aboutsummaryrefslogtreecommitdiff
path: root/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js')
-rw-r--r--js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js123
1 files changed, 73 insertions, 50 deletions
diff --git a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js
index 299d44f5..6b0d92f7 100644
--- a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js
+++ b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js
@@ -7,7 +7,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
7var Montage = require("montage/core/core").Montage, 7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component, 8 Component = require("montage/ui/component").Component,
9 iconsListModule = require("js/components/ui/icon-list-basic/iconsList.reel"), 9 iconsListModule = require("js/components/ui/icon-list-basic/iconsList.reel"),
10 filePickerControllerModule = require("js/components/ui/FilePicker/file-picker-controller"),
11 treeModule = require("js/components/ui/tree-basic/tree.reel"); 10 treeModule = require("js/components/ui/tree-basic/tree.reel");
12 11
13var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { 12var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
@@ -150,6 +149,12 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
150 leftNav.appendChild(newDiv); 149 leftNav.appendChild(newDiv);
151 if(dirObj.uri === this.pickerModel.currentRoot){ 150 if(dirObj.uri === this.pickerModel.currentRoot){
152 newDiv.classList.add("highlighted"); 151 newDiv.classList.add("highlighted");
152 //enable ok for logical drive selections, when in directory selection mode
153 if(this.pickerModel.inFileMode === false){
154 this.okButton.removeAttribute("disabled");
155 //put into selectedItems..currently single selection is supported
156 this.selectedItems = [dirObj.uri];
157 }
153 } 158 }
154 159
155 newDiv.addEventListener("click", function(evt){that.handleTopLevelDirectoryClicks(evt, dirObj);}, false); 160 newDiv.addEventListener("click", function(evt){that.handleTopLevelDirectoryClicks(evt, dirObj);}, false);
@@ -209,26 +214,27 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
209 this.refreshButton.addEventListener("click", this, false);//refresh - gets from file system directly 214 this.refreshButton.addEventListener("click", this, false);//refresh - gets from file system directly
210 this.backArrow.addEventListener("click", this, false); 215 this.backArrow.addEventListener("click", this, false);
211 this.forwardArrow.addEventListener("click", this, false); 216 this.forwardArrow.addEventListener("click", this, false);
212 this.okButton.addEventListener("click", this, false);
213 this.cancelButton.addEventListener("click", this, false);
214
215 //populate filters
216 var filtersDD = this.element.querySelector(".filters .dropdown");
217 if(!!this.pickerModel.fileFilters
218 && (typeof this.pickerModel.fileFilters === "object")
219 && ('splice' in this.pickerModel.fileFilters)
220 && ('join' in this.pickerModel.fileFilters)){
221 this.pickerModel.fileFilters.forEach(function(aFilter){
222 var newDiv = document.createElement("div");
223 newDiv.innerHTML = aFilter;
224 filtersDD.appendChild(newDiv);
225 newDiv.addEventListener("click", function(evt){that.handleFilterClick(evt, aFilter, filtersDD)}, false);
226 }, this);
227 }
228 217
229 var renderedWidth = this.getComputedWidth(filtersDD); 218 //populate filters if in file selection mode
230 this.filters.style.width = "" + (parseInt((renderedWidth.substring(0, (renderedWidth.length - 2)))) + 20) + "px"; 219 if(this.pickerModel.inFileMode === true){
220 var filtersDD = this.element.querySelector(".filters .dropdown");
221 if(!!this.pickerModel.fileFilters
222 && (typeof this.pickerModel.fileFilters === "object")
223 && ('splice' in this.pickerModel.fileFilters)
224 && ('join' in this.pickerModel.fileFilters)){
225 this.pickerModel.fileFilters.forEach(function(aFilter){
226 var newDiv = document.createElement("div");
227 newDiv.innerHTML = aFilter;
228 filtersDD.appendChild(newDiv);
229 newDiv.addEventListener("click", function(evt){that.handleFilterClick(evt, aFilter, filtersDD)}, false);
230 }, this);
231 }
231 232
233 var renderedWidth = this.getComputedWidth(filtersDD);
234 this.filters.style.width = "" + (parseInt((renderedWidth.substring(0, (renderedWidth.length - 2)))) + 20) + "px";
235 }else{
236 this.filters.style.display = "none";
237 }
232 /** 238 /**
233 * attach click event listeners to the addressbar dropdown arrows 239 * attach click event listeners to the addressbar dropdown arrows
234 */ 240 */
@@ -244,6 +250,9 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
244 this.resultsArea.addEventListener("click", function(evt){that.handleResultsAreaClick(evt);}, false); 250 this.resultsArea.addEventListener("click", function(evt){that.handleResultsAreaClick(evt);}, false);
245 this.element.addEventListener("click", function(evt){that.handlePickerNavClick(evt);}, false); 251 this.element.addEventListener("click", function(evt){that.handlePickerNavClick(evt);}, false);
246 252
253 this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false);
254 this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false);
255
247 //ready to show picker now 256 //ready to show picker now
248 this.element.style.visibility = "visible"; 257 this.element.style.visibility = "visible";
249 } 258 }
@@ -263,11 +272,11 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
263 } 272 }
264 }, 273 },
265 274
266 //TODO: add uri pattern validation 275 cleanupUri:{
267 validateUri:{
268 writable: false, 276 writable: false,
269 enumerable:true, 277 enumerable:true,
270 value: function(folderUri){ 278 value: function(folderUri){
279 folderUri = folderUri.replace(/^\s+|\s+$/g,""); // strip any leading or trailing spaces
271 //remove unnecessary / from end - for Win and Mac .... don't trim for the root 280 //remove unnecessary / from end - for Win and Mac .... don't trim for the root
272 if(((folderUri.charAt(folderUri.length - 1) === "/") || (folderUri.charAt(folderUri.length - 1) === "\\")) && (folderUri !== "/")){ 281 if(((folderUri.charAt(folderUri.length - 1) === "/") || (folderUri.charAt(folderUri.length - 1) === "\\")) && (folderUri !== "/")){
273 folderUri = folderUri.substring(0, (folderUri.length - 1)); 282 folderUri = folderUri.substring(0, (folderUri.length - 1));
@@ -324,14 +333,14 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
324 writable:false, 333 writable:false,
325 enumerable:true, 334 enumerable:true,
326 value:function(uri){ 335 value:function(uri){
327 uri = this.validateUri(uri); 336 uri = this.cleanupUri(uri);
328 var arr = []; 337 var arr = [];
329 var temp = new String(uri); 338 var temp = new String(uri);
330 while(temp.indexOf("/") != -1){ 339 while(temp.indexOf("/") != -1){
331 temp = temp.substring(0, temp.lastIndexOf("/")); 340 temp = temp.substring(0, temp.lastIndexOf("/"));
332 341
333 //populate dropdown irrespective of validity 342 //populate dropdown irrespective of validity
334// if(!!filePickerControllerModule.FilePickerController._directoryContentCache[temp]){//check if it is a valid location 343// if(!!this.application.ninja.filePickerController._directoryContentCache[temp]){//check if it is a valid location
335// arr.push(temp); 344// arr.push(temp);
336// }else{ 345// }else{
337// break; 346// break;
@@ -354,7 +363,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
354 value:function(element, uri){ 363 value:function(element, uri){
355 if(!!element){ 364 if(!!element){
356 var tree = treeModule.Tree.create(); 365 var tree = treeModule.Tree.create();
357 tree.treeViewDataObject = filePickerControllerModule.FilePickerController.prepareContentList(uri, this.pickerModel); 366 tree.treeViewDataObject = this.application.ninja.filePickerController.prepareContentList(uri, this.pickerModel);
358 //console.log("renderTree() for "+ uri); 367 //console.log("renderTree() for "+ uri);
359 //console.log(tree.treeViewDataObject); 368 //console.log(tree.treeViewDataObject);
360 tree.element = element; 369 tree.element = element;
@@ -370,10 +379,10 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
370 var status = true; 379 var status = true;
371 var iconViewContainer = this.element.querySelector(".iconViewContainer"); 380 var iconViewContainer = this.element.querySelector(".iconViewContainer");
372 if((typeof fromCache === 'undefined') || (fromCache === true)){ 381 if((typeof fromCache === 'undefined') || (fromCache === true)){
373 this.newContent = filePickerControllerModule.FilePickerController.prepareContentList(uri, this.pickerModel); 382 this.newContent = this.application.ninja.filePickerController.prepareContentList(uri, this.pickerModel);
374 } 383 }
375 else{ 384 else{
376 this.newContent = filePickerControllerModule.FilePickerController.prepareContentList(uri, this.pickerModel, false); 385 this.newContent = this.application.ninja.filePickerController.prepareContentList(uri, this.pickerModel, false);
377 } 386 }
378 if(!!this.newContent && this.newContent.length > 0){ 387 if(!!this.newContent && this.newContent.length > 0){
379 //clear selection 388 //clear selection
@@ -419,10 +428,10 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
419 if(!!treeViewContainer){ 428 if(!!treeViewContainer){
420 var data = []; 429 var data = [];
421 if((typeof fromCache === 'undefined') || (fromCache === true)){ 430 if((typeof fromCache === 'undefined') || (fromCache === true)){
422 data = filePickerControllerModule.FilePickerController.prepareContentList(uri, this.pickerModel); 431 data = this.application.ninja.filePickerController.prepareContentList(uri, this.pickerModel);
423 } 432 }
424 else{ 433 else{
425 data = filePickerControllerModule.FilePickerController.prepareContentList(uri, this.pickerModel, false); 434 data = this.application.ninja.filePickerController.prepareContentList(uri, this.pickerModel, false);
426 } 435 }
427 436
428 if(data.length > 0){ 437 if(data.length > 0){
@@ -471,7 +480,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
471 enumerable: false, 480 enumerable: false,
472 writable:false, 481 writable:false,
473 value:function(currentUri){ 482 value:function(currentUri){
474 var data = filePickerControllerModule.FilePickerController._directoryContentCache[currentUri]; 483 var data = this.application.ninja.filePickerController._directoryContentCache[currentUri];
475 var metadata = "";