1
0
Fork 0
forked from 0x2620/oxjs

use new form element syntax, continued

This commit is contained in:
rlx 2011-12-22 15:47:46 +00:00
commit 02f53a57c1
15 changed files with 107 additions and 88 deletions

View file

@ -47,10 +47,9 @@ Ox.Button = function(options, self) {
values: [],
width: 'auto'
})
.options(options ? Ox.extend(Ox.clone(options), {
// tooltip may be an array, so we can't pass it yet
tooltip: ''
}) : {})
.options(Ox.isArray(options.tooltip) ? Ox.extend(Ox.clone(options), {
tooltip: options.tooltip[0]
}) : options || {})
.attr({
disabled: self.options.disabled,
type: self.options.type == 'text' ? 'button' : 'image'
@ -87,19 +86,20 @@ Ox.Button = function(options, self) {
setTitle();
options.tooltip && that.options({
tooltip: Ox.isArray(options.tooltip)
? options.tooltip[self.value]
: options.tooltip
});
if (Ox.isArray(options.tooltip)) {
self.options.tooltip = options.tooltip;
Ox.print('TOOLTIP', self.options.tooltip);
that.$tooltip.options({
title: self.options.tooltip[self.value]
});
}
function click() {
if (!self.options.disabled) {
that.triggerEvent('click');
if (self.options.values.length || self.options.selectable) {
that.toggle();
that.triggerEvent('change', {value: self.options.value});
} else {
that.triggerEvent('click');
}
}
}
@ -143,16 +143,16 @@ Ox.Button = function(options, self) {
};
that.toggle = function() {
var index;
if (self.options.values.length) {
index = 1 - Ox.getPositionById(self.options.values, self.options.value);
self.options.title = self.options.values[index].title;
self.options.value = self.options.values[index].id;
self.value = 1 - Ox.getPositionById(self.options.values, self.options.value);
Ox.print('S:O:', self.options, self.value)
self.options.title = self.options.values[self.value].title;
self.options.value = self.options.values[self.value].id;
setTitle();
// fixme: if the tooltip is visible
// we also need to call show()
that.$tooltip && that.$tooltip.options({
title: self.options.tooltips[index]
title: self.options.tooltip[self.value]
});
} else {
self.options.value = !self.options.value;