cytoplasm 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +38 -0
  4. data/app/assets/images/cytoplasm/triangle-medium-circle-1.png +0 -0
  5. data/app/assets/images/cytoplasm/triangle-medium-circle-2.png +0 -0
  6. data/app/assets/images/cytoplasm/triangle-medium-circle-3.png +0 -0
  7. data/app/assets/images/cytoplasm/triangle-medium-circle-4.png +0 -0
  8. data/app/assets/javascripts/cytoplasm/cytoAjax.js.erb +53 -0
  9. data/app/assets/javascripts/cytoplasm/cytoColorPicker.js.erb +204 -0
  10. data/app/assets/javascripts/cytoplasm/cytoRadio.js.erb +210 -0
  11. data/app/assets/javascripts/cytoplasm/cytoSelect.js.erb +414 -0
  12. data/app/assets/javascripts/cytoplasm/cytoSlider.js.erb +170 -0
  13. data/app/assets/javascripts/cytoplasm/cytoTable.js.erb +48 -0
  14. data/app/assets/javascripts/cytoplasm/cytoUpload.js.erb +200 -0
  15. data/app/assets/javascripts/cytoplasm/cytoplasm.js.erb +220 -0
  16. data/app/assets/javascripts/cytoplasm/jquery.ba-throttle-debounce.min.js +9 -0
  17. data/app/assets/javascripts/cytoplasm/jquery.color.js +663 -0
  18. data/app/assets/javascripts/cytoplasm/less-1.3.1.min.js +9 -0
  19. data/app/assets/stylesheets/cytoplasm/cytoplasm.less +113 -0
  20. data/app/controllers/cytoplasm/fonts_controller.rb +46 -0
  21. data/app/controllers/cytoplasm/settings_controller.rb +34 -0
  22. data/app/views/cytoplasm/settings/edit.html.erb +529 -0
  23. data/app/views/cytoplasm/settings/index.html.erb +18 -0
  24. data/config/routes.rb +6 -0
  25. data/lib/cytoplasm.rb +317 -0
  26. data/lib/cytoplasm/ajax.rb +34 -0
  27. data/lib/cytoplasm/railtie.rb +12 -0
  28. data/lib/cytoplasm/version.rb +3 -0
  29. data/lib/tasks/cytoplasm_tasks.rake +4 -0
  30. data/test/cytoplasm_test.rb +7 -0
  31. data/test/dummy/README.rdoc +261 -0
  32. data/test/dummy/Rakefile +7 -0
  33. data/test/dummy/app/assets/javascripts/about.js +2 -0
  34. data/test/dummy/app/assets/javascripts/application.js +15 -0
  35. data/test/dummy/app/assets/javascripts/demos.js +2 -0
  36. data/test/dummy/app/assets/javascripts/docs.js +2 -0
  37. data/test/dummy/app/assets/javascripts/downloads.js +2 -0
  38. data/test/dummy/app/assets/javascripts/home.js +2 -0
  39. data/test/dummy/app/assets/stylesheets/about.css +4 -0
  40. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  41. data/test/dummy/app/assets/stylesheets/demos.css +4 -0
  42. data/test/dummy/app/assets/stylesheets/docs.css +4 -0
  43. data/test/dummy/app/assets/stylesheets/downloads.css +4 -0
  44. data/test/dummy/app/assets/stylesheets/home.css +4 -0
  45. data/test/dummy/app/controllers/about_controller.rb +4 -0
  46. data/test/dummy/app/controllers/application_controller.rb +3 -0
  47. data/test/dummy/app/controllers/demos_controller.rb +4 -0
  48. data/test/dummy/app/controllers/docs_controller.rb +5 -0
  49. data/test/dummy/app/controllers/downloads_controller.rb +4 -0
  50. data/test/dummy/app/controllers/home_controller.rb +7 -0
  51. data/test/dummy/app/helpers/about_helper.rb +2 -0
  52. data/test/dummy/app/helpers/application_helper.rb +2 -0
  53. data/test/dummy/app/helpers/demos_helper.rb +2 -0
  54. data/test/dummy/app/helpers/docs_helper.rb +2 -0
  55. data/test/dummy/app/helpers/downloads_helper.rb +2 -0
  56. data/test/dummy/app/helpers/home_helper.rb +2 -0
  57. data/test/dummy/app/views/about/index.html.erb +2 -0
  58. data/test/dummy/app/views/demos/index.html.erb +15 -0
  59. data/test/dummy/app/views/docs/index.html.erb +15 -0
  60. data/test/dummy/app/views/downloads/index.html.erb +60 -0
  61. data/test/dummy/app/views/home/index.html.erb +74 -0
  62. data/test/dummy/app/views/layouts/application.html.erb +30 -0
  63. data/test/dummy/config.ru +4 -0
  64. data/test/dummy/config/application.rb +59 -0
  65. data/test/dummy/config/boot.rb +10 -0
  66. data/test/dummy/config/database.yml +25 -0
  67. data/test/dummy/config/environment.rb +5 -0
  68. data/test/dummy/config/environments/development.rb +37 -0
  69. data/test/dummy/config/environments/production.rb +67 -0
  70. data/test/dummy/config/environments/test.rb +37 -0
  71. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  72. data/test/dummy/config/initializers/cytoplasm.vars.yml +4 -0
  73. data/test/dummy/config/initializers/inflections.rb +15 -0
  74. data/test/dummy/config/initializers/mime_types.rb +5 -0
  75. data/test/dummy/config/initializers/secret_token.rb +7 -0
  76. data/test/dummy/config/initializers/session_store.rb +8 -0
  77. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  78. data/test/dummy/config/locales/en.yml +5 -0
  79. data/test/dummy/config/routes.rb +65 -0
  80. data/test/dummy/db/development.sqlite3 +0 -0
  81. data/test/dummy/db/test.sqlite3 +0 -0
  82. data/test/dummy/log/development.log +178434 -0
  83. data/test/dummy/log/production.log +4 -0
  84. data/test/dummy/log/test.log +43 -0
  85. data/test/dummy/public/404.html +26 -0
  86. data/test/dummy/public/422.html +26 -0
  87. data/test/dummy/public/500.html +25 -0
  88. data/test/dummy/public/cytoplasm/cytoplasm.vars.less +36 -0
  89. data/test/dummy/public/favicon.ico +0 -0
  90. data/test/dummy/script/rails +6 -0
  91. data/test/dummy/test/functional/about_controller_test.rb +9 -0
  92. data/test/dummy/test/functional/demos_controller_test.rb +9 -0
  93. data/test/dummy/test/functional/docs_controller_test.rb +7 -0
  94. data/test/dummy/test/functional/downloads_controller_test.rb +9 -0
  95. data/test/dummy/test/functional/home_controller_test.rb +9 -0
  96. data/test/dummy/test/unit/helpers/about_helper_test.rb +4 -0
  97. data/test/dummy/test/unit/helpers/demos_helper_test.rb +4 -0
  98. data/test/dummy/test/unit/helpers/docs_helper_test.rb +4 -0
  99. data/test/dummy/test/unit/helpers/downloads_helper_test.rb +4 -0
  100. data/test/dummy/test/unit/helpers/home_helper_test.rb +4 -0
  101. data/test/dummy/tmp/cache/assets/C23/A50/sprockets%2F1011830ce123d00a75be4330f2721412 +0 -0
  102. data/test/dummy/tmp/cache/assets/C2E/4E0/sprockets%2F5b29288e435665a224409e7d76530c95 +0 -0
  103. data/test/dummy/tmp/cache/assets/C75/590/sprockets%2Fc3abe8a0059292e1e3818278c0434027 +0 -0
  104. data/test/dummy/tmp/cache/assets/C77/C20/sprockets%2F165a39476f3fa731c0af49432141049c +0 -0
  105. data/test/dummy/tmp/cache/assets/C87/580/sprockets%2Fd904f7e82971fdde744127c702222195 +0 -0
  106. data/test/dummy/tmp/cache/assets/C8F/0F0/sprockets%2F369f11075c8c5f939359cb5cb0569281 +0 -0
  107. data/test/dummy/tmp/cache/assets/CA0/B40/sprockets%2F26961c657dc345435242accb433d260a +0 -0
  108. data/test/dummy/tmp/cache/assets/CA3/4B0/sprockets%2Fb78b7754bf248ba091802070be5c1630 +0 -0
  109. data/test/dummy/tmp/cache/assets/CA7/8F0/sprockets%2F901b96894219d63a767e8898f73d4ce7 +0 -0
  110. data/test/dummy/tmp/cache/assets/CAC/280/sprockets%2F408a235a236b0a3aa1302733211db5ba +0 -0
  111. data/test/dummy/tmp/cache/assets/CAE/FD0/sprockets%2F3bb22e4d409072c2278c1771893ec19e +0 -0
  112. data/test/dummy/tmp/cache/assets/CB2/AD0/sprockets%2F0c26131d87e0691ba9904e46ff5820b9 +0 -0
  113. data/test/dummy/tmp/cache/assets/CB8/330/sprockets%2F8d9120752c9f38f7a5e164395e5d0c04 +0 -0
  114. data/test/dummy/tmp/cache/assets/CBA/320/sprockets%2Fa34641007e856c6bd67567e2ac8668c4 +0 -0
  115. data/test/dummy/tmp/cache/assets/CCE/F60/sprockets%2F37d1a6c1a8d398c4404b1b00076912fd +0 -0
  116. data/test/dummy/tmp/cache/assets/CD7/990/sprockets%2F55411442048c5a69b45be06da29ee62c +0 -0
  117. data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  118. data/test/dummy/tmp/cache/assets/CD8/900/sprockets%2Fc68606f026190266d8099ada290bbaa4 +0 -0
  119. data/test/dummy/tmp/cache/assets/CDF/870/sprockets%2Fb878faf942403e313a5b103e5d80488e +0 -0
  120. data/test/dummy/tmp/cache/assets/CE1/E60/sprockets%2F08ae5c39217fa93841884cfcb0037c46 +0 -0
  121. data/test/dummy/tmp/cache/assets/CE2/AE0/sprockets%2F79562f7c45761a5d0dba9361d11ae594 +0 -0
  122. data/test/dummy/tmp/cache/assets/CE3/080/sprockets%2F7d4d7689d6fa8236f0b4848c03ba1215 +0 -0
  123. data/test/dummy/tmp/cache/assets/CE4/530/sprockets%2F70521f5a32e550f6da0d76e896c7183e +0 -0
  124. data/test/dummy/tmp/cache/assets/CE5/D30/sprockets%2F8c9834a63b25a66203918a75ff56e2ac +0 -0
  125. data/test/dummy/tmp/cache/assets/CEE/7F0/sprockets%2F8b32778387c589166e26a7e5a6aa4cc3 +0 -0
  126. data/test/dummy/tmp/cache/assets/CF3/120/sprockets%2Fe2b304b015ce82a222d634e7e544b0b3 +0 -0
  127. data/test/dummy/tmp/cache/assets/CF7/ED0/sprockets%2F8061089f9dc8af8cc6353949d9b9d212 +0 -0
  128. data/test/dummy/tmp/cache/assets/CF9/7C0/sprockets%2F40fc2f3d2a468a00e463f1d313cb1683 +0 -0
  129. data/test/dummy/tmp/cache/assets/D03/6B0/sprockets%2Fd3cfc780201b87a3439e35c5236bb71a +0 -0
  130. data/test/dummy/tmp/cache/assets/D05/D40/sprockets%2F1c9faaf28d05409b88ad3113374d613c +0 -0
  131. data/test/dummy/tmp/cache/assets/D06/7A0/sprockets%2Fa46b76e739460d2691f4121ffa8a0ca0 +0 -0
  132. data/test/dummy/tmp/cache/assets/D0D/A10/sprockets%2F5c22f257a7abbc8e5720b17433657f6d +0 -0
  133. data/test/dummy/tmp/cache/assets/D0E/4A0/sprockets%2F6b27287928ba630c1b25dfa80ee18b48 +0 -0
  134. data/test/dummy/tmp/cache/assets/D0E/7D0/sprockets%2F89200785fe2710582a6c1b8d04ae7fbe +0 -0
  135. data/test/dummy/tmp/cache/assets/D12/010/sprockets%2F8067431ced3f34f1c97d34c3b4fb7049 +0 -0
  136. data/test/dummy/tmp/cache/assets/D12/1E0/sprockets%2Fba248329196c372b79d1f4c4f2a771bf +0 -0
  137. data/test/dummy/tmp/cache/assets/D14/170/sprockets%2F40a7b83bb067eea7ce2c8394e1529287 +0 -0
  138. data/test/dummy/tmp/cache/assets/D15/8E0/sprockets%2F4752afcb2967724e7e47b58b200d8ed2 +0 -0
  139. data/test/dummy/tmp/cache/assets/D15/CE0/sprockets%2Fa1310379a19df3c1796f2f67dcd5915d +0 -0
  140. data/test/dummy/tmp/cache/assets/D21/A50/sprockets%2Feb094bfe70c49891ce65c0178d88d904 +0 -0
  141. data/test/dummy/tmp/cache/assets/D2D/E60/sprockets%2F34ec37e4221a9a127bf1de1ee52951b0 +0 -0
  142. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  143. data/test/dummy/tmp/cache/assets/D47/930/sprockets%2F1a738430fd705a9dddde85a18dd29782 +0 -0
  144. data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  145. data/test/dummy/tmp/cache/assets/D50/750/sprockets%2F7fbcc321810c8f493f86364fee480ed9 +0 -0
  146. data/test/dummy/tmp/cache/assets/D52/430/sprockets%2F6ada07f0c9869f9f35b05fa0988dc717 +0 -0
  147. data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  148. data/test/dummy/tmp/cache/assets/D60/2A0/sprockets%2Ff1857b8a367fbae328221040cfcb2f1c +0 -0
  149. data/test/dummy/tmp/cache/assets/D65/180/sprockets%2F346621e7334bd914afc87bc6a9d1bc0a +0 -0
  150. data/test/dummy/tmp/cache/assets/D65/F10/sprockets%2F0a60d2fd5c544ea66af4d382b5e3d147 +0 -0
  151. data/test/dummy/tmp/cache/assets/D68/A20/sprockets%2F8b8272d3eaf9323f1c34114cbcbf56f3 +0 -0
  152. data/test/dummy/tmp/cache/assets/D69/0A0/sprockets%2Fe6c078d521b528e004f5dd673ddb2a6d +0 -0
  153. data/test/dummy/tmp/cache/assets/D69/0B0/sprockets%2Fb9e3ae8763ce66c2090d9413bdd400fa +0 -0
  154. data/test/dummy/tmp/cache/assets/D6E/3E0/sprockets%2F1be4cbdc9c19703c546405f087aee92d +0 -0
  155. data/test/dummy/tmp/cache/assets/D73/5F0/sprockets%2F6aee922214ffea56b31595f1a5ed8c92 +0 -0
  156. data/test/dummy/tmp/cache/assets/D78/840/sprockets%2F326ec6387a9d1b45ec2cdf7093b79f0e +0 -0
  157. data/test/dummy/tmp/cache/assets/D83/C70/sprockets%2Ff536f7a68e692747fca1d2fcd5c07f57 +0 -0
  158. data/test/dummy/tmp/cache/assets/D87/C40/sprockets%2F9dcd7a6999affe28e91e514cee079016 +0 -0
  159. data/test/dummy/tmp/cache/assets/D88/700/sprockets%2Fe13c6f31271a8ac23e63ef0a118ebe2b +0 -0
  160. data/test/dummy/tmp/cache/assets/D98/8B0/sprockets%2Fedbef6e0d0a4742346cf479f2c522eb0 +0 -0
  161. data/test/dummy/tmp/cache/assets/DA4/140/sprockets%2F24502b9d4e4eea6f709e089c0fdff30f +0 -0
  162. data/test/dummy/tmp/cache/assets/DBE/210/sprockets%2Fbedb89fd02eac0dc7aa93c820c612343 +0 -0
  163. data/test/dummy/tmp/cache/assets/DBE/950/sprockets%2F46cc27391a6badaac462d9b3aa43ec73 +0 -0
  164. data/test/dummy/tmp/cache/assets/DC7/E10/sprockets%2Fac6d2602a61a59c16ad89cbf2d2d48de +0 -0
  165. data/test/dummy/tmp/cache/assets/DC8/E80/sprockets%2F117e87cbd2939c4a9afcbbca2a3684d0 +0 -0
  166. data/test/dummy/tmp/cache/assets/DCD/AD0/sprockets%2Ffb914fa2e51ab43f0f857f0fddd8713b +0 -0
  167. data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  168. data/test/dummy/tmp/cache/assets/DEB/B50/sprockets%2Fdcfb6dd7dae66f42a5a10e80a33d1b24 +0 -0
  169. data/test/dummy/tmp/cache/assets/DEC/A90/sprockets%2F3f26f0f2e3ea4a0e194b22be6c3b5cce +0 -0
  170. data/test/dummy/tmp/cache/assets/E00/880/sprockets%2Fecb876bb310c1a3e6fd534ece45c9ed9 +0 -0
  171. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  172. data/test/dummy/tmp/cache/assets/E05/E70/sprockets%2Fead5bfd3417fc5de81d3794c3e443cfe +0 -0
  173. data/test/dummy/tmp/cache/assets/E1A/970/sprockets%2Ff89b4657cfc95e2d28f6fad44c58edfb +0 -0
  174. data/test/dummy/tmp/cache/assets/E2E/720/sprockets%2Ff76ac8420ca62debb77ecbfe7d0c6d45 +0 -0
  175. data/test/dummy/tmp/cache/assets/E38/2A0/sprockets%2Fc6e8ba43cbed7d3981f70bcfeb3a69c9 +0 -0
  176. data/test/dummy/tmp/cache/assets/E69/B60/sprockets%2Ffdbf7ec615e9a92e4857cdade17f4daa +0 -0
  177. data/test/dummy/tmp/cache/assets/E71/0E0/sprockets%2Fcbbecea061be6e609adc04133b9badab +0 -0
  178. data/test/dummy/tmp/cache/assets/E8C/480/sprockets%2Fdacb331ac961cf7b7cbc69abe8fb74dd +0 -0
  179. data/test/dummy/tmp/cache/assets/E8D/B40/sprockets%2Fb862bf7fb4b4c634aeaa9dfc97babc6b +0 -0
  180. data/test/test_helper.rb +15 -0
  181. metadata +420 -0
@@ -0,0 +1,9 @@
1
+ /*
2
+ * jQuery throttle / debounce - v1.1 - 3/7/2010
3
+ * http://benalman.com/projects/jquery-throttle-debounce-plugin/
4
+ *
5
+ * Copyright (c) 2010 "Cowboy" Ben Alman
6
+ * Dual licensed under the MIT and GPL licenses.
7
+ * http://benalman.com/about/license/
8
+ */
9
+ (function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this);
@@ -0,0 +1,663 @@
1
+ /*!
2
+ * jQuery Color Animations v@VERSION
3
+ * https://github.com/jquery/jquery-color
4
+ *
5
+ * Copyright 2012 jQuery Foundation and other contributors
6
+ * Released under the MIT license.
7
+ * http://jquery.org/license
8
+ *
9
+ * Date: @DATE
10
+ */
11
+ (function( jQuery, undefined ) {
12
+
13
+ var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
14
+
15
+ // plusequals test for += 100 -= 100
16
+ rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
17
+ // a set of RE's that can match strings and generate color tuples.
18
+ stringParsers = [{
19
+ re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
20
+ parse: function( execResult ) {
21
+ return [
22
+ execResult[ 1 ],
23
+ execResult[ 2 ],
24
+ execResult[ 3 ],
25
+ execResult[ 4 ]
26
+ ];
27
+ }
28
+ }, {
29
+ re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
30
+ parse: function( execResult ) {
31
+ return [
32
+ execResult[ 1 ] * 2.55,
33
+ execResult[ 2 ] * 2.55,
34
+ execResult[ 3 ] * 2.55,
35
+ execResult[ 4 ]
36
+ ];
37
+ }
38
+ }, {
39
+ // this regex ignores A-F because it's compared against an already lowercased string
40
+ re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
41
+ parse: function( execResult ) {
42
+ return [
43
+ parseInt( execResult[ 1 ], 16 ),
44
+ parseInt( execResult[ 2 ], 16 ),
45
+ parseInt( execResult[ 3 ], 16 )
46
+ ];
47
+ }
48
+ }, {
49
+ // this regex ignores A-F because it's compared against an already lowercased string
50
+ re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
51
+ parse: function( execResult ) {
52
+ return [
53
+ parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
54
+ parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
55
+ parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
56
+ ];
57
+ }
58
+ }, {
59
+ re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
60
+ space: "hsla",
61
+ parse: function( execResult ) {
62
+ return [
63
+ execResult[ 1 ],
64
+ execResult[ 2 ] / 100,
65
+ execResult[ 3 ] / 100,
66
+ execResult[ 4 ]
67
+ ];
68
+ }
69
+ }],
70
+
71
+ // jQuery.Color( )
72
+ color = jQuery.Color = function( color, green, blue, alpha ) {
73
+ return new jQuery.Color.fn.parse( color, green, blue, alpha );
74
+ },
75
+ spaces = {
76
+ rgba: {
77
+ props: {
78
+ red: {
79
+ idx: 0,
80
+ type: "byte"
81
+ },
82
+ green: {
83
+ idx: 1,
84
+ type: "byte"
85
+ },
86
+ blue: {
87
+ idx: 2,
88
+ type: "byte"
89
+ }
90
+ }
91
+ },
92
+
93
+ hsla: {
94
+ props: {
95
+ hue: {
96
+ idx: 0,
97
+ type: "degrees"
98
+ },
99
+ saturation: {
100
+ idx: 1,
101
+ type: "percent"
102
+ },
103
+ lightness: {
104
+ idx: 2,
105
+ type: "percent"
106
+ }
107
+ }
108
+ }
109
+ },
110
+ propTypes = {
111
+ "byte": {
112
+ floor: true,
113
+ max: 255
114
+ },
115
+ "percent": {
116
+ max: 1
117
+ },
118
+ "degrees": {
119
+ mod: 360,
120
+ floor: true
121
+ }
122
+ },
123
+ support = color.support = {},
124
+
125
+ // element for support tests
126
+ supportElem = jQuery( "<p>" )[ 0 ],
127
+
128
+ // colors = jQuery.Color.names
129
+ colors,
130
+
131
+ // local aliases of functions called often
132
+ each = jQuery.each;
133
+
134
+ // determine rgba support immediately
135
+ supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
136
+ support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
137
+
138
+ // define cache name and alpha properties
139
+ // for rgba and hsla spaces
140
+ each( spaces, function( spaceName, space ) {
141
+ space.cache = "_" + spaceName;
142
+ space.props.alpha = {
143
+ idx: 3,
144
+ type: "percent",
145
+ def: 1
146
+ };
147
+ });
148
+
149
+ function clamp( value, prop, allowEmpty ) {
150
+ var type = propTypes[ prop.type ] || {};
151
+
152
+ if ( value == null ) {
153
+ return (allowEmpty || !prop.def) ? null : prop.def;
154
+ }
155
+
156
+ // ~~ is an short way of doing floor for positive numbers
157
+ value = type.floor ? ~~value : parseFloat( value );
158
+
159
+ // IE will pass in empty strings as value for alpha,
160
+ // which will hit this case
161
+ if ( isNaN( value ) ) {
162
+ return prop.def;
163
+ }
164
+
165
+ if ( type.mod ) {
166
+ // we add mod before modding to make sure that negatives values
167
+ // get converted properly: -10 -> 350
168
+ return (value + type.mod) % type.mod;
169
+ }
170
+
171
+ // for now all property types without mod have min and max
172
+ return 0 > value ? 0 : type.max < value ? type.max : value;
173
+ }
174
+
175
+ function stringParse( string ) {
176
+ var inst = color(),
177
+ rgba = inst._rgba = [];
178
+
179
+ string = string.toLowerCase();
180
+
181
+ each( stringParsers, function( i, parser ) {
182
+ var parsed,
183
+ match = parser.re.exec( string ),
184
+ values = match && parser.parse( match ),
185
+ spaceName = parser.space || "rgba";
186
+
187
+ if ( values ) {
188
+ parsed = inst[ spaceName ]( values );
189
+
190
+ // if this was an rgba parse the assignment might happen twice
191
+ // oh well....
192
+ inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
193
+ rgba = inst._rgba = parsed._rgba;
194
+
195
+ // exit each( stringParsers ) here because we matched
196
+ return false;
197
+ }
198
+ });
199
+
200
+ // Found a stringParser that handled it
201
+ if ( rgba.length ) {
202
+
203
+ // if this came from a parsed string, force "transparent" when alpha is 0
204
+ // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
205
+ if ( rgba.join() === "0,0,0,0" ) {
206
+ jQuery.extend( rgba, colors.transparent );
207
+ }
208
+ return inst;
209
+ }
210
+
211
+ // named colors
212
+ return colors[ string ];
213
+ }
214
+
215
+ color.fn = jQuery.extend( color.prototype, {
216
+ parse: function( red, green, blue, alpha ) {
217
+ if ( red === undefined ) {
218
+ this._rgba = [ null, null, null, null ];
219
+ return this;
220
+ }
221
+ if ( red.jquery || red.nodeType ) {
222
+ red = jQuery( red ).css( green );
223
+ green = undefined;
224
+ }
225
+
226
+ var inst = this,
227
+ type = jQuery.type( red ),
228
+ rgba = this._rgba = [];
229
+
230
+ // more than 1 argument specified - assume ( red, green, blue, alpha )
231
+ if ( green !== undefined ) {
232
+ red = [ red, green, blue, alpha ];
233
+ type = "array";
234
+ }
235
+
236
+ if ( type === "string" ) {
237
+ return this.parse( stringParse( red ) || colors._default );
238
+ }
239
+
240
+ if ( type === "array" ) {
241
+ each( spaces.rgba.props, function( key, prop ) {
242
+ rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
243
+ });
244
+ return this;
245
+ }
246
+
247
+ if ( type === "object" ) {
248
+ if ( red instanceof color ) {
249
+ each( spaces, function( spaceName, space ) {
250
+ if ( red[ space.cache ] ) {
251
+ inst[ space.cache ] = red[ space.cache ].slice();
252
+ }
253
+ });
254
+ } else {
255
+ each( spaces, function( spaceName, space ) {
256
+ var cache = space.cache;
257
+ each( space.props, function( key, prop ) {
258
+
259
+ // if the cache doesn't exist, and we know how to convert
260
+ if ( !inst[ cache ] && space.to ) {
261
+
262
+ // if the value was null, we don't need to copy it
263
+ // if the key was alpha, we don't need to copy it either
264
+ if ( key === "alpha" || red[ key ] == null ) {
265
+ return;
266
+ }
267
+ inst[ cache ] = space.to( inst._rgba );
268
+ }
269
+
270
+ // this is the only case where we allow nulls for ALL properties.
271
+ // call clamp with alwaysAllowEmpty
272
+ inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
273
+ });
274
+
275
+ // everything defined but alpha?
276
+ if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
277
+ // use the default of 1
278
+ inst[ cache ][ 3 ] = 1;
279
+ if ( space.from ) {
280
+ inst._rgba = space.from( inst[ cache ] );
281
+ }
282
+ }
283
+ });
284
+ }
285
+ return this;
286
+ }
287
+ },
288
+ is: function( compare ) {
289
+ var is = color( compare ),
290
+ same = true,
291
+ inst = this;
292
+
293
+ each( spaces, function( _, space ) {
294
+ var localCache,
295
+ isCache = is[ space.cache ];
296
+ if (isCache) {
297
+ localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
298
+ each( space.props, function( _, prop ) {
299
+ if ( isCache[ prop.idx ] != null ) {
300
+ same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
301
+ return same;
302
+ }
303
+ });
304
+ }
305
+ return same;
306
+ });
307
+ return same;
308
+ },
309
+ _space: function() {
310
+ var used = [],
311
+ inst = this;
312
+ each( spaces, function( spaceName, space ) {
313
+ if ( inst[ space.cache ] ) {
314
+ used.push( spaceName );
315
+ }
316
+ });
317
+ return used.pop();
318
+ },
319
+ transition: function( other, distance ) {
320
+ var end = color( other ),
321
+ spaceName = end._space(),
322
+ space = spaces[ spaceName ],
323
+ startColor = this.alpha() === 0 ? color( "transparent" ) : this,
324
+ start = startColor[ space.cache ] || space.to( startColor._rgba ),
325
+ result = start.slice();
326
+
327
+ end = end[ space.cache ];
328
+ each( space.props, function( key, prop ) {
329
+ var index = prop.idx,
330
+ startValue = start[ index ],
331
+ endValue = end[ index ],
332
+ type = propTypes[ prop.type ] || {};
333
+
334
+ // if null, don't override start value
335
+ if ( endValue === null ) {
336
+ return;
337
+ }
338
+ // if null - use end
339
+ if ( startValue === null ) {
340
+ result[ index ] = endValue;
341
+ } else {
342
+ if ( type.mod ) {
343
+ if ( endValue - startValue > type.mod / 2 ) {
344
+ startValue += type.mod;
345
+ } else if ( startValue - endValue > type.mod / 2 ) {
346
+ startValue -= type.mod;
347
+ }
348
+ }
349
+ result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
350
+ }
351
+ });
352
+ return this[ spaceName ]( result );
353
+ },
354
+ blend: function( opaque ) {
355
+ // if we are already opaque - return ourself
356
+ if ( this._rgba[ 3 ] === 1 ) {
357
+ return this;
358
+ }
359
+
360
+ var rgb = this._rgba.slice(),
361
+ a = rgb.pop(),
362
+ blend = color( opaque )._rgba;
363
+
364
+ return color( jQuery.map( rgb, function( v, i ) {
365
+ return ( 1 - a ) * blend[ i ] + a * v;
366
+ }));
367
+ },
368
+ toRgbaString: function() {
369
+ var prefix = "rgba(",
370
+ rgba = jQuery.map( this._rgba, function( v, i ) {
371
+ return v == null ? ( i > 2 ? 1 : 0 ) : v;
372
+ });
373
+
374
+ if ( rgba[ 3 ] === 1 ) {
375
+ rgba.pop();
376
+ prefix = "rgb(";
377
+ }
378
+
379
+ return prefix + rgba.join() + ")";
380
+ },
381
+ toHslaString: function() {
382
+ var prefix = "hsla(",
383
+ hsla = jQuery.map( this.hsla(), function( v, i ) {
384
+ if ( v == null ) {
385
+ v = i > 2 ? 1 : 0;
386
+ }
387
+
388
+ // catch 1 and 2
389
+ if ( i && i < 3 ) {
390
+ v = Math.round( v * 100 ) + "%";
391
+ }
392
+ return v;
393
+ });
394
+
395
+ if ( hsla[ 3 ] === 1 ) {
396
+ hsla.pop();
397
+ prefix = "hsl(";
398
+ }
399
+ return prefix + hsla.join() + ")";
400
+ },
401
+ toHexString: function( includeAlpha ) {
402
+ var rgba = this._rgba.slice(),
403
+ alpha = rgba.pop();
404
+
405
+ if ( includeAlpha ) {
406
+ rgba.push( ~~( alpha * 255 ) );
407
+ }
408
+
409
+ return "#" + jQuery.map( rgba, function( v ) {
410
+
411
+ // default to 0 when nulls exist
412
+ v = ( v || 0 ).toString( 16 );
413
+ return v.length === 1 ? "0" + v : v;
414
+ }).join("");
415
+ },
416
+ toString: function() {
417
+ return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
418
+ }
419
+ });
420
+ color.fn.parse.prototype = color.fn;
421
+
422
+ // hsla conversions adapted from:
423
+ // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
424
+
425
+ function hue2rgb( p, q, h ) {
426
+ h = ( h + 1 ) % 1;
427
+ if ( h * 6 < 1 ) {
428
+ return p + (q - p) * h * 6;
429
+ }
430
+ if ( h * 2 < 1) {
431
+ return q;
432
+ }
433
+ if ( h * 3 < 2 ) {
434
+ return p + (q - p) * ((2/3) - h) * 6;
435
+ }
436
+ return p;
437
+ }
438
+
439
+ spaces.hsla.to = function ( rgba ) {
440
+ if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
441
+ return [ null, null, null, rgba[ 3 ] ];
442
+ }
443
+ var r = rgba[ 0 ] / 255,
444
+ g = rgba[ 1 ] / 255,
445
+ b = rgba[ 2 ] / 255,
446
+ a = rgba[ 3 ],
447
+ max = Math.max( r, g, b ),
448
+ min = Math.min( r, g, b ),
449
+ diff = max - min,
450
+ add = max + min,
451
+ l = add * 0.5,
452
+ h, s;
453
+
454
+ if ( min === max ) {
455
+ h = 0;
456
+ } else if ( r === max ) {
457
+ h = ( 60 * ( g - b ) / diff ) + 360;
458
+ } else if ( g === max ) {
459
+ h = ( 60 * ( b - r ) / diff ) + 120;
460
+ } else {
461
+ h = ( 60 * ( r - g ) / diff ) + 240;
462
+ }
463
+
464
+ // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
465
+ // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
466
+ if ( diff === 0 ) {
467
+ s = 0;
468
+ } else if ( l <= 0.5 ) {
469
+ s = diff / add;
470
+ } else {
471
+ s = diff / ( 2 - add );
472
+ }
473
+ return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
474
+ };
475
+
476
+ spaces.hsla.from = function ( hsla ) {
477
+ if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
478
+ return [ null, null, null, hsla[ 3 ] ];
479
+ }
480
+ var h = hsla[ 0 ] / 360,
481
+ s = hsla[ 1 ],
482
+ l = hsla[ 2 ],
483
+ a = hsla[ 3 ],
484
+ q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
485
+ p = 2 * l - q;
486
+
487
+ return [
488
+ Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
489
+ Math.round( hue2rgb( p, q, h ) * 255 ),
490
+ Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
491
+ a
492
+ ];
493
+ };
494
+
495
+
496
+ each( spaces, function( spaceName, space ) {
497
+ var props = space.props,
498
+ cache = space.cache,
499
+ to = space.to,
500
+ from = space.from;
501
+
502
+ // makes rgba() and hsla()
503
+ color.fn[ spaceName ] = function( value ) {
504
+
505
+ // generate a cache for this space if it doesn't exist
506
+ if ( to && !this[ cache ] ) {
507
+ this[ cache ] = to( this._rgba );
508
+ }
509
+ if ( value === undefined ) {
510
+ return this[ cache ].slice();
511
+ }
512
+
513
+ var ret,
514
+ type = jQuery.type( value ),
515
+ arr = ( type === "array" || type === "object" ) ? value : arguments,
516
+ local = this[ cache ].slice();
517
+
518
+ each( props, function( key, prop ) {
519
+ var val = arr[ type === "object" ? key : prop.idx ];
520
+ if ( val == null ) {
521
+ val = local[ prop.idx ];
522
+ }
523
+ local[ prop.idx ] = clamp( val, prop );
524
+ });
525
+
526
+ if ( from ) {
527
+ ret = color( from( local ) );
528
+ ret[ cache ] = local;
529
+ return ret;
530
+ } else {
531
+ return color( local );
532
+ }
533
+ };
534
+
535
+ // makes red() green() blue() alpha() hue() saturation() lightness()
536
+ each( props, function( key, prop ) {
537
+ // alpha is included in more than one space
538
+ if ( color.fn[ key ] ) {
539
+ return;
540
+ }
541
+ color.fn[ key ] = function( value ) {
542
+ var vtype = jQuery.type( value ),
543
+ fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
544
+ local = this[ fn ](),
545
+ cur = local[ prop.idx ],
546
+ match;
547
+
548
+ if ( vtype === "undefined" ) {
549
+ return cur;
550
+ }
551
+
552
+ if ( vtype === "function" ) {
553
+ value = value.call( this, cur );
554
+ vtype = jQuery.type( value );
555
+ }
556
+ if ( value == null && prop.empty ) {
557
+ return this;
558
+ }
559
+ if ( vtype === "string" ) {
560
+ match = rplusequals.exec( value );
561
+ if ( match ) {
562
+ value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
563
+ }
564
+ }
565
+ local[ prop.idx ] = value;
566
+ return this[ fn ]( local );
567
+ };
568
+ });
569
+ });
570
+
571
+ // add cssHook and .fx.step function for each named hook.
572
+ // accept a space separated string of properties
573
+ color.hook = function( hook ) {
574
+ var hooks = hook.split( " " );
575
+ each( hooks, function( i, hook ) {
576
+ jQuery.cssHooks[ hook ] = {
577
+ set: function( elem, value ) {
578
+ var parsed, curElem,
579
+ backgroundColor = "";
580
+
581
+ if ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) {
582
+ value = color( parsed || value );
583
+ if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
584
+ curElem = hook === "backgroundColor" ? elem.parentNode : elem;
585
+ while (
586
+ (backgroundColor === "" || backgroundColor === "transparent") &&
587
+ curElem && curElem.style
588
+ ) {
589
+ try {
590
+ backgroundColor = jQuery.css( curElem, "backgroundColor" );
591
+ curElem = curElem.parentNode;
592
+ } catch ( e ) {
593
+ }
594
+ }
595
+
596
+ value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
597
+ backgroundColor :
598
+ "_default" );
599
+ }
600
+
601
+ value = value.toRgbaString();
602
+ }
603
+ try {
604
+ elem.style[ hook ] = value;
605
+ } catch( e ) {
606
+ // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
607
+ }
608
+ }
609
+ };
610
+ jQuery.fx.step[ hook ] = function( fx ) {
611
+ if ( !fx.colorInit ) {
612
+ fx.start = color( fx.elem, hook );
613
+ fx.end = color( fx.end );
614
+ fx.colorInit = true;
615
+ }
616
+ jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
617
+ };
618
+ });
619
+
620
+ };
621
+
622
+ color.hook( stepHooks );
623
+
624
+ jQuery.cssHooks.borderColor = {
625
+ expand: function( value ) {
626
+ var expanded = {};
627
+
628
+ each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
629
+ expanded[ "border" + part + "Color" ] = value;
630
+ });
631
+ return expanded;
632
+ }
633
+ };
634
+
635
+ // Basic color names only.
636
+ // Usage of any of the other color names requires adding yourself or including
637
+ // jquery.color.svg-names.js.
638
+ colors = jQuery.Color.names = {
639
+ // 4.1. Basic color keywords
640
+ aqua: "#00ffff",
641
+ black: "#000000",
642
+ blue: "#0000ff",
643
+ fuchsia: "#ff00ff",
644
+ gray: "#808080",
645
+ green: "#008000",
646
+ lime: "#00ff00",
647
+ maroon: "#800000",
648
+ navy: "#000080",
649
+ olive: "#808000",
650
+ purple: "#800080",
651
+ red: "#ff0000",
652
+ silver: "#c0c0c0",
653
+ teal: "#008080",
654
+ white: "#ffffff",
655
+ yellow: "#ffff00",
656
+
657
+ // 4.2.3. "transparent" color keyword
658
+ transparent: [ null, null, null, 0 ],
659
+
660
+ _default: "#ffffff"
661
+ };
662
+
663
+ })( jQuery );