You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var egnyte =Egnyte.init("http://mydomain.egnyte.com", {
13
14
...
14
15
});
15
16
```
17
+
16
18
(See API docs)
17
19
18
20
### Open file picker:
21
+
19
22
```javascript
20
-
//find a DOM node to put the picker in:
21
-
var containerNode =document.getElementById("myPickerContainer");
22
-
//open file picker
23
-
var picker =egnyte.filePicker(containerNode,options);
23
+
//find a DOM node to put the picker in:
24
+
var containerNode =document.getElementById("myPickerContainer");
25
+
//open file picker
26
+
var picker =egnyte.filePicker(containerNode,options);
24
27
```
25
28
26
29
None of the options are required. (although without the selection callback it doesn't make much sense to use the picker)
27
30
28
31
The options are:
29
-
-`path`_String_ - a path to open the filepicker at, default: "/"
30
-
-`cancel`_Function_ - a callback to run when the user decides to cancel selecting
31
-
-`selection`_Function_ - a callback to run when the user makes a selection. First argument is an array of selected items.
32
-
-`error`_Function_ - a callback to call when an error occurs. First argument is an error object. Filepicker has its default error handling, return false from your error handler function to supress that, return a string to replace the default error text. When picker instance is not useful after an error, remember to close it.
33
-
-`barAlign`_String_ - decide if buttons on the bottom bar should be aligned to left or right, default: "right"
34
-
-`select`_Map_ of selectables configuration
35
-
```javascript
36
-
select: {
37
-
folder:true, //should folders be selectable
38
-
file:true, //should files be selectable (files are hidden when not selectable)
39
-
filesRemainVisible:false, //should files be visible even if not selectable
40
-
multiple:true, //should allow multiselection
41
-
forbidden: [] //array of folder paths that selection is forbidden in
42
-
}
43
-
```
44
-
-`texts`_Map_ of labels in the filepicker to replace with given replacements, optional
45
-
```javascript
46
-
texts: {
47
-
"Ok":"...",
48
-
"Cancel":"...",
49
-
"Loading":"...",
50
-
"This folder is empty":"..."
51
-
}
52
-
```
53
-
54
-
-`keys`_Map_ to override default keybinding, set to false to disable all keyboard handling
55
-
56
-
```javascript
57
-
keys: {
58
-
"up":"<up>",
59
-
"down":"<down>",
60
-
"select":"<space>",
61
-
"explore":"<right>",
62
-
"back":"<left>",
63
-
"confirm":"none",
64
-
"close":"<escape>"
65
-
}
66
-
```
32
+
33
+
-`path`_String_ - a path to open the filepicker at, default: "/"
34
+
-`cancel`_Function_ - a callback to run when the user decides to cancel selecting
35
+
-`selection`_Function_ - a callback to run when the user makes a selection. First argument is an array of selected items.
36
+
-`error`_Function_ - a callback to call when an error occurs. First argument is an error object. Filepicker has its default error handling, return false from your error handler function to supress that, return a string to replace the default error text. When picker instance is not useful after an error, remember to close it.
37
+
-`barAlign`_String_ - decide if buttons on the bottom bar should be aligned to left or right, default: "right"
38
+
-`select`_Map_ of selectables configuration
39
+
40
+
```javascript
41
+
select: {
42
+
folder:true, //should folders be selectable
43
+
file:true, //should files be selectable (files are hidden when not selectable)
44
+
filesRemainVisible:false, //should files be visible even if not selectable
45
+
multiple:true, //should allow multiselection
46
+
forbidden: [] //array of folder paths that selection is forbidden in
47
+
}
48
+
```
49
+
50
+
-`texts`_Map_ of labels in the filepicker to replace with given replacements, optional
51
+
52
+
```javascript
53
+
texts: {
54
+
"Ok":"...",
55
+
"Cancel":"...",
56
+
"Loading":"...",
57
+
"This folder is empty":"..."
58
+
}
59
+
```
60
+
61
+
-`keys`_Map_ to override default keybinding, set to false to disable all keyboard handling
62
+
63
+
```javascript
64
+
keys: {
65
+
"up":"<up>",
66
+
"down":"<down>",
67
+
"select":"<space>",
68
+
"explore":"<right>",
69
+
"back":"<left>",
70
+
"confirm":"none",
71
+
"close":"<escape>"
72
+
}
73
+
```
74
+
67
75
All keys handled by https://github.com/chrisdickinson/vkey are available.
68
76
69
-
-`filterExtensions`_Function_ - a filter function that decides if file should be visible to the user. Google drive files are filtered out by default. Pass `false` explicitly to disable filtering. First argument to the function is 3 first characters of file extension, second is the internal mime group name (used for icon colors too).
77
+
-`filterExtensions`_Function_ - a filter function that decides if file should be visible to the user. Google drive files are filtered out by default. Pass `false` explicitly to disable filtering. First argument to the function is 3 first characters of file extension, second is the internal mime group name (used for icon colors too).
78
+
79
+
```javascript
80
+
filterExtensions:function(ext3chars, mime){
81
+
return ext3chars==="htm"; //show only htm* files
82
+
}
83
+
```
70
84
71
-
```javascript
72
-
filterExtensions:function(ext3chars, mime){
73
-
return ext3chars==="htm"; //show only htm* files
74
-
}
75
-
```
76
-
Possible values of mime: `"audio", "video", "pdf", "word_processing", "spreadsheet", "presentation", "cad", "text", "image", "archive", "goog"`
85
+
Possible values of mime: `"audio", "video", "pdf", "word_processing", "spreadsheet", "presentation", "cad", "text", "image", "archive", "goog"`
77
86
78
-
-`noFont`_Boolean_ - set to true to opt-out from linking Open Sans from google fonts. The font will be linked to only once if at least one filepicker instance doesn't have `noFont:true` in options.
87
+
-`noFont`_Boolean_ - set to true to opt-out from linking Open Sans from google fonts. The font will be linked to only once if at least one filepicker instance doesn't have `noFont:true` in options.
79
88
80
-
----
89
+
---
81
90
82
91
_Examples_
83
92
84
93
Open on `/Private` location, with single selection and changed labels for OK and empty folder
85
94
86
95
```javascript
87
-
var picker =egnyte.filePicker(containerNode,{
88
-
path:"/Private",
89
-
navigation:function(currentFolder){
90
-
//handle change folder
91
-
},
92
-
selection:function(list){
93
-
//handle selection
94
-
},
95
-
cancel:function(){
96
-
//the user cancelled. containerNode will be emptied by the filepicker itself.
97
-
},
98
-
select: {
99
-
multiple:false//single selection
100
-
},
101
-
texts: {
102
-
"Ok":"Continue",
103
-
"This folder is empty":"Nothing here, sorry"
104
-
}
105
-
});
96
+
var picker =egnyte.filePicker(containerNode,{
97
+
path:"/Private",
98
+
navigation:function(currentFolder){
99
+
//handle change folder
100
+
},
101
+
selection:function(list){
102
+
//handle selection
103
+
},
104
+
cancel:function () {
105
+
//the user cancelled. containerNode will be emptied by the filepicker itself.
106
+
},
107
+
select: {
108
+
multiple:false,//single selection
109
+
},
110
+
texts: {
111
+
Ok:"Continue",
112
+
"This folder is empty":"Nothing here, sorry",
113
+
},
114
+
});
106
115
```
107
116
108
117
Added a detailed error handler for
118
+
109
119
```javascript
110
-
var picker =egnyte.filePicker(containerNode,{
111
-
selection:function(list){
112
-
//handle selection
113
-
},
114
-
cancel:function(){
115
-
//the user cancelled. containerNode will be emptied by the filepicker itself.
116
-
},
117
-
error:function(e){
118
-
if(e.statusCode==503){
119
-
return"Server is tired of all this querying"
120
-
}
121
-
}
122
-
});
120
+
var picker =egnyte.filePicker(containerNode,{
121
+
selection:function(list){
122
+
//handle selection
123
+
},
124
+
cancel:function () {
125
+
//the user cancelled. containerNode will be emptied by the filepicker itself.
126
+
},
127
+
error:function(e){
128
+
if(e.statusCode==503){
129
+
return"Server is tired of all this querying";
130
+
}
131
+
},
132
+
});
123
133
```
124
134
125
135
File picker will fill the container node (width and height 100%). Minimal dimensions of the container node are 400x400 px
@@ -165,14 +175,15 @@ _Folder_
165
175
### Close file picker
166
176
167
177
File picker can be closed without the user clicking "cancel":
178
+
168
179
```javascript
169
-
picker.close();
180
+
picker.close();
170
181
```
171
182
172
183
### Get current folder
173
184
174
185
```javascript
175
-
picker.getCurrentFolder();
186
+
picker.getCurrentFolder();
176
187
```
177
188
178
189
### Change the style
@@ -183,32 +194,32 @@ You can also modify the defaults to keep everything in one package. Change the c
183
194
184
195
## Prompt widget
185
196
186
-
187
197
### Open prompt:
198
+
188
199
```javascript
189
-
//find a DOM node to work with:
190
-
var containerNode =document.getElementById("myPickerContainer");
191
-
//open prompt
192
-
var promptObj =egnyte.prompt(containerNode,{
193
-
texts:{
194
-
question:"What's your name"
195
-
},
196
-
result:function(name){
197
-
//do stuff
198
-
}
199
-
});
200
+
//find a DOM node to work with:
201
+
var containerNode =document.getElementById("myPickerContainer");
202
+
//open prompt
203
+
var promptObj =egnyte.prompt(containerNode,{
204
+
texts:{
205
+
question:"What's your name",
206
+
},
207
+
result:function(name){
208
+
//do stuff
209
+
},
210
+
});
200
211
```
201
212
202
-
203
213
The options are:
204
-
-`result`_Function_ - a callback to run when the user clicks ok. First argument is the string from user input
205
-
-`barAlign`_String_ - decide if buttons on the bottom bar should be aligned to left or right, default: "right"
206
-
-`texts`_Map_ of labels in the widget to replace with given replacements. Put your question in the `question` field
207
214
215
+
-`result`_Function_ - a callback to run when the user clicks ok. First argument is the string from user input
216
+
-`barAlign`_String_ - decide if buttons on the bottom bar should be aligned to left or right, default: "right"
217
+
-`texts`_Map_ of labels in the widget to replace with given replacements. Put your question in the `question` field
208
218
209
219
### Close the prompt
210
220
211
221
Prompt can be closed without the user clicking the button:
0 commit comments