use native select folder dialog
This commit is contained in:
parent
1d52413618
commit
b2368b9053
6 changed files with 94 additions and 46 deletions
46
static/js/selectFolder.js
Normal file
46
static/js/selectFolder.js
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
'use strict';
|
||||
|
||||
oml.ui.selectFolder = function(options, self) {
|
||||
options.width = options.width - options.labelWidth
|
||||
options = Ox.extend({
|
||||
title: '...',
|
||||
textAlign: 'left'
|
||||
}, options);
|
||||
var $button = Ox.Button(options, self).bindEvent({
|
||||
click: function(event) {
|
||||
oml.api.selectFolder({
|
||||
base: $button.value()
|
||||
}, function(result) {
|
||||
if (result.data.path) {
|
||||
$button.value(result.data.path);
|
||||
$button.options({
|
||||
title: result.data.path
|
||||
});
|
||||
$button.triggerEvent('change', result.data.path);
|
||||
}
|
||||
})
|
||||
}
|
||||
}),
|
||||
that = Ox.FormElementGroup({
|
||||
id: options.id,
|
||||
elements: [
|
||||
Ox.Label({
|
||||
style: options.style,
|
||||
textAlign: 'right',
|
||||
overlap: 'right',
|
||||
title: options.label,
|
||||
width: options.labelWidth
|
||||
}),
|
||||
$button
|
||||
],
|
||||
}, self);
|
||||
|
||||
that.value = function() {
|
||||
return $button.value()
|
||||
}
|
||||
|
||||
if (options.title && options.title != '...') {
|
||||
$button.value(options.title)
|
||||
}
|
||||
return that;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue