aboutsummaryrefslogtreecommitdiff
path: root/js/io/ui/save-as-dialog.reel/save-as-dialog.js
diff options
context:
space:
mode:
authorEric Guzman2012-04-02 15:36:08 -0700
committerEric Guzman2012-04-02 15:36:08 -0700
commit0241bf331b7e06e206a54be441edf2f4c7261f63 (patch)
treeb7e2f9cad73eed4fc616cf1841cd0be02bd955d4 /js/io/ui/save-as-dialog.reel/save-as-dialog.js
parentdde5b5054f93db493e5d4d502e677f5781334b08 (diff)
parentc6de22bf42be90b403491b5f87b1818d9020310c (diff)
downloadninja-0241bf331b7e06e206a54be441edf2f4c7261f63.tar.gz
Merge branch 'refs/heads/master' into CSSPanelUpdates
Diffstat (limited to 'js/io/ui/save-as-dialog.reel/save-as-dialog.js')
-rw-r--r--js/io/ui/save-as-dialog.reel/save-as-dialog.js59
1 files changed, 56 insertions, 3 deletions
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 c60a92f9..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
@@ -55,18 +55,42 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
55 this.fileInputField.newFileDirectory.value = this.folderUri; 55 this.fileInputField.newFileDirectory.value = this.folderUri;
56 56
57 this.newFileName.addEventListener("keyup", function(evt){self.handleNewFileNameOnkeyup(evt);}, false); 57 this.newFileName.addEventListener("keyup", function(evt){self.handleNewFileNameOnkeyup(evt);}, false);
58 this.newFileName.addEventListener("paste", this, false);
58 this.eventManager.addEventListener("newFileDirectorySet", function(evt){self.handleNewFileDirectorySet(evt);}, false); 59 this.eventManager.addEventListener("newFileDirectorySet", function(evt){self.handleNewFileDirectorySet(evt);}, false);
59 60
60 this.okButton.addEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false); 61 this.okButton.addEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false);
61 this.cancelButton.addEventListener("click", function(evt){self.handleCancelButtonAction(evt);}, false); 62 this.cancelButton.addEventListener("click", function(evt){self.handleCancelButtonAction(evt);}, false);
62 63
64 this.newFileName.focus();
65 this.newFileName.select();
66
63 this.enableOk(); 67 this.enableOk();
68
69 this.element.addEventListener("keyup", function(evt){
70 if(evt.keyCode == 27) {//ESC key
71 if(self.application.ninja.newFileController.saveAsDialog !== null){
72 self.handleCancelButtonAction();
73 }
74 }else if((evt.keyCode == 13) && !(evt.ctrlKey || evt.metaKey)){//ENTER key
75 if((self.application.ninja.newFileController.saveAsDialog !== null)
76 && !self.okButton.hasAttribute("disabled")){
77
78 self.handleOkButtonAction();
79 }
80 }
81 }, true);
82
64 } 83 }
65 }, 84 },
66 85
67 handleNewFileDirectorySet:{ 86 handleNewFileDirectorySet:{
68 value:function(evt){ 87 value:function(evt){
69 if(!!evt._event.newFileDirectory){ 88 if(evt.keyCode === 13){
89 if(!this.okButton.hasAttribute("disabled")) this.handleOkButtonAction(evt);
90 }else if(evt.keyCode === 27){
91 this.handleCancelButtonAction(evt);
92 }
93 else if(!!evt._event.newFileDirectory){
70 this.folderUri = evt._event.newFileDirectory; 94 this.folderUri = evt._event.newFileDirectory;
71 if(this.isValidUri(this.folderUri)){ 95 if(this.isValidUri(this.folderUri)){
72 this.enableOk(); 96 this.enableOk();
@@ -75,6 +99,14 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
75 } 99 }
76 }, 100 },
77 101
102 handlePaste:{
103 value:function(evt){
104 evt.preventDefault();
105 evt.target.value = evt.clipboardData.getData("Text");
106 this.handleNewFileNameOnkeyup(evt);
107 }
108 },
109
78 handleNewFileNameOnkeyup:{ 110 handleNewFileNameOnkeyup:{
79 value:function(evt){ 111 value:function(evt){
80 this.fileName = this.newFileName.value; 112 this.fileName = this.newFileName.value;
@@ -83,6 +115,13 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
83 this.enableOk(); 115 this.enableOk();
84 } 116 }
85 } 117 }
118 if(evt.keyCode === 13){
119 if(!this.okButton.hasAttribute("disabled")){
120 this.handleOkButtonAction(evt);
121 }
122 }else if(evt.keyCode === 27){
123 this.handleCancelButtonAction(evt);
124 }
86 } 125 }
87 }, 126 },
88 127
@@ -99,7 +138,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
99 handleCancelButtonAction :{ 138 handleCancelButtonAction :{
100 value:function(evt){ 139 value:function(evt){
101 //clean up memory 140 //clean up memory
102 //this.cleanup(); 141 this.cleanup();
103 142
104 if(this.popup){ 143 if(this.popup){
105 this.popup.hide(); 144 this.popup.hide();
@@ -134,7 +173,7 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
134 173
135 if(success){ 174 if(success){
136 //clean up memory 175 //clean up memory
137 //this.cleanup(); 176 this.cleanup();
138 177
139 if(this.popup){ 178 if(this.popup){
140 this.popup.hide(); 179 this.popup.hide();
@@ -227,6 +266,20 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, {
227 } 266 }
228 return status; 267 return status;
229 } 268 }
269 },
270
271 cleanup:{
272 value:function(){
273 var self = this;
274
275 //remove event listener
276 this.newFileName.removeEventListener("keyup", function(evt){self.handleNewFileNameOnkeyup(evt);}, false);
277 this.eventManager.removeEventListener("newFileDirectorySet", function(evt){self.handleNewFileDirectorySet(evt);}, false);
278 this.okButton.removeEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false);
279 this.cancelButton.removeEventListener("click", function(evt){self.handleCancelButtonAction(evt);}, false);
280
281 this.application.ninja.newFileController.saveAsDialog = null;
230 } 282 }
283 }
231 284
232}); \ No newline at end of file 285}); \ No newline at end of file