aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
authorJonathan Duran2012-05-31 08:54:48 -0700
committerJonathan Duran2012-05-31 08:54:48 -0700
commitf297093b5bfa62c9832829751a12f0e556bb5cc0 (patch)
tree6e04cdf142cb1b36e2197970c9dc2141017a2be7 /js/controllers
parent9253e2ce98d748edd8c3929f113a597923960387 (diff)
parentd49c909cff7f0c5e5d0b127ad84a2fefc6677dc6 (diff)
downloadninja-f297093b5bfa62c9832829751a12f0e556bb5cc0.tar.gz
Merge branch 'refs/heads/NINJAmaster' into TimelineUber
Conflicts: js/panels/Timeline/Layer.reel/Layer.js js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js js/panels/properties.reel/properties.js Signed-off-by: Jonathan Duran <jduran@motorola.com>
Diffstat (limited to 'js/controllers')
-rw-r--r--js/controllers/code-editor-controller.js40
-rwxr-xr-xjs/controllers/document-controller.js555
-rwxr-xr-xjs/controllers/elements/body-controller.js30
-rwxr-xr-xjs/controllers/elements/component-controller.js4
-rwxr-xr-xjs/controllers/elements/shapes-controller.js4
-rwxr-xr-xjs/controllers/selection-controller.js40
-rwxr-xr-xjs/controllers/styles-controller.js196
7 files changed, 476 insertions, 393 deletions
<
diff --git a/js/controllers/code-editor-controller.js b/js/controllers/code-editor-controller.js
index 7913cfc1..e7163bd8 100644
--- a/js/controllers/code-editor-controller.js
+++ b/js/controllers/code-editor-controller.js
@@ -68,7 +68,7 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone
68 * Creates an editor instance 68 * Creates an editor instance
69 */ 69 */
70 createEditor : { 70 createEditor : {
71 value:function(doc, type, documentType){ 71 value:function(codeDocumentView, type, documentType, textDocument){
72 var self = this, editorOptions = null; 72 var self = this, editorOptions = null;
73 73
74 editorOptions = { 74 editorOptions = {
@@ -76,17 +76,17 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone
76 matchBrackets:true, 76 matchBrackets:true,
77 mode: type, 77 mode: type,
78 onChange: function(){ 78 onChange: function(){
79 var historySize = doc.editor.historySize(); 79 var historySize = codeDocumentView.editor.historySize();
80 if(historySize.undo>0){ 80 if(historySize.undo>0){
81 doc.needsSave = true; 81 textDocument.model.needsSave = true;
82 }else if(historySize.undo===0 && historySize.redo>0){ 82 }else if(historySize.undo===0 && historySize.redo>0){
83 doc.needsSave = false; 83 textDocument.model.needsSave = false;
84 } 84 }
85 }, 85 },
86 onCursorActivity: function() { 86 onCursorActivity: function() {
87 doc.editor.matchHighlight("CodeMirror-matchhighlight"); 87 codeDocumentView.editor.matchHighlight("CodeMirror-matchhighlight");
88 doc.editor.setLineClass(doc.editor.hline, null, null); 88 codeDocumentView.editor.setLineClass(codeDocumentView.editor.hline, null, null);
89 doc.editor.hline = doc.editor.setLineClass(doc.editor.getCursor().line, null, "activeline"); 89 codeDocumentView.editor.hline = codeDocumentView.editor.setLineClass(codeDocumentView.editor.getCursor().line, null, "activeline");
90 } 90 }
91 }; 91 };
92 92
@@ -95,9 +95,7 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone
95 editorOptions.onKeyEvent = function(cm, keyEvent){self._codeCompletionKeyEventHandler.call(self, cm, keyEvent, documentType)}; 95 editorOptions.onKeyEvent = function(cm, keyEvent){self._codeCompletionKeyEventHandler.call(self, cm, keyEvent, documentType)};
96 } 96 }
97 97
98 var editor = self.codeEditor.fromTextArea(doc.textArea, editorOptions); 98 var editor = self.codeEditor.fromTextArea(codeDocumentView.textArea, editorOptions);
99
100 //editor.setOption("theme", "night");
101 99
102 return editor; 100 return editor;
103 } 101 }
@@ -215,22 +213,22 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone
215 213
216 autoFormatSelection:{ 214 autoFormatSelection:{
217 value: function(){ 215 value: function(){
218 var range = this.getSelectedRange(this.application.ninja.documentController.activeDocument.editor); 216 var range = this.getSelectedRange(this.application.ninja.documentController.activeDocument.model.views.code.editor);
219 this.application.ninja.documentController.activeDocument.editor.autoFormatRange(range.from, range.to); 217 this.application.ninja.documentController.activeDocument.model.views.code.editor.autoFormatRange(range.from, range.to);
220 } 218 }
221 }, 219 },
222 220
223 commentSelection:{ 221 commentSelection:{
224 value: function(isComment){ 222 value: function(isComment){
225 var range = this.getSelectedRange(this.application.ninja.documentController.activeDocument.editor); 223 var range = this.getSelectedRange(this.application.ninja.documentController.activeDocument.model.views.code.editor);
226 this.application.ninja.documentController.activeDocument.editor.commentRange(isComment, range.from, range.to); 224 this.application.ninja.documentController.activeDocument.model.views.code.editor.commentRange(isComment, range.from, range.to);
227 } 225 }
228 }, 226 },
229 227
230 handleThemeSelection:{ 228 handleThemeSelection:{
231 value: function(){ 229 value: function(){
232 this.application.ninja.documentController.activeDocument.editor.setOption("theme", this.editorTheme); 230 this.application.ninja.documentController.activeDocument.model.views.code.editor.setOption("theme", this.editorTheme);
233 this.application.ninja.stage.stageView.applyTheme("cm-s-"+this.editorTheme); 231 this.application.ninja.documentController.activeDocument.model.views.code.applyTheme("cm-s-"+this.editorTheme);
234 } 232 }
235 }, 233 },
236 234
@@ -238,10 +236,10 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone
238 value:function(value){ 236 value:function(value){
239 var originalFont=13,originalLineHeight=16; 237 var originalFont=13,originalLineHeight=16;
240 this._zoomFactor = value; 238 this._zoomFactor = value;
241 this.application.ninja.documentController.activeDocument.container.style.fontSize = ""+((value/100)*originalFont)+"px"; 239 this.application.ninja.documentController.activeDocument.model.views.code.textViewContainer.style.fontSize = ""+((value/100)*originalFont)+"px";
242 this.application.ninja.documentController.activeDocument.container.style.cursor = "text"; 240 this.application.ninja.documentController.activeDocument.model.views.code.textViewContainer.style.cursor = "text";
243 this.application.ninja.documentController.activeDocument.container.querySelector(".CodeMirror").style.lineHeight = ""+((value/100)*originalLineHeight)+"px"; 241 this.application.ninja.documentController.activeDocument.model.views.code.textViewContainer.querySelector(".CodeMirror").style.lineHeight = ""+((value/100)*originalLineHeight)+"px";
244 this.application.ninja.documentController.activeDocument.editor.refresh();//refresh editor display for xoom 242 this.application.ninja.documentController.activeDocument.model.views.code.editor.refresh();//refresh editor display for xoom
245 } 243 }
246 }, 244 },
247 245
@@ -250,7 +248,7 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone
250 //set theme 248 //set theme
251 this.handleThemeSelection(); 249 this.handleThemeSelection();
252 //check autocomplete support 250 //check autocomplete support
253 this.handleCodeCompletionSupport(this.application.ninja.documentController.activeDocument.documentType); 251 this.handleCodeCompletionSupport(this.application.ninja.documentController.activeDocument.model.file.extension);
254 //set zoom 252 //set zoom
255 this.handleZoom(this._zoomFactor); 253 this.handleZoom(this._zoomFactor);
256 } 254 }
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index c6bf4c6b..2c34eedf 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -9,31 +9,18 @@ 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 Uuid = require("montage/core/uuid").Uuid, 11 Uuid = require("montage/core/uuid").Uuid,
12 HTMLDocument = require("js/document/html-document").HTMLDocument, 12 HTMLDocument = require("js/document/document-html").HtmlDocument,
13 TextDocument = require("js/document/text-document").TextDocument; 13 TextDocument = require("js/document/document-text").TextDocument;
14
15 // New Document Objects
16var Document = require("js/document/document-html").HtmlDocument;
17//////////////////////////////////////////////////////////////////////// 14////////////////////////////////////////////////////////////////////////
18// 15//
19var DocumentController = exports.DocumentController = Montage.create(Component, { 16exports.DocumentController = Montage.create(Component, {
20 hasTemplate: { 17 //
21 value: false 18 hasTemplate: {value: false},
22 }, 19 _documents: {value: []},
23 20 //TODO: what is this?!?!
24 webTemplate: { 21 _hackInitialStyles: {value: true},
25 value: false
26 },
27
28 _documents: {
29 value: []
30 },
31
32 _hackRootFlag: {
33 value: false
34 },
35
36 _activeDocument: { value: null }, 22 _activeDocument: { value: null },
23 //TODO: Are any of these needed?
37 _iframeCounter: { value: 1, enumerable: false }, 24 _iframeCounter: { value: 1, enumerable: false },
38 _iframeHolder: { value: null, enumerable: false }, 25 _iframeHolder: { value: null, enumerable: false },
39 _textHolder: { value: null, enumerable: false }, 26 _textHolder: { value: null, enumerable: false },
@@ -44,21 +31,19 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
44 return this._activeDocument; 31 return this._activeDocument;
45 }, 32 },
46 set: function(doc) { 33 set: function(doc) {
47 if(!!this._activeDocument){ this._activeDocument.isActive = false;} 34 //if(!!this._activeDocument){ this._activeDocument.isActive = false;}
35
48 this._activeDocument = doc; 36 this._activeDocument = doc;
37
49 if(!!this._activeDocument){ 38 if(!!this._activeDocument){
50 if(this._documents.indexOf(doc) === -1) this._documents.push(doc); 39 if(this._documents.indexOf(doc) === -1) this._documents.push(doc);
51 this._activeDocument.isActive = true; 40 this._activeDocument.isActive = true;
52
53 if(!!this._activeDocument.editor){
54 this._activeDocument.editor.focus();
55 }
56 } 41 }
57 } 42 }
58 }, 43 },
59 44
60 deserializedFromTemplate: { 45 deserializedFromTemplate: {
61 value: function() { 46 value: function() { //TODO: Add event naming consistency (save, fileOpen and newFile should be consistent, all file events should be executeFile[operation name])
62 this.eventManager.addEventListener("appLoaded", this, false); 47 this.eventManager.addEventListener("appLoaded", this, false);
63 this.eventManager.addEventListener("executeFileOpen", this, false); 48 this.eventManager.addEventListener("executeFileOpen", this, false);
64 this.eventManager.addEventListener("executeNewFile", this, false); 49 this.eventManager.addEventListener("executeNewFile", this, false);
@@ -69,37 +54,30 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
69 this.eventManager.addEventListener("executeFileCloseAll", this, false); 54 this.eventManager.addEventListener("executeFileCloseAll", this, false);
70 55
71 this.eventManager.addEventListener("styleSheetDirty", this, false); 56 this.eventManager.addEventListener("styleSheetDirty", this, false);
72
73 this.eventManager.addEventListener("addComponentFirstDraw", this, false);