diff options
Diffstat (limited to 'js/io/document/document-controller.js')
-rwxr-xr-x | js/io/document/document-controller.js | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js index ca6b4533..51575a24 100755 --- a/js/io/document/document-controller.js +++ b/js/io/document/document-controller.js | |||
@@ -239,45 +239,25 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
239 | value: function(id) { | 239 | value: function(id) { |
240 | 240 | ||
241 | //if file dirty then save | 241 | //if file dirty then save |
242 | if(this.activeDocument.dirtyFlag === true){ | ||
243 | this.activeDocument.save(true); | ||
244 | this.activeDocument.dirtyFlag=false; | ||
245 | } | ||
242 | 246 | ||
243 | var doc = this._findDocumentByUUID(id); | 247 | var doc = this._findDocumentByUUID(id); |
244 | this._removeDocumentView(doc.container); | 248 | this._removeDocumentView(doc.container); |
245 | 249 | ||
250 | var closeDocumentIndex = this._findIndexByUUID(id); | ||
246 | this._documents.splice(this._findIndexByUUID(id), 1); | 251 | this._documents.splice(this._findIndexByUUID(id), 1); |
247 | 252 | ||
248 | if(this.activeDocument.uuid === id && this._documents.length > 0) { | 253 | if(this.activeDocument.uuid === id && this._documents.length > 0) { |
249 | |||
250 | var closeDocumentIndex = this._findIndexByUUID(id); | ||
251 | var nextDocumentIndex = -1 ; | 254 | var nextDocumentIndex = -1 ; |
252 | if((this._documents.length > 0) && (closeDocumentIndex === 0)){ | 255 | if((this._documents.length > 0) && (closeDocumentIndex === 0)){ |
253 | nextDocumentIndex = 1; | 256 | nextDocumentIndex = 1; |
254 | }else if((this._documents.length > 0) && (closeDocumentIndex > 0)){ | 257 | }else if((this._documents.length > 0) && (closeDocumentIndex > 0)){ |
255 | nextDocumentIndex = closeDocumentIndex - 1; | 258 | nextDocumentIndex = closeDocumentIndex - 1; |
256 | } | 259 | } |
257 | 260 | this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); | |
258 | //remove the codemirror div if this is for a code view | ||
259 | /////test | ||
260 | |||
261 | ////end- test | ||
262 | |||
263 | this.switchDocument(this._documents[0].uuid); | ||
264 | |||
265 | } | ||
266 | } | ||
267 | }, | ||
268 | |||
269 | switchDocument: { | ||
270 | value: function(id) { | ||
271 | this._hideCurrentDocument(); | ||
272 | this.activeDocument = this._findDocumentByUUID(id); | ||
273 | |||
274 | this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe | ||
275 | this._showCurrentDocument(); | ||
276 | |||
277 | if(this.activeDocument.documentType === "htm" || this.activeDocument.documentType === "html") { | ||
278 | this.application.ninja.stage._scrollFlag = true; // TODO HACK to prevent type error on Hide/Show Iframe | ||
279 | // TODO dispatch event here | ||
280 | // appDelegateModule.MyAppDelegate.onSetActiveDocument(); | ||
281 | } | 261 | } |
282 | } | 262 | } |
283 | }, | 263 | }, |
@@ -406,6 +386,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
406 | if(this.activeDocument.currentView === "design" || this.activeDocument.currentView === "design"){ | 386 | if(this.activeDocument.currentView === "design" || this.activeDocument.currentView === "design"){ |
407 | this.activeDocument.container.parentNode.style["display"] = "none"; | 387 | this.activeDocument.container.parentNode.style["display"] = "none"; |
408 | this.application.ninja.stage.hideCanvas(true); | 388 | this.application.ninja.stage.hideCanvas(true); |
389 | this.application.ninja.stage.stageView.hideRulers(); | ||
409 | } | 390 | } |
410 | } | 391 | } |
411 | } | 392 | } |
@@ -418,6 +399,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
418 | if(this.activeDocument.currentView === "design" || this.activeDocument.currentView === "design"){ | 399 | if(this.activeDocument.currentView === "design" || this.activeDocument.currentView === "design"){ |
419 | this.activeDocument.container.parentNode.style["display"] = "block"; | 400 | this.activeDocument.container.parentNode.style["display"] = "block"; |
420 | this.application.ninja.stage.hideCanvas(false); | 401 | this.application.ninja.stage.hideCanvas(false); |
402 | this.application.ninja.stage.stageView.showRulers(); | ||
421 | } | 403 | } |
422 | } | 404 | } |
423 | } | 405 | } |