aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/controllers/document-controller.js7
-rwxr-xr-xjs/document/document-html.js37
-rwxr-xr-xjs/document/models/base.js43
-rwxr-xr-xjs/document/views/design.js31
4 files changed, 103 insertions, 15 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 682bd6a6..58fa4de7 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -211,9 +211,14 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
211 //////////////////////////////////////////////////////////////////// 211 ////////////////////////////////////////////////////////////////////
212 handleExecuteFileClose:{ 212 handleExecuteFileClose:{
213 value: function(event) { 213 value: function(event) {
214 if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ 214 if (this.activeDocument) {
215 this.activeDocument.closeDocument();
216 }
217 /*
218if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
215 this.closeDocument(this.activeDocument.uuid); 219 this.closeDocument(this.activeDocument.uuid);
216 } 220 }
221*/
217 } 222 }
218 }, 223 },
219 //////////////////////////////////////////////////////////////////// 224 ////////////////////////////////////////////////////////////////////
diff --git a/js/document/document-html.js b/js/document/document-html.js
index 567e4455..e00333f0 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -70,10 +70,11 @@ exports.HtmlDocument = Montage.create(Component, {
70 //Creating instance of HTML Document Model 70 //Creating instance of HTML Document Model
71 this.model = Montage.create(HtmlDocumentModel,{ 71 this.model = Montage.create(HtmlDocumentModel,{
72 file: {value: file}, 72 file: {value: file},
73 parentContainer: {value: document.getElementById("iframeContainer")}, //Saving reference to parent container of all views (should be changed to buckets approach
73 views: {value: {'design': DesignDocumentView.create(), 'code': null}} //TODO: Add code view logic 74 views: {value: {'design': DesignDocumentView.create(), 'code': null}} //TODO: Add code view logic
74 }); 75 });
75 //Initiliazing views and hiding 76 //Initiliazing views and hiding
76 if (this.model.views.design.initialize(document.getElementById("iframeContainer"))) { 77 if (this.model.views.design.initialize(this.model.parentContainer)) {
77 //Hiding iFrame, just initiliazing 78 //Hiding iFrame, just initiliazing
78 this.model.views.design.hide(); 79 this.model.views.design.hide();
79 } else { 80 } else {
@@ -123,6 +124,40 @@ exports.HtmlDocument = Montage.create(Component, {
123 //Setting opacity to be viewable after load 124 //Setting opacity to be viewable after load
124 this.model.views.design.iframe.style.opacity = 1; 125 this.model.views.design.iframe.style.opacity = 1;
125 } 126 }
127 },
128 ////////////////////////////////////////////////////////////////////
129 //
130 closeDocument: {
131 value: function () {
132 //
133 this.model.close(null, this.handleCloseDocument.bind(this));
134 }
135 },
136 ////////////////////////////////////////////////////////////////////
137 //
138 handleCloseDocument: {
139 value: function (success) {
140 //TODO: Add logic for handling success or failure
141 //
142 this.application.ninja.documentController._documents.splice(this.uuid, 1);
143 //
144 NJevent("closeDocument", this.model.file.uri);
145 //TODO: Delete object here
146 }
147 },
148 ////////////////////////////////////////////////////////////////////
149 //
150 saveAppState: {
151 value: function () {
152 //TODO: Import functionality
153 }
154 },
155 ////////////////////////////////////////////////////////////////////
156 //
157 restoreAppState: {
158 value: function () {
159 //TODO: Import functionality
160 }
126 } 161 }
127 //////////////////////////////////////////////////////////////////// 162 ////////////////////////////////////////////////////////////////////
128 //////////////////////////////////////////////////////////////////// 163 ////////////////////////////////////////////////////////////////////
diff --git a/js/document/models/base.js b/js/document/models/base.js
index 2bbbe501..ebfb73b8 100755
--- a/js/document/models/base.js
+++ b/js/document/models/base.js
@@ -62,6 +62,11 @@ exports.BaseDocumentModel = Montage.create(Component, {
62 }, 62 },
63 //////////////////////////////////////////////////////////////////// 63 ////////////////////////////////////////////////////////////////////
64 // 64 //
65 parentContainer: {
66 value: null
67 },
68 ////////////////////////////////////////////////////////////////////
69 //
65 views: { 70 views: {
66 value: null 71 value: null
67 }, 72 },
@@ -115,6 +120,12 @@ exports.BaseDocumentModel = Montage.create(Component, {
115 save: { 120 save: {
116 value: function (callback) { 121 value: function (callback) {
117 // 122 //
123 if (this.needsSave) {
124 //Save
125 } else {
126 //Ignore command
127 }
128 //
118 if (this.currentView === this.views.design) { 129 if (this.currentView === this.views.design) {
119 // 130 //
120 this.application.ninja.ioMediator.fileSave({ 131 this.application.ninja.ioMediator.fileSave({
@@ -129,18 +140,18 @@ exports.BaseDocumentModel = Montage.create(Component, {
129 } else { 140 } else {
130 //TODO: Add logic to save code view data 141 //TODO: Add logic to save code view data
131 } 142 }
132 //
133 if (this.needsSave) {
134 //Save
135 } else {
136 //Ignore command
137 }
138 } 143 }
139 }, 144 },
140 //////////////////////////////////////////////////////////////////// 145 ////////////////////////////////////////////////////////////////////
141 // 146 //
142 saveAll: { 147 saveAll: {
143 value: function (callback) { 148 value: function (callback) {
149 //
150 if (this.needsSave) {
151 //Save
152 } else {
153 //Ignore command
154 }
144 // 155 //
145 if (this.currentView === this.views.design) { 156 if (this.currentView === this.views.design) {
146 // 157 //
@@ -156,12 +167,7 @@ exports.BaseDocumentModel = Montage.create(Component, {
156 } else { 167 } else {
157 //TODO: Add logic to save code view data 168 //TODO: Add logic to save code view data
158 } 169 }
159 // 170
160 if (this.needsSave) {
161 //Save
162 } else {
163 //Ignore command
164 }
165 } 171 }
166 }, 172 },
167 //////////////////////////////////////////////////////////////////// 173 ////////////////////////////////////////////////////////////////////
@@ -179,13 +185,24 @@ exports.BaseDocumentModel = Montage.create(Component, {
179 //////////////////////////////////////////////////////////////////// 185 ////////////////////////////////////////////////////////////////////
180 // 186 //
181 close: { 187 close: {
182 value: function () { 188 value: function (view, callback) {
189 //Outcome of close (pending on save logic)
190 var success;
183 // 191 //
184 if (this.needsSave) { 192 if (this.needsSave) {
185 //Prompt user to save of lose data 193 //Prompt user to save of lose data
186 } else { 194 } else {
187 //Close file 195 //Close file
196 success = true;
197 }
198 //
199 if (this.views.design && (!view || view === 'design')) {
200 //
201 this.parentContainer.removeChild(this.views.design.iframe);
202 this.views.design = null;
188 } 203 }
204 //
205 if (callback) callback(success);
189 } 206 }
190 } 207 }
191 //////////////////////////////////////////////////////////////////// 208 ////////////////////////////////////////////////////////////////////
diff --git a/js/document/views/design.js b/js/document/views/design.js
index 765099e6..1a8f4986 100755
--- a/js/document/views/design.js
+++ b/js/document/views/design.js
@@ -289,6 +289,37 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
289 value: function(x, y) { 289 value: function(x, y) {
290 return this.iframe.contentWindow.getElement(x,y); 290 return this.iframe.contentWindow.getElement(x,y);
291 } 291 }
292 },
293 ////////////////////////////////////////////////////////////////////
294 //
295 pauseVideos:{
296 value:function(){
297 var i, videos = this.document.getElementsByTagName("video");
298 for(i = 0; i < videos.length; i++){
299 if(!videos[i].paused) videos[i].pause();
300 }
301 }
302 },
303 ////////////////////////////////////////////////////////////////////
304 //
305 stopVideos:{
306 value:function(){
307 var i, videos = this.document.getElementsByTagName("video");
308 for(i = 0; i < videos.length; i++){
309 videos[i].src = "";
310 }
311 }
312 },
313 ////////////////////////////////////////////////////////////////////
314 //
315 pauseAndStopVideos:{
316 value:function(){
317 var i, videos = this.document.getElementsByTagName("video");
318 for(i = 0; i < videos.length; i++){
319 if(!videos[i].paused) videos[i].pause();
320 videos[i].src = "";
321 }
322 }
292 } 323 }