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/save-as-dialog.js') 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 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 --- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 79 ++++++++++++++------------ 1 file changed, 43 insertions(+), 36 deletions(-) (limited to 'js/io/ui/save-as-dialog.reel/save-as-dialog.js') 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 81d1afee..5df91ab9 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 @@ -36,7 +36,12 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { writable: true, value: null }, - + prepareForDraw: { + value: function() { + this.newFileName.value = this.fileName; + this.fileInputField.newFileDirectory.value = this.folderUri; + } + }, willDraw: { enumerable: false, value: function() {} @@ -51,19 +56,16 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { var self = this; this.fileInputField.selectDirectory = true; this.fileInputField.pickerName = "saveAsDirectoryPicker"; - this.newFileName.value = this.fileName; - this.fileInputField.newFileDirectory.value = this.folderUri; - this.newFileName.addEventListener("keyup", function(evt){self.handleNewFileNameOnkeyup(evt);}, false); - this.newFileName.addEventListener("paste", this, false); - this.newFileName.addEventListener("search", this, false); + this.addEventListener("change@newFileName.value", this.handleNewFileNameChange, false); + this.newFileName.element.addEventListener("keyup", this, false); this.eventManager.addEventListener("newFileDirectorySet", function(evt){self.handleNewFileDirectorySet(evt);}, false); - 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.eventManager.addEventListener("enterKey", this, false); + this.eventManager.addEventListener("escKey", this, false); + this.enableOk(); @@ -81,52 +83,57 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { } }, true); + this.newFileName.element.focus(); + this.newFileName.element.select(); + } }, 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.folderUri = evt._event.newFileDirectory; - if(this.isValidUri(this.folderUri)){ - this.enableOk(); - } + this.folderUri = evt._event.newFileDirectory; + if(this.isValidUri(this.folderUri)){ + this.enableOk(); } } }, - handlePaste:{ - value:function(evt){ - evt.preventDefault(); - evt.target.value = evt.clipboardData.getData("Text"); - this.handleNewFileNameOnkeyup(evt); - } - }, - - handleNewFileNameOnkeyup:{ + handleNewFileNameChange:{ value:function(evt){ this.fileName = this.newFileName.value; if(this.isValidFileName(this.fileName)){ this.enableOk(); } - if(evt.keyCode === 13){ - if(!this.okButton.hasAttribute("disabled")){ + } + }, + + handleKeyup:{ + value: function(evt){ + if(evt.keyCode === 13){ + if(!this.okButton.hasAttribute("disabled")){ this.handleOkButtonAction(evt); } - }else if(evt.keyCode === 27){ - this.handleCancelButtonAction(evt); + }else if(evt.keyCode === 27){ + this.handleCancelButtonAction(evt); + } + } + }, + + handleEnterKey:{ + value: function(evt){ + if((this.application.ninja.newFileController.saveAsDialog !== null) + && !this.okButton.hasAttribute("disabled")){ + + this.handleOkButtonAction(evt); } - } + } }, - handleSearch:{ - value:function(evt){ - this.handleNewFileNameOnkeyup(evt); + handleEscKey:{ + value: function(evt){ + if(this.application.ninja.newFileController.saveAsDialog !== 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 --- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/io/ui/save-as-dialog.reel/save-as-dialog.js') 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 5df91ab9..e2f50ff5 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 @@ -266,6 +266,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { 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