!function(c){c.jqx.jqxWidget("jqxColorPicker","",{}),c.extend(c.jqx._jqxColorPicker.prototype,{defineInstance:function(){var e={disabled:!1,height:null,width:null,color:new c.jqx.color({hex:"ff0000"}),redString:"R:",greenString:"G:",blueString:"B:",showTransparent:!1,colorMode:"saturation",_delayLoading:!1,events:["colorchange"]};return this===c.jqx._jqxColorPicker.prototype||c.extend(!0,this,e),e},_createFromInput:function(e){var t,r,o=this;"input"==o.element.nodeName.toLowerCase()&&(o.field=o.element,o.field.className&&(o._className=o.field.className),r={title:o.field.title},o.field.getAttribute("value")&&(t=o.field.getAttribute("value"),o.color=new c.jqx.color({hex:t})),o.field.id.length?r.id=o.field.id.replace(/[^\w]/g,"_")+"_"+e:r.id=c.jqx.utilities.createId()+"_"+e,(t=c("
",r))[0].style.cssText=o.field.style.cssText,o.width||(o.width=c(o.field).width()),o.height||(o.height=c(o.field).outerHeight()),c(o.field).hide().after(t),e=o.host.data(),o.host=t,o.host.data(e),o.element=t[0],o.element.id=o.field.id,o.field.id=r.id,o._className&&(o.host.addClass(o._className),c(o.field).removeClass(o._className)),o.field.tabIndex&&(r=o.field.tabIndex,o.field.tabIndex=-1,o.element.tabIndex=r))},createInstance:function(e){this._createFromInput("jqxColorPicker"),this.render();var t=this;c.jqx.utilities.resize(this.host,function(){t._setSize(),t.refresh()},!1,!this._delayLoading)},render:function(){this.element.innerHTML="";this._isTouchDevice=c.jqx.mobile.isTouchDevice(),"string"==typeof this.color&&(this.color=new c.jqx.color({hex:this.color})),this._setSize(),this.host.addClass(this.toThemeProperty("jqx-widget")),this.host.addClass(this.toThemeProperty("jqx-reset")),this.host.addClass(this.toThemeProperty("jqx-color-picker")),this.container=c(""),this.container.appendTo(this.host),this.colorMap=c(""),this.colorMap.appendTo(this.container),this.colorBar=c(""),this.colorBar.appendTo(this.container),this.colorPanel=c(""),this.colorPanel.appendTo(this.container),this.hexPanel=c(""),this.hexPanel.appendTo(this.colorPanel),this.hexPanel.append('#'),this.hex=c(""),this.hex.addClass(this.toThemeProperty("jqx-input")),this.hex.addClass(this.toThemeProperty("jqx-widget-content")),this.hex.appendTo(this.hexPanel),this.colorPanel.append(''),this.rgb=c(""),this.rgb.appendTo(this.colorPanel),this.red=c(""),this.red.addClass(this.toThemeProperty("jqx-input")),this.red.addClass(this.toThemeProperty("jqx-widget-content")),this.rgb.append(''+this.redString+""),this.red.appendTo(this.rgb),this.green=c(""),this.green.addClass(this.toThemeProperty("jqx-input")),this.green.addClass(this.toThemeProperty("jqx-widget-content")),this.rgb.append(''+this.greenString+""),this.green.appendTo(this.rgb),this.colorPanel.addClass(this.toThemeProperty("jqx-color-picker-map-overlay")),this._mapImageOverlayURL=this._getImageUrl(this.colorPanel),this.colorPanel.removeClass(this.toThemeProperty("jqx-color-picker-map-overlay")),this.blue=c(""),this.blue.addClass(this.toThemeProperty("jqx-input")),this.blue.addClass(this.toThemeProperty("jqx-widget-content")),this.rgb.append(''+this.blueString+""),this.blue.appendTo(this.rgb),this.preview=c(""),this.preview.addClass(this.toThemeProperty("jqx-widget-content")),this.preview.appendTo(this.colorPanel),this.colorBarPointer=c(""),this.colorBarPointer.addClass(this.toThemeProperty("jqx-color-picker-bar-pointer")),this.colorMapPointer=c(""),this.colorMapPointer.addClass(this.toThemeProperty("jqx-color-picker-pointer")),this.transparent=c(""),this.disabled&&(this.host.addClass(this.toThemeProperty("jqx-fill-state-disabled")),this.element.disabled=!0),this._addHandlers()},val:function(e){return 0==arguments.length?"#"+this.color.hex:(this.setColor(e),this.color.hex)},_setPositionFromValue:function(){var e,t=this,r=t.color.h,o=100-t.color.v,i=t.colorMap.height(),s=t.colorMap.width(),a=r*s/360,h=o*i/100;"saturation"==this.colorMode?(e=(e=100-t.color.s)*i/100,t._saturation=100-t.color.s,t.colorMapPointer.css("margin-left",a-8),t.colorMapPointer.css("margin-top",h-8),t.colorBarPointer.css("margin-top",e-8),t.colorMapImageOverlay.css("opacity",(100-t.color.s)/100)):(a=(r=t.color.s)*s/100,h=o*i/100,e=(e=360-t.color.h)*i/360,t._hue=t.color.h,t.colorMapPointer.css("margin-left",a-8),t.colorMapPointer.css("margin-top",h-8),t.colorBarPointer.css("margin-top",e-8))},updateRGB:function(){var e=this;e.color.setRgb(e.red.val(),e.green.val(),e.blue.val()),e._updateUI(),e._raiseEvent("0",{color:e.color}),e.color.transparent=!1},_setPosition:function(e,t,r){var o=parseInt(e.pageX),i=parseInt(t.offset().left),s=parseInt(e.pageY),a=parseInt(t.offset().top);this._isTouchDevice&&(o=(e=c.jqx.position(e)).left,s=e.top),-1==r[0].className.indexOf("jqx-color-picker-bar")&&r.css("margin-left",o-8-i),a<=s&&s<=a+t.height()&&r.css("margin-top",s-8-a)},_handleKeyInput:function(e,t,r){if(!e.disabled){if(!e._validateKey(t))return t;r.val(e._setValueInRange(r.val(),0,255)),this.updateRGB(),this._setPositionFromValue()}},_addHandlers:function(){var r=this;this.addHandler(this.colorMapPointer,"dragStart",function(e){return e.preventDefault(),!1}),this.addHandler(this.colorBarPointer,"dragStart",function(e){return e.preventDefault(),!1}),this.addHandler(this.transparent,"click",function(e){r._raiseEvent("0",{color:"transparent"}),e.preventDefault(),r.color.transparent=!0}),this.addHandler(this.host,"selectionstart",function(e){return e.preventDefault(),!1}),this.addHandler(this.blue,"keyup blur",function(e){r._handleKeyInput(r,e,r.blue)}),this.addHandler(this.green,"keyup blur",function(e){r._handleKeyInput(r,e,r.green)}),this.addHandler(this.red,"keyup blur",function(e){r._handleKeyInput(r,e,r.red)}),this.addHandler(this.hex,"keyup blur",function(e){if(!r.disabled)return r._validateKey(e)?void(6==r.hex.val().toString().length&&(r.hex.val(r.color.validateHex(r.hex.val())),r.color.setHex(r.hex.val()),r._updateUI(),r._setPositionFromValue(),r._raiseEvent("0",{color:r.color}))):e}),this.addHandler(this.colorMap,"dragstart",function(e){return e.preventDefault(),!1});function t(e){var t;r._setPosition(e,r.colorMap,r.colorMapPointer),"saturation"==r.colorMode?(360<(t=r._valuesFromMouse(e,r.colorMap,360,100)).x&&(t.x=360),r.color.setHsv(t.x,null!=r._saturation?100-r._saturation:100,100-t.y)):(100<(t=r._valuesFromMouse(e,r.colorMap,100,100)).x&&(t.x=100),r.color.setHsv(null!=r._hue?r._hue:360,t.x,100-t.y)),r._updateUI(),r._raiseEvent("0",{color:r.color}),r.color.transparent=!1}var e="mousedown.picker"+this.element.id;this._isTouchDevice&&(e=c.jqx.mobile.getTouchEventName("touchstart")+".picker"+this.element.id),this.addHandler(this.colorMap,e,function(e){r.disabled||(r.beginDrag=!0,t(e))});var o="mousemove.picker"+this.element.id;this._isTouchDevice&&(o=c.jqx.mobile.getTouchEventName("touchmove")+".picker"+this.element.id),this.addHandler(c(document),o,function(e){r.disabled||1==r.beginDrag&&(t(e),r._isTouchDevice&&e.preventDefault())}),this._isTouchDevice||this.addHandler(this.colorBar,"dragstart",function(e){return e.preventDefault(),!1});function i(e){var t;r._setPosition(e,r.colorBar,r.colorBarPointer),"saturation"==r.colorMode?(t=r._valuesFromMouse(e,r.colorBar,100,100),r.color.s=t.y,r._saturation=t.y,r.colorMapImageOverlay.css("opacity",r.color.s/100),r.color.setHsv(r.color.h,100-r.color.s,r.color.v)):(t=r._valuesFromMouse(e,r.colorBar,100,360),r.color.h=360-t.y,r._hue=r.color.h,r.color.setHsv(r.color.h,r.color.s,r.color.v)),r._updateUI(),r._raiseEvent("0",{color:r.color}),r.color.transparent=!1}var s="mousemove.colorBar"+this.element.id,e="mousedown.colorBar"+this.element.id,o="mouseup.colorBar"+this.element.id;this._isTouchDevice&&(s=c.jqx.mobile.getTouchEventName("touchmove")+".colorBar"+this.element.id,e=c.jqx.mobile.getTouchEventName("touchstart")+".colorBar"+this.element.id,o=c.jqx.mobile.getTouchEventName("touchend")+".colorBar"+this.element.id),this.addHandler(this.colorBar,e,function(e){r.disabled||(r.beginDragBar=!0,i(e))}),this.addHandler(c(document),s,function(e){r.disabled||1==r.beginDragBar&&(i(e),r._isTouchDevice&&e.preventDefault())}),this.addHandler(c(document),o,function(e){r.disabled||(r.beginDrag=!1,r.beginDragBar=!1)})},_removeHandlers:function(){this.removeHandler(this.transparent,"click"),this.removeHandler(this.host,"selectionstart"),this.removeHandler(this.blue,"keyup blur"),this.removeHandler(this.green,"keyup blur"),this.removeHandler(this.red,"keyup blur"),this.removeHandler(this.hex,"keyup blur"),this.removeHandler(this.colorMap,"dragstart"),this.removeHandler(this.colorBar,"dragstart"),this.removeHandler(this.colorMapPointer,"dragStart"),this.removeHandler(this.colorBarPointer,"dragStart");var e=this.element.id,t="mousemove.colorBar"+e,r="mousedown.colorBar"+e,o="mouseup.colorBar"+e,i="mousedown.picker"+e,s="mousemove.picker"+e;this._isTouchDevice&&(t=c.jqx.mobile.getTouchEventName("touchmove")+".colorBar"+e,r=c.jqx.mobile.getTouchEventName("touchstart")+".colorBar"+e,o=c.jqx.mobile.getTouchEventName("touchend")+".colorBar"+e,i=c.jqx.mobile.getTouchEventName("touchstart")+".picker"+e,s=c.jqx.mobile.getTouchEventName("touchmove")+".picker"+e),this.removeHandler(this.colorMap,i),this.removeHandler(this.colorMap,s),this.removeHandler(this.colorBar,r),this.removeHandler(this.colorBar,t),this.removeHandler(c(document),s),this.removeHandler(c(document),t),this.removeHandler(c(document),o)},_raiseEvent:function(e,t){null==t&&(t={owner:null});e=this.events[e],t=t||{};t.owner=this;e=new c.Event(e);return e.owner=this,e.args=t,this.host.trigger(e)},setColor:function(e){e&&("transparent"==e?(this.color.transparent=!0,this.color.hex="000",this.color.r=0,this.color.g=0,this.color.b=0):e.r?this.color=new c.jqx.color({rgb:e}):"#"==e.substring(0,1)?this.color=new c.jqx.color({hex:e.substring(1)}):this.color=new c.jqx.color({hex:e}),this._updateUI(),this._setPositionFromValue(),this._raiseEvent("0",{color:this.color}))},getColor:function(){return this.color},resize:function(e,t){this.width=e,this.height=t,this._setSize(),this.refresh()},propertyChangedHandler:function(e,t,r,o){null!=e.isInitialized&&0!=e.isInitialized&&("colorMode"==t&&e.refresh(),"color"==t&&(e._updateUI(),e._setPositionFromValue(),e._raiseEvent("0",{color:o})),"width"!=t&&"height"!=t||(e._setSize(),e.refresh()),"showTransparent"==t&&e.refresh(),"disabled"==t&&((this.element.disabled=o)?e.host.addClass(e.toThemeProperty("jqx-fill-state-disabled")):e.host.removeClass(e.toThemeProperty("jqx-fill-state-disabled"))))},_valuesFromMouse:function(e,t,r,o){var i=0,s=0,a=t.offset(),h=t.height(),n=t.width(),l=e.pageX,t=e.pageY;return this._isTouchDevice&&(l=(e=c.jqx.position(e)).left,t=e.top),i=l