Sha256: 429a69d800d6150246d6b8a159c162b29169616d67ef0785680d8b0189c0ba88
Contents?: true
Size: 1.76 KB
Versions: 25
Compression:
Stored size: 1.76 KB
Contents
class @Mercury.SnippetToolbar extends Mercury.Toolbar constructor: (@document, @options = {}) -> super(@options) build: -> @element = jQuery('<div>', {class: 'mercury-toolbar mercury-snippet-toolbar', style: 'display:none'}) @element.appendTo(jQuery(@options.appendTo).get(0) ? 'body') for own buttonName, options of Mercury.config.toolbars.snippetable button = @buildButton(buttonName, options) button.appendTo(@element) if button bindEvents: -> Mercury.on 'show:toolbar', (event, options) => return unless options.snippet options.snippet.mouseout => @hide() @show(options.snippet) Mercury.on 'hide:toolbar', (event, options) => return unless options.type && options.type == 'snippet' @hide(options.immediately) @element.mousemove => clearTimeout(@hideTimeout) @element.mouseout => @hide() jQuery(@document).on 'scroll', => @position() if @visible show: (@snippet) -> Mercury.tooltip.hide() @position() @appear() position: -> offset = @snippet.offset() top = offset.top + Mercury.displayRect.top - jQuery(@document).scrollTop() - @height() + 10 left = offset.left - jQuery(@document).scrollLeft() @element.css { top: top left: left } appear: -> clearTimeout(@hideTimeout) return if @visible @visible = true @element.css({display: 'block', opacity: 0}) @element.stop().animate({opacity: 1}, 200, 'easeInOutSine') hide: (immediately = false) -> clearTimeout(@hideTimeout) if immediately @element.hide() @visible = false else @hideTimeout = setTimeout 500, => @element.stop().animate {opacity: 0}, 300, 'easeInOutSine', => @element.hide() @visible = false
Version data entries
25 entries across 25 versions & 3 rubygems