Sha256: 52bf3ae8c48a18f1bf9f3c46ce4fb90ad809daa7112009af7759e94731a6db4d

Contents?: true

Size: 1.07 KB

Versions: 28

Compression:

Stored size: 1.07 KB

Contents

/* global Blacklight */

Blacklight.onLoad(function() {
  'use strict';

  $('body').on('mouseenter', '.blacklight-icons.svg_tooltip svg', function() {
    var svgTitle = $(this).find('title');
    var titleText = svgTitle && svgTitle.text();

    if (titleText !== undefined && titleText !== '') {
      $(this).tooltip({ placement: 'bottom', title: titleText });
      $(this).tooltip('show');

      // Store the original title in the data-original-title attribute
      // and remove the title element on mouseenter.
      // This prevents the title from interfering w/ Bootstrap's tooltip.
      $(this).attr('data-original-title', titleText);
      svgTitle.remove();
    }
  });

  $('body').on('mouseleave', '.blacklight-icons.svg_tooltip svg', function() {
    var originalTitle = $(this).attr('data-original-title');

    if (originalTitle !== undefined && originalTitle !== '') {
      // Restore the SVG title element from data-original-title on mouseleave
      $(this).prepend($('<title>' + originalTitle + '</title>'));
      $(this).attr('data-original-title', '');
    }
  });
});

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
geoblacklight-4.0.0.pre.alpha app/assets/javascripts/geoblacklight/modules/svg_tooltips.js
geoblacklight-3.4.0 app/assets/javascripts/geoblacklight/modules/svg_tooltips.js
geoblacklight-3.3.1 app/assets/javascripts/geoblacklight/modules/svg_tooltips.js
geoblacklight-3.3.0 app/assets/javascripts/geoblacklight/modules/svg_tooltips.js
geoblacklight-3.2.0 app/assets/javascripts/geoblacklight/modules/svg_tooltips.js
geoblacklight-3.1.0 app/assets/javascripts/geoblacklight/modules/svg_tooltips.js
geoblacklight-3.0.1 app/assets/javascripts/geoblacklight/modules/svg_tooltips.js
geoblacklight-3.0.0 app/assets/javascripts/geoblacklight/modules/svg_tooltips.js