jpicker.js 98 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091
  1. /*
  2. * jPicker 1.1.6
  3. *
  4. * jQuery Plugin for Photoshop style color picker
  5. *
  6. * Copyright (c) 2010 Christopher T. Tillman
  7. * Digital Magic Productions, Inc. (http://www.digitalmagicpro.com/)
  8. * MIT style license, FREE to use, alter, copy, sell, and especially ENHANCE
  9. *
  10. * Painstakingly ported from John Dyers' excellent work on his own color picker based on the Prototype framework.
  11. *
  12. * John Dyers' website: (http://johndyer.name)
  13. * Color Picker page: (http://johndyer.name/post/2007/09/PhotoShop-like-JavaScript-Color-Picker.aspx)
  14. *
  15. */
  16. (function($, version)
  17. {
  18. Math.precision = function(value, precision)
  19. {
  20. if (precision === undefined) precision = 0;
  21. return Math.round(value * Math.pow(10, precision)) / Math.pow(10, precision);
  22. };
  23. var Slider = // encapsulate slider functionality for the ColorMap and ColorBar - could be useful to use a jQuery UI draggable for this with certain extensions
  24. function(bar, options)
  25. {
  26. var $this = this, // private properties, methods, and events - keep these variables and classes invisible to outside code
  27. arrow = bar.find('img:first'), // the arrow image to drag
  28. minX = 0,
  29. maxX = 100,
  30. rangeX = 100,
  31. minY = 0,
  32. maxY = 100,
  33. rangeY = 100,
  34. x = 0,
  35. y = 0,
  36. offset,
  37. timeout,
  38. changeEvents = new Array(),
  39. fireChangeEvents =
  40. function(context)
  41. {
  42. for (var i = 0; i < changeEvents.length; i++) changeEvents[i].call($this, $this, context);
  43. },
  44. mouseDown = // bind the mousedown to the bar not the arrow for quick snapping to the clicked location
  45. function(e)
  46. {
  47. var off = bar.offset();
  48. offset = { l: off.left | 0, t: off.top | 0 };
  49. clearTimeout(timeout);
  50. timeout = setTimeout( // using setTimeout for visual updates - once the style is updated the browser will re-render internally allowing the next Javascript to run
  51. function()
  52. {
  53. setValuesFromMousePosition.call($this, e);
  54. }, 0);
  55. // Bind mousemove and mouseup event to the document so it responds when dragged of of the bar - we will unbind these when on mouseup to save processing
  56. $(document).bind('mousemove', mouseMove).bind('mouseup', mouseUp);
  57. e.preventDefault(); // don't try to select anything or drag the image to the desktop
  58. },
  59. mouseMove = // set the values as the mouse moves
  60. function(e)
  61. {
  62. clearTimeout(timeout);
  63. timeout = setTimeout(
  64. function()
  65. {
  66. setValuesFromMousePosition.call($this, e);
  67. }, 0);
  68. e.stopPropagation();
  69. e.preventDefault();
  70. return false;
  71. },
  72. mouseUp = // unbind the document events - they aren't needed when not dragging
  73. function(e)
  74. {
  75. $(document).unbind('mouseup', mouseUp).unbind('mousemove', mouseMove);
  76. e.stopPropagation();
  77. e.preventDefault();
  78. return false;
  79. },
  80. setValuesFromMousePosition = // calculate mouse position and set value within the current range
  81. function(e)
  82. {
  83. var locX = e.pageX - offset.l,
  84. locY = e.pageY - offset.t,
  85. barW = bar.w, // local copies for YUI compressor
  86. barH = bar.h;
  87. // keep the arrow within the bounds of the bar
  88. if (locX < 0) locX = 0;
  89. else if (locX > barW) locX = barW;
  90. if (locY < 0) locY = 0;
  91. else if (locY > barH) locY = barH;
  92. val.call($this, 'xy', { x: ((locX / barW) * rangeX) + minX, y: ((locY / barH) * rangeY) + minY });
  93. },
  94. draw =
  95. function()
  96. {
  97. var arrowOffsetX = 0,
  98. arrowOffsetY = 0,
  99. barW = bar.w,
  100. barH = bar.h,
  101. arrowW = arrow.w,
  102. arrowH = arrow.h;
  103. setTimeout(
  104. function()
  105. {
  106. if (rangeX > 0) // range is greater than zero
  107. {
  108. // constrain to bounds
  109. if (x == maxX) arrowOffsetX = barW;
  110. else arrowOffsetX = ((x / rangeX) * barW) | 0;
  111. }
  112. if (rangeY > 0) // range is greater than zero
  113. {
  114. // constrain to bounds
  115. if (y == maxY) arrowOffsetY = barH;
  116. else arrowOffsetY = ((y / rangeY) * barH) | 0;
  117. }
  118. // if arrow width is greater than bar width, center arrow and prevent horizontal dragging
  119. if (arrowW >= barW) arrowOffsetX = (barW >> 1) - (arrowW >> 1); // number >> 1 - superfast bitwise divide by two and truncate (move bits over one bit discarding lowest)
  120. else arrowOffsetX -= arrowW >> 1;
  121. // if arrow height is greater than bar height, center arrow and prevent vertical dragging
  122. if (arrowH >= barH) arrowOffsetY = (barH >> 1) - (arrowH >> 1);
  123. else arrowOffsetY -= arrowH >> 1;
  124. // set the arrow position based on these offsets
  125. arrow.css({ left: arrowOffsetX + 'px', top: arrowOffsetY + 'px' });
  126. }, 0);
  127. },
  128. val =
  129. function(name, value, context)
  130. {
  131. var set = value !== undefined;
  132. if (!set)
  133. {
  134. if (name === undefined || name == null) name = 'xy';
  135. switch (name.toLowerCase())
  136. {
  137. case 'x': return x;
  138. case 'y': return y;
  139. case 'xy':
  140. default: return { x: x, y: y };
  141. }
  142. }
  143. if (context != null && context == $this) return;
  144. var changed = false,
  145. newX,
  146. newY;
  147. if (name == null) name = 'xy';
  148. switch (name.toLowerCase())
  149. {
  150. case 'x':
  151. newX = value && (value.x && value.x | 0 || value | 0) || 0;
  152. break;
  153. case 'y':
  154. newY = value && (value.y && value.y | 0 || value | 0) || 0;
  155. break;
  156. case 'xy':
  157. default:
  158. newX = value && value.x && value.x | 0 || 0;
  159. newY = value && value.y && value.y | 0 || 0;
  160. break;
  161. }
  162. if (newX != null)
  163. {
  164. if (newX < minX) newX = minX;
  165. else if (newX > maxX) newX = maxX;
  166. if (x != newX)
  167. {
  168. x = newX;
  169. changed = true;
  170. }
  171. }
  172. if (newY != null)
  173. {
  174. if (newY < minY) newY = minY;
  175. else if (newY > maxY) newY = maxY;
  176. if (y != newY)
  177. {
  178. y = newY;
  179. changed = true;
  180. }
  181. }
  182. changed && fireChangeEvents.call($this, context || $this);
  183. },
  184. range =
  185. function (name, value)
  186. {
  187. var set = value !== undefined;
  188. if (!set)
  189. {
  190. if (name === undefined || name == null) name = 'all';
  191. switch (name.toLowerCase())
  192. {
  193. case 'minx': return minX;
  194. case 'maxx': return maxX;
  195. case 'rangex': return { minX: minX, maxX: maxX, rangeX: rangeX };
  196. case 'miny': return minY;
  197. case 'maxy': return maxY;
  198. case 'rangey': return { minY: minY, maxY: maxY, rangeY: rangeY };
  199. case 'all':
  200. default: return { minX: minX, maxX: maxX, rangeX: rangeX, minY: minY, maxY: maxY, rangeY: rangeY };
  201. }
  202. }
  203. var changed = false,
  204. newMinX,
  205. newMaxX,
  206. newMinY,
  207. newMaxY;
  208. if (name == null) name = 'all';
  209. switch (name.toLowerCase())
  210. {
  211. case 'minx':
  212. newMinX = value && (value.minX && value.minX | 0 || value | 0) || 0;
  213. break;
  214. case 'maxx':
  215. newMaxX = value && (value.maxX && value.maxX | 0 || value | 0) || 0;
  216. break;
  217. case 'rangex':
  218. newMinX = value && value.minX && value.minX | 0 || 0;
  219. newMaxX = value && value.maxX && value.maxX | 0 || 0;
  220. break;
  221. case 'miny':
  222. newMinY = value && (value.minY && value.minY | 0 || value | 0) || 0;
  223. break;
  224. case 'maxy':
  225. newMaxY = value && (value.maxY && value.maxY | 0 || value | 0) || 0;
  226. break;
  227. case 'rangey':
  228. newMinY = value && value.minY && value.minY | 0 || 0;
  229. newMaxY = value && value.maxY && value.maxY | 0 || 0;
  230. break;
  231. case 'all':
  232. default:
  233. newMinX = value && value.minX && value.minX | 0 || 0;
  234. newMaxX = value && value.maxX && value.maxX | 0 || 0;
  235. newMinY = value && value.minY && value.minY | 0 || 0;
  236. newMaxY = value && value.maxY && value.maxY | 0 || 0;
  237. break;
  238. }
  239. if (newMinX != null && minX != newMinX)
  240. {
  241. minX = newMinX;
  242. rangeX = maxX - minX;
  243. }
  244. if (newMaxX != null && maxX != newMaxX)
  245. {
  246. maxX = newMaxX;
  247. rangeX = maxX - minX;
  248. }
  249. if (newMinY != null && minY != newMinY)
  250. {
  251. minY = newMinY;
  252. rangeY = maxY - minY;
  253. }
  254. if (newMaxY != null && maxY != newMaxY)
  255. {
  256. maxY = newMaxY;
  257. rangeY = maxY - minY;
  258. }
  259. },
  260. bind =
  261. function (callback)
  262. {
  263. if ($.isFunction(callback)) changeEvents.push(callback);
  264. },
  265. unbind =
  266. function (callback)
  267. {
  268. if (!$.isFunction(callback)) return;
  269. var i;
  270. while ((i = $.inArray(callback, changeEvents)) != -1) changeEvents.splice(i, 1);
  271. },
  272. destroy =
  273. function()
  274. {
  275. // unbind all possible events and null objects
  276. $(document).unbind('mouseup', mouseUp).unbind('mousemove', mouseMove);
  277. bar.unbind('mousedown', mouseDown);
  278. bar = null;
  279. arrow = null;
  280. changeEvents = null;
  281. };
  282. $.extend(true, $this, // public properties, methods, and event bindings - these we need to access from other controls
  283. {
  284. val: val,
  285. range: range,
  286. bind: bind,
  287. unbind: unbind,
  288. destroy: destroy
  289. });
  290. // initialize this control
  291. arrow.src = options.arrow && options.arrow.image;
  292. arrow.w = options.arrow && options.arrow.width || arrow.width();
  293. arrow.h = options.arrow && options.arrow.height || arrow.height();
  294. bar.w = options.map && options.map.width || bar.width();
  295. bar.h = options.map && options.map.height || bar.height();
  296. // bind mousedown event
  297. bar.bind('mousedown', mouseDown);
  298. bind.call($this, draw);
  299. },
  300. ColorValuePicker = // controls for all the input elements for the typing in color values
  301. function(picker, color, bindedHex, alphaPrecision)
  302. {
  303. var $this = this, // private properties and methods
  304. inputs = picker.find('td.Text input'),
  305. red = inputs.eq(3),
  306. green = inputs.eq(4),
  307. blue = inputs.eq(5),
  308. alpha = inputs.length > 7 ? inputs.eq(6) : null,
  309. hue = inputs.eq(0),
  310. saturation = inputs.eq(1),
  311. value = inputs.eq(2),
  312. hex = inputs.eq(inputs.length > 7 ? 7 : 6),
  313. ahex = inputs.length > 7 ? inputs.eq(8) : null,
  314. keyDown = // input box key down - use arrows to alter color
  315. function(e)
  316. {
  317. if (e.target.value == '' && e.target != hex.get(0) && (bindedHex != null && e.target != bindedHex.get(0) || bindedHex == null)) return;
  318. if (!validateKey(e)) return e;
  319. switch (e.target)
  320. {
  321. case red.get(0):
  322. switch (e.keyCode)
  323. {
  324. case 38:
  325. red.val(setValueInRange.call($this, (red.val() << 0) + 1, 0, 255));
  326. color.val('r', red.val(), e.target);
  327. return false;
  328. case 40:
  329. red.val(setValueInRange.call($this, (red.val() << 0) - 1, 0, 255));
  330. color.val('r', red.val(), e.target);
  331. return false;
  332. }
  333. break;
  334. case green.get(0):
  335. switch (e.keyCode)
  336. {
  337. case 38:
  338. green.val(setValueInRange.call($this, (green.val() << 0) + 1, 0, 255));
  339. color.val('g', green.val(), e.target);
  340. return false;
  341. case 40:
  342. green.val(setValueInRange.call($this, (green.val() << 0) - 1, 0, 255));
  343. color.val('g', green.val(), e.target);
  344. return false;
  345. }
  346. break;
  347. case blue.get(0):
  348. switch (e.keyCode)
  349. {
  350. case 38:
  351. blue.val(setValueInRange.call($this, (blue.val() << 0) + 1, 0, 255));
  352. color.val('b', blue.val(), e.target);
  353. return false;
  354. case 40:
  355. blue.val(setValueInRange.call($this, (blue.val() << 0) - 1, 0, 255));
  356. color.val('b', blue.val(), e.target);
  357. return false;
  358. }
  359. break;
  360. case alpha && alpha.get(0):
  361. switch (e.keyCode)
  362. {
  363. case 38:
  364. alpha.val(setValueInRange.call($this, parseFloat(alpha.val()) + 1, 0, 100));
  365. color.val('a', Math.precision((alpha.val() * 255) / 100, alphaPrecision), e.target);
  366. return false;
  367. case 40:
  368. alpha.val(setValueInRange.call($this, parseFloat(alpha.val()) - 1, 0, 100));
  369. color.val('a', Math.precision((alpha.val() * 255) / 100, alphaPrecision), e.target);
  370. return false;
  371. }
  372. break;
  373. case hue.get(0):
  374. switch (e.keyCode)
  375. {
  376. case 38:
  377. hue.val(setValueInRange.call($this, (hue.val() << 0) + 1, 0, 360));
  378. color.val('h', hue.val(), e.target);
  379. return false;
  380. case 40:
  381. hue.val(setValueInRange.call($this, (hue.val() << 0) - 1, 0, 360));
  382. color.val('h', hue.val(), e.target);
  383. return false;
  384. }
  385. break;
  386. case saturation.get(0):
  387. switch (e.keyCode)
  388. {
  389. case 38:
  390. saturation.val(setValueInRange.call($this, (saturation.val() << 0) + 1, 0, 100));
  391. color.val('s', saturation.val(), e.target);
  392. return false;
  393. case 40:
  394. saturation.val(setValueInRange.call($this, (saturation.val() << 0) - 1, 0, 100));
  395. color.val('s', saturation.val(), e.target);
  396. return false;
  397. }
  398. break;
  399. case value.get(0):
  400. switch (e.keyCode)
  401. {
  402. case 38:
  403. value.val(setValueInRange.call($this, (value.val() << 0) + 1, 0, 100));
  404. color.val('v', value.val(), e.target);
  405. return false;
  406. case 40:
  407. value.val(setValueInRange.call($this, (value.val() << 0) - 1, 0, 100));
  408. color.val('v', value.val(), e.target);
  409. return false;
  410. }
  411. break;
  412. }
  413. },
  414. keyUp = // input box key up - validate value and set color
  415. function(e)
  416. {
  417. if (e.target.value == '' && e.target != hex.get(0) && (bindedHex != null && e.target != bindedHex.get(0) || bindedHex == null)) return;
  418. if (!validateKey(e)) return e;
  419. switch (e.target)
  420. {
  421. case red.get(0):
  422. red.val(setValueInRange.call($this, red.val(), 0, 255));
  423. color.val('r', red.val(), e.target);
  424. break;
  425. case green.get(0):
  426. green.val(setValueInRange.call($this, green.val(), 0, 255));
  427. color.val('g', green.val(), e.target);
  428. break;
  429. case blue.get(0):
  430. blue.val(setValueInRange.call($this, blue.val(), 0, 255));
  431. color.val('b', blue.val(), e.target);
  432. break;
  433. case alpha && alpha.get(0):
  434. alpha.val(setValueInRange.call($this, alpha.val(), 0, 100));
  435. color.val('a', Math.precision((alpha.val() * 255) / 100, alphaPrecision), e.target);
  436. break;
  437. case hue.get(0):
  438. hue.val(setValueInRange.call($this, hue.val(), 0, 360));
  439. color.val('h', hue.val(), e.target);
  440. break;
  441. case saturation.get(0):
  442. saturation.val(setValueInRange.call($this, saturation.val(), 0, 100));
  443. color.val('s', saturation.val(), e.target);
  444. break;
  445. case value.get(0):
  446. value.val(setValueInRange.call($this, value.val(), 0, 100));
  447. color.val('v', value.val(), e.target);
  448. break;
  449. case hex.get(0):
  450. hex.val(hex.val().replace(/[^a-fA-F0-9]/g, '').toLowerCase().substring(0, 6));
  451. bindedHex && bindedHex.val(hex.val());
  452. color.val('hex', hex.val() != '' ? hex.val() : null, e.target);
  453. break;
  454. case bindedHex && bindedHex.get(0):
  455. bindedHex.val(bindedHex.val().replace(/[^a-fA-F0-9]/g, '').toLowerCase().substring(0, 6));
  456. hex.val(bindedHex.val());
  457. color.val('hex', bindedHex.val() != '' ? bindedHex.val() : null, e.target);
  458. break;
  459. case ahex && ahex.get(0):
  460. ahex.val(ahex.val().replace(/[^a-fA-F0-9]/g, '').toLowerCase().substring(0, 2));
  461. color.val('a', ahex.val() != null ? parseInt(ahex.val(), 16) : null, e.target);
  462. break;
  463. }
  464. },
  465. blur = // input box blur - reset to original if value empty
  466. function(e)
  467. {
  468. if (color.val() != null)
  469. {
  470. switch (e.target)
  471. {
  472. case red.get(0): red.val(color.val('r')); break;
  473. case green.get(0): green.val(color.val('g')); break;
  474. case blue.get(0): blue.val(color.val('b')); break;
  475. case alpha && alpha.get(0): alpha.val(Math.precision((color.val('a') * 100) / 255, alphaPrecision)); break;
  476. case hue.get(0): hue.val(color.val('h')); break;
  477. case saturation.get(0): saturation.val(color.val('s')); break;
  478. case value.get(0): value.val(color.val('v')); break;
  479. case hex.get(0):
  480. case bindedHex && bindedHex.get(0):
  481. hex.val(color.val('hex'));
  482. bindedHex && bindedHex.val(color.val('hex'));
  483. break;
  484. case ahex && ahex.get(0): ahex.val(color.val('ahex').substring(6)); break;
  485. }
  486. }
  487. },
  488. validateKey = // validate key
  489. function(e)
  490. {
  491. switch(e.keyCode)
  492. {
  493. case 9:
  494. case 16:
  495. case 29:
  496. case 37:
  497. case 39:
  498. return false;
  499. case 'c'.charCodeAt():
  500. case 'v'.charCodeAt():
  501. if (e.ctrlKey) return false;
  502. }
  503. return true;
  504. },
  505. setValueInRange = // constrain value within range
  506. function(value, min, max)
  507. {
  508. if (value == '' || isNaN(value)) return min;
  509. if (value > max) return max;
  510. if (value < min) return min;
  511. return value;
  512. },
  513. colorChanged =
  514. function(ui, context)
  515. {
  516. var all = ui.val('all');
  517. if (context != red.get(0)) red.val(all != null ? all.r : '');
  518. if (context != green.get(0)) green.val(all != null ? all.g : '');
  519. if (context != blue.get(0)) blue.val(all != null ? all.b : '');
  520. if (alpha && context != alpha.get(0)) alpha.val(all != null ? Math.precision((all.a * 100) / 255, alphaPrecision) : '');
  521. if (context != hue.get(0)) hue.val(all != null ? all.h : '');
  522. if (context != saturation.get(0)) saturation.val(all != null ? all.s : '');
  523. if (context != value.get(0)) value.val(all != null ? all.v : '');
  524. if (context != hex.get(0) && (bindedHex && context != bindedHex.get(0) || !bindedHex)) hex.val(all != null ? all.hex : '');
  525. if (bindedHex && context != bindedHex.get(0) && context != hex.get(0)) bindedHex.val(all != null ? all.hex : '');
  526. if (ahex && context != ahex.get(0)) ahex.val(all != null ? all.ahex.substring(6) : '');
  527. },
  528. destroy =
  529. function()
  530. {
  531. // unbind all events and null objects
  532. red.add(green).add(blue).add(alpha).add(hue).add(saturation).add(value).add(hex).add(bindedHex).add(ahex).unbind('keyup', keyUp).unbind('blur', blur);
  533. red.add(green).add(blue).add(alpha).add(hue).add(saturation).add(value).unbind('keydown', keyDown);
  534. color.unbind(colorChanged);
  535. red = null;
  536. green = null;
  537. blue = null;
  538. alpha = null;
  539. hue = null;
  540. saturation = null;
  541. value = null;
  542. hex = null;
  543. ahex = null;
  544. };
  545. $.extend(true, $this, // public properties and methods
  546. {
  547. destroy: destroy
  548. });
  549. red.add(green).add(blue).add(alpha).add(hue).add(saturation).add(value).add(hex).add(bindedHex).add(ahex).bind('keyup', keyUp).bind('blur', blur);
  550. red.add(green).add(blue).add(alpha).add(hue).add(saturation).add(value).bind('keydown', keyDown);
  551. color.bind(colorChanged);
  552. };
  553. $.jPicker =
  554. {
  555. List: [], // array holding references to each active instance of the control
  556. Color: // color object - we will be able to assign by any color space type or retrieve any color space info
  557. // we want this public so we can optionally assign new color objects to initial values using inputs other than a string hex value (also supported)
  558. function(init)
  559. {
  560. var $this = this,
  561. r,
  562. g,
  563. b,
  564. a,
  565. h,
  566. s,
  567. v,
  568. changeEvents = new Array(),
  569. fireChangeEvents =
  570. function(context)
  571. {
  572. for (var i = 0; i < changeEvents.length; i++) changeEvents[i].call($this, $this, context);
  573. },
  574. val =
  575. function(name, value, context)
  576. {
  577. // Kind of ugly
  578. var set = Boolean(value);
  579. if (set && value.ahex === "") value.ahex = "00000000";
  580. if (!set)
  581. {
  582. if (name === undefined || name == null || name == '') name = 'all';
  583. if (r == null) return null;
  584. switch (name.toLowerCase())
  585. {
  586. case 'ahex': return ColorMethods.rgbaToHex({ r: r, g: g, b: b, a: a });
  587. case 'hex': return val('ahex').substring(0, 6);
  588. case 'all': return { r: r, g: g, b: b, a: a, h: h, s: s, v: v, hex: val.call($this, 'hex'), ahex: val.call($this, 'ahex') };
  589. default:
  590. var ret={};
  591. for (var i = 0; i < name.length; i++)
  592. {
  593. switch (name.charAt(i))
  594. {
  595. case 'r':
  596. if (name.length == 1) ret = r;
  597. else ret.r = r;
  598. break;
  599. case 'g':
  600. if (name.length == 1) ret = g;
  601. else ret.g = g;
  602. break;
  603. case 'b':
  604. if (name.length == 1) ret = b;
  605. else ret.b = b;
  606. break;
  607. case 'a':
  608. if (name.length == 1) ret = a;
  609. else ret.a = a;
  610. break;
  611. case 'h':
  612. if (name.length == 1) ret = h;
  613. else ret.h = h;
  614. break;
  615. case 's':
  616. if (name.length == 1) ret = s;
  617. else ret.s = s;
  618. break;
  619. case 'v':
  620. if (name.length == 1) ret = v;
  621. else ret.v = v;
  622. break;
  623. }
  624. }
  625. return ret == {} ? val.call($this, 'all') : ret;
  626. break;
  627. }
  628. }
  629. if (context != null && context == $this) return;
  630. var changed = false;
  631. if (name == null) name = '';
  632. if (value == null)
  633. {
  634. if (r != null)
  635. {
  636. r = null;
  637. changed = true;
  638. }
  639. if (g != null)
  640. {
  641. g = null;
  642. changed = true;
  643. }
  644. if (b != null)
  645. {
  646. b = null;
  647. changed = true;
  648. }
  649. if (a != null)
  650. {
  651. a = null;
  652. changed = true;
  653. }
  654. if (h != null)
  655. {
  656. h = null;
  657. changed = true;
  658. }
  659. if (s != null)
  660. {
  661. s = null;
  662. changed = true;
  663. }
  664. if (v != null)
  665. {
  666. v = null;
  667. changed = true;
  668. }
  669. changed && fireChangeEvents.call($this, context || $this);
  670. return;
  671. }
  672. switch (name.toLowerCase())
  673. {
  674. case 'ahex':
  675. case 'hex':
  676. var ret = ColorMethods.hexToRgba(value && (value.ahex || value.hex) || value || 'none');
  677. val.call($this, 'rgba', { r: ret.r, g: ret.g, b: ret.b, a: name == 'ahex' ? ret.a : a != null ? a : 255 }, context);
  678. break;
  679. default:
  680. if (value && (value.ahex != null || value.hex != null))
  681. {
  682. val.call($this, 'ahex', value.ahex || value.hex || '00000000', context);
  683. return;
  684. }
  685. var newV = {}, rgb = false, hsv = false;
  686. if (value.r !== undefined && !name.indexOf('r') == -1) name += 'r';
  687. if (value.g !== undefined && !name.indexOf('g') == -1) name += 'g';
  688. if (value.b !== undefined && !name.indexOf('b') == -1) name += 'b';
  689. if (value.a !== undefined && !name.indexOf('a') == -1) name += 'a';
  690. if (value.h !== undefined && !name.indexOf('h') == -1) name += 'h';
  691. if (value.s !== undefined && !name.indexOf('s') == -1) name += 's';
  692. if (value.v !== undefined && !name.indexOf('v') == -1) name += 'v';
  693. for (var i = 0; i < name.length; i++)
  694. {
  695. switch (name.charAt(i))
  696. {
  697. case 'r':
  698. if (hsv) continue;
  699. rgb = true;
  700. newV.r = value && value.r && value.r | 0 || value && value | 0 || 0;
  701. if (newV.r < 0) newV.r = 0;
  702. else if (newV.r > 255) newV.r = 255;
  703. if (r != newV.r)
  704. {
  705. r = newV.r;
  706. changed = true;
  707. }
  708. break;
  709. case 'g':
  710. if (hsv) continue;
  711. rgb = true;
  712. newV.g = value && value.g && value.g | 0 || value && value | 0 || 0;
  713. if (newV.g < 0) newV.g = 0;
  714. else if (newV.g > 255) newV.g = 255;
  715. if (g != newV.g)
  716. {
  717. g = newV.g;
  718. changed = true;
  719. }
  720. break;
  721. case 'b':
  722. if (hsv) continue;
  723. rgb = true;
  724. newV.b = value && value.b && value.b | 0 || value && value | 0 || 0;
  725. if (newV.b < 0) newV.b = 0;
  726. else if (newV.b > 255) newV.b = 255;
  727. if (b != newV.b)
  728. {
  729. b = newV.b;
  730. changed = true;
  731. }
  732. break;
  733. case 'a':
  734. newV.a = value && value.a != null ? value.a | 0 : value != null ? value | 0 : 255;
  735. if (newV.a < 0) newV.a = 0;
  736. else if (newV.a > 255) newV.a = 255;
  737. if (a != newV.a)
  738. {
  739. a = newV.a;
  740. changed = true;
  741. }
  742. break;
  743. case 'h':
  744. if (rgb) continue;
  745. hsv = true;
  746. newV.h = value && value.h && value.h | 0 || value && value | 0 || 0;
  747. if (newV.h < 0) newV.h = 0;
  748. else if (newV.h > 360) newV.h = 360;
  749. if (h != newV.h)
  750. {
  751. h = newV.h;
  752. changed = true;
  753. }
  754. break;
  755. case 's':
  756. if (rgb) continue;
  757. hsv = true;
  758. newV.s = value && value.s != null ? value.s | 0 : value != null ? value | 0 : 100;
  759. if (newV.s < 0) newV.s = 0;
  760. else if (newV.s > 100) newV.s = 100;
  761. if (s != newV.s)
  762. {
  763. s = newV.s;
  764. changed = true;
  765. }
  766. break;
  767. case 'v':
  768. if (rgb) continue;
  769. hsv = true;
  770. newV.v = value && value.v != null ? value.v | 0 : value != null ? value | 0 : 100;
  771. if (newV.v < 0) newV.v = 0;
  772. else if (newV.v > 100) newV.v = 100;
  773. if (v != newV.v)
  774. {
  775. v = newV.v;
  776. changed = true;
  777. }
  778. break;
  779. }
  780. }
  781. if (changed)
  782. {
  783. if (rgb)
  784. {
  785. r = r || 0;
  786. g = g || 0;
  787. b = b || 0;
  788. var ret = ColorMethods.rgbToHsv({ r: r, g: g, b: b });
  789. h = ret.h;
  790. s = ret.s;
  791. v = ret.v;
  792. }
  793. else if (hsv)
  794. {
  795. h = h || 0;
  796. s = s != null ? s : 100;
  797. v = v != null ? v : 100;
  798. var ret = ColorMethods.hsvToRgb({ h: h, s: s, v: v });
  799. r = ret.r;
  800. g = ret.g;
  801. b = ret.b;
  802. }
  803. a = a != null ? a : 255;
  804. fireChangeEvents.call($this, context || $this);
  805. }
  806. break;
  807. }
  808. },
  809. bind =
  810. function(callback)
  811. {
  812. if ($.isFunction(callback)) changeEvents.push(callback);
  813. },
  814. unbind =
  815. function(callback)
  816. {
  817. if (!$.isFunction(callback)) return;
  818. var i;
  819. while ((i = $.inArray(callback, changeEvents)) != -1) changeEvents.splice(i, 1);
  820. },
  821. destroy =
  822. function()
  823. {
  824. changeEvents = null;
  825. }
  826. $.extend(true, $this, // public properties and methods
  827. {
  828. val: val,
  829. bind: bind,
  830. unbind: unbind,
  831. destroy: destroy
  832. });
  833. if (init)
  834. {
  835. if (init.ahex != null) val('ahex', init);
  836. else if (init.hex != null) val((init.a != null ? 'a' : '') + 'hex', init.a != null ? { ahex: init.hex + ColorMethods.intToHex(init.a) } : init);
  837. else if (init.r != null && init.g != null && init.b != null) val('rgb' + (init.a != null ? 'a' : ''), init);
  838. else if (init.h != null && init.s != null && init.v != null) val('hsv' + (init.a != null ? 'a' : ''), init);
  839. }
  840. },
  841. ColorMethods: // color conversion methods - make public to give use to external scripts
  842. {
  843. hexToRgba:
  844. function(hex)
  845. {
  846. if (hex === '' || hex === 'none') return { r: null, g: null, b: null, a: null };
  847. hex = this.validateHex(hex);
  848. var r = '00', g = '00', b = '00', a = '255';
  849. if (hex.length == 6) hex += 'ff';
  850. if (hex.length > 6)
  851. {
  852. r = hex.substring(0, 2);
  853. g = hex.substring(2, 4);
  854. b = hex.substring(4, 6);
  855. a = hex.substring(6, hex.length);
  856. }
  857. else
  858. {
  859. if (hex.length > 4)
  860. {
  861. r = hex.substring(4, hex.length);
  862. hex = hex.substring(0, 4);
  863. }
  864. if (hex.length > 2)
  865. {
  866. g = hex.substring(2, hex.length);
  867. hex = hex.substring(0, 2);
  868. }
  869. if (hex.length > 0) b = hex.substring(0, hex.length);
  870. }
  871. return { r: this.hexToInt(r), g: this.hexToInt(g), b: this.hexToInt(b), a: this.hexToInt(a) };
  872. },
  873. validateHex:
  874. function(hex)
  875. {
  876. //if (typeof hex === "object") return "";
  877. hex = hex.toLowerCase().replace(/[^a-f0-9]/g, '');
  878. if (hex.length > 8) hex = hex.substring(0, 8);
  879. return hex;
  880. },
  881. rgbaToHex:
  882. function(rgba)
  883. {
  884. return this.intToHex(rgba.r) + this.intToHex(rgba.g) + this.intToHex(rgba.b) + this.intToHex(rgba.a);
  885. },
  886. intToHex:
  887. function(dec)
  888. {
  889. var result = (dec | 0).toString(16);
  890. if (result.length == 1) result = ('0' + result);
  891. return result.toLowerCase();
  892. },
  893. hexToInt:
  894. function(hex)
  895. {
  896. return parseInt(hex, 16);
  897. },
  898. rgbToHsv:
  899. function(rgb)
  900. {
  901. var r = rgb.r / 255, g = rgb.g / 255, b = rgb.b / 255, hsv = { h: 0, s: 0, v: 0 }, min = 0, max = 0, delta;
  902. if (r >= g && r >= b)
  903. {
  904. max = r;
  905. min = g > b ? b : g;
  906. }
  907. else if (g >= b && g >= r)
  908. {
  909. max = g;
  910. min = r > b ? b : r;
  911. }
  912. else
  913. {
  914. max = b;
  915. min = g > r ? r : g;
  916. }
  917. hsv.v = max;
  918. hsv.s = max ? (max - min) / max : 0;
  919. if (!hsv.s) hsv.h = 0;
  920. else
  921. {
  922. delta = max - min;
  923. if (r == max) hsv.h = (g - b) / delta;
  924. else if (g == max) hsv.h = 2 + (b - r) / delta;
  925. else hsv.h = 4 + (r - g) / delta;
  926. hsv.h = parseInt(hsv.h * 60);
  927. if (hsv.h < 0) hsv.h += 360;
  928. }
  929. hsv.s = (hsv.s * 100) | 0;
  930. hsv.v = (hsv.v * 100) | 0;
  931. return hsv;
  932. },
  933. hsvToRgb:
  934. function(hsv)
  935. {
  936. var rgb = { r: 0, g: 0, b: 0, a: 100 }, h = hsv.h, s = hsv.s, v = hsv.v;
  937. if (s == 0)
  938. {
  939. if (v == 0) rgb.r = rgb.g = rgb.b = 0;
  940. else rgb.r = rgb.g = rgb.b = (v * 255 / 100) | 0;
  941. }
  942. else
  943. {
  944. if (h == 360) h = 0;
  945. h /= 60;
  946. s = s / 100;
  947. v = v / 100;
  948. var i = h | 0,
  949. f = h - i,
  950. p = v * (1 - s),
  951. q = v * (1 - (s * f)),
  952. t = v * (1 - (s * (1 - f)));
  953. switch (i)
  954. {
  955. case 0:
  956. rgb.r = v;
  957. rgb.g = t;
  958. rgb.b = p;
  959. break;
  960. case 1:
  961. rgb.r = q;
  962. rgb.g = v;
  963. rgb.b = p;
  964. break;
  965. case 2:
  966. rgb.r = p;
  967. rgb.g = v;
  968. rgb.b = t;
  969. break;
  970. case 3:
  971. rgb.r = p;
  972. rgb.g = q;
  973. rgb.b = v;
  974. break;
  975. case 4:
  976. rgb.r = t;
  977. rgb.g = p;
  978. rgb.b = v;
  979. break;
  980. case 5:
  981. rgb.r = v;
  982. rgb.g = p;
  983. rgb.b = q;
  984. break;
  985. }
  986. rgb.r = (rgb.r * 255) | 0;
  987. rgb.g = (rgb.g * 255) | 0;
  988. rgb.b = (rgb.b * 255) | 0;
  989. }
  990. return rgb;
  991. }
  992. }
  993. };
  994. var Color = $.jPicker.Color, List = $.jPicker.List, ColorMethods = $.jPicker.ColorMethods; // local copies for YUI compressor
  995. $.fn.jPicker =
  996. function(options)
  997. {
  998. var $arguments = arguments;
  999. return this.each(
  1000. function()
  1001. {
  1002. var $this = this, settings = $.extend(true, {}, $.fn.jPicker.defaults, options); // local copies for YUI compressor
  1003. if ($($this).get(0).nodeName.toLowerCase() == 'input') // Add color picker icon if binding to an input element and bind the events to the input
  1004. {
  1005. $.extend(true, settings,
  1006. {
  1007. window:
  1008. {
  1009. bindToInput: true,
  1010. expandable: true,
  1011. input: $($this)
  1012. }
  1013. });
  1014. if($($this).val()=='')
  1015. {
  1016. settings.color.active = new Color({ hex: null });
  1017. settings.color.current = new Color({ hex: null });
  1018. }
  1019. else if (ColorMethods.validateHex($($this).val()))
  1020. {
  1021. settings.color.active = new Color({ hex: $($this).val(), a: settings.color.active.val('a') });
  1022. settings.color.current = new Color({ hex: $($this).val(), a: settings.color.active.val('a') });
  1023. }
  1024. }
  1025. if (settings.window.expandable)
  1026. $($this).after('<span class="jPicker"><span class="Icon"><span class="Color">&nbsp;</span><span class="Alpha">&nbsp;</span><span class="Image" title="Click To Open Color Picker">&nbsp;</span><span class="Container">&nbsp;</span></span></span>');
  1027. else settings.window.liveUpdate = false; // Basic control binding for inline use - You will need to override the liveCallback or commitCallback function to retrieve results
  1028. var isLessThanIE7 = parseFloat(navigator.appVersion.split('MSIE')[1]) < 7 && document.body.filters, // needed to run the AlphaImageLoader function for IE6
  1029. container = null,
  1030. colorMapDiv = null,
  1031. colorBarDiv = null,
  1032. colorMapL1 = null, // different layers of colorMap and colorBar
  1033. colorMapL2 = null,
  1034. colorMapL3 = null,
  1035. colorBarL1 = null,
  1036. colorBarL2 = null,
  1037. colorBarL3 = null,
  1038. colorBarL4 = null,
  1039. colorBarL5 = null,
  1040. colorBarL6 = null,
  1041. colorMap = null, // color maps
  1042. colorBar = null,
  1043. colorPicker = null,
  1044. elementStartX = null, // Used to record the starting css positions for dragging the control
  1045. elementStartY = null,
  1046. pageStartX = null, // Used to record the mousedown coordinates for dragging the control
  1047. pageStartY = null,
  1048. activePreview = null, // color boxes above the radio buttons
  1049. currentPreview = null,
  1050. okButton = null,
  1051. cancelButton = null,
  1052. grid = null, // preset colors grid
  1053. iconColor = null, // iconColor for popup icon
  1054. iconAlpha = null, // iconAlpha for popup icon
  1055. iconImage = null, // iconImage popup icon
  1056. moveBar = null, // drag bar
  1057. setColorMode = // set color mode and update visuals for the new color mode
  1058. function(colorMode)
  1059. {
  1060. var active = color.active, // local copies for YUI compressor
  1061. clientPath = images.clientPath,
  1062. hex = active.val('hex'),
  1063. rgbMap,
  1064. rgbBar;
  1065. settings.color.mode = colorMode;
  1066. switch (colorMode)
  1067. {
  1068. case 'h':
  1069. setTimeout(
  1070. function()
  1071. {
  1072. setBG.call($this, colorMapDiv, 'transparent');
  1073. setImgLoc.call($this, colorMapL1, 0);
  1074. setAlpha.call($this, colorMapL1, 100);
  1075. setImgLoc.call($this, colorMapL2, 260);
  1076. setAlpha.call($this, colorMapL2, 100);
  1077. setBG.call($this, colorBarDiv, 'transparent');
  1078. setImgLoc.call($this, colorBarL1, 0);
  1079. setAlpha.call($this, colorBarL1, 100);
  1080. setImgLoc.call($this, colorBarL2, 260);
  1081. setAlpha.call($this, colorBarL2, 100);
  1082. setImgLoc.call($this, colorBarL3, 260);
  1083. setAlpha.call($this, colorBarL3, 100);
  1084. setImgLoc.call($this, colorBarL4, 260);
  1085. setAlpha.call($this, colorBarL4, 100);
  1086. setImgLoc.call($this, colorBarL6, 260);
  1087. setAlpha.call($this, colorBarL6, 100);
  1088. }, 0);
  1089. colorMap.range('all', { minX: 0, maxX: 100, minY: 0, maxY: 100 });
  1090. colorBar.range('rangeY', { minY: 0, maxY: 360 });
  1091. if (active.val('ahex') == null) break;
  1092. colorMap.val('xy', { x: active.val('s'), y: 100 - active.val('v') }, colorMap);
  1093. colorBar.val('y', 360 - active.val('h'), colorBar);
  1094. break;
  1095. case 's':
  1096. setTimeout(
  1097. function()
  1098. {
  1099. setBG.call($this, colorMapDiv, 'transparent');
  1100. setImgLoc.call($this, colorMapL1, -260);
  1101. setImgLoc.call($this, colorMapL2, -520);
  1102. setImgLoc.call($this, colorBarL1, -260);
  1103. setImgLoc.call($this, colorBarL2, -520);
  1104. setImgLoc.call($this, colorBarL6, 260);
  1105. setAlpha.call($this, colorBarL6, 100);
  1106. }, 0);
  1107. colorMap.range('all', { minX: 0, maxX: 360, minY: 0, maxY: 100 });
  1108. colorBar.range('rangeY', { minY: 0, maxY: 100 });
  1109. if (active.val('ahex') == null) break;
  1110. colorMap.val('xy', { x: active.val('h'), y: 100 - active.val('v') }, colorMap);
  1111. colorBar.val('y', 100 - active.val('s'), colorBar);
  1112. break;
  1113. case 'v':
  1114. setTimeout(
  1115. function()
  1116. {
  1117. setBG.call($this, colorMapDiv, '000000');
  1118. setImgLoc.call($this, colorMapL1, -780);
  1119. setImgLoc.call($this, colorMapL2, 260);
  1120. setBG.call($this, colorBarDiv, hex);
  1121. setImgLoc.call($this, colorBarL1, -520);
  1122. setImgLoc.call($this, colorBarL2, 260);
  1123. setAlpha.call($this, colorBarL2, 100);
  1124. setImgLoc.call($this, colorBarL6, 260);
  1125. setAlpha.call($this, colorBarL6, 100);
  1126. }, 0);
  1127. colorMap.range('all', { minX: 0, maxX: 360, minY: 0, maxY: 100 });
  1128. colorBar.range('rangeY', { minY: 0, maxY: 100 });
  1129. if (active.val('ahex') == null) break;
  1130. colorMap.val('xy', { x: active.val('h'), y: 100 - active.val('s') }, colorMap);
  1131. colorBar.val('y', 100 - active.val('v'), colorBar);
  1132. break;
  1133. case 'r':
  1134. rgbMap = -1040;
  1135. rgbBar = -780;
  1136. colorMap.range('all', { minX: 0, maxX: 255, minY: 0, maxY: 255 });
  1137. colorBar.range('rangeY', { minY: 0, maxY: 255 });
  1138. if (active.val('ahex') == null) break;
  1139. colorMap.val('xy', { x: active.val('b'), y: 255 - active.val('g') }, colorMap);
  1140. colorBar.val('y', 255 - active.val('r'), colorBar);
  1141. break;
  1142. case 'g':
  1143. rgbMap = -1560;
  1144. rgbBar = -1820;
  1145. colorMap.range('all', { minX: 0, maxX: 255, minY: 0, maxY: 255 });
  1146. colorBar.range('rangeY', { minY: 0, maxY: 255 });
  1147. if (active.val('ahex') == null) break;
  1148. colorMap.val('xy', { x: active.val('b'), y: 255 - active.val('r') }, colorMap);
  1149. colorBar.val('y', 255 - active.val('g'), colorBar);
  1150. break;
  1151. case 'b':
  1152. rgbMap = -2080;
  1153. rgbBar = -2860;
  1154. colorMap.range('all', { minX: 0, maxX: 255, minY: 0, maxY: 255 });
  1155. colorBar.range('rangeY', { minY: 0, maxY: 255 });
  1156. if (active.val('ahex') == null) break;
  1157. colorMap.val('xy', { x: active.val('r'), y: 255 - active.val('g') }, colorMap);
  1158. colorBar.val('y', 255 - active.val('b'), colorBar);
  1159. break;
  1160. case 'a':
  1161. setTimeout(
  1162. function()
  1163. {
  1164. setBG.call($this, colorMapDiv, 'transparent');
  1165. setImgLoc.call($this, colorMapL1, -260);
  1166. setImgLoc.call($this, colorMapL2, -520);
  1167. setImgLoc.call($this, colorBarL1, 260);
  1168. setImgLoc.call($this, colorBarL2, 260);
  1169. setAlpha.call($this, colorBarL2, 100);
  1170. setImgLoc.call($this, colorBarL6, 0);
  1171. setAlpha.call($this, colorBarL6, 100);
  1172. }, 0);
  1173. colorMap.range('all', { minX: 0, maxX: 360, minY: 0, maxY: 100 });
  1174. colorBar.range('rangeY', { minY: 0, maxY: 255 });
  1175. if (active.val('ahex') == null) break;
  1176. colorMap.val('xy', { x: active.val('h'), y: 100 - active.val('v') }, colorMap);
  1177. colorBar.val('y', 255 - active.val('a'), colorBar);
  1178. break;
  1179. default:
  1180. throw ('Invalid Mode');
  1181. break;
  1182. }
  1183. switch (colorMode)
  1184. {
  1185. case 'h':
  1186. break;
  1187. case 's':
  1188. case 'v':
  1189. case 'a':
  1190. setTimeout(
  1191. function()
  1192. {
  1193. setAlpha.call($this, colorMapL1, 100);
  1194. setAlpha.call($this, colorBarL1, 100);
  1195. setImgLoc.call($this, colorBarL3, 260);
  1196. setAlpha.call($this, colorBarL3, 100);
  1197. setImgLoc.call($this, colorBarL4, 260);
  1198. setAlpha.call($this, colorBarL4, 100);
  1199. }, 0);
  1200. break;
  1201. case 'r':
  1202. case 'g':
  1203. case 'b':
  1204. setTimeout(
  1205. function()
  1206. {
  1207. setBG.call($this, colorMapDiv, 'transparent');
  1208. setBG.call($this, colorBarDiv, 'transparent');
  1209. setAlpha.call($this, colorBarL1, 100);
  1210. setAlpha.call($this, colorMapL1, 100);
  1211. setImgLoc.call($this, colorMapL1, rgbMap);
  1212. setImgLoc.call($this, colorMapL2, rgbMap - 260);
  1213. setImgLoc.call($this, colorBarL1, rgbBar - 780);
  1214. setImgLoc.call($this, colorBarL2, rgbBar - 520);
  1215. setImgLoc.call($this, colorBarL3, rgbBar);
  1216. setImgLoc.call($this, colorBarL4, rgbBar - 260);
  1217. setImgLoc.call($this, colorBarL6, 260);
  1218. setAlpha.call($this, colorBarL6, 100);
  1219. }, 0);
  1220. break;
  1221. }
  1222. if (active.val('ahex') == null) return;
  1223. activeColorChanged.call($this, active);
  1224. },
  1225. activeColorChanged = // Update color when user changes text values
  1226. function(ui, context)
  1227. {
  1228. if (context == null || (context != colorBar && context != colorMap)) positionMapAndBarArrows.call($this, ui, context);
  1229. setTimeout(
  1230. function()
  1231. {
  1232. updatePreview.call($this, ui);
  1233. updateMapVisuals.call($this, ui);
  1234. updateBarVisuals.call($this, ui);
  1235. }, 0);
  1236. },
  1237. mapValueChanged = // user has dragged the ColorMap pointer
  1238. function(ui, context)
  1239. {
  1240. var active = color.active;
  1241. if (context != colorMap && active.val() == null) return;
  1242. var xy = ui.val('all');
  1243. switch (settings.color.mode)
  1244. {
  1245. case 'h':
  1246. active.val('sv', { s: xy.x, v: 100 - xy.y }, context);
  1247. break;
  1248. case 's':
  1249. case 'a':
  1250. active.val('hv', { h: xy.x, v: 100 - xy.y }, context);
  1251. break;
  1252. case 'v':
  1253. active.val('hs', { h: xy.x, s: 100 - xy.y }, context);
  1254. break;
  1255. case 'r':
  1256. active.val('gb', { g: 255 - xy.y, b: xy.x }, context);
  1257. break;
  1258. case 'g':
  1259. active.val('rb', { r: 255 - xy.y, b: xy.x }, context);
  1260. break;
  1261. case 'b':
  1262. active.val('rg', { r: xy.x, g: 255 - xy.y }, context);
  1263. break;
  1264. }
  1265. },
  1266. colorBarValueChanged = // user has dragged the ColorBar slider
  1267. function(ui, context)
  1268. {
  1269. var active = color.active;
  1270. if (context != colorBar && active.val() == null) return;
  1271. switch (settings.color.mode)
  1272. {
  1273. case 'h':
  1274. active.val('h', { h: 360 - ui.val('y') }, context);
  1275. break;
  1276. case 's':
  1277. active.val('s', { s: 100 - ui.val('y') }, context);
  1278. break;
  1279. case 'v':
  1280. active.val('v', { v: 100 - ui.val('y') }, context);
  1281. break;
  1282. case 'r':
  1283. active.val('r', { r: 255 - ui.val('y') }, context);
  1284. break;
  1285. case 'g':
  1286. active.val('g', { g: 255 - ui.val('y') }, context);
  1287. break;
  1288. case 'b':
  1289. active.val('b', { b: 255 - ui.val('y') }, context);
  1290. break;
  1291. case 'a':
  1292. active.val('a', 255 - ui.val('y'), context);
  1293. break;
  1294. }
  1295. },
  1296. positionMapAndBarArrows = // position map and bar arrows to match current color
  1297. function(ui, context)
  1298. {
  1299. if (context != colorMap)
  1300. {
  1301. switch (settings.color.mode)
  1302. {
  1303. case 'h':
  1304. var sv = ui.val('sv');
  1305. colorMap.val('xy', { x: sv != null ? sv.s : 100, y: 100 - (sv != null ? sv.v : 100) }, context);
  1306. break;
  1307. case 's':
  1308. case 'a':
  1309. var hv = ui.val('hv');
  1310. colorMap.val('xy', { x: hv && hv.h || 0, y: 100 - (hv != null ? hv.v : 100) }, context);
  1311. break;
  1312. case 'v':
  1313. var hs = ui.val('hs');
  1314. colorMap.val('xy', { x: hs && hs.h || 0, y: 100 - (hs != null ? hs.s : 100) }, context);
  1315. break;
  1316. case 'r':
  1317. var bg = ui.val('bg');
  1318. colorMap.val('xy', { x: bg && bg.b || 0, y: 255 - (bg && bg.g || 0) }, context);
  1319. break;
  1320. case 'g':
  1321. var br = ui.val('br');
  1322. colorMap.val('xy', { x: br && br.b || 0, y: 255 - (br && br.r || 0) }, context);
  1323. break;
  1324. case 'b':
  1325. var rg = ui.val('rg');
  1326. colorMap.val('xy', { x: rg && rg.r || 0, y: 255 - (rg && rg.g || 0) }, context);
  1327. break;
  1328. }
  1329. }
  1330. if (context != colorBar)
  1331. {
  1332. switch (settings.color.mode)
  1333. {
  1334. case 'h':
  1335. colorBar.val('y', 360 - (ui.val('h') || 0), context);
  1336. break;
  1337. case 's':
  1338. var s = ui.val('s');
  1339. colorBar.val('y', 100 - (s != null ? s : 100), context);
  1340. break;
  1341. case 'v':
  1342. var v = ui.val('v');
  1343. colorBar.val('y', 100 - (v != null ? v : 100), context);
  1344. break;
  1345. case 'r':
  1346. colorBar.val('y', 255 - (ui.val('r') || 0), context);
  1347. break;
  1348. case 'g':
  1349. colorBar.val('y', 255 - (ui.val('g') || 0), context);
  1350. break;
  1351. case 'b':
  1352. colorBar.val('y', 255 - (ui.val('b') || 0), context);
  1353. break;
  1354. case 'a':
  1355. var a = ui.val('a');
  1356. colorBar.val('y', 255 - (a != null ? a : 255), context);
  1357. break;
  1358. }
  1359. }
  1360. },
  1361. updatePreview =
  1362. function(ui)
  1363. {
  1364. try
  1365. {
  1366. var all = ui.val('all');
  1367. activePreview.css({ backgroundColor: all && '#' + all.hex || 'transparent' });
  1368. setAlpha.call($this, activePreview, all && Math.precision((all.a * 100) / 255, 4) || 0);
  1369. }
  1370. catch (e) { }
  1371. },
  1372. updateMapVisuals =
  1373. function(ui)
  1374. {
  1375. switch (settings.color.mode)
  1376. {
  1377. case 'h':
  1378. setBG.call($this, colorMapDiv, new Color({ h: ui.val('h') || 0, s: 100, v: 100 }).val('hex'));
  1379. break;
  1380. case 's':
  1381. case 'a':
  1382. var s = ui.val('s');
  1383. setAlpha.call($this, colorMapL2, 100 - (s != null ? s : 100));
  1384. break;
  1385. case 'v':
  1386. var v = ui.val('v');
  1387. setAlpha.call($this, colorMapL1, v != null ? v : 100);
  1388. break;
  1389. case 'r':
  1390. setAlpha.call($this, colorMapL2, Math.precision((ui.val('r') || 0) / 255 * 100, 4));
  1391. break;
  1392. case 'g':
  1393. setAlpha.call($this, colorMapL2, Math.precision((ui.val('g') || 0) / 255 * 100, 4));
  1394. break;
  1395. case 'b':
  1396. setAlpha.call($this, colorMapL2, Math.precision((ui.val('b') || 0) / 255 * 100));
  1397. break;
  1398. }
  1399. var a = ui.val('a');
  1400. setAlpha.call($this, colorMapL3, Math.precision(((255 - (a || 0)) * 100) / 255, 4));
  1401. },
  1402. updateBarVisuals =
  1403. function(ui)
  1404. {
  1405. switch (settings.color.mode)
  1406. {
  1407. case 'h':
  1408. var a = ui.val('a');
  1409. setAlpha.call($this, colorBarL5, Math.precision(((255 - (a || 0)) * 100) / 255, 4));
  1410. break;
  1411. case 's':
  1412. var hva = ui.val('hva'),
  1413. saturatedColor = new Color({ h: hva && hva.h || 0, s: 100, v: hva != null ? hva.v : 100 });
  1414. setBG.call($this, colorBarDiv, saturatedColor.val('hex'));
  1415. setAlpha.call($this, colorBarL2, 100 - (hva != null ? hva.v : 100));
  1416. setAlpha.call($this, colorBarL5, Math.precision(((255 - (hva && hva.a || 0)) * 100) / 255, 4));
  1417. break;
  1418. case 'v':
  1419. var hsa = ui.val('hsa'),
  1420. valueColor = new Color({ h: hsa && hsa.h || 0, s: hsa != null ? hsa.s : 100, v: 100 });
  1421. setBG.call($this, colorBarDiv, valueColor.val('hex'));
  1422. setAlpha.call($this, colorBarL5, Math.precision(((255 - (hsa && hsa.a || 0)) * 100) / 255, 4));
  1423. break;
  1424. case 'r':
  1425. case 'g':
  1426. case 'b':
  1427. var hValue = 0, vValue = 0, rgba = ui.val('rgba');
  1428. if (settings.color.mode == 'r')
  1429. {
  1430. hValue = rgba && rgba.b || 0;
  1431. vValue = rgba && rgba.g || 0;
  1432. }
  1433. else if (settings.color.mode == 'g')
  1434. {
  1435. hValue = rgba && rgba.b || 0;
  1436. vValue = rgba && rgba.r || 0;
  1437. }
  1438. else if (settings.color.mode == 'b')
  1439. {
  1440. hValue = rgba && rgba.r || 0;
  1441. vValue = rgba && rgba.g || 0;
  1442. }
  1443. var middle = vValue > hValue ? hValue : vValue;
  1444. setAlpha.call($this, colorBarL2, hValue > vValue ? Math.precision(((hValue - vValue) / (255 - vValue)) * 100, 4) : 0);
  1445. setAlpha.call($this, colorBarL3, vValue > hValue ? Math.precision(((vValue - hValue) / (255 - hValue)) * 100, 4) : 0);
  1446. setAlpha.call($this, colorBarL4, Math.precision((middle / 255) * 100, 4));
  1447. setAlpha.call($this, colorBarL5, Math.precision(((255 - (rgba && rgba.a || 0)) * 100) / 255, 4));
  1448. break;
  1449. case 'a':
  1450. var a = ui.val('a');
  1451. setBG.call($this, colorBarDiv, ui.val('hex') || '000000');
  1452. setAlpha.call($this, colorBarL5, a != null ? 0 : 100);
  1453. setAlpha.call($this, colorBarL6, a != null ? 100 : 0);
  1454. break;
  1455. }
  1456. },
  1457. setBG =
  1458. function(el, c)
  1459. {
  1460. el.css({ backgroundColor: c && c.length == 6 && '#' + c || 'transparent' });
  1461. },
  1462. setImg =
  1463. function(img, src)
  1464. {
  1465. if (isLessThanIE7 && (src.indexOf('AlphaBar.png') != -1 || src.indexOf('Bars.png') != -1 || src.indexOf('Maps.png') != -1))
  1466. {
  1467. img.attr('pngSrc', src);
  1468. img.css({ backgroundImage: 'none', filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + src + '\', sizingMethod=\'scale\')' });
  1469. }
  1470. else img.css({ backgroundImage: 'url(\'' + src + '\')' });
  1471. },
  1472. setImgLoc =
  1473. function(img, y)
  1474. {
  1475. img.css({ top: y + 'px' });
  1476. },
  1477. setAlpha =
  1478. function(obj, alpha)
  1479. {
  1480. obj.css({ visibility: alpha > 0 ? 'visible' : 'hidden' });
  1481. if (alpha > 0 && alpha < 100)
  1482. {
  1483. if (isLessThanIE7)
  1484. {
  1485. var src = obj.attr('pngSrc');
  1486. if (src != null && (src.indexOf('AlphaBar.png') != -1 || src.indexOf('Bars.png') != -1 || src.indexOf('Maps.png') != -1))
  1487. obj.css({ filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + src + '\', sizingMethod=\'scale\') progid:DXImageTransform.Microsoft.Alpha(opacity=' + alpha + ')' });
  1488. else obj.css({ opacity: Math.precision(alpha / 100, 4) });
  1489. }
  1490. else obj.css({ opacity: Math.precision(alpha / 100, 4) });
  1491. }
  1492. else if (alpha == 0 || alpha == 100)
  1493. {
  1494. if (isLessThanIE7)
  1495. {
  1496. var src = obj.attr('pngSrc');
  1497. if (src != null && (src.indexOf('AlphaBar.png') != -1 || src.indexOf('Bars.png') != -1 || src.indexOf('Maps.png') != -1))
  1498. obj.css({ filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + src + '\', sizingMethod=\'scale\')' });
  1499. else obj.css({ opacity: '' });
  1500. }
  1501. else obj.css({ opacity: '' });
  1502. }
  1503. },
  1504. revertColor = // revert color to original color when opened
  1505. function()
  1506. {
  1507. color.active.val('ahex', color.current.val('ahex'));
  1508. },
  1509. commitColor = // commit the color changes
  1510. function()
  1511. {
  1512. color.current.val('ahex', color.active.val('ahex'));
  1513. },
  1514. radioClicked =
  1515. function(e)
  1516. {
  1517. $(this).parents('tbody:first').find('input:radio[value!="'+e.target.value+'"]').removeAttr('checked');
  1518. setColorMode.call($this, e.target.value);
  1519. },
  1520. currentClicked =
  1521. function()
  1522. {
  1523. revertColor.call($this);
  1524. },
  1525. cancelClicked =
  1526. function()
  1527. {
  1528. revertColor.call($this);
  1529. settings.window.expandable && hide.call($this);
  1530. $.isFunction(cancelCallback) && cancelCallback.call($this, color.active, cancelButton);
  1531. },
  1532. okClicked =
  1533. function()
  1534. {
  1535. commitColor.call($this);
  1536. settings.window.expandable && hide.call($this);
  1537. $.isFunction(commitCallback) && commitCallback.call($this, color.active, okButton);
  1538. },
  1539. iconImageClicked =
  1540. function()
  1541. {
  1542. show.call($this);
  1543. },
  1544. currentColorChanged =
  1545. function(ui, context)
  1546. {
  1547. var hex = ui.val('hex');
  1548. currentPreview.css({ backgroundColor: hex && '#' + hex || 'transparent' });
  1549. setAlpha.call($this, currentPreview, Math.precision(((ui.val('a') || 0) * 100) / 255, 4));
  1550. },
  1551. expandableColorChanged =
  1552. function(ui, context)
  1553. {
  1554. var hex = ui.val('hex');
  1555. var va = ui.val('va');
  1556. iconColor.css({ backgroundColor: hex && '#' + hex || 'transparent' });
  1557. setAlpha.call($this, iconAlpha, Math.precision(((255 - (va && va.a || 0)) * 100) / 255, 4));
  1558. if (settings.window.bindToInput&&settings.window.updateInputColor)
  1559. settings.window.input.css(
  1560. {
  1561. backgroundColor: hex && '#' + hex || 'transparent',
  1562. color: va == null || va.v > 75 ? '#000000' : '#ffffff'
  1563. });
  1564. },
  1565. moveBarMouseDown =
  1566. function(e)
  1567. {
  1568. var element = settings.window.element, // local copies for YUI compressor
  1569. page = settings.window.page;
  1570. elementStartX = parseInt(container.css('left'));
  1571. elementStartY = parseInt(container.css('top'));
  1572. pageStartX = e.pageX;
  1573. pageStartY = e.pageY;
  1574. // bind events to document to move window - we will unbind these on mouseup
  1575. $(document).bind('mousemove', documentMouseMove).bind('mouseup', documentMouseUp);
  1576. e.preventDefault(); // prevent attempted dragging of the column
  1577. },
  1578. documentMouseMove =
  1579. function(e)
  1580. {
  1581. container.css({ left: elementStartX - (pageStartX - e.pageX) + 'px', top: elementStartY - (pageStartY - e.pageY) + 'px' });
  1582. if (settings.window.expandable && !$.support.boxModel) container.prev().css({ left: container.css("left"), top: container.css("top") });
  1583. e.stopPropagation();
  1584. e.preventDefault();
  1585. return false;
  1586. },
  1587. documentMouseUp =
  1588. function(e)
  1589. {
  1590. $(document).unbind('mousemove', documentMouseMove).unbind('mouseup', documentMouseUp);
  1591. e.stopPropagation();
  1592. e.preventDefault();
  1593. return false;
  1594. },
  1595. quickPickClicked =
  1596. function(e)
  1597. {
  1598. e.preventDefault();
  1599. e.stopPropagation();
  1600. color.active.val('ahex', $(this).attr('title') || null, e.target);
  1601. return false;
  1602. },
  1603. commitCallback = $.isFunction($arguments[1]) && $arguments[1] || null,
  1604. liveCallback = $.isFunction($arguments[2]) && $arguments[2] || null,
  1605. cancelCallback = $.isFunction($arguments[3]) && $arguments[3] || null,
  1606. show =
  1607. function()
  1608. {
  1609. color.current.val('ahex', color.active.val('ahex'));
  1610. var attachIFrame = function()
  1611. {
  1612. if (!settings.window.expandable || $.support.boxModel) return;
  1613. var table = container.find('table:first');
  1614. container.before('<iframe/>');
  1615. container.prev().css({ width: table.width(), height: container.height(), opacity: 0, position: 'absolute', left: container.css("left"), top: container.css("top") });
  1616. };
  1617. if (settings.window.expandable)
  1618. {
  1619. $(document.body).children('div.jPicker.Container').css({zIndex:10});
  1620. container.css({zIndex:20});
  1621. }
  1622. switch (settings.window.effects.type)
  1623. {
  1624. case 'fade':
  1625. container.fadeIn(settings.window.effects.speed.show, attachIFrame);
  1626. break;
  1627. case 'slide':
  1628. container.slideDown(settings.window.effects.speed.show, attachIFrame);
  1629. break;
  1630. case 'show':
  1631. default:
  1632. container.show(settings.window.effects.speed.show, attachIFrame);
  1633. break;
  1634. }
  1635. },
  1636. hide =
  1637. function()
  1638. {
  1639. var removeIFrame = function()
  1640. {
  1641. if (settings.window.expandable) container.css({ zIndex: 10 });
  1642. if (!settings.window.expandable || $.support.boxModel) return;
  1643. container.prev().remove();
  1644. };
  1645. switch (settings.window.effects.type)
  1646. {
  1647. case 'fade':
  1648. container.fadeOut(settings.window.effects.speed.hide, removeIFrame);
  1649. break;
  1650. case 'slide':
  1651. container.slideUp(settings.window.effects.speed.hide, removeIFrame);
  1652. break;
  1653. case 'show':
  1654. default:
  1655. container.hide(settings.window.effects.speed.hide, removeIFrame);
  1656. break;
  1657. }
  1658. },
  1659. initialize =
  1660. function()
  1661. {
  1662. var win = settings.window,
  1663. popup = win.expandable ? $($this).next().find('.Container:first') : null;
  1664. container = win.expandable ? $('<div/>') : $($this);
  1665. container.addClass('jPicker Container');
  1666. if (win.expandable) container.hide();
  1667. container.get(0).onselectstart = function(event){ if (event.target.nodeName.toLowerCase() !== 'input') return false; };
  1668. // inject html source code - we are using a single table for this control - I know tables are considered bad, but it takes care of equal height columns and
  1669. // this control really is tabular data, so I believe it is the right move
  1670. var all = color.active.val('all');
  1671. if (win.alphaPrecision < 0) win.alphaPrecision = 0;
  1672. else if (win.alphaPrecision > 2) win.alphaPrecision = 2;
  1673. var controlHtml='<table class="jPicker" cellpadding="0" cellspacing="0"><tbody>' + (win.expandable ? '<tr><td class="Move" colspan="5">&nbsp;</td></tr>' : '') + '<tr><td rowspan="9"><h2 class="Title">' + (win.title || localization.text.title) + '</h2><div class="Map"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><img src="' + images.clientPath + images.colorMap.arrow.file + '" class="Arrow"/></div></td><td rowspan="9"><div class="Bar"><span class="Map1">&nbsp;</span><span class="Map2">&nbsp;</span><span class="Map3">&nbsp;</span><span class="Map4">&nbsp;</span><span class="Map5">&nbsp;</span><span class="Map6">&nbsp;</span><img src="' + images.clientPath + images.colorBar.arrow.file + '" class="Arrow"/></div></td><td colspan="2" class="Preview">' + localization.text.newColor + '<div><span class="Active" title="' + localization.tooltips.colors.newColor + '">&nbsp;</span><span class="Current" title="' + localization.tooltips.colors.currentColor + '">&nbsp;</span></div>' + localization.text.currentColor + '</td><td rowspan="9" class="Button"><input type="button" class="Ok" value="' + localization.text.ok + '" title="' + localization.tooltips.buttons.ok + '"/><input type="button" class="Cancel" value="' + localization.text.cancel + '" title="' + localization.tooltips.buttons.cancel + '"/><hr/><div class="Grid">&nbsp;</div></td></tr><tr class="Hue"><td class="Radio"><label title="' + localization.tooltips.hue.radio + '"><input type="radio" value="h"' + (settings.color.mode == 'h' ? ' checked="checked"' : '') + '/>H:</label></td><td class="Text"><input type="text" maxlength="3" value="' + (all != null ? all.h : '') + '" title="' + localization.tooltips.hue.textbox + '"/>&nbsp;&deg;</td></tr><tr class="Saturation"><td class="Radio"><label title="' + localization.tooltips.saturation.radio + '"><input type="radio" value="s"' + (settings.color.mode == 's' ? ' checked="checked"' : '') + '/>S:</label></td><td class="Text"><input type="text" maxlength="3" value="' + (all != null ? all.s : '') + '" title="' + localization.tooltips.saturation.textbox + '"/>&nbsp;%</td></tr><tr class="Value"><td class="Radio"><label title="' + localization.tooltips.value.radio + '"><input type="radio" value="v"' + (settings.color.mode == 'v' ? ' checked="checked"' : '') + '/>V:</label><br/><br/></td><td class="Text"><input type="text" maxlength="3" value="' + (all != null ? all.v : '') + '" title="' + localization.tooltips.value.textbox + '"/>&nbsp;%<br/><br/></td></tr><tr class="Red"><td class="Radio"><label title="' + localization.tooltips.red.radio + '"><input type="radio" value="r"' + (settings.color.mode == 'r' ? ' checked="checked"' : '') + '/>R:</label></td><td class="Text"><input type="text" maxlength="3" value="' + (all != null ? all.r : '') + '" title="' + localization.tooltips.red.textbox + '"/></td></tr><tr class="Green"><td class="Radio"><label title="' + localization.tooltips.green.radio + '"><input type="radio" value="g"' + (settings.color.mode == 'g' ? ' checked="checked"' : '') + '/>G:</label></td><td class="Text"><input type="text" maxlength="3" value="' + (all != null ? all.g : '') + '" title="' + localization.tooltips.green.textbox + '"/></td></tr><tr class="Blue"><td class="Radio"><label title="' + localization.tooltips.blue.radio + '"><input type="radio" value="b"' + (settings.color.mode == 'b' ? ' checked="checked"' : '') + '/>B:</label></td><td class="Text"><input type="text" maxlength="3" value="' + (all != null ? all.b : '') + '" title="' + localization.tooltips.blue.textbox + '"/></td></tr><tr class="Alpha"><td class="Radio">' + (win.alphaSupport ? '<label title="' + localization.tooltips.alpha.radio + '"><input type="radio" value="a"' + (settings.color.mode == 'a' ? ' checked="checked"' : '') + '/>A:</label>' : '&nbsp;') + '</td><td class="Text">' + (win.alphaSupport ? '<input type="text" maxlength="' + (3 + win.alphaPrecision) + '" value="' + (all != null ? Math.precision((all.a * 100) / 255, win.alphaPrecision) : '') + '" title="' + localization.tooltips.alpha.textbox + '"/>&nbsp;%' : '&nbsp;') + '</td></tr><tr class="Hex"><td colspan="2" class="Text"><label title="' + localization.tooltips.hex.textbox + '">#:<input type="text" maxlength="6" class="Hex" value="' + (all != null ? all.hex : '') + '"/></label>' + (win.alphaSupport ? '<input type="text" maxlength="2" class="AHex" value="' + (all != null ? all.ahex.substring(6) : '') + '" title="' + localization.tooltips.hex.alpha + '"/></td>' : '&nbsp;') + '</tr></tbody></table>';
  1674. if (win.expandable)
  1675. {
  1676. container.html(controlHtml);
  1677. if($(document.body).children('div.jPicker.Container').length==0)$(document.body).prepend(container);
  1678. else $(document.body).children('div.jPicker.Container:last').after(container);
  1679. container.mousedown(
  1680. function()
  1681. {
  1682. $(document.body).children('div.jPicker.Container').css({zIndex:10});
  1683. container.css({zIndex:20});
  1684. });
  1685. container.css( // positions must be set and display set to absolute before source code injection or IE will size the container to fit the window
  1686. {
  1687. left:
  1688. win.position.x == 'left' ? (popup.offset().left - 530 - (win.position.y == 'center' ? 25 : 0)) + 'px' :
  1689. win.position.x == 'center' ? (popup.offset().left - 260) + 'px' :
  1690. win.position.x == 'right' ? (popup.offset().left - 10 + (win.position.y == 'center' ? 25 : 0)) + 'px' :
  1691. win.position.x == 'screenCenter' ? (($(document).width() >> 1) - 260) + 'px' : (popup.offset().left + parseInt(win.position.x)) + 'px',
  1692. position: 'absolute',
  1693. top: win.position.y == 'top' ? (popup.offset().top - 312) + 'px' :
  1694. win.position.y == 'center' ? (popup.offset().top - 156) + 'px' :
  1695. win.position.y == 'bottom' ? (popup.offset().top + 25) + 'px' : (popup.offset().top + parseInt(win.position.y)) + 'px'
  1696. });
  1697. }
  1698. else
  1699. {
  1700. container = $($this);
  1701. container.html(controlHtml);
  1702. }
  1703. // initialize the objects to the source code just injected
  1704. var tbody = container.find('tbody:first');
  1705. colorMapDiv = tbody.find('div.Map:first');
  1706. colorBarDiv = tbody.find('div.Bar:first');
  1707. var MapMaps = colorMapDiv.find('span'),
  1708. BarMaps = colorBarDiv.find('span');
  1709. colorMapL1 = MapMaps.filter('.Map1:first');
  1710. colorMapL2 = MapMaps.filter('.Map2:first');
  1711. colorMapL3 = MapMaps.filter('.Map3:first');
  1712. colorBarL1 = BarMaps.filter('.Map1:first');
  1713. colorBarL2 = BarMaps.filter('.Map2:first');
  1714. colorBarL3 = BarMaps.filter('.Map3:first');
  1715. colorBarL4 = BarMaps.filter('.Map4:first');
  1716. colorBarL5 = BarMaps.filter('.Map5:first');
  1717. colorBarL6 = BarMaps.filter('.Map6:first');
  1718. // create color pickers and maps
  1719. colorMap = new Slider(colorMapDiv,
  1720. {
  1721. map:
  1722. {
  1723. width: images.colorMap.width,
  1724. height: images.colorMap.height
  1725. },
  1726. arrow:
  1727. {
  1728. image: images.clientPath + images.colorMap.arrow.file,
  1729. width: images.colorMap.arrow.width,
  1730. height: images.colorMap.arrow.height
  1731. }
  1732. });
  1733. colorMap.bind(mapValueChanged);
  1734. colorBar = new Slider(colorBarDiv,
  1735. {
  1736. map:
  1737. {
  1738. width: images.colorBar.width,
  1739. height: images.colorBar.height
  1740. },
  1741. arrow:
  1742. {
  1743. image: images.clientPath + images.colorBar.arrow.file,
  1744. width: images.colorBar.arrow.width,
  1745. height: images.colorBar.arrow.height
  1746. }
  1747. });
  1748. colorBar.bind(colorBarValueChanged);
  1749. colorPicker = new ColorValuePicker(tbody, color.active, win.expandable && win.bindToInput ? win.input : null, win.alphaPrecision);
  1750. var hex = all != null ? all.hex : null,
  1751. preview = tbody.find('.Preview'),
  1752. button = tbody.find('.Button');
  1753. activePreview = preview.find('.Active:first').css({ backgroundColor: hex && '#' + hex || 'transparent' });
  1754. currentPreview = preview.find('.Current:first').css({ backgroundColor: hex && '#' + hex || 'transparent' }).bind('click', currentClicked);
  1755. setAlpha.call($this, currentPreview, Math.precision(color.current.val('a') * 100) / 255, 4);
  1756. okButton = button.find('.Ok:first').bind('click', okClicked);
  1757. cancelButton = button.find('.Cancel:first').bind('click', cancelClicked);
  1758. grid = button.find('.Grid:first');
  1759. setTimeout(
  1760. function()
  1761. {
  1762. setImg.call($this, colorMapL1, images.clientPath + 'Maps.png');
  1763. setImg.call($this, colorMapL2, images.clientPath + 'Maps.png');
  1764. setImg.call($this, colorMapL3, images.clientPath + 'map-opacity.png');
  1765. setImg.call($this, colorBarL1, images.clientPath + 'Bars.png');
  1766. setImg.call($this, colorBarL2, images.clientPath + 'Bars.png');
  1767. setImg.call($this, colorBarL3, images.clientPath + 'Bars.png');
  1768. setImg.call($this, colorBarL4, images.clientPath + 'Bars.png');
  1769. setImg.call($this, colorBarL5, images.clientPath + 'bar-opacity.png');
  1770. setImg.call($this, colorBarL6, images.clientPath + 'AlphaBar.png');
  1771. setImg.call($this, preview.find('div:first'), images.clientPath + 'preview-opacity.png');
  1772. }, 0);
  1773. tbody.find('td.Radio input').bind('click', radioClicked);
  1774. // initialize quick list
  1775. if (color.quickList && color.quickList.length > 0)
  1776. {
  1777. var html = '';
  1778. for (i = 0; i < color.quickList.length; i++)
  1779. {
  1780. /* if default colors are hex strings, change them to color objects */
  1781. if ((typeof (color.quickList[i])).toString().toLowerCase() == 'string') color.quickList[i] = new Color({ hex: color.quickList[i] });
  1782. var alpha = color.quickList[i].val('a');
  1783. var ahex = color.quickList[i].val('ahex');
  1784. if (!win.alphaSupport && ahex) ahex = ahex.substring(0, 6) + 'ff';
  1785. var quickHex = color.quickList[i].val('hex');
  1786. if(!ahex) ahex = "00000000";
  1787. html+='<span class="QuickColor"' + (ahex && ' title="#' + ahex + '"' || 'none') + ' style="background-color:' + (quickHex && '#' + quickHex || '') + ';' + (quickHex ? '' : 'background-image:url(' + images.clientPath + 'NoColor.png)') + (win.alphaSupport && alpha && alpha < 255 ? ';opacity:' + Math.precision(alpha / 255, 4) + ';filter:Alpha(opacity=' + Math.precision(alpha / 2.55, 4) + ')' : '') + '">&nbsp;</span>';
  1788. }
  1789. setImg.call($this, grid, images.clientPath + 'bar-opacity.png');
  1790. grid.html(html);
  1791. grid.find('.QuickColor').click(quickPickClicked);
  1792. }
  1793. setColorMode.call($this, settings.color.mode);
  1794. color.active.bind(activeColorChanged);
  1795. $.isFunction(liveCallback) && color.active.bind(liveCallback);
  1796. color.current.bind(currentColorChanged);
  1797. // bind to input
  1798. if (win.expandable)
  1799. {
  1800. $this.icon = popup.parents('.Icon:first');
  1801. iconColor = $this.icon.find('.Color:first').css({ backgroundColor: hex && '#' + hex || 'transparent' });
  1802. iconAlpha = $this.icon.find('.Alpha:first');
  1803. setImg.call($this, iconAlpha, images.clientPath + 'bar-opacity.png');
  1804. setAlpha.call($this, iconAlpha, Math.precision(((255 - (all != null ? all.a : 0)) * 100) / 255, 4));
  1805. iconImage = $this.icon.find('.Image:first').css(
  1806. {
  1807. backgroundImage: 'url(\'' + images.clientPath + images.picker.file + '\')'
  1808. }).bind('click', iconImageClicked);
  1809. if (win.bindToInput&&win.updateInputColor)
  1810. win.input.css(
  1811. {
  1812. backgroundColor: hex && '#' + hex || 'transparent',
  1813. color: all == null || all.v > 75 ? '#000000' : '#ffffff'
  1814. });
  1815. moveBar = tbody.find('.Move:first').bind('mousedown', moveBarMouseDown);
  1816. color.active.bind(expandableColorChanged);
  1817. }
  1818. else show.call($this);
  1819. },
  1820. destroy =
  1821. function()
  1822. {
  1823. container.find('td.Radio input').unbind('click', radioClicked);
  1824. currentPreview.unbind('click', currentClicked);
  1825. cancelButton.unbind('click', cancelClicked);
  1826. okButton.unbind('click', okClicked);
  1827. if (settings.window.expandable)
  1828. {
  1829. iconImage.unbind('click', iconImageClicked);
  1830. moveBar.unbind('mousedown', moveBarMouseDown);
  1831. $this.icon = null;
  1832. }
  1833. container.find('.QuickColor').unbind('click', quickPickClicked);
  1834. colorMapDiv = null;
  1835. colorBarDiv = null;
  1836. colorMapL1 = null;
  1837. colorMapL2 = null;
  1838. colorMapL3 = null;
  1839. colorBarL1 = null;
  1840. colorBarL2 = null;
  1841. colorBarL3 = null;
  1842. colorBarL4 = null;
  1843. colorBarL5 = null;
  1844. colorBarL6 = null;
  1845. colorMap.destroy();
  1846. colorMap = null;
  1847. colorBar.destroy();
  1848. colorBar = null;
  1849. colorPicker.destroy();
  1850. colorPicker = null;
  1851. activePreview = null;
  1852. currentPreview = null;
  1853. okButton = null;
  1854. cancelButton = null;
  1855. grid = null;
  1856. commitCallback = null;
  1857. cancelCallback = null;
  1858. liveCallback = null;
  1859. container.html('');
  1860. for (i = 0; i < List.length; i++) if (List[i] == $this) List.splice(i, 1);
  1861. },
  1862. images = settings.images, // local copies for YUI compressor
  1863. localization = settings.localization,
  1864. color =
  1865. {
  1866. active: (typeof(settings.color.active)).toString().toLowerCase() == 'string' ? new Color({ ahex: !settings.window.alphaSupport && settings.color.active ? settings.color.active.substring(0, 6) + 'ff' : settings.color.active }) : new Color({ ahex: !settings.window.alphaSupport && settings.color.active.val('ahex') ? settings.color.active.val('ahex').substring(0, 6) + 'ff' : settings.color.active.val('ahex') }),
  1867. current: (typeof(settings.color.active)).toString().toLowerCase() == 'string' ? new Color({ ahex: !settings.window.alphaSupport && settings.color.active ? settings.color.active.substring(0, 6) + 'ff' : settings.color.active }) : new Color({ ahex: !settings.window.alphaSupport && settings.color.active.val('ahex') ? settings.color.active.val('ahex').substring(0, 6) + 'ff' : settings.color.active.val('ahex') }),
  1868. quickList: settings.color.quickList
  1869. };
  1870. $.extend(true, $this, // public properties, methods, and callbacks
  1871. {
  1872. commitCallback: commitCallback, // commitCallback function can be overridden to return the selected color to a method you specify when the user clicks "OK"
  1873. liveCallback: liveCallback, // liveCallback function can be overridden to return the selected color to a method you specify in live mode (continuous update)
  1874. cancelCallback: cancelCallback, // cancelCallback function can be overridden to a method you specify when the user clicks "Cancel"
  1875. color: color,
  1876. show: show,
  1877. hide: hide,
  1878. destroy: destroy // destroys this control entirely, removing all events and objects, and removing itself from the List
  1879. });
  1880. List.push($this);
  1881. setTimeout(
  1882. function()
  1883. {
  1884. initialize.call($this);
  1885. }, 0);
  1886. });
  1887. };
  1888. $.fn.jPicker.defaults = /* jPicker defaults - you can change anything in this section (such as the clientPath to your images) without fear of breaking the program */
  1889. {
  1890. window:
  1891. {
  1892. title: null, /* any title for the jPicker window itself - displays "Drag Markers To Pick A Color" if left null */
  1893. effects:
  1894. {
  1895. type: 'slide', /* effect used to show/hide an expandable picker. Acceptable values "slide", "show", "fade" */
  1896. speed:
  1897. {
  1898. show: 'slow', /* duration of "show" effect. Acceptable values are "fast", "slow", or time in ms */
  1899. hide: 'fast' /* duration of "hide" effect. Acceptable values are "fast", "slow", or time in ms */
  1900. }
  1901. },
  1902. position:
  1903. {
  1904. x: 'screenCenter', /* acceptable values "left", "center", "right", "screenCenter", or relative px value */
  1905. y: 'top' /* acceptable values "top", "bottom", "center", or relative px value */
  1906. },
  1907. expandable: false, /* default to large static picker - set to true to make an expandable picker (small icon with popup) - set automatically when binded to input element */
  1908. liveUpdate: true, /* set false if you want the user to have to click "OK" before the binded input box updates values (always "true" for expandable picker) */
  1909. alphaSupport: false, /* set to true to enable alpha picking */
  1910. alphaPrecision: 0, /* set decimal precision for alpha percentage display - hex codes do not map directly to percentage integers - range 0-2 */
  1911. updateInputColor: true /* set to false to prevent binded input colors from changing */
  1912. },
  1913. color:
  1914. {
  1915. mode: 'h', /* acceptabled values "h" (hue), "s" (saturation), "v" (value), "r" (red), "g" (green), "b" (blue), "a" (alpha) */
  1916. active: new Color({ ahex: '#ffcc00ff' }), /* acceptable values are any declared $.jPicker.Color object or string HEX value (e.g. #ffc000) WITH OR WITHOUT the "#" prefix */
  1917. quickList: /* the quick pick color list */
  1918. [
  1919. new Color({ h: 360, s: 33, v: 100 }), /* acceptable values are any declared $.jPicker.Color object or string HEX value (e.g. #ffc000) WITH OR WITHOUT the "#" prefix */
  1920. new Color({ h: 360, s: 66, v: 100 }),
  1921. new Color({ h: 360, s: 100, v: 100 }),
  1922. new Color({ h: 360, s: 100, v: 75 }),
  1923. new Color({ h: 360, s: 100, v: 50 }),
  1924. new Color({ h: 180, s: 0, v: 100 }),
  1925. new Color({ h: 30, s: 33, v: 100 }),
  1926. new Color({ h: 30, s: 66, v: 100 }),
  1927. new Color({ h: 30, s: 100, v: 100 }),
  1928. new Color({ h: 30, s: 100, v: 75 }),
  1929. new Color({ h: 30, s: 100, v: 50 }),
  1930. new Color({ h: 180, s: 0, v: 90 }),
  1931. new Color({ h: 60, s: 33, v: 100 }),
  1932. new Color({ h: 60, s: 66, v: 100 }),
  1933. new Color({ h: 60, s: 100, v: 100 }),
  1934. new Color({ h: 60, s: 100, v: 75 }),
  1935. new Color({ h: 60, s: 100, v: 50 }),
  1936. new Color({ h: 180, s: 0, v: 80 }),
  1937. new Color({ h: 90, s: 33, v: 100 }),
  1938. new Color({ h: 90, s: 66, v: 100 }),
  1939. new Color({ h: 90, s: 100, v: 100 }),
  1940. new Color({ h: 90, s: 100, v: 75 }),
  1941. new Color({ h: 90, s: 100, v: 50 }),
  1942. new Color({ h: 180, s: 0, v: 70 }),
  1943. new Color({ h: 120, s: 33, v: 100 }),
  1944. new Color({ h: 120, s: 66, v: 100 }),
  1945. new Color({ h: 120, s: 100, v: 100 }),
  1946. new Color({ h: 120, s: 100, v: 75 }),
  1947. new Color({ h: 120, s: 100, v: 50 }),
  1948. new Color({ h: 180, s: 0, v: 60 }),
  1949. new Color({ h: 150, s: 33, v: 100 }),
  1950. new Color({ h: 150, s: 66, v: 100 }),
  1951. new Color({ h: 150, s: 100, v: 100 }),
  1952. new Color({ h: 150, s: 100, v: 75 }),
  1953. new Color({ h: 150, s: 100, v: 50 }),
  1954. new Color({ h: 180, s: 0, v: 50 }),
  1955. new Color({ h: 180, s: 33, v: 100 }),
  1956. new Color({ h: 180, s: 66, v: 100 }),
  1957. new Color({ h: 180, s: 100, v: 100 }),
  1958. new Color({ h: 180, s: 100, v: 75 }),
  1959. new Color({ h: 180, s: 100, v: 50 }),
  1960. new Color({ h: 180, s: 0, v: 40 }),
  1961. new Color({ h: 210, s: 33, v: 100 }),
  1962. new Color({ h: 210, s: 66, v: 100 }),
  1963. new Color({ h: 210, s: 100, v: 100 }),
  1964. new Color({ h: 210, s: 100, v: 75 }),
  1965. new Color({ h: 210, s: 100, v: 50 }),
  1966. new Color({ h: 180, s: 0, v: 30 }),
  1967. new Color({ h: 240, s: 33, v: 100 }),
  1968. new Color({ h: 240, s: 66, v: 100 }),
  1969. new Color({ h: 240, s: 100, v: 100 }),
  1970. new Color({ h: 240, s: 100, v: 75 }),
  1971. new Color({ h: 240, s: 100, v: 50 }),
  1972. new Color({ h: 180, s: 0, v: 20 }),
  1973. new Color({ h: 270, s: 33, v: 100 }),
  1974. new Color({ h: 270, s: 66, v: 100 }),
  1975. new Color({ h: 270, s: 100, v: 100 }),
  1976. new Color({ h: 270, s: 100, v: 75 }),
  1977. new Color({ h: 270, s: 100, v: 50 }),
  1978. new Color({ h: 180, s: 0, v: 10 }),
  1979. new Color({ h: 300, s: 33, v: 100 }),
  1980. new Color({ h: 300, s: 66, v: 100 }),
  1981. new Color({ h: 300, s: 100, v: 100 }),
  1982. new Color({ h: 300, s: 100, v: 75 }),
  1983. new Color({ h: 300, s: 100, v: 50 }),
  1984. new Color({ h: 180, s: 0, v: 0 }),
  1985. new Color({ h: 330, s: 33, v: 100 }),
  1986. new Color({ h: 330, s: 66, v: 100 }),
  1987. new Color({ h: 330, s: 100, v: 100 }),
  1988. new Color({ h: 330, s: 100, v: 75 }),
  1989. new Color({ h: 330, s: 100, v: 50 }),
  1990. new Color()
  1991. ]
  1992. },
  1993. images:
  1994. {
  1995. clientPath: '/jPicker/images/', /* Path to image files */
  1996. colorMap:
  1997. {
  1998. width: 256,
  1999. height: 256,
  2000. arrow:
  2001. {
  2002. file: 'mappoint.gif', /* ColorMap arrow icon */
  2003. width: 15,
  2004. height: 15
  2005. }
  2006. },
  2007. colorBar:
  2008. {
  2009. width: 20,
  2010. height: 256,
  2011. arrow:
  2012. {
  2013. file: 'rangearrows.gif', /* ColorBar arrow icon */
  2014. width: 20,
  2015. height: 7
  2016. }
  2017. },
  2018. picker:
  2019. {
  2020. file: 'picker.gif', /* Color Picker icon */
  2021. width: 25,
  2022. height: 24
  2023. }
  2024. },
  2025. localization: /* alter these to change the text presented by the picker (e.g. different language) */
  2026. {
  2027. text:
  2028. {
  2029. title: 'Drag Markers To Pick A Color',
  2030. newColor: 'new',
  2031. currentColor: 'current',
  2032. ok: 'OK',
  2033. cancel: 'Cancel'
  2034. },
  2035. tooltips:
  2036. {
  2037. colors:
  2038. {
  2039. newColor: 'New Color - Press &ldquo;OK&rdquo; To Commit',
  2040. currentColor: 'Click To Revert To Original Color'
  2041. },
  2042. buttons:
  2043. {
  2044. ok: 'Commit To This Color Selection',
  2045. cancel: 'Cancel And Revert To Original Color'
  2046. },
  2047. hue:
  2048. {
  2049. radio: 'Set To &ldquo;Hue&rdquo; Color Mode',
  2050. textbox: 'Enter A &ldquo;Hue&rdquo; Value (0-360&deg;)'
  2051. },
  2052. saturation:
  2053. {
  2054. radio: 'Set To &ldquo;Saturation&rdquo; Color Mode',
  2055. textbox: 'Enter A &ldquo;Saturation&rdquo; Value (0-100%)'
  2056. },
  2057. value:
  2058. {
  2059. radio: 'Set To &ldquo;Value&rdquo; Color Mode',
  2060. textbox: 'Enter A &ldquo;Value&rdquo; Value (0-100%)'
  2061. },
  2062. red:
  2063. {
  2064. radio: 'Set To &ldquo;Red&rdquo; Color Mode',
  2065. textbox: 'Enter A &ldquo;Red&rdquo; Value (0-255)'
  2066. },
  2067. green:
  2068. {
  2069. radio: 'Set To &ldquo;Green&rdquo; Color Mode',
  2070. textbox: 'Enter A &ldquo;Green&rdquo; Value (0-255)'
  2071. },
  2072. blue:
  2073. {
  2074. radio: 'Set To &ldquo;Blue&rdquo; Color Mode',
  2075. textbox: 'Enter A &ldquo;Blue&rdquo; Value (0-255)'
  2076. },
  2077. alpha:
  2078. {
  2079. radio: 'Set To &ldquo;Alpha&rdquo; Color Mode',
  2080. textbox: 'Enter A &ldquo;Alpha&rdquo; Value (0-100)'
  2081. },
  2082. hex:
  2083. {
  2084. textbox: 'Enter A &ldquo;Hex&rdquo; Color Value (#000000-#ffffff)',
  2085. alpha: 'Enter A &ldquo;Alpha&rdquo; Value (#00-#ff)'
  2086. }
  2087. }
  2088. }
  2089. };
  2090. })(jQuery, '1.1.6');