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 --- .../new-file-options-navigator.reel/new-file-options-navigator.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') 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; } }, -- 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 --- .../new-file-options-navigator.js | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') 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 --- .../new-file-options-navigator.js | 39 +++++++++++----------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') 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); -- 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 ++++ 1 file changed, 4 insertions(+) (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') 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; -- 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 --- .../new-file-options-navigator.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') 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); + } }, -- cgit v1.2.3 From d4a682ddca0248e0dd7d8871dddbd167bd020a18 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 30 Mar 2012 16:31:18 -0700 Subject: - using clipboard data directly to avoid using setTimeout - fixed logical error to trigger OK on Enter key pressed Signed-off-by: Ananya Sen --- .../new-file-options-navigator.reel/new-file-options-navigator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') 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 18556bc5..c98955ca 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 @@ -326,8 +326,8 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C handleNewFileDirectorySet:{ value:function(evt){ - if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ - this.handleOkButtonAction(evt); + if(evt.keyCode === 13){ + if(!this.okButton.hasAttribute("disabled")) this.handleOkButtonAction(evt); }else if(evt.keyCode === 27){ this.handleCancelButtonAction(evt); } -- cgit v1.2.3