File: demos/startbootstrap-sb-admin-2/bower_components/morrisjs/lib/morris.hover.coffee

Recommend this page to a friend!
  Classes of Emmanuel Podvin   Blapy   demos/startbootstrap-sb-admin-2/bower_components/morrisjs/lib/morris.hover.coffee   Download  
File: demos/startbootstrap-sb-admin-2/bower_components/morrisjs/lib/morris.hover.coffee
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Blapy
jQuery plugin to load linked pages using AJAX
Author: By
Last change: Update of demos/startbootstrap-sb-admin-2/bower_components/morrisjs/lib/morris.hover.coffee
Date: 3 years ago
Size: 1,108 bytes
 

Contents

Class file image Download
class Morris.Hover # Displays contextual information in a floating HTML div. @defaults: class: 'morris-hover morris-default-style' constructor: (options = {}) -> @options = $.extend {}, Morris.Hover.defaults, options @el = $ "<div class='#{@options.class}'></div>" @el.hide() @options.parent.append(@el) update: (html, x, y) -> if not html @hide() else @html(html) @show() @moveTo(x, y) html: (content) -> @el.html(content) moveTo: (x, y) -> parentWidth = @options.parent.innerWidth() parentHeight = @options.parent.innerHeight() hoverWidth = @el.outerWidth() hoverHeight = @el.outerHeight() left = Math.min(Math.max(0, x - hoverWidth / 2), parentWidth - hoverWidth) if y? top = y - hoverHeight - 10 if top < 0 top = y + 10 if top + hoverHeight > parentHeight top = parentHeight / 2 - hoverHeight / 2 else top = parentHeight / 2 - hoverHeight / 2 @el.css(left: left + "px", top: parseInt(top) + "px") show: -> @el.show() hide: -> @el.hide()