Sha256: 54192807f3dd191c286ce630ec1338422ea0b514f80a5839a547b9efc7cda23b

Contents?: true

Size: 1.76 KB

Versions: 53

Compression:

Stored size: 1.76 KB

Contents

$(function () {
  $('[data-toggle="popover"]').popover();
});

$.fn.popover.Constructor.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
  return  placement == 'bottom' ?       { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
          placement == 'top' ?          { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
          placement == 'left' ?         { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
          placement == 'bottomleft' ?   { top: pos.top + pos.height, left: (pos.left - actualWidth+ pos.width)  } :
          placement == 'bottomright' ?  { top: pos.top + pos.height, left: pos.left } :
          /* placement == 'right' */    { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
};

$.fn.popover.Constructor.prototype.replaceArrow = function (delta, dimension, isHorizontal) {
  var $arrow   = this.arrow();
  var arrowWidth  = $arrow[0].offsetWidth;
  var arrowHeight = $arrow[0].offsetHeight;

  var $tip = this.tip();
  var tipWidth = $tip[0].offsetWidth;
  var tipHeight = $tip[0].offsetHeight;

  var $button = this.$element;
  var buttonWidth = $button[0].offsetWidth;
  var buttonHeight = $button[0].offsetHeight;

  switch(this.options.placement) {
    case "bottomleft":
      var centerOfButton = tipWidth - buttonWidth / 2;
      this.arrow().css('left', centerOfButton + "px");
      break;
    case "bottomright":
      var centerOfButton = buttonWidth / 2;
      this.arrow().css('left', centerOfButton + "px");
      break;
    default:
      this.arrow()
        .css(isHorizontal ? 'left' : 'top', 50 * (1 - delta / dimension) + '%')
        .css(isHorizontal ? 'top' : 'left', '')
  }
};

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
forever_style_guide-3.0.0 app/assets/javascripts/forever_style_guide/popover.js
forever_style_guide-2.0.3 app/assets/javascripts/forever_style_guide/popover.js
forever_style_guide-2.0.2 app/assets/javascripts/forever_style_guide/popover.js
forever_style_guide-2.0.1 app/assets/javascripts/forever_style_guide/popover.js
forever_style_guide-2.0.0 app/assets/javascripts/forever_style_guide/popover.js
forever_style_guide-1.2.11 app/assets/javascripts/forever_style_guide/popover.js
forever_style_guide-1.2.10 app/assets/javascripts/forever_style_guide/popover.js
forever_style_guide-1.2.9 app/assets/javascripts/forever_style_guide/popover.js
forever_style_guide-1.2.8 app/assets/javascripts/forever_style_guide/popover.js
forever_style_guide-1.2.7 app/assets/javascripts/forever_style_guide/popover.js
forever_style_guide-1.2.5 app/assets/javascripts/forever_style_guide/popover.js
forever_style_guide-1.2.4 app/assets/javascripts/forever_style_guide/popover.js
forever_style_guide-1.2.3 app/assets/javascripts/forever_style_guide/popover.js