diff options
author | Jose Antonio Marquez Russo | 2012-02-10 11:12:25 -0800 |
---|---|---|
committer | Jose Antonio Marquez Russo | 2012-02-10 11:12:25 -0800 |
commit | 13b98b96ab36da5029204aa2a35d0d646d471274 (patch) | |
tree | 477ee2ae9ff0c81f269da4b34e03f2983f1edae1 /js/components/ui | |
parent | fbe830fabe497d01f4f2eaddb867161a8187c101 (diff) | |
parent | 8c40940f030adb74f534c3c5ad8d845e41f09b30 (diff) | |
download | ninja-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')
3 files changed, 38 insertions, 52 deletions
diff --git a/js/components/ui/FilePicker/file-input-field.reel/file-input-field.js b/js/components/ui/FilePicker/file-input-field.reel/file-input-field.js index 8710de63..235be8ad 100755 --- a/js/components/ui/FilePicker/file-input-field.reel/file-input-field.js +++ b/js/components/ui/FilePicker/file-input-field.reel/file-input-field.js | |||
@@ -70,8 +70,7 @@ var FileInputField = exports.FileInputField = Montage.create(Component, { | |||
70 | settings.inFileMode = true; | 70 | settings.inFileMode = true; |
71 | settings.pickerName = this.pickerName || "fileSelector"; | 71 | settings.pickerName = this.pickerName || "fileSelector"; |
72 | } | 72 | } |
73 | settings.callback = this.filePickerCallback; | 73 | settings.callback = this.filePickerCallback.bind(this); |
74 | settings.callbackScope = this; | ||
75 | openFilePicker.settings = settings; | 74 | openFilePicker.settings = settings; |
76 | this.eventManager.dispatchEvent(openFilePicker); | 75 | this.eventManager.dispatchEvent(openFilePicker); |
77 | } | 76 | } |
diff --git a/js/components/ui/FilePicker/file-picker-controller.js b/js/components/ui/FilePicker/file-picker-controller.js index e71d1460..0ff20cc8 100755 --- a/js/components/ui/FilePicker/file-picker-controller.js +++ b/js/components/ui/FilePicker/file-picker-controller.js | |||
@@ -39,30 +39,6 @@ var FilePickerController = exports.FilePickerController = Montage.create(require | |||
39 | }, | 39 | }, |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * this will be stored in the local storage and in the cloud may be, for the cloud one. | ||
43 | */ | ||
44 | _lastOpenedFolderURI:{ | ||
45 | writable:true, | ||
46 | enumerable:true, | ||
47 | value:{ | ||
48 | lastFolderUri_local:null, | ||
49 | lastFolderUri_cloud:null | ||
50 | } | ||
51 | }, | ||
52 | |||
53 | /** | ||
54 | * this will be stored in the local storage and in the cloud may be, for the cloud one. | ||
55 | */ | ||
56 | _lastSavedFolderURI:{ | ||
57 | writable:true, | ||
58 | enumerable:true, | ||
59 | value:{ | ||
60 | lastSavedFolderUri_local:null, | ||
61 | lastSavedFolderUri_cloud:null | ||
62 | } | ||
63 | }, | ||
64 | |||
65 | /** | ||
66 | *this function is used to create an instance of a file picker | 42 | *this function is used to create an instance of a file picker |
67 | * | 43 | * |
68 | * parameters: | 44 | * parameters: |
@@ -87,7 +63,6 @@ var FilePickerController = exports.FilePickerController = Montage.create(require | |||
87 | var callback, callbackScope, pickerMode, currentFilter, allFileFilters, inFileMode, allowNewFileCreation, allowMultipleSelections, pickerName; | 63 | var callback, callbackScope, pickerMode, currentFilter, allFileFilters, inFileMode, allowNewFileCreation, allowMultipleSelections, pickerName; |
88 | if(!!settings){ | 64 | if(!!settings){ |
89 | if(typeof settings.callback !== "undefined"){callback = settings.callback;} | 65 | if(typeof settings.callback !== "undefined"){callback = settings.callback;} |
90 | if(typeof settings.callbackScope !== "undefined"){callbackScope = settings.callbackScope;} | ||
91 | if(typeof settings.pickerMode !== "undefined"){pickerMode = settings.pickerMode;} | 66 | if(typeof settings.pickerMode !== "undefined"){pickerMode = settings.pickerMode;} |
92 | if(typeof settings.currentFilter !== "undefined"){currentFilter = settings.currentFilter;} | 67 | if(typeof settings.currentFilter !== "undefined"){currentFilter = settings.currentFilter;} |
93 | if(typeof settings.allFileFilters !== "undefined"){allFileFilters = settings.allFileFilters;} | 68 | if(typeof settings.allFileFilters !== "undefined"){allFileFilters = settings.allFileFilters;} |
@@ -97,6 +72,12 @@ var FilePickerController = exports.FilePickerController = Montage.create(require | |||
97 | if(typeof settings.pickerName !== "undefined"){this.filePickerPopupType = settings.pickerName;} | 72 | if(typeof settings.pickerName !== "undefined"){this.filePickerPopupType = settings.pickerName;} |
98 | } | 73 | } |
99 | 74 | ||
75 | if(settings.pickerName === "saveAsDirectoryPicker"){//need to set the picker mode in a better way | ||
76 | pickerMode = "write"; | ||
77 | }else{ | ||
78 | pickerMode = "read"; | ||
79 | } | ||
80 | |||
100 | var aModel = filePickerModelModule.FilePickerModel.create(); | 81 | var aModel = filePickerModelModule.FilePickerModel.create(); |
101 | 82 | ||
102 | var topLevelDirectories = null; | 83 | var topLevelDirectories = null; |
@@ -131,13 +112,20 @@ var FilePickerController = exports.FilePickerController = Montage.create(require | |||
131 | } | 112 | } |
132 | 113 | ||
133 | //populate the last opened folder first, if none then populate default root | 114 | //populate the last opened folder first, if none then populate default root |
134 | var sessionStorage = window.sessionStorage; | ||
135 | var storedUri = null; | 115 | var storedUri = null; |
136 | 116 | var sessionStorage = window.sessionStorage; | |
137 | if(pickerMode === "write"){ | 117 | try{ |
138 | storedUri = sessionStorage.getItem("lastSavedFolderURI"); | 118 | if(pickerMode === "write"){ |
139 | }else{ | 119 | storedUri = sessionStorage.getItem("lastSavedFolderURI"); |
140 | storedUri = sessionStorage.getItem("lastOpenedFolderURI"); | 120 | }else if(inFileMode === true){ |
121 | storedUri = sessionStorage.getItem("lastOpenedFolderURI_fileSelection"); | ||
122 | }else if(inFileMode === false){ | ||
123 | storedUri = sessionStorage.getItem("lastOpenedFolderURI_folderSelection"); | ||
124 | } | ||
125 | }catch(e){ | ||
126 | if(e.code == 22){ | ||
127 | sessionStorage.clear(); | ||
128 | } | ||
141 | } | 129 | } |
142 | 130 | ||
143 | if(!!storedUri){ | 131 | if(!!storedUri){ |
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 | |||
7 | var Montage = require("montage/core/core").Montage, | 7 | var 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 | ||
13 | var PickerNavigator = exports.PickerNavigator = Montage.create(Component, { | 12 | var 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; | 6 |