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 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js') 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 -- 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.js | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js') 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 -- cgit v1.2.3