/js/bootstrap.bundle.js

https://bitbucket.org/denissilva/cgpdi_admin · JavaScript · 6328 lines · 3950 code · 1039 blank · 1339 comment · 671 complexity · 6866f102282d95443edf73ca112b117b MD5 · raw file

Large files are truncated click here to view the full file

  1. /*!
  2. * Bootstrap v4.0.0 (https://getbootstrap.com)
  3. * Copyright 2011-2018 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  4. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('jquery')) :
  8. typeof define === 'function' && define.amd ? define(['exports', 'jquery'], factory) :
  9. (factory((global.bootstrap = {}),global.jQuery));
  10. }(this, (function (exports,$) { 'use strict';
  11. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  12. function _defineProperties(target, props) {
  13. for (var i = 0; i < props.length; i++) {
  14. var descriptor = props[i];
  15. descriptor.enumerable = descriptor.enumerable || false;
  16. descriptor.configurable = true;
  17. if ("value" in descriptor) descriptor.writable = true;
  18. Object.defineProperty(target, descriptor.key, descriptor);
  19. }
  20. }
  21. function _createClass(Constructor, protoProps, staticProps) {
  22. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  23. if (staticProps) _defineProperties(Constructor, staticProps);
  24. return Constructor;
  25. }
  26. function _extends() {
  27. _extends = Object.assign || function (target) {
  28. for (var i = 1; i < arguments.length; i++) {
  29. var source = arguments[i];
  30. for (var key in source) {
  31. if (Object.prototype.hasOwnProperty.call(source, key)) {
  32. target[key] = source[key];
  33. }
  34. }
  35. }
  36. return target;
  37. };
  38. return _extends.apply(this, arguments);
  39. }
  40. function _inheritsLoose(subClass, superClass) {
  41. subClass.prototype = Object.create(superClass.prototype);
  42. subClass.prototype.constructor = subClass;
  43. subClass.__proto__ = superClass;
  44. }
  45. /**
  46. * --------------------------------------------------------------------------
  47. * Bootstrap (v4.0.0): util.js
  48. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  49. * --------------------------------------------------------------------------
  50. */
  51. var Util = function ($$$1) {
  52. /**
  53. * ------------------------------------------------------------------------
  54. * Private TransitionEnd Helpers
  55. * ------------------------------------------------------------------------
  56. */
  57. var transition = false;
  58. var MAX_UID = 1000000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  59. function toType(obj) {
  60. return {}.toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase();
  61. }
  62. function getSpecialTransitionEndEvent() {
  63. return {
  64. bindType: transition.end,
  65. delegateType: transition.end,
  66. handle: function handle(event) {
  67. if ($$$1(event.target).is(this)) {
  68. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  69. }
  70. return undefined; // eslint-disable-line no-undefined
  71. }
  72. };
  73. }
  74. function transitionEndTest() {
  75. if (typeof window !== 'undefined' && window.QUnit) {
  76. return false;
  77. }
  78. return {
  79. end: 'transitionend'
  80. };
  81. }
  82. function transitionEndEmulator(duration) {
  83. var _this = this;
  84. var called = false;
  85. $$$1(this).one(Util.TRANSITION_END, function () {
  86. called = true;
  87. });
  88. setTimeout(function () {
  89. if (!called) {
  90. Util.triggerTransitionEnd(_this);
  91. }
  92. }, duration);
  93. return this;
  94. }
  95. function setTransitionEndSupport() {
  96. transition = transitionEndTest();
  97. $$$1.fn.emulateTransitionEnd = transitionEndEmulator;
  98. if (Util.supportsTransitionEnd()) {
  99. $$$1.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  100. }
  101. }
  102. function escapeId(selector) {
  103. // We escape IDs in case of special selectors (selector = '#myId:something')
  104. // $.escapeSelector does not exist in jQuery < 3
  105. selector = typeof $$$1.escapeSelector === 'function' ? $$$1.escapeSelector(selector).substr(1) : selector.replace(/(:|\.|\[|\]|,|=|@)/g, '\\$1');
  106. return selector;
  107. }
  108. /**
  109. * --------------------------------------------------------------------------
  110. * Public Util Api
  111. * --------------------------------------------------------------------------
  112. */
  113. var Util = {
  114. TRANSITION_END: 'bsTransitionEnd',
  115. getUID: function getUID(prefix) {
  116. do {
  117. // eslint-disable-next-line no-bitwise
  118. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  119. } while (document.getElementById(prefix));
  120. return prefix;
  121. },
  122. getSelectorFromElement: function getSelectorFromElement(element) {
  123. var selector = element.getAttribute('data-target');
  124. if (!selector || selector === '#') {
  125. selector = element.getAttribute('href') || '';
  126. } // If it's an ID
  127. if (selector.charAt(0) === '#') {
  128. selector = escapeId(selector);
  129. }
  130. try {
  131. var $selector = $$$1(document).find(selector);
  132. return $selector.length > 0 ? selector : null;
  133. } catch (err) {
  134. return null;
  135. }
  136. },
  137. reflow: function reflow(element) {
  138. return element.offsetHeight;
  139. },
  140. triggerTransitionEnd: function triggerTransitionEnd(element) {
  141. $$$1(element).trigger(transition.end);
  142. },
  143. supportsTransitionEnd: function supportsTransitionEnd() {
  144. return Boolean(transition);
  145. },
  146. isElement: function isElement(obj) {
  147. return (obj[0] || obj).nodeType;
  148. },
  149. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  150. for (var property in configTypes) {
  151. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  152. var expectedTypes = configTypes[property];
  153. var value = config[property];
  154. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  155. if (!new RegExp(expectedTypes).test(valueType)) {
  156. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  157. }
  158. }
  159. }
  160. }
  161. };
  162. setTransitionEndSupport();
  163. return Util;
  164. }($);
  165. /**
  166. * --------------------------------------------------------------------------
  167. * Bootstrap (v4.0.0): alert.js
  168. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  169. * --------------------------------------------------------------------------
  170. */
  171. var Alert = function ($$$1) {
  172. /**
  173. * ------------------------------------------------------------------------
  174. * Constants
  175. * ------------------------------------------------------------------------
  176. */
  177. var NAME = 'alert';
  178. var VERSION = '4.0.0';
  179. var DATA_KEY = 'bs.alert';
  180. var EVENT_KEY = "." + DATA_KEY;
  181. var DATA_API_KEY = '.data-api';
  182. var JQUERY_NO_CONFLICT = $$$1.fn[NAME];
  183. var TRANSITION_DURATION = 150;
  184. var Selector = {
  185. DISMISS: '[data-dismiss="alert"]'
  186. };
  187. var Event = {
  188. CLOSE: "close" + EVENT_KEY,
  189. CLOSED: "closed" + EVENT_KEY,
  190. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
  191. };
  192. var ClassName = {
  193. ALERT: 'alert',
  194. FADE: 'fade',
  195. SHOW: 'show'
  196. /**
  197. * ------------------------------------------------------------------------
  198. * Class Definition
  199. * ------------------------------------------------------------------------
  200. */
  201. };
  202. var Alert =
  203. /*#__PURE__*/
  204. function () {
  205. function Alert(element) {
  206. this._element = element;
  207. } // Getters
  208. var _proto = Alert.prototype;
  209. // Public
  210. _proto.close = function close(element) {
  211. element = element || this._element;
  212. var rootElement = this._getRootElement(element);
  213. var customEvent = this._triggerCloseEvent(rootElement);
  214. if (customEvent.isDefaultPrevented()) {
  215. return;
  216. }
  217. this._removeElement(rootElement);
  218. };
  219. _proto.dispose = function dispose() {
  220. $$$1.removeData(this._element, DATA_KEY);
  221. this._element = null;
  222. }; // Private
  223. _proto._getRootElement = function _getRootElement(element) {
  224. var selector = Util.getSelectorFromElement(element);
  225. var parent = false;
  226. if (selector) {
  227. parent = $$$1(selector)[0];
  228. }
  229. if (!parent) {
  230. parent = $$$1(element).closest("." + ClassName.ALERT)[0];
  231. }
  232. return parent;
  233. };
  234. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  235. var closeEvent = $$$1.Event(Event.CLOSE);
  236. $$$1(element).trigger(closeEvent);
  237. return closeEvent;
  238. };
  239. _proto._removeElement = function _removeElement(element) {
  240. var _this = this;
  241. $$$1(element).removeClass(ClassName.SHOW);
  242. if (!Util.supportsTransitionEnd() || !$$$1(element).hasClass(ClassName.FADE)) {
  243. this._destroyElement(element);
  244. return;
  245. }
  246. $$$1(element).one(Util.TRANSITION_END, function (event) {
  247. return _this._destroyElement(element, event);
  248. }).emulateTransitionEnd(TRANSITION_DURATION);
  249. };
  250. _proto._destroyElement = function _destroyElement(element) {
  251. $$$1(element).detach().trigger(Event.CLOSED).remove();
  252. }; // Static
  253. Alert._jQueryInterface = function _jQueryInterface(config) {
  254. return this.each(function () {
  255. var $element = $$$1(this);
  256. var data = $element.data(DATA_KEY);
  257. if (!data) {
  258. data = new Alert(this);
  259. $element.data(DATA_KEY, data);
  260. }
  261. if (config === 'close') {
  262. data[config](this);
  263. }
  264. });
  265. };
  266. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  267. return function (event) {
  268. if (event) {
  269. event.preventDefault();
  270. }
  271. alertInstance.close(this);
  272. };
  273. };
  274. _createClass(Alert, null, [{
  275. key: "VERSION",
  276. get: function get() {
  277. return VERSION;
  278. }
  279. }]);
  280. return Alert;
  281. }();
  282. /**
  283. * ------------------------------------------------------------------------
  284. * Data Api implementation
  285. * ------------------------------------------------------------------------
  286. */
  287. $$$1(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
  288. /**
  289. * ------------------------------------------------------------------------
  290. * jQuery
  291. * ------------------------------------------------------------------------
  292. */
  293. $$$1.fn[NAME] = Alert._jQueryInterface;
  294. $$$1.fn[NAME].Constructor = Alert;
  295. $$$1.fn[NAME].noConflict = function () {
  296. $$$1.fn[NAME] = JQUERY_NO_CONFLICT;
  297. return Alert._jQueryInterface;
  298. };
  299. return Alert;
  300. }($);
  301. /**
  302. * --------------------------------------------------------------------------
  303. * Bootstrap (v4.0.0): button.js
  304. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  305. * --------------------------------------------------------------------------
  306. */
  307. var Button = function ($$$1) {
  308. /**
  309. * ------------------------------------------------------------------------
  310. * Constants
  311. * ------------------------------------------------------------------------
  312. */
  313. var NAME = 'button';
  314. var VERSION = '4.0.0';
  315. var DATA_KEY = 'bs.button';
  316. var EVENT_KEY = "." + DATA_KEY;
  317. var DATA_API_KEY = '.data-api';
  318. var JQUERY_NO_CONFLICT = $$$1.fn[NAME];
  319. var ClassName = {
  320. ACTIVE: 'active',
  321. BUTTON: 'btn',
  322. FOCUS: 'focus'
  323. };
  324. var Selector = {
  325. DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
  326. DATA_TOGGLE: '[data-toggle="buttons"]',
  327. INPUT: 'input',
  328. ACTIVE: '.active',
  329. BUTTON: '.btn'
  330. };
  331. var Event = {
  332. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY,
  333. FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY + DATA_API_KEY + " " + ("blur" + EVENT_KEY + DATA_API_KEY)
  334. /**
  335. * ------------------------------------------------------------------------
  336. * Class Definition
  337. * ------------------------------------------------------------------------
  338. */
  339. };
  340. var Button =
  341. /*#__PURE__*/
  342. function () {
  343. function Button(element) {
  344. this._element = element;
  345. } // Getters
  346. var _proto = Button.prototype;
  347. // Public
  348. _proto.toggle = function toggle() {
  349. var triggerChangeEvent = true;
  350. var addAriaPressed = true;
  351. var rootElement = $$$1(this._element).closest(Selector.DATA_TOGGLE)[0];
  352. if (rootElement) {
  353. var input = $$$1(this._element).find(Selector.INPUT)[0];
  354. if (input) {
  355. if (input.type === 'radio') {
  356. if (input.checked && $$$1(this._element).hasClass(ClassName.ACTIVE)) {
  357. triggerChangeEvent = false;
  358. } else {
  359. var activeElement = $$$1(rootElement).find(Selector.ACTIVE)[0];
  360. if (activeElement) {
  361. $$$1(activeElement).removeClass(ClassName.ACTIVE);
  362. }
  363. }
  364. }
  365. if (triggerChangeEvent) {
  366. if (input.hasAttribute('disabled') || rootElement.hasAttribute('disabled') || input.classList.contains('disabled') || rootElement.classList.contains('disabled')) {
  367. return;
  368. }
  369. input.checked = !$$$1(this._element).hasClass(ClassName.ACTIVE);
  370. $$$1(input).trigger('change');
  371. }
  372. input.focus();
  373. addAriaPressed = false;
  374. }
  375. }
  376. if (addAriaPressed) {
  377. this._element.setAttribute('aria-pressed', !$$$1(this._element).hasClass(ClassName.ACTIVE));
  378. }
  379. if (triggerChangeEvent) {
  380. $$$1(this._element).toggleClass(ClassName.ACTIVE);
  381. }
  382. };
  383. _proto.dispose = function dispose() {
  384. $$$1.removeData(this._element, DATA_KEY);
  385. this._element = null;
  386. }; // Static
  387. Button._jQueryInterface = function _jQueryInterface(config) {
  388. return this.each(function () {
  389. var data = $$$1(this).data(DATA_KEY);
  390. if (!data) {
  391. data = new Button(this);
  392. $$$1(this).data(DATA_KEY, data);
  393. }
  394. if (config === 'toggle') {
  395. data[config]();
  396. }
  397. });
  398. };
  399. _createClass(Button, null, [{
  400. key: "VERSION",
  401. get: function get() {
  402. return VERSION;
  403. }
  404. }]);
  405. return Button;
  406. }();
  407. /**
  408. * ------------------------------------------------------------------------
  409. * Data Api implementation
  410. * ------------------------------------------------------------------------
  411. */
  412. $$$1(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE_CARROT, function (event) {
  413. event.preventDefault();
  414. var button = event.target;
  415. if (!$$$1(button).hasClass(ClassName.BUTTON)) {
  416. button = $$$1(button).closest(Selector.BUTTON);
  417. }
  418. Button._jQueryInterface.call($$$1(button), 'toggle');
  419. }).on(Event.FOCUS_BLUR_DATA_API, Selector.DATA_TOGGLE_CARROT, function (event) {
  420. var button = $$$1(event.target).closest(Selector.BUTTON)[0];
  421. $$$1(button).toggleClass(ClassName.FOCUS, /^focus(in)?$/.test(event.type));
  422. });
  423. /**
  424. * ------------------------------------------------------------------------
  425. * jQuery
  426. * ------------------------------------------------------------------------
  427. */
  428. $$$1.fn[NAME] = Button._jQueryInterface;
  429. $$$1.fn[NAME].Constructor = Button;
  430. $$$1.fn[NAME].noConflict = function () {
  431. $$$1.fn[NAME] = JQUERY_NO_CONFLICT;
  432. return Button._jQueryInterface;
  433. };
  434. return Button;
  435. }($);
  436. /**
  437. * --------------------------------------------------------------------------
  438. * Bootstrap (v4.0.0): carousel.js
  439. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  440. * --------------------------------------------------------------------------
  441. */
  442. var Carousel = function ($$$1) {
  443. /**
  444. * ------------------------------------------------------------------------
  445. * Constants
  446. * ------------------------------------------------------------------------
  447. */
  448. var NAME = 'carousel';
  449. var VERSION = '4.0.0';
  450. var DATA_KEY = 'bs.carousel';
  451. var EVENT_KEY = "." + DATA_KEY;
  452. var DATA_API_KEY = '.data-api';
  453. var JQUERY_NO_CONFLICT = $$$1.fn[NAME];
  454. var TRANSITION_DURATION = 600;
  455. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  456. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  457. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  458. var Default = {
  459. interval: 5000,
  460. keyboard: true,
  461. slide: false,
  462. pause: 'hover',
  463. wrap: true
  464. };
  465. var DefaultType = {
  466. interval: '(number|boolean)',
  467. keyboard: 'boolean',
  468. slide: '(boolean|string)',
  469. pause: '(string|boolean)',
  470. wrap: 'boolean'
  471. };
  472. var Direction = {
  473. NEXT: 'next',
  474. PREV: 'prev',
  475. LEFT: 'left',
  476. RIGHT: 'right'
  477. };
  478. var Event = {
  479. SLIDE: "slide" + EVENT_KEY,
  480. SLID: "slid" + EVENT_KEY,
  481. KEYDOWN: "keydown" + EVENT_KEY,
  482. MOUSEENTER: "mouseenter" + EVENT_KEY,
  483. MOUSELEAVE: "mouseleave" + EVENT_KEY,
  484. TOUCHEND: "touchend" + EVENT_KEY,
  485. LOAD_DATA_API: "load" + EVENT_KEY + DATA_API_KEY,
  486. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
  487. };
  488. var ClassName = {
  489. CAROUSEL: 'carousel',
  490. ACTIVE: 'active',
  491. SLIDE: 'slide',
  492. RIGHT: 'carousel-item-right',
  493. LEFT: 'carousel-item-left',
  494. NEXT: 'carousel-item-next',
  495. PREV: 'carousel-item-prev',
  496. ITEM: 'carousel-item'
  497. };
  498. var Selector = {
  499. ACTIVE: '.active',
  500. ACTIVE_ITEM: '.active.carousel-item',
  501. ITEM: '.carousel-item',
  502. NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
  503. INDICATORS: '.carousel-indicators',
  504. DATA_SLIDE: '[data-slide], [data-slide-to]',
  505. DATA_RIDE: '[data-ride="carousel"]'
  506. /**
  507. * ------------------------------------------------------------------------
  508. * Class Definition
  509. * ------------------------------------------------------------------------
  510. */
  511. };
  512. var Carousel =
  513. /*#__PURE__*/
  514. function () {
  515. function Carousel(element, config) {
  516. this._items = null;
  517. this._interval = null;
  518. this._activeElement = null;
  519. this._isPaused = false;
  520. this._isSliding = false;
  521. this.touchTimeout = null;
  522. this._config = this._getConfig(config);
  523. this._element = $$$1(element)[0];
  524. this._indicatorsElement = $$$1(this._element).find(Selector.INDICATORS)[0];
  525. this._addEventListeners();
  526. } // Getters
  527. var _proto = Carousel.prototype;
  528. // Public
  529. _proto.next = function next() {
  530. if (!this._isSliding) {
  531. this._slide(Direction.NEXT);
  532. }
  533. };
  534. _proto.nextWhenVisible = function nextWhenVisible() {
  535. // Don't call next when the page isn't visible
  536. // or the carousel or its parent isn't visible
  537. if (!document.hidden && $$$1(this._element).is(':visible') && $$$1(this._element).css('visibility') !== 'hidden') {
  538. this.next();
  539. }
  540. };
  541. _proto.prev = function prev() {
  542. if (!this._isSliding) {
  543. this._slide(Direction.PREV);
  544. }
  545. };
  546. _proto.pause = function pause(event) {
  547. if (!event) {
  548. this._isPaused = true;
  549. }
  550. if ($$$1(this._element).find(Selector.NEXT_PREV)[0] && Util.supportsTransitionEnd()) {
  551. Util.triggerTransitionEnd(this._element);
  552. this.cycle(true);
  553. }
  554. clearInterval(this._interval);
  555. this._interval = null;
  556. };
  557. _proto.cycle = function cycle(event) {
  558. if (!event) {
  559. this._isPaused = false;
  560. }
  561. if (this._interval) {
  562. clearInterval(this._interval);
  563. this._interval = null;
  564. }
  565. if (this._config.interval && !this._isPaused) {
  566. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  567. }
  568. };
  569. _proto.to = function to(index) {
  570. var _this = this;
  571. this._activeElement = $$$1(this._element).find(Selector.ACTIVE_ITEM)[0];
  572. var activeIndex = this._getItemIndex(this._activeElement);
  573. if (index > this._items.length - 1 || index < 0) {
  574. return;
  575. }
  576. if (this._isSliding) {
  577. $$$1(this._element).one(Event.SLID, function () {
  578. return _this.to(index);
  579. });
  580. return;
  581. }
  582. if (activeIndex === index) {
  583. this.pause();
  584. this.cycle();
  585. return;
  586. }
  587. var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
  588. this._slide(direction, this._items[index]);
  589. };
  590. _proto.dispose = function dispose() {
  591. $$$1(this._element).off(EVENT_KEY);
  592. $$$1.removeData(this._element, DATA_KEY);
  593. this._items = null;
  594. this._config = null;
  595. this._element = null;
  596. this._interval = null;
  597. this._isPaused = null;
  598. this._isSliding = null;
  599. this._activeElement = null;
  600. this._indicatorsElement = null;
  601. }; // Private
  602. _proto._getConfig = function _getConfig(config) {
  603. config = _extends({}, Default, config);
  604. Util.typeCheckConfig(NAME, config, DefaultType);
  605. return config;
  606. };
  607. _proto._addEventListeners = function _addEventListeners() {
  608. var _this2 = this;
  609. if (this._config.keyboard) {
  610. $$$1(this._element).on(Event.KEYDOWN, function (event) {
  611. return _this2._keydown(event);
  612. });
  613. }
  614. if (this._config.pause === 'hover') {
  615. $$$1(this._element).on(Event.MOUSEENTER, function (event) {
  616. return _this2.pause(event);
  617. }).on(Event.MOUSELEAVE, function (event) {
  618. return _this2.cycle(event);
  619. });
  620. if ('ontouchstart' in document.documentElement) {
  621. // If it's a touch-enabled device, mouseenter/leave are fired as
  622. // part of the mouse compatibility events on first tap - the carousel
  623. // would stop cycling until user tapped out of it;
  624. // here, we listen for touchend, explicitly pause the carousel
  625. // (as if it's the second time we tap on it, mouseenter compat event
  626. // is NOT fired) and after a timeout (to allow for mouse compatibility
  627. // events to fire) we explicitly restart cycling
  628. $$$1(this._element).on(Event.TOUCHEND, function () {
  629. _this2.pause();
  630. if (_this2.touchTimeout) {
  631. clearTimeout(_this2.touchTimeout);
  632. }
  633. _this2.touchTimeout = setTimeout(function (event) {
  634. return _this2.cycle(event);
  635. }, TOUCHEVENT_COMPAT_WAIT + _this2._config.interval);
  636. });
  637. }
  638. }
  639. };
  640. _proto._keydown = function _keydown(event) {
  641. if (/input|textarea/i.test(event.target.tagName)) {
  642. return;
  643. }
  644. switch (event.which) {
  645. case ARROW_LEFT_KEYCODE:
  646. event.preventDefault();
  647. this.prev();
  648. break;
  649. case ARROW_RIGHT_KEYCODE:
  650. event.preventDefault();
  651. this.next();
  652. break;
  653. default:
  654. }
  655. };
  656. _proto._getItemIndex = function _getItemIndex(element) {
  657. this._items = $$$1.makeArray($$$1(element).parent().find(Selector.ITEM));
  658. return this._items.indexOf(element);
  659. };
  660. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  661. var isNextDirection = direction === Direction.NEXT;
  662. var isPrevDirection = direction === Direction.PREV;
  663. var activeIndex = this._getItemIndex(activeElement);
  664. var lastItemIndex = this._items.length - 1;
  665. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  666. if (isGoingToWrap && !this._config.wrap) {
  667. return activeElement;
  668. }
  669. var delta = direction === Direction.PREV ? -1 : 1;
  670. var itemIndex = (activeIndex + delta) % this._items.length;
  671. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  672. };
  673. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  674. var targetIndex = this._getItemIndex(relatedTarget);
  675. var fromIndex = this._getItemIndex($$$1(this._element).find(Selector.ACTIVE_ITEM)[0]);
  676. var slideEvent = $$$1.Event(Event.SLIDE, {
  677. relatedTarget: relatedTarget,
  678. direction: eventDirectionName,
  679. from: fromIndex,
  680. to: targetIndex
  681. });
  682. $$$1(this._element).trigger(slideEvent);
  683. return slideEvent;
  684. };
  685. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  686. if (this._indicatorsElement) {
  687. $$$1(this._indicatorsElement).find(Selector.ACTIVE).removeClass(ClassName.ACTIVE);
  688. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  689. if (nextIndicator) {
  690. $$$1(nextIndicator).addClass(ClassName.ACTIVE);
  691. }
  692. }
  693. };
  694. _proto._slide = function _slide(direction, element) {
  695. var _this3 = this;
  696. var activeElement = $$$1(this._element).find(Selector.ACTIVE_ITEM)[0];
  697. var activeElementIndex = this._getItemIndex(activeElement);
  698. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  699. var nextElementIndex = this._getItemIndex(nextElement);
  700. var isCycling = Boolean(this._interval);
  701. var directionalClassName;
  702. var orderClassName;
  703. var eventDirectionName;
  704. if (direction === Direction.NEXT) {
  705. directionalClassName = ClassName.LEFT;
  706. orderClassName = ClassName.NEXT;
  707. eventDirectionName = Direction.LEFT;
  708. } else {
  709. directionalClassName = ClassName.RIGHT;
  710. orderClassName = ClassName.PREV;
  711. eventDirectionName = Direction.RIGHT;
  712. }
  713. if (nextElement && $$$1(nextElement).hasClass(ClassName.ACTIVE)) {
  714. this._isSliding = false;
  715. return;
  716. }
  717. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  718. if (slideEvent.isDefaultPrevented()) {
  719. return;
  720. }
  721. if (!activeElement || !nextElement) {
  722. // Some weirdness is happening, so we bail
  723. return;
  724. }
  725. this._isSliding = true;
  726. if (isCycling) {
  727. this.pause();
  728. }
  729. this._setActiveIndicatorElement(nextElement);
  730. var slidEvent = $$$1.Event(Event.SLID, {
  731. relatedTarget: nextElement,
  732. direction: eventDirectionName,
  733. from: activeElementIndex,
  734. to: nextElementIndex
  735. });
  736. if (Util.supportsTransitionEnd() && $$$1(this._element).hasClass(ClassName.SLIDE)) {
  737. $$$1(nextElement).addClass(orderClassName);
  738. Util.reflow(nextElement);
  739. $$$1(activeElement).addClass(directionalClassName);
  740. $$$1(nextElement).addClass(directionalClassName);
  741. $$$1(activeElement).one(Util.TRANSITION_END, function () {
  742. $$$1(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName.ACTIVE);
  743. $$$1(activeElement).removeClass(ClassName.ACTIVE + " " + orderClassName + " " + directionalClassName);
  744. _this3._isSliding = false;
  745. setTimeout(function () {
  746. return $$$1(_this3._element).trigger(slidEvent);
  747. }, 0);
  748. }).emulateTransitionEnd(TRANSITION_DURATION);
  749. } else {
  750. $$$1(activeElement).removeClass(ClassName.ACTIVE);
  751. $$$1(nextElement).addClass(ClassName.ACTIVE);
  752. this._isSliding = false;
  753. $$$1(this._element).trigger(slidEvent);
  754. }
  755. if (isCycling) {
  756. this.cycle();
  757. }
  758. }; // Static
  759. Carousel._jQueryInterface = function _jQueryInterface(config) {
  760. return this.each(function () {
  761. var data = $$$1(this).data(DATA_KEY);
  762. var _config = _extends({}, Default, $$$1(this).data());
  763. if (typeof config === 'object') {
  764. _config = _extends({}, _config, config);
  765. }
  766. var action = typeof config === 'string' ? config : _config.slide;
  767. if (!data) {
  768. data = new Carousel(this, _config);
  769. $$$1(this).data(DATA_KEY, data);
  770. }
  771. if (typeof config === 'number') {
  772. data.to(config);
  773. } else if (typeof action === 'string') {
  774. if (typeof data[action] === 'undefined') {
  775. throw new TypeError("No method named \"" + action + "\"");
  776. }
  777. data[action]();
  778. } else if (_config.interval) {
  779. data.pause();
  780. data.cycle();
  781. }
  782. });
  783. };
  784. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  785. var selector = Util.getSelectorFromElement(this);
  786. if (!selector) {
  787. return;
  788. }
  789. var target = $$$1(selector)[0];
  790. if (!target || !$$$1(target).hasClass(ClassName.CAROUSEL)) {
  791. return;
  792. }
  793. var config = _extends({}, $$$1(target).data(), $$$1(this).data());
  794. var slideIndex = this.getAttribute('data-slide-to');
  795. if (slideIndex) {
  796. config.interval = false;
  797. }
  798. Carousel._jQueryInterface.call($$$1(target), config);
  799. if (slideIndex) {
  800. $$$1(target).data(DATA_KEY).to(slideIndex);
  801. }
  802. event.preventDefault();
  803. };
  804. _createClass(Carousel, null, [{
  805. key: "VERSION",
  806. get: function get() {
  807. return VERSION;
  808. }
  809. }, {
  810. key: "Default",
  811. get: function get() {
  812. return Default;
  813. }
  814. }]);
  815. return Carousel;
  816. }();
  817. /**
  818. * ------------------------------------------------------------------------
  819. * Data Api implementation
  820. * ------------------------------------------------------------------------
  821. */
  822. $$$1(document).on(Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel._dataApiClickHandler);
  823. $$$1(window).on(Event.LOAD_DATA_API, function () {
  824. $$$1(Selector.DATA_RIDE).each(function () {
  825. var $carousel = $$$1(this);
  826. Carousel._jQueryInterface.call($carousel, $carousel.data());
  827. });
  828. });
  829. /**
  830. * ------------------------------------------------------------------------
  831. * jQuery
  832. * ------------------------------------------------------------------------
  833. */
  834. $$$1.fn[NAME] = Carousel._jQueryInterface;
  835. $$$1.fn[NAME].Constructor = Carousel;
  836. $$$1.fn[NAME].noConflict = function () {
  837. $$$1.fn[NAME] = JQUERY_NO_CONFLICT;
  838. return Carousel._jQueryInterface;
  839. };
  840. return Carousel;
  841. }($);
  842. /**
  843. * --------------------------------------------------------------------------
  844. * Bootstrap (v4.0.0): collapse.js
  845. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  846. * --------------------------------------------------------------------------
  847. */
  848. var Collapse = function ($$$1) {
  849. /**
  850. * ------------------------------------------------------------------------
  851. * Constants
  852. * ------------------------------------------------------------------------
  853. */
  854. var NAME = 'collapse';
  855. var VERSION = '4.0.0';
  856. var DATA_KEY = 'bs.collapse';
  857. var EVENT_KEY = "." + DATA_KEY;
  858. var DATA_API_KEY = '.data-api';
  859. var JQUERY_NO_CONFLICT = $$$1.fn[NAME];
  860. var TRANSITION_DURATION = 600;
  861. var Default = {
  862. toggle: true,
  863. parent: ''
  864. };
  865. var DefaultType = {
  866. toggle: 'boolean',
  867. parent: '(string|element)'
  868. };
  869. var Event = {
  870. SHOW: "show" + EVENT_KEY,
  871. SHOWN: "shown" + EVENT_KEY,
  872. HIDE: "hide" + EVENT_KEY,
  873. HIDDEN: "hidden" + EVENT_KEY,
  874. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
  875. };
  876. var ClassName = {
  877. SHOW: 'show',
  878. COLLAPSE: 'collapse',
  879. COLLAPSING: 'collapsing',
  880. COLLAPSED: 'collapsed'
  881. };
  882. var Dimension = {
  883. WIDTH: 'width',
  884. HEIGHT: 'height'
  885. };
  886. var Selector = {
  887. ACTIVES: '.show, .collapsing',
  888. DATA_TOGGLE: '[data-toggle="collapse"]'
  889. /**
  890. * ------------------------------------------------------------------------
  891. * Class Definition
  892. * ------------------------------------------------------------------------
  893. */
  894. };
  895. var Collapse =
  896. /*#__PURE__*/
  897. function () {
  898. function Collapse(element, config) {
  899. this._isTransitioning = false;
  900. this._element = element;
  901. this._config = this._getConfig(config);
  902. this._triggerArray = $$$1.makeArray($$$1("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  903. var tabToggles = $$$1(Selector.DATA_TOGGLE);
  904. for (var i = 0; i < tabToggles.length; i++) {
  905. var elem = tabToggles[i];
  906. var selector = Util.getSelectorFromElement(elem);
  907. if (selector !== null && $$$1(selector).filter(element).length > 0) {
  908. this._selector = selector;
  909. this._triggerArray.push(elem);
  910. }
  911. }
  912. this._parent = this._config.parent ? this._getParent() : null;
  913. if (!this._config.parent) {
  914. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  915. }
  916. if (this._config.toggle) {
  917. this.toggle();
  918. }
  919. } // Getters
  920. var _proto = Collapse.prototype;
  921. // Public
  922. _proto.toggle = function toggle() {
  923. if ($$$1(this._element).hasClass(ClassName.SHOW)) {
  924. this.hide();
  925. } else {
  926. this.show();
  927. }
  928. };
  929. _proto.show = function show() {
  930. var _this = this;
  931. if (this._isTransitioning || $$$1(this._element).hasClass(ClassName.SHOW)) {
  932. return;
  933. }
  934. var actives;
  935. var activesData;
  936. if (this._parent) {
  937. actives = $$$1.makeArray($$$1(this._parent).find(Selector.ACTIVES).filter("[data-parent=\"" + this._config.parent + "\"]"));
  938. if (actives.length === 0) {
  939. actives = null;
  940. }
  941. }
  942. if (actives) {
  943. activesData = $$$1(actives).not(this._selector).data(DATA_KEY);
  944. if (activesData && activesData._isTransitioning) {
  945. return;
  946. }
  947. }
  948. var startEvent = $$$1.Event(Event.SHOW);
  949. $$$1(this._element).trigger(startEvent);
  950. if (startEvent.isDefaultPrevented()) {
  951. return;
  952. }
  953. if (actives) {
  954. Collapse._jQueryInterface.call($$$1(actives).not(this._selector), 'hide');
  955. if (!activesData) {
  956. $$$1(actives).data(DATA_KEY, null);
  957. }
  958. }
  959. var dimension = this._getDimension();
  960. $$$1(this._element).removeClass(ClassName.COLLAPSE).addClass(ClassName.COLLAPSING);
  961. this._element.style[dimension] = 0;
  962. if (this._triggerArray.length > 0) {
  963. $$$1(this._triggerArray).removeClass(ClassName.COLLAPSED).attr('aria-expanded', true);
  964. }
  965. this.setTransitioning(true);
  966. var complete = function complete() {
  967. $$$1(_this._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).addClass(ClassName.SHOW);
  968. _this._element.style[dimension] = '';
  969. _this.setTransitioning(false);
  970. $$$1(_this._element).trigger(Event.SHOWN);
  971. };
  972. if (!Util.supportsTransitionEnd()) {
  973. complete();
  974. return;
  975. }
  976. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  977. var scrollSize = "scroll" + capitalizedDimension;
  978. $$$1(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
  979. this._element.style[dimension] = this._element[scrollSize] + "px";
  980. };
  981. _proto.hide = function hide() {
  982. var _this2 = this;
  983. if (this._isTransitioning || !$$$1(this._element).hasClass(ClassName.SHOW)) {
  984. return;
  985. }
  986. var startEvent = $$$1.Event(Event.HIDE);
  987. $$$1(this._element).trigger(startEvent);
  988. if (startEvent.isDefaultPrevented()) {
  989. return;
  990. }
  991. var dimension = this._getDimension();
  992. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  993. Util.reflow(this._element);
  994. $$$1(this._element).addClass(ClassName.COLLAPSING).removeClass(ClassName.COLLAPSE).removeClass(ClassName.SHOW);
  995. if (this._triggerArray.length > 0) {
  996. for (var i = 0; i < this._triggerArray.length; i++) {
  997. var trigger = this._triggerArray[i];
  998. var selector = Util.getSelectorFromElement(trigger);
  999. if (selector !== null) {
  1000. var $elem = $$$1(selector);
  1001. if (!$elem.hasClass(ClassName.SHOW)) {
  1002. $$$1(trigger).addClass(ClassName.COLLAPSED).attr('aria-expanded', false);
  1003. }
  1004. }
  1005. }
  1006. }
  1007. this.setTransitioning(true);
  1008. var complete = function complete() {
  1009. _this2.setTransitioning(false);
  1010. $$$1(_this2._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).trigger(Event.HIDDEN);
  1011. };
  1012. this._element.style[dimension] = '';
  1013. if (!Util.supportsTransitionEnd()) {
  1014. complete();
  1015. return;
  1016. }
  1017. $$$1(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION);
  1018. };
  1019. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  1020. this._isTransitioning = isTransitioning;
  1021. };
  1022. _proto.dispose = function dispose() {
  1023. $$$1.removeData(this._element, DATA_KEY);
  1024. this._config = null;
  1025. this._parent = null;
  1026. this._element = null;
  1027. this._triggerArray = null;
  1028. this._isTransitioning = null;
  1029. }; // Private
  1030. _proto._getConfig = function _getConfig(config) {
  1031. config = _extends({}, Default, config);
  1032. config.toggle = Boolean(config.toggle); // Coerce string values
  1033. Util.typeCheckConfig(NAME, config, DefaultType);
  1034. return config;
  1035. };
  1036. _proto._getDimension = function _getDimension() {
  1037. var hasWidth = $$$1(this._element).hasClass(Dimension.WIDTH);
  1038. return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
  1039. };
  1040. _proto._getParent = function _getParent() {
  1041. var _this3 = this;
  1042. var parent = null;
  1043. if (Util.isElement(this._config.parent)) {
  1044. parent = this._config.parent; // It's a jQuery object
  1045. if (typeof this._config.parent.jquery !== 'undefined') {
  1046. parent = this._config.parent[0];
  1047. }
  1048. } else {
  1049. parent = $$$1(this._config.parent)[0];
  1050. }
  1051. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  1052. $$$1(parent).find(selector).each(function (i, element) {
  1053. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  1054. });
  1055. return parent;
  1056. };
  1057. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  1058. if (element) {
  1059. var isOpen = $$$1(element).hasClass(ClassName.SHOW);
  1060. if (triggerArray.length > 0) {
  1061. $$$1(triggerArray).toggleClass(ClassName.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  1062. }
  1063. }
  1064. }; // Static
  1065. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  1066. var selector = Util.getSelectorFromElement(element);
  1067. return selector ? $$$1(selector)[0] : null;
  1068. };
  1069. Collapse._jQueryInterface = function _jQueryInterface(config) {
  1070. return this.each(function () {
  1071. var $this = $$$1(this);
  1072. var data = $this.data(DATA_KEY);
  1073. var _config = _extends({}, Default, $this.data(), typeof config === 'object' && config);
  1074. if (!data && _config.toggle && /show|hide/.test(config)) {
  1075. _config.toggle = false;
  1076. }
  1077. if (!data) {
  1078. data = new Collapse(this, _config);
  1079. $this.data(DATA_KEY, data);
  1080. }
  1081. if (typeof config === 'string') {
  1082. if (typeof data[config] === 'undefined') {
  1083. throw new TypeError("No method named \"" + config + "\"");
  1084. }
  1085. data[config]();
  1086. }
  1087. });
  1088. };
  1089. _createClass(Collapse, null, [{
  1090. key: "VERSION",
  1091. get: function get() {
  1092. return VERSION;
  1093. }
  1094. }, {
  1095. key: "Default",
  1096. get: function get() {
  1097. return Default;
  1098. }
  1099. }]);
  1100. return Collapse;
  1101. }();
  1102. /**
  1103. * ------------------------------------------------------------------------
  1104. * Data Api implementation
  1105. * ------------------------------------------------------------------------
  1106. */
  1107. $$$1(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
  1108. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  1109. if (event.currentTarget.tagName === 'A') {
  1110. event.preventDefault();
  1111. }
  1112. var $trigger = $$$1(this);
  1113. var selector = Util.getSelectorFromElement(this);
  1114. $$$1(selector).each(function () {
  1115. var $target = $$$1(this);
  1116. var data = $target.data(DATA_KEY);
  1117. var config = data ? 'toggle' : $trigger.data();
  1118. Collapse._jQueryInterface.call($target, config);
  1119. });
  1120. });
  1121. /**
  1122. * ------------------------------------------------------------------------
  1123. * jQuery
  1124. * ------------------------------------------------------------------------
  1125. */
  1126. $$$1.fn[NAME] = Collapse._jQueryInterface;
  1127. $$$1.fn[NAME].Constructor = Collapse;
  1128. $$$1.fn[NAME].noConflict = function () {
  1129. $$$1.fn[NAME] = JQUERY_NO_CONFLICT;
  1130. return Collapse._jQueryInterface;
  1131. };
  1132. return Collapse;
  1133. }($);
  1134. /**!
  1135. * @fileOverview Kickass library to create and place poppers near their reference elements.
  1136. * @version 1.12.9
  1137. * @license
  1138. * Copyright (c) 2016 Federico Zivolo and contributors
  1139. *
  1140. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1141. * of this software and associated documentation files (the "Software"), to deal
  1142. * in the Software without restriction, including without limitation the rights
  1143. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1144. * copies of the Software, and to permit persons to whom the Software is
  1145. * furnished to do so, subject to the following conditions:
  1146. *
  1147. * The above copyright notice and this permission notice shall be included in all
  1148. * copies or substantial portions of the Software.
  1149. *
  1150. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1151. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1152. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1153. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1154. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1155. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  1156. * SOFTWARE.
  1157. */
  1158. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
  1159. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  1160. var timeoutDuration = 0;
  1161. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  1162. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  1163. timeoutDuration = 1;
  1164. break;
  1165. }
  1166. }
  1167. function microtaskDebounce(fn) {
  1168. var called = false;
  1169. return function () {
  1170. if (called) {
  1171. return;
  1172. }
  1173. called = true;
  1174. window.Promise.resolve().then(function () {
  1175. called = false;
  1176. fn();
  1177. });
  1178. };
  1179. }
  1180. function taskDebounce(fn) {
  1181. var scheduled = false;
  1182. return function () {
  1183. if (!scheduled) {
  1184. scheduled = true;
  1185. setTimeout(function () {
  1186. scheduled = false;
  1187. fn();
  1188. }, timeoutDuration);
  1189. }
  1190. };
  1191. }
  1192. var supportsMicroTasks = isBrowser && window.Promise;
  1193. /**
  1194. * Create a debounced version of a method, that's asynchronously deferred
  1195. * but called in the minimum time possible.
  1196. *
  1197. * @method
  1198. * @memberof Popper.Utils
  1199. * @argument {Function} fn
  1200. * @returns {Function}
  1201. */
  1202. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  1203. /**
  1204. * Check if the given variable is a function
  1205. * @method
  1206. * @memberof Popper.Utils
  1207. * @argument {Any} functionToCheck - variable to check
  1208. * @returns {Boolean} answer to: is a function?
  1209. */
  1210. function isFunction(functionToCheck) {
  1211. var getType = {};
  1212. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  1213. }
  1214. /**
  1215. * Get CSS computed property of the given element
  1216. * @method
  1217. * @memberof Popper.Utils
  1218. * @argument {Eement} element
  1219. * @argument {String} property
  1220. */
  1221. function getStyleComputedProperty(element, property) {
  1222. if (element.nodeType !== 1) {
  1223. return [];
  1224. }
  1225. // NOTE: 1 DOM access here
  1226. var css = getComputedStyle(element, null);
  1227. return property ? css[property] : css;
  1228. }
  1229. /**
  1230. * Returns the parentNode or the host of the element
  1231. * @method
  1232. * @memberof Popper.Utils
  1233. * @argument {Element} element
  1234. * @returns {Element} parent
  1235. */
  1236. function getParentNode(element) {
  1237. if (element.nodeName === 'HTML') {
  1238. return element;
  1239. }
  1240. return element.parentNode || element.host;
  1241. }
  1242. /**
  1243. * Returns the scrolling parent of the given element
  1244. * @method
  1245. * @memberof Popper.Utils
  1246. * @argument {Element} element
  1247. * @returns {Element} scroll parent
  1248. */
  1249. function getScrollParent(element) {
  1250. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  1251. if (!element) {
  1252. return document.body;
  1253. }
  1254. switch (element.nodeName) {
  1255. case 'HTML':
  1256. case 'BODY':
  1257. return element.ownerDocument.body;
  1258. case '#document':
  1259. return element.body;
  1260. }
  1261. // Firefox want us to check `-x` and `-y` variations as well
  1262. var _getStyleComputedProp = getStyleComputedProperty(element),
  1263. overflow = _getStyleComputedProp.overflow,
  1264. overflowX = _getStyleComputedProp.overflowX,
  1265. overflowY = _getStyleComputedProp.overflowY;
  1266. if (/(auto|scroll)/.test(overflow + overflowY + overflowX)) {
  1267. return element;
  1268. }
  1269. return getScrollParent(getParentNode(element));
  1270. }
  1271. /**
  1272. * Returns the offset parent of the given element
  1273. * @method
  1274. * @memberof Popper.Utils
  1275. * @argument {Element} element
  1276. * @returns {Element} offset parent
  1277. */
  1278. function getOffsetParent(element) {
  1279. // NOTE: 1 DOM access here
  1280. var offsetParent = element && element.offsetParent;
  1281. var nodeName = offsetParent && offsetParent.nodeName;
  1282. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  1283. if (element) {
  1284. return element.ownerDocument.documentElement;
  1285. }
  1286. return document.documentElement;
  1287. }
  1288. // .offsetParent will return the closest TD or TABLE in case
  1289. // no offsetParent is present, I hate this job...
  1290. if (['TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  1291. return getOffsetParent(offsetParent);
  1292. }
  1293. return offsetParent;
  1294. }
  1295. function isOffsetContainer(element) {
  1296. var nodeName = element.nodeName;
  1297. if (nodeName === 'BODY') {
  1298. return false;
  1299. }
  1300. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  1301. }
  1302. /**
  1303. * Finds the root node (document, shadowDOM root) of the given element
  1304. * @method
  1305. * @memberof Popper.Utils
  1306. * @argument {Element} node
  1307. * @returns {Element} root node
  1308. */
  1309. function getRoot(node) {
  1310. if (node.parentNode !== null) {
  1311. return getRoot(node.parentNode);
  1312. }
  1313. return node;
  1314. }
  1315. /**
  1316. * Finds the offset parent common to the two provided nodes
  1317. * @method
  1318. * @memberof Popper.Utils
  1319. * @argument {Element} element1
  1320. * @argument {Element} element2
  1321. * @returns {Element} common offset parent
  1322. */
  1323. function findCommonOffsetParent(element1, element2) {
  1324. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  1325. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  1326. return document.documentElement;
  1327. }
  1328. // Here we make sure to give as "start" the element that comes first in the DOM
  1329. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  1330. var start = order ? element1 : element2;
  1331. var end = order ? element2 : element1;
  1332. // Get common ancestor container
  1333. var range = document.createRange();
  1334. range.setStart(start, 0);
  1335. range.setEnd(end, 0);
  1336. var commonAncestorContainer = range.commonAncestorContainer;
  1337. // Both nodes are inside #document
  1338. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  1339. if (isOffsetContainer(commonAncestorContainer)) {
  1340. return commonAncestorContainer;
  1341. }
  1342. return getOffsetParent(commonAncestorContainer);
  1343. }
  1344. // one of the nodes is inside shadowDOM, find which one
  1345. var element1root = getRoot(element1);
  1346. if (element1root.host) {
  1347. return findCommonOffsetParent(element1root.host, element2);
  1348. } else {
  1349. return findCommonOffsetParent(element1, getRoot(element2).host);
  1350. }
  1351. }
  1352. /**
  1353. * Gets the scroll value of the given element in the given side (top and left)
  1354. * @method
  1355. * @memberof Popper.Utils
  1356. * @argument {Element} element
  1357. * @argument {String} side `top` or `left`
  1358. * @returns {number} amount of scrolled pixels
  1359. */
  1360. function getScroll(element) {
  1361. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  1362. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  1363. var nodeName = element.nodeName;
  1364. if (nodeName === 'BODY' || nodeName === 'HTML') {
  1365. var html = element.ownerDocument.documentElement;
  1366. var scrollingElement = element.ownerDocument.scrollingElement || html;
  1367. return scrollingElement[upperSide];
  1368. }
  1369. return element[upperSide];
  1370. }
  1371. /*
  1372. * Sum or subtract the element scroll values (left and top) from a given rect object
  1373. * @method
  1374. * @memberof Popper.Utils
  1375. * @param {Object} rect - Rect object you want to change
  1376. * @param {HTMLElement} element - The element from the function reads the scroll values
  1377. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  1378. * @return {Object} rect - The modifier rect object
  1379. */
  1380. function includeScroll(rect, element) {
  1381. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  1382. var scrollTop = getScroll(element, 'top');
  1383. var scrollLeft = getScroll(element, 'left');
  1384. var modifier = subtract ? -1 : 1;
  1385. rect.top += scrollTop * modifier;
  1386. rect.bottom += scrollTop * modifier;
  1387. rect.left += scrollLeft * modifier;
  1388. rect.right += scrollLeft * modifier;
  1389. return rect;
  1390. }
  1391. /*
  1392. * Helper to detect borders of a given element
  1393. * @method
  1394. * @memberof Popper.Utils
  1395. * @param {CSSStyleDeclaration} styles
  1396. * Result of `getStyleComputedProperty` on the given element
  1397. * @param {String} axis - `x` or `y`
  1398. * @return {number} borders - The borders size of the given axis
  1399. */
  1400. function getBordersSize(styles, axis) {
  1401. var sideA = a