!function(f){f.jqx.jqxWidget("jqxColorPicker","",{}),f.extend(f.jqx._jqxColorPicker.prototype,{defineInstance:function(){var e={disabled:!1,height:null,width:null,color:new f.jqx.color({hex:"ff0000"}),redString:"R:",greenString:"G:",blueString:"B:",showTransparent:!1,colorMode:"saturation",_delayLoading:!1,events:["colorchange"]};return this===f.jqx._jqxColorPicker.prototype||f.extend(!0,this,e),e},_createFromInput:function(e){var t,r,o,i,s,a=this;"input"==a.element.nodeName.toLowerCase()&&(a.field=a.element,a.field.className&&(a._className=a.field.className),t={title:a.field.title},a.field.getAttribute("value")&&(r=a.field.getAttribute("value"),a.color=new f.jqx.color({hex:r})),a.field.id.length?t.id=a.field.id.replace(/[^\w]/g,"_")+"_"+e:t.id=f.jqx.utilities.createId()+"_"+e,(o=f("
",t))[0].style.cssText=a.field.style.cssText,a.width||(a.width=f(a.field).width()),a.height||(a.height=f(a.field).outerHeight()),f(a.field).hide().after(o),i=a.host.data(),a.host=o,a.host.data(i),a.element=o[0],a.element.id=a.field.id,a.field.id=t.id,a._className&&(a.host.addClass(a._className),f(a.field).removeClass(a._className)),a.field.tabIndex&&(s=a.field.tabIndex,a.field.tabIndex=-1,a.element.tabIndex=s))},createInstance:function(e){this._createFromInput("jqxColorPicker"),this.render();var t=this;f.jqx.utilities.resize(this.host,function(){t._setSize(),t.refresh()},!1,!this._delayLoading)},render:function(){this.element.innerHTML="";this._isTouchDevice=f.jqx.mobile.isTouchDevice(),"string"==typeof this.color&&(this.color=new f.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=f(""),this.container.appendTo(this.host),this.colorMap=f(""),this.colorMap.appendTo(this.container),this.colorBar=f(""),this.colorBar.appendTo(this.container),this.colorPanel=f(""),this.colorPanel.appendTo(this.container),this.hexPanel=f(""),this.hexPanel.appendTo(this.colorPanel),this.hexPanel.append('#'),this.hex=f(""),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=f(""),this.rgb.appendTo(this.colorPanel),this.red=f(""),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=f(""),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=f(""),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=f(""),this.preview.addClass(this.toThemeProperty("jqx-widget-content")),this.preview.appendTo(this.colorPanel),this.colorBarPointer=f(""),this.colorBarPointer.addClass(this.toThemeProperty("jqx-color-picker-bar-pointer")),this.colorMapPointer=f(""),this.colorMapPointer.addClass(this.toThemeProperty("jqx-color-picker-pointer")),this.transparent=f(""),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,i=parseInt(e.pageX),s=parseInt(t.offset().left),a=parseInt(e.pageY),h=parseInt(t.offset().top);this._isTouchDevice&&(i=(o=f.jqx.position(e)).left,a=o.top),-1==r[0].className.indexOf("jqx-color-picker-bar")&&r.css("margin-left",i-8-s),h<=a&&a<=h+t.height()&&r.css("margin-top",a-8-h)},_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=f.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=f.jqx.mobile.getTouchEventName("touchmove")+".picker"+this.element.id),this.addHandler(f(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,a="mousedown.colorBar"+this.element.id,h="mouseup.colorBar"+this.element.id;this._isTouchDevice&&(s=f.jqx.mobile.getTouchEventName("touchmove")+".colorBar"+this.element.id,a=f.jqx.mobile.getTouchEventName("touchstart")+".colorBar"+this.element.id,h=f.jqx.mobile.getTouchEventName("touchend")+".colorBar"+this.element.id),this.addHandler(this.colorBar,a,function(e){r.disabled||(r.beginDragBar=!0,i(e))}),this.addHandler(f(document),s,function(e){r.disabled||1==r.beginDragBar&&(i(e),r._isTouchDevice&&e.preventDefault())}),this.addHandler(f(document),h,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=f.jqx.mobile.getTouchEventName("touchmove")+".colorBar"+e,r=f.jqx.mobile.getTouchEventName("touchstart")+".colorBar"+e,o=f.jqx.mobile.getTouchEventName("touchend")+".colorBar"+e,i=f.jqx.mobile.getTouchEventName("touchstart")+".picker"+e,s=f.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(f(document),s),this.removeHandler(f(document),t),this.removeHandler(f(document),o)},_raiseEvent:function(e,t){null==t&&(t={owner:null});var r=this.events[e],o=t||{};o.owner=this;var i=new f.Event(r);return i.owner=this,i.args=o,this.host.trigger(i)},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 f.jqx.color({rgb:e}):"#"==e.substring(0,1)?this.color=new f.jqx.color({hex:e.substring(1)}):this.color=new f.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,s=0,a=0,h=t.offset(),n=t.height(),l=t.width(),c=e.pageX,d=e.pageY;return this._isTouchDevice&&(c=(i=f.jqx.position(e)).left,d=i.top),s=c