From 7a481168f1dd52069023cc0c8766f8078fe20089 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 14 Mar 2012 11:43:11 -0700 Subject: Removing the obsolete modalContainer div. Signed-off-by: Valerio Virgillito --- js/io/ui/new-file-dialog/new-file-workflow-controller.js | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'js/io/ui/new-file-dialog') diff --git a/js/io/ui/new-file-dialog/new-file-workflow-controller.js b/js/io/ui/new-file-dialog/new-file-workflow-controller.js index 901b61c7..d065ca35 100755 --- a/js/io/ui/new-file-dialog/new-file-workflow-controller.js +++ b/js/io/ui/new-file-dialog/new-file-workflow-controller.js @@ -70,21 +70,10 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre var fileName = data.fileName || "filename.txt"; var folderUri = data.folderUri || "/Documents"; - //render modal dialog - var saveAsDialogContainer = document.createElement("div"); - saveAsDialogContainer.id = "saveAsDialog"; - - //elements needs to be on DOM to be drawn - document.getElementById('modalContainer').appendChild(saveAsDialogContainer); - var saveAsDialog = saveAsModule.SaveAsDialog.create(); saveAsDialog.fileName = fileName; saveAsDialog.folderUri = folderUri; saveAsDialog.callback = data.callback; - saveAsDialog.element = saveAsDialogContainer; - - //remove after rendering and add in modal dialog - document.getElementById('modalContainer').removeChild(saveAsDialogContainer); var popup = Popup.create(); popup.content = saveAsDialog; -- cgit v1.2.3 From 2557f463c1cfe2d0dd8ea187c184755bd141dab4 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:38:44 -0700 Subject: IKNINJA-1302 : For File>New and File>SaveAll dialogs, 'ESC' key now triggers Cancel button and 'Enter' key now triggers OK button. For File picker, the 'ESC' now triggers the Cancel button. Signed-off-by: Ananya Sen Conflicts: js/io/ui/new-file-dialog/new-file-workflow-controller.js Signed-off-by: Ananya Sen --- .../new-file-location.reel/new-file-location.js | 6 ++++++ .../new-file-options-navigator.js | 8 ++++++++ js/io/ui/new-file-dialog/new-file-workflow-controller.js | 14 ++++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) (limited to 'js/io/ui/new-file-dialog') 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 0e1e09a4..c4b7ea99 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 @@ -34,6 +34,12 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { newFileNameSetEvent.newFileName = this.newFileName.value; this.eventManager.dispatchEvent(newFileNameSetEvent); } + if(evt.keyCode === 13){ + var enterPressedEvent = document.createEvent("Events"); + enterPressedEvent.initEvent("enterPressed", false, false); + enterPressedEvent.newFileName = this.newFileName.value; + this.eventManager.dispatchEvent(enterPressedEvent); + } } } 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 aaf39005..5adcc250 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 @@ -106,6 +106,12 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); + this.element.addEventListener("enterPressed", function(evt){ + if(!that.okButton.hasAttribute("disabled")){ + that.handleOkButtonAction(evt); + } + }, false); + if(!!this.newFileModel.defaultProjectType){ var templates = this.newFileModel.prepareContents(this.newFileModel.defaultProjectType); this.templateList = iconsListModule.IconsList.create(); @@ -382,6 +388,8 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.element.removeEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only this.eventManager.removeEventListener("newFileDirectorySet", function(evt){that.handleNewFileDirectorySet(evt);}, false); this.eventManager.removeEventListener("newFileNameSet", function(evt){that.handleNewFileNameSet(evt);}, false); + + this.application.ninja.newFileController.newFileOptionsNav = null; } }, diff --git a/js/io/ui/new-file-dialog/new-file-workflow-controller.js b/js/io/ui/new-file-dialog/new-file-workflow-controller.js index d065ca35..279a74b4 100755 --- a/js/io/ui/new-file-dialog/new-file-workflow-controller.js +++ b/js/io/ui/new-file-dialog/new-file-workflow-controller.js @@ -27,6 +27,16 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre value: null }, + newFileOptionsNav:{ + enumerable:true, + value: null + }, + + saveAsDialog:{ + enumerable:true, + value: null + }, + showNewFileDialog:{ writable:false, enumerable:true, @@ -49,7 +59,7 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre this.model.defaultProjectType = lastSelectedProjectType; } - var newFileOptionsNav = newFileOptionsNavigatorModule.NewFileOptionsNavigator.create(); + var newFileOptionsNav = this.newFileOptionsNav = newFileOptionsNavigatorModule.NewFileOptionsNavigator.create(); newFileOptionsNav.newFileModel = this.model; var popup = Popup.create(); @@ -70,7 +80,7 @@ var NewFileWorkflowController = exports.NewFileWorkflowController = Montage.cre var fileName = data.fileName || "filename.txt"; var folderUri = data.folderUri || "/Documents"; - var saveAsDialog = saveAsModule.SaveAsDialog.create(); + var saveAsDialog = this.saveAsDialog = saveAsModule.SaveAsDialog.create(); saveAsDialog.fileName = fileName; saveAsDialog.folderUri = folderUri; saveAsDialog.callback = data.callback; -- cgit v1.2.3 From 85bf9f937fa2ec46e42f791fc6815f7c2f5446ea Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:42:05 -0700 Subject: file picker - added size unit new file - don't disable OK is file exists Signed-off-by: Ananya Sen --- .../new-file-options-navigator.js | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'js/io/ui/new-file-dialog') 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 5adcc250..f63067b1 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 @@ -297,10 +297,16 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C }else{ if(this.error.innerHTML === ""){ this.showError("! Project Template, Name and Directory should be valid."); - } - //disable ok - if(!this.okButton.hasAttribute("disabled")){ - this.okButton.setAttribute("disabled", "true"); + //disable ok + if(!this.okButton.hasAttribute("disabled")){ + this.okButton.setAttribute("disabled", "true"); + } + }else if(!this.selectedProjectType || !this.selectedTemplate){ + this.showError("! Project Template should be selected."); + //disable ok + if(!this.okButton.hasAttribute("disabled")){ + this.okButton.setAttribute("disabled", "true"); + } } } } @@ -399,6 +405,10 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C if(uri !== ""){ if(!status){ this.showError("! Invalid directory."); + //disable ok + if(!this.okButton.hasAttribute("disabled")){ + this.okButton.setAttribute("disabled", "true"); + } } } return status; @@ -410,6 +420,10 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C if(fileName !== ""){ if(!status){ this.showError("! Invalid file name."); + //disable ok + if(!this.okButton.hasAttribute("disabled")){ + this.okButton.setAttribute("disabled", "true"); + } } } return status; @@ -445,10 +459,6 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C value:function(errorString){ this.error.innerHTML = ""; this.error.innerHTML=errorString; - //disable ok - if(!this.okButton.hasAttribute("disabled")){ - this.okButton.setAttribute("disabled", "true"); - } } }, -- cgit v1.2.3 From 5b0ff2b7347d158876c366c51988a94570dda18b Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:43:54 -0700 Subject: IKNINJA-1302 : more fix Signed-off-by: Ananya Sen --- .../new-file-location.reel/new-file-location.js | 7 +--- .../new-file-options-navigator.js | 39 +++++++++++----------- 2 files changed, 21 insertions(+), 25 deletions(-) (limited to 'js/io/ui/new-file-dialog') 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 c4b7ea99..811231e4 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 @@ -32,14 +32,9 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { var newFileNameSetEvent = document.createEvent("Events"); newFileNameSetEvent.initEvent("newFileNameSet", false, false); newFileNameSetEvent.newFileName = this.newFileName.value; + newFileNameSetEvent.keyCode = evt.keyCode; this.eventManager.dispatchEvent(newFileNameSetEvent); } - if(evt.keyCode === 13){ - var enterPressedEvent = document.createEvent("Events"); - enterPressedEvent.initEvent("enterPressed", false, false); - enterPressedEvent.newFileName = this.newFileName.value; - this.eventManager.dispatchEvent(enterPressedEvent); - } } } 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 f63067b1..d5b59ab8 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 @@ -98,20 +98,6 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.addIdentifiers(); - this.element.addEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false); - this.element.addEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only - this.eventManager.addEventListener("newFileDirectorySet", function(evt){that.handleNewFileDirectorySet(evt);}, false); - this.eventManager.addEventListener("newFileNameSet", function(evt){that.handleNewFileNameSet(evt);}, false); - - this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); - this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); - - this.element.addEventListener("enterPressed", function(evt){ - if(!that.okButton.hasAttribute("disabled")){ - that.handleOkButtonAction(evt); - } - }, false); - if(!!this.newFileModel.defaultProjectType){ var templates = this.newFileModel.prepareContents(this.newFileModel.defaultProjectType); this.templateList = iconsListModule.IconsList.create(); @@ -122,7 +108,6 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.templateList.element = this.templateIcons; this.templateList.needsDraw = true; - this.selectedProjectType = {"uri":this.newFileModel.defaultProjectType, "element":null}; } @@ -133,6 +118,18 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C fileExtensionEl.innerHTML = ""+this.newFileModel.projectTypeData[this.newFileModel.defaultProjectType].fileExtension; } } + + this.element.addEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false); + this.element.addEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only + this.eventManager.addEventListener("newFileDirectorySet", function(evt){ + that.handleNewFileDirectorySet(evt); + }, false); + this.eventManager.addEventListener("newFileNameSet", function(evt){ + that.handleNewFileNameSet(evt); + }, false); + + this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); + this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); } }, @@ -314,7 +311,10 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C handleNewFileDirectorySet:{ value:function(evt){ - if(!!evt._event.newFileDirectory){ + if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ + this.handleOkButtonAction(evt); + } + else if(!!evt._event.newFileDirectory){ this.newFileDirectory = evt._event.newFileDirectory; if(this.isValidUri(this.newFileDirectory)){ this.enableOk(); @@ -325,7 +325,10 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C handleNewFileNameSet:{ value:function(evt){ - if(!!evt._event.newFileName){ + if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ + this.handleOkButtonAction(evt); + } + else if(!!evt._event.newFileName){ this.newFileName = evt._event.newFileName; if(this.isValidFileName(this.newFileName)){ this.enableOk(); @@ -386,8 +389,6 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.newFileName = ""; this.newFileDirectory = ""; - this.selectedProjectType = null; - this.selectedTemplate = null; //remove event listeners this.element.removeEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false); -- cgit v1.2.3 From 7a7ac1d6479155760d99b7ecdf5a8d1f63e25f24 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:46:39 -0700 Subject: IKNINJA-1361: autofocus and auto-select file name on open of new file and save as dialog Signed-off-by: Ananya Sen --- js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/io/ui/new-file-dialog') 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 811231e4..fac4c488 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 @@ -23,6 +23,8 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { this.fileInputField.selectDirectory = true; this.newFileName.addEventListener("keyup", this, false); + this.newFileName.focus(); + this.newFileName.select(); } }, -- cgit v1.2.3 From 87cf1d7d899bb60581d5e5c6c7ba678620c7148e Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 11:46:04 -0700 Subject: IKNINJA-1302 : close on ESC even if text field is focussed Signed-off-by: Ananya Sen --- .../new-file-options-navigator.reel/new-file-options-navigator.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'js/io/ui/new-file-dialog') 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 d5b59ab8..ecee7c1d 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 @@ -313,6 +313,8 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C value:function(evt){ if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ this.handleOkButtonAction(evt); + }else if(evt.keyCode === 27){ + this.handleCancelButtonAction(evt); } else if(!!evt._event.newFileDirectory){ this.newFileDirectory = evt._event.newFileDirectory; @@ -327,6 +329,8 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C value:function(evt){ if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ this.handleOkButtonAction(evt); + }else if(evt.keyCode === 27){ + this.handleCancelButtonAction(evt); } else if(!!evt._event.newFileName){ this.newFileName = evt._event.newFileName; -- cgit v1.2.3 From 80ceeffeb3dd3227008714b8b56383f9556ff409 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 14:49:17 -0700 Subject: KNINJA-1302 : refactored fixed as per request Signed-off-by: Ananya Sen --- .../new-file-options-navigator.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'js/io/ui/new-file-dialog') 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 ecee7c1d..18556bc5 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 @@ -130,6 +130,21 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); + + this.element.addEventListener("keyup", function(evt){ + if(evt.keyCode == 27) {//ESC key + if(that.application.ninja.newFileController.newFileOptionsNav !== null){ + that.handleCancelButtonAction(); + } + }else if((evt.keyCode == 13) && !(evt.ctrlKey || evt.metaKey)){//ENTER key + if((that.application.ninja.newFileController.newFileOptionsNav !== null) + && !that.okButton.hasAttribute("disabled")){ + + that.handleOkButtonAction(); + } + } + }, true); + } }, -- cgit v1.2.3 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 --- .../new-file-location.reel/new-file-location.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'js/io/ui/new-file-dialog') 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 fac4c488..5dd1153d 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 @@ -23,11 +23,21 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { this.fileInputField.selectDirectory = true; this.newFileName.addEventListener("keyup", this, false); - this.newFileName.focus(); + this.newFileName.addEventListener("paste", this, false); + this.newFileName.focus(); this.newFileName.select(); } }, + handlePaste:{ + value:function(evt){ + var self=this; + setTimeout(function(){ + self.handleKeyup(evt); + }, 1); + } + }, + handleKeyup:{ value:function(evt){ if(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 --- .../ui/new-file-dialog/new-file-location.reel/new-file-location.js | 7 +++---- .../new-file-options-navigator.reel/new-file-options-navigator.js | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'js/io/ui/new-file-dialog') 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 5dd1153d..02579676 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 @@ -31,10 +31,9 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { handlePaste:{ value:function(evt){ - var self=this; - setTimeout(function(){ - self.handleKeyup(evt); - }, 1); + evt.preventDefault(); + evt.target.value = evt.clipboardData.getData("Text"); + this.handleKeyup(evt); } }, 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 18556bc5..c98955ca 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 @@ -326,8 +326,8 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C 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); } -- cgit v1.2.3 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 +++++++++++-------- .../new-file-options-navigator.js | 18 +++++++----------- 2 files changed, 18 insertions(+), 19 deletions(-) (limited to 'js/io/ui/new-file-dialog') 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 -- 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.html | 9 ++++- .../new-file-location.reel/new-file-location.js | 32 +++++++-------- .../new-file-options-navigator.js | 45 +++++++++++++--------- 3 files changed, 50 insertions(+), 36 deletions(-) (limited to 'js/io/ui/new-file-dialog') diff --git a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.html b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.html index 7340251c..1f9d9b9f 100755 --- a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.html +++ b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.html @@ -58,13 +58,20 @@ } }, + "newFileName": { + "prototype": "montage/ui/textfield.reel", + "properties": { + "element": {"#": "newFileName"} + } + }, + "owner":{ "module": "js/io/ui/new-file-dialog/new-file-location.reel", "name": "NewFileLocation", "properties": { "element": {"#": "newfileLocation"}, "fileInputField": {"@": "fileInputField"}, - "newFileName": {"#": "newFileName"} + "newFileName": {"@": "newFileName"} } } } 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 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 35c3b28e..552e8f6f 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 @@ -145,6 +145,9 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C } }, true); + this.eventManager.addEventListener("enterKey", this, false); + this.eventManager.addEventListener("escKey", this, false); + } }, @@ -326,32 +329,36 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C 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.newFileDirectory = evt._event.newFileDirectory; - if(this.isValidUri(this.newFileDirectory)){ - this.enableOk(); - } + this.newFileDirectory = evt._event.newFileDirectory; + if(this.isValidUri(this.newFileDirectory)){ + this.enableOk(); } } }, handleNewFileNameSet:{ value:function(evt){ - if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ - this.handleOkButtonAction(evt); - }else if(evt.keyCode === 27){ - this.handleCancelButtonAction(evt); + this.newFileName = evt._event.newFileName; + if(this.isValidFileName(this.newFileName)){ + this.enableOk(); } - else{ - this.newFileName = evt._event.newFileName; - if(this.isValidFileName(this.newFileName)){ - this.enableOk(); - } + } + }, + + handleEnterKey:{ + value: function(evt){ + if((this.application.ninja.newFileController.newFileOptionsNav !== null) + && !this.okButton.hasAttribute("disabled")){ + + this.handleOkButtonAction(evt); + } + } + }, + + handleEscKey:{ + value: function(evt){ + if(this.application.ninja.newFileController.newFileOptionsNav !== 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 --- .../new-file-options-navigator.reel/new-file-options-navigator.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/io/ui/new-file-dialog') 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 552e8f6f..1a26c99c 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 @@ -493,6 +493,7 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C 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