forked from 0x2620/oxjs
add unified Ox.Layer object for dialogs and menus
This commit is contained in:
parent
3aa10edec8
commit
1720d2a184
5 changed files with 73 additions and 51 deletions
55
source/Ox.UI/js/Window/Ox.Layer.js
Normal file
55
source/Ox.UI/js/Window/Ox.Layer.js
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
||||
|
||||
/*@
|
||||
Ox.Layer <o> Background layer for dialogs and menus
|
||||
(options, self) -> <o> Layer
|
||||
options <o> Options
|
||||
type <s|'dialog'> Layer type ('dialog' or 'menu')
|
||||
self <o> Shared private variable
|
||||
@*/
|
||||
|
||||
Ox.Layer = function(options, self) {
|
||||
|
||||
self = self || {};
|
||||
var that = Ox.Element({}, self)
|
||||
.defaults({
|
||||
type: 'dialog'
|
||||
})
|
||||
.options(options || {})
|
||||
.addClass('OxLayer Ox' + Ox.toTitleCase(self.options.type) + 'Layer')
|
||||
.bind(self.options.type == 'dialog' ? {
|
||||
mousedown: mousedown,
|
||||
} : {
|
||||
click: click
|
||||
});
|
||||
|
||||
function click() {
|
||||
Ox.print('CLICK!!!!!!!')
|
||||
that.triggerEvent('click').removeElement();
|
||||
}
|
||||
|
||||
function mousedown() {
|
||||
that.stop().animate({opacity: 0.5}, 0);
|
||||
}
|
||||
|
||||
function mouseup() {
|
||||
that.stop().animate({opacity: 0}, 250);
|
||||
}
|
||||
|
||||
that.hide = function() {
|
||||
if (self.options.type == 'dialog') {
|
||||
Ox.UI.$window.unbind({mouseup: mouseup});
|
||||
}
|
||||
that.removeElement();
|
||||
};
|
||||
|
||||
that.show = function() {
|
||||
if (self.options.type == 'dialog') {
|
||||
Ox.UI.$window.bind({mouseup: mouseup});
|
||||
}
|
||||
that.appendTo(Ox.UI.$body);
|
||||
}
|
||||
|
||||
return that;
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue