09bcf5b9b98e58d3cfd2bc2a00e691b489a0c2c9f24174e04375d4cd56600e479b61f1d585a4788acfa6180affd9b410bb171211b3dbb42e9265e585480b13 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276
  1. /**
  2. * @fileOverview Kickass library to create and place poppers near their reference elements.
  3. * @version {{version}}
  4. * @license
  5. * Copyright (c) 2016 Federico Zivolo and contributors
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8. * of this software and associated documentation files (the "Software"), to deal
  9. * in the Software without restriction, including without limitation the rights
  10. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. * copies of the Software, and to permit persons to whom the Software is
  12. * furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in all
  15. * copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  23. * SOFTWARE.
  24. */
  25. //
  26. // Cross module loader
  27. // Supported: Node, AMD, Browser globals
  28. //
  29. ;(function (root, factory) {
  30. if (typeof define === 'function' && define.amd) {
  31. // AMD. Register as an anonymous module.
  32. define(factory);
  33. } else if (typeof module === 'object' && module.exports) {
  34. // Node. Does not work with strict CommonJS, but
  35. // only CommonJS-like environments that support module.exports,
  36. // like Node.
  37. module.exports = factory();
  38. } else {
  39. // Browser globals (root is window)
  40. root.Popper = factory();
  41. }
  42. }(this, function () {
  43. 'use strict';
  44. var root = window;
  45. // default options
  46. var DEFAULTS = {
  47. // placement of the popper
  48. placement: 'bottom',
  49. gpuAcceleration: true,
  50. // shift popper from its origin by the given amount of pixels (can be negative)
  51. offset: 0,
  52. // the element which will act as boundary of the popper
  53. boundariesElement: 'viewport',
  54. // amount of pixel used to define a minimum distance between the boundaries and the popper
  55. boundariesPadding: 5,
  56. // popper will try to prevent overflow following this order,
  57. // by default, then, it could overflow on the left and on top of the boundariesElement
  58. preventOverflowOrder: ['left', 'right', 'top', 'bottom'],
  59. // the behavior used by flip to change the placement of the popper
  60. flipBehavior: 'flip',
  61. arrowElement: '[x-arrow]',
  62. arrowOffset: 0,
  63. // list of functions used to modify the offsets before they are applied to the popper
  64. modifiers: [ 'shift', 'offset', 'preventOverflow', 'keepTogether', 'arrow', 'flip', 'applyStyle'],
  65. modifiersIgnored: [],
  66. forceAbsolute: false
  67. };
  68. /**
  69. * Create a new Popper.js instance
  70. * @constructor Popper
  71. * @param {HTMLElement} reference - The reference element used to position the popper
  72. * @param {HTMLElement|Object} popper
  73. * The HTML element used as popper, or a configuration used to generate the popper.
  74. * @param {String} [popper.tagName='div'] The tag name of the generated popper.
  75. * @param {Array} [popper.classNames=['popper']] Array of classes to apply to the generated popper.
  76. * @param {Array} [popper.attributes] Array of attributes to apply, specify `attr:value` to assign a value to it.
  77. * @param {HTMLElement|String} [popper.parent=window.document.body] The parent element, given as HTMLElement or as query string.
  78. * @param {String} [popper.content=''] The content of the popper, it can be text, html, or node; if it is not text, set `contentType` to `html` or `node`.
  79. * @param {String} [popper.contentType='text'] If `html`, the `content` will be parsed as HTML. If `node`, it will be appended as-is.
  80. * @param {String} [popper.arrowTagName='div'] Same as `popper.tagName` but for the arrow element.
  81. * @param {Array} [popper.arrowClassNames='popper__arrow'] Same as `popper.classNames` but for the arrow element.
  82. * @param {String} [popper.arrowAttributes=['x-arrow']] Same as `popper.attributes` but for the arrow element.
  83. * @param {Object} options
  84. * @param {String} [options.placement=bottom]
  85. * Placement of the popper accepted values: `top(-start, -end), right(-start, -end), bottom(-start, -right),
  86. * left(-start, -end)`
  87. *
  88. * @param {HTMLElement|String} [options.arrowElement='[x-arrow]']
  89. * The DOM Node used as arrow for the popper, or a CSS selector used to get the DOM node. It must be child of
  90. * its parent Popper. Popper.js will apply to the given element the style required to align the arrow with its
  91. * reference element.
  92. * By default, it will look for a child node of the popper with the `x-arrow` attribute.
  93. *
  94. * @param {Boolean} [options.gpuAcceleration=true]
  95. * When this property is set to true, the popper position will be applied using CSS3 translate3d, allowing the
  96. * browser to use the GPU to accelerate the rendering.
  97. * If set to false, the popper will be placed using `top` and `left` properties, not using the GPU.
  98. *
  99. * @param {Number} [options.offset=0]
  100. * Amount of pixels the popper will be shifted (can be negative).
  101. *
  102. * @param {String|Element} [options.boundariesElement='viewport']
  103. * The element which will define the boundaries of the popper position, the popper will never be placed outside
  104. * of the defined boundaries (except if `keepTogether` is enabled)
  105. *
  106. * @param {Number} [options.boundariesPadding=5]
  107. * Additional padding for the boundaries
  108. *
  109. * @param {Array} [options.preventOverflowOrder=['left', 'right', 'top', 'bottom']]
  110. * Order used when Popper.js tries to avoid overflows from the boundaries, they will be checked in order,
  111. * this means that the last ones will never overflow
  112. *
  113. * @param {String|Array} [options.flipBehavior='flip']
  114. * The behavior used by the `flip` modifier to change the placement of the popper when the latter is trying to
  115. * overlap its reference element. Defining `flip` as value, the placement will be flipped on
  116. * its axis (`right - left`, `top - bottom`).
  117. * You can even pass an array of placements (eg: `['right', 'left', 'top']` ) to manually specify
  118. * how alter the placement when a flip is needed. (eg. in the above example, it would first flip from right to left,
  119. * then, if even in its new placement, the popper is overlapping its reference element, it will be moved to top)
  120. *
  121. * @param {Array} [options.modifiers=[ 'shift', 'offset', 'preventOverflow', 'keepTogether', 'arrow', 'flip', 'applyStyle']]
  122. * List of functions used to modify the data before they are applied to the popper, add your custom functions
  123. * to this array to edit the offsets and placement.
  124. * The function should reflect the @params and @returns of preventOverflow
  125. *
  126. * @param {Array} [options.modifiersIgnored=[]]
  127. * Put here any built-in modifier name you want to exclude from the modifiers list
  128. * The function should reflect the @params and @returns of preventOverflow
  129. *
  130. * @param {Boolean} [options.removeOnDestroy=false]
  131. * Set to true if you want to automatically remove the popper when you call the `destroy` method.
  132. */
  133. function Popper(reference, popper, options) {
  134. this._reference = reference.jquery ? reference[0] : reference;
  135. this.state = {};
  136. // if the popper variable is a configuration object, parse it to generate an HTMLElement
  137. // generate a default popper if is not defined
  138. var isNotDefined = typeof popper === 'undefined' || popper === null;
  139. var isConfig = popper && Object.prototype.toString.call(popper) === '[object Object]';
  140. if (isNotDefined || isConfig) {
  141. this._popper = this.parse(isConfig ? popper : {});
  142. }
  143. // otherwise, use the given HTMLElement as popper
  144. else {
  145. this._popper = popper.jquery ? popper[0] : popper;
  146. }
  147. // with {} we create a new object with the options inside it
  148. this._options = Object.assign({}, DEFAULTS, options);
  149. // refactoring modifiers' list
  150. this._options.modifiers = this._options.modifiers.map(function(modifier){
  151. // remove ignored modifiers
  152. if (this._options.modifiersIgnored.indexOf(modifier) !== -1) return;
  153. // set the x-placement attribute before everything else because it could be used to add margins to the popper
  154. // margins needs to be calculated to get the correct popper offsets
  155. if (modifier === 'applyStyle') {
  156. this._popper.setAttribute('x-placement', this._options.placement);
  157. }
  158. // return predefined modifier identified by string or keep the custom one
  159. return this.modifiers[modifier] || modifier;
  160. }.bind(this));
  161. // make sure to apply the popper position before any computation
  162. this.state.position = this._getPosition(this._popper, this._reference);
  163. setStyle(this._popper, { position: this.state.position, top: 0 });
  164. // fire the first update to position the popper in the right place
  165. this.update();
  166. // setup event listeners, they will take care of update the position in specific situations
  167. this._setupEventListeners();
  168. return this;
  169. }
  170. //
  171. // Methods
  172. //
  173. /**
  174. * Destroy the popper
  175. * @method
  176. * @memberof Popper
  177. */
  178. Popper.prototype.destroy = function() {
  179. this._popper.removeAttribute('x-placement');
  180. this._popper.style.left = '';
  181. this._popper.style.position = '';
  182. this._popper.style.top = '';
  183. this._popper.style[getSupportedPropertyName('transform')] = '';
  184. this._removeEventListeners();
  185. // remove the popper if user explicity asked for the deletion on destroy
  186. if (this._options.removeOnDestroy) {
  187. this._popper.remove();
  188. }
  189. return this;
  190. };
  191. /**
  192. * Updates the position of the popper, computing the new offsets and applying the new style
  193. * @method
  194. * @memberof Popper
  195. */
  196. Popper.prototype.update = function() {
  197. var data = { instance: this, styles: {} };
  198. // store placement inside the data object, modifiers will be able to edit `placement` if needed
  199. // and refer to _originalPlacement to know the original value
  200. data.placement = this._options.placement;
  201. data._originalPlacement = this._options.placement;
  202. // compute the popper and reference offsets and put them inside data.offsets
  203. data.offsets = this._getOffsets(this._popper, this._reference, data.placement);
  204. // get boundaries
  205. data.boundaries = this._getBoundaries(data, this._options.boundariesPadding, this._options.boundariesElement);
  206. data = this.runModifiers(data, this._options.modifiers);
  207. if (typeof this.state.updateCallback === 'function') {
  208. this.state.updateCallback(data);
  209. }
  210. };
  211. /**
  212. * If a function is passed, it will be executed after the initialization of popper with as first argument the Popper instance.
  213. * @method
  214. * @memberof Popper
  215. * @param {Function} callback
  216. */
  217. Popper.prototype.onCreate = function(callback) {
  218. // the createCallbacks return as first argument the popper instance
  219. callback(this);
  220. return this;
  221. };
  222. /**
  223. * If a function is passed, it will be executed after each update of popper with as first argument the set of coordinates and informations
  224. * used to style popper and its arrow.
  225. * NOTE: it doesn't get fired on the first call of the `Popper.update()` method inside the `Popper` constructor!
  226. * @method
  227. * @memberof Popper
  228. * @param {Function} callback
  229. */
  230. Popper.prototype.onUpdate = function(callback) {
  231. this.state.updateCallback = callback;
  232. return this;
  233. };
  234. /**
  235. * Helper used to generate poppers from a configuration file
  236. * @method
  237. * @memberof Popper
  238. * @param config {Object} configuration
  239. * @returns {HTMLElement} popper
  240. */
  241. Popper.prototype.parse = function(config) {
  242. var defaultConfig = {
  243. tagName: 'div',
  244. classNames: [ 'popper' ],
  245. attributes: [],
  246. parent: root.document.body,
  247. content: '',
  248. contentType: 'text',
  249. arrowTagName: 'div',
  250. arrowClassNames: [ 'popper__arrow' ],
  251. arrowAttributes: [ 'x-arrow']
  252. };
  253. config = Object.assign({}, defaultConfig, config);
  254. var d = root.document;
  255. var popper = d.createElement(config.tagName);
  256. addClassNames(popper, config.classNames);
  257. addAttributes(popper, config.attributes);
  258. if (config.contentType === 'node') {
  259. popper.appendChild(config.content.jquery ? config.content[0] : config.content);
  260. }else if (config.contentType === 'html') {
  261. popper.innerHTML = config.content;
  262. } else {
  263. popper.textContent = config.content;
  264. }
  265. if (config.arrowTagName) {
  266. var arrow = d.createElement(config.arrowTagName);
  267. addClassNames(arrow, config.arrowClassNames);
  268. addAttributes(arrow, config.arrowAttributes);
  269. popper.appendChild(arrow);
  270. }
  271. var parent = config.parent.jquery ? config.parent[0] : config.parent;
  272. // if the given parent is a string, use it to match an element
  273. // if more than one element is matched, the first one will be used as parent
  274. // if no elements are matched, the script will throw an error
  275. if (typeof parent === 'string') {
  276. parent = d.querySelectorAll(config.parent);
  277. if (parent.length > 1) {
  278. console.warn('WARNING: the given `parent` query(' + config.parent + ') matched more than one element, the first one will be used');
  279. }
  280. if (parent.length === 0) {
  281. throw 'ERROR: the given `parent` doesn\'t exists!';
  282. }
  283. parent = parent[0];
  284. }
  285. // if the given parent is a DOM nodes list or an array of nodes with more than one element,
  286. // the first one will be used as parent
  287. if (parent.length > 1 && parent instanceof Element === false) {
  288. console.warn('WARNING: you have passed as parent a list of elements, the first one will be used');
  289. parent = parent[0];
  290. }
  291. // append the generated popper to its parent
  292. parent.appendChild(popper);
  293. return popper;
  294. /**
  295. * Adds class names to the given element
  296. * @function
  297. * @ignore
  298. * @param {HTMLElement} target
  299. * @param {Array} classes
  300. */
  301. function addClassNames(element, classNames) {
  302. classNames.forEach(function(className) {
  303. element.classList.add(className);
  304. });
  305. }
  306. /**
  307. * Adds attributes to the given element
  308. * @function
  309. * @ignore
  310. * @param {HTMLElement} target
  311. * @param {Array} attributes
  312. * @example
  313. * addAttributes(element, [ 'data-info:foobar' ]);
  314. */
  315. function addAttributes(element, attributes) {
  316. attributes.forEach(function(attribute) {
  317. element.setAttribute(attribute.split(':')[0], attribute.split(':')[1] || '');
  318. });
  319. }
  320. };
  321. /**
  322. * Helper used to get the position which will be applied to the popper
  323. * @method
  324. * @memberof Popper
  325. * @param config {HTMLElement} popper element
  326. * @param reference {HTMLElement} reference element
  327. * @returns {String} position
  328. */
  329. Popper.prototype._getPosition = function(popper, reference) {
  330. var container = getOffsetParent(reference);
  331. if (this._options.forceAbsolute) {
  332. return 'absolute';
  333. }
  334. // Decide if the popper will be fixed
  335. // If the reference element is inside a fixed context, the popper will be fixed as well to allow them to scroll together
  336. var isParentFixed = isFixed(reference, container);
  337. return isParentFixed ? 'fixed' : 'absolute';
  338. };
  339. /**
  340. * Get offsets to the popper
  341. * @method
  342. * @memberof Popper
  343. * @access private
  344. * @param {Element} popper - the popper element
  345. * @param {Element} reference - the reference element (the popper will be relative to this)
  346. * @returns {Object} An object containing the offsets which will be applied to the popper
  347. */
  348. Popper.prototype._getOffsets = function(popper, reference, placement) {
  349. placement = placement.split('-')[0];
  350. var popperOffsets = {};
  351. popperOffsets.position = this.state.position;
  352. var isParentFixed = popperOffsets.position === 'fixed';
  353. //
  354. // Get reference element position
  355. //
  356. var referenceOffsets = getOffsetRectRelativeToCustomParent(reference, getOffsetParent(popper), isParentFixed);
  357. //
  358. // Get popper sizes
  359. //
  360. var popperRect = getOuterSizes(popper);
  361. //
  362. // Compute offsets of popper
  363. //
  364. // depending by the popper placement we have to compute its offsets slightly differently
  365. if (['right', 'left'].indexOf(placement) !== -1) {
  366. popperOffsets.top = referenceOffsets.top + referenceOffsets.height / 2 - popperRect.height / 2;
  367. if (placement === 'left') {
  368. popperOffsets.left = referenceOffsets.left - popperRect.width;
  369. } else {
  370. popperOffsets.left = referenceOffsets.right;
  371. }
  372. } else {
  373. popperOffsets.left = referenceOffsets.left + referenceOffsets.width / 2 - popperRect.width / 2;
  374. if (placement === 'top') {
  375. popperOffsets.top = referenceOffsets.top - popperRect.height;
  376. } else {
  377. popperOffsets.top = referenceOffsets.bottom;
  378. }
  379. }
  380. // Add width and height to our offsets object
  381. popperOffsets.width = popperRect.width;
  382. popperOffsets.height = popperRect.height;
  383. return {
  384. popper: popperOffsets,
  385. reference: referenceOffsets
  386. };
  387. };
  388. /**
  389. * Setup needed event listeners used to update the popper position
  390. * @method
  391. * @memberof Popper
  392. * @access private
  393. */
  394. Popper.prototype._setupEventListeners = function() {
  395. // NOTE: 1 DOM access here
  396. this.state.updateBound = this.update.bind(this);
  397. root.addEventListener('resize', this.state.updateBound);
  398. // if the boundariesElement is window we don't need to listen for the scroll event
  399. if (this._options.boundariesElement !== 'window') {
  400. var target = getScrollParent(this._reference);
  401. // here it could be both `body` or `documentElement` thanks to Firefox, we then check both
  402. if (target === root.document.body || target === root.document.documentElement) {
  403. target = root;
  404. }
  405. target.addEventListener('scroll', this.state.updateBound);
  406. this.state.scrollTarget = target;
  407. }
  408. };
  409. /**
  410. * Remove event listeners used to update the popper position
  411. * @method
  412. * @memberof Popper
  413. * @access private
  414. */
  415. Popper.prototype._removeEventListeners = function() {
  416. // NOTE: 1 DOM access here
  417. root.removeEventListener('resize', this.state.updateBound);
  418. if (this._options.boundariesElement !== 'window' && this.state.scrollTarget) {
  419. this.state.scrollTarget.removeEventListener('scroll', this.state.updateBound);
  420. this.state.scrollTarget = null;
  421. }
  422. this.state.updateBound = null;
  423. };
  424. /**
  425. * Computed the boundaries limits and return them
  426. * @method
  427. * @memberof Popper
  428. * @access private
  429. * @param {Object} data - Object containing the property "offsets" generated by `_getOffsets`
  430. * @param {Number} padding - Boundaries padding
  431. * @param {Element} boundariesElement - Element used to define the boundaries
  432. * @returns {Object} Coordinates of the boundaries
  433. */
  434. Popper.prototype._getBoundaries = function(data, padding, boundariesElement) {
  435. // NOTE: 1 DOM access here
  436. var boundaries = {};
  437. var width, height;
  438. if (boundariesElement === 'window') {
  439. var body = root.document.body,
  440. html = root.document.documentElement;
  441. height = Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight );
  442. width = Math.max( body.scrollWidth, body.offsetWidth, html.clientWidth, html.scrollWidth, html.offsetWidth );
  443. boundaries = {
  444. top: 0,
  445. right: width,
  446. bottom: height,
  447. left: 0
  448. };
  449. } else if (boundariesElement === 'viewport') {
  450. var offsetParent = getOffsetParent(this._popper);
  451. var scrollParent = getScrollParent(this._popper);
  452. var offsetParentRect = getOffsetRect(offsetParent);
  453. // Thanks the fucking native API, `document.body.scrollTop` & `document.documentElement.scrollTop`
  454. var getScrollTopValue = function (element) {
  455. return element == document.body ? Math.max(document.documentElement.scrollTop, document.body.scrollTop) : element.scrollTop;
  456. }
  457. var getScrollLeftValue = function (element) {
  458. return element == document.body ? Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) : element.scrollLeft;
  459. }
  460. // if the popper is fixed we don't have to substract scrolling from the boundaries
  461. var scrollTop = data.offsets.popper.position === 'fixed' ? 0 : getScrollTopValue(scrollParent);
  462. var scrollLeft = data.offsets.popper.position === 'fixed' ? 0 : getScrollLeftValue(scrollParent);
  463. boundaries = {
  464. top: 0 - (offsetParentRect.top - scrollTop),
  465. right: root.document.documentElement.clientWidth - (offsetParentRect.left - scrollLeft),
  466. bottom: root.document.documentElement.clientHeight - (offsetParentRect.top - scrollTop),
  467. left: 0 - (offsetParentRect.left - scrollLeft)
  468. };
  469. } else {
  470. if (getOffsetParent(this._popper) === boundariesElement) {
  471. boundaries = {
  472. top: 0,
  473. left: 0,
  474. right: boundariesElement.clientWidth,
  475. bottom: boundariesElement.clientHeight
  476. };
  477. } else {
  478. boundaries = getOffsetRect(boundariesElement);
  479. }
  480. }
  481. boundaries.left += padding;
  482. boundaries.right -= padding;
  483. boundaries.top = boundaries.top + padding;
  484. boundaries.bottom = boundaries.bottom - padding;
  485. return boundaries;
  486. };
  487. /**
  488. * Loop trough the list of modifiers and run them in order, each of them will then edit the data object
  489. * @method
  490. * @memberof Popper
  491. * @access public
  492. * @param {Object} data
  493. * @param {Array} modifiers
  494. * @param {Function} ends
  495. */
  496. Popper.prototype.runModifiers = function(data, modifiers, ends) {
  497. var modifiersToRun = modifiers.slice();
  498. if (ends !== undefined) {
  499. modifiersToRun = this._options.modifiers.slice(0, getArrayKeyIndex(this._options.modifiers, ends));
  500. }
  501. modifiersToRun.forEach(function(modifier) {
  502. if (isFunction(modifier)) {
  503. data = modifier.call(this, data);
  504. }
  505. }.bind(this));
  506. return data;
  507. };
  508. /**
  509. * Helper used to know if the given modifier depends from another one.
  510. * @method
  511. * @memberof Popper
  512. * @param {String} requesting - name of requesting modifier
  513. * @param {String} requested - name of requested modifier
  514. * @returns {Boolean}
  515. */
  516. Popper.prototype.isModifierRequired = function(requesting, requested) {
  517. var index = getArrayKeyIndex(this._options.modifiers, requesting);
  518. return !!this._options.modifiers.slice(0, index).filter(function(modifier) {
  519. return modifier === requested;
  520. }).length;
  521. };
  522. //
  523. // Modifiers
  524. //
  525. /**
  526. * Modifiers list
  527. * @namespace Popper.modifiers
  528. * @memberof Popper
  529. * @type {Object}
  530. */
  531. Popper.prototype.modifiers = {};
  532. /**
  533. * Apply the computed styles to the popper element
  534. * @method
  535. * @memberof Popper.modifiers
  536. * @argument {Object} data - The data object generated by `update` method
  537. * @returns {Object} The same data object
  538. */
  539. Popper.prototype.modifiers.applyStyle = function(data) {
  540. // apply the final offsets to the popper
  541. // NOTE: 1 DOM access here
  542. var styles = {
  543. position: data.offsets.popper.position
  544. };
  545. // round top and left to avoid blurry text
  546. var left = Math.round(data.offsets.popper.left);
  547. var top = Math.round(data.offsets.popper.top);
  548. // if gpuAcceleration is set to true and transform is supported, we use `translate3d` to apply the position to the popper
  549. // we automatically use the supported prefixed version if needed
  550. var prefixedProperty;
  551. if (this._options.gpuAcceleration && (prefixedProperty = getSupportedPropertyName('transform'))) {
  552. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  553. styles.top = 0;
  554. styles.left = 0;
  555. }
  556. // othwerise, we use the standard `left` and `top` properties
  557. else {
  558. styles.left =left;
  559. styles.top = top;
  560. }
  561. // any property present in `data.styles` will be applied to the popper,
  562. // in this way we can make the 3rd party modifiers add custom styles to it
  563. // Be aware, modifiers could override the properties defined in the previous
  564. // lines of this modifier!
  565. Object.assign(styles, data.styles);
  566. setStyle(this._popper, styles);
  567. // set an attribute which will be useful to style the tooltip (use it to properly position its arrow)
  568. // NOTE: 1 DOM access here
  569. this._popper.setAttribute('x-placement', data.placement);
  570. // if the arrow modifier is required and the arrow style has been computed, apply the arrow style
  571. if (this.isModifierRequired(this.modifiers.applyStyle, this.modifiers.arrow) && data.offsets.arrow) {
  572. setStyle(data.arrowElement, data.offsets.arrow);
  573. }
  574. return data;
  575. };
  576. /**
  577. * Modifier used to shift the popper on the start or end of its reference element side
  578. * @method
  579. * @memberof Popper.modifiers
  580. * @argument {Object} data - The data object generated by `update` method
  581. * @returns {Object} The data object, properly modified
  582. */
  583. Popper.prototype.modifiers.shift = function(data) {
  584. var placement = data.placement;
  585. var basePlacement = placement.split('-')[0];
  586. var shiftVariation = placement.split('-')[1];
  587. // if shift shiftVariation is specified, run the modifier
  588. if (shiftVariation) {
  589. var reference = data.offsets.reference;
  590. var popper = getPopperClientRect(data.offsets.popper);
  591. var shiftOffsets = {
  592. y: {
  593. start: { top: reference.top },
  594. end: { top: reference.top + reference.height - popper.height }
  595. },
  596. x: {
  597. start: { left: reference.left },
  598. end: { left: reference.left + reference.width - popper.width }
  599. }
  600. };
  601. var axis = ['bottom', 'top'].indexOf(basePlacement) !== -1 ? 'x' : 'y';
  602. data.offsets.popper = Object.assign(popper, shiftOffsets[axis][shiftVariation]);
  603. }
  604. return data;
  605. };
  606. /**
  607. * Modifier used to make sure the popper does not overflows from it's boundaries
  608. * @method
  609. * @memberof Popper.modifiers
  610. * @argument {Object} data - The data object generated by `update` method
  611. * @returns {Object} The data object, properly modified
  612. */
  613. Popper.prototype.modifiers.preventOverflow = function(data) {
  614. var order = this._options.preventOverflowOrder;
  615. var popper = getPopperClientRect(data.offsets.popper);
  616. var check = {
  617. left: function() {
  618. var left = popper.left;
  619. if (popper.left < data.boundaries.left) {
  620. left = Math.max(popper.left, data.boundaries.left);
  621. }
  622. return { left: left };
  623. },
  624. right: function() {
  625. var left = popper.left;
  626. if (popper.right > data.boundaries.right) {
  627. left = Math.min(popper.left, data.boundaries.right - popper.width);
  628. }
  629. return { left: left };
  630. },
  631. top: function() {
  632. var top = popper.top;
  633. if (popper.top < data.boundaries.top) {
  634. top = Math.max(popper.top, data.boundaries.top);
  635. }
  636. return { top: top };
  637. },
  638. bottom: function() {
  639. var top = popper.top;
  640. if (popper.bottom > data.boundaries.bottom) {
  641. top = Math.min(popper.top, data.boundaries.bottom - popper.height);
  642. }
  643. return { top: top };
  644. }
  645. };
  646. order.forEach(function(direction) {
  647. data.offsets.popper = Object.assign(popper, check[direction]());
  648. });
  649. return data;
  650. };
  651. /**
  652. * Modifier used to make sure the popper is always near its reference
  653. * @method
  654. * @memberof Popper.modifiers
  655. * @argument {Object} data - The data object generated by _update method
  656. * @returns {Object} The data object, properly modified
  657. */
  658. Popper.prototype.modifiers.keepTogether = function(data) {
  659. var popper = getPopperClientRect(data.offsets.popper);
  660. var reference = data.offsets.reference;
  661. var f = Math.floor;
  662. if (popper.right < f(reference.left)) {
  663. data.offsets.popper.left = f(reference.left) - popper.width;
  664. }
  665. if (popper.left > f(reference.right)) {
  666. data.offsets.popper.left = f(reference.right);
  667. }
  668. if (popper.bottom < f(reference.top)) {
  669. data.offsets.popper.top = f(reference.top) - popper.height;
  670. }
  671. if (popper.top > f(reference.bottom)) {
  672. data.offsets.popper.top = f(reference.bottom);
  673. }
  674. return data;
  675. };
  676. /**
  677. * Modifier used to flip the placement of the popper when the latter is starting overlapping its reference element.
  678. * Requires the `preventOverflow` modifier before it in order to work.
  679. * **NOTE:** This modifier will run all its previous modifiers everytime it tries to flip the popper!
  680. * @method
  681. * @memberof Popper.modifiers
  682. * @argument {Object} data - The data object generated by _update method
  683. * @returns {Object} The data object, properly modified
  684. */
  685. Popper.prototype.modifiers.flip = function(data) {
  686. // check if preventOverflow is in the list of modifiers before the flip modifier.
  687. // otherwise flip would not work as expected.
  688. if (!this.isModifierRequired(this.modifiers.flip, this.modifiers.preventOverflow)) {
  689. console.warn('WARNING: preventOverflow modifier is required by flip modifier in order to work, be sure to include it before flip!');
  690. return data;
  691. }
  692. if (data.flipped && data.placement === data._originalPlacement) {
  693. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  694. return data;
  695. }
  696. var placement = data.placement.split('-')[0];
  697. var placementOpposite = getOppositePlacement(placement);
  698. var variation = data.placement.split('-')[1] || '';
  699. var flipOrder = [];
  700. if(this._options.flipBehavior === 'flip') {
  701. flipOrder = [
  702. placement,
  703. placementOpposite
  704. ];
  705. } else {
  706. flipOrder = this._options.flipBehavior;
  707. }
  708. flipOrder.forEach(function(step, index) {
  709. if (placement !== step || flipOrder.length === index + 1) {
  710. return;
  711. }
  712. placement = data.placement.split('-')[0];
  713. placementOpposite = getOppositePlacement(placement);
  714. var popperOffsets = getPopperClientRect(data.offsets.popper);
  715. // this boolean is used to distinguish right and bottom from top and left
  716. // they need different computations to get flipped
  717. var a = ['right', 'bottom'].indexOf(placement) !== -1;
  718. // using Math.floor because the reference offsets may contain decimals we are not going to consider here
  719. if (
  720. a && Math.floor(data.offsets.reference[placement]) > Math.floor(popperOffsets[placementOpposite]) ||
  721. !a && Math.floor(data.offsets.reference[placement]) < Math.floor(popperOffsets[placementOpposite])
  722. ) {
  723. // we'll use this boolean to detect any flip loop
  724. data.flipped = true;
  725. data.placement = flipOrder[index + 1];
  726. if (variation) {
  727. data.placement += '-' + variation;
  728. }
  729. data.offsets.popper = this._getOffsets(this._popper, this._reference, data.placement).popper;
  730. data = this.runModifiers(data, this._options.modifiers, this._flip);
  731. }
  732. }.bind(this));
  733. return data;
  734. };
  735. /**
  736. * Modifier used to add an offset to the popper, useful if you more granularity positioning your popper.
  737. * The offsets will shift the popper on the side of its reference element.
  738. * @method
  739. * @memberof Popper.modifiers
  740. * @argument {Object} data - The data object generated by _update method
  741. * @returns {Object} The data object, properly modified
  742. */
  743. Popper.prototype.modifiers.offset = function(data) {
  744. var offset = this._options.offset;
  745. var popper = data.offsets.popper;
  746. if (data.placement.indexOf('left') !== -1) {
  747. popper.top -= offset;
  748. }
  749. else if (data.placement.indexOf('right') !== -1) {
  750. popper.top += offset;
  751. }
  752. else if (data.placement.indexOf('top') !== -1) {
  753. popper.left -= offset;
  754. }
  755. else if (data.placement.indexOf('bottom') !== -1) {
  756. popper.left += offset;
  757. }
  758. return data;
  759. };
  760. /**
  761. * Modifier used to move the arrows on the edge of the popper to make sure them are always between the popper and the reference element
  762. * It will use the CSS outer size of the arrow element to know how many pixels of conjuction are needed
  763. * @method
  764. * @memberof Popper.modifiers
  765. * @argument {Object} data - The data object generated by _update method
  766. * @returns {Object} The data object, properly modified
  767. */
  768. Popper.prototype.modifiers.arrow = function(data) {
  769. var arrow = this._options.arrowElement;
  770. var arrowOffset = this._options.arrowOffset;
  771. // if the arrowElement is a string, suppose it's a CSS selector
  772. if (typeof arrow === 'string') {
  773. arrow = this._popper.querySelector(arrow);
  774. }
  775. // if arrow element is not found, don't run the modifier
  776. if (!arrow) {
  777. return data;
  778. }
  779. // the arrow element must be child of its popper
  780. if (!this._popper.contains(arrow)) {
  781. console.warn('WARNING: `arrowElement` must be child of its popper element!');
  782. return data;
  783. }
  784. // arrow depends on keepTogether in order to work
  785. if (!this.isModifierRequired(this.modifiers.arrow, this.modifiers.keepTogether)) {
  786. console.warn('WARNING: keepTogether modifier is required by arrow modifier in order to work, be sure to include it before arrow!');
  787. return data;
  788. }
  789. var arrowStyle = {};
  790. var placement = data.placement.split('-')[0];
  791. var popper = getPopperClientRect(data.offsets.popper);
  792. var reference = data.offsets.reference;
  793. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  794. var len = isVertical ? 'height' : 'width';
  795. var side = isVertical ? 'top' : 'left';
  796. var translate = isVertical ? 'translateY' : 'translateX';
  797. var altSide = isVertical ? 'left' : 'top';
  798. var opSide = isVertical ? 'bottom' : 'right';
  799. var arrowSize = getOuterSizes(arrow)[len];
  800. //
  801. // extends keepTogether behavior making sure the popper and its reference have enough pixels in conjuction
  802. //
  803. // top/left side
  804. if (reference[opSide] - arrowSize < popper[side]) {
  805. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowSize);
  806. }
  807. // bottom/right side
  808. if (reference[side] + arrowSize > popper[opSide]) {
  809. data.offsets.popper[side] += (reference[side] + arrowSize) - popper[opSide];
  810. }
  811. // compute center of the popper
  812. var center = reference[side] + (arrowOffset || (reference[len] / 2) - (arrowSize / 2));
  813. var sideValue = center - popper[side];
  814. // prevent arrow from being placed not contiguously to its popper
  815. sideValue = Math.max(Math.min(popper[len] - arrowSize - 8, sideValue), 8);
  816. arrowStyle[side] = sideValue;
  817. arrowStyle[altSide] = ''; // make sure to remove any old style from the arrow
  818. data.offsets.arrow = arrowStyle;
  819. data.arrowElement = arrow;
  820. return data;
  821. };
  822. //
  823. // Helpers
  824. //
  825. /**
  826. * Get the outer sizes of the given element (offset size + margins)
  827. * @function
  828. * @ignore
  829. * @argument {Element} element
  830. * @returns {Object} object containing width and height properties
  831. */
  832. function getOuterSizes(element) {
  833. // NOTE: 1 DOM access here
  834. var _display = element.style.display, _visibility = element.style.visibility;
  835. element.style.display = 'block'; element.style.visibility = 'hidden';
  836. var calcWidthToForceRepaint = element.offsetWidth;
  837. // original method
  838. var styles = root.getComputedStyle(element);
  839. var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
  840. var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
  841. var result = { width: element.offsetWidth + y, height: element.offsetHeight + x };
  842. // reset element styles
  843. element.style.display = _display; element.style.visibility = _visibility;
  844. return result;
  845. }
  846. /**
  847. * Get the opposite placement of the given one/
  848. * @function
  849. * @ignore
  850. * @argument {String} placement
  851. * @returns {String} flipped placement
  852. */
  853. function getOppositePlacement(placement) {
  854. var hash = {left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  855. return placement.replace(/left|right|bottom|top/g, function(matched){
  856. return hash[matched];
  857. });
  858. }
  859. /**
  860. * Given the popper offsets, generate an output similar to getBoundingClientRect
  861. * @function
  862. * @ignore
  863. * @argument {Object} popperOffsets
  864. * @returns {Object} ClientRect like output
  865. */
  866. function getPopperClientRect(popperOffsets) {
  867. var offsets = Object.assign({}, popperOffsets);
  868. offsets.right = offsets.left + offsets.width;
  869. offsets.bottom = offsets.top + offsets.height;
  870. return offsets;
  871. }
  872. /**
  873. * Given an array and the key to find, returns its index
  874. * @function
  875. * @ignore
  876. * @argument {Array} arr
  877. * @argument keyToFind
  878. * @returns index or null
  879. */
  880. function getArrayKeyIndex(arr, keyToFind) {
  881. var i = 0, key;
  882. for (key in arr) {
  883. if (arr[key] === keyToFind) {
  884. return i;
  885. }
  886. i++;
  887. }
  888. return null;
  889. }
  890. /**
  891. * Get CSS computed property of the given element
  892. * @function
  893. * @ignore
  894. * @argument {Eement} element
  895. * @argument {String} property
  896. */
  897. function getStyleComputedProperty(element, property) {
  898. // NOTE: 1 DOM access here
  899. var css = root.getComputedStyle(element, null);
  900. return css[property];
  901. }
  902. /**
  903. * Returns the offset parent of the given element
  904. * @function
  905. * @ignore
  906. * @argument {Element} element
  907. * @returns {Element} offset parent
  908. */
  909. function getOffsetParent(element) {
  910. // NOTE: 1 DOM access here
  911. var offsetParent = element.offsetParent;
  912. return offsetParent === root.document.body || !offsetParent ? root.document.documentElement : offsetParent;
  913. }
  914. /**
  915. * Returns the scrolling parent of the given element
  916. * @function
  917. * @ignore
  918. * @argument {Element} element
  919. * @returns {Element} offset parent
  920. */
  921. function getScrollParent(element) {
  922. var parent = element.parentNode;
  923. if (!parent) {
  924. return element;
  925. }
  926. if (parent === root.document) {
  927. // Firefox puts the scrollTOp value on `documentElement` instead of `body`, we then check which of them is
  928. // greater than 0 and return the proper element
  929. if (root.document.body.scrollTop || root.document.body.scrollLeft) {
  930. return root.document.body;
  931. } else {
  932. return root.document.documentElement;
  933. }
  934. }
  935. // Firefox want us to check `-x` and `-y` variations as well
  936. if (
  937. ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow')) !== -1 ||
  938. ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-x')) !== -1 ||
  939. ['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-y')) !== -1
  940. ) {
  941. // If the detected scrollParent is body, we perform an additional check on its parentNode
  942. // in this way we'll get body if the browser is Chrome-ish, or documentElement otherwise
  943. // fixes issue #65
  944. return parent;
  945. }
  946. return getScrollParent(element.parentNode);
  947. }
  948. /**
  949. * Check if the given element is fixed or is inside a fixed parent
  950. * @function
  951. * @ignore
  952. * @argument {Element} element
  953. * @argument {Element} customContainer
  954. * @returns {Boolean} answer to "isFixed?"
  955. */
  956. function isFixed(element) {
  957. if (element === root.document.body) {
  958. return false;
  959. }
  960. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  961. return true;
  962. }
  963. return element.parentNode ? isFixed(element.parentNode) : element;
  964. }
  965. /**
  966. * Set the style to the given popper
  967. * @function
  968. * @ignore
  969. * @argument {Element} element - Element to apply the style to
  970. * @argument {Object} styles - Object with a list of properties and values which will be applied to the element
  971. */
  972. function setStyle(element, styles) {
  973. function is_numeric(n) {
  974. return (n !== '' && !isNaN(parseFloat(n)) && isFinite(n));
  975. }
  976. Object.keys(styles).forEach(function(prop) {
  977. var unit = '';
  978. // add unit if the value is numeric and is one of the following
  979. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && is_numeric(styles[prop])) {
  980. unit = 'px';
  981. }
  982. element.style[prop] = styles[prop] + unit;
  983. });
  984. }
  985. /**
  986. * Check if the given variable is a function
  987. * @function
  988. * @ignore
  989. * @argument {*} functionToCheck - variable to check
  990. * @returns {Boolean} answer to: is a function?
  991. */
  992. function isFunction(functionToCheck) {
  993. var getType = {};
  994. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  995. }
  996. /**
  997. * Get the position of the given element, relative to its offset parent
  998. * @function
  999. * @ignore
  1000. * @param {Element} element
  1001. * @return {Object} position - Coordinates of the element and its `scrollTop`
  1002. */
  1003. function getOffsetRect(element) {
  1004. var elementRect = {
  1005. width: element.offsetWidth,
  1006. height: element.offsetHeight,
  1007. left: element.offsetLeft,
  1008. top: element.offsetTop
  1009. };
  1010. elementRect.right = elementRect.left + elementRect.width;
  1011. elementRect.bottom = elementRect.top + elementRect.height;
  1012. // position
  1013. return elementRect;
  1014. }
  1015. /**
  1016. * Get bounding client rect of given element
  1017. * @function
  1018. * @ignore
  1019. * @param {HTMLElement} element
  1020. * @return {Object} client rect
  1021. */
  1022. function getBoundingClientRect(element) {
  1023. var rect = element.getBoundingClientRect();
  1024. // whether the IE version is lower than 11
  1025. var isIE = navigator.userAgent.indexOf("MSIE") != -1;
  1026. // fix ie document bounding top always 0 bug
  1027. var rectTop = isIE && element.tagName === 'HTML'
  1028. ? -element.scrollTop
  1029. : rect.top;
  1030. return {
  1031. left: rect.left,
  1032. top: rectTop,
  1033. right: rect.right,
  1034. bottom: rect.bottom,
  1035. width: rect.right - rect.left,
  1036. height: rect.bottom - rectTop
  1037. };
  1038. }
  1039. /**
  1040. * Given an element and one of its parents, return the offset
  1041. * @function
  1042. * @ignore
  1043. * @param {HTMLElement} element
  1044. * @param {HTMLElement} parent
  1045. * @return {Object} rect
  1046. */
  1047. function getOffsetRectRelativeToCustomParent(element, parent, fixed) {
  1048. var elementRect = getBoundingClientRect(element);
  1049. var parentRect = getBoundingClientRect(parent);
  1050. if (fixed) {
  1051. var scrollParent = getScrollParent(parent);
  1052. parentRect.top += scrollParent.scrollTop;
  1053. parentRect.bottom += scrollParent.scrollTop;
  1054. parentRect.left += scrollParent.scrollLeft;
  1055. parentRect.right += scrollParent.scrollLeft;
  1056. }
  1057. var rect = {
  1058. top: elementRect.top - parentRect.top ,
  1059. left: elementRect.left - parentRect.left ,
  1060. bottom: (elementRect.top - parentRect.top) + elementRect.height,
  1061. right: (elementRect.left - parentRect.left) + elementRect.width,
  1062. width: elementRect.width,
  1063. height: elementRect.height
  1064. };
  1065. return rect;
  1066. }
  1067. /**
  1068. * Get the prefixed supported property name
  1069. * @function
  1070. * @ignore
  1071. * @argument {String} property (camelCase)
  1072. * @returns {String} prefixed property (camelCase)
  1073. */
  1074. function getSupportedPropertyName(property) {
  1075. var prefixes = ['', 'ms', 'webkit', 'moz', 'o'];
  1076. for (var i = 0; i < prefixes.length; i++) {
  1077. var toCheck = prefixes[i] ? prefixes[i] + property.charAt(0).toUpperCase() + property.slice(1) : property;
  1078. if (typeof root.document.body.style[toCheck] !== 'undefined') {
  1079. return toCheck;
  1080. }
  1081. }
  1082. return null;
  1083. }
  1084. /**
  1085. * The Object.assign() method is used to copy the values of all enumerable own properties from one or more source
  1086. * objects to a target object. It will return the target object.
  1087. * This polyfill doesn't support symbol properties, since ES5 doesn't have symbols anyway
  1088. * Source: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
  1089. * @function
  1090. * @ignore
  1091. */
  1092. if (!Object.assign) {
  1093. Object.defineProperty(Object, 'assign', {
  1094. enumerable: false,
  1095. configurable: true,
  1096. writable: true,
  1097. value: function(target) {
  1098. if (target === undefined || target === null) {
  1099. throw new TypeError('Cannot convert first argument to object');
  1100. }
  1101. var to = Object(target);
  1102. for (var i = 1; i < arguments.length; i++) {
  1103. var nextSource = arguments[i];
  1104. if (nextSource === undefined || nextSource === null) {
  1105. continue;
  1106. }
  1107. nextSource = Object(nextSource);
  1108. var keysArray = Object.keys(nextSource);
  1109. for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
  1110. var nextKey = keysArray[nextIndex];
  1111. var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
  1112. if (desc !== undefined && desc.enumerable) {
  1113. to[nextKey] = nextSource[nextKey];
  1114. }
  1115. }
  1116. }
  1117. return to;
  1118. }
  1119. });
  1120. }
  1121. return Popper;
  1122. }));