From 1c528b42f9b1c9be9197921586388c3a3bdc5c17 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Wed, 22 Feb 2012 23:16:23 -0800 Subject: CSS Panel Update - Adding montage objects for css panel --- .../style-sheets-view.reel/style-sheets-view.js | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js (limited to 'js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js') diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js new file mode 100644 index 00000000..f93de830 --- /dev/null +++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js @@ -0,0 +1,45 @@ +/* + 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; + +exports.StyleSheetsView = Montage.create(Component, { + noDocumentCondition : { + value: true + }, + styleSheets : { + value: [] + }, + stylesController : { + value: null + }, + deserializedFromTemplate : { + value: function() { + console.log("style sheet view - deserialized"); + + this.stylesController = this.application.ninja.stylesController; + + this.eventManager.addEventListener("styleSheetsReady", this, false); + } + }, + handleStyleSheetsReady : { + value: function(e) { + //this.styleSheets = null; + this.styleSheets = this.stylesController.userStyleSheets; + } + }, + prepareForDraw : { + value: function() { + console.log("style sheet view - prepare for draw"); + } + }, + draw : { + value: function() { + console.log("styles sheet view - draw"); + } + } +}); \ No newline at end of file -- cgit v1.2.3 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/panels/css-panel/style-sheets-view.reel/style-sheets-view.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js') diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js index f93de830..f8826b18 100644 --- a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js +++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js @@ -28,8 +28,12 @@ exports.StyleSheetsView = Montage.create(Component, { }, handleStyleSheetsReady : { value: function(e) { - //this.styleSheets = null; - this.styleSheets = this.stylesController.userStyleSheets; + this.noDocumentCondition = false; + + this.stylesController.userStyleSheets.forEach(function(sheet) { + this.styleSheets.push(sheet); + }, this); + } }, prepareForDraw : { -- 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 --- .../style-sheets-view.reel/style-sheets-view.js | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js') diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js index f8826b18..b1315311 100644 --- a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js +++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js @@ -11,6 +11,9 @@ exports.StyleSheetsView = Montage.create(Component, { noDocumentCondition : { value: true }, + showToolbar : { + value: false + }, styleSheets : { value: [] }, @@ -24,18 +27,27 @@ exports.StyleSheetsView = Montage.create(Component, { this.stylesController = this.application.ninja.stylesController; this.eventManager.addEventListener("styleSheetsReady", this, false); + this.eventManager.addEventListener("newStyleSheet", this, false); } }, + _initView : { + value: false + }, handleStyleSheetsReady : { value: function(e) { - this.noDocumentCondition = false; + this._initView = this.needsDraw = true; - this.stylesController.userStyleSheets.forEach(function(sheet) { - this.styleSheets.push(sheet); - }, this); +// this.noDocumentCondition = false; +// this.showToolbar = true; +// this.styleSheets = this.stylesController.userStyleSheets; } }, + handleNewStyleSheet : { + value: function(e) { + this.styleSheets.push(e._event.detail); + } + }, prepareForDraw : { value: function() { console.log("style sheet view - prepare for draw"); @@ -44,6 +56,13 @@ exports.StyleSheetsView = Montage.create(Component, { draw : { value: function() { console.log("styles sheet view - draw"); + + if(this._initView) { + this.noDocumentCondition = false; + this.showToolbar = true; + this.styleSheets = this.stylesController.userStyleSheets; + this._initView = false; + } } } }); \ No newline at end of file -- cgit v1.2.3 From 946fae3acf8ca9f384b662e40f406506e8b90ea7 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Mon, 23 Apr 2012 22:37:34 -0700 Subject: CSSPanel - Resizer --- .../style-sheets-view.reel/style-sheets-view.js | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js') diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js index b1315311..95adddd0 100644 --- a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js +++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js @@ -14,6 +14,27 @@ exports.StyleSheetsView = Montage.create(Component, { showToolbar : { value: false }, + _resizedHeight : { + value: null + }, + isResizing : { + value: null + }, + _height: { + value: null + }, + height: { + get: function() { + return this._height; + }, + set: function(val) { + if(this._height !== val) { + this._height = val; + this.needsDraw = true; + } + } + }, + styleSheets : { value: [] }, @@ -33,6 +54,7 @@ exports.StyleSheetsView = Montage.create(Component, { _initView : { value: false }, + handleStyleSheetsReady : { value: function(e) { this._initView = this.needsDraw = true; @@ -48,6 +70,30 @@ exports.StyleSheetsView = Montage.create(Component, { this.styleSheets.push(e._event.detail); } }, + handleResizeStart: { + value:function(e) { + this.isResizing = true; + this.needsDraw = true; + } + }, + + handleResizeMove: { + value:function(e) { + this._resizedHeight = e._event.dY; + this.needsDraw = true; + } + }, + + handleResizeEnd: { + value: function(e) { + this.height += this._resizedHeight; + this._resizedHeight = 0; + this.isResizing = false; + this.needsDraw = true; + } + }, + + prepareForDraw : { value: function() { console.log("style sheet view - prepare for draw"); @@ -63,6 +109,18 @@ exports.StyleSheetsView = Montage.create(Component, { this.styleSheets = this.stylesController.userStyleSheets; this._initView = false; } + + if(this.height) { + console.log("StyleSheetsView draw - resizing to", (this.height + this._resizedHeight) + "px"); + this.styleSheetList.element.style.height = (this.height + this._resizedHeight) + "px"; + } + } + }, + didDraw: { + value: function() { + if(!this.isResizing) { + this.height = this.styleSheetList.element.offsetHeight; + } } } }); \ No newline at end of file -- cgit v1.2.3 From 72ad2e9710adfccaab637fffdf6c82712aa85197 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Thu, 3 May 2012 11:50:03 -0700 Subject: Style sheets - Add stub for add stylesheet button --- .../css-panel/style-sheets-view.reel/style-sheets-view.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js') diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js index 95adddd0..29381d73 100644 --- a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js +++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js @@ -35,6 +35,16 @@ exports.StyleSheetsView = Montage.create(Component, { } }, + /// Toolbar Button Actions + /// ----------------------- + + ///// Add rule button action + handleAddAction : { + value: function(e) { + debugger; + } + }, + styleSheets : { value: [] }, -- cgit v1.2.3 From 8b9024faa65566a18e4548f198b43f18390e6bc5 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Thu, 3 May 2012 16:01:47 -0700 Subject: CSS Panel - Add labels for selection and document names --- .../style-sheets-view.reel/style-sheets-view.js | 148 +++++++++++---------- 1 file changed, 76 insertions(+), 72 deletions(-) (limited to 'js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js') diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js index 29381d73..26b996ec 100644 --- a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js +++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js @@ -8,35 +8,29 @@ var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component; exports.StyleSheetsView = Montage.create(Component, { - noDocumentCondition : { - value: true - }, - showToolbar : { - value: false - }, - _resizedHeight : { - value: null - }, - isResizing : { - value: null - }, - _height: { - value: null - }, - height: { + noDocumentCondition : { value: true }, + showToolbar : { value: false }, + stylesController : { value: null }, + styleSheets : { value: [] }, + _initView : { value: false }, + documentNameLabel : { value: null }, + noDocumentLabelClass : { value: "no-document" }, + + _documentName : { value: null }, + documentName : { get: function() { - return this._height; + return this._documentName; }, - set: function(val) { - if(this._height !== val) { - this._height = val; - this.needsDraw = true; - } + set: function(label) { + if(label === this._documentName) { return false; } + + this._documentName = label; + this.needsDraw = true; } }, - + /// Toolbar Button Actions - /// ----------------------- + /// -------------------------------- ///// Add rule button action handleAddAction : { @@ -45,34 +39,75 @@ exports.StyleSheetsView = Montage.create(Component, { } }, - styleSheets : { - value: [] - }, - stylesController : { - value: null + /// App event handlers + /// -------------------------------- + + handleStyleSheetsReady : { + value: function(e) { + this.documentName = this.stylesController.activeDocument.name; + this._initView = this.needsDraw = true; + } }, - deserializedFromTemplate : { - value: function() { - console.log("style sheet view - deserialized"); + /// Draw cycle + /// -------------------------------- + + templateDidLoad : { + value: function() { this.stylesController = this.application.ninja.stylesController; - + } + }, + prepareForDraw : { + value: function() { this.eventManager.addEventListener("styleSheetsReady", this, false); this.eventManager.addEventListener("newStyleSheet", this, false); } }, - _initView : { - value: false + draw : { + value: function() { + if(this._initView) { + this.noDocumentCondition = false; + this.showToolbar = true; + this.styleSheets = this.stylesController.userStyleSheets; + this._initView = false; + } + + if(this.height) { + this.styleSheetList.element.style.height = (this.height + this._resizedHeight) + "px"; + } + + if(this.documentName && this.documentNameLabel) { + this.documentNameLabel.innerHTML = this.documentName; + this.documentNameLabel.classList.remove(this.noDocumentLabelClass); + } else { + this.documentNameLabel.classList.add(this.noDocumentLabelClass); + } + } + }, + didDraw: { + value: function() { + if(!this.isResizing) { + this.height = this.styleSheetList.element.offsetHeight; + } + } }, - handleStyleSheetsReady : { - value: function(e) { - this._initView = this.needsDraw = true; -// this.noDocumentCondition = false; -// this.showToolbar = true; -// this.styleSheets = this.stylesController.userStyleSheets; + /// Resize properties + /// -------------------------------- + _resizedHeight : { value: null }, + isResizing : { value: null }, + _height : { value: null }, + height: { + get: function() { + return this._height; + }, + set: function(val) { + if(this._height !== val) { + this._height = val; + this.needsDraw = true; + } } }, handleNewStyleSheet : { @@ -102,35 +137,4 @@ exports.StyleSheetsView = Montage.create(Component, { this.needsDraw = true; } }, - - - prepareForDraw : { - value: function() { - console.log("style sheet view - prepare for draw"); - } - }, - draw : { - value: function() { - console.log("styles sheet view - draw"); - - if(this._initView) { - this.noDocumentCondition = false; - this.showToolbar = true; - this.styleSheets = this.stylesController.userStyleSheets; - this._initView = false; - } - - if(this.height) { - console.log("StyleSheetsView draw - resizing to", (this.height + this._resizedHeight) + "px"); - this.styleSheetList.element.style.height = (this.height + this._resizedHeight) + "px"; - } - } - }, - didDraw: { - value: function() { - if(!this.isResizing) { - this.height = this.styleSheetList.element.offsetHeight; - } - } - } }); \ No newline at end of file -- 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 --- .../css-panel/style-sheets-view.reel/style-sheets-view.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js') diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js index 26b996ec..2d6e18ed 100644 --- a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js +++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js @@ -35,7 +35,7 @@ exports.StyleSheetsView = Montage.create(Component, { ///// Add rule button action handleAddAction : { value: function(e) { - debugger; + this.stylesController.createStylesheet(); } }, @@ -45,6 +45,7 @@ exports.StyleSheetsView = Montage.create(Component, { handleStyleSheetsReady : { value: function(e) { this.documentName = this.stylesController.activeDocument.name; + this.styleSheets = this.stylesController.userStyleSheets; this._initView = this.needsDraw = true; } }, @@ -60,7 +61,6 @@ exports.StyleSheetsView = Montage.create(Component, { prepareForDraw : { value: function() { this.eventManager.addEventListener("styleSheetsReady", this, false); - this.eventManager.addEventListener("newStyleSheet", this, false); } }, draw : { @@ -68,7 +68,6 @@ exports.StyleSheetsView = Montage.create(Component, { if(this._initView) { this.noDocumentCondition = false; this.showToolbar = true; - this.styleSheets = this.stylesController.userStyleSheets; this._initView = false; } @@ -110,11 +109,6 @@ exports.StyleSheetsView = Montage.create(Component, { } } }, - handleNewStyleSheet : { - value: function(e) { - this.styleSheets.push(e._event.detail); - } - }, handleResizeStart: { value:function(e) { this.isResizing = true; -- cgit v1.2.3 From af4dac82d2e76fe90191d6c085740d855bf961f3 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Tue, 8 May 2012 09:43:57 -0700 Subject: Style sheets - Added default stylesheet selection --- .../style-sheets-view.reel/style-sheets-view.js | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js') diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js index 2d6e18ed..b2d2c0fb 100644 --- a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js +++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js @@ -13,6 +13,7 @@ exports.StyleSheetsView = Montage.create(Component, { stylesController : { value: null }, styleSheets : { value: [] }, _initView : { value: false }, + _needsScroll : { value: false }, documentNameLabel : { value: null }, noDocumentLabelClass : { value: "no-document" }, @@ -28,6 +29,29 @@ exports.StyleSheetsView = Montage.create(Component, { this.needsDraw = true; } }, + _defaultStyleSheet: { value: null }, + defaultStyleSheet: { + get: function() { + return this._defaultStyleSheet; + }, + set: function(sheet) { + if(sheet === this._defaultStyleSheet) { return false; } + + var sheetComponent, oldDefaultSheet; + + if(this.styleSheetList) { + sheetComponent = this.styleSheetList.childComponents[this.styleSheets.indexOf(sheet)]; + sheetComponent.default = true; + if(this._defaultStyleSheet) { + oldDefaultSheet = this.styleSheetList.childComponents[this.styleSheets.indexOf(this._defaultStyleSheet)]; + oldDefaultSheet.default = false; + } + } + + this._defaultStyleSheet = sheet; + this.needsDraw = true; + } + }, /// Toolbar Button Actions /// -------------------------------- @@ -36,6 +60,8 @@ exports.StyleSheetsView = Montage.create(Component, { handleAddAction : { value: function(e) { this.stylesController.createStylesheet(); + this.needsDraw = this._needsScroll = true; + } }, @@ -46,6 +72,13 @@ exports.StyleSheetsView = Montage.create(Component, { value: function(e) { this.documentName = this.stylesController.activeDocument.name; this.styleSheets = this.stylesController.userStyleSheets; + + Object.defineBinding(this, 'defaultStyleSheet', { + 'boundObject': this.stylesController, + 'boundObjectPropertyPath': 'defaultStylesheet', + 'oneway': false + }); + this._initView = this.needsDraw = true; } }, @@ -81,6 +114,17 @@ exports.StyleSheetsView = Montage.create(Component, { } else { this.documentNameLabel.classList.add(this.noDocumentLabelClass); } + + if(this._needsScroll) { + + setTimeout(function() { + console.log('setting scroll top to:', this.styleSheetList.element.scrollHeight); + //debugger; + this.styleSheetList.element.scrollTop = this.styleSheetList.element.scrollHeight; + }.bind(this), 50); + + this._needsScroll = false; + } } }, didDraw: { -- 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 --- .../style-sheets-view.reel/style-sheets-view.js | 41 +++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js') diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js index b2d2c0fb..8131a619 100644 --- a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js +++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js @@ -17,6 +17,8 @@ exports.StyleSheetsView = Montage.create(Component, { documentNameLabel : { value: null }, noDocumentLabelClass : { value: "no-document" }, + dirtyStyleSheets: { value: null }, + _documentName : { value: null }, documentName : { get: function() { @@ -52,7 +54,21 @@ exports.StyleSheetsView = Montage.create(Component, { this.needsDraw = true; } }, - + + _dirtyStyleSheets : { value: null }, + dirtyStyleSheets : { + get: function() { + return this._dirtyStyleSheets; + }, + set: function(value) { + if(value === this._dirtyStyleSheets) { return false; } + + this._dirtyStyleSheets = value; + + this.needsDraw = true; + } + }, + /// Toolbar Button Actions /// -------------------------------- @@ -79,10 +95,22 @@ exports.StyleSheetsView = Montage.create(Component, { 'oneway': false }); + Object.defineBinding(this, 'dirtyStyleSheets', { + 'boundObject': this.stylesController, + 'boundObjectPropertyPath': 'dirtyStyleSheets', + 'oneway': true + }); + this._initView = this.needsDraw = true; } }, + handleStyleSheetModified : { + value: function(e) { + this.needsDraw = true; + } + }, + /// Draw cycle /// -------------------------------- @@ -94,6 +122,7 @@ exports.StyleSheetsView = Montage.create(Component, { prepareForDraw : { value: function() { this.eventManager.addEventListener("styleSheetsReady", this, false); + this.eventManager.addEventListener("styleSheetModified", this, false); } }, draw : { @@ -115,6 +144,16 @@ exports.StyleSheetsView = Montage.create(Component, { this.documentNameLabel.classList.add(this.noDocumentLabelClass); } + if(this.dirtyStyleSheets) { + var dirtySheets = this.dirtyStyleSheets.map(function(sheetDescriptor) { + return sheetDescriptor.stylesheet; + }); + + this.styleSheetList.childComponents.forEach(function(sheetComponent) { + sheetComponent.dirty = dirtySheets.indexOf(sheetComponent.source) !== -1; + }, this); + } + if(this._needsScroll) { setTimeout(function() { -- cgit v1.2.3 From f5cd1f7a93e0dbc17600d96dcb2c20702c6b5fa5 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Thu, 17 May 2012 16:01:18 -0700 Subject: Style sheets view - Remove duplicate property definition --- js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js') diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js index 8131a619..7902f80a 100644 --- a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js +++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js @@ -17,8 +17,6 @@ exports.StyleSheetsView = Montage.create(Component, { documentNameLabel : { value: null }, noDocumentLabelClass : { value: "no-document" }, - dirtyStyleSheets: { value: null }, - _documentName : { value: null }, documentName : { get: function() { -- cgit v1.2.3 From 197a7646e472fcea616764685c8d03c6063e66f5 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Fri, 18 May 2012 14:05:06 -0700 Subject: CSS Panel - Add support for deleting style sheets --- .../style-sheets-view.reel/style-sheets-view.js | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js') diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js index 7902f80a..383fc467 100644 --- a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js +++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js @@ -79,6 +79,13 @@ exports.StyleSheetsView = Montage.create(Component, { } }, + handleDeleteAction : { + value: function(sheetComponent) { + this.stylesController.removeStyleSheet(sheetComponent.source); + this._dispatchChange(); + } + }, + /// App event handlers /// -------------------------------- @@ -212,4 +219,22 @@ exports.StyleSheetsView = Montage.create(Component, { this.needsDraw = true; } }, + + ///// Utilities + //// ------------------------------------- + + _dispatchChange : { + value: function(category, type, data) { + this.application.ninja.stage.updatedStage = true; + + category = category || 'elementChange'; + type = type || 'styleSheetRemoved'; + + NJevent(category, { + type : type, + data: data, + redraw: null + }); + } + } }); \ No newline at end of file -- cgit v1.2.3 From 4553f48aa17024922569faea1f62e9251a0c0185 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Fri, 18 May 2012 14:35:09 -0700 Subject: Style sheets - Add support for removing default style sheet --- js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js') diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js index 383fc467..d6ec5349 100644 --- a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js +++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js @@ -37,6 +37,11 @@ exports.StyleSheetsView = Montage.create(Component, { set: function(sheet) { if(sheet === this._defaultStyleSheet) { return false; } + if(sheet === null) { + this._defaultStyleSheet = null; + return; + } + var sheetComponent, oldDefaultSheet; if(this.styleSheetList) { -- cgit v1.2.3 From a8e97144c832e355de7f8177ce38644119248e87 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Mon, 21 May 2012 09:30:24 -0700 Subject: Style sheets view - Fixed drawing of toolbar and "no sheets" message --- .../style-sheets-view.reel/style-sheets-view.js | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js') diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js index d6ec5349..28b094a7 100644 --- a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js +++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js @@ -8,7 +8,7 @@ var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component; exports.StyleSheetsView = Montage.create(Component, { - noDocumentCondition : { value: true }, + documentLoaded : { value: false }, showToolbar : { value: false }, stylesController : { value: null }, styleSheets : { value: [] }, @@ -17,6 +17,22 @@ exports.StyleSheetsView = Montage.create(Component, { documentNameLabel : { value: null }, noDocumentLabelClass : { value: "no-document" }, + _activeDocument: { + value: null + }, + activeDocument : { + get: function() { + return this._activeDocument; + }, + set: function(value) { + if(value === this._activeDocument) { return;} + + this.documentLoaded = !!value; + + this._activeDocument = value; + } + }, + _documentName : { value: null }, documentName : { get: function() { @@ -99,6 +115,12 @@ exports.StyleSheetsView = Montage.create(Component, { this.documentName = this.stylesController.activeDocument.name; this.styleSheets = this.stylesController.userStyleSheets; + Object.defineBinding(this, 'activeDocument', { + 'boundObject': this.stylesController, + 'boundObjectPropertyPath': 'activeDocument', + 'oneway': true + }); + Object.defineBinding(this, 'defaultStyleSheet', { 'boundObject': this.stylesController, 'boundObjectPropertyPath': 'defaultStylesheet', -- cgit v1.2.3 From 83a777effad7b20fc9b1ad925de36a261c50451a Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Mon, 21 May 2012 11:16:26 -0700 Subject: Style sheets - Clear element model style cache after deleting stylesheet --- js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js') diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js index 28b094a7..11b1d19c 100644 --- a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js +++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js @@ -103,6 +103,7 @@ exports.StyleSheetsView = Montage.create(Component, { handleDeleteAction : { value: function(sheetComponent) { this.stylesController.removeStyleSheet(sheetComponent.source); + this.stylesController._clearCache(); this._dispatchChange(); } }, -- cgit v1.2.3 From 022164517cafa5f75f6d3e5eed250ae1500f898a Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Mon, 21 May 2012 15:42:24 -0700 Subject: Style Sheets - Fix error on opening new document (without refresh) --- .../css-panel/style-sheets-view.reel/style-sheets-view.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js') diff --git a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js index 11b1d19c..5081a124 100644 --- a/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js +++ b/js/panels/css-panel/style-sheets-view.reel/style-sheets-view.js @@ -62,10 +62,12 @@ exports.StyleSheetsView = Montage.create(Component, { if(this.styleSheetList) { sheetComponent = this.styleSheetList.childComponents[this.styleSheets.indexOf(sheet)]; - sheetComponent.default = true; - if(this._defaultStyleSheet) { - oldDefaultSheet = this.styleSheetList.childComponents[this.styleSheets.indexOf(this._defaultStyleSheet)]; - oldDefaultSheet.default = false; + if(sheetComponent) { + sheetComponent.default = true; + if(this._defaultStyleSheet) { + oldDefaultSheet = this.styleSheetList.childComponents[this.styleSheets.indexOf(this._defaultStyleSheet)]; + oldDefaultSheet.default = false; + } } } -- cgit v1.2.3