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 +++++------ js/data/menu-data.js | 35 ++++++++++------------------------- js/ninja.reel/ninja.html | 14 ++++++++------ js/stage/stage-deps.js | 6 ------ js/stage/stage.reel/stage.html | 3 +++ js/stage/stage.reel/stage.js | 23 +++++++++++++++++++++++ 6 files changed, 49 insertions(+), 43 deletions(-) (limited to 'js') 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) { diff --git a/js/data/menu-data.js b/js/data/menu-data.js index 1cde3e8d..7cf40a8a 100755 --- a/js/data/menu-data.js +++ b/js/data/menu-data.js @@ -36,11 +36,8 @@ exports.MenuData = Montage.create( Montage, { "enabled": { "value": false, "boundObj": "documentController", - "boundProperty": "activeDocument", - "oneway": true, - "boundValueMutator": function(activeDocument){ - return activeDocument !== null; - } + "boundProperty": "_documents.count()", + "oneway": true }, "action": "executeFileClose" }, @@ -50,11 +47,8 @@ exports.MenuData = Montage.create( Montage, { "enabled": { "value": false, "boundObj": "documentController", - "boundProperty": "activeDocument", - "oneway": true, - "boundValueMutator": function(activeDocument){ - return activeDocument !== null; - } + "boundProperty": "_documents.count()", + "oneway": true }, "action": "executeFileCloseAll" }, @@ -68,11 +62,8 @@ exports.MenuData = Montage.create( Montage, { "enabled": { "value": false, "boundObj": "documentController", - "boundProperty": "activeDocument", - "oneway": true, - "boundValueMutator": function(activeDocument){ - return activeDocument !== null; - } + "boundProperty": "_documents.count()", + "oneway": true }, "action": "executeSave" }, @@ -82,11 +73,8 @@ exports.MenuData = Montage.create( Montage, { "enabled": { "value": false, "boundObj": "documentController", - "boundProperty": "activeDocument", - "oneway": true, - "boundValueMutator": function(activeDocument) { - return activeDocument !== null; - } + "boundProperty": "_documents.count()", + "oneway": true }, "action":"executeSaveAs" }, @@ -96,11 +84,8 @@ exports.MenuData = Montage.create( Montage, { "enabled": { "value": false, "boundObj": "documentController", - "boundProperty": "activeDocument", - "oneway": true, - "boundValueMutator": function(activeDocument){ - return activeDocument !== null; - } + "boundProperty": "_documents.count()", + "oneway": true }, "action": "executeSaveAll" }, diff --git a/js/ninja.reel/ninja.html b/js/ninja.reel/ninja.html index 52a6daa2..51d74cb2 100755 --- a/js/ninja.reel/ninja.html +++ b/js/ninja.reel/ninja.html @@ -186,6 +186,9 @@ "properties": { "element": {"#": "stageAndScenesContainer"}, "appModel": {"@": "appModel"} + }, + "bindings": { + "activeDocument": {"<-": "@documentController1.activeDocument"} } }, @@ -263,11 +266,7 @@ "selectionController1": { "prototype": "js/controllers/selection-controller", "bindings" : { - "selectionContainer": { - "boundObject": {"@": "owner"}, - "boundObjectPropertyPath": "currentSelectedContainer", - "oneway": true - } + "selectionContainer": {"<-": "@owner.currentSelectedContainer"} } }, @@ -287,7 +286,10 @@ }, "stylesController": { - "prototype": "js/controllers/styles-controller" + "prototype": "js/controllers/styles-controller", + "bindings": { + "activeDocument": {"<-": "@documentController1.activeDocument"} + } }, "presetsController": { diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index 33ba2359..1825eb06 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -95,12 +95,6 @@ exports.StageDeps = Montage.create(Component, { handleAppLoaded: { value: function() { - Object.defineBinding(this, "currentDocument", { - boundObject: this.application.ninja, - boundObjectPropertyPath: "currentDocument", - oneway: true - }); - Object.defineBinding(this, "userContentLeft", { boundObject: this.stage, boundObjectPropertyPath: "_userContentLeft", diff --git a/js/stage/stage.reel/stage.html b/js/stage/stage.reel/stage.html index 30c3d231..88cd6149 100755 --- a/js/stage/stage.reel/stage.html +++ b/js/stage/stage.reel/stage.html @@ -22,6 +22,9 @@ "prototype": "js/stage/stage-deps", "properties": { "stage": {"@": "owner"} + }, + "bindings": { + "currentDocument": {"<-": "@owner.activeDocument"} } }, diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index deed4112..125155d8 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -164,6 +164,29 @@ exports.Stage = Montage.create(Component, { set: function(value) { this._userContentBorder = value; } }, + _activeDocument : { + value : null, + enumerable : false + }, + + activeDocument : { + get : function() { + return this._activeDocument; + }, + set : function(document) { + ///// If the document is null set default stylesheets to null + + if(!document) { + return false; + } + + ///// setting document via binding + this._activeDocument = document; + + }, + enumerable : false + }, + willDraw: { value: function() { if(this.resizeCanvases) { -- cgit v1.2.3