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 From 5de25f936c9dce08f1d24824ae1946a07e7b708d Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 4 Apr 2012 19:21:01 -0700 Subject: - disable ok when text box is cleared using backspace and cross, for file name and directory location, in New file and save as dialog Signed-off-by: Ananya Sen --- .../new-file-options-navigator.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 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 c98955ca..35c3b28e 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 @@ -30,12 +30,12 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C newFileName:{ writable:true, enumerable:false, - value:"" + value:null }, newFileDirectory:{ writable:true, enumerable:false, - value:"" + value:null }, templateWidth:{ writable:true, @@ -331,7 +331,7 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C }else if(evt.keyCode === 27){ this.handleCancelButtonAction(evt); } - else if(!!evt._event.newFileDirectory){ + else{ this.newFileDirectory = evt._event.newFileDirectory; if(this.isValidUri(this.newFileDirectory)){ this.enableOk(); @@ -347,7 +347,7 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C }else if(evt.keyCode === 27){ this.handleCancelButtonAction(evt); } - else if(!!evt._event.newFileName){ + else{ this.newFileName = evt._event.newFileName; if(this.isValidFileName(this.newFileName)){ this.enableOk(); @@ -422,14 +422,12 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C isValidUri:{ value: function(uri){ var status= this.application.ninja.coreIoApi.isValidUri(uri); - if(uri !== ""){ - if(!status){ + if((uri !== null) && !status){ this.showError("! Invalid directory."); //disable ok if(!this.okButton.hasAttribute("disabled")){ this.okButton.setAttribute("disabled", "true"); } - } } return status; } @@ -437,14 +435,12 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C isValidFileName:{ value: function(fileName){ var status = this.validateFileName(fileName); - if(fileName !== ""){ - if(!status){ + if((fileName !== null ) && !status){ this.showError("! Invalid file name."); //disable ok if(!this.okButton.hasAttribute("disabled")){ this.okButton.setAttribute("disabled", "true"); } - } } return status; } @@ -488,7 +484,7 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C validateFileName:{ value: function(fileName){ var status = false; - if(fileName !== ""){ + if((fileName !== null) && (fileName !== "")){ fileName = fileName.replace(/^\s+|\s+$/g,""); status = !(/[/\\]/g.test(fileName)); if(status && navigator.userAgent.indexOf("Macintosh") != -1){//for Mac files beginning with . are hidden -- cgit v1.2.3 From 8acdde3e87f8cabd179a068c54fe5b78fa38e40d Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 5 Apr 2012 22:54:53 -0700 Subject: - using Montage TextField component to handle any edits like keyup, paste, cut. - optimized Enter and Esc key handling Signed-off-by: Ananya Sen --- .../new-file-options-navigator.js | 45 +++++++++++++--------- 1 file changed, 26 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 35c3b28e..552e8f6f 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 @@ -145,6 +145,9 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C } }, true); + this.eventManager.addEventListener("enterKey", this, false); + this.eventManager.addEventListener("escKey", this, false); + } }, @@ -326,32 +329,36 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C handleNewFileDirectorySet:{ value:function(evt){ - if(evt.keyCode === 13){ - if(!this.okButton.hasAttribute("disabled")) this.handleOkButtonAction(evt); - }else if(evt.keyCode === 27){ - this.handleCancelButtonAction(evt); - } - else{ - this.newFileDirectory = evt._event.newFileDirectory; - if(this.isValidUri(this.newFileDirectory)){ - this.enableOk(); - } + this.newFileDirectory = evt._event.newFileDirectory; + if(this.isValidUri(this.newFileDirectory)){ + this.enableOk(); } } }, handleNewFileNameSet:{ value:function(evt){ - if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ - this.handleOkButtonAction(evt); - }else if(evt.keyCode === 27){ - this.handleCancelButtonAction(evt); + this.newFileName = evt._event.newFileName; + if(this.isValidFileName(this.newFileName)){ + this.enableOk(); } - else{ - this.newFileName = evt._event.newFileName; - if(this.isValidFileName(this.newFileName)){ - this.enableOk(); - } + } + }, + + handleEnterKey:{ + value: function(evt){ + if((this.application.ninja.newFileController.newFileOptionsNav !== null) + && !this.okButton.hasAttribute("disabled")){ + + this.handleOkButtonAction(evt); + } + } + }, + + handleEscKey:{ + value: function(evt){ + if(this.application.ninja.newFileController.newFileOptionsNav !== null){ + this.handleCancelButtonAction(evt); } } }, -- cgit v1.2.3 From efe18b4c8e52667683727139e9f9e28f66381164 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 6 Apr 2012 15:31:43 -0700 Subject: block filenames and directories with all space Signed-off-by: Ananya Sen --- .../new-file-options-navigator.reel/new-file-options-navigator.js | 1 + 1 file changed, 1 insertion(+) (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 552e8f6f..1a26c99c 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 @@ -493,6 +493,7 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C var status = false; if((fileName !== null) && (fileName !== "")){ fileName = fileName.replace(/^\s+|\s+$/g,""); + if(fileName === ""){return false;} status = !(/[/\\]/g.test(fileName)); if(status && navigator.userAgent.indexOf("Macintosh") != -1){//for Mac files beginning with . are hidden status = !(/^\./g.test(fileName)); -- cgit v1.2.3