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/system/coreioapi.js | 2 +- .../file-input-field.reel/file-input-field.js | 21 ++++++++++------- .../new-file-location.reel/new-file-location.js | 19 +++++++++------- .../new-file-options-navigator.js | 18 ++++++--------- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 26 +++++++++++----------- 5 files changed, 45 insertions(+), 41 deletions(-) (limited to 'js/io') diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index b0ffe2d8..ed7df972 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js @@ -1085,7 +1085,7 @@ exports.CoreIoApi = Montage.create(Component, { isValidUri:{ value: function(uri){ var isWindowsUri=false, isUnixUri=false,status=false; - if(uri !== ""){ + if((uri !== null) && (uri !== "")){ uri = uri.replace(/^\s+|\s+$/g,""); // strip any leading or trailing spaces //for local machine folder uri diff --git a/js/io/ui/file-picker/file-input-field.reel/file-input-field.js b/js/io/ui/file-picker/file-input-field.reel/file-input-field.js index 46e8b386..0f66468a 100755 --- a/js/io/ui/file-picker/file-input-field.reel/file-input-field.js +++ b/js/io/ui/file-picker/file-input-field.reel/file-input-field.js @@ -21,6 +21,7 @@ var FileInputField = exports.FileInputField = Montage.create(Component, { this.newFileDirectory.addEventListener("keyup", function(evt){that.handleNewFileDirectoryOnkeyup(evt);}, false); this.newFileDirectory.addEventListener("paste", this, false); + this.newFileDirectory.addEventListener("search", this, false); } }, @@ -74,16 +75,20 @@ var FileInputField = exports.FileInputField = Montage.create(Component, { handleNewFileDirectoryOnkeyup:{ value:function(evt){ - if(this.newFileDirectory.value !== ""){ - var newFileDirectorySetEvent = document.createEvent("Events"); - newFileDirectorySetEvent.initEvent("newFileDirectorySet", false, false); - newFileDirectorySetEvent.newFileDirectory = this.newFileDirectory.value; - newFileDirectorySetEvent.keyCode = evt.keyCode; - this.eventManager.dispatchEvent(newFileDirectorySetEvent); - } + var newFileDirectorySetEvent = document.createEvent("Events"); + newFileDirectorySetEvent.initEvent("newFileDirectorySet", false, false); + newFileDirectorySetEvent.newFileDirectory = this.newFileDirectory.value; + newFileDirectorySetEvent.keyCode = evt.keyCode; + this.eventManager.dispatchEvent(newFileDirectorySetEvent); } }, + handleSearch:{ + value:function(evt){ + this.handleNewFileDirectoryOnkeyup(evt); + } + }, + handleFileInputPickerSelectionsDone:{ value: function(evt){ var selectedUri = ""; @@ -105,7 +110,7 @@ var FileInputField = exports.FileInputField = Montage.create(Component, { if(!!obj && obj.uri && obj.uri.length > 0){ selectedUri = obj.uri[0]; this.newFileDirectory.value = selectedUri; - + this.newFileDirectory.focus(); var newFileDirectorySetEvent = document.createEvent("Events"); newFileDirectorySetEvent.initEvent("newFileDirectorySet", false, false); newFileDirectorySetEvent.newFileDirectory = this.newFileDirectory.value; 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 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 --- .../file-input-field.reel/file-input-field.html | 10 ++- .../file-input-field.reel/file-input-field.js | 37 +++++----- .../new-file-location.reel/new-file-location.html | 9 ++- .../new-file-location.reel/new-file-location.js | 32 ++++----- .../new-file-options-navigator.js | 45 ++++++------ js/io/ui/save-as-dialog.reel/save-as-dialog.html | 9 ++- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 79 ++++++++++++---------- 7 files changed, 127 insertions(+), 94 deletions(-) (limited to 'js/io') diff --git a/js/io/ui/file-picker/file-input-field.reel/file-input-field.html b/js/io/ui/file-picker/file-input-field.reel/file-input-field.html index 2fcaa075..00df1c11 100755 --- a/js/io/ui/file-picker/file-input-field.reel/file-input-field.html +++ b/js/io/ui/file-picker/file-input-field.reel/file-input-field.html @@ -10,13 +10,21 @@