aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
authorArmen Kesablyan2012-05-17 14:01:38 -0700
committerArmen Kesablyan2012-05-17 14:01:38 -0700
commit6c8f3525b839e82cf43df43700a0160ee2c5458f (patch)
tree3fb801fa54b759c5568d75bb467e02652ce77c3e /js/controllers
parente8ae5db7ce7023b638375cbc27a3f7b7a2f77b23 (diff)
parent342c97ac9b727b22a7b0bfefca4d2a168bc3055b (diff)
downloadninja-6c8f3525b839e82cf43df43700a0160ee2c5458f.tar.gz
Merge branch 'refs/heads/dom-architecture' into binding
Conflicts: css/ninja.css scss/imports/scss/_toolbar.scss Signed-off-by: Armen Kesablyan <armen@motorola.com>
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/color-controller.js16
-rwxr-xr-xjs/controllers/document-controller.js300
-rwxr-xr-xjs/controllers/styles-controller.js11
3 files changed, 118 insertions, 209 deletions
diff --git a/js/controllers/color-controller.js b/js/controllers/color-controller.js
index c6d664cf..d4737aad 100755
--- a/js/controllers/color-controller.js
+++ b/js/controllers/color-controller.js
@@ -9,7 +9,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
9var Montage = require("montage/core/core").Montage, 9var Montage = require("montage/core/core").Montage,
10 Component = require("montage/ui/component").Component, 10 Component = require("montage/ui/component").Component,
11 ColorModel = require("js/models/color-model").ColorModel, 11 ColorModel = require("js/models/color-model").ColorModel,
12 ColorToolbar = require("js/panels/Color/colortoolbar.reel").ColorToolbar,
13 ColorPanelBase = require("js/panels/Color/colorpanelbase.reel").ColorPanelBase, 12 ColorPanelBase = require("js/panels/Color/colorpanelbase.reel").ColorPanelBase,
14 ElementsMediator = require("js/mediators/element-mediator").ElementMediator, 13 ElementsMediator = require("js/mediators/element-mediator").ElementMediator,
15 ColorPopupManager = require("js/panels/Color/colorpopup-manager").ColorPopupManager, 14 ColorPopupManager = require("js/panels/Color/colorpopup-manager").ColorPopupManager,
@@ -368,20 +367,5 @@ exports.ColorController = Montage.create(Component, {
368 //Must be a valid CSS or null will be returned 367 //Must be a valid CSS or null will be returned
369 return color; 368 return color;
370 } 369 }
371 },
372 ////////////////////////////////////////////////////////////////////
373 ////////////////////////////////////////////////////////////////////
374 ////////////////////////////////////////////////////////////////////
375 //TODO: Remove, add via toolbar repetition
376 createToolbar: {
377 enumerable: true,
378 value: function () {
379 this.colorToolbar = ColorToolbar.create();
380 this.colorToolbar.element = document.getElementById("colortoolbar");
381 this.colorToolbar.needsDraw = true;
382 }
383 } 370 }
384 ////////////////////////////////////////////////////////////////////
385 ////////////////////////////////////////////////////////////////////
386 ////////////////////////////////////////////////////////////////////
387}); \ No newline at end of file 371}); \ No newline at end of file
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 48ceb21b..cf46e73e 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -21,10 +21,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
21 value: false 21 value: false
22 }, 22 },
23 23
24 webTemplate: {
25 value: false
26 },
27
28 _documents: { 24 _documents: {
29 value: [] 25 value: []
30 }, 26 },
@@ -33,6 +29,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
33 value: false 29 value: false
34 }, 30 },
35 31
32 _hackInitialStyles: {
33 value: true
34 },
35
36 _activeDocument: { value: null }, 36 _activeDocument: { value: null },
37 _iframeCounter: { value: 1, enumerable: false }, 37 _iframeCounter: { value: 1, enumerable: false },
38 _iframeHolder: { value: null, enumerable: false }, 38 _iframeHolder: { value: null, enumerable: false },
@@ -44,8 +44,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
44 return this._activeDocument; 44 return this._activeDocument;
45 }, 45 },
46 set: function(doc) { 46 set: function(doc) {
47 if(!!this._activeDocument){ this._activeDocument.isActive = false;} 47// if(!!this._activeDocument){ this._activeDocument.isActive = false;}
48
48 this._activeDocument = doc; 49 this._activeDocument = doc;
50
49 if(!!this._activeDocument){ 51 if(!!this._activeDocument){
50 if(this._documents.indexOf(doc) === -1) this._documents.push(doc); 52 if(this._documents.indexOf(doc) === -1) this._documents.push(doc);
51 this._activeDocument.isActive = true; 53 this._activeDocument.isActive = true;
@@ -69,25 +71,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
69 this.eventManager.addEventListener("executeFileCloseAll", this, false); 71 this.eventManager.addEventListener("executeFileCloseAll", this, false);
70 72
71 this.eventManager.addEventListener("styleSheetDirty", this, false); 73 this.eventManager.addEventListener("styleSheetDirty", this, false);
72
73 this.eventManager.addEventListener("addComponentFirstDraw", this, false);
74
75 // Temporary add listeners for the new stage templates
76 this.eventManager.addEventListener("executeWebpageOpen", this, false);
77 this.eventManager.addEventListener("executeNewWebpage", this, false);
78 } 74 }
79 }, 75 },
80 76
81 handleAddComponentFirstDraw: { 77
82 value: function (e) {
83 //TODO: Add logic to reparse the document for dynamically added styles
84 //console.log(e);
85 }
86 },
87
88
89
90
91 //TODO: Ensure these APIs are not needed 78 //TODO: Ensure these APIs are not needed
92 //////////////////////////////////////////////////////////////////// 79 ////////////////////////////////////////////////////////////////////
93 // 80 //
@@ -143,20 +130,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
143 } 130 }
144 }, 131 },
145 132
146 handleExecuteWebpageOpen: {
147 value: function(event) {
148 this.webTemplate = true;
149 this.handleExecuteFileOpen(event);
150 }
151 },
152
153 handleExecuteNewWebpage: {
154 value: function(event) {
155 this.webTemplate = true;
156 this.handleExecuteNewFile(event);
157 }
158 },
159
160 handleExecuteNewFile: { 133 handleExecuteNewFile: {
161 value: function(event) { 134 value: function(event) {
162 var newFileSettings = event._event.settings || {}; 135 var newFileSettings = event._event.settings || {};
@@ -182,6 +155,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
182 testCallback: { 155 testCallback: {
183 value: function (value) { 156 value: function (value) {
184 console.log(value); 157 console.log(value);
158 //TODO: Move this to the model.save()
159 this.activeDocument.model.needsSave = false;
185 } 160 }
186 }, 161 },
187 //////////////////////////////////////////////////////////////////// 162 ////////////////////////////////////////////////////////////////////
@@ -213,13 +188,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
213 handleExecuteFileClose:{ 188 handleExecuteFileClose:{
214 value: function(event) { 189 value: function(event) {
215 if (this.activeDocument) { 190 if (this.activeDocument) {
216 this.activeDocument.closeDocument(); 191// this.activeDocument.closeDocument();
192 this.closeFile(this.activeDocument);
217 } 193 }
218 /*
219if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
220 this.closeDocument(this.activeDocument.uuid);
221 }
222*/
223 } 194 }
224 }, 195 },
225 //////////////////////////////////////////////////////////////////// 196 ////////////////////////////////////////////////////////////////////
@@ -311,12 +282,8 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
311 this.isNewFilePath = false;//reset path identifier flag 282 this.isNewFilePath = false;//reset path identifier flag
312 283
313 //Sending full response object 284 //Sending full response object
314 // TODO: Unify those 2 methods. Using if/else for the new template 285 this.openDocument(response);
315 if(this.webTemplate) { 286
316 this.openWebDocument(response);
317 } else {
318 this.openDocument(response);
319 }
320 } else if (!!response && (response.status === 404)){ 287 } else if (!!response && (response.status === 404)){
321 alert("Unable to open file.\n [Error: File does not exist]"); 288 alert("Unable to open file.\n [Error: File does not exist]");
322 } else if (!!response && (response.status === 500)){ 289 } else if (!!response && (response.status === 500)){
@@ -352,30 +319,7 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
352 }, 319 },
353 320
354 //////////////////////////////////////////////////////////////////// 321 ////////////////////////////////////////////////////////////////////
355 openDocument: { 322 openDocument: {
356 value: function(doc) {
357
358 //
359 this.documentHackReference = doc;
360 //
361 switch (doc.extension) {
362 case 'html':
363 //Open in designer view
364 Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this));
365 break;
366 default:
367 //Open in code view
368 var code = Montage.create(TextDocument, {"source": {value: doc.content}}), docuuid = Uuid.generate(), textArea;
369 textArea = this.application.ninja.stage.stageView.createTextAreaElement(docuuid);
370 code.initialize(doc, docuuid, textArea, textArea.parentNode);
371 //code.init(doc.name, doc.uri, doc.extension, null, docuuid);
372 code.textArea.value = doc.content;
373 this.application.ninja.stage.stageView.createTextView(code);
374 break;
375 }
376 }
377 },
378 openWebDocument: {
379 value: function(doc) { 323 value: function(doc) {
380 var template, dimensions; 324 var template, dimensions;
381 if (doc.content.body.indexOf('Ninja-Banner Dimensions@@@') !== -1) { 325 if (doc.content.body.indexOf('Ninja-Banner Dimensions@@@') !== -1) {
@@ -448,7 +392,32 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
448 */ 392 */