extend-jquery.js 842 B

1234567891011121314151617181920212223242526272829303132333435
  1. define(['jquery'],
  2. function ($) {
  3. 'use strict';
  4. /**
  5. * jQuery extensions
  6. */
  7. var $win = $(window);
  8. $.fn.place_tt = (function () {
  9. var defaults = {
  10. offset: 5,
  11. };
  12. return function (x, y, opts) {
  13. opts = $.extend(true, {}, defaults, opts);
  14. return this.each(function () {
  15. var $tooltip = $(this), width, height;
  16. $tooltip.addClass('grafana-tooltip');
  17. $("#tooltip").remove();
  18. $tooltip.appendTo(document.body);
  19. width = $tooltip.outerWidth(true);
  20. height = $tooltip.outerHeight(true);
  21. $tooltip.css('left', x + opts.offset + width > $win.width() ? x - opts.offset - width : x + opts.offset);
  22. $tooltip.css('top', y + opts.offset + height > $win.height() ? y - opts.offset - height : y + opts.offset);
  23. });
  24. };
  25. })();
  26. return $;
  27. });