asd
This commit is contained in:
commit
5e7b81fb76
2102 files changed
+789649
No files matched your search
@@ -0,0 +1,428 @@
|
||||
/*!
|
||||
* bsStepper v1.7.0 (https://github.com/Johann-S/bs-stepper)
|
||||
* Copyright 2018 - 2019 Johann-S <johann.servoire@gmail.com>
|
||||
* Licensed under MIT (https://github.com/Johann-S/bs-stepper/blob/master/LICENSE)
|
||||
*/
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = global || self, global.Stepper = factory());
|
||||
}(this, function () { 'use strict';
|
||||
|
||||
function _extends() {
|
||||
_extends = Object.assign || function (target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
|
||||
for (var key in source) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
return _extends.apply(this, arguments);
|
||||
}
|
||||
|
||||
var matches = window.Element.prototype.matches;
|
||||
|
||||
var closest = function closest(element, selector) {
|
||||
return element.closest(selector);
|
||||
};
|
||||
|
||||
var WinEvent = function WinEvent(inType, params) {
|
||||
return new window.Event(inType, params);
|
||||
};
|
||||
|
||||
var createCustomEvent = function createCustomEvent(eventName, params) {
|
||||
var cEvent = new window.CustomEvent(eventName, params);
|
||||
return cEvent;
|
||||
};
|
||||
/* istanbul ignore next */
|
||||
|
||||
|
||||
function polyfill() {
|
||||
if (!window.Element.prototype.matches) {
|
||||
matches = window.Element.prototype.msMatchesSelector || window.Element.prototype.webkitMatchesSelector;
|
||||
}
|
||||
|
||||
if (!window.Element.prototype.closest) {
|
||||
closest = function closest(element, selector) {
|
||||
if (!document.documentElement.contains(element)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
do {
|
||||
if (matches.call(element, selector)) {
|
||||
return element;
|
||||
}
|
||||
|
||||
element = element.parentElement || element.parentNode;
|
||||
} while (element !== null && element.nodeType === 1);
|
||||
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
if (!window.Event || typeof window.Event !== 'function') {
|
||||
WinEvent = function WinEvent(inType, params) {
|
||||
params = params || {};
|
||||
var e = document.createEvent('Event');
|
||||
e.initEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable));
|
||||
return e;
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof window.CustomEvent !== 'function') {
|
||||
var originPreventDefault = window.Event.prototype.preventDefault;
|
||||
|
||||
createCustomEvent = function createCustomEvent(eventName, params) {
|
||||
var evt = document.createEvent('CustomEvent');
|
||||
params = params || {
|
||||
bubbles: false,
|
||||
cancelable: false,
|
||||
detail: null
|
||||
};
|
||||
evt.initCustomEvent(eventName, params.bubbles, params.cancelable, params.detail);
|
||||
|
||||
evt.preventDefault = function () {
|
||||
if (!this.cancelable) {
|
||||
return;
|
||||
}
|
||||
|
||||
originPreventDefault.call(this);
|
||||
Object.defineProperty(this, 'defaultPrevented', {
|
||||
get: function get() {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return evt;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
polyfill();
|
||||
|
||||
var MILLISECONDS_MULTIPLIER = 1000;
|
||||
var ClassName = {
|
||||
ACTIVE: 'active',
|
||||
LINEAR: 'linear',
|
||||
BLOCK: 'dstepper-block',
|
||||
NONE: 'dstepper-none',
|
||||
FADE: 'fade',
|
||||
VERTICAL: 'vertical'
|
||||
};
|
||||
var transitionEndEvent = 'transitionend';
|
||||
var customProperty = 'bsStepper';
|
||||
|
||||
var show = function show(stepperNode, indexStep, options, done) {
|
||||
var stepper = stepperNode[customProperty];
|
||||
|
||||
if (stepper._steps[indexStep].classList.contains(ClassName.ACTIVE) || stepper._stepsContents[indexStep].classList.contains(ClassName.ACTIVE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var showEvent = createCustomEvent('show.bs-stepper', {
|
||||
cancelable: true,
|
||||
detail: {
|
||||
from: stepper._currentIndex,
|
||||
to: indexStep,
|
||||
indexStep: indexStep
|
||||
}
|
||||
});
|
||||
stepperNode.dispatchEvent(showEvent);
|
||||
|
||||
var activeStep = stepper._steps.filter(function (step) {
|
||||
return step.classList.contains(ClassName.ACTIVE);
|
||||
});
|
||||
|
||||
var activeContent = stepper._stepsContents.filter(function (content) {
|
||||
return content.classList.contains(ClassName.ACTIVE);
|
||||
});
|
||||
|
||||
if (showEvent.defaultPrevented) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeStep.length) {
|
||||
activeStep[0].classList.remove(ClassName.ACTIVE);
|
||||
}
|
||||
|
||||
if (activeContent.length) {
|
||||
activeContent[0].classList.remove(ClassName.ACTIVE);
|
||||
|
||||
if (!stepperNode.classList.contains(ClassName.VERTICAL) && !stepper.options.animation) {
|
||||
activeContent[0].classList.remove(ClassName.BLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
showStep(stepperNode, stepper._steps[indexStep], stepper._steps, options);
|
||||
showContent(stepperNode, stepper._stepsContents[indexStep], stepper._stepsContents, activeContent, done);
|
||||
};
|
||||
|
||||
var showStep = function showStep(stepperNode, step, stepList, options) {
|
||||
stepList.forEach(function (step) {
|
||||
var trigger = step.querySelector(options.selectors.trigger);
|
||||
trigger.setAttribute('aria-selected', 'false'); // if stepper is in linear mode, set disabled attribute on the trigger
|
||||
|
||||
if (stepperNode.classList.contains(ClassName.LINEAR)) {
|
||||
trigger.setAttribute('disabled', 'disabled');
|
||||
}
|
||||
});
|
||||
step.classList.add(ClassName.ACTIVE);
|
||||
var currentTrigger = step.querySelector(options.selectors.trigger);
|
||||
currentTrigger.setAttribute('aria-selected', 'true'); // if stepper is in linear mode, remove disabled attribute on current
|
||||
|
||||
if (stepperNode.classList.contains(ClassName.LINEAR)) {
|
||||
currentTrigger.removeAttribute('disabled');
|
||||
}
|
||||
};
|
||||
|
||||
var showContent = function showContent(stepperNode, content, contentList, activeContent, done) {
|
||||
var stepper = stepperNode[customProperty];
|
||||
var toIndex = contentList.indexOf(content);
|
||||
var shownEvent = createCustomEvent('shown.bs-stepper', {
|
||||
cancelable: true,
|
||||
detail: {
|
||||
from: stepper._currentIndex,
|
||||
to: toIndex,
|
||||
indexStep: toIndex
|
||||
}
|
||||
});
|
||||
|
||||
function complete() {
|
||||
content.classList.add(ClassName.BLOCK);
|
||||
content.removeEventListener(transitionEndEvent, complete);
|
||||
stepperNode.dispatchEvent(shownEvent);
|
||||
done();
|
||||
}
|
||||
|
||||
if (content.classList.contains(ClassName.FADE)) {
|
||||
content.classList.remove(ClassName.NONE);
|
||||
var duration = getTransitionDurationFromElement(content);
|
||||
content.addEventListener(transitionEndEvent, complete);
|
||||
|
||||
if (activeContent.length) {
|
||||
activeContent[0].classList.add(ClassName.NONE);
|
||||
}
|
||||
|
||||
content.classList.add(ClassName.ACTIVE);
|
||||
emulateTransitionEnd(content, duration);
|
||||
} else {
|
||||
content.classList.add(ClassName.ACTIVE);
|
||||
content.classList.add(ClassName.BLOCK);
|
||||
stepperNode.dispatchEvent(shownEvent);
|
||||
done();
|
||||
}
|
||||
};
|
||||
|
||||
var getTransitionDurationFromElement = function getTransitionDurationFromElement(element) {
|
||||
if (!element) {
|
||||
return 0;
|
||||
} // Get transition-duration of the element
|
||||
|
||||
|
||||
var transitionDuration = window.getComputedStyle(element).transitionDuration;
|
||||
var floatTransitionDuration = parseFloat(transitionDuration); // Return 0 if element or transition duration is not found
|
||||
|
||||
if (!floatTransitionDuration) {
|
||||
return 0;
|
||||
} // If multiple durations are defined, take the first
|
||||
|
||||
|
||||
transitionDuration = transitionDuration.split(',')[0];
|
||||
return parseFloat(transitionDuration) * MILLISECONDS_MULTIPLIER;
|
||||
};
|
||||
|
||||
var emulateTransitionEnd = function emulateTransitionEnd(element, duration) {
|
||||
var called = false;
|
||||
var durationPadding = 5;
|
||||
var emulatedDuration = duration + durationPadding;
|
||||
|
||||
function listener() {
|
||||
called = true;
|
||||
element.removeEventListener(transitionEndEvent, listener);
|
||||
}
|
||||
|
||||
element.addEventListener(transitionEndEvent, listener);
|
||||
window.setTimeout(function () {
|
||||
if (!called) {
|
||||
element.dispatchEvent(WinEvent(transitionEndEvent));
|
||||
}
|
||||
|
||||
element.removeEventListener(transitionEndEvent, listener);
|
||||
}, emulatedDuration);
|
||||
};
|
||||
|
||||
var detectAnimation = function detectAnimation(contentList, options) {
|
||||
if (options.animation) {
|
||||
contentList.forEach(function (content) {
|
||||
content.classList.add(ClassName.FADE);
|
||||
content.classList.add(ClassName.NONE);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var buildClickStepLinearListener = function buildClickStepLinearListener() {
|
||||
return function clickStepLinearListener(event) {
|
||||
event.preventDefault();
|
||||
};
|
||||
};
|
||||
|
||||
var buildClickStepNonLinearListener = function buildClickStepNonLinearListener(options) {
|
||||
return function clickStepNonLinearListener(event) {
|
||||
event.preventDefault();
|
||||
var step = closest(event.target, options.selectors.steps);
|
||||
var stepperNode = closest(step, options.selectors.stepper);
|
||||
var stepper = stepperNode[customProperty];
|
||||
|
||||
var stepIndex = stepper._steps.indexOf(step);
|
||||
|
||||
show(stepperNode, stepIndex, options, function () {
|
||||
stepper._currentIndex = stepIndex;
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var DEFAULT_OPTIONS = {
|
||||
linear: true,
|
||||
animation: false,
|
||||
selectors: {
|
||||
steps: '.step',
|
||||
trigger: '.step-trigger',
|
||||
stepper: '.bs-stepper'
|
||||
}
|
||||
};
|
||||
|
||||
var Stepper =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function Stepper(element, _options) {
|
||||
var _this = this;
|
||||
|
||||
if (_options === void 0) {
|
||||
_options = {};
|
||||
}
|
||||
|
||||
this._element = element;
|
||||
this._currentIndex = 0;
|
||||
this._stepsContents = [];
|
||||
this.options = _extends({}, DEFAULT_OPTIONS, {}, _options);
|
||||
this.options.selectors = _extends({}, DEFAULT_OPTIONS.selectors, {}, this.options.selectors);
|
||||
|
||||
if (this.options.linear) {
|
||||
this._element.classList.add(ClassName.LINEAR);
|
||||
}
|
||||
|
||||
this._steps = [].slice.call(this._element.querySelectorAll(this.options.selectors.steps));
|
||||
|
||||
this._steps.filter(function (step) {
|
||||
return step.hasAttribute('data-target');
|
||||
}).forEach(function (step) {
|
||||
_this._stepsContents.push(_this._element.querySelector(step.getAttribute('data-target')));
|
||||
});
|
||||
|
||||
detectAnimation(this._stepsContents, this.options);
|
||||
|
||||
this._setLinkListeners();
|
||||
|
||||
Object.defineProperty(this._element, customProperty, {
|
||||
value: this,
|
||||
writable: true
|
||||
});
|
||||
|
||||
if (this._steps.length) {
|
||||
show(this._element, this._currentIndex, this.options, function () {});
|
||||
}
|
||||
} // Private
|
||||
|
||||
|
||||
var _proto = Stepper.prototype;
|
||||
|
||||
_proto._setLinkListeners = function _setLinkListeners() {
|
||||
var _this2 = this;
|
||||
|
||||
this._steps.forEach(function (step) {
|
||||
var trigger = step.querySelector(_this2.options.selectors.trigger);
|
||||
|
||||
if (_this2.options.linear) {
|
||||
_this2._clickStepLinearListener = buildClickStepLinearListener(_this2.options);
|
||||
trigger.addEventListener('click', _this2._clickStepLinearListener);
|
||||
} else {
|
||||
_this2._clickStepNonLinearListener = buildClickStepNonLinearListener(_this2.options);
|
||||
trigger.addEventListener('click', _this2._clickStepNonLinearListener);
|
||||
}
|
||||
});
|
||||
} // Public
|
||||
;
|
||||
|
||||
_proto.next = function next() {
|
||||
var _this3 = this;
|
||||
|
||||
var nextStep = this._currentIndex + 1 <= this._steps.length - 1 ? this._currentIndex + 1 : this._steps.length - 1;
|
||||
show(this._element, nextStep, this.options, function () {
|
||||
_this3._currentIndex = nextStep;
|
||||
});
|
||||
};
|
||||
|
||||
_proto.previous = function previous() {
|
||||
var _this4 = this;
|
||||
|
||||
var previousStep = this._currentIndex - 1 >= 0 ? this._currentIndex - 1 : 0;
|
||||
show(this._element, previousStep, this.options, function () {
|
||||
_this4._currentIndex = previousStep;
|
||||
});
|
||||
};
|
||||
|
||||
_proto.to = function to(stepNumber) {
|
||||
var _this5 = this;
|
||||
|
||||
var tempIndex = stepNumber - 1;
|
||||
var nextStep = tempIndex >= 0 && tempIndex < this._steps.length ? tempIndex : 0;
|
||||
show(this._element, nextStep, this.options, function () {
|
||||
_this5._currentIndex = nextStep;
|
||||
});
|
||||
};
|
||||
|
||||
_proto.reset = function reset() {
|
||||
var _this6 = this;
|
||||
|
||||
show(this._element, 0, this.options, function () {
|
||||
_this6._currentIndex = 0;
|
||||
});
|
||||
};
|
||||
|
||||
_proto.destroy = function destroy() {
|
||||
var _this7 = this;
|
||||
|
||||
this._steps.forEach(function (step) {
|
||||
var trigger = step.querySelector(_this7.options.selectors.trigger);
|
||||
|
||||
if (_this7.options.linear) {
|
||||
trigger.removeEventListener('click', _this7._clickStepLinearListener);
|
||||
} else {
|
||||
trigger.removeEventListener('click', _this7._clickStepNonLinearListener);
|
||||
}
|
||||
});
|
||||
|
||||
this._element[customProperty] = undefined;
|
||||
this._element = undefined;
|
||||
this._currentIndex = undefined;
|
||||
this._steps = undefined;
|
||||
this._stepsContents = undefined;
|
||||
this._clickStepLinearListener = undefined;
|
||||
this._clickStepNonLinearListener = undefined;
|
||||
};
|
||||
|
||||
return Stepper;
|
||||
}();
|
||||
|
||||
return Stepper;
|
||||
|
||||
}));
|
||||
//# sourceMappingURL=bs-stepper.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"bs-stepper.js","sources":["../../src/js/polyfill.js","../../src/js/util.js","../../src/js/listeners.js","../../src/js/index.js"],"sourcesContent":["let matches = window.Element.prototype.matches\nlet closest = (element, selector) => element.closest(selector)\nlet WinEvent = (inType, params) => new window.Event(inType, params)\nlet createCustomEvent = (eventName, params) => {\n const cEvent = new window.CustomEvent(eventName, params)\n\n return cEvent\n}\n\n/* istanbul ignore next */\nfunction polyfill () {\n if (!window.Element.prototype.matches) {\n matches = window.Element.prototype.msMatchesSelector ||\n window.Element.prototype.webkitMatchesSelector\n }\n\n if (!window.Element.prototype.closest) {\n closest = (element, selector) => {\n if (!document.documentElement.contains(element)) {\n return null\n }\n\n do {\n if (matches.call(element, selector)) {\n return element\n }\n\n element = element.parentElement || element.parentNode\n } while (element !== null && element.nodeType === 1)\n\n return null\n }\n }\n\n if (!window.Event || typeof window.Event !== 'function') {\n WinEvent = (inType, params) => {\n params = params || {}\n const e = document.createEvent('Event')\n e.initEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable))\n return e\n }\n }\n\n if (typeof window.CustomEvent !== 'function') {\n const originPreventDefault = window.Event.prototype.preventDefault\n\n createCustomEvent = (eventName, params) => {\n const evt = document.createEvent('CustomEvent')\n\n params = params || { bubbles: false, cancelable: false, detail: null }\n evt.initCustomEvent(eventName, params.bubbles, params.cancelable, params.detail)\n evt.preventDefault = function () {\n if (!this.cancelable) {\n return\n }\n\n originPreventDefault.call(this)\n Object.defineProperty(this, 'defaultPrevented', {\n get: function () { return true }\n })\n }\n\n return evt\n }\n }\n}\n\npolyfill()\n\nexport {\n closest,\n WinEvent,\n createCustomEvent\n}\n","import { WinEvent, createCustomEvent } from './polyfill'\n\nconst MILLISECONDS_MULTIPLIER = 1000\n\nconst ClassName = {\n ACTIVE: 'active',\n LINEAR: 'linear',\n BLOCK: 'dstepper-block',\n NONE: 'dstepper-none',\n FADE: 'fade',\n VERTICAL: 'vertical'\n}\n\nconst transitionEndEvent = 'transitionend'\nconst customProperty = 'bsStepper'\n\nconst show = (stepperNode, indexStep, options, done) => {\n const stepper = stepperNode[customProperty]\n\n if (stepper._steps[indexStep].classList.contains(ClassName.ACTIVE) || stepper._stepsContents[indexStep].classList.contains(ClassName.ACTIVE)) {\n return\n }\n\n const showEvent = createCustomEvent('show.bs-stepper', {\n cancelable: true,\n detail: {\n from: stepper._currentIndex,\n to: indexStep,\n indexStep\n }\n })\n stepperNode.dispatchEvent(showEvent)\n\n const activeStep = stepper._steps.filter(step => step.classList.contains(ClassName.ACTIVE))\n const activeContent = stepper._stepsContents.filter(content => content.classList.contains(ClassName.ACTIVE))\n\n if (showEvent.defaultPrevented) {\n return\n }\n\n if (activeStep.length) {\n activeStep[0].classList.remove(ClassName.ACTIVE)\n }\n if (activeContent.length) {\n activeContent[0].classList.remove(ClassName.ACTIVE)\n\n if (!stepperNode.classList.contains(ClassName.VERTICAL) && !stepper.options.animation) {\n activeContent[0].classList.remove(ClassName.BLOCK)\n }\n }\n\n showStep(stepperNode, stepper._steps[indexStep], stepper._steps, options)\n showContent(stepperNode, stepper._stepsContents[indexStep], stepper._stepsContents, activeContent, done)\n}\n\nconst showStep = (stepperNode, step, stepList, options) => {\n stepList.forEach(step => {\n const trigger = step.querySelector(options.selectors.trigger)\n\n trigger.setAttribute('aria-selected', 'false')\n // if stepper is in linear mode, set disabled attribute on the trigger\n if (stepperNode.classList.contains(ClassName.LINEAR)) {\n trigger.setAttribute('disabled', 'disabled')\n }\n })\n\n step.classList.add(ClassName.ACTIVE)\n const currentTrigger = step.querySelector(options.selectors.trigger)\n\n currentTrigger.setAttribute('aria-selected', 'true')\n // if stepper is in linear mode, remove disabled attribute on current\n if (stepperNode.classList.contains(ClassName.LINEAR)) {\n currentTrigger.removeAttribute('disabled')\n }\n}\n\nconst showContent = (stepperNode, content, contentList, activeContent, done) => {\n const stepper = stepperNode[customProperty]\n const toIndex = contentList.indexOf(content)\n const shownEvent = createCustomEvent('shown.bs-stepper', {\n cancelable: true,\n detail: {\n from: stepper._currentIndex,\n to: toIndex,\n indexStep: toIndex\n }\n })\n\n Line truncated
|
||||
@@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* bsStepper v1.7.0 (https://github.com/Johann-S/bs-stepper)
|
||||
* Copyright 2018 - 2019 Johann-S <johann.servoire@gmail.com>
|
||||
* Licensed under MIT (https://github.com/Johann-S/bs-stepper/blob/master/LICENSE)
|
||||
*/
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Stepper=e()}(this,function(){"use strict";function t(){return(t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t}).apply(this,arguments)}var e=window.Element.prototype.matches,n=function(t,e){return t.closest(e)},s=function(t,e){return new window.Event(t,e)},i=function(t,e){return new window.CustomEvent(t,e)};!function(){if(window.Element.prototype.matches||(e=window.Element.prototype.msMatchesSelector||window.Element.prototype.webkitMatchesSelector),window.Element.prototype.closest||(n=function(t,n){if(!document.documentElement.contains(t))return null;do{if(e.call(t,n))return t;t=t.parentElement||t.parentNode}while(null!==t&&1===t.nodeType);return null}),window.Event&&"function"==typeof window.Event||(s=function(t,e){e=e||{};var n=document.createEvent("Event");return n.initEvent(t,Boolean(e.bubbles),Boolean(e.cancelable)),n}),"function"!=typeof window.CustomEvent){var t=window.Event.prototype.preventDefault;i=function(e,n){var s=document.createEvent("CustomEvent");return n=n||{bubbles:!1,cancelable:!1,detail:null},s.initCustomEvent(e,n.bubbles,n.cancelable,n.detail),s.preventDefault=function(){this.cancelable&&(t.call(this),Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}}))},s}}}();var r={ACTIVE:"active",LINEAR:"linear",BLOCK:"dstepper-block",NONE:"dstepper-none",FADE:"fade",VERTICAL:"vertical"},o="transitionend",c="bsStepper",a=function(t,e,n,s){var o=t[c];if(!o._steps[e].classList.contains(r.ACTIVE)&&!o._stepsContents[e].classList.contains(r.ACTIVE)){var a=i("show.bs-stepper",{cancelable:!0,detail:{from:o._currentIndex,to:e,indexStep:e}});t.dispatchEvent(a);var p=o._steps.filter(function(t){return t.classList.contains(r.ACTIVE)}),d=o._stepsContents.filter(function(t){return t.classList.contains(r.ACTIVE)});a.defaultPrevented||(p.length&&p[0].classList.remove(r.ACTIVE),d.length&&(d[0].classList.remove(r.ACTIVE),t.classList.contains(r.VERTICAL)||o.options.animation||d[0].classList.remove(r.BLOCK)),l(t,o._steps[e],o._steps,n),u(t,o._stepsContents[e],o._stepsContents,d,s))}},l=function(t,e,n,s){n.forEach(function(e){var n=e.querySelector(s.selectors.trigger);n.setAttribute("aria-selected","false"),t.classList.contains(r.LINEAR)&&n.setAttribute("disabled","disabled")}),e.classList.add(r.ACTIVE);var i=e.querySelector(s.selectors.trigger);i.setAttribute("aria-selected","true"),t.classList.contains(r.LINEAR)&&i.removeAttribute("disabled")},u=function(t,e,n,s,a){var l=t[c],u=n.indexOf(e),f=i("shown.bs-stepper",{cancelable:!0,detail:{from:l._currentIndex,to:u,indexStep:u}});if(e.classList.contains(r.FADE)){e.classList.remove(r.NONE);var h=p(e);e.addEventListener(o,function n(){e.classList.add(r.BLOCK),e.removeEventListener(o,n),t.dispatchEvent(f),a()}),s.length&&s[0].classList.add(r.NONE),e.classList.add(r.ACTIVE),d(e,h)}else e.classList.add(r.ACTIVE),e.classList.add(r.BLOCK),t.dispatchEvent(f),a()},p=function(t){if(!t)return 0;var e=window.getComputedStyle(t).transitionDuration;return parseFloat(e)?(e=e.split(",")[0],1e3*parseFloat(e)):0},d=function(t,e){var n=!1,i=e+5;function r(){n=!0,t.removeEventListener(o,r)}t.addEventListener(o,r),window.setTimeout(function(){n||t.dispatchEvent(s(o)),t.removeEventListener(o,r)},i)},f=function(t,e){e.animation&&t.forEach(function(t){t.classList.add(r.FADE),t.classList.add(r.NONE)})},h={linear:!0,animation:!1,selectors:{steps:".step",trigger:".step-trigger",stepper:".bs-stepper"}};return function(){function e(e,n){var s=this;void 0===n&&(n={}),this._element=e,this._currentIndex=0,this._stepsContents=[],this.options=t({},h,{},n),this.options.selectors=t({},h.selectors,{},this.options.selectors),this.options.linear&&this._element.classList.add(r.LINEAR),this._steps=[].slice.call(this._element.querySelectorAll(this.options.selectors.steps)),this._steps.filter(function(t){return t.hasAttribute("data-target")}).forEach(function(t){s._stepsContents.push(s._element.querySelector(t.getAttribute("data-target")))}),f(this._stepsContents,this.options),this._setLinkListeners(),Object.defineProperty(this._element,c,{value:this,writable:!0}),this._steps.length&&a(this._element,this._currentIndex,this.options,function(){})}var s=e.prototype;return s._setLinkListeners=function(){var t=this;this._steps.forEach(function(e){var s,i=e.querySelector(t.options.selectors.trigger);t.options.linear?(t._clickStepLinearListener=(t.options,function(t){t.preventDefault()}),i.addEventListener("click",t._clickStepLinearListener)):(t._clickStepNonLinearListener=(s=t.options,function(t){t.preventDefault();var e=n(t.target,s.selectors.steps),i=n(e,s.selectors.stepper),r=i[c],o=r._steps.indexOf(e);a(i,o,s,function(){r._currentIndex=o})}),i.addEventListener("click",t._clickStepNonLinearListener))})},s.next=function(){var t=this,e=thLine truncated
|
||||
//# sourceMappingURL=bs-stepper.min.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"bs-stepper.min.js","sources":["../../src/js/polyfill.js","../../src/js/util.js","../../src/js/index.js","../../src/js/listeners.js"],"sourcesContent":["let matches = window.Element.prototype.matches\nlet closest = (element, selector) => element.closest(selector)\nlet WinEvent = (inType, params) => new window.Event(inType, params)\nlet createCustomEvent = (eventName, params) => {\n const cEvent = new window.CustomEvent(eventName, params)\n\n return cEvent\n}\n\n/* istanbul ignore next */\nfunction polyfill () {\n if (!window.Element.prototype.matches) {\n matches = window.Element.prototype.msMatchesSelector ||\n window.Element.prototype.webkitMatchesSelector\n }\n\n if (!window.Element.prototype.closest) {\n closest = (element, selector) => {\n if (!document.documentElement.contains(element)) {\n return null\n }\n\n do {\n if (matches.call(element, selector)) {\n return element\n }\n\n element = element.parentElement || element.parentNode\n } while (element !== null && element.nodeType === 1)\n\n return null\n }\n }\n\n if (!window.Event || typeof window.Event !== 'function') {\n WinEvent = (inType, params) => {\n params = params || {}\n const e = document.createEvent('Event')\n e.initEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable))\n return e\n }\n }\n\n if (typeof window.CustomEvent !== 'function') {\n const originPreventDefault = window.Event.prototype.preventDefault\n\n createCustomEvent = (eventName, params) => {\n const evt = document.createEvent('CustomEvent')\n\n params = params || { bubbles: false, cancelable: false, detail: null }\n evt.initCustomEvent(eventName, params.bubbles, params.cancelable, params.detail)\n evt.preventDefault = function () {\n if (!this.cancelable) {\n return\n }\n\n originPreventDefault.call(this)\n Object.defineProperty(this, 'defaultPrevented', {\n get: function () { return true }\n })\n }\n\n return evt\n }\n }\n}\n\npolyfill()\n\nexport {\n closest,\n WinEvent,\n createCustomEvent\n}\n","import { WinEvent, createCustomEvent } from './polyfill'\n\nconst MILLISECONDS_MULTIPLIER = 1000\n\nconst ClassName = {\n ACTIVE: 'active',\n LINEAR: 'linear',\n BLOCK: 'dstepper-block',\n NONE: 'dstepper-none',\n FADE: 'fade',\n VERTICAL: 'vertical'\n}\n\nconst transitionEndEvent = 'transitionend'\nconst customProperty = 'bsStepper'\n\nconst show = (stepperNode, indexStep, options, done) => {\n const stepper = stepperNode[customProperty]\n\n if (stepper._steps[indexStep].classList.contains(ClassName.ACTIVE) || stepper._stepsContents[indexStep].classList.contains(ClassName.ACTIVE)) {\n return\n }\n\n const showEvent = createCustomEvent('show.bs-stepper', {\n cancelable: true,\n detail: {\n from: stepper._currentIndex,\n to: indexStep,\n indexStep\n }\n })\n stepperNode.dispatchEvent(showEvent)\n\n const activeStep = stepper._steps.filter(step => step.classList.contains(ClassName.ACTIVE))\n const activeContent = stepper._stepsContents.filter(content => content.classList.contains(ClassName.ACTIVE))\n\n if (showEvent.defaultPrevented) {\n return\n }\n\n if (activeStep.length) {\n activeStep[0].classList.remove(ClassName.ACTIVE)\n }\n if (activeContent.length) {\n activeContent[0].classList.remove(ClassName.ACTIVE)\n\n if (!stepperNode.classList.contains(ClassName.VERTICAL) && !stepper.options.animation) {\n activeContent[0].classList.remove(ClassName.BLOCK)\n }\n }\n\n showStep(stepperNode, stepper._steps[indexStep], stepper._steps, options)\n showContent(stepperNode, stepper._stepsContents[indexStep], stepper._stepsContents, activeContent, done)\n}\n\nconst showStep = (stepperNode, step, stepList, options) => {\n stepList.forEach(step => {\n const trigger = step.querySelector(options.selectors.trigger)\n\n trigger.setAttribute('aria-selected', 'false')\n // if stepper is in linear mode, set disabled attribute on the trigger\n if (stepperNode.classList.contains(ClassName.LINEAR)) {\n trigger.setAttribute('disabled', 'disabled')\n }\n })\n\n step.classList.add(ClassName.ACTIVE)\n const currentTrigger = step.querySelector(options.selectors.trigger)\n\n currentTrigger.setAttribute('aria-selected', 'true')\n // if stepper is in linear mode, remove disabled attribute on current\n if (stepperNode.classList.contains(ClassName.LINEAR)) {\n currentTrigger.removeAttribute('disabled')\n }\n}\n\nconst showContent = (stepperNode, content, contentList, activeContent, done) => {\n const stepper = stepperNode[customProperty]\n const toIndex = contentList.indexOf(content)\n const shownEvent = createCustomEvent('shown.bs-stepper', {\n cancelable: true,\n detail: {\n from: stepper._currentIndex,\n to: toIndex,\n indexStep: toIndex\n }\n })\Line truncated
|
||||
Reference in new issue
Block a user