From 2557f463c1cfe2d0dd8ea187c184755bd141dab4 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:38:44 -0700 Subject: IKNINJA-1302 : For File>New and File>SaveAll dialogs, 'ESC' key now triggers Cancel button and 'Enter' key now triggers OK button. For File picker, the 'ESC' now triggers the Cancel button. Signed-off-by: Ananya Sen Conflicts: js/io/ui/new-file-dialog/new-file-workflow-controller.js Signed-off-by: Ananya Sen --- js/io/ui/file-picker/file-picker-controller.js | 7 ++++++- .../picker-navigator.reel/picker-navigator.js | 2 +- .../new-file-location.reel/new-file-location.js | 6 ++++++ .../new-file-options-navigator.js | 8 ++++++++ .../new-file-workflow-controller.js | 14 +++++++++++-- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 23 ++++++++++++++++++++-- 6 files changed, 54 insertions(+), 6 deletions(-) (limited to 'js/io') diff --git a/js/io/ui/file-picker/file-picker-controller.js b/js/io/ui/file-picker/file-picker-controller.js index 105dc223..e3276ee6 100755 --- a/js/io/ui/file-picker/file-picker-controller.js +++ b/js/io/ui/file-picker/file-picker-controller.js @@ -23,6 +23,11 @@ var FilePickerController = exports.FilePickerController = Montage.create(require } }, + pickerNavChoices:{ + enumerable: true, + value: null + }, + filePickerPopupType:{ enumerable: false, value: "filePicker" @@ -149,7 +154,7 @@ var FilePickerController = exports.FilePickerController = Montage.create(require writable:false, enumerable:true, value:function(callback, aModel){ - var pickerNavChoices = Montage.create(pickerNavigatorReel); + var pickerNavChoices = this.pickerNavChoices = Montage.create(pickerNavigatorReel); var initUri = aModel.currentRoot; //remove extra / at the end 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 7a9d90b4..e31fa29d 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 @@ -258,7 +258,6 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { this.element.addEventListener("refreshTreeSegment", function(evt){that.handlePickerNavRefreshTreeSegment(evt);}, false); this.resultsArea.addEventListener("click", function(evt){that.handleResultsAreaClick(evt);}, false); this.element.addEventListener("click", function(evt){that.handlePickerNavClick(evt);}, false); - this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); @@ -1071,6 +1070,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { //clear memory - TODO:check for more memory leaks this.pickerModel = null; this.application.ninja.filePickerController._directoryContentCache = {}; + this.application.ninja.filePickerController.pickerNavChoices = null; //remove listeners this.element.removeEventListener("openFolder", this, false);//add icon double click event listener to reload iconList with new set of data this.element.removeEventListener("selectedItem", this, false);//for single selection only diff --git a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js index 0e1e09a4..c4b7ea99 100755 --- a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js +++ b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js @@ -34,6 +34,12 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { newFileNameSetEvent.newFileName = this.newFileName.value; this.eventManager.dispatchEvent(newFileNameSetEvent); } + if(evt.keyCode === 13){ + var enterPressedEvent = document.createEvent("Events"); + enterPressedEvent.initEvent("enterPressed", false, false); + enterPressedEvent.newFileName = this.newFileName.value; + this.eventManager.dispatchEvent(enterPressedEvent); + } } } diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index aaf39005..5adcc250 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js @@ -106,6 +106,12 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); + this.element.addEventListener("enterPressed", function(evt){ + if(!that.okButton.hasAttribute("disabled")){ + that.handleOkButtonAction(evt); + } + }, false); + if(!!this.newFileModel.defaultProjectType){ var templates = this.newFileModel.prepareContents(this.newFileModel.defaultProjectType); this.templateList = iconsListModule.IconsList.create(); @@ -382,6 +388,8 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.element.removeEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only this.eventManager.removeEventListener("newFileDirectorySet", function(evt){that.handleNewFileDirectorySet(evt);}, false); this.eventManager.removeEventListener("newFileNameSet", function(evt){that.handleNewFileNameSet(evt);}, false); + + this.application.ninja.newFileController.newFileOptionsNav = null; } }, diff --git a/js/io/ui/new-file-dialog/new-file-workflow-controller.js b/js/io/ui/new-file-dialog/new-file-workflow-controller.js index d065ca35..279a74b4 100755 --- a/js/io/ui/new-file-dialog/new-file-workflow-controller.js +++ b/js/io/ui/new-file-dialog/new-file-workflow-controller.js @@ -27,6 +27,16 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre value: null }, + newFileOptionsNav:{ + enumerable:true, + value: null + }, + + saveAsDialog:{ + enumerable:true, + value: null + }, + showNewFileDialog:{ writable:false, enumerable:true, @@ -49,7 +59,7 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre this.model.defaultProjectType = lastSelectedProjectType; } - var newFileOptionsNav = newFileOptionsNavigatorModule.NewFileOptionsNavigator.create(); + var newFileOptionsNav = this.newFileOptionsNav = newFileOptionsNavigatorModule.NewFileOptionsNavigator.create(); newFileOptionsNav.newFileModel = this.model; var popup = Popup.create(); @@ -70,7 +80,7 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre var fileName = data.fileName || "filename.txt"; var folderUri = data.folderUri || "/Documents"; - var saveAsDialog = saveAsModule.SaveAsDialog.create(); + var saveAsDialog = this.saveAsDialog = saveAsModule.SaveAsDialog.create(); saveAsDialog.fileName = fileName; saveAsDialog.folderUri = folderUri; saveAsDialog.callback = data.callback; 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 c60a92f9..98749106 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 @@ -83,6 +83,11 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { this.enableOk(); } } + if(evt.keyCode === 13){ + if(!this.okButton.hasAttribute("disabled")){ + this.handleOkButtonAction(evt); + } + } } }, @@ -99,7 +104,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { handleCancelButtonAction :{ value:function(evt){ //clean up memory - //this.cleanup(); + this.cleanup(); if(this.popup){ this.popup.hide(); @@ -134,7 +139,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { if(success){ //clean up memory - //this.cleanup(); + this.cleanup(); if(this.popup){ this.popup.hide(); @@ -227,6 +232,20 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { } return status; } + }, + + cleanup:{ + value:function(){ + var self = this; + + //remove event listener + this.newFileName.removeEventListener("keyup", function(evt){self.handleNewFileNameOnkeyup(evt);}, false); + this.eventManager.removeEventListener("newFileDirectorySet", function(evt){self.handleNewFileDirectorySet(evt);}, false); + this.okButton.removeEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false); + this.cancelButton.removeEventListener("click", function(evt){self.handleCancelButtonAction(evt);}, false); + + this.application.ninja.newFileController.saveAsDialog = null; } + } }); \ No newline at end of file -- cgit v1.2.3 From 85bf9f937fa2ec46e42f791fc6815f7c2f5446ea Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:42:05 -0700 Subject: file picker - added size unit new file - don't disable OK is file exists Signed-off-by: Ananya Sen --- .../picker-navigator.reel/picker-navigator.js | 2 +- .../new-file-options-navigator.js | 26 +++++++++++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) (limited to 'js/io') 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 e31fa29d..3cf6fc5a 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 @@ -500,7 +500,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { metadata = "Name: "+data.name; } metadata = metadata + "
" + "Type: "+data.type; - if(data.size){metadata = metadata + "
" + "Size: "+data.size;} + if(data.size){metadata = metadata + "
" + "Size: "+data.size+" bytes";} if(data.creationDate){metadata = metadata + "
" + "Creation date: "+ this.formatTimestamp(data.creationDate);} if(data.modifiedDate){metadata = metadata + "
" + "Modified date: "+ this.formatTimestamp(data.modifiedDate);} } diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index 5adcc250..f63067b1 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js @@ -297,10 +297,16 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C }else{ if(this.error.innerHTML === ""){ this.showError("! Project Template, Name and Directory should be valid."); - } - //disable ok - if(!this.okButton.hasAttribute("disabled")){ - this.okButton.setAttribute("disabled", "true"); + //disable ok + if(!this.okButton.hasAttribute("disabled")){ + this.okButton.setAttribute("disabled", "true"); + } + }else if(!this.selectedProjectType || !this.selectedTemplate){ + this.showError("! Project Template should be selected."); + //disable ok + if(!this.okButton.hasAttribute("disabled")){ + this.okButton.setAttribute("disabled", "true"); + } } } } @@ -399,6 +405,10 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C if(uri !== ""){ if(!status){ this.showError("! Invalid directory."); + //disable ok + if(!this.okButton.hasAttribute("disabled")){ + this.okButton.setAttribute("disabled", "true"); + } } } return status; @@ -410,6 +420,10 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C if(fileName !== ""){ if(!status){ this.showError("! Invalid file name."); + //disable ok + if(!this.okButton.hasAttribute("disabled")){ + this.okButton.setAttribute("disabled", "true"); + } } } return status; @@ -445,10 +459,6 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C value:function(errorString){ this.error.innerHTML = ""; this.error.innerHTML=errorString; - //disable ok - if(!this.okButton.hasAttribute("disabled")){ - this.okButton.setAttribute("disabled", "true"); - } } }, -- cgit v1.2.3 From 5b0ff2b7347d158876c366c51988a94570dda18b Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:43:54 -0700 Subject: IKNINJA-1302 : more fix Signed-off-by: Ananya Sen --- .../file-input-field.reel/file-input-field.js | 1 + .../new-file-location.reel/new-file-location.js | 7 +--- .../new-file-options-navigator.js | 39 +++++++++++----------- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 5 ++- 4 files changed, 26 insertions(+), 26 deletions(-) (limited to 'js/io') diff --git a/js/io/ui/file-picker/file-input-field.reel/file-input-field.js b/js/io/ui/file-picker/file-input-field.reel/file-input-field.js index 651fd7fa..ccb925b9 100755 --- a/js/io/ui/file-picker/file-input-field.reel/file-input-field.js +++ b/js/io/ui/file-picker/file-input-field.reel/file-input-field.js @@ -69,6 +69,7 @@ var FileInputField = exports.FileInputField = Montage.create(Component, { var newFileDirectorySetEvent = document.createEvent("Events"); newFileDirectorySetEvent.initEvent("newFileDirectorySet", false, false); newFileDirectorySetEvent.newFileDirectory = this.newFileDirectory.value; + newFileDirectorySetEvent.keyCode = evt.keyCode; this.eventManager.dispatchEvent(newFileDirectorySetEvent); } } diff --git a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js index c4b7ea99..811231e4 100755 --- a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js +++ b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js @@ -32,14 +32,9 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { var newFileNameSetEvent = document.createEvent("Events"); newFileNameSetEvent.initEvent("newFileNameSet", false, false); newFileNameSetEvent.newFileName = this.newFileName.value; + newFileNameSetEvent.keyCode = evt.keyCode; this.eventManager.dispatchEvent(newFileNameSetEvent); } - if(evt.keyCode === 13){ - var enterPressedEvent = document.createEvent("Events"); - enterPressedEvent.initEvent("enterPressed", false, false); - enterPressedEvent.newFileName = this.newFileName.value; - this.eventManager.dispatchEvent(enterPressedEvent); - } } } diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index f63067b1..d5b59ab8 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js @@ -98,20 +98,6 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.addIdentifiers(); - this.element.addEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false); - this.element.addEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only - this.eventManager.addEventListener("newFileDirectorySet", function(evt){that.handleNewFileDirectorySet(evt);}, false); - this.eventManager.addEventListener("newFileNameSet", function(evt){that.handleNewFileNameSet(evt);}, false); - - this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); - this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); - - this.element.addEventListener("enterPressed", function(evt){ - if(!that.okButton.hasAttribute("disabled")){ - that.handleOkButtonAction(evt); - } - }, false); - if(!!this.newFileModel.defaultProjectType){ var templates = this.newFileModel.prepareContents(this.newFileModel.defaultProjectType); this.templateList = iconsListModule.IconsList.create(); @@ -122,7 +108,6 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.templateList.element = this.templateIcons; this.templateList.needsDraw = true; - this.selectedProjectType = {"uri":this.newFileModel.defaultProjectType, "element":null}; } @@ -133,6 +118,18 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C fileExtensionEl.innerHTML = ""+this.newFileModel.projectTypeData[this.newFileModel.defaultProjectType].fileExtension; } } + + this.element.addEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false); + this.element.addEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only + this.eventManager.addEventListener("newFileDirectorySet", function(evt){ + that.handleNewFileDirectorySet(evt); + }, false); + this.eventManager.addEventListener("newFileNameSet", function(evt){ + that.handleNewFileNameSet(evt); + }, false); + + this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); + this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); } }, @@ -314,7 +311,10 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C handleNewFileDirectorySet:{ value:function(evt){ - if(!!evt._event.newFileDirectory){ + if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ + this.handleOkButtonAction(evt); + } + else if(!!evt._event.newFileDirectory){ this.newFileDirectory = evt._event.newFileDirectory; if(this.isValidUri(this.newFileDirectory)){ this.enableOk(); @@ -325,7 +325,10 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C handleNewFileNameSet:{ value:function(evt){ - if(!!evt._event.newFileName){ + if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ + this.handleOkButtonAction(evt); + } + else if(!!evt._event.newFileName){ this.newFileName = evt._event.newFileName; if(this.isValidFileName(this.newFileName)){ this.enableOk(); @@ -386,8 +389,6 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.newFileName = ""; this.newFileDirectory = ""; - this.selectedProjectType = null; - this.selectedTemplate = null; //remove event listeners this.element.removeEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false); 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 98749106..4d07ca66 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 @@ -66,7 +66,10 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { handleNewFileDirectorySet:{ value:function(evt){ - if(!!evt._event.newFileDirectory){ + if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ + this.handleOkButtonAction(evt); + } + else if(!!evt._event.newFileDirectory){ this.folderUri = evt._event.newFileDirectory; if(this.isValidUri(this.folderUri)){ this.enableOk(); -- cgit v1.2.3 From 7a7ac1d6479155760d99b7ecdf5a8d1f63e25f24 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:46:39 -0700 Subject: IKNINJA-1361: autofocus and auto-select file name on open of new file and save as dialog Signed-off-by: Ananya Sen --- js/io/ui/file-picker/file-picker-controller.js | 2 -- js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js | 2 ++ js/io/ui/save-as-dialog.reel/save-as-dialog.js | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) (limited to 'js/io') diff --git a/js/io/ui/file-picker/file-picker-controller.js b/js/io/ui/file-picker/file-picker-controller.js index e3276ee6..436a50f3 100755 --- a/js/io/ui/file-picker/file-picker-controller.js +++ b/js/io/ui/file-picker/file-picker-controller.js @@ -130,8 +130,6 @@ var FilePickerController = exports.FilePickerController = Montage.create(require } if(!!storedUri){ - // This is depracated -- use decodeURI instead - //aModel.currentRoot = unescape(storedUri); aModel.currentRoot = decodeURI(storedUri); } diff --git a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js index 811231e4..fac4c488 100755 --- a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js +++ b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js @@ -23,6 +23,8 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { this.fileInputField.selectDirectory = true; this.newFileName.addEventListener("keyup", this, false); + this.newFileName.focus(); + this.newFileName.select(); } }, 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 4d07ca66..1910f30d 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 @@ -60,6 +60,9 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { this.okButton.addEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false); this.cancelButton.addEventListener("click", function(evt){self.handleCancelButtonAction(evt);}, false); + this.newFileName.focus(); + this.newFileName.select(); + this.enableOk(); } }, -- cgit v1.2.3 From 94bc7b61951677b04213ce18b0ec3e72da5aa8cd Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:47:29 -0700 Subject: IKNINJA-1367 - if filename contains #, then encode # so that the create URI path includes the full filename Signed-off-by: Ananya Sen --- js/io/system/coreioapi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/io') diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index f428a229..00ab6ac1 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js @@ -217,7 +217,7 @@ exports.CoreIoApi = Montage.create(Component, { value: function(serviceURL, path) { var urlOut = path.replace(/\\/g,"/"); urlOut = urlOut.replace(/:/g,""); - urlOut = encodeURI(urlOut); + urlOut = encodeURIComponent(urlOut); //add leading / if not already there if((urlOut.length > 0) && (urlOut.charAt(0) !== "/")){ urlOut = "/" + urlOut; -- cgit v1.2.3 From 87cf1d7d899bb60581d5e5c6c7ba678620c7148e Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 11:46:04 -0700 Subject: IKNINJA-1302 : close on ESC even if text field is focussed Signed-off-by: Ananya Sen --- .../new-file-options-navigator.reel/new-file-options-navigator.js | 4 ++++ js/io/ui/save-as-dialog.reel/save-as-dialog.js | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'js/io') diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index d5b59ab8..ecee7c1d 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js @@ -313,6 +313,8 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C value:function(evt){ if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ this.handleOkButtonAction(evt); + }else if(evt.keyCode === 27){ + this.handleCancelButtonAction(evt); } else if(!!evt._event.newFileDirectory){ this.newFileDirectory = evt._event.newFileDirectory; @@ -327,6 +329,8 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C value:function(evt){ if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ this.handleOkButtonAction(evt); + }else if(evt.keyCode === 27){ + this.handleCancelButtonAction(evt); } else if(!!evt._event.newFileName){ this.newFileName = evt._event.newFileName; 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 1910f30d..dfaac1aa 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 @@ -71,6 +71,8 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { value:function(evt){ if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ this.handleOkButtonAction(evt); + }else if(evt.keyCode === 27){ + this.handleCancelButtonAction(evt); } else if(!!evt._event.newFileDirectory){ this.folderUri = evt._event.newFileDirectory; @@ -93,6 +95,8 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { if(!this.okButton.hasAttribute("disabled")){ this.handleOkButtonAction(evt); } + }else if(evt.keyCode === 27){ + this.handleCancelButtonAction(evt); } } }, -- cgit v1.2.3 From 80ceeffeb3dd3227008714b8b56383f9556ff409 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 14:49:17 -0700 Subject: KNINJA-1302 : refactored fixed as per request Signed-off-by: Ananya Sen --- .../file-picker/picker-navigator.reel/picker-navigator.js | 9 +++++++++ .../new-file-options-navigator.js | 15 +++++++++++++++ js/io/ui/save-as-dialog.reel/save-as-dialog.js | 15 +++++++++++++++ 3 files changed, 39 insertions(+) (limited to 'js/io') 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 3cf6fc5a..945b0301 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 @@ -261,8 +261,17 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); + this.element.addEventListener("keyup", function(evt){ + if(evt.keyCode == 27) { + if(that.application.ninja.filePickerController.pickerNavChoices !== null){ + that.handleCancelButtonAction(); + } + } + }, true); + //ready to show picker now this.element.style.visibility = "visible"; + this.element.focus(); } }, diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index ecee7c1d..18556bc5 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js @@ -130,6 +130,21 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); + + this.element.addEventListener("keyup", function(evt){ + if(evt.keyCode == 27) {//ESC key + if(that.application.ninja.newFileController.newFileOptionsNav !== null){ + that.handleCancelButtonAction(); + } + }else if((evt.keyCode == 13) && !(evt.ctrlKey || evt.metaKey)){//ENTER key + if((that.application.ninja.newFileController.newFileOptionsNav !== null) + && !that.okButton.hasAttribute("disabled")){ + + that.handleOkButtonAction(); + } + } + }, true); + } }, 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 dfaac1aa..d59d5be1 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 @@ -64,6 +64,21 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { this.newFileName.select(); this.enableOk(); + + this.element.addEventListener("keyup", function(evt){ + if(evt.keyCode == 27) {//ESC key + if(self.application.ninja.newFileController.saveAsDialog !== null){ + self.handleCancelButtonAction(); + } + }else if((evt.keyCode == 13) && !(evt.ctrlKey || evt.metaKey)){//ENTER key + if((self.application.ninja.newFileController.saveAsDialog !== null) + && !self.okButton.hasAttribute("disabled")){ + + self.handleOkButtonAction(); + } + } + }, true); + } }, -- cgit v1.2.3