openmedialibrary/static/js/selectFolder.js

47 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-01-23 08:07:03 +00:00
'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;
}