aboutsummaryrefslogtreecommitdiff
path: root/js/components/ui/FilePicker/file-picker-model.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/components/ui/FilePicker/file-picker-model.js')
-rw-r--r--js/components/ui/FilePicker/file-picker-model.js122
1 files changed, 122 insertions, 0 deletions
diff --git a/js/components/ui/FilePicker/file-picker-model.js b/js/components/ui/FilePicker/file-picker-model.js
new file mode 100644
index 00000000..b1df3b4e
--- /dev/null
+++ b/js/components/ui/FilePicker/file-picker-model.js
@@ -0,0 +1,122 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */
6
7var filePickerControllerModule = require("js/components/ui/FilePicker/file-picker-controller");
8
9//this is per file picker instance
10exports.FilePickerModel = (require("montage/core/core").Montage).create(require("montage/ui/component").Component, {
11
12 fatalError:{
13 writable:true,
14 enumerable:true,
15 value:null
16 },
17
18 _fileFilters:{
19 writable:true,
20 enumerable:false,
21 value:null
22 },
23 fileFilters:{
24 get:function(){
25 return this._fileFilters;
26 },
27 set:function(value){
28 this._fileFilters = value;
29 }
30 },
31 _currentFilter:{
32 writable:true,
33 enumerable:false,
34 value:null
35 },
36 currentFilter:{
37 get:function(){
38 return this._currentFilter;
39 },
40 set:function(value){
41 this._currentFilter = value;
42 }
43 },
44
45 /**
46 * true -> file selection mode
47 * false -> directory selection mode
48 */
49 inFileMode:{
50 writable:true,
51 enumerable:false,
52 value:null
53 },
54
55 /**
56 * pickerMode: ["read", "write"] : specifies if the file picker is opened to read a file/folder or to save a file
57 */
58 pickerMode:{
59 writable:true,
60 enumerable:false,
61 value:null
62 },
63
64 topLevelDirectories:{
65 writable:true,
66 enumerable:true,
67 value:[]
68 },
69
70 currentRoot:{
71 writable:true,
72 enumerable:true,
73 value:""
74 },
75
76 callback:{
77 writable:true,
78 enumerable:true,
79 value:null
80 },
81
82 /**
83 * stores the previously viewed directory uris in an array [FILO] per file picker instance
84 */
85 _history:{
86 writable:true,
87 enumerable:true,
88 value:[]//array of visited URIs for the back/forward arrows
89 },
90
91 /**
92 * store history of folders navigated if it was already not visited last
93 */
94 storeHistory:{
95 writable:false,
96 enumerable:true,
97 value:function(uri){
98 //remove redundant / at end
99// uri = new String(uri);
100// if((uri.charAt(uri.length - 1) === "/") || (uri.charAt(uri.length - 1) === "\\")){
101// uri = uri.substring(0, (uri.length - 1));
102// }
103 //console.log("storeHistory: "+uri);
104 if(uri && (uri !== this._history[this._history.length -1]) && (!!filePickerControllerModule.FilePickerController._directoryContentCache[uri]) && (filePickerControllerModule.FilePickerController._directoryContentCache[uri].type === "directory")){
105 //remove history after current pointer
106 if(this._history.length >0){
107 this._history.splice((this.currentHistoryPointer+1), (this._history.length - this.currentHistoryPointer - 1));
108 }
109 //now add the new state
110 this._history.push(uri);
111 this.currentHistoryPointer = this._history.length -1;
112 //console.log("### stored: "+uri+" : pointer="+this.currentHistoryPointer);
113 }
114 }
115 },
116
117 currentHistoryPointer:{
118 writable:true,
119 enumerable:true,
120 value:-1
121 }
122}); \ No newline at end of file