oxjs/source/Ox.UI/js/Window/Ox.Layer.js

64 lines
1.4 KiB
JavaScript
Raw Normal View History

2011-11-05 16:46:53 +00:00
'use strict';
/*@
2012-05-22 13:14:40 +00:00
Ox.Layer <f:Ox.Element> 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() {
that.triggerEvent('click').remove();
}
function mousedown() {
that.stop().animate({opacity: 0.5}, 0);
}
function mouseup() {
that.stop().animate({opacity: 0}, 250);
}
2012-05-21 10:38:18 +00:00
/*@
hide <f> hide
() -> <u> hide layer
@*/
that.hide = function() {
if (self.options.type == 'dialog') {
Ox.UI.$window.unbind({mouseup: mouseup});
}
that.remove();
};
2012-05-21 10:38:18 +00:00
/*@
show <f> show
() -> <o> show layer
@*/
that.show = function() {
if (self.options.type == 'dialog') {
Ox.UI.$window.bind({mouseup: mouseup});
}
that.appendTo(Ox.UI.$body);
2011-11-01 14:45:47 +00:00
return that;
}
return that;
2012-05-21 10:38:18 +00:00
}