diff options
author | Jon Reid | 2012-02-27 12:08:17 -0800 |
---|---|---|
committer | Jon Reid | 2012-02-27 12:08:17 -0800 |
commit | d55224f36da55e26c266a02efa6e58d4ecf1253e (patch) | |
tree | 36faa8ff93c0f7b925f5c0a7fb85b5d209da1f8e /js/controllers | |
parent | ec5f81c6c0ccf865505ab82ebf9240c667f05c91 (diff) | |
parent | cf9e9b711ba3d77a2a0888f8ab763383f53a1619 (diff) | |
download | ninja-d55224f36da55e26c266a02efa6e58d4ecf1253e.tar.gz |
Merge remote-tracking branch 'ninja-jduran/Timeline' into Timeline-local
Diffstat (limited to 'js/controllers')
-rwxr-xr-x | js/controllers/document-controller.js | 66 | ||||
-rwxr-xr-x | js/controllers/elements/element-controller.js | 6 | ||||
-rwxr-xr-x | js/controllers/local-storage-controller.js | 67 | ||||
-rwxr-xr-x | js/controllers/selection-controller.js | 9 | ||||
-rwxr-xr-x | js/controllers/styles-controller.js | 44 |
5 files changed, 121 insertions, 71 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 843db87c..02031922 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -58,6 +58,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
58 | this.eventManager.addEventListener("executeFileOpen", this, false); | 58 | this.eventManager.addEventListener("executeFileOpen", this, false); |
59 | this.eventManager.addEventListener("executeNewFile", this, false); | 59 | this.eventManager.addEventListener("executeNewFile", this, false); |
60 | this.eventManager.addEventListener("executeSave", this, false); | 60 | this.eventManager.addEventListener("executeSave", this, false); |
61 | this.eventManager.addEventListener("executeSaveAs", this, false); | ||
62 | this.eventManager.addEventListener("executeSaveAll", this, false); | ||
61 | 63 | ||
62 | this.eventManager.addEventListener("recordStyleChanged", this, false); | 64 | this.eventManager.addEventListener("recordStyleChanged", this, false); |
63 | 65 | ||
@@ -87,11 +89,11 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
87 | //Checking for app to be loaded through extension | 89 | //Checking for app to be loaded through extension |
88 | var check; | 90 | var check; |
89 | if (chrome && chrome.app) { | 91 | if (chrome && chrome.app) { |
90 | check = chrome.app.getDetails(); | 92 | check = chrome.app.getDetails(); |
91 | } | 93 | } |
92 | if (check !== null) { | 94 | if (check !== null) { |
93 | //Adding an intercept to resources loaded to ensure user assets load from cloud simulator | 95 | //Adding an intercept to resources loaded to ensure user assets load from cloud simulator |
94 | chrome.webRequest.onBeforeRequest.addListener(this.handleWebRequest.bind(this), {urls: ["<all_urls>"]}, ["blocking"]); | 96 | chrome.webRequest.onBeforeRequest.addListener(this.handleWebRequest.bind(this), {urls: ["<all_urls>"]}, ["blocking"]); |
95 | } | 97 | } |
96 | } | 98 | } |
97 | }, | 99 | }, |
@@ -107,33 +109,57 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
107 | handleExecuteFileOpen: { | 109 | handleExecuteFileOpen: { |
108 | value: function(event) { | 110 | value: function(event) { |
109 | var pickerSettings = event._event.settings || {}; | 111 | var pickerSettings = event._event.settings || {}; |
110 | pickerSettings.callback = this.openFileWithURI.bind(this); | 112 | if (this.application.ninja.coreIoApi.cloudAvailable()) { |
111 | pickerSettings.pickerMode = "read"; | 113 | pickerSettings.callback = this.openFileWithURI.bind(this); |
112 | pickerSettings.inFileMode = true; | 114 | pickerSettings.pickerMode = "read"; |
113 | this.application.ninja.filePickerController.showFilePicker(pickerSettings); | 115 | pickerSettings.inFileMode = true; |
116 | this.application.ninja.filePickerController.showFilePicker(pickerSettings); | ||
117 | } | ||
114 | } | 118 | } |
115 | }, | 119 | }, |
116 | 120 | ||
117 | handleExecuteNewFile: { | 121 | handleExecuteNewFile: { |
118 | value: function(event) { | 122 | value: function(event) { |
119 | var newFileSettings = event._event.settings || {}; | 123 | var newFileSettings = event._event.settings || {}; |
120 | newFileSettings.callback = this.createNewFile.bind(this); | 124 | if (this.application.ninja.coreIoApi.cloudAvailable()) { |
121 | this.application.ninja.newFileController.showNewFileDialog(newFileSettings); | 125 | newFileSettings.callback = this.createNewFile.bind(this); |
126 | this.application.ninja.newFileController.showNewFileDialog(newFileSettings); | ||
127 | } | ||
122 | } | 128 | } |
123 | }, | 129 | }, |
124 | |||
125 | |||
126 | //////////////////////////////////////////////////////////////////// | 130 | //////////////////////////////////////////////////////////////////// |
127 | //TODO: Check for appropiate structures | 131 | //TODO: Check for appropiate structures |
128 | handleExecuteSave: { | 132 | handleExecuteSave: { |
129 | value: function(event) { | 133 | value: function(event) { |
130 | if(!!this.activeDocument){ | 134 | if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ |
131 | //Text and HTML document classes should return the same save object for fileSave | 135 | //Text and HTML document classes should return the same save object for fileSave |
132 | this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this)); | 136 | this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this)); |
137 | } | ||
133 | } | 138 | } |
139 | }, | ||
140 | //////////////////////////////////////////////////////////////////// | ||
141 | //TODO: Check for appropiate structures | ||
142 | handleExecuteSaveAll: { | ||
143 | value: function(event) { | ||
144 | if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ | ||
145 | //Text and HTML document classes should return the same save object for fileSave | ||
146 | this.application.ninja.ioMediator.fileSave(this.activeDocument.saveAll(), this.fileSaveResult.bind(this)); | ||
147 | } | ||
134 | } | 148 | } |
135 | }, | 149 | }, |
136 | //////////////////////////////////////////////////////////////////// | 150 | //////////////////////////////////////////////////////////////////// |
151 | handleExecuteSaveAs: { | ||
152 | value: function(event) { | ||
153 | var saveAsSettings = event._event.settings || {}; | ||
154 | if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ | ||
155 | saveAsSettings.fileName = this.activeDocument.name; | ||
156 | saveAsSettings.folderUri = this.activeDocument.uri.substring(0, this.activeDocument.uri.lastIndexOf("/")); | ||
157 | //add callback | ||
158 | this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); | ||
159 | } | ||
160 | } | ||
161 | }, | ||
162 | |||
137 | // | 163 | // |
138 | fileSaveResult: { | 164 | fileSaveResult: { |
139 | value: function (result) { | 165 | value: function (result) { |
@@ -298,7 +324,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
298 | if(this.activeDocument.uuid === id && this._documents.length > 0) {//closing the active document tab | 324 | if(this.activeDocument.uuid === id && this._documents.length > 0) {//closing the active document tab |
299 | var nextDocumentIndex = -1 ; | 325 | var nextDocumentIndex = -1 ; |
300 | if((this._documents.length > 0) && (closeDocumentIndex === 0)){ | 326 | if((this._documents.length > 0) && (closeDocumentIndex === 0)){ |
301 | nextDocumentIndex = 1; | 327 | nextDocumentIndex = 0; |
302 | }else if((this._documents.length > 0) && (closeDocumentIndex > 0)){ | 328 | }else if((this._documents.length > 0) && (closeDocumentIndex > 0)){ |
303 | nextDocumentIndex = closeDocumentIndex - 1; | 329 | nextDocumentIndex = closeDocumentIndex - 1; |
304 | } | 330 | } |
@@ -312,6 +338,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
312 | 338 | ||
313 | this.application.ninja.stage.hideCanvas(true); | 339 | this.application.ninja.stage.hideCanvas(true); |
314 | } | 340 | } |
341 | |||
342 | NJevent("closeDocument", doc.uri); | ||
343 | |||
344 | doc=null; | ||
315 | } | 345 | } |
316 | }, | 346 | }, |
317 | 347 | ||
@@ -319,7 +349,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
319 | // Event Detail: Contains the current ActiveDocument | 349 | // Event Detail: Contains the current ActiveDocument |
320 | _onOpenDocument: { | 350 | _onOpenDocument: { |
321 | value: function(doc){ | 351 | value: function(doc){ |
322 | //var data = DocumentManager.activeDocument; | 352 | this.application.ninja.currentDocument = doc; |
323 | this._hideCurrentDocument(); | 353 | this._hideCurrentDocument(); |
324 | this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); | 354 | this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); |
325 | 355 | ||
@@ -403,7 +433,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
403 | value: function() { | 433 | value: function() { |
404 | if(this.activeDocument) { | 434 | if(this.activeDocument) { |
405 | if(this.activeDocument.currentView === "design"){ | 435 | if(this.activeDocument.currentView === "design"){ |
406 | this.application.ninja.stage.saveScroll(); | 436 | this.activeDocument.saveAppState(); |
407 | this.activeDocument.container.parentNode.style["display"] = "none"; | 437 | this.activeDocument.container.parentNode.style["display"] = "none"; |
408 | this.application.ninja.stage.hideCanvas(true); | 438 | this.application.ninja.stage.hideCanvas(true); |
409 | this.application.ninja.stage.stageView.hideRulers(); | 439 | this.application.ninja.stage.stageView.hideRulers(); |
@@ -420,7 +450,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
420 | this.activeDocument.container.style["display"] = "block"; | 450 | this.activeDocument.container.style["display"] = "block"; |
421 | if(this.activeDocument.currentView === "design"){ | 451 | if(this.activeDocument.currentView === "design"){ |
422 | this.activeDocument.container.parentNode.style["display"] = "block"; | 452 | this.activeDocument.container.parentNode.style["display"] = "block"; |
423 | this.application.ninja.stage.restoreScroll(); | 453 | this.activeDocument.restoreAppState(); |
424 | this.application.ninja.stage.hideCanvas(false); | 454 | this.application.ninja.stage.hideCanvas(false); |
425 | this.application.ninja.stage.stageView.showRulers(); | 455 | this.application.ninja.stage.stageView.showRulers(); |
426 | }else{ | 456 | }else{ |
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 46e82ace..ec0335b4 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js | |||
@@ -27,7 +27,11 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, | |||
27 | 27 | ||
28 | getProperty: { | 28 | getProperty: { |
29 | value: function(el, prop, fallbackOnComputed, isStageElement) { | 29 | value: function(el, prop, fallbackOnComputed, isStageElement) { |
30 | return this.application.ninja.stylesController.getElementStyle(el, prop, fallbackOnComputed, isStageElement); | 30 | if(el.nodeType !== 3){ |
31 | return this.application.ninja.stylesController.getElementStyle(el, prop, fallbackOnComputed, isStageElement); | ||
32 | }else{ | ||
33 | return null; | ||
34 | } | ||
31 | } | 35 | } |
32 | }, | 36 | }, |
33 | 37 | ||
diff --git a/js/controllers/local-storage-controller.js b/js/controllers/local-storage-controller.js index 6963b245..1388f3e5 100755 --- a/js/controllers/local-storage-controller.js +++ b/js/controllers/local-storage-controller.js | |||
@@ -7,44 +7,51 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | Component = require("montage/ui/component").Component; | 8 | Component = require("montage/ui/component").Component; |
9 | 9 | ||
10 | exports.LocalStorage = Montage.create( Montage, { | 10 | exports.LocalStorage = Montage.create( Component, { |
11 | 11 | ||
12 | getItem: { | 12 | canStore: { |
13 | value: function(item) { | 13 | value: null |
14 | var item; | 14 | }, |
15 | |||
16 | if (window.localStorage) { | ||
17 | item = window.localStorage.getItem(item); | ||
18 | if(item !== null) return JSON.parse(item) | ||