aboutsummaryrefslogtreecommitdiffstats
path: root/package/button-hotplug/src/Makefile
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2011-10-24 21:49:21 +0000
committerGabor Juhos <juhosg@openwrt.org>2011-10-24 21:49:21 +0000
commit5333794b364544dbd0249f4570a99b283b05843a (patch)
treeda53c239011c52ce8e8e718fcdc7d85384362014 /package/button-hotplug/src/Makefile
parentab0f50a4215bc26d4bfe4994507d25247e46a7dd (diff)
downloadupstream-5333794b364544dbd0249f4570a99b283b05843a.tar.gz
upstream-5333794b364544dbd0249f4570a99b283b05843a.tar.bz2
upstream-5333794b364544dbd0249f4570a99b283b05843a.zip
ar71xx: add kernel support for the Allnet ALL0258N board
This patchs adds support for the Allnet ALL0258N outdoor AP/bridge. The ALL0258N is based on the AR7240 SoC paired with an AR9285 radio, it got 8MB of NOR and 32MB SDRAM. Signed-off-by: Daniel Golle <dgolle@allnet.de> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@28564 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/button-hotplug/src/Makefile')
0 files changed, 0 insertions, 0 deletions
n142' href='#n142'>142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
import React from "react"
import ReactDOM from "react-dom"
import {Key} from "../utils.js";
import _ from "lodash"

export var Splitter = React.createClass({
    getDefaultProps: function () {
        return {
            axis: "x"
        };
    },
    getInitialState: function () {
        return {
            applied: false,
            startX: false,
            startY: false
        };
    },
    onMouseDown: function (e) {
        this.setState({
            startX: e.pageX,
            startY: e.pageY
        });
        window.addEventListener("mousemove", this.onMouseMove);
        window.addEventListener("mouseup", this.onMouseUp);
        // Occasionally, only a dragEnd event is triggered, but no mouseUp.
        window.addEventListener("dragend", this.onDragEnd);
    },
    onDragEnd: function () {
        ReactDOM.findDOMNode(this).style.transform = "";
        window.removeEventListener("dragend", this.onDragEnd);
        window.removeEventListener("mouseup", this.onMouseUp);
        window.removeEventListener("mousemove", this.onMouseMove);
    },
    onMouseUp: function (e) {
        this.onDragEnd();

        var node = ReactDOM.findDOMNode(this);
        var prev = node.previousElementSibling;
        var next = node.nextElementSibling;

        var dX = e.pageX - this.state.startX;
        var dY = e.pageY - this.state.startY;
        var flexBasis;
        if (this.props.axis === "x") {
            flexBasis = prev.offsetWidth + dX;
        } else {
            flexBasis = prev.offsetHeight + dY;
        }

        prev.style.flex = "0 0 " + Math.max(0, flexBasis) + "px";
        next.style.flex = "1 1 auto";

        this.setState({
            applied: true
        });
        this.onResize();
    },
    onMouseMove: function (e) {
        var dX = 0, dY = 0;
        if (this.props.axis === "x") {
            dX = e.pageX - this.state.startX;
        } else {
            dY = e.pageY - this.state.startY;
        }
        ReactDOM.findDOMNode(this).style.transform = "translate(" + dX + "px," + dY + "px)";
    },
    onResize: function () {
        // Trigger a global resize event. This notifies components that employ virtual scrolling
        // that their viewport may have changed.
        window.setTimeout(function () {
            window.dispatchEvent(new CustomEvent("resize"));
        }, 1);
    },
    reset: function (willUnmount) {
        if (!this.state.applied) {
            return;
        }
        var node = ReactDOM.findDOMNode(this);
        var prev = node.previousElementSibling;
        var next = node.nextElementSibling;

        prev.style.flex = "";
        next.style.flex = "";

        if (!willUnmount) {
            this.setState({
                applied: false
            });
        }
        this.onResize();
    },
    componentWillUnmount: function () {
        this.reset(true);
    },
    render: function () {
        var className = "splitter";
        if (this.props.axis === "x") {
            className += " splitter-x";
        } else {
            className += " splitter-y";
        }
        return (
            <div className={className}>
                <div onMouseDown={this.onMouseDown} draggable="true"></div>
            </div>
        );
    }
});

export const ToggleButton = (props) =>
    <div className="input-group toggle-btn">
        <div
        className={"btn " + (props.checked ? "btn-primary" : "btn-default")}
        onClick={props.onToggleChanged}>
        <span className={"fa " + (props.checked ? "fa-check-square-o" : "fa-square-o")}>&nbsp;{props.name}</span>
        </div>
    </div>;

ToggleButton.propTypes = {
    name: React.PropTypes.string.isRequired,
    onToggleChanged: React.PropTypes.func.isRequired
};

export class ToggleInputButton extends React.Component {
    constructor(props) {
        super(props);
        this.state = {txt: props.txt};
    }

    render() {
        return (
            <div className="input-group toggle-input-btn">
                <span
                    className="input-group-btn"
                    onClick={() => this.props.onToggleChanged(this.state.txt)}>
                    <div className={"btn  " + (this.props.checked ? "btn-primary" : "btn-default")}>
                        <span className={"fa " + (this.props.checked ? "fa-check-square-o" : "fa-square-o")}/>
                        &nbsp;{this.props.name}
                    </div>
                </span>
                <input
                    className="form-control"
                    placeholder={this.props.placeholder}
                    disabled={this.props.checked}
                    value={this.state.txt}
                    type={this.props.inputType}
                    onChange={e => this.setState({txt: e.target.value})}
                    onKeyDown={e => {if (e.keyCode === Key.ENTER) this.props.onToggleChanged(this.state.txt); e.stopPropagation()}}/>
            </div>
        );
    }
}

ToggleInputButton.propTypes = {
    name: React.PropTypes.string.isRequired,
    txt: React.PropTypes.string.isRequired,
    onToggleChanged: React.PropTypes.func.isRequired
};