espurna-sonoff-pow/html/vendor/jquery.wheelcolorpicker-3.0.3.min.js

14 lines
28 KiB
JavaScript
Raw Permalink Normal View History

2018-06-06 15:28:17 +02:00
/**
* jQuery Wheel Color Picker v3.0.3
*
* http://www.jar2.net/projects/jquery-wheelcolorpicker
*
* Author : Fajar Chandra
* Date : 2017.09.03
*
* Copyright © 2011-2017 Fajar Chandra. All rights reserved.
* Released under MIT License.
* http://www.opensource.org/licenses/mit-license.php
*/
!function(a){a.fn.wheelColorPicker=function(){var c=this;if(arguments.length>0)var d=[].shift,e=d.apply(arguments),f="string"==typeof e?e.charAt(0).toUpperCase()+e.slice(1):e;else var e=void 0,f=void 0;var g=arguments;return this.each(function(){var d=a(this).data("jQWCP.instance");if(void 0==d||null==d){var h={};"object"==typeof e&&(h=e),d=new b.ColorPicker(this,h),a(this).data("jQWCP.instance",d)}if(void 0===e||"object"==typeof e);else if("function"==typeof d[e]){var i=d[e].apply(d,g);if(i!==d)return c=i,!1}else if("function"==typeof d["set"+f]&&g.length>0){var i=d["set"+f].apply(d,g);if(i!==d)return c=i,!1}else if("function"==typeof d["get"+f]){var i=d["get"+f].apply(d,g);if(i!==d)return c=i,!1}else if(void 0!==d.options[e]&&g.length>0)d.options[e]=g[0];else{if(void 0!==d.options[e])return c=d.options[e],!1;a.error("Method/option named "+e+" does not exist on jQuery.wheelColorPicker")}}),c};var b=a.fn.wheelColorPicker;b.defaults={format:"hex",preview:!1,live:!0,userinput:!0,validate:!0,autoResize:!0,autoFormat:!0,preserveWheel:null,cssClass:"",layout:"popup",animDuration:200,quality:1,sliders:null,rounding:2,mobile:!0,mobileWidth:480,hideKeyboard:!1,htmlOptions:!0,snap:!1,snapTolerance:.05},b.BUG_RELATIVE_PAGE_ORIGIN=!1,b.ORIGIN={left:0,top:0},b.colorToStr=function(a,b){var c="";switch(b){case"css":c="#";case"hex":var d=Math.round(255*a.r).toString(16);1==d.length&&(d="0"+d);var e=Math.round(255*a.g).toString(16);1==e.length&&(e="0"+e);var f=Math.round(255*a.b).toString(16);1==f.length&&(f="0"+f),c+=d+e+f;break;case"cssa":c="#";case"hexa":var d=Math.round(255*a.r).toString(16);1==d.length&&(d="0"+d);var e=Math.round(255*a.g).toString(16);1==e.length&&(e="0"+e);var f=Math.round(255*a.b).toString(16);1==f.length&&(f="0"+f);var g=Math.round(255*a.a).toString(16);1==g.length&&(g="0"+g),c+=d+e+f+g;break;case"rgb":c="rgb("+Math.round(255*a.r)+","+Math.round(255*a.g)+","+Math.round(255*a.b)+")";break;case"rgb%":c="rgb("+100*a.r+"%,"+100*a.g+"%,"+100*a.b+"%)";break;case"rgba":c="rgba("+Math.round(255*a.r)+","+Math.round(255*a.g)+","+Math.round(255*a.b)+","+a.a+")";break;case"rgba%":c="rgba("+100*a.r+"%,"+100*a.g+"%,"+100*a.b+"%,"+100*a.a+"%)";break;case"hsv":c="hsv("+360*a.h+","+a.s+","+a.v+")";break;case"hsv%":c="hsv("+100*a.h+"%,"+100*a.s+"%,"+100*a.v+"%)";break;case"hsva":c="hsva("+360*a.h+","+a.s+","+a.v+","+a.a+")";break;case"hsva%":c="hsva("+100*a.h+"%,"+100*a.s+"%,"+100*a.v+"%,"+100*a.a+"%)";break;case"hsb":c="hsb("+a.h+","+a.s+","+a.v+")";break;case"hsb%":c="hsb("+100*a.h+"%,"+100*a.s+"%,"+100*a.v+"%)";break;case"hsba":c="hsba("+a.h+","+a.s+","+a.v+","+a.a+")";break;case"hsba%":c="hsba("+100*a.h+"%,"+100*a.s+"%,"+100*a.v+"%,"+100*a.a+"%)"}return c},b.strToColor=function(a){var c,d,b={a:1};if(null!=a.match(/^#[0-9a-f]{3}$/i)||a.match(/^#[0-9a-f]{4}$/i)){if(isNaN(b.r=17*parseInt(a.substr(1,1),16)/255))return!1;if(isNaN(b.g=17*parseInt(a.substr(2,1),16)/255))return!1;if(isNaN(b.b=17*parseInt(a.substr(3,1),16)/255))return!1;if(5==a.length&&isNaN(b.a=17*parseInt(a.substr(4,1),16)/255))return!1}else if(null!=a.match(/^[0-9a-f]{3}$/i)||null!=a.match(/^[0-9a-f]{4}$/i)){if(isNaN(b.r=17*parseInt(a.substr(0,1),16)/255))return!1;if(isNaN(b.g=17*parseInt(a.substr(1,1),16)/255))return!1;if(isNaN(b.b=17*parseInt(a.substr(2,1),16)/255))return!1;if(4==a.length&&isNaN(b.a=17*parseInt(a.substr(3,1),16)/255))return!1}else if(null!=a.match(/^#[0-9a-f]{6}$/i)||null!=a.match(/^#[0-9a-f]{8}$/i)){if(isNaN(b.r=parseInt(a.substr(1,2),16)/255))return!1;if(isNaN(b.g=parseInt(a.substr(3,2),16)/255))return!1;if(isNaN(b.b=parseInt(a.substr(5,2),16)/255))return!1;if(9==a.length&&isNaN(b.a=parseInt(a.substr(7,2),16)/255))return!1}else if(null!=a.match(/^[0-9a-f]{6}$/i)||null!=a.match(/^[0-9a-f]{8}$/i)){if(isNaN(b.r=parseInt(a.substr(0,2),16)/255))return!1;if(isNaN(b.g=parseInt(a.substr(2,2),16)/255))return!1;if(isNaN(b.b=parseInt(a.substr(4,2),16)/255))return!1;if(8==a.length&&isNaN(b.a=parseInt(a.substr(6,2),16)/255))return!1}else if(null!=a.match(/^rgba\s*\(\s*([0-9\.]+%|[01]?\.?[0-9]*)\s*,\s*([0-9\.]+%|[01]?\.?[0-9]*)\s*,\s*([0-9\.]+%|[01]?\.?[0-9