Sha256: 563e46ed9591ba464b47ba426dc815c3907d99db08b250edf7812e55556a0876

Contents?: true

Size: 863 Bytes

Versions: 3

Compression:

Stored size: 863 Bytes

Contents

class @Mercury.Palette extends Mercury.Dialog

  constructor: (@url, @name, @options = {}) ->
    super


  build: ->
    @element = jQuery('<div>', {class: "mercury-palette mercury-#{@name}-palette loading", style: 'display:none'})
    @element.appendTo(jQuery(@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()
    width = @element.width()

    position.left = position.left - width + @button.width() if position.left + width > jQuery(window).width()

    @element.css {
      top: position.top + @button.height()
      left: position.left
      display: if keepVisible then 'block' else 'none'
      visibility: 'visible'
    }

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mercury-rails-0.2.3 vendor/assets/javascripts/mercury/palette.js.coffee
mercury-rails-0.2.0 vendor/assets/javascripts/mercury/palette.js.coffee
mercury-rails-0.1.2 app/assets/javascripts/mercury/palette.js.coffee