diff options
author | Marvin Borner | 2018-07-13 19:06:45 +0200 |
---|---|---|
committer | Marvin Borner | 2018-07-13 19:06:45 +0200 |
commit | 6fcfb7c04d32e1c8b26a312295bf7ac3ec2d2ad7 (patch) | |
tree | dbc87ef16fa01d5d99116de283592b8fe5e02944 /public/bower_components/morris.js/lib/morris.hover.coffee | |
parent | dfd839f27146df0ad0494e11734fc7d310c70ebf (diff) |
Fixed many permissions and began admin interface
Diffstat (limited to 'public/bower_components/morris.js/lib/morris.hover.coffee')
-rw-r--r-- | public/bower_components/morris.js/lib/morris.hover.coffee | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/public/bower_components/morris.js/lib/morris.hover.coffee b/public/bower_components/morris.js/lib/morris.hover.coffee new file mode 100644 index 0000000..530cb08 --- /dev/null +++ b/public/bower_components/morris.js/lib/morris.hover.coffee @@ -0,0 +1,44 @@ +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() |