Example #1
0
    var AboutView = (function () {

        var _super = Extend(AboutView, DOMElement);

        function AboutView() {
            _super.call(this);
        }

        /**
         * @overridden DOMElement.createChildren
         */
        AboutView.prototype.createChildren = function () {
            _super.prototype.createChildren.call(this, AboutTemplate);

            // Create and add your child objects to this parent class.
        };

        /**
         * @overridden DOMElement.layoutChildren
         */
        AboutView.prototype.layoutChildren = function () {
            // Layout or update the child objects in this parent class.

            return this;
        };

        /**
         * @overridden DOMElement.enable
         */
        AboutView.prototype.enable = function () {
            if (this.isEnabled === true) { return this; }

            // Enable the child objects and add any event listeners.

            return _super.prototype.enable.call(this);
        };

        /**
         * @overridden DOMElement.disable
         */
        AboutView.prototype.disable = function () {
            if (this.isEnabled === false) { return this; }

            // Disable the child objects and remove any event listeners.

            return _super.prototype.disable.call(this);
        };

        /**
         * @overridden DOMElement.destroy
         */
        AboutView.prototype.destroy = function () {
            // Call destroy on any child objects that is need.
            // This super method will also null out all properties automatically to prevent memory leaks.

            _super.prototype.destroy.call(this);
        };

        return AboutView;
    })();
Example #2
0
    var GameVO = (function () {

        var _super = Extend(GameVO, ValueObject);

        function GameVO(data) {
            _super.call(this);

            /**
             * TODO: YUIDoc_comment
             *
             * @property buttonIndex
             * @type {int}
             * @public
             */
            this.buttonIndex = null;

            if (data) {
                this.update(data);
            }
        }

        /**
         * @overridden ValueObject.update
         */
        GameVO.prototype.update = function (data) {
            this.buttonIndex = data.buttonIndex;
        };

        /**
         * @overridden ValueObject.copy
         */
        GameVO.prototype.copy = function () {
            var data = _super.prototype.copy();
            return new GameVO(data);
        };

        return GameVO;
    })();
Example #3
0
    var DeviceButton = (function () {

        var _super = Extend(DeviceButton, DOMElement);

        function DeviceButton(color, index) {
            _super.call(this);

            /**
             * @property _color
             * @type {string}
             * @private
             */
            this._color = color;

            /**
             * @property _indexId
             * @type {number}
             * @public
             */
            this._indexId = index;
        }

        /**
         * @overridden DOMElement.createChildren
         */
        DeviceButton.prototype.createChildren = function () {
            _super.prototype.createChildren.call(this, DeviceButtonTemplate, {buttonColor: this._color});// Example of passing a template in.

        };

        /**
         * @overridden DOMElement.layoutChildren
         */
        DeviceButton.prototype.layoutChildren = function () {
            // Layout or update the child objects in this parent class.

            return this;
        };

        /**
         * @overridden DOMElement.enable
         */
        DeviceButton.prototype.enable = function () {
            if (this.isEnabled === true) { return this; }

            this.$element.addEventListener('click', this._onClick, this);
            this.$element.css('cursor','pointer');

            return _super.prototype.enable.call(this);
        };

        /**
         * @overridden DOMElement.disable
         */
        DeviceButton.prototype.disable = function () {
            if (this.isEnabled === false) { return this; }

            this.$element.removeEventListener('click', this._onClick, this);
            this.$element.css('cursor','default');

            return _super.prototype.disable.call(this);
        };

        /**
         * @overridden DOMElement.destroy
         */
        DeviceButton.prototype.destroy = function () {
            _super.prototype.destroy.call(this);

        };

        /**
         * A helper method to trigger the CSS transitions.
         *
         * @method animate
         * @public
         */
        DeviceButton.prototype.animate = function () {
            this.$element.addClass('active');

            setTimeout(function() {
                this.$element.removeClass('active');
            }.bind(this), 250);
        };

        /**
         * On click of the button it will animate itself and dispatch an event so the SimonApp
         * can respond to the CHANGE event. Probably should of create and dispatched a custom event.
         *
         * @method _onClick
         * @param event {jQueryEventObject}
         * @private
         */
        DeviceButton.prototype._onClick = function (event) {
            event.preventDefault();

            this.animate();

            var gameVO = new GameVO();
            gameVO.buttonIndex = this._indexId;

            this.dispatchEvent(new BaseEvent(BaseEvent.CHANGE, true, true, gameVO));
        };

        return DeviceButton;
    })();
Example #4
0
    var WebsiteApp = (function () {

        var _super = Extend(WebsiteApp, Stage);

        function WebsiteApp() {
            _super.call(this);

            /**
             * The root view controls the main display area for this app.
             *
             * @property _rootView
             * @type {RootView}
             * @private
             */
            this._rootView = null;
        }

        /**
         * @overridden DOMElement.createChildren
         */
        WebsiteApp.prototype.createChildren = function () {
            _super.prototype.createChildren.call(this);

            this._rootView = new RootView();
            this.addChild(this._rootView);
        };

        /**
         * @overridden DOMElement.layoutChildren
         */
        WebsiteApp.prototype.layoutChildren = function () {
            // Layout or update the child objects in this parent class.

            return this;
        };

        /**
         * @overridden DOMElement.enable
         */
        WebsiteApp.prototype.enable = function () {
            if (this.isEnabled === true) { return this; }

            NetworkMonitor.addEventListener(NetworkMonitorEvent.STATUS, this._onNetworkChange, this);
            NetworkMonitor.start();

            return _super.prototype.enable.call(this);
        };

        /**
         * @overridden DOMElement.disable
         */
        WebsiteApp.prototype.disable = function () {
            if (this.isEnabled === false) { return this; }

            NetworkMonitor.removeEventListener(NetworkMonitorEvent.STATUS, this._onNetworkChange, this);

            return _super.prototype.disable.call(this);
        };

        /**
         * @overridden DOMElement.destroy
         */
        WebsiteApp.prototype.destroy = function () {
            this._rootView.destroy();

            _super.prototype.destroy.call(this);
        };

        /**
         * TODO: YUIDoc_comment
         *
         * @method _onNetworkChange
         * @param event {NetworkMonitorEvent}
         * @private
         */
        WebsiteApp.prototype._onNetworkChange = function(event) {
            console.log("NetworkMonitorEvent.STATUS", event.status);
        };

        return WebsiteApp;
    })();