{"version":3,"sources":["kendo.switch.js"],"names":["f","define","$","undefined","kendo","window","ui","NS","Widget","support","CHANGE","switchStyles","widget","container","handle","checked","checkedLabel","unchecked","uncheckedLabel","disabled","readonly","active","DISABLED","ARIA_DISABLED","READONLY","ARIA_READONLY","ARIA_CHECKED","CHECKED","CLICK","click","TOUCHEND","pointers","KEYDOWN","LABELIDPART","proxy","SWITCH_TEMPLATE","template","SWITCH_CONTAINER_TEMPLATE","Switch","extend","init","element","options","wrapper","that","this","fn","call","type","styles","wrap","parent","append","messages","addClass","className","removeClass","on","_click","_touchEnd","_keydown","enabled","_tabindex","_initSettings","_aria","notify","setOptions","find","text","width","css","enable","check","attr","labelId","id","labelFor","ariaLabel","ariaLabelledBy","length","guid","events","name","toggleClass","removeAttr","value","apply","destroy","off","toggle","_check","focus","trigger","e","keyCode","keys","SPACEBAR","preventDefault","_isTouch","event","test","originalEvent","pointerType","which","plugin","jQuery","amd","a1","a2","a3"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;CAwBC,SAAUA,EAAGC,QACVA,OAAO,gBAAiB,cAAeD,IACzC,WAuME,MA/LC,UAAUE,EAAGC,GAAb,GACOC,GAAQC,OAAOD,MAAOE,EAAKF,EAAME,GAAIC,EAAK,eAAgBC,EAASF,EAAGE,OAAQC,EAAUL,EAAMK,QAASC,EAAS,SAAUC,GACtHC,OAAQ,oBACRC,UAAW,qBACXC,OAAQ,kBACRC,QAAS,cACTC,aAAc,oBACdC,UAAW,eACXC,eAAgB,qBAChBC,SAAU,mBACVC,SAAU,mBACVC,OAAQ,kBACTC,EAAW,WAAYC,EAAgB,gBAAiBC,EAAW,WAAYC,EAAgB,gBAAiBC,EAAe,eAAgBC,EAAU,UAAWC,EAAQnB,EAAQoB,MAAQtB,EAAIuB,EAAWrB,EAAQsB,SAAW,YAAc,WAAYC,EAAU,UAAYzB,EAAI0B,EAAc,SAAUC,EAAQhC,EAAEgC,MACvTC,EAAkB/B,EAAMgC,SAAS,wDACjCC,EAA4Bj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A6B,GAAKD,QAAQgD,SACR/C,EAAKF,QAAQmB,SAAWjB,EAAKF,QAAQtB,UAAYwB,EAAKgD,QAAQlF,GAAUK,QAASA,KAClF6B,EAAKH,QAAQ,GAAG1B,SAAWA,EAC3B,IAEJ6B,EAAK4B,MAAMzD,GAAX6B,IAEJgB,SAAU,SAAUiC,GACZA,EAAEC,UAAY1F,EAAM2F,KAAKC,WACzBnD,KAAK6C,SACLG,EAAEI,mBAGVC,SAAU,SAAUC,GAChB,MAAO,QAAQC,KAAKD,EAAMnD,OAASmD,EAAME,eAAiB,QAAQD,KAAKD,EAAME,cAAcC,cAE/F5C,OAAQ,SAAUmC,GACThD,KAAKqD,SAASL,IAAkB,IAAZA,EAAEU,OACvB1D,KAAK6C,UAGb/B,UAAW,SAAUkC,GACbhD,KAAKqD,SAASL,KACdhD,KAAK6C,SACLG,EAAEI,oBAId3F,GAAGkG,OAAOlE,IACZjC,OAAOD,MAAMqG,QACRpG,OAAOD,OACE,kBAAVH,SAAwBA,OAAOyG,IAAMzG,OAAS,SAAU0G,EAAIC,EAAIC,IACrEA,GAAMD","file":"kendo.switch.min.js","sourcesContent":["/*!\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n*/\n(function (f, define) {\n define('kendo.switch', ['kendo.core'], f);\n}(function () {\n var __meta__ = {\n id: 'switch',\n name: 'Switch',\n category: 'web',\n description: 'The Switch widget is used to display two exclusive choices.',\n depends: ['core']\n };\n (function ($, undefined) {\n var kendo = window.kendo, ui = kendo.ui, NS = '.kendoSwitch', Widget = ui.Widget, support = kendo.support, CHANGE = 'change', switchStyles = {\n widget: 'k-switch k-widget',\n container: 'k-switch-container',\n handle: 'k-switch-handle',\n checked: 'k-switch-on',\n checkedLabel: 'k-switch-label-on',\n unchecked: 'k-switch-off',\n uncheckedLabel: 'k-switch-label-off',\n disabled: 'k-state-disabled',\n readonly: 'k-state-readonly',\n active: 'k-state-active'\n }, DISABLED = 'disabled', ARIA_DISABLED = 'aria-disabled', READONLY = 'readonly', ARIA_READONLY = 'aria-readonly', ARIA_CHECKED = 'aria-checked', CHECKED = 'checked', CLICK = support.click + NS, TOUCHEND = support.pointers ? 'pointerup' : 'touchend', KEYDOWN = 'keydown' + NS, LABELIDPART = '_label', proxy = $.proxy;\n var SWITCH_TEMPLATE = kendo.template('');\n var SWITCH_CONTAINER_TEMPLATE = kendo.template('' + '#=checked#' + '#=unchecked#' + '' + '');\n var Switch = Widget.extend({\n init: function (element, options) {\n var that = this, wrapper;\n Widget.fn.init.call(that, element, options);\n options = that.options;\n element = that.element[0];\n element.type = 'checkbox';\n wrapper = $(SWITCH_TEMPLATE({ styles: switchStyles }));\n that.wrapper = that.element.wrap(wrapper).parent();\n that.wrapper.append($(SWITCH_CONTAINER_TEMPLATE({\n styles: switchStyles,\n checked: options.messages.checked,\n unchecked: options.messages.unchecked\n }))).addClass(element.className).removeClass('input-validation-error');\n that.wrapper.on(CLICK, proxy(that._click, that)).on(TOUCHEND, proxy(that._touchEnd, that)).on(KEYDOWN, proxy(that._keydown, that));\n if (that.options.enabled) {\n that._tabindex();\n }\n that._initSettings();\n that._aria();\n kendo.notify(that, kendo.ui);\n },\n setOptions: function (options) {\n var that = this, messages = options.messages, checkedLabel, uncheckedLabel;\n that.options = $.extend(that.options, options);\n if (messages && messages.checked !== undefined) {\n checkedLabel = that.wrapper.find('.' + switchStyles.checkedLabel);\n checkedLabel.text(messages.checked);\n }\n if (messages && messages.unchecked !== undefined) {\n uncheckedLabel = that.wrapper.find('.' + switchStyles.uncheckedLabel);\n uncheckedLabel.text(messages.unchecked);\n }\n if (options.width) {\n that.wrapper.css({ width: options.width });\n }\n if (options.enabled !== undefined) {\n that.enable(options.enabled);\n }\n if (options.readonly !== undefined) {\n that.readonly(options.readonly);\n }\n that.check(options.checked);\n },\n _initSettings: function () {\n var that = this, element = that.element[0], options = that.options;\n if (options.width) {\n that.wrapper.css({ width: options.width });\n }\n if (options.checked === null) {\n options.checked = element.checked;\n }\n that.check(options.checked);\n options.enabled = options.enabled && !that.element.attr(DISABLED);\n that.enable(options.enabled);\n options.readonly = options.readonly || !!that.element.attr(READONLY);\n that.readonly(options.readonly);\n },\n _aria: function () {\n var that = this, element = that.element, wrapper = that.wrapper, id = element.attr('id'), labelFor = $('label[for=\"' + id + '\"]'), ariaLabel = element.attr('aria-label'), ariaLabelledBy = element.attr('aria-labelledby');\n if (ariaLabel) {\n wrapper.attr('aria-label', ariaLabel);\n } else if (ariaLabelledBy) {\n wrapper.attr('aria-labelledby', ariaLabelledBy);\n } else if (labelFor.length) {\n var labelId = labelFor.attr('id');\n if (!labelId) {\n labelId = (id || kendo.guid()) + LABELIDPART;\n labelFor.attr('id', labelId);\n }\n wrapper.attr('aria-labelledby', labelId);\n }\n },\n events: [CHANGE],\n options: {\n name: 'Switch',\n messages: {\n checked: 'On',\n unchecked: 'Off'\n },\n width: null,\n checked: null,\n enabled: true,\n readonly: false\n },\n check: function (checked) {\n var that = this, element = that.element[0];\n if (checked === undefined) {\n return element.checked;\n }\n if (element.checked !== checked) {\n that.options.checked = element.checked = checked;\n }\n that.wrapper.attr(ARIA_CHECKED, checked).toggleClass(switchStyles.checked, checked).toggleClass(switchStyles.unchecked, !checked);\n if (checked) {\n that.element.attr(CHECKED, CHECKED);\n } else {\n that.element.removeAttr(CHECKED);\n }\n },\n value: function (value) {\n if (typeof value === 'string') {\n value = value === 'true';\n }\n return this.check.apply(this, [value]);\n },\n destroy: function () {\n Widget.fn.destroy.call(this);\n this.wrapper.off(NS);\n },\n toggle: function () {\n var that = this;\n that.check(!that.element[0].checked);\n },\n enable: function (enable) {\n var element = this.element, wrapper = this.wrapper;\n if (typeof enable == 'undefined') {\n enable = true;\n }\n this.options.enabled = enable;\n if (enable) {\n element.removeAttr(DISABLED);\n wrapper.removeAttr(ARIA_DISABLED);\n } else {\n element.attr(DISABLED, DISABLED);\n wrapper.attr(ARIA_DISABLED, true);\n }\n wrapper.toggleClass(switchStyles.disabled, !enable);\n },\n readonly: function (readonly) {\n var that = this, element = that.element, wrapper = that.wrapper;\n if (typeof readonly == 'undefined') {\n readonly = true;\n }\n that.options.readonly = readonly;\n if (readonly) {\n element.attr(READONLY, true);\n wrapper.attr(ARIA_READONLY, true);\n } else {\n element.removeAttr(READONLY);\n wrapper.removeAttr(ARIA_READONLY);\n }\n wrapper.toggleClass(switchStyles.readonly, readonly);\n },\n _check: function () {\n var that = this, checked = that.element[0].checked = !that.element[0].checked;\n that.wrapper.focus();\n if (!that.options.enabled || that.options.readonly || that.trigger(CHANGE, { checked: checked })) {\n that.element[0].checked = !checked;\n return;\n }\n that.check(checked);\n },\n _keydown: function (e) {\n if (e.keyCode === kendo.keys.SPACEBAR) {\n this._check();\n e.preventDefault();\n }\n },\n _isTouch: function (event) {\n return /touch/.test(event.type) || event.originalEvent && /touch/.test(event.originalEvent.pointerType);\n },\n _click: function (e) {\n if (!this._isTouch(e) && e.which === 1) {\n this._check();\n }\n },\n _touchEnd: function (e) {\n if (this._isTouch(e)) {\n this._check();\n e.preventDefault();\n }\n }\n });\n ui.plugin(Switch);\n }(window.kendo.jQuery));\n return window.kendo;\n}, typeof define == 'function' && define.amd ? define : function (a1, a2, a3) {\n (a3 || a2)();\n}));"]}