Sha256: d94db8728bba0980d4728eb447e640180e00d483f82b7f3c2bff64cffb787126
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
class @Mercury.Select extends Mercury.Dialog constructor: (@url, @name, @options = {}) -> super build: -> @element = $('<div>', {class: "mercury-select mercury-#{@name}-select loading", style: 'display:none'}) @element.appendTo($(@options.appendTo).get(0) ? 'body') bindEvents: -> Mercury.bind 'hide:dialogs', (event, dialog) => @hide() unless dialog == @ super position: (keepVisible) -> @element.css({top: 0, left: 0, display: 'block', visibility: 'hidden'}) position = @button.offset() elementWidth = @element.width() elementHeight = @element.height() documentHeight = $(document).height() top = position.top + (@button.height() / 2) - (elementHeight / 2) top = position.top - 100 if top < position.top - 100 top = 20 if top < 20 height = if @loaded then 'auto' else elementHeight height = documentHeight - top - 20 if top + elementHeight >= documentHeight - 20 left = position.left left = left - elementWidth + @button.width() if left + elementWidth > $(window).width() @element.css { top: top, left: left, height: height, display: if keepVisible then 'block' else 'none', visibility: 'visible' }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mercury-rails-0.1.1 | app/assets/javascripts/mercury/select.js.coffee |
mercury-rails-0.1.0 | app/assets/javascripts/mercury/select.js.coffee |