diff options
author | Nivesh Rajbhandari | 2012-04-16 16:06:24 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-04-16 16:06:24 -0700 |
commit | c253192a08b499ea7be46fa5438d273e51f7ec5a (patch) | |
tree | 18a1f0e3679c0eb993a9dedb537035d3861f49ac /js/io/ui/file-picker | |
parent | e19376c54eedd1f1c457ba405b2f110be376a559 (diff) | |
parent | 4b900ea5cd6bb77eb30cec8c03b9ec9fa662c1e9 (diff) | |
download | ninja-c253192a08b499ea7be46fa5438d273e51f7ec5a.tar.gz |
Merge branch 'refs/heads/ninja-internal' into WebGLFixes
Diffstat (limited to 'js/io/ui/file-picker')
4 files changed, 51 insertions, 19 deletions
diff --git a/js/io/ui/file-picker/file-input-field.reel/file-input-field.html b/js/io/ui/file-picker/file-input-field.reel/file-input-field.html index 2fcaa075..00df1c11 100755 --- a/js/io/ui/file-picker/file-input-field.reel/file-input-field.html +++ b/js/io/ui/file-picker/file-input-field.reel/file-input-field.html | |||
@@ -10,13 +10,21 @@ | |||
10 | <link rel="stylesheet" type="text/css" href="file-input-field.css"> | 10 | <link rel="stylesheet" type="text/css" href="file-input-field.css"> |
11 | <script type="text/montage-serialization"> | 11 | <script type="text/montage-serialization"> |
12 | { | 12 | { |
13 | |||
14 | "newFileDirectory": { | ||
15 | "prototype": "montage/ui/textfield.reel", | ||
16 | "properties": { | ||
17 | "element": {"#": "newFileDirectory"} | ||
18 | } | ||
19 | }, | ||
20 | |||
13 | "owner":{ | 21 | "owner":{ |
14 | "module": "js/io/ui/file-picker/file-input-field.reel", | 22 | "module": "js/io/ui/file-picker/file-input-field.reel", |
15 | "name": "FileInputField", | 23 | "name": "FileInputField", |
16 | "properties": { | 24 | "properties": { |
17 | "element": {"#": "fileInputField"}, | 25 | "element": {"#": "fileInputField"}, |
18 | "findDirectory": {"#": "findDirectory"}, | 26 | "findDirectory": {"#": "findDirectory"}, |
19 | "newFileDirectory": {"#": "newFileDirectory"} | 27 | "newFileDirectory": {"@": "newFileDirectory"} |
20 | } | 28 | } |
21 | } | 29 | } |
22 | } | 30 | } |
diff --git a/js/io/ui/file-picker/file-input-field.reel/file-input-field.js b/js/io/ui/file-picker/file-input-field.reel/file-input-field.js index 651fd7fa..9e77759f 100755 --- a/js/io/ui/file-picker/file-input-field.reel/file-input-field.js +++ b/js/io/ui/file-picker/file-input-field.reel/file-input-field.js | |||
@@ -14,12 +14,10 @@ var FileInputField = exports.FileInputField = Montage.create(Component, { | |||
14 | value: function() { | 14 | value: function() { |
15 | var that = this; | 15 | var that = this; |
16 | this.findDirectory.identifier = "findDirectory"; | 16 | this.findDirectory.identifier = "findDirectory"; |
17 | |||
18 | this.findDirectory.addEventListener("click", this, false); | 17 | this.findDirectory.addEventListener("click", this, false); |
19 | 18 | this.eventManager.addEventListener("pickerSelectionsDone", this.handleFileInputPickerSelectionsDone, false); | |
20 | this.eventManager.addEventListener("pickerSelectionsDone", function(evt){that.handleFileInputPickerSelectionsDone(evt);}, false); | 19 | this.addEventListener("change@newFileDirectory.value", this.handleNewFileDirectoryChange, false); |
21 | 20 | this.newFileDirectory.element.addEventListener("keyup", this, false); | |
22 | this.newFileDirectory.addEventListener("keyup", function(evt){that.handleNewFileDirectoryOnkeyup(evt);}, false); | ||
23 | } | 21 | } |
24 | }, | 22 | }, |
25 | 23 | ||
@@ -63,17 +61,31 @@ var FileInputField = exports.FileInputField = Montage.create(Component, { | |||
63 | } | 61 | } |
64 | }, | 62 | }, |
65 | 63 | ||
66 | handleNewFileDirectoryOnkeyup:{ | 64 | handleNewFileDirectoryChange:{ |
67 | value:function(evt){ | 65 | value:function(evt){ |
68 | if(this.newFileDirectory.value !== ""){ | 66 | var newFileDirectorySetEvent = document.createEvent("Events"); |
69 | var newFileDirectorySetEvent = document.createEvent("Events"); | 67 | newFileDirectorySetEvent.initEvent("newFileDirectorySet", false, false); |
70 | newFileDirectorySetEvent.initEvent("newFileDirectorySet", false, false); | 68 | newFileDirectorySetEvent.newFileDirectory = this.newFileDirectory.value; |
71 | newFileDirectorySetEvent.newFileDirectory = this.newFileDirectory.value; | 69 | newFileDirectorySetEvent.keyCode = evt.keyCode; |
72 | this.eventManager.dispatchEvent(newFileDirectorySetEvent); | 70 | this.eventManager.dispatchEvent(newFileDirectorySetEvent); |
73 | } | ||
74 | } | 71 | } |
75 | }, | 72 | }, |
76 | 73 | ||
74 | |||
75 | handleKeyup:{ | ||
76 | value: function(evt){ | ||
77 | if(evt.keyCode === 13){ | ||
78 | var enterKeyupEvent = document.createEvent("Events"); | ||
79 | enterKeyupEvent.initEvent("enterKey", false, false); | ||
80 | this.eventManager.dispatchEvent(enterKeyupEvent); | ||
81 | }else if(evt.keyCode === 27){ | ||
82 | var escKeyupEvent = document.createEvent("Events"); | ||
83 | escKeyupEvent.initEvent("escKey", false, false); | ||
84 | this.eventManager.dispatchEvent(escKeyupEvent); | ||
85 | } | ||
86 | } | ||
87 | }, | ||
88 | |||
77 | handleFileInputPickerSelectionsDone:{ | 89 | handleFileInputPickerSelectionsDone:{ |
78 | value: function(evt){ | 90 | value: function(evt){ |
79 | var selectedUri = ""; | 91 | var selectedUri = ""; |
@@ -95,7 +107,7 @@ var FileInputField = exports.FileInputField = Montage.create(Component, { | |||
95 | if(!!obj && obj.uri && obj.uri.length > 0){ | 107 | if(!!obj && obj.uri && obj.uri.length > 0){ |
96 | selectedUri = obj.uri[0]; | 108 | selectedUri = obj.uri[0]; |
97 | this.newFileDirectory.value = selectedUri; | 109 | this.newFileDirectory.value = selectedUri; |
98 | 110 | this.newFileDirectory.element.focus(); | |
99 | var newFileDirectorySetEvent = document.createEvent("Events"); | 111 | var newFileDirectorySetEvent = document.createEvent("Events"); |
100 | newFileDirectorySetEvent.initEvent("newFileDirectorySet", false, false); | 112 | newFileDirectorySetEvent.initEvent("newFileDirectorySet", false, false); |
101 | newFileDirectorySetEvent.newFileDirectory = this.newFileDirectory.value; | 113 | newFileDirectorySetEvent.newFileDirectory = this.newFileDirectory.value; |
diff --git a/js/io/ui/file-picker/file-picker-controller.js b/js/io/ui/file-picker/file-picker-controller.js index 105dc223..436a50f3 100755 --- a/js/io/ui/file-picker/file-picker-controller.js +++ b/js/io/ui/file-picker/file-picker-controller.js | |||
@@ -23,6 +23,11 @@ var FilePickerController = exports.FilePickerController = Montage.create(require | |||
23 | } | 23 | } |
24 | }, | 24 | }, |
25 | 25 | ||
26 | pickerNavChoices:{ | ||
27 | enumerable: true, | ||
28 | value: null | ||
29 | }, | ||
30 | |||
26 | filePickerPopupType:{ | 31 | filePickerPopupType:{ |
27 | enumerable: false, | 32 | enumerable: false, |
28 | value: "filePicker" | 33 | value: "filePicker" |
@@ -125,8 +130,6 @@ var FilePickerController = exports.FilePickerController = Montage.create(require | |||
125 | } | 130 | } |
126 | 131 | ||
127 | if(!!storedUri){ | 132 | if(!!storedUri){ |
128 | // This is depracated -- use decodeURI instead | ||
129 | //aModel.currentRoot = unescape(storedUri); | ||
130 | aModel.currentRoot = decodeURI(storedUri); | 133 | aModel.currentRoot = decodeURI(storedUri); |
131 | } | 134 | } |
132 | 135 | ||
@@ -149,7 +152,7 @@ var FilePickerController = exports.FilePickerController = Montage.create(require | |||
149 | writable:false, | 152 | writable:false, |
150 | enumerable:true, | 153 | enumerable:true, |
151 | value:function(callback, aModel){ | 154 | value:function(callback, aModel){ |
152 | var pickerNavChoices = Montage.create(pickerNavigatorReel); | 155 | var pickerNavChoices = this.pickerNavChoices = Montage.create(pickerNavigatorReel); |
153 | var initUri = aModel.currentRoot; | 156 | var initUri = aModel.currentRoot; |
154 | 157 | ||
155 | //remove extra / at the end | 158 | //remove extra / at the end |
diff --git a/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js b/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js index 7a9d90b4..945b0301 100644 --- a/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js +++ b/js/io/ui/file-picker/picker-navigator.reel/picker-navigator.js | |||
@@ -258,12 +258,20 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { | |||
258 | this.element.addEventListener("refreshTreeSegment", function(evt){that.handlePickerNavRefreshTreeSegment(evt);}, false); | 258 | this.element.addEventListener("refreshTreeSegment", function(evt){that.handlePickerNavRefreshTreeSegment(evt);}, false); |
259 | this.resultsArea.addEventListener("click", function(evt){that.handleResultsAreaClick(evt);}, false); | 259 | this.resultsArea.addEventListener("click", function(evt){that.handleResultsAreaClick(evt);}, false); |
260 | this.element.addEventListener("click", function(evt){that.handlePickerNavClick(evt);}, false); | 260 | this.element.addEventListener("click", function(evt){that.handlePickerNavClick(evt);}, false); |
261 | |||
262 | this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); | 261 | this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); |
263 | this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); | 262 | this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); |
264 | 263 | ||
264 | this.element.addEventListener("keyup", function(evt){ | ||
265 | if(evt.keyCode == 27) { | ||
266 | if(that.application.ninja.filePickerController.pickerNavChoices !== null){ | ||
267 | that.handleCancelButtonAction(); | ||
268 | } | ||
269 | } | ||
270 | }, true); | ||
271 | |||
265 | //ready to show picker now | 272 | //ready to show picker now |
266 | this.element.style.visibility = "visible"; | 273 | this.element.style.visibility = "visible"; |
274 | this.element.focus(); | ||
267 | } | 275 | } |
268 | }, | 276 | }, |
269 | 277 | ||
@@ -501,7 +509,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { | |||
501 | metadata = "Name: "+data.name; | 509 | metadata = "Name: "+data.name; |
502 | } | 510 | } |
503 | metadata = metadata + "<br />" + "Type: "+data.type; | 511 | metadata = metadata + "<br />" + "Type: "+data.type; |
504 | if(data.size){metadata = metadata + "<br />" + "Size: "+data.size;} | 512 | if(data.size){metadata = metadata + "<br />" + "Size: "+data.size+" bytes";} |
505 | if(data.creationDate){metadata = metadata + "<br />" + "Creation date: "+ this.formatTimestamp(data.creationDate);} | 513 | if(data.creationDate){metadata = metadata + "<br />" + "Creation date: "+ this.formatTimestamp(data.creationDate);} |
506 | if(data.modifiedDate){metadata = metadata + "<br />" + "Modified date: "+ this.formatTimestamp(data.modifiedDate);} | 514 | if(data.modifiedDate){metadata = metadata + "<br />" + "Modified date: "+ this.formatTimestamp(data.modifiedDate);} |
507 | } | 515 | } |
@@ -1071,6 +1079,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { | |||
1071 | //clear memory - TODO:check for more memory leaks | 1079 | //clear memory - TODO:check for more memory leaks |
1072 | this.pickerModel = null; | 1080 | this.pickerModel = null; |
1073 | this.application.ninja.filePickerController._directoryContentCache = {}; | 1081 | this.application.ninja.filePickerController._directoryContentCache = {}; |
1082 | this.application.ninja.filePickerController.pickerNavChoices = null; | ||
1074 | //remove listeners | 1083 | //remove listeners |
1075 |