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 --- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'js/io/ui/save-as-dialog.reel') 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 c5ed8d33..81d1afee 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 @@ -16,13 +16,13 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { fileName : { enumerable: true, writable: true, - value: "" + value: null }, folderUri:{ enumerable: true, writable: true, - value: "" + value: null }, callback : { @@ -56,6 +56,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { this.newFileName.addEventListener("keyup", function(evt){self.handleNewFileNameOnkeyup(evt);}, false); this.newFileName.addEventListener("paste", this, false); + this.newFileName.addEventListener("search", this, false); this.eventManager.addEventListener("newFileDirectorySet", function(evt){self.handleNewFileDirectorySet(evt);}, false); this.okButton.addEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false); @@ -90,7 +91,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { }else if(evt.keyCode === 27){ this.handleCancelButtonAction(evt); } - else if(!!evt._event.newFileDirectory){ + else{ this.folderUri = evt._event.newFileDirectory; if(this.isValidUri(this.folderUri)){ this.enableOk(); @@ -110,10 +111,8 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { handleNewFileNameOnkeyup:{ value:function(evt){ this.fileName = this.newFileName.value; - if(this.fileName !== ""){ - if(this.isValidFileName(this.fileName)){ + if(this.isValidFileName(this.fileName)){ this.enableOk(); - } } if(evt.keyCode === 13){ if(!this.okButton.hasAttribute("disabled")){ @@ -125,6 +124,11 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { } }, + handleSearch:{ + value:function(evt){ + this.handleNewFileNameOnkeyup(evt); + } + }, enableOk:{ value: function(){ @@ -194,10 +198,8 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { isValidUri:{ value: function(uri){ var status= this.application.ninja.coreIoApi.isValidUri(uri); - if(uri !== ""){ - if(!status){ + if((uri !== null) && !status){ this.showError("! Invalid directory."); - } } return status; } @@ -205,10 +207,8 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { isValidFileName:{ value: function(fileName){ var status = this.validateFileName(fileName); - if(fileName !== ""){ - if(!status){ + if((fileName !== null) && !status){ this.showError("! Invalid file name."); - } } return status; } @@ -257,7 +257,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { 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