{"version":3,"file":"kendo.colorpicker.min.js","sources":["kendo.colorpicker.js"],"sourcesContent":["(function(f, define){\n define('colorpicker/colorselector',[ \"kendo.core\" ], f);\n})(function(){\n\n(function($, undefined) {\n // WARNING: removing the following jshint declaration and turning\n // == into === to make JSHint happy will break functionality.\n\n var kendo = window.kendo,\n ui = kendo.ui,\n Widget = ui.Widget,\n parseColor = kendo.parseColor,\n TabKeyTrap = kendo.ui.Popup.TabKeyTrap,\n\n extend = $.extend,\n\n NS = \".kendoColorTools\",\n KEYDOWN_NS = \"keydown\" + NS,\n DISABLED = \"k-disabled\";\n\n var ColorSelector = Widget.extend({\n init: function(element, options) {\n var that = this;\n\n Widget.fn.init.call(that, element, options);\n element = that.element;\n options = that.options;\n\n if (element.is(\"input\")) {\n that._initialValue();\n that._preventDefaultLabelClick();\n } else {\n that._value = parseColor(options.value);\n }\n\n that._tabIndex = element.attr(\"tabIndex\") || 0;\n\n if (options._standalone) {\n that._triggerSelect = that._triggerChange;\n }\n },\n options: {\n name: \"ColorSelector\",\n ARIATemplate: 'Current selected color is #=data || \"none\"#',\n value: null,\n _standalone: true\n },\n events: [\n \"change\",\n \"select\",\n \"forceSelect\",\n \"cancel\"\n ],\n color: function(value) {\n if (value !== undefined) {\n this._value = parseColor(value);\n\n if (this.element.is(\"input\")) {\n this._updateInput(this._value);\n }\n\n this._updateUI(this._value);\n }\n\n return this._value;\n },\n value: function(color) {\n color = this.color(color);\n\n if (color) {\n if (this.options.opacity) {\n color = color.toCssRgba();\n } else {\n color = color.toCss();\n }\n }\n\n return color || null;\n },\n enable: function(enable) {\n if (arguments.length === 0) {\n enable = true;\n }\n\n if (this.element.is(\"input\")) {\n this.element.attr(\"disabled\", !enable);\n }\n\n this.wrapper.toggleClass(DISABLED, !enable);\n\n this._onEnable(enable);\n },\n _attachFocusEvents: function () {\n this.wrapper.on(KEYDOWN_NS, this._navKeydown.bind(this))\n .on(\"focusout\" + NS, this._navFocusout.bind(this));\n },\n _initialValue: function() {\n var element = this.element,\n options = this.options,\n value = options.value || element.attr(\"value\");\n\n if (value) {\n this._value = parseColor(value, true);\n }\n\n this.element.val(value);\n },\n _innerTabindex: function(value) {\n var wrapper = this.wrapper;\n\n wrapper.find(\".k-draghandle, .k-button, .k-input-inner\").attr(\"tabindex\", value);\n },\n _isInputTypeColor: function() {\n var el = this.element[0];\n return (/^input$/i).test(el.tagName) && (/^color$/i).test(el.type);\n },\n _navFocusout: function() {\n var that = this,\n wrapper = that.wrapper[0];\n\n setTimeout(function() {\n if (!wrapper.contains(document.activeElement)) {\n that._releaseInnerFocus();\n }\n });\n },\n _navKeydown: function(e) {\n var wrapper = this.wrapper;\n\n if (e.keyCode === kendo.keys.ENTER && wrapper.attr(\"tabindex\")) {\n e.preventDefault();\n\n this._trapInnerFocus();\n } else if (e.keyCode === kendo.keys.ESC && wrapper.attr(\"tabindex\") === undefined) {\n this._releaseInnerFocus();\n this.wrapper.trigger(\"focus\");\n }\n },\n _releaseInnerFocus: function() {\n this._tabKeyTrap.removeTrap();\n this.wrapper.attr(\"tabindex\", this._tabIndex);\n this._innerTabindex(-1);\n },\n _select: function(color, nohooks) {\n var prev = this._value;\n\n color = this.color(color);\n\n if (!nohooks) {\n if ((color && (!prev || !color.equals(prev))) || (color === null && color !== prev)) {\n this.element.trigger(\"change\");\n this.trigger(\"change\", { value: this.value() });\n } else if (!this._standalone) {\n this.trigger(\"cancel\");\n }\n }\n },\n _navigation: function() {\n var value = this.value();\n\n if (value && value.indexOf(\"rgba\") > -1) {\n value = value.replace(\"rgba\", \"RGBA\");\n };\n\n if (this.options._otOfPicker) {\n this._innerTabindex(-1);\n this._attachFocusEvents();\n this._tabKeyTrap = new TabKeyTrap(this.wrapper);\n\n this._ariaTemplate = kendo.template(this.options.ARIATemplate);\n this.wrapper.attr({\n \"aria-label\": this._ariaTemplate(value || \"\"),\n tabindex: this._tabIndex\n });\n } else {\n this.wrapper.removeAttr(\"tabindex\");\n this.wrapper.removeAttr(\"aria-label\");\n this.wrapper.removeAttr(\"role\");\n this.wrapper.removeAttr(\"aria-keyshortcuts\");\n }\n },\n _trapInnerFocus: function() {\n this._innerTabindex(0);\n this.wrapper.removeAttr(\"tabindex\");\n this.wrapper.find(\".k-hsv-draghandle\").trigger(\"focus\");\n this._tabKeyTrap.trap();\n },\n _triggerSelect: function(color) {\n triggerEvent(this, \"select\", color);\n },\n _triggerChange: function(color) {\n triggerEvent(this, \"change\", color);\n },\n destroy: function() {\n if (this.element) {\n this.element.off(NS);\n }\n\n if (this.wrapper) {\n this.wrapper.off(KEYDOWN_NS);\n this.wrapper.off(NS).find(\"*\").off(NS);\n this.wrapper = null;\n }\n\n Widget.fn.destroy.call(this);\n },\n _preventDefaultLabelClick: function() {\n // if there exists a