2011-11-05 16:46:53 +00:00
|
|
|
'use strict';
|
|
|
|
|
2011-11-01 14:16:27 +00:00
|
|
|
/*@
|
2012-05-31 10:32:54 +00:00
|
|
|
Ox.Layer <f> Background layer for dialogs and menus
|
|
|
|
([options[, self]]) -> <o:Ox.Element> Layer
|
2011-11-01 14:16:27 +00:00
|
|
|
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')
|
2012-05-28 14:06:22 +00:00
|
|
|
.on(self.options.type == 'dialog' ? {
|
2012-05-26 15:48:19 +00:00
|
|
|
mousedown: mousedown
|
2011-11-01 14:16:27 +00:00
|
|
|
} : {
|
|
|
|
click: click
|
|
|
|
});
|
|
|
|
|
|
|
|
function click() {
|
2011-11-04 22:14:30 +00:00
|
|
|
that.triggerEvent('click').remove();
|
2011-11-01 14:16:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function mousedown() {
|
2012-06-16 16:50:58 +00:00
|
|
|
that.stop().css({opacity: 0.5});
|
2011-11-01 14:16:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function mouseup() {
|
|
|
|
that.stop().animate({opacity: 0}, 250);
|
|
|
|
}
|
|
|
|
|
2012-05-21 10:38:18 +00:00
|
|
|
/*@
|
|
|
|
hide <f> hide
|
|
|
|
() -> <u> hide layer
|
|
|
|
@*/
|
2011-11-01 14:16:27 +00:00
|
|
|
that.hide = function() {
|
|
|
|
if (self.options.type == 'dialog') {
|
2012-05-28 14:06:22 +00:00
|
|
|
Ox.$window.off({mouseup: mouseup});
|
2011-11-01 14:16:27 +00:00
|
|
|
}
|
2011-11-04 22:14:30 +00:00
|
|
|
that.remove();
|
2011-11-01 14:16:27 +00:00
|
|
|
};
|
|
|
|
|
2012-05-21 10:38:18 +00:00
|
|
|
/*@
|
|
|
|
show <f> show
|
|
|
|
() -> <o> show layer
|
|
|
|
@*/
|
2011-11-01 14:16:27 +00:00
|
|
|
that.show = function() {
|
|
|
|
if (self.options.type == 'dialog') {
|
2012-05-28 14:06:22 +00:00
|
|
|
Ox.$window.on({mouseup: mouseup});
|
2011-11-01 14:16:27 +00:00
|
|
|
}
|
2012-05-28 14:06:22 +00:00
|
|
|
that.appendTo(Ox.$body);
|
2011-11-01 14:45:47 +00:00
|
|
|
return that;
|
2011-11-01 14:16:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
2012-05-21 10:38:18 +00:00
|
|
|
}
|