From 834086b91afc752745128a0c2be4730bf1c7858d Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 28 Mar 2012 14:02:57 -0700 Subject: detect paste from context menu for new file and save as dialog Signed-off-by: Ananya Sen Conflicts: js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js Signed-off-by: Ananya Sen --- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (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 d59d5be1..2bc141f7 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 @@ -55,6 +55,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { this.fileInputField.newFileDirectory.value = this.folderUri; this.newFileName.addEventListener("keyup", function(evt){self.handleNewFileNameOnkeyup(evt);}, false); + this.newFileName.addEventListener("paste", this, false); this.eventManager.addEventListener("newFileDirectorySet", function(evt){self.handleNewFileDirectorySet(evt);}, false); this.okButton.addEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false); @@ -98,6 +99,15 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { } }, + handlePaste:{ + value:function(evt){ + var self=this; + setTimeout(function(){ + self.handleNewFileNameOnkeyup(evt); + }, 1); + } + }, + handleNewFileNameOnkeyup:{ value:function(evt){ this.fileName = this.newFileName.value; -- cgit v1.2.3 From d4a682ddca0248e0dd7d8871dddbd167bd020a18 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 30 Mar 2012 16:31:18 -0700 Subject: - using clipboard data directly to avoid using setTimeout - fixed logical error to trigger OK on Enter key pressed Signed-off-by: Ananya Sen --- js/io/ui/save-as-dialog.reel/save-as-dialog.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 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 2bc141f7..c5ed8d33 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 @@ -85,8 +85,8 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { handleNewFileDirectorySet:{ value:function(evt){ - if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ - this.handleOkButtonAction(evt); + if(evt.keyCode === 13){ + if(!this.okButton.hasAttribute("disabled")) this.handleOkButtonAction(evt); }else if(evt.keyCode === 27){ this.handleCancelButtonAction(evt); } @@ -101,10 +101,9 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { handlePaste:{ value:function(evt){ - var self=this; - setTimeout(function(){ - self.handleNewFileNameOnkeyup(evt); - }, 1); + evt.preventDefault(); + evt.target.value = evt.clipboardData.getData("Text"); + this.handleNewFileNameOnkeyup(evt); } }, -- cgit v1.2.3