Sha256: e96e732ebf43c4fa99ae556c34efc0a23286a33fa5d5e610b17eed99bbe44837

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 KB

Contents

class @Mercury.Statusbar

  constructor: (@options = {}) ->
    @visible = @options.visible
    @build()
    @bindEvents()


  build: ->
    @element = jQuery('<div>', {class: 'mercury-statusbar'})
    @aboutElement = jQuery('<a>', {class: "mercury-statusbar-about"}).appendTo(@element).html("Mercury Editor v#{Mercury.version}")
    @pathElement = jQuery('<div>', {class: 'mercury-statusbar-path'}).appendTo(@element)

    @element.css({visibility: 'hidden'}) unless @visible
    @element.appendTo(jQuery(@options.appendTo).get(0) ? 'body')


  bindEvents: ->
    Mercury.bind 'region:update', (event, options) =>
      @setPath(options.region.path()) if options.region && jQuery.type(options.region.path) == 'function'

    @aboutElement.click =>
      Mercury.lightview('/mercury/lightviews/about.html', {title: "About Mercury Editor v#{Mercury.version}"})


  height: ->
    @element.outerHeight()


  top: ->
    top =  @element.offset().top
    currentTop = if parseInt(@element.css('bottom')) < 0 then top - @element.outerHeight() else top
    if @visible then currentTop else top + @element.outerHeight()


  setPath: (elements) ->
    path = []
    path.push("<a>#{element.tagName.toLowerCase()}</a>") for element in elements

    @pathElement.html("<span><strong>Path: </strong>#{path.reverse().join(' &raquo; ')}</span>")


  show: ->
    @visible = true
    @element.css({opacity: 0, visibility: 'visible'})
    @element.animate({opacity: 1}, 200, 'easeInOutSine')


  hide: ->
    @visible = false
    @element.css({visibility: 'hidden'})

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mercury-rails-0.2.3 vendor/assets/javascripts/mercury/statusbar.js.coffee
mercury-rails-0.2.0 vendor/assets/javascripts/mercury/statusbar.js.coffee