From a5ee11857f923d3e49b44c0a8c480e9d0b026d5b Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Wed, 22 Feb 2012 23:18:12 -0800 Subject: CSS Panel Update --- js/controllers/styles-controller.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 44ca50e1..aa5a4e7f 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -94,11 +94,18 @@ var stylesController = exports.StylesController = Montage.create(Component, { // Returns null if sheet not found (as in non-ninja projects) // Setter will handle null case this.defaultStylesheet = this.getSheetFromElement(this.CONST.DEFAULT_SHEET_ID); - - //debugger; + + this.userStyleSheets = nj.toArray(document._document.styleSheets).filter(function(sheet) { + return sheet !== this._stageStylesheet; + }, this); + + NJevent('styleSheetsReady', this); }, enumerable : false }, + userStyleSheets : { + value : null + }, _stageStylesheet : { value : null }, -- cgit v1.2.3 From 1433f2bdf2e5b8c5c18fed5e9c17fd983ab3606d Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Fri, 2 Mar 2012 10:55:51 -0800 Subject: CSS Panel - Updating components, created toolbar components, and small changes to styles controller --- js/controllers/styles-controller.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 33084169..d36c8cb9 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -190,6 +190,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// attach specificity to rule object ///// if rule is css keyframes, return rule and don't attach specificity if (rule instanceof WebKitCSSKeyframesRule) { + return rule; } rule[this.CONST.SPECIFICITY_KEY] = this.getSpecificity(rule.selectorText); @@ -1184,6 +1185,8 @@ var stylesController = exports.StylesController = Montage.create(Component, { this.styleSheetModified(sheet); + NJevent('newStyleSheet', sheet); + return sheet; } }, @@ -1243,11 +1246,16 @@ var stylesController = exports.StylesController = Montage.create(Component, { clearDirtyStyleSheets : { value: function(doc) { - if(!doc) { + this.dirtyStyleSheets.length = 0; + + if(doc) { this.dirtyStyleSheets = null; - this.dirtyStyleSheets = []; + this.dirtyStyleSheets = this.dirtyStyleSheets.filter(function(sheet) { + return sheet.document !== doc; + }); } + } }, -- cgit v1.2.3 From 4ba680a7e9168d0f505a81e42a287dfbc54b4d7d Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 1 May 2012 15:26:37 -0700 Subject: Preliminary IO to new DOM view --- js/controllers/document-controller.js | 2 +- js/controllers/selection-controller.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 7795a74d..bb0f542f 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -366,7 +366,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, case 'html': //Open in designer view this._hackRootFlag = false; - Montage.create(Document).init(doc, this, this._onOpenDocument); + Montage.create(Document).init(doc, this, this._onOpenDocument, 'design'); break; default: //Open in code view diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 5665b09c..2bd774f5 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -152,7 +152,6 @@ exports.SelectionController = Montage.create(Component, { selectElement: { value: function(element) { - if(this.findSelectedElement(element) === -1) { if(this.application.ninja.currentDocument.inExclusion(element) !== -1){ -- cgit v1.2.3 From 9617e4d3870c9872dc1837a67a6f927fd2680476 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Tue, 1 May 2012 16:23:43 -0700 Subject: Styles Controller - Fix error when trying dispatch stylesheet change event --- js/controllers/styles-controller.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index f7c98023..3422427c 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -803,7 +803,9 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// method to apply/test the new value dec.setProperty(property, value, priority); - this.styleSheetModified(rule.parentStyleSheet); + if(rule.parentStyleSheet) { + this.styleSheetModified(rule.parentStyleSheet); + } ///// Return browser value for value we just set return dec.getPropertyValue(property); -- cgit v1.2.3 From 8f1385d4aa12173fb4d9af695b8e5036f675b621 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 4 May 2012 14:39:33 -0700 Subject: Fixing selection and layout code to exclude SCRIPT and STYLE tags. Signed-off-by: Nivesh Rajbhandari --- js/controllers/selection-controller.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 5665b09c..77c065ae 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -112,12 +112,12 @@ exports.SelectionController = Montage.create(Component, { handleSelectAll: { value: function(event) { - var selected = [], childNodes = []; + var selected = [], childNodes = [], self = this; childNodes = this.application.ninja.currentDocument.documentRoot.childNodes; childNodes = Array.prototype.slice.call(childNodes, 0); childNodes.forEach(function(item) { - if(item.nodeType == 1) { + if(self.isNodeTraversable(item)) { selected.push(item); } }); @@ -281,6 +281,13 @@ exports.SelectionController = Montage.create(Component, { return -1; } + }, + + isNodeTraversable: { + value: function( item ) { + if(item.nodeType !== 1) return false; + return ((item.nodeName !== "STYLE") && (item.nodeName !== "SCRIPT")); + } } }); -- cgit v1.2.3 From 8f8f7f9a36fb9abadea2a9f25aef0084946bebc9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 4 May 2012 14:42:00 -0700 Subject: Removed special-casing for new template workflow. Instead, we will enforce a width and height on the body in order to do 3d. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/body-controller.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'js/controllers') diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js index 14aeae24..943594f2 100755 --- a/js/controllers/elements/body-controller.js +++ b/js/controllers/elements/body-controller.js @@ -28,11 +28,39 @@ exports.BodyController = Montage.create(ElementController, { getProperty: { value: function(el, p) { + switch(p) { + case "background" : + return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-color", true, true)); + case "border": + return 0; + case "height": + case "width": + case "-webkit-transform-style": + return this.application.ninja.stylesController.getElementStyle(el, p, true, true); + default: + return ElementController.getProperty(el, p, true, true); + //console.log("Undefined Stage property ", p); + } } }, setProperty: { value: function(el, p, value) { + switch(p) { + case "body-background": + case "background": + this.application.ninja.stylesController.setElementStyle(el, "background-color", value, true); + break; + case "overflow": + case "width": + case "height": + case "-webkit-transform-style": + this.application.ninja.stylesController.setElementStyle(el, p, value, true); + this.application.ninja.stage.updatedStage = true; + break; + default: + console.log("Undefined property ", p, "for the Body Controller"); + } } }, -- cgit v1.2.3 From a62f57cf6beee332ff60a48f5e26d0084b4a5432 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Mon, 7 May 2012 10:38:29 -0700 Subject: Style sheets - Add sheet action --- js/controllers/styles-controller.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/controllers') diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 3422427c..dfe7c69a 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -1252,6 +1252,8 @@ var stylesController = exports.StylesController = Montage.create(Component, { doc.head.appendChild(sheetElement); sheet = this.getSheetFromElement(sheetElement, doc); + this.userStyleSheets.push(sheet); + this.styleSheetModified(sheet); NJevent('newStyleSheet', sheet); -- cgit v1.2.3 From 4504972c1f3b9bf1d02a4484a07a8a85cf9ccee2 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 8 May 2012 10:37:38 -0700 Subject: Adding Chrome Preview --- js/controllers/document-controller.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 803519a7..6a25420a 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -88,7 +88,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, - + //TODO: Ensure these APIs are not needed + /* //////////////////////////////////////////////////////////////////// // handleWebRequest: { @@ -119,6 +120,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } }, //////////////////////////////////////////////////////////////////// +*/ -- cgit v1.2.3 From a1e8540f5656e62db6a89f3af7829be6b259b7ed Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 8 May 2012 17:33:13 -0700 Subject: Adding SAVE for I/O Adding save functionality to new template. Need to implement user UI for prompts and also clean up... --- js/controllers/document-controller.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 6a25420a..ed4d33eb 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -166,23 +166,34 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } }, //////////////////////////////////////////////////////////////////// - //TODO: Check for appropiate structures + // handleExecuteSave: { value: function(event) { - if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ - //Text and HTML document classes should return the same save object for fileSave - this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this)); - } + // + if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ + // + this.activeDocument.model.save(this.testCallback.bind(this)); //this.fileSaveResult.bind(this) + } else { + //Error: + } } }, + testCallback: { + value: function (value) { + console.log(value); + } + }, //////////////////////////////////////////////////////////////////// //TODO: Check for appropiate structures handleExecuteSaveAll: { value: function(event) { - if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ - //Text and HTML document classes should return the same save object for fileSave - this.application.ninja.ioMediator.fileSave(this.activeDocument.saveAll(), this.fileSaveResult.bind(this)); - } + // + if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ + // + this.activeDocument.model.saveAll(this.testCallback.bind(this)); //this.fileSaveResult.bind(this) + } else { + //Error: + } } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 9ff89d41048d056ddab4c15b4e9e74bc5417c883 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 9 May 2012 18:12:48 -0700 Subject: Adding support to save body's css styles on preview. Signed-off-by: Nivesh Rajbhandari --- js/controllers/document-controller.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 17ae8cc3..682bd6a6 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -498,6 +498,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.webTemplate = false; + this._initializeBodyStyles(); NJevent("onOpenDocument", doc); this.application.ninja.stage.stageView.showCodeViewBar(false); @@ -645,5 +646,37 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value:function(){ this.activeDocument.needsSave = true; } + }, + + _initializeBodyStyles: { + value: function() { + var sc = this.application.ninja.stylesController, + docRoot = this.application.ninja.currentDocument.documentRoot, + styles = {}, + needsRule = false, + rule; + + if(sc.getElementStyle(docRoot, "width", false, false) == null) { + styles['width'] = '100%'; + needsRule = true; + } + if(sc.getElementStyle(docRoot, "height", false, false) == null) { + styles['height'] = '100%'; + needsRule = true; + } + if(sc.getElementStyle(docRoot, "-webkit-transform", false, false) == null) { + styles['-webkit-transform'] = 'perspective(1400) matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'; + needsRule = true; + } + if(sc.getElementStyle(docRoot, "-webkit-transform-style", false, false) == null) { + styles['-webkit-transform-style'] = 'preserve-3d'; + needsRule = true; + } + + if(needsRule) { + rule = sc.addRule('body{}'); + sc.setStyles(rule, styles); + } + } } }); -- cgit v1.2.3 From 0cbfa32fa4e62be128b6478dcba0aa9db902f78b Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Wed, 9 May 2012 18:23:17 -0700 Subject: Styles Controller - Added fix for setting style on cached, multi-target rule. Added fix for setting style on cached, multi-target rule. Also added parameter to selector override to augment specificity of selector --- js/controllers/styles-controller.js | 45 ++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index dfe7c69a..02c3dad9 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -217,10 +217,12 @@ var stylesController = exports.StylesController = Montage.create(Component, { } var selectorToOverride = getSelector.bind(this)(element, ruleToOverride), - overrideData, rule; + overrideData, rule, isRuleLocked; + + isRuleLocked = this.isSheetLocked(ruleToOverride.parentStyleSheet); ///// Get the overriding selector and className - overrideData = this.createOverrideSelector(selectorToOverride, element.nodeName); + overrideData = this.createOverrideSelector(selectorToOverride, element.nodeName, isRuleLocked); ///// Create new rule with selector and insert it after the rule we're overriding rule = this.addRule(overrideData.selector + ' { }', this.getRuleIndex(ruleToOverride)+1); @@ -234,7 +236,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { }, createOverrideSelector : { - value: function(selectorToOverride, classPrefix, className) { + value: function(selectorToOverride, classPrefix, increaseSpecificity, className) { var tokens = selectorToOverride.split(/\s/), newClass = className || this.generateClassName(classPrefix, true), lastToken, pseudoSplit, base, pseudo, newToken, newSelector; @@ -255,10 +257,19 @@ var stylesController = exports.StylesController = Montage.create(Component, { if(base.indexOf('#') !== -1) { newToken = base + '.' + newClass + pseudo; } else { - ///// Replace last class or attribute selector - ///// Get everything right before the last class or attribute selector - ///// to support compound selector values: (i.e. .firstClass.secondClass) - newToken = base.substring(0, Math.max(base.lastIndexOf('.'), base.lastIndexOf('['))); + if(increaseSpecificity) { + ///// Increases specificity by one class selector + ///// We'll do a direct append to the base class + ///// if we want to increase the specificity + newToken = base; + } else { + ///// Maintains original specificity + ///// Replace last class or attribute selector + ///// Get everything right before the last class or attribute selector + ///// to support compound selector values: (i.e. .firstClass.secondClass) + newToken = base.substring(0, Math.max(base.lastIndexOf('.'), base.lastIndexOf('['))); + } + ///// Append the generated class newToken += '.' + newClass + pseudo; } @@ -979,12 +990,13 @@ var stylesController = exports.StylesController = Montage.create(Component, { var doc = element.ownerDocument, useImportant = false, cache = this._getCachedRuleForProperty(element, property), - dominantRule, override, className, browserValue; + dominantRule, override, className, browserValue, cacheMatchesMany; if(cache) { ///// We've cached the rule for this property! //console.log('Styles Controller :: setElementStyle - We found the cached rule!'); dominantRule = cache; + cacheMatchesMany = this.matchesMultipleElements(dominantRule, doc); } else { ///// Use Dominant Rule logic to find the right place to add the style ///// Pass "true" to method to return an override object, which @@ -992,7 +1004,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { dominantRule = this.getDominantRuleForElement(element, property, true, isStageElement); } - + ///// Did we find a dominant rule? if(!dominantRule) { ///// No. This means there was no rule with this property, and no @@ -1010,6 +1022,13 @@ var stylesController = exports.StylesController = Montage.create(Component, { useImportant = dominantRule.useImportant; dominantRule = override.rule; this.addClass(element, override.className); + } else if(cacheMatchesMany) { + ///// Only happens when the cached rule applies to multiple + ///// elements - we must create override + override = this.createOverrideRule(dominantRule, element); + useImportant = !!dominantRule.style.getPropertyPriority(property); + dominantRule = override.rule; + this.addClass(element, override.className); } @@ -1017,7 +1036,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { browserValue = this.setStyle(dominantRule, property, value, useImportant); ///// Only cache the dominant rule if the style value was valid, and not already cached - if(browserValue && !cache) { + if(browserValue && (!cache || cacheMatchesMany)) { this._setCachedRuleForProperty(element, property, dominantRule); } @@ -1280,6 +1299,12 @@ var stylesController = exports.StylesController = Montage.create(Component, { } }, + isSheetLocked : { + value: function(sheet) { + return !!sheet.ownerNode.dataset['ninjaFileReadOnly']; + } + }, + ///// Style Sheet Modified ///// Method to call whenever a stylesheet change is made ///// Dispatches an event, and keeps list of dirty style sheets -- cgit v1.2.3 From 2088ff54c96af4bd5c96075b74939b50c56f5f24 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 10 May 2012 12:01:16 -0700 Subject: New stage template should not distinguish between user and template body styles. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/body-controller.js | 6 +++--- js/controllers/styles-controller.js | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js index 943594f2..5c23dcf7 100755 --- a/js/controllers/elements/body-controller.js +++ b/js/controllers/elements/body-controller.js @@ -13,7 +13,7 @@ exports.BodyController = Montage.create(ElementController, { set3DProperties: { value: function(el, props, update3DModel) { var dist = props["dist"], mat = props["mat"]; - this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform", "perspective(" + dist + ") " + "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")", true); + this.application.ninja.stylesController.setElementStyle(el, "-webkit-transform", "perspective(" + dist + ") " + "matrix3d(" + MathUtils.scientificToDecimal(mat, 5) + ")"); el.elementModel.props3D.matrix3d = mat; el.elementModel.props3D.perspectiveDist = dist; @@ -49,13 +49,13 @@ exports.BodyController = Montage.create(ElementController, { switch(p) { case "body-background": case "background": - this.application.ninja.stylesController.setElementStyle(el, "background-color", value, true); + this.application.ninja.stylesController.setElementStyle(el, "background-color", value); break; case "overflow": case "width": case "height": case "-webkit-transform-style": - this.application.ninja.stylesController.setElementStyle(el, p, value, true); + this.application.ninja.stylesController.setElementStyle(el, p, value); this.application.ninja.stage.updatedStage = true; break; default: diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 647c0870..7707a826 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -1130,6 +1130,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { getMatrixFromElement : { value: function(element, isStage) { + isStage = false; var xformStr = this.getElementStyle(element, "-webkit-transform", true, isStage), mat; @@ -1163,6 +1164,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { getPerspectiveDistFromElement : { value: function(element, isStage) { + isStage = false; var xformStr = this.getElementStyle(element, "-webkit-perspective", false, isStage), dist; -- cgit v1.2.3 From fb7a3aa9ce0d9b99dca79cfb89951b5c51523250 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 10 May 2012 14:54:38 -0700 Subject: Adding partial close functionality --- js/controllers/document-controller.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 682bd6a6..58fa4de7 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -211,9 +211,14 @@ var DocumentController = exports.DocumentController = Montage.create(Component, //////////////////////////////////////////////////////////////////// handleExecuteFileClose:{ value: function(event) { - if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ + if (this.activeDocument) { + this.activeDocument.closeDocument(); + } + /* +if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ this.closeDocument(this.activeDocument.uuid); } +*/ } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From d75aff9e251f84a13c326668a5271b5852dcde53 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 10 May 2012 15:36:24 -0700 Subject: Adding webRequest API Adding webRequest API to handle local URLs intercepting. Should be a temp fix. --- js/controllers/document-controller.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 58fa4de7..84e9f4fc 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -89,8 +89,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, //TODO: Ensure these APIs are not needed - /* -//////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// // handleWebRequest: { value: function (request) { @@ -100,7 +99,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, //console.log(request); //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url); //return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]}; - return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/montage-html/'))[1]}; + return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/montage-web/'))[1]}; } } }, @@ -120,7 +119,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } }, //////////////////////////////////////////////////////////////////// -*/ -- cgit v1.2.3 From d6cec6193a16563e9d35d75f0caee49bab927cda Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 10 May 2012 15:54:29 -0700 Subject: Fixing the google components. Signed-off-by: Valerio Virgillito --- js/controllers/elements/component-controller.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js index d902e4a1..41f0f943 100755 --- a/js/controllers/elements/component-controller.js +++ b/js/controllers/elements/component-controller.js @@ -11,7 +11,8 @@ exports.ComponentController = Montage.create(ElementController, { getProperty: { value: function(el, prop) { - var component = el.controller || this.application.ninja.currentDocument.getComponentFromElement(el); + console.log("safdasdasdasd"); + var component = el.controller || this.application.ninja.currentDocument.model.getComponentFromElement(el); switch(prop) { case "id": @@ -34,7 +35,7 @@ exports.ComponentController = Montage.create(ElementController, { setProperty: { value: function(el, p, value) { - var component = el.controller || this.application.ninja.currentDocument.getComponentFromElement(el); + var component = el.controller || this.application.ninja.currentDocument.model.getComponentFromElement(el); switch(p) { case "id": -- cgit v1.2.3 From 8f9be38f9a9ef9c5ee78ae59912ad9254b78a16e Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 10 May 2012 16:46:10 -0700 Subject: remove console logs Signed-off-by: Valerio Virgillito --- js/controllers/elements/component-controller.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js index 41f0f943..5b0aaeac 100755 --- a/js/controllers/elements/component-controller.js +++ b/js/controllers/elements/component-controller.js @@ -11,7 +11,6 @@ exports.ComponentController = Montage.create(ElementController, { getProperty: { value: function(el, prop) { - console.log("safdasdasdasd"); var component = el.controller || this.application.ninja.currentDocument.model.getComponentFromElement(el); switch(prop) { -- cgit v1.2.3 From e7293b28c53b23e64044c29e8451cbf3fc0bd049 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 10 May 2012 22:25:26 -0700 Subject: Partially fixing the body pi and fixing the selection controller Signed-off-by: Valerio Virgillito --- js/controllers/selection-controller.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index a81cdf7f..6e40abb5 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -165,7 +165,7 @@ exports.SelectionController = Montage.create(Component, { while(outerElement.parentNode && outerElement.parentNode.uuid !== this.selectionContainer.uuid) { // If element is higher up than current container then return - if(outerElement.id === "UserContent") return; + if(outerElement.nodeName === "BODY") return; // else keep going up the chain outerElement = outerElement.parentNode; } @@ -246,25 +246,20 @@ exports.SelectionController = Montage.create(Component, { } }, - /** - * Looks into the selectionObject for the item to be found using it's id - * - * @return: Item index in the selectionObject if found - * -1 if not found - */ findSelectedElement: { value: function(item) { - // TODO do the loop check in the select element and only use the index here - // return this.application.ninja.selectedElements.indexOf(item); + // TODO: Remove this function and use the stage selectable. Then only return a match in the array + //return this.application.ninja.selectedElements.indexOf(item); + //TODO: Make sure we don't need to loop back to the container element. var itemUUID; for(var i=0, uuid; this.application.ninja.selectedElements[i];i++) { // Check for multiple selection and excluding inner elements - if(item.parentNode && item.parentNode.id !== "UserContent") { + if(item.parentNode && item.parentNode !== this.application.ninja.currentDocument.documentRoot) { var outerElement = item.parentNode; - while(outerElement.parentNode && outerElement.parentNode.id !== "UserContent") { + while(outerElement.parentNode && outerElement.parentNode !== this.application.ninja.currentDocument.documentRoot) { outerElement = outerElement.parentNode; } -- cgit v1.2.3 From f6f722feecf88c8afe59327eaf8557ce4012abc7 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 10 May 2012 22:40:02 -0700 Subject: Fixing the dirty document flag. Disabling the stylesheets dirty flag because === true on document open. Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 4 ++-- js/controllers/elements/shapes-controller.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 84e9f4fc..0fd13be2 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -235,7 +235,7 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ fileSaveResult: { value: function (result) { if((result.status === 204) || (result.status === 404)){//204=>existing file || 404=>new file... saved - this.activeDocument.needsSave = false; + this.activeDocument.model.needsSave = false; if(this.application.ninja.currentDocument !== null){ //clear Dirty StyleSheets for the saved document this.application.ninja.stylesController.clearDirtyStyleSheets(this.application.ninja.currentDocument); @@ -647,7 +647,7 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ handleStyleSheetDirty:{ value:function(){ - this.activeDocument.needsSave = true; +// this.activeDocument.model.needsSave = true; } }, diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index e9a5f865..38f133b5 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -213,7 +213,7 @@ exports.ShapesController = Montage.create(CanvasController, { default: CanvasController.setProperty(el, p, value); } - this.application.ninja.documentController.activeDocument.needsSave = true; + this.application.ninja.documentController.activeDocument.model.needsSave = true; } }, @@ -559,7 +559,7 @@ exports.ShapesController = Montage.create(CanvasController, { } } el.elementModel.shapeModel.GLWorld.render(); - this.application.ninja.documentController.activeDocument.needsSave = true; + this.application.ninja.documentController.activeDocument.model.needsSave = true; } }, -- cgit v1.2.3 From c87e538fdc337639bc4d54bb087dbf2b4f20297f Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 11 May 2012 14:41:20 -0700 Subject: Adding support for new templates This is supported for NEW and OPEN, SAVE is not supported yet by I/O. Saving works, but it will not be a banner template. --- js/controllers/document-controller.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 0fd13be2..d88059ab 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -99,7 +99,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, //console.log(request); //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url); //return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]}; - return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/montage-web/'))[1]}; + return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/'))[1]}; } } }, @@ -244,20 +244,20 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ } }, + + + //////////////////////////////////////////////////////////////////// + // createNewFile:{ value:function(newFileObj){ - //console.log(newFileObj);//contains the template uri and the new file uri + // if(!newFileObj) return; - this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, this.openNewFileCallback.bind(this)); - - if((newFileObj.fileExtension !== ".html") && (newFileObj.fileExtension !== ".htm")){//open code view - - } else { - //open design view - } + // + this.application.ninja.ioMediator.fileNew(newFileObj.newFilePath, newFileObj.fileTemplateUri, this.openNewFileCallback.bind(this), newFileObj.template); } }, - + //////////////////////////////////////////////////////////////////// + /** * Public method * doc contains: @@ -374,6 +374,12 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ }, openWebDocument: { value: function(doc) { + var template, dimensions; + if (doc.content.body.indexOf('Ninja-Banner Dimensions@@@') !== -1) { + dimensions = (doc.content.body.split('Ninja-Banner Dimensions@@@'))[1].split('-->')[0].split('x'); + dimensions = {width: parseInt(dimensions[0]), height: parseInt(dimensions[1])}; + template = {type: 'banner', size: dimensions}; + } // TODO: HACKS to remove this.documentHackReference = doc; document.getElementById("iframeContainer").style.overflow = "hidden"; @@ -382,7 +388,7 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ case 'html': //Open in designer view this._hackRootFlag = false; - Montage.create(Document).init(doc, this, this._onOpenDocument, 'design'); + Montage.create(Document).init(doc, this, this._onOpenDocument, 'design', template); break; default: //Open in code view -- cgit v1.2.3 From 1559abff592b976e6b983881fe208da4257e98f7 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Mon, 14 May 2012 10:44:42 -0700 Subject: Fixing webRequest URL parsing --- js/controllers/document-controller.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index d88059ab..e6b543d7 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -95,11 +95,14 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function (request) { //TODO: Check if frameId is proper if (this._hackRootFlag && request.parentFrameId !== -1) { - //TODO: Optimize creating string - //console.log(request); - //console.log(this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1], request.url); - //return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split('/')[request.url.split('/').length-1]}; - return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/'))[1]}; + //Checking for proper URL redirect (from different directories) + if (request.url.indexOf('js/document/templates/banner') !== -1) { + return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/banner/'))[1]}; + } else if (request.url.indexOf('js/document/templates/html') !== -1) { + return {redirectUrl: this.application.ninja.coreIoApi.rootUrl+this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1]+request.url.split(chrome.extension.getURL('js/document/templates/html/'))[1]}; + } else { + //Error, not a valid folder + } } } }, -- cgit v1.2.3 From 734b6ad96d25bb67d0db4a0a75c331468e194809 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 14 May 2012 12:05:41 -0700 Subject: Fixing 3d to work in banner templates. Signed-off-by: Nivesh Rajbhandari --- js/controllers/document-controller.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index d88059ab..3b6eb5bf 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -683,8 +683,11 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ } if(needsRule) { - rule = sc.addRule('body{}'); +// rule = sc.addRule('body{}'); +// sc.setStyles(rule, styles); + rule = sc.addRule('.ninjaUserDoc{}'); sc.setStyles(rule, styles); + sc.addClass(docRoot, "ninjaUserDoc"); } } } -- cgit v1.2.3 From cfd3a44bb7aba54c15fab59eff39ecdffcb7ac11 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 14 May 2012 14:38:35 -0700 Subject: Viewport for banner templates so content doesn't push through "body". Signed-off-by: Nivesh Rajbhandari --- js/controllers/document-controller.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 3b6eb5bf..3ce4ba81 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -683,11 +683,9 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ } if(needsRule) { -// rule = sc.addRule('body{}'); -// sc.setStyles(rule, styles); - rule = sc.addRule('.ninjaUserDoc{}'); + rule = sc.addRule('.ninja-body{}'); sc.setStyles(rule, styles); - sc.addClass(docRoot, "ninjaUserDoc"); + sc.addClass(docRoot, "ninja-body"); } } } -- cgit v1.2.3 From 9b2cecc30a2e94ac247fddd8ec931b9aa768cb5c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 14 May 2012 16:04:46 -0700 Subject: code cleanup Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index d88059ab..0a91ae29 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -155,13 +155,13 @@ var DocumentController = exports.DocumentController = Montage.create(Component, }, handleExecuteNewFile: { - value: function(event) { - var newFileSettings = event._event.settings || {}; - if (this.application.ninja.coreIoApi.cloudAvailable()) { - newFileSettings.callback = this.createNewFile.bind(this); - this.application.ninja.newFileController.showNewFileDialog(newFileSettings); - } + value: function(event) { + var newFileSettings = event._event.settings || {}; + if (this.application.ninja.coreIoApi.cloudAvailable()) { + newFileSettings.callback = this.createNewFile.bind(this); + this.application.ninja.newFileController.showNewFileDialog(newFileSettings); } + } }, //////////////////////////////////////////////////////////////////// // @@ -607,7 +607,7 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ //hide the iframe when switching to code view document.getElementById("iframeContainer").style.display = "none"; } - } + } } }, -- cgit v1.2.3 From 919a0d0ed35c24b1047281723ddde2ac98fc9a3e Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 15 May 2012 22:36:44 -0700 Subject: document close handler. initial working draft Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 66 ++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 24 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 48ceb21b..51791a11 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -33,6 +33,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: false }, + _hackInitialStyles: { + value: true + }, + _activeDocument: { value: null }, _iframeCounter: { value: 1, enumerable: false }, _iframeHolder: { value: null, enumerable: false }, @@ -44,8 +48,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, return this._activeDocument; }, set: function(doc) { - if(!!this._activeDocument){ this._activeDocument.isActive = false;} +// if(!!this._activeDocument){ this._activeDocument.isActive = false;} + this._activeDocument = doc; + if(!!this._activeDocument){ if(this._documents.indexOf(doc) === -1) this._documents.push(doc); this._activeDocument.isActive = true; @@ -213,13 +219,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component, handleExecuteFileClose:{ value: function(event) { if (this.activeDocument) { - this.activeDocument.closeDocument(); +// this.activeDocument.closeDocument(); + this.closeFile(this.activeDocument); } - /* -if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ - this.closeDocument(this.activeDocument.uuid); - } -*/ } }, //////////////////////////////////////////////////////////////////// @@ -448,7 +450,32 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ */ } - }, + }, + + closeFile: { + value: function(document) { + document.closeDocument(this, this.onCloseFile); + } + }, + + onCloseFile: { + value: function(doc) { + + this._documents.splice(this._documents.indexOf(doc), 1); + + this.activeDocument = null; + + this.application.ninja.stage.stageView.hideRulers(); + +// document.getElementById("iframeContainer").style.display="block"; + + this.application.ninja.stage.hideCanvas(true); + + + NJevent("closeDocument", doc.model.file.uri); + //TODO: Delete object here + } + }, closeDocument: { value: function(id) { @@ -468,15 +495,7 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ if(typeof doc.stopVideos !== "undefined"){doc.stopVideos();} this._removeDocumentView(doc.container); }else if(this._documents.length === 0){ - if(typeof this.activeDocument.pauseAndStopVideos !== "undefined"){ - this.activeDocument.pauseAndStopVideos(); - } - this.activeDocument = null; - this._removeDocumentView(doc.container); - this.application.ninja.stage.stageView.hideRulers(); - document.getElementById("iframeContainer").style.display="block"; - - this.application.ninja.stage.hideCanvas(true); + // See above }else{//closing inactive document tab - just clear DOM if(typeof doc.pauseAndStopVideos !== "undefined"){ doc.pauseAndStopVideos(); @@ -515,6 +534,9 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ this.application.ninja.stage.stageView.showCodeViewBar(false); this.application.ninja.stage.stageView.restoreAllPanels(); + + // Flag to stop stylesheet dirty event + this._hackInitialStyles = false; } }, @@ -552,12 +574,6 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ /** * VIEW Related Methods */ - // PUBLIC - ShowActiveDocument: { - value: function() { - this.activeDocument.iframe.style.opacity = 1.0; - } - }, // PRIVATE _findDocumentByUUID: { @@ -656,7 +672,9 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ handleStyleSheetDirty:{ value:function(){ -// this.activeDocument.model.needsSave = true; + if(!this._hackInitialStyles) { + this.activeDocument.model.needsSave = true; + } } }, -- cgit v1.2.3 From 0eaa0be8e030a6bac5ab70af3c1044682d973366 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 15 May 2012 23:33:44 -0700 Subject: fixed some binding warnings Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 51791a11..fba9fad5 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -463,7 +463,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this._documents.splice(this._documents.indexOf(doc), 1); - this.activeDocument = null; + this._activeDocument = null; this.application.ninja.stage.stageView.hideRulers(); -- cgit v1.2.3 From f9f8fdc3000042ba5b4504d91870dc9a32ef25eb Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 01:00:22 -0700 Subject: Squashed master into dom-architecture Signed-off-by: Valerio Virgillito --- js/controllers/styles-controller.js | 4 +- js/controllers/tree-controller.js | 185 ------------------------------------ 2 files changed, 3 insertions(+), 186 deletions(-) delete mode 100644 js/controllers/tree-controller.js (limited to 'js/controllers') diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 7707a826..26485508 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -795,7 +795,9 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// method to apply/test the new value dec.setProperty(property, value, priority); - this.styleSheetModified(rule.parentStyleSheet); + if(rule.parentStyleSheet) { + this.styleSheetModified(rule.parentStyleSheet); + } ///// Return browser value for value we just set return dec.getPropertyValue(property); diff --git a/js/controllers/tree-controller.js b/js/controllers/tree-controller.js deleted file mode 100644 index 2b2e910c..00000000 --- a/js/controllers/tree-controller.js +++ /dev/null @@ -1,185 +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. -
*/ -/** - @module montage/ui/controller/tree-controller - @requires montage/core/core - @requires montage/ui/controller/object-controller - @requires montage/core/event/mutable-event - */ -var Montage = require("montage").Montage, - ObjectController = require("montage/ui/controller/object-controller").ObjectController, - ArrayController = require("montage/ui/controller/array-controller").ArrayController, - MutableEvent = require("montage/core/event/mutable-event").MutableEvent; -/** - TODO: Write description like the array controllers: The ArrayController helps with organizing a hierarchical - collection of objects, and managing user selection within that collection. - You can assign a TreeController instance as the contentProvider property for a TreeView object. - @class module:montage/ui/controller/tree-controller.TreeController - @classdesc - @extends module:montage/ui/controller/object-controller.ObjectController -*/ -var TreeController = exports.TreeController = Montage.create(ObjectController, /** @lends module:montage/ui/controller/tree-controller.TreeController# */ { - - rootKey : { - value: null - }, - - branchKey : { - value: 'children' - }, - - _root : { - value : null - }, - root : { - get: function() { - return this._root; - }, - set: function(value) { - this._root = value; - - this.initArrayControllers(); - } - }, - - rootController: { - value: null - }, - - initArrayControllers : { - value: function() { - var self = this; - - ///// Recursive function that finds all branch nodes and initializes - ///// sets the tree node type to "branch" or "leaf" - - function walk(node, init, depth) { - var branch = node[self.branchKey]; - - if(branch) { - branch.forEach(function(node) { - walk(node, init, ++depth); - }); - - node['treeNodeType'] = 'branch'; - } else { - node['treeNodeType'] = 'leaf'; - } - } - - walk(this._root, 0); - - } - }, - - /** - @private - */ - _selectedIndexes: { - value: null, - enumerable: false - }, - - /** - Description TODO - @type {Function} - @default null - */ - selectedIndexes: { - get: function() { - - }, - set: function(value) { - - } - }, - - branchControllers: { - value: [] - }, - - addBranchController : { - value: function(controller) { - if(this.delegate) { - controller.delegate = this.delegate; - } - - this.branchControllers.push(controller); - } - }, - - /** - @private - */ - _content: { - enumerable: false, - value: null - }, - /** - The content managed by the TreeController. - @type {Function} - @default {String} null - */ - content: { - get: function() { - return this._content; - }, - set: function(value) { - if (this._content === value) { - return; - } - - this._content = value; - - this.selectedObjects = null; - - if (this.rootKey) { - if (value[this.rootKey]) { - this.root = value[this.rootKey]; - } else { - console.log('No root key found in content data'); - } - } else { - this.root = value; - } - - } - }, - - addObjects : { - value: function() { - - var objects = Array.prototype.slice.call(arguments), - i, - objectCount = objects.length, - selectedContentIndexes, firstIndex; - - for (i = 0; i < objectCount; i++) { - this.content.push(objects[i]); - } - - if (this.selectObjectsOnAddition) { - selectedContentIndexes = []; - firstIndex = this.content.length-objectCount; - for (i = 0; i < objectCount; i++) { - selectedContentIndexes[i] = firstIndex++; - } - this.selectedContentIndexes = selectedContentIndexes; - this.selectedObjects = objects; - } - - if (this.clearFilterFunctionOnAddition) { - this.filterFunction = null; - } - - if (this.automaticallyOrganizeObjects) { - this.organizeObjects(); - } - - } - } - -}); -- cgit v1.2.3 From 0ebb822b0535bf1bb100b3f3cb396c8b6d3383f1 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 11:23:12 -0700 Subject: fixing some of the document bindings. Signed-off-by: Valerio Virgillito --- js/controllers/styles-controller.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 26485508..ae504f0e 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -53,11 +53,11 @@ var stylesController = exports.StylesController = Montage.create(Component, { ///// Bind app's activeDocument property to ///// styles controller's _activeDocument property - Object.defineBinding(this, "activeDocument", { - boundObject: this.application.ninja, - boundObjectPropertyPath: "currentDocument", - oneway: true - }); +// Object.defineBinding(this, "activeDocument", { +// boundObject: this.application.ninja, +// boundObjectPropertyPath: "currentDocument", +// oneway: true +// }); } }, @@ -79,7 +79,6 @@ var stylesController = exports.StylesController = Montage.create(Component, { return this._activeDocument; }, set : function(document) { - ///// If the document is null set default stylesheets to null if(!document) { -- cgit v1.2.3 From 5164c2415c8a0750c21299325bb1caa8a97fc5b5 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Wed, 16 May 2012 14:10:14 -0700 Subject: Styles Controller - Fix issue with clearing dirty stylesheet list --- js/controllers/styles-controller.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index cbc00676..60b2ca92 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -1345,7 +1345,6 @@ var stylesController = exports.StylesController = Montage.create(Component, { this.dirtyStyleSheets.length = 0; if(doc) { - this.dirtyStyleSheets = null; this.dirtyStyleSheets = this.dirtyStyleSheets.filter(function(sheet) { return sheet.document !== doc; }); -- cgit v1.2.3 From 99f16ae08fbb0a6dfe6008c9833f2253b18c19e5 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 14:13:28 -0700 Subject: removing first draw on the component event Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index fba9fad5..1e894f02 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -76,24 +76,13 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.eventManager.addEventListener("styleSheetDirty", this, false); - this.eventManager.addEventListener("addComponentFirstDraw", this, false); - // Temporary add listeners for the new stage templates this.eventManager.addEventListener("executeWebpageOpen", this, false); this.eventManager.addEventListener("executeNewWebpage", this, false); } }, - handleAddComponentFirstDraw: { - value: function (e) { - //TODO: Add logic to reparse the document for dynamically added styles - //console.log(e); - } - }, - - - - + //TODO: Ensure these APIs are not needed //////////////////////////////////////////////////////////////////// // -- cgit v1.2.3 From b5439f436cac405c4bbf7e01ead9cee5dbc71a73 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Wed, 16 May 2012 16:04:00 -0700 Subject: CSS Panel - Style sheets dirty flag added --- js/controllers/styles-controller.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to