From 4a3793e9cc498219d246e543a55b543e1b4fb708 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Mon, 30 Jan 2012 11:21:15 -0800 Subject: CSSPanel Updates - Add new original CSS error icon --- js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.css b/js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.css index ff70b5b6..27d19e58 100644 --- a/js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.css +++ b/js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.css @@ -400,7 +400,7 @@ .nj-css-error:not(.nj-css-no-error) { background-repeat: no-repeat; background-position: 3px 2px; - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAAXNSR0IArs4c6QAAAMtJREFUGJV1kM0KAXEUxc/SWh7MM0zJE3gQCxM2EpJ8bEiNjWHhBWYjYkUkRdQoGde5f2Q03PrV6ZzTrXuB0MgQiU0ba0U1/k3gwBYXoqj+WeKG2LaBgwxYJEbTixa7yMyLLPlLw6xATS9SXDWx25cZ7sYG1ep9b3OR8h3cTyUWtyMylnMNcqGn2WdbHQs94FqFnPtxg2r1NHsfkTx0EMiEG7IMpy2D0fSOPWbsgD/zzEtoik323hP75THTDvJpVHIW5I1t4aaEPe08AF+CuEXWXJtHAAAAAElFTkSuQmCC); + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAALCAYAAABGbhwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw%2FeHBhY2tldCBiZWdpbj0i77u%2FIiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8%2BIDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNS4xIE1hY2ludG9zaCIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDowMzYyMERFNTQwNzMxMUUxQTREQ0IxQTRGNEI2MTE3RiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDowMzYyMERFNjQwNzMxMUUxQTREQ0IxQTRGNEI2MTE3RiI%2BIDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjAzNjIwREUzNDA3MzExRTFBNERDQjFBNEY0QjYxMTdGIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjAzNjIwREU0NDA3MzExRTFBNERDQjFBNEY0QjYxMTdGIi8%2BIDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY%2BIDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8%2Bc4fwegAAAWpJREFUeNo8kLtLA0EQxr%2B9l3lcDAaCBsEqEOysBFEQsRAsRVCEpBREsbIUSxtBrAxEewsrK8VHQIhK%2FoIUUVJIQFFjYi65XDZ36%2Bz5GFgWZr75fjPDhBD4C%2BucjWgaphjQdTgK%2FfPi5a%2FGpPDtjEVjERyqKlag%2FlY8gHPsfzSwPbQgbDyfIs6vURa3EKK8Jf6jmhUy51yiWDlBUDED2NF0JKGQS3IPVn4ATXqIL0EYJgwD42YQG4quE45EggOtCwbWrUM1Ej%2F0jkXDAYaOtOa6iIH2YSQOBugPj4KN3aFdnIThkprynoeUYjtwIRO0hCLxiU3wp12odgl0AXhUa3VQ0xoWCqEApiNhEpFzt7Tm%2F4Tzo9kGvtq4UjNzqJB1mswURvNoqayP57V7KcB7HfZnE8v%2BHYtZtmiGcBzqQ1TSZUPP85HVlo1MfCaX94WPpSO83qwO6wbWCTtBQocoD70eDgZncw3Z%2BC3AAFMzlxlnnpevAAAAAElFTkSuQmCC); opacity: 0.5; } .nj-editing.nj-css-error { -- cgit v1.2.3 From 086ade64bb2f5bcc7b6126b5e83c4efccc10ef43 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 31 Jan 2012 08:35:59 +0800 Subject: Adding a version json object to Ninja Versions object to start keeping track of versions for Ninja, Montage and eventually other dependencies. Loaded before montage to use in the splash screen. Signed-off-by: Valerio Virgillito --- js/ninja.reel/ninja.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js') diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index bc31e0e1..75ec7fcc 100644 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -36,6 +36,7 @@ exports.Ninja = Montage.create(Component, { prepareForDraw: { value: function() { + console.log("Loading Ninja --> ", window.ninjaVersion.ninja.version); this.application.ninja = this; -- cgit v1.2.3 From a4fcd3237432a361e9a07c7fe3d75128e6c99d1c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 31 Jan 2012 08:36:31 +0800 Subject: Code cleanup - Removed extra log. Signed-off-by: Valerio Virgillito --- js/preloader/Preloader.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js') diff --git a/js/preloader/Preloader.js b/js/preloader/Preloader.js index f137f4b6..93d71e8f 100755 --- a/js/preloader/Preloader.js +++ b/js/preloader/Preloader.js @@ -136,7 +136,6 @@ exports.Preloader = Montage.create(Component, { deserializedFromTemplate: { value: function() { - console.log("Start Preloading"); this.filesTotal = this.ninjaJsRequire.length + this.ninjaCssRequire.length; -- cgit v1.2.3 From df018322f823392fd7da56a42cddcab5473b0f0a Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 31 Jan 2012 08:57:57 +0800 Subject: Adding the version to the main Ninja reel component. Signed-off-by: Valerio Virgillito --- js/ninja.reel/ninja.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index 75ec7fcc..465533cd 100644 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -13,6 +13,10 @@ exports.Ninja = Montage.create(Component, { _appLoaded: { value: false }, _preload: { value: false }, + ninjaVersion: { + value: window.ninjaVersion.ninja.version + }, + toolsData: { value: null }, appData: { value: AppData }, @@ -36,7 +40,7 @@ exports.Ninja = Montage.create(Component, { prepareForDraw: { value: function() { - console.log("Loading Ninja --> ", window.ninjaVersion.ninja.version); + console.log("Loading Ninja --> ", this.ninjaVersion); this.application.ninja = this; -- cgit v1.2.3 From 1d8af9fb2be85c33ce6a846f97360ba2ee17ea23 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 31 Jan 2012 01:54:55 +0800 Subject: Checkbox and Combobox change/changing events were not setting wasSetByCode property correctly, causing our PI to dispatch events at improper times. Signed-off-by: Nivesh Rajbhandari --- js/components/combobox.reel/combobox.js | 2 +- js/components/radio.reel/radio.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/components/combobox.reel/combobox.js b/js/components/combobox.reel/combobox.js index f262bb06..a68a7d6b 100644 --- a/js/components/combobox.reel/combobox.js +++ b/js/components/combobox.reel/combobox.js @@ -67,7 +67,7 @@ exports.Combobox = Montage.create(Component, { var e = document.createEvent("CustomEvent"); e.initEvent("change", true, true); e.type = "change"; - e._wasSetByCode = this._wasSetByCode; + e.wasSetByCode = this._wasSetByCode; e.value = this._value; this.dispatchEvent(e); diff --git a/js/components/radio.reel/radio.js b/js/components/radio.reel/radio.js index 954da3c4..c661ec11 100644 --- a/js/components/radio.reel/radio.js +++ b/js/components/radio.reel/radio.js @@ -41,7 +41,7 @@ exports.RadioGroup = Montage.create(Component, { e = document.createEvent("CustomEvent"); e.initEvent("change", true, true); e.type = "change"; - e._wasSetByCode = this._wasSetByCode; + e.wasSetByCode = this._wasSetByCode; e.selectedIndex = i; e.selectedItem = value; this.dispatchEvent(e); @@ -77,7 +77,7 @@ exports.RadioGroup = Montage.create(Component, { { value:function(event) { - this._wasSetByCode = event._event._wasSetByCode; + this._wasSetByCode = event._event.wasSetByCode; this.selectedItem = event._event.value; } } @@ -126,7 +126,7 @@ exports.Radio = Montage.create(Component, { var e = document.createEvent("CustomEvent"); e.initEvent("change", true, true); e.type = "change"; - e._wasSetByCode = this._wasSetByCode; + e.wasSetByCode = this._wasSetByCode; e.value = this; this.dispatchEvent(e); -- cgit v1.2.3 From b01b586a26ae47d329bdd5fe005051513711fab7 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 31 Jan 2012 15:11:04 -0800 Subject: Fixing the bread-crumb background The CSS cleanup added a background to the bottom panel container which broke the bread-crumb background. Fixing by adding the background directly to the bread-crumb component. Signed-off-by: Valerio Virgillito --- js/components/layout/bread-crumb.reel/bread-crumb.css | 1 + 1 file changed, 1 insertion(+) (limited to 'js') diff --git a/js/components/layout/bread-crumb.reel/bread-crumb.css b/js/components/layout/bread-crumb.reel/bread-crumb.css index f84c6e80..cc984609 100644 --- a/js/components/layout/bread-crumb.reel/bread-crumb.css +++ b/js/components/layout/bread-crumb.reel/bread-crumb.css @@ -5,6 +5,7 @@ */ .bread_crumb{ + background-color: #282828; border-style: double; height: 26px; } -- cgit v1.2.3 From 5233508614656c529d6c596f7e2f2c24adce9b69 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 30 Jan 2012 15:18:50 -0800 Subject: IKNINJA-1083 Fixing minor bug with no color breaking on null alpha value. --- js/panels/Color/colorchippopup.reel/colorchippopup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/panels/Color/colorchippopup.reel/colorchippopup.js b/js/panels/Color/colorchippopup.reel/colorchippopup.js index 03e14b28..05bcb447 100644 --- a/js/panels/Color/colorchippopup.reel/colorchippopup.js +++ b/js/panels/Color/colorchippopup.reel/colorchippopup.js @@ -109,7 +109,7 @@ exports.ColorChipPopup = Montage.create(Component, { this.cc_hexinput.labelFunction = this._hexLabel.bind(this); this.cc_hexinput.inputFunction = this._hexInput.bind(this); // - if (this.application.ninja.colorController.colorView.currentChip && this.application.ninja.colorController.colorView.currentChip.colorValue.a) { + if (this.application.ninja.colorController.colorView.currentChip && this.application.ninja.colorController.colorView.currentChip.colorValue && this.application.ninja.colorController.colorView.currentChip.colorValue.a) { this.combo.slider.value = Math.round(this.application.ninja.colorController.colorView.currentChip.colorValue.a*100); } else { this.combo.slider.value = 100; -- cgit v1.2.3 From 2e24eaa71b260fd11632d8a124874b238c9aa82a Mon Sep 17 00:00:00 2001 From: Jon Reid Date: Wed, 1 Feb 2012 16:02:37 -0800 Subject: Delete unneeded compass log file (IKNINJA 1101). Update base styles for better colors on HTML buttons. Change project panel so it shows no project by default. --- js/panels/Project/projectpanelbase.reel/ProjectPanelBase.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/panels/Project/projectpanelbase.reel/ProjectPanelBase.js b/js/panels/Project/projectpanelbase.reel/ProjectPanelBase.js index 31582153..e5173005 100644 --- a/js/panels/Project/projectpanelbase.reel/ProjectPanelBase.js +++ b/js/panels/Project/projectpanelbase.reel/ProjectPanelBase.js @@ -577,11 +577,11 @@ exports.ProjectPanelBase = (require("montage/core/core").Montage).create(require arrLinkedScrollersLength = arrLinkedScrollers.length, i = 0, that = this; - + /* if (this.firstTimeDraw) { this.hasActiveProject="large"; } - + */ if (!this.hasActiveProject) { -- 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 (limited to '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(-) (limited to 'js') 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 (limited to '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 +- js/panels/CSSPanel/CSSPanelBase.reel/CSSPanelBase.js | 2 +- js/panels/CSSPanel/ComputedStyleSubPanel.reel/ComputedStyleSubPanel.js | 2 +- js/panels/Project/projectpanelbase.reel/ProjectPanelBase.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to '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: { -- cgit v1.2.3 From 834e362e33113fd00e7568a67f108f836bf87ce9 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 2 Feb 2012 11:30:02 -0800 Subject: Fixed the color popups to work with m-js v6 Removed the wrapper DIV, now it's more direct to create and insert the content in the popups. Changes created DOM exceptions, so it had to be modified. --- js/panels/Color/colorpopup-manager.js | 64 ++++++++++++++--------------------- 1 file changed, 25 insertions(+), 39 deletions(-) (limited to 'js') diff --git a/js/panels/Color/colorpopup-manager.js b/js/panels/Color/colorpopup-manager.js index 943ec7e7..a4c9a8c2 100644 --- a/js/panels/Color/colorpopup-manager.js +++ b/js/panels/Color/colorpopup-manager.js @@ -161,11 +161,13 @@ exports.ColorPopupManager = Montage.create(Component, { //////////////////////////////////////////////////// //Creating popup from m-js component var popup = document.createElement('div'); + document.body.appendChild(popup); // this._popupBase = ColorPanelPopup.create(); - this._popupBase.content = document.createElement('div'); + this._popupBase.element = popup; this._popupBase.props = {x: x, y: y, side: side, align: align}; - + this._popupBase.colorManager = this.colorManager; + //TODO: Remove if (this._hackOffset) { this._popupBase.hack = {x: 53, y: 235}; } else { @@ -173,20 +175,10 @@ exports.ColorPopupManager = Montage.create(Component, { this._popupBase.hack = {x: 0, y: 0}; } // - document.body.appendChild(popup); - document.body.appendChild(this._popupBase.content); - //Setting color panel for reference when drawing - //this._popupBase.colorPanel = this; - this._popupBase.colorManager = this.colorManager; - //Setting up events this._popupBase.addEventListener('change', this, false); - this._popupBase.addEventListener('changing', this, false); - //TODO: Use m-js popup or check m-js fix of nested drawing components - this._popupBase.element = popup; - this._popupBase.needsDraw = true; - //Adding drawn element to container - this._popupBase.content.appendChild(this._popupBase.element); - //Waiting for content to drawn before loading popup + this._popupBase.addEventListener('changing', this, false); + // + this._popupBase.needsDraw = true; this._popupBase.addEventListener('firstDraw', this, false); } } @@ -286,41 +278,33 @@ exports.ColorPopupManager = Montage.create(Component, { //////////////////////////////////////////////////// //Creating popup from m-js component var popup = document.createElement('div'); + document.body.appendChild(popup); // - this._popupChipBase = ColorChipPopup.create(); - this._popupChipBase.content = document.createElement('div'); this._popupChip.event = e._event; - // + this._popupChipBase = ColorChipPopup.create(); + this._popupChipBase.element = popup; + this._popupChipBase.colorManager = this.colorManager; if (e._event.srcElement.props) { this.colorChipProps = e._event.srcElement.props; } else { this.colorChipProps = {side: 'top', align: 'center', wheel: true, palette: true, gradient: true, image: true, panel: false}; } // - if (!this.colorChipProps.panel) { + if (!this.colorChipProps.panel) { this.hideColorPopup(); } // - document.body.appendChild(popup); - document.body.appendChild(this._popupChipBase.content); - //Setting color panel for reference when drawing - //popupBase.colorPanel = this; - this._popupChipBase.colorManager = this.colorManager; - // + this._popupChipBase.popupModes = {}; this._popupChipBase.popupModes.gradient = this.colorChipProps.gradient; this._popupChipBase.popupModes.image = this.colorChipProps.image; this._popupChipBase.popupModes.wheel = this.colorChipProps.wheel; this._popupChipBase.popupModes.palette = this.colorChipProps.palette; - this._popupChipBase.popupModes.nocolor = this.colorChipProps.nocolor; - //Setting up events + this._popupChipBase.popupModes.nocolor = this.colorChipProps.nocolor; + // this._popupChipBase.addEventListener('change', this, false); - this._popupChipBase.addEventListener('changing', this, false); - //TODO: Use m-js popup or check m-js fix of nested drawing components - this._popupChipBase.element = popup; - this._popupChipBase.needsDraw = true; - //Adding drawn element to container - this._popupChipBase.content.appendChild(this._popupChipBase.element); - //Waiting for content to drawn before loading popup + this._popupChipBase.addEventListener('changing', this, false); + // + this._popupChipBase.needsDraw = true; this._popupChipBase.addEventListener('firstDraw', this, false); } } @@ -354,14 +338,14 @@ exports.ColorPopupManager = Montage.create(Component, { if (e._target._element.className === 'cpp_popup') { this._popupBase.removeEventListener('firstDraw', this, false); //Creating an instance of the popup and sending in created color popup content - this._popupPanel.popup = this.application.ninja.popupManager.createPopup(this._popupBase.content, {x: this._popupBase.props.x, y: this._popupBase.props.y}, {side: this._popupBase.props.side, align: this._popupBase.props.align}); + this._popupPanel.popup = this.application.ninja.popupManager.createPopup(this._popupBase.element, {x: this._popupBase.props.x, y: this._popupBase.props.y}, {side: this._popupBase.props.side, align: this._popupBase.props.align}); //Displaying popup once it's drawn this._popupPanel.popup.addEventListener('firstDraw', this, false); //Hiding popup while it draws this._popupPanel.popup.element.style.opacity = 0; //Storing popup for use when closing this._popupPanel.popup.base = this._popupBase; - } else if (e._target._element.className === 'default_popup' && e._target._content.firstChild.className === 'cpp_popup') { + } else if (e._target._element.className === 'default_popup' && e._target._content.className === 'cpp_popup') { // this._colorPopupDrawing = false; // @@ -371,11 +355,12 @@ exports.ColorPopupManager = Montage.create(Component, { //Popup was added, so it's opened this._popupPanel.opened = true; } else if (e._target._element.className === 'cc_popup') { + this._popupChipBase.removeEventListener('firstDraw', this, false); //Creating an instance of the popup and sending in created color popup content if (this.colorChipProps.offset) { - this._popupChip.popup = this.application.ninja.popupManager.createPopup(this._popupChipBase.content, {x: (this._popupChip.event.clientX - this._popupChip.event.offsetX + this.colorChipProps.offset)+'px', y: (this._popupChip.event.target.clientHeight/2+this._popupChip.event.clientY - this._popupChip.event.offsetY)+'px'}, {side: this.colorChipProps.side, align: this.colorChipProps.align}); + this._popupChip.popup = this.application.ninja.popupManager.createPopup(this._popupChipBase.element, {x: (this._popupChip.event.clientX - this._popupChip.event.offsetX + this.colorChipProps.offset)+'px', y: (this._popupChip.event.target.clientHeight/2+this._popupChip.event.clientY - this._popupChip.event.offsetY)+'px'}, {side: this.colorChipProps.side, align: this.colorChipProps.align}); } else { - this._popupChip.popup = this.application.ninja.popupManager.createPopup(this._popupChipBase.content, {x: (this._popupChip.event.clientX - this._popupChip.event.offsetX)+'px', y: (this._popupChip.event.target.clientHeight/2+this._popupChip.event.clientY - this._popupChip.event.offsetY)+'px'}, {side: this.colorChipProps.side, align: this.colorChipProps.align}); + this._popupChip.popup = this.application.ninja.popupManager.createPopup(this._popupChipBase.element, {x: (this._popupChip.event.clientX - this._popupChip.event.offsetX)+'px', y: (this._popupChip.event.target.clientHeight/2+this._popupChip.event.clientY - this._popupChip.event.offsetY)+'px'}, {side: this.colorChipProps.side, align: this.colorChipProps.align}); } // if (!this.colorChipProps.panel) { @@ -387,7 +372,8 @@ exports.ColorPopupManager = Montage.create(Component, { this._popupChip.popup.base = this._popupChipBase; //Displaying popup once it's drawn this._popupChip.popup.addEventListener('firstDraw', this, false); - } else if (e._target._element.className === 'default_popup' && e._target._content.firstChild.className === 'cc_popup') { + } else if (e._target._element.className === 'default_popup' && e._target._content.className === 'cc_popup') { + this._popupChip.popup.removeEventListener('firstDraw', this, false); // this._colorChipPopupDrawing = false; // -- cgit v1.2.3 From c7b5089b6cea5304cd94e3f25a760919748abfef Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 31 Jan 2012 01:54:55 +0800 Subject: Checkbox and Combobox change/changing events were not setting wasSetByCode property correctly, causing our PI to dispatch events at improper times. Signed-off-by: Nivesh Rajbhandari --- js/components/combobox.reel/combobox.js | 2 +- js/components/radio.reel/radio.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/components/combobox.reel/combobox.js b/js/components/combobox.reel/combobox.js index f262bb06..a68a7d6b 100644 --- a/js/components/combobox.reel/combobox.js +++ b/js/components/combobox.reel/combobox.js @@ -67,7 +67,7 @@ exports.Combobox = Montage.create(Component, { var e = document.createEvent("CustomEvent"); e.initEvent("change", true, true); e.type = "change"; - e._wasSetByCode = this._wasSetByCode; + e.wasSetByCode = this._wasSetByCode; e.value = this._value; this.dispatchEvent(e); diff --git a/js/components/radio.reel/radio.js b/js/components/radio.reel/radio.js index 954da3c4..c661ec11 100644 --- a/js/components/radio.reel/radio.js +++ b/js/components/radio.reel/radio.js @@ -41,7 +41,7 @@ exports.RadioGroup = Montage.create(Component, { e = document.createEvent("CustomEvent"); e.initEvent("change", true, true); e.type = "change"; - e._wasSetByCode = this._wasSetByCode; + e.wasSetByCode = this._wasSetByCode; e.selectedIndex = i; e.selectedItem = value; this.dispatchEvent(e); @@ -77,7 +77,7 @@ exports.RadioGroup = Montage.create(Component, { { value:function(event) { - this._wasSetByCode = event._event._wasSetByCode; + this._wasSetByCode = event._event.wasSetByCode; this.selectedItem = event._event.value; } } @@ -126,7 +126,7 @@ exports.Radio = Montage.create(Component, { var e = document.createEvent("CustomEvent"); e.initEvent("change", true, true); e.type = "change"; - e._wasSetByCode = this._wasSetByCode; + e.wasSetByCode = this._wasSetByCode; e.value = this; this.dispatchEvent(e); -- cgit v1.2.3 From 51061ead1bd6cbb8568287724b3e23cf9f5a3b17 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 31 Jan 2012 15:11:04 -0800 Subject: Fixing the bread-crumb background The CSS cleanup added a background to the bottom panel container which broke the bread-crumb background. Fixing by adding the background directly to the bread-crumb component. Signed-off-by: Valerio Virgillito --- js/components/layout/bread-crumb.reel/bread-crumb.css | 1 + 1 file changed, 1 insertion(+) (limited to 'js') diff --git a/js/components/layout/bread-crumb.reel/bread-crumb.css b/js/components/layout/bread-crumb.reel/bread-crumb.css index f84c6e80..cc984609 100644 --- a/js/components/layout/bread-crumb.reel/bread-crumb.css +++ b/js/components/layout/bread-crumb.reel/bread-crumb.css @@ -5,6 +5,7 @@ */ .bread_crumb{ + background-color: #282828; border-style: double; height: 26px; } -- cgit v1.2.3 From 57836b24aca08de591bece3e5878caaceadf5c57 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 30 Jan 2012 15:18:50 -0800 Subject: IKNINJA-1083 Fixing minor bug with no color breaking on null alpha value. --- js/panels/Color/colorchippopup.reel/colorchippopup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/panels/Color/colorchippopup.reel/colorchippopup.js b/js/panels/Color/colorchippopup.reel/colorchippopup.js index 03e14b28..05bcb447 100644 --- a/js/panels/Color/colorchippopup.reel/colorchippopup.js +++ b/js/panels/Color/colorchippopup.reel/colorchippopup.js @@ -109,7 +109,7 @@ exports.ColorChipPopup = Montage.create(Component, { this.cc_hexinput.labelFunction = this._hexLabel.bind(this); this.cc_hexinput.inputFunction = this._hexInput.bind(this); // - if (this.application.ninja.colorController.colorView.currentChip && this.application.ninja.colorController.colorView.currentChip.colorValue.a) { + if (this.application.ninja.colorController.colorView.currentChip && this.application.ninja.colorController.colorView.currentChip.colorValue && this.application.ninja.colorController.colorView.currentChip.colorValue.a) { this.combo.slider.value = Math.round(this.application.ninja.colorController.colorView.currentChip.colorValue.a*100); } else { this.combo.slider.value = 100; -- cgit v1.2.3 From 54f9f6ebfb495feed695cf12a0f245f535cd3372 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 2 Feb 2012 15:17:16 -0800 Subject: Switching to alternate dashed line function. Adding code attributions. Signed-off-by: Valerio Virgillito --- js/stage/layout.js | 53 ++++------------------------------------------------- 1 file changed, 4 insertions(+), 49 deletions(-) (limited to 'js') diff --git a/js/stage/layout.js b/js/stage/layout.js index 625c09ad..1e712550 100644 --- a/js/stage/layout.js +++ b/js/stage/layout.js @@ -282,8 +282,9 @@ exports.Layout = Montage.create(Component, { } }, - // Alternate dashed line method. - ___dashedLine: { + // Dashed line function found at http://stackoverflow.com/questions/4576724/dotted-stroke-in-canvas/ + // Portions used with permission of Gavin Kistner (phrogz) + _dashedLine: { value: function(x, y, x2, y2, dashArray) { this.ctx.lineCap = "square"; this.ctx.beginPath(); @@ -303,7 +304,7 @@ exports.Layout = Montage.create(Component, { var step = Math.sqrt(dashLength * dashLength / (1 + slope * slope)); if(xSlope){ if(dx < 0) step = -step; - x += step + x += step; y += slope * step; }else{ if(dy < 0) step = -step; @@ -321,52 +322,6 @@ exports.Layout = Montage.create(Component, { } }, - _dashedLine: { - value: function (fromX, fromY, toX, toY, pattern){ - this.ctx.beginPath(); - // Our growth rate for our line can be one of the following: - // (+,+), (+,-), (-,+), (-,-) - // Because of this, our algorithm needs to understand if the x-coord and - // y-coord should be getting smaller or larger and properly cap the values - // based on (x,y). - var lt = function (a, b) { return a <= b; }; - var gt = function (a, b) { return a >= b; }; - var capmin = function (a, b) { return Math.min(a, b); }; - var capmax = function (a, b) { return Math.max(a, b); }; - - var checkX = { thereYet: gt, cap: capmin }; - var checkY = { thereYet: gt, cap: capmin }; - - if (fromY - toY > 0) { - checkY.thereYet = lt; - checkY.cap = capmax; - } - if (fromX - toX > 0) { - checkX.thereYet = lt; - checkX.cap = capmax; - } - - this.ctx.moveTo(fromX, fromY); - var offsetX = fromX; - var offsetY = fromY; - var idx = 0, dash = true; - while (!(checkX.thereYet(offsetX, toX) && checkY.thereYet(offsetY, toY))) { - var ang = Math.atan2(toY - fromY, toX - fromX); - var len = pattern[idx]; - - offsetX = checkX.cap(toX, offsetX + (Math.cos(ang) * len)); - offsetY = checkY.cap(toY, offsetY + (Math.sin(ang) * len)); - - if (dash) this.ctx.lineTo(offsetX, offsetY); - else this.ctx.moveTo(offsetX, offsetY); - - idx = (idx + 1) % pattern.length; - dash = !dash; - } - this.ctx.stroke(); - } - }, - _elementName: { value: function(item) { return this.application.ninja.elementMediator.getNJProperty(item, "selection"); -- cgit v1.2.3 From 7e23cfe542f29148ed315586830785de59201f92 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 (limited to '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