Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfat <fat@folders.local>2015-05-08 03:07:38 +0300
committerfat <fat@folders.local>2015-05-08 03:14:38 +0300
commit660505188241418ffda53b5eb848defecd5f57e1 (patch)
treeec0895cb5267cc798f386f96caca653a7fe191f1 /js/dist/button.js
parentc3a79b1a8c2fa8d7fc8edcd3e626dad8b45d5dc3 (diff)
button -> es6
Diffstat (limited to 'js/dist/button.js')
-rw-r--r--js/dist/button.js158
1 files changed, 158 insertions, 0 deletions
diff --git a/js/dist/button.js b/js/dist/button.js
new file mode 100644
index 0000000000..76aa09a7f5
--- /dev/null
+++ b/js/dist/button.js
@@ -0,0 +1,158 @@
+'use strict';
+
+var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
+
+/**
+ * --------------------------------------------------------------------------
+ * Bootstrap (v4.0.0): button.js
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ * --------------------------------------------------------------------------
+ */
+
+var Button = (function ($) {
+
+ /**
+ * ------------------------------------------------------------------------
+ * Constants
+ * ------------------------------------------------------------------------
+ */
+
+ var NAME = 'button';
+ var VERSION = '4.0.0';
+ var DATA_KEY = 'bs.button';
+ var JQUERY_NO_CONFLICT = $.fn[NAME];
+ var TRANSITION_DURATION = 150;
+
+ var ClassName = {
+ ACTIVE: 'active',
+ BUTTON: 'btn',
+ FOCUS: 'focus'
+ };
+
+ var Selector = {
+ DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
+ DATA_TOGGLE: '[data-toggle="buttons"]',
+ INPUT: 'input',
+ ACTIVE: '.active',
+ BUTTON: '.btn'
+ };
+
+ var Event = {
+ CLICK: 'click.bs.button.data-api',
+ FOCUS_BLUR: 'focus.bs.button.data-api blur.bs.button.data-api'
+ };
+
+ /**
+ * ------------------------------------------------------------------------
+ * Class Definition
+ * ------------------------------------------------------------------------
+ */
+
+ var Button = (function () {
+ function Button(element) {
+ _classCallCheck(this, Button);
+
+ this.element = element;
+ }
+
+ _createClass(Button, [{
+ key: 'toggle',
+
+ // public
+
+ value: function toggle() {
+ var triggerChangeEvent = true;
+ var rootElement = $(this.element).closest(Selector.DATA_TOGGLE)[0];
+
+ if (rootElement) {
+ var input = $(this.element).find(Selector.INPUT)[0];
+
+ if (input) {
+ if (input.type === 'radio') {
+ if (input.checked && $(this.element).hasClass(ClassName.ACTIVE)) {
+ triggerChangeEvent = false;
+ } else {
+ var activeElement = $(rootElement).find(Selector.ACTIVE)[0];
+
+ if (activeElement) {
+ $(activeElement).removeClass(ClassName.ACTIVE);
+ }
+ }
+ }
+
+ if (triggerChangeEvent) {
+ input.checked = !$(this.element).hasClass(ClassName.ACTIVE);
+ $(this.element).trigger('change');
+ }
+ }
+ } else {
+ this.element.setAttribute('aria-pressed', !$(this.element).hasClass(ClassName.ACTIVE));
+ }
+
+ if (triggerChangeEvent) {
+ $(this.element).toggleClass(ClassName.ACTIVE);
+ }
+ }
+ }], [{
+ key: '_jQueryInterface',
+
+ // static
+
+ value: function _jQueryInterface(config) {
+ return this.each(function () {
+ var data = $(this).data(DATA_KEY);
+
+ if (!data) {
+ data = new Button(this);
+ $(this).data(DATA_KEY, data);
+ }
+
+ if (config === 'toggle') {
+ data[config]();
+ }
+ });
+ }
+ }]);
+
+ return Button;
+ })();
+
+ /**
+ * ------------------------------------------------------------------------
+ * Data Api implementation
+ * ------------------------------------------------------------------------
+ */
+
+ $(document).on(Event.CLICK, Selector.DATA_TOGGLE_CARROT, function (event) {
+ event.preventDefault();
+
+ var button = event.target;
+
+ if (!$(button).hasClass(ClassName.BUTTON)) {
+ button = $(button).closest(Selector.BUTTON);
+ }
+
+ Button._jQueryInterface.call($(button), 'toggle');
+ }).on(Event.FOCUS_BLUR, Selector.DATA_TOGGLE_CARROT, function (event) {
+ var button = $(event.target).closest(Selector.BUTTON)[0];
+ $(button).toggleClass(ClassName.FOCUS, /^focus(in)?$/.test(event.type));
+ });
+
+ /**
+ * ------------------------------------------------------------------------
+ * jQuery
+ * ------------------------------------------------------------------------
+ */
+
+ $.fn[NAME] = Button._jQueryInterface;
+ $.fn[NAME].Constructor = Button;
+ $.fn[NAME].noConflict = function () {
+ $.fn[NAME] = JQUERY_NO_CONFLICT;
+ return Button._jQueryInterface;
+ };
+
+ return Button;
+})(jQuery);
+//# sourceMappingURL=button.js.map \ No newline at end of file