2016-04-13 00:53:28 +00:00
/*! jQuery v1.11.3 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */
! function ( a , b ) { "object" == typeof module && "object" == typeof module . exports ? module . exports = a . document ? b ( a , ! 0 ) : function ( a ) { if ( ! a . document ) throw new Error ( "jQuery requires a window with a document" ) ; return b ( a ) } : b ( a ) } ( "undefined" != typeof window ? window : this , function ( a , b ) { var c = [ ] , d = c . slice , e = c . concat , f = c . push , g = c . indexOf , h = { } , i = h . toString , j = h . hasOwnProperty , k = { } , l = "1.11.3" , m = function ( a , b ) { return new m . fn . init ( a , b ) } , n = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g , o = /^-ms-/ , p = /-([\da-z])/gi , q = function ( a , b ) { return b . toUpperCase ( ) } ; m . fn = m . prototype = { jquery : l , constructor : m , selector : "" , length : 0 , toArray : function ( ) { return d . call ( this ) } , get : function ( a ) { return null != a ? 0 > a ? this [ a + this . length ] : this [ a ] : d . call ( this ) } , pushStack : function ( a ) { var b = m . merge ( this . constructor ( ) , a ) ; return b . prevObject = this , b . context = this . context , b } , each : function ( a , b ) { return m . each ( this , a , b ) } , map : function ( a ) { return this . pushStack ( m . map ( this , function ( b , c ) { return a . call ( b , c , b ) } ) ) } , slice : function ( ) { return this . pushStack ( d . apply ( this , arguments ) ) } , first : function ( ) { return this . eq ( 0 ) } , last : function ( ) { return this . eq ( - 1 ) } , eq : function ( a ) { var b = this . length , c = + a + ( 0 > a ? b : 0 ) ; return this . pushStack ( c >= 0 && b > c ? [ this [ c ] ] : [ ] ) } , end : function ( ) { return this . prevObject || this . constructor ( null ) } , push : f , sort : c . sort , splice : c . splice } , m . extend = m . fn . extend = function ( ) { var a , b , c , d , e , f , g = arguments [ 0 ] || { } , h = 1 , i = arguments . length , j = ! 1 ; for ( "boolean" == typeof g && ( j = g , g = arguments [ h ] || { } , h ++ ) , "object" == typeof g || m . isFunction ( g ) || ( g = { } ) , h === i && ( g = this , h -- ) ; i > h ; h ++ ) if ( null != ( e = arguments [ h ] ) ) for ( d in e ) a = g [ d ] , c = e [ d ] , g !== c && ( j && c && ( m . isPlainObject ( c ) || ( b = m . isArray ( c ) ) ) ? ( b ? ( b = ! 1 , f = a && m . isArray ( a ) ? a : [ ] ) : f = a && m . isPlainObject ( a ) ? a : { } , g [ d ] = m . extend ( j , f , c ) ) : void 0 !== c && ( g [ d ] = c ) ) ; return g } , m . extend ( { expando : "jQuery" + ( l + Math . random ( ) ) . replace ( /\D/g , "" ) , isReady : ! 0 , error : function ( a ) { throw new Error ( a ) } , noop : function ( ) { } , isFunction : function ( a ) { return "function" === m . type ( a ) } , isArray : Array . isArray || function ( a ) { return "array" === m . type ( a ) } , isWindow : function ( a ) { return null != a && a == a . window } , isNumeric : function ( a ) { return ! m . isArray ( a ) && a - parseFloat ( a ) + 1 >= 0 } , isEmptyObject : function ( a ) { var b ; for ( b in a ) return ! 1 ; return ! 0 } , isPlainObject : function ( a ) { var b ; if ( ! a || "object" !== m . type ( a ) || a . nodeType || m . isWindow ( a ) ) return ! 1 ; try { if ( a . constructor && ! j . call ( a , "constructor" ) && ! j . call ( a . constructor . prototype , "isPrototypeOf" ) ) return ! 1 } catch ( c ) { return ! 1 } if ( k . ownLast ) for ( b in a ) return j . call ( a , b ) ; for ( b in a ) ; return void 0 === b || j . call ( a , b ) } , type : function ( a ) { return null == a ? a + "" : "object" == typeof a || "function" == typeof a ? h [ i . call ( a ) ] || "object" : typeof a } , globalEval : function ( b ) { b && m . trim ( b ) && ( a . execScript || function ( b ) { a . eval . call ( a , b ) } ) ( b ) } , camelCase : function ( a ) { return a . replace ( o , "ms-" ) . replace ( p , q ) } , nodeName : function ( a , b ) { return a . nodeName && a . nodeName . toLowerCase ( ) === b . toLowerCase ( ) } , each : function ( a , b , c ) { var d , e = 0 , f = a . length , g = r ( a ) ; if ( c ) { if ( g ) { for ( ; f > e ; e ++ ) if ( d = b . apply ( a [ e ] , c ) , d === ! 1 ) break } else for ( e in a ) if ( d = b . apply ( a [ e ] , c ) , d === ! 1 ) break } else if ( g ) { for ( ; f > e ; e ++ ) if ( d = b . call ( a [ e ] , e , a [ e ] ) , d === ! 1 ) break } else for ( e in a ) if ( d = b . call ( a [ e ] , e , a [ e ] ) , d === ! 1 ) break ; return a } , trim : function ( a ) { return null == a ? "" : ( a + "" ) . replace ( n , "" ) } , makeArray : function ( a , b ) { var c = b || [ ] ; return null != a && ( r ( Object ( a ) ) ? m . merge ( c , "string" == typeof a ? [ a ] : a ) : f . call ( c , a ) ) , c } , inArray : function ( a , b , c ) { var d ; if ( b ) { if ( g ) return g . call ( b , a , c ) ; for ( d = b . length , c = c ? 0 > c ? Math . max ( 0 , d + c ) : c : 0 ; d > c ; c ++ ) if ( c in b && b [ c ] === a ) return c } return - 1 } , merge : function ( a , b ) { var c = + b . length , d = 0 , e = a . length ; while ( c > d ) a [ e ++ ] = b [ d ++ ] ; if ( c !== c ) while ( void 0 !== b [ d ] ) a [ e ++ ] = b [ d ++ ] ; return a . length = e , a } , grep : function ( a , b , c ) { for ( var d , e = [ ] , f = 0 , g = a . length , h = ! c ; g > f ; f ++ ) d = ! b ( a [ f ] , f ) , d !== h && e . push ( a [ f ] ) ; return e } , map : function ( a , b , c ) { var d , f = 0 , g = a . length , h = r ( a ) , i = [ ] ; if ( h ) for ( ; g > f ; f ++ ) d = b ( a [ f ] , f , c ) , null != d && i . push ( d ) ; else for ( f in a ) d = b ( a [ f ] , f , c ) , null != d && i . push ( d ) ; return e . apply ( [ ] , i ) } , guid : 1 , proxy : function ( a , b ) { var c , e , f ; return "string" == typeof b && ( f = a [ b ] , b = a , a = f ) , m . isFunction ( a ) ? ( c = d . call ( arguments , 2 ) , e = function ( ) { return a . apply ( b || this , c . concat ( d . call ( arguments ) ) ) } , e . guid = a . guid = a . guid || m . guid ++ , e ) : void 0 } , now : function ( ) { return + new Date } , support : k } ) , m . each (
return ! 0 } function Q ( a , b , d , e ) { if ( m . acceptData ( a ) ) { var f , g , h = m . expando , i = a . nodeType , j = i ? m . cache : a , k = i ? a [ h ] : a [ h ] && h ; if ( k && j [ k ] && ( e || j [ k ] . data ) || void 0 !== d || "string" != typeof b ) return k || ( k = i ? a [ h ] = c . pop ( ) || m . guid ++ : h ) , j [ k ] || ( j [ k ] = i ? { } : { toJSON : m . noop } ) , ( "object" == typeof b || "function" == typeof b ) && ( e ? j [ k ] = m . extend ( j [ k ] , b ) : j [ k ] . data = m . extend ( j [ k ] . data , b ) ) , g = j [ k ] , e || ( g . data || ( g . data = { } ) , g = g . data ) , void 0 !== d && ( g [ m . camelCase ( b ) ] = d ) , "string" == typeof b ? ( f = g [ b ] , null == f && ( f = g [ m . camelCase ( b ) ] ) ) : f = g , f } } function R ( a , b , c ) { if ( m . acceptData ( a ) ) { var d , e , f = a . nodeType , g = f ? m . cache : a , h = f ? a [ m . expando ] : m . expando ; if ( g [ h ] ) { if ( b && ( d = c ? g [ h ] : g [ h ] . data ) ) { m . isArray ( b ) ? b = b . concat ( m . map ( b , m . camelCase ) ) : b in d ? b = [ b ] : ( b = m . camelCase ( b ) , b = b in d ? [ b ] : b . split ( " " ) ) , e = b . length ; while ( e -- ) delete d [ b [ e ] ] ; if ( c ? ! P ( d ) : ! m . isEmptyObject ( d ) ) return } ( c || ( delete g [ h ] . data , P ( g [ h ] ) ) ) && ( f ? m . cleanData ( [ a ] , ! 0 ) : k . deleteExpando || g != g . window ? delete g [ h ] : g [ h ] = null ) } } } m . extend ( { cache : { } , noData : { "applet " : ! 0 , "embed " : ! 0 , "object " : "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" } , hasData : function ( a ) { return a = a . nodeType ? m . cache [ a [ m . expando ] ] : a [ m . expando ] , ! ! a && ! P ( a ) } , data : function ( a , b , c ) { return Q ( a , b , c ) } , removeData : function ( a , b ) { return R ( a , b ) } , _data : function ( a , b , c ) { return Q ( a , b , c , ! 0 ) } , _removeData : function ( a , b ) { return R ( a , b , ! 0 ) } } ) , m . fn . extend ( { data : function ( a , b ) { var c , d , e , f = this [ 0 ] , g = f && f . attributes ; if ( void 0 === a ) { if ( this . length && ( e = m . data ( f ) , 1 === f . nodeType && ! m . _data ( f , "parsedAttrs" ) ) ) { c = g . length ; while ( c -- ) g [ c ] && ( d = g [ c ] . name , 0 === d . indexOf ( "data-" ) && ( d = m . camelCase ( d . slice ( 5 ) ) , O ( f , d , e [ d ] ) ) ) ; m . _data ( f , "parsedAttrs" , ! 0 ) } return e } return "object" == typeof a ? this . each ( function ( ) { m . data ( this , a ) } ) : arguments . length > 1 ? this . each ( function ( ) { m . data ( this , a , b ) } ) : f ? O ( f , a , m . data ( f , a ) ) : void 0 } , removeData : function ( a ) { return this . each ( function ( ) { m . removeData ( this , a ) } ) } } ) , m . extend ( { queue : function ( a , b , c ) { var d ; return a ? ( b = ( b || "fx" ) + "queue" , d = m . _data ( a , b ) , c && ( ! d || m . isArray ( c ) ? d = m . _data ( a , b , m . makeArray ( c ) ) : d . push ( c ) ) , d || [ ] ) : void 0 } , dequeue : function ( a , b ) { b = b || "fx" ; var c = m . queue ( a , b ) , d = c . length , e = c . shift ( ) , f = m . _queueHooks ( a , b ) , g = function ( ) { m . dequeue ( a , b ) } ; "inprogress" === e && ( e = c . shift ( ) , d -- ) , e && ( "fx" === b && c . unshift ( "inprogress" ) , delete f . stop , e . call ( a , g , f ) ) , ! d && f && f . empty . fire ( ) } , _queueHooks : function ( a , b ) { var c = b + "queueHooks" ; return m . _data ( a , c ) || m . _data ( a , c , { empty : m . Callbacks ( "once memory" ) . add ( function ( ) { m . _removeData ( a , b + "queue" ) , m . _removeData ( a , c ) } ) } ) } } ) , m . fn . extend ( { queue : function ( a , b ) { var c = 2 ; return "string" != typeof a && ( b = a , a = "fx" , c -- ) , arguments . length < c ? m . queue ( this [ 0 ] , a ) : void 0 === b ? this : this . each ( function ( ) { var c = m . queue ( this , a , b ) ; m . _queueHooks ( this , a ) , "fx" === a && "inprogress" !== c [ 0 ] && m . dequeue ( this , a ) } ) } , dequeue : function ( a ) { return this . each ( function ( ) { m . dequeue ( this , a ) } ) } , clearQueue : function ( a ) { return this . queue ( a || "fx" , [ ] ) } , promise : function ( a , b ) { var c , d = 1 , e = m . Deferred ( ) , f = this , g = this . length , h = function ( ) { -- d || e . resolveWith ( f , [ f ] ) } ; "string" != typeof a && ( b = a , a = void 0 ) , a = a || "fx" ; while ( g -- ) c = m . _data ( f [ g ] , a + "queueHooks" ) , c && c . empty && ( d ++ , c . empty . add ( h ) ) ; return h ( ) , e . promise ( b ) } } ) ; var S = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ . source , T = [ "Top" , "Right" , "Bottom" , "Left" ] , U = function ( a , b ) { return a = b || a , "none" === m . css ( a , "display" ) || ! m . contains ( a . ownerDocument , a ) } , V = m . access = function ( a , b , c , d , e , f , g ) { var h = 0 , i = a . length , j = null == c ; if ( "object" === m . type ( c ) ) { e = ! 0 ; for ( h in c ) m . access ( a , b , h , c [ h ] , ! 0 , f , g ) } else if ( void 0 !== d && ( e = ! 0 , m . isFunction ( d ) || ( g = ! 0 ) , j && ( g ? ( b . call ( a , d ) , b = null ) : ( j = b , b = function ( a , b , c ) { return j . call ( m ( a ) , c ) } ) ) , b ) ) for ( ; i > h ; h ++ ) b ( a [ h ] , c , g ? d : d . call ( a [ h ] , h , b ( a [ h ] , c ) ) ) ; return e ? a : j ? b . call ( a ) : i ? b ( a [ 0 ] , c ) : f } , W = /^(?:checkbox|radio)$/i ; ! function ( ) { var a = y . createElement ( "input" ) , b = y . createElement ( "div" ) , c = y . createDocumentFragment ( ) ; if ( b . innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>" , k . leadingWhitespace = 3 === b . firstChild . nodeType , k . tbody = ! b . getElementsByTagName ( "tbody" ) . length , k . htmlSerialize = ! ! b . getElementsByTagName ( "link" ) . length , k . html5Clone = "<:nav></:nav>" !== y . createElement ( "nav" ) . cloneNode ( ! 0 ) . outerHTML , a . type = "checkbox" , a . checked = ! 0 , c . appendChild ( a ) , k . appendChecked = a . checked , b . innerHTML = " < textarea > x < / t e x
return new Za . prototype . init ( a , b , c , d , e ) } m . Tween = Za , Za . prototype = { constructor : Za , init : function ( a , b , c , d , e , f ) { this . elem = a , this . prop = c , this . easing = e || "swing" , this . options = b , this . start = this . now = this . cur ( ) , this . end = d , this . unit = f || ( m . cssNumber [ c ] ? "" : "px" ) } , cur : function ( ) { var a = Za . propHooks [ this . prop ] ; return a && a . get ? a . get ( this ) : Za . propHooks . _default . get ( this ) } , run : function ( a ) { var b , c = Za . propHooks [ this . prop ] ; return this . options . duration ? this . pos = b = m . easing [ this . easing ] ( a , this . options . duration * a , 0 , 1 , this . options . duration ) : this . pos = b = a , this . now = ( this . end - this . start ) * b + this . start , this . options . step && this . options . step . call ( this . elem , this . now , this ) , c && c . set ? c . set ( this ) : Za . propHooks . _default . set ( this ) , this } } , Za . prototype . init . prototype = Za . prototype , Za . propHooks = { _default : { get : function ( a ) { var b ; return null == a . elem [ a . prop ] || a . elem . style && null != a . elem . style [ a . prop ] ? ( b = m . css ( a . elem , a . prop , "" ) , b && "auto" !== b ? b : 0 ) : a . elem [ a . prop ] } , set : function ( a ) { m . fx . step [ a . prop ] ? m . fx . step [ a . prop ] ( a ) : a . elem . style && ( null != a . elem . style [ m . cssProps [ a . prop ] ] || m . cssHooks [ a . prop ] ) ? m . style ( a . elem , a . prop , a . now + a . unit ) : a . elem [ a . prop ] = a . now } } } , Za . propHooks . scrollTop = Za . propHooks . scrollLeft = { set : function ( a ) { a . elem . nodeType && a . elem . parentNode && ( a . elem [ a . prop ] = a . now ) } } , m . easing = { linear : function ( a ) { return a } , swing : function ( a ) { return . 5 - Math . cos ( a * Math . PI ) / 2 } } , m . fx = Za . prototype . init , m . fx . step = { } ; var $a , _a , ab = /^(?:toggle|show|hide)$/ , bb = new RegExp ( "^(?:([+-])=|)(" + S + ")([a-z%]*)$" , "i" ) , cb = /queueHooks$/ , db = [ ib ] , eb = { "*" : [ function ( a , b ) { var c = this . createTween ( a , b ) , d = c . cur ( ) , e = bb . exec ( b ) , f = e && e [ 3 ] || ( m . cssNumber [ a ] ? "" : "px" ) , g = ( m . cssNumber [ a ] || "px" !== f && + d ) && bb . exec ( m . css ( c . elem , a ) ) , h = 1 , i = 20 ; if ( g && g [ 3 ] !== f ) { f = f || g [ 3 ] , e = e || [ ] , g = + d || 1 ; do h = h || ".5" , g /= h , m . style ( c . elem , a , g + f ) ; while ( h !== ( h = c . cur ( ) / d ) && 1 !== h && -- i ) } return e && ( g = c . start = + g || + d || 0 , c . unit = f , c . end = e [ 1 ] ? g + ( e [ 1 ] + 1 ) * e [ 2 ] : + e [ 2 ] ) , c } ] } ; function fb ( ) { return setTimeout ( function ( ) { $a = void 0 } ) , $a = m . now ( ) } function gb ( a , b ) { var c , d = { height : a } , e = 0 ; for ( b = b ? 1 : 0 ; 4 > e ; e += 2 - b ) c = T [ e ] , d [ "margin" + c ] = d [ "padding" + c ] = a ; return b && ( d . opacity = d . width = a ) , d } function hb ( a , b , c ) { for ( var d , e = ( eb [ b ] || [ ] ) . concat ( eb [ "*" ] ) , f = 0 , g = e . length ; g > f ; f ++ ) if ( d = e [ f ] . call ( c , b , a ) ) return d } function ib ( a , b , c ) { var d , e , f , g , h , i , j , l , n = this , o = { } , p = a . style , q = a . nodeType && U ( a ) , r = m . _data ( a , "fxshow" ) ; c . queue || ( h = m . _queueHooks ( a , "fx" ) , null == h . unqueued && ( h . unqueued = 0 , i = h . empty . fire , h . empty . fire = function ( ) { h . unqueued || i ( ) } ) , h . unqueued ++ , n . always ( function ( ) { n . always ( function ( ) { h . unqueued -- , m . queue ( a , "fx" ) . length || h . empty . fire ( ) } ) } ) ) , 1 === a . nodeType && ( "height" in b || "width" in b ) && ( c . overflow = [ p . overflow , p . overflowX , p . overflowY ] , j = m . css ( a , "display" ) , l = "none" === j ? m . _data ( a , "olddisplay" ) || Fa ( a . nodeName ) : j , "inline" === l && "none" === m . css ( a , "float" ) && ( k . inlineBlockNeedsLayout && "inline" !== Fa ( a . nodeName ) ? p . zoom = 1 : p . display = "inline-block" ) ) , c . overflow && ( p . overflow = "hidden" , k . shrinkWrapBlocks ( ) || n . always ( function ( ) { p . overflow = c . overflow [ 0 ] , p . overflowX = c . overflow [ 1 ] , p . overflowY = c . overflow [ 2 ] } ) ) ; for ( d in b ) if ( e = b [ d ] , ab . exec ( e ) ) { if ( delete b [ d ] , f = f || "toggle" === e , e === ( q ? "hide" : "show" ) ) { if ( "show" !== e || ! r || void 0 === r [ d ] ) continue ; q = ! 0 } o [ d ] = r && r [ d ] || m . style ( a , d ) } else j = void 0 ; if ( m . isEmptyObject ( o ) ) "inline" === ( "none" === j ? Fa ( a . nodeName ) : j ) && ( p . display = j ) ; else { r ? "hidden" in r && ( q = r . hidden ) : r = m . _data ( a , "fxshow" , { } ) , f && ( r . hidden = ! q ) , q ? m ( a ) . show ( ) : n . done ( function ( ) { m ( a ) . hide ( ) } ) , n . done ( function ( ) { var b ; m . _removeData ( a , "fxshow" ) ; for ( b in o ) m . style ( a , b , o [ b ] ) } ) ; for ( d in o ) g = hb ( q ? r [ d ] : 0 , d , n ) , d in r || ( r [ d ] = g . start , q && ( g . end = g . start , g . start = "width" === d || "height" === d ? 1 : 0 ) ) } } function jb ( a , b ) { var c , d , e , f , g ; for ( c in a ) if ( d = m . camelCase ( c ) , e = b [ d ] , f = a [ c ] , m . isArray ( f ) && ( e = f [ 1 ] , f = a [ c ] = f [ 0 ] ) , c !== d && ( a [ d ] = f , delete a [ c ] ) , g = m . cssHooks [ d ] , g && "expand" in g ) { f = g . expand ( f ) , delete a [ d ] ; for ( c in f ) c in a || ( a [ c ] = f [ c ] , b [ c ] = e ) } else b [ d ] = e } function kb ( a , b , c ) { var d , e , f = 0 , g = db . length , h = m . Deferred ( ) . always ( function ( ) { delete i . elem } ) , i = function ( ) { if ( e ) return ! 1 ; for ( var b = $a || fb ( ) , c = Math . max ( 0 , j . startTime + j . duration - b ) , d = c / j . duration || 0 , f = 1 - d , g = 0 , i = j . tweens . length ; i > g ; g ++ ) j . tweens [ g ] . run ( f ) ; return h . notifyWith ( a , [ j , f , c ] ) , 1 > f && i ? c : ( h . resolveWith ( a , [ j ] ) , ! 1 ) } , j = h
2016-04-13 01:04:13 +00:00
try {
$ = jQuery = module . exports ;
// If you want module.exports to be empty, uncomment:
// module.exports = {};
} catch ( e ) { }
2016-04-17 21:55:23 +00:00
/ * !
* jQuery contextMenu v2 . 1.1 - Plugin for simple contextMenu handling
*
* Version : v2 . 1.1
*
* Authors : Björn Brala ( SWIS . nl ) , Rodney Rehm , Addy Osmani ( patches for FF )
* Web : http : //swisnl.github.io/jQuery-contextMenu/
*
* Copyright ( c ) 2011 - 2016 SWIS BV and contributors
*
* Licensed under
* MIT License http : //www.opensource.org/licenses/mit-license
* GPL v3 http : //opensource.org/licenses/GPL-3.0
*
* Date : 2016 - 04 - 08 T15 : 05 : 16.920 Z
* /
! function ( e ) { "function" == typeof define && define . amd ? define ( [ "jquery" ] , e ) : e ( "object" == typeof exports ? require ( "jquery" ) : jQuery ) } ( function ( e ) { "use strict" ; function t ( e ) { for ( var t , n = e . split ( /\s+/ ) , a = [ ] , o = 0 ; t = n [ o ] ; o ++ ) t = t . charAt ( 0 ) . toUpperCase ( ) , a . push ( t ) ; return a } function n ( t ) { return t . id && e ( 'label[for="' + t . id + '"]' ) . val ( ) || t . name } function a ( t , o , s ) { return s || ( s = 0 ) , o . each ( function ( ) { var o , i , c = e ( this ) , r = this , l = this . nodeName . toLowerCase ( ) ; switch ( "label" === l && c . find ( "input, textarea, select" ) . length && ( o = c . text ( ) , c = c . children ( ) . first ( ) , r = c . get ( 0 ) , l = r . nodeName . toLowerCase ( ) ) , l ) { case "menu" : i = { name : c . attr ( "label" ) , items : { } } , s = a ( i . items , c . children ( ) , s ) ; break ; case "a" : case "button" : i = { name : c . text ( ) , disabled : ! ! c . attr ( "disabled" ) , callback : function ( ) { return function ( ) { c . click ( ) } } ( ) } ; break ; case "menuitem" : case "command" : switch ( c . attr ( "type" ) ) { case void 0 : case "command" : case "menuitem" : i = { name : c . attr ( "label" ) , disabled : ! ! c . attr ( "disabled" ) , icon : c . attr ( "icon" ) , callback : function ( ) { return function ( ) { c . click ( ) } } ( ) } ; break ; case "checkbox" : i = { type : "checkbox" , disabled : ! ! c . attr ( "disabled" ) , name : c . attr ( "label" ) , selected : ! ! c . attr ( "checked" ) } ; break ; case "radio" : i = { type : "radio" , disabled : ! ! c . attr ( "disabled" ) , name : c . attr ( "label" ) , radio : c . attr ( "radiogroup" ) , value : c . attr ( "id" ) , selected : ! ! c . attr ( "checked" ) } ; break ; default : i = void 0 } break ; case "hr" : i = "-------" ; break ; case "input" : switch ( c . attr ( "type" ) ) { case "text" : i = { type : "text" , name : o || n ( r ) , disabled : ! ! c . attr ( "disabled" ) , value : c . val ( ) } ; break ; case "checkbox" : i = { type : "checkbox" , name : o || n ( r ) , disabled : ! ! c . attr ( "disabled" ) , selected : ! ! c . attr ( "checked" ) } ; break ; case "radio" : i = { type : "radio" , name : o || n ( r ) , disabled : ! ! c . attr ( "disabled" ) , radio : ! ! c . attr ( "name" ) , value : c . val ( ) , selected : ! ! c . attr ( "checked" ) } ; break ; default : i = void 0 } break ; case "select" : i = { type : "select" , name : o || n ( r ) , disabled : ! ! c . attr ( "disabled" ) , selected : c . val ( ) , options : { } } , c . children ( ) . each ( function ( ) { i . options [ this . value ] = e ( this ) . text ( ) } ) ; break ; case "textarea" : i = { type : "textarea" , name : o || n ( r ) , disabled : ! ! c . attr ( "disabled" ) , value : c . val ( ) } ; break ; case "label" : break ; default : i = { type : "html" , html : c . clone ( ! 0 ) } } i && ( s ++ , t [ "key" + s ] = i ) } ) , s } e . support . htmlMenuitem = "HTMLMenuItemElement" in window , e . support . htmlCommand = "HTMLCommandElement" in window , e . support . eventSelectstart = "onselectstart" in document . documentElement , e . ui && e . widget || ( e . cleanData = function ( t ) { return function ( n ) { var a , o , s ; for ( s = 0 ; null != n [ s ] ; s ++ ) { o = n [ s ] ; try { a = e . _data ( o , "events" ) , a && a . remove && e ( o ) . triggerHandler ( "remove" ) } catch ( i ) { } } t ( n ) } } ( e . cleanData ) ) ; var o = null , s = ! 1 , i = e ( window ) , c = 0 , r = { } , l = { } , u = { } , d = { selector : null , appendTo : null , trigger : "right" , autoHide : ! 1 , delay : 200 , reposition : ! 0 , classNames : { hover : "context-menu-hover" , disabled : "context-menu-disabled" , visible : "context-menu-visible" , notSelectable : "context-menu-not-selectable" , icon : "context-menu-icon" , iconEdit : "context-menu-icon-edit" , iconCut : "context-menu-icon-cut" , iconCopy : "context-menu-icon-copy" , iconPaste : "context-menu-icon-paste" , iconDelete : "context-menu-icon-delete" , iconAdd : "context-menu-icon-add" , iconQuit : "context-menu-icon-quit" } , determinePosition : function ( t ) { if ( e . ui && e . ui . position ) t . css ( "display" , "block" ) . position ( { my : "center top" , at : "center bottom" , of : this , offset : "0 5" , collision : "fit" } ) . css ( "display" , "none" ) ; else { var n = this . offset ( ) ; n . top += this . outerHeight ( ) , n . left += this . outerWidth ( ) / 2 - t . outerWidth ( ) / 2 , t . css ( n ) } } , position : function ( e , t , n ) { var a ; if ( ! t && ! n ) return void e . determinePosition . call ( this , e . $menu ) ; a = "maintain" === t && "maintain" === n ? e . $menu . position ( ) : { top : n , left : t } ; var o = i . scrollTop ( ) + i . height ( ) , s = i . scrollLeft ( ) + i . width ( ) , c = e . $menu . outerHeight ( ) , r = e . $menu . outerWidth ( ) ; a . top + c > o && ( a . top -= c ) , a . top < 0 && ( a . top = 0 ) , a . left + r > s && ( a . left -= r ) , a . left < 0 && ( a . left = 0 ) , e . $menu . css ( a ) } , positionSubmenu : function ( t ) { if ( e . ui && e . ui . position ) t . css ( "display" , "block" ) . position ( { my : "left top" , at : "right top" , of : this , collision : "flipfit fit" } ) . css ( "display" , "" ) ; else { var n = { top : 0 , left : this . outerWidth ( ) } ; t . css ( n ) } } , zIndex : 1 , animation : { duration : 50 , show : "slideDown" , hide : "slideUp" } , events : { show : e . noop , hide : e . noop } , callback : null , items : { } } , m = { timer : null , pageX : null , pageY : null } , p = function ( e ) { for ( var t = 0 , n = e ; ; ) if ( t =
//# sourceMappingURL=jquery.contextMenu.min.js.map
2016-04-12 06:18:33 +00:00
/* w2ui 1.4.3 (c) http://w2ui.com, vitmalina@gmail.com */
var w2ui = w2ui || { } , w2obj = w2obj || { } , w2utils = function ( ) { function a ( a ) { var b = /^[-+]?[0-9]+$/ ; return b . test ( a ) } function b ( a ) { return "string" == typeof a && ( a = a . replace ( w2utils . settings . decimalSymbol , "." ) ) , ( "number" == typeof a || "string" == typeof a && "" !== a ) && ! isNaN ( Number ( a ) ) } function c ( a ) { var b = w2utils . settings , c = new RegExp ( "^" + ( b . currencyPrefix ? "\\" + b . currencyPrefix + "?" : "" ) + "[-+]?[0-9]*[\\" + w2utils . settings . decimalSymbol + "]?[0-9]+" + ( b . currencySuffix ? "\\" + b . currencySuffix + "?" : "" ) + "$" , "i" ) ; return "string" == typeof a && ( a = a . replace ( new RegExp ( b . groupSymbol , "g" ) , "" ) ) , "object" == typeof a || "" === a ? ! 1 : c . test ( a ) } function d ( a ) { var b = /^[a-fA-F0-9]+$/ ; return b . test ( a ) } function e ( a ) { var b = /^[a-zA-Z0-9_-]+$/ ; return b . test ( a ) } function f ( a ) { var b = /^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/ ; return b . test ( a ) } function g ( b , c , d ) { if ( ! b ) return ! 1 ; var e , f , g , h = "Invalid Date" ; if ( null == c && ( c = w2utils . settings . date _format ) , "function" == typeof b . getUTCFullYear && "function" == typeof b . getUTCMonth && "function" == typeof b . getUTCDate ) g = b . getUTCFullYear ( ) , e = b . getUTCMonth ( ) , f = b . getUTCDate ( ) ; else if ( "function" == typeof b . getFullYear && "function" == typeof b . getMonth && "function" == typeof b . getDate ) g = b . getFullYear ( ) , e = b . getMonth ( ) , f = b . getDate ( ) ; else { if ( b = String ( b ) , RegExp ( "mon" , "ig" ) . test ( c ) ) { c = c . replace ( /month/gi , "m" ) . replace ( /mon/gi , "m" ) . replace ( /dd/gi , "d" ) . replace ( /[, ]/gi , "/" ) . replace ( /\/\//g , "/" ) . toLowerCase ( ) , b = b . replace ( /[, ]/gi , "/" ) . replace ( /\/\//g , "/" ) . toLowerCase ( ) ; for ( var i = 0 , j = w2utils . settings . fullmonths . length ; j > i ; i ++ ) { var k = w2utils . settings . fullmonths [ i ] ; b = b . replace ( RegExp ( k , "ig" ) , parseInt ( i ) + 1 ) . replace ( RegExp ( k . substr ( 0 , 3 ) , "ig" ) , parseInt ( i ) + 1 ) } } var l = b . replace ( /-/g , "/" ) . replace ( /\./g , "/" ) . toLowerCase ( ) . split ( "/" ) , m = c . replace ( /-/g , "/" ) . replace ( /\./g , "/" ) . toLowerCase ( ) ; "mm/dd/yyyy" === m && ( e = l [ 0 ] , f = l [ 1 ] , g = l [ 2 ] ) , "m/d/yyyy" === m && ( e = l [ 0 ] , f = l [ 1 ] , g = l [ 2 ] ) , "dd/mm/yyyy" === m && ( e = l [ 1 ] , f = l [ 0 ] , g = l [ 2 ] ) , "d/m/yyyy" === m && ( e = l [ 1 ] , f = l [ 0 ] , g = l [ 2 ] ) , "yyyy/dd/mm" === m && ( e = l [ 2 ] , f = l [ 1 ] , g = l [ 0 ] ) , "yyyy/d/m" === m && ( e = l [ 2 ] , f = l [ 1 ] , g = l [ 0 ] ) , "yyyy/mm/dd" === m && ( e = l [ 1 ] , f = l [ 2 ] , g = l [ 0 ] ) , "yyyy/m/d" === m && ( e = l [ 1 ] , f = l [ 2 ] , g = l [ 0 ] ) , "mm/dd/yy" === m && ( e = l [ 0 ] , f = l [ 1 ] , g = l [ 2 ] ) , "m/d/yy" === m && ( e = l [ 0 ] , f = l [ 1 ] , g = parseInt ( l [ 2 ] ) + 1900 ) , "dd/mm/yy" === m && ( e = l [ 1 ] , f = l [ 0 ] , g = parseInt ( l [ 2 ] ) + 1900 ) , "d/m/yy" === m && ( e = l [ 1 ] , f = l [ 0 ] , g = parseInt ( l [ 2 ] ) + 1900 ) , "yy/dd/mm" === m && ( e = l [ 2 ] , f = l [ 1 ] , g = parseInt ( l [ 0 ] ) + 1900 ) , "yy/d/m" === m && ( e = l [ 2 ] , f = l [ 1 ] , g = parseInt ( l [ 0 ] ) + 1900 ) , "yy/mm/dd" === m && ( e = l [ 1 ] , f = l [ 2 ] , g = parseInt ( l [ 0 ] ) + 1900 ) , "yy/m/d" === m && ( e = l [ 1 ] , f = l [ 2 ] , g = parseInt ( l [ 0 ] ) + 1900 ) } return a ( g ) && a ( e ) && a ( f ) ? ( g = + g , e = + e , f = + f , h = new Date ( g , e - 1 , f ) , null == e ? ! 1 : "Invalid Date" == String ( h ) ? ! 1 : h . getMonth ( ) + 1 !== e || h . getDate ( ) !== f || h . getFullYear ( ) !== g ? ! 1 : d === ! 0 ? h : ! 0 ) : ! 1 } function h ( a , b ) { if ( null == a ) return ! 1 ; var c , d ; a = String ( a ) , a = a . toUpperCase ( ) , d = a . indexOf ( "PM" ) >= 0 ; var e = d || a . indexOf ( "AM" ) >= 0 ; c = e ? 12 : 24 , a = a . replace ( "AM" , "" ) . replace ( "PM" , "" ) , a = $ . trim ( a ) ; var f = a . split ( ":" ) , g = parseInt ( f [ 0 ] || 0 ) , h = parseInt ( f [ 1 ] || 0 ) ; return e && 1 === f . length || 2 === f . length ? "" === f [ 0 ] || 0 > g || g > c || ! this . isInt ( f [ 0 ] ) || f [ 0 ] . length > 2 ? ! 1 : 2 === f . length && ( "" === f [ 1 ] || 0 > h || h > 59 || ! this . isInt ( f [ 1 ] ) || 2 !== f [ 1 ] . length ) ? ! 1 : e || c !== g || 0 === h ? e && 1 === f . length && 0 === g ? ! 1 : b === ! 0 ? ( d && ( g += 12 ) , { hours : g , minutes : h } ) : ! 0 : ! 1 : ! 1 } function i ( a ) { if ( "" === a || null == a ) return "" ; var b = new Date ( a ) ; if ( w2utils . isInt ( a ) && ( b = new Date ( Number ( a ) ) ) , "Invalid Date" == String ( b ) ) return "" ; var c = new Date , d = ( c . getTime ( ) - b . getTime ( ) ) / 1e3 , e = "" , f = "" ; return 0 > d ? ( e = '<span style="color: #aaa">future</span>' , f = "" ) : 60 > d ? ( e = Math . floor ( d ) , f = "sec" , 0 > d && ( e = 0 , f = "sec" ) ) : 3600 > d ? ( e = Math . floor ( d / 60 ) , f = "min" ) : 86400 > d ? ( e = Math . floor ( d / 60 / 60 ) , f = "hour" ) : 2592e3 > d ? ( e = Math . floor ( d / 24 / 60 / 60 ) , f = "day" ) : 31557600 > d ? ( e = Math . floor ( d / 365.25 / 24 / 60 / 60 * 10 ) / 10 , f = "month" ) : d >= 31557600 && ( e = Math . floor ( d / 365.25 / 24 / 60 / 60 * 10 ) / 10 , f = "year" ) , e + " " + f + ( e > 1 ? "s" : "" ) } function j ( a ) { if ( "" === a || null == a ) return "" ; var b = new Date ( a ) ; if ( w2utils . isInt ( a ) && ( b = new Date ( Number ( a ) ) ) , "Invalid Date" == String ( b ) ) return "" ; var c = w2utils . settings . shortmonths , d = new Date , e = new Date ; e . setTime ( e . getTime ( ) - 864e5 ) ; var f = c [ b . getMonth ( ) ] + " " + b . getDate ( ) + ", " + b . getFullYear ( ) , g = c [ d . getMonth ( ) ] + " " + d . getDate ( ) + ", " + d . getFullYear ( ) , h = c [ e . getMonth ( ) ] + "
0 >= i && ( b . index = - 1 ) } $ ( g ) . w2menu ( "refresh" , b ) , c ( ) } function e ( ) { if ( b . spinner ) return '<table class="w2ui-drop-menu"><tr><td style="padding: 5px 10px 10px 10px; text-align: center"> <div class="w2ui-spinner" style="width: 18px; height: 18px; position: relative; top: 5px;"></div> <div style="display: inline-block; padding: 3px; color: #999;">' + w2utils . lang ( "Loading..." ) + "</div></td></tr></table>" ; for ( var a = 0 , c = '<table cellspacing="0" cellpadding="0" class="w2ui-drop-menu">' , d = null , e = null , f = 0 ; f < b . items . length ; f ++ ) { var g = b . items [ f ] ; if ( "string" == typeof g ? g = { id : g , text : g } : ( null != g . text && null == g . id && ( g . id = g . text ) , null == g . text && null != g . id && ( g . text = g . id ) , null != g . caption && ( g . text = g . caption ) , d = g . img , e = g . icon , null == d && ( d = null ) , null == e && ( e = null ) ) , g . hidden !== ! 0 ) { var i = "" , j = g . text ; if ( "function" == typeof b . render && ( j = b . render ( g , b ) ) , d && ( i = '<td class="menu-icon"><div class="w2ui-tb-image w2ui-icon ' + d + '"></div></td>' ) , e && ( i = '<td class="menu-icon" align="center"><span class="w2ui-icon ' + e + '"></span></td>' ) , "undefined" == typeof j || "" === j || /^-+$/ . test ( j ) ) c += '<tr><td colspan="2" style="padding: 6px; pointer-events: none"><div style="border-top: 1px solid silver;"></div></td></tr>' ; else { var k = a % 2 === 0 ? "w2ui-item-even" : "w2ui-item-odd" ; b . altRows !== ! 0 && ( k = "" ) ; var l = 1 ; "" == i && l ++ , null == g . count && l ++ , c += '<tr index="' + f + '" style="' + ( g . style ? g . style : "" ) + '" class="' + k + " " + ( b . index === f ? "w2ui-selected" : "" ) + " " + ( g . disabled === ! 0 ? "w2ui-disabled" : "" ) + "\" onmousedown=\"$(this).parent().find('tr').removeClass('w2ui-selected'); $(this).addClass('w2ui-selected');\" onclick=\"event.stopPropagation(); if (" + ( g . disabled === ! 0 ? "true" : "false" ) + ") return; $('#w2ui-overlay" + h + "').remove(); $.fn.w2menuHandler(event, '" + f + "');\">" + i + ' <td class="menu-text" colspan="' + l + '">' + j + '</td> <td class="menu-count">' + ( null != g . count ? "<span>" + g . count + "</span>" : "" ) + "</td></tr>" , a ++ } } b . items [ f ] = g } return 0 === a && ( c += '<tr><td style="padding: 13px; color: #999; text-align: center">' + b . msgNoItems + "</div></td></tr>" ) , c += "</table>" } var f = { index : null , items : [ ] , render : null , msgNoItems : "No items" , onSelect : null , tmp : { } } , g = this , h = "" ; if ( "refresh" !== a ) { 1 === arguments . length ? b = a : b . items = a , "object" != typeof b && ( b = { } ) , b = $ . extend ( { } , f , b ) , $ . fn . w2menuOptions = b , b . name && ( h = "-" + b . name ) , "function" == typeof b . select && "function" != typeof b . onSelect && ( b . onSelect = b . select ) , "function" == typeof b . onRender && "function" != typeof b . render && ( b . render = b . onRender ) , $ . fn . w2menuHandler = function ( a , c ) { "function" = = typeof b . onSelect && setTimeout ( function ( ) { b . onSelect ( { index : c , item : b . items [ c ] , originalEvent : a } ) } , 10 ) } ; var i = "" ; if ( b . search ) { i += '<div style="position: absolute; top: 0px; height: 40px; left: 0px; right: 0px; border-bottom: 1px solid silver; background-color: #ECECEC; padding: 8px 5px;"> <div class="w2ui-icon icon-search" style="position: absolute; margin-top: 4px; margin-left: 6px; width: 11px; background-position: left !important;"></div> <input id="menu-search" type="text" style="width: 100%; outline: none; padding-left: 20px;" onclick="event.stopPropagation();"></div>' , b . style += ";background-color: #ECECEC" , b . index = 0 ; for ( var j in b . items ) b . items [ j ] . hidden = ! 1 } i += '<div class="menu" style="position: absolute; top: ' + ( b . search ? 40 : 0 ) + 'px; bottom: 0px; width: 100%; overflow: auto;">' + e ( ) + "</div>" ; var k = $ ( this ) . w2overlay ( i , b ) ; return setTimeout ( function ( ) { if ( $ ( "#w2ui-overlay" + h + " #menu-search" ) . on ( "keyup" , d ) . on ( "keydown" , function ( a ) { 9 === a . keyCode && ( a . stopPropagation ( ) , a . preventDefault ( ) ) } ) , b . search ) { if ( - 1 != [ "text" , "password" ] . indexOf ( $ ( g ) [ 0 ] . type ) || "texarea" == $ ( g ) [ 0 ] . tagName ) return ; $ ( "#w2ui-overlay" + h + " #menu-search" ) . focus ( ) } } , 200 ) , c ( ) , k } if ( $ ( "#w2ui-overlay" + h ) . length > 0 ) { b = $ . extend ( $ . fn . w2menuOptions , b ) ; var l = $ ( "#w2ui-overlay" + h + " div.menu" ) . scrollTop ( ) ; $ ( "#w2ui-overlay" + h + " div.menu" ) . html ( e ( ) ) , $ ( "#w2ui-overlay" + h + " div.menu" ) . scrollTop ( l ) , c ( ) } else $ ( this ) . w2menu ( b ) } } ( ) , function ( ) { var w2grid = function ( a ) { this . name = null , this . box = null , this . header = "" , this . url = "" , this . routeData = { } , this . columns = [ ] , this . columnGroups = [ ] , this . records = [ ] , this . summary = [ ] , this . searches = [ ]
} , reset : function ( a ) { this . offset = 0 , this . total = 0 , this . last . scrollTop = 0 , this . last . scrollLeft = 0 , this . last . selection . indexes = [ ] , this . last . selection . columns = { } , this . last . range _start = null , this . last . range _end = null , this . last . xhr _offset = 0 , this . searchReset ( a ) , null != this . last . sortData && ( this . sortData = this . last . sortData ) , this . set ( { expanded : ! 1 } , ! 0 ) , a || this . refresh ( ) } , skip : function ( a ) { var b = "object" != typeof this . url ? this . url : this . url . get ; b ? ( this . offset = parseInt ( a ) , this . offset > this . total && ( this . offset = this . total - this . limit ) , ( this . offset < 0 || ! w2utils . isInt ( this . offset ) ) && ( this . offset = 0 ) , this . records = [ ] , this . last . xhr _offset = 0 , this . last . pull _more = ! 0 , this . last . scrollTop = 0 , this . last . scrollLeft = 0 , $ ( "#grid_" + this . name + "_records" ) . prop ( "scrollTop" , 0 ) , this . reload ( ) ) : console . log ( "ERROR: grid.skip() can only be called when you have remote data source." ) } , load : function ( a , b ) { return "undefined" == typeof a ? void console . log ( 'ERROR: You need to provide url argument when calling .load() method of "' + this . name + '" object.' ) : void this . request ( "get-records" , { } , a , b ) } , reload : function ( a ) { var b = "object" != typeof this . url ? this . url : this . url . get ; b ? ( this . clear ( ! 0 ) , this . request ( "get-records" , { } , null , a ) ) : ( this . last . scrollTop = 0 , this . last . scrollLeft = 0 , this . last . range _start = null , this . last . range _end = null , this . localSearch ( ) , this . refresh ( ) , "function" == typeof a && a ( { status : "success" } ) ) } , request : function ( a , b , c , d ) { if ( "undefined" == typeof b && ( b = { } ) , ( "undefined" == typeof c || "" == c || null == c ) && ( c = this . url ) , "" != c && null != c ) { var e = { } ; if ( w2utils . isInt ( this . offset ) || ( this . offset = 0 ) , w2utils . isInt ( this . last . xhr _offset ) || ( this . last . xhr _offset = 0 ) , e . cmd = a , e . selected = this . getSelection ( ) , e . limit = this . limit , e . offset = parseInt ( this . offset ) + this . last . xhr _offset , e . search = this . searchData , e . searchLogic = this . last . logic , e . sort = this . sortData , 0 == this . searchData . length && ( delete e . search , delete e . searchLogic ) , 0 == this . sortData . length && delete e . sort , $ . extend ( e , this . postData ) , $ . extend ( e , b ) , "get-records" == a ) { var f = this . trigger ( { phase : "before" , type : "request" , target : this . name , url : c , postData : e } ) ; if ( f . isCancelled === ! 0 ) return void ( "function" == typeof d && d ( { status : "error" , message : "Request aborted." } ) ) } else var f = { url : c , postData : e } ; var g = this ; if ( 0 == this . last . xhr _offset ) this . lock ( this . msgRefresh , ! 0 ) ; else { var h = $ ( "#grid_" + this . name + "_rec_more" ) ; this . autoLoad === ! 0 ? h . show ( ) . find ( "td" ) . html ( '<div><div style="width: 20px; height: 20px;" class="w2ui-spinner"></div></div>' ) : h . find ( "td" ) . html ( "<div>" + w2utils . lang ( "Load" ) + " " + g . limit + " " + w2utils . lang ( "More" ) + "...</div>" ) } if ( this . last . xhr ) try { this . last . xhr . abort ( ) } catch ( i ) { } var c = "object" != typeof f . url ? f . url : f . url . get ; if ( "save-records" == e . cmd && "object" == typeof f . url && ( c = f . url . save ) , "delete-records" == e . cmd && "object" == typeof f . url && ( c = f . url . remove ) , ! $ . isEmptyObject ( g . routeData ) ) { var j = w2utils . parseRoute ( c ) ; if ( j . keys . length > 0 ) for ( var k = 0 ; k < j . keys . length ; k ++ ) null != g . routeData [ j . keys [ k ] . name ] && ( c = c . replace ( new RegExp ( ":" + j . keys [ k ] . name , "g" ) , g . routeData [ j . keys [ k ] . name ] ) ) } var l = { type : "POST" , url : c , data : f . postData , dataType : "text" } ; "HTTP" == w2utils . settings . dataType && ( l . data = "object" == typeof l . data ? String ( $ . param ( l . data , ! 1 ) ) . replace ( /%5B/g , "[" ) . replace ( /%5D/g , "]" ) : l . data ) , "RESTFULL" == w2utils . settings . dataType && ( l . type = "GET" , "save-records" == e . cmd && ( l . type = "PUT" ) , "delete-records" == e . cmd && ( l . type = "DELETE" ) , l . data = "object" == typeof l . data ? String ( $ . param ( l . data , ! 1 ) ) . replace ( /%5B/g , "[" ) . replace ( /%5D/g , "]" ) : l . data ) , "JSON" == w2utils . settings . dataType && ( l . type = "POST" , l . data = JSON . stringify ( l . data ) , l . contentType = "application/json" ) , this . method && ( l . type = this . method ) , this . last . xhr _cmd = e . cmd , this . last . xhr _start = ( new Date ) . getTime ( ) , this . last . xhr = $ . ajax ( l ) . done ( function ( b , c ) { g . requestComplete ( c , a , d ) } ) . fail ( function ( b , c , e ) { var f = { status : c , error : e , rawResponseText : b . responseText } , h = g . trigger ( { phase : "before" , type : "error" , error : f , xhr : b } ) ; if ( h . isCancelled !== ! 0 ) { if ( "abort" != c ) { var i ; try { i = $ . parseJSON ( b . responseText ) } catch ( j ) { } console . log ( "ERROR: Server communication failed." , "\n EXPECTED:" , { status : "success" , total : 5 , records : [ { recid : 1 , field : "value" } ] } , "\n OR:" , { status : "error" , message : "error message" } , " \ n RECE
for ( var f in e ) "w2ui-search" != e [ f ] . id && "break" != e [ f ] . type && this . toolbar . refresh ( e [ f ] . id ) } } else $ ( "#grid_" + this . name + "_toolbar" ) . hide ( ) ; this . searchClose ( ) ; var g = $ ( "#grid_" + a . name + "_search_all" ) ; ! this . multiSearch && "all" == this . last . field && this . searches . length > 0 && ( this . last . field = this . searches [ 0 ] . field , this . last . caption = this . searches [ 0 ] . caption ) ; for ( var h in this . searches ) this . searches [ h ] . field == this . last . field && ( this . last . caption = this . searches [ h ] . caption ) ; if ( this . last . multi ? g . attr ( "placeholder" , "[" + w2utils . lang ( "Multiple Fields" ) + "]" ) : g . attr ( "placeholder" , this . last . caption ) , g . val ( ) != this . last . search ) { var i = this . last . search , e = g . data ( "w2field" ) ; e && ( i = e . format ( i ) ) , g . val ( i ) } var e = this . find ( { summary : ! 0 } , ! 0 ) ; if ( e . length > 0 ) { for ( var f in e ) this . summary . push ( this . records [ e [ f ] ] ) ; for ( var f = e . length - 1 ; f >= 0 ; f -- ) this . records . splice ( e [ f ] , 1 ) ; this . total = this . total - e . length } var j = a . find ( { expanded : ! 0 } , ! 0 ) ; for ( var k in j ) a . records [ j [ k ] ] . expanded = ! 1 ; var l = "" ; l += '<div id="grid_' + this . name + '_records" class="w2ui-grid-records" onscroll="var obj = w2ui[\'' + this . name + "']; obj.last.scrollTop = this.scrollTop; obj.last.scrollLeft = this.scrollLeft; $('#grid_" + this . name + "_columns')[0].scrollLeft = this.scrollLeft; $('#grid_" + this . name + "_summary')[0].scrollLeft = this.scrollLeft; obj.scroll(event);\">" + this . getRecordsHTML ( ) + '</div><div id="grid_' + this . name + '_columns" class="w2ui-grid-columns"> <table>' + this . getColumnsHTML ( ) + "</table></div>" , $ ( "#grid_" + this . name + "_body" ) . html ( l ) , this . summary . length > 0 ? $ ( "#grid_" + this . name + "_summary" ) . html ( this . getSummaryHTML ( ) ) . show ( ) : $ ( "#grid_" + this . name + "_summary" ) . hide ( ) , this . show . footer ? $ ( "#grid_" + this . name + "_footer" ) . html ( this . getFooterHTML ( ) ) . show ( ) : $ ( "#grid_" + this . name + "_footer" ) . hide ( ) , this . searchData . length > 0 ? $ ( "#grid_" + this . name + "_searchClear" ) . show ( ) : $ ( "#grid_" + this . name + "_searchClear" ) . hide ( ) ; var m = this . last . selection ; return m . indexes . length == this . records . length || 0 !== this . searchData . length && m . indexes . length == this . last . searchIds . length ? $ ( "#grid_" + this . name + "_check_all" ) . prop ( "checked" , ! 0 ) : $ ( "#grid_" + this . name + "_check_all" ) . prop ( "checked" , ! 1 ) , this . status ( ) , setTimeout ( function ( ) { var b = $ . trim ( $ ( "#grid_" + a . name + "_search_all" ) . val ( ) ) ; "" != b && $ ( a . box ) . find ( ".w2ui-grid-data > div" ) . w2marker ( b ) } , 50 ) , this . trigger ( $ . extend ( d , { phase : "after" } ) ) , a . resize ( ) , a . addRange ( "selection" ) , setTimeout ( function ( ) { a . resize ( ) , a . scroll ( ) } , 1 ) , a . reorderColumns && ! a . last . columnDrag ? a . last . columnDrag = a . initColumnDrag ( ) : ! a . reorderColumns && a . last . columnDrag && a . last . columnDrag . remove ( ) , ( new Date ) . getTime ( ) - b } } } , render : function ( a ) { function b ( a ) { if ( 1 == a . which && ( "text" == e . last . userSelect && ( delete e . last . userSelect , $ ( e . box ) . find ( ".w2ui-grid-body" ) . css ( "user-select" , "none" ) . css ( "-webkit-user-select" , "none" ) . css ( "-moz-user-select" , "none" ) . css ( "-ms-user-select" , "none" ) , $ ( this . box ) . on ( "selectstart" , function ( ) { return ! 1 } ) ) , ! ( $ ( a . target ) . parents ( ) . hasClass ( "w2ui-head" ) || $ ( a . target ) . hasClass ( "w2ui-head" ) || e . last . move && "expand" == e . last . move . type ) ) ) { if ( a . altKey ) $ ( e . box ) . off ( "selectstart" ) , $ ( e . box ) . find ( ".w2ui-grid-body" ) . css ( "user-select" , "text" ) . css ( "-webkit-user-select" , "text" ) . css ( "-moz-user-select" , "text" ) . css ( "-ms-user-select" , "text" ) , e . selectNone ( ) , e . last . move = { type : "text-select" } , e . last . userSelect = "text" ; else { if ( ! e . multiSelect ) return ; e . last . move = { x : a . screenX , y : a . screenY , divX : 0 , divY : 0 , recid : $ ( a . target ) . parents ( "tr" ) . attr ( "recid" ) , column : "TD" == a . target . tagName ? $ ( a . target ) . attr ( "col" ) : $ ( a . target ) . parents ( "td" ) . attr ( "col" ) , type : "select" , ghost : ! 1 , start : ! 0 } } $ ( document ) . on ( "mousemove" , c ) , $ ( document ) . on ( "mouseup" , d ) } } function c ( a ) { var b = e . last . move ; if ( b && "select" == b . type && ( b . divX = a . screenX - b . x , b . divY = a . screenY - b . y , ! ( Math . abs ( b . divX ) <= 1 && Math . abs ( b . divY ) <= 1 ) ) ) { if ( e . last . cancelClick = ! 0 , 1 == e . reorderRows ) { if ( ! b . ghost ) { var c = $ ( "#grid_" + e . name + "_rec_" + b . recid ) , d = c . parents ( "table" ) . find ( "tr:first-child" ) . clone ( ) ; b . offsetY = a . offsetY , b . from = b . recid , b . pos = c . position ( ) , b . ghost = $ ( c ) . clone ( ! 0 ) , b . ghost . removeAttr ( "id" ) , c . find ( "td:first-child" ) . replaceWith ( '<td colspan="1000" style="height: ' + e . recordHeight + ' px ; background - color : # d
case "hex" : break ; case "list" : case "combo" : case "enum" : var e = c . options ; "list" == c . type && ( e . selected = { } ) , "enum" == c . type && ( e . selected = [ ] ) , d && ( e . selected = d . value ) , $ ( "#grid_" + this . name + "_field_" + b ) . w2field ( c . type , e ) , "combo" == c . type && $ ( "#grid_" + this . name + "_operator_" + b ) . val ( "begins" ) ; break ; case "select" : var e = '<option value="">--</option>' ; for ( var f in c . options . items ) { var g = c . options . items [ f ] ; if ( $ . isPlainObject ( c . options . items [ f ] ) ) { var h = g . id , i = g . text ; "undefined" == typeof h && "undefined" != typeof g . value && ( h = g . value ) , "undefined" == typeof i && "undefined" != typeof g . caption && ( i = g . caption ) , null == h && ( h = "" ) , e += '<option value="' + h + '">' + i + "</option>" } else e += '<option value="' + g + '">' + g + "</option>" } $ ( "#grid_" + this . name + "_field_" + b ) . html ( e ) } null != d && ( "int" == d . type && - 1 != [ "in" , "not in" ] . indexOf ( d . operator ) && $ ( "#grid_" + this . name + "_field_" + b ) . w2field ( "clear" ) . val ( d . value ) , $ ( "#grid_" + this . name + "_operator_" + b ) . val ( d . operator ) . trigger ( "change" ) , $ . isArray ( d . value ) ? - 1 != [ "in" , "not in" ] . indexOf ( d . operator ) ? $ ( "#grid_" + this . name + "_field_" + b ) . val ( d . value ) . trigger ( "change" ) : ( $ ( "#grid_" + this . name + "_field_" + b ) . val ( d . value [ 0 ] ) . trigger ( "change" ) , $ ( "#grid_" + this . name + "_field2_" + b ) . val ( d . value [ 1 ] ) . trigger ( "change" ) ) : "udefined" != typeof d . value && $ ( "#grid_" + this . name + "_field_" + b ) . val ( d . value ) . trigger ( "change" ) ) } $ ( "#w2ui-overlay-searches-" + this . name + " .w2ui-grid-searches *[rel=search]" ) . on ( "keypress" , function ( b ) { 13 == b . keyCode && ( a . search ( ) , $ ( ) . w2overlay ( ) ) } ) } , getColumnsHTML : function ( ) { function a ( ) { var a = "<tr>" ; "" != c . columnGroups [ c . columnGroups . length - 1 ] . caption && c . columnGroups . push ( { caption : "" } ) , c . show . lineNumbers && ( a += '<td class="w2ui-head w2ui-col-number"> <div> </div></td>' ) , c . show . selectColumn && ( a += '<td class="w2ui-head w2ui-col-select"> <div> </div></td>' ) , c . show . expandColumn && ( a += '<td class="w2ui-head w2ui-col-expand"> <div> </div></td>' ) ; for ( var b = 0 , d = 0 ; d < c . columnGroups . length ; d ++ ) { var e = c . columnGroups [ d ] , f = c . columns [ b ] ; if ( ( "undefined" == typeof e . span || e . span != parseInt ( e . span ) ) && ( e . span = 1 ) , "undefined" != typeof e . colspan && ( e . span = e . colspan ) , e . master === ! 0 ) { var g = "" ; for ( var h in c . sortData ) c . sortData [ h ] . field == f . field && ( RegExp ( "asc" , "i" ) . test ( c . sortData [ h ] . direction ) && ( g = "w2ui-sort-up" ) , RegExp ( "desc" , "i" ) . test ( c . sortData [ h ] . direction ) && ( g = "w2ui-sort-down" ) ) ; var i = "" ; f . resizable !== ! 1 && ( i = '<div class="w2ui-resizer" name="' + b + '"></div>' ) , a += '<td class="w2ui-head ' + g + '" col="' + b + '" rowspan="2" colspan="' + ( e . span + ( d == c . columnGroups . length - 1 ? 1 : 0 ) ) + '" onclick="w2ui[\'' + c . name + "'].columnClick('" + f . field + "', event);\">" + i + ' <div class="w2ui-col-group w2ui-col-header ' + ( g ? "w2ui-col-sorted" : "" ) + '"> <div class="' + g + '"></div>' + ( f . caption ? f . caption : " " ) + " </div></td>" } else a += '<td class="w2ui-head" col="' + b + '" colspan="' + ( e . span + ( d == c . columnGroups . length - 1 ? 1 : 0 ) ) + '"> <div class="w2ui-col-group">' + ( e . caption ? e . caption : " " ) + " </div></td>" ; b += e . span } return a += "</tr>" } function b ( a ) { var b = "<tr>" , d = ! c . reorderColumns || c . columnGroups && c . columnGroups . length ? "" : " w2ui-reorder-cols-head " ; c . show . lineNumbers && ( b += '<td class="w2ui-head w2ui-col-number" onclick="w2ui[\'' + c . name + "'].columnClick('line-number', event);\"> <div>#</div></td>" ) , c . show . selectColumn && ( b += '<td class="w2ui-head w2ui-col-select" onclick="if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;"> <div> <input type="checkbox" id="grid_' + c . name + '_check_all" tabIndex="-1" style="' + ( 0 == c . multiSelect ? "display: none;" : "" ) + '" onclick="if (this.checked) w2ui[\'' + c . name + "'].selectAll(); else w2ui['" + c . name + "'].selectNone(); if (event.stopPropagation) event.stopPropagation(); else event.cancelBubble = true;\"> </div></td>" ) , c . show . expandColumn && ( b += '<td class="w2ui-head w2ui-col-expand"> <div> </div></td>' ) ; for ( var e = 0 , f = 0 , g = 0 ; g < c . columns . length ; g ++ ) { var h = c . columns [ g ] , i = { } ; if ( g == f && ( f += "undefined" != typeof c . columnGroups [ e ] ? parseInt ( c . columnGroups [ e ] . span ) : 0 , e ++ ) , "undefined" != typeof c . columnGroups [ e - 1 ] ) var i = c . columnGroups [ e - 1 ] ; if ( ! h . hidden ) { var j = "" ; f
} , 0 ) , ( new Date ) . getTime ( ) - h } } , refresh : function ( a ) { var b = this ; "undefined" == typeof a && ( a = null ) ; var c = ( new Date ) . getTime ( ) , d = b . trigger ( { phase : "before" , type : "refresh" , target : "undefined" != typeof a ? a : b . name , object : b . get ( a ) } ) ; if ( d . isCancelled !== ! 0 ) { if ( "string" == typeof a ) { var e = b . get ( a ) ; if ( null === e ) return ; var f = "#layout_" + b . name + "_panel_" + e . type , g = "#layout_" + b . name + "_resizer_" + e . type ; $ ( f ) . css ( { display : e . hidden ? "none" : "block" } ) , e . resizable ? $ ( g ) . show ( ) : $ ( g ) . hide ( ) , "object" == typeof e . content && "function" == typeof e . content . render ? ( e . content . box = $ ( f + "> .w2ui-panel-content" ) [ 0 ] , setTimeout ( function ( ) { $ ( f + "> .w2ui-panel-content" ) . length > 0 && ( $ ( f + "> .w2ui-panel-content" ) . removeClass ( ) . removeAttr ( "name" ) . off ( "selectstart" ) . addClass ( "w2ui-panel-content" ) . css ( "overflow" , e . overflow ) [ 0 ] . style . cssText += ";" + e . style ) , e . content . render ( ) } , 1 ) ) : $ ( f + "> .w2ui-panel-content" ) . length > 0 && ( $ ( f + "> .w2ui-panel-content" ) . removeClass ( ) . removeAttr ( "name" ) . off ( "selectstart" ) . addClass ( "w2ui-panel-content" ) . html ( e . content ) . css ( "overflow" , e . overflow ) [ 0 ] . style . cssText += ";" + e . style ) ; var h = $ ( b . box ) . find ( f + "> .w2ui-panel-tabs" ) ; e . show . tabs ? 0 === h . find ( "[name=" + e . tabs . name + "]" ) . length && null !== e . tabs ? h . w2render ( e . tabs ) : e . tabs . refresh ( ) : h . html ( "" ) . removeClass ( "w2ui-tabs" ) . hide ( ) , h = $ ( b . box ) . find ( f + "> .w2ui-panel-toolbar" ) , e . show . toolbar ? 0 === h . find ( "[name=" + e . toolbar . name + "]" ) . length && null !== e . toolbar ? h . w2render ( e . toolbar ) : e . toolbar . refresh ( ) : h . html ( "" ) . removeClass ( "w2ui-toolbar" ) . hide ( ) , h = $ ( b . box ) . find ( f + "> .w2ui-panel-title" ) , e . title ? h . html ( e . title ) . show ( ) : h . html ( "" ) . hide ( ) } else { if ( 0 == $ ( "#layout_" + b . name + "_panel_main" ) . length ) return void b . render ( ) ; b . resize ( ) ; for ( var i in this . panels ) b . refresh ( this . panels [ i ] . type ) } return b . trigger ( $ . extend ( d , { phase : "after" } ) ) , ( new Date ) . getTime ( ) - c } } , resize : function ( ) { if ( ! this . box ) return ! 1 ; var a = ( new Date ) . getTime ( ) , c = this . tmp . resize , d = this . trigger ( { phase : "before" , type : "resize" , target : this . name , panel : c ? c . type : "all" , diff _x : c ? c . diff _x : 0 , diff _y : c ? c . diff _y : 0 } ) ; if ( d . isCancelled !== ! 0 ) { this . padding < 0 && ( this . padding = 0 ) ; var e = parseInt ( $ ( this . box ) . width ( ) ) , f = parseInt ( $ ( this . box ) . height ( ) ) ; $ ( this . box ) . find ( " > div" ) . css ( { width : e + "px" , height : f + "px" } ) ; var g , h , i , j , k , l = this , m = this . get ( "main" ) , n = this . get ( "preview" ) , o = this . get ( "left" ) , p = this . get ( "right" ) , q = this . get ( "top" ) , r = this . get ( "bottom" ) , s = null !== n && n . hidden !== ! 0 ? ! 0 : ! 1 , t = null !== o && o . hidden !== ! 0 ? ! 0 : ! 1 , u = null !== p && p . hidden !== ! 0 ? ! 0 : ! 1 , v = null !== q && q . hidden !== ! 0 ? ! 0 : ! 1 , w = null !== r && r . hidden !== ! 0 ? ! 0 : ! 1 ; for ( var x in b ) if ( x = b [ x ] , "main" !== x ) { var c = this . get ( x ) ; if ( c ) { var y = String ( c . size || 0 ) ; if ( "%" == y . substr ( y . length - 1 ) ) { var z = f ; "preview" == c . type && ( z = z - ( q && ! q . hidden ? q . sizeCalculated : 0 ) - ( r && ! r . hidden ? r . sizeCalculated : 0 ) ) , c . sizeCalculated = parseInt ( ( "left" == c . type || "right" == c . type ? e : z ) * parseFloat ( c . size ) / 100 ) } else c . sizeCalculated = parseInt ( c . size ) ; c . sizeCalculated = Math . max ( c . sizeCalculated , parseInt ( c . minSize ) ) } } null !== q && q . hidden !== ! 0 ? ( g = 0 , h = 0 , i = e , j = q . sizeCalculated , $ ( "#layout_" + this . name + "_panel_top" ) . css ( { display : "block" , left : g + "px" , top : h + "px" , width : i + "px" , height : j + "px" } ) . show ( ) , q . width = i , q . height = j , q . resizable && ( h = q . sizeCalculated - ( 0 === this . padding ? this . resizer : 0 ) , j = this . resizer > this . padding ? this . resizer : this . padding , $ ( "#layout_" + this . name + "_resizer_top" ) . show ( ) . css ( { display : "block" , left : g + "px" , top : h + "px" , width : i + "px" , height : j + "px" , cursor : "ns-resize" } ) . off ( "mousedown" ) . on ( "mousedown" , function ( a ) { var b = l . trigger ( { phase : "before" , type : "resizerClick" , target : "top" , originalEvent : a } ) ; if ( b . isCancelled !== ! 0 ) return w2ui [ l . name ] . tmp . events . resizeStart ( "top" , a ) , l . trigger ( $ . extend ( b , { phase : "after" } ) ) , ! 1 } ) ) ) : $ ( "#layout_" + this . name + "_panel_top" ) . hide ( ) , null !== o && o . hidden !== ! 0 ? ( g = 0 , h = 0 + ( v ? q . sizeCalculated + this . padding : 0 ) , i = o . sizeCalculated , j = f - ( v ? q . sizeCalculated + this . padding : 0 ) - ( w ? r . sizeCalculated + this . padding : 0 ) , k = $ ( "#layout_" + this . name + "_panel_left" ) , - 1 != window . navigator . userAgent . indexOf ( "MSIE" ) && k . length > 0 && k [ 0 ] . clientHeight < k [ 0 ] . scrollHeight && ( i += 17 ) , k . css ( { display : "block" , left : g + "px" , top : h + "px" , width : i + "px" , height : j + "px" } ) . show ( ) , o . width = i , o . height = j , o . resizable && ( g = o . sizeCalculated - ( 0 === this . padding ? this . resizer : 0 ) , i = this .
} return a } , select : function ( a ) { return this . active == a || null === this . get ( a ) ? ! 1 : ( this . active = a , this . refresh ( ) , ! 0 ) } , set : function ( a , b ) { var c = this . get ( a , ! 0 ) ; return null === c ? ! 1 : ( $ . extend ( this . tabs [ c ] , b ) , this . refresh ( a ) , ! 0 ) } , get : function ( a , b ) { if ( 0 === arguments . length ) { for ( var c = [ ] , d = 0 ; d < this . tabs . length ; d ++ ) null != this . tabs [ d ] . id && c . push ( this . tabs [ d ] . id ) ; return c } for ( var e = 0 ; e < this . tabs . length ; e ++ ) if ( this . tabs [ e ] . id == a ) return b === ! 0 ? e : this . tabs [ e ] ; return null } , show : function ( ) { for ( var a = this , b = 0 , c = [ ] , d = 0 ; d < arguments . length ; d ++ ) { var e = this . get ( arguments [ d ] ) ; e && e . hidden !== ! 1 && ( b ++ , e . hidden = ! 1 , c . push ( e . id ) ) } return setTimeout ( function ( ) { for ( var b in c ) a . refresh ( c [ b ] ) } , 15 ) , b } , hide : function ( ) { for ( var a = this , b = 0 , c = [ ] , d = 0 ; d < arguments . length ; d ++ ) { var e = this . get ( arguments [ d ] ) ; e && e . hidden !== ! 0 && ( b ++ , e . hidden = ! 0 , c . push ( e . id ) ) } return setTimeout ( function ( ) { for ( var b in c ) a . refresh ( c [ b ] ) } , 15 ) , b } , enable : function ( ) { for ( var a = this , b = 0 , c = [ ] , d = 0 ; d < arguments . length ; d ++ ) { var e = this . get ( arguments [ d ] ) ; e && e . disabled !== ! 1 && ( b ++ , e . disabled = ! 1 , c . push ( e . id ) ) } return setTimeout ( function ( ) { for ( var b in c ) a . refresh ( c [ b ] ) } , 15 ) , b } , disable : function ( ) { for ( var a = this , b = 0 , c = [ ] , d = 0 ; d < arguments . length ; d ++ ) { var e = this . get ( arguments [ d ] ) ; e && e . disabled !== ! 0 && ( b ++ , e . disabled = ! 0 , c . push ( e . id ) ) } return setTimeout ( function ( ) { for ( var b in c ) a . refresh ( c [ b ] ) } , 15 ) , b } , refresh : function ( a ) { var b = ( new Date ) . getTime ( ) , c = this . trigger ( { phase : "before" , type : "refresh" , target : "undefined" != typeof a ? a : this . name , object : this . get ( a ) } ) ; if ( c . isCancelled !== ! 0 ) { if ( "undefined" == typeof a ) for ( var d = 0 ; d < this . tabs . length ; d ++ ) this . refresh ( this . tabs [ d ] . id ) ; else { var e = this . get ( a ) ; if ( null === e ) return ! 1 ; "undefined" != typeof e . caption && ( e . text = e . caption ) ; var f = $ ( this . box ) . find ( "#tabs_" + this . name + "_tab_" + w2utils . escapeId ( e . id ) ) , g = ( e . closable ? '<div class="w2ui-tab-close" onclick="w2ui[\'' + this . name + "'].animateClose('" + e . id + "', event);\"></div>" : "" ) + ' <div class="w2ui-tab' + ( this . active === e . id ? " active" : "" ) + ( e . closable ? " closable" : "" ) + '" title="' + ( "undefined" != typeof e . hint ? e . hint : "" ) + '" onclick="w2ui[\'' + this . name + "'].click('" + e . id + "', event);\">" + e . text + "</div>" ; if ( 0 === f . length ) { var h = "" ; e . hidden && ( h += "display: none;" ) , e . disabled && ( h += "opacity: 0.2; -moz-opacity: 0.2; -webkit-opacity: 0.2; -o-opacity: 0.2; filter:alpha(opacity=20);" ) ; var i = '<td id="tabs_' + this . name + "_tab_" + e . id + '" style="' + h + '" valign="middle">' + g + "</td>" ; this . get ( a , ! 0 ) !== this . tabs . length - 1 && $ ( this . box ) . find ( "#tabs_" + this . name + "_tab_" + w2utils . escapeId ( this . tabs [ parseInt ( this . get ( a , ! 0 ) ) + 1 ] . id ) ) . length > 0 ? $ ( this . box ) . find ( "#tabs_" + this . name + "_tab_" + w2utils . escapeId ( this . tabs [ parseInt ( this . get ( a , ! 0 ) ) + 1 ] . id ) ) . before ( i ) : $ ( this . box ) . find ( "#tabs_" + this . name + "_right" ) . before ( i ) } else f . html ( g ) , e . hidden ? f . css ( "display" , "none" ) : f . css ( "display" , "" ) , f . css ( e . disabled ? { opacity : "0.2" , "-moz-opacity" : "0.2" , "-webkit-opacity" : "0.2" , "-o-opacity" : "0.2" , filter : "alpha(opacity=20)" } : { opacity : "1" , "-moz-opacity" : "1" , "-webkit-opacity" : "1" , "-o-opacity" : "1" , filter : "alpha(opacity=100)" } ) } return $ ( "#tabs_" + this . name + "_right" ) . html ( this . right ) , this . trigger ( $ . extend ( c , { phase : "after" } ) ) , ( new Date ) . getTime ( ) - b } } , render : function ( a ) { var b = ( new Date ) . getTime ( ) , c = this . trigger ( { phase : "before" , type : "render" , target : this . name , box : a } ) ; if ( c . isCancelled !== ! 0 ) { if ( "undefined" != typeof a && null !== a && ( $ ( this . box ) . find ( "> table #tabs_" + this . name + "_right" ) . length > 0 && $ ( this . box ) . removeAttr ( "name" ) . removeClass ( "w2ui-reset w2ui-tabs" ) . html ( "" ) , this . box = a ) , ! this . box ) return ! 1 ; var d = '<table cellspacing="0" cellpadding="1" width="100%"> <tr><td width="100%" id="tabs_' + this . name + '_right" align="right">' + this . right + "</td></tr></table>" ; return $ ( this . box ) . attr ( "name" , this . name ) . addClass ( "w2ui-reset w2ui-tabs" ) . html ( d ) , $ ( this . box ) . length > 0 && ( $ ( this . box ) [ 0 ] . style . cssText += this . style ) , this . trigger ( $ . extend ( c , { phase : "after" } ) ) , this . refresh ( ) , ( new Date ) . getTime ( ) - b } } , resize : function ( ) { var a = ( new Date ) . getTime ( ) , b = this . trigger ( { phase : "before" , type : "resize" , target : this . name } ) ; return b . isCancelled !== ! 0 ? ( this . trigger ( $ . extend ( b , { phase : "after" } ) ) , ( new Date ) . getTime ( ) - a ) : void 0 } , destroy : function ( ) { var a = this .
} var c = ( new Date ) . getTime ( ) , d = this . trigger ( { phase : "before" , type : "refresh" , target : "undefined" != typeof a ? a : this . name } ) ; if ( d . isCancelled !== ! 0 ) { "" !== this . topHTML && ( $ ( this . box ) . find ( ".w2ui-sidebar-top" ) . html ( this . topHTML ) , $ ( this . box ) . find ( ".w2ui-sidebar-div" ) . css ( "top" , $ ( this . box ) . find ( ".w2ui-sidebar-top" ) . height ( ) + "px" ) ) , "" !== this . bottomHTML && ( $ ( this . box ) . find ( ".w2ui-sidebar-bottom" ) . html ( this . bottomHTML ) , $ ( this . box ) . find ( ".w2ui-sidebar-div" ) . css ( "bottom" , $ ( this . box ) . find ( ".w2ui-sidebar-bottom" ) . height ( ) + "px" ) ) , $ ( this . box ) . find ( "> div" ) . css ( { width : $ ( this . box ) . width ( ) + "px" , height : $ ( this . box ) . height ( ) + "px" } ) ; var e , f , g , h = this ; if ( "undefined" == typeof a ) e = this , g = ".w2ui-sidebar-div" ; else { if ( e = this . get ( a ) , null === e ) return ; g = "#node_" + w2utils . escapeId ( e . id ) + "_sub" } var i ; if ( e !== this ) { var j = "#node_" + w2utils . escapeId ( e . id ) ; i = b ( e ) , $ ( this . box ) . find ( j ) . before ( '<div id="sidebar_' + this . name + '_tmp"></div>' ) , $ ( this . box ) . find ( j ) . remove ( ) , $ ( this . box ) . find ( g ) . remove ( ) , $ ( "#sidebar_" + this . name + "_tmp" ) . before ( i ) , $ ( "#sidebar_" + this . name + "_tmp" ) . remove ( ) } $ ( this . box ) . find ( g ) . html ( "" ) ; for ( var k = 0 ; k < e . nodes . length ; k ++ ) f = e . nodes [ k ] , i = b ( f ) , $ ( this . box ) . find ( g ) . append ( i ) , 0 !== f . nodes . length && this . refresh ( f . id ) ; return this . trigger ( $ . extend ( d , { phase : "after" } ) ) , ( new Date ) . getTime ( ) - c } } , resize : function ( ) { var a = ( new Date ) . getTime ( ) , b = this . trigger ( { phase : "before" , type : "resize" , target : this . name } ) ; return b . isCancelled !== ! 0 ? ( $ ( this . box ) . css ( "overflow" , "hidden" ) , $ ( this . box ) . find ( "> div" ) . css ( { width : $ ( this . box ) . width ( ) + "px" , height : $ ( this . box ) . height ( ) + "px" } ) , this . trigger ( $ . extend ( b , { phase : "after" } ) ) , ( new Date ) . getTime ( ) - a ) : void 0 } , destroy : function ( ) { var a = this . trigger ( { phase : "before" , type : "destroy" , target : this . name } ) ; a . isCancelled !== ! 0 && ( $ ( this . box ) . find ( "> div > div.w2ui-sidebar-div" ) . length > 0 && $ ( this . box ) . removeAttr ( "name" ) . removeClass ( "w2ui-reset w2ui-sidebar" ) . html ( "" ) , delete w2ui [ this . name ] , this . trigger ( $ . extend ( a , { phase : "after" } ) ) ) } , lock : function ( ) { var a = $ ( this . box ) . find ( "> div:first-child" ) , b = Array . prototype . slice . call ( arguments , 0 ) ; b . unshift ( a ) , w2utils . lock . apply ( window , b ) } , unlock : function ( ) { w2utils . unlock ( this . box ) } } , $ . extend ( a . prototype , w2utils . event ) , w2obj . sidebar = a } ( ) , function ( a ) { var b = function ( b ) { this . el = null , this . helpers = { } , this . type = b . type || "text" , this . options = a . extend ( ! 0 , { } , b ) , this . onSearch = b . onSearch || null , this . onRequest = b . onRequest || null , this . onLoad = b . onLoad || null , this . onError = b . onError || null , this . onClick = b . onClick || null , this . onAdd = b . onAdd || null , this . onNew = b . onNew || null , this . onRemove = b . onRemove || null , this . onMouseOver = b . onMouseOver || null , this . onMouseOut = b . onMouseOut || null , this . onIconClick = b . onIconClick || null , this . tmp = { } , delete this . options . type , delete this . options . onSearch , delete this . options . onRequest , delete this . options . onLoad , delete this . options . onError , delete this . options . onClick , delete this . options . onMouseOver , delete this . options . onMouseOut , delete this . options . onIconClick , a . extend ( ! 0 , this , w2obj . field ) } ; a . fn . w2field = function ( c , d ) { if ( 0 != this . length ) { if ( 0 == arguments . length ) { var e = a ( this ) . data ( "w2field" ) ; return e } return "string" == typeof c && "object" == typeof d && ( c = a . extend ( ! 0 , { } , d , { type : c } ) ) , "string" == typeof c && "undefined" == typeof d && ( c = { type : c } ) , c . type = String ( c . type ) . toLowerCase ( ) , this . each ( function ( d , e ) { var f = a ( e ) . data ( "w2field" ) ; if ( "undefined" == typeof f ) { var f = new b ( c ) ; return a . extend ( f , { handlers : [ ] } ) , e && ( f . el = a ( e ) [ 0 ] ) , f . init ( ) , a ( e ) . data ( "w2field" , f ) , f } if ( f . clear ( ) , "clear" != c . type ) { var f = new b ( c ) ; return a . extend ( f , { handlers : [ ] } ) , e && ( f . el = a ( e ) [ 0 ] ) , f . init ( ) , a ( e ) . data ( "w2field" , f ) , f } } ) } var f = b . prototype ; return f [ c ] ? f [ c ] . apply ( f , Array . prototype . slice . call ( arguments , 1 ) ) : void 0 } , b . prototype = { custom : { } , pallete : [ [ "000000" , "444444" , "666666" , "999999" , "CCCCCC" , "EEEEEE" , "F3F3F3" , "FFFFFF" ] , [ "FF011B" , "FF9838" , "FFFD59" , "01FD55" , "00FFFE" , "0424F3" , "9B24F4" , "FF21F5" ] , [ "F4CCCC" , "FCE5CD" , "FFF2CC" , "D9EAD3" , "D0E0E3" , "CFE2F3" , "D9D1E9" , "EAD1DC" ] , [ "EA9899" , "F9CB9C" , "FEE599" , "B6D7A8" , "A2C4C9" , "9FC5E8" , "B4A7D6" , "D5A6BD" ] , [ "E06666" , "F6B26B" , "FED966" , "93C47D" , "76A5AF" , "6FA8DC" , "8E7CC3" , "C27BA0" ] , [ "CC0814" , "E69138" , "F1C232" , "6AA84F" , "45818E" , "3D85C6" , "674EA7" , "A54D79" ] , [ "99050C" , " B45
else { var c , d ; a ( this ) . after ( '<div class="w2ui-calendar-jump" style=""></div>' ) , a ( this ) . next ( ) . hide ( ) . html ( b . getYearHTML ( ) ) . fadeIn ( 200 ) , setTimeout ( function ( ) { a ( "#w2ui-overlay .w2ui-calendar-jump" ) . find ( ".w2ui-jump-month, .w2ui-jump-year" ) . on ( "click" , function ( ) { a ( this ) . hasClass ( "w2ui-jump-month" ) && ( a ( this ) . parent ( ) . find ( ".w2ui-jump-month" ) . removeClass ( "selected" ) , a ( this ) . addClass ( "selected" ) , d = a ( this ) . attr ( "name" ) ) , a ( this ) . hasClass ( "w2ui-jump-year" ) && ( a ( this ) . parent ( ) . find ( ".w2ui-jump-year" ) . removeClass ( "selected" ) , a ( this ) . addClass ( "selected" ) , c = a ( this ) . attr ( "name" ) ) , null != c && null != d && ( a ( "#w2ui-overlay .w2ui-calendar-jump" ) . fadeOut ( 100 ) , setTimeout ( function ( ) { k ( parseInt ( d ) + 1 , c ) } , 100 ) ) } ) , a ( "#w2ui-overlay .w2ui-calendar-jump >:last-child" ) . prop ( "scrollTop" , 2e3 ) } , 1 ) } } ) , a ( "#w2ui-overlay .w2ui-date" ) . on ( "mousedown" , function ( ) { var c = a ( this ) . attr ( "date" ) ; a ( b . el ) . val ( c ) . change ( ) , a ( this ) . css ( { "background-color" : "#B6D5FB" , "border-color" : "#aaa" } ) } ) . on ( "mouseup" , function ( ) { setTimeout ( function ( ) { a ( "#w2ui-overlay" ) . length > 0 && a ( "#w2ui-overlay" ) . removeData ( "keepOpen" ) [ 0 ] . hide ( ) } , 10 ) } ) , a ( "#w2ui-overlay .previous" ) . on ( "mousedown" , function ( ) { var a = b . options . current . split ( "/" ) ; a [ 0 ] = parseInt ( a [ 0 ] ) - 1 , k ( a [ 0 ] , a [ 1 ] ) } ) , a ( "#w2ui-overlay .next" ) . on ( "mousedown" , function ( ) { var a = b . options . current . split ( "/" ) ; a [ 0 ] = parseInt ( a [ 0 ] ) + 1 , k ( a [ 0 ] , a [ 1 ] ) } ) } ( d , e ) } if ( "time" == this . type ) { if ( a ( b . el ) . attr ( "readonly" ) ) return ; 0 == a ( "#w2ui-overlay" ) . length && a ( b . el ) . w2overlay ( '<div class="w2ui-reset w2ui-calendar-time" onclick="event.stopPropagation();"></div>' , { css : { "background-color" : "#fff" } } ) ; var g = "h24" == this . options . format ? ! 0 : ! 1 ; a ( "#w2ui-overlay > div" ) . html ( b . getHourHTML ( ) ) , a ( "#w2ui-overlay .w2ui-time" ) . on ( "mousedown" , function ( ) { a ( this ) . css ( { "background-color" : "#B6D5FB" , "border-color" : "#aaa" } ) ; var c = a ( this ) . attr ( "hour" ) ; a ( b . el ) . val ( ( c > 12 && ! g ? c - 12 : c ) + ":00" + ( g ? "" : 12 > c ? " am" : " pm" ) ) . change ( ) } ) . on ( "mouseup" , function ( ) { var c = a ( this ) . attr ( "hour" ) ; a ( "#w2ui-overlay" ) . length > 0 && a ( "#w2ui-overlay" ) [ 0 ] . hide ( ) , a ( b . el ) . w2overlay ( '<div class="w2ui-reset w2ui-calendar-time"></div>' , { css : { "background-color" : "#fff" } } ) , a ( "#w2ui-overlay > div" ) . html ( b . getMinHTML ( c ) ) , a ( "#w2ui-overlay .w2ui-time" ) . on ( "mousedown" , function ( ) { a ( this ) . css ( { "background-color" : "#B6D5FB" , "border-color" : "#aaa" } ) ; var d = a ( this ) . attr ( "min" ) ; a ( b . el ) . val ( ( c > 12 && ! g ? c - 12 : c ) + ":" + ( 10 > d ? 0 : "" ) + d + ( g ? "" : 12 > c ? " am" : " pm" ) ) . change ( ) } ) . on ( "mouseup" , function ( ) { setTimeout ( function ( ) { a ( "#w2ui-overlay" ) . length > 0 && a ( "#w2ui-overlay" ) . removeData ( "keepOpen" ) [ 0 ] . hide ( ) } , 10 ) } ) } ) } if ( - 1 != [ "list" , "combo" , "enum" ] . indexOf ( this . type ) ) { var h = this . el , i = this . el ; if ( "enum" == this . type && ( h = a ( this . helpers . multi ) , i = a ( h ) . find ( "input" ) ) , "list" == this . type && ( i = a ( this . helpers . focus ) . find ( "input" ) ) , a ( i ) . is ( ":focus" ) ) { if ( c . openOnFocus === ! 1 && "" == a ( i ) . val ( ) && b . tmp . force _open !== ! 0 ) return void a ( ) . w2overlay ( ) ; if ( b . tmp . force _hide ) return a ( ) . w2overlay ( ) , void setTimeout ( function ( ) { delete b . tmp . force _hide } , 1 ) ; "" != a ( i ) . val ( ) && delete b . tmp . force _open , 0 == a ( "#w2ui-overlay" ) . length && ( c . index = 0 ) ; var j = w2utils . lang ( "No matches" ) ; null != c . url && a ( i ) . val ( ) . length < c . minLength && b . tmp . emptySet !== ! 0 && ( j = c . minLength + " " + w2utils . lang ( "letters or more..." ) ) , null != c . url && "" == a ( i ) . val ( ) && b . tmp . emptySet !== ! 0 && ( j = w2utils . lang ( "Type to search...." ) ) , a ( h ) . w2menu ( "refresh" , a . extend ( ! 0 , { } , c , { search : ! 1 , render : c . renderDrop , maxHeight : c . maxDropHeight , msgNoItems : j , onSelect : function ( d ) { if ( "enum" == b . type ) { var e = a ( b . el ) . data ( "selected" ) ; if ( d . item ) { var f = b . trigger ( { phase : "before" , type : "add" , target : b . el , originalEvent : d . originalEvent , item : d . item } ) ; if ( f . isCancelled === ! 0 ) return ; e . length >= c . max && c . max > 0 && e . pop ( ) , delete d . item . hidden , e . push ( d . item ) , a ( b . el ) . data ( "selected" , e ) . change ( ) , a ( b . helpers . multi ) . find ( "input" ) . val ( "" ) . width ( 20 ) , b . refresh ( ) , a ( "#w2ui-overlay" ) . length > 0 && a ( "#w2ui-overlay" ) [ 0 ] . hide ( ) , b . trigger ( a . extend ( f , { phase : "after" } ) ) } } else a ( b . el ) . data ( "selected" , d . item ) . val ( d . item . text ) . change ( ) , b . helpers . focus && b . helpers . focus . find ( "input" ) . val ( "" ) } } ) ) } } } , inRange : function ( b ) { var c = ! 1 ; if ( "date" == this . type ) { var d = w2utils . isDate ( b , this . options . format , ! 0 ) ; if ( d ) { if ( this . options . start || this . options . end ) { var e
2016-04-13 00:53:28 +00:00
} if ( "" != c && ( b [ b . length - 1 ] += "\n </div>" ) , this . tabs . tabs ) for ( var h = 0 ; h < this . tabs . tabs . length ; h ++ ) "undefined" == typeof b [ h ] && ( b [ h ] = "" ) ; for ( var i in b ) b [ i ] = '<div class="w2ui-page page-' + i + '">' + b [ i ] + "\n</div>" ; var j = "" ; if ( ! $ . isEmptyObject ( this . actions ) ) { var k = "" ; j += '\n<div class="w2ui-buttons">' ; for ( var l in this . actions ) k = - 1 != [ "save" , "update" , "create" ] . indexOf ( l . toLowerCase ( ) ) ? "btn-green" : "" , j += '\n <button name="' + l + '" class="btn ' + k + '">' + w2utils . lang ( l ) + "</button>" ; j += "\n</div>" } return b . join ( "" ) + j } , action : function ( a , b ) { var c = this . trigger ( { phase : "before" , target : a , type : "action" , originalEvent : b } ) ; c . isCancelled !== ! 0 && ( "function" == typeof this . actions [ a ] && this . actions [ a ] . call ( this , b ) , this . trigger ( $ . extend ( c , { phase : "after" } ) ) ) } , resize : function ( ) { function a ( ) { d . width ( $ ( b . box ) . width ( ) ) . height ( $ ( b . box ) . height ( ) ) , f . css ( "top" , "" != b . header ? w2utils . getSize ( e , "height" ) : 0 ) , g . css ( "top" , ( "" != b . header ? w2utils . getSize ( e , "height" ) : 0 ) + ( "object" == typeof b . toolbar && $ . isArray ( b . toolbar . items ) && b . toolbar . items . length > 0 ? w2utils . getSize ( f , "height" ) : 0 ) ) , h . css ( "top" , ( "" != b . header ? w2utils . getSize ( e , "height" ) : 0 ) + ( "object" == typeof b . toolbar && $ . isArray ( b . toolbar . items ) && b . toolbar . items . length > 0 ? w2utils . getSize ( f , "height" ) + 5 : 0 ) + ( "object" == typeof b . tabs && $ . isArray ( b . tabs . tabs ) && b . tabs . tabs . length > 0 ? w2utils . getSize ( g , "height" ) + 5 : 0 ) ) , h . css ( "bottom" , k . length > 0 ? w2utils . getSize ( k , "height" ) : 0 ) } var b = this , c = this . trigger ( { phase : "before" , target : this . name , type : "resize" } ) ; if ( c . isCancelled !== ! 0 ) { var d = $ ( this . box ) . find ( "> div" ) , e = $ ( this . box ) . find ( "> div .w2ui-form-header" ) , f = $ ( this . box ) . find ( "> div .w2ui-form-toolbar" ) , g = $ ( this . box ) . find ( "> div .w2ui-form-tabs" ) , h = $ ( this . box ) . find ( "> div .w2ui-page" ) , i = $ ( this . box ) . find ( "> div .w2ui-page.page-" + this . page ) , j = $ ( this . box ) . find ( "> div .w2ui-page.page-" + this . page + " > div" ) , k = $ ( this . box ) . find ( "> div .w2ui-buttons" ) ; a ( ) , ( 0 == parseInt ( $ ( this . box ) . height ( ) ) || $ ( this . box ) . data ( "auto-size" ) === ! 0 ) && ( $ ( this . box ) . height ( ( e . length > 0 ? w2utils . getSize ( e , "height" ) : 0 ) + ( "object" == typeof this . tabs && $ . isArray ( this . tabs . tabs ) && this . tabs . tabs . length > 0 ? w2utils . getSize ( g , "height" ) : 0 ) + ( "object" == typeof this . toolbar && $ . isArray ( this . toolbar . items ) && this . toolbar . items . length > 0 ? w2utils . getSize ( f , "height" ) : 0 ) + ( h . length > 0 ? w2utils . getSize ( j , "height" ) + w2utils . getSize ( i , "+height" ) + 12 : 0 ) + ( k . length > 0 ? w2utils . getSize ( k , "height" ) : 0 ) ) , $ ( this . box ) . data ( "auto-size" , ! 0 ) ) , a ( ) , b . trigger ( $ . extend ( c , { phase : "after" } ) ) } } , refresh : function ( ) { var a = ( new Date ) . getTime ( ) , b = this ; if ( this . box && this . isGenerated && "undefined" != typeof $ ( this . box ) . html ( ) ) { $ ( this . box ) . find ( "input, textarea, select" ) . each ( function ( a , c ) { var d = $ ( c ) . attr ( "undefined" != typeof $ ( c ) . attr ( "name" ) ? "name" : "id" ) , e = b . get ( d ) ; if ( e ) { var f = $ ( c ) . parents ( ".w2ui-page" ) ; if ( f . length > 0 ) for ( var g = 0 ; 100 > g ; g ++ ) if ( f . hasClass ( "page-" + g ) ) { e . page = g ; break } } } ) ; var c = this . trigger ( { phase : "before" , target : this . name , type : "refresh" , page : this . page } ) ; if ( c . isCancelled !== ! 0 ) { $ ( this . box ) . find ( ".w2ui-page" ) . hide ( ) , $ ( this . box ) . find ( ".w2ui-page.page-" + this . page ) . show ( ) , $ ( this . box ) . find ( ".w2ui-form-header" ) . html ( this . header ) , "object" == typeof this . tabs && $ . isArray ( this . tabs . tabs ) && this . tabs . tabs . length > 0 ? ( $ ( "#form_" + this . name + "_tabs" ) . show ( ) , this . tabs . active = this . tabs . tabs [ this . page ] . id , this . tabs . refresh ( ) ) : $ ( "#form_" + this . name + "_tabs" ) . hide ( ) , "object" == typeof this . toolbar && $ . isArray ( this . toolbar . items ) && this . toolbar . items . length > 0 ? ( $ ( "#form_" + this . name + "_toolbar" ) . show ( ) , this . toolbar . refresh ( ) ) : $ ( "#form_" + this . name + "_toolbar" ) . hide ( ) ; for ( var d in this . fields ) { var e = this . fields [ d ] ; "undefined" == typeof e . name && "undefined" != typeof e . field && ( e . name = e . field ) , "undefined" == typeof e . field && "undefined" != typeof e . name && ( e . field = e . name ) , e . $el = $ ( this . box ) . find ( '[name="' + String ( e . name ) . replace ( /\\/g , "\\\\" ) + '"]' ) , e . el = e . $el [ 0 ] , "undefined" == typeof e . el && console . log ( 'ERROR: Cannot associate field "' + e . name + '" with html control. Make sure html control exists with the same name.' ) , e . el && ( e . el . id = e . name ) ; var f = $ ( e ) . data ( "w2field" ) ; f && f . clear ( ) , $ ( e . $el ) . off ( "change" ) . on ( "change" , function ( ) { var a = this . value , c = b . record [ this . name ] ? b . record [ this . name ] : "" , d = b . get ( this . na
2016-04-19 03:44:31 +00:00
/ * C o d e M i r r o r - M i n i f i e d & B u n d l e d
2016-04-19 20:49:37 +00:00
Generated on 4 / 19 / 2016 with http : //codemirror.net/doc/compress.html
2016-04-19 03:44:31 +00:00
Version : HEAD
CodeMirror Library :
- codemirror . js
2016-04-19 20:49:37 +00:00
Modes :
- python . js
2016-04-19 03:44:31 +00:00
* /
! function ( a ) { if ( "object" == typeof exports && "object" == typeof module ) module . exports = a ( ) ; else { if ( "function" == typeof define && define . amd ) return define ( [ ] , a ) ; ( this || window ) . CodeMirror = a ( ) } } ( function ( ) { "use strict" ; function y ( a , b ) { if ( ! ( this instanceof y ) ) return new y ( a , b ) ; this . options = b = b ? ng ( b ) : { } , ng ( Ed , b , ! 1 ) , L ( b ) ; var c = b . value ; "string" == typeof c && ( c = new ef ( c , b . mode , null , b . lineSeparator ) ) , this . doc = c ; var d = new y . inputStyles [ b . inputStyle ] ( this ) , e = this . display = new z ( a , c , d ) ; e . wrapper . CodeMirror = this , H ( this ) , F ( this ) , b . lineWrapping && ( this . display . wrapper . className += " CodeMirror-wrap" ) , b . autofocus && ! p && e . input . focus ( ) , P ( this ) , this . state = { keyMaps : [ ] , overlays : [ ] , modeGen : 0 , overwrite : ! 1 , delayingBlurEvent : ! 1 , focused : ! 1 , suppressEdits : ! 1 , pasteIncoming : ! 1 , cutIncoming : ! 1 , selectingText : ! 1 , draggingText : ! 1 , highlight : new cg , keySeq : null , specialChars : null } ; var i = this ; f && 11 > g && setTimeout ( function ( ) { i . display . input . reset ( ! 0 ) } , 20 ) , tc ( this ) , Hg ( ) , Zb ( this ) , this . curOp . forceUpdate = ! 0 , jf ( this , c ) , b . autofocus && ! p || i . hasFocus ( ) ? setTimeout ( og ( bd , this ) , 20 ) : cd ( this ) ; for ( var j in Fd ) Fd . hasOwnProperty ( j ) && Fd [ j ] ( this , b [ j ] , Hd ) ; U ( this ) , b . finishInit && b . finishInit ( this ) ; for ( var k = 0 ; k < Ld . length ; ++ k ) Ld [ k ] ( this ) ; _b ( this ) , h && b . lineWrapping && "optimizelegibility" == getComputedStyle ( e . lineDiv ) . textRendering && ( e . lineDiv . style . textRendering = "auto" ) } function z ( a , b , d ) { var e = this ; this . input = d , e . scrollbarFiller = vg ( "div" , null , "CodeMirror-scrollbar-filler" ) , e . scrollbarFiller . setAttribute ( "cm-not-content" , "true" ) , e . gutterFiller = vg ( "div" , null , "CodeMirror-gutter-filler" ) , e . gutterFiller . setAttribute ( "cm-not-content" , "true" ) , e . lineDiv = vg ( "div" , null , "CodeMirror-code" ) , e . selectionDiv = vg ( "div" , null , null , "position: relative; z-index: 1" ) , e . cursorDiv = vg ( "div" , null , "CodeMirror-cursors" ) , e . measure = vg ( "div" , null , "CodeMirror-measure" ) , e . lineMeasure = vg ( "div" , null , "CodeMirror-measure" ) , e . lineSpace = vg ( "div" , [ e . measure , e . lineMeasure , e . selectionDiv , e . cursorDiv , e . lineDiv ] , null , "position: relative; outline: none" ) , e . mover = vg ( "div" , [ vg ( "div" , [ e . lineSpace ] , "CodeMirror-lines" ) ] , null , "position: relative" ) , e . sizer = vg ( "div" , [ e . mover ] , "CodeMirror-sizer" ) , e . sizerWidth = null , e . heightForcer = vg ( "div" , null , null , "position: absolute; height: " + Zf + "px; width: 1px;" ) , e . gutters = vg ( "div" , null , "CodeMirror-gutters" ) , e . lineGutter = null , e . scroller = vg ( "div" , [ e . sizer , e . heightForcer , e . gutters ] , "CodeMirror-scroll" ) , e . scroller . setAttribute ( "tabIndex" , "-1" ) , e . wrapper = vg ( "div" , [ e . scrollbarFiller , e . gutterFiller , e . scroller ] , "CodeMirror" ) , f && 8 > g && ( e . gutters . style . zIndex = - 1 , e . scroller . style . paddingRight = 0 ) , h || c && p || ( e . scroller . draggable = ! 0 ) , a && ( a . appendChild ? a . appendChild ( e . wrapper ) : a ( e . wrapper ) ) , e . viewFrom = e . viewTo = b . first , e . reportedViewFrom = e . reportedViewTo = b . first , e . view = [ ] , e . renderedView = null , e . externalMeasured = null , e . viewOffset = 0 , e . lastWrapHeight = e . lastWrapWidth = 0 , e . updateLineNumbers = null , e . nativeBarWidth = e . barHeight = e . barWidth = 0 , e . scrollbarsClipped = ! 1 , e . lineNumWidth = e . lineNumInnerWidth = e . lineNumChars = null , e . alignWidgets = ! 1 , e . cachedCharWidth = e . cachedTextHeight = e . cachedPaddingH = null , e . maxLine = null , e . maxLineLength = 0 , e . maxLineChanged = ! 1 , e . wheelDX = e . wheelDY = e . wheelStartX = e . wheelStartY = null , e . shift = ! 1 , e . selForContextMenu = null , e . activeTouch = null , d . init ( e ) } function A ( a ) { a . doc . mode = y . getMode ( a . options , a . doc . modeOption ) , B ( a ) } function B ( a ) { a . doc . iter ( function ( a ) { a . stateAfter && ( a . stateAfter = null ) , a . styles && ( a . styles = null ) } ) , a . doc . frontier = a . doc . first , mb ( a , 100 ) , a . state . modeGen ++ , a . curOp && mc ( a ) } function C ( a ) { a . options . lineWrapping ? ( Dg ( a . display . wrapper , "CodeMirror-wrap" ) , a . display . sizer . style . minWidth = "" , a . display . sizerWidth = null ) : ( Cg ( a . display . wrapper , "CodeMirror-wrap" ) , K ( a ) ) , E ( a ) , mc ( a ) , Jb ( a ) , setTimeout ( function ( ) { Q ( a ) } , 100 ) } function D ( a ) { var b = Vb ( a . display ) , c = a . options . lineWrapping , d = c && Math . max ( 5 , a . display . scroller . clientWidth / Wb ( a . display ) - 3 ) ; return function ( e ) { if ( Ae ( a . doc , e ) ) return 0 ; var f = 0 ; if ( e . widgets ) for ( var g = 0 ; g < e . widgets . length ; g ++ ) e . widgets [ g ] . height && ( f += e . widgets [ g ] . height ) ; return c ? f + ( Math . ceil ( e . text . length / d ) || 1 ) * b : f + b } } function E ( a ) { var b = a . doc , c = D ( a ) ; b . iter ( function ( a ) { var b = c ( a ) ; b != a . height && nf ( a , b ) } ) } function F ( a ) { a . display . wra
e = f - 1 , b >= j && ( g = "right" ) ) , null != e ) { if ( d = a [ h + 2 ] , i == j && c == ( d . insertLeft ? "left" : "right" ) && ( g = c ) , "left" == c && 0 == e ) for ( ; h && a [ h - 2 ] == a [ h - 3 ] && a [ h - 1 ] . insertLeft ; ) d = a [ ( h -= 3 ) + 2 ] , g = "left" ; if ( "right" == c && e == j - i ) for ( ; h < a . length - 3 && a [ h + 3 ] == a [ h + 4 ] && ! a [ h + 5 ] . insertLeft ; ) d = a [ ( h += 3 ) + 2 ] , g = "right" ; break } } return { node : d , start : e , end : f , collapse : g , coverStart : i , coverEnd : j } } function Fb ( a , b , c , d ) { var l , e = Eb ( b . map , c , d ) , h = e . node , i = e . start , j = e . end , k = e . collapse ; if ( 3 == h . nodeType ) { for ( var m = 0 ; 4 > m ; m ++ ) { for ( ; i && ug ( b . line . text . charAt ( e . coverStart + i ) ) ; ) -- i ; for ( ; e . coverStart + j < e . coverEnd && ug ( b . line . text . charAt ( e . coverStart + j ) ) ; ) ++ j ; if ( f && 9 > g && 0 == i && j == e . coverEnd - e . coverStart ) l = h . parentNode . getBoundingClientRect ( ) ; else if ( f && a . options . lineWrapping ) { var n = wg ( h , i , j ) . getClientRects ( ) ; l = n . length ? n [ "right" == d ? n . length - 1 : 0 ] : Db } else l = wg ( h , i , j ) . getBoundingClientRect ( ) || Db ; if ( l . left || l . right || 0 == i ) break ; j = i , i -= 1 , k = "right" } f && 11 > g && ( l = Gb ( a . display . measure , l ) ) } else { i > 0 && ( k = d = "right" ) ; var n ; l = a . options . lineWrapping && ( n = h . getClientRects ( ) ) . length > 1 ? n [ "right" == d ? n . length - 1 : 0 ] : h . getBoundingClientRect ( ) } if ( f && 9 > g && ! i && ( ! l || ! l . left && ! l . right ) ) { var o = h . parentNode . getClientRects ( ) [ 0 ] ; l = o ? { left : o . left , right : o . left + Wb ( a . display ) , top : o . top , bottom : o . bottom } : Db } for ( var p = l . top - b . rect . top , q = l . bottom - b . rect . top , r = ( p + q ) / 2 , s = b . view . measure . heights , m = 0 ; m < s . length - 1 && ! ( r < s [ m ] ) ; m ++ ) ; var t = m ? s [ m - 1 ] : 0 , u = s [ m ] , v = { left : ( "right" == k ? l . right : l . left ) - b . rect . left , right : ( "left" == k ? l . left : l . right ) - b . rect . left , top : t , bottom : u } ; return l . left || l . right || ( v . bogus = ! 0 ) , a . options . singleCursorHeightPerLine || ( v . rtop = p , v . rbottom = q ) , v } function Gb ( a , b ) { if ( ! window . screen || null == screen . logicalXDPI || screen . logicalXDPI == screen . deviceXDPI || ! Sg ( a ) ) return b ; var c = screen . logicalXDPI / screen . deviceXDPI , d = screen . logicalYDPI / screen . deviceYDPI ; return { left : b . left * c , right : b . right * c , top : b . top * d , bottom : b . bottom * d } } function Hb ( a ) { if ( a . measure && ( a . measure . cache = { } , a . measure . heights = null , a . rest ) ) for ( var b = 0 ; b < a . rest . length ; b ++ ) a . measure . caches [ b ] = { } } function Ib ( a ) { a . display . externalMeasure = null , xg ( a . display . lineMeasure ) ; for ( var b = 0 ; b < a . display . view . length ; b ++ ) Hb ( a . display . view [ b ] ) } function Jb ( a ) { Ib ( a ) , a . display . cachedCharWidth = a . display . cachedTextHeight = a . display . cachedPaddingH = null , a . options . lineWrapping || ( a . display . maxLineChanged = ! 0 ) , a . display . lineNumChars = null } function Kb ( ) { return window . pageXOffset || ( document . documentElement || document . body ) . scrollLeft } function Lb ( ) { return window . pageYOffset || ( document . documentElement || document . body ) . scrollTop } function Mb ( a , b , c , d ) { if ( b . widgets ) for ( var e = 0 ; e < b . widgets . length ; ++ e ) if ( b . widgets [ e ] . above ) { var f = Ee ( b . widgets [ e ] ) ; c . top += f , c . bottom += f } if ( "line" == d ) return c ; d || ( d = "local" ) ; var g = qf ( b ) ; if ( "local" == d ? g += qb ( a . display ) : g -= a . display . viewOffset , "page" == d || "window" == d ) { var h = a . display . lineSpace . getBoundingClientRect ( ) ; g += h . top + ( "window" == d ? 0 : Lb ( ) ) ; var i = h . left + ( "window" == d ? 0 : Kb ( ) ) ; c . left += i , c . right += i } return c . top += g , c . bottom += g , c } function Nb ( a , b , c ) { if ( "div" == c ) return b ; var d = b . left , e = b . top ; if ( "page" == c ) d -= Kb ( ) , e -= Lb ( ) ; else if ( "local" == c || ! c ) { var f = a . display . sizer . getBoundingClientRect ( ) ; d += f . left , e += f . top } var g = a . display . lineSpace . getBoundingClientRect ( ) ; return { left : d - g . left , top : e - g . top } } function Ob ( a , b , c , d , e ) { return d || ( d = kf ( a . doc , b . line ) ) , Mb ( a , d , zb ( a , d , b . ch , e ) , c ) } function Pb ( a , b , c , d , e , f ) { function g ( b , g ) { var h = Cb ( a , e , b , g ? "right" : "left" , f ) ; return g ? h . left = h . right : h . right = h . left , Mb ( a , d , h , c ) } function h ( a , b ) { var c = i [ b ] , d = c . level % 2 ; return a == Vg ( c ) && b && c . level < i [ b - 1 ] . level ? ( c = i [ -- b ] , a = Wg ( c ) - ( c . level % 2 ? 0 : 1 ) , d = ! 0 ) : a == Wg ( c ) && b < i . length - 1 && c . level < i [ b + 1 ] . level && ( c = i [ ++ b ] , a = Vg ( c ) - c . level % 2 , d = ! 1 ) , d && a == c . to && a > c . from ? g ( a - 1 ) : g ( a , d ) } d = d || kf ( a . doc , b . line ) , e || ( e = Bb ( a , d ) ) ; var i = rf ( d ) , j = b . ch ; if ( ! i ) return g ( j ) ; var k = ch ( i , j ) , l = h ( j , k ) ; return null != bh && ( l . other = h ( j , bh ) ) , l } function Qb ( a , b ) { var c = 0 , b = Qa ( a . doc , b ) ; a . options . lineWrapping || ( c = Wb ( a . display ) * b . ch ) ; var d = kf ( a . doc , b . line ) , e = qf ( d ) + qb ( a . display ) ; return { left : c , right : c , top : e , bottom : e + d . height } } function Rb ( a , b , c , d ) { var e = ra ( a , b ) ; return e . xRel = d , c && ( e . outside = ! 0 ) , e } function Sb ( a , b , c ) { var d = a . doc ; if ( c += a . display . viewOffset , 0 > c ) return Rb ( d . first , 0 , ! 0 , - 1 ) ; var e = pf ( d , c ) , f = d .
a . curOp . scrollToPos = { from : c , to : d , margin : a . options . cursorScrollMargin , isCursor : ! 0 } } function yd ( a ) { var b = a . curOp . scrollToPos ; if ( b ) { a . curOp . scrollToPos = null ; var c = Qb ( a , b . from ) , d = Qb ( a , b . to ) , e = vd ( a , Math . min ( c . left , d . left ) , Math . min ( c . top , d . top ) - b . margin , Math . max ( c . right , d . right ) , Math . max ( c . bottom , d . bottom ) + b . margin ) ; a . scrollTo ( e . scrollLeft , e . scrollTop ) } } function zd ( a , b , c , d ) { var f , e = a . doc ; null == c && ( c = "add" ) , "smart" == c && ( e . mode . indent ? f = pb ( a , b ) : c = "prev" ) ; var g = a . options . tabSize , h = kf ( e , b ) , i = dg ( h . text , null , g ) ; h . stateAfter && ( h . stateAfter = null ) ; var k , j = h . text . match ( /^\s*/ ) [ 0 ] ; if ( d || /\S/ . test ( h . text ) ) { if ( "smart" == c && ( k = e . mode . indent ( f , h . text . slice ( j . length ) , h . text ) , k == $f || k > 150 ) ) { if ( ! d ) return ; c = "prev" } } else k = 0 , c = "not" ; "prev" == c ? k = b > e . first ? dg ( kf ( e , b - 1 ) . text , null , g ) : 0 : "add" == c ? k = i + a . options . indentUnit : "subtract" == c ? k = i - a . options . indentUnit : "number" == typeof c && ( k = i + c ) , k = Math . max ( 0 , k ) ; var l = "" , m = 0 ; if ( a . options . indentWithTabs ) for ( var n = Math . floor ( k / g ) ; n ; -- n ) m += g , l += " " ; if ( k > m && ( l += gg ( k - m ) ) , l != j ) return rd ( e , l , ra ( b , 0 ) , ra ( b , j . length ) , "+input" ) , h . stateAfter = null , ! 0 ; for ( var n = 0 ; n < e . sel . ranges . length ; n ++ ) { var o = e . sel . ranges [ n ] ; if ( o . head . line == b && o . head . ch < j . length ) { var m = ra ( b , j . length ) ; Xa ( e , n , new Ma ( m , m ) ) ; break } } } function Ad ( a , b , c , d ) { var e = b , f = b ; return "number" == typeof b ? f = kf ( a , Pa ( a , b ) ) : e = of ( b ) , null == e ? null : ( d ( f , e ) && a . cm && nc ( a . cm , e , c ) , f ) } function Bd ( a , b ) { for ( var c = a . doc . sel . ranges , d = [ ] , e = 0 ; e < c . length ; e ++ ) { for ( var f = b ( c [ e ] ) ; d . length && sa ( f . from , hg ( d ) . to ) <= 0 ; ) { var g = d . pop ( ) ; if ( sa ( g . from , f . from ) < 0 ) { f . from = g . from ; break } } d . push ( f ) } gc ( a , function ( ) { for ( var b = d . length - 1 ; b >= 0 ; b -- ) rd ( a . doc , "" , d [ b ] . from , d [ b ] . to , "+delete" ) ; xd ( a ) } ) } function Cd ( a , b , c , d , e ) { function j ( ) { var b = f + c ; return b < a . first || b >= a . first + a . size ? ! 1 : ( f = b , i = kf ( a , b ) ) } function k ( a ) { var b = ( e ? eh : fh ) ( i , g , c , ! 0 ) ; if ( null == b ) { if ( a || ! j ( ) ) return ! 1 ; g = e ? ( 0 > c ? Yg : Xg ) ( i ) : 0 > c ? i . text . length : 0 } else g = b ; return ! 0 } var f = b . line , g = b . ch , h = c , i = kf ( a , f ) ; if ( "char" == d ) k ( ) ; else if ( "column" == d ) k ( ! 0 ) ; else if ( "word" == d || "group" == d ) for ( var l = null , m = "group" == d , n = a . cm && a . cm . getHelper ( b , "wordChars" ) , o = ! 0 ; ! ( 0 > c ) || k ( ! o ) ; o = ! 1 ) { var p = i . text . charAt ( g ) || "\n" , q = rg ( p , n ) ? "w" : m && "\n" == p ? "n" : ! m || /\s/ . test ( p ) ? null : "p" ; if ( ! m || o || q || ( q = "s" ) , l && l != q ) { 0 > c && ( c = 1 , k ( ) ) ; break } if ( q && ( l = q ) , c > 0 && ! k ( ! o ) ) break } var r = fb ( a , ra ( f , g ) , b , h , ! 0 ) ; return sa ( b , r ) || ( r . hitSide = ! 0 ) , r } function Dd ( a , b , c , d ) { var g , e = a . doc , f = b . left ; if ( "page" == d ) { var h = Math . min ( a . display . wrapper . clientHeight , window . innerHeight || document . documentElement . clientHeight ) ; g = b . top + c * ( h - ( 0 > c ? 1.5 : . 5 ) * Vb ( a . display ) ) } else "line" == d && ( g = c > 0 ? b . bottom + 3 : b . top - 3 ) ; for ( ; ; ) { var i = Sb ( a , f , g ) ; if ( ! i . outside ) break ; if ( 0 > c ? 0 >= g : g >= e . height ) { i . hitSide = ! 0 ; break } g += 5 * c } return i } function Gd ( a , b , c , d ) { y . defaults [ a ] = b , c && ( Fd [ a ] = d ? function ( a , b , d ) { d != Hd && c ( a , b , d ) } : c ) } function Rd ( a ) { for ( var c , d , e , f , b = a . split ( /-(?!$)/ ) , a = b [ b . length - 1 ] , g = 0 ; g < b . length - 1 ; g ++ ) { var h = b [ g ] ; if ( /^(cmd|meta|m)$/i . test ( h ) ) f = ! 0 ; else if ( /^a(lt)?$/i . test ( h ) ) c = ! 0 ; else if ( /^(c|ctrl|control)$/i . test ( h ) ) d = ! 0 ; else { if ( ! /^s(hift)$/i . test ( h ) ) throw new Error ( "Unrecognized modifier name: " + h ) ; e = ! 0 } } return c && ( a = "Alt-" + a ) , d && ( a = "Ctrl-" + a ) , f && ( a = "Cmd-" + a ) , e && ( a = "Shift-" + a ) , a } function Vd ( a ) { return "string" == typeof a ? Qd [ a ] : a } function Zd ( a , b , c , d , e ) { if ( d && d . shared ) return _d ( a , b , c , d , e ) ; if ( a . cm && ! a . cm . curOp ) return hc ( a . cm , Zd ) ( a , b , c , d , e ) ; var f = new Yd ( a , e ) , g = sa ( b , c ) ; if ( d && ng ( d , f , ! 1 ) , g > 0 || 0 == g && f . clearWhenEmpty !== ! 1 ) return f ; if ( f . replacedWith && ( f . collapsed = ! 0 , f . widgetNode = vg ( "span" , [ f . replacedWith ] , "CodeMirror-widget" ) , d . handleMouseEvents || f . widgetNode . setAttribute ( "cm-ignore-events" , "true" ) , d . insertLeft && ( f . widgetNode . insertLeft = ! 0 ) ) , f . collapsed ) { if ( ve ( a , b . line , b , c , f ) || b . line != c . line && ve ( a , c . line , b , c , f ) ) throw new Error ( "Inserting collapsed marker partially overlapping an existing one" ) ; x = ! 0 } f . addToHistory && wf ( a , { from : b , to : c , origin : "markText" } , a . sel , NaN ) ; var j , h = b . line , i = a . cm ; if ( a . iter ( h , c . line + 1 , function ( a ) { i && f . collapsed && ! i . options . lineWrapping && we ( a ) == i . display . maxLine && ( j = ! 0 ) , f . collapsed && h != b . line && nf ( a , 0 ) , ge ( a , new de ( f , h == b . line ? b . ch : null , h == c . line ? c . ch : null ) ) , ++ h } ) , f . collapsed && a . iter ( b . line , c . line + 1 , function ( b ) { Ae ( a , b ) && nf ( b , 0 ) } ) , f . clearOnEnter && Nf ( f , " beforeCursorEnter
for ( var a = 0 ; a < this . events . length ; a ++ ) Rf . apply ( null , this . events [ a ] ) } ; var ra = y . Pos = function ( a , b ) { return this instanceof ra ? ( this . line = a , void ( this . ch = b ) ) : new ra ( a , b ) } , sa = y . cmpPos = function ( a , b ) { return a . line - b . line || a . ch - b . ch } , xa = null ; Da . prototype = ng ( { init : function ( a ) { function h ( a ) { if ( ! Vf ( c , a ) ) { if ( c . somethingSelected ( ) ) xa = c . getSelections ( ) , b . inaccurateSelection && ( b . prevInput = "" , b . inaccurateSelection = ! 1 , e . value = xa . join ( "\n" ) , ig ( e ) ) ; else { if ( ! c . options . lineWiseCopyCut ) return ; var d = Ba ( c ) ; xa = d . text , "cut" == a . type ? c . setSelections ( d . ranges , null , _f ) : ( b . prevInput = "" , e . value = d . text . join ( "\n" ) , ig ( e ) ) } "cut" == a . type && ( c . state . cutIncoming = ! 0 ) } } var b = this , c = this . cm , d = this . wrapper = Ea ( ) , e = this . textarea = d . firstChild ; a . wrapper . insertBefore ( d , a . wrapper . firstChild ) , o && ( e . style . width = "0px" ) , Nf ( e , "input" , function ( ) { f && g >= 9 && b . hasSelection && ( b . hasSelection = null ) , b . poll ( ) } ) , Nf ( e , "paste" , function ( a ) { Vf ( c , a ) || za ( a , c ) || ( c . state . pasteIncoming = ! 0 , b . fastPoll ( ) ) } ) , Nf ( e , "cut" , h ) , Nf ( e , "copy" , h ) , Nf ( a . scroller , "paste" , function ( d ) { wc ( a , d ) || Vf ( c , d ) || ( c . state . pasteIncoming = ! 0 , b . focus ( ) ) } ) , Nf ( a . lineSpace , "selectstart" , function ( b ) { wc ( a , b ) || Hf ( b ) } ) , Nf ( e , "compositionstart" , function ( ) { var a = c . getCursor ( "from" ) ; b . composing && b . composing . range . clear ( ) , b . composing = { start : a , range : c . markText ( a , c . getCursor ( "to" ) , { className : "CodeMirror-composing" } ) } } ) , Nf ( e , "compositionend" , function ( ) { b . composing && ( b . poll ( ) , b . composing . range . clear ( ) , b . composing = null ) } ) } , prepareSelection : function ( ) { var a = this . cm , b = a . display , c = a . doc , d = ib ( a ) ; if ( a . options . moveInputWithCursor ) { var e = Pb ( a , c . sel . primary ( ) . head , "div" ) , f = b . wrapper . getBoundingClientRect ( ) , g = b . lineDiv . getBoundingClientRect ( ) ; d . teTop = Math . max ( 0 , Math . min ( b . wrapper . clientHeight - 10 , e . top + g . top - f . top ) ) , d . teLeft = Math . max ( 0 , Math . min ( b . wrapper . clientWidth - 10 , e . left + g . left - f . left ) ) } return d } , showSelection : function ( a ) { var b = this . cm , c = b . display ; yg ( c . cursorDiv , a . cursors ) , yg ( c . selectionDiv , a . selection ) , null != a . teTop && ( this . wrapper . style . top = a . teTop + "px" , this . wrapper . style . left = a . teLeft + "px" ) } , reset : function ( a ) { if ( ! this . contextMenuPending ) { var b , c , d = this . cm , e = d . doc ; if ( d . somethingSelected ( ) ) { this . prevInput = "" ; var h = e . sel . primary ( ) ; b = Qg && ( h . to ( ) . line - h . from ( ) . line > 100 || ( c = d . getSelection ( ) ) . length > 1e3 ) ; var i = b ? "-" : c || d . getSelection ( ) ; this . textarea . value = i , d . state . focused && ig ( this . textarea ) , f && g >= 9 && ( this . hasSelection = i ) } else a || ( this . prevInput = this . textarea . value = "" , f && g >= 9 && ( this . hasSelection = null ) ) ; this . inaccurateSelection = b } } , getField : function ( ) { return this . textarea } , supportsTouch : function ( ) { return ! 1 } , focus : function ( ) { if ( "nocursor" != this . cm . options . readOnly && ( ! p || Ag ( ) != this . textarea ) ) try { this . textarea . focus ( ) } catch ( a ) { } } , blur : function ( ) { this . textarea . blur ( ) } , resetPosition : function ( ) { this . wrapper . style . top = this . wrapper . style . left = 0 } , receivedFocus : function ( ) { this . slowPoll ( ) } , slowPoll : function ( ) { var a = this ; a . pollingFast || a . polling . set ( this . cm . options . pollInterval , function ( ) { a . poll ( ) , a . cm . state . focused && a . slowPoll ( ) } ) } , fastPoll : function ( ) { function c ( ) { var d = b . poll ( ) ; d || a ? ( b . pollingFast = ! 1 , b . slowPoll ( ) ) : ( a = ! 0 , b . polling . set ( 60 , c ) ) } var a = ! 1 , b = this ; b . pollingFast = ! 0 , b . polling . set ( 20 , c ) } , poll : function ( ) { var a = this . cm , b = this . textarea , c = this . prevInput ; if ( this . contextMenuPending || ! a . state . focused || Pg ( b ) && ! c && ! this . composing || a . isReadOnly ( ) || a . options . disableInput || a . state . keySeq ) return ! 1 ; var d = b . value ; if ( d == c && ! a . somethingSelected ( ) ) return ! 1 ; if ( f && g >= 9 && this . hasSelection === d || q && /[\uf700-\uf7ff]/ . test ( d ) ) return a . display . input . reset ( ) , ! 1 ; if ( a . doc . sel == a . display . selForContextMenu ) { var e = d . charCodeAt ( 0 ) ; if ( 8203 != e || c || ( c = "\u200b" ) , 8666 == e ) return this . reset ( ) , this . cm . execCommand ( "undo" ) } for ( var h = 0 , i = Math . min ( c . length , d . length ) ; i > h && c . charCodeAt ( h ) == d . charCodeAt ( h ) ; ) ++ h ; var j = this ; return gc ( a , function ( ) { ya ( a , d . slice ( h ) , c . length - h , null , j . composing ? "*compose" : null ) , d . length > 1e3 || d . indexOf ( "\n" ) > - 1 ? b . value = j . prevInput = "" : j . prevInput = d , j . composing && ( j . composing . range . clear ( ) , j . composing . range = a . markText ( j . composing . start , a . getCursor ( "to" ) , { className : "CodeMirror-composing" } ) ) } ) , ! 0 } , ensurePolled : function ( ) { this . pollingFast && this . poll ( ) && ( this . pollingFast = ! 1 ) } , onKeyPress : fu
2016-04-19 20:49:37 +00:00
} , Qd . pcDefault = { "Ctrl-A" : "selectAll" , "Ctrl-D" : "deleteLine" , "Ctrl-Z" : "undo" , "Shift-Ctrl-Z" : "redo" , "Ctrl-Y" : "redo" , "Ctrl-Home" : "goDocStart" , "Ctrl-End" : "goDocEnd" , "Ctrl-Up" : "goLineUp" , "Ctrl-Down" : "goLineDown" , "Ctrl-Left" : "goGroupLeft" , "Ctrl-Right" : "goGroupRight" , "Alt-Left" : "goLineStart" , "Alt-Right" : "goLineEnd" , "Ctrl-Backspace" : "delGroupBefore" , "Ctrl-Delete" : "delGroupAfter" , "Ctrl-S" : "save" , "Ctrl-F" : "find" , "Ctrl-G" : "findNext" , "Shift-Ctrl-G" : "findPrev" , "Shift-Ctrl-F" : "replace" , "Shift-Ctrl-R" : "replaceAll" , "Ctrl-[" : "indentLess" , "Ctrl-]" : "indentMore" , "Ctrl-U" : "undoSelection" , "Shift-Ctrl-U" : "redoSelection" , "Alt-U" : "redoSelection" , fallthrough : "basic" } , Qd . emacsy = { "Ctrl-F" : "goCharRight" , "Ctrl-B" : "goCharLeft" , "Ctrl-P" : "goLineUp" , "Ctrl-N" : "goLineDown" , "Alt-F" : "goWordRight" , "Alt-B" : "goWordLeft" , "Ctrl-A" : "goLineStart" , "Ctrl-E" : "goLineEnd" , "Ctrl-V" : "goPageDown" , "Shift-Ctrl-V" : "goPageUp" , "Ctrl-D" : "delCharAfter" , "Ctrl-H" : "delCharBefore" , "Alt-D" : "delWordAfter" , "Alt-Backspace" : "delWordBefore" , "Ctrl-K" : "killLine" , "Ctrl-T" : "transposeChars" } , Qd . macDefault = { "Cmd-A" : "selectAll" , "Cmd-D" : "deleteLine" , "Cmd-Z" : "undo" , "Shift-Cmd-Z" : "redo" , "Cmd-Y" : "redo" , "Cmd-Home" : "goDocStart" , "Cmd-Up" : "goDocStart" , "Cmd-End" : "goDocEnd" , "Cmd-Down" : "goDocEnd" , "Alt-Left" : "goGroupLeft" , "Alt-Right" : "goGroupRight" , "Cmd-Left" : "goLineLeft" , "Cmd-Right" : "goLineRight" , "Alt-Backspace" : "delGroupBefore" , "Ctrl-Alt-Backspace" : "delGroupAfter" , "Alt-Delete" : "delGroupAfter" , "Cmd-S" : "save" , "Cmd-F" : "find" , "Cmd-G" : "findNext" , "Shift-Cmd-G" : "findPrev" , "Cmd-Alt-F" : "replace" , "Shift-Cmd-Alt-F" : "replaceAll" , "Cmd-[" : "indentLess" , "Cmd-]" : "indentMore" , "Cmd-Backspace" : "delWrappedLineLeft" , "Cmd-Delete" : "delWrappedLineRight" , "Cmd-U" : "undoSelection" , "Shift-Cmd-U" : "redoSelection" , "Ctrl-Up" : "goDocStart" , "Ctrl-Down" : "goDocEnd" , fallthrough : [ "basic" , "emacsy" ] } , Qd [ "default" ] = q ? Qd . macDefault : Qd . pcDefault , y . normalizeKeyMap = function ( a ) { var b = { } ; for ( var c in a ) if ( a . hasOwnProperty ( c ) ) { var d = a [ c ] ; if ( /^(name|fallthrough|(de|at)tach)$/ . test ( c ) ) continue ; if ( "..." == d ) { delete a [ c ] ; continue } for ( var e = kg ( c . split ( " " ) , Rd ) , f = 0 ; f < e . length ; f ++ ) { var g , h ; f == e . length - 1 ? ( h = e . join ( " " ) , g = d ) : ( h = e . slice ( 0 , f + 1 ) . join ( " " ) , g = "..." ) ; var i = b [ h ] ; if ( i ) { if ( i != g ) throw new Error ( "Inconsistent bindings for " + h ) } else b [ h ] = g } delete a [ c ] } for ( var j in b ) a [ j ] = b [ j ] ; return a } ; var Sd = y . lookupKey = function ( a , b , c , d ) { b = Vd ( b ) ; var e = b . call ? b . call ( a , d ) : b [ a ] ; if ( e === ! 1 ) return "nothing" ; if ( "..." === e ) return "multi" ; if ( null != e && c ( e ) ) return "handled" ; if ( b . fallthrough ) { if ( "[object Array]" != Object . prototype . toString . call ( b . fallthrough ) ) return Sd ( a , b . fallthrough , c , d ) ; for ( var f = 0 ; f < b . fallthrough . length ; f ++ ) { var g = Sd ( a , b . fallthrough [ f ] , c , d ) ; if ( g ) return g } } } , Td = y . isModifierKey = function ( a ) { var b = "string" == typeof a ? a : Tg [ a . keyCode ] ; return "Ctrl" == b || "Alt" == b || "Shift" == b || "Mod" == b } , Ud = y . keyName = function ( a , b ) { if ( k && 34 == a . keyCode && a [ "char" ] ) return ! 1 ; var c = Tg [ a . keyCode ] , d = c ; return null == d || a . altGraphKey ? ! 1 : ( a . altKey && "Alt" != c && ( d = "Alt-" + d ) , ( u ? a . metaKey : a . ctrlKey ) && "Ctrl" != c && ( d = "Ctrl-" + d ) , ( u ? a . ctrlKey : a . metaKey ) && "Cmd" != c && ( d = "Cmd-" + d ) , ! b && a . shiftKey && "Shift" != c && ( d = "Shift-" + d ) , d ) } ; y . fromTextArea = function ( a , b ) { function d ( ) { a . value = i . getValue ( ) } if ( b = b ? ng ( b ) : { } , b . value = a . value , ! b . tabindex && a . tabIndex && ( b . tabindex = a . tabIndex ) , ! b . placeholder && a . placeholder && ( b . placeholder = a . placeholder ) , null == b . autofocus ) { var c = Ag ( ) ; b . autofocus = c == a || null != a . getAttribute ( "autofocus" ) && c == document . body } if ( a . form && ( Nf ( a . form , "submit" , d ) , ! b . leaveSubmitMethodAlone ) ) { var e = a . form , f = e . submit ; try { var g = e . submit = function ( ) { d ( ) , e . submit = f , e . submit ( ) , e . submit = g } } catch ( h ) { } } b . finishInit = function ( b ) { b . save = d , b . getTextArea = function ( ) { return a } , b . toTextArea = function ( ) { b . toTextArea = isNaN , d ( ) , a . parentNode . removeChild ( b . getWrapperElement ( ) ) , a . style . display = "" , a . form && ( Qf ( a . form , "submit" , d ) , "function" == typeof a . form . submit && ( a . form . submit = f ) ) } } , a . style . display = "none" ; var i = y ( function ( b ) { a . parentNode . insertBefore ( b , a . nextSibling ) } , b ) ; return i } ; var Wd = y . StringStream = function ( a , b ) { this . pos = this . start = 0 , this . string = a , this . tabSize = b || 8 , this . lastColumnPos = this . lastColumnValue = 0 , this . lineStart = 0 } ; Wd . prototype = { eol : function ( ) { r
} else { s = s . concat ( f . keywords ) , t = t . concat ( f . builtins ) ; var u = new RegExp ( "^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))" , "i" ) } var v = b ( s ) , w = b ( t ) , E = { startState : function ( a ) { return { tokenize : x , scopes : [ { offset : a || 0 , type : "py" , align : null } ] , indent : a || 0 , lastToken : null , lambda : ! 1 , dedent : 0 } } , token : function ( a , b ) { var c = b . errorToken ; c && ( b . errorToken = ! 1 ) ; var d = D ( a , b ) ; return d && "comment" != d && ( b . lastToken = "keyword" == d || "punctuation" == d ? a . current ( ) : d ) , "punctuation" == d && ( d = null ) , a . eol ( ) && b . lambda && ( b . lambda = ! 1 ) , c ? d + " " + k : d } , indent : function ( b , c ) { if ( b . tokenize != x ) return b . tokenize . isString ? a . Pass : 0 ; var d = h ( b ) , e = d . type == c . charAt ( 0 ) ; return null != d . align ? d . align - ( e ? 1 : 0 ) : d . offset - ( e ? r : 0 ) } , electricInput : /^\s*[\}\]\)]$/ , closeBrackets : { triples : "'\"" } , lineComment : "#" , fold : "indent" } ; return E } ) , a . defineMIME ( "text/x-python" , "python" ) ; var i = function ( a ) { return a . split ( " " ) } ; a . defineMIME ( "text/x-cython" , { name : "python" , extra _keywords : i ( "by cdef cimport cpdef ctypedef enum exceptextern gil include nogil property publicreadonly struct union DEF IF ELIF ELSE" ) } ) } ) ;
2016-04-13 02:18:37 +00:00
//! moment.js
//! version : 2.12.0
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
//! license : MIT
//! momentjs.com
! function ( a , b ) { "object" == typeof exports && "undefined" != typeof module ? module . exports = b ( ) : "function" == typeof define && define . amd ? define ( b ) : a . moment = b ( ) } ( this , function ( ) { "use strict" ; function a ( ) { return Zc . apply ( null , arguments ) } function b ( a ) { Zc = a } function c ( a ) { return a instanceof Array || "[object Array]" === Object . prototype . toString . call ( a ) } function d ( a ) { return a instanceof Date || "[object Date]" === Object . prototype . toString . call ( a ) } function e ( a , b ) { var c , d = [ ] ; for ( c = 0 ; c < a . length ; ++ c ) d . push ( b ( a [ c ] , c ) ) ; return d } function f ( a , b ) { return Object . prototype . hasOwnProperty . call ( a , b ) } function g ( a , b ) { for ( var c in b ) f ( b , c ) && ( a [ c ] = b [ c ] ) ; return f ( b , "toString" ) && ( a . toString = b . toString ) , f ( b , "valueOf" ) && ( a . valueOf = b . valueOf ) , a } function h ( a , b , c , d ) { return Ia ( a , b , c , d , ! 0 ) . utc ( ) } function i ( ) { return { empty : ! 1 , unusedTokens : [ ] , unusedInput : [ ] , overflow : - 2 , charsLeftOver : 0 , nullInput : ! 1 , invalidMonth : null , invalidFormat : ! 1 , userInvalidated : ! 1 , iso : ! 1 } } function j ( a ) { return null == a . _pf && ( a . _pf = i ( ) ) , a . _pf } function k ( a ) { if ( null == a . _isValid ) { var b = j ( a ) ; a . _isValid = ! ( isNaN ( a . _d . getTime ( ) ) || ! ( b . overflow < 0 ) || b . empty || b . invalidMonth || b . invalidWeekday || b . nullInput || b . invalidFormat || b . userInvalidated ) , a . _strict && ( a . _isValid = a . _isValid && 0 === b . charsLeftOver && 0 === b . unusedTokens . length && void 0 === b . bigHour ) } return a . _isValid } function l ( a ) { var b = h ( NaN ) ; return null != a ? g ( j ( b ) , a ) : j ( b ) . userInvalidated = ! 0 , b } function m ( a ) { return void 0 === a } function n ( a , b ) { var c , d , e ; if ( m ( b . _isAMomentObject ) || ( a . _isAMomentObject = b . _isAMomentObject ) , m ( b . _i ) || ( a . _i = b . _i ) , m ( b . _f ) || ( a . _f = b . _f ) , m ( b . _l ) || ( a . _l = b . _l ) , m ( b . _strict ) || ( a . _strict = b . _strict ) , m ( b . _tzm ) || ( a . _tzm = b . _tzm ) , m ( b . _isUTC ) || ( a . _isUTC = b . _isUTC ) , m ( b . _offset ) || ( a . _offset = b . _offset ) , m ( b . _pf ) || ( a . _pf = j ( b ) ) , m ( b . _locale ) || ( a . _locale = b . _locale ) , $c . length > 0 ) for ( c in $c ) d = $c [ c ] , e = b [ d ] , m ( e ) || ( a [ d ] = e ) ; return a } function o ( b ) { n ( this , b ) , this . _d = new Date ( null != b . _d ? b . _d . getTime ( ) : NaN ) , _c === ! 1 && ( _c = ! 0 , a . updateOffset ( this ) , _c = ! 1 ) } function p ( a ) { return a instanceof o || null != a && null != a . _isAMomentObject } function q ( a ) { return 0 > a ? Math . ceil ( a ) : Math . floor ( a ) } function r ( a ) { var b = + a , c = 0 ; return 0 !== b && isFinite ( b ) && ( c = q ( b ) ) , c } function s ( a , b , c ) { var d , e = Math . min ( a . length , b . length ) , f = Math . abs ( a . length - b . length ) , g = 0 ; for ( d = 0 ; e > d ; d ++ ) ( c && a [ d ] !== b [ d ] || ! c && r ( a [ d ] ) !== r ( b [ d ] ) ) && g ++ ; return g + f } function t ( b ) { a . suppressDeprecationWarnings === ! 1 && "undefined" != typeof console && console . warn && console . warn ( "Deprecation warning: " + b ) } function u ( a , b ) { var c = ! 0 ; return g ( function ( ) { return c && ( t ( a + "\nArguments: " + Array . prototype . slice . call ( arguments ) . join ( ", " ) + "\n" + ( new Error ) . stack ) , c = ! 1 ) , b . apply ( this , arguments ) } , b ) } function v ( a , b ) { ad [ a ] || ( t ( b ) , ad [ a ] = ! 0 ) } function w ( a ) { return a instanceof Function || "[object Function]" === Object . prototype . toString . call ( a ) } function x ( a ) { return "[object Object]" === Object . prototype . toString . call ( a ) } function y ( a ) { var b , c ; for ( c in a ) b = a [ c ] , w ( b ) ? this [ c ] = b : this [ "_" + c ] = b ; this . _config = a , this . _ordinalParseLenient = new RegExp ( this . _ordinalParse . source + "|" + /\d{1,2}/ . source ) } function z ( a , b ) { var c , d = g ( { } , a ) ; for ( c in b ) f ( b , c ) && ( x ( a [ c ] ) && x ( b [ c ] ) ? ( d [ c ] = { } , g ( d [ c ] , a [ c ] ) , g ( d [ c ] , b [ c ] ) ) : null != b [ c ] ? d [ c ] = b [ c ] : delete d [ c ] ) ; return d } function A ( a ) { null != a && this . set ( a ) } function B ( a ) { return a ? a . toLowerCase ( ) . replace ( "_" , "-" ) : a } function C ( a ) { for ( var b , c , d , e , f = 0 ; f < a . length ; ) { for ( e = B ( a [ f ] ) . split ( "-" ) , b = e . length , c = B ( a [ f + 1 ] ) , c = c ? c . split ( "-" ) : null ; b > 0 ; ) { if ( d = D ( e . slice ( 0 , b ) . join ( "-" ) ) ) return d ; if ( c && c . length >= b && s ( e , c , ! 0 ) >= b - 1 ) break ; b -- } f ++ } return null } function D ( a ) { var b = null ; if ( ! cd [ a ] && "undefined" != typeof module && module && module . exports ) try { b = bd . _abbr , require ( "./locale/" + a ) , E ( b ) } catch ( c ) { } return cd [ a ] } function E ( a , b ) { var c ; return a && ( c = m ( b ) ? H ( a ) : F ( a , b ) , c && ( bd = c ) ) , bd . _abbr } function F ( a , b ) { return null !== b ? ( b . abbr = a , null != cd [ a ] ? ( v ( "defineLocaleOverride" , "use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale" ) , b = z ( cd [ a ] . _config , b ) ) : null != b . parentLocale && ( null != cd [ b . parentLocale ] ? b = z ( cd [ b . parentLocale ] . _config , b ) : v ( "parentLocaleUndefined" , "specified parentLocale is not defined yet" ) ) , cd [ a ] = new A ( b ) , E ( a ) , cd
} ) , $ ( "YY" , function ( b , c ) { c [ Bd ] = a . parseTwoDigitYear ( b ) } ) , $ ( "Y" , function ( a , b ) { b [ Bd ] = parseInt ( a , 10 ) } ) , a . parseTwoDigitYear = function ( a ) { return r ( a ) + ( r ( a ) > 68 ? 1900 : 2e3 ) } ; var Vd = M ( "FullYear" , ! 1 ) ; a . ISO _8601 = function ( ) { } ; var Wd = u ( "moment().min is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548" , function ( ) { var a = Ja . apply ( null , arguments ) ; return this . isValid ( ) && a . isValid ( ) ? this > a ? this : a : l ( ) } ) , Xd = u ( "moment().max is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548" , function ( ) { var a = Ja . apply ( null , arguments ) ; return this . isValid ( ) && a . isValid ( ) ? a > this ? this : a : l ( ) } ) , Yd = function ( ) { return Date . now ? Date . now ( ) : + new Date } ; Pa ( "Z" , ":" ) , Pa ( "ZZ" , "" ) , W ( "Z" , wd ) , W ( "ZZ" , wd ) , $ ( [ "Z" , "ZZ" ] , function ( a , b , c ) { c . _useUTC = ! 0 , c . _tzm = Qa ( wd , a ) } ) ; var Zd = /([\+\-]|\d\d)/gi ; a . updateOffset = function ( ) { } ; var $d = /^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?\d*)?$/ , _d = /^(-)?P(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)W)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?$/ ; cb . fn = Na . prototype ; var ae = hb ( 1 , "add" ) , be = hb ( - 1 , "subtract" ) ; a . defaultFormat = "YYYY-MM-DDTHH:mm:ssZ" ; var ce = u ( "moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages." , function ( a ) { return void 0 === a ? this . localeData ( ) : this . locale ( a ) } ) ; R ( 0 , [ "gg" , 2 ] , 0 , function ( ) { return this . weekYear ( ) % 100 } ) , R ( 0 , [ "GG" , 2 ] , 0 , function ( ) { return this . isoWeekYear ( ) % 100 } ) , Ob ( "gggg" , "weekYear" ) , Ob ( "ggggg" , "weekYear" ) , Ob ( "GGGG" , "isoWeekYear" ) , Ob ( "GGGGG" , "isoWeekYear" ) , J ( "weekYear" , "gg" ) , J ( "isoWeekYear" , "GG" ) , W ( "G" , ud ) , W ( "g" , ud ) , W ( "GG" , nd , jd ) , W ( "gg" , nd , jd ) , W ( "GGGG" , rd , ld ) , W ( "gggg" , rd , ld ) , W ( "GGGGG" , sd , md ) , W ( "ggggg" , sd , md ) , _ ( [ "gggg" , "ggggg" , "GGGG" , "GGGGG" ] , function ( a , b , c , d ) { b [ d . substr ( 0 , 2 ) ] = r ( a ) } ) , _ ( [ "gg" , "GG" ] , function ( b , c , d , e ) { c [ e ] = a . parseTwoDigitYear ( b ) } ) , R ( "Q" , 0 , "Qo" , "quarter" ) , J ( "quarter" , "Q" ) , W ( "Q" , id ) , $ ( "Q" , function ( a , b ) { b [ Cd ] = 3 * ( r ( a ) - 1 ) } ) , R ( "w" , [ "ww" , 2 ] , "wo" , "week" ) , R ( "W" , [ "WW" , 2 ] , "Wo" , "isoWeek" ) , J ( "week" , "w" ) , J ( "isoWeek" , "W" ) , W ( "w" , nd ) , W ( "ww" , nd , jd ) , W ( "W" , nd ) , W ( "WW" , nd , jd ) , _ ( [ "w" , "ww" , "W" , "WW" ] , function ( a , b , c , d ) { b [ d . substr ( 0 , 1 ) ] = r ( a ) } ) ; var de = { dow : 0 , doy : 6 } ; R ( "D" , [ "DD" , 2 ] , "Do" , "date" ) , J ( "date" , "D" ) , W ( "D" , nd ) , W ( "DD" , nd , jd ) , W ( "Do" , function ( a , b ) { return a ? b . _ordinalParse : b . _ordinalParseLenient } ) , $ ( [ "D" , "DD" ] , Dd ) , $ ( "Do" , function ( a , b ) { b [ Dd ] = r ( a . match ( nd ) [ 0 ] , 10 ) } ) ; var ee = M ( "Date" , ! 0 ) ; R ( "d" , 0 , "do" , "day" ) , R ( "dd" , 0 , 0 , function ( a ) { return this . localeData ( ) . weekdaysMin ( this , a ) } ) , R ( "ddd" , 0 , 0 , function ( a ) { return this . localeData ( ) . weekdaysShort ( this , a ) } ) , R ( "dddd" , 0 , 0 , function ( a ) { return this . localeData ( ) . weekdays ( this , a ) } ) , R ( "e" , 0 , 0 , "weekday" ) , R ( "E" , 0 , 0 , "isoWeekday" ) , J ( "day" , "d" ) , J ( "weekday" , "e" ) , J ( "isoWeekday" , "E" ) , W ( "d" , nd ) , W ( "e" , nd ) , W ( "E" , nd ) , W ( "dd" , yd ) , W ( "ddd" , yd ) , W ( "dddd" , yd ) , _ ( [ "dd" , "ddd" , "dddd" ] , function ( a , b , c , d ) { var e = c . _locale . weekdaysParse ( a , d , c . _strict ) ; null != e ? b . d = e : j ( c ) . invalidWeekday = a } ) , _ ( [ "d" , "e" , "E" ] , function ( a , b , c , d ) { b [ d ] = r ( a ) } ) ; var fe = "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday" . split ( "_" ) , ge = "Sun_Mon_Tue_Wed_Thu_Fri_Sat" . split ( "_" ) , he = "Su_Mo_Tu_We_Th_Fr_Sa" . split ( "_" ) ; R ( "DDD" , [ "DDDD" , 3 ] , "DDDo" , "dayOfYear" ) , J ( "dayOfYear" , "DDD" ) , W ( "DDD" , qd ) , W ( "DDDD" , kd ) , $ ( [ "DDD" , "DDDD" ] , function ( a , b , c ) { c . _dayOfYear = r ( a ) } ) , R ( "H" , [ "HH" , 2 ] , 0 , "hour" ) , R ( "h" , [ "hh" , 2 ] , 0 , ic ) , R ( "hmm" , 0 , 0 , function ( ) { return "" + ic . apply ( this ) + Q ( this . minutes ( ) , 2 ) } ) , R ( "hmmss" , 0 , 0 , function ( ) { return "" + ic . apply ( this ) + Q ( this . minutes ( ) , 2 ) + Q ( this . seconds ( ) , 2 ) } ) , R ( "Hmm" , 0 , 0 , function ( ) { return "" + this . hours ( ) + Q ( this . minutes ( ) , 2 ) } ) , R ( "Hmmss" , 0 , 0 , function ( ) { return "" + this . hours ( ) + Q ( this . minutes ( ) , 2 ) + Q ( this . seconds ( ) , 2 ) } ) , jc ( "a" , ! 0 ) , jc ( "A" , ! 1 ) , J ( "hour" , "h" ) , W ( "a" , kc ) , W ( "A" , kc ) , W ( "H" , nd ) , W ( "h" , nd ) , W ( "HH" , nd , jd ) , W ( "hh" , nd , jd ) , W ( "hmm" , od ) , W ( "hmmss" , pd ) , W ( "Hmm" , od ) , W ( "Hmmss" , pd ) , $ ( [ "H" , "HH" ] , Ed ) , $ ( [ "a" , "A" ] , function ( a , b , c ) { c . _isPm = c . _locale . isPM ( a ) , c . _meridiem = a } ) , $ ( [ "h" , "hh" ] , function ( a , b , c ) { b [ Ed ] = r ( a ) , j ( c ) . bigHour = ! 0 } ) , $ ( "hmm" , function ( a , b , c ) { var d = a . length - 2 ; b [ Ed ] = r ( a . substr ( 0 , d ) ) , b [ Fd ] = r ( a . substr ( d ) ) , j ( c ) . bigHour = ! 0 } ) , $ ( "hmmss" , function ( a , b , c ) { var d = a . length - 4 , e = a . length - 2 ; b [ Ed ] = r ( a . substr ( 0 , d ) ) , b [ Fd ] = r ( a
2016-04-13 04:45:40 +00:00
; ( function ( window , undefined ) {
"use strict"
var _valueRanges = {
rgb : { r : [ 0 , 255 ] , g : [ 0 , 255 ] , b : [ 0 , 255 ] } ,
hsv : { h : [ 0 , 360 ] , s : [ 0 , 100 ] , v : [ 0 , 100 ] } ,
hsl : { h : [ 0 , 360 ] , s : [ 0 , 100 ] , l : [ 0 , 100 ] } ,
cmy : { c : [ 0 , 100 ] , m : [ 0 , 100 ] , y : [ 0 , 100 ] } ,
cmyk : { c : [ 0 , 100 ] , m : [ 0 , 100 ] , y : [ 0 , 100 ] , k : [ 0 , 100 ] } ,
Lab : { L : [ 0 , 100 ] , a : [ - 128 , 127 ] , b : [ - 128 , 127 ] } ,
XYZ : { X : [ 0 , 100 ] , Y : [ 0 , 100 ] , Z : [ 0 , 100 ] } ,
alpha : { alpha : [ 0 , 1 ] } ,
HEX : { HEX : [ 0 , 16777215 ] } // maybe we don't need this
} ,
_instance = { } ,
_colors = { } ,
// http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html for more
XYZMatrix = { // Observer = 2° (CIE 1931), Illuminant = D65
X : [ 0.4124564 , 0.3575761 , 0.1804375 ] ,
Y : [ 0.2126729 , 0.7151522 , 0.0721750 ] ,
Z : [ 0.0193339 , 0.1191920 , 0.9503041 ] ,
R : [ 3.2404542 , - 1.5371385 , - 0.4985314 ] ,
G : [ - 0.9692660 , 1.8760108 , 0.0415560 ] ,
B : [ 0.0556434 , - 0.2040259 , 1.0572252 ]
} ,
grey = { r : 0.298954 , g : 0.586434 , b : 0.114612 } , // CIE-XYZ 1931
luminance = { r : 0.2126 , g : 0.7152 , b : 0.0722 } , // W3C 2.0
_math = Math ,
_parseint = parseInt ,
Colors = window . Colors = function ( options ) {
this . colors = { RND : { } } ;
this . options = {
color : 'rgba(204, 82, 37, 0.8)' , // init value(s)...
XYZMatrix : XYZMatrix ,
// XYZReference: {},
grey : grey ,
luminance : luminance ,
valueRanges : _valueRanges
// customBG: '#808080'
// convertCallback: undefined,
// allMixDetails: false
} ;
initInstance ( this , options || { } ) ;
} ,
initInstance = function ( THIS , options ) {
var matrix ,
importColor ,
_options = THIS . options ,
customBG ;
focusInstance ( THIS ) ;
for ( var option in options ) {
if ( options [ option ] !== undefined ) _options [ option ] = options [ option ] ;
}
matrix = _options . XYZMatrix ;
if ( ! options . XYZReference ) _options . XYZReference = {
X : matrix . X [ 0 ] + matrix . X [ 1 ] + matrix . X [ 2 ] ,
Y : matrix . Y [ 0 ] + matrix . Y [ 1 ] + matrix . Y [ 2 ] ,
Z : matrix . Z [ 0 ] + matrix . Z [ 1 ] + matrix . Z [ 2 ]
} ;
customBG = _options . customBG ;
_options . customBG = ( typeof customBG === 'string' ) ? ColorConverter . txt2color ( customBG ) . rgb : customBG ;
_colors = setColor ( THIS . colors , _options . color , undefined , true ) ; // THIS.colors = _colors =
} ,
focusInstance = function ( THIS ) {
if ( _instance !== THIS ) {
_instance = THIS ;
_colors = THIS . colors ;
}
} ;
Colors . prototype . setColor = function ( newCol , type , alpha ) {
focusInstance ( this ) ;
if ( newCol ) {
return setColor ( this . colors , newCol , type , undefined , alpha ) ;
} else {
if ( alpha !== undefined ) {
this . colors . alpha = limitValue ( alpha , 0 , 1 ) ;
}
return convertColors ( type ) ;
}
} ;
Colors . prototype . getColor = function ( type ) {
var result = this . colors , n = 0 ;
if ( type ) {
type = type . split ( '.' ) ;
while ( result [ type [ n ] ] ) {
result = result [ type [ n ++ ] ] ;
}
if ( type . length !== n ) {
result = undefined ;
}
}
return result ;
} ;
Colors . prototype . setCustomBackground = function ( col ) { // wild gues,... check again...
focusInstance ( this ) ; // needed???
this . options . customBG = ( typeof col === 'string' ) ? ColorConverter . txt2color ( col ) . rgb : col ;
// return setColor(this.colors, this.options.customBG, 'rgb', true); // !!!!RGB
return setColor ( this . colors , undefined , 'rgb' ) ; // just recalculate existing
} ;
Colors . prototype . saveAsBackground = function ( ) { // alpha
focusInstance ( this ) ; // needed???
// return setColor(this.colors, this.colors.RND.rgb, 'rgb', true);
return setColor ( this . colors , undefined , 'rgb' , true ) ;
} ;
Colors . prototype . convertColor = function ( color , type ) {
var convert = ColorConverter ,
ranges = _valueRanges ,
types = type . split ( '2' ) ,
fromType = types [ 0 ] ,
toType = types [ 1 ] ,
test = /(?:RG|HS|CM|LA)/ ,
normalizeFrom = test . test ( fromType ) ,
normalizeTo = test . test ( toType ) ,
exceptions = { LAB : 'Lab' } ,
normalize = function ( color , type , reverse ) {
var result = { } ,
Lab = type === 'Lab' ? 1 : 0 ;
for ( var n in color ) { // faster (but bigger) way: if/else outside 2 for loops
result [ n ] = reverse ?
_math . round ( color [ n ] * ( Lab || ranges [ type ] [ n ] [ 1 ] ) ) :
color [ n ] / ( Lab || ranges [ type ] [ n ] [ 1 ] ) ;
}
return result ;
} ;
fromType = ranges [ fromType ] ? fromType : exceptions [ fromType ] || fromType . toLowerCase ( ) ;
toType = ranges [ toType ] ? toType : exceptions [ toType ] || toType . toLowerCase ( ) ;
if ( normalizeFrom && type !== 'RGB2HEX' ) { // from ABC to abc
color = normalize ( color , fromType ) ;
}
color = fromType === toType ? color : ( // same type; returns same/normalized version
convert [ fromType + '2' + toType ] ? convert [ fromType + '2' + toType ] ( color , true ) : // existing converter
toType === 'HEX' ? convert . RGB2HEX ( type === 'RGB2HEX' ? color : normalize ( fromType === 'rgb' ? color :
convert [ fromType + '2rgb' ] ( color , true ) , 'rgb' , true ) ) :
convert [ 'rgb2' + toType ] ( convert [ fromType + '2rgb' ] ( color , true ) , true ) // not in ColorConverter
) ;
if ( normalizeTo ) { // from abc to ABC
color = normalize ( color , toType , true ) ;
}
return color ;
} ;
// ------------------------------------------------------ //
// ---------- Color calculation related stuff ---------- //
// -------------------------------------------------------//
function setColor ( colors , color , type , save , alpha ) { // color only full range
if ( typeof color === 'string' ) {
var color = ColorConverter . txt2color ( color ) ; // new object
type = color . type ;
_colors [ type ] = color [ type ] ;
alpha = alpha !== undefined ? alpha : color . alpha ;
} else if ( color ) {
for ( var n in color ) {
colors [ type ] [ n ] = limitValue ( color [ n ] / _valueRanges [ type ] [ n ] [ 1 ] , 0 , 1 ) ;
}
}
if ( alpha !== undefined ) {
colors . alpha = limitValue ( + alpha , 0 , 1 ) ;
}
return convertColors ( type , save ? colors : undefined ) ;
}
function saveAsBackground ( RGB , rgb , alpha ) {
var grey = _instance . options . grey ,
color = { } ;
color . RGB = { r : RGB . r , g : RGB . g , b : RGB . b } ;
color . rgb = { r : rgb . r , g : rgb . g , b : rgb . b } ;
color . alpha = alpha ;
// color.RGBLuminance = getLuminance(RGB);
color . equivalentGrey = _math . round ( grey . r * RGB . r + grey . g * RGB . g + grey . b * RGB . b ) ;
color . rgbaMixBlack = mixColors ( rgb , { r : 0 , g : 0 , b : 0 } , alpha , 1 ) ;
color . rgbaMixWhite = mixColors ( rgb , { r : 1 , g : 1 , b : 1 } , alpha , 1 ) ;
color . rgbaMixBlack . luminance = getLuminance ( color . rgbaMixBlack , true ) ;
color . rgbaMixWhite . luminance = getLuminance ( color . rgbaMixWhite , true ) ;
if ( _instance . options . customBG ) {
color . rgbaMixCustom = mixColors ( rgb , _instance . options . customBG , alpha , 1 ) ;
color . rgbaMixCustom . luminance = getLuminance ( color . rgbaMixCustom , true ) ;
_instance . options . customBG . luminance = getLuminance ( _instance . options . customBG , true ) ;
}
return color ;
}
function convertColors ( type , colorObj ) {
// console.time('convertColors');
var _Math = _math ,
colors = colorObj || _colors ,
convert = ColorConverter ,
options = _instance . options ,
ranges = _valueRanges ,
RND = colors . RND ,
// type = colorType, // || _mode.type,
modes , mode = '' , from = '' , // value = '',
exceptions = { hsl : 'hsv' , cmyk : 'cmy' , rgb : type } ,
RGB = RND . rgb , SAVE , SMART ;
if ( type !== 'alpha' ) {
for ( var typ in ranges ) {
if ( ! ranges [ typ ] [ typ ] ) { // no alpha|HEX
if ( type !== typ && typ !== 'XYZ' ) {
from = exceptions [ typ ] || 'rgb' ;
colors [ typ ] = convert [ from + '2' + typ ] ( colors [ from ] ) ;
}
if ( ! RND [ typ ] ) RND [ typ ] = { } ;
modes = colors [ typ ] ;
for ( mode in modes ) {
RND [ typ ] [ mode ] = _Math . round ( modes [ mode ] * ( typ === 'Lab' ? 1 : ranges [ typ ] [ mode ] [ 1 ] ) ) ;
}
}
}
if ( type !== 'Lab' ) {
delete colors . _rgb ;
}
RGB = RND . rgb ;
colors . HEX = convert . RGB2HEX ( RGB ) ;
colors . equivalentGrey =
options . grey . r * colors . rgb . r +
options . grey . g * colors . rgb . g +
options . grey . b * colors . rgb . b ;
colors . webSave = SAVE = getClosestWebColor ( RGB , 51 ) ;
// colors.webSave.HEX = convert.RGB2HEX(colors.webSave);
colors . webSmart = SMART = getClosestWebColor ( RGB , 17 ) ;
// colors.webSmart.HEX = convert.RGB2HEX(colors.webSmart);
colors . saveColor =
RGB . r === SAVE . r && RGB . g === SAVE . g && RGB . b === SAVE . b ? 'web save' :
RGB . r === SMART . r && RGB . g === SMART . g && RGB . b === SMART . b ? 'web smart' : '' ;
colors . hueRGB = convert . hue2RGB ( colors . hsv . h ) ;
if ( colorObj ) {
colors . background = saveAsBackground ( RGB , colors . rgb , colors . alpha ) ;
}
} // else RGB = RND.rgb;
var rgb = colors . rgb , // for better minification...
alpha = colors . alpha ,
luminance = 'luminance' ,
background = colors . background ,
rgbaMixBlack , rgbaMixWhite , rgbaMixCustom ,
rgbaMixBG , rgbaMixBGMixBlack , rgbaMixBGMixWhite , rgbaMixBGMixCustom ,
_mixColors = mixColors ,
_getLuminance = getLuminance ,
_getWCAG2Ratio = getWCAG2Ratio ,
_getHueDelta = getHueDelta ;
rgbaMixBlack = _mixColors ( rgb , { r : 0 , g : 0 , b : 0 } , alpha , 1 ) ;
rgbaMixBlack [ luminance ] = _getLuminance ( rgbaMixBlack , true ) ;
colors . rgbaMixBlack = rgbaMixBlack ;
rgbaMixWhite = _mixColors ( rgb , { r : 1 , g : 1 , b : 1 } , alpha , 1 ) ;
rgbaMixWhite [ luminance ] = _getLuminance ( rgbaMixWhite , true ) ;
colors . rgbaMixWhite = rgbaMixWhite ;
if ( options . allMixDetails ) {
rgbaMixBlack . WCAG2Ratio = _getWCAG2Ratio ( rgbaMixBlack [ luminance ] , 0 ) ;
rgbaMixWhite . WCAG2Ratio = _getWCAG2Ratio ( rgbaMixWhite [ luminance ] , 1 ) ;
if ( options . customBG ) {
rgbaMixCustom = _mixColors ( rgb , options . customBG , alpha , 1 ) ;
rgbaMixCustom [ luminance ] = _getLuminance ( rgbaMixCustom , true ) ;
rgbaMixCustom . WCAG2Ratio = _getWCAG2Ratio ( rgbaMixCustom [ luminance ] , options . customBG [ luminance ] ) ;
colors . rgbaMixCustom = rgbaMixCustom ;
}
rgbaMixBG = _mixColors ( rgb , background . rgb , alpha , background . alpha ) ;
rgbaMixBG [ luminance ] = _getLuminance ( rgbaMixBG , true ) ; // ?? do we need this?
colors . rgbaMixBG = rgbaMixBG ;
rgbaMixBGMixBlack = _mixColors ( rgb , background . rgbaMixBlack , alpha , 1 ) ;
rgbaMixBGMixBlack [ luminance ] = _getLuminance ( rgbaMixBGMixBlack , true ) ;
rgbaMixBGMixBlack . WCAG2Ratio = _getWCAG2Ratio ( rgbaMixBGMixBlack [ luminance ] ,
background . rgbaMixBlack [ luminance ] ) ;
/* ------ */
rgbaMixBGMixBlack . luminanceDelta = _Math . abs (
rgbaMixBGMixBlack [ luminance ] - background . rgbaMixBlack [ luminance ] ) ;
rgbaMixBGMixBlack . hueDelta = _getHueDelta ( background . rgbaMixBlack , rgbaMixBGMixBlack , true ) ;
/* ------ */
colors . rgbaMixBGMixBlack = rgbaMixBGMixBlack ;
rgbaMixBGMixWhite = _mixColors ( rgb , background . rgbaMixWhite , alpha , 1 ) ;
rgbaMixBGMixWhite [ luminance ] = _getLuminance ( rgbaMixBGMixWhite , true ) ;
rgbaMixBGMixWhite . WCAG2Ratio = _getWCAG2Ratio ( rgbaMixBGMixWhite [ luminance ] ,
background . rgbaMixWhite [ luminance ] ) ;
/* ------ */
rgbaMixBGMixWhite . luminanceDelta = _Math . abs (
rgbaMixBGMixWhite [ luminance ] - background . rgbaMixWhite [ luminance ] ) ;
rgbaMixBGMixWhite . hueDelta = _getHueDelta ( background . rgbaMixWhite , rgbaMixBGMixWhite , true ) ;
/* ------ */
colors . rgbaMixBGMixWhite = rgbaMixBGMixWhite ;
}
if ( options . customBG ) {
rgbaMixBGMixCustom = _mixColors ( rgb , background . rgbaMixCustom , alpha , 1 ) ;
rgbaMixBGMixCustom [ luminance ] = _getLuminance ( rgbaMixBGMixCustom , true ) ;
rgbaMixBGMixCustom . WCAG2Ratio = _getWCAG2Ratio ( rgbaMixBGMixCustom [ luminance ] ,
background . rgbaMixCustom [ luminance ] ) ;
colors . rgbaMixBGMixCustom = rgbaMixBGMixCustom ;
/* ------ */
rgbaMixBGMixCustom . luminanceDelta = _Math . abs (
rgbaMixBGMixCustom [ luminance ] - background . rgbaMixCustom [ luminance ] ) ;
rgbaMixBGMixCustom . hueDelta = _getHueDelta ( background . rgbaMixCustom , rgbaMixBGMixCustom , true ) ;
/* ------ */
}
colors . RGBLuminance = _getLuminance ( RGB ) ;
colors . HUELuminance = _getLuminance ( colors . hueRGB ) ;
// renderVars.readyToRender = true;
if ( options . convertCallback ) {
options . convertCallback ( colors , type ) ; //, convert); //, _mode);
}
// console.timeEnd('convertColors')
// if (colorObj)
return colors ;
}
// ------------------------------------------------------ //
// ------------------ color conversion ------------------ //
// -------------------------------------------------------//
var ColorConverter = {
txt2color : function ( txt ) {
var color = { } ,
parts = txt . replace ( /(?:#|\)|%)/g , '' ) . split ( '(' ) ,
values = ( parts [ 1 ] || '' ) . split ( /,\s*/ ) ,
type = parts [ 1 ] ? parts [ 0 ] . substr ( 0 , 3 ) : 'rgb' ,
m = '' ;
color . type = type ;
color [ type ] = { } ;
if ( parts [ 1 ] ) {
for ( var n = 3 ; n -- ; ) {
m = type [ n ] || type . charAt ( n ) ; // IE7
color [ type ] [ m ] = + values [ n ] / _valueRanges [ type ] [ m ] [ 1 ] ;
}
} else {
color . rgb = ColorConverter . HEX2rgb ( parts [ 0 ] ) ;
}
// color.color = color[type];
color . alpha = values [ 3 ] ? + values [ 3 ] : 1 ;
return color ;
} ,
RGB2HEX : function ( RGB ) {
return (
( RGB . r < 16 ? '0' : '' ) + RGB . r . toString ( 16 ) +
( RGB . g < 16 ? '0' : '' ) + RGB . g . toString ( 16 ) +
( RGB . b < 16 ? '0' : '' ) + RGB . b . toString ( 16 )
) . toUpperCase ( ) ;
} ,
HEX2rgb : function ( HEX ) {
var _parseInt = _parseint ;
HEX = HEX . split ( '' ) ; // IE7
return {
r : _parseInt ( HEX [ 0 ] + HEX [ HEX [ 3 ] ? 1 : 0 ] , 16 ) / 255 ,
g : _parseInt ( HEX [ HEX [ 3 ] ? 2 : 1 ] + ( HEX [ 3 ] || HEX [ 1 ] ) , 16 ) / 255 ,
b : _parseInt ( ( HEX [ 4 ] || HEX [ 2 ] ) + ( HEX [ 5 ] || HEX [ 2 ] ) , 16 ) / 255
} ;
} ,
hue2RGB : function ( hue ) {
var _Math = _math ,
h = hue * 6 ,
mod = ~ ~ h % 6 , // Math.floor(h) -> faster in most browsers
i = h === 6 ? 0 : ( h - mod ) ;
return {
r : _Math . round ( [ 1 , 1 - i , 0 , 0 , i , 1 ] [ mod ] * 255 ) ,
g : _Math . round ( [ i , 1 , 1 , 1 - i , 0 , 0 ] [ mod ] * 255 ) ,
b : _Math . round ( [ 0 , 0 , i , 1 , 1 , 1 - i ] [ mod ] * 255 )
} ;
} ,
// ------------------------ HSV ------------------------ //
rgb2hsv : function ( rgb ) { // faster
var _Math = _math ,
r = rgb . r ,
g = rgb . g ,
b = rgb . b ,
k = 0 , chroma , min , s ;
if ( g < b ) {
g = b + ( b = g , 0 ) ;
k = - 1 ;
}
min = b ;
if ( r < g ) {
r = g + ( g = r , 0 ) ;
k = - 2 / 6 - k ;
min = _Math . min ( g , b ) ; // g < b ? g : b; ???
}
chroma = r - min ;
s = r ? ( chroma / r ) : 0 ;
return {
h : s < 1e-15 ? ( ( _colors && _colors . hsl && _colors . hsl . h ) || 0 ) :
chroma ? _Math . abs ( k + ( g - b ) / ( 6 * chroma ) ) : 0 ,
s : r ? ( chroma / r ) : ( ( _colors && _colors . hsv && _colors . hsv . s ) || 0 ) , // ??_colors.hsv.s || 0
v : r
} ;
} ,
hsv2rgb : function ( hsv ) {
var h = hsv . h * 6 ,
s = hsv . s ,
v = hsv . v ,
i = ~ ~ h , // Math.floor(h) -> faster in most browsers
f = h - i ,
p = v * ( 1 - s ) ,
q = v * ( 1 - f * s ) ,
t = v * ( 1 - ( 1 - f ) * s ) ,
mod = i % 6 ;
return {
r : [ v , q , p , p , t , v ] [ mod ] ,
g : [ t , v , v , q , p , p ] [ mod ] ,
b : [ p , p , t , v , v , q ] [ mod ]
} ;
} ,
// ------------------------ HSL ------------------------ //
hsv2hsl : function ( hsv ) {
var l = ( 2 - hsv . s ) * hsv . v ,
s = hsv . s * hsv . v ;
s = ! hsv . s ? 0 : l < 1 ? ( l ? s / l : 0 ) : s / ( 2 - l ) ;
return {
h : hsv . h ,
s : ! hsv . v && ! s ? ( ( _colors && _colors . hsl && _colors . hsl . s ) || 0 ) : s , // ???
l : l / 2
} ;
} ,
rgb2hsl : function ( rgb , dependent ) { // not used in Color
var hsv = ColorConverter . rgb2hsv ( rgb ) ;
return ColorConverter . hsv2hsl ( dependent ? hsv : ( _colors . hsv = hsv ) ) ;
} ,
hsl2rgb : function ( hsl ) {
var h = hsl . h * 6 ,
s = hsl . s ,
l = hsl . l ,
v = l < 0.5 ? l * ( 1 + s ) : ( l + s ) - ( s * l ) ,
m = l + l - v ,
sv = v ? ( ( v - m ) / v ) : 0 ,
sextant = ~ ~ h , // Math.floor(h) -> faster in most browsers
fract = h - sextant ,
vsf = v * sv * fract ,
t = m + vsf ,
q = v - vsf ,
mod = sextant % 6 ;
return {
r : [ v , q , m , m , t , v ] [ mod ] ,
g : [ t , v , v , q , m , m ] [ mod ] ,
b : [ m , m , t , v , v , q ] [ mod ]
} ;
} ,
// ------------------------ CMYK ------------------------ //
// Quote from Wikipedia:
// "Since RGB and CMYK spaces are both device-dependent spaces, there is no
// simple or general conversion formula that converts between them.
// Conversions are generally done through color management systems, using
// color profiles that describe the spaces being converted. Nevertheless, the
// conversions cannot be exact, since these spaces have very different gamuts."
// Translation: the following are just simple RGB to CMY(K) and visa versa conversion functions.
rgb2cmy : function ( rgb ) {
return {
c : 1 - rgb . r ,
m : 1 - rgb . g ,
y : 1 - rgb . b
} ;
} ,
cmy2cmyk : function ( cmy ) {
var _Math = _math ,
k = _Math . min ( _Math . min ( cmy . c , cmy . m ) , cmy . y ) ,
t = 1 - k || 1e-20 ;
return { // regular
c : ( cmy . c - k ) / t ,
m : ( cmy . m - k ) / t ,
y : ( cmy . y - k ) / t ,
k : k
} ;
} ,
cmyk2cmy : function ( cmyk ) {
var k = cmyk . k ;
return { // regular
c : cmyk . c * ( 1 - k ) + k ,
m : cmyk . m * ( 1 - k ) + k ,
y : cmyk . y * ( 1 - k ) + k
} ;
} ,
cmy2rgb : function ( cmy ) {
return {
r : 1 - cmy . c ,
g : 1 - cmy . m ,
b : 1 - cmy . y
} ;
} ,
rgb2cmyk : function ( rgb , dependent ) {
var cmy = ColorConverter . rgb2cmy ( rgb ) ; // doppelt??
return ColorConverter . cmy2cmyk ( dependent ? cmy : ( _colors . cmy = cmy ) ) ;
} ,
cmyk2rgb : function ( cmyk , dependent ) {
var cmy = ColorConverter . cmyk2cmy ( cmyk ) ; // doppelt??
return ColorConverter . cmy2rgb ( dependent ? cmy : ( _colors . cmy = cmy ) ) ;
} ,
// ------------------------ LAB ------------------------ //
XYZ2rgb : function ( XYZ , skip ) {
var _Math = _math ,
M = _instance . options . XYZMatrix ,
X = XYZ . X ,
Y = XYZ . Y ,
Z = XYZ . Z ,
r = X * M . R [ 0 ] + Y * M . R [ 1 ] + Z * M . R [ 2 ] ,
g = X * M . G [ 0 ] + Y * M . G [ 1 ] + Z * M . G [ 2 ] ,
b = X * M . B [ 0 ] + Y * M . B [ 1 ] + Z * M . B [ 2 ] ,
N = 1 / 2.4 ;
M = 0.0031308 ;
r = ( r > M ? 1.055 * _Math . pow ( r , N ) - 0.055 : 12.92 * r ) ;
g = ( g > M ? 1.055 * _Math . pow ( g , N ) - 0.055 : 12.92 * g ) ;
b = ( b > M ? 1.055 * _Math . pow ( b , N ) - 0.055 : 12.92 * b ) ;
if ( ! skip ) { // out of gammut
_colors . _rgb = { r : r , g : g , b : b } ;
}
return {
r : limitValue ( r , 0 , 1 ) ,
g : limitValue ( g , 0 , 1 ) ,
b : limitValue ( b , 0 , 1 )
} ;
} ,
rgb2XYZ : function ( rgb ) {
var _Math = _math ,
M = _instance . options . XYZMatrix ,
r = rgb . r ,
g = rgb . g ,
b = rgb . b ,
N = 0.04045 ;
r = ( r > N ? _Math . pow ( ( r + 0.055 ) / 1.055 , 2.4 ) : r / 12.92 ) ;
g = ( g > N ? _Math . pow ( ( g + 0.055 ) / 1.055 , 2.4 ) : g / 12.92 ) ;
b = ( b > N ? _Math . pow ( ( b + 0.055 ) / 1.055 , 2.4 ) : b / 12.92 ) ;
return {
X : r * M . X [ 0 ] + g * M . X [ 1 ] + b * M . X [ 2 ] ,
Y : r * M . Y [ 0 ] + g * M . Y [ 1 ] + b * M . Y [ 2 ] ,
Z : r * M . Z [ 0 ] + g * M . Z [ 1 ] + b * M . Z [ 2 ]
} ;
} ,
XYZ2Lab : function ( XYZ ) {
var _Math = _math ,
R = _instance . options . XYZReference ,
X = XYZ . X / R . X ,
Y = XYZ . Y / R . Y ,
Z = XYZ . Z / R . Z ,
N = 16 / 116 , M = 1 / 3 , K = 0.008856 , L = 7.787037 ;
X = X > K ? _Math . pow ( X , M ) : ( L * X ) + N ;
Y = Y > K ? _Math . pow ( Y , M ) : ( L * Y ) + N ;
Z = Z > K ? _Math . pow ( Z , M ) : ( L * Z ) + N ;
return {
L : ( 116 * Y ) - 16 ,
a : 500 * ( X - Y ) ,
b : 200 * ( Y - Z )
} ;
} ,
Lab2XYZ : function ( Lab ) {
var _Math = _math ,
R = _instance . options . XYZReference ,
Y = ( Lab . L + 16 ) / 116 ,
X = Lab . a / 500 + Y ,
Z = Y - Lab . b / 200 ,
X3 = _Math . pow ( X , 3 ) ,
Y3 = _Math . pow ( Y , 3 ) ,
Z3 = _Math . pow ( Z , 3 ) ,
N = 16 / 116 , K = 0.008856 , L = 7.787037 ;
return {
X : ( X3 > K ? X3 : ( X - N ) / L ) * R . X ,
Y : ( Y3 > K ? Y3 : ( Y - N ) / L ) * R . Y ,
Z : ( Z3 > K ? Z3 : ( Z - N ) / L ) * R . Z
} ;
} ,
rgb2Lab : function ( rgb , dependent ) {
var XYZ = ColorConverter . rgb2XYZ ( rgb ) ;
return ColorConverter . XYZ2Lab ( dependent ? XYZ : ( _colors . XYZ = XYZ ) ) ;
} ,
Lab2rgb : function ( Lab , dependent ) {
var XYZ = ColorConverter . Lab2XYZ ( Lab ) ;
return ColorConverter . XYZ2rgb ( dependent ? XYZ : ( _colors . XYZ = XYZ ) , dependent ) ;
}
} ;
// ------------------------------------------------------ //
// ------------------ helper functions ------------------ //
// -------------------------------------------------------//
function getClosestWebColor ( RGB , val ) {
var out = { } ,
tmp = 0 ,
half = val / 2 ;
for ( var n in RGB ) {
tmp = RGB [ n ] % val ; // 51 = 'web save', 17 = 'web smart'
out [ n ] = RGB [ n ] + ( tmp > half ? val - tmp : - tmp ) ;
}
return out ;
}
function getHueDelta ( rgb1 , rgb2 , nominal ) {
var _Math = _math ;
return ( _Math . max ( rgb1 . r - rgb2 . r , rgb2 . r - rgb1 . r ) +
_Math . max ( rgb1 . g - rgb2 . g , rgb2 . g - rgb1 . g ) +
_Math . max ( rgb1 . b - rgb2 . b , rgb2 . b - rgb1 . b ) ) * ( nominal ? 255 : 1 ) / 765 ;
}
function getLuminance ( rgb , normalized ) {
var div = normalized ? 1 : 255 ,
RGB = [ rgb . r / div , rgb . g / div , rgb . b / div ] ,
luminance = _instance . options . luminance ;
for ( var i = RGB . length ; i -- ; ) {
RGB [ i ] = RGB [ i ] <= 0.03928 ? RGB [ i ] / 12.92 : _math . pow ( ( ( RGB [ i ] + 0.055 ) / 1.055 ) , 2.4 ) ;
}
return ( ( luminance . r * RGB [ 0 ] ) + ( luminance . g * RGB [ 1 ] ) + ( luminance . b * RGB [ 2 ] ) ) ;
}
function mixColors ( topColor , bottomColor , topAlpha , bottomAlpha ) {
var newColor = { } ,
alphaTop = ( topAlpha !== undefined ? topAlpha : 1 ) ,
alphaBottom = ( bottomAlpha !== undefined ? bottomAlpha : 1 ) ,
alpha = alphaTop + alphaBottom * ( 1 - alphaTop ) ; // 1 - (1 - alphaTop) * (1 - alphaBottom);
for ( var n in topColor ) {
newColor [ n ] = ( topColor [ n ] * alphaTop + bottomColor [ n ] * alphaBottom * ( 1 - alphaTop ) ) / alpha ;
}
newColor . a = alpha ;
return newColor ;
}
function getWCAG2Ratio ( lum1 , lum2 ) {
var ratio = 1 ;
if ( lum1 >= lum2 ) {
ratio = ( lum1 + 0.05 ) / ( lum2 + 0.05 ) ;
} else {
ratio = ( lum2 + 0.05 ) / ( lum1 + 0.05 ) ;
}
return _math . round ( ratio * 100 ) / 100 ;
}
function limitValue ( value , min , max ) {
// return Math.max(min, Math.min(max, value)); // faster??
return ( value > max ? max : value < min ? min : value ) ;
}
} ) ( window ) ;
; ( function ( window , undefined ) {
"use strict"
2016-04-13 07:26:35 +00:00
// see colorPicker.html for the following encrypted variables... will only be used in buildView()
var _html = ( '^§app alpha-bg-w">^§slds">^§sldl-1">$^§sldl-2">$^§sldl-3">$^§curm">$^§sldr-1">$^§sldr-2">$^§sldr-4">$^§curl">$^§curr">$$^§opacity">|^§opacity-slider">$$$^§memo">^§raster">$^§raster-bg">$|$|$|$|$|$|$|$|$^§memo-store">$^§memo-cursor">$$^§panel">^§hsv">^hsl-mode §ß">$^hsv-h-ß §ß">H$^hsv-h-~ §~">-^§nsarrow">$$^hsl-h-@ §@">H$^hsv-s-ß §ß">S$^hsv-s-~ §~">-$^hsl-s-@ §@">S$^hsv-v-ß §ß">B$^hsv-v-~ §~">-$^hsl-l-@ §@">L$$^§hsl §hide">^hsv-mode §ß">$^hsl-h-ß §ß">H$^hsl-h-~ §~">-$^hsv-h-@ §@">H$^hsl-s-ß §ß">S$^hsl-s-~ §~">-$^hsv-s-@ §@">S$^hsl-l-ß §ß">L$^hsl-l-~ §~">-$^hsv-v-@ §@">B$$^§rgb">^rgb-r-ß §ß">R$^rgb-r-~ §~">-$^rgb-r-@ §ß"> $^rgb-g-ß §ß">G$^rgb-g-~ §~">-$^rgb-g-@ §ß"> $^rgb-b-ß §ß">B$^rgb-b-~ §~">-$^rgb-b-@ §ß"> $$^§cmyk">^Lab-mode §ß">$^cmyk-c-ß §@">C$^cmyk-c-~ §~">-$^Lab-L-@ §@">L$^cmyk-m-ß §@">M$^cmyk-m-~ §~">-$^Lab-a-@ §@">a$^cmyk-y-ß §@">Y$^cmyk-y-~ §~">-$^Lab-b-@ §@">b$^cmyk-k-ß §@">K$^cmyk-k-~ §~">-$^Lab-x-@ §ß"> $$^§Lab §hide">^cmyk-mode §ß">$^Lab-L-ß §@">L$^Lab-L-~ §~">-$^cmyk-c-@ §@">C$^Lab-a-ß §@">a$^Lab-a-~ §~">-$^cmyk-m-@ §@">M$^Lab-b-ß §@">b$^Lab-b-~ §~">-$^cmyk-y-@ §@">Y$^Lab-x-ß §@"> $^Lab-x-~ §~">-$^cmyk-k-@ §@">K$$^§alpha">^alpha-ß §ß">A$^alpha-~ §~">-$^alpha-@ §ß">W$$^§HEX">^HEX-ß §ß">#$^HEX-~ §~">-$^HEX-@ §ß">M$$^§ctrl">^§raster">$^§cont">$^§cold">$^§col1">| $$^§col2">| $$^§bres">RESET$^§bsav">SAVE$$$^§exit">$^§resize">$^§resizer">|$$$' ) .
replace ( /\^/g , '<div class="' ) . replace ( /\$/g , '</div>' ) . replace ( /~/g , 'disp' ) . replace ( /ß/g , 'butt' ) . replace ( /@/g , 'labl' ) . replace ( /\|/g , '<div>' ) ,
_cssFunc = ( 'är^1,äg^1,äb^1,öh^1,öh?1,öh?2,ös?1,öv?1,üh^1,üh?1,üh?2,üs?1,ül?1,.no-rgb-r är?2,.no-rgb-r är?3,.no-rgb-r är?4,.no-rgb-g äg?2,.no-rgb-g äg?3,.no-rgb-g äg?4,.no-rgb-b äb?2,.no-rgb-b äb?3,.no-rgb-b äb?4{visibility:hidden}är^2,är^3,äg^2,äg^3,äb^2,äb^3{@-image:url(_patches.png)}.§slds div{@-image:url(_vertical.png)}öh^2,ös^1,öv^1,üh^2,üs^1,ül^1{@-image:url(_horizontal.png)}ös?4,öv^3,üs?4,ül^3{@:#000}üs?3,ül^4{@:#fff}är?1{@-color:#f00}äg?1{@-color:#0f0}äb?1{@-color:#00f}är^2{@|-1664px 0}är^3{@|-896px 0}är?1,äg?1,äb?1,öh^3,ös^2,öv?2Ü-2432Öär?2Ü-2944Öär?3Ü-4480Öär?4Ü-3202Öäg^2Äöh^2{@|-640px 0}äg^3{@|-384px 0}äg?2Ü-4736Öäg?3Ü-3968Öäg?4Ü-3712Öäb^2{@|-1152px 0}äb^3{@|-1408px 0}äb?2Ü-3456Öäb?3Ü-4224Öäb?4Ü-2688Ööh^2Äär^3Ääb?4Ü0}öh?4,üh?4Ü-1664Öös^1,öv^1,üs^1,ül^1Ääg^3{@|-256px 0}ös^3,öv?4,üs^3,ül?4Ü-2176Öös?2,öv^2Ü-1920Öüh^2{@|-768px 0}üh^3,üs^2,ül?2Ü-5184Öüs?2,ül^2Ü-5824Ö.S är^2{@|-128px -128Ö.S är?1Ääg?1Ääb?1Äöh^3Äös^2Äöv?2Ü-1408Ö.S är?2Ääb^3Ü-128Ö.S är?3Ü-896Ö.S är?4Ü-256Ö.S äg^2{@|-256px -128Ö.S äg?2Ü-1024Ö.S äg?3Ü-640Ö.S äg?4Ü-512Ö.S äb^2{@|-128px 0}.S äb?2Ü-384Ö.S äb?3Ü-768Ö.S öh?4Äüh?4Ü-1536Ö.S ös^1Äöv^1Äüs^1Äül^1{@|-512px 0}.S ös^3Äöv?4Äüs^3Äül?4Ü-1280Ö.S ös?2Äöv^2Ü-1152Ö.S üh^2{@|-1024px 0}.S üh^3Äüs^2Äül?2Ü-5440Ö.S üs?2Äül^2Ü-5696Ö.XXS ös^2,.XXS öv?2Ü-5120Ö.XXS ös^3,.XXS öv?4,.XXS üs^3,.XXS ül^3,.XXS ül?4Ü-5056Ö.XXS ös?2,.XXS öv^2Ü-4992Ö.XXS üs^2,.XXS ül?2Ü-5568Ö.XXS üs?2,.XXS ül^2Ü-5632Ö' ) .
replace ( /Ü/g , '{@|0 ' ) . replace ( /Ö/g , 'px}' ) . replace ( /Ä/g , ',.S ' ) . replace ( /\|/g , '-position:' ) . replace ( /@/g , 'background' ) . replace ( /ü/g , '.hsl-' ) . replace ( /ö/g , '.hsv-' ) . replace ( /ä/g , '.rgb-' ) . replace ( /~/g , ' .no-rgb-}' ) . replace ( /\?/g , ' .§sldr-' ) . replace ( /\^/g , ' .§sldl-' ) ,
_cssMain = ( ' ∑ { @ # bbb ; font - family : monospace , "Courier New" , Courier , mono ; font - size : 12 ¥ line - ä15 ¥ font - weight : bold ; cursor : default ; ~ 412 ¥ ä323 ¥ ? top - left - radius : 7 ¥ ? top - Ü - radius : 7 ¥ ? bottom - Ü - radius : 7 ¥ ? bottom - left - radius : 7 ¥ ö @ # 444 } . S { ~ 266 ¥ ä177px } . XS { ~ 158 ¥ ä173px } . XXS { ä105 ¥ ~ 154 px } . no - alpha { ä308px } . no - alpha . § opacity , . no - alpha . § alpha { display : none } . S . no - alpha { ä162px } . XS . no - alpha { ä158px } . XXS . no - alpha { ä90px } ∑ , ∑ div { border : none ; padding : 0 ¥ float : none ; margin : 0 ¥ outline : none ; box - sizing : content - box } ∑ div { | absolute } ^ s . § curm , « § disp , « § nsarrow , ∑ . § exit , ∑ ø - cursor , ∑ . § resize { öimage : url ( _icons . png ) } ∑ . do - drag div { cursor : none } ∑ . § opacity , ø . § raster - bg , ∑ . § raster { öimage : url ( _bgs . png ) } ∑ ^ s { ~ 287 ¥ ä256 ¥ top : 10 ¥ left : 10 ¥ overflow : hidden ; cursor : crosshair } . S ^ s { ~ 143 ¥ ä128 ¥ left : 9 ¥ top : 9 px } . XS ^ s { left : 7 ¥ top : 7 px } . XXS ^ s { left : 5 ¥ top : 5 px } ^ s div { ~ 256 ¥ ä256 ¥ left : 0 px } . S ^ l - 1 , . S ^ l - 2 , . S ^ l - 3 , . S ^ l - 4 { ~ 128 ¥ ä128px } . XXS ^ s , . XXS ^ s ^ l - 1 , . XXS ^ s ^ l - 2 , . XXS ^ s ^ l - 3 , . XXS ^ s ^ l - 4 { ä64px } ^ s ^ r - 1 , ^ s ^ r - 2 , ^ s ^ r - 3 , ^ s ^ r - 4 { ~ 31 ¥ left : 256 ¥ cursor : default } . S ^ r - 1 , . S ^ r - 2 , . S ^ r - 3 , . S ^ r - 4 { ~ 15 ¥ ä128 ¥ left : 128 px } ^ s . § curm { margin : - 5 ¥ ~ 11 ¥ ä11 ¥ ö | - 36 px - 30 px } . light . § curm { ö | - 7 px - 30 px } ^ s . § curl , ^ s . § curr { ~ 0 ¥ ä0 ¥ margin : - 3 px - 4 ¥ border : 4 px solid ; cursor : default ; left : auto ; öimage : none } ^ s . § curl , ∑ ^ s . § curl - dark , . hue - dark div . § curl { Ü : 27 ¥ ? @ † † † # fff } . light . § curl , ∑ ^ s . § curl - light , . hue - light . § curl { ? @ † † † # 000 } . S ^ s . § curl , . S ^ s . § curr { ? ~ 3 px } . S ^ s . § curl - light , . S ^ s . § curl { Ü : 13 px } ^ s . § curr , ∑ ^ s . § curr - dark { Ü : 4 ¥ ? @ † # fff † † } . light . § curr , ∑ ^ s . § curr - light { ? @ † # 000 † † } ∑ . § opacity { bottom : 44 ¥ left : 10 ¥ ä10 ¥ ~ 287 ¥ ö | 0 - 87 px } . S . § opacity { bottom : 27 ¥ left : 9 ¥ ~ 143 ¥ ö | 0 - 100 px } . XS . § opacity { left : 7 ¥ bottom : 25 px } . XXS . § opacity { left : 5 ¥ bottom : 23 px } . § opacity div { ~ 100 % ; ä16 ¥ margin - top : - 3 ¥ overflow : hidden } . § opacity . § opacity - slider { margin : 0 - 4 ¥ ~ 0 ¥ ä8 ¥ ? ~ 4 ¥ ? style : solid ; ? @ # eee † } ∑ ø { bottom : 10 ¥ left : 10 ¥ ~ 288 ¥ ä31 ¥ ö @ # fff } . S ø { ä15 ¥ ~ 144 ¥ left : 9 ¥ bottom : 9 px } . XS ø { left : 7 ¥ bottom : 7 px } . XXS ø { left : 5 ¥ bottom : 5 px } ø div { | relative ; float : left ; ~ 31 ¥ ä31 ¥ margin - Ü : 1 px } . S ø div { ~ 15 ¥ ä15px } ∑ . § raster , ø . § raster - bg , . S ø . § raster , . S ø . § raster - bg { | absolute ; top : 0 ¥ Ü : 0 ¥ bottom : 0 ¥ left : 0 ¥ ~ 100 % } . S ø . § raster - bg { ö | 0 - 31 px } ∑ . § raster { opacity : 0.2 ; ö | 0 - 49 px } . alpha - bg - b ø { ö @ # 333 } . alpha - bg - b . § raster { opacity : 1 } ø ø - cursor { | absolute ; Ü : 0 ¥ ö | - 26 px - 87 px } ∑ . light ø - cursor { ö | 3 px - 87 px } . S ø - cursor { ö | - 34 px - 95 px } . S . light ø - cursor { ö | - 5 px - 95 px } ∑ . § panel { | absolute ; top : 10 ¥ Ü : 10 ¥ bottom : 10 ¥ ~ 94 ¥ ? ~ 1 ¥ ? style : solid ; ? @ # 222 # 555 # 555 # 222 ; overflow : hidden ; ö @ # 333 } . S . § panel { top : 9 ¥ Ü : 9 ¥ bottom : 9 px } . XS . § panel { display : none } . § panel div { | relative } « § hsv , « § hsl , « § rgb , « § cmyk , « § Lab , « § alpha , . no - alpha « § HEX , « § HEX { ~ 86 ¥ margin : - 1 px 0 px 1 px 4 ¥ padding : 1 px 0 px 3 ¥ ? top - ~ 1 ¥ ? top - style : solid ; ? top - @ # 444 ; ? bottom - ~ 1 ¥ ? bottom - style : solid ; ? bottom - @ # 222 ; float : Ö « § hsv , « § hsl { padding - top : 2 px } . S . § hsv , . S . § hsl { padding - top : 1 px } « § HEX { ? bottom - style : none ; ? top - ~ 0 ¥ margin - top : - 4 ¥ padding - top : 0 px } . no - alpha « § HEX { ? bottom - style : none } « § alpha { ? bottom - style : none } . S . rgb - r . § hsv , . S . rgb - g . § hsv , . S . rgb - b . § hsv , . S . rgb - r . § hsl , . S . rgb - g . § hsl , . S . rgb - b . § hsl , . S . hsv - h . § rgb , . S . hsv - s . § rgb , . S . hsv - v . § rgb , . S . hsl - h . § rgb , . S . hsl - s . § rgb , . S . hsl - l . § rgb , . S . § cmyk , . S . § Lab { display : none } « § butt , « § labl { float : left ; ~ 14 ¥ ä14 ¥ margin - top : 2 ¥ text - align : center ; border : 1 px solid } « § butt { ? @ # 555 # 222 # 222 # 555 } « § butt : active { ö @ # 444 } « § labl { ? @ † } « Lab - mode , « cmyk - mode , « hsv - mode , « hsl - mode { | absolute ; Ü : 0 ¥ top : 1 ¥ ä50px } « hsv - mode , « hsl - mode { top : 2 px } « cmyk - mode { ä68px } . hsl - h . hsl - h - labl , . hsl - s . hsl - s - labl , . hsl - l . hsl - l - labl , . hsv - h . hsv - h - labl , . hsv - s . hsv - s - labl , . hsv - v . hsv - v - labl { @ # f90 } « cmyk - mode , « hsv - mode , . rgb - r . rgb - r - butt , . rgb - g . rgb - g - butt , . rgb - b . rgb - b - butt , . hsv - h . hsv - h - butt , . hsv - s . hsv - s - butt , . hsv - v . hsv - v - butt , . hsl - h . hsl - h - butt , . hsl - s . hsl - s - butt , . hsl - l . hsl - l - butt , « rgb - r - labl , « rgb - g - labl , « rgb - b - labl , « alpha - butt , « HEX - butt , « Lab - x - labl { ? @ # 222
replace ( /Ü/g , 'right' ) . replace ( /Ö/g , 'left}' ) . replace ( /∑/g , '.§app' ) . replace ( /«/g , '.§panel .' ) . replace ( /¥/g , 'px;' ) . replace ( /\|/g , 'position:' ) . replace ( /@/g , 'color:' ) . replace ( /ö/g , 'background-' ) . replace ( /ä/g , 'height:' ) . replace ( /ø/g , '.§memo' ) . replace ( /†/g , 'transparent' ) . replace ( /\~/g , 'width:' ) . replace ( /\?/g , 'border-' ) . replace ( /\^/g , '.§sld' ) ,
_horizontalPng = 'iVBORw0KGgoAAAANSUhEUgAABIAAAAABCAYAAACmC9U0AAABT0lEQVR4Xu2S3Y6CMBCFhyqIsjGBO1/B9/F5DC/pK3DHhVkUgc7Zqus2DVlGU/cnQZKTjznttNPJBABA149HyRf1iN//4mIBCg0jV4In+j9xJiuihly1V/Z9X88v//kNeDXVvyO/lK+IPR76B019+1Riab3H1zkmeqerKnL+Bzwxx6PAgZxaSQU8vB62T28pxcQeRQ2sHw6GxCOWHvP78zwHAARBABOfdYtd30rwxXOEPDF+dj2+91r6vV/id3k+/brrXmaGUkqKhX3i+ffSt16HQ/dorTGZTHrs7ev7Tl7XdZhOpzc651nfsm1bRFF0YRiGaJoGs9nsQuN/xafTCXEco65rzOdzHI9HJEmCqqqwXC6x3++RZRnKssRqtUJRFFiv19jtdthutyAi5Hl+Jo9VZg7+7f3yXuvZf5c3KaXYzByb+WIzO5ymKW82G/0BNcFhO/tOuuMAAAAASUVORK5CYII=' ,
_verticalPng = 'iVBORw0KGgoAAAANSUhEUgAAAAEAABfACAYAAABn2KvYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABHtJREFUeNrtnN9SqzAQxpOF1to6zuiVvoI+j6/gva/lA/kKeqUzjtX+QTi7SzSYBg49xdIzfL34+e1usoQQklCnmLwoCjImNwDQA2xRGMqNAYB+gPEH9IdCgIUA6Aem0P1fLoMQAPYNHYDoCKAv8OMHFgKgX2AjDPQDXn4t1l+gt/1fId//yWgE/hUJ+mAn8EyY5wCwXxhrbaHzn8E9iPlv79DdHxXTqciZ4KROnXRVZMF/6U2OPhcEavtAbZH1SM7wRDD7VoHZItCiyEQf4t6+MW9UOxaZybmdCGKqNrB9Eb5SfMg3wTyiagMtigTmWofiSDCOYNTSNz6sLDIoaCU9GWDd0tdhoMMsRm+r8U/EfB0GfjmLXiqzimDd0tdhoLMsI7la45+I+ToM/HIW0kfGVQTrlr7tA91kaUr//fxrKo8jUFB7VAn6AKpHJf+EKwAAAIYD/f7F7/8MVgMo7P+gBqDKr57Lf72V8x8AAMDgYIuvH4EAAAAMDQX6AACAQcI9GGMjDADA4MA/P2KlP8IEAAAYFCz6AACAgaLA8y8AAIN+CMYXoQAADA7u/UPYCAMAMDjI7z9S+SdwDFQX2C9Gh9GMEOWriz8/Pw1lWQZsi/L3R4czzP678Ve+P8f9nCv/C7hwLq99ah8NfKrU15zPB5pVcwtiJt9qGy0IfEE+jQa+Fn0VtI/fkxUPqBlEfRENeF+tqUpbGpi1iu8epwJzvV5XA4GpWC6XGz7F+/u766EgwJ+ckiTJKU3TnI6OjnI6OzvLZf6zMggt3dzckPhIoiTlSGpQ+eEsVegdz0fbCCi4fRs+Po+4yWdeDXiT+6pBSTeHple1pkz3FZ+avpyavoiPxgLN0B7yprY08PlyQTTm0+PWmkH7ynedNKraar4F/lRj1WpTtYh+ozL/cY2sAvZl0gcbZm0gSLBLvkxGoaogiy/HDXemQk2t5pUm8OAhH8/HH6e0mkJ9q9XKKQXfb07xfZnJbZrRxcVFVt6/t7e3Kc1ms5RGo1Eq5VIZuyl9fHw4k/M5xYeoKj64A7eqCt1ZeqWFVSl8NV9OTV3fmvP5qE9VmzSoEcsXpArK1UHen/hZbgL53BZSdyEXalGau/hU8TEW0u3VcoFPy3EDFrTgT+njydeZ0+l0UV7fu7u7iVzziQQmUm4iqRw4n/NxMxw4s/Mp1NSALxf4NEtQ10cjMDwSl+b+/j6hp6enVGb+jUvrn05iKobm6PboOt8vPISY5Pr6OqGXlxe3fOokoGtAbMUJZmqvYmaLQDP+sdrecOjtO/SXeH69P8Imutm5urqy9PDwYOny8tLS4+OjpfPzc0vPz8+WTk9PLb2+vlpZbCzN53NLx8fHVtYZS5PJxMoEZWWqsjKULY3HYytTi1Pex5OMldXKRVXxuLcy/20onmms3BBOxcr5qCrZtsrd45SPel8sGlOxGoGy0neynQ6VL9fsa1YtWlCrtj9G83G7PjdVush5n5q1iJWLZW6u21a1bUvbVnVzlru0pe3RdmlV1/23fZtbZv4Dx+7FBypx77kAAAAASUVORK5CYII=' ,
_patchesPng = ( 'iVBORw0KGgo^NSUhEUgAAB4^EACAI#DdoPxz#L0UlEQVR4Xu3cQWrDQBREwR7FF8/BPR3wXktnQL+KvxfypuEhvLJXcp06d/bXd71OPt+trIw95zr33Z1bk1/fudEv79wa++7OfayZ59wrO2PBzklcGQmAZggAAOBYgAYBmpWRAGg^BGgRofAENgAAN#I0CBA6w8AG^ECABgEa/QH§AI0CNDoDwAY^QIAGAVp/AM§AjQI0OgPAAY^QoEGARn8Aw§CNAjQ+gMABg#BCgQYCmGQmABgAAEKBBgEZ/AM§AjQI0PoDAAY^QoEGARn8AM^IAADQI0+gMABg#BCgQYDWHwAw^gAANAjT6A4AB^BGgQoNEfAD^C#0CtP4AgAE^EaBCgaUYCoAE#RoEKDRHwAw^gAANArT+AIAB^BGgQoNEfAAw^gQIMAjf4AgAE^EaBCg9QcAD^CBAgwCN/gBg§EaBGj0BwAM^IECDAK0/AG§ARoEaJqRAGg^BGgRo9AcAD^CBAgwCtPwBg§EaBGj0BwAD^CNAgQKM/AG§ARoEaP0BAAM^I0CBAoz8AG^ECABgEa/QEAAw^jQIEDrDwAY^QIAGAZpmJACaBw^RoEKD1BwAM^IECDAK0/AG§ARoEaPQHAAw^gQIMArT8AY§BGgRo/QEAAw^jQIECjPwBg§EaBGj9AQAD^CNAgQOsPABg#BAgAYBGv0BAANwCwAAGB6gYeckmpEAa^AEaBGj0BwAM^IECDAK0/AG§ARoEaPQHAAM^I0CBAoz8AY§BGgRo/QEAAw^jQIECjPwAY^QIAGARr9AQAD^CNAgQOsPABg#BAgAYBmmYkABoAAECABgEa/QEAAw^jQIEDrDwAY^QIAGARr9Ac§AjQI0OgPABg#BAgAYBWn8Aw§CNAjQ6A8ABg#BCgQYBGfwD§AI0CND6AwAG^EKBBgKYZCYAG#QoEGARn8Aw§CNAjQ+gMABg#BCgQYBGfwAw^gAANAjT6AwAG^EKBBgNYfAD^C#0CNPoDgAE^EaBCg0R8AM^IAADQK0/gCAAQ^RoEKBpRgKgAQAABGgQoNEfAD^C#0CtP4AgAE^EaBCg0R8AD^CBAgwCN/gCAAQ^RoEKD1BwAM^IECDAI3+AG§ARoEaPQHAAw^gQIMArT8AY§BGgRomsMAM^IAADQK0/gCAAQ^RoEKDRHwAw^gAANO7fQHwAw^gAANArT+AIAB^BGgQoNEfAGg^BGgRo9AcAD^CBAgwCtPwBg§EaBGj0BwAD^RIB+Ntg5iea5AD^DAIwI0CND6AwAG^EKBBgEZ/AKAB#EaBCg0R8AM^IAADQK0/gCAAQ^RoEKDRHwAM^IECDAI3+AIAB^BGgQoPUHAAw^gQIMAjf4AY§BGgRo9AcAD^CBAgwCtPwBg§EaBGiakQBo^ARoEaPQHAAw^gQIMArT8AY§BGgRo9AcAAw^jQIECjPwBg§EaBGj9AQAD^CNAgQKM/ABg#BAgAYBGv0BAAM^I0CBA6w8AG^ECABgGaZiQAGgAAQIAGARr9AQAD^CNAgQOsPABg#BAgAYBGv0Bw§CNAjQ6A8AG^ECABgFafwD§AI0CNDoDwAG^EKBBgEZ/AM§AjQI0PoDAAY^QoEGApjkMAAM^I0CBA6w8AG^ECABgEa/QEAAw^jQsIP+AIAB^BGgQoPUHAAw^gQIMAjf4AgAE#Bea/fK+3P5/3PJOvh8t1cO4nflmQAQoAEAAF9Aw/7JHfQHAAw^gQIMArT8AY§BGvwHNPoDAA0AACBAgwCN/gCAAQ^RoEKD1BwAM^IECDAI3+AG§ARoEaPQHAAw^gQIMArT8AY§BGgRo9AcAAw^jQIECjPwBg§EaBGj9AQAD^CNAgQNOMBEAD#I0CBAoz8AY§BGgRo/QEAAw^jQIECjPwAY^QIAGARr9AQAD^CNAgQOsPABg#BAgAYBGv0Bw§CNAjQ6A8AG^ECABgFafwD§AI0CNA0IwHQ^AjQI0OgPABg#BAgAYBWn8Aw§CNAjQ6A8ABg#BCgQYBGfwD§AI0CND6AwAG^EKBBgEZ/AD^C#0CNPoDAAY^QoEGA1h8AM^IAADQI0DQAG^EKBBgEZ/AM§AjQI0PoDAAY^QoEGA1h8AM^IAADQI0+gMABg#BCgQYDWHwAw^gAANArT+AIAB^BGgQoNEfAD^C#0CtP4AgAE^EaBCg9QcAD^CBAgwCN/gCAAQ^RoEKD1BwAM^IECDAK0/AG§ARoEaPQHAAw^gQIMArT8AY§BGgRo/QEAAw^jQIECjPwBgACDhFgC#07t9AfAD^C#0CtP4AgAE^EaBCg0R8Aa^AEaBGj0BwAM^IECDAK0/AG§ARoEaPQHAAM^I0CBAoz8AY§BGgRo/QEAAw^jQIECjPwAY^QIAGARr9AQAD^CNAgQOsPABg#BAgAYBmmYkABoAAECABgEa/QEAAw^jQIEDrDwAY^QIAGARr9Ac§AjQI0OgPABg#BAgAYBWn8Aw§CNAjQ6A8ABg#BCgQYBGfwD§AI0CND6AwAG^EKBBgKYZCYAG#QoEGARn8Aw§CNAjQ+gMABg#BCgQYBGfwAw^gAANAjT6AwAG^EKBBgNYfAD^C#0CNPoDgAE^EaBCg0R8AM^IAADQK0/gCAAQ^RoEKBpRgKgAQAABGgQoNEfAD^C#0CtP4AgAE^EaBCg0R8AD^CBAgwCN/gCAAQ^RoEKD1BwAM^IECDAI3+AG§ARoEaPQHAAw^gQIMArT8AY§BGgRommEAM^CBAgwCN/gCAAQ^RoEKD1BwAM^IECDAI3+AIAB^ARoEaPQHAAw^gQIMArT8AY§BGgRo9AcAGgAAQICGCNBfRfNcABg#BgeICGnVvoDwAY^QIAGAVp/AM§AjQI0OgPADQAAIAADQI0+gMABg#BCgQYDWHwAw^gAANAjT6A4AB^BGgQoNEfAD^C#0CtP4AgAE^EaBCg0R8AD^CBAgwCN/gCAAQ^RoEKD1BwAM^IECDAE0zEgAN#gQIMAjf4AgAE^EaBCg9QcAD^CBAgwCN/gBg§EaBGj0BwAM^IECDAK0/AG§ARoEaPQHAAM^I0CBAoz8AY§BGgRo/QEAAw^jQIEDTjARAAwAACNAgQKM/AG§ARoEaP0BAAM^I0CBAoz8AG^ECABgEa/QEAAw^jQIEDrDwAY^QIAGARr9Ac§AjQI0OgPABg#BAgAYBWn8Aw§CNAjQNIcBY§BGgRo/QEAAw^jQIECjPwBg§EadtAfAD^C#0CtP4AgAE^EaBCgAQABGgAA+AO2TAbHupOgH^ABJRU5ErkJggg==' ) .
replace ( /§/g , 'AAAAAA' ) . replace ( /\^/g , 'AAAA' ) . replace ( /#/g , 'AAA' ) ,
_iconsPng = 'iVBORw0KGgoAAAANSUhEUgAAAGEAAABDCAMAAAC7vJusAAAAkFBMVEUAAAAvLy9ERERubm7///8AAAD///9EREREREREREREREQAAAD///8AAAD///8AAAD///8AAAD///8AAAD///8AAAD///8AAAD///8AAAD///8AAAD///8cHBwkJCQnJycoKCgpKSkqKiouLi4vLy8/Pz9AQEBCQkJDQ0NdXV1ubm58fHykpKRERERVVVUzMzPx7Ab+AAAAHXRSTlMAAAAAAAQEBQ4QGR4eIyMtLUVFVVVqapKSnJy7u9JKTggAAAFUSURBVHja7dXbUoMwEAbgSICqLYeW88F6KIogqe//dpoYZ0W4AXbv8g9TwkxmvtndZMrEwlw/F8YIRjCCEYxgBCOsFmzqGMEI28J5zzmt0Pc9rdDL0NYgMxIYC5KiKpKAzZphWtZlGm4SjlnkOV6UHeeEUx77rh/npw1dCrI9k9lnwUwF+UG9D3m4ftJJxH4SJdPtaawXcbr+tBaeFrxiur309cIv19+4ytGCU0031a5euPVigLYGqjlAqM4ShOQ+QAYQUO80AMMAAkUGGfMfR9Ul+kmvPq2QGxXKOQBAKdjUgk0t2NiCGEVP+rHT3/iCUMBT90YrPMsKsIWP3x/VolaonJEETchHCS8AYAmaUICQQwaAQnjoXgHAES7jLkEFaHO4bdq/k25HAIpgWY34FwAE5xjCffM+D2DV8B0gRsAZT7hr5gE8wdrJcU+CJqhcqQD7Cx5L7Ph4WnrKAAAAAElFTkSuQmCC' ,
_bgsPng = 'iVBORw0KGgoAAAANSUhEUgAAASAAAABvCAYAAABM+h2NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABORJREFUeNrs3VtTW1UYBuCEcxAI4YydWqTWdqr1V7T/2QsvvPDCCy9qjxZbamsrhZIQUHsCEtfafpmJe8qFjpUxfZ4Zuvt2feydJvAOARZUut1u5bRerl692nV913f99/f6QxWAU6KAAAUEKCAABQQoIAAFBCggAAUEKCAABQQoIAAFBCggAAUEKCAABQQoIEABASggQAEBKCBAAQEoIEABASggQAEBKCBAAQEoIGBQC+jatWvd07zxrv9+Xx8fAQEoIEABASggQAEBKCBAAQEoIEABAQoIQAEBCghAAQEKCEABAQOk2u36kS6AAgLetwJKL29toFRM1be+QrVq3rx58//KvM8BAadGAQEKCFBAAAoIGHwnfhneZ+/Nmzf/LufzrI+AAE/BAAUEoIAABQTwztgLZt68eXvBAE/BABQQoIAAFBAweOwFM2/evL1ggKdgAAoIUEAACggYPPaCmTdv3l4wwFMwAAUEKCAABQQMHnvBzJs3by8Y4CkYgAICFBCAAgIGz4lfBQNQQMDgFlCtVisaaHV1tThubW1VInciD0U+ysdnz54N5+PKysphOnRTHsvHlN9EHo/1l5FrkV9Enoz8W87b29tTOS8vLx9EnoncjlyPvBe5EbkZeT4fU96NvBDr2znv7Ows57y0tLQVeSXy08gf5mNfPhPrjyOfrVarlcXFxZ9yfv78+bl8TPlh5LU8n/KDyOuxfj/y+VjfyHl3d/dCKv28fi/yp/m4sLDwQ+SLke9GvhT5Tinfjnw5f4/F/Pz8rZybzeZn+ZjyzVK+EfnzUr4S+Xopf9/L+fxzc3M5d1qt1hf531Mu5k/IxzGf85VYL+fefHH+RqNRrO/t7RW3L+UbkS9Hvhk5/386Kd/qW8/5duRLMV/OdyJfzNebnZ0t7t92u53v/07K9yJfiLwROT9+ef7HyOux/iDyWuSHkT+K+eLtZX9//2xer9frjyOfyY9/Wn8S86v59qT1p7Ge315zLt4RU16K19+O9YXIu5HnYn435hux3opcj9yOPB3z+5E/iPXf43y1yMX778HBQS3f3pTz+28l5bHIr2N+LN3+zszMzGHkoh/S+mHMF98XlNaP8zHd/0W/pMe943NAwKlSQIACAhQQgAICFBCAAgIUEIACAhQQgAIC/n9GqtXqYbfbHa38+RtSu32llPdqdNL6aOSj+LfxyMVekLTem39Ryr/mPDQ0NBznzXtROikPRW6W8k7k3m9rzXthOsPDw73bUuylGRkZ6cR63nvTSfko8oPIr+Pnz96P/DLW816ezujoaN6DdtyX9+P8eS9QZ2xs7Hxf7qa8Xlr/JO6Ljcjrcf6cj1P+OO+N6V1/fHz8XLz+/Tjfubh+sZcorZ+N9Ycxfybyo8ircf6fc56YmFiJ1/8l8mLk7cjzkfP92U15Ns63G+u9nPcKdWq12lQ8Xu3Ixd6f9Pd8P3UmJycnUszzL2N9LM7/anNzs9V7Q2q32395w/q7ubdH6L/KrVbrpPxlKX9Vyl+X8jel/G0pf5f/aDabvXy9tH6ztH63lDdKebOUH5Xyk1LeKuWd/ry2tlap9P125Onp6Zf9eWpq6lW3b8f6zMzM6/71er3+ppSP+u/XNN/pz41Go+sjIMBTMEABASggQAEBKCBAAQEoIEABASggQAEB/CN/CDAAw78uW9AVDw4AAAAASUVORK5CYII=' ;
window . ColorPicker = {
_html : _html ,
_cssFunc : _cssFunc ,
_cssMain : _cssMain ,
_horizontalPng : _horizontalPng ,
_verticalPng : _verticalPng ,
_patchesPng : _patchesPng ,
_iconsPng : _iconsPng ,
_bgsPng : _bgsPng
}
} ) ( window ) ;
; ( function ( window , undefined ) {
"use strict"
2016-04-13 04:45:40 +00:00
var _data = window . ColorPicker , // will be deleted in buildView() and holds:
// window.ColorPicker = { // comes from colorPicker.data.js and will be overwritten.
// _html: ..., // holds the HTML markup of colorPicker
// _cssFunc: ..., // CSS for all the sliders
// _cssMain: ..., // CSS of the GUI
// _horizontalPng: ..., // horizontal background images for sliders
// _verticalPng: ..., // vertical background images for sliders
// _patchesPng: ..., // background images for square sliders in RGB mode
// _iconsPng: ..., // some icon sprite images
// _bgsPng: ..., // some more icon sprite images
// }
_devMode = ! _data , // if no _data we assume that colorPicker.data.js is missing (for development)
_isIE = document . createStyleSheet !== undefined && document . getElementById || ! ! window . MSInputMethodContext ,
_doesOpacity = typeof document . body . style . opacity !== 'undefined' ,
// _isIE8 = _isIE && document.querySelectorAll,
_valueRanges = { } , // will be assigned in initInstance() by Colors instance
// _valueRanges = {
// rgb: {r: [0, 255], g: [0, 255], b: [0, 255]},
// hsv: {h: [0, 360], s: [0, 100], v: [0, 100]},
// hsl: {h: [0, 360], s: [0, 100], l: [0, 100]},
// cmyk: {c: [0, 100], m: [0, 100], y: [0, 100], k: [0, 100]},
// cmy: {c: [0, 100], m: [0, 100], y: [0, 100]},
// XYZ: {X: [0, 100], Y: [0, 100], Z: [0, 100]},
// Lab: {L: [0, 100], a: [-128, 127], b: [-128, 127]},
// alpha: {alpha: [0, 1]},
// HEX: {HEX: [0, 16777215]}
// },
_bgTypes = { w : 'White' , b : 'Black' , c : 'Custom' } ,
_mouseMoveAction , // current mouseMove handler assigned on mouseDown
_action = '' , // needed for action callback; needed due to minification of javaScript
_mainTarget , // target on mouseDown, might be parent element though...
_valueType , // check this variable; gets missused/polutet over time
_delayState = 1 , // mouseMove offset (y-axis) in display elements // same here...
_startCoords = { } ,
_targetOrigin = { } ,
_renderTimer , // animationFrame/interval variable
_newData = true ,
// _txt = {
// selection: document.selection || window.getSelection(),
// range: (document.createRange ? document.createRange() : document.body.createTextRange())
// },
_renderVars = { } , // used only in renderAll and convertColors
_cashedVars = { } , // reset in initSliders
_colorPicker ,
_previousInstance , // only used for recycling purposes in buildView()
_colorInstance = { } ,
_colors = { } ,
_options = { } ,
_nodes = { } ,
_math = Math ,
animationFrame = 'AnimationFrame' , // we also need this later
requestAnimationFrame = 'request' + animationFrame ,
cancelAnimationFrame = 'cancel' + animationFrame ,
vendors = [ 'ms' , 'moz' , 'webkit' , 'o' ] ,
ColorPicker = function ( options ) { // as tiny as possible...
this . options = {
color : 'rgba(204, 82, 37, 0.8)' ,
mode : 'rgb-b' ,
fps : 60 , // 1000 / 60 = ~16.7ms
delayOffset : 8 ,
CSSPrefix : 'cp-' ,
allMixDetails : true ,
alphaBG : 'w' ,
imagePath : ''
// devPicker: false // uses existing HTML for development...
// noAlpha: true,
// customBG: '#808080'
// size: 0,
// cmyOnly: false,
// initStyle: 'display: none',
// memoryColors: "'rgba(82,80,151,1)','rgba(100,200,10,0.5)','rgba(100,0,0,1)','rgba(0,0,0,1)'"
// memoryColors: [{r: 100, g: 200, b: 10, a: 0.5}] //
// opacityPositionRelative: undefined,
// customCSS: undefined,
// appendTo: document.body,
// noRangeBackground: false,
// textRight: false, ?????
// noHexButton: false,
// noResize: false,
// noRGBr: false,
// noRGBg: false,
// noRGBb: false,
// ------ CSSStrength: 'div.',
// XYZMatrix: XYZMatrix,
// XYZReference: {},
// grey: grey,
// luminance: luminance,
// renderCallback: undefined,
// actionCallback: undefined,
// convertCallback: undefined,
} ;
initInstance ( this , options || { } ) ;
} ;
window . ColorPicker = ColorPicker ; // export differently
ColorPicker . addEvent = addEvent ;
ColorPicker . removeEvent = removeEvent ;
ColorPicker . getOrigin = getOrigin ;
ColorPicker . limitValue = limitValue ;
ColorPicker . changeClass = changeClass ;
// ------------------------------------------------------ //
ColorPicker . prototype . setColor = function ( newCol , type , alpha , forceRender ) {
focusInstance ( this ) ;
_valueType = true ; // right cursor...
// https://github.com/petkaantonov/bluebird/wiki/Optimization-killers
preRenderAll ( _colorInstance . setColor . apply ( _colorInstance , arguments ) ) ;
if ( forceRender ) {
this . startRender ( true ) ;
}
} ;
ColorPicker . prototype . saveAsBackground = function ( ) {
focusInstance ( this ) ;
return saveAsBackground ( true ) ;
} ;
ColorPicker . prototype . setCustomBackground = function ( col ) {
focusInstance ( this ) ; // needed???
return _colorInstance . setCustomBackground ( col ) ;
} ;
ColorPicker . prototype . startRender = function ( oneTime ) {
focusInstance ( this ) ;
if ( oneTime ) {
_mouseMoveAction = false ; // prevents window[requestAnimationFrame] in renderAll()
renderAll ( ) ;
this . stopRender ( ) ;
} else {
_mouseMoveAction = 1 ;
_renderTimer = window [ requestAnimationFrame ] ( renderAll ) ;
}
} ;
ColorPicker . prototype . stopRender = function ( ) {
focusInstance ( this ) ; // check again
window [ cancelAnimationFrame ] ( _renderTimer ) ;
if ( _valueType ) {
// renderAll();
_mouseMoveAction = 1 ;
stopChange ( undefined , 'external' ) ;
// _valueType = undefined;
}
} ;
ColorPicker . prototype . setMode = function ( mode ) { // check again ... right cursor
focusInstance ( this ) ;
setMode ( mode ) ;
initSliders ( ) ;
renderAll ( ) ;
} ;
ColorPicker . prototype . destroyAll = function ( ) { // check this again...
var html = this . nodes . colorPicker ,
destroyReferences = function ( nodes ) {
for ( var n in nodes ) {
if ( nodes [ n ] && nodes [ n ] . toString ( ) === '[object Object]' || nodes [ n ] instanceof Array ) {
destroyReferences ( nodes [ n ] ) ;
}
nodes [ n ] = null ;
delete nodes [ n ] ;
}
} ;
this . stopRender ( ) ;
installEventListeners ( this , true ) ;
destroyReferences ( this ) ;
html . parentNode . removeChild ( html ) ;
html = null ;
} ;
ColorPicker . prototype . renderMemory = function ( memory ) {
var memos = this . nodes . memos ,
tmp = [ ] ;
if ( typeof memory === 'string' ) { // revisit!!!
memory = memory . replace ( /^'|'$/g , '' ) . replace ( /\s*/ , '' ) . split ( '\',\'' ) ;
}
for ( var n = memos . length ; n -- ; ) { // check again how to handle alpha...
if ( memory && typeof memory [ n ] === 'string' ) {
tmp = memory [ n ] . replace ( 'rgba(' , '' ) . replace ( ')' , '' ) . split ( ',' ) ;
memory [ n ] = { r : tmp [ 0 ] , g : tmp [ 1 ] , b : tmp [ 2 ] , a : tmp [ 3 ] }
}
memos [ n ] . style . cssText = 'background-color: ' + ( memory && memory [ n ] !== undefined ?
color2string ( memory [ n ] ) + ';' + getOpacityCSS ( memory [ n ] [ 'a' ] || 1 ) : 'rgb(0,0,0);' ) ;
}
} ;
// ------------------------------------------------------ //
function initInstance ( THIS , options ) {
var exporter , // do something here..
mode = '' ,
CSSPrefix = '' ,
optionButtons ;
for ( var option in options ) { // deep copy ??
THIS . options [ option ] = options [ option ] ;
}
_colorInstance = new Colors ( THIS . options ) ;
// We transfer the responsibility to the instance of Color (to save space and memory)
delete THIS . options ;
_options = _colorInstance . options ;
_options . scale = 1 ;
CSSPrefix = _options . CSSPrefix ;
THIS . color = _colorInstance ; // check this again...
_valueRanges = _options . valueRanges ;
THIS . nodes = _nodes = getInstanceNodes ( buildView ( THIS ) , THIS ) ; // ha, ha,... make this different
setMode ( _options . mode ) ;
focusInstance ( THIS ) ;
saveAsBackground ( ) ;
mode = ' ' + _options . mode . type + '-' + _options . mode . z ;
_nodes . slds . className += mode ;
_nodes . panel . className += mode ;
//_nodes.colorPicker.className += ' cmy-' + _options.cmyOnly;
if ( _options . noHexButton ) {
changeClass ( _nodes . HEX _butt , CSSPrefix + 'butt' , CSSPrefix + 'labl' ) ;
}
if ( _options . size !== undefined ) {
resizeApp ( undefined , _options . size ) ;
}
optionButtons = {
alphaBG : _nodes . alpha _labl ,
cmyOnly : _nodes . HEX _labl // test... take out
} ;
for ( var n in optionButtons ) {
if ( _options [ n ] !== undefined ) {
buttonActions ( { target : optionButtons [ n ] , data : _options [ n ] } ) ;
}
}
if ( _options . noAlpha ) {
_nodes . colorPicker . className += ' no-alpha' ; // IE6 ??? maybe for IE6 on document.body
}
THIS . renderMemory ( _options . memoryColors ) ;
installEventListeners ( THIS ) ;
_mouseMoveAction = true ;
stopChange ( undefined , 'init' ) ;
if ( _previousInstance ) {
focusInstance ( _previousInstance ) ;
renderAll ( ) ;
}
}
function focusInstance ( THIS ) {
_newData = true ;
if ( _colorPicker !== THIS ) {
_colorPicker = THIS ;
_colors = THIS . color . colors ;
_options = THIS . color . options ;
_nodes = THIS . nodes ;
_colorInstance = THIS . color ;
_cashedVars = { } ;
preRenderAll ( _colors ) ;
}
}
function getUISizes ( ) {
var sizes = [ 'L' , 'S' , 'XS' , 'XXS' ] ;
_options . sizes = { } ;
_nodes . testNode . style . cssText = 'position:absolute;left:-1000px;top:-1000px;' ;
document . body . appendChild ( _nodes . testNode ) ;
for ( var n = sizes . length ; n -- ; ) {
_nodes . testNode . className = _options . CSSPrefix + 'app ' + sizes [ n ] ;
_options . sizes [ sizes [ n ] ] = [ _nodes . testNode . offsetWidth , _nodes . testNode . offsetHeight ] ;
}
if ( _nodes . testNode . removeNode ) { // old IEs
_nodes . testNode . removeNode ( true ) ;
} else {
document . body . removeChild ( _nodes . testNode ) ;
}
}
function buildView ( THIS ) {
var app = document . createElement ( 'div' ) ,
prefix = _options . CSSPrefix ,
urlData = 'data:image/png;base64,' ,
addStyleSheet = function ( cssText , id ) {
var style = document . createElement ( 'style' ) ;
style . setAttribute ( 'type' , 'text/css' ) ;
if ( id ) {
style . setAttribute ( 'id' , id ) ;
}
if ( ! style . styleSheet ) {
style . appendChild ( document . createTextNode ( cssText ) ) ;
}
document . getElementsByTagName ( 'head' ) [ 0 ] . appendChild ( style ) ;
if ( style . styleSheet ) { // IE compatible
document . styleSheets [ document . styleSheets . length - 1 ] . cssText = cssText ;
}
} ,
processCSS = function ( doesBAS64 ) {
// CSS - system
_data . _cssFunc = _data . _cssFunc .
replace ( /§/g , prefix ) .
replace ( '_patches.png' , doesBAS64 ? urlData + _data . _patchesPng : _options . imagePath + '_patches.png' ) .
replace ( '_vertical.png' , doesBAS64 ? urlData + _data . _verticalPng : _options . imagePath + '_vertical.png' ) .
replace ( '_horizontal.png' , doesBAS64 ? urlData + _data . _horizontalPng :
_options . imagePath + '_horizontal.png' ) ;
addStyleSheet ( _data . _cssFunc , 'colorPickerCSS' ) ;
// CSS - main
if ( ! _options . customCSS ) {
_data . _cssMain = _data . _cssMain .
replace ( /§/g , prefix ) .
replace ( '_bgs.png' , doesBAS64 ? urlData + _data . _bgsPng : _options . imagePath + '_bgs.png' ) .
replace ( '_icons.png' , doesBAS64 ? urlData + _data . _iconsPng : _options . imagePath + '_icons.png' ) .
// replace('"Courier New",', !_isIE ? '' : '"Courier New",').
replace ( /opacity:(\d*\.*(\d+))/g , function ( $1 , $2 ) {
return ! _doesOpacity ? '-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=' +
_math . round ( + $2 * 100 ) + ')";filter: alpha(opacity=' + _math . round ( + $2 * 100 ) + ')' :
'-moz-opacity: ' + $2 + '; -khtml-opacity: ' + $2 + '; opacity: ' + $2 ;
} ) ;
// style.appendChild(document.createTextNode(_data._cssFunc));
addStyleSheet ( _data . _cssMain ) ;
}
// for (var n in _data) { // almost 25k of memory ;o)
// _data[n] = null;
// }
} ,
test = document . createElement ( 'img' ) ;
// development mode
if ( _devMode ) {
return THIS . color . options . devPicker ;
}
// CSS
if ( ! document . getElementById ( 'colorPickerCSS' ) ) { // only once needed
test . onload = test . onerror = function ( ) {
if ( _data . _cssFunc ) {
processCSS ( this . width === 1 && this . height === 1 ) ;
}
} ;
test . src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==" ;
}
// HTML
if ( _previousInstance = _colorPicker ) {
// we need to be careful with recycling HTML as slider calssNames might have been changed...
initSliders ( ) ;
}
// app.innerHTML = _colorPicker ? _colorPicker.nodes.colorPicker.outerHTML : _data._html.replace(/§/g, prefix);
// faster ... FF8.0 (2011) though (but IE4)
// outerHTML ... FF11 (2013)
app . insertAdjacentHTML ( 'afterbegin' ,
_colorPicker ? _colorPicker . nodes . colorPicker . outerHTML ||
new XMLSerializer ( ) . serializeToString ( _colorPicker . nodes . colorPicker ) : // FF before F11
_data . _html . replace ( /§/g , prefix ) ) ;
// _colorPicker ? _colorPicker.nodes.colorPicker.parentNode.innerHTML : _data._html.replace(/§/g, prefix));
// _data._html = null;
app = app . children [ 0 ] ;
app . style . cssText = _options . initStyle || '' ; // for initial hiding...
// get a better addClass for this....
// app.className = app.className.split(' ')[0]; // cleanup for multy instances
return ( _options . appendTo || document . body ) . appendChild ( app ) ;
}
function getInstanceNodes ( colorPicker , THIS ) { // check nodes again... are they all needed?
var all = colorPicker . getElementsByTagName ( '*' ) ,
nodes = { colorPicker : colorPicker } , // length ?? // rename nodes.colorPicker
node ,
className ,
memoCounter = 0 ,
regexp = new RegExp ( _options . CSSPrefix ) ;
// nodes.displayStyles = {}; // not needed ... or change to CSS
nodes . styles = { } ;
// nodes.styles.displays = {};
nodes . textNodes = { } ;
nodes . memos = [ ] ;
nodes . testNode = document . createElement ( 'div' ) ;
for ( var n = 0 , m = all . length ; n < m ; n ++ ) {
node = all [ n ] ;
if ( ( className = node . className ) && regexp . test ( className ) ) {
className = className . split ( ' ' ) [ 0 ] . replace ( _options . CSSPrefix , '' ) . replace ( /-/g , '_' ) ;
if ( /_disp/ . test ( className ) ) {
className = className . replace ( '_disp' , '' ) ;
// nodes.styles.displays[className] = node.style;
nodes . styles [ className ] = node . style ;
nodes . textNodes [ className ] = node . firstChild ;
node . contentEditable = true ; // does this slow down rendering??
} else {
if ( ! ( /(?:hs|cmyk|Lab).*?(?:butt|labl)/ . test ( className ) ) ) {
nodes [ className ] = node ;
}
if ( /(?:cur|sld[^s]|opacity|cont|col)/ . test ( className ) ) {
nodes . styles [ className ] = /(?:col\d)/ . test ( className ) ? node . children [ 0 ] . style : node . style ;
}
}
} else if ( /memo/ . test ( node . parentNode . className ) ) {
nodes . memos . push ( node ) ;
}
}
// Chrome bug: focuses contenteditable on mouse over while dragging
nodes . panelCover = nodes . panel . appendChild ( document . createElement ( 'div' ) ) ;
return nodes ;
}
// ------------------------------------------------------ //
// ---- Add event listners to colorPicker and window ---- //
// -------------------------------------------------------//
function installEventListeners ( THIS , off ) {
var onOffEvent = off ? removeEvent : addEvent ;
onOffEvent ( _nodes . colorPicker , 'mousedown' , function ( e ) {
var event = e || window . event ,
page = getPageXY ( event ) ,
target = event . target || event . srcElement ,
className = target . className ;
focusInstance ( THIS ) ;
_mainTarget = target ;
stopChange ( undefined , 'resetEventListener' ) ;
_action = '' ; // needed due to minification of javaScript
if ( target === _nodes . sldl _3 || target === _nodes . curm ) {
_mainTarget = _nodes . sldl _3 ;
_mouseMoveAction = changeXYValue ;
_action = 'changeXYValue' ;
changeClass ( _nodes . slds , 'do-drag' ) ;
} else if ( /sldr/ . test ( className ) || target === _nodes . curl || target === _nodes . curr ) {
_mainTarget = _nodes . sldr _4 ;
_mouseMoveAction = changeZValue ;
_action = 'changeZValue' ;
} else if ( target === _nodes . opacity . children [ 0 ] || target === _nodes . opacity _slider ) {
_mainTarget = _nodes . opacity ;
_mouseMoveAction = changeOpacityValue ;
_action = 'changeOpacityValue' ;
} else if ( /-disp/ . test ( className ) && ! /HEX-/ . test ( className ) ) {
_mouseMoveAction = changeInputValue ;
_action = 'changeInputValue' ;
( target . nextSibling . nodeType === 3 ? target . nextSibling . nextSibling : target . nextSibling ) .
appendChild ( _nodes . nsarrow ) ; // nextSibling for better text selection
_valueType = className . split ( '-disp' ) [ 0 ] . split ( '-' ) ;
_valueType = { type : _valueType [ 0 ] , z : _valueType [ 1 ] || '' } ;
changeClass ( _nodes . panel , 'start-change' ) ;
_delayState = 0 ;
} else if ( target === _nodes . resize && ! _options . noResize ) {
if ( ! _options . sizes ) {
getUISizes ( ) ;
}
_mainTarget = _nodes . resizer ;
_mouseMoveAction = resizeApp ;
_action = 'resizeApp' ;
} else {
_mouseMoveAction = undefined ;
}
if ( _mouseMoveAction ) {
_startCoords = { pageX : page . X , pageY : page . Y } ;
_mainTarget . style . display = 'block' ; // for resizer...
_targetOrigin = getOrigin ( _mainTarget ) ;
_targetOrigin . width = _nodes . opacity . offsetWidth ; // ???????
_targetOrigin . childWidth = _nodes . opacity _slider . offsetWidth ; // ???????
_mainTarget . style . display = '' ; // ??? for resizer...
_mouseMoveAction ( event ) ;
addEvent ( _isIE ? document . body : window , 'mousemove' , _mouseMoveAction ) ;
_renderTimer = window [ requestAnimationFrame ] ( renderAll ) ;
} else {
// console.log(className)
// console.log(THIS.nodes[className.split(' ')[0].replace('cp-', '').replace('-', '_')])
// resize, button states, etc...
}
// if (_mouseMoveAction !== changeInputValue) preventDefault(event);
if ( ! /-disp/ . test ( className ) ) {
return preventDefault ( event ) ;
// document.activeElement.blur();
}
} ) ;
onOffEvent ( _nodes . colorPicker , 'click' , function ( e ) {
focusInstance ( THIS ) ;
buttonActions ( e ) ;
} ) ;
onOffEvent ( _nodes . colorPicker , 'dblclick' , buttonActions ) ;
onOffEvent ( _nodes . colorPicker , 'keydown' , function ( e ) {
focusInstance ( THIS ) ;
keyControl ( e ) ;
} ) ;
// keydown is before keypress and focuses already
onOffEvent ( _nodes . colorPicker , 'keypress' , keyControl ) ;
// onOffEvent(_nodes.colorPicker, 'keyup', keyControl);
onOffEvent ( _nodes . colorPicker , 'paste' , function ( e ) {
e . target . firstChild . data = e . clipboardData . getData ( 'Text' ) ;
return preventDefault ( e ) ;
} ) ;
}
addEvent ( _isIE ? document . body : window , 'mouseup' , stopChange ) ;
// ------------------------------------------------------ //
// --------- Event listner's callback functions -------- //
// -------------------------------------------------------//
function stopChange ( e , action ) {
var mouseMoveAction = _mouseMoveAction ;
if ( _mouseMoveAction ) { // why??? please test again...
// if (document.selection && _mouseMoveAction !== changeInputValue) {
// //ie -> prevent showing the accelerator menu
// document.selection.empty();
// }
window [ cancelAnimationFrame ] ( _renderTimer ) ;
removeEvent ( _isIE ? document . body : window , 'mousemove' , _mouseMoveAction ) ;
if ( _delayState ) { // hapens on inputs
_valueType = { type : 'alpha' } ;
renderAll ( ) ;
}
// this is dirty... has to do with M|W|! button
if ( typeof _mouseMoveAction === 'function' || typeof _mouseMoveAction === 'number' ) {
delete _options . webUnsave ;
}
_delayState = 1 ;
_mouseMoveAction = undefined ;
changeClass ( _nodes . slds , 'do-drag' , '' ) ;
changeClass ( _nodes . panel , '(?:start-change|do-change)' , '' ) ;
_nodes . resizer . style . cssText = '' ;
_nodes . panelCover . style . cssText = '' ;
_nodes . memo _store . style . cssText = 'background-color: ' +
color2string ( _colors . RND . rgb ) + '; ' + getOpacityCSS ( _colors . alpha ) ;
_nodes . memo . className = _nodes . memo . className . replace ( /\s+(?:dark|light)/ , '' ) +
// (/dark/.test(_nodes.colorPicker.className) ? ' dark' : ' light');
( _colors [ 'rgbaMix' + _bgTypes [ _options . alphaBG ] ] . luminance < 0.22 ? ' dark' : ' light' ) ;
// (_colors.rgbaMixCustom.luminance < 0.22 ? ' dark' : ' light')
_valueType = undefined ;
resetCursors ( ) ;
if ( _options . actionCallback ) {
_options . actionCallback ( e , _action || mouseMoveAction . name || action || 'external' ) ;
}
}
}
function changeXYValue ( e ) {
var event = e || window . event ,
scale = _options . scale ,
page = getPageXY ( event ) ,
x = ( page . X - _targetOrigin . left ) * ( scale === 4 ? 2 : scale ) ,
y = ( page . Y - _targetOrigin . top ) * scale ,
mode = _options . mode ;
_colors [ mode . type ] [ mode . x ] = limitValue ( x / 255 , 0 , 1 ) ;
_colors [ mode . type ] [ mode . y ] = 1 - limitValue ( y / 255 , 0 , 1 ) ;
convertColors ( ) ;
return preventDefault ( event ) ;
}
function changeZValue ( e ) { // make this part of changeXYValue
var event = e || window . event ,
page = getPageXY ( event ) ,
z = ( page . Y - _targetOrigin . top ) * _options . scale ,
mode = _options . mode ;
_colors [ mode . type ] [ mode . z ] = 1 - limitValue ( z / 255 , 0 , 1 ) ;
convertColors ( ) ;
return preventDefault ( event ) ;
}
function changeOpacityValue ( e ) {
var event = e || window . event ,
page = getPageXY ( event ) ;
_newData = true ;
_colors . alpha = limitValue ( _math . round (
( page . X - _targetOrigin . left ) / _targetOrigin . width * 100 ) , 0 , 100
) / 100 ;
convertColors ( 'alpha' ) ;
return preventDefault ( event ) ;
}
function changeInputValue ( e ) {
var event = e || window . event ,
page = getPageXY ( event ) ,
delta = _startCoords . pageY - page . Y ,
delayOffset = _options . delayOffset ,
type = _valueType . type ,
isAlpha = type === 'alpha' ,
ranges ;
if ( _delayState || _math . abs ( delta ) >= delayOffset ) {
if ( ! _delayState ) {
_delayState = ( delta > 0 ? - delayOffset : delayOffset ) +
( + _mainTarget . firstChild . data ) * ( isAlpha ? 100 : 1 ) ;
_startCoords . pageY += _delayState ;
delta += _delayState ;
_delayState = 1 ;
changeClass ( _nodes . panel , 'start-change' , 'do-change' ) ;
_nodes . panelCover . style . cssText = 'position:absolute;left:0;top:0;right:0;bottom:0' ;
// window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
document . activeElement . blur ( ) ;
_renderTimer = window [ requestAnimationFrame ] ( renderAll ) ;
}
if ( type === 'cmyk' && _options . cmyOnly ) {
type = 'cmy' ;
}
if ( isAlpha ) {
_newData = true ;
_colors . alpha = limitValue ( delta / 100 , 0 , 1 ) ;
} else {
ranges = _valueRanges [ type ] [ _valueType . z ] ;
_colors [ type ] [ _valueType . z ] = type === 'Lab' ? limitValue ( delta , ranges [ 0 ] , ranges [ 1 ] ) :
limitValue ( delta / ranges [ 1 ] , 0 , 1 ) ;
}
convertColors ( isAlpha ? 'alpha' : type ) ;
// event.returnValue is deprecated. Please use the standard event.preventDefault() instead.
// event.returnValue = false; // see: pauseEvent(event);
return preventDefault ( event ) ;
}
}
function keyControl ( e ) { // this is quite big for what it does...
var event = e || window . event ,
keyCode = event . which || event . keyCode ,
key = String . fromCharCode ( keyCode ) ,
elm = document . activeElement ,
cln = elm . className . replace ( _options . CSSPrefix , '' ) . split ( '-' ) ,
type = cln [ 0 ] ,
mode = cln [ 1 ] ,
isAlpha = type === 'alpha' ,
isHex = type === 'HEX' ,
arrowKey = { k40 : - 1 , k38 : 1 , k34 : - 10 , k33 : 10 } [ 'k' + keyCode ] / ( isAlpha ? 100 : 1 ) ,
validKeys = { 'HEX' : /[0-9a-fA-F]/ , 'Lab' : /[\-0-9]/ , 'alpha' : /[\.0-9]/ } [ type ] || /[0-9]/ ,
valueRange = _valueRanges [ type ] [ type ] || _valueRanges [ type ] [ mode ] , // let op!
textNode = elm . firstChild , // chnge on TAB key
rangeData = caret ( elm ) ,
origValue = textNode . data , // do not change
value ,
val = origValue === '0' && ! isHex ? [ ] : origValue . split ( '' ) ; // gefixt
if ( /^(?:27|13)$/ . test ( keyCode ) ) { // ENTER || ESC
preventDefault ( event ) ;
elm . blur ( ) ;
} else if ( event . type === 'keydown' ) { // functional keys
if ( arrowKey ) { // arrow/page keys
value = limitValue ( _math . round ( ( + origValue + arrowKey ) * 1e+6 ) / 1e+6 , valueRange [ 0 ] , valueRange [ 1 ] ) ;
} else if ( /^(?:8|46)$/ . test ( keyCode ) ) { // DELETE / BACKSPACE
if ( ! rangeData . range ) {
rangeData . range ++ ;
rangeData . start -= keyCode === 8 ? 1 : 0 ;
}
val . splice ( rangeData . start , rangeData . range ) ;
value = val . join ( '' ) || '0' ; // never loose elm.firstChild
}
if ( value !== undefined ) { // prevent keypress
preventDefault ( event , true ) ;
}
} else if ( event . type === 'keypress' ) {
if ( ! /^(?:37|39|8|46|9)$/ . test ( keyCode ) ) { // left, right,DEL, BACK, TAB for FF
preventDefault ( event , true ) ;
}
if ( validKeys . test ( key ) ) { // regular input
val . splice ( rangeData . start , rangeData . range , key ) ;
value = val . join ( '' ) ;
}
rangeData . start ++ ;
}
if ( keyCode === 13 && isHex ) {
if ( textNode . data . length % 3 === 0 || textNode . data === '0' ) { // textNode.data.length &&
return _colorPicker . setColor ( textNode . data === '0' ? '000' : textNode . data , 'rgb' , _colors . alpha , true ) ;
} else {
preventDefault ( event , true ) ;
return elm . focus ( ) ;
}
}
if ( isHex && value !== undefined ) {
value = /^0+/ . test ( value ) ? value : parseInt ( '' + value , 16 ) || 0 ;
}
if ( value !== undefined && value !== '' && + value >= valueRange [ 0 ] && + value <= valueRange [ 1 ] ) {
if ( isHex ) {
value = value . toString ( 16 ) . toUpperCase ( ) || '0' ;
}
if ( isAlpha ) {
_colors [ type ] = + value ;
} else if ( ! isHex ) {
_colors [ type ] [ mode ] = + value / ( type === 'Lab' ? 1 : valueRange [ 1 ] ) ;
}
convertColors ( isAlpha ? 'alpha' : type ) ;
preRenderAll ( _colors ) ;
_mouseMoveAction = true ;
stopChange ( e , event . type ) ;
textNode . data = value ; // if
caret ( elm , _math . min ( elm . firstChild . data . length , rangeData . start < 0 ? 0 : rangeData . start ) ) ;
}
}
function buttonActions ( e ) {
var event = e || window . event ,
target = event . target || event . srcElement ,
targetClass = target . className ,
parent = target . parentNode ,
options = _options ,
RGB = _colors . RND . rgb ,
customBG , alphaBG ,
mode = _options . mode ,
newMode = '' ,
prefix = options . CSSPrefix ,
isModeButton = /(?:hs|rgb)/ . test ( parent . className ) && /^[HSBLRG]$/ . test (
target . firstChild ? target . firstChild . data : ''
) ,
isDblClick = /dblc/ . test ( event . type ) ,
buttonAction = '' ; // think this over again....
if ( isDblClick && ! isModeButton ) {
return ;
} else if ( targetClass . indexOf ( '-labl ' + prefix + 'labl' ) !== - 1 ) { // HSB -> HSL; CMYK -> Lab buttons
changeClass ( _nodes [ targetClass . split ( '-' ) [ 0 ] ] , prefix + 'hide' , '' ) ;
changeClass ( _nodes [ parent . className . split ( '-' ) [ 1 ] ] , prefix + 'hide' ) ;
} else if ( targetClass . indexOf ( prefix + 'butt' ) !== - 1 ) { // BUTTONS
if ( isModeButton ) { // set render modes
if ( isDblClick && _options . scale === 2 ) {
newMode = /hs/ . test ( mode . type ) ? 'rgb' : /hide/ . test ( _nodes . hsl . className ) ? 'hsv' : 'hsl' ;
newMode = newMode + '-' + newMode [ mode . type . indexOf ( mode . z ) ] ;
}
_colorPicker . setMode ( newMode ? newMode : targetClass . replace ( '-butt' , '' ) . split ( ' ' ) [ 0 ] ) ;
buttonAction = 'modeChange' ;
} else if ( /^[rgb]/ . test ( targetClass ) ) { // no vertical slider rendering in RGB mode
newMode = targetClass . split ( '-' ) [ 1 ] ;
changeClass ( _nodes . colorPicker , 'no-rgb-' + newMode ,
( options [ 'noRGB' + newMode ] = ! options [ 'noRGB' + newMode ] ) ? undefined : '' ) ;
buttonAction = 'noRGB' + newMode ;
// preRenderAll();
} else if ( target === _nodes . alpha _labl ) { // alpha button right (background of raster)
customBG = options . customBG ;
alphaBG = options . alphaBG ;
changeClass ( _nodes . colorPicker , 'alpha-bg-' + alphaBG , 'alpha-bg-' +
( alphaBG = options . alphaBG = e . data || ( alphaBG === 'w' ? ( customBG ? 'c' : 'b' ) :
alphaBG === 'c' ? 'b' : 'w' ) ) ) ;
target . firstChild . data = alphaBG . toUpperCase ( ) ;
_nodes . ctrl . style . backgroundColor = _nodes . memo . style . backgroundColor =
alphaBG !== 'c' ? '' : 'rgb(' + _math . round ( customBG . r * 255 ) + ', ' +
_math . round ( customBG . g * 255 ) + ', ' +
_math . round ( customBG . b * 255 ) + ')' ;
_nodes . raster . style . cssText = _nodes . raster _bg . previousSibling . style . cssText =
alphaBG !== 'c' ? '' : getOpacityCSS ( customBG . luminance < 0.22 ? 0.5 : 0.4 ) ;
buttonAction = 'alphaBackground' ;
} else if ( target === _nodes . alpha _butt ) { // alpha button left (disable alpha rendering)
changeClass ( _nodes . colorPicker , 'mute-alpha' , ( options . muteAlpha = ! options . muteAlpha ) ? undefined : '' ) ;
buttonAction = 'alphaState' ;
} else if ( target === _nodes . HEX _butt ) { // make it on/off
changeClass ( _nodes . colorPicker , 'no-HEX' , ( options . HEXState = ! options . HEXState ) ? undefined : '' ) ;
buttonAction = 'HEXState' ;
} else if ( target === _nodes . HEX _labl ) { // web save state change
var isWebSave = _colors . saveColor === 'web save' ;
if ( _colors . saveColor !== 'web smart' && ! isWebSave ) {
options . webUnsave = copyColor ( RGB ) ;
_colorPicker . setColor ( _colors . webSmart , 'rgb' ) ;
} else if ( ! isWebSave ) {
if ( ! options . webUnsave ) {
options . webUnsave = copyColor ( RGB ) ;
}
_colorPicker . setColor ( _colors . webSave , 'rgb' ) ;
} else {
_colorPicker . setColor ( options . webUnsave , 'rgb' ) ;
}
buttonAction = 'webColorState' ;
} else if ( /Lab-x-labl/ . test ( targetClass ) ) { //target === _nodes.cmyk_type) {
// switch between CMYK and CMY
changeClass ( _nodes . colorPicker , 'cmy-only' , ( options . cmyOnly = ! options . cmyOnly ) ? undefined : '' ) ;
buttonAction = 'cmykState' ;
}
} else if ( target === _nodes . bsav ) { // SAVE
saveAsBackground ( ) ;
buttonAction = 'saveAsBackground' ;
} else if ( target === _nodes . bres ) { // RESET
var tmpColor = copyColor ( RGB ) ,
tmpAlpha = _colors . alpha ;
// a bit heavy but... doesn't matter here
// newCol, type, alpha, forceRender
_colorPicker . setColor ( options . color ) ;
saveAsBackground ( ) ;
_colorPicker . setColor ( tmpColor , 'rgb' , tmpAlpha ) ;
buttonAction = 'resetColor' ;
} else if ( parent === _nodes . col1 ) { // COLOR left
// _colors.hsv.h = (_colors.hsv.h + 0.5) % 1; // not acurate
_colors . hsv . h -= ( _colors . hsv . h > 0.5 ? 0.5 : - 0.5 ) ;
convertColors ( 'hsv' ) ;
buttonAction = 'shiftColor' ;
} else if ( parent === _nodes . col2 ) { // COLOR right
_colorPicker . setColor ( target . style . backgroundColor , 'rgb' , _colors . background . alpha ) ;
buttonAction = 'setSavedColor' ;
} else if ( parent === _nodes . memo ) { // MEMORIES // revisit...
var resetBlink = function ( ) {
if ( _nodes . memos . blinker ) _nodes . memos . blinker . style . cssText = _nodes . memos . cssText ;
} ,
doBlink = function ( elm ) {
_nodes . memos . blinker = elm ;
elm . style . cssText = 'background-color:' + ( _colors . RGBLuminance > 0.22 ? '#333' : '#DDD' ) ;
window . setTimeout ( resetBlink , 200 ) ;
} ;
if ( target === _nodes . memo _cursor ) { // save color in memo
resetBlink ( ) ;
_nodes . memos . blinker = undefined ;
_nodes . testNode . style . cssText = _nodes . memo _store . style . cssText ;
_nodes . memos . cssText = _nodes . testNode . style . cssText ; // ...how browser sees css
for ( var n = _nodes . memos . length - 1 ; n -- ; ) { // check if color already exists
if ( _nodes . memos . cssText === _nodes . memos [ n ] . style . cssText ) {
doBlink ( _nodes . memos [ n ] ) ; // sets _nodes.memos.blinker
break ;
}
}
if ( ! _nodes . memos . blinker ) { // right shift colors
for ( var n = _nodes . memos . length - 1 ; n -- ; ) {
_nodes . memos [ n + 1 ] . style . cssText = _nodes . memos [ n ] . style . cssText ;
}
_nodes . memos [ 0 ] . style . cssText = _nodes . memo _store . style . cssText ;
}
buttonAction = 'toMemery' ;
} else { // reset color from memo
resetBlink ( ) ;
_colorPicker . setColor ( target . style . backgroundColor , 'rgb' , target . style . opacity || 1 ) ;
_nodes . memos . cssText = target . style . cssText ;
doBlink ( target ) ;
// this is dirty... has to do with M|W|! button
_mouseMoveAction = 1 ;
buttonAction = 'fromMemory' ;
}
}
// think this over again, does this need to be like this??
if ( buttonAction ) {
preRenderAll ( _colors ) ;
_mouseMoveAction = _mouseMoveAction || true ; // !!!! search for: // this is dirty...
stopChange ( e , buttonAction ) ;
}
}
function resizeApp ( e , size ) {
var event = e || window . event ,
page = event ? getPageXY ( event ) : { } ,
isSize = size !== undefined ,
x = isSize ? size : page . X - _targetOrigin . left + 8 ,
y = isSize ? size : page . Y - _targetOrigin . top + 8 ,
values = [ ' S XS XXS' , ' S XS' , ' S' , '' ] ,
sizes = _options . sizes , // from getUISizes();
currentSize = isSize ? size :
y < sizes . XXS [ 1 ] + 25 ? 0 :
x < sizes . XS [ 0 ] + 25 ? 1 :
x < sizes . S [ 0 ] + 25 || y < sizes . S [ 1 ] + 25 ? 2 : 3 ,
value = values [ currentSize ] ,
isXXS = false ,
mode ,
tmp = '' ;
if ( _cashedVars . resizer !== value ) {
isXXS = /XX/ . test ( value ) ;
mode = _options . mode ;
if ( isXXS && ( ! /hs/ . test ( mode . type ) || mode . z === 'h' ) ) {
tmp = mode . type + '-' + mode . z ;
_colorPicker . setMode ( /hs/ . test ( mode . type ) ? mode . type + '-s' : 'hsv-s' ) ;
_options . mode . original = tmp ;
} else if ( mode . original ) {
// setMode(mode) creates a new object so mode.original gets deleted automatically
_colorPicker . setMode ( mode . original ) ;
}
_nodes . colorPicker . className = _nodes . colorPicker . className . replace ( /\s+(?:S|XS|XXS)/g , '' ) + value ;
_options . scale = isXXS ? 4 : /S/ . test ( value ) ? 2 : 1 ;
_options . currentSize = currentSize ;
_cashedVars . resizer = value ;
// fix this... from this point on inside if() ... convertColors();
_newData = true ;
renderAll ( ) ;
resetCursors ( ) ;
}
_nodes . resizer . style . cssText = 'display: block;' +
'width: ' + ( x > 10 ? x : 10 ) + 'px;' +
'height: ' + ( y > 10 ? y : 10 ) + 'px;' ;
}
// ------------------------------------------------------ //
// --- Colors calculation and rendering related stuff --- //
// -------------------------------------------------------//
function setMode ( mode ) {
var ModeMatrix = {
rgb _r : { x : 'b' , y : 'g' } ,
rgb _g : { x : 'b' , y : 'r' } ,
rgb _b : { x : 'r' , y : 'g' } ,
hsv _h : { x : 's' , y : 'v' } ,
hsv _s : { x : 'h' , y : 'v' } ,
hsv _v : { x : 'h' , y : 's' } ,
hsl _h : { x : 's' , y : 'l' } ,
hsl _s : { x : 'h' , y : 'l' } ,
hsl _l : { x : 'h' , y : 's' }
} ,
key = mode . replace ( '-' , '_' ) ,
regex = '\\b(?:rg|hs)\\w\\-\\w\\b' ; // \\b\\w{3}\\-\\w\\b';
// changeClass(_nodes.colorPicker, '(?:.*?)$', mode);
// changeClass(_nodes.colorPicker, '\\b\\w{3}\\-\\w\\b', mode);
// changeClass(_nodes.slds, '\\b\\w{3}\\-\\w\\b', mode);
changeClass ( _nodes . panel , regex , mode ) ;
changeClass ( _nodes . slds , regex , mode ) ;
mode = mode . split ( '-' ) ;
return _options . mode = {
type : mode [ 0 ] ,
x : ModeMatrix [ key ] . x ,
y : ModeMatrix [ key ] . y ,
z : mode [ 1 ]
} ;
}
function initSliders ( ) { // function name...
var regex = /\s+(?:hue-)*(?:dark|light)/g ,
className = 'className' ; // minification
_nodes . curl [ className ] = _nodes . curl [ className ] . replace ( regex , '' ) ; // .....
_nodes . curr [ className ] = _nodes . curr [ className ] . replace ( regex , '' ) ; // .....
_nodes . slds [ className ] = _nodes . slds [ className ] . replace ( regex , '' ) ;
// var sldrs = ['sldr_2', 'sldr_4', 'sldl_3'];
// for (var n = sldrs.length; n--; ) {
// _nodes[sldrs[n]][className] = _options.CSSPrefix + sldrs[n].replace('_', '-');
// }
_nodes . sldr _2 [ className ] = _options . CSSPrefix + 'sldr-2' ;
_nodes . sldr _4 [ className ] = _options . CSSPrefix + 'sldr-4' ;
_nodes . sldl _3 [ className ] = _options . CSSPrefix + 'sldl-3' ;
for ( var style in _nodes . styles ) {
if ( ! style . indexOf ( 'sld' ) ) _nodes . styles [ style ] . cssText = '' ;
}
_cashedVars = { } ;
}
function resetCursors ( ) {
// _renderVars.isNoRGB = undefined;
_nodes . styles . curr . cssText = _nodes . styles . curl . cssText ; // only coordinates
_nodes . curl . className = _options . CSSPrefix + 'curl' + (
_renderVars . noRGBZ ? ' ' + _options . CSSPrefix + 'curl-' + _renderVars . noRGBZ : '' ) ;
_nodes . curr . className = _options . CSSPrefix + 'curr ' + _options . CSSPrefix + 'curr-' +
( _options . mode . z === 'h' ? _renderVars . HUEContrast : _renderVars . noRGBZ ?
_renderVars . noRGBZ : _renderVars . RGBLuminance ) ;
}
function convertColors ( type ) {
preRenderAll ( _colorInstance . setColor ( undefined , type || _options . mode . type ) ) ;
_newData = true ;
}
function saveAsBackground ( refresh ) {
_colorInstance . saveAsBackground ( ) ;
_nodes . styles . col2 . cssText = 'background-color: ' + color2string ( _colors . background . RGB ) + ';' +
getOpacityCSS ( _colors . background . alpha ) ;
if ( refresh ) {
preRenderAll ( _colors ) ;
// renderAll();
}
return ( _colors ) ;
}
function preRenderAll ( colors ) {
var _Math = _math ,
renderVars = _renderVars ,
bgType = _bgTypes [ _options . alphaBG ] ;
renderVars . hueDelta = _Math . round ( colors [ 'rgbaMixBGMix' + bgType ] . hueDelta * 100 ) ;
// renderVars.RGBLuminanceDelta = _Math.round(colors.RGBLuminanceDelta * 100);
renderVars . luminanceDelta = _Math . round ( colors [ 'rgbaMixBGMix' + bgType ] . luminanceDelta * 100 ) ;
renderVars . RGBLuminance = colors . RGBLuminance > 0.22 ? 'light' : 'dark' ;
renderVars . HUEContrast = colors . HUELuminance > 0.22 ? 'light' : 'dark' ;
// renderVars.contrast = renderVars.RGBLuminanceDelta > renderVars.hueDelta ? 'contrast' : '';
renderVars . contrast = renderVars . luminanceDelta > renderVars . hueDelta ? 'contrast' : '' ;
renderVars . readabiltiy =
colors [ 'rgbaMixBGMix' + bgType ] . WCAG2Ratio >= 7 ? 'green' :
colors [ 'rgbaMixBGMix' + bgType ] . WCAG2Ratio >= 4.5 ? 'orange' : '' ;
renderVars . noRGBZ = _options [ 'no' + _options . mode . type . toUpperCase ( ) + _options . mode . z ] ?
( _options . mode . z === 'g' && colors . rgb . g < 0.59 || _options . mode . z === 'b' || _options . mode . z === 'r' ?
'dark' : 'light' ) : undefined ;
}
function renderAll ( ) { // maybe render alpha seperately...
if ( _mouseMoveAction ) {
// _renderTimer = window[requestAnimationFrame](renderAll);
if ( ! _newData ) return ( _renderTimer = window [ requestAnimationFrame ] ( renderAll ) ) ;
_newData = false ;
}
// console.time('renderAll');
var options = _options ,
mode = options . mode ,
scale = options . scale ,
prefix = options . CSSPrefix ,
colors = _colors ,
nodes = _nodes ,
CSS = nodes . styles ,
textNodes = nodes . textNodes ,
valueRanges = _valueRanges ,
valueType = _valueType ,
renderVars = _renderVars ,
cashedVars = _cashedVars ,
_Math = _math ,
_getOpacityCSS = getOpacityCSS ,
_color2string = color2string ,
a = 0 ,
b = 0 ,
x = colors [ mode . type ] [ mode . x ] ,
X = _Math . round ( x * 255 / ( scale === 4 ? 2 : scale ) ) ,
y _ = colors [ mode . type ] [ mode . y ] ,
y = 1 - y _ ,
Y = _Math . round ( y * 255 / scale ) ,
z = 1 - colors [ mode . type ] [ mode . z ] ,
Z = _Math . round ( z * 255 / scale ) ,
coords = ( 1 === 1 ) ? [ x , y _ ] : [ 0 , 0 ] , // (1 === 2) button label up
isRGB = mode . type === 'rgb' ,
isHue = mode . z === 'h' ,
isHSL = mode . type === 'hsl' ,
isHSL _S = isHSL && mode . z === 's' ,
moveXY = _mouseMoveAction === changeXYValue ,
moveZ = _mouseMoveAction === changeZValue ,
display , tmp , value , slider ;
if ( isRGB ) {
if ( coords [ 0 ] >= coords [ 1 ] ) b = 1 ; else a = 1 ;
if ( cashedVars . sliderSwap !== a ) {
nodes . sldr _2 . className = options . CSSPrefix + 'sldr-' + ( 3 - a ) ;
cashedVars . sliderSwap = a ;
}
}
if ( ( isRGB && ! moveZ ) || ( isHue && ! moveXY ) || ( ! isHue && ! moveZ ) ) {
CSS [ isHue ? 'sldl_2' : 'sldr_2' ] [ isRGB ? 'cssText' : 'backgroundColor' ] =
isRGB ? _getOpacityCSS ( ( coords [ a ] - coords [ b ] ) / ( 1 - ( coords [ b ] ) || 0 ) ) : _color2string ( colors . hueRGB ) ;
}
if ( ! isHue ) {
if ( ! moveZ ) CSS . sldr _4 . cssText = _getOpacityCSS ( isRGB ? coords [ b ] : isHSL _S ? _Math . abs ( 1 - y * 2 ) : y ) ;
if ( ! moveXY ) CSS . sldl _3 . cssText = _getOpacityCSS ( isHSL && mode . z === 'l' ? _Math . abs ( 1 - z * 2 ) : z ) ;
if ( isHSL ) { // switch slider class name for black/white color half way through in HSL(S|L) mode(s)
slider = isHSL _S ? 'sldr_4' : 'sldl_3' ;
tmp = isHSL _S ? 'r-' : 'l-' ;
value = isHSL _S ? ( y > 0.5 ? 4 : 3 ) : ( z > 0.5 ? 3 : 4 ) ;
if ( cashedVars [ slider ] !== value ) {
nodes [ slider ] . className = options . CSSPrefix + 'sld' + tmp + value ;
cashedVars [ slider ] = value ;
}
}
}
if ( ! moveZ ) CSS . curm . cssText = 'left: ' + X + 'px; top: ' + Y + 'px;' ;
if ( ! moveXY ) CSS . curl . top = Z + 'px' ;
if ( valueType ) CSS . curr . top = Z + 'px' ; // && valueType.type !== mode.type
if ( ( valueType && valueType . type === 'alpha' ) || _mainTarget === nodes . opacity ) {
CSS . opacity _slider . left = options . opacityPositionRelative ? ( colors . alpha * (
( _targetOrigin . width || nodes . opacity . offsetWidth ) -
( _targetOrigin . childWidth || nodes . opacity _slider . offsetWidth ) ) ) + 'px' :
( colors . alpha * 100 ) + '%' ;
}
CSS . col1 . cssText = 'background-color: ' + _color2string ( colors . RND . rgb ) + '; ' +
( options . muteAlpha ? '' : _getOpacityCSS ( colors . alpha ) ) ;
CSS . opacity . backgroundColor = _color2string ( colors . RND . rgb ) ;
CSS . cold . width = renderVars . hueDelta + '%' ;
CSS . cont . width = renderVars . luminanceDelta + '%' ;
for ( display in textNodes ) {
tmp = display . split ( '_' ) ;
if ( options . cmyOnly ) {
tmp [ 0 ] = tmp [ 0 ] . replace ( 'k' , '' ) ;
}
value = tmp [ 1 ] ? colors . RND [ tmp [ 0 ] ] [ tmp [ 1 ] ] : colors . RND [ tmp [ 0 ] ] || colors [ tmp [ 0 ] ] ;
if ( cashedVars [ display ] !== value ) {
cashedVars [ display ] = value ;
textNodes [ display ] . data = value > 359.5 && display !== 'HEX' ? 0 : value ;
if ( display !== 'HEX' && ! options . noRangeBackground ) {
value = colors [ tmp [ 0 ] ] [ tmp [ 1 ] ] !== undefined ? colors [ tmp [ 0 ] ] [ tmp [ 1 ] ] : colors [ tmp [ 0 ] ] ;
if ( tmp [ 0 ] === 'Lab' ) {
value = ( value - valueRanges [ tmp [ 0 ] ] [ tmp [ 1 ] ] [ 0 ] ) /
( valueRanges [ tmp [ 0 ] ] [ tmp [ 1 ] ] [ 1 ] - valueRanges [ tmp [ 0 ] ] [ tmp [ 1 ] ] [ 0 ] ) ;
}
CSS [ display ] . backgroundPosition = _Math . round ( ( 1 - value ) * 100 ) + '% 0%' ;
}
}
}
// Lab out of gammut
tmp = colors . _rgb ? [
colors . _rgb . r !== colors . rgb . r ,
colors . _rgb . g !== colors . rgb . g ,
colors . _rgb . b !== colors . rgb . b
] : [ ] ;
if ( tmp . join ( '' ) !== cashedVars . outOfGammut ) {
nodes . rgb _r _labl . firstChild . data = tmp [ 0 ] ? '!' : ' ' ;
nodes . rgb _g _labl . firstChild . data = tmp [ 1 ] ? '!' : ' ' ;
nodes . rgb _b _labl . firstChild . data = tmp [ 2 ] ? '!' : ' ' ;
cashedVars . outOfGammut = tmp . join ( '' ) ;
}
if ( renderVars . noRGBZ ) {
if ( cashedVars . noRGBZ !== renderVars . noRGBZ ) {
nodes . curl . className = prefix + 'curl ' + prefix + 'curl-' + renderVars . noRGBZ ;
if ( ! moveZ ) {
nodes . curr . className = prefix + 'curr ' + prefix + 'curr-' + renderVars . noRGBZ ;
}
cashedVars . noRGBZ = renderVars . noRGBZ ;
}
}
if ( cashedVars . HUEContrast !== renderVars . HUEContrast && mode . z === 'h' ) {
nodes . slds . className = nodes . slds . className . replace ( /\s+hue-(?:dark|light)/ , '' ) +
' hue-' + renderVars . HUEContrast ;
if ( ! moveZ ) {
nodes . curr . className = prefix + 'curr ' + prefix + 'curr-' + renderVars . HUEContrast ;
}
cashedVars . HUEContrast = renderVars . HUEContrast ;
} else if ( cashedVars . RGBLuminance !== renderVars . RGBLuminance ) { // test for no else
nodes . colorPicker . className = nodes . colorPicker . className . replace ( /\s+(?:dark|light)/ , '' ) +
' ' + renderVars . RGBLuminance ;
if ( ! moveZ && mode . z !== 'h' && ! renderVars . noRGBZ ) {
nodes . curr . className = prefix + 'curr ' + prefix + 'curr-' + renderVars . RGBLuminance ;
}
cashedVars . RGBLuminance = renderVars . RGBLuminance ;
}
if ( cashedVars . contrast !== renderVars . contrast || cashedVars . readabiltiy !== renderVars . readabiltiy ) {
nodes . ctrl . className = nodes . ctrl . className . replace ( ' contrast' , '' ) . replace ( /\s*(?:orange|green)/ , '' ) +
( renderVars . contrast ? ' ' + renderVars . contrast : '' ) +
( renderVars . readabiltiy ? ' ' + renderVars . readabiltiy : '' ) ;
cashedVars . contrast = renderVars . contrast ;
cashedVars . readabiltiy = renderVars . readabiltiy ;
}
if ( cashedVars . saveColor !== colors . saveColor ) {
nodes . HEX _labl . firstChild . data = ! colors . saveColor ? '!' : colors . saveColor === 'web save' ? 'W' : 'M' ;
cashedVars . saveColor = colors . saveColor ;
}
if ( options . renderCallback ) {
options . renderCallback ( colors , mode ) ; // maybe more parameters
}
if ( _mouseMoveAction ) {
_renderTimer = window [ requestAnimationFrame ] ( renderAll ) ;
}
// console.timeEnd('renderAll')
}
// ------------------------------------------------------ //
// ------------------ helper functions ------------------ //
// -------------------------------------------------------//
function copyColor ( color ) {
var newColor = { } ;
for ( var n in color ) {
newColor [ n ] = color [ n ] ;
}
return newColor ;
}
// function color2string(color, type) {
// var out = [],
// n = 0;
// type = type || 'rgb';
// while (type.charAt(n)) { // IE7 // V8 type[n] ||
// out.push(color[type.charAt(n)]);
// n++;
// }
// return type + '(' + out.join(', ') + ')';
// }
function color2string ( color , type ) { // ~2 x faster on V8
var out = '' ,
t = ( type || 'rgb' ) . split ( '' ) ,
n = t . length ;
for ( ; n -- ; ) {
out = ', ' + color [ t [ n ] ] + out ;
}
return ( type || 'rgb' ) + '(' + out . substr ( 2 ) + ')' ;
}
function limitValue ( value , min , max ) {
// return Math.max(min, Math.min(max, value)); // faster??
return ( value > max ? max : value < min ? min : value ) ;
}
function getOpacityCSS ( value ) {
if ( value === undefined ) value = 1 ;
if ( _doesOpacity ) {
return 'opacity: ' + ( _math . round ( value * 10000000000 ) / 10000000000 ) + ';' ; // value.toFixed(16) = 99% slower
// some speed test:
// return ['opacity: ', (Math.round(value * 1e+10) / 1e+10), ';'].join('');
} else {
return 'filter: alpha(opacity=' + _math . round ( value * 100 ) + ');' ;
}
}
function preventDefault ( e , skip ) {
e . preventDefault ? e . preventDefault ( ) : e . returnValue = false ;
if ( ! skip ) window . getSelection ? window . getSelection ( ) . removeAllRanges ( ) : document . selection . empty ( ) ;
return false ;
}
function changeClass ( elm , cln , newCln ) {
return ! elm ? false : elm . className = ( newCln !== undefined ?
elm . className . replace ( new RegExp ( '\\s+?' + cln , 'g' ) , newCln ? ' ' + newCln : '' ) :
elm . className + ' ' + cln ) ;
}
function getOrigin ( elm ) {
var box = ( elm . getBoundingClientRect ) ? elm . getBoundingClientRect ( ) : { top : 0 , left : 0 } ,
doc = elm && elm . ownerDocument ,
body = doc . body ,
win = doc . defaultView || doc . parentWindow || window ,
docElem = doc . documentElement || body . parentNode ,
clientTop = docElem . clientTop || body . clientTop || 0 , // border on html or body or both
clientLeft = docElem . clientLeft || body . clientLeft || 0 ;
return {
left : box . left + ( win . pageXOffset || docElem . scrollLeft ) - clientLeft ,
top : box . top + ( win . pageYOffset || docElem . scrollTop ) - clientTop
} ;
}
function getPageXY ( e ) {
var doc = window . document ;
return {
X : e . pageX || e . clientX + doc . body . scrollLeft + doc . documentElement . scrollLeft ,
Y : e . pageY || e . clientY + doc . body . scrollTop + doc . documentElement . scrollTop
} ;
}
function addEvent ( obj , type , func ) {
addEvent . cache = addEvent . cache || {
_get : function ( obj , type , func , checkOnly ) {
var cache = addEvent . cache [ type ] || [ ] ;
for ( var n = cache . length ; n -- ; ) {
if ( obj === cache [ n ] . obj && '' + func === '' + cache [ n ] . func ) {
func = cache [ n ] . func ;
if ( ! checkOnly ) {
cache [ n ] = cache [ n ] . obj = cache [ n ] . func = null ;
cache . splice ( n , 1 ) ;
}
return func ;
}
}
} ,
_set : function ( obj , type , func ) {
var cache = addEvent . cache [ type ] = addEvent . cache [ type ] || [ ] ;
if ( addEvent . cache . _get ( obj , type , func , true ) ) {
return true ;
} else {
cache . push ( {
func : func ,
obj : obj
} ) ;
}
}
} ;
if ( ! func . name && addEvent . cache . _set ( obj , type , func ) || typeof func !== 'function' ) {
return ;
}
if ( obj . addEventListener ) obj . addEventListener ( type , func , false ) ;
else obj . attachEvent ( 'on' + type , func ) ;
}
function removeEvent ( obj , type , func ) {
if ( typeof func !== 'function' ) return ;
if ( ! func . name ) {
func = addEvent . cache . _get ( obj , type , func ) || func ;
}
if ( obj . removeEventListener ) obj . removeEventListener ( type , func , false ) ;
else obj . detachEvent ( 'on' + type , func ) ;
}
function caret ( target , pos ) { // only for contenteditable
var out = { } ;
if ( pos === undefined ) { // get
if ( window . getSelection ) { // HTML5
target . focus ( ) ;
var range1 = window . getSelection ( ) . getRangeAt ( 0 ) ,
range2 = range1 . cloneRange ( ) ;
range2 . selectNodeContents ( target ) ;
range2 . setEnd ( range1 . endContainer , range1 . endOffset ) ;
out = {
end : range2 . toString ( ) . length ,
range : range1 . toString ( ) . length
} ;
} else { // IE < 9
target . focus ( ) ;
var range1 = document . selection . createRange ( ) ,
range2 = document . body . createTextRange ( ) ;
range2 . moveToElementText ( target ) ;
range2 . setEndPoint ( 'EndToEnd' , range1 ) ;
out = {
end : range2 . text . length ,
range : range1 . text . length
} ;
}
out . start = out . end - out . range ;
return out ;
}
// set
if ( pos == - 1 ) pos = target [ 'text' ] ( ) . length ;
if ( window . getSelection ) { // HTML5
target . focus ( ) ;
window . getSelection ( ) . collapse ( target . firstChild , pos ) ;
} else { // IE < 9
var range = document . body . createTextRange ( ) ;
range . moveToElementText ( target ) ;
range . moveStart ( 'character' , pos ) ;
range . collapse ( true ) ;
range . select ( ) ;
}
return pos ;
}
// ------------- requestAnimationFrame shim ------------- //
// ---------- quite optimized for minification ---------- //
for ( var n = vendors . length ; n -- && ! window [ requestAnimationFrame ] ; ) {
window [ requestAnimationFrame ] = window [ vendors [ n ] + 'Request' + animationFrame ] ;
window [ cancelAnimationFrame ] = window [ vendors [ n ] + 'Cancel' + animationFrame ] ||
window [ vendors [ n ] + 'CancelRequest' + animationFrame ] ;
}
window [ requestAnimationFrame ] = window [ requestAnimationFrame ] || function ( callback ) {
// this is good enough... and better than setTimeout
return window . setTimeout ( callback , 1000 / _options . fps ) ;
// return _renderTimer ? _renderTimer : window.setInterval(callback, 1000 / _options.fps);
} ;
window [ cancelAnimationFrame ] = window [ cancelAnimationFrame ] || function ( id ) {
// console.log('OFF-', id + '-' + _renderTimer)
window . clearTimeout ( id ) ;
return _renderTimer = null ;
} ;
} ) ( window ) ;
2016-04-13 07:26:35 +00:00
( function ( window ) {
window . jsColorPicker = function ( selectors , config ) {
var renderCallback = function ( colors , mode ) {
var options = this ,
input = options . input ,
patch = options . patch ,
RGB = colors . RND . rgb ,
HSL = colors . RND . hsl ,
AHEX = options . isIE8 ? ( colors . alpha < 0.16 ? '0' : '' ) +
( Math . round ( colors . alpha * 100 ) ) . toString ( 16 ) . toUpperCase ( ) + colors . HEX : '' ,
RGBInnerText = RGB . r + ', ' + RGB . g + ', ' + RGB . b ,
RGBAText = 'rgba(' + RGBInnerText + ', ' + colors . alpha + ')' ,
isAlpha = colors . alpha !== 1 && ! options . isIE8 ,
colorMode = input . getAttribute ( 'data-colorMode' ) ;
patch . style . cssText =
'color:' + ( colors . rgbaMixCustom . luminance > 0.22 ? '#222' : '#ddd' ) + ';' + // Black...???
'background-color:' + RGBAText + ';' +
'filter:' + ( options . isIE8 ? 'progid:DXImageTransform.Microsoft.gradient(' + // IE<9
'startColorstr=#' + AHEX + ',' + 'endColorstr=#' + AHEX + ')' : '' ) ;
input . value = ( colorMode === 'HEX' && ! isAlpha ? '#' + ( options . isIE8 ? AHEX : colors . HEX ) :
colorMode === 'rgb' || ( colorMode === 'HEX' && isAlpha ) ?
( ! isAlpha ? 'rgb(' + RGBInnerText + ')' : RGBAText ) :
( 'hsl' + ( isAlpha ? 'a(' : '(' ) + HSL . h + ', ' + HSL . s + '%, ' + HSL . l + '%' +
( isAlpha ? ', ' + colors . alpha : '' ) + ')' )
) ;
if ( options . displayCallback ) {
options . displayCallback ( colors , mode , options ) ;
}
} ,
extractValue = function ( elm ) {
return elm . value || elm . getAttribute ( 'value' ) || elm . style . backgroundColor || '#FFFFFF' ;
} ,
actionCallback = function ( event , action ) {
var options = this ,
colorPicker = colorPickers . current ;
if ( action === 'toMemory' ) {
var memos = colorPicker . nodes . memos ,
backgroundColor = '' ,
opacity = 0 ,
cookieTXT = [ ] ;
for ( var n = 0 , m = memos . length ; n < m ; n ++ ) {
backgroundColor = memos [ n ] . style . backgroundColor ;
opacity = memos [ n ] . style . opacity ;
opacity = Math . round ( ( opacity === '' ? 1 : opacity ) * 100 ) / 100 ;
cookieTXT . push ( backgroundColor .
replace ( /, /g , ',' ) .
replace ( 'rgb(' , 'rgba(' ) .
replace ( ')' , ',' + opacity + ')' )
) ;
}
cookieTXT = '\'' + cookieTXT . join ( '\',\'' ) + '\'' ;
ColorPicker . docCookies ( 'colorPickerMemos' + ( options . noAlpha ? 'NoAlpha' : '' ) , cookieTXT ) ;
} else if ( action === 'resizeApp' ) {
ColorPicker . docCookies ( 'colorPickerSize' , colorPicker . color . options . currentSize ) ;
} else if ( action === 'modeChange' ) {
var mode = colorPicker . color . options . mode ;
ColorPicker . docCookies ( 'colorPickerMode' , mode . type + '-' + mode . z ) ;
}
} ,
createInstance = function ( elm , config ) {
var initConfig = {
klass : window . ColorPicker ,
input : elm ,
patch : elm ,
isIE8 : ! ! document . all && ! document . addEventListener , // Opera???
// *** animationSpeed: 200,
// *** draggable: true,
margin : { left : - 1 , top : 2 } ,
customBG : '#FFFFFF' ,
// displayCallback: displayCallback,
/* --- regular colorPicker options from this point --- */
color : extractValue ( elm ) ,
initStyle : 'display: block' ,
mode : ColorPicker . docCookies ( 'colorPickerMode' ) || 'hsv-h' ,
// memoryColors: (function(colors, config) {
// return config.noAlpha ?
// colors.replace(/\,\d*\.*\d*\)/g, ',1)') : colors;
// })($.docCookies('colorPickerMemos'), config || {}),
memoryColors : ColorPicker . docCookies ( 'colorPickerMemos' +
( ( config || { } ) . noAlpha ? 'NoAlpha' : '' ) ) ,
size : ColorPicker . docCookies ( 'colorPickerSize' ) || 1 ,
renderCallback : renderCallback ,
actionCallback : actionCallback
} ;
for ( var n in config ) {
initConfig [ n ] = config [ n ] ;
}
return new initConfig . klass ( initConfig ) ;
} ,
doEventListeners = function ( elm , multiple , off ) {
var onOff = off ? 'removeEventListener' : 'addEventListener' ,
focusListener = function ( e ) {
var input = this ,
position = window . ColorPicker . getOrigin ( input ) ,
index = multiple ? Array . prototype . indexOf . call ( elms , this ) : 0 ,
colorPicker = colorPickers [ index ] ||
( colorPickers [ index ] = createInstance ( this , config ) ) ,
options = colorPicker . color . options ,
colorPickerUI = colorPicker . nodes . colorPicker ;
options . color = extractValue ( elm ) ; // brings color to default on reset
colorPickerUI . style . cssText =
'position: absolute;' +
'left:' + ( position . left + options . margin . left ) + 'px;' +
'top:' + ( position . top + + input . offsetHeight + options . margin . top ) + 'px;' ;
if ( ! multiple ) {
options . input = elm ;
options . patch = elm ; // check again???
colorPicker . setColor ( extractValue ( elm ) , undefined , undefined , true ) ;
colorPicker . saveAsBackground ( ) ;
}
colorPickers . current = colorPickers [ index ] ;
( options . appendTo || document . body ) . appendChild ( colorPickerUI ) ;
setTimeout ( function ( ) { // compensating late style on onload in colorPicker
colorPickerUI . style . display = 'block' ;
} , 0 ) ;
} ,
mousDownListener = function ( e ) {
var colorPicker = colorPickers . current ,
colorPickerUI = ( colorPicker ? colorPicker . nodes . colorPicker : undefined ) ,
animationSpeed = colorPicker ? colorPicker . color . options . animationSpeed : 0 ,
isColorPicker = colorPicker && ( function ( elm ) {
while ( elm ) {
if ( ( elm . className || '' ) . indexOf ( 'cp-app' ) !== - 1 ) return elm ;
elm = elm . parentNode ;
}
return false ;
} ) ( e . target ) ,
inputIndex = Array . prototype . indexOf . call ( elms , e . target ) ;
if ( isColorPicker && Array . prototype . indexOf . call ( colorPickers , isColorPicker ) ) {
if ( e . target === colorPicker . nodes . exit ) {
//colorPickerUI.style.display = 'none';
//document.activeElement.blur();
} else {
// ...
}
} else if ( inputIndex !== - 1 ) {
// ...
} else if ( colorPickerUI ) {
//colorPickerUI.style.display = 'none';
}
} ;
elm [ onOff ] ( 'focus' , focusListener ) ;
if ( ! colorPickers . evt || off ) {
colorPickers . evt = true ; // prevent new eventListener for window
window [ onOff ] ( 'mousedown' , mousDownListener ) ;
}
} ,
// this is a way to prevent data binding on HTMLElements
colorPickers = window . jsColorPicker . colorPickers || [ ] ,
elms = document . querySelectorAll ( selectors ) ,
testColors = new window . Colors ( { customBG : config . customBG , allMixDetails : true } ) ;
window . jsColorPicker . colorPickers = colorPickers ;
for ( var n = 0 , m = elms . length ; n < m ; n ++ ) {
var elm = elms [ n ] ;
if ( config === 'destroy' ) {
doEventListeners ( elm , ( config && config . multipleInstances ) , true ) ;
if ( colorPickers [ n ] ) {
colorPickers [ n ] . destroyAll ( ) ;
}
} else {
var color = extractValue ( elm ) ;
var value = color . split ( '(' ) ;
testColors . setColor ( color ) ;
if ( config && config . init ) {
config . init ( elm , testColors . colors ) ;
}
elm . setAttribute ( 'data-colorMode' , value [ 1 ] ? value [ 0 ] . substr ( 0 , 3 ) : 'HEX' ) ;
doEventListeners ( elm , ( config && config . multipleInstances ) , false ) ;
if ( config && config . readOnly ) {
elm . readOnly = true ;
}
}
} ;
return window . jsColorPicker . colorPickers ;
} ;
window . ColorPicker . docCookies = function ( key , val , options ) {
var encode = encodeURIComponent , decode = decodeURIComponent ,
cookies , n , tmp , cache = { } ,
days ;
if ( val === undefined ) { // all about reading cookies
cookies = document . cookie . split ( /;\s*/ ) || [ ] ;
for ( n = cookies . length ; n -- ; ) {
tmp = cookies [ n ] . split ( '=' ) ;
if ( tmp [ 0 ] ) cache [ decode ( tmp . shift ( ) ) ] = decode ( tmp . join ( '=' ) ) ; // there might be '='s in the value...
}
if ( ! key ) return cache ; // return Json for easy access to all cookies
else return cache [ key ] ; // easy access to cookies from here
} else { // write/delete cookie
options = options || { } ;
if ( val === '' || options . expires < 0 ) { // prepare deleteing the cookie
options . expires = - 1 ;
// options.path = options.domain = options.secure = undefined; // to make shure the cookie gets deleted...
}
if ( options . expires !== undefined ) { // prepare date if any
days = new Date ( ) ;
days . setDate ( days . getDate ( ) + options . expires ) ;
}
document . cookie = encode ( key ) + '=' + encode ( val ) +
( days ? '; expires=' + days . toUTCString ( ) : '' ) +
( options . path ? '; path=' + options . path : '' ) +
( options . domain ? '; domain=' + options . domain : '' ) +
( options . secure ? '; secure' : '' ) ;
}
} ;
} ) ( this ) ;
2016-04-13 00:53:28 +00:00
/ *
chroma . js - JavaScript library for color conversions
Copyright ( c ) 2011 - 2015 , Gregor Aisch
All rights reserved .
Redistribution and use in source and binary forms , with or without
modification , are permitted provided that the following conditions are met :
1. Redistributions of source code must retain the above copyright notice , this
list of conditions and the following disclaimer .
2. Redistributions in binary form must reproduce the above copyright notice ,
this list of conditions and the following disclaimer in the documentation
and / or other materials provided with the distribution .
3. The name Gregor Aisch may not be used to endorse or promote products
derived from this software without specific prior written permission .
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED . IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT ,
INDIRECT , INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING ,
BUT NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE ,
DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT ( INCLUDING
NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE ,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
* /
( function ( ) { var a , b , c , d , e , f , g , h , i , j , k , l , m , n , o , p , q , r , s , t , u , v , w , x , y , z , A , B , C , D , E , F , G , H , I , J , K , L , M , N , O , P , Q , R , S , T , U , V , W , X , Y , Z , $ , _ , aa , ba , ca , da , ea , fa , ga , ha , ia , ja , ka , la , ma , na , oa , pa , qa , ra , sa , ta , ua , va , wa , xa , ya , za = [ ] . slice ; ua = function ( ) { var a , b , c , d , e ; for ( a = { } , e = "Boolean Number String Function Array Date RegExp Undefined Null" . split ( " " ) , d = 0 , b = e . length ; b > d ; d ++ ) c = e [ d ] , a [ "[object " + c + "]" ] = c . toLowerCase ( ) ; return function ( b ) { var c ; return c = Object . prototype . toString . call ( b ) , a [ c ] || "object" } } ( ) , S = function ( a , b , c ) { return null == b && ( b = 0 ) , null == c && ( c = 1 ) , b > a && ( a = b ) , a > c && ( a = c ) , a } , va = function ( a ) { return a . length >= 3 ? [ ] . slice . call ( a ) : a [ 0 ] } , t = function ( a ) { var b ; for ( b in a ) 3 > b ? ( a [ b ] < 0 && ( a [ b ] = 0 ) , a [ b ] > 255 && ( a [ b ] = 255 ) ) : 3 === b && ( a [ b ] < 0 && ( a [ b ] = 0 ) , a [ b ] > 1 && ( a [ b ] = 1 ) ) ; return a } , d = Math . PI , pa = Math . round , w = Math . cos , B = Math . floor , _ = Math . pow , T = Math . log , ra = Math . sin , sa = Math . sqrt , m = Math . atan2 , W = Math . max , l = Math . abs , g = 2 * d , e = d / 3 , b = d / 180 , f = 180 / d , s = function ( ) { return arguments [ 0 ] instanceof a ? arguments [ 0 ] : function ( a , b , c ) { c . prototype = a . prototype ; var d = new c , e = a . apply ( d , b ) ; return Object ( e ) === e ? e : d } ( a , arguments , function ( ) { } ) } , k = [ ] , "undefined" != typeof module && null !== module && null != module . exports && ( module . exports = s ) , "function" == typeof define && define . amd ? define ( [ ] , function ( ) { return s } ) : ( oa = "undefined" != typeof exports && null !== exports ? exports : this , oa . chroma = s ) , s . version = "1.1.1" , j = { } , h = [ ] , i = ! 1 , a = function ( ) { function a ( ) { var a , b , c , d , e , f , g , k , l ; for ( f = this , b = [ ] , k = 0 , d = arguments . length ; d > k ; k ++ ) a = arguments [ k ] , null != a && b . push ( a ) ; if ( g = b [ b . length - 1 ] , null != j [ g ] ) f . _rgb = t ( j [ g ] ( va ( b . slice ( 0 , - 1 ) ) ) ) ; else { for ( i || ( h = h . sort ( function ( a , b ) { return b . p - a . p } ) , i = ! 0 ) , l = 0 , e = h . length ; e > l && ( c = h [ l ] , ! ( g = c . test . apply ( c , b ) ) ) ; l ++ ) ; g && ( f . _rgb = t ( j [ g ] . apply ( j , b ) ) ) } null == f . _rgb && console . warn ( "unknown format: " + b ) , null == f . _rgb && ( f . _rgb = [ 0 , 0 , 0 ] ) , 3 === f . _rgb . length && f . _rgb . push ( 1 ) } return a . prototype . alpha = function ( a ) { return arguments . length ? ( this . _rgb [ 3 ] = a , this ) : this . _rgb [ 3 ] } , a . prototype . toString = function ( ) { return this . name ( ) } , a } ( ) , s . _input = j , s . brewer = q = { OrRd : [ "#fff7ec" , "#fee8c8" , "#fdd49e" , "#fdbb84" , "#fc8d59" , "#ef6548" , "#d7301f" , "#b30000" , "#7f0000" ] , PuBu : [ "#fff7fb" , "#ece7f2" , "#d0d1e6" , "#a6bddb" , "#74a9cf" , "#3690c0" , "#0570b0" , "#045a8d" , "#023858" ] , BuPu : [ "#f7fcfd" , "#e0ecf4" , "#bfd3e6" , "#9ebcda" , "#8c96c6" , "#8c6bb1" , "#88419d" , "#810f7c" , "#4d004b" ] , Oranges : [ "#fff5eb" , "#fee6ce" , "#fdd0a2" , "#fdae6b" , "#fd8d3c" , "#f16913" , "#d94801" , "#a63603" , "#7f2704" ] , BuGn : [ "#f7fcfd" , "#e5f5f9" , "#ccece6" , "#99d8c9" , "#66c2a4" , "#41ae76" , "#238b45" , "#006d2c" , "#00441b" ] , YlOrBr : [ "#ffffe5" , "#fff7bc" , "#fee391" , "#fec44f" , "#fe9929" , "#ec7014" , "#cc4c02" , "#993404" , "#662506" ] , YlGn : [ "#ffffe5" , "#f7fcb9" , "#d9f0a3" , "#addd8e" , "#78c679" , "#41ab5d" , "#238443" , "#006837" , "#004529" ] , Reds : [ "#fff5f0" , "#fee0d2" , "#fcbba1" , "#fc9272" , "#fb6a4a" , "#ef3b2c" , "#cb181d" , "#a50f15" , "#67000d" ] , RdPu : [ "#fff7f3" , "#fde0dd" , "#fcc5c0" , "#fa9fb5" , "#f768a1" , "#dd3497" , "#ae017e" , "#7a0177" , "#49006a" ] , Greens : [ "#f7fcf5" , "#e5f5e0" , "#c7e9c0" , "#a1d99b" , "#74c476" , "#41ab5d" , "#238b45" , "#006d2c" , "#00441b" ] , YlGnBu : [ "#ffffd9" , "#edf8b1" , "#c7e9b4" , "#7fcdbb" , "#41b6c4" , "#1d91c0" , "#225ea8" , "#253494" , "#081d58" ] , Purples : [ "#fcfbfd" , "#efedf5" , "#dadaeb" , "#bcbddc" , "#9e9ac8" , "#807dba" , "#6a51a3" , "#54278f" , "#3f007d" ] , GnBu : [ "#f7fcf0" , "#e0f3db" , "#ccebc5" , "#a8ddb5" , "#7bccc4" , "#4eb3d3" , "#2b8cbe" , "#0868ac" , "#084081" ] , Greys : [ "#ffffff" , "#f0f0f0" , "#d9d9d9" , "#bdbdbd" , "#969696" , "#737373" , "#525252" , "#252525" , "#000000" ] , YlOrRd : [ "#ffffcc" , "#ffeda0" , "#fed976" , "#feb24c" , "#fd8d3c" , "#fc4e2a" , "#e31a1c" , "#bd0026" , "#800026" ] , PuRd : [ "#f7f4f9" , "#e7e1ef" , "#d4b9da" , "#c994c7" , "#df65b0" , "#e7298a" , "#ce1256" , "#980043" , "#67001f" ] , Blues : [ "#f7fbff" , "#deebf7" , "#c6dbef" , "#9ecae1" , "#6baed6" , "#4292c6" , "#2171b5" , "#08519c" , "#08306b" ] , PuBuGn : [ "#fff7fb" , "#ece2f0" , "#d0d1e6" , "#a6bddb" , "#67a9cf" , "#3690c0" , "#02818a" , "#016c59" , "#014636" ] , Spectral : [ "#9e0142" , "#d53e4f" , "#f46d43" , "#fdae61" , "#fee08b" , "#ffffbf" , "#e6f598" , "#abdda4" , "#66c2a5" , "#3288bd" , "#5e4fa2" ] , RdYlGn : [ "#a50026" , "#d73027" , "#f46d43" , "#fdae61" , "#fee08b" , "#ffffbf" , "#d9ef8b" , "#a6d96a" , "#66bd63" , "#1a9850" , "#006837" ] , RdBu : [ "#67001f" , "#b2182b" , "#d6604d" , "#f4a582" , "#fddbc7" , "#f7f7f7" , "#d1e5f0" , "#92c5de" , "#4393c3" , "#2166ac" , " # 05306
} , k . push ( [ "lab" , J ] ) } ) . call ( this ) ;
2016-04-19 03:44:31 +00:00
//fgnass.github.com/spin.js#v2.0.1
! function ( a , b ) { "object" == typeof exports ? module . exports = b ( ) : "function" == typeof define && define . amd ? define ( b ) : a . Spinner = b ( ) } ( this , function ( ) { "use strict" ; function a ( a , b ) { var c , d = document . createElement ( a || "div" ) ; for ( c in b ) d [ c ] = b [ c ] ; return d } function b ( a ) { for ( var b = 1 , c = arguments . length ; c > b ; b ++ ) a . appendChild ( arguments [ b ] ) ; return a } function c ( a , b , c , d ) { var e = [ "opacity" , b , ~ ~ ( 100 * a ) , c , d ] . join ( "-" ) , f = . 01 + c / d * 100 , g = Math . max ( 1 - ( 1 - a ) / b * ( 100 - f ) , a ) , h = j . substring ( 0 , j . indexOf ( "Animation" ) ) . toLowerCase ( ) , i = h && "-" + h + "-" || "" ; return l [ e ] || ( m . insertRule ( "@" + i + "keyframes " + e + "{0%{opacity:" + g + "}" + f + "%{opacity:" + a + "}" + ( f + . 01 ) + "%{opacity:1}" + ( f + b ) % 100 + "%{opacity:" + a + "}100%{opacity:" + g + "}}" , m . cssRules . length ) , l [ e ] = 1 ) , e } function d ( a , b ) { var c , d , e = a . style ; for ( b = b . charAt ( 0 ) . toUpperCase ( ) + b . slice ( 1 ) , d = 0 ; d < k . length ; d ++ ) if ( c = k [ d ] + b , void 0 !== e [ c ] ) return c ; return void 0 !== e [ b ] ? b : void 0 } function e ( a , b ) { for ( var c in b ) a . style [ d ( a , c ) || c ] = b [ c ] ; return a } function f ( a ) { for ( var b = 1 ; b < arguments . length ; b ++ ) { var c = arguments [ b ] ; for ( var d in c ) void 0 === a [ d ] && ( a [ d ] = c [ d ] ) } return a } function g ( a , b ) { return "string" == typeof a ? a : a [ b % a . length ] } function h ( a ) { this . opts = f ( a || { } , h . defaults , n ) } function i ( ) { function c ( b , c ) { return a ( "<" + b + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">' , c ) } m . addRule ( ".spin-vml" , "behavior:url(#default#VML)" ) , h . prototype . lines = function ( a , d ) { function f ( ) { return e ( c ( "group" , { coordsize : k + " " + k , coordorigin : - j + " " + - j } ) , { width : k , height : k } ) } function h ( a , h , i ) { b ( m , b ( e ( f ( ) , { rotation : 360 / d . lines * a + "deg" , left : ~ ~ h } ) , b ( e ( c ( "roundrect" , { arcsize : d . corners } ) , { width : j , height : d . width , left : d . radius , top : - d . width >> 1 , filter : i } ) , c ( "fill" , { color : g ( d . color , a ) , opacity : d . opacity } ) , c ( "stroke" , { opacity : 0 } ) ) ) ) } var i , j = d . length + d . width , k = 2 * j , l = 2 * - ( d . width + d . length ) + "px" , m = e ( f ( ) , { position : "absolute" , top : l , left : l } ) ; if ( d . shadow ) for ( i = 1 ; i <= d . lines ; i ++ ) h ( i , - 2 , "progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)" ) ; for ( i = 1 ; i <= d . lines ; i ++ ) h ( i ) ; return b ( a , m ) } , h . prototype . opacity = function ( a , b , c , d ) { var e = a . firstChild ; d = d . shadow && d . lines || 0 , e && b + d < e . childNodes . length && ( e = e . childNodes [ b + d ] , e = e && e . firstChild , e = e && e . firstChild , e && ( e . opacity = c ) ) } } var j , k = [ "webkit" , "Moz" , "ms" , "O" ] , l = { } , m = function ( ) { var c = a ( "style" , { type : "text/css" } ) ; return b ( document . getElementsByTagName ( "head" ) [ 0 ] , c ) , c . sheet || c . styleSheet } ( ) , n = { lines : 12 , length : 7 , width : 5 , radius : 10 , rotate : 0 , corners : 1 , color : "#000" , direction : 1 , speed : 1 , trail : 100 , opacity : . 25 , fps : 20 , zIndex : 2e9 , className : "spinner" , top : "50%" , left : "50%" , position : "absolute" } ; h . defaults = { } , f ( h . prototype , { spin : function ( b ) { this . stop ( ) ; { var c = this , d = c . opts , f = c . el = e ( a ( 0 , { className : d . className } ) , { position : d . position , width : 0 , zIndex : d . zIndex } ) ; d . radius + d . length + d . width } if ( e ( f , { left : d . left , top : d . top } ) , b && b . insertBefore ( f , b . firstChild || null ) , f . setAttribute ( "role" , "progressbar" ) , c . lines ( f , c . opts ) , ! j ) { var g , h = 0 , i = ( d . lines - 1 ) * ( 1 - d . direction ) / 2 , k = d . fps , l = k / d . speed , m = ( 1 - d . opacity ) / ( l * d . trail / 100 ) , n = l / d . lines ; ! function o ( ) { h ++ ; for ( var a = 0 ; a < d . lines ; a ++ ) g = Math . max ( 1 - ( h + ( d . lines - a ) * n ) % l * m , d . opacity ) , c . opacity ( f , a * d . direction + i , g , d ) ; c . timeout = c . el && setTimeout ( o , ~ ~ ( 1e3 / k ) ) } ( ) } return c } , stop : function ( ) { var a = this . el ; return a && ( clearTimeout ( this . timeout ) , a . parentNode && a . parentNode . removeChild ( a ) , this . el = void 0 ) , this } , lines : function ( d , f ) { function h ( b , c ) { return e ( a ( ) , { position : "absolute" , width : f . length + f . width + "px" , height : f . width + "px" , background : b , boxShadow : c , transformOrigin : "left" , transform : "rotate(" + ~ ~ ( 360 / f . lines * k + f . rotate ) + "deg) translate(" + f . radius + "px,0)" , borderRadius : ( f . corners * f . width >> 1 ) + "px" } ) } for ( var i , k = 0 , l = ( f . lines - 1 ) * ( 1 - f . direction ) / 2 ; k < f . lines ; k ++ ) i = e ( a ( ) , { position : "absolute" , top : 1 + ~ ( f . width / 2 ) + "px" , transform : f . hwaccel ? "translate3d(0,0,0)" : "" , opacity : f . opacity , animation : j && c ( f . opacity , f . trail , l + k * f . direction , f . lines ) + " " + 1 / f . speed + "s linear infinite" } ) , f . shadow && b ( i , e ( h ( "#000" , "0 0 4px #000" ) , { top : "2px" } ) ) , b ( d , b ( i , h ( g ( f . color , k ) , "0 0 1px rgba(0,0,0,.1)" ) ) ) ; return d } , opacity : function ( a , b , c ) { b < a . childNodes . length && ( a . childNodes [ b ] . style . opacity = c ) } } ) ; var o = e ( a ( "group" ) , { behavior : "url(#default#VML)" } ) ; return ! d ( o , "transform" ) && o . adj ? i ( ) : j = d ( o , " ani
2018-02-01 19:53:26 +00:00
const mcopy = { } ;
2022-06-04 15:11:23 +00:00
const remote = require ( '@electron/remote' ) ;
const { ipcRenderer } = require ( 'electron' ) ;
const { dialog } = remote ;
2018-02-01 19:53:26 +00:00
const notifier = require ( 'node-notifier' ) ;
const fs = require ( 'fs' ) ;
2019-04-20 14:15:28 +00:00
const uuid = require ( 'uuid' ) . v4 ;
2018-02-01 19:53:26 +00:00
const moment = require ( 'moment' ) ;
2019-07-07 04:00:45 +00:00
const path = require ( 'path' ) ;
2018-02-01 19:53:26 +00:00
const humanizeDuration = require ( 'humanize-duration' ) ;
2019-03-22 01:32:33 +00:00
const PACKAGE = require ( './package.json' ) ;
2019-03-21 19:47:07 +00:00
const cfg = require ( './data/cfg.json' ) ;
2018-02-01 19:53:26 +00:00
const gui = require ( './lib/ui' ) ;
2019-03-22 01:02:28 +00:00
const grid = require ( './lib/ui/grid.js' ) ;
2018-02-01 19:53:26 +00:00
const light = require ( './lib/ui/light.js' ) ;
const proj = require ( './lib/ui/proj.js' ) ;
const cam = require ( './lib/ui/cam.js' ) ;
const nav = require ( './lib/ui/nav.js' ) ;
const seq = require ( './lib/ui/seq.js' ) ;
const cmd = require ( './lib/ui/cmd.js' ) ;
const devices = require ( './lib/ui/devices.js' ) ;
2019-06-18 19:40:09 +00:00
const filmout = require ( './lib/ui/filmout.js' ) ;
2018-03-05 18:27:00 +00:00
const mse = require ( './lib/ui/mscript.js' ) ;
2022-07-13 19:21:26 +00:00
const capper = require ( './lib/ui/capper.js' ) ;
2023-02-28 19:30:17 +00:00
const timing = require ( './lib/ui/timing.js' ) ;
2018-06-17 03:19:58 +00:00
const Mscript = require ( './lib/mscript' ) ;
2020-01-09 23:06:18 +00:00
const { delay } = require ( './lib/delay' ) ;
2022-08-03 13:02:47 +00:00
const alertObj = require ( './lib/ui/alert.js' ) ;
2024-05-19 22:14:33 +00:00
const { Log } = require ( './lib/log' ) ;
2021-02-24 15:05:45 +00:00
2019-03-21 19:47:07 +00:00
let log ;
2018-02-01 19:53:26 +00:00
2016-04-14 04:17:42 +00:00
/ * * * * * *
State shared by ALL interfaces
* * * * * * * /
mcopy . state = {
2019-04-02 14:21:01 +00:00
version : PACKAGE . version //use for file compatibility check
2016-04-14 04:17:42 +00:00
} ;
2019-03-21 19:47:07 +00:00
//
2016-04-14 04:17:42 +00:00
2019-03-21 19:47:07 +00:00
async function init ( ) {
2016-04-13 07:26:35 +00:00
'use strict' ;
2019-03-21 19:47:07 +00:00
2024-05-19 22:14:33 +00:00
log = await Log ( { label : 'ui' } )
2019-03-21 19:47:07 +00:00
2016-04-13 07:26:35 +00:00
nav . init ( ) ;
2023-02-19 16:36:06 +00:00
gui . init ( ) ;
2019-03-22 01:02:28 +00:00
grid . init ( ) ;
2018-03-05 18:27:00 +00:00
mse . mscript . init ( ) ;
mse . console . init ( ) ;
2019-03-21 19:47:07 +00:00
2016-04-19 03:44:31 +00:00
devices . init ( ) ;
2019-06-25 01:11:14 +00:00
filmout . init ( ) ;
2016-04-13 04:06:19 +00:00
light . init ( ) ;
2016-04-18 02:22:18 +00:00
proj . init ( ) ;
2016-04-18 03:02:22 +00:00
cam . init ( ) ;
2019-03-24 01:58:22 +00:00
seq . init ( ) ;
2022-07-13 19:21:26 +00:00
capper . init ( ) ;
2022-08-03 13:02:47 +00:00
alertObj . init ( ) ;
2023-07-31 02:13:50 +00:00
timing . init ( ) ;
2016-04-13 01:04:13 +00:00
} ;