aboutsummaryrefslogtreecommitdiff
path: root/js/components/ui/FilePicker/pickerNavigator.reel
diff options
context:
space:
mode:
authorJose Antonio Marquez Russo2012-02-10 11:12:25 -0800
committerJose Antonio Marquez Russo2012-02-10 11:12:25 -0800
commit13b98b96ab36da5029204aa2a35d0d646d471274 (patch)
tree477ee2ae9ff0c81f269da4b34e03f2983f1edae1 /js/components/ui/FilePicker/pickerNavigator.reel
parentfbe830fabe497d01f4f2eaddb867161a8187c101 (diff)
parent8c40940f030adb74f534c3c5ad8d845e41f09b30 (diff)
downloadninja-13b98b96ab36da5029204aa2a35d0d646d471274.tar.gz
Merge pull request #6 from ananyasen/FileIO
Open file fixes and adding opening in code view.
Diffstat (limited to 'js/components/ui/FilePicker/pickerNavigator.reel')
-rw-r--r--js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js37
1 files changed, 18 insertions, 19 deletions
diff --git a/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js b/js/components/ui/FilePicker/pickerNavigator.reel/pickerNavigator.js
index d7a19c14..ff9c7073 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, {
@@ -335,7 +334,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
335 temp = temp.substring(0, temp.lastIndexOf("/")); 334 temp = temp.substring(0, temp.lastIndexOf("/"));
336 335
337 //populate dropdown irrespective of validity 336 //populate dropdown irrespective of validity
338// if(!!filePickerControllerModule.FilePickerController._directoryContentCache[temp]){//check if it is a valid location 337// if(!!this.application.ninja.filePickerController._directoryContentCache[temp]){//check if it is a valid location
339// arr.push(temp); 338// arr.push(temp);
340// }else{ 339// }else{
341// break; 340// break;
@@ -358,7 +357,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
358 value:function(element, uri){ 357 value:function(element, uri){
359 if(!!element){ 358 if(!!element){
360 var tree = treeModule.Tree.create(); 359 var tree = treeModule.Tree.create();
361 tree.treeViewDataObject = filePickerControllerModule.FilePickerController.prepareContentList(uri, this.pickerModel); 360 tree.treeViewDataObject = this.application.ninja.filePickerController.prepareContentList(uri, this.pickerModel);
362 //console.log("renderTree() for "+ uri); 361 //console.log("renderTree() for "+ uri);
363 //console.log(tree.treeViewDataObject); 362 //console.log(tree.treeViewDataObject);
364 tree.element = element; 363 tree.element = element;
@@ -374,10 +373,10 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
374 var status = true; 373 var status = true;
375 var iconViewContainer = this.element.querySelector(".iconViewContainer"); 374 var iconViewContainer = this.element.querySelector(".iconViewContainer");
376 if((typeof fromCache === 'undefined') || (fromCache === true)){ 375 if((typeof fromCache === 'undefined') || (fromCache === true)){
377 this.newContent = filePickerControllerModule.FilePickerController.prepareContentList(uri, this.pickerModel); 376 this.newContent = this.application.ninja.filePickerController.prepareContentList(uri, this.pickerModel);
378 } 377 }
379 else{ 378 else{
380 this.newContent = filePickerControllerModule.FilePickerController.prepareContentList(uri, this.pickerModel, false); 379 this.newContent = this.application.ninja.filePickerController.prepareContentList(uri, this.pickerModel, false);
381 } 380 }
382 if(!!this.newContent && this.newContent.length > 0){ 381 if(!!this.newContent && this.newContent.length > 0){
383 //clear selection 382 //clear selection
@@ -423,10 +422,10 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
423 if(!!treeViewContainer){ 422 if(!!treeViewContainer){
424 var data = []; 423 var data = [];
425 if((typeof fromCache === 'undefined') || (fromCache === true)){ 424 if((typeof fromCache === 'undefined') || (fromCache === true)){
426 data = filePickerControllerModule.FilePickerController.prepareContentList(uri, this.pickerModel); 425 data = this.application.ninja.filePickerController.prepareContentList(uri, this.pickerModel);
427 } 426 }
428 else{ 427 else{
429 data = filePickerControllerModule.FilePickerController.prepareContentList(uri, this.pickerModel, false); 428 data = this.application.ninja.filePickerController.prepareContentList(uri, this.pickerModel, false);
430 } 429 }
431 430
432 if(data.length > 0){ 431 if(data.length > 0){
@@ -475,7 +474,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
475 enumerable: false, 474 enumerable: false,
476 writable:false, 475 writable:false,
477 value:function(currentUri){ 476 value:function(currentUri){
478 var data = filePickerControllerModule.FilePickerController._directoryContentCache[currentUri]; 477 var data = this.application.ninja.filePickerController._directoryContentCache[currentUri];
479 var metadata = ""; 478 var metadata = "";
480 if(!!data){ 479 if(!!data){
481 if(data.name !== ""){ 480 if(data.name !== ""){
@@ -610,8 +609,8 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
610 this.currentSelectedNode = null; 609 this.currentSelectedNode = null;
611 } 610 }
612 //enable OK button if the selection is valid as per the picker mode 611 //enable OK button if the selection is valid as per the picker mode
613 if((this.pickerModel.inFileMode && (filePickerControllerModule.FilePickerController._directoryContentCache[uri].type === "file")) 612 if((this.pickerModel.inFileMode && (this.application.ninja.filePickerController._directoryContentCache[uri].type === "file"))
614 || (!this.pickerModel.inFileMode && (filePickerControllerModule.FilePickerController._directoryContentCache[uri].type === "directory"))){ 613 || (!this.pickerModel.inFileMode && (this.application.ninja.filePickerController._directoryContentCache[uri].type === "directory"))){
615 this.okButton.removeAttribute("disabled"); 614 this.okButton.removeAttribute("disabled");
616 615
617 //put into selectedItems..currently single selection is supported 616 //put into selectedItems..currently single selection is supported
@@ -784,9 +783,9 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
784 value: function(evt){ 783 value: function(evt){
785 console.log("$$$ File Picker : selected "+ this.selectedItems.toString()); 784 console.log("$$$ File Picker : selected "+ this.selectedItems.toString());
786 var success = true; 785 var success = true;
787 if(!!this.pickerModel.callback && !!this.pickerModel.callbackScope && (this.selectedItems.length > 0)){//call the callback if it is available 786 if(!!this.pickerModel.callback && (this.selectedItems.length > 0)){//call the callback if it is available
788 try{ 787 try{
789 this.pickerModel.callback.call(this.pickerModel.callbackScope, {"uri":this.selectedItems}); 788 this.pickerModel.callback({"uri":this.selectedItems});
790 }catch(e){ 789 }catch(e){
791 success = false; 790 success = false;
792 console.log("[Error] Failed to open "+ this.selectedItems.toString()); 791 console.log("[Error] Failed to open "+ this.selectedItems.toString());
@@ -803,12 +802,12 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
803 var dataStore = window.sessionStorage; 802 var dataStore = window.sessionStorage;
804 try { 803 try {
805 if(this.pickerModel.pickerMode === "write"){ 804 if(this.pickerModel.pickerMode === "write"){
806 filePickerControllerModule.FilePickerController._lastSavedFolderURI.lastSavedFolderUri_local = this.currentURI;
807 dataStore.setItem('lastSavedFolderURI',escape(""+this.currentURI)); 805 dataStore.setItem('lastSavedFolderURI',escape(""+this.currentURI));
808 } 806 }
809 else{ 807 else if(this.pickerModel.inFileMode === true){
810 filePickerControllerModule.FilePickerController._lastOpenedFolderURI.lastFolderUri_local = this.currentURI; 808 dataStore.setItem('lastOpenedFolderURI_fileSelection',escape(""+this.currentURI));
811 dataStore.setItem('lastOpenedFolderURI',escape(""+this.currentURI)); 809 }else if(this.pickerModel.inFileMode === false){
810 dataStore.setItem('lastOpenedFolderURI_folderSelection',escape(""+this.currentURI));
812 } 811 }
813 } 812 }
814 catch(e){ 813 catch(e){
@@ -962,9 +961,9 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
962 961
963 handlePickerNavRefreshTreeSegment:{ 962 handlePickerNavRefreshTreeSegment:{
964 value: function(evt){ 963 value: function(evt){
965// if(filePickerControllerModule.FilePickerController.checkIfStale(evt.uri)){ 964// if(this.application.ninja.filePickerController.checkIfStale(evt.uri)){
966// //update tree segment if was stale 965// //update tree segment if was stale
967// evt.treeSegment.treeViewDataObject = filePickerControllerModule.FilePickerController.prepareContentList(evt.uri, this.pickerModel, true, false); 966// evt.treeSegment.treeViewDataObject = this.application.ninja.filePickerController.prepareContentList(evt.uri, this.pickerModel, true, false);
968// } 967// }
969 } 968 }
970 }, 969 },
@@ -1007,7 +1006,7 @@ var PickerNavigator = exports.PickerNavigator = Montage.create(Component, {
1007 value:function(){ 1006 value:function(){
1008 //clear memory - TODO:check for more memory leaks 1007 //clear memory - TODO:check for more memory leaks
1009 this.pickerModel = null; 1008 this.pickerModel = null;
1010 filePickerControllerModule.FilePickerController._directoryContentCache = {}; 1009 this.application.ninja.filePickerController._directoryContentCache = {};
1011 //remove listeners 1010 //remove listeners
1012 this.element.removeEventListener("openFolder", this, false);//add icon double click event listener to reload iconList with new set of data 1011 this.element.removeEventListener("openFolder", this, false);//add icon double click event listener to reload iconList with new set of data
1013 this.element.removeEventListener("selectedItem", this, false);//for single selection only 1012 this.element.removeEventListener("selectedItem", this, false);//for single selection only