diff options
author | Pushkar Joshi | 2012-04-03 15:07:07 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-04-03 15:07:07 -0700 |
commit | 12f988a32da12731ab35104128e396a6f388aeae (patch) | |
tree | 1333043a3d5573f32bcaaf8df9955aef5e2e9720 /js/io/ui/new-file-dialog | |
parent | 79fb912bdaa22b8107bbddc93d1779820af80cf9 (diff) | |
parent | c6de22bf42be90b403491b5f87b1818d9020310c (diff) | |
download | ninja-12f988a32da12731ab35104128e396a6f388aeae.tar.gz |
Merge branch 'master' into pentool
Diffstat (limited to 'js/io/ui/new-file-dialog')
3 files changed, 83 insertions, 23 deletions
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..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 | |||
@@ -23,6 +23,17 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { | |||
23 | this.fileInputField.selectDirectory = true; | 23 | this.fileInputField.selectDirectory = true; |
24 | 24 | ||
25 | this.newFileName.addEventListener("keyup", this, false); | 25 | this.newFileName.addEventListener("keyup", this, false); |
26 | this.newFileName.addEventListener("paste", this, false); | ||
27 | this.newFileName.focus(); | ||
28 | this.newFileName.select(); | ||
29 | } | ||
30 | }, | ||
31 | |||
32 | handlePaste:{ | ||
33 | value:function(evt){ | ||
34 | evt.preventDefault(); | ||
35 | evt.target.value = evt.clipboardData.getData("Text"); | ||
36 | this.handleKeyup(evt); | ||
26 | } | 37 | } |
27 | }, | 38 | }, |
28 | 39 | ||
@@ -32,6 +43,7 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { | |||
32 | var newFileNameSetEvent = document.createEvent("Events"); | 43 | var newFileNameSetEvent = document.createEvent("Events"); |
33 | newFileNameSetEvent.initEvent("newFileNameSet", false, false); | 44 | newFileNameSetEvent.initEvent("newFileNameSet", false, false); |
34 | newFileNameSetEvent.newFileName = this.newFileName.value; | 45 | newFileNameSetEvent.newFileName = this.newFileName.value; |
46 | newFileNameSetEvent.keyCode = evt.keyCode; | ||
35 | this.eventManager.dispatchEvent(newFileNameSetEvent); | 47 | this.eventManager.dispatchEvent(newFileNameSetEvent); |
36 | } | 48 | } |
37 | } | 49 | } |
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..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 | |||
@@ -98,14 +98,6 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
98 | 98 | ||
99 | this.addIdentifiers(); | 99 | this.addIdentifiers(); |
100 | 100 | ||
101 | this.element.addEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false); | ||
102 | this.element.addEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only | ||
103 | this.eventManager.addEventListener("newFileDirectorySet", function(evt){that.handleNewFileDirectorySet(evt);}, false); | ||
104 | this.eventManager.addEventListener("newFileNameSet", function(evt){that.handleNewFileNameSet(evt);}, false); | ||
105 | |||
106 | this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); | ||
107 | this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); | ||
108 | |||
109 | if(!!this.newFileModel.defaultProjectType){ | 101 | if(!!this.newFileModel.defaultProjectType){ |
110 | var templates = this.newFileModel.prepareContents(this.newFileModel.defaultProjectType); | 102 | var templates = this.newFileModel.prepareContents(this.newFileModel.defaultProjectType); |
111 | this.templateList = iconsListModule.IconsList.create(); | 103 | this.templateList = iconsListModule.IconsList.create(); |
@@ -116,7 +108,6 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
116 | this.templateList.element = this.templateIcons; | 108 | this.templateList.element = this.templateIcons; |
117 | this.templateList.needsDraw = true; | 109 | this.templateList.needsDraw = true; |
118 | 110 | ||
119 | |||
120 | this.selectedProjectType = {"uri":this.newFileModel.defaultProjectType, "element":null}; | 111 | this.selectedProjectType = {"uri":this.newFileModel.defaultProjectType, "element":null}; |
121 | } | 112 | } |
122 | 113 | ||
@@ -127,6 +118,33 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
127 | fileExtensionEl.innerHTML = ""+this.newFileModel.projectTypeData[this.newFileModel.defaultProjectType].fileExtension; | 118 | fileExtensionEl.innerHTML = ""+this.newFileModel.projectTypeData[this.newFileModel.defaultProjectType].fileExtension; |
128 | } | 119 | } |
129 | } | 120 | } |
121 | |||
122 | this.element.addEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false); | ||
123 | this.element.addEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only | ||
124 | this.eventManager.addEventListener("newFileDirectorySet", function(evt){ | ||
125 | that.handleNewFileDirectorySet(evt); | ||
126 | }, false); | ||
127 | this.eventManager.addEventListener("newFileNameSet", function(evt){ | ||
128 | that.handleNewFileNameSet(evt); | ||
129 | }, false); | ||
130 | |||
131 | this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); | ||
132 | this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); | ||
133 | |||
134 | this.element.addEventListener("keyup", function(evt){ | ||
135 | if(evt.keyCode == 27) {//ESC key | ||
136 | if(that.application.ninja.newFileController.newFileOptionsNav !== null){ | ||
137 | that.handleCancelButtonAction(); | ||
138 | } | ||
139 | }else if((evt.keyCode == 13) && !(evt.ctrlKey || evt.metaKey)){//ENTER key | ||
140 | if((that.application.ninja.newFileController.newFileOptionsNav !== null) | ||
141 | && !that.okButton.hasAttribute("disabled")){ | ||
142 | |||
143 | that.handleOkButtonAction(); | ||
144 | } | ||
145 | } | ||
146 | }, true); | ||
147 | |||
130 | } | 148 | } |
131 | 149 | ||
132 | }, | 150 | }, |
@@ -291,10 +309,16 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
291 | }else{ | 309 | }else{ |
292 | if(this.error.innerHTML === ""){ | 310 | if(this.error.innerHTML === ""){ |
293 | this.showError("! Project Template, Name and Directory should be valid."); | 311 | this.showError("! Project Template, Name and Directory should be valid."); |
294 | } | 312 | //disable ok |
295 | //disable ok | 313 | if(!this.okButton.hasAttribute("disabled")){ |
296 | if(!this.okButton.hasAttribute("disabled")){ | 314 | this.okButton.setAttribute("disabled", "true"); |
297 | this.okButton.setAttribute("disabled", "true"); | 315 | } |
316 | }else if(!this.selectedProjectType || !this.selectedTemplate){ | ||
317 | this.showError("! Project Template should be selected."); | ||
318 | //disable ok | ||
319 | if(!this.okButton.hasAttribute("disabled")){ | ||
320 | this.okButton.setAttribute("disabled", "true"); | ||
321 | } | ||
298 | } | 322 | } |
299 | } | 323 | } |
300 | } | 324 | } |
@@ -302,7 +326,12 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
302 | 326 | ||
303 | handleNewFileDirectorySet:{ | 327 | handleNewFileDirectorySet:{ |
304 | value:function(evt){ | 328 | value:function(evt){ |
305 | if(!!evt._event.newFileDirectory){ | 329 | if(evt.keyCode === 13){ |
330 | if(!this.okButton.hasAttribute("disabled")) this.handleOkButtonAction(evt); | ||
331 | }else if(evt.keyCode === 27){ | ||
332 | this.handleCancelButtonAction(evt); | ||
333 | } | ||
334 | else if(!!evt._event.newFileDirectory){ | ||
306 | this.newFileDirectory = evt._event.newFileDirectory; | 335 | this.newFileDirectory = evt._event.newFileDirectory; |
307 | if(this.isValidUri(this.newFileDirectory)){ | 336 | if(this.isValidUri(this.newFileDirectory)){ |
308 | this.enableOk(); | 337 | this.enableOk(); |
@@ -313,7 +342,12 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
313 | 342 | ||
314 | handleNewFileNameSet:{ | 343 | handleNewFileNameSet:{ |
315 | value:function(evt){ | 344 | value:function(evt){ |
316 | if(!!evt._event.newFileName){ | 345 | if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ |
346 | this.handleOkButtonAction(evt); | ||
347 | }else if(evt.keyCode === 27){ | ||
348 | this.handleCancelButtonAction(evt); | ||
349 | } | ||
350 | else if(!!evt._event.newFileName){ | ||
317 | this.newFileName = evt._event.newFileName; | 351 | this.newFileName = evt._event.newFileName; |
318 | if(this.isValidFileName(this.newFileName)){ | 352 | if(this.isValidFileName(this.newFileName)){ |
319 | this.enableOk(); | 353 | this.enableOk(); |
@@ -374,14 +408,14 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
374 | 408 | ||
375 | this.newFileName = ""; | 409 | this.newFileName = ""; |
376 | this.newFileDirectory = ""; | 410 | this.newFileDirectory = ""; |
377 | this.selectedProjectType = null; | ||
378 | this.selectedTemplate = null; | ||
379 | 411 | ||
380 | //remove event listeners | 412 | //remove event listeners |
381 | this.element.removeEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false); | 413 | this.element.removeEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false); |
382 | this.element.removeEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only | 414 | this.element.removeEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only |
383 | this.eventManager.removeEventListener("newFileDirectorySet", function(evt){that.handleNewFileDirectorySet(evt);}, false); | 415 | this.eventManager.removeEventListener("newFileDirectorySet", function(evt){that.handleNewFileDirectorySet(evt);}, false); |
384 | this.eventManager.removeEventListener("newFileNameSet", function(evt){that.handleNewFileNameSet(evt);}, false); | 416 | this.eventManager.removeEventListener("newFileNameSet", function(evt){that.handleNewFileNameSet(evt);}, false); |
417 | |||
418 | this.application.ninja.newFileController.newFileOptionsNav = null; | ||
385 | } | 419 | } |
386 | }, |