'use strict'; /*@ Ox.Picker Picker Object options Options object element picker element elementHeight height elemementWidth width id picker id overlap select button overlap value self Shared private variable ([options[, self]]) -> Picker Object show picker is shown hide picker is hidden @*/ Ox.Picker = function(options, self) { self = self || {}; var that = Ox.Element({}, self) .defaults({ element: null, elementHeight: 128, elementWidth: 256, overlap: 'none' }) .options(options || {}); self.$selectButton = Ox.Button({ overlap: self.options.overlap, title: 'select', type: 'image' }) .bindEvent({ click: showMenu }) .appendTo(that); self.$menu = Ox.Element() .addClass('OxPicker') .css({ width: self.options.elementWidth + 'px', height: (self.options.elementHeight + 24) + 'px' }); self.options.element .css({ width: self.options.elementWidth + 'px', height: self.options.elementHeight + 'px' }) .appendTo(self.$menu); self.$bar = Ox.Bar({ orientation: 'horizontal', size: 24 }) .appendTo(self.$menu); that.$label = Ox.Label({ width: self.options.elementWidth - 60 }) .appendTo(self.$bar); self.$doneButton = Ox.Button({ title: 'Done', width: 48 }) .click(hideMenu) .appendTo(self.$bar); self.$layer = $('
') .addClass('OxLayer') .click(hideMenu); function hideMenu() { self.$menu.detach(); self.$layer.detach(); self.$selectButton .removeClass('OxSelected') .css({ borderRadius: '8px' }); that.triggerEvent('hide'); } function showMenu() { var offset = that.offset(), left = offset.left, top = offset.top + 15; self.$selectButton .addClass('OxSelected') .css({ borderRadius: '8px 8px 0 0' }); self.$layer.appendTo(Ox.$body); self.$menu .css({ left: left + 'px', top: top + 'px' }) .appendTo(Ox.$body); that.triggerEvent('show'); } return that; };