Sha256: be1706aeac6a843e1cb9344c1e74bcd02bf00083bdbab5b8c4a73752278ac7a8

Contents?: true

Size: 1.75 KB

Versions: 30

Compression:

Stored size: 1.75 KB

Contents

class @Mercury.Toolbar.Expander extends Mercury.Palette

  constructor: (@name, @options) ->
    @container = @options.for
    @containerWidth = @container.outerWidth()
    super(null, @name, @options)
    return @element


  build: ->
    @container.css({whiteSpace: 'normal'})
    @trigger = jQuery('<div>', {class: 'mercury-toolbar-expander'}).appendTo(jQuery(@options.appendTo).get(0) ? 'body')
    @element = jQuery('<div>', {class: "mercury-palette mercury-expander mercury-#{@name}-expander", style: 'display:none'})
    @windowResize()


  bindEvents: ->
    Mercury.on 'hide:dialogs', (event, dialog) => @hide() unless dialog == @
    Mercury.on 'resize', => @windowResize()

    super

    @trigger.click (event) =>
      event.stopPropagation()
      hiddenButtons = []
      for button in @container.find('.mercury-button')
        button = jQuery(button)
        hiddenButtons.push(button.data('expander')) if button.position().top > 5

      @loadContent(hiddenButtons.join(''))
      @toggle()

    @element.click (event) =>
      buttonName = jQuery(event.target).closest('[data-button]').data('button')
      button = @container.find(".mercury-#{buttonName}-button")
      button.click()


  windowResize: ->
    if @containerWidth > jQuery(window).width() then @trigger.show() else @trigger.hide()
    @hide()


  position: (keepVisible) ->
    @element.css({top: 0, left: 0, display: 'block', visibility: 'hidden'})
    position = @trigger.offset()
    width = @element.width()

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

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

Version data entries

30 entries across 30 versions & 3 rubygems

Version Path
kiteditor-1.0.25 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.24 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.23 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.22 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.21 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.20 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.19 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.18 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.17 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.16 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.14 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.13 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.11 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.10 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.9 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.8 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.7 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.6 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.5 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee
kiteditor-1.0.4 vendor/assets/javascripts/mercury/toolbar.expander.js.coffee