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-location.reel/new-file-location.js | 19 +++++++++++-------- .../new-file-options-navigator.js | 18 +++++++----------- 2 files changed, 18 insertions(+), 19 deletions(-) (limited to 'js/io/ui/new-file-dialog') 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 02579676..3582f1a5 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 @@ -24,6 +24,7 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { this.newFileName.addEventListener("keyup", this, false); this.newFileName.addEventListener("paste", this, false); + this.newFileName.addEventListener("search", this, false); this.newFileName.focus(); this.newFileName.select(); } @@ -39,14 +40,16 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { handleKeyup:{ value:function(evt){ - if(this.newFileName.value !== "") { - var newFileNameSetEvent = document.createEvent("Events"); - newFileNameSetEvent.initEvent("newFileNameSet", false, false); - newFileNameSetEvent.newFileName = this.newFileName.value; - newFileNameSetEvent.keyCode = evt.keyCode; - this.eventManager.dispatchEvent(newFileNameSetEvent); - } + var newFileNameSetEvent = document.createEvent("Events"); + newFileNameSetEvent.initEvent("newFileNameSet", false, false); + newFileNameSetEvent.newFileName = this.newFileName.value; + newFileNameSetEvent.keyCode = evt.keyCode; + this.eventManager.dispatchEvent(newFileNameSetEvent); + } + }, + handleSearch:{ + value:function(evt){ + this.handleKeyup(evt); } } - }); \ No newline at end of file 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-location.reel/new-file-location.html | 9 ++++- .../new-file-location.reel/new-file-location.js | 32 +++++++-------- .../new-file-options-navigator.js | 45 +++++++++++++--------- 3 files changed, 50 insertions(+), 36 deletions(-) (limited to 'js/io/ui/new-file-dialog') diff --git a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.html b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.html index 7340251c..1f9d9b9f 100755 --- a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.html +++ b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.html @@ -58,13 +58,20 @@ } }, + "newFileName": { + "prototype": "montage/ui/textfield.reel", + "properties": { + "element": {"#": "newFileName"} + } + }, + "owner":{ "module": "js/io/ui/new-file-dialog/new-file-location.reel", "name": "NewFileLocation", "properties": { "element": {"#": "newfileLocation"}, "fileInputField": {"@": "fileInputField"}, - "newFileName": {"#": "newFileName"} + "newFileName": {"@": "newFileName"} } } } 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 3582f1a5..3ac38d02 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 @@ -22,23 +22,28 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { value: function() { this.fileInputField.selectDirectory = true; - this.newFileName.addEventListener("keyup", this, false); - this.newFileName.addEventListener("paste", this, false); - this.newFileName.addEventListener("search", this, false); - this.newFileName.focus(); - this.newFileName.select(); + this.addEventListener("change@newFileName.value", this.newFileNameChange, false); + this.newFileName.element.addEventListener("keyup", this, false); + this.newFileName.element.focus(); + this.newFileName.element.select(); } }, - handlePaste:{ - value:function(evt){ - evt.preventDefault(); - evt.target.value = evt.clipboardData.getData("Text"); - this.handleKeyup(evt); + handleKeyup:{ + value: function(evt){ + if(evt.keyCode === 13){ + var enterKeyupEvent = document.createEvent("Events"); + enterKeyupEvent.initEvent("enterKey", false, false); + this.eventManager.dispatchEvent(enterKeyupEvent); + }else if(evt.keyCode === 27){ + var escKeyupEvent = document.createEvent("Events"); + escKeyupEvent.initEvent("escKey", false, false); + this.eventManager.dispatchEvent(escKeyupEvent); + } } }, - handleKeyup:{ + newFileNameChange:{ value:function(evt){ var newFileNameSetEvent = document.createEvent("Events"); newFileNameSetEvent.initEvent("newFileNameSet", false, false); @@ -46,10 +51,5 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { newFileNameSetEvent.keyCode = evt.keyCode; this.eventManager.dispatchEvent(newFileNameSetEvent); } - }, - handleSearch:{ - value:function(evt){ - this.handleKeyup(evt); - } } }); \ No newline at end of file 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') 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