Sha256: 34414f39d65a926c14a5d2f30705cdb72ed7f564e2c4f2daa3d6e6bacd5c415e

Contents?: true

Size: 1.12 KB

Versions: 26

Compression:

Stored size: 1.12 KB

Contents

(function ($) {
  // register namespace
  $.extend(true, window, {
    "Slick": {
      "AutoTooltips": AutoTooltips
    }
  });


  function AutoTooltips(options) {
    var _grid;
    var _self = this;
    var _defaults = {
      maxToolTipLength: null
    };

    function init(grid) {
      options = $.extend(true, {}, _defaults, options);
      _grid = grid;
      _grid.onMouseEnter.subscribe(handleMouseEnter);
    }

    function destroy() {
      _grid.onMouseEnter.unsubscribe(handleMouseEnter);
    }

    function handleMouseEnter(e, args) {
      var cell = _grid.getCellFromEvent(e);
      if (cell) {
        var node = _grid.getCellNode(cell.row, cell.cell);
        if ($(node).innerWidth() < node.scrollWidth) {
          var text = $.trim($(node).text());
          if (options.maxToolTipLength && text.length > options.maxToolTipLength) {
            text = text.substr(0, options.maxToolTipLength - 3) + "...";
          }
          $(node).attr("title", text);
        } else {
          $(node).attr("title", "");
        }
      }
    }

    $.extend(this, {
      "init": init,
      "destroy": destroy
    });
  }
})(jQuery);

Version data entries

26 entries across 25 versions & 3 rubygems

Version Path
omf_web-0.9.3 share/htdocs/vendor/slickgrid-200512/plugins/slick.autotooltips.js
omf_web-0.9.1 share/htdocs/vendor/slickgrid-200512/plugins/slick.autotooltips.js
omf_web-0.9 share/htdocs/vendor/slickgrid/plugins/slick.autotooltips.js
omf_web-0.9 share/htdocs/vendor/slickgrid-200512/plugins/slick.autotooltips.js
slickgrid-rails-0.2.0 vendor/assets/javascripts/slick/plugins/autotooltips.js
slickgrid-rails-0.1.0 vendor/assets/javascripts/slick/plugins/autotooltips.js