').append(stepLink);\n this._link();\n this._stepClasses();\n },\n _stepClasses: function () {\n var options = this.options, stepClasses = stepStyles.step;\n if (options.isFirstStep) {\n stepClasses += SPACE + stepStyles.firstStep;\n }\n if (options.isLastStep) {\n stepClasses += SPACE + stepStyles.lastStep;\n }\n if (!options.enabled) {\n stepClasses += SPACE + stepStyles.disabledStep;\n }\n if (options.error) {\n stepClasses += SPACE + stepStyles.errorStep;\n }\n if (options.previous) {\n stepClasses += SPACE + stepStyles.doneStep;\n if (!options.error) {\n stepClasses += SPACE + stepStyles.successStep;\n }\n } else if (options.selected) {\n stepClasses += SPACE + stepStyles.currentStep;\n stepClasses += SPACE + stepStyles.focusStep;\n }\n this.element.removeClass().addClass(stepClasses);\n }\n });\n var Stepper = Widget.extend({\n init: function (element, options) {\n var that = this;\n options = options || {};\n Widget.fn.init.call(that, element, options);\n that._indicatorAndLabel();\n that._wrapper();\n if (options.steps && options.steps.length) {\n that._processSteps(options.steps);\n that._progressBar();\n }\n that._attachEvents();\n that._resizeHandler = kendo.onResize(function () {\n that.resize();\n });\n },\n options: {\n orientation: 'horizontal',\n linear: true,\n indicator: true,\n label: true,\n selectOnFocus: false,\n steps: null,\n name: 'Stepper'\n },\n events: [\n ACTIVATE,\n SELECT,\n 'kendoKeydown'\n ],\n destroy: function () {\n var that = this;\n if (that.progressBar) {\n Widget.fn.destroy.call(that.progressBar);\n }\n Widget.fn.destroy.call(that);\n kendo.unbindResize(that._resizeHandler);\n that.wrapper.off(STEPPER);\n },\n setOptions: function (options) {\n var that = this;\n Widget.fn.setOptions.call(that, options);\n if (that.progressBar) {\n Widget.fn.destroy.call(that.progressBar);\n }\n that._indicatorAndLabel();\n that._addStepList();\n if (that.options.steps && that.options.steps.length) {\n that._processSteps(that.options.steps);\n that._progressBar();\n }\n },\n enable: function (value) {\n var steps = this.steps(), stepsOptions = this.options.steps;\n var enableStep = function (step, idx) {\n step.enable(value);\n stepsOptions[idx] = step.options;\n };\n if (value) {\n this.wrapper.removeAttr(ARIA_DISABLED);\n } else {\n this.wrapper.attr(ARIA_DISABLED, 'true');\n }\n this.progressBar.enable(value);\n steps.forEach(enableStep);\n },\n insertAt: function (index, stepOptions) {\n var steps = this.options.steps, selectedStep;\n var findSelectedStep = function (step) {\n if (step.selected) {\n selectedStep = step;\n }\n };\n if (!stepOptions || isNaN(index)) {\n return;\n }\n if (index < 0) {\n index = steps.length + index;\n }\n if (index < 0) {\n return;\n }\n if (!steps) {\n steps = [];\n }\n if (steps.length === 0 || index >= steps.length) {\n index = steps.length;\n }\n steps.forEach(findSelectedStep);\n if (stepOptions.selected === true) {\n selectedStep.selected = false;\n }\n steps.splice(index, 0, stepOptions);\n this._createSteps();\n this._renderSteps();\n this._resetProgressBar();\n this._calculateDimensions();\n },\n next: function () {\n if (!this._steps || this._steps.length <= 1) {\n return;\n }\n var selectedStep = this.selectedStep;\n var selectedIndex = selectedStep.getIndex();\n if (selectedIndex + 1 === this._steps.length) {\n return;\n } else {\n this._select(selectedIndex + 1);\n }\n },\n previous: function () {\n if (!this._steps || this._steps.length <= 1) {\n return;\n }\n var selectedStep = this.selectedStep;\n var selectedIndex = selectedStep.getIndex();\n if (selectedIndex === 0) {\n return;\n } else {\n this._select(selectedIndex - 1);\n }\n },\n removeAt: function (index) {\n var steps = this.options.steps, removedStep, newSelected, newSelectedIndex;\n if (isNaN(index) || !steps || steps.length < 2 || index >= steps.length) {\n return;\n }\n if (index < 0) {\n index = steps.length + index;\n }\n if (index < 0) {\n return;\n }\n removedStep = steps.splice(index, 1)[0];\n if (removedStep.selected === true && steps.length > 0) {\n if (index > 0) {\n newSelectedIndex = index - 1;\n } else {\n newSelectedIndex = 0;\n }\n newSelected = steps[newSelectedIndex];\n if (typeof newSelected === 'string') {\n newSelected = { label: newSelected };\n steps[newSelectedIndex] = newSelected;\n }\n newSelected.selected = true;\n newSelected.previous = false;\n }\n this._createSteps();\n this._renderSteps();\n this._resetProgressBar();\n this._calculateDimensions();\n },\n resize: function () {\n this._calculateDimensions();\n },\n select: function (stepIndex) {\n var that = this;\n if (stepIndex === undefined || stepIndex === null || isNaN(stepIndex)) {\n return that.selectedStep;\n }\n if (stepIndex >= that._steps.length || stepIndex < 0) {\n return;\n }\n stepIndex = Number(stepIndex);\n that._select(stepIndex);\n },\n steps: function (steps) {\n if (steps === undefined) {\n return this._steps;\n }\n this._processSteps(steps);\n this._resetProgressBar();\n this._calculateDimensions();\n },\n _processSteps: function (steps) {\n var that = this, selectedStep;\n var findSelectedStep = function (step) {\n if (step.selected) {\n selectedStep = step;\n }\n };\n steps.forEach(findSelectedStep);\n if (!selectedStep) {\n if (typeof steps[0] === 'string') {\n steps[0] = { label: steps[0] };\n }\n steps[0].selected = true;\n }\n that.options.steps = steps;\n that._createSteps();\n that._renderSteps();\n },\n _addStepList: function () {\n var that = this;\n that.wrapper.empty().append($('
').addClass(stepperStyles.stepList));\n that._stepList = that.wrapper.find(DOT + stepperStyles.stepList);\n if (that.options.orientation === VERTICAL) {\n that._stepList.addClass(stepperStyles.stepListVertical);\n } else {\n that._stepList.addClass(stepperStyles.stepListHorizontal);\n }\n },\n _attachEvents: function () {\n var that = this;\n that.wrapper.on(CLICK + STEPPER, DOT + stepStyles.step, proxy(that._selectClickHandler, that)).on(CLICK + STEPPER, proxy(that._wrapperClickHandler, that)).on(FOCUSOUT + STEPPER, proxy(that._focusout, that)).on(KEYDOWN + STEPPER, that, proxy(that._keydown, that));\n },\n _calculateDimensions: function () {\n var orientation = this.options.orientation, numberOfSteps = this._steps.length, stepList = this._stepList, steps = stepList.find(DOT + stepStyles.step), stepWidth = stepList.width() / numberOfSteps, stepHeight = stepList.height() / numberOfSteps, progressElement = this.progressBar.element, margin = 'margin-left', style = {};\n if (orientation === VERTICAL) {\n steps.css('max-height', 100 / numberOfSteps + '%');\n progressElement.css({\n 'margin-top': -1 * (stepList.height() - 16),\n 'height': stepHeight * (numberOfSteps - 1)\n });\n } else {\n steps.css('max-width', 100 / numberOfSteps + '%');\n if (kendo.support.isRtl(this.wrapper)) {\n margin = 'margin-right';\n }\n style[margin] = stepWidth / 2;\n style.width = stepWidth * (numberOfSteps - 1);\n progressElement.css(style);\n }\n },\n _createStep: function (stepOptions, idx, isLastStep) {\n var that = this, isFirstStep = idx === 0, options = that.options, indicatorVisible = options.indicator, labelVisible = options.label;\n stepOptions = extend({}, stepOptions, { enabled: stepOptions.enabled === false ? false : true });\n stepOptions = extend({}, stepOptions, {\n isFirstStep: isFirstStep,\n isLastStep: isLastStep,\n indicatorVisible: indicatorVisible,\n labelVisible: labelVisible,\n index: idx\n });\n return new Step(stepOptions);\n },\n _createSteps: function () {\n var that = this, stepsOptions = that.options.steps, selected = false, step, idx, isLastStep, stepOpt;\n that._steps = [];\n for (idx = 0; idx < stepsOptions.length; idx++) {\n stepOpt = stepsOptions[idx];\n if (typeof stepOpt === 'string') {\n stepOpt = { label: stepOpt };\n }\n if (stepOpt !== undefined) {\n isLastStep = idx === stepsOptions.length - 1;\n if (stepOpt.selected) {\n selected = true;\n } else {\n stepOpt = that._selectablePreviousState(stepOpt, selected, idx);\n }\n step = that._createStep(stepOpt, idx, isLastStep);\n that._steps.push(step);\n if (step.getSelected()) {\n that.selectedStep = step;\n }\n }\n }\n },\n _indicatorAndLabel: function () {\n if (!this.options.indicator && !this.options.label) {\n this.options.indicator = true;\n this.options.label = true;\n }\n },\n _focusout: function (e) {\n var that = this;\n if (!that.wrapper.get(0).contains(e.relatedTarget)) {\n setTimeout(function () {\n that._leaveStepper();\n });\n }\n },\n _focusStep: function (newStep) {\n var focusedStep = this.wrapper.find(DOT + stepStyles.focusStep), allStepLinks = this.wrapper.find(DOT + stepStyles.stepLink);\n if (newStep.length > 0) {\n focusedStep.removeClass(stepStyles.focusStep);\n allStepLinks.attr(TABINDEX, '-1');\n newStep.find(DOT + stepStyles.stepLink).removeAttr(TABINDEX)[0].focus();\n }\n },\n _focusNextStep: function () {\n var focusedStep = $(document.activeElement).closest(DOT + stepStyles.step), nextStep = focusedStep.next();\n this._focusStep(nextStep);\n },\n _focusPreviousStep: function () {\n var focusedStep = $(document.activeElement).closest(DOT + stepStyles.step), previousStep = focusedStep.prev();\n this._focusStep(previousStep);\n },\n _focusFirstStep: function () {\n var wrapper = this.wrapper, firstStep = wrapper.find(DOT + stepStyles.firstStep);\n this._focusStep(firstStep);\n },\n _focusLastStep: function () {\n var wrapper = this.wrapper, lastStep = wrapper.find(DOT + stepStyles.lastStep);\n this._focusStep(lastStep);\n },\n _keydown: function (e) {\n var that = this, keyCode = e.keyCode, focusedStepElement = $(document.activeElement).closest(DOT + stepStyles.step), focusedStepIndex = focusedStepElement.index(), stepsCount = that.steps().length;\n if (keyCode === keys.TAB) {\n if (e.shiftKey && focusedStepIndex > 0) {\n e.preventDefault();\n that._tabKey(e, -1);\n } else if (!e.shiftKey && focusedStepIndex < stepsCount - 1) {\n e.preventDefault();\n that._tabKey(e, +1);\n }\n } else if (keyCode > 34 && keyCode < 41) {\n e.preventDefault();\n that._navKeys(e);\n } else if (keyCode === keys.ENTER || keyCode === keys.SPACEBAR) {\n e.preventDefault();\n that._selectHandler(e, $(document.activeElement).closest(DOT + stepStyles.step));\n } else {\n e.preventDefault();\n }\n },\n _leaveStepper: function () {\n var selectedStep = this.wrapper.find(DOT + stepStyles.currentStep), allStepLinks = this.wrapper.find(DOT + stepStyles.stepLink);\n allStepLinks.removeClass(stepStyles.focusStep).attr(TABINDEX, '-1');\n selectedStep.addClass(stepStyles.focusStep);\n selectedStep.find(DOT + stepStyles.stepLink).removeAttr(TABINDEX);\n },\n _navKeys: function (e) {\n var selectOnFocus = this.options.selectOnFocus;\n if (selectOnFocus) {\n this._navKeysSelect(e);\n } else {\n this._navKeysFocus(e);\n }\n },\n _navKeysFocus: function (e) {\n var keyCode = e.keyCode, rtl = kendo.support.isRtl(this.wrapper), orientation = this.options.orientation;\n switch (keyCode) {\n case keys.DOWN:\n if (rtl && orientation !== VERTICAL) {\n this._focusPreviousStep();\n } else {\n this._focusNextStep();\n }\n break;\n case keys.RIGHT:\n if (rtl) {\n this._focusPreviousStep();\n } else {\n this._focusNextStep();\n }\n break;\n case keys.UP:\n if (rtl && orientation !== VERTICAL) {\n this._focusNextStep();\n } else {\n this._focusPreviousStep();\n }\n break;\n case keys.LEFT:\n if (rtl) {\n this._focusNextStep();\n } else {\n this._focusPreviousStep();\n }\n break;\n case keys.HOME:\n this._focusFirstStep();\n break;\n case keys.END:\n this._focusLastStep();\n break;\n }\n },\n _navKeysSelect: function (e) {\n var keyCode = e.keyCode, focusedStepIndex = $(document.activeElement).closest(DOT + stepStyles.step).index(), rtl = kendo.support.isRtl(this.wrapper), steps = this.steps(), orientation = this.options.orientation, targetStep;\n switch (keyCode) {\n case keys.DOWN:\n if (rtl && orientation !== VERTICAL) {\n targetStep = steps[focusedStepIndex - 1];\n } else {\n targetStep = steps[focusedStepIndex + 1];\n }\n break;\n case keys.RIGHT:\n if (rtl) {\n targetStep = steps[focusedStepIndex - 1];\n } else {\n targetStep = steps[focusedStepIndex + 1];\n }\n break;\n case keys.UP:\n if (rtl && orientation !== VERTICAL) {\n targetStep = steps[focusedStepIndex + 1];\n } else {\n targetStep = steps[focusedStepIndex - 1];\n }\n break;\n case keys.LEFT:\n if (rtl) {\n targetStep = steps[focusedStepIndex + 1];\n } else {\n targetStep = steps[focusedStepIndex - 1];\n }\n break;\n case keys.HOME:\n targetStep = steps[0];\n break;\n case keys.END:\n targetStep = steps[steps.length - 1];\n break;\n }\n if (targetStep) {\n this._focusStep(targetStep.element);\n this._selectHandlerOnKey(e, targetStep.element);\n }\n },\n _progressBar: function () {\n var wrapper = this.wrapper, progressBarOptions = this._progressOptions();\n this.progressBar = $('').kendoProgressBar(progressBarOptions).getKendoProgressBar();\n this._calculateDimensions();\n wrapper.append(this.progressBar.element);\n },\n _progressOptions: function () {\n var options = this.options, orientation = options.orientation, stepsOptions = options.steps, numberOfSteps, progressBarOptions;\n if (!stepsOptions || stepsOptions.length === 0) {\n return;\n } else {\n numberOfSteps = stepsOptions.length;\n }\n progressBarOptions = {\n max: numberOfSteps - 1,\n value: this.select().getIndex(),\n orientation: orientation,\n showStatus: false\n };\n if (orientation === VERTICAL) {\n progressBarOptions.reverse = true;\n }\n return progressBarOptions;\n },\n _resetProgressBar: function () {\n var progressBar = this.progressBar, newOptions;\n if (!progressBar) {\n return;\n }\n newOptions = this._progressOptions();\n progressBar.setOptions(newOptions);\n },\n _renderSteps: function () {\n var steps = this._steps, stepsList = this._stepList, step, idx;\n stepsList.empty();\n for (idx = 0; idx < steps.length; idx++) {\n step = steps[idx];\n stepsList.append(step.element);\n }\n },\n _resetStep: function (i, index, forward) {\n var step = this._steps[i];\n if (!forward && i < index) {\n step.options.selectable = true;\n } else if (i === index) {\n step.options.previous = false;\n step.options.selected = true;\n } else if (forward && i > index) {\n step.options.selectable = true;\n } else {\n step.options.selected = false;\n step.options.previous = forward;\n }\n if (this.options.linear && (i < index - 1 || i > index + 1)) {\n step.options.selectable = false;\n }\n step._link();\n step._stepClasses();\n this.options.steps[i] = step.options;\n },\n _select: function (index) {\n var options = this.options, linear = options.linear, selectedStep = this.select(), selectedIndex = selectedStep.getIndex(), stepsOptions = options.steps, targetStep = this._steps[index], forward, i, min, max;\n if (!targetStep || !targetStep.getEnabled() || !targetStep.getSelectable()) {\n return;\n }\n if (index > selectedIndex) {\n forward = true;\n if (linear) {\n min = Math.max(selectedIndex - 1, 0);\n max = Math.min(index + 1, stepsOptions.length - 1);\n } else {\n min = selectedIndex;\n max = index;\n }\n } else {\n forward = false;\n if (linear) {\n min = Math.max(index - 1, 0);\n max = Math.min(selectedIndex + 1, stepsOptions.length - 1);\n } else {\n min = index;\n max = selectedIndex;\n }\n }\n for (i = min; i <= max; i++) {\n this._resetStep(i, index, forward);\n }\n this.selectedStep = targetStep;\n this.progressBar.value(index);\n },\n _selectablePreviousState: function (stepOpt, selected, idx) {\n var stepsOptions = this.options.steps, linear = this.options.linear;\n if (!selected) {\n stepOpt.previous = true;\n if (linear && !stepsOptions[idx + 1].selected) {\n stepOpt.selectable = false;\n } else {\n stepOpt.selectable = true;\n }\n } else if (linear && !stepsOptions[idx - 1].selected) {\n stepOpt.selectable = false;\n } else {\n stepOpt.selectable = true;\n }\n return stepOpt;\n },\n _selectClickHandler: function (e) {\n var stepElement = $(e.target).closest(DOT + stepStyles.step);\n e.preventDefault();\n this._preventWrapperClick = true;\n this._selectHandler(e, stepElement);\n },\n _selectHandler: function (e, stepElement) {\n var that = this, step = that._steps[stepElement.index()], currentStep = this.select();\n if (!step || step.getIndex() === currentStep.getIndex() || !step.getEnabled() || !step.getSelectable()) {\n that._focusStep(currentStep.element);\n return;\n }\n if (!that.trigger(SELECT, {\n sender: that,\n originalEvent: e,\n step: step\n })) {\n that._select(step.getIndex());\n stepElement.find(DOT + stepStyles.stepLink)[0].focus();\n that.trigger(ACTIVATE, {\n sender: that,\n originalEvent: e,\n step: step\n });\n }\n },\n _selectHandlerOnKey: function (e, stepElement) {\n var that = this, step = that._steps[stepElement.index()];\n if (!step.getEnabled() || !step.getSelectable()) {\n return;\n }\n if (!that.trigger(SELECT, {\n sender: that,\n originalEvent: e,\n step: step\n })) {\n that._select(step.getIndex());\n stepElement.find(DOT + stepStyles.stepLink)[0].focus();\n that.trigger(ACTIVATE, {\n sender: that,\n originalEvent: e,\n step: step\n });\n }\n },\n _tabKey: function (e, shift) {\n var selectOnFocus = this.options.selectOnFocus, focusedStepElement = $(document.activeElement).closest(DOT + stepStyles.step), focusedStepIndex = focusedStepElement.index(), targetStep = $(focusedStepElement.parent().find(DOT + stepStyles.step)[focusedStepIndex + shift]);\n this._focusStep(targetStep);\n if (selectOnFocus) {\n this._selectHandlerOnKey(e, targetStep);\n }\n },\n _wrapper: function () {\n var that = this, element = that.element;\n that.wrapper = element;\n that.wrapper.addClass(stepperStyles.widget);\n if (that.options.linear) {\n that.wrapper.addClass(stepperStyles.stepperLinear);\n }\n this._addStepList();\n },\n _wrapperClickHandler: function (e) {\n var currentStep = this.select();\n if (!this._preventWrapperClick) {\n e.preventDefault();\n this._focusStep(currentStep.element);\n } else {\n this._preventWrapperClick = false;\n }\n }\n });\n kendo.stepper = { Step: Step };\n kendo.ui.plugin(Stepper);\n }(window.kendo.jQuery));\n return window.kendo;\n}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {\n (a3 || a2)();\n}));"]}