aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rwxr-xr-xjs/controllers/document-controller.js18
-rwxr-xr-xjs/controllers/styles-controller.js34
-rwxr-xr-xjs/document/document-html.js15
-rwxr-xr-xjs/document/models/base.js15
-rwxr-xr-xjs/document/views/code.js4
-rw-r--r--js/document/views/design-code.js27
-rwxr-xr-xjs/document/views/design.js4
-rwxr-xr-xjs/stage/binding-view.reel/binding-view.js24
-rwxr-xr-xjs/stage/stage.reel/stage.js20
9 files changed, 124 insertions, 37 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index ee7ca82c..83c1f58c 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -80,6 +80,7 @@ exports.DocumentController = Montage.create(Component, {
80 } else if(this._currentDocument.currentView === "design") { 80 } else if(this._currentDocument.currentView === "design") {
81 document.getElementById("codeViewContainer").style.display = "none"; 81 document.getElementById("codeViewContainer").style.display = "none";
82 document.getElementById("iframeContainer").style.display = "block"; 82 document.getElementById("iframeContainer").style.display = "block";
83 this._currentDocument.addPropertyChangeListener("model.currentViewIdentifier", this, false);
83 if (this._currentDocument.model.currentView) this._currentDocument.model.currentView.show(); 84 if (this._currentDocument.model.currentView) this._currentDocument.model.currentView.show();
84 this._currentDocument.model.views.design._liveNodeList = this._currentDocument.model.documentRoot.getElementsByTagName('*'); 85 this._currentDocument.model.views.design._liveNodeList = this._currentDocument.model.documentRoot.getElementsByTagName('*');
85 } else { 86 } else {
@@ -91,6 +92,23 @@ exports.DocumentController = Montage.create(Component, {
91 } 92 }
92 }, 93 },
93 94
95 handleChange: {
96 value: function(notification) {
97 if(notification.currentPropertyPath === "model.currentViewIdentifier") {
98 if(this.currentDocument.model.currentView.identifier === "design-code") {
99// document.getElementById("iframeContainer").style.display = "none";
100// this._currentDocument.model.parentContainer.style["display"] = "block";
101// if (this._currentDocument.model.currentView) this._currentDocument.model.currentView.show();
102 } else {
103 document.getElementById("codeViewContainer").style.display = "none";
104 document.getElementById("iframeContainer").style.display = "block";
105 if (this._currentDocument.model.currentView) this._currentDocument.model.currentView.show();
106 this._currentDocument.model.views.design._liveNodeList = this._currentDocument.model.documentRoot.getElementsByTagName('*');
107 }
108 }
109 }
110 },
111
94 deserializedFromTemplate: { 112 deserializedFromTemplate: {
95 value: function() { //TODO: Add event naming consistency (save, fileOpen and newFile should be consistent, all file events should be executeFile[operation name]) 113 value: function() { //TODO: Add event naming consistency (save, fileOpen and newFile should be consistent, all file events should be executeFile[operation name])
96 this.eventManager.addEventListener("appLoaded", this, false); 114 this.eventManager.addEventListener("appLoaded", this, false);
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index 21321f6d..0e1df1e9 100755
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -99,6 +99,8 @@ var stylesController = exports.StylesController = Montage.create(Component, {
99 ///// setting document via binding 99 ///// setting document via binding
100 this._currentDocument = document; 100 this._currentDocument = document;
101 101
102 this._currentDocument.addPropertyChangeListener("model.currentViewIdentifier", this, false);
103
102 ///// Stage stylesheet should always be found 104 ///// Stage stylesheet should always be found
103 this._stageStylesheet = this.getSheetFromElement(this.CONST.STAGE_SHEET_ID); 105 this._stageStylesheet = this.getSheetFromElement(this.CONST.STAGE_SHEET_ID);
104 // Returns null if sheet not found (as in non-ninja projects) 106 // Returns null if sheet not found (as in non-ninja projects)
@@ -126,6 +128,38 @@ var stylesController = exports.StylesController = Montage.create(Component, {
126 enumerable : false 128 enumerable : false
127 }, 129 },
128 130
131 handleChange: {
132 value: function(notification) {
133 if(notification.currentPropertyPath === "model.currentViewIdentifier") {
134 if(this.currentDocument.model.currentView.identifier === "design") {
135 ///// Stage stylesheet should always be found
136 this._stageStylesheet = this.getSheetFromElement(this.CONST.STAGE_SHEET_ID);
137 // Returns null if sheet not found (as in non-ninja projects)
138 // Setter will handle null case
139 this.defaultStylesheet = this.getSheetFromElement(this.CONST.DEFAULT_SHEET_ID);
140
141 this.userStyleSheets = nj.toArray(this.currentDocument.model.views.design.document.styleSheets).filter(function(sheet) {
142 if(sheet === this._stageStylesheet) { return false; }
143
144 var media = sheet.ownerNode.getAttribute('media');
145
146 ///// If the media attribute contains a query, we'll watch for changes in media
147 if(/\([0-9A-Za-z-: ]+\)/.test(media)) {
148 this.watchMedia(media);
149 }
150
151 return true;
152
153 }, this);
154
155 this.initializeRootStyles();
156
157 NJevent('styleSheetsReady', this);
158 }
159 }
160 }
161 },
162
129 _mediaList : { 163 _mediaList : {
130 value: [] 164 value: []
131 }, 165 },
diff --git a/js/document/document-html.js b/js/document/document-html.js
index a59f5848..f3163339 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -164,7 +164,7 @@ exports.HtmlDocument = Montage.create(Component, {
164 //Adding observer to know when template is ready 164 //Adding observer to know when template is ready
165 this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); 165 this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this));
166 this._observer.observe(this.model.views.design.document.head, {childList: true}); 166 this._observer.observe(this.model.views.design.document.head, {childList: true});
167 }.bind(this), template, {viewCallback: this.handleViewReady, context: this}); 167 }.bind(this), template, {viewCallback: this.handleReloadViewReady, context: this});
168 } else if(view === 'code'){ 168 } else if(view === 'code'){
169 //TODO: Add logic to handle external changed files 169 //TODO: Add logic to handle external changed files
170 //Checking for template type and not saving external data 170 //Checking for template type and not saving external data
@@ -176,6 +176,7 @@ exports.HtmlDocument = Montage.create(Component, {
176 //Setting current view object to code 176 //Setting current view object to code
177 this.currentView = 'code'; 177 this.currentView = 'code';
178 this.model.currentView = this.model.views.code; 178 this.model.currentView = this.model.views.code;
179 this.model.currentViewIdentifier = this.model.currentView.identifier;
179 } else { 180 } else {
180 //TODO: Identify default view (probably code) - Error handling 181 //TODO: Identify default view (probably code) - Error handling
181 } 182 }
@@ -200,10 +201,22 @@ exports.HtmlDocument = Montage.create(Component, {
200 if(typeof this.model.domContainer !== "undefined") { 201 if(typeof this.model.domContainer !== "undefined") {
201 this.model.domContainer = this.model.documentRoot; 202 this.model.domContainer = this.model.documentRoot;
202 } 203 }
204 this.model.currentViewIdentifier = this.model.currentView.identifier;
203 //Making callback after view is loaded 205 //Making callback after view is loaded
204 this.loaded.callback.call(this.loaded.context, this); 206 this.loaded.callback.call(this.loaded.context, this);
205 } 207 }
206 }, 208 },
209 handleReloadViewReady: {
210 value: function(mObjects) {
211 this.model.mObjects = mObjects;
212 // TODO: Find a better way to initialize this property
213 // Assign the domContainer to be the document root on open
214 if(typeof this.model.domContainer !== "undefined") {
215 this.model.domContainer = this.model.documentRoot;
216 }
217 this.model.currentViewIdentifier = this.model.currentView.identifier;
218 }
219 },
207 //////////////////////////////////////////////////////////////////// 220 ////////////////////////////////////////////////////////////////////
208 // 221 //
209 closeDocument: { 222 closeDocument: {
diff --git a/js/document/models/base.js b/js/document/models/base.js
index a9bbd6db..03c792c9 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -88,6 +88,21 @@ exports.BaseDocumentModel = Montage.create(Component, {
88 }, 88 },
89 //////////////////////////////////////////////////////////////////// 89 ////////////////////////////////////////////////////////////////////
90 // 90 //
91 _currentViewIdentifier: {
92 value: ""
93 },
94 ////////////////////////////////////////////////////////////////////
95 //
96 currentViewIdentifier: {
97 get: function() {
98 return this._currentViewIdentifier;
99 },
100 set: function(value) {
101 this._currentViewIdentifier = value;
102 }
103 },
104 ////////////////////////////////////////////////////////////////////
105 //
91 _selection: { 106 _selection: {
92 value: [] 107 value: []
93 }, 108 },
diff --git a/js/document/views/code.js b/js/document/views/code.js
index 05f671b2..0ca87fa9 100755
--- a/js/document/views/code.js
+++ b/js/document/views/code.js
@@ -39,8 +39,8 @@ var Montage = require("montage/core/core").Montage,
39exports.CodeDocumentView = Montage.create(BaseDocumentView, { 39exports.CodeDocumentView = Montage.create(BaseDocumentView, {
40 //////////////////////////////////////////////////////////////////// 40 ////////////////////////////////////////////////////////////////////
41 // 41 //
42 hasTemplate: { 42 identifier: {
43 value: false 43 value: "code"
44 }, 44 },
45 //////////////////////////////////////////////////////////////////// 45 ////////////////////////////////////////////////////////////////////
46 // 46 //
diff --git a/js/document/views/design-code.js b/js/document/views/design-code.js
index 25073833..44d12549 100644
--- a/js/document/views/design-code.js
+++ b/js/document/views/design-code.js
@@ -40,8 +40,8 @@ var Montage = require("montage/core/core").Montage,
40exports.DesignCodeView = Montage.create(CodeDocumentView, { 40exports.DesignCodeView = Montage.create(CodeDocumentView, {
41 //////////////////////////////////////////////////////////////////// 41 ////////////////////////////////////////////////////////////////////
42 // 42 //
43 hasTemplate: { 43 identifier: {
44 value: false 44 value: "design-code"
45 }, 45 },
46 //////////////////////////////////////////////////////////////////// 46 ////////////////////////////////////////////////////////////////////
47 // 47 //
@@ -75,22 +75,6 @@ exports.DesignCodeView = Montage.create(CodeDocumentView, {
75 this.textViewContainer.style.background = "white"; 75 this.textViewContainer.style.background = "white";
76 this.textViewContainer.style.height = "100%"; 76 this.textViewContainer.style.height = "100%";
77 77
78
79 ///todo-remove after the switch view logic is added in all the components
80 this.application.ninja.stage.collapseAllPanels();
81 this.application.ninja.stage.hideCanvas(true);
82 this.application.ninja.stage.hideRulers();
83