diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b1dccadb50..32ed4c8d77 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,20 +3,27 @@ Contributing Pull requests are gladly accepted. We also really appreciate tests. -Tests ------ -Tests can be run by loading the following url in your browser `/test/run.html`. +## Running Tests + +Tests can be run by loading the following url in your browser `/test/run.html` + +E.g. of running an individual test: `/test/run.html?spec=events/eventmanager-spec` + ### Creating + #### Unit test + Here's how to create a new unit test: 1. run `minit create:spec -n myspec`. This will create a `-spec.js` file where you can add your Jasmine assertions. 2. Add the moduleId of the new spec to `/test/run.js`. + #### UI test + Here's how to create a new ui test: 1. run `minit create:test -n mytest`. This will create a `mytest` directory that includes @@ -31,25 +38,25 @@ The spec file queues up the ui test and executes the assertions when the page u ```javascript var TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; -TestPageLoader.queueTest("mytest", function(testPage) { - describe("test/ui/mytest-spec", function() { +TestPageLoader.queueTest("mytest", function (testPage) { + describe("test/ui/mytest-spec", function () { ... }) }); ``` -Core Team -========= -git subtree ------------ +## Notes for Core Team + + +### git subtree Git subtrees are like submodules, but better and easier for everyone involved. They allow you to import code from a different repository but instead of adding a *reference* to your repository, they add the **actual code** *and commit saying where the code came from*. The great thing about subtrees is if you do not care about merging or splitting them, they **do not affect you**. You can treat the whole repository as you would normally. If the above describes you, you can stop reading now. -Installing ----------- + +#### Installing If you use OSX and homebrew, then `brew install git` will install the subtree command along with git. @@ -60,20 +67,23 @@ Otherwise it is a single script you can download: 3. Rename to git-subtree: `mv git-subtree.sh git-subtree` 4. Move to a directory on your `PATH` -Using ------ + +#### Using Each section below has a description and example for each command, and a list of the subtrees in each of the montagejs repositories with the command that you can copy and paste. See the Adding section for an example of what a subtree looks like. -### Merging/pulling + +#### Merging/pulling + This will merge updates from the other repository while keeping any changes made to the subtree locally (for example deleted files). ```bash git subtree pull --squash --prefix=$dir$ git@github.com:$repo$.git $commitOrTag$ -m "Update $name$ to $version$" ``` + #### Mr ↣ Montage ```bash @@ -81,13 +91,14 @@ git subtree pull --squash --prefix=packages/mr git@github.com:montagejs/mr.git $ ``` -### Splitting +#### Splitting Splitting allows you take take changes to the subtree from your repository and commit them to the other one. TODO: Write after splitting for the first time -### Adding + +#### Adding This will add all the files in `repo` at `commit` under `dir`, and will create 2 commits diff --git a/composer/composer.js b/composer/composer.js index 1b7c00dc0e..474521ea9b 100644 --- a/composer/composer.js +++ b/composer/composer.js @@ -37,10 +37,10 @@ exports.Composer = Target.specialize( /** @lends Composer# */ { * @default null */ component: { - get: function() { + get: function () { return this._component; }, - set: function(component) { + set: function (component) { this._component = component; } }, @@ -62,10 +62,10 @@ exports.Composer = Target.specialize( /** @lends Composer# */ { * @default null */ element: { - get: function() { + get: function () { return this._element; }, - set: function(element) { + set: function (element) { this._element = element; } }, @@ -100,7 +100,7 @@ exports.Composer = Target.specialize( /** @lends Composer# */ { * @default false */ needsFrame: { - set: function(value) { + set: function (value) { if (this._needsFrame !== value) { this._needsFrame = value; if (this._component) { @@ -110,7 +110,7 @@ exports.Composer = Target.specialize( /** @lends Composer# */ { } } }, - get: function() { + get: function () { return this._needsFrame; } }, @@ -119,11 +119,11 @@ exports.Composer = Target.specialize( /** @lends Composer# */ { * This method will be invoked by the framework at the beginning of a draw * cycle. This is where a composer may implement its update logic if it * needs to respond to draws by its component. - * @method + * @function * @param {Date} timestamp The time that the draw cycle started */ frame: { - value: function(timestamp) { + value: function (timestamp) { } }, @@ -135,7 +135,7 @@ exports.Composer = Target.specialize( /** @lends Composer# */ { * @private */ _resolveDefaults: { - value: function() { + value: function () { if (this.element == null && this.component != null) { this.element = this.component.element; } @@ -147,7 +147,7 @@ exports.Composer = Target.specialize( /** @lends Composer# */ { * @private */ _load: { - value: function() { + value: function () { if (!this.element) { this._resolveDefaults(); } @@ -163,10 +163,10 @@ exports.Composer = Target.specialize( /** @lends Composer# */ { * Subclasses should override `load` with their DOM initialization. Most * composers attach DOM event listeners to `this.element` in `load`. * - * @method + * @function */ load: { - value: function() { + value: function () { } }, @@ -178,10 +178,10 @@ exports.Composer = Target.specialize( /** @lends Composer# */ { * Subclasses should override `unload` to do any necessary cleanup, such as * removing event listeners. * - * @method + * @function */ unload: { - value: function() { + value: function () { } }, @@ -192,7 +192,7 @@ exports.Composer = Target.specialize( /** @lends Composer# */ { * @private */ deserializedFromTemplate: { - value: function() { + value: function () { if (this.component) { this.component.addComposer(this); } diff --git a/composer/key-composer.js b/composer/key-composer.js index 4c2fc1db1a..2f3a905826 100644 --- a/composer/key-composer.js +++ b/composer/key-composer.js @@ -60,10 +60,10 @@ var KeyComposer = exports.KeyComposer = Composer.specialize( /** @lends KeyCompo * @default null */ keys: { - get: function() { + get: function () { return this._keys; }, - set: function(keys) { + set: function (keys) { if (this._keyRegistered) { KeyManagerProxy.defaultKeyManager.unregisterKey(this); this._keys = keys; @@ -75,7 +75,7 @@ var KeyComposer = exports.KeyComposer = Composer.specialize( /** @lends KeyCompo }, load: { - value: function() { + value: function () { // Only register the key if somebody is listening for, else let do // it later. // console.log("--- load", this.identifier); @@ -88,7 +88,7 @@ var KeyComposer = exports.KeyComposer = Composer.specialize( /** @lends KeyCompo }, unload: { - value: function() { + value: function () { this._isLoaded = false; KeyManagerProxy.defaultKeyManager.unregisterKey(this); this._keyRegistered = false; @@ -97,7 +97,7 @@ var KeyComposer = exports.KeyComposer = Composer.specialize( /** @lends KeyCompo /** * Listen to find out when this `KeyComposer` detects a matching key press. - * @method + * @function * @param {string} type Any of the following types: keyPress, longKeyPress * and keyRelease. * @param {Object|function} listener The listener object or function to @@ -106,7 +106,7 @@ var KeyComposer = exports.KeyComposer = Composer.specialize( /** @lends KeyCompo * during the capture phase of the event. */ addEventListener: { - value: function(type, listener, useCapture) { + value: function (type, listener, useCapture) { // Optimisation so that we don't dispatch an event if we do not need to // console.log("--- addEventListener", this.identifier); var component = this.component; @@ -139,7 +139,7 @@ var KeyComposer = exports.KeyComposer = Composer.specialize( /** @lends KeyCompo }, constructor: { - value: function() { + value: function () { // console.log("KEY CREATED") Composer.constructor.call(this); } @@ -152,7 +152,7 @@ var KeyComposer = exports.KeyComposer = Composer.specialize( /** @lends KeyCompo * @private */ deserializedFromTemplate: { - value: function() { + value: function () { var component = this.component; if (this.identifier === null) { @@ -193,7 +193,7 @@ var KeyComposer = exports.KeyComposer = Composer.specialize( /** @lends KeyCompo * @returns {Object} the newly created `KeyComposer` Object */ createKey: { - value: function(component, keys, identifier) { + value: function (component, keys, identifier) { var key = this; if (this === KeyComposer) { @@ -226,14 +226,14 @@ var KeyComposer = exports.KeyComposer = Composer.specialize( /** @lends KeyCompo * * The composer will respond to key events that bubble up to the `window`. * - * @method + * @function * @param {Object} component. The component to attach the keyComposer to. * @param {Object} keys. The key sequence. * @param {Object} identifier. The identifier. * @returns {Object} the newly created KeyComposer Object */ createGlobalKey: { - value: function(component, keys, identifier) { + value: function (component, keys, identifier) { var key = this; if (this === KeyComposer) { @@ -290,18 +290,18 @@ var KeyManagerProxy = Montage.specialize( { * @private */ constructor: { - value: function() { + value: function () { // console.log("PROXY CREATED") } }, /** * Register a `KeyComposer` with the default `KeyManager`. - * @method + * @function * @param {Object} keyComposer. A key composer object. */ registerKey: { - value: function(keyComposer) { + value: function (keyComposer) { var thisRef = this; if (!this._defaultKeyManager) { @@ -310,9 +310,9 @@ var KeyManagerProxy = Montage.specialize( { this._loadingDefaultKeyManager = true; require.async("core/event/key-manager") - .then(function(module) { + .then(function (module) { var keyManager = thisRef._defaultKeyManager = module.defaultKeyManager; - thisRef._keysToRegister.forEach(function(keyComposer) { + thisRef._keysToRegister.forEach(function (keyComposer) { keyManager.registerKey(keyComposer); }); thisRef._keysToRegister.length = 0; @@ -329,11 +329,11 @@ var KeyManagerProxy = Montage.specialize( { /** * Unregister a `KeyComposer` with the default `KeyManager`. - * @method + * @function * @param {Object} keyComposer. A key composer object. */ unregisterKey: { - value: function(keyComposer) { + value: function (keyComposer) { if (this._defaultKeyManager) { this._defaultKeyManager.unregisterKey(keyComposer); } @@ -344,11 +344,11 @@ var KeyManagerProxy = Montage.specialize( { /** * Return either the default `KeyManager` or its `KeyManagerProxy`. - * @method + * @function * @returns {Object} `KeyManager` or `KeyManagerProxy`. */ defaultKeyManager: { - get: function() { + get: function () { if (!_keyManagerProxy) { _keyManagerProxy = new KeyManagerProxy(); } diff --git a/composer/press-composer.js b/composer/press-composer.js index 12aef0c52f..7ec7ae89d0 100644 --- a/composer/press-composer.js +++ b/composer/press-composer.js @@ -1,10 +1,11 @@ /*global require, exports*/ + /** - @module montage/composer/press-composer - @requires montage - @requires montage/composer/composer - @requires montage/core/event/mutable-event -*/ + * @module montage/composer/press-composer + * @requires montage/core/core + * @requires montage/composer/composer + * @requires montage/core/event/mutable-event + */ var Montage = require("../core/core").Montage, Composer = require("./composer").Composer, MutableEvent = require("../core/event/mutable-event").MutableEvent; @@ -14,13 +15,14 @@ var Montage = require("../core/core").Montage, * @classdesc The `PressComposer` abstracts away handling mouse and touch * events that represent presses, allowing generic detection of presses, long * presses, and cancelled presses. + * * @extends Composer * @fires pressStart * @fires press * @fires longPress * @fires pressCancel */ -var PressComposer = exports.PressComposer = Composer.specialize(/** @lends PressComposer# */ { +var PressComposer = exports.PressComposer = Composer.specialize(/** @lends PressComposer.prototype # */ { /** * Dispatched when a press begins. It is ended by either a {@link press} or @@ -68,7 +70,7 @@ var PressComposer = exports.PressComposer = Composer.specialize(/** @lends Press // Load/unload load: { - value: function() { + value: function () { if (window.Touch) { this._element.addEventListener("touchstart", this, true); } else { @@ -78,7 +80,7 @@ var PressComposer = exports.PressComposer = Composer.specialize(/** @lends Press }, unload: { - value: function() { + value: function () { if (window.Touch) { this._element.removeEventListener("touchstart", this, true); } else { @@ -108,7 +110,7 @@ var PressComposer = exports.PressComposer = Composer.specialize(/** @lends Press * already in a unpressed or canceled state. */ cancelPress: { - value: function() { + value: function () { if (this._state === PressComposer.PRESSED) { this._dispatchPressCancel(); this._endInteraction(); @@ -120,7 +122,7 @@ var PressComposer = exports.PressComposer = Composer.specialize(/** @lends Press // Optimisation so that we don't set a timeout if we do not need to addEventListener: { - value: function(type, listener, useCapture) { + value: function (type, listener, useCapture) { Composer.addEventListener.call(this, type, listener, useCapture); if (type === "longPress") { this._shouldDispatchLongPress = true; @@ -143,7 +145,7 @@ var PressComposer = exports.PressComposer = Composer.specialize(/** @lends Press value: 0 }, state: { - get: function() { + get: function () { return this._state; } }, @@ -163,10 +165,10 @@ var PressComposer = exports.PressComposer = Composer.specialize(/** @lends Press * @type number */ longPressThreshold: { - get: function() { + get: function () { return this._longPressThreshold; }, - set: function(value) { + set: function (value) { if (this._longPressThreshold !== value) { this._longPressThreshold = value; } @@ -189,7 +191,7 @@ var PressComposer = exports.PressComposer = Composer.specialize(/** @lends Press // and handleMousedown _startInteraction: { enumerable: false, - value: function(event) { + value: function (event) { if ( ("enabled" in this.component && !this.component.enabled) || this._observedPointer !== null @@ -236,7 +238,7 @@ var PressComposer = exports.PressComposer = Composer.specialize(/** @lends Press * @private */ _interpretInteraction: { - value: function(event) { + value: function (event) { // TODO maybe the code should be moved out to handleClick and // handleMouseup var isSurrendered, target, isTarget; @@ -282,7 +284,7 @@ var PressComposer = exports.PressComposer = Composer.specialize(/** @lends Press * @private */ _endInteraction: { - value: function(event) { + value: function (event) { document.removeEventListener("touchend", this); document.removeEventListener("touchcancel", this); document.removeEventListener("click", this); @@ -302,12 +304,12 @@ var PressComposer = exports.PressComposer = Composer.specialize(/** @lends Press * to check against `!== false` or `=== false` as the * matching index might be 0. * - * @method + * @function * @returns {number|boolean} The index of the matching touch, or false * @private */ _changedTouchisObserved: { - value: function(changedTouches) { + value: function (changedTouches) { if (this._observedPointer === null) { return false; } @@ -326,7 +328,7 @@ var PressComposer = exports.PressComposer = Composer.specialize(/** @lends Press // Surrender pointer surrenderPointer: { - value: function(pointer, component) { + value: function (pointer, component) { var shouldSurrender = this.callDelegateMethod("surrenderPointer", pointer, component); if (typeof shouldSurrender !== "undefined" && shouldSurrender === false) { return false; @@ -340,12 +342,12 @@ var PressComposer = exports.PressComposer = Composer.specialize(/** @lends Press // Handlers captureTouchstart: { - value: function(event) { + value: function (event) { this._startInteraction(event); } }, handleTouchend: { - value: function(event) { + value: function (event) { if (this._observedPointer === null) { this._endInteraction(event); return; @@ -362,7 +364,7 @@ var PressComposer = exports.PressComposer = Composer.specialize(/** @lends Press } }, handleTouchcancel: { - value: function(event) { + value: function (event) { if (this._observedPointer === null || this._changedTouchisObserved(event.changedTouches) !== false) { if (this.component.eventManager.isPointerClaimedByComponent(this._observedPointer, this)) { this._dispatchPressCancel(event); @@ -373,22 +375,22 @@ var PressComposer = exports.PressComposer = Composer.specialize(/** @lends Press }, captureMousedown: { - value: function(event) { + value: function (event) { this._startInteraction(event); } }, handleClick: { - value: function(event) { + value: function (event) { this._interpretInteraction(event); } }, handleMouseup: { - value: function(event) { + value: function (event) { this._interpretInteraction(event); } }, handleDragstart: { - value: function(event) { + value: function (event) { this._dispatchPressCancel(event); this._endInteraction(); } @@ -398,7 +400,7 @@ var PressComposer = exports.PressComposer = Composer.specialize(/** @lends Press _createPressEvent: { enumerable: false, - value: function(name, event) { + value: function (name, event) { var pressEvent, detail, index; if (!event) { @@ -481,7 +483,7 @@ var PressComposer = exports.PressComposer = Composer.specialize(/** @lends Press * @classdesc The event dispatched by the `PressComposer`, providing access to * the raw DOM event and proxying its properties. */ -var PressEvent = (function(){ +var PressEvent = (function (){ var value, eventProps, typeProps, eventPropDescriptor, typePropDescriptor, i; value = MutableEvent.specialize({ @@ -493,10 +495,10 @@ var PressEvent = (function(){ value: null }, event: { - get: function() { + get: function () { return this._event; }, - set: function(value) { + set: function (value) { this._event = value; } }, @@ -505,10 +507,10 @@ var PressEvent = (function(){ value: null }, touch: { - get: function() { + get: function () { return this._touch; }, - set: function(value) { + set: function (value) { this._touch = value; } } @@ -523,16 +525,16 @@ var PressEvent = (function(){ // on the _touch in the case of touch typeProps = ["clientX", "clientY", "pageX", "pageY", "screenX", "screenY", "target"]; - eventPropDescriptor = function(prop) { + eventPropDescriptor = function (prop) { return { - get: function() { + get: function () { return this._event[prop]; } }; }; - typePropDescriptor = function(prop) { + typePropDescriptor = function (prop) { return { - get: function() { + get: function () { return (this._touch) ? this._touch[prop] : this._event[prop]; } }; diff --git a/composer/swipe-composer.js b/composer/swipe-composer.js index a8b3a2af6a..53095cd383 100644 --- a/composer/swipe-composer.js +++ b/composer/swipe-composer.js @@ -14,13 +14,13 @@ var Montage = require("../core/core").Montage, exports.SwipeComposer = Composer.specialize( /** @lends SwipeComposer# */ { load: { - value: function() { + value: function () { document.addEventListener("touchstart", this, true); } }, unload: { - value: function() { + value: function () { document.removeEventListener("touchstart", this, true); } }, @@ -71,7 +71,7 @@ exports.SwipeComposer = Composer.specialize( /** @lends SwipeComposer# */ { }, captureTouchstart: { - value: function(event) { + value: function (event) { this._reset(); var touches = event.touches, touch = touches[0]; @@ -86,7 +86,7 @@ exports.SwipeComposer = Composer.specialize( /** @lends SwipeComposer# */ { _reset: { enumerable: false, - value: function() { + value: function () { this._startX = 0; this._startY = 0; this._deltaX = 0; @@ -101,7 +101,7 @@ exports.SwipeComposer = Composer.specialize( /** @lends SwipeComposer# */ { }, captureTouchcancel: { - value: function(event) { + value: function (event) { document.removeEventListener("touchmove", this, true); document.removeEventListener("touchend", this, true); document.removeEventListener("touchcancel", this, true); @@ -109,7 +109,7 @@ exports.SwipeComposer = Composer.specialize( /** @lends SwipeComposer# */ { }, captureTouchmove: { - value: function(event) { + value: function (event) { event.preventDefault(); var touches = event.changedTouches[0], swipeEvent, direction; @@ -169,14 +169,14 @@ exports.SwipeComposer = Composer.specialize( /** @lends SwipeComposer# */ { _findSwipeAngle: { enumerable: false, - value: function(dX, dY) { + value: function (dX, dY) { var swipeAngle = -1 * (Math.atan2(dY, dX) * 180 / 3.14); return swipeAngle.toFixed(2); } }, captureTouchend: { - value: function(event) { + value: function (event) { if (event == null) { return; @@ -227,7 +227,7 @@ exports.SwipeComposer = Composer.specialize( /** @lends SwipeComposer# */ { _findVelocity: { enumerable: false, - value: function(deltaTime) { + value: function (deltaTime) { return (Math.sqrt(/*xSquare*/(this._deltaX * this._deltaX) + /*ySquare*/(this._deltaY * this._deltaY)) / /*deltaTime*/(deltaTime)); } diff --git a/composer/translate-composer.js b/composer/translate-composer.js index c4e2f12b76..7589adbec4 100644 --- a/composer/translate-composer.js +++ b/composer/translate-composer.js @@ -16,9 +16,9 @@ var Composer = require("./composer").Composer, * * @class TranslateComposer * @extends Composer - * @emits translate - * @emits translateStart - * @emits translateEnd + * @fires translate + * @fires translateStart + * @fires translateEnd * @classdesc A composer that elevates touch and mouse events into drag events. */ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @lends TranslateComposer# */ { @@ -97,7 +97,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, frame: { - value: function() { + value: function () { if (this.isAnimating) { this._animationInterval(); } @@ -115,10 +115,10 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len * @default 1 */ pointerSpeedMultiplier: { - get: function() { + get: function () { return this._pointerSpeedMultiplier; }, - set: function(value) { + set: function (value) { this._pointerSpeedMultiplier = value; } }, @@ -145,10 +145,10 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len * @default false */ allowFloats: { - get: function() { + get: function () { return this._allowFloats; }, - set: function(value) { + set: function (value) { if (this._allowFloats !== value) { this._allowFloats = value; this.translateX = this._translateX; @@ -169,10 +169,10 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len * @default 0 */ translateX: { - get: function() { + get: function () { return this._translateX; }, - set: function(value) { + set: function (value) { if (this._axis === "vertical") { this._translateX = this._minTranslateX || 0; } else { @@ -206,10 +206,10 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len * @default 0 */ translateY: { - get: function() { + get: function () { return this._translateY; }, - set: function(value) { + set: function (value) { if (this._axis === "horizontal") { this._translateY = this._minTranslateY || 0; } else { @@ -242,10 +242,10 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len * @default null */ minTranslateX: { - get: function() { + get: function () { return this._minTranslateX; }, - set: function(value) { + set: function (value) { if (value !== null) { value = parseFloat(value); } @@ -270,10 +270,10 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len * @default null */ maxTranslateX: { - get: function() { + get: function () { return this._maxTranslateX; }, - set: function(value) { + set: function (value) { if (value !== null) { value = parseFloat(value); } @@ -298,10 +298,10 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len * @default null */ minTranslateY: { - get: function() { + get: function () { return this._minTranslateY; }, - set: function(value) { + set: function (value) { if (value !== null) { value = parseFloat(value); } @@ -326,10 +326,10 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len * @default null */ maxTranslateY: { - get: function() { + get: function () { return this._maxTranslateY; }, - set: function(value) { + set: function (value) { if (value !== null) { value = parseFloat(value); } @@ -355,10 +355,10 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len * @default "both" */ axis: { - get: function() { + get: function () { return this._axis; }, - set: function(value) { + set: function (value) { switch (value) { case "vertical": case "horizontal": @@ -386,10 +386,10 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len */ invertAxis: { depends: ["invertXAxis", "invertYAxis"], - get: function() { + get: function () { return (this._invertXAxis === this._invertYAxis) ? this._invertXAxis : null; }, - set: function(value) { + set: function (value) { this.invertXAxis = value; this.invertYAxis = value; } @@ -407,10 +407,10 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len * @default false */ invertXAxis: { - get: function() { + get: function () { return this._invertXAxis; }, - set: function(value) { + set: function (value) { this._invertXAxis = !!value; } }, @@ -427,10 +427,10 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len * @default false */ invertYAxis: { - get: function() { + get: function () { return this._invertYAxis; }, - set: function(value) { + set: function (value) { this._invertYAxis = !!value; } }, @@ -459,10 +459,10 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len * @default true */ hasMomentum: { - get: function() { + get: function () { return this._hasMomentum; }, - set: function(value) { + set: function (value) { this._hasMomentum = value ? true : false; } }, @@ -472,10 +472,10 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, _momentumDuration: { - get: function() { + get: function () { return this.__momentumDuration; }, - set: function(value) { + set: function (value) { //jshint -W016 this.__momentumDuration = isNaN(value) ? 1 : value >> 0; //jshint +W016 @@ -502,7 +502,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, _start: { - value: function(x, y, target, timeStamp) { + value: function (x, y, target, timeStamp) { this.pointerStartEventPosition = { pageX: x, pageY: y, @@ -539,7 +539,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len * @private **/ _shouldPreventDefault: { - value: function(event) { + value: function (event) { return !!event.target.tagName && TranslateComposer._NATIVE_ELEMENTS.indexOf(event.target.tagName) === -1 && !event.target.isContentEditable; } }, @@ -547,12 +547,12 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len /** * Handle the mousedown that bubbled back up from beneath the element * If nobody else claimed this pointer, we should handle it now - * @method + * @function * @param {Event} event * @private */ handleMousedown: { - value: function(event) { + value: function (event) { if (!this.enabled) return; this._observedPointer = "mouse"; @@ -565,7 +565,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, captureMousemove: { - value: function(event) { + value: function (event) { if (!this.enabled) return; if (this.eventManager.isPointerClaimedByComponent(this._observedPointer, this)) { @@ -580,7 +580,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, captureMouseup: { - value: function(event) { + value: function (event) { if (!this.enabled) return; this._end(event); @@ -588,7 +588,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, _releaseInterest: { // unload?? - value: function() { + value: function () { if (window.Touch) { this._element.removeEventListener("touchend", this, true); @@ -615,7 +615,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, captureTouchstart: { - value: function(event) { + value: function (event) { if (!this.enabled) return; if (this._shouldPreventDefault(event)) { @@ -635,7 +635,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, captureTouchmove: { - value: function(event) { + value: function (event) { var timeToMove; if (!this.enabled) return; if (this.stealChildrenPointer && this._isAxisMovement(event.targetTouches[0])) { @@ -648,7 +648,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, handleTouchmove: { - value: function(event) { + value: function (event) { if (!this.enabled) return; var i = 0, len = event.changedTouches.length; @@ -683,7 +683,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, captureTouchend: { - value: function(event) { + value: function (event) { if (!this.enabled) return; var i = 0, len = event.changedTouches.length; @@ -697,7 +697,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, captureTouchcancel: { - value: function(event) { + value: function (event) { var i = 0, len = event.changedTouches.length; while (i < len && event.changedTouches[i].identifier !== this._observedPointer) { i++; @@ -709,7 +709,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, _isAxisMovement: { - value: function(event) { + value: function (event) { var velocity = event.velocity, lowerRight = 0.7853981633974483, // pi/4 lowerLeft = 2.356194490192345, // 3pi/4 @@ -763,7 +763,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, captureWheel: { - value: function() { + value: function () { if (!this.eventManager.componentClaimingPointer(this._WHEEL_POINTER)) { this.eventManager.claimPointer(this._WHEEL_POINTER, this.component); } @@ -771,7 +771,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, handleWheel: { - value: function(event) { + value: function (event) { if (!this.enabled) return; var self = this; @@ -784,7 +784,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len this.translateY = this._translateY - ((deltaY * 20) / 120); this._dispatchTranslate(); window.clearTimeout(this._translateEndTimeout); - this._translateEndTimeout = window.setTimeout(function() { + this._translateEndTimeout = window.setTimeout(function () { self._dispatchTranslateEnd(); }, 400); @@ -800,7 +800,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, _firstMove: { - value: function() { + value: function () { if (this._isFirstMove) { this._dispatchTranslateStart(this._translateX, this._translateY); this._isFirstMove = false; @@ -818,7 +818,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, _move: { - value: function(x, y) { + value: function (x, y) { var pointerDelta; this._isSelfUpdate = true; @@ -842,7 +842,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, _bezierTValue: { - value: function(x, p1x, p1y, p2x, p2y) { + value: function (x, p1x, p1y, p2x, p2y) { var a = 1 - 3 * p2x + 3 * p1x, b = 3 * p2x - 6 * p1x, c = 3 * p1x, @@ -862,7 +862,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, _dispatchTranslateStart: { - value: function(x, y) { + value: function (x, y) { var translateStartEvent = document.createEvent("CustomEvent"); translateStartEvent.initCustomEvent("translateStart", true, true, null); @@ -876,7 +876,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, _dispatchTranslateEnd: { - value: function() { + value: function () { var translateEndEvent = document.createEvent("CustomEvent"); translateEndEvent.initCustomEvent("translateEnd", true, true, null); @@ -889,7 +889,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, _dispatchTranslateCancel: { - value: function() { + value: function () { var translateCancelEvent = document.createEvent("CustomEvent"); translateCancelEvent.initCustomEvent("translateCancel", true, true, null); @@ -902,7 +902,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, _dispatchTranslate: { - value: function() { + value: function () { var translateEvent = document.createEvent("CustomEvent"); translateEvent.initCustomEvent("translate", true, true, null); translateEvent.translateX = this._translateX; @@ -1056,7 +1056,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, surrenderPointer: { - value: function(pointer, demandingComponent) { + value: function (pointer, demandingComponent) { return ! this.isMoving && demandingComponent.stealChildrenPointer && // assuming that demanding component is a (great)*child @@ -1065,13 +1065,13 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len }, eventManager: { - get: function() { + get: function () { return defaultEventManager; } }, load: { - value: function() { + value: function () { if (window.Touch) { this._element.addEventListener("touchstart", this, true); this._element.addEventListener("touchstart", this, false); @@ -1100,7 +1100,7 @@ var TranslateComposer = exports.TranslateComposer = Composer.specialize(/** @len * @param {boolean} use capture instead of bubble */ addEventListener: { - value: function(type, listener, useCapture) { + value: function (type, listener, useCapture) { Composer.addEventListener.call(this, type, listener, useCapture); if (type === "translate") { this._shouldDispatchTranslate = true; diff --git a/core/application.js b/core/application.js index 0d4ed0cb4b..de31f40f37 100644 --- a/core/application.js +++ b/core/application.js @@ -1,5 +1,4 @@ /** - * This module defines the {Application} prototype. * @module core/application * @requires event/event-manager * @requires template @@ -19,22 +18,24 @@ var Montage = require("./core").Montage, require("./dom"); /** - * The application is a singleton, it initially loads and oversees the running - * program. + * The application is a singleton, it initially loads and oversees the running program. * It is also responsible for window management. * The behavior of the application can be modified by implementing a delegate - * {Application#delegate}. + * {@link Application#delegate}. * It is also possible to subclass the application by specifying an - * `applicationPrototype"` in `the package.json`. + * `applicationPrototype"` in the `package.json`. + * * @class Application * @extends Target */ -var Application = exports.Application = Target.specialize( /** @lends Application# */ { +var Application = exports.Application = Target.specialize( /** @lends Application.prototype # */ { /** * Provides a reference to the Montage event manager used in the * application. - * @type {EventManager} + * + * @property {EventManager} value + * @default null */ eventManager: { value: null @@ -42,7 +43,8 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio /** * Provides a reference to the parent application. - * @type {Application} + * + * @property {Application} value * @default null */ parentApplication: { @@ -51,11 +53,12 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio /** * Provides a reference to the main application. + * * @type {Application} * @default this */ mainApplication: { - get: function() { + get: function () { // JFD TODO: We should cache the result, would need to update it // when the window is detached or attached var mainApplication = this; @@ -66,8 +69,11 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio } }, - // possible values: "z-order", "reverse-z-order", "z-order", - // "reverse-open-order" + /** + * possible values: "z-order", "reverse-z-order", "z-order", "reverse-open-order" + * @private + * @property {String} value + */ _windowsSortOrder: { value: "reverse-z-order" }, @@ -76,11 +82,12 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio * Determines the sort order for the Application.windows array. * Possible values are: z-order, reverse-z-order, open-order, * reverse-open-order - * @type {string} + * + * @returns {string} * @default "reverse-z-order" */ windowsSortOrder: { - get: function() { + get: function () { if (this.parentApplication == null) { return this._windowsSortOrder; } else { @@ -88,7 +95,7 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio } }, - set: function(value) { + set: function (value) { if (this.parentApplication == null) { if (["z-order", "reverse-z-order", "z-order", "reverse-open-order"].indexOf(value) !== -1) { this._windowsSortOrder = value; @@ -104,10 +111,11 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio * or any of its descendents, including the main window itself. * The list is kept sorted, the sort order is determined by the * `Application.windowsSortOrder` property - * @type {Array} + * + * @returns {Array} */ windows: { - get: function() { + get: function () { var theWindow; if (this.parentApplication == null) { @@ -134,10 +142,11 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio /** * Provides a reference to the MontageWindow associated with the * application. - * @type {MontageWindow} + * + * @returns {MontageWindow} */ window: { - get: function() { + get: function () { if (!this._window && this == this.mainApplication) { var theWindow = new MontageWindow(); theWindow.application = this; @@ -147,7 +156,7 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio return this._window; }, - set: function(value) { + set: function (value) { if (!this._window) { this._window = value; } @@ -165,12 +174,12 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio /** * Returns the event manager for the specified window object. - * @method + * @function * @param {Window} aWindow The browser window whose event manager object should be returned. * @returns aWindow.defaultEventMananger */ eventManagerForWindow: { - value: function(aWindow) { + value: function (aWindow) { return aWindow.defaultEventMananger; } }, @@ -181,7 +190,7 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio * @default document.defaultView */ focusWindow: { - get: function() { + get: function () { var windows = this.windows, sortOrder = this.windowsSortOrder; @@ -225,28 +234,29 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio * The component URL must be in the same domain as the calling script. Can * be relative to the main application * - * @method + * @function * @param {string} component, the path to the reel component to open in the * new window. * @param {string} name, the component main class name. * @param {Object} parameters, the new window parameters (accept same * parameters than window.open). + * * @example * var app = document.application; * app.openWindow("docs/help.reel", "Help", "{width:300, height:500}"); */ openWindow: { - value: function(component, name, parameters) { + value: function (component, name, parameters) { var thisRef = this, childWindow = new MontageWindow(), childApplication, event, windowParams = { location: false, -// height: , -// width: , -// left: , -// top: , + // height: , + // width: , + // left: , + // top: , menubar: false, resizable: true, scrollbars: true, @@ -259,7 +269,7 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio module: component, name: name, parent: window, - callback: function(aWindow, aComponent) { + callback: function (aWindow, aComponent) { var sortOrder; // Finishing the window object initialization and let the consumer knows the window is loaded and ready @@ -319,7 +329,7 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio } } - self.mr.loadPackage({name: "montage"}).then(function(require) { + self.mr.loadPackage({name: "montage"}).then(function (require) { var newWindow = window.open(require.location + "window-loader/index.html", "_blank", stringParamaters); newWindow.loadInfo = loadInfo; }).done(); @@ -332,11 +342,11 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio * Attach a window to a parent application. * When a window open, it is automatically attached to the Application used * to create the window. - * @method + * @function * @param {MontageWindow} window to detach. */ attachWindow: { - value: function(montageWindow) { + value: function (montageWindow) { var parentApplicaton = montageWindow.application.parentApplication, sortOrder; @@ -364,11 +374,11 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio * Detach the window from its parent application. * If no montageWindow is specified, the current application's windows will * be detached. - * @method + * @function * @param {MontageWindow} window to detach. */ detachWindow: { - value: function(montageWindow) { + value: function (montageWindow) { var index, parentApplicaton, windows = this.windows; @@ -404,7 +414,7 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio }, _load: { - value: function(applicationRequire, callback) { + value: function (applicationRequire, callback) { var rootComponent, self = this; @@ -412,12 +422,12 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio exports.application = self; require.async("ui/component") - .then(function(exports) { + .then(function (exports) { rootComponent = exports.__root__; rootComponent.element = document; return require("./template").instantiateDocument(window.document, applicationRequire) - .then(function(part) { + .then(function (part) { self.callDelegateMethod("willFinishLoading", self); rootComponent.needsDraw = true; if (callback) { @@ -429,17 +439,34 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio } }, - // @private + /** + * @private + */ _alertPopup: {value: null, enumerable: false}, + /** + * @private + */ _confirmPopup: {value: null, enumerable: false}, + /** + * @private + */ _notifyPopup: {value: null, enumerable: false}, + /** + * @private + */ _zIndex: {value: null}, - _isSystemPopup: {value: function(type) { + /** + * @private + */ + _isSystemPopup: {value: function (type) { return (type === 'alert' || type === 'confirm' || type === 'notify'); }}, - _createPopupSlot: {value: function(zIndex) { + /** + * @private + */ + _createPopupSlot: {value: function (zIndex) { var slotEl = document.createElement('div'); document.body.appendChild(slotEl); slotEl.style.zIndex = zIndex; @@ -452,11 +479,11 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio }}, getPopupSlot: { - value: function(type, content, callback) { + value: function (type, content, callback) { var self = this; require.async("ui/slot.reel/slot") - .then(function(exports) { + .then(function (exports) { Slot = Slot || exports.Slot; type = type || "custom"; var isSystemPopup = self._isSystemPopup(type), zIndex, slotEl, popupSlot; @@ -501,7 +528,7 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio } }, - returnPopupSlot: {value: function(type) { + returnPopupSlot: {value: function (type) { var self = this; if(self.popupSlots && self.popupSlots[type]) { var popupSlot = self.popupSlots[type]; @@ -512,9 +539,11 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio }}, - // private + /** + * @private + */ _getActivePopupSlots: { - value: function() { + value: function () { var arr = []; if(this.popupSlots) { var keys = Object.keys(this.popupSlots); @@ -532,6 +561,5 @@ var Application = exports.Application = Target.specialize( /** @lends Applicatio return arr; } } - }); diff --git a/core/bindings.js b/core/bindings.js index 5e165593c3..fb943f8771 100644 --- a/core/bindings.js +++ b/core/bindings.js @@ -1,4 +1,11 @@ -// logs: montage/core/bindings is deprecated, use montage/core/core instead. +/** + * @module montage/core/bindings + * @require montage/core/deprecate + */ + require("./deprecate").deprecationWarning("montage/core/bindings", "montage/core/core"); +/** + * @deprecated console.log montage/core/bindings is deprecated, use montage/core/core instead + */ exports.Bindings = require("frb"); diff --git a/core/bitfield.js b/core/bitfield.js index de766af629..ee9f4ef90d 100644 --- a/core/bitfield.js +++ b/core/bitfield.js @@ -26,7 +26,7 @@ var BitField = exports.BitField = Montage.specialize( /** @lends BitField */ { /** * Creates a new BitField object containing the fields provided in the * propertyDescriptor parameter. - * @method + * @function * @param {Object} propertyDescriptor An object containing one or more * property name/value pairs. * Each pair is added to the new BitField. @@ -48,7 +48,7 @@ var BitField = exports.BitField = Montage.specialize( /** @lends BitField */ { */ initWithDescriptor: { enumerable: false, - value: function(propertyDescriptor) { + value: function (propertyDescriptor) { var fieldName; this.reset(); for (fieldName in propertyDescriptor) { @@ -60,13 +60,13 @@ var BitField = exports.BitField = Montage.specialize( /** @lends BitField */ { /** * Adds a new field to a BitField instance. - * @method + * @function * @param {string} aFieldName The name of the field to add. * @param {Mixed} defaultValue The new field's default value. */ addField: { enumerable: false, - value: function(aFieldName, defaultValue) { + value: function (aFieldName, defaultValue) { if (aFieldName in this) { return; } @@ -77,10 +77,10 @@ var BitField = exports.BitField = Montage.specialize( /** @lends BitField */ { this._trueValue += (this._fields[aFieldName] = this._constantsToReuse.length ? this._constantsToReuse.shift() : (1 << this._fieldCount)); Montage.defineProperty(this, aFieldName, { enumerable: true, - get: function() { + get: function () { return (this._value === this._trueValue); }, - set: function(value) { + set: function (value) { value ? (this._value |= this._fields[aFieldName]) : (this._value &= ~ (this._fields[aFieldName])); if (this.value) { this.callDelegateMethod(); @@ -101,12 +101,12 @@ var BitField = exports.BitField = Montage.specialize( /** @lends BitField */ { /** * Removes a field from the bitfield. - * @method + * @function * @param {string} aFieldName The name of the field to remove. */ removeField: { enumerable: false, - value: function(aFieldName) { + value: function (aFieldName) { delete this[aFieldName]; this._constantsToReuse.push(this._fields[aFieldName]); this._trueValue -= this._fields[aFieldName]; @@ -125,11 +125,11 @@ var BitField = exports.BitField = Montage.specialize( /** @lends BitField */ { }, /** - * @method + * @function * @returns Nothing */ callDelegateMethod: { - value: function() { + value: function () { var delegateMethod; if (this.delegate && typeof (delegateMethod = this.delegate.bitFieldDidBecomeTrue) === "function") { delegateMethod.call(this.delegate, this); @@ -143,7 +143,7 @@ var BitField = exports.BitField = Montage.specialize( /** @lends BitField */ { */ value: { enumerable: false, - get: function() { + get: function () { return (this._value === this._trueValue); } }, @@ -165,11 +165,11 @@ var BitField = exports.BitField = Montage.specialize( /** @lends BitField */ { }, /** - * @method + * @function */ reset: { enumerable: false, - value: function() { + value: function () { this._value = 0x0; } }, @@ -180,10 +180,10 @@ var BitField = exports.BitField = Montage.specialize( /** @lends BitField */ { }, /** - * @method + * @function */ toString: { - value: function() { + value: function () { var fieldNames = this._fields, i, iField, diff --git a/core/converter/bytes-converter.js b/core/converter/bytes-converter.js index 595771a5dc..8d573a0b7a 100644 --- a/core/converter/bytes-converter.js +++ b/core/converter/bytes-converter.js @@ -20,10 +20,10 @@ var NUMERIC_SCALE_PREFIXES_BYTES = [ * Binary conversion. * @function * @param {string} stringValue String to be converted to numeric value. - * @return {number} Numeric value for string. + * @returns {number} Numeric value for string. * @private */ -var stringToNumBytes = function(stringValue) { +var stringToNumBytes = function (stringValue) { return _stringToNumericValue(stringValue, NUMERIC_SCALES_BINARY_); }; @@ -37,10 +37,10 @@ var stringToNumBytes = function(stringValue) { * Defaults to 2. * @param {?boolean} suffix=true If true, include trailing 'B' in returned * string. Default is true. - * @return {string} String representation of number of bytes. + * @returns {string} String representation of number of bytes. * @private */ -var numBytesToString = function(val, opt_decimals, opt_suffix) { +var numBytesToString = function (val, opt_decimals, opt_suffix) { var suffix = ''; if (!isDef(opt_suffix) || opt_suffix) { suffix = 'B'; @@ -54,10 +54,10 @@ var numBytesToString = function(val, opt_decimals, opt_suffix) { * @param {number} bytes The number of bytes to show. * @param {number} decimals=2 The number of decimals to use. * Defaults to 2. - * @return {string} The human readable form of the byte size. + * @returns {string} The human readable form of the byte size. * @private */ -var fileSize = function(bytes, opt_decimals) { +var fileSize = function (bytes, opt_decimals) { return numBytesToString(bytes, opt_decimals, false); }; @@ -80,7 +80,7 @@ exports.BytesConverter = Converter.specialize( /** @lends BytesConverter# */ { /** * Converts the specified value to byte format. - * @method + * @function * @param {Property} v The value to format. * @returns {string} The value converted to byte format. * @example @@ -94,14 +94,14 @@ exports.BytesConverter = Converter.specialize( /** @lends BytesConverter# */ { * // Reverted: 12341234 */ convert: { - value: function(v) { + value: function (v) { return fileSize(v, this.decimals); } }, /** * Reverts a formatted byte string to a standard number. - * @method + * @function * @param {string} v The value to revert. * @returns {string} v * @see BytesConverter#convert @@ -114,7 +114,7 @@ exports.BytesConverter = Converter.specialize( /** @lends BytesConverter# */ { * // Reverted: 12341234 */ revert: { - value: function(v) { + value: function (v) { return v; } } diff --git a/core/converter/converter.js b/core/converter/converter.js index 1dcd292e81..e1e139f032 100644 --- a/core/converter/converter.js +++ b/core/converter/converter.js @@ -1,12 +1,15 @@ /** * Provides common conversion, validation, and formatting functions for * different types of values. + * * @module montage/core/converter/converter * @requires montage/core/core */ var Montage = require("../core").Montage; - +/** + * @const {string} + */ var FUNCTION_CLASS = '[object Function]', BOOLEAN_CLASS = '[object Boolean]', NUMBER_CLASS = '[object Number]', @@ -16,13 +19,12 @@ var FUNCTION_CLASS = '[object Function]', var _toString = Object.prototype.toString; - /** * @exports module:montage/core/converter#isNumber * @function * @private */ -var isNumber = function(object) { +var isNumber = function (object) { return _toString.call(object) === NUMBER_CLASS; }; exports.isNumber = isNumber; @@ -33,7 +35,7 @@ exports.isNumber = isNumber; * @function * @private */ -var isDef = function(obj) { +var isDef = function (obj) { return (obj && typeof obj !== 'undefined'); }; exports.isDef = isDef; @@ -81,7 +83,7 @@ var Converter = exports.Converter = Montage.specialize( /** @lends Converter# */ /** * Converts values from the input domain into the output range. - * @method + * @function * @default null */ convert: { @@ -93,7 +95,7 @@ var Converter = exports.Converter = Montage.specialize( /** @lends Converter# */ * Optionally, reverts values from the output range, back into the input * range. This may not be possible with high fidelity depending on the * relationship between these domains. - * @method + * @function * @default null */ revert: { diff --git a/core/converter/currency-converter.js b/core/converter/currency-converter.js index 5cd26bb248..9beea597bc 100644 --- a/core/converter/currency-converter.js +++ b/core/converter/currency-converter.js @@ -53,12 +53,12 @@ exports.CurrencyConverter = NumberConverter.specialize( /** @lends CurrencyConve }, /** - * @method + * @function * @param {number} amount * @returns {string} The formatted currency value. */ convert: { - value: function(amount) { + value: function (amount) { var stringValue = this.super(amount); if ((amount < 0) && this.useParensForNegative) { stringValue = '(' + stringValue.substring(1, stringValue.length) + ')'; diff --git a/core/converter/date-converter.js b/core/converter/date-converter.js index 45d41ffada..576e46525c 100644 --- a/core/converter/date-converter.js +++ b/core/converter/date-converter.js @@ -1,14 +1,3 @@ -/** - * @version: 1.0 Alpha-1 - * @author: Coolite Inc. http://www.coolite.com/ - * @date: 2008-04-13 - * @copyright: Copyright (c) 2006-2008, Coolite Inc. (http://www.coolite.com/). - * All rights reserved. - * @license: Licensed under The MIT License. See license.txt and - * http://www.datejs.com/license/. - * @website: http://www.datejs.com/ - */ - /** * @module montage/core/converter/date-converter * @requires montage/core/core @@ -18,6 +7,16 @@ var Montage = require("../core").Montage, Converter = require("./converter").Converter, Validator = require("./converter").Validator; +/** + * 2008-04-13 + * + * @version: 1.0 Alpha-1 + * @author: Coolite Inc. http://www.coolite.com/ + * @copyright Copyright (c) 2006-2008, Coolite Inc. (http://www.coolite.com/). All rights reserved. + * @license MIT + * @see http://www.datejs.com/ + * @todo https://github.com/montagejs/montage/issues/1539 + */ (function () { var $D = Date, $P = $D.prototype, @@ -31,9 +30,9 @@ var Montage = require("../core").Montage, /** * Resets the time of this Date object to 12:00 AM (00:00), which is the start of the day. - * @method + * @function * @param {boolean} .clone() this date instance before clearing Time - * @return {Date} itself + * @returns {Date} itself */ $P.clearTime = function () { this.setHours(0); @@ -45,8 +44,8 @@ var Montage = require("../core").Montage, /** * Resets the time of this Date object to the current time ('now'). - * @method - * @return {Date} itself + * @function + * @returns {Date} itself */ $P.setTimeToNow = function () { var n = new Date(); @@ -60,7 +59,7 @@ var Montage = require("../core").Montage, /** * Gets a date that is set to the current date. The time is set to the start of the day (00:00 or 12:00 AM). * @function - * @return {Date} The current date. + * @returns {Date} The current date. */ $D.today = function () { return new Date().clearTime(); @@ -71,7 +70,7 @@ var Montage = require("../core").Montage, * @function * @param {Date} First Date object to compare [Required]. * @param {Date} Second Date object to compare to [Required]. - * @return {number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. + * @returns {number} -1 = date1 is lessthan date2. 0 = values are equal. 1 = date1 is greaterthan date2. */ $D.compare = function (date1, date2) { if (isNaN(date1) || isNaN(date2)) { @@ -88,7 +87,7 @@ var Montage = require("../core").Montage, * @function * @param {Date} First Date object to compare [Required] * @param {Date} Second Date object to compare to [Required] - * @return {boolean} true if dates are equal. false if they are not equal. + * @returns {boolean} true if dates are equal. false if they are not equal. */ $D.equals = function (date1, date2) { return (date1.compareTo(date2) === 0); @@ -98,7 +97,7 @@ var Montage = require("../core").Montage, * Gets the day number (0-6) if given a CultureInfo specific string which is a valid dayName, abbreviatedDayName or shortestDayName (two char). * @function * @param {string} The name of the day (eg. "Monday, "Mon", "tuesday", "tue", "We", "we"). - * @return {number} The day number + * @returns {number} The day number */ $D.getDayNumberFromName = function (name) { var n = $C.dayNames, m = $C.abbreviatedDayNames, o = $C.shortestDayNames, s = name.toLowerCase(); @@ -112,9 +111,9 @@ var Montage = require("../core").Montage, /** * Gets the month number (0-11) if given a Culture Info specific string which is a valid monthName or abbreviatedMonthName. - * @method + * @function * @param {string} The name of the month (eg. "February, "Feb", "october", "oct"). - * @return {number} The day number + * @returns {number} The day number */ $D.getMonthNumberFromName = function (name) { var n = $C.monthNames, m = $C.abbreviatedMonthNames, s = name.toLowerCase(); @@ -130,7 +129,7 @@ var Montage = require("../core").Montage, * Determines if the current date instance is within a LeapYear. * @function * @param {number} The year. - * @return {boolean} true if date is within a LeapYear, otherwise false. + * @returns {boolean} true if date is within a LeapYear, otherwise false. */ $D.isLeapYear = function (year) { return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0); @@ -141,7 +140,7 @@ var Montage = require("../core").Montage, * @function * @param {number} The year. * @param {number} The month (0-11). - * @return {number} The number of days in the month. + * @returns {number} The number of days in the month. */ $D.getDaysInMonth = function (year, month) { return [31, ($D.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month]; @@ -178,8 +177,8 @@ var Montage = require("../core").Montage, /** * Returns a new Date object that is an exact date and time copy of the original instance. - * @method - * @return {Date} A new Date instance + * @function + * @returns {Date} A new Date instance */ $P.clone = function () { return new Date(this.getTime()); @@ -187,9 +186,9 @@ var Montage = require("../core").Montage, /** * Compares this instance to a Date object and returns an number indication of their relative values. - * @method + * @function * @param {Date} Date Object to compare [Required]. - * @return {number} -1 = This is less-than date. 0 = values are equal. 1 = this is greater-than date. + * @returns {number} -1 = This is less-than date. 0 = values are equal. 1 = this is greater-than date. */ $P.compareTo = function (date) { return Date.compare(this, date); @@ -197,9 +196,9 @@ var Montage = require("../core").Montage, /** * Compares this instance to another Date object and returns true if they are equal. - * @method + * @function * @param {Date} Date Object to compare. If no date to compare, new Date() [now] is used. - * @return {boolean} true If dates are equal. False if they are not equal. + * @returns {boolean} true If dates are equal. False if they are not equal. */ $P.equals = function (date) { return Date.equals(this, date || new Date()); @@ -207,10 +206,10 @@ var Montage = require("../core").Montage, /** * Determines if this instance is between a range of two dates or equal to either the start or end dates. - * @method + * @function * @param {Date} start Of range [Required] * @param {Date} end Of range [Required] - * @return {boolean} true This is between or equal to the start and end dates, else false. + * @returns {boolean} true This is between or equal to the start and end dates, else false. */ $P.between = function (start, end) { return this.getTime() >= start.getTime() && this.getTime() <= end.getTime(); @@ -218,9 +217,9 @@ var Montage = require("../core").Montage, /** * Determines if this date occurs after the date to compare to. - * @method + * @function * @param {Date} Date object to compare. If no date to compare, new Date() ("now") is used. - * @return {boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. + * @returns {boolean} true if this date instance is greater than the date to compare to (or "now"), otherwise false. */ $P.isAfter = function (date) { return this.compareTo(date || new Date()) === 1; @@ -228,9 +227,9 @@ var Montage = require("../core").Montage, /** * Determines if this date occurs before the date to compare to. - * @method + * @function * @param {Date} date object to compare. If no date to compare, new Date() ("now") is used. - * @return {boolean} true if this date instance is less than the date to compare to (or "now"). + * @returns {boolean} true if this date instance is less than the date to compare to (or "now"). */ $P.isBefore = function (date) { return (this.compareTo(date || new Date()) === -1); @@ -238,16 +237,16 @@ var Montage = require("../core").Montage, /** * Determines if the current Date instance occurs today. - * @method - * @return {boolean} true if this date instance is 'today', otherwise false. + * @function + * @returns {boolean} true if this date instance is 'today', otherwise false. */ /** * Determines if the current Date instance occurs on the same Date as the supplied 'date'. * If no 'date' to compare to is provided, the current Date instance is compared to 'today'. - * @method + * @function * @param {Date} date object to compare. If no date to compare, the current Date ("now") is used. - * @return {boolean} true if this Date instance occurs on the same Day as the supplied 'date'. + * @returns {boolean} true if this Date instance occurs on the same Day as the supplied 'date'. */ $P.isToday = $P.isSameDay = function (date) { return this.clone().clearTime().equals((date || new Date()).clone().clearTime()); @@ -255,9 +254,9 @@ var Montage = require("../core").Montage, /** * Adds the specified number of milliseconds to this instance. - * @method + * @function * @param {number} value The number of milliseconds to add. The number can be positive or negative [Required] - * @return {Date} this + * @returns {Date} this */ $P.addMilliseconds = function (value) { this.setMilliseconds(this.getMilliseconds() + value * 1); @@ -266,9 +265,9 @@ var Montage = require("../core").Montage, /** * Adds the specified number of seconds to this instance. - * @method + * @function * @param {number} value The number of seconds to add. The number can be positive or negative [Required] - * @return {Date} this + * @returns {Date} this */ $P.addSeconds = function (value) { return this.addMilliseconds(value * 1000); @@ -276,9 +275,9 @@ var Montage = require("../core").Montage, /** * Adds the specified number of seconds to this instance. - * @method + * @function * @param {number} value The number of seconds to add. The number can be positive or negative [Required] - * @return {Date} this + * @returns {Date} this */ $P.addMinutes = function (value) { return this.addMilliseconds(value * 60000); @@ -287,9 +286,9 @@ var Montage = require("../core").Montage, /** * Adds the specified number of hours to this instance. - * @method + * @function * @param {number} value The number of hours to add. The number can be positive or negative [Required] - * @return {Date} this + * @returns {Date} this */ $P.addHours = function (value) { return this.addMilliseconds(value * 3600000); @@ -298,9 +297,9 @@ var Montage = require("../core").Montage, /** * Adds the specified number of days to this instance. - * @method + * @function * @param {number} value The number of days to add. The number can be positive or negative [Required] - * @return {Date} this + * @returns {Date} this */ $P.addDays = function (value) { this.setDate(this.getDate() + value * 1); @@ -309,9 +308,9 @@ var Montage = require("../core").Montage, /** * Adds the specified number of weeks to this instance. - * @method + * @function * @param {number} value The number of weeks to add. The number can be positive or negative [Required] - * @return {Date} this.addDays(value * 7) + * @returns {Date} this.addDays(value * 7) */ $P.addWeeks = function (value) { return this.addDays(value * 7); @@ -319,9 +318,9 @@ var Montage = require("../core").Montage, /** * Adds the specified number of months to this instance. - * @method + * @function * @param {number} value The number of months to add. The number can be positive or negative [Required] - * @return {Date} this + * @returns {Date} this */ $P.addMonths = function (value) { var n = this.getDate(); @@ -334,7 +333,7 @@ var Montage = require("../core").Montage, /** * Adds the specified number of years to this instance. * @param {number} value The number of years to add. The number can be positive or negative [Required] - * @return {Date} this + * @returns {Date} this */ $P.addYears = function (value) { return this.addMonths(value * 12); @@ -342,9 +341,9 @@ var Montage = require("../core").Montage, /** * Adds (or subtracts) to the value of the years, months, weeks, days, hours, minutes, seconds, milliseconds of the date instance using given configuration object. Positive and Negative values allowed. - * @method + * @function * @param {Object} config Configuration object containing attributes (months, days, etc.) - * @return {Date} this + * @returns {Date} this * @example * Date.today().add( { days: 1, months: 1 } ) * new Date().add( { years: -1 } ) @@ -391,8 +390,8 @@ var Montage = require("../core").Montage, * This algorithm is a JavaScript port of the work presented by Claus Tøndering at http://www.tondering.dk/claus/cal/node8.html#SECTION00880000000000000000 * .getWeek() Algorithm Copyright (c) 2008 Claus Tondering. * The .getWeek() function does NOT convert the date to UTC. The local datetime is used. Please use .getISOWeek() to get the week of the UTC converted date. - * @method - * @return {number} 1 to 53 + * @function + * @returns {number} 1 to 53 */ $P.getWeek = function () { var a, b, c, d, e, f, g, n, s, w; @@ -437,8 +436,8 @@ var Montage = require("../core").Montage, /** * Get the ISO 8601 week number. Week one ("01") is the week which contains the first Thursday of the year. Monday is considered the first day of the week. * The .getISOWeek() function does convert the date to it's UTC value. Please use .getWeek() to get the week of the local date. - * @method - * @return {string} "01" to "53" + * @function + * @returns {string} "01" to "53" */ $P.getISOWeek = function () { $y = this.getUTCFullYear(); @@ -449,9 +448,9 @@ var Montage = require("../core").Montage, /** * Moves the date to Monday of the week set. Week one (1) is the week which contains the first Thursday of the year. - * @method + * @function * @param {number} n A Number (1 to 53) that represents the week of the year. - * @return {Date} this + * @returns {Date} this */ $P.setWeek = function (n) { return this.moveToDayOfWeek(1).addWeeks(n - this.getWeek()); @@ -470,9 +469,9 @@ var Montage = require("../core").Montage, /** * Validates the number is within an acceptable range for milliseconds [0-999]. - * @method + * @function * @param {number} value The number to check if within range. - * @return {boolean} true if within range, otherwise false. + * @returns {boolean} true if within range, otherwise false. */ $D.validateMillisecond = function (value) { return validate(value, 0, 999, "millisecond"); @@ -480,9 +479,9 @@ var Montage = require("../core").Montage, /** Validates the number is within an acceptable range for seconds [0-59]. - @method + @function @param {number} value The number to check if within range. - @return {boolean} true if within range, otherwise false. + @returns {boolean} true if within range, otherwise false. */ $D.validateSecond = function (value) { return validate(value, 0, 59, "second"); @@ -492,7 +491,7 @@ var Montage = require("../core").Montage, * Validates the number is within an acceptable range for minutes [0-59]. * @function * @param {number} value The number to check if within range. - * @return {boolean} true if within range, otherwise false. + * @returns {boolean} true if within range, otherwise false. */ $D.validateMinute = function (value) { return validate(value, 0, 59, "minute"); @@ -502,7 +501,7 @@ var Montage = require("../core").Montage, * Validates the number is within an acceptable range for hours [0-23]. * @function * @param {number} value The number to check if within range. - * @return {boolean} true If within range, otherwise false. + * @returns {boolean} true If within range, otherwise false. */ $D.validateHour = function (value) { return validate(value, 0, 23, "hour"); @@ -514,7 +513,7 @@ var Montage = require("../core").Montage, * @param {number} value The number to check if within range. * @param {number} year The number to check if within range. * @param {number} month The number to check if within range. - * @return {boolean} true if within range, otherwise false. + * @returns {boolean} true if within range, otherwise false. */ $D.validateDay = function (value, year, month) { return validate(value, 1, $D.getDaysInMonth(year, month), "day"); @@ -524,7 +523,7 @@ var Montage = require("../core").Montage, * Validates the number is within an acceptable range for months [0-11]. * @function * @param {number} value The number to check if within range. - * @return {boolean} true if within range, otherwise false. + * @returns {boolean} true if within range, otherwise false. */ $D.validateMonth = function (value) { return validate(value, 0, 11, "month"); @@ -534,7 +533,7 @@ var Montage = require("../core").Montage, * Validates the number is within an acceptable range for years. * @function * @param {number} value The number to check if within range. - * @return {boolean} true if within range, otherwise false. + * @returns {boolean} true if within range, otherwise false. */ $D.validateYear = function (value) { return validate(value, 0, 9999, "year"); @@ -544,7 +543,7 @@ var Montage = require("../core").Montage, * Set the value of year, month, day, hour, minute, second, millisecond of date instance using given configuration object. * @function * @param {Object} config Configuration object containing attributes (month, day, etc.) - * @return {Date} this + * @returns {Date} this * @example * Date.today().set( { day: 20, month: 1 } ) * new Date().set( { millisecond: 0 } ) @@ -596,8 +595,8 @@ var Montage = require("../core").Montage, /** * Moves the date to the first day of the month. - * @method - * @return {Date} this + * @function + * @returns {Date} this */ $P.moveToFirstDayOfMonth = function () { return this.set({ day: 1 }); @@ -605,8 +604,8 @@ var Montage = require("../core").Montage, /** * Moves the date to the last day of the month. - * @method - * @return {Date} this + * @function + * @returns {Date} this */ $P.moveToLastDayOfMonth = function () { return this.set({ day: $D.getDaysInMonth(this.getFullYear(), this.getMonth())}); @@ -614,10 +613,10 @@ var Montage = require("../core").Montage, /** * Moves the date to the next n'th occurrence of the dayOfWeek starting from the beginning of the month. The number (-1) is a magic number and will return the last occurrence of the dayOfWeek in the month. - * @method + * @function * @param {number} dayOfWeek The dayOfWeek to move to. * @param {number} occurrence The n'th occurrence to move to. Use (-1) to return the last occurrence in the month. - * @return {Date} this + * @returns {Date} this */ $P.moveToNthOccurrence = function (dayOfWeek, occurrence) { var shift = 0; @@ -636,10 +635,10 @@ var Montage = require("../core").Montage, /** * Move to the next or last dayOfWeek based on the orient value. - * @method + * @function * @param {number} dayOfWeek The dayOfWeek to move to * @param {number} orient Forward (+1) or Back (-1). Defaults to +1. [Optional] - * @return {Date} this + * @returns {Date} this */ $P.moveToDayOfWeek = function (dayOfWeek, orient) { var diff = (dayOfWeek - this.getDay() + 7 * (orient || +1)) % 7; @@ -648,10 +647,10 @@ var Montage = require("../core").Montage, /** * Move to the next or last month based on the orient value. - * @method + * @function * @param {number} month The month to move to. 0 = January, 11 = December * @param {number} orient Forward (+1) or Back (-1). Defaults to +1. [Optional] - * @return {Date} this + * @returns {Date} this */ $P.moveToMonth = function (month, orient) { var diff = (month - this.getMonth() + 12 * (orient || +1)) % 12; @@ -660,8 +659,8 @@ var Montage = require("../core").Montage, /** * Get the Ordinal day (numeric day number) of the year, adjusted for leap year. - * @method - * @return {number} 1 through 365 (366 in leap years) + * @function + * @returns {number} 1 through 365 (366 in leap years) */ $P.getOrdinalNumber = function () { return Math.ceil((this.clone().clearTime() - new Date(this.getFullYear(), 0, 1)) / 86400000) + 1; @@ -669,25 +668,25 @@ var Montage = require("../core").Montage, /** * Get the time zone abbreviation of the current date. - * @method - * @return {string} The abbreviated time zone name (e.g. "EST") + * @function + * @returns {string} The abbreviated time zone name (e.g. "EST") */ $P.getTimezone = function () { return $D.getTimezoneAbbreviation(this.getUTCOffset()); }; /** - * @method + * @function * @param {number} offset - * @return {number} this.addMinutes(there - here) + * @returns {number} this.addMinutes(there - here) */ $P.setTimezoneOffset = function (offset) { var here = this.getTimezoneOffset(), there = Number(offset) * -6 / 10; return this.addMinutes(there - here); }; /** - * @method + * @function * @param {number} offset - * @return {number} this.setTimezoneOffset($D.getTimezoneOffset(offset)) + * @returns {number} this.setTimezoneOffset($D.getTimezoneOffset(offset)) */ $P.setTimezone = function (offset) { return this.setTimezoneOffset($D.getTimezoneOffset(offset)); @@ -695,8 +694,8 @@ var Montage = require("../core").Montage, /** * Indicates whether Daylight Saving Time is observed in the current time zone. - * @method - * @return {boolean} true|false + * @function + * @returns {boolean} true|false */ $P.hasDaylightSavingTime = function () { return (Date.today().set({month: 0, day: 1}).getTimezoneOffset() !== Date.today().set({month: 6, day: 1}).getTimezoneOffset()); @@ -704,8 +703,8 @@ var Montage = require("../core").Montage, /** * Indicates whether this Date instance is within the Daylight Saving Time range for the current time zone. - * @method - * @return {boolean} true|false + * @function + * @returns {boolean} true|false */ $P.isDaylightSavingTime = function () { return Date.today().set({month: 0, day: 1}).getTimezoneOffset() != this.getTimezoneOffset(); @@ -713,8 +712,8 @@ var Montage = require("../core").Montage, /** * Get the offset from UTC of the current date. - * @method - * @return {string} The 4-character offset string prefixed with + or - (e.g. "-0500"). + * @function + * @returns {string} The 4-character offset string prefixed with + or - (e.g. "-0500"). */ $P.getUTCOffset = function () { var n = this.getTimezoneOffset() * -10 / 6, r; @@ -729,9 +728,9 @@ var Montage = require("../core").Montage, /** * Returns the number of milliseconds between this date and date. - * @method + * @function * @param {Date} date Defaults to now - * @return {number} The diff in milliseconds + * @returns {number} The diff in milliseconds */ $P.getElapsed = function (date) { return (date || new Date()) - this; @@ -740,8 +739,8 @@ var Montage = require("../core").Montage, if (!$P.toISOString) { /** Converts the current date instance into a string with an ISO 8601 format. The date is converted to it's UTC value. - @method - @return {string} ISO 8601 string of date + @function + @returns {string} ISO 8601 string of date */ $P.toISOString = function () { // From http://www.json.org/json.js. Public Domain. @@ -830,9 +829,9 @@ var Montage = require("../core").Montage, */ /** - * @method + * @function * @param {string} format A format string consisting of one or more format spcifiers [Optional]. - * @return {string} A string representation of the current Date object. + * @returns {string} A string representation of the current Date object. */ $P.toString = function (format) { var x = this; @@ -943,16 +942,6 @@ var Montage = require("../core").Montage, // Date formatting - - /** - * @version: 1.0 Alpha-1 - * @author: Coolite Inc. http://www.coolite.com/ - * @date: 2008-04-13 - * @copyright: Copyright (c) 2006-2008, Coolite Inc. (http://www.coolite.com/). All rights reserved. - * @license: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/. - * @website: http://www.datejs.com/ - */ - Date.CultureInfo = { /* Culture Name */ name: "en-US", @@ -1171,9 +1160,9 @@ var Montage = require("../core").Montage, /** * Converts the value of the current Date object to its equivalent string representation. * Format Specifiers - * @method + * @function * @param {string} format A format string consisting of one or more format spcifiers [Optional]. - * @return {string} A string representation of the current Date object. + * @returns {string} A string representation of the current Date object. * @example * CUSTOM DATE AND TIME FORMAT STRINGS * Format Description Example @@ -2311,7 +2300,7 @@ var Montage = require("../core").Montage, * Converts the specified string value into its JavaScript Date equivalent using CultureInfo specific format information. * @function * @param {string} s The string value to convert into a Date object [Required] - * @return {Date} A Date object or null if the string cannot be converted into a Date. + * @returns {Date} A Date object or null if the string cannot be converted into a Date. * @example * /////////// * // Dates // @@ -2438,7 +2427,7 @@ var Montage = require("../core").Montage, * @function * @param {string} s The string value to convert into a Date object [Required]. * @param {Object} fx The expected format {string} or an array of expected formats {Array} of the date string [Required]. - * @return {Date} A Date object or null if the string cannot be converted into a Date. + * @returns {Date} A Date object or null if the string cannot be converted into a Date. * @example * // 15-Oct-2004 * var d1 = Date.parseExact("10/15/2004", "M/d/yyyy"); @@ -2468,11 +2457,11 @@ var _toString = Object.prototype.toString; // TODO much like Array.isArray these should probably be moved into a shim i.e. Foo.isFoo(obj) -var isDate = function(object) { +var isDate = function (object) { return _toString.call(object) === DATE_CLASS; }; -var formatDate = function(v, format) { +var formatDate = function (v, format) { var date; if (typeof v === "string") { // try to create a Date instance from the string @@ -2493,16 +2482,16 @@ var formatDate = function(v, format) { /** - * Date Validator: * @class DateValidator - * @classdesc Validate that date provided as string/number can be converted to a Date Object using the pattern provided. + * @classdesc + * Validate that date provided as string/number can be converted to a Date Object using the pattern provided. + * * @extends Validator */ -var DateValidator = exports.DateValidator = Validator.specialize(/** @lends DateValidator# */ { - +var DateValidator = exports.DateValidator = Validator.specialize(/** @lends DateValidator.prototype # */ { /** - * @type {Property} - * @default {Date} 'MM/dd/yyyy' + * @property {String} value + * @default {String} 'MM/dd/yyyy' */ pattern: { value: 'MM/dd/yyyy' @@ -2510,11 +2499,11 @@ var DateValidator = exports.DateValidator = Validator.specialize(/** @lends Date /** * @function - * @param {Date} v Value. - * //@returns {message: 'Unable to parse date - ' + v + ' in the format - ' + this.pattern} | new Date(result) + * @param {Date} v - value + * @returns {Object|Date} */ validate: { - value: function(v) { + value: function (v) { // @todo - implement a Date validator that will accept all the date formats // that we support for Formatting // for now, just accept what is possible by default @@ -2532,44 +2521,44 @@ var DateValidator = exports.DateValidator = Validator.specialize(/** @lends Date }); -// Date Converter /** * @class DateConverter + * @extends Converter */ -var DateConverter = exports.DateConverter = Converter.specialize(/** @lends DateConverter# */ { +var DateConverter = exports.DateConverter = Converter.specialize(/** @lends DateConverter.prototype # */ { /** - Specifies whether the converter allows partial conversion. - @type {Property} - @default {boolean} true + * Specifies whether the converter allows partial conversion. + * + * @property {boolean} value + * @default {boolean} false */ allowPartialConversion: { value: false }, /** - * @type {Property} - * @default {Function} new DateValidator() + * @property {Function} value + * @default {Function} DateValidator */ validator: { value: new DateValidator() }, - // valid fn values are: /** - * @type {Property} - * @default {Date} 'MM/dd/yyyy' + * @property {String} value + * @default {String} 'MM/dd/yyyy' */ pattern: { value: 'MM/dd/yyyy' }, /** - * @method + * @function * @param {Date} v Value. * @returns v */ convert: { - value: function(v) { + value: function (v) { var t = typeof v; if (isDate(v) || t === "string" || t === "number") { return formatDate(v, this.pattern); @@ -2578,11 +2567,11 @@ var DateConverter = exports.DateConverter = Converter.specialize(/** @lends Date } }, /** - * @method + * @function * @param {Date} v Value. */ revert: { - value: function(v) { + value: function (v) { if(isDate(v)) { return v; } diff --git a/core/converter/invert-converter.js b/core/converter/invert-converter.js index 35eb682038..2afd204028 100644 --- a/core/converter/invert-converter.js +++ b/core/converter/invert-converter.js @@ -14,13 +14,13 @@ var Converter = require("./converter").Converter; */ var InvertConverter = exports.InvertConverter = Converter.specialize( { convert: { - value: function(v) { + value: function (v) { return !v; } }, revert: { - value: function(v) { + value: function (v) { return !v; } } diff --git a/core/converter/lower-case-converter.js b/core/converter/lower-case-converter.js index 2da071426b..25d752b00f 100644 --- a/core/converter/lower-case-converter.js +++ b/core/converter/lower-case-converter.js @@ -13,7 +13,7 @@ var Converter = require("./converter").Converter; exports.LowerCaseConverter = Converter.specialize( /** @lends LowerCaseConverter# */{ _convert: { - value: function(v) { + value: function (v) { if (v && typeof v === 'string') { return (v.toLowerCase ? v.toLowerCase() : v); } @@ -22,20 +22,20 @@ exports.LowerCaseConverter = Converter.specialize( /** @lends LowerCaseConverter }, /** - * @method + * @function * @param {string} v Case format * @returns this._convert(v) */ - convert: {value: function(v) { + convert: {value: function (v) { return this._convert(v); }}, /** - * @method + * @function * @param {string} v Case format * @returns this._convert(v) */ - revert: {value: function(v) { + revert: {value: function (v) { return this._convert(v); }} diff --git a/core/converter/new-line-to-br-converter.js b/core/converter/new-line-to-br-converter.js index e2ce97732c..0f0605b182 100644 --- a/core/converter/new-line-to-br-converter.js +++ b/core/converter/new-line-to-br-converter.js @@ -14,7 +14,7 @@ var Converter = require("./converter").Converter; * @param {string} str The string to format. * @returns {string} The formatted string. */ -var newLineToBr = function(str) { +var newLineToBr = function (str) { return str.replace(/(\r\n|\r|\n)/g, '
'); }; @@ -25,7 +25,7 @@ var newLineToBr = function(str) { exports.NewLineToBrConverter = Converter.specialize( /** @lends NewLineToBrConverter# */{ _convert: { - value: function(v) { + value: function (v) { if (v && typeof v === 'string') { return newLineToBr(v); } @@ -34,20 +34,20 @@ exports.NewLineToBrConverter = Converter.specialize( /** @lends NewLineToBrConve }, /** - * @method + * @function * @param {string} v Case format * @returns this._convert(v) */ - convert: {value: function(v) { + convert: {value: function (v) { return this._convert(v); }}, /** - * @method + * @function * @param {string} v Case format * @returns this._convert(v) */ - revert: {value: function(v) { + revert: {value: function (v) { return this._convert(v); }} diff --git a/core/converter/number-converter.js b/core/converter/number-converter.js index fd46c53547..11ef947926 100644 --- a/core/converter/number-converter.js +++ b/core/converter/number-converter.js @@ -112,10 +112,10 @@ var NUMERIC_SCALES_BINARY_ = exports.NUMERIC_SCALES_BINARY_ = { * @param {Object} conversion Dictionary of scaling factors. * @param {number} opt_decimals The number of decimals to use. Default is 2. * @param {string} opt_suffix Optional suffix to append. - * @return {string} The human readable form of the byte size. + * @returns {string} The human readable form of the byte size. * @private */ -var _numericValueToString = exports._numericValueToString = function(val, conversion, opt_decimals, opt_suffix, prefixes) { +var _numericValueToString = exports._numericValueToString = function (val, conversion, opt_decimals, opt_suffix, prefixes) { prefixes = prefixes || NUMERIC_SCALE_PREFIXES_; var orig_val = val; var symbol = ''; @@ -147,10 +147,10 @@ var _numericValueToString = exports._numericValueToString = function(val, conver * @memberof module:montage/converter# * @param {string} stringValue String to be converted to numeric value. * @param {Object} conversion Dictionary of conversion scales. - * @return {number} Numeric value for string. If it cannot be converted, returns NaN. + * @returns {number} Numeric value for string. If it cannot be converted, returns NaN. * @private */ -var _stringToNumericValue = function(stringValue, conversion) { +var _stringToNumericValue = function (stringValue, conversion) { var match = stringValue.match(SCALED_NUMERIC_RE_); if (!match) { return NaN; @@ -169,9 +169,9 @@ var _stringToNumericValue = function(stringValue, conversion) { * @memberof module:montage/core/converter# * @function * @param {string} val String value to check. - * @return {boolean} true If the string could be converted to a numeric value. + * @returns {boolean} true If the string could be converted to a numeric value. */ -var isConvertableScaledNumber = function(val) { +var isConvertableScaledNumber = function (val) { return SCALED_NUMERIC_RE_.test(val); }; @@ -182,9 +182,9 @@ var isConvertableScaledNumber = function(val) { * @memberof module:montage/core/converter# * @function * @param {string} stringValue String to be converted to numeric value. - * @return {number} Numeric value for string. + * @returns {number} Numeric value for string. */ -var stringToNumericValue = exports.stringToNumericValue = function(stringValue) { +var stringToNumericValue = exports.stringToNumericValue = function (stringValue) { if (stringValue.endsWith('B')) { return _stringToNumericValue( stringValue, NUMERIC_SCALES_BINARY_); @@ -203,7 +203,7 @@ var stringToNumericValue = exports.stringToNumericValue = function(stringValue) * @param {number} opt_decimals The number of decimals to use. Defaults to 2. * @returns {string} String representation of number. */ -var numericValueToString = exports.numericValueToString = function(val, opt_decimals) { +var numericValueToString = exports.numericValueToString = function (val, opt_decimals) { return _numericValueToString(val, NUMERIC_SCALES_SI_, opt_decimals); }; @@ -238,14 +238,14 @@ var NumberValidator = exports.NumberValidator = Validator.specialize( /** @lends /** * Determines if the parameter `v` is a number or not. - * @method + * @function * @param {string} v The value to validate as a number. * @returns {number} num An integer or float, if the value provided to the * function can parsed as a number; * otherwise returns an error. */ validate: { - value: function(v) { + value: function (v) { var num; v = v || ''; v = v.replace(/,/g, ''); @@ -345,7 +345,7 @@ var NumberConverter = exports.NumberConverter = Converter.specialize( /** @lends // credit: sugar.js - https://github.com/andrewplummer/Sugar _makeReadable: { - value: function(num, comma, period) { + value: function (num, comma, period) { comma = comma || ','; period = period || '.'; var split = num.toString().split('.'); @@ -368,12 +368,12 @@ var NumberConverter = exports.NumberConverter = Converter.specialize( /** @lends }, /** - * @method + * @function * @param {number} value The value to convert. * @returns {string} */ convert: { - value: function(v) { + value: function (v) { if (this.shorten) { // shorten the number to 10K, 100K, 1M etc return numericValueToString(v, this.decimals); @@ -393,7 +393,7 @@ var NumberConverter = exports.NumberConverter = Converter.specialize( /** @lends }, /** - * @method + * @function * @param {string} stringValue The string representation of a number. * @returns {number} The numeric value validated with to {@link * NumberConverter#validator}. @@ -404,7 +404,7 @@ var NumberConverter = exports.NumberConverter = Converter.specialize( /** @lends * @see NumberConverter#allowNegative */ revert: { - value: function(stringValue) { + value: function (stringValue) { // use a Validator to validate first this.validator.allowFloat = this.allowFloat; this.validator.allowNegative = this.allowNegative; diff --git a/core/converter/trim-converter.js b/core/converter/trim-converter.js index 3ce9b47b2a..ce75444474 100644 --- a/core/converter/trim-converter.js +++ b/core/converter/trim-converter.js @@ -14,7 +14,7 @@ var Converter = require("./converter").Converter; * @param {string} str String to be trimmed. * @returns {string} The trimmed string. */ -var trim = exports.trim = function(str) { +var trim = exports.trim = function (str) { // from Google Closure library // Since IE doesn't include non-breaking-space (0xa0) in their \s character // class (as required by section 7.2 of the ECMAScript spec), we explicitly @@ -37,7 +37,7 @@ var trim = exports.trim = function(str) { exports.TrimConverter = Converter.specialize( /** @lends TrimConverter# */ { _convert: { - value: function(v) { + value: function (v) { if (v && typeof v === 'string') { return trim(v); } @@ -46,21 +46,21 @@ exports.TrimConverter = Converter.specialize( /** @lends TrimConverter# */ { /** * Trims the provided string and returns the new string. - * @method + * @function * @param {string} v The string to trim. * @returns this._convert(v) */ - convert: {value: function(v) { + convert: {value: function (v) { return this._convert(v); }}, /** * Reverts the conversion. - * @method + * @function * @param {string} v The string to revert. * @returns this._convert(v) */ - revert: {value: function(v) { + revert: {value: function (v) { return this._convert(v); }} diff --git a/core/converter/upper-case-converter.js b/core/converter/upper-case-converter.js index 4734fc4578..b98f22b01a 100644 --- a/core/converter/upper-case-converter.js +++ b/core/converter/upper-case-converter.js @@ -13,7 +13,7 @@ var Converter = require("./converter").Converter; exports.UpperCaseConverter = Converter.specialize( /** @lends UpperCaseConverter# */ { _convert: { - value: function(v) { + value: function (v) { if (v && typeof v === 'string') { return (v.toUpperCase ? v.toUpperCase() : v); } @@ -23,21 +23,21 @@ exports.UpperCaseConverter = Converter.specialize( /** @lends UpperCaseConverter /** * Converts the specified string to all upper case letters. - * @method + * @function * @param {string} v The string to convert. * @returns {string} The converted string. */ - convert: {value: function(v) { + convert: {value: function (v) { return this._convert(v); }}, /** * Reverts the specified string. - * @method + * @function * @param {string} v The specified string. * @returns {string} */ - revert: {value: function(v) { + revert: {value: function (v) { return this._convert(v); }} diff --git a/core/core.js b/core/core.js index d34d7d6f13..fffcc3b910 100644 --- a/core/core.js +++ b/core/core.js @@ -1,3 +1,6 @@ +/** + * @module montage/core/core + */ require("collections/shim"); require("./shim/object"); @@ -42,6 +45,7 @@ var CONSTRUCTOR_COMPATIBILITY = true; * The Montage constructor provides conveniences for sub-typing * ([specialize]{@link Montage.specialize}) and common methods for Montage * prototype chains. + * * @class Montage * @classdesc The basis of all types using the MontageJS framework. */ @@ -63,14 +67,14 @@ var FUNCTION_PROPERTIES = Object.getOwnPropertyNames(Function); * for common usage in MontageJS. * * See {@link Montage.defineProperty} - * @method Montage.specialize + * @function Montage.specialize * @param {Object} prototypeProperties a object mapping property names to * customized Montage property descriptors, to be applied to the new * prototype * @param {?Object} constructorProperties a object mapping property names to * customized Montage property descriptors, to be applied to the new * constructor - * @return {function} a constructor function for the new type, which + * @returns {function} a constructor function for the new type, which * derrives prototypically from `this`, with a prototype that inherits * `this.prototype`, with the given property descriptors applied. */ @@ -110,7 +114,7 @@ Object.defineProperty(Montage, "specialize", { } constructor.__constructorProto__ = parent; Montage.defineProperty(constructor, "isPrototypeOf", { - value: function(object) { + value: function (object) { while (object !== null) { if(Object.getPrototypeOf(object) === this) { return true; @@ -150,7 +154,7 @@ Object.defineProperty(Montage, "specialize", { if (CONSTRUCTOR_COMPATIBILITY) { // to catch class properties - constructorProperty = function(original, constructor, propertyName) { + constructorProperty = function (original, constructor, propertyName) { function deprecationWrapper() { if(this === constructor) { deprecate.deprecationWarning(Montage.getInfoForObject(constructor).objectName + "." @@ -181,7 +185,7 @@ Object.defineProperty(Montage, "specialize", { } Montage.defineProperties(constructor, prototypeProperties); Montage.defineProperty(constructor, "create", { - value: function() { + value: function () { return new constructor(); }, enumerable: false @@ -226,7 +230,7 @@ if (!PROTO_IS_SUPPORTED) { // DEPRECATED Object.defineProperty(Montage, "create", { configurable: true, - value: function(aPrototype, propertyDescriptors) { + value: function (aPrototype, propertyDescriptors) { if (aPrototype !== undefined && (typeof aPrototype !== "object" && /* CONSTRUCTOR_COMPATIBILITY*/typeof aPrototype !== "function")) { throw new TypeError("Object prototype may only be an Object or null, not '" + aPrototype + "'"); @@ -257,7 +261,7 @@ var extendedPropertyAttributes = [SERIALIZABLE]; /** * @member external:Object#extendedPropertyAttributes */ -extendedPropertyAttributes.forEach(function(name) { +extendedPropertyAttributes.forEach(function (name) { Object.defineProperty(Object.prototype, UNDERSCORE + name + ATTRIBUTE_PROPERTIES, { enumerable: false, configurable: false, @@ -283,7 +287,7 @@ extendedPropertyAttributes.forEach(function(name) { * ill-defined and temperamental. * * @function Montage.defineProperty - * @method Montage.defineProperty + * @function Montage.defineProperty * @param {Object} object The object on which to define the property. * @param {string} name The name of the property to define, or modify. * @param {Object} descriptor A descriptor object that defines the properties @@ -298,7 +302,7 @@ extendedPropertyAttributes.forEach(function(name) { */ Object.defineProperty(Montage, "defineProperty", { - value: function(obj, prop, descriptor) { + value: function (obj, prop, descriptor) { if (! (typeof obj === "object" || typeof obj === "function") || obj === null) { throw new TypeError("Object must be an object, not '" + obj + "'"); } @@ -353,8 +357,8 @@ Object.defineProperty(Montage, "defineProperty", { // TODO replace this with Object.clone from collections - @kriskowal //this is added to enable value properties with [] or Objects that are new for every instance if (descriptor.distinct === true && typeof descriptor.value === "object") { - (function(prop,internalProperty, value, obj) { - var defineInternalProperty = function(obj, internalProperty, value) { + (function (prop,internalProperty, value, obj) { + var defineInternalProperty = function (obj, internalProperty, value) { Object.defineProperty(obj, internalProperty, { enumerable: false, configurable: true, @@ -367,7 +371,7 @@ Object.defineProperty(Montage, "defineProperty", { if (Object.keys(value).length !== 0) { Object.defineProperty(obj, prop, { configurable: true, - get: function() { + get: function () { //Special case for object to copy the values var returnValue = this[internalProperty]; if (!returnValue) { @@ -384,7 +388,7 @@ Object.defineProperty(Montage, "defineProperty", { } return returnValue; }, - set: function(value) { + set: function (value) { if(!this.hasOwnProperty(internalProperty)) { defineInternalProperty(this, internalProperty, value); } else { @@ -395,7 +399,7 @@ Object.defineProperty(Montage, "defineProperty", { } else { Object.defineProperty(obj, prop, { configurable: true, - get: function() { + get: function () { var returnValue = this[internalProperty]; if (!returnValue) { returnValue = {}; @@ -407,7 +411,7 @@ Object.defineProperty(Montage, "defineProperty", { } return returnValue; }, - set: function(value) { + set: function (value) { if(!this.hasOwnProperty(internalProperty)) { defineInternalProperty(this, internalProperty, value); } else { @@ -422,7 +426,7 @@ Object.defineProperty(Montage, "defineProperty", { if (value.length !== 0) { Object.defineProperty(obj, prop, { configurable: true, - get: function() { + get: function () { //Special case for object to copy the values var returnValue = this[internalProperty]; if (!returnValue) { @@ -439,7 +443,7 @@ Object.defineProperty(Montage, "defineProperty", { } return returnValue; }, - set: function(value) { + set: function (value) { if(!this.hasOwnProperty(internalProperty)) { defineInternalProperty(this, internalProperty, value); } else { @@ -451,7 +455,7 @@ Object.defineProperty(Montage, "defineProperty", { } else { Object.defineProperty(obj, prop, { configurable: true, - get: function() { + get: function () { var returnValue = this[internalProperty]; if (!returnValue) { returnValue = []; @@ -463,7 +467,7 @@ Object.defineProperty(Montage, "defineProperty", { } return returnValue; }, - set: function(value) { + set: function (value) { if(!this.hasOwnProperty(internalProperty)) { defineInternalProperty(this, internalProperty, value); } else { @@ -476,7 +480,7 @@ Object.defineProperty(Montage, "defineProperty", { } else if (value.constructor.prototype === Object.getPrototypeOf(value)) { Object.defineProperty(obj, prop, { configurable: true, - get: function() { + get: function () { //Special case for object to copy the values var returnValue = this[internalProperty]; if (!returnValue) { @@ -493,7 +497,7 @@ Object.defineProperty(Montage, "defineProperty", { } return returnValue; }, - set: function(value) { + set: function (value) { if(!this.hasOwnProperty(internalProperty)) { defineInternalProperty(this, internalProperty, value); } else { @@ -506,7 +510,7 @@ Object.defineProperty(Montage, "defineProperty", { } else { Object.defineProperty(obj, prop, { configurable: true, - get: function() { + get: function () { var returnValue = this[internalProperty]; if (!returnValue) { returnValue = Object.create(value.__proto__ || Object.getPrototypeOf(value)); @@ -518,7 +522,7 @@ Object.defineProperty(Montage, "defineProperty", { } return returnValue; }, - set: function(value) { + set: function (value) { if(!this.hasOwnProperty(internalProperty)) { defineInternalProperty(this, internalProperty, value); } else { @@ -564,7 +568,7 @@ Object.defineProperty(Montage, "defineProperty", { * @param {Object} properties An object that maps names to Montage property * descriptors. */ -Object.defineProperty(Montage, "defineProperties", {value: function(obj, properties) { +Object.defineProperty(Montage, "defineProperties", {value: function (obj, properties) { if (typeof properties !== "object" || properties === null) { throw new TypeError("Properties must be an object, not '" + properties + "'"); } @@ -613,7 +617,7 @@ Montage.defineProperty(Montage, "didCreate", { value: Function.noop }); -var getSuper = function(object, method) { +var getSuper = function (object, method) { var propertyNames, proto, i, propCount, propertyName, func, context, foundSuper, property; if (!(method._superPropertyName && method._superPropertyType)) { Montage.defineProperty(method, "_superPropertyType", {value:null}); @@ -701,8 +705,8 @@ var superForImplementation = function (object, propertyType, propertyName) { // is the super for this method in the cache? if (cacheObject._superCache && cacheObject._superCache[cacheId]) { - boundSuper = (function(cacheId, object, superObject, superFunction) { - return function() { + boundSuper = (function (cacheId, object, superObject, superFunction) { + return function () { object._superContext[cacheId] = superObject; var retVal = superFunction.apply(object, arguments); delete object._superContext[cacheId]; @@ -741,8 +745,8 @@ var superForImplementation = function (object, propertyType, propertyName) { // and immediately clears it again after the super has been called. This is needed // in case superFunction also calls superFor*() so superForImplementation() knows // which object owns the calling method. - boundSuper = (function(cacheId, object, superObject, superFunction) { - return function() { + boundSuper = (function (cacheId, object, superObject, superFunction) { + return function () { object._superContext[cacheId] = superObject; var retVal = superFunction.apply(object, arguments); delete object._superContext[cacheId]; @@ -781,8 +785,8 @@ var superForSetImplementation = function (propertyName) { * Calls the method with the same name as the caller from the parent of the * constructor that contains the caller, falling back to a no-op if no such * method exists. - * @method Montage.super - * @return {function} this constructor’s parent constructor. + * @function Montage.super + * @returns {function} this constructor’s parent constructor. */ Montage.defineProperty(Montage, "super", { get: superImplementation, @@ -846,7 +850,7 @@ Montage.defineProperty(Montage.prototype, "superForSet", { * @returns {Array} An array containing the names of the serializable * properties belonging to `anObject`. */ -Montage.defineProperty(Montage, "getSerializablePropertyNames", {value: function(anObject) { +Montage.defineProperty(Montage, "getSerializablePropertyNames", {value: function (anObject) { var propertyNames = [], attributes = anObject._serializableAttributeProperties; @@ -871,7 +875,7 @@ Montage.defineProperty(Montage, "getSerializablePropertyNames", {value: function @param {string} attributeName The name of a property's attribute. @returns attributes array */ -Montage.defineProperty(Montage, "getPropertyAttribute", {value: function(anObject, propertyName, attributeName) { +Montage.defineProperty(Montage, "getPropertyAttribute", {value: function (anObject, propertyName, attributeName) { var attributePropertyName = UNDERSCORE + attributeName + ATTRIBUTE_PROPERTIES, attributes = anObject[attributePropertyName]; @@ -923,7 +927,7 @@ var _functionInstanceMetadataDescriptor = { * constructors and prototypes from instances. */ Montage.defineProperty(Montage, "getInfoForObject", { - value: function(object) { + value: function (object) { var metadata; var instanceMetadataDescriptor; @@ -979,7 +983,7 @@ if (typeof window !== "undefined") { var hasOwnProperty = Object.prototype.hasOwnProperty; -var uuidGetGenerator = function() { +var uuidGetGenerator = function () { var uuid = UUID.generate(), info = Montage.getInfoForObject(this); @@ -987,7 +991,7 @@ var uuidGetGenerator = function() { if (info !== null && info.isInstance === false) { this._uuid = uuid; Object.defineProperty(this, "uuid", { - get: function() { + get: function () { if (this.hasOwnProperty("uuid")) { // we are calling uuid on the prototype return this._uuid; @@ -1055,7 +1059,7 @@ Object.defineProperty(Object.prototype, "_uuid", { Object.defineProperty(Object.prototype, "uuid", { configurable: true, get: defaultUuidGet, - set: function() { + set: function () { } }); @@ -1070,14 +1074,14 @@ Montage.defineProperty(Montage.prototype, "identifier", { /** * Returns true if two objects are equal, otherwise returns false. - * @method Montage#equals + * @function Montage#equals * @param {Object} anObject The object to compare for equality. * @returns {boolean} Returns `true` if the calling object and * `anObject` are identical and their `uuid` properties * are also equal. Otherwise, returns `false`. */ Montage.defineProperty(Montage.prototype, "equals", { - value: function(anObject) { + value: function (anObject) { if (!anObject) return false; return this === anObject || this.uuid === anObject.uuid; } @@ -1091,11 +1095,11 @@ Montage.defineProperty(Montage, "equals", { * This method calls the method named with the identifier prefix if it exists. * Example: If the name parameter is "shouldDoSomething" and the caller's identifier is "bob", then * this method will try and call "bobShouldDoSomething" - * @method Montage#callDelegateMethod + * @function Montage#callDelegateMethod * @param {string} name */ Montage.defineProperty(Montage.prototype, "callDelegateMethod", { - value: function(name) { + value: function (name) { var delegate = this.delegate, delegateFunctionName, delegateFunction; if (typeof this.identifier === "string") { delegateFunctionName = this.identifier + name.toCapitalized(); @@ -1131,7 +1135,7 @@ Object.addEach(Montage.prototype, PropertyChanges.prototype); * `handle` + PropertyName + `WillChange` then `handlePropertyWillChange`. The * arguments to the handler are `value`, `name`, and this. * - * @method Montage#addOwnPropertyChangeListener + * @function Montage#addOwnPropertyChangeListener * @param {string} name The name of the property to observe. * @param {object|function} handler On which to dispatch change notifications. * @param {boolean} beforeChange Whether to observer changes before they occur. @@ -1146,7 +1150,7 @@ Object.addEach(Montage.prototype, PropertyChanges.prototype); * Cancels a change listener established with the same given parameters. For * the meanings of the parameters, see `addOwnPropertyChangeListener`. * @see Montage#addOwnPropertyChangeListener - * @method Montage#removeOwnPropertyChangeListener + * @function Montage#removeOwnPropertyChangeListener * @param {string} name * @param {object|function} handler * @param {boolean} beforeChange @@ -1156,7 +1160,7 @@ Object.addEach(Montage.prototype, PropertyChanges.prototype); * Adds a listener that will be notified *before* a property changes. See * `addOwnPropertyChangeListener` for details. * @see Montage#addOwnPropertyChangeListener - * @method Montage#addBeforeOwnPropertyChangeListener + * @function Montage#addBeforeOwnPropertyChangeListener * @param {string} name * @param {object|function} handler * @returns {function} cancel @@ -1168,7 +1172,7 @@ Object.addEach(Montage.prototype, PropertyChanges.prototype); * Call with the same arguments used to set up the observer. * @see Montage#addOwnPropertyChangeListener * @see Montage#addBeforeOwnPropertyChangeListener - * @method Montage#removeBeforeOwnPropertyChangeListener + * @function Montage#removeBeforeOwnPropertyChangeListener * @param {string} name * @param {object|function} handler */ @@ -1181,7 +1185,7 @@ Object.addEach(Montage.prototype, PropertyChanges.prototype); * `addBeforeOwnPropertyChangeListener`. * @see Montage#addOwnPropertyChangeListener * @see Montage#addBeforeOwnPropertyChangeListener - * @method Montage#getOwnPropertyChangeDescriptor + * @function Montage#getOwnPropertyChangeDescriptor * @param {string} name * @returns the property change descriptor for this name, created if necessary. */ @@ -1194,7 +1198,7 @@ Object.addEach(Montage.prototype, PropertyChanges.prototype); * it modifies its own value, but if changing `celicius` has a side effect on * `fahrenheit`, they can manually dispatch changes to the other. Be sure * to dispatch both the change and before the change. - * @method Montage#dispatchOwnPropertyChange + * @function Montage#dispatchOwnPropertyChange * @param {string} name * @param value * @param {boolean} beforeChange Avoid the boolean trap and use @@ -1206,7 +1210,7 @@ Object.addEach(Montage.prototype, PropertyChanges.prototype); * Manually dispatches a notification that a property is about to change. * See `dispatchOwnPropertyChange`. * @see Montage#dispatchOwnPropertyChange - * @method Montage#dispatchBeforeOwnPropertyChange + * @function Montage#dispatchBeforeOwnPropertyChange * @param {string} name * @param value */ @@ -1215,19 +1219,22 @@ Object.addEach(Montage.prototype, PropertyChanges.prototype); * An overridable method for ensuring that changes to the named property * dispatch notifications. The default behavior is to wrap the property with a * getter and setter. - * @method Montage#makePropertyObservable + * @function Montage#makePropertyObservable * @param {string} name */ /** * Determines whether a property has ever been observed. Removing all property * change listeners does not destroy this record. - * @method Montage#hasOwnPropertyChangeDescriptor + * @function Montage#hasOwnPropertyChangeDescriptor * @param {string} name */ -// Bindings - +/** + * @class Bindings + * @extends frb + * @typedef {string} FRBExpression + */ var Bindings = exports.Bindings = require("frb"); var bindingPropertyDescriptors = { @@ -1251,7 +1258,7 @@ var bindingPropertyDescriptors = { * `converter`, but the polarity is reversed. This is useful for reusing * converters that were designed for data flowing the “wrong” way. The * `descriptor` may also provide a `trace` flag for console debugging. - * @method Montage#defineBinding + * @function Montage#defineBinding */ // The `commonDescriptor` is deliberately not documented as its use is // specific to the `defineBindings` implementation and not intended to @@ -1265,7 +1272,7 @@ var bindingPropertyDescriptors = { /** * Establishes multiple bindings. * @see Montage#defineBinding - * @method Montage#defineBindings + * @function Montage#defineBindings * @param descriptors {object} an object for which every property is a * source path and every value is a binding descriptor as described by * `defineBinding`. @@ -1284,7 +1291,8 @@ var bindingPropertyDescriptors = { * far reaching objects for the binding to be canceled. A component should * call this if the binding reaches into objects it does not itself own to * ensure that they are available for garbage collection. - * @method Montage#cancelBinding + * + * @function * @param {string} targetPath The target path used to establish the * binding. */ @@ -1296,7 +1304,8 @@ var bindingPropertyDescriptors = { /** * Cancels all registered bindings on this object. - * @method Montage#cancelBindings + * + * @function */ cancelBindings: { value: function () { @@ -1306,11 +1315,11 @@ var bindingPropertyDescriptors = { /** * Gets the binding descriptor for a target path. - * @method Montage#getBinding + * + * @function * @param {string} targetPath - * @returns {object} the descriptor for the binding. See `defineBinding` - * for information on the descriptor type. - * @see Montage#defineBinding + * @returns {object} the descriptor for the binding + * @see {@link Montage#defineBinding} for information on the descriptor type. */ getBinding: { value: function (targetPath) { @@ -1320,7 +1329,7 @@ var bindingPropertyDescriptors = { /** * Gets the binding descriptors for all target paths. - * @method Montage#getBindings + * @function Montage#getBindings * @returns {object} an object that maps traget paths to binding * descriptors. * See `defineBinding` for information on the descriptor type. @@ -1359,9 +1368,9 @@ var pathPropertyDescriptors = { /** * Evaluates an FRB expression from this object and returns the value. * The evaluator does not establish any change listeners. - * @method Montage#getPath + * @function Montage#getPath * @param {string} path an FRB expression - * @return the current value of the expression + * @returns the current value of the expression */ getPath: { value: function (path, parameters, document, components) { @@ -1379,7 +1388,7 @@ var pathPropertyDescriptors = { * Assigns a value to the FRB expression from this object. Not all * expressions can be assigned to. Property chains will work, but will * silently fail if the target object does not exist. - * @method Montage#setPath + * @function Montage#setPath * @param {string} path an FRB expression designating the value to replace * @param value the new value */ @@ -1399,12 +1408,12 @@ var pathPropertyDescriptors = { /** * Observes changes to the value of an FRB expression. The content of the * emitted value may react to changes, particularly if it is an array. - * @method Montage#observePath + * @function Montage#observePath * @param {string} path an FRB expression * @param {function} emit a function that receives new values in response * to changes. The emitter may return a `cancel` function if it manages * event listeners that must be collected when the value changes. - * @return {function} a canceler function that will remove all involved + * @returns {function} a canceler function that will remove all involved * change listeners, prevent new values from being observed, and prevent * previously emitted values from reacting to any further changes. */ @@ -1421,7 +1430,7 @@ var pathPropertyDescriptors = { * The handler will receive “ranged content change” messages. When a * change listener is added, the handler will be immediately invoked with * the initial content added at index 0 for the expression. - * @method Montage#addRangeAtPathChangeListener + * @function Montage#addRangeAtPathChangeListener * @param {string} path an FRB expression that produces content changes * @param handler a function that accepts `plus`, `minus`, and `index` * arguments, or a handler object with a designated method by that @@ -1469,7 +1478,7 @@ var pathPropertyDescriptors = { * Returns an internal index of all of the path change descriptors * associated with this instance. * @see Montage#getPathChangeDescriptor - * @method Montage#getPathChangeDescriptors + * @function Montage#getPathChangeDescriptors * @returns an object that maps property names to an object with two * Maps, `changeListeners` and `willChangeListeners`. Each of these * maps handler objects to path change descriptors. See @@ -1487,7 +1496,7 @@ var pathPropertyDescriptors = { /** * Gets the path change descriptor object for an observer established * previously by `addPathChangeListener` or `addBeforePathChangeListener`. - * @method Montage#getPathChangeDescriptor + * @function Montage#getPathChangeDescriptor * @param {string} path an FRB expression * @param handler a function that will receive a value change notification, * or an object with a method that will receive the change notifications @@ -1540,7 +1549,7 @@ var pathPropertyDescriptors = { * * Use `removePathChangeListener` to cancel all involved change listeners. * - * @method Montage#addPathChangeListener + * @function Montage#addPathChangeListener * @param {string} path an FRB expression. * @param {object|function} handler an object with a handler method, or a * function. The handler will be called with `value`, `path`, and this as @@ -1615,7 +1624,7 @@ var pathPropertyDescriptors = { * `addPathChangeListener`. The given arguments must match the original. * See `addPathChangeListener` for descriptions of their meaning. * @see Montage#addPathChangeListener - * @method Montage#removePathChangeListener + * @function Montage#removePathChangeListener * @param {string} path * @param {object|function} * @param {string} handlerMethodName @@ -1657,7 +1666,7 @@ var pathPropertyDescriptors = { * notification when the value of an FRB expression is about to change. * See `addPathChangeListener` for details. * @see Montage#addPathChangeListener - * @method Montage#addBeforePathChangeListener + * @function Montage#addBeforePathChangeListener * @param {string} path * @param {object|function} * @param {string} handlerMethodName @@ -1674,7 +1683,7 @@ var pathPropertyDescriptors = { * original. See `addPathChangeListener` for descriptions of their meaning. * @see Montage#addBeforePathChangeListener * @see Montage#addPathChangeListener - * @method Montage#removeBeforePathChangeListener + * @function Montage#removeBeforePathChangeListener * @param {string} path * @param {object|function} * @param {string} handlerMethodName diff --git a/core/deprecate.js b/core/deprecate.js index e26a2f3283..0893b8a38c 100644 --- a/core/deprecate.js +++ b/core/deprecate.js @@ -1,12 +1,14 @@ /* global ARRAY_PROTOTYPE: false, Montage: false */ + /** - * @module deprecate + * @module montage/core/deprecate */ /** * Prints out a deprecation warning to the console.warn with the format: * `name` is deprecated, use `alternative` instead. * It can also print out a stack trace with the line numbers. + * * @param {String} name - Name of the thing that is deprecated. * @param {String} alternative - Name of alternative that should be used instead. * @param {Number} [stackTraceLimit] - depth of the stack trace to print out. Set to falsy value to disable stack. @@ -36,10 +38,12 @@ var deprecationWarning = exports.deprecationWarning = function deprecationWarnin * Prints out a deprecation warning to the console.warn with the format: * `name` is deprecated, use `alternative` instead. * It will also print out a stack trace with the line numbers. + * * @param {Object} scope - The object that will be used as the `this` when the `deprecatedFunction` is applied. * @param {Function} deprecatedFunction - The function object that is deprecated. * @param {String} name - Name of the method that is deprecated. * @param {String} alternative - Name of alternative method that should be used instead. + * * @returns {Function} deprecationWrapper */ exports.deprecateMethod = function deprecate(scope, deprecatedFunction, name, alternative) { @@ -52,7 +56,15 @@ exports.deprecateMethod = function deprecate(scope, deprecatedFunction, name, al return deprecationWrapper; }; -// too call a function immediately and log a deprecation warning +/** + * To call a function immediately and log a deprecation warning + * + * @param scope + * @param callback + * @param name + * @param alternative + * @returns {*} + */ exports.callDeprecatedFunction = function callDeprecatedFunction(scope, callback, name, alternative/*, ...args */) { var depth = Error.stackTraceLimit, scopeName, diff --git a/core/document-part.js b/core/document-part.js index 33aff37f9f..e2d5d92207 100644 --- a/core/document-part.js +++ b/core/document-part.js @@ -18,7 +18,7 @@ var DocumentPart = Montage.specialize({ }, initWithTemplateAndFragment: { - value: function(template, fragment) { + value: function (template, fragment) { this.template = template; this.fragment = fragment; this.objects = null; @@ -28,7 +28,7 @@ var DocumentPart = Montage.specialize({ }, startActingAsTopComponent: { - value: function() { + value: function () { if (this.fragment) { defaultEventManager.registerEventHandlerForElement( this, this.fragment); @@ -37,7 +37,7 @@ var DocumentPart = Montage.specialize({ }, stopActingAsTopComponent: { - value: function() { + value: function () { if (this.fragment) { defaultEventManager.unregisterEventHandlerForElement( this.fragment); @@ -46,7 +46,7 @@ var DocumentPart = Montage.specialize({ }, addChildComponent: { - value: function(childComponent) { + value: function (childComponent) { if (this.childComponents.indexOf(childComponent) == -1) { this.childComponents.push(childComponent); } @@ -54,7 +54,7 @@ var DocumentPart = Montage.specialize({ }, removeChildComponent: { - value: function(childComponent) { + value: function (childComponent) { var childComponents = this.childComponents, ix = childComponents.indexOf(childComponent); @@ -67,12 +67,12 @@ var DocumentPart = Montage.specialize({ }, _addToDrawList: { - value: function() {} + value: function () {} }, _componentTreeLoadedDeferred: {value: null}, loadComponentTree: { - value: function() { + value: function () { var deferred = this._componentTreeLoadedDeferred, promises; @@ -82,11 +82,11 @@ var DocumentPart = Montage.specialize({ promises = []; - this.childComponents.forEach(function(childComponent) { + this.childComponents.forEach(function (childComponent) { promises.push(childComponent.loadComponentTree()); }); - Promise.all(promises).then(function() { + Promise.all(promises).then(function () { deferred.resolve(); }, deferred.reject).done(); } diff --git a/core/document-resources.js b/core/document-resources.js index 1988d891b1..1962abc542 100644 --- a/core/document-resources.js +++ b/core/document-resources.js @@ -18,7 +18,7 @@ var DocumentResources = Montage.specialize({ }, initWithDocument: { - value: function(_document) { + value: function (_document) { this.clear(); this._document = _document; @@ -29,11 +29,11 @@ var DocumentResources = Montage.specialize({ }, _populateWithDocument: { - value: function(_document) { + value: function (_document) { var scripts = _document.querySelectorAll("script"), forEach = Array.prototype.forEach; - forEach.call(scripts, function(script) { + forEach.call(scripts, function (script) { if (script.src) { this._addResource(this.normalizeUrl(script.src)); } @@ -41,7 +41,7 @@ var DocumentResources = Montage.specialize({ var links = _document.querySelectorAll("link"); - forEach.call(links, function(link) { + forEach.call(links, function (link) { if (link.rel === "stylesheet") { this._addResource(this.normalizeUrl(link.href)); } @@ -57,49 +57,49 @@ var DocumentResources = Montage.specialize({ }, _addResource: { - value: function(url) { + value: function (url) { this._resources[url] = true; } }, hasResource: { - value: function(url) { + value: function (url) { return url in this._resources; } }, isResourcePreloaded: { - value: function(url) { + value: function (url) { return this._preloaded[url] === true; } }, isResourcePreloading: { - value: function(url) { + value: function (url) { return Promise.isPromise(this._preloaded[url]); } }, setResourcePreloadedPromise: { - value: function(url, promise) { + value: function (url, promise) { this._preloaded[url] = promise; } }, setResourcePreloaded: { - value: function(url) { + value: function (url) { this._preloaded[url] = true; } }, getResourcePreloadedPromise: { - value: function(url) { + value: function (url) { return this._preloaded[url]; } }, addScript: { - value: function(script) { + value: function (script) { var url = this.normalizeUrl(script.src); if (url) { @@ -121,7 +121,7 @@ var DocumentResources = Montage.specialize({ // This change would make addStyle sync and up to whoever is adding // to listen for its proper loading. _importScript: { - value: function(script) { + value: function (script) { var self = this, _document = this._document, documentHead = _document.head, @@ -136,7 +136,7 @@ var DocumentResources = Montage.specialize({ // because templateDidLoad might need to access objects that // are defined in these scripts, the downsize is that it takes // more time for the template to be considered loaded. - scriptLoaded = function(event) { + scriptLoaded = function (event) { //if (event.type === "load") { self.setResourcePreloaded(url); //} @@ -152,7 +152,7 @@ var DocumentResources = Montage.specialize({ // Setup the timeout to wait for the script until the resource // is considered loaded. The template doesn't fail loading just // because a single script didn't load. - loadingTimeout = setTimeout(function() { + loadingTimeout = setTimeout(function () { self.setResourcePreloaded(url); deferred.resolve(); }, this._SCRIPT_TIMEOUT); @@ -178,7 +178,7 @@ var DocumentResources = Montage.specialize({ }, addStyle: { - value: function(element) { + value: function (element) { var url = element.getAttribute("href"), documentHead; @@ -198,7 +198,7 @@ var DocumentResources = Montage.specialize({ }, normalizeUrl: { - value: function(url, baseUrl) { + value: function (url, baseUrl) { if (!baseUrl) { baseUrl = this._document.location.href; } @@ -212,14 +212,14 @@ var DocumentResources = Montage.specialize({ }, isCrossDomain: { - value: function(url) { + value: function (url) { return url.indexOf(this.domain + "/") !== 0 || url.indexOf("file://") === 0; } }, preloadResource: { - value: function(url, forcePreload) { + value: function (url, forcePreload) { var skipPreload; url = this.normalizeUrl(url); @@ -242,7 +242,7 @@ var DocumentResources = Montage.specialize({ }, _preloadResource: { - value: function(url) { + value: function (url) { var self = this, req = new XMLHttpRequest(), loadHandler, @@ -251,7 +251,7 @@ var DocumentResources = Montage.specialize({ req.open("GET", url); - loadHandler = function(event) { + loadHandler = function (event) { //if (event.type === "load") { self.setResourcePreloaded(url); //} @@ -267,7 +267,7 @@ var DocumentResources = Montage.specialize({ // Setup the timeout to wait for the script until the resource // is considered loaded. - loadingTimeout = setTimeout(function() { + loadingTimeout = setTimeout(function () { self.setResourcePreloaded(url); deferred.resolve(); }, this._SCRIPT_TIMEOUT); @@ -279,7 +279,7 @@ var DocumentResources = Montage.specialize({ }, areStylesLoaded: { - get: function() { + get: function () { var styleSheets, ix; @@ -300,7 +300,7 @@ var DocumentResources = Montage.specialize({ }, { getInstanceForDocument: { - value: function(_document) { + value: function (_document) { //jshint -W106 var documentResources = _document.__montage_resources__; diff --git a/core/dom.js b/core/dom.js index 165e6a6e97..4fa0290b30 100644 --- a/core/dom.js +++ b/core/dom.js @@ -16,7 +16,7 @@ var Point = require("./geometry/point").Point, * @param {number} string */ Object.defineProperty(ElementPrototype, "set", { - value: function(aPropertyPath, value, currentIndex) { + value: function (aPropertyPath, value, currentIndex) { var dotIndex = aPropertyPath.indexOf(".", currentIndex), result, currentKeyComponent, @@ -55,11 +55,11 @@ Object.defineProperty(ElementPrototype, "set", { enumerable: false }); -NodePrototype.get = function(key) { +NodePrototype.get = function (key) { return this.getAttribute(key) || this[key]; }; -Object.getPrototypeOf(document).addRule = function(selectorText, definition) { +Object.getPrototypeOf(document).addRule = function (selectorText, definition) { var styleSheet, cssRule; if ((styleSheet = document.styleSheets[0]) == null) { var style = document.createElement("style"); @@ -74,7 +74,7 @@ Object.getPrototypeOf(document).addRule = function(selectorText, definition) { } }; -Object.getPrototypeOf(document).getRule = function(ruleKey, styleSheet) { +Object.getPrototypeOf(document).getRule = function (ruleKey, styleSheet) { var cssRule; if (styleSheet.cssRules) { for (var j = 0; (cssRule = styleSheet.cssRules[j]); j++) { @@ -170,14 +170,14 @@ if (typeof Element !== "undefined") { } -NodePrototype.parentOf = function(child) { +NodePrototype.parentOf = function (child) { while ((child = child.parentNode) && child !== this) {} //If child is defined then we didn't walk all the way up to the root return child ? true : false; }; -var _offsetForElement = function(element) { +var _offsetForElement = function (element) { var boundingClientRect, elementsDocument = element.ownerDocument, elementsDocumentElement, @@ -213,8 +213,8 @@ var _offsetForElement = function(element) { var _webKitPoint = null; -var webkitImplementation = function() { - exports.convertPointFromNodeToPage = function(element, point) { +var webkitImplementation = function () { + exports.convertPointFromNodeToPage = function (element, point) { if(point) { _webKitPoint.x = point.x; _webKitPoint.y = point.y; @@ -226,7 +226,7 @@ var webkitImplementation = function() { return point ? new Point().init(point.x, point.y) : null; }; - exports.convertPointFromPageToNode = function(element, point) { + exports.convertPointFromPageToNode = function (element, point) { if(point) { _webKitPoint.x = point.x; _webKitPoint.y = point.y; @@ -239,8 +239,8 @@ var webkitImplementation = function() { }; }; -var shimImplementation = function() { - exports.convertPointFromNodeToPage = function(element, point) { +var shimImplementation = function () { + exports.convertPointFromNodeToPage = function (element, point) { if (!element || typeof element.x !== "undefined") { return null; } @@ -252,7 +252,7 @@ var shimImplementation = function() { } }; - exports.convertPointFromPageToNode = function(element, point) { + exports.convertPointFromPageToNode = function (element, point) { if (!element || typeof element.x !== "undefined") { return null; } diff --git a/core/enum.js b/core/enum.js index 3a7b34ae28..d9c995e1bb 100644 --- a/core/enum.js +++ b/core/enum.js @@ -23,11 +23,11 @@ exports.Enum = Montage.specialize( /** @lends Enum# */ { }, /** - * @method + * @function * @returns itself */ init : { - value: function() { + value: function () { if (Object.isSealed(this)) { logger.error(this, "Object is sealed"); } @@ -36,11 +36,11 @@ exports.Enum = Montage.specialize( /** @lends Enum# */ { }, /** - * @method + * @function * @returns {Object} Object.seal(this) */ initWithMembers : { - value: function() { + value: function () { if (Object.isSealed(this)) { logger.error(this, "Object is sealed"); return this; @@ -58,11 +58,11 @@ exports.Enum = Montage.specialize( /** @lends Enum# */ { }, /** - * @method + * @function * @param {string} member The member to be added. */ addMember : { - value: function(member) { + value: function (member) { if (typeof this[member] === "undefined") { Object.defineProperty(this, member, { @@ -77,11 +77,11 @@ exports.Enum = Montage.specialize( /** @lends Enum# */ { }, /** - * @method + * @function * @returns {Object} this, but sealed */ seal : { - value: function() { + value: function () { if (! Object.isSealed(this)) { return Object.seal(this); } diff --git a/core/event/action-event-listener.js b/core/event/action-event-listener.js index 005b79c3c2..4a3217c618 100644 --- a/core/event/action-event-listener.js +++ b/core/event/action-event-listener.js @@ -8,7 +8,7 @@ var Montage = require("../core").Montage; * @class ActionEventListener * @extends Montage */ -var ActionEventListener = exports.ActionEventListener = Montage.specialize( /** @lends ActionEventListener# */ { +var ActionEventListener = exports.ActionEventListener = Montage.specialize( /** @lends ActionEventListener.prototype # */ { /** * The logical object handling received events @@ -27,8 +27,9 @@ var ActionEventListener = exports.ActionEventListener = Montage.specialize( /** * actionEventListener as the context. * * If neither handler nor action is set, the event is ignored. - * @type {String|Function} - * @default {Event handler} null + * + * @property {String|Function} value + * @default null * */ action: { @@ -38,21 +39,26 @@ var ActionEventListener = exports.ActionEventListener = Montage.specialize( /** /** * Returns a new ActionEventListener instance with the specified handler * and action. - * @method - * @param {Object} handler The event handler - * @param {String|Function} action The event handler action - * @returns {ActionEventListener} The initialized ActionEventListener + * + * @function + * @param {Object} handler - The event handler + * @param {String|Function} action - The event handler action + * @returns {ActionEventListener} - The initialized ActionEventListener * */ initWithHandler_action_: { - value: function(handler, action) { + value: function (handler, action) { this.handler = handler; this.action = action; return this; } }, + /** + * @function + * @param {Event} event + */ handleEvent: { - value: function(event) { + value: function (event) { if (typeof this.action === "function") { var context = this.handler ? this.handler : this; this.action.call(context, event); @@ -62,8 +68,12 @@ var ActionEventListener = exports.ActionEventListener = Montage.specialize( /** } }, + /** + * @function + * @param {Serializer} serializer + */ serializeProperties: { - value: function(serializer) { + value: function (serializer) { serializer.set("handler", this.handler, "reference"); // TODO accepting an actual function is less than ideal from the // serialization standpoint @@ -72,10 +82,7 @@ var ActionEventListener = exports.ActionEventListener = Montage.specialize( /** } }, { - blueprintModuleId: require("../core")._blueprintModuleIdDescriptor, - blueprint: require("../core")._blueprintDescriptor - }); diff --git a/core/event/event-manager.js b/core/event/event-manager.js index 25b326bd12..8dba591a07 100644 --- a/core/event/event-manager.js +++ b/core/event/event-manager.js @@ -1,15 +1,18 @@ /*global Window,Document,Element,Event,Components,Touch */ /** - * @author: Lea Verou - * @license: Licensed under The MIT License. See license.txt and http://www.opensource.org/licenses/mit-license.php. - * @website: http://leaverou.github.com/chainvas/ + * @author Lea Verou + * @license MIT + * @see http://leaverou.github.com/chainvas/ */ /** * @module montage/core/event/event-manager * @requires montage/core/core + * @requires montage/core/uuid + * @requires montage/core/uuid * @requires montage/core/event/mutable-event + * @requires montage/core/serialization * @requires montage/core/event/action-event-listener */ @@ -22,1625 +25,1727 @@ var Montage = require("../core").Montage, // XXX Does not presently function server-side if (typeof window !== "undefined") { // client-side -//jshint -W015 -/* This is to handle browsers that have TouchEvents but don't have the global constructor function Touch */ -if (typeof window.Touch === "undefined" && "ontouchstart" in window) { - window.Touch = function() { - }; - (function() { - var onFirstTouchstart; - - document.addEventListener("touchstart", onFirstTouchstart = function (event) { - window.Touch = event.touches[0].constructor; - if (document.nativeRemoveEventListener) { - document.nativeRemoveEventListener("touchstart", onFirstTouchstart, true); - } else { - document.removeEventListener("touchstart", onFirstTouchstart, true); - } - if (defaultEventManager && defaultEventManager.isStoringPointerEvents) { - defaultEventManager.isStoringPointerEvents = false; - defaultEventManager.isStoringPointerEvents = true; - } - }, true); - })(); -} + // jshint -W015 + /* This is to handle browsers that have TouchEvents but don't have the global constructor function Touch */ + if (typeof window.Touch === "undefined" && "ontouchstart" in window) { + window.Touch = function () {}; + + (function () { + var onFirstTouchstart; + + document.addEventListener("touchstart", onFirstTouchstart = function (event) { + window.Touch = event.touches[0].constructor; + if (document.nativeRemoveEventListener) { + document.nativeRemoveEventListener("touchstart", onFirstTouchstart, true); + } else { + document.removeEventListener("touchstart", onFirstTouchstart, true); + } + if (defaultEventManager && defaultEventManager.isStoringPointerEvents) { + defaultEventManager.isStoringPointerEvents = false; + defaultEventManager.isStoringPointerEvents = true; + } + }, true); + })(); + } -var EventListenerDescriptor = Montage.specialize( { - type: { - value: null - }, + var EventListenerDescriptor = Montage.specialize({ + type: { + value: null + }, - listener: { - value: null - }, + listener: { + value: null + }, - capture: { - value: null - } -}); - -var _PointerStorageMemoryEntry = Montage.specialize( { - constructor: { - value: function(identifier) { - this.data = new Array(32); - this.velocity = { velocity:(new _PointerVelocity()).initWithIdentifier(identifier)}; - return this; - } - }, - data: { - enumerable: false, - writable: true, - value: null - }, - size: { - enumerable: false, - writable: true, - value: 0 - }, - pos: { - enumerable: false, - writable: true, - value: 0 - }, - velocity: { - enumerable: false, - writable: true, - value: 0 - } + capture: { + value: null + } + }); -}); - -var _StoredEvent = Montage.specialize( { - constructor: { - value: function(clientX,clientY,timeStamp) { - this.clientX = clientX; - this.clientY = clientY; - this.timeStamp = timeStamp; - return this; - } - }, - clientX: { - enumerable: false, - writable: true, - value: null - }, - clientY: { - enumerable: false, - writable: true, - value: 0 - }, - timeStamp: { - enumerable: false, - writable: true, - value: 0 - } -}); - -var _PointerStorage = Montage.specialize( { - - memory: { - value:{} - }, - add: { - value:function (identifier, clientX, clientY, timeStamp) { - var identifierEntry; - if (!(identifierEntry = this.memory[identifier])) { - identifierEntry = this.memory[identifier] = new _PointerStorageMemoryEntry(identifier); - } - if(!(data = identifierEntry.data[identifierEntry.pos])) { - data = identifierEntry.data[identifierEntry.pos] = new _StoredEvent(clientX,clientY,timeStamp); - } - else { - data.clientX = clientX; - data.clientY = clientY; - data.timeStamp = timeStamp; - } - if (identifierEntry.size < identifierEntry.data.length) { - identifierEntry.size++; - } - identifierEntry.pos = (identifierEntry.pos + 1) % identifierEntry.data.length; - } - }, - remove: { - value:function (identifier) { - delete this.memory[identifier]; - } - }, - clear: { - value:function (identifier) { - if (this.memory[identifier]) { - this.memory[identifier].size = 0; - this.memory[identifier].velocity.velocity.clearCache(); - } - } - }, - getMemory: { - value:function (identifier) { - return this.memory[identifier]; - } - }, - isStored: { - value:function (identifier) { - return (this.memory[identifier] && (this.memory[identifier].size > 0)); - } - }, + var _PointerStorageMemoryEntry = Montage.specialize({ + constructor: { + value: function (identifier) { + this.data = new Array(32); + this.velocity = {velocity: (new _PointerVelocity()).initWithIdentifier(identifier)}; + return this; + } + }, + data: { + enumerable: false, + writable: true, + value: null + }, + size: { + enumerable: false, + writable: true, + value: 0 + }, + pos: { + enumerable: false, + writable: true, + value: 0 + }, + velocity: { + enumerable: false, + writable: true, + value: 0 + } - /** - * Created a dedicated type, _PointerVelocity and cached the instance of _PointerVelocity used per identifier, - * which is typically mouse/touch. This - */ + }); - pointerVelocity: { - value:function (identifier) { - if(this.memory[identifier]) { - return this.memory[identifier].velocity; - } - } - }, - storeEvent: { - value:function(event) { - var i; - switch (event.type) { - case "mousedown": - defaultEventManager._isMouseDragging = true; - // roll into mousemove. break omitted intentionally. - case "mousemove": - if (defaultEventManager._isStoringMouseEventsWhileDraggingOnly) { - if (defaultEventManager._isMouseDragging) { - this.add("mouse", event.clientX,event.clientY,event.timeStamp); - Object.defineProperty(event, "velocity", { - get: function () { - return defaultEventManager.pointerMotion("mouse").velocity; - }, - set: function () { - } - }); - } - } else { - this.add("mouse", event.clientX,event.clientY,event.timeStamp); - Object.defineProperty(event, "velocity", { - get: function () { - return defaultEventManager.pointerMotion("mouse").velocity; - }, - set: function () { - } - }); - } - break; - case "mouseup": - this.add("mouse", event.clientX,event.clientY,event.timeStamp); - Object.defineProperty(event, "velocity", { - get: function () { - return defaultEventManager.pointerMotion("mouse").velocity; - }, - set: function () { - } - }); - break; - case "touchstart": - case "touchmove": - for (i = 0; i < event.touches.length; i++) { - this.add(event.touches[i].identifier, event.touches[i].clientX,event.touches[i].clientY,event.timeStamp); - } - break; - case "touchend": - for (i = 0; i < event.changedTouches.length; i++) { - this.add(event.changedTouches[i].identifier, event.changedTouches[i].clientX,event.changedTouches[i].clientY,event.timeStamp); - } - break; - } - } - }, - removeEvent: { - value:function(event) { - var i; - switch (event.type) { - case "mouseup": - defaultEventManager._isMouseDragging = false; - if (defaultEventManager._isStoringMouseEventsWhileDraggingOnly) { - this.clear("mouse"); - } - break; - case "touchend": - for (i = 0; i < event.changedTouches.length; i++) { - this.remove(event.changedTouches[i].identifier); - } - break; - } - } - } -}); - -var _PointerVelocity = Montage.specialize( { - _identifier: { - enumerable: false, - writable: true, - value: null - }, - initWithIdentifier: { - value: function(identifier) { - this._identifier = identifier; - return this; - } - }, - clearCache: { - value: function() { - this._data = this._x = this._y = this._speed = this._angle = null; - return this; - } - }, - _data: { - enumerable: false, - writable: true, - value: null - }, - _x: { - enumerable: false, - writable: true, - value: null - }, - _y: { - enumerable: false, - writable: true, - value: null - }, - _speed: { - enumerable: false, - writable: true, - value: null - }, - _angle: { - enumerable: false, - writable: true, - value: null - }, - x: { - get: function () { - if (this._x === null) { - if (this._data === null) { - this._data = defaultEventManager._getPointerVelocityData(this._identifier); - } - this._x = defaultEventManager._calculatePointerVelocity(this._data.time, this._data.x); + var _StoredEvent = Montage.specialize({ + constructor: { + value: function (clientX, clientY, timeStamp) { + this.clientX = clientX; + this.clientY = clientY; + this.timeStamp = timeStamp; + return this; } - return this._x; }, - set: function () { + clientX: { + enumerable: false, + writable: true, + value: null + }, + clientY: { + enumerable: false, + writable: true, + value: 0 + }, + timeStamp: { + enumerable: false, + writable: true, + value: 0 } - }, - y: { - get: function () { - if (this._y === null) { - if (this._data === null) { - this._data = defaultEventManager._getPointerVelocityData(this._identifier); - } - this._y = defaultEventManager._calculatePointerVelocity(this._data.time, this._data.y); + }); + + var _PointerStorage = Montage.specialize({ + + memory: { + value: {} + }, + add: { + value: function (identifier, clientX, clientY, timeStamp) { + var identifierEntry; + if (!(identifierEntry = this.memory[identifier])) { + identifierEntry = this.memory[identifier] = new _PointerStorageMemoryEntry(identifier); + } + if (!(data = identifierEntry.data[identifierEntry.pos])) { + data = identifierEntry.data[identifierEntry.pos] = new _StoredEvent(clientX, clientY, timeStamp); + } + else { + data.clientX = clientX; + data.clientY = clientY; + data.timeStamp = timeStamp; + } + if (identifierEntry.size < identifierEntry.data.length) { + identifierEntry.size++; + } + identifierEntry.pos = (identifierEntry.pos + 1) % identifierEntry.data.length; } - return this._y; }, - set: function () { - } - }, - speed: { - get: function () { - if (this._speed === null) { - this._speed = Math.sqrt(this.x * this.x + this.y * this.y); + remove: { + value: function (identifier) { + delete this.memory[identifier]; } - return this._speed; }, - set: function () { + clear: { + value: function (identifier) { + if (this.memory[identifier]) { + this.memory[identifier].size = 0; + this.memory[identifier].velocity.velocity.clearCache(); + } + } + }, + getMemory: { + value: function (identifier) { + return this.memory[identifier]; + } + }, + isStored: { + value: function (identifier) { + return (this.memory[identifier] && (this.memory[identifier].size > 0)); + } + }, + + /** + * Created a dedicated type, _PointerVelocity and cached the instance of _PointerVelocity used per identifier, + * which is typically mouse/touch. This + */ + + pointerVelocity: { + value: function (identifier) { + if (this.memory[identifier]) { + return this.memory[identifier].velocity; + } + } + }, + storeEvent: { + value: function (event) { + var i; + switch (event.type) { + case "mousedown": + defaultEventManager._isMouseDragging = true; + // roll into mousemove. break omitted intentionally. + case "mousemove": + if (defaultEventManager._isStoringMouseEventsWhileDraggingOnly) { + if (defaultEventManager._isMouseDragging) { + this.add("mouse", event.clientX, event.clientY, event.timeStamp); + Object.defineProperty(event, "velocity", { + get: function () { + return defaultEventManager.pointerMotion("mouse").velocity; + }, + set: function () { + } + }); + } + } else { + this.add("mouse", event.clientX, event.clientY, event.timeStamp); + Object.defineProperty(event, "velocity", { + get: function () { + return defaultEventManager.pointerMotion("mouse").velocity; + }, + set: function () { + } + }); + } + break; + case "mouseup": + this.add("mouse", event.clientX, event.clientY, event.timeStamp); + Object.defineProperty(event, "velocity", { + get: function () { + return defaultEventManager.pointerMotion("mouse").velocity; + }, + set: function () { + } + }); + break; + case "touchstart": + case "touchmove": + for (i = 0; i < event.touches.length; i++) { + this.add(event.touches[i].identifier, event.touches[i].clientX, event.touches[i].clientY, event.timeStamp); + } + break; + case "touchend": + for (i = 0; i < event.changedTouches.length; i++) { + this.add(event.changedTouches[i].identifier, event.changedTouches[i].clientX, event.changedTouches[i].clientY, event.timeStamp); + } + break; + } + } + }, + removeEvent: { + value: function (event) { + var i; + switch (event.type) { + case "mouseup": + defaultEventManager._isMouseDragging = false; + if (defaultEventManager._isStoringMouseEventsWhileDraggingOnly) { + this.clear("mouse"); + } + break; + case "touchend": + for (i = 0; i < event.changedTouches.length; i++) { + this.remove(event.changedTouches[i].identifier); + } + break; + } + } } - }, - angle: { - get: function () { - if (this._angle === null) { - this._angle = Math.atan2(this.y, this.x); + }); + + var _PointerVelocity = Montage.specialize({ + _identifier: { + enumerable: false, + writable: true, + value: null + }, + initWithIdentifier: { + value: function (identifier) { + this._identifier = identifier; + return this; + } + }, + clearCache: { + value: function () { + this._data = this._x = this._y = this._speed = this._angle = null; + return this; + } + }, + _data: { + enumerable: false, + writable: true, + value: null + }, + _x: { + enumerable: false, + writable: true, + value: null + }, + _y: { + enumerable: false, + writable: true, + value: null + }, + _speed: { + enumerable: false, + writable: true, + value: null + }, + _angle: { + enumerable: false, + writable: true, + value: null + }, + x: { + get: function () { + if (this._x === null) { + if (this._data === null) { + this._data = defaultEventManager._getPointerVelocityData(this._identifier); + } + this._x = defaultEventManager._calculatePointerVelocity(this._data.time, this._data.x); + } + return this._x; + }, + set: function () { + } + }, + y: { + get: function () { + if (this._y === null) { + if (this._data === null) { + this._data = defaultEventManager._getPointerVelocityData(this._identifier); + } + this._y = defaultEventManager._calculatePointerVelocity(this._data.time, this._data.y); + } + return this._y; + }, + set: function () { } - return this._angle; }, - set: function () { + speed: { + get: function () { + if (this._speed === null) { + this._speed = Math.sqrt(this.x * this.x + this.y * this.y); + } + return this._speed; + }, + set: function () { + } + }, + angle: { + get: function () { + if (this._angle === null) { + this._angle = Math.atan2(this.y, this.x); + } + return this._angle; + }, + set: function () { + } } - } -}); - -/* -eventTypeRegistration[target.uuid] = {target: target, listeners: {}}; -eventTypeRegistration[target.uuid].listeners[listener.uuid] = {listener: listener, capture: useCapture, bubble: !useCapture}; -*/ -var _TargetRegistration = function () { - this.listeners = {}; - return this; -}; - -_TargetRegistration._pool = []; -_TargetRegistration.checkoutRegistration = function() { - return (this._pool.length === 0) ? (new this()) : this._pool.pop(); -}; -_TargetRegistration.checkinRegistration = function(aTargetRegistration) { - aTargetRegistration.target = null; - //aTargetRegistration.listeners = {}; - this._pool.push(aTargetRegistration); -}; - -Object.defineProperties(_TargetRegistration.prototype, - -{ - target: { - enumerable: false, - writable: true, - value: null - }, - listeners: { - enumerable: false, - writable: true, - value: null - } -} -); - -var _TargetListenerRegistration = function () { - return this; -}; - -_TargetListenerRegistration._pool = []; -_TargetListenerRegistration.checkoutRegistration = function() { - return (this._pool.length === 0) ? (new this()) : this._pool.pop(); -}; -_TargetListenerRegistration.checkinRegistration = function(aTargetListenerRegistration) { - aTargetListenerRegistration.listener = null; - this._pool.push(aTargetListenerRegistration); -}; - -Object.defineProperties(_TargetListenerRegistration.prototype, - -{ - initWithListener: { - value: function(listener,capture,bubble) { - this.listener = listener; - this.capture = capture; - this.bubble = bubble; - return this; - } - }, - listener: { - enumerable: false, - writable: true, - value: null - }, - capture: { - enumerable: false, - writable: true, - value: true - }, - bubble: { - enumerable: false, - writable: true, - value: false - } -} -); - - - -Serializer.defineSerializationUnit("listeners", function(serializer, object) { - var eventManager = defaultEventManager, - uuid = object.uuid, - eventListenerDescriptors = [], - descriptors, - descriptor, - listener; - - for (var type in eventManager.registeredEventListeners) { - descriptors = eventManager.registeredEventListeners[type]; - descriptor = descriptors && descriptors[uuid]; - if (descriptor) { - for (var listenerUuid in descriptor.listeners) { - listener = descriptor.listeners[listenerUuid]; - - eventListenerDescriptors.push({ - type: type, - listener: serializer.addObjectReference(listener.listener), - capture: listener.capture - }); + }); + + /* + eventTypeRegistration[target.uuid] = {target: target, listeners: {}}; + eventTypeRegistration[target.uuid].listeners[listener.uuid] = {listener: listener, capture: useCapture, bubble: !useCapture}; + */ + var _TargetRegistration = function () { + this.listeners = {}; + return this; + }; + + _TargetRegistration._pool = []; + _TargetRegistration.checkoutRegistration = function () { + return (this._pool.length === 0) ? (new this()) : this._pool.pop(); + }; + _TargetRegistration.checkinRegistration = function (aTargetRegistration) { + aTargetRegistration.target = null; + //aTargetRegistration.listeners = {}; + this._pool.push(aTargetRegistration); + }; + + Object.defineProperties(_TargetRegistration.prototype, + + { + target: { + enumerable: false, + writable: true, + value: null + }, + listeners: { + enumerable: false, + writable: true, + value: null } } - } + ); - if (eventListenerDescriptors.length > 0) { - return eventListenerDescriptors; - } -}); + var _TargetListenerRegistration = function () { + return this; + }; -Deserializer.defineDeserializationUnit("listeners", function(deserializer, object, listeners) { - for (var i = 0, listener; (listener = listeners[i]); i++) { - object.addEventListener(listener.type, listener.listener, listener.capture); - } -}); + _TargetListenerRegistration._pool = []; + _TargetListenerRegistration.checkoutRegistration = function () { + return (this._pool.length === 0) ? (new this()) : this._pool.pop(); + }; + _TargetListenerRegistration.checkinRegistration = function (aTargetListenerRegistration) { + aTargetListenerRegistration.listener = null; + this._pool.push(aTargetListenerRegistration); + }; -var NONE = Event.NONE, - CAPTURING_PHASE = Event.CAPTURING_PHASE, - AT_TARGET = Event.AT_TARGET, - BUBBLING_PHASE = Event.BUBBLING_PHASE, - FUNCTION_TYPE = "function"; + Object.defineProperties(_TargetListenerRegistration.prototype, -/** - * @class EventManager - */ -var EventManager = exports.EventManager = Montage.specialize(/** @lends EventManager# */ { - constructor: { - value: function EventManager() { - this.super(); + { + initWithListener: { + value: function (listener, capture, bubble) { + this.listener = listener; + this.capture = capture; + this.bubble = bubble; + return this; + } + }, + listener: { + enumerable: false, + writable: true, + value: null + }, + capture: { + enumerable: false, + writable: true, + value: true + }, + bubble: { + enumerable: false, + writable: true, + value: false + } } - }, - // Utility - eventDefinitions: { - // ClipboardEvent http://dev.w3.org/2006/webapi/clipops/clipops.html#event-types-and-details - // DND http://www.w3.org/TR/2010/WD-html5-20101019/dnd.html - // document.implementation.hasFeature("HTMLEvents", "2.0") - // DOM2 http://www.w3.org/TR/DOM-Level-2-Events/events.html - // DOM3 http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html - // DOM4 http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#events - // GECKO https://developer.mozilla.org/en/Gecko-Specific_DOM_Events - // MSFT defacto standard - // ProgressEvent http://www.w3.org/TR/progress-events/ - // TouchEvent http://dvcs.w3.org/hg/webevents/raw-file/tip/touchevents.html - // INPUT http://dev.w3.org/html5/spec/common-input-element-apis.html#common-event-behaviors - // WEBSOCKETS http://www.w3.org/TR/html5/comms.html - - // Other info: - // http://www.quirksmode.org/dom/events/index.html - // https://developer.mozilla.org/en/DOM/DOM_event_reference - value: { - abort: {bubbles: false, cancelable: false}, //ProgressEvent, DOM3, //DOM2 does bubble - beforeunload: {bubbles: false}, //MSFT - blur: {bubbles: false, cancelable: false}, //DOM2, DOM3 - change: {bubbles: true, cancelable: false}, //DOM2, INPUT - click: {bubbles: true, cancelable: true}, //DOM3 - close: {bubbles: false, cancelable: false}, //WEBSOCKETS - compositionend: {bubbles: true, cancelable: false}, //DOM3 - compositionstart: {bubbles: true, cancelable: true}, //DOM3 - compositionupdate: {bubbles: true, cancelable: false}, //DOM3 - contextmenu: {bubbles: true, cancelable: true}, //MSFT - copy: {bubbles: true, cancelable: true}, //ClipboardEvent - cut: {bubbles: true, cancelable: true}, //ClipboardEvent - dblclick: {bubbles: true, cancelable: false}, //DOM3 - DOMActivate: {bubbles: true, cancelable: true, deprecated: true}, //DOM2, DOM3 deprecated - DOMMouseScroll: {bubbles: true}, //GECKO - drag: {bubbles: true, cancelable: true}, //DND - dragend: {bubbles: true, cancelable: false}, //DND - dragenter: {bubbles: true, cancelable: true}, //DND - dragleave: {bubbles: true, cancelable: false}, //DND - dragover: {bubbles: true, cancelable: true}, //DND - dragstart: {bubbles: true, cancelable: true}, //DND - drop: {bubbles: true, cancelable: true}, //DND - error: { - bubbles: function(target) { - // error does not bubble when used as a ProgressEvent - return !(XMLHttpRequest.prototype.isPrototypeOf(target) || - target.tagName && "VIDEO" === target.tagName.toUpperCase() || - target.tagName && "AUDIO" === target.tagName.toUpperCase()); - }, - cancelable: false - }, //DOM2, DOM3, ProgressEvent - focus: {bubbles: false, cancelable: false}, //DOM2, DOM3 - focusin: {bubbles: true, cancelable: false}, //DOM3 - focusout: {bubbles: true, cancelable: false}, //DOM3 - input: {bubbles: true, cancelable: false}, // INPUT - keydown: {bubbles: true, cancelable: false}, //DOM3 - keypress: {bubbles: true, cancelable: false}, //DOM3 - keyup: {bubbles: true, cancelable: false}, //DOM3 - load: {bubbles: false, cancelable: false}, //ProgressEvent, DOM2, DOM3 - loadend: {bubbles: false, cancelable: false}, //ProgressEvent - loadstart: {bubbles: false, cancelable: false}, //ProgressEvent - message: {bubbles: false, cancelable: false}, //WEBSOCKETS - mousedown: {bubbles: true, cancelable: true}, //DOM3 - mouseenter: {bubbles: false, cancelable: false}, //DOM3 - mouseleave: {bubbles: false, cancelable: false}, //DOM3 - mousemove: {bubbles: true, cancelable: true}, //DOM3 - mouseout: {bubbles: true, cancelable: true}, //DOM3 - mouseover: {bubbles: true, cancelable: true}, //DOM3 - mouseup: {bubbles: true, cancelable: true}, //DOM3 - mousewheel: {bubbles: true}, - orientationchange: {bubbles: false}, - paste: {bubbles: true, cancelable: true}, //ClipboardEvent - progress: {bubbles: false, cancelable: false}, //ProgressEvent - reset: {bubbles: true, cancelable: false}, //DOM2 - resize: {bubbles: false, cancelable: false}, //DOM2 bubbles, DOM3 - - scroll: { - bubbles: function(target) { - return /*isDocument*/!!target.defaultView; - }, - cancelable: false - }, //DOM2, DOM3 When dispatched on Document element must bubble to defaultView object - - select: {bubbles: true, cancelable: false}, //DOM2, DOM3 - - submit: {bubbles: true, cancelable: true}, //DOM2 - touchcancel: {bubbles: true, cancelable: false}, //TouchEvent - touchend: {bubbles: true, cancelable: true}, //TouchEvent - touchmove: {bubbles: true, cancelable: true}, //TouchEvent - touchstart: {bubbles: true, cancelable: true}, //TouchEvent - unload: {bubbles: false, cancelable: false}, //DOM2, DOM3 - wheel: {bubbles: true, cancelable: true} //DOM3 + ); + + Serializer.defineSerializationUnit("listeners", function (serializer, object) { + var eventManager = defaultEventManager, + uuid = object.uuid, + eventListenerDescriptors = [], + descriptors, + descriptor, + listener; + + for (var type in eventManager.registeredEventListeners) { + descriptors = eventManager.registeredEventListeners[type]; + descriptor = descriptors && descriptors[uuid]; + if (descriptor) { + for (var listenerUuid in descriptor.listeners) { + listener = descriptor.listeners[listenerUuid]; + + eventListenerDescriptors.push({ + type: type, + listener: serializer.addObjectReference(listener.listener), + capture: listener.capture + }); + } + } } - }, - - _DOMPasteboardElement: { - value: null, - enumerable: false - }, - _delegate: { - value: null, - enumerable: false - }, -/** - @type {string} - @default null - */ - delegate: { - enumerable: false, - get: function() { - return this._delegate; - }, - set: function(delegate) { - this._delegate = delegate; + if (eventListenerDescriptors.length > 0) { + return eventListenerDescriptors; } - }, - _application: { - value: null, - enumerable: false - }, -/** - The application object associated with the event manager. - @type {string} - @default null - */ - application: { - enumerable: false, - get: function() { - return this._application; - }, - set: function(application) { - // TODO if this changes...we probably need to unregister all the windows - // we know about and frankly probably the components too - // Really maybe this should be possible. - this._application = application; + }); + + Deserializer.defineDeserializationUnit("listeners", function (deserializer, object, listeners) { + for (var i = 0, listener; (listener = listeners[i]); i++) { + object.addEventListener(listener.type, listener.listener, listener.capture); } - }, + }); - // Dictionary keyed by event types with the collection of handlers per event type - // This dictates why the event manager observes events of a particular type + var NONE = Event.NONE, + CAPTURING_PHASE = Event.CAPTURING_PHASE, + AT_TARGET = Event.AT_TARGET, + BUBBLING_PHASE = Event.BUBBLING_PHASE, + FUNCTION_TYPE = "function"; - // Simple array of all windows this event Manager may be listening to + /** + * @class EventManager + * @extends Montage + */ + var EventManager = exports.EventManager = Montage.specialize(/** @lends EventManager.prototype # */ { + /** + * @constructs + */ + constructor: { + value: function EventManager () { + this.super(); + } + }, - _registeredWindows: { - value: null, - enumerable: false - }, + /** + * Utility + * @see ClipboardEvent http://dev.w3.org/2006/webapi/clipops/clipops.html#event-types-and-details + * @see DND http://www.w3.org/TR/2010/WD-html5-20101019/dnd.html + * @see document.implementation.hasFeature("HTMLEvents", "2.0") + * @see DOM2 http://www.w3.org/TR/DOM-Level-2-Events/events.html + * @see DOM3 http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html + * @see DOM4 http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#events + * @see GECKO https://developer.mozilla.org/en/Gecko-Specific_DOM_Events + * @see MSFT defacto standard + * @see ProgressEvent http://www.w3.org/TR/progress-events/ + * @see TouchEvent http://dvcs.w3.org/hg/webevents/raw-file/tip/touchevents.html + * @see INPUT http://dev.w3.org/html5/spec/common-input-element-apis.html#common-event-behaviors + * @see WEBSOCKETS http://www.w3.org/TR/html5/comms.html + * @see http://www.quirksmode.org/dom/events/index.html + * @see https://developer.mozilla.org/en/DOM/DOM_event_reference + */ + eventDefinitions: { + value: { + abort: {bubbles: false, cancelable: false}, //ProgressEvent, DOM3, //DOM2 does bubble + beforeunload: {bubbles: false}, //MSFT + blur: {bubbles: false, cancelable: false}, //DOM2, DOM3 + change: {bubbles: true, cancelable: false}, //DOM2, INPUT + click: {bubbles: true, cancelable: true}, //DOM3 + close: {bubbles: false, cancelable: false}, //WEBSOCKETS + compositionend: {bubbles: true, cancelable: false}, //DOM3 + compositionstart: {bubbles: true, cancelable: true}, //DOM3 + compositionupdate: {bubbles: true, cancelable: false}, //DOM3 + contextmenu: {bubbles: true, cancelable: true}, //MSFT + copy: {bubbles: true, cancelable: true}, //ClipboardEvent + cut: {bubbles: true, cancelable: true}, //ClipboardEvent + dblclick: {bubbles: true, cancelable: false}, //DOM3 + DOMActivate: {bubbles: true, cancelable: true, deprecated: true}, //DOM2, DOM3 deprecated + DOMMouseScroll: {bubbles: true}, //GECKO + drag: {bubbles: true, cancelable: true}, //DND + dragend: {bubbles: true, cancelable: false}, //DND + dragenter: {bubbles: true, cancelable: true}, //DND + dragleave: {bubbles: true, cancelable: false}, //DND + dragover: {bubbles: true, cancelable: true}, //DND + dragstart: {bubbles: true, cancelable: true}, //DND + drop: {bubbles: true, cancelable: true}, //DND + error: { + bubbles: function (target) { + // error does not bubble when used as a ProgressEvent + return !(XMLHttpRequest.prototype.isPrototypeOf(target) || + target.tagName && "VIDEO" === target.tagName.toUpperCase() || + target.tagName && "AUDIO" === target.tagName.toUpperCase()); + }, + cancelable: false + }, //DOM2, DOM3, ProgressEvent + focus: {bubbles: false, cancelable: false}, //DOM2, DOM3 + focusin: {bubbles: true, cancelable: false}, //DOM3 + focusout: {bubbles: true, cancelable: false}, //DOM3 + input: {bubbles: true, cancelable: false}, // INPUT + keydown: {bubbles: true, cancelable: false}, //DOM3 + keypress: {bubbles: true, cancelable: false}, //DOM3 + keyup: {bubbles: true, cancelable: false}, //DOM3 + load: {bubbles: false, cancelable: false}, //ProgressEvent, DOM2, DOM3 + loadend: {bubbles: false, cancelable: false}, //ProgressEvent + loadstart: {bubbles: false, cancelable: false}, //ProgressEvent + message: {bubbles: false, cancelable: false}, //WEBSOCKETS + mousedown: {bubbles: true, cancelable: true}, //DOM3 + mouseenter: {bubbles: false, cancelable: false}, //DOM3 + mouseleave: {bubbles: false, cancelable: false}, //DOM3 + mousemove: {bubbles: true, cancelable: true}, //DOM3 + mouseout: {bubbles: true, cancelable: true}, //DOM3 + mouseover: {bubbles: true, cancelable: true}, //DOM3 + mouseup: {bubbles: true, cancelable: true}, //DOM3 + mousewheel: {bubbles: true}, + orientationchange: {bubbles: false}, + paste: {bubbles: true, cancelable: true}, //ClipboardEvent + progress: {bubbles: false, cancelable: false}, //ProgressEvent + reset: {bubbles: true, cancelable: false}, //DOM2 + resize: {bubbles: false, cancelable: false}, //DOM2 bubbles, DOM3 + + scroll: { + bubbles: function (target) { + return /*isDocument*/!!target.defaultView; + }, + cancelable: false + }, //DOM2, DOM3 When dispatched on Document element must bubble to defaultView object - _windowsAwaitingFinalRegistration: { - value: {}, - enumerable: false - }, + select: {bubbles: true, cancelable: false}, //DOM2, DOM3 - // Initialization -/** - @function - @param {Window} aWindow - @returns this.registerWindow(aWindow) - */ - initWithWindow: { - enumerable: false, - value: function(aWindow) { - if (!!this._registeredWindows) { - throw "EventManager has already been initialized"; + submit: {bubbles: true, cancelable: true}, //DOM2 + touchcancel: {bubbles: true, cancelable: false}, //TouchEvent + touchend: {bubbles: true, cancelable: true}, //TouchEvent + touchmove: {bubbles: true, cancelable: true}, //TouchEvent + touchstart: {bubbles: true, cancelable: true}, //TouchEvent + unload: {bubbles: false, cancelable: false}, //DOM2, DOM3 + wheel: {bubbles: true, cancelable: true} //DOM3 } + }, - // TODO do we also complain if no window is given? Technically - // we don't need one until we start listening for events - this.registerWindow(aWindow); - return this; - } - }, -/** - @function - @param {Window} aWindow - */ - registerWindow: { - enumerable: false, - value: function(aWindow) { - - if (aWindow.defaultEventManager && aWindow.defaultEventManager !== this) { - throw "EventManager cannot register a window already registered to another EventManager"; - } + /** + * @private + */ + _DOMPasteboardElement: { + value: null, + enumerable: false + }, - if (this._registeredWindows && this._registeredWindows.indexOf(aWindow) >= 0) { - throw "EventManager cannot register a window more than once"; - } + /** + * @property {string} value + * @private + */ + _delegate: { + value: null, + enumerable: false + }, - if (!this._registeredWindows) { - this._registeredWindows = []; + /** + * @returns {string} + * @param {string} + * @default null + */ + delegate: { + enumerable: false, + get: function () { + return this._delegate; + }, + set: function (delegate) { + this._delegate = delegate; } + }, - if (!aWindow.uuid || aWindow.uuid.length === 0) { - aWindow.uuid = UUID.generate(); - } + /** + * @property {Application} value + * @private + */ + _application: { + value: null, + enumerable: false + }, - if (this._windowsAwaitingFinalRegistration[aWindow.uuid] === aWindow) { - return; + /** + * The application object associated with the event manager. + * @returns {Application} + * @param {Application} + * @default null + * + * @todo if this changes...we probably need to unregister all the windows + * we know about and frankly probably the components too + */ + application: { + enumerable: false, + get: function () { + return this._application; + }, + set: function (application) { + this._application = application; } + }, - // Setup the window as much as possible now without knowing whether - // the DOM is ready or not - - // Keep a reference to the original listener functions - - // Note I think it may be implementation specific how these are implemented - // so I'd rather preserve any native optimizations a browser has for - // adding listeners to the document versus and element etc. - aWindow.Element.prototype.nativeAddEventListener = aWindow.Element.prototype.addEventListener; - Object.defineProperty(aWindow, "nativeAddEventListener", { - configurable: true, - value: aWindow.addEventListener - }); - Object.getPrototypeOf(aWindow.document).nativeAddEventListener = aWindow.document.addEventListener; - aWindow.XMLHttpRequest.prototype.nativeAddEventListener = aWindow.XMLHttpRequest.prototype.addEventListener; - if (aWindow.Worker) { - aWindow.Worker.prototype.nativeAddEventListener = aWindow.Worker.prototype.addEventListener; - } - if (aWindow.MediaController) { - aWindow.MediaController.prototype.nativeAddEventListener = aWindow.MediaController.prototype.addEventListener; - } + // Dictionary keyed by event types with the collection of handlers per event type + // This dictates why the event manager observes events of a particular type + + /** + * All windows this event Manager may be listening to + * + * @property {Array} value + * @private + */ + _registeredWindows: { + value: null, + enumerable: false + }, - aWindow.Element.prototype.nativeRemoveEventListener = aWindow.Element.prototype.removeEventListener; - Object.defineProperty(aWindow, "nativeRemoveEventListener", { - configurable: true, - value: aWindow.removeEventListener - }); - Object.getPrototypeOf(aWindow.document).nativeRemoveEventListener = aWindow.document.removeEventListener; - aWindow.XMLHttpRequest.prototype.nativeRemoveEventListener = aWindow.XMLHttpRequest.prototype.removeEventListener; - if (aWindow.Worker) { - aWindow.Worker.prototype.nativeRemoveEventListener = aWindow.Worker.prototype.removeEventListener; - } - if (aWindow.MediaController) { - aWindow.MediaController.prototype.nativeRemoveEventListener = aWindow.MediaController.prototype.removeEventListener; + /** + * @property {Object} value + * @private + */ + _windowsAwaitingFinalRegistration: { + value: {}, + enumerable: false + }, + + // Initialization + + /** + * @function + * @param {external:window} aWindow + * @returns {EventManager} + */ + initWithWindow: { + enumerable: false, + value: function (aWindow) { + if (!!this._registeredWindows) { + throw "EventManager has already been initialized"; + } + + // TODO do we also complain if no window is given? + // Technically we don't need one until we start listening for events + this.registerWindow(aWindow); + return this; } + }, + /** + * @function + * @param {external:window} aWindow + */ + registerWindow: { + enumerable: false, + value: function (aWindow) { + + if (aWindow.defaultEventManager && aWindow.defaultEventManager !== this) { + throw "EventManager cannot register a window already registered to another EventManager"; + } + + if (this._registeredWindows && this._registeredWindows.indexOf(aWindow) >= 0) { + throw "EventManager cannot register a window more than once"; + } + + if (!this._registeredWindows) { + this._registeredWindows = []; + } + + if (!aWindow.uuid || aWindow.uuid.length === 0) { + aWindow.uuid = UUID.generate(); + } + + if (this._windowsAwaitingFinalRegistration[aWindow.uuid] === aWindow) { + return; + } - // Redefine listener functions + // Setup the window as much as possible now without knowing whether + // the DOM is ready or not - Object.defineProperty(aWindow, "addEventListener", { - configurable: true, - value: (aWindow.XMLHttpRequest.prototype.addEventListener = + // Keep a reference to the original listener functions + + // Note I think it may be implementation specific how these are implemented + // so I'd rather preserve any native optimizations a browser has for + // adding listeners to the document versus and element etc. + aWindow.Element.prototype.nativeAddEventListener = aWindow.Element.prototype.addEventListener; + Object.defineProperty(aWindow, "nativeAddEventListener", { + configurable: true, + value: aWindow.addEventListener + }); + Object.getPrototypeOf(aWindow.document).nativeAddEventListener = aWindow.document.addEventListener; + aWindow.XMLHttpRequest.prototype.nativeAddEventListener = aWindow.XMLHttpRequest.prototype.addEventListener; + if (aWindow.Worker) { + aWindow.Worker.prototype.nativeAddEventListener = aWindow.Worker.prototype.addEventListener; + } + if (aWindow.MediaController) { + aWindow.MediaController.prototype.nativeAddEventListener = aWindow.MediaController.prototype.addEventListener; + } + + aWindow.Element.prototype.nativeRemoveEventListener = aWindow.Element.prototype.removeEventListener; + Object.defineProperty(aWindow, "nativeRemoveEventListener", { + configurable: true, + value: aWindow.removeEventListener + }); + Object.getPrototypeOf(aWindow.document).nativeRemoveEventListener = aWindow.document.removeEventListener; + aWindow.XMLHttpRequest.prototype.nativeRemoveEventListener = aWindow.XMLHttpRequest.prototype.removeEventListener; + if (aWindow.Worker) { + aWindow.Worker.prototype.nativeRemoveEventListener = aWindow.Worker.prototype.removeEventListener; + } + if (aWindow.MediaController) { + aWindow.MediaController.prototype.nativeRemoveEventListener = aWindow.MediaController.prototype.removeEventListener; + } + + // Redefine listener functions + + Object.defineProperty(aWindow, "addEventListener", { + configurable: true, + value: (aWindow.XMLHttpRequest.prototype.addEventListener = aWindow.Element.prototype.addEventListener = Object.getPrototypeOf(aWindow.document).addEventListener = - function(eventType, listener, useCapture) { + function (eventType, listener, useCapture) { return aWindow.defaultEventManager.registerEventListener(this, eventType, listener, !!useCapture); }) - }); + }); - if (aWindow.Worker) { - aWindow.Worker.prototype.addEventListener = aWindow.addEventListener; - } - if (aWindow.MediaController) { - aWindow.MediaController.prototype.addEventListener = aWindow.addEventListener; - } + if (aWindow.Worker) { + aWindow.Worker.prototype.addEventListener = aWindow.addEventListener; + } + if (aWindow.MediaController) { + aWindow.MediaController.prototype.addEventListener = aWindow.addEventListener; + } - Object.defineProperty(aWindow, "removeEventListener", { - configurable: true, - value: (aWindow.XMLHttpRequest.prototype.removeEventListener = + Object.defineProperty(aWindow, "removeEventListener", { + configurable: true, + value: (aWindow.XMLHttpRequest.prototype.removeEventListener = aWindow.Element.prototype.removeEventListener = Object.getPrototypeOf(aWindow.document).removeEventListener = - function(eventType, listener, useCapture) { + function (eventType, listener, useCapture) { return aWindow.defaultEventManager.unregisterEventListener(this, eventType, listener, !!useCapture); }) - }); + }); - if (aWindow.Worker) { - aWindow.Worker.prototype.removeEventListener = aWindow.removeEventListener; - } - if (aWindow.MediaController) { - aWindow.MediaController.prototype.removeEventListener = aWindow.removeEventListener; - } + if (aWindow.Worker) { + aWindow.Worker.prototype.removeEventListener = aWindow.removeEventListener; + } + if (aWindow.MediaController) { + aWindow.MediaController.prototype.removeEventListener = aWindow.removeEventListener; + } - // In some browsers (Firefox) each element has their own addEventLister/removeEventListener - // Methodology to find all elements found in Chainvas (now mostly gone from this) - if(aWindow.HTMLDivElement.prototype.addEventListener !== aWindow.Element.prototype.nativeAddEventListener) { - if (aWindow.HTMLElement && - 'addEventListener' in aWindow.HTMLElement.prototype - ) { - var candidates = Object.getOwnPropertyNames(aWindow), - candidate, candidatePrototype, - i = 0, candidatesLength = candidates.length; - for (i; i < candidatesLength; i++) { - candidate = candidates[i]; - if(candidate.match(/^HTML\w*Element$/) && typeof candidate === "function") { - candidatePrototype = candidate.prototype; - candidatePrototype.nativeAddEventListener = candidatePrototype.addEventListener; - candidatePrototype.addEventListener = aWindow.Element.prototype.addEventListener; - candidatePrototype.nativeRemoveEventListener = candidatePrototype.removeEventListener; - candidatePrototype.removeEventListener = aWindow.Element.prototype.removeEventListener; + // In some browsers (Firefox) each element has their own addEventLister/removeEventListener + // Methodology to find all elements found in Chainvas (now mostly gone from this) + if (aWindow.HTMLDivElement.prototype.addEventListener !== aWindow.Element.prototype.nativeAddEventListener) { + if (aWindow.HTMLElement && + 'addEventListener' in aWindow.HTMLElement.prototype + ) { + var candidates = Object.getOwnPropertyNames(aWindow), + candidate, candidatePrototype, + i = 0, candidatesLength = candidates.length; + for (i; i < candidatesLength; i++) { + candidate = candidates[i]; + if (candidate.match(/^HTML\w*Element$/) && typeof candidate === "function") { + candidatePrototype = candidate.prototype; + candidatePrototype.nativeAddEventListener = candidatePrototype.addEventListener; + candidatePrototype.addEventListener = aWindow.Element.prototype.addEventListener; + candidatePrototype.nativeRemoveEventListener = candidatePrototype.removeEventListener; + candidatePrototype.removeEventListener = aWindow.Element.prototype.removeEventListener; + } } } } - } - /** - HTML element event handler UUID - @member external:Element#eventHandlerUUID - */ - Montage.defineProperty(aWindow.Element.prototype, "eventHandlerUUID", /** @lends defineProperty */ { - value: undefined, - enumerable: false - }); - - /** - The component instance directly associated with the specified element. - @member external:Element#component - */ - Montage.defineProperty(aWindow.Element.prototype, "component", { - get: function() { - return defaultEventManager._elementEventHandlerByUUID[this.eventHandlerUUID]; - }, - enumerable: false - }); + /** + * HTML element event handler UUID + * + * @member external:Element#eventHandlerUUID + */ + Montage.defineProperty(aWindow.Element.prototype, "eventHandlerUUID", { + value: undefined, + enumerable: false + }); - defaultEventManager = aWindow.defaultEventManager = exports.defaultEventManager = this; - this._registeredWindows.push(aWindow); + /** + * The component instance directly associated with the specified element. + * + * @member external:Element#component + */ + Montage.defineProperty(aWindow.Element.prototype, "component", { + get: function () { + return defaultEventManager._elementEventHandlerByUUID[this.eventHandlerUUID]; + }, + enumerable: false + }); - this._windowsAwaitingFinalRegistration[aWindow.uuid] = aWindow; + /** + * @namespace EventManager + * @instance + * @global + */ + defaultEventManager = aWindow.defaultEventManager = exports.defaultEventManager = this; + this._registeredWindows.push(aWindow); - // Some registration demands the window's dom be accessible - // only finalize registration when that's true - if (/loaded|complete|interactive/.test(aWindow.document.readyState)) { - this._finalizeWindowRegistration(aWindow); - } else { - aWindow.document.addEventListener("DOMContentLoaded", this, true); - } - } - }, + this._windowsAwaitingFinalRegistration[aWindow.uuid] = aWindow; + // Some registration demands the window's dom be accessible + // only finalize registration when that's true + if (/loaded|complete|interactive/.test(aWindow.document.readyState)) { + this._finalizeWindowRegistration(aWindow); + } else { + aWindow.document.addEventListener("DOMContentLoaded", this, true); + } + } + }, - _finalizeWindowRegistration: { - enumerable: false, - value: function(aWindow) { + _finalizeWindowRegistration: { + enumerable: false, + value: function (aWindow) { - if (this._windowsAwaitingFinalRegistration[aWindow.uuid] !== aWindow) { - throw "EventManager wasn't expecting to register this window"; - } + if (this._windowsAwaitingFinalRegistration[aWindow.uuid] !== aWindow) { + throw "EventManager wasn't expecting to register this window"; + } - delete this._windowsAwaitingFinalRegistration[aWindow.uuid]; + delete this._windowsAwaitingFinalRegistration[aWindow.uuid]; - this._listenToWindow(aWindow); - // TODO uninstall DOMContentLoaded listener if all windows finalized - } - }, -/** - @function - @param {Window} aWindow - */ - unregisterWindow: { - enumerable: false, - value: function(aWindow) { - if (this._registeredWindows.indexOf(aWindow) < 0) { - throw "EventManager cannot unregister an unregistered window"; + this._listenToWindow(aWindow); + // TODO uninstall DOMContentLoaded listener if all windows finalized } + }, + /** + * @function + * @param {external:window} aWindow + */ + unregisterWindow: { + enumerable: false, + value: function (aWindow) { + if (this._registeredWindows.indexOf(aWindow) < 0) { + throw "EventManager cannot unregister an unregistered window"; + } - this._registeredWindows = this._registeredWindows.filter(function (element) { - return (aWindow !== element); - }); + this._registeredWindows = this._registeredWindows.filter(function (element) { + return (aWindow !== element); + }); - delete aWindow.defaultEventManager; + delete aWindow.defaultEventManager; - // Restore existing listener functions + // Restore existing listener functions - aWindow.Element.prototype.addEventListener = aWindow.Element.prototype.nativeAddEventListener; - Object.defineProperty(aWindow, "addEventListener", { - configurable: true, - value: aWindow.nativeAddEventListener - }); - Object.getPrototypeOf(aWindow.document).addEventListener = aWindow.document.nativeAddEventListener; - aWindow.XMLHttpRequest.prototype.addEventListener = aWindow.XMLHttpRequest.prototype.nativeAddEventListener; - if (aWindow.Worker) { - aWindow.Worker.prototype.addEventListener = aWindow.Worker.prototype.nativeAddEventListener; - } + aWindow.Element.prototype.addEventListener = aWindow.Element.prototype.nativeAddEventListener; + Object.defineProperty(aWindow, "addEventListener", { + configurable: true, + value: aWindow.nativeAddEventListener + }); + Object.getPrototypeOf(aWindow.document).addEventListener = aWindow.document.nativeAddEventListener; + aWindow.XMLHttpRequest.prototype.addEventListener = aWindow.XMLHttpRequest.prototype.nativeAddEventListener; + if (aWindow.Worker) { + aWindow.Worker.prototype.addEventListener = aWindow.Worker.prototype.nativeAddEventListener; + } - aWindow.Element.prototype.removeEventListener = aWindow.Element.prototype.nativeRemoveEventListener; - Object.defineProperty(aWindow, "removeEventListener", { - configurable: true, - value: aWindow.nativeRemoveEventListener - }); - Object.getPrototypeOf(aWindow.document).removeEventListener = aWindow.document.nativeRemoveEventListener; - aWindow.XMLHttpRequest.prototype.removeEventListener = aWindow.XMLHttpRequest.prototype.nativeRemoveEventListener; - if (aWindow.Worker) { - aWindow.Worker.prototype.removeEventListener = aWindow.Worker.prototype.nativeRemoveEventListener; - } + aWindow.Element.prototype.removeEventListener = aWindow.Element.prototype.nativeRemoveEventListener; + Object.defineProperty(aWindow, "removeEventListener", { + configurable: true, + value: aWindow.nativeRemoveEventListener + }); + Object.getPrototypeOf(aWindow.document).removeEventListener = aWindow.document.nativeRemoveEventListener; + aWindow.XMLHttpRequest.prototype.removeEventListener = aWindow.XMLHttpRequest.prototype.nativeRemoveEventListener; + if (aWindow.Worker) { + aWindow.Worker.prototype.removeEventListener = aWindow.Worker.prototype.nativeRemoveEventListener; + } - // In some browsers (Firefox) each element has their own addEventLister/removeEventListener - // Methodology to find all elements found in Chainvas - if(aWindow.HTMLDivElement.prototype.nativeAddEventListener !== aWindow.Element.prototype.addEventListener) { - if (aWindow.HTMLElement && - 'addEventListener' in aWindow.HTMLElement.prototype && - aWindow.Components && - aWindow.Components.interfaces - ) { - var candidate, candidatePrototype; - - for(candidate in Components.interfaces) { - if(candidate.match(/^nsIDOMHTML\w*Element$/)) { - candidate = candidate.replace(/^nsIDOM/, ''); - if(candidate = window[candidate]) { - candidatePrototype = candidate.prototype; - candidatePrototype.addEventListener = candidatePrototype.nativeAddEventListener; - delete candidatePrototype.nativeAddEventListener; - candidatePrototype.removeEventListener = candidatePrototype.nativeRemoveEventListener; - delete candidatePrototype.nativeRemoveEventListener; + // In some browsers (Firefox) each element has their own addEventLister/removeEventListener + // Methodology to find all elements found in Chainvas + if (aWindow.HTMLDivElement.prototype.nativeAddEventListener !== aWindow.Element.prototype.addEventListener) { + if (aWindow.HTMLElement && + 'addEventListener' in aWindow.HTMLElement.prototype && + aWindow.Components && + aWindow.Components.interfaces + ) { + var candidate, candidatePrototype; + + for (candidate in Components.interfaces) { + if (candidate.match(/^nsIDOMHTML\w*Element$/)) { + candidate = candidate.replace(/^nsIDOM/, ''); + if (candidate = window[candidate]) { + candidatePrototype = candidate.prototype; + candidatePrototype.addEventListener = candidatePrototype.nativeAddEventListener; + delete candidatePrototype.nativeAddEventListener; + candidatePrototype.removeEventListener = candidatePrototype.nativeRemoveEventListener; + delete candidatePrototype.nativeRemoveEventListener; + } } } } } - } - // Delete our references + // Delete our references - delete aWindow.Element.prototype.nativeAddEventListener; - delete aWindow.nativeAddEventListener; + delete aWindow.Element.prototype.nativeAddEventListener; + delete aWindow.nativeAddEventListener; - delete Object.getPrototypeOf(aWindow.document).nativeAddEventListener; - delete aWindow.XMLHttpRequest.prototype.nativeAddEventListener; - if (aWindow.Worker) { - delete aWindow.Worker.prototype.nativeAddEventListener; - } + delete Object.getPrototypeOf(aWindow.document).nativeAddEventListener; + delete aWindow.XMLHttpRequest.prototype.nativeAddEventListener; + if (aWindow.Worker) { + delete aWindow.Worker.prototype.nativeAddEventListener; + } - delete aWindow.Element.prototype.nativeRemoveEventListener; - delete aWindow.nativeRemoveEventListener; + delete aWindow.Element.prototype.nativeRemoveEventListener; + delete aWindow.nativeRemoveEventListener; - delete Object.getPrototypeOf(aWindow.document).nativeRemoveEventListener; - delete aWindow.XMLHttpRequest.prototype.nativeRemoveEventListener; - if (aWindow.Worker) { - delete aWindow.Worker.prototype.nativeRemoveEventListener; - } + delete Object.getPrototypeOf(aWindow.document).nativeRemoveEventListener; + delete aWindow.XMLHttpRequest.prototype.nativeRemoveEventListener; + if (aWindow.Worker) { + delete aWindow.Worker.prototype.nativeRemoveEventListener; + } - delete aWindow.Element.prototype.eventHandlerUUID; - delete aWindow.Element.prototype.component; + delete aWindow.Element.prototype.eventHandlerUUID; + delete aWindow.Element.prototype.component; - this._stopListeningToWindow(aWindow); - } - }, -/** - @function - */ - unregisterWindows: { - enumerable: false, - value: function() { - this._registeredWindows.forEach(this.unregisterWindow); - } - }, - - // Event Handler Registration - - // e.g. - // mousedown: { - // target.uuid: { - // target: target, - // listeners: { - // Object1.uuid: {listener: Object1, capture: true, bubble: true}, - // Object2.uuid: {listener: Object2, capture: true, bubble: false}, - // Object3.uuid: {listener: Object3, capture: false, bubble: true}}}} - - - /** - Registered event listeners. - @type {Listeners} - @default {} - */ - registeredEventListeners: { - enumerable: false, - value: {} - }, - - /** - Returns a dictionary of all listeners registered for the specified eventType, regardless of the target being observed. - @function - @param {Event} eventType The event type. - @returns null || listeners - */ - registeredEventListenersForEventType_: { - value: function(eventType) { - var eventTypeEntry = this.registeredEventListeners[eventType], - targetUid, - listenerEntries, - listenerUid, - listeners; - - if (!eventTypeEntry) { - return null; + this._stopListeningToWindow(aWindow); } + }, - listeners = {}; + /** + * @function + */ + unregisterWindows: { + enumerable: false, + value: function () { + this._registeredWindows.forEach(this.unregisterWindow); + } + }, - for (targetUid in eventTypeEntry) { - listenerEntries = eventTypeEntry[targetUid].listeners; + // Event Handler Registration + + /** + * Registered event listeners. + * + * @example + * ```json + * mousedown: { + * target.uuid: { + * target: target, + * listeners: { + * bject1.uuid: {listener: Object1, capture: true, bubble: true}, + * Object2.uuid: {listener: Object2, capture: true, bubble: false}, + * Object3.uuid: {listener: Object3, capture: false, bubble: true}}}} + * ``` + * + * @property {Listeners} value + * @default {} + */ + registeredEventListeners: { + enumerable: false, + value: {} + }, - for (listenerUid in listenerEntries) { - listeners[listenerUid] = listenerEntries[listenerUid]; + /** + * Returns a dictionary of all listeners registered for the specified eventType, + * regardless of the target being observed. + * + * @function + * @param {Event} eventType The event type. + * @returns null || listeners + */ + registeredEventListenersForEventType_: { + value: function (eventType) { + var eventTypeEntry = this.registeredEventListeners[eventType], + targetUid, + listenerEntries, + listenerUid, + listeners; + + if (!eventTypeEntry) { + return null; } - } - return listeners; - } - }, + listeners = {}; - /** - Returns the dictionary of all listeners registered for the specified eventType, on the specified target. - @function - @param {Event} eventType The event type. - @param {Event} target The event target. - @returns targetRegistration ? targetRegistration.listeners : null - */ - registeredEventListenersForEventType_onTarget_: { - enumerable: false, - value: function(eventType, target, application) { - - var eventRegistration, - targetRegistration; - - if (target === application) { - eventRegistration = application.eventManager.registeredEventListeners[eventType]; - } else { - eventRegistration = this.registeredEventListeners[eventType]; - } + for (targetUid in eventTypeEntry) { + listenerEntries = eventTypeEntry[targetUid].listeners; - if (!eventRegistration) { - return null; - } else { - targetRegistration = eventRegistration[target.uuid]; + for (listenerUid in listenerEntries) { + listeners[listenerUid] = listenerEntries[listenerUid]; + } + } - return targetRegistration ? targetRegistration.listeners : null; + return listeners; } - } - }, + }, + /** + * Returns the dictionary of all listeners registered for + * the specified eventType on the specified target. + * + * @function + * @param {Event} eventType - The event type. + * @param {Event} target - The event target. + * @returns {?ActionEventListener} + */ + registeredEventListenersForEventType_onTarget_: { + enumerable: false, + value: function (eventType, target, application) { + + var eventRegistration, + targetRegistration; + + if (target === application) { + eventRegistration = application.eventManager.registeredEventListeners[eventType]; + } else { + eventRegistration = this.registeredEventListeners[eventType]; + } - /** - Returns the dictionary of all listeners registered on the specified target, keyed by eventType. - @function - @param {Event} target The event target. - @returns observedEventListeners - */ - registeredEventListenersOnTarget_: { - value: function(target) { - - var eventType, - eventRegistration, - observedEventListeners = []; - - for (eventType in this.registeredEventListeners) { - eventRegistration = this.registeredEventListeners[eventType]; - if (target.uuid in eventRegistration) { - observedEventListeners.push(eventRegistration); + if (!eventRegistration) { + return null; + } else { + targetRegistration = eventRegistration[target.uuid]; + + return targetRegistration ? targetRegistration.listeners : null; } } + }, - return observedEventListeners; - } - }, - - // NOTE this adds the listener to the definitive collection of what - // targets are being observed for what eventTypes by whom and in what phases - // This collection maintained by the EventManager is used throughout the - // discovery and distribution steps of the event handling system - - /** - This adds the listener to the definitive collection of what targets are being observed for what eventTypes by whom and in what phases. This collection maintained by the EventManager is used throughout the discovery and distribution steps of the event handling system. - @function - @param {Event} target The event target. - @param {Event} eventType The event type. - @param {Event} listener The event listener. - @param {Event} useCapture The event capture. - @returns returnResult - */ - - registerEventListener: { - enumerable: false, - value: function registerEventListener(target, eventType, listener, useCapture) { - - // console.log("EventManager.registerEventListener", target, eventType, listener, useCapture) - - var eventTypeRegistration = this.registeredEventListeners[eventType], - targetRegistration, - listenerRegistration, - phase, - isNewTarget = false, - returnResult = false; - - if (typeof target.uuid === "undefined") { - throw new Error("EventManager cannot observe a target without a uuid: " + (target.outerHTML || target)); + /** + * Returns the dictionary of all listeners registered on + * the specified target, keyed by eventType. + * + * @function + * @param {Event} target The event target. + * @returns observedEventListeners + */ + registeredEventListenersOnTarget_: { + value: function (target) { + + var eventType, + eventRegistration, + observedEventListeners = []; + + for (eventType in this.registeredEventListeners) { + eventRegistration = this.registeredEventListeners[eventType]; + if (target.uuid in eventRegistration) { + observedEventListeners.push(eventRegistration); + } + } + + return observedEventListeners; } + }, - if (!eventTypeRegistration) { - // First time this eventType has been requested - eventTypeRegistration = this.registeredEventListeners[eventType] = {}; - (eventTypeRegistration[target.uuid] = _TargetRegistration.checkoutRegistration()).target = target; + /** + * This adds the listener to the definitive collection of + * what targets are being observed for what eventTypes by whom and in what phases. + * This collection maintained by the EventManager is used throughout + * the discovery and distribution steps of the event handling system. + * + * @function + * @param {Event} target - The event target. + * @param {Event} eventType - The event type. + * @param {Event} listener - The event listener. + * @param {Event} useCapture - The event capture. + * @returns returnResult + */ + registerEventListener: { + enumerable: false, + value: function registerEventListener(target, eventType, listener, useCapture) { + + // console.log("EventManager.registerEventListener", target, eventType, listener, useCapture) + + var eventTypeRegistration = this.registeredEventListeners[eventType], + targetRegistration, + listenerRegistration, + phase, + isNewTarget = false, + returnResult = false; + + if (typeof target.uuid === "undefined") { + throw new Error("EventManager cannot observe a target without a uuid: " + (target.outerHTML || target)); + } - eventTypeRegistration[target.uuid].listeners[listener.uuid] = _TargetListenerRegistration.checkoutRegistration().initWithListener(listener,useCapture,!useCapture); + if (!eventTypeRegistration) { + // First time this eventType has been requested + eventTypeRegistration = this.registeredEventListeners[eventType] = {}; + (eventTypeRegistration[target.uuid] = _TargetRegistration.checkoutRegistration()).target = target; - isNewTarget = true; - returnResult = true; - } else { + eventTypeRegistration[target.uuid].listeners[listener.uuid] = _TargetListenerRegistration.checkoutRegistration().initWithListener(listener, useCapture, !useCapture); - // Or, the event type was already observed; install this new listener (or at least any new parts) - if (!(targetRegistration = eventTypeRegistration[target.uuid])) { - (targetRegistration = (eventTypeRegistration[target.uuid] = _TargetRegistration.checkoutRegistration())).target = target; isNewTarget = true; - } - - listenerRegistration = targetRegistration.listeners[listener.uuid]; - phase = useCapture ? "capture" : "bubble"; - - if (listenerRegistration) { - listenerRegistration[phase] = true; returnResult = true; } else { - targetRegistration.listeners[listener.uuid] = _TargetListenerRegistration.checkoutRegistration().initWithListener(listener,useCapture,!useCapture) - returnResult = true; - } - - } - if (isNewTarget && typeof target.nativeAddEventListener === "function") { - this._observeTarget_forEventType_(target, eventType); - } + // Or, the event type was already observed; install this new listener (or at least any new parts) + if (!(targetRegistration = eventTypeRegistration[target.uuid])) { + (targetRegistration = (eventTypeRegistration[target.uuid] = _TargetRegistration.checkoutRegistration())).target = target; + isNewTarget = true; + } - // console.log("EventManager.registeredEventListeners", this.registeredEventListeners) + listenerRegistration = targetRegistration.listeners[listener.uuid]; + phase = useCapture ? "capture" : "bubble"; - return returnResult; - } - }, -/** - This unregisters the listener. - @function - @param {Event} target The event target. - @param {Event} eventType The event type. - @param {Event} listener The event listener. - @param {Event} useCapture The event capture. - */ - unregisterEventListener: { - enumerable: false, - value: function unregisterEventListener(target, eventType, listener, useCapture) { - - // console.log("EventManager.unregisterEventListener", target, eventType, listener, useCapture) - - var eventTypeRegistration = this.registeredEventListeners[eventType], - targetRegistration, - listenerRegistration, - phase, - listenerUUID, - installedListener; - - if (!eventTypeRegistration) { - // this eventType wasn't being observed at all - return; - } + if (listenerRegistration) { + listenerRegistration[phase] = true; + returnResult = true; + } else { + targetRegistration.listeners[listener.uuid] = _TargetListenerRegistration.checkoutRegistration().initWithListener(listener, useCapture, !useCapture) + returnResult = true; + } - // the event type was observed; see if the target was registered - targetRegistration = eventTypeRegistration[target.uuid]; - if (!targetRegistration) { - return; - } + } - // the target was being observed for this eventType; see if the specified listener was registered - listenerRegistration = targetRegistration.listeners[listener.uuid]; + if (isNewTarget && typeof target.nativeAddEventListener === "function") { + this._observeTarget_forEventType_(target, eventType); + } - if (!listenerRegistration) { + // console.log("EventManager.registeredEventListeners", this.registeredEventListeners) - for (listenerUUID in targetRegistration.listeners) { - installedListener = targetRegistration.listeners[listenerUUID].listener; + return returnResult; + } + }, + /** + * This unregisters the listener. + * + * @function + * @param {Event} target - The event target. + * @param {Event} eventType - The event type. + * @param {Event} listener - The event listener. + * @param {Event} useCapture - The event capture. + */ + unregisterEventListener: { + enumerable: false, + value: function unregisterEventListener (target, eventType, listener, useCapture) { + + // console.log("EventManager.unregisterEventListener", target, eventType, listener, useCapture) + + var eventTypeRegistration = this.registeredEventListeners[eventType], + targetRegistration, + listenerRegistration, + phase, + listenerUUID, + installedListener; + + if (!eventTypeRegistration) { + // this eventType wasn't being observed at all + return; + } - if (installedListener.originalListener && installedListener.originalListener.uuid === listener.uuid) { - listenerRegistration = targetRegistration.listeners[listenerUUID]; - listener = installedListener; - break; - } + // the event type was observed; see if the target was registered + targetRegistration = eventTypeRegistration[target.uuid]; + if (!targetRegistration) { + return; } + // the target was being observed for this eventType; see if the specified listener was registered + listenerRegistration = targetRegistration.listeners[listener.uuid]; if (!listenerRegistration) { - return; - } - } - phase = useCapture ? "capture" : "bubble"; - // console.log("unregistering listener from phase:", phase) + for (listenerUUID in targetRegistration.listeners) { + installedListener = targetRegistration.listeners[listenerUUID].listener; - listenerRegistration[phase] = false; + if (installedListener.originalListener && installedListener.originalListener.uuid === listener.uuid) { + listenerRegistration = targetRegistration.listeners[listenerUUID]; + listener = installedListener; + break; + } + } - // Done unregistering the listener for the specified phase - // Now see if we need to remove any registrations as a result of that + if (!listenerRegistration) { + return; + } + } - if (!listenerRegistration.bubble && !listenerRegistration.capture) { - // this listener isn't listening in any phase; remove it - _TargetListenerRegistration.checkinRegistration(targetRegistration.listeners[listener.uuid]); - delete targetRegistration.listeners[listener.uuid]; + phase = useCapture ? "capture" : "bubble"; + // console.log("unregistering listener from phase:", phase) + + listenerRegistration[phase] = false; + + // Done unregistering the listener for the specified phase + // Now see if we need to remove any registrations as a result of that + + if (!listenerRegistration.bubble && !listenerRegistration.capture) { + // this listener isn't listening in any phase; remove it + _TargetListenerRegistration.checkinRegistration(targetRegistration.listeners[listener.uuid]); + delete targetRegistration.listeners[listener.uuid]; + + if (Object.keys(targetRegistration.listeners).length === 0) { + // If no listeners for this target given this event type; remove this target + delete eventTypeRegistration[target.uuid]; + //Once we get here, listeners structure of targetRegistration is empty + _TargetRegistration.checkinRegistration(targetRegistration); + if (Object.keys(eventTypeRegistration).length === 0) { + // If no targets for this eventType; stop observing this event + delete this.registeredEventListeners[eventType]; + this._stopObservingTarget_forEventType_(target, eventType); + } - if (Object.keys(targetRegistration.listeners).length === 0) { - // If no listeners for this target given this event type; remove this target - delete eventTypeRegistration[target.uuid]; - //Once we get here, listeners structure of targetRegistration is empty - _TargetRegistration.checkinRegistration(targetRegistration); - if (Object.keys(eventTypeRegistration).length === 0) { - // If no targets for this eventType; stop observing this event - delete this.registeredEventListeners[eventType]; - this._stopObservingTarget_forEventType_(target, eventType); } } - + // console.log("EventManager.unregisteredEventListener", this.registeredEventListeners) } - // console.log("EventManager.unregisteredEventListener", this.registeredEventListeners) - } - }, + }, - /** - Determines the actual target to observe given a target and an eventType. This correctly decides whether to observe the element specified or to observe some other element to leverage event delegation. This should be consulted whenever starting or stopping the observation of a target for a given eventType. - @function - @param {Event} eventType - @param {Event} target - @returns null || target.screen ? target.document : target.ownerDocument - */ + /** + * Determines the actual target to observe given a target and an eventType. + * This correctly decides whether to observe the element specified or + * to observe some other element to leverage event delegation. + * This should be consulted whenever starting or stopping the observation of + * a target for a given eventType. + * + * @function + * @param {Event} eventType + * @param {Event} target + * @returns null || target.screen ? target.document : target.ownerDocument + */ + actualDOMTargetForEventTypeOnTarget: { + value: function (eventType, target) { + + if (!target.nativeAddEventListener) { + return null; + } else { - actualDOMTargetForEventTypeOnTarget: { - value: function(eventType, target) { + if (/*isDocument*/!!target.defaultView) { + return target; + } - if (!target.nativeAddEventListener) { - return null; - } else { + var entry = this.eventDefinitions[eventType], + bubbles; - if (/*isDocument*/!!target.defaultView) { - return target; - } + // For events we know we can safely delegate to handling at a higher level, listen on the document + // otherwise, be less surprising and listen on the specified target - var entry = this.eventDefinitions[eventType], - bubbles; + if (!entry) { + return target; + } - // For events we know we can safely delegate to handling at a higher level, listen on the document - // otherwise, be less surprising and listen on the specified target + // TODO allow eventTypes to describe a preferred delegation target window|document|none etc. + bubbles = (typeof entry.bubbles === FUNCTION_TYPE) ? entry.bubbles(target) : entry.bubbles; - if (!entry) { - return target; + if (bubbles) { + // TODO why on the document and not the window? + return /* isWindow*/target.screen ? target.document : target.ownerDocument; + } else { + return target; + } } - // TODO allow eventTypes to describe a preferred delegation target window|document|none etc. - bubbles = (typeof entry.bubbles === FUNCTION_TYPE) ? entry.bubbles(target) : entry.bubbles; - - if (bubbles) { - // TODO why on the document and not the window? - return /* isWindow*/target.screen ? target.document : target.ownerDocument; - } else { - return target; - } } + }, - } - }, + /** + * @private + */ + _observedTarget_byEventType_: {value: {}}, + // Individual Event Registration - _observedTarget_byEventType_: {value:{}}, + /** + * @private + */ + _observeTarget_forEventType_: { + enumerable: false, + value: function (target, eventType) { - // Individual Event Registration - _observeTarget_forEventType_: { - enumerable: false, - value: function(target, eventType) { + var listenerTarget; - var listenerTarget; + if ((listenerTarget = this.actualDOMTargetForEventTypeOnTarget(eventType, target)) && (!this._observedTarget_byEventType_[eventType] || !this._observedTarget_byEventType_[eventType][listenerTarget.uuid])) { + if (!this._observedTarget_byEventType_[eventType]) { + this._observedTarget_byEventType_[eventType] = {}; + } + this._observedTarget_byEventType_[eventType][listenerTarget.uuid] = this; - if ((listenerTarget = this.actualDOMTargetForEventTypeOnTarget(eventType, target)) && (!this._observedTarget_byEventType_[eventType] || !this._observedTarget_byEventType_[eventType][listenerTarget.uuid])) { - if (!this._observedTarget_byEventType_[eventType]) { - this._observedTarget_byEventType_[eventType] = {}; + listenerTarget.nativeAddEventListener(eventType, this, true); } - this._observedTarget_byEventType_[eventType][listenerTarget.uuid] = this; - - listenerTarget.nativeAddEventListener(eventType, this, true); + // console.log("started listening: ", eventType, listenerTarget) } - // console.log("started listening: ", eventType, listenerTarget) - } - }, + }, - _stopObservingTarget_forEventType_: { - enumerable: false, - value: function(target, eventType) { + /** + * @private + */ + _stopObservingTarget_forEventType_: { + enumerable: false, + value: function (target, eventType) { - var listenerTarget; + var listenerTarget; - listenerTarget = this.actualDOMTargetForEventTypeOnTarget(eventType, target); - if (listenerTarget) { - delete this._observedTarget_byEventType_[eventType][listenerTarget.uuid]; - listenerTarget.nativeRemoveEventListener(eventType, this, true); + listenerTarget = this.actualDOMTargetForEventTypeOnTarget(eventType, target); + if (listenerTarget) { + delete this._observedTarget_byEventType_[eventType][listenerTarget.uuid]; + listenerTarget.nativeRemoveEventListener(eventType, this, true); + } + // console.log("stopped listening: ", eventType, window.uuid) } - // console.log("stopped listening: ", eventType, window.uuid) - } - }, - - _activationHandler: { - enumerable: true, - value: null - }, - - // Toggle listening for EventManager - _listenToWindow: { - enumerable: false, - value: function(aWindow) { - - // We use our own function to handle activation events so it's not inadvertently - // removed as a listener when removing the last listener that may have also been observing - // the same eventType of an activation event - if (!this._activationHandler) { - var eventManager = this; - this._activationHandler = function(evt) { - var eventType = evt.type, - touchCount; - - // Prepare any components associated with elements that may receive this event - // They need to registered there listeners before the next step, which is to find the components that - // observing for this type of event - if ("focus" === eventType || "mousedown" === eventType || "touchstart" === eventType) { - if (evt.changedTouches) { - touchCount = evt.changedTouches.length; - for (var i = 0; i < touchCount; i++) { - eventManager._prepareComponentsForActivation(evt.changedTouches[i].target); + }, + + /** + * @private + */ + _activationHandler: { + enumerable: true, + value: null + }, + + // Toggle listening for EventManager + + /** + * @private + */ + _listenToWindow: { + enumerable: false, + value: function (aWindow) { + + // We use our own function to handle activation events so it's not inadvertently + // removed as a listener when removing the last listener that may have also been observing + // the same eventType of an activation event + if (!this._activationHandler) { + var eventManager = this; + this._activationHandler = function (evt) { + var eventType = evt.type, + touchCount; + + // Prepare any components associated with elements that may receive this event + // They need to registered there listeners before the next step, which is to find the components that + // observing for this type of event + if ("focus" === eventType || "mousedown" === eventType || "touchstart" === eventType) { + if (evt.changedTouches) { + touchCount = evt.changedTouches.length; + for (var i = 0; i < touchCount; i++) { + eventManager._prepareComponentsForActivation(evt.changedTouches[i].target); + } + } else { + eventManager._prepareComponentsForActivation(evt.target); } - } else { - eventManager._prepareComponentsForActivation(evt.target); } - } - }; - } + }; + } + + // The EventManager needs to handle "gateway/pointer/activation events" that we + // haven't let children listen for yet + // when the EM handles them eventually it will need to allow + // all components from the event target to the window to prepareForPointerEvents + // before finding event handlers that were registered for these events + if (aWindow.Touch) { + // TODO on iOS the touch doesn't capture up at the window, just the document; interesting + aWindow.document.nativeAddEventListener("touchstart", this._activationHandler, true); + } else { + aWindow.document.nativeAddEventListener("mousedown", this._activationHandler, true); + //TODO also should accommodate mouseenter/mouseover possibly + } + aWindow.document.nativeAddEventListener("focus", this._activationHandler, true); + + if (this.application) { + + var applicationLevelEvents = this.registeredEventListenersOnTarget_(this.application), + eventType; + + for (eventType in applicationLevelEvents) { + this._observeTarget_forEventType_(aWindow, eventType); + } + } - // The EventManager needs to handle "gateway/pointer/activation events" that we - // haven't let children listen for yet - // when the EM handles them eventually it will need to allow - // all components from the event target to the window to prepareForPointerEvents - // before finding event handlers that were registered for these events - if (aWindow.Touch) { - // TODO on iOS the touch doesn't capture up at the window, just the document; interesting - aWindow.document.nativeAddEventListener("touchstart", this._activationHandler, true); - } else { - aWindow.document.nativeAddEventListener("mousedown", this._activationHandler, true); - //TODO also should accommodate mouseenter/mouseover possibly } - aWindow.document.nativeAddEventListener("focus", this._activationHandler, true); + }, - if (this.application) { + /** + * @private + */ + _stopListeningToWindow: { + enumerable: false, + value: function (aWindow) { var applicationLevelEvents = this.registeredEventListenersOnTarget_(this.application), + windowLevelEvents = this.registeredEventListenersOnTarget_(aWindow), eventType; for (eventType in applicationLevelEvents) { - this._observeTarget_forEventType_(aWindow, eventType); + this._stopObservingTarget_forEventType_(aWindow, eventType); } - } - - } - }, - _stopListeningToWindow: { - enumerable: false, - value: function(aWindow) { + for (eventType in windowLevelEvents) { + this._stopObservingTarget_forEventType_(aWindow, eventType); + } + } + }, - var applicationLevelEvents = this.registeredEventListenersOnTarget_(this.application), - windowLevelEvents = this.registeredEventListenersOnTarget_(aWindow), - eventType; + /** + * @function + */ + reset: { + enumerable: false, + value: function () { + var eventType, + eventRegistration, + targetUUID, + targetRegistration; + + for (eventType in this.registeredEventListeners) { + eventRegistration = this.registeredEventListeners[eventType]; + for (targetUUID in eventRegistration.targets) { + targetRegistration = eventRegistration.targets[targetUUID]; + this._stopObservingTarget_forEventType_(targetRegistration.target, eventType); + } + } - for (eventType in applicationLevelEvents) { - this._stopObservingTarget_forEventType_(aWindow, eventType); - } + this.registeredEventListeners = {}; - for (eventType in windowLevelEvents) { - this._stopObservingTarget_forEventType_(aWindow, eventType); + // TODO for each component claiming a pointer, force them to surrender the pointer? + this._claimedPointers = {}; } - } - }, + }, - /** - * @function - */ - reset: { - enumerable: false, - value: function() { - var eventType, - eventRegistration, - targetUUID, - targetRegistration; - - for (eventType in this.registeredEventListeners) { - eventRegistration = this.registeredEventListeners[eventType]; - for (targetUUID in eventRegistration.targets) { - targetRegistration = eventRegistration.targets[targetUUID]; - this._stopObservingTarget_forEventType_(targetRegistration.target, eventType); - } + /** + * @function + */ + unload: { + enumerable: false, + value: function () { + this._stopListening(); } + }, - this.registeredEventListeners = {}; + /** + * @function + */ + methodNameForBubblePhaseOfEventType: { + enumerable: false, + value: (function (_methodNameForBubblePhaseByEventType_) { + return function (eventType, identifier) { + var eventTypeKey = identifier ? eventType + "+" + identifier : eventType; + return _methodNameForBubblePhaseByEventType_[eventTypeKey] || (_methodNameForBubblePhaseByEventType_[eventTypeKey] = ("handle" + (identifier ? identifier.toCapitalized() : "") + eventType.toCapitalized())); + }; + })({}) + }, - // TODO for each component claiming a pointer, force them to surrender the pointer? - this._claimedPointers = {}; - } - }, + /** + * @private + */ + _methodNameForCapturePhaseByEventType_: { + value: {} + }, - /** - * @method - */ - unload: { - enumerable: false, - value: function() { - this._stopListening(); - } - }, + methodNameForCapturePhaseOfEventType: { + enumerable: false, + value: (function (_methodNameForCapturePhaseByEventType_) { + return function (eventType, identifier) { + var eventTypeKey = identifier ? eventType + "+" + identifier : eventType; + return _methodNameForCapturePhaseByEventType_[eventTypeKey] || (_methodNameForCapturePhaseByEventType_[eventTypeKey] = "capture" + (identifier ? identifier.toCapitalized() : "") + eventType.toCapitalized()); + }; + })({}) + }, - /** - * @method - */ - methodNameForBubblePhaseOfEventType: { - enumerable: false, - value: (function(_methodNameForBubblePhaseByEventType_) { - return function(eventType, identifier) { - var eventTypeKey = identifier ? eventType + "+" + identifier : eventType; - return _methodNameForBubblePhaseByEventType_[eventTypeKey] || (_methodNameForBubblePhaseByEventType_[eventTypeKey] = ("handle" + (identifier ? identifier.toCapitalized() : "") + eventType.toCapitalized())); - }; - })({}) - }, - - _methodNameForCapturePhaseByEventType_: { - value:{} - }, - methodNameForCapturePhaseOfEventType: { - enumerable: false, - value: (function(_methodNameForCapturePhaseByEventType_) { - return function(eventType, identifier) { - var eventTypeKey = identifier ? eventType + "+" + identifier : eventType; - return _methodNameForCapturePhaseByEventType_[eventTypeKey] || (_methodNameForCapturePhaseByEventType_[eventTypeKey] = "capture" + (identifier ? identifier.toCapitalized() : "") + eventType.toCapitalized()); - }; - })({}) - }, - - // Claimed pointer information - _claimedPointers: { - enumerable: false, - distinct: true, - value: {} - }, + // Claimed pointer information - /** - * The component claiming the specified pointer component - * @function - * @param {string} pointer The pointer identifier in question - * @returns component - */ - componentClaimingPointer: { - value: function(pointer) { - return this._claimedPointers[pointer]; - } - }, + /** + * @private + */ + _claimedPointers: { + enumerable: false, + distinct: true, + value: {} + }, - /** - * Whether or not the specified pointer identifier is claimed by the - * specified component. - * @function - * @param {string} pointer The pointer identifier in question - * @param {string} component The component to interrogate regarding - * ownership of the specified pointer - * @returns boolean - */ - isPointerClaimedByComponent: { - value: function(pointer, component) { - - if (!component) { - throw "Must specify a valid component to see if it claims the specified pointer, '" + component + "' is not valid."; + /** + * The component claiming the specified pointer component + * + * @function + * @param {string} pointer The pointer identifier in question + * @returns component + */ + componentClaimingPointer: { + value: function (pointer) { + return this._claimedPointers[pointer]; } + }, - return this._claimedPointers[pointer] === component; - } - }, - - /** - * Claims that a pointer, referred to by the specified pointer identifier, - * is claimed by the specified component. This does not give the component - * exclusive use of the pointer per se, but does indicate that the - * component is acting in a manner where it expects to be the only one - * performing major actions in response to this pointer. Other components - * should respect the claimant's desire to react to this pointer in order - * to prevent an entire hierarchy of components from reacting to a pointer - * in potentially conflicting ways. - * - * If the pointer is currently claimed by another component that component - * is asked to surrender the pointer, which is may or may not agree to do. - * - * @function - * @param {string} pointer The pointer identifier to claim - * @param {string} component The component that is claiming the specified - * pointer. - * @returns boolean Whether or not the pointer was successfully claimed. - */ - claimPointer: { - value: function(pointer, component) { + /** + * Whether or not the specified pointer identifier is claimed by the + * specified component. + * + * @function + * @param {string} pointer The pointer identifier in question + * @param {string} component The component to interrogate regarding + * ownership of the specified pointer + * @returns {boolean} + */ + isPointerClaimedByComponent: { + value: function (pointer, component) { + + if (!component) { + throw "Must specify a valid component to see if it claims the specified pointer, '" + component + "' is not valid."; + } - // if null, undefined, false: complain - if (!pointer && pointer !== 0) { - throw "Must specify a valid pointer to claim, '" + pointer + "' is not valid."; + return this._claimedPointers[pointer] === component; } + }, - if (!component) { - throw "Must specify a valid component to claim a pointer, '" + component + "' is not valid."; - } + /** + * Claims that a pointer, referred to by the specified pointer identifier, + * is claimed by the specified component. This does not give the component + * exclusive use of the pointer per se, but does indicate that the + * component is acting in a manner where it expects to be the only one + * performing major actions in response to this pointer. Other components + * should respect the claimant's desire to react to this pointer in order + * to prevent an entire hierarchy of components from reacting to a pointer + * in potentially conflicting ways. + * + * If the pointer is currently claimed by another component that component + * is asked to surrender the pointer, which is may or may not agree to do. + * + * @function + * @param {string} pointer The pointer identifier to claim + * @param {string} component The component that is claiming the specified + * pointer. + * @returns {boolean} - Whether or not the pointer was successfully claimed. + */ + claimPointer: { + value: function (pointer, component) { + + // if null, undefined, false: complain + if (!pointer && pointer !== 0) { + throw "Must specify a valid pointer to claim, '" + pointer + "' is not valid."; + } - var claimant = this._claimedPointers[pointer]; + if (!component) { + throw "Must specify a valid component to claim a pointer, '" + component + "' is not valid."; + } - if (claimant === component) { - // Already claimed this pointer ourselves - return true; + var claimant = this._claimedPointers[pointer]; - } else if (!claimant) { - //Nobody has claimed it; go for it - this._claimedPointers[pointer] = component; - return true; + if (claimant === component) { + // Already claimed this pointer ourselves + return true; - } else { - //Somebody else has claimed it; ask them to surrender - if (claimant.surrenderPointer(pointer, component)) { + } else if (!claimant) { + //Nobody has claimed it; go for it this._claimedPointers[pointer] = component; return true; + } else { - return false; + //Somebody else has claimed it; ask them to surrender + if (claimant.surrenderPointer(pointer, component)) { + this._claimedPointers[pointer] = component; + return true; + } else { + return false; + } } - } - - } - }, - /** - * Forfeits the specified pointer identifier from the specified component. - * The specified component must be the current claimant. - * @function - * @param {string} pointer The pointer identifier in question - * @param {string} component The component that is trying to forfeit the - * specified pointer - */ - forfeitPointer: { - value: function(pointer, component) { - if (component === this._claimedPointers[pointer]) { - delete this._claimedPointers[pointer]; - } else { - throw "Not allowed to forfeit pointer '" + pointer + "' claimed by another component"; } + }, - } - }, - - /** - * Forfeits all pointers from the specified component. - * @function - * @param {Component} component - */ - forfeitAllPointers: { - value: function(component) { + /** + * Forfeits the specified pointer identifier from the specified component. + * The specified component must be the current claimant. + * + * @function + * @param {string} pointer The pointer identifier in question + * @param {string} component The component that is trying to forfeit the + * specified pointer + */ + forfeitPointer: { + value: function (pointer, component) { + if (component === this._claimedPointers[pointer]) { + delete this._claimedPointers[pointer]; + } else { + throw "Not allowed to forfeit pointer '" + pointer + "' claimed by another component"; + } - var pointerKey, - claimant; + } + }, - for (pointerKey in this._claimedPointers) { - claimant = this._claimedPointers[pointerKey]; - if (component === claimant) { - // NOTE basically doing the work ofr freePointerFromComponent - delete this._claimedPointers[pointerKey]; + /** + * Forfeits all pointers from the specified component. + * + * @function + * @param {Component} component + */ + forfeitAllPointers: { + value: function (component) { + + var pointerKey, + claimant; + + for (pointerKey in this._claimedPointers) { + claimant = this._claimedPointers[pointerKey]; + if (component === claimant) { + // NOTE basically doing the work ofr freePointerFromComponent + delete this._claimedPointers[pointerKey]; + } } + } + }, - } - }, + // Pointer Storage for calculating velocities - // Pointer Storage for calculating velocities - _isStoringPointerEvents: { - enumerable: false, - value: false - }, + /** + * @private + */ + _isStoringPointerEvents: { + enumerable: false, + value: false + }, - /** - * @type {Function} - * @default {boolean} false - */ - isStoringPointerEvents: { - enumerable: true, - get: function () { - return this._isStoringPointerEvents; - }, - set: function (value) { - if (value === true) { - if (!this._isStoringPointerEvents) { - this._isStoringPointerEvents = true; - if (window.Touch) { - Object.defineProperty(Touch.prototype, "velocity", { - get: function () { - return defaultEventManager.pointerMotion(this.identifier).velocity; - }, - set: function () { - } - }); + /** + * @returns {boolean} + * @default false + */ + isStoringPointerEvents: { + enumerable: true, + get: function () { + return this._isStoringPointerEvents; + }, + set: function (value) { + if (value === true) { + if (!this._isStoringPointerEvents) { + this._isStoringPointerEvents = true; + if (window.Touch) { + Object.defineProperty(Touch.prototype, "velocity", { + get: function () { + return defaultEventManager.pointerMotion(this.identifier).velocity; + }, + set: function () { + } + }); + } } + } else { + this._isStoringPointerEvents = false; + this._pointerStorage.memory = {}; + this._isMouseDragging = false; } - } else { - this._isStoringPointerEvents = false; - this._pointerStorage.memory = {}; - this._isMouseDragging = false; } - } - }, - - _isStoringMouseEventsWhileDraggingOnly: { - enumerable: false, - value: true - }, + }, - /** - * @type {Function} - * @default {boolean} true - */ - isStoringMouseEventsWhileDraggingOnly: { - enumerable: true, - get: function () { - return this._isStoringMouseEventsWhileDraggingOnly; + /** + * @private + */ + _isStoringMouseEventsWhileDraggingOnly: { + enumerable: false, + value: true }, - set: function (value) { - this._isStoringMouseEventsWhileDraggingOnly = (value === true) ? true : false; - } - }, - - _isMouseDragging: { - enumerable: false, - value: false - }, - - _pointerStorage: { - enumerable: false, - value: { - memory: {}, - add: function (identifier, data) { - if (!this.memory[identifier]) { - this.memory[identifier] = { - data: new Array(32), - size: 0, - pos: 0 - }; - } - this.memory[identifier].data[this.memory[identifier].pos] = data; - if (this.memory[identifier].size < this.memory[identifier].data.length) { - this.memory[identifier].size++; - } - this.memory[identifier].pos = (this.memory[identifier].pos + 1) % this.memory[identifier].data.length; - }, - remove: function (identifier) { - delete this.memory[identifier]; - }, - clear: function (identifier) { - if (this.memory[identifier]) { - this.memory[identifier].size = 0; - } - }, - getMemory: function (identifier) { - return this.memory[identifier]; - }, - isStored: function (identifier) { - return (this.memory[identifier] && (this.memory[identifier].size > 0)); + + /** + * @type {Function} + * @default {boolean} true + */ + isStoringMouseEventsWhileDraggingOnly: { + enumerable: true, + get: function () { + return this._isStoringMouseEventsWhileDraggingOnly; }, - storeEvent: function(event) { - var i; - switch (event.type) { - case "mousedown": - defaultEventManager._isMouseDragging = true; + set: function (value) { + this._isStoringMouseEventsWhileDraggingOnly = (value === true) ? true : false; + } + }, + + /** + * @private + */ + _isMouseDragging: { + enumerable: false, + value: false + }, + + /** + * @private + */ + _pointerStorage: { + enumerable: false, + value: { + memory: {}, + add: function (identifier, data) { + if (!this.memory[identifier]) { + this.memory[identifier] = { + data: new Array(32), + size: 0, + pos: 0 + }; + } + this.memory[identifier].data[this.memory[identifier].pos] = data; + if (this.memory[identifier].size < this.memory[identifier].data.length) { + this.memory[identifier].size++; + } + this.memory[identifier].pos = (this.memory[identifier].pos + 1) % this.memory[identifier].data.length; + }, + remove: function (identifier) { + delete this.memory[identifier]; + }, + clear: function (identifier) { + if (this.memory[identifier]) { + this.memory[identifier].size = 0; + } + }, + getMemory: function (identifier) { + return this.memory[identifier]; + }, + isStored: function (identifier) { + return (this.memory[identifier] && (this.memory[identifier].size > 0)); + }, + storeEvent: function (event) { + var i; + switch (event.type) { + case "mousedown": + defaultEventManager._isMouseDragging = true; // roll into mousemove. break omitted intentionally. - case "mousemove": - if (defaultEventManager._isStoringMouseEventsWhileDraggingOnly) { - if (defaultEventManager._isMouseDragging) { + case "mousemove": + if (defaultEventManager._isStoringMouseEventsWhileDraggingOnly) { + if (defaultEventManager._isMouseDragging) { + this.add("mouse", { + clientX: event.clientX, + clientY: event.clientY, + timeStamp: event.timeStamp + }); + Object.defineProperty(event, "velocity", { + get: function () { + return defaultEventManager.pointerMotion("mouse").velocity; + }, + set: function () { + } + }); + } + } else { this.add("mouse", { clientX: event.clientX, clientY: event.clientY, @@ -1652,877 +1757,889 @@ var EventManager = exports.EventManager = Montage.specialize(/** @lends EventMan }, set: function () { } - }); - } - } else { - this.add("mouse", { - clientX: event.clientX, - clientY: event.clientY, - timeStamp: event.timeStamp - }); - Object.defineProperty(event, "velocity", { - get: function () { - return defaultEventManager.pointerMotion("mouse").velocity; - }, - set: function () { - } - }); - } - break; - case "mouseup": - this.add("mouse", { - clientX: event.clientX, - clientY: event.clientY, - timeStamp: event.timeStamp - }); - Object.defineProperty(event, "velocity", { - get: function () { - return defaultEventManager.pointerMotion("mouse").velocity; - }, - set: function () { - } - }); - break; - case "touchstart": - case "touchmove": - for (i = 0; i < event.touches.length; i++) { - this.add(event.touches[i].identifier, { - clientX: event.touches[i].clientX, - clientY: event.touches[i].clientY, + }); + } + break; + case "mouseup": + this.add("mouse", { + clientX: event.clientX, + clientY: event.clientY, timeStamp: event.timeStamp }); - } - break; - case "touchend": - for (i = 0; i < event.changedTouches.length; i++) { - this.add(event.changedTouches[i].identifier, { - clientX: event.changedTouches[i].clientX, - clientY: event.changedTouches[i].clientY, - timeStamp: event.timeStamp + Object.defineProperty(event, "velocity", { + get: function () { + return defaultEventManager.pointerMotion("mouse").velocity; + }, + set: function () { + } }); - } - break; + break; + case "touchstart": + case "touchmove": + for (i = 0; i < event.touches.length; i++) { + this.add(event.touches[i].identifier, { + clientX: event.touches[i].clientX, + clientY: event.touches[i].clientY, + timeStamp: event.timeStamp + }); + } + break; + case "touchend": + for (i = 0; i < event.changedTouches.length; i++) { + this.add(event.changedTouches[i].identifier, { + clientX: event.changedTouches[i].clientX, + clientY: event.changedTouches[i].clientY, + timeStamp: event.timeStamp + }); + } + break; + } + }, + removeEvent: function (event) { + var i; + switch (event.type) { + case "mouseup": + defaultEventManager._isMouseDragging = false; + if (defaultEventManager._isStoringMouseEventsWhileDraggingOnly) { + this.clear("mouse"); + } + break; + case "touchend": + for (i = 0; i < event.changedTouches.length; i++) { + this.remove(event.changedTouches[i].identifier); + } + break; + } } - }, - removeEvent: function(event) { - var i; - switch (event.type) { - case "mouseup": - defaultEventManager._isMouseDragging = false; - if (defaultEventManager._isStoringMouseEventsWhileDraggingOnly) { - this.clear("mouse"); - } - break; - case "touchend": - for (i = 0; i < event.changedTouches.length; i++) { - this.remove(event.changedTouches[i].identifier); - } - break; + } + }, + + /** + @private + */ + _getPointerVelocityData: { + enumerable: false, + value: function (identifier) { + var i = 0, + memory, + memoryLength, + evt, + startTime, + iTime, + oldTime, oldX, oldY, squaredModule, + difTime = 0, + addData = true, + data = { + x: [], + y: [], + time: [] + }; + + memory = defaultEventManager._pointerStorage.getMemory(identifier); + memoryLength = memory.data.length; + evt = memory.data[((memory.pos - 1) + memoryLength) % memoryLength]; + startTime = iTime = oldTime = evt.timeStamp; + oldX = evt.clientX; + oldY = evt.clientY; + while (addData && (iTime > startTime - 350) && (i < memory.size)) { + evt = memory.data[((memory.pos - i - 1) + memoryLength) % memoryLength]; + iTime = evt.timeStamp; + squaredModule = oldX * oldX + oldY * oldY; + if ((squaredModule > 2) && ((oldTime - iTime) <= 50)) { + data.x.push(evt.clientX); + data.y.push(evt.clientY); + data.time.push(iTime); + oldTime = iTime; + oldX = evt.clientX; + oldY = evt.clientY; + i++; + } else { + addData = false; + } } + return data; } - } - }, -/** - @private -*/ - _getPointerVelocityData: { - enumerable: false, - value: function (identifier) { - var i = 0, - memory, - memoryLength, - evt, - startTime, - iTime, - oldTime, oldX, oldY, squaredModule, - difTime = 0, - addData = true, - data = { - x: [], - y: [], - time: [] - }; + }, - memory = defaultEventManager._pointerStorage.getMemory(identifier); - memoryLength = memory.data.length; - evt = memory.data[((memory.pos - 1) + memoryLength) % memoryLength]; - startTime = iTime = oldTime = evt.timeStamp; - oldX = evt.clientX; - oldY = evt.clientY; - while (addData && (iTime > startTime - 350) && (i < memory.size)) { - evt = memory.data[((memory.pos - i - 1) + memoryLength) % memoryLength]; - iTime = evt.timeStamp; - squaredModule = oldX * oldX + oldY * oldY; - if ((squaredModule > 2) && ((oldTime - iTime) <= 50)) { - data.x.push(evt.clientX); - data.y.push(evt.clientY); - data.time.push(iTime); - oldTime = iTime; - oldX = evt.clientX; - oldY = evt.clientY; - i++; - } else { - addData = false; + /** + @private + */ + _fitPointerCurve: { + enumerable: false, + value: function (bezier, data) { + var pos, a, b, c, d, epsilon = 0.0001, + dl = data.length, e, t, v, t2, t3, i, + f0, c0, d0, b0, a0, s0, e0, + f1, c1, d1, b1, a1, s1, e1, + f2, c2, d2, b2, a2, s2, e2, + f3, c3, d3, b3, a3, s3, e3; + do { + f0 = 0; + c0 = 0; + d0 = 0; + b0 = 0; + a0 = 0; + s0 = 0; + f1 = 0; + c1 = 0; + d1 = 0; + b1 = 0; + a1 = 0; + s1 = 0; + f2 = 0; + c2 = 0; + d2 = 0; + b2 = 0; + a2 = 0; + s2 = 0; + f3 = 0; + c3 = 0; + d3 = 0; + b3 = 0; + a3 = 0; + s3 = 0; + for (i = 0; i < dl; i++) { + e = data[i]; + t = e.t; + t2 = t * t; + t3 = t2 * t; + v = e.v; + e0 = epsilon * (6 * (t2 - t) - t3 + 2); + e1 = epsilon * 6 * (t3 - 2 * t2 + t); + e2 = epsilon * 6 * (t2 - t3); + e3 = epsilon * 2 * t3; + s0 += e0 * e0; + s1 += e1 * e1; + s2 += e2 * e2; + s3 += e3 * e3; + f0 += v * e0; + f1 += v * e1; + f2 += v * e2; + f3 += v * e3; + d0 -= e0; + d1 -= e1; + d2 -= e2; + d3 -= e3; + c0 -= e0 * t; + c1 -= e1 * t; + c2 -= e2 * t; + c3 -= e3 * t; + b0 -= e0 * t2; + b1 -= e1 * t2; + b2 -= e2 * t2; + b3 -= e3 * t2; + a0 -= e0 * t3; + a1 -= e1 * t3; + a2 -= e2 * t3; + a3 -= e3 * t3; + } + epsilon *= 2; + } while (s0 === 0 || s1 === 0 || s2 === 0 || s3 === 0); + t = epsilon / s0; + f0 *= t; + c0 *= t * 3; + d0 *= t; + b0 *= t * 3; + a0 *= t; + t = epsilon / s1; + f1 *= t; + c1 *= t * 3; + d1 *= t; + b1 *= t * 3; + a1 *= t; + t = epsilon / s2; + f2 *= t; + c2 *= t * 3; + d2 *= t; + b2 *= t * 3; + a2 *= t; + t = epsilon / s3; + f3 *= t; + c3 *= t * 3; + d3 *= t; + b3 *= t * 3; + a3 *= t; + s0 = bezier[0]; + s1 = bezier[1]; + s2 = bezier[2]; + s3 = bezier[3]; + a = (s1 - s2) * 3 + s3 - s0; + b = s0 + s2 - 2 * s1; + c = s1 - s0; + d = s0; + for (i = 0; i < 20; i++) { + t = f0 + d * d0 + c * c0 + b * b0 + a * a0; + s0 += t; + d += t; + a -= t; + b += t; + c -= t; + t = f1 + d * d1 + c * c1 + b * b1 + a * a1; + s1 += t; + a += t * 3; + b -= t + t; + c += t; + t = f2 + d * d2 + c * c2 + b * b2 + a * a2; + s2 += t; + a -= t * 3; + b += t; + t = f3 + d * d3 + c * c3 + b * b3 + a * a3; + s3 += t; + a += t; } + bezier[0] = s0; + bezier[1] = s1; + bezier[2] = s2; + bezier[3] = s3; } - return data; - } - }, -/** - @private -*/ - _fitPointerCurve: { - enumerable: false, - value: function (bezier, data) { - var pos, a, b, c, d, epsilon = 0.0001, - dl = data.length, e, t, v, t2, t3, i, - f0, c0, d0, b0, a0, s0, e0, - f1, c1, d1, b1, a1, s1, e1, - f2, c2, d2, b2, a2, s2, e2, - f3, c3, d3, b3, a3, s3, e3; - do { - f0 = 0; - c0 = 0; - d0 = 0; - b0 = 0; - a0 = 0; - s0 = 0; - f1 = 0; - c1 = 0; - d1 = 0; - b1 = 0; - a1 = 0; - s1 = 0; - f2 = 0; - c2 = 0; - d2 = 0; - b2 = 0; - a2 = 0; - s2 = 0; - f3 = 0; - c3 = 0; - d3 = 0; - b3 = 0; - a3 = 0; - s3 = 0; - for (i = 0; i < dl; i++) { - e = data[i]; - t = e.t; - t2 = t * t; - t3 = t2 * t; - v = e.v; - e0 = epsilon * (6 * (t2 - t) - t3 + 2); - e1 = epsilon * 6 * (t3 - 2 * t2 + t); - e2 = epsilon * 6 * (t2 - t3); - e3 = epsilon * 2 * t3; - s0 += e0 * e0; - s1 += e1 * e1; - s2 += e2 * e2; - s3 += e3 * e3; - f0 += v * e0; - f1 += v * e1; - f2 += v * e2; - f3 += v * e3; - d0 -= e0; - d1 -= e1; - d2 -= e2; - d3 -= e3; - c0 -= e0 * t; - c1 -= e1 * t; - c2 -= e2 * t; - c3 -= e3 * t; - b0 -= e0 * t2; - b1 -= e1 * t2; - b2 -= e2 * t2; - b3 -= e3 * t2; - a0 -= e0 * t3; - a1 -= e1 * t3; - a2 -= e2 * t3; - a3 -= e3 * t3; - } - epsilon *= 2; - } while (s0 === 0 || s1 === 0 || s2 === 0 || s3 === 0); - t = epsilon / s0; - f0 *= t; - c0 *= t * 3; - d0 *= t; - b0 *= t * 3; - a0 *= t; - t = epsilon / s1; - f1 *= t; - c1 *= t * 3; - d1 *= t; - b1 *= t * 3; - a1 *= t; - t = epsilon / s2; - f2 *= t; - c2 *= t * 3; - d2 *= t; - b2 *= t * 3; - a2 *= t; - t = epsilon / s3; - f3 *= t; - c3 *= t * 3; - d3 *= t; - b3 *= t * 3; - a3 *= t; - s0 = bezier[0]; - s1 = bezier[1]; - s2 = bezier[2]; - s3 = bezier[3]; - a = (s1 - s2) * 3 + s3 - s0; - b = s0 + s2 - 2 * s1; - c = s1 - s0; - d = s0; - for (i = 0; i < 20; i++) { - t = f0 + d * d0 + c * c0 + b * b0 + a * a0; - s0 += t; - d += t; - a -= t; - b += t; - c -= t; - t = f1 + d * d1 + c * c1 + b * b1 + a * a1; - s1 += t; - a += t * 3; - b -= t + t; - c += t; - t = f2 + d * d2 + c * c2 + b * b2 + a * a2; - s2 += t; - a -= t * 3; - b += t; - t = f3 + d * d3 + c * c3 + b * b3 + a * a3; - s3 += t; - a += t; + }, + + /** + @private + */ + _pointerBezierValue: { + enumerable: false, + value: function (t, bezier) { + var it = 1 - t; + return it * it * it * bezier[0] + 3 * it * it * t * bezier[1] + 3 * it * t * t * bezier[2] + t * t * t * bezier[3]; } - bezier[0] = s0; - bezier[1] = s1; - bezier[2] = s2; - bezier[3] = s3; - } - }, -/** - @private -*/ - _pointerBezierValue: { - enumerable: false, - value: function (t, bezier) { - var it = 1 - t; - return it * it * it * bezier[0] + 3 * it * it * t * bezier[1] + 3 * it * t * t * bezier[2] + t * t * t * bezier[3]; - } - }, -/** - @private -*/ - _calculatePointerVelocity: { - enumerable: false, - value: function (time, position) { - var length = time.length, - timeMin = time[0], - timeMax = time[0], - timeInterval, - iMin = 0, i; - for (i = 1; i < length; i++) { - if (time[i] < timeMin) { - timeMin = time[i]; - iMin = i; + }, + /** + @private + */ + _calculatePointerVelocity: { + enumerable: false, + value: function (time, position) { + var length = time.length, + timeMin = time[0], + timeMax = time[0], + timeInterval, + iMin = 0, i; + for (i = 1; i < length; i++) { + if (time[i] < timeMin) { + timeMin = time[i]; + iMin = i; + } } - } - timeInterval = timeMax - timeMin; - if (timeInterval) { - if (length > 5) { - var s, e, bezier, data = []; - for (i = 0; i < length; i++) { - data[i] = { - v: position[i], - t: (time[i] - timeMin) / timeInterval - }; + timeInterval = timeMax - timeMin; + if (timeInterval) { + if (length > 5) { + var s, e, bezier, data = []; + for (i = 0; i < length; i++) { + data[i] = { + v: position[i], + t: (time[i] - timeMin) / timeInterval + }; + } + s = data[iMin].v; + e = data[0].v; + bezier = [s, (s * 2 + e) / 3, (s + e * 2) / 3, e]; + this._fitPointerCurve(bezier, data); + return (this._pointerBezierValue(0.8, bezier) - this._pointerBezierValue(0.6, bezier)) * 5000 / timeInterval; + } else if (length > 1) { + return (position[0] - position[iMin]) * 1000 / timeInterval; + } else { + return 0; } - s = data[iMin].v; - e = data[0].v; - bezier = [s, (s * 2 + e) / 3, (s + e * 2) / 3, e]; - this._fitPointerCurve(bezier, data); - return (this._pointerBezierValue(0.8, bezier) - this._pointerBezierValue(0.6, bezier)) * 5000 / timeInterval; - } else if (length > 1) { - return (position[0] - position[iMin]) * 1000 / timeInterval; } else { return 0; } - } else { - return 0; } - } - }, -/** - @function - @param {attribute} identifier - */ - pointerMotion: { - value: function (identifier) { - if (defaultEventManager._pointerStorage.isStored(identifier)) { - var velocity = {}; - Object.defineProperties(velocity, { - _data: { - enumerable: false, - writable: true, - value: null - }, - _x: { - enumerable: false, - writable: true, - value: null - }, - _y: { - enumerable: false, - writable: true, - value: null - }, - _speed: { - enumerable: false, - writable: true, - value: null - }, - _angle: { - enumerable: false, - writable: true, - value: null - }, - x: { - get: function () { - if (this._x === null) { - if (this._data === null) { - this._data = defaultEventManager._getPointerVelocityData(identifier); + }, + + /** + @function + @param {attribute} identifier + */ + pointerMotion: { + value: function (identifier) { + if (defaultEventManager._pointerStorage.isStored(identifier)) { + var velocity = {}; + Object.defineProperties(velocity, { + _data: { + enumerable: false, + writable: true, + value: null + }, + _x: { + enumerable: false, + writable: true, + value: null + }, + _y: { + enumerable: false, + writable: true, + value: null + }, + _speed: { + enumerable: false, + writable: true, + value: null + }, + _angle: { + enumerable: false, + writable: true, + value: null + }, + x: { + get: function () { + if (this._x === null) { + if (this._data === null) { + this._data = defaultEventManager._getPointerVelocityData(identifier); + } + this._x = defaultEventManager._calculatePointerVelocity(this._data.time, this._data.x); } - this._x = defaultEventManager._calculatePointerVelocity(this._data.time, this._data.x); + return this._x; + }, + set: function () { } - return this._x; }, - set: function () { - } - }, - y: { - get: function () { - if (this._y === null) { - if (this._data === null) { - this._data = defaultEventManager._getPointerVelocityData(identifier); + y: { + get: function () { + if (this._y === null) { + if (this._data === null) { + this._data = defaultEventManager._getPointerVelocityData(identifier); + } + this._y = defaultEventManager._calculatePointerVelocity(this._data.time, this._data.y); } - this._y = defaultEventManager._calculatePointerVelocity(this._data.time, this._data.y); + return this._y; + }, + set: function () { } - return this._y; }, - set: function () { - } - }, - speed: { - get: function () { - if (this._speed === null) { - this._speed = Math.sqrt(this.x * this.x + this.y * this.y); + speed: { + get: function () { + if (this._speed === null) { + this._speed = Math.sqrt(this.x * this.x + this.y * this.y); + } + return this._speed; + }, + set: function () { } - return this._speed; }, - set: function () { - } - }, - angle: { - get: function () { - if (this._angle === null) { - this._angle = Math.atan2(this.y, this.x); + angle: { + get: function () { + if (this._angle === null) { + this._angle = Math.atan2(this.y, this.x); + } + return this._angle; + }, + set: function () { } - return this._angle; - }, - set: function () { } - } - }); - return { - velocity: velocity - }; - } else { - return undefined; - } - } - }, - monitorDOMModificationInEventHandling: {value: false}, - domModificationEventHandler: { value: Montage.specialize( { - handleEvent: {value : function(event) { - throw "DOM Modified"; - }}, - captureDOMSubtreeModified: {value: function(event) { - throw "DOMSubtreeModified"; - }}, - captureDOMAttrModified: {value: function(event) { - throw "DOMAttrModified"; - }}, - captureDOMCharacterDataModified: { value: function(event) { - throw "DOMCharacterDataModified"; - }}}) - }, - // Event Handling - /** - @function - @param {Event} event The handled event. - */ - handleEvent: { - enumerable: false, - value: function(event) { - - if (this.monitorDOMModificationInEventHandling) { - document.body.addEventListener("DOMSubtreeModified", this.domModificationEventHandler, true); - document.body.addEventListener("DOMAttrModified", this.domModificationEventHandler, true); - document.body.addEventListener("DOMCharacterDataModified", this.domModificationEventHandler, true); - } - - - var loadedWindow, - i, - iTarget, - listenerEntries, - j, - jListenerEntry, - listenerEntryKeys, - listenerEntryKeyCount, - jListener, - eventPath, - eventType = event.type, - eventBubbles = event.bubbles, - captureMethodName, - bubbleMethodName, - identifierSpecificCaptureMethodName, - identifierSpecificBubbleMethodName, - mutableEvent, - touchCount; - - if ("DOMContentLoaded" === eventType) { - loadedWindow = event.target.defaultView; - if (loadedWindow && this._windowsAwaitingFinalRegistration[loadedWindow.uuid]) { - this._finalizeWindowRegistration(loadedWindow); - // Stop listening for DOMContentLoaded on this target - // Otherwise the eventManager's handleEvent will be called - // again from within here when the eventManager is found - // to be a listener for this event when we find the listeners - event.target.removeEventListener("DOMContentLoaded", this, true); + }); + return { + velocity: velocity + }; + } else { + return undefined; } } + }, - if (typeof event.propagationStopped !== "boolean") { - mutableEvent = MutableEvent.fromEvent(event); - } else { - mutableEvent = event; - } + monitorDOMModificationInEventHandling: {value: false}, - if (Element.isElement(mutableEvent.target) || mutableEvent.target instanceof Document || mutableEvent.target === window) { - eventPath = this._eventPathForDomTarget(mutableEvent.target); - } else { - eventPath = this._eventPathForTarget(mutableEvent.target); - } + domModificationEventHandler: { + value: Montage.specialize({ + handleEvent: { + value: function (event) { + throw "DOM Modified"; + } + }, + captureDOMSubtreeModified: { + value: function (event) { + throw "DOMSubtreeModified"; + } + }, + captureDOMAttrModified: { + value: function (event) { + throw "DOMAttrModified"; + } + }, + captureDOMCharacterDataModified: { + value: function (event) { + throw "DOMCharacterDataModified"; + } + } + }) + }, - // use most specific handler method available, possibly based upon the identifier of the event target - if (mutableEvent.target.identifier) { - identifierSpecificCaptureMethodName = this.methodNameForCapturePhaseOfEventType(eventType, mutableEvent.target.identifier); - } else { - identifierSpecificCaptureMethodName = null; - } + // Event Handling - if (mutableEvent.target.identifier) { - identifierSpecificBubbleMethodName = this.methodNameForBubblePhaseOfEventType(eventType, mutableEvent.target.identifier); - } else { - identifierSpecificBubbleMethodName = null; - } + /** + @function + @param {Event} event The handled event. + */ + handleEvent: { + enumerable: false, + value: function (event) { - captureMethodName = this.methodNameForCapturePhaseOfEventType(eventType); - bubbleMethodName = this.methodNameForBubblePhaseOfEventType(eventType); + if (this.monitorDOMModificationInEventHandling) { + document.body.addEventListener("DOMSubtreeModified", this.domModificationEventHandler, true); + document.body.addEventListener("DOMAttrModified", this.domModificationEventHandler, true); + document.body.addEventListener("DOMCharacterDataModified", this.domModificationEventHandler, true); + } - // Let the delegate handle the event first - if (this.delegate && typeof this.delegate.willDistributeEvent === FUNCTION_TYPE) { - this.delegate.willDistributeEvent(mutableEvent); - } + var loadedWindow, + i, + iTarget, + listenerEntries, + j, + jListenerEntry, + listenerEntryKeys, + listenerEntryKeyCount, + jListener, + eventPath, + eventType = event.type, + eventBubbles = event.bubbles, + captureMethodName, + bubbleMethodName, + identifierSpecificCaptureMethodName, + identifierSpecificBubbleMethodName, + mutableEvent, + touchCount; + + if ("DOMContentLoaded" === eventType) { + loadedWindow = event.target.defaultView; + if (loadedWindow && this._windowsAwaitingFinalRegistration[loadedWindow.uuid]) { + this._finalizeWindowRegistration(loadedWindow); + // Stop listening for DOMContentLoaded on this target + // Otherwise the eventManager's handleEvent will be called + // again from within here when the eventManager is found + // to be a listener for this event when we find the listeners + event.target.removeEventListener("DOMContentLoaded", this, true); + } + } - if (this._isStoringPointerEvents) { - this._pointerStorage.storeEvent(mutableEvent); - } + if (typeof event.propagationStopped !== "boolean") { + mutableEvent = MutableEvent.fromEvent(event); + } else { + mutableEvent = event; + } - // Capture Phase Distribution - mutableEvent.eventPhase = CAPTURING_PHASE; - // The event path we generate is from bottom to top, capture needs to traverse this backwards - for (i = eventPath.length - 1; !mutableEvent.propagationStopped && (iTarget = eventPath[i]); i--) { - mutableEvent.currentTarget = iTarget; + if (Element.isElement(mutableEvent.target) || mutableEvent.target instanceof Document || mutableEvent.target === window) { + eventPath = this._eventPathForDomTarget(mutableEvent.target); + } else { + eventPath = this._eventPathForTarget(mutableEvent.target); + } - listenerEntries = this.registeredEventListenersForEventType_onTarget_(eventType, iTarget); - if (!listenerEntries) { - continue; + // use most specific handler method available, possibly based upon the identifier of the event target + if (mutableEvent.target.identifier) { + identifierSpecificCaptureMethodName = this.methodNameForCapturePhaseOfEventType(eventType, mutableEvent.target.identifier); + } else { + identifierSpecificCaptureMethodName = null; } - listenerEntryKeys = Object.keys(listenerEntries); - for (j = 0; listenerEntries && !mutableEvent.immediatePropagationStopped && (jListenerEntry = listenerEntries[listenerEntryKeys[j]]); j++) { + if (mutableEvent.target.identifier) { + identifierSpecificBubbleMethodName = this.methodNameForBubblePhaseOfEventType(eventType, mutableEvent.target.identifier); + } else { + identifierSpecificBubbleMethodName = null; + } - if (!jListenerEntry.capture) { - continue; - } + captureMethodName = this.methodNameForCapturePhaseOfEventType(eventType); + bubbleMethodName = this.methodNameForBubblePhaseOfEventType(eventType); - jListener = jListenerEntry.listener; + // Let the delegate handle the event first + if (this.delegate && typeof this.delegate.willDistributeEvent === FUNCTION_TYPE) { + this.delegate.willDistributeEvent(mutableEvent); + } - this._invokeTargetListenerForEvent(iTarget,jListener,mutableEvent,identifierSpecificCaptureMethodName,captureMethodName); + if (this._isStoringPointerEvents) { + this._pointerStorage.storeEvent(mutableEvent); } - } - // At Target Distribution - if (!mutableEvent.propagationStopped) { - mutableEvent.eventPhase = AT_TARGET; - mutableEvent.currentTarget = iTarget = mutableEvent.target; + // Capture Phase Distribution + mutableEvent.eventPhase = CAPTURING_PHASE; + // The event path we generate is from bottom to top, capture needs to traverse this backwards + for (i = eventPath.length - 1; !mutableEvent.propagationStopped && (iTarget = eventPath[i]); i--) { + mutableEvent.currentTarget = iTarget; - listenerEntries = this.registeredEventListenersForEventType_onTarget_(eventType, iTarget); - if (listenerEntries) { + listenerEntries = this.registeredEventListenersForEventType_onTarget_(eventType, iTarget); + if (!listenerEntries) { + continue; + } listenerEntryKeys = Object.keys(listenerEntries); for (j = 0; listenerEntries && !mutableEvent.immediatePropagationStopped && (jListenerEntry = listenerEntries[listenerEntryKeys[j]]); j++) { - jListener = jListenerEntry.listener; - - if (jListenerEntry.capture) { - this._invokeTargetListenerForEvent(iTarget, jListener, mutableEvent, identifierSpecificCaptureMethodName, captureMethodName); + if (!jListenerEntry.capture) { + continue; } - if (jListenerEntry.bubble) { - this._invokeTargetListenerForEvent(iTarget, jListener, mutableEvent, identifierSpecificBubbleMethodName, bubbleMethodName); - } + jListener = jListenerEntry.listener; + this._invokeTargetListenerForEvent(iTarget, jListener, mutableEvent, identifierSpecificCaptureMethodName, captureMethodName); } } - } - // Bubble Phase Distribution - mutableEvent.eventPhase = BUBBLING_PHASE; - for (i = 0; eventBubbles && !mutableEvent.propagationStopped && (iTarget = eventPath[i]); i++) { - mutableEvent.currentTarget = iTarget; + // At Target Distribution + if (!mutableEvent.propagationStopped) { + mutableEvent.eventPhase = AT_TARGET; + mutableEvent.currentTarget = iTarget = mutableEvent.target; + + listenerEntries = this.registeredEventListenersForEventType_onTarget_(eventType, iTarget); + if (listenerEntries) { + listenerEntryKeys = Object.keys(listenerEntries); + + for (j = 0; listenerEntries && !mutableEvent.immediatePropagationStopped && (jListenerEntry = listenerEntries[listenerEntryKeys[j]]); j++) { + + jListener = jListenerEntry.listener; + + if (jListenerEntry.capture) { + this._invokeTargetListenerForEvent(iTarget, jListener, mutableEvent, identifierSpecificCaptureMethodName, captureMethodName); + } + + if (jListenerEntry.bubble) { + this._invokeTargetListenerForEvent(iTarget, jListener, mutableEvent, identifierSpecificBubbleMethodName, bubbleMethodName); + } - listenerEntries = this.registeredEventListenersForEventType_onTarget_(eventType, iTarget); - if (!listenerEntries) { - continue; + } + } } - listenerEntryKeys = Object.keys(listenerEntries); - for (j = 0; listenerEntries && !mutableEvent.immediatePropagationStopped && (jListenerEntry = listenerEntries[listenerEntryKeys[j]]); j++) { + // Bubble Phase Distribution + mutableEvent.eventPhase = BUBBLING_PHASE; + for (i = 0; eventBubbles && !mutableEvent.propagationStopped && (iTarget = eventPath[i]); i++) { + mutableEvent.currentTarget = iTarget; - if (!jListenerEntry.bubble) { + listenerEntries = this.registeredEventListenersForEventType_onTarget_(eventType, iTarget); + if (!listenerEntries) { continue; } + listenerEntryKeys = Object.keys(listenerEntries); + + for (j = 0; listenerEntries && !mutableEvent.immediatePropagationStopped && (jListenerEntry = listenerEntries[listenerEntryKeys[j]]); j++) { + + if (!jListenerEntry.bubble) { + continue; + } - jListener = jListenerEntry.listener; + jListener = jListenerEntry.listener; - this._invokeTargetListenerForEvent(iTarget, jListener, mutableEvent, identifierSpecificBubbleMethodName, bubbleMethodName); + this._invokeTargetListenerForEvent(iTarget, jListener, mutableEvent, identifierSpecificBubbleMethodName, bubbleMethodName); + } } - } - mutableEvent.eventPhase = NONE; - mutableEvent.currentTarget = null; + mutableEvent.eventPhase = NONE; + mutableEvent.currentTarget = null; - if (this._isStoringPointerEvents) { - this._pointerStorage.removeEvent(event); - } + if (this._isStoringPointerEvents) { + this._pointerStorage.removeEvent(event); + } - if (this.monitorDOMModificationInEventHandling) { - document.body.removeEventListener("DOMSubtreeModified", this.domModificationEventHandler, true); - document.body.removeEventListener("DOMAttrModified", this.domModificationEventHandler, true); - document.body.removeEventListener("DOMCharacterDataModified", this.domModificationEventHandler, true); + if (this.monitorDOMModificationInEventHandling) { + document.body.removeEventListener("DOMSubtreeModified", this.domModificationEventHandler, true); + document.body.removeEventListener("DOMAttrModified", this.domModificationEventHandler, true); + document.body.removeEventListener("DOMCharacterDataModified", this.domModificationEventHandler, true); + } } - } - }, - - _invokeTargetListenerForEvent: { - value: function(iTarget, jListener,mutableEvent,identifierSpecificPhaseMethodName,phaseMethodName) { - var listenerFunction; - if ((identifierSpecificPhaseMethodName && typeof (listenerFunction = jListener[identifierSpecificPhaseMethodName]) === FUNCTION_TYPE) - || (typeof (listenerFunction = jListener[phaseMethodName]) === FUNCTION_TYPE) - || (typeof (listenerFunction = jListener.handleEvent) === FUNCTION_TYPE)) { - listenerFunction.call(jListener, mutableEvent); - } else if (typeof jListener === FUNCTION_TYPE) { - jListener.call(iTarget, mutableEvent); + }, + + /** + * @private + */ + _invokeTargetListenerForEvent: { + value: function (iTarget, jListener, mutableEvent, identifierSpecificPhaseMethodName, phaseMethodName) { + var listenerFunction; + if ((identifierSpecificPhaseMethodName && typeof (listenerFunction = jListener[identifierSpecificPhaseMethodName]) === FUNCTION_TYPE) + || (typeof (listenerFunction = jListener[phaseMethodName]) === FUNCTION_TYPE) + || (typeof (listenerFunction = jListener.handleEvent) === FUNCTION_TYPE)) { + listenerFunction.call(jListener, mutableEvent); + } else if (typeof jListener === FUNCTION_TYPE) { + jListener.call(iTarget, mutableEvent); + } } - } - }, - - // Ensure that any components associated with DOM elements in the hierarchy between the - // original activationEvent target and the window are preparedForActionEvents - - /** - @private -*/ - _prepareComponentsForActivation: { - value: function(eventTarget) { - - var target = eventTarget, - previousTarget, - targetView = target && target.defaultView ? target.defaultView : window, - targetDocument = targetView.document ? targetView.document : document, - associatedComponent, - lookedForActiveTarget = false, - activeTarget = null; - - do { - - if (target) { - associatedComponent = this.eventHandlerForElement(target); - if (associatedComponent) { - - // Once we've found a component starting point, - // find the closest Target that accepts focus - if (!lookedForActiveTarget) { - lookedForActiveTarget = true; - activeTarget = this._findActiveTarget(associatedComponent); - } + }, + + /** + * Ensure that any components associated with DOM elements in the hierarchy between the + * original activationEvent target and the window are preparedForActionEvents + * + * @function + * @private + */ + _prepareComponentsForActivation: { + value: function (eventTarget) { + + var target = eventTarget, + previousTarget, + targetView = target && target.defaultView ? target.defaultView : window, + targetDocument = targetView.document ? targetView.document : document, + associatedComponent, + lookedForActiveTarget = false, + activeTarget = null; + + do { + + if (target) { + associatedComponent = this.eventHandlerForElement(target); + if (associatedComponent) { + + // Once we've found a component starting point, + // find the closest Target that accepts focus + if (!lookedForActiveTarget) { + lookedForActiveTarget = true; + activeTarget = this._findActiveTarget(associatedComponent); + } - if (!associatedComponent._preparedForActivationEvents) { - associatedComponent._prepareForActivationEvents(); - associatedComponent._preparedForActivationEvents = true; + if (!associatedComponent._preparedForActivationEvents) { + associatedComponent._prepareForActivationEvents(); + associatedComponent._preparedForActivationEvents = true; + } } } - } - - previousTarget = target; - // We only need to go up to the window, and even that's debateable as the activationEvent system really - // only pertains to components, which are only ever associated with elements. The root element being the - // exception which is associated with the document. - switch (target) { - case targetView: - target = null; - break; - case targetDocument: - target = targetView; - break; - case targetDocument.documentElement: - target = targetDocument; - break; - default: - target = target.parentNode; - break; - } + previousTarget = target; + + // We only need to go up to the window, and even that's debateable as the activationEvent system really + // only pertains to components, which are only ever associated with elements. The root element being the + // exception which is associated with the document. + switch (target) { + case targetView: + target = null; + break; + case targetDocument: + target = targetView; + break; + case targetDocument.documentElement: + target = targetDocument; + break; + default: + target = target.parentNode; + break; + } - } while (target && previousTarget !== target); + } while (target && previousTarget !== target); - this.activeTarget = activeTarget; - } - }, + this.activeTarget = activeTarget; + } + }, - /** - * - @private - */ - _findActiveTarget: { - value: function(target) { + /** + * @private + */ + _findActiveTarget: { + value: function (target) { - var foundTarget = null, - uuidCheckedTargetMap = {}; + var foundTarget = null, + uuidCheckedTargetMap = {}; - //TODO report if a cycle is detected? - while (!foundTarget && target && !(target.uuid in uuidCheckedTargetMap)) { + //TODO report if a cycle is detected? + while (!foundTarget && target && !(target.uuid in uuidCheckedTargetMap)) { - //TODO complain if a non-Target-alike is considered + //TODO complain if a non-Target-alike is considered - uuidCheckedTargetMap[target.uuid] = target; + uuidCheckedTargetMap[target.uuid] = target; - if (target.acceptsActiveTarget) { - foundTarget = target; - } else { - target = target.nextTarget; + if (target.acceptsActiveTarget) { + foundTarget = target; + } else { + target = target.nextTarget; + } } + + return foundTarget; } + }, - return foundTarget; - } - }, + /** + * Build the event target chain for the the specified Target + * @private + */ + _eventPathForTarget: { + enumerable: false, + value: function (target) { - /** - * Build the event target chain for the the specified Target - * @private - */ - _eventPathForTarget: { - enumerable: false, - value: function(target) { + if (!target) { + return []; + } - if (!target) { - return []; - } + var targetCandidate = target, + application = this.application, + eventPath = [], + discoveredTargets = {}; - var targetCandidate = target, - application = this.application, - eventPath = [], - discoveredTargets = {}; + // Consider the target "discovered" for less specialized detection of cycles + discoveredTargets[target.uuid] = target; - // Consider the target "discovered" for less specialized detection of cycles - discoveredTargets[target.uuid] = target; + do { + if (!(targetCandidate.uuid in discoveredTargets)) { + eventPath.push(targetCandidate); + discoveredTargets[targetCandidate.uuid] = targetCandidate; + } - do { - if (!(targetCandidate.uuid in discoveredTargets)) { - eventPath.push(targetCandidate); - discoveredTargets[targetCandidate.uuid] = targetCandidate; - } + targetCandidate = targetCandidate.nextTarget; - targetCandidate = targetCandidate.nextTarget; + if (!targetCandidate || targetCandidate.uuid in discoveredTargets) { + targetCandidate = application; + } - if (!targetCandidate || targetCandidate.uuid in discoveredTargets) { - targetCandidate = application; + if (targetCandidate && (targetCandidate.uuid in discoveredTargets)) { + targetCandidate = null; + } } + while (targetCandidate); - if (targetCandidate && (targetCandidate.uuid in discoveredTargets)) { - targetCandidate = null; - } + return eventPath; } - while (targetCandidate); - - return eventPath; - } - }, + }, - /** - * Build the event target chain for the the specified DOM target - * @private - */ - _eventPathForDomTarget: { - enumerable: false, - value: function(target) { + /** + * Build the event target chain for the the specified DOM target + * @private + */ + _eventPathForDomTarget: { + enumerable: false, + value: function (target) { - if (!target) { - return []; - } + if (!target) { + return []; + } - var targetCandidate = target, - targetView = targetCandidate && targetCandidate.defaultView ? targetCandidate.defaultView : window, - targetDocument = targetView.document ? targetView.document : document, - targetApplication = this.application, - previousBubblingTarget, - eventPath = []; - - do { - // Don't include the target itself as the root of the event path - if (targetCandidate !== target) { - eventPath.push(targetCandidate); - } - - previousBubblingTarget = targetCandidate; - // use the structural DOM hierarchy until we run out of that and need - // to give listeners on document, window, and application a chance to respond - switch (targetCandidate) { - case targetApplication: - targetCandidate = targetCandidate.parentApplication; - if (targetCandidate) { - targetApplication = targetCandidate; - } - break; - case targetView: - targetCandidate = targetApplication; - break; - case targetDocument: - targetCandidate = targetView; - break; - case targetDocument.documentElement: - targetCandidate = targetDocument; - break; - default: - targetCandidate = targetCandidate.parentNode; + var targetCandidate = target, + targetView = targetCandidate && targetCandidate.defaultView ? targetCandidate.defaultView : window, + targetDocument = targetView.document ? targetView.document : document, + targetApplication = this.application, + previousBubblingTarget, + eventPath = []; + + do { + // Don't include the target itself as the root of the event path + if (targetCandidate !== target) { + eventPath.push(targetCandidate); + } - // Run out of hierarchy candidates? go up to the application - if (!targetCandidate) { + previousBubblingTarget = targetCandidate; + // use the structural DOM hierarchy until we run out of that and need + // to give listeners on document, window, and application a chance to respond + switch (targetCandidate) { + case targetApplication: + targetCandidate = targetCandidate.parentApplication; + if (targetCandidate) { + targetApplication = targetCandidate; + } + break; + case targetView: targetCandidate = targetApplication; - } + break; + case targetDocument: + targetCandidate = targetView; + break; + case targetDocument.documentElement: + targetCandidate = targetDocument; + break; + default: + targetCandidate = targetCandidate.parentNode; + + // Run out of hierarchy candidates? go up to the application + if (!targetCandidate) { + targetCandidate = targetApplication; + } - break; + break; + } } - } - while (targetCandidate && previousBubblingTarget !== targetCandidate); + while (targetCandidate && previousBubblingTarget !== targetCandidate); - return eventPath; - } - }, -/** - @private -*/ - _elementEventHandlerByUUID: { - enumerable: false, - value: {} - }, -/** - @function - @param {Event} anElementEventHandler - @param {Element} anElement - */ - registerEventHandlerForElement: { - enumerable: false, - value: function(anElementEventHandler, anElement) { - // console.log("registerEventHandlerForElement",anElementEventHandler,anElementEventHandler.uuid,anElement) - var oldEventHandler = this.eventHandlerForElement(anElement); - // unreference unused event handlers - if (oldEventHandler) { - this.unregisterEventHandlerForElement(anElement); + return eventPath; } - this._elementEventHandlerByUUID[(anElement.eventHandlerUUID = anElementEventHandler.uuid)] = anElementEventHandler; - } - }, -/** - @function - @param {Element} anElement - */ - unregisterEventHandlerForElement: { - enumerable: false, - value: function(anElement) { - delete this._elementEventHandlerByUUID[anElement.eventHandlerUUID]; - delete anElement.eventHandlerUUID; - } - }, -/** - @function - @param {Element} anElement - @returns this._elementEventHandlerByUUID[anElement.eventHandlerUUID] - */ - eventHandlerForElement: { - enumerable: false, - value: function(anElement) { - return this._elementEventHandlerByUUID[anElement.eventHandlerUUID]; - } - }, - - _activeTarget: { - value: null - }, + }, - /** - * The logical component that has focus within the application - * - * This can be used as the proximal target for dispatching in - * situations where it logically makes sense that and event, while - * created by some other component, should appear to originate from - * where the user is currently focused. - * - * This is particularly useful for things such as keyboard shortcuts or - * menuAction events. - * - * Prior to setting the activeTarget manually the desired target should - * be checked to see if it `acceptsActiveTarget`. In the course of then - * setting that target as the activeTarget, the current activeTarget - * will be instructed to `surrendersActiveTarget`. If the activeTarget - * refuses to surrender, the change is rejected. - */ - activeTarget: { - get: function () { - return this._activeTarget || this.application; + /** + * @private + */ + _elementEventHandlerByUUID: { + enumerable: false, + value: {} }, - set: function (value) { - if (!value) { - value = this.application; + /** + @function + @param {Event} anElementEventHandler + @param {Element} anElement + */ + registerEventHandlerForElement: { + enumerable: false, + value: function (anElementEventHandler, anElement) { + // console.log("registerEventHandlerForElement",anElementEventHandler,anElementEventHandler.uuid,anElement) + var oldEventHandler = this.eventHandlerForElement(anElement); + // unreference unused event handlers + if (oldEventHandler) { + this.unregisterEventHandlerForElement(anElement); + } + this._elementEventHandlerByUUID[(anElement.eventHandlerUUID = anElementEventHandler.uuid)] = anElementEventHandler; } + }, - if (value === this._activeTarget || (this.activeTarget && !this.activeTarget.surrendersActiveTarget(value))) { - return; + /** + @function + @param {Element} anElement + */ + unregisterEventHandlerForElement: { + enumerable: false, + value: function (anElement) { + delete this._elementEventHandlerByUUID[anElement.eventHandlerUUID]; + delete anElement.eventHandlerUUID; + } + }, + /** + @function + @param {Element} anElement + @returns this._elementEventHandlerByUUID[anElement.eventHandlerUUID] + */ + eventHandlerForElement: { + enumerable: false, + value: function (anElement) { + return this._elementEventHandlerByUUID[anElement.eventHandlerUUID]; } + }, + + /** + * @private + */ + _activeTarget: { + value: null + }, + + /** + * The logical component that has focus within the application + * + * This can be used as the proximal target for dispatching in + * situations where it logically makes sense that and event, while + * created by some other component, should appear to originate from + * where the user is currently focused. + * + * This is particularly useful for things such as keyboard shortcuts or + * menuAction events. + * + * Prior to setting the activeTarget manually the desired target should + * be checked to see if it `acceptsActiveTarget`. In the course of then + * setting that target as the activeTarget, the current activeTarget + * will be instructed to `surrendersActiveTarget`. If the activeTarget + * refuses to surrender, the change is rejected. + */ + activeTarget: { + get: function () { + return this._activeTarget || this.application; + }, + set: function (value) { + + if (!value) { + value = this.application; + } + + if (value === this._activeTarget || (this.activeTarget && !this.activeTarget.surrendersActiveTarget(value))) { + return; + } - value.willBecomeActiveTarget(this.activeTarget); - this._activeTarget = value; - value.didBecomeActiveTarget(); + value.willBecomeActiveTarget(this.activeTarget); + this._activeTarget = value; + value.didBecomeActiveTarget(); + } } - } -}); + }); } // client-side diff --git a/core/event/key-manager.js b/core/event/key-manager.js index ee6d99fa31..a77d2c2ac9 100644 --- a/core/event/key-manager.js +++ b/core/event/key-manager.js @@ -256,10 +256,10 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# * @default 1000 */ longPressThreshold: { - get: function() { + get: function () { return this._longPressThreshold; }, - set: function(value) { + set: function (value) { if (value > 0 && value !== this._longPressThreshold) { this._longPressThreshold = value; if (this._longPressThreshold > this._cleanupThreshold - 100) { @@ -273,11 +273,11 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# /** * Register a composerKey. - * @method + * @function * @param {Object} keyComposer. The key to register. */ registerKey: { - value: function(keyComposer) { + value: function (keyComposer) { // validates the keys: var normalizedKeys = this._normalizeKeySequence(keyComposer.keys), modifiersAndKey, @@ -324,11 +324,11 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# * Unregister a composerKey. if a key has been registered multiple time, * unregister must be called the same amount of time before the key is * actually unregistered. - * @method + * @function * @param {Object} keyComposer The key to unregister. */ unregisterKey: { - value: function(keyComposer) { + value: function (keyComposer) { var map = this._composerKeyMap, mapModifiersEntry, mapKeyEntry, @@ -361,7 +361,7 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# }, constructor: { - value: function() { + value: function () { var userAgent = navigator.userAgent, code; @@ -436,7 +436,7 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# }, captureKeydown: { - value: function(event) { + value: function (event) { var keyCode, identifierCode, submap, @@ -471,7 +471,7 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# }, captureKeypress: { - value: function(event) { + value: function (event) { var charCode = event.charCode, keyCode, identifierCode, @@ -512,7 +512,7 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# }, captureKeyup: { - value: function(event) { + value: function (event) { var keyCode = event.keyCode, identifierCode, submap, @@ -563,7 +563,7 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# }, _normalizeKeySequence: { - value: function(keySequence) { + value: function (keySequence) { var modifiersOrder = [MODIFIERS.meta.name, MODIFIERS.alt.name, MODIFIERS.control.name, MODIFIERS.shift.name], keys = keySequence.toLowerCase().replace(/ /g, "").replace(/\+\+/g, "+add").split("+"), nbrKeys = keys.length, @@ -586,7 +586,7 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# } } - normalizedKeys.sort(function(a, b) { + normalizedKeys.sort(function (a, b) { return modifiersOrder.indexOf(a) - modifiersOrder.indexOf(b); }); @@ -605,7 +605,7 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# }, _preprocessKeyEvent: { - value: function(event) { + value: function (event) { var thisRef = this, eventType = event.type, keyCode = event.keyCode, @@ -638,7 +638,7 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# if (eventType == "keyup") { // Setup a timeout to force reset the modifier state ~3 seconds after the last key up // This is to recover when we miss a keyup event which seems to occurs once in a while with Opera - this._operaModifierTimeout = setTimeout(function(){ + this._operaModifierTimeout = setTimeout(function (){ thisRef._shiftKey = false; thisRef._altKey = false; thisRef._metaKey = false; @@ -680,7 +680,7 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# }, _registerListeners: { - value: function() { + value: function () { if (!this._keyEventsListenerInstalled) { window.addEventListener("keydown", this, true); window.addEventListener("keypress", this, true); @@ -691,7 +691,7 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# }, _unregisterListeners: { - value: function() { + value: function () { if (this._keyEventsListenerInstalled) { window.removeEventListener("keydown", this, true); window.removeEventListener("keypress", this, true); @@ -702,7 +702,7 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# }, _dispatchComposerKeyMatches: { - value: function(matches, event) { + value: function (matches, event) { var thisRef = this, stopped = false, keyUp = event.type == "keyup", @@ -768,7 +768,7 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# continue; } if (keyComposer._shouldDispatchLongPress && !keyComposer._longPressTimeout) { - keyComposer._longPressTimeout = setTimeout(function() { + keyComposer._longPressTimeout = setTimeout(function () { var longPressEvent; keyComposer._longPressTimeout = null; @@ -835,7 +835,7 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# }, _cleanup: { - value: function() { + value: function () { var keyComposer, i; @@ -863,7 +863,7 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# }, _setupCleanupTimer: { - value: function() { + value: function () { var thisRef = this; // When a keydown event is stopped, we will not received the corresponding keyup event. @@ -873,14 +873,14 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# if (this._cleanupTimeout) { clearTimeout(this._cleanupTimeout); } - this._cleanupTimeout = setTimeout(function() { + this._cleanupTimeout = setTimeout(function () { thisRef._cleanup(); }, this._cleanupThreshold); } }, _convertKeysToModifiersAndKeyCode: { - value: function(keys) { + value: function (keys) { var nbrKeys, key, i, @@ -928,7 +928,7 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# }, _decodeKeyIdentifier: { - value: function(identifier) { + value: function (identifier) { if (identifier.match(/U\+/)) { return parseInt(identifier.substring(2), 16); } @@ -938,7 +938,7 @@ var KeyManager = exports.KeyManager = Montage.specialize(/** @lends KeyManager# var _defaultKeyManager = null; Montage.defineProperty(exports, "defaultKeyManager", { - get: function() { + get: function () { if (!_defaultKeyManager) { _defaultKeyManager = new KeyManager(); } diff --git a/core/event/mutable-event.js b/core/event/mutable-event.js index b48c221bc4..99dd86c3c6 100644 --- a/core/event/mutable-event.js +++ b/core/event/mutable-event.js @@ -10,21 +10,21 @@ if (typeof window !== "undefined") { var _eventConstructorsByType = {}; var nullDescriptor = {value: null}; - var wrapProperty = function(obj, key) { + var wrapProperty = function (obj, key) { var storageKey = "_" + key; Montage.defineProperty(obj, storageKey, {value: undefined}); Montage.defineProperty(obj, key, { - get:(function(key, storageKey) { - return function() { + get:(function (key, storageKey) { + return function () { return this.hasOwnProperty(storageKey) ? this[storageKey] : (this._event ? this._event[key] : undefined); }; })(key, storageKey), - set: (function(storageKey) { - return function(value) { + set: (function (storageKey) { + return function (value) { this[storageKey] = value; }; })(storageKey) @@ -39,7 +39,7 @@ if (typeof window !== "undefined") { @private */ _initPrototypeWithEvent: { - value: function(event) { + value: function (event) { var key; for (key in event) { @@ -68,26 +68,26 @@ if (typeof window !== "undefined") { }, _initWithEvent: { - value: function(event) { + value: function (event) { this._event = event; return this; } }, /** - * @method + * @function */ preventDefault: { - value: function() { + value: function () { this._event.preventDefault(); } }, /** - * @method + * @function */ getPreventDefault: { - value: function() { + value: function () { if (this._event.getPreventDefault) { return this._event.getPreventDefault(); } @@ -96,10 +96,10 @@ if (typeof window !== "undefined") { }, /** - * @method + * @function */ stopImmediatePropagation: { - value: function() { + value: function () { this._event.stopImmediatePropagation(); // TODO only if the event is cancellable? this.propagationStopped = true; @@ -140,10 +140,10 @@ if (typeof window !== "undefined") { }, /** - * @method + * @function */ stopPropagation: { - value: function() { + value: function () { this._event.stopPropagation(); // TODO only if the event is cancellable? this.propagationStopped = true; @@ -151,10 +151,10 @@ if (typeof window !== "undefined") { }, /** - * @method + * @function */ stop: { - value: function() { + value: function () { this.preventDefault(); this.stopPropagation(); } @@ -167,7 +167,7 @@ if (typeof window !== "undefined") { * @returns newEvent */ fromEvent: { - value: function(event) { + value: function (event) { var type = event.type, constructor = _eventConstructorsByType[type], newEvent; @@ -194,7 +194,7 @@ if (typeof window !== "undefined") { * @returns this.fromEvent(anEvent) */ fromType: { - value: function(type, canBubbleArg, cancelableArg, detail) { + value: function (type, canBubbleArg, cancelableArg, detail) { var anEvent = document.createEvent("CustomEvent"); anEvent.initCustomEvent(type, canBubbleArg, cancelableArg, detail); return this.fromEvent(anEvent); diff --git a/core/exception.js b/core/exception.js index 817f6cd256..a8d82d0a24 100644 --- a/core/exception.js +++ b/core/exception.js @@ -44,32 +44,32 @@ var Exception = exports.Exception = Montage.specialize(/** @lends Exception# */ }, /** - * @method + * @function * @param {string} message The message to be initialized. * @returns this.initWithMessageTargetAndMethod(message, null, null) */ initWithMessage : { enumerable: true, - value: function(message) { + value: function (message) { return this.initWithMessageTargetAndMethod(message, null, null); } }, /** - * @method + * @function * @param {string} message The message to be initialized. * @param {string} target The target to be initialized. * @returns this.initWithMessageTargetAndMethod(message, target, null) */ initWithMessageAndTarget : { enumerable: true, - value: function(message, target) { + value: function (message, target) { return this.initWithMessageTargetAndMethod(message, target, null); } }, /** - * @method + * @function * @param {string} message The message to be initialized. * @param {string} target The target to be initialized. * @param {Function} method The method to be initialized. @@ -77,7 +77,7 @@ var Exception = exports.Exception = Montage.specialize(/** @lends Exception# */ */ initWithMessageTargetAndMethod : { enumerable: true, - value: function(message, target, method) { + value: function (message, target, method) { this.message = (typeof message !== 'undefined' ? message : null); Object.defineProperty(this, "message", {writable: false}); this.target = (typeof target !== 'undefined' ? target : null); @@ -89,12 +89,12 @@ var Exception = exports.Exception = Montage.specialize(/** @lends Exception# */ }, /** - * @method + * @function * @returns The exception */ toString: { enumerable: false, - value: function() { + value: function () { return "Exception: " + (this.message !== null ? this.message + " " : null) + (this.target !== null ? this.target + " " : null) + (this.method !== null ? this.method + " " : null); } } diff --git a/core/extras/date.js b/core/extras/date.js index 2f5ce1b704..3540ef7a3d 100644 --- a/core/extras/date.js +++ b/core/extras/date.js @@ -1,5 +1,6 @@ /** * Defines extensions to intrinsic `Date` object. + * * @module montage/core/extras/date * @see {external:Date} */ @@ -11,8 +12,8 @@ /** * Creates a copy of a date. * - * @method external:Date#clone - * @returns {Date} a new date + * @function external:Date#clone + * @returns {Date} - a new date */ Object.defineProperty(Date.prototype, "clone", { value: function () { diff --git a/core/extras/object.js b/core/extras/object.js index a9949f4af8..43803bbecd 100644 --- a/core/extras/object.js +++ b/core/extras/object.js @@ -20,7 +20,7 @@ var FUNCTION = "function"; * @function external:Object.getPropertyDescriptor */ Object.defineProperty(Object, "getPropertyDescriptor", { - value: function(anObject, propertyName) { + value: function (anObject, propertyName) { var current = anObject, currentDescriptor; @@ -45,7 +45,7 @@ Object.defineProperty(Object, "getPropertyDescriptor", { * external:Object.getPrototypeAndDescriptorDefiningProperty */ Object.defineProperty(Object, "getPrototypeAndDescriptorDefiningProperty", { - value: function(anObject, propertyName) { + value: function (anObject, propertyName) { var current = anObject, currentDescriptor; if (propertyName) { @@ -72,7 +72,7 @@ Object.defineProperty(Object, "getPrototypeAndDescriptorDefiningProperty", { * @returns this */ Object.defineProperty(Object.prototype, "clear", { - value: function() { + value: function () { var keys = Object.keys(this), i = keys.length; diff --git a/core/extras/regexp.js b/core/extras/regexp.js index d7a0905f1d..b6a0e4eb96 100644 --- a/core/extras/regexp.js +++ b/core/extras/regexp.js @@ -19,7 +19,7 @@ if (!RegExp.isRegExp) { var toString = Object.prototype.toString; Object.defineProperty(RegExp, "isRegExp", { - value: function(obj) { + value: function (obj) { return toString.call(obj) === "[object RegExp]"; }, writable: true, diff --git a/core/extras/string.js b/core/extras/string.js index 58ac31dc51..44e962e115 100644 --- a/core/extras/string.js +++ b/core/extras/string.js @@ -8,7 +8,7 @@ /** * Returns true if the two strings are equal, otherwise returns false. * - * @method external:String#equals + * @function external:String#equals * @param {Object} that The object to compare to the string. * @returns {boolean} Returns true if the string is equal to * `that`. @@ -24,7 +24,7 @@ Object.defineProperty(String.prototype, "equals", { /** * Determines whether a substring exists within this string. * - * @method external:String#contains + * @function external:String#contains * @param {string} content * @returns {boolean} whether this string contains the given content */ @@ -39,7 +39,7 @@ Object.defineProperty(String.prototype, "contains", { /** * Capitalizes the first letter in the string. * - * @method external:String#toCapitalized + * @function external:String#toCapitalized * @returns {string} The original string with its first letter capitalized. * @example * var fname = "abe"; @@ -48,7 +48,7 @@ Object.defineProperty(String.prototype, "contains", { * // name == "Abe Lincoln" */ Object.defineProperty(String.prototype, "toCapitalized", { - value: function() { + value: function () { return this.charAt(0).toUpperCase() + this.slice(1); }, writable: true, diff --git a/core/gate.js b/core/gate.js index 46a55254e1..1d20fa13ef 100644 --- a/core/gate.js +++ b/core/gate.js @@ -11,7 +11,7 @@ var Montage = require("./core").Montage, * @class Gate * @extends Montage */ -var Gate = exports.Gate = Montage.specialize(/** @lends Gate# */ { +var Gate = exports.Gate = Montage.specialize(/** @lends Gate.prototype # */ { constructor: { value: function Gate() { @@ -20,25 +20,25 @@ var Gate = exports.Gate = Montage.specialize(/** @lends Gate# */ { }, /** - * @method + * @function * @returns {Gate} A new Gate instance. */ init: { enumerable: false, - value: function() { + value: function () { this.reset(); return this; } }, /** - * @method + * @function * @param {string} delegate The delegate to be initialized. * @returns itself */ initWithDelegate: { enumerable: false, - value: function(delegate) { + value: function (delegate) { this.reset(); this.delegate = delegate; return this; @@ -46,13 +46,13 @@ var Gate = exports.Gate = Montage.specialize(/** @lends Gate# */ { }, /** - * @method + * @function * @param {string} propertyDescriptor The propertyDescriptor to be initialized. * @returns itself */ initWithDescriptor: { enumerable: false, - value: function(propertyDescriptor) { + value: function (propertyDescriptor) { var fieldName; this.reset(); for (fieldName in propertyDescriptor) { @@ -79,26 +79,26 @@ var Gate = exports.Gate = Montage.specialize(/** @lends Gate# */ { }, /** - * @method + * @function * @param {Array} aFieldName The aFieldName array. * @returns !table or table[aFieldName] */ getField: { enumerable: false, - value: function(aFieldName) { + value: function (aFieldName) { var table = this.table; return !table || table[aFieldName]; } }, /** - * @method + * @function * @param {Array} aFieldName The aFieldName array. * @param {number} value The count on the array. */ setField: { enumerable: false, - value: function(aFieldName, value) { + value: function (aFieldName, value) { var table = this.table, fieldValue, oldCount = this.count; @@ -129,12 +129,12 @@ var Gate = exports.Gate = Montage.specialize(/** @lends Gate# */ { }, /** - * @method + * @function * @param {Array} aFieldName The aFieldName array to be removed. */ removeField: { enumerable: false, - value: function(aFieldName) { + value: function (aFieldName) { var table = this.table, fieldValue = table[aFieldName]; if (typeof fieldValue !== "undefined" && !fieldValue) { // if the value was false decrement the count @@ -154,11 +154,11 @@ var Gate = exports.Gate = Montage.specialize(/** @lends Gate# */ { }, /** - * @method + * @function * @param {number} value The value to be called. */ callDelegateMethod: { - value: function(value) { + value: function (value) { var delegateMethod; if (this.delegate && typeof (delegateMethod = this.delegate["gateDidBecome" + (value ? "True" : "False")]) === "function") { delegateMethod.call(this.delegate, this); @@ -173,28 +173,28 @@ var Gate = exports.Gate = Montage.specialize(/** @lends Gate# */ { */ value: { enumerable: false, - get: function() { + get: function () { return this.count === 0; } }, /** - * @method + * @function */ reset: { enumerable: false, - value: function() { + value: function () { this.table = {}; this.count = 0; } }, /** - * @method + * @function * @returns {string} result */ toString: { - value: function() { + value: function () { var fieldNames = this._fields, i, iField, diff --git a/core/geometry/cubic-bezier.js b/core/geometry/cubic-bezier.js index 99e6872e73..4c22b82ec4 100644 --- a/core/geometry/cubic-bezier.js +++ b/core/geometry/cubic-bezier.js @@ -13,13 +13,13 @@ var Point = require("./point").Point; var CubicBezier = exports.CubicBezier = Montage.specialize( /** @lends CubicBezier# */{ /** - * @method + * @function * @param {Array} controlPoints Control points. * @returns itself */ init: { enumerable: false, - value: function(controlPoints) { + value: function (controlPoints) { if (controlPoints !== null) { if (controlPoints.length === 2) { this.p1 = controlPoints[0]; @@ -36,7 +36,7 @@ var CubicBezier = exports.CubicBezier = Montage.specialize( /** @lends CubicBezi }, /** - * @method + * @function * @param {number} t Control point. * @returns itself or `new Point().init(this.p0.x * b1 + this.p1.x * b2 + * this.p2.x * b3 + this.p3.x * b4, this.p0.y * b1 + this.p1.y * b2 + @@ -44,7 +44,7 @@ var CubicBezier = exports.CubicBezier = Montage.specialize( /** @lends CubicBezi */ position: { enumerable: false, - value: function(t) { + value: function (t) { if (t < 0 || t > 1) { return; } @@ -61,20 +61,20 @@ var CubicBezier = exports.CubicBezier = Montage.specialize( /** @lends CubicBezi }, /** - * @method + * @function * @param {number} t Control point. * @returns CubicBezier.create(CubicBezier).init([this.p0, this.p01, this.p012, this.p0123]) */ split: { enumerable: false, - value: function(t) { + value: function (t) { this.makeScaffolding(t); return CubicBezier.create(CubicBezier).init([this.p0, this.p01, this.p012, this.p0123]); } }, /** - * @method + * @function * @param {number} t Control point. * @returns `CubicBezier.create(CubicBezier).init([new * Point().init(this.p01.x / xScale, this.p01.y / yScale), new @@ -82,7 +82,7 @@ var CubicBezier = exports.CubicBezier = Montage.specialize( /** @lends CubicBezi */ splitToTimingFunction: { enumerable: false, - value: function(t) { + value: function (t) { this.makeScaffolding(t); // p0123 x and y are the scale var xScale = this.p0123.x, @@ -92,12 +92,12 @@ var CubicBezier = exports.CubicBezier = Montage.specialize( /** @lends CubicBezi }, /** - * @method + * @function * @param {number} t Control point. */ makeScaffolding: { enumerable: false, - value: function(t) { + value: function (t) { t = 1 - t; diff --git a/core/geometry/point.js b/core/geometry/point.js index a41e6d74be..f4331e5296 100644 --- a/core/geometry/point.js +++ b/core/geometry/point.js @@ -12,7 +12,7 @@ var Montage = require("../core").Montage; exports.Point = Montage.specialize( /** @lends Point# */ { init: { enumerable: false, - value: function(x, y) { + value: function (x, y) { this.x = x === null ? 0 : x; this.y = y === null ? 0 : y; return this; @@ -52,7 +52,7 @@ exports.Point = Montage.specialize( /** @lends Point# */ { */ interpolate: { enumerable: false, - value: function(percent, point0, point1, precision) { + value: function (percent, point0, point1, precision) { var xValue, yValue; xValue = point0.x + (point1.x - point0.x) * percent; diff --git a/core/localizer.js b/core/localizer.js index a779318343..4724570b43 100644 --- a/core/localizer.js +++ b/core/localizer.js @@ -36,7 +36,7 @@ var KEY_KEY = "key", // filename of the manifest file MANIFEST_FILENAME = "manifest.json"; -var EMPTY_STRING_FUNCTION = function() { return ""; }; +var EMPTY_STRING_FUNCTION = function () { return ""; }; // This is not a strict match for the grammar in // http://tools.ietf.org/html/rfc5646, but it's good enough for our purposes. @@ -46,7 +46,7 @@ var reLanguageTagValidator = /^[a-zA-Z]+(?:-[a-zA-Z0-9]+)*$/; * @class Localizer * @extends Montage */ -var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ { +var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer.prototype # */ { constructor: { value: function Localizer() { @@ -55,13 +55,13 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ }, /** - * @method + * @function * @param {string} [locale] The RFC-5646 language tag this localizer * should use. Defaults to defaultLocalizer.locale * @returns {Localizer} The Localizer object it was called on. */ init: { - value: function(locale) { + value: function (locale) { this.locale = locale || defaultLocalizer.locale; return this; @@ -69,13 +69,13 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ }, /** - * @method + * @function * @param {string} locale The RFC-5646 language tag this localizer should use. * @param {Object} messages A map from keys to messages. Each message should either be a string or an object with a "message" property. * @returns {Localizer} The Localizer object it was called on. */ initWithMessages: { - value: function(locale, messages) { + value: function (locale, messages) { this.locale = locale; this.messages = messages; @@ -103,10 +103,10 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ * @default null */ messages: { - get: function() { + get: function () { return this._messages; }, - set: function(value) { + set: function (value) { if (this._messages !== value) { // != ok checking for undefined as well if (value != null && typeof value !== "object") { @@ -140,10 +140,10 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ * @default null */ locale: { - get: function() { + get: function () { return this._locale; }, - set: function(value) { + set: function (value) { if (!reLanguageTagValidator.test(value)) { throw new TypeError("Language tag '" + value + "' is not valid. It must match http://tools.ietf.org/html/rfc5646 (alphanumeric characters separated by hyphens)"); } @@ -165,12 +165,12 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ * @default null */ availableLocales: { - get: function() { + get: function () { if (this._availableLocales) { return this._availableLocales; } - return this._availableLocales = this._manifest.get("files").get(LOCALES_DIRECTORY).get("files").then(function(locales) { + return this._availableLocales = this._manifest.get("files").get(LOCALES_DIRECTORY).get("files").then(function (locales) { return Object.keys(locales); }); } @@ -191,10 +191,10 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ */ require: { serializable: false, - get: function() { + get: function () { return this._require; }, - set: function(value) { + set: function (value) { if (this._require !== value) { this.__manifest = null; this._require = value; @@ -214,7 +214,7 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ */ _manifest: { depends: ["require"], - get: function() { + get: function () { var messageRequire = this.require; if (messageRequire.packageDescription.manifest === true) { @@ -235,7 +235,7 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ /** * Load messages for the locale - * @method + * @function * @param {?number|boolean} [timeout=5000] Number of milliseconds to wait * before failing. Set to false for no timeout. * @param {Function} [callback] Called on successful loading of messages. @@ -243,7 +243,7 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ * @returns {Promise} A promise for the messages. */ loadMessages: { - value: function(timeout, callback) { + value: function (timeout, callback) { if (!this.require) { throw new Error("Cannot load messages as", this, "require is not set"); } @@ -261,17 +261,17 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ promise = promise.timeout(timeout); } - return this.messagesPromise = promise.get("files").then(function(files) { + return this.messagesPromise = promise.get("files").then(function (files) { return self._loadMessageFiles(files); - }).then(function(localesMessages) { + }).then(function (localesMessages) { return self._collapseMessages(localesMessages); - }).fail(function(error) { + }).fail(function (error) { console.error("Could not load messages for '" + self.locale + "': " + error); throw error; - }).then(function(messages) { + }).then(function (messages) { if (typeof callback === "function") { callback(messages); } @@ -284,7 +284,7 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ /** * Load the locale appropriate message files from the given manifest * structure. - * @method + * @function * @param {Object} files An object mapping directory (locale) names to * @returns {Promise} A promise that will be resolved with an array * containing the content of message files appropriate to this locale. @@ -292,7 +292,7 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ * @private */ _loadMessageFiles: { - value: function(files) { + value: function (files) { var messageRequire = this.require; if (!files) { @@ -343,7 +343,7 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ var promise = Promise.all(localesMessagesP); if (logger.isDebug) { var self = this; - promise = promise.then(function(localesMessages) { + promise = promise.then(function (localesMessages) { logger.debug(self, "loaded " + localesMessages.length + " message files"); return localesMessages; }); @@ -355,7 +355,7 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ /** * Collapse an array of message objects into one, earlier elements taking * precedence over later ones. - * @method + * @function * @param {Array} localesMessages * @returns {Object} An object mapping messages keys to the messages * @example @@ -365,7 +365,7 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ * @private */ _collapseMessages: { - value: function(localesMessages) { + value: function (localesMessages) { var messages = {}; // Go through each set of messages, adding any keys that haven't @@ -401,14 +401,14 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ * will not return the localized string. See `localize` for * method that works whether the messages have loaded or not. * - * @method + * @function * @param {string} key The key to the string in the {@link messages} object. * @param {string} defaultMessage The value to use if key does not exist. * @returns {Function} A function that accepts an object mapping variables * in the message string to values. */ localizeSync: { - value: function(key, defaultMessage) { + value: function (key, defaultMessage) { var message, type, compiled; if (!key && !defaultMessage) { @@ -447,7 +447,7 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ // and set it as its own toString so that it behaves a bit like // a string if (ast.program && ast.program.statements && ast.program.statements.length === 1 && ast.program.statements[0].type === "string") { - compiled = function() { return message; }; + compiled = function () { return message; }; compiled.toString = compiled; } else { compiled = (new Function('MessageFormat', 'return ' + this.messageFormat.precompile(ast))(MessageFormat)); @@ -488,7 +488,7 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ * }); * ``` * - * @method + * @function * @param {string} key The key to the string in the {@link messages} * object. * @param {string} defaultMessage The value to use if key does not exist. @@ -498,7 +498,7 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ * @returns {Promise} A promise that is resolved with the message function. */ localize: { - value: function(key, defaultMessage, defaultOnFail, callback) { + value: function (key, defaultMessage, defaultOnFail, callback) { var listener, deferred, promise, self = this; defaultOnFail = (typeof defaultOnFail === "undefined") ? true : defaultOnFail; @@ -508,7 +508,7 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ return promise; } - var l = function() { + var l = function () { var messageFn = self.localizeSync(key, defaultMessage); if (typeof callback === "function") { callback(messageFn); @@ -534,7 +534,7 @@ var Localizer = exports.Localizer = Montage.specialize( /** @lends Localizer# */ var DefaultLocalizer = Localizer.specialize( /** @lends DefaultLocalizer# */ { init: { - value: function() { + value: function () { var defaultLocale = this.callDelegateMethod("getDefaultLocale"); if (!defaultLocale && typeof window !== "undefined") { @@ -565,10 +565,10 @@ var DefaultLocalizer = Localizer.specialize( /** @lends DefaultLocalizer# */ { * @default null */ delegate: { - get: function() { + get: function () { return this._delegate; }, - set: function(value) { + set: function (value) { if (this._delegate !== value) { this._delegate = value; this.init(); @@ -577,10 +577,10 @@ var DefaultLocalizer = Localizer.specialize( /** @lends DefaultLocalizer# */ { }, locale: { - get: function() { + get: function () { return this._locale; }, - set: function(value) { + set: function (value) { try { Object.getPropertyDescriptor(Localizer.prototype, "locale").set.call(this, value); } catch (e) { @@ -597,11 +597,11 @@ var DefaultLocalizer = Localizer.specialize( /** @lends DefaultLocalizer# */ { /** * Reset the saved locale back to default by using the steps above. - * @method + * @function * @returns {string} the reset locale */ reset: { - value: function() { + value: function () { if (typeof window !== "undefined" && window.localStorage) { window.localStorage.removeItem(LOCALE_STORAGE_KEY); } @@ -644,13 +644,15 @@ exports.localize = defaultLocalizer.localize.bind(defaultLocalizer); * Tracks a message function and its data for changes in order to generate a * localized message. * - * @class MessageLocalizer + * @class Message * @extends Montage */ -var Message = exports.Message = Montage.specialize( /** @lends MessageLocalizer# */ { - +var Message = exports.Message = Montage.specialize( /** @lends Message.prototype # */ { + /** + * @constructs Message + */ constructor: { - value: function() { + value: function () { // _data Map needs to track changes on existing properties of // _dataObject, .toMap() provides this behaviour. // _dataObject is set in the data setter. @@ -660,7 +662,7 @@ var Message = exports.Message = Montage.specialize( /** @lends MessageLocalizer# }, /** - * @method + * @function * @param {string|function} keyOrFunction A messageformat string or a * function that takes an object argument mapping variables to values and * returns a string. Usually the output of Localizer#localize. @@ -668,7 +670,7 @@ var Message = exports.Message = Montage.specialize( /** @lends MessageLocalizer# * @returns {Message} this. */ init: { - value: function(key, defaultMessage, data) { + value: function (key, defaultMessage, data) { if (key) this.key = key; if (defaultMessage) this.defaultMessage = defaultMessage; if (data) this.data = data; @@ -682,10 +684,10 @@ var Message = exports.Message = Montage.specialize( /** @lends MessageLocalizer# }, localizer: { - get: function() { + get: function () { return this._localizer; }, - set: function(value) { + set: function (value) { if (this._localizer == value) { return; } @@ -704,10 +706,10 @@ var Message = exports.Message = Montage.specialize( /** @lends MessageLocalizer# * @default null */ key: { - get: function() { + get: function () { return this._key; }, - set: function(value) { + set: function (value) { if (this._key === value) { return; } @@ -722,10 +724,10 @@ var Message = exports.Message = Montage.specialize( /** @lends MessageLocalizer# }, defaultMessage: { - get: function() { + get: function () { return this._defaultMessage; }, - set: function(value) { + set: function (value) { if (this._defaultMessage === value) { return; } @@ -739,7 +741,7 @@ var Message = exports.Message = Montage.specialize( /** @lends MessageLocalizer# }, _localize: { - value: function() { + value: function () { // Optimization: only run this function in the next tick. So that // if the key, defaultKey and data are set individually we don't // try and localize each time. @@ -758,7 +760,7 @@ var Message = exports.Message = Montage.specialize( /** @lends MessageLocalizer# return fn(self._data.toObject()); }); - Promise.nextTick(function() { + Promise.nextTick(function () { self._isLocalizeQueued = false; if (!self._key && !self._defaultMessage) { @@ -810,10 +812,10 @@ var Message = exports.Message = Montage.specialize( /** @lends MessageLocalizer# // Receives an object literal and creates a Map that tracks it. data: { - get: function() { + get: function () { return this._data; }, - set: function(value) { + set: function (value) { if (this._dataObject === value) { return; } @@ -837,10 +839,10 @@ var Message = exports.Message = Montage.specialize( /** @lends MessageLocalizer# @default "" */ localized: { - get: function() { + get: function () { return this._localizedDeferred.promise; }, - set: function(value) { + set: function (value) { if (value === this._localized) { return; } @@ -868,13 +870,13 @@ var Message = exports.Message = Montage.specialize( /** @lends MessageLocalizer# * @private */ handleDataMapChange: { - value: function(event) { + value: function (event) { this.localized = this._messageFunction.fcall(this._data.toObject()); } }, serializeSelf: { - value: function(serializer) { + value: function (serializer) { var result = { _bindingDescriptors: this._bindingDescriptors }; @@ -893,7 +895,7 @@ var Message = exports.Message = Montage.specialize( /** @lends MessageLocalizer# }, serializeForLocalizations: { - value: function(serializer) { + value: function (serializer) { var result = {}, data, bindings; @@ -948,10 +950,10 @@ var Message = exports.Message = Montage.specialize( /** @lends MessageLocalizer# }, _serializeBinding: { - value: function(object, output, input, serializer) { + value: function (object, output, input, serializer) { //bindingsParameters = ["<-", "<->", "source", "revert", "convert", "trace", "serializable"]; // - //bindingsParameters.forEach(function(key) { + //bindingsParameters.forEach(function (key) { // if (key in binding) { // data[key] = binding[key]; // } @@ -996,7 +998,7 @@ var Message = exports.Message = Montage.specialize( /** @lends MessageLocalizer# } }); -var createMessageBinding = function(object, prop, key, defaultMessage, data, deserializer) { +var createMessageBinding = function (object, prop, key, defaultMessage, data, deserializer) { var message = new Message(); for (var d in data) { @@ -1036,7 +1038,7 @@ var createMessageBinding = function(object, prop, key, defaultMessage, data, des }); }; -Serializer.defineSerializationUnit("localizations", function(serializer, object) { +Serializer.defineSerializationUnit("localizations", function (serializer, object) { var bindingDescriptors = FrbBindings.getBindings(object); if (bindingDescriptors) { @@ -1055,7 +1057,7 @@ Serializer.defineSerializationUnit("localizations", function(serializer, object) } }); -Deserializer.defineDeserializationUnit("localizations", function(deserializer, object, properties) { +Deserializer.defineDeserializationUnit("localizations", function (deserializer, object, properties) { for (var prop in properties) { var desc = properties[prop], key, diff --git a/core/logger.js b/core/logger.js index 378c402cce..77a563fe36 100644 --- a/core/logger.js +++ b/core/logger.js @@ -14,7 +14,7 @@ var Montage = require("./core").Montage, loggers = exports.loggers = {}; -getFunctionName = function(montageObject) { +getFunctionName = function (montageObject) { var aCaller = getFunctionName.caller.caller, aFunctionName; aFunctionName = aCaller.name; @@ -24,7 +24,7 @@ getFunctionName = function(montageObject) { return aFunctionName; }; -toTimeString = function(date) { +toTimeString = function (date) { if (date.getHours) { var hours = date.getHours(), mins = date.getMinutes(), @@ -33,10 +33,10 @@ toTimeString = function(date) { } }; -emptyLoggerFunction = function() { +emptyLoggerFunction = function () { }; -consoleLog = function() { +consoleLog = function () { console.log(arguments); }; @@ -54,13 +54,13 @@ Logger = exports.Logger = Montage.specialize(/** @lends Logger# */ { }, /** - * @method + * @function * @param {string} name The name of the logger. * @param {State} [dontStoreState=false] If true, don't store the isDebug state of the logger in localStorage . * @returns itself */ init: { - value: function(name, onStateChange, dontStoreState) { + value: function (name, onStateChange, dontStoreState) { this.name = name; this._onStateChange = onStateChange; this._storeState = !dontStoreState; @@ -108,7 +108,7 @@ Logger = exports.Logger = Montage.specialize(/** @lends Logger# */ { * Log all the contents the logger's buffer. */ flush: { - value: function() { + value: function () { var buffer = this.buffer, args, i; @@ -123,10 +123,10 @@ Logger = exports.Logger = Montage.specialize(/** @lends Logger# */ { * @type {boolean} */ isDebug: { - get: function() { + get: function () { return this.debug !== emptyLoggerFunction; }, - set: function(value) { + set: function (value) { if (value) { this.debug = this._consoleLogMontage; } else { @@ -140,10 +140,10 @@ Logger = exports.Logger = Montage.specialize(/** @lends Logger# */ { * @type {boolean} */ isError: { - get: function() { + get: function () { return this.error !== emptyLoggerFunction; }, - set: function(value) { + set: function (value) { if (value) { this.error = this._consoleLogMontage; } else { @@ -153,7 +153,7 @@ Logger = exports.Logger = Montage.specialize(/** @lends Logger# */ { }, _consoleLogMontage: { - value: function() { + value: function () { var firstArgument = arguments[0], //jshint -W106 metadata = firstArgument._montage_metadata, @@ -208,7 +208,7 @@ Logger = exports.Logger = Montage.specialize(/** @lends Logger# */ { }, /** - * @method Logger#debug + * @function Logger#debug * @param {Function|String} object If the first argument is a function the logger with print its name * @param {string} [...] */ @@ -217,7 +217,7 @@ Logger = exports.Logger = Montage.specialize(/** @lends Logger# */ { }, /** - * @method Logger#error + * @function Logger#error * @param {Function|String} object If the first argument is a function the logger with print its name * @param {string} [...] */ @@ -226,7 +226,7 @@ Logger = exports.Logger = Montage.specialize(/** @lends Logger# */ { }, /** - * @method Logger#toTimeString + * @function Logger#toTimeString * @description Prints the current time in format HH:MM:SS.000 */ toTimeString: { @@ -248,8 +248,8 @@ function addColorProperty (logger) { return this; }; for (var name in SOLARIZED_COLORS) { - _color[name] = function(name) { - return function() { + _color[name] = function (name) { + return function () { return logger.color(SOLARIZED_COLORS[name]); } }(name); @@ -279,7 +279,7 @@ var SOLARIZED_COLORS = { /** * @function module:montage/core/logger#logger */ -exports.logger = function(loggerName, onStateChange, dontStoreState) { +exports.logger = function (loggerName, onStateChange, dontStoreState) { var logger; if ((logger = loggers[loggerName]) == null) { logger = new Logger().init(loggerName, onStateChange, dontStoreState); @@ -299,7 +299,7 @@ LoggerUI = Montage.specialize( /** @lends LoggerUI# */{ }, init: { - value: function() { + value: function () { if (document.nativeAddEventListener) { document.nativeAddEventListener("keyup", this, false); document.nativeAddEventListener("keydown", this, false); @@ -336,7 +336,7 @@ LoggerUI = Montage.specialize( /** @lends LoggerUI# */{ }, keyup: { - value: function(event) { + value: function (event) { if (event.which == 17) { this.isCtrl = false; } @@ -347,7 +347,7 @@ LoggerUI = Montage.specialize( /** @lends LoggerUI# */{ }, keydown: { - value: function(event) { + value: function (event) { if (event.which == 17) { this.isCtrl = true; } @@ -366,7 +366,7 @@ LoggerUI = Montage.specialize( /** @lends LoggerUI# */{ }, change: { - value: function(event) { + value: function (event) { var value = event.target.checked, name = event.target.value, logger = loggers[name]; @@ -381,13 +381,13 @@ LoggerUI = Montage.specialize( /** @lends LoggerUI# */{ }, mouseup: { - value: function(event) { + value: function (event) { this.hideInspector(); } }, showInspector: { - value: function() { + value: function () { if (! this.inspectorElement) { var i = 0, iLogger, @@ -483,7 +483,7 @@ LoggerUI = Montage.specialize( /** @lends LoggerUI# */{ }, hideInspector: { - value: function() { + value: function () { if (document.getElementById("_montage_logger_inspector")) { this.shown = false; this.m_dontRemove.removeChild(this.inspectorElement); @@ -495,7 +495,7 @@ LoggerUI = Montage.specialize( /** @lends LoggerUI# */{ handleEvent: { enumerable: false, - value: function(event) { + value: function (event) { if (this[event.type]) { this[event.type](event); } @@ -503,7 +503,7 @@ LoggerUI = Montage.specialize( /** @lends LoggerUI# */{ } }); -var setupUI = function() { +var setupUI = function () { new LoggerUI().init(); }; if (typeof window !== "undefined") { diff --git a/core/media-controller.js b/core/media-controller.js index ecafa9dff2..9f67056174 100644 --- a/core/media-controller.js +++ b/core/media-controller.js @@ -156,7 +156,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med }, /** - * @method + * @function */ play: { value: function () { @@ -178,7 +178,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med }, /** - * @method + * @function */ pause: { value: function () { @@ -192,7 +192,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med }, /** - * @method + * @function */ unpause: { value: function () { @@ -209,7 +209,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med }, /** - * @method + * @function * @returns {boolean} !playing (true if it is now playing) */ playPause: { @@ -301,7 +301,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med }, /** - * @method + * @function */ rewind: { value: function () { @@ -316,7 +316,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med }, /** - * @method + * @function */ fastForward: { value: function () { @@ -331,7 +331,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med }, /** - * @method + * @function */ stop: { value: function () { @@ -378,7 +378,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med }, /** - * @method + * @function */ volumeIncrease: { value: function () { @@ -387,7 +387,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med }, /** - * @method + * @function */ volumeDecrease: { value: function () { @@ -396,7 +396,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med }, /** - * @method + * @function */ toggleMute: { value: function () { @@ -424,7 +424,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med -----------------------------------------------------------------------------*/ /** - * @method + * @function * @returns itself */ handleLoadedmetadata: { @@ -455,7 +455,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med }, /** - * @method + * @function */ handleTimeupdate: { value: function () { @@ -470,7 +470,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med }, /** - * @method + * @function */ handlePlay: { value: function () { @@ -482,7 +482,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med }, /** - * @method + * @function */ handlePlaying: { value: function () { @@ -494,7 +494,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med }, /** - * @method + * @function */ handlePause: { value: function () { @@ -513,7 +513,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med }, /** - * @method + * @function */ handleEnded: { value: function () { @@ -528,7 +528,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med }, /** - * @method + * @function */ handleAbort: { value: function () { @@ -540,7 +540,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med }, /** - * @method + * @function * @param {Event} event TODO */ handleError: { @@ -575,7 +575,7 @@ var MediaController = exports.MediaController = Target.specialize(/** @lends Med }, /** - * @method + * @function */ handleEmptied: { value: function () { diff --git a/core/messageformat-locale.js b/core/messageformat-locale.js index 6ee0902975..f7e43287f3 100644 --- a/core/messageformat-locale.js +++ b/core/messageformat-locale.js @@ -1,11 +1,11 @@ // jshint -W015, -W106 -exports.am = function(n) { +exports.am = function (n) { if (n === 0 || n == 1) { return 'one'; } return 'other'; }; -exports.ar = function(n) { +exports.ar = function (n) { if (n === 0) { return 'zero'; } @@ -137,7 +137,7 @@ exports.fi = function ( n ) { } return "other"; }; -exports.fil = function(n) { +exports.fil = function (n) { if (n === 0 || n == 1) { return 'one'; } @@ -182,7 +182,7 @@ exports.he = function ( n ) { } return "other"; }; -exports.hi = function(n) { +exports.hi = function (n) { if (n === 0 || n == 1) { return 'one'; } @@ -202,13 +202,13 @@ exports.hr = function (n) { } return 'other'; }; -exports.hu = function(n) { +exports.hu = function (n) { return 'other'; }; -exports.id = function(n) { +exports.id = function (n) { return 'other'; }; -exports["in"] = function(n) { +exports["in"] = function (n) { return 'other'; }; exports.is = function ( n ) { @@ -247,7 +247,7 @@ exports.lag = function (n) { } return 'other'; }; -exports.ln = function(n) { +exports.ln = function (n) { if (n === 0 || n == 1) { return 'one'; } @@ -378,7 +378,7 @@ exports.ru = function (n) { } return 'other'; }; -exports.shi = function(n) { +exports.shi = function (n) { if (n >= 0 && n <= 1) { return 'one'; } @@ -455,13 +455,13 @@ exports.te = function ( n ) { exports.th = function ( n ) { return "other"; }; -exports.tl = function(n) { +exports.tl = function (n) { if (n === 0 || n == 1) { return 'one'; } return 'other'; }; -exports.tr = function(n) { +exports.tr = function (n) { return 'other'; }; exports.uk = function (n) { diff --git a/core/messageformat.js b/core/messageformat.js index efe593a164..b77d1c3492 100644 --- a/core/messageformat.js +++ b/core/messageformat.js @@ -1,16 +1,14 @@ // jshint -W015, -W106 + /** - * @module montage/core/messageformat - */ -/** - * messageformat.js - * * ICU PluralFormat + SelectFormat for JavaScript * + * @module montage/core/messageformat * @author Alex Sexton - @SlexAxton * @version 0.1.5 - * @license WTFPL - * @contributor_license Dojo CLA + * @license MIT + * @see https://github.com/SlexAxton/messageformat.js + * @todo https://github.com/montagejs/montage/issues/1539 */ (function ( root ) { @@ -52,7 +50,7 @@ // Build out our basic SafeString type // more or less stolen from Handlebars by @wycats - MessageFormat.SafeString = function( string ) { + MessageFormat.SafeString = function ( string ) { this.string = string; }; @@ -76,7 +74,7 @@ }, badChars = /[\n"]/g, possible = /[\n"]/, - escapeChar = function(chr) { + escapeChar = function (chr) { return escape[chr] || "&"; }; @@ -93,7 +91,7 @@ } return string.replace( badChars, escapeChar ); }, - getFallbackLocale: function( locale ) { + getFallbackLocale: function ( locale ) { var tagSeparator = locale.indexOf("-") >= 0 ? "-" : "_"; // Lets just be friends, fallback through the language tags @@ -109,7 +107,7 @@ }; // This is generated and pulled in for browsers. - var mparser = (function(){ + var mparser = (function (){ /* Generated by PEG.js 0.6.2 (http://pegjs.majda.cz/). */ var result = { @@ -119,7 +117,7 @@ * which the parser was generated (see |PEG.buildParser|). If the parsing is * unsuccessful, throws |PEG.parser.SyntaxError| describing the error. */ - parse: function(input, startRule) { + parse: function (input, startRule) { var parseFunctions = { "_": parse__, "char": parse_char, @@ -223,7 +221,7 @@ var savedPos0 = pos; var result1 = parse_messageFormatPattern(); var result2 = result1 !== null - ? (function(messageFormatPattern) { return { type: "program", program: messageFormatPattern }; })(result1) + ? (function (messageFormatPattern) { return { type: "program", program: messageFormatPattern }; })(result1) : null; if (result2 !== null) { var result0 = result2; @@ -271,7 +269,7 @@ pos = savedPos1; } var result2 = result1 !== null - ? (function(s1, inner) { + ? (function (s1, inner) { var st = []; if ( s1 && s1.val ) { st.push( s1 ); @@ -365,7 +363,7 @@ pos = savedPos1; } var result2 = result1 !== null - ? (function(mfe, s1) { + ? (function (mfe, s1) { var res = []; if ( mfe ) { res.push(mfe); @@ -439,7 +437,7 @@ pos = savedPos1; } var result2 = result1 !== null - ? (function(argIdx, efmt) { + ? (function (argIdx, efmt) { var res = { type: "messageFormatElement", argumentIndex: argIdx @@ -540,7 +538,7 @@ pos = savedPos3; } var result13 = result12 !== null - ? (function(t, s) { + ? (function (t, s) { return { type : "elementFormat", key : t, @@ -619,7 +617,7 @@ pos = savedPos1; } var result3 = result2 !== null - ? (function(t, s) { + ? (function (t, s) { return { type : "elementFormat", key : t, @@ -661,7 +659,7 @@ var savedPos0 = pos; var result1 = parse_pluralFormatPattern(); var result2 = result1 !== null - ? (function(pfp) { + ? (function (pfp) { return { type: "pluralStyle", val: pfp }; })(result1) : null; @@ -693,7 +691,7 @@ var savedPos0 = pos; var result1 = parse_selectFormatPattern(); var result2 = result1 !== null - ? (function(sfp) { + ? (function (sfp) { return { type: "selectStyle", val: sfp }; })(result1) : null; @@ -744,7 +742,7 @@ pos = savedPos1; } var result2 = result1 !== null - ? (function(op, pf) { + ? (function (op, pf) { var res = { type: "pluralFormatPattern", pluralForms: pf @@ -845,7 +843,7 @@ pos = savedPos1; } var result2 = result1 !== null - ? (function(d) { + ? (function (d) { return d; })(result1[5]) : null; @@ -882,7 +880,7 @@ var result3 = parse_pluralForms(); } var result2 = result1 !== null - ? (function(pf) { + ? (function (pf) { return { type: "selectFormatPattern", pluralForms: pf @@ -982,7 +980,7 @@ pos = savedPos1; } var result2 = result1 !== null - ? (function(k, mfp) { + ? (function (k, mfp) { return { type: "pluralForms", key: k, @@ -1018,7 +1016,7 @@ var savedPos2 = pos; var result7 = parse_id(); var result8 = result7 !== null - ? (function(i) { + ? (function (i) { return i; })(result7) : null; @@ -1055,7 +1053,7 @@ pos = savedPos1; } var result3 = result2 !== null - ? (function(d) { + ? (function (d) { return d; })(result2[1]) : null; @@ -1149,7 +1147,7 @@ pos = savedPos1; } var result2 = result1 !== null - ? (function(ws, s) { + ? (function (ws, s) { var tmp = []; for( var i = 0; i < s.length; ++i ) { for( var j = 0; j < s[ i ].length; ++j ) { @@ -1244,7 +1242,7 @@ pos = savedPos1; } var result2 = result1 !== null - ? (function(s1, s2) { + ? (function (s1, s2) { return s1 + (s2 ? s2.join('') : ''); })(result1[1], result1[2]) : null; @@ -1285,7 +1283,7 @@ var result1 = null; } var result2 = result1 !== null - ? (function(chars) { return chars.join(''); })(result1) + ? (function (chars) { return chars.join(''); })(result1) : null; if (result2 !== null) { var result0 = result2; @@ -1323,7 +1321,7 @@ } } var result20 = result19 !== null - ? (function(x) { + ? (function (x) { return x; })(result19) : null; @@ -1347,7 +1345,7 @@ } } var result17 = result16 !== null - ? (function() { + ? (function () { return "\\#"; })() : null; @@ -1371,7 +1369,7 @@ } } var result14 = result13 !== null - ? (function() { + ? (function () { return "\u007B"; })() : null; @@ -1395,7 +1393,7 @@ } } var result11 = result10 !== null - ? (function() { + ? (function () { return "\u007D"; })() : null; @@ -1450,7 +1448,7 @@ pos = savedPos1; } var result3 = result2 !== null - ? (function(h1, h2, h3, h4) { + ? (function (h1, h2, h3, h4) { return String.fromCharCode(parseInt("0x" + h1 + h2 + h3 + h4)); })(result2[1], result2[2], result2[3], result2[4]) : null; @@ -1516,7 +1514,7 @@ var result1 = null; } var result2 = result1 !== null - ? (function(ds) { + ? (function (ds) { return parseInt((ds.join('')), 10); })(result1) : null; @@ -1582,7 +1580,7 @@ var result3 = parse_whitespace(); } var result2 = result1 !== null - ? (function(w) { return w.join(''); })(result1) + ? (function (w) { return w.join(''); })(result1) : null; if (result2 !== null) { var result0 = result2; @@ -1736,12 +1734,12 @@ }, /* Returns the parser source code. */ - toSource: function() { return this._source; } + toSource: function () { return this._source; } }; /* Thrown when a parser encounters a syntax error. */ - result.SyntaxError = function(message, line, column) { + result.SyntaxError = function (message, line, column) { this.name = 'SyntaxError'; this.message = message; this.line = line; @@ -1838,7 +1836,7 @@ tmp = 1; } s += '"' + ast.pluralForms[ i ].key + '" : ' + interpMFP( ast.pluralForms[ i ].val, - (function(){ var res = JSON.parse(JSON.stringify(data)); res.pf_count++; return res; })() ); + (function (){ var res = JSON.parse(JSON.stringify(data)); res.pf_count++; return res; })() ); } s += '\n};\n'; if ( needOther ) { @@ -1863,7 +1861,7 @@ tmp = 1; } s += '"' + ast.pluralForms[ i ].key + '" : ' + interpMFP( ast.pluralForms[ i ].val, - (function(){ + (function (){ var res = JSON.parse( JSON.stringify( data ) ); res.pf_count++; return res; @@ -1908,7 +1906,7 @@ exports.MessageFormat = MessageFormat; } else if (typeof define === 'function' && define.amd) { - define(function() { + define(function () { return MessageFormat; }); } diff --git a/core/meta/association-blueprint.js b/core/meta/association-blueprint.js index 0f59138128..457451dac6 100644 --- a/core/meta/association-blueprint.js +++ b/core/meta/association-blueprint.js @@ -23,14 +23,14 @@ exports.AssociationBlueprint = PropertyBlueprint.specialize( /** @lends Associat }, serializeSelf: { - value: function(serializer) { + value: function (serializer) { serializer.setProperty("targetBlueprint", this._targetBlueprintReference); PropertyBlueprint.serializeSelf.call(this, serializer); } }, deserializeSelf: { - value: function(deserializer) { + value: function (deserializer) { PropertyBlueprint.deserializeSelf.call(this, deserializer); this._targetBlueprintReference = deserializer.getProperty("targetBlueprint"); } @@ -51,10 +51,10 @@ exports.AssociationBlueprint = PropertyBlueprint.specialize( /** @lends Associat */ targetBlueprint: { serializable: false, - get: function() { + get: function () { return this._targetBlueprintReference.promise(this.require); }, - set: function(blueprint) { + set: function (blueprint) { this._targetBlueprintReference = new BlueprintReference().initWithValue(blueprint); } }, @@ -64,7 +64,7 @@ exports.AssociationBlueprint = PropertyBlueprint.specialize( /** @lends Associat * @default false */ isAssociationBlueprint: { - get: function() { + get: function () { return true; } } diff --git a/core/meta/binder-manager.js b/core/meta/binder-manager.js index 618bbfe1bb..bb459ecdce 100644 --- a/core/meta/binder-manager.js +++ b/core/meta/binder-manager.js @@ -3,25 +3,28 @@ /** * @module montage/core/meta/binder-manager * @requires montage/core/core - * @requires core/exception - * @requires core/promise - * @requires core/logger + * @requires montage/core/meta/object-property + * @requires montage/core/promise + * @requires montage/core/meta/binder + * @requires montage/core/logger */ -var Montage = require("../core").Montage; -var Promise = require("../promise").Promise; -var ObjectProperty = require("./object-property").ObjectProperty; -var BinderModule = require("./binder"); - -var logger = require("../logger").logger("blueprint"); +var Montage = require("../core").Montage, + Promise = require("../promise").Promise, + ObjectProperty = require("./object-property").ObjectProperty, + BinderModule = require("./binder"), + logger = require("../logger").logger("blueprint"); /** * @class BinderManager * @classdesc A blueprint binder manager is a singleton that is responsible for * loading and dispaching binders and blueprints. + * * @extends Montage */ -var BinderManager = exports.BinderManager = Montage.specialize( /** @lends BinderManager# */ { - +var BinderManager = exports.BinderManager = Montage.specialize( /** @lends BinderManager.prototype # */ { + /** + * @constructs BinderManager + */ constructor: { value: function BinderManager() { this._binders = []; @@ -29,33 +32,42 @@ var BinderManager = exports.BinderManager = Montage.specialize( /** @lends Binde } }, + /** + * @private + * @property {Array} value + */ _binders: { value: null }, + /** + * @private + */ _binderTable: { value: null }, /** * Return the list of binder registered on the manager. + * * @readonly - * @type {Array.} + * @returns {Array.} */ binders: { - get: function() { + get: function () { return this._binders; } }, /** - * Add a new blueprint binder. - * @method + * Add a new blueprint binder + * + * @function * @param {Binder} binder */ addBinder: { - value: function(binder) { + value: function (binder) { if (binder !== null) { if (this._binderTable[binder.name]) { this.removeBinder(this._binderTable[binder.name]); @@ -71,11 +83,11 @@ var BinderManager = exports.BinderManager = Montage.specialize( /** @lends Binde }, /** - * @method + * @function * @param {Binder} binder */ removeBinder: { - value: function(binder) { + value: function (binder) { if (binder !== null) { var index = this._binders.indexOf(binder); if (index >= 0) { @@ -93,21 +105,21 @@ var BinderManager = exports.BinderManager = Montage.specialize( /** @lends Binde * @param {string} name */ binderForName: { - value: function(name) { + value: function (name) { return this._binderTable[name]; } }, /** * Search through the binders for a blueprint that extends that prototype. - * @method + * @function * @param {string} prototypeName * @param {string} moduleId * @returns The requested blueprint or null if this prototype is not * managed. */ blueprintForPrototype: { - value: function(prototypeName, moduleId) { + value: function (prototypeName, moduleId) { var binder, blueprint, index; for (index = 0; typeof (binder = this.binders[index]) !== "undefined"; index++) { blueprint = binder.blueprintForPrototype(prototypeName, moduleId); @@ -119,6 +131,9 @@ var BinderManager = exports.BinderManager = Montage.specialize( /** @lends Binde } }, + /** + * @private + */ _defaultBlueprintObjectProperty: { serializable: true, value: null @@ -127,11 +142,12 @@ var BinderManager = exports.BinderManager = Montage.specialize( /** @lends Binde /** * Return the default blueprint object property. * This is the last resort property declaration object. + * * @readonly - * @type {ObjectProperty} default blueprint object property + * @returns {ObjectProperty} default blueprint object property */ defaultBlueprintObjectProperty: { - get: function() { + get: function () { if (!this._defaultBlueprintObjectProperty) { this._defaultBlueprintObjectProperty = new ObjectProperty().init(); } @@ -147,11 +163,12 @@ var BinderManager = exports.BinderManager = Montage.specialize( /** @lends Binde /** * Return the default blueprint object property. * This is the last resort property declaration object. + * * @readonly - * @type {ObjectProperty} default blueprint object property + * @returns {ObjectProperty} default blueprint object property */ defaultBinder: { - get: function() { + get: function () { if (!this._defaultBinder) { this._defaultBinder = new BinderModule.Binder().initWithNameAndRequire("default", self.mr); this._defaultBinder.isDefault = true; diff --git a/core/meta/binder-reference.js b/core/meta/binder-reference.js index 8f0737a32a..5c44f7a643 100644 --- a/core/meta/binder-reference.js +++ b/core/meta/binder-reference.js @@ -29,7 +29,7 @@ exports.BinderReference = RemoteReference.create(RemoteReference, { * @type {string} */ identifier: { - get: function() { + get: function () { if (!this._reference) { this._reference = this.referenceFromValue(this._value); } @@ -42,7 +42,7 @@ exports.BinderReference = RemoteReference.create(RemoteReference, { }, valueFromReference: { - value: function(references, require) { + value: function (references, require) { var binderName = references.binderName; var binderModuleId = references.binderModuleId; @@ -73,7 +73,7 @@ exports.BinderReference = RemoteReference.create(RemoteReference, { }, referenceFromValue: { - value: function(value) { + value: function (value) { var references = {}; references.binderName = value.name; references.binderModuleId = value.binderModuleId; diff --git a/core/meta/binder.js b/core/meta/binder.js index 2adcde3dc2..3c718b39d0 100644 --- a/core/meta/binder.js +++ b/core/meta/binder.js @@ -1,4 +1,5 @@ "use strict"; + /** * @module montage/core/meta/binder * @requires montage/core/core @@ -20,12 +21,14 @@ var _binderManager = null; /** * @class Binder * @classdesc A blueprint binder is a collection of of blueprints for a - * specific access type. - * It also includes the connection information. + * specific access type. It also includes the connection information. + * * @extends Montage */ -var Binder = exports.Binder = Montage.specialize( /** @lends Binder# */ { - +var Binder = exports.Binder = Montage.specialize( /** @lends Binder.prototype # */ { + /** + * @constructs Binder + */ constructor: { value: function Binder() { this.superForValue("constructor")(); @@ -38,12 +41,12 @@ var Binder = exports.Binder = Montage.specialize( /** @lends Binder# */ { }, /** - * @method + * @function * @param {string} name * @returns itself */ initWithNameAndRequire: { - value: function(name, _require) { + value: function (name, _require) { if (!name) throw new Error("name is required"); if (!_require) throw new Error("require is required"); @@ -55,7 +58,7 @@ var Binder = exports.Binder = Montage.specialize( /** @lends Binder# */ { }, serializeSelf: { - value: function(serializer) { + value: function (serializer) { serializer.setProperty("name", this.name); if (this.blueprints.length > 0) { serializer.setProperty("blueprints", this.blueprints); @@ -65,7 +68,7 @@ var Binder = exports.Binder = Montage.specialize( /** @lends Binder# */ { }, deserializeSelf: { - value: function(deserializer) { + value: function (deserializer) { this._name = deserializer.getProperty("name"); //copy contents into the blueprints array var value = deserializer.getProperty("blueprints"); @@ -83,15 +86,18 @@ var Binder = exports.Binder = Montage.specialize( /** @lends Binder# */ { /** * Name of the object. * The name is used to define the property on the object. - * @method + * @function * @type {string} */ name: { - get: function() { + get: function () { return this._name; } }, + /** + * @private + */ _require: { value: null }, @@ -101,14 +107,17 @@ var Binder = exports.Binder = Montage.specialize( /** @lends Binder# */ { * All blueprints added must be in this require's package, or in a direct * dependency. * @readonly - * @type {function} a package's `require` function + * @returns {function} a package's `require` function */ require: { - get: function() { + get: function () { return this._require; } }, + /** + * @private + */ _blueprintForPrototypeTable: { distinct:true, value: {} @@ -117,10 +126,10 @@ var Binder = exports.Binder = Montage.specialize( /** @lends Binder# */ { /** * The identifier is the name of the binder and is used to make the * serialization of binders more readable. - * @type {string} + * @returns {string} */ identifier: { - get: function() { + get: function () { return [ "binder", this.name.toLowerCase() @@ -155,16 +164,16 @@ var Binder = exports.Binder = Montage.specialize( /** @lends Binder# */ { /** * The list of blueprints in this binder. * @readonly - * @type {Array.} + * @returns {Array.} */ blueprints: { - get: function() { + get: function () { return this._blueprints; } }, /** - * @method + * @function * @param {?Blueprint} blueprint * @returns blueprint */ @@ -185,12 +194,12 @@ var Binder = exports.Binder = Montage.specialize( /** @lends Binder# */ { }, /** - * @method + * @function * @param {Blueprint} blueprint * @returns blueprint */ removeBlueprint: { - value: function(blueprint) { + value: function (blueprint) { if (blueprint !== null) { var index = this.blueprints.indexOf(blueprint); if (index >= 0) { @@ -203,7 +212,7 @@ var Binder = exports.Binder = Montage.specialize( /** @lends Binder# */ { }, /** - * @method + * @function * @param {string} name * @param {string} moduleID * @returns {Blueprint} The new blueprint @@ -216,7 +225,7 @@ var Binder = exports.Binder = Montage.specialize( /** @lends Binder# */ { /** * Return the blueprint associated with this prototype. - * @method + * @function * @param {string} prototypeName * @param {string} moduleId * @returns {?Blueprint} blueprint @@ -243,6 +252,9 @@ var Binder = exports.Binder = Montage.specialize( /** @lends Binder# */ { } }, + /** + * @private + */ _blueprintObjectProperty: { value: null }, @@ -253,7 +265,7 @@ var Binder = exports.Binder = Montage.specialize( /** @lends Binder# */ { * @type {ObjectProperty} */ ObjectProperty: { - get: function() { + get: function () { if (!this._blueprintObjectProperty) { this._blueprintObjectProperty = Binder.manager.defaultBlueprintObjectProperty; } @@ -269,10 +281,10 @@ var Binder = exports.Binder = Montage.specialize( /** @lends Binder# */ { /** * Returns the blueprint binder manager. - * @type {BinderManager} + * @returns {BinderManager} */ manager: { - get: function() { + get: function () { if (_binderManager === null) { _binderManager = new BinderManager(); } diff --git a/core/meta/blueprint-reference.js b/core/meta/blueprint-reference.js index 7919795f1a..aacdb5ef5b 100644 --- a/core/meta/blueprint-reference.js +++ b/core/meta/blueprint-reference.js @@ -31,7 +31,7 @@ exports.BlueprintReference = RemoteReference.specialize( { * @default this.name */ identifier: { - get: function() { + get: function () { if (!this._reference) { this._reference = this.referenceFromValue(this._value); } @@ -44,7 +44,7 @@ exports.BlueprintReference = RemoteReference.specialize( { }, valueFromReference: { - value: function(references, targetRequire) { + value: function (references, targetRequire) { var blueprintName = references.blueprintName; var blueprintModule = references.blueprintModule; var prototypeName = references.prototypeName; @@ -56,7 +56,7 @@ exports.BlueprintReference = RemoteReference.specialize( { binderPromise = BinderReference.valueFromReference(binderReference, require); } - return binderPromise.then(function(binder) { + return binderPromise.then(function (binder) { if (binder) { var ModuleBlueprintModule = require("./module-blueprint"); return ModuleBlueprintModule.ModuleBlueprint.getBlueprintWithModuleId(blueprintModule.id, blueprintModule.require).then(function (blueprint) { @@ -75,7 +75,7 @@ exports.BlueprintReference = RemoteReference.specialize( { }, referenceFromValue: { - value: function(value) { + value: function (value) { // the value is a blueprint we need to serialize the binder and the blueprint reference var references = {}; references.blueprintName = value.name; diff --git a/core/meta/blueprint.js b/core/meta/blueprint.js index 91c3729228..e218e19ab2 100644 --- a/core/meta/blueprint.js +++ b/core/meta/blueprint.js @@ -1,4 +1,5 @@ "use strict"; + /** * @module montage/core/meta/blueprint * @requires montage/core/core @@ -19,18 +20,18 @@ var DerivedPropertyBlueprint = require("./derived-property-blueprint").DerivedPr var EventBlueprint = require("./event-blueprint").EventBlueprint; var PropertyValidationRule = require("./validation-rule").PropertyValidationRule; var deprecate = require("../deprecate"); - var logger = require("../logger").logger("blueprint"); var Defaults = { - name:"default", - customPrototype:false + name: "default", + customPrototype: false }; /** * @class Blueprint + * @extends Montage */ -var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ { +var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint.prototype # */ { FileExtension: { value: ".meta" @@ -45,12 +46,12 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ }, /** - * @method + * @function * @param {string} name The name of the blueprint * @returns itself */ initWithName: { - value: function(name) { + value: function (name) { this._name = (name !== null ? name : "default"); this.customPrototype = false; @@ -59,7 +60,7 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ }, /** - * @method + * @function * @param {string} name * @param {string} moduleId * @returns itself @@ -157,10 +158,10 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ * * This is an accessor. It is not writable or observable. * - * @type {string} this._name + * @returns {string} this._name */ name: { - get: function() { + get: function () { return this._name; } }, @@ -171,13 +172,13 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ * Newly created prototype will be blessed with all the required properties * to be well behaved. * - * @method + * @function * @param {Object} prototype * @param {Object} propertyDescriptor * @returns newPrototype */ create: { - value: function(aPrototype, propertyDescriptor) { + value: function (aPrototype, propertyDescriptor) { if ((typeof aPrototype === "undefined") || (Blueprint.prototype.isPrototypeOf(aPrototype))) { var parentCreate = Object.getPrototypeOf(Blueprint).create; return parentCreate.call(this, (typeof aPrototype === "undefined" ? this : aPrototype), propertyDescriptor); @@ -192,11 +193,11 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ /** * Create a new instance of the target prototype for the blueprint. - * @method - * @return new instance + * @function + * @returns new instance */ newInstance: { - value: function() { + value: function () { var prototype = this.newInstancePrototype(); return (prototype ? new prototype() : null); } @@ -208,21 +209,21 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ * **Note:** This method uses the `customPrototype` property to determine * if it needs to require a custom prototype or create a default prototype. * - * @method - * @return new prototype + * @function + * @returns new prototype */ newInstancePrototype: { - value: function() { + value: function () { // FIXME this function is no missing all the data it needs var self = this; if (this.customPrototype) { throw new Error("FIXME"); var results = Promise.defer(); require.async(this.moduleId, - function(exports) { + function (exports) { results.resolve(exports); }); - return results.promise.then(function(exports) { + return results.promise.then(function (exports) { var prototype = exports[self.prototypeName]; return (prototype ? prototype : null); } @@ -232,7 +233,7 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ var newConstructor = Montage.create(parentInstancePrototype, { // Token class init: { - value: function() { + value: function () { return this; } } @@ -249,12 +250,12 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ * * This will return the default if none is declared. * - * @type {ObjectProperty} + * @returns {ObjectProperty} */ ObjectProperty: { serializable: false, enumerable: true, - get: function() { + get: function () { if (this.binder) { return this.binder.ObjectProperty; } @@ -283,11 +284,11 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ /** * The identifier is the same as the name and is used to make the * serialization of a blueprint humane. - * @type {string} + * @returns {string} * @default `this.name` */ identifier: { - get: function() { + get: function () { // TODO convert UpperCase to lower-case instead of lowercase return [ "blueprint", @@ -301,19 +302,19 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ }, /** - * @type {Property} + * @returns {Property} * @default null */ binder: { serializable: false, - get: function() { + get: function () { if (! this._binder) { this._binder = BinderModule.Binder.manager.defaultBinder; this._binder.addBlueprint(this); } return this._binder; }, - set: function(value) { + set: function (value) { this._binder = value; } }, @@ -328,14 +329,14 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ /** * Blueprint parent - * @type {?BlueprintReference} + * @returns {?BlueprintReference} */ parent: { serializable: false, - get: function() { + get: function () { return this._parent; }, - set: function(blueprint) { + set: function (blueprint) { if (blueprint) { this._parentReference = new BlueprintReference().initWithValue(blueprint); this._parent = blueprint; @@ -371,7 +372,7 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ * Is `true` if the blueprint needs to require a custom prototype for * creating new instances, `false` if new instance are generic prototypes. * - * @type {boolean} + * @property {boolean} value * @default false */ customPrototype: { @@ -384,10 +385,10 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ }, /** - * @type {Array.} + * @returns {Array.} */ propertyBlueprints: { - get: function() { + get: function () { var propertyBlueprints = []; propertyBlueprints = propertyBlueprints.concat(this._propertyBlueprints); if (this.parent) { @@ -409,13 +410,13 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ * If that property blueprint was associated with another blueprint it will * be removed first. * - * @method + * @function * @param {PropertyBlueprint} property blueprint The property blueprint to * be added. * @returns the property blueprint */ addPropertyBlueprint: { - value: function(propertyBlueprint) { + value: function (propertyBlueprint) { if (propertyBlueprint !== null && propertyBlueprint.name !== null) { var index = this._propertyBlueprints.indexOf(propertyBlueprint); if (index < 0) { @@ -435,13 +436,13 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ * Removes a property blueprint from the property blueprint list of this * blueprint. * - * @method + * @function * @param {PropertyBlueprint} property blueprint The property blueprint to * be removed. * @returns the same property blueprint */ removePropertyBlueprint: { - value: function(propertyBlueprint) { + value: function (propertyBlueprint) { if (propertyBlueprint !== null && propertyBlueprint.name !== null) { var index = this._propertyBlueprints.indexOf(propertyBlueprint); if (index >= 0) { @@ -464,7 +465,7 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ * @returns {PropertyBlueprint} */ newPropertyBlueprint: { - value: function(name, cardinality) { + value: function (name, cardinality) { return new PropertyBlueprint().initWithNameBlueprintAndCardinality(name, this, cardinality); } }, @@ -478,7 +479,7 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ * @returns {AssociationBlueprint} */ newAssociationBlueprint: { - value: function(name, cardinality) { + value: function (name, cardinality) { return new AssociationBlueprint().initWithNameBlueprintAndCardinality(name, this, cardinality); } }, @@ -492,44 +493,44 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ * @returns {DerivedPropertyBlueprint} */ newDerivedPropertyBlueprint: { - value: function(name, cardinality) { + value: function (name, cardinality) { return new DerivedPropertyBlueprint().initWithNameBlueprintAndCardinality(name, this, cardinality); } }, /** * Convenience to add one property blueprint. - * @method + * @function * @param {string} name Add to one property blueprint * @returns {PropertyBlueprint} */ addToOnePropertyBlueprintNamed: { - value: function(name) { + value: function (name) { return this.addPropertyBlueprint(this.newPropertyBlueprint(name, 1)); } }, /** * Convenience to add many property blueprints. - * @method + * @function * @param {string} name Add to many property blueprints * @returns {PropertyBlueprint} */ addToManyPropertyBlueprintNamed: { - value: function(name) { + value: function (name) { return this.addPropertyBlueprint(this.newPropertyBlueprint(name, Infinity)); } }, /** * Convenience to add an property blueprint to one relationship. - * @method + * @function * @param {string} name * @param {string} inverse * @returns {AssociationBlueprint} */ addToOneAssociationBlueprintNamed: { - value: function(name, inverse) { + value: function (name, inverse) { var relationship = this.addPropertyBlueprint(this.newAssociationBlueprint(name, 1)); if (inverse) { relationship.targetBlueprint = inverse.owner; @@ -541,13 +542,13 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ /** * Convenience to add an property blueprint to many relationships. - * @method + * @function * @param {string} name TODO * @param {string} inverse TODO * @returns {AssociationBlueprint} */ addToManyAssociationBlueprintNamed: { - value: function(name, inverse) { + value: function (name, inverse) { var relationship = this.addPropertyBlueprint(this.newAssociationBlueprint(name, Infinity)); if (inverse) { relationship.targetBlueprint = inverse.owner; @@ -558,12 +559,12 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ }, /** - * @method + * @function * @param {string} name * @returns {PropertyBlueprint} */ propertyBlueprintForName: { - value: function(name) { + value: function (name) { var propertyBlueprint = this._propertyBlueprintsTable[name]; if (typeof propertyBlueprint === "undefined") { propertyBlueprint = UnknownPropertyBlueprint; @@ -594,10 +595,10 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ /** * List of properties blueprint groups names - * @type {Array.} + * @returns {Array.} */ propertyBlueprintGroups: { - get: function() { + get: function () { var groups = []; for (var name in this._propertyBlueprintGroups) { groups.push(name); @@ -615,7 +616,7 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ * @returns {Array.} property blueprint group */ propertyBlueprintGroupForName: { - value: function(groupName) { + value: function (groupName) { var group = this._propertyBlueprintGroups[groupName]; if ((! group) && (this.parent)) { group = this.parent.propertyBlueprintGroupForName(groupName); @@ -626,12 +627,12 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ /** * Add a new property blueprint group. - * @method + * @function * @param {string} name of the group * @returns {Array.} new property blueprint group */ addPropertyBlueprintGroupNamed: { - value: function(groupName) { + value: function (groupName) { var group = this._propertyBlueprintGroups[groupName]; if (group == null) { group = []; @@ -643,12 +644,12 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ /** * Remove the property blueprint group. - * @method + * @function * @param {string} name of the group to remove * @returns {Array.} removed property blueprint group */ removePropertyBlueprintGroupNamed: { - value: function(groupName) { + value: function (groupName) { var group = this._propertyBlueprintGroups[groupName]; if (group != null) { delete this._propertyBlueprintGroups[groupName]; @@ -660,13 +661,13 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ /** * Adds a property blueprint to the group name. * if the group does not exist creates it. - * @method + * @function * @param {string} property to add * @param {string} name of the group * @returns {Array.} property blueprint group */ addPropertyBlueprintToGroupNamed: { - value: function(propertyBlueprint, groupName) { + value: function (propertyBlueprint, groupName) { var group = this._propertyBlueprintGroups[groupName]; if (group == null) { group = this.addPropertyBlueprintGroupNamed(groupName); @@ -681,13 +682,13 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ /** * Removes a property blueprint from the group name. - * @method + * @function * @param {string} name of the property * @param {string} name of the group * @returns {Array.} property blueprint group */ removePropertyBlueprintFromGroupNamed: { - value: function(propertyBlueprint, groupName) { + value: function (propertyBlueprint, groupName) { var group = this._propertyBlueprintGroups[groupName]; if ((group != null) && (propertyBlueprint != null)) { var index = group.indexOf(propertyBlueprint); @@ -704,7 +705,7 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ }, /** - * @type {?Array.} + * @property {Array.} value */ eventBlueprints: { value: null @@ -723,12 +724,12 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ * If that property blueprint was associated with another blueprint it will * be removed first. * - * @method + * @function * @param {string} property blueprint The property blueprint to be added. * @returns {PropertyBlueprint} */ addEventBlueprint: { - value: function(eventBlueprint) { + value: function (eventBlueprint) { if (eventBlueprint !== null && eventBlueprint.name !== null) { var index = this._eventBlueprints.indexOf(eventBlueprint); if (index < 0) { @@ -747,12 +748,12 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ /** * Removes an property blueprint from the property blueprint list of this * blueprint. - * @method + * @function * @param {Object} property blueprint The property blueprint to be removed. * @returns {PropertyBlueprint} */ removeEventBlueprint: { - value: function(eventBlueprint) { + value: function (eventBlueprint) { if (eventBlueprint !== null && eventBlueprint.name !== null) { var index = this._eventBlueprints.indexOf(eventBlueprint); if (index >= 0) { @@ -772,7 +773,7 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ * @param {string} name name of the event blueprint to create */ newEventBlueprint: { - value: function(name) { + value: function (name) { return new EventBlueprint().initWithNameAndBlueprint(name, this); } }, @@ -780,23 +781,23 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ /** * Convenience to add an event blueprint. - * @method + * @function * @param {string} name * @returns {EventBlueprint} */ addEventBlueprintNamed: { - value: function(name, inverse) { + value: function (name, inverse) { return this.addEventBlueprint(this.newEventBlueprint(name)); } }, /** - * @method + * @function * @param {string} name * @returns {EventBlueprint} */ eventBlueprintForName: { - value: function(name) { + value: function (name) { var eventBlueprint = this._eventBlueprintsTable[name]; if (typeof eventBlueprint === "undefined") { eventBlueprint = UnknownEventBlueprint; @@ -827,11 +828,11 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ /** * Gets the list of properties validation rules. - * @return {Array.} copy of the list of properties + * @returns {Array.} copy of the list of properties * validation rules. */ propertyValidationRules: { - get: function() { + get: function () { var propertyValidationRules = []; for (var name in this._propertyValidationRules) { propertyValidationRules.push(this._propertyValidationRules[name]); @@ -849,7 +850,7 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ * @returns {PropertyDescription} property description */ propertyValidationRuleForName: { - value: function(name) { + value: function (name) { var propertyValidationRule = this._propertyValidationRules[name]; if ((! propertyValidationRule) && (this.parent)) { propertyValidationRule = this.parent.propertyValidationRuleForName(name); @@ -860,12 +861,12 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ /** * Add a new properties validation rule . - * @method + * @function * @param {string} name of the rule * @returns {PropertyDescription} new properties validation rule */ addPropertyValidationRule: { - value: function(name) { + value: function (name) { var propertyValidationRule = this._propertyValidationRules[name]; if (propertyValidationRule == null) { propertyValidationRule = new PropertyValidationRule().initWithNameAndBlueprint(name, this); @@ -877,12 +878,12 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ /** * Remove the properties validation rule for the name. - * @method + * @function * @param {string} name of the rule * @returns {PropertyDescription} removed properties validation rule */ removePropertyValidationRule: { - value: function(name) { + value: function (name) { var propertyValidationRule = this._propertyValidationRules[name]; if (propertyValidationRule != null) { delete this._propertyValidationRules[name]; @@ -894,11 +895,11 @@ var Blueprint = exports.Blueprint = Montage.specialize( /** @lends Blueprint# */ /** * Evaluates the rules based on the object and the properties. * @param {Object} object instance to evaluate the rule for - * @return {Array.} list of message key for rule that fired. Empty + * @returns {Array.} list of message key for rule that fired. Empty * array otherwise. */ evaluateRules: { - value: function(objectInstance) { + value: function (objectInstance) { var messages = []; for (var name in this._propertyValidationRules) { var rule = this._propertyValidationRules[name]; diff --git a/core/meta/derived-property-blueprint.js b/core/meta/derived-property-blueprint.js index deb3244fb6..1a976a64e2 100644 --- a/core/meta/derived-property-blueprint.js +++ b/core/meta/derived-property-blueprint.js @@ -30,7 +30,7 @@ exports.DerivedPropertyBlueprint = PropertyBlueprint.specialize( /** @lends Deri }, serializeSelf: { - value: function(serializer) { + value: function (serializer) { if (this.dependencies.length > 0) { this._setPropertyWithDefaults(serializer, "dependencies", this.dependencies); } @@ -40,7 +40,7 @@ exports.DerivedPropertyBlueprint = PropertyBlueprint.specialize( /** @lends Deri }, deserializeSelf: { - value: function(deserializer) { + value: function (deserializer) { this.dependencies = this._getPropertyWithDefaults(deserializer, "dependencies"); this.getterDefinition = this._getPropertyWithDefaults(deserializer, "getterDefinition"); this.setterDefinition = this._getPropertyWithDefaults(deserializer, "setterDefinition"); @@ -67,7 +67,7 @@ exports.DerivedPropertyBlueprint = PropertyBlueprint.specialize( /** @lends Deri * @default true */ isDerived: { - get: function() { + get: function () { return true; }, serializable: false diff --git a/core/meta/module-blueprint.js b/core/meta/module-blueprint.js index e0081eb169..c11bfb2c1a 100644 --- a/core/meta/module-blueprint.js +++ b/core/meta/module-blueprint.js @@ -20,7 +20,7 @@ var ModuleBlueprint = exports.ModuleBlueprint = Blueprint.specialize(/** @lends * @returns this */ initWithModuleAndExportName: { - value: function(module, exportName) { + value: function (module, exportName) { var self = Blueprint.prototype.initWithName.call(this, exportName); self.module = module; @@ -37,7 +37,7 @@ var ModuleBlueprint = exports.ModuleBlueprint = Blueprint.specialize(/** @lends }, serializeSelf: { - value: function(serializer) { + value: function (serializer) { if (!this.module) { throw new Error("Cannot serialize blueprint without a module reference"); } @@ -52,7 +52,7 @@ var ModuleBlueprint = exports.ModuleBlueprint = Blueprint.specialize(/** @lends }, deserializeSelf: { - value: function(deserializer) { + value: function (deserializer) { this.super(deserializer); this.module = deserializer.getProperty("module"); this.exportName = deserializer.getProperty("exportName"); @@ -91,7 +91,7 @@ var ModuleBlueprint = exports.ModuleBlueprint = Blueprint.specialize(/** @lends * @param {function} require function */ getBlueprintWithModuleId: { - value: function(moduleId, _require) { + value: function (moduleId, _require) { if (moduleId.search(/\.meta$/) === -1) { throw new Error(moduleId + " blueprint module id does not end in '.meta'"); } @@ -124,7 +124,7 @@ var ModuleBlueprint = exports.ModuleBlueprint = Blueprint.specialize(/** @lends // Load parent "synchronously" so that all the properties // through the blueprint chain are available return blueprint._parentReference.promise(targetRequire) // MARK - .then(function(parentBlueprint) { + .then(function (parentBlueprint) { blueprint._parent = parentBlueprint; return blueprint; }); diff --git a/core/meta/object-property.js b/core/meta/object-property.js index 7c30c1a6f7..72b5603cfa 100644 --- a/core/meta/object-property.js +++ b/core/meta/object-property.js @@ -27,7 +27,7 @@ var ObjectProperty = exports.ObjectProperty = Montage.specialize( /** @lends Obj }, /** - * @method + * @function * @returns itself */ init: { @@ -44,7 +44,7 @@ var ObjectProperty = exports.ObjectProperty = Montage.specialize( /** @lends Obj * If the blueprint is null, this method will make a best attempt to locate * it. * - * @method + * @function * @param {Object} prototype * @param {Blueprint} blueprint */ @@ -71,7 +71,7 @@ var ObjectProperty = exports.ObjectProperty = Montage.specialize( /** @lends Obj * * **Note:** This method will explore the blueprint hierarchy recursively. * - * @method + * @function * @param {Object} prototype * @param {Blueprint} blueprint */ @@ -89,7 +89,7 @@ var ObjectProperty = exports.ObjectProperty = Montage.specialize( /** @lends Obj /** * Add all the properties defined in the blueprint to the target prototype. * - * @method + * @function * @param {Object} prototype * @param {Blueprint} blueprint */ @@ -121,7 +121,7 @@ var ObjectProperty = exports.ObjectProperty = Montage.specialize( /** @lends Obj /** * Add one property defined in the attribute to the target prototype. * - * @method + * @function * @param {Prototype} prototype * @param {Attribute} attribute */ @@ -134,7 +134,7 @@ var ObjectProperty = exports.ObjectProperty = Montage.specialize( /** @lends Obj }, /** - * @method + * @function * @param {Object} prototype * @param {Attribute} attribute */ @@ -167,7 +167,7 @@ var ObjectProperty = exports.ObjectProperty = Montage.specialize( /** @lends Obj }, /** - * @method + * @function * @param {Property} prototype TODO * @param {Object} attribute TODO */ @@ -201,7 +201,7 @@ var ObjectProperty = exports.ObjectProperty = Montage.specialize( /** @lends Obj * This is the get function called on the target object to access * properties. * - * @method + * @function * @param {string} propertyName * @returns {PropertyBlueprint} */ @@ -219,7 +219,7 @@ var ObjectProperty = exports.ObjectProperty = Montage.specialize( /** @lends Obj * This is the get function called on the target object to set * properties. * - * @method + * @function * @param {string} propertyName * @param {PropertyBlueprint} value */ @@ -238,7 +238,7 @@ var ObjectProperty = exports.ObjectProperty = Montage.specialize( /** @lends Obj }, /** - * @method + * @function * @param {Object} prototype * @param {Attribute} attribute */ @@ -272,7 +272,7 @@ var ObjectProperty = exports.ObjectProperty = Montage.specialize( /** @lends Obj /** * Adds a relationship management methods to the managed object. - * @method + * @function * @param {Object} prototype * @param {Attribute} attribute relationship to add */ @@ -286,7 +286,7 @@ var ObjectProperty = exports.ObjectProperty = Montage.specialize( /** @lends Obj /** - * @method + * @function * @param {Object} prototype * @param {Attribute} attribute */ @@ -301,7 +301,7 @@ var ObjectProperty = exports.ObjectProperty = Montage.specialize( /** @lends Obj }, /** - * @method + * @function * @param {Object} prototype * @param {Attribute} attribute */ @@ -342,7 +342,7 @@ var ObjectProperty = exports.ObjectProperty = Montage.specialize( /** @lends Obj }, /** - * @method + * @function * @param {Object} prototype * @param {Association} attribute */ @@ -384,7 +384,7 @@ var ObjectProperty = exports.ObjectProperty = Montage.specialize( /** @lends Obj /** * Adds a derived attribute to the managed object. - * @method + * @function * @param {Object} prototype * @param {Attribute} attribute */ diff --git a/core/meta/property-blueprint.js b/core/meta/property-blueprint.js index 76092712ae..ba6d475348 100644 --- a/core/meta/property-blueprint.js +++ b/core/meta/property-blueprint.js @@ -44,7 +44,7 @@ exports.PropertyBlueprint = Montage.specialize( /** @lends PropertyBlueprint# */ /** * Initialize a newly allocated property blueprint. - * @method + * @function * @param {string} name name of the property blueprint to create * @param {Blueprint} blueprint * @param {number} cardinality name of the property blueprint to create diff --git a/core/meta/remote-reference.js b/core/meta/remote-reference.js index b652bb11dd..032192630c 100644 --- a/core/meta/remote-reference.js +++ b/core/meta/remote-reference.js @@ -23,7 +23,7 @@ exports.RemoteReference = Montage.specialize({ }, initWithValue: { - value: function(value) { + value: function (value) { this._value = value; this._reference = null; this._promise = null; @@ -32,7 +32,7 @@ exports.RemoteReference = Montage.specialize({ }, serializeSelf: { - value: function(serializer) { + value: function (serializer) { if (!this._reference) { this._reference = this.referenceFromValue(this._value); } @@ -41,7 +41,7 @@ exports.RemoteReference = Montage.specialize({ }, deserializeSelf: { - value: function(deserializer) { + value: function (deserializer) { this._value = null; this._reference = deserializer.getProperty("valueReference"); this._promise = null; @@ -61,7 +61,7 @@ exports.RemoteReference = Montage.specialize({ }, promise: { - value: function(iRequire) { + value: function (iRequire) { if (!this._promise) { if (this._value) { this._promise = Promise.resolve(this._value); @@ -82,7 +82,7 @@ exports.RemoteReference = Montage.specialize({ * @param {boolean} isRequire */ valueFromReference: { - value: function(reference, iRequire) { + value: function (reference, iRequire) { return Promise.resolve(null); } }, @@ -94,7 +94,7 @@ exports.RemoteReference = Montage.specialize({ * subtypes. */ referenceFromValue: { - value: function(value) { + value: function (value) { return {}; } }, diff --git a/core/meta/validation-rule.js b/core/meta/validation-rule.js index 56c8ebd39b..a47e515bbf 100644 --- a/core/meta/validation-rule.js +++ b/core/meta/validation-rule.js @@ -26,13 +26,13 @@ var PropertyValidationRule = exports.PropertyValidationRule = Montage.specialize /** * Initialize a newly allocated blueprint validation rule. - * @method + * @function * @param {string} rule name * @param {Blueprint} blueprint * @returns itself */ initWithNameAndBlueprint: { - value: function(name, blueprint) { + value: function (name, blueprint) { this._name = name; this._owner = blueprint; return this; @@ -40,7 +40,7 @@ var PropertyValidationRule = exports.PropertyValidationRule = Montage.specialize }, serializeSelf: { - value: function(serializer) { + value: function (serializer) { serializer.setProperty("name", this.name); serializer.setProperty("blueprint", this.owner, "reference"); // serializer.setProperty("validationSelector", this._validationSelector, "reference"); @@ -50,7 +50,7 @@ var PropertyValidationRule = exports.PropertyValidationRule = Montage.specialize }, deserializeSelf: { - value: function(deserializer) { + value: function (deserializer) { this._name = deserializer.getProperty("name"); this._owner = deserializer.getProperty("blueprint"); // this._validationSelector = deserializer.getProperty("validationSelector"); @@ -74,7 +74,7 @@ var PropertyValidationRule = exports.PropertyValidationRule = Montage.specialize * @type {Blueprint} */ owner: { - get: function() { + get: function () { return this._owner; } }, @@ -84,7 +84,7 @@ var PropertyValidationRule = exports.PropertyValidationRule = Montage.specialize * @type {string} */ identifier: { - get: function() { + get: function () { return [ this.blueprint.identifier, "rule", @@ -101,7 +101,7 @@ var PropertyValidationRule = exports.PropertyValidationRule = Montage.specialize * Name of the property being described */ name: { - get: function() { + get: function () { return this._name; } }, @@ -117,13 +117,13 @@ var PropertyValidationRule = exports.PropertyValidationRule = Montage.specialize */ validationSelector: { serializable: false, - get: function() { + get: function () { if (!this._validationSelector) { this._validationSelector = Selector['false']; } return this._validationSelector; }, - set: function(value) { + set: function (value) { this._validationSelector = value; } }, @@ -137,13 +137,13 @@ var PropertyValidationRule = exports.PropertyValidationRule = Montage.specialize */ messageKey: { serializable: false, - get: function() { + get: function () { if ((!this._messageKey) || (this._messageKey.length === 0)) { return this._name; } return this._messageKey; }, - set: function(value) { + set: function (value) { this._messageKey = value; } }, @@ -152,13 +152,13 @@ var PropertyValidationRule = exports.PropertyValidationRule = Montage.specialize value: null }, - /* + /** * Evaluates the rules based on the blueprint and the properties. * @param {Object} object instance to evaluate the rule for - * @return {boolean} true if the rules fires, false otherwise. + * @returns {boolean} true if the rules fires, false otherwise. */ evaluateRule: { - value: function(objectInstance) { + value: function (objectInstance) { if (this._propertyValidationEvaluator === null) { var propertyValidationSemantics = new PropertyValidationSemantics().initWithBlueprint(this.blueprint); this._propertyValidationEvaluator = propertyValidationSemantics.compile(this.selector.syntax); diff --git a/core/meta/validation-semantics.js b/core/meta/validation-semantics.js index 88991a78a5..aba3185a4d 100644 --- a/core/meta/validation-semantics.js +++ b/core/meta/validation-semantics.js @@ -27,12 +27,12 @@ var PropertyValidationSemantics = exports.PropertyValidationSemantics = Semantic /** * Create a new semantic evaluator with the blueprint. - * @method + * @function * @param {Blueprint} blueprint * @returns itself */ initWithBlueprint: { - value: function(blueprint) { + value: function (blueprint) { this._blueprint = blueprint; return this; } @@ -46,7 +46,7 @@ var PropertyValidationSemantics = exports.PropertyValidationSemantics = Semantic * Component description attached to this validation rule. */ blueprint: { - get: function() { + get: function () { return this._blueprint; } }, @@ -54,19 +54,19 @@ var PropertyValidationSemantics = exports.PropertyValidationSemantics = Semantic /** * Compile the syntax tree into a function that can be used for evaluating * this selector. - * @method + * @function * @param {Selector} selector syntax * @returns function */ compile: { - value: function(syntax, parents) { + value: function (syntax, parents) { Semantics.compile.call(this, syntax, parents); } }, operators: { value: { - isBound: function(a) { + isBound: function (a) { return !a; } } @@ -74,9 +74,9 @@ var PropertyValidationSemantics = exports.PropertyValidationSemantics = Semantic evaluators: { value: { - isBound: function(collection, modify) { + isBound: function (collection, modify) { var self = this; - return function(value, parameters) { + return function (value, parameters) { value = self.count(collection(value, parameters)); return modify(value, parameters); }; diff --git a/core/module-reference.js b/core/module-reference.js index 0c4816702f..3abb06cdfd 100644 --- a/core/module-reference.js +++ b/core/module-reference.js @@ -1,11 +1,17 @@ - +/** + * @module montage/core/module-reference + * @requires montage/core/core + */ var Montage = require("./core").Montage; /** * @class ModuleReference * @extends Montage */ -exports.ModuleReference = Montage.specialize( /** @lends ModuleReference */ { +exports.ModuleReference = Montage.specialize( /** @lends ModuleReference.prototype */ { + /** + * @constructs ModuleReference + */ constructor: { value: function ModuleReference() { return this.super(); @@ -26,7 +32,7 @@ exports.ModuleReference = Montage.specialize( /** @lends ModuleReference */ { /** * The absolute id of the module within the `require` package - * @type {string} + * @property {string} value */ id: { value: null @@ -34,7 +40,7 @@ exports.ModuleReference = Montage.specialize( /** @lends ModuleReference */ { /** * The require of a package. - * @type {function} + * @property {function} value */ require: { value: null @@ -46,7 +52,8 @@ exports.ModuleReference = Montage.specialize( /** @lends ModuleReference */ { /** * A promise for the exports of the module. The exports are loaded lazily * when the property is accessed. - * @type {Promise.} The exports of the module. + * + * @returns {Promise.} The exports of the module. */ exports: { get: function () { @@ -60,16 +67,19 @@ exports.ModuleReference = Montage.specialize( /** @lends ModuleReference */ { /** * Resolves this module reference so that it can be required from * otherRequire. - * @method - * @param {function} otherRequire Require from another package that has + * + * @function + * @param {function} otherRequire - Require from another package that has * the package of this module as a dependency. * @returns {string} The module id to pass to otherRequire that results * in this module. * @throws {Error} If there is no mapping from this require inside * otherRequire. + * * @example * var ref = new ModuleReference().initWithIdAndRequire("core/uuid", montageRequire); * ref.resolve(applicationRequire); // => "montage/core/uuid" + * * @example * var ref = new ModuleReference().initWithIdAndRequire("ui/main.reel", applicationRequire); * ref.resolve(montageRequire); // => Error diff --git a/core/object-controller.js b/core/object-controller.js index 768fedadab..239a676b49 100644 --- a/core/object-controller.js +++ b/core/object-controller.js @@ -28,23 +28,23 @@ var ObjectController = exports.ObjectController = Montage.specialize( /** @lends }, /** - * @method + * @function * @returns new this.objectPrototype() */ newObject: { enumerable: false, - value: function() { + value: function () { return new this.objectPrototype(); } }, /** - * @method + * @function * @param {Property} content TODO * @returns itself */ initWithContent: { - value: function(content) { + value: function (content) { this.content = content; return this; } diff --git a/core/radio-button-controller.js b/core/radio-button-controller.js index 2cf3ddc5fd..6daa3be32d 100644 --- a/core/radio-button-controller.js +++ b/core/radio-button-controller.js @@ -57,13 +57,13 @@ exports.RadioButtonController = Montage.specialize(/** @lends RadioButtonControl * The currently-selected option. */ value: { - set: function(value) { + set: function (value) { if (this._value !== value) { this._value = value; this._updateRadioButtons(); } }, - get: function() { + get: function () { return this._value; } }, @@ -80,7 +80,7 @@ exports.RadioButtonController = Montage.specialize(/** @lends RadioButtonControl }, _updateRadioButtons: { - value: function() { + value: function () { var value = this._value; for (var i = 0, ii = this._radioButtons.length; i < ii; i++) { @@ -94,12 +94,12 @@ exports.RadioButtonController = Montage.specialize(/** @lends RadioButtonControl /** * Add a radio button to be managed by this controller. - * @method + * @function * @param {RadioButton} radioButton * @returns {undefined} */ registerRadioButton: { - value: function(radioButton) { + value: function (radioButton) { if (this._radioButtons.indexOf(radioButton) === -1) { this._radioButtons.push(radioButton); this._updateRadioButtons(); @@ -109,12 +109,12 @@ exports.RadioButtonController = Montage.specialize(/** @lends RadioButtonControl /** * Remove a radio button from being managed by this controller. - * @method + * @function * @param {RadioButton} radioButton * @returns {undefined} */ unregisterRadioButton: { - value: function(radioButton) { + value: function (radioButton) { var ix = this._radioButtons.indexOf(radioButton); if (ix >= 0) { this._radioButtons.splice(ix, 1); @@ -126,7 +126,7 @@ exports.RadioButtonController = Montage.specialize(/** @lends RadioButtonControl }, handleRadioButtonChange: { - value: function(plus, minus, index) { + value: function (plus, minus, index) { if (plus[0] === true) { for (var i = 0, ii = this._radioButtons.length; i < ii; i++) { if (i === index) { diff --git a/core/range-controller.js b/core/range-controller.js index 14d2531b93..81c0381abf 100644 --- a/core/range-controller.js +++ b/core/range-controller.js @@ -1,3 +1,6 @@ +/** + * @module montage/core/range-controller + */ var Montage = require("./core").Montage; var GenericCollection = require("collections/generic-collection"); @@ -23,55 +26,60 @@ var GenericCollection = require("collections/generic-collection"); // the same position. /** - * A `RangeSelection` is a special kind of `Array` that knows about a `RangeController` + * @const {Array} + */ +var EMPTY_ARRAY = Object.freeze([]); + +/** + * A `_RangeSelection` is a special kind of `Array` that knows about a `RangeController` * and maintains invariants about itself relative to the properties of the - * `RangeController`. A `RangeSelection` should only be modified using the `splice` + * `RangeController`. A `_RangeSelection` should only be modified using the `splice` * method. Changes by directly using other `Array` methods can break the invariants. - * @class RangeSelection + * + * @class _RangeSelection * @private */ - -var EMPTY_ARRAY = Object.freeze([]); - -var RangeSelection = function(content, rangeController) { +var _RangeSelection = function (content, rangeController) { var self = content.clone(); self.makeObservable(); self.rangeController = rangeController; self.contentEquals = content && content.contentEquals || Object.is; Object.defineProperty(self, "clone", { - value: function(){ + value: function () { return self.slice(); } }); - + + var oldSwap = self.swap; + /** - * @method swap - * @param {number} start - * @param {number} howMany - * @param {object...} itemsToAdd * A custom version of swap to ensure that changes obey the RangeController * invariants: * - if rC.multiSelect is false, only allow one item in set. * - if rC.avoidsEmtySelection is true, require at least one item in set. * - only add items that are present in rC.content * - enforce uniqueness of items according to the contentEquals of the content + * + * @function swap + * @param {number} start + * @param {number} howMany + * @param {Object} itemsToAdd + * */ - var oldSwap = self.swap; Object.defineProperty(self, "swap", { configurable: false, - value: function(start, howMany, itemsToAdd) { + value: function (start, howMany, itemsToAdd) { var content = this.rangeController.content; this.contentEquals = content && content.contentEquals || Object.is; start = start >= 0 ? start : this.length + start; var oldLength = this.length; var minusLength = Math.min(howMany, oldLength - start); - if(itemsToAdd) { - + if (itemsToAdd) { itemsToAdd.contentEquals = this.contentEquals; - - var plus = itemsToAdd.filter(function(item, index){ + + var plus = itemsToAdd.filter(function (item, index) { // do not add items to the selection if they aren't in content if (content && !content.has(item)) { return false; @@ -94,14 +102,15 @@ var RangeSelection = function(content, rangeController) { plus = EMPTY_ARRAY; } - var minus; if (minusLength === 0) { // minus will be empty minus = EMPTY_ARRAY; } else { + // `this` may not have .slice method; .call assumes `this` is array-like minus = Array.prototype.slice.call(this, start, start + minusLength); } + var diff = plus.length - minus.length; var newLength = Math.max(this.length + diff, start + plus.length); var args; @@ -120,7 +129,7 @@ var RangeSelection = function(content, rangeController) { } else { args = [start, howMany, plus]; } - + return oldSwap.apply(this, args); } }); @@ -159,12 +168,14 @@ var RangeSelection = function(content, rangeController) { * typically an Array for for a [Repetition]{@link Repetition}. * @extends Montage */ -var RangeController = exports.RangeController = Montage.specialize( /** @lends RangeController# */ { - +var RangeController = exports.RangeController = Montage.specialize( /** @lends RangeController.prototype # */ { + /** + * @constructs RangeController + */ constructor: { value: function RangeController(content) { this.content = null; - this._selection = new RangeSelection([], this); + this._selection = new _RangeSelection([], this); this.sortPath = null; this.filterPath = null; @@ -224,9 +235,9 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R /** * Initializes a range controller with a backing collection. - * @method - * @param content Any collection that produces range change events, like an - * `Array` or `SortedSet`. + * + * @function + * @param {Array|SortedSet} content - Any collection that produces range change events * @returns this */ initWithContent: { @@ -243,13 +254,15 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R * An FRB expression that determines how to sort the content, like "name" * to sort by name. * If the `sortPath` is null, the content is not sorted. - * @type {?string} + * + * @property {string} value */ sortPath: {value: null}, /** * Whether to reverse the order of the sorted content. - * @type {?boolean} + * + * @property {boolean} value */ reversed: {value: null}, @@ -257,7 +270,8 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R * An FRB expression that determines how to filter content like * "name.startsWith('A')" to see only names starting with 'A'. * If the `filterPath` is null, all content is accepted. - * @type {?string} + * + * @property {string} value */ filterPath: {value: null}, @@ -265,7 +279,8 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R * An array of indexes to pluck from the ordered and filtered content. * The output will be an array of the corresponding content. * If the `visibleIndexes` is null, all content is accepted. - * @type {?Array.} + * + * @property {Array.} */ visibleIndexes: {value: null}, @@ -274,7 +289,8 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R * binding (indirectly) to the scroll offset of a large list. * If `start` or `length` is null, all content is * accepted. - * @type {?number} + * + * @property {Number} */ start: {value: null}, @@ -283,7 +299,8 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R * (indirectly) to the scroll height. * If `start` or `length` is null, all content is * accepted. - * @type {?number} + * + * @property {Number} */ length: {value: null}, @@ -293,19 +310,19 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R /** * Whether to select new content automatically. + * @property {boolean} + * @default false * - * Off by default. - * @type {boolean} + * @todo make this work */ selectAddedContent: {value: false}, - // TODO make this work /** * Whether to automatically deselect content that disappears from the * `organizedContent`. * - * Off by default. - * @type {boolean} + * @default false + * @property {boolean} */ deselectInvisibleContent: {value: false}, @@ -314,8 +331,8 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R * `sortPath`, `filterPath`, or `reversed` * knobs change. * - * Off by default. - * @type {boolean} + * @default false + * @property {boolean} */ clearSelectionOnOrderChange: {value: false}, @@ -323,8 +340,8 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R * Whether to automatically reselect a value if it is the last value * removed from the selection. * - * Off by default. - * @type {boolean} + * @default false + * @property {boolean} */ avoidsEmptySelection: {value: false}, @@ -332,8 +349,8 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R * Whether to automatically deselect all previously selected content when a * new selection is made. * - * Off by default. - * @type {boolean} + * @default false + * @property {boolean} */ multiSelect: {value: false}, @@ -344,6 +361,7 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R /** * The content after it has been sorted, reversed, and filtered, suitable * for plucking visible indexes and/or then the sliding window. + * * @private */ _orderedContent: {value: null}, @@ -351,7 +369,8 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R /** * An array incrementally projected from `content` through sort, * reversed, filter, visibleIndexes, start, and length. - * @type {Array.} + * + * @property {Array.} */ organizedContent: {value: null}, @@ -359,7 +378,8 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R * An array of iterations corresponding to each of the values in * `organizedContent`, providing an interface for getting or * setting whether each is selected. - * @type {Array.} + * + * @property {Array.} */ iterations: {value: null}, @@ -372,21 +392,19 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R * The selection may be `null`. * The selection may be any collection that supports range change events * like `Array` or `SortedSet`. - * @type {?Array|Set|SortedSet} + * + * @param {Collection} a collection of values to be set as the selection. + * @returns {?Array|Set|SortedSet} + * + * @deprecated: setting the `selection` will not replace it with the provided. + * collection. Instead, it will empty the selection and then shallow-copy the + * contents of the argument into the existing selection array. This is done to + * maintain the complicated invariants about what the selection can be. */ selection: { get: function () { return this._selection; }, - /** - * @name RangeController#set:selection - * @method - * @param {Collection} a collection of values to be set as the selection. - * @deprecated: setting the `selection` will not replace it with the provided. - * collection. Instead, it will empty the selection and then shallow-copy the - * contents of the argument into the existing selection array. This is done to - * maintain the complicated invariants about what the selection can be. - */ set: function (collection) { var args = [0, this._selection.length]; if (collection && collection.toArray) { @@ -402,7 +420,8 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R * You can however directly manipulate the selection, but that will update * the selection asynchronously because the controller cannot change the * selection while handling a selection change event. - * @method + * + * @function * @param value */ select: { @@ -420,7 +439,8 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R * You can however directly manipulate the selection, but that will update * the selection asynchronously because the controller cannot change the * selection while handling a selection change event. - * @method + * + * @function * @param value */ deselect: { @@ -437,7 +457,8 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R * You can however directly manipulate the selection, but that will update * the selection asynchronously because the controller cannot change the * selection while handling a selection change event. - * @method + * + * @function */ clearSelection: { value: function () { @@ -450,9 +471,10 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R /** * Proxies adding content to the underlying collection, accounting for * `selectAddedContent`. - * @method + * + * @function * @param value - * @return {boolean} whether the value was added + * @returns {boolean} whether the value was added */ add: { value: function (value) { @@ -472,9 +494,10 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R /** * Proxies pushing content to the underlying collection, accounting for * `selectAddedContent`. - * @method + * + * @function * @param ...values - * @return {boolean} whether the value was added + * @returns {boolean} whether the value was added */ push: { value: function () { @@ -488,8 +511,9 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R /** * Proxies popping content from the underlying collection. - * @method - * @return the popped value + * + * @function + * @returns the popped value */ pop: { value: function () { @@ -499,8 +523,9 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R /** * Proxies shifting content from the underlying collection. - * @method - * @return the shifted value + * + * @function + * @returns the shifted value */ shift: { value: function () { @@ -511,9 +536,10 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R /** * Proxies unshifting content to the underlying collection, accounting for * `selectAddedContent`. - * @method + * + * @function * @param ...values - * @return {boolean} whether the value was added + * @returns {boolean} whether the value was added */ unshift: { value: function () { @@ -528,8 +554,9 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R /** * Proxies splicing values into the underlying collection. * Accounts for * `selectAddedContent`. - * @method - * @return the resulting content + * + * @function + * @returns the resulting content */ splice: { value: function () { @@ -544,11 +571,12 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R /** * Proxies swapping values in the underlying collection. * Accounts for * `selectAddedContent` - * @method + * + * @function * @param {number} index the position at which to remove values * @param {number} minusLength the number of values to remove * @param {Array} plus the values to add - * @return {Array} `minus`, the removed values from the content + * @returns {Array} `minus`, the removed values from the content */ swap: { value: function (index, length, values) { @@ -564,9 +592,10 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R /** * Proxies deleting content from the underlying collection. - * @method + * + * @function * @param value - * @return {boolean} whether the value was found and deleted successfully + * @returns {boolean} whether the value was found and deleted successfully */ "delete": { value: function (value) { @@ -576,12 +605,13 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R /** * Does the value exist in the content? - * @method + * + * @function * @param {object} value the value to test for - * @return {boolean} + * @returns {boolean} */ has: { - value: function(value) { + value: function (value) { if (this.content) { return this.content.has(value); } else { @@ -592,7 +622,8 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R /** * Proxies adding each value into the underlying collection. - * @method + * + * @function * @param {...object} values */ addEach: { @@ -601,7 +632,7 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R /** * Proxies deleting each value out from the underlying collection. - * @method + * @function * @param {...object} values */ deleteEach: { @@ -610,7 +641,7 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R /** * Proxies clearing the underlying content collection. - * @method + * @function */ clear: { value: function () { @@ -622,8 +653,8 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R * Creates content and adds it to the controller and its backing * collection. * Uses `add` and `contentConstructor`. - * @method - * @return the value constructed and added + * @function + * @returns the value constructed and added */ addContent: { value: function () { @@ -633,6 +664,9 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R } }, + /** + * @private + */ _contentConstructor: { value: null }, @@ -691,7 +725,7 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R * @private */ handleSelectionRangeChange : { - value: function(plus, minus, index) { + value: function (plus, minus, index) { if (this.selection) { if (this.content) { var notInContent = []; @@ -769,7 +803,7 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R * @private */ handleMultiSelectChange: { - value: function() { + value: function () { if (this.selection) { var length = this.selection.length; if (!this.multiSelect && length > 1) { @@ -781,7 +815,7 @@ var RangeController = exports.RangeController = Montage.specialize( /** @lends R } } -}, /** @lends RangeController. */ { +}, /** @lends RangeController */ { blueprintModuleId:require("./core")._blueprintModuleIdDescriptor, diff --git a/core/request.js b/core/request.js index 099ba520de..0a2a6d6ecd 100644 --- a/core/request.js +++ b/core/request.js @@ -15,7 +15,7 @@ var Promise = require("./promise").Promise; * @param {string} [request.overrideMimeType] Override the return MIME-type of the request * @param {object} [request.options] An object of properties to set on the XHR object, such as `responseType` or `withCredentials` * @param {object} [request.xhr] An existing XMLHttpRequest object to use. - * @return {Promise.} A promise for a response object + * @returns {Promise.} A promise for a response object * containing `status`, `headers`, `body` and `xhr` properties. */ exports = module.exports = function doRequest(request) { @@ -25,7 +25,7 @@ exports = module.exports = function doRequest(request) { var xhr = request.xhr || new XMLHttpRequest(); xhr.open(request.method, request.url, true); - xhr.onload = function() { + xhr.onload = function () { var response = { status: xhr.status, headers: exports.parseResponseHeaders(xhr.getAllResponseHeaders()), @@ -36,7 +36,7 @@ exports = module.exports = function doRequest(request) { done.resolve(response); }; - xhr.onerror = function() { + xhr.onerror = function () { done.reject(new Error("Could not load")); }; @@ -93,7 +93,7 @@ exports.makeOk = function (next) { * is 2xx, otherwise it is rejected. The rejected Error object has a `response` * property containing the response. * @param {string|object} request See documentation for `request` - * @return {Promise.} See documentation for `request` + * @returns {Promise.} See documentation for `request` */ exports.ok = exports.makeOk(exports.request); diff --git a/core/serialization/alias.js b/core/serialization/alias.js index aa813cd341..facb380125 100644 --- a/core/serialization/alias.js +++ b/core/serialization/alias.js @@ -44,11 +44,11 @@ exports.Alias = Montage.specialize({ /** @lends Alias# */ * @type {string} */ value: { - get: function() { + get: function () { return this._value; }, - set: function(value) { + set: function (value) { var split = this._aliasRegExp.exec(value); if (!split) { @@ -76,7 +76,7 @@ exports.Alias = Montage.specialize({ /** @lends Alias# */ * @readonly */ componentLabel: { - get: function() { + get: function () { return this._componentLabel; } }, @@ -95,13 +95,13 @@ exports.Alias = Montage.specialize({ /** @lends Alias# */ * @readonly */ propertyName: { - get: function() { + get: function () { return this._propertyName; } }, init: { - value: function(value) { + value: function (value) { this.value = value; return this; diff --git a/core/serialization/deserializer/montage-deserializer.js b/core/serialization/deserializer/montage-deserializer.js index 47f9f4f0d7..b292788937 100644 --- a/core/serialization/deserializer/montage-deserializer.js +++ b/core/serialization/deserializer/montage-deserializer.js @@ -14,7 +14,7 @@ var MontageDeserializer = Montage.specialize.call(Deserializer, { _serialization: {value: null}, init: { - value: function(serializationString, _require, objectRequires, origin) { + value: function (serializationString, _require, objectRequires, origin) { if (! this.isSerializationStringValid(serializationString)) { throw new Error( this._formatSerializationSyntaxError(serializationString) @@ -32,7 +32,7 @@ var MontageDeserializer = Montage.specialize.call(Deserializer, { }, serialization: { - get: function() { + get: function () { var serialization = this._serialization; if (!serialization) { @@ -45,7 +45,7 @@ var MontageDeserializer = Montage.specialize.call(Deserializer, { }, deserialize: { - value: function(instances, element) { + value: function (instances, element) { var serialization; try { @@ -60,7 +60,7 @@ var MontageDeserializer = Montage.specialize.call(Deserializer, { }, preloadModules: { - value: function() { + value: function () { var serialization = JSON.parse(this._serializationString); return this._interpreter.preloadModules(serialization); @@ -68,7 +68,7 @@ var MontageDeserializer = Montage.specialize.call(Deserializer, { }, getExternalObjectLabels: { - value: function() { + value: function () { var serialization = this.serialization, labels = []; @@ -83,7 +83,7 @@ var MontageDeserializer = Montage.specialize.call(Deserializer, { }, isSerializationStringValid: { - value: function(serializationString) { + value: function (serializationString) { try { JSON.parse(serializationString); return true; @@ -94,7 +94,7 @@ var MontageDeserializer = Montage.specialize.call(Deserializer, { }, _formatSerializationSyntaxError: { - value: function(source) { + value: function (source) { var gutterPadding = " ", origin = this._origin, message, @@ -128,7 +128,7 @@ var MontageDeserializer = Montage.specialize.call(Deserializer, { }, { defineDeserializationUnit: { - value: function(name, funktion) { + value: function (name, funktion) { MontageReviver.defineUnitReviver(name, funktion); } } @@ -136,7 +136,7 @@ var MontageDeserializer = Montage.specialize.call(Deserializer, { }); exports.MontageDeserializer = MontageDeserializer; -exports.deserialize = function(serializationString, _require) { +exports.deserialize = function (serializationString, _require) { return new MontageDeserializer(). init(serializationString, _require) .deserializeObject(); diff --git a/core/serialization/deserializer/montage-interpreter.js b/core/serialization/deserializer/montage-interpreter.js index 68bab2fd6a..5a645bdef7 100644 --- a/core/serialization/deserializer/montage-interpreter.js +++ b/core/serialization/deserializer/montage-interpreter.js @@ -9,7 +9,7 @@ var MontageInterpreter = Montage.specialize.call(Interpreter, { _reviver: {value: null}, init: { - value: function(_require, objectRequires) { + value: function (_require, objectRequires) { if (typeof _require !== "function") { throw new Error("Function 'require' missing."); } @@ -23,7 +23,7 @@ var MontageInterpreter = Montage.specialize.call(Interpreter, { }, instantiate: { - value: function(serialization, objects, element) { + value: function (serialization, objects, element) { var context; context = new MontageContext() @@ -34,7 +34,7 @@ var MontageInterpreter = Montage.specialize.call(Interpreter, { }, preloadModules: { - value: function(serialization) { + value: function (serialization) { var reviver = this._reviver, moduleLoader = reviver.moduleLoader, object, @@ -71,13 +71,13 @@ var MontageContext = Montage.specialize.call(Context, { _require: {value: null}, constructor: { - value: function() { + value: function () { this._unitsToDeserialize = []; } }, init: { - value: function(serialization, reviver, objects, element, _require) { + value: function (serialization, reviver, objects, element, _require) { Context.call(this, serialization, reviver, objects); this._element = element; @@ -88,7 +88,7 @@ var MontageContext = Montage.specialize.call(Context, { }, hasObject: { - value: function(label) { + value: function (label) { return label in this._serialization; } }, @@ -100,13 +100,13 @@ var MontageContext = Montage.specialize.call(Context, { }, getElement: { - value: function() { + value: function () { return this._element; } }, getElementById: { - value: function(id) { + value: function (id) { var selector = '*[' + this._ELEMENT_ID_ATTRIBUTE + '="' + id + '"]'; return this._element.querySelector(selector); @@ -114,7 +114,7 @@ var MontageContext = Montage.specialize.call(Context, { }, setUnitsToDeserialize: { - value: function(object, objectDesc, unitNames) { + value: function (object, objectDesc, unitNames) { this._unitsToDeserialize.push({ object: object, objectDesc: objectDesc, @@ -124,7 +124,7 @@ var MontageContext = Montage.specialize.call(Context, { }, getUnitsToDeserialize: { - value: function() { + value: function () { return this._unitsToDeserialize; } } diff --git a/core/serialization/deserializer/montage-reviver.js b/core/serialization/deserializer/montage-reviver.js index 8867790f4b..4e233a63e0 100644 --- a/core/serialization/deserializer/montage-reviver.js +++ b/core/serialization/deserializer/montage-reviver.js @@ -13,7 +13,7 @@ var ModuleLoader = Montage.specialize( { _objectRequires: {value: null}, init: { - value: function(_require, objectRequires) { + value: function (_require, objectRequires) { if (typeof _require !== "function") { throw new Error("Function 'require' missing."); } @@ -35,7 +35,7 @@ var ModuleLoader = Montage.specialize( { }, getExports: { - value: function(_require, moduleId) { + value: function (_require, moduleId) { var module; // Transforms relative module ids into absolute module ids @@ -55,7 +55,7 @@ var ModuleLoader = Montage.specialize( { }, getModule: { - value: function(moduleId, label) { + value: function (moduleId, label) { var objectRequires = this._objectRequires, _require, module; @@ -90,7 +90,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / * serialization. */ init: { - value: function(_require, objectRequires) { + value: function (_require, objectRequires) { this.moduleLoader = new ModuleLoader() .init(_require, objectRequires); @@ -99,7 +99,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / }, getTypeOf: { - value: function(value) { + value: function (value) { if (value !== null && typeof value === "object" && Object.keys(value).length === 1 @@ -116,7 +116,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / }, _checkLabel: { - value: function(label, isTemplateProperty) { + value: function (label, isTemplateProperty) { if (isTemplateProperty && label[0] !== ":") { return new Error("Aliases can only be defined in template properties (start with a colon (:)), \"" + label + "\"."); } else if (!isTemplateProperty && label[0] === ":") { @@ -126,7 +126,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / }, reviveRootObject: { - value: function(value, context, label) { + value: function (value, context, label) { var error, isAlias = "alias" in value; @@ -145,7 +145,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / }, reviveElement: { - value: function(value, context, label) { + value: function (value, context, label) { var elementId = value["#"], element = context.getElementById(elementId); @@ -161,7 +161,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / }, reviveModule: { - value: function(value, context, label) { + value: function (value, context, label) { var moduleId = value["%"], _require = context.getRequire(); @@ -173,7 +173,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / }, reviveCustomObject: { - value: function(value, context, label) { + value: function (value, context, label) { if ("alias" in value) { return this.reviveAlias(value, context, label); } else { @@ -183,7 +183,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / }, reviveMontageObject: { - value: function(value, context, label) { + value: function (value, context, label) { var self = this, module, locationDesc, @@ -198,7 +198,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / } if (Promise.isPromise(module)) { - return module.then(function(exports) { + return module.then(function (exports) { return self.instantiateMontageObject(value, exports, objectName, context, label); }, function (error) { if (error.stack) { @@ -215,7 +215,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / }, instantiateMontageObject: { - value: function(value, module, objectName, context, label) { + value: function (value, module, objectName, context, label) { var self = this, object, montageObjectDesc; @@ -227,7 +227,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / montageObjectDesc = this.reviveObjectLiteral(value, context); if (Promise.isPromise(montageObjectDesc)) { - return montageObjectDesc.then(function(montageObjectDesc) { + return montageObjectDesc.then(function (montageObjectDesc) { return self.deserializeMontageObject(montageObjectDesc, object, context, label); }); } else { @@ -237,7 +237,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / }, deserializeMontageObject: { - value: function(montageObjectDesc, object, context, label) { + value: function (montageObjectDesc, object, context, label) { var properties; if (typeof object.deserializeSelf === "function") { @@ -249,7 +249,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / properties = this.deserializeMontageObjectProperties(object, montageObjectDesc.properties, context); if (Promise.isPromise(properties)) { - return properties.then(function() { + return properties.then(function () { return object; }); } else { @@ -260,7 +260,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / }, deserializeMontageObjectProperties: { - value: function(object, properties, context) { + value: function (object, properties, context) { var value; if (typeof object.deserializeProperties === "function") { @@ -278,7 +278,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / }, deserializeCustomMontageObject: { - value: function(object, objectDesc, context, label) { + value: function (object, objectDesc, context, label) { var substituteObject; var selfDeserializer = new SelfDeserializer() @@ -286,7 +286,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / substituteObject = object.deserializeSelf(selfDeserializer); if (Promise.isPromise(substituteObject)) { - return substituteObject.then(function(substituteObject) { + return substituteObject.then(function (substituteObject) { context.setObjectLabel(substituteObject, label); return substituteObject; }); @@ -300,7 +300,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / }, getMontageObject: { - value: function(value, module, objectName, context, label) { + value: function (value, module, objectName, context, label) { var object; if (context.hasUserObject(label)) { @@ -343,7 +343,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / }, reviveAlias: { - value: function(value, context, label) { + value: function (value, context, label) { var alias = new Alias(); alias.value = value.alias; @@ -353,14 +353,14 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / }, didReviveObjects: { - value: function(objects, context) { + value: function (objects, context) { var self = this, value; value = this._deserializeUnits(context); if (Promise.isPromise(value)) { - return value.then(function() { + return value.then(function () { self._invokeDeserializedFromSerialization(objects, context); }); } else { @@ -371,7 +371,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / // TODO: can deserializeSelf make deserializedFromSerialization irrelevant? _invokeDeserializedFromSerialization: { - value: function(objects, context) { + value: function (objects, context) { var object; for (var label in objects) { @@ -393,7 +393,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / }, _deserializeUnits: { - value: function(context) { + value: function (context) { var unitsToDeserialize = context.getUnitsToDeserialize(), units = MontageReviver._unitRevivers, unitNames, @@ -428,7 +428,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / value: /(?:^|-)([^-])/g }, _replaceToCamelCase: { - value: function(_, g1) { return g1.toUpperCase(); } + value: function (_, g1) { return g1.toUpperCase(); } }, // Cache of location descriptors indexed by locationId _locationDescCache: {value: Object.create(null)}, @@ -447,7 +447,7 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / // // @returns {moduleId, objectName} parseObjectLocationId: { - value: function(locationId) { + value: function (locationId) { var locationDescCache = this._locationDescCache, locationDesc, bracketIndex, @@ -483,14 +483,14 @@ var MontageReviver = exports.MontageReviver = Montage.specialize.call(Reviver, / }, defineUnitReviver: { - value: function(name, funktion) { + value: function (name, funktion) { this._unitRevivers[name] = funktion; this._unitNames.push(name); } }, getTypeOf: { - value: function(value) { + value: function (value) { return this.prototype.getTypeOf.call(this, value); } } diff --git a/core/serialization/deserializer/properties-deserializer.js b/core/serialization/deserializer/properties-deserializer.js index 37c5bf0f76..1222237bec 100644 --- a/core/serialization/deserializer/properties-deserializer.js +++ b/core/serialization/deserializer/properties-deserializer.js @@ -7,7 +7,7 @@ var PropertiesDeserializer = Montage.specialize( { _context: {value: null}, initWithObjectAndObjectDescriptorAndContext: { - value: function(object, objectDescriptor, context) { + value: function (object, objectDescriptor, context) { this._object = object; this._objectDescriptor = objectDescriptor; this._context = context; @@ -17,7 +17,7 @@ var PropertiesDeserializer = Montage.specialize( { }, get: { - value: function(name) { + value: function (name) { if (this._objectDescriptor.properties) { return this._objectDescriptor.properties[name]; } @@ -25,7 +25,7 @@ var PropertiesDeserializer = Montage.specialize( { }, deserializeProperties: { - value: function(propertyNames) { + value: function (propertyNames) { var object = this._object, properties = this._objectDescriptor.properties, propertyName; @@ -44,7 +44,7 @@ var PropertiesDeserializer = Montage.specialize( { }, getObjectByLabel: { - value: function(label) { + value: function (label) { this._context.getObject(label); } } diff --git a/core/serialization/deserializer/self-deserializer.js b/core/serialization/deserializer/self-deserializer.js index 832c5b6bd4..4cf69090ab 100644 --- a/core/serialization/deserializer/self-deserializer.js +++ b/core/serialization/deserializer/self-deserializer.js @@ -9,13 +9,13 @@ var SelfDeserializer = Montage.specialize( { _objectUnitNames: {value: null}, create: { - value: function() { + value: function () { return new this(); } }, initWithObjectAndObjectDescriptorAndContextAndUnitNames: { - value: function(object, objectDescriptor, context, unitNames) { + value: function (object, objectDescriptor, context, unitNames) { this._object = object; this._objectDescriptor = objectDescriptor; this._context = context; @@ -26,7 +26,7 @@ var SelfDeserializer = Montage.specialize( { }, getProperty: { - value: function(name) { + value: function (name) { if (this._objectDescriptor.properties) { return this._objectDescriptor.properties[name]; } @@ -34,7 +34,7 @@ var SelfDeserializer = Montage.specialize( { }, getType: { - value: function() { + value: function () { if ("prototype" in this._objectDescriptor) { return "prototype"; } else if ("object" in this._objectDescriptor) { @@ -44,19 +44,19 @@ var SelfDeserializer = Montage.specialize( { }, getTypeValue: { - value: function() { + value: function () { return this._objectDescriptor.prototype || this._objectDescriptor.object; } }, getObjectByLabel: { - value: function(label) { + value: function (label) { this._context.getObject(label); } }, deserializeProperties: { - value: function(propertyNames) { + value: function (propertyNames) { var object = this._object, properties = this._objectDescriptor.properties, propertyName; @@ -75,7 +75,7 @@ var SelfDeserializer = Montage.specialize( { }, deserializeUnit: { - value: function(name) { + value: function (name) { var objectUnitNames = this._objectUnitNames; if (!objectUnitNames) { @@ -88,7 +88,7 @@ var SelfDeserializer = Montage.specialize( { }, deserializeUnits: { - value: function() { + value: function () { var objectUnitNames = this._objectUnitNames; if (!objectUnitNames) { diff --git a/core/serialization/deserializer/serialization-extractor.js b/core/serialization/deserializer/serialization-extractor.js index e0eab4f4c5..2c97f1c3b3 100644 --- a/core/serialization/deserializer/serialization-extractor.js +++ b/core/serialization/deserializer/serialization-extractor.js @@ -6,13 +6,13 @@ var SerializationExtractor = Montage.specialize( { _serialization: {value: null}, initWithSerialization: { - value: function(serialization) { + value: function (serialization) { this._serialization = serialization; } }, extractObjects: { - value: function(labels, externalLabels) { + value: function (labels, externalLabels) { var serialization = this._serialization, objects = {}; @@ -36,7 +36,7 @@ var SerializationExtractor = Montage.specialize( { }, _findLabels: { - value: function(label, labels) { + value: function (label, labels) { var serialization; if (labels.indexOf(label) === -1) { @@ -53,7 +53,7 @@ var SerializationExtractor = Montage.specialize( { }, _collectLabels: { - value: function(serialization, labels) { + value: function (serialization, labels) { var type = MontageReviver.getTypeOf(serialization), label; @@ -73,7 +73,7 @@ var SerializationExtractor = Montage.specialize( { }, _collectLabelsInUnits: { - value: function(objectSerialization, objects) { + value: function (objectSerialization, objects) { if ("bindings" in objectSerialization) { this._collectLabelsInBindings(objectSerialization.bindings, objects); } else if ("localizations" in objectSerialization) { @@ -87,7 +87,7 @@ var SerializationExtractor = Montage.specialize( { // _collectLabelsInBindings: { - value: function(unitSerialization, labels) { + value: function (unitSerialization, labels) { var binding, sourcePath; @@ -100,18 +100,18 @@ var SerializationExtractor = Montage.specialize( { }, _collectLabelsInBindingPath: { - value: function(path, labels) { + value: function (path, labels) { var self = this, parseTree = parse(path); - this._traverseBindingParseTree(parseTree, function(syntax) { + this._traverseBindingParseTree(parseTree, function (syntax) { self._findLabels(syntax.label, labels); }); } }, _traverseBindingParseTree: { - value: function(parseTree, visitor) { + value: function (parseTree, visitor) { var args = parseTree.args; if (parseTree.type === "component") { @@ -131,7 +131,7 @@ var SerializationExtractor = Montage.specialize( { // _collectLabelsInLocalizations: { - value: function(unitSerialization, labels) { + value: function (unitSerialization, labels) { var property, data; @@ -143,7 +143,7 @@ var SerializationExtractor = Montage.specialize( { }, _collectLabelsInLocalizationProperty: { - value: function(property, labels) { + value: function (property, labels) { var data; if ("key" in property) { @@ -168,7 +168,7 @@ var SerializationExtractor = Montage.specialize( { }, _collectLabelsInLocalizationBinding: { - value: function(binding, labels) { + value: function (binding, labels) { var sourcePath = binding["<-"] || binding["<->"]; if (sourcePath) { diff --git a/core/serialization/deserializer/unit-deserializer.js b/core/serialization/deserializer/unit-deserializer.js index e27209178a..f0b8c9729f 100644 --- a/core/serialization/deserializer/unit-deserializer.js +++ b/core/serialization/deserializer/unit-deserializer.js @@ -5,13 +5,13 @@ var UnitDeserializer = Montage.specialize(/** @lends UnitDeserializer# */ { _context: {value: null}, create: { - value: function() { + value: function () { return new this(); } }, initWithContext: { - value: function(context) { + value: function (context) { this._context = context; return this; @@ -27,7 +27,7 @@ var UnitDeserializer = Montage.specialize(/** @lends UnitDeserializer# */ { * that exists and has the format: @:. */ isValidTemplatePropertyReference: { - value: function(label) { + value: function (label) { var templateProperty = this._templatePropertyRegExp.exec(label); if (templateProperty) { @@ -45,7 +45,7 @@ var UnitDeserializer = Montage.specialize(/** @lends UnitDeserializer# */ { }, getObjectByLabel: { - value: function(label) { + value: function (label) { if (this._context.hasObject(label)) { // All labels that exist are immediately resolved into an object // even if they are a valid template property reference. This diff --git a/core/serialization/serialization.js b/core/serialization/serialization.js index 31ac49dc5a..e1c9909fc2 100644 --- a/core/serialization/serialization.js +++ b/core/serialization/serialization.js @@ -1,3 +1,8 @@ +/** + * @module montage/serialization/serialization + * @requires montage/core + */ + var Montage = require("../core").Montage, MontageLabeler = require("./serializer/montage-labeler").MontageLabeler, MontageReviver = require("./deserializer/montage-reviver").MontageReviver, @@ -6,14 +11,15 @@ var Montage = require("../core").Montage, /** * @class Serialization + * @extends Montage */ -var Serialization = Montage.specialize( /** @lends Serialization# */ { +var Serialization = Montage.specialize( /** @lends Serialization.prototype # */ { _serializationString: {value: null}, _serializationObject: {value: null}, _serializationLabels: {value: null}, initWithString: { - value: function(string) { + value: function (string) { this._serializationString = string; this._serializationObject = null; this._serializationLabels = null; @@ -23,7 +29,7 @@ var Serialization = Montage.specialize( /** @lends Serialization# */ { }, initWithObject: { - value: function(object) { + value: function (object) { this._serializationString = null; this._serializationObject = object; this._serializationLabels = null; @@ -33,7 +39,7 @@ var Serialization = Montage.specialize( /** @lends Serialization# */ { }, clone: { - value: function() { + value: function () { var serialization = new Serialization(); serialization.initWithString(this.getSerializationString()); @@ -43,7 +49,7 @@ var Serialization = Montage.specialize( /** @lends Serialization# */ { }, getSerializationObject: { - value: function() { + value: function () { if (!this._serializationObject) { this._serializationObject = JSON.parse(this._serializationString); } @@ -53,7 +59,7 @@ var Serialization = Montage.specialize( /** @lends Serialization# */ { }, getSerializationString: { - value: function() { + value: function () { if (!this._serializationString) { this._serializationString = JSON.stringify(this._serializationObject); } @@ -63,7 +69,7 @@ var Serialization = Montage.specialize( /** @lends Serialization# */ { }, getSerializationLabels: { - value: function() { + value: function () { var serializationObject; if (!this._serializationLabels) { @@ -77,7 +83,7 @@ var Serialization = Montage.specialize( /** @lends Serialization# */ { }, getExternalObjectLabels: { - value: function() { + value: function () { var serializationObject = this.getSerializationObject(), labels = []; @@ -92,13 +98,13 @@ var Serialization = Montage.specialize( /** @lends Serialization# */ { }, hasSerializationLabel: { - value: function(label) { + value: function (label) { return label in this.getSerializationObject(); } }, isExternalObject: { - value: function(label) { + value: function (label) { var serializationObject = this.getSerializationObject(); if (serializationObject && label in serializationObject) { @@ -110,7 +116,7 @@ var Serialization = Montage.specialize( /** @lends Serialization# */ { }, isAlias: { - value: function(label) { + value: function (label) { var serializationObject = this.getSerializationObject(); if (serializationObject && label in serializationObject) { @@ -122,7 +128,7 @@ var Serialization = Montage.specialize( /** @lends Serialization# */ { }, getElementId: { - value: function(label) { + value: function (label) { var object = this.getSerializationObject(); // TODO: much faster than using the visitor, need to make the visitor @@ -135,12 +141,12 @@ var Serialization = Montage.specialize( /** @lends Serialization# */ { }, getSerializationLabelsWithElements: { - value: function(elementIds) { + value: function (elementIds) { var inspector = new SerializationInspector(), labels = []; inspector.initWithSerialization(this); - inspector.visitSerialization(function(node) { + inspector.visitSerialization(function (node) { // Check if this is one of the elements we're looking for if (node.type === "Element" && elementIds.indexOf(node.data) >= 0) { // Check if it's inside a "properties" block @@ -160,11 +166,11 @@ var Serialization = Montage.specialize( /** @lends Serialization# */ { }, renameElementReferences: { - value: function(elementsTable) { + value: function (elementsTable) { var inspector = new SerializationInspector(); inspector.initWithSerialization(this); - inspector.visitSerialization(function(node) { + inspector.visitSerialization(function (node) { if (node.type === "Element" && node.data in elementsTable) { node.data = elementsTable[node.data]; } @@ -173,11 +179,11 @@ var Serialization = Montage.specialize( /** @lends Serialization# */ { }, renameSerializationLabels: { - value: function(labelsTable) { + value: function (labelsTable) { var inspector = new SerializationInspector(); inspector.initWithSerialization(this); - inspector.visitSerialization(function(node) { + inspector.visitSerialization(function (node) { if (node.label) { var label = node.label; @@ -197,13 +203,13 @@ var Serialization = Montage.specialize( /** @lends Serialization# */ { }, mergeSerialization: { - value: function(serialization, delegate) { + value: function (serialization, delegate) { return SerializationMerger.mergeSerializations(this, serialization, delegate); } }, extractSerialization: { - value: function(labels, externalLabels) { + value: function (labels, externalLabels) { var extractor = new SerializationExtractor(); extractor.initWithSerialization(this); @@ -214,8 +220,9 @@ var Serialization = Montage.specialize( /** @lends Serialization# */ { /** * @class SerializationMerger + * @extends Montage */ -var SerializationMerger = Montage.specialize(null, /** @lends SerializationMerger */ { +var SerializationMerger = Montage.specialize(null, /** @lends SerializationMerger.prototype */ { /** * This delegate method is called when merging an object from serialization2 * into serialization1. It allows the delegate to change how the object is @@ -236,23 +243,22 @@ var SerializationMerger = Montage.specialize(null, /** @lends SerializationMerge * * @callback delegateWillMergeObjectWithLabel * @param {string} label The object label. - * @param {string} newLabel The new label generated by the collision - * resolver in case of collision. - * @return {string|undefined} the new label for this object. + * @param {string} newLabel The new label generated by the collision resolver in case of collision. + * @returns {string|undefined} the new label for this object. */ /** * Merges serialization2 into serialization1. * - * @param {Serialization} serialization1 The serialization to be merged and - * end result of the merge operation. - * @param {Serialization} serialization2 The serialization to be merged. - * @param {{willMergeObjectWithLabel: delegateWillMergeObjectWithLabel}} delegate The delegate to override the default behavior. - * @return {Object} The collision table with the new labels generated for - * label clashes. + * @param {Serialization} serialization1 - The serialization to be merged and end result of the merge operation. + * @param {Serialization} serialization2 - The serialization to be merged. + * @param {{willMergeObjectWithLabel: delegateWillMergeObjectWithLabel}} delegate + * - The delegate to override the default behavior. + * + * @returns {Object} The collision table with the new labels generated for label clashes */ mergeSerializations: { - value: function(serialization1, serialization2, delegate) { + value: function (serialization1, serialization2, delegate) { var serializationObject1, serializationObject2, labels1, @@ -298,8 +304,12 @@ var SerializationMerger = Montage.specialize(null, /** @lends SerializationMerge } }, + /** + * @private + * @function + */ _willMergeObjectWithLabel: { - value: function(delegate, serialization1, serialization2, collisionTable) { + value: function (delegate, serialization1, serialization2, collisionTable) { var newLabel, collisionLabel, collisionLabels, @@ -310,7 +320,7 @@ var SerializationMerger = Montage.specialize(null, /** @lends SerializationMerge if (collisionTable) { collisionLabels = []; - Object.keys(collisionTable).forEach(function(label) { + Object.keys(collisionTable).forEach(function (label) { collisionLabels.push(collisionTable[label]); }); } @@ -355,10 +365,11 @@ var SerializationMerger = Montage.specialize(null, /** @lends SerializationMerge * This function returns true when the label is part of the serialization, * or, if a template property, it refers to a component label that is part * of the serialization. + * * @private */ _isLabelValidInSerialization: { - value: function(label, serialization) { + value: function (label, serialization) { var componentLabel, ix; @@ -397,7 +408,7 @@ var SerializationMerger = Montage.specialize(null, /** @lends SerializationMerge * case the component label will also be part of the resulting collision * table even if there was no original collision in labels1. * - * Example: + * @example * labels1: ["repetition:iteration"] * labels2: ["repetition", "repetition:iteration"] * collisionTable: {"repetition:iteration": "object:iteration", @@ -406,7 +417,7 @@ var SerializationMerger = Montage.specialize(null, /** @lends SerializationMerge * @private */ _createCollisionTable: { - value: function(labels1, labels2, collisionTable, labeler) { + value: function (labels1, labels2, collisionTable, labeler) { var labeler = labeler || new MontageLabeler(), foundCollisions = false, componentLabel, @@ -478,16 +489,17 @@ var SerializationMerger = Montage.specialize(null, /** @lends SerializationMerge /** * @class SerializationInspector + * @extends Montage */ -var SerializationInspector = Montage.specialize(/** @lends SerializationInspector# */ { +var SerializationInspector = Montage.specialize(/** @lends SerializationInspector.prototype # */ { initWithSerialization: { - value: function(serialization) { + value: function (serialization) { this._serialization = serialization; } }, visitSerialization: { - value: function(visitor) { + value: function (visitor) { var serialization = this._serialization.getSerializationObject(); this._walkRootObjects(visitor, serialization); @@ -496,7 +508,7 @@ var SerializationInspector = Montage.specialize(/** @lends SerializationInspecto }, visitSerializationObject: { - value: function(label, visitor) { + value: function (label, visitor) { var serialization = this._serialization.getSerializationObject(); if (label in serialization) { @@ -509,7 +521,7 @@ var SerializationInspector = Montage.specialize(/** @lends SerializationInspecto }, changeLabel: { - value: function(oldLabel, newLabel) { + value: function (oldLabel, newLabel) { var serialization = this._serialization.getSerializationObject(), object; @@ -520,7 +532,7 @@ var SerializationInspector = Montage.specialize(/** @lends SerializationInspecto }, _walkRootObjects: { - value: function(visitor, objects) { + value: function (visitor, objects) { var object, type; @@ -531,7 +543,7 @@ var SerializationInspector = Montage.specialize(/** @lends SerializationInspecto }, _walkRootObject: { - value: function(visitor, objects, label) { + value: function (visitor, objects, label) { var object = objects[label]; if ("value" in object) { @@ -546,12 +558,11 @@ var SerializationInspector = Montage.specialize(/** @lends SerializationInspecto * @private * @param parentObject {Object} The parent object of the object to walk * @param key {string} The key of the object in the parent object - * @param label {string} Optional label for when the object has no - * parent + * @param label {string} Optional label for when the object has no parent * @param parent {Object} The representation of the object's parent */ _walkObject: { - value: function(visitor, parentObject, key, label, parent) { + value: function (visitor, parentObject, key, label, parent) { var object = parentObject[key], type = MontageReviver.getTypeOf(object), value, @@ -619,7 +630,7 @@ var SerializationInspector = Montage.specialize(/** @lends SerializationInspecto }, _walkCustomObject: { - value: function(visitor, objects, label) { + value: function (visitor, objects, label) { var object = objects[label], value; @@ -651,7 +662,7 @@ var SerializationInspector = Montage.specialize(/** @lends SerializationInspecto }, _walkBindings: { - value: function(visitor, parentObject, parent) { + value: function (visitor, parentObject, parent) { var object = parentObject.bindings, value; @@ -671,7 +682,7 @@ var SerializationInspector = Montage.specialize(/** @lends SerializationInspecto }, _walkBinding: { - value: function(visitor, parentObject, key, parent) { + value: function (visitor, parentObject, key, parent) { var object = parentObject[key], value; @@ -690,14 +701,14 @@ var SerializationInspector = Montage.specialize(/** @lends SerializationInspecto }, _walkBindingData: { - value: function(visitor, object, parent) { + value: function (visitor, object, parent) { var sourcePath, parseTree, modified = false; sourcePath = object["<-"] || object["<->"]; parseTree = Object.clone(parse(sourcePath)); - this._walksBindingReferences(parseTree, function(syntax) { + this._walksBindingReferences(parseTree, function (syntax) { var value = { type: "reference", data: syntax.label @@ -724,7 +735,7 @@ var SerializationInspector = Montage.specialize(/** @lends SerializationInspecto }, _walkLocalizations: { - value: function(visitor, parentObject, parent) { + value: function (visitor, parentObject, parent) { var object = parentObject.localizations, value; @@ -744,7 +755,7 @@ var SerializationInspector = Montage.specialize(/** @lends SerializationInspecto }, _walkLocalization: { - value: function(visitor, parentObject, key, parent) { + value: function (visitor, parentObject, key, parent) { var object = parentObject[key], value, data; @@ -782,7 +793,7 @@ var SerializationInspector = Montage.specialize(/** @lends SerializationInspecto * @private */ _walksBindingReferences: { - value: function(parseTree, visitor) { + value: function (parseTree, visitor) { var args = parseTree.args; if (parseTree.type === "component") { @@ -801,21 +812,29 @@ var SerializationInspector = Montage.specialize(/** @lends SerializationInspecto /** * @class SerializationExtractor + * @extends Montage */ -var SerializationExtractor = Montage.specialize( /** @lends SerializationExtractor# */ { +var SerializationExtractor = Montage.specialize( /** @lends SerializationExtractor.prototype # */ { + /** + * @private + */ _serialization: {value: null}, + /** + * @function + */ initWithSerialization: { - value: function(serialization) { + value: function (serialization) { this._serialization = serialization; } }, /** * Creates a new serialization with the labels given. + * @function */ extractSerialization: { - value: function(labels, externalLabels) { + value: function (labels, externalLabels) { var inspector = new SerializationInspector(), serializationObject, objects = {}, @@ -827,7 +846,7 @@ var SerializationExtractor = Montage.specialize( /** @lends SerializationExtract for (var i = 0, label; (label = labels[i]); i++) { objects[label] = serializationObject[label]; - inspector.visitSerializationObject(label, function(node) { + inspector.visitSerializationObject(label, function (node) { var label; if (node.type === "reference") { diff --git a/core/serialization/serializer/montage-ast.js b/core/serialization/serializer/montage-ast.js index 15b5f0330f..74f0968e65 100644 --- a/core/serialization/serializer/montage-ast.js +++ b/core/serialization/serializer/montage-ast.js @@ -12,14 +12,14 @@ var ElementReference = Montage.specialize.call(Value, /** @lends ElementReferenc }, initWithRootAndId: { - value: function(root, id) { + value: function (root, id) { Value.call(this, root, id); return this; } }, _getSerializationValue: { - value: function() { + value: function () { return {"#": this.value}; } } @@ -36,14 +36,14 @@ var ModuleReference = Montage.specialize.call(Value, /** @lends ModuleReference# }, initWithRootAndModuleId: { - value: function(root, moduleId) { + value: function (root, moduleId) { Value.call(this, root, moduleId); return this; } }, _getSerializationValue: { - value: function() { + value: function () { return {"%": this.value}; } } diff --git a/core/serialization/serializer/montage-builder.js b/core/serialization/serializer/montage-builder.js index 7bfb4e6182..3552171c56 100644 --- a/core/serialization/serializer/montage-builder.js +++ b/core/serialization/serializer/montage-builder.js @@ -14,14 +14,14 @@ var MontageBuilder = Montage.specialize.call(Builder, /** @lends MontageBuilder# }, createElementReference: { - value: function(id) { + value: function (id) { return new MontageAst.ElementReference() .initWithRootAndId(this._root, id); } }, createModuleReference: { - value: function(moduleId) { + value: function (moduleId) { return new MontageAst.ModuleReference() .initWithRootAndModuleId(this._root, moduleId); } diff --git a/core/serialization/serializer/montage-labeler.js b/core/serialization/serializer/montage-labeler.js index 08bb34e2cc..db09139812 100644 --- a/core/serialization/serializer/montage-labeler.js +++ b/core/serialization/serializer/montage-labeler.js @@ -11,7 +11,7 @@ exports.MontageLabeler = Montage.specialize.call(Labeler, { }, getTemplatePropertyLabel: { - value: function(object) { + value: function (object) { var label = this.superForValue("getObjectLabel")(object); if (label[0] !== ":") { @@ -23,7 +23,7 @@ exports.MontageLabeler = Montage.specialize.call(Labeler, { }, getObjectLabel: { - value: function(object) { + value: function (object) { var label = this.super(object); if (label[0] === ":") { @@ -35,7 +35,7 @@ exports.MontageLabeler = Montage.specialize.call(Labeler, { }, getObjectName: { - value: function(object) { + value: function (object) { var identifier = object.identifier, objectName; diff --git a/core/serialization/serializer/montage-serializer.js b/core/serialization/serializer/montage-serializer.js index edb6f10899..f6a9d83ae5 100644 --- a/core/serialization/serializer/montage-serializer.js +++ b/core/serialization/serializer/montage-serializer.js @@ -13,14 +13,14 @@ var MontageSerializer = Montage.specialize.call(Serializer, { _findObjectNameRegExp: {value: /([^\/]+?)(\.reel)?$/}, _toCamelCaseRegExp: {value: /(?:^|-)([^-])/g}, - _replaceToCamelCase: {value: function(_, g1){return g1.toUpperCase();}}, + _replaceToCamelCase: {value: function (_, g1){return g1.toUpperCase();}}, constructor: { value: function MontageSerializer() {} }, initWithRequire: { - value: function(_require) { + value: function (_require) { this._require = _require; this._builder = new MontageBuilder(); @@ -39,13 +39,13 @@ var MontageSerializer = Montage.specialize.call(Serializer, { }, getExternalObjects: { - value: function() { + value: function () { return this._visitor.getExternalObjects(); } }, getExternalElements: { - value: function() { + value: function () { return this._visitor.getExternalElements(); } } @@ -55,13 +55,13 @@ var MontageSerializer = Montage.specialize.call(Serializer, { }, defineSerializationUnit: { - value: function(name, funktion) { + value: function (name, funktion) { this._units[name] = funktion; } }, getDefaultObjectNameForModuleId: { - value: function(moduleId) { + value: function (moduleId) { this._findObjectNameRegExp.test(moduleId); return RegExp.$1.replace(this._toCamelCaseRegExp, this._replaceToCamelCase); @@ -71,7 +71,7 @@ var MontageSerializer = Montage.specialize.call(Serializer, { }); exports.MontageSerializer = MontageSerializer; -exports.serialize = function(object, _require) { +exports.serialize = function (object, _require) { return new MontageSerializer().initWithRequire(_require) .serializeObject(object); }; diff --git a/core/serialization/serializer/montage-visitor.js b/core/serialization/serializer/montage-visitor.js index c190bf5190..e9ef7f780b 100644 --- a/core/serialization/serializer/montage-visitor.js +++ b/core/serialization/serializer/montage-visitor.js @@ -17,7 +17,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { }, initWithBuilderAndLabelerAndRequireAndUnits: { - value: function(builder, labeler, require, units) { + value: function (builder, labeler, require, units) { Visitor.call(this, builder, labeler); this._require = require; @@ -29,7 +29,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { }, getTypeOf: { - value: function(object) { + value: function (object) { // Module and Alias are MontageObject's too so they need to be // tested for before. if (object.isModuleReference) { @@ -47,13 +47,13 @@ var MontageVisitor = Montage.specialize.call(Visitor, { }, visitMontageReference: { - value: function(malker, object, name) { + value: function (malker, object, name) { this.builder.top.setProperty(name, object.reference); } }, visitElement: { - value: function(malker, element, name) { + value: function (malker, element, name) { var elementReference, id; @@ -70,7 +70,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { }, visitModule: { - value: function(malker, reference, name) { + value: function (malker, reference, name) { var referenceReference, moduleId; @@ -89,7 +89,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { }, visitAlias: { - value: function(malker, object) { + value: function (malker, object) { var label = this.labeler.getTemplatePropertyLabel(object); var builderObject = this.builder.createCustomObject(); @@ -100,7 +100,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { }, visitMontageObject: { - value: function(malker, object, name) { + value: function (malker, object, name) { if (this.isObjectSerialized(object)) { this.serializeReferenceToMontageObject(malker, object, name); } else { @@ -110,7 +110,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { }, handleMontageObject: { - value: function(malker, object, name) { + value: function (malker, object, name) { var builderObject = this.builder.createCustomObject(), substituteObject; @@ -128,7 +128,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { }, serializeReferenceToMontageObject: { - value: function(malker, object, name) { + value: function (malker, object, name) { var label = this.labeler.getObjectLabel(object), reference = this.builder.createObjectReference(label); @@ -137,7 +137,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { }, serializeSubstituteObject: { - value: function(malker, object, name, builderObject, substituteObject) { + value: function (malker, object, name, builderObject, substituteObject) { var label, oldLabel, newLabel, @@ -198,7 +198,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { }, serializeMontageObject: { - value: function(malker, object, builderObject) { + value: function (malker, object, builderObject) { var selfSerializer, substituteObject, propertiesBuilderObject = this.builder.createObjectLiteral(); @@ -233,7 +233,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { }, setObjectType: { - value: function(object, builderObject) { + value: function (object, builderObject) { var isInstance = Montage.getInfoForObject(object).isInstance, locationId = this.getObjectLocationId(object), locationIdBuilderObject = this.builder.createString(locationId); @@ -247,7 +247,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { }, getObjectModuleId: { - value: function(object) { + value: function (object) { var objectInfo = Montage.getInfoForObject(object); return this._require.identify(objectInfo.moduleId, @@ -256,7 +256,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { }, getObjectLocationId: { - value: function(object) { + value: function (object) { var moduleId = this.getObjectModuleId(object), defaultObjectName, objectInfo = Montage.getInfoForObject(object), @@ -276,7 +276,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { * Expected object at the top of the stack: CustomObject */ setObjectProperties: { - value: function(malker, object) { + value: function (malker, object) { var propertiesSerializer, propertiesObject; @@ -299,7 +299,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { * Expected object at the top of the stack: ObjectLiteral */ setSerializableObjectProperties: { - value: function(malker, object) { + value: function (malker, object) { var type, propertyName, propertyNames = Montage.getSerializablePropertyNames(object), @@ -314,7 +314,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { }, hackIsReferenceAllowedForValue: { - value: function(value) { + value: function (value) { // Only serialize as a reference values that are non-null objects, // we don't support references to non-objects and elements. // There's nothing in the serialization that prevents us to store @@ -332,7 +332,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { * Expected object at the top of the stack: ObjectLiteral */ setProperty: { - value: function(malker, propertyName, value, type) { + value: function (malker, propertyName, value, type) { var label; if (type === "reference" && this.hackIsReferenceAllowedForValue(value)) { @@ -346,7 +346,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { }, setObjectCustomUnits: { - value: function(malker, object) { + value: function (malker, object) { for (var unitName in this._units) { this.setObjectCustomUnit(malker, object, unitName); } @@ -354,7 +354,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { }, setObjectCustomUnit: { - value: function(malker, object, unitName) { + value: function (malker, object, unitName) { var unit = this._units[unitName], value, unitSerializer; @@ -374,7 +374,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { }, getExternalObjects: { - value: function() { + value: function () { var externalObjects = {}, labels = this.builder.getExternalReferences(), label; @@ -388,7 +388,7 @@ var MontageVisitor = Montage.specialize.call(Visitor, { }, getExternalElements: { - value: function() { + value: function () { return this._elements; } } diff --git a/core/serialization/serializer/properties-serializer.js b/core/serialization/serializer/properties-serializer.js index 6b9b0094bf..207987479d 100644 --- a/core/serialization/serializer/properties-serializer.js +++ b/core/serialization/serializer/properties-serializer.js @@ -10,7 +10,7 @@ var PropertiesSerializer = Montage.specialize.call(Object, { }, initWithMalkerAndVisitorAndObject: { - value: function(malker, visitor, object) { + value: function (malker, visitor, object) { this._malker = malker; this._visitor = visitor; this._object = object; @@ -20,7 +20,7 @@ var PropertiesSerializer = Montage.specialize.call(Object, { }, addObject: { - value: function(object) { + value: function (object) { if (typeof object === "object") { this._malker.visit(object); @@ -30,7 +30,7 @@ var PropertiesSerializer = Montage.specialize.call(Object, { }, addObjectReference: { - value: function(object) { + value: function (object) { var builder = this._visitor.builder, labeler = this._visitor.labeler, label = labeler.getObjectLabel(object); @@ -43,13 +43,13 @@ var PropertiesSerializer = Montage.specialize.call(Object, { }, set: { - value: function(propertyName, value, type) { + value: function (propertyName, value, type) { this._visitor.setProperty(this._malker, propertyName, value, type); } }, setAll: { - value: function() { + value: function () { this._visitor.setSerializableObjectProperties( this._malker, this._object); } diff --git a/core/serialization/serializer/self-serializer.js b/core/serialization/serializer/self-serializer.js index 435f447dc0..0d34e0dc1d 100644 --- a/core/serialization/serializer/self-serializer.js +++ b/core/serialization/serializer/self-serializer.js @@ -10,7 +10,7 @@ var SelfSerializer = Montage.specialize.call(Object, { }, initWithMalkerAndVisitorAndObject: { - value: function(malker, visitor, object) { + value: function (malker, visitor, object) { this._malker = malker; this._visitor = visitor; this._object = object; @@ -20,13 +20,13 @@ var SelfSerializer = Montage.specialize.call(Object, { }, getObjectLabel: { - value: function(object) { + value: function (object) { return this._visitor.labeler.getObjectLabel(object); } }, addObject: { - value: function(object) { + value: function (object) { if (typeof object === "object") { this._malker.visit(object); @@ -36,7 +36,7 @@ var SelfSerializer = Montage.specialize.call(Object, { }, addObjectReference: { - value: function(object) { + value: function (object) { var builder = this._visitor.builder, labeler = this._visitor.labeler, label = labeler.getObjectLabel(object); @@ -49,7 +49,7 @@ var SelfSerializer = Montage.specialize.call(Object, { }, setProperty: { - value: function(propertyName, value, type) { + value: function (propertyName, value, type) { var builder = this._visitor.builder, propertiesObject; @@ -63,7 +63,7 @@ var SelfSerializer = Montage.specialize.call(Object, { }, setAllProperties: { - value: function() { + value: function () { var builder = this._visitor.builder, propertiesObject; @@ -77,13 +77,13 @@ var SelfSerializer = Montage.specialize.call(Object, { }, setUnit: { - value: function(unitName) { + value: function (unitName) { this._visitor.setObjectCustomUnit(this._malker, this._object, unitName); } }, setAllUnits: { - value: function(unitName) { + value: function (unitName) { this._visitor.setObjectCustomUnits(this._malker, this._object); } } diff --git a/core/serialization/serializer/unit-serializer.js b/core/serialization/serializer/unit-serializer.js index 4d89313337..57300d38a7 100644 --- a/core/serialization/serializer/unit-serializer.js +++ b/core/serialization/serializer/unit-serializer.js @@ -16,7 +16,7 @@ var UnitSerializer = Montage.specialize.call(Object, { }, initWithMalkerAndVisitorAndObject: { - value: function(malker, visitor, object) { + value: function (malker, visitor, object) { this._malker = malker; this._visitor = visitor; this._object = object; @@ -26,7 +26,7 @@ var UnitSerializer = Montage.specialize.call(Object, { }, getObjectLabel: { - value: function(object) { + value: function (object) { this.addObjectReference(object); return this._visitor.labeler.getObjectLabel(object); @@ -34,7 +34,7 @@ var UnitSerializer = Montage.specialize.call(Object, { }, addObject: { - value: function(object) { + value: function (object) { if (typeof object === "object") { this._malker.visit(object); @@ -44,7 +44,7 @@ var UnitSerializer = Montage.specialize.call(Object, { }, addObjectReference: { - value: function(object) { + value: function (object) { var builder = this._visitor.builder, labeler = this._visitor.labeler, label = labeler.getObjectLabel(object); diff --git a/core/shim/array.js b/core/shim/array.js index a37b0362c0..c2abd19741 100644 --- a/core/shim/array.js +++ b/core/shim/array.js @@ -23,7 +23,7 @@ */ if (!Array.isArray) { Object.defineProperty(Array, "isArray", { - value: function(obj) { + value: function (obj) { return Object.prototype.toString.call(obj) === "[object Array]"; }, writable: true, diff --git a/core/shim/object.js b/core/shim/object.js index d488be0674..ba9b16305e 100644 --- a/core/shim/object.js +++ b/core/shim/object.js @@ -23,13 +23,13 @@ if (!Object.create) { Object._creator = function _ObjectCreator() { this.__proto__ = _ObjectCreator.prototype; }; - Object.create = function(o, properties) { + Object.create = function (o, properties) { this._creator.prototype = o || Object.prototype; //Still needs to add properties.... return new this._creator; }; - Object.getPrototypeOf = function(o) { + Object.getPrototypeOf = function (o) { return o.__proto__; }; } @@ -40,7 +40,7 @@ if (!Object.create) { // TODO documentation if (!Object.isSealed) { Object.defineProperty(Object, "isSealed", { - value: function() { + value: function () { return false; }, writable: true, @@ -51,7 +51,7 @@ if (!Object.isSealed) { // TODO documentation if (!Object.seal) { Object.defineProperty(Object, "seal", { - value: function(object) { + value: function (object) { return object; }, writable: true, diff --git a/core/state-chart.js b/core/state-chart.js index f0ba045af6..1bd9c4f588 100644 --- a/core/state-chart.js +++ b/core/state-chart.js @@ -23,12 +23,12 @@ var State = exports.State = Montage.specialize( /** @lends State# */{ /** * Initializes a State object with a set of options. - * @method + * @function * @param {string} options The options for the new State. * @returns {State} */ init: { - value: function(options) { + value: function (options) { this.substates = {}; this.enterState = null; @@ -83,13 +83,13 @@ var State = exports.State = Montage.specialize( /** @lends State# */{ * @default {string} null */ initialSubstate: { - get: function() { + get: function () { if (typeof this._initialSubstate === "string") { this._initialSubstate = this[this._initialSubstate]; } return this._initialSubstate; }, - set: function(value) { + set: function (value) { this._initialSubstate = value; } }, @@ -126,7 +126,7 @@ var State = exports.State = Montage.specialize( /** @lends State# */{ path: { // TODO add dependency on parentState, remember to clear cached value enumerable: false, - get: function() { + get: function () { if (!this._path) { if (this.parentState && this.parentState.path) { @@ -158,14 +158,14 @@ var State = exports.State = Montage.specialize( /** @lends State# */{ }, /** - * @method + * @function * @param {string} otherState * @returns `!!this.path.match(new RegExp(".?" + otherState + ".?"))` */ // TODO XXX @returns block should be in code isInState: { enumerable: false, - value: function(otherState) { + value: function (otherState) { if (typeof otherState !== "string") { otherState = otherState.name; @@ -176,8 +176,8 @@ var State = exports.State = Montage.specialize( /** @lends State# */{ }, _encloseGotoState: { - value: function(state) { - return (function(stateChart, owner) { + value: function (state) { + return (function (stateChart, owner) { // Not relying on original implementation to save an extra function call, despite duplicated code return this._stateChart._gotoState(state, owner); }); @@ -185,20 +185,20 @@ var State = exports.State = Montage.specialize( /** @lends State# */{ }, /** - * @method + * @function * @param {Property} state * @param {Property} owner * @returns this._stateChart._gotoState(state, owner) */ gotoState: { - value: function(state, owner) { + value: function (state, owner) { return this._stateChart._gotoState(state, owner); } }, _performAction: { enumerable: null, - value: function(actionName, stateChart, owner) { + value: function (actionName, stateChart, owner) { if (this[actionName]) { // TODO what should the context be inside the action function: // state or stateChart? state makes sense but requires that @@ -217,12 +217,12 @@ var State = exports.State = Montage.specialize( /** @lends State# */{ }, /** - * @method + * @function * @returns "[State " + this.path + " ]" */ toString: { enumerable: false, - value: function() { + value: function () { return "[State " + this.path + " ]"; } } @@ -276,11 +276,11 @@ var StateChart = exports.StateChart = Montage.specialize(/** @lends StateChart# /** * The current state. - * @method + * @function * @returns The current state. */ currentState: { - get: function() { + get: function () { return this.ownerStateProperty ? null : this._currentState; } }, @@ -288,12 +288,12 @@ var StateChart = exports.StateChart = Montage.specialize(/** @lends StateChart# /** * Initializes a StateChart with a State object, and returns the * StateChart. - * @method + * @function * @param {string} state TODO * @returns {StateChart} */ initWithState: { - value: function(state) { + value: function (state) { this._states = {}; @@ -314,12 +314,12 @@ var StateChart = exports.StateChart = Montage.specialize(/** @lends StateChart# /** * The default state. - * @method + * @function * @returns this._defaultState */ defaultState: { enumerable: false, - get: function() { + get: function () { if (!this._defaultState) { var deepestState, nextState; @@ -337,12 +337,12 @@ var StateChart = exports.StateChart = Montage.specialize(/** @lends StateChart# }, /** - * @method + * @function * @returns this.defaultState */ enterDefaultState: { enumerable: false, - value: function() { + value: function () { if (this.ownerStateProperty && !this.owner) { throw "This stateChart has been configured to require an owner to execute this function"; } @@ -391,7 +391,7 @@ var StateChart = exports.StateChart = Montage.specialize(/** @lends StateChart# _prepareState: { enumerable: false, - value: function(state) { + value: function (state) { state._stateChart = this; // Keep a record of all states other than the root @@ -412,24 +412,24 @@ var StateChart = exports.StateChart = Montage.specialize(/** @lends StateChart# }, /** - * @method + * @function * @param {Property} stateName TODO * @returns {Array} this._states[stateName] */ stateWithName: { enumerable: false, - value: function(stateName) { + value: function (stateName) { return this._states[stateName]; } }, /** - * @method + * @function * @param {string} action TODO * @param {string} owner TODO */ performAction: { - value: function(action, owner) { + value: function (action, owner) { if (this.ownerStateProperty && !owner) { throw "This stateChart has been configured to require an owner to execute this function"; @@ -451,7 +451,7 @@ var StateChart = exports.StateChart = Montage.specialize(/** @lends StateChart# }, _gotoState: { - value: function(state, owner) { + value: function (state, owner) { if (this.ownerStateProperty && !owner) { throw "This stateChart has been configured to require an owner to execute this function"; diff --git a/core/target.js b/core/target.js index 77b9fc5e69..914171add4 100644 --- a/core/target.js +++ b/core/target.js @@ -8,8 +8,9 @@ var Montage = require("./core").Montage, * Montage application. * * @class Target + * @extends Montage */ -exports.Target = Montage.specialize( /** @lends Target# */ { +exports.Target = Montage.specialize( /** @lends Target # */ { constructor: { value: function Target() { @@ -51,7 +52,7 @@ exports.Target = Montage.specialize( /** @lends Target# */ { /** * Called prior to this target becoming the activeTarget - * @method + * @function * @param {Target} oldTarget the current activeTarget */ willBecomeActiveTarget: { @@ -60,7 +61,7 @@ exports.Target = Montage.specialize( /** @lends Target# */ { /** * Called after to this target became the activeTarget - * @method + * @function */ didBecomeActiveTarget: { value: Function.noop @@ -68,10 +69,10 @@ exports.Target = Montage.specialize( /** @lends Target# */ { /** * Ask this target to surrender its activeTarget status. - * @method + * @function * @param {Target} newTarget the Target that is about to become the * `activeTarget` - * @return {boolean} Whether or not to surrender activeTarget status + * @returns {boolean} Whether or not to surrender activeTarget status */ surrendersActiveTarget: { value: function (newTarget) { @@ -82,7 +83,8 @@ exports.Target = Montage.specialize( /** @lends Target# */ { /** * Which target to distribute an event after this when distributing events * throughout a graph of targets. - * @type {Component} + * @property {boolean} serializable + * @property {Component} value */ nextTarget: { serializable: false, @@ -92,11 +94,11 @@ exports.Target = Montage.specialize( /** @lends Target# */ { /** * Dispatches the specified event with this target * as the event's proximal target - * @method + * @function * @param {Event} event The event object to dispatch */ dispatchEvent: { - value: function(event) { + value: function (event) { var targettedEvent = event; if (! (event instanceof MutableEvent)) { @@ -113,14 +115,14 @@ exports.Target = Montage.specialize( /** @lends Target# */ { /** * Creates and dispatches an event with the specified properties with this * target as the event's proximal target - * @method + * @function * @param {string} type The type of the event to dispatch * @param {boolean} canBubble Whether or not the event can bubble * @param {boolean} cancelable Whether or not the event can be cancelled * @param {Object} detail The optional detail object of the event */ dispatchEventNamed: { - value: function(type, canBubble, cancelable, detail) { + value: function (type, canBubble, cancelable, detail) { var event = MutableEvent.fromType(type, canBubble, cancelable, detail); event.target = this; defaultEventManager.handleEvent(event); @@ -131,7 +133,7 @@ exports.Target = Montage.specialize( /** @lends Target# */ { /** * Adds an event listener to the object. - * @method + * @function * @param {string} type The event type to listen for. * @param {object | function} listener The listener object or function. * @param {boolean} useCapture Specifies whether to listen for the event during the bubble or capture phases. @@ -146,7 +148,7 @@ exports.Target = Montage.specialize( /** @lends Target# */ { /** * Removes an event listener from the object. - * @method + * @function * @param {string} type The event type. * @param {object | function} listener The listener object or function. * @param {boolean} useCapture The phase of the event listener. diff --git a/core/template.js b/core/template.js index 2dcefef2bc..bfab343e43 100644 --- a/core/template.js +++ b/core/template.js @@ -27,10 +27,10 @@ var Template = Montage.specialize( /** @lends Template# */ { _objectsString: {value: null}, objectsString: { - get: function() { + get: function () { return this._objectsString; }, - set: function(value) { + set: function (value) { this._objectsString = value; if (this._serialization) { this._serialization.initWithString(value); @@ -44,7 +44,7 @@ var Template = Montage.specialize( /** @lends Template# */ { // Deserializer cache __deserializer: {value: null}, _deserializer: { - get: function() { + get: function () { var deserializer = this.__deserializer, metadata, requires; @@ -66,7 +66,7 @@ var Template = Montage.specialize( /** @lends Template# */ { } }, getDeserializer: { - value: function() { + value: function () { return this._deserializer; } }, @@ -75,7 +75,7 @@ var Template = Montage.specialize( /** @lends Template# */ { value: null }, getSerialization: { - value: function() { + value: function () { var serialiation = this._serialization; if (!serialiation) { @@ -92,10 +92,10 @@ var Template = Montage.specialize( /** @lends Template# */ { }, isDirty: { - get: function() { + get: function () { return this._isDirty; }, - set: function(value) { + set: function (value) { if (this._isDirty !== value) { this._isDirty = value; this.clearTemplateFromElementContentsCache(); @@ -116,13 +116,13 @@ var Template = Montage.specialize( /** @lends Template# */ { }, document: { - get: function() { + get: function () { if (this._isDirty) { this.refresh(); } return this._document; }, - set: function(value) { + set: function (value) { this._document = value; } }, @@ -136,12 +136,12 @@ var Template = Montage.specialize( /** @lends Template# */ { /** * Initializes the Template with an empty document. * - * @method + * @function * @param {require} _require The require function used to load modules when * a template is instantiated. */ initWithRequire: { - value: function(_require) { + value: function (_require) { this._require = _require; this.document = this.createHtmlDocumentWithHtml(""); this.objectsString = ""; @@ -153,7 +153,7 @@ var Template = Montage.specialize( /** @lends Template# */ { /** * Initializes the Template with a document. * - * @method + * @function * @param {HTMLDocument} _document The document to be used as a template. * @param {require} _require The require function used to load modules when * a template is instantiated. @@ -161,14 +161,14 @@ var Template = Montage.specialize( /** @lends Template# */ { * template. */ initWithDocument: { - value: function(_document, _require) { + value: function (_document, _require) { var self = this; this._require = _require; this.setDocument(_document); return this.getObjectsString(_document) - .then(function(objectsString) { + .then(function (objectsString) { self.objectsString = objectsString; return self; }); @@ -178,7 +178,7 @@ var Template = Montage.specialize( /** @lends Template# */ { /** * Initializes the Template with an HTML string. * - * @method + * @function * @param {HTMLDocument} html The HTML string to be used as a template. * @param {require} _require The require function used to load modules when * a template is instantiated. @@ -186,14 +186,14 @@ var Template = Montage.specialize( /** @lends Template# */ { * template. */ initWithHtml: { - value: function(html, _require) { + value: function (html, _require) { var self = this; this._require = _require; this.document = this.createHtmlDocumentWithHtml(html); return this.getObjectsString(this.document) - .then(function(objectsString) { + .then(function (objectsString) { self.objectsString = objectsString; return self; }); @@ -204,7 +204,7 @@ var Template = Montage.specialize( /** @lends Template# */ { * Initializes the Template with Objects and a DocumentFragment to be * used as the body of the document. * - * @method + * @function * @param {Object} objects A JSON'able representation of the objects of the * template. * @param {DocumentFragment} html The HTML string to be used as the body. @@ -214,7 +214,7 @@ var Template = Montage.specialize( /** @lends Template# */ { * template. */ initWithObjectsAndDocumentFragment: { - value: function(objects, documentFragment, _require) { + value: function (objects, documentFragment, _require) { var self = this; this._require = _require; @@ -231,7 +231,7 @@ var Template = Montage.specialize( /** @lends Template# */ { /** * Initializes the Template with the HTML document at the module id. * - * @method + * @function * @param {string} moduleId The module id of the HTML page to load. * @param {require} _require The require function used to load modules when * a template is instantiated. @@ -239,20 +239,20 @@ var Template = Montage.specialize( /** @lends Template# */ { * template. */ initWithModuleId: { - value: function(moduleId, _require) { + value: function (moduleId, _require) { var self = this; this._require = _require; return this.createHtmlDocumentWithModuleId(moduleId, _require) - .then(function(_document) { + .then(function (_document) { var baseUrl = _require(moduleId).directory; self.document = _document; self.setBaseUrl(baseUrl); return self.getObjectsString(_document) - .then(function(objectsString) { + .then(function (objectsString) { self.objectsString = objectsString; return self; @@ -262,7 +262,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, clone: { - value: function() { + value: function () { var clonedTemplate = new Template(); clonedTemplate._require = this._require; @@ -276,7 +276,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, instantiate: { - value: function(targetDocument) { + value: function (targetDocument) { return this.instantiateWithInstances(null, targetDocument); } }, @@ -290,7 +290,7 @@ var Template = Montage.specialize( /** @lends Template# */ { * resultant of the instantiation. */ instantiateWithInstances: { - value: function(instances, targetDocument) { + value: function (instances, targetDocument) { var self = this, fragment, part = new DocumentPart(), @@ -308,7 +308,7 @@ var Template = Montage.specialize( /** @lends Template# */ { templateObjects = this._createTemplateObjects(instances); return this._instantiateObjects(templateObjects, fragment) - .then(function(objects) { + .then(function (objects) { var resources; part.objects = objects; @@ -335,11 +335,11 @@ var Template = Montage.specialize( /** @lends Template# */ { value: null }, /** - * @return {undefined|Promise} A promise if there are objects to optimize, + * @returns {undefined|Promise} A promise if there are objects to optimize, * nothing otherwise. */ _optimizeObjectsInstantiation: { - value: function() { + value: function () { var self = this, promise; @@ -349,7 +349,7 @@ var Template = Montage.specialize( /** @lends Template# */ { if (promise) { this._optimizeObjectsInstantiationPromise = promise - .then(function() { + .then(function () { self._objectsInstantiationOptimized = true; }); } else { @@ -363,19 +363,19 @@ var Template = Montage.specialize( /** @lends Template# */ { }, setBaseUrl: { - value: function(baseUrl) { + value: function (baseUrl) { this._baseUrl = baseUrl; } }, getBaseUrl: { - value: function() { + value: function () { return this._baseUrl; } }, getResources: { - value: function() { + value: function () { var resources = this._resources; if (!resources) { @@ -395,7 +395,7 @@ var Template = Montage.specialize( /** @lends Template# */ { * @returns {Object} The object with instances and application and template. */ _createTemplateObjects: { - value: function(instances) { + value: function (instances) { var templateObjects = Object.create(instances || null); if (typeof defaultApplication === "undefined") { @@ -410,7 +410,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, _instantiateObjects: { - value: function(instances, fragment) { + value: function (instances, fragment) { var self = this, deserializer = this._deserializer, optimizationPromise; @@ -418,7 +418,7 @@ var Template = Montage.specialize( /** @lends Template# */ { optimizationPromise = this._optimizeObjectsInstantiation(); if (optimizationPromise) { - return optimizationPromise.then(function() { + return optimizationPromise.then(function () { return deserializer.deserialize(instances, fragment); }); } else { @@ -428,7 +428,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, _createMarkupDocumentFragment: { - value: function(targetDocument) { + value: function (targetDocument) { var fragment = targetDocument.createDocumentFragment(), nodes = this.document.body.childNodes; @@ -443,19 +443,19 @@ var Template = Montage.specialize( /** @lends Template# */ { }, getParameterName: { - value: function(element) { + value: function (element) { return element.getAttribute(this.PARAM_ATTRIBUTE); } }, getParameters: { - value: function() { + value: function () { return this._getParameters(this.document.body); } }, _getParameters: { - value: function(rootElement) { + value: function (rootElement) { var elements = rootElement.querySelectorAll("*[" + this.PARAM_ATTRIBUTE + "]"), elementsCount = elements.length, element, @@ -485,13 +485,13 @@ var Template = Montage.specialize( /** @lends Template# */ { }, hasParameters: { - value: function() { + value: function () { return !!this.document.querySelector("*[" + this.PARAM_ATTRIBUTE + "]"); } }, _invokeDelegates: { - value: function(documentPart, instances) { + value: function (documentPart, instances) { var objects = documentPart.objects, object, owner = objects.owner || instances && instances.owner, @@ -547,23 +547,23 @@ var Template = Montage.specialize( /** @lends Template# */ { * unless a different set of instances is passed in * instantiateWithInstances(). * - * @method + * @function * @param {Object} instances The objects' instances. */ setInstances: { - value: function(instances) { + value: function (instances) { this._instances = instances; } }, getInstances: { - value: function() { + value: function () { return this._instances; } }, setObjects: { - value: function(objects) { + value: function (objects) { // TODO: use Serializer.formatSerialization(object|string) this.objectsString = JSON.stringify(objects, null, 4); } @@ -580,7 +580,7 @@ var Template = Montage.specialize( /** @lends Template# */ { * @param {Object} owner The owner object to be given to the object. */ setObjectMetadata: { - value: function(label, _require, effectiveLabel, owner) { + value: function (label, _require, effectiveLabel, owner) { var metadata = this._metadata; if (!metadata) { @@ -600,7 +600,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, getObjectMetadata: { - value: function(label) { + value: function (label) { var metadata = this._metadata; if (metadata && label in metadata) { @@ -615,7 +615,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, _getObjectOwner: { - value: function(label, defaultOwner) { + value: function (label, defaultOwner) { var objectOwner, metadata = this._metadata; @@ -630,7 +630,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, _getObjectLabel: { - value: function(label) { + value: function (label) { var objectLabel, metadata = this._metadata; @@ -647,13 +647,13 @@ var Template = Montage.specialize( /** @lends Template# */ { /** * Uses the document markup as the base of the template markup. * - * @method + * @function * @param {HTMLDocument} doc The document. * @returns {Promise} A promise for the proper initialization of the * document. */ setDocument: { - value: function(_document) { + value: function (_document) { var html = _document.documentElement.innerHTML; this.document = this.createHtmlDocumentWithHtml(html, _document.baseURI); @@ -666,13 +666,13 @@ var Template = Montage.specialize( /** @lends Template# */ { * The objects string can live as an inline script in the document or as an * external resource that needs to be loaded. * - * @method + * @function * @param {HTMLDocument} doc The document with the objects string. * @returns {Promise} A promise for the objects string, null if not * found. */ getObjectsString: { - value: function(doc) { + value: function (doc) { var objectsString; objectsString = this.getInlineObjectsString(doc); @@ -688,12 +688,13 @@ var Template = Montage.specialize( /** @lends Template# */ { /** * Searches for an inline objects string in a document and returns it if * found. - * @method + * + * @function * @param {HTMLDocument} doc The document with the objects string. - * @returns {(String|null)} The objects string or null if not found. + * @returns {?String} The objects string or null if not found. */ getInlineObjectsString: { - value: function(doc) { + value: function (doc) { var selector = "script[type='" + this._SERIALIZATON_SCRIPT_TYPE + "']", script = doc.querySelector(selector); @@ -709,13 +710,13 @@ var Template = Montage.specialize( /** @lends Template# */ { * Searches for an external objects file in a document and returns its * contents if found. * - * @method + * @function * @param {string} doc The document to search. * @returns {Promise} A promise to the contents of the objects file or null * if none found. */ getExternalObjectsString: { - value: function(doc) { + value: function (doc) { var link = doc.querySelector('link[rel="serialization"]'), req, url, @@ -727,7 +728,7 @@ var Template = Montage.specialize( /** @lends Template# */ { deferred = Promise.defer(); req.open("GET", url); - req.addEventListener("load", function() { + req.addEventListener("load", function () { if (req.status == 200) { deferred.resolve(req.responseText); } else { @@ -736,7 +737,7 @@ var Template = Montage.specialize( /** @lends Template# */ { ); } }, false); - req.addEventListener("error", function(event) { + req.addEventListener("error", function (event) { deferred.reject( new Error("Unable to retrive '" + url + "' with error: " + event.error + ".") ); @@ -751,7 +752,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, createHtmlDocumentWithHtml: { - value: function(html, baseURI) { + value: function (html, baseURI) { var htmlDocument = document.implementation.createHTMLDocument(""); htmlDocument.documentElement.innerHTML = html; @@ -762,7 +763,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, createHtmlDocumentWithModuleId: { - value: function(moduleId, _require) { + value: function (moduleId, _require) { var self = this; if (typeof _require !== "function") { @@ -771,7 +772,7 @@ var Template = Montage.specialize( /** @lends Template# */ { ); } - return _require.async(moduleId).then(function(exports) { + return _require.async(moduleId).then(function (exports) { return self.createHtmlDocumentWithHtml(exports.content, exports.directory); }); } @@ -781,7 +782,7 @@ var Template = Montage.specialize( /** @lends Template# */ { * Removes all artifacts related to objects string */ _removeObjects: { - value: function(doc) { + value: function (doc) { var elements, selector = "script[type='" + this._SERIALIZATON_SCRIPT_TYPE + "'], link[rel='serialization']"; @@ -795,7 +796,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, _addObjects: { - value: function(doc, objectsString) { + value: function (doc, objectsString) { if (objectsString) { var script = doc.createElement("script"); @@ -816,7 +817,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, createTemplateFromElementContents: { - value: function(elementId) { + value: function (elementId) { var element, template, range, @@ -856,7 +857,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, createTemplateFromElement: { - value: function(elementId) { + value: function (elementId) { var element, range; @@ -907,7 +908,7 @@ var Template = Montage.specialize( /** @lends Template# */ { // TODO: should this be on Serialization? _createSerializationWithElementIds: { - value: function(elementIds) { + value: function (elementIds) { var serialization = new Serialization(), labels, extractedSerialization; @@ -940,7 +941,7 @@ var Template = Montage.specialize( /** @lends Template# */ { * */ expandParameters: { - value: function(templateArgumentProvider) { + value: function (templateArgumentProvider) { var parameterElements, argumentsElementIds = [], collisionTable, @@ -996,7 +997,7 @@ var Template = Montage.specialize( /** @lends Template# */ { // This approach works because the arguments serialization is // created assuming that template properties are just like any other // label and are considered external objects. - willMergeObjectWithLabel = function(label) { + willMergeObjectWithLabel = function (label) { if (label.indexOf(":") > 0) { return templateArgumentProvider .resolveTemplateArgumentTemplateProperty(label); @@ -1021,7 +1022,7 @@ var Template = Montage.specialize( /** @lends Template# */ { * already exist in the current template. */ _resolveElementIdCollisions: { - value: function(node, labeler) { + value: function (node, labeler) { var collisionTable, nodeElements, elementIds, @@ -1054,7 +1055,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, replaceNode: { - value: function(newNode, oldNode, labeler) { + value: function (newNode, oldNode, labeler) { var collisionTable; collisionTable = this._resolveElementIdCollisions(newNode, labeler); @@ -1066,7 +1067,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, insertNodeBefore: { - value: function(node, reference, labeler) { + value: function (node, reference, labeler) { var collisionTable; collisionTable = this._resolveElementIdCollisions(node, labeler); @@ -1078,7 +1079,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, appendNode: { - value: function(node, parentNode, labeler) { + value: function (node, parentNode, labeler) { var collisionTable; collisionTable = this._resolveElementIdCollisions(node, labeler); @@ -1090,7 +1091,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, getElementId: { - value: function(element) { + value: function (element) { if (element.getAttribute) { return element.getAttribute(this._ELEMENT_ID_ATTRIBUTE); } @@ -1098,19 +1099,19 @@ var Template = Montage.specialize( /** @lends Template# */ { }, setElementId: { - value: function(element, elementId) { + value: function (element, elementId) { element.setAttribute(this._ELEMENT_ID_ATTRIBUTE, elementId); } }, getElementIds: { - value: function() { + value: function () { return this._getElementIds(this.document.body); } }, _getElements: { - value: function(rootNode) { + value: function (rootNode) { var selector = "*[" + this._ELEMENT_ID_ATTRIBUTE + "]", elements, result = {}, @@ -1134,7 +1135,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, _getChildrenElementIds: { - value: function(rootNode) { + value: function (rootNode) { // XPath might do a better job here...should test. var selector = "*[" + this._ELEMENT_ID_ATTRIBUTE + "]", elements, @@ -1151,7 +1152,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, _getElementIds: { - value: function(rootNode) { + value: function (rootNode) { var elementIds = this._getChildrenElementIds(rootNode), elementId; @@ -1165,7 +1166,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, getElementById: { - value: function(elementId) { + value: function (elementId) { var selector = "*[" + this._ELEMENT_ID_ATTRIBUTE + "='" + elementId + "']"; return this.document.querySelector(selector); @@ -1173,7 +1174,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, html: { - get: function() { + get: function () { var _document = this.document; this._removeObjects(_document); @@ -1196,7 +1197,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, normalizeRelativeUrls: { - value: function(parentNode, baseUrl) { + value: function (parentNode, baseUrl) { // Resolve component's images relative URLs if we have a valid baseUrl if (typeof baseUrl === "string" && baseUrl !== "" && baseUrl !== 'about:blank') { // We are only looking for DOM and SVG image elements @@ -1237,7 +1238,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, replaceContentsWithTemplate: { - value: function(template) { + value: function (template) { this._require = template._require; this._baseUrl = template._baseUrl; this._document = template._document; @@ -1252,7 +1253,7 @@ var Template = Montage.specialize( /** @lends Template# */ { * Refresh the contents of the template when its dirty. */ refresh: { - value: function() { + value: function () { if (this.isDirty) { if (this.refresher && typeof this.refresher.refreshTemplate === "function") { @@ -1273,14 +1274,14 @@ var Template = Montage.specialize( /** @lends Template# */ { } }, _getTemplateCacheKey: { - value: function(moduleId, _require) { + value: function (moduleId, _require) { // Transforms relative module ids into absolute module ids moduleId = _require.resolve(moduleId); return _require.location + "#" + moduleId; } }, getTemplateWithModuleId: { - value: function(moduleId, _require) { + value: function (moduleId, _require) { var cacheKey, template; @@ -1307,7 +1308,7 @@ var Template = Montage.specialize( /** @lends Template# */ { }, _NORMALIZED_TAG_NAMES_SELECTOR: { - get: function() { + get: function () { if (!this.__NORMALIZED_TAG_NAMES_SELECTOR) { this.__NORMALIZED_TAG_NAMES_SELECTOR = this._NORMALIZED_TAG_NAMES.join(","); } @@ -1334,25 +1335,25 @@ var TemplateResources = Montage.specialize( /** @lends TemplateResources# */ { }, initWithTemplate: { - value: function(template) { + value: function (template) { this.template = template; } }, hasResources: { - value: function() { + value: function () { return this.getStyles().length > 0 || this.getScripts().length > 0; } }, resourcesLoaded: { - value: function() { + value: function () { return this._resourcesLoaded; } }, loadResources: { - value: function(targetDocument) { + value: function (targetDocument) { this._resourcesLoaded = true; return Promise.all([ @@ -1363,7 +1364,7 @@ var TemplateResources = Montage.specialize( /** @lends TemplateResources# */ { }, getScripts: { - value: function() { + value: function () { var scripts = this._resources.scripts, script, type, @@ -1390,7 +1391,7 @@ var TemplateResources = Montage.specialize( /** @lends TemplateResources# */ { }, loadScripts: { - value: function(targetDocument) { + value: function (targetDocument) { var scripts, promises = []; @@ -1407,7 +1408,7 @@ var TemplateResources = Montage.specialize( /** @lends TemplateResources# */ { }, loadScript: { - value: function(script, targetDocument) { + value: function (script, targetDocument) { var url, documentResources, newScript; @@ -1423,7 +1424,7 @@ var TemplateResources = Montage.specialize( /** @lends TemplateResources# */ { }, _cloneScriptElement: { - value: function(scriptTemplate, _document) { + value: function (scriptTemplate, _document) { var script = _document.createElement("script"), attributes = scriptTemplate.attributes, attribute; @@ -1440,7 +1441,7 @@ var TemplateResources = Montage.specialize( /** @lends TemplateResources# */ { }, getStyles: { - value: function() { + value: function () { var styles = this._resources.styles, template, templateStyles, @@ -1461,7 +1462,7 @@ var TemplateResources = Montage.specialize( /** @lends TemplateResources# */ { }, loadStyles: { - value: function(targetDocument) { + value: function (targetDocument) { var promises = [], styles; @@ -1478,7 +1479,7 @@ var TemplateResources = Montage.specialize( /** @lends TemplateResources# */ { }, loadStyle: { - value: function(element, targetDocument) { + value: function (element, targetDocument) { var url, documentResources; @@ -1494,7 +1495,7 @@ var TemplateResources = Montage.specialize( /** @lends TemplateResources# */ { }, createStylesForDocument: { - value: function(targetDocument) { + value: function (targetDocument) { var styles = this.getStyles(), newStyle, stylesForDocument = []; @@ -1523,7 +1524,7 @@ function instantiateDocument(_document, _require, instances) { clonedDocument = template.createHtmlDocumentWithHtml(html, _document.location.href); return template.initWithDocument(clonedDocument, _require) - .then(function() { + .then(function () { template.setBaseUrl(_document.location.href); // Instantiate it using the document given since we don't want to clone // the document markup @@ -1531,7 +1532,7 @@ function instantiateDocument(_document, _require, instances) { part.initWithTemplateAndFragment(template); return template._instantiateObjects(templateObjects, rootElement) - .then(function(objects) { + .then(function (objects) { part.objects = objects; template._invokeDelegates(part); @@ -1548,7 +1549,7 @@ var TemplateArgumentProvider = Montage.specialize({ * @private */ getTemplateArgumentElement: { - value: function(argumentName) {} + value: function (argumentName) {} }, /** @@ -1559,7 +1560,7 @@ var TemplateArgumentProvider = Montage.specialize({ * @private */ getTemplateArgumentSerialization: { - value: function(elementIds) {} + value: function (elementIds) {} }, /** @@ -1572,7 +1573,7 @@ var TemplateArgumentProvider = Montage.specialize({ * @private */ resolveTemplateArgumentTemplateProperty: { - value: function(templatePropertyLabel) {} + value: function (templatePropertyLabel) {} } }); diff --git a/core/tree-controller.js b/core/tree-controller.js index 8e31b695c1..d22bd6daec 100644 --- a/core/tree-controller.js +++ b/core/tree-controller.js @@ -1,3 +1,6 @@ +/** + * @module montage/core/tree-controller + */ var Montage = require("./core").Montage; var Map = require("collections/map"); var WeakMap = require("collections/weak-map"); @@ -14,7 +17,7 @@ var Object = require("collections/shim-object"); * Bind a root node from the data model to a tree controller and bind the tree * controller's iterations to a content controller for a repetition. */ -var Node = exports.TreeControllerNode = Montage.specialize( /** @lends TreeControllerNode# */ { +var Node = exports.TreeControllerNode = Montage.specialize( /** @lends TreeControllerNode.prototype # */ { /** * The only meaningful user-defined state for this tree view, whether the @@ -169,12 +172,14 @@ var Node = exports.TreeControllerNode = Montage.specialize( /** @lends TreeContr }, /** - * Creates a tree controller node. + * @constructs TreeControllerNode + * @param controller * @param content - * @param {string} childenPath * @param {Node} parent * @param {number} depth - * @param {[Number, Node]|null} entry + * @param {?Array} entry + * @param {Number} entry[0] + * @param {Node} entry[1] */ constructor: { value: function TreeControllerNode(controller, parent, content, depth, entry) { @@ -312,8 +317,9 @@ var Node = exports.TreeControllerNode = Montage.specialize( /** @lends TreeContr /** * @class TreeController + * @extends Montage */ -exports.TreeController = Montage.specialize( /** @lends TreeController# */ { +exports.TreeController = Montage.specialize( /** @lends TreeController.prototype # */ { /** * The input of a tree controller, an object to serve at the root of the @@ -463,7 +469,7 @@ exports.TreeController = Montage.specialize( /** @lends TreeController# */ { * `nodeForContent <- nodes{[content, this]}.toMap()` */ findNodeByContent: { - value: function(content, equals) { + value: function (content, equals) { if (this.root) { return this.root.findNodeByContent(content, equals); } @@ -478,7 +484,7 @@ exports.TreeController = Montage.specialize( /** @lends TreeController# */ { * The callback is called before continuing the walk on its children. */ preOrderWalk: { - value: function(callback) { + value: function (callback) { if (this.root) { this.root.preOrderWalk(callback); } @@ -490,7 +496,7 @@ exports.TreeController = Montage.specialize( /** @lends TreeController# */ { * The callback is called after continuing the walk on its children. */ postOrderWalk: { - value: function(callback) { + value: function (callback) { if (this.root) { this.root.postOrderWalk(callback); } diff --git a/core/undo-manager.js b/core/undo-manager.js index cdc0a16e8a..0c1ca7730b 100644 --- a/core/undo-manager.js +++ b/core/undo-manager.js @@ -93,7 +93,7 @@ var UNDO_OPERATION = 0, * * this.undoManager.register("Add Random", deferredUndo.promise); * - * return this.randomNumberGeneratorService.next().then(function(rand) { + * return this.randomNumberGeneratorService.next().then(function (rand) { * deferredUndo.resolve(["Add " + rand, self.subtract, self, rand]; * var result = self.total = self.total + number; * return result @@ -374,7 +374,7 @@ var UndoManager = exports.UndoManager = Target.specialize( /** @lends UndoManage * @param {string} label A label to associate with this undo entry. * @param {promise} operationPromise A promise for an undoable operation * @returns a promise for the resolution of the operationPromise - * @method + * @function */ register: { value: function (label, operationPromise) { @@ -440,7 +440,7 @@ var UndoManager = exports.UndoManager = Target.specialize( /** @lends UndoManage }, _resolveUndoEntry: { - value: function(entry, operationInfo) { + value: function (entry, operationInfo) { var label, undoFunction, context, @@ -554,7 +554,7 @@ var UndoManager = exports.UndoManager = Target.specialize( /** @lends UndoManage /** * Removes all items from the undo stack. - * @method + * @function */ clearUndo: { value: function () { @@ -564,7 +564,7 @@ var UndoManager = exports.UndoManager = Target.specialize( /** @lends UndoManage /** * Removes all items from the redo stack. - * @method + * @function */ clearRedo: { value: function () { @@ -600,7 +600,7 @@ var UndoManager = exports.UndoManager = Target.specialize( /** @lends UndoManage /** * Schedules the next undo operation for invocation as soon as possible - * @method + * @function * @returns {Promise} A promise resolving to true when this undo request has been performed */ undo: { @@ -621,7 +621,7 @@ var UndoManager = exports.UndoManager = Target.specialize( /** @lends UndoManage /** * Schedules the next redo operation for invocation as soon as possible - * @method + * @function * @returns {Promise} A promise resolving to true when this redo request has been performed */ redo: { diff --git a/externals.jsdoc b/externals.jsdoc deleted file mode 100644 index d386fa7dab..0000000000 --- a/externals.jsdoc +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Provided by Montage. - * @external AbstractButton - * @see http://montagejs.org/api/AbstractButton.html - */ - -/** - * Provided by Montage. - * @external Text - * @see http://montagejs.org/api/Text.html - */ - -/** - * Provided by Montage. - * @external AbstractTextField - * @see http://montagejs.org/api/AbstractTextField.html - */ - -/** - * Provided by Montage. - * @external AbstractImage - * @see http://montagejs.org/api/AbstractImage.html - */ - -/** - * Provided by Montage. - * @external AbstractCheckbox - * @see http://montagejs.org/api/AbstractCheckbox.html - */ - -/** - * Provided by Montage. - * @external AbstractNumberField - * @see http://montagejs.org/api/AbstractNumberField.html - */ - -/** - * Provided by Montage. - * @external AbstractRadioButton - * @see http://montagejs.org/api/AbstractRadioButton.html - */ - -/** - * Provided by Montage. - * @external AbstractTextArea - * @see http://montagejs.org/api/AbstractTextArea.html - */ - -/** - * Provided by Montage. - * @external AbstractSelect - * @see http://montagejs.org/api/AbstractSelect.html - */ diff --git a/montage.js b/montage.js index 00b6e3aaf0..869531a7b1 100644 --- a/montage.js +++ b/montage.js @@ -13,9 +13,9 @@ if (typeof window !== "undefined") { // Applications that use our loader will interact with this timeout // and class name to coordinate a nice loading experience. Applications that do not will // just go about business as usual and draw their content as soon as possible. - window.addEventListener("DOMContentLoaded", function() { + window.addEventListener("DOMContentLoaded", function () { var bootstrappingDelay = 1000; - document._montageStartBootstrappingTimeout = setTimeout(function() { + document._montageStartBootstrappingTimeout = setTimeout(function () { document._montageStartBootstrappingTimeout = null; var root = document.documentElement; @@ -269,7 +269,7 @@ if (typeof window !== "undefined") { .then(function (JSHINT) { if (!JSHINT.JSHINT(module.text)) { console.warn("JSHint Error: "+module.location); - JSHINT.JSHINT.errors.forEach(function(error) { + JSHINT.JSHINT.errors.forEach(function (error) { if (error) { console.warn("Problem at line "+error.line+" character "+error.character+": "+error.reason); if (error.evidence) { @@ -302,13 +302,13 @@ if (typeof window !== "undefined") { */ var reverseReelExpression = /((.*)\.reel)\/\2$/; var reverseReelFunction = function ($0, $1) { return $1; }; - exports.SerializationCompiler = function(config, compile) { - return function(module) { + exports.SerializationCompiler = function (config, compile) { + return function (module) { compile(module); if (!module.factory) return; var defaultFactory = module.factory; - module.factory = function(require, exports, module) { + module.factory = function (require, exports, module) { defaultFactory.call(this, require, exports, module); for (var name in exports) { var object = exports[name]; @@ -347,6 +347,7 @@ if (typeof window !== "undefined") { }; }; + var reelExpression = /([^\/]+)\.reel$/; /** * Allows reel directories to load the contained eponymous JavaScript * module. @@ -354,7 +355,6 @@ if (typeof window !== "undefined") { * @param config * @param loader the next loader in the chain */ - var reelExpression = /([^\/]+)\.reel$/; exports.ReelLoader = function (config, load) { return function (id, module) { var match = reelExpression.exec(id); @@ -367,13 +367,13 @@ if (typeof window !== "undefined") { }; }; + var metaExpression = /\.meta/; /** * Allows the .meta files to be loaded as json * @see Compiler middleware in require/require.js * @param config * @param compile */ - var metaExpression = /\.meta/; exports.MetaCompiler = function (config, compile) { return function (module) { var json = (module.location || "").match(metaExpression); @@ -387,13 +387,14 @@ if (typeof window !== "undefined") { }; /** - Allows the reel's html file to be loaded via require. - @see Compiler middleware in require/require.js - @param config - @param compiler + * Allows the reel's html file to be loaded via require. + * + * @see Compiler middleware in require/require.js + * @param config + * @param compiler */ - exports.TemplateCompiler = function(config, compile) { - return function(module) { + exports.TemplateCompiler = function (config, compile) { + return function (module) { if (!module.location) return; var match = module.location.match(/(.*\/)?(?=[^\/]+\.html(?:\.load\.js)?$)/); @@ -473,7 +474,7 @@ if (typeof window !== "undefined") { document.getElementsByTagName("head")[0].appendChild(script); }, - getParams: function() { + getParams: function () { var i, j, match, script, @@ -642,7 +643,7 @@ if (typeof window !== "undefined") { var defaultEventManager, application; // Setup Promise's longStackTrace support option - logger("Promise stacktrace support", function(state) { + logger("Promise stacktrace support", function (state) { Promise.longStackSupport = !!state; }); @@ -665,7 +666,7 @@ if (typeof window !== "undefined") { appModulePromise = montageRequire.async("core/application"); } - return appModulePromise.then(function(exports) { + return appModulePromise.then(function (exports) { var Application = exports[(applicationLocation ? applicationLocation.objectName : "Application")]; application = new Application(); Object.defineProperty(window.document, "application", { @@ -679,7 +680,7 @@ if (typeof window !== "undefined") { }); defaultEventManager.application = application; application.eventManager = defaultEventManager; - application._load(applicationRequire, function() { + application._load(applicationRequire, function () { if (params.module) { // If a module was specified in the config then we initialize it now applicationRequire.async(params.module) diff --git a/node.js b/node.js index 6e2896ca9e..e6ec21d0fc 100644 --- a/node.js +++ b/node.js @@ -97,7 +97,7 @@ MontageBoot.loadPackage = function (location, config) { }; MontageBoot.TemplateLoader = function (config, load) { - return function(id, module) { + return function (id, module) { var html = id.match(/(.*\/)?(?=[^\/]+\.html$)/); var serialization = id.match(/(?=[^\/]+\.json$)/); // XXX this is not necessarily a strong indicator of a serialization alone var reelModule = id.match(/(.*\/)?([^\/]+)\.reel\/\2$/); diff --git a/packages/mr/packages/q/q.js b/packages/mr/packages/q/q.js index 5880306d85..e9dda8218a 100644 --- a/packages/mr/packages/q/q.js +++ b/packages/mr/packages/q/q.js @@ -692,7 +692,7 @@ Q.race = race; function race(answerPs) { return promise(function(resolve, reject) { // Switch to this once we can assume at least ES5 - // answerPs.forEach(function(answerP) { + // answerPs.forEach(function (answerP) { // Q(answerP).then(resolve, reject); // }); // Use this in the meantime diff --git a/test/application-spec.js b/test/application-spec.js index 970c751d64..a281edc371 100644 --- a/test/application-spec.js +++ b/test/application-spec.js @@ -32,37 +32,37 @@ POSSIBILITY OF SUCH DAMAGE. var Montage = require("montage").Montage, TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; -TestPageLoader.queueTest("application-as-application", {src: "application/as-application.html"}, function(testPage) { - describe("application-spec", function() { - describe("Application used in application label", function() { - it("should draw correctly", function() { +TestPageLoader.queueTest("application-as-application", {src: "application/as-application.html"}, function (testPage) { + describe("application-spec", function () { + describe("Application used in application label", function () { + it("should draw correctly", function () { expect(testPage.test).toBeDefined(); }); - it("should be THE application", function() { + it("should be THE application", function () { expect(testPage.test.theOne).toEqual("true"); }); }); }); }); -TestPageLoader.queueTest("application-as-owner", {src: "application/as-owner.html"}, function(testPage) { - describe("application-spec", function() { - describe("Application used in owner label", function() { - it("should draw correctly", function() { +TestPageLoader.queueTest("application-as-owner", {src: "application/as-owner.html"}, function (testPage) { + describe("application-spec", function () { + describe("Application used in owner label", function () { + it("should draw correctly", function () { expect(testPage.test).toBeDefined(); }); }); }); }); -TestPageLoader.queueTest("application-test", {src: "application-test/application-test.html"}, function(testPage) { +TestPageLoader.queueTest("application-test", {src: "application-test/application-test.html"}, function (testPage) { var test; - beforeEach(function() { + beforeEach(function () { test = testPage.test; }); - describe("application-spec", function() { - describe("Application", function() { + describe("application-spec", function () { + describe("Application", function () { var testWindow; beforeEach(function () { testWindow = testPage.iframe.contentWindow; @@ -74,10 +74,10 @@ TestPageLoader.queueTest("application-test", {src: "application-test/application }) }); - describe("delegate", function() { - it("should have willFinishLoading method called", function() { + describe("delegate", function () { + it("should have willFinishLoading method called", function () { return testWindow.mr.async("montage/core/application").get("application") - .then(function(testApplication) { + .then(function (testApplication) { expect(testApplication.delegate.willFinishLoadingCalled).toBeTruthy(); }) @@ -88,17 +88,17 @@ TestPageLoader.queueTest("application-test", {src: "application-test/application }); }); -TestPageLoader.queueTest("application-test-subtype", {src: "application-test/application-test-subtype.html"}, function(testPage) { +TestPageLoader.queueTest("application-test-subtype", {src: "application-test/application-test-subtype.html"}, function (testPage) { var test; - beforeEach(function() { + beforeEach(function () { test = testPage.test; }); - describe("application-spec", function() { - describe("Application", function() { + describe("application-spec", function () { + describe("Application", function () { - describe("subtyping", function() { - it("should use defined subtype", function() { + describe("subtyping", function () { + it("should use defined subtype", function () { var testWindow = testPage.iframe.contentWindow; var testApplication = testWindow.mr("montage/core/application").application; expect(testApplication.testProperty).toBeTruthy(); diff --git a/test/application-test/app-delegate.js b/test/application-test/app-delegate.js index 497b26a4bf..14b621dd67 100644 --- a/test/application-test/app-delegate.js +++ b/test/application-test/app-delegate.js @@ -37,7 +37,7 @@ exports.AppDelegate = Montage.specialize( { }, willFinishLoading: { - value: function(application) { + value: function (application) { this.willFinishLoadingCalled = true; } } diff --git a/test/array-spec.js b/test/array-spec.js index cec24efb85..9c14172fd3 100644 --- a/test/array-spec.js +++ b/test/array-spec.js @@ -30,36 +30,36 @@ POSSIBILITY OF SUCH DAMAGE. */ var Montage = require("montage").Montage; -describe("array-spec", function() { +describe("array-spec", function () { - describe("mutator methods", function() { + describe("mutator methods", function () { - describe("when pushing", function() { + describe("when pushing", function () { - describe("a single value", function() { + describe("a single value", function () { var array, newValue; - beforeEach(function() { + beforeEach(function () { array = [0,1,2]; newValue = 3; }); // Want to double check that the expected behavior still works - afterEach(function() { + afterEach(function () { expect(array.length).toBe(4); expect(array[3]).toBe(newValue); }); - it("should push the new value on the end of the array", function() { + it("should push the new value on the end of the array", function () { array.push(newValue); // Expectations performed automatically }); - it("should notify listeners observing the array for 'change' events, with a collection of the pushed values", function() { + it("should notify listeners observing the array for 'change' events, with a collection of the pushed values", function () { var arrayChangeListener = { - changeHandlerFunction: function(event) { + changeHandlerFunction: function (event) { expect(event.minus.length).toBe(0); expect(event.plus[0]).toBe(newValue); expect(event.plus.length).toBe(1); @@ -76,9 +76,9 @@ describe("array-spec", function() { expect(arrayChangeListener.changeHandlerFunction).toHaveBeenCalled(); }); - it("should notify listeners observing the affected index of the array for 'change' events, detailing the diff at that index", function() { + it("should notify listeners observing the affected index of the array for 'change' events, detailing the diff at that index", function () { var indexChangeListener = { - changeHandlerFunction: function(event) { + changeHandlerFunction: function (event) { expect(event.minus).not.toBeDefined(); expect(event.plus).toBe(newValue); } @@ -93,9 +93,9 @@ describe("array-spec", function() { expect(indexChangeListener.changeHandlerFunction).toHaveBeenCalled(); }); - it("must not notify listeners observing unaffected indices of the array for 'change' events", function() { + it("must not notify listeners observing unaffected indices of the array for 'change' events", function () { var indexChangeListener = { - changeHandlerFunction: function(event) { + changeHandlerFunction: function (event) { throw "Did not expect to handle event for " + event.type; } }; @@ -115,30 +115,30 @@ describe("array-spec", function() { }); - describe("multiple values", function() { + describe("multiple values", function () { var array, newValues; - beforeEach(function() { + beforeEach(function () { array = [0,1,2]; newValues = [3,4]; }); - afterEach(function() { + afterEach(function () { expect(array.length).toBe(5); expect(array[3]).toBe(newValues[0]); expect(array[4]).toBe(newValues[1]); }); - it("should push the new values on the end of the array", function() { + it("should push the new values on the end of the array", function () { array.push.apply(array, newValues); // Expectations performed automatically }); - it("should notify listeners observing the array for 'change' events, detailing the diff", function() { + it("should notify listeners observing the array for 'change' events, detailing the diff", function () { var arrayChangeListener = { - changeHandlerFunction: function(event) { + changeHandlerFunction: function (event) { expect(event.minus.length).toBe(0); expect(event.plus.length).toBe(2); expect(event.plus[0]).toBe(newValues[0]); @@ -155,16 +155,16 @@ describe("array-spec", function() { expect(arrayChangeListener.changeHandlerFunction).toHaveBeenCalled(); }); - it("should notify listeners observing the affected index of the array for 'change' events, detailing the diff at those respective indexes", function() { + it("should notify listeners observing the affected index of the array for 'change' events, detailing the diff at those respective indexes", function () { var index3ChangeListener = { - index3ChangeHandlerFunction: function(event) { + index3ChangeHandlerFunction: function (event) { expect(event.minus).not.toBeDefined(); expect(event.plus).toBe(newValues[0]); } }; var index4ChangeListener = { - index4ChangeHandlerFunction: function(event) { + index4ChangeHandlerFunction: function (event) { expect(event.minus).not.toBeDefined(); expect(event.plus).toBe(newValues[1]); } @@ -182,9 +182,9 @@ describe("array-spec", function() { expect(index4ChangeListener.index4ChangeHandlerFunction).toHaveBeenCalled(); }); - it("must not notify listeners observing unaffected indices of the array for 'change' events", function() { + it("must not notify listeners observing unaffected indices of the array for 'change' events", function () { var indexChangeListener = { - changeHandlerFunction: function(event) { + changeHandlerFunction: function (event) { throw "Did not expect to handle event for " + event.type; } }; @@ -206,30 +206,30 @@ describe("array-spec", function() { }); - describe("when popping", function() { + describe("when popping", function () { var array, poppedValue; - beforeEach(function() { + beforeEach(function () { array = [0, 1, 2]; poppedValue = 2; }); // We want to make sure our own tinkering doesn't affect the expected behavior, but // I don't want to be the focus of these tests necessarily - afterEach(function() { + afterEach(function () { expect(array.length).toBe(2); expect(array[2]).not.toBeDefined(); }); - it("should return the last value removed from the end of the array", function() { + it("should return the last value removed from the end of the array", function () { expect(array.pop()).toBe(poppedValue); }); - it("should notify listeners observing the array for 'change' events, detailing the diff of the change", function() { + it("should notify listeners observing the array for 'change' events, detailing the diff of the change", function () { var arrayChangeListener = { - changeHandlerFunction: function(event) { + changeHandlerFunction: function (event) { expect(event.minus[0]).toBe(poppedValue); expect(event.plus.length).toBe(0); } @@ -244,9 +244,9 @@ describe("array-spec", function() { expect(arrayChangeListener.changeHandlerFunction).toHaveBeenCalled(); }); - it("should notify listeners observing the affected index of the array for 'change' events, detailing the diff of the change", function() { + it("should notify listeners observing the affected index of the array for 'change' events, detailing the diff of the change", function () { var indexChangeListener = { - changeHandlerFunction: function(event) { + changeHandlerFunction: function (event) { expect(event.minus).toBe(poppedValue); expect(event.plus).not.toBeDefined(); } @@ -261,9 +261,9 @@ describe("array-spec", function() { expect(indexChangeListener.changeHandlerFunction).toHaveBeenCalled(); }); - it ("must not notify listeners observing unaffected indices of the array for 'change' events", function() { + it ("must not notify listeners observing unaffected indices of the array for 'change' events", function () { var indexChangeListener = { - changeHandlerFunction: function(event) { + changeHandlerFunction: function (event) { throw "Did not expect to handle event for " + event.type; } }; @@ -281,14 +281,14 @@ describe("array-spec", function() { }); }); - describe("when shifting", function() { + describe("when shifting", function () { var array, shiftedValue, prevArray, newArray; - beforeEach(function() { + beforeEach(function () { prevArray = [0, 1, 2]; array = [0, 1, 2]; shiftedValue = 0; @@ -297,31 +297,31 @@ describe("array-spec", function() { // We want to make sure our own tinkering doesn't affect the expected behavior, but // I don't want to be the focus of these tests necessarily - afterEach(function() { + afterEach(function () { expect(array.length).toBe(2); expect(array[0]).toBe(1); expect(array[1]).toBe(2); expect(array[2]).not.toBeDefined(); }); - it("should return the first value removed from the front of the array", function() { + it("should return the first value removed from the front of the array", function () { expect(array.shift()).toBe(shiftedValue); }); - it ("must notify listeners observing affected indices of the array for 'change' events, providing the previous and new values at that index", function() { + it ("must notify listeners observing affected indices of the array for 'change' events, providing the previous and new values at that index", function () { var indexChangeListener = { - index0ChangeHandlerFunction: function(event) { + index0ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[0]); expect(event.plus).toBe(newArray[0]); }, - index1ChangeHandlerFunction: function(event) { + index1ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[1]); expect(event.plus).toBe(newArray[1]); }, - index2ChangeHandlerFunction: function(event) { + index2ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[2]); expect(event.plus).toBe(newArray[2]); } @@ -344,23 +344,23 @@ describe("array-spec", function() { }); - describe("when unshifting", function() { + describe("when unshifting", function () { - describe("a single value", function() { + describe("a single value", function () { var prevArray, array, unshiftedValue, newArray; - beforeEach(function() { + beforeEach(function () { prevArray = [0, 1, 2]; array = [0, 1, 2]; unshiftedValue = -1; newArray = [-1, 0, 1, 2]; }); - afterEach(function() { + afterEach(function () { expect(array.length).toBe(newArray.length); @@ -369,32 +369,32 @@ describe("array-spec", function() { } }); - it("should add the value to the front of the array", function() { + it("should add the value to the front of the array", function () { array.unshift(unshiftedValue); }); - it("should return the new length of the array", function() { + it("should return the new length of the array", function () { expect(array.unshift(unshiftedValue)).toBe(newArray.length); }); - it ("should notify listeners observing affected indices of the array for 'change' events, providing the previous and new values at that index", function() { + it ("should notify listeners observing affected indices of the array for 'change' events, providing the previous and new values at that index", function () { var indexChangeListener = { - index0ChangeHandlerFunction: function(event) { + index0ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[0]); expect(event.plus).toBe(newArray[0]); }, - index1ChangeHandlerFunction: function(event) { + index1ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[1]); expect(event.plus).toBe(newArray[1]); }, - index2ChangeHandlerFunction: function(event) { + index2ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[2]); expect(event.plus).toBe(newArray[2]); }, - index3ChangeHandlerFunction: function(event) { + index3ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[3]); expect(event.plus).toBe(newArray[3]); } @@ -420,21 +420,21 @@ describe("array-spec", function() { }); - describe("multiple values", function() { + describe("multiple values", function () { var prevArray, array, unshiftedValues, newArray; - beforeEach(function() { + beforeEach(function () { prevArray = [0, 1, 2]; array = [0, 1, 2]; unshiftedValues = [-2, -1]; newArray = [-2, -1, 0, 1, 2]; }); - afterEach(function() { + afterEach(function () { expect(array.length).toBe(newArray.length); @@ -443,37 +443,37 @@ describe("array-spec", function() { } }); - it("should add the values to the front of the array", function() { + it("should add the values to the front of the array", function () { array.unshift.apply(array, unshiftedValues); }); - it("should return the new length of the array", function() { + it("should return the new length of the array", function () { expect(array.unshift.apply(array, unshiftedValues)).toBe(newArray.length); }); - it ("should notify listeners observing affected indices of the array for 'change' events, providing the previous and new values at that index", function() { + it ("should notify listeners observing affected indices of the array for 'change' events, providing the previous and new values at that index", function () { var indexChangeListener = { - index0ChangeHandlerFunction: function(event) { + index0ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[0]); expect(event.plus).toBe(newArray[0]); }, - index1ChangeHandlerFunction: function(event) { + index1ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[1]); expect(event.plus).toBe(newArray[1]); }, - index2ChangeHandlerFunction: function(event) { + index2ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[2]); expect(event.plus).toBe(newArray[2]); }, - index3ChangeHandlerFunction: function(event) { + index3ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[3]); expect(event.plus).toBe(newArray[3]); }, - index4ChangeHandlerFunction: function(event) { + index4ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[4]); expect(event.plus).toBe(newArray[4]); } @@ -504,19 +504,19 @@ describe("array-spec", function() { }); - describe("when reversing", function() { + describe("when reversing", function () { var array, prevArray, newArray; - beforeEach(function() { + beforeEach(function () { prevArray = [0,1,2]; array = [0,1,2]; newArray = [2,1,0]; }); - afterEach(function() { + afterEach(function () { expect(array.length).toBe(newArray.length); for(var i = 0; i < newArray.length; i++) { @@ -524,23 +524,23 @@ describe("array-spec", function() { } }); - it("should reverse the order of the array", function() { + it("should reverse the order of the array", function () { array.reverse(); }); - it("should notify listeners observing affected indices of the array for 'change' events, providing the previous and new values at that index", function() { + it("should notify listeners observing affected indices of the array for 'change' events, providing the previous and new values at that index", function () { var indexChangeListener = { - index0ChangeHandlerFunction: function(event) { + index0ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[0]); expect(event.plus).toBe(newArray[0]); }, - index1ChangeHandlerFunction: function(event) { + index1ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[1]); expect(event.plus).toBe(newArray[1]); }, - index2ChangeHandlerFunction: function(event) { + index2ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[2]); expect(event.plus).toBe(newArray[2]); } @@ -563,20 +563,20 @@ describe("array-spec", function() { }); - describe("when sorting", function() { + describe("when sorting", function () { var myArray, sortedArray; - beforeEach(function() { + beforeEach(function () { myArray = ["alice", "eve", "carol", "bob", "david"]; sortedArray = ["alice", "bob", "carol", "david", "eve"]; }); - it("should return a reference to the sorted array", function() { + it("should return a reference to the sorted array", function () { expect(myArray.sort()).toBe(myArray); }); - it("should sort the array without a given sorting function", function() { + it("should sort the array without a given sorting function", function () { myArray.sort(); for (var i = 0; i < sortedArray.length; i++) { @@ -584,29 +584,29 @@ describe("array-spec", function() { } }); - it("TODO should sort the array with a given sorting function", function() { + it("TODO should sort the array with a given sorting function", function () { }); - describe("when observed for changes at any index", function() { + describe("when observed for changes at any index", function () { - it("TODO should dispatch a change for each index affected by the sort", function() { + it("TODO should dispatch a change for each index affected by the sort", function () { }); - it("TODO must not dispatch a change for an index unaffected by the sort", function() { + it("TODO must not dispatch a change for an index unaffected by the sort", function () { }); }); - describe("when observed for a change at the array itself", function() { + describe("when observed for a change at the array itself", function () { - it("TODO should dispatch a change for each index affected by the sort", function() { + it("TODO should dispatch a change for each index affected by the sort", function () { }); }); }); - describe("when splicing", function() { + describe("when splicing", function () { var array, prevArray, @@ -615,42 +615,42 @@ describe("array-spec", function() { spliceIndex, spliceLength; - beforeEach(function() { + beforeEach(function () { prevArray = [0, 1, 2]; array = [0, 1, 2]; }); - describe("to add a single object", function() { + describe("to add a single object", function () { - beforeEach(function() { + beforeEach(function () { splicedValue = "foo"; }); - describe("without replacement", function() { + describe("without replacement", function () { - beforeEach(function() { + beforeEach(function () { spliceLength = 0; }); - describe("into the middle of an array", function() { + describe("into the middle of an array", function () { - beforeEach(function() { + beforeEach(function () { spliceIndex = 1; newArray = [0, "foo", 1, 2]; }); - it("should insert the element at the index specified", function() { + it("should insert the element at the index specified", function () { array.splice(spliceIndex, spliceLength, splicedValue); }); - it("should return an array of the removed elements, which will be empty", function() { + it("should return an array of the removed elements, which will be empty", function () { var replacedValues = array.splice(spliceIndex, spliceLength, splicedValue); expect(replacedValues.length).toBe(0); }); - it("should notify listeners observing the array for 'change' events, providing the previous and new list values", function() { + it("should notify listeners observing the array for 'change' events, providing the previous and new list values", function () { var changeListener = { - changeHandlerFunction: function(event) { + changeHandlerFunction: function (event) { expect(event.minus.length).toBe(0); expect(event.plus.length).toBe(1); expect(event.plus[0]).toBe(splicedValue); @@ -666,9 +666,9 @@ describe("array-spec", function() { expect(changeListener.changeHandlerFunction).toHaveBeenCalled(); }); - it("must not notify listeners observing unaffected indices of the array for 'change' events", function() { + it("must not notify listeners observing unaffected indices of the array for 'change' events", function () { var indexChangeListener = { - indexChangeHandlerFunction: function(event) { + indexChangeHandlerFunction: function (event) { throw "Did not expect to handle event for " + event.type; } }; @@ -684,19 +684,19 @@ describe("array-spec", function() { expect(indexChangeListener.indexChangeHandlerFunction).not.toHaveBeenCalled(); }); - it("should notify listeners observing affected indices of the array for 'change' events, detailing the diff at that index", function() { + it("should notify listeners observing affected indices of the array for 'change' events, detailing the diff at that index", function () { var indexChangeListener = { - index1ChangeHandlerFunction: function(event) { + index1ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[1]); expect(event.plus).toBe(newArray[1]); }, - index2ChangeHandlerFunction: function(event) { + index2ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[2]); expect(event.plus).toBe(newArray[2]); }, - index3ChangeHandlerFunction: function(event) { + index3ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[3]); expect(event.plus).toBe(newArray[3]); } @@ -721,32 +721,32 @@ describe("array-spec", function() { }); - describe("with replacement", function() { + describe("with replacement", function () { - beforeEach(function() { + beforeEach(function () { spliceLength = 1; }); - describe("into the middle of an array", function() { + describe("into the middle of an array", function () { - beforeEach(function() { + beforeEach(function () { spliceIndex = 1; newArray = [0, "foo", 2]; }); - it("should insert the element at the index specified", function() { + it("should insert the element at the index specified", function () { array.splice(spliceIndex, spliceLength, splicedValue); }); - it("should return an array of the removed elements", function() { + it("should return an array of the removed elements", function () { var replacedValues = array.splice(spliceIndex, spliceLength, splicedValue); expect(replacedValues.length).toBe(1); expect(replacedValues[0]).toBe(1); }); - it("must not notify listeners observing unaffected indices of the array for 'change' events", function() { + it("must not notify listeners observing unaffected indices of the array for 'change' events", function () { var indexChangeListener = { - indexChangeHandlerFunction: function(event) { + indexChangeHandlerFunction: function (event) { throw "Did not expect to handle event for " + event.type; } }; @@ -763,9 +763,9 @@ describe("array-spec", function() { expect(indexChangeListener.indexChangeHandlerFunction).not.toHaveBeenCalled(); }); - it("should notify listeners observing affected indices of the array for 'change' events, providing the previous and new values at that index", function() { + it("should notify listeners observing affected indices of the array for 'change' events, providing the previous and new values at that index", function () { var index1ChangeListener = { - index1ChangeHandlerFunction: function(event) { + index1ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[1]); expect(event.plus).toBe(splicedValue); } @@ -784,7 +784,7 @@ describe("array-spec", function() { }); - afterEach(function() { + afterEach(function () { expect(array.length).toBe(newArray.length); for(var i = 0; i < newArray.length; i++) { @@ -794,40 +794,40 @@ describe("array-spec", function() { }); - xdescribe("to add multiple objects", function() { + xdescribe("to add multiple objects", function () { - it ("must not notify listeners observing unaffected indices of the array for 'change' events", function() { + it ("must not notify listeners observing unaffected indices of the array for 'change' events", function () { }); }); - describe("to remove a single object", function() { + describe("to remove a single object", function () { - beforeEach(function() { + beforeEach(function () { spliceLength = 1; }); - describe("from the middle of an array", function() { + describe("from the middle of an array", function () { - beforeEach(function() { + beforeEach(function () { spliceIndex = 1; newArray = [0, 2]; }); - it("should remove the element at the index specified", function() { + it("should remove the element at the index specified", function () { array.splice(spliceIndex, spliceLength); }); - it("should return an array of the removed elements", function() { + it("should return an array of the removed elements", function () { var replacedValues = array.splice(spliceIndex, spliceLength); expect(replacedValues.length).toBe(1); expect(replacedValues[0]).toBe(1); }); - it("should notify listeners observing the array for 'change' events, providing the previous and new list values", function() { + it("should notify listeners observing the array for 'change' events, providing the previous and new list values", function () { var changeListener = { - changeHandlerFunction: function(event) { + changeHandlerFunction: function (event) { expect(event.minus.length).toBe(1); expect(event.minus[0]).toBe(prevArray[1]); expect(event.plus.length).toBe(0); @@ -843,9 +843,9 @@ describe("array-spec", function() { expect(changeListener.changeHandlerFunction).toHaveBeenCalled(); }); - it("must not notify listeners observing unaffected indices of the array for 'change' events", function() { + it("must not notify listeners observing unaffected indices of the array for 'change' events", function () { var indexChangeListener = { - indexChangeHandlerFunction: function(event) { + indexChangeHandlerFunction: function (event) { throw "Did not expect to handle event for " + event.type; } }; @@ -861,14 +861,14 @@ describe("array-spec", function() { expect(indexChangeListener.indexChangeHandlerFunction).not.toHaveBeenCalled(); }); - it("should notify listeners observing affected indices of the array for 'change' events, providing the previous and new values at that index", function() { + it("should notify listeners observing affected indices of the array for 'change' events, providing the previous and new values at that index", function () { var indexChangeListener = { - index1ChangeHandlerFunction: function(event) { + index1ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[1]); expect(event.plus).toBe(newArray[1]); }, - index2ChangeHandlerFunction: function(event) { + index2ChangeHandlerFunction: function (event) { expect(event.minus).toBe(prevArray[2]); expect(event.plus).toBe(newArray[2]); } @@ -887,7 +887,7 @@ describe("array-spec", function() { }); }); - afterEach(function() { + afterEach(function () { expect(array.length).toBe(newArray.length); for(var i = 0; i < newArray.length; i++) { @@ -898,9 +898,9 @@ describe("array-spec", function() { }); - xdescribe("to remove multiple objects", function() { + xdescribe("to remove multiple objects", function () { - it("must not notify listeners observing unaffected indices of the array for 'change' events", function() { + it("must not notify listeners observing unaffected indices of the array for 'change' events", function () { }); @@ -910,39 +910,39 @@ describe("array-spec", function() { }); - describe("when detecting any", function() { + describe("when detecting any", function () { - it("should have an any method exposed", function() { + it("should have an any method exposed", function () { expect([].any).toBeTruthy(); }); - describe("when no property path is provided", function() { + describe("when no property path is provided", function () { - it("should return false for an empty array", function() { + it("should return false for an empty array", function () { expect([].any()).toBe(false); }); - it("should return false for an array with no truthy values", function() { + it("should return false for an array with no truthy values", function () { expect([0, false, null].any()).toBe(false); }); - it("should return true for an array with any truthy values", function() { + it("should return true for an array with any truthy values", function () { expect([0, false, null, true].any()).toBe(true); }); }); - describe("when a property path is provided", function() { + describe("when a property path is provided", function () { - it("should return false for an empty array", function() { + it("should return false for an empty array", function () { expect([].any("a.b")).toBe(false); }); - it("should return false for an array with no truthy values", function() { + it("should return false for an array with no truthy values", function () { expect([{a: {b: 0}}, {a: {b: false}}, {a: {b: null}}].any("a.b")).toBe(false); }); - it("should return true for an array with any truthy values", function() { + it("should return true for an array with any truthy values", function () { expect([{a: {b: 0}}, {a: {b: false}}, {a: {b: null}}, {a: {b: true}}].any("a.b")).toBe(true); }); diff --git a/test/base/abstract-alert-spec.js b/test/base/abstract-alert-spec.js index 953675109a..e535b116b5 100644 --- a/test/base/abstract-alert-spec.js +++ b/test/base/abstract-alert-spec.js @@ -26,11 +26,11 @@ AbstractAlert.prototype.hasTemplate = false; describe("test/base/abstract-alert-spec", function () { describe("creation", function () { - beforeEach(function() { + beforeEach(function () { setupMockRootComponent(); }); - afterEach(function() { + afterEach(function () { setdownMockRootComponent(); }); @@ -56,8 +56,8 @@ describe("test/base/abstract-alert-spec", function () { anAlert = new Alert(); anAlert.element = MockDOM.element(_document); anAlert._overlay = MockComponent.component(); - anAlert._overlay.show = function(){}; - anAlert._overlay.hide = function(){}; + anAlert._overlay.show = function (){}; + anAlert._overlay.hide = function (){}; anAlert._okButton = MockComponent.component(); }); @@ -76,8 +76,8 @@ describe("test/base/abstract-alert-spec", function () { }); }); - describe("user action", function() { - it("should resolve the user action promise when the ok button is pressed", function() { + describe("user action", function () { + it("should resolve the user action promise when the ok button is pressed", function () { var event = {target: anAlert._okButton}, promise = anAlert.show(); @@ -86,24 +86,24 @@ describe("test/base/abstract-alert-spec", function () { }) }); - describe("static show", function() { + describe("static show", function () { var AlertSubtype; - beforeEach(function() { + beforeEach(function () { setupMockRootComponent(); AlertSubtype = AbstractAlert.specialize({}); }); - afterEach(function() { + afterEach(function () { setdownMockRootComponent(); }); - it("should create an instance to show the alert", function() { + it("should create an instance to show the alert", function () { AlertSubtype.show("message"); expect(AlertSubtype._instance).toBeDefined(); }); - it("should create an instance to show the alert and add it to the document", function() { + it("should create an instance to show the alert and add it to the document", function () { AlertSubtype.show("message"); expect(AlertSubtype._instance.element).toBeDefined(); @@ -112,134 +112,134 @@ describe("test/base/abstract-alert-spec", function () { .toBe(_document.body); }); - it("should create an instance to show the alert and add it to the component tree", function() { + it("should create an instance to show the alert and add it to the component tree", function () { AlertSubtype.show("message"); expect(AlertSubtype._instance.parentComponent) .toBe(_document.rootComponent); }); - it("should create an instance to show the alert and add request it to draw", function() { + it("should create an instance to show the alert and add request it to draw", function () { AlertSubtype.show("message"); expect(AlertSubtype._instance.needsDraw).toBeTruthy(); }); - it("should return a promise of user action", function() { + it("should return a promise of user action", function () { var promise = AlertSubtype.show("message"); expect(Promise.isPromise(promise)).toBeTruthy(); }); - it("should configure the alert with the message upon entering the document", function() { + it("should configure the alert with the message upon entering the document", function () { AlertSubtype.show("message"); AlertSubtype._instance._overlay = MockComponent.component(); - AlertSubtype._instance._overlay.show = function(){}; - AlertSubtype._instance._overlay.hide = function(){}; + AlertSubtype._instance._overlay.show = function (){}; + AlertSubtype._instance._overlay.hide = function (){}; AlertSubtype._instance._okButton = MockComponent.component(); AlertSubtype._instance.enterDocument(true); spyOn(AlertSubtype._instance, "show").andCallThrough(); - waitsFor(function() { + waitsFor(function () { return AlertSubtype._instance.show.calls.length === 1; }); - runs(function() { + runs(function () { expect(AlertSubtype._instance.message).toBe("message"); }); }); - it("should configure the alert with the title upon entering the document", function() { + it("should configure the alert with the title upon entering the document", function () { AlertSubtype.show("message", "a title"); AlertSubtype._instance._overlay = MockComponent.component(); - AlertSubtype._instance._overlay.show = function(){}; - AlertSubtype._instance._overlay.hide = function(){}; + AlertSubtype._instance._overlay.show = function (){}; + AlertSubtype._instance._overlay.hide = function (){}; AlertSubtype._instance._okButton = MockComponent.component(); AlertSubtype._instance.enterDocument(true); spyOn(AlertSubtype._instance, "show").andCallThrough(); - waitsFor(function() { + waitsFor(function () { return AlertSubtype._instance.show.calls.length === 1; }); - runs(function() { + runs(function () { expect(AlertSubtype._instance.title).toBe("a title"); }); }); - it("should configure the alert with the next title when the current alert is closed", function() { + it("should configure the alert with the next title when the current alert is closed", function () { AlertSubtype.show("message", "a title"); AlertSubtype.show("another message", "another title"); AlertSubtype._instance._overlay = MockComponent.component(); - AlertSubtype._instance._overlay.show = function(){}; - AlertSubtype._instance._overlay.hide = function(){}; + AlertSubtype._instance._overlay.show = function (){}; + AlertSubtype._instance._overlay.hide = function (){}; AlertSubtype._instance._okButton = MockComponent.component(); AlertSubtype._instance.enterDocument(true); spyOn(AlertSubtype._instance, "show").andCallThrough(); - waitsFor(function() { + waitsFor(function () { return AlertSubtype._instance.show.calls.length === 1; }); - runs(function() { + runs(function () { AlertSubtype._instance.handleAction({target: AlertSubtype._instance._okButton}); - waitsFor(function() { + waitsFor(function () { return AlertSubtype._instance.show.calls.length === 2; }); - runs(function() { + runs(function () { expect(AlertSubtype._instance.title).toBe("another title"); }); }); }); - it("should configure the alert with the default message when the current alert is closed", function() { + it("should configure the alert with the default message when the current alert is closed", function () { AlertSubtype.show("message", "a title"); AlertSubtype.show("another message"); AlertSubtype._instance._overlay = MockComponent.component(); - AlertSubtype._instance._overlay.show = function(){}; - AlertSubtype._instance._overlay.hide = function(){}; + AlertSubtype._instance._overlay.show = function (){}; + AlertSubtype._instance._overlay.hide = function (){}; AlertSubtype._instance._okButton = MockComponent.component(); AlertSubtype._instance.enterDocument(true); spyOn(AlertSubtype._instance, "show").andCallThrough(); - waitsFor(function() { + waitsFor(function () { return AlertSubtype._instance.show.calls.length === 1; }); - runs(function() { + runs(function () { AlertSubtype._instance.handleAction({target: AlertSubtype._instance._okButton}); - waitsFor(function() { + waitsFor(function () { return AlertSubtype._instance.show.calls.length === 2; }); - runs(function() { + runs(function () { expect(AlertSubtype._instance.title).toBe(AlertSubtype.prototype.title); }); }); }); - it("should fulfill the show promise when the alert is closed", function() { + it("should fulfill the show promise when the alert is closed", function () { var promise = AlertSubtype.show("message"); AlertSubtype._instance._overlay = MockComponent.component(); - AlertSubtype._instance._overlay.show = function(){}; - AlertSubtype._instance._overlay.hide = function(){}; + AlertSubtype._instance._overlay.show = function (){}; + AlertSubtype._instance._overlay.hide = function (){}; AlertSubtype._instance._okButton = MockComponent.component(); AlertSubtype._instance.enterDocument(true); spyOn(AlertSubtype._instance, "show").andCallThrough(); - waitsFor(function() { + waitsFor(function () { return AlertSubtype._instance.show.calls.length === 1; }); - runs(function() { + runs(function () { AlertSubtype._instance.handleAction({target: AlertSubtype._instance._okButton}); expect(Promise.isFulfilled(promise)).toBeTruthy(); diff --git a/test/base/abstract-button-spec.js b/test/base/abstract-button-spec.js index 26ef87b7e4..c5ca53c350 100644 --- a/test/base/abstract-button-spec.js +++ b/test/base/abstract-button-spec.js @@ -127,7 +127,7 @@ describe("test/base/abstract-button-spec", function () { }); }); - describe("converter", function() { + describe("converter", function () { var Button = AbstractButton.specialize( {}); beforeEach(function () { aButton = new Button(); @@ -136,7 +136,7 @@ describe("test/base/abstract-button-spec", function () { aButton.originalElement = aButton.element; aButton.element.firstChild = MockDOM.element(); aButton.converter = { - convert: function(v) { + convert: function (v) { return v.replace(/fail/gi, "pass"); } }; @@ -157,10 +157,10 @@ describe("test/base/abstract-button-spec", function () { aButton = new Button(); anElement = MockDOM.element(); listener = { - handleEvent: function() {} + handleEvent: function () {} } }); - it("should listen for pressStart only after prepareForActivationEvents", function() { + it("should listen for pressStart only after prepareForActivationEvents", function () { var listeners, em = aButton.eventManager; @@ -172,7 +172,7 @@ describe("test/base/abstract-button-spec", function () { listeners = em.registeredEventListenersForEventType_onTarget_("pressStart", aButton._pressComposer); expect(listeners[aButton.uuid].listener).toBe(aButton); }); - it("should listen for longPress on PressComposer on demand", function() { + it("should listen for longPress on PressComposer on demand", function () { var listeners, em = aButton.eventManager; @@ -184,7 +184,7 @@ describe("test/base/abstract-button-spec", function () { listeners = em.registeredEventListenersForEventType_onTarget_("longPress", aButton._pressComposer); expect(listeners[aButton.uuid].listener).toBe(aButton); }); - it("should fires a 'longAction' event when the PressComposer fires a longPress", function() { + it("should fires a 'longAction' event when the PressComposer fires a longPress", function () { var callback = jasmine.createSpy(); aButton.addEventListener("longAction", callback, false); aButton._pressComposer.dispatchEventNamed("longPress"); @@ -195,8 +195,8 @@ describe("test/base/abstract-button-spec", function () { aButton.element = anElement; aButton.prepareForActivationEvents(); }); - it("should fire an 'action' event when the PressComposer fires a pressStart + press", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should fire an 'action' event when the PressComposer fires a pressStart + press", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.type).toEqual("action"); }); aButton.addEventListener("action", callback, false); @@ -206,8 +206,8 @@ describe("test/base/abstract-button-spec", function () { expect(callback).toHaveBeenCalled(); }); - it("shouldn't fire an 'action' event when the PressComposer fires a pressStart + pressCancel", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("shouldn't fire an 'action' event when the PressComposer fires a pressStart + pressCancel", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.type).toEqual("action"); }); aButton.addEventListener("action", callback, false); @@ -217,8 +217,8 @@ describe("test/base/abstract-button-spec", function () { expect(callback).not.toHaveBeenCalled(); }); - it("should fire an 'action' event with the contents of the detail property", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should fire an 'action' event with the contents of the detail property", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.detail.get("foo")).toEqual("bar"); }); aButton.addEventListener("action", callback, false); diff --git a/test/base/abstract-checkbox-spec.js b/test/base/abstract-checkbox-spec.js index c13d7be01d..27b59dd445 100644 --- a/test/base/abstract-checkbox-spec.js +++ b/test/base/abstract-checkbox-spec.js @@ -39,18 +39,18 @@ describe("test/base/abstract-checkbox-spec", function () { aCheckbox.prepareForActivationEvents(); }); - it("should be false by default", function() { + it("should be false by default", function () { expect(aCheckbox.checked).toBe(false); }); - it("should be true when the PressComposer fires a pressStart + press", function() { + it("should be true when the PressComposer fires a pressStart + press", function () { aCheckbox._pressComposer.dispatchEventNamed("pressStart"); aCheckbox._pressComposer.dispatchEventNamed("press"); expect(aCheckbox.checked).toBe(true); }); - it("should be false when the PressComposer fires a pressStart + pressCancel", function() { + it("should be false when the PressComposer fires a pressStart + pressCancel", function () { aCheckbox.checked = false; aCheckbox._pressComposer.dispatchEventNamed("pressStart"); @@ -59,7 +59,7 @@ describe("test/base/abstract-checkbox-spec", function () { expect(aCheckbox.checked).toBe(false); }); - it("should toggle when the PressComposer fires a pressStart + press twice", function() { + it("should toggle when the PressComposer fires a pressStart + press twice", function () { aCheckbox._pressComposer.dispatchEventNamed("pressStart"); aCheckbox._pressComposer.dispatchEventNamed("press"); expect(aCheckbox.checked).toBe(true); @@ -69,7 +69,7 @@ describe("test/base/abstract-checkbox-spec", function () { expect(aCheckbox.checked).toBe(false); }); - it("should add the corresponding class name to classList when checked", function() { + it("should add the corresponding class name to classList when checked", function () { aCheckbox.checked = true; expect(aCheckbox.classList.contains("montage-Checkbox--checked")).toBe(true); @@ -84,7 +84,7 @@ describe("test/base/abstract-checkbox-spec", function () { aCheckbox.prepareForActivationEvents(); }); - it("should not get checked when enabled is false and PressComposer fires a press", function() { + it("should not get checked when enabled is false and PressComposer fires a press", function () { aCheckbox.enabled = false; aCheckbox._pressComposer.dispatchEventNamed("pressStart"); @@ -93,8 +93,8 @@ describe("test/base/abstract-checkbox-spec", function () { expect(aCheckbox.checked).toBe(false); }); - it("should not dispatch an action event when enabled is false and PressComposer fires a press", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should not dispatch an action event when enabled is false and PressComposer fires a press", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.type).toEqual("action"); }); aCheckbox.addEventListener("action", callback, false); @@ -106,7 +106,7 @@ describe("test/base/abstract-checkbox-spec", function () { expect(callback).not.toHaveBeenCalled(); }); - it("should add the corresponding class name to classList when enabled is false", function() { + it("should add the corresponding class name to classList when enabled is false", function () { aCheckbox.enabled = false; expect(aCheckbox.classList.contains("montage--disabled")).toBe(true); @@ -121,18 +121,18 @@ describe("test/base/abstract-checkbox-spec", function () { aCheckbox.prepareForActivationEvents(); }); - it("should be true when the PressComposer fires a pressStart", function() { + it("should be true when the PressComposer fires a pressStart", function () { aCheckbox._pressComposer.dispatchEventNamed("pressStart"); expect(aCheckbox.active).toBe(true); }); - it("should be false when the PressComposer fires a pressStart + press", function() { + it("should be false when the PressComposer fires a pressStart + press", function () { aCheckbox._pressComposer.dispatchEventNamed("pressStart"); aCheckbox._pressComposer.dispatchEventNamed("press"); expect(aCheckbox.active).toBe(false); }); - it("should be false when the PressComposer fires a pressStart + press while checked", function() { + it("should be false when the PressComposer fires a pressStart + press while checked", function () { aCheckbox.checked = true; aCheckbox._pressComposer.dispatchEventNamed("pressStart"); @@ -141,13 +141,13 @@ describe("test/base/abstract-checkbox-spec", function () { expect(aCheckbox.active).toBe(false); }); - it("should be false when the PressComposer fires a pressStart + pressCancel", function() { + it("should be false when the PressComposer fires a pressStart + pressCancel", function () { aCheckbox._pressComposer.dispatchEventNamed("pressStart"); aCheckbox._pressComposer.dispatchEventNamed("pressCancel"); expect(aCheckbox.active).toBe(false); }); - it("should add the corresponding class name to classList when active", function() { + it("should add the corresponding class name to classList when active", function () { aCheckbox.active = true; expect(aCheckbox.classList.contains("montage--active")).toBe(true); @@ -182,11 +182,11 @@ describe("test/base/abstract-checkbox-spec", function () { aCheckbox = new Checkbox(); anElement = MockDOM.element(); listener = { - handleEvent: function() {} + handleEvent: function () {} }; }); - it("should listen for press only after prepareForActivationEvents", function() { + it("should listen for press only after prepareForActivationEvents", function () { var listeners, em = aCheckbox.eventManager; @@ -204,8 +204,8 @@ describe("test/base/abstract-checkbox-spec", function () { beforeEach(function () { aCheckbox.prepareForActivationEvents(); }); - it("should fire an 'action' event when the PressComposer fires a pressStart + press", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should fire an 'action' event when the PressComposer fires a pressStart + press", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.type).toEqual("action"); }); aCheckbox.addEventListener("action", callback, false); @@ -216,8 +216,8 @@ describe("test/base/abstract-checkbox-spec", function () { expect(callback).toHaveBeenCalled(); }); - it("should not fire an 'action' event when the PressComposer fires a pressStart + pressCancel", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should not fire an 'action' event when the PressComposer fires a pressStart + pressCancel", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.type).toEqual("action"); }); aCheckbox.addEventListener("action", callback, false); @@ -228,8 +228,8 @@ describe("test/base/abstract-checkbox-spec", function () { expect(callback).not.toHaveBeenCalled(); }); - it("should fire an 'action' event with the contents of the detail property", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should fire an 'action' event with the contents of the detail property", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.detail.get("foo")).toEqual("bar"); }); aCheckbox.addEventListener("action", callback, false); @@ -243,7 +243,7 @@ describe("test/base/abstract-checkbox-spec", function () { }); }); - describe("aria", function() { + describe("aria", function () { var Checkbox = Montage.create(AbstractCheckbox, {}), aCheckbox; @@ -252,20 +252,20 @@ describe("test/base/abstract-checkbox-spec", function () { aCheckbox.element = MockDOM.element(); }); - it("should have the checkbox role", function() { + it("should have the checkbox role", function () { aCheckbox.enterDocument(true); expect(aCheckbox.element.getAttribute("role")).toBe("checkbox"); }); - it("should have aria-checked set to true when it is checked", function() { + it("should have aria-checked set to true when it is checked", function () { aCheckbox.checked = true; aCheckbox.draw(); expect(aCheckbox.element.getAttribute("aria-checked")).toBe("true"); }); - it("should have aria-checked set to false when it is not checked", function() { + it("should have aria-checked set to false when it is not checked", function () { aCheckbox.checked = false; aCheckbox.draw(); diff --git a/test/base/abstract-confirm-spec.js b/test/base/abstract-confirm-spec.js index 5af2e73fba..713caf7775 100644 --- a/test/base/abstract-confirm-spec.js +++ b/test/base/abstract-confirm-spec.js @@ -49,13 +49,13 @@ describe("test/base/abstract-confirm-spec", function () { aConfirm = new Confirm(); aConfirm.element = MockDOM.element(_document); aConfirm._overlay = MockComponent.component(); - aConfirm._overlay.show = function(){}; - aConfirm._overlay.hide = function(){}; + aConfirm._overlay.show = function (){}; + aConfirm._overlay.hide = function (){}; aConfirm._okButton = MockComponent.component(); aConfirm._cancelButton = MockComponent.component(); }); - afterEach(function() { + afterEach(function () { setdownMockRootComponent(); }); @@ -74,8 +74,8 @@ describe("test/base/abstract-confirm-spec", function () { }); }); - describe("user action", function() { - it("should resolve the user action promise when the ok button is pressed", function() { + describe("user action", function () { + it("should resolve the user action promise when the ok button is pressed", function () { var event = {target: aConfirm._okButton}, promise = aConfirm.show(); @@ -83,18 +83,18 @@ describe("test/base/abstract-confirm-spec", function () { expect(Promise.isFulfilled(promise)).toBeTruthy(); }); - it("should resolve the user action promise to 'ok' when the ok button is pressed", function() { + it("should resolve the user action promise to 'ok' when the ok button is pressed", function () { var event = {target: aConfirm._okButton}, promise = aConfirm.show(); aConfirm.handleAction(event); - return promise.then(function(buttonPressed) { + return promise.then(function (buttonPressed) { expect(buttonPressed).toBe(Confirm.OKButton); }); }); - it("should resolve the user action promise when the cancel button is pressed", function() { + it("should resolve the user action promise when the cancel button is pressed", function () { var event = {target: aConfirm._cancelButton}, promise = aConfirm.show(); @@ -102,187 +102,187 @@ describe("test/base/abstract-confirm-spec", function () { expect(Promise.isFulfilled(promise)).toBeTruthy(); }); - it("should resolve the user action promise to 'cancel' when the ok button is pressed", function() { + it("should resolve the user action promise to 'cancel' when the ok button is pressed", function () { var event = {target: aConfirm._cancelButton}, promise = aConfirm.show(); aConfirm.handleAction(event); - return promise.then(function(buttonPressed) { + return promise.then(function (buttonPressed) { expect(buttonPressed).toBe(Confirm.CancelButton); }); }); }); }); - describe("static show", function() { + describe("static show", function () { var ConfirmSubtype; - beforeEach(function() { + beforeEach(function () { setupMockRootComponent(); ConfirmSubtype = AbstractConfirm.specialize({}); }); - afterEach(function() { + afterEach(function () { setdownMockRootComponent(); }); - it("should create an instance to show the alert", function() { + it("should create an instance to show the alert", function () { ConfirmSubtype.show("message"); expect(ConfirmSubtype._instance).toBeDefined(); }); - it("should configure the confirm okLabel with the ok label upon entering the document", function() { + it("should configure the confirm okLabel with the ok label upon entering the document", function () { ConfirmSubtype.show("Question", "Title", "Okay"); ConfirmSubtype._instance._overlay = MockComponent.component(); - ConfirmSubtype._instance._overlay.show = function(){}; - ConfirmSubtype._instance._overlay.hide = function(){}; + ConfirmSubtype._instance._overlay.show = function (){}; + ConfirmSubtype._instance._overlay.hide = function (){}; ConfirmSubtype._instance._okButton = MockComponent.component(); ConfirmSubtype._instance._cancelButton = MockComponent.component(); ConfirmSubtype._instance.enterDocument(true); spyOn(ConfirmSubtype._instance, "show").andCallThrough(); - waitsFor(function() { + waitsFor(function () { return ConfirmSubtype._instance.show.calls.length === 1; }); - runs(function() { + runs(function () { expect(ConfirmSubtype._instance.okLabel).toBe("Okay"); }); }); - it("should configure the confirm cancelLabel with the cancel label upon entering the document", function() { + it("should configure the confirm cancelLabel with the cancel label upon entering the document", function () { ConfirmSubtype.show("Question", "Title", "Okay", "Nay"); ConfirmSubtype._instance._overlay = MockComponent.component(); - ConfirmSubtype._instance._overlay.show = function(){}; - ConfirmSubtype._instance._overlay.hide = function(){}; + ConfirmSubtype._instance._overlay.show = function (){}; + ConfirmSubtype._instance._overlay.hide = function (){}; ConfirmSubtype._instance._okButton = MockComponent.component(); ConfirmSubtype._instance._cancelButton = MockComponent.component(); ConfirmSubtype._instance.enterDocument(true); spyOn(ConfirmSubtype._instance, "show").andCallThrough(); - waitsFor(function() { + waitsFor(function () { return ConfirmSubtype._instance.show.calls.length === 1; }); - runs(function() { + runs(function () { expect(ConfirmSubtype._instance.cancelLabel).toBe("Nay"); }); }); - it("should configure the confirm okButton with the next ok button label when the current alert is closed", function() { + it("should configure the confirm okButton with the next ok button label when the current alert is closed", function () { ConfirmSubtype.show("message", "a title", "Okay"); ConfirmSubtype.show("another message", "another title", "Yap"); ConfirmSubtype._instance._overlay = MockComponent.component(); - ConfirmSubtype._instance._overlay.show = function(){}; - ConfirmSubtype._instance._overlay.hide = function(){}; + ConfirmSubtype._instance._overlay.show = function (){}; + ConfirmSubtype._instance._overlay.hide = function (){}; ConfirmSubtype._instance._okButton = MockComponent.component(); ConfirmSubtype._instance._cancelButton = MockComponent.component(); ConfirmSubtype._instance.enterDocument(true); spyOn(ConfirmSubtype._instance, "show").andCallThrough(); - waitsFor(function() { + waitsFor(function () { return ConfirmSubtype._instance.show.calls.length === 1; }); - runs(function() { + runs(function () { ConfirmSubtype._instance.handleAction({target: ConfirmSubtype._instance._okButton}); - waitsFor(function() { + waitsFor(function () { return ConfirmSubtype._instance.show.calls.length === 2; }); - runs(function() { + runs(function () { expect(ConfirmSubtype._instance.okLabel).toBe("Yap"); }); }); }); - it("should configure the confirm cancelButton with the next cancel button label when the current alert is closed", function() { + it("should configure the confirm cancelButton with the next cancel button label when the current alert is closed", function () { ConfirmSubtype.show("message", "a title", "Okay", "Nay"); ConfirmSubtype.show("another message", "another title", "Yap", "Nope"); ConfirmSubtype._instance._overlay = MockComponent.component(); - ConfirmSubtype._instance._overlay.show = function(){}; - ConfirmSubtype._instance._overlay.hide = function(){}; + ConfirmSubtype._instance._overlay.show = function (){}; + ConfirmSubtype._instance._overlay.hide = function (){}; ConfirmSubtype._instance._okButton = MockComponent.component(); ConfirmSubtype._instance._cancelButton = MockComponent.component(); ConfirmSubtype._instance.enterDocument(true); spyOn(ConfirmSubtype._instance, "show").andCallThrough(); - waitsFor(function() { + waitsFor(function () { return ConfirmSubtype._instance.show.calls.length === 1; }); - runs(function() { + runs(function () { ConfirmSubtype._instance.handleAction({target: ConfirmSubtype._instance._okButton}); - waitsFor(function() { + waitsFor(function () { return ConfirmSubtype._instance.show.calls.length === 2; }); - runs(function() { + runs(function () { expect(ConfirmSubtype._instance.cancelLabel).toBe("Nope"); }); }); }); - it("should configure the confirm okButton with the default label when the current alert is closed", function() { + it("should configure the confirm okButton with the default label when the current alert is closed", function () { ConfirmSubtype.show("message", "a title", "Okay", "Nay"); ConfirmSubtype.show("another message", "another title"); ConfirmSubtype._instance._overlay = MockComponent.component(); - ConfirmSubtype._instance._overlay.show = function(){}; - ConfirmSubtype._instance._overlay.hide = function(){}; + ConfirmSubtype._instance._overlay.show = function (){}; + ConfirmSubtype._instance._overlay.hide = function (){}; ConfirmSubtype._instance._okButton = MockComponent.component(); ConfirmSubtype._instance._cancelButton = MockComponent.component(); ConfirmSubtype._instance.enterDocument(true); spyOn(ConfirmSubtype._instance, "show").andCallThrough(); - waitsFor(function() { + waitsFor(function () { return ConfirmSubtype._instance.show.calls.length === 1; }); - runs(function() { + runs(function () { ConfirmSubtype._instance.handleAction({target: ConfirmSubtype._instance._okButton}); - waitsFor(function() { + waitsFor(function () { return ConfirmSubtype._instance.show.calls.length === 2; }); - runs(function() { + runs(function () { expect(ConfirmSubtype._instance.okButton).toBe(ConfirmSubtype.prototype.okButton); }); }); }); - it("should configure the confirm cancelButton with the default label when the current alert is closed", function() { + it("should configure the confirm cancelButton with the default label when the current alert is closed", function () { ConfirmSubtype.show("message", "a title", "Okay", "Nay"); ConfirmSubtype.show("another message", "another title"); ConfirmSubtype._instance._overlay = MockComponent.component(); - ConfirmSubtype._instance._overlay.show = function(){}; - ConfirmSubtype._instance._overlay.hide = function(){}; + ConfirmSubtype._instance._overlay.show = function (){}; + ConfirmSubtype._instance._overlay.hide = function (){}; ConfirmSubtype._instance._okButton = MockComponent.component(); ConfirmSubtype._instance._cancelButton = MockComponent.component(); ConfirmSubtype._instance.enterDocument(true); spyOn(ConfirmSubtype._instance, "show").andCallThrough(); - waitsFor(function() { + waitsFor(function () { return ConfirmSubtype._instance.show.calls.length === 1; }); - runs(function() { + runs(function () { ConfirmSubtype._instance.handleAction({target: ConfirmSubtype._instance._okButton}); - waitsFor(function() { + waitsFor(function () { return ConfirmSubtype._instance.show.calls.length === 2; }); - runs(function() { + runs(function () { expect(ConfirmSubtype._instance.cancelLabel).toBe(ConfirmSubtype.prototype.cancelLabel); }); }); diff --git a/test/base/abstract-image-spec.js b/test/base/abstract-image-spec.js index 3941fb0837..5db9ba2c58 100644 --- a/test/base/abstract-image-spec.js +++ b/test/base/abstract-image-spec.js @@ -40,7 +40,7 @@ describe("test/base/abstract-image-spec", function () { anImage.element = MockDOM.element(); }); - it("should start loading the new image", function() { + it("should start loading the new image", function () { var url = imageURL + "?donotchache=" + Date.now(); anImage.src = url; expect(anImage._isLoadingImage).toBeTruthy(); @@ -119,13 +119,13 @@ describe("test/base/abstract-image-spec", function () { expect(anImage.element.hasAttribute("crossorigin")).toBe(false); }); - it("should draw the rebased relative url if the _ownerDocumentPart is set after src", function() { + it("should draw the rebased relative url if the _ownerDocumentPart is set after src", function () { var src = "logo.png"; anImage.src = src; anImage._ownerDocumentPart = { template: { - getBaseUrl: function() { + getBaseUrl: function () { return "http://montagestudio.com/assets/images/montagejs/"; } } @@ -136,12 +136,12 @@ describe("test/base/abstract-image-spec", function () { expect(anImage.element.src).toBe(imageURL); }); - it("should draw the rebased relative url if the src is set after _ownerDocumentPart", function() { + it("should draw the rebased relative url if the src is set after _ownerDocumentPart", function () { var src = "logo.png"; anImage._ownerDocumentPart = { template: { - getBaseUrl: function() { + getBaseUrl: function () { return "http://montagestudio.com/assets/images/montagejs/"; } } @@ -155,7 +155,7 @@ describe("test/base/abstract-image-spec", function () { }); - describe("rebased src", function() { + describe("rebased src", function () { var Image = AbstractImage.specialize( {}), anImage; @@ -163,7 +163,7 @@ describe("test/base/abstract-image-spec", function () { anImage = new Image(); }); - it("should not rebase http:// urls", function() { + it("should not rebase http:// urls", function () { var src = imageURL, rebasedSrc; @@ -173,7 +173,7 @@ describe("test/base/abstract-image-spec", function () { expect(rebasedSrc).toBe(src); }); - it("should not rebase https:// urls", function() { + it("should not rebase https:// urls", function () { var src = "https://montagestudio.com/assets/images/montagejs/logo.png", rebasedSrc; @@ -186,7 +186,7 @@ describe("test/base/abstract-image-spec", function () { expect(rebasedSrc).toBe(src); }); - it("should not rebase / urls", function() { + it("should not rebase / urls", function () { var src = "/montagestudio.com/assets/images/montagejs/logo.png", rebasedSrc; @@ -196,7 +196,7 @@ describe("test/base/abstract-image-spec", function () { expect(rebasedSrc).toBe(src); }); - it("should not rebase // urls", function() { + it("should not rebase // urls", function () { var src = "//montagestudio.com/assets/images/montagejs/logo.png", rebasedSrc; @@ -206,7 +206,7 @@ describe("test/base/abstract-image-spec", function () { expect(rebasedSrc).toBe(src); }); - it("should not rebase data: urls", function() { + it("should not rebase data: urls", function () { var src = src1, rebasedSrc; @@ -216,7 +216,7 @@ describe("test/base/abstract-image-spec", function () { expect(rebasedSrc).toBe(src); }); - it("should not rebase protocol: urls", function() { + it("should not rebase protocol: urls", function () { var src = "protocol://image.jpg", rebasedSrc; @@ -229,7 +229,7 @@ describe("test/base/abstract-image-spec", function () { expect(rebasedSrc).toBe(src); }); - it("should not rebase empty urls", function() { + it("should not rebase empty urls", function () { var src = "", rebasedSrc; @@ -239,7 +239,7 @@ describe("test/base/abstract-image-spec", function () { expect(rebasedSrc).toBe(null); }); - it("should not rebase null urls", function() { + it("should not rebase null urls", function () { var src = null, rebasedSrc; @@ -249,7 +249,7 @@ describe("test/base/abstract-image-spec", function () { expect(rebasedSrc).toBe(null); }); - it("should not rebase relative urls when owner document is not available", function() { + it("should not rebase relative urls when owner document is not available", function () { var src = "logo.png", rebasedSrc; @@ -260,13 +260,13 @@ describe("test/base/abstract-image-spec", function () { expect(rebasedSrc).toBe(null); }); - it("should not rebase relative urls when base url is not available", function() { + it("should not rebase relative urls when base url is not available", function () { var src = "logo.png", rebasedSrc; anImage._ownerDocumentPart = { template: { - getBaseUrl: function() { + getBaseUrl: function () { return null; } } @@ -277,13 +277,13 @@ describe("test/base/abstract-image-spec", function () { expect(rebasedSrc).toBe(null); }); - it("should rebase relative urls when base url is not available", function() { + it("should rebase relative urls when base url is not available", function () { var src = "logo.png", rebasedSrc; anImage._ownerDocumentPart = { template: { - getBaseUrl: function() { + getBaseUrl: function () { return "http://montagestudio.com/assets/images/montagejs/"; } } @@ -294,13 +294,13 @@ describe("test/base/abstract-image-spec", function () { expect(rebasedSrc).toBe(imageURL); }); - it("should rebase relative urls as soon as owner template is available", function() { + it("should rebase relative urls as soon as owner template is available", function () { var src = "logo.png"; anImage.src = src; anImage._ownerDocumentPart = { template: { - getBaseUrl: function() { + getBaseUrl: function () { return "http://montagestudio.com/assets/images/montagejs/"; } } @@ -308,13 +308,13 @@ describe("test/base/abstract-image-spec", function () { expect(anImage._image.src).toBe(imageURL); }); - it("should not change the src to the rebased src", function() { + it("should not change the src to the rebased src", function () { var src = "logo.png"; anImage.src = src; anImage._ownerDocumentPart = { template: { - getBaseUrl: function() { + getBaseUrl: function () { return "http://montagestudio.com/assets/images/montagejs/"; } } @@ -325,19 +325,19 @@ describe("test/base/abstract-image-spec", function () { }); - describe("cached image", function() { + describe("cached image", function () { var Image = AbstractImage.specialize({}), cachedImage = new Image(); - it("should preload the image", function() { + it("should preload the image", function () { cachedImage.src = imageURL; - waitsFor(function() { + waitsFor(function () { return !cachedImage._isLoadingImage; }, 4000); }); - it("should display the cached image", function() { + it("should display the cached image", function () { var anImage = new Image(); anImage.src = imageURL; expect(anImage._isLoadingImage).toBe(false); diff --git a/test/base/abstract-link-spec.js b/test/base/abstract-link-spec.js index 5bda08f924..8d950541ff 100644 --- a/test/base/abstract-link-spec.js +++ b/test/base/abstract-link-spec.js @@ -37,8 +37,8 @@ describe("test/base/abstract-link-spec", function () { aLink.prepareForActivationEvents(); }); - it("should not dispatch an action event when enabled is false and PressComposer fires a press", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should not dispatch an action event when enabled is false and PressComposer fires a press", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.type).toEqual("action"); }); aLink.addEventListener("action", callback, false); @@ -50,7 +50,7 @@ describe("test/base/abstract-link-spec", function () { expect(callback).not.toHaveBeenCalled(); }); - it("should add the corresponding class name to classList when enabled is false", function() { + it("should add the corresponding class name to classList when enabled is false", function () { aLink.enabled = false; expect(aLink.classList.contains("montage--disabled")).toBe(true); @@ -64,39 +64,39 @@ describe("test/base/abstract-link-spec", function () { aLink.prepareForActivationEvents(); }); - it("should be true when the PressComposer fires a pressStart", function() { + it("should be true when the PressComposer fires a pressStart", function () { aLink._pressComposer.dispatchEventNamed("pressStart"); expect(aLink.active).toBe(true); }); - it("should be false when the PressComposer fires a pressStart + press", function() { + it("should be false when the PressComposer fires a pressStart + press", function () { aLink._pressComposer.dispatchEventNamed("pressStart"); aLink._pressComposer.dispatchEventNamed("press"); expect(aLink.active).toBe(false); }); - it("should be false when the PressComposer fires a pressStart + press while checked", function() { + it("should be false when the PressComposer fires a pressStart + press while checked", function () { aLink._pressComposer.dispatchEventNamed("pressStart"); aLink._pressComposer.dispatchEventNamed("press"); expect(aLink.active).toBe(false); }); - it("should be false when the PressComposer fires a pressStart + pressCancel", function() { + it("should be false when the PressComposer fires a pressStart + pressCancel", function () { aLink._pressComposer.dispatchEventNamed("pressStart"); aLink._pressComposer.dispatchEventNamed("pressCancel"); expect(aLink.active).toBe(false); }); - it("should add the corresponding class name to classList when active", function() { + it("should add the corresponding class name to classList when active", function () { aLink.active = true; expect(aLink.classList.contains("montage--active")).toBe(true); }); }); - describe("label", function() { - it("should read the text value of the element if label wasn't provided", function() { + describe("label", function () { + it("should read the text value of the element if label wasn't provided", function () { var label = "MontageJS"; aLink.element.textContent = label; @@ -104,7 +104,7 @@ describe("test/base/abstract-link-spec", function () { expect(aLink.label).toBe(label) }); - it("should not read the text value of the element when label is set", function() { + it("should not read the text value of the element when label is set", function () { var label = "MontageJS"; aLink.element.textContent = "Text Content"; @@ -134,22 +134,22 @@ describe("test/base/abstract-link-spec", function () { expect(aLink.needsDraw).toBeTruthy(); }); - it("should be requested when url is changed", function() { + it("should be requested when url is changed", function () { aLink.url = "http://montagejs.org/"; expect(aLink.needsDraw).toBeTruthy(); }); - it("should be requested when label is changed", function() { + it("should be requested when label is changed", function () { aLink.label = "MontageJS"; expect(aLink.needsDraw).toBeTruthy(); }); - it("should be requested when opensNewWindow is changed", function() { + it("should be requested when opensNewWindow is changed", function () { aLink.opensNewWindow = true; expect(aLink.needsDraw).toBeTruthy(); }); - it("should be requested when textAlternative is changed", function() { + it("should be requested when textAlternative is changed", function () { aLink.textAlternative = true; expect(aLink.needsDraw).toBeTruthy(); }); @@ -163,11 +163,11 @@ describe("test/base/abstract-link-spec", function () { aLink = new Link(); anElement = MockDOM.element(); listener = { - handleEvent: function() {} + handleEvent: function () {} }; }); - it("should listen for press only after prepareForActivationEvents", function() { + it("should listen for press only after prepareForActivationEvents", function () { var listeners, em = aLink.eventManager; @@ -185,8 +185,8 @@ describe("test/base/abstract-link-spec", function () { beforeEach(function () { aLink.prepareForActivationEvents(); }); - it("should fire an 'action' event when the PressComposer fires a pressStart + press", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should fire an 'action' event when the PressComposer fires a pressStart + press", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.type).toEqual("action"); }); aLink.addEventListener("action", callback, false); @@ -197,8 +197,8 @@ describe("test/base/abstract-link-spec", function () { expect(callback).toHaveBeenCalled(); }); - it("should not fire an 'action' event when the PressComposer fires a pressStart + pressCancel", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should not fire an 'action' event when the PressComposer fires a pressStart + pressCancel", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.type).toEqual("action"); }); aLink.addEventListener("action", callback, false); @@ -209,8 +209,8 @@ describe("test/base/abstract-link-spec", function () { expect(callback).not.toHaveBeenCalled(); }); - it("should fire an 'action' event with the contents of the detail property", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should fire an 'action' event with the contents of the detail property", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.detail.get("foo")).toEqual("bar"); }); aLink.addEventListener("action", callback, false); diff --git a/test/base/abstract-number-field-spec.js b/test/base/abstract-number-field-spec.js index e74bf1dee2..17cf0686d0 100644 --- a/test/base/abstract-number-field-spec.js +++ b/test/base/abstract-number-field-spec.js @@ -38,148 +38,148 @@ describe("test/base/abstract-number-field-spec", function () { aNumberField._numberFieldPlusComponent = MockComponent.component(); }); - describe("value", function() { - it("should have correct default", function() { + describe("value", function () { + it("should have correct default", function () { expect(aNumberField.value).toEqual(0); }); - it("can be set", function() { + it("can be set", function () { aNumberField.value = 5; expect(aNumberField.value).toEqual(5); }); - it("can be negative", function() { + it("can be negative", function () { aNumberField.value = -2; expect(aNumberField.value).toEqual(-2); }); - it("can be set with a string", function() { + it("can be set with a string", function () { aNumberField.value = "5"; expect(aNumberField.value).toEqual(5); }); - it("can't be set with letters", function() { + it("can't be set with letters", function () { var previousValue = aNumberField.value; aNumberField.value = "hello"; expect(aNumberField.value).not.toEqual("hello"); expect(aNumberField.value).toEqual(previousValue); }); - it("can be set to null", function() { + it("can be set to null", function () { aNumberField.value = null; expect(aNumberField.value).toEqual(""); }); - it("can be set to undefined", function() { + it("can be set to undefined", function () { aNumberField.value = void 0; expect(aNumberField.value).toEqual(""); }); - it("can be set to an object without valueOf", function() { + it("can be set to an object without valueOf", function () { aNumberField.value = Object.create(null); expect(aNumberField.value).toEqual(""); }); - describe("behavior", function() { - it("value shouldn't be affected by step", function() { + describe("behavior", function () { + it("value shouldn't be affected by step", function () { aNumberField.step = 2; aNumberField.value = 5.5; expect(aNumberField.value).toEqual(5.5); }); - it("value should take min into account", function() { + it("value should take min into account", function () { aNumberField.min = 10; aNumberField.value = 0; expect(aNumberField.value).toEqual(10); }); - it("value should take max into account", function() { + it("value should take max into account", function () { aNumberField.max = 20; aNumberField.value = 25; expect(aNumberField.value).toEqual(20); }); }); }); - describe("step", function() { - it("should have correct default", function() { + describe("step", function () { + it("should have correct default", function () { expect(aNumberField.step).toEqual(1); }); - it("can be set", function() { + it("can be set", function () { aNumberField.step = 2; expect(aNumberField.step).toEqual(2); }); - it("cannot be negative", function() { + it("cannot be negative", function () { // Inspiration from: // http://dev.w3.org/html5/spec/common-input-element-attributes.html#attr-input-step var previousValue = aNumberField.step; aNumberField.step = -2; expect(aNumberField.step).toEqual(previousValue); }); - it("can be set with a string", function() { + it("can be set with a string", function () { aNumberField.step = "2"; expect(aNumberField.step).toEqual(2); }); - it("can't be set with letters", function() { + it("can't be set with letters", function () { var previousValue = aNumberField.step; aNumberField.step = "hello"; expect(aNumberField.step).not.toEqual("hello"); expect(aNumberField.step).toEqual(previousValue); }); }); - describe("min", function() { - it("should have correct default", function() { + describe("min", function () { + it("should have correct default", function () { expect(aNumberField.min).toEqual("any"); }); - it("can be set", function() { + it("can be set", function () { aNumberField.min = 2; expect(aNumberField.min).toEqual(2); }); - it("can be negative", function() { + it("can be negative", function () { aNumberField.min = -2; expect(aNumberField.min).toEqual(-2); }); - it("can be set with a string", function() { + it("can be set with a string", function () { aNumberField.min = "2"; expect(aNumberField.min).toEqual(2); }); - it("can't be set with letters", function() { + it("can't be set with letters", function () { var previousValue = aNumberField.min; aNumberField.min = "hello"; expect(aNumberField.min).not.toEqual("hello"); expect(aNumberField.min).toEqual(previousValue); }); - describe("behavior", function() { - it("value should be unchanged if value already a greater than min", function() { + describe("behavior", function () { + it("value should be unchanged if value already a greater than min", function () { aNumberField.value = 6; aNumberField.min = 2; expect(aNumberField.value).toEqual(6); }); - it("value should be changed if value isn't greater than min", function() { + it("value should be changed if value isn't greater than min", function () { aNumberField.value = 1; aNumberField.min = 2; expect(aNumberField.value).toEqual(2); }); }); }); - describe("max", function() { - it("should have correct default", function() { + describe("max", function () { + it("should have correct default", function () { expect(aNumberField.max).toEqual("any"); }); - it("can be set", function() { + it("can be set", function () { aNumberField.max = 2; expect(aNumberField.max).toEqual(2); }); - it("can be negative", function() { + it("can be negative", function () { aNumberField.max = -2; expect(aNumberField.max).toEqual(-2); }); - it("can be set with a string", function() { + it("can be set with a string", function () { aNumberField.max = "2"; expect(aNumberField.max).toEqual(2); }); - it("can't be set with letters", function() { + it("can't be set with letters", function () { var previousValue = aNumberField.max; aNumberField.max = "hello"; expect(aNumberField.max).not.toEqual("hello"); expect(aNumberField.max).toEqual(previousValue); }); - describe("behavior", function() { - it("value should be unchanged if value is already less than max", function() { + describe("behavior", function () { + it("value should be unchanged if value is already less than max", function () { aNumberField.value = 2; aNumberField.max = 6; expect(aNumberField.value).toEqual(2); }); - it("value should be changed if value isn't less than max", function() { + it("value should be changed if value isn't less than max", function () { aNumberField.value = 10; aNumberField.max = 9; expect(aNumberField.value).toEqual(9); @@ -284,7 +284,7 @@ describe("test/base/abstract-number-field-spec", function () { aNumberField.handlePlusAction(); expect(aNumberField.value).toEqual(11); }); - it("should increment by a unit of floating point step", function() { + it("should increment by a unit of floating point step", function () { aNumberField.value = 0.3; aNumberField.min = 0; aNumberField.max = 1; @@ -293,7 +293,7 @@ describe("test/base/abstract-number-field-spec", function () { expect(aNumberField.value).toEqual(0.4); }); - it("should snap to greater floating point multiple", function() { + it("should snap to greater floating point multiple", function () { aNumberField.value = 0.2; aNumberField.min = 0; aNumberField.max = 1; @@ -333,7 +333,7 @@ describe("test/base/abstract-number-field-spec", function () { aNumberField.handleMinusAction(); expect(aNumberField.value).toEqual(1); }); - it("should decrement by a unit of floating point step", function() { + it("should decrement by a unit of floating point step", function () { aNumberField.value = 0.2; aNumberField.min = 0; aNumberField.max = 1; @@ -342,7 +342,7 @@ describe("test/base/abstract-number-field-spec", function () { expect(aNumberField.value).toEqual(0.1); }); - it("should snap to greater floating point multiple", function() { + it("should snap to greater floating point multiple", function () { aNumberField.value = 0.3; aNumberField.min = 0; aNumberField.max = 1; @@ -367,24 +367,24 @@ describe("test/base/abstract-number-field-spec", function () { }); describe("'action' event ", function () { - it("should listen for 'action' event on the textfield after enterDocument", function() { + it("should listen for 'action' event on the textfield after enterDocument", function () { expect(aNumberField._numberFieldTextFieldComponent.hasEventListener("action", aNumberField)).toBeFalsy(); aNumberField.enterDocument(true); expect(aNumberField._numberFieldTextFieldComponent.hasEventListener("action", aNumberField)).toBeTruthy(); }); - it("should listen for 'action' event on the textfield after enterDocument", function() { + it("should listen for 'action' event on the textfield after enterDocument", function () { expect(aNumberField._numberFieldMinusComponent.hasEventListener("action", aNumberField)).toBeFalsy(); aNumberField.enterDocument(true); expect(aNumberField._numberFieldMinusComponent.hasEventListener("action", aNumberField)).toBeTruthy(); }); - it("should listen for 'action' event on the textfield after enterDocument", function() { + it("should listen for 'action' event on the textfield after enterDocument", function () { expect(aNumberField._numberFieldPlusComponent.hasEventListener("action", aNumberField)).toBeFalsy(); aNumberField.enterDocument(true); expect(aNumberField._numberFieldPlusComponent.hasEventListener("action", aNumberField)).toBeTruthy(); }); - it("should fire an 'action' event when the textfield fires an action", function() { - var callback = jasmine.createSpy("actionCallback").andCallFake(function(event) { + it("should fire an 'action' event when the textfield fires an action", function () { + var callback = jasmine.createSpy("actionCallback").andCallFake(function (event) { expect(event.type).toEqual("action"); }), actionEvent = MockEvent.event("action", true, true, null); @@ -396,8 +396,8 @@ describe("test/base/abstract-number-field-spec", function () { expect(callback).toHaveBeenCalled(); }); - it("should fire an 'action' event when the plus button fires an action", function() { - var callback = jasmine.createSpy("actionCallback").andCallFake(function(event) { + it("should fire an 'action' event when the plus button fires an action", function () { + var callback = jasmine.createSpy("actionCallback").andCallFake(function (event) { expect(event.type).toEqual("action"); }), actionEvent = MockEvent.event("action", true, true, null); @@ -409,8 +409,8 @@ describe("test/base/abstract-number-field-spec", function () { expect(callback).toHaveBeenCalled(); }); - it("should fire an 'action' event when the minus button fires an action", function() { - var callback = jasmine.createSpy("actionCallback").andCallFake(function(event) { + it("should fire an 'action' event when the minus button fires an action", function () { + var callback = jasmine.createSpy("actionCallback").andCallFake(function (event) { expect(event.type).toEqual("action"); }), actionEvent = MockEvent.event("action", true, true, null); @@ -421,21 +421,21 @@ describe("test/base/abstract-number-field-spec", function () { expect(callback).toHaveBeenCalled(); }); - it("should stop the propagation of 'action' events from the textfield", function() { + it("should stop the propagation of 'action' events from the textfield", function () { var actionEvent = MockEvent.event("action", true, true, null); aNumberField.enterDocument(true); aNumberField._numberFieldTextFieldComponent.dispatchEvent(actionEvent); expect(actionEvent.propagationStopped).toBeTruthy(); }); - it("should stop the propagation of 'action' events from the plus button", function() { + it("should stop the propagation of 'action' events from the plus button", function () { var actionEvent = MockEvent.event("action", true, true, null); aNumberField.enterDocument(true); aNumberField._numberFieldPlusComponent.dispatchEvent(actionEvent); expect(actionEvent.propagationStopped).toBeTruthy(); }); - it("should stop the propagation of 'action' events from the minus button", function() { + it("should stop the propagation of 'action' events from the minus button", function () { var actionEvent = MockEvent.event("action", true, true, null); aNumberField.enterDocument(true); aNumberField._numberFieldMinusComponent.dispatchEvent(actionEvent); diff --git a/test/base/abstract-radio-button-spec.js b/test/base/abstract-radio-button-spec.js index 0a6e5f9e3b..f5fb159f1b 100644 --- a/test/base/abstract-radio-button-spec.js +++ b/test/base/abstract-radio-button-spec.js @@ -40,21 +40,21 @@ describe("test/base/abstract-radio-button-spec", function () { aRadioButton.prepareForActivationEvents(); }); - it("should be true when the PressComposer fires a pressStart + press", function() { + it("should be true when the PressComposer fires a pressStart + press", function () { aRadioButton._pressComposer.dispatchEventNamed("pressStart"); aRadioButton._pressComposer.dispatchEventNamed("press"); expect(aRadioButton.checked).toBe(true); }); - it("should be false when the PressComposer fires a pressStart + pressCancel", function() { + it("should be false when the PressComposer fires a pressStart + pressCancel", function () { aRadioButton._pressComposer.dispatchEventNamed("pressStart"); aRadioButton._pressComposer.dispatchEventNamed("pressCancel"); expect(aRadioButton.checked).toBe(false); }); - it("should add the corresponding class name to classList when checked", function() { + it("should add the corresponding class name to classList when checked", function () { aRadioButton.checked = true; expect(aRadioButton.classList.contains("montage-RadioButton--checked")).toBe(true); @@ -69,7 +69,7 @@ describe("test/base/abstract-radio-button-spec", function () { aRadioButton.prepareForActivationEvents(); }); - it("should not get checked when enabled is false and PressComposer fires a press", function() { + it("should not get checked when enabled is false and PressComposer fires a press", function () { aRadioButton.enabled = false; aRadioButton._pressComposer.dispatchEventNamed("pressStart"); @@ -78,8 +78,8 @@ describe("test/base/abstract-radio-button-spec", function () { expect(aRadioButton.checked).toBe(false); }); - it("should not dispatch an action event when enabled is false and PressComposer fires a press", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should not dispatch an action event when enabled is false and PressComposer fires a press", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.type).toEqual("action"); }); aRadioButton.addEventListener("action", callback, false); @@ -91,7 +91,7 @@ describe("test/base/abstract-radio-button-spec", function () { expect(callback).not.toHaveBeenCalled(); }); - it("should add the corresponding class name to classList when enabled is false", function() { + it("should add the corresponding class name to classList when enabled is false", function () { aRadioButton.enabled = false; expect(aRadioButton.classList.contains("montage--disabled")).toBe(true); @@ -106,18 +106,18 @@ describe("test/base/abstract-radio-button-spec", function () { aRadioButton.prepareForActivationEvents(); }); - it("should be true when the PressComposer fires a pressStart", function() { + it("should be true when the PressComposer fires a pressStart", function () { aRadioButton._pressComposer.dispatchEventNamed("pressStart"); expect(aRadioButton.active).toBe(true); }); - it("should be false when the PressComposer fires a pressStart + press", function() { + it("should be false when the PressComposer fires a pressStart + press", function () { aRadioButton._pressComposer.dispatchEventNamed("pressStart"); aRadioButton._pressComposer.dispatchEventNamed("press"); expect(aRadioButton.active).toBe(false); }); - it("should be false when the PressComposer fires a pressStart + press while checked", function() { + it("should be false when the PressComposer fires a pressStart + press while checked", function () { aRadioButton.checked = true; aRadioButton._pressComposer.dispatchEventNamed("pressStart"); @@ -126,13 +126,13 @@ describe("test/base/abstract-radio-button-spec", function () { expect(aRadioButton.active).toBe(false); }); - it("should be false when the PressComposer fires a pressStart + pressCancel", function() { + it("should be false when the PressComposer fires a pressStart + pressCancel", function () { aRadioButton._pressComposer.dispatchEventNamed("pressStart"); aRadioButton._pressComposer.dispatchEventNamed("pressCancel"); expect(aRadioButton.active).toBe(false); }); - it("should add the corresponding class name to classList when active", function() { + it("should add the corresponding class name to classList when active", function () { aRadioButton.active = true; expect(aRadioButton.classList.contains("montage--active")).toBe(true); @@ -167,10 +167,10 @@ describe("test/base/abstract-radio-button-spec", function () { aRadioButton = new InputRadio(); anElement = MockDOM.element(); listener = { - handleEvent: function() {} + handleEvent: function () {} }; }); - it("should listen for press only after prepareForActivationEvents", function() { + it("should listen for press only after prepareForActivationEvents", function () { var listeners, em = aRadioButton.eventManager; @@ -187,8 +187,8 @@ describe("test/base/abstract-radio-button-spec", function () { beforeEach(function () { aRadioButton.prepareForActivationEvents(); }); - it("should fire an 'action' event when the PressComposer fires a pressStart + press", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should fire an 'action' event when the PressComposer fires a pressStart + press", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.type).toEqual("action"); }); aRadioButton.addEventListener("action", callback, false); @@ -199,8 +199,8 @@ describe("test/base/abstract-radio-button-spec", function () { expect(callback).toHaveBeenCalled(); }); - it("should not fire an 'action' event when the PressComposer fires a pressStart + pressCancel", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should not fire an 'action' event when the PressComposer fires a pressStart + pressCancel", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.type).toEqual("action"); }); aRadioButton.addEventListener("action", callback, false); @@ -211,8 +211,8 @@ describe("test/base/abstract-radio-button-spec", function () { expect(callback).not.toHaveBeenCalled(); }); - it("should not fire an 'action' event when the PressComposer fires a pressStart + press and already checked", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should not fire an 'action' event when the PressComposer fires a pressStart + press and already checked", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.type).toEqual("action"); }); aRadioButton.addEventListener("action", callback, false); @@ -224,8 +224,8 @@ describe("test/base/abstract-radio-button-spec", function () { expect(callback).not.toHaveBeenCalled(); }); - it("should fire an 'action' event with the contents of the detail property", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should fire an 'action' event with the contents of the detail property", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.detail.get("foo")).toEqual("bar"); }); aRadioButton.addEventListener("action", callback, false); @@ -239,7 +239,7 @@ describe("test/base/abstract-radio-button-spec", function () { }); }); - describe("aria", function() { + describe("aria", function () { var RadioButton = Montage.create(AbstractRadioButton, {}), aRadioButton; @@ -248,20 +248,20 @@ describe("test/base/abstract-radio-button-spec", function () { aRadioButton.element = MockDOM.element(); }); - it("should have the checkbox role", function() { + it("should have the checkbox role", function () { aRadioButton.enterDocument(true); expect(aRadioButton.element.getAttribute("role")).toBe("radio"); }); - it("should have aria-checked set to true when it is checked", function() { + it("should have aria-checked set to true when it is checked", function () { aRadioButton.checked = true; aRadioButton.draw(); expect(aRadioButton.element.getAttribute("aria-checked")).toBe("true"); }); - it("should have aria-checked set to false when it is not checked", function() { + it("should have aria-checked set to false when it is not checked", function () { aRadioButton.checked = false; aRadioButton.draw(); diff --git a/test/base/abstract-select-spec.js b/test/base/abstract-select-spec.js index c346f9adf2..f3debaf100 100644 --- a/test/base/abstract-select-spec.js +++ b/test/base/abstract-select-spec.js @@ -50,7 +50,7 @@ describe("test/base/abstract-select-spec", function () { aSelect.prepareForActivationEvents(); }); - it("should add the corresponding class name to classList when enabled is false", function() { + it("should add the corresponding class name to classList when enabled is false", function () { aSelect.enabled = false; expect(aSelect.classList.contains("montage--disabled")).toBe(true); @@ -58,7 +58,7 @@ describe("test/base/abstract-select-spec", function () { }); describe("content", function () { - it("should setup the content controller with the content", function() { + it("should setup the content controller with the content", function () { var content = []; aSelect.content = content; @@ -66,13 +66,13 @@ describe("test/base/abstract-select-spec", function () { expect(aSelect.contentController.content).toBe(content); }); - it("should consider the content dirty when it has a new content", function() { + it("should consider the content dirty when it has a new content", function () { aSelect.content = []; expect(aSelect._contentIsDirty).toBeTruthy(); }); - it("should consider the content dirty when it is modified", function() { + it("should consider the content dirty when it is modified", function () { aSelect.content = []; aSelect._contentIsDirty = false; @@ -82,8 +82,8 @@ describe("test/base/abstract-select-spec", function () { }); }); - describe("contentController", function() { - it("should setup content with the contentController's content", function() { + describe("contentController", function () { + it("should setup content with the contentController's content", function () { var contentController = new RangeController(); contentController.content = content; @@ -93,37 +93,37 @@ describe("test/base/abstract-select-spec", function () { }); }); - describe("value", function() { + describe("value", function () { beforeEach(function () { aSelect = new Select(); aSelect.content = content.slice(0); }); - it("should have a default value from the content", function() { + it("should have a default value from the content", function () { expect(aSelect.contentController.content).toContain(aSelect.value); }); - it("should change the selection of the content controller", function() { + it("should change the selection of the content controller", function () { aSelect.value = content[1]; expect(aSelect.contentController.selection.length).toBe(1); expect(aSelect.contentController.selection[0]).toBe(content[1]); }); - it("should change when content controller's selection change", function() { + it("should change when content controller's selection change", function () { aSelect.contentController.selection = [content[1]]; expect(aSelect.value).toBe(content[1]); }); - it("should change when content controller's selection is modified", function() { + it("should change when content controller's selection is modified", function () { aSelect.contentController.selection = [content[0]]; aSelect.contentController.selection.splice(0, 1, content[1]); expect(aSelect.value).toBe(content[1]); }); - it("should change when content controller is modified", function() { + it("should change when content controller is modified", function () { aSelect.contentController.selection = [content[0]]; var newContentController = new RangeController(); @@ -134,17 +134,17 @@ describe("test/base/abstract-select-spec", function () { expect(aSelect.value).toBe(content[1]); }); - it("should change to another value when content controller's selection is removed from the content", function() { + it("should change to another value when content controller's selection is removed from the content", function () { aSelect.contentController.selection = [content[0]]; aSelect.contentController.content.delete(content[0]); expect(aSelect.contentController.content).toContain(aSelect.value); }); - it("should dispatch value changes when values' first value change", function() { + it("should dispatch value changes when values' first value change", function () { var spy = jasmine.createSpy(); - aSelect.addOwnPropertyChangeListener("value", function() { + aSelect.addOwnPropertyChangeListener("value", function () { spy(); }); @@ -153,33 +153,33 @@ describe("test/base/abstract-select-spec", function () { }); }); - describe("value with multiSelect", function() { + describe("value with multiSelect", function () { beforeEach(function () { aSelect = new Select(); aSelect.content = content; aSelect.multiSelect = true; }); - it("should have first of the values", function() { + it("should have first of the values", function () { aSelect.values = [content[1], content[2]]; expect(aSelect.value).toBe(content[1]); }); - it("should set first of the values", function() { + it("should set first of the values", function () { aSelect.values = [content[1], content[2]]; aSelect.value = content[2]; expect(aSelect.values.slice()).toEqual([content[2]]); }); }); - describe("values", function() { + describe("values", function () { beforeEach(function () { aSelect = new Select(); aSelect.content = content; aSelect.multiSelect = true; }); - it("should change the selection of the content controller", function() { + it("should change the selection of the content controller", function () { aSelect.values = [content[1], content[2]]; expect(aSelect.contentController.selection.length).toBe(2); @@ -187,7 +187,7 @@ describe("test/base/abstract-select-spec", function () { expect(aSelect.contentController.selection[1]).toBe(content[2]); }); - it("should change the selection of the content controller when values is modifed", function() { + it("should change the selection of the content controller when values is modifed", function () { aSelect.values = [content[1]]; expect(aSelect.values.toArray()).toEqual([content[1]]); expect(aSelect.contentController.selection.toArray()).toEqual([content[1]]); @@ -199,7 +199,7 @@ describe("test/base/abstract-select-spec", function () { expect(aSelect.contentController.selection[1]).toBe(content[2]); }); - it("should change when content controller's selection change", function() { + it("should change when content controller's selection change", function () { aSelect.contentController.selection.splice(0, 1, content[1], content[2]); expect(aSelect.values.length).toBe(2); @@ -207,7 +207,7 @@ describe("test/base/abstract-select-spec", function () { expect(aSelect.values[1]).toBe(content[2]); }); - it("should change when content controller's selection is modified", function() { + it("should change when content controller's selection is modified", function () { aSelect.contentController.selection.splice(0, 1, content[1]); aSelect.contentController.selection.push(content[2]); @@ -216,7 +216,7 @@ describe("test/base/abstract-select-spec", function () { expect(aSelect.values[1]).toBe(content[2]); }); - it("should copy the contents when setting a new value", function() { + it("should copy the contents when setting a new value", function () { // This is needed to bind to a rangeContent() aSelect.values = [content[1]]; aSelect.contentController.selection.push(content[2]); @@ -225,13 +225,13 @@ describe("test/base/abstract-select-spec", function () { }); }); - describe("multiSelect", function() { + describe("multiSelect", function () { beforeEach(function () { aSelect = new Select(); aSelect.content = content; }); - it("should only have one item in the content controller's selection when multiSelect is off", function() { + it("should only have one item in the content controller's selection when multiSelect is off", function () { aSelect.multiSelect = false; expect(aSelect.contentController.selection.length).toBe(1); @@ -239,7 +239,7 @@ describe("test/base/abstract-select-spec", function () { expect(aSelect.contentController.selection.length).toBe(1); }); - it("should only have one selected item in content controller's selection when multiSelect is turned off", function() { + it("should only have one selected item in content controller's selection when multiSelect is turned off", function () { aSelect.multiSelect = true; aSelect.values = [content[1], content[2]]; @@ -254,7 +254,7 @@ describe("test/base/abstract-select-spec", function () { aSelect.element = MockDOM.element(); }); - it("should consider the content dirty when it is modified", function() { + it("should consider the content dirty when it is modified", function () { aSelect.labelPropertyName = "key"; expect(aSelect._contentIsDirty).toBeTruthy(); @@ -362,11 +362,11 @@ describe("test/base/abstract-select-spec", function () { aSelect = new Select(); anElement = MockDOM.element(); listener = { - handleEvent: function() {} + handleEvent: function () {} }; }); - it("should listen for pressStart only after prepareForActivationEvents", function() { + it("should listen for pressStart only after prepareForActivationEvents", function () { var listeners, em = aSelect.eventManager; diff --git a/test/base/abstract-slider-spec.js b/test/base/abstract-slider-spec.js index 2e41231705..0cc8cfbda1 100644 --- a/test/base/abstract-slider-spec.js +++ b/test/base/abstract-slider-spec.js @@ -33,99 +33,99 @@ describe("test/base/abstract-slider-spec", function () { // Inspired by // http://www.w3.org/html/wg/drafts/html/master/forms.html#range-state-(type=range) - describe("value", function() { - it("should have correct default", function() { + describe("value", function () { + it("should have correct default", function () { // is the minimum plus half the difference between the minimum and the maximum expect(aSlider.value).toEqual(50); }); - it("should have correct default for non integer min value", function() { + it("should have correct default for non integer min value", function () { aSlider.min = 60.2; expect(aSlider.value).toEqual(aSlider.min); }); - it("can be set", function() { + it("can be set", function () { aSlider.value = 5; expect(aSlider.value).toEqual(5); }); - it("can be negative", function() { + it("can be negative", function () { aSlider.min = -10; aSlider.value = -2; expect(aSlider.value).toEqual(-2); }); - it("can be set with a string", function() { + it("can be set with a string", function () { aSlider.value = "5"; expect(aSlider.value).toEqual(5); }); - it("can't be set with letters", function() { + it("can't be set with letters", function () { var previousValue = aSlider.value; aSlider.value = "hello"; expect(aSlider.value).not.toEqual("hello"); expect(aSlider.value).toEqual(previousValue); }); - describe("behavior", function() { - it("value should take min into account", function() { + describe("behavior", function () { + it("value should take min into account", function () { aSlider.min = 10; aSlider.value = 0; expect(aSlider.value).toEqual(10); }); - it("value should take max into account", function() { + it("value should take max into account", function () { aSlider.max = 20; aSlider.value = 25; expect(aSlider.value).toEqual(20); }); }); }); - describe("active", function() { - it("should have correct default", function() { + describe("active", function () { + it("should have correct default", function () { expect(aSlider.active).toBeFalsy(); }); - it("should be true after touchstart", function() { + it("should be true after touchstart", function () { aSlider.handleTouchstart(MockEvent.event()); expect(aSlider.active).toBeTruthy(); }); - it("should be true after mousedown", function() { + it("should be true after mousedown", function () { aSlider.handleMousedown(MockEvent.event()); expect(aSlider.active).toBeTruthy(); }); - it("should be false after mouseup", function() { + it("should be false after mouseup", function () { aSlider.handleMouseup(MockEvent.event()); expect(aSlider.active).toBeFalsy(); }); - it("should be false after touchend", function() { + it("should be false after touchend", function () { aSlider.handleTouchend(MockEvent.event()); expect(aSlider.active).toBeFalsy(); }); - it("should be false after thumbTranslateEnd", function() { + it("should be false after thumbTranslateEnd", function () { aSlider.handleThumbTranslateEnd(); expect(aSlider.active).toBeFalsy(); }); - it("should add active class when set to true", function() { + it("should add active class when set to true", function () { aSlider.active = true; expect(aSlider.classList.contains("montage-Slider--active")).toBeTruthy(); }); - it("should remove active class when set to false", function() { + it("should remove active class when set to false", function () { aSlider.active = true; aSlider.active = false; expect(aSlider.classList.contains("montage-Slider--active")).toBeFalsy(); }); }); - describe("step", function() { - it("should have correct default", function() { + describe("step", function () { + it("should have correct default", function () { expect(aSlider.step).toEqual("any"); }); - it("can be set", function() { + it("can be set", function () { aSlider.step = 2; expect(aSlider.step).toEqual(2); }); - it("cannot be negative", function() { + it("cannot be negative", function () { var previousValue = aSlider.step; aSlider.step = -2; expect(aSlider.step).toEqual(previousValue); }); - it("can be set with a string", function() { + it("can be set with a string", function () { aSlider.step = "2"; expect(aSlider.step).toEqual(2); }); - it("can't be set with letters", function() { + it("can't be set with letters", function () { var previousValue = aSlider.step; aSlider.step = "hello"; expect(aSlider.step).not.toEqual("hello"); @@ -152,40 +152,40 @@ describe("test/base/abstract-slider-spec", function () { }); }); }); - describe("min", function() { - it("should have correct default", function() { + describe("min", function () { + it("should have correct default", function () { expect(aSlider.min).toEqual(0); }); - it("can be set", function() { + it("can be set", function () { aSlider.min = 2; expect(aSlider.min).toEqual(2); }); - it("can be negative", function() { + it("can be negative", function () { aSlider.min = -2; expect(aSlider.min).toEqual(-2); }); - it("can be set with a string", function() { + it("can be set with a string", function () { aSlider.min = "2"; expect(aSlider.min).toEqual(2); }); - it("can't be set with letters", function() { + it("can't be set with letters", function () { var previousValue = aSlider.min; aSlider.min = "hello"; expect(aSlider.min).not.toEqual("hello"); expect(aSlider.min).toEqual(previousValue); }); - describe("behavior", function() { - it("value should be unchanged if value already a greater than min", function() { + describe("behavior", function () { + it("value should be unchanged if value already a greater than min", function () { aSlider.value = 6; aSlider.min = 2; expect(aSlider.value).toEqual(6); }); - it("value should be changed if value isn't greater than min", function() { + it("value should be changed if value isn't greater than min", function () { aSlider.value = 1; aSlider.min = 2; expect(aSlider.value).toEqual(2); }); - it("value should be changed if value isn't greater than min if min is negative", function() { + it("value should be changed if value isn't greater than min if min is negative", function () { aSlider.min = -10; aSlider.value = -3; aSlider.min = -2; @@ -193,35 +193,35 @@ describe("test/base/abstract-slider-spec", function () { }); }); }); - describe("max", function() { - it("should have correct default", function() { + describe("max", function () { + it("should have correct default", function () { expect(aSlider.max).toEqual(100); }); - it("can be set", function() { + it("can be set", function () { aSlider.max = 2; expect(aSlider.max).toEqual(2); }); - it("can be negative", function() { + it("can be negative", function () { aSlider.max = -2; expect(aSlider.max).toEqual(-2); }); - it("can be set with a string", function() { + it("can be set with a string", function () { aSlider.max = "2"; expect(aSlider.max).toEqual(2); }); - it("can't be set with letters", function() { + it("can't be set with letters", function () { var previousValue = aSlider.max; aSlider.max = "hello"; expect(aSlider.max).not.toEqual("hello"); expect(aSlider.max).toEqual(previousValue); }); - describe("behavior", function() { - it("value should be unchanged if value is already less than max", function() { + describe("behavior", function () { + it("value should be unchanged if value is already less than max", function () { aSlider.value = 2; aSlider.max = 6; expect(aSlider.value).toEqual(2); }); - it("value should be changed if value isn't less than max", function() { + it("value should be changed if value isn't less than max", function () { aSlider.value = 10; aSlider.max = 9; expect(aSlider.value).toEqual(9); @@ -241,7 +241,7 @@ describe("test/base/abstract-slider-spec", function () { aSlider.enterDocument(true); }); it("should allow value to change", function () { - expect(function() { + expect(function () { aSlider.value = 30; }).not.toThrow(); expect(aSlider.value).toEqual(30); @@ -333,10 +333,10 @@ describe("test/base/abstract-slider-spec", function () { anElement = MockDOM.element(); aSlider.element = anElement; listener = { - handleEvent: function() {} + handleEvent: function () {} }; }); - it("should listen for translateStart only after prepareForActivationEvents", function() { + it("should listen for translateStart only after prepareForActivationEvents", function () { var listeners, em = aSlider.eventManager; aSlider._sliderThumbElement = anElement; @@ -351,7 +351,7 @@ describe("test/base/abstract-slider-spec", function () { listeners = em.registeredEventListenersForEventType_onTarget_("translateStart", aSlider._translateComposer); expect(listeners[aSlider.uuid].listener).toBe(aSlider); }); - it("should listen for translate only after prepareForActivationEvents", function() { + it("should listen for translate only after prepareForActivationEvents", function () { var listeners, em = aSlider.eventManager; aSlider._sliderThumbElement = anElement; @@ -366,7 +366,7 @@ describe("test/base/abstract-slider-spec", function () { listeners = em.registeredEventListenersForEventType_onTarget_("translate", aSlider._translateComposer); expect(listeners[aSlider.uuid].listener).toBe(aSlider); }); - it("should listen for translateEnd only after prepareForActivationEvents", function() { + it("should listen for translateEnd only after prepareForActivationEvents", function () { var listeners, em = aSlider.eventManager; aSlider._sliderThumbElement = anElement; diff --git a/test/base/abstract-text-area-spec.js b/test/base/abstract-text-area-spec.js index 58697330d4..0aca8b70d0 100644 --- a/test/base/abstract-text-area-spec.js +++ b/test/base/abstract-text-area-spec.js @@ -37,7 +37,7 @@ describe("test/base/abstract-text-area-spec", function () { aTextArea.enterDocument(true); }); - it("should be the value of the element when input is fired", function() { + it("should be the value of the element when input is fired", function () { aTextArea.element.value = "A text"; var anEvent = document.createEvent("CustomEvent"); @@ -47,7 +47,7 @@ describe("test/base/abstract-text-area-spec", function () { expect(aTextArea.value).toBe("A text"); }); - it("should be the value of the element when change is fired", function() { + it("should be the value of the element when change is fired", function () { aTextArea.element.value = "A text"; var anEvent = document.createEvent("CustomEvent"); @@ -64,7 +64,7 @@ describe("test/base/abstract-text-area-spec", function () { aTextArea.element = MockDOM.element(); }); - it("should add the corresponding class name to classList when enabled is false", function() { + it("should add the corresponding class name to classList when enabled is false", function () { aTextArea.enabled = false; expect(aTextArea.classList.contains("montage--disabled")).toBe(true); @@ -160,18 +160,18 @@ describe("test/base/abstract-text-area-spec", function () { aTextArea = new TextArea(); anElement = MockDOM.element(); listener = { - handleEvent: function() {} + handleEvent: function () {} }; }); - it("should listen for element input after enterDocument", function() { + it("should listen for element input after enterDocument", function () { aTextArea.element = anElement; aTextArea.enterDocument(true); expect(aTextArea.element.hasEventListener("input", aTextArea)).toBe(true); }); - it("should listen for element change after enterDocument", function() { + it("should listen for element change after enterDocument", function () { aTextArea.element = anElement; aTextArea.enterDocument(true); diff --git a/test/base/abstract-text-field-spec.js b/test/base/abstract-text-field-spec.js index e8a4757c72..6ede6b2223 100644 --- a/test/base/abstract-text-field-spec.js +++ b/test/base/abstract-text-field-spec.js @@ -37,7 +37,7 @@ describe("test/base/abstract-text-field-spec", function () { aTextField.enterDocument(true); }); - it("should be the value of the element when input is fired", function() { + it("should be the value of the element when input is fired", function () { aTextField.element.value = "A text"; var anEvent = document.createEvent("CustomEvent"); @@ -47,7 +47,7 @@ describe("test/base/abstract-text-field-spec", function () { expect(aTextField.value).toBe("A text"); }); - it("should be the value of the element when change is fired", function() { + it("should be the value of the element when change is fired", function () { aTextField.element.value = "A text"; var anEvent = document.createEvent("CustomEvent"); @@ -57,13 +57,13 @@ describe("test/base/abstract-text-field-spec", function () { expect(aTextField.value).toBe("A text"); }); - it("should set value when field not selected", function() { + it("should set value when field not selected", function () { aTextField._value = "initial"; aTextField.value = "updated"; expect(aTextField.value).toBe("updated"); }); - it("should not set value when field selected", function() { + it("should not set value when field selected", function () { aTextField._value = "initial"; aTextField._hasFocus = true; aTextField.value = "updated"; @@ -78,8 +78,8 @@ describe("test/base/abstract-text-field-spec", function () { aTextField.prepareForActivationEvents(); }); - it("should not dispatch an action event when enabled is false and KeyComposer fires a keyPress", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should not dispatch an action event when enabled is false and KeyComposer fires a keyPress", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.type).toEqual("action"); }), anEvent = MockDOM.keyPressEvent("enter", aTextField.element); @@ -92,7 +92,7 @@ describe("test/base/abstract-text-field-spec", function () { expect(callback).not.toHaveBeenCalled(); }); - it("should add the corresponding class name to classList when enabled is false", function() { + it("should add the corresponding class name to classList when enabled is false", function () { aTextField.enabled = false; expect(aTextField.classList.contains("montage--disabled")).toBe(true); @@ -156,7 +156,7 @@ describe("test/base/abstract-text-field-spec", function () { aTextField.draw(); expect(aTextField.element.value).toBe("42"); }); - it("should display a 0 as 0 in the element", function() { + it("should display a 0 as 0 in the element", function () { aTextField.value = 0; aTextField.draw(); expect(aTextField.element.value).toEqual("0"); @@ -196,25 +196,25 @@ describe("test/base/abstract-text-field-spec", function () { aTextField = new TextField(); anElement = MockDOM.element(); listener = { - handleEvent: function() {} + handleEvent: function () {} }; }); - it("should listen for element input after enterDocument", function() { + it("should listen for element input after enterDocument", function () { aTextField.element = anElement; aTextField.enterDocument(true); expect(aTextField.element.hasEventListener("input", aTextField)).toBe(true); }); - it("should listen for element change after enterDocument", function() { + it("should listen for element change after enterDocument", function () { aTextField.element = anElement; aTextField.enterDocument(true); expect(aTextField.element.hasEventListener("change", aTextField)).toBe(true); }); - it("should listen for keyPress only after prepareForActivationEvents", function() { + it("should listen for keyPress only after prepareForActivationEvents", function () { var listeners, em = aTextField.eventManager; @@ -233,8 +233,8 @@ describe("test/base/abstract-text-field-spec", function () { aTextField.prepareForActivationEvents(); }); - it("should fire an 'action' event when the KeyComposer fires a keyPress", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should fire an 'action' event when the KeyComposer fires a keyPress", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.type).toEqual("action"); }), anEvent = MockDOM.keyPressEvent("enter", aTextField.element); @@ -246,8 +246,8 @@ describe("test/base/abstract-text-field-spec", function () { expect(callback).toHaveBeenCalled(); }); - it("should fire an 'action' event with the contents of the detail property", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should fire an 'action' event with the contents of the detail property", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.detail.get("foo")).toEqual("bar"); }), anEvent = MockDOM.keyPressEvent("enter", aTextField.element); @@ -279,24 +279,24 @@ describe("test/base/abstract-text-field-spec", function () { aTextFieldDelegate.shouldBeginEditing = jasmine.createSpy(); }); - it("should be called when acceptsActiveTarget consulted ", function() { + it("should be called when acceptsActiveTarget consulted ", function () { var accepts = aTextField.acceptsActiveTarget; expect(aTextFieldDelegate.shouldBeginEditing).toHaveBeenCalled(); }); - it("should be ignored if it returns undefined", function() { + it("should be ignored if it returns undefined", function () { aTextFieldDelegate.shouldBeginEditing.andReturn(void 0); var accepts = aTextField.acceptsActiveTarget; expect(accepts).toBeTruthy(); }); - it("should be able to return false", function() { + it("should be able to return false", function () { aTextFieldDelegate.shouldBeginEditing.andReturn(false); var accepts = aTextField.acceptsActiveTarget; expect(accepts).toBeFalsy(); }); - it("should be able to return true", function() { + it("should be able to return true", function () { aTextFieldDelegate.shouldBeginEditing.andReturn(true); var accepts = aTextField.acceptsActiveTarget; expect(accepts).toBeTruthy(); @@ -308,7 +308,7 @@ describe("test/base/abstract-text-field-spec", function () { aTextFieldDelegate.didChange = jasmine.createSpy(); }); - it("should be ", function() { + it("should be ", function () { aTextField.handleChange(); expect(aTextFieldDelegate.didChange).toHaveBeenCalled(); }); @@ -319,7 +319,7 @@ describe("test/base/abstract-text-field-spec", function () { aTextFieldDelegate.didBeginEditing = jasmine.createSpy(); }); - it("should be called when textfield is focused", function() { + it("should be called when textfield is focused", function () { aTextField.willBecomeActiveTarget(); expect(aTextFieldDelegate.didBeginEditing).toHaveBeenCalled(); }); @@ -331,24 +331,24 @@ describe("test/base/abstract-text-field-spec", function () { aTextField.willBecomeActiveTarget(); }); - it("should be called when textfield receives blur", function() { + it("should be called when textfield receives blur", function () { aTextField.surrendersActiveTarget(); expect(aTextFieldDelegate.shouldEndEditing).toHaveBeenCalled(); }); - it("should be ignored if it returns undefined", function() { + it("should be ignored if it returns undefined", function () { aTextFieldDelegate.shouldEndEditing.andReturn(void 0); aTextField.surrendersActiveTarget(); expect(aTextField.hasFocus).toBeFalsy(); }); - it("should be prevent textfield being unfocused if it returns false", function() { + it("should be prevent textfield being unfocused if it returns false", function () { aTextFieldDelegate.shouldEndEditing.andReturn(false); aTextField.surrendersActiveTarget(); expect(aTextField.hasFocus).toBeTruthy(); }); - it("should not be prevent textfield being unfocused if it returns true", function() { + it("should not be prevent textfield being unfocused if it returns true", function () { aTextFieldDelegate.shouldEndEditing.andReturn(true); aTextField.surrendersActiveTarget(); expect(aTextField.hasFocus).toBeFalsy(); @@ -361,7 +361,7 @@ describe("test/base/abstract-text-field-spec", function () { aTextFieldDelegate.didEndEditing = jasmine.createSpy(); }); - it("should be called when textfield receives blur", function() { + it("should be called when textfield receives blur", function () { aTextField.surrendersActiveTarget(); expect(aTextFieldDelegate.didEndEditing).toHaveBeenCalled(); }); diff --git a/test/base/abstract-toggle-button-spec.js b/test/base/abstract-toggle-button-spec.js index fb3a12f695..121896b052 100644 --- a/test/base/abstract-toggle-button-spec.js +++ b/test/base/abstract-toggle-button-spec.js @@ -21,7 +21,7 @@ describe("test/base/abstract-toggle-button-spec", function () { expect(aToggleButtonSubtype).toBeDefined(); }); }); - + describe("properties", function () { var ToggleButton = AbstractToggleButton.specialize( {}), aToggleButton; @@ -43,7 +43,7 @@ describe("test/base/abstract-toggle-button-spec", function () { aToggleButton.prepareForActivationEvents(); }); - it("should not toggle when enabled is false and PressComposer fires a press", function() { + it("should not toggle when enabled is false and PressComposer fires a press", function () { aToggleButton.pressed = false; aToggleButton.enabled = false; @@ -53,8 +53,8 @@ describe("test/base/abstract-toggle-button-spec", function () { expect(aToggleButton.pressed).toBe(false); }); - it("should not dispatch an action event when enabled is false and PressComposer fires a press", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should not dispatch an action event when enabled is false and PressComposer fires a press", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.type).toEqual("action"); }); aToggleButton.addEventListener("action", callback, false); @@ -67,7 +67,7 @@ describe("test/base/abstract-toggle-button-spec", function () { expect(callback).not.toHaveBeenCalled(); }); - it("should add the corresponding class name to classList when enabled is false", function() { + it("should add the corresponding class name to classList when enabled is false", function () { aToggleButton.enabled = false; expect(aToggleButton.classList.contains("montage--disabled")).toBe(true); @@ -113,7 +113,7 @@ describe("test/base/abstract-toggle-button-spec", function () { aToggleButton.prepareForActivationEvents(); }); - it("should toggle when enabled is true and PressComposer fires a press", function() { + it("should toggle when enabled is true and PressComposer fires a press", function () { aToggleButton.pressed = false; aToggleButton.enabled = true; @@ -123,7 +123,7 @@ describe("test/base/abstract-toggle-button-spec", function () { expect(aToggleButton.pressed).toBe(true); }); - it("should not toggle when enabled is false and PressComposer fires a press", function() { + it("should not toggle when enabled is false and PressComposer fires a press", function () { aToggleButton.pressed = false; aToggleButton.enabled = false; @@ -133,7 +133,7 @@ describe("test/base/abstract-toggle-button-spec", function () { expect(aToggleButton.pressed).toBe(false); }); - it("should add the corresponding class name to classList when enabled is false", function() { + it("should add the corresponding class name to classList when enabled is false", function () { aToggleButton.pressed = true; expect(aToggleButton.classList.contains("montage-ToggleButton--pressed")).toBe(true); @@ -205,11 +205,11 @@ describe("test/base/abstract-toggle-button-spec", function () { aToggleButton = new ToggleButton(); anElement = MockDOM.element(); listener = { - handleEvent: function() {} + handleEvent: function () {} } }); - it("should listen for pressStart only after prepareForActivationEvents", function() { + it("should listen for pressStart only after prepareForActivationEvents", function () { var listeners, em = aToggleButton.eventManager; @@ -222,7 +222,7 @@ describe("test/base/abstract-toggle-button-spec", function () { expect(listeners[aToggleButton.uuid].listener).toBe(aToggleButton); }); - it("should listen for longPress on PressComposer on demand", function() { + it("should listen for longPress on PressComposer on demand", function () { var listeners, em = aToggleButton.eventManager; @@ -241,8 +241,8 @@ describe("test/base/abstract-toggle-button-spec", function () { aToggleButton.prepareForActivationEvents(); }); - it("should fire a 'longAction' event when the PressComposer fires a longPress", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should fire a 'longAction' event when the PressComposer fires a longPress", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.type).toEqual("longAction"); }); aToggleButton.addEventListener("longAction", callback, false); @@ -250,8 +250,8 @@ describe("test/base/abstract-toggle-button-spec", function () { expect(callback).toHaveBeenCalled(); }); - it("should not fire an 'action' event when enabled is false and PressComposer fires a press", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should not fire an 'action' event when enabled is false and PressComposer fires a press", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.type).toEqual("action"); }); aToggleButton.addEventListener("action", callback, false); @@ -263,8 +263,8 @@ describe("test/base/abstract-toggle-button-spec", function () { expect(callback).not.toHaveBeenCalled(); }); - it("should fire an 'action' event when enabled is true and PressComposer fires a press", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should fire an 'action' event when enabled is true and PressComposer fires a press", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.type).toEqual("action"); }); aToggleButton.addEventListener("action", callback, false); @@ -276,8 +276,8 @@ describe("test/base/abstract-toggle-button-spec", function () { expect(callback).toHaveBeenCalled(); }); - it("should fire an 'action' event with the contents of the detail property", function() { - var callback = jasmine.createSpy().andCallFake(function(event) { + it("should fire an 'action' event with the contents of the detail property", function () { + var callback = jasmine.createSpy().andCallFake(function (event) { expect(event.detail.get("foo")).toEqual("bar"); }); aToggleButton.addEventListener("action", callback, false); @@ -290,7 +290,7 @@ describe("test/base/abstract-toggle-button-spec", function () { expect(callback).toHaveBeenCalled(); }); - it("should toggle on 'space' keyPress", function() { + it("should toggle on 'space' keyPress", function () { var anEvent = MockDOM.keyPressEvent("space", aToggleButton.element); aToggleButton.pressed = false; diff --git a/test/base/abstract-toggle-switch-spec.js b/test/base/abstract-toggle-switch-spec.js index 8fed02c53e..06e15184b2 100644 --- a/test/base/abstract-toggle-switch-spec.js +++ b/test/base/abstract-toggle-switch-spec.js @@ -4,31 +4,31 @@ var MockDOM = require("mocks/dom"); AbstractToggleSwitch.prototype.hasTemplate = false; -describe("test/base/abstract-toggle-switch-spec", function() { +describe("test/base/abstract-toggle-switch-spec", function () { var ToggleSwitch = AbstractToggleSwitch.specialize({}), aToggleSwitch; - beforeEach(function() { + beforeEach(function () { aToggleSwitch = new ToggleSwitch(); aToggleSwitch.element = MockDOM.element(); aToggleSwitch.needsDraw = false; }); - describe("creation", function() { - it("cannot be instantiated directly", function() { - expect(function() { + describe("creation", function () { + it("cannot be instantiated directly", function () { + expect(function () { new AbstractToggleSwitch(); }).toThrow(); }); - it("can be instantiated as a subtype", function() { + it("can be instantiated as a subtype", function () { expect(aToggleSwitch).toBeDefined(); }); }); - describe("properties", function() { - describe("enabled", function() { - it("should not toggle when enabled is false and there is a press", function() { + describe("properties", function () { + describe("enabled", function () { + it("should not toggle when enabled is false and there is a press", function () { aToggleSwitch.checked = false; aToggleSwitch.enabled = false; aToggleSwitch.prepareForActivationEvents(); @@ -38,14 +38,14 @@ describe("test/base/abstract-toggle-switch-spec", function() { expect(aToggleSwitch.checked).toBe(false); }); - it("should add the corresponding class name to classList when enabled is false", function() { + it("should add the corresponding class name to classList when enabled is false", function () { aToggleSwitch.enabled = false; expect(aToggleSwitch.classList.contains("montage--disabled")).toBe(true); }); }); - describe("checked", function() { - it("should update classList to reflect when it is checked", function() { + describe("checked", function () { + it("should update classList to reflect when it is checked", function () { aToggleSwitch.checked = false; expect(aToggleSwitch.classList.contains("montage-ToggleSwitch--checked")).toBe(false); aToggleSwitch.checked = true; @@ -54,21 +54,21 @@ describe("test/base/abstract-toggle-switch-spec", function() { }); }); - describe("draw", function() { - it("should be requested after changing checked state", function() { + describe("draw", function () { + it("should be requested after changing checked state", function () { aToggleSwitch.checked = true; expect(aToggleSwitch.needsDraw).toBeTruthy(); }); - it("should be requested after changing enabled state", function() { + it("should be requested after changing enabled state", function () { aToggleSwitch.enabled = false; expect(aToggleSwitch.needsDraw).toBeTruthy(); }); }); - describe("blueprint", function() { - it("can be created", function() { + describe("blueprint", function () { + it("can be created", function () { var blueprintPromise = AbstractToggleSwitch.blueprint; - return blueprintPromise.then(function(blueprint) { + return blueprintPromise.then(function (blueprint) { expect(blueprint).not.toBeNull(); }); }); diff --git a/test/base/abstract-video-spec.js b/test/base/abstract-video-spec.js index b3bb484863..9629c7c743 100644 --- a/test/base/abstract-video-spec.js +++ b/test/base/abstract-video-spec.js @@ -35,11 +35,11 @@ describe("test/base/abstract-video-spec", function () { aVideoPlayer.enterDocument(true); }); - it("should be set after enterDocument()", function() { + it("should be set after enterDocument()", function () { expect(aVideoPlayer.videoController).not.toBeNull(); }); - it("should link native media controller to media element", function() { + it("should link native media controller to media element", function () { expect(aVideoPlayer.videoController.mediaController).toEqual(aVideoPlayer.mediaElement.controller); }); @@ -52,14 +52,14 @@ describe("test/base/abstract-video-spec", function () { aVideoPlayer.mediaElement = MockDOM.element(); }); - it("should read initial value from original element", function() { + it("should read initial value from original element", function () { aVideoPlayer.originalElement.setAttribute("src", "sample.mov"); aVideoPlayer.enterDocument(true); expect(aVideoPlayer.src).toBe("sample.mov"); }); - it("should read initial value from child source elements", function() { + it("should read initial value from child source elements", function () { var sourceElements = [ MockDOM.element(), MockDOM.element() @@ -71,7 +71,7 @@ describe("test/base/abstract-video-spec", function () { sourceElements[1].setAttribute("src", "movie2.ogg"); sourceElements[1].setAttribute("type", "video/ogg"); aVideoPlayer.originalElement.childNodes = sourceElements; - aVideoPlayer.mediaElement.canPlayType = function(type) { + aVideoPlayer.mediaElement.canPlayType = function (type) { if (type === "video/ogg") { return "maybe"; } @@ -81,7 +81,7 @@ describe("test/base/abstract-video-spec", function () { expect(aVideoPlayer.src).toBe("movie1.ogg"); }); - it("should read initial value from child source elements only with valid type", function() { + it("should read initial value from child source elements only with valid type", function () { var sourceElements = [ MockDOM.element(), MockDOM.element() @@ -93,7 +93,7 @@ describe("test/base/abstract-video-spec", function () { sourceElements[1].setAttribute("src", "movie2.ogg"); sourceElements[1].setAttribute("type", "video/ogg"); aVideoPlayer.originalElement.childNodes = sourceElements; - aVideoPlayer.mediaElement.canPlayType = function(type) { + aVideoPlayer.mediaElement.canPlayType = function (type) { if (type === "video/ogg") { return "maybe"; } @@ -110,9 +110,9 @@ describe("test/base/abstract-video-spec", function () { aVideoPlayer.element = MockDOM.element(); aVideoPlayer.originalElement = MockDOM.element(); aVideoPlayer.mediaElement = MockDOM.element(); - aVideoPlayer.element.ownerDocument.createElement = function() { + aVideoPlayer.element.ownerDocument.createElement = function () { var element = MockDOM.element(); - element.canPlayType = function(type) { + element.canPlayType = function (type) { if (type === "video/ogg") { return "maybe"; } @@ -122,7 +122,7 @@ describe("test/base/abstract-video-spec", function () { aVideoPlayer.enterDocument(true); }); - it("should use first source with known/valid media type", function() { + it("should use first source with known/valid media type", function () { aVideoPlayer.sources = [ {src: "movie1.ogg", type: "video/ogg"}, {src: "movie2.ogg", type: "video/ogg"} @@ -130,7 +130,7 @@ describe("test/base/abstract-video-spec", function () { expect(aVideoPlayer.src).toBe("movie1.ogg"); }); - it("should skip sources with unknown/invalid media type", function() { + it("should skip sources with unknown/invalid media type", function () { aVideoPlayer.sources = [ {src: "movie1.ogg", type: "invalid/type"}, {src: "movie2.ogg", type: "video/ogg"} @@ -138,7 +138,7 @@ describe("test/base/abstract-video-spec", function () { expect(aVideoPlayer.src).toBe("movie2.ogg"); }); - it("should save all sources", function() { + it("should save all sources", function () { var sources = [ {src: "movie1.ogg", type: "invalid/type"}, {src: "movie2.ogg", type: "video/ogg"} @@ -199,23 +199,23 @@ describe("test/base/abstract-video-spec", function () { expect(aVideoPlayer.isFullScreen).toBeFalsy(); }); - it("can not be set directly", function() { + it("can not be set directly", function () { aVideoPlayer.isFullScreen = true; expect(aVideoPlayer.isFullScreen).toBeFalsy(); }); - it("can be toggled", function() { + it("can be toggled", function () { aVideoPlayer.toggleFullScreen(); expect(aVideoPlayer.isFullScreen).toBeTruthy(); }); - it("can not be toggled if fullscreen is not supported", function() { + it("can not be toggled if fullscreen is not supported", function () { aVideoPlayer.supportsFullScreen = false; aVideoPlayer.toggleFullScreen(); expect(aVideoPlayer.isFullScreen).toBeFalsy(); }); - it("can be toggled back", function() { + it("can be toggled back", function () { aVideoPlayer.toggleFullScreen(); aVideoPlayer.toggleFullScreen(); expect(aVideoPlayer.isFullScreen).toBeFalsy(); @@ -238,7 +238,7 @@ describe("test/base/abstract-video-spec", function () { expect(aVideoPlayer.supportsFullScreen).toBeTruthy(); }); - it("can be set", function() { + it("can be set", function () { aVideoPlayer.supportsFullScreen = false; expect(aVideoPlayer.supportsFullScreen).toBeFalsy(); }); diff --git a/test/bindings/converter-spec.js b/test/bindings/converter-spec.js index d0dde39db6..9ab08edd21 100644 --- a/test/bindings/converter-spec.js +++ b/test/bindings/converter-spec.js @@ -35,24 +35,24 @@ var Montage = require("montage").Montage, var TestConverter = Converter.specialize( { convert: { - value: function(value) { + value: function (value) { return "CONVERT" + value; } }, revert: { - value: function(value) { + value: function (value) { return value.replace("CONVERT", ""); } } }); -describe("bindings/binding-converter-spec", function() { +describe("bindings/binding-converter-spec", function () { var target, source, bindingDescriptor; - beforeEach(function() { + beforeEach(function () { target = new Montage(); source = new Montage(); @@ -63,9 +63,9 @@ describe("bindings/binding-converter-spec", function() { }; }) - describe("involved in a two way binding", function() { + describe("involved in a two way binding", function () { - it("should convert the value passed to the source when the binding is established", function() { + it("should convert the value passed to the source when the binding is established", function () { source.bar = "bar"; Bindings.defineBinding(target, "foo", bindingDescriptor); @@ -73,7 +73,7 @@ describe("bindings/binding-converter-spec", function() { expect(target.foo).toBe("CONVERTbar") }); - it("should convert the value passed to the source when the bound object's value changes", function() { + it("should convert the value passed to the source when the bound object's value changes", function () { source.bar = "bar"; Bindings.defineBinding(target, "foo", bindingDescriptor); @@ -84,7 +84,7 @@ describe("bindings/binding-converter-spec", function() { }); - it("should revert the value passed to the bound object when the source object's value changes", function() { + it("should revert the value passed to the bound object when the source object's value changes", function () { source.bar = "bar"; Bindings.defineBinding(target, "foo", bindingDescriptor); @@ -96,14 +96,14 @@ describe("bindings/binding-converter-spec", function() { }); - describe("involved in a one way binding", function() { + describe("involved in a one way binding", function () { - beforeEach(function() { + beforeEach(function () { bindingDescriptor["<-"] = bindingDescriptor["<->"]; delete bindingDescriptor["<->"]; }); - it("should convert the value passed to the source when the binding is established", function() { + it("should convert the value passed to the source when the binding is established", function () { source.bar = "bar"; Bindings.defineBinding(target, "foo", bindingDescriptor); @@ -111,7 +111,7 @@ describe("bindings/binding-converter-spec", function() { expect(target.foo).toBe("CONVERTbar") }); - it("should convert the value passed to the source when the bound object's value changes", function() { + it("should convert the value passed to the source when the bound object's value changes", function () { source.bar = "bar"; Bindings.defineBinding(target, "foo", bindingDescriptor); @@ -121,7 +121,7 @@ describe("bindings/binding-converter-spec", function() { expect(target.foo).toBe("CONVERTbaz") }); - it("must not enable propagating a value from the source object to the bound object", function() { + it("must not enable propagating a value from the source object to the bound object", function () { source.bar = "bar"; Bindings.defineBinding(target, "foo", bindingDescriptor); diff --git a/test/bindings/self-spec.js b/test/bindings/self-spec.js index cb597680f5..a10d0ae799 100644 --- a/test/bindings/self-spec.js +++ b/test/bindings/self-spec.js @@ -35,39 +35,39 @@ var Converter = require("montage/core/converter/converter").Converter; var StrToBoolConverter = Converter.specialize( { convert: { - value: function(value) { + value: function (value) { return value === "yes"; } }, revert: { - value: function(value) { + value: function (value) { return value ? "yes" : "no"; } } }); -describe("bindings/self-spec.js", function() { +describe("bindings/self-spec.js", function () { var theObject, bindingDescriptor; - beforeEach(function() { + beforeEach(function () { theObject = { foo: true, bar: "yes" }; }); - describe("with a oneway binding", function() { + describe("with a oneway binding", function () { - beforeEach(function() { + beforeEach(function () { bindingDescriptor = { "<-": "bar", source: theObject }; }); - it ("should propagate a change at the bound property to the source property", function() { + it ("should propagate a change at the bound property to the source property", function () { Bindings.defineBinding(theObject, "foo", bindingDescriptor); theObject.bar = "new bar value"; @@ -75,7 +75,7 @@ describe("bindings/self-spec.js", function() { expect(theObject.bar).toBe("new bar value"); }); - it ("must not propagate a change at the source property to the bound property", function() { + it ("must not propagate a change at the source property to the bound property", function () { Bindings.defineBinding(theObject, "foo", bindingDescriptor); theObject.foo = "new foo value"; @@ -83,11 +83,11 @@ describe("bindings/self-spec.js", function() { expect(theObject.foo).toBe("new foo value"); }); - describe("with a converter in place", function() { + describe("with a converter in place", function () { var converter; - beforeEach(function() { + beforeEach(function () { bindingDescriptor = { "<-": "bar", source: theObject, @@ -95,7 +95,7 @@ describe("bindings/self-spec.js", function() { }; }); - it ("should propagate a change at the bound property as a 'converted' value to the source property", function() { + it ("should propagate a change at the bound property as a 'converted' value to the source property", function () { Bindings.defineBinding(theObject, "foo", bindingDescriptor); theObject.bar = "no"; @@ -104,7 +104,7 @@ describe("bindings/self-spec.js", function() { }); - it ("must not propagate a change at the source property to the bound property", function() { + it ("must not propagate a change at the source property to the bound property", function () { Bindings.defineBinding(theObject, "foo", bindingDescriptor); theObject.foo = false; @@ -112,7 +112,7 @@ describe("bindings/self-spec.js", function() { expect(theObject.bar).toBe("yes"); }); - it ("should propagate a change at the source property as a 'reverted' value to the bound property if this change is not the first time the binding is fired", function() { + it ("should propagate a change at the source property as a 'reverted' value to the bound property if this change is not the first time the binding is fired", function () { Bindings.defineBinding(theObject, "foo", bindingDescriptor); theObject.foo = false; theObject.foo = true; @@ -125,16 +125,16 @@ describe("bindings/self-spec.js", function() { }); - describe("with a twoway binding", function() { + describe("with a twoway binding", function () { - beforeEach(function() { + beforeEach(function () { bindingDescriptor = { "<->": "bar", source: theObject }; }); - it ("should propagate a change at the bound property to the source property", function() { + it ("should propagate a change at the bound property to the source property", function () { Bindings.defineBinding(theObject, "foo", bindingDescriptor); theObject.bar = "new bar value"; @@ -142,7 +142,7 @@ describe("bindings/self-spec.js", function() { expect(theObject.bar).toBe("new bar value"); }); - it ("should propagate a change at the source property to the bound property", function() { + it ("should propagate a change at the source property to the bound property", function () { Bindings.defineBinding(theObject, "foo", bindingDescriptor); theObject.foo = "new foo value"; @@ -150,11 +150,11 @@ describe("bindings/self-spec.js", function() { expect(theObject.bar).toBe("new foo value"); }); - describe("with a converter in place", function() { + describe("with a converter in place", function () { var converter; - beforeEach(function() { + beforeEach(function () { bindingDescriptor = { "<->": "bar", source: theObject, @@ -162,7 +162,7 @@ describe("bindings/self-spec.js", function() { }; }); - it ("should propagate a change at the bound property as a 'converted' value to the source property the first time such a change occurs", function() { + it ("should propagate a change at the bound property as a 'converted' value to the source property the first time such a change occurs", function () { Bindings.defineBinding(theObject, "foo", bindingDescriptor); theObject.bar = "no"; @@ -170,7 +170,7 @@ describe("bindings/self-spec.js", function() { expect(theObject.bar).toBe("no"); }); - it ("should propagate a change at the bound property as a 'converted' value to the source property if this change is not the first time the binding is fired", function() { + it ("should propagate a change at the bound property as a 'converted' value to the source property if this change is not the first time the binding is fired", function () { Bindings.defineBinding(theObject, "foo", bindingDescriptor); theObject.bar = "no"; theObject.bar = "yes"; @@ -179,7 +179,7 @@ describe("bindings/self-spec.js", function() { expect(theObject.bar).toBe("yes"); }); - it ("should propagate a change at the source property as a 'reverted' value to the bound property the first time such a change occurs", function() { + it ("should propagate a change at the source property as a 'reverted' value to the bound property the first time such a change occurs", function () { Bindings.defineBinding(theObject, "foo", bindingDescriptor); theObject.foo = false; @@ -187,7 +187,7 @@ describe("bindings/self-spec.js", function() { expect(theObject.bar).toBe("no"); }); - it ("should propagate a change at the source property as a 'reverted' value to the bound property if this change is not the first time the binding is fired", function() { + it ("should propagate a change at the source property as a 'reverted' value to the bound property if this change is not the first time the binding is fired", function () { Bindings.defineBinding(theObject, "foo", bindingDescriptor); theObject.foo = false; diff --git a/test/bindings/spec.js b/test/bindings/spec.js index ebd16f02cf..5f06d7c8e7 100644 --- a/test/bindings/spec.js +++ b/test/bindings/spec.js @@ -43,10 +43,10 @@ var Alpha = Montage.specialize( { foo: { enumerable: false, - set: function(value) { + set: function (value) { this._foo = value; }, - get: function() { + get: function () { return this._foo; } }, @@ -63,7 +63,7 @@ var Alpha = Montage.specialize( { getOnly: { enumerable: false, - get: function() { + get: function () { return this._getOnly; } }, @@ -75,7 +75,7 @@ var Alpha = Montage.specialize( { setOnly: { enumerable: false, - set: function(value) { + set: function (value) { this._setOnly = value; } } @@ -91,22 +91,22 @@ var Omega = Montage.specialize( { bar: { enumerable: false, - set: function(value) { + set: function (value) { this._bar = value; }, - get: function() { + get: function () { return this._bar; } } }); -describe("bindings/spec", function() { +describe("bindings/spec", function () { - describe("a typical installed binding", function() { + describe("a typical installed binding", function () { - describe('that is not one way', function() { + describe('that is not one way', function () { - it("must correctly observe a propertyPath where a get/set property follows a value property", function() { + it("must correctly observe a propertyPath where a get/set property follows a value property", function () { var target = new Alpha(), source = new Alpha(), intermediateValue = new Omega(); @@ -126,7 +126,7 @@ describe("bindings/spec", function() { expect(intermediateValue.bar).toBe("hey new value here"); }); - it("should propagate a change from the source object's source property path to the bound object's bound property path, if the binding is not one way", function() { + it("should propagate a change from the source object's source property path to the bound object's bound property path, if the binding is not one way", function () { var target = new Alpha(), source = new Omega(); @@ -150,14 +150,14 @@ describe("bindings/spec", function() { }); - it("must not give the specified converter a chance to modify the value being passed from the bound object to the source object", function() { + it("must not give the specified converter a chance to modify the value being passed from the bound object to the source object", function () { var target = new Alpha(), source = new Omega(); Bindings.defineBinding(target, "foo", { source: source, "<->": "bar", - convert: function() { + convert: function () { return "no!"; } }); @@ -169,7 +169,7 @@ describe("bindings/spec", function() { }); - it("must not propagate a change from the source object's source property path to the bound object's bound property path", function() { + it("must not propagate a change from the source object's source property path to the bound object's bound property path", function () { var target = new Alpha(), source = new Omega(); @@ -188,7 +188,7 @@ describe("bindings/spec", function() { expect(target.foo).toBeTruthy(); }); - it("should propagate a change from the bound object's bound property path to the source object's source property path", function() { + it("should propagate a change from the bound object's bound property path to the source object's source property path", function () { var target = new Alpha(), source = new Omega(); @@ -202,7 +202,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe("foo"); }); - it("should propagate the original value from the bound object's bound property path to the source object's source property path", function() { + it("should propagate the original value from the bound object's bound property path to the source object's source property path", function () { var target = new Alpha(), source = new Omega(); @@ -216,7 +216,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe("foo"); }); - it("should properly install a binding on a property that has only a 'get' in its propertyDescriptor, without making the property 'set-able'", function() { + it("should properly install a binding on a property that has only a 'get' in its propertyDescriptor, without making the property 'set-able'", function () { var target = new Omega(), source = new Alpha(); @@ -246,14 +246,14 @@ describe("bindings/spec", function() { expect(target.result).toBe("pass"); }); - it("should give the specified converter a chance to modify the value being passed from the source object to the bound object", function() { + it("should give the specified converter a chance to modify the value being passed from the source object to the bound object", function () { var target = new Alpha(), source = new Omega(); Bindings.defineBinding(target, "foo", { source: source, "<-": "bar", - convert: function() { + convert: function () { return "yay"; } }); @@ -263,7 +263,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe("yay"); }); - it("should not define a property for a nonexistent property on a bound object", function() { + it("should not define a property for a nonexistent property on a bound object", function () { // TODO this is what's happening right now, and while it seems a little odd it's basically how you can // observe with the expectation that the property may exist later... // This makes a lot more sense on arrays than it does on objects, so I'd definitely understand @@ -281,7 +281,7 @@ describe("bindings/spec", function() { expect(source.hasOwnProperty("foo")).toBeTruthy(); }); - it("should return undefined when defining a binding along a propertyPath that encounters an undefined property", function() { + it("should return undefined when defining a binding along a propertyPath that encounters an undefined property", function () { var target = new Alpha(), source = new Omega(); @@ -295,7 +295,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(undefined); }); - it("should update a binding to undefined if the path is broken", function() { + it("should update a binding to undefined if the path is broken", function () { var target = new Alpha(), source = new Omega(), validObjectInPath = new Omega(), @@ -316,7 +316,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(undefined); }); - it("must throw an error when trying to use a property on a target as the source of a binding at a different path of the same source", function() { + it("must throw an error when trying to use a property on a target as the source of a binding at a different path of the same source", function () { var target = new Alpha(), source = new Omega(); @@ -330,7 +330,7 @@ describe("bindings/spec", function() { expect(source.bar).toBe(null); source.baz = "baz"; - expect(function() { + expect(function () { Bindings.defineBinding(target, "foo", { source: source, "<-": "baz" @@ -338,7 +338,7 @@ describe("bindings/spec", function() { }).toThrow("Can't bind to already bound target, \"foo\""); }); - it("must throw an error when trying to use a property on a target as the source of a binding to another object", function() { + it("must throw an error when trying to use a property on a target as the source of a binding to another object", function () { var target = new Alpha(), source = new Omega(), secondBoundObject = new Omega(); @@ -352,7 +352,7 @@ describe("bindings/spec", function() { expect(source.bar).toBe(null); - expect(function() { + expect(function () { Bindings.defineBinding(target, "foo", { source: secondBoundObject, "<-": "bar" @@ -360,9 +360,9 @@ describe("bindings/spec", function() { }).toThrow("Can't bind to already bound target, \"foo\""); }); - describe("when bound to the same object", function() { + describe("when bound to the same object", function () { - it("should work as expected", function() { + it("should work as expected", function () { var target = new Alpha(); target.valueOnly = "startValue"; @@ -382,7 +382,7 @@ describe("bindings/spec", function() { }); - describe("two hop binding with boolean", function() { + describe("two hop binding with boolean", function () { var FormatBar, DocumentController, @@ -391,7 +391,7 @@ describe("bindings/spec", function() { documentController, textItem; - beforeEach(function() { + beforeEach(function () { FormatBar = Montage.specialize( {boldMode: {value: null}}); DocumentController = Montage.specialize( {boldMode: {value: null}}); @@ -412,14 +412,14 @@ describe("bindings/spec", function() { }); }); - it("should propagate values to all parties when the change occurs on a two-way bound object", function() { + it("should propagate values to all parties when the change occurs on a two-way bound object", function () { formatBar.boldMode = true; expect(formatBar.boldMode).toBeTruthy(); expect(documentController.boldMode).toBeTruthy(); expect(textItem.boldMode).toBeTruthy(); }); - it("must not propagate values to all parties when the change occurs on a one-way bound object", function() { + it("must not propagate values to all parties when the change occurs on a one-way bound object", function () { // NOTE this runs this the risk of putting this object out of sync with all the other objects bound together textItem.boldMode = false; @@ -428,7 +428,7 @@ describe("bindings/spec", function() { expect(textItem.boldMode).toBeFalsy(); }); - it("must not propagate values to all parties when the value on the two-way binding did not change", function() { + it("must not propagate values to all parties when the value on the two-way binding did not change", function () { documentController.boldMode = true; expect(formatBar.boldMode).toBeTruthy(); @@ -438,9 +438,9 @@ describe("bindings/spec", function() { }); }); - describe("involving strings", function() { + describe("involving strings", function () { - it("should probably not bother observing an immutable string for a change at its length property", function() { + it("should probably not bother observing an immutable string for a change at its length property", function () { var target = new Alpha(), source = "test"; @@ -452,7 +452,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(4); }); - it("should propagate a change to a string found at a property when the string's length is being observed", function() { + it("should propagate a change to a string found at a property when the string's length is being observed", function () { var target = new Alpha(), source = new Alpha(); @@ -468,7 +468,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(11); }); - it("should correctly observe the length property of an object if the object at that property was previously a string", function() { + it("should correctly observe the length property of an object if the object at that property was previously a string", function () { var target = new Alpha(), source = new Alpha(); @@ -484,7 +484,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(12); }); - describe("two hop binding with string", function() { + describe("two hop binding with string", function () { var FormatBar, DocumentController, @@ -493,7 +493,7 @@ describe("bindings/spec", function() { documentController, textItem; - beforeEach(function() { + beforeEach(function () { FormatBar = Montage.specialize( {boldMode: {value: null}}); DocumentController = Montage.specialize( {boldMode: {value: null}}); @@ -514,21 +514,21 @@ describe("bindings/spec", function() { }); }); - it("should propagate values to all parties when the change occurs on a two-way bound object", function() { + it("should propagate values to all parties when the change occurs on a two-way bound object", function () { formatBar.boldMode = "true"; expect(formatBar.boldMode).toEqual("true"); expect(documentController.boldMode).toEqual("true"); expect(textItem.boldMode).toEqual("true"); }); - it("must not propagate values to all parties when the change occurs on a one-way bound object", function() { + it("must not propagate values to all parties when the change occurs on a one-way bound object", function () { textItem.boldMode = "false"; expect(formatBar.boldMode).toBeNull(); expect(documentController.boldMode).toBeNull(); expect(textItem.boldMode).toEqual("false"); }); - it("must not propagate values to all parties when the value on the two-way binding did not change", function() { + it("must not propagate values to all parties when the value on the two-way binding did not change", function () { documentController.boldMode = "true"; expect(formatBar.boldMode).toEqual("true"); expect(documentController.boldMode).toEqual("true"); @@ -539,9 +539,9 @@ describe("bindings/spec", function() { }); - describe("when bound to an array", function() { + describe("when bound to an array", function () { - it("should not go out of its way to protect you from mutations to an object on the left making their way over to the right", function() { + it("should not go out of its way to protect you from mutations to an object on the left making their way over to the right", function () { var target = new Alpha(), source = new Omega(); @@ -569,7 +569,7 @@ describe("bindings/spec", function() { expect(source.bar[3]).toBe("d"); //but it makes sense, left and right are the same array }); - it("should propagate additions from the bound array to the source propertyPath", function() { + it("should propagate additions from the bound array to the source propertyPath", function () { var target = new Alpha(), source = new Omega(); @@ -590,7 +590,7 @@ describe("bindings/spec", function() { expect(target.foo[3]).toBe("d"); }); - it("should propagate deletions from the bound array to the source propertyPath", function() { + it("should propagate deletions from the bound array to the source propertyPath", function () { var target = new Alpha(), source = new Omega(); @@ -609,7 +609,7 @@ describe("bindings/spec", function() { expect(target.foo[1]).toBe("b"); }); - it("should propagate a change from the bound array index contents to the source propertyPath using splice", function() { + it("should propagate a change from the bound array index contents to the source propertyPath using splice", function () { var target = new Alpha(), source = new Omega(); @@ -626,7 +626,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe("aa"); }); - it("should propagate a change from the bound array index contents to the source propertyPath using set", function() { + it("should propagate a change from the bound array index contents to the source propertyPath using set", function () { var target = new Alpha(), source = new Omega(); @@ -641,7 +641,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe("aa"); }); - it("should propagate a change from the bound array index contents to the source propertyPath using set when the array changes", function() { + it("should propagate a change from the bound array index contents to the source propertyPath using set when the array changes", function () { var target = new Alpha(), source = new Omega(); @@ -656,7 +656,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe("aa"); }); - it("should propagate changes to other objects bound ", function() { + it("should propagate changes to other objects bound ", function () { var a = new Alpha(), b = new Omega(), c = new Alpha(); @@ -678,7 +678,7 @@ describe("bindings/spec", function() { expect(c.foo[0]).toBe("aa"); }); - it ("should affect and emit changes on both sides of a two-way binding", function() { + it ("should affect and emit changes on both sides of a two-way binding", function () { var target = new Alpha(), source = new Omega(); @@ -692,11 +692,11 @@ describe("bindings/spec", function() { }); var changeListener = { - targetListener: function() { + targetListener: function () { expect(target.foo.length).toBe(4); expect(target.foo[3]).toBe("d"); }, - sourceListener: function() { + sourceListener: function () { expect(source.bar.length).toBe(4); expect(source.bar[3]).toBe("d"); } @@ -714,7 +714,7 @@ describe("bindings/spec", function() { expect(changeListener.sourceListener).toHaveBeenCalled(); }); - it("should remove the last element on a pop, multiple times, when that array index content is bound", function() { + it("should remove the last element on a pop, multiple times, when that array index content is bound", function () { var target = new Alpha(), source = new Omega(); @@ -733,7 +733,7 @@ describe("bindings/spec", function() { expect(source.bar.length).toBe(0); }); - it("should propagate a change from the bound object when the property path includes an array index and that element is removed", function() { + it("should propagate a change from the bound object when the property path includes an array index and that element is removed", function () { var target = new Alpha(), source = new Omega(); @@ -748,7 +748,7 @@ describe("bindings/spec", function() { expect(target.foo).toBeUndefined(); }); - it("must not allow an outright replacement of the value on the target to affect the rightObject in a one wayy binding", function() { + it("must not allow an outright replacement of the value on the target to affect the rightObject in a one wayy binding", function () { var target = new Alpha(), source = new Omega(), originalObject = ["a", "b", "c"], @@ -767,7 +767,7 @@ describe("bindings/spec", function() { expect(source.bar).toBe(originalObject); }); - it("should correctly observe a nonexistent index", function() { + it("should correctly observe a nonexistent index", function () { var target = new Alpha(), source = new Omega(); @@ -783,9 +783,9 @@ describe("bindings/spec", function() { expect(target.foo).toBe(42); }); - describe("and the 'count' function as part of the property path", function() { + describe("and the 'count' function as part of the property path", function () { - it("should propagate a change to the length when pushing onto to the array", function() { + it("should propagate a change to the length when pushing onto to the array", function () { var target = new Alpha(), source = new Omega(); @@ -804,7 +804,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(4); }); - it("should propagate a change to the length when popping from the array", function() { + it("should propagate a change to the length when popping from the array", function () { var target = new Alpha(), source = new Omega(); @@ -822,7 +822,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(2); }); - it("should propagate a change to the length when shifting from the array", function() { + it("should propagate a change to the length when shifting from the array", function () { var target = new Alpha(), source = new Omega(); @@ -840,7 +840,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(2); }); - it("should propagate a change to the length when unshifting to the array", function() { + it("should propagate a change to the length when unshifting to the array", function () { var target = new Alpha(), source = new Omega(); @@ -858,7 +858,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(6); }); - it("should propagate a change to the length when splicing to add to the array", function() { + it("should propagate a change to the length when splicing to add to the array", function () { var target = new Alpha(), source = new Omega(); @@ -876,7 +876,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(4); }); - it("should propagate a change to the length when splicing to remove from the array", function() { + it("should propagate a change to the length when splicing to remove from the array", function () { var target = new Alpha(), source = new Omega(); @@ -896,11 +896,11 @@ describe("bindings/spec", function() { }); - describe("using the 'some' function as part of the property path", function() { + describe("using the 'some' function as part of the property path", function () { - describe("with no propertyPath provided to the 'some' function", function() { + describe("with no propertyPath provided to the 'some' function", function () { - it("should propagate a change from false to true", function() { + it("should propagate a change from false to true", function () { var target = new Alpha(), source = new Omega(); @@ -915,7 +915,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(true); }); - it("should propagate a change from true to false", function() { + it("should propagate a change from true to false", function () { var target = new Alpha(), source = new Omega(); @@ -930,7 +930,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(false); }); - it("should propagate the addition of a true value to an otherwise false array", function() { + it("should propagate the addition of a true value to an otherwise false array", function () { var target = new Alpha(), source = new Omega(); @@ -945,7 +945,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(true); }); - it("should propagate the removal of a true value from an otherwise false array", function() { + it("should propagate the removal of a true value from an otherwise false array", function () { var target = new Alpha(), source = new Omega(); @@ -962,9 +962,9 @@ describe("bindings/spec", function() { }); - describe("with a propertyPath provided to the 'some' function", function() { + describe("with a propertyPath provided to the 'some' function", function () { - it("should propagate a change from false to true when a false object is pushed to a path after establishing the binding, and then changed to true", function() { + it("should propagate a change from false to true when a false object is pushed to a path after establishing the binding, and then changed to true", function () { var target = new Alpha(), source = new Omega(); @@ -981,7 +981,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(true); }); - it("should propagate a change from false to true", function() { + it("should propagate a change from false to true", function () { var target = new Alpha(), source = new Omega(); @@ -996,7 +996,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(true); }); - it("should propagate a change from true to false", function() { + it("should propagate a change from true to false", function () { var target = new Alpha(), source = new Omega(); @@ -1011,7 +1011,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(false); }); - it("should propagate the addition of a true value to an otherwise false array", function() { + it("should propagate the addition of a true value to an otherwise false array", function () { var target = new Alpha(), source = new Omega(); @@ -1026,7 +1026,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(true); }); - it("should propagate the removal of a true value from an otherwise false array", function() { + it("should propagate the removal of a true value from an otherwise false array", function () { var target = new Alpha(), source = new Omega(); @@ -1041,7 +1041,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(false); }); - it("should propagate a change from false to true when the array is initially null.", function() { + it("should propagate a change from false to true when the array is initially null.", function () { var target = new Alpha(), source = new Omega(); @@ -1062,8 +1062,8 @@ describe("bindings/spec", function() { }); }); - describe("bindings deletion", function() { - it("should remove a binding on an single level property path", function() { + describe("bindings deletion", function () { + it("should remove a binding on an single level property path", function () { var target = new Alpha(), source = new Omega(); @@ -1080,7 +1080,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(1); }); - it("should remove a binding on an multiple level property path", function() { + it("should remove a binding on an multiple level property path", function () { var target = new Alpha(), source = new Omega(); @@ -1097,7 +1097,7 @@ describe("bindings/spec", function() { expect(target.foo).toBe(1); }); - it("should remove a binding on an property path that includes an array index", function() { + it("should remove a binding on an property path that includes an array index", function () { var target = new Alpha(), source = new Omega(); @@ -1115,8 +1115,8 @@ describe("bindings/spec", function() { }); }); - describe("serialization", function() { - it("should call \"bindings\" deserialization unit", function() { + describe("serialization", function () { + it("should call \"bindings\" deserialization unit", function () { var Alpha = Montage.specialize( {foo: {value: null}}), Omega = Montage.specialize( {bar: {value: null}}), target = new Alpha(), @@ -1138,13 +1138,13 @@ describe("bindings/spec", function() { spyOn(MontageReviver._unitRevivers, "bindings").andCallThrough(); return deserializer.deserialize(labels) - .then(function(objects) { + .then(function (objects) { object = objects.root; expect(MontageReviver._unitRevivers.bindings).toHaveBeenCalled(); }); }); - it("should serialize a binding to a shorthand format", function() { + it("should serialize a binding to a shorthand format", function () { var Alpha = Montage.specialize( {foo: {value: null}}), Omega = Montage.specialize( {bar: {value: null}}), target = new Alpha(), @@ -1176,7 +1176,7 @@ describe("bindings/spec", function() { expect(JSON.parse(serialization)).toEqual(expectedSerialization); }); - it("should deserialize a one way binding", function() { + it("should deserialize a one way binding", function () { var deserializer = new Deserializer(), serialization = { "root": { @@ -1203,7 +1203,7 @@ describe("bindings/spec", function() { deserializer.init( serializationString, require); return deserializer.deserialize() - .then(function(objects) { + .then(function (objects) { var root = objects.root, source = objects.source; @@ -1214,7 +1214,7 @@ describe("bindings/spec", function() { }); }); - it("should deserialize a twoway binding", function() { + it("should deserialize a twoway binding", function () { var deserializer = new Deserializer(), serialization = { "root": { @@ -1241,7 +1241,7 @@ describe("bindings/spec", function() { deserializer.init( serializationString, require); return deserializer.deserialize() - .then(function(objects) { + .then(function (objects) { var root = objects.root, source = objects.source; diff --git a/test/bitfield-spec.js b/test/bitfield-spec.js index 876160b590..920066b23c 100644 --- a/test/bitfield-spec.js +++ b/test/bitfield-spec.js @@ -32,20 +32,20 @@ var Montage = require("montage").Montage, BitField = require("montage/core/bitfield").BitField; describe("bitfield-spec", -function() { +function () { describe("creating empty bitfield", - function() { + function () { var bitField = new BitField(); it("should be true", - function() { + function () { expect(bitField.value).toBeTruthy(); }); }); describe("creation with four false fields", - function() { + function () { var bitField; - beforeEach(function() { + beforeEach(function () { bitField = new BitField().initWithDescriptor({ A: { value: false @@ -63,43 +63,43 @@ function() { }); it("should have the expected field count", - function() { + function () { expect(bitField._fieldCount).toEqual(4); }); describe("set one of its fields to true", - function() { - beforeEach(function() { + function () { + beforeEach(function () { bitField.B = true; }); - afterEach(function() { + afterEach(function () { bitField.B = false; }); it("should be false", - function() { + function () { expect(bitField.value).toBeFalsy(); }); }); describe("set all of its fields to true", - function() { - beforeEach(function() { + function () { + beforeEach(function () { bitField.A = true; bitField.B = true; bitField.C = true; bitField.D = true; }); it("should be true", - function() { + function () { expect(bitField.value).toBeTruthy(); }); describe("add a false field", - function() { - beforeEach(function() { + function () { + beforeEach(function () { bitField.addField("E"); }); it("should be false", - function() { + function () { expect(bitField.value).toBeFalsy(); }); }); diff --git a/test/claimed-pointer-spec.js b/test/claimed-pointer-spec.js index 822ecb51cd..0bb59a4f89 100644 --- a/test/claimed-pointer-spec.js +++ b/test/claimed-pointer-spec.js @@ -32,18 +32,18 @@ var Montage = require("montage").Montage; var Component = require("montage/ui/component").Component; var TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; -TestPageLoader.queueTest("claimed-pointer-test/claimed-pointer-test", function(testPage) { +TestPageLoader.queueTest("claimed-pointer-test/claimed-pointer-test", function (testPage) { var test; - beforeEach(function() { + beforeEach(function () { test = testPage.test; }); - describe("claimed-pointer-spec", function() { + describe("claimed-pointer-spec", function () { var componentA, componentB, eventManager; - beforeEach(function() { + beforeEach(function () { var testWindow = testPage.iframe.contentWindow; eventManager = testWindow.mr("montage/core/application").application.eventManager; eventManager.reset(); @@ -52,9 +52,9 @@ TestPageLoader.queueTest("claimed-pointer-test/claimed-pointer-test", function(t componentB = testPage.test.componentB; }); - describe("an unclaimed pointer identifier", function() { + describe("an unclaimed pointer identifier", function () { - it("should be successfully claimed by a component", function() { + it("should be successfully claimed by a component", function () { eventManager.claimPointer("touch1", componentA); expect(eventManager._claimedPointers["touch1"]).toBe(componentA); @@ -62,20 +62,20 @@ TestPageLoader.queueTest("claimed-pointer-test/claimed-pointer-test", function(t }); - describe("a claimed pointer identifier", function() { + describe("a claimed pointer identifier", function () { - beforeEach(function() { + beforeEach(function () { eventManager.claimPointer("touch1", componentA); }); - it("should be successfully forfeited by the owner component", function() { + it("should be successfully forfeited by the owner component", function () { eventManager.forfeitPointer("touch1", componentA); expect(eventManager._claimedPointers["touch1"]).toBeUndefined(); }); - it("must not be forfeited from a component it is not claimed by", function() { - expect(function() { + it("must not be forfeited from a component it is not claimed by", function () { + expect(function () { eventManager.forfeitPointer("touch1", componentB); }).toThrow("Not allowed to forfeit pointer 'touch1' claimed by another component"); diff --git a/test/composer/composer-spec.js b/test/composer/composer-spec.js index d03dd34ee3..001643adc0 100644 --- a/test/composer/composer-spec.js +++ b/test/composer/composer-spec.js @@ -2,46 +2,46 @@ var Montage = require("montage").Montage; var TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; var EventInfo = require("montage-testing/testpageloader").EventInfo; -TestPageLoader.queueTest("composer-serialization", {src: "composer/composer-serialization-test-page.html", firstDraw: false}, function(testPage) { +TestPageLoader.queueTest("composer-serialization", {src: "composer/composer-serialization-test-page.html", firstDraw: false}, function (testPage) { var test; - beforeEach(function() { + beforeEach(function () { test = testPage.test; }); - describe("composer/composer-spec", function() { - describe("serialized composer", function() { - it("should have its load method called", function() { + describe("composer/composer-spec", function () { + describe("serialized composer", function () { + it("should have its load method called", function () { expect(testPage.test.simpleTestComposer._loadWasCalled).toBeTruthy(); }); - it("should have its frame method called after setting needsFrame", function() { + it("should have its frame method called after setting needsFrame", function () { testPage.test.simpleTestComposer.needsFrame = true; spyOn(testPage.test.simpleTestComposer, "frame").andCallThrough(); testPage.waitForDraw(); - runs(function(){ + runs(function (){ expect(testPage.test.simpleTestComposer.frame).toHaveBeenCalled(); }); }); -// it("should have its unload method called", function() { +// it("should have its unload method called", function () { // // }); }); }); }); -TestPageLoader.queueTest("composer-serialization-lazyload", {src: "composer/composer-serialization-lazyload-test.html", firstDraw: false}, function(testPage) { +TestPageLoader.queueTest("composer-serialization-lazyload", {src: "composer/composer-serialization-lazyload-test.html", firstDraw: false}, function (testPage) { var test; - beforeEach(function() { + beforeEach(function () { test = testPage.test; }); - describe("composer/composer-spec", function() { - describe("lazy load serialized composer", function() { - it("load method should not have been called", function() { + describe("composer/composer-spec", function () { + describe("lazy load serialized composer", function () { + it("load method should not have been called", function () { expect(test.simpleTestComposer._loadWasCalled).toBeFalsy(); }); - it("load method should be called as the result of an activation event", function() { - testPage.mouseEvent(new EventInfo().initWithElementAndPosition(test.dynamicText, 0, 0), "mousedown", function() { + it("load method should be called as the result of an activation event", function () { + testPage.mouseEvent(new EventInfo().initWithElementAndPosition(test.dynamicText, 0, 0), "mousedown", function () { expect(test.simpleTestComposer._loadWasCalled).toBeTruthy(); }); }); @@ -49,46 +49,46 @@ TestPageLoader.queueTest("composer-serialization-lazyload", {src: "composer/comp }); }); -TestPageLoader.queueTest("composer-programmatic", {src: "composer/composer-test-page.html", firstDraw: false}, function(testPage) { +TestPageLoader.queueTest("composer-programmatic", {src: "composer/composer-test-page.html", firstDraw: false}, function (testPage) { var test; - beforeEach(function() { + beforeEach(function () { test = testPage.test; }); - describe("composer/composer-spec", function() { - describe("programmatically added composer", function() { - it("should have its load method called", function() { + describe("composer/composer-spec", function () { + describe("programmatically added composer", function () { + it("should have its load method called", function () { expect(test.simpleTestComposer._loadWasCalled).toBeTruthy(); }); - it("should have its frame method called after setting needsFrame", function() { + it("should have its frame method called after setting needsFrame", function () { test.simpleTestComposer.needsFrame = true; spyOn(test.simpleTestComposer, "frame").andCallThrough(); testPage.waitForDraw(); - runs(function(){ + runs(function (){ expect(test.simpleTestComposer.frame).toHaveBeenCalled(); }); }); -// it("should have its unload method called", function() { +// it("should have its unload method called", function () { // // }); }); }); }); -TestPageLoader.queueTest("composer-programmatic-lazyload", {src: "composer/composer-programmatic-lazyload.html", firstDraw: false}, function(testPage) { +TestPageLoader.queueTest("composer-programmatic-lazyload", {src: "composer/composer-programmatic-lazyload.html", firstDraw: false}, function (testPage) { var test; - beforeEach(function() { + beforeEach(function () { test = testPage.test; }); - describe("composer/composer-spec", function() { - describe("lazy load serialized composer", function() { - it("load method should not have been called", function() { + describe("composer/composer-spec", function () { + describe("lazy load serialized composer", function () { + it("load method should not have been called", function () { expect(test.simpleTestComposer._loadWasCalled).toBeFalsy(); }); - it("load method should be called as the result of an activation event", function() { - testPage.mouseEvent(new EventInfo().initWithElementAndPosition(test.dynamicTextC.element, 0, 0), "mousedown", function() { + it("load method should be called as the result of an activation event", function () { + testPage.mouseEvent(new EventInfo().initWithElementAndPosition(test.dynamicTextC.element, 0, 0), "mousedown", function () { expect(test.simpleTestComposer._loadWasCalled).toBeTruthy(); }); }); @@ -96,20 +96,20 @@ TestPageLoader.queueTest("composer-programmatic-lazyload", {src: "composer/compo }); }); -TestPageLoader.queueTest("swipe-composer", {src:"composer/swipe/swipe.html", firstDraw: false}, function(testPage) { +TestPageLoader.queueTest("swipe-composer", {src:"composer/swipe/swipe.html", firstDraw: false}, function (testPage) { var test; - beforeEach(function() { + beforeEach(function () { test = testPage.test; }); - describe("composer-spec", function() { - describe("swipe right",function() { - it("shouldn't emit swipe event or swipemove event if no move", function() { + describe("composer-spec", function () { + describe("swipe right",function () { + it("shouldn't emit swipe event or swipemove event if no move", function () { //simulate touch events spyOn(test, 'handleSwipe').andCallThrough(); spyOn(test, 'handleSwipemove').andCallThrough(); - testPage.touchEvent(new EventInfo().initWithElementAndPosition(null, -100, 100), "touchstart", function() { - testPage.touchEvent(new EventInfo().initWithElementAndPosition(null, -100, 100), "touchmove", function() { - testPage.touchEvent(new EventInfo().initWithElementAndPosition(null, -100, 100), "touchend", function() { + testPage.touchEvent(new EventInfo().initWithElementAndPosition(null, -100, 100), "touchstart", function () { + testPage.touchEvent(new EventInfo().initWithElementAndPosition(null, -100, 100), "touchmove", function () { + testPage.touchEvent(new EventInfo().initWithElementAndPosition(null, -100, 100), "touchend", function () { expect(test.handleSwipemove).not.toHaveBeenCalled(); expect(test.handleSwipe).not.toHaveBeenCalled(); }); @@ -118,14 +118,14 @@ TestPageLoader.queueTest("swipe-composer", {src:"composer/swipe/swipe.html", fir }); }); - it("should emit swipe event and swipemove event", function() { + it("should emit swipe event and swipemove event", function () { //simulate touch events spyOn(test, 'handleSwipe').andCallThrough(); spyOn(test, 'handleSwipemove').andCallThrough(); - testPage.touchEvent(new EventInfo().initWithElementAndPosition(null, 0, 0), "touchstart", function() { - testPage.touchEvent(new EventInfo().initWithElementAndPosition(null, 0, 50), "touchmove", function() { - testPage.touchEvent(new EventInfo().initWithElementAndPosition(null, 0, 100), "touchmove", function() { - testPage.touchEvent(new EventInfo().initWithElementAndPosition(null, 50, 50), "touchend", function() { + testPage.touchEvent(new EventInfo().initWithElementAndPosition(null, 0, 0), "touchstart", function () { + testPage.touchEvent(new EventInfo().initWithElementAndPosition(null, 0, 50), "touchmove", function () { + testPage.touchEvent(new EventInfo().initWithElementAndPosition(null, 0, 100), "touchmove", function () { + testPage.touchEvent(new EventInfo().initWithElementAndPosition(null, 50, 50), "touchend", function () { expect(test.handleSwipemove).toHaveBeenCalled(); expect(test.handleSwipe).toHaveBeenCalled(); }); diff --git a/test/composer/key-composer-spec.js b/test/composer/key-composer-spec.js index 77672f4f17..5ec4d712c0 100644 --- a/test/composer/key-composer-spec.js +++ b/test/composer/key-composer-spec.js @@ -3,12 +3,12 @@ var Montage = require("montage").Montage; var TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; var KeyComposer = require("montage/composer/key-composer").KeyComposer; -TestPageLoader.queueTest("key-composer-test/key-composer-test", function(testPage) { +TestPageLoader.queueTest("key-composer-test/key-composer-test", function (testPage) { var test, userAgent = navigator.userAgent, command; - beforeEach(function() { + beforeEach(function () { test = testPage.test; }); @@ -21,9 +21,9 @@ TestPageLoader.queueTest("key-composer-test/key-composer-test", function(testPag command = "control" } - describe("composer/key-composer-spec", function() { - describe("KeyComposer", function(){ - it("should fire keyPress, longKeyPress and keyRelease when pressing, holding and releasing a composerKey", function() { + describe("composer/key-composer-spec", function () { + describe("KeyComposer", function (){ + it("should fire keyPress, longKeyPress and keyRelease when pressing, holding and releasing a composerKey", function () { var target = test.example.element, listener1 = testPage.addListener(test.key_composer1, null, "keyPress"), listener2 = testPage.addListener(test.key_composer1, null, "longKeyPress"), @@ -31,7 +31,7 @@ TestPageLoader.queueTest("key-composer-test/key-composer-test", function(testPag testPage.keyEvent({target: target, modifiers: command, charCode: 0, keyCode: "J".charCodeAt(0)}, "keydown"); waits(1050); - runs(function(){ + runs(function (){ testPage.keyEvent({target: target, modifiers: command, charCode: 0, keyCode: "J".charCodeAt(0)}, "keyup"); expect(listener1).toHaveBeenCalled(); expect(listener2).toHaveBeenCalled(); @@ -39,24 +39,24 @@ TestPageLoader.queueTest("key-composer-test/key-composer-test", function(testPag }); }); - it("should not fire keyComposer's event when pressing a composerKey which is not in the target path", function() { + it("should not fire keyComposer's event when pressing a composerKey which is not in the target path", function () { var target = test.example.element.parentNode, keyPressCalled = false, keyReleaseCalled = false; - test.key_composer1.addEventListener("keyPress", function(){keyPressCalled = true}); - test.key_composer1.addEventListener("keyRelease", function(){keyReleaseCalled = true}); + test.key_composer1.addEventListener("keyPress", function (){keyPressCalled = true}); + test.key_composer1.addEventListener("keyRelease", function (){keyReleaseCalled = true}); testPage.keyEvent({target: target, modifiers: command, charCode: 0, keyCode: "J".charCodeAt(0)}, "keydown"); waits(50); - runs(function(){ + runs(function (){ testPage.keyEvent({target: target, modifiers: command, charCode: 0, keyCode: "J".charCodeAt(0)}, "keyup"); expect(keyPressCalled).toBeFalsy(); expect(keyReleaseCalled).toBeFalsy(); }); }); - it("should fire keyPress and KeyRelease on pressing a global key whatever of the target", function() { + it("should fire keyPress and KeyRelease on pressing a global key whatever of the target", function () { var target = test.example.element.parentNode; test.keyPressCalled = false; @@ -64,14 +64,14 @@ TestPageLoader.queueTest("key-composer-test/key-composer-test", function(testPag testPage.keyEvent({target: target, modifiers: "shift control", charCode: 0, keyCode: "K".charCodeAt(0)}, "keydown"); waits(50); - runs(function(){ + runs(function (){ testPage.keyEvent({target: target, modifiers: "shift control", charCode: 0, keyCode: "K".charCodeAt(0)}, "keyup"); expect(test.keyPressCalled).toBeTruthy(); expect(test.keyReleaseCalled).toBeTruthy(); }); }); - it("should not fire keyPress and KeyRelease on pressing shift+k+control (modifier pressed after the main key)", function() { + it("should not fire keyPress and KeyRelease on pressing shift+k+control (modifier pressed after the main key)", function () { var target = test.example.element.parentNode; test.keyPressCalled = false; @@ -79,15 +79,15 @@ TestPageLoader.queueTest("key-composer-test/key-composer-test", function(testPag testPage.keyEvent({target: target, modifiers: "shift", charCode: 0, keyCode: "K".charCodeAt(0)}, "keydown"); waits(50); - runs(function(){ + runs(function (){ testPage.keyEvent({target: target, modifiers: "shift control", charCode: 0, keyCode: "K".charCodeAt(0)}, "keyup"); expect(test.keyPressCalled).toBeFalsy(); expect(test.keyReleaseCalled).toBeFalsy(); }); }); - describe("interacting with activeTarget", function() { - it("should fire window key events on composers of the activeTarget", function() { + describe("interacting with activeTarget", function () { + it("should fire window key events on composers of the activeTarget", function () { var target = test.example.element, listener1 = testPage.addListener(test.key_composer1, null, "keyPress"), listener2 = testPage.addListener(test.key_composer1, null, "longKeyPress"), @@ -97,7 +97,7 @@ TestPageLoader.queueTest("key-composer-test/key-composer-test", function(testPag testPage.keyEvent({target: testPage.window, modifiers: command, charCode: 0, keyCode: "J".charCodeAt(0)}, "keydown"); waits(1050); - runs(function(){ + runs(function (){ testPage.keyEvent({target: testPage.window, modifiers: command, charCode: 0, keyCode: "J".charCodeAt(0)}, "keyup"); expect(listener1).toHaveBeenCalled(); expect(listener2).toHaveBeenCalled(); diff --git a/test/composer/key-composer-test/key-composer-test.js b/test/composer/key-composer-test/key-composer-test.js index 156d78d55b..79916c3329 100644 --- a/test/composer/key-composer-test/key-composer-test.js +++ b/test/composer/key-composer-test/key-composer-test.js @@ -41,13 +41,13 @@ var KeyComposerTest = exports.KeyComposerTest = Montage.specialize( { }, handleKKeyPress: { - value: function(event) { + value: function (event) { this.keyPressCalled = true; } }, handleKKeyRelease: { - value: function(event) { + value: function (event) { this.keyReleaseCalled = true; } } diff --git a/test/composer/press-composer-spec.js b/test/composer/press-composer-spec.js index adc0141e49..95a2b8a6d5 100644 --- a/test/composer/press-composer-spec.js +++ b/test/composer/press-composer-spec.js @@ -2,15 +2,15 @@ var Montage = require("montage").Montage, TestPageLoader = require("montage-testing/testpageloader").TestPageLoader, PressComposer = require("montage/composer/press-composer").PressComposer; -TestPageLoader.queueTest("press-composer-test/press-composer-test", function(testPage) { +TestPageLoader.queueTest("press-composer-test/press-composer-test", function (testPage) { var test; - beforeEach(function() { + beforeEach(function () { test = testPage.test; }); - describe("composer/press-composer-spec", function() { - describe("PressComposer", function(){ - it("should fire pressStart on mousedown/touchstart", function() { + describe("composer/press-composer-spec", function () { + describe("PressComposer", function (){ + it("should fire pressStart on mousedown/touchstart", function () { var listener = testPage.addListener(test.press_composer, null, "pressStart"); if (window.Touch) { @@ -23,7 +23,7 @@ TestPageLoader.queueTest("press-composer-test/press-composer-test", function(tes expect(test.press_composer.state).toBe(PressComposer.PRESSED); }); - it("should fire press on mouseup/touchend", function() { + it("should fire press on mouseup/touchend", function () { var pressListener = testPage.addListener(test.press_composer, null, "press"); var cancelListener = testPage.addListener(test.press_composer, null, "pressCancel"); @@ -41,7 +41,7 @@ TestPageLoader.queueTest("press-composer-test/press-composer-test", function(tes // touchend's target is always the same as touch start, so this // test doesn't apply if (!window.Touch) { - it("should fire pressCancel when the mouse is released elsewhere", function() { + it("should fire pressCancel when the mouse is released elsewhere", function () { var pressListener = testPage.addListener(test.press_composer, null, "press"); var cancelListener = testPage.addListener(test.press_composer, null, "pressCancel"); @@ -54,7 +54,7 @@ TestPageLoader.queueTest("press-composer-test/press-composer-test", function(tes }); } - it("should fire pressCancel when surrenderPointer is called", function() { + it("should fire pressCancel when surrenderPointer is called", function () { var pressListener = testPage.addListener(test.press_composer, null, "press"); var cancelListener = testPage.addListener(test.press_composer, null, "pressCancel"); @@ -80,13 +80,13 @@ TestPageLoader.queueTest("press-composer-test/press-composer-test", function(tes }); - describe("delegate", function() { - it("surrenderPointer should be called", function() { + describe("delegate", function () { + it("surrenderPointer should be called", function () { var pressListener = testPage.addListener(test.press_composer, null, "press"); var cancelListener = testPage.addListener(test.press_composer, null, "pressCancel"); test.press_composer.delegate = { - surrenderPointer: function(pointer, component) { + surrenderPointer: function (pointer, component) { return false; } }; @@ -115,8 +115,8 @@ TestPageLoader.queueTest("press-composer-test/press-composer-test", function(tes }); }); - describe("cancelPress", function() { - it("cancels the active press and returns true", function() { + describe("cancelPress", function () { + it("cancels the active press and returns true", function () { var pressListener = testPage.addListener(test.press_composer, null, "press"); var cancelListener = testPage.addListener(test.press_composer, null, "pressCancel"); @@ -133,7 +133,7 @@ TestPageLoader.queueTest("press-composer-test/press-composer-test", function(tes expect(test.press_composer.state).toBe(PressComposer.UNPRESSED); }); - it("returns false if there is no active press", function() { + it("returns false if there is no active press", function () { var cancelListener = testPage.addListener(test.press_composer, null, "pressCancel"); expect(test.press_composer.cancelPress()).toBe(false); @@ -143,8 +143,8 @@ TestPageLoader.queueTest("press-composer-test/press-composer-test", function(tes }); }); - describe("longPress", function() { - it("is fired after longPressThreshold", function() { + describe("longPress", function () { + it("is fired after longPressThreshold", function () { var listener = testPage.addListener(test.press_composer, null, "longPress"); if (window.Touch) { @@ -154,7 +154,7 @@ TestPageLoader.queueTest("press-composer-test/press-composer-test", function(tes } waits(test.press_composer.longPressThreshold); - runs(function() { + runs(function () { expect(listener).toHaveBeenCalled(); if (window.Touch) { @@ -165,7 +165,7 @@ TestPageLoader.queueTest("press-composer-test/press-composer-test", function(tes }); }); - it("isn't fired if the press is released before the timeout", function() { + it("isn't fired if the press is released before the timeout", function () { var longListener = testPage.addListener(test.press_composer, null, "longPress"); if (window.Touch) { @@ -175,7 +175,7 @@ TestPageLoader.queueTest("press-composer-test/press-composer-test", function(tes } waits(test.press_composer.longPressThreshold - 100); - runs(function() { + runs(function () { expect(longListener).not.toHaveBeenCalled(); if (window.Touch) { @@ -186,8 +186,8 @@ TestPageLoader.queueTest("press-composer-test/press-composer-test", function(tes }); }); - describe("longPressThreshold", function() { - it("can be changed", function() { + describe("longPressThreshold", function () { + it("can be changed", function () { var listener = testPage.addListener(test.press_composer, null, "longPress"); var timeout = test.press_composer.longPressThreshold - 500; test.press_composer.longPressThreshold = timeout; @@ -199,7 +199,7 @@ TestPageLoader.queueTest("press-composer-test/press-composer-test", function(tes } waits(timeout); - runs(function() { + runs(function () { expect(listener).toHaveBeenCalled(); if (window.Touch) { testPage.touchEvent({target: test.example.element}, "touchend"); @@ -212,13 +212,13 @@ TestPageLoader.queueTest("press-composer-test/press-composer-test", function(tes }); }); - describe("Nested PressComposers", function() { - beforeEach(function() { + describe("Nested PressComposers", function () { + beforeEach(function () { test.outer_press_composer._endInteraction(); test.inner_press_composer._endInteraction(); }); - it("should fire pressStart for both composers", function() { + it("should fire pressStart for both composers", function () { var inner_listener = testPage.addListener(test.inner_press_composer, null, "pressStart"), outer_listener = testPage.addListener(test.outer_press_composer, null, "pressStart"); @@ -234,7 +234,7 @@ TestPageLoader.queueTest("press-composer-test/press-composer-test", function(tes expect(outer_listener).toHaveBeenCalled(); }); - it("should fire press for inner composer", function() { + it("should fire press for inner composer", function () { var inner_listener = testPage.addListener(test.inner_press_composer, null, "press"), outer_listener = testPage.addListener(test.outer_press_composer, null, "press"); @@ -250,7 +250,7 @@ TestPageLoader.queueTest("press-composer-test/press-composer-test", function(tes expect(outer_listener).not.toHaveBeenCalled(); }); - it("should fire pressCancel for outer composer", function() { + it("should fire pressCancel for outer composer", function () { var inner_listener = testPage.addListener(test.inner_press_composer, null, "pressCancel"), outer_listener = testPage.addListener(test.outer_press_composer, null, "pressCancel"); @@ -274,12 +274,12 @@ TestPageLoader.queueTest("press-composer-test/press-composer-test", function(tes beforeEach(function () { _endInteractionSpy = spyOn(test.outer_press_composer, "_endInteraction") }); - it("should _endInteraction when the mouse is released elsewhere", function() { + it("should _endInteraction when the mouse is released elsewhere", function () { testPage.mouseEvent({target: test.innerComponent.element}, "mousedown"); testPage.mouseEvent({target: testPage.document}, "mouseup"); expect(_endInteractionSpy).toHaveBeenCalled(); }); - it("should _endInteraction when the mouse is released within the element but unclaimed", function() { + it("should _endInteraction when the mouse is released within the element but unclaimed", function () { testPage.mouseEvent({target: test.innerComponent.element}, "mousedown"); testPage.mouseEvent({target: test.inner2Component.element}, "mouseup"); expect(_endInteractionSpy).toHaveBeenCalled(); diff --git a/test/composer/simple-test-composer.js b/test/composer/simple-test-composer.js index bb95da2d26..e053821466 100644 --- a/test/composer/simple-test-composer.js +++ b/test/composer/simple-test-composer.js @@ -8,19 +8,19 @@ exports.SimpleTestComposer = Composer.specialize( { }, load: { - value: function() { + value: function () { this._loadWasCalled = true; } }, unload: { - value: function() { + value: function () { } }, frame: { - value: function(timestamp) { + value: function (timestamp) { } } @@ -38,19 +38,19 @@ exports.LazyLoadTestComposer = Composer.specialize( { }, load: { - value: function() { + value: function () { this._loadWasCalled = true; } }, unload: { - value: function() { + value: function () { } }, frame: { - value: function(timestamp) { + value: function (timestamp) { } } diff --git a/test/composer/swipe/swipe.js b/test/composer/swipe/swipe.js index 743d1d852d..1ff525e1a3 100644 --- a/test/composer/swipe/swipe.js +++ b/test/composer/swipe/swipe.js @@ -5,7 +5,7 @@ var Montage = require("montage").Montage, exports.Swipe = Montage.specialize( { deserializedFromTemplate: { - value: function() { + value: function () { var dummyComponent = new Component(); dummyComponent.hasTemplate = false; dummyComponent.element = document.body; @@ -19,12 +19,12 @@ exports.Swipe = Montage.specialize( { }, handleSwipe: { - value: function(event) { + value: function (event) { } }, handleSwipemove: { - value: function(event) { + value: function (event) { } } diff --git a/test/composer/test.js b/test/composer/test.js index 231537934c..b41d2ed4e4 100644 --- a/test/composer/test.js +++ b/test/composer/test.js @@ -20,7 +20,7 @@ exports.ProgrammaticTest = TestController.specialize( { }, deserializedFromTemplate: { - value: function() { + value: function () { this.simpleTestComposer = new SimpleTestComposer(); this.dynamicTextC.addComposer(this.simpleTestComposer); } @@ -35,7 +35,7 @@ exports.ProgrammaticLazyTest = TestController.specialize( { }, deserializedFromTemplate: { - value: function() { + value: function () { this.simpleTestComposer = new LazyLoadComposer(); this.dynamicTextC.addComposer(this.simpleTestComposer); } diff --git a/test/composer/translate-composer/translate-composer-spec.js b/test/composer/translate-composer/translate-composer-spec.js index 1766dc85f9..6c080ef438 100644 --- a/test/composer/translate-composer/translate-composer-spec.js +++ b/test/composer/translate-composer/translate-composer-spec.js @@ -2,93 +2,93 @@ var Montage = require("montage").Montage; var TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; -TestPageLoader.queueTest("translate-composer-test", function(testPage) { +TestPageLoader.queueTest("translate-composer-test", function (testPage) { var test; - beforeEach(function() { + beforeEach(function () { test = testPage.test; }); - describe("composer/translate-composer-spec", function() { - describe("TranslateComposer", function(){ - it("can be created", function() { + describe("composer/translate-composer-spec", function () { + describe("TranslateComposer", function (){ + it("can be created", function () { expect(test.translateComposer).toBeDefined(); }); - describe("translateX", function() { - it("updates as the mouse moves", function() { - testPage.dragElementOffsetTo(test.example.element, 20, 0, null, null, function() { + describe("translateX", function () { + it("updates as the mouse moves", function () { + testPage.dragElementOffsetTo(test.example.element, 20, 0, null, null, function () { expect(test.translateComposer.translateX).toBeGreaterThan(19); }); }); - it("can be set", function() { + it("can be set", function () { test.translateComposer.translateX = 25; expect(test.x).toBe("25px"); }); }); - describe("translateY", function() { - it("updates as the mouse moves", function() { - testPage.dragElementOffsetTo(test.example.element, 0, 20, null, null, function() { + describe("translateY", function () { + it("updates as the mouse moves", function () { + testPage.dragElementOffsetTo(test.example.element, 0, 20, null, null, function () { expect(test.translateComposer.translateY).toBeGreaterThan(19); }); }); - it("can be set", function() { + it("can be set", function () { test.translateComposer.translateY = 5; expect(test.y).toBe("5px"); }); }); - describe("maxTranslateX", function() { - it("limits translateX", function() { - testPage.dragElementOffsetTo(test.example.element, 500, 0, null, null, function() { - runs(function() { + describe("maxTranslateX", function () { + it("limits translateX", function () { + testPage.dragElementOffsetTo(test.example.element, 500, 0, null, null, function () { + runs(function () { expect(test.translateComposer.translateX).not.toBeGreaterThan(350); }); }); }); }); - describe("maxTranslateY", function() { - it ("limits translateY", function() { - testPage.dragElementOffsetTo(test.example.element, 0, 500, null, null, function() { - runs(function() { + describe("maxTranslateY", function () { + it ("limits translateY", function () { + testPage.dragElementOffsetTo(test.example.element, 0, 500, null, null, function () { + runs(function () { expect(test.translateComposer.translateY).not.toBeGreaterThan(350); }); }); }); }); - describe("minTranslateX", function() { - it ("limits translateX", function() { - testPage.dragElementOffsetTo(test.example.element, -500, 0, null, null, function() { + describe("minTranslateX", function () { + it ("limits translateX", function () { + testPage.dragElementOffsetTo(test.example.element, -500, 0, null, null, function () { expect(test.translateComposer.translateX).not.toBeLessThan(20); }); }); - it("can be set to null and translateX has no minimum", function() { + it("can be set to null and translateX has no minimum", function () { var old = test.translateComposer.minTranslateX; test.translateComposer.minTranslateX = null; test.translateComposer.translateX = 0; - testPage.dragElementOffsetTo(test.example.element, -500, 0, null, null, function() { + testPage.dragElementOffsetTo(test.example.element, -500, 0, null, null, function () { expect(test.translateComposer.translateX).toBeLessThan(-400); test.translateComposer.minTranslateX = old; }); }); }); - describe("minTranslateY", function() { - it("limits translateY", function() { - testPage.dragElementOffsetTo(test.example.element, 0, -500, null, null, function() { + describe("minTranslateY", function () { + it("limits translateY", function () { + testPage.dragElementOffsetTo(test.example.element, 0, -500, null, null, function () { expect(test.translateComposer.translateY).not.toBeLessThan(-40); }); }); }); - describe("allowFloats", function() { - it('only allows translate{X|Y} to be ints when false', function() { + describe("allowFloats", function () { + it('only allows translate{X|Y} to be ints when false', function () { test.translateComposer.translateX = 100.543; test.translateComposer.translateY = -20.4; expect(test.translateComposer.translateX).toBe(100); expect(test.translateComposer.translateY).toBe(-20); }); - it('allows translate{X|Y} to be floats when true', function() { + it('allows translate{X|Y} to be floats when true', function () { test.translateComposer.allowFloats = true; test.translateComposer.translateX = 100.543; test.translateComposer.translateY = -20.4; @@ -98,13 +98,13 @@ TestPageLoader.queueTest("translate-composer-test", function(testPage) { }); }); - describe("invertAxis", function() { - it("causes translation in the opposite direction to pointer movement when true", function() { + describe("invertAxis", function () { + it("causes translation in the opposite direction to pointer movement when true", function () { test.translateComposer.translateX = 0; test.translateComposer.translateY = 0; test.translateComposer.invertAxis = true; - testPage.dragElementOffsetTo(test.example.element, -50, -50, null, null, function() { + testPage.dragElementOffsetTo(test.example.element, -50, -50, null, null, function () { expect(test.translateComposer.translateX).toBeGreaterThan(49); expect(test.translateComposer.translateY).toBeGreaterThan(49); test.translateComposer.invertAxis = false; @@ -112,53 +112,53 @@ TestPageLoader.queueTest("translate-composer-test", function(testPage) { }); }); - describe("axis", function() { + describe("axis", function () { - it("limits movement to horizonal when set to 'horizontal'", function() { + it("limits movement to horizonal when set to 'horizontal'", function () { test.translateComposer.translateX = 0; test.translateComposer.translateY = 0; test.translateComposer.axis = "horizontal"; - testPage.dragElementOffsetTo(test.example.element, 50, 50, null, null, function() { - runs(function() { + testPage.dragElementOffsetTo(test.example.element, 50, 50, null, null, function () { + runs(function () { expect(test.translateComposer.translateX).toBeGreaterThan(49); expect(test.translateComposer.translateY).toBe(-40); }); }); }); - it("limits movement to vertical when set to 'vertical'", function() { + it("limits movement to vertical when set to 'vertical'", function () { test.translateComposer.translateX = 0; test.translateComposer.translateY = 0; test.translateComposer.axis = "vertical"; - testPage.dragElementOffsetTo(test.example.element, 50, 50, null, null, function() { - runs(function() { + testPage.dragElementOffsetTo(test.example.element, 50, 50, null, null, function () { + runs(function () { expect(test.translateComposer.translateX).toBe(20); expect(test.translateComposer.translateY).toBeGreaterThan(9); }); }); }); - it("does not limit movement when set to an unknown value", function() { + it("does not limit movement when set to an unknown value", function () { test.translateComposer.translateX = 0; test.translateComposer.translateY = 0; test.translateComposer.axis = null; - testPage.dragElementOffsetTo(test.example.element, 50, 50, null, null, function() { - runs(function() { + testPage.dragElementOffsetTo(test.example.element, 50, 50, null, null, function () { + runs(function () { expect(test.translateComposer.translateX).toBeGreaterThan(49); expect(test.translateComposer.translateY).toBeGreaterThan(49); }); }); }); }); - describe("pointerSpeedMultiplier", function() { - it ("multiplies the translation values by 3 when set to 3", function() { + describe("pointerSpeedMultiplier", function () { + it ("multiplies the translation values by 3 when set to 3", function () { test.translateComposer.translateX = 0; test.translateComposer.translateY = 0; test.translateComposer.invertAxis = false; test.translateComposer.pointerSpeedMultiplier = 3; - testPage.dragElementOffsetTo(test.example.element, 50, 50, null, null, function() { + testPage.dragElementOffsetTo(test.example.element, 50, 50, null, null, function () { expect(test.translateComposer.translateX).toBeGreaterThan(149); expect(test.translateComposer.translateY).toBeGreaterThan(149); test.translateComposer.pointerSpeedMultiplier = 1; @@ -166,21 +166,21 @@ TestPageLoader.queueTest("translate-composer-test", function(testPage) { }); }); }); - describe("hasMomentum", function() { - it("keeps translating after mouse is released", function() { + describe("hasMomentum", function () { + it("keeps translating after mouse is released", function () { test.translateComposer.hasMomentum = true; test.translateComposer.translateX = 0; test.translateComposer.translateY = 0; - testPage.dragElementOffsetTo(test.example.element, 50, 50, null, null, function() { + testPage.dragElementOffsetTo(test.example.element, 50, 50, null, null, function () { waits(100); - runs(function(){ + runs(function (){ expect(test.translateComposer.translateX).toBeGreaterThan(55); expect(test.translateComposer.translateY).toBeGreaterThan(55); test.translateComposer.hasMomentum = false; }); }); }); - it("dispatches the translate event", function() { + it("dispatches the translate event", function () { test.translateComposer.hasMomentum = true; test.translateComposer.translateX = 0; test.translateComposer.translateY = 0; @@ -188,24 +188,24 @@ TestPageLoader.queueTest("translate-composer-test", function(testPage) { var listener = jasmine.createSpy("handleTranslateEvent"); test.translateComposer.addEventListener("translate", listener); - testPage.dragElementOffsetTo(test.example.element, 50, 50, null, null, function() { + testPage.dragElementOffsetTo(test.example.element, 50, 50, null, null, function () { waits(100); - runs(function(){ + runs(function (){ expect(listener).toHaveBeenCalled(); test.translateComposer.hasMomentum = false; test.translateComposer.removeEventListener("translate", listener); }); }); }); - it("keeps translating after mouse is released when inverted", function() { + it("keeps translating after mouse is released when inverted", function () { test.translateComposer.hasMomentum = true; test.translateComposer.invertAxis = true; test.translateComposer.translateX = 0; test.translateComposer.translateY = 0; - testPage.dragElementOffsetTo(test.example.element, 50, 50, null, null, function() { + testPage.dragElementOffsetTo(test.example.element, 50, 50, null, null, function () { waits(100); - runs(function(){ + runs(function (){ expect(test.translateComposer.translateX).toBeLessThan(45); expect(test.translateComposer.translateY).toBeLessThan(45); test.translateComposer.hasMomentum = false; @@ -214,24 +214,24 @@ TestPageLoader.queueTest("translate-composer-test", function(testPage) { }); }); }); - describe("translate event", function() { - it ("should not dispatch a translate event by default", function() { + describe("translate event", function () { + it ("should not dispatch a translate event by default", function () { spyOn(test, 'handleTranslate').andCallThrough(); - testPage.dragElementOffsetTo(test.example.element, 50, 50, null, null, function() { + testPage.dragElementOffsetTo(test.example.element, 50, 50, null, null, function () { expect(test.handleTranslate).not.toHaveBeenCalled(); }); }); - it ("should dispatch a translate event if an object is listening for it", function() { + it ("should dispatch a translate event if an object is listening for it", function () { spyOn(test, 'handleTranslate').andCallThrough(); test.translateComposer.addEventListener("translate", test.handleTranslate, false); - testPage.dragElementOffsetTo(test.example.element, 50, 50, null, null, function() { + testPage.dragElementOffsetTo(test.example.element, 50, 50, null, null, function () { expect(test.handleTranslate).toHaveBeenCalled(); }); }); }); - describe("nested composer", function() { + describe("nested composer", function () { var inner, outer, outerComposer, innerComposer,outerListener,innerListener; beforeEach(function () { @@ -253,32 +253,32 @@ TestPageLoader.queueTest("translate-composer-test", function(testPage) { outerListener.reset(); outerComposer.removeEventListener("translate", outerListener); }); - it ("should dispatch a translate if outer is interacted with", function() { - testPage.dragElementOffsetTo(outer.element, 50, 50, null, null, function() { + it ("should dispatch a translate if outer is interacted with", function () { + testPage.dragElementOffsetTo(outer.element, 50, 50, null, null, function () { expect(outerListener).toHaveBeenCalled(); }); }); - it ("should dispatch a translate if inner is interacted with", function() { - testPage.dragElementOffsetTo(inner.element, 50, 50, null, null, function() { + it ("should dispatch a translate if inner is interacted with", function () { + testPage.dragElementOffsetTo(inner.element, 50, 50, null, null, function () { expect(innerListener).toHaveBeenCalled(); }); }); - it ("should not dispatch a translate on the outer if inner is interacted with", function() { - testPage.dragElementOffsetTo(inner.element, 50, 50, null, null, function() { + it ("should not dispatch a translate on the outer if inner is interacted with", function () { + testPage.dragElementOffsetTo(inner.element, 50, 50, null, null, function () { expect(outerListener).not.toHaveBeenCalled(); }); }); - it ("should not dispatch a translate on the outer even if the inner is on a different axis", function() { + it ("should not dispatch a translate on the outer even if the inner is on a different axis", function () { innerComposer.axis = "horizontal"; outerComposer.axis = "vertical"; - testPage.dragElementOffsetTo(inner.element, 0, -50, null, null, function() { + testPage.dragElementOffsetTo(inner.element, 0, -50, null, null, function () { expect(outerListener).not.toHaveBeenCalled(); }); }); }); - describe("scrolling", function() { - it ("should translate on a the wheel event used by this browser", function() { + describe("scrolling", function () { + it ("should translate on a the wheel event used by this browser", function () { spyOn(test, 'handleTranslate').andCallThrough(); test.translateComposer.addEventListener("translate", test.handleTranslate, false); @@ -292,7 +292,7 @@ TestPageLoader.queueTest("translate-composer-test", function(testPage) { var eventInfo = {target: test.example.element}; eventInfo[deltaPropertyName] = 6; - testPage.wheelEvent(eventInfo, eventName, function() { + testPage.wheelEvent(eventInfo, eventName, function () { expect(test.handleTranslate.callCount).toBe(1); // test how much we scroll by, learn amounts @@ -303,22 +303,22 @@ TestPageLoader.queueTest("translate-composer-test", function(testPage) { }); }); }); -var touchOptions = TestPageLoader.options("translate-composer-test", {timeoutLength: 10000}, function() {console.log("translate-composer-test touch callback");}); +var touchOptions = TestPageLoader.options("translate-composer-test", {timeoutLength: 10000}, function () {console.log("translate-composer-test touch callback");}); describe("translate-composer-test touch", function () { var testPage = TestPageLoader.testPage; - it("should load", function() { + it("should load", function () { console.group("translate-composer-touch-test"); - var frameLoaded = TestPageLoader.testPage.loadFrame(touchOptions).then(function(theTestPage) { - theTestPage.window.Touch = function() {}; + var frameLoaded = TestPageLoader.testPage.loadFrame(touchOptions).then(function (theTestPage) { + theTestPage.window.Touch = function () {}; }); - return testPage.loadTest(frameLoaded, touchOptions).then(function(theTestPage) { + return testPage.loadTest(frameLoaded, touchOptions).then(function (theTestPage) { expect(theTestPage.loaded).toBe(true); }); }); - describe("nested composer", function() { + describe("nested composer", function () { var test; - beforeEach(function() { + beforeEach(function () { test = testPage.test; }); @@ -346,7 +346,7 @@ describe("translate-composer-test touch", function () { outerListener.reset(); outerComposer.removeEventListener("translate", outerListener); }); - it ("should dispatch a translate on the outer if inner is on a different axis", function() { + it ("should dispatch a translate on the outer if inner is on a different axis", function () { innerComposer.axis = "horizontal"; outerComposer.axis = "vertical"; @@ -372,7 +372,7 @@ describe("translate-composer-test touch", function () { ] }]; - testPage.fireEventsOnTimeline(timeline, function(time) { + testPage.fireEventsOnTimeline(timeline, function (time) { if(time === 4) { expect(outerListener).toHaveBeenCalled(); expect(innerListener).toHaveBeenCalled(); @@ -380,7 +380,7 @@ describe("translate-composer-test touch", function () { }); }); - it ("should claim the pointer to the inner in a container->widget situation with a fast flick", function() { + it ("should claim the pointer to the inner in a container->widget situation with a fast flick", function () { outerComposer.axis = "both"; outerComposer.stealChildrenPointer = true; outerComposer.stealChildrenPointerThreshold = 100; @@ -399,7 +399,7 @@ describe("translate-composer-test touch", function () { ] }]; - testPage.fireEventsOnTimeline(timeline, function(time) { + testPage.fireEventsOnTimeline(timeline, function (time) { if(time === 1) { var claimedByComponent = inner.eventManager.componentClaimingPointer(1); expect(claimedByComponent).toBe(outerComposer); @@ -407,7 +407,7 @@ describe("translate-composer-test touch", function () { }); }); - it ("should claim the pointer to the inner in a container->widget situation with a fast flick but opposite directions", function() { + it ("should claim the pointer to the inner in a container->widget situation with a fast flick but opposite directions", function () { outerComposer.axis = "vertical"; outerComposer.stealChildrenPointer = true; outerComposer.stealChildrenPointerThreshold = 100; @@ -426,7 +426,7 @@ describe("translate-composer-test touch", function () { ] }]; - testPage.fireEventsOnTimeline(timeline, function(time) { + testPage.fireEventsOnTimeline(timeline, function (time) { if(time === 1) { var claimedByComponent = inner.eventManager.componentClaimingPointer(1); expect(claimedByComponent).toBe(innerComposer); @@ -434,7 +434,7 @@ describe("translate-composer-test touch", function () { }); }); - it ("should claim the pointer to the inner in a container->container situation with a fast flick", function() { + it ("should claim the pointer to the inner in a container->container situation with a fast flick", function () { outerComposer.axis = "vertical"; outerComposer.stealChildrenPointer = true; outerComposer.stealChildrenPointerThreshold = 100; @@ -454,7 +454,7 @@ describe("translate-composer-test touch", function () { ] }]; - testPage.fireEventsOnTimeline(timeline, function(time) { + testPage.fireEventsOnTimeline(timeline, function (time) { if(time === 1) { var claimedByComponent = inner.eventManager.componentClaimingPointer(1); expect(claimedByComponent).toBe(innerComposer); @@ -462,7 +462,7 @@ describe("translate-composer-test touch", function () { }); }); - it ("should claim the pointer to the outer in a container->container situation with a slow flick", function() { + it ("should claim the pointer to the outer in a container->container situation with a slow flick", function () { outerComposer.axis = "vertical"; outerComposer.stealChildrenPointer = true; outerComposer.stealChildrenPointerThreshold = 100; @@ -482,7 +482,7 @@ describe("translate-composer-test touch", function () { ] }]; - testPage.fireEventsOnTimeline(timeline, function(time) { + testPage.fireEventsOnTimeline(timeline, function (time) { if(time === 1) { var claimedByComponent = inner.eventManager.componentClaimingPointer(1); expect(claimedByComponent).toBe(innerComposer); @@ -490,7 +490,7 @@ describe("translate-composer-test touch", function () { }); }); - it ("should claim the pointer to the outer in a container->container situation with a fast flick for the inner and outer", function() { + it ("should claim the pointer to the outer in a container->container situation with a fast flick for the inner and outer", function () { outerComposer.axis = "vertical"; outerComposer.stealChildrenPointer = true; outerComposer.stealChildrenPointerThreshold = 50; @@ -510,7 +510,7 @@ describe("translate-composer-test touch", function () { ] }]; - testPage.fireEventsOnTimeline(timeline, function(time) { + testPage.fireEventsOnTimeline(timeline, function (time) { if(time === 1) { var claimedByComponent = inner.eventManager.componentClaimingPointer(1); expect(claimedByComponent).toBe(outerComposer); @@ -518,7 +518,7 @@ describe("translate-composer-test touch", function () { }); }); - it ("should claim the pointer to the inner in a container->container situation with a slow flick for the outer and fast for the inner", function() { + it ("should claim the pointer to the inner in a container->container situation with a slow flick for the outer and fast for the inner", function () { outerComposer.axis = "vertical"; outerComposer.stealChildrenPointer = true; outerComposer.stealChildrenPointerThreshold = 50; @@ -538,7 +538,7 @@ describe("translate-composer-test touch", function () { ] }]; - testPage.fireEventsOnTimeline(timeline, function(time) { + testPage.fireEventsOnTimeline(timeline, function (time) { if(time === 1) { var claimedByComponent = inner.eventManager.componentClaimingPointer(1); expect(claimedByComponent).toBe(innerComposer); @@ -546,7 +546,7 @@ describe("translate-composer-test touch", function () { }); }); - it ("should claim the pointer in a widget situation with a slow flick", function() { + it ("should claim the pointer in a widget situation with a slow flick", function () { translateComposer.axis = "vertical"; translateComposer.stealChildrenPointer = false; @@ -562,7 +562,7 @@ describe("translate-composer-test touch", function () { ] }]; - testPage.fireEventsOnTimeline(timeline, function(time) { + testPage.fireEventsOnTimeline(timeline, function (time) { if(time === 1) { var claimedByComponent = inner.eventManager.componentClaimingPointer(1); expect(claimedByComponent).toBe(translateComposer); @@ -570,7 +570,7 @@ describe("translate-composer-test touch", function () { }); }); - it ("should claim the pointer in a widget situation with a fast flick", function() { + it ("should claim the pointer in a widget situation with a fast flick", function () { translateComposer.axis = "vertical"; translateComposer.stealChildrenPointer = false; @@ -586,7 +586,7 @@ describe("translate-composer-test touch", function () { ] }]; - testPage.fireEventsOnTimeline(timeline, function(time) { + testPage.fireEventsOnTimeline(timeline, function (time) { if(time === 1) { var claimedByComponent = inner.eventManager.componentClaimingPointer(1); expect(claimedByComponent).toBe(translateComposer); @@ -594,7 +594,7 @@ describe("translate-composer-test touch", function () { }); }); - it ("should claim the pointer in a container situation with a slow flick", function() { + it ("should claim the pointer in a container situation with a slow flick", function () { translateComposer.axis = "vertical"; translateComposer.stealChildrenPointer = true; translateComposer.stealChildrenPointerThreshold = 100; @@ -611,7 +611,7 @@ describe("translate-composer-test touch", function () { ] }]; - testPage.fireEventsOnTimeline(timeline, function(time) { + testPage.fireEventsOnTimeline(timeline, function (time) { if(time === 1) { var claimedByComponent = inner.eventManager.componentClaimingPointer(1); expect(claimedByComponent).toBe(translateComposer); @@ -619,7 +619,7 @@ describe("translate-composer-test touch", function () { }); }); - it ("should claim the pointer in a container situation with a fast flick", function() { + it ("should claim the pointer in a container situation with a fast flick", function () { translateComposer.axis = "vertical"; translateComposer.stealChildrenPointer = true; translateComposer.stealChildrenPointerThreshold = 100; @@ -636,7 +636,7 @@ describe("translate-composer-test touch", function () { ] }]; - testPage.fireEventsOnTimeline(timeline, function(time) { + testPage.fireEventsOnTimeline(timeline, function (time) { if(time === 1) { var claimedByComponent = inner.eventManager.componentClaimingPointer(1); expect(claimedByComponent).toBe(translateComposer); @@ -645,7 +645,7 @@ describe("translate-composer-test touch", function () { }); }); - it("should unload", function() { + it("should unload", function () { TestPageLoader.testPage.unloadTest(); console.groupEnd(); }); diff --git a/test/composer/translate-composer/translate-composer-test.js b/test/composer/translate-composer/translate-composer-test.js index b2b550b0c8..f06c84d61a 100644 --- a/test/composer/translate-composer/translate-composer-test.js +++ b/test/composer/translate-composer/translate-composer-test.js @@ -35,70 +35,70 @@ var TranslateComposerTest = exports.TranslateComposerTest = Montage.specialize( // value: null // }, // example: { - // get: function() { + // get: function () { // return this._example; // }, - // set: function(value) { + // set: function (value) { // this._example = value; // } // }, x: { - get: function() { + get: function () { return this.example.element.style.left; }, - set: function(value) { + set: function (value) { this.example.element.style.left = value + "px"; } }, y: { - get: function() { + get: function () { return this.example.element.style.top; }, - set: function(value) { + set: function (value) { this.example.element.style.top = value + "px"; } }, inner_x: { - get: function() { + get: function () { return this.innermover.element.style.left; }, - set: function(value) { + set: function (value) { this.innermover.element.style.left = value + "px"; } }, inner_y: { - get: function() { + get: function () { return this.innermover.element.style.top; }, - set: function(value) { + set: function (value) { this.innermover.element.style.top = value + "px"; } }, outer_x: { - get: function() { + get: function () { return this.outermover.element.style.left; }, - set: function(value) { + set: function (value) { this.outermover.element.style.left = value + "px"; } }, outer_y: { - get: function() { + get: function () { return this.outermover.element.style.top; }, - set: function(value) { + set: function (value) { this.outermover.element.style.top = value + "px"; } }, handleTranslate: { - value: function(event) { + value: function (event) { } } }); diff --git a/test/converter-spec.js b/test/converter-spec.js index f26f0f2781..2d2d69072c 100644 --- a/test/converter-spec.js +++ b/test/converter-spec.js @@ -38,13 +38,13 @@ BytesConverter = require("montage/core/converter/bytes-converter").BytesConverte DateConverter = require("montage/core/converter/date-converter").DateConverter, CurrencyConverter = require("montage/core/converter/currency-converter").CurrencyConverter; -describe("converter-spec", function() { +describe("converter-spec", function () { var numberConverter, stringConverter, dateConverter, currencyConverter, bytesConverter; var dateConverter; var date = new Date('25 Aug 2011 12:00:00 PM'); - beforeEach(function() { + beforeEach(function () { //stringConverter = new StringConverter(); ucaseConverter = new UpperCaseConverter(); lcaseConverter = new LowerCaseConverter(); @@ -61,22 +61,22 @@ describe("converter-spec", function() { //dateConverter.pattern = 'YYYY-MM-DD'; }); - describe("test string formatters", function() { - it("should format a string to uppercase", function() { + describe("test string formatters", function () { + it("should format a string to uppercase", function () { var value = "hello world"; //stringConverter.fn = "uppercase"; var result = ucaseConverter.convert(value); expect(result).toBe('HELLO WORLD'); }); - it("should format a string to lowercase", function() { + it("should format a string to lowercase", function () { var value = "HELLO World"; //stringConverter.fn = "lowercase"; var result = lcaseConverter.convert(value); expect(result).toBe('hello world'); }); - it("should format a string by trimming it", function() { + it("should format a string by trimming it", function () { var value = " hello world "; //stringConverter.fn = "trim"; var result = trimConverter.convert(value); @@ -84,7 +84,7 @@ describe("converter-spec", function() { }); /* - it("should format a string by converting newline characters to
", function() { + it("should format a string by converting newline characters to
", function () { var value = " hello \r\n world "; stringConverter.fn = "trim"; var result = stringConverter.convert(value); @@ -94,28 +94,28 @@ describe("converter-spec", function() { }); - describe("Test Number to String formatters", function() { - it("should format a number to human readable format 100s", function() { + describe("Test Number to String formatters", function () { + it("should format a number to human readable format 100s", function () { var value = 100.0102; var result = numberConverter.convert(value); expect(result).toBe('100.01'); }); - it("should format a number to human readable format 1K", function() { + it("should format a number to human readable format 1K", function () { var value = 1001.920304; numberConverter.decimals = 3; var result = numberConverter.convert(value); expect(result).toBe('1.002K'); }); - it("should format a number to human readable format 1M", function() { + it("should format a number to human readable format 1M", function () { var value = 1509000.920304; numberConverter.decimals = 2; var result = numberConverter.convert(value); expect(result).toBe('1.51M'); }); - it("should format a number to 3 decimal places", function() { + it("should format a number to 3 decimal places", function () { var value = 1509000.929304; numberConverter.decimals = 3; numberConverter.shorten = false; @@ -123,7 +123,7 @@ describe("converter-spec", function() { expect(result).toBe('1,509,000.929'); }); - it("should, by default, not include trailing 0s after the decimal", function() { + it("should, by default, not include trailing 0s after the decimal", function () { var value = 12.2 numberConverter.decimals = 2; numberConverter.shorten = false; @@ -131,7 +131,7 @@ describe("converter-spec", function() { expect(result).toBe('12.2'); }); - it("should add trailing 0s in decimal places when forceDecimals is on", function() { + it("should add trailing 0s in decimal places when forceDecimals is on", function () { var value = 12.2 numberConverter.decimals = 2; numberConverter.shorten = false; @@ -142,18 +142,18 @@ describe("converter-spec", function() { }); - describe("Test formatting of file sizes and numbers representing bytes", function() { - it("should format a number to friendly byte size", function() { + describe("Test formatting of file sizes and numbers representing bytes", function () { + it("should format a number to friendly byte size", function () { var value = 100200300; var result = bytesConverter.convert(value); expect(result).toBe('95.56MB'); }); - it("should format a number to friendly byte size", function() { + it("should format a number to friendly byte size", function () { var value = 1024; var result = bytesConverter.convert(value); expect(result).toBe('1KB'); }); - it("should format a number to friendly byte size", function() { + it("should format a number to friendly byte size", function () { var value = 2048000000; bytesConverter.decimals = 4; var result = bytesConverter.convert(value); @@ -162,33 +162,33 @@ describe("converter-spec", function() { }); - describe("Test Date/time formatters", function() { - it("should format a date to the default mm/dd/yyyy format", function() { + describe("Test Date/time formatters", function () { + it("should format a date to the default mm/dd/yyyy format", function () { var value = date; // use default pattern which is mm/dd/yy or use the %D pattern var result = dateConverter.convert(value); expect(result).toBe('08/25/2011'); }); - it("should format a date to mm/dd/yyyy format", function() { + it("should format a date to mm/dd/yyyy format", function () { var value = date; dateConverter.pattern = 'MM/dd/yyyy'; var result = dateConverter.convert(value); expect(result).toBe('08/25/2011'); }); - it("should format a date to dd-mm-yyyy format", function() { + it("should format a date to dd-mm-yyyy format", function () { var value = date; dateConverter.pattern = 'dd-MM-yyyy'; var result = dateConverter.convert(value); expect(result).toBe('25-08-2011'); }); - it("should format a date to dd MM yyyy format", function() { + it("should format a date to dd MM yyyy format", function () { var value = date; dateConverter.pattern = 'dd-MM-yyyy'; var result = dateConverter.convert(value); expect(result).toBe('25-08-2011'); }); - it("should format a date to dd MM YYYY format", function() { + it("should format a date to dd MM YYYY format", function () { var value = date; dateConverter.pattern = 'dd MMM yyyy'; var result = dateConverter.convert(value); @@ -196,14 +196,14 @@ describe("converter-spec", function() { }); - it("should format a date to Date:dd Month:MM Year:YYYY format", function() { + it("should format a date to Date:dd Month:MM Year:YYYY format", function () { var value = date; dateConverter.pattern = 'dd of MMMM yyyy'; //'%d %b %Y %k:%M %p'; var result = dateConverter.convert(value); expect(result).toBe('25 of August 2011'); }); - it("should format a date to ISO 8601 format", function() { + it("should format a date to ISO 8601 format", function () { var value = date; dateConverter.pattern = 'c'; var result = dateConverter.convert(value); @@ -213,25 +213,25 @@ describe("converter-spec", function() { }); - describe("Test formatting numbers to Currency", function() { - it("should format a String representing a number to $ {value}", function() { + describe("Test formatting numbers to Currency", function () { + it("should format a String representing a number to $ {value}", function () { var value = "100000"; var result = currencyConverter.convert(value); expect(result).toBe('100K $'); }); - it("should format a number to a USD value", function() { + it("should format a number to a USD value", function () { var value = 100.01002; currencyConverter.currency = 'USD'; var result = currencyConverter.convert(value); expect(result).toBe('100.01 USD'); }); - it("should format a negative number to a US $ value", function() { + it("should format a negative number to a US $ value", function () { var value = -1000000; currencyConverter.currency = 'HK$'; var result = currencyConverter.convert(value); expect(result).toBe('-1M HK$'); }); - it("should format a negative number to currency with parens", function() { + it("should format a negative number to currency with parens", function () { var value = -10010.8009; currencyConverter.currency = 'USD'; currencyConverter.useParensForNegative = true; @@ -240,14 +240,14 @@ describe("converter-spec", function() { var result = currencyConverter.convert(value); expect(result).toBe('(10.011K) USD'); }); - it("should format a negative number to a US $ value using parens", function() { + it("should format a negative number to a US $ value using parens", function () { var value = -1000000; currencyConverter.useParensForNegative = true; currencyConverter.decimals = 3; var result = currencyConverter.convert(value); expect(result).toBe('(1M) $'); }); - it("should format a negative number to a US $ value using parens", function() { + it("should format a negative number to a US $ value using parens", function () { var value = -1000000; currencyConverter.useParensForNegative = false; currencyConverter.decimals = 3; @@ -255,21 +255,21 @@ describe("converter-spec", function() { expect(result).toBe('-1M $'); }); - it("should format a negative number to a US $ value using parens", function() { + it("should format a negative number to a US $ value using parens", function () { var value = -12500.199;; currencyConverter.useParensForNegative = false; currencyConverter.decimals = 4; var result = currencyConverter.convert(value); expect(result).toBe('-12.5002K $'); }); - it("should format a negative number to a US $ value using parens", function() { + it("should format a negative number to a US $ value using parens", function () { var value = -12500.199;; currencyConverter.useParensForNegative = false; currencyConverter.decimals = 5; var result = currencyConverter.convert(value); expect(result).toBe('-12.5002K $'); }); - it("should not shorten when asked not to", function() { + it("should not shorten when asked not to", function () { var value = -12400; currencyConverter.useParensForNegative = false; currencyConverter.decimals = 0 @@ -277,7 +277,7 @@ describe("converter-spec", function() { var result = currencyConverter.convert(value); expect(result).toBe("-12,400 $"); }); - it("should allow putting currency before the number", function() { + it("should allow putting currency before the number", function () { var value = -12400; currencyConverter.useParensForNegative = false; currencyConverter.decimals = 0 @@ -286,7 +286,7 @@ describe("converter-spec", function() { var result = currencyConverter.convert(value); expect(result).toBe("$ -12,400"); }); - it("should allow putting currency before the number", function() { + it("should allow putting currency before the number", function () { var value = -12400; currencyConverter.useParensForNegative = false; currencyConverter.decimals = 0 @@ -295,7 +295,7 @@ describe("converter-spec", function() { var result = currencyConverter.convert(value); expect(result).toBe("-12,400 $"); }); - it("should include all requested decimal places", function() { + it("should include all requested decimal places", function () { var value = 12.2; currencyConverter.decimals = 2; currencyConverter.showCurrencyBeforeNumber = true; @@ -306,8 +306,8 @@ describe("converter-spec", function() { }); - describe("test date converter", function() { - it("should create a date from a formatted string", function() { + describe("test date converter", function () { + it("should create a date from a formatted string", function () { var value = "08/30/2011"; var result = dateConverter.revert(value); expect(date.getFullYear()).toBe(2011); @@ -318,21 +318,21 @@ describe("converter-spec", function() { // string formatters - describe("Test String formatters", function() { + describe("Test String formatters", function () { - it("should format a string as uppercase", function() { + it("should format a string as uppercase", function () { var value = 'Motorola'; var result = formatter.upperCase(value); expect(result).toBe('MOTOROLA'); }); - it("should format a string as lowercase", function() { + it("should format a string as lowercase", function () { var value = 'Hello World!'; var result = formatter.lowerCase(value); expect(result).toBe('hello world!'); }); - it("should format by trimming the string", function() { + it("should format by trimming the string", function () { var value = ' Hello World! '; var result = formatter.trim(value); expect(result).toBe('Hello World!'); diff --git a/test/core/core-require-spec.js b/test/core/core-require-spec.js index 6992fa0f69..10943c8216 100644 --- a/test/core/core-require-spec.js +++ b/test/core/core-require-spec.js @@ -32,11 +32,11 @@ var Montage = require("montage").Montage, objects = require("./testobjects"); describe("core-require-spec", -function() { +function () { describe("Object Information", - function() { + function () { it("should describe a class object", - function() { + function () { var info = Montage.getInfoForObject(objects.Proto); expect(info.objectName).toBe("Proto"); @@ -44,7 +44,7 @@ function() { expect(info.moduleId).toBe("core/testobjects"); }); it("should describe a subclass object", - function() { + function () { var info = Montage.getInfoForObject(objects.SubProto); expect(info.objectName).toBe("SubProto"); @@ -52,7 +52,7 @@ function() { expect(info.moduleId).toBe("core/testobjects"); }); it("should describe a class instance object", - function() { + function () { var instance = new objects.Simple(); var info = Montage.getInfoForObject(instance); @@ -62,7 +62,7 @@ function() { }); it("should describe a function instance object", - function() { + function () { var instance = new objects.Funktion(); var info = Montage.getInfoForObject(instance); @@ -72,7 +72,7 @@ function() { }); it("should describe a class object that accessed getInfoForObject before being exported", - function() { + function () { var info = Montage.getInfoForObject(objects.FunkyProto); expect(info.objectName).toBe("FunkyProto"); diff --git a/test/core/core-spec.js b/test/core/core-spec.js index f092e1a85d..9fbde5a820 100644 --- a/test/core/core-spec.js +++ b/test/core/core-spec.js @@ -33,9 +33,9 @@ var Montage = require("montage").Montage; var WeakMap = require("montage/collections/weak-map"); var Map = require("montage/collections/map"); -describe("core/core-spec", function() { +describe("core/core-spec", function () { - describe("inherited object creation and basic properties", function() { + describe("inherited object creation and basic properties", function () { var A, BSubClassOfA, a, @@ -44,7 +44,7 @@ describe("core/core-spec", function() { object, object2; - beforeEach(function() { + beforeEach(function () { A = Montage.specialize( {}); Object.defineProperty(A, "_montage_metadata", { value: { @@ -72,31 +72,31 @@ describe("core/core-spec", function() { object2 = {}; }); - describe("regular objects", function() { + describe("regular objects", function () { - it("should have a unique uuid defined", function() { + it("should have a unique uuid defined", function () { expect(object.uuid).toBeTruthy(); expect(object2.uuid).toBeTruthy(); expect(object.uuid).not.toBe(object2.uuid); }); - it("should have a constant uuid", function() { + it("should have a constant uuid", function () { expect(object.uuid).toBe(object.uuid); }); }); - describe("Montage objects", function() { + describe("Montage objects", function () { - describe("getting prototypes uuid", function() { + describe("getting prototypes uuid", function () { - it("should have a unique uuid defined", function() { + it("should have a unique uuid defined", function () { expect(A.uuid).toBeTruthy(); expect(BSubClassOfA.uuid).toBeTruthy(); expect(A.uuid).not.toEqual(BSubClassOfA.uuid); }); - it("shouldn't affect the instances' uuid", function() { + it("shouldn't affect the instances' uuid", function () { expect(a.uuid).toBeTruthy(); expect(b.uuid).toBeTruthy(); expect(a.uuid).not.toEqual(A.uuid); @@ -104,7 +104,7 @@ describe("core/core-spec", function() { }); }); - it("should have the right prototype chain", function() { + it("should have the right prototype chain", function () { expect(a).not.toBeNull(); expect(b).not.toBeNull(); expect(BSubClassOfA.__proto__).toBe(A); @@ -112,7 +112,7 @@ describe("core/core-spec", function() { expect(b.__proto__).toBe(BSubClassOfA.prototype); }); - it("should have a unique uuid defined", function() { + it("should have a unique uuid defined", function () { expect(a.uuid).toBeTruthy(); expect(a2.uuid).toBeTruthy(); expect(a.uuid).not.toEqual(a2.uuid); @@ -121,12 +121,12 @@ describe("core/core-spec", function() { expect(a.uuid).not.toEqual(b.uuid); }); - it("should have a constant uuid", function() { + it("should have a constant uuid", function () { expect(a.uuid).toBe(a.uuid); expect(b.uuid).toBe(b.uuid); }); - it("should be equal based on uuid", function() { + it("should be equal based on uuid", function () { expect(a.equals(a2)).toBeFalsy(); var a3 = Montage.create(Montage); a3.__proto__ = null; @@ -138,9 +138,9 @@ describe("core/core-spec", function() { }); //TODO when we remove compatibility mode (Montage.create returns a constructor) this needs to be re-enabled - xdescribe("create", function() { - it("must be given an object, null or undefined as the first argument", function() { - expect(function(){ + xdescribe("create", function () { + it("must be given an object, null or undefined as the first argument", function () { + expect(function (){ Montage.create("string", {}); }).toThrow(new TypeError("Object prototype may only be an Object or null, not 'string'")); @@ -151,9 +151,9 @@ describe("core/core-spec", function() { expect(Montage.create({a: 1}, {b: { value: 2 }})).toEqual({a: 1, b: 2}); }); }); - describe("create", function() { - it("must be given an object, null or undefined as the first argument", function() { - expect(function(){ + describe("create", function () { + it("must be given an object, null or undefined as the first argument", function () { + expect(function (){ Montage.create("string", {}); }).toThrow(new TypeError("Object prototype may only be an Object or null, not 'string'")); @@ -166,20 +166,20 @@ describe("core/core-spec", function() { }); }); - describe("defineProperty", function() { + describe("defineProperty", function () { var foo; - it("must be given an object as the first argument", function() { - expect(function(){ + it("must be given an object as the first argument", function () { + expect(function (){ Montage.defineProperty(null, "b", { value: null }); }).toThrow(new TypeError("Object must be an object, not 'null'")); - expect(function(){ + expect(function (){ Montage.defineProperty(undefined, "b", { value: null }); }).toThrow(new TypeError("Object must be an object, not 'undefined'")); - expect(function(){ + expect(function (){ Montage.defineProperty("string", "b", { value: null }); }).toThrow(new TypeError("Object must be an object, not 'string'")); @@ -200,20 +200,20 @@ describe("core/core-spec", function() { }); }); - describe("underscore property name object value", function() { + describe("underscore property name object value", function () { - beforeEach(function() { + beforeEach(function () { foo = Montage.create(); }); - it("should not be enumerable by default", function() { + it("should not be enumerable by default", function () { Montage.defineProperty(foo, "_privateObjectProperty", { value: {} }); expect(Object.getPropertyDescriptor(foo, "_privateObjectProperty").enumerable).toBeFalsy(); }); - it("should be enumerable if underscore but overridden", function() { + it("should be enumerable if underscore but overridden", function () { Montage.defineProperty(foo, "_privateObjectProperty", { value: {}, enumerable:true @@ -222,15 +222,15 @@ describe("core/core-spec", function() { }); }); - describe("function value", function() { + describe("function value", function () { - beforeEach(function() { + beforeEach(function () { foo = Montage.create(); }); - it("should be non-enumerable by default", function() { + it("should be non-enumerable by default", function () { Montage.defineProperty(foo, "objectProperty", { - value: function() { + value: function () { } }); @@ -238,18 +238,18 @@ describe("core/core-spec", function() { }); }); - describe("getter setter", function() { + describe("getter setter", function () { - beforeEach(function() { + beforeEach(function () { foo = Montage.create(); }); - it("should be enumerable by default", function() { + it("should be enumerable by default", function () { Montage.defineProperty(foo, "objectProperty", { - get: function() { + get: function () { }, - set: function() { + set: function () { } }); @@ -260,17 +260,17 @@ describe("core/core-spec", function() { }); - describe("defineProperties", function() { - it("must be given an object as the second argument", function() { - expect(function(){ + describe("defineProperties", function () { + it("must be given an object as the second argument", function () { + expect(function (){ Montage.defineProperties({}, null); }).toThrow(new TypeError("Properties must be an object, not 'null'")); - expect(function(){ + expect(function (){ Montage.defineProperties({}, undefined); }).toThrow(new TypeError("Properties must be an object, not 'undefined'")); - expect(function(){ + expect(function (){ Montage.defineProperties({}, "string"); }).toThrow(new TypeError("Properties must be an object, not 'string'")); @@ -278,16 +278,16 @@ describe("core/core-spec", function() { }); }); - describe("serializable property attribute", function() { + describe("serializable property attribute", function () { var A, B; var defaultPropertyNamesCount = Montage.getSerializablePropertyNames({}).length; - beforeEach(function() { + beforeEach(function () { A = {}; B = Montage.create(A); }); - describe("defaults", function() { + describe("defaults", function () { it("should be reference", function () { Montage.defineProperty(A, "foo", {value: null}); expect(Montage.getPropertyAttribute(A, "foo", "serializable")).toBe("reference") @@ -297,7 +297,7 @@ describe("core/core-spec", function() { expect(Montage.getPropertyAttribute(A, "foo", "serializable")).toBe(false) }); it("should be false if the property has a get but no set", function () { - Montage.defineProperty(A, "foo", {get: function( ) {}}); + Montage.defineProperty(A, "foo", {get: function ( ) {}}); expect(Montage.getPropertyAttribute(A, "foo", "serializable")).toBe(false) }); it("should be false if the property is not writable", function () { @@ -306,7 +306,7 @@ describe("core/core-spec", function() { }); }); - it("should set a property as serializable", function() { + it("should set a property as serializable", function () { Montage.defineProperty(A, "foo", {serializable:true}); var propertyNames = Montage.getSerializablePropertyNames(A); @@ -315,7 +315,7 @@ describe("core/core-spec", function() { expect(propertyNames).toContain("foo"); }); - it("must not set a property as serializable", function() { + it("must not set a property as serializable", function () { Montage.defineProperty(A, "foo", {serializable:false}); var propertyNames = Montage.getSerializablePropertyNames(A); @@ -324,7 +324,7 @@ describe("core/core-spec", function() { expect(propertyNames).not.toContain("foo"); }); - it("should set the serializable attribute in properties as defined", function() { + it("should set the serializable attribute in properties as defined", function () { Montage.defineProperties(A, { foo: {serializable:false}, foz: {serializable:true}, @@ -341,7 +341,7 @@ describe("core/core-spec", function() { expect(propertyNames).toContain("baz"); }); - it("should inherit the serializable property attribute", function() { + it("should inherit the serializable property attribute", function () { Montage.defineProperty(A, "foo", {serializable:true}); var propertyNames = Montage.getSerializablePropertyNames(B); @@ -350,7 +350,7 @@ describe("core/core-spec", function() { expect(propertyNames).toContain("foo"); }); - it("should override the serializable property attribute", function() { + it("should override the serializable property attribute", function () { Montage.defineProperty(A, "foo", {serializable:false}); Montage.defineProperty(B, "foo", {serializable:true}); @@ -361,15 +361,15 @@ describe("core/core-spec", function() { }); }); - describe("extended property attributes", function() { + describe("extended property attributes", function () { var A, B; - beforeEach(function() { + beforeEach(function () { A = {}; B = Montage.create(A); }); - it("should return the boolean attribute values", function() { + it("should return the boolean attribute values", function () { Montage.defineProperties(A, { "foo": {serializable:true, value:null}, "bar": {serializable:false, value:null}, @@ -387,7 +387,7 @@ describe("core/core-spec", function() { expect(Montage.getPropertyAttribute(A, "baz", "serializable")).toBe("reference"); }); - it("should return the defined attribute values", function() { + it("should return the defined attribute values", function () { Montage.defineProperties(A, { "foo": {serializable:"auto", value:null}, "bar": {serializable:"reference", value:null}, @@ -405,7 +405,7 @@ describe("core/core-spec", function() { expect(Montage.getPropertyAttribute(A, "baz", "serializable")).toBe("value"); }); - it("should return the inherited defined attribute values", function() { + it("should return the inherited defined attribute values", function () { Montage.defineProperties(A, { "foo": {serializable:"auto", value:null}, "bar": {serializable:"value", value:null} @@ -428,38 +428,38 @@ describe("core/core-spec", function() { }); }); - describe("method inheritance calling \"super\"", function() { + describe("method inheritance calling \"super\"", function () { var A = Montage.specialize( { everywhere: { enumerable:false, - value: function() { + value: function () { return "everywhereA"; } }, skipped: { enumerable:false, - value: function() { + value: function () { return "skippedA"; } }, getEverywhere: { - get: function() { + get: function () { return "everywhereA"; } }, getSkipped: { - get: function() { + get: function () { return "skippedA"; } }, inheritedValue: { - value: function() { + value: function () { return "valueA"; } }, valueFromPrototype: { - value: function() { + value: function () { return "PrototypeValueA"; } } @@ -467,22 +467,22 @@ describe("core/core-spec", function() { B = Montage.create(A, { everywhere: { enumerable:false, - value: function() { + value: function () { return "everywhereB"; } }, getEverywhere: { - get: function() { + get: function () { return "everywhereB"; } }, inheritedValue: { - value: function() { + value: function () { return Object.getPrototypeOf(B)["inheritedValue"].call(this); } }, valueFromPrototype: { - value: function() { + value: function () { return "PrototypeValueB"; } } @@ -490,33 +490,33 @@ describe("core/core-spec", function() { C = Montage.create(B, { everywhere: { enumerable:false, - value: function() { + value: function () { return "everywhereC"; } }, skipped: { enumerable:false, - value: function() { + value: function () { return "skippedC"; } }, getEverywhere: { - get: function() { + get: function () { return "everywhereC"; } }, getSkipped: { - get: function() { + get: function () { return "skippedC"; } }, inheritedValue: { - value: function() { + value: function () { return Object.getPrototypeOf(C)["inheritedValue"].call(this); } }, valueFromPrototype: { - value: function() { + value: function () { return Object.getPrototypeOf(C)["valueFromPrototype"].call(this); } } @@ -525,7 +525,7 @@ describe("core/core-spec", function() { b = Montage.create(B), c = Montage.create(C); - it("should override methods", function() { + it("should override methods", function () { expect(a.everywhere()).toEqual("everywhereA"); expect(b.everywhere()).toEqual("everywhereB"); expect(c.everywhere()).toEqual("everywhereC"); @@ -534,7 +534,7 @@ describe("core/core-spec", function() { expect(c.skipped()).toEqual("skippedC"); }); - it("should be able to call prototype method and return expected value", function() { + it("should be able to call prototype method and return expected value", function () { expect(Object.getPrototypeOf(A)["everywhere"]).toBeUndefined(); expect(Object.getPrototypeOf(B)["everywhere"].call(b)).toEqual("everywhereA"); expect(Object.getPrototypeOf(C)["everywhere"].call(c)).toEqual("everywhereB"); @@ -542,38 +542,38 @@ describe("core/core-spec", function() { expect(Object.getPrototypeOf(C)["skipped"].call(c)).toEqual("skippedA"); }); - it("should be able to get properties from the prototype and return expected value", function() { + it("should be able to get properties from the prototype and return expected value", function () { expect(Object.getPropertyDescriptor(Object.getPrototypeOf(B), "getEverywhere").get.call(b)).toEqual("everywhereA"); expect(Object.getPropertyDescriptor(Object.getPrototypeOf(C), "getEverywhere").get.call(c)).toEqual("everywhereB"); expect(Object.getPropertyDescriptor(Object.getPrototypeOf(B), "getSkipped").get.call(b)).toEqual("skippedA"); expect(Object.getPropertyDescriptor(Object.getPrototypeOf(C), "getSkipped").get.call(c)).toEqual("skippedA"); }); - it("inheritedValue() should call inherited methods", function() { + it("inheritedValue() should call inherited methods", function () { expect(b.inheritedValue()).toEqual("valueA"); expect(c.inheritedValue()).toEqual("valueA"); }); - it("valueFromPrototype should call parent prototype method", function() { + it("valueFromPrototype should call parent prototype method", function () { expect(C.valueFromPrototype()).toEqual("PrototypeValueB"); }); }); - describe("split getter/setter inheritance", function() { + describe("split getter/setter inheritance", function () { var A = Montage.specialize( { getsetEverywhere: { - get: function() { + get: function () { return this._everywhere; }, - set: function(value) { + set: function (value) { this._everywhere = "setA"; } }, getsetSkipped: { - get: function() { + get: function () { return this._skipped; }, - set: function(value) { + set: function (value) { this._skipped = "setA"; } }, @@ -586,15 +586,15 @@ describe("core/core-spec", function() { }), B = Montage.create(A, { getsetEverywhere: { - get: function() { + get: function () { return this._everywhere; }, - set: function(value) { + set: function (value) { this._everywhere = "setB"; } }, getsetSkipped: { - get: function() { + get: function () { return this._skipped; } } @@ -602,18 +602,18 @@ describe("core/core-spec", function() { }), C = Montage.create(B, { getsetEverywhere: { - get: function() { + get: function () { return this._everywhere; }, - set: function(value) { + set: function (value) { this._everywhere = "setC"; } }, getsetSkipped: { - get: function() { + get: function () { return this._skipped; }, - set: function(value) { + set: function (value) { this._skipped = "setC"; } } @@ -622,7 +622,7 @@ describe("core/core-spec", function() { b = Montage.create(B), c = Montage.create(C); - it("should override methods", function() { + it("should override methods", function () { c.getsetEverywhere = "X"; expect(c.getsetEverywhere).toEqual("setC"); b.getsetEverywhere = "X"; @@ -637,37 +637,37 @@ describe("core/core-spec", function() { expect(a.getsetSkipped).toEqual("setA"); }); - describe("distinct properties", function() { + describe("distinct properties", function () { - it("must not allow marking a get-only property with as distinct", function() { - expect(function() { + it("must not allow marking a get-only property with as distinct", function () { + expect(function () { Montage.defineProperty({}, "foo", { distinct: true, - get: function() {} + get: function () {} }) }).toThrow(); }); - it("must not allow marking a set-only property with as distinct", function() { - expect(function() { + it("must not allow marking a set-only property with as distinct", function () { + expect(function () { Montage.defineProperty({}, "foo", { distinct: true, - set: function() {} + set: function () {} }) }).toThrow(); }); - it("must not allow marking a get-set property with as distinct", function() { - expect(function() { + it("must not allow marking a get-set property with as distinct", function () { + expect(function () { Montage.defineProperty({}, "foo", { distinct: true, - get: function() {}, - set: function() {} + get: function () {}, + set: function () {} }) }).toThrow(); }); - describe("array property", function() { + describe("array property", function () { var subType = Montage.specialize( { collection: { @@ -682,32 +682,32 @@ describe("core/core-spec", function() { var a = Montage.create(subType); var b = Montage.create(subType); - it("should have different collection property values", function() { + it("should have different collection property values", function () { expect(a.collection !== b.collection).toBeTruthy(); expect(a.collectionWithValues !== b.collectionWithValues).toBeTruthy(); }); - it("should have the same prototype", function() { + it("should have the same prototype", function () { expect(a.collection.__proto__ === b.collection.__proto__).toBeTruthy(); expect(a.collectionWithValues.__proto__ === b.collectionWithValues.__proto__).toBeTruthy(); }); - it("should have the same default content", function() { + it("should have the same default content", function () { expect(a.collectionWithValues[0]).toEqual(0); expect(a.collectionWithValues[1]).toEqual(1); expect(a.collectionWithValues[2]).toEqual(2); }); - describe("with deep inheritance", function() { + describe("with deep inheritance", function () { var subSubType = Montage.create(subType); var a = Montage.create(subSubType); var b = Montage.create(subSubType); - it("should have different collection property values", function() { + it("should have different collection property values", function () { expect(a.collection !== b.collection).toBeTruthy(); }); - it("should have the same prototype", function() { + it("should have the same prototype", function () { expect(a.collection.__proto__ === b.collection.__proto__).toBeTruthy(); }); @@ -715,7 +715,7 @@ describe("core/core-spec", function() { }); - describe("object property", function() { + describe("object property", function () { var subType = Montage.specialize( { object: { value: {}, @@ -729,23 +729,23 @@ describe("core/core-spec", function() { var a = Montage.create(subType); var b = Montage.create(subType); - it("should have different collection property values", function() { + it("should have different collection property values", function () { expect(a.object !== b.object).toBeTruthy(); expect(a.objectWithValues !== b.objectWithValues).toBeTruthy(); }); - it("should have the same prototype", function() { + it("should have the same prototype", function () { expect(a.object.__proto__ === b.object.__proto__).toBeTruthy(); expect(a.objectWithValues.__proto__ === b.objectWithValues.__proto__).toBeTruthy(); }); - it("should have the same default content", function() { + it("should have the same default content", function () { expect(a.objectWithValues["foo"]).toEqual("bar"); }); }); - describe("WeakMap property", function() { + describe("WeakMap property", function () { var subType = Montage.specialize( { object: { value:new WeakMap(), @@ -756,21 +756,21 @@ describe("core/core-spec", function() { var b = Montage.create(subType); var wm = new WeakMap() - it("should have different collection property values", function() { + it("should have different collection property values", function () { expect(a.object !== b.object).toBeTruthy(); }); - it("should have the same prototype", function() { + it("should have the same prototype", function () { expect(a.object.__proto__ === b.object.__proto__).toBeTruthy(); }); - it("should be weak maps", function() { + it("should be weak maps", function () { expect(a.object.__proto__ === wm.__proto__).toBeTruthy(); expect(b.object.__proto__ === wm.__proto__).toBeTruthy(); }); }); - describe("Map property", function() { + describe("Map property", function () { var subType = Montage.specialize( { object: { value:new Map(), @@ -781,15 +781,15 @@ describe("core/core-spec", function() { var b = Montage.create(subType); var wm = new Map() - it("should have different collection property values", function() { + it("should have different collection property values", function () { expect(a.object !== b.object).toBeTruthy(); }); - it("should have the same prototype", function() { + it("should have the same prototype", function () { expect(a.object.__proto__ === b.object.__proto__).toBeTruthy(); }); - it("should be weak maps", function() { + it("should be weak maps", function () { expect(a.object.__proto__ === wm.__proto__).toBeTruthy(); expect(b.object.__proto__ === wm.__proto__).toBeTruthy(); }); @@ -799,33 +799,33 @@ describe("core/core-spec", function() { }); - describe("delegate methods", function() { + describe("delegate methods", function () { var object, delegate; - beforeEach(function() { + beforeEach(function () { object = Montage.create(Montage); delegate = {}; object.delegate = delegate; }); - it("should call generic delegate method", function() { - delegate.methodToBeCalled = function() {}; + it("should call generic delegate method", function () { + delegate.methodToBeCalled = function () {}; spyOn(delegate, "methodToBeCalled"); object.callDelegateMethod("methodToBeCalled"); expect(delegate.methodToBeCalled).toHaveBeenCalled(); }); - it("should call delegate method with identifier", function() { - delegate.aMethodToBeCalled = function() {}; + it("should call delegate method with identifier", function () { + delegate.aMethodToBeCalled = function () {}; spyOn(delegate, "aMethodToBeCalled"); object.identifier = "a"; object.callDelegateMethod("methodToBeCalled"); expect(delegate.aMethodToBeCalled).toHaveBeenCalled(); }); - it("should call generic delegate method even if the object has an identifier", function() { - delegate.methodToBeCalled = function() {}; + it("should call generic delegate method even if the object has an identifier", function () { + delegate.methodToBeCalled = function () {}; spyOn(delegate, "methodToBeCalled"); object.identifier = "a"; object.callDelegateMethod("methodToBeCalled"); diff --git a/test/core/dom-spec.js b/test/core/dom-spec.js index 9a5b72d8bc..ff2aadbe97 100644 --- a/test/core/dom-spec.js +++ b/test/core/dom-spec.js @@ -34,90 +34,90 @@ var Montage = require("montage").Montage, convertPointFromNodeToPage = require("montage/core/dom").convertPointFromNodeToPage, convertPointFromPageToNode = require("montage/core/dom").convertPointFromPageToNode; -TestPageLoader.queueTest("dom/dom", function(testPage) { - describe("core/dom-spec", function() { - describe("convertPointFromNodeToPage parameter passing", function() { - it("should not fail if no node passed", function() { +TestPageLoader.queueTest("dom/dom", function (testPage) { + describe("core/dom-spec", function () { + describe("convertPointFromNodeToPage parameter passing", function () { + it("should not fail if no node passed", function () { var result; - expect(function() { + expect(function () { result = convertPointFromNodeToPage(new Point().init(0,0)); }).not.toThrow(); expect(result).toBeNull(); }); - it("should not fail if null node passed", function() { + it("should not fail if null node passed", function () { var result; - expect(function() { + expect(function () { result = convertPointFromNodeToPage(null,new Point().init(0,0)); }).not.toThrow(); expect(result).toBeNull(); }); - it("should not fail if all null passed", function() { + it("should not fail if all null passed", function () { var result; - expect(function() { + expect(function () { result = convertPointFromNodeToPage(null, null); }).not.toThrow(); expect(result).toBeNull(); }); }); - describe("convertPointFromPageToNode parameter passing", function() { - it("should not fail if no node passed", function() { + describe("convertPointFromPageToNode parameter passing", function () { + it("should not fail if no node passed", function () { var result; - expect(function() { + expect(function () { result = convertPointFromPageToNode(new Point().init(0,0)); }).not.toThrow(); expect(result).toBeNull(); }); - it("should not fail if null node passed", function() { + it("should not fail if null node passed", function () { var result; - expect(function() { + expect(function () { result = convertPointFromPageToNode(null,new Point().init(0,0)); }).not.toThrow(); expect(result).toBeNull(); }); - it("should not fail if all null passed", function() { + it("should not fail if all null passed", function () { var result; - expect(function() { + expect(function () { result = convertPointFromNodeToPage(null, null); }).not.toThrow(); expect(result).toBeNull(); }); }); - describe("convertPointFrom functions", function() { - describe("heading", function() { - it("should return correct position", function() { + describe("convertPointFrom functions", function () { + describe("heading", function () { + it("should return correct position", function () { testConvertPoint(testPage.test.convertPoint1, 46,36,61,236); }); }); - describe("paragraph", function() { - it("should return correct position", function() { + describe("paragraph", function () { + it("should return correct position", function () { testConvertPoint(testPage.test.convertPoint2, 46,43,61,243); }); - describe("including a link", function() { - it("should return correct position", function() { + describe("including a link", function () { + it("should return correct position", function () { testConvertPoint(testPage.test.convertPoint3, 46,43,61,243); }); }) - describe("including a link with border", function() { - it("should return correct position", function() { + describe("including a link with border", function () { + it("should return correct position", function () { testConvertPoint(testPage.test.convertPoint4, 46,43,61,243); }); }); - describe("translated", function() { - describe("including a link with border", function() { - it("should return correct position", function() { + describe("translated", function () { + describe("including a link with border", function () { + it("should return correct position", function () { testConvertPoint(testPage.test.convertPoint5, 56,43,71,243); }); }); - describe("including a link with border and a break", function() { - it("should return correct position", function() { + describe("including a link with border and a break", function () { + it("should return correct position", function () { testConvertPoint(testPage.test.convertPoint6, 56,43,71,243); }); }); - describe(", rotated, and scaled including a link with border and a break", function() { - it("should return correct position", function() { + describe(", rotated, and scaled including a link with border and a break", function () { + it("should return correct position", function () { testConvertPoint(testPage.test.convertPoint7, 56,53,3,82); }); }); @@ -125,18 +125,18 @@ TestPageLoader.queueTest("dom/dom", function(testPage) { }); }); - describe("classList element property of an HTML element", function() { - it("should return the class", function() { - expect(function() { + describe("classList element property of an HTML element", function () { + it("should return the class", function () { + expect(function () { testPage.test.html.classList; }).not.toThrow(); expect(testPage.test.html.classList.item(0)).toEqual("classOne"); }); }); - describe("classList element property of an SVG element", function() { - it("should return the class", function() { - expect(function() { + describe("classList element property of an SVG element", function () { + it("should return the class", function () { + expect(function () { testPage.test.svg.classList; }).not.toThrow(); expect(testPage.test.svg.classList.item(0)).toEqual("classTwo"); @@ -145,7 +145,7 @@ TestPageLoader.queueTest("dom/dom", function(testPage) { }); }); -var testConvertPoint = function(element, x1, y1, x2, y2) { +var testConvertPoint = function (element, x1, y1, x2, y2) { var point1, point2; point1 = convertPointFromNodeToPage(element, new Point().init(0, 0)); expect(Math.round(point1.x)).toEqual(x1); diff --git a/test/core/extras/url.js b/test/core/extras/url.js index 64c4f4bee9..848fbfeaa8 100644 --- a/test/core/extras/url.js +++ b/test/core/extras/url.js @@ -7,8 +7,6 @@ describe("core/extras/url", function () { var savedBaseElem = document.head.querySelector("base"), baseElem = document.createElement("base"); - console.log(document.head) - it("should be an absolute URL", function () { expect(URL.resolve("http://montagejs.org/", "./logo.jpeg")).toBe("http://montagejs.org/logo.jpeg"); }); diff --git a/test/core/localizer-spec.js b/test/core/localizer-spec.js index 550b7358fd..8766bed2b3 100644 --- a/test/core/localizer-spec.js +++ b/test/core/localizer-spec.js @@ -35,22 +35,22 @@ var Montage = require("montage").Montage, Bindings = require("montage/core/bindings").Bindings, Map = require("montage/collections/map"); -describe("core/localizer-spec", function() { +describe("core/localizer-spec", function () { - describe("Message", function() { + describe("Message", function () { var message; - beforeEach(function() { + beforeEach(function () { message = new Localizer.Message(); }); - it("has an init method that accepts key and default", function() { + it("has an init method that accepts key and default", function () { message = new Localizer.Message().init("hello", "Hello"); return message.localized.then(function (localized) { expect(localized).toBe("Hello"); }); }); - it("has an init method that accepts a key, default and data", function() { + it("has an init method that accepts a key, default and data", function () { var object = { name: "World" }; @@ -61,14 +61,14 @@ describe("core/localizer-spec", function() { }); - it("sets the localized property to the default message", function() { + it("sets the localized property to the default message", function () { message.key = "Hello"; return message.localized.then(function (localized) { expect(localized).toBe("Hello"); }); }); - it("localizes the messages when message binding update", function() { + it("localizes the messages when message binding update", function () { var def = { key: "Hello, {name}" }; @@ -92,7 +92,7 @@ describe("core/localizer-spec", function() { }); }); - it("localizes the messages when data bindings update", function() { + it("localizes the messages when data bindings update", function () { message.key = "Hello, {name}"; var object = { @@ -120,7 +120,7 @@ describe("core/localizer-spec", function() { }); }); - it("localizes the messages when other data bindings update", function() { + it("localizes the messages when other data bindings update", function () { message.key = "Hello, {name}"; var otherObject = { @@ -149,7 +149,7 @@ describe("core/localizer-spec", function() { }); }); - it("automatically localizes the messages when data property updates", function() { + it("automatically localizes the messages when data property updates", function () { message.key = "Hello, {name}"; message.data = { @@ -166,7 +166,7 @@ describe("core/localizer-spec", function() { }); }); - it("waits for the localizer to have messages", function() { + it("waits for the localizer to have messages", function () { var localizeDeferred = Promise.defer(); var mockLocalizer = { localize: function () { @@ -178,7 +178,7 @@ describe("core/localizer-spec", function() { message.key = "test"; expect(message.localized.isFulfilled()).toBe(false); - localizeDeferred.resolve(function() { return "pass"; }); + localizeDeferred.resolve(function () { return "pass"; }); return message.localized.then(function (localized) { expect(localized).toBe("pass"); @@ -186,19 +186,19 @@ describe("core/localizer-spec", function() { }); }); - describe("Localizer", function(){ + describe("Localizer", function (){ var l; - beforeEach(function() { + beforeEach(function () { l = new Localizer.Localizer().init("en"); }); - it("can be created with a foreign language code", function() { + it("can be created with a foreign language code", function () { var l = new Localizer.Localizer().init("no"); expect(l.messageFormat).not.toBe(null); }); - describe("locale", function() { - it("can't be set to an invalid tag", function() { + describe("locale", function () { + it("can't be set to an invalid tag", function () { var threw = false; try { l.locale = "123-en-US"; @@ -210,8 +210,8 @@ describe("core/localizer-spec", function() { }); }); - describe("messages", function() { - it("can't be set to a non-object", function() { + describe("messages", function () { + it("can't be set to a non-object", function () { var threw = false; try { l.messages = "hello"; @@ -219,7 +219,7 @@ describe("core/localizer-spec", function() { expect(l.messages).not.toBe("hello"); expect(threw).toBe(true); }); - it("can be set to an object", function() { + it("can be set to an object", function () { var input = {"hello": "ahoy!"}; l.messages = input; @@ -227,11 +227,11 @@ describe("core/localizer-spec", function() { }); }); - describe("localize", function() { - beforeEach(function() { + describe("localize", function () { + beforeEach(function () { l.messages = { "hello_name": "Hei {name}!", - "hello_name_function": function(d){ + "hello_name_function": function (d){ var r = ""; r += "Hei "; if(!d){ @@ -246,33 +246,33 @@ describe("core/localizer-spec", function() { }; }); - it("returns a function with toString for simple messages", function() { + it("returns a function with toString for simple messages", function () { var x = l.localizeSync("love you"); expect(x()).toBe("Jeg elsker deg"); expect("" + x).toBe("Jeg elsker deg"); }); - it("returns a function if it takes variables", function() { + it("returns a function if it takes variables", function () { var fn = l.localizeSync("hello_name"); expect(typeof fn).toBe("function"); expect(fn({name: "Ingrid"})).toBe("Hei Ingrid!"); }); - it("caches the compiled functions", function() { + it("caches the compiled functions", function () { var fn = l.localizeSync("hello_name"); var fn2 = l.localizeSync("hello_name"); expect(fn).toBe(fn2); }); - it("returns precompiled functions", function() { + it("returns precompiled functions", function () { var fn = l.localizeSync("hello_name_function"); expect(typeof fn).toBe("function"); expect(fn({name: "Ingrid"})).toBe("Hei Ingrid!"); }); - it("uses the default if the key does not exist", function() { + it("uses the default if the key does not exist", function () { expect(l.localizeSync("missing", "Missing key")()).toBe("Missing key"); }); - it("returns the key if the key does not exist and no fallback is given", function() { + it("returns the key if the key does not exist and no fallback is given", function () { expect(l.localizeSync("missing")()).toBe("missing"); }); - it("throws if the message object does not contain a 'message' property", function() { + it("throws if the message object does not contain a 'message' property", function () { var threw = false; try { l.localizeSync("wrong object"); @@ -283,52 +283,52 @@ describe("core/localizer-spec", function() { }); }); - describe("loadMessages", function() { - it("fails when package.json has no manifest", function() { - return require.loadPackage(module.directory + "localizer/no-package-manifest/", {}).then(function(r){ + describe("loadMessages", function () { + it("fails when package.json has no manifest", function () { + return require.loadPackage(module.directory + "localizer/no-package-manifest/", {}).then(function (r){ l.require = r; return l.loadMessages(); - }).then(function(messages) { + }).then(function (messages) { return Promise.reject("expected messages not to load but got " + JSON.stringify(messages)); - }, function(err) { + }, function (err) { return void 0; }); }); - it("fails when package has no manifest.json", function() { - return require.loadPackage(module.directory + "localizer/no-manifest/", {}).then(function(r){ + it("fails when package has no manifest.json", function () { + return require.loadPackage(module.directory + "localizer/no-manifest/", {}).then(function (r){ l.require = r; return l.loadMessages(); - }).then(function(messages) { + }).then(function (messages) { return Promise.reject("expected messages not to load but got " + JSON.stringify(messages)); - }, function(err) { + }, function (err) { return void 0; }); }); - it("fails when package has no manifest.json", function() { - return require.loadPackage(module.directory + "localizer/no-manifest-files/", {}).then(function(r){ + it("fails when package has no manifest.json", function () { + return require.loadPackage(module.directory + "localizer/no-manifest-files/", {}).then(function (r){ l.require = r; return l.loadMessages(); - }).then(function(messages) { + }).then(function (messages) { return Promise.reject("expected messages not to load but got " + JSON.stringify(messages)); - }, function(err) { + }, function (err) { return void 0; }); }); - it("can load a simple messages.json (promise)", function() { - return require.loadPackage(module.directory + "localizer/simple/", {}).then(function(r){ + it("can load a simple messages.json (promise)", function () { + return require.loadPackage(module.directory + "localizer/simple/", {}).then(function (r){ l.require = r; return l.loadMessages(); - }).then(function(messages) { + }).then(function (messages) { expect(messages.hello).toBe("Hello, World!"); }); }); - it("can load a simple messages.json (callback)", function() { + it("can load a simple messages.json (callback)", function () { var deferred = Promise.defer(); - require.loadPackage(module.directory + "localizer/simple/", {}).then(function(r){ + require.loadPackage(module.directory + "localizer/simple/", {}).then(function (r){ l.require = r; - l.loadMessages(null, function(messages) { + l.loadMessages(null, function (messages) { expect(messages.hello).toBe("Hello, World!"); deferred.resolve(); }); @@ -336,34 +336,34 @@ describe("core/localizer-spec", function() { return deferred.promise; }); - it("has a timeout", function() { - return require.loadPackage(module.directory + "localizer/simple/", {}).then(function(r){ + it("has a timeout", function () { + return require.loadPackage(module.directory + "localizer/simple/", {}).then(function (r){ l.require = r; return l.loadMessages(1); - }).then(function() { + }).then(function () { return Promise.reject("expected a timeout"); - }, function(err) { + }, function (err) { return void 0; }); }); - it("loads non-English messages", function() { + it("loads non-English messages", function () { var l = new Localizer.Localizer().init("no"); - return require.loadPackage(module.directory + "localizer/fallback/", {}).then(function(r){ + return require.loadPackage(module.directory + "localizer/fallback/", {}).then(function (r){ l.require = r; return l.loadMessages(); - }).then(function(messages) { + }).then(function (messages) { expect(messages.hello).toBe("Hei"); }); }); - it("loads the fallback messages", function() { + it("loads the fallback messages", function () { var l = new Localizer.Localizer().init("no-x-compiled"); - return require.loadPackage(module.directory + "localizer/fallback/", {}).then(function(r){ + return require.loadPackage(module.directory + "localizer/fallback/", {}).then(function (r){ l.require = r; return l.loadMessages(); - }).then(function(messages) { + }).then(function (messages) { expect(messages.hello).toBe("Hei"); expect(typeof messages.welcome).toBe("function"); var num_albums = l.localizeSync("num_albums"); @@ -374,26 +374,26 @@ describe("core/localizer-spec", function() { }); }); - describe("defaultLocalizer", function() { - beforeEach(function() { + describe("defaultLocalizer", function () { + beforeEach(function () { Localizer.defaultLocalizer.reset(); }); - describe("locale", function() { - it("defaults to navigator.language", function() { + describe("locale", function () { + it("defaults to navigator.language", function () { expect(Localizer.defaultLocalizer.locale).toBe(window.navigator.language); }); - it("saves the value to local storage", function() { + it("saves the value to local storage", function () { Localizer.defaultLocalizer.locale = "en-x-test"; expect(Localizer.defaultLocalizer.locale).toBe("en-x-test"); expect(window.localStorage.getItem("montage_locale")).toBe("en-x-test"); }); }); - describe("delegate", function() { - it("is called to determine the default locale to use", function() { + describe("delegate", function () { + it("is called to determine the default locale to use", function () { var delegate = { - getDefaultLocale: function() { + getDefaultLocale: function () { return "en-x-delegate"; } }; diff --git a/test/core/localizer/fallback/double.reel/double.js b/test/core/localizer/fallback/double.reel/double.js index 8838fb809e..fc4501bab9 100644 --- a/test/core/localizer/fallback/double.reel/double.js +++ b/test/core/localizer/fallback/double.reel/double.js @@ -13,10 +13,10 @@ exports.Double = Component.specialize( { }, value: { - get: function() { + get: function () { return this._value; }, - set: function(value) { + set: function (value) { if (this._value !== value) { this._value = value; this.needsDraw = true; @@ -29,10 +29,10 @@ exports.Double = Component.specialize( { }, secondValue: { - get: function() { + get: function () { return this._secondValue; }, - set: function(value) { + set: function (value) { if (this._secondValue !== value) { this._secondValue = value; this.needsDraw = true; @@ -71,7 +71,7 @@ exports.Double = Component.specialize( { }, enterDocument: { - value: function(firstTime) { + value: function (firstTime) { if (firstTime) { var range = this._RANGE; range.selectNodeContents(this.element); @@ -85,7 +85,7 @@ exports.Double = Component.specialize( { }, draw: { - value: function() { + value: function () { // get correct value var value = this._value, displayValue = (value || 0 === value ) ? value : this.defaultValue; diff --git a/test/core/localizer/fallback/locale/no-x-compiled/messages.js b/test/core/localizer/fallback/locale/no-x-compiled/messages.js index 20eecab1c5..eea8c7b238 100644 --- a/test/core/localizer/fallback/locale/no-x-compiled/messages.js +++ b/test/core/localizer/fallback/locale/no-x-compiled/messages.js @@ -1,5 +1,5 @@ var MessageFormat = {locale: require("montage/core/messageformat-locale")}; -exports.num_albums = function(d){ +exports.num_albums = function (d){ var r = ""; if(!d){ throw new Error("MessageFormat: No data passed to function."); @@ -8,14 +8,14 @@ var lastkey_1 = "albums"; var k_1=d[lastkey_1]; var off_0 = 0; var pf_0 = { -"one" : function(d){ +"one" : function (d){ var r = ""; r += "1 fotoalbum"; return r; }, -"other" : function(d){ +"other" : function (d){ var r = ""; -r += "" + (function(){ var x = k_1 - off_0; +r += "" + (function (){ var x = k_1 - off_0; if( isNaN(x) ){ throw new Error("MessageFormat: `"+lastkey_1+"` isnt a number."); } @@ -33,7 +33,7 @@ r += (pf_0[ MessageFormat.locale["no"]( k_1 - off_0 ) ] || pf_0[ "other" ] )( d return r; }; -exports.welcome = function(d){ +exports.welcome = function (d){ var r = ""; r += "Velkommen til nettstedet, "; if(!d){ @@ -43,7 +43,7 @@ r += d["name"]; return r; }; -exports.photo_deleted = function(d){ +exports.photo_deleted = function (d){ var r = ""; if(!d){ throw new Error("MessageFormat: No data passed to function."); diff --git a/test/core/localizer/serialization-spec.js b/test/core/localizer/serialization-spec.js index 4ef7db7eef..cf2c0dca5d 100644 --- a/test/core/localizer/serialization-spec.js +++ b/test/core/localizer/serialization-spec.js @@ -43,9 +43,9 @@ var stripPP = function stripPrettyPrintting(str) { return str.replace(/\n\s*/g, ""); }; -TestPageLoader.queueTest("fallback/fallback", {directory: module.directory}, function(testPage) { +TestPageLoader.queueTest("fallback/fallback", {directory: module.directory}, function (testPage) { var test; - beforeEach(function() { + beforeEach(function () { test = testPage.test; }); @@ -56,13 +56,13 @@ TestPageLoader.queueTest("fallback/fallback", {directory: module.directory}, fun deserializer.init( serializationString, require); - deserializer.deserialize().then(function(objs) { + deserializer.deserialize().then(function (objs) { latch = true; objects = objs; }); - waitsFor(function() { return latch; }); - runs(function() { + waitsFor(function () { return latch; }); + runs(function () { callback(objects); }); } @@ -71,25 +71,25 @@ TestPageLoader.queueTest("fallback/fallback", {directory: module.directory}, fun var serializer = new Serializer().initWithRequire(require), objects; - testDeserializer(object, function(o) { + testDeserializer(object, function (o) { objects = o; waits(10); // wait for messages to be resolved - runs(function() { + runs(function () { var serialization = serializer.serializeObject(objects.target); callback(stripPP(serialization)); }); }); } - describe("core/localizer/serialization-spec", function() { - describe("Message", function() { - it("localizes the message", function() { + describe("core/localizer/serialization-spec", function () { + describe("Message", function () { + it("localizes the message", function () { return test.message.localized.then(function (localized) { expect(localized).toBe("Welcome to the site, World"); }); }); - it("does not serialize the default localizer", function() { + it("does not serialize the default localizer", function () { testSerializer({ target: { prototype: "montage/core/localizer[Message]", @@ -97,12 +97,12 @@ TestPageLoader.queueTest("fallback/fallback", {directory: module.directory}, fun key: "hello" } } - }, function(serialization) { + }, function (serialization) { expect(serialization).not.toContain("localizer"); }); }); - it("serializes an non-default localizer", function() { + it("serializes an non-default localizer", function () { var serialization = { localizer: { prototype: "montage/core/localizer", @@ -137,32 +137,32 @@ TestPageLoader.queueTest("fallback/fallback", {directory: module.directory}, fun } }; - testSerializer(serialization, function(serializationString) { + testSerializer(serialization, function (serializationString) { expect(JSON.parse(serializationString)) .toEqual(expectedSerialization); }); }); }); - describe("localizations unit", function() { + describe("localizations unit", function () { - it("requires a key", function() { + it("requires a key", function () { expect(test.missingKey.value).toBe("Pass"); }); - it("localizes a string", function() { + it("localizes a string", function () { expect(test.basic.value).toBe("Pass."); }); - it("localizes a string and uses available resources", function() { + it("localizes a string and uses available resources", function () { expect(test.resources.value).toBe("Hello"); }); - it("creates a binding from the localizer to the object", function() { + it("creates a binding from the localizer to the object", function () { var iframeRequire = testPage.iframe.contentWindow.mr; return iframeRequire.async("montage/core/bindings") - .then(function(exports) { + .then(function (exports) { var iframeBindings = exports.Bindings, bindings; @@ -172,19 +172,19 @@ TestPageLoader.queueTest("fallback/fallback", {directory: module.directory}, fun expect(bindings.value).toBeDefined(); test.bindingInput.value = "Earth"; - waitsFor(function() { return test.binding.value !== "Hello World"; }); - runs(function() { + waitsFor(function () { return test.binding.value !== "Hello World"; }); + runs(function () { expect(test.binding.value).toBe("Hello Earth"); }); }); }); - it("can localize two properties", function() { + it("can localize two properties", function () { expect(test.twoProperties.value).toBe("On"); expect(test.twoProperties.secondValue).toBe("Off"); }); - it("accepts a binding for the default message", function() { + it("accepts a binding for the default message", function () { testDeserializer({ source: { value: {value: "Hello, {name}"} @@ -201,25 +201,25 @@ TestPageLoader.queueTest("fallback/fallback", {directory: module.directory}, fun } } } - }, function(objects) { - waitsFor(function() { return objects.target.value !== ""; }); - runs(function() { + }, function (objects) { + waitsFor(function () { return objects.target.value !== ""; }); + runs(function () { expect(objects.target.value).toBe("Hello, someone"); objects.source.value = "Goodbye, {name}"; - waitsFor(function() { return objects.target.value !== "Hello, someone"; }); - runs(function() { + waitsFor(function () { return objects.target.value !== "Hello, someone"; }); + runs(function () { expect(objects.target.value).toBe("Goodbye, someone"); }); }); }); }); - describe("serializer", function() { + describe("serializer", function () { var objects, serializer; - beforeEach(function() { + beforeEach(function () { testDeserializer({ source: { value: {x: "Hello, {name}"} @@ -240,14 +240,14 @@ TestPageLoader.queueTest("fallback/fallback", {directory: module.directory}, fun } } } - }, function(o) { + }, function (o) { objects = o; }); serializer = new Serializer().initWithRequire(require); }); - it("doesn't create a localizations block when there are none", function() { + it("doesn't create a localizations block when there are none", function () { testSerializer({ source: { value: {value: "Hello", identifier: "source"} @@ -258,12 +258,12 @@ TestPageLoader.queueTest("fallback/fallback", {directory: module.directory}, fun "test": {"<-": "@source.value"} } } - }, function(serialization) { + }, function (serialization) { expect(serialization).not.toContain("localizations"); }); }); - it("serializes simple localization strings", function() { + it("serializes simple localization strings", function () { var serialization = { target: { prototype: "montage", @@ -290,13 +290,13 @@ TestPageLoader.queueTest("fallback/fallback", {directory: module.directory}, fun } }; - testSerializer(serialization, function(serializationString) { + testSerializer(serialization, function (serializationString) { expect(JSON.parse(serializationString)) .toEqual(expectedSerialization); }); }); - it("serializes default message binding", function() { + it("serializes default message binding", function () { var serialization = { source: { value: { @@ -338,13 +338,13 @@ TestPageLoader.queueTest("fallback/fallback", {directory: module.directory}, fun "source": {} }; - testSerializer(serialization, function(serializationString) { + testSerializer(serialization, function (serializationString) { expect(JSON.parse(serializationString)) .toEqual(expectedSerialization); }); }); - it("serializes data binding", function() { + it("serializes data binding", function () { var serialization = { source: { value: { @@ -386,7 +386,7 @@ TestPageLoader.queueTest("fallback/fallback", {directory: module.directory}, fun "source": {} }; - testSerializer(serialization, function(serializationString) { + testSerializer(serialization, function (serializationString) { expect(JSON.parse(serializationString)) .toEqual(expectedSerialization); }); diff --git a/test/core/media-controller-spec.js b/test/core/media-controller-spec.js index a8dd898b93..948eef37d5 100644 --- a/test/core/media-controller-spec.js +++ b/test/core/media-controller-spec.js @@ -3,7 +3,7 @@ var Montage = require("montage").Montage, MockDOM = require("mocks/dom"), MockEvent = require("mocks/event"); -describe("core/media-controller-spec", function() { +describe("core/media-controller-spec", function () { var aMediaController, mediaElement; @@ -33,33 +33,33 @@ describe("core/media-controller-spec", function() { describe("properties", function () { describe("playbackRate", function () { - it("should have correct default value", function() { + it("should have correct default value", function () { expect(aMediaController.playbackRate).toEqual(1); }); - - it("can be set", function() { + + it("can be set", function () { aMediaController.playbackRate = 0.5; expect(aMediaController.playbackRate).toEqual(0.5); }); - - it("can be negative", function() { + + it("can be negative", function () { aMediaController.playbackRate = -0.5; expect(aMediaController.playbackRate).toEqual(-0.5); }); }); describe("currentTime", function () { - it("should have correct default value", function() { + it("should have correct default value", function () { expect(aMediaController.currentTime).toEqual(0); }); - - it("can be set", function() { + + it("can be set", function () { aMediaController.status = aMediaController.PLAYING; aMediaController.currentTime = 142; expect(aMediaController.currentTime).toEqual(142); }); - - it("can not be set when status is EMPTY", function() { + + it("can not be set when status is EMPTY", function () { aMediaController.status = aMediaController.EMPTY; aMediaController.currentTime = 142; expect(aMediaController.currentTime).toEqual(0); @@ -67,22 +67,22 @@ describe("core/media-controller-spec", function() { }); describe("duration", function () { - it("should have correct default value", function() { + it("should have correct default value", function () { expect(aMediaController.duration).toBeNull(); }); - - it("can be set", function() { + + it("can be set", function () { aMediaController.duration = 5256; expect(aMediaController.duration).toEqual(5256); }); }); - + describe("autoplay", function () { - it("should have correct default value", function() { + it("should have correct default value", function () { expect(aMediaController.autoplay).toEqual(false); }); - - it("can be set", function() { + + it("can be set", function () { aMediaController.autoplay = true; expect(aMediaController.autoplay).toEqual(true); aMediaController.autoplay = false; @@ -91,11 +91,11 @@ describe("core/media-controller-spec", function() { }); describe("volume", function () { - it("should have correct default value", function() { + it("should have correct default value", function () { expect(aMediaController.volume).toEqual(100); }); - - it("can be set", function() { + + it("can be set", function () { aMediaController.volume = 53; expect(aMediaController.volume).toEqual(53); expect(mediaElement.volume).toEqual(0.53); @@ -103,18 +103,18 @@ describe("core/media-controller-spec", function() { }); describe("mute", function () { - it("should have correct default value", function() { + it("should have correct default value", function () { expect(aMediaController.mute).toEqual(false); }); - - it("can be set", function() { + + it("can be set", function () { aMediaController.mute = true; expect(aMediaController.mute).toEqual(true); aMediaController.mute = false; expect(aMediaController.mute).toEqual(false); }); - - it("should set muted on native controller", function() { + + it("should set muted on native controller", function () { aMediaController.mute = true; expect(mediaElement.muted).toEqual(true); }); @@ -122,11 +122,11 @@ describe("core/media-controller-spec", function() { }); describe("status", function () { - it("should have default value of EMPTY", function() { + it("should have default value of EMPTY", function () { expect(aMediaController.status).toEqual(aMediaController.EMPTY); }); - - it("can be set", function() { + + it("can be set", function () { aMediaController.status = aMediaController.STOPPED; expect(aMediaController.status).toEqual(aMediaController.STOPPED); }); @@ -135,9 +135,9 @@ describe("core/media-controller-spec", function() { }); describe("functions", function () { - + describe("play", function () { - it("should play from the beginning", function() { + it("should play from the beginning", function () { aMediaController.currentTime = 1000; aMediaController.play(); expect(aMediaController.currentTime).toEqual(0); @@ -145,19 +145,19 @@ describe("core/media-controller-spec", function() { }); describe("playPause", function () { - it("should call play on media controller if not playing", function() { + it("should call play on media controller if not playing", function () { var wasCalled = false; - aMediaController.play = function() { + aMediaController.play = function () { wasCalled = true; }; aMediaController.status = aMediaController.STOPPED; aMediaController.playPause(); expect(wasCalled).toEqual(true); }); - - it("should call pause on media controller if playing", function() { + + it("should call pause on media controller if playing", function () { var wasCalled = false; - aMediaController.pause = function() { + aMediaController.pause = function () { wasCalled = true; }; aMediaController.status = aMediaController.PLAYING; @@ -167,14 +167,14 @@ describe("core/media-controller-spec", function() { }); describe("rewind", function () { - it("should set playback rate to -4.0 when playing", function() { + it("should set playback rate to -4.0 when playing", function () { aMediaController.playbackRate = 1.0; aMediaController.status = aMediaController.PLAYING; aMediaController.rewind(); expect(aMediaController.playbackRate).toEqual(-4.0); }); - it("should not change playback rate if not playing", function() { + it("should not change playback rate if not playing", function () { aMediaController.playbackRate = 1.0; aMediaController.status = aMediaController.STOPPED; aMediaController.rewind(); @@ -184,14 +184,14 @@ describe("core/media-controller-spec", function() { }); describe("fastForward", function () { - it("should set playback rate to 4.0 when playing", function() { + it("should set playback rate to 4.0 when playing", function () { aMediaController.playbackRate = 1.0; aMediaController.status = aMediaController.PLAYING; aMediaController.fastForward(); expect(aMediaController.playbackRate).toEqual(4.0); }); - it("should not change playback rate if not playing", function() { + it("should not change playback rate if not playing", function () { aMediaController.playbackRate = 1.0; aMediaController.status = aMediaController.STOPPED; aMediaController.fastForward(); @@ -200,13 +200,13 @@ describe("core/media-controller-spec", function() { }); describe("stop", function () { - it("should set current time on media controller to zero", function() { + it("should set current time on media controller to zero", function () { aMediaController.currentTime = 500; aMediaController.stop(); expect(aMediaController.currentTime).toEqual(0); }); - - it("should set status to STOPPED", function() { + + it("should set status to STOPPED", function () { aMediaController.status = aMediaController.PLAYING; aMediaController.stop(); expect(aMediaController.status).toEqual(aMediaController.STOPPED); @@ -214,7 +214,7 @@ describe("core/media-controller-spec", function() { }); describe("volumeIncrease", function () { - it("should increase volume by 10", function() { + it("should increase volume by 10", function () { aMediaController.volume = 40; aMediaController.volumeIncrease(); expect(aMediaController.volume).toEqual(50); @@ -222,7 +222,7 @@ describe("core/media-controller-spec", function() { }); describe("volumeDecrease", function () { - it("should decrease volume by 10", function() { + it("should decrease volume by 10", function () { aMediaController.volume = 40; aMediaController.volumeDecrease(); expect(aMediaController.volume).toEqual(30); @@ -230,13 +230,13 @@ describe("core/media-controller-spec", function() { }); describe("toggleMute", function () { - it("should set mute to false if muted", function() { + it("should set mute to false if muted", function () { aMediaController.mute = true; aMediaController.toggleMute(); expect(aMediaController.mute).toEqual(false); }); - it("should set mute to true if not muted", function() { + it("should set mute to true if not muted", function () { aMediaController.mute = false; aMediaController.toggleMute(); expect(aMediaController.mute).toEqual(true); @@ -247,23 +247,23 @@ describe("core/media-controller-spec", function() { }); describe("events", function () { - + describe("loadedmetadata", function () { var anEvent; - + beforeEach(function () { anEvent = MockEvent.event("loadedmetadata", true, true, null); }); - it("should set status to STOPPED", function() { + it("should set status to STOPPED", function () { aMediaController.status = aMediaController.EMPTY; mediaElement.dispatchEvent(anEvent); expect(aMediaController.status).toEqual(aMediaController.STOPPED); }); - it("should start playing if autoplay=true", function() { + it("should start playing if autoplay=true", function () { var wasCalled = false; - aMediaController.play = function() { + aMediaController.play = function () { wasCalled = true; }; @@ -273,23 +273,23 @@ describe("core/media-controller-spec", function() { expect(wasCalled).toEqual(true); }); }); - + describe("timeupdate", function () { var anEvent; - + beforeEach(function () { anEvent = MockEvent.event("timeupdate", true, true, null); }); - - it("should update the position value", function() { + + it("should update the position value", function () { aMediaController.status = aMediaController.PLAYING; aMediaController.position = 26; aMediaController.currentTime = 34; mediaElement.dispatchEvent(anEvent); expect(aMediaController.position).toEqual(34); }); - - it("should not update the position value if stopped", function() { + + it("should not update the position value if stopped", function () { aMediaController.position = 26; aMediaController.status = aMediaController.STOPPED; aMediaController.currentTime = 34; @@ -297,9 +297,9 @@ describe("core/media-controller-spec", function() { expect(aMediaController.position).toEqual(26); }); }); - + describe("play", function () { - it("should set the status to PLAYING", function() { + it("should set the status to PLAYING", function () { aMediaController.status = aMediaController.EMPTY; var anEvent = MockEvent.event("play", true, true, null); @@ -307,9 +307,9 @@ describe("core/media-controller-spec", function() { expect(aMediaController.status).toEqual(aMediaController.PLAYING); }); }); - + describe("playing", function () { - it("should set the status to PLAYING", function() { + it("should set the status to PLAYING", function () { aMediaController.status = aMediaController.EMPTY; var anEvent = MockEvent.event("playing", true, true, null); @@ -317,7 +317,7 @@ describe("core/media-controller-spec", function() { expect(aMediaController.status).toEqual(aMediaController.PLAYING); }); }); - + describe("pause", function () { var anEvent; @@ -325,21 +325,21 @@ describe("core/media-controller-spec", function() { anEvent = MockEvent.event("pause", true, true, null); }); - it("should set the status to PAUSED", function() { + it("should set the status to PAUSED", function () { aMediaController.status = aMediaController.EMPTY; mediaElement.dispatchEvent(anEvent); expect(aMediaController.status).toEqual(aMediaController.PAUSED); }); - - it("should not change the status if stopped", function() { + + it("should not change the status if stopped", function () { aMediaController.status = aMediaController.STOPPED; mediaElement.dispatchEvent(anEvent); expect(aMediaController.status).toEqual(aMediaController.STOPPED); }); }); - + describe("abort", function () { - it("should set the status to STOPPED", function() { + it("should set the status to STOPPED", function () { aMediaController.status = aMediaController.EMPTY; var anEvent = MockEvent.event("abort", true, true, null); @@ -347,9 +347,9 @@ describe("core/media-controller-spec", function() { expect(aMediaController.status).toEqual(aMediaController.STOPPED); }); }); - + describe("error", function () { - it("should set the status to STOPPED", function() { + it("should set the status to STOPPED", function () { aMediaController.status = aMediaController.EMPTY; var anEvent = MockEvent.event("error", true, true, null); @@ -357,9 +357,9 @@ describe("core/media-controller-spec", function() { expect(aMediaController.status).toEqual(aMediaController.STOPPED); }); }); - + describe("emptied", function () { - it("should set the status to STOPPED", function() { + it("should set the status to STOPPED", function () { var anEvent = MockEvent.event("emptied", true, true, null); aMediaController.status = aMediaController.EMPTY; @@ -367,9 +367,9 @@ describe("core/media-controller-spec", function() { expect(aMediaController.status).toEqual(aMediaController.STOPPED); }); }); - + describe("ended", function () { - it("should set the status to STOPPED", function() { + it("should set the status to STOPPED", function () { var anEvent = MockEvent.event("ended", true, true, null); aMediaController.status = aMediaController.EMPTY; @@ -377,7 +377,7 @@ describe("core/media-controller-spec", function() { expect(aMediaController.status).toEqual(aMediaController.STOPPED); }); }); - + }); - + }); diff --git a/test/core/module-reference-spec.js b/test/core/module-reference-spec.js index 8caf78d339..9f01ed20db 100644 --- a/test/core/module-reference-spec.js +++ b/test/core/module-reference-spec.js @@ -1,7 +1,7 @@ /*global require,exports,describe,beforeEach,it,expect,waits,waitsFor,runs,spyOn */ var ModuleReference = require("montage/core/module-reference").ModuleReference; -describe("core/module-reference-spec", function() { +describe("core/module-reference-spec", function () { var ref; beforeEach(function () { ref = new ModuleReference(); diff --git a/test/core/radio-button-controller-spec.js b/test/core/radio-button-controller-spec.js index a2ca37a75c..a1599165aa 100644 --- a/test/core/radio-button-controller-spec.js +++ b/test/core/radio-button-controller-spec.js @@ -12,13 +12,13 @@ describe("core/radio-button-controller-spec", function () { controller = new RadioButtonController(); controller.content = ["Germany", "Canada", "Spain"]; - controller.content.forEach(function(country, index) { + controller.content.forEach(function (country, index) { inputRadios[index] = new InputRadio(); inputRadios[index].value = country; }); }); - it("should reflect the value of the controller in the checked property of all checkboxes sharing the same controller", function() { + it("should reflect the value of the controller in the checked property of all checkboxes sharing the same controller", function () { for (var i = 0; i < inputRadios.length; i++) { inputRadios[i].radioButtonController = controller; inputRadios[i].checked = false; @@ -32,7 +32,7 @@ describe("core/radio-button-controller-spec", function () { expect(inputRadios[2].checked).toBe(false); }); - it("should change the controller value when checked radio button changes", function() { + it("should change the controller value when checked radio button changes", function () { for (var i = 0; i < inputRadios.length; i++) { inputRadios[i].radioButtonController = controller; inputRadios[i].checked = false; @@ -44,7 +44,7 @@ describe("core/radio-button-controller-spec", function () { expect(controller.value).toBe(inputRadios[1].value); }); - it("should reavaluate the checked checkbox when a new checkbox is registered", function() { + it("should reavaluate the checked checkbox when a new checkbox is registered", function () { inputRadios[0].checked = false; inputRadios[0].radioButtonController = controller; @@ -56,7 +56,7 @@ describe("core/radio-button-controller-spec", function () { expect(inputRadios[1].checked).toBe(true); }); - it("should change the checked property of all checkboxes sharing the same controller when one checkbox's checked property is set to true", function() { + it("should change the checked property of all checkboxes sharing the same controller when one checkbox's checked property is set to true", function () { for (var i = 0; i < inputRadios.length; i++) { inputRadios[i].radioButtonController = controller; inputRadios[i].checked = false; diff --git a/test/core/range-controller-spec.js b/test/core/range-controller-spec.js index ff20fdefd2..2b282b76fb 100644 --- a/test/core/range-controller-spec.js +++ b/test/core/range-controller-spec.js @@ -2,19 +2,19 @@ var Montage = require("montage").Montage; var RangeController = require("montage/core/range-controller").RangeController; var Set = require("montage/collections/set"); -describe("core/range-controller-spec", function() { +describe("core/range-controller-spec", function () { var rangeController; beforeEach(function () { rangeController = RangeController.create().initWithContent([0, 1, 2]); }); - describe("selection", function() { - describe("constrained by uniqueness", function() { + describe("selection", function () { + describe("constrained by uniqueness", function () { it("TODO should not allow duplicates"); it("TODO should allow new item if duplicate deleted in same splice"); }); - + it("swap should select an object in case of for no-op when rangeController avoidsEmptySelection", function () { //Save state var avoidsEmptySelection = rangeController.avoidsEmptySelection; @@ -25,7 +25,7 @@ describe("core/range-controller-spec", function() { //set property to what it was rangeController.avoidsEmptySelection = avoidsEmptySelection; rangeController.selection = selection; - + expect(swapResult.toArray()).toEqual([]); expect(rangeController.selection.toArray()).toEqual([0]); }); @@ -42,16 +42,16 @@ describe("core/range-controller-spec", function() { expect(rangeController.selection.length).toBe(0); }); - describe("constrained to content", function() { - it("should allow selection if subset of content", function() { + describe("constrained to content", function () { + it("should allow selection if subset of content", function () { rangeController.selection.add(1); expect(rangeController.selection.toArray()).toEqual([1]); }); - it("should disallow selection if not in content", function() { + it("should disallow selection if not in content", function () { rangeController.selection.add(5); expect(rangeController.selection.toArray()).toEqual([]); }); - it("should remove selection if selected content is removed", function() { + it("should remove selection if selected content is removed", function () { rangeController.selection.add(2); rangeController.pop(); expect(rangeController.selection.toArray()).toEqual([]); @@ -73,7 +73,7 @@ describe("core/range-controller-spec", function() { expect(rangeController.selection.toArray()).toEqual([1]); }); }); - describe("constrained by multiSelect", function() { + describe("constrained by multiSelect", function () { beforeEach(function () { rangeController.selection.add(0); expect(rangeController.selection.toArray()).toEqual([0]); @@ -97,7 +97,7 @@ describe("core/range-controller-spec", function() { it("TODO: test two-way bindings with multiple values"); - it("multiSelect splicing and setting", function() { + it("multiSelect splicing and setting", function () { rangeController.selection.splice(1, 0, 2); expect(rangeController.selection.toArray()).toEqual([2]); rangeController.selection.splice(0, 1, 0, 1); @@ -132,25 +132,25 @@ describe("core/range-controller-spec", function() { }); }); - describe("when true", function() { - beforeEach(function() { + describe("when true", function () { + beforeEach(function () { rangeController.multiSelect = true; }); - it("allows multiple selected items to be added", function() { + it("allows multiple selected items to be added", function () { rangeController.selection.add(1); rangeController.selection.add(2); expect(rangeController.selection.toArray()).toEqual([0, 1, 2]); }); - it("allows multiple selected items to be set", function() { + it("allows multiple selected items to be set", function () { rangeController.selection.splice(0, 1, 1, 2); expect(rangeController.selection.toArray()).toEqual([1, 2]); }); }); }); - describe("constrained by avoidsEmptySelection", function() { + describe("constrained by avoidsEmptySelection", function () { beforeEach(function () { rangeController.multiSelect = true; rangeController.selection.splice(0, 0, 0, 1); @@ -209,7 +209,7 @@ describe("core/range-controller-spec", function() { }); }); - describe("constrained to always have one selection", function() { + describe("constrained to always have one selection", function () { beforeEach(function () { rangeController.avoidsEmptySelection = false; rangeController.avoidsEmptySelection = true; @@ -324,7 +324,7 @@ describe("core/range-controller-spec", function() { describe("When content has a custom contentEquals", function () { beforeEach(function () { var content = [0, 1, 2]; - content.contentEquals = function(){ return true; }; + content.contentEquals = function (){ return true; }; expect(content.find(42)).toBe(0); rangeController = RangeController.create().initWithContent(content); diff --git a/test/core/super-for-spec.js b/test/core/super-for-spec.js index ee3b57ae06..f8722dffd9 100644 --- a/test/core/super-for-spec.js +++ b/test/core/super-for-spec.js @@ -1168,7 +1168,7 @@ describe("test/core/super-for-spec", function () { }); }); describe("constructors", function () { - describe("with three in a row", function() { + describe("with three in a row", function () { beforeEach(function () { Vehicle = Montage.specialize( { constructor: { @@ -1229,7 +1229,7 @@ describe("test/core/super-for-spec", function () { expect(beetleConstructorSpy.callCount).toEqual(2); }); }); - describe("with no constructor on Beetle", function() { + describe("with no constructor on Beetle", function () { beforeEach(function () { Vehicle = Montage.specialize( { constructor: { @@ -1263,7 +1263,7 @@ describe("test/core/super-for-spec", function () { expect(carConstructorSpy.callCount).toEqual(2); }); }); - describe("with no constructor on Car", function() { + describe("with no constructor on Car", function () { beforeEach(function () { Vehicle = Montage.specialize( { constructor: { diff --git a/test/core/super-spec.js b/test/core/super-spec.js index 6b888cdc2c..1a22290489 100644 --- a/test/core/super-spec.js +++ b/test/core/super-spec.js @@ -1203,7 +1203,7 @@ describe("test/core/super-spec", function () { }); }); describe("constructors", function () { - describe("with three in a row", function() { + describe("with three in a row", function () { beforeEach(function () { Vehicle = Montage.specialize( { constructor: { @@ -1246,7 +1246,7 @@ describe("test/core/super-spec", function () { expect(calledSpy).toContain("beetleConstructorSpy"); }); }); - describe("with no constructor on Beetle", function() { + describe("with no constructor on Beetle", function () { beforeEach(function () { Vehicle = Montage.specialize( { constructor: { @@ -1272,7 +1272,7 @@ describe("test/core/super-spec", function () { expect(calledSpy).toContain("carConstructorSpy"); }); }); - describe("with no constructor on Car", function() { + describe("with no constructor on Car", function () { beforeEach(function () { Vehicle = Montage.specialize( { constructor: { diff --git a/test/core/testobjects.js b/test/core/testobjects.js index f3d59c8479..bc337f462b 100644 --- a/test/core/testobjects.js +++ b/test/core/testobjects.js @@ -50,8 +50,8 @@ var SubProto = exports.SubProto = Proto.specialize( { prototypeUuid: {value: "c"} }); -var Funktion = exports.Funktion = function() { - this.foo = function() { +var Funktion = exports.Funktion = function () { + this.foo = function () { return 42; }; } diff --git a/test/core/tree-controller-spec.js b/test/core/tree-controller-spec.js index c75d287341..145a1e926c 100644 --- a/test/core/tree-controller-spec.js +++ b/test/core/tree-controller-spec.js @@ -239,14 +239,14 @@ describe("core/tree-controller-spec", function () { it("should be able to find the root", function () { var seek = {id: "1"}; - var equality = function(x,y) { return x.id === y.id; }; + var equality = function (x,y) { return x.id === y.id; }; node = treeController.findNodeByContent(seek, equality); expect(node.content).toBe(tree); }); it("should be able to find any level", function () { var seek = {id: "3"}; - var equality = function(x,y) { return x.id === y.id; }; + var equality = function (x,y) { return x.id === y.id; }; node = treeController.findNodeByContent(seek, equality); expect(node.content).toBe(tree.children[1]); }); @@ -254,7 +254,7 @@ describe("core/tree-controller-spec", function () { }); // 4 + 2 * 2 -> pre= +4*22; post= 422+* - describe("walk tree", function(){ + describe("walk tree", function (){ var ast = { value: "+", children: [{ @@ -277,13 +277,13 @@ describe("core/tree-controller-spec", function () { treeController = new TreeController(); treeController.content = ast; var res = ""; - treeController.preOrderWalk(function(node){ + treeController.preOrderWalk(function (node){ res += node.content.value; }); expect(res).toBe("+4*22"); res = ""; - treeController.postOrderWalk(function(node){ + treeController.postOrderWalk(function (node){ res += node.content.value; }); expect(res).toBe("422*+"); diff --git a/test/core/undo-manager-spec.js b/test/core/undo-manager-spec.js index 367a938720..11fc9fb7f9 100644 --- a/test/core/undo-manager-spec.js +++ b/test/core/undo-manager-spec.js @@ -445,7 +445,7 @@ describe('core/undo-manager-spec', function () { describe("batch operations", function () { - beforeEach(function() { + beforeEach(function () { roster._members = ["Alice", "Bob", "Carol"]; }); @@ -527,7 +527,7 @@ describe('core/undo-manager-spec', function () { describe("nested batch operations", function () { - beforeEach(function() { + beforeEach(function () { roster._members = ["Alice", "Bob", "Carol"]; }); diff --git a/test/document-resources-spec.js b/test/document-resources-spec.js index b242ae2abe..fc09e40e5c 100644 --- a/test/document-resources-spec.js +++ b/test/document-resources-spec.js @@ -11,7 +11,7 @@ function createPage(url) { deferred = Promise.defer(); iframe.src = url; - iframe.onload = function() { + iframe.onload = function () { deferred.resolve(iframe.contentWindow); }; iframe.style.display = "none"; @@ -28,139 +28,139 @@ function deletePage(page) { iframe.parentNode.removeChild(iframe); } -describe("document-resources-spec", function() { - it("should add an inline script", function() { +describe("document-resources-spec", function () { + it("should add an inline script", function () { var resources = new DocumentResources(), script; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { resources.initWithDocument(page.document); script = page.document.createElement("script"); script.textContent = "window.InlineScriptLoaded = 1;"; return resources.addScript(script) - .then(function() { + .then(function () { expect(page.document.scripts.length).toBe(1); expect(page.InlineScriptLoaded).toBe(1); deletePage(page); }); - }).fail(function(reason) { + }).fail(function (reason) { expect("test").toBe("executed"); }); }); - it("should add a script file", function() { + it("should add a script file", function () { var resources = new DocumentResources(), url = "resource.js", script; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { resources.initWithDocument(page.document); script = page.document.createElement("script"); script.src = url; return resources.addScript(script) - .then(function() { + .then(function () { expect(page.document.scripts.length).toBe(1); deletePage(page); }); - }).fail(function(reason) { + }).fail(function (reason) { expect("test").toBe("executed"); }); }); - it("should know its loaded resources", function() { + it("should know its loaded resources", function () { var resources = new DocumentResources(), url = "resource.js", script; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { resources.initWithDocument(page.document); script = page.document.createElement("script"); script.src = url; return resources.addScript(script) - .then(function() { + .then(function () { var src = page.document.scripts[0].src; expect(resources.hasResource(src)).toBe(true); deletePage(page); }); - }).fail(function(reason) { + }).fail(function (reason) { expect("test").toBe("executed"); }); }); - it("should add a script file even if it 404's", function() { + it("should add a script file even if it 404's", function () { var resources = new DocumentResources(), url = "notfound.js", script; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { resources.initWithDocument(page.document); script = page.document.createElement("script"); script.src = url; return resources.addScript(script) - .then(function() { + .then(function () { expect(page.document.scripts.length).toBe(1); deletePage(page); }); - }).fail(function(reason) { + }).fail(function (reason) { expect("test").toBe("executed"); }); }); - it("should not add a script file twice when requested in serial", function() { + it("should not add a script file twice when requested in serial", function () { var resources = new DocumentResources(), url = "resource.js", script; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { resources.initWithDocument(page.document); script = page.document.createElement("script"); script.src = url; return resources.addScript(script) - .then(function() { + .then(function () { script = page.document.createElement("script"); script.src = url; return resources.addScript(script) - .then(function() { + .then(function () { expect(page.document.scripts.length).toBe(1); deletePage(page); }); }); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should not add a script file twice when requested in parallel", function() { + it("should not add a script file twice when requested in parallel", function () { var resources = new DocumentResources(), url = "resource.js", script1, script2; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { resources.initWithDocument(page.document); script1 = page.document.createElement("script"); @@ -171,23 +171,23 @@ describe("document-resources-spec", function() { return Promise.all([ resources.addScript(script1), resources.addScript(script2) - ]).then(function() { + ]).then(function () { expect(page.document.scripts.length).toBe(1); deletePage(page); }); - }).fail(function(reason) { + }).fail(function (reason) { expect("test").toBe("executed"); }); }); - it("should add a scripts even if it timesout", function() { + it("should add a scripts even if it timesout", function () { var resources = new DocumentResources(), // The server is available as template-server.js url = "http://localhost:9090/resource.js?delay=60000", script; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { var initialTime = new Date; resources.initWithDocument(page.document); @@ -198,7 +198,7 @@ describe("document-resources-spec", function() { script.src = url; return resources.addScript(script) - .then(function() { + .then(function () { var finalTime = new Date; expect(page.document.scripts.length).toBe(1); @@ -206,65 +206,65 @@ describe("document-resources-spec", function() { deletePage(page); }); - }).fail(function(reason) { + }).fail(function (reason) { expect("test").toBe("executed"); }); }); - it("should preload a resource", function() { + it("should preload a resource", function () { var resources = new DocumentResources(), url = "resource.js", script; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { resources.initWithDocument(page.document); return resources.preloadResource(url) - .then(function() { + .then(function () { var normalizedUrl = resources.normalizeUrl(url); expect(resources.isResourcePreloaded(normalizedUrl)).toBe(true); deletePage(page); }); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should preload a resource even if it 404's", function() { + it("should preload a resource even if it 404's", function () { var resources = new DocumentResources(), url = "notfound.js", script; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { resources.initWithDocument(page.document); return resources.preloadResource(url) - .then(function() { + .then(function () { var normalizedUrl = resources.normalizeUrl(url); expect(resources.isResourcePreloaded(normalizedUrl)).toBe(true); deletePage(page); }); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should preload a resource even if it timesout", function() { + it("should preload a resource even if it timesout", function () { var resources = new DocumentResources(), // The server is available as template-server.js url = "http://localhost:9090/resource.js?delay=60000", script; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { var initialTime = new Date; resources.initWithDocument(page.document); @@ -272,72 +272,72 @@ describe("document-resources-spec", function() { resources._SCRIPT_TIMEOUT = 500; return resources.preloadResource(url, true) - .then(function() { + .then(function () { var finalTime = new Date; expect(resources.isResourcePreloaded(url)).toBe(true); expect(finalTime - initialTime).toBeLessThan(60000); deletePage(page); }); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should avoid x-domain requests on file://", function() { + it("should avoid x-domain requests on file://", function () { var resources = new DocumentResources(), url = "file://example.html"; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { resources.initWithDocument(page.document); return resources.preloadResource(url) - .then(function() { + .then(function () { expect(resources.isResourcePreloaded(url)).toBe(false); deletePage(page); }); }); }); - it("should avoid x-domain requests on absolute urls", function() { + it("should avoid x-domain requests on absolute urls", function () { var resources = new DocumentResources(), url = "http://montagejs.org/example.html"; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { resources.initWithDocument(page.document); return resources.preloadResource(url) - .then(function() { + .then(function () { expect(resources.isResourcePreloaded(url)).toBe(false); deletePage(page); }); }); }); - it("should load on absolute url if it's in the same domain", function() { + it("should load on absolute url if it's in the same domain", function () { var resources = new DocumentResources(), url = resources.domain + "/example.html"; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { resources.initWithDocument(page.document); return resources.preloadResource(url) - .then(function() { + .then(function () { expect(resources.isResourcePreloaded(url)).toBe(true); deletePage(page); }); }); }); - it("should add an inline style", function() { + it("should add an inline style", function () { var resources = new DocumentResources(); return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { var style, computedStyle; @@ -352,17 +352,17 @@ describe("document-resources-spec", function() { expect(computedStyle.paddingLeft).toBe("42px"); expect(page.document.styleSheets.length).toBe(1); deletePage(page); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should add an inline style but not wait for it to be loaded like a style file", function() { + it("should add an inline style but not wait for it to be loaded like a style file", function () { var resources = new DocumentResources(); return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { var style; resources.initWithDocument(page.document); @@ -374,18 +374,18 @@ describe("document-resources-spec", function() { expect(resources.areStylesLoaded).toBe(true); deletePage(page); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should add a style file", function() { + it("should add a style file", function () { var resources = new DocumentResources(), url = "resource.css"; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { var deferred = Promise.defer(), style; @@ -394,7 +394,7 @@ describe("document-resources-spec", function() { style = page.document.createElement("link"); style.rel = "stylesheet"; style.href = url; - style.onload = function() { + style.onload = function () { var computedStyle; computedStyle = page.getComputedStyle(page.document.body); @@ -409,18 +409,18 @@ describe("document-resources-spec", function() { resources.addStyle(style); return deferred.promise; - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should not add a style file twice when requested in serial", function() { + it("should not add a style file twice when requested in serial", function () { var resources = new DocumentResources(), url = "resource.css"; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { var deferred = Promise.defer(), style, links; @@ -437,18 +437,18 @@ describe("document-resources-spec", function() { links = page.document.head.querySelectorAll("link"); expect(links.length).toBe(1); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should report styles as loaded when they're laoded", function() { + it("should report styles as loaded when they're laoded", function () { var resources = new DocumentResources(), url = "resource.css"; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { var deferred = Promise.defer(), style; @@ -457,7 +457,7 @@ describe("document-resources-spec", function() { style = page.document.createElement("link"); style.rel = "stylesheet"; style.href = url; - style.onload = function() { + style.onload = function () { expect(resources.areStylesLoaded).toBeTruthy(); deletePage(page); @@ -467,95 +467,95 @@ describe("document-resources-spec", function() { resources.addStyle(style); return deferred.promise; - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should report styles as not loaded when they're not loaded", function() { + it("should report styles as not loaded when they're not loaded", function () { var resources = new DocumentResources(); return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { resources.initWithDocument(page.document); resources._expectedStyles.push("resource.css"); expect(resources.areStylesLoaded).toBeFalsy(); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - describe("prepopulate with the existing resources in the document", function() { - it("should prepopulate with a script file", function() { + describe("prepopulate with the existing resources in the document", function () { + it("should prepopulate with a script file", function () { var resources = new DocumentResources(); return createPage("reel/template/prepopulated-page.html") - .then(function(page) { + .then(function (page) { resources.initWithDocument(page.document); var src = page.document.querySelector("script").src; expect(resources.hasResource(src)).toBe(true); - }).fail(function(reason) { + }).fail(function (reason) { expect("test").toBe("executed"); }); }); - it("should prepopulate with a link file", function() { + it("should prepopulate with a link file", function () { var resources = new DocumentResources(); return createPage("reel/template/prepopulated-page.html") - .then(function(page) { + .then(function (page) { resources.initWithDocument(page.document); var src = page.document.querySelector("link").href; expect(resources.hasResource(src)).toBe(true); - }).fail(function(reason) { + }).fail(function (reason) { expect("test").toBe("executed"); }); }); }); - describe("normalize url", function() { - it("should normalize a relative url", function() { + describe("normalize url", function () { + it("should normalize a relative url", function () { var resources = new DocumentResources(), normalizedUrl, url = "../resource.css", expectedUrl; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { expectedUrl = page.document.location.href.split("/").slice(0, -2).join("/") + "/resource.css"; resources.initWithDocument(page.document); normalizedUrl = resources.normalizeUrl(url); expect(normalizedUrl).toBe(expectedUrl); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should normalize an absolute url", function() { + it("should normalize an absolute url", function () { var resources = new DocumentResources(), normalizedUrl, url = "http://www.montagejs.org/resource.css", expectedUrl = "http://www.montagejs.org/resource.css"; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { resources.initWithDocument(page.document); normalizedUrl = resources.normalizeUrl(url); expect(normalizedUrl).toBe(expectedUrl); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should normalize an url with a base url", function() { + it("should normalize an url with a base url", function () { var resources = new DocumentResources(), normalizedUrl, url = "resource.css", @@ -563,12 +563,12 @@ describe("document-resources-spec", function() { expectedUrl = "http://www.montagejs.org/resource.css"; return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { resources.initWithDocument(page.document); normalizedUrl = resources.normalizeUrl(url, baseUrl); expect(normalizedUrl).toBe(expectedUrl); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); diff --git a/test/enum-spec.js b/test/enum-spec.js index d0d4936117..c1c3718e56 100644 --- a/test/enum-spec.js +++ b/test/enum-spec.js @@ -32,37 +32,37 @@ var Montage = require("montage").Montage, Enum = require("montage/core/enum").Enum; describe("enum-spec", -function() { +function () { describe("initialization", - function() { + function () { var TestEnum = new Enum().initWithMembers("ZERO","ONE","TWO"); it("should define properties", - function() { + function () { expect(Object.getOwnPropertyDescriptor(TestEnum, "ZERO")).not.toBeNull(); expect(Object.getOwnPropertyDescriptor(TestEnum, "ONE")).not.toBeNull(); expect(Object.getOwnPropertyDescriptor(TestEnum, "TWO")).not.toBeNull(); }); it("should be use incremental values", - function() { + function () { expect(TestEnum.ZERO).toEqual(0); expect(TestEnum.ONE).toEqual(1); expect(TestEnum.TWO).toEqual(2); }); it("should not be editable", - function() { + function () { TestEnum.ZERO = 666; expect(TestEnum.ZERO).toEqual(0); }); it("should not be extensible", - function() { + function () { TestEnum = new Enum().initWithMembers("ZERO","ONE","TWO"); - expect(function() { + expect(function () { TestEnum.addMember("THREE"); }).toThrow(); }); }); describe("adding a member", - function() { + function () { var TestEnum = new Enum().init(); TestEnum.addMember("ZERO"); TestEnum.addMember("ONE"); @@ -70,11 +70,11 @@ function() { TestEnum.addMember("THREE"); TestEnum.seal(); it("should define a property", - function() { + function () { expect(Object.getOwnPropertyDescriptor(TestEnum, "THREE")).not.toBeNull(); }); it("should be use incremental values", - function() { + function () { expect(TestEnum.THREE).toEqual(3); }); }); diff --git a/test/events/active-target-spec.js b/test/events/active-target-spec.js index ac0acc7b77..88315160d3 100644 --- a/test/events/active-target-spec.js +++ b/test/events/active-target-spec.js @@ -2,7 +2,7 @@ var Montage = require("montage").Montage; var Component = require("montage/ui/component").Component; var TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; -TestPageLoader.queueTest("active-target-test/active-target-test", function(testPage) { +TestPageLoader.queueTest("active-target-test/active-target-test", function (testPage) { describe("events/active-target-spec", function () { var testDocument; diff --git a/test/events/active-target-test/menu-item.js b/test/events/active-target-test/menu-item.js index 062d3a8d8b..b7e951e50b 100644 --- a/test/events/active-target-test/menu-item.js +++ b/test/events/active-target-test/menu-item.js @@ -16,7 +16,7 @@ exports.MenuItem = Component.specialize( { }, prepareForActivationEvents: { - value: function() { + value: function () { this.element.addEventListener("mouseup", this); } }, diff --git a/test/events/eventmanager-spec.js b/test/events/eventmanager-spec.js index b3234962bc..32e744936d 100644 --- a/test/events/eventmanager-spec.js +++ b/test/events/eventmanager-spec.js @@ -40,8 +40,8 @@ var Montage = require("montage").Montage, var global = typeof global !== "undefined" ? global : window; -TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) { - describe("events/eventmanager-spec", function() { +TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function (testPage) { + describe("events/eventmanager-spec", function () { var NONE = Event.NONE, CAPTURING_PHASE = Event.CAPTURING_PHASE, @@ -50,7 +50,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) var testDocument, eventManager; - beforeEach(function() { + beforeEach(function () { var testWindow = testPage.iframe.contentWindow; eventManager = testWindow.mr("montage/core/application").application.eventManager; @@ -59,64 +59,64 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) eventManager.reset(); }); - describe("when determining handler method names", function() { + describe("when determining handler method names", function () { - it('should correctly prefix the eventType with "capture" for the capture phase event handler method', function() { + it('should correctly prefix the eventType with "capture" for the capture phase event handler method', function () { expect(eventManager.methodNameForCapturePhaseOfEventType("mousedown")).toBe("captureMousedown"); }); - it('should correctly prefix the eventType with "handle" for the bubble phase event handler method', function() { + it('should correctly prefix the eventType with "handle" for the bubble phase event handler method', function () { expect(eventManager.methodNameForBubblePhaseOfEventType("mousedown")).toBe("handleMousedown"); }); - it("must not alter inner capitalization of capture phase event handler method names", function() { + it("must not alter inner capitalization of capture phase event handler method names", function () { expect(eventManager.methodNameForCapturePhaseOfEventType("DOMContentReady")).toBe("captureDOMContentReady"); }); - it("must not alter inner capitalization of bubble phase event handler method names", function() { + it("must not alter inner capitalization of bubble phase event handler method names", function () { expect(eventManager.methodNameForBubblePhaseOfEventType("DOMContentReady")).toBe("handleDOMContentReady"); }); - it("should inject the specified target identifier as part of the bubble phase event handler method name", function() { + it("should inject the specified target identifier as part of the bubble phase event handler method name", function () { expect(eventManager.methodNameForBubblePhaseOfEventType("click", "testButton")).toBe("handleTestButtonClick"); }); - it("should inject the specified target identifier as part of the capture phase event handler method name", function() { + it("should inject the specified target identifier as part of the capture phase event handler method name", function () { expect(eventManager.methodNameForCapturePhaseOfEventType("click", "testButton")).toBe("captureTestButtonClick"); }); }); - describe("when registering a window", function() { + describe("when registering a window", function () { - it("should be installed as the defaultManager in the current window", function() { + it("should be installed as the defaultManager in the current window", function () { expect(eventManager).toBeTruthy(); }); - it("should have overridden the addEventListener for window", function() { + it("should have overridden the addEventListener for window", function () { var testWindow = testDocument.defaultView; expect(testWindow.nativeAddEventListener).toBeTruthy(); expect(testWindow.nativeAddEventListener).toNotBe(testWindow.addEventListener); }); - it("should have overridden the addEventListener for document", function() { + it("should have overridden the addEventListener for document", function () { expect(testDocument.nativeAddEventListener).toBeTruthy(); expect(testDocument.nativeAddEventListener).toNotBe(testDocument.addEventListener); }); - it("should have overridden the addEventListener for Element", function() { + it("should have overridden the addEventListener for Element", function () { var testElement = testDocument.defaultView.Element.prototype; expect(testElement.nativeAddEventListener).toBeTruthy(); expect(testElement.nativeAddEventListener).toNotBe(testElement.addEventListener); }); - it("should have overridden the addEventListener for XMLHttpRequest", function() { + it("should have overridden the addEventListener for XMLHttpRequest", function () { var request = testDocument.defaultView.XMLHttpRequest.prototype; expect(request.nativeAddEventListener).toBeTruthy(); expect(request.nativeAddEventListener).toNotBe(request.addEventListener); }); if (Worker) { - it("should have overridden the addEventListener for Worker", function() { + it("should have overridden the addEventListener for Worker", function () { var worker = testDocument.defaultView.Worker.prototype; expect(worker.nativeAddEventListener).toBeTruthy(); expect(worker.nativeAddEventListener).toNotBe(worker.addEventListener); @@ -124,38 +124,38 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) } if (typeof window.MediaController !== "undefined") { - it("should have overridden the addEventListener for MediaController", function() { + it("should have overridden the addEventListener for MediaController", function () { var mediaController = testDocument.defaultView.MediaController.prototype; expect(mediaController.nativeAddEventListener).toBeTruthy(); expect(mediaController.nativeAddEventListener).toNotBe(mediaController.addEventListener); }); } - it("should have overridden the removeEventListener for window", function() { + it("should have overridden the removeEventListener for window", function () { var testWindow = testDocument.defaultView; expect(testWindow.nativeRemoveEventListener).toBeTruthy(); expect(testWindow.nativeRemoveEventListener).toNotBe(testWindow.removeEventListener); }); - it("should have overridden the removeEventListener for document", function() { + it("should have overridden the removeEventListener for document", function () { expect(testDocument.nativeRemoveEventListener).toBeTruthy(); expect(testDocument.nativeRemoveEventListener).toNotBe(testDocument.removeEventListener); }); - it("should have overridden the removeEventListener for Element", function() { + it("should have overridden the removeEventListener for Element", function () { var testElement = testDocument.defaultView.Element.prototype; expect(testElement.nativeRemoveEventListener).toBeTruthy(); expect(testElement.nativeRemoveEventListener).toNotBe(testElement.removeEventListener); }); - it("should have overridden the removeEventListener for XMLHttpRequest", function() { + it("should have overridden the removeEventListener for XMLHttpRequest", function () { var request = testDocument.defaultView.XMLHttpRequest.prototype; expect(request.nativeRemoveEventListener).toBeTruthy(); expect(request.nativeRemoveEventListener).toNotBe(request.removeEventListener); }); if (Worker) { - it("should have overridden the addEventListener for Worker", function() { + it("should have overridden the addEventListener for Worker", function () { var worker = testDocument.defaultView.Worker.prototype; expect(worker.nativeRemoveEventListener).toBeTruthy(); expect(worker.nativeRemoveEventListener).toNotBe(worker.removeEventListener); @@ -163,7 +163,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) } if (typeof window.MediaController !== "undefined") { - it("should have overridden the addEventListener for MediaController", function() { + it("should have overridden the addEventListener for MediaController", function () { var mediaController = testDocument.defaultView.MediaController.prototype; expect(mediaController.nativeRemoveEventListener).toBeTruthy(); expect(mediaController.nativeRemoveEventListener).toNotBe(mediaController.removeEventListener); @@ -200,9 +200,9 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) }); }); - describe("when adding event listeners", function() { + describe("when adding event listeners", function () { - it("should record that the listener cares about an event on the target", function() { + it("should record that the listener cares about an event on the target", function () { var listener = new Montage(); testDocument.addEventListener("mousedown", listener, false); @@ -212,7 +212,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) expect(listenerEntry.listener).toBe(listener); }); - it("should add a native event listener when the first listener for an eventType is added for a target", function() { + it("should add a native event listener when the first listener for an eventType is added for a target", function () { var listener = {}, eventType = UUID.generate(); @@ -220,7 +220,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) var originalHandler = eventManager.handleEvent; var handleEventCalled = false; - eventManager.handleEvent = function() { + eventManager.handleEvent = function () { handleEventCalled = true; }; @@ -232,37 +232,37 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) expect(handleEventCalled).toBe(true); }); - it("should present an event to any listeners watching for that event type on a specific target", function() { + it("should present an event to any listeners watching for that event type on a specific target", function () { var clickSpy = { - handleClick: function(event) { + handleClick: function (event) { } }; spyOn(clickSpy, 'handleClick'); testDocument.addEventListener("click", clickSpy, false); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "click", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "click", function () { expect(clickSpy.handleClick).toHaveBeenCalled(); }); }); - it("should not interfere with inline DOM 0 event listener function", function() { + it("should not interfere with inline DOM 0 event listener function", function () { var inlineCalled = false; - var inlineClickSpy = function() { + var inlineClickSpy = function () { inlineCalled = true; }; testDocument.onclick = inlineClickSpy; var clickSpy = { - handleClick: function(event) { + handleClick: function (event) { } }; spyOn(clickSpy, 'handleClick'); testDocument.addEventListener("click", clickSpy, false); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "click", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "click", function () { expect(clickSpy.handleClick).toHaveBeenCalled(); expect(inlineCalled).toBeTruthy(); }); @@ -270,9 +270,9 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) }); - describe("when reporting registered event listeners", function() { + describe("when reporting registered event listeners", function () { - it("should be able to report all the listeners registered for a specific eventType, regardless of target", function() { + it("should be able to report all the listeners registered for a specific eventType, regardless of target", function () { var docEventSpy = {}; testDocument.addEventListener("foo", docEventSpy, false); @@ -296,7 +296,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) expect(rootListenerEntry.listener).toBe(rootEventSpy); }); - it("should be able to report all the listeners registered for a specific eventType on a specific target", function() { + it("should be able to report all the listeners registered for a specific eventType on a specific target", function () { var docEventSpy = {}; testDocument.addEventListener("bar", docEventSpy, false); @@ -317,9 +317,9 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) }); - describe("when removing event listeners", function() { + describe("when removing event listeners", function () { - it("should correctly remove a registered event listener", function() { + it("should correctly remove a registered event listener", function () { var listener = {}, listener2 = {}; @@ -335,7 +335,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) expect(listeners[listener2.uuid]).toBeFalsy(); }); - it("should remove a registered eventType when the last listener is removed", function() { + it("should remove a registered eventType when the last listener is removed", function () { var listener = {}, eventType = UUID.generate(); @@ -346,7 +346,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) expect(listeners).toBeNull(); }); - it("should remove the native event listener when the last listener for an eventType is removed", function() { + it("should remove the native event listener when the last listener for an eventType is removed", function () { var listener = {}, eventType = UUID.generate(); @@ -355,7 +355,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) var originalHandler = eventManager.handleEvent; var handleEventCalled = false; - eventManager.handleEvent = function() { + eventManager.handleEvent = function () { handleEventCalled = true; }; @@ -367,7 +367,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) expect(handleEventCalled).toBe(false); }); - it("should remove all registered listeners after being reset", function() { + it("should remove all registered listeners after being reset", function () { var listener = {}, listener2 = {}, eventType = UUID.generate(), @@ -387,42 +387,42 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) expect(listenerEntries[eventType2]).toBeFalsy(); }); - it("should still respond to activationEvent event type events even if the last interested listener is removed for an activationEvent event type", function() { + it("should still respond to activationEvent event type events even if the last interested listener is removed for an activationEvent event type", function () { var activationTarget = testPage.test.activationTarget; - activationTarget.prepareForActivationEvents = function() {}; + activationTarget.prepareForActivationEvents = function () {}; spyOn(activationTarget, "prepareForActivationEvents"); - var otherListener = function() {}; + var otherListener = function () {}; testDocument.addEventListener("mousedown", otherListener, false); testDocument.removeEventListener("mousedown", otherListener, false); - testPage.mouseEvent(new EventInfo().initWithElement(activationTarget.element), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(activationTarget.element), "mousedown", function () { expect(activationTarget.prepareForActivationEvents).toHaveBeenCalled(); }); }); }); - describe("when distributing an event", function() { + describe("when distributing an event", function () { - describe("with respect to phases", function() { + describe("with respect to phases", function () { - it("should present the event to any listeners along the propagation path registered in the capture phase first", function() { + it("should present the event to any listeners along the propagation path registered in the capture phase first", function () { var captureCalled = false, bubbleCalled = false; var mousedownCaptureSpy = { - captureMousedown: function() { + captureMousedown: function () { expect(bubbleCalled).toBe(false); captureCalled = true; } }; var mousedownBubbleSpy = { - handleMousedown: function() { + handleMousedown: function () { expect(captureCalled).toBe(true); bubbleCalled = true; } @@ -434,19 +434,19 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) testDocument.addEventListener("mousedown", mousedownCaptureSpy, true); testDocument.addEventListener("mousedown", mousedownBubbleSpy, false); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function () { expect(mousedownCaptureSpy.captureMousedown).toHaveBeenCalled(); expect(mousedownBubbleSpy.handleMousedown).toHaveBeenCalled(); }); }); - it("should present an event to capture listeners in the capture phase based on the DOM hierarchy from top to target, not in the order they registered", function() { + it("should present an event to capture listeners in the capture phase based on the DOM hierarchy from top to target, not in the order they registered", function () { var calledHandlers = []; var windowSpy = { - captureMousedown: function() { + captureMousedown: function () { expect(calledHandlers.length).toBe(0); calledHandlers.push(this); } @@ -454,7 +454,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) spyOn(windowSpy, 'captureMousedown').andCallThrough(); var documentSpy = { - captureMousedown: function() { + captureMousedown: function () { expect(calledHandlers.length).toBe(1); calledHandlers.push(this); } @@ -462,7 +462,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) spyOn(documentSpy, 'captureMousedown').andCallThrough(); var bodySpy = { - captureMousedown: function() { + captureMousedown: function () { expect(calledHandlers.length).toBe(2); calledHandlers.push(this); } @@ -470,7 +470,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) spyOn(bodySpy, 'captureMousedown').andCallThrough(); var parentSpy = { - captureMousedown: function() { + captureMousedown: function () { expect(calledHandlers.length).toBe(3); calledHandlers.push(this); } @@ -478,7 +478,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) spyOn(parentSpy, 'captureMousedown').andCallThrough(); var targetSpy = { - captureMousedown: function() { + captureMousedown: function () { expect(calledHandlers.length).toBe(4); calledHandlers.push(this); } @@ -495,7 +495,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) testDocument.addEventListener("mousedown", documentSpy, true); testDocument.defaultView.addEventListener("mousedown", windowSpy, true); - testPage.mouseEvent(new EventInfo().initWithElement(target), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(target), "mousedown", function () { expect(windowSpy.captureMousedown).toHaveBeenCalled(); expect(documentSpy.captureMousedown).toHaveBeenCalled(); expect(bodySpy.captureMousedown).toHaveBeenCalled(); @@ -504,12 +504,12 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) }); }); - it("should present an event to bubble listeners in the capture phase based on the DOM hierarchy from target to top, not in the order they registered", function() { + it("should present an event to bubble listeners in the capture phase based on the DOM hierarchy from target to top, not in the order they registered", function () { var calledHandlers = []; var targetSpy = { - handleMousedown: function() { + handleMousedown: function () { expect(calledHandlers.length).toBe(0); calledHandlers.push(this); } @@ -517,7 +517,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) spyOn(targetSpy, 'handleMousedown').andCallThrough(); var parentSpy = { - handleMousedown: function() { + handleMousedown: function () { expect(calledHandlers.length).toBe(1); calledHandlers.push(this); } @@ -525,7 +525,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) spyOn(parentSpy, 'handleMousedown').andCallThrough(); var bodySpy = { - handleMousedown: function() { + handleMousedown: function () { expect(calledHandlers.length).toBe(2); calledHandlers.push(this); } @@ -533,7 +533,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) spyOn(bodySpy, 'handleMousedown').andCallThrough(); var documentSpy = { - handleMousedown: function() { + handleMousedown: function () { expect(calledHandlers.length).toBe(3); calledHandlers.push(this); } @@ -541,7 +541,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) spyOn(documentSpy, 'handleMousedown').andCallThrough(); var windowSpy = { - handleMousedown: function() { + handleMousedown: function () { expect(calledHandlers.length).toBe(4); calledHandlers.push(this); } @@ -557,7 +557,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) target.parentNode.addEventListener("mousedown", parentSpy, false); target.addEventListener("mousedown", targetSpy, false); - testPage.mouseEvent(new EventInfo().initWithElement(target), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(target), "mousedown", function () { expect(windowSpy.handleMousedown).toHaveBeenCalled(); expect(documentSpy.handleMousedown).toHaveBeenCalled(); expect(bodySpy.handleMousedown).toHaveBeenCalled(); @@ -566,68 +566,68 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) }); }); - it ("should present an event to capture listeners that are functions themselves when the event is at target", function() { + it ("should present an event to capture listeners that are functions themselves when the event is at target", function () { var bubbleCalled = false; - testDocument.documentElement.addEventListener("mousedown", function(evt) { + testDocument.documentElement.addEventListener("mousedown", function (evt) { expect(this).toBe(evt.currentTarget); bubbleCalled = true; }, true); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function () { expect(bubbleCalled).toBeTruthy(); }); }); - it ("should present an event to bubble listeners that are functions themselves during the capture phase", function() { + it ("should present an event to bubble listeners that are functions themselves during the capture phase", function () { var bubbleCalled = false; - testDocument.addEventListener("mousedown", function(evt) { + testDocument.addEventListener("mousedown", function (evt) { expect(this).toBe(evt.currentTarget); bubbleCalled = true; }, true); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function () { expect(bubbleCalled).toBeTruthy(); }); }); - it ("should present an event to bubble listeners that are functions themselves when the event is at target", function() { + it ("should present an event to bubble listeners that are functions themselves when the event is at target", function () { var bubbleCalled = false; - testDocument.documentElement.addEventListener("mousedown", function(evt) { + testDocument.documentElement.addEventListener("mousedown", function (evt) { expect(this).toBe(evt.currentTarget); bubbleCalled = true; }, false); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function () { expect(bubbleCalled).toBeTruthy(); }); }); - it ("should present an event to bubble listeners that are functions themselves during the event phase", function() { + it ("should present an event to bubble listeners that are functions themselves during the event phase", function () { var bubbleCalled = false; - testDocument.addEventListener("mousedown", function(evt) { + testDocument.addEventListener("mousedown", function (evt) { expect(this).toBe(evt.currentTarget); bubbleCalled = true; }, false); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function () { expect(bubbleCalled).toBeTruthy(); }); }); - it("must not present the event to the generic handler in a phase the listener has not registered in", function() { + it("must not present the event to the generic handler in a phase the listener has not registered in", function () { var eventCaptureSpy = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event.eventPhase).toBe(CAPTURING_PHASE); } }; var eventBubbleSpy = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event.eventPhase).toBe(BUBBLING_PHASE); } }; @@ -638,16 +638,16 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) testDocument.addEventListener("mousedown", eventCaptureSpy, true); testDocument.addEventListener("mousedown", eventBubbleSpy, false); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function () { expect(eventCaptureSpy.handleEvent).toHaveBeenCalled(); expect(eventBubbleSpy.handleEvent).toHaveBeenCalled(); }); }); - it("should present the event at the CAPTURING_PHASE when the current target is triggered during the capture phase and the current target is not the proximal target", function() { + it("should present the event at the CAPTURING_PHASE when the current target is triggered during the capture phase and the current target is not the proximal target", function () { var eventSpy = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event.eventPhase).toBe(CAPTURING_PHASE); } }; @@ -656,15 +656,15 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) testDocument.addEventListener("mousedown", eventSpy, true); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function () { expect(eventSpy.handleEvent).toHaveBeenCalled(); }); }); - it("should present the event at the AT_TARGET when the current target is the proximal target when the listener registered for the capture phase", function() { + it("should present the event at the AT_TARGET when the current target is the proximal target when the listener registered for the capture phase", function () { var eventSpy = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event.eventPhase).toBe(AT_TARGET); } }; @@ -673,15 +673,15 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) testDocument.addEventListener("mousedown", eventSpy, true); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument), "mousedown", function () { expect(eventSpy.handleEvent).toHaveBeenCalled(); }); }); - it("should present the event at the AT_TARGET when the current target is the proximal target when the listener registered for the bubble phase", function() { + it("should present the event at the AT_TARGET when the current target is the proximal target when the listener registered for the bubble phase", function () { var eventSpy = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event.eventPhase).toBe(AT_TARGET); } }; @@ -690,16 +690,16 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) testDocument.addEventListener("mousedown", eventSpy, false); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument), "mousedown", function () { expect(eventSpy.handleEvent).toHaveBeenCalled(); }); }); - it("should present the event at the BUBBLING_PHASE during the bubble phase and the current target is not the proximal target", function() { + it("should present the event at the BUBBLING_PHASE during the bubble phase and the current target is not the proximal target", function () { var eventSpy = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event.eventPhase).toBe(BUBBLING_PHASE); } }; @@ -708,16 +708,16 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) testDocument.addEventListener("mousedown", eventSpy, false); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument.body), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument.body), "mousedown", function () { expect(eventSpy.handleEvent).toHaveBeenCalled(); }); }); - it("must set the event phase as NONE after distribution", function() { + it("must set the event phase as NONE after distribution", function () { var event; var eventSpy = { - handleEvent: function(evt) { + handleEvent: function (evt) { event = evt; } }; @@ -726,24 +726,24 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) testDocument.addEventListener("mousedown", eventSpy, false); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument), "mousedown", function () { expect(eventSpy.handleEvent).toHaveBeenCalled(); }); expect(event.eventPhase).toBe(NONE); }); - describe("adding listeners during distribution", function() { + describe("adding listeners during distribution", function () { - it("should distribute the event if the added listener would receive the event after the point that it was added", function() { + it("should distribute the event if the added listener would receive the event after the point that it was added", function () { var lateAddedRootListener = { - handleEvent: function() { + handleEvent: function () { } }; var bodyListener = { - handleEvent: function() { + handleEvent: function () { testDocument.documentElement.addEventListener("mousedown", lateAddedRootListener, false); } }; @@ -753,7 +753,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) testDocument.body.addEventListener("mousedown", bodyListener, false); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument.body), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument.body), "mousedown", function () { expect(lateAddedRootListener.handleEvent).toHaveBeenCalled(); }); }); @@ -762,12 +762,12 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) }); - describe("with respect to the currentTarget property", function() { + describe("with respect to the currentTarget property", function () { - it("must set the currentTarget as null after distribution", function() { + it("must set the currentTarget as null after distribution", function () { var event; var eventSpy = { - handleEvent: function(evt) { + handleEvent: function (evt) { event = evt; } }; @@ -776,7 +776,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) testDocument.addEventListener("mousedown", eventSpy, false); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument), "mousedown", function () { expect(eventSpy.handleEvent).toHaveBeenCalled(); }); @@ -785,15 +785,15 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) }); - describe("with respect to handler method names", function() { + describe("with respect to handler method names", function () { - it("must not present the event to a generic handler function if a more specific eventType handler method is available", function() { + it("must not present the event to a generic handler function if a more specific eventType handler method is available", function () { var eventSpy = { - handleMousedown: function() { + handleMousedown: function () { }, - handleEvent: function() { + handleEvent: function () { } }; @@ -802,18 +802,18 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) testDocument.addEventListener("mousedown", eventSpy, false); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function () { expect(eventSpy.handleMousedown).toHaveBeenCalled(); expect(eventSpy.handleEvent).not.toHaveBeenCalled(); }); }); - it("should present the event to the generic handler if no specific handler is present, in either event phase", function() { + it("should present the event to the generic handler if no specific handler is present, in either event phase", function () { var handledEventCount = 0; var eventSpy = { - handleEvent: function() { + handleEvent: function () { handledEventCount++; } }; @@ -823,40 +823,40 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) testDocument.addEventListener("mousedown", eventSpy, false); testDocument.addEventListener("mousedown", eventSpy, true); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function () { expect(eventSpy.handleEvent).toHaveBeenCalled(); expect(handledEventCount).toBe(2); }); }); - describe("involving identifiers", function() { + describe("involving identifiers", function () { - beforeEach(function() { + beforeEach(function () { testDocument.documentElement.identifier = "foo"; }); - afterEach(function() { + afterEach(function () { delete testDocument.documentElement.identifier; }) - it("should handle the event using the identifier from the original target as part of the handler method name, for listeners on the original target", function() { + it("should handle the event using the identifier from the original target as part of the handler method name, for listeners on the original target", function () { var eventSpy = { - handleFooMousedown: function() {} + handleFooMousedown: function () {} }; spyOn(eventSpy, 'handleFooMousedown'); testDocument.documentElement.addEventListener("mousedown", eventSpy, false); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function () { expect(eventSpy.handleFooMousedown).toHaveBeenCalled(); }); }); - it("should handle the event using the identifier from the original target as part of the handler method name, for listeners along the distribution chain", function() { + it("should handle the event using the identifier from the original target as part of the handler method name, for listeners along the distribution chain", function () { var eventSpy = { - handleFooMousedown: function() {} + handleFooMousedown: function () {} }; spyOn(eventSpy, 'handleFooMousedown'); @@ -864,21 +864,21 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) testDocument.identifier = "document"; testDocument.addEventListener("mousedown", eventSpy, false); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function () { expect(eventSpy.handleFooMousedown).toHaveBeenCalled(); }); delete testDocument.identifier; }); - it("should handle the event using a less specific handler if the original target has no identifier, even if the currentTarget has an identifier", function() { + it("should handle the event using a less specific handler if the original target has no identifier, even if the currentTarget has an identifier", function () { var eventSpy = { - handleDocumentMousedown: function() { + handleDocumentMousedown: function () { }, - handleMousedown: function() { + handleMousedown: function () { } }; @@ -889,7 +889,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) testDocument.addEventListener("mousedown", eventSpy, false); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function () { expect(eventSpy.handleMousedown).toHaveBeenCalled(); expect(eventSpy.handleDocumentMousedown).not.toHaveBeenCalled(); }); @@ -897,9 +897,9 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) delete testDocument.identifier; }); - it("must not handle the event using an identifier based handler based on the current target, if it is not also the original event target", function() { + it("must not handle the event using an identifier based handler based on the current target, if it is not also the original event target", function () { var eventSpy = { - handleDocumentMousedown: function() {} + handleDocumentMousedown: function () {} }; spyOn(eventSpy, 'handleDocumentMousedown'); @@ -907,7 +907,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) testDocument.identifier = "document"; testDocument.addEventListener("mousedown", eventSpy, false); - testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function() { + testPage.mouseEvent(new EventInfo().initWithElement(testDocument.documentElement), "mousedown", function () { expect(eventSpy.handleDocumentMousedown).not.toHaveBeenCalled(); }); @@ -923,14 +923,14 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) bubbleCalled = false; var fooCaptureSpy = { - captureFoo: function() { + captureFoo: function () { expect(bubbleCalled).toBe(false); captureCalled = true; } }; var fooBubbleSpy = { - handleFoo: function() { + handleFoo: function () { expect(captureCalled).toBe(true); bubbleCalled = true; } @@ -958,14 +958,14 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) bubbleCalled = false; var fooCaptureSpy = { - captureFoo: function() { + captureFoo: function () { expect(bubbleCalled).toBe(false); captureCalled = true; } }; var fooBubbleSpy = { - handleFoo: function() { + handleFoo: function () { expect(captureCalled).toBe(true); bubbleCalled = true; } @@ -995,14 +995,14 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) bubbleCalled = false; var fooCaptureSpy = { - captureFoo: function() { + captureFoo: function () { expect(bubbleCalled).toBe(false); captureCalled = true; } }; var fooBubbleSpy = { - handleFoo: function() { + handleFoo: function () { expect(captureCalled).toBe(true); bubbleCalled = true; } @@ -1029,28 +1029,28 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) }); // TODO verify the desired behavior in edge cases - describe("when determining where to install a native event listener", function() { + describe("when determining where to install a native event listener", function () { - it("should install listeners on a document if the requested target is a window", function() { + it("should install listeners on a document if the requested target is a window", function () { var testWindow = testDocument.defaultView; var actualTarget = eventManager.actualDOMTargetForEventTypeOnTarget("mousedown", testWindow); expect(actualTarget).toBe(testDocument); }); - it("should install listeners on a document if the requested target is a document", function() { + it("should install listeners on a document if the requested target is a document", function () { var actualTarget = eventManager.actualDOMTargetForEventTypeOnTarget("mousedown", testDocument); expect(actualTarget).toBe(testDocument); }); - it("should install listeners on a document if the requested target is an element", function() { + it("should install listeners on a document if the requested target is an element", function () { var actualTarget = eventManager.actualDOMTargetForEventTypeOnTarget("mousedown", testDocument.documentElement); expect(actualTarget).toBe(testDocument); }); - it("should install listeners on the specified target if the eventType is 'load'", function() { + it("should install listeners on the specified target if the eventType is 'load'", function () { var actualTarget = eventManager.actualDOMTargetForEventTypeOnTarget("load", testDocument.documentElement); expect(actualTarget).toBe(testDocument.documentElement); @@ -1062,7 +1062,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) expect(actualTarget).toBe(testWindow); }); - it("should install listeners on the specified target if the eventType is 'resize'", function() { + it("should install listeners on the specified target if the eventType is 'resize'", function () { var actualTarget = eventManager.actualDOMTargetForEventTypeOnTarget("resize", testDocument.documentElement); expect(actualTarget).toBe(testDocument.documentElement); @@ -1076,23 +1076,23 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) }); - describe("elements' event handler support", function() { + describe("elements' event handler support", function () { var element; beforeEach(function () { element = testPage.querySelector("#element"); }); - afterEach(function() { + afterEach(function () { eventManager.unregisterEventHandlerForElement(element); }); - it("should install an event handler on an element", function() { + it("should install an event handler on an element", function () { var handler = {name: "handler"}; eventManager.registerEventHandlerForElement(handler, element); expect(eventManager.eventHandlerForElement(element)).toBe(handler); }); - it("should uninstall an event handler on an element", function() { + it("should uninstall an event handler on an element", function () { var handler = {name: "handler"}; eventManager.registerEventHandlerForElement(handler, element); @@ -1101,7 +1101,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) expect(eventManager._elementEventHandlerByUUID[handler.uuid]).toBeUndefined(); }); - it("should override an element's previous event handler", function() { + it("should override an element's previous event handler", function () { var handler1 = {name: "handler1"}, handler2 = {name: "handler2"}; @@ -1112,7 +1112,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) expect(eventManager._elementEventHandlerByUUID[handler1.uuid]).toBeUndefined(); }); - it("should install an event handler on an element after the previous one has been uninstalled", function() { + it("should install an event handler on an element after the previous one has been uninstalled", function () { var handler1 = {name: "handler1"}, handler2 = {name: "handler2"}; @@ -1123,8 +1123,8 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) }); }); - describe("serialization", function() { - it("should call \"listeners\" deserialization unit", function() { + describe("serialization", function () { + it("should call \"listeners\" deserialization unit", function () { var sourceObject = new Target(), handlerObject = new Montage(), serializer = new Serializer().initWithRequire(require), @@ -1142,7 +1142,7 @@ TestPageLoader.queueTest("eventmanagertest/eventmanagertest", function(testPage) spyOn(MontageReviver._unitRevivers, "listeners").andCallThrough(); return deserializer.deserialize(labels) - .then(function(objects) { + .then(function (objects) { object = objects.root; expect(MontageReviver._unitRevivers.listeners).toHaveBeenCalled(); }); diff --git a/test/events/eventmanagertest/eventmanagertest.js b/test/events/eventmanagertest/eventmanagertest.js index 0d53ff6703..1ddde7d0b4 100644 --- a/test/events/eventmanagertest/eventmanagertest.js +++ b/test/events/eventmanagertest/eventmanagertest.js @@ -33,7 +33,7 @@ var Montage = require("montage").Montage, var EventManagerTest = exports.EventManagerTest = Montage.specialize( { deserializedFromTemplate: { - value: function() { + value: function () { var dummyComponent = new Component(); dummyComponent.hasTemplate = false; dummyComponent.element = document.body; diff --git a/test/events/mutable-event-spec.js b/test/events/mutable-event-spec.js index 33190ad5c0..4ac1d66959 100644 --- a/test/events/mutable-event-spec.js +++ b/test/events/mutable-event-spec.js @@ -32,13 +32,13 @@ var Montage = require("montage").Montage; var MutableEvent = require("montage/core/event/mutable-event").MutableEvent; var Target = require("montage/core/target").Target; -describe("events/mutable-event-spec", function() { +describe("events/mutable-event-spec", function () { - describe("custom events using fromType", function() { + describe("custom events using fromType", function () { var type, target, listener, event; - beforeEach(function() { + beforeEach(function () { type = "myCustomEventType"; listener = {}; target = new Target(); @@ -46,30 +46,30 @@ describe("events/mutable-event-spec", function() { target.addEventListener(type, listener); }); - afterEach(function() { + afterEach(function () { spyOn(listener, "handleEvent").andCallThrough(); target.dispatchEvent(event); expect(listener.handleEvent).toHaveBeenCalledWith(event); }); - it("should preserve target upon dispatching", function() { - listener.handleEvent = function(evt) { + it("should preserve target upon dispatching", function () { + listener.handleEvent = function (evt) { expect(evt.target).toBe(target); } event = MutableEvent.fromType(type); }); - it("should preserve type upon dispatching", function() { - listener.handleEvent = function(evt) { + it("should preserve type upon dispatching", function () { + listener.handleEvent = function (evt) { expect(evt.type).toBe(type); } event = MutableEvent.fromType(type); }); - it("should preserve custom properties upon dispatching", function() { - listener.handleEvent = function(evt) { + it("should preserve custom properties upon dispatching", function () { + listener.handleEvent = function (evt) { expect(evt.foo).toBe("foo in properties"); } @@ -77,8 +77,8 @@ describe("events/mutable-event-spec", function() { event.foo = "foo in properties"; }); - it("should preserve detail upon dispatching", function() { - listener.handleEvent = function(evt) { + it("should preserve detail upon dispatching", function () { + listener.handleEvent = function (evt) { expect(evt.detail.foo).toBe("foo in detail"); } @@ -87,32 +87,32 @@ describe("events/mutable-event-spec", function() { }); }); - it("should preserve truthy canBubble upon dispatching", function() { - listener.handleEvent = function(evt) { + it("should preserve truthy canBubble upon dispatching", function () { + listener.handleEvent = function (evt) { expect(evt.canBubble).toBeTruthy; } event = MutableEvent.fromType(type, true); }); - it("should preserve falsy canBubble upon dispatching", function() { - listener.handleEvent = function(evt) { + it("should preserve falsy canBubble upon dispatching", function () { + listener.handleEvent = function (evt) { expect(evt.canBubble).toBeFalsy; } event = MutableEvent.fromType(type, false); }); - it("should preserve truthy cancelability upon dispatching", function() { - listener.handleEvent = function(evt) { + it("should preserve truthy cancelability upon dispatching", function () { + listener.handleEvent = function (evt) { expect(evt.cancelable).toBeTruthy; } event = MutableEvent.fromType(type, false, true); }); - it("should preserve falsy cancelability upon dispatching", function() { - listener.handleEvent = function(evt) { + it("should preserve falsy cancelability upon dispatching", function () { + listener.handleEvent = function (evt) { expect(evt.cancelable).toBeFalsy; } @@ -120,11 +120,11 @@ describe("events/mutable-event-spec", function() { }); }); - describe("custom events using dispatchEventNamed", function() { + describe("custom events using dispatchEventNamed", function () { var type, target, listener, event; - beforeEach(function() { + beforeEach(function () { type = "myCustomEventType"; listener = {}; target = new Target(); @@ -132,12 +132,12 @@ describe("events/mutable-event-spec", function() { target.addEventListener(type, listener); }); - afterEach(function() { + afterEach(function () { expect(listener.handleEvent).toHaveBeenCalled(); }); - it("should preserve target upon dispatching", function() { - listener.handleEvent = function(evt) { + it("should preserve target upon dispatching", function () { + listener.handleEvent = function (evt) { expect(evt.target).toBe(target); } @@ -145,8 +145,8 @@ describe("events/mutable-event-spec", function() { target.dispatchEventNamed(type); }); - it("should preserve type upon dispatching", function() { - listener.handleEvent = function(evt) { + it("should preserve type upon dispatching", function () { + listener.handleEvent = function (evt) { expect(evt.type).toBe(type); } @@ -154,8 +154,8 @@ describe("events/mutable-event-spec", function() { target.dispatchEventNamed(type); }); - it("should preserve detail upon dispatching", function() { - listener.handleEvent = function(evt) { + it("should preserve detail upon dispatching", function () { + listener.handleEvent = function (evt) { expect(evt.detail.foo).toBe("foo in detail"); } @@ -165,8 +165,8 @@ describe("events/mutable-event-spec", function() { }); }); - it("should preserve truthy canBubble upon dispatching", function() { - listener.handleEvent = function(evt) { + it("should preserve truthy canBubble upon dispatching", function () { + listener.handleEvent = function (evt) { expect(evt.canBubble).toBeTruthy; } @@ -174,8 +174,8 @@ describe("events/mutable-event-spec", function() { target.dispatchEventNamed(type, true); }); - it("should preserve falsy canBubble upon dispatching", function() { - listener.handleEvent = function(evt) { + it("should preserve falsy canBubble upon dispatching", function () { + listener.handleEvent = function (evt) { expect(evt.canBubble).toBeFalsy; } @@ -183,8 +183,8 @@ describe("events/mutable-event-spec", function() { target.dispatchEventNamed(type, false); }); - it("should preserve truthy cancelability upon dispatching", function() { - listener.handleEvent = function(evt) { + it("should preserve truthy cancelability upon dispatching", function () { + listener.handleEvent = function (evt) { expect(evt.cancelable).toBeTruthy; } @@ -192,8 +192,8 @@ describe("events/mutable-event-spec", function() { target.dispatchEventNamed(type, false, true); }); - it("should preserve falsy cancelability upon dispatching", function() { - listener.handleEvent = function(evt) { + it("should preserve falsy cancelability upon dispatching", function () { + listener.handleEvent = function (evt) { expect(evt.cancelable).toBeFalsy; } @@ -205,7 +205,7 @@ describe("events/mutable-event-spec", function() { - describe("methods", function() { + describe("methods", function () { var event; beforeEach(function () { event = MutableEvent.fromType("mousedown"); diff --git a/test/events/object-hierarchy-spec.js b/test/events/object-hierarchy-spec.js index dbf3f1ae3f..dc5ee699ab 100644 --- a/test/events/object-hierarchy-spec.js +++ b/test/events/object-hierarchy-spec.js @@ -32,12 +32,12 @@ var Montage = require("montage").Montage; var Component = require("montage/ui/component").Component; var TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; -TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function(testPage) { - describe("events/object-hierarchy-spec", function() { +TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function (testPage) { + describe("events/object-hierarchy-spec", function () { var eventManager, parent, testApplication, testTarget; - beforeEach(function() { + beforeEach(function () { var testWindow = testPage.iframe.contentWindow; var testDocument = testPage.iframe.contentDocument; testTarget = testDocument.defaultView.mr.getPackage({name: "montage"})("core/target").Target; @@ -46,14 +46,14 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function eventManager.reset(); }); - describe("handling events throughout the object hierarchy", function() { + describe("handling events throughout the object hierarchy", function () { var orphan, childFoo, childBar, grandchildFoo, bubbleEvent, orphanListener, childFooListener, childBarListener, grandchildFooListener, parentListener; - beforeEach(function() { + beforeEach(function () { // We need to use the testMontage as the base so the global defaultEventManager is the testEventManager // from the test iframe, not the global defaultEventManager of the test parent = new testTarget(); @@ -74,15 +74,15 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function bubbleEvent.initCustomEvent("bubbleEvent", true, false, null); }); - describe("during the capture phase", function() { + describe("during the capture phase", function () { - it("should distribute the event to listeners observing the parent of the target object if the event does not bubble", function() { + it("should distribute the event to listeners observing the parent of the target object if the event does not bubble", function () { bubbleEvent = window.document.createEvent("CustomEvent"); bubbleEvent.initCustomEvent("bubbleEvent", false, false, null); parentListener = { - handleEvent: function() {} + handleEvent: function () {} }; parent.addEventListener("bubbleEvent", parentListener, true); @@ -93,10 +93,10 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function expect(parentListener.handleEvent).toHaveBeenCalled(); }); - it("should distribute the event to listeners observing the target object", function() { + it("should distribute the event to listeners observing the target object", function () { childFooListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); } }; @@ -109,10 +109,10 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function expect(childFooListener.handleEvent).toHaveBeenCalled(); }); - it("should distribute the event to listeners observing the parent of the target object", function() { + it("should distribute the event to listeners observing the parent of the target object", function () { parentListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); } }; @@ -125,10 +125,10 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function expect(parentListener.handleEvent).toHaveBeenCalled(); }); - it("should distribute the event to listeners observing the application", function() { + it("should distribute the event to listeners observing the application", function () { var applicationListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); } }; @@ -142,12 +142,12 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function expect(applicationListener.handleEvent).toHaveBeenCalled(); }); - it("should distribute the event all listeners from the target to the top-most parent in order", function() { + it("should distribute the event all listeners from the target to the top-most parent in order", function () { var handledCount = 0; childFooListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); expect(handledCount).toBe(1); handledCount++; @@ -155,7 +155,7 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function }; parentListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); expect(handledCount).toBe(0); handledCount++; @@ -176,15 +176,15 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function }); - describe("during the bubble phase", function() { + describe("during the bubble phase", function () { - it("must not distribute the event to listeners observing the parent of the target object if the event does not bubble", function() { + it("must not distribute the event to listeners observing the parent of the target object if the event does not bubble", function () { bubbleEvent = window.document.createEvent("CustomEvent"); bubbleEvent.initCustomEvent("bubbleEvent", false, false, null); parentListener = { - handleEvent: function() {} + handleEvent: function () {} }; parent.addEventListener("bubbleEvent", parentListener, false); @@ -195,10 +195,10 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function expect(parentListener.handleEvent).not.toHaveBeenCalled(); }); - it("should distribute the event to listeners observing the target object", function() { + it("should distribute the event to listeners observing the target object", function () { childFooListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); } }; @@ -211,10 +211,10 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function expect(childFooListener.handleEvent).toHaveBeenCalled(); }); - it("should distribute the event to listeners observing the parent of the target object", function() { + it("should distribute the event to listeners observing the parent of the target object", function () { parentListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); } }; @@ -227,10 +227,10 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function expect(parentListener.handleEvent).toHaveBeenCalled(); }); - it("should distribute the event to listeners observing the application", function() { + it("should distribute the event to listeners observing the application", function () { var applicationListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); } }; @@ -243,12 +243,12 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function expect(applicationListener.handleEvent).toHaveBeenCalled(); }); - it("should distribute the event all listeners from the target to the top-most parent in order", function() { + it("should distribute the event all listeners from the target to the top-most parent in order", function () { var handledCount = 0; childFooListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); expect(handledCount).toBe(0); handledCount++; @@ -256,7 +256,7 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function }; parentListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); expect(handledCount).toBe(1); handledCount++; @@ -276,17 +276,17 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function }); }); - it("should distribute the event to the entire chain of registered event listeners in the expected order", function() { + it("should distribute the event to the entire chain of registered event listeners in the expected order", function () { var handledCount = 0; parentListener = { - captureBubbleEvent: function(event) { + captureBubbleEvent: function (event) { expect(event._event).toBe(bubbleEvent); expect(handledCount).toBe(0); handledCount++; }, - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); expect(handledCount).toBe(5); handledCount++; @@ -294,13 +294,13 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function }; childFooListener = { - captureBubbleEvent: function(event) { + captureBubbleEvent: function (event) { expect(event._event).toBe(bubbleEvent); expect(handledCount).toBe(1); handledCount++; }, - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); expect(handledCount).toBe(4); handledCount++; @@ -308,13 +308,13 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function }; grandchildFooListener = { - captureBubbleEvent: function(event) { + captureBubbleEvent: function (event) { expect(event._event).toBe(bubbleEvent); expect(handledCount).toBe(2); handledCount++; }, - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); expect(handledCount).toBe(3); handledCount++; @@ -353,11 +353,11 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function }); - describe("handling events throughout the component hierarchy", function() { + describe("handling events throughout the component hierarchy", function () { var parent, child, bubbleEvent; - beforeEach(function() { + beforeEach(function () { parent = testPage.test.component1; child = parent.childComponents[0]; @@ -365,20 +365,20 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function bubbleEvent.initCustomEvent("bubbleEvent", true, false, null); }); - it("should have a default nextTarget of the parentComponent on all components", function() { + it("should have a default nextTarget of the parentComponent on all components", function () { var component = new Component(); expect(component.nextTarget).toBe(component.parentComponent); }); - describe("during the capture phase", function() { + describe("during the capture phase", function () { - it("should distribute the event to listeners observing the parent of the target object if the event does not bubble", function() { + it("should distribute the event to listeners observing the parent of the target object if the event does not bubble", function () { bubbleEvent = window.document.createEvent("CustomEvent"); bubbleEvent.initCustomEvent("bubbleEvent", false, false, null); var parentListener = { - handleEvent: function() {} + handleEvent: function () {} }; parent.addEventListener("bubbleEvent", parentListener, true); @@ -389,10 +389,10 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function expect(parentListener.handleEvent).toHaveBeenCalled(); }); - it("should distribute the event to listeners observing the target component", function() { + it("should distribute the event to listeners observing the target component", function () { var childListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); } }; @@ -405,10 +405,10 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function expect(childListener.handleEvent).toHaveBeenCalled(); }); - it("should distribute the event to listeners observing the parent of the target object", function() { + it("should distribute the event to listeners observing the parent of the target object", function () { var parentListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); } }; @@ -421,10 +421,10 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function expect(parentListener.handleEvent).toHaveBeenCalled(); }); - it("should distribute the event to listeners observing the application", function() { + it("should distribute the event to listeners observing the application", function () { var applicationListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); } }; @@ -437,12 +437,12 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function expect(applicationListener.handleEvent).toHaveBeenCalled(); }); - it("should distribute the event all listeners from the target to the top-most parent in order", function() { + it("should distribute the event all listeners from the target to the top-most parent in order", function () { var handledCount = 0; var childListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); expect(handledCount).toBe(1); handledCount++; @@ -450,7 +450,7 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function }; var parentListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); expect(handledCount).toBe(0); handledCount++; @@ -471,15 +471,15 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function }); - describe("during the bubble phase", function() { + describe("during the bubble phase", function () { - it("must not distribute the event to listeners observing the parent of the target object if the event does not bubble", function() { + it("must not distribute the event to listeners observing the parent of the target object if the event does not bubble", function () { bubbleEvent = window.document.createEvent("CustomEvent"); bubbleEvent.initCustomEvent("bubbleEvent", false, false, null); var parentListener = { - handleEvent: function() { + handleEvent: function () { } }; @@ -491,10 +491,10 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function expect(parentListener.handleEvent).not.toHaveBeenCalled(); }); - it("should distribute the event to listeners observing the target object", function() { + it("should distribute the event to listeners observing the target object", function () { var childListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); } }; @@ -507,10 +507,10 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function expect(childListener.handleEvent).toHaveBeenCalled(); }); - it("should distribute the event to listeners observing the parent of the target object", function() { + it("should distribute the event to listeners observing the parent of the target object", function () { var parentListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); } }; @@ -523,10 +523,10 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function expect(parentListener.handleEvent).toHaveBeenCalled(); }); - it("should distribute the event to listeners observing the application", function() { + it("should distribute the event to listeners observing the application", function () { var applicationListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); } }; @@ -539,12 +539,12 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function expect(applicationListener.handleEvent).toHaveBeenCalled(); }); - it("should distribute the event all listeners from the target to the top-most parent in order", function() { + it("should distribute the event all listeners from the target to the top-most parent in order", function () { var handledCount = 0; var childListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); expect(handledCount).toBe(0); handledCount++; @@ -552,7 +552,7 @@ TestPageLoader.queueTest("object-hierarchy-test/object-hierarchy-test", function }; var parentListener = { - handleEvent: function(event) { + handleEvent: function (event) { expect(event._event).toBe(bubbleEvent); expect(handledCount).toBe(1); handledCount++; diff --git a/test/gate-spec.js b/test/gate-spec.js index 3f5d94b6eb..b54fc50495 100644 --- a/test/gate-spec.js +++ b/test/gate-spec.js @@ -32,20 +32,20 @@ var Montage = require("montage").Montage, Gate = require("montage/core/gate").Gate; describe("gate-spec", -function() { +function () { describe("creating empty gate", - function() { + function () { var gate = new Gate().init(); it("should be true", - function() { + function () { expect(gate.value).toBeTruthy(); }); }); describe("creation with four false fields", - function() { + function () { var gate; - beforeEach(function() { + beforeEach(function () { gate = new Gate().initWithDescriptor({ A: { value: false @@ -63,43 +63,43 @@ function() { }); it("should have the expected false field count", - function() { + function () { expect(gate.count).toEqual(4); }); describe("set one of its fields to true", - function() { - beforeEach(function() { + function () { + beforeEach(function () { gate.setField("B",true); }); - afterEach(function() { + afterEach(function () { gate.setField("B",false); }); it("should be false", - function() { + function () { expect(gate.value).toBeFalsy(); }); }); describe("set all of its fields to true", - function() { - beforeEach(function() { + function () { + beforeEach(function () { gate.setField("A",true); gate.setField("B",true); gate.setField("C",true); gate.setField("D",true); }); it("should be true", - function() { + function () { expect(gate.value).toBeTruthy(); }); describe("add a false field", - function() { - beforeEach(function() { + function () { + beforeEach(function () { gate.setField("E"); }); it("should be false", - function() { + function () { expect(gate.value).toBeFalsy(); }); }); diff --git a/test/geometry/cubicbezier-spec.js b/test/geometry/cubicbezier-spec.js index f2029decb1..b7d0156fe6 100644 --- a/test/geometry/cubicbezier-spec.js +++ b/test/geometry/cubicbezier-spec.js @@ -33,17 +33,17 @@ var Montage = require("montage").Montage, CubicBezier = require("montage/core/geometry/cubic-bezier").CubicBezier; describe("geometry/cubicbezier-spec", -function() { +function () { describe("creation with no args", - function() { + function () { var cubicBezier; - beforeEach(function() { + beforeEach(function () { cubicBezier = new CubicBezier(); }); it("should be a linear CubicBezier", - function() { + function () { expect(cubicBezier.p0).toEqual(new Point().init(0, 0)); expect(cubicBezier.p1).toEqual(new Point().init(0, 0)); expect(cubicBezier.p2).toEqual(new Point().init(1, 1)); @@ -51,21 +51,21 @@ function() { }); }); describe("position along curve", - function() { + function () { var cubicBezier; - beforeEach(function() { + beforeEach(function () { cubicBezier = CubicBezier.create(CubicBezier).init([new Point().init(.42, 0), new Point().init(.58, 1)]); }); it("is undefined @ t < 1 & t > 1", - function() { + function () { expect(cubicBezier.position( - 1)).not.toBeDefined(); expect(cubicBezier.position( 2)).not.toBeDefined(); }); it("is correct", - function() { + function () { expect(cubicBezier.position(0)).toEqual(new Point().init(0, 0)); expect(cubicBezier.position(0.1)).toEqual(new Point().init(.11871999999999998, .02799999999999999)); expect(cubicBezier.position(0.5)).toEqual(new Point().init(.5, .5)); @@ -74,16 +74,16 @@ function() { }); }); describe("makeScaffolding for curve", - function() { + function () { var cubicBezier; - beforeEach(function() { + beforeEach(function () { cubicBezier = CubicBezier.create(CubicBezier).init([new Point().init(.42, 0), new Point().init(.58, 1)]); cubicBezier.makeScaffolding(.25); }); it("is correct", - function() { + function () { expect(cubicBezier.p01).toEqual(new Point().init(.315, 0)); expect(cubicBezier.p12).toEqual(new Point().init(.54, .75)); expect(cubicBezier.p23).toEqual(new Point().init(.895, 1)); @@ -93,16 +93,16 @@ function() { }); }); describe("split for curve", - function() { + function () { var cubicBezier; - beforeEach(function() { + beforeEach(function () { cubicBezier = cubicBezier = CubicBezier.create(CubicBezier).init([new Point().init(.42, 0), new Point().init(.58, 1)]); cubicBezier = cubicBezier.split(.25); }); it("is correct", - function() { + function () { expect(cubicBezier.p0).toEqual(new Point().init(0, 0)); expect(cubicBezier.p1).toEqual(new Point().init(.315, 0)); expect(cubicBezier.p2).toEqual(new Point().init(.48375, .5625)); @@ -110,16 +110,16 @@ function() { }); }); describe("splitToTimingFunction for curve", - function() { + function () { var cubicBezier; - beforeEach(function() { + beforeEach(function () { cubicBezier = cubicBezier = CubicBezier.create(CubicBezier).init([new Point().init(.42, 0), new Point().init(.58, 1)]); cubicBezier = cubicBezier.splitToTimingFunction(.25); }); it("is correct", - function() { + function () { expect(cubicBezier.p0).toEqual(new Point().init(0, 0)); expect(cubicBezier.p1).toEqual(new Point().init(.434108527131783, 0)); expect(cubicBezier.p2).toEqual(new Point().init(.6666666666666667, .6666666666666666)); diff --git a/test/geometry/point-spec.js b/test/geometry/point-spec.js index 3acbe77c67..0393554355 100644 --- a/test/geometry/point-spec.js +++ b/test/geometry/point-spec.js @@ -33,34 +33,34 @@ var Montage = require("montage").Montage, describe("geometry/point-spec", -function() { +function () { describe("create", - function() { + function () { describe("no arguments", - function() { + function () { var point; - beforeEach(function() { + beforeEach(function () { point = new Point(); }); it("should be origin", - function() { + function () { expect(point).not.toBeNull(); expect(point.x).toBe(0); expect(point.y).toBe(0); }); }); describe("with x and y", - function() { + function () { var point; - beforeEach(function() { + beforeEach(function () { point = new Point().init(10, 20); }); it("should be (x, y)", - function() { + function () { expect(point).not.toBeNull(); expect(point.x).toBe(10); expect(point.y).toBe(20); @@ -69,17 +69,17 @@ function() { }); describe("interpolate between points", - function() { + function () { describe("(0, 0) and (0, 0)", - function() { + function () { var points; - beforeEach(function() { + beforeEach(function () { points = [new Point().init(0, 0), new Point().init(0, 0)]; }); it("is correct positions", - function() { + function () { var newPoint = Point.interpolate(.75, points[0], points[1]); expect(newPoint.x).toBe(0); expect(newPoint.y).toBe(0); @@ -89,15 +89,15 @@ function() { }); }); describe("arbitrary", - function() { + function () { var points; - beforeEach(function() { + beforeEach(function () { points = [new Point().init(10, -10), new Point().init(-20, 10)]; }); it("is correct positions", - function() { + function () { var newPoint = Point.interpolate(.25, points[0], points[1]); expect(newPoint.x).toBe(2.5); expect(newPoint.y).toBe(-5); @@ -107,15 +107,15 @@ function() { }); }); describe("arbitrary with specified precision", - function() { + function () { var points; - beforeEach(function() { + beforeEach(function () { points = [new Point().init(.315, 0), new Point().init(.54, .75)]; }); it("is correct positions", - function() { + function () { var newPoint = Point.interpolate(.25, points[0], points[1]); expect(newPoint.x).toBe(.37125); newPoint = Point.interpolate(.25, points[0], points[1], 10); diff --git a/test/logger-spec.js b/test/logger-spec.js index 461f59e5b0..108de37bff 100644 --- a/test/logger-spec.js +++ b/test/logger-spec.js @@ -32,29 +32,29 @@ var Montage = require("montage").Montage, loggerRequire = require("montage/core/logger"); describe("logger-spec", -function() { +function () { describe("get a logger", - function() { + function () { it("shoud be the same logger for the same name", - function() { + function () { var loggerA = loggerRequire.logger("testMyName", null, true); var loggerB = loggerRequire.logger("testMyName", null, true); expect(loggerA).toBe(loggerB); }); }); describe("defaults", - function() { + function () { it("should be disabled by default", - function() { + function () { var loggerA = loggerRequire.logger("testLogger", null, true); expect(loggerA.isDebug).toBeFalsy(); expect(loggerA.isError).toBeTruthy(); }); }); describe("activation", - function() { + function () { it("should activated by assigning truthy value", - function() { + function () { var loggerA = loggerRequire.logger("testLogger2", null, true); expect(loggerA.isDebug).toBeFalsy(); loggerA.isDebug = true; diff --git a/test/meta/blueprint/binderhelper.js b/test/meta/blueprint/binderhelper.js index 0b5929a5ba..ec32474226 100644 --- a/test/meta/blueprint/binderhelper.js +++ b/test/meta/blueprint/binderhelper.js @@ -11,7 +11,7 @@ exports.companyBinder = function () { exports.BinderHelper = Montage.specialize( { }, { companyBinder: { - value: function() { + value: function () { var companyBinder = new Binder().initWithNameAndRequire("CompanyBinder", self.mr); var personBlueprint = companyBinder.addBlueprintNamed("Person", "meta/blueprint/person"); diff --git a/test/meta/component-blueprint-test/component-blueprint-test-1.reel/component-blueprint-test-1.js b/test/meta/component-blueprint-test/component-blueprint-test-1.reel/component-blueprint-test-1.js index dce8f20e36..8da2e95ff1 100644 --- a/test/meta/component-blueprint-test/component-blueprint-test-1.reel/component-blueprint-test-1.js +++ b/test/meta/component-blueprint-test/component-blueprint-test-1.reel/component-blueprint-test-1.js @@ -6,13 +6,13 @@ var Montage = require("montage").Montage, var ComponentBlueprintTest1 = exports.ComponentBlueprintTest1 = Component.specialize( { templateDidLoad: { - value: function() { + value: function () { //console.log("Component Blueprint Test 1 template did load"); } }, deserializedFromTemplate: { - value: function() { + value: function () { //console.log("Component Blueprint Test 1 deserialized from template"); } } diff --git a/test/meta/component-blueprint-test/component-blueprint-test-2.reel/component-blueprint-test-2.js b/test/meta/component-blueprint-test/component-blueprint-test-2.reel/component-blueprint-test-2.js index b645525b1c..f8fbae0857 100644 --- a/test/meta/component-blueprint-test/component-blueprint-test-2.reel/component-blueprint-test-2.js +++ b/test/meta/component-blueprint-test/component-blueprint-test-2.reel/component-blueprint-test-2.js @@ -6,13 +6,13 @@ var Montage = require("montage").Montage, var ComponentBlueprintTest2 = exports.ComponentBlueprintTest2 = Component.specialize( { templateDidLoad: { - value: function() { + value: function () { //console.log("Component Blueprint Test 2 template did load"); } }, deserializedFromTemplate: { - value: function() { + value: function () { //console.log("Component Blueprint Test 2 deserialized from template"); } } diff --git a/test/meta/component-blueprint-test/component-blueprint-test-3.reel/component-blueprint-test-3.js b/test/meta/component-blueprint-test/component-blueprint-test-3.reel/component-blueprint-test-3.js index 24f6759e78..c52af8aac4 100644 --- a/test/meta/component-blueprint-test/component-blueprint-test-3.reel/component-blueprint-test-3.js +++ b/test/meta/component-blueprint-test/component-blueprint-test-3.reel/component-blueprint-test-3.js @@ -6,13 +6,13 @@ var Montage = require("montage").Montage, var ComponentBlueprintTest3 = exports.ComponentBlueprintTest3 = Component.specialize( { templateDidLoad: { - value: function() { + value: function () { //console.log("Component Blueprint Test 3 template did load"); } }, deserializedFromTemplate: { - value: function() { + value: function () { //console.log("Component Blueprint Test 3 deserialized from template"); } }, diff --git a/test/meta/component-blueprint-test/component-blueprint-test.js b/test/meta/component-blueprint-test/component-blueprint-test.js index 5b7f42013c..44da3dfda8 100644 --- a/test/meta/component-blueprint-test/component-blueprint-test.js +++ b/test/meta/component-blueprint-test/component-blueprint-test.js @@ -6,7 +6,7 @@ var Montage = require("montage").Montage, var ComponentBlueprintTest = exports. ComponentBlueprintTest = Component.specialize( { init: { - value: function() { + value: function () { return this; } }, @@ -55,5 +55,5 @@ var ComponentBlueprintTest = exports. ComponentBlueprintTest = Component.specia enumerable: false, value: null } - + }); diff --git a/test/meta/controller-blueprint-test/parent-controller.js b/test/meta/controller-blueprint-test/parent-controller.js index c12b1fcdfb..0fff79c3c5 100644 --- a/test/meta/controller-blueprint-test/parent-controller.js +++ b/test/meta/controller-blueprint-test/parent-controller.js @@ -7,7 +7,7 @@ var ParentController = exports.ParentController = ObjectController.specialize( init: { - value: function() { + value: function () { return this; } }, diff --git a/test/meta/controller-blueprint-test/test-controller.js b/test/meta/controller-blueprint-test/test-controller.js index 4326c3adbd..233eef43c9 100644 --- a/test/meta/controller-blueprint-test/test-controller.js +++ b/test/meta/controller-blueprint-test/test-controller.js @@ -6,7 +6,7 @@ var Montage = require("montage").Montage, var TestController = exports.TestController = ObjectController.specialize( { init: { - value: function() { + value: function () { return this; } }, diff --git a/test/meta/event-blueprint-spec.js b/test/meta/event-blueprint-spec.js index e10e5b6194..5e8138a208 100644 --- a/test/meta/event-blueprint-spec.js +++ b/test/meta/event-blueprint-spec.js @@ -38,7 +38,7 @@ describe("meta/event-blueprint-spec", function () { describe("serialization", function () { var serializer, blueprintSerialization; - beforeEach(function() { + beforeEach(function () { blueprintSerialization = { "root": { "prototype": "montage/core/meta/event-blueprint", @@ -54,7 +54,7 @@ describe("meta/event-blueprint-spec", function () { serializer.setSerializationIndentation(4); }); - it("should serialize correctly", function() { + it("should serialize correctly", function () { var expectedSerialization, serialization; diff --git a/test/meta/module-blueprint-spec.js b/test/meta/module-blueprint-spec.js index 0ae90154b4..cf6cd45d94 100644 --- a/test/meta/module-blueprint-spec.js +++ b/test/meta/module-blueprint-spec.js @@ -40,12 +40,12 @@ describe("meta/module-blueprint-spec", function () { describe("serialization", function () { var serializer; - beforeEach(function() { + beforeEach(function () { serializer = new Serializer().initWithRequire(require); serializer.setSerializationIndentation(4); }); - it("should serialize correctly", function() { + it("should serialize correctly", function () { var expectedSerialization, serialization; diff --git a/test/mocks/component.js b/test/mocks/component.js index d96877f357..702639e0a4 100644 --- a/test/mocks/component.js +++ b/test/mocks/component.js @@ -40,7 +40,7 @@ exports.component = function () { eventListeners[eventType].push(listener); }, removeEventListener: function () {}, - dispatchEvent: function(event) { + dispatchEvent: function (event) { var type = event.type, listeners, names, @@ -71,14 +71,14 @@ exports.component = function () { } } }, - hasEventListener: function(eventType, listener) { + hasEventListener: function (eventType, listener) { return !!(eventListeners[eventType] && eventListeners[eventType].indexOf(listener) >= 0); }, childComponents: [], addChildComponent: Component.prototype.addChildComponent, removeChildComponent: Function.noop, - _addToDrawList: function() {} + _addToDrawList: function () {} }; }; @@ -87,9 +87,9 @@ exports.rootComponent = function (_document) { defaultEventManager.registerEventHandlerForElement(component, _document); component.element = _document; - component.drawTree = function() {}; + component.drawTree = function () {}; component.rootComponent = component; - component.isComponentWaitingNeedsDraw = function() { return false; } + component.isComponentWaitingNeedsDraw = function () { return false; } return component; }; diff --git a/test/mocks/dom.js b/test/mocks/dom.js index 8123479138..994390fea0 100644 --- a/test/mocks/dom.js +++ b/test/mocks/dom.js @@ -26,7 +26,7 @@ var EventTarget = { } listeners.splice(listenerIndex, 1); }, - dispatchEvent: function(event) { + dispatchEvent: function (event) { var type = event.type, listeners, names, @@ -57,7 +57,7 @@ var EventTarget = { } } }, - hasEventListener: function(eventType, listener) { + hasEventListener: function (eventType, listener) { return !!(this._eventListeners[eventType] && this._eventListeners[eventType].indexOf(listener) >= 0); } @@ -105,14 +105,14 @@ exports.element = function (_document) { return attribute in this.__attributes__; }, childNodes: [], - appendChild: function(child) { + appendChild: function (child) { if (child.parentNode) { child.parentNode.removeChild(child); } this.childNodes.push(child); child.parentNode = this; }, - removeChild: function(child) { + removeChild: function (child) { var ix = this.childNodes.indexOf(child); if (ix >= 0) { @@ -122,7 +122,7 @@ exports.element = function (_document) { } child.parentNode = null; }, - contains: function(child) { + contains: function (child) { do { if (child === this) { return true; @@ -131,7 +131,7 @@ exports.element = function (_document) { return false; }, - getElementsByTagName: function(tagName) { + getElementsByTagName: function (tagName) { var elements = []; for (var i=0;i'); - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should initialize document and objects with a document", function() { + it("should initialize document and objects with a document", function () { var html = require("reel/template/simple-template.html").content, htmlDocument = document.implementation.createHTMLDocument(""), expectedObjects = { @@ -93,7 +93,7 @@ describe("reel/template-spec", function() { htmlDocument.documentElement.innerHTML = html; return template.initWithDocument(htmlDocument) - .then(function() { + .then(function () { var children = template.document.body.children, objects = JSON.parse(template.objectsString); @@ -101,12 +101,12 @@ describe("reel/template-spec", function() { expect(children.length).toBe(1); // there must be a better way to compare DOM tree's... expect(children[0].outerHTML).toBe(''); - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should initialize document and objects with objects and a document fragment", function() { + it("should initialize document and objects with objects and a document fragment", function () { var fragment = document.createDocumentFragment(), children, objects, @@ -134,7 +134,7 @@ describe("reel/template-spec", function() { expect(children[0].outerHTML).toBe(''); }); - it("should initialize document and objects with a module id", function() { + it("should initialize document and objects with a module id", function () { var moduleId = "reel/template/simple-template.html", expectedObjects = { "text": { @@ -147,7 +147,7 @@ describe("reel/template-spec", function() { }; return template.initWithModuleId(moduleId, require) - .then(function() { + .then(function () { var children = template.document.body.children, objects = JSON.parse(template.objectsString); @@ -155,31 +155,31 @@ describe("reel/template-spec", function() { expect(children.length).toBe(1); // there must be a better way to compare DOM tree's... expect(children[0].outerHTML).toBe(''); - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should reuse the same template instance for the same module id", function() { + it("should reuse the same template instance for the same module id", function () { var moduleId = "reel/template/simple-template.html"; return Template.getTemplateWithModuleId(moduleId, require) - .then(function(template1) { + .then(function (template1) { return Template.getTemplateWithModuleId(moduleId, require) - .then(function(template2) { + .then(function (template2) { expect(template1).toBe(template2); }); }); }); - it("should resolve relative image's URL", function() { + it("should resolve relative image's URL", function () { var moduleId = "reel/template/template-relative-image.html", expectedResult = { "src" : URL.resolve(document.baseURI, "reel/template/sample-image.jpeg") } return template.initWithModuleId(moduleId, require) - .then(function() { + .then(function () { var domImage = template.document.body.querySelector("img"), domSrc = domImage ? domImage.src : "", svgImage = template.document.body.querySelector("image"), @@ -187,15 +187,15 @@ describe("reel/template-spec", function() { expect(domSrc).toBe(expectedResult.src); expect(svgSrc).toBe(expectedResult.src); - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); }); - describe("objects", function() { - it("should change the objects of a template", function() { + describe("objects", function () { + it("should change the objects of a template", function () { var expectedObjects = { "array": { "value": [1, 2, 3] @@ -221,7 +221,7 @@ describe("reel/template-spec", function() { expect(JSON.parse(template.objectsString)).toEqual(expectedObjects); }); - it("should instantiate the objects with an document fragment", function() { + it("should instantiate the objects with an document fragment", function () { var html = require("reel/template/simple-template.html").content, div = document.createElement("div"), fragment = document.createDocumentFragment(); @@ -230,21 +230,21 @@ describe("reel/template-spec", function() { .setAttribute("data-montage-id", "text"); return template.initWithHtml(html, require) - .then(function() { + .then(function () { return template._instantiateObjects(null, fragment) - .then(function(objects) { + .then(function (objects) { var text = objects.text; expect(text).toBeDefined(); expect(text.value).toBe("Hello, World!"); expect(text.element).toBe(div); }); - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should read the objects from an external file", function() { + it("should read the objects from an external file", function () { var moduleId = "reel/template/external-objects-file.html", expectedSerialization = { "text": { @@ -257,7 +257,7 @@ describe("reel/template-spec", function() { }; return Template.getTemplateWithModuleId(moduleId, require) - .then(function(template) { + .then(function (template) { var serialization = template.getSerialization() .getSerializationObject(); @@ -266,8 +266,8 @@ describe("reel/template-spec", function() { }); }); - describe("markup", function() { - it("should change the markup of a template", function() { + describe("markup", function () { + it("should change the markup of a template", function () { var html = require("reel/template/simple-template.html").content, htmlDocument = document.implementation.createHTMLDocument(""), expectedObjects = { @@ -293,11 +293,11 @@ describe("reel/template-spec", function() { expect(children[0].outerHTML).toBe(''); }); - it("should clone the markup out of the document", function() { + it("should clone the markup out of the document", function () { var html = require("reel/template/simple-template.html").content; return template.initWithHtml(html) - .then(function() { + .then(function () { var fragment = template._createMarkupDocumentFragment(document), element = document.createElement("div"), children = template.document.body.children; @@ -308,12 +308,12 @@ describe("reel/template-spec", function() { expect(element.children.length).toBe(1); expect(element.children[0].outerHTML).toBe(''); expect(element.children[0]).toNotBe(children[0]); - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should add a node to the template without collisions", function() { + it("should add a node to the template without collisions", function () { var html = require("reel/template/modification.html").content, htmlModification = require("reel/template/modification-elements.html").content, htmlDocument = document.implementation.createHTMLDocument(""), @@ -333,7 +333,7 @@ describe("reel/template-spec", function() { expect(reference.previousSibling).toBe(node); }); - it("should add a node to the template with collisions", function() { + it("should add a node to the template with collisions", function () { var html = require("reel/template/modification.html").content, htmlModification = require("reel/template/modification-elements.html").content, htmlDocument = document.implementation.createHTMLDocument(""), @@ -360,7 +360,7 @@ describe("reel/template-spec", function() { expect(collisionTable).toEqual(expectedCollisionTable); }); - it("should solve the collisions with the same base name", function() { + it("should solve the collisions with the same base name", function () { var html = require("reel/template/modification.html").content, htmlModification = require("reel/template/modification-elements.html").content, htmlDocument = document.implementation.createHTMLDocument(""), @@ -380,7 +380,7 @@ describe("reel/template-spec", function() { expect(collisionTable.title).toBe("title2") }); - it("should solve the collisions by using a custom labeler with insertNodeBefore", function() { + it("should solve the collisions by using a custom labeler with insertNodeBefore", function () { var html = require("reel/template/modification.html").content, htmlModification = require("reel/template/modification-elements.html").content, htmlDocument = document.implementation.createHTMLDocument(""), @@ -402,7 +402,7 @@ describe("reel/template-spec", function() { expect(collisionTable.title).not.toBe("title2") }); - it("should solve the collisions by using a custom labeler with appendNode", function() { + it("should solve the collisions by using a custom labeler with appendNode", function () { var html = require("reel/template/modification.html").content, htmlModification = require("reel/template/modification-elements.html").content, htmlDocument = document.implementation.createHTMLDocument(""), @@ -424,7 +424,7 @@ describe("reel/template-spec", function() { expect(collisionTable.title).not.toBe("title2") }); - it("should solve the collisions by using a custom labeler with replaceNode", function() { + it("should solve the collisions by using a custom labeler with replaceNode", function () { var html = require("reel/template/modification.html").content, htmlModification = require("reel/template/modification-elements.html").content, htmlDocument = document.implementation.createHTMLDocument(""), @@ -446,7 +446,7 @@ describe("reel/template-spec", function() { expect(collisionTable.title).not.toBe("title2") }); - it("should append a node to the template", function() { + it("should append a node to the template", function () { var html = require("reel/template/modification.html").content, htmlModification = require("reel/template/modification-elements.html").content, htmlDocument = document.implementation.createHTMLDocument(""), @@ -465,7 +465,7 @@ describe("reel/template-spec", function() { expect(reference.lastChild).toBe(node); }); - it("should replace a node into the template and resolve any relative Urls", function() { + it("should replace a node into the template and resolve any relative Urls", function () { var moduleId = "reel/template/modification.html", htmlModification = require("reel/template/template-relative-image.html").content, htmlDocument = document.implementation.createHTMLDocument(""), @@ -474,7 +474,7 @@ describe("reel/template-spec", function() { }; return template.initWithModuleId(moduleId, require) - .then(function() { + .then(function () { var node, reference; htmlDocument.documentElement.innerHTML = htmlModification; @@ -491,18 +491,18 @@ describe("reel/template-spec", function() { expect(domSrc).toBe(expectedResult.src); expect(svgSrc).toBe(expectedResult.src); - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should replace a node into the template and not add a rebased src attribute to images that have a src attribute", function() { + it("should replace a node into the template and not add a rebased src attribute to images that have a src attribute", function () { var moduleId = "reel/template/modification.html", htmlModification = require("reel/template/template-relative-image.html").content, htmlDocument = document.implementation.createHTMLDocument(""); return template.initWithModuleId(moduleId, require) - .then(function() { + .then(function () { var node, reference; htmlDocument.documentElement.innerHTML = htmlModification; @@ -515,18 +515,18 @@ describe("reel/template-spec", function() { var domImage = template.document.getElementById("no_src"); expect(domImage.hasAttribute("src")).toBeFalsy(); - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should replace a node into the template and not modify a src attribute on images that have an empty src attribute", function() { + it("should replace a node into the template and not modify a src attribute on images that have an empty src attribute", function () { var moduleId = "reel/template/modification.html", htmlModification = require("reel/template/template-relative-image.html").content, htmlDocument = document.implementation.createHTMLDocument(""); return template.initWithModuleId(moduleId, require) - .then(function() { + .then(function () { var node, reference; htmlDocument.documentElement.innerHTML = htmlModification; @@ -540,13 +540,13 @@ describe("reel/template-spec", function() { domSrc = domImage ? domImage.src : ""; expect(domSrc).toBe(""); - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should insert a node to the template and resolve any relative Urls", function() { + it("should insert a node to the template and resolve any relative Urls", function () { var moduleId = "reel/template/modification.html", htmlModification = require("reel/template/template-relative-image.html").content, htmlDocument = document.implementation.createHTMLDocument(""), @@ -555,7 +555,7 @@ describe("reel/template-spec", function() { } return template.initWithModuleId(moduleId, require) - .then(function() { + .then(function () { var node, reference; htmlDocument.documentElement.innerHTML = htmlModification; @@ -572,12 +572,12 @@ describe("reel/template-spec", function() { expect(domSrc).toBe(expectedResult.src); expect(svgSrc).toBe(expectedResult.src); - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should append a node to the template and resolve any relative Urls", function() { + it("should append a node to the template and resolve any relative Urls", function () { var moduleId = "reel/template/modification.html", htmlModification = require("reel/template/template-relative-image.html").content, htmlDocument = document.implementation.createHTMLDocument(""), @@ -586,7 +586,7 @@ describe("reel/template-spec", function() { } return template.initWithModuleId(moduleId, require) - .then(function() { + .then(function () { var node, reference; htmlDocument.documentElement.innerHTML = htmlModification; @@ -603,12 +603,12 @@ describe("reel/template-spec", function() { expect(domSrc).toBe(expectedResult.src); expect(svgSrc).toBe(expectedResult.src); - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should append a image to the template and resolve it's relative Url", function() { + it("should append a image to the template and resolve it's relative Url", function () { var moduleId = "reel/template/modification.html", htmlModification = require("reel/template/template-relative-image.html").content, htmlDocument = document.implementation.createHTMLDocument(""), @@ -617,7 +617,7 @@ describe("reel/template-spec", function() { } return template.initWithModuleId(moduleId, require) - .then(function() { + .then(function () { var reference = template.getElementById("title"); htmlDocument.documentElement.innerHTML = htmlModification; @@ -632,21 +632,21 @@ describe("reel/template-spec", function() { expect(domSrc).toBe(expectedResult.src); expect(svgSrc).toBe(expectedResult.src); - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); }); - describe("instantiation", function() { - it("should have the same markup as the template", function() { + describe("instantiation", function () { + it("should have the same markup as the template", function () { var html = require("reel/template/simple-template.html").content; return template.initWithHtml(html, require) - .then(function() { + .then(function () { return template.instantiate(document) - .then(function(documentPart) { + .then(function (documentPart) { var _document = documentPart.fragment.ownerDocument, element; @@ -656,73 +656,73 @@ describe("reel/template-spec", function() { expect(element.children.length).toBe(1); expect(element.children[0].outerHTML).toBe(''); }) - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should reference the template", function() { + it("should reference the template", function () { var html = require("reel/template/simple-template.html").content; return template.initWithHtml(html, require) - .then(function() { + .then(function () { return template.instantiate(document) - .then(function(documentPart) { + .then(function (documentPart) { expect(documentPart.template).toBe(template); }) - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should only reference objects that were declared in the template", function() { + it("should only reference objects that were declared in the template", function () { var html = require("reel/template/simple-template.html").content; return template.initWithHtml(html, require) - .then(function() { + .then(function () { return template.instantiate(document) - .then(function(documentPart) { + .then(function (documentPart) { expect(Object.keys(documentPart.objects).length).toBe(1); expect(documentPart.objects.text).toBeDefined(); }) - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should instantiate an empty template", function() { + it("should instantiate an empty template", function () { var html = require("reel/template/empty-template.html").content; return template.initWithHtml(html, require) - .then(function() { + .then(function () { return template.instantiate(document) - .then(function(documentPart) { + .then(function (documentPart) { expect(documentPart.objects).toEqual({}); }) - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should have the correct child components", function() { + it("should have the correct child components", function () { var html = require("reel/template/component-tree-template.html").content; return template.initWithHtml(html, require) - .then(function() { + .then(function () { return template.instantiate(document) - .then(function(documentPart) { + .then(function (documentPart) { var objects = documentPart.objects; expect(documentPart.childComponents) .toEqual([objects.title, objects.rows]); }); - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should instantiate a template with instances", function() { + it("should instantiate a template with instances", function () { var html = require("reel/template/simple-template.html").content, text = {}, instances = { @@ -730,17 +730,17 @@ describe("reel/template-spec", function() { }; return template.initWithHtml(html, require) - .then(function() { + .then(function () { return template.instantiateWithInstances(instances, document) - .then(function(documentPart) { + .then(function (documentPart) { expect(documentPart.objects.text).toBe(text); }) - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should use the object instances set when none is given", function() { + it("should use the object instances set when none is given", function () { var html = require("reel/template/simple-template.html").content, text = {}, instances = { @@ -748,19 +748,19 @@ describe("reel/template-spec", function() { }; return template.initWithHtml(html, require) - .then(function() { + .then(function () { template.setInstances(instances); return template.instantiate(document) - .then(function(documentPart) { + .then(function (documentPart) { expect(documentPart.objects.text).toBe(text); }) - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should ignore the object instances set when one is given", function() { + it("should ignore the object instances set when one is given", function () { var html = require("reel/template/simple-template.html").content, text = {}, instances = { @@ -768,137 +768,137 @@ describe("reel/template-spec", function() { }; return template.initWithHtml(html, require) - .then(function() { + .then(function () { template.setInstances({text: {}}); return template.instantiateWithInstances(instances, document) - .then(function(documentPart) { + .then(function (documentPart) { expect(documentPart.objects.text).toBe(text); }) - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); }); - describe("delegate methods", function() { + describe("delegate methods", function () { var DelegateMethods = require("reel/template/delegate-methods").DelegateMethods; - it("should call deserializedFromTemplate", function() { + it("should call deserializedFromTemplate", function () { var html = require("reel/template/delegate-methods-template.html").content, instances = { two: new DelegateMethods() }; return template.initWithHtml(html, require) - .then(function() { + .then(function () { return template.instantiateWithInstances(instances, document) - .then(function(documentPart) { + .then(function (documentPart) { var objects = documentPart.objects; expect(objects.owner.deserializedFromTemplateCount).toBe(1); expect(objects.one.deserializedFromTemplateCount).toBe(1); expect(objects.two.deserializedFromTemplateCount).toBe(0); }); - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should not call deserializedFromTemplate on null values", function() { + it("should not call deserializedFromTemplate on null values", function () { var html = require("reel/template/delegate-methods-null-template.html").content; return template.initWithHtml(html, require) - .then(function() { + .then(function () { return template.instantiate(document) - .then(function(documentPart) { + .then(function (documentPart) { expect(true).toBe(true); }); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should call templateDidLoad on owner object", function() { + it("should call templateDidLoad on owner object", function () { var html = require("reel/template/delegate-methods-template.html").content; return template.initWithHtml(html, require) - .then(function() { + .then(function () { return template.instantiate(document) - .then(function(documentPart) { + .then(function (documentPart) { var objects = documentPart.objects; expect(objects.owner.templateDidLoadCount).toBe(1); expect(objects.one.templateDidLoadCount).toBe(0); expect(objects.two.templateDidLoadCount).toBe(0); }); - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should call templateDidLoad on owner not used in serialization", function() { + it("should call templateDidLoad on owner not used in serialization", function () { var html = require("reel/template/delegate-methods-no-owner-template.html").content; return template.initWithHtml(html, require) - .then(function() { + .then(function () { var instances = { owner: new DelegateMethods(), one: new DelegateMethods() } return template.instantiateWithInstances(instances, document) - .then(function(documentPart) { + .then(function (documentPart) { var objects = documentPart.objects; expect(instances.owner.templateDidLoadCount).toBe(1); }); - }).fail(function(reason) { + }).fail(function (reason) { expect("test").toBe("executed"); }); }) - it("should not call templateDidLoad on external objects", function() { + it("should not call templateDidLoad on external objects", function () { var html = require("reel/template/delegate-methods-template-external.html").content; return template.initWithHtml(html, require) - .then(function() { + .then(function () { var instances = { owner: new DelegateMethods(), one: new DelegateMethods() } return template.instantiateWithInstances(instances, document) - .then(function(documentPart) { + .then(function (documentPart) { var objects = documentPart.objects; expect(objects.owner.templateDidLoadCount).toBe(0); }); - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should not call deserializedFromTemplate on external objects", function() { + it("should not call deserializedFromTemplate on external objects", function () { var html = require("reel/template/delegate-methods-template-external.html").content; return template.initWithHtml(html, require) - .then(function() { + .then(function () { var instances = { owner: new DelegateMethods(), one: new DelegateMethods() } return template.instantiateWithInstances(instances, document) - .then(function(documentPart) { + .then(function (documentPart) { var objects = documentPart.objects; expect(objects.one.deserializedFromTemplateCount).toBe(0); }); - }).fail(function() { + }).fail(function () { expect("test").toBe("executed"); }); }); - it("should call _deserializedFromTemplate with the right metadata", function() { + it("should call _deserializedFromTemplate with the right metadata", function () { var owner = {}, documentPart = { objects: { @@ -907,7 +907,7 @@ describe("reel/template-spec", function() { }, object = documentPart.objects.object; - object._deserializedFromTemplate = function(){}; + object._deserializedFromTemplate = function (){}; spyOn(object, "_deserializedFromTemplate"); template.initWithRequire(require); template.setObjectMetadata("object", null, "effectiveLabel", owner); @@ -916,7 +916,7 @@ describe("reel/template-spec", function() { expect(object._deserializedFromTemplate).toHaveBeenCalledWith(owner, "effectiveLabel", documentPart); }); - it("should call deserializedFromTemplate with the right metadata", function() { + it("should call deserializedFromTemplate with the right metadata", function () { var owner = {}, documentPart = { objects: { @@ -925,7 +925,7 @@ describe("reel/template-spec", function() { }, object = documentPart.objects.object; - object.deserializedFromTemplate = function(){}; + object.deserializedFromTemplate = function (){}; spyOn(object, "deserializedFromTemplate"); template.initWithRequire(require); template.setObjectMetadata("object", null, "effectiveLabel", owner); @@ -935,8 +935,8 @@ describe("reel/template-spec", function() { }); }); - describe("metadata", function() { - it("should get the right object owner", function() { + describe("metadata", function () { + it("should get the right object owner", function () { var owner = {}; template.initWithRequire(require); @@ -945,7 +945,7 @@ describe("reel/template-spec", function() { expect(template._getObjectOwner("object")).toBe(owner); }); - it("should get the right object label", function() { + it("should get the right object label", function () { var owner = {}; template.initWithRequire(require); @@ -955,90 +955,90 @@ describe("reel/template-spec", function() { }); }); - describe("external objects", function() { - it("should have access to application object", function() { + describe("external objects", function () { + it("should have access to application object", function () { var html = require("reel/template/external-objects-template.html").content, instances = { one: {} }; return template.initWithHtml(html, require) - .then(function() { + .then(function () { return template.instantiateWithInstances(instances, document) - .then(function(documentPart) { + .then(function (documentPart) { var objects = documentPart.objects; expect(objects.one.application).toBeDefined(); }); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should have access to template object", function() { + it("should have access to template object", function () { var html = require("reel/template/external-objects-template.html").content, instances = { one: {} }; return template.initWithHtml(html, require) - .then(function() { + .then(function () { return template.instantiateWithInstances(instances, document) - .then(function(documentPart) { + .then(function (documentPart) { var objects = documentPart.objects; expect(objects.one.template).toBe(template); }); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); }); - describe("template resources", function() { - it("should load all scripts except montage serialization", function() { + describe("template resources", function () { + it("should load all scripts except montage serialization", function () { var html = require("reel/template/resources-template.html").content, resources = new TemplateResources(); return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { return template.initWithHtml(html) - .then(function() { + .then(function () { resources.initWithTemplate(template); return resources.loadScripts(page.document) - .then(function() { + .then(function () { expect(page.ReelTemplateResourceLoadCount).toBe(1); expect(page.document.scripts.length).toBe(3); deletePage(page); }); }); - }).fail(function(reason) { + }).fail(function (reason) { expect("test").toBe("executed"); }); }); - it("should load all scripts in two different documents in serial", function() { + it("should load all scripts in two different documents in serial", function () { var html = require("reel/template/resources-template.html").content, resources = new TemplateResources(); return Promise.all([ createPage("reel/template/page.html"), createPage("reel/template/page.html")]) - .then(function(pages) { + .then(function (pages) { var page1 = pages[0], page2 = pages[1]; return template.initWithHtml(html) - .then(function() { + .then(function () { resources.initWithTemplate(template); return resources.loadScripts(page1.document) - .then(function() { + .then(function () { return resources.loadScripts(page2.document) - .then(function() { + .then(function () { expect(page1.ReelTemplateResourceLoadCount).toBe(1); expect(page2.ReelTemplateResourceLoadCount).toBe(1); expect(page1.document.scripts.length).toBe(3); @@ -1048,31 +1048,31 @@ describe("reel/template-spec", function() { }); }); }); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should load all scripts in two different documents in parallel", function() { + it("should load all scripts in two different documents in parallel", function () { var html = require("reel/template/resources-template.html").content, resources = new TemplateResources(); return Promise.all([ createPage("reel/template/page.html"), createPage("reel/template/page.html")]) - .then(function(pages) { + .then(function (pages) { var page1 = pages[0], page2 = pages[1]; return template.initWithHtml(html) - .then(function() { + .then(function () { resources.initWithTemplate(template); return Promise.all([ resources.loadScripts(page1.document), resources.loadScripts(page2.document)]) - .then(function() { + .then(function () { expect(page1.ReelTemplateResourceLoadCount).toBe(1); expect(page2.ReelTemplateResourceLoadCount).toBe(1); expect(page1.document.scripts.length).toBe(3); @@ -1081,103 +1081,103 @@ describe("reel/template-spec", function() { deletePage(page2); }); }); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should load inline scripts with their content", function() { + it("should load inline scripts with their content", function () { var html = require("reel/template/resources-template.html").content, resources = new TemplateResources(); return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { return template.initWithHtml(html) - .then(function() { + .then(function () { resources.initWithTemplate(template); return resources.loadScripts(page.document) - .then(function() { + .then(function () { var script = page.document.getElementById("inline"); expect(script.textContent).toBe("var x;"); deletePage(page); }); }); - }).fail(function(reason) { + }).fail(function (reason) { expect("test").toBe("executed"); }); }); - it("should load all styles", function() { + it("should load all styles", function () { var html = require("reel/template/resources-template.html").content, resources = new TemplateResources(); return createPage("reel/template/page.html") - .then(function(page) { + .then(function (page) { return template.initWithHtml(html) - .then(function() { + .then(function () { resources.initWithTemplate(template); return resources.loadStyles(page.document) - .then(function() { + .then(function () { expect(resources.getStyles().length).toBe(2); deletePage(page); }); }); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); }); - describe("sub templates", function() { - describe("find element ids in DOM tree", function() { - it("should find no element ids", function() { + describe("sub templates", function () { + describe("find element ids in DOM tree", function () { + it("should find no element ids", function () { var moduleId = "reel/template/sub-template.html", expectedIds = [], elementIds, node; return template.initWithModuleId(moduleId, require) - .then(function() { + .then(function () { node = template.document.getElementById("title"); elementIds = template._getChildrenElementIds(node); expect(elementIds.length).toBe(0); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should find a single element id", function() { + it("should find a single element id", function () { var moduleId = "reel/template/sub-template.html", expectedIds = [], elementIds, node; return template.initWithModuleId(moduleId, require) - .then(function() { + .then(function () { node = template.document.getElementById("list"); elementIds = template._getChildrenElementIds(node); expect(elementIds.length).toBe(1); expect(elementIds).toContain("item") - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should find all element ids of a populated tree", function() { + it("should find all element ids of a populated tree", function () { var moduleId = "reel/template/sub-template.html", expectedIds = [], elementIds, node; return template.initWithModuleId(moduleId, require) - .then(function() { + .then(function () { node = template.document.getElementById("rows"); elementIds = template._getChildrenElementIds(node); @@ -1185,14 +1185,14 @@ describe("reel/template-spec", function() { expect(elementIds).toContain("row"); expect(elementIds).toContain("columns"); expect(elementIds).toContain("column"); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); }); - it("should create a sub template from a leaf element", function() { + it("should create a sub template from a leaf element", function () { var moduleId = "reel/template/sub-template.html", expectedObjects = { "item": { @@ -1208,18 +1208,18 @@ describe("reel/template-spec", function() { objects; return template.initWithModuleId(moduleId, require) - .then(function() { + .then(function () { subTemplate = template.createTemplateFromElementContents("list"); objects = JSON.parse(subTemplate.objectsString); expect(objects).toEqual(expectedObjects); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should create a sub template from a leaf element", function() { + it("should create a sub template from a leaf element", function () { var moduleId = "reel/template/sub-template.html", expectedObjects = { "list": { @@ -1241,18 +1241,18 @@ describe("reel/template-spec", function() { objects; return template.initWithModuleId(moduleId, require) - .then(function() { + .then(function () { subTemplate = template.createTemplateFromElement("list"); objects = JSON.parse(subTemplate.objectsString); expect(objects).toEqual(expectedObjects); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should create a sub template with composed components", function() { + it("should create a sub template with composed components", function () { var moduleId = "reel/template/sub-template.html", expectedObjects = { "row": { @@ -1282,63 +1282,63 @@ describe("reel/template-spec", function() { objects; return template.initWithModuleId(moduleId, require) - .then(function() { + .then(function () { subTemplate = template.createTemplateFromElementContents("rows"); objects = JSON.parse(subTemplate.objectsString); expect(objects).toEqual(expectedObjects); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); }); - describe("document (live) templates", function() { - it("should instantiate in a live page", function() { + describe("document (live) templates", function () { + it("should instantiate in a live page", function () { var module = require("montage/core/template"); return createPage("reel/template/simple-template.html") - .then(function(page) { + .then(function (page) { return module.instantiateDocument(page.document, require) - .then(function(part) { + .then(function (part) { expect(part.template).toBeDefined(); expect(part.objects.text).toBeDefined(); //expect(part.fragment).toBe(page.document.documentElement); //expect(part.childComponents.length).toBe(1); }); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should instantiate in a live page with instances", function() { + it("should instantiate in a live page with instances", function () { var module = require("montage/core/template"), instances = { text: {} }; return createPage("reel/template/simple-template.html") - .then(function(page) { + .then(function (page) { return module.instantiateDocument(page.document, require, instances) - .then(function(part) { + .then(function (part) { expect(part.template).toBeDefined(); expect(part.objects.text).toBe(instances.text); }); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); }) - describe("template parameters", function() { - it("should find the star parameter", function() { + describe("template parameters", function () { + it("should find the star parameter", function () { var html = require("reel/template/template-star-parameter.html").content; return template.initWithHtml(html) - .then(function() { + .then(function () { var templateParameters = template.getParameters(), templateParameterKeys = Object.keys(templateParameters); @@ -1347,11 +1347,11 @@ describe("reel/template-spec", function() { }) }); - it("should find all parameters", function() { + it("should find all parameters", function () { var html = require("reel/template/template-parameters.html").content; return template.initWithHtml(html) - .then(function() { + .then(function () { var templateParameters = template.getParameters(), templateParameterKeys = Object.keys(templateParameters); @@ -1361,11 +1361,11 @@ describe("reel/template-spec", function() { }) }); - it("should fail when star and other parameters were declared", function() { + it("should fail when star and other parameters were declared", function () { var html = require("reel/template/template-parameters-error.html").content; return template.initWithHtml(html) - .then(function() { + .then(function () { try { template.getParameters(); expect("call").toBe("fail"); @@ -1375,11 +1375,11 @@ describe("reel/template-spec", function() { }) }); - it("should fail when the same parameter is declared more than once", function() { + it("should fail when the same parameter is declared more than once", function () { var html = require("reel/template/template-duplicate-parameters.html").content; return template.initWithHtml(html) - .then(function() { + .then(function () { try { template.getParameters(); expect("call").toBe("fail"); @@ -1390,28 +1390,28 @@ describe("reel/template-spec", function() { }); }); - describe("expanding template parameters", function() { + describe("expanding template parameters", function () { var parametersTemplate, argumentsTemplate, argumentsProvider; - beforeEach(function() { + beforeEach(function () { parametersTemplate = new Template(); argumentsTemplate = new Template(); argumentsProvider = { - getTemplateArgumentSerialization: function(elementIds) { + getTemplateArgumentSerialization: function (elementIds) { return argumentsTemplate ._createSerializationWithElementIds(elementIds); } }; }); - it("should expand a parameter with non-colliding element", function() { + it("should expand a parameter with non-colliding element", function () { var parametersHtml = require("reel/template/template-star-parameter.html").content, argumentsHtml = require("reel/template/template-arguments.html").content; - argumentsProvider.getTemplateArgumentElement = function(name) { + argumentsProvider.getTemplateArgumentElement = function (name) { range = document.createRange(); range.selectNodeContents(argumentsTemplate.getElementById("list")); return range.extractContents(); @@ -1420,7 +1420,7 @@ describe("reel/template-spec", function() { return Promise.all([ parametersTemplate.initWithHtml(parametersHtml), argumentsTemplate.initWithHtml(argumentsHtml) - ]).then(function() { + ]).then(function () { var repetition, args; @@ -1435,11 +1435,11 @@ describe("reel/template-spec", function() { }); }); - it("should expand a parameter with colliding element", function() { + it("should expand a parameter with colliding element", function () { var parametersHtml = require("reel/template/template-star-parameter.html").content, argumentsHtml = require("reel/template/template-arguments.html").content; - argumentsProvider.getTemplateArgumentElement = function(name) { + argumentsProvider.getTemplateArgumentElement = function (name) { range = document.createRange(); range.selectNodeContents( argumentsTemplate.getElementById("element-id-collision")); @@ -1449,7 +1449,7 @@ describe("reel/template-spec", function() { return Promise.all([ parametersTemplate.initWithHtml(parametersHtml), argumentsTemplate.initWithHtml(argumentsHtml) - ]).then(function() { + ]).then(function () { var repetition, args; @@ -1463,11 +1463,11 @@ describe("reel/template-spec", function() { }); }); - it("should expand multiple parameters with non-colliding element", function() { + it("should expand multiple parameters with non-colliding element", function () { var parametersHtml = require("reel/template/template-parameters.html").content, argumentsHtml = require("reel/template/template-arguments.html").content; - argumentsProvider.getTemplateArgumentElement = function(name) { + argumentsProvider.getTemplateArgumentElement = function (name) { range = document.createRange(); range.selectNodeContents( argumentsTemplate.getElementById("multiple-elements-" + name)); @@ -1477,7 +1477,7 @@ describe("reel/template-spec", function() { return Promise.all([ parametersTemplate.initWithHtml(parametersHtml), argumentsTemplate.initWithHtml(argumentsHtml) - ]).then(function() { + ]).then(function () { var repetition, side; @@ -1493,11 +1493,11 @@ describe("reel/template-spec", function() { }); }); - it("should expand multiple parameters with colliding elements", function() { + it("should expand multiple parameters with colliding elements", function () { var parametersHtml = require("reel/template/template-parameters.html").content, argumentsHtml = require("reel/template/template-arguments.html").content; - argumentsProvider.getTemplateArgumentElement = function(name) { + argumentsProvider.getTemplateArgumentElement = function (name) { range = document.createRange(); range.selectNodeContents( argumentsTemplate.getElementById("multiple-elements-colliding-" + name)); @@ -1507,7 +1507,7 @@ describe("reel/template-spec", function() { return Promise.all([ parametersTemplate.initWithHtml(parametersHtml), argumentsTemplate.initWithHtml(argumentsHtml) - ]).then(function() { + ]).then(function () { var side, leftSideElementId, rightSideElementId; @@ -1528,12 +1528,12 @@ describe("reel/template-spec", function() { }); }); - it("should expand a parameter with element and non-colliding objects", function() { + it("should expand a parameter with element and non-colliding objects", function () { var parametersHtml = require("reel/template/template-star-parameter.html").content, argumentsHtml = require("reel/template/template-arguments.html").content, serialization; - argumentsProvider.getTemplateArgumentElement = function(name) { + argumentsProvider.getTemplateArgumentElement = function (name) { range = document.createRange(); range.selectNodeContents( argumentsTemplate.getElementById("objects-no-collision")); @@ -1543,7 +1543,7 @@ describe("reel/template-spec", function() { return Promise.all([ parametersTemplate.initWithHtml(parametersHtml), argumentsTemplate.initWithHtml(argumentsHtml) - ]).then(function() { + ]).then(function () { var expansionResult; expansionResult = parametersTemplate.expandParameters( @@ -1557,13 +1557,13 @@ describe("reel/template-spec", function() { }); }); - it("should expand a parameter with element and colliding objects", function() { + it("should expand a parameter with element and colliding objects", function () { var parametersHtml = require("reel/template/template-star-parameter.html").content, argumentsHtml = require("reel/template/template-arguments.html").content, delegate, serialization; - argumentsProvider.getTemplateArgumentElement = function(name) { + argumentsProvider.getTemplateArgumentElement = function (name) { range = document.createRange(); range.selectNodeContents( argumentsTemplate.getElementById("objects-collision")); @@ -1573,7 +1573,7 @@ describe("reel/template-spec", function() { return Promise.all([ parametersTemplate.initWithHtml(parametersHtml), argumentsTemplate.initWithHtml(argumentsHtml) - ]).then(function() { + ]).then(function () { var collisionTable; parametersTemplate.expandParameters(argumentsProvider); @@ -1586,12 +1586,12 @@ describe("reel/template-spec", function() { }); }); - it("should expand multiple parameters with elements and colliding objects", function() { + it("should expand multiple parameters with elements and colliding objects", function () { var parametersHtml = require("reel/template/template-parameters.html").content, argumentsHtml = require("reel/template/template-arguments.html").content, serialization; - argumentsProvider.getTemplateArgumentElement = function(name) { + argumentsProvider.getTemplateArgumentElement = function (name) { range = document.createRange(); range.selectNodeContents( argumentsTemplate.getElementById("multiple-objects-" + name)); @@ -1601,7 +1601,7 @@ describe("reel/template-spec", function() { return Promise.all([ parametersTemplate.initWithHtml(parametersHtml), argumentsTemplate.initWithHtml(argumentsHtml) - ]).then(function() { + ]).then(function () { var expansionResult, labelsCollisions, labels, @@ -1631,26 +1631,26 @@ describe("reel/template-spec", function() { }); }); - it("should resolve a direct template property alias", function() { + it("should resolve a direct template property alias", function () { var parametersHtml = require("reel/template/template-properties-parameters.html").content, argumentsHtml = require("reel/template/template-arguments.html").content, serialization; - argumentsProvider.getTemplateArgumentElement = function() { + argumentsProvider.getTemplateArgumentElement = function () { range = document.createRange(); range.selectNodeContents( argumentsTemplate.getElementById("template-properties")); return range.extractContents(); }; - argumentsProvider.resolveTemplateArgumentTemplateProperty = function() { + argumentsProvider.resolveTemplateArgumentTemplateProperty = function () { return "repetition:iteration"; }; return Promise.all([ parametersTemplate.initWithHtml(parametersHtml), argumentsTemplate.initWithHtml(argumentsHtml) - ]).then(function() { + ]).then(function () { var serializationObject; parametersTemplate.expandParameters(argumentsProvider); @@ -1663,26 +1663,26 @@ describe("reel/template-spec", function() { }); }); - it("should resolve to another template property alias", function() { + it("should resolve to another template property alias", function () { var parametersHtml = require("reel/template/template-properties-parameters.html").content, argumentsHtml = require("reel/template/template-arguments.html").content, serialization; - argumentsProvider.getTemplateArgumentElement = function() { + argumentsProvider.getTemplateArgumentElement = function () { range = document.createRange(); range.selectNodeContents( argumentsTemplate.getElementById("template-properties")); return range.extractContents(); }; - argumentsProvider.resolveTemplateArgumentTemplateProperty = function() { + argumentsProvider.resolveTemplateArgumentTemplateProperty = function () { return "list:iteration"; }; return Promise.all([ parametersTemplate.initWithHtml(parametersHtml), argumentsTemplate.initWithHtml(argumentsHtml) - ]).then(function() { + ]).then(function () { var serializationObject; parametersTemplate.expandParameters(argumentsProvider); @@ -1695,27 +1695,27 @@ describe("reel/template-spec", function() { }); }); - it("should not resolve to a label (not an alias)", function() { + it("should not resolve to a label (not an alias)", function () { var parametersHtml = require("reel/template/template-properties-parameters.html").content, argumentsHtml = require("reel/template/template-arguments.html").content, serialization, templatePropertyAlias; - argumentsProvider.getTemplateArgumentElement = function() { + argumentsProvider.getTemplateArgumentElement = function () { var range = document.createRange(); range.selectNodeContents( argumentsTemplate.getElementById("template-properties")); return range.extractContents(); }; - argumentsProvider.resolveTemplateArgumentTemplateProperty = function(name) { + argumentsProvider.resolveTemplateArgumentTemplateProperty = function (name) { templatePropertyAlias = name; }; return Promise.all([ parametersTemplate.initWithHtml(parametersHtml), argumentsTemplate.initWithHtml(argumentsHtml) - ]).then(function() { + ]).then(function () { var serializationObject; parametersTemplate.expandParameters(argumentsProvider); @@ -1729,19 +1729,19 @@ describe("reel/template-spec", function() { }); }); - describe("cache", function() { - it("should treat same module id in different package as different templates", function() { - return require.loadPackage("package-a").then(function(pkg1) { - return require.loadPackage("package-b").then(function(pkg2) { + describe("cache", function () { + it("should treat same module id in different package as different templates", function () { + return require.loadPackage("package-a").then(function (pkg1) { + return require.loadPackage("package-b").then(function (pkg2) { return Template.getTemplateWithModuleId("ui/main.reel/main.html", pkg1) - .then(function(template1) { + .then(function (template1) { return Template.getTemplateWithModuleId("ui/main.reel/main.html", pkg2) - .then(function(template2) { + .then(function (template2) { expect(template1).toNotBe(template2); }); }); }); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); diff --git a/test/reel/template/componentgranddaughter.reel/componentgranddaughter.js b/test/reel/template/componentgranddaughter.reel/componentgranddaughter.js index b27aa7ec8e..d762a7642d 100644 --- a/test/reel/template/componentgranddaughter.reel/componentgranddaughter.js +++ b/test/reel/template/componentgranddaughter.reel/componentgranddaughter.js @@ -40,7 +40,7 @@ var ComponentGranddaughter = exports.ComponentGranddaughter = ComponentDaughter. }, templateDidLoad: { - value: function() { + value: function () { this.templateDidLoadCallCount++; } } diff --git a/test/reel/template/componentson.reel/componentson.js b/test/reel/template/componentson.reel/componentson.js index 46852acf4a..ef40380c3f 100644 --- a/test/reel/template/componentson.reel/componentson.js +++ b/test/reel/template/componentson.reel/componentson.js @@ -38,7 +38,7 @@ var ComponentSon = exports.ComponentSon = ComponentFather.specialize( { _templateModuleId: {value: "../componentfather.reel/componentfather.html"}, draw: { - value: function() { + value: function () { this._element.textContent = "Component Son"; } } diff --git a/test/reel/template/delegate-methods.js b/test/reel/template/delegate-methods.js index 51b0f749fa..2b2b4c8044 100644 --- a/test/reel/template/delegate-methods.js +++ b/test/reel/template/delegate-methods.js @@ -6,7 +6,7 @@ var DelegateMethods = Component.specialize( { deserializedFromTemplateCount: {value: 0}, deserializedFromTemplate: { - value: function() { + value: function () { this.deserializedFromTemplateCount++; } }, @@ -14,7 +14,7 @@ var DelegateMethods = Component.specialize( { templateDidLoadCount: {value: 0}, templateDidLoad: { - value: function() { + value: function () { this.templateDidLoadCount++; } } diff --git a/test/reel/template/flatten.reel/flatten.js b/test/reel/template/flatten.reel/flatten.js index 2530273d81..274d8c74e2 100644 --- a/test/reel/template/flatten.reel/flatten.js +++ b/test/reel/template/flatten.reel/flatten.js @@ -39,18 +39,18 @@ var Flatten = exports.Flatten = Component.specialize( { value: true }, - loadTemplate: {value: function(callback) { + loadTemplate: {value: function (callback) { if (this._isTemplateLoading) return; this._isTemplateLoading = true; var self = this; var templateModuleId, info, moduleId; - var onTemplateLoad = function(reel) { + var onTemplateLoad = function (reel) { self._template = reel; self._isTemplateLoaded = true; self._isTemplateLoading = false; // TODO: only need to change this part on Component.loadTemplate to make it generic for any component, we need a way for a component to say they want to be expanded... at the moment we'll only use it for repetitions I'd say. - reel.flatten(function() { + reel.flatten(function () { reel.instantiateWithComponent(self); if (callback) { callback(); diff --git a/test/reel/template/my-dynamic-text.reel/my-dynamic-text.js b/test/reel/template/my-dynamic-text.reel/my-dynamic-text.js index 7133f8b2f3..4a1cf67b1e 100644 --- a/test/reel/template/my-dynamic-text.reel/my-dynamic-text.js +++ b/test/reel/template/my-dynamic-text.reel/my-dynamic-text.js @@ -38,7 +38,7 @@ var MyText = exports.MyText = Text.specialize( { value: false }, deserializedFromTemplate: { - value: function() { + value: function () { this.didDeserializedFromTemplate = true; } } diff --git a/test/reel/template/template-server.js b/test/reel/template/template-server.js index 75e80fa466..a59d023cfd 100644 --- a/test/reel/template/template-server.js +++ b/test/reel/template/template-server.js @@ -16,7 +16,7 @@ http.createServer(function (req, res) { }).listen(port); function serveWithDelay(req, res, delay) { - setTimeout(function() { + setTimeout(function () { serve(req, res); }, delay); } @@ -25,7 +25,7 @@ function serve(req, res) { var path = getUrlPath(req); if (path === "/resource.js") { - fs.readFile('./resource.js', function(err, data) { + fs.readFile('./resource.js', function (err, data) { res.writeHead(200, {'Content-Type': 'text/javascript'}); res.end(data); }); @@ -58,4 +58,4 @@ function getUrlParam(req, name) { } } -console.log("Template server started at: " + port); \ No newline at end of file +console.log("Template server started at: " + port); diff --git a/test/reel/template/template-test.js b/test/reel/template/template-test.js index 690d2d67ee..f4215c1329 100644 --- a/test/reel/template/template-test.js +++ b/test/reel/template/template-test.js @@ -28,20 +28,20 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -var querySelector = function(e){return document.querySelector(e);} +var querySelector = function (e){return document.querySelector(e);} var Montage = require("montage").Montage; var Component = require("montage/ui/component").Component; var TemplateTest = exports.TemplateTest = Montage.specialize( { - loadComponents: {value: function() { + loadComponents: {value: function () { // var component = new Component(); // component.hasTemplate = true; // component.element = document.body; // // TemplateTest.topComponent = component; }}, - listener: {value: function() { + listener: {value: function () { }} }); @@ -57,130 +57,130 @@ if (window.parent === window) { var component; - setTimeout(function() { + setTimeout(function () { component = window.defaultEventManager.application.delegate; }, 1000); /* - querySelector("#add-list1").onclick = function() { + querySelector("#add-list1").onclick = function () { //var list1 = eventManager.eventHandlerForElement(querySelector("#list1")); component.list1Objects.push(""); }; - querySelector("#remove-list1").onclick = function() { + querySelector("#remove-list1").onclick = function () { component.list1Objects.pop(); } - querySelector("#add5-list1").onclick = function() { + querySelector("#add5-list1").onclick = function () { component.list1Objects.splice(component.list1Objects.length-1, 0, 1, 2, 3, 4, 5); }; - querySelector("#remove5-list1").onclick = function() { + querySelector("#remove5-list1").onclick = function () { component.list1Objects.splice(component.list1Objects.length-5, 5); } - querySelector("#add-list2").onclick = function() { + querySelector("#add-list2").onclick = function () { component.list2Objects.push(""); }; - querySelector("#remove-list2").onclick = function() { + querySelector("#remove-list2").onclick = function () { component.list2Objects.pop(); } - querySelector("#add5-list2").onclick = function() { + querySelector("#add5-list2").onclick = function () { component.list2Objects.splice(component.list2Objects.length-1, 0, 1, 2, 3, 4, 5); }; - querySelector("#remove5-list2").onclick = function() { + querySelector("#remove5-list2").onclick = function () { component.list2Objects.splice(component.list2Objects.length-6, 5); } - querySelector("#add11-list3").onclick = function() { + querySelector("#add11-list3").onclick = function () { component.list3Objects.push([1]); }; - querySelector("#remove1-list3").onclick = function() { + querySelector("#remove1-list3").onclick = function () { component.list3Objects.pop(); } - querySelector("#remove01-list3").onclick = function() { + querySelector("#remove01-list3").onclick = function () { var innerArray = component.list3Objects[component.list3Objects.length-1]; innerArray.pop(); } - querySelector("#add15-list3").onclick = function() { + querySelector("#add15-list3").onclick = function () { component.list3Objects.push([1, 2, 3, 4, 5]); }; - querySelector("#add11-list5").onclick = function() { + querySelector("#add11-list5").onclick = function () { component.list5Objects.push([1]); }; - querySelector("#remove1-list5").onclick = function() { + querySelector("#remove1-list5").onclick = function () { component.list5Objects.pop(); } - querySelector("#remove01-list5").onclick = function() { + querySelector("#remove01-list5").onclick = function () { var innerArray = component.list5Objects[component.list5Objects.length-1]; innerArray.pop(); } - querySelector("#add15-list5").onclick = function() { + querySelector("#add15-list5").onclick = function () { component.list5Objects.push([1, 2, 3, 4, 5]); }; - querySelector("#add11-list6").onclick = function() { + querySelector("#add11-list6").onclick = function () { component.list6Objects.push([1]); }; - querySelector("#remove1-list6").onclick = function() { + querySelector("#remove1-list6").onclick = function () { component.list6Objects.pop(); } - querySelector("#remove01-list6").onclick = function() { + querySelector("#remove01-list6").onclick = function () { var innerArray = component.list6Objects[component.list6Objects.length-1]; innerArray.pop(); } - querySelector("#add15-list6").onclick = function() { + querySelector("#add15-list6").onclick = function () { component.list6Objects.push([1, 2, 3, 4, 5]); }; /* - querySelector("#add-componentit1").onclick = function() { + querySelector("#add-componentit1").onclick = function () { var componentit1 = eventManager.eventHandlerForElement(querySelector("#componentit1")); componentit1.listObjects.push(1); }; - querySelector("#remove-componentit1").onclick = function() { + querySelector("#remove-componentit1").onclick = function () { var componentit1 = eventManager.eventHandlerForElement(querySelector("#componentit1")); componentit1.listObjects.pop(); } - querySelector("#add5-componentit1").onclick = function() { + querySelector("#add5-componentit1").onclick = function () { var componentit1 = eventManager.eventHandlerForElement(querySelector("#componentit1")); componentit1.listObjects.push(1, 2, 3, 4, 5); }; - querySelector("#remove5-componentit1").onclick = function() { + querySelector("#remove5-componentit1").onclick = function () { var componentit1 = eventManager.eventHandlerForElement(querySelector("#componentit1")); componentit1.listObjects.splice(componentit1.listObjects.length-5, 5); } - querySelector("#add-componentit2").onclick = function() { + querySelector("#add-componentit2").onclick = function () { var componentit2 = eventManager.eventHandlerForElement(querySelector("#componentit2")); componentit2.listObjects.push(1); }; - querySelector("#remove-componentit2").onclick = function() { + querySelector("#remove-componentit2").onclick = function () { var componentit2 = eventManager.eventHandlerForElement(querySelector("#componentit2")); componentit2.listObjects.pop(); } - querySelector("#add5-componentit2").onclick = function() { + querySelector("#add5-componentit2").onclick = function () { var componentit2 = eventManager.eventHandlerForElement(querySelector("#componentit2")); componentit2.listObjects.push(1, 2, 3, 4, 5); }; - querySelector("#remove5-componentit2").onclick = function() { + querySelector("#remove5-componentit2").onclick = function () { var componentit2 = eventManager.eventHandlerForElement(querySelector("#componentit2")); componentit2.listObjects.splice(componentit2.listObjects.length-5, 5); } diff --git a/test/reel/template/textfield.reel/textfield.js b/test/reel/template/textfield.reel/textfield.js index b6a2bbd224..fd7506c417 100644 --- a/test/reel/template/textfield.reel/textfield.js +++ b/test/reel/template/textfield.reel/textfield.js @@ -37,11 +37,11 @@ var TextField = exports.TextField = Component.specialize( { hasTemplate: {value: true}, text: { - set: function(value) { + set: function (value) { this._text = value; this.needsDraw = true; }, - get: function() { + get: function () { return this._text; } }, @@ -50,7 +50,7 @@ var TextField = exports.TextField = Component.specialize( { value: "default text" }, - draw: {value: function() { + draw: {value: function () { this.element.value = this.text; }} }); diff --git a/test/run.js b/test/run.js index 40b5a68cbc..04be0f72e1 100644 --- a/test/run.js +++ b/test/run.js @@ -1,104 +1,99 @@ -require("montage-testing").run(require,[ - // Please keep in alphabetical order +require("montage-testing").run(require, [ + "application-spec", + "bitfield-spec", + "claimed-pointer-spec", + "converter-spec", + "enum-spec", + "gate-spec", + "logger-spec", + "paths-spec", + "require-spec", + "state-chart-spec", + "string-spec", + "document-resources-spec", - "application-spec", - "bitfield-spec", - "claimed-pointer-spec", - "converter-spec", - "enum-spec", - "gate-spec", - "logger-spec", - "paths-spec", - "require-spec", - "state-chart-spec", - "string-spec", + "base/abstract-alert-spec", + "base/abstract-button-spec", + "base/abstract-checkbox-spec", + "base/abstract-control-spec", + "base/abstract-confirm-spec", + "base/abstract-image-spec", + "base/abstract-link-spec", + "base/abstract-number-field-spec", + "base/abstract-radio-button-spec", + "base/abstract-select-spec", + "base/abstract-slider-spec", + "base/abstract-text-area-spec", + "base/abstract-text-field-spec", + "base/abstract-toggle-button-spec", + "base/abstract-video-spec", - "base/abstract-alert-spec", - "base/abstract-button-spec", - "base/abstract-checkbox-spec", - "base/abstract-control-spec", - "base/abstract-confirm-spec", - "base/abstract-image-spec", - "base/abstract-link-spec", - "base/abstract-number-field-spec", - "base/abstract-radio-button-spec", - "base/abstract-select-spec", - "base/abstract-slider-spec", - "base/abstract-text-area-spec", - "base/abstract-text-field-spec", - "base/abstract-toggle-button-spec", - "base/abstract-video-spec", + "bindings/spec", + "bindings/converter-spec", + "bindings/self-spec", - "bindings/spec", - "bindings/converter-spec", - "bindings/self-spec", + "composer/composer-spec", + "composer/press-composer-spec", + "composer/translate-composer/translate-composer-spec", - "composer/composer-spec", - "composer/press-composer-spec", - "composer/translate-composer/translate-composer-spec", + "core/browser-spec", + "core/core-spec", + "core/core-require-spec", + "core/dom-spec", + "core/localizer-spec", + "core/media-controller-spec", + "core/range-controller-spec", + "core/radio-button-controller-spec", + "core/request-spec", + "core/selector-spec", + "core/super-spec", + "core/super-for-spec", + "core/undo-manager-spec", + "core/tree-controller-spec", - "core/browser-spec", - "core/core-spec", - "core/core-require-spec", - "core/dom-spec", - "core/localizer-spec", - "core/media-controller-spec", - "core/range-controller-spec", - "core/radio-button-controller-spec", - "core/request-spec", - "core/selector-spec", - "core/super-spec", - "core/super-for-spec", - "core/undo-manager-spec", + "core/extras/function", + "core/extras/string", + "core/extras/url", - "core/tree-controller-spec", + "events/active-target-spec", + "events/eventmanager-spec", + "events/mutable-event-spec", + "events/object-hierarchy-spec", - "core/extras/function", - "core/extras/string", - "core/extras/url", + "geometry/cubicbezier-spec", + "geometry/point-spec", - "events/active-target-spec", - "events/eventmanager-spec", - "events/mutable-event-spec", - "events/object-hierarchy-spec", + "meta/blueprint-spec", + "meta/build-in-component-blueprint-spec", + "meta/component-blueprint-spec", + "meta/controller-blueprint-spec", + "meta/converter-blueprint-spec", + "meta/event-blueprint-spec", + "meta/module-blueprint-spec", - "geometry/cubicbezier-spec", - "geometry/point-spec", + "reel/template-spec", - "meta/blueprint-spec", - "meta/build-in-component-blueprint-spec", - "meta/component-blueprint-spec", - "meta/controller-blueprint-spec", - "meta/converter-blueprint-spec", - "meta/event-blueprint-spec", - "meta/module-blueprint-spec", + "serialization/alias-spec", + "serialization/serialization-spec", + "serialization/montage-serializer-spec", + "serialization/montage-deserializer-spec", + "serialization/serialization-extractor-spec", + "serialization/bindings-spec", + "serialization/serialization-inspector-spec", + "serialization/serialization-merger-spec", - "reel/template-spec", - "document-resources-spec", - - "serialization/alias-spec", - "serialization/serialization-spec", - "serialization/montage-serializer-spec", - "serialization/montage-deserializer-spec", - "serialization/serialization-extractor-spec", - "serialization/bindings-spec", - "serialization/serialization-inspector-spec", - "serialization/serialization-merger-spec", - - "trigger/trigger-spec", - - "ui/component-spec", - "ui/condition-spec", - "ui/firstdraw-spec", - "ui/loader-spec", - "ui/modal-overlay-spec", - "ui/overlay-spec", - // Broken due to changes to repetition - "ui/repetition-spec", - "ui/repetition-selection-spec", - "ui/repetition-binding-spec", - "ui/slot-spec", - "ui/substitution-spec", - "ui/text/text-spec" + "trigger/trigger-spec", + "ui/component-spec", + "ui/condition-spec", + "ui/firstdraw-spec", + "ui/loader-spec", + "ui/modal-overlay-spec", + "ui/overlay-spec", + "ui/repetition-spec", + "ui/repetition-selection-spec", + "ui/repetition-binding-spec", + "ui/slot-spec", + "ui/substitution-spec", + "ui/text/text-spec" ]); diff --git a/test/serialization/alias-spec.js b/test/serialization/alias-spec.js index ce6e0e1f7f..2da8bce357 100644 --- a/test/serialization/alias-spec.js +++ b/test/serialization/alias-spec.js @@ -1,42 +1,42 @@ var Alias = require("montage/core/serialization/alias").Alias, Promise = require("montage/core/promise").Promise; -describe("serialization/alias-spec", function() { +describe("serialization/alias-spec", function () { var alias; - beforeEach(function() { + beforeEach(function () { alias = new Alias(); }); - describe("Template Property Alias", function() { - describe("invalid alias syntax", function() { - it("should reject invalid component name", function() { - expect(function() { + describe("Template Property Alias", function () { + describe("invalid alias syntax", function () { + it("should reject invalid component name", function () { + expect(function () { alias.value = "componentMissingAt:propertyName"; }).toThrow(); }); - it("should reject missing property name", function() { - expect(function() { + it("should reject missing property name", function () { + expect(function () { alias.value = "@component"; }).toThrow(); }); - it("should reject a template property with path", function() { - expect(function() { + it("should reject a template property with path", function () { + expect(function () { alias.value = "@component:propertyName.path"; }).toThrow(); }); }); - describe("valid alias syntax", function() { - it("should accept a template property", function() { - expect(function() { + describe("valid alias syntax", function () { + it("should accept a template property", function () { + expect(function () { alias.value = "@component:propertyName"; }).not.toThrow(); }); - it("should initialize with the value", function() { + it("should initialize with the value", function () { var value = "@component:propertyName"; alias.init(value); @@ -45,4 +45,4 @@ describe("serialization/alias-spec", function() { }) }); }); -}); \ No newline at end of file +}); diff --git a/test/serialization/bindings-spec.js b/test/serialization/bindings-spec.js index 60c838d6cb..fdba1ddd77 100644 --- a/test/serialization/bindings-spec.js +++ b/test/serialization/bindings-spec.js @@ -103,19 +103,19 @@ describe("serialization/bindings-spec", function () { return deserialize(serializationString, require) .then(function (object) { expect("deserialization").toBe("fail"); - }).fail(function() { + }).fail(function () { // it should fail }); }); - describe("template properties' bindings", function() { + describe("template properties' bindings", function () { var deserializer; - beforeEach(function() { + beforeEach(function () { deserializer = new Deserializer(); }); - it("should not allow binding to a template property of a component that does not exist", function() { + it("should not allow binding to a template property of a component that does not exist", function () { var serialization = { "component": { "prototype": "montage/ui/component", @@ -129,14 +129,14 @@ describe("serialization/bindings-spec", function () { deserializer.init(serializationString, require); return deserializer.deserialize() - .then(function() { + .then(function () { expect("deserialization").toBe("failed"); - }).fail(function() { + }).fail(function () { // it should fail }); }); - it("should allow binding to a template property of a component that exists", function() { + it("should allow binding to a template property of a component that exists", function () { var serialization = { "known": {}, @@ -155,12 +155,12 @@ describe("serialization/bindings-spec", function () { deserializer.init(serializationString, require); return deserializer.deserialize(instances) - .then(function() { + .then(function () { // this is here just to consume the promise result }); }); - it("should bind correctly to a component with a colon", function() { + it("should bind correctly to a component with a colon", function () { // This "trick" can be used to speed up template properties' // resolution at bind time. var serialization = { @@ -184,7 +184,7 @@ describe("serialization/bindings-spec", function () { deserializer.init(serializationString, require); return deserializer.deserialize(instances) - .then(function(objects) { + .then(function (objects) { expect(objects.component.value).toBe(instances["owner:templateProperty"]); }); }); diff --git a/test/serialization/montage-deserializer-spec.js b/test/serialization/montage-deserializer-spec.js index 7244fae021..610b74a006 100644 --- a/test/serialization/montage-deserializer-spec.js +++ b/test/serialization/montage-deserializer-spec.js @@ -40,15 +40,15 @@ var Montage = require("montage").Montage, logger.isError = true; -describe("serialization/montage-deserializer-spec", function() { +describe("serialization/montage-deserializer-spec", function () { var deserializer; - beforeEach(function() { + beforeEach(function () { deserializer = new Deserializer(); }); - describe("Montage Objects Deserialization", function() { - it("should deserialize a class instance object", function() { + describe("Montage Objects Deserialization", function () { + it("should deserialize a class instance object", function () { var serialization = { "root": { "prototype": "montage", @@ -63,17 +63,17 @@ describe("serialization/montage-deserializer-spec", function() { deserializer.init( serializationString, require); - return deserializer.deserializeObject().then(function(root) { + return deserializer.deserializeObject().then(function (root) { expect(Object.getPrototypeOf(root)).toBe(Montage.prototype); expect(root.number).toBe(42); expect(root.string).toBe("a string"); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should deserialize two class instance objects", function() { + it("should deserialize two class instance objects", function () { var serialization = { "root": { "prototype": "montage", @@ -93,12 +93,12 @@ describe("serialization/montage-deserializer-spec", function() { deserializer.init(serializationString, require); - return deserializer.deserializeObject().then(function(root) { + return deserializer.deserializeObject().then(function (root) { expect(root.oneprop.prop).toBe(42); }); }); - it("should deserialize an external object with a label", function() { + it("should deserialize an external object with a label", function () { var serialization = { "root": { "prototype": "montage", @@ -119,15 +119,15 @@ describe("serialization/montage-deserializer-spec", function() { serializationString, require); return deserializer.deserializeObject(instances) - .then(function(root) { + .then(function (root) { expect(root.simple).toBe(simple); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should deserialize an object as another by providing an instance", function() { + it("should deserialize an object as another by providing an instance", function () { var serialization = { "root": { "prototype": "montage", @@ -150,15 +150,15 @@ describe("serialization/montage-deserializer-spec", function() { serializationString, require); return deserializer.deserializeObject(instances) - .then(function(root) { + .then(function (root) { expect(root.simple).toBe(simple); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should deserialize to a different object", function() { + it("should deserialize to a different object", function () { var serialization = { "root": { "prototype": "serialization/testobjects-v2[Singleton]", @@ -173,15 +173,15 @@ describe("serialization/montage-deserializer-spec", function() { serializationString, require); return deserializer.deserializeObject() - .then(function(root) { + .then(function (root) { expect(root).toBe(objects.Singleton.instance); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should deserialize an object's properties when an instance is given for that object", function() { + it("should deserialize an object's properties when an instance is given for that object", function () { var serialization = { "root": { "prototype": "montage", @@ -200,16 +200,16 @@ describe("serialization/montage-deserializer-spec", function() { serializationString, require); return deserializer.deserializeObject(instances) - .then(function(root) { + .then(function (root) { expect(root).toBe(instances.root); expect(instances.root.number).toBe(42); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should deserialize an object's properties when an instance is given for that object even when the serialization doesn't have a prototype or object property", function() { + it("should deserialize an object's properties when an instance is given for that object even when the serialization doesn't have a prototype or object property", function () { var serialization = { "owner": { "properties": { @@ -227,16 +227,16 @@ describe("serialization/montage-deserializer-spec", function() { serializationString, require); return deserializer.deserialize(instances) - .then(function(objects) { + .then(function (objects) { expect(objects.owner).toBe(instances.owner); expect(instances.owner.number).toBe(42); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should call deserializedFromSerialization function on the instantiated objects", function() { + it("should call deserializedFromSerialization function on the instantiated objects", function () { var serialization = { "root": { "prototype": "serialization/testobjects-v2[OneProp]", @@ -257,19 +257,19 @@ describe("serialization/montage-deserializer-spec", function() { serializationString, require); return deserializer.deserialize(instances) - .then(function(object) { + .then(function (object) { var root = object.root, oneprop = object.oneprop; expect(root.deserializedFromSerializationCount).toBe(0); expect(oneprop.deserializedFromSerializationCount).toBe(1); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - //it("should call deserializedFromSerialization function on the instantiated objects even if they were given as null instances", function() { + //it("should call deserializedFromSerialization function on the instantiated objects even if they were given as null instances", function () { // var latch; // var instances = {root: null}; // var exports; @@ -286,18 +286,18 @@ describe("serialization/montage-deserializer-spec", function() { // module: "serialization/testobjects-v2", // name: "OneProp" // } - // }).deserializeWithInstances(instances, function(objs) { + // }).deserializeWithInstances(instances, function (objs) { // latch = true; // exports = objs; // }); // - // waitsFor(function() { return latch; }); - // runs(function() { + // waitsFor(function () { return latch; }); + // runs(function () { // expect(exports.root.deserializedFromSerializationCount).toBe(1); // }) //}); - it("should have isDeserializing set to true during units deserialization", function() { + it("should have isDeserializing set to true during units deserialization", function () { var serialization = { "root": { "prototype": "serialization/testobjects-v2[OneProp]", @@ -313,23 +313,23 @@ describe("serialization/montage-deserializer-spec", function() { deserializer.init( serializationString, require); - Deserializer.defineDeserializationUnit("spec", function(deserializer, object) { + Deserializer.defineDeserializationUnit("spec", function (deserializer, object) { isDeserializing = object.isDeserializing; }); return deserializer.deserialize() - .then(function(objects) { + .then(function (objects) { expect(isDeserializing).toBeTruthy(); expect(objects.root.isDeserializing).toBeUndefined(); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); }); - describe("Alias deserialization", function() { - it("should deserialize an alias", function() { + describe("Alias deserialization", function () { + it("should deserialize an alias", function () { var serialization = { ":templateProperty": { "alias": "@component:propertyName" @@ -339,7 +339,7 @@ describe("serialization/montage-deserializer-spec", function() { deserializer.init(serializationString, require); - return deserializer.deserialize().then(function(objects) { + return deserializer.deserialize().then(function (objects) { var alias = objects[":templateProperty"]; expect(Object.getPrototypeOf(alias)).toBe(Alias.prototype); @@ -350,8 +350,8 @@ describe("serialization/montage-deserializer-spec", function() { }); }); - describe("Template properties deserialization", function() { - it("should deserialize a template property as an alias", function() { + describe("Template properties deserialization", function () { + it("should deserialize a template property as an alias", function () { var serialization = { ":templateProperty": { "alias": "@component:propertyName" @@ -362,12 +362,12 @@ describe("serialization/montage-deserializer-spec", function() { deserializer.init(serializationString, require); return deserializer.deserialize() - .then(function() { + .then(function () { // promise needs to return undefined }); }); - it("should not deserialize a template property as an external object", function() { + it("should not deserialize a template property as an external object", function () { var serialization = { ":templateProperty": {} }, @@ -376,14 +376,14 @@ describe("serialization/montage-deserializer-spec", function() { deserializer.init(serializationString, require); return deserializer.deserialize() - .then(function() { + .then(function () { expect("deserialization").toBe("failed"); - }).fail(function() { + }).fail(function () { // it should fail }); }); - it("should not deserialize a montage object as a template property", function() { + it("should not deserialize a montage object as a template property", function () { var serialization = { ":templateProperty": { "prototype": "montage/ui/component" @@ -394,14 +394,14 @@ describe("serialization/montage-deserializer-spec", function() { deserializer.init(serializationString, require); return deserializer.deserialize() - .then(function() { + .then(function () { expect("deserialization").toBe("failed"); - }).fail(function() { + }).fail(function () { // it should fail }); }); - it("should not deserialize a value as a template property", function() { + it("should not deserialize a value as a template property", function () { var serialization = { ":templateProperty": { "value": 42 @@ -412,14 +412,14 @@ describe("serialization/montage-deserializer-spec", function() { deserializer.init(serializationString, require); return deserializer.deserialize() - .then(function() { + .then(function () { expect("deserialization").toBe("failed"); - }).fail(function() { + }).fail(function () { // it should fail }); }); - it("should not deserialize a regexp as a template property", function() { + it("should not deserialize a regexp as a template property", function () { var serialization = { ":templateProperty": { "/": {"source": "regexp"} @@ -430,14 +430,14 @@ describe("serialization/montage-deserializer-spec", function() { deserializer.init(serializationString, require); return deserializer.deserialize() - .then(function() { + .then(function () { expect("deserialization").toBe("failed"); - }).fail(function() { + }).fail(function () { // it should fail }); }); - it("should not deserialize a literal object as a template property", function() { + it("should not deserialize a literal object as a template property", function () { var serialization = { ":templateProperty": { "value": {} @@ -448,16 +448,16 @@ describe("serialization/montage-deserializer-spec", function() { deserializer.init(serializationString, require); return deserializer.deserialize() - .then(function() { + .then(function () { expect("deserialization").toBe("failed"); - }).fail(function() { + }).fail(function () { // it should fail }); }); }); - describe("Object Location", function() { - it("should deserialize using prototype: module[name]", function() { + describe("Object Location", function () { + it("should deserialize using prototype: module[name]", function () { var serialization = { "root": { "prototype": "serialization/testobjects-v2[TestobjectsV2]", @@ -473,18 +473,18 @@ describe("serialization/montage-deserializer-spec", function() { serializationString, require); return deserializer.deserializeObject() - .then(function(root) { + .then(function (root) { var info = Montage.getInfoForObject(root); expect(Object.getPrototypeOf(root)).toBe(objects.TestobjectsV2.prototype); expect(root.instance).toBeUndefined(); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should deserialize using prototype: module", function() { + it("should deserialize using prototype: module", function () { var serialization = { "root": { "prototype": "serialization/testobjects-v2", @@ -500,7 +500,7 @@ describe("serialization/montage-deserializer-spec", function() { serializationString, require); return deserializer.deserializeObject() - .then(function(root) { + .then(function (root) { var info = Montage.getInfoForObject(root); expect(Object.getPrototypeOf(root)).toBe(objects.TestobjectsV2.prototype); @@ -509,13 +509,13 @@ describe("serialization/montage-deserializer-spec", function() { expect(info.objectName).toBe("TestobjectsV2"); expect(info.isInstance).toBe(true); expect(root.instance).toBeUndefined(); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should deserialize using prototype: module-name.reel", function() { + it("should deserialize using prototype: module-name.reel", function () { var serialization = { "root": { "prototype": "serialization/module-name.reel", @@ -531,19 +531,19 @@ describe("serialization/montage-deserializer-spec", function() { serializationString, require); return deserializer.deserializeObject() - .then(function(root) { + .then(function (root) { var info = Montage.getInfoForObject(root); expect(info.moduleId).toBe("serialization/module-name.reel"); expect(info.objectName).toBe("ModuleName"); expect(info.isInstance).toBe(true); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should deserialize using object: module[name]", function() { + it("should deserialize using object: module[name]", function () { var serialization = { "root": { "object": "serialization/testobjects-v2[TestobjectsV2]", @@ -559,7 +559,7 @@ describe("serialization/montage-deserializer-spec", function() { serializationString, require); return deserializer.deserializeObject() - .then(function(root) { + .then(function (root) { var info = Montage.getInfoForObject(root); expect(root).toBe(objects.TestobjectsV2); @@ -567,13 +567,13 @@ describe("serialization/montage-deserializer-spec", function() { expect(info.objectName).toBe("TestobjectsV2"); expect(info.isInstance).toBe(false); expect(root.type).toBeUndefined(); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should deserialize using object: module", function() { + it("should deserialize using object: module", function () { var serialization = { "root": { "object": "serialization/testobjects-v2", @@ -589,7 +589,7 @@ describe("serialization/montage-deserializer-spec", function() { serializationString, require); return deserializer.deserializeObject() - .then(function(root) { + .then(function (root) { var info = Montage.getInfoForObject(root); expect(root).toBe(objects.TestobjectsV2); @@ -597,13 +597,13 @@ describe("serialization/montage-deserializer-spec", function() { expect(info.objectName).toBe("TestobjectsV2"); expect(info.isInstance).toBe(false); expect(root.type).toBeUndefined(); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - //it("should deserialize using instance after compilation", function() { + //it("should deserialize using instance after compilation", function () { // var latch, objects; // // deserializer.initWithObjectAndRequire({ @@ -614,15 +614,15 @@ describe("serialization/montage-deserializer-spec", function() { // string: "string" // } // } - // }, require).deserialize(function() { - // deserializer.deserialize(function(objs) { + // }, require).deserialize(function () { + // deserializer.deserialize(function (objs) { // latch = true; // objects = objs; // }); // }); // - // waitsFor(function() { return latch; }); - // runs(function() { + // waitsFor(function () { return latch; }); + // runs(function () { // var root = objects.root, // info = Montage.getInfoForObject(root); // @@ -633,7 +633,7 @@ describe("serialization/montage-deserializer-spec", function() { // }); //}); - //it("should deserialize using type after compilation", function() { + //it("should deserialize using type after compilation", function () { // var latch, objects; // // deserializer.initWithObjectAndRequire({ @@ -644,15 +644,15 @@ describe("serialization/montage-deserializer-spec", function() { // string: "string" // } // } - // }, require).deserialize(function() { - // deserializer.deserialize(function(objs) { + // }, require).deserialize(function () { + // deserializer.deserialize(function (objs) { // latch = true; // objects = objs; // }); // }); // - // waitsFor(function() { return latch; }); - // runs(function() { + // waitsFor(function () { return latch; }); + // runs(function () { // var root = objects.root, // info = Montage.getInfoForObject(root); // @@ -664,10 +664,10 @@ describe("serialization/montage-deserializer-spec", function() { //}); }); - describe("Element Reference Deserialization", function() { + describe("Element Reference Deserialization", function () { var element = document.createElement("div"); - it("should deserialize an element reference", function() { + it("should deserialize an element reference", function () { var serialization = { "root": { "value": {"#": "id"} @@ -680,20 +680,20 @@ describe("serialization/montage-deserializer-spec", function() { serializationString, require); return deserializer.deserialize(null, element) - .then(function(objects) { + .then(function (objects) { expect(objects.root instanceof Element).toBe(true); expect(objects.root.textContent).toBe("content"); }); //for (var i = 0; i < 3; i++) { - // deserializer.deserializeObjectWithElement(root, function(object) { + // deserializer.deserializeObjectWithElement(root, function (object) { // expect(object.element instanceof Element).toBe(true); // expect(object.element.textContent).toBe("content"); // }); //} }); - //it("should deserialize an element reference through data-montage-id over id", function() { + //it("should deserialize an element reference through data-montage-id over id", function () { // root.innerHTML = '
content1
' + // '
content2
'; // deserializer.initWithObject({ @@ -705,14 +705,14 @@ describe("serialization/montage-deserializer-spec", function() { // }); // // for (var i = 0; i < 3; i++) { - // deserializer.deserializeObjectWithElement(root, function(object) { + // deserializer.deserializeObjectWithElement(root, function (object) { // expect(object.element instanceof Element).toBe(true); // expect(object.element.textContent).toBe("content2"); // }); // } //}); - //it("should deserialize an element with id and data-montage-id", function() { + //it("should deserialize an element with id and data-montage-id", function () { // root.innerHTML = '
content
'; // deserializer.initWithObject({ // root: { @@ -723,14 +723,14 @@ describe("serialization/montage-deserializer-spec", function() { // }); // // for (var i = 0; i < 3; i++) { - // deserializer.deserializeObjectWithElement(root, function(object) { + // deserializer.deserializeObjectWithElement(root, function (object) { // expect(object.element instanceof Element).toBe(true); // expect(object.element.textContent).toBe("content"); // }); // } //}); - //it("should deserialize an element with the same id and data-montage-id", function() { + //it("should deserialize an element with the same id and data-montage-id", function () { // root.innerHTML = '
content
'; // deserializer.initWithObject({ // root: { @@ -741,14 +741,14 @@ describe("serialization/montage-deserializer-spec", function() { // }); // // for (var i = 0; i < 3; i++) { - // deserializer.deserializeObjectWithElement(root, function(object) { + // deserializer.deserializeObjectWithElement(root, function (object) { // expect(object.element instanceof Element).toBe(true); // expect(object.element.textContent).toBe("content"); // }); // } //}); - //it("should deserialize an element reference through id w/ optimization", function() { + //it("should deserialize an element reference through id w/ optimization", function () { // root.innerHTML = '
content
'; // deserializer.initWithObject({ // root: { @@ -760,7 +760,7 @@ describe("serialization/montage-deserializer-spec", function() { // deserializer.optimizeForDocument(root); // // for (var i = 0; i < 3; i++) { - // deserializer.deserializeObjectWithElement(root, function(object) { + // deserializer.deserializeObjectWithElement(root, function (object) { // expect(object.element instanceof Element).toBe(true); // expect(object.element.textContent).toBe("content"); // expect(object.element.getAttribute("id")).toBe("id"); @@ -768,7 +768,7 @@ describe("serialization/montage-deserializer-spec", function() { // } //}); - //it("should deserialize an element reference through data-montage-id w/ optimization", function() { + //it("should deserialize an element reference through data-montage-id w/ optimization", function () { // root.innerHTML = '
content
'; // deserializer.initWithObject({ // root: { @@ -780,7 +780,7 @@ describe("serialization/montage-deserializer-spec", function() { // deserializer.optimizeForDocument(root); // // for (var i = 0; i < 3; i++) { - // deserializer.deserializeObjectWithElement(root, function(object) { + // deserializer.deserializeObjectWithElement(root, function (object) { // expect(object.element instanceof Element).toBe(true); // expect(object.element.textContent).toBe("content"); // expect(object.element.getAttribute("id")).toBeNull(); @@ -788,7 +788,7 @@ describe("serialization/montage-deserializer-spec", function() { // } //}); - //it("should deserialize an element reference through data-montage-id over id w/ optimization", function() { + //it("should deserialize an element reference through data-montage-id over id w/ optimization", function () { // root.innerHTML = '
content1
' + // '
content2
'; // deserializer.initWithObject({ @@ -801,7 +801,7 @@ describe("serialization/montage-deserializer-spec", function() { // deserializer.optimizeForDocument(root); // // for (var i = 0; i < 3; i++) { - // deserializer.deserializeObjectWithElement(root, function(object) { + // deserializer.deserializeObjectWithElement(root, function (object) { // expect(object.element instanceof Element).toBe(true); // expect(object.element.textContent).toBe("content2"); // expect(object.element.getAttribute("id")).toBeNull(); @@ -809,7 +809,7 @@ describe("serialization/montage-deserializer-spec", function() { // } //}); - //it("should deserialize an element with id and data-montage-id w/ optimization", function() { + //it("should deserialize an element with id and data-montage-id w/ optimization", function () { // root.innerHTML = '
content
'; // deserializer.initWithObject({ // root: { @@ -821,7 +821,7 @@ describe("serialization/montage-deserializer-spec", function() { // deserializer.optimizeForDocument(root); // // for (var i = 0; i < 3; i++) { - // deserializer.deserializeObjectWithElement(root, function(object) { + // deserializer.deserializeObjectWithElement(root, function (object) { // expect(object.element instanceof Element).toBe(true); // expect(object.element.textContent).toBe("content"); // expect(object.element.getAttribute("id")).toBe("realId"); @@ -829,7 +829,7 @@ describe("serialization/montage-deserializer-spec", function() { // } //}); - //it("should deserialize an element with the same id and data-montage-id w/ optimization", function() { + //it("should deserialize an element with the same id and data-montage-id w/ optimization", function () { // root.innerHTML = '
content
'; // deserializer.initWithObject({ // root: { @@ -841,7 +841,7 @@ describe("serialization/montage-deserializer-spec", function() { // deserializer.optimizeForDocument(root); // // for (var i = 0; i < 3; i++) { - // deserializer.deserializeObjectWithElement(root, function(object) { + // deserializer.deserializeObjectWithElement(root, function (object) { // expect(object.element instanceof Element).toBe(true); // expect(object.element.textContent).toBe("content"); // expect(object.element.getAttribute("id")).toBe("id"); @@ -850,8 +850,8 @@ describe("serialization/montage-deserializer-spec", function() { //}); }); - describe("Module reference deserialization", function() { - it("should deserialize a module", function() { + describe("Module reference deserialization", function () { + it("should deserialize a module", function () { var serialization = { "root": { "value": {"%": "./testobjects-v2"} @@ -863,7 +863,7 @@ describe("serialization/montage-deserializer-spec", function() { serializationString, require); return deserializer.deserializeObject() - .then(function(root) { + .then(function (root) { // module is now absolute from the root of the test package expect(root.id).toBe("serialization/testobjects-v2"); expect(root.require.location).toBe(require.location); @@ -871,7 +871,7 @@ describe("serialization/montage-deserializer-spec", function() { }); it("should use the require of the package the deserializer is using", function () { - return require.loadPackage("package-a").then(function(pkg1) { + return require.loadPackage("package-a").then(function (pkg1) { var serialization = { "root": { "value": {"%": "pass"} @@ -883,7 +883,7 @@ describe("serialization/montage-deserializer-spec", function() { serializationString, pkg1); return deserializer.deserializeObject() - .then(function(root) { + .then(function (root) { expect(root.id).toBe("pass"); expect(root.require.location).toBe(pkg1.location); }); @@ -891,7 +891,7 @@ describe("serialization/montage-deserializer-spec", function() { }); }); - describe("Custom deserialization", function() { + describe("Custom deserialization", function () { var customDeserialization = objects.CustomDeserialization, serialization = { "root": { @@ -916,30 +916,30 @@ describe("serialization/montage-deserializer-spec", function() { } }; - it("should only create the object", function() { + it("should only create the object", function () { var serializationString = JSON.stringify(serialization); deserializer.init( serializationString, require); - customDeserialization.prototype.deserializeSelf = function(deserializer) { + customDeserialization.prototype.deserializeSelf = function (deserializer) { }; return deserializer.deserializeObject() - .then(function(root) { + .then(function (root) { expect(root.prop1).toBeNull(); if (defaultEventManager.registeredEventListeners.action) { expect(root.uuid in defaultEventManager.registeredEventListeners.action).toBeFalsy(); } expect(root._bindingDescriptors).toBeFalsy(); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should report prototype type", function() { + it("should report prototype type", function () { var serializationString = JSON.stringify(serialization), type, typeValue; @@ -947,22 +947,22 @@ describe("serialization/montage-deserializer-spec", function() { deserializer.init( serializationString, require); - customDeserialization.prototype.deserializeSelf = function(deserializer) { + customDeserialization.prototype.deserializeSelf = function (deserializer) { type = deserializer.getType(); typeValue = deserializer.getTypeValue(); }; return deserializer.deserializeObject() - .then(function(root) { + .then(function (root) { expect(type).toBe("prototype"); expect(typeValue).toBe("serialization/testobjects-v2[CustomDeserialization]"); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should report object type", function() { + it("should report object type", function () { var serialization = { "root": { "object": "serialization/testobjects-v2[CustomDeserialization]" @@ -975,156 +975,156 @@ describe("serialization/montage-deserializer-spec", function() { deserializer.init( serializationString, require); - customDeserialization.deserializeSelf = function(deserializer) { + customDeserialization.deserializeSelf = function (deserializer) { type = deserializer.getType(); typeValue = deserializer.getTypeValue(); }; return deserializer.deserializeObject() - .then(function(root) { + .then(function (root) { expect(type).toBe("object"); expect(typeValue).toBe("serialization/testobjects-v2[CustomDeserialization]"); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should access properties", function() { + it("should access properties", function () { var serializationString = JSON.stringify(serialization), prop1; deserializer.init( serializationString, require); - customDeserialization.prototype.deserializeSelf = function(deserializer) { + customDeserialization.prototype.deserializeSelf = function (deserializer) { prop1 = deserializer.getProperty("prop1"); }; return deserializer.deserializeObject() - .then(function(root) { + .then(function (root) { expect(prop1).toBe(3.14); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should only deserialize properties", function() { + it("should only deserialize properties", function () { var serializationString = JSON.stringify(serialization); deserializer.init( serializationString, require); - customDeserialization.prototype.deserializeSelf = function(deserializer) { + customDeserialization.prototype.deserializeSelf = function (deserializer) { deserializer.deserializeProperties(); }; return deserializer.deserializeObject() - .then(function(root) { + .then(function (root) { expect(root.prop1).toBe(3.14); if (defaultEventManager.registeredEventListeners.action) { expect(root.uuid in defaultEventManager.registeredEventListeners.action).toBeFalsy(); } expect(root._bindingDescriptors).toBeFalsy(); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should deserialize properties and listeners", function() { + it("should deserialize properties and listeners", function () { var serializationString = JSON.stringify(serialization); deserializer.init( serializationString, require); - customDeserialization.prototype.deserializeSelf = function(deserializer) { + customDeserialization.prototype.deserializeSelf = function (deserializer) { deserializer.deserializeProperties(); deserializer.deserializeUnit("listeners"); }; return deserializer.deserializeObject() - .then(function(root) { + .then(function (root) { expect(root.prop1).toBe(3.14); expect(defaultEventManager.registeredEventListeners.action).toBeDefined(); expect(root.uuid in defaultEventManager.registeredEventListeners.action).toBeTruthy(); expect(root._bindingDescriptors).toBeFalsy(); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should deserialize properties and bindings", function() { + it("should deserialize properties and bindings", function () { var serializationString = JSON.stringify(serialization); deserializer.init( serializationString, require); - customDeserialization.prototype.deserializeSelf = function(deserializer) { + customDeserialization.prototype.deserializeSelf = function (deserializer) { deserializer.deserializeProperties(); deserializer.deserializeUnit("bindings"); }; return deserializer.deserializeObject() - .then(function(root) { + .then(function (root) { expect(root.prop1).toBe(3.14); if (defaultEventManager.registeredEventListeners.action) { expect(root.uuid in defaultEventManager.registeredEventListeners.action).toBeFalsy(); } expect(Object.keys(Bindings.getBindings(root)).length).toBeGreaterThan(0); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should deserialize properties and all units", function() { + it("should deserialize properties and all units", function () { var serializationString = JSON.stringify(serialization); deserializer.init( serializationString, require); - customDeserialization.prototype.deserializeSelf = function(deserializer) { + customDeserialization.prototype.deserializeSelf = function (deserializer) { deserializer.deserializeProperties(); deserializer.deserializeUnits(); }; return deserializer.deserializeObject() - .then(function(root) { + .then(function (root) { expect(root.prop1).toBe(3.14); expect(defaultEventManager.registeredEventListeners.action).toBeDefined(); expect(root.uuid in defaultEventManager.registeredEventListeners.action).toBeTruthy(); expect(Object.keys(Bindings.getBindings(root)).length).toBeGreaterThan(0); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should deserialize into another object in an asynchronous way", function() { + it("should deserialize into another object in an asynchronous way", function () { var serializationString = JSON.stringify(serialization), newRoot = {}; deserializer.init(serializationString, require); - customDeserialization.prototype.deserializeSelf = function(deserializer) { + customDeserialization.prototype.deserializeSelf = function (deserializer) { return Promise.resolve(newRoot); }; return deserializer.deserializeObject() - .then(function(root) { + .then(function (root) { expect(root).toBe(newRoot); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); }); - it("should load the correct module even if it's from a diferent package but with the same name", function() { + it("should load the correct module even if it's from a diferent package but with the same name", function () { var deserializer1 = new Deserializer(), deserializer2 = new Deserializer(), serialization = { @@ -1134,12 +1134,12 @@ describe("serialization/montage-deserializer-spec", function() { }, serializationString = JSON.stringify(serialization); - return require.loadPackage("package-a").then(function(pkg1) { - return require.loadPackage("package-b").then(function(pkg2) { + return require.loadPackage("package-a").then(function (pkg1) { + return require.loadPackage("package-b").then(function (pkg2) { return deserializer1.init(serializationString, pkg1) - .deserialize().then(function(object1) { + .deserialize().then(function (object1) { return deserializer2.init(serializationString, pkg2) - .deserialize().then(function(object2) { + .deserialize().then(function (object2) { expect(object1.root.name).toBe("A"); expect(object2.root.name).toBe("B"); }); @@ -1148,7 +1148,7 @@ describe("serialization/montage-deserializer-spec", function() { }); }); - it("should detect a malformed serialization string", function() { + it("should detect a malformed serialization string", function () { var serializationString = "{root:}", valid; @@ -1156,7 +1156,7 @@ describe("serialization/montage-deserializer-spec", function() { expect(valid).toBe(false); }); - it("should detect a well formed serialization string", function() { + it("should detect a well formed serialization string", function () { var serializationString = '{"root": {"value": 3}}', valid; @@ -1164,7 +1164,7 @@ describe("serialization/montage-deserializer-spec", function() { expect(valid).toBe(true); }); - it("should deserialize null", function() { + it("should deserialize null", function () { var serialization = { "a": { "value": null @@ -1176,16 +1176,16 @@ describe("serialization/montage-deserializer-spec", function() { serializationString, require); return deserializer.deserialize(serializationString) - .then(function(objects) { + .then(function (objects) { expect(objects.a).toBe(null); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - describe("errors", function() { - it("should fail if no require was given", function() { + describe("errors", function () { + it("should fail if no require was given", function () { var serialization = { "root": { "prototype": "montage", @@ -1207,23 +1207,23 @@ describe("serialization/montage-deserializer-spec", function() { } }); - it("should fail if serialization is malformed", function() { + it("should fail if serialization is malformed", function () { var serializationString = "{root:}"; deserializer._serializationString = serializationString; - return deserializer.deserialize().then(function() { + return deserializer.deserialize().then(function () { // should never execute expect(true).toBe(false); - }, function(reason) { + }, function (reason) { expect(reason).toBeDefined(); - }).fail(function(reason) { + }).fail(function (reason) { console.log(reason.stack); expect("test").toBe("executed"); }); }); - it("should fail initialization if serialization is malformed", function() { + it("should fail initialization if serialization is malformed", function () { var serializationString = "{root:}"; try { diff --git a/test/serialization/montage-serializer-spec.js b/test/serialization/montage-serializer-spec.js index 6954e5c929..df405dfac5 100644 --- a/test/serialization/montage-serializer-spec.js +++ b/test/serialization/montage-serializer-spec.js @@ -8,7 +8,7 @@ var Montage = require("montage/core/core").Montage, getSerializablePropertyNames = Montage.getSerializablePropertyNames; spyOn(Montage, "getSerializablePropertyNames") - .andCallFake(function(obj) { + .andCallFake(function (obj) { if (obj === object) { return returnValues; } else { @@ -20,7 +20,7 @@ var Montage = require("montage/core/core").Montage, function createFakeElement(id) { var isElement = Element.isElement, element = { - getAttribute: function(attributeName) { + getAttribute: function (attributeName) { if (attributeName === "data-montage-id") { return id; } @@ -28,7 +28,7 @@ var Montage = require("montage/core/core").Montage, }; spyOn(Element, "isElement") - .andCallFake(function(obj) { + .andCallFake(function (obj) { if (obj === element) { return true; } else { @@ -43,22 +43,22 @@ var Montage = require("montage/core/core").Montage, return new ModuleReference().initWithIdAndRequire(id, _require || require); } -describe("serialization/montage-serializer-spec", function() { +describe("serialization/montage-serializer-spec", function () { var serializer; var originalUnits; - beforeEach(function() { + beforeEach(function () { originalUnits = MontageSerializer._units; MontageSerializer._units = {}; serializer = new MontageSerializer().initWithRequire(require); serializer.setSerializationIndentation(4); }); - afterEach(function() { + afterEach(function () { MontageSerializer._units = originalUnits; }); - it("should still serialize native types", function() { + it("should still serialize native types", function () { var object = { string: "string", number: 42, @@ -109,10 +109,10 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - describe("Montage objects serialization", function() { + describe("Montage objects serialization", function () { - describe("types", function() { - it("should serialize an empty class object", function() { + describe("types", function () { + it("should serialize an empty class object", function () { var object = objects.Empty, serialization, expectedSerialization; @@ -131,7 +131,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize an empty instance object", function() { + it("should serialize an empty instance object", function () { var object = new objects.Empty(), serialization, expectedSerialization; @@ -150,7 +150,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize without the object name", function() { + it("should serialize without the object name", function () { var object = objects.TestobjectsV2.create(), serialization, expectedSerialization; @@ -170,8 +170,8 @@ describe("serialization/montage-serializer-spec", function() { }); }); - describe("elements", function() { - it("should serialize an element", function() { + describe("elements", function () { + it("should serialize an element", function () { var object = createFakeElement("id"), serialization, expectedSerialization; @@ -187,7 +187,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize an element as an object property", function() { + it("should serialize an element as an object property", function () { var object = new objects.OneProp(), element = createFakeElement("id"), serialization, @@ -211,7 +211,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize an element multiple times", function() { + it("should serialize an element multiple times", function () { var object = new objects.TwoProps(), element = createFakeElement("id"), serialization, @@ -236,7 +236,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize an element from a different document", function() { + it("should serialize an element from a different document", function () { var context = createJavaScriptContext(), object = context.document.createElement("div"), serialization, @@ -257,8 +257,8 @@ describe("serialization/montage-serializer-spec", function() { }); }); - describe("modules", function() { - it("should serialize a module reference", function() { + describe("modules", function () { + it("should serialize a module reference", function () { var object = createFakeModuleReference("pass"), serialization, expectedSerialization; @@ -274,7 +274,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize an module reference as an object property", function() { + it("should serialize an module reference as an object property", function () { var object = new objects.OneProp(), ref = createFakeModuleReference("pass"), serialization, @@ -298,7 +298,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize an module reference multiple times", function() { + it("should serialize an module reference multiple times", function () { var object = new objects.TwoProps(), ref = createFakeModuleReference("pass"), serialization, @@ -323,7 +323,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize a module reference from a different package", function() { + it("should serialize a module reference from a different package", function () { var montageRequire = require.getPackage({name: "montage"}), object = createFakeModuleReference("core/module-reference", montageRequire), serialization, @@ -341,7 +341,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should throw when there is no mapping to the module from a different package", function() { + it("should throw when there is no mapping to the module from a different package", function () { var montageRequire = require.getPackage({name: "montage"}), object = createFakeModuleReference("pass", require), serialization; @@ -357,8 +357,8 @@ describe("serialization/montage-serializer-spec", function() { }); }); - describe("properties", function() { - it("shouldn't serialize undefined values", function() { + describe("properties", function () { + it("shouldn't serialize undefined values", function () { var object = new objects.OneProp(), undefined, serialization, @@ -380,7 +380,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize an instance object with an array property", function() { + it("should serialize an instance object with an array property", function () { var object = new objects.OneProp(), serialization, expectedSerialization; @@ -402,7 +402,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize an instance object with a distinct array property", function() { + it("should serialize an instance object with a distinct array property", function () { var object = new objects.DistinctArrayProp(), serialization, expectedSerialization; @@ -421,7 +421,7 @@ describe("serialization/montage-serializer-spec", function() { expect(JSON.parse(serialization)).toEqual(expectedSerialization); }); - it("should serialize an instance object with a distinct literal property", function() { + it("should serialize an instance object with a distinct literal property", function () { var object = new objects.DistinctLiteralProp(), serialization, expectedSerialization; @@ -441,7 +441,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize an instance object with native type properties", function() { + it("should serialize an instance object with native type properties", function () { var object = new objects.Simple(), serialization, expectedSerialization; @@ -462,7 +462,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize according to the 'serializer' attribute", function() { + it("should serialize according to the 'serializer' attribute", function () { var object = new objects.SerializableAttribute(), prop1 = new objects.OneProp(), prop2 = new objects.OneProp(), @@ -503,8 +503,8 @@ describe("serialization/montage-serializer-spec", function() { }); }); - describe("multiple references to the same object", function() { - it("should serialize the same object first as reference then value", function() { + describe("multiple references to the same object", function () { + it("should serialize the same object first as reference then value", function () { var object = new objects.SerializableAttribute(), empty = new objects.Empty(), serialization, @@ -536,7 +536,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize the same object first as value then reference", function() { + it("should serialize the same object first as value then reference", function () { var object = new objects.SerializableAttribute(), empty = new objects.Empty(), serialization, @@ -569,7 +569,7 @@ describe("serialization/montage-serializer-spec", function() { }); }); - it("should serialize two connected objects", function() { + it("should serialize two connected objects", function () { var object = new objects.OneProp(), simple = new objects.Simple(), serialization, @@ -600,7 +600,7 @@ describe("serialization/montage-serializer-spec", function() { expect(JSON.parse(serialization)).toEqual(expectedSerialization); }); - it("should serialize two disconnected objects", function() { + it("should serialize two disconnected objects", function () { var object = new objects.Empty(), simple = new objects.Simple(), serialization, @@ -630,8 +630,8 @@ describe("serialization/montage-serializer-spec", function() { expect(JSON.parse(serialization)).toEqual(expectedSerialization); }); - describe("cycles", function() { - it("should serialize an instance object that references itself", function() { + describe("cycles", function () { + it("should serialize an instance object that references itself", function () { var object = new objects.OneProp(), serialization, expectedSerialization; @@ -653,7 +653,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize two instance objects with a mutual dependence", function() { + it("should serialize two instance objects with a mutual dependence", function () { var object = new objects.OneProp(), oneProp = new objects.OneProp(), serialization, @@ -686,8 +686,8 @@ describe("serialization/montage-serializer-spec", function() { }); }); - describe("serializeProperties delegate", function() { - it("should serialize native type property", function() { + describe("serializeProperties delegate", function () { + it("should serialize native type property", function () { var object = new objects.Empty(), serialization, expectedSerialization; @@ -701,7 +701,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeProperties = function(serializer) { + object.serializeProperties = function (serializer) { serializer.set("number", 42); }; @@ -710,7 +710,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize an object property", function() { + it("should serialize an object property", function () { var object = new objects.Empty(), empty = new objects.Empty(), serialization, @@ -732,7 +732,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeProperties = function(serializer) { + object.serializeProperties = function (serializer) { serializer.set("object", empty); }; @@ -741,7 +741,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize an object property as an external reference", function() { + it("should serialize an object property as an external reference", function () { var object = new objects.Empty(), empty = new objects.Empty(), serialization, @@ -757,7 +757,7 @@ describe("serialization/montage-serializer-spec", function() { empty: {} }; - object.serializeProperties = function(serializer) { + object.serializeProperties = function (serializer) { serializer.set("object", empty, "reference"); }; @@ -766,7 +766,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize an external reference to an object that implements serializeSelf", function() { + it("should serialize an external reference to an object that implements serializeSelf", function () { var object = new objects.Empty(), empty = new objects.Empty(), serialization, @@ -782,11 +782,11 @@ describe("serialization/montage-serializer-spec", function() { empty: {} }; - object.serializeProperties = function(serializer) { + object.serializeProperties = function (serializer) { serializer.set("object", empty, "reference"); }; - empty.serializeSelf = function(serializer) { + empty.serializeSelf = function (serializer) { serializer.setProperty("object", {}); }; @@ -795,7 +795,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize all properties", function() { + it("should serialize all properties", function () { var object = new objects.CustomAllProperties(), serialization, expectedSerialization; @@ -825,7 +825,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize references to native types as value", function() { + it("should serialize references to native types as value", function () { var object = new objects.Empty(), serialization, expectedSerialization; @@ -842,7 +842,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeProperties = function(serializer) { + object.serializeProperties = function (serializer) { serializer.set("string", "string", "reference"); serializer.set("number", 42, "reference"); serializer.set("boolean", true, "reference"); @@ -854,7 +854,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should add objects", function() { + it("should add objects", function () { var object = new objects.Empty(), empty = new objects.Empty(), serialization, @@ -873,7 +873,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeProperties = function(serializer) { + object.serializeProperties = function (serializer) { serializer.addObject(empty); }; @@ -882,7 +882,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should ignore adding a native type as an object", function() { + it("should ignore adding a native type as an object", function () { var object = new objects.Empty(), serialization, expectedSerialization; @@ -893,7 +893,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeProperties = function(serializer) { + object.serializeProperties = function (serializer) { serializer.addObject("string"); }; @@ -903,10 +903,10 @@ describe("serialization/montage-serializer-spec", function() { }); }); - describe("serializeSelf delegate", function() { - beforeEach(function() { + describe("serializeSelf delegate", function () { + beforeEach(function () { MontageSerializer.defineSerializationUnit("unitA", - function(serializer, object) { + function (serializer, object) { if (object._unitA) { return { content: object._unitA @@ -914,7 +914,7 @@ describe("serialization/montage-serializer-spec", function() { } }); MontageSerializer.defineSerializationUnit("unitB", - function(serializer, object) { + function (serializer, object) { if (object._unitB) { return { content: object._unitB @@ -930,7 +930,7 @@ describe("serialization/montage-serializer-spec", function() { serializeSelfTestObject._unitB = "unit-b content"; }); - it("should only serialize the type", function() { + it("should only serialize the type", function () { var object = new objects.Empty(), serialization, expectedSerialization; @@ -941,7 +941,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { }; serialization = serializer.serializeObject(object); @@ -949,7 +949,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should only serialize the the properties", function() { + it("should only serialize the the properties", function () { var object = serializeSelfTestObject, serialization, expectedSerialization; @@ -965,7 +965,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { serializer.setAllProperties(); }; @@ -974,7 +974,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should only serialize unit A", function() { + it("should only serialize unit A", function () { var object = serializeSelfTestObject, serialization, expectedSerialization; @@ -988,7 +988,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { serializer.setUnit("unitA"); }; @@ -997,7 +997,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should only serialize unit A and unit B explicitly", function() { + it("should only serialize unit A and unit B explicitly", function () { var object = serializeSelfTestObject, serialization, expectedSerialization; @@ -1014,7 +1014,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { serializer.setUnit("unitA"); serializer.setUnit("unitB"); }; @@ -1024,7 +1024,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should only serialize all units", function() { + it("should only serialize all units", function () { var object = serializeSelfTestObject, serialization, expectedSerialization; @@ -1041,7 +1041,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { serializer.setAllUnits(); }; @@ -1050,7 +1050,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize a native type property", function() { + it("should serialize a native type property", function () { var object = new objects.Empty(), serialization, expectedSerialization; @@ -1064,7 +1064,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { serializer.setProperty("manchete", 42); }; @@ -1073,7 +1073,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize an object property", function() { + it("should serialize an object property", function () { var object = new objects.Empty(), empty = new objects.Empty(), serialization, @@ -1095,7 +1095,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { serializer.setProperty("object", empty); }; @@ -1104,7 +1104,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize an object property as an external reference", function() { + it("should serialize an object property as an external reference", function () { var object = new objects.Empty(), empty = new objects.Empty(), serialization, @@ -1120,7 +1120,7 @@ describe("serialization/montage-serializer-spec", function() { empty: {} }; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { serializer.setProperty("object", empty, "reference"); }; @@ -1129,7 +1129,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize a subtitute object", function() { + it("should serialize a subtitute object", function () { var object = new objects.Simple(), empty = new objects.Empty(), serialization, @@ -1144,7 +1144,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { return empty; }; @@ -1153,7 +1153,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize a subtitute object that is an object literal", function() { + it("should serialize a subtitute object that is an object literal", function () { var object = new objects.Simple(), serialization, expectedSerialization; @@ -1166,7 +1166,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { return { substituteObject: true }; @@ -1177,7 +1177,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize a substitute object that has already been serialized", function() { + it("should serialize a substitute object that has already been serialized", function () { var object = new objects.TwoProps(), simple = new objects.Simple(), empty = new objects.Empty(), @@ -1202,12 +1202,12 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeProperties = function(serializer) { + object.serializeProperties = function (serializer) { serializer.set("prop1", simple); serializer.set("prop2", empty); }; - empty.serializeSelf = function(serializer) { + empty.serializeSelf = function (serializer) { return simple; }; @@ -1217,7 +1217,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize a reference to a substitute object, when serializing a reference to the proxy object, that has already been serialized", function() { + it("should serialize a reference to a substitute object, when serializing a reference to the proxy object, that has already been serialized", function () { var object = new objects.TwoProps(), simple = new objects.Simple(), empty = new objects.Empty(), @@ -1242,12 +1242,12 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeProperties = function(serializer) { + object.serializeProperties = function (serializer) { serializer.set("prop1", empty); serializer.set("prop2", empty, "reference"); }; - empty.serializeSelf = function(serializer) { + empty.serializeSelf = function (serializer) { return simple; }; @@ -1257,7 +1257,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize a substitute object for an object that has a user defined label", function() { + it("should serialize a substitute object for an object that has a user defined label", function () { var object = new objects.Simple(), empty = new objects.Empty(), serialization, @@ -1272,7 +1272,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { return empty; }; @@ -1281,7 +1281,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize a substitute object, with a self reference, for an object that has a user defined label", function() { + it("should serialize a substitute object, with a self reference, for an object that has a user defined label", function () { var object = new objects.Simple(), oneProp = new objects.OneProp(), serialization, @@ -1297,7 +1297,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { return oneProp; }; @@ -1308,7 +1308,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize a substitute object, with a reference to the substituted object, for an object that has a user defined label", function() { + it("should serialize a substitute object, with a reference to the substituted object, for an object that has a user defined label", function () { var object = new objects.Simple(), oneProp = new objects.OneProp(), serialization, @@ -1324,7 +1324,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { return oneProp; }; @@ -1335,7 +1335,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize a substitute object, that has already been serialized, for an object that has a user defined label", function() { + it("should serialize a substitute object, that has already been serialized, for an object that has a user defined label", function () { var object = new objects.TwoProps(), simple = new objects.Simple(), empty = new objects.Empty(), @@ -1360,12 +1360,12 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeProperties = function(serializer) { + object.serializeProperties = function (serializer) { serializer.set("prop1", simple); serializer.set("prop2", empty); }; - empty.serializeSelf = function(serializer) { + empty.serializeSelf = function (serializer) { return simple; }; @@ -1374,7 +1374,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize a substitute object for an object where both object and substitute object have a user defined label", function() { + it("should serialize a substitute object for an object where both object and substitute object have a user defined label", function () { var object = new objects.Simple(), empty = new objects.Empty(), serialization, @@ -1389,7 +1389,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { return empty; }; @@ -1398,7 +1398,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize a substitute object of an object that was added with serializeProperties' addObject", function() { + it("should serialize a substitute object of an object that was added with serializeProperties' addObject", function () { var object = new objects.Empty(), simple = new objects.Simple(), empty = new objects.Empty(), @@ -1420,11 +1420,11 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeProperties = function(serializer) { + object.serializeProperties = function (serializer) { serializer.addObject(empty); }; - empty.serializeSelf = function(serializer) { + empty.serializeSelf = function (serializer) { return simple; }; @@ -1433,7 +1433,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize a substitute object of an object that was added with serializeSelf's addObject", function() { + it("should serialize a substitute object of an object that was added with serializeSelf's addObject", function () { var object = new objects.Empty(), simple = new objects.Simple(), empty = new objects.Empty(), @@ -1455,11 +1455,11 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { serializer.addObject(empty); }; - empty.serializeSelf = function(serializer) { + empty.serializeSelf = function (serializer) { return simple; }; @@ -1468,7 +1468,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize a chain of substitute objects", function() { + it("should serialize a chain of substitute objects", function () { var object = new objects.Empty(), simple = new objects.Simple(), oneProp = new objects.OneProp(), @@ -1485,11 +1485,11 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { return simple; }; - simple.serializeSelf = function(serializer) { + simple.serializeSelf = function (serializer) { return oneProp; }; @@ -1498,7 +1498,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should add objects", function() { + it("should add objects", function () { var object = new objects.Empty(), empty = new objects.Empty(), serialization, @@ -1517,7 +1517,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { serializer.addObject(empty); }; @@ -1526,7 +1526,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should ignore adding a native type as an object", function() { + it("should ignore adding a native type as an object", function () { var object = new objects.Empty(), serialization, expectedSerialization; @@ -1537,7 +1537,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { serializer.addObject("string"); }; @@ -1546,7 +1546,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize a substitute object when both object and substitute object have a user defined label", function() { + it("should serialize a substitute object when both object and substitute object have a user defined label", function () { var object = new objects.TwoProps(), simple = new objects.Simple(), empty = new objects.Empty(), @@ -1574,12 +1574,12 @@ describe("serialization/montage-serializer-spec", function() { } }; - object.serializeProperties = function(serializer) { + object.serializeProperties = function (serializer) { serializer.set("prop1", simple); serializer.set("prop2", empty); }; - empty.serializeSelf = function(serializer) { + empty.serializeSelf = function (serializer) { return simple; }; @@ -1589,8 +1589,8 @@ describe("serialization/montage-serializer-spec", function() { }); }); - describe("labels", function() { - it("should serialize an object using its identifier property as the label", function() { + describe("labels", function () { + it("should serialize an object using its identifier property as the label", function () { var object = new objects.OneProp(), empty = new objects.Empty(), serialization, @@ -1621,7 +1621,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should not serialize an object using its identifier property as the label if it's invalid", function() { + it("should not serialize an object using its identifier property as the label if it's invalid", function () { var object = new objects.OneProp(), empty = new objects.Empty(), serialization, @@ -1652,7 +1652,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should avoid name clashes between given labels and generated labels from identifier", function() { + it("should avoid name clashes between given labels and generated labels from identifier", function () { var object = new objects.OneProp(), empty = new objects.Empty(), serialization, @@ -1684,8 +1684,8 @@ describe("serialization/montage-serializer-spec", function() { }); }); - describe("external references", function() { - it("should serialize an external reference", function() { + describe("external references", function () { + it("should serialize an external reference", function () { var object = new objects.OneReferenceProp(), empty = new objects.Empty(), serialization, @@ -1708,13 +1708,13 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should not consider an object that was referenced and then serialized as an external object", function() { + it("should not consider an object that was referenced and then serialized as an external object", function () { var object = new objects.OneProp(), oneProp = new objects.OneProp(), externalObjects, serialization; - object.serializeProperties = function(serializer) { + object.serializeProperties = function (serializer) { serializer.set("object1", oneProp, "reference"); serializer.set("object2", oneProp); }; @@ -1725,14 +1725,14 @@ describe("serialization/montage-serializer-spec", function() { expect(Object.keys(externalObjects).length).toBe(0); }); - it("should return all external objects", function() { + it("should return all external objects", function () { var object = new objects.Empty(), empty = new objects.Empty(), simple = new objects.Simple(), serialization, externalObjects; - object.serializeSelf = function(serializer) { + object.serializeSelf = function (serializer) { serializer.setProperty("external", simple, "reference"); serializer.setProperty("internal", empty); }; @@ -1745,8 +1745,8 @@ describe("serialization/montage-serializer-spec", function() { }) }); - describe("serialization units", function() { - it("should serialize native values in serialization unit", function() { + describe("serialization units", function () { + it("should serialize native values in serialization unit", function () { var object = new objects.Empty(), serialization, expectedSerialization; @@ -1764,7 +1764,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - MontageSerializer.defineSerializationUnit("testing", function(serializer, object) { + MontageSerializer.defineSerializationUnit("testing", function (serializer, object) { return { number: 42, string: "string" @@ -1777,7 +1777,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize references in serialization unit", function() { + it("should serialize references in serialization unit", function () { var object = new objects.Empty(), simple = new objects.Simple(), serialization, @@ -1797,7 +1797,7 @@ describe("serialization/montage-serializer-spec", function() { simple: {} }; - MontageSerializer.defineSerializationUnit("testing", function(serializer, object) { + MontageSerializer.defineSerializationUnit("testing", function (serializer, object) { var simpleRef = serializer.addObjectReference(simple); return { @@ -1813,7 +1813,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should first serialize the object then a reference in serialization unit", function() { + it("should first serialize the object then a reference in serialization unit", function () { var object = new objects.Empty(), simple = new objects.Simple(), serialization, @@ -1840,7 +1840,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - MontageSerializer.defineSerializationUnit("testing", function(serializer, _object) { + MontageSerializer.defineSerializationUnit("testing", function (serializer, _object) { if (_object !== object) { return; } @@ -1860,7 +1860,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should first serialize a reference then the object in serialization unit", function() { + it("should first serialize a reference then the object in serialization unit", function () { var object = new objects.Empty(), simple = new objects.Simple(), serialization, @@ -1887,7 +1887,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - MontageSerializer.defineSerializationUnit("testing", function(serializer, _object) { + MontageSerializer.defineSerializationUnit("testing", function (serializer, _object) { if (_object !== object) { return; } @@ -1906,7 +1906,7 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should serialize a parentless object in serialization unit", function() { + it("should serialize a parentless object in serialization unit", function () { var object = new objects.Simple(), empty = new objects.Empty(), serialization, @@ -1929,7 +1929,7 @@ describe("serialization/montage-serializer-spec", function() { } }; - MontageSerializer.defineSerializationUnit("testing", function(serializer, _object) { + MontageSerializer.defineSerializationUnit("testing", function (serializer, _object) { if (_object !== object) { return; } @@ -1946,8 +1946,8 @@ describe("serialization/montage-serializer-spec", function() { }); }); - describe("Template properties serialization", function() { - it("should serialize a template property alias", function() { + describe("Template properties serialization", function () { + it("should serialize a template property alias", function () { var object = { ":templateProperty": new Alias().init("@component:propertyName") }, @@ -1965,52 +1965,52 @@ describe("serialization/montage-serializer-spec", function() { .toEqual(expectedSerialization); }); - it("should not serialize a alias outside a template property", function() { + it("should not serialize a alias outside a template property", function () { var object = { "property": new Alias().init("@component:propertyName") }; - expect(function() { + expect(function () { serializer.serialize(object); }).toThrow(); }); - it("should not serialize a value with a template property label", function() { + it("should not serialize a value with a template property label", function () { var object = { ":property": 42 }; - expect(function() { + expect(function () { serializer.serialize(object); }).toThrow(); }); - it("should not serialize an object literal with a template property label", function() { + it("should not serialize an object literal with a template property label", function () { var object = { ":property": {} }; - expect(function() { + expect(function () { serializer.serialize(object); }).toThrow(); }); - it("should not serialize a regexp with a template property label", function() { + it("should not serialize a regexp with a template property label", function () { var object = { ":property": /regexp/ }; - expect(function() { + expect(function () { serializer.serialize(object); }).toThrow(); }); - it("should not serialize a montage object with a template property label", function() { + it("should not serialize a montage object with a template property label", function () { var object = { ":property": objects.Empty }; - expect(function() { + expect(function () { serializer.serialize(object); }).toThrow(); }); diff --git a/test/serialization/serialization-extractor-spec.js b/test/serialization/serialization-extractor-spec.js index 7c051b033e..203ae80611 100644 --- a/test/serialization/serialization-extractor-spec.js +++ b/test/serialization/serialization-extractor-spec.js @@ -7,14 +7,14 @@ var Montage = require("montage").Montage, Serialization = require("montage/core/serialization/serialization").Serialization, Promise = require("montage/core/promise").Promise; -describe("reel/serialization/serialization-extractor-spec", function() { +describe("reel/serialization/serialization-extractor-spec", function () { var serializationExtractor; - beforeEach(function() { + beforeEach(function () { serializationExtractor = new SerializationExtractor(); }); - it("should extract an object", function() { + it("should extract an object", function () { var objects = { "one": { "properties": { @@ -49,7 +49,7 @@ describe("reel/serialization/serialization-extractor-spec", function() { .toEqual(expectedObjects); }); - it("should extract an object and add a defined external", function() { + it("should extract an object and add a defined external", function () { var objects = { "one": { "properties": { @@ -76,7 +76,7 @@ describe("reel/serialization/serialization-extractor-spec", function() { .toEqual(expectedObjects); }); - it("should extract an object with its object dependencies as external objects", function() { + it("should extract an object with its object dependencies as external objects", function () { var objects = { "one": { "properties": { @@ -113,7 +113,7 @@ describe("reel/serialization/serialization-extractor-spec", function() { .toEqual(expectedObjects); }); - it("should extract objects with dependencies between them", function() { + it("should extract objects with dependencies between them", function () { var objects = { "one": { "properties": { @@ -150,7 +150,7 @@ describe("reel/serialization/serialization-extractor-spec", function() { .toEqual(expectedObjects); }); - it("should extract two objects even when one of them is a defined external", function() { + it("should extract two objects even when one of them is a defined external", function () { var objects = { "one": { "properties": { @@ -182,7 +182,7 @@ describe("reel/serialization/serialization-extractor-spec", function() { .toEqual(expectedObjects); }); - it("should extract two objects even if one of them is an external reference", function() { + it("should extract two objects even if one of them is an external reference", function () { var objects = { "one": { "properties": { @@ -209,7 +209,7 @@ describe("reel/serialization/serialization-extractor-spec", function() { .toEqual(expectedObjects); }); - it("should ignore passed external objects that do not exist", function() { + it("should ignore passed external objects that do not exist", function () { var objects = { "one": { "properties": { @@ -233,8 +233,8 @@ describe("reel/serialization/serialization-extractor-spec", function() { .toEqual(expectedObjects); }); - describe("bindings", function() { - it("should extract an object and its one way bindings as external objects", function() { + describe("bindings", function () { + it("should extract an object and its one way bindings as external objects", function () { var objects = { "one": { "properties": { @@ -268,7 +268,7 @@ describe("reel/serialization/serialization-extractor-spec", function() { .toEqual(expectedObjects); }); - it("should extract an object and its two way bindings as external objects", function() { + it("should extract an object and its two way bindings as external objects", function () { var objects = { "one": { "properties": { @@ -302,7 +302,7 @@ describe("reel/serialization/serialization-extractor-spec", function() { .toEqual(expectedObjects); }); - it("should extract an object with bindings that have multiple references", function() { + it("should extract an object with bindings that have multiple references", function () { var objects = { "one": { "properties": { @@ -342,7 +342,7 @@ describe("reel/serialization/serialization-extractor-spec", function() { }); }); - it("should extract an object and its listeners as external objects", function() { + it("should extract an object and its listeners as external objects", function () { var objects = { "one": { "properties": { diff --git a/test/serialization/serialization-inspector-spec.js b/test/serialization/serialization-inspector-spec.js index b16cdf87e7..5cc695a448 100644 --- a/test/serialization/serialization-inspector-spec.js +++ b/test/serialization/serialization-inspector-spec.js @@ -6,15 +6,15 @@ var Montage = require("montage").Montage, SerializationInspector = require("montage/core/serialization/serialization").SerializationInspector, Serialization = require("montage/core/serialization/serialization").Serialization; -describe("reel/serialization/serialization-inspector-spec", function() { +describe("reel/serialization/serialization-inspector-spec", function () { var inspector; - beforeEach(function() { + beforeEach(function () { inspector = new SerializationInspector(); }); - describe("visitor", function() { - it("should visit a number", function() { + describe("visitor", function () { + it("should visit a number", function () { var object = { "object": { "value": 42 @@ -33,7 +33,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { expect(args[0].data).toBe(object.object.value); }); - it("should visit a string", function() { + it("should visit a string", function () { var object = { "object": { "value": "a string" @@ -52,7 +52,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { expect(args[0].data).toBe(object.object.value); }); - it("should visit a regexp", function() { + it("should visit a regexp", function () { var object = { "object": { "value": {"/": {"source": "regexp"}} @@ -71,7 +71,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { expect(args[0].data).toEqual(object.object.value["/"]); }); - it("should visit a null", function() { + it("should visit a null", function () { var object = { "object": { "value": null @@ -90,7 +90,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { expect(args[0].data).toBe(object.object.value); }); - it("should visit an array", function() { + it("should visit an array", function () { var object = { "object": { "value": ["a string", 42] @@ -119,7 +119,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { expect(args[0].data).toBe(object.object.value[1]); }); - it("should visit an object", function() { + it("should visit an object", function () { var object = { "object": { "value": { @@ -151,7 +151,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { expect(args[0].data).toBe(object.object.value.id); }); - it("should visit a reference", function() { + it("should visit a reference", function () { var object = { "object": { "value": {"@": "label"} @@ -170,7 +170,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { expect(args[0].data).toBe(object.object.value["@"]); }); - it("should visit an element", function() { + it("should visit an element", function () { var object = { "object": { "value": {"#": "label"} @@ -189,7 +189,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { expect(args[0].data).toBe(object.object.value["#"]); }); - it("should visit a single object", function() { + it("should visit a single object", function () { var object = { "object": { "value": { @@ -219,7 +219,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { expect(args[0].data).toEqual(object.foo.value); }); - it("should visit a montage object", function() { + it("should visit a montage object", function () { var object = { "text": { "prototype": "montage/ui/text.reel", @@ -249,7 +249,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { expect(args[0].data).toEqual(object.text.properties.identifier); }); - it("should visit bindings", function() { + it("should visit bindings", function () { var object = { "text": { "prototype": "montage/ui/text.reel", @@ -271,7 +271,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { expect(args[0].data).toEqual(object.text.bindings); }); - it("should visit a binding", function() { + it("should visit a binding", function () { var object = { "text": { "prototype": "montage/ui/text.reel", @@ -294,7 +294,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { expect(args[0].data).toEqual(object.text.bindings.value); }); - it("should visit a binding reference", function() { + it("should visit a binding reference", function () { var object = { "text": { "prototype": "montage/ui/text.reel", @@ -316,7 +316,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { expect(args[0].data).toBe("object"); }); - it("should visit complex binding references", function() { + it("should visit complex binding references", function () { var object = { "text": { "prototype": "montage/ui/text.reel", @@ -342,7 +342,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { expect(args[0].data).toBe("owner"); }); - it("should visit a binding converter", function() { + it("should visit a binding converter", function () { var serialization = new Serialization().initWithObject({ "text": { "prototype": "montage/ui/text.reel", @@ -366,7 +366,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { expect(args[0].data).toBe("converter"); }); - it("should visit localizations", function() { + it("should visit localizations", function () { var object = { "text": { "prototype": "montage/ui/text.reel", @@ -388,7 +388,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { expect(args[0].data).toEqual(object.text.localizations); }); - it("should visit a localization", function() { + it("should visit a localization", function () { var object = { "text": { "prototype": "montage/ui/text.reel", @@ -411,7 +411,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { expect(args[0].data).toEqual(object.text.localizations.value); }); - it("should visit localization references", function() { + it("should visit localization references", function () { var object = { "text": { "prototype": "montage/ui/text.reel", @@ -436,8 +436,8 @@ describe("reel/serialization/serialization-inspector-spec", function() { }); }); - describe("modifications", function() { - it("should modify a number", function() { + describe("modifications", function () { + it("should modify a number", function () { var serialization = new Serialization().initWithObject({ "object": { "value": 42 @@ -452,7 +452,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { visitorSpy, args; - visitor = function(node) { + visitor = function (node) { node.data = 3.14; }; @@ -465,7 +465,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { .toEqual(expectedSerialization); }); - it("should modify a string", function() { + it("should modify a string", function () { var serialization = new Serialization().initWithObject({ "object": { "value": "a string" @@ -480,7 +480,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { visitorSpy, args; - visitor = function(node) { + visitor = function (node) { node.data = "another string"; }; @@ -493,7 +493,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { .toEqual(expectedSerialization); }); - it("should modify a regexp", function() { + it("should modify a regexp", function () { var serialization = new Serialization().initWithObject({ "object": { "value": {"/": {"source": "regexp"}} @@ -508,7 +508,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { visitorSpy, args; - visitor = function(node) { + visitor = function (node) { node.data.flags = "gi"; }; @@ -521,7 +521,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { .toEqual(expectedSerialization); }); - it("should modify a null", function() { + it("should modify a null", function () { var serialization = new Serialization().initWithObject({ "object": { "value": null @@ -536,7 +536,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { visitorSpy, args; - visitor = function(node) { + visitor = function (node) { node.data = "not a null"; }; @@ -549,7 +549,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { .toEqual(expectedSerialization); }); - it("should modify an array", function() { + it("should modify an array", function () { var serialization = new Serialization().initWithObject({ "object": { "value": [1, 2, 3] @@ -564,7 +564,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { visitorSpy, args; - visitor = function(node) { + visitor = function (node) { if (node.type === "array") { node.data = [4, 5, 6]; } @@ -579,7 +579,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { .toEqual(expectedSerialization); }); - it("should modify an object", function() { + it("should modify an object", function () { var serialization = new Serialization().initWithObject({ "object": { "value": { @@ -598,7 +598,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { visitorSpy, args; - visitor = function(node) { + visitor = function (node) { if (node.type === "object") { node.data = {number: 42}; } @@ -613,7 +613,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { .toEqual(expectedSerialization); }); - it("should modify a reference", function() { + it("should modify a reference", function () { var serialization = new Serialization().initWithObject({ "object": { "value": {"@": "string"} @@ -628,7 +628,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { visitorSpy, args; - visitor = function(node) { + visitor = function (node) { node.data = "number"; }; @@ -641,7 +641,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { .toEqual(expectedSerialization); }); - it("should modify a label", function() { + it("should modify a label", function () { var serialization = new Serialization().initWithObject({ "object1": { "value": { @@ -670,7 +670,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { visitorSpy, args; - visitor = function(node) { + visitor = function (node) { if (node.label === "object1") { node.label = "object"; } @@ -685,7 +685,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { .toEqual(expectedSerialization); }); - it("should modify a label of a montage object", function() { + it("should modify a label of a montage object", function () { var serialization = new Serialization().initWithObject({ "object1": { "prototype": "montage/ui/text.reel" @@ -700,7 +700,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { visitorSpy, args; - visitor = function(node) { + visitor = function (node) { if (node.label === "object1") { node.label = "object"; } @@ -715,7 +715,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { .toEqual(expectedSerialization); }); - it("should modify binding references", function() { + it("should modify binding references", function () { var serialization = new Serialization().initWithObject({ "text": { "prototype": "montage/ui/text.reel", @@ -735,7 +735,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { visitorSpy, visitor; - visitor = function(node) { + visitor = function (node) { if (node.type === "reference") { node.data = "array"; } @@ -749,7 +749,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { .toEqual(expectedSerialization); }); - it("should modify complex binding references", function() { + it("should modify complex binding references", function () { var serialization = new Serialization().initWithObject({ "text": { "prototype": "montage/ui/text.reel", @@ -769,7 +769,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { visitorSpy, visitor; - visitor = function(node) { + visitor = function (node) { if (node.type === "reference") { if (node.data == "objects") { node.data = "objects2"; @@ -787,7 +787,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { .toEqual(expectedSerialization); }); - it("should modify a binding converter label", function() { + it("should modify a binding converter label", function () { var serialization = new Serialization().initWithObject({ "text": { "prototype": "montage/ui/text.reel", @@ -813,7 +813,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { visitorSpy, visitor; - visitor = function(node) { + visitor = function (node) { if (node.type === "reference") { if (node.data == "converter") { node.data = "converterNewLabel"; @@ -829,7 +829,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { .toEqual(expectedSerialization); }); - it("should modify a localization reference", function() { + it("should modify a localization reference", function () { var serialization = new Serialization().initWithObject({ "text": { "prototype": "montage/ui/text.reel", @@ -853,7 +853,7 @@ describe("reel/serialization/serialization-inspector-spec", function() { visitorSpy, visitor; - visitor = function(node) { + visitor = function (node) { if (node.type === "reference") { node.data = "foo"; } diff --git a/test/serialization/serialization-merger-spec.js b/test/serialization/serialization-merger-spec.js index 6c95ca9cab..aa46e2cf60 100644 --- a/test/serialization/serialization-merger-spec.js +++ b/test/serialization/serialization-merger-spec.js @@ -7,14 +7,14 @@ var Montage = require("montage").Montage, Serialization = require("montage/core/serialization/serialization").Serialization, MontageLabeler = require("montage/core/serialization/serializer/montage-labeler").MontageLabeler; -describe("reel/serialization/serialization-merger-spec", function() { +describe("reel/serialization/serialization-merger-spec", function () { var merger; - beforeEach(function() { + beforeEach(function () { merger = new SerializationMerger(); }); - it("should merge two non-colliding serializations", function() { + it("should merge two non-colliding serializations", function () { var serialization1 = new Serialization().initWithObject({ "object1": { "value": { @@ -49,7 +49,7 @@ describe("reel/serialization/serialization-merger-spec", function() { .toEqual(expectedSerialization); }); - it("should merge two colliding serializations", function() { + it("should merge two colliding serializations", function () { var serialization1 = new Serialization().initWithObject({ "object": { "value": { @@ -84,7 +84,7 @@ describe("reel/serialization/serialization-merger-spec", function() { .toEqual(expectedSerialization); }); - it("should return a collision table when merging serializations", function() { + it("should return a collision table when merging serializations", function () { var serialization1 = new Serialization().initWithObject({ "object": { "value": { @@ -107,9 +107,9 @@ describe("reel/serialization/serialization-merger-spec", function() { expect("object" in collisionTable).toBe(true); }); - describe("delegate", function() { - describe("willMergeObjectWithLabel", function() { - it("should not change the merge behavior", function() { + describe("delegate", function () { + describe("willMergeObjectWithLabel", function () { + it("should not change the merge behavior", function () { var serialization1 = new Serialization().initWithObject({ "object1": { "value": { @@ -138,7 +138,7 @@ describe("reel/serialization/serialization-merger-spec", function() { } }, delegate = { - willMergeObjectWithLabel: function(label) { + willMergeObjectWithLabel: function (label) { } }; @@ -148,7 +148,7 @@ describe("reel/serialization/serialization-merger-spec", function() { .toEqual(expectedSerialization); }); - it("should merge object2 as object1", function() { + it("should merge object2 as object1", function () { var serialization1 = new Serialization().initWithObject({ "object1": { "value": { @@ -184,7 +184,7 @@ describe("reel/serialization/serialization-merger-spec", function() { } }, delegate = { - willMergeObjectWithLabel: function(label) { + willMergeObjectWithLabel: function (label) { if (label === "object2") { return "object1"; } @@ -196,7 +196,7 @@ describe("reel/serialization/serialization-merger-spec", function() { .toEqual(expectedSerialization); }); - it("should merge object2 as object1 from serialization1 even though there's another on in serialization2", function() { + it("should merge object2 as object1 from serialization1 even though there's another on in serialization2", function () { var serialization1 = new Serialization().initWithObject({ "object1": { "value": { @@ -241,7 +241,7 @@ describe("reel/serialization/serialization-merger-spec", function() { } }, delegate = { - willMergeObjectWithLabel: function(label) { + willMergeObjectWithLabel: function (label) { if (label === "object2") { return "object1"; } @@ -253,7 +253,7 @@ describe("reel/serialization/serialization-merger-spec", function() { .toEqual(expectedSerialization); }); - it("should rename a template property to a label that refers to a component that exists in serialization1", function() { + it("should rename a template property to a label that refers to a component that exists in serialization1", function () { var serialization1 = new Serialization().initWithObject({ "object1": { "value": { @@ -273,7 +273,7 @@ describe("reel/serialization/serialization-merger-spec", function() { "object1:cell": {} }, delegate = { - willMergeObjectWithLabel: function(label) { + willMergeObjectWithLabel: function (label) { if (label === "object2:cell") { return "object1:cell"; } @@ -285,7 +285,7 @@ describe("reel/serialization/serialization-merger-spec", function() { .toEqual(expectedSerialization); }); - it("should rename an object label when merging", function() { + it("should rename an object label when merging", function () { var serialization1 = new Serialization().initWithObject({ "x": { "value": { @@ -313,7 +313,7 @@ describe("reel/serialization/serialization-merger-spec", function() { } }, delegate = { - willMergeObjectWithLabel: function(label) { + willMergeObjectWithLabel: function (label) { if (label === "y") { return "z"; } @@ -325,7 +325,7 @@ describe("reel/serialization/serialization-merger-spec", function() { .toEqual(expectedSerialization); }); - it("should rename an object label when merging even when there's a collision", function() { + it("should rename an object label when merging even when there's a collision", function () { var serialization1 = new Serialization().initWithObject({ "x": { "value": { @@ -353,7 +353,7 @@ describe("reel/serialization/serialization-merger-spec", function() { } }, delegate = { - willMergeObjectWithLabel: function(label) { + willMergeObjectWithLabel: function (label) { if (label === "x") { return "z"; } @@ -365,7 +365,7 @@ describe("reel/serialization/serialization-merger-spec", function() { .toEqual(expectedSerialization); }); - it("should throw when willMergeObjectWithLabel returns a labels that already exists in the origin serialization", function() { + it("should throw when willMergeObjectWithLabel returns a labels that already exists in the origin serialization", function () { var serialization1 = new Serialization().initWithObject({ "x": { "value": { @@ -386,7 +386,7 @@ describe("reel/serialization/serialization-merger-spec", function() { } }), delegate = { - willMergeObjectWithLabel: function(label) { + willMergeObjectWithLabel: function (label) { if (label === "x") { return "z"; } @@ -398,7 +398,7 @@ describe("reel/serialization/serialization-merger-spec", function() { }).toThrow(); }); - it("should throw when willMergeObjectWithLabel returns a labels that was generated to solve a collision", function() { + it("should throw when willMergeObjectWithLabel returns a labels that was generated to solve a collision", function () { var serialization1 = new Serialization().initWithObject({ "x": { "value": { @@ -424,7 +424,7 @@ describe("reel/serialization/serialization-merger-spec", function() { } }), delegate = { - willMergeObjectWithLabel: function(label) { + willMergeObjectWithLabel: function (label) { if (label === "x") { return "x4"; } @@ -437,7 +437,7 @@ describe("reel/serialization/serialization-merger-spec", function() { }); }); - describe("labeler", function() { + describe("labeler", function () { var serialization1 = new Serialization().initWithObject({ "object": { "value": { @@ -464,8 +464,8 @@ describe("reel/serialization/serialization-merger-spec", function() { }); }); - describe("creation of collision table", function() { - it("should find no collisions", function() { + describe("creation of collision table", function () { + it("should find no collisions", function () { var labels1 = ["foo"], labels2 = ["bar"], foundCollisions; @@ -475,7 +475,7 @@ describe("reel/serialization/serialization-merger-spec", function() { expect(foundCollisions).toBe(false); }); - it("should find collisions", function() { + it("should find collisions", function () { var labels1 = ["foo"], labels2 = ["foo", "bar"], collisionTable = {}, @@ -487,7 +487,7 @@ describe("reel/serialization/serialization-merger-spec", function() { expect(collisionTable.foo).toBeDefined(); }); - it("should find a collision from the template property", function() { + it("should find a collision from the template property", function () { var labels1 = ["repetition:iteration"], labels2 = ["repetition"], collisionTable = {}, @@ -499,7 +499,7 @@ describe("reel/serialization/serialization-merger-spec", function() { expect(collisionTable.repetition).toBeDefined(); }); - it("should reuse the new label given to the component label", function() { + it("should reuse the new label given to the component label", function () { var labels1 = ["repetition"], labels2 = ["repetition", "repetition:iteration"], collisionTable = {}, @@ -513,7 +513,7 @@ describe("reel/serialization/serialization-merger-spec", function() { expect(collisionTable.repetition).toBe(newLabel); }); - it("should rename the component label when the template property is renamed", function() { + it("should rename the component label when the template property is renamed", function () { var labels1 = ["repetition:iteration"], labels2 = ["repetition:iteration", "repetition"], collisionTable = {}, @@ -527,7 +527,7 @@ describe("reel/serialization/serialization-merger-spec", function() { expect(collisionTable.repetition).toBe(newLabel); }); - it("should rename the template property when it finds its component label colides", function() { + it("should rename the template property when it finds its component label colides", function () { var labels1 = ["repetition"], labels2 = ["repetition:iteration"], collisionTable = {}, @@ -539,7 +539,7 @@ describe("reel/serialization/serialization-merger-spec", function() { expect(collisionTable["repetition:iteration"]).toBeDefined(); }); - it("should rename the component to the same new label the template property got", function() { + it("should rename the component to the same new label the template property got", function () { var labels1 = ["repetition"], labels2 = ["repetition:iteration", "repetition"], collisionTable = {}, @@ -553,7 +553,7 @@ describe("reel/serialization/serialization-merger-spec", function() { expect(collisionTable.repetition).toBe(newLabel); }); - it("should not solve a conflict by using a label that exists in the source labels", function() { + it("should not solve a conflict by using a label that exists in the source labels", function () { var labels1 = ["owner"], labels2 = ["object", "owner"], collisionTable = {}; @@ -562,7 +562,7 @@ describe("reel/serialization/serialization-merger-spec", function() { expect(collisionTable.owner).not.toBe("object"); }); - it("should not solve a conflict by using a template property label that exists in the source labels", function() { + it("should not solve a conflict by using a template property label that exists in the source labels", function () { var labels1 = ["owner:foo"], labels2 = ["object:foo", "owner:foo"], collisionTable = {}; @@ -571,7 +571,7 @@ describe("reel/serialization/serialization-merger-spec", function() { expect(collisionTable["owner:foo"]).not.toBe("object:foo"); }); - it("should not find a conflict just because the label exists in the labeler", function() { + it("should not find a conflict just because the label exists in the labeler", function () { var labels1 = ["owner"], labels2 = ["object"], collisionTable = {}, @@ -584,7 +584,7 @@ describe("reel/serialization/serialization-merger-spec", function() { }); }); - xit("template", function() { + xit("template", function () { var serialization1 = new Serialization().initWithObject({ "object1": { "value": { diff --git a/test/serialization/serialization-spec.js b/test/serialization/serialization-spec.js index f498773cf0..57f2e70f54 100644 --- a/test/serialization/serialization-spec.js +++ b/test/serialization/serialization-spec.js @@ -6,14 +6,14 @@ var Montage = require("montage").Montage, Serialization = require("montage/core/serialization/serialization").Serialization, Promise = require("montage/core/promise").Promise; -describe("reel/serialization/serialization-spec", function() { +describe("reel/serialization/serialization-spec", function () { var serialization; - beforeEach(function() { + beforeEach(function () { serialization = new Serialization(); }); - it("should clone", function() { + it("should clone", function () { var objects = { "one": { "properties": { @@ -31,8 +31,8 @@ describe("reel/serialization/serialization-spec", function() { expect(serializationClone.getSerializationString()).toBe(serialization.getSerializationString()); }); - describe("hasSerializationLabel", function() { - it("should know if a label exists in the serialization", function() { + describe("hasSerializationLabel", function () { + it("should know if a label exists in the serialization", function () { var objects = { "one": {} }, @@ -44,7 +44,7 @@ describe("reel/serialization/serialization-spec", function() { expect(hasLabel).toBe(true); }); - it("should know if a label does not exist in the serialization", function() { + it("should know if a label does not exist in the serialization", function () { var objects = { "one": {} }, @@ -57,8 +57,8 @@ describe("reel/serialization/serialization-spec", function() { }); }); - describe("isAlias", function() { - it("should know that an object is an alias", function() { + describe("isAlias", function () { + it("should know that an object is an alias", function () { var objects = { "one": { "alias": "@component:propertyName" @@ -73,7 +73,7 @@ describe("reel/serialization/serialization-spec", function() { expect(isAlias).toBe(true); }); - it("should know that an object is not an alias", function() { + it("should know that an object is not an alias", function () { var objects = { "one": {} }, @@ -86,7 +86,7 @@ describe("reel/serialization/serialization-spec", function() { }); }); - it("should find the labels of objects with a specific element id", function() { + it("should find the labels of objects with a specific element id", function () { var objects = { "one": { "properties": { @@ -117,7 +117,7 @@ describe("reel/serialization/serialization-spec", function() { expect(labels).toContain("three"); }); - it("should rename an element reference", function() { + it("should rename an element reference", function () { var objects = { "one": { "properties": { @@ -147,7 +147,7 @@ describe("reel/serialization/serialization-spec", function() { }); - it("should find no external object labels", function() { + it("should find no external object labels", function () { var object = { "one": { "value": 1 @@ -169,7 +169,7 @@ describe("reel/serialization/serialization-spec", function() { expect(labels.length).toBe(0); }); - it("should find all external object labels", function() { + it("should find all external object labels", function () { var object = { "one": {}, @@ -189,7 +189,7 @@ describe("reel/serialization/serialization-spec", function() { expect(labels).toContain("three"); }); - it("should get the element id of a component's element", function() { + it("should get the element id of a component's element", function () { var object = { "one": { "properties": { @@ -205,8 +205,8 @@ describe("reel/serialization/serialization-spec", function() { expect(elementId).toBe("mid"); }); - describe("isExternalObject", function() { - beforeEach(function() { + describe("isExternalObject", function () { + beforeEach(function () { var object = { "one": {}, @@ -220,18 +220,18 @@ describe("reel/serialization/serialization-spec", function() { serialization.initWithObject(object); }); - it("can determine an external object", function() { + it("can determine an external object", function () { expect(serialization.isExternalObject("one")).toBe(true); }); - it("can determine an internal object", function() { + it("can determine an internal object", function () { expect(serialization.isExternalObject("two")).toBe(false); }); - describe("without a serialization object", function() { - beforeEach(function() { + describe("without a serialization object", function () { + beforeEach(function () { serialization.initWithObject(null); }); - it("returns false", function() { + it("returns false", function () { expect(serialization.isExternalObject("one")).toBe(false); }); }); diff --git a/test/serialization/testobjects-v2.js b/test/serialization/testobjects-v2.js index 5241717193..bfd0eec3ce 100644 --- a/test/serialization/testobjects-v2.js +++ b/test/serialization/testobjects-v2.js @@ -47,7 +47,7 @@ exports.OneProp = Target.specialize( { prop: {value: null, serializable: true}, deserializedFromSerializationCount: {value: 0, serializable: false}, - deserializedFromSerialization: {value: function() { + deserializedFromSerialization: {value: function () { this.deserializedFromSerializationCount++; }} }); @@ -79,11 +79,11 @@ exports.DistinctLiteralProp = Montage.specialize( { exports.CustomProperties = Montage.specialize( { manchete: {value: 42}, - serializeProperties: {value: function(serializer) { + serializeProperties: {value: function (serializer) { serializer.set("manchete", 226); }}, - deserializeProperties: {value: function(serializer) { + deserializeProperties: {value: function (serializer) { this.manchete = serializer.get("manchete"); }} }); @@ -91,11 +91,11 @@ exports.CustomProperties = Montage.specialize( { exports.CustomPropertiesRef = Montage.specialize( { object: {value: new exports.Empty()}, - serializeProperties: {value: function(serializer) { + serializeProperties: {value: function (serializer) { serializer.set("object", this.object, "reference"); }}, - deserializeProperties: {value: function(deserializer) { + deserializeProperties: {value: function (deserializer) { this.object = deserializer.get("object"); }} }); @@ -106,11 +106,11 @@ exports.CustomAllProperties = Montage.specialize( { luz: {value: new exports.Empty(), serializable: true}, tarantino: {value: 105, serializable: false}, - serializeProperties: {value: function(serializer) { + serializeProperties: {value: function (serializer) { serializer.setAll(); }}, - deserializeProperties: {value: function(serializer) { + deserializeProperties: {value: function (serializer) { this.manchete = serializer.get("manchete"); }} }); @@ -118,11 +118,11 @@ exports.CustomAllProperties = Montage.specialize( { exports.CustomRef = Montage.specialize( { object: {value: new exports.Empty()}, - serializeSelf: {value: function(serializer) { + serializeSelf: {value: function (serializer) { serializer.setProperty("object", this.object, "reference"); }}, - deserializeSelf: {value: function(deserializer) { + deserializeSelf: {value: function (deserializer) { this.object = deserializer.getProperty("object"); }} }); @@ -130,7 +130,7 @@ exports.CustomRef = Montage.specialize( { exports.Singleton = Montage.specialize( { instance: {value: {another: "object"}}, - deserializeSelf: {value: function(serializer) { + deserializeSelf: {value: function (serializer) { return this.instance; }} }); @@ -139,11 +139,11 @@ exports.Comp = Montage.specialize( { element: {value: null, serializable: true}, child: {value: null, serializable: true}, templateDidLoadCount: {value: 0}, - templateDidLoad: {value: function() { + templateDidLoad: {value: function () { this.templateDidLoadCount++; }}, deserializedFromTemplateCount: {value: 0}, - deserializedFromTemplate: {value: function() { + deserializedFromTemplate: {value: function () { this.deserializedFromTemplateCount++; }}, }); diff --git a/test/state-chart-spec.js b/test/state-chart-spec.js index 9cd1f69bc2..95e1422f7e 100644 --- a/test/state-chart-spec.js +++ b/test/state-chart-spec.js @@ -32,27 +32,27 @@ var Montage = require("montage").Montage; var StateChart= require("montage/core/state-chart").StateChart; var State = require("montage/core/state-chart").State; -describe("state-chart-spec", function() { +describe("state-chart-spec", function () { var stateChart, rootState, stateA, stateB, stateC, stateD; - beforeEach(function() { + beforeEach(function () { // NOTE this would probably be written more concisely in real use, I've exposed all the // states for my own use during testing stateA = new State().init({ - gamma: function() { + gamma: function () { this.gotoState('C'); } }); stateB = new State().init({ - alpha: function() { + alpha: function () { this.gotoState('A'); }, - delta: function() { + delta: function () { this.gotoState('C'); } }); @@ -78,38 +78,38 @@ describe("state-chart-spec", function() { stateChart = new StateChart().initWithState(rootState); }); - describe("when initialized", function() { + describe("when initialized", function () { - it("should be in the deepest initial state", function() { + it("should be in the deepest initial state", function () { expect(stateChart.currentState.path).toBe("D.A") }); }); - describe("when determining whether it is in a specified state", function() { + describe("when determining whether it is in a specified state", function () { - it("should be true when the currentState is the specified state", function() { + it("should be true when the currentState is the specified state", function () { expect(stateChart.currentState.isInState("A")).toBeTruthy(); }); - it("should be true when the currentState is within the specifiedState", function() { + it("should be true when the currentState is within the specifiedState", function () { expect(stateChart.currentState.isInState("D")).toBeTruthy(); }); - it("must be false when the currentState is not the specifiedState and is not a child of the specifiedState", function() { + it("must be false when the currentState is not the specifiedState and is not a child of the specifiedState", function () { expect(stateChart.currentState.isInState("C")).toBeFalsy(); }); }); - describe("when performing actions", function() { + describe("when performing actions", function () { - it("should end up at the expected state", function() { + it("should end up at the expected state", function () { stateChart.performAction("gamma"); expect(stateChart.currentState.path).toBe("D.C") }); - it("exit any states that are not no longer active as part of changing states", function() { + it("exit any states that are not no longer active as part of changing states", function () { spyOn(stateA, "exitState"); stateChart.performAction("gamma"); @@ -117,7 +117,7 @@ describe("state-chart-spec", function() { expect(stateA.exitState).toHaveBeenCalled(); }); - it("enter any states that are now active as part of changing states", function() { + it("enter any states that are now active as part of changing states", function () { spyOn(stateC, "enterState"); stateChart.performAction("gamma"); @@ -125,9 +125,9 @@ describe("state-chart-spec", function() { expect(stateC.enterState).toHaveBeenCalled(); }); - describe("when the action is defined on a parent", function() { + describe("when the action is defined on a parent", function () { - it("should end up at the expected state", function() { + it("should end up at the expected state", function () { stateChart.performAction("beta"); expect(stateChart.currentState.path).toBe("B") }); diff --git a/test/string-spec.js b/test/string-spec.js index 7810fe283f..bff8d2c326 100644 --- a/test/string-spec.js +++ b/test/string-spec.js @@ -30,30 +30,30 @@ POSSIBILITY OF SUCH DAMAGE. */ var Montage = require("montage").Montage; -describe("string-spec", function() { +describe("string-spec", function () { - describe("when capitalizing", function() { + describe("when capitalizing", function () { - it('should capitalize the the first word', function() { + it('should capitalize the the first word', function () { expect("foo".toCapitalized()).toBe("Foo"); }); - it ("should not alter a word that is already properly capitalized", function() { + it ("should not alter a word that is already properly capitalized", function () { expect("Foo".toCapitalized()).toBe("Foo"); }); - it ('must not capitalize any "words" beyond the first', function() { + it ('must not capitalize any "words" beyond the first', function () { expect("foo bar baz".toCapitalized()).toBe("Foo bar baz"); }); - it ("must not alter the capitalization of characters beyond the first character of the first word", function() { + it ("must not alter the capitalization of characters beyond the first character of the first word", function () { expect("fooBarBaz".toCapitalized()).toBe("FooBarBaz"); }); }); - describe("when comparing equality with the equals method", function() { - it("should be equal to the same string", function() { + describe("when comparing equality with the equals method", function () { + it("should be equal to the same string", function () { expect("foo".equals("foo")).toBeTruthy(); }); }); diff --git a/test/support/spec-helper.js b/test/support/spec-helper.js index 94b13ab121..982dfc8ec7 100755 --- a/test/support/spec-helper.js +++ b/test/support/spec-helper.js @@ -1,7 +1,7 @@ //Setup Config jasmine.getEnv().addReporter(new jasmine.TrivialReporter()); -queryString = function(parameter) { +queryString = function (parameter) { var i, key, value, equalSign; var loc = location.search.substring(1, location.search.length); var params = loc.split('&'); @@ -37,28 +37,28 @@ function createJavaScriptContext() { return context; } -var updateReporter = function() { +var updateReporter = function () { var runner = jasmine.getEnv().currentRunner(); runner.finishCallback(); } -addMontageMetadataToProto = function(objectName, moduleId, proto) { +addMontageMetadataToProto = function (objectName, moduleId, proto) { Object.defineProperty(proto, "_montage_metadata", { value: { moduleId: moduleId, objectName: objectName, isInstance: false }, enumerable: false}); }; -var waitsThen = function(promise, resolved) { - waitsFor(function() { +var waitsThen = function (promise, resolved) { + waitsFor(function () { return promise.isResolved(); }, "promise", 500); - runs(function() { + runs(function () { resolved(promise.valueOf()); }) }; -var expectationToDispatch = function(object, expectation, handleEvent) { +var expectationToDispatch = function (object, expectation, handleEvent) { var handler = { - handleEvent: handleEvent? handleEvent : function(event) {} + handleEvent: handleEvent? handleEvent : function (event) {} }; if (typeof expectation === "string") { @@ -67,7 +67,7 @@ var expectationToDispatch = function(object, expectation, handleEvent) { object.addEventListener(expectation, handler, false); } - return function(negate) { + return function (negate) { if (negate) { expect(handler.handleEvent).not.toHaveBeenCalled(); } else { @@ -119,14 +119,14 @@ jasmine.Block.prototype.execute = function (onComplete) { } }; -beforeEach(function() { +beforeEach(function () { this.addMatchers({ - toHave: function(expected) { + toHave: function (expected) { var actual = this.actual, notText = this.isNot ? " not" : "", isArray = jasmine.isArray_(actual); - this.message = function() { + this.message = function () { if (isArray) { return "Expected " + actual + " to" + notText + " have " + expected; } else { @@ -141,4 +141,4 @@ beforeEach(function() { } } }) -}); \ No newline at end of file +}); diff --git a/test/testobjects.js b/test/testobjects.js index 654df5a79c..50f7019440 100644 --- a/test/testobjects.js +++ b/test/testobjects.js @@ -33,7 +33,7 @@ exports = typeof exports !== "undefined" ? exports : {}; var Montage = require("montage").Montage, Uuid = require("montage/core/uuid").Uuid; -var TestObject = (function() { +var TestObject = (function () { var instances = []; // used to cleanup cached urn's. var level = 0; @@ -56,7 +56,7 @@ var TestObject = (function() { if (typeof value !== "object") { return JSON.stringify(value); } else if (Array.isArray(value)) { - return "[" + value.map(function(el) { + return "[" + value.map(function (el) { return serValue(el); }).join(",") + "]"; } else { @@ -64,21 +64,21 @@ var TestObject = (function() { } } - return function(props, isClass) { + return function (props, isClass) { var object = {}; var isInstance = !isClass; instances.push(object); - object.urn = function() { + object.urn = function () { return 'm-obj://' + this.info.objectName + (isInstance ? '/' + (this.obj.UID||'FAIL') : ''); } - object.furn = function() { + object.furn = function () { return 'm-obj://' + this.info.objectName + (isInstance ? '/' + (this.obj.UID||'FAIL') : '') + '?mId=' + this.info.moduleId; } - object.ser = function() { + object.ser = function () { var ser; var names = Montage.getSerializablePropertyNames(this.obj); var serProps = []; @@ -99,7 +99,7 @@ var TestObject = (function() { if (level === 0) cleanup(); return ser; }; - object.ref = function() { + object.ref = function () { return 'U("' + this.urn() + '")'; }; for (var key in props) if (props.hasOwnProperty(key)) { @@ -150,13 +150,13 @@ TestObjectsDesc.simpleA = TestObject({ moduleId: "testobjects", objectName: "Simple" }, - ser: function() { + ser: function () { return TestObjectsDesc.simple.ser(this.obj) ; } }); -var Klass = exports.Klass = function() { - this.hello = function(name) { +var Klass = exports.Klass = function () { + this.hello = function (name) { return "hello " + name; } this.foo = 226; @@ -167,7 +167,7 @@ TestObjectsDesc.klass = TestObject({ moduleId: "testobjects", objectName: "Klass" }, - ser: function(instance) { + ser: function (instance) { return 'U("m-obj://Klass' + (instance ? '/' + (instance.UID||'FAIL') : '') + '?mId=testobjects", {})'; } }); @@ -191,7 +191,7 @@ TestObjectsDesc.composedA = TestObject({ moduleId: "testobjects", objectName: "Composed" }, - ser: function() { + ser: function () { return 'U("' + this.furn(this.obj) + '", {"tags": ["object","composed","test"],"simpleObj": ' + TestObjectsDesc.simpleA.ser() + '})'; } }); @@ -206,7 +206,7 @@ TestObjectsDesc.selfCycleA = TestObject({ moduleId: "montage", objectName: "Montage" }, - ser: function() { + ser: function () { return 'U("' + this.furn(this.obj) + '", {"self": ' + this.ref(this.obj)+ '})'; } }); @@ -219,7 +219,7 @@ TestObjectsDesc.indirectCycleA = TestObject({ moduleId: "montage", objectName: "Montage" }, - ser: function() { + ser: function () { return 'U("' + this.furn(this.obj) + '", {"B": ' + TestObjectsDesc.indirectCycleB.ser(indirectCycleB)+ '})'; } }); @@ -232,7 +232,7 @@ TestObjectsDesc.indirectCycleB = TestObject({ moduleId: "montage", objectName: "Montage" }, - ser: function() { + ser: function () { return 'U("' + this.furn(this.obj) + '", {"A": ' + TestObjectsDesc.indirectCycleA.ref(indirectCycleA)+ '})'; } }); @@ -243,11 +243,11 @@ Montage.defineProperty(indirectCycleB, "A", {value: indirectCycleA, serializable var Custom = exports.Custom = Montage.specialize( { manchete: {value: 42}, - serializeSelf: {value: function(serializer) { + serializeSelf: {value: function (serializer) { serializer.set("manchete", 226); }}, - deserializeSelf: {value: function(serializer) { + deserializeSelf: {value: function (serializer) { this.manchete = serializer.get("manchete"); }} }); @@ -258,7 +258,7 @@ TestObjectsDesc.custom = TestObject({ moduleId: "testobjects", objectName: "Custom" }, - ser: function(instance) { + ser: function (instance) { return 'U("m-obj://Custom' + (instance ? '/'+instance.UID : '') + '?mId=testobjects", {"manchete": 226})'; } }); @@ -270,7 +270,7 @@ TestObjectsDesc.customA = TestObject({ moduleId: "testobjects", objectName: "Custom" }, - ser: function() { + ser: function () { return TestObjectsDesc.custom.ser(this.obj); } }); diff --git a/test/trigger/trigger-spec.js b/test/trigger/trigger-spec.js index 3bd3837d2f..8b8e05df66 100644 --- a/test/trigger/trigger-spec.js +++ b/test/trigger/trigger-spec.js @@ -3,40 +3,40 @@ var Montage = require("montage").Montage; var Promise = require("montage/core/promise").Promise; var TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; -var options = TestPageLoader.options("trigger-test", {timeoutLength: 10000}, function() {console.log("trigger-test callback");}); -describe("trigger-test", function() { - describe("trigger/trigger-spec", function() { +var options = TestPageLoader.options("trigger-test", {timeoutLength: 10000}, function () {console.log("trigger-test callback");}); +describe("trigger-test", function () { + describe("trigger/trigger-spec", function () { var testWindow, promiseForFrameLoad; - it("should receive a montageReady event", function() { + it("should receive a montageReady event", function () { console.group("trigger-test"); promiseForFrameLoad = TestPageLoader.testPage.loadFrame(options); - return promiseForFrameLoad.then(function(iWindow) { + return promiseForFrameLoad.then(function (iWindow) { var deferForMontageReady = Promise.defer(); testWindow = iWindow; testWindow.postMessage({ type: "isMontageReady" }, "*"); - testWindow.addEventListener("message", function(event) { + testWindow.addEventListener("message", function (event) { if(event.source === testWindow) { deferForMontageReady.resolve(event); } }); return deferForMontageReady.promise - .then(function(event) { + .then(function (event) { expect(event.data.type).toEqual("montageReady"); expect(TestPageLoader.testPage.loaded).toBeFalsy(); }); }); }); - it("load when message is posted", function() { + it("load when message is posted", function () { console.log("load when message is posted"); - return require.async("trigger/to-be-defined-package.json").then(function(packageJSON) { + return require.async("trigger/to-be-defined-package.json").then(function (packageJSON) { var injections = {}; //packageDescriptions @@ -84,58 +84,58 @@ describe("trigger-test", function() { location: options.directory, injections: injections }, "*"); - return TestPageLoader.testPage.loadTest(promiseForFrameLoad, options).then(function(testPage) { + return TestPageLoader.testPage.loadTest(promiseForFrameLoad, options).then(function (testPage) { expect(testPage.loaded).toBeTruthy(); }); }) }); - it("should be able to inject a packaged description", function() { + it("should be able to inject a packaged description", function () { // the inject-description-location.json is supposed to define the main modules as inject.js var injectModule = TestPageLoader.testPage.window.mr.async("to-be-defined/inject"); - return injectModule.then(function(inject) { + return injectModule.then(function (inject) { expect(inject.injected).toBeTruthy(); }); }); - it("should be able to inject a packaged description location", function() { + it("should be able to inject a packaged description location", function () { // the inject-description-location.json is supposed to define the main modules as inject.js var injectModule = TestPageLoader.testPage.window.mr.async("inject-description-location"); - return injectModule.then(function(inject) { + return injectModule.then(function (inject) { expect(inject.injected).toBeTruthy(); }); }); - it("should be able to inject a mapping", function() { + it("should be able to inject a mapping", function () { var injectModule = TestPageLoader.testPage.window.mr.async("__custom/inject"); - return injectModule.then(function(inject) { + return injectModule.then(function (inject) { expect(inject.injected).toBeTruthy(); }); }); - it("should be able to inject a dependency", function() { + it("should be able to inject a dependency", function () { var injectModule = TestPageLoader.testPage.window.mr.async("injected-dependency/inject"); - return injectModule.then(function(inject) { + return injectModule.then(function (inject) { expect(inject.injected).toBeTruthy(); }); }); - it("should be able to still use an existing dependency", function() { + it("should be able to still use an existing dependency", function () { var injectModule = TestPageLoader.testPage.window.mr.async("existing/inject"); - return injectModule.then(function(inject) { + return injectModule.then(function (inject) { expect(inject.injected).toBeTruthy(); }); }); - it("should unload", function() { + it("should unload", function () { TestPageLoader.testPage.unloadTest(); console.groupEnd(); }); diff --git a/test/ui/component-spec.js b/test/ui/component-spec.js index 8161b95121..b698092a84 100644 --- a/test/ui/component-spec.js +++ b/test/ui/component-spec.js @@ -38,10 +38,10 @@ var Montage = require("montage").Montage, var Bindings = require("montage/core/bindings").Bindings; var MockDOM = require("mocks/dom"); -TestPageLoader.queueTest("draw/draw", function(testPage) { +TestPageLoader.queueTest("draw/draw", function (testPage) { var test; - var querySelector = function(s) { + var querySelector = function (s) { return testPage.querySelector(s); }; @@ -49,16 +49,16 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { test = testPage.test; }); - describe("ui/component-spec", function() { - describe("draw test", function() { - it("should use the label as identifier if no identifier is given", function() { + describe("ui/component-spec", function () { + describe("draw test", function () { + it("should use the label as identifier if no identifier is given", function () { expect(testPage.test.componentWithoutIdentifier.identifier).toBe("componentWithoutIdentifier"); expect(testPage.test.componentWithIdentifier.identifier).toBe("anIdentifier"); }); - describe("innerTemplate", function() { - it("should be a template with the contents of the element", function() { + describe("innerTemplate", function () { + it("should be a template with the contents of the element", function () { var innerTemplate = testPage.test.repetition.innerTemplate, childNodes = innerTemplate.document.body.childNodes; @@ -68,14 +68,14 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { }); }); - describe("domContent", function() { - it("should contain the current content of the component markup", function() { + describe("domContent", function () { + it("should contain the current content of the component markup", function () { var content = testPage.test.componentC.domContent; expect(content.length).toBe(3); }); - it("should change the content of the component for markup part1", function() { + it("should change the content of the component for markup part1", function () { var componentC = testPage.test.componentC, content = componentC.domContent, newContent = componentC._element.ownerDocument.createElement("div"); @@ -86,17 +86,17 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(componentC.domContent).toEqual(content); }); - it("should change the content of the component for markup part2", function() { + it("should change the content of the component for markup part2", function () { var componentC = testPage.test.componentC; testPage.waitForComponentDraw(componentC); - runs(function() { + runs(function () { expect(componentC.domContent.length).toBe(1); expect(componentC.domContent[0].outerHTML).toBe('
'); }); }); - it("should change the content of the component for another component part1", function() { + it("should change the content of the component for another component part1", function () { var componentC = testPage.test.componentC, componentC1 = testPage.test.componentC1, content = componentC.domContent, @@ -107,35 +107,35 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(componentC.domContent).toEqual(content); }); - it("should change the content of the component for another component part2", function() { + it("should change the content of the component for another component part2", function () { var componentC = testPage.test.componentC, componentC1 = testPage.test.componentC1; testPage.waitForComponentDraw(componentC); - runs(function() { + runs(function () { expect(componentC.domContent.length).toBe(1); expect(componentC.domContent[0].outerHTML).toBe('
C1
'); expect(componentC.domContent[0].component).toBe(componentC1); }); }); - it("should change the content of the component for another component with root elements that are not components themselves", function() { + it("should change the content of the component for another component with root elements that are not components themselves", function () { var domContent = testPage.test.componentD.domContent, componentDtarget = testPage.test.componentDtarget; componentDtarget.domContent = domContent; testPage.waitForDraw(); - runs(function() { + runs(function () { expect(componentDtarget._element.innerHTML).toBe("\n

\n
D1
\n

\n"); }); }); - it("should preverve the owner component of transplanted components", function() { + it("should preverve the owner component of transplanted components", function () { var componentLayout = testPage.test.componentLayout; expect(componentLayout.leftComponent.ownerComponent).not.toBe(componentLayout); expect(componentLayout.rightComponent.ownerComponent).not.toBe(componentLayout); }); - it("should correct the parent component's drawList of transplanted components", function() { + it("should correct the parent component's drawList of transplanted components", function () { var componentLayout = testPage.test.componentLayout, rightComponent = componentLayout.rightComponent, right = componentLayout.templateObjects.right, @@ -150,29 +150,29 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { }); - describe("calling willDraw prior to drawing", function() { + describe("calling willDraw prior to drawing", function () { - beforeEach(function() { + beforeEach(function () { expect(testPage.test).toBeDefined(); testPage.test.loadComponents(); }); - it("should have access to DOM metrics during willDraw", function() { + it("should have access to DOM metrics during willDraw", function () { var documentElement = testPage.iframe.contentDocument.documentElement; var offsetHeight = 0; - spyOn(testPage.test.componentA, 'willDraw').andCallFake(function() { + spyOn(testPage.test.componentA, 'willDraw').andCallFake(function () { offsetHeight = documentElement.offsetHeight; })(); testPage.test.componentA.needsDraw = true; testPage.waitForDraw(); - runs(function() { + runs(function () { expect(offsetHeight).not.toBe(0); }); }); - it("should draw children in the same cycle that are added during parent's willDraw", function() { + it("should draw children in the same cycle that are added during parent's willDraw", function () { // Draw the components once so that they are loaded, then run the test testPage.test.componentB.needsDraw = true; @@ -180,8 +180,8 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { testPage.waitForDraw(); - runs(function() { - spyOn(testPage.test.componentB, 'willDraw').andCallFake(function() { + runs(function () { + spyOn(testPage.test.componentB, 'willDraw').andCallFake(function () { testPage.test.componentB1.needsDraw = true; }); spyOn(testPage.test.componentB1, 'draw').andCallThrough(); @@ -190,12 +190,12 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { // wait for draw testPage.waitForDraw(); // test results - runs(function() { + runs(function () { expect(testPage.test.componentB1.draw).toHaveBeenCalled(); }); }); }); - it("should draw components in the same cycle that are added during a willDraw", function() { + it("should draw components in the same cycle that are added during a willDraw", function () { // Draw the components once so that they are fully loaded, then run the test testPage.test.componentB.needsDraw = true; @@ -205,14 +205,14 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { testPage.waitForDraw(); - runs(function() { - spyOn(testPage.test.componentB, 'willDraw').andCallFake(function() { + runs(function () { + spyOn(testPage.test.componentB, 'willDraw').andCallFake(function () { testPage.test.componentB1.needsDraw = true; }); - spyOn(testPage.test.componentB1, 'willDraw').andCallFake(function() { + spyOn(testPage.test.componentB1, 'willDraw').andCallFake(function () { testPage.test.componentA.needsDraw = true; }); - spyOn(testPage.test.componentA, 'willDraw').andCallFake(function() { + spyOn(testPage.test.componentA, 'willDraw').andCallFake(function () { testPage.test.componentA1.needsDraw = true; }); spyOn(testPage.test.componentB1, 'draw').andCallThrough(); @@ -223,27 +223,27 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { // wait for draw testPage.waitForDraw(); // test results - runs(function() { + runs(function () { expect(testPage.test.componentB1.draw).toHaveBeenCalled(); expect(testPage.test.componentA.draw).toHaveBeenCalled(); expect(testPage.test.componentA1.draw).toHaveBeenCalled(); }); }); }); - it("should draw children before parents even if the parents are added during willDraw", function() { + it("should draw children before parents even if the parents are added during willDraw", function () { // Draw the components once so that they are fully loaded, then run the test testPage.test.componentDrawsParent.needsDraw = true; testPage.test.componentParent.parentHasDrawn = false; - spyOn(testPage.test.componentDrawsParent, 'willDraw').andCallFake(function() { + spyOn(testPage.test.componentDrawsParent, 'willDraw').andCallFake(function () { testPage.test.componentDrawsParent.parentComponent.needsDraw = true; }); - spyOn(testPage.test.componentParent, 'draw').andCallFake(function() { + spyOn(testPage.test.componentParent, 'draw').andCallFake(function () { testPage.test.componentParent.parentHasDrawn = true; }); - spyOn(testPage.test.componentDrawsParent, 'draw').andCallFake(function() { + spyOn(testPage.test.componentDrawsParent, 'draw').andCallFake(function () { expect(testPage.test.componentParent.parentHasDrawn).toBeFalsy(); }); @@ -251,11 +251,11 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { }); }); - describe("component drawing", function() { - beforeEach(function() { + describe("component drawing", function () { + beforeEach(function () { testPage.test.loadComponents(); }); - it("should draw after needsDraw is called", function() { + it("should draw after needsDraw is called", function () { // setup spies spyOn(testPage.test.componentA, 'draw').andCallThrough(); // trigger test @@ -263,11 +263,11 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { // wait for draw testPage.waitForDraw(); // test results - runs(function() { + runs(function () { expect(testPage.test.componentA.draw).toHaveBeenCalled(); }); }); - it("should draw after needsDraw is called again", function() { + it("should draw after needsDraw is called again", function () { // setup spies spyOn(testPage.test.componentA, 'draw').andCallThrough(); // trigger test @@ -275,11 +275,11 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { // wait for draw testPage.waitForDraw(); // test results - runs(function() { + runs(function () { expect(testPage.test.componentA.draw).toHaveBeenCalled(); }); }); - it("should draw parent and child when parent is called last", function() { + it("should draw parent and child when parent is called last", function () { // setup spies spyOn(testPage.test.componentA, 'draw').andCallThrough(); spyOn(testPage.test.componentA1, 'draw').andCallThrough(); @@ -289,12 +289,12 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { /// wait for draw testPage.waitForDraw(); // test results - runs(function() { + runs(function () { expect(testPage.test.componentA.draw).toHaveBeenCalled(); expect(testPage.test.componentA1.draw).toHaveBeenCalled(); }); }); - it("shouldn't draw child if parent can't", function() { + it("shouldn't draw child if parent can't", function () { // setup spies spyOn(testPage.test.componentA, 'canDraw').andReturn(false); spyOn(testPage.test.componentA1, 'draw').andCallThrough(); @@ -304,17 +304,17 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { /// wait for draw testPage.waitForDraw(); // test results - runs(function() { + runs(function () { expect(testPage.test.componentA1.draw).not.toHaveBeenCalled(); }); }); - it("should draw children in an additional cycle that are added during parent's draw", function() { + it("should draw children in an additional cycle that are added during parent's draw", function () { // TODO: we can't make this working at the moment because // enter/exitDocument is implemented by forcing a draw return; // setup spies - spyOn(testPage.test.componentB, 'draw').andCallFake(function() { + spyOn(testPage.test.componentB, 'draw').andCallFake(function () { testPage.test.componentB1.needsDraw = true; }); spyOn(testPage.test.componentB1, 'draw').andCallThrough(); @@ -323,21 +323,21 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { // wait for draw testPage.waitForDraw(); // test results - runs(function() { + runs(function () { expect(testPage.test.componentB.draw).toHaveBeenCalled(); expect(testPage.test.componentB1.draw).not.toHaveBeenCalled(); testPage.waitForDraw(); - runs(function() { + runs(function () { expect(testPage.test.componentB1.draw).toHaveBeenCalled(); }); }); }); - it("should schedule an additional draw if needsDraw is set during draw", function() { + it("should schedule an additional draw if needsDraw is set during draw", function () { var count = 0; - spyOn(testPage.test.componentB, 'draw').andCallFake(function() { + spyOn(testPage.test.componentB, 'draw').andCallFake(function () { if (count == 0) { testPage.test.componentB.needsDraw = true; } @@ -350,17 +350,17 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { testPage.waitForDraw(); // test results - runs(function() { + runs(function () { expect(testPage.test.componentB.draw).toHaveBeenCalled(); testPage.waitForDraw(); - runs(function() { + runs(function () { // Really just needs the waitForDraw to complete since componentB.draw has already been called expect(testPage.test.componentB.draw).toHaveBeenCalled(); }); }); }); - it("should draw a component that was assigned an element not part of the DOM tree when it's added to the DOM tree", function() { + it("should draw a component that was assigned an element not part of the DOM tree when it's added to the DOM tree", function () { var component = testPage.test.componentNoelement, element = component.element; @@ -369,26 +369,26 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { component.needsDraw = true; testPage.waitForDraw(); - runs(function() { + runs(function () { expect(element.textContent).toBe(component.value); }); }); - it("should correctly append styles attributes", function() { + it("should correctly append styles attributes", function () { var style = testPage.test.componentStyle.element.getAttribute("style"); expect(style).toBe("border: 1px solid black; margin: 2px"); }); - it("should correctly merge attributes without leading or trailing whitespaces", function() { + it("should correctly merge attributes without leading or trailing whitespaces", function () { var element = testPage.test.componentStyle.element; expect(element.getAttribute("data-element-attr")).toBe("element"); expect(element.getAttribute("data-template-attr")).toBe("template"); }); - describe("_blocksOwnerComponentDraw", function() { - it("should stop the owner from drawing when the component can't", function() { + describe("_blocksOwnerComponentDraw", function () { + it("should stop the owner from drawing when the component can't", function () { // setup spies spyOn(testPage.test.componentH, 'draw').andCallThrough(); // trigger test @@ -397,13 +397,13 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { /// wait for draw testPage.waitForDraw(); // test results - runs(function() { + runs(function () { expect(testPage.test.componentH.draw).not.toHaveBeenCalled(); testPage.test.componentH1.canDrawGate.setField("field", true); }); }); - it("should continue drawing when the component can", function() { + it("should continue drawing when the component can", function () { // setup spies spyOn(testPage.test.componentH, 'draw').andCallThrough(); // trigger test @@ -412,16 +412,16 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { /// wait for draw testPage.waitForDraw(); // test results - runs(function() { + runs(function () { testPage.test.componentH1.canDrawGate.setField("field", true); testPage.waitForDraw(); - runs(function() { + runs(function () { expect(testPage.test.componentH.draw).toHaveBeenCalled(); }); }); }); - it("should continue drawing even if the owner component doesn't need to draw", function() { + it("should continue drawing even if the owner component doesn't need to draw", function () { // setup spies spyOn(testPage.test.componentH1, 'draw').andCallThrough(); // trigger test @@ -431,11 +431,11 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { /// wait for draw testPage.waitForDraw(); // test results - runs(function() { + runs(function () { expect(testPage.test.componentH1.draw).not.toHaveBeenCalled(); testPage.test.componentH1.canDrawGate.setField("field", true); testPage.waitForDraw(); - runs(function() { + runs(function () { expect(testPage.test.componentH1.draw).toHaveBeenCalled(); }) }); @@ -443,11 +443,11 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { }); }); - describe("didDraw calling after draw", function() { - beforeEach(function() { + describe("didDraw calling after draw", function () { + beforeEach(function () { testPage.test.loadComponents(); }); - it("should call didDraw after draw", function() { + it("should call didDraw after draw", function () { // setup spies spyOn(testPage.test.componentA, 'draw').andCallThrough(); spyOn(testPage.test.componentA, 'didDraw').andCallThrough(); @@ -456,12 +456,12 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { // wait for draw testPage.waitForDraw(); // test results - runs(function() { + runs(function () { expect(testPage.test.componentA.draw).toHaveBeenCalled(); expect(testPage.test.componentA.didDraw).toHaveBeenCalled(); }); }); - it("should call didDraw after draw only if draw was called", function() { + it("should call didDraw after draw only if draw was called", function () { // setup spies spyOn(testPage.test.componentB, 'draw').andCallThrough(); spyOn(testPage.test.componentB, 'didDraw').andCallThrough(); @@ -477,17 +477,17 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { // wait for draw testPage.waitForDraw(); // test results - runs(function() { + runs(function () { expect(testPage.test.componentB.didDraw).toHaveBeenCalled(); expect(testPage.test.componentB1.didDraw).not.toHaveBeenCalled(); expect(testPage.test.componentB2.didDraw).toHaveBeenCalled(); }); }); - it("should receive a first draw event after its first draw", function() { + it("should receive a first draw event after its first draw", function () { testPage.test.componentB1.addEventListener("firstDraw", testPage.test.componentB1, false); testPage.test.componentB.addEventListener("firstDraw", testPage.test.componentB, false); - spyOn(testPage.test.componentB, 'willDraw').andCallFake(function() { + spyOn(testPage.test.componentB, 'willDraw').andCallFake(function () { testPage.test.componentB1.needsDraw = true; }); @@ -501,7 +501,7 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { testPage.waitForDraw(); // test results - runs(function() { + runs(function () { expect(testPage.test.componentB.handleFirstDraw).toHaveBeenCalled(); // TODO: we can't make this working at the moment because // enter/exitDocument is implemented by forcing a draw @@ -509,13 +509,13 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(testPage.test.componentB1.handleFirstDraw).not.toHaveBeenCalled(); testPage.waitForDraw(); - runs(function() { + runs(function () { expect(testPage.test.componentB1.draw).toHaveBeenCalled(); expect(testPage.test.componentB1.handleFirstDraw).toHaveBeenCalled(); }); }); }); - it("should not receive a first draw event on subsequent draws", function() { + it("should not receive a first draw event on subsequent draws", function () { testPage.test.componentB.addEventListener("firstDraw", testPage.test.componentB, false); // trigger test testPage.test.componentB.needsDraw = true; @@ -523,38 +523,38 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { testPage.waitForDraw(); // test results - runs(function() { + runs(function () { spyOn(testPage.test.componentB, 'draw').andCallThrough(); spyOn(testPage.test.componentB, 'handleFirstDraw').andCallThrough(); testPage.test.componentB.needsDraw = true; testPage.waitForDraw(); - runs(function() { + runs(function () { expect(testPage.test.componentB.draw).toHaveBeenCalled(); expect(testPage.test.componentB.handleFirstDraw).not.toHaveBeenCalled(); }); }); }); - it("should have access to DOM metrics during didDraw", function() { + it("should have access to DOM metrics during didDraw", function () { var documentElement = testPage.iframe.contentDocument.documentElement; var offsetHeight = 0; - spyOn(testPage.test.componentA, 'didDraw').andCallFake(function() { + spyOn(testPage.test.componentA, 'didDraw').andCallFake(function () { offsetHeight = documentElement.offsetHeight; })(); testPage.test.componentA.needsDraw = true; testPage.waitForDraw(); - runs(function() { + runs(function () { expect(offsetHeight).not.toBe(0); }); }); }); - describe("the component tree", function() { - it("should reorganize the component tree when a new component is added", function() { + describe("the component tree", function () { + it("should reorganize the component tree when a new component is added", function () { var Component = testPage.window.mr("montage/ui/component").Component, componentE1 = new Component(), element = testPage.window.document.getElementById("componentE1"); @@ -568,7 +568,7 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(componentE1.childComponents[0]).toBe(testPage.test.componentE11); }); - it("should remove a component from its previous parent component childComponent's when it is reattached in another part of the component tree", function() { + it("should remove a component from its previous parent component childComponent's when it is reattached in another part of the component tree", function () { var componentF = testPage.test.componentF, componentF1 = testPage.test.componentF1, componentG = testPage.test.componentG, @@ -583,8 +583,8 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { }); }); - describe("the owner component property", function() { - it("should be the component that loaded the template", function() { + describe("the owner component property", function () { + it("should be the component that loaded the template", function () { var componentOwner = testPage.test.componentOwner; var leaf1 = componentOwner.leaf1; @@ -600,68 +600,68 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { }); }); - it("should be able to draw a component after being cleaned up", function() { + it("should be able to draw a component after being cleaned up", function () { testPage.test.componentToBeCleaned.cleanupDeletedComponentTree(); testPage.test.componentToBeCleaned.text.value = "New Text"; testPage.waitForDraw(); - runs(function() { + runs(function () { expect(testPage.test.componentToBeCleaned.text._element.textContent).toBe("New Text"); }); }); }); - it("does not allow the element to be changed", function() { + it("does not allow the element to be changed", function () { var oldElement = testPage.test.text1.element; testPage.test.text1.element = testPage.document.createElement("div"); expect(testPage.test.text1.element).toBe(oldElement); }); - it("does not allow an element to be assigned to two components", function() { + it("does not allow an element to be assigned to two components", function () { var element = testPage.test.text1.element; var component = new Component(); - expect(function() { + expect(function () { component.element = element; }).toThrow(); }); - describe("template objects", function() { + describe("template objects", function () { var templateObjectsComponent; beforeEach(function () { templateObjectsComponent = testPage.test.templateObjects; }); - it("should have templateObjects object", function() { + it("should have templateObjects object", function () { expect(templateObjectsComponent.templateObjects).not.toBeNull(); }); - it("should have templateObjects ready at templateDidLoad", function() { + it("should have templateObjects ready at templateDidLoad", function () { expect(templateObjectsComponent.templateObjectsPresent).toBeTruthy(); }); - it("should have a reference to owner", function() { + it("should have a reference to owner", function () { expect(templateObjectsComponent.templateObjects.owner).toBe(templateObjectsComponent); }); - it("should have a reference to an object", function() { + it("should have a reference to an object", function () { expect(templateObjectsComponent.templateObjects.object).toEqual({}); }); - it("should have a reference to a component", function() { + it("should have a reference to a component", function () { var text = templateObjectsComponent.element.querySelector(".text").component; expect(templateObjectsComponent.templateObjects.text).toBe(text); }); }); - it("should maintain the placeholder data-montage-id and not the one from the template", function() { + it("should maintain the placeholder data-montage-id and not the one from the template", function () { var element = testPage.test.componentList.element; expect(element.getAttribute("data-montage-id")).toBe("componentList"); }); - it("should maintain the placeholder id and not the one from the template", function() { + it("should maintain the placeholder id and not the one from the template", function () { var element = testPage.test.componentList.element; expect(element.getAttribute("id")).toBe("componentList"); @@ -701,8 +701,8 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { }); }); - describe("dom arguments", function() { - it("should have dom arguments", function() { + describe("dom arguments", function () { + it("should have dom arguments", function () { var component = testPage.test.arguments1, names = component.getDomArgumentNames(); @@ -711,14 +711,14 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(names).toContain("two"); }); - it("should have no dom arguments", function() { + it("should have no dom arguments", function () { var component = testPage.test.noArguments, names = component.getDomArgumentNames(); expect(names.length).toBe(0); }); - it("should have the correct dom arguments", function() { + it("should have the correct dom arguments", function () { var component = testPage.test.arguments1, one, two; @@ -730,7 +730,7 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(two.className).toBe("two"); }); - it("should have dom arguments removed from the DOM", function() { + it("should have dom arguments removed from the DOM", function () { var component = testPage.test.arguments2, domArguments = component._domArguments; @@ -738,14 +738,14 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(domArguments.two.parentNode).toBe(null); }); - it("should remove the data argument attribute from the element", function() { + it("should remove the data argument attribute from the element", function () { var component = testPage.test.arguments2, domArguments = component._domArguments; expect(domArguments.one.hasAttribute(Component.DOM_ARG_ATTRIBUTE)).toBe(false); }); - it("should extract the DOM arguments from the component", function() { + it("should extract the DOM arguments from the component", function () { var component = testPage.test.arguments2, one; @@ -755,14 +755,14 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(one).toBe(null); }); - it("should have dom arguments of the component only and not of nested components", function() { + it("should have dom arguments of the component only and not of nested components", function () { var component = testPage.test.nestedArguments, names = component.getDomArgumentNames(); expect(names.length).toBe(2); }); - it("should have correct DOM arguments even when they're wrapped by elements", function() { + it("should have correct DOM arguments even when they're wrapped by elements", function () { var component = testPage.test.wrappedArguments, one; @@ -770,7 +770,7 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(one).toBeDefined(); }); - it("should satisfy the star parameter when no arguments are given", function() { + it("should satisfy the star parameter when no arguments are given", function () { var templateArguments = { }, @@ -784,7 +784,7 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(validation).toBeUndefined(); }); - it("should fail when an argument is given and no named parameter is defined", function() { + it("should fail when an argument is given and no named parameter is defined", function () { var templateArguments = { "right": document.createElement("div") }, @@ -798,7 +798,7 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(validation).toBeDefined(); }); - it("should fail when no arguments are given and named parameters are not satisfied", function() { + it("should fail when no arguments are given and named parameters are not satisfied", function () { var templateArguments = { }, templateParameters = { @@ -811,7 +811,7 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(validation).toBeDefined(); }); - it("should fail when any parameter is not satisfied", function() { + it("should fail when any parameter is not satisfied", function () { var templateArguments = { "right": document.createElement("div") }, @@ -826,7 +826,7 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(validation).toBeDefined(); }); - it("should fail when a parameter does not exist", function() { + it("should fail when a parameter does not exist", function () { var templateArguments = { "right": document.createElement("div"), "center": document.createElement("div") @@ -841,7 +841,7 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(validation).toBeDefined(); }); - it("should bind the contents to the template star parameter", function() { + it("should bind the contents to the template star parameter", function () { var component = testPage.test.componentBindingStar1, parameters, center, @@ -858,7 +858,7 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(center.element.children.length).toBe(3); }); - it("should bind the arguments to the template parameters", function() { + it("should bind the arguments to the template parameters", function () { var component = testPage.test.componentBindingParams1, parameters, left, @@ -879,7 +879,7 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(rightText).toBeDefined(); }); - it("should fix the component tree when binding a template star parameter", function() { + it("should fix the component tree when binding a template star parameter", function () { var component = testPage.test.componentBindingStar2, parameters, center, @@ -898,7 +898,7 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(component.childComponents).toHave(center); }); - it("should fix the component tree when binding template parameters", function() { + it("should fix the component tree when binding template parameters", function () { var component = testPage.test.componentBindingParams2, parameters, center, @@ -918,14 +918,14 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(right.childComponents).toHave(rightText.component); }); - it("should clone the argument from the template for a named parameter", function() { + it("should clone the argument from the template for a named parameter", function () { var templateHtml = require("ui/draw/template-arguments.html").content, template = new Template(), component = new Component(); return template.initWithHtml(templateHtml) - .then(function() { + .then(function () { var section, element, originalArgument; @@ -942,14 +942,14 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { }); }); - it("should clone the contents of the component for the star parameter", function() { + it("should clone the contents of the component for the star parameter", function () { var templateHtml = require("ui/draw/template-arguments.html").content, template = new Template(), component = new Component(); return template.initWithHtml(templateHtml) - .then(function() { + .then(function () { var star, element, originalNodes, @@ -970,14 +970,14 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { }); }); - it("should remove the data-arg attributes when cloning an argument for a named parameter", function() { + it("should remove the data-arg attributes when cloning an argument for a named parameter", function () { var templateHtml = require("ui/draw/template-arguments.html").content, template = new Template(), component = new Component(); return template.initWithHtml(templateHtml) - .then(function() { + .then(function () { var section, element, dataArgs; @@ -996,13 +996,13 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { }); }); - it("should clone the right argument and ignore arguments for nested components", function() { + it("should clone the right argument and ignore arguments for nested components", function () { var templateHtml = require("ui/draw/template-arguments.html").content, template = new Template(), component = new Component(); return template.initWithHtml(templateHtml) - .then(function() { + .then(function () { var two, element; @@ -1017,13 +1017,13 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { }); }); - it("should clone an argument even if it's inside a data-montage-id element", function() { + it("should clone an argument even if it's inside a data-montage-id element", function () { var templateHtml = require("ui/draw/template-arguments.html").content, template = new Template(), component = new Component(); return template.initWithHtml(templateHtml) - .then(function() { + .then(function () { var one, element; @@ -1038,13 +1038,13 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { }); }); - it("should clone an argument even if it's wrapped by an element", function() { + it("should clone an argument even if it's wrapped by an element", function () { var templateHtml = require("ui/draw/template-arguments.html").content, template = new Template(), component = new Component(); return template.initWithHtml(templateHtml) - .then(function() { + .then(function () { var one, element; @@ -1059,13 +1059,13 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { }); }); - it("should not clone an argument of a nested component when the component argument is wrapped by an element", function() { + it("should not clone an argument of a nested component when the component argument is wrapped by an element", function () { var templateHtml = require("ui/draw/template-arguments.html").content, template = new Template(), component = new Component(); return template.initWithHtml(templateHtml) - .then(function() { + .then(function () { var two, element; @@ -1081,129 +1081,129 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { }); }); - describe("using classList", function() { - describe("with bindings", function() { - it("should correctly initialize from a template", function() { + describe("using classList", function () { + describe("with bindings", function () { + it("should correctly initialize from a template", function () { expect(test.componentClassList.element.classList.contains("class1")).toBeTruthy(); expect(test.componentClassList.element.classList.contains("class2")).toBeFalsy(); }); - it("should reflect changes to the classList's properties", function() { + it("should reflect changes to the classList's properties", function () { test.class1 = false; test.class2 = true; - return testPage.nextDraw().then(function() { + return testPage.nextDraw().then(function () { expect(test.componentClassList.element.classList.contains("class1")).toBeFalsy(); expect(test.componentClassList.element.classList.contains("class2")).toBeTruthy(); }) }); - it("should be possible to bind to a new class", function() { + it("should be possible to bind to a new class", function () { test.class3 = true; Bindings.defineBinding(test.componentClassList, "classList.has('newClass')", { source: test, "<-": "class3" }); expect(test.componentClassList.classList.contains("newClass")).toBeTruthy(); - return testPage.nextDraw().then(function() { + return testPage.nextDraw().then(function () { expect(test.componentClassList.element.classList.contains("newClass")).toBeTruthy(); }) }); }); - describe("with programmatic API", function() { - it("should correctly add a class", function() { + describe("with programmatic API", function () { + it("should correctly add a class", function () { test.componentClassList.classList.add("myclass"); - return testPage.nextDraw().then(function() { + return testPage.nextDraw().then(function () { expect(test.componentClassList.element.classList.contains("myclass")).toBeTruthy(); }) }); - it("should correctly remove a class", function() { + it("should correctly remove a class", function () { test.componentClassList.classList.remove("myclass"); - return testPage.nextDraw().then(function() { + return testPage.nextDraw().then(function () { expect(test.componentClassList.element.classList.contains("myclass")).toBeFalsy(); }) }); - it("should correctly add more than one class", function() { + it("should correctly add more than one class", function () { test.componentClassList.classList.add("myclass"); test.componentClassList.classList.add("myclass2"); - return testPage.nextDraw().then(function() { + return testPage.nextDraw().then(function () { expect(test.componentClassList.element.classList.contains("myclass")).toBeTruthy(); expect(test.componentClassList.element.classList.contains("myclass2")).toBeTruthy(); }) }); - it("should correctly remove more than one class", function() { + it("should correctly remove more than one class", function () { test.componentClassList.classList.remove("myclass"); test.componentClassList.classList.remove("myclass2"); - return testPage.nextDraw().then(function() { + return testPage.nextDraw().then(function () { expect(test.componentClassList.element.classList.contains("myclass")).toBeFalsy(); expect(test.componentClassList.element.classList.contains("myclass2")).toBeFalsy(); }) }); - it("should correctly toggle a class", function() { + it("should correctly toggle a class", function () { test.componentClassList.classList.toggle("myclass"); - return testPage.nextDraw().then(function() { + return testPage.nextDraw().then(function () { expect(test.componentClassList.element.classList.contains("myclass")).toBeTruthy(); }) }); - it("should correctly report contains state of a class", function() { + it("should correctly report contains state of a class", function () { expect(test.componentClassList.classList.contains("myclass")).toBeTruthy(); }); }); - describe("with classes in original element", function() { - it("should correctly add a class based on markup", function() { + describe("with classes in original element", function () { + it("should correctly add a class based on markup", function () { expect(test.componentClassInMarkup.classList.contains("markupClass1")).toBeTruthy(); expect(test.componentClassInMarkup.classList.contains("markupClass2")).toBeTruthy(); expect(test.componentClassInMarkup.element.classList.contains("markupClass1")).toBeTruthy(); expect(test.componentClassInMarkup.element.classList.contains("markupClass2")).toBeTruthy(); }); - it("should be able to change those classes as if they were added via the component", function() { + it("should be able to change those classes as if they were added via the component", function () { test.componentClassInMarkup.classList.toggle("markupClass1"); - return testPage.nextDraw().then(function() { + return testPage.nextDraw().then(function () { expect(test.componentClassInMarkup.element.classList.contains("markupClass1")).toBeFalsy(); }) }); }); - describe("with classes in original element and in template", function() { + describe("with classes in original element and in template", function () { describe("element", function () { - it("should correctly preserve the class based on markup", function() { + it("should correctly preserve the class based on markup", function () { expect(test.componentClassInTemplate.element.classList.contains("markupClass3")).toBeTruthy(); }); - it("should correctly add a class from the template's markup", function() { + it("should correctly add a class from the template's markup", function () { expect(test.componentClassInTemplate.element.classList.contains("ClassListTemplate")).toBeTruthy(); }); }); - it("should correctly add a class to the component based on markup", function() { + it("should correctly add a class to the component based on markup", function () { expect(test.componentClassInTemplate.classList.contains("markupClass3")).toBeTruthy(); }); - it("should correctly add a class from the template's markup to the component", function() { + it("should correctly add a class from the template's markup to the component", function () { expect(test.componentClassInTemplate.classList.contains("ClassListTemplate")).toBeTruthy(); }); - it("should be able to change those classes as if they were added via the component", function() { + it("should be able to change those classes as if they were added via the component", function () { test.componentClassInTemplate.classList.toggle("ClassListTemplate"); - return testPage.nextDraw().then(function() { + return testPage.nextDraw().then(function () { expect(test.componentClassInTemplate.element.classList.contains("ClassListTemplate")).toBeFalsy(); }) }); }); - describe("with classes in element, template, and bindings", function() { + describe("with classes in element, template, and bindings", function () { describe("element", function () { - it("should correctly preserve the class based on markup", function() { + it("should correctly preserve the class based on markup", function () { expect(test.componentClassInTemplateAndBindings.element.classList.contains("markupClass3")).toBeTruthy(); }); - it("should correctly add a class from the template's markup", function() { + it("should correctly add a class from the template's markup", function () { expect(test.componentClassInTemplateAndBindings.element.classList.contains("ClassListTemplate")).toBeTruthy(); }); - it("should correctly have the classes from the bindings", function() { + it("should correctly have the classes from the bindings", function () { expect(test.componentClassInTemplateAndBindings.element.classList.contains("class1")).toBeTruthy(); expect(test.componentClassInTemplateAndBindings.element.classList.contains("class2")).toBeFalsy(); }); }); - it("should correctly add a class to the component based on markup", function() { + it("should correctly add a class to the component based on markup", function () { expect(test.componentClassInTemplateAndBindings.classList.contains("markupClass3")).toBeTruthy(); }); - it("should correctly add a class from the template's markup to the component", function() { + it("should correctly add a class from the template's markup to the component", function () { expect(test.componentClassInTemplateAndBindings.classList.contains("ClassListTemplate")).toBeTruthy(); }); - it("should be able to change those classes as if they were added via the component", function() { + it("should be able to change those classes as if they were added via the component", function () { test.componentClassInTemplateAndBindings.classList.toggle("ClassListTemplate"); - return testPage.nextDraw().then(function() { + return testPage.nextDraw().then(function () { expect(test.componentClassInTemplateAndBindings.element.classList.contains("ClassListTemplate")).toBeFalsy(); }) }); @@ -1219,11 +1219,11 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(aComponent.classList.contains("foo")).toBeTruthy(); }); it("should not fail when classList is used in constructor", function () { - expect(function() { + expect(function () { aComponent = Component.specialize( { hasTemplate: { value: false }, constructor: { - value: function() { + value: function () { this.classList.contains("foo"); } } @@ -1235,12 +1235,12 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { }); - describe("enter document", function() { + describe("enter document", function () { var componentA, componentB, componentC; - beforeEach(function() { + beforeEach(function () { componentA = new Component(); componentB = new Component(); componentC = new Component(); @@ -1272,7 +1272,7 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { componentC._firstDraw = false; }); - it("should request enter document on all components of the sub component tree", function() { + it("should request enter document on all components of the sub component tree", function () { componentA.addChildComponent(componentB); expect(componentB._needsEnterDocument).toBe(true); @@ -1280,12 +1280,12 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { }); }); - describe("exit document", function() { + describe("exit document", function () { var componentA, componentB, componentC; - beforeEach(function() { + beforeEach(function () { componentA = new Component(); componentB = new Component(); componentC = new Component(); @@ -1310,9 +1310,9 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { componentC._inDocument = true; }); - it("should exit the document in bottom-up order", function() { + it("should exit the document in bottom-up order", function () { var callOrder = []; - var exitDocument = function() { + var exitDocument = function () { callOrder.push(this); }; @@ -1325,8 +1325,8 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { }); }); - describe("resolveTemplateArgumentTemplateProperty", function() { - it("should not resolve a template property not targeting the component", function() { + describe("resolveTemplateArgumentTemplateProperty", function () { + it("should not resolve a template property not targeting the component", function () { var component = new Component(), templatePropertyLabel; @@ -1341,7 +1341,7 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(templatePropertyLabel).toBeUndefined(); }); - it("should not resolve when the template property is not an alias", function() { + it("should not resolve when the template property is not an alias", function () { var component = new Component(), templatePropertyLabel; @@ -1356,7 +1356,7 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(templatePropertyLabel).toBeUndefined(); }); - it("should resolve an alias recursively until it finds a template property that is not an alias", function() { + it("should resolve an alias recursively until it finds a template property that is not an alias", function () { var component = new Component(), templatePropertyLabel, foo = new Component(), @@ -1387,35 +1387,35 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(templatePropertyLabel).toBe("bar:i"); }); }); - describe("array object pool", function() { + describe("array object pool", function () { var component; - beforeEach(function() { + beforeEach(function () { component = new Component(); component._arrayObjectPool.pool = null; component._arrayObjectPool.ix = 0; }); - it("should return an array", function() { + it("should return an array", function () { var array = component._getArray(); expect(Array.isArray(array)).toBeTruthy(); }); - it("should return an empty array", function() { + it("should return an empty array", function () { var array = component._getArray(); expect(array.length).toBe(0); }); - it("should return different arrays", function() { + it("should return different arrays", function () { var array1 = component._getArray(), array2 = component._getArray(); expect(array1).not.toBe(array2); }); - it("should return disposed array", function() { + it("should return disposed array", function () { var array1 = component._getArray(), array2; @@ -1425,7 +1425,7 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(array1).toBe(array2); }); - it("should continue to return arrays after the pool is depleted", function() { + it("should continue to return arrays after the pool is depleted", function () { var array; for (var i = 0; i <= component._arrayObjectPool.size; i++) { @@ -1436,7 +1436,7 @@ TestPageLoader.queueTest("draw/draw", function(testPage) { expect(Array.isArray(array)).toBeTruthy(); }); - it("should dispose arrays when the pool is full", function() { + it("should dispose arrays when the pool is full", function () { var array = [], ix = component._arrayObjectPool.ix; diff --git a/test/ui/condition-spec.js b/test/ui/condition-spec.js index c2342cb7bc..2c2ad5a493 100644 --- a/test/ui/condition-spec.js +++ b/test/ui/condition-spec.js @@ -31,41 +31,41 @@ POSSIBILITY OF SUCH DAMAGE. var Montage = require("montage").Montage, TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; -TestPageLoader.queueTest("ui/condition", {src: "ui/condition/condition-test-page.html", firstDraw: false}, function(conditionTestPage) { - describe("ui/condition-spec", function() { - describe("condition with false condition and removal strategy hide", function() { - it("upon initial load content should have a class of montage-invisible", function() { +TestPageLoader.queueTest("ui/condition", {src: "ui/condition/condition-test-page.html", firstDraw: false}, function (conditionTestPage) { + describe("ui/condition-spec", function () { + describe("condition with false condition and removal strategy hide", function () { + it("upon initial load content should have a class of montage-invisible", function () { var conditionDiv = conditionTestPage.iframe.contentDocument.getElementsByClassName("fetchHide")[0]; expect(conditionDiv.classList.contains("montage-invisible")).toBeTruthy(); }); - it("should remove montage-invisible class when condition becomes true", function() { + it("should remove montage-invisible class when condition becomes true", function () { conditionTestPage.test.hideValue = true; conditionTestPage.waitForDraw(); - runs(function(){ + runs(function (){ var conditionDiv = conditionTestPage.iframe.contentDocument.getElementsByClassName("fetchHide")[0]; expect(conditionDiv.classList.contains("montage-invisible")).toBeFalsy(); }); }); }); - describe("condition with false condition and removal strategy remove", function() { - it("upon initial load its contents should be empty", function() { + describe("condition with false condition and removal strategy remove", function () { + it("upon initial load its contents should be empty", function () { var conditionDiv = conditionTestPage.iframe.contentDocument.getElementsByClassName("fetchRemove")[0]; expect(conditionDiv.innerHTML).toBe(""); }); - it("should add its contents to the DOM when condition becomes true", function() { + it("should add its contents to the DOM when condition becomes true", function () { conditionTestPage.test.removeValue = true; conditionTestPage.waitForDraw(); - runs(function(){ + runs(function (){ var conditionDiv = conditionTestPage.iframe.contentDocument.getElementsByClassName("fetchRemove")[0]; expect(conditionDiv.innerHTML).toBe("Foo"); }); }); }); - it("should not remove contents if the initial value of the condition is true", function() { + it("should not remove contents if the initial value of the condition is true", function () { var condition = conditionTestPage.test.templateObjects.conditionTrue; expect(condition.element.innerHTML).toBe("Bar"); @@ -73,5 +73,5 @@ TestPageLoader.queueTest("ui/condition", {src: "ui/condition/condition-test-page }); }); -TestPageLoader.queueTest("ui/nested-condition", {src: "ui/condition/nested-condition-test-page.html", firstDraw: false}, function(nestedConditionTestPage) { +TestPageLoader.queueTest("ui/nested-condition", {src: "ui/condition/nested-condition-test-page.html", firstDraw: false}, function (nestedConditionTestPage) { }); diff --git a/test/ui/condition/test.js b/test/ui/condition/test.js index 92f6f2c29e..7e561bade9 100644 --- a/test/ui/condition/test.js +++ b/test/ui/condition/test.js @@ -34,7 +34,7 @@ var Montage = require("montage").Montage, exports.Test = Montage.specialize( { deserializedFromTemplate: { - value: function(_1, _2, part) { + value: function (_1, _2, part) { this.templateObjects = part.objects; } }, diff --git a/test/ui/draw/component-binding-params.reel/component-binding-params.js b/test/ui/draw/component-binding-params.reel/component-binding-params.js index 64885d8246..c4084f5bd5 100644 --- a/test/ui/draw/component-binding-params.reel/component-binding-params.js +++ b/test/ui/draw/component-binding-params.reel/component-binding-params.js @@ -3,12 +3,12 @@ var Montage = require("montage").Montage, exports.ComponentBindingParams = Component.specialize( { _bindTemplateParametersToArguments: { - value: function() { + value: function () { } }, _replaceElementWithTemplate: { - value: function() { + value: function () { } } diff --git a/test/ui/draw/component-binding-star.reel/component-binding-star.js b/test/ui/draw/component-binding-star.reel/component-binding-star.js index ccb4e6e629..9a61def5de 100644 --- a/test/ui/draw/component-binding-star.reel/component-binding-star.js +++ b/test/ui/draw/component-binding-star.reel/component-binding-star.js @@ -3,12 +3,12 @@ var Montage = require("montage").Montage, exports.ComponentBindingStar = Component.specialize( { _bindTemplateParametersToArguments: { - value: function() { + value: function () { } }, _replaceElementWithTemplate: { - value: function() { + value: function () { } } diff --git a/test/ui/draw/component-noelement.reel/component-noelement.js b/test/ui/draw/component-noelement.reel/component-noelement.js index 91defca143..896c1f1a0a 100644 --- a/test/ui/draw/component-noelement.reel/component-noelement.js +++ b/test/ui/draw/component-noelement.reel/component-noelement.js @@ -35,7 +35,7 @@ exports.ComponentNoelement = Component.specialize( { hasTemplate: {value: false}, deserializedFromSerialization: { - value: function() { + value: function () { var element = document.createElement("div"); this.setElementWithParentComponent(element, this.parentOfNoElement); this.needsDraw = true; @@ -43,7 +43,7 @@ exports.ComponentNoelement = Component.specialize( { }, draw: { - value: function() { + value: function () { this.element.textContent = this.value; } } diff --git a/test/ui/draw/draw.js b/test/ui/draw/draw.js index ce1a05988d..cc85405208 100644 --- a/test/ui/draw/draw.js +++ b/test/ui/draw/draw.js @@ -36,7 +36,7 @@ var TestController = require("montage-testing/test-controller").TestController; var FirstDrawListenerComponent = Component.specialize( { handleFirstDraw: { - value: function(event) { + value: function (event) { } } }); @@ -45,7 +45,7 @@ var FirstDrawListenerComponent = Component.specialize( { var Draw = exports.Draw = TestController.specialize( { loadComponents: { enumerable: false, - value: function() { + value: function () { if (this.componentA) { this.componentA.dispose(); } @@ -86,7 +86,7 @@ var Draw = exports.Draw = TestController.specialize( { } }, deserializedFromTemplate: { - value: function() { + value: function () { window.test = this; this.loadComponents(); this.componentA.needsDraw = true; diff --git a/test/ui/draw/list.reel/list.js b/test/ui/draw/list.reel/list.js index b7f24eb479..ec22673dd8 100644 --- a/test/ui/draw/list.reel/list.js +++ b/test/ui/draw/list.reel/list.js @@ -30,26 +30,26 @@ var List = exports.List = Component.specialize(/** @lends module:"matte/ui/list. _content: {value: null}, content: { - set: function(value) { + set: function (value) { this._content = value; this.defineBinding("_repetition.content", { "<-": "_content" }); }, - get: function() { + get: function () { return this._content; } }, _contentController: {value: null}, contentController: { - set: function(value) { + set: function (value) { this._contentController = value; this.defineBinding("_repetition.contentController", { "<-": "_contentController" }); }, - get: function() { + get: function () { return this._contentController; } }, diff --git a/test/ui/draw/scroller.reel/scroller.js b/test/ui/draw/scroller.reel/scroller.js index b71af93c44..4c632eb1f2 100644 --- a/test/ui/draw/scroller.reel/scroller.js +++ b/test/ui/draw/scroller.reel/scroller.js @@ -3,7 +3,7 @@ var Montage = require("montage").Montage, exports.Scroller = Component.specialize( { canDraw: { - value: function() { + value: function () { this.needsDraw = true; return Component.canDraw.apply(this, arguments); } diff --git a/test/ui/draw/template-objects.reel/template-objects.js b/test/ui/draw/template-objects.reel/template-objects.js index 0f9e8d3dc3..6f6bd734c7 100644 --- a/test/ui/draw/template-objects.reel/template-objects.js +++ b/test/ui/draw/template-objects.reel/template-objects.js @@ -7,7 +7,7 @@ exports.TemplateObjects = Component.specialize( { templateObjectsPresent: {value: false}, templateDidLoad: { - value: function() { + value: function () { this.templateObjectsPresent = !!this.templateObjects; } } diff --git a/test/ui/firstdraw-spec.js b/test/ui/firstdraw-spec.js index e0b580456c..24ee353b8a 100644 --- a/test/ui/firstdraw-spec.js +++ b/test/ui/firstdraw-spec.js @@ -31,23 +31,23 @@ POSSIBILITY OF SUCH DAMAGE. var Montage = require("montage").Montage, TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; -TestPageLoader.queueTest("firstdraw-simple", {src: "ui/drawing/simple.html", firstDraw: true}, function(simpleTestPage) { - describe("ui/firstdraw-spec", function() { - describe("component", function() { - it("should draw within first draw", function() { +TestPageLoader.queueTest("firstdraw-simple", {src: "ui/drawing/simple.html", firstDraw: true}, function (simpleTestPage) { + describe("ui/firstdraw-spec", function () { + describe("component", function () { + it("should draw within first draw", function () { var text = simpleTestPage.iframe.contentDocument.getElementsByClassName("dynamictext")[0]; expect(text).not.toBeNull(); expect(text.textContent).toEqual("Test Value"); }); }); - describe("component with template", function() { - it("should draw within first draw", function() { + describe("component with template", function () { + it("should draw within first draw", function () { var text = simpleTestPage.iframe.contentDocument.getElementsByClassName("dynamictext")[1]; expect(text).not.toBeNull(); expect(text.textContent).toEqual("Custom Test Value"); }); }); - it("should insert styles from component template with no templateElement", function() { + it("should insert styles from component template with no templateElement", function () { var onlyStyle = simpleTestPage.iframe.contentDocument.getElementsByClassName("onlyStyle")[0]; expect(getComputedStyle(onlyStyle).paddingTop).toBe("42px"); @@ -55,22 +55,22 @@ TestPageLoader.queueTest("firstdraw-simple", {src: "ui/drawing/simple.html", fir }); }); -TestPageLoader.queueTest("firstdraw-repetition", {src: "ui/drawing/repetition.html", firstDraw: true}, function(repetitionTestPage) { - describe("Drawing Repetition", function() { - describe("repeating component", function() { - it("TODO should draw within first draw", function() { +TestPageLoader.queueTest("firstdraw-repetition", {src: "ui/drawing/repetition.html", firstDraw: true}, function (repetitionTestPage) { + describe("Drawing Repetition", function () { + describe("repeating component", function () { + it("TODO should draw within first draw", function () { repetitionTestPage.waitForComponentDraw(repetitionTestPage.test.repetition1); - runs(function() { + runs(function () { var text0 = repetitionTestPage.iframe.contentDocument.querySelectorAll(".list1 > div")[0]; expect(text0).not.toBeFalsy(); expect(text0.textContent).toEqual("Test Value"); }); }); }); - describe("repeating component with template", function() { - it("should draw within first draw", function() { + describe("repeating component with template", function () { + it("should draw within first draw", function () { var text0 = repetitionTestPage.iframe.contentDocument.querySelectorAll(".list2 .dynamictext")[0]; expect(text0).not.toBeFalsy(); expect(text0.textContent).toEqual("Custom Test Value"); @@ -78,12 +78,12 @@ TestPageLoader.queueTest("firstdraw-repetition", {src: "ui/drawing/repetition.ht }); }); }); -//var cancelDrawTestPage = TestPageLoader.queueTest("firstdraw-cancel-draw", {src: "ui/drawing/cancel-draw.html", firstDraw: false}, function() { -// describe("Canceling a component draw", function() { -// it("should load", function() { +//var cancelDrawTestPage = TestPageLoader.queueTest("firstdraw-cancel-draw", {src: "ui/drawing/cancel-draw.html", firstDraw: false}, function () { +// describe("Canceling a component draw", function () { +// it("should load", function () { // expect(cancelDrawTestPage.loaded).toBeTruthy(); // }); -// it("should not call draw on a template based component where needsDraw has been set to false", function() { +// it("should not call draw on a template based component where needsDraw has been set to false", function () { // // setup spies // spyOn(cancelDrawTestPage.test.sliderC, 'draw').andCallThrough(); // spyOn(cancelDrawTestPage.test.customC, 'draw').andCallThrough(); @@ -95,7 +95,7 @@ TestPageLoader.queueTest("firstdraw-repetition", {src: "ui/drawing/repetition.ht // // cancelDrawTestPage.waitForDraw(2); // -// runs(function() { +// runs(function () { // expect(cancelDrawTestPage.test.sliderC.needsDraw).toBeFalsy(); // expect(cancelDrawTestPage.test.customC.needsDraw).toBeFalsy(); // expect(cancelDrawTestPage.test.sliderC.draw).not.toHaveBeenCalled(); @@ -104,13 +104,13 @@ TestPageLoader.queueTest("firstdraw-repetition", {src: "ui/drawing/repetition.ht // }); // }); //}); -//var templateParametersTestPage = TestPageLoader.queueTest("firstdraw-template-parameters", {src: "ui/drawing/template-parameters.html", firstDraw: true}, function() { -// describe("Template parameters draw", function() { -// it("should load", function() { +//var templateParametersTestPage = TestPageLoader.queueTest("firstdraw-template-parameters", {src: "ui/drawing/template-parameters.html", firstDraw: true}, function () { +// describe("Template parameters draw", function () { +// it("should load", function () { // expect(templateParametersTestPage.loaded).toBeTruthy(); // }); // -// it("should replace the template parameters with the component dom arguments", function() { +// it("should replace the template parameters with the component dom arguments", function () { // var decorator = templateParametersTestPage.test.decorator, // element = decorator.element; // @@ -118,7 +118,7 @@ TestPageLoader.queueTest("firstdraw-repetition", {src: "ui/drawing/repetition.ht // expect(element.children[0].children.length).toBe(2); // }); // -// it("should pass the component arguments to another component arguments using template parameters", function() { +// it("should pass the component arguments to another component arguments using template parameters", function () { // var compositionDecorator = templateParametersTestPage.test.compositionDecorator, // element = compositionDecorator.element, // decoration; @@ -127,7 +127,7 @@ TestPageLoader.queueTest("firstdraw-repetition", {src: "ui/drawing/repetition.ht // expect(decoration.children.length).toBe(2); // }); // -// it("should pass the component arguments to another component arguments along with other elements using template parameters", function() { +// it("should pass the component arguments to another component arguments along with other elements using template parameters", function () { // var compositionDecoratorMore = templateParametersTestPage.test.compositionDecoratorMore, // element = compositionDecoratorMore.element, // decoration; @@ -136,7 +136,7 @@ TestPageLoader.queueTest("firstdraw-repetition", {src: "ui/drawing/repetition.ht // expect(decoration.children.length).toBe(2); // }); // -// it("should replace the template named parameters with the component dom arguments", function() { +// it("should replace the template named parameters with the component dom arguments", function () { // var parameters = templateParametersTestPage.test.parameters, // element = parameters.element, // item1 = element.querySelector(".item1 > span"), diff --git a/test/ui/flow/flow-spec.js b/test/ui/flow/flow-spec.js index 4af4b488fd..df62bbefd9 100644 --- a/test/ui/flow/flow-spec.js +++ b/test/ui/flow/flow-spec.js @@ -1,21 +1,21 @@ var Montage = require("montage").Montage; var TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; -TestPageLoader.queueTest("flow-test", function(testPage) { +TestPageLoader.queueTest("flow-test", function (testPage) { - describe("ui/flow/flow-spec", function() { - it("should load", function() { + describe("ui/flow/flow-spec", function () { + it("should load", function () { expect(testPage.loaded).toBe(true); }); - describe("Flow", function() { + describe("Flow", function () { var flow; beforeEach(function () { flow = testPage.test.flow; }); - it("can be created", function() { + it("can be created", function () { expect(testPage.test.flow).toBeDefined(); }); diff --git a/test/ui/label/label-spec.js b/test/ui/label/label-spec.js index 21b1cd5228..8e2ee2a927 100644 --- a/test/ui/label/label-spec.js +++ b/test/ui/label/label-spec.js @@ -2,29 +2,29 @@ var Montage = require("montage").Montage; var TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; -TestPageLoader.queueTest("label-test", function(testPage) { +TestPageLoader.queueTest("label-test", function (testPage) { var test; - beforeEach(function() { + beforeEach(function () { test = testPage.test; }); - describe("ui/label/label-spec", function() { + describe("ui/label/label-spec", function () { - describe("Label with text", function() { - it("value can be set", function() { + describe("Label with text", function () { + it("value can be set", function () { test.label.value = "foo"; testPage.waitForDraw(); - runs(function() { + runs(function () { expect(test.label.element.textContent).toEqual("foo"); }) }); }); - describe("Label as a button", function() { - it("activates its target component", function() { + describe("Label as a button", function () { + it("activates its target component", function () { // Ok, not super realistic to 'activate' some text, // but there's not much available in Montage core - test.text.activate = function(){}; + test.text.activate = function (){}; var spy = spyOn(test.text, 'activate'); test.label.target = test.text; @@ -32,10 +32,10 @@ TestPageLoader.queueTest("label-test", function(testPage) { expect(spy).toHaveBeenCalled(); }); - it("calls a custom method on its target", function() { + it("calls a custom method on its target", function () { // Ok, not super realistic to 'activate' some text, // but there's not much available in Montage core - test.text.activateMe = function(){}; + test.text.activateMe = function (){}; var spy = spyOn(test.text, 'activateMe'); test.label.target = test.text; diff --git a/test/ui/loader-spec.js b/test/ui/loader-spec.js index c1ca9fe615..a4d35ecfe9 100644 --- a/test/ui/loader-spec.js +++ b/test/ui/loader-spec.js @@ -6,69 +6,69 @@ var Montage = require("montage").Montage, LOADING = 2, LOADED = 3; -TestPageLoader.queueTest("loader/loader-test", function(testPage) { +TestPageLoader.queueTest("loader/loader-test", function (testPage) { var test; - beforeEach(function() { + beforeEach(function () { test = testPage.test; }); - describe("ui/loader/loader-spec", function() { + describe("ui/loader/loader-spec", function () { // These tests need to run in order, also, they're not deterministic // we don't have enough mocks to drive the loader yet. // These tests should be consider sanity tests. - it("should be in the PRELOADING stage or after", function() { + it("should be in the PRELOADING stage or after", function () { var loader = test.templateObjects.owner; if (loader.currentStage === PRELOADING) { - waitsFor(function() { + waitsFor(function () { return loader.currentStage > PRELOADING; }, "PRELOADING is over", 2000); } }); - it("should be in the BOOTSTRAPPING stage or after", function() { + it("should be in the BOOTSTRAPPING stage or after", function () { var loader = test.templateObjects.owner; if (loader.currentStage === BOOTSTRAPPING) { - waitsFor(function() { + waitsFor(function () { return loader.currentStage > BOOTSTRAPPING; }, "BOOTSTRAPPING is over", 2000); } }); - it("should be in the LOADING stage or after", function() { + it("should be in the LOADING stage or after", function () { var loader = test.templateObjects.owner; if (loader.currentStage === LOADING) { - waitsFor(function() { + waitsFor(function () { return loader.currentStage > LOADING; }, "LOADING is over", 2000); } }); - it("should be in the LOADED stage", function() { + it("should be in the LOADED stage", function () { var loader = test.templateObjects.owner; expect(loader.currentStage).toBe(LOADED); }); // After this point the Loader has finished its work. - it("should load the main component", function() { + it("should load the main component", function () { var loader = test.templateObjects.owner, main = loader._mainComponent; expect(main.element.textContent).toBe(main.text); }); - it("should not be part of the component tree", function() { + it("should not be part of the component tree", function () { var loader = test.templateObjects.owner; expect(loader.parentComponent).toBeFalsy(); expect(loader.childComponents.length).toBe(0); }); - it("should replace itself in the component tree with the main component", function() { + it("should replace itself in the component tree with the main component", function () { var loader = test.templateObjects.owner, main = loader._mainComponent; diff --git a/test/ui/loader/main.reel/main.js b/test/ui/loader/main.reel/main.js index c98fa6e2b2..2d558649ad 100644 --- a/test/ui/loader/main.reel/main.js +++ b/test/ui/loader/main.reel/main.js @@ -8,7 +8,7 @@ exports.Main = Component.specialize( /** @lends Main# */ { }, draw: { - value: function() { + value: function () { this.element.textContent = this.text; } } diff --git a/test/ui/modal-overlay-spec.js b/test/ui/modal-overlay-spec.js index 854f4adfb2..ce5161f9d9 100644 --- a/test/ui/modal-overlay-spec.js +++ b/test/ui/modal-overlay-spec.js @@ -5,11 +5,11 @@ var Montage = require("montage").Montage, MockDOM = require("mocks/dom"), defaultEventManager = require("montage/core/event/event-manager").defaultEventManager; -describe("ui/modal-overlay-spec", function() { +describe("ui/modal-overlay-spec", function () { var aModalOverlay, anotherModalOverlay; - beforeEach(function() { + beforeEach(function () { defaultEventManager._activeTarget = null; aModalOverlay = new ModalOverlay(); aModalOverlay.hasTemplate = false; @@ -26,47 +26,47 @@ describe("ui/modal-overlay-spec", function() { ModalOverlay.prototype._queue = []; }); - describe("enterDocument", function() { - it("should move the modal mask to be a child of the body", function() { + describe("enterDocument", function () { + it("should move the modal mask to be a child of the body", function () { expect(aModalOverlay.element.ownerDocument.body.childNodes).toContain(aModalOverlay.modalMaskElement); }); }); - describe("show", function() { - it("should return a fullfilled promise for the first overlay", function() { + describe("show", function () { + it("should return a fullfilled promise for the first overlay", function () { var promise = aModalOverlay.show(); expect(Promise.isFulfilled(promise)).toBe(true); }); - it("should show the first overlay", function() { + it("should show the first overlay", function () { aModalOverlay.show(); expect(aModalOverlay._isShown).toBe(true); }); - it("should return an unfulfilled promise when another overlay is shown", function() { + it("should return an unfulfilled promise when another overlay is shown", function () { anotherModalOverlay.show(); var promise = aModalOverlay.show(); expect(Promise.isFulfilled(promise)).toBe(false); }); - it("should not show the overlay when another overlay is shown", function() { + it("should not show the overlay when another overlay is shown", function () { anotherModalOverlay.show(); aModalOverlay.show(); expect(aModalOverlay._isShown).toBe(false); }); - it("should return a new promise if the overlay is shown", function() { + it("should return a new promise if the overlay is shown", function () { var promise = aModalOverlay.show(), anotherPromise = aModalOverlay.show(); expect(promise).not.toBe(anotherPromise); }); - it("should return the same promise if the overlay hasn't shown yet", function() { + it("should return the same promise if the overlay hasn't shown yet", function () { var promise, anotherPromise; @@ -78,8 +78,8 @@ describe("ui/modal-overlay-spec", function() { }); }); - describe("hide", function() { - it("should the next overlay when the overlay shown is hidden", function() { + describe("hide", function () { + it("should the next overlay when the overlay shown is hidden", function () { aModalOverlay.show(); anotherModalOverlay.show(); @@ -88,7 +88,7 @@ describe("ui/modal-overlay-spec", function() { expect(anotherModalOverlay._isShown).toBe(true); }); - it("should reject the show promise when hidden before shown", function() { + it("should reject the show promise when hidden before shown", function () { anotherModalOverlay.show(); var promise = aModalOverlay.show(); @@ -98,22 +98,22 @@ describe("ui/modal-overlay-spec", function() { }); }); - describe("draw", function() { - beforeEach(function() { + describe("draw", function () { + beforeEach(function () { var aWindow = aModalOverlay.element.ownerDocument.defaultView; aWindow.innerWidth = 700; aWindow.innerHeight = 600; }); - it("should not be requested when there is another overlay shown", function() { + it("should not be requested when there is another overlay shown", function () { anotherModalOverlay.show(); aModalOverlay.show(); expect(aModalOverlay.needsDraw).toBe(false); }); - it("should be requested when the overlay shown is hidden", function() { + it("should be requested when the overlay shown is hidden", function () { anotherModalOverlay.show(); aModalOverlay.show(); @@ -122,7 +122,7 @@ describe("ui/modal-overlay-spec", function() { expect(aModalOverlay.needsDraw).toBe(true); }); - it("should show the modal mask", function() { + it("should show the modal mask", function () { aModalOverlay._isShown = true; aModalOverlay.draw(); @@ -130,7 +130,7 @@ describe("ui/modal-overlay-spec", function() { expect(aModalOverlay.modalMaskElement.classList.contains("montage-ModalOverlay-modalMask--visible")).toBe(true); }); - it("should hide the modal mask", function() { + it("should hide the modal mask", function () { aModalOverlay._isShown = false; aModalOverlay.draw(); diff --git a/test/ui/overlay-spec.js b/test/ui/overlay-spec.js index 83705744ce..557b845922 100644 --- a/test/ui/overlay-spec.js +++ b/test/ui/overlay-spec.js @@ -7,10 +7,10 @@ var Montage = require("montage").Montage, defaultEventManager = require("montage/core/event/event-manager").defaultEventManager; defaultKeyManager = require("montage/core/event/key-manager").defaultKeyManager; -describe("ui/overlay-spec", function() { +describe("ui/overlay-spec", function () { var anOverlay; - beforeEach(function() { + beforeEach(function () { defaultEventManager._activeTarget = null; anOverlay = new Overlay(); anOverlay.hasTemplate = false; @@ -22,14 +22,14 @@ describe("ui/overlay-spec", function() { anOverlay.enterDocument(true); }); - describe("position calculation", function() { - it("should use the overlay position property", function() { + describe("position calculation", function () { + it("should use the overlay position property", function () { anOverlay.position = {left: 100, top: 100}; anOverlay._calculatePosition(); expect(anOverlay._drawPosition).toEqual({left: 100, top: 100}); }); - it("should calculate the overlay position to be in the middle of the screen when no position hints are given", function() { + it("should calculate the overlay position to be in the middle of the screen when no position hints are given", function () { var aWindow = anOverlay.element.ownerDocument.defaultView; aWindow.innerWidth = 700; @@ -41,8 +41,8 @@ describe("ui/overlay-spec", function() { expect(anOverlay._drawPosition).toEqual({left: 300, top: 275}); }); - describe("element position", function() { - it("should find the position of an element with no offset parent", function() { + describe("element position", function () { + it("should find the position of an element with no offset parent", function () { var anElement = MockDOM.element(), position; @@ -54,7 +54,7 @@ describe("ui/overlay-spec", function() { expect(position.left).toBe(200); }); - it("should find the position of an element with an offset parent", function() { + it("should find the position of an element with an offset parent", function () { var anElement = MockDOM.element(), anElementParent = MockDOM.element(), position; @@ -71,8 +71,8 @@ describe("ui/overlay-spec", function() { }); }); - describe("anchor position", function() { - it("should center the element bellow the anchor", function() { + describe("anchor position", function () { + it("should center the element bellow the anchor", function () { var anAnchor = MockDOM.element(); anAnchor.offsetTop = 100; @@ -88,7 +88,7 @@ describe("ui/overlay-spec", function() { expect(anOverlay._drawPosition).toEqual({left: 225, top: 200}); }); - it("should center the element bellow the anchor and bump it to the right because it's left outside the screen", function() { + it("should center the element bellow the anchor and bump it to the right because it's left outside the screen", function () { var anAnchor = MockDOM.element(); anAnchor.offsetTop = 100; @@ -106,13 +106,13 @@ describe("ui/overlay-spec", function() { }); }); - describe("delegate", function() { + describe("delegate", function () { var delegate; beforeEach(function () { delegate = anOverlay.delegate = {}; }); - it("should call willPositionOverlay", function() { + it("should call willPositionOverlay", function () { delegate.willPositionOverlay = jasmine.createSpy(); anOverlay.position = { @@ -125,7 +125,7 @@ describe("ui/overlay-spec", function() { expect(delegate.willPositionOverlay).toHaveBeenCalledWith(anOverlay, anOverlay.position); }); - it("should call didHideOverlay", function() { + it("should call didHideOverlay", function () { delegate.didHideOverlay = jasmine.createSpy(); anOverlay._isShown = false; @@ -135,7 +135,7 @@ describe("ui/overlay-spec", function() { expect(delegate.didHideOverlay).toHaveBeenCalledWith(anOverlay); }); - it("should call didShowOverlay", function() { + it("should call didShowOverlay", function () { delegate.didShowOverlay = jasmine.createSpy(); anOverlay._isShown = true; @@ -146,8 +146,8 @@ describe("ui/overlay-spec", function() { expect(delegate.didShowOverlay).toHaveBeenCalledWith(anOverlay); }); - describe("shouldDismissOverlay", function() { - it("should hide the overlay when a pressStart is fired outside the overlay and it returns true", function() { + describe("shouldDismissOverlay", function () { + it("should hide the overlay when a pressStart is fired outside the overlay and it returns true", function () { delegate.shouldDismissOverlay = jasmine.createSpy().andReturn(true); var event = Event.event(); @@ -164,7 +164,7 @@ describe("ui/overlay-spec", function() { expect(delegate.shouldDismissOverlay).toHaveBeenCalledWith(anOverlay, event.target, "pressStart"); }); - it("should not be called when a pressStart is fired inside the overlay", function() { + it("should not be called when a pressStart is fired inside the overlay", function () { delegate.shouldDismissOverlay = jasmine.createSpy().andReturn(true); var event = Event.event(); @@ -184,7 +184,7 @@ describe("ui/overlay-spec", function() { expect(delegate.shouldDismissOverlay).not.toHaveBeenCalled(); }); - it("should not hide the overlay when a pressStart is fired outside the overlay and it returns false", function() { + it("should not hide the overlay when a pressStart is fired outside the overlay and it returns false", function () { delegate.shouldDismissOverlay = jasmine.createSpy().andReturn(false); var event = Event.event(); @@ -201,7 +201,7 @@ describe("ui/overlay-spec", function() { expect(delegate.shouldDismissOverlay).toHaveBeenCalledWith(anOverlay, event.target, "pressStart"); }); - it("should be called when the escape key is pressed", function() { + it("should be called when the escape key is pressed", function () { delegate.shouldDismissOverlay = jasmine.createSpy().andReturn(true); anOverlay.enterDocument(true); @@ -218,7 +218,7 @@ describe("ui/overlay-spec", function() { expect(delegate.shouldDismissOverlay).toHaveBeenCalledWith(anOverlay, event.targetElement, "keyPress"); }); - it("should not hide the overlay when the delegate returns false", function() { + it("should not hide the overlay when the delegate returns false", function () { delegate.shouldDismissOverlay = jasmine.createSpy().andReturn(false); anOverlay.enterDocument(true); @@ -237,7 +237,7 @@ describe("ui/overlay-spec", function() { expect(delegate.shouldDismissOverlay).toHaveBeenCalledWith(anOverlay, event.targetElement, "keyPress"); }); - it("should return activeTarget to the component that had it before", function() { + it("should return activeTarget to the component that had it before", function () { var previousTarget = new Component(); defaultEventManager.activeTarget = previousTarget; @@ -248,7 +248,7 @@ describe("ui/overlay-spec", function() { expect(defaultEventManager.activeTarget).toBe(previousTarget); }); - it("should not change the activeTarget if it's non-modal", function() { + it("should not change the activeTarget if it's non-modal", function () { var previousTarget = new Component(); defaultEventManager.activeTarget = previousTarget; @@ -260,9 +260,9 @@ describe("ui/overlay-spec", function() { expect(defaultEventManager.activeTarget).toBe(previousTarget); }); - it("should not show if the overlay isn't able to be the activeTarget", function() { + it("should not show if the overlay isn't able to be the activeTarget", function () { var previousTarget = new Component(); - previousTarget.surrendersActiveTarget = function() { + previousTarget.surrendersActiveTarget = function () { return false; }; defaultEventManager.activeTarget = previousTarget; @@ -275,8 +275,8 @@ describe("ui/overlay-spec", function() { }); - describe("_isDisplayed", function() { - it("should be false before it is measurable", function() { + describe("_isDisplayed", function () { + it("should be false before it is measurable", function () { anOverlay._isShown = false; anOverlay._isDisplayed = true; @@ -285,7 +285,7 @@ describe("ui/overlay-spec", function() { expect(anOverlay._isDisplayed).toBe(false); }); - it("should be true after it is measurable", function() { + it("should be true after it is measurable", function () { anOverlay._isShown = true; anOverlay._isDisplayed = false; @@ -295,8 +295,8 @@ describe("ui/overlay-spec", function() { }); }); - describe("dismissOnExternalInteraction", function() { - it("should hide the overlay when a pressStart is fired outside the overlay and dismissOnExternalInteraction is true", function() { + describe("dismissOnExternalInteraction", function () { + it("should hide the overlay when a pressStart is fired outside the overlay and dismissOnExternalInteraction is true", function () { var event = Event.event(); anOverlay.dismissOnExternalInteraction = true; @@ -309,7 +309,7 @@ describe("ui/overlay-spec", function() { expect(anOverlay._isShown).toBe(false); }); - it("should not hide the overlay when a pressStart is fired inside the overlay and dismissOnExternalInteraction is true", function() { + it("should not hide the overlay when a pressStart is fired inside the overlay and dismissOnExternalInteraction is true", function () { var event = Event.event(); anOverlay.dismissOnExternalInteraction = true; @@ -324,7 +324,7 @@ describe("ui/overlay-spec", function() { expect(anOverlay._isShown).toBe(true); }); - it("should not hide the overlay when a pressStart is fired outside the overlay and dismissOnExternalInteraction is false", function() { + it("should not hide the overlay when a pressStart is fired outside the overlay and dismissOnExternalInteraction is false", function () { var event = Event.event(); anOverlay.dismissOnExternalInteraction = false; @@ -339,21 +339,21 @@ describe("ui/overlay-spec", function() { }); }); - describe("enterDocument", function() { - it("should move the element to be a child of the body", function() { + describe("enterDocument", function () { + it("should move the element to be a child of the body", function () { expect(anOverlay.element.ownerDocument.body.childNodes).toContain(anOverlay.element); }); }); - describe("draw", function() { - beforeEach(function() { + describe("draw", function () { + beforeEach(function () { var aWindow = anOverlay.element.ownerDocument.defaultView; aWindow.innerWidth = 700; aWindow.innerHeight = 600; }); - it("should be requested after show() when hidden", function() { + it("should be requested after show() when hidden", function () { anOverlay._isShown = false; anOverlay.show(); @@ -362,7 +362,7 @@ describe("ui/overlay-spec", function() { expect(anOverlay.classList.has("montage-Overlay--visible")).toBe(true); }); - it("should be requested after hide() when shown", function() { + it("should be requested after hide() when shown", function () { anOverlay._isShown = true; anOverlay.hide(); @@ -371,7 +371,7 @@ describe("ui/overlay-spec", function() { expect(anOverlay.classList.has("montage-Overlay--visible")).toBe(false); }); - it("should not calculate position on willDraw when content is not shown", function() { + it("should not calculate position on willDraw when content is not shown", function () { anOverlay._isDisplayed = false; anOverlay._isShown = true; @@ -380,7 +380,7 @@ describe("ui/overlay-spec", function() { expect(anOverlay._drawPosition).toBe(null); }); - it("should turn the element invisible when it's not measurable and request another draw", function() { + it("should turn the element invisible when it's not measurable and request another draw", function () { anOverlay._isDisplayed = false; anOverlay._isShown = true; @@ -391,7 +391,7 @@ describe("ui/overlay-spec", function() { expect(anOverlay.needsDraw).toBe(true); }); - it("should calculate the position on willDraw", function() { + it("should calculate the position on willDraw", function () { spyOn(anOverlay, "_calculatePosition"); anOverlay._isDisplayed = true; anOverlay._isShown = true; @@ -401,7 +401,7 @@ describe("ui/overlay-spec", function() { expect(anOverlay._calculatePosition).toHaveBeenCalled(); }); - it("should position the element when it's measurable", function() { + it("should position the element when it's measurable", function () { anOverlay._isDisplayed = true; anOverlay._isShown = true; anOverlay.element.offsetWidth = 100; @@ -415,7 +415,7 @@ describe("ui/overlay-spec", function() { expect(anOverlay.element.style.left).toBe("300px"); }); - it("should be requested on window resize when shown", function() { + it("should be requested on window resize when shown", function () { anOverlay.needsDraw = false; anOverlay._isShown = true; anOverlay.handleResize(); @@ -423,7 +423,7 @@ describe("ui/overlay-spec", function() { expect(anOverlay.needsDraw).toBe(true); }); - it("should not be requested on window resize when hidden", function() { + it("should not be requested on window resize when hidden", function () { anOverlay.needsDraw = false; anOverlay._isShown = false; anOverlay.handleResize(); @@ -432,8 +432,8 @@ describe("ui/overlay-spec", function() { }); }); - describe("dismissal", function() { - it("should hide the overlay when a pressStart is fired outside the overlay", function() { + describe("dismissal", function () { + it("should hide the overlay when a pressStart is fired outside the overlay", function () { var event = Event.event(); anOverlay._isShown = true; @@ -443,7 +443,7 @@ describe("ui/overlay-spec", function() { expect(anOverlay._isShown).toBe(false); }); - it("should not hide the overlay when a pressStart is fired inside the overlay", function() { + it("should not hide the overlay when a pressStart is fired inside the overlay", function () { var event = Event.event(); anOverlay._isShown = true; @@ -455,7 +455,7 @@ describe("ui/overlay-spec", function() { expect(anOverlay._isShown).toBe(true); }); - it("should hide the overlay when the escape key is pressed", function() { + it("should hide the overlay when the escape key is pressed", function () { anOverlay.enterDocument(true); anOverlay.show(); @@ -469,15 +469,15 @@ describe("ui/overlay-spec", function() { }); }); - describe("keyPress", function() { - it("should be loaded when the overlay is shown", function() { + describe("keyPress", function () { + it("should be loaded when the overlay is shown", function () { anOverlay.enterDocument(true); anOverlay.show(); expect(anOverlay._keyComposer._isLoaded).toBe(true); }); - it("should not be loaded when the overlay is shown", function() { + it("should not be loaded when the overlay is shown", function () { anOverlay.enterDocument(true); anOverlay.show(); anOverlay.hide(); @@ -485,7 +485,7 @@ describe("ui/overlay-spec", function() { expect(anOverlay._keyComposer._isLoaded).toBe(false); }); - it("should be loaded when the overlay is hidden and shown again", function() { + it("should be loaded when the overlay is hidden and shown again", function () { anOverlay.enterDocument(true); anOverlay.show(); anOverlay.hide(); @@ -495,8 +495,8 @@ describe("ui/overlay-spec", function() { }); }); - describe("events", function() { - it("should fire dismiss event when overlay is dismissed", function() { + describe("events", function () { + it("should fire dismiss event when overlay is dismissed", function () { var event = Event.event(), callback = jasmine.createSpy(); @@ -533,9 +533,9 @@ describe("ui/overlay-spec", function() { }); }); - describe("show", function() { + describe("show", function () { - it("should enter the document", function() { + it("should enter the document", function () { var componentA = new Component(); componentA.hasTemplate = false; componentA.element = MockDOM.element(); diff --git a/test/ui/repetition-binding-spec.js b/test/ui/repetition-binding-spec.js index 4c030ba1a3..5e121c3048 100644 --- a/test/ui/repetition-binding-spec.js +++ b/test/ui/repetition-binding-spec.js @@ -35,17 +35,17 @@ var Montage = require("montage").Montage, var stripPP = function stripPrettyPrintting(str) { return str.replace(/\n\s*/g, ""); }; -TestPageLoader.queueTest("repetition/repetition-binding", function(testPage) { - - - describe("ui/repetition-binding-spec", function() { +TestPageLoader.queueTest("repetition/repetition-binding", function (testPage) { + + + describe("ui/repetition-binding-spec", function () { var eventManager, application, - delegate; - var querySelector = function(s) { + delegate; + var querySelector = function (s) { return testPage.querySelector(s); }; - var querySelectorAll = function(s) { + var querySelectorAll = function (s) { return testPage.querySelectorAll(s); }; @@ -55,9 +55,9 @@ TestPageLoader.queueTest("repetition/repetition-binding", function(testPage) { delegate = application.delegate; }); - describe("Repetition inner Text", function() { + describe("Repetition inner Text", function () { - it("should change when repetition content changes", function() { + it("should change when repetition content changes", function () { var repetition20 = delegate.repetition20; var repetition20 = delegate.repetition20; @@ -71,7 +71,7 @@ TestPageLoader.queueTest("repetition/repetition-binding", function(testPage) { delegate.content = ["c", "d"]; testPage.waitForComponentDraw(repetition20,1); - runs(function() { + runs(function () { expect(firstChildElement.childNodes[0].data).toBe("c"); expect(secondChildElement.childNodes[0].data).toBe("d"); }); diff --git a/test/ui/repetition-selection-spec.js b/test/ui/repetition-selection-spec.js index d201f282f4..c5bf814d65 100644 --- a/test/ui/repetition-selection-spec.js +++ b/test/ui/repetition-selection-spec.js @@ -2,19 +2,19 @@ var Montage = require("montage").Montage, TestPageLoader = require("montage-testing/testpageloader").TestPageLoader, Promise = require("montage/core/promise").Promise; -TestPageLoader.queueTest("repetition/selection-test/selection-test", function(testPage) { - describe("ui/repetition-selection-spec", function() { +TestPageLoader.queueTest("repetition/selection-test/selection-test", function (testPage) { + describe("ui/repetition-selection-spec", function () { var application, eventManager, nameController, repetition; - var querySelector = function(s) { + var querySelector = function (s) { return testPage.querySelector(s); }; - var querySelectorAll = function(s) { + var querySelectorAll = function (s) { return testPage.querySelectorAll(s); }; - it("should load", function() { + it("should load", function () { expect(testPage.loaded).toBeTruthy(); application = testPage.window.document.application; eventManager = application.eventManager; diff --git a/test/ui/repetition-spec.js b/test/ui/repetition-spec.js index 1200813c0e..8b680a68da 100644 --- a/test/ui/repetition-spec.js +++ b/test/ui/repetition-spec.js @@ -36,16 +36,16 @@ var stripPP = function stripPrettyPrintting(str) { return str.replace(/\n\s*/g, ""); }; -TestPageLoader.queueTest("repetition/repetition", function(testPage) { - describe("ui/repetition-spec", function() { +TestPageLoader.queueTest("repetition/repetition", function (testPage) { + describe("ui/repetition-spec", function () { var eventManager, application, delegate; - var querySelector = function(s) { + var querySelector = function (s) { return testPage.querySelector(s); }; - var querySelectorAll = function(s) { + var querySelectorAll = function (s) { return testPage.querySelectorAll(s); }; @@ -55,13 +55,13 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { delegate = application.delegate; }); - xit("should expect unloaded new iterations to be present during the draw", function() { + xit("should expect unloaded new iterations to be present during the draw", function () { var list14 = querySelector(".list14").component, willDraw = list14.willDraw, draw = list14.draw, didThrow = false; - spyOn(list14, "willDraw").andCallFake(function() { + spyOn(list14, "willDraw").andCallFake(function () { list14._iterationTemplate._deserializer._compiledDeserializationFunctionString = null; list14._iterationTemplate._deserializer._areModulesLoaded = false; list14._iterationTemplate._deserializer._modules = {}; @@ -71,7 +71,7 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { } }); - spyOn(list14, "draw").andCallFake(function() { + spyOn(list14, "draw").andCallFake(function () { try { draw.apply(this, arguments); } catch (ex) { @@ -83,24 +83,24 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { list14.content = [1]; testPage.waitForComponentDraw(list14); - runs(function() { + runs(function () { expect(didThrow).toBe(false); }); }); - it("should remove the correct child components when removing an iteration", function() { + it("should remove the correct child components when removing an iteration", function () { var list15 = querySelector(".list15").component; runs(function () { list15.content.unshift(1); testPage.waitForComponentDraw(list15); }); - runs(function() { + runs(function () { expect(list15.childComponents[0].text).toBe(1); list15.content.unshift(0); testPage.waitForComponentDraw(list15); }); - runs(function() { + runs(function () { expect(list15.childComponents.length).toBe(2); expect(list15.childComponents[0].text).toBe(1); expect(list15.childComponents[1].text).toBe(0); @@ -114,9 +114,9 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }) }); - describe("main document template", function() { - it("should empty inner markup and populate with the bindings value", function() { - runs(function() { + describe("main document template", function () { + it("should empty inner markup and populate with the bindings value", function () { + runs(function () { expect(querySelectorAll(".list1 > *").length).toBe(0); expect(querySelectorAll(".list2 > *").length).toBe(1); expect(querySelectorAll(".list2 > li > input.textfield1").length).toBe(1); @@ -126,69 +126,69 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - xit("should not serialize bindings in the iteration template", function() { + xit("should not serialize bindings in the iteration template", function () { var serialization = delegate.repetition1._iterationTemplate._ownerSerialization; expect(stripPP(serialization)).toBe('{"owner":{"prototype":"montage/ui/repetition.reel","properties":{"element":{"#":"list1"},"_isComponentExpanded":true,"ownerComponent":{"@":"__root__"}}},"__root__":{}}'); }); - describe("The static repetition", function() { - it("should add one iteration on the static repetition", function() { + describe("The static repetition", function () { + it("should add one iteration on the static repetition", function () { delegate.list1Objects.push(1); testPage.waitForComponentDraw(delegate.repetition1); - runs(function() { + runs(function () { var lis = querySelectorAll(".list1 > li"); expect(lis.length).toBe(1); expect(lis[0].textContent).toBe("Hello Friend!"); }); }); - it("should remove one iteration on the static repetition", function() { + it("should remove one iteration on the static repetition", function () { delegate.list1Objects.pop(); testPage.waitForComponentDraw(delegate.repetition1); - runs(function() { + runs(function () { var lis = querySelectorAll(".list1 > li"); expect(lis.length).toBe(0); }); }); - it("should add five iterations on the static repetition", function() { + it("should add five iterations on the static repetition", function () { delegate.list1Objects.push(1, 2, 3, 4, 5); testPage.waitForComponentDraw(delegate.repetition1); - runs(function() { + runs(function () { var lis = querySelectorAll(".list1 > li"); expect(lis.length).toBe(5); expect(lis[0].textContent).toBe("Hello Friend!"); }); }); - it("should remove five iteration on the static repetition", function() { + it("should remove five iteration on the static repetition", function () { delegate.list1Objects.splice(0, 5); testPage.waitForComponentDraw(delegate.repetition1); - runs(function() { + runs(function () { var lis = querySelectorAll(".list1 > li"); expect(lis.length).toBe(0); }); }); - it("should change the repetition to three iterations on the static repetition", function() { + it("should change the repetition to three iterations on the static repetition", function () { delegate.list1Objects = [1, 2, 3]; testPage.waitForComponentDraw(delegate.repetition1); - runs(function() { + runs(function () { var lis = querySelectorAll(".list1 > li"); expect(lis.length).toBe(3); }); }); - it("should change the repetition after a batch of operations", function() { + it("should change the repetition after a batch of operations", function () { delegate.list1Objects = []; testPage.waitForComponentDraw(delegate.repetition1); - runs(function() { + runs(function () { // sanity test var lis = querySelectorAll(".list1 > li"); expect(lis.length).toBe(0); @@ -201,18 +201,18 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { delegate.list1Objects.push(4); testPage.waitForComponentDraw(delegate.repetition1); - runs(function() { + runs(function () { lis = querySelectorAll(".list1 > li"); expect(lis.length).toBe(4); }); }); }); - it("should change the repetition on shift and consecutive pop", function() { + it("should change the repetition on shift and consecutive pop", function () { delegate.list1Objects = [1, 2, 3]; testPage.waitForComponentDraw(delegate.repetition1); - runs(function() { + runs(function () { // sanity test var lis = querySelectorAll(".list1 > li"); expect(lis.length).toBe(3); @@ -221,18 +221,18 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { delegate.list1Objects.pop(); testPage.waitForComponentDraw(delegate.repetition1); - runs(function() { + runs(function () { lis = querySelectorAll(".list1 > li"); expect(lis.length).toBe(3); }); }); }); - it("should replace an item of the repetition", function() { + it("should replace an item of the repetition", function () { delegate.list1Objects = [1]; testPage.waitForComponentDraw(delegate.repetition1); - runs(function() { + runs(function () { // sanity test var lis = querySelectorAll(".list1 > li"); expect(lis.length).toBe(1); @@ -241,14 +241,14 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { delegate.list1Objects.push(2); testPage.waitForComponentDraw(delegate.repetition1); - runs(function() { + runs(function () { lis = querySelectorAll(".list1 > li"); expect(lis.length).toBe(1); }); }); }); - xit("[TODO] should create a repetition programmatically", function() { + xit("[TODO] should create a repetition programmatically", function () { var Repetition = testPage.window.mr("montage/ui/repetition.reel").Repetition, repetition = new Repetition(); @@ -258,7 +258,7 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { testPage.waitForComponentDraw(repetition); - runs(function() { + runs(function () { // sanity test var lis = repetition.element.querySelectorAll("li"); expect(lis.length).toBe(3); @@ -266,12 +266,12 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - describe("The component repetition", function() { - it("should add one iteration on the component repetition", function() { + describe("The component repetition", function () { + it("should add one iteration on the component repetition", function () { delegate.list2Objects.push({text: "is"}); testPage.waitForComponentDraw(delegate.repetition2); - runs(function() { + runs(function () { expect(querySelectorAll(".list2 > li").length).toBe(2); var input = querySelectorAll(".list2 > li > input.textfield1"); expect(input.length).toBe(2); @@ -279,11 +279,11 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - it("should remove one iteration on the component repetition", function() { + it("should remove one iteration on the component repetition", function () { delegate.list2Objects.pop(); testPage.waitForComponentDraw(delegate.repetition2); - runs(function() { + runs(function () { expect(querySelectorAll(".list2 > li").length).toBe(1); var input = querySelectorAll(".list2 > li > input.textfield1"); expect(input.length).toBe(1); @@ -291,17 +291,17 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - it("should replace one iteration on the component repetition", function() { + it("should replace one iteration on the component repetition", function () { delegate.list2Objects = [{text: "This"}, {text: "is"}, {text: "Sparta"}]; testPage.waitForComponentDraw(delegate.repetition2); - runs(function() { + runs(function () { // sonity check expect(querySelectorAll(".list2 > li").length).toBe(3); delegate.list2Objects.set(2, {text: "Motorola"}); testPage.waitForDraw(); - runs(function() { + runs(function () { expect(querySelectorAll(".list2 > li").length).toBe(3); var input = querySelectorAll(".list2 > li > input.textfield1"); expect(input.length).toBe(3); @@ -310,11 +310,11 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - it("should change the component repetition after a batch of operations", function() { + it("should change the component repetition after a batch of operations", function () { delegate.list2Objects = []; testPage.waitForComponentDraw(delegate.repetition2); - runs(function() { + runs(function () { // sanity test var lis = querySelectorAll(".list2 > li"); expect(lis.length).toBe(0); @@ -327,7 +327,7 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { delegate.list2Objects.push({text: "item 4"}); testPage.waitForComponentDraw(delegate.repetition2); - runs(function() { + runs(function () { var inputs = querySelectorAll(".list2 > li > input.textfield1"); for (var i = 0, input; i < 4; i++) { @@ -337,11 +337,11 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - it("should replace an item of the repetition", function() { + it("should replace an item of the repetition", function () { delegate.list2Objects = [{text: "item 1"}]; testPage.waitForComponentDraw(delegate.repetition2); - runs(function() { + runs(function () { // sanity test var lis = querySelectorAll(".list2 > li"); expect(lis.length).toBe(1); @@ -350,7 +350,7 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { delegate.list2Objects.push({text: "item 2"}); testPage.waitForComponentDraw(delegate.repetition2); - runs(function() { + runs(function () { var lis = querySelectorAll(".list2 > li"); expect(lis.length).toBe(1); @@ -361,17 +361,17 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - describe("The nested repetition w/ component", function() { - it("should draw one>one iteration on the nested repetition w/ component", function() { + describe("The nested repetition w/ component", function () { + it("should draw one>one iteration on the nested repetition w/ component", function () { delegate.list3Objects = [[{text: "iteration 1"}]]; testPage.waitForComponentDraw(delegate.repetition4); - runs(function() { + runs(function () { var innerRepetition; expect(querySelectorAll(".list3 > li").length).toBe(1); - var expectationFunction = function() { + var expectationFunction = function () { expect(innerRepetition.element.querySelectorAll("li").length).toBe(1); var inputs = innerRepetition.element.querySelectorAll("li > input.textfield2"); expect(inputs.length).toBe(1); @@ -393,11 +393,11 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - it("should draw one>three iteration on the nested repetition w/ component", function() { + it("should draw one>three iteration on the nested repetition w/ component", function () { delegate.list3Objects = [[{text: "iteration 1"}, {text: "iteration 2"}, {text: "iteration 3"}]]; testPage.waitForComponentDraw(querySelector(".list3 > li > ul.list3a").component); - runs(function() { + runs(function () { expect(querySelectorAll(".list3 > li").length).toBe(1); expect(querySelectorAll(".list3 > li > ul.list3a > li").length).toBe(3); var inputs = querySelectorAll(".list3 > li > ul.list3a > li > input.textfield2"); @@ -406,11 +406,11 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - it("should draw one>five iterations on the nested repetition w/ component", function() { + it("should draw one>five iterations on the nested repetition w/ component", function () { delegate.list3Objects = [[{text: "iteration 1"}, {text: "iteration 2"}, {text: "iteration 3"}], [{text: "iteration 1"}, {text: "iteration 2"}, {text: "iteration 3"}, {text: "iteration 4"}, {text: "iteration 5"}]]; testPage.waitForComponentDraw(delegate.repetition4); - var expectationFunction = function() { + var expectationFunction = function () { expect(querySelectorAll(".list3 > li").length).toBe(2); // BUG: Chrome outputs 0 on this.. @@ -425,7 +425,7 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { } }; - runs(function() { + runs(function () { // Depending on timing the inner repetitions might have not // drawn yet so we need to wait till one of the inner // repetitions draws because atm we're not able to draw two @@ -441,23 +441,23 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - it("should remove one iteration on the nested repetition w/ component", function() { + it("should remove one iteration on the nested repetition w/ component", function () { delegate.list3Objects.shift(); testPage.waitForComponentDraw(delegate.repetition4); - runs(function() { + runs(function () { expect(querySelectorAll(".list3 > li").length).toBe(1); // should have not affected the other iteration expect(querySelectorAll(".list3 > li > ul.list3a > li").length).toBe(5); }); }); - it("should remove one inner iteration on the nested repetition w/ component", function() { + it("should remove one inner iteration on the nested repetition w/ component", function () { var innerArray = delegate.list3Objects[delegate.list3Objects.length-1]; innerArray.pop(); testPage.waitForDraw(); - runs(function() { + runs(function () { expect(querySelectorAll(".list3 > li").length).toBe(1); expect(querySelectorAll(".list3 > li:first-child > ul > li").length).toBe(4); @@ -469,19 +469,19 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - describe("The nested repetition w/ Static Component Composition (SCC)", function() { - it("should draw one>one iteration on the nested repetition w/ SCC", function() { + describe("The nested repetition w/ Static Component Composition (SCC)", function () { + it("should draw one>one iteration on the nested repetition w/ SCC", function () { delegate.list4Objects.push([1]); testPage.waitForComponentDraw(delegate.repetition5); - runs(function() { + runs(function () { // we need to wait till one of the inner repetitions draws // because atm we're not able to draw two nested repetitions // in a single draw. var innerRepetition = delegate.repetition5.element.querySelector(".list4a").component; testPage.waitForComponentDraw(innerRepetition); - runs(function() { + runs(function () { expect(querySelectorAll(".list4 > li").length).toBe(1); expect(querySelectorAll(".list4 > li > ul.list4a > li").length).toBe(1); expect(querySelectorAll(".list4 > li > ul.list4a > li > div.content3").length).toBe(1); @@ -490,17 +490,17 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - it("should draw one>five iterations on the nested repetition w/ SCC", function() { + it("should draw one>five iterations on the nested repetition w/ SCC", function () { delegate.list4Objects.push([1, 2, 3, 4, 5]); testPage.waitForComponentDraw(delegate.repetition5); - runs(function() { + runs(function () { // Depending on timing the inner repetitions might have not // drawn yet so we need to wait till one of the inner // repetitions draws because atm we're not able to draw two // nested repetitions in a single draw. var innerRepetition = delegate.repetition5.element.querySelectorAll(".list4a")[1].component; - var expectationFunction = function() { + var expectationFunction = function () { expect(querySelectorAll(".list4 > li").length).toBe(2); // BUG: Chrome outputs 0 on this.. @@ -523,11 +523,11 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - it("should remove one iteration on the nested repetition w/ SCC", function() { + it("should remove one iteration on the nested repetition w/ SCC", function () { delegate.list4Objects.shift(); testPage.waitForComponentDraw(delegate.repetition5); - runs(function() { + runs(function () { expect(querySelectorAll(".list4 > li").length).toBe(1); // should have not affected the other iteration expect(querySelectorAll(".list4 > li > ul.list4a > li").length).toBe(5); @@ -536,19 +536,19 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); - describe("The nested repetition w/ Dynamic Component Composition (DCC)", function() { - it("should draw one>one iteration on the nested repetition w/ DCC", function() { + describe("The nested repetition w/ Dynamic Component Composition (DCC)", function () { + it("should draw one>one iteration on the nested repetition w/ DCC", function () { delegate.list5Objects.push([1]); testPage.waitForComponentDraw(delegate.repetition7); - runs(function() { + runs(function () { // Depending on timing the inner repetitions might have not // drawn yet so we need to wait till one of the inner // repetitions draws because atm we're not able to draw two // nested repetitions in a single draw. var innerRepetition = delegate.repetition7.element.querySelector(".list5a").component; - var expectationFunction = function() { + var expectationFunction = function () { expect(querySelectorAll(".list5 > li").length).toBe(1); expect(querySelectorAll(".list5 > li > ul.list5a > li").length).toBe(1); expect(querySelectorAll(".list5 > li > ul.list5a > li > div.content4").length).toBe(1); @@ -564,18 +564,18 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - it("should draw one>five iterations on the nested repetition w/ DCC", function() { + it("should draw one>five iterations on the nested repetition w/ DCC", function () { delegate.list5Objects.push([1, 2, 3, 4, 5]); testPage.waitForComponentDraw(delegate.repetition7); - runs(function() { + runs(function () { // Depending on timing the inner repetitions might have not // drawn yet so we need to wait till one of the inner // repetitions draws because atm we're not able to draw two // nested repetitions in a single draw. var innerRepetition = delegate.repetition7.element.querySelectorAll(".list5a")[1].component; - var expectationFunction = function() { + var expectationFunction = function () { expect(querySelectorAll(".list5 > li").length).toBe(2); expect(querySelectorAll(".list5 > li:nth-child(2) > ul.list5a > li").length).toBe(5); @@ -597,11 +597,11 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - it("should remove one iteration on the nested repetition w/ DCC", function() { + it("should remove one iteration on the nested repetition w/ DCC", function () { delegate.list5Objects.shift(); testPage.waitForComponentDraw(delegate.repetition7); - runs(function() { + runs(function () { expect(querySelectorAll(".list5 > li").length).toBe(1); // should have not affected the other iteration expect(querySelectorAll(".list5 > li > ul.list5a > li").length).toBe(5); @@ -609,20 +609,20 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); it("should remove one inner iteration on the nested repetition w/ DCC", - function() { + function () { var innerArray = delegate.list5Objects[delegate.list5Objects.length-1]; innerArray.pop(); testPage.waitForDraw(); - runs(function() { + runs(function () { expect(querySelectorAll(".list5 > li").length).toBe(1); expect(querySelectorAll(".list5 > li > ul.list5a > li").length).toBe(4); }); }); }); - describe("Repetition of a component with a binding", function() { - it("should draw the repetition with the correct duplicated bindings", function() { + describe("Repetition of a component with a binding", function () { + it("should draw the repetition with the correct duplicated bindings", function () { var inputs = querySelectorAll(".list7 .textfield5"); expect(inputs.length).toBe(2); @@ -631,8 +631,8 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - describe("Repetition of a component with an action event listener", function() { - it("should draw the repetition with the correct duplicated action event listeners", function() { + describe("Repetition of a component with an action event listener", function () { + it("should draw the repetition with the correct duplicated action event listeners", function () { var component = querySelectorAll(".textfield6")[0].component; spyOn(application.delegate, "listener"); @@ -644,27 +644,27 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - describe("Repetition of a direct component", function() { - it("should be able to remove the iteration correctly", function() { + describe("Repetition of a direct component", function () { + it("should be able to remove the iteration correctly", function () { delegate.list9Objects = [1]; testPage.waitForComponentDraw(delegate.repetition12); - runs(function() { + runs(function () { expect(querySelectorAll(".list9 input").length).toBe(1); delegate.list9Objects.pop(); testPage.waitForComponentDraw(delegate.repetition12); - runs(function() { + runs(function () { expect(querySelectorAll(".list9 > input").length).toBe(0); }); }); }); }); - describe("Repetitions with different external objects", function() { - it("should not reuse the same template if it has external objects associated", function() { + describe("Repetitions with different external objects", function () { + it("should not reuse the same template if it has external objects associated", function () { var textfield1 = querySelector(".componentz1 input"); var textfield2 = querySelector(".componentz2 input"); @@ -674,24 +674,24 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); - describe("with a content controller", function() { - it("it should have as many iterations as the arraycontroller's initial organizedObjects", function() { + describe("with a content controller", function () { + it("it should have as many iterations as the arraycontroller's initial organizedObjects", function () { expect(querySelectorAll(".repetitionController > li").length).toBe(3); }); - xit("it should increment the number of iterations", function() { + xit("it should increment the number of iterations", function () { delegate.simpleArrayControllerContent.push("four"); testPage.waitForComponentDraw(delegate.repetitionController); - runs(function() { + runs(function () { expect(delegate.simpleArrayController.iterations.length).toBe(4); expect(querySelectorAll(".repetitionController > li").length).toBe(4); }); }); }); - describe("Repetition in a external component", function() { - it("should draw the repetition", function() { + describe("Repetition in a external component", function () { + it("should draw the repetition", function () { var eventManager = testPage.window.document.application.eventManager; var componentit1 = eventManager.eventHandlerForElement(querySelector(".componentrep1")); @@ -702,7 +702,7 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { testPage.waitForComponentDraw(querySelector(".componentrep2 > ul").component); - runs(function() { + runs(function () { var inputs; inputs = querySelectorAll(".componentrep1 input"); @@ -717,7 +717,7 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - it("should draw the repetition of the 'component repetition'", function() { + it("should draw the repetition of the 'component repetition'", function () { delegate.list6Objects = [ { elements1: [ @@ -743,7 +743,7 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { testPage.waitForComponentDraw(delegate.repetition9); // Note: the inner repetition does in fact draw in the same // draw cycle - runs(function() { + runs(function () { var inputs; inputs = querySelectorAll(".list6comp1 input"); expect(inputs.length).toBe(4); @@ -762,21 +762,21 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); // This test needs to be run last since slow to load components do block the draw - it("should draw a repetition with slow components", function() { + it("should draw a repetition with slow components", function () { // it should draw even if the 2nd component loads before the 1st one. delegate.list10Objects.push(1); delegate.list10Objects.push(2); testPage.waitForDraw(); - runs(function() { + runs(function () { // It just needs to draw }); }); }); - describe("Repetition innerTemplate change", function() { - it("should rebuild the repetition", function() { + describe("Repetition innerTemplate change", function () { + it("should rebuild the repetition", function () { var repetition = querySelector(".list11").component; runs(function () { @@ -802,7 +802,7 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - it("should rebuild the repetition with components", function() { + it("should rebuild the repetition with components", function () { var repetition = querySelector(".list11b").component; var templateRepetition = querySelector(".list11btemplate").component; @@ -830,22 +830,22 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); - describe("manual objects changes", function() { + describe("manual objects changes", function () { var list13, object; beforeEach(function () { list13 = querySelector(".list13").component; object = {array: [1, 2, 3]}; }); - it("should add an iteration when an object is pushed", function() { + it("should add an iteration when an object is pushed", function () { list13.content.push(4); testPage.waitForComponentDraw(delegate.repetition15); - runs(function() { + runs(function () { expect(querySelectorAll(".list13 > li").length).toBe(4); }); }); - xit("should call update items once if a binding to objects is in place", function() { + xit("should call update items once if a binding to objects is in place", function () { spyOn(list13, "_updateItems").andCallThrough(); testPage.window.list13.defineBinding("objects", { "<-": "array", @@ -855,7 +855,7 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { expect(list13._updateItems.callCount).toBe(1); }); - xit("should call update items once if a binding to objects is removed", function() { + xit("should call update items once if a binding to objects is removed", function () { spyOn(list13, "_updateItems").andCallThrough(); testPage.window.Object.deleteBinding(list13, "objects"); list13.content.push(4); @@ -863,13 +863,13 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - it("should draw inner repetitions with their original objects value", function() { + it("should draw inner repetitions with their original objects value", function () { var lis = querySelectorAll(".list17 > li"); expect(lis.length).toBe(3*2); }) - describe("iteration template", function() { - it("should expand template star parameter", function() { + describe("iteration template", function () { + it("should expand template star parameter", function () { var component = querySelector(".listParameters ul").component, template = component._iterationTemplate, serialization = template.getSerialization(), @@ -880,7 +880,7 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { .toBeDefined(); }); - it("should expand template star parameter with multiple expansions", function() { + it("should expand template star parameter with multiple expansions", function () { var component = querySelector(".listParametersDecorator ul").component, template = component._iterationTemplate, serialization = template.getSerialization(), @@ -899,7 +899,7 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { expect("decoratorText" in instances).toBeTruthy(); }); - it("should expand template star parameter with multiple expansions and colliding object", function() { + it("should expand template star parameter with multiple expansions and colliding object", function () { var component = querySelector(".listParametersDecoratorColliding ul").component, template = component._iterationTemplate, serialization = template.getSerialization(), @@ -926,7 +926,7 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { expect(instances[textObjectLabel]).toBe("Text Collision"); }); - it("should expand template with named parameters", function() { + it("should expand template with named parameters", function () { var elements = querySelectorAll(".namedParameters ul"), template, serialization, @@ -959,15 +959,15 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { .toBeDefined(); }); - describe("property templates", function() { - it("should expand template with an alias to repetition:iteration", function() { + describe("property templates", function () { + it("should expand template with an alias to repetition:iteration", function () { var elements = querySelectorAll(".aliasRepetitionIteration .text100"); expect(elements[0].component.value).toBe("1"); expect(elements[1].component.value).toBe("2"); }); - it("should expand template with an alias to nested repetition:iteration", function() { + it("should expand template with an alias to nested repetition:iteration", function () { var elements = querySelectorAll(".aliasNestedRepetitionIteration .text110"); expect(elements[0].component.value).toBe("1-a"); @@ -976,14 +976,14 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { expect(elements[3].component.value).toBe("2-b"); }); - it("should expand template with a chained alias to repetition:iteration", function() { + it("should expand template with a chained alias to repetition:iteration", function () { var elements = querySelectorAll(".aliasChainedRepetitionIteration .text120"); expect(elements[0].component.value).toBe("1"); expect(elements[1].component.value).toBe("2"); }); - it("should expand the correct alias to repetition:iteration", function() { + it("should expand the correct alias to repetition:iteration", function () { var elements = querySelectorAll(".aliasMixedRepetitionIteration .header"); expect(elements[0].component.value).toBe("a1"); @@ -1041,8 +1041,8 @@ TestPageLoader.queueTest("repetition/repetition", function(testPage) { }); }); - describe("iteration selection", function() { - it("should select an iteration that does not have components when clicked", function() { + describe("iteration selection", function () { + it("should select an iteration that does not have components when clicked", function () { var repetition = delegate.domRepetition; var li = repetition.element.querySelectorAll("li")[1]; testPage.mouseEvent({target: li}, "mousedown", function () { diff --git a/test/ui/repetition/componentslowload.js b/test/ui/repetition/componentslowload.js index c5bff87f3d..db7b2427ee 100644 --- a/test/ui/repetition/componentslowload.js +++ b/test/ui/repetition/componentslowload.js @@ -39,11 +39,11 @@ var ComponentSlowLoad = exports.ComponentSlowLoad = Component.specialize( { delay: {value: 100}, // This code makes the first instantiated component to load after the second - loadComponentTree: {value: function(callback) { + loadComponentTree: {value: function (callback) { var self = this, defered = Promise.defer(); - setTimeout(function() { + setTimeout(function () { self.canDrawGate.setField("componentTreeLoaded", true); defered.resolve(); }, ComponentSlowLoad.delay); diff --git a/test/ui/repetition/repetition-binding-test.js b/test/ui/repetition/repetition-binding-test.js index a5706d1334..e1d8bae192 100644 --- a/test/ui/repetition/repetition-binding-test.js +++ b/test/ui/repetition/repetition-binding-test.js @@ -28,7 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -var querySelector = function(e){return document.querySelector(e);} +var querySelector = function (e){return document.querySelector(e);} var Montage = require("montage").Montage; var Component = require("montage/ui/component").Component; diff --git a/test/ui/repetition/repetition-test.js b/test/ui/repetition/repetition-test.js index 5f65128e89..dea045e3d3 100644 --- a/test/ui/repetition/repetition-test.js +++ b/test/ui/repetition/repetition-test.js @@ -28,13 +28,13 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -var querySelector = function(e){return document.querySelector(e);} +var querySelector = function (e){return document.querySelector(e);} var Montage = require("montage").Montage; var Component = require("montage/ui/component").Component; var RepetitionTest = exports.RepetitionTest = Montage.specialize( { - listener: {value: function() { + listener: {value: function () { }}, simpleArrayController: {value: null} diff --git a/test/ui/repetition/textfield.reel/textfield.js b/test/ui/repetition/textfield.reel/textfield.js index b6a2bbd224..fd7506c417 100644 --- a/test/ui/repetition/textfield.reel/textfield.js +++ b/test/ui/repetition/textfield.reel/textfield.js @@ -37,11 +37,11 @@ var TextField = exports.TextField = Component.specialize( { hasTemplate: {value: true}, text: { - set: function(value) { + set: function (value) { this._text = value; this.needsDraw = true; }, - get: function() { + get: function () { return this._text; } }, @@ -50,7 +50,7 @@ var TextField = exports.TextField = Component.specialize( { value: "default text" }, - draw: {value: function() { + draw: {value: function () { this.element.value = this.text; }} }); diff --git a/test/ui/slot-spec.js b/test/ui/slot-spec.js index 026ebe9bca..4f5052939f 100644 --- a/test/ui/slot-spec.js +++ b/test/ui/slot-spec.js @@ -31,135 +31,135 @@ POSSIBILITY OF SUCH DAMAGE. var Montage = require("montage").Montage, TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; -TestPageLoader.queueTest("slot-test/slot-test", function(testPage) { - describe("ui/slot-spec", function() { +TestPageLoader.queueTest("slot-test/slot-test", function (testPage) { + describe("ui/slot-spec", function () { var slot; - beforeEach(function() { + beforeEach(function () { slot = testPage.test.slot; slot.content = null; }); - describe("when first loaded", function() { - it("it should have no initial content", function() { + describe("when first loaded", function () { + it("it should have no initial content", function () { expect(slot.content).toEqual(null); expect(slot.element.childNodes.length).toEqual(0); }); }); - describe("when inserting a component", function() { + describe("when inserting a component", function () { // TODO it's a shame that the state of all the components is preserved from spec to spec // that means that once this componentWithNoElement is put into a slot and given an element // it will have an element for all subsequent specs. // This means the order of the specs matter; I find this a little troubling. - it("should give the incoming component an element if it has none", function() { + it("should give the incoming component an element if it has none", function () { var content = testPage.test.componentWithNoElement; slot.content = content; testPage.waitForDraw(); - runs(function() { + runs(function () { expect(content.element).toBeTruthy(); }); }); - it("must not replace the incoming component's element if it is already set", function() { + it("must not replace the incoming component's element if it is already set", function () { var content = testPage.test.componentInPageWithElement, originalElement = content.element; slot.content = content; testPage.waitForDraw(); - runs(function() { + runs(function () { //console.log(content.element, originalElement) expect(content.element).toBe(originalElement); }); }); - it("should draw a component that has an element but the element is not part of the DOM when the slot content is set", function() { + it("should draw a component that has an element but the element is not part of the DOM when the slot content is set", function () { var content = testPage.test.componentInPageWithElement; slot.content = null; testpage.waitForDraw(); - runs(function() { + runs(function () { slot.content = content; content.value = "This is new text"; testPage.waitForDraw(); - runs(function() { + runs(function () { expect(slot.element.childNodes.length).toEqual(1); expect(slot.element.childNodes[0].textContent).toBe("This is new text"); }); }); }); - it("should append the incoming component's element if there was no content", function() { + it("should append the incoming component's element if there was no content", function () { var content = testPage.test.componentWithNoElement; slot.content = content; testPage.waitForDraw(); - runs(function() { + runs(function () { expect(slot.element.firstElementChild).toBe(content.element); }); }); - it("should set the incoming component's parentComponent to be the slot", function() { + it("should set the incoming component's parentComponent to be the slot", function () { testPage.waitForDraw(); - runs(function() { + runs(function () { var content = testPage.test.componentWithNoElement; slot.content = content; testPage.waitForDraw(); - runs(function() { + runs(function () { expect(content.parentComponent).toBe(slot); }); }); }); - it("should set the component as a childComponent of the slot", function() { + it("should set the component as a childComponent of the slot", function () { testPage.waitForDraw(); - runs(function() { + runs(function () { var content = testPage.test.componentWithNoElement; slot.content = content; testPage.waitForDraw(); - runs(function() { + runs(function () { expect(slot.childComponents).toContain(content); }); }); }); - it("accessing the content property should return an element if an element was initially set", function() { + it("accessing the content property should return an element if an element was initially set", function () { testPage.waitForDraw(); - runs(function() { + runs(function () { var content = testPage.test.bazContent; slot.content = content; testPage.waitForDraw(); - runs(function() { + runs(function () { expect(slot.content).toEqual(content); }); }); }); - it("accessing the content property should return a component if a component was initially set", function() { + it("accessing the content property should return a component if a component was initially set", function () { testPage.waitForDraw(); - runs(function() { + runs(function () { var content = testPage.test.componentInPageWithElement; slot.content = content; testPage.waitForDraw(); - runs(function() { + runs(function () { expect(slot.content).toEqual(content); }); }); @@ -167,20 +167,20 @@ TestPageLoader.queueTest("slot-test/slot-test", function(testPage) { }); - describe("when removing a component", function() { + describe("when removing a component", function () { var originalContent; - beforeEach(function() { + beforeEach(function () { originalContent = testPage.test.componentWithNoElement; slot.content = originalContent; }); - it("should properly remove the current content inside the slot", function() { + it("should properly remove the current content inside the slot", function () { slot.content = null; testPage.waitForDraw(); - runs(function() { + runs(function () { expect(slot.element.childElementCount).toBe(0); expect(originalContent.parentComponent).toBe(null); }); diff --git a/test/ui/slot-test/photo-viewer.reel/photo-viewer.js b/test/ui/slot-test/photo-viewer.reel/photo-viewer.js index eae9a41afc..5b76ce5ac7 100644 --- a/test/ui/slot-test/photo-viewer.reel/photo-viewer.js +++ b/test/ui/slot-test/photo-viewer.reel/photo-viewer.js @@ -34,13 +34,13 @@ var Montage = require("montage").Montage, var PhotoViewer = exports.PhotoViewer = Component.specialize( { templateDidLoad: { - value: function() { + value: function () { //console.log("PHOTOVIEWER REEL DID LOAD"); } }, deserializedFromTemplate: { - value: function() { + value: function () { //console.log("PHOTOVIEWER DESERIALIZED FROM REEL"); } }, diff --git a/test/ui/slot-test/slot-test.js b/test/ui/slot-test/slot-test.js index 48e2db5458..d284cb8b7a 100644 --- a/test/ui/slot-test/slot-test.js +++ b/test/ui/slot-test/slot-test.js @@ -70,7 +70,7 @@ var VideoMedia = Media.specialize( { var SlotTest = exports.SlotTest = Component.specialize( { init: { - value: function() { + value: function () { this.video = new VideoMedia(); this.video.duration = "VIDEO 81 Minutes"; this.video.description = "VIDEO: The Last Dispatch" @@ -88,7 +88,7 @@ var SlotTest = exports.SlotTest = Component.specialize( { }, deserializedFromTemplate: { - value: function() { + value: function () { this.init(); } }, @@ -197,7 +197,7 @@ var SlotTest = exports.SlotTest = Component.specialize( { enterDocument: { enumerable: false, - value: function(firstTime) { + value: function (firstTime) { if (firstTime) { this.componentWithNoElementButton.addEventListener("action", this); this.componentInPageWithElementButton.addEventListener("action", this); @@ -214,21 +214,21 @@ var SlotTest = exports.SlotTest = Component.specialize( { handleComponentWithNoElementButtonPress: { enumerable: false, - value: function() { + value: function () { this.showContent(this.componentWithNoElement); } }, handleComponentInPageWithElementButtonPress: { enumerable: false, - value: function() { + value: function () { this.showContent(this.componentInPageWithElement); } }, handleVideoButtonPress: { enumerable: false, - value: function() { + value: function () { this.currentMedia = this.video; this.showContent(this.videoViewer); } @@ -236,7 +236,7 @@ var SlotTest = exports.SlotTest = Component.specialize( { handlePhotoButtonPress: { enumerable: false, - value: function() { + value: function () { this.currentMedia = this.photo; this.showContent(this.photoViewer); } @@ -244,35 +244,35 @@ var SlotTest = exports.SlotTest = Component.specialize( { handleBarButtonPress: { enumerable: false, - value: function() { + value: function () { this.showContent(this.barContent); } }, handleBazButtonPress: { enumerable: false, - value: function() { + value: function () { this.showContent(this.bazContent); } }, handleQuxButtonPress: { enumerable: false, - value: function() { + value: function () { this.showContent(this.quxContent); } }, handleEmptyButtonPress: { enumerable: false, - value: function() { + value: function () { this.showContent(null); } }, showContent: { enumerable: false, - value: function(content) { + value: function (content) { //console.log("chooser showContent:", content); this.slot.content = content; } diff --git a/test/ui/slot-test/video-viewer.reel/video-viewer.js b/test/ui/slot-test/video-viewer.reel/video-viewer.js index b67ebde230..a3285592db 100644 --- a/test/ui/slot-test/video-viewer.reel/video-viewer.js +++ b/test/ui/slot-test/video-viewer.reel/video-viewer.js @@ -34,13 +34,13 @@ var Montage = require("montage").Montage, var VideoViewer = exports.VideoViewer = Component.specialize( { templateDidLoad: { - value: function() { + value: function () { //console.log("VIDEOVIEWER REEL DID LOAD"); } }, deserializedFromTemplate: { - value: function() { + value: function () { //console.log("VIDEOVIEWER DESERIALIZED FROM REEL"); } }, diff --git a/test/ui/substitution-spec.js b/test/ui/substitution-spec.js index 3f3124e11a..156244b4eb 100644 --- a/test/ui/substitution-spec.js +++ b/test/ui/substitution-spec.js @@ -1,22 +1,22 @@ var Montage = require("montage").Montage, TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; -TestPageLoader.queueTest("substitution-test/substitution-test", function(testPage) { - describe("ui/substitution-spec", function() { +TestPageLoader.queueTest("substitution-test/substitution-test", function (testPage) { + describe("ui/substitution-spec", function () { var templateObjects; - beforeEach(function() { + beforeEach(function () { templateObjects = testPage.test.templateObjects; }); - describe("pure dom arguments", function() { - it("should not have dom content when switchValue is not defined", function() { + describe("pure dom arguments", function () { + it("should not have dom content when switchValue is not defined", function () { var substitution = templateObjects.substitution1; expect(substitution.element.children.length).toBe(0); }); - it("should have its switchElements configured", function() { + it("should have its switchElements configured", function () { var substitution = templateObjects.substitution1, switchElementsKeys = Object.keys(substitution._switchElements); @@ -25,20 +25,20 @@ TestPageLoader.queueTest("substitution-test/substitution-test", function(testPag expect(switchElementsKeys).toHave("two"); }); - it("should change its DOM content when switchValue is initially set", function() { + it("should change its DOM content when switchValue is initially set", function () { var substitution = templateObjects.substitution1; substitution.switchValue = "one"; testPage.waitForComponentDraw(substitution); - runs(function() { + runs(function () { var title = substitution.element.querySelector(".title1"); expect(title).toBeDefined(); }); }); - it("should contain the content of the defined switchValue", function() { + it("should contain the content of the defined switchValue", function () { var substitution = templateObjects.substitution2, title; @@ -47,46 +47,46 @@ TestPageLoader.queueTest("substitution-test/substitution-test", function(testPag expect(title).toBeDefined(); }); - it("should switch to the new content when switchValue is changed", function() { + it("should switch to the new content when switchValue is changed", function () { var substitution = templateObjects.substitution2; substitution.switchValue = "two"; testPage.waitForComponentDraw(substitution); - runs(function() { + runs(function () { var title = substitution.element.querySelector(".title2"); expect(title).toBeDefined(); }); }); - it("should switch to a content that was previously shown and removed", function() { + it("should switch to a content that was previously shown and removed", function () { var substitution = templateObjects.substitution2; substitution.switchValue = "one"; testPage.waitForComponentDraw(substitution); - runs(function() { + runs(function () { var title = substitution.element.querySelector(".title1"); expect(title).toBeDefined(); }); }); - it("should remove all content when switchValue is null", function() { + it("should remove all content when switchValue is null", function () { var substitution = templateObjects.substitution1; substitution.switchValue = null; testPage.waitForComponentDraw(substitution); - runs(function() { + runs(function () { var children = substitution.element.children; expect(children.length).toBe(0); }); }); - it("should draw the correct element after changing the switchValue twice before it draws", function() { + it("should draw the correct element after changing the switchValue twice before it draws", function () { var substitution = templateObjects.substitution5; substitution.switchValue = "two"; @@ -94,7 +94,7 @@ TestPageLoader.queueTest("substitution-test/substitution-test", function(testPag substitution.switchValue = "two"; testPage.waitForComponentDraw(substitution); - runs(function() { + runs(function () { var children = substitution.element.children; expect(children[0].className).toBe("two"); @@ -102,8 +102,8 @@ TestPageLoader.queueTest("substitution-test/substitution-test", function(testPag }); }); - describe("arguments with components", function() { - it("should draw components when switchValue is initially set", function() { + describe("arguments with components", function () { + it("should draw components when switchValue is initially set", function () { var substitution = templateObjects.substitution3, one = templateObjects.one3; @@ -111,56 +111,56 @@ TestPageLoader.queueTest("substitution-test/substitution-test", function(testPag substitution.switchValue = "one"; testPage.waitForComponentDraw(substitution); - runs(function() { + runs(function () { expect(one.element.textContent).toBe("Title 1a"); }); }); - it("should draw a component that was previously removed", function() { + it("should draw a component that was previously removed", function () { var substitution = templateObjects.substitution3, one = templateObjects.one3; substitution.switchValue = "two"; testPage.waitForComponentDraw(substitution); - runs(function() { + runs(function () { one.value = "Title 1b"; substitution.switchValue = "one"; testPage.waitForComponentDraw(substitution); - runs(function() { + runs(function () { expect(one.element.textContent).toBe("Title 1b"); }); }); }); - it("should update the switchElements if the component is changed while in the substitution content", function() { + it("should update the switchElements if the component is changed while in the substitution content", function () { var substitution = templateObjects.substitution6; substitution.switchValue = "two"; testPage.waitForComponentDraw(substitution); - runs(function() { + runs(function () { expect(substitution._switchElements.one.className).toBe("Foo"); }); }); - it("should not use switchElements to draw a switchValue that is currently drawn because it hasn't been updated", function() { + it("should not use switchElements to draw a switchValue that is currently drawn because it hasn't been updated", function () { var substitution = templateObjects.substitution7; substitution.switchValue = "two"; substitution.switchValue = "one"; testPage.waitForComponentDraw(substitution); - runs(function() { + runs(function () { expect(substitution.element.children[0].className).toBe("Foo"); }); }); }); - describe("programmatic api", function() { - it("should accept a new element to switch", function() { + describe("programmatic api", function () { + it("should accept a new element to switch", function () { var substitution = templateObjects.substitution4, element; @@ -172,20 +172,20 @@ TestPageLoader.queueTest("substitution-test/substitution-test", function(testPag expect(substitution._switchElements.one).toBe(element); }); - it("should switch to a programmaticaly added element", function() { + it("should switch to a programmaticaly added element", function () { var substitution = templateObjects.substitution4; substitution.switchValue = "one"; testPage.waitForComponentDraw(substitution); - runs(function() { + runs(function () { var one = substitution.element.querySelector(".one"); expect(one).toBeDefined(); }); }); - it("should not accept elements that have a parent node", function() { + it("should not accept elements that have a parent node", function () { var substitution = templateObjects.substitution4, text = templateObjects.text1; diff --git a/test/ui/substitution-test/substitution-test.js b/test/ui/substitution-test/substitution-test.js index 2536a6ce32..ab543fac2a 100644 --- a/test/ui/substitution-test/substitution-test.js +++ b/test/ui/substitution-test/substitution-test.js @@ -3,7 +3,7 @@ var TestController = require("montage-testing/test-controller").TestController; exports.SubstitutionTest = TestController.specialize( { templateDidLoad: { - value: function(documentPart) { + value: function (documentPart) { this.templateObjects = documentPart.objects; } } diff --git a/test/ui/text/text-spec.js b/test/ui/text/text-spec.js index b02b153878..ecff8f3281 100644 --- a/test/ui/text/text-spec.js +++ b/test/ui/text/text-spec.js @@ -2,35 +2,35 @@ var Montage = require("montage").Montage; var TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; -TestPageLoader.queueTest("text-test", function(testPage) { +TestPageLoader.queueTest("text-test", function (testPage) { var test; - beforeEach(function() { + beforeEach(function () { test = testPage.test; }); - describe("ui/text/text-spec", function() { + describe("ui/text/text-spec", function () { - describe("Text", function() { - it("wipes out its content in initialization", function() { + describe("Text", function () { + it("wipes out its content in initialization", function () { expect(testPage.getElementById("bar")).toBeNull(); }); }); - describe("Text using plain text", function() { - it("can be created", function() { + describe("Text using plain text", function () { + it("can be created", function () { expect(test.plainText).toBeDefined(); }); - it("value can be set", function() { + it("value can be set", function () { test.plainText.value = "foo"; testPage.waitForDraw(); - runs(function() { + runs(function () { expect(test.plainText.element.textContent).toEqual("foo"); }) }); - it("value can be reset", function() { + it("value can be reset", function () { test.plainText.value = ""; testPage.waitForDraw(); - runs(function() { + runs(function () { expect(test.plainText.element.textContent).toEqual(""); }) }); diff --git a/ui/base/abstract-alert.js b/ui/base/abstract-alert.js index 290c39b20e..82b3eb3f86 100644 --- a/ui/base/abstract-alert.js +++ b/ui/base/abstract-alert.js @@ -49,7 +49,7 @@ exports.AbstractAlert = Component.specialize(/** @lends AbstractAlert# */ { }, enterDocument: { - value: function(firstTime) { + value: function (firstTime) { var constructor; if (firstTime) { @@ -69,7 +69,7 @@ exports.AbstractAlert = Component.specialize(/** @lends AbstractAlert# */ { * Returns a promise for the close of the alert */ show: { - value: function() { + value: function () { if (!this._userActionDeferred) { this._overlay.hasModalMask = false; this._overlay.show(); @@ -81,7 +81,7 @@ exports.AbstractAlert = Component.specialize(/** @lends AbstractAlert# */ { }, handleAction: { - value: function(event) { + value: function (event) { if (event.target === this._okButton) { this._userActionDeferred.resolve(); this._userActionDeferred = null; @@ -103,7 +103,7 @@ exports.AbstractAlert = Component.specialize(/** @lends AbstractAlert# */ { * on the AbstractAlert but on the type that extends it. */ _nextMessageDeferred: { - get: function() { + get: function () { if (!this.hasOwnProperty("__nextMessageDeferred")) { this.__nextMessageDeferred = Promise.defer(); } @@ -121,10 +121,10 @@ exports.AbstractAlert = Component.specialize(/** @lends AbstractAlert# */ { }, _nextMessagePromise: { - set: function(value) { + set: function (value) { this.__nextMessagePromise = value; }, - get: function() { + get: function () { if (!this.hasOwnProperty("__nextMessagePromise")) { this.__nextMessagePromise = this._nextMessageDeferred.promise; } @@ -134,7 +134,7 @@ exports.AbstractAlert = Component.specialize(/** @lends AbstractAlert# */ { }, _setupInstance: { - value: function() { + value: function () { var instance; instance = this._instance = new this(); @@ -149,7 +149,7 @@ exports.AbstractAlert = Component.specialize(/** @lends AbstractAlert# */ { }, show: { - value: function(message, title) { + value: function (message, title) { var instance, self = this; @@ -159,7 +159,7 @@ exports.AbstractAlert = Component.specialize(/** @lends AbstractAlert# */ { instance = this._instance; - return this._nextMessagePromise = this._nextMessagePromise.then(function() { + return this._nextMessagePromise = this._nextMessagePromise.then(function () { if (title) { instance.title = title; } else { diff --git a/ui/base/abstract-button.js b/ui/base/abstract-button.js index f3c5e2b413..5abb2d6167 100644 --- a/ui/base/abstract-button.js +++ b/ui/base/abstract-button.js @@ -1,49 +1,42 @@ /*global require, exports*/ /** - * @module montage/ui/base/abstract-button.reel - * @requires montage/core/core - * @requires montage/ui/component - * @requires montage/ui/native-control + * @module montage/ui/base/abstract-button + * @requires montage/ui/base/abstract-control * @requires montage/composer/press-composer */ -var Montage = require("../../core/core").Montage, - AbstractControl = require("./abstract-control").AbstractControl, +var AbstractControl = require("./abstract-control").AbstractControl, PressComposer = require("../../composer/press-composer").PressComposer; /** * @class AbstractButton * @extends AbstractControl - * @fires AbstractButton#action - * @fires AbstractButton#longAction */ -var AbstractButton = exports.AbstractButton = AbstractControl.specialize( /** @lends AbstractButton# */ { +var AbstractButton = exports.AbstractButton = AbstractControl.specialize( /** @lends AbstractButton.prototype # */ { /** * Dispatched when the button is activated through a mouse click, finger * tap, or when focused and the spacebar is pressed. - * @event action - * @memberof AbstractButton - * @property {Dict} detail - The detail object as defined in {@link - * AbstractControl#detail} + * + * @event AbstractButton#action + * @property {Dict} detail - The detail object as defined in {@link AbstractControl#detail} */ /** * Dispatched when the button is pressed for a period of time, set by * {@link AbstractButton#holdThreshold}. - * @event longAction - * @memberof AbstractButton - * @property {Dict} detail - The detail object as defined in {@link - * AbstractControl#detail} + * + * @event AbstractButton#longAction + * @property {Dict} detail - The detail object as defined in {@link AbstractControl#detail} */ /** - * @private + * @constructs */ constructor: { value: function AbstractButton() { if(this.constructor === AbstractButton) { - throw new Error("AbstractControl cannot be instantiated."); + throw new Error("AbstractButton cannot be instantiated."); } this.super(); this._pressComposer = new PressComposer(); @@ -62,22 +55,24 @@ var AbstractButton = exports.AbstractButton = AbstractControl.specialize( /** @l * button's DOM element during the next draw cycle. When set to `true` the * "montage--disabled" CSS class is removed from the element's class * list. - * @type {boolean} + * @property {boolean} value */ enabled: { value: true }, + /** + * @private + */ _preventFocus: { value: false }, /** * Specifies whether the button should receive focus or not. - * @type {boolean} + * + * @property {boolean} * @default false - * @event longpress - * @memberof AbstractButton */ preventFocus: { get: function () { @@ -90,13 +85,13 @@ var AbstractButton = exports.AbstractButton = AbstractControl.specialize( /** @l }, acceptsActiveTarget: { - value: function() { + value: function () { return ! this._preventFocus; } }, willBecomeActiveTarget: { - value: function(previousActiveTarget) { + value: function (previousActiveTarget) { } }, @@ -108,19 +103,22 @@ var AbstractButton = exports.AbstractButton = AbstractControl.specialize( /** @l */ _labelNode: {value:undefined, enumerable: false}, - _label: { value: undefined, enumerable: false }, + _label: {value: undefined, enumerable: false}, /** - * The displayed text on the button. In an <input> element this is taken from the element's `value` attribute. On any other element (including <button>) this is the first child node which is a text node. If one isn't found then it will be created. - * If the button has a non-null `converter` property, the converter object's `convert()` method is called on the value before being assigned to the button instance. - * @type {string} + * The displayed text on the button. In an `input` element this is taken from the element's `value` attribute. + * On any other element (including `button`) this is the first child node which is a text node. + * If one isn't found then it will be created. If the button has a non-null `converter` property, + * the converter object's `convert()` method is called on the value before being assigned to the button instance. + * + * @property {string} * @default undefined */ label: { - get: function() { + get: function () { return this._label; }, - set: function(value) { + set: function (value) { if (typeof value !== "undefined" && this.converter) { try { value = this.converter.convert(value); @@ -140,17 +138,25 @@ var AbstractButton = exports.AbstractButton = AbstractControl.specialize( /** @l /** * The amount of time in milliseconds the user must press and hold the * button a `longAction` event is dispatched. The default is 1 second. - * @type {number} + * @property {number} value * @default 1000 */ holdThreshold: { value: 1000 }, + /** + * @property {PressComposer} value + * @default null + * @private + */ _pressComposer: { value: null }, + /** + * @private + */ _active: { value: false }, @@ -158,21 +164,22 @@ var AbstractButton = exports.AbstractButton = AbstractControl.specialize( /** @l /** * This property is true when the button is being interacted with, either * through mouse click or touch event, otherwise false. - * @type {boolean} + * + * @property {boolean} * @default false */ active: { - get: function() { + get: function () { return this._active; }, - set: function(value) { + set: function (value) { this._active = value; this.needsDraw = true; } }, prepareForActivationEvents: { - value: function() { + value: function () { this._pressComposer.addEventListener("pressStart", this, false); this._pressComposer.addEventListener("press", this, false); this._pressComposer.addEventListener("pressCancel", this, false); @@ -181,7 +188,7 @@ var AbstractButton = exports.AbstractButton = AbstractControl.specialize( /** @l // Optimisation addEventListener: { - value: function(type, listener, useCapture) { + value: function (type, listener, useCapture) { AbstractControl.addEventListener.call(this, type, listener, useCapture); if (type === "longAction") { this._pressComposer.addEventListener("longPress", this, false); @@ -193,10 +200,11 @@ var AbstractButton = exports.AbstractButton = AbstractControl.specialize( /** @l /** * Called when the user starts interacting with the component. + * * @private */ handlePressStart: { - value: function(event) { + value: function (event) { this.active = true; if (event.touch) { @@ -213,10 +221,11 @@ var AbstractButton = exports.AbstractButton = AbstractControl.specialize( /** @l /** * Called when the user has interacted with the button. + * * @private */ handlePress: { - value: function(event) { + value: function (event) { this.active = false; this.dispatchActionEvent(); document.removeEventListener("touchmove", this, false); @@ -224,7 +233,7 @@ var AbstractButton = exports.AbstractButton = AbstractControl.specialize( /** @l }, handleKeyup: { - value: function(event) { + value: function (event) { // action event on spacebar if (event.keyCode === 32) { this.active = false; @@ -234,7 +243,7 @@ var AbstractButton = exports.AbstractButton = AbstractControl.specialize( /** @l }, handleLongPress: { - value: function(event) { + value: function (event) { // When we fire the "longAction" event we don't want to fire the // "action" event as well. this._pressComposer.cancelPress(); @@ -246,32 +255,35 @@ var AbstractButton = exports.AbstractButton = AbstractControl.specialize( /** @l }, /** - Called when all interaction is over. - @private - */ + * Called when all interaction is over. + * @private + */ handlePressCancel: { - value: function(event) { + value: function (event) { this.active = false; document.removeEventListener("touchmove", this, false); } }, + /** + * @private + */ handleTouchmove: { - value: function(event) { + value: function (event) { event.preventDefault(); } }, /** - If this is an input element then the label is handled differently. - @private - */ + * If this is an input element then the label is handled differently. + * @private + */ isInputElement: { value: false }, enterDocument: { - value: function(firstDraw) { + value: function (firstDraw) { if(firstDraw) { this.isInputElement = (this.originalElement.tagName === "INPUT"); // Only take the value from the element if it hasn't been set @@ -299,12 +311,12 @@ var AbstractButton = exports.AbstractButton = AbstractControl.specialize( /** @l /** * Draws the label to the DOM. - * @method + * @function * @private */ _drawLabel: { enumerable: false, - value: function(value) { + value: function (value) { if (this.isInputElement) { this._element.value = value; } else if (this._labelNode) { @@ -314,7 +326,7 @@ var AbstractButton = exports.AbstractButton = AbstractControl.specialize( /** @l }, draw: { - value: function() { + value: function () { if (this._elementNeedsTabIndex()) { if (this._preventFocus) { this.element.removeAttribute("tabindex"); @@ -336,7 +348,7 @@ var AbstractButton = exports.AbstractButton = AbstractControl.specialize( /** @l }, _elementNeedsTabIndex: { - value: function() { + value: function () { return this.element.tagName.match(this._elementNeedsTabIndexRegex) === null; } } diff --git a/ui/base/abstract-checkbox.js b/ui/base/abstract-checkbox.js index 50e4e4e641..35e61499e4 100644 --- a/ui/base/abstract-checkbox.js +++ b/ui/base/abstract-checkbox.js @@ -66,10 +66,10 @@ var AbstractCheckbox = exports.AbstractCheckbox = AbstractControl.specialize( /* * @default false */ checked: { - set: function(value) { + set: function (value) { this._checked = value; }, - get: function() { + get: function () { return this._checked; } }, @@ -89,7 +89,7 @@ var AbstractCheckbox = exports.AbstractCheckbox = AbstractControl.specialize( /* }, enterDocument: { - value: function(firstTime) { + value: function (firstTime) { if (firstTime) { this.element.setAttribute("role", "checkbox"); } @@ -97,7 +97,7 @@ var AbstractCheckbox = exports.AbstractCheckbox = AbstractControl.specialize( /* }, draw: { - value: function() { + value: function () { if (this.checked) { this.element.setAttribute("aria-checked", "true"); } else { @@ -107,7 +107,7 @@ var AbstractCheckbox = exports.AbstractCheckbox = AbstractControl.specialize( /* }, toggleChecked: { - value: function() { + value: function () { if (!this.enabled) { return; } @@ -117,7 +117,7 @@ var AbstractCheckbox = exports.AbstractCheckbox = AbstractControl.specialize( /* }, handlePressStart: { - value: function(event) { + value: function (event) { this.active = true; if (event.touch) { @@ -132,7 +132,7 @@ var AbstractCheckbox = exports.AbstractCheckbox = AbstractControl.specialize( /* * Handle press event from press composer */ handlePress: { - value: function(/* event */) { + value: function (/* event */) { this.active = false; this.toggleChecked(); } @@ -143,14 +143,14 @@ var AbstractCheckbox = exports.AbstractCheckbox = AbstractControl.specialize( /* * @private */ handlePressCancel: { - value: function(/* event */) { + value: function (/* event */) { this.active = false; document.removeEventListener("touchmove", this, false); } }, prepareForActivationEvents: { - value: function() { + value: function () { this._pressComposer.addEventListener("pressStart", this, false); this._pressComposer.addEventListener("press", this, false); this._pressComposer.addEventListener("pressCancel", this, false); @@ -158,7 +158,7 @@ var AbstractCheckbox = exports.AbstractCheckbox = AbstractControl.specialize( /* }, activate: { - value: function() { + value: function () { this.toggleChecked(); } } diff --git a/ui/base/abstract-confirm.js b/ui/base/abstract-confirm.js index e1c2b9c731..8c6242340f 100644 --- a/ui/base/abstract-confirm.js +++ b/ui/base/abstract-confirm.js @@ -35,7 +35,7 @@ var AbstractConfirm = exports.AbstractConfirm = AbstractAlert.specialize(/** @le }, enterDocument: { - value: function(firstTime) { + value: function (firstTime) { this.super(firstTime); if (firstTime) { @@ -45,7 +45,7 @@ var AbstractConfirm = exports.AbstractConfirm = AbstractAlert.specialize(/** @le }, handleAction: { - value: function(event) { + value: function (event) { if (event.target === this._okButton) { this._userActionDeferred.resolve(AbstractConfirm.OKButton); this._userActionDeferred = null; @@ -63,7 +63,7 @@ var AbstractConfirm = exports.AbstractConfirm = AbstractAlert.specialize(/** @le }, { show: { - value: function(message, title, okLabel, cancelLabel) { + value: function (message, title, okLabel, cancelLabel) { var instance, self = this; @@ -73,7 +73,7 @@ var AbstractConfirm = exports.AbstractConfirm = AbstractAlert.specialize(/** @le instance = this._instance; - return this._nextMessagePromise = this._nextMessagePromise.then(function() { + return this._nextMessagePromise = this._nextMessagePromise.then(function () { if (title) { instance.title = title; } else { diff --git a/ui/base/abstract-control.js b/ui/base/abstract-control.js index d1bcfeb8a3..067a75dd99 100644 --- a/ui/base/abstract-control.js +++ b/ui/base/abstract-control.js @@ -1,6 +1,11 @@ /*global require, exports, document, Error*/ -var Montage = require("../../core/core").Montage, - Component = require("../component").Component, + +/** + * @module montage/ui/base/abstract-control + * @requires montage/ui/component + * @requires collections/dict + */ +var Component = require("../component").Component, Dict = require("collections/dict"); /** @@ -8,14 +13,32 @@ var Montage = require("../../core/core").Montage, * @classdesc A basis for common behavior of control components. * @extends Component */ -exports.AbstractControl = Component.specialize( /** @lends AbstractControl# */ { +exports.AbstractControl = Component.specialize( /** @lends AbstractControl.prototype # */ { + /** + * Dispatched when the button is activated through a mouse click, finger + * tap, or when focused and the spacebar is pressed. + * + * @event AbstractControl#action + * @type {Event} + * @property {Dict} detail - pass custom data in this property + */ + + /** + * @function + * @fires AbstractControl#action + */ dispatchActionEvent: { - value: function() { + value: function () { return this.dispatchEvent(this.createActionEvent()); } }, + /** + * @private + * @property {Dict} value + * @default null + */ _detail: { value: null }, @@ -25,11 +48,11 @@ exports.AbstractControl = Component.specialize( /** @lends AbstractControl# */ { * * Example to toggle the complete class: `"detail.get('selectedItem')" : { * "<-" : "@repetition:iteration.object"}` - * @type {Dict} - * @default null + * + * @returns {Dict} */ detail: { - get: function() { + get: function () { if (this._detail == null) { this._detail = new Dict(); } @@ -37,8 +60,15 @@ exports.AbstractControl = Component.specialize( /** @lends AbstractControl# */ { } }, + /** + * Overrides {@link Component#createActionEvent} + * by adding {@link AbstractControl#detail} custom data + * + * @function + * @returns {AbstractControl#action} + */ createActionEvent: { - value: function() { + value: function () { var actionEvent = document.createEvent("CustomEvent"), eventDetail; diff --git a/ui/base/abstract-image.js b/ui/base/abstract-image.js index ac4c1de3ca..87d58ebade 100644 --- a/ui/base/abstract-image.js +++ b/ui/base/abstract-image.js @@ -43,7 +43,7 @@ var AbstractImage = exports.AbstractImage = Component.specialize( /** @lends Abs }, src: { - set: function(value) { + set: function (value) { if (this._src !== value) { this._src = value; @@ -57,13 +57,13 @@ var AbstractImage = exports.AbstractImage = Component.specialize( /** @lends Abs this.needsDraw = true; } }, - get: function() { + get: function () { return this._src; } }, _loadImage: { - value: function(src) { + value: function (src) { this._image.src = src; this._isLoadingImage = !this._image.complete; } @@ -90,11 +90,11 @@ var AbstractImage = exports.AbstractImage = Component.specialize( /** @lends Abs }, textAlternative: { - set: function(value) { + set: function (value) { this._textAlternative = value; this.needsDraw = true; }, - get: function() { + get: function () { return this._textAlternative; } }, @@ -104,19 +104,19 @@ var AbstractImage = exports.AbstractImage = Component.specialize( /** @lends Abs }, crossOrigin: { - set: function(value) { + set: function (value) { if (value !== this._crossOrigin) { this._crossOrigin = value; this.needsDraw = true; } }, - get: function() { + get: function () { return this._crossOrigin; } }, _rebaseSrc: { - value: function() { + value: function () { var value; value = this._getRebasedSrc(); @@ -135,7 +135,7 @@ var AbstractImage = exports.AbstractImage = Component.specialize( /** @lends Abs // If the "src" property is an absolute url ("http://" "https://" "/" "//" // "data:") then no operation is performed and the "src" ir returned as is. _getRebasedSrc: { - value: function() { + value: function () { var url = this._src, baseUrl, // Check for ":", "/" and "//" @@ -157,7 +157,7 @@ var AbstractImage = exports.AbstractImage = Component.specialize( /** @lends Abs }, enterDocument: { - value: function(firstTime) { + value: function (firstTime) { if (firstTime) { this.element.setAttribute("role", "img"); } @@ -165,7 +165,7 @@ var AbstractImage = exports.AbstractImage = Component.specialize( /** @lends Abs }, draw: { - value: function() { + value: function () { var src; if (this._isLoadingImage || this._isInvalidSrc) { @@ -192,7 +192,7 @@ var AbstractImage = exports.AbstractImage = Component.specialize( /** @lends Abs }, handleImageLoad: { - value: function() { + value: function () { this._isLoadingImage = false; this.needsDraw = true; } diff --git a/ui/base/abstract-link.js b/ui/base/abstract-link.js index adff56077a..d8d13fa471 100644 --- a/ui/base/abstract-link.js +++ b/ui/base/abstract-link.js @@ -64,11 +64,11 @@ var AbstractLink = exports.AbstractLink = AbstractControl.specialize( }, url: { - set: function(value) { + set: function (value) { this._url = value; this.needsDraw = true; }, - get: function() { + get: function () { return this._url; } }, @@ -78,11 +78,11 @@ var AbstractLink = exports.AbstractLink = AbstractControl.specialize( }, label: { - set: function(value) { + set: function (value) { this._label = value; this.needsDraw = true; }, - get: function() { + get: function () { return this._label; } }, @@ -92,11 +92,11 @@ var AbstractLink = exports.AbstractLink = AbstractControl.specialize( }, textAlternative: { - set: function(value) { + set: function (value) { this._textAlternative = value; this.needsDraw = true; }, - get: function() { + get: function () { return this._textAlternative; } }, @@ -106,17 +106,17 @@ var AbstractLink = exports.AbstractLink = AbstractControl.specialize( }, opensNewWindow: { - set: function(value) { + set: function (value) { this._opensNewWindow = value; this.needsDraw = true; }, - get: function() { + get: function () { return this._opensNewWindow; } }, enterDocument: { - value: function(firstTime) { + value: function (firstTime) { if (firstTime) { if (!this.hasOwnProperty("_label")) { this.label = this.element.textContent; @@ -126,7 +126,7 @@ var AbstractLink = exports.AbstractLink = AbstractControl.specialize( }, handlePressStart: { - value: function(event) { + value: function (event) { this.active = true; if (event.touch) { @@ -142,7 +142,7 @@ var AbstractLink = exports.AbstractLink = AbstractControl.specialize( * @private */ handlePress: { - value: function(/* event */) { + value: function (/* event */) { this.active = false; if (!this.enabled) { @@ -158,14 +158,14 @@ var AbstractLink = exports.AbstractLink = AbstractControl.specialize( * @private */ handlePressCancel: { - value: function(/* event */) { + value: function (/* event */) { this.active = false; document.removeEventListener("touchmove", this, false); } }, prepareForActivationEvents: { - value: function() { + value: function () { this._pressComposer.addEventListener("pressStart", this, false); this._pressComposer.addEventListener("press", this, false); this._pressComposer.addEventListener("pressCancel", this, false); diff --git a/ui/base/abstract-number-field.js b/ui/base/abstract-number-field.js index 7320e66553..df06a5c5ad 100644 --- a/ui/base/abstract-number-field.js +++ b/ui/base/abstract-number-field.js @@ -67,24 +67,24 @@ var AbstractNumberField = exports.AbstractNumberField = AbstractControl.speciali }, textFieldShouldBeginEditing: { - value: function() { + value: function () { return this.enabled; } }, textFieldDidChange: { - value: function() { + value: function () { } }, textFieldDidEndEditing: { - value: function() { + value: function () { this.value = this._numberFieldTextFieldComponent.value; } }, textFieldShouldAcceptValue: { - value: function(textField, value) { + value: function (textField, value) { if (this._activeValueChange === true) { return true; } @@ -93,7 +93,7 @@ var AbstractNumberField = exports.AbstractNumberField = AbstractControl.speciali prepareForActivationEvents: { - value: function() { + value: function () { this._upKeyComposer.addEventListener("keyPress", this, false); this._downKeyComposer.addEventListener("keyPress", this, false); this._leftKeyComposer.addEventListener("keyPress", this, false); @@ -102,7 +102,7 @@ var AbstractNumberField = exports.AbstractNumberField = AbstractControl.speciali }, draw: { - value: function() { + value: function () { this.element.setAttribute("aria-valuemax", this.max); this.element.setAttribute("aria-valuemin", this.min); this.element.setAttribute("aria-valuenow", this.value); @@ -172,7 +172,7 @@ var AbstractNumberField = exports.AbstractNumberField = AbstractControl.speciali }, handleKeyPress: { - value: function(event) { + value: function (event) { if (!this.enabled) { return; } @@ -185,7 +185,7 @@ var AbstractNumberField = exports.AbstractNumberField = AbstractControl.speciali }, handleAction: { - value: function(event) { + value: function (event) { if (event.target === this._numberFieldTextFieldComponent || event.target === this._numberFieldMinusComponent || event.target === this._numberFieldPlusComponent) { diff --git a/ui/base/abstract-radio-button.js b/ui/base/abstract-radio-button.js index cbd2c194a2..2e6bde8dc3 100644 --- a/ui/base/abstract-radio-button.js +++ b/ui/base/abstract-radio-button.js @@ -70,10 +70,10 @@ var AbstractRadioButton = exports.AbstractRadioButton = AbstractControl.speciali * @type {boolean} */ checked: { - set: function(value) { + set: function (value) { this._checked = value; }, - get: function() { + get: function () { return this._checked; } }, @@ -100,14 +100,14 @@ var AbstractRadioButton = exports.AbstractRadioButton = AbstractControl.speciali * @type {RadioButtonController} */ radioButtonController: { - set: function(value) { + set: function (value) { if (this._radioButtonController) { this._radioButtonController.unregisterRadioButton(this); } this._radioButtonController = value; value.registerRadioButton(this); }, - get: function() { + get: function () { return this._radioButtonController; } }, @@ -117,7 +117,7 @@ var AbstractRadioButton = exports.AbstractRadioButton = AbstractControl.speciali }, enterDocument: { - value: function(firstTime) { + value: function (firstTime) { if (firstTime) { this.element.setAttribute("role", "radio"); this._keyComposer.addEventListener("keyPress", this, false); @@ -127,7 +127,7 @@ var AbstractRadioButton = exports.AbstractRadioButton = AbstractControl.speciali }, draw: { - value: function() { + value: function () { if (this.checked) { this.element.setAttribute("aria-checked", "true"); } else { @@ -137,7 +137,7 @@ var AbstractRadioButton = exports.AbstractRadioButton = AbstractControl.speciali }, handlePressStart: { - value: function(event) { + value: function (event) { this.active = true; if (event.touch) { @@ -149,7 +149,7 @@ var AbstractRadioButton = exports.AbstractRadioButton = AbstractControl.speciali }, check: { - value: function() { + value: function () { if (!this.enabled || this.checked) { return; } @@ -163,7 +163,7 @@ var AbstractRadioButton = exports.AbstractRadioButton = AbstractControl.speciali Handle press event from press composer */ handlePress: { - value: function(/* event */) { + value: function (/* event */) { this.active = false; this.check(); } @@ -174,27 +174,27 @@ var AbstractRadioButton = exports.AbstractRadioButton = AbstractControl.speciali @private */ handlePressCancel: { - value: function(/* event */) { + value: function (/* event */) { this.active = false; document.removeEventListener("touchmove", this, false); } }, handleKeyPress: { - value: function() { + value: function () { this.active = true; } }, handleKeyRelease: { - value: function() { + value: function () { this.active = false; this.check(); } }, prepareForActivationEvents: { - value: function() { + value: function () { this._pressComposer.addEventListener("pressStart", this, false); this._pressComposer.addEventListener("press", this, false); this._pressComposer.addEventListener("pressCancel", this, false); @@ -202,7 +202,7 @@ var AbstractRadioButton = exports.AbstractRadioButton = AbstractControl.speciali }, activate: { - value: function() { + value: function () { this.check(); } } diff --git a/ui/base/abstract-select.js b/ui/base/abstract-select.js index b76c541b99..a7e105bc8f 100644 --- a/ui/base/abstract-select.js +++ b/ui/base/abstract-select.js @@ -105,7 +105,7 @@ var AbstractSelect = exports.AbstractSelect = AbstractControl.specialize( /** @l }, labelPropertyName: { - set: function(value) { + set: function (value) { if (value) { this._labelPropertyName = value; } else { @@ -114,7 +114,7 @@ var AbstractSelect = exports.AbstractSelect = AbstractControl.specialize( /** @l this._contentIsDirty = true; this.needsDraw = true; }, - get: function() { + get: function () { return this._labelPropertyName; } }, @@ -124,10 +124,10 @@ var AbstractSelect = exports.AbstractSelect = AbstractControl.specialize( /** @l }, value: { - get: function() { + get: function () { return this._value; }, - set: function(value) { + set: function (value) { if (value !== this._value) { this._value = value; // TODO: "value" <-> "values.one()" @@ -144,10 +144,10 @@ var AbstractSelect = exports.AbstractSelect = AbstractControl.specialize( /** @l }, values: { - get: function() { + get: function () { return this._values; }, - set: function(value) { + set: function (value) { var args = [0, this._values.length].concat(value); this._values.splice.apply(this._values, args); @@ -164,7 +164,7 @@ var AbstractSelect = exports.AbstractSelect = AbstractControl.specialize( /** @l }, prepareForActivationEvents: { - value: function() { + value: function () { this._pressComposer.addEventListener("pressStart", this, false); this._pressComposer.addEventListener("press", this, false); this._pressComposer.addEventListener("pressCancel", this, false); @@ -177,7 +177,7 @@ var AbstractSelect = exports.AbstractSelect = AbstractControl.specialize( /** @l * Called when the user starts interacting with the component. */ handlePressStart: { - value: function(event) { + value: function (event) { this.active = true; if (event.touch) { @@ -192,7 +192,7 @@ var AbstractSelect = exports.AbstractSelect = AbstractControl.specialize( /** @l * Called when the user has interacted with the select. */ handlePress: { - value: function(event) { + value: function (event) { this.active = false; if (!this.enabled) { @@ -209,20 +209,20 @@ var AbstractSelect = exports.AbstractSelect = AbstractControl.specialize( /** @l * @private */ handlePressCancel: { - value: function(event) { + value: function (event) { this.active = false; document.removeEventListener("touchmove", this, false); } }, handleTouchmove: { - value: function(event) { + value: function (event) { event.preventDefault(); } }, handleContentRangeChange: { - value: function() { + value: function () { // When the content changes we need to update the "value" if none is // set (new content) or if the previous "value" was removed in this // range change. @@ -239,7 +239,7 @@ var AbstractSelect = exports.AbstractSelect = AbstractControl.specialize( /** @l }, handleValuesRangeChange: { - value: function() { + value: function () { // TODO: "value" <-> "values.one()" if (this.values.length > 0) { this.value = this.values.one(); @@ -249,7 +249,7 @@ var AbstractSelect = exports.AbstractSelect = AbstractControl.specialize( /** @l }, handleContentControllerChange: { - value: function(value) { + value: function (value) { if (value) { this._values = value.selection; this.handleValuesRangeChange(); @@ -258,7 +258,7 @@ var AbstractSelect = exports.AbstractSelect = AbstractControl.specialize( /** @l }, enterDocument: { - value: function(firstDraw) { + value: function (firstDraw) { if(firstDraw) { this.element.setAttribute("role", "listbox"); } diff --git a/ui/base/abstract-slider.js b/ui/base/abstract-slider.js index dd00d42be8..cbc532320e 100644 --- a/ui/base/abstract-slider.js +++ b/ui/base/abstract-slider.js @@ -266,7 +266,7 @@ var AbstractSlider = exports.AbstractSlider = AbstractControl.specialize( /** @l }, handleKeyPress: { - value: function(event) { + value: function (event) { if (!this.enabled) { return; } @@ -422,7 +422,7 @@ var AbstractSlider = exports.AbstractSlider = AbstractControl.specialize( /** @l }, _calculateSliderMagnitude: { - value: function() { + value: function () { var computedStyle = window.getComputedStyle(this._element); if(this.axis === "vertical") { @@ -442,7 +442,7 @@ var AbstractSlider = exports.AbstractSlider = AbstractControl.specialize( /** @l }, handleAxisChange: { - value: function() { + value: function () { if (this._translateComposer) { this._translateComposer.axis = this.axis; } @@ -461,7 +461,7 @@ var AbstractSlider = exports.AbstractSlider = AbstractControl.specialize( /** @l }, handlePropertyChange: { - value: function(changeValue, key, object) { + value: function (changeValue, key, object) { if(key.match(this._propertyRegex) !== null) { if(this._propertyNamesUsed) { this._propertyNamesUsed[key] = true; diff --git a/ui/base/abstract-text-area.js b/ui/base/abstract-text-area.js index c559179209..f4cef04383 100644 --- a/ui/base/abstract-text-area.js +++ b/ui/base/abstract-text-area.js @@ -42,11 +42,11 @@ var AbstractTextArea = exports.AbstractTextArea = Component.specialize( }, placeholderValue: { - set: function(value) { + set: function (value) { this._placeholderValue = value; this.needsDraw = true; }, - get: function() { + get: function () { return this._placeholderValue; } }, @@ -56,17 +56,17 @@ var AbstractTextArea = exports.AbstractTextArea = Component.specialize( }, value: { - set: function(value) { + set: function (value) { this._value = value; this.needsDraw = true; }, - get: function() { + get: function () { return this._value; } }, enterDocument: { - value: function(firstTime) { + value: function (firstTime) { if (firstTime) { this.element.addEventListener("input", this, false); this.element.addEventListener("change", this, false); @@ -75,7 +75,7 @@ var AbstractTextArea = exports.AbstractTextArea = Component.specialize( }, draw: { - value: function() { + value: function () { var value = this.value; this.element.value = value || false === value ? value.toString() : ""; if (this._placeholderValue != null) { @@ -85,19 +85,19 @@ var AbstractTextArea = exports.AbstractTextArea = Component.specialize( }, handleChange: { - value: function() { + value: function () { this._updateValueFromDom(); } }, handleInput: { - value: function(event) { + value: function (event) { this._updateValueFromDom(); } }, _updateValueFromDom: { - value: function() { + value: function () { if (this._value !== this.element.value) { this._value = this.element.value; this.dispatchOwnPropertyChange("value", this._value); diff --git a/ui/base/abstract-text-field.js b/ui/base/abstract-text-field.js index 7e7e40d47d..f1abb72a88 100644 --- a/ui/base/abstract-text-field.js +++ b/ui/base/abstract-text-field.js @@ -49,7 +49,7 @@ var AbstractTextField = exports.AbstractTextField = AbstractControl.specialize( }, acceptsActiveTarget: { - get: function() { + get: function () { var shouldBeginEditing = this.callDelegateMethod("shouldBeginEditing", this); return (shouldBeginEditing !== false); } @@ -68,11 +68,11 @@ var AbstractTextField = exports.AbstractTextField = AbstractControl.specialize( }, placeholderValue: { - set: function(value) { + set: function (value) { this._placeholderValue = value; this.needsDraw = true; }, - get: function() { + get: function () { return this._placeholderValue; } }, @@ -100,7 +100,7 @@ var AbstractTextField = exports.AbstractTextField = AbstractControl.specialize( }, hasFocus: { - get: function() { + get: function () { return this._hasFocus; } }, @@ -110,7 +110,7 @@ var AbstractTextField = exports.AbstractTextField = AbstractControl.specialize( }, handleKeyPress: { - value: function(evt) { + value: function (evt) { if (!this.enabled || evt.keyComposer !== this._keyComposer) { return; } @@ -120,13 +120,13 @@ var AbstractTextField = exports.AbstractTextField = AbstractControl.specialize( }, prepareForActivationEvents: { - value: function() { + value: function () { this._keyComposer.addEventListener("keyPress", this, false); } }, enterDocument: { - value: function(firstTime) { + value: function (firstTime) { if (firstTime) { this.element.addEventListener("input", this, false); this.element.addEventListener("change", this, false); @@ -135,7 +135,7 @@ var AbstractTextField = exports.AbstractTextField = AbstractControl.specialize( }, draw: { - value: function() { + value: function () { var value = this.value; if (value === null || typeof value === "undefined") { this.element.value = ""; @@ -151,26 +151,26 @@ var AbstractTextField = exports.AbstractTextField = AbstractControl.specialize( }, handleChange: { - value: function() { + value: function () { this._updateValueFromDom(); } }, handleInput: { - value: function(event) { + value: function (event) { this._updateValueFromDom(); } }, willBecomeActiveTarget: { - value: function(event) { + value: function (event) { this._hasFocus = true; this.callDelegateMethod("didBeginEditing", this); } }, surrendersActiveTarget: { - value: function(event) { + value: function (event) { var shouldEnd = this.callDelegateMethod("shouldEndEditing", this); if (shouldEnd === false) { return false; @@ -183,7 +183,7 @@ var AbstractTextField = exports.AbstractTextField = AbstractControl.specialize( }, _updateValueFromDom: { - value: function() { + value: function () { if (this._value !== this.element.value) { this._value = this.element.value; this.dispatchOwnPropertyChange("value", this._value); diff --git a/ui/base/abstract-toggle-button.js b/ui/base/abstract-toggle-button.js index 32bebe7f79..555112732e 100644 --- a/ui/base/abstract-toggle-button.js +++ b/ui/base/abstract-toggle-button.js @@ -36,7 +36,7 @@ var AbstractToggleButton = exports.AbstractToggleButton = AbstractControl.specia * @private */ constructor: { - value: function() { + value: function () { if(this.constructor === AbstractToggleButton) { throw new Error("AbstractToggleButton cannot be instantiated."); } @@ -82,7 +82,7 @@ var AbstractToggleButton = exports.AbstractToggleButton = AbstractControl.specia }, acceptsActiveTarget: { - value: function() { + value: function () { return true; } }, @@ -107,10 +107,10 @@ var AbstractToggleButton = exports.AbstractToggleButton = AbstractControl.specia * @default undefined */ pressedLabel: { - get: function() { + get: function () { return this._pressedLabel; }, - set: function(value) { + set: function (value) { this._pressedLabel = "" + value; this.needsDraw = true; } @@ -126,10 +126,10 @@ var AbstractToggleButton = exports.AbstractToggleButton = AbstractControl.specia * @default undefined */ unpressedLabel: { - get: function() { + get: function () { return this._unpressedLabel; }, - set: function(value) { + set: function (value) { this._unpressedLabel = "" + value; this.needsDraw = true; } @@ -164,10 +164,10 @@ var AbstractToggleButton = exports.AbstractToggleButton = AbstractControl.specia * @default false */ active: { - get: function() { + get: function () { return this._active; }, - set: function(value) { + set: function (value) { this._active = value; this.needsDraw = true; } @@ -178,19 +178,19 @@ var AbstractToggleButton = exports.AbstractToggleButton = AbstractControl.specia }, pressed: { - set: function(value) { + set: function (value) { if (value !== this._pressed) { this._pressed = value; this.needsDraw = true; } }, - get: function() { + get: function () { return this._pressed; } }, prepareForActivationEvents: { - value: function() { + value: function () { this._pressComposer.addEventListener("pressStart", this, false); this._pressComposer.addEventListener("press", this, false); this._pressComposer.addEventListener("pressCancel", this, false); @@ -201,7 +201,7 @@ var AbstractToggleButton = exports.AbstractToggleButton = AbstractControl.specia // Optimisation addEventListener: { - value: function(type, listener, useCapture) { + value: function (type, listener, useCapture) { AbstractControl.addEventListener.call(this, type, listener, useCapture); if (type === "longAction") { this._pressComposer.addEventListener("longPress", this, false); @@ -216,7 +216,7 @@ var AbstractToggleButton = exports.AbstractToggleButton = AbstractControl.specia * @private */ handlePressStart: { - value: function(event) { + value: function (event) { this.active = true; if (event.touch) { @@ -232,7 +232,7 @@ var AbstractToggleButton = exports.AbstractToggleButton = AbstractControl.specia * @private */ handlePress: { - value: function(event) { + value: function (event) { this.active = false; if (!this.enabled) { @@ -246,7 +246,7 @@ var AbstractToggleButton = exports.AbstractToggleButton = AbstractControl.specia }, handleKeyPress: { - value: function(event) { + value: function (event) { this.active = false; if (!this.enabled) { @@ -259,7 +259,7 @@ var AbstractToggleButton = exports.AbstractToggleButton = AbstractControl.specia }, handleLongPress: { - value: function(event) { + value: function (event) { // When we fire the "longAction" event we don't want to fire the // "action" event as well. this._pressComposer.cancelPress(); @@ -275,20 +275,20 @@ var AbstractToggleButton = exports.AbstractToggleButton = AbstractControl.specia @private */ handlePressCancel: { - value: function(event) { + value: function (event) { this.active = false; document.removeEventListener("touchmove", this, false); } }, handleTouchmove: { - value: function(event) { + value: function (event) { event.preventDefault(); } }, _toggle: { - value: function() { + value: function () { this.pressed = !this.pressed; } }, @@ -302,7 +302,7 @@ var AbstractToggleButton = exports.AbstractToggleButton = AbstractControl.specia }, enterDocument: { - value: function(firstDraw) { + value: function (firstDraw) { if(firstDraw) { this.isInputElement = (this.originalElement.tagName === "INPUT"); @@ -320,12 +320,12 @@ var AbstractToggleButton = exports.AbstractToggleButton = AbstractControl.specia /** * Draws the label to the DOM. - * @method + * @function * @private */ _drawLabel: { enumerable: false, - value: function(value) { + value: function (value) { if (this.isInputElement) { this._element.setAttribute("value", value); } else if (this._labelNode) { @@ -335,7 +335,7 @@ var AbstractToggleButton = exports.AbstractToggleButton = AbstractControl.specia }, draw: { - value: function() { + value: function () { if (this.pressed) { this._drawLabel(this.pressedLabel); } else { diff --git a/ui/base/abstract-toggle-switch.js b/ui/base/abstract-toggle-switch.js index d5b573b909..5a020441a0 100644 --- a/ui/base/abstract-toggle-switch.js +++ b/ui/base/abstract-toggle-switch.js @@ -59,17 +59,17 @@ var AbstractToggleSwitch = exports.AbstractToggleSwitch = AbstractControl.specia * @type {boolean} */ enabled: { - get: function() { + get: function () { return this._enabled; }, - set: function(value) { + set: function (value) { this._enabled = value; this.needsDraw = true; } }, acceptsActiveTarget: { - value: function() { + value: function () { return this.enabled; } }, @@ -83,17 +83,17 @@ var AbstractToggleSwitch = exports.AbstractToggleSwitch = AbstractControl.specia }, checked: { - get: function() { + get: function () { return this._checked; }, - set: function(value) { + set: function (value) { this._checked = value; this.needsDraw = true; } }, prepareForActivationEvents: { - value: function() { + value: function () { this._pressComposer.addEventListener("press", this, false); } }, @@ -103,7 +103,7 @@ var AbstractToggleSwitch = exports.AbstractToggleSwitch = AbstractControl.specia * @private */ handlePress: { - value: function(event) { + value: function (event) { if(!this.enabled) { return; } @@ -114,7 +114,7 @@ var AbstractToggleSwitch = exports.AbstractToggleSwitch = AbstractControl.specia }, handleKeyup: { - value: function(event) { + value: function (event) { if(!this.enabled) { return; } @@ -128,14 +128,14 @@ var AbstractToggleSwitch = exports.AbstractToggleSwitch = AbstractControl.specia }, enterDocument: { - value: function(firstDraw) { + value: function (firstDraw) { this.element.setAttribute("role", "checkbox"); this.element.addEventListener("keyup", this, false); } }, draw: { - value: function() { + value: function () { this.element.setAttribute("aria-checked", this._checked); this.element.setAttribute("aria-disabled", !this._enabled); } diff --git a/ui/base/abstract-video.js b/ui/base/abstract-video.js index fbda576544..9a5fec0d21 100644 --- a/ui/base/abstract-video.js +++ b/ui/base/abstract-video.js @@ -114,7 +114,7 @@ var AbstractVideo = exports.AbstractVideo = Component.specialize(/** @lends Abst }, /** - * @method + * @function */ loadMedia: { value: function () { @@ -150,7 +150,7 @@ var AbstractVideo = exports.AbstractVideo = Component.specialize(/** @lends Abst }, /** - * @method + * @function */ toggleRepeat: { value: function () { @@ -176,7 +176,7 @@ var AbstractVideo = exports.AbstractVideo = Component.specialize(/** @lends Abst }, /** - * @method + * @function */ showPoster: { value: function () { @@ -210,7 +210,7 @@ var AbstractVideo = exports.AbstractVideo = Component.specialize(/** @lends Abst /** * Toggles full-screen playback mode. - * @method + * @function */ toggleFullScreen: { value: function () { diff --git a/ui/component.js b/ui/component.js index dcdd89f81a..31c96310f1 100644 --- a/ui/component.js +++ b/ui/component.js @@ -2,11 +2,15 @@ /** * @module montage/ui/component * @requires montage - * @requires montage/ui/template + * @requires montage/core/target + * @requires montage/core/template + * @requires montage/core/document-resources * @requires montage/core/gate - * @requires montage/core/logger | component - * @requires montage/core/logger | drawing + * @requires montage/core/promise + * @requires montage/core/logger * @requires montage/core/event/event-manager + * @requires montage/core/serialization/alias + * @requires collections/set */ var Montage = require("../core/core").Montage, Target = require("../core/target").Target, @@ -14,29 +18,33 @@ var Montage = require("../core/core").Montage, DocumentResources = require("../core/document-resources").DocumentResources, Gate = require("../core/gate").Gate, Promise = require("../core/promise").Promise, + defaultEventManager = require("../core/event/event-manager").defaultEventManager, + Alias = require("../core/serialization/alias").Alias, + logger = require("../core/logger").logger("component"), drawPerformanceLogger = require("../core/logger").logger("Drawing performance").color.green(), drawListLogger = require("../core/logger").logger("drawing list").color.blue(), needsDrawLogger = require("../core/logger").logger("drawing needsDraw").color.violet(), drawLogger = require("../core/logger").logger("drawing").color.blue(), - defaultEventManager = require("../core/event/event-manager").defaultEventManager, - Set = require("collections/set"), - Alias = require("../core/serialization/alias").Alias; -var ATTR_LE_COMPONENT="data-montage-le-component"; -var ATTR_LE_ARG="data-montage-le-arg"; -var ATTR_LE_ARG_BEGIN="data-montage-le-arg-begin"; -var ATTR_LE_ARG_END="data-montage-le-arg-end"; + Set = require("collections/set"); /** - * @requires montage/ui/component-description + * @const + * @default + * @type {string} */ +var ATTR_LE_COMPONENT = "data-montage-le-component", + ATTR_LE_ARG = "data-montage-le-arg", + ATTR_LE_ARG_BEGIN = "data-montage-le-arg-begin", + ATTR_LE_ARG_END = "data-montage-le-arg-end"; + /** * @class Component * @classdesc Base class for all Montage components. - * @extends Montage + * @extends Target */ -var Component = exports.Component = Target.specialize(/** @lends Component# */ { +var Component = exports.Component = Target.specialize( /** @lends Component.prototype # */ { DOM_ARG_ATTRIBUTE: {value: "data-arg"}, constructor: { @@ -65,7 +73,9 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * This property is populated by the template. It is a map of all the * instances present in the template's serialization keyed by their label. * - * @type {Object} + * @property {boolean} serializable + * @default false + * @property {object} value * @default null */ templateObjects: { @@ -73,6 +83,10 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { value: null }, + /** + * @private + * @property {Target} value + */ _nextTarget: { value: null }, @@ -87,7 +101,8 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * To interrupt the propagation path a Target that accepts a falsy * nextTarget needs to be set at a component's nextTarget. * - * @type {Target} + * @param {Target} value + * @returns {Target} */ nextTarget: { get: function () { @@ -119,7 +134,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * @private */ _dispatchActionEvent: { - value: function() { + value: function () { this.dispatchEvent(this.createActionEvent()); }, enumerable: false @@ -127,11 +142,11 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { /** * Convenience to create a custom event named "action" - * @method + * @function * @returns and event to dispatch upon interaction */ createActionEvent: { - value: function() { + value: function () { var actionEvent = document.createEvent("CustomEvent"); actionEvent.initCustomEvent("action", true, true, null); return actionEvent; @@ -144,7 +159,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * @private */ canDrawGate: { - get: function() { + get: function () { if (!this._canDrawGate) { this._canDrawGate = new Gate().initWithDelegate(this); this._canDrawGate.setField("componentTreeLoaded", false); @@ -165,7 +180,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { */ blockDrawGate: { enumerable: false, - get: function() { + get: function () { if (!this._blockDrawGate) { this._blockDrawGate = new Gate().initWithDelegate(this); this._blockDrawGate.setField("element", false); @@ -249,10 +264,10 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * @default null */ element: { - get: function() { + get: function () { return this._element; }, - set: function(value) { + set: function (value) { if (value == null) { console.warn("Tried to set element of ", this, " to ", value); return; @@ -300,7 +315,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, getElementId: { - value: function() { + value: function () { var element = this._element; if (element) { @@ -310,7 +325,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _initDomArguments: { - value: function() { + value: function () { var candidates, domArguments = {}, name, @@ -342,7 +357,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, getDomArgumentNames: { - value: function() { + value: function () { if (!this._domArgumentNames) { this._domArgumentNames = Object.keys(this._domArguments); } @@ -359,13 +374,13 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * When a DOM argument is extracted from a Component it is no longer * available * - * @method + * @function * @param {string} name The name of the argument, or `"*"` for the entire * content. * @returns the element */ extractDomArgument: { - value: function(name) { + value: function (name) { var argument; argument = this._domArguments[name]; @@ -384,7 +399,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * @private */ _getTemplateDomArgument: { - value: function(name) { + value: function (name) { var candidates, node, element, @@ -428,7 +443,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { */ getTemplateArgumentElement: { - value: function(argumentName) { + value: function (argumentName) { var template = this._ownerDocumentPart.template, element, range, @@ -464,7 +479,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, getTemplateArgumentSerialization: { - value: function(elementIds) { + value: function (elementIds) { var template = this._ownerDocumentPart.template; return template._createSerializationWithElementIds(elementIds); @@ -476,7 +491,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * @private */ resolveTemplateArgumentTemplateProperty: { - value: function(templatePropertyName) { + value: function (templatePropertyName) { var ix = templatePropertyName.indexOf(":"), componentLabel = templatePropertyName.slice(0, ix), propertyName = templatePropertyName.slice(ix), @@ -510,7 +525,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, setElementWithParentComponent: { - value: function(element, parent) { + value: function (element, parent) { this._alternateParentComponent = parent; if (this.element !== element) { this.element = element; @@ -525,7 +540,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { */ application: { enumerable: false, - get: function() { + get: function () { return require("../core/application").application; } }, @@ -536,7 +551,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { */ eventManager: { enumerable: false, - get: function() { + get: function () { return defaultEventManager; } }, @@ -547,19 +562,19 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { */ rootComponent: { enumerable: false, - get: function() { + get: function () { return rootComponent; } }, /** - * @method + * @function * @returns targetElementController * @private */ elementControllerFromEvent: { enumerable: false, - value: function(event, targetElementController) { + value: function (event, targetElementController) { return targetElementController; } }, @@ -576,11 +591,11 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _parentComponent: { - set: function(value) { + set: function (value) { this.__parentComponent = value; this.dispatchOwnPropertyChange("parentComponent", value); }, - get: function() { + get: function () { return this.__parentComponent; } }, @@ -597,13 +612,13 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { */ parentComponent: { enumerable: false, - get: function() { + get: function () { return this._parentComponent; } }, findParentComponent: { - value: function() { + value: function () { var anElement = this.element, aParentNode, eventManager = this.eventManager; @@ -617,7 +632,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, querySelectorComponent: { - value: function(selector) { + value: function (selector) { if (typeof selector !== "string") { throw "querySelectorComponent: Selector needs to be a string."; } @@ -674,7 +689,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, querySelectorAllComponent: { - value: function(selector, owner) { + value: function (selector, owner) { if (typeof selector !== "string") { throw "querySelectorComponent: Selector needs to be a string."; } @@ -769,12 +784,12 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { /** * @private * @deprecated - * @method + * @function * @param {Component} childComponent */ // TODO update all calls to use addChildComponent and remove this method. _addChildComponent: { - value: function(childComponent) { + value: function (childComponent) { return this.addChildComponent(childComponent); } }, @@ -795,7 +810,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, attachToParentComponent: { - value: function() { + value: function () { this.detachFromParentComponent(); this._parentComponent = null; @@ -823,7 +838,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, detachFromParentComponent: { - value: function() { + value: function () { var parentComponent = this.parentComponent; if (parentComponent) { @@ -833,7 +848,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, removeChildComponent: { - value: function(childComponent) { + value: function (childComponent) { var childComponents = this.childComponents, ix = childComponents.indexOf(childComponent); @@ -877,7 +892,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, __exitDocument: { - value: function() { + value: function () { if (this._inDocument && typeof this.exitDocument === "function") { this.exitDocument(); this._inDocument = false; @@ -886,7 +901,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _exitDocument: { - value: function() { + value: function () { var traverse; if (this._needsEnterDocument) { @@ -915,7 +930,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { /** * Lifecycle method called when this component is removed from the * document's DOM tree. - * @method + * @function */ exitDocument: { value: function () { @@ -926,14 +941,14 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _prepareForEnterDocument: { - value: function() { + value: function () { // On their first draw components will have their needsDraw = true // when they loadComponentTree. if (this._firstDraw) { this._needsEnterDocument = true; } else { this.needsDraw = true; - this.traverseComponentTree(function(component) { + this.traverseComponentTree(function (component) { if (component._needsEnterDocument) { return false; } @@ -981,11 +996,11 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { /** * Remove all bindings and starts buffering the needsDraw. - * @method + * @function * @private */ cleanupDeletedComponentTree: { - value: function(cancelBindings) { + value: function (cancelBindings) { // Deleting bindings in all cases was causing the symptoms expressed in gh-603 // Until we have a more granular way we shouldn't do this, // the cancelBindings parameter is a short term fix. @@ -993,7 +1008,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { this.cancelBindings(); } this.needsDraw = false; - this.traverseComponentTree(function(component) { + this.traverseComponentTree(function (component) { // See above comment if (cancelBindings) { component.cancelBindings(); @@ -1010,14 +1025,14 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { domContent: { serializable: false, - get: function() { + get: function () { if (this._element) { return Array.prototype.slice.call(this._element.childNodes, 0); } else { return null; } }, - set: function(value) { + set: function (value) { var components, componentsToAdd = [], i, @@ -1060,7 +1075,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _findAndDetachComponents: { - value: function(node, components) { + value: function (node, components) { // TODO: Check if searching the childComponents of the parent // component can make the search faster.. var component = node.component, @@ -1106,7 +1121,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { innerTemplate: { serializable: false, - get: function() { + get: function () { var innerTemplate = this._innerTemplate, ownerDocumentPart, ownerTemplate, @@ -1141,29 +1156,32 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { return innerTemplate; }, - set: function(value) { + set: function (value) { this._innerTemplate = value; } }, /** * This method is called right before draw is called. - * If ```canDraw()``` returns false, then the component is re-added to the parent's draw list and draw isn't called. - * @method - * @returns {boolean} true or false - * @private this method is evil + * If ```canDraw()``` returns false, then the component is re-added to + * the parent's draw list and draw isn't called. + * This method is evil + * + * @function + * @returns {boolean} + * @private */ canDraw: { - value: function() { + value: function () { return this._canDraw; } }, _canDraw: { - get: function() { + get: function () { return (!this._canDrawGate || this._canDrawGate.value); }, - set: function(value) { + set: function (value) { rootComponent.componentCanDraw(this, value); }, enumerable: false @@ -1183,7 +1201,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _updateOwnerCanDrawGate: { - value: function() { + value: function () { if (this._blocksOwnerComponentDraw && this.ownerComponent) { this.ownerComponent.canDrawGate.setField(this.uuid, this.canDrawGate.value); } @@ -1219,7 +1237,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { this._canDraw = false; } - this.expandComponent().then(function() { + this.expandComponent().then(function () { if (self.hasTemplate || self.shouldLoadComponentTree) { var promises = [], childComponents = self.childComponents, @@ -1231,7 +1249,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { return Promise.all(promises); } - }).then(function() { + }).then(function () { self._isComponentTreeLoaded = true; // When the component tree is loaded we need to draw if the // component needs to have its enterDocument() called. @@ -1252,7 +1270,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { /** * Whenever traverseComponentTree reaches the end of a subtree Component#expandComponent~callback is called. - * @method + * @function * @param {Component#traverseComponentTree~visitor} visitor visitor * @param {Component#traverseComponentTree~callback} callback callback object * @private @@ -1282,7 +1300,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { return; } - var visitorFunction = function() { + var visitorFunction = function () { if (--childLeftCount === 0 && callback) { callback(); } @@ -1302,16 +1320,16 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * Visitor function for Component#traverseComponentTree. For every component in the tree, the visitor function is * called with the current component as an argument. * If the function returns false then the traversal is stopped for that subtree. - * @method Component#traverseComponentTree~visitor + * @function Component#traverseComponentTree~visitor * @param Component visitedComponent */ /** - * @method Component#traverseComponentTree~callback + * @function Component#traverseComponentTree~callback */ /** - * @method + * @function * @param {Component#expandComponent~callback} callback TODO * @private */ @@ -1326,7 +1344,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { this._expandComponentDeferred = deferred; if (this.hasTemplate) { - this._instantiateTemplate().then(function() { + this._instantiateTemplate().then(function () { self._isComponentExpanded = true; self._addTemplateStyles(); self.needsDraw = true; @@ -1350,14 +1368,14 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _setupTemplateObjects: { - value: function(objects) { + value: function (objects) { this.templateObjects = Object.create(null); this._addTemplateObjects(objects); } }, _addTemplateObjects: { - value: function(objects) { + value: function (objects) { var descriptor = this._templateObjectDescriptor, templateObjects = this.templateObjects; @@ -1378,7 +1396,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _makeTemplateObjectGetter: { - value: function(owner, label, object) { + value: function (owner, label, object) { var querySelectorLabel = "@"+label, isRepeated, components, @@ -1423,9 +1441,9 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _instantiateTemplate: { - value: function() { + value: function () { var self = this; - return this._loadTemplate().then(function(template) { + return this._loadTemplate().then(function (template) { if (!self._element) { console.error("Cannot instantiate template without an element.", self); return Promise.reject(new Error("Cannot instantiate template without an element.", self)); @@ -1441,12 +1459,12 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { self._isTemplateInstantiated = true; return template.instantiateWithInstances(instances, _document) - .then(function(documentPart) { + .then(function (documentPart) { documentPart.parentDocumentPart = self._ownerDocumentPart; self._templateDocumentPart = documentPart; documentPart.fragment = null; }) - .fail(function(reason) { + .fail(function (reason) { var message = reason.stack || reason; console.error("Error in", template.getBaseUrl() + ":", message); throw reason; @@ -1456,7 +1474,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _templateDidLoad: { - value: function(documentPart) { + value: function (documentPart) { this._setupTemplateObjects(documentPart.objects); } }, @@ -1473,7 +1491,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { promise = this._loadTemplatePromise = Template.getTemplateWithModuleId( this.templateModuleId, info.require) - .then(function(template) { + .then(function (template) { self._template = template; self._isTemplateLoaded = true; @@ -1491,13 +1509,13 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * @default */ templateModuleId: { - get: function() { + get: function () { return this._templateModuleId || this._getDefaultTemplateModuleId(); } }, _getDefaultTemplateModuleId: { - value: function() { + value: function () { var templateModuleId, slashIndex, moduleId, @@ -1513,13 +1531,13 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, deserializedFromSerialization: { - value: function() { + value: function () { this.attachToParentComponent(); } }, _deserializedFromTemplate: { - value: function(owner, label, documentPart) { + value: function (owner, label, documentPart) { Montage.getInfoForObject(this).label = label; this._ownerDocumentPart = documentPart; @@ -1579,13 +1597,13 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { /** * Callback for the ```canDrawGate```. * Propagates to the parent and adds the component to the draw list. - * @method + * @function * @param {Gate} gate * @see Component#canDrawGate * @private */ gateDidBecomeTrue: { - value: function(gate) { + value: function (gate) { if (gate === this._canDrawGate) { this._canDraw = true; this._updateOwnerCanDrawGate(); @@ -1598,7 +1616,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, gateDidBecomeFalse: { - value: function(gate) { + value: function (gate) { if (gate === this._canDrawGate) { this._updateOwnerCanDrawGate(); } @@ -1609,7 +1627,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { /** * Gate that controls the _canDraw property. When it becomes true it sets * _canDraw to true. - * @method + * @function * @returns Gate * @private */ @@ -1632,7 +1650,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _getArray: { - value: function() { + value: function () { if (this._arrayObjectPool.pool == null) { this._arrayObjectPool.pool = []; for (var i = 0; i < this._arrayObjectPool.size; i++) { @@ -1649,7 +1667,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _disposeArray: { - value: function(array) { + value: function (array) { if (this._arrayObjectPool.ix > 0) { array.length = 0; this._arrayObjectPool.pool[--this._arrayObjectPool.ix] = array; @@ -1714,7 +1732,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _updateComponentDom: { - value: function() { + value: function () { var component, composer, length, i; if (this._firstDraw) { @@ -1746,7 +1764,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { _replaceElementWithTemplate: { enumerable: false, - value: function() { + value: function () { var element = this.element, template = this._templateElement, attributes = this.element.attributes, @@ -1805,7 +1823,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _addTemplateStyles: { - value: function() { + value: function () { var part = this._templateDocumentPart, resources, styles, @@ -1848,7 +1866,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _leTagArguments: { - value: function() { + value: function () { //jshint -W106 var ownerModuleId = this.ownerComponent._montage_metadata.moduleId; var label = this._montage_metadata.label; @@ -1866,7 +1884,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _getNodeFirstElement: { - value: function(node) { + value: function (node) { var element = node.firstElementChild; if (!element) { @@ -1883,7 +1901,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _getNodeLastElement: { - value: function(node) { + value: function (node) { var element = node.lastElementChild; if (!element) { @@ -1900,7 +1918,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _leTagStarArgument: { - value: function(ownerModuleId, label, rootElement) { + value: function (ownerModuleId, label, rootElement) { var argumentBegin = this._getNodeFirstElement(rootElement); var argumentEnd = this._getNodeLastElement(rootElement); @@ -1914,14 +1932,14 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _leTagNamedArgument: { - value: function(ownerModuleId, label, element, name) { + value: function (ownerModuleId, label, element, name) { element.setAttribute(ATTR_LE_ARG, ownerModuleId + "," + label + "," + name); } }, _bindTemplateParametersToArguments: { - value: function() { + value: function () { var parameters = this._templateDocumentPart.parameters, parameter, templateArguments, @@ -1967,7 +1985,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _validateTemplateArguments: { - value: function(templateArguments, templateParameters) { + value: function (templateArguments, templateParameters) { var parameterNames = Object.keys(templateParameters), argumentNames, param; @@ -2019,7 +2037,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * * The component can implement this method to add event listeners for these * events before they are dispatched. - * @method + * @function */ prepareForActivationEvents: { enumerable: false, @@ -2032,7 +2050,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * @private */ _prepareForActivationEvents: { - value: function() { + value: function () { var i = this.composerList.length, composer; for (i = 0; i < this.composerList.length; i++) { composer = this.composerList[i]; @@ -2047,7 +2065,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _performDomContentChanges: { - value: function() { + value: function () { var contents = this._newDomContent, oldContent = this._element.childNodes[0], childNodesCount, @@ -2094,12 +2112,12 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * Components should not read the DOM during this phase of the draw cycle * as it could force an unwanted reflow from the browser. * - * @method + * @function * @see http://montagejs.org/docs/Component-draw-cycle.html */ draw: { enumerable: false, - value: function() { + value: function () { } }, @@ -2113,7 +2131,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * Components should not change the DOM during this phase of the draw cycle * as it could force an unwanted reflow from the browser. * - * @method + * @function * @see http://montagejs.org/docs/Component-draw-cycle.html */ willDraw: { @@ -2131,12 +2149,12 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * Components should not change the DOM during this phase of the draw cycle * as it could force an unwanted reflow from the browser. * - * @method + * @function * @see http://montagejs.org/docs/Component-draw-cycle.html */ didDraw: { enumerable: false, - value: function() { + value: function () { } }, @@ -2150,7 +2168,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { _addToParentsDrawList: { enumerable: false, - value: function() { + value: function () { if (!this._addedToDrawList) { var parentComponent = this.parentComponent; @@ -2196,10 +2214,10 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { */ needsDraw: { enumerable: false, - get: function() { + get: function () { return !!this._needsDraw; }, - set: function(value) { + set: function (value) { if (this.isDeserializing) { // Ignore needsDraw(s) which happen during deserialization this._needsDrawInDeserialization = true; @@ -2233,7 +2251,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { __addToDrawList: { enumerable: false, - value: function(childComponent) { + value: function (childComponent) { if (this._drawList === null) { this._drawList = [childComponent]; childComponent._addedToDrawList = true; @@ -2253,7 +2271,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { */ _addToDrawList: { enumerable: false, - value: function(childComponent) { + value: function (childComponent) { this.__addToDrawList(childComponent); this._addToParentsDrawList(); } @@ -2281,7 +2299,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * The demandingComponent is responsible for claiming the surrendered * pointer if it desires. * - * @method + * @function * @param {string} pointer The `pointerIdentifier` that the demanding * component is asking this component to surrender * @param {Object} demandingComponent The component that is asking this @@ -2289,7 +2307,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * @returns {boolean} true */ surrenderPointer: { - value: function(pointer, demandingComponent) { + value: function (pointer, demandingComponent) { return true; } }, @@ -2307,11 +2325,11 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { /** * Adds the passed in composer to the component's composer list. - * @method + * @function * @param {Composer} composer */ addComposer: { // What if the same composer instance is added to more than one component? - value: function(composer) { + value: function (composer) { this.addComposerForElement(composer, composer.element); } }, @@ -2319,12 +2337,12 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { /** * Adds the passed in composer to the component's composer list and * sets the element of the composer to the passed in element. - * @method + * @function * @param {Composer} composer * @param {Element} element */ addComposerForElement: { - value: function(composer, element) { + value: function (composer, element) { composer.component = this; composer.element = element; this.composerList.push(composer); @@ -2343,11 +2361,11 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * Adds the passed in composer to the list of composers which will have their * frame method called during the next draw cycle. It causes a draw cycle to be scheduled * iff one has not already been scheduled. - * @method + * @function * @param {Composer} composer */ scheduleComposer: { - value: function(composer) { + value: function (composer) { this.rootComponent.addToComposerList(composer); } }, @@ -2355,11 +2373,11 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { /** * Removes the passed in composer from this component's composer list. It takes care * of calling the composers unload method before removing it from the list. - * @method + * @function * @param {Composer} composer */ removeComposer: { - value: function(composer) { + value: function (composer) { var i, length; length = this.composerList.length; for (i = 0; i < length; i++) { @@ -2375,10 +2393,10 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { /** * A convenience method for removing all composers from a component. This method * is responsible for calling unload on each composer before removing it. - * @method + * @function */ clearAllComposers: { - value: function() { + value: function () { var i, length, composerList = this.composerList; length = composerList.length; for (i = 0; i < length; i++) { @@ -2416,7 +2434,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * exports.Main = Component.specialize( { * * constructor: { - * value: function() { + * value: function () { * this.localizer = defaultLocalizer; * this.waitForLocalizerMessages = true; * } @@ -2426,14 +2444,14 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * * // no draw happens until the localizer's messages have been loaded * enterDocument: { - * value: function(firstTime) { + * value: function (firstTime) { * if (firstTime) { * this._greeting = _("hello", "Hello {name}!"); * } * } * }, * draw: { - * value: function() { + * value: function () { * // this is for illustration only. This example is simple enough that * // you should use a localizations binding * this._element.textContent = this._greeting({name: this.name}); @@ -2443,10 +2461,10 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { */ waitForLocalizerMessages: { enumerable: false, - get: function() { + get: function () { return this._waitForLocalizerMessages; }, - set: function(value) { + set: function (value) { if (this._waitForLocalizerMessages !== value) { if (value === true && !this.localizer.messages) { if (!this.localizer) { @@ -2459,7 +2477,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { logger.debug(this, "waiting for messages from localizer"); this.canDrawGate.setField("messages", false); - this.localizer.messagesPromise.then(function(messages) { + this.localizer.messagesPromise.then(function (messages) { if (logger.isDebug) { logger.debug(self, "got messages from localizer"); } @@ -2495,7 +2513,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { _getElementAttributeDescriptor: { - value: function(attributeName) { + value: function (attributeName) { var attributeDescriptor, instance = this; // walk up the prototype chain from the instance to NativeControl's prototype // if _elementAttributeDescriptors is falsy, stop. @@ -2522,13 +2540,13 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * For example, if the name "title" is passed as the first parameter, a * "title" accessor property is created as well a data property named * "_title". - * @method + * @function * @param {string} name The property name to add. * @param {Object} descriptor An object that specifies the new properties default attributes such as configurable and enumerable. * @private */ defineAttribute: { - value: function(name, descriptor) { + value: function (name, descriptor) { descriptor = descriptor || {}; var _name = '_' + name; @@ -2536,8 +2554,8 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { var newDescriptor = { configurable: (typeof descriptor.configurable === 'undefined') ? true: descriptor.configurable, enumerable: (typeof descriptor.enumerable === 'undefined') ? true: descriptor.enumerable, - set: (function(name, attributeName) { - return function(value) { + set: (function (name, attributeName) { + return function (value) { var descriptor = this._getElementAttributeDescriptor(name, this); // if requested dataType is boolean (eg: checked, readonly etc) @@ -2560,8 +2578,8 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { } }; }(name, _name)), - get: (function(name, attributeName) { - return function() { + get: (function (name, attributeName) { + return function () { return this[attributeName]; }; }(name, _name)) @@ -2577,12 +2595,12 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { /** * Add the specified properties as properties of this component. - * @method + * @function * @param {object} properties An object that contains the properties you want to add. * @private */ addAttributes: { - value: function(properties) { + value: function (properties) { var i, descriptor, property, object; this.prototype._elementAttributeDescriptors = properties; @@ -2611,7 +2629,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * This function is called when the component element is added to the * document's DOM tree. * - * @method Component#enterDocument + * @function Component#enterDocument * @param {boolean} firstTime `true` if it's the first time the component * enters the document. */ @@ -2619,7 +2637,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { // callbacks _enterDocument: { - value: function(firstTime) { + value: function (firstTime) { var originalElement; if (firstTime) { @@ -2689,7 +2707,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, _draw: { - value: function() { + value: function () { var element = this.element, descriptor; for(var attributeName in this._elementAttributeValues) { @@ -2728,6 +2746,10 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { } }, + /** + * @property {Set} value + * @private + */ _classList: { value: null }, @@ -2742,11 +2764,12 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * * It can also be bound to by binding each class as a property. * example to toggle the complete class: + * * ```json * "classList.has('complete')" : { "<-" : "@owner.isComplete"} * ``` - * @type {Set} - * @default null + * + * @returns {Set} */ classList: { get: function () { @@ -2759,8 +2782,11 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { } }, + /** + * @private + */ _initializeClassListFromElement: { - value: function(element) { + value: function (element) { if (element && element.classList && element.classList.length > 0) { // important to initializae the classList first, so that the listener doesn't get installed. var classList = this.classList; @@ -2775,12 +2801,18 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { } }, + /** + * @private + */ _unsubscribeToClassListChanges: { value: null }, + /** + * @private + */ _subscribeToToClassListChanges: { - value: function() { + value: function () { this._unsubscribeToClassListChanges = this._classList.addRangeChangeListener(this, "classList"); } }, @@ -2816,7 +2848,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { }, dispose: { - value: function() { + value: function () { this.cancelBindings(); this.detachFromParentComponent(); if (this._element) { @@ -2824,7 +2856,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { this._element = null; } - this.childComponents.forEach(function(component) { + this.childComponents.forEach(function (component) { component.dispose(); }); } @@ -2836,7 +2868,7 @@ var Component = exports.Component = Target.specialize(/** @lends Component# */ { * @class RootComponent * @extends Component */ -var RootComponent = Component.specialize( /** @lends RootComponent# */{ +var RootComponent = Component.specialize( /** @lends RootComponent.prototype # */{ constructor: { value: function RootComponent() { this.super(); @@ -2847,21 +2879,21 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ /** * @private - * @method + * @function * @returns itself */ init: { - value: function() { + value: function () { return this; } }, needsDraw: { enumerable: true, - get: function() { + get: function () { return false; }, - set: function(value) { + set: function (value) { if (this._needsDraw !== value) { this._needsDraw = !!value; if (value) { @@ -2880,7 +2912,7 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ }, canDrawGate: { - get: function() { + get: function () { return this._canDrawGate || (this._canDrawGate = new Gate().initWithDelegate(this)); } }, @@ -2898,11 +2930,11 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ }, /** - * @method + * @function * @param {Object} component */ componentBlockDraw: { - value: function(component) { + value: function (component) { this._cannotDrawList = (this._cannotDrawList ? this._cannotDrawList : {}); this._cannotDrawList[component.uuid] = component; if (this._clearNeedsDrawTimeOut) { @@ -2914,19 +2946,19 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ // TODO: implement this with a flag on the component isComponentWaitingNeedsDraw: { - value: function(component) { + value: function (component) { return component.uuid in this._cannotDrawList || this._needsDrawList.indexOf(component) >= 0; } }, /** - * @method + * @function * @param {Object} component * @param {number} value */ componentCanDraw: { - value: function(component, value) { + value: function (component, value) { if (value) { if (!this._cannotDrawList) { return; @@ -2937,7 +2969,7 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ if (!this._clearNeedsDrawTimeOut) { var self = this; // Wait to clear the needsDraw list as components could be loaded synchronously - this._clearNeedsDrawTimeOut = window.setTimeout(function() { + this._clearNeedsDrawTimeOut = window.setTimeout(function () { self._clearNeedsDrawList(); }, 0); } @@ -2952,7 +2984,7 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ }, _clearNeedsDrawList: { - value: function() { + value: function () { var component, i, length, needsDrawList = this._needsDrawList; length = needsDrawList.length; for (i = 0; i < length; i++) { @@ -2965,16 +2997,16 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ } } this._clearNeedsDrawTimeOut = null; - needsDrawList.length = 0; + needsDrawList.length = 0; } }, /** - * @method + * @function * @param {Component} componentId */ removeFromCannotDrawList: { - value: function(component) { + value: function (component) { if (!this._cannotDrawList) { return; } @@ -2984,7 +3016,7 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ if (Object.keys(this._cannotDrawList).length === 0 && this._needsDrawList.length > 0) { if (!this._clearNeedsDrawTimeOut) { var self = this; - this._clearNeedsDrawTimeOut = window.setTimeout(function() { + this._clearNeedsDrawTimeOut = window.setTimeout(function () { self._clearNeedsDrawList(); }, 0); } @@ -2993,7 +3025,7 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ }, _cancelDrawIfScheduled: { - value: function() { + value: function () { var requestedAnimationFrame = this.requestedAnimationFrame, cancelAnimationFrame = this.cancelAnimationFrame; if (requestedAnimationFrame !== null) { @@ -3017,7 +3049,7 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ * @private */ _addToDrawList: { - value: function(childComponent) { + value: function (childComponent) { this.__addToDrawList(childComponent); if (drawListLogger.isDebug) { drawListLogger.debug(this, this.canDrawGate.value, this.requestedAnimationFrame); @@ -3031,11 +3063,11 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ * Adds the passed in composer to the list of composers to be executed * in the next draw cycle and requests a draw cycle if one has not been * requested yet. - * @method + * @function * @param {Composer} composer */ addToComposerList: { - value: function(composer) { + value: function (composer) { this.composerList.push(composer); if (drawLogger.isDebug) { drawLogger.debug(this, composer, "Added to composer list"); @@ -3076,7 +3108,7 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ /** * @private - * @method + * @function */ requestAnimationFrame: { value: (window.requestAnimationFrame || window.webkitRequestAnimationFrame @@ -3086,7 +3118,7 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ /** * @private - * @method + * @function */ cancelAnimationFrame: { value: (window.cancelAnimationFrame || window.webkitCancelAnimationFrame @@ -3114,7 +3146,7 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ _diff: { // Written by John Resig. Used under the Creative Commons Attribution 2.5 License. // http://ejohn.org/projects/javascript-diff-algorithm/ - value: function( o, n ) { + value: function ( o, n ) { var ns = {}; var os = {}; @@ -3195,10 +3227,10 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ }, /** - * @private + * @function */ addStylesheet: { - value: function(style) { + value: function (style) { this._stylesheets.push(style); this._needsStylesheetsDraw = true; } @@ -3208,7 +3240,7 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ * @private */ drawStylesheets: { - value: function() { + value: function () { var documentResources = this._documentResources, stylesheets = this._stylesheets, stylesheet; @@ -3248,7 +3280,7 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ }, _drawTree: { - value: function(timestamp) { + value: function (timestamp) { var drawPerformanceStartTime; // Add all stylesheets needed by the components since last @@ -3310,10 +3342,11 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ this.drawIfNeeded(); if (drawPerformanceLogger.isDebug) { + var drawPerformanceEndTime; if (window.performance) { - var drawPerformanceEndTime = window.performance.now(); + drawPerformanceEndTime = window.performance.now(); } else { - var drawPerformanceEndTime = Date.now(); + drawPerformanceEndTime = Date.now(); } console.log("Draw Cycle Time: ", @@ -3349,11 +3382,11 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ }, /** - * @method + * @function * @param {Component} component Component to add */ addToDrawCycle: { - value: function(component) { + value: function (component) { var needsDrawListIndex = this._readyToDrawListIndex, length, composer; if (needsDrawListIndex.hasOwnProperty(component.uuid)) { @@ -3378,14 +3411,14 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ }, _sortByLevel: { - value: function(component1, component2) { + value: function (component1, component2) { return component1._treeLevel - component2._treeLevel; } }, /** * @private - * @method + * @function * @returns Boolean true if all the components that needed to draw have drawn */ drawIfNeeded:{ @@ -3497,10 +3530,10 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ * @default null */ element: { - get:function() { + get:function () { return this._element; }, - set:function(value) { + set:function (value) { defaultEventManager.registerEventHandlerForElement(this, value); this._element = value; this._documentResources = DocumentResources.getInstanceForDocument(value); @@ -3509,9 +3542,7 @@ var RootComponent = Component.specialize( /** @lends RootComponent# */{ }); var rootComponent = new RootComponent().init(); -//if(window.parent && window.parent.jasmine) { exports.__root__ = rootComponent; -//} function loggerToString (object) { if (!object) return "NIL"; diff --git a/ui/condition.reel/condition.js b/ui/condition.reel/condition.js index 700f035c78..145c27f094 100644 --- a/ui/condition.reel/condition.js +++ b/ui/condition.reel/condition.js @@ -1,5 +1,5 @@ /** - * @module montage/ui/condition.reel + * @module "montage/ui/condition.reel" */ var Component = require("../component").Component, logger = require("../../core/logger").logger("condition"); @@ -13,13 +13,13 @@ var Component = require("../component").Component, * condition will remove its content from the DOM but * [removalStrategy]{@link Condition#removalStrategy} can be changed to alter * this behavior. - * + * * @class Condition * @classdesc A component that shows or hides its inner template in response to * changes to some condition. * @extends Component */ -exports.Condition = Component.specialize( /** @lends Condition# */ { +exports.Condition = Component.specialize( /** @lends Condition.prototype # */ { hasTemplate: { value: false @@ -33,6 +33,9 @@ exports.Condition = Component.specialize( /** @lends Condition# */ { value: null }, + /** + * @constructs Condition + */ constructor: { value: function Condition() { this.super(); @@ -44,11 +47,11 @@ exports.Condition = Component.specialize( /** @lends Condition# */ { * visible (`true`) or hidden (`false`). * `null` is equivalent to `false`. * - * @type {boolean} + * @returns {boolean} * @default null */ condition: { - set: function(value) { + set: function (value) { if (value === this._condition) { return; @@ -61,13 +64,13 @@ exports.Condition = Component.specialize( /** @lends Condition# */ { this._updateDomContent(value); } }, - get: function() { + get: function () { return this._condition; } }, _updateDomContent: { - value: function(value) { + value: function (value) { if (this.removalStrategy === "remove") { if (value) { this.domContent = this._contents; @@ -80,7 +83,7 @@ exports.Condition = Component.specialize( /** @lends Condition# */ { }, deserializedFromTemplate: { - value: function() { + value: function () { // update the DOM if the condition is false because we're preventing // changes at deserialization time. if (!this._condition) { @@ -103,18 +106,18 @@ exports.Condition = Component.specialize( /** @lends Condition# */ { * the DOM. * * A value of `hide` will make the condition hide its contents through CSS - * using the `montage-invisible` class while keeping them on the DOM. Apps using - * `hide` should declare the `montage-invisible` class + * using the `montage-invisible` class while keeping them on the DOM. Apps using + * `hide` should declare the `montage-invisible` class * which will be applied to elements. - * + * * Example: - * + * * ```css * .montage-invisible { * display: none; * } * ``` - * + * * Possible values are `remove`, `hide`. * * @type {string} @@ -141,7 +144,7 @@ exports.Condition = Component.specialize( /** @lends Condition# */ { }, draw: { - value: function() { + value: function () { if (this.condition) { this.element.classList.remove("montage-invisible"); diff --git a/ui/flow.reel/flow-translate-composer.js b/ui/flow.reel/flow-translate-composer.js index 0dc3292f36..aba0621ddb 100644 --- a/ui/flow.reel/flow-translate-composer.js +++ b/ui/flow.reel/flow-translate-composer.js @@ -101,7 +101,7 @@ var FlowTranslateComposer = exports.FlowTranslateComposer = TranslateComposer.sp /** */ _start: { - value: function(x, y, target, timeStamp) { + value: function (x, y, target, timeStamp) { this._superStart(x, y, target, timeStamp); // TODO: Review using getComputedStyle outside draw cycle @@ -129,7 +129,7 @@ var FlowTranslateComposer = exports.FlowTranslateComposer = TranslateComposer.sp /** */ _analyzeMovement: { - value: function(event) { + value: function (event) { var velocity = event.velocity, speed, dX, dY; @@ -153,7 +153,7 @@ var FlowTranslateComposer = exports.FlowTranslateComposer = TranslateComposer.sp /** */ _dispatchTranslateStart: { - value: function(x, y) { + value: function (x, y) { var translateStartEvent = document.createEvent("CustomEvent"); translateStartEvent.initCustomEvent("translateStart", true, true, null); @@ -169,7 +169,7 @@ var FlowTranslateComposer = exports.FlowTranslateComposer = TranslateComposer.sp /** */ _dispatchTranslateEnd: { - value: function() { + value: function () { var translateEndEvent = document.createEvent("CustomEvent"); translateEndEvent.initCustomEvent("translateEnd", true, true, null); @@ -182,7 +182,7 @@ var FlowTranslateComposer = exports.FlowTranslateComposer = TranslateComposer.sp }, _dispatchTranslateCancel: { - value: function() { + value: function () { var translateCancelEvent = document.createEvent("CustomEvent"); translateCancelEvent.initCustomEvent("translateCancel", true, true, null); @@ -198,7 +198,7 @@ var FlowTranslateComposer = exports.FlowTranslateComposer = TranslateComposer.sp /** */ _dispatchTranslate: { - value: function() { + value: function () { var translateEvent = document.createEvent("CustomEvent"); translateEvent.initCustomEvent("translate", true, true, null); translateEvent.scroll = this._scroll; @@ -213,7 +213,7 @@ var FlowTranslateComposer = exports.FlowTranslateComposer = TranslateComposer.sp /** */ _move: { - value: function(x, y) { + value: function (x, y) { var pointerDelta; if (this._isFirstMove) { @@ -292,7 +292,7 @@ var FlowTranslateComposer = exports.FlowTranslateComposer = TranslateComposer.sp /** */ handleWheel: { - value: function(event) { + value: function (event) { var self = this; // If this composers' component is claiming the "wheel" pointer then handle the event @@ -311,7 +311,7 @@ var FlowTranslateComposer = exports.FlowTranslateComposer = TranslateComposer.sp } } } - this._mousewheelStrideTimeout = window.setTimeout(function() { + this._mousewheelStrideTimeout = window.setTimeout(function () { self._mousewheelStrideTimeout = null; self._previousDeltaY = 0; }, 70); @@ -327,7 +327,7 @@ var FlowTranslateComposer = exports.FlowTranslateComposer = TranslateComposer.sp this._updateScroll(); this._dispatchTranslate(); window.clearTimeout(this._translateEndTimeout); - this._translateEndTimeout = window.setTimeout(function() { + this._translateEndTimeout = window.setTimeout(function () { self._dispatchTranslateEnd(); self._translateEndTimeout = null; }, 400); @@ -433,7 +433,7 @@ var FlowTranslateComposer = exports.FlowTranslateComposer = TranslateComposer.sp /** */ frame: { - value: function(timestamp) { + value: function (timestamp) { if (this.isAnimating) { this._animationInterval(); } diff --git a/ui/flow.reel/flow.js b/ui/flow.reel/flow.js index 213dced7b6..7a6adecd6d 100644 --- a/ui/flow.reel/flow.js +++ b/ui/flow.reel/flow.js @@ -1,3 +1,6 @@ +/** + * @module "montage/ui/flow.reel" + */ var Montage = require("../../core/core").Montage, Component = require("../component").Component, observeProperty = require("frb/observers").observeProperty, @@ -10,8 +13,10 @@ var deprecationWarning = require("../../core/deprecate").deprecationWarning; * @class Flow * @extends Component */ -var Flow = exports.Flow = Component.specialize( /** @lends Flow# */ { - +var Flow = exports.Flow = Component.specialize( /** @lends Flow.prototype # */ { + /** + * @constructs Flow + */ constructor: { value: function Flow() { this.super(); @@ -1167,7 +1172,7 @@ var Flow = exports.Flow = Component.specialize( /** @lends Flow# */ { }, _determineCssPrefixedProperties: { - value: function() { + value: function () { if("webkitTransform" in this.element.style) { this._transform = "webkitTransform"; this._transformCss = "-webkit-transform"; @@ -1773,7 +1778,7 @@ var Flow = exports.Flow = Component.specialize( /** @lends Flow# */ { // TODO remove, will be obsoleted by inner template, provided we have a way // to redraft the innter template with a wrapper node. templateDidLoad: { - value: function() { + value: function () { var self = this; // TODO consider a two-way binding on needsDraw this._repetition.willDraw = function () { @@ -2139,7 +2144,7 @@ var Flow = exports.Flow = Component.specialize( /** @lends Flow# */ { }, serializeSelf: { - value: function(serializer) { + value: function (serializer) { serializer.setAllProperties(); // TODO: we need a way to add nodes to the serialization... we only diff --git a/ui/label.reel/label.js b/ui/label.reel/label.js index 800a231fe7..46676becad 100644 --- a/ui/label.reel/label.js +++ b/ui/label.reel/label.js @@ -1,3 +1,6 @@ +/** + * @module "montage/ui/label.reel" + */ var Montage = require("../../core/core").Montage, Text = require("../text.reel/text").Text, PressComposer = require("../../composer/press-composer").PressComposer; @@ -11,7 +14,7 @@ var Montage = require("../../core/core").Montage, var Label = exports.Label = Text.specialize({ constructor: { - value: function() { + value: function () { this.super(); this._pressComposer = new PressComposer(); this.addComposer(this._pressComposer); @@ -19,7 +22,7 @@ var Label = exports.Label = Text.specialize({ }, prepareForActivationEvents: { - value: function() { + value: function () { this.super(); this._pressComposer.addEventListener("press", this, false); } @@ -38,11 +41,11 @@ var Label = exports.Label = Text.specialize({ }, handlePress: { - value: function(event) { + value: function (event) { this.super(event); if(this.target && typeof this.target[this.action] == "function") { this.target[this.action]({ from: this }); } } }, -}); \ No newline at end of file +}); diff --git a/ui/loader.reel/loader.js b/ui/loader.reel/loader.js index 0dd4a79775..a9c8856ff3 100644 --- a/ui/loader.reel/loader.js +++ b/ui/loader.reel/loader.js @@ -1,7 +1,6 @@ - /** - @module montage/ui/loader +/** + * @module "montage/ui/loader.reel" */ - var Montage = require("../../core/core").Montage, Component = require("../component").Component, logger = require("../../core/logger").logger("loader"), @@ -11,8 +10,14 @@ var Montage = require("../../core/core").Montage, MONTAGE_LOADER_ELEMENT_ID = "montage-app-loader", BOOTSTRAPPING_CLASS_NAME = "montage-app-bootstrapping", LOADING_CLASS_NAME = "montage-app-loading", - LOADED_CLASS_NAME = "montage-app-loaded", - PRELOADING = 0, + LOADED_CLASS_NAME = "montage-app-loaded"; + +/** + * @const + * @type {number} + * @default + */ +var PRELOADING = 0, BOOTSTRAPPING = 1, LOADING = 2, LOADED = 3; @@ -21,9 +26,10 @@ var Montage = require("../../core/core").Montage, @class Loader @extends Component */ - -exports.Loader = Component.specialize( /** @lends Loader# */ { - +exports.Loader = Component.specialize( /** @lends Loader.prototype # */ { + /** + * @constructs Loader + */ constructor: { value: function Loader() { this.super(); @@ -76,14 +82,14 @@ exports.Loader = Component.specialize( /** @lends Loader# */ { initializedModules: { dependencies: ["includeFrameworkModules"], enumerable: false, - get: function() { + get: function () { if (!this._initializedModules || this.includeFrameworkModules) { return this._initializedModules; } else { return this._initializedModules.slice(this._frameworkModuleCount - 1); } }, - set: function(value) { + set: function (value) { this._initializedModules = value; } }, @@ -97,14 +103,14 @@ exports.Loader = Component.specialize( /** @lends Loader# */ { requiredModules: { dependencies: ["includeFrameworkModules"], enumerable: false, - get: function() { + get: function () { if (!this._requiredModules || this.includeFrameworkModules) { return this._requiredModules; } else { return this._requiredModules.slice(this._frameworkModuleCount - 1); } }, - set: function(value) { + set: function (value) { this._requiredModules = value; } }, @@ -118,10 +124,10 @@ exports.Loader = Component.specialize( /** @lends Loader# */ { /** */ currentStage: { - get: function() { + get: function () { return this._currentStage; }, - set: function(value) { + set: function (value) { if (value === this._currentStage) { return; } @@ -150,10 +156,10 @@ exports.Loader = Component.specialize( /** @lends Loader# */ { /** */ readyToShowLoader: { - get: function() { + get: function () { return this._readyToShowLoader; }, - set: function(value) { + set: function (value) { if (value !== this._readyToShowLoader) { return; } @@ -167,7 +173,7 @@ exports.Loader = Component.specialize( /** @lends Loader# */ { * Specifies whether the main component is ready to be displayed. */ readyToShowMainComponent: { - get: function() { + get: function () { return !!this._mainComponent; } }, @@ -205,7 +211,7 @@ exports.Loader = Component.specialize( /** @lends Loader# */ { // Implementation templateDidLoad: { - value: function() { + value: function () { if (logger.isDebug) { logger.debug(this, "templateDidLoad"); @@ -239,7 +245,7 @@ exports.Loader = Component.specialize( /** @lends Loader# */ { if (logger.isDebug) { logger.debug(this, "still need to show bootstrapper for another " + remainingBootstrappingDelay + "ms"); } - this._showLoadingTimeout = setTimeout(function() { + this._showLoadingTimeout = setTimeout(function () { self._revealLoader(); }, remainingBootstrappingDelay); } else { @@ -256,7 +262,7 @@ exports.Loader = Component.specialize( /** @lends Loader# */ { }, _revealLoader: { - value: function() { + value: function () { if (logger.isDebug) { logger.debug(this, "_revealLoader"); @@ -286,7 +292,7 @@ exports.Loader = Component.specialize( /** @lends Loader# */ { }, _revealMainComponent: { - value: function() { + value: function () { if (logger.isDebug) { logger.debug(this, "_revealMainComponent"); } @@ -295,7 +301,7 @@ exports.Loader = Component.specialize( /** @lends Loader# */ { }, _loadMainComponent: { - value: function() { + value: function () { if (logger.isDebug) { logger.debug(this, "_loadMainComponent"); } @@ -313,7 +319,7 @@ exports.Loader = Component.specialize( /** @lends Loader# */ { }, _mainLoadedCallback: { - value: function(exports) { + value: function (exports) { if (logger.isDebug) { logger.debug(this, "_mainLoadedCallback"); } @@ -331,7 +337,7 @@ exports.Loader = Component.specialize( /** @lends Loader# */ { }, mainComponentEnterDocument: { - value: function() { + value: function () { var self = this, insertionElement; @@ -441,7 +447,7 @@ exports.Loader = Component.specialize( /** @lends Loader# */ { /** * Specifies whether to remove the loading content when load is completed. - * @type {boolean} + * @property {boolean} value * @default true */ removeContentOnLoad: { @@ -462,14 +468,14 @@ exports.Loader = Component.specialize( /** @lends Loader# */ { * Forces a manual removal of loading content. */ removeContent: { - value: function() { + value: function () { this._forceContentRemoval = true; this.needsDraw = true; } }, draw: { - value: function() { + value: function () { // start loading the mainComponent if we haven't already if (!this.readyToShowMainComponent && !this.isLoadingMainComponent) { if (logger.isDebug) { diff --git a/ui/modal-overlay.reel/modal-overlay.js b/ui/modal-overlay.reel/modal-overlay.js index 482337e5ed..0b0fe3434e 100644 --- a/ui/modal-overlay.reel/modal-overlay.js +++ b/ui/modal-overlay.reel/modal-overlay.js @@ -1,5 +1,5 @@ /** - * @module ui/modal-overlay.reel + * @module "ui/modal-overlay.reel" */ var Overlay = require("../overlay.reel").Overlay, Promise = require("../../core/promise").Promise; @@ -8,10 +8,12 @@ var CLASS_PREFIX = "montage-ModalOverlay"; /** * @class ModalOverlay - * @extends Component + * @extends Overlay */ -exports.ModalOverlay = Overlay.specialize(/** @lends ModalOverlay# */ { - +exports.ModalOverlay = Overlay.specialize(/** @lends ModalOverlay.prototype # */ { + /** + * @constructs ModalOverlay + */ constructor: { value: function ModalOverlay() { this.super(); @@ -19,7 +21,7 @@ exports.ModalOverlay = Overlay.specialize(/** @lends ModalOverlay# */ { }, enterDocument: { - value: function(firstTime) { + value: function (firstTime) { var body; this.super(firstTime); @@ -54,7 +56,7 @@ exports.ModalOverlay = Overlay.specialize(/** @lends ModalOverlay# */ { * overlay be shown. */ show: { - value: function() { + value: function () { var queue = this._queue, ix = queue.indexOf(this), promise; @@ -90,7 +92,7 @@ exports.ModalOverlay = Overlay.specialize(/** @lends ModalOverlay# */ { }, hide: { - value: function() { + value: function () { var queue = this._queue, ix = queue.indexOf(this), nextOverlay; @@ -111,7 +113,7 @@ exports.ModalOverlay = Overlay.specialize(/** @lends ModalOverlay# */ { }, draw: { - value: function() { + value: function () { this.super(); if (this._isShown && this.hasModalMask) { diff --git a/ui/overlay.reel/overlay.js b/ui/overlay.reel/overlay.js index 81dab92e0f..35add9f4c7 100644 --- a/ui/overlay.reel/overlay.js +++ b/ui/overlay.reel/overlay.js @@ -9,7 +9,7 @@ var Montage = require("../../core/core").Montage, var CLASS_PREFIX = "montage-Overlay"; -/* +/** * This component uses a "trick" to measure its element when it is shown. * Since the element is "display: none" when it's hidden it's not possible to * measure it at willDraw in order to calculate the correct position to center it. @@ -19,10 +19,11 @@ var CLASS_PREFIX = "montage-Overlay"; * class that has a "display: block". A second draw is then forced. * On the second draw the element is now measurable and the visibility is set * back to "visible". This mechanism is controlled by the _isDisplayed flag. + * * @class Overlay * @extends Component */ -exports.Overlay = Component.specialize( /** @lends Overlay# */ { +exports.Overlay = Component.specialize( /** @lends Overlay.prototype # */ { /** * Dispatched when the user dismiss the overlay by clicking outside of it. @@ -47,11 +48,11 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { * The anchor element or component to display the overlay next to. */ anchor: { - set: function(value) { + set: function (value) { this._anchor = value; this.needsDraw = true; }, - get: function() { + get: function () { return this._anchor; } }, @@ -65,11 +66,11 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { * @type {{left: number, top: number}} */ position: { - set: function(value) { + set: function (value) { this._position = value; this.needsDraw = true; }, - get: function() { + get: function () { return this._position; } }, @@ -85,7 +86,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { }, isShown: { - get: function() { + get: function () { return this._isShown; } }, @@ -125,7 +126,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { }, dismissOnExternalInteraction: { - set: function(value) { + set: function (value) { if (value !== this._dismissOnExternalInteraction) { this._dismissOnExternalInteraction = value; if (value) { @@ -135,11 +136,14 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { } } }, - get: function() { + get: function () { return this._dismissOnExternalInteraction; } }, + /** + * @constructs Overlay + */ constructor: { value: function Overlay() { this.super(); @@ -155,7 +159,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { }, enterDocument: { - value: function(firstTime) { + value: function (firstTime) { var body, _window; @@ -200,7 +204,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { * because of a bug in KeyComposer. */ show: { - value: function() { + value: function () { if (!this._isShown) { if (this.isModal) { this._previousActiveTarget = defaultEventManager.activeTarget; @@ -224,7 +228,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { }, hide: { - value: function() { + value: function () { if (this._isShown) { // detachFromParentComponent happens at didDraw this.classList.remove(CLASS_PREFIX + "--visible"); @@ -251,7 +255,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { * if the other component is one of its descendants. */ surrendersActiveTarget: { - value: function(candidateActiveTarget) { + value: function (candidateActiveTarget) { if (!this.isShown || !this.isModal) { return true; } @@ -267,7 +271,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { // Event handlers handleResize: { - value: function() { + value: function () { if (this.isShown) { this.needsDraw = true; } @@ -275,7 +279,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { }, handlePressStart: { - value: function(event) { + value: function (event) { if (!this.element.contains(event.targetElement)) { this.dismissOverlay(event); } @@ -283,7 +287,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { }, handleKeyPress: { - value: function(event) { + value: function (event) { if (event.identifier === "escape") { this.dismissOverlay(event); } @@ -295,7 +299,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { * an opportunity to prevent it. Returns whether the overlay was hidden. */ dismissOverlay: { - value: function(event) { + value: function (event) { var shouldDismissOverlay = false; if (this._isShown) { shouldDismissOverlay = this.callDelegateMethod("shouldDismissOverlay", this, event.targetElement, event.type); @@ -313,7 +317,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { // Draw willDraw: { - value: function() { + value: function () { // Only calculate the position if the element is part of the layout, // otherwise it's not possible to measure the element. if (this._isDisplayed && this._isShown) { @@ -326,7 +330,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { }, draw: { - value: function() { + value: function () { if (this._isShown) { // The element is displayed when it is measurable. if (this._isDisplayed) { @@ -351,7 +355,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { }, didDraw: { - value: function() { + value: function () { if (!this._isShown) { this.detachFromParentComponent(); } @@ -359,7 +363,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { }, _reposition: { - value: function() { + value: function () { var position = this._drawPosition; this.element.style.top = position.top + "px"; @@ -368,7 +372,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { }, _getElementPosition: { - value: function(element) { + value: function (element) { var left = 0, top = 0; @@ -385,7 +389,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { }, _calculatePosition: { - value: function() { + value: function () { var position, delegatePosition; @@ -408,7 +412,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { }, _calculateAnchorPosition: { - value: function() { + value: function () { var anchor = this.anchor, width = this.element.offsetWidth, anchorPosition = this._getElementPosition(anchor), @@ -430,7 +434,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { }, _calculateCenteredPosition: { - value: function() { + value: function () { var _window = this.element.ownerDocument.defaultView, viewportHeight = _window.innerHeight, viewportWidth = _window.innerWidth, @@ -445,7 +449,7 @@ exports.Overlay = Component.specialize( /** @lends Overlay# */ { }, _dispatchDismissEvent: { - value: function() { + value: function () { var dismissEvent = document.createEvent("CustomEvent"); dismissEvent.initCustomEvent("dismiss", true, true, null); diff --git a/ui/repetition.reel/repetition.js b/ui/repetition.reel/repetition.js index 3d47885ee8..11c612e63e 100644 --- a/ui/repetition.reel/repetition.js +++ b/ui/repetition.reel/repetition.js @@ -1,5 +1,5 @@ /** - * @module montage/ui/repetition.reel + * @module "montage/ui/repetition.reel" */ var Montage = require("../../core/core").Montage; var Component = require("../component").Component; @@ -28,8 +28,9 @@ var TIMEOUT_BEFORE_ITERATION_BECOME_ACTIVE = 60; * selected. * * @class Iteration + * @extends Montage */ -var Iteration = exports.Iteration = Montage.specialize( /** @lends Iteration# */ { +var Iteration = exports.Iteration = Montage.specialize( /** @lends Iteration.prototype # */ { /** * The parent repetition component. @@ -488,6 +489,9 @@ var Iteration = exports.Iteration = Montage.specialize( /** @lends Iteration# */ // Give it up for the Repetition... /** + * @class Repetition + * @classdesc A component that repeats its inner template for each value in + * @desc * A component that manages copies of its inner template for each value in its * content. The content is managed by a controller. The repetition will * create a {@link RangeController} for the content if you provide a @@ -507,12 +511,11 @@ var Iteration = exports.Iteration = Montage.specialize( /** @lends Iteration# */ * document, prefering to inject or retract iterations between ones that remain * in their respective order, or even just rebind existing iterations to * alternate content instead of injecting and retracting in the same position. - * @class Repetition - * @classdesc A component that repeats its inner template for each value in * some content. + * * @extends Component */ -var Repetition = exports.Repetition = Component.specialize(/** @lends Repetition# */{ +var Repetition = exports.Repetition = Component.specialize(/** @lends Repetition.prototype # */{ // For the creator: // ---- @@ -934,7 +937,7 @@ var Repetition = exports.Repetition = Component.specialize(/** @lends Repetition }, _buildIterationTemplate: { - value: function() { + value: function () { var iterationTemplate; var serialization; var serializationObject; @@ -969,7 +972,7 @@ var Repetition = exports.Repetition = Component.specialize(/** @lends Repetition }, _rebuildIterationTemplate: { - value: function() { + value: function () { var iterationTemplate = this._iterationTemplate, newIterationTemplate, iterations = this.iterations; @@ -986,7 +989,7 @@ var Repetition = exports.Repetition = Component.specialize(/** @lends Repetition }, refreshTemplate: { - value: function() { + value: function () { this._rebuildIterationTemplate(); } }, @@ -1035,7 +1038,7 @@ var Repetition = exports.Repetition = Component.specialize(/** @lends Repetition }, _leTagIterationTemplate: { - value: function(template) { + value: function (template) { var body = template.document.body; if (body.children.length > 0) { @@ -1088,7 +1091,7 @@ var Repetition = exports.Repetition = Component.specialize(/** @lends Repetition }, _purgeFreeIterations: { - value: function() { + value: function () { for (var i = 0; i < this._freeIterations.length; i++) { var iteration = this._freeIterations[i]; for (var j = 0; j < iteration._childComponents.length; j++) { @@ -1106,7 +1109,7 @@ var Repetition = exports.Repetition = Component.specialize(/** @lends Repetition * @private */ _expandIterationTemplateParameters: { - value: function(template) { + value: function (template) { var owner = this, argumentsTemplate, collisionTable, @@ -1193,7 +1196,7 @@ var Repetition = exports.Repetition = Component.specialize(/** @lends Repetition iteration = new this.Iteration().initWithRepetition(this); this._iterationCreationPromise = this._iterationCreationPromise - .then(function() { + .then(function () { var _document = self.element.ownerDocument, instances, promise; @@ -1211,7 +1214,7 @@ var Repetition = exports.Repetition = Component.specialize(/** @lends Repetition .then(function (part) { part.parentDocumentPart = self._ownerDocumentPart; iteration._templateDocumentPart = part; - part.loadComponentTree().then(function() { + part.loadComponentTree().then(function () { if (logger.isDebug) { logger.debug("Iteration:%s component tree loaded.", Object.hash(iteration)); } diff --git a/ui/slot.reel/slot.js b/ui/slot.reel/slot.js index 36cccbd80f..0dfdf8b9a1 100644 --- a/ui/slot.reel/slot.js +++ b/ui/slot.reel/slot.js @@ -12,7 +12,7 @@ var Montage = require("../../core/core").Montage, * other component. * @extends Component */ -exports.Slot = Component.specialize( /** @lends Slot# */ { +exports.Slot = Component.specialize( /** @lends Slot.prototype # */ { hasTemplate: { enumerable: false, @@ -60,10 +60,10 @@ exports.Slot = Component.specialize( /** @lends Slot# */ { * @default null */ content: { - get: function() { + get: function () { return this._content; }, - set: function(value) { + set: function (value) { var element, content; @@ -100,12 +100,12 @@ exports.Slot = Component.specialize( /** @lends Slot# */ { /** * Informs the `delegate` that `slotDidSwitchContent(slot, newContent, * oldContent)` - * @method + * @function * @param newContent * @param oldContent */ contentDidChange: { - value: function(newContent, oldContent) { + value: function (newContent, oldContent) { if (this.delegate && typeof this.delegate.slotDidSwitchContent === "function") { this.delegate.slotDidSwitchContent(this, newContent, (newContent ? newContent.component : null), oldContent, (oldContent ? oldContent.component : null)); } diff --git a/ui/substitution.reel/substitution.js b/ui/substitution.reel/substitution.js index 71c18865f9..0af68a4c93 100644 --- a/ui/substitution.reel/substitution.js +++ b/ui/substitution.reel/substitution.js @@ -54,7 +54,7 @@ var Slot = require("../slot.reel").Slot, * at a time. * @extends Slot */ -exports.Substitution = Slot.specialize( /** @lends Substitution# */ { +exports.Substitution = Slot.specialize( /** @lends Substitution.prototype # */ { hasTemplate: { enumerable: false, @@ -73,7 +73,7 @@ exports.Substitution = Slot.specialize( /** @lends Substitution# */ { }, deserializedFromTemplate: { - value: function() { + value: function () { this._allChildComponents = this.childComponents.slice(0); if (this.switchValue) { @@ -97,7 +97,7 @@ exports.Substitution = Slot.specialize( /** @lends Substitution# */ { * * Throws when the `element` given has a parent node. * - * @method + * @function * @param {string} key The key that identifies the content given, similar to * `data-arg` when declaring the content in the template. * @param {Node} element The element that will be shown when the `key` is @@ -106,7 +106,7 @@ exports.Substitution = Slot.specialize( /** @lends Substitution# */ { * have a parent node. */ addSwitchElement: { - value: function(key, element) { + value: function (key, element) { if (element.parentNode) { throw new Error("Can't handle elements inside the DOM."); } @@ -117,7 +117,7 @@ exports.Substitution = Slot.specialize( /** @lends Substitution# */ { }, _findFringeComponents: { - value: function(element, components) { + value: function (element, components) { var nodes; components = components || []; @@ -151,10 +151,10 @@ exports.Substitution = Slot.specialize( /** @lends Substitution# */ { * @type {string} */ switchValue: { - get: function() { + get: function () { return this._switchValue; }, - set: function(value) { + set: function (value) { if (this._switchValue === value || this._isSwitchingContent) { return; @@ -173,7 +173,7 @@ exports.Substitution = Slot.specialize( /** @lends Substitution# */ { }, enterDocument: { - value: function(firstTime) { + value: function (firstTime) { var argumentNames; Slot.enterDocument.apply(this, arguments); @@ -195,7 +195,7 @@ exports.Substitution = Slot.specialize( /** @lends Substitution# */ { }, _loadContent: { - value: function(value) { + value: function (value) { // If the value being loaded is already in the document then use it // instead of the element in the switchElements. The element in the // document could be a diferent one (if it is a component that had @@ -213,7 +213,7 @@ exports.Substitution = Slot.specialize( /** @lends Substitution# */ { }, contentDidChange: { - value: function(newContent, oldContent) { + value: function (newContent, oldContent) { this.super(); if (this._drawnSwitchValue) { this._switchElements[this._drawnSwitchValue] = oldContent; @@ -223,7 +223,7 @@ exports.Substitution = Slot.specialize( /** @lends Substitution# */ { }, _loadSwitchComponentTree: { - value: function(value) { + value: function (value) { var self = this, childComponents = this._allChildComponents, element = this._switchElements[value], @@ -259,7 +259,7 @@ exports.Substitution = Slot.specialize( /** @lends Substitution# */ { if (promises.length > 0) { canDrawGate.setField(value + "ComponentTreeLoaded", false); - Promise.all(promises).then(function() { + Promise.all(promises).then(function () { self._switchComponentTreeLoaded[value] = true; canDrawGate.setField(value + "ComponentTreeLoaded", true); self._canDraw = true; @@ -280,7 +280,7 @@ exports.Substitution = Slot.specialize( /** @lends Substitution# */ { * @private */ _getSubstitutionDomArgument: { - value: function(name) { + value: function (name) { var candidates, node, element, diff --git a/ui/text.reel/text.js b/ui/text.reel/text.js index cfd41ac724..815779b872 100644 --- a/ui/text.reel/text.js +++ b/ui/text.reel/text.js @@ -1,5 +1,5 @@ /** - * @module montage/ui/text.reel + * @module "montage/ui/text.reel" */ var Component = require("../component").Component; @@ -15,8 +15,10 @@ var Component = require("../component").Component; * @classdesc A component that displays a string of plain text. * @extends Component */ -exports.Text = Component.specialize( /** @lends Text# */ { - +exports.Text = Component.specialize( /** @lends Text.prototype # */ { + /** + * @constructs Text + */ constructor: { value: function Text() { this.super(); @@ -37,10 +39,10 @@ exports.Text = Component.specialize( /** @lends Text# */ { * @default null */ value: { - get: function() { + get: function () { return this._value; }, - set: function(value) { + set: function (value) { if (this._value !== value) { this._value = value; this.needsDraw = true; @@ -77,7 +79,7 @@ exports.Text = Component.specialize( /** @lends Text# */ { }, enterDocument: { - value: function(firstTime) { + value: function (firstTime) { if (firstTime) { var range = this._RANGE; range.selectNodeContents(this.element); @@ -90,7 +92,7 @@ exports.Text = Component.specialize( /** @lends Text# */ { }, draw: { - value: function() { + value: function () { // get correct value var value = this._value, displayValue = (value || 0 === value ) ? value : this.defaultValue; diff --git a/window-loader/montage-window.js b/window-loader/montage-window.js index f2a42ad64a..9d6be32204 100644 --- a/window-loader/montage-window.js +++ b/window-loader/montage-window.js @@ -1,20 +1,16 @@ /** * @module montage/ui/window * @requires montage/core/core - * @requires montage/ui/reel - * @requires montage/core/gate - * @requires montage/core/logger | component - * @requires montage/core/logger | drawing - * @requires montage/core/event/event-manager */ var Montage = require("../core/core").Montage; /** * The Window object is responsible for managing a DOM window. + * * @class MontageWindow * @extends Montage */ -var MontageWindow = exports.MontageWindow = Montage.specialize( /** @lends MontageWindow# */ { +var MontageWindow = exports.MontageWindow = Montage.specialize( /** @lends MontageWindow.prototype # */ { _application: { value: null @@ -25,8 +21,8 @@ var MontageWindow = exports.MontageWindow = Montage.specialize( /** @lends Monta * @type {Application} */ application: { - get: function() { return this._application; }, - set: function(value) { + get: function () { return this._application; }, + set: function (value) { if (this._application === null) { this._application = value; if (this.focused) { @@ -45,8 +41,8 @@ var MontageWindow = exports.MontageWindow = Montage.specialize( /** @lends Monta * @type {Window} */ window: { - get: function() { return this._window; }, - set: function(value) { + get: function () { return this._window; }, + set: function (value) { if (this._window === null) { var body = value.document.body; @@ -70,7 +66,7 @@ var MontageWindow = exports.MontageWindow = Montage.specialize( /** @lends Monta * @type {document} */ document: { - get: function() { return this._window.document; } + get: function () { return this._window.document; } }, _component: { @@ -82,8 +78,8 @@ var MontageWindow = exports.MontageWindow = Montage.specialize( /** @lends Monta * @type {component} */ component: { - get: function() {return this._component;}, - set: function(value) { + get: function () {return this._component;}, + set: function (value) { if (this._component === null) { this._component = value; } @@ -95,11 +91,12 @@ var MontageWindow = exports.MontageWindow = Montage.specialize( /** @lends Monta * window's title rather than directly accessing directly the title by the * document, else you will not be able to use binding with the window's * title. - * @type {string} + * + * @returns {string} */ title: { - get: function() { return this.document.title; }, - set: function(value) { + get: function () { return this.document.title; }, + set: function (value) { this.document.title = value; } }, @@ -115,10 +112,10 @@ var MontageWindow = exports.MontageWindow = Montage.specialize( /** @lends Monta /** * Set the focus on the window, move it to the front. - * @method + * @function */ focus: { - value: function() { + value: function () { if (this._window) { this._window.focus(); } @@ -126,7 +123,7 @@ var MontageWindow = exports.MontageWindow = Montage.specialize( /** @lends Monta }, _setFocusedWindow: { - value: function(aWindow) { + value: function (aWindow) { var application = this.application, windows, theWindow, @@ -163,16 +160,16 @@ var MontageWindow = exports.MontageWindow = Montage.specialize( /** @lends Monta * @type {boolean} */ closed: { - get: function() { return this._window ? this._window.closed : false; } + get: function () { return this._window ? this._window.closed : false; } }, /** * Close the window * Note: Any child window will be closed too. - * @method + * @function */ close: { - value: function() { + value: function () { if (this._window) { this._window.close(); } @@ -181,12 +178,12 @@ var MontageWindow = exports.MontageWindow = Montage.specialize( /** @lends Monta /** * Resize the window to the specified width and height - * @method + * @function * @param {Integer} width The window's width desired. * @param {Integer} height The window's height desired. */ resizeTo: { - value: function(width, height) { + value: function (width, height) { if (this._window) { this._window.resizeTo(width, height); } @@ -195,12 +192,12 @@ var MontageWindow = exports.MontageWindow = Montage.specialize( /** @lends Monta /** * Move the window to the specified screen coordinate x and y - * @method + * @function * @param {Integer} x The window's x screen position. * @param {Integer} y The window's y screen position. */ moveTo: { - value: function(x, y) { + value: function (x, y) { if (this._window) { this._window.moveTo(x, y); } @@ -208,7 +205,7 @@ var MontageWindow = exports.MontageWindow = Montage.specialize( /** @lends Monta }, captureFocus: { - value: function(event) { + value: function (event) { var application = this.application; if (!this.application) { @@ -228,14 +225,14 @@ var MontageWindow = exports.MontageWindow = Montage.specialize( /** @lends Monta }, captureMousedown: { - value: function(event) { + value: function (event) { // Sometime, for some reason, we do not receive anymore a focus event... let presume that if we get a mouse click, we should have focus this.captureFocus(event); } }, captureBeforeunload: { - value: function(event) { + value: function (event) { var application = this.application, windows = application.windows, diff --git a/window-loader/window-loader.js b/window-loader/window-loader.js index 955463fb61..05e566edc6 100644 --- a/window-loader/window-loader.js +++ b/window-loader/window-loader.js @@ -2,7 +2,7 @@ var parentWindow = window.opener; // Let's switch to the parent application package context require.loadPackage(parentWindow.require.location) -.then(function(require) { +.then(function (require) { var loadInfo = window.loadInfo, module = loadInfo.module, name = loadInfo.name, @@ -13,7 +13,7 @@ require.loadPackage(parentWindow.require.location) window.require = window.mr = require; return require.async("montage/ui/component") - .then(function(exports) { + .then(function (exports) { return require.async("montage/ui/loader.reel") .then(function (exports) { var mainComponent = exports["Loader"].create(); @@ -24,7 +24,7 @@ require.loadPackage(parentWindow.require.location) mainComponent.needsDraw = true; if (callback) { - mainComponent.addEventListener("componentLoaded", function(event) { + mainComponent.addEventListener("componentLoaded", function (event) { mainComponent.removeEventListener("componentLoaded", arguments.callee); callback(window, event.detail); });