From 0e221e80eb41bbe770c195838373b9e27de54c7a Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 6 Mar 2012 16:11:52 -0800 Subject: IKNINJA-1207: added check for design view to fix js error Signed-off-by: Ananya Sen --- js/stage/layout.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/stage/layout.js b/js/stage/layout.js index de4c67c1..ab2daf9b 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js @@ -65,8 +65,9 @@ exports.Layout = Montage.create(Component, { handleOpenDocument: { value: function() { // Initial elements to draw is the entire node list - this.elementsToDraw = this.application.ninja.documentController.activeDocument._liveNodeList; - + if(typeof this.application.ninja.documentController.activeDocument._liveNodeList !== "undefined"){//only for designer view + this.elementsToDraw = this.application.ninja.documentController.activeDocument._liveNodeList; + } // Draw the elements and the 3d info this.draw(); this.draw3DInfo(false); @@ -104,8 +105,9 @@ exports.Layout = Montage.create(Component, { } // Make an array copy of the line node list which is not an array like object - this.domTree = Array.prototype.slice.call(this.application.ninja.documentController.activeDocument._liveNodeList, 0); - + if(typeof this.application.ninja.documentController.activeDocument._liveNodeList !== "undefined"){//only for designer view + this.domTree = Array.prototype.slice.call(this.application.ninja.documentController.activeDocument._liveNodeList, 0); + } // Clear the elements to draw this.elementsToDraw.length = 0; -- cgit v1.2.3 From fbde30a4651d34ac569bf6750db5dd017ccc8d6e Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 6 Mar 2012 16:18:56 -0800 Subject: fixed picker address dropdown to backtrace till the logical drive Signed-off-by: Ananya Sen --- js/io/ui/file-picker/file-picker-controller.js | 2 +- js/io/ui/file-picker/file-picker-model.js | 6 ++++++ js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js | 7 ++++++- 3 files changed, 13 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/io/ui/file-picker/file-picker-controller.js b/js/io/ui/file-picker/file-picker-controller.js index 3b19de83..105dc223 100755 --- a/js/io/ui/file-picker/file-picker-controller.js +++ b/js/io/ui/file-picker/file-picker-controller.js @@ -104,7 +104,7 @@ var FilePickerController = exports.FilePickerController = Montage.create(require aModel.topLevelDirectories = topLevelDirectories; if(!!topLevelDirectories && !!topLevelDirectories[0]){ - aModel.currentRoot = topLevelDirectories[0].uri; + aModel.currentRoot = aModel.currentLogicalDrive = topLevelDirectories[0].uri; } //populate the last opened folder first, if none then populate default root diff --git a/js/io/ui/file-picker/file-picker-model.js b/js/io/ui/file-picker/file-picker-model.js index 09c3ae9c..c92ec586 100755 --- a/js/io/ui/file-picker/file-picker-model.js +++ b/js/io/ui/file-picker/file-picker-model.js @@ -73,6 +73,12 @@ exports.FilePickerModel = (require("montage/core/core").Montage).create(require( value:"" }, + currentLogicalDrive:{ + writable:true, + enumerable:true, + value:"" + }, + callback:{ writable:true, enumerable:true, diff --git a/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js b/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js index 3d99ae4d..1e3cb1b9 100644 --- a/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js +++ b/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js @@ -346,6 +346,11 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { var arr = []; var temp = new String(uri); while(temp.indexOf("/") != -1){ + + if(temp === this.pickerModel.currentLogicalDrive){//stop at the logical drive + break; + } + temp = temp.substring(0, temp.lastIndexOf("/")); //populate dropdown irrespective of validity @@ -560,7 +565,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { enumerable: true, writable: false, value : function(evt, dirObj){ - this.currentURI = dirObj.uri; + this.currentURI = this.pickerModel.currentLogicalDrive = dirObj.uri; var status = this.pickerViews()[this.selectedPickerView].call(this, dirObj.uri);//dynamically calls the update function of the current picker view -- cgit v1.2.3 From 2364c671ffc2953e3ee8dfdf037244de8fab3920 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 6 Mar 2012 16:30:33 -0800 Subject: IKNINJA-1238 fix and fixing other js errors on switching and closing documents Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 21 ++++++++++++++++++++- js/controllers/selection-controller.js | 18 ++++++++++-------- js/stage/stage-view.reel/stage-view.js | 5 ++++- 3 files changed, 34 insertions(+), 10 deletions(-) (limited to 'js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 194496a6..1f8c58b0 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -61,7 +61,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.eventManager.addEventListener("executeSaveAs", this, false); this.eventManager.addEventListener("executeSaveAll", this, false); - this.eventManager.addEventListener("recordStyleChanged", this, false); + this.eventManager.addEventListener("styleSheetDirty", this, false); } }, @@ -168,6 +168,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function (result) { if(result.status === 204){ this.activeDocument.needsSave = false; + if(this.application.ninja.currentDocument !== null){ + //clear Dirty StyleSheets for the saved document + this.application.ninja.stylesController.clearDirtyStyleSheets(this.application.ninja.currentDocument); + } } } }, @@ -249,6 +253,15 @@ var DocumentController = exports.DocumentController = Montage.create(Component, }, //////////////////////////////////////////////////////////////////// // + saveAsCallback:{ + value:function(){ + //close current document + + //create a new file + } + }, + + //////////////////////////////////////////////////////////////////// openDocument: { value: function(doc) { @@ -506,5 +519,11 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function() { return "userDocument_" + (this._iframeCounter++); } + }, + + handleStyleSheetDirty:{ + value:function(){ + this.activeDocument.needsSave = true; } + } }); diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 08eb018f..3f9d8514 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -91,15 +91,17 @@ exports.SelectionController = Montage.create(Component, { handleSwitchDocument: { value: function() { - this._selectedItems = this.application.ninja.selectedElements.slice(0); - if(this._selectedItems.length === 0 ){ - this._isDocument = true; - }else{ - this._isDocument = false; - } - NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); + if(this.application.ninja.documentController.activeDocument.currentView === "design"){ + this._selectedItems = this.application.ninja.selectedElements.slice(0); + if(this._selectedItems.length === 0 ){ + this._isDocument = true; + }else{ + this._isDocument = false; + } + NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); - this._selectionContainer = this.application.ninja.currentSelectedContainer; + this._selectionContainer = this.application.ninja.currentSelectedContainer; + } } }, diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index 91047e51..ad67cada 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -125,6 +125,10 @@ exports.StageView = Montage.create(Component, { this.application.ninja.documentController.activeDocument = doc; + if(this.application.ninja.documentController.activeDocument.currentView === "design") { + this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument; + } + this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe this.application.ninja.documentController._showCurrentDocument(); @@ -135,7 +139,6 @@ exports.StageView = Montage.create(Component, { if(this.application.ninja.documentController.activeDocument.currentView === "design") { this.application.ninja.stage._scrollFlag = true; // TODO HACK to prevent type error on Hide/Show Iframe - this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument; //reinitialize draw-util, snapmanager and view-util this.application.ninja.stage.stageDeps.reinitializeForSwitchDocument(); -- cgit v1.2.3 From b00a0da52ae29eefb45c8b28f7c782c7ebfa4b57 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 6 Mar 2012 16:33:58 -0800 Subject: IKNINJA-1256 fix - needed to convert String object to string Signed-off-by: Ananya Sen --- js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js b/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js index 1e3cb1b9..7a9d90b4 100644 --- a/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js +++ b/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js @@ -347,7 +347,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { var temp = new String(uri); while(temp.indexOf("/") != -1){ - if(temp === this.pickerModel.currentLogicalDrive){//stop at the logical drive + if(""+temp === this.pickerModel.currentLogicalDrive){//stop at the logical drive break; } -- cgit v1.2.3 From 92c311c527b864f35aa98dba950da677746d4708 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 6 Mar 2012 16:42:10 -0800 Subject: - detect document style edit [with Eric's input for styles-controller.js] - integrated save as Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 26 ++++++++++++++++++++------ js/controllers/styles-controller.js | 10 ++++++++-- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 4 ++-- 3 files changed, 30 insertions(+), 10 deletions(-) (limited to 'js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 1f8c58b0..e29148c9 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -157,7 +157,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ saveAsSettings.fileName = this.activeDocument.name; saveAsSettings.folderUri = this.activeDocument.uri.substring(0, this.activeDocument.uri.lastIndexOf("/")); - //add callback + saveAsSettings.callback = this.saveAsCallback.bind(this); this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); } } @@ -166,7 +166,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, // fileSaveResult: { value: function (result) { - if(result.status === 204){ + if((result.status === 204) || (result.status === 404)){//204=>existing file || 404=>new file... saved this.activeDocument.needsSave = false; if(this.application.ninja.currentDocument !== null){ //clear Dirty StyleSheets for the saved document @@ -254,10 +254,24 @@ var DocumentController = exports.DocumentController = Montage.create(Component, //////////////////////////////////////////////////////////////////// // saveAsCallback:{ - value:function(){ - //close current document - - //create a new file + value:function(saveAsDetails){ + var fileUri = null, filename = saveAsDetails.filename, destination = saveAsDetails.destination; + //update document metadata + this.activeDocument.name = ""+filename; + //prepare new file uri + if(destination && (destination.charAt(destination.length -1) !== "/")){ + destination = destination + "/"; + } + fileUri = destination+filename; + + this.activeDocument.uri = fileUri; + //save a new file + //use the ioMediator.fileSaveAll when implemented + this.activeDocument._userDocument.name=filename; + this.activeDocument._userDocument.root=destination; + this.activeDocument._userDocument.uri=fileUri; + this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this)); + // } }, diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 662816f5..addfc24e 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -1236,11 +1236,17 @@ var stylesController = exports.StylesController = Montage.create(Component, { clearDirtyStyleSheets : { value: function(doc) { - if(!doc) { + this.dirtyStyleSheets.length = 0; + + if(doc) { + var stillDirty = this.dirtyStyleSheets.filter(function(sheet) { + return sheet.document !== doc; + }); this.dirtyStyleSheets = null; - this.dirtyStyleSheets = []; + this.dirtyStyleSheets = stillDirty; } + } }, diff --git a/js/io/ui/save-as-dialog.reel/save-as-dialog.js b/js/io/ui/save-as-dialog.reel/save-as-dialog.js index 0a322b99..c60a92f9 100644 --- a/js/io/ui/save-as-dialog.reel/save-as-dialog.js +++ b/js/io/ui/save-as-dialog.reel/save-as-dialog.js @@ -111,7 +111,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { handleOkButtonAction:{ value: function(evt){ var filename = this.fileName, - newFileDirectory = this.newFileDirectory, + newFileDirectory = this.folderUri, success = true; if(this.isValidFileName(this.fileName) && this.isValidUri(this.folderUri) && !this.checkFileExists(this.fileName, this.folderUri)){ try{ @@ -128,7 +128,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { } }catch(e){ success = false; - console.log("[ERROR] Failed to save: "+ this.fileName + " at "+ this.newFileDirectory); + console.log("[ERROR] Failed to save: "+ this.fileName + " at "+ newFileDirectory); console.log(e.stack); } -- cgit v1.2.3 From f7641a9b2d6f33e73227d2f8398509b54fdc0aa1 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 6 Mar 2012 16:48:52 -0800 Subject: updated file picker image icons Signed-off-by: Ananya Sen --- js/components/ui/icon-list-basic/icon.reel/icon.js | 14 +++++--------- js/components/ui/tree-basic/treeItem.reel/treeItem.js | 14 +++++--------- 2 files changed, 10 insertions(+), 18 deletions(-) (limited to 'js') diff --git a/js/components/ui/icon-list-basic/icon.reel/icon.js b/js/components/ui/icon-list-basic/icon.reel/icon.js index 72adbfa1..1ef6e277 100755 --- a/js/components/ui/icon-list-basic/icon.reel/icon.js +++ b/js/components/ui/icon-list-basic/icon.reel/icon.js @@ -174,21 +174,17 @@ var Icon = exports.Icon = Montage.create(Component, { enumerable: true, value:{ "img_root":"images/picker/", - ".png":"png_file.png", - ".jpg":"jpeg_file.png", ".js":"js_file.png", + ".json":"json_file.png", ".css":"css_file.png", ".html":"html_file.png", ".xml":"xml_file.png", ".php":"php_file.png", + ".pl":"pl_file.png", + ".py":"py_file.png", + ".rb":"rb_file.png", ".doc":"doc_file.png", - ".docx":"doc_file.png", - ".rtf":"rtf_file.png", - ".pdf":"pdf_file.png", - ".zip":"zip_file.png", - ".rar":"zip_file.png", - ".app":"executable.png", - ".exe":"executable.png", + ".txt":"txt_file.png", "file_default":"file.png", "directory":"folder.png" } diff --git a/js/components/ui/tree-basic/treeItem.reel/treeItem.js b/js/components/ui/tree-basic/treeItem.reel/treeItem.js index 4c71cb6b..a67dad43 100755 --- a/js/components/ui/tree-basic/treeItem.reel/treeItem.js +++ b/js/components/ui/tree-basic/treeItem.reel/treeItem.js @@ -242,21 +242,17 @@ exports.TreeItem = Montage.create(Component, { enumerable: true, value:{ "img_root":"images/picker/", - ".png":"png_file.png", - ".jpg":"jpeg_file.png", ".js":"js_file.png", + ".json":"json_file.png", ".css":"css_file.png", ".html":"html_file.png", ".xml":"xml_file.png", ".php":"php_file.png", + ".pl":"pl_file.png", + ".py":"py_file.png", + ".rb":"rb_file.png", ".doc":"doc_file.png", - ".docx":"doc_file.png", - ".rtf":"rtf_file.png", - ".pdf":"pdf_file.png", - ".zip":"zip_file.png", - ".rar":"zip_file.png", - ".app":"executable.png", - ".exe":"executable.png", + ".txt":"txt_file.png", "file_default":"file.png", "directory":"folder.png" } -- cgit v1.2.3 From 9e4ee2470726e3334eb47d904a6f4079d4ed7aef Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 6 Mar 2012 17:01:39 -0800 Subject: IKNINJA-1270: fixed browser crashing when you close a document while playing a video then wait for a while Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 9 ++++++++ js/controllers/selection-controller.js | 13 +++++++++++ js/document/html-document.js | 41 +++++++++++++++++++++++++++++++++- js/helper-classes/3D/draw-utils.js | 10 +++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index e29148c9..de080167 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -363,14 +363,23 @@ var DocumentController = exports.DocumentController = Montage.create(Component, nextDocumentIndex = closeDocumentIndex - 1; } this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); + doc.stopVideos(); this._removeDocumentView(doc.container); }else if(this._documents.length === 0){ + if(typeof this.activeDocument.pauseVideos !== "undefined"){ + this.activeDocument.pauseVideos(true); + } this.activeDocument = null; this._removeDocumentView(doc.container); this.application.ninja.stage.stageView.hideRulers(); document.getElementById("iframeContainer").style.display="block"; this.application.ninja.stage.hideCanvas(true); + }else{//closing inactive document tab - just clear DOM + if(typeof doc.pauseVideos !== "undefined"){ + doc.pauseVideos(true); + } + this._removeDocumentView(doc.container); } NJevent("closeDocument", doc.uri); diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 3f9d8514..49bf42b6 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -48,6 +48,7 @@ exports.SelectionController = Montage.create(Component, { this.eventManager.addEventListener("selectAll", this, false); this.eventManager.addEventListener("deleteSelection", this, false); this.eventManager.addEventListener("switchDocument", this, false); + this.eventManager.addEventListener("closeDocument", this, false); // defaultEventManager.addEventListener( "undo", this, false); // defaultEventManager.addEventListener( "redo", this, false); } @@ -105,6 +106,18 @@ exports.SelectionController = Montage.create(Component, { } }, + handleCloseDocument:{ + value: function() { + //clear selections if all documents are closed + if(this.application.ninja.documentController._documents.length === 0){ + this._selectedItems.length =0; + this.application.ninja.selectedElements.length =0; + this._isDocument = true; + NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); + } + } + }, + handleElementAdded: { value: function(event) { this.executeSelectElement(event.detail); diff --git a/js/document/html-document.js b/js/document/html-document.js index 80930af2..d90231e3 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -824,6 +824,9 @@ exports.HTMLDocument = Montage.create(TextDocument, { this.undoStack = this.application.ninja.undocontroller.undoQueue.slice(0); this.redoStack = this.application.ninja.undocontroller.redoQueue.slice(0); this.application.ninja.undocontroller.clearHistory();//clear history to give the next document a fresh start + + //pause videos on switching or closing the document, so that the browser does not keep downloading the media data + this.pauseVideos(); } }, @@ -852,6 +855,42 @@ exports.HTMLDocument = Montage.create(TextDocument, { } - } + }, //////////////////////////////////////////////////////////////////// + /** + *pause videos on switching or closing the document, so that the browser does not keep downloading the media data + *removeSrc : boolean to remove the src if the video... set only in the close document flow + */ + pauseVideos:{ + value:function(removeSrc){ + console.log("$$$ pauseVideos"); + var videosArr = this.documentRoot.getElementsByTagName("video"), i=0; + for(i=0;i --- js/document/html-document.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'js') diff --git a/js/document/html-document.js b/js/document/html-document.js index d90231e3..924a013d 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -863,16 +863,16 @@ exports.HTMLDocument = Montage.create(TextDocument, { */ pauseVideos:{ value:function(removeSrc){ - console.log("$$$ pauseVideos"); + //console.log("$$$ pauseVideos"); var videosArr = this.documentRoot.getElementsByTagName("video"), i=0; for(i=0;i --- js/controllers/document-controller.js | 11 ++++++++++- js/data/menu-data.js | 6 ++++++ js/document/html-document.js | 1 - 3 files changed, 16 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index de080167..ca3cd585 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -60,6 +60,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.eventManager.addEventListener("executeSave", this, false); this.eventManager.addEventListener("executeSaveAs", this, false); this.eventManager.addEventListener("executeSaveAll", this, false); + this.eventManager.addEventListener("executeFileClose", this, false); this.eventManager.addEventListener("styleSheetDirty", this, false); @@ -162,7 +163,15 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } } }, - + //////////////////////////////////////////////////////////////////// + handleExecuteFileClose:{ + value: function(event) { + if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ + this.closeDocument(this.activeDocument.uuid); + } + } + }, + //////////////////////////////////////////////////////////////////// // fileSaveResult: { value: function (result) { diff --git a/js/data/menu-data.js b/js/data/menu-data.js index 52710b3a..40512f5d 100755 --- a/js/data/menu-data.js +++ b/js/data/menu-data.js @@ -30,6 +30,12 @@ exports.MenuData = Montage.create( Montage, { "enabled": true, "action": "executeFileOpen" }, + { + "displayText" : "Close File", + "hasSubMenu" : false, + "enabled": true, + "action": "executeFileClose" + }, { "displayText" : "", "separator": true diff --git a/js/document/html-document.js b/js/document/html-document.js index 9670e0c4..83f91c19 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -894,7 +894,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { /** * remove the video src on closing the document, so that the browser does not keep downloading the media data, if the tag does not get garbage collected - *removeSrc : boolean to remove the src if the video... set only in the close document flow */ stopVideos:{ value:function(){ -- cgit v1.2.3 From 250420d8c6154172b27fe53aff30e78c227e8a67 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 7 Mar 2012 14:26:37 -0800 Subject: minor fixes Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 12 ++++++------ js/controllers/selection-controller.js | 14 -------------- js/document/html-document.js | 25 ++++++++++++++----------- js/stage/layout.js | 4 ++-- 4 files changed, 22 insertions(+), 33 deletions(-) (limited to 'js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index ca3cd585..87e93465 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -166,7 +166,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, //////////////////////////////////////////////////////////////////// handleExecuteFileClose:{ value: function(event) { - if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ + if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ this.closeDocument(this.activeDocument.uuid); } } @@ -372,11 +372,11 @@ var DocumentController = exports.DocumentController = Montage.create(Component, nextDocumentIndex = closeDocumentIndex - 1; } this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); - doc.stopVideos(); + if(typeof this.activeDocument.stopVideos !== "undefined"){doc.stopVideos();} this._removeDocumentView(doc.container); }else if(this._documents.length === 0){ - if(typeof this.activeDocument.pauseVideos !== "undefined"){ - this.activeDocument.pauseVideos(true); + if(typeof this.activeDocument.pauseAndStopVideos !== "undefined"){ + this.activeDocument.pauseAndStopVideos(); } this.activeDocument = null; this._removeDocumentView(doc.container); @@ -385,8 +385,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.application.ninja.stage.hideCanvas(true); }else{//closing inactive document tab - just clear DOM - if(typeof doc.pauseVideos !== "undefined"){ - doc.pauseVideos(true); + if(typeof doc.pauseAndStopVideos !== "undefined"){ + doc.pauseAndStopVideos(); } this._removeDocumentView(doc.container); } diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index eff9c91a..c713b6e5 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -100,20 +100,6 @@ exports.SelectionController = Montage.create(Component, { this._isDocument = false; } NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); - - this._selectionContainer = this.application.ninja.currentSelectedContainer; - } - } - }, - - handleCloseDocument:{ - value: function() { - //clear selections if all documents are closed - if(this.application.ninja.documentController._documents.length === 0){ - this._selectedItems.length =0; - this.application.ninja.selectedElements.length =0; - this._isDocument = true; - NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); } } }, diff --git a/js/document/html-document.js b/js/document/html-document.js index 83f91c19..f730b853 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -872,22 +872,15 @@ exports.HTMLDocument = Montage.create(TextDocument, { }, //////////////////////////////////////////////////////////////////// /** - *pause videos on switching or closing the document, so that the browser does not keep downloading the media data - *removeSrc : boolean to remove the src if the video... set only in the close document flow + *pause videos on switching or closing the document */ pauseVideos:{ - value:function(removeSrc){ - //console.log("$$$ pauseVideos"); + value:function(){ var videosArr = this.documentRoot.getElementsByTagName("video"), i=0; for(i=0;i --- js/helper-classes/3D/draw-utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 63e7799a..59da411f 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -139,8 +139,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { handleCloseDocument:{ value: function() { if(this.application.ninja.documentController._documents.length === 0){ - this._eltArray = []; - this._planesArray = []; + this._eltArray = null; + this._planesArray = null; } } }, -- cgit v1.2.3