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

@ -26,36 +26,42 @@ Ox.CollapsePanel = function(options, self) {
title: ''
})
.options(options)
.addClass('OxCollapsePanel'),
// fixme: the following should all be self.foo
title = self.options.collapsed ?
[{id: 'expand', title: 'right'}, {id: 'collapse', title: 'down'}] :
[{id: 'collapse', title: 'down'}, {id: 'expand', title: 'right'}],
$titlebar = Ox.Bar({
orientation: 'horizontal',
size: self.options.size,
})
.dblclick(dblclickTitlebar)
.appendTo(that),
$switch = Ox.Button({
style: 'symbol',
title: title,
type: 'image',
})
.click(toggleCollapsed)
.appendTo($titlebar),
$title = Ox.Element()
.addClass('OxTitle')
.html(self.options.title/*.toUpperCase()*/)
.appendTo($titlebar),
$extras;
.addClass('OxCollapsePanel');
self.$titlebar = Ox.Bar({
orientation: 'horizontal',
size: self.options.size,
})
.bindEvent({
doubleclick: doubleclickTitlebar
})
.appendTo(that);
self.$button = Ox.Button({
style: 'symbol',
type: 'image',
value: self.options.collapsed ? 'expand' : 'collapse',
values: [
{id: 'expand', title: 'right'},
{id: 'collapse', title: 'down'}
]
})
.bindEvent({
click: toggleCollapsed
})
.appendTo(self.$titlebar);
self.$title = Ox.Element()
.addClass('OxTitle')
.html(self.options.title)
.appendTo(self.$titlebar);
if (self.options.extras.length) {
$extras = Ox.Element()
self.$extras = Ox.Element()
.addClass('OxExtras')
.appendTo($titlebar);
.appendTo(self.$titlebar);
self.options.extras.forEach(function($extra) {
$extra.appendTo($extras);
$extra.appendTo(self.$extras);
});
}
@ -70,9 +76,9 @@ Ox.CollapsePanel = function(options, self) {
});
}
function dblclickTitlebar(e) {
function doubleclickTitlebar(e) {
if (!$(e.target).hasClass('OxButton')) {
$switch.trigger('click');
self.$button.trigger('click');
}
}
@ -94,9 +100,9 @@ Ox.CollapsePanel = function(options, self) {
@*/
self.setOption = function(key, value) {
if (key == 'collapsed') {
self.$button.trigger('click');
} else if (key == 'title') {
$title.html(self.options.title);
self.$title.html(self.options.title);
}
};