forked from 0x2620/oxjs
better filesystem structure for modules and themes; 'minified' ui if debug option not set; dynamially generated map markers
This commit is contained in:
parent
358ee1bc96
commit
4489e88f44
596 changed files with 115093 additions and 17682 deletions
|
|
@ -1,75 +0,0 @@
|
|||
// vim: et:ts=4:sw=4:sts=4:ft=js
|
||||
Ox.ButtonGroup = function(options, self) {
|
||||
|
||||
/**
|
||||
options
|
||||
buttons array of buttons
|
||||
max integer, maximum number of selected buttons, 0 for all
|
||||
min integer, minimum number of selected buttons, 0 for none
|
||||
selectable if true, buttons are selectable
|
||||
type string, 'image' or 'text'
|
||||
methods:
|
||||
events:
|
||||
change {id, value} selection within a group changed
|
||||
*/
|
||||
|
||||
var self = self || {},
|
||||
that = new Ox.Element({}, self)
|
||||
.defaults({
|
||||
buttons: [],
|
||||
max: 1,
|
||||
min: 1,
|
||||
selectable: false,
|
||||
size: 'medium',
|
||||
style: '',
|
||||
type: 'text',
|
||||
})
|
||||
.options(options || {})
|
||||
.addClass('OxButtonGroup');
|
||||
|
||||
if (self.options.selectable) {
|
||||
self.optionGroup = new Ox.OptionGroup(
|
||||
self.options.buttons,
|
||||
self.options.min,
|
||||
self.options.max,
|
||||
'selected'
|
||||
);
|
||||
self.options.buttons = self.optionGroup.init();
|
||||
}
|
||||
|
||||
self.$buttons = [];
|
||||
self.options.buttons.forEach(function(button, position) {
|
||||
var id = self.options.id + Ox.toTitleCase(button.id)
|
||||
self.$buttons[position] = Ox.Button({
|
||||
disabled: button.disabled,
|
||||
group: true,
|
||||
id: id,
|
||||
selectable: self.options.selectable,
|
||||
selected: button.selected,
|
||||
size: self.options.size,
|
||||
style: self.options.style,
|
||||
title: button.title,
|
||||
type: self.options.type
|
||||
})
|
||||
.bindEvent('select', function() {
|
||||
selectButton(position);
|
||||
})
|
||||
.appendTo(that);
|
||||
});
|
||||
|
||||
function selectButton(pos) {
|
||||
var toggled = self.optionGroup.toggle(pos);
|
||||
if (toggled.length) {
|
||||
toggled.forEach(function(pos, i) {
|
||||
self.$buttons[pos].toggleSelected();
|
||||
});
|
||||
that.triggerEvent('change', {
|
||||
selected: $.map(self.optionGroup.selected(), function(v, i) {
|
||||
return self.options.buttons[v].id;
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return that;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue