<commit_before>/**
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * org.apache.flex.charts.core.IChart
 *
 * @fileoverview
 *
 * @suppress {checkTypes}
 */

goog.provide('org.apache.flex.charts.core.ChartBase');

goog.require('org.apache.flex.charts.core.IChart');
goog.require('org.apache.flex.events.Event');
goog.require('org.apache.flex.html.List');

/**
 * @constructor
 * @extends {org.apache.flex.html.List}
 * @implements {org.apache.flex.charts.core.IChart}
 */
org.apache.flex.charts.core.ChartBase =
    function() {
  goog.base(this);
  this.className = 'ChartBase';
};
goog.inherits(
    org.apache.flex.charts.core.ChartBase,
    org.apache.flex.html.List);

/**
 * Metadata
 *
 * @type {Object.<string, Array.<Object>>}
 */
org.apache.flex.charts.core.ChartBase.prototype.FLEXJS_CLASS_INFO = {
    names: [{ name: 'ChartBase', qName: 'org.apache.flex.charts.core.ChartBase'}]
  };

/**
 * @private
 * @type {Array}
 */
org.apache.flex.charts.core.ChartBase.prototype.series_ = null;

/**
 * @expose
 * @return {Array} The series for the chart.
 */
org.apache.flex.charts.core.ChartBase.prototype.get_series = function() {
  return this.series_;
};

/**
 * @expose
 * @param {Array} value The series for the chart.
 */
org.apache.flex.charts.core.ChartBase.prototype.set_series = function(value) {
  this.series_ = value;
  this.dispatchEvent(new org.apache.flex.events.Event('seriesChanged'));
};
<commit_msg>Removed the border and scrollbars from JS charts.<commit_after>/**
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * org.apache.flex.charts.core.IChart
 *
 * @fileoverview
 *
 * @suppress {checkTypes}
 */

goog.provide('org.apache.flex.charts.core.ChartBase');

goog.require('org.apache.flex.charts.core.IChart');
goog.require('org.apache.flex.events.Event');
goog.require('org.apache.flex.html.List');

/**
 * @constructor
 * @extends {org.apache.flex.html.List}
 * @implements {org.apache.flex.charts.core.IChart}
 */
org.apache.flex.charts.core.ChartBase =
    function() {
  goog.base(this);
  this.className = 'ChartBase';
};
goog.inherits(
    org.apache.flex.charts.core.ChartBase,
    org.apache.flex.html.List);

/**
 * Metadata
 *
 * @type {Object.<string, Array.<Object>>}
 */
org.apache.flex.charts.core.ChartBase.prototype.FLEXJS_CLASS_INFO = {
    names: [{ name: 'ChartBase', qName: 'org.apache.flex.charts.core.ChartBase'}]
  };

/**
 * @override
 */
org.apache.flex.charts.core.ChartBase.prototype.createElement = function() {
    org.apache.flex.charts.core.ChartBase.base(this, 'createElement');
    this.element.style.border = 'none';
    this.element.style.overflow = 'visible';
};

/**
 * @private
 * @type {Array}
 */
org.apache.flex.charts.core.ChartBase.prototype.series_ = null;

/**
 * @expose
 * @return {Array} The series for the chart.
 */
org.apache.flex.charts.core.ChartBase.prototype.get_series = function() {
  return this.series_;
};

/**
 * @expose
 * @param {Array} value The series for the chart.
 */
org.apache.flex.charts.core.ChartBase.prototype.set_series = function(value) {
  this.series_ = value;
  this.dispatchEvent(new org.apache.flex.events.Event('seriesChanged'));
};
<|endoftext|>


<commit_before>/*
 * MelonJS Game Engine
 * Copyright (C) 2011 - 2013 melonJS
 * http://www.melonjs.org
 *
 */
(function(window) {

	/**
	 * A singleton object representing the device capabilities and specific events
	 * @namespace me.device
	 * @memberOf me
	 */
	me.device = (function() {

		// defines object for holding public information/functionality.
		var obj = {};
		// private properties
		var accelInitialized = false;
		var deviceOrientationInitialized = false;
		var devicePixelRatio = null;

		/**
		 * check the device capapbilities
		 * @ignore
		 */
		obj._check = function() {

			// detect audio capabilities (should be moved here too)
			me.audio.detectCapabilities();

			// future proofing (MS) feature detection
			navigator.pointerEnabled = navigator.pointerEnabled || navigator.msPointerEnabled;
			navigator.maxTouchPoints = navigator.maxTouchPoints || navigator.msMaxTouchPoints || 0;
			window.gesture = window.gesture || window.MSGesture;

			// detect touch capabilities
			me.device.touch = ('createTouch' in document) || ('ontouchstart' in window) ||
							  (navigator.isCocoonJS) || (navigator.maxTouchPoints > 0);

			// detect platform
			me.device.isMobile = me.device.ua.match(/Android|iPhone|iPad|iPod|BlackBerry|Windows Phone|Mobi/i);

			// accelerometer detection
			me.device.hasAccelerometer = (
				(typeof (window.DeviceMotionEvent) !== 'undefined') || (
					(typeof (window.Windows) !== 'undefined') &&
					(typeof (Windows.Devices.Sensors.Accelerometer) === 'function')
				)
			);

			// pointerlock detection
			this.hasPointerLockSupport = 'pointerLockElement' in document || 'mozPointerLockElement' in document || 'webkitPointerLockElement' in document;
			if(this.hasPointerLockSupport) {
				document.body.requestPointerLock = document.body.requestPointerLock || document.body.mozRequestPointerLock || document.body.webkitRequestPointerLock;
				document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock || document.webkitExitPointerLock;
			}

			// device motion detection
			if (window.DeviceOrientationEvent) {
				me.device.hasDeviceOrientation = true;
			}

			// fullscreen api detection
			document.body.requestFullscreen = document.body.requestFullscreen || document.body.mozRequestFullScreen || document.body.webkitRequestFullscreen;
			this.hasFullScreenSupport = document.body.requestFullscreen !== null && typeof document.body.requestFullscreen === 'function';
			if(this.hasFullScreenSupport) {
				document.cancelFullScreen = document.cancelFullScreen || document.mozCancelFullScreen || document.webkitCancelFullScreen;
			}

			me.device.HighResTimer = (typeof window.performance !== 'undefined') &&
				(typeof window.performance.now !== 'undefined');

			try {
				obj.localStorage = !!window.localStorage;
			} catch (e) {
				// the above generates an exception when cookies are blocked
				obj.localStorage = false;
			}
		};

		// ----- PUBLIC Properties & Functions -----

		// Browser capabilities

        /**
		 * High Resolution timer (typically performance.now)
		 * @type Boolean
         * @readonly
		 * @name HighResTimer
		 * @memberOf me.device
         * @see https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/HighResolutionTime/Overview.html
		 */
		obj.HighResTimer = false;

		/**
		 * Browser User Agent
		 * @type Boolean
         * @readonly
		 * @name ua
		 * @memberOf me.device
		 */
		obj.ua = navigator.userAgent;
		/**
		 * Browser Audio capabilities
		 * @type Boolean
         * @readonly
		 * @name sound
		 * @memberOf me.device
		 */
		obj.sound = false;
		/**
		 * Browser Local Storage capabilities

		 * (this flag will be set to false if cookies are blocked)
		 * @type Boolean
         * @readonly
		 * @name localStorage
		 * @memberOf me.device
		 */
		obj.localStorage = false;
		/**
		 * Browser accelerometer capabilities
		 * @type Boolean
         * @readonly
		 * @name hasAccelerometer
		 * @memberOf me.device
		 */
		obj.hasAccelerometer = false;

		/**
		 * Browser device orientation
		 * @type Boolean
         * @readonly
		 * @name hasDeviceOrientation
		 * @memberOf me.device
		 */
		obj.hasDeviceOrientation = false;

		/**
		 * Browser full screen support
		 * @type Boolean
		 		 * @readonly
		 * @name hasFullScreenSupport
		 * @memberOf me.device
		 */
		 obj.hasFullScreenSupport = false;

		 /**
		 * Browser pointerlock api support
		 * @type Boolean
		 		 * @readonly
		 * @name hasPointerLockSupport
		 * @memberOf me.device
		 */
		 obj.hasPointerLockSupport = false;

		/**
		 * Browser Base64 decoding capability
		 * @type Boolean
         * @readonly
		 * @name nativeBase64
		 * @memberOf me.device
		 */
		obj.nativeBase64 = (typeof(window.atob) === 'function');

		/**
		 * Touch capabilities
		 * @type Boolean
         * @readonly
		 * @name touch
		 * @memberOf me.device
		 */
		obj.touch = false;

		/**
		 * equals to true if a mobile device

		 * (Android | iPhone | iPad | iPod | BlackBerry | Windows Phone)
		 * @type Boolean
         * @readonly
		 * @name isMobile
		 * @memberOf me.device
		 */
		obj.isMobile = false;

        /**
         * The device current orientation status.

         *   0 : default orientation

         *  90 : 90 degrees clockwise from default

         * -90 : 90 degrees anti-clockwise from default

         * 180 : 180 degrees from default
         * @type Number
         * @readonly
         * @name orientation
         * @memberOf me.device
         */
        obj.orientation = 0;

		/**
		 * contains the g-force acceleration along the x-axis.
		 * @public
		 * @type Number
         * @readonly
		 * @name accelerationX
		 * @memberOf me.device
		 */
		obj.accelerationX = 0;

		/**
		 * contains the g-force acceleration along the y-axis.
		 * @public
		 * @type Number
         * @readonly
		 * @name accelerationY
		 * @memberOf me.device
		 */
		obj.accelerationY = 0;

		/**
		 * contains the g-force acceleration along the z-axis.
		 * @public
		 * @type Number
         * @readonly
		 * @name accelerationZ
		 * @memberOf me.device
		 */
		obj.accelerationZ = 0;

		/**
		 * Device orientation Gamma property. Gives angle on tilting a portrait held phone left or right
		 * @public
		 * @type Number
         * @readonly
		 * @name gamma
		 * @memberOf me.device
		 */
		obj.gamma = 0;

		/**
		 * Device orientation Beta property. Gives angle on tilting a portrait held phone forward or backward
		 * @public
		 * @type Number
         * @readonly
		 * @name beta
		 * @memberOf me.device
		 */
		obj.beta = 0;

		/**
		 * Device orientation Alpha property. Gives angle based on the rotation of the phone around its z axis.
		 * The z-axis is perpendicular to the phone, facing out from the center of the screen.
		 * @public
		 * @type Number
         * @readonly
		 * @name alpha
		 * @memberOf me.device
		 */
		obj.alpha = 0;

		/**
		 * Triggers fullscreen request. Requires fullscreen support from the browser/device. Must be called in a click event
		 * or an event that requires user interaction.
		 * If you need to utilize event handlers around the fullscreen changing, use as per example below
		 * @name enterFullScreen
		 * @memberOf me.device
		 * @function
		 * @example
		 *   document.addEventListener( 'fullscreenchange', fullscreenchange, false );
     *   document.addEventListener( 'mozfullscreenchange', fullscreenchange, false );
		 */
		obj.enterFullScreen = function() {
			if(this.hasFullScreenSupport) {
				document.body.requestFullscreen();
			}
		}

		/**
		 * Exit fullscreen mode. Requires fullscreen support from the browser/device.
		 * @name exitFullScreen
		 * @memberOf me.device
		 * @function
		 */
		obj.exitFullScreen = function() {
			if(this.hasFullScreenSupport) {
				document.cancelFullScreen();
			}
		}

		/**
		 * return the device pixel ratio
		 * @name getPixelRatio
		 * @memberOf me.device
		 * @function
		 */
		obj.getPixelRatio = function() {

			if (devicePixelRatio===null) {
				var _context = me.video.getScreenContext();
				var _devicePixelRatio = window.devicePixelRatio || 1,
					_backingStoreRatio = _context.webkitBackingStorePixelRatio ||
					_context.mozBackingStorePixelRatio ||
					_context.msBackingStorePixelRatio ||
					_context.oBackingStorePixelRatio ||
					_context.backingStorePixelRatio || 1;
				devicePixelRatio = _devicePixelRatio / _backingStoreRatio;
			}
			return devicePixelRatio;
		};

		/**
		 * return the device storage
		 * @name getStorage
		 * @memberOf me.device
		 * @function
		 * @param {String} [type="local"]
		 * @return me.save object
		 */
		obj.getStorage = function(type) {

			type = type || "local";

			switch (type) {
				case "local" :
					return me.save;

				default :
					break;
			}
			throw "melonJS : storage type " + type + " not supported";
		};

		/**
		 * event management (Accelerometer)
		 * http://www.mobilexweb.com/samples/ball.html
		 * http://www.mobilexweb.com/blog/safari-ios-accelerometer-websockets-html5
		 * @ignore
		 */
		function onDeviceMotion(e) {
			if (e.reading) {
				// For Windows 8 devices
				obj.accelerationX = e.reading.accelerationX;
				obj.accelerationY = e.reading.accelerationY;
				obj.accelerationZ = e.reading.accelerationZ;
			} else {
				// Accelerometer information
				obj.accelerationX = e.accelerationIncludingGravity.x;
				obj.accelerationY = e.accelerationIncludingGravity.y;
				obj.accelerationZ = e.accelerationIncludingGravity.z;
			}
		}

		function onDeviceRotate(e) {
			obj.gamma = e.gamma;
			obj.beta = e.beta;
			obj.alpha = e.alpha;
		}

		/**
		 * Enters pointer lock, requesting it from the user first. Works on supported devices & browsers
		 * Must be called in a click event or an event that requires user interaction.
		 * If you need to run handle events for errors or change of the pointer lock, see below.
		 * @name turnOnPointerLock
		 * @memberOf me.device
		 * @function
		 * @example
		 *   document.addEventListener( 'pointerlockchange', pointerlockchange, false );
     *   document.addEventListener( 'mozpointerlockchange', pointerlockchange, false );
     *   document.addEventListener( 'webkitpointerlockchange', pointerlockchange, false );
     *
     *   document.addEventListener( 'pointerlockerror', pointerlockerror, false );
     *   document.addEventListener( 'mozpointerlockerror', pointerlockerror, false );
     *   document.addEventListener( 'webkitpointerlockerror', pointerlockerror, false );
		 */
		obj.turnOnPointerLock = function() {
			if(this.hasPointerLockSupport) {
				var element = document.body;
				if (/Firefox/i.test(navigator.userAgent)) {
					function fullscreenchange (event) {
						if (document.fullscreenElement === element || document.mozFullscreenElement === element || document.mozFullScreenElement === element ) {
							document.removeEventListener( 'fullscreenchange', fullscreenchange );
							document.removeEventListener( 'mozfullscreenchange', fullscreenchange );
							element.requestPointerLock();
						}
					}

					document.addEventListener( 'fullscreenchange', fullscreenchange, false );
					document.addEventListener( 'mozfullscreenchange', fullscreenchange, false );

					element.requestFullscreen();

				} else {
					element.requestPointerLock();
				}
			}
		}

		/**
		 * Exits pointer lock. Works on supported devices & browsers
		 * @name turnOffPointerLock
		 * @memberOf me.device
		 * @function
		 */
		obj.turnOffPointerLock = function() {
			if(this.hasPointerLockSupport) {
				document.exitPointerLock();
			}
		}

		/**
		 * watch Accelerator event
		 * @name watchAccelerometer
		 * @memberOf me.device
		 * @public
		 * @function
		 * @return {Boolean} false if not supported by the device
		 */
		obj.watchAccelerometer = function () {
			if (me.device.hasAccelerometer) {
				if (!accelInitialized) {
					if (typeof Windows === 'undefined') {
						// add a listener for the devicemotion event
						window.addEventListener('devicemotion', onDeviceMotion, false);
					} else {
						// On Windows 8 Device
						var accelerometer = Windows.Devices.Sensors.Accelerometer.getDefault();
						if (accelerometer) {
							// Capture event at regular intervals
							var minInterval = accelerometer.minimumReportInterval;
							var Interval = minInterval >= 16 ? minInterval : 25;
							accelerometer.reportInterval = Interval;

							accelerometer.addEventListener('readingchanged', onDeviceMotion, false);
						}
					}
					accelInitialized = true;
				}
				return true;
			}
			return false;
		};

		/**
		 * unwatch Accelerometor event
		 * @name unwatchAccelerometer
		 * @memberOf me.device
		 * @public
		 * @function
		 */
		obj.unwatchAccelerometer = function() {
			if (accelInitialized) {
				if (typeof Windows === 'undefined') {
					// add a listener for the mouse
					window.removeEventListener('devicemotion', onDeviceMotion, false);
				} else {
					// On Windows 8 Devices
					var accelerometer = Windows.Device.Sensors.Accelerometer.getDefault();

					accelerometer.removeEventListener('readingchanged', onDeviceMotion, false);
				}
				accelInitialized = false;
			}
		};

		/**
		 * watch the device orientation event
		 * @name watchDeviceOrientation
		 * @memberOf me.device
		 * @public
		 * @function
		 * @return {Boolean} false if not supported by the device
		 */
		obj.watchDeviceOrientation = function() {
			if(me.device.hasDeviceOrientation && !deviceOrientationInitialized) {
				window.addEventListener('deviceorientation', onDeviceRotate, false);
				deviceOrientationInitialized = true;
			}
			return false;
		};

		/**
		 * unwatch Device orientation event
		 * @name unwatchDeviceOrientation
		 * @memberOf me.device
		 * @public
		 * @function
		 */
		obj.unwatchDeviceOrientation = function() {
			if(deviceOrientationInitialized) {
				window.removeEventListener('deviceorientation', onDeviceRotate, false);
				deviceOrientationInitialized = false;
			}
		};

		return obj;
	})();
})(window);
<commit_msg>re-arranged the code to be more eye-friendly<commit_after>/*
 * MelonJS Game Engine
 * Copyright (C) 2011 - 2013 melonJS
 * http://www.melonjs.org
 *
 */
(function(window) {

    /**
     * A singleton object representing the device capabilities and specific events
     * @namespace me.device
     * @memberOf me
     */
    me.device = (function() {

        // defines object for holding public information/functionality.
        var obj = {};
        // private properties
        var accelInitialized = false;
        var deviceOrientationInitialized = false;
        var devicePixelRatio = null;

        /**
         * check the device capapbilities
         * @ignore
         */
        obj._check = function() {

            // detect audio capabilities (should be moved here too)
            me.audio.detectCapabilities();

            // future proofing (MS) feature detection
            navigator.pointerEnabled = navigator.pointerEnabled || navigator.msPointerEnabled;
            navigator.maxTouchPoints = navigator.maxTouchPoints || navigator.msMaxTouchPoints || 0;
            window.gesture = window.gesture || window.MSGesture;

            // detect touch capabilities
            me.device.touch = ('createTouch' in document) || ('ontouchstart' in window) ||
                              (navigator.isCocoonJS) || (navigator.maxTouchPoints > 0);

            // detect platform
            me.device.isMobile = me.device.ua.match(/Android|iPhone|iPad|iPod|BlackBerry|Windows Phone|Mobi/i);

            // accelerometer detection
            me.device.hasAccelerometer = (
                (typeof (window.DeviceMotionEvent) !== 'undefined') || (
                    (typeof (window.Windows) !== 'undefined') &&
                    (typeof (Windows.Devices.Sensors.Accelerometer) === 'function')
                )
            );

            // pointerlock detection
            this.hasPointerLockSupport = 'pointerLockElement' in document ||
                                         'mozPointerLockElement' in document ||
                                         'webkitPointerLockElement' in document;

            if(this.hasPointerLockSupport) {
                document.body.requestPointerLock = document.body.requestPointerLock ||
                                                   document.body.mozRequestPointerLock ||
                                                   document.body.webkitRequestPointerLock;

                document.exitPointerLock = document.exitPointerLock ||
                                           document.mozExitPointerLock ||
                                           document.webkitExitPointerLock;
            }

            // device motion detection
            if (window.DeviceOrientationEvent) {
                me.device.hasDeviceOrientation = true;
            }

            // fullscreen api detection
            document.body.requestFullscreen = document.body.requestFullscreen ||
                                              document.body.mozRequestFullScreen ||
                                              document.body.webkitRequestFullscreen;

            this.hasFullScreenSupport = document.body.requestFullscreen !== null && typeof document.body.requestFullscreen === 'function';

            if(this.hasFullScreenSupport) {
                document.cancelFullScreen = document.cancelFullScreen ||
                                            document.mozCancelFullScreen ||
                                            document.webkitCancelFullScreen;
            }

            me.device.HighResTimer = (typeof window.performance !== 'undefined') &&
                                     (typeof window.performance.now !== 'undefined');

            try {
                obj.localStorage = !!window.localStorage;
            } catch (e) {
                // the above generates an exception when cookies are blocked
                obj.localStorage = false;
            }
        };

        // ----- PUBLIC Properties & Functions -----

        // Browser capabilities

        /**
         * High Resolution timer (typically performance.now)
         * @type Boolean
         * @readonly
         * @name HighResTimer
         * @memberOf me.device
         * @see https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/HighResolutionTime/Overview.html
         */
        obj.HighResTimer = false;

        /**
         * Browser User Agent
         * @type Boolean
         * @readonly
         * @name ua
         * @memberOf me.device
         */
        obj.ua = navigator.userAgent;
        /**
         * Browser Audio capabilities
         * @type Boolean
         * @readonly
         * @name sound
         * @memberOf me.device
         */
        obj.sound = false;
        /**
         * Browser Local Storage capabilities

         * (this flag will be set to false if cookies are blocked)
         * @type Boolean
         * @readonly
         * @name localStorage
         * @memberOf me.device
         */
        obj.localStorage = false;
        /**
         * Browser accelerometer capabilities
         * @type Boolean
         * @readonly
         * @name hasAccelerometer
         * @memberOf me.device
         */
        obj.hasAccelerometer = false;

        /**
         * Browser device orientation
         * @type Boolean
         * @readonly
         * @name hasDeviceOrientation
         * @memberOf me.device
         */
        obj.hasDeviceOrientation = false;

        /**
         * Browser full screen support
         * @type Boolean
         * @readonly
         * @name hasFullScreenSupport
         * @memberOf me.device
         */
         obj.hasFullScreenSupport = false;

         /**
         * Browser pointerlock api support
         * @type Boolean
         * @readonly
         * @name hasPointerLockSupport
         * @memberOf me.device
         */
         obj.hasPointerLockSupport = false;

        /**
         * Browser Base64 decoding capability
         * @type Boolean
         * @readonly
         * @name nativeBase64
         * @memberOf me.device
         */
        obj.nativeBase64 = (typeof(window.atob) === 'function');

        /**
         * Touch capabilities
         * @type Boolean
         * @readonly
         * @name touch
         * @memberOf me.device
         */
        obj.touch = false;

        /**
         * equals to true if a mobile device

         * (Android | iPhone | iPad | iPod | BlackBerry | Windows Phone)
         * @type Boolean
         * @readonly
         * @name isMobile
         * @memberOf me.device
         */
        obj.isMobile = false;

        /**
         * The device current orientation status.

         *   0 : default orientation

         *  90 : 90 degrees clockwise from default

         * -90 : 90 degrees anti-clockwise from default

         * 180 : 180 degrees from default
         * @type Number
         * @readonly
         * @name orientation
         * @memberOf me.device
         */
        obj.orientation = 0;

        /**
         * contains the g-force acceleration along the x-axis.
         * @public
         * @type Number
         * @readonly
         * @name accelerationX
         * @memberOf me.device
         */
        obj.accelerationX = 0;

        /**
         * contains the g-force acceleration along the y-axis.
         * @public
         * @type Number
         * @readonly
         * @name accelerationY
         * @memberOf me.device
         */
        obj.accelerationY = 0;

        /**
         * contains the g-force acceleration along the z-axis.
         * @public
         * @type Number
         * @readonly
         * @name accelerationZ
         * @memberOf me.device
         */
        obj.accelerationZ = 0;

        /**
         * Device orientation Gamma property. Gives angle on tilting a portrait held phone left or right
         * @public
         * @type Number
         * @readonly
         * @name gamma
         * @memberOf me.device
         */
        obj.gamma = 0;

        /**
         * Device orientation Beta property. Gives angle on tilting a portrait held phone forward or backward
         * @public
         * @type Number
         * @readonly
         * @name beta
         * @memberOf me.device
         */
        obj.beta = 0;

        /**
         * Device orientation Alpha property. Gives angle based on the rotation of the phone around its z axis.
         * The z-axis is perpendicular to the phone, facing out from the center of the screen.
         * @public
         * @type Number
         * @readonly
         * @name alpha
         * @memberOf me.device
         */
        obj.alpha = 0;

        /**
         * Triggers fullscreen request. Requires fullscreen support from the browser/device. Must be called in a click event
         * or an event that requires user interaction.
         * If you need to utilize event handlers around the fullscreen changing, use as per example below
         * @name enterFullScreen
         * @memberOf me.device
         * @function
         * @example
         *   document.addEventListener( 'fullscreenchange', fullscreenchange, false );
         *   document.addEventListener( 'mozfullscreenchange', fullscreenchange, false );
         */
        obj.enterFullScreen = function() {
            if(this.hasFullScreenSupport) {
                document.body.requestFullscreen();
            }
        }

        /**
         * Exit fullscreen mode. Requires fullscreen support from the browser/device.
         * @name exitFullScreen
         * @memberOf me.device
         * @function
         */
        obj.exitFullScreen = function() {
            if(this.hasFullScreenSupport) {
                document.cancelFullScreen();
            }
        }

        /**
         * return the device pixel ratio
         * @name getPixelRatio
         * @memberOf me.device
         * @function
         */
        obj.getPixelRatio = function() {

            if (devicePixelRatio===null) {
                var _context = me.video.getScreenContext();
                var _devicePixelRatio = window.devicePixelRatio || 1,
                    _backingStoreRatio = _context.webkitBackingStorePixelRatio ||
                    _context.mozBackingStorePixelRatio ||
                    _context.msBackingStorePixelRatio ||
                    _context.oBackingStorePixelRatio ||
                    _context.backingStorePixelRatio || 1;
                devicePixelRatio = _devicePixelRatio / _backingStoreRatio;
            }
            return devicePixelRatio;
        };

        /**
         * return the device storage
         * @name getStorage
         * @memberOf me.device
         * @function
         * @param {String} [type="local"]
         * @return me.save object
         */
        obj.getStorage = function(type) {

            type = type || "local";

            switch (type) {
                case "local" :
                    return me.save;

                default :
                    break;
            }
            throw "melonJS : storage type " + type + " not supported";
        };

        /**
         * event management (Accelerometer)
         * http://www.mobilexweb.com/samples/ball.html
         * http://www.mobilexweb.com/blog/safari-ios-accelerometer-websockets-html5
         * @ignore
         */
        function onDeviceMotion(e) {
            if (e.reading) {
                // For Windows 8 devices
                obj.accelerationX = e.reading.accelerationX;
                obj.accelerationY = e.reading.accelerationY;
                obj.accelerationZ = e.reading.accelerationZ;
            } else {
                // Accelerometer information
                obj.accelerationX = e.accelerationIncludingGravity.x;
                obj.accelerationY = e.accelerationIncludingGravity.y;
                obj.accelerationZ = e.accelerationIncludingGravity.z;
            }
        }

        function onDeviceRotate(e) {
            obj.gamma = e.gamma;
            obj.beta = e.beta;
            obj.alpha = e.alpha;
        }

        /**
         * Enters pointer lock, requesting it from the user first. Works on supported devices & browsers
         * Must be called in a click event or an event that requires user interaction.
         * If you need to run handle events for errors or change of the pointer lock, see below.
         * @name turnOnPointerLock
         * @memberOf me.device
         * @function
         * @example
         *   document.addEventListener( 'pointerlockchange', pointerlockchange, false );
         *   document.addEventListener( 'mozpointerlockchange', pointerlockchange, false );
         *   document.addEventListener( 'webkitpointerlockchange', pointerlockchange, false );
         *
         *   document.addEventListener( 'pointerlockerror', pointerlockerror, false );
         *   document.addEventListener( 'mozpointerlockerror', pointerlockerror, false );
         *   document.addEventListener( 'webkitpointerlockerror', pointerlockerror, false );
         */
        obj.turnOnPointerLock = function() {
            if(this.hasPointerLockSupport) {
                var element = document.body;
                if (/Firefox/i.test(navigator.userAgent)) {
                    function fullscreenchange (event) {
                        if (document.fullscreenElement === element || document.mozFullscreenElement === element || document.mozFullScreenElement === element ) {
                            document.removeEventListener( 'fullscreenchange', fullscreenchange );
                            document.removeEventListener( 'mozfullscreenchange', fullscreenchange );
                            element.requestPointerLock();
                        }
                    }

                    document.addEventListener( 'fullscreenchange', fullscreenchange, false );
                    document.addEventListener( 'mozfullscreenchange', fullscreenchange, false );

                    element.requestFullscreen();

                } else {
                    element.requestPointerLock();
                }
            }
        }

        /**
         * Exits pointer lock. Works on supported devices & browsers
         * @name turnOffPointerLock
         * @memberOf me.device
         * @function
         */
        obj.turnOffPointerLock = function() {
            if(this.hasPointerLockSupport) {
                document.exitPointerLock();
            }
        }

        /**
         * watch Accelerator event
         * @name watchAccelerometer
         * @memberOf me.device
         * @public
         * @function
         * @return {Boolean} false if not supported by the device
         */
        obj.watchAccelerometer = function () {
            if (me.device.hasAccelerometer) {
                if (!accelInitialized) {
                    if (typeof Windows === 'undefined') {
                        // add a listener for the devicemotion event
                        window.addEventListener('devicemotion', onDeviceMotion, false);
                    } else {
                        // On Windows 8 Device
                        var accelerometer = Windows.Devices.Sensors.Accelerometer.getDefault();
                        if (accelerometer) {
                            // Capture event at regular intervals
                            var minInterval = accelerometer.minimumReportInterval;
                            var Interval = minInterval >= 16 ? minInterval : 25;
                            accelerometer.reportInterval = Interval;

                            accelerometer.addEventListener('readingchanged', onDeviceMotion, false);
                        }
                    }
                    accelInitialized = true;
                }
                return true;
            }
            return false;
        };

        /**
         * unwatch Accelerometor event
         * @name unwatchAccelerometer
         * @memberOf me.device
         * @public
         * @function
         */
        obj.unwatchAccelerometer = function() {
            if (accelInitialized) {
                if (typeof Windows === 'undefined') {
                    // add a listener for the mouse
                    window.removeEventListener('devicemotion', onDeviceMotion, false);
                } else {
                    // On Windows 8 Devices
                    var accelerometer = Windows.Device.Sensors.Accelerometer.getDefault();

                    accelerometer.removeEventListener('readingchanged', onDeviceMotion, false);
                }
                accelInitialized = false;
            }
        };

        /**
         * watch the device orientation event
         * @name watchDeviceOrientation
         * @memberOf me.device
         * @public
         * @function
         * @return {Boolean} false if not supported by the device
         */
        obj.watchDeviceOrientation = function() {
            if(me.device.hasDeviceOrientation && !deviceOrientationInitialized) {
                window.addEventListener('deviceorientation', onDeviceRotate, false);
                deviceOrientationInitialized = true;
            }
            return false;
        };

        /**
         * unwatch Device orientation event
         * @name unwatchDeviceOrientation
         * @memberOf me.device
         * @public
         * @function
         */
        obj.unwatchDeviceOrientation = function() {
            if(deviceOrientationInitialized) {
                window.removeEventListener('deviceorientation', onDeviceRotate, false);
                deviceOrientationInitialized = false;
            }
        };

        return obj;
    })();
})(window);
<|endoftext|>


<commit_before>var EE = require('events').EventEmitter;
var h = require('hyperscript');
var inherits = require('inherits');

var Input = require('./input');

function Prompt(options) {
    if (!this instanceof Prompt) {
        return new Prompt(options);
    }
    this.input = new Input();
    this.input.element.style.display = 'none';
    this.element = h('div.prompt');
    this.displayElement = this.element.appendChild(h('span'));
    this.element.appendChild(this.input.element);
    this.expected = '';
    this.got = '';
    this.inputing = null;
    var self = this;
    this.input.on('stop', function(event) {
        self.emit('stopkey', event);
    });
    this.input.on('data', function(got, force) {
        self.got = got;
        self.emit('input', force);
    });
}

inherits(Prompt, EE);

Prompt.prototype.prompt = function(text) {
    this.expected = text;
    this.got = '';
    this.display(text);
};

Prompt.prototype.display = function(text) {
    this.displayElement.innerHTML = text;
    this.got = this.input.element.value = '';
    this.input.element.size = text.length + 2;
    this.showDisplay(text);
    this.emit('display');
};

Prompt.prototype.showDisplay = function() {
    if (this.inputing !== false) {
        this.inputing = false;
        this.displayElement.style.display = '';
        this.input.element.style.display = 'none';
        this.emit('showdisplay');
    }
};

Prompt.prototype.showInput = function() {
    if (this.inputing !== true) {
        this.inputing = true;
        this.displayElement.style.display = 'none';
        this.input.element.style.display = '';
        this.input.element.disabled = false;
        this.input.element.focus();
        this.emit('showinput');
    }
};

module.exports = Prompt;
<commit_msg>Emit prompt showinput before changing input state<commit_after>var EE = require('events').EventEmitter;
var h = require('hyperscript');
var inherits = require('inherits');

var Input = require('./input');

function Prompt(options) {
    if (!this instanceof Prompt) {
        return new Prompt(options);
    }
    this.input = new Input();
    this.input.element.style.display = 'none';
    this.element = h('div.prompt');
    this.displayElement = this.element.appendChild(h('span'));
    this.element.appendChild(this.input.element);
    this.expected = '';
    this.got = '';
    this.inputing = null;
    var self = this;
    this.input.on('stop', function(event) {
        self.emit('stopkey', event);
    });
    this.input.on('data', function(got, force) {
        self.got = got;
        self.emit('input', force);
    });
}

inherits(Prompt, EE);

Prompt.prototype.prompt = function(text) {
    this.expected = text;
    this.got = '';
    this.display(text);
};

Prompt.prototype.display = function(text) {
    this.displayElement.innerHTML = text;
    this.got = this.input.element.value = '';
    this.input.element.size = text.length + 2;
    this.showDisplay(text);
    this.emit('display');
};

Prompt.prototype.showDisplay = function() {
    if (this.inputing !== false) {
        this.inputing = false;
        this.displayElement.style.display = '';
        this.input.element.style.display = 'none';
        this.emit('showdisplay');
    }
};

Prompt.prototype.showInput = function() {
    if (this.inputing !== true) {
        this.inputing = true;
        this.displayElement.style.display = 'none';
        this.input.element.style.display = '';
        this.emit('showinput');
        this.input.element.disabled = false;
        this.input.element.focus();
    }
};

module.exports = Prompt;
<|endoftext|>


<commit_before>// dependencies -------------------------------------------------------------------

import config from '../config';

// public API ---------------------------------------------------------------------

let fileUtils = {
	generateTree,
    countTree,
    read
};

export default fileUtils;

// implementations ----------------------------------------------------------------

/**
 * Generate Tree
 *
 * Takes a files object of a selected directory
 * and restructures them from a flat array to a
 * tree following the structure of the original
 * directory.
 */
function generateTree (files) {
	let pathList = {};
	let dirTree = {};

    // generate list of paths
	for (let i = 0; i < files.length; i++) {
		let file = files[i];
        // ignore blacklisted files
        if (config.upload.blacklist.indexOf(file.name) > -1) {continue;}
        pathList[file.webkitRelativePath] = file;
    }

    // build path from list
    for (let key in pathList) {
    	let path = key;
    	let pathParts = path.split('/');
    	let subObj = dirTree;
    	for (let j = 0; j < pathParts.length; j++) {
    		let part = pathParts[j];
    		if (!subObj[part]) {
    			subObj[part] = j < pathParts.length - 1 ? {} : pathList[key];
    		}
    		subObj = subObj[part];
    	}
    }

	// convert dirTree to array structure
    function objToArr (obj) {
    	let arr = [];
    	for (let key in obj) {
    		if (obj[key].webkitRelativePath && obj[key].webkitRelativePath.length > 0) {
    			arr.push(obj[key]);
    		} else {
    			arr.push({name: key, type: 'folder', children: objToArr(obj[key])});
    		}
    	}
    	return arr;
	}

	dirTree = objToArr(dirTree);

    // return tree
    return dirTree;
}

/**
 * Count Tree
 *
 * Takes a BIDS tree object and returns
 * a total count of files and folders.
 */
function countTree (tree) {
    let count = 0;
    function recurse (tree) {
        for (let item of tree) {
            count++
            if (item.children) {recurse(item.children);}
        }
    }
    recurse(tree);
    return count;
}

/**
 * Read
 *
 * A helper method for reading file contents.
 * Takes a file object and a callback and calls
 * the callback with the text contents of the
 * file as the only argument.
 */
function read (file, callback) {
    var reader = new FileReader();
    reader.onloadend = function (e) {
        if (e.target.readyState == FileReader.DONE) {
            callback(e.target.result);
        }
    };
    reader.readAsBinaryString(file);
}
<commit_msg>Added a basic tree searching method for retrieving objects in a dataset filetree by their '_id'<commit_after>// dependencies -------------------------------------------------------------------

import config from '../config';

// public API ---------------------------------------------------------------------

let fileUtils = {
	generateTree,
    countTree,
    findInTree,
    read
};

export default fileUtils;

// implementations ----------------------------------------------------------------

/**
 * Generate Tree
 *
 * Takes a files object of a selected directory
 * and restructures them from a flat array to a
 * tree following the structure of the original
 * directory.
 */
function generateTree (files) {
	let pathList = {};
	let dirTree = {};

    // generate list of paths
	for (let i = 0; i < files.length; i++) {
		let file = files[i];
        // ignore blacklisted files
        if (config.upload.blacklist.indexOf(file.name) > -1) {continue;}
        pathList[file.webkitRelativePath] = file;
    }

    // build path from list
    for (let key in pathList) {
    	let path = key;
    	let pathParts = path.split('/');
    	let subObj = dirTree;
    	for (let j = 0; j < pathParts.length; j++) {
    		let part = pathParts[j];
    		if (!subObj[part]) {
    			subObj[part] = j < pathParts.length - 1 ? {} : pathList[key];
    		}
    		subObj = subObj[part];
    	}
    }

	// convert dirTree to array structure
    function objToArr (obj) {
    	let arr = [];
    	for (let key in obj) {
    		if (obj[key].webkitRelativePath && obj[key].webkitRelativePath.length > 0) {
    			arr.push(obj[key]);
    		} else {
    			arr.push({name: key, type: 'folder', children: objToArr(obj[key])});
    		}
    	}
    	return arr;
	}

	dirTree = objToArr(dirTree);

    // return tree
    return dirTree;
}

/**
 * Count Tree
 *
 * Takes a BIDS tree object and returns
 * a total count of files and folders.
 */
function countTree (tree) {
    let count = 0;
    function recurse (tree) {
        for (let item of tree) {
            count++
            if (item.children) {recurse(item.children);}
        }
    }
    recurse(tree);
    return count;
}

/**
 * Find In Tree
 *
 * Takes a file tree and an object id and
 * returns the corresponding object from
 * the tree.
 */
function findInTree (tree, id) {
    let match, subTree;
    for (let item of tree) {
        if (item.children) {subTree = item.children;}
        if (item._id == id) {
            return item;
        } else if (subTree) {
            match = findInTree(subTree, id);
            if (match) {return match;}
        }
    }
}

/**
 * Read
 *
 * A helper method for reading file contents.
 * Takes a file object and a callback and calls
 * the callback with the text contents of the
 * file as the only argument.
 */
function read (file, callback) {
    var reader = new FileReader();
    reader.onloadend = function (e) {
        if (e.target.readyState == FileReader.DONE) {
            callback(e.target.result);
        }
    };
    reader.readAsBinaryString(file);
}
<|endoftext|>


<commit_before>EN.Controller = (function(){
    var m_eCanvas = null;

    var m_cBoundEvents = {
        "tap": {},
        "drag": {},
        "hold": {}
    };

    var m_nEventId = 0;

    var m_nEventStart = 0;

    function InputStart(e)
    {
        e.preventDefault();

        try
        {
            var nNow = Date.now();

            var nX = 0;
            var nY = 0;

            if (isset(e.touches))
            {
                nX = e.touches[0].clientX;
                nY = e.touches[0].clientY;
            }
            else
            {
                nX = e.clientX;
                nY = e.clientY;
            }

            for (var sKey in m_cBoundEvents.tap)
            {
                m_cBoundEvents.tap[sKey].onTap(nX, nY);
            }

            for (var sKey in m_cBoundEvents.drag)
            {
                m_cBoundEvents.drag[sKey].onDragStart(nX, nY);
            }

            m_nEventStart = nNow;
        }
        catch (e)
        {
            console.error(e.stack);
            throw e;
        }
    }

    function InputMove(e)
    {
        e.preventDefault();

        setTimeout(function(){
            try
            {
                var nX = 0;
                var nY = 0;

                if (isset(e.touches))
                {
                    nX = e.touches[0].clientX;
                    nY = e.touches[0].clientY;
                }
                else
                {
                    nX = e.clientX;
                    nY = e.clientY;
                }

                for (var sKey in m_cBoundEvents.drag)
                {
                    m_cBoundEvents.drag[sKey].onDrag(nX, nY);
                }
            }
            catch (e)
            {
                console.error(e.stack);
                throw e;
            }
        }, 0);
    }

    function InputEnd(e)
    {
        e.preventDefault();

        try
        {
            for (var sKey in m_cBoundEvents.drag)
            {
                m_cBoundEvents.drag[sKey].onDragEnd(e.clientX, e.clientY);
            }

            for (var sKey in m_cBoundEvents.hold)
            {
                m_cBoundEvents.hold[sKey].onHold(Date.now() - m_nEventStart);
            }
        }
        catch (e)
        {
            console.error(e.stack);
            throw e;
        }
    }

    return {
        Init: function(eCanvas){
            m_eCanvas = eCanvas;

            eCanvas.addEventListener("touchstart", InputStart);
            eCanvas.addEventListener("touchend", InputEnd);

            eCanvas.addEventListener("mousedown", InputStart);
            eCanvas.addEventListener("mousemove", InputMove);
            eCanvas.addEventListener("mouseup", InputEnd);
        },
        Bind: function(sEventType, cOptions){
            var nId = m_nEventId++;

            m_cBoundEvents[sEventType][nId] = cOptions;

            return nId;
        },
        Unbind: function(sEventType, nEventId){
            delete m_cBoundEvents[sEventType][nEventId];
        }
    };
})();

//# sourceURL=engine/control/controller.js
<commit_msg>fixes touch events on cocoon js webview<commit_after>EN.Controller = (function(){
    var m_eCanvas = null;

    var m_cBoundEvents = {
        "tap": {},
        "drag": {},
        "hold": {}
    };

    var m_nEventId = 0;

    var m_nEventStart = 0;

    function InputStart(e)
    {
        e.preventDefault();

        try
        {
            var nNow = Date.now();

            var nX = 0;
            var nY = 0;

            if (isset(e.changedTouches))
            {
                nX = e.changedTouches[0].clientX;
                nY = e.changedTouches[0].clientY;
            }
            else
            {
                nX = e.clientX;
                nY = e.clientY;
            }

            for (var sKey in m_cBoundEvents.tap)
            {
                m_cBoundEvents.tap[sKey].onTap(nX, nY);
            }

            for (var sKey in m_cBoundEvents.drag)
            {
                m_cBoundEvents.drag[sKey].onDragStart(nX, nY);
            }

            m_nEventStart = nNow;
        }
        catch (e)
        {
            console.error(e.stack);
            throw e;
        }
    }

    function InputMove(e)
    {
        e.preventDefault();

        setTimeout(function(){
            try
            {
                var nX = 0;
                var nY = 0;

                if (isset(e.changedTouches))
                {
                    nX = e.changedTouches[0].clientX;
                    nY = e.changedTouches[0].clientY;
                }
                else
                {
                    nX = e.clientX;
                    nY = e.clientY;
                }

                for (var sKey in m_cBoundEvents.drag)
                {
                    m_cBoundEvents.drag[sKey].onDrag(nX, nY);
                }
            }
            catch (e)
            {
                console.error(e.stack);
                throw e;
            }
        }, 0);
    }

    function InputEnd(e)
    {
        e.preventDefault();

        try
        {
            var nX = 0;
            var nY = 0;

            if (isset(e.changedTouches))
            {
                nX = e.changedTouches[0].clientX;
                nY = e.changedTouches[0].clientY;
            }
            else
            {
                nX = e.clientX;
                nY = e.clientY;
            }

            for (var sKey in m_cBoundEvents.drag)
            {
                m_cBoundEvents.drag[sKey].onDragEnd(nX, nY);
            }

            for (var sKey in m_cBoundEvents.hold)
            {
                m_cBoundEvents.hold[sKey].onHold(Date.now() - m_nEventStart);
            }
        }
        catch (e)
        {
            console.error(e.stack);
            throw e;
        }
    }

    return {
        Init: function(eCanvas){
            m_eCanvas = eCanvas;

            eCanvas.addEventListener("touchstart", InputStart);
            eCanvas.addEventListener("touchend", InputEnd);

            eCanvas.addEventListener("mousedown", InputStart);
            eCanvas.addEventListener("mousemove", InputMove);
            eCanvas.addEventListener("mouseup", InputEnd);
        },
        Bind: function(sEventType, cOptions){
            var nId = m_nEventId++;

            m_cBoundEvents[sEventType][nId] = cOptions;

            return nId;
        },
        Unbind: function(sEventType, nEventId){
            delete m_cBoundEvents[sEventType][nEventId];
        }
    };
})();

//# sourceURL=engine/control/controller.js
<|endoftext|>


<commit_before>/*
 * MelonJS Game Engine
 * Copyright (C) 2011 - 2013 melonJS
 * http://www.melonjs.org
 *
 */
(function(window) {

    /**
     * A singleton object representing the device capabilities and specific events
     * @namespace me.device
     * @memberOf me
     */
    me.device = (function() {

        // defines object for holding public information/functionality.
        var obj = {};
        // private properties
        var accelInitialized = false;
        var deviceOrientationInitialized = false;
        var devicePixelRatio = null;

        /**
         * check the device capapbilities
         * @ignore
         */
        obj._check = function() {

            // future proofing (MS) feature detection
            me.device.pointerEnabled = navigator.pointerEnabled || navigator.msPointerEnabled;
            navigator.maxTouchPoints = navigator.maxTouchPoints || navigator.msMaxTouchPoints || 0;
            window.gesture = window.gesture || window.MSGesture;

            // detect touch capabilities
            me.device.touch = ('createTouch' in document) || ('ontouchstart' in window) ||
                              (navigator.isCocoonJS) || (navigator.maxTouchPoints > 0);

            // detect platform
            me.device.isMobile = me.device.ua.match(/Android|iPhone|iPad|iPod|BlackBerry|Windows Phone|Mobi/i) || false;

            // accelerometer detection
            me.device.hasAccelerometer = (
                (typeof (window.DeviceMotionEvent) !== 'undefined') || (
                    (typeof (window.Windows) !== 'undefined') &&
                    (typeof (Windows.Devices.Sensors.Accelerometer) === 'function')
                )
            );

            // pointerlock detection
            this.hasPointerLockSupport = 'pointerLockElement' in document ||
                                         'mozPointerLockElement' in document ||
                                         'webkitPointerLockElement' in document;

            if(this.hasPointerLockSupport) {
                document.body.requestPointerLock = document.body.requestPointerLock ||
                                                   document.body.mozRequestPointerLock ||
                                                   document.body.webkitRequestPointerLock;

                document.exitPointerLock = document.exitPointerLock ||
                                           document.mozExitPointerLock ||
                                           document.webkitExitPointerLock;
            }

            // device motion detection
            if (window.DeviceOrientationEvent) {
                me.device.hasDeviceOrientation = true;
            }

            // fullscreen api detection
            this.hasFullScreenSupport = document.fullscreenEnabled ||
                                        document.webkitFullscreenEnabled ||
                                        document.msFullscreenEnabled ||
                                        document.mozFullScreenEnabled;

            if(this.hasFullScreenSupport) {
                // some usefull polyfill
                document.body.requestFullscreen = document.body.requestFullscreen ||
                                                  document.body.webkitRequestFullscreen ||
                                                  document.body.mozRequestFullScreen ||
                                                  document.body.msRequestFullscreen;

                document.exitFullscreen = document.cancelFullScreen ||
                                          document.exitFullscreen ||
                                          document.webkitCancelFullScreen ||
                                          document.webkitExitFullscreen ||
                                          document.mozCancelFullScreen ||
                                          document.msExitFullscreen;
            }

            try {
                obj.localStorage = !!window.localStorage;
            } catch (e) {
                // the above generates an exception when cookies are blocked
                obj.localStorage = false;
            }

            // detect audio capabilities
            me.device._detectAudio();
        };

        /**
         * check the audio capapbilities
         * @ignore
         */
        obj._detectAudio = function() {
            // check for browser codec support
            var audioTest;
            try {
                audioTest = new Audio();
            } catch(e) {
                audioTest = false;
            }
            if (audioTest) {
                me.device.audioCodecs = {
                    mp3: !!audioTest.canPlayType('audio/mpeg;').replace(/^no$/, ''),
                    opus: !!audioTest.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, ''),
                    ogg: !!audioTest.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ''),
                    wav: !!audioTest.canPlayType('audio/wav; codecs="1"').replace(/^no$/, ''),
                    m4a: !!(audioTest.canPlayType('audio/x-m4a;') || audioTest.canPlayType('audio/aac;')).replace(/^no$/, ''),
                    weba: !!audioTest.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, '')
                };
                me.device.sound = true;
            }
        };

        // ----- PUBLIC Properties & Functions -----

        // Browser capabilities

        /**
         * Browser User Agent
         * @type Boolean
         * @readonly
         * @name ua
         * @memberOf me.device
         */
        obj.ua = navigator.userAgent;

        /**
         * list of supported audio codecs
         * @type enum
         * @readonly
         * @name audioCodecs
         * @memberOf me.device
         */
        obj.audioCodecs = {};

        /**
         * Browser Audio capabilities
         * @type Boolean
         * @readonly
         * @name sound
         * @memberOf me.device
         */
        obj.sound = false;
        /**
         * Browser Local Storage capabilities

         * (this flag will be set to false if cookies are blocked)
         * @type Boolean
         * @readonly
         * @name localStorage
         * @memberOf me.device
         */
        obj.localStorage = false;
        /**
         * Browser accelerometer capabilities
         * @type Boolean
         * @readonly
         * @name hasAccelerometer
         * @memberOf me.device
         */
        obj.hasAccelerometer = false;

        /**
         * Browser device orientation
         * @type Boolean
         * @readonly
         * @name hasDeviceOrientation
         * @memberOf me.device
         */
        obj.hasDeviceOrientation = false;

        /**
         * Browser full screen support
         * @type Boolean
         * @readonly
         * @name hasFullScreenSupport
         * @memberOf me.device
         */
         obj.hasFullScreenSupport = false;

         /**
         * Browser pointerlock api support
         * @type Boolean
         * @readonly
         * @name hasPointerLockSupport
         * @memberOf me.device
         */
         obj.hasPointerLockSupport = false;

        /**
         * Browser Base64 decoding capability
         * @type Boolean
         * @readonly
         * @name nativeBase64
         * @memberOf me.device
         */
        obj.nativeBase64 = (typeof(window.atob) === 'function');

        /**
         * Touch capabilities
         * @type Boolean
         * @readonly
         * @name touch
         * @memberOf me.device
         */
        obj.touch = false;

        /**
         * equals to true if a mobile device

         * (Android | iPhone | iPad | iPod | BlackBerry | Windows Phone)
         * @type Boolean
         * @readonly
         * @name isMobile
         * @memberOf me.device
         */
        obj.isMobile = false;

        /**
         * The device current orientation status.

         *   0 : default orientation

         *  90 : 90 degrees clockwise from default

         * -90 : 90 degrees anti-clockwise from default

         * 180 : 180 degrees from default
         * @type Number
         * @readonly
         * @name orientation
         * @memberOf me.device
         */
        obj.orientation = 0;

        /**
         * contains the g-force acceleration along the x-axis.
         * @public
         * @type Number
         * @readonly
         * @name accelerationX
         * @memberOf me.device
         */
        obj.accelerationX = 0;

        /**
         * contains the g-force acceleration along the y-axis.
         * @public
         * @type Number
         * @readonly
         * @name accelerationY
         * @memberOf me.device
         */
        obj.accelerationY = 0;

        /**
         * contains the g-force acceleration along the z-axis.
         * @public
         * @type Number
         * @readonly
         * @name accelerationZ
         * @memberOf me.device
         */
        obj.accelerationZ = 0;

        /**
         * Device orientation Gamma property. Gives angle on tilting a portrait held phone left or right
         * @public
         * @type Number
         * @readonly
         * @name gamma
         * @memberOf me.device
         */
        obj.gamma = 0;

        /**
         * Device orientation Beta property. Gives angle on tilting a portrait held phone forward or backward
         * @public
         * @type Number
         * @readonly
         * @name beta
         * @memberOf me.device
         */
        obj.beta = 0;

        /**
         * Device orientation Alpha property. Gives angle based on the rotation of the phone around its z axis.
         * The z-axis is perpendicular to the phone, facing out from the center of the screen.
         * @public
         * @type Number
         * @readonly
         * @name alpha
         * @memberOf me.device
         */
        obj.alpha = 0;

        /**
         * Triggers fullscreen request. Requires fullscreen support from the browser/device. Must be called in a click event
         * or an event that requires user interaction.
         * If you need to utilize event handlers around the fullscreen changing, use as per example below
         * @name requestFullscreen
         * @memberOf me.device
         * @function
         * @example
         *   document.addEventListener( 'fullscreenchange', fullscreenchange, false );
         *   document.addEventListener( 'mozfullscreenchange', fullscreenchange, false );
         */
        obj.requestFullscreen = function() {
            if(this.hasFullScreenSupport) {
                document.body.requestFullscreen();
            }
        };

        /**
         * Exit fullscreen mode. Requires fullscreen support from the browser/device.
         * @name exitFullscreen
         * @memberOf me.device
         * @function
         */
        obj.exitFullscreen = function() {
            if(this.hasFullScreenSupport) {
                document.exitFullscreen();
            }
        };

        /**
         * return the device pixel ratio
         * @name getPixelRatio
         * @memberOf me.device
         * @function
         */
        obj.getPixelRatio = function() {

            if (devicePixelRatio===null) {
                var _context = me.video.getScreenContext();
                var _devicePixelRatio = window.devicePixelRatio || 1,
                    _backingStoreRatio = _context.webkitBackingStorePixelRatio ||
                    _context.mozBackingStorePixelRatio ||
                    _context.msBackingStorePixelRatio ||
                    _context.oBackingStorePixelRatio ||
                    _context.backingStorePixelRatio || 1;
                devicePixelRatio = _devicePixelRatio / _backingStoreRatio;
            }
            return devicePixelRatio;
        };

        /**
         * return the device storage
         * @name getStorage
         * @memberOf me.device
         * @function
         * @param {String} [type="local"]
         * @return me.save object
         */
        obj.getStorage = function(type) {

            type = type || "local";

            switch (type) {
                case "local" :
                    return me.save;

                default :
                    break;
            }
            throw "melonJS : storage type " + type + " not supported";
        };

        /**
         * event management (Accelerometer)
         * http://www.mobilexweb.com/samples/ball.html
         * http://www.mobilexweb.com/blog/safari-ios-accelerometer-websockets-html5
         * @ignore
         */
        function onDeviceMotion(e) {
            if (e.reading) {
                // For Windows 8 devices
                obj.accelerationX = e.reading.accelerationX;
                obj.accelerationY = e.reading.accelerationY;
                obj.accelerationZ = e.reading.accelerationZ;
            } else {
                // Accelerometer information
                obj.accelerationX = e.accelerationIncludingGravity.x;
                obj.accelerationY = e.accelerationIncludingGravity.y;
                obj.accelerationZ = e.accelerationIncludingGravity.z;
            }
        }

        function onDeviceRotate(e) {
            obj.gamma = e.gamma;
            obj.beta = e.beta;
            obj.alpha = e.alpha;
        }

        /**
         * Enters pointer lock, requesting it from the user first. Works on supported devices & browsers
         * Must be called in a click event or an event that requires user interaction.
         * If you need to run handle events for errors or change of the pointer lock, see below.
         * @name turnOnPointerLock
         * @memberOf me.device
         * @function
         * @example
         *   document.addEventListener( 'pointerlockchange', pointerlockchange, false );
         *   document.addEventListener( 'mozpointerlockchange', pointerlockchange, false );
         *   document.addEventListener( 'webkitpointerlockchange', pointerlockchange, false );
         *
         *   document.addEventListener( 'pointerlockerror', pointerlockerror, false );
         *   document.addEventListener( 'mozpointerlockerror', pointerlockerror, false );
         *   document.addEventListener( 'webkitpointerlockerror', pointerlockerror, false );
         */
        obj.turnOnPointerLock = function() {
            if(this.hasPointerLockSupport) {
                var element = document.body;
                if (me.device.ua.match(/Firefox/i)) {
                    var fullscreenchange = function(event) {
                        if ((document.fullscreenElement ||
                             document.webkitFullscreenElement ||
                             document.msFullscreenElement ||
                             document.mozFullScreenElement) === element) {
                            document.removeEventListener( 'fullscreenchange', fullscreenchange );
                            document.removeEventListener( 'mozfullscreenchange', fullscreenchange );
                            element.requestPointerLock();
                        }
                    };

                    document.addEventListener( 'fullscreenchange', fullscreenchange, false );
                    document.addEventListener( 'mozfullscreenchange', fullscreenchange, false );

                    element.requestFullscreen();

                } else {
                    element.requestPointerLock();
                }
            }
        };

        /**
         * Exits pointer lock. Works on supported devices & browsers
         * @name turnOffPointerLock
         * @memberOf me.device
         * @function
         */
        obj.turnOffPointerLock = function() {
            if(this.hasPointerLockSupport) {
                document.exitPointerLock();
            }
        };

        /**
         * watch Accelerator event
         * @name watchAccelerometer
         * @memberOf me.device
         * @public
         * @function
         * @return {Boolean} false if not supported by the device
         */
        obj.watchAccelerometer = function () {
            if (me.device.hasAccelerometer) {
                if (!accelInitialized) {
                    if (typeof Windows === 'undefined') {
                        // add a listener for the devicemotion event
                        window.addEventListener('devicemotion', onDeviceMotion, false);
                    } else {
                        // On Windows 8 Device
                        var accelerometer = Windows.Devices.Sensors.Accelerometer.getDefault();
                        if (accelerometer) {
                            // Capture event at regular intervals
                            var minInterval = accelerometer.minimumReportInterval;
                            var Interval = minInterval >= 16 ? minInterval : 25;
                            accelerometer.reportInterval = Interval;

                            accelerometer.addEventListener('readingchanged', onDeviceMotion, false);
                        }
                    }
                    accelInitialized = true;
                }
                return true;
            }
            return false;
        };

        /**
         * unwatch Accelerometor event
         * @name unwatchAccelerometer
         * @memberOf me.device
         * @public
         * @function
         */
        obj.unwatchAccelerometer = function() {
            if (accelInitialized) {
                if (typeof Windows === 'undefined') {
                    // add a listener for the mouse
                    window.removeEventListener('devicemotion', onDeviceMotion, false);
                } else {
                    // On Windows 8 Devices
                    var accelerometer = Windows.Device.Sensors.Accelerometer.getDefault();

                    accelerometer.removeEventListener('readingchanged', onDeviceMotion, false);
                }
                accelInitialized = false;
            }
        };

        /**
         * watch the device orientation event
         * @name watchDeviceOrientation
         * @memberOf me.device
         * @public
         * @function
         * @return {Boolean} false if not supported by the device
         */
        obj.watchDeviceOrientation = function() {
            if(me.device.hasDeviceOrientation && !deviceOrientationInitialized) {
                window.addEventListener('deviceorientation', onDeviceRotate, false);
                deviceOrientationInitialized = true;
            }
            return false;
        };

        /**
         * unwatch Device orientation event
         * @name unwatchDeviceOrientation
         * @memberOf me.device
         * @public
         * @function
         */
        obj.unwatchDeviceOrientation = function() {
            if(deviceOrientationInitialized) {
                window.removeEventListener('deviceorientation', onDeviceRotate, false);
                deviceOrientationInitialized = false;
            }
        };

        return obj;
    })();

    /**
     * Returns true if the browser/device is in full screen mode.
     * @name isFullscreen
     * @memberOf me.device
     * @public
     * @type Boolean
     * @readonly
     * @return {boolean}
     */
    Object.defineProperty(me.device, "isFullscreen", {
        get: function () {
            if (me.device.hasFullScreenSupport) {
                return ((document.fullscreenElement ||
                        document.webkitFullscreenElement ||
                        document.msFullscreenElement ||
                        document.mozFullScreenElement) !== null);
            } else {
                return false;
            }
        }
    });

})(window);
<commit_msg>[#315] more fixes to the me.device fullscreen API (now working with Safari)<commit_after>/*
 * MelonJS Game Engine
 * Copyright (C) 2011 - 2013 melonJS
 * http://www.melonjs.org
 *
 */
(function(window) {

    /**
     * A singleton object representing the device capabilities and specific events
     * @namespace me.device
     * @memberOf me
     */
    me.device = (function() {

        // defines object for holding public information/functionality.
        var obj = {};
        // private properties
        var accelInitialized = false;
        var deviceOrientationInitialized = false;
        var devicePixelRatio = null;

        /**
         * check the device capapbilities
         * @ignore
         */
        obj._check = function() {

            // future proofing (MS) feature detection
            me.device.pointerEnabled = navigator.pointerEnabled || navigator.msPointerEnabled;
            navigator.maxTouchPoints = navigator.maxTouchPoints || navigator.msMaxTouchPoints || 0;
            window.gesture = window.gesture || window.MSGesture;

            // detect touch capabilities
            me.device.touch = ('createTouch' in document) || ('ontouchstart' in window) ||
                              (navigator.isCocoonJS) || (navigator.maxTouchPoints > 0);

            // detect platform
            me.device.isMobile = me.device.ua.match(/Android|iPhone|iPad|iPod|BlackBerry|Windows Phone|Mobi/i) || false;

            // accelerometer detection
            me.device.hasAccelerometer = (
                (typeof (window.DeviceMotionEvent) !== 'undefined') || (
                    (typeof (window.Windows) !== 'undefined') &&
                    (typeof (Windows.Devices.Sensors.Accelerometer) === 'function')
                )
            );

            // pointerlock detection
            this.hasPointerLockSupport = 'pointerLockElement' in document ||
                                         'mozPointerLockElement' in document ||
                                         'webkitPointerLockElement' in document;

            if(this.hasPointerLockSupport) {
                document.exitPointerLock = document.exitPointerLock ||
                                           document.mozExitPointerLock ||
                                           document.webkitExitPointerLock;
            }

            // device motion detection
            if (window.DeviceOrientationEvent) {
                me.device.hasDeviceOrientation = true;
            }

            // fullscreen api detection & polyfill when possible
            this.hasFullScreenSupport = document.fullscreenEnabled ||
                                        document.webkitFullscreenEnabled ||
                                        document.msFullscreenEnabled ||
                                        document.mozFullScreenEnabled;

            document.exitFullscreen = document.cancelFullScreen ||
                                      document.exitFullscreen ||
                                      document.webkitCancelFullScreen ||
                                      document.webkitExitFullscreen ||
                                      document.mozCancelFullScreen ||
                                      document.msExitFullscreen;

            try {
                obj.localStorage = !!window.localStorage;
            } catch (e) {
                // the above generates an exception when cookies are blocked
                obj.localStorage = false;
            }

            // detect audio capabilities
            me.device._detectAudio();
        };

        /**
         * check the audio capapbilities
         * @ignore
         */
        obj._detectAudio = function() {
            // check for browser codec support
            var audioTest;
            try {
                audioTest = new Audio();
            } catch(e) {
                audioTest = false;
            }
            if (audioTest) {
                me.device.audioCodecs = {
                    mp3: !!audioTest.canPlayType('audio/mpeg;').replace(/^no$/, ''),
                    opus: !!audioTest.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, ''),
                    ogg: !!audioTest.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ''),
                    wav: !!audioTest.canPlayType('audio/wav; codecs="1"').replace(/^no$/, ''),
                    m4a: !!(audioTest.canPlayType('audio/x-m4a;') || audioTest.canPlayType('audio/aac;')).replace(/^no$/, ''),
                    weba: !!audioTest.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, '')
                };
                me.device.sound = true;
            }
        };

        // ----- PUBLIC Properties & Functions -----

        // Browser capabilities

        /**
         * Browser User Agent
         * @type Boolean
         * @readonly
         * @name ua
         * @memberOf me.device
         */
        obj.ua = navigator.userAgent;

        /**
         * list of supported audio codecs
         * @type enum
         * @readonly
         * @name audioCodecs
         * @memberOf me.device
         */
        obj.audioCodecs = {};

        /**
         * Browser Audio capabilities
         * @type Boolean
         * @readonly
         * @name sound
         * @memberOf me.device
         */
        obj.sound = false;
        /**
         * Browser Local Storage capabilities

         * (this flag will be set to false if cookies are blocked)
         * @type Boolean
         * @readonly
         * @name localStorage
         * @memberOf me.device
         */
        obj.localStorage = false;
        /**
         * Browser accelerometer capabilities
         * @type Boolean
         * @readonly
         * @name hasAccelerometer
         * @memberOf me.device
         */
        obj.hasAccelerometer = false;

        /**
         * Browser device orientation
         * @type Boolean
         * @readonly
         * @name hasDeviceOrientation
         * @memberOf me.device
         */
        obj.hasDeviceOrientation = false;

        /**
         * Browser full screen support
         * @type Boolean
         * @readonly
         * @name hasFullScreenSupport
         * @memberOf me.device
         */
         obj.hasFullScreenSupport = false;

         /**
         * Browser pointerlock api support
         * @type Boolean
         * @readonly
         * @name hasPointerLockSupport
         * @memberOf me.device
         */
         obj.hasPointerLockSupport = false;

        /**
         * Browser Base64 decoding capability
         * @type Boolean
         * @readonly
         * @name nativeBase64
         * @memberOf me.device
         */
        obj.nativeBase64 = (typeof(window.atob) === 'function');

        /**
         * Touch capabilities
         * @type Boolean
         * @readonly
         * @name touch
         * @memberOf me.device
         */
        obj.touch = false;

        /**
         * equals to true if a mobile device

         * (Android | iPhone | iPad | iPod | BlackBerry | Windows Phone)
         * @type Boolean
         * @readonly
         * @name isMobile
         * @memberOf me.device
         */
        obj.isMobile = false;

        /**
         * The device current orientation status.

         *   0 : default orientation

         *  90 : 90 degrees clockwise from default

         * -90 : 90 degrees anti-clockwise from default

         * 180 : 180 degrees from default
         * @type Number
         * @readonly
         * @name orientation
         * @memberOf me.device
         */
        obj.orientation = 0;

        /**
         * contains the g-force acceleration along the x-axis.
         * @public
         * @type Number
         * @readonly
         * @name accelerationX
         * @memberOf me.device
         */
        obj.accelerationX = 0;

        /**
         * contains the g-force acceleration along the y-axis.
         * @public
         * @type Number
         * @readonly
         * @name accelerationY
         * @memberOf me.device
         */
        obj.accelerationY = 0;

        /**
         * contains the g-force acceleration along the z-axis.
         * @public
         * @type Number
         * @readonly
         * @name accelerationZ
         * @memberOf me.device
         */
        obj.accelerationZ = 0;

        /**
         * Device orientation Gamma property. Gives angle on tilting a portrait held phone left or right
         * @public
         * @type Number
         * @readonly
         * @name gamma
         * @memberOf me.device
         */
        obj.gamma = 0;

        /**
         * Device orientation Beta property. Gives angle on tilting a portrait held phone forward or backward
         * @public
         * @type Number
         * @readonly
         * @name beta
         * @memberOf me.device
         */
        obj.beta = 0;

        /**
         * Device orientation Alpha property. Gives angle based on the rotation of the phone around its z axis.
         * The z-axis is perpendicular to the phone, facing out from the center of the screen.
         * @public
         * @type Number
         * @readonly
         * @name alpha
         * @memberOf me.device
         */
        obj.alpha = 0;

        /**
         * Triggers fullscreen request. Requires fullscreen support from the browser/device. Must be called in a click event
         * or an event that requires user interaction.
         * If you need to utilize event handlers around the fullscreen changing, use as per example below
         * @name requestFullscreen
         * @memberOf me.device
         * @function
         * @example
         *   document.addEventListener( 'fullscreenchange', fullscreenchange, false );
         *   document.addEventListener( 'mozfullscreenchange', fullscreenchange, false );
         */
        obj.requestFullscreen = function() {
            if(this.hasFullScreenSupport) {
                var element = me.video.getWrapper();
                element.requestFullscreen = element.requestFullscreen ||
                                            element.webkitRequestFullscreen ||
                                            element.mozRequestFullScreen ||
                                            element.msRequestFullscreen;
                element.requestFullscreen();
            }
        };

        /**
         * Exit fullscreen mode. Requires fullscreen support from the browser/device.
         * @name exitFullscreen
         * @memberOf me.device
         * @function
         */
        obj.exitFullscreen = function() {
            if(this.hasFullScreenSupport) {
                document.exitFullscreen();
            }
        };

        /**
         * return the device pixel ratio
         * @name getPixelRatio
         * @memberOf me.device
         * @function
         */
        obj.getPixelRatio = function() {

            if (devicePixelRatio===null) {
                var _context = me.video.getScreenContext();
                var _devicePixelRatio = window.devicePixelRatio || 1,
                    _backingStoreRatio = _context.webkitBackingStorePixelRatio ||
                    _context.mozBackingStorePixelRatio ||
                    _context.msBackingStorePixelRatio ||
                    _context.oBackingStorePixelRatio ||
                    _context.backingStorePixelRatio || 1;
                devicePixelRatio = _devicePixelRatio / _backingStoreRatio;
            }
            return devicePixelRatio;
        };

        /**
         * return the device storage
         * @name getStorage
         * @memberOf me.device
         * @function
         * @param {String} [type="local"]
         * @return me.save object
         */
        obj.getStorage = function(type) {

            type = type || "local";

            switch (type) {
                case "local" :
                    return me.save;

                default :
                    break;
            }
            throw "melonJS : storage type " + type + " not supported";
        };

        /**
         * event management (Accelerometer)
         * http://www.mobilexweb.com/samples/ball.html
         * http://www.mobilexweb.com/blog/safari-ios-accelerometer-websockets-html5
         * @ignore
         */
        function onDeviceMotion(e) {
            if (e.reading) {
                // For Windows 8 devices
                obj.accelerationX = e.reading.accelerationX;
                obj.accelerationY = e.reading.accelerationY;
                obj.accelerationZ = e.reading.accelerationZ;
            } else {
                // Accelerometer information
                obj.accelerationX = e.accelerationIncludingGravity.x;
                obj.accelerationY = e.accelerationIncludingGravity.y;
                obj.accelerationZ = e.accelerationIncludingGravity.z;
            }
        }

        function onDeviceRotate(e) {
            obj.gamma = e.gamma;
            obj.beta = e.beta;
            obj.alpha = e.alpha;
        }

        /**
         * Enters pointer lock, requesting it from the user first. Works on supported devices & browsers
         * Must be called in a click event or an event that requires user interaction.
         * If you need to run handle events for errors or change of the pointer lock, see below.
         * @name turnOnPointerLock
         * @memberOf me.device
         * @function
         * @example
         *   document.addEventListener( 'pointerlockchange', pointerlockchange, false );
         *   document.addEventListener( 'mozpointerlockchange', pointerlockchange, false );
         *   document.addEventListener( 'webkitpointerlockchange', pointerlockchange, false );
         *
         *   document.addEventListener( 'pointerlockerror', pointerlockerror, false );
         *   document.addEventListener( 'mozpointerlockerror', pointerlockerror, false );
         *   document.addEventListener( 'webkitpointerlockerror', pointerlockerror, false );
         */
        obj.turnOnPointerLock = function() {
            if(this.hasPointerLockSupport) {
                var element = me.video.getWrapper();
                if (me.device.ua.match(/Firefox/i)) {
                    var fullscreenchange = function(event) {
                        if ((document.fullscreenElement ||
                             document.webkitFullscreenElement ||
                             document.msFullscreenElement ||
                             document.mozFullScreenElement) === element) {

                            document.removeEventListener( 'fullscreenchange', fullscreenchange );
                            document.removeEventListener( 'mozfullscreenchange', fullscreenchange );
                            element.requestPointerLock = element.requestPointerLock ||
                                                         element.mozRequestPointerLock ||
                                                         element.webkitRequestPointerLock;
                            element.requestPointerLock();
                        }
                    };

                    document.addEventListener( 'fullscreenchange', fullscreenchange, false );
                    document.addEventListener( 'mozfullscreenchange', fullscreenchange, false );

                    me.device.requestFullscreen();

                } else {
                    element.requestPointerLock();
                }
            }
        };

        /**
         * Exits pointer lock. Works on supported devices & browsers
         * @name turnOffPointerLock
         * @memberOf me.device
         * @function
         */
        obj.turnOffPointerLock = function() {
            if(this.hasPointerLockSupport) {
                document.exitPointerLock();
            }
        };

        /**
         * watch Accelerator event
         * @name watchAccelerometer
         * @memberOf me.device
         * @public
         * @function
         * @return {Boolean} false if not supported by the device
         */
        obj.watchAccelerometer = function () {
            if (me.device.hasAccelerometer) {
                if (!accelInitialized) {
                    if (typeof Windows === 'undefined') {
                        // add a listener for the devicemotion event
                        window.addEventListener('devicemotion', onDeviceMotion, false);
                    } else {
                        // On Windows 8 Device
                        var accelerometer = Windows.Devices.Sensors.Accelerometer.getDefault();
                        if (accelerometer) {
                            // Capture event at regular intervals
                            var minInterval = accelerometer.minimumReportInterval;
                            var Interval = minInterval >= 16 ? minInterval : 25;
                            accelerometer.reportInterval = Interval;

                            accelerometer.addEventListener('readingchanged', onDeviceMotion, false);
                        }
                    }
                    accelInitialized = true;
                }
                return true;
            }
            return false;
        };

        /**
         * unwatch Accelerometor event
         * @name unwatchAccelerometer
         * @memberOf me.device
         * @public
         * @function
         */
        obj.unwatchAccelerometer = function() {
            if (accelInitialized) {
                if (typeof Windows === 'undefined') {
                    // add a listener for the mouse
                    window.removeEventListener('devicemotion', onDeviceMotion, false);
                } else {
                    // On Windows 8 Devices
                    var accelerometer = Windows.Device.Sensors.Accelerometer.getDefault();

                    accelerometer.removeEventListener('readingchanged', onDeviceMotion, false);
                }
                accelInitialized = false;
            }
        };

        /**
         * watch the device orientation event
         * @name watchDeviceOrientation
         * @memberOf me.device
         * @public
         * @function
         * @return {Boolean} false if not supported by the device
         */
        obj.watchDeviceOrientation = function() {
            if(me.device.hasDeviceOrientation && !deviceOrientationInitialized) {
                window.addEventListener('deviceorientation', onDeviceRotate, false);
                deviceOrientationInitialized = true;
            }
            return false;
        };

        /**
         * unwatch Device orientation event
         * @name unwatchDeviceOrientation
         * @memberOf me.device
         * @public
         * @function
         */
        obj.unwatchDeviceOrientation = function() {
            if(deviceOrientationInitialized) {
                window.removeEventListener('deviceorientation', onDeviceRotate, false);
                deviceOrientationInitialized = false;
            }
        };

        return obj;
    })();

    /**
     * Returns true if the browser/device is in full screen mode.
     * @name isFullscreen
     * @memberOf me.device
     * @public
     * @type Boolean
     * @readonly
     * @return {boolean}
     */
    Object.defineProperty(me.device, "isFullscreen", {
        get: function () {
            if (me.device.hasFullScreenSupport) {
                return ((document.fullscreenElement ||
                        document.webkitFullscreenElement ||
                        document.msFullscreenElement ||
                        document.mozFullScreenElement) === me.video.getWrapper());
            } else {
                return false;
            }
        }
    });

})(window);
<|endoftext|>


<commit_before>import React from 'react';
import ApplicationStore from '../stores/ApplicationStore';

class DefaultHTMLLayout extends React.Component {
    render() {
        return (

                <meta charSet="utf-8" />
                <title>{this.props.context.getStore(ApplicationStore).getPageTitle()}</title>
                <meta name="viewport" content="width=device-width, user-scalable=no" />
                <link href="/custom_modules/custom-semantic-ui/dist/semantic.min.css" rel="stylesheet" type="text/css" />
                <link href="/assets/css/custom.css" rel="stylesheet" type="text/css" />

                {/* Following are added only to support IE browser */}

                {/* Above are added only to support IE browser */}

                {/* All external vendors bundle*/}

                {/* Main app bundle */}

        );
    }
}

export default DefaultHTMLLayout;
<commit_msg>revert changes on js loading<commit_after>import React from 'react';
import ApplicationStore from '../stores/ApplicationStore';

class DefaultHTMLLayout extends React.Component {
    render() {
        return (

                <meta charSet="utf-8" />
                <title>{this.props.context.getStore(ApplicationStore).getPageTitle()}</title>
                <meta name="viewport" content="width=device-width, user-scalable=no" />
                <link href="/custom_modules/custom-semantic-ui/dist/semantic.min.css" rel="stylesheet" type="text/css" />
                <link href="/assets/css/custom.css" rel="stylesheet" type="text/css" />

                {/* Following are added only to support IE browser */}

                {/* Above are added only to support IE browser */}

                {/* All external vendors bundle*/}

                {/* Main app bundle */}

        );
    }
}

export default DefaultHTMLLayout;
<|endoftext|>


<commit_before>import React from 'react'
import withAutofillProps from './withAutofillProps'
import { equal } from 'assert'

describe('withAutofillProps', () => {
  it('wraps the name of the original component', () => {
    function Input(props) {
      return <input {...props} />
    }

    const EnhancedInput = withAutofillProps({ autofill: true })(Input)

    equal(EnhancedInput.displayName, 'withAutofillProps(Input)')
  })
})
<commit_msg>Add tests<commit_after>import React from 'react'
import { render } from 'react-dom'
import withAutofillProps from './withAutofillProps'
import { equal } from 'assert'

describe('withAutofillProps', () => {
  it('wraps the name of the original component', () => {
    function Input(props) {
      return <input {...props} />
    }

    const EnhancedInput = withAutofillProps({ autofill: true })(Input)

    equal(EnhancedInput.displayName, 'withAutofillProps(Input)')
  })

  it('has the autofilled prop when autofill animation gets triggered', () => {
    const root = document.createElement('div')
    let animationStartCallback

    function Target({ autofilled, onAnimationStart }) {
      animationStartCallback = onAnimationStart

      return
{autofilled ? 'autofilled' : 'not autofilled'}

    }

    const DecoratedTarget = withAutofillProps({
      autofilled: true,
    })(Target)

    render(<DecoratedTarget />, root)

    equal(root.innerText, 'not autofilled')

    animationStartCallback('onAutofillStart')

    equal(root.innerText, 'autofilled')
  })

  it('does not have the autofilled prop when autofill animation gets canceled', () => {
    const root = document.createElement('div')
    let animationStartCallback

    function Target({ autofilled, onAnimationStart }) {
      animationStartCallback = onAnimationStart

      return
{autofilled ? 'autofilled' : 'not autofilled'}

    }

    const DecoratedTarget = withAutofillProps({
      autofilled: true,
    })(Target)

    render(<DecoratedTarget />, root)

    animationStartCallback('onAutofillStart')
    equal(root.innerText, 'autofilled')

    animationStartCallback('onAutofillCancel')

    equal(root.innerText, 'not autofilled')
  })
})
<|endoftext|>