# HG changeset patch # User Thierry Florac # Date 1429022203 -7200 # Node ID ad0378995d5a0f2931789716ff061cb700643399 # Parent 1ea9e5a677a3b4bc0fd2ef11aaf66ea861ccb2f0 Added color plug-ins diff -r 1ea9e5a677a3 -r ad0378995d5a src/pyams_skin/resources/js/ext/jquery-color-2.1.2.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_skin/resources/js/ext/jquery-color-2.1.2.js Tue Apr 14 16:36:43 2015 +0200 @@ -0,0 +1,663 @@ +/*! + * jQuery Color Animations v2.1.2 + * https://github.com/jquery/jquery-color + * + * Copyright 2013 jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + * + * Date: Wed Jan 16 08:47:09 2013 -0600 + */ +(function( jQuery, undefined ) { + + var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor", + + // plusequals test for += 100 -= 100 + rplusequals = /^([\-+])=\s*(\d+\.?\d*)/, + // a set of RE's that can match strings and generate color tuples. + stringParsers = [{ + re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, + parse: function( execResult ) { + return [ + execResult[ 1 ], + execResult[ 2 ], + execResult[ 3 ], + execResult[ 4 ] + ]; + } + }, { + re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, + parse: function( execResult ) { + return [ + execResult[ 1 ] * 2.55, + execResult[ 2 ] * 2.55, + execResult[ 3 ] * 2.55, + execResult[ 4 ] + ]; + } + }, { + // this regex ignores A-F because it's compared against an already lowercased string + re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/, + parse: function( execResult ) { + return [ + parseInt( execResult[ 1 ], 16 ), + parseInt( execResult[ 2 ], 16 ), + parseInt( execResult[ 3 ], 16 ) + ]; + } + }, { + // this regex ignores A-F because it's compared against an already lowercased string + re: /#([a-f0-9])([a-f0-9])([a-f0-9])/, + parse: function( execResult ) { + return [ + parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ), + parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ), + parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ) + ]; + } + }, { + re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/, + space: "hsla", + parse: function( execResult ) { + return [ + execResult[ 1 ], + execResult[ 2 ] / 100, + execResult[ 3 ] / 100, + execResult[ 4 ] + ]; + } + }], + + // jQuery.Color( ) + color = jQuery.Color = function( color, green, blue, alpha ) { + return new jQuery.Color.fn.parse( color, green, blue, alpha ); + }, + spaces = { + rgba: { + props: { + red: { + idx: 0, + type: "byte" + }, + green: { + idx: 1, + type: "byte" + }, + blue: { + idx: 2, + type: "byte" + } + } + }, + + hsla: { + props: { + hue: { + idx: 0, + type: "degrees" + }, + saturation: { + idx: 1, + type: "percent" + }, + lightness: { + idx: 2, + type: "percent" + } + } + } + }, + propTypes = { + "byte": { + floor: true, + max: 255 + }, + "percent": { + max: 1 + }, + "degrees": { + mod: 360, + floor: true + } + }, + support = color.support = {}, + + // element for support tests + supportElem = jQuery( "

" )[ 0 ], + + // colors = jQuery.Color.names + colors, + + // local aliases of functions called often + each = jQuery.each; + +// determine rgba support immediately +supportElem.style.cssText = "background-color:rgba(1,1,1,.5)"; +support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1; + +// define cache name and alpha properties +// for rgba and hsla spaces +each( spaces, function( spaceName, space ) { + space.cache = "_" + spaceName; + space.props.alpha = { + idx: 3, + type: "percent", + def: 1 + }; +}); + +function clamp( value, prop, allowEmpty ) { + var type = propTypes[ prop.type ] || {}; + + if ( value == null ) { + return (allowEmpty || !prop.def) ? null : prop.def; + } + + // ~~ is an short way of doing floor for positive numbers + value = type.floor ? ~~value : parseFloat( value ); + + // IE will pass in empty strings as value for alpha, + // which will hit this case + if ( isNaN( value ) ) { + return prop.def; + } + + if ( type.mod ) { + // we add mod before modding to make sure that negatives values + // get converted properly: -10 -> 350 + return (value + type.mod) % type.mod; + } + + // for now all property types without mod have min and max + return 0 > value ? 0 : type.max < value ? type.max : value; +} + +function stringParse( string ) { + var inst = color(), + rgba = inst._rgba = []; + + string = string.toLowerCase(); + + each( stringParsers, function( i, parser ) { + var parsed, + match = parser.re.exec( string ), + values = match && parser.parse( match ), + spaceName = parser.space || "rgba"; + + if ( values ) { + parsed = inst[ spaceName ]( values ); + + // if this was an rgba parse the assignment might happen twice + // oh well.... + inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ]; + rgba = inst._rgba = parsed._rgba; + + // exit each( stringParsers ) here because we matched + return false; + } + }); + + // Found a stringParser that handled it + if ( rgba.length ) { + + // if this came from a parsed string, force "transparent" when alpha is 0 + // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0) + if ( rgba.join() === "0,0,0,0" ) { + jQuery.extend( rgba, colors.transparent ); + } + return inst; + } + + // named colors + return colors[ string ]; +} + +color.fn = jQuery.extend( color.prototype, { + parse: function( red, green, blue, alpha ) { + if ( red === undefined ) { + this._rgba = [ null, null, null, null ]; + return this; + } + if ( red.jquery || red.nodeType ) { + red = jQuery( red ).css( green ); + green = undefined; + } + + var inst = this, + type = jQuery.type( red ), + rgba = this._rgba = []; + + // more than 1 argument specified - assume ( red, green, blue, alpha ) + if ( green !== undefined ) { + red = [ red, green, blue, alpha ]; + type = "array"; + } + + if ( type === "string" ) { + return this.parse( stringParse( red ) || colors._default ); + } + + if ( type === "array" ) { + each( spaces.rgba.props, function( key, prop ) { + rgba[ prop.idx ] = clamp( red[ prop.idx ], prop ); + }); + return this; + } + + if ( type === "object" ) { + if ( red instanceof color ) { + each( spaces, function( spaceName, space ) { + if ( red[ space.cache ] ) { + inst[ space.cache ] = red[ space.cache ].slice(); + } + }); + } else { + each( spaces, function( spaceName, space ) { + var cache = space.cache; + each( space.props, function( key, prop ) { + + // if the cache doesn't exist, and we know how to convert + if ( !inst[ cache ] && space.to ) { + + // if the value was null, we don't need to copy it + // if the key was alpha, we don't need to copy it either + if ( key === "alpha" || red[ key ] == null ) { + return; + } + inst[ cache ] = space.to( inst._rgba ); + } + + // this is the only case where we allow nulls for ALL properties. + // call clamp with alwaysAllowEmpty + inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true ); + }); + + // everything defined but alpha? + if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) { + // use the default of 1 + inst[ cache ][ 3 ] = 1; + if ( space.from ) { + inst._rgba = space.from( inst[ cache ] ); + } + } + }); + } + return this; + } + }, + is: function( compare ) { + var is = color( compare ), + same = true, + inst = this; + + each( spaces, function( _, space ) { + var localCache, + isCache = is[ space.cache ]; + if (isCache) { + localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || []; + each( space.props, function( _, prop ) { + if ( isCache[ prop.idx ] != null ) { + same = ( isCache[ prop.idx ] === localCache[ prop.idx ] ); + return same; + } + }); + } + return same; + }); + return same; + }, + _space: function() { + var used = [], + inst = this; + each( spaces, function( spaceName, space ) { + if ( inst[ space.cache ] ) { + used.push( spaceName ); + } + }); + return used.pop(); + }, + transition: function( other, distance ) { + var end = color( other ), + spaceName = end._space(), + space = spaces[ spaceName ], + startColor = this.alpha() === 0 ? color( "transparent" ) : this, + start = startColor[ space.cache ] || space.to( startColor._rgba ), + result = start.slice(); + + end = end[ space.cache ]; + each( space.props, function( key, prop ) { + var index = prop.idx, + startValue = start[ index ], + endValue = end[ index ], + type = propTypes[ prop.type ] || {}; + + // if null, don't override start value + if ( endValue === null ) { + return; + } + // if null - use end + if ( startValue === null ) { + result[ index ] = endValue; + } else { + if ( type.mod ) { + if ( endValue - startValue > type.mod / 2 ) { + startValue += type.mod; + } else if ( startValue - endValue > type.mod / 2 ) { + startValue -= type.mod; + } + } + result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop ); + } + }); + return this[ spaceName ]( result ); + }, + blend: function( opaque ) { + // if we are already opaque - return ourself + if ( this._rgba[ 3 ] === 1 ) { + return this; + } + + var rgb = this._rgba.slice(), + a = rgb.pop(), + blend = color( opaque )._rgba; + + return color( jQuery.map( rgb, function( v, i ) { + return ( 1 - a ) * blend[ i ] + a * v; + })); + }, + toRgbaString: function() { + var prefix = "rgba(", + rgba = jQuery.map( this._rgba, function( v, i ) { + return v == null ? ( i > 2 ? 1 : 0 ) : v; + }); + + if ( rgba[ 3 ] === 1 ) { + rgba.pop(); + prefix = "rgb("; + } + + return prefix + rgba.join() + ")"; + }, + toHslaString: function() { + var prefix = "hsla(", + hsla = jQuery.map( this.hsla(), function( v, i ) { + if ( v == null ) { + v = i > 2 ? 1 : 0; + } + + // catch 1 and 2 + if ( i && i < 3 ) { + v = Math.round( v * 100 ) + "%"; + } + return v; + }); + + if ( hsla[ 3 ] === 1 ) { + hsla.pop(); + prefix = "hsl("; + } + return prefix + hsla.join() + ")"; + }, + toHexString: function( includeAlpha ) { + var rgba = this._rgba.slice(), + alpha = rgba.pop(); + + if ( includeAlpha ) { + rgba.push( ~~( alpha * 255 ) ); + } + + return "#" + jQuery.map( rgba, function( v ) { + + // default to 0 when nulls exist + v = ( v || 0 ).toString( 16 ); + return v.length === 1 ? "0" + v : v; + }).join(""); + }, + toString: function() { + return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString(); + } +}); +color.fn.parse.prototype = color.fn; + +// hsla conversions adapted from: +// https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021 + +function hue2rgb( p, q, h ) { + h = ( h + 1 ) % 1; + if ( h * 6 < 1 ) { + return p + (q - p) * h * 6; + } + if ( h * 2 < 1) { + return q; + } + if ( h * 3 < 2 ) { + return p + (q - p) * ((2/3) - h) * 6; + } + return p; +} + +spaces.hsla.to = function ( rgba ) { + if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) { + return [ null, null, null, rgba[ 3 ] ]; + } + var r = rgba[ 0 ] / 255, + g = rgba[ 1 ] / 255, + b = rgba[ 2 ] / 255, + a = rgba[ 3 ], + max = Math.max( r, g, b ), + min = Math.min( r, g, b ), + diff = max - min, + add = max + min, + l = add * 0.5, + h, s; + + if ( min === max ) { + h = 0; + } else if ( r === max ) { + h = ( 60 * ( g - b ) / diff ) + 360; + } else if ( g === max ) { + h = ( 60 * ( b - r ) / diff ) + 120; + } else { + h = ( 60 * ( r - g ) / diff ) + 240; + } + + // chroma (diff) == 0 means greyscale which, by definition, saturation = 0% + // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add) + if ( diff === 0 ) { + s = 0; + } else if ( l <= 0.5 ) { + s = diff / add; + } else { + s = diff / ( 2 - add ); + } + return [ Math.round(h) % 360, s, l, a == null ? 1 : a ]; +}; + +spaces.hsla.from = function ( hsla ) { + if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) { + return [ null, null, null, hsla[ 3 ] ]; + } + var h = hsla[ 0 ] / 360, + s = hsla[ 1 ], + l = hsla[ 2 ], + a = hsla[ 3 ], + q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s, + p = 2 * l - q; + + return [ + Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ), + Math.round( hue2rgb( p, q, h ) * 255 ), + Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ), + a + ]; +}; + + +each( spaces, function( spaceName, space ) { + var props = space.props, + cache = space.cache, + to = space.to, + from = space.from; + + // makes rgba() and hsla() + color.fn[ spaceName ] = function( value ) { + + // generate a cache for this space if it doesn't exist + if ( to && !this[ cache ] ) { + this[ cache ] = to( this._rgba ); + } + if ( value === undefined ) { + return this[ cache ].slice(); + } + + var ret, + type = jQuery.type( value ), + arr = ( type === "array" || type === "object" ) ? value : arguments, + local = this[ cache ].slice(); + + each( props, function( key, prop ) { + var val = arr[ type === "object" ? key : prop.idx ]; + if ( val == null ) { + val = local[ prop.idx ]; + } + local[ prop.idx ] = clamp( val, prop ); + }); + + if ( from ) { + ret = color( from( local ) ); + ret[ cache ] = local; + return ret; + } else { + return color( local ); + } + }; + + // makes red() green() blue() alpha() hue() saturation() lightness() + each( props, function( key, prop ) { + // alpha is included in more than one space + if ( color.fn[ key ] ) { + return; + } + color.fn[ key ] = function( value ) { + var vtype = jQuery.type( value ), + fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ), + local = this[ fn ](), + cur = local[ prop.idx ], + match; + + if ( vtype === "undefined" ) { + return cur; + } + + if ( vtype === "function" ) { + value = value.call( this, cur ); + vtype = jQuery.type( value ); + } + if ( value == null && prop.empty ) { + return this; + } + if ( vtype === "string" ) { + match = rplusequals.exec( value ); + if ( match ) { + value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 ); + } + } + local[ prop.idx ] = value; + return this[ fn ]( local ); + }; + }); +}); + +// add cssHook and .fx.step function for each named hook. +// accept a space separated string of properties +color.hook = function( hook ) { + var hooks = hook.split( " " ); + each( hooks, function( i, hook ) { + jQuery.cssHooks[ hook ] = { + set: function( elem, value ) { + var parsed, curElem, + backgroundColor = ""; + + if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) { + value = color( parsed || value ); + if ( !support.rgba && value._rgba[ 3 ] !== 1 ) { + curElem = hook === "backgroundColor" ? elem.parentNode : elem; + while ( + (backgroundColor === "" || backgroundColor === "transparent") && + curElem && curElem.style + ) { + try { + backgroundColor = jQuery.css( curElem, "backgroundColor" ); + curElem = curElem.parentNode; + } catch ( e ) { + } + } + + value = value.blend( backgroundColor && backgroundColor !== "transparent" ? + backgroundColor : + "_default" ); + } + + value = value.toRgbaString(); + } + try { + elem.style[ hook ] = value; + } catch( e ) { + // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit' + } + } + }; + jQuery.fx.step[ hook ] = function( fx ) { + if ( !fx.colorInit ) { + fx.start = color( fx.elem, hook ); + fx.end = color( fx.end ); + fx.colorInit = true; + } + jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) ); + }; + }); + +}; + +color.hook( stepHooks ); + +jQuery.cssHooks.borderColor = { + expand: function( value ) { + var expanded = {}; + + each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) { + expanded[ "border" + part + "Color" ] = value; + }); + return expanded; + } +}; + +// Basic color names only. +// Usage of any of the other color names requires adding yourself or including +// jquery.color.svg-names.js. +colors = jQuery.Color.names = { + // 4.1. Basic color keywords + aqua: "#00ffff", + black: "#000000", + blue: "#0000ff", + fuchsia: "#ff00ff", + gray: "#808080", + green: "#008000", + lime: "#00ff00", + maroon: "#800000", + navy: "#000080", + olive: "#808000", + purple: "#800080", + red: "#ff0000", + silver: "#c0c0c0", + teal: "#008080", + white: "#ffffff", + yellow: "#ffff00", + + // 4.2.3. "transparent" color keyword + transparent: [ null, null, null, 0 ], + + _default: "#ffffff" +}; + +})( jQuery ); diff -r 1ea9e5a677a3 -r ad0378995d5a src/pyams_skin/resources/js/ext/jquery-color-2.1.2.min.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_skin/resources/js/ext/jquery-color-2.1.2.min.js Tue Apr 14 16:36:43 2015 +0200 @@ -0,0 +1,11 @@ +/* + * jQuery Color Animations v2.1.2 + * https://github.com/jquery/jquery-color + * + * Copyright 2013 jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + * + * Date: Wed Jan 16 08:47:09 2013 -0600 + */ +(function(o,d){var k="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",h=/^([\-+])=\s*(\d+\.?\d*)/,g=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(p){return[p[1],p[2],p[3],p[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(p){return[p[1]*2.55,p[2]*2.55,p[3]*2.55,p[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(p){return[parseInt(p[1],16),parseInt(p[2],16),parseInt(p[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(p){return[parseInt(p[1]+p[1],16),parseInt(p[2]+p[2],16),parseInt(p[3]+p[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(p){return[p[1],p[2]/100,p[3]/100,p[4]]}}],e=o.Color=function(q,r,p,s){return new o.Color.fn.parse(q,r,p,s)},j={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},n={"byte":{floor:true,max:255},percent:{max:1},degrees:{mod:360,floor:true}},m=e.support={},b=o("

")[0],a,l=o.each;b.style.cssText="background-color:rgba(1,1,1,.5)";m.rgba=b.style.backgroundColor.indexOf("rgba")>-1;l(j,function(p,q){q.cache="_"+p;q.props.alpha={idx:3,type:"percent",def:1}});function i(q,s,r){var p=n[s.type]||{};if(q==null){return(r||!s.def)?null:s.def}q=p.floor?~~q:parseFloat(q);if(isNaN(q)){return s.def}if(p.mod){return(q+p.mod)%p.mod}return 0>q?0:p.maxB.mod/2){y+=B.mod}else{if(y-x>B.mod/2){y-=B.mod}}}p[z]=i((x-y)*w+y,C)}});return this[s](p)},blend:function(s){if(this._rgba[3]===1){return this}var r=this._rgba.slice(),q=r.pop(),p=e(s)._rgba;return e(o.map(r,function(t,u){return(1-q)*p[u]+q*t}))},toRgbaString:function(){var q="rgba(",p=o.map(this._rgba,function(r,s){return r==null?(s>2?1:0):r});if(p[3]===1){p.pop();q="rgb("}return q+p.join()+")"},toHslaString:function(){var q="hsla(",p=o.map(this.hsla(),function(r,s){if(r==null){r=s>2?1:0}if(s&&s<3){r=Math.round(r*100)+"%"}return r});if(p[3]===1){p.pop();q="hsl("}return q+p.join()+")"},toHexString:function(p){var q=this._rgba.slice(),r=q.pop();if(p){q.push(~~(r*255))}return"#"+o.map(q,function(s){s=(s||0).toString(16);return s.length===1?"0"+s:s}).join("")},toString:function(){return this._rgba[3]===0?"transparent":this.toRgbaString()}});e.fn.parse.prototype=e.fn;function c(t,s,r){r=(r+1)%1;if(r*6<1){return t+(s-t)*r*6}if(r*2<1){return s}if(r*3<2){return t+(s-t)*((2/3)-r)*6}return t}j.hsla.to=function(t){if(t[0]==null||t[1]==null||t[2]==null){return[null,null,null,t[3]]}var p=t[0]/255,w=t[1]/255,x=t[2]/255,z=t[3],y=Math.max(p,w,x),u=Math.min(p,w,x),A=y-u,B=y+u,q=B*0.5,v,C;if(u===y){v=0}else{if(p===y){v=(60*(w-x)/A)+360}else{if(w===y){v=(60*(x-p)/A)+120}else{v=(60*(p-w)/A)+240}}}if(A===0){C=0}else{if(q<=0.5){C=A/B}else{C=A/(2-B)}}return[Math.round(v)%360,C,q,z==null?1:z]};j.hsla.from=function(w){if(w[0]==null||w[1]==null||w[2]==null){return[null,null,null,w[3]]}var v=w[0]/360,u=w[1],t=w[2],r=w[3],x=t<=0.5?t*(1+u):t+u-t*u,y=2*t-x;return[Math.round(c(y,x,v+(1/3))*255),Math.round(c(y,x,v)*255),Math.round(c(y,x,v-(1/3))*255),r]};l(j,function(q,s){var r=s.props,p=s.cache,u=s.to,t=s.from;e.fn[q]=function(z){if(u&&!this[p]){this[p]=u(this._rgba)}if(z===d){return this[p].slice()}var w,y=o.type(z),v=(y==="array"||y==="object")?z:arguments,x=this[p].slice();l(r,function(A,C){var B=v[y==="object"?A:C.idx];if(B==null){B=x[C.idx]}x[C.idx]=i(B,C)});if(t){w=e(t(x));w[p]=x;return w}else{return e(x)}};l(r,function(v,w){if(e.fn[v]){return}e.fn[v]=function(A){var C=o.type(A),z=(v==="alpha"?(this._hsla?"hsla":"rgba"):q),y=this[z](),B=y[w.idx],x;if(C==="undefined"){return B}if(C==="function"){A=A.call(this,B);C=o.type(A)}if(A==null&&w.empty){return this}if(C==="string"){x=h.exec(A);if(x){A=B+parseFloat(x[2])*(x[1]==="+"?1:-1)}}y[w.idx]=A;return this[z](y)}})});e.hook=function(q){var p=q.split(" ");l(p,function(r,s){o.cssHooks[s]={set:function(w,x){var u,v,t="";if(x!=="transparent"&&(o.type(x)!=="string"||(u=f(x)))){x=e(u||x);if(!m.rgba&&x._rgba[3]!==1){v=s==="backgroundColor"?w.parentNode:w;while((t===""||t==="transparent")&&v&&v.style){try{t=o.css(v,"backgroundColor");v=v.parentNode}catch(y){}}x=x.blend(t&&t!=="transparent"?t:"_default")}x=x.toRgbaString()}try{w.style[s]=x}catch(y){}}};o.fx.step[s]=function(t){if(!t.colorInit){t.start=e(t.elem,s);t.end=e(t.end);t.colorInit=true}o.cssHooks[s].set(t.elem,t.start.transition(t.end,t.pos))}})};e.hook(k);o.cssHooks.borderColor={expand:function(q){var p={};l(["Top","Right","Bottom","Left"],function(s,r){p["border"+r+"Color"]=q});return p}};a=o.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}})(jQuery); \ No newline at end of file diff -r 1ea9e5a677a3 -r ad0378995d5a src/pyams_skin/resources/js/ext/jquery-minicolors.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_skin/resources/js/ext/jquery-minicolors.js Tue Apr 14 16:36:43 2015 +0200 @@ -0,0 +1,861 @@ +/* + * jQuery MiniColors: A tiny color picker built on jQuery + * + * Copyright: Cory LaViska for A Beautiful Site, LLC: http://www.abeautifulsite.net/ + * + * Contribute: https://github.com/claviska/jquery-minicolors + * + * @license: http://opensource.org/licenses/MIT + * + */ +(function (factory) { + /* jshint ignore:start */ + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['jquery'], factory); + } else if (typeof exports === 'object') { + // Node/CommonJS + module.exports = factory(require('jquery')); + } else { + // Browser globals + factory(jQuery); + } + /* jshint ignore:end */ +}(function ($) { + + // Defaults + $.minicolors = { + defaults: { + animationSpeed: 50, + animationEasing: 'swing', + change: null, + changeDelay: 0, + control: 'hue', + dataUris: true, + defaultValue: '', + hide: null, + hideSpeed: 100, + inline: false, + letterCase: 'lowercase', + opacity: false, + position: 'bottom left', + show: null, + showSpeed: 100, + theme: 'default' + } + }; + + // Public methods + $.extend($.fn, { + minicolors: function(method, data) { + + switch(method) { + + // Destroy the control + case 'destroy': + $(this).each( function() { + destroy($(this)); + }); + return $(this); + + // Hide the color picker + case 'hide': + hide(); + return $(this); + + // Get/set opacity + case 'opacity': + // Getter + if( data === undefined ) { + // Getter + return $(this).attr('data-opacity'); + } else { + // Setter + $(this).each( function() { + updateFromInput($(this).attr('data-opacity', data)); + }); + } + return $(this); + + // Get an RGB(A) object based on the current color/opacity + case 'rgbObject': + return rgbObject($(this), method === 'rgbaObject'); + + // Get an RGB(A) string based on the current color/opacity + case 'rgbString': + case 'rgbaString': + return rgbString($(this), method === 'rgbaString'); + + // Get/set settings on the fly + case 'settings': + if( data === undefined ) { + return $(this).data('minicolors-settings'); + } else { + // Setter + $(this).each( function() { + var settings = $(this).data('minicolors-settings') || {}; + destroy($(this)); + $(this).minicolors($.extend(true, settings, data)); + }); + } + return $(this); + + // Show the color picker + case 'show': + show( $(this).eq(0) ); + return $(this); + + // Get/set the hex color value + case 'value': + if( data === undefined ) { + // Getter + return $(this).val(); + } else { + // Setter + $(this).each( function() { + updateFromInput($(this).val(data)); + }); + } + return $(this); + + // Initializes the control + default: + if( method !== 'create' ) data = method; + $(this).each( function() { + init($(this), data); + }); + return $(this); + + } + + } + }); + + // Initialize input elements + function init(input, settings) { + + var minicolors = $('

'), + defaults = $.minicolors.defaults; + + // Do nothing if already initialized + if( input.data('minicolors-initialized') ) return; + + // Handle settings + settings = $.extend(true, {}, defaults, settings); + + // The wrapper + minicolors + .addClass('minicolors-theme-' + settings.theme) + .toggleClass('minicolors-with-opacity', settings.opacity) + .toggleClass('minicolors-no-data-uris', settings.dataUris !== true); + + // Custom positioning + if( settings.position !== undefined ) { + $.each(settings.position.split(' '), function() { + minicolors.addClass('minicolors-position-' + this); + }); + } + + // The input + input + .addClass('minicolors-input') + .data('minicolors-initialized', false) + .data('minicolors-settings', settings) + .prop('size', 7) + .wrap(minicolors) + .after( + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + + '
' + ); + + // The swatch + if( !settings.inline ) { + input.after(''); + input.next('.minicolors-swatch').on('click', function(event) { + event.preventDefault(); + input.focus(); + }); + } + + // Prevent text selection in IE + input.parent().find('.minicolors-panel').on('selectstart', function() { return false; }).end(); + + // Inline controls + if( settings.inline ) input.parent().addClass('minicolors-inline'); + + updateFromInput(input, false); + + input.data('minicolors-initialized', true); + + } + + // Returns the input back to its original state + function destroy(input) { + + var minicolors = input.parent(); + + // Revert the input element + input + .removeData('minicolors-initialized') + .removeData('minicolors-settings') + .removeProp('size') + .removeClass('minicolors-input'); + + // Remove the wrap and destroy whatever remains + minicolors.before(input).remove(); + + } + + // Shows the specified dropdown panel + function show(input) { + + var minicolors = input.parent(), + panel = minicolors.find('.minicolors-panel'), + settings = input.data('minicolors-settings'); + + // Do nothing if uninitialized, disabled, inline, or already open + if( !input.data('minicolors-initialized') || + input.prop('disabled') || + minicolors.hasClass('minicolors-inline') || + minicolors.hasClass('minicolors-focus') + ) return; + + hide(); + + minicolors.addClass('minicolors-focus'); + panel + .stop(true, true) + .fadeIn(settings.showSpeed, function() { + if( settings.show ) settings.show.call(input.get(0)); + }); + + } + + // Hides all dropdown panels + function hide() { + + $('.minicolors-focus').each( function() { + + var minicolors = $(this), + input = minicolors.find('.minicolors-input'), + panel = minicolors.find('.minicolors-panel'), + settings = input.data('minicolors-settings'); + + panel.fadeOut(settings.hideSpeed, function() { + if( settings.hide ) settings.hide.call(input.get(0)); + minicolors.removeClass('minicolors-focus'); + }); + + }); + } + + // Moves the selected picker + function move(target, event, animate) { + + var input = target.parents('.minicolors').find('.minicolors-input'), + settings = input.data('minicolors-settings'), + picker = target.find('[class$=-picker]'), + offsetX = target.offset().left, + offsetY = target.offset().top, + x = Math.round(event.pageX - offsetX), + y = Math.round(event.pageY - offsetY), + duration = animate ? settings.animationSpeed : 0, + wx, wy, r, phi; + + // Touch support + if( event.originalEvent.changedTouches ) { + x = event.originalEvent.changedTouches[0].pageX - offsetX; + y = event.originalEvent.changedTouches[0].pageY - offsetY; + } + + // Constrain picker to its container + if( x < 0 ) x = 0; + if( y < 0 ) y = 0; + if( x > target.width() ) x = target.width(); + if( y > target.height() ) y = target.height(); + + // Constrain color wheel values to the wheel + if( target.parent().is('.minicolors-slider-wheel') && picker.parent().is('.minicolors-grid') ) { + wx = 75 - x; + wy = 75 - y; + r = Math.sqrt(wx * wx + wy * wy); + phi = Math.atan2(wy, wx); + if( phi < 0 ) phi += Math.PI * 2; + if( r > 75 ) { + r = 75; + x = 75 - (75 * Math.cos(phi)); + y = 75 - (75 * Math.sin(phi)); + } + x = Math.round(x); + y = Math.round(y); + } + + // Move the picker + if( target.is('.minicolors-grid') ) { + picker + .stop(true) + .animate({ + top: y + 'px', + left: x + 'px' + }, duration, settings.animationEasing, function() { + updateFromControl(input, target); + }); + } else { + picker + .stop(true) + .animate({ + top: y + 'px' + }, duration, settings.animationEasing, function() { + updateFromControl(input, target); + }); + } + + } + + // Sets the input based on the color picker values + function updateFromControl(input, target) { + + function getCoords(picker, container) { + + var left, top; + if( !picker.length || !container ) return null; + left = picker.offset().left; + top = picker.offset().top; + + return { + x: left - container.offset().left + (picker.outerWidth() / 2), + y: top - container.offset().top + (picker.outerHeight() / 2) + }; + + } + + var hue, saturation, brightness, x, y, r, phi, + + hex = input.val(), + opacity = input.attr('data-opacity'), + + // Helpful references + minicolors = input.parent(), + settings = input.data('minicolors-settings'), + swatch = minicolors.find('.minicolors-swatch'), + + // Panel objects + grid = minicolors.find('.minicolors-grid'), + slider = minicolors.find('.minicolors-slider'), + opacitySlider = minicolors.find('.minicolors-opacity-slider'), + + // Picker objects + gridPicker = grid.find('[class$=-picker]'), + sliderPicker = slider.find('[class$=-picker]'), + opacityPicker = opacitySlider.find('[class$=-picker]'), + + // Picker positions + gridPos = getCoords(gridPicker, grid), + sliderPos = getCoords(sliderPicker, slider), + opacityPos = getCoords(opacityPicker, opacitySlider); + + // Handle colors + if( target.is('.minicolors-grid, .minicolors-slider') ) { + + // Determine HSB values + switch(settings.control) { + + case 'wheel': + // Calculate hue, saturation, and brightness + x = (grid.width() / 2) - gridPos.x; + y = (grid.height() / 2) - gridPos.y; + r = Math.sqrt(x * x + y * y); + phi = Math.atan2(y, x); + if( phi < 0 ) phi += Math.PI * 2; + if( r > 75 ) { + r = 75; + gridPos.x = 69 - (75 * Math.cos(phi)); + gridPos.y = 69 - (75 * Math.sin(phi)); + } + saturation = keepWithin(r / 0.75, 0, 100); + hue = keepWithin(phi * 180 / Math.PI, 0, 360); + brightness = keepWithin(100 - Math.floor(sliderPos.y * (100 / slider.height())), 0, 100); + hex = hsb2hex({ + h: hue, + s: saturation, + b: brightness + }); + + // Update UI + slider.css('backgroundColor', hsb2hex({ h: hue, s: saturation, b: 100 })); + break; + + case 'saturation': + // Calculate hue, saturation, and brightness + hue = keepWithin(parseInt(gridPos.x * (360 / grid.width()), 10), 0, 360); + saturation = keepWithin(100 - Math.floor(sliderPos.y * (100 / slider.height())), 0, 100); + brightness = keepWithin(100 - Math.floor(gridPos.y * (100 / grid.height())), 0, 100); + hex = hsb2hex({ + h: hue, + s: saturation, + b: brightness + }); + + // Update UI + slider.css('backgroundColor', hsb2hex({ h: hue, s: 100, b: brightness })); + minicolors.find('.minicolors-grid-inner').css('opacity', saturation / 100); + break; + + case 'brightness': + // Calculate hue, saturation, and brightness + hue = keepWithin(parseInt(gridPos.x * (360 / grid.width()), 10), 0, 360); + saturation = keepWithin(100 - Math.floor(gridPos.y * (100 / grid.height())), 0, 100); + brightness = keepWithin(100 - Math.floor(sliderPos.y * (100 / slider.height())), 0, 100); + hex = hsb2hex({ + h: hue, + s: saturation, + b: brightness + }); + + // Update UI + slider.css('backgroundColor', hsb2hex({ h: hue, s: saturation, b: 100 })); + minicolors.find('.minicolors-grid-inner').css('opacity', 1 - (brightness / 100)); + break; + + default: + // Calculate hue, saturation, and brightness + hue = keepWithin(360 - parseInt(sliderPos.y * (360 / slider.height()), 10), 0, 360); + saturation = keepWithin(Math.floor(gridPos.x * (100 / grid.width())), 0, 100); + brightness = keepWithin(100 - Math.floor(gridPos.y * (100 / grid.height())), 0, 100); + hex = hsb2hex({ + h: hue, + s: saturation, + b: brightness + }); + + // Update UI + grid.css('backgroundColor', hsb2hex({ h: hue, s: 100, b: 100 })); + break; + + } + + // Adjust case + input.val( convertCase(hex, settings.letterCase) ); + + } + + // Handle opacity + if( target.is('.minicolors-opacity-slider') ) { + if( settings.opacity ) { + opacity = parseFloat(1 - (opacityPos.y / opacitySlider.height())).toFixed(2); + } else { + opacity = 1; + } + if( settings.opacity ) input.attr('data-opacity', opacity); + } + + // Set swatch color + swatch.find('SPAN').css({ + backgroundColor: hex, + opacity: opacity + }); + + // Handle change event + doChange(input, hex, opacity); + + } + + // Sets the color picker values from the input + function updateFromInput(input, preserveInputValue) { + + var hex, + hsb, + opacity, + x, y, r, phi, + + // Helpful references + minicolors = input.parent(), + settings = input.data('minicolors-settings'), + swatch = minicolors.find('.minicolors-swatch'), + + // Panel objects + grid = minicolors.find('.minicolors-grid'), + slider = minicolors.find('.minicolors-slider'), + opacitySlider = minicolors.find('.minicolors-opacity-slider'), + + // Picker objects + gridPicker = grid.find('[class$=-picker]'), + sliderPicker = slider.find('[class$=-picker]'), + opacityPicker = opacitySlider.find('[class$=-picker]'); + + // Determine hex/HSB values + hex = convertCase(parseHex(input.val(), true), settings.letterCase); + if( !hex ){ + hex = convertCase(parseHex(settings.defaultValue, true), settings.letterCase); + } + hsb = hex2hsb(hex); + + // Update input value + if( !preserveInputValue ) input.val(hex); + + // Determine opacity value + if( settings.opacity ) { + // Get from data-opacity attribute and keep within 0-1 range + opacity = input.attr('data-opacity') === '' ? 1 : keepWithin(parseFloat(input.attr('data-opacity')).toFixed(2), 0, 1); + if( isNaN(opacity) ) opacity = 1; + input.attr('data-opacity', opacity); + swatch.find('SPAN').css('opacity', opacity); + + // Set opacity picker position + y = keepWithin(opacitySlider.height() - (opacitySlider.height() * opacity), 0, opacitySlider.height()); + opacityPicker.css('top', y + 'px'); + } + + // Update swatch + swatch.find('SPAN').css('backgroundColor', hex); + + // Determine picker locations + switch(settings.control) { + + case 'wheel': + // Set grid position + r = keepWithin(Math.ceil(hsb.s * 0.75), 0, grid.height() / 2); + phi = hsb.h * Math.PI / 180; + x = keepWithin(75 - Math.cos(phi) * r, 0, grid.width()); + y = keepWithin(75 - Math.sin(phi) * r, 0, grid.height()); + gridPicker.css({ + top: y + 'px', + left: x + 'px' + }); + + // Set slider position + y = 150 - (hsb.b / (100 / grid.height())); + if( hex === '' ) y = 0; + sliderPicker.css('top', y + 'px'); + + // Update panel color + slider.css('backgroundColor', hsb2hex({ h: hsb.h, s: hsb.s, b: 100 })); + break; + + case 'saturation': + // Set grid position + x = keepWithin((5 * hsb.h) / 12, 0, 150); + y = keepWithin(grid.height() - Math.ceil(hsb.b / (100 / grid.height())), 0, grid.height()); + gridPicker.css({ + top: y + 'px', + left: x + 'px' + }); + + // Set slider position + y = keepWithin(slider.height() - (hsb.s * (slider.height() / 100)), 0, slider.height()); + sliderPicker.css('top', y + 'px'); + + // Update UI + slider.css('backgroundColor', hsb2hex({ h: hsb.h, s: 100, b: hsb.b })); + minicolors.find('.minicolors-grid-inner').css('opacity', hsb.s / 100); + break; + + case 'brightness': + // Set grid position + x = keepWithin((5 * hsb.h) / 12, 0, 150); + y = keepWithin(grid.height() - Math.ceil(hsb.s / (100 / grid.height())), 0, grid.height()); + gridPicker.css({ + top: y + 'px', + left: x + 'px' + }); + + // Set slider position + y = keepWithin(slider.height() - (hsb.b * (slider.height() / 100)), 0, slider.height()); + sliderPicker.css('top', y + 'px'); + + // Update UI + slider.css('backgroundColor', hsb2hex({ h: hsb.h, s: hsb.s, b: 100 })); + minicolors.find('.minicolors-grid-inner').css('opacity', 1 - (hsb.b / 100)); + break; + + default: + // Set grid position + x = keepWithin(Math.ceil(hsb.s / (100 / grid.width())), 0, grid.width()); + y = keepWithin(grid.height() - Math.ceil(hsb.b / (100 / grid.height())), 0, grid.height()); + gridPicker.css({ + top: y + 'px', + left: x + 'px' + }); + + // Set slider position + y = keepWithin(slider.height() - (hsb.h / (360 / slider.height())), 0, slider.height()); + sliderPicker.css('top', y + 'px'); + + // Update panel color + grid.css('backgroundColor', hsb2hex({ h: hsb.h, s: 100, b: 100 })); + break; + + } + + // Fire change event, but only if minicolors is fully initialized + if( input.data('minicolors-initialized') ) { + doChange(input, hex, opacity); + } + + } + + // Runs the change and changeDelay callbacks + function doChange(input, hex, opacity) { + + var settings = input.data('minicolors-settings'), + lastChange = input.data('minicolors-lastChange'); + + // Only run if it actually changed + if( !lastChange || lastChange.hex !== hex || lastChange.opacity !== opacity ) { + + // Remember last-changed value + input.data('minicolors-lastChange', { + hex: hex, + opacity: opacity + }); + + // Fire change event + if( settings.change ) { + if( settings.changeDelay ) { + // Call after a delay + clearTimeout(input.data('minicolors-changeTimeout')); + input.data('minicolors-changeTimeout', setTimeout( function() { + settings.change.call(input.get(0), hex, opacity); + }, settings.changeDelay)); + } else { + // Call immediately + settings.change.call(input.get(0), hex, opacity); + } + } + input.trigger('change').trigger('input'); + } + + } + + // Generates an RGB(A) object based on the input's value + function rgbObject(input) { + var hex = parseHex($(input).val(), true), + rgb = hex2rgb(hex), + opacity = $(input).attr('data-opacity'); + if( !rgb ) return null; + if( opacity !== undefined ) $.extend(rgb, { a: parseFloat(opacity) }); + return rgb; + } + + // Genearates an RGB(A) string based on the input's value + function rgbString(input, alpha) { + var hex = parseHex($(input).val(), true), + rgb = hex2rgb(hex), + opacity = $(input).attr('data-opacity'); + if( !rgb ) return null; + if( opacity === undefined ) opacity = 1; + if( alpha ) { + return 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', ' + parseFloat(opacity) + ')'; + } else { + return 'rgb(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ')'; + } + } + + // Converts to the letter case specified in settings + function convertCase(string, letterCase) { + return letterCase === 'uppercase' ? string.toUpperCase() : string.toLowerCase(); + } + + // Parses a string and returns a valid hex string when possible + function parseHex(string, expand) { + string = string.replace(/[^A-F0-9]/ig, ''); + if( string.length !== 3 && string.length !== 6 ) return ''; + if( string.length === 3 && expand ) { + string = string[0] + string[0] + string[1] + string[1] + string[2] + string[2]; + } + return '#' + string; + } + + // Keeps value within min and max + function keepWithin(value, min, max) { + if( value < min ) value = min; + if( value > max ) value = max; + return value; + } + + // Converts an HSB object to an RGB object + function hsb2rgb(hsb) { + var rgb = {}; + var h = Math.round(hsb.h); + var s = Math.round(hsb.s * 255 / 100); + var v = Math.round(hsb.b * 255 / 100); + if(s === 0) { + rgb.r = rgb.g = rgb.b = v; + } else { + var t1 = v; + var t2 = (255 - s) * v / 255; + var t3 = (t1 - t2) * (h % 60) / 60; + if( h === 360 ) h = 0; + if( h < 60 ) { rgb.r = t1; rgb.b = t2; rgb.g = t2 + t3; } + else if( h < 120 ) {rgb.g = t1; rgb.b = t2; rgb.r = t1 - t3; } + else if( h < 180 ) {rgb.g = t1; rgb.r = t2; rgb.b = t2 + t3; } + else if( h < 240 ) {rgb.b = t1; rgb.r = t2; rgb.g = t1 - t3; } + else if( h < 300 ) {rgb.b = t1; rgb.g = t2; rgb.r = t2 + t3; } + else if( h < 360 ) {rgb.r = t1; rgb.g = t2; rgb.b = t1 - t3; } + else { rgb.r = 0; rgb.g = 0; rgb.b = 0; } + } + return { + r: Math.round(rgb.r), + g: Math.round(rgb.g), + b: Math.round(rgb.b) + }; + } + + // Converts an RGB object to a hex string + function rgb2hex(rgb) { + var hex = [ + rgb.r.toString(16), + rgb.g.toString(16), + rgb.b.toString(16) + ]; + $.each(hex, function(nr, val) { + if (val.length === 1) hex[nr] = '0' + val; + }); + return '#' + hex.join(''); + } + + // Converts an HSB object to a hex string + function hsb2hex(hsb) { + return rgb2hex(hsb2rgb(hsb)); + } + + // Converts a hex string to an HSB object + function hex2hsb(hex) { + var hsb = rgb2hsb(hex2rgb(hex)); + if( hsb.s === 0 ) hsb.h = 360; + return hsb; + } + + // Converts an RGB object to an HSB object + function rgb2hsb(rgb) { + var hsb = { h: 0, s: 0, b: 0 }; + var min = Math.min(rgb.r, rgb.g, rgb.b); + var max = Math.max(rgb.r, rgb.g, rgb.b); + var delta = max - min; + hsb.b = max; + hsb.s = max !== 0 ? 255 * delta / max : 0; + if( hsb.s !== 0 ) { + if( rgb.r === max ) { + hsb.h = (rgb.g - rgb.b) / delta; + } else if( rgb.g === max ) { + hsb.h = 2 + (rgb.b - rgb.r) / delta; + } else { + hsb.h = 4 + (rgb.r - rgb.g) / delta; + } + } else { + hsb.h = -1; + } + hsb.h *= 60; + if( hsb.h < 0 ) { + hsb.h += 360; + } + hsb.s *= 100/255; + hsb.b *= 100/255; + return hsb; + } + + // Converts a hex string to an RGB object + function hex2rgb(hex) { + hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16); + return { + /* jshint ignore:start */ + r: hex >> 16, + g: (hex & 0x00FF00) >> 8, + b: (hex & 0x0000FF) + /* jshint ignore:end */ + }; + } + + // Handle events + $(document) + // Hide on clicks outside of the control + .on('mousedown.minicolors touchstart.minicolors', function(event) { + if( !$(event.target).parents().add(event.target).hasClass('minicolors') ) { + hide(); + } + }) + // Start moving + .on('mousedown.minicolors touchstart.minicolors', '.minicolors-grid, .minicolors-slider, .minicolors-opacity-slider', function(event) { + var target = $(this); + event.preventDefault(); + $(document).data('minicolors-target', target); + move(target, event, true); + }) + // Move pickers + .on('mousemove.minicolors touchmove.minicolors', function(event) { + var target = $(document).data('minicolors-target'); + if( target ) move(target, event); + }) + // Stop moving + .on('mouseup.minicolors touchend.minicolors', function() { + $(this).removeData('minicolors-target'); + }) + // Show panel when swatch is clicked + .on('mousedown.minicolors touchstart.minicolors', '.minicolors-swatch', function(event) { + var input = $(this).parent().find('.minicolors-input'); + event.preventDefault(); + show(input); + }) + // Show on focus + .on('focus.minicolors', '.minicolors-input', function() { + var input = $(this); + if( !input.data('minicolors-initialized') ) return; + show(input); + }) + // Fix hex on blur + .on('blur.minicolors', '.minicolors-input', function() { + var input = $(this), + settings = input.data('minicolors-settings'); + if( !input.data('minicolors-initialized') ) return; + + // Parse Hex + input.val(parseHex(input.val(), true)); + + // Is it blank? + if( input.val() === '' ) input.val(parseHex(settings.defaultValue, true)); + + // Adjust case + input.val( convertCase(input.val(), settings.letterCase) ); + + }) + // Handle keypresses + .on('keydown.minicolors', '.minicolors-input', function(event) { + var input = $(this); + if( !input.data('minicolors-initialized') ) return; + switch(event.keyCode) { + case 9: // tab + hide(); + break; + case 13: // enter + case 27: // esc + hide(); + input.blur(); + break; + } + }) + // Update on keyup + .on('keyup.minicolors', '.minicolors-input', function() { + var input = $(this); + if( !input.data('minicolors-initialized') ) return; + updateFromInput(input, true); + }) + // Update on paste + .on('paste.minicolors', '.minicolors-input', function() { + var input = $(this); + if( !input.data('minicolors-initialized') ) return; + setTimeout( function() { + updateFromInput(input, true); + }, 1); + }); + +})); \ No newline at end of file diff -r 1ea9e5a677a3 -r ad0378995d5a src/pyams_skin/resources/js/ext/jquery-minicolors.min.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_skin/resources/js/ext/jquery-minicolors.min.js Tue Apr 14 16:36:43 2015 +0200 @@ -0,0 +1,1 @@ +(function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{if(typeof exports==="object"){module.exports=a(require("jquery"))}else{a(jQuery)}}}(function(f){f.minicolors={defaults:{animationSpeed:50,animationEasing:"swing",change:null,changeDelay:0,control:"hue",dataUris:true,defaultValue:"",hide:null,hideSpeed:100,inline:false,letterCase:"lowercase",opacity:false,position:"bottom left",show:null,showSpeed:100,theme:"default"}};f.extend(f.fn,{minicolors:function(v,u){switch(v){case"destroy":f(this).each(function(){t(f(this))});return f(this);case"hide":k();return f(this);case"opacity":if(u===undefined){return f(this).attr("data-opacity")}else{f(this).each(function(){b(f(this).attr("data-opacity",u))})}return f(this);case"rgbObject":return i(f(this),v==="rgbaObject");case"rgbString":case"rgbaString":return j(f(this),v==="rgbaString");case"settings":if(u===undefined){return f(this).data("minicolors-settings")}else{f(this).each(function(){var w=f(this).data("minicolors-settings")||{};t(f(this));f(this).minicolors(f.extend(true,w,u))})}return f(this);case"show":s(f(this).eq(0));return f(this);case"value":if(u===undefined){return f(this).val()}else{f(this).each(function(){b(f(this).val(u))})}return f(this);default:if(v!=="create"){u=v}f(this).each(function(){p(f(this),u)});return f(this)}}});function p(u,v){var x=f('
'),w=f.minicolors.defaults;if(u.data("minicolors-initialized")){return}v=f.extend(true,{},w,v);x.addClass("minicolors-theme-"+v.theme).toggleClass("minicolors-with-opacity",v.opacity).toggleClass("minicolors-no-data-uris",v.dataUris!==true);if(v.position!==undefined){f.each(v.position.split(" "),function(){x.addClass("minicolors-position-"+this)})}u.addClass("minicolors-input").data("minicolors-initialized",false).data("minicolors-settings",v).prop("size",7).wrap(x).after('
');if(!v.inline){u.after('');u.next(".minicolors-swatch").on("click",function(y){y.preventDefault();u.focus()})}u.parent().find(".minicolors-panel").on("selectstart",function(){return false}).end();if(v.inline){u.parent().addClass("minicolors-inline")}b(u,false);u.data("minicolors-initialized",true)}function t(u){var v=u.parent();u.removeData("minicolors-initialized").removeData("minicolors-settings").removeProp("size").removeClass("minicolors-input");v.before(u).remove()}function s(v){var x=v.parent(),u=x.find(".minicolors-panel"),w=v.data("minicolors-settings");if(!v.data("minicolors-initialized")||v.prop("disabled")||x.hasClass("minicolors-inline")||x.hasClass("minicolors-focus")){return}k();x.addClass("minicolors-focus");u.stop(true,true).fadeIn(w.showSpeed,function(){if(w.show){w.show.call(v.get(0))}})}function k(){f(".minicolors-focus").each(function(){var x=f(this),v=x.find(".minicolors-input"),u=x.find(".minicolors-panel"),w=v.data("minicolors-settings");u.fadeOut(w.hideSpeed,function(){if(w.hide){w.hide.call(v.get(0))}x.removeClass("minicolors-focus")})})}function o(H,v,w){var K=H.parents(".minicolors").find(".minicolors-input"),z=K.data("minicolors-settings"),F=H.find("[class$=-picker]"),E=H.offset().left,D=H.offset().top,J=Math.round(v.pageX-E),I=Math.round(v.pageY-D),B=w?z.animationSpeed:0,C,A,u,G;if(v.originalEvent.changedTouches){J=v.originalEvent.changedTouches[0].pageX-E;I=v.originalEvent.changedTouches[0].pageY-D}if(J<0){J=0}if(I<0){I=0}if(J>H.width()){J=H.width()}if(I>H.height()){I=H.height()}if(H.parent().is(".minicolors-slider-wheel")&&F.parent().is(".minicolors-grid")){C=75-J;A=75-I;u=Math.sqrt(C*C+A*A);G=Math.atan2(A,C);if(G<0){G+=Math.PI*2}if(u>75){u=75;J=75-(75*Math.cos(G));I=75-(75*Math.sin(G))}J=Math.round(J);I=Math.round(I)}if(H.is(".minicolors-grid")){F.stop(true).animate({top:I+"px",left:J+"px"},B,z.animationEasing,function(){h(K,H)})}else{F.stop(true).animate({top:I+"px"},B,z.animationEasing,function(){h(K,H)})}}function h(M,T){function P(y,x){var V,U;if(!y.length||!x){return null}V=y.offset().left;U=y.offset().top;return{x:V-x.offset().left+(y.outerWidth()/2),y:U-x.offset().top+(y.outerHeight()/2)}}var D,E,S,K,J,N,A,H=M.val(),B=M.attr("data-opacity"),C=M.parent(),R=M.data("minicolors-settings"),O=C.find(".minicolors-swatch"),u=C.find(".minicolors-grid"),Q=C.find(".minicolors-slider"),G=C.find(".minicolors-opacity-slider"),F=u.find("[class$=-picker]"),L=Q.find("[class$=-picker]"),z=G.find("[class$=-picker]"),w=P(F,u),v=P(L,Q),I=P(z,G);if(T.is(".minicolors-grid, .minicolors-slider")){switch(R.control){case"wheel":K=(u.width()/2)-w.x;J=(u.height()/2)-w.y;N=Math.sqrt(K*K+J*J);A=Math.atan2(J,K);if(A<0){A+=Math.PI*2}if(N>75){N=75;w.x=69-(75*Math.cos(A));w.y=69-(75*Math.sin(A))}E=m(N/0.75,0,100);D=m(A*180/Math.PI,0,360);S=m(100-Math.floor(v.y*(100/Q.height())),0,100);H=c({h:D,s:E,b:S});Q.css("backgroundColor",c({h:D,s:E,b:100}));break;case"saturation":D=m(parseInt(w.x*(360/u.width()),10),0,360);E=m(100-Math.floor(v.y*(100/Q.height())),0,100);S=m(100-Math.floor(w.y*(100/u.height())),0,100);H=c({h:D,s:E,b:S});Q.css("backgroundColor",c({h:D,s:100,b:S}));C.find(".minicolors-grid-inner").css("opacity",E/100);break;case"brightness":D=m(parseInt(w.x*(360/u.width()),10),0,360);E=m(100-Math.floor(w.y*(100/u.height())),0,100);S=m(100-Math.floor(v.y*(100/Q.height())),0,100);H=c({h:D,s:E,b:S});Q.css("backgroundColor",c({h:D,s:E,b:100}));C.find(".minicolors-grid-inner").css("opacity",1-(S/100));break;default:D=m(360-parseInt(v.y*(360/Q.height()),10),0,360);E=m(Math.floor(w.x*(100/u.width())),0,100);S=m(100-Math.floor(w.y*(100/u.height())),0,100);H=c({h:D,s:E,b:S});u.css("backgroundColor",c({h:D,s:100,b:100}));break}M.val(l(H,R.letterCase))}if(T.is(".minicolors-opacity-slider")){if(R.opacity){B=parseFloat(1-(I.y/G.height())).toFixed(2)}else{B=1}if(R.opacity){M.attr("data-opacity",B)}}O.find("SPAN").css({backgroundColor:H,opacity:B});e(M,H,B)}function b(H,I){var C,K,z,F,E,J,w,A=H.parent(),N=H.data("minicolors-settings"),L=A.find(".minicolors-swatch"),u=A.find(".minicolors-grid"),M=A.find(".minicolors-slider"),D=A.find(".minicolors-opacity-slider"),B=u.find("[class$=-picker]"),G=M.find("[class$=-picker]"),v=D.find("[class$=-picker]");C=l(q(H.val(),true),N.letterCase);if(!C){C=l(q(N.defaultValue,true),N.letterCase)}K=d(C);if(!I){H.val(C)}if(N.opacity){z=H.attr("data-opacity")===""?1:m(parseFloat(H.attr("data-opacity")).toFixed(2),0,1);if(isNaN(z)){z=1}H.attr("data-opacity",z);L.find("SPAN").css("opacity",z);E=m(D.height()-(D.height()*z),0,D.height());v.css("top",E+"px")}L.find("SPAN").css("backgroundColor",C);switch(N.control){case"wheel":J=m(Math.ceil(K.s*0.75),0,u.height()/2);w=K.h*Math.PI/180;F=m(75-Math.cos(w)*J,0,u.width());E=m(75-Math.sin(w)*J,0,u.height());B.css({top:E+"px",left:F+"px"});E=150-(K.b/(100/u.height()));if(C===""){E=0}G.css("top",E+"px");M.css("backgroundColor",c({h:K.h,s:K.s,b:100}));break;case"saturation":F=m((5*K.h)/12,0,150);E=m(u.height()-Math.ceil(K.b/(100/u.height())),0,u.height());B.css({top:E+"px",left:F+"px"});E=m(M.height()-(K.s*(M.height()/100)),0,M.height());G.css("top",E+"px");M.css("backgroundColor",c({h:K.h,s:100,b:K.b}));A.find(".minicolors-grid-inner").css("opacity",K.s/100);break;case"brightness":F=m((5*K.h)/12,0,150);E=m(u.height()-Math.ceil(K.s/(100/u.height())),0,u.height());B.css({top:E+"px",left:F+"px"});E=m(M.height()-(K.b*(M.height()/100)),0,M.height());G.css("top",E+"px");M.css("backgroundColor",c({h:K.h,s:K.s,b:100}));A.find(".minicolors-grid-inner").css("opacity",1-(K.b/100));break;default:F=m(Math.ceil(K.s/(100/u.width())),0,u.width());E=m(u.height()-Math.ceil(K.b/(100/u.height())),0,u.height());B.css({top:E+"px",left:F+"px"});E=m(M.height()-(K.h/(360/M.height())),0,M.height());G.css("top",E+"px");u.css("backgroundColor",c({h:K.h,s:100,b:100}));break}if(H.data("minicolors-initialized")){e(H,C,z)}}function e(u,y,v){var w=u.data("minicolors-settings"),x=u.data("minicolors-lastChange");if(!x||x.hex!==y||x.opacity!==v){u.data("minicolors-lastChange",{hex:y,opacity:v});if(w.change){if(w.changeDelay){clearTimeout(u.data("minicolors-changeTimeout"));u.data("minicolors-changeTimeout",setTimeout(function(){w.change.call(u.get(0),y,v)},w.changeDelay))}else{w.change.call(u.get(0),y,v)}}u.trigger("change").trigger("input")}}function i(u){var x=q(f(u).val(),true),w=n(x),v=f(u).attr("data-opacity");if(!w){return null}if(v!==undefined){f.extend(w,{a:parseFloat(v)})}return w}function j(u,y){var x=q(f(u).val(),true),w=n(x),v=f(u).attr("data-opacity");if(!w){return null}if(v===undefined){v=1}if(y){return"rgba("+w.r+", "+w.g+", "+w.b+", "+parseFloat(v)+")"}else{return"rgb("+w.r+", "+w.g+", "+w.b+")"}}function l(u,v){return v==="uppercase"?u.toUpperCase():u.toLowerCase()}function q(u,v){u=u.replace(/[^A-F0-9]/ig,"");if(u.length!==3&&u.length!==6){return""}if(u.length===3&&v){u=u[0]+u[0]+u[1]+u[1]+u[2]+u[2]}return"#"+u}function m(w,v,u){if(wu){w=u}return w}function r(u){var x={};var B=Math.round(u.h);var A=Math.round(u.s*255/100);var w=Math.round(u.b*255/100);if(A===0){x.r=x.g=x.b=w}else{var C=w;var z=(255-A)*w/255;var y=(C-z)*(B%60)/60;if(B===360){B=0}if(B<60){x.r=C;x.b=z;x.g=z+y}else{if(B<120){x.g=C;x.b=z;x.r=C-y}else{if(B<180){x.g=C;x.r=z;x.b=z+y}else{if(B<240){x.b=C;x.r=z;x.g=C-y}else{if(B<300){x.b=C;x.g=z;x.r=z+y}else{if(B<360){x.r=C;x.g=z;x.b=C-y}else{x.r=0;x.g=0;x.b=0}}}}}}}return{r:Math.round(x.r),g:Math.round(x.g),b:Math.round(x.b)}}function a(u){var v=[u.r.toString(16),u.g.toString(16),u.b.toString(16)];f.each(v,function(w,x){if(x.length===1){v[w]="0"+x}});return"#"+v.join("")}function c(u){return a(r(u))}function d(v){var u=g(n(v));if(u.s===0){u.h=360}return u}function g(w){var v={h:0,s:0,b:0};var x=Math.min(w.r,w.g,w.b);var u=Math.max(w.r,w.g,w.b);var y=u-x;v.b=u;v.s=u!==0?255*y/u:0;if(v.s!==0){if(w.r===u){v.h=(w.g-w.b)/y}else{if(w.g===u){v.h=2+(w.b-w.r)/y}else{v.h=4+(w.r-w.g)/y}}}else{v.h=-1}v.h*=60;if(v.h<0){v.h+=360}v.s*=100/255;v.b*=100/255;return v}function n(u){u=parseInt(((u.indexOf("#")>-1)?u.substring(1):u),16);return{r:u>>16,g:(u&65280)>>8,b:(u&255)}}f(document).on("mousedown.minicolors touchstart.minicolors",function(u){if(!f(u.target).parents().add(u.target).hasClass("minicolors")){k()}}).on("mousedown.minicolors touchstart.minicolors",".minicolors-grid, .minicolors-slider, .minicolors-opacity-slider",function(u){var v=f(this);u.preventDefault();f(document).data("minicolors-target",v);o(v,u,true)}).on("mousemove.minicolors touchmove.minicolors",function(u){var v=f(document).data("minicolors-target");if(v){o(v,u)}}).on("mouseup.minicolors touchend.minicolors",function(){f(this).removeData("minicolors-target")}).on("mousedown.minicolors touchstart.minicolors",".minicolors-swatch",function(v){var u=f(this).parent().find(".minicolors-input");v.preventDefault();s(u)}).on("focus.minicolors",".minicolors-input",function(){var u=f(this);if(!u.data("minicolors-initialized")){return}s(u)}).on("blur.minicolors",".minicolors-input",function(){var u=f(this),v=u.data("minicolors-settings");if(!u.data("minicolors-initialized")){return}u.val(q(u.val(),true));if(u.val()===""){u.val(q(v.defaultValue,true))}u.val(l(u.val(),v.letterCase))}).on("keydown.minicolors",".minicolors-input",function(v){var u=f(this);if(!u.data("minicolors-initialized")){return}switch(v.keyCode){case 9:k();break;case 13:case 27:k();u.blur();break}}).on("keyup.minicolors",".minicolors-input",function(){var u=f(this);if(!u.data("minicolors-initialized")){return}b(u,true)}).on("paste.minicolors",".minicolors-input",function(){var u=f(this);if(!u.data("minicolors-initialized")){return}setTimeout(function(){b(u,true)},1)})})); \ No newline at end of file