diff options
author | Pushkar Joshi | 2012-02-24 12:08:49 -0800 |
---|---|---|
committer | Pushkar Joshi | 2012-02-24 12:08:49 -0800 |
commit | 03ca7a5ed13c25faaa9100bb666e062fd15335e6 (patch) | |
tree | c51112223ceb9121cd595a60335eb2795215590f /js/io/ui/file-picker/file-picker-model.js | |
parent | fcb12cc09eb3cd3b42bd215877ba18f449275b75 (diff) | |
parent | 053fc63a2950c7a5ee4ebf98033b64d474a3c46e (diff) | |
download | ninja-03ca7a5ed13c25faaa9100bb666e062fd15335e6.tar.gz |
Merge branch 'pentool' into brushtool
Conflicts:
imports/codemirror/mode/scheme/scheme.js
js/tools/BrushTool.js
Diffstat (limited to 'js/io/ui/file-picker/file-picker-model.js')
-rwxr-xr-x | js/io/ui/file-picker/file-picker-model.js | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/js/io/ui/file-picker/file-picker-model.js b/js/io/ui/file-picker/file-picker-model.js new file mode 100755 index 00000000..09c3ae9c --- /dev/null +++ b/js/io/ui/file-picker/file-picker-model.js | |||
@@ -0,0 +1,128 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No 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 | |||
7 | var filePickerControllerModule = require("js/io/ui/file-picker/file-picker-controller"); | ||
8 | |||
9 | //this is per file picker instance | ||
10 | exports.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 | callbackScope:{ | ||
83 | writable:true, | ||
84 | enumerable:true, | ||
85 | value:null | ||
86 | }, | ||
87 | |||
88 | /** | ||
89 | * stores the previously viewed directory uris in an array [FILO] per file picker instance | ||
90 | */ | ||
91 | _history:{ | ||
92 | writable:true, | ||
93 | enumerable:true, | ||
94 | value:[]//array of visited URIs for the back/forward arrows | ||
95 | }, | ||
96 | |||
97 | /** | ||
98 | * store history of folders navigated if it was already not visited last | ||
99 | */ | ||
100 | storeHistory:{ | ||
101 | writable:false, | ||
102 | enumerable:true, | ||
103 | value:function(uri){ | ||
104 | //remove redundant / at end | ||
105 | // uri = new String(uri); | ||
106 | // if((uri.charAt(uri.length - 1) === "/") || (uri.charAt(uri.length - 1) === "\\")){ | ||
107 | // uri = uri.substring(0, (uri.length - 1)); | ||
108 | // } | ||
109 | //console.log("storeHistory: "+uri); | ||
110 | if(uri && (uri !== this._history[this._history.length -1]) && (!!filePickerControllerModule.FilePickerController._directoryContentCache[uri]) && (filePickerControllerModule.FilePickerController._directoryContentCache[uri].type === "directory")){ | ||
111 | //remove history after current pointer | ||
112 | if(this._history.length >0){ | ||
113 | this._history.splice((this.currentHistoryPointer+1), (this._history.length - this.currentHistoryPointer - 1)); | ||
114 | } | ||
115 | //now add the new state | ||
116 | this._history.push(uri); | ||
117 | this.currentHistoryPointer = this._history.length -1; | ||
118 | //console.log("### stored: "+uri+" : pointer="+this.currentHistoryPointer); | ||
119 | } | ||
120 | } | ||
121 | }, | ||
122 | |||
123 | currentHistoryPointer:{ | ||
124 | writable:true, | ||
125 | enumerable:true, | ||
126 | value:-1 | ||
127 | } | ||
128 | }); \ No newline at end of file | ||