aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/document-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/document-controller.js')
-rwxr-xr-xjs/controllers/document-controller.js39
1 files changed, 17 insertions, 22 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 84b994ce..f397ace7 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -9,8 +9,8 @@ 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/io/document/html-document").HTMLDocument, 12 HTMLDocument = require("js/document/html-document").HTMLDocument,
13 TextDocument = require("js/io/document/text-document").TextDocument, 13 TextDocument = require("js/document/text-document").TextDocument,
14 DocumentController; 14 DocumentController;
15//////////////////////////////////////////////////////////////////////// 15////////////////////////////////////////////////////////////////////////
16// 16//
@@ -28,13 +28,7 @@ DocumentController = exports.DocumentController = Montage.create(Component, {
28 _iframeHolder: { value: null, enumerable: false }, 28 _iframeHolder: { value: null, enumerable: false },
29 _textHolder: { value: null, enumerable: false }, 29 _textHolder: { value: null, enumerable: false },
30 _codeMirrorCounter: {value: 1, enumerable: false}, 30 _codeMirrorCounter: {value: 1, enumerable: false},
31 31
32 tmpSourceForTesting: {
33 value: "function CodeMirror(place, givenOptions) {" +
34 "// Determine effective options based on given values and defaults." +
35 "var options = {}, defaults = CodeMirror.defaults; }"
36 },
37
38 activeDocument: { 32 activeDocument: {
39 get: function() { 33 get: function() {
40 return this._activeDocument; 34 return this._activeDocument;
@@ -62,21 +56,12 @@ DocumentController = exports.DocumentController = Montage.create(Component, {
62 this.eventManager.addEventListener("executeSave", this, false); 56 this.eventManager.addEventListener("executeSave", this, false);
63 57
64 this.eventManager.addEventListener("recordStyleChanged", this, false); 58 this.eventManager.addEventListener("recordStyleChanged", this, false);
65
66 // Temporary testing opening a new file after Ninja has loaded
67 this.eventManager.addEventListener("executeNewProject", this, false);
68 } 59 }
69 }, 60 },
70 61
71 handleAppLoaded: { 62 handleAppLoaded: {
72 value: function() { 63 value: function() {
73 //this.openDocument({"type": "html"}); 64 //
74 }
75 },
76
77 handleExecuteNewProject: {
78 value: function() {
79 this.openDocument({"type": "html"});
80 } 65 }
81 }, 66 },
82 67
@@ -104,16 +89,26 @@ DocumentController = exports.DocumentController = Montage.create(Component, {
104 handleExecuteSave: { 89 handleExecuteSave: {
105 value: function(event) { 90 value: function(event) {
106 //Text and HTML document classes should return the same save object for fileSave 91 //Text and HTML document classes should return the same save object for fileSave
107 this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.clearDocumentDirtyFlag.bind(this)); 92 this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this));
108 } 93 }
109 }, 94 },
110 95 ////////////////////////////////////////////////////////////////////
96 //
97 fileSaveResult: {
98 value: function (result) {
99 if(result.status === 204){
100 this.clearDocumentDirtyFlag();
101 }
102 }
103 },
104 ////////////////////////////////////////////////////////////////////
105
106
111 clearDocumentDirtyFlag:{ 107 clearDocumentDirtyFlag:{
112 value: function(){ 108 value: function(){
113 this.activeDocument.dirtyFlag = false; 109 this.activeDocument.dirtyFlag = false;
114 } 110 }
115 }, 111 },
116 ////////////////////////////////////////////////////////////////////
117 112
118 113
119 createNewFile:{ 114 createNewFile:{