openmedialibrary/static/js/selectFolder.js

46 lines
1.3 KiB
JavaScript

'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;
}