corrade-http-templates – Blame information for rev 61
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
61 | office | 1 | (function (global, factory) { |
2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery')) : |
||
3 | typeof define === 'function' && define.amd ? define(['jquery'], factory) : |
||
4 | (global.Util = factory(global.jQuery)); |
||
5 | }(this, (function ($) { 'use strict'; |
||
6 | |||
7 | $ = $ && $.hasOwnProperty('default') ? $['default'] : $; |
||
8 | |||
9 | /** |
||
10 | * -------------------------------------------------------------------------- |
||
11 | * Bootstrap (v4.1.3): util.js |
||
12 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) |
||
13 | * -------------------------------------------------------------------------- |
||
14 | */ |
||
15 | |||
16 | var Util = function ($$$1) { |
||
17 | /** |
||
18 | * ------------------------------------------------------------------------ |
||
19 | * Private TransitionEnd Helpers |
||
20 | * ------------------------------------------------------------------------ |
||
21 | */ |
||
22 | var TRANSITION_END = 'transitionend'; |
||
23 | var MAX_UID = 1000000; |
||
24 | var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp) |
||
25 | |||
26 | function toType(obj) { |
||
27 | return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase(); |
||
28 | } |
||
29 | |||
30 | function getSpecialTransitionEndEvent() { |
||
31 | return { |
||
32 | bindType: TRANSITION_END, |
||
33 | delegateType: TRANSITION_END, |
||
34 | handle: function handle(event) { |
||
35 | if ($$$1(event.target).is(this)) { |
||
36 | return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params |
||
37 | } |
||
38 | |||
39 | return undefined; // eslint-disable-line no-undefined |
||
40 | } |
||
41 | }; |
||
42 | } |
||
43 | |||
44 | function transitionEndEmulator(duration) { |
||
45 | var _this = this; |
||
46 | |||
47 | var called = false; |
||
48 | $$$1(this).one(Util.TRANSITION_END, function () { |
||
49 | called = true; |
||
50 | }); |
||
51 | setTimeout(function () { |
||
52 | if (!called) { |
||
53 | Util.triggerTransitionEnd(_this); |
||
54 | } |
||
55 | }, duration); |
||
56 | return this; |
||
57 | } |
||
58 | |||
59 | function setTransitionEndSupport() { |
||
60 | $$$1.fn.emulateTransitionEnd = transitionEndEmulator; |
||
61 | $$$1.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent(); |
||
62 | } |
||
63 | /** |
||
64 | * -------------------------------------------------------------------------- |
||
65 | * Public Util Api |
||
66 | * -------------------------------------------------------------------------- |
||
67 | */ |
||
68 | |||
69 | |||
70 | var Util = { |
||
71 | TRANSITION_END: 'bsTransitionEnd', |
||
72 | getUID: function getUID(prefix) { |
||
73 | do { |
||
74 | // eslint-disable-next-line no-bitwise |
||
75 | prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here |
||
76 | } while (document.getElementById(prefix)); |
||
77 | |||
78 | return prefix; |
||
79 | }, |
||
80 | getSelectorFromElement: function getSelectorFromElement(element) { |
||
81 | var selector = element.getAttribute('data-target'); |
||
82 | |||
83 | if (!selector || selector === '#') { |
||
84 | selector = element.getAttribute('href') || ''; |
||
85 | } |
||
86 | |||
87 | try { |
||
88 | return document.querySelector(selector) ? selector : null; |
||
89 | } catch (err) { |
||
90 | return null; |
||
91 | } |
||
92 | }, |
||
93 | getTransitionDurationFromElement: function getTransitionDurationFromElement(element) { |
||
94 | if (!element) { |
||
95 | return 0; |
||
96 | } // Get transition-duration of the element |
||
97 | |||
98 | |||
99 | var transitionDuration = $$$1(element).css('transition-duration'); |
||
100 | var floatTransitionDuration = parseFloat(transitionDuration); // Return 0 if element or transition duration is not found |
||
101 | |||
102 | if (!floatTransitionDuration) { |
||
103 | return 0; |
||
104 | } // If multiple durations are defined, take the first |
||
105 | |||
106 | |||
107 | transitionDuration = transitionDuration.split(',')[0]; |
||
108 | return parseFloat(transitionDuration) * MILLISECONDS_MULTIPLIER; |
||
109 | }, |
||
110 | reflow: function reflow(element) { |
||
111 | return element.offsetHeight; |
||
112 | }, |
||
113 | triggerTransitionEnd: function triggerTransitionEnd(element) { |
||
114 | $$$1(element).trigger(TRANSITION_END); |
||
115 | }, |
||
116 | // TODO: Remove in v5 |
||
117 | supportsTransitionEnd: function supportsTransitionEnd() { |
||
118 | return Boolean(TRANSITION_END); |
||
119 | }, |
||
120 | isElement: function isElement(obj) { |
||
121 | return (obj[0] || obj).nodeType; |
||
122 | }, |
||
123 | typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) { |
||
124 | for (var property in configTypes) { |
||
125 | if (Object.prototype.hasOwnProperty.call(configTypes, property)) { |
||
126 | var expectedTypes = configTypes[property]; |
||
127 | var value = config[property]; |
||
128 | var valueType = value && Util.isElement(value) ? 'element' : toType(value); |
||
129 | |||
130 | if (!new RegExp(expectedTypes).test(valueType)) { |
||
131 | throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\".")); |
||
132 | } |
||
133 | } |
||
134 | } |
||
135 | } |
||
136 | }; |
||
137 | setTransitionEndSupport(); |
||
138 | return Util; |
||
139 | }($); |
||
140 | |||
141 | return Util; |
||
142 | |||
143 | }))); |
||
144 | //# sourceMappingURL=util.js.map |