2011-11-05 16:46:53 +00:00
|
|
|
'use strict';
|
2012-05-21 10:38:18 +00:00
|
|
|
|
2011-05-16 08:24:46 +00:00
|
|
|
/*@
|
2012-05-31 10:32:54 +00:00
|
|
|
Ox.Picker <f> Picker Object
|
2011-05-16 08:24:46 +00:00
|
|
|
options <o> Options object
|
2011-05-16 10:49:48 +00:00
|
|
|
element <o|null> picker element
|
|
|
|
elementHeight <n|128> height
|
|
|
|
elemementWidth <n|256> width
|
|
|
|
id <s> picker id
|
|
|
|
overlap <s|none> select button overlap value
|
2012-07-04 11:29:18 +00:00
|
|
|
self <o> Shared private variable
|
|
|
|
([options[, self]]) -> <o:Ox.Element> Picker Object
|
|
|
|
show <!> picker is shown
|
|
|
|
hide <!> picker is hidden
|
2011-05-16 08:24:46 +00:00
|
|
|
@*/
|
|
|
|
|
2011-04-22 22:03:10 +00:00
|
|
|
Ox.Picker = function(options, self) {
|
|
|
|
|
2011-06-19 17:48:32 +00:00
|
|
|
self = self || {};
|
|
|
|
var that = Ox.Element({}, self)
|
2011-04-22 22:03:10 +00:00
|
|
|
.defaults({
|
|
|
|
element: null,
|
|
|
|
elementHeight: 128,
|
|
|
|
elementWidth: 256,
|
2012-07-09 14:29:45 +00:00
|
|
|
overlap: 'right', // 'none'
|
2011-04-22 22:03:10 +00:00
|
|
|
})
|
|
|
|
.options(options || {});
|
|
|
|
|
2011-06-19 17:48:32 +00:00
|
|
|
self.$selectButton = Ox.Button({
|
2011-04-22 22:03:10 +00:00
|
|
|
overlap: self.options.overlap,
|
|
|
|
title: 'select',
|
|
|
|
type: 'image'
|
|
|
|
})
|
2012-06-15 09:43:11 +00:00
|
|
|
.bindEvent({
|
|
|
|
click: showMenu
|
|
|
|
})
|
2011-04-22 22:03:10 +00:00
|
|
|
.appendTo(that);
|
|
|
|
|
2011-06-19 17:48:32 +00:00
|
|
|
self.$menu = Ox.Element()
|
2011-04-22 22:03:10 +00:00
|
|
|
.addClass('OxPicker')
|
|
|
|
.css({
|
|
|
|
width: self.options.elementWidth + 'px',
|
|
|
|
height: (self.options.elementHeight + 24) + 'px'
|
|
|
|
});
|
|
|
|
|
2014-09-22 11:18:28 +00:00
|
|
|
self.options.element.css({
|
2011-04-22 22:03:10 +00:00
|
|
|
width: self.options.elementWidth + 'px',
|
|
|
|
height: self.options.elementHeight + 'px'
|
|
|
|
})
|
|
|
|
.appendTo(self.$menu);
|
|
|
|
|
2011-06-19 17:48:32 +00:00
|
|
|
self.$bar = Ox.Bar({
|
2011-04-22 22:03:10 +00:00
|
|
|
orientation: 'horizontal',
|
|
|
|
size: 24
|
|
|
|
})
|
|
|
|
.appendTo(self.$menu);
|
|
|
|
|
2011-06-19 17:48:32 +00:00
|
|
|
that.$label = Ox.Label({
|
2011-04-22 22:03:10 +00:00
|
|
|
width: self.options.elementWidth - 60
|
|
|
|
})
|
|
|
|
.appendTo(self.$bar);
|
|
|
|
|
2011-06-19 17:48:32 +00:00
|
|
|
self.$doneButton = Ox.Button({
|
2013-05-09 13:03:33 +00:00
|
|
|
title: Ox._('Done'),
|
2011-04-22 22:03:10 +00:00
|
|
|
width: 48
|
|
|
|
})
|
2014-09-22 11:18:28 +00:00
|
|
|
.bindEvent({
|
|
|
|
click: hideMenu
|
|
|
|
})
|
2011-04-22 22:03:10 +00:00
|
|
|
.appendTo(self.$bar);
|
|
|
|
|
2014-09-22 11:18:28 +00:00
|
|
|
self.$layer = Ox.$('<div>')
|
2011-04-22 22:03:10 +00:00
|
|
|
.addClass('OxLayer')
|
2014-09-22 11:18:28 +00:00
|
|
|
.on({
|
|
|
|
click: hideMenu
|
|
|
|
});
|
2011-04-22 22:03:10 +00:00
|
|
|
|
|
|
|
function hideMenu() {
|
|
|
|
self.$menu.detach();
|
|
|
|
self.$layer.detach();
|
|
|
|
self.$selectButton
|
|
|
|
.removeClass('OxSelected')
|
|
|
|
.css({
|
2012-06-15 09:43:11 +00:00
|
|
|
borderRadius: '8px'
|
2011-04-22 22:03:10 +00:00
|
|
|
});
|
|
|
|
that.triggerEvent('hide');
|
2011-06-19 17:48:32 +00:00
|
|
|
}
|
2011-04-22 22:03:10 +00:00
|
|
|
|
|
|
|
function showMenu() {
|
|
|
|
var offset = that.offset(),
|
|
|
|
left = offset.left,
|
|
|
|
top = offset.top + 15;
|
|
|
|
self.$selectButton
|
|
|
|
.addClass('OxSelected')
|
|
|
|
.css({
|
2012-06-15 09:43:11 +00:00
|
|
|
borderRadius: '8px 8px 0 0'
|
2011-04-22 22:03:10 +00:00
|
|
|
});
|
2019-02-21 10:40:58 +00:00
|
|
|
self.$layer.appendTo(Ox.Fullscreen.element ? Ox.Fullscreen.element : Ox.$body);
|
2011-04-22 22:03:10 +00:00
|
|
|
self.$menu
|
|
|
|
.css({
|
|
|
|
left: left + 'px',
|
|
|
|
top: top + 'px'
|
|
|
|
})
|
2012-06-15 09:43:11 +00:00
|
|
|
.appendTo(Ox.$body);
|
2011-04-22 22:03:10 +00:00
|
|
|
that.triggerEvent('show');
|
2011-06-19 17:48:32 +00:00
|
|
|
}
|
2011-04-22 22:03:10 +00:00
|
|
|
|
|
|
|
return that;
|
|
|
|
|
|
|
|
};
|