From 05bba59fc9cb0ce07175e5f0865a319e9dd0ff52 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 1 Feb 2012 16:30:41 -0800 Subject: removing references to the old components in the app delegate Signed-off-by: Valerio Virgillito --- .../montage-application-cloud/appdelegate.js | 25 ---------------------- 1 file changed, 25 deletions(-) diff --git a/user-document-templates/montage-application-cloud/appdelegate.js b/user-document-templates/montage-application-cloud/appdelegate.js index 64ce6f59..3c21b46e 100644 --- a/user-document-templates/montage-application-cloud/appdelegate.js +++ b/user-document-templates/montage-application-cloud/appdelegate.js @@ -7,31 +7,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component; -var Button = require("montage/ui/button.reel").Button, - Checkbox = require("montage/ui/checkbox.reel").Checkbox, - Condition = require("montage/ui/condition.reel").Condition, - DynamicText = require("montage/ui/dynamic-text.reel").DynamicText, - - FlowController = require("montage/ui/flow-controller.reel").FlowController, - - HotText = require("montage/ui/hottext.reel").HotText, - HotTextUnit = require("montage/ui/hottextunit.reel").HotTextUnit, - - ImageContainer = require("montage/ui/photo-editor.reel").PhotoEditor, - Progress = require("montage/ui/progress.reel").Progress, - - Repetition = require("montage/ui/repetition.reel").Repetition, - Scrollview = require("montage/ui/scrollview.reel").Scrollview, - Slider = require("montage/ui/slider.reel").Slider, - Slot = require("montage/ui/slot.reel").Slot, - Substitution = require("montage/ui/substitution.reel").Substitution, - - TextArea = require("montage/ui/textarea.reel").TextArea, - Textfield = require("montage/ui/textfield.reel").Textfield, - - Toggle = require("montage/ui/toggle.reel").Toggle, - ToggleButton = require("montage/ui/button.reel").ToggleButton; - exports.MyAppDelegate = Montage.create(Component, { templateDidLoad: { value: function(){ -- cgit v1.2.3 From f07bbfaa60c3fb7c2412c5aa97b49d114d6a88ea Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 1 Feb 2012 16:43:08 -0800 Subject: Adding njUtils as a component and adding it to the application object Signed-off-by: Valerio Virgillito --- js/lib/nj-utils.js | 214 +++++++++++++++++++++++++++++++++++++++++++++++ js/ninja.reel/ninja.html | 8 +- js/ninja.reel/ninja.js | 2 + 3 files changed, 223 insertions(+), 1 deletion(-) create mode 100644 js/lib/nj-utils.js diff --git a/js/lib/nj-utils.js b/js/lib/nj-utils.js new file mode 100644 index 00000000..59ea6095 --- /dev/null +++ b/js/lib/nj-utils.js @@ -0,0 +1,214 @@ +/* +This file contains proprietary software owned by Motorola Mobility, Inc.
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component, + ElementModel = require("js/models/element-model").ElementModel, + Properties3D = require("js/models/properties-3d").Properties3D, + ShapeModel = require("js/models/shape-model").ShapeModel, + ControllerFactory = require("js/controllers/elements/controller-factory").ControllerFactory; + +exports.NJUtils = Montage.create( Component, { + + + + /* =============== DOM Access ================ */ + + ///// Quick "getElementById" + $ : { + value: function(id) { + return document.getElementById(id); + } + }, + + ///// Quick "getElementsByClassName" which also returns as an Array + ///// Can return as NodeList by passing true as second argument + $$ : { + value: function(className, asNodeList) { + var list = document.getElementsByClassName(className); + return (asNodeList) ? list : this.toArray(list); + } + }, + + ///// Get child nodes of element + ///// Omit filter to only return element nodes + ///// Pass in filter function to minimize collection, or + ///// set to true to include all nodes + children : { + value : function(el, filter) { + var f = filter || function(item) { + return item.nodeType === 1; + }; + return this.toArray(el.childNodes).filter(f); + } + }, + + /* ============= DOM Manipulation ============= */ + + ///// Creates and returns text node from string + textNode : { + value: function(text) { + return document.createTextNode(text); + } + }, + + ///// Quick "createElement" function "attr" can be classname or object + ///// with attribute key/values + make : { + value: function(tag, attr) { + var el = document.createElement(tag); + if (typeof attr === 'object') { + for (var a in attr) { + if (attr.hasOwnProperty(a)) { + el[a] = attr[a]; + } + } + } else if (typeof attr === 'string') { + el.className = (el.className + ' ' + attr).trim(); + } + + return el; + } + }, + + ///// Element factory function for Ninja Elements + ///// selection is the string displayed in the PI + makeNJElement: { + value: function(tag, selection, controller, attr, isShape) { + var el = this.make(tag, attr); + this.makeElementModel(el, selection, controller, isShape); + + return el; + } + }, + + ///// Element Model creation for existing elements + ///// TODO: find a different place for this function + makeElementModel: { + value: function(el, selection, controller, isShape) { + var p3d = Montage.create(Properties3D).init(el); + var shapeProps = null; + if(isShape) { + shapeProps = Montage.create(ShapeModel); + } + + el.elementModel = Montage.create(ElementModel, { + type: { value: el.nodeName}, + selection: { value: selection}, + controller: { value: ControllerFactory.getController(controller)}, + pi: { value: controller + "Pi"}, + props3D: { value: p3d}, + shapeModel: { value: shapeProps} + }); + + } + }, + + ///// Element Model creation for existing elements based on element type. + ///// TODO: find a different place for this function and return different element models based on type. + makeElementModel2: { + value: function(el) { + this.makeElementModel(el, "Div", "block", false); + } + }, + + ///// Removes all child nodes and returns node + ///// Accepts a single node, or an array of dom nodes + empty : { + value: function(node) { + var elements = [], + self = this; + if (node.constructor === Array) { + node.forEach(function(el) { self.empty(el) }); + } else { + this.toArray(node.childNodes).forEach(function(child) { + child.parentNode.removeChild(child); + }); + } + + return node; + } + }, + + queryParentSelector : { + value: function(el, strSelector) { + // queryParentSelector: + // Given a DOM element el (required), walk up the DOM tree + // and find the first parent that matches selector strSelector (required). + // Returns: The element that matches, or false if there is no match + // or if insufficient parameters are supplied. + + if ((typeof(el) === "undefined") || (typeof(strSelector) === "undefined")) { + // Parameters are required, m'kay? + return false; + } else if ((typeof(el) !== "object") || (typeof(strSelector) !== "string" )) { + // You also have to use the right parameters. + return false; + } + + // First, get an empty clone of the parent. + var myParent = el.parentNode; + var clone = myParent.cloneNode(false); + if (clone === null) { + return false; + } + + // If we're at the top of the DOM, our clone will be an htmlDocument. + // htmlDocument has no tagName. + if (typeof(clone.tagName) !== "undefined") { + // create a bogus div to use as a base for querySelector + var temp = document.createElement("div"); + + // Append the clone to the bogus div + temp.appendChild(clone); + + // Now we can use querySelector! Sweet. + var selectorTest = temp.querySelector(strSelector); + + // What has querySelector returned? + if (selectorTest === null) { + // No match, so recurse. + return this.queryParentSelector(myParent, strSelector); + } else { + // Match! Return the element. + return myParent; + } + } else { + // We're at the top of the DOM so we're done. + return false; + } + } + + }, + + /* ================= Style methods ================= */ + + ///// Get computed height of element + height : { + value: function(node, pseudo) { + return node.ownerDocument.defaultView.getComputedStyle(node, pseudo).getPropertyValue('height'); + } + }, + + /* ================= Array methods ================= */ + + ///// Return an array from an array-like object + toArray : { + value: function(arrayLikeObj) { + return Array.prototype.slice.call(arrayLikeObj); + } + }, + + /* ================= String methods ================= */ + + ///// Return the last part of a path (e.g. filename) + getFileNameFromPath : { + value: function(path) { + return path.substr(path.lastIndexOf('/') + 1); + } + } + +}); diff --git a/js/ninja.reel/ninja.html b/js/ninja.reel/ninja.html index 706c8243..f3ff3d58 100644 --- a/js/ninja.reel/ninja.html +++ b/js/ninja.reel/ninja.html @@ -259,6 +259,11 @@ "name": "NewFileWorkflowController" }, + "njUtils": { + "module":"js/lib/nj-utils", + "name": "NJUtils" + }, + "owner": { "module": "js/ninja.reel", "name": "Ninja", @@ -279,7 +284,8 @@ "stylesController": {"@": "stylesController"}, "filePickerController": {"@": "filePickerController"}, "newFileController": {"@": "newFileController"}, - "documentBar": {"@": "documentBar"} + "documentBar": {"@": "documentBar"}, + "njUtils": {"@": "njUtils"} } } diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index 465533cd..7115b228 100644 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -34,6 +34,8 @@ exports.Ninja = Montage.create(Component, { templateDidLoad: { value: function() { + this.application.njutils = this.njUtils; + this.eventManager.addEventListener( "preloadFinish", this, false); } }, -- cgit v1.2.3 From 1159924ecae4e7d371d40cee00e0e56d1605ffda Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 1 Feb 2012 23:53:47 -0800 Subject: Fixes for montage integration Signed-off-by: Valerio Virgillito --- js/helper-classes/RDGE/GLBrushStroke.js | 1 + js/helper-classes/RDGE/GLSubpath.js | 1 + js/ninja.reel/ninja.js | 15 ++++++++------- .../PanelContainer/PanelContainer.reel/PanelContainer.js | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/js/helper-classes/RDGE/GLBrushStroke.js b/js/helper-classes/RDGE/GLBrushStroke.js index 89292ad8..e3b14bf7 100644 --- a/js/helper-classes/RDGE/GLBrushStroke.js +++ b/js/helper-classes/RDGE/GLBrushStroke.js @@ -4,6 +4,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ +// Todo: This shoudl be converted to a module var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; diff --git a/js/helper-classes/RDGE/GLSubpath.js b/js/helper-classes/RDGE/GLSubpath.js index 25b12093..55b7e49a 100644 --- a/js/helper-classes/RDGE/GLSubpath.js +++ b/js/helper-classes/RDGE/GLSubpath.js @@ -4,6 +4,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ +// Todo: This shoudl be converted to a module var VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index 7115b228..48c72a1d 100644 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -96,9 +96,16 @@ exports.Ninja = Montage.create(Component, { } }, + _didDraw: { + value: false + }, + didDraw: { value: function() { - NJevent("appLoaded"); + if(!this._didDraw) { + NJevent("appLoaded"); + this._didDraw = true; + } } }, @@ -165,12 +172,6 @@ exports.Ninja = Montage.create(Component, { } }, - handleLivePreview: { - value: function(event) { - - } - }, - executeLivePreview: { value: function() { var background, overflow, transitionStopRule; diff --git a/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js b/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js index 57187af1..66333cc0 100644 --- a/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js +++ b/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js @@ -91,7 +91,7 @@ exports.PanelContainer = Montage.create(Component, { this.panelSplitter.disabled = true; } - this.needsDraw = true; +// this.needsDraw = true; this.addEventListener("change@appModel.PropertiesPanel", this, false); this.addEventListener("change@appModel.ProjectPanel", this, false); @@ -198,7 +198,7 @@ exports.PanelContainer = Montage.create(Component, { minHeights += this.repeater.childComponents[i].element.offsetHeight; } else { this._panels[i].isLocked = false; - this.repeater.childComponents[i].needsDraw = true; + if(this.repeater.childComponents[i]) this.repeater.childComponents[i].needsDraw = true; minHeights += this._panels[i].minHeight; } } -- cgit v1.2.3 From dbe9c7705860fb3551321e23e7eab763f622241c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 1 Feb 2012 23:54:24 -0800 Subject: Revert "Adding njUtils as a component and adding it to the application object" This reverts commit f07bbfaa60c3fb7c2412c5aa97b49d114d6a88ea. Signed-off-by: Valerio Virgillito --- js/lib/nj-utils.js | 214 ----------------------------------------------- js/ninja.reel/ninja.html | 8 +- js/ninja.reel/ninja.js | 2 - 3 files changed, 1 insertion(+), 223 deletions(-) delete mode 100644 js/lib/nj-utils.js diff --git a/js/lib/nj-utils.js b/js/lib/nj-utils.js deleted file mode 100644 index 59ea6095..00000000 --- a/js/lib/nj-utils.js +++ /dev/null @@ -1,214 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component, - ElementModel = require("js/models/element-model").ElementModel, - Properties3D = require("js/models/properties-3d").Properties3D, - ShapeModel = require("js/models/shape-model").ShapeModel, - ControllerFactory = require("js/controllers/elements/controller-factory").ControllerFactory; - -exports.NJUtils = Montage.create( Component, { - - - - /* =============== DOM Access ================ */ - - ///// Quick "getElementById" - $ : { - value: function(id) { - return document.getElementById(id); - } - }, - - ///// Quick "getElementsByClassName" which also returns as an Array - ///// Can return as NodeList by passing true as second argument - $$ : { - value: function(className, asNodeList) { - var list = document.getElementsByClassName(className); - return (asNodeList) ? list : this.toArray(list); - } - }, - - ///// Get child nodes of element - ///// Omit filter to only return element nodes - ///// Pass in filter function to minimize collection, or - ///// set to true to include all nodes - children : { - value : function(el, filter) { - var f = filter || function(item) { - return item.nodeType === 1; - }; - return this.toArray(el.childNodes).filter(f); - } - }, - - /* ============= DOM Manipulation ============= */ - - ///// Creates and returns text node from string - textNode : { - value: function(text) { - return document.createTextNode(text); - } - }, - - ///// Quick "createElement" function "attr" can be classname or object - ///// with attribute key/values - make : { - value: function(tag, attr) { - var el = document.createElement(tag); - if (typeof attr === 'object') { - for (var a in attr) { - if (attr.hasOwnProperty(a)) { - el[a] = attr[a]; - } - } - } else if (typeof attr === 'string') { - el.className = (el.className + ' ' + attr).trim(); - } - - return el; - } - }, - - ///// Element factory function for Ninja Elements - ///// selection is the string displayed in the PI - makeNJElement: { - value: function(tag, selection, controller, attr, isShape) { - var el = this.make(tag, attr); - this.makeElementModel(el, selection, controller, isShape); - - return el; - } - }, - - ///// Element Model creation for existing elements - ///// TODO: find a different place for this function - makeElementModel: { - value: function(el, selection, controller, isShape) { - var p3d = Montage.create(Properties3D).init(el); - var shapeProps = null; - if(isShape) { - shapeProps = Montage.create(ShapeModel); - } - - el.elementModel = Montage.create(ElementModel, { - type: { value: el.nodeName}, - selection: { value: selection}, - controller: { value: ControllerFactory.getController(controller)}, - pi: { value: controller + "Pi"}, - props3D: { value: p3d}, - shapeModel: { value: shapeProps} - }); - - } - }, - - ///// Element Model creation for existing elements based on element type. - ///// TODO: find a different place for this function and return different element models based on type. - makeElementModel2: { - value: function(el) { - this.makeElementModel(el, "Div", "block", false); - } - }, - - ///// Removes all child nodes and returns node - ///// Accepts a single node, or an array of dom nodes - empty : { - value: function(node) { - var elements = [], - self = this; - if (node.constructor === Array) { - node.forEach(function(el) { self.empty(el) }); - } else { - this.toArray(node.childNodes).forEach(function(child) { - child.parentNode.removeChild(child); - }); - } - - return node; - } - }, - - queryParentSelector : { - value: function(el, strSelector) { - // queryParentSelector: - // Given a DOM element el (required), walk up the DOM tree - // and find the first parent that matches selector strSelector (required). - // Returns: The element that matches, or false if there is no match - // or if insufficient parameters are supplied. - - if ((typeof(el) === "undefined") || (typeof(strSelector) === "undefined")) { - // Parameters are required, m'kay? - return false; - } else if ((typeof(el) !== "object") || (typeof(strSelector) !== "string" )) { - // You also have to use the right parameters. - return false; - } - - // First, get an empty clone of the parent. - var myParent = el.parentNode; - var clone = myParent.cloneNode(false); - if (clone === null) { - return false; - } - - // If we're at the top of the DOM, our clone will be an htmlDocument. - // htmlDocument has no tagName. - if (typeof(clone.tagName) !== "undefined") { - // create a bogus div to use as a base for querySelector - var temp = document.createElement("div"); - - // Append the clone to the bogus div - temp.appendChild(clone); - - // Now we can use querySelector! Sweet. - var selectorTest = temp.querySelector(strSelector); - - // What has querySelector returned? - if (selectorTest === null) { - // No match, so recurse. - return this.queryParentSelector(myParent, strSelector); - } else { - // Match! Return the element. - return myParent; - } - } else { - // We're at the top of the DOM so we're done. - return false; - } - } - - }, - - /* ================= Style methods ================= */ - - ///// Get computed height of element - height : { - value: function(node, pseudo) { - return node.ownerDocument.defaultView.getComputedStyle(node, pseudo).getPropertyValue('height'); - } - }, - - /* ================= Array methods ================= */ - - ///// Return an array from an array-like object - toArray : { - value: function(arrayLikeObj) { - return Array.prototype.slice.call(arrayLikeObj); - } - }, - - /* ================= String methods ================= */ - - ///// Return the last part of a path (e.g. filename) - getFileNameFromPath : { - value: function(path) { - return path.substr(path.lastIndexOf('/') + 1); - } - } - -}); diff --git a/js/ninja.reel/ninja.html b/js/ninja.reel/ninja.html index f3ff3d58..706c8243 100644 --- a/js/ninja.reel/ninja.html +++ b/js/ninja.reel/ninja.html @@ -259,11 +259,6 @@ "name": "NewFileWorkflowController" }, - "njUtils": { - "module":"js/lib/nj-utils", - "name": "NJUtils" - }, - "owner": { "module": "js/ninja.reel", "name": "Ninja", @@ -284,8 +279,7 @@ "stylesController": {"@": "stylesController"}, "filePickerController": {"@": "filePickerController"}, "newFileController": {"@": "newFileController"}, - "documentBar": {"@": "documentBar"}, - "njUtils": {"@": "njUtils"} + "documentBar": {"@": "documentBar"} } } diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index 48c72a1d..90015f5a 100644 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -34,8 +34,6 @@ exports.Ninja = Montage.create(Component, { templateDidLoad: { value: function() { - this.application.njutils = this.njUtils; - this.eventManager.addEventListener( "preloadFinish", this, false); } }, -- cgit v1.2.3 From 5a305ec44b2bd5198a248357439aae8ebbd75fee Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 2 Feb 2012 00:11:51 -0800 Subject: upgrading to Montage v0.6 Signed-off-by: Valerio Virgillito --- js/components/tree.reel/tree.js | 2 +- js/controllers/styles-controller.js | 2 +- .../CSSPanel/CSSPanelBase.reel/CSSPanelBase.js | 2 +- .../ComputedStyleSubPanel.js | 2 +- .../projectpanelbase.reel/ProjectPanelBase.js | 2 +- .../montage/core/converter/date-converter.js | 9 + node_modules/montage/core/core.js | 26 +- node_modules/montage/core/deserializer.js | 104 +- node_modules/montage/core/event/binding.js | 93 +- node_modules/montage/core/event/event-manager.js | 15 +- node_modules/montage/core/event/mutable-event.js | 5 + node_modules/montage/core/jshint.js | 2 +- node_modules/montage/core/logger.js | 14 +- node_modules/montage/core/next-tick.js | 91 ++ node_modules/montage/core/promise.js | 115 +- node_modules/montage/core/serializer.js | 21 +- node_modules/montage/core/shim.js | 2 - node_modules/montage/core/shim/immediate.js | 57 + node_modules/montage/core/shim/structures.js | 22 +- node_modules/montage/core/shim/timers.js | 87 -- node_modules/montage/core/url.js | 2 +- node_modules/montage/core/uuid.js | 96 +- node_modules/montage/effect/desaturate-effect.js | 25 - node_modules/montage/effect/effect.js | 15 - node_modules/montage/effect/invert-effect.js | 23 - node_modules/montage/effect/kaliedoscope-effect.js | 17 - node_modules/montage/effect/multiply-effect.js | 23 - node_modules/montage/effect/sepia-effect.js | 25 - node_modules/montage/montage.js | 213 +-- node_modules/montage/node.js | 79 + node_modules/montage/package.json | 13 +- node_modules/montage/require/browser.js | 183 +-- node_modules/montage/require/node.js | 101 ++ node_modules/montage/require/require.js | 997 +++++------- node_modules/montage/ui/anchor.reel/anchor.js | 26 + node_modules/montage/ui/application.js | 128 +- .../ui/bluemoon/button-group.reel/button-group.css | 111 ++ .../bluemoon/button-group.reel/button-group.html | 26 + .../ui/bluemoon/button-group.reel/button-group.js | 77 + .../montage/ui/bluemoon/button.reel/button.css | 386 +++++ .../montage/ui/bluemoon/button.reel/button.html | 26 + .../montage/ui/bluemoon/button.reel/button.js | 743 +++++++++ .../montage/ui/bluemoon/checkbox.reel/checkbox.css | 116 ++ .../ui/bluemoon/checkbox.reel/checkbox.html | 14 + .../montage/ui/bluemoon/checkbox.reel/checkbox.js | 452 ++++++ .../checkbox.reel/checkmark-dark-disabled.svg | 5 + .../ui/bluemoon/checkbox.reel/checkmark-dark.svg | 7 + .../checkbox.reel/checkmark-light-disabled.svg | 5 + .../ui/bluemoon/checkbox.reel/checkmark.svg | 7 + .../montage/ui/bluemoon/progress.reel/progress.css | 51 + .../ui/bluemoon/progress.reel/progress.html | 32 + .../montage/ui/bluemoon/progress.reel/progress.js | 139 ++ .../montage/ui/bluemoon/progress.reel/rule.png | Bin 0 -> 956 bytes .../montage/ui/bluemoon/progress.reel/scroll.png | Bin 0 -> 272 bytes .../montage/ui/bluemoon/slider.reel/slider.css | 255 +++ .../montage/ui/bluemoon/slider.reel/slider.html | 82 + .../montage/ui/bluemoon/slider.reel/slider.js | 583 +++++++ .../montage/ui/bluemoon/textarea.reel/textarea.css | 36 + .../ui/bluemoon/textarea.reel/textarea.html | 15 + .../montage/ui/bluemoon/textarea.reel/textarea.js | 29 + .../ui/bluemoon/textfield.reel/textfield.css | 35 + .../ui/bluemoon/textfield.reel/textfield.html | 16 + .../ui/bluemoon/textfield.reel/textfield.js | 56 + .../montage/ui/bluemoon/toggle.reel/toggle.css | 162 ++ .../montage/ui/bluemoon/toggle.reel/toggle.html | 16 + .../montage/ui/bluemoon/toggle.reel/toggle.js | 423 +++++ .../montage/ui/button-group.reel/button-group.css | 111 -- .../montage/ui/button-group.reel/button-group.html | 26 - .../montage/ui/button-group.reel/button-group.js | 77 - node_modules/montage/ui/button.reel/button.css | 386 ----- node_modules/montage/ui/button.reel/button.html | 26 - node_modules/montage/ui/button.reel/button.js | 655 ++------ node_modules/montage/ui/check-input.js | 46 + node_modules/montage/ui/checkbox.reel/checkbox.css | 116 -- .../montage/ui/checkbox.reel/checkbox.html | 14 - node_modules/montage/ui/checkbox.reel/checkbox.js | 464 +----- .../ui/checkbox.reel/checkmark-dark-disabled.svg | 5 - .../montage/ui/checkbox.reel/checkmark-dark.svg | 7 - .../ui/checkbox.reel/checkmark-light-disabled.svg | 5 - .../montage/ui/checkbox.reel/checkmark.svg | 7 - node_modules/montage/ui/component.js | 292 +++- node_modules/montage/ui/composer/composer.js | 142 ++ .../montage/ui/composer/long-press-composer.js | 232 +++ node_modules/montage/ui/composer/swipe-composer.js | 303 ++++ .../montage/ui/composer/translate-composer.js | 775 ++++++++++ .../montage/ui/controller/array-controller.js | 73 +- .../montage/ui/date-input.reel/date-input.js | 31 + node_modules/montage/ui/dom.js | 30 +- .../ui/flow-controller.reel/flow-controller.html | 275 ---- .../ui/flow-controller.reel/flow-controller.js | 288 ---- node_modules/montage/ui/flow-offset.js | 389 ----- node_modules/montage/ui/flow-path-cubic.js | 32 +- node_modules/montage/ui/flow-path-lerp.js | 36 +- node_modules/montage/ui/flow-path-linear.js | 26 +- node_modules/montage/ui/flow-path-sigmoid.js | 42 +- node_modules/montage/ui/flow-path.js | 46 +- node_modules/montage/ui/flow.reel/flow.html | 4 +- node_modules/montage/ui/flow.reel/flow.js | 658 ++++++-- node_modules/montage/ui/hottext.reel/hottext.css | 27 - node_modules/montage/ui/hottext.reel/hottext.html | 29 - node_modules/montage/ui/hottext.reel/hottext.js | 376 ----- .../montage/ui/hottextunit.reel/hottextunit.css | 41 - .../montage/ui/hottextunit.reel/hottextunit.html | 28 - .../montage/ui/hottextunit.reel/hottextunit.js | 185 --- node_modules/montage/ui/image.reel/image.js | 65 +- node_modules/montage/ui/image2.reel/image2.html | 31 - node_modules/montage/ui/image2.reel/image2.js | 26 - node_modules/montage/ui/image3d.reel/image3d.html | 95 -- node_modules/montage/ui/image3d.reel/image3d.js | 30 - node_modules/montage/ui/list.reel/list.html | 34 +- node_modules/montage/ui/list.reel/list.js | 192 +-- node_modules/montage/ui/loader.reel/loader.js | 7 + .../ui/loading-panel.reel/loading-panel.html | 2 +- node_modules/montage/ui/native-control.js | 240 +++ .../ui/nearest-neighbor-component-search.js | 458 +++--- .../montage/ui/number-input.reel/number-input.js | 17 + .../montage/ui/photo-editor.reel/photo-editor.css | 34 - .../montage/ui/photo-editor.reel/photo-editor.html | 50 - .../montage/ui/photo-editor.reel/photo-editor.js | 415 ----- node_modules/montage/ui/popup/alert.reel/alert.css | 8 +- .../montage/ui/popup/alert.reel/alert.html | 14 +- .../montage/ui/popup/confirm.reel/confirm.css | 2 +- .../montage/ui/popup/confirm.reel/confirm.html | 16 +- .../montage/ui/popup/confirm.reel/confirm.js | 12 +- node_modules/montage/ui/popup/popup.reel/popup.css | 15 +- .../montage/ui/popup/popup.reel/popup.html | 2 +- node_modules/montage/ui/popup/popup.reel/popup.js | 69 +- .../montage/ui/progress.reel/progress.html | 8 +- node_modules/montage/ui/progress.reel/progress.js | 23 +- .../montage/ui/radio-button.reel/radio-button.js | 97 ++ .../montage/ui/range-input.reel/range-input.js | 24 + .../montage/ui/repetition.reel/repetition.js | 243 +-- .../montage/ui/scroll-bars.reel/scroll-bars.html | 2 +- .../montage/ui/scroll-bars.reel/scroll-bars.js | 14 +- node_modules/montage/ui/scroll.js | 1634 ++++++++++---------- .../montage/ui/scroller.reel/scroller.html | 59 +- node_modules/montage/ui/scroller.reel/scroller.js | 87 +- .../montage/ui/select-input.reel/select-input.js | 320 ++++ node_modules/montage/ui/slider-base.js | 278 ---- node_modules/montage/ui/slider.reel/slider.css | 255 --- node_modules/montage/ui/slider.reel/slider.html | 82 - node_modules/montage/ui/slider.reel/slider.js | 583 ------- node_modules/montage/ui/tabs.reel/tabs.html | 8 +- node_modules/montage/ui/template.js | 47 +- node_modules/montage/ui/text-input.js | 304 ++++ node_modules/montage/ui/textarea.reel/textarea.css | 36 - .../montage/ui/textarea.reel/textarea.html | 15 - node_modules/montage/ui/textarea.reel/textarea.js | 48 +- .../montage/ui/textfield.reel/textfield.css | 35 - .../montage/ui/textfield.reel/textfield.html | 16 - .../montage/ui/textfield.reel/textfield.js | 37 +- .../montage/ui/toggle-button.reel/toggle-button.js | 171 ++ .../ui/toggle-switch.reel/toggle-switch.css | 162 ++ .../ui/toggle-switch.reel/toggle-switch.html | 16 + .../montage/ui/toggle-switch.reel/toggle-switch.js | 424 +++++ node_modules/montage/ui/toggle.reel/toggle.css | 162 -- node_modules/montage/ui/toggle.reel/toggle.html | 16 - node_modules/montage/ui/toggle.reel/toggle.js | 423 ----- .../montage/ui/video-player.reel/video-player.css | 22 +- .../montage/ui/video-player.reel/video-player.html | 18 +- 160 files changed, 11219 insertions(+), 9133 deletions(-) create mode 100644 node_modules/montage/core/next-tick.js create mode 100644 node_modules/montage/core/shim/immediate.js delete mode 100755 node_modules/montage/core/shim/timers.js delete mode 100755 node_modules/montage/effect/desaturate-effect.js delete mode 100755 node_modules/montage/effect/effect.js delete mode 100755 node_modules/montage/effect/invert-effect.js delete mode 100755 node_modules/montage/effect/kaliedoscope-effect.js delete mode 100755 node_modules/montage/effect/multiply-effect.js delete mode 100755 node_modules/montage/effect/sepia-effect.js create mode 100644 node_modules/montage/node.js create mode 100644 node_modules/montage/require/node.js create mode 100644 node_modules/montage/ui/anchor.reel/anchor.js create mode 100644 node_modules/montage/ui/bluemoon/button-group.reel/button-group.css create mode 100644 node_modules/montage/ui/bluemoon/button-group.reel/button-group.html create mode 100644 node_modules/montage/ui/bluemoon/button-group.reel/button-group.js create mode 100644 node_modules/montage/ui/bluemoon/button.reel/button.css create mode 100644 node_modules/montage/ui/bluemoon/button.reel/button.html create mode 100644 node_modules/montage/ui/bluemoon/button.reel/button.js create mode 100644 node_modules/montage/ui/bluemoon/checkbox.reel/checkbox.css create mode 100644 node_modules/montage/ui/bluemoon/checkbox.reel/checkbox.html create mode 100644 node_modules/montage/ui/bluemoon/checkbox.reel/checkbox.js create mode 100644 node_modules/montage/ui/bluemoon/checkbox.reel/checkmark-dark-disabled.svg create mode 100644 node_modules/montage/ui/bluemoon/checkbox.reel/checkmark-dark.svg create mode 100644 node_modules/montage/ui/bluemoon/checkbox.reel/checkmark-light-disabled.svg create mode 100644 node_modules/montage/ui/bluemoon/checkbox.reel/checkmark.svg create mode 100644 node_modules/montage/ui/bluemoon/progress.reel/progress.css create mode 100644 node_modules/montage/ui/bluemoon/progress.reel/progress.html create mode 100644 node_modules/montage/ui/bluemoon/progress.reel/progress.js create mode 100644 node_modules/montage/ui/bluemoon/progress.reel/rule.png create mode 100644 node_modules/montage/ui/bluemoon/progress.reel/scroll.png create mode 100644 node_modules/montage/ui/bluemoon/slider.reel/slider.css create mode 100644 node_modules/montage/ui/bluemoon/slider.reel/slider.html create mode 100644 node_modules/montage/ui/bluemoon/slider.reel/slider.js create mode 100644 node_modules/montage/ui/bluemoon/textarea.reel/textarea.css create mode 100644 node_modules/montage/ui/bluemoon/textarea.reel/textarea.html create mode 100644 node_modules/montage/ui/bluemoon/textarea.reel/textarea.js create mode 100644 node_modules/montage/ui/bluemoon/textfield.reel/textfield.css create mode 100644 node_modules/montage/ui/bluemoon/textfield.reel/textfield.html create mode 100644 node_modules/montage/ui/bluemoon/textfield.reel/textfield.js create mode 100644 node_modules/montage/ui/bluemoon/toggle.reel/toggle.css create mode 100644 node_modules/montage/ui/bluemoon/toggle.reel/toggle.html create mode 100644 node_modules/montage/ui/bluemoon/toggle.reel/toggle.js delete mode 100755 node_modules/montage/ui/button-group.reel/button-group.css delete mode 100755 node_modules/montage/ui/button-group.reel/button-group.html delete mode 100755 node_modules/montage/ui/button-group.reel/button-group.js delete mode 100755 node_modules/montage/ui/button.reel/button.css delete mode 100755 node_modules/montage/ui/button.reel/button.html mode change 100755 => 100644 node_modules/montage/ui/button.reel/button.js create mode 100644 node_modules/montage/ui/check-input.js delete mode 100755 node_modules/montage/ui/checkbox.reel/checkbox.css delete mode 100755 node_modules/montage/ui/checkbox.reel/checkbox.html mode change 100755 => 100644 node_modules/montage/ui/checkbox.reel/checkbox.js delete mode 100755 node_modules/montage/ui/checkbox.reel/checkmark-dark-disabled.svg delete mode 100755 node_modules/montage/ui/checkbox.reel/checkmark-dark.svg delete mode 100755 node_modules/montage/ui/checkbox.reel/checkmark-light-disabled.svg delete mode 100755 node_modules/montage/ui/checkbox.reel/checkmark.svg create mode 100644 node_modules/montage/ui/composer/composer.js create mode 100644 node_modules/montage/ui/composer/long-press-composer.js create mode 100644 node_modules/montage/ui/composer/swipe-composer.js create mode 100644 node_modules/montage/ui/composer/translate-composer.js create mode 100644 node_modules/montage/ui/date-input.reel/date-input.js delete mode 100644 node_modules/montage/ui/flow-controller.reel/flow-controller.html delete mode 100644 node_modules/montage/ui/flow-controller.reel/flow-controller.js delete mode 100644 node_modules/montage/ui/flow-offset.js delete mode 100644 node_modules/montage/ui/hottext.reel/hottext.css delete mode 100644 node_modules/montage/ui/hottext.reel/hottext.html delete mode 100644 node_modules/montage/ui/hottext.reel/hottext.js delete mode 100644 node_modules/montage/ui/hottextunit.reel/hottextunit.css delete mode 100644 node_modules/montage/ui/hottextunit.reel/hottextunit.html delete mode 100644 node_modules/montage/ui/hottextunit.reel/hottextunit.js mode change 100644 => 100755 node_modules/montage/ui/image.reel/image.js delete mode 100644 node_modules/montage/ui/image2.reel/image2.html delete mode 100644 node_modules/montage/ui/image2.reel/image2.js delete mode 100644 node_modules/montage/ui/image3d.reel/image3d.html delete mode 100644 node_modules/montage/ui/image3d.reel/image3d.js create mode 100644 node_modules/montage/ui/native-control.js create mode 100644 node_modules/montage/ui/number-input.reel/number-input.js delete mode 100755 node_modules/montage/ui/photo-editor.reel/photo-editor.css delete mode 100755 node_modules/montage/ui/photo-editor.reel/photo-editor.html delete mode 100755 node_modules/montage/ui/photo-editor.reel/photo-editor.js create mode 100755 node_modules/montage/ui/radio-button.reel/radio-button.js create mode 100644 node_modules/montage/ui/range-input.reel/range-input.js create mode 100644 node_modules/montage/ui/select-input.reel/select-input.js delete mode 100644 node_modules/montage/ui/slider-base.js delete mode 100755 node_modules/montage/ui/slider.reel/slider.css delete mode 100755 node_modules/montage/ui/slider.reel/slider.html delete mode 100755 node_modules/montage/ui/slider.reel/slider.js create mode 100644 node_modules/montage/ui/text-input.js delete mode 100755 node_modules/montage/ui/textarea.reel/textarea.css delete mode 100755 node_modules/montage/ui/textarea.reel/textarea.html mode change 100755 => 100644 node_modules/montage/ui/textarea.reel/textarea.js delete mode 100755 node_modules/montage/ui/textfield.reel/textfield.css delete mode 100755 node_modules/montage/ui/textfield.reel/textfield.html mode change 100755 => 100644 node_modules/montage/ui/textfield.reel/textfield.js create mode 100644 node_modules/montage/ui/toggle-button.reel/toggle-button.js create mode 100755 node_modules/montage/ui/toggle-switch.reel/toggle-switch.css create mode 100755 node_modules/montage/ui/toggle-switch.reel/toggle-switch.html create mode 100644 node_modules/montage/ui/toggle-switch.reel/toggle-switch.js delete mode 100755 node_modules/montage/ui/toggle.reel/toggle.css delete mode 100755 node_modules/montage/ui/toggle.reel/toggle.html delete mode 100755 node_modules/montage/ui/toggle.reel/toggle.js diff --git a/js/components/tree.reel/tree.js b/js/components/tree.reel/tree.js index 9c1b07e4..7084ba99 100644 --- a/js/components/tree.reel/tree.js +++ b/js/components/tree.reel/tree.js @@ -6,7 +6,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Montage = require("montage/core/core").Montage; var Component = require("montage/ui/component").Component; -var nj = require("js/lib/NJUtils.js").NJUtils; +var nj = require("js/lib/NJUtils").NJUtils; exports.Tree = Montage.create(Component, { diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index d462bc98..afd298c9 100644 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -7,7 +7,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component, cssShorthandMap = require("js/panels/CSSPanel/css-shorthand-map").CSS_SHORTHAND_MAP, - nj = require("js/lib/NJUtils.js").NJUtils; + nj = require("js/lib/NJUtils").NJUtils; /* diff --git a/js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.js b/js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.js index ae7e5c14..0c950ffd 100644 --- a/js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.js +++ b/js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.js @@ -8,7 +8,7 @@ var cssPropertyNameList = require("js/panels/CSSPanel/css-property-name-lis cssCompletionMap = require("js/panels/CSSPanel/css-value-completion-map").cssValueCompletionMap, CSS_SHORTHAND_MAP = require("js/panels/CSSPanel/css-shorthand-map").CSS_SHORTHAND_MAP, keyboardModule = require("js/mediators/keyboard-mediator").Keyboard, - nj = require("js/lib/NJUtils.js").NJUtils; + nj = require("js/lib/NJUtils").NJUtils; diff --git a/js/panels/CSSPanel/ComputedStyleSubPanel.reel/ComputedStyleSubPanel.js b/js/panels/CSSPanel/ComputedStyleSubPanel.reel/ComputedStyleSubPanel.js index 0e1cf206..bb6f9de6 100644 --- a/js/panels/CSSPanel/ComputedStyleSubPanel.reel/ComputedStyleSubPanel.js +++ b/js/panels/CSSPanel/ComputedStyleSubPanel.reel/ComputedStyleSubPanel.js @@ -6,7 +6,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component, - nj = require("js/lib/NJUtils.js").NJUtils; + nj = require("js/lib/NJUtils").NJUtils; exports.ComputedStyleSubPanel = Montage.create(Component, { diff --git a/js/panels/Project/projectpanelbase.reel/ProjectPanelBase.js b/js/panels/Project/projectpanelbase.reel/ProjectPanelBase.js index 31582153..083dafeb 100644 --- a/js/panels/Project/projectpanelbase.reel/ProjectPanelBase.js +++ b/js/panels/Project/projectpanelbase.reel/ProjectPanelBase.js @@ -6,7 +6,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var TreeControl = require("js/components/tree.reel").Tree, ResizerControl = require("js/panels/Resizer").Resizer, - nj = require("js/lib/NJUtils.js").NJUtils; + nj = require("js/lib/NJUtils").NJUtils; exports.ProjectPanelBase = (require("montage/core/core").Montage).create(require("montage/ui/component").Component, { hasTemplate: { diff --git a/node_modules/montage/core/converter/date-converter.js b/node_modules/montage/core/converter/date-converter.js index b00a5b22..f0d3e540 100755 --- a/node_modules/montage/core/converter/date-converter.js +++ b/node_modules/montage/core/converter/date-converter.js @@ -2573,6 +2573,15 @@ var DateValidator = exports.DateValidator = Montage.create(Validator,/** @lends @class module:montage/core/converter/date-converter.DateConverter */ var DateConverter = exports.DateConverter = Montage.create(Converter,/** @lends module:montage/core/converter/date-converter.DateConverter# */ { + /** + Specifies whether the converter allows partial conversion. + @type {Property} + @default {Boolean} true + */ + allowPartialConversion: { + value: false + }, + /** @type {Property} @default {Function} Montage.create(DateValidator) diff --git a/node_modules/montage/core/core.js b/node_modules/montage/core/core.js index b665f591..8c1f4249 100755 --- a/node_modules/montage/core/core.js +++ b/node_modules/montage/core/core.js @@ -788,7 +788,8 @@ Description */ Object.defineProperty(Object.prototype, "setProperty", { value: function(aPropertyPath, value) { - var lastDotIndex = aPropertyPath.lastIndexOf("."), + var propertyIsNumber = !isNaN(aPropertyPath), + lastDotIndex = propertyIsNumber ? -1 : aPropertyPath.lastIndexOf("."), setObject, lastObjectAtPath, propertyToSetOnArray; @@ -883,9 +884,10 @@ Object.defineProperty(Array.prototype, "getProperty", { currentIndex = currentIndex || 0; var result, - parenthesisStartIndex = aPropertyPath.indexOf("(", currentIndex), - parenthesisEndIndex = aPropertyPath.lastIndexOf(")"), - currentPathComponentEndIndex = aPropertyPath.indexOf(".", currentIndex), + propertyIsNumber = !isNaN(aPropertyPath), + parenthesisStartIndex = propertyIsNumber ? -1 : aPropertyPath.indexOf("(", currentIndex), + parenthesisEndIndex = propertyIsNumber ? -1 : aPropertyPath.lastIndexOf(")"), + currentPathComponentEndIndex = propertyIsNumber ? -1 : aPropertyPath.indexOf(".", currentIndex), nextDelimiterIndex = -1, itemResult, index, @@ -917,7 +919,7 @@ Object.defineProperty(Array.prototype, "getProperty", { } // Find the component of the propertyPath we want to deal with during this particular invocation of this function - currentPathComponent = aPropertyPath.substring(currentIndex, (nextDelimiterIndex === -1 ? aPropertyPath.length : nextDelimiterIndex)); + currentPathComponent = propertyIsNumber ? aPropertyPath : aPropertyPath.substring(currentIndex, (nextDelimiterIndex === -1 ? aPropertyPath.length : nextDelimiterIndex)); // EVALUATE: Determine the value of the currentPathComponent @@ -1115,8 +1117,14 @@ Object.defineProperty(Object.prototype, "parentProperty", { writable: true }); -var EventManager = require("core/event/event-manager").EventManager; -EventManager.create().initWithWindow(window); +// XXX Does not presently function server-side +if (typeof window !== "undefined") { + + var EventManager = require("core/event/event-manager").EventManager; + EventManager.create().initWithWindow(window); + + // Now that we have a defaultEventManager we can setup the bindings system + require("core/event/binding"); + +} -// Now that we have a defaultEventManager we can setup the bindings system -require("core/event/binding"); diff --git a/node_modules/montage/core/deserializer.js b/node_modules/montage/core/deserializer.js index 8f1f0831..09635153 100755 --- a/node_modules/montage/core/deserializer.js +++ b/node_modules/montage/core/deserializer.js @@ -15,11 +15,17 @@ var Montage = require("montage").Montage, logger = require("core/logger").logger("deserializer"), Promise = require("core/promise").Promise; +// By rebinding eval to a new name, it loses its ability to +// capture the calling scope. +var globalEval = eval; + /** @class module:montage/core/deserializer.Deserializer @extends module:montage/core/core.Montage */ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deserializer.Deserializer# */ { + _MONTAGE_ID_ATTRIBUTE: {value: "data-montage-id"}, + _objects: {value: null}, /** @private @@ -51,6 +57,13 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri /** @private */ + + /** + @private + */ + // list of ids that were just created for optimization + _optimizedIds: {value: {}}, + _indexedDeserializationUnits: {value: {}}, __sharedDocument: { @@ -365,6 +378,27 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri this._compileAndDeserialize(); return this._compiledDeserializationFunctionString; }}, + + /** + * Optimizes the current serialization for a specific document. + * @function + * @param {Document} doc The document to optimize against, this document can be modified during optimization. + */ + optimizeForDocument: { + value: function(doc) { + var idAttributeName = Deserializer._MONTAGE_ID_ATTRIBUTE, + elements = doc.querySelectorAll('*[' + idAttributeName + ']'), + ids = this._optimizedIds = {}; + + for (var i = 0, element; (element = elements[i]); i++) { + if (!element.id) { + var attribute = element.getAttribute(idAttributeName); + element.setAttribute("id", ids[attribute] = "_" + idAttributeName + "_" + attribute); + } + } + } + }, + /** @private */ @@ -374,9 +408,12 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri exportsStrings = "", unitsStrings = "", objectsStrings = "", + cleanupStrings = "", valueString, exports = {}, modules = this._modules, + idsToRemove = [], + optimizedIds = this._optimizedIds, requireStrings = [], objectNamesCounter = {}, label; @@ -408,8 +445,17 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri } } - this._compiledDeserializationFunctionString = "(function() {\n" + requireStrings.join("\n") + "\nreturn function(element) {\nvar exports = {};\n" + exportsStrings + "\n\n" + objectsStrings + "\n\n" + unitsStrings + "\nreturn exports;\n}}).call(this)"; - //console.log(this._compiledDeserializationFunctionString); + if (idsToRemove.length > 0) { + cleanupStrings = 'element.getElementById("' + idsToRemove.join('").removeAttribute("id");\nelement.getElementById("') + '").removeAttribute("id");'; + for (var i = 0, id; (id = idsToRemove[i]); i++) { + element.getElementById(idsToRemove[i]).removeAttribute("id"); + } + } + + this._compiledDeserializationFunctionString = "(function() {\n" + requireStrings.join("\n") + "\nreturn function(element) {\nvar exports = {};\n" + exportsStrings + "\n\n" + objectsStrings + "\n\n" + unitsStrings + "\n\n" + cleanupStrings + "\nreturn exports;\n}}).call(this)"; + if (logger.isDebug) { + logger.debug(this._compiledDeserializationFunctionString); + } this._serialization = serialization = null; @@ -490,7 +536,7 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri } else if (value === null) { return "null"; } else if ("#" in value) { - type = "elementById"; + type = "elementByMontageId"; value = value["#"]; } else if ("/" in value) { type = "regexp"; @@ -502,7 +548,7 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri type = "function"; value = value["->"]; } else if ("." in value && Object.keys(value).length === 1) { - console.log("Warning: It's not possible to reference elements by class name anymore: " + JSON.stringify(value) + "' in template " + self._origin + "."); + console.log("Warning: It's not possible to reference elements by class name anymore: '" + JSON.stringify(value) + "' in template " + self._origin + "."); } } @@ -529,15 +575,35 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri return '[' + properties.join(",\n") + ']'; break; - case "elementById": - if (deserialize) { - var node = element.getElementById(value); + case "elementByMontageId": + var id = self._optimizedIds[value], + node; + + if (id) { + node = element.getElementById(id); + idsToRemove.push(id); + } else { + node = element.querySelector('*[' + Deserializer._MONTAGE_ID_ATTRIBUTE + '="' + value + '"]'); if (!node) { - console.log("Warning: Element '#" + value + "' not found in template " + self._origin); + node = element.getElementById(value); + id = value; } + } + + if (!node) { + console.log("Warning: Element " + Deserializer._MONTAGE_ID_ATTRIBUTE + "='" + value + "' not found in template " + self._origin); + } + + if (deserialize) { parent[key] = node; } - return 'element.getElementById("' + value + '")'; + + if (id) { + return 'element.getElementById("' + id + '")'; + } else { + // TODO: getElemenyById only here for backwards compatibility + return 'element.querySelector(\'*[' + Deserializer._MONTAGE_ID_ATTRIBUTE + '="' + value + '"]\') || element.getElementById("' + value + '")'; + } break; case "regexp": @@ -569,7 +635,7 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri case "function": var source = "function" + (value.name ? " " + value.name : "") + "(" + value.arguments.join(", ") + ") {\n" + value.body + "\n}"; if (deserialize) { - parent[key] = (1,eval)('(' + source + ')'); + parent[key] = globalEval('(' + source + ')'); } return source; break; @@ -618,7 +684,6 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri // first run, deserialize and create the source of the compiled deserialization function } else { exports = this._compileAndDeserialize(sourceDocument, true); - //console.log(this._compiledDeserializationFunctionString); } if (targetDocument) { @@ -642,6 +707,20 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri } }, + /** + Deserializes a serialization of a single object using a root element to find elements' references. + @function + @param {Element} element The element to be cloned and used during deserialization of elements' references. + @param {function(object)} callback The callback to be invoked when the object has been fully deserialized. + */ + deserializeObjectWithElement: { + value: function(element, callback) { + return this.deserializeWithInstancesAndElementForDocument(null, element, null, function(exports) { + callback(exports ? exports.root : undefined); + }); + } + }, + /** Deserializes all objects. @function @@ -769,9 +848,6 @@ var Deserializer = Montage.create(Montage, /** @lends module:montage/core/deseri for (var unit in serializedUnits) { var unitFunction = units[unit]; if (unitFunction) { - if (serializedUnits[unit].text) { - //debugger; - } unitFunction(object, serializedUnits[unit]); } } diff --git a/node_modules/montage/core/event/binding.js b/node_modules/montage/core/event/binding.js index 0ce154a1..7a15e5b9 100755 --- a/node_modules/montage/core/event/binding.js +++ b/node_modules/montage/core/event/binding.js @@ -88,10 +88,19 @@ Object.defineProperty(ChangeEventDispatchingArray, "splice", { removedMembers = this._splice.apply(this, arguments); removedCount = removedMembers.length; - // I stopped caring about whether or not this splice could be considered an ADDITION or REMOVAL - // all splices result in a modification now; we could change this if we want to + netChange = addedCount - removedCount; + + // Find the most accurate propertyChange type for this splice, + // For the most part it's considered a modification unless the length of the array was modified + // if only to not bother notifying listeners for changes of the length of this array changeType = ChangeTypes.MODIFICATION; + if (netChange > 0) { + changeType = ChangeTypes.ADDITION; + } else if (netChange < 0) { + changeType = ChangeTypes.REMOVAL; + } + if (this.dispatchChangeEvent) { changeEvent = new ChangeEventConstructor(); changeEvent.minus = removedMembers; @@ -103,8 +112,6 @@ Object.defineProperty(ChangeEventDispatchingArray, "splice", { if (this.dispatchChangeAtIndexEvent) { - netChange = addedCount - removedCount; - if (typeof howMany === "undefined") { // no howMany argument given: remove all elements after index? // TODO this may only be in some implementations @@ -498,7 +505,7 @@ var PropertyChangeBindingListener = exports.PropertyChangeBindingListener = Obje localPrevValue = event.minus, localTarget = event.target, type = event.type, - changeType = event.propertyChange, //MODIFICATION is 1, ADDITION 2, REMOVAL 3, + changeType = event.propertyChange, localPropertyName = event.propertyName, boundObjectValue, sourceObjectValue, @@ -508,7 +515,12 @@ var PropertyChangeBindingListener = exports.PropertyChangeBindingListener = Obje baseType, bindingDescriptor, bindingOrigin = this.bindingOrigin, - leftOriginated; + leftOriginated, + changeOriginPropertyPath = null, + exploredPath, + remainingPath, + i, + localPrevValueCount; if (target !== bindingOrigin) { //the left and the right are different objects; easy enough @@ -617,51 +629,46 @@ var PropertyChangeBindingListener = exports.PropertyChangeBindingListener = Obje event.plus = localNewValue; event.target = localTarget; + if (localPrevValue) { - // Now we know that we handled a particular type of change event - // Depending on what happened we may need to remove listeners from a broken propertyPath or - // install listeners along the modified (or deeper) propertyPath - - // MODIFICATION 1 - if (changeType === 1) { - - if (localPrevValue) { - // TODO remove all the listeners from the localPrev object as far to tne end of the path as possible - // localPrevValue.removeEventListener(baseType, this, this.useCapture); - } - - if (localNewValue) { - // TODO this may be less efficient than we could be, but frankly I don't know how to tell where - // in the path you are by the time you get here, so I'm not sure how to install just the part - // we need, plus addEventListener seems to use the targetPropertyPath from the listener - // regardless of what you pass in fro the eventType. - this.target.addEventListener(baseType + "@" + this.targetPropertyPath, this, this.useCapture); - } + // Determine where along the property path the change originated from so we know how to build the path + // to stop observing on things that were removed + //TODO extract this into a "obj.getPathOfObjectAlongPropertyPath" method or something with proper tests + exploredPath = ""; + this.target.getProperty(this.targetPropertyPath, null, null, function(value, currentPathComponent, result) { - } - //ADDITION 2, REMOVAL 3, typically on collections + if (changeOriginPropertyPath) { + return; + } - //TODO looks like we end up wanting to do the sam thing in both cases right now, I think the TODO in the - // modification explains why a bit. - else { + exploredPath += "." + currentPathComponent; - if (localPrevValue) { + if (result === event.target) { + changeOriginPropertyPath = exploredPath.replace(/^\./, ""); + } + }); - // TODO how do we know the nextPathComponent, we need to know the rest of the path after each - // entry in the localPrevValue array -// for (var i = 0; i < localPrevValue.length; i++) { - localPrevValue.removeEventListener(nextPathComponent ? baseType + "@" + nextPathComponent : baseType, this, this.useCapture); -// } + if (changeOriginPropertyPath) { + remainingPath = this.targetPropertyPath.replace(new RegExp("^" + changeOriginPropertyPath + "\.?"), ""); + } else { + remainingPath = this.targetPropertyPath; } - if (localNewValue) { - this.target.addEventListener(baseType + "@" + this.targetPropertyPath, this, this.useCapture); - } else if (event._event.plus) { - this.target.addEventListener(baseType + "@" + this.targetPropertyPath, this, this.useCapture); + // NOTE this check works around Safari not havin