sketchily 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (284) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +39 -0
  3. data/Rakefile +40 -0
  4. data/app/helpers/sketchily.rb~ +10 -0
  5. data/app/helpers/sketchily_helper.rb +10 -0
  6. data/app/views/sketchily/_embed.html.erb +28 -0
  7. data/app/views/sketchily/_embed.html.erb~ +28 -0
  8. data/app/views/sketchily/_embed.js.erb +50 -0
  9. data/app/views/sketchily/_embed.js.erb~ +50 -0
  10. data/app/views/sketchily/_sketchily.html.erb +23 -0
  11. data/app/views/sketchily/_sketchily.html.erb~ +23 -0
  12. data/app/views/sketchily/_sketchily_tag.html.erb +21 -0
  13. data/app/views/sketchily/_sketchily_tag.html.erb~ +21 -0
  14. data/app/views/sketchily/_svg_edit_tag.html.erb~ +51 -0
  15. data/app/views/sketchily/svg_edit_tag_.html~ +35 -0
  16. data/lib/sketchily.rb +15 -0
  17. data/lib/sketchily.rb~ +16 -0
  18. data/lib/sketchily/engine.rb +4 -0
  19. data/lib/sketchily/sketchily.rb +28 -0
  20. data/lib/sketchily/sketchily_show.rb~ +13 -0
  21. data/lib/sketchily/sketchily_tag.rb +15 -0
  22. data/lib/sketchily/svg_edit_tag.rb~ +9 -0
  23. data/lib/sketchily/version.rb +3 -0
  24. data/lib/sketchily/version.rb~ +3 -0
  25. data/spec/dummy/README.rdoc +261 -0
  26. data/spec/dummy/Rakefile +7 -0
  27. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  28. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  29. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  30. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  31. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  32. data/spec/dummy/config.ru +4 -0
  33. data/spec/dummy/config/application.rb +59 -0
  34. data/spec/dummy/config/boot.rb +10 -0
  35. data/spec/dummy/config/database.yml +25 -0
  36. data/spec/dummy/config/environment.rb +5 -0
  37. data/spec/dummy/config/environments/development.rb +37 -0
  38. data/spec/dummy/config/environments/production.rb +67 -0
  39. data/spec/dummy/config/environments/test.rb +37 -0
  40. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  41. data/spec/dummy/config/initializers/inflections.rb +15 -0
  42. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  43. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  44. data/spec/dummy/config/initializers/session_store.rb +8 -0
  45. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  46. data/spec/dummy/config/locales/en.yml +5 -0
  47. data/spec/dummy/config/routes.rb +58 -0
  48. data/spec/dummy/public/404.html +26 -0
  49. data/spec/dummy/public/422.html +26 -0
  50. data/spec/dummy/public/500.html +25 -0
  51. data/spec/dummy/public/favicon.ico +0 -0
  52. data/spec/dummy/script/rails +6 -0
  53. data/spec/lib/sketchily_spec.rb +0 -0
  54. data/spec/spec_helper.rb +11 -0
  55. data/vendor/assets/svg-edit-2.6/browser-not-supported.html +27 -0
  56. data/vendor/assets/svg-edit-2.6/browser.js +180 -0
  57. data/vendor/assets/svg-edit-2.6/canvg/canvg.js +2620 -0
  58. data/vendor/assets/svg-edit-2.6/canvg/rgbcolor.js +287 -0
  59. data/vendor/assets/svg-edit-2.6/contextmenu.js +67 -0
  60. data/vendor/assets/svg-edit-2.6/contextmenu/jquery.contextMenu.js +203 -0
  61. data/vendor/assets/svg-edit-2.6/draw.js +528 -0
  62. data/vendor/assets/svg-edit-2.6/embedapi.html +56 -0
  63. data/vendor/assets/svg-edit-2.6/embedapi.js +173 -0
  64. data/vendor/assets/svg-edit-2.6/extensions/closepath_icons.svg +41 -0
  65. data/vendor/assets/svg-edit-2.6/extensions/ext-arrows.js +298 -0
  66. data/vendor/assets/svg-edit-2.6/extensions/ext-closepath.js +92 -0
  67. data/vendor/assets/svg-edit-2.6/extensions/ext-connector.js +587 -0
  68. data/vendor/assets/svg-edit-2.6/extensions/ext-eyedropper.js +109 -0
  69. data/vendor/assets/svg-edit-2.6/extensions/ext-foreignobject.js +277 -0
  70. data/vendor/assets/svg-edit-2.6/extensions/ext-grid.js +184 -0
  71. data/vendor/assets/svg-edit-2.6/extensions/ext-helloworld.js +78 -0
  72. data/vendor/assets/svg-edit-2.6/extensions/ext-imagelib.js +453 -0
  73. data/vendor/assets/svg-edit-2.6/extensions/ext-imagelib.xml +14 -0
  74. data/vendor/assets/svg-edit-2.6/extensions/ext-markers.js +572 -0
  75. data/vendor/assets/svg-edit-2.6/extensions/ext-server_moinsave.js +56 -0
  76. data/vendor/assets/svg-edit-2.6/extensions/ext-server_opensave.js +180 -0
  77. data/vendor/assets/svg-edit-2.6/extensions/ext-shapes.js +387 -0
  78. data/vendor/assets/svg-edit-2.6/extensions/ext-shapes.xml +10 -0
  79. data/vendor/assets/svg-edit-2.6/extensions/eyedropper-icon.xml +34 -0
  80. data/vendor/assets/svg-edit-2.6/extensions/eyedropper.png +0 -0
  81. data/vendor/assets/svg-edit-2.6/extensions/fileopen.php +31 -0
  82. data/vendor/assets/svg-edit-2.6/extensions/filesave.php +44 -0
  83. data/vendor/assets/svg-edit-2.6/extensions/foreignobject-icons.xml +96 -0
  84. data/vendor/assets/svg-edit-2.6/extensions/grid-icon.xml +30 -0
  85. data/vendor/assets/svg-edit-2.6/extensions/helloworld-icon.xml +21 -0
  86. data/vendor/assets/svg-edit-2.6/extensions/imagelib/index.html +64 -0
  87. data/vendor/assets/svg-edit-2.6/extensions/imagelib/smiley.svg +12 -0
  88. data/vendor/assets/svg-edit-2.6/extensions/markers-icons.xml +115 -0
  89. data/vendor/assets/svg-edit-2.6/extensions/shapelib/animal.json +21 -0
  90. data/vendor/assets/svg-edit-2.6/extensions/shapelib/arrow.json +28 -0
  91. data/vendor/assets/svg-edit-2.6/extensions/shapelib/dialog_balloon.json +9 -0
  92. data/vendor/assets/svg-edit-2.6/extensions/shapelib/electronics.json +20 -0
  93. data/vendor/assets/svg-edit-2.6/extensions/shapelib/flowchart.json +25 -0
  94. data/vendor/assets/svg-edit-2.6/extensions/shapelib/game.json +13 -0
  95. data/vendor/assets/svg-edit-2.6/extensions/shapelib/math.json +9 -0
  96. data/vendor/assets/svg-edit-2.6/extensions/shapelib/misc.json +37 -0
  97. data/vendor/assets/svg-edit-2.6/extensions/shapelib/music.json +21 -0
  98. data/vendor/assets/svg-edit-2.6/extensions/shapelib/object.json +19 -0
  99. data/vendor/assets/svg-edit-2.6/extensions/shapelib/raphael.txt +12 -0
  100. data/vendor/assets/svg-edit-2.6/extensions/shapelib/raphael_1.json +67 -0
  101. data/vendor/assets/svg-edit-2.6/extensions/shapelib/raphael_2.json +64 -0
  102. data/vendor/assets/svg-edit-2.6/extensions/shapelib/symbol.json +28 -0
  103. data/vendor/assets/svg-edit-2.6/history.js +601 -0
  104. data/vendor/assets/svg-edit-2.6/images/README.txt +61 -0
  105. data/vendor/assets/svg-edit-2.6/images/align-bottom.png +0 -0
  106. data/vendor/assets/svg-edit-2.6/images/align-bottom.svg +277 -0
  107. data/vendor/assets/svg-edit-2.6/images/align-center.png +0 -0
  108. data/vendor/assets/svg-edit-2.6/images/align-center.svg +252 -0
  109. data/vendor/assets/svg-edit-2.6/images/align-left.png +0 -0
  110. data/vendor/assets/svg-edit-2.6/images/align-left.svg +235 -0
  111. data/vendor/assets/svg-edit-2.6/images/align-middle.png +0 -0
  112. data/vendor/assets/svg-edit-2.6/images/align-middle.svg +250 -0
  113. data/vendor/assets/svg-edit-2.6/images/align-right.png +0 -0
  114. data/vendor/assets/svg-edit-2.6/images/align-right.svg +233 -0
  115. data/vendor/assets/svg-edit-2.6/images/align-top.png +0 -0
  116. data/vendor/assets/svg-edit-2.6/images/align-top.svg +233 -0
  117. data/vendor/assets/svg-edit-2.6/images/bold.png +0 -0
  118. data/vendor/assets/svg-edit-2.6/images/cancel.png +0 -0
  119. data/vendor/assets/svg-edit-2.6/images/circle.png +0 -0
  120. data/vendor/assets/svg-edit-2.6/images/clear.png +0 -0
  121. data/vendor/assets/svg-edit-2.6/images/clone.png +0 -0
  122. data/vendor/assets/svg-edit-2.6/images/conn.svg +29 -0
  123. data/vendor/assets/svg-edit-2.6/images/copy.png +0 -0
  124. data/vendor/assets/svg-edit-2.6/images/cut.png +0 -0
  125. data/vendor/assets/svg-edit-2.6/images/delete.png +0 -0
  126. data/vendor/assets/svg-edit-2.6/images/document-properties.png +0 -0
  127. data/vendor/assets/svg-edit-2.6/images/dropdown.gif +0 -0
  128. data/vendor/assets/svg-edit-2.6/images/ellipse.png +0 -0
  129. data/vendor/assets/svg-edit-2.6/images/eye.png +0 -0
  130. data/vendor/assets/svg-edit-2.6/images/fhpath.png +0 -0
  131. data/vendor/assets/svg-edit-2.6/images/flyouth.png +0 -0
  132. data/vendor/assets/svg-edit-2.6/images/flyup.gif +0 -0
  133. data/vendor/assets/svg-edit-2.6/images/freehand-circle.png +0 -0
  134. data/vendor/assets/svg-edit-2.6/images/freehand-square.png +0 -0
  135. data/vendor/assets/svg-edit-2.6/images/go-down.png +0 -0
  136. data/vendor/assets/svg-edit-2.6/images/go-up.png +0 -0
  137. data/vendor/assets/svg-edit-2.6/images/image.png +0 -0
  138. data/vendor/assets/svg-edit-2.6/images/italic.png +0 -0
  139. data/vendor/assets/svg-edit-2.6/images/line.png +0 -0
  140. data/vendor/assets/svg-edit-2.6/images/link_controls.png +0 -0
  141. data/vendor/assets/svg-edit-2.6/images/logo.png +0 -0
  142. data/vendor/assets/svg-edit-2.6/images/logo.svg +32 -0
  143. data/vendor/assets/svg-edit-2.6/images/move_bottom.png +0 -0
  144. data/vendor/assets/svg-edit-2.6/images/move_top.png +0 -0
  145. data/vendor/assets/svg-edit-2.6/images/node_clone.png +0 -0
  146. data/vendor/assets/svg-edit-2.6/images/node_delete.png +0 -0
  147. data/vendor/assets/svg-edit-2.6/images/none.png +0 -0
  148. data/vendor/assets/svg-edit-2.6/images/open.png +0 -0
  149. data/vendor/assets/svg-edit-2.6/images/paste.png +0 -0
  150. data/vendor/assets/svg-edit-2.6/images/path.png +0 -0
  151. data/vendor/assets/svg-edit-2.6/images/polygon.png +0 -0
  152. data/vendor/assets/svg-edit-2.6/images/polygon.svg +219 -0
  153. data/vendor/assets/svg-edit-2.6/images/rect.png +0 -0
  154. data/vendor/assets/svg-edit-2.6/images/redo.png +0 -0
  155. data/vendor/assets/svg-edit-2.6/images/reorient.png +0 -0
  156. data/vendor/assets/svg-edit-2.6/images/rotate.png +0 -0
  157. data/vendor/assets/svg-edit-2.6/images/save.png +0 -0
  158. data/vendor/assets/svg-edit-2.6/images/select.png +0 -0
  159. data/vendor/assets/svg-edit-2.6/images/select_node.png +0 -0
  160. data/vendor/assets/svg-edit-2.6/images/sep.png +0 -0
  161. data/vendor/assets/svg-edit-2.6/images/shape_group.png +0 -0
  162. data/vendor/assets/svg-edit-2.6/images/shape_ungroup.png +0 -0
  163. data/vendor/assets/svg-edit-2.6/images/source.png +0 -0
  164. data/vendor/assets/svg-edit-2.6/images/spinbtn_updn_big.png +0 -0
  165. data/vendor/assets/svg-edit-2.6/images/square.png +0 -0
  166. data/vendor/assets/svg-edit-2.6/images/svg_edit_icons.svg +1034 -0
  167. data/vendor/assets/svg-edit-2.6/images/svg_edit_icons.svgz +0 -0
  168. data/vendor/assets/svg-edit-2.6/images/text.png +0 -0
  169. data/vendor/assets/svg-edit-2.6/images/text.svg +157 -0
  170. data/vendor/assets/svg-edit-2.6/images/to_path.png +0 -0
  171. data/vendor/assets/svg-edit-2.6/images/undo.png +0 -0
  172. data/vendor/assets/svg-edit-2.6/images/view-refresh.png +0 -0
  173. data/vendor/assets/svg-edit-2.6/images/wave.png +0 -0
  174. data/vendor/assets/svg-edit-2.6/images/wireframe.png +0 -0
  175. data/vendor/assets/svg-edit-2.6/images/zoom.png +0 -0
  176. data/vendor/assets/svg-edit-2.6/jgraduate/LICENSE +202 -0
  177. data/vendor/assets/svg-edit-2.6/jgraduate/README +3 -0
  178. data/vendor/assets/svg-edit-2.6/jgraduate/css/jPicker.css +1 -0
  179. data/vendor/assets/svg-edit-2.6/jgraduate/css/jgraduate.css +351 -0
  180. data/vendor/assets/svg-edit-2.6/jgraduate/images/AlphaBar.png +0 -0
  181. data/vendor/assets/svg-edit-2.6/jgraduate/images/Bars.png +0 -0
  182. data/vendor/assets/svg-edit-2.6/jgraduate/images/Maps.png +0 -0
  183. data/vendor/assets/svg-edit-2.6/jgraduate/images/NoColor.png +0 -0
  184. data/vendor/assets/svg-edit-2.6/jgraduate/images/bar-opacity.png +0 -0
  185. data/vendor/assets/svg-edit-2.6/jgraduate/images/map-opacity.png +0 -0
  186. data/vendor/assets/svg-edit-2.6/jgraduate/images/mappoint.gif +0 -0
  187. data/vendor/assets/svg-edit-2.6/jgraduate/images/mappoint_c.png +0 -0
  188. data/vendor/assets/svg-edit-2.6/jgraduate/images/mappoint_f.png +0 -0
  189. data/vendor/assets/svg-edit-2.6/jgraduate/images/picker.gif +0 -0
  190. data/vendor/assets/svg-edit-2.6/jgraduate/images/preview-opacity.png +0 -0
  191. data/vendor/assets/svg-edit-2.6/jgraduate/images/rangearrows.gif +0 -0
  192. data/vendor/assets/svg-edit-2.6/jgraduate/images/rangearrows2.gif +0 -0
  193. data/vendor/assets/svg-edit-2.6/jgraduate/jpicker.js +2091 -0
  194. data/vendor/assets/svg-edit-2.6/jgraduate/jpicker.min.js +1 -0
  195. data/vendor/assets/svg-edit-2.6/jgraduate/jquery.jgraduate.js +1175 -0
  196. data/vendor/assets/svg-edit-2.6/jgraduate/jquery.jgraduate.min.js +37 -0
  197. data/vendor/assets/svg-edit-2.6/jquery-ui/jquery-ui-1.8.17.custom.min.js +54 -0
  198. data/vendor/assets/svg-edit-2.6/jquery-ui/jquery-ui-1.8.custom.min.js +84 -0
  199. data/vendor/assets/svg-edit-2.6/jquery.js +4 -0
  200. data/vendor/assets/svg-edit-2.6/jquerybbq/jquery.bbq.min.js +18 -0
  201. data/vendor/assets/svg-edit-2.6/js-hotkeys/README.md +45 -0
  202. data/vendor/assets/svg-edit-2.6/js-hotkeys/jquery.hotkeys.min.js +15 -0
  203. data/vendor/assets/svg-edit-2.6/locale/README.txt +17 -0
  204. data/vendor/assets/svg-edit-2.6/locale/lang.af.js +234 -0
  205. data/vendor/assets/svg-edit-2.6/locale/lang.ar.js +234 -0
  206. data/vendor/assets/svg-edit-2.6/locale/lang.az.js +234 -0
  207. data/vendor/assets/svg-edit-2.6/locale/lang.be.js +234 -0
  208. data/vendor/assets/svg-edit-2.6/locale/lang.bg.js +234 -0
  209. data/vendor/assets/svg-edit-2.6/locale/lang.ca.js +234 -0
  210. data/vendor/assets/svg-edit-2.6/locale/lang.cs.js +234 -0
  211. data/vendor/assets/svg-edit-2.6/locale/lang.cy.js +234 -0
  212. data/vendor/assets/svg-edit-2.6/locale/lang.da.js +234 -0
  213. data/vendor/assets/svg-edit-2.6/locale/lang.de.js +234 -0
  214. data/vendor/assets/svg-edit-2.6/locale/lang.el.js +234 -0
  215. data/vendor/assets/svg-edit-2.6/locale/lang.en.js +234 -0
  216. data/vendor/assets/svg-edit-2.6/locale/lang.es.js +234 -0
  217. data/vendor/assets/svg-edit-2.6/locale/lang.et.js +234 -0
  218. data/vendor/assets/svg-edit-2.6/locale/lang.fa.js +234 -0
  219. data/vendor/assets/svg-edit-2.6/locale/lang.fi.js +234 -0
  220. data/vendor/assets/svg-edit-2.6/locale/lang.fr.js +234 -0
  221. data/vendor/assets/svg-edit-2.6/locale/lang.fy.js +234 -0
  222. data/vendor/assets/svg-edit-2.6/locale/lang.ga.js +234 -0
  223. data/vendor/assets/svg-edit-2.6/locale/lang.gl.js +234 -0
  224. data/vendor/assets/svg-edit-2.6/locale/lang.he.js +234 -0
  225. data/vendor/assets/svg-edit-2.6/locale/lang.hi.js +234 -0
  226. data/vendor/assets/svg-edit-2.6/locale/lang.hr.js +234 -0
  227. data/vendor/assets/svg-edit-2.6/locale/lang.hu.js +234 -0
  228. data/vendor/assets/svg-edit-2.6/locale/lang.hy.js +234 -0
  229. data/vendor/assets/svg-edit-2.6/locale/lang.id.js +234 -0
  230. data/vendor/assets/svg-edit-2.6/locale/lang.is.js +234 -0
  231. data/vendor/assets/svg-edit-2.6/locale/lang.it.js +234 -0
  232. data/vendor/assets/svg-edit-2.6/locale/lang.ja.js +234 -0
  233. data/vendor/assets/svg-edit-2.6/locale/lang.ko.js +234 -0
  234. data/vendor/assets/svg-edit-2.6/locale/lang.lt.js +234 -0
  235. data/vendor/assets/svg-edit-2.6/locale/lang.lv.js +234 -0
  236. data/vendor/assets/svg-edit-2.6/locale/lang.mk.js +234 -0
  237. data/vendor/assets/svg-edit-2.6/locale/lang.ms.js +234 -0
  238. data/vendor/assets/svg-edit-2.6/locale/lang.mt.js +234 -0
  239. data/vendor/assets/svg-edit-2.6/locale/lang.nl.js +234 -0
  240. data/vendor/assets/svg-edit-2.6/locale/lang.no.js +234 -0
  241. data/vendor/assets/svg-edit-2.6/locale/lang.pl.js +234 -0
  242. data/vendor/assets/svg-edit-2.6/locale/lang.pt-BR.js +234 -0
  243. data/vendor/assets/svg-edit-2.6/locale/lang.pt-PT.js +234 -0
  244. data/vendor/assets/svg-edit-2.6/locale/lang.ro.js +234 -0
  245. data/vendor/assets/svg-edit-2.6/locale/lang.ru.js +234 -0
  246. data/vendor/assets/svg-edit-2.6/locale/lang.sk.js +234 -0
  247. data/vendor/assets/svg-edit-2.6/locale/lang.sl.js +234 -0
  248. data/vendor/assets/svg-edit-2.6/locale/lang.sq.js +234 -0
  249. data/vendor/assets/svg-edit-2.6/locale/lang.sr.js +234 -0
  250. data/vendor/assets/svg-edit-2.6/locale/lang.sv.js +234 -0
  251. data/vendor/assets/svg-edit-2.6/locale/lang.sw.js +234 -0
  252. data/vendor/assets/svg-edit-2.6/locale/lang.test.js +234 -0
  253. data/vendor/assets/svg-edit-2.6/locale/lang.th.js +234 -0
  254. data/vendor/assets/svg-edit-2.6/locale/lang.tl.js +234 -0
  255. data/vendor/assets/svg-edit-2.6/locale/lang.tr.js +234 -0
  256. data/vendor/assets/svg-edit-2.6/locale/lang.uk.js +234 -0
  257. data/vendor/assets/svg-edit-2.6/locale/lang.vi.js +234 -0
  258. data/vendor/assets/svg-edit-2.6/locale/lang.yi.js +234 -0
  259. data/vendor/assets/svg-edit-2.6/locale/lang.zh-CN.js +234 -0
  260. data/vendor/assets/svg-edit-2.6/locale/lang.zh-HK.js +234 -0
  261. data/vendor/assets/svg-edit-2.6/locale/lang.zh-TW.js +234 -0
  262. data/vendor/assets/svg-edit-2.6/locale/locale.js +320 -0
  263. data/vendor/assets/svg-edit-2.6/math.js +246 -0
  264. data/vendor/assets/svg-edit-2.6/path.js +980 -0
  265. data/vendor/assets/svg-edit-2.6/sanitize.js +273 -0
  266. data/vendor/assets/svg-edit-2.6/select.js +532 -0
  267. data/vendor/assets/svg-edit-2.6/spinbtn/JQuerySpinBtn.css +41 -0
  268. data/vendor/assets/svg-edit-2.6/spinbtn/JQuerySpinBtn.js +266 -0
  269. data/vendor/assets/svg-edit-2.6/spinbtn/JQuerySpinBtn.min.js +7 -0
  270. data/vendor/assets/svg-edit-2.6/spinbtn/spinbtn_updn.png +0 -0
  271. data/vendor/assets/svg-edit-2.6/svg-editor.css +1495 -0
  272. data/vendor/assets/svg-edit-2.6/svg-editor.css~ +1500 -0
  273. data/vendor/assets/svg-edit-2.6/svg-editor.html +788 -0
  274. data/vendor/assets/svg-edit-2.6/svg-editor.html~ +788 -0
  275. data/vendor/assets/svg-edit-2.6/svg-editor.js +4969 -0
  276. data/vendor/assets/svg-edit-2.6/svg-editor.manifest +121 -0
  277. data/vendor/assets/svg-edit-2.6/svgcanvas.js +8775 -0
  278. data/vendor/assets/svg-edit-2.6/svgedit.compiled.js +465 -0
  279. data/vendor/assets/svg-edit-2.6/svgicons/jquery.svgicons.js +486 -0
  280. data/vendor/assets/svg-edit-2.6/svgtransformlist.js +291 -0
  281. data/vendor/assets/svg-edit-2.6/svgutils.js +651 -0
  282. data/vendor/assets/svg-edit-2.6/touch.js +30 -0
  283. data/vendor/assets/svg-edit-2.6/units.js +281 -0
  284. metadata +407 -0
@@ -0,0 +1,2091 @@
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
+
678
+ val.call($this, 'rgba', { r: ret.r, g: ret.g, b: ret.b, a: name == 'ahex' ? ret.a : a != null ? a : 255 }, context);
679
+ break;
680
+ default:
681
+ if (value && (value.ahex != null || value.hex != null))
682
+ {
683
+ val.call($this, 'ahex', value.ahex || value.hex || '00000000', context);
684
+ return;
685
+ }
686
+ var newV = {}, rgb = false, hsv = false;
687
+ if (value.r !== undefined && !name.indexOf('r') == -1) name += 'r';
688
+ if (value.g !== undefined && !name.indexOf('g') == -1) name += 'g';
689
+ if (value.b !== undefined && !name.indexOf('b') == -1) name += 'b';
690
+ if (value.a !== undefined && !name.indexOf('a') == -1) name += 'a';
691
+ if (value.h !== undefined && !name.indexOf('h') == -1) name += 'h';
692
+ if (value.s !== undefined && !name.indexOf('s') == -1) name += 's';
693
+ if (value.v !== undefined && !name.indexOf('v') == -1) name += 'v';
694
+ for (var i = 0; i < name.length; i++)
695
+ {
696
+ switch (name.charAt(i))
697
+ {
698
+ case 'r':
699
+ if (hsv) continue;
700
+ rgb = true;
701
+ newV.r = value && value.r && value.r | 0 || value && value | 0 || 0;
702
+ if (newV.r < 0) newV.r = 0;
703
+ else if (newV.r > 255) newV.r = 255;
704
+ if (r != newV.r)
705
+ {
706
+ r = newV.r;
707
+ changed = true;
708
+ }
709
+ break;
710
+ case 'g':
711
+ if (hsv) continue;
712
+ rgb = true;
713
+ newV.g = value && value.g && value.g | 0 || value && value | 0 || 0;
714
+ if (newV.g < 0) newV.g = 0;
715
+ else if (newV.g > 255) newV.g = 255;
716
+ if (g != newV.g)
717
+ {
718
+ g = newV.g;
719
+ changed = true;
720
+ }
721
+ break;
722
+ case 'b':
723
+ if (hsv) continue;
724
+ rgb = true;
725
+ newV.b = value && value.b && value.b | 0 || value && value | 0 || 0;
726
+ if (newV.b < 0) newV.b = 0;
727
+ else if (newV.b > 255) newV.b = 255;
728
+ if (b != newV.b)
729
+ {
730
+ b = newV.b;
731
+ changed = true;
732
+ }
733
+ break;
734
+ case 'a':
735
+ newV.a = value && value.a != null ? value.a | 0 : value != null ? value | 0 : 255;
736
+ if (newV.a < 0) newV.a = 0;
737
+ else if (newV.a > 255) newV.a = 255;
738
+ if (a != newV.a)
739
+ {
740
+ a = newV.a;
741
+ changed = true;
742
+ }
743
+ break;
744
+ case 'h':
745
+ if (rgb) continue;
746
+ hsv = true;
747
+ newV.h = value && value.h && value.h | 0 || value && value | 0 || 0;
748
+ if (newV.h < 0) newV.h = 0;
749
+ else if (newV.h > 360) newV.h = 360;
750
+ if (h != newV.h)
751
+ {
752
+ h = newV.h;
753
+ changed = true;
754
+ }
755
+ break;
756
+ case 's':
757
+ if (rgb) continue;
758
+ hsv = true;
759
+ newV.s = value && value.s != null ? value.s | 0 : value != null ? value | 0 : 100;
760
+ if (newV.s < 0) newV.s = 0;
761
+ else if (newV.s > 100) newV.s = 100;
762
+ if (s != newV.s)
763
+ {
764
+ s = newV.s;
765
+ changed = true;
766
+ }
767
+ break;
768
+ case 'v':
769
+ if (rgb) continue;
770
+ hsv = true;
771
+ newV.v = value && value.v != null ? value.v | 0 : value != null ? value | 0 : 100;
772
+ if (newV.v < 0) newV.v = 0;
773
+ else if (newV.v > 100) newV.v = 100;
774
+ if (v != newV.v)
775
+ {
776
+ v = newV.v;
777
+ changed = true;
778
+ }
779
+ break;
780
+ }
781
+ }
782
+ if (changed)
783
+ {
784
+ if (rgb)
785
+ {
786
+ r = r || 0;
787
+ g = g || 0;
788
+ b = b || 0;
789
+ var ret = ColorMethods.rgbToHsv({ r: r, g: g, b: b });
790
+ h = ret.h;
791
+ s = ret.s;
792
+ v = ret.v;
793
+ }
794
+ else if (hsv)
795
+ {
796
+ h = h || 0;
797
+ s = s != null ? s : 100;
798
+ v = v != null ? v : 100;
799
+ var ret = ColorMethods.hsvToRgb({ h: h, s: s, v: v });
800
+ r = ret.r;
801
+ g = ret.g;
802
+ b = ret.b;
803
+ }
804
+ a = a != null ? a : 255;
805
+ fireChangeEvents.call($this, context || $this);
806
+ }
807
+ break;
808
+ }
809
+ },
810
+ bind =
811
+ function(callback)
812
+ {
813
+ if ($.isFunction(callback)) changeEvents.push(callback);
814
+ },
815
+ unbind =
816
+ function(callback)
817
+ {
818
+ if (!$.isFunction(callback)) return;
819
+ var i;
820
+ while ((i = $.inArray(callback, changeEvents)) != -1) changeEvents.splice(i, 1);
821
+ },
822
+ destroy =
823
+ function()
824
+ {
825
+ changeEvents = null;
826
+ }
827
+ $.extend(true, $this, // public properties and methods
828
+ {
829
+ val: val,
830
+ bind: bind,
831
+ unbind: unbind,
832
+ destroy: destroy
833
+ });
834
+ if (init)
835
+ {
836
+ if (init.ahex != null) val('ahex', init);
837
+ else if (init.hex != null) val((init.a != null ? 'a' : '') + 'hex', init.a != null ? { ahex: init.hex + ColorMethods.intToHex(init.a) } : init);
838
+ else if (init.r != null && init.g != null && init.b != null) val('rgb' + (init.a != null ? 'a' : ''), init);
839
+ else if (init.h != null && init.s != null && init.v != null) val('hsv' + (init.a != null ? 'a' : ''), init);
840
+ }
841
+ },
842
+ ColorMethods: // color conversion methods - make public to give use to external scripts
843
+ {
844
+ hexToRgba:
845
+ function(hex)
846
+ {
847
+ if (hex === '' || hex === 'none') return { r: null, g: null, b: null, a: null };
848
+ hex = this.validateHex(hex);
849
+ var r = '00', g = '00', b = '00', a = '255';
850
+ if (hex.length == 6) hex += 'ff';
851
+ if (hex.length > 6)
852
+ {
853
+ r = hex.substring(0, 2);
854
+ g = hex.substring(2, 4);
855
+ b = hex.substring(4, 6);
856
+ a = hex.substring(6, hex.length);
857
+ }
858
+ else
859
+ {
860
+ if (hex.length > 4)
861
+ {
862
+ r = hex.substring(4, hex.length);
863
+ hex = hex.substring(0, 4);
864
+ }
865
+ if (hex.length > 2)
866
+ {
867
+ g = hex.substring(2, hex.length);
868
+ hex = hex.substring(0, 2);
869
+ }
870
+ if (hex.length > 0) b = hex.substring(0, hex.length);
871
+ }
872
+ return { r: this.hexToInt(r), g: this.hexToInt(g), b: this.hexToInt(b), a: this.hexToInt(a) };
873
+ },
874
+ validateHex:
875
+ function(hex)
876
+ {
877
+ //if (typeof hex === "object") return "";
878
+ hex = hex.toLowerCase().replace(/[^a-f0-9]/g, '');
879
+ if (hex.length > 8) hex = hex.substring(0, 8);
880
+ return hex;
881
+ },
882
+ rgbaToHex:
883
+ function(rgba)
884
+ {
885
+ return this.intToHex(rgba.r) + this.intToHex(rgba.g) + this.intToHex(rgba.b) + this.intToHex(rgba.a);
886
+ },
887
+ intToHex:
888
+ function(dec)
889
+ {
890
+ var result = (dec | 0).toString(16);
891
+ if (result.length == 1) result = ('0' + result);
892
+ return result.toLowerCase();
893
+ },
894
+ hexToInt:
895
+ function(hex)
896
+ {
897
+ return parseInt(hex, 16);
898
+ },
899
+ rgbToHsv:
900
+ function(rgb)
901
+ {
902
+ 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;
903
+ if (r >= g && r >= b)
904
+ {
905
+ max = r;
906
+ min = g > b ? b : g;
907
+ }
908
+ else if (g >= b && g >= r)
909
+ {
910
+ max = g;
911
+ min = r > b ? b : r;
912
+ }
913
+ else
914
+ {
915
+ max = b;
916
+ min = g > r ? r : g;
917
+ }
918
+ hsv.v = max;
919
+ hsv.s = max ? (max - min) / max : 0;
920
+ if (!hsv.s) hsv.h = 0;
921
+ else
922
+ {
923
+ delta = max - min;
924
+ if (r == max) hsv.h = (g - b) / delta;
925
+ else if (g == max) hsv.h = 2 + (b - r) / delta;
926
+ else hsv.h = 4 + (r - g) / delta;
927
+ hsv.h = parseInt(hsv.h * 60);
928
+ if (hsv.h < 0) hsv.h += 360;
929
+ }
930
+ hsv.s = (hsv.s * 100) | 0;
931
+ hsv.v = (hsv.v * 100) | 0;
932
+ return hsv;
933
+ },
934
+ hsvToRgb:
935
+ function(hsv)
936
+ {
937
+ var rgb = { r: 0, g: 0, b: 0, a: 100 }, h = hsv.h, s = hsv.s, v = hsv.v;
938
+ if (s == 0)
939
+ {
940
+ if (v == 0) rgb.r = rgb.g = rgb.b = 0;
941
+ else rgb.r = rgb.g = rgb.b = (v * 255 / 100) | 0;
942
+ }
943
+ else
944
+ {
945
+ if (h == 360) h = 0;
946
+ h /= 60;
947
+ s = s / 100;
948
+ v = v / 100;
949
+ var i = h | 0,
950
+ f = h - i,
951
+ p = v * (1 - s),
952
+ q = v * (1 - (s * f)),
953
+ t = v * (1 - (s * (1 - f)));
954
+ switch (i)
955
+ {
956
+ case 0:
957
+ rgb.r = v;
958
+ rgb.g = t;
959
+ rgb.b = p;
960
+ break;
961
+ case 1:
962
+ rgb.r = q;
963
+ rgb.g = v;
964
+ rgb.b = p;
965
+ break;
966
+ case 2:
967
+ rgb.r = p;
968
+ rgb.g = v;
969
+ rgb.b = t;
970
+ break;
971
+ case 3:
972
+ rgb.r = p;
973
+ rgb.g = q;
974
+ rgb.b = v;
975
+ break;
976
+ case 4:
977
+ rgb.r = t;
978
+ rgb.g = p;
979
+ rgb.b = v;
980
+ break;
981
+ case 5:
982
+ rgb.r = v;
983
+ rgb.g = p;
984
+ rgb.b = q;
985
+ break;
986
+ }
987
+ rgb.r = (rgb.r * 255) | 0;
988
+ rgb.g = (rgb.g * 255) | 0;
989
+ rgb.b = (rgb.b * 255) | 0;
990
+ }
991
+ return rgb;
992
+ }
993
+ }
994
+ };
995
+ var Color = $.jPicker.Color, List = $.jPicker.List, ColorMethods = $.jPicker.ColorMethods; // local copies for YUI compressor
996
+ $.fn.jPicker =
997
+ function(options)
998
+ {
999
+ var $arguments = arguments;
1000
+ return this.each(
1001
+ function()
1002
+ {
1003
+ var $this = this, settings = $.extend(true, {}, $.fn.jPicker.defaults, options); // local copies for YUI compressor
1004
+ if ($($this).get(0).nodeName.toLowerCase() == 'input') // Add color picker icon if binding to an input element and bind the events to the input
1005
+ {
1006
+ $.extend(true, settings,
1007
+ {
1008
+ window:
1009
+ {
1010
+ bindToInput: true,
1011
+ expandable: true,
1012
+ input: $($this)
1013
+ }
1014
+ });
1015
+ if($($this).val()=='')
1016
+ {
1017
+ settings.color.active = new Color({ hex: null });
1018
+ settings.color.current = new Color({ hex: null });
1019
+ }
1020
+ else if (ColorMethods.validateHex($($this).val()))
1021
+ {
1022
+ settings.color.active = new Color({ hex: $($this).val(), a: settings.color.active.val('a') });
1023
+ settings.color.current = new Color({ hex: $($this).val(), a: settings.color.active.val('a') });
1024
+ }
1025
+ }
1026
+ if (settings.window.expandable)
1027
+ $($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>');
1028
+ else settings.window.liveUpdate = false; // Basic control binding for inline use - You will need to override the liveCallback or commitCallback function to retrieve results
1029
+ var isLessThanIE7 = parseFloat(navigator.appVersion.split('MSIE')[1]) < 7 && document.body.filters, // needed to run the AlphaImageLoader function for IE6
1030
+ container = null,
1031
+ colorMapDiv = null,
1032
+ colorBarDiv = null,
1033
+ colorMapL1 = null, // different layers of colorMap and colorBar
1034
+ colorMapL2 = null,
1035
+ colorMapL3 = null,
1036
+ colorBarL1 = null,
1037
+ colorBarL2 = null,
1038
+ colorBarL3 = null,
1039
+ colorBarL4 = null,
1040
+ colorBarL5 = null,
1041
+ colorBarL6 = null,
1042
+ colorMap = null, // color maps
1043
+ colorBar = null,
1044
+ colorPicker = null,
1045
+ elementStartX = null, // Used to record the starting css positions for dragging the control
1046
+ elementStartY = null,
1047
+ pageStartX = null, // Used to record the mousedown coordinates for dragging the control
1048
+ pageStartY = null,
1049
+ activePreview = null, // color boxes above the radio buttons
1050
+ currentPreview = null,
1051
+ okButton = null,
1052
+ cancelButton = null,
1053
+ grid = null, // preset colors grid
1054
+ iconColor = null, // iconColor for popup icon
1055
+ iconAlpha = null, // iconAlpha for popup icon
1056
+ iconImage = null, // iconImage popup icon
1057
+ moveBar = null, // drag bar
1058
+ setColorMode = // set color mode and update visuals for the new color mode
1059
+ function(colorMode)
1060
+ {
1061
+ var active = color.active, // local copies for YUI compressor
1062
+ clientPath = images.clientPath,
1063
+ hex = active.val('hex'),
1064
+ rgbMap,
1065
+ rgbBar;
1066
+ settings.color.mode = colorMode;
1067
+ switch (colorMode)
1068
+ {
1069
+ case 'h':
1070
+ setTimeout(
1071
+ function()
1072
+ {
1073
+ setBG.call($this, colorMapDiv, 'transparent');
1074
+ setImgLoc.call($this, colorMapL1, 0);
1075
+ setAlpha.call($this, colorMapL1, 100);
1076
+ setImgLoc.call($this, colorMapL2, 260);
1077
+ setAlpha.call($this, colorMapL2, 100);
1078
+ setBG.call($this, colorBarDiv, 'transparent');
1079
+ setImgLoc.call($this, colorBarL1, 0);
1080
+ setAlpha.call($this, colorBarL1, 100);
1081
+ setImgLoc.call($this, colorBarL2, 260);
1082
+ setAlpha.call($this, colorBarL2, 100);
1083
+ setImgLoc.call($this, colorBarL3, 260);
1084
+ setAlpha.call($this, colorBarL3, 100);
1085
+ setImgLoc.call($this, colorBarL4, 260);
1086
+ setAlpha.call($this, colorBarL4, 100);
1087
+ setImgLoc.call($this, colorBarL6, 260);
1088
+ setAlpha.call($this, colorBarL6, 100);
1089
+ }, 0);
1090
+ colorMap.range('all', { minX: 0, maxX: 100, minY: 0, maxY: 100 });
1091
+ colorBar.range('rangeY', { minY: 0, maxY: 360 });
1092
+ if (active.val('ahex') == null) break;
1093
+ colorMap.val('xy', { x: active.val('s'), y: 100 - active.val('v') }, colorMap);
1094
+ colorBar.val('y', 360 - active.val('h'), colorBar);
1095
+ break;
1096
+ case 's':
1097
+ setTimeout(
1098
+ function()
1099
+ {
1100
+ setBG.call($this, colorMapDiv, 'transparent');
1101
+ setImgLoc.call($this, colorMapL1, -260);
1102
+ setImgLoc.call($this, colorMapL2, -520);
1103
+ setImgLoc.call($this, colorBarL1, -260);
1104
+ setImgLoc.call($this, colorBarL2, -520);
1105
+ setImgLoc.call($this, colorBarL6, 260);
1106
+ setAlpha.call($this, colorBarL6, 100);
1107
+ }, 0);
1108
+ colorMap.range('all', { minX: 0, maxX: 360, minY: 0, maxY: 100 });
1109
+ colorBar.range('rangeY', { minY: 0, maxY: 100 });
1110
+ if (active.val('ahex') == null) break;
1111
+ colorMap.val('xy', { x: active.val('h'), y: 100 - active.val('v') }, colorMap);
1112
+ colorBar.val('y', 100 - active.val('s'), colorBar);
1113
+ break;
1114
+ case 'v':
1115
+ setTimeout(
1116
+ function()
1117
+ {
1118
+ setBG.call($this, colorMapDiv, '000000');
1119
+ setImgLoc.call($this, colorMapL1, -780);
1120
+ setImgLoc.call($this, colorMapL2, 260);
1121
+ setBG.call($this, colorBarDiv, hex);
1122
+ setImgLoc.call($this, colorBarL1, -520);
1123
+ setImgLoc.call($this, colorBarL2, 260);
1124
+ setAlpha.call($this, colorBarL2, 100);
1125
+ setImgLoc.call($this, colorBarL6, 260);
1126
+ setAlpha.call($this, colorBarL6, 100);
1127
+ }, 0);
1128
+ colorMap.range('all', { minX: 0, maxX: 360, minY: 0, maxY: 100 });
1129
+ colorBar.range('rangeY', { minY: 0, maxY: 100 });
1130
+ if (active.val('ahex') == null) break;
1131
+ colorMap.val('xy', { x: active.val('h'), y: 100 - active.val('s') }, colorMap);
1132
+ colorBar.val('y', 100 - active.val('v'), colorBar);
1133
+ break;
1134
+ case 'r':
1135
+ rgbMap = -1040;
1136
+ rgbBar = -780;
1137
+ colorMap.range('all', { minX: 0, maxX: 255, minY: 0, maxY: 255 });
1138
+ colorBar.range('rangeY', { minY: 0, maxY: 255 });
1139
+ if (active.val('ahex') == null) break;
1140
+ colorMap.val('xy', { x: active.val('b'), y: 255 - active.val('g') }, colorMap);
1141
+ colorBar.val('y', 255 - active.val('r'), colorBar);
1142
+ break;
1143
+ case 'g':
1144
+ rgbMap = -1560;
1145
+ rgbBar = -1820;
1146
+ colorMap.range('all', { minX: 0, maxX: 255, minY: 0, maxY: 255 });
1147
+ colorBar.range('rangeY', { minY: 0, maxY: 255 });
1148
+ if (active.val('ahex') == null) break;
1149
+ colorMap.val('xy', { x: active.val('b'), y: 255 - active.val('r') }, colorMap);
1150
+ colorBar.val('y', 255 - active.val('g'), colorBar);
1151
+ break;
1152
+ case 'b':
1153
+ rgbMap = -2080;
1154
+ rgbBar = -2860;
1155
+ colorMap.range('all', { minX: 0, maxX: 255, minY: 0, maxY: 255 });
1156
+ colorBar.range('rangeY', { minY: 0, maxY: 255 });
1157
+ if (active.val('ahex') == null) break;
1158
+ colorMap.val('xy', { x: active.val('r'), y: 255 - active.val('g') }, colorMap);
1159
+ colorBar.val('y', 255 - active.val('b'), colorBar);
1160
+ break;
1161
+ case 'a':
1162
+ setTimeout(
1163
+ function()
1164
+ {
1165
+ setBG.call($this, colorMapDiv, 'transparent');
1166
+ setImgLoc.call($this, colorMapL1, -260);
1167
+ setImgLoc.call($this, colorMapL2, -520);
1168
+ setImgLoc.call($this, colorBarL1, 260);
1169
+ setImgLoc.call($this, colorBarL2, 260);
1170
+ setAlpha.call($this, colorBarL2, 100);
1171
+ setImgLoc.call($this, colorBarL6, 0);
1172
+ setAlpha.call($this, colorBarL6, 100);
1173
+ }, 0);
1174
+ colorMap.range('all', { minX: 0, maxX: 360, minY: 0, maxY: 100 });
1175
+ colorBar.range('rangeY', { minY: 0, maxY: 255 });
1176
+ if (active.val('ahex') == null) break;
1177
+ colorMap.val('xy', { x: active.val('h'), y: 100 - active.val('v') }, colorMap);
1178
+ colorBar.val('y', 255 - active.val('a'), colorBar);
1179
+ break;
1180
+ default:
1181
+ throw ('Invalid Mode');
1182
+ break;
1183
+ }
1184
+ switch (colorMode)
1185
+ {
1186
+ case 'h':
1187
+ break;
1188
+ case 's':
1189
+ case 'v':
1190
+ case 'a':
1191
+ setTimeout(
1192
+ function()
1193
+ {
1194
+ setAlpha.call($this, colorMapL1, 100);
1195
+ setAlpha.call($this, colorBarL1, 100);
1196
+ setImgLoc.call($this, colorBarL3, 260);
1197
+ setAlpha.call($this, colorBarL3, 100);
1198
+ setImgLoc.call($this, colorBarL4, 260);
1199
+ setAlpha.call($this, colorBarL4, 100);
1200
+ }, 0);
1201
+ break;
1202
+ case 'r':
1203
+ case 'g':
1204
+ case 'b':
1205
+ setTimeout(
1206
+ function()
1207
+ {
1208
+ setBG.call($this, colorMapDiv, 'transparent');
1209
+ setBG.call($this, colorBarDiv, 'transparent');
1210
+ setAlpha.call($this, colorBarL1, 100);
1211
+ setAlpha.call($this, colorMapL1, 100);
1212
+ setImgLoc.call($this, colorMapL1, rgbMap);
1213
+ setImgLoc.call($this, colorMapL2, rgbMap - 260);
1214
+ setImgLoc.call($this, colorBarL1, rgbBar - 780);
1215
+ setImgLoc.call($this, colorBarL2, rgbBar - 520);
1216
+ setImgLoc.call($this, colorBarL3, rgbBar);
1217
+ setImgLoc.call($this, colorBarL4, rgbBar - 260);
1218
+ setImgLoc.call($this, colorBarL6, 260);
1219
+ setAlpha.call($this, colorBarL6, 100);
1220
+ }, 0);
1221
+ break;
1222
+ }
1223
+ if (active.val('ahex') == null) return;
1224
+ activeColorChanged.call($this, active);
1225
+ },
1226
+ activeColorChanged = // Update color when user changes text values
1227
+ function(ui, context)
1228
+ {
1229
+ if (context == null || (context != colorBar && context != colorMap)) positionMapAndBarArrows.call($this, ui, context);
1230
+ setTimeout(
1231
+ function()
1232
+ {
1233
+ updatePreview.call($this, ui);
1234
+ updateMapVisuals.call($this, ui);
1235
+ updateBarVisuals.call($this, ui);
1236
+ }, 0);
1237
+ },
1238
+ mapValueChanged = // user has dragged the ColorMap pointer
1239
+ function(ui, context)
1240
+ {
1241
+ var active = color.active;
1242
+ if (context != colorMap && active.val() == null) return;
1243
+ var xy = ui.val('all');
1244
+ switch (settings.color.mode)
1245
+ {
1246
+ case 'h':
1247
+ active.val('sv', { s: xy.x, v: 100 - xy.y }, context);
1248
+ break;
1249
+ case 's':
1250
+ case 'a':
1251
+ active.val('hv', { h: xy.x, v: 100 - xy.y }, context);
1252
+ break;
1253
+ case 'v':
1254
+ active.val('hs', { h: xy.x, s: 100 - xy.y }, context);
1255
+ break;
1256
+ case 'r':
1257
+ active.val('gb', { g: 255 - xy.y, b: xy.x }, context);
1258
+ break;
1259
+ case 'g':
1260
+ active.val('rb', { r: 255 - xy.y, b: xy.x }, context);
1261
+ break;
1262
+ case 'b':
1263
+ active.val('rg', { r: xy.x, g: 255 - xy.y }, context);
1264
+ break;
1265
+ }
1266
+ },
1267
+ colorBarValueChanged = // user has dragged the ColorBar slider
1268
+ function(ui, context)
1269
+ {
1270
+ var active = color.active;
1271
+ if (context != colorBar && active.val() == null) return;
1272
+ switch (settings.color.mode)
1273
+ {
1274
+ case 'h':
1275
+ active.val('h', { h: 360 - ui.val('y') }, context);
1276
+ break;
1277
+ case 's':
1278
+ active.val('s', { s: 100 - ui.val('y') }, context);
1279
+ break;
1280
+ case 'v':
1281
+ active.val('v', { v: 100 - ui.val('y') }, context);
1282
+ break;
1283
+ case 'r':
1284
+ active.val('r', { r: 255 - ui.val('y') }, context);
1285
+ break;
1286
+ case 'g':
1287
+ active.val('g', { g: 255 - ui.val('y') }, context);
1288
+ break;
1289
+ case 'b':
1290
+ active.val('b', { b: 255 - ui.val('y') }, context);
1291
+ break;
1292
+ case 'a':
1293
+ active.val('a', 255 - ui.val('y'), context);
1294
+ break;
1295
+ }
1296
+ },
1297
+ positionMapAndBarArrows = // position map and bar arrows to match current color
1298
+ function(ui, context)
1299
+ {
1300
+ if (context != colorMap)
1301
+ {
1302
+ switch (settings.color.mode)
1303
+ {
1304
+ case 'h':
1305
+ var sv = ui.val('sv');
1306
+ colorMap.val('xy', { x: sv != null ? sv.s : 100, y: 100 - (sv != null ? sv.v : 100) }, context);
1307
+ break;
1308
+ case 's':
1309
+ case 'a':
1310
+ var hv = ui.val('hv');
1311
+ colorMap.val('xy', { x: hv && hv.h || 0, y: 100 - (hv != null ? hv.v : 100) }, context);
1312
+ break;
1313
+ case 'v':
1314
+ var hs = ui.val('hs');
1315
+ colorMap.val('xy', { x: hs && hs.h || 0, y: 100 - (hs != null ? hs.s : 100) }, context);
1316
+ break;
1317
+ case 'r':
1318
+ var bg = ui.val('bg');
1319
+ colorMap.val('xy', { x: bg && bg.b || 0, y: 255 - (bg && bg.g || 0) }, context);
1320
+ break;
1321
+ case 'g':
1322
+ var br = ui.val('br');
1323
+ colorMap.val('xy', { x: br && br.b || 0, y: 255 - (br && br.r || 0) }, context);
1324
+ break;
1325
+ case 'b':
1326
+ var rg = ui.val('rg');
1327
+ colorMap.val('xy', { x: rg && rg.r || 0, y: 255 - (rg && rg.g || 0) }, context);
1328
+ break;
1329
+ }
1330
+ }
1331
+ if (context != colorBar)
1332
+ {
1333
+ switch (settings.color.mode)
1334
+ {
1335
+ case 'h':
1336
+ colorBar.val('y', 360 - (ui.val('h') || 0), context);
1337
+ break;
1338
+ case 's':
1339
+ var s = ui.val('s');
1340
+ colorBar.val('y', 100 - (s != null ? s : 100), context);
1341
+ break;
1342
+ case 'v':
1343
+ var v = ui.val('v');
1344
+ colorBar.val('y', 100 - (v != null ? v : 100), context);
1345
+ break;
1346
+ case 'r':
1347
+ colorBar.val('y', 255 - (ui.val('r') || 0), context);
1348
+ break;
1349
+ case 'g':
1350
+ colorBar.val('y', 255 - (ui.val('g') || 0), context);
1351
+ break;
1352
+ case 'b':
1353
+ colorBar.val('y', 255 - (ui.val('b') || 0), context);
1354
+ break;
1355
+ case 'a':
1356
+ var a = ui.val('a');
1357
+ colorBar.val('y', 255 - (a != null ? a : 255), context);
1358
+ break;
1359
+ }
1360
+ }
1361
+ },
1362
+ updatePreview =
1363
+ function(ui)
1364
+ {
1365
+ try
1366
+ {
1367
+ var all = ui.val('all');
1368
+ activePreview.css({ backgroundColor: all && '#' + all.hex || 'transparent' });
1369
+ setAlpha.call($this, activePreview, all && Math.precision((all.a * 100) / 255, 4) || 0);
1370
+ }
1371
+ catch (e) { }
1372
+ },
1373
+ updateMapVisuals =
1374
+ function(ui)
1375
+ {
1376
+ switch (settings.color.mode)
1377
+ {
1378
+ case 'h':
1379
+ setBG.call($this, colorMapDiv, new Color({ h: ui.val('h') || 0, s: 100, v: 100 }).val('hex'));
1380
+ break;
1381
+ case 's':
1382
+ case 'a':
1383
+ var s = ui.val('s');
1384
+ setAlpha.call($this, colorMapL2, 100 - (s != null ? s : 100));
1385
+ break;
1386
+ case 'v':
1387
+ var v = ui.val('v');
1388
+ setAlpha.call($this, colorMapL1, v != null ? v : 100);
1389
+ break;
1390
+ case 'r':
1391
+ setAlpha.call($this, colorMapL2, Math.precision((ui.val('r') || 0) / 255 * 100, 4));
1392
+ break;
1393
+ case 'g':
1394
+ setAlpha.call($this, colorMapL2, Math.precision((ui.val('g') || 0) / 255 * 100, 4));
1395
+ break;
1396
+ case 'b':
1397
+ setAlpha.call($this, colorMapL2, Math.precision((ui.val('b') || 0) / 255 * 100));
1398
+ break;
1399
+ }
1400
+ var a = ui.val('a');
1401
+ setAlpha.call($this, colorMapL3, Math.precision(((255 - (a || 0)) * 100) / 255, 4));
1402
+ },
1403
+ updateBarVisuals =
1404
+ function(ui)
1405
+ {
1406
+ switch (settings.color.mode)
1407
+ {
1408
+ case 'h':
1409
+ var a = ui.val('a');
1410
+ setAlpha.call($this, colorBarL5, Math.precision(((255 - (a || 0)) * 100) / 255, 4));
1411
+ break;
1412
+ case 's':
1413
+ var hva = ui.val('hva'),
1414
+ saturatedColor = new Color({ h: hva && hva.h || 0, s: 100, v: hva != null ? hva.v : 100 });
1415
+ setBG.call($this, colorBarDiv, saturatedColor.val('hex'));
1416
+ setAlpha.call($this, colorBarL2, 100 - (hva != null ? hva.v : 100));
1417
+ setAlpha.call($this, colorBarL5, Math.precision(((255 - (hva && hva.a || 0)) * 100) / 255, 4));
1418
+ break;
1419
+ case 'v':
1420
+ var hsa = ui.val('hsa'),
1421
+ valueColor = new Color({ h: hsa && hsa.h || 0, s: hsa != null ? hsa.s : 100, v: 100 });
1422
+ setBG.call($this, colorBarDiv, valueColor.val('hex'));
1423
+ setAlpha.call($this, colorBarL5, Math.precision(((255 - (hsa && hsa.a || 0)) * 100) / 255, 4));
1424
+ break;
1425
+ case 'r':
1426
+ case 'g':
1427
+ case 'b':
1428
+ var hValue = 0, vValue = 0, rgba = ui.val('rgba');
1429
+ if (settings.color.mode == 'r')
1430
+ {
1431
+ hValue = rgba && rgba.b || 0;
1432
+ vValue = rgba && rgba.g || 0;
1433
+ }
1434
+ else if (settings.color.mode == 'g')
1435
+ {
1436
+ hValue = rgba && rgba.b || 0;
1437
+ vValue = rgba && rgba.r || 0;
1438
+ }
1439
+ else if (settings.color.mode == 'b')
1440
+ {
1441
+ hValue = rgba && rgba.r || 0;
1442
+ vValue = rgba && rgba.g || 0;
1443
+ }
1444
+ var middle = vValue > hValue ? hValue : vValue;
1445
+ setAlpha.call($this, colorBarL2, hValue > vValue ? Math.precision(((hValue - vValue) / (255 - vValue)) * 100, 4) : 0);
1446
+ setAlpha.call($this, colorBarL3, vValue > hValue ? Math.precision(((vValue - hValue) / (255 - hValue)) * 100, 4) : 0);
1447
+ setAlpha.call($this, colorBarL4, Math.precision((middle / 255) * 100, 4));
1448
+ setAlpha.call($this, colorBarL5, Math.precision(((255 - (rgba && rgba.a || 0)) * 100) / 255, 4));
1449
+ break;
1450
+ case 'a':
1451
+ var a = ui.val('a');
1452
+ setBG.call($this, colorBarDiv, ui.val('hex') || '000000');
1453
+ setAlpha.call($this, colorBarL5, a != null ? 0 : 100);
1454
+ setAlpha.call($this, colorBarL6, a != null ? 100 : 0);
1455
+ break;
1456
+ }
1457
+ },
1458
+ setBG =
1459
+ function(el, c)
1460
+ {
1461
+ el.css({ backgroundColor: c && c.length == 6 && '#' + c || 'transparent' });
1462
+ },
1463
+ setImg =
1464
+ function(img, src)
1465
+ {
1466
+ if (isLessThanIE7 && (src.indexOf('AlphaBar.png') != -1 || src.indexOf('Bars.png') != -1 || src.indexOf('Maps.png') != -1))
1467
+ {
1468
+ img.attr('pngSrc', src);
1469
+ img.css({ backgroundImage: 'none', filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + src + '\', sizingMethod=\'scale\')' });
1470
+ }
1471
+ else img.css({ backgroundImage: 'url(\'' + src + '\')' });
1472
+ },
1473
+ setImgLoc =
1474
+ function(img, y)
1475
+ {
1476
+ img.css({ top: y + 'px' });
1477
+ },
1478
+ setAlpha =
1479
+ function(obj, alpha)
1480
+ {
1481
+ obj.css({ visibility: alpha > 0 ? 'visible' : 'hidden' });
1482
+ if (alpha > 0 && alpha < 100)
1483
+ {
1484
+ if (isLessThanIE7)
1485
+ {
1486
+ var src = obj.attr('pngSrc');
1487
+ if (src != null && (src.indexOf('AlphaBar.png') != -1 || src.indexOf('Bars.png') != -1 || src.indexOf('Maps.png') != -1))
1488
+ obj.css({ filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + src + '\', sizingMethod=\'scale\') progid:DXImageTransform.Microsoft.Alpha(opacity=' + alpha + ')' });
1489
+ else obj.css({ opacity: Math.precision(alpha / 100, 4) });
1490
+ }
1491
+ else obj.css({ opacity: Math.precision(alpha / 100, 4) });
1492
+ }
1493
+ else if (alpha == 0 || alpha == 100)
1494
+ {
1495
+ if (isLessThanIE7)
1496
+ {
1497
+ var src = obj.attr('pngSrc');
1498
+ if (src != null && (src.indexOf('AlphaBar.png') != -1 || src.indexOf('Bars.png') != -1 || src.indexOf('Maps.png') != -1))
1499
+ obj.css({ filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + src + '\', sizingMethod=\'scale\')' });
1500
+ else obj.css({ opacity: '' });
1501
+ }
1502
+ else obj.css({ opacity: '' });
1503
+ }
1504
+ },
1505
+ revertColor = // revert color to original color when opened
1506
+ function()
1507
+ {
1508
+ color.active.val('ahex', color.current.val('ahex'));
1509
+ },
1510
+ commitColor = // commit the color changes
1511
+ function()
1512
+ {
1513
+ color.current.val('ahex', color.active.val('ahex'));
1514
+ },
1515
+ radioClicked =
1516
+ function(e)
1517
+ {
1518
+ $(this).parents('tbody:first').find('input:radio[value!="'+e.target.value+'"]').removeAttr('checked');
1519
+ setColorMode.call($this, e.target.value);
1520
+ },
1521
+ currentClicked =
1522
+ function()
1523
+ {
1524
+ revertColor.call($this);
1525
+ },
1526
+ cancelClicked =
1527
+ function()
1528
+ {
1529
+ revertColor.call($this);
1530
+ settings.window.expandable && hide.call($this);
1531
+ $.isFunction(cancelCallback) && cancelCallback.call($this, color.active, cancelButton);
1532
+ },
1533
+ okClicked =
1534
+ function()
1535
+ {
1536
+ commitColor.call($this);
1537
+ settings.window.expandable && hide.call($this);
1538
+ $.isFunction(commitCallback) && commitCallback.call($this, color.active, okButton);
1539
+ },
1540
+ iconImageClicked =
1541
+ function()
1542
+ {
1543
+ show.call($this);
1544
+ },
1545
+ currentColorChanged =
1546
+ function(ui, context)
1547
+ {
1548
+ var hex = ui.val('hex');
1549
+ currentPreview.css({ backgroundColor: hex && '#' + hex || 'transparent' });
1550
+ setAlpha.call($this, currentPreview, Math.precision(((ui.val('a') || 0) * 100) / 255, 4));
1551
+ },
1552
+ expandableColorChanged =
1553
+ function(ui, context)
1554
+ {
1555
+ var hex = ui.val('hex');
1556
+ var va = ui.val('va');
1557
+ iconColor.css({ backgroundColor: hex && '#' + hex || 'transparent' });
1558
+ setAlpha.call($this, iconAlpha, Math.precision(((255 - (va && va.a || 0)) * 100) / 255, 4));
1559
+ if (settings.window.bindToInput&&settings.window.updateInputColor)
1560
+ settings.window.input.css(
1561
+ {
1562
+ backgroundColor: hex && '#' + hex || 'transparent',
1563
+ color: va == null || va.v > 75 ? '#000000' : '#ffffff'
1564
+ });
1565
+ },
1566
+ moveBarMouseDown =
1567
+ function(e)
1568
+ {
1569
+ var element = settings.window.element, // local copies for YUI compressor
1570
+ page = settings.window.page;
1571
+ elementStartX = parseInt(container.css('left'));
1572
+ elementStartY = parseInt(container.css('top'));
1573
+ pageStartX = e.pageX;
1574
+ pageStartY = e.pageY;
1575
+ // bind events to document to move window - we will unbind these on mouseup
1576
+ $(document).bind('mousemove', documentMouseMove).bind('mouseup', documentMouseUp);
1577
+ e.preventDefault(); // prevent attempted dragging of the column
1578
+ },
1579
+ documentMouseMove =
1580
+ function(e)
1581
+ {
1582
+ container.css({ left: elementStartX - (pageStartX - e.pageX) + 'px', top: elementStartY - (pageStartY - e.pageY) + 'px' });
1583
+ if (settings.window.expandable && !$.support.boxModel) container.prev().css({ left: container.css("left"), top: container.css("top") });
1584
+ e.stopPropagation();
1585
+ e.preventDefault();
1586
+ return false;
1587
+ },
1588
+ documentMouseUp =
1589
+ function(e)
1590
+ {
1591
+ $(document).unbind('mousemove', documentMouseMove).unbind('mouseup', documentMouseUp);
1592
+ e.stopPropagation();
1593
+ e.preventDefault();
1594
+ return false;
1595
+ },
1596
+ quickPickClicked =
1597
+ function(e)
1598
+ {
1599
+ e.preventDefault();
1600
+ e.stopPropagation();
1601
+ color.active.val('ahex', $(this).attr('title') || null, e.target);
1602
+ return false;
1603
+ },
1604
+ commitCallback = $.isFunction($arguments[1]) && $arguments[1] || null,
1605
+ liveCallback = $.isFunction($arguments[2]) && $arguments[2] || null,
1606
+ cancelCallback = $.isFunction($arguments[3]) && $arguments[3] || null,
1607
+ show =
1608
+ function()
1609
+ {
1610
+ color.current.val('ahex', color.active.val('ahex'));
1611
+ var attachIFrame = function()
1612
+ {
1613
+ if (!settings.window.expandable || $.support.boxModel) return;
1614
+ var table = container.find('table:first');
1615
+ container.before('<iframe/>');
1616
+ container.prev().css({ width: table.width(), height: container.height(), opacity: 0, position: 'absolute', left: container.css("left"), top: container.css("top") });
1617
+ };
1618
+ if (settings.window.expandable)
1619
+ {
1620
+ $(document.body).children('div.jPicker.Container').css({zIndex:10});
1621
+ container.css({zIndex:20});
1622
+ }
1623
+ switch (settings.window.effects.type)
1624
+ {
1625
+ case 'fade':
1626
+ container.fadeIn(settings.window.effects.speed.show, attachIFrame);
1627
+ break;
1628
+ case 'slide':
1629
+ container.slideDown(settings.window.effects.speed.show, attachIFrame);
1630
+ break;
1631
+ case 'show':
1632
+ default:
1633
+ container.show(settings.window.effects.speed.show, attachIFrame);
1634
+ break;
1635
+ }
1636
+ },
1637
+ hide =
1638
+ function()
1639
+ {
1640
+ var removeIFrame = function()
1641
+ {
1642
+ if (settings.window.expandable) container.css({ zIndex: 10 });
1643
+ if (!settings.window.expandable || $.support.boxModel) return;
1644
+ container.prev().remove();
1645
+ };
1646
+ switch (settings.window.effects.type)
1647
+ {
1648
+ case 'fade':
1649
+ container.fadeOut(settings.window.effects.speed.hide, removeIFrame);
1650
+ break;
1651
+ case 'slide':
1652
+ container.slideUp(settings.window.effects.speed.hide, removeIFrame);
1653
+ break;
1654
+ case 'show':
1655
+ default:
1656
+ container.hide(settings.window.effects.speed.hide, removeIFrame);
1657
+ break;
1658
+ }
1659
+ },
1660
+ initialize =
1661
+ function()
1662
+ {
1663
+ var win = settings.window,
1664
+ popup = win.expandable ? $($this).next().find('.Container:first') : null;
1665
+ container = win.expandable ? $('<div/>') : $($this);
1666
+ container.addClass('jPicker Container');
1667
+ if (win.expandable) container.hide();
1668
+ container.get(0).onselectstart = function(event){ if (event.target.nodeName.toLowerCase() !== 'input') return false; };
1669
+ // 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
1670
+ // this control really is tabular data, so I believe it is the right move
1671
+ var all = color.active.val('all');
1672
+ if (win.alphaPrecision < 0) win.alphaPrecision = 0;
1673
+ else if (win.alphaPrecision > 2) win.alphaPrecision = 2;
1674
+ 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>';
1675
+ if (win.expandable)
1676
+ {
1677
+ container.html(controlHtml);
1678
+ if($(document.body).children('div.jPicker.Container').length==0)$(document.body).prepend(container);
1679
+ else $(document.body).children('div.jPicker.Container:last').after(container);
1680
+ container.mousedown(
1681
+ function()
1682
+ {
1683
+ $(document.body).children('div.jPicker.Container').css({zIndex:10});
1684
+ container.css({zIndex:20});
1685
+ });
1686
+ 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
1687
+ {
1688
+ left:
1689
+ win.position.x == 'left' ? (popup.offset().left - 530 - (win.position.y == 'center' ? 25 : 0)) + 'px' :
1690
+ win.position.x == 'center' ? (popup.offset().left - 260) + 'px' :
1691
+ win.position.x == 'right' ? (popup.offset().left - 10 + (win.position.y == 'center' ? 25 : 0)) + 'px' :
1692
+ win.position.x == 'screenCenter' ? (($(document).width() >> 1) - 260) + 'px' : (popup.offset().left + parseInt(win.position.x)) + 'px',
1693
+ position: 'absolute',
1694
+ top: win.position.y == 'top' ? (popup.offset().top - 312) + 'px' :
1695
+ win.position.y == 'center' ? (popup.offset().top - 156) + 'px' :
1696
+ win.position.y == 'bottom' ? (popup.offset().top + 25) + 'px' : (popup.offset().top + parseInt(win.position.y)) + 'px'
1697
+ });
1698
+ }
1699
+ else
1700
+ {
1701
+ container = $($this);
1702
+ container.html(controlHtml);
1703
+ }
1704
+ // initialize the objects to the source code just injected
1705
+ var tbody = container.find('tbody:first');
1706
+ colorMapDiv = tbody.find('div.Map:first');
1707
+ colorBarDiv = tbody.find('div.Bar:first');
1708
+ var MapMaps = colorMapDiv.find('span'),
1709
+ BarMaps = colorBarDiv.find('span');
1710
+ colorMapL1 = MapMaps.filter('.Map1:first');
1711
+ colorMapL2 = MapMaps.filter('.Map2:first');
1712
+ colorMapL3 = MapMaps.filter('.Map3:first');
1713
+ colorBarL1 = BarMaps.filter('.Map1:first');
1714
+ colorBarL2 = BarMaps.filter('.Map2:first');
1715
+ colorBarL3 = BarMaps.filter('.Map3:first');
1716
+ colorBarL4 = BarMaps.filter('.Map4:first');
1717
+ colorBarL5 = BarMaps.filter('.Map5:first');
1718
+ colorBarL6 = BarMaps.filter('.Map6:first');
1719
+ // create color pickers and maps
1720
+ colorMap = new Slider(colorMapDiv,
1721
+ {
1722
+ map:
1723
+ {
1724
+ width: images.colorMap.width,
1725
+ height: images.colorMap.height
1726
+ },
1727
+ arrow:
1728
+ {
1729
+ image: images.clientPath + images.colorMap.arrow.file,
1730
+ width: images.colorMap.arrow.width,
1731
+ height: images.colorMap.arrow.height
1732
+ }
1733
+ });
1734
+ colorMap.bind(mapValueChanged);
1735
+ colorBar = new Slider(colorBarDiv,
1736
+ {
1737
+ map:
1738
+ {
1739
+ width: images.colorBar.width,
1740
+ height: images.colorBar.height
1741
+ },
1742
+ arrow:
1743
+ {
1744
+ image: images.clientPath + images.colorBar.arrow.file,
1745
+ width: images.colorBar.arrow.width,
1746
+ height: images.colorBar.arrow.height
1747
+ }
1748
+ });
1749
+ colorBar.bind(colorBarValueChanged);
1750
+ colorPicker = new ColorValuePicker(tbody, color.active, win.expandable && win.bindToInput ? win.input : null, win.alphaPrecision);
1751
+ var hex = all != null ? all.hex : null,
1752
+ preview = tbody.find('.Preview'),
1753
+ button = tbody.find('.Button');
1754
+ activePreview = preview.find('.Active:first').css({ backgroundColor: hex && '#' + hex || 'transparent' });
1755
+ currentPreview = preview.find('.Current:first').css({ backgroundColor: hex && '#' + hex || 'transparent' }).bind('click', currentClicked);
1756
+ setAlpha.call($this, currentPreview, Math.precision(color.current.val('a') * 100) / 255, 4);
1757
+ okButton = button.find('.Ok:first').bind('click', okClicked);
1758
+ cancelButton = button.find('.Cancel:first').bind('click', cancelClicked);
1759
+ grid = button.find('.Grid:first');
1760
+ setTimeout(
1761
+ function()
1762
+ {
1763
+ setImg.call($this, colorMapL1, images.clientPath + 'Maps.png');
1764
+ setImg.call($this, colorMapL2, images.clientPath + 'Maps.png');
1765
+ setImg.call($this, colorMapL3, images.clientPath + 'map-opacity.png');
1766
+ setImg.call($this, colorBarL1, images.clientPath + 'Bars.png');
1767
+ setImg.call($this, colorBarL2, images.clientPath + 'Bars.png');
1768
+ setImg.call($this, colorBarL3, images.clientPath + 'Bars.png');
1769
+ setImg.call($this, colorBarL4, images.clientPath + 'Bars.png');
1770
+ setImg.call($this, colorBarL5, images.clientPath + 'bar-opacity.png');
1771
+ setImg.call($this, colorBarL6, images.clientPath + 'AlphaBar.png');
1772
+ setImg.call($this, preview.find('div:first'), images.clientPath + 'preview-opacity.png');
1773
+ }, 0);
1774
+ tbody.find('td.Radio input').bind('click', radioClicked);
1775
+ // initialize quick list
1776
+ if (color.quickList && color.quickList.length > 0)
1777
+ {
1778
+ var html = '';
1779
+ for (i = 0; i < color.quickList.length; i++)
1780
+ {
1781
+ /* if default colors are hex strings, change them to color objects */
1782
+ if ((typeof (color.quickList[i])).toString().toLowerCase() == 'string') color.quickList[i] = new Color({ hex: color.quickList[i] });
1783
+ var alpha = color.quickList[i].val('a');
1784
+ var ahex = color.quickList[i].val('ahex');
1785
+ if (!win.alphaSupport && ahex) ahex = ahex.substring(0, 6) + 'ff';
1786
+ var quickHex = color.quickList[i].val('hex');
1787
+ if(!ahex) ahex = "00000000";
1788
+ 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>';
1789
+ }
1790
+ setImg.call($this, grid, images.clientPath + 'bar-opacity.png');
1791
+ grid.html(html);
1792
+ grid.find('.QuickColor').click(quickPickClicked);
1793
+ }
1794
+ setColorMode.call($this, settings.color.mode);
1795
+ color.active.bind(activeColorChanged);
1796
+ $.isFunction(liveCallback) && color.active.bind(liveCallback);
1797
+ color.current.bind(currentColorChanged);
1798
+ // bind to input
1799
+ if (win.expandable)
1800
+ {
1801
+ $this.icon = popup.parents('.Icon:first');
1802
+ iconColor = $this.icon.find('.Color:first').css({ backgroundColor: hex && '#' + hex || 'transparent' });
1803
+ iconAlpha = $this.icon.find('.Alpha:first');
1804
+ setImg.call($this, iconAlpha, images.clientPath + 'bar-opacity.png');
1805
+ setAlpha.call($this, iconAlpha, Math.precision(((255 - (all != null ? all.a : 0)) * 100) / 255, 4));
1806
+ iconImage = $this.icon.find('.Image:first').css(
1807
+ {
1808
+ backgroundImage: 'url(\'' + images.clientPath + images.picker.file + '\')'
1809
+ }).bind('click', iconImageClicked);
1810
+ if (win.bindToInput&&win.updateInputColor)
1811
+ win.input.css(
1812
+ {
1813
+ backgroundColor: hex && '#' + hex || 'transparent',
1814
+ color: all == null || all.v > 75 ? '#000000' : '#ffffff'
1815
+ });
1816
+ moveBar = tbody.find('.Move:first').bind('mousedown', moveBarMouseDown);
1817
+ color.active.bind(expandableColorChanged);
1818
+ }
1819
+ else show.call($this);
1820
+ },
1821
+ destroy =
1822
+ function()
1823
+ {
1824
+ container.find('td.Radio input').unbind('click', radioClicked);
1825
+ currentPreview.unbind('click', currentClicked);
1826
+ cancelButton.unbind('click', cancelClicked);
1827
+ okButton.unbind('click', okClicked);
1828
+ if (settings.window.expandable)
1829
+ {
1830
+ iconImage.unbind('click', iconImageClicked);
1831
+ moveBar.unbind('mousedown', moveBarMouseDown);
1832
+ $this.icon = null;
1833
+ }
1834
+ container.find('.QuickColor').unbind('click', quickPickClicked);
1835
+ colorMapDiv = null;
1836
+ colorBarDiv = null;
1837
+ colorMapL1 = null;
1838
+ colorMapL2 = null;
1839
+ colorMapL3 = null;
1840
+ colorBarL1 = null;
1841
+ colorBarL2 = null;
1842
+ colorBarL3 = null;
1843
+ colorBarL4 = null;
1844
+ colorBarL5 = null;
1845
+ colorBarL6 = null;
1846
+ colorMap.destroy();
1847
+ colorMap = null;
1848
+ colorBar.destroy();
1849
+ colorBar = null;
1850
+ colorPicker.destroy();
1851
+ colorPicker = null;
1852
+ activePreview = null;
1853
+ currentPreview = null;
1854
+ okButton = null;
1855
+ cancelButton = null;
1856
+ grid = null;
1857
+ commitCallback = null;
1858
+ cancelCallback = null;
1859
+ liveCallback = null;
1860
+ container.html('');
1861
+ for (i = 0; i < List.length; i++) if (List[i] == $this) List.splice(i, 1);
1862
+ },
1863
+ images = settings.images, // local copies for YUI compressor
1864
+ localization = settings.localization,
1865
+ color =
1866
+ {
1867
+ 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') }),
1868
+ 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') }),
1869
+ quickList: settings.color.quickList
1870
+ };
1871
+ $.extend(true, $this, // public properties, methods, and callbacks
1872
+ {
1873
+ commitCallback: commitCallback, // commitCallback function can be overridden to return the selected color to a method you specify when the user clicks "OK"
1874
+ liveCallback: liveCallback, // liveCallback function can be overridden to return the selected color to a method you specify in live mode (continuous update)
1875
+ cancelCallback: cancelCallback, // cancelCallback function can be overridden to a method you specify when the user clicks "Cancel"
1876
+ color: color,
1877
+ show: show,
1878
+ hide: hide,
1879
+ destroy: destroy // destroys this control entirely, removing all events and objects, and removing itself from the List
1880
+ });
1881
+ List.push($this);
1882
+ setTimeout(
1883
+ function()
1884
+ {
1885
+ initialize.call($this);
1886
+ }, 0);
1887
+ });
1888
+ };
1889
+ $.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 */
1890
+ {
1891
+ window:
1892
+ {
1893
+ title: null, /* any title for the jPicker window itself - displays "Drag Markers To Pick A Color" if left null */
1894
+ effects:
1895
+ {
1896
+ type: 'slide', /* effect used to show/hide an expandable picker. Acceptable values "slide", "show", "fade" */
1897
+ speed:
1898
+ {
1899
+ show: 'slow', /* duration of "show" effect. Acceptable values are "fast", "slow", or time in ms */
1900
+ hide: 'fast' /* duration of "hide" effect. Acceptable values are "fast", "slow", or time in ms */
1901
+ }
1902
+ },
1903
+ position:
1904
+ {
1905
+ x: 'screenCenter', /* acceptable values "left", "center", "right", "screenCenter", or relative px value */
1906
+ y: 'top' /* acceptable values "top", "bottom", "center", or relative px value */
1907
+ },
1908
+ 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 */
1909
+ 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) */
1910
+ alphaSupport: false, /* set to true to enable alpha picking */
1911
+ alphaPrecision: 0, /* set decimal precision for alpha percentage display - hex codes do not map directly to percentage integers - range 0-2 */
1912
+ updateInputColor: true /* set to false to prevent binded input colors from changing */
1913
+ },
1914
+ color:
1915
+ {
1916
+ mode: 'h', /* acceptabled values "h" (hue), "s" (saturation), "v" (value), "r" (red), "g" (green), "b" (blue), "a" (alpha) */
1917
+ 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 */
1918
+ quickList: /* the quick pick color list */
1919
+ [
1920
+ 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 */
1921
+ new Color({ h: 360, s: 66, v: 100 }),
1922
+ new Color({ h: 360, s: 100, v: 100 }),
1923
+ new Color({ h: 360, s: 100, v: 75 }),
1924
+ new Color({ h: 360, s: 100, v: 50 }),
1925
+ new Color({ h: 180, s: 0, v: 100 }),
1926
+ new Color({ h: 30, s: 33, v: 100 }),
1927
+ new Color({ h: 30, s: 66, v: 100 }),
1928
+ new Color({ h: 30, s: 100, v: 100 }),
1929
+ new Color({ h: 30, s: 100, v: 75 }),
1930
+ new Color({ h: 30, s: 100, v: 50 }),
1931
+ new Color({ h: 180, s: 0, v: 90 }),
1932
+ new Color({ h: 60, s: 33, v: 100 }),
1933
+ new Color({ h: 60, s: 66, v: 100 }),
1934
+ new Color({ h: 60, s: 100, v: 100 }),
1935
+ new Color({ h: 60, s: 100, v: 75 }),
1936
+ new Color({ h: 60, s: 100, v: 50 }),
1937
+ new Color({ h: 180, s: 0, v: 80 }),
1938
+ new Color({ h: 90, s: 33, v: 100 }),
1939
+ new Color({ h: 90, s: 66, v: 100 }),
1940
+ new Color({ h: 90, s: 100, v: 100 }),
1941
+ new Color({ h: 90, s: 100, v: 75 }),
1942
+ new Color({ h: 90, s: 100, v: 50 }),
1943
+ new Color({ h: 180, s: 0, v: 70 }),
1944
+ new Color({ h: 120, s: 33, v: 100 }),
1945
+ new Color({ h: 120, s: 66, v: 100 }),
1946
+ new Color({ h: 120, s: 100, v: 100 }),
1947
+ new Color({ h: 120, s: 100, v: 75 }),
1948
+ new Color({ h: 120, s: 100, v: 50 }),
1949
+ new Color({ h: 180, s: 0, v: 60 }),
1950
+ new Color({ h: 150, s: 33, v: 100 }),
1951
+ new Color({ h: 150, s: 66, v: 100 }),
1952
+ new Color({ h: 150, s: 100, v: 100 }),
1953
+ new Color({ h: 150, s: 100, v: 75 }),
1954
+ new Color({ h: 150, s: 100, v: 50 }),
1955
+ new Color({ h: 180, s: 0, v: 50 }),
1956
+ new Color({ h: 180, s: 33, v: 100 }),
1957
+ new Color({ h: 180, s: 66, v: 100 }),
1958
+ new Color({ h: 180, s: 100, v: 100 }),
1959
+ new Color({ h: 180, s: 100, v: 75 }),
1960
+ new Color({ h: 180, s: 100, v: 50 }),
1961
+ new Color({ h: 180, s: 0, v: 40 }),
1962
+ new Color({ h: 210, s: 33, v: 100 }),
1963
+ new Color({ h: 210, s: 66, v: 100 }),
1964
+ new Color({ h: 210, s: 100, v: 100 }),
1965
+ new Color({ h: 210, s: 100, v: 75 }),
1966
+ new Color({ h: 210, s: 100, v: 50 }),
1967
+ new Color({ h: 180, s: 0, v: 30 }),
1968
+ new Color({ h: 240, s: 33, v: 100 }),
1969
+ new Color({ h: 240, s: 66, v: 100 }),
1970
+ new Color({ h: 240, s: 100, v: 100 }),
1971
+ new Color({ h: 240, s: 100, v: 75 }),
1972
+ new Color({ h: 240, s: 100, v: 50 }),
1973
+ new Color({ h: 180, s: 0, v: 20 }),
1974
+ new Color({ h: 270, s: 33, v: 100 }),
1975
+ new Color({ h: 270, s: 66, v: 100 }),
1976
+ new Color({ h: 270, s: 100, v: 100 }),
1977
+ new Color({ h: 270, s: 100, v: 75 }),
1978
+ new Color({ h: 270, s: 100, v: 50 }),
1979
+ new Color({ h: 180, s: 0, v: 10 }),
1980
+ new Color({ h: 300, s: 33, v: 100 }),
1981
+ new Color({ h: 300, s: 66, v: 100 }),
1982
+ new Color({ h: 300, s: 100, v: 100 }),
1983
+ new Color({ h: 300, s: 100, v: 75 }),
1984
+ new Color({ h: 300, s: 100, v: 50 }),
1985
+ new Color({ h: 180, s: 0, v: 0 }),
1986
+ new Color({ h: 330, s: 33, v: 100 }),
1987
+ new Color({ h: 330, s: 66, v: 100 }),
1988
+ new Color({ h: 330, s: 100, v: 100 }),
1989
+ new Color({ h: 330, s: 100, v: 75 }),
1990
+ new Color({ h: 330, s: 100, v: 50 }),
1991
+ new Color()
1992
+ ]
1993
+ },
1994
+ images:
1995
+ {
1996
+ clientPath: '/jPicker/images/', /* Path to image files */
1997
+ colorMap:
1998
+ {
1999
+ width: 256,
2000
+ height: 256,
2001
+ arrow:
2002
+ {
2003
+ file: 'mappoint.gif', /* ColorMap arrow icon */
2004
+ width: 15,
2005
+ height: 15
2006
+ }
2007
+ },
2008
+ colorBar:
2009
+ {
2010
+ width: 20,
2011
+ height: 256,
2012
+ arrow:
2013
+ {
2014
+ file: 'rangearrows.gif', /* ColorBar arrow icon */
2015
+ width: 20,
2016
+ height: 7
2017
+ }
2018
+ },
2019
+ picker:
2020
+ {
2021
+ file: 'picker.gif', /* Color Picker icon */
2022
+ width: 25,
2023
+ height: 24
2024
+ }
2025
+ },
2026
+ localization: /* alter these to change the text presented by the picker (e.g. different language) */
2027
+ {
2028
+ text:
2029
+ {
2030
+ title: 'Drag Markers To Pick A Color',
2031
+ newColor: 'new',
2032
+ currentColor: 'current',
2033
+ ok: 'OK',
2034
+ cancel: 'Cancel'
2035
+ },
2036
+ tooltips:
2037
+ {
2038
+ colors:
2039
+ {
2040
+ newColor: 'New Color - Press &ldquo;OK&rdquo; To Commit',
2041
+ currentColor: 'Click To Revert To Original Color'
2042
+ },
2043
+ buttons:
2044
+ {
2045
+ ok: 'Commit To This Color Selection',
2046
+ cancel: 'Cancel And Revert To Original Color'
2047
+ },
2048
+ hue:
2049
+ {
2050
+ radio: 'Set To &ldquo;Hue&rdquo; Color Mode',
2051
+ textbox: 'Enter A &ldquo;Hue&rdquo; Value (0-360&deg;)'
2052
+ },
2053
+ saturation:
2054
+ {
2055
+ radio: 'Set To &ldquo;Saturation&rdquo; Color Mode',
2056
+ textbox: 'Enter A &ldquo;Saturation&rdquo; Value (0-100%)'
2057
+ },
2058
+ value:
2059
+ {
2060
+ radio: 'Set To &ldquo;Value&rdquo; Color Mode',
2061
+ textbox: 'Enter A &ldquo;Value&rdquo; Value (0-100%)'
2062
+ },
2063
+ red:
2064
+ {
2065
+ radio: 'Set To &ldquo;Red&rdquo; Color Mode',
2066
+ textbox: 'Enter A &ldquo;Red&rdquo; Value (0-255)'
2067
+ },
2068
+ green:
2069
+ {
2070
+ radio: 'Set To &ldquo;Green&rdquo; Color Mode',
2071
+ textbox: 'Enter A &ldquo;Green&rdquo; Value (0-255)'
2072
+ },
2073
+ blue:
2074
+ {
2075
+ radio: 'Set To &ldquo;Blue&rdquo; Color Mode',
2076
+ textbox: 'Enter A &ldquo;Blue&rdquo; Value (0-255)'
2077
+ },
2078
+ alpha:
2079
+ {
2080
+ radio: 'Set To &ldquo;Alpha&rdquo; Color Mode',
2081
+ textbox: 'Enter A &ldquo;Alpha&rdquo; Value (0-100)'
2082
+ },
2083
+ hex:
2084
+ {
2085
+ textbox: 'Enter A &ldquo;Hex&rdquo; Color Value (#000000-#ffffff)',
2086
+ alpha: 'Enter A &ldquo;Alpha&rdquo; Value (#00-#ff)'
2087
+ }
2088
+ }
2089
+ }
2090
+ };
2091
+ })(jQuery, '1.1.6');