bootstrap.js 138 KB
Newer Older
Jacob Thornton's avatar
Jacob Thornton committed
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
                         this._isEnabled = true;
                    } }, { key: 'disable', value: function disable() {
                         this._isEnabled = false;
                    } }, { key: 'toggleEnabled', value: function toggleEnabled() {
                         this._isEnabled = !this._isEnabled;
                    } }, { key: 'toggle', value: function toggle(event) {
                         var context = this;var dataKey = this.constructor.DATA_KEY;if (event) {
                              context = $(event.currentTarget).data(dataKey);if (!context) {
                                   context = new this.constructor(event.currentTarget, this._getDelegateConfig());$(event.currentTarget).data(dataKey, context);
                              }context._activeTrigger.click = !context._activeTrigger.click;if (context._isWithActiveTrigger()) {
                                   context._enter(null, context);
                              } else {
                                   context._leave(null, context);
                              }
                         } else {
                              $(context.getTipElement()).hasClass(ClassName.IN) ? context._leave(null, context) : context._enter(null, context);
                         }
                    } }, { key: 'dispose', value: function dispose() {
                         clearTimeout(this._timeout);this.cleanupTether();$.removeData(this.element, this.constructor.DATA_KEY);$(this.element).off(this.constructor.EVENT_KEY);if (this.tip) {
                              $(this.tip).remove();
                         }this._isEnabled = null;this._timeout = null;this._hoverState = null;this._activeTrigger = null;this._tether = null;this.element = null;this.config = null;this.tip = null;
                    } }, { key: 'show', value: function show() {
                         var _this16 = this;var showEvent = $.Event(this.constructor.Event.SHOW);if (this.isWithContent() && this._isEnabled) {
                              $(this.element).trigger(showEvent);var isInTheDom = $.contains(this.element.ownerDocument.documentElement, this.element);if (showEvent.isDefaultPrevented() || !isInTheDom) {
                                   return;
                              }var tip = this.getTipElement();var tipId = Util.getUID(this.constructor.NAME);tip.setAttribute('id', tipId);this.element.setAttribute('aria-describedby', tipId);this.setContent();if (this.config.animation) {
                                   $(tip).addClass(ClassName.FADE);
                              }var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;var attachment = this._getAttachment(placement);$(tip).data(this.constructor.DATA_KEY, this).appendTo(document.body);$(this.element).trigger(this.constructor.Event.INSERTED);this._tether = new Tether({ element: tip, target: this.element, attachment: attachment, classes: TetherClass, classPrefix: CLASS_PREFIX, offset: this.config.offset, constraints: this.config.constraints });Util.reflow(tip);this._tether.position();$(tip).addClass(ClassName.IN);var complete = function complete() {
                                   var prevHoverState = _this16._hoverState;_this16._hoverState = null;$(_this16.element).trigger(_this16.constructor.Event.SHOWN);if (prevHoverState === HoverState.OUT) {
                                        _this16._leave(null, _this16);
                                   }
                              };Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE) ? $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(Tooltip._TRANSITION_DURATION) : complete();
                         }
                    } }, { key: 'hide', value: function hide(callback) {
                         var _this17 = this;var tip = this.getTipElement();var hideEvent = $.Event(this.constructor.Event.HIDE);var complete = function complete() {
                              if (_this17._hoverState !== HoverState.IN && tip.parentNode) {
                                   tip.parentNode.removeChild(tip);
                              }_this17.element.removeAttribute('aria-describedby');$(_this17.element).trigger(_this17.constructor.Event.HIDDEN);_this17.cleanupTether();if (callback) {
                                   callback();
                              }
                         };$(this.element).trigger(hideEvent);if (hideEvent.isDefaultPrevented()) {
                              return;
                         }$(tip).removeClass(ClassName.IN);if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) {
                              $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
                         } else {
                              complete();
                         }this._hoverState = '';
                    } }, { key: 'isWithContent', // protected
                    value: function isWithContent() {
                         return !!this.getTitle();
                    } }, { key: 'getTipElement', value: function getTipElement() {
                         return this.tip = this.tip || $(this.config.template)[0];
                    } }, { key: 'setContent', value: function setContent() {
                         var tip = this.getTipElement();var title = this.getTitle();var method = this.config.html ? 'innerHTML' : 'innerText';$(tip).find(Selector.TOOLTIP_INNER)[0][method] = title;$(tip).removeClass(ClassName.FADE).removeClass(ClassName.IN);this.cleanupTether();
                    } }, { key: 'getTitle', value: function getTitle() {
                         var title = this.element.getAttribute('data-original-title');if (!title) {
                              title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
                         }return title;
                    } }, { key: 'cleanupTether', value: function cleanupTether() {
                         if (this._tether) {
                              this._tether.destroy(); // clean up after tether's junk classes
                              // remove after they fix issue
                              // (https://github.com/HubSpot/tether/issues/36)
                              $(this.element).removeClass(this._removeTetherClasses);$(this.tip).removeClass(this._removeTetherClasses);
                         }
                    } }, { key: '_getAttachment', // private
                    value: function _getAttachment(placement) {
                         return AttachmentMap[placement.toUpperCase()];
                    } }, { key: '_setListeners', value: function _setListeners() {
                         var _this18 = this;var triggers = this.config.trigger.split(' ');triggers.forEach(function (trigger) {
                              if (trigger === 'click') {
                                   $(_this18.element).on(_this18.constructor.Event.CLICK, _this18.config.selector, $.proxy(_this18.toggle, _this18));
                              } else if (trigger !== Trigger.MANUAL) {
                                   var eventIn = trigger == Trigger.HOVER ? _this18.constructor.Event.MOUSEENTER : _this18.constructor.Event.FOCUSIN;var eventOut = trigger == Trigger.HOVER ? _this18.constructor.Event.MOUSELEAVE : _this18.constructor.Event.FOCUSOUT;$(_this18.element).on(eventIn, _this18.config.selector, $.proxy(_this18._enter, _this18)).on(eventOut, _this18.config.selector, $.proxy(_this18._leave, _this18));
                              }
                         });if (this.config.selector) {
                              this.config = $.extend({}, this.config, { trigger: 'manual', selector: '' });
                         } else {
                              this._fixTitle();
                         }
                    } }, { key: '_removeTetherClasses', value: function _removeTetherClasses(i, css) {
                         return ((css.baseVal || css).match(new RegExp('(^|\\s)' + CLASS_PREFIX + '-\\S+', 'g')) || []).join(' ');
                    } }, { key: '_fixTitle', value: function _fixTitle() {
                         var titleType = typeof this.element.getAttribute('data-original-title');if (this.element.getAttribute('title') || titleType !== 'string') {
                              this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');this.element.setAttribute('title', '');
                         }
                    } }, { key: '_enter', value: function _enter(event, context) {
                         var dataKey = this.constructor.DATA_KEY;context = context || $(event.currentTarget).data(dataKey);if (!context) {
                              context = new this.constructor(event.currentTarget, this._getDelegateConfig());$(event.currentTarget).data(dataKey, context);
                         }if (event) {
                              context._activeTrigger[event.type == 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
                         }if ($(context.getTipElement()).hasClass(ClassName.IN) || context._hoverState === HoverState.IN) {
                              context._hoverState = HoverState.IN;return;
                         }clearTimeout(context._timeout);context._hoverState = HoverState.IN;if (!context.config.delay || !context.config.delay.show) {
                              context.show();return;
                         }context._timeout = setTimeout(function () {
                              if (context._hoverState === HoverState.IN) {
                                   context.show();
                              }
                         }, context.config.delay.show);
                    } }, { key: '_leave', value: function _leave(event, context) {
                         var dataKey = this.constructor.DATA_KEY;context = context || $(event.currentTarget).data(dataKey);if (!context) {
                              context = new this.constructor(event.currentTarget, this._getDelegateConfig());$(event.currentTarget).data(dataKey, context);
                         }if (event) {
                              context._activeTrigger[event.type == 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
                         }if (context._isWithActiveTrigger()) {
                              return;
                         }clearTimeout(context._timeout);context._hoverState = HoverState.OUT;if (!context.config.delay || !context.config.delay.hide) {
                              context.hide();return;
                         }context._timeout = setTimeout(function () {
                              if (context._hoverState === HoverState.OUT) {
                                   context.hide();
                              }
                         }, context.config.delay.hide);
                    } }, { key: '_isWithActiveTrigger', value: function _isWithActiveTrigger() {
                         for (var trigger in this._activeTrigger) {
                              if (this._activeTrigger[trigger]) {
                                   return true;
                              }
                         }return false;
                    } }, { key: '_getConfig', value: function _getConfig(config) {
                         config = $.extend({}, this.constructor.Default, $(this.element).data(), config);if (config.delay && typeof config.delay === 'number') {
                              config.delay = { show: config.delay, hide: config.delay };
                         }Util.typeCheckConfig(NAME, config, this.constructor.DefaultType);return config;
                    } }, { key: '_getDelegateConfig', value: function _getDelegateConfig() {
                         var config = {};if (this.config) {
                              for (var key in this.config) {
                                   var value = this.config[key];if (this.constructor.Default[key] !== value) {
                                        config[key] = value;
                                   }
                              }
                         }return config;
                    } }], [{ key: '_jQueryInterface', // static
                    value: function _jQueryInterface(config) {
                         return this.each(function () {
                              var data = $(this).data(DATA_KEY);var _config = typeof config === 'object' ? config : null;if (!data && /destroy|hide/.test(config)) {
                                   return;
                              }if (!data) {
                                   data = new Tooltip(this, _config);$(this).data(DATA_KEY, data);
                              }if (typeof config === 'string') {
                                   data[config]();
                              }
                         });
                    } }, { key: 'VERSION', // getters
                    get: function get() {
                         return VERSION;
                    } }, { key: 'Default', get: function get() {
                         return Default;
                    } }, { key: 'NAME', get: function get() {
                         return NAME;
                    } }, { key: 'DATA_KEY', get: function get() {
                         return DATA_KEY;
                    } }, { key: 'Event', get: function get() {
                         return Event;
                    } }, { key: 'EVENT_KEY', get: function get() {
                         return EVENT_KEY;
                    } }, { key: 'DefaultType', get: function get() {
                         return DefaultType;
                    } }]);return Tooltip;
          })(); /**
                * ------------------------------------------------------------------------
                * jQuery
                * ------------------------------------------------------------------------
                */$.fn[NAME] = Tooltip._jQueryInterface;$.fn[NAME].Constructor = Tooltip;$.fn[NAME].noConflict = function () {
               $.fn[NAME] = JQUERY_NO_CONFLICT;return Tooltip._jQueryInterface;
          };return Tooltip;
     })(jQuery); /**
                 * --------------------------------------------------------------------------
                 * Bootstrap (v4.0.0): popover.js
                 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
                 * --------------------------------------------------------------------------
                 */var Popover = (function ($) {
          /**
          * ------------------------------------------------------------------------
          * Constants
          * ------------------------------------------------------------------------
          */var NAME = 'popover';var VERSION = '4.0.0';var DATA_KEY = 'bs.popover';var EVENT_KEY = '.' + DATA_KEY;var JQUERY_NO_CONFLICT = $.fn[NAME];var Default = $.extend({}, Tooltip.Default, { placement: 'right', trigger: 'click', content: '', template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-title"></h3>' + '<div class="popover-content"></div></div>' });var DefaultType = $.extend({}, Tooltip.DefaultType, { content: '(string|function)' });var ClassName = { FADE: 'fade', IN: 'in' };var Selector = { TITLE: '.popover-title', CONTENT: '.popover-content', ARROW: '.popover-arrow' };var Event = { HIDE: 'hide' + EVENT_KEY, HIDDEN: 'hidden' + EVENT_KEY, SHOW: 'show' + EVENT_KEY, SHOWN: 'shown' + EVENT_KEY, INSERTED: 'inserted' + EVENT_KEY, CLICK: 'click' + EVENT_KEY, FOCUSIN: 'focusin' + EVENT_KEY, FOCUSOUT: 'focusout' + EVENT_KEY, MOUSEENTER: 'mouseenter' + EVENT_KEY, MOUSELEAVE: 'mouseleave' + EVENT_KEY }; /**
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               * ------------------------------------------------------------------------
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               * Class Definition
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               * ------------------------------------------------------------------------
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               */var Popover = (function (_Tooltip) {
               function Popover() {
                    _classCallCheck(this, Popover);if (_Tooltip != null) {
                         _Tooltip.apply(this, arguments);
                    }
               }_inherits(Popover, _Tooltip);_createClass(Popover, [{ key: 'isWithContent', // overrides
                    value: function isWithContent() {
                         return this.getTitle() || this._getContent();
                    } }, { key: 'getTipElement', value: function getTipElement() {
                         return this.tip = this.tip || $(this.config.template)[0];
                    } }, { key: 'setContent', value: function setContent() {
                         var tip = this.getTipElement();var title = this.getTitle();var content = this._getContent();var titleElement = $(tip).find(Selector.TITLE)[0];if (titleElement) {
                              titleElement[this.config.html ? 'innerHTML' : 'innerText'] = title;
                         } // we use append for html objects to maintain js events
                         $(tip).find(Selector.CONTENT).children().detach().end()[this.config.html ? typeof content === 'string' ? 'html' : 'append' : 'text'](content);$(tip).removeClass(ClassName.FADE).removeClass(ClassName.IN);this.cleanupTether();
                    } }, { key: '_getContent', // private
                    value: function _getContent() {
                         return this.element.getAttribute('data-content') || (typeof this.config.content == 'function' ? this.config.content.call(this.element) : this.config.content);
                    } }], [{ key: '_jQueryInterface', // static
                    value: function _jQueryInterface(config) {
                         return this.each(function () {
                              var data = $(this).data(DATA_KEY);var _config = typeof config === 'object' ? config : null;if (!data && /destroy|hide/.test(config)) {
                                   return;
                              }if (!data) {
                                   data = new Popover(this, _config);$(this).data(DATA_KEY, data);
                              }if (typeof config === 'string') {
                                   data[config]();
                              }
                         });
                    } }, { key: 'VERSION', // getters
                    get: function get() {
                         return VERSION;
                    } }, { key: 'Default', get: function get() {
                         return Default;
                    } }, { key: 'NAME', get: function get() {
                         return NAME;
                    } }, { key: 'DATA_KEY', get: function get() {
                         return DATA_KEY;
                    } }, { key: 'Event', get: function get() {
                         return Event;
                    } }, { key: 'EVENT_KEY', get: function get() {
                         return EVENT_KEY;
                    } }, { key: 'DefaultType', get: function get() {
                         return DefaultType;
                    } }]);return Popover;
          })(Tooltip); /**
                       * ------------------------------------------------------------------------
                       * jQuery
                       * ------------------------------------------------------------------------
                       */$.fn[NAME] = Popover._jQueryInterface;$.fn[NAME].Constructor = Popover;$.fn[NAME].noConflict = function () {
               $.fn[NAME] = JQUERY_NO_CONFLICT;return Popover._jQueryInterface;
          };return Popover;
     })(jQuery);
1234
})(jQuery);
For faster browsing, not all history is shown. View entire blame