aboutsummaryrefslogtreecommitdiff
path: root/js/dist/util.js
diff options
context:
space:
mode:
authorfat <[email protected]>2015-05-07 16:34:28 -0700
committerfat <[email protected]>2015-05-07 16:34:28 -0700
commitc3a79b1a8c2fa8d7fc8edcd3e626dad8b45d5dc3 (patch)
tree06a02f216b801efdba5d920da89b2cad47fd2408 /js/dist/util.js
parent0724bd91ff81b5eca0addce0c336c72b3ec10be5 (diff)
downloadbootstrap-c3a79b1a8c2fa8d7fc8edcd3e626dad8b45d5dc3.tar.xz
bootstrap-c3a79b1a8c2fa8d7fc8edcd3e626dad8b45d5dc3.zip
change the export pattern to protect against leaking globals
Diffstat (limited to 'js/dist/util.js')
-rw-r--r--js/dist/util.js167
1 files changed, 83 insertions, 84 deletions
diff --git a/js/dist/util.js b/js/dist/util.js
index 48865c5d7..4c8c4e639 100644
--- a/js/dist/util.js
+++ b/js/dist/util.js
@@ -5,120 +5,119 @@
* --------------------------------------------------------------------------
*/
-/**
- * ------------------------------------------------------------------------
- * Public Util Api
- * ------------------------------------------------------------------------
- */
-
'use strict';
-var Util = {
+var Util = (function () {
- TRANSITION_END: 'bsTransitionEnd',
+ /**
+ * ------------------------------------------------------------------------
+ * Private TransitionEnd Helpers
+ * ------------------------------------------------------------------------
+ */
- getUID: function getUID(prefix) {
- do prefix += ~ ~(Math.random() * 1000000); while (document.getElementById(prefix));
- return prefix;
- },
+ var transition = false;
- getSelectorFromElement: function getSelectorFromElement(element) {
- var selector = element.getAttribute('data-target');
+ var TransitionEndEvent = {
+ WebkitTransition: 'webkitTransitionEnd',
+ MozTransition: 'transitionend',
+ OTransition: 'oTransitionEnd otransitionend',
+ transition: 'transitionend'
+ };
+
+ function getSpecialTransitionEndEvent() {
+ return {
+ bindType: transition.end,
+ delegateType: transition.end,
+ handle: function handle(event) {
+ if ($(event.target).is(this)) {
+ return event.handleObj.handler.apply(this, arguments);
+ }
+ }
+ };
+ }
- if (!selector) {
- selector = element.getAttribute('href') || '';
- selector = /^#[a-z]/i.test(selector) ? selector : null;
+ function transitionEndTest() {
+ if (window.QUnit) {
+ return false;
}
- return selector;
- },
+ var el = document.createElement('bootstrap');
- reflow: function reflow(element) {
- new Function('bs', 'return bs')(element.offsetHeight);
- },
+ for (var name in TransitionEndEvent) {
+ if (el.style[name] !== undefined) {
+ return { end: TransitionEndEvent[name] };
+ }
+ }
- supportsTransitionEnd: function supportsTransitionEnd() {
- return !!transition;
+ return false;
}
-};
+ function transitionEndEmulator(duration) {
+ var _this = this;
-/**
- * ------------------------------------------------------------------------
- * Private TransitionEnd Helpers
- * ------------------------------------------------------------------------
- */
+ var called = false;
+
+ $(this).one(Util.TRANSITION_END, function () {
+ called = true;
+ });
-var transition = false;
-
-var TransitionEndEvent = {
- WebkitTransition: 'webkitTransitionEnd',
- MozTransition: 'transitionend',
- OTransition: 'oTransitionEnd otransitionend',
- transition: 'transitionend'
-};
-
-function getSpecialTransitionEndEvent() {
- return {
- bindType: transition.end,
- delegateType: transition.end,
- handle: function handle(event) {
- if ($(event.target).is(this)) {
- return event.handleObj.handler.apply(this, arguments);
+ setTimeout(function () {
+ if (!called) {
+ $(_this).trigger(transition.end);
}
- }
- };
-}
+ }, duration);
-function transitionEndTest() {
- if (window.QUnit) {
- return false;
+ return this;
}
- var el = document.createElement('bootstrap');
+ function setTransitionEndSupport() {
+ transition = transitionEndTest();
- for (var name in TransitionEndEvent) {
- if (el.style[name] !== undefined) {
- return { end: TransitionEndEvent[name] };
+ $.fn.emulateTransitionEnd = transitionEndEmulator;
+
+ if (Util.supportsTransitionEnd()) {
+ $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
}
}
- return false;
-}
+ /**
+ * --------------------------------------------------------------------------
+ * Public Util Api
+ * --------------------------------------------------------------------------
+ */
-function transitionEndEmulator(duration) {
- var _this = this;
+ var Util = {
- var called = false;
+ TRANSITION_END: 'bsTransitionEnd',
- $(this).one(Util.TRANSITION_END, function () {
- called = true;
- });
+ getUID: function getUID(prefix) {
+ do prefix += ~ ~(Math.random() * 1000000); while (document.getElementById(prefix));
+ return prefix;
+ },
- setTimeout(function () {
- if (!called) {
- $(_this).trigger(transition.end);
- }
- }, duration);
+ getSelectorFromElement: function getSelectorFromElement(element) {
+ var selector = element.getAttribute('data-target');
+
+ if (!selector) {
+ selector = element.getAttribute('href') || '';
+ selector = /^#[a-z]/i.test(selector) ? selector : null;
+ }
- return this;
-}
+ return selector;
+ },
-function setTransitionEndSupport() {
- transition = transitionEndTest();
+ reflow: function reflow(element) {
+ new Function('bs', 'return bs')(element.offsetHeight);
+ },
- $.fn.emulateTransitionEnd = transitionEndEmulator;
+ supportsTransitionEnd: function supportsTransitionEnd() {
+ return !!transition;
+ }
- if (Util.supportsTransitionEnd()) {
- $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
- }
-}
+ };
-setTransitionEndSupport();
+ setTransitionEndSupport();
-/**
- * ------------------------------------------------------------------------
- * Export Api
- * ------------------------------------------------------------------------
- */
+ return Util;
+})();
//# sourceMappingURL=util.js.map \ No newline at end of file