Sha256: eee7b5b3678fcb17d2e63564e7a6b3b5123c15214b41938b8b1a84d9eef67b82

Contents?: true

Size: 1.53 KB

Versions: 9

Compression:

Stored size: 1.53 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.on 'region:update', (event, options) =>
      @setPath(options.region.path()) if options.region && jQuery.type(options.region.path) == 'function'

    @aboutElement.on 'click', =>
      Mercury.lightview('/mercury/lightviews/about.html', {title: "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>#{Mercury.I18n('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

9 entries across 9 versions & 2 rubygems

Version Path
mercury-rails-0.9.0 app/assets/javascripts/mercury/statusbar.js.coffee
mercury-rails-0.8.0 app/assets/javascripts/mercury/statusbar.js.coffee
mercury-rails-0.7.1 app/assets/javascripts/mercury/statusbar.js.coffee
mercury-rails-0.7.0 app/assets/javascripts/mercury/statusbar.js.coffee
mercury-rails-0.6.0 app/assets/javascripts/mercury/statusbar.js.coffee
mercury-rails-0.5.0 app/assets/javascripts/mercury/statusbar.js.coffee
kuji-mercury-rails-0.3.3 vendor/assets/javascripts/mercury/statusbar.js.coffee
kuji-mercury-rails-0.3.2 vendor/assets/javascripts/mercury/statusbar.js.coffee
mercury-rails-0.3.1 vendor/assets/javascripts/mercury/statusbar.js.coffee