cytoplasm 0.0.1

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 (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,48 @@
1
+ // CytoTable v0.1
2
+ // By MacKinley Smith
3
+ (function($){
4
+ var defaults = {
5
+ widget:{
6
+ table:{
7
+ cell:{
8
+ padding:0,
9
+ spacing:0
10
+ }
11
+ }
12
+ },
13
+ events:{
14
+ create:function(cy){},
15
+ change:function(cy,event){},
16
+ destroy:function(cy){}
17
+ }
18
+ };
19
+
20
+ var methods = {
21
+ init:function(options){
22
+ return this.each(function(){
23
+ var $this = $(this);
24
+ var settings = $.extend(true,{},defaults,options);
25
+
26
+ // Setup table
27
+ $this.attr({cellpadding:0,cellspacing:0});
28
+
29
+ $this.data('cytoTable',settings);
30
+ });
31
+ },
32
+ resize:function(){
33
+
34
+ },
35
+ destroy:function(){
36
+
37
+ }
38
+ };
39
+
40
+ $.fn.cytoTable=function(method){
41
+ if (methods[method]) return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
42
+ else if (typeof method == 'object' || !method) return methods.init.apply(this,arguments);
43
+ else $.error('Method ' + method + ' does not exist on $.cytoTable!');
44
+ };
45
+
46
+ $(window).resize(function(){$('.cytoTable').cytoTable('resize');});
47
+ $.Cytoplasm("ready",function(){$('.cytoTable').cytoTable();});
48
+ })(jQuery);
@@ -0,0 +1,200 @@
1
+ // CytoUpload v2.0
2
+ // By MacKinley Smith
3
+ (function($){
4
+ var defaults = {
5
+ widget:{
6
+ button:{
7
+ placeholder:"Click to select a file for upload…",
8
+ css:{
9
+ "text-align":"left",
10
+ width:"100%",
11
+ height:30
12
+ },
13
+ element:null,
14
+ nameReadout:{
15
+ css:{},
16
+ element:null
17
+ },
18
+ sizeReadout:{
19
+ css:{
20
+ font:'<%=Cytoplasm.vars("fonts.sizes.small")+" "+Cytoplasm.vars("fonts.faces.medium")%>',
21
+ float:'right'
22
+ },
23
+ element:null,
24
+ precision:2,
25
+ units:['b','Kb','Mb','Gb','Tb']
26
+ },
27
+ active:false
28
+ },
29
+ input:{
30
+ css:{display:'none'},
31
+ element:null
32
+ },
33
+ wrapper:{
34
+ css:{},
35
+ element:null
36
+ }
37
+ },
38
+ events:{
39
+ create:function(){},
40
+ change:function(file){},
41
+ destroy:function(){}
42
+ },
43
+ filters:{
44
+ name:false,
45
+ type:false,
46
+ size:false
47
+ },
48
+ errors:{
49
+ name:"The file you have chosen is not named correctly.",
50
+ size:"The file you have chosen is larger that the allowed size.",
51
+ type:"The file you have chosen is not the correct type."
52
+ }
53
+ };
54
+ var methods = {
55
+ init:function(options,reinit){
56
+ if (reinit==null) reinit = false;
57
+ return this.each(function(){
58
+ var $this = $(this);
59
+ if ($this.data("cytoUpload")!=null && $this.hasClass("cytoUpload")) return console.warn("You cannot reinstatiate cytoUpload before calling the destroy method.\nProtip: Use the refresh method to reinstantiate in one move.");
60
+
61
+ // Instantiate settings
62
+ var settings = $.extend(true,{},defaults,options);
63
+ $this.data('cytoUpload',settings);
64
+
65
+ // Generate widget
66
+ settings.widget.wrapper.element = $this.wrap("<div></div>").parent().addClass('cytoUpload-wrapper').css(settings.widget.wrapper.css);
67
+ settings.widget.input.element = $this.addClass('cytoUpload').css(settings.widget.input.css);
68
+ settings.widget.button.element = $('<button />').addClass('cytoButton cytoUpload-button').css(settings.widget.button.css).appendTo(settings.widget.wrapper.element)
69
+ settings.widget.button.nameReadout.element = $('<span />').addClass('cytoUpload-nameReadout').css(settings.widget.button.nameReadout.css).html(settings.widget.button.placeholder).appendTo(settings.widget.button.element);
70
+ settings.widget.button.sizeReadout.element = $('<span />').addClass('cytoUpload-sizeReadout').css(settings.widget.button.sizeReadout.css).appendTo(settings.widget.button.element);
71
+
72
+ // Bindings
73
+ settings.widget.button.element.bind('click.cytoUpload',function(e){
74
+ e.preventDefault();
75
+ $this.click();
76
+ });
77
+ $this.bind('change.cytoUpload',function(){
78
+ var file = this.files[0];
79
+ methods.activate.apply($this,[file]);
80
+ var size = file.size;
81
+
82
+ for (u=0;size>=1024;u++) size/=1024;
83
+ settings.widget.button.element.html(file.name).append($('<span />').css(settings.widget.button.sizeReadout.css).html(size.toFixed(2)+" "+settings.widget.button.sizeReadout.units[u])).addClass('active');
84
+ settings.events.change.apply($this,[file]);
85
+ });
86
+
87
+ // Store data in data-cytoUpload
88
+ $this.data('cytoUpload',settings);
89
+
90
+ // Attempt to activate via JSON from data-file attribute
91
+ if ($this.data('file')!=null) try {
92
+ var file = $.parseJSON($this.data('file'));
93
+ methods.activate.apply($this,[file]);
94
+ } catch (e) {console.warn("The file parameter you passed did not contain valid JSON and therefore it has been ignored.");}
95
+
96
+ settings.events.create.apply($this);
97
+ });
98
+ },
99
+ activate:function(file){
100
+ if (file==null || typeof file!="object" || typeof file.name!="string" || typeof file.size!="number" || typeof file.type!="string") return $.error("$.cytoUpload('activate') requires one parameter of type File Object ({name:(string containing filename),size:(integer containing filesize in bytes),type:(string containing a MIME type)}.");
101
+ return this.each(function(){
102
+ var $this = $(this);
103
+ var settings = $this.data('cytoUpload');
104
+ if (!$this.hasClass('cytoUpload') || settings==null) return console.warn("You must instanciate $.cytoUpload before you call the activate method!");
105
+
106
+ // Run filters over the received data
107
+ var error;
108
+ if (typeof settings.filters.name == "string" && file.name != settings.filters.name) error = settings.errors.name;
109
+ if ((typeof settings.filters.type == "string" && file.type != settings.filters.type) || (typeof settings.filters.type=="object" && $.inArray(file.type,settings.filters.type)==-1)) error = settings.errors.type;
110
+ if (settings.filters.size && size > settings.filters.size) error = settings.errors.size;
111
+ if (error!=null) {
112
+ $.cytoAjaxResponse(error,"error");
113
+ return;
114
+ }
115
+
116
+ // Calculate size
117
+ var size = file.size;
118
+ for (u=0;size>=1024;u++) size/=1024;
119
+ size = size.toFixed(settings.widget.button.sizeReadout.precision)+" "+settings.widget.button.sizeReadout.units[u];
120
+
121
+ // Apply cosmetic changes
122
+ settings.widget.button.element.addClass('active');
123
+ settings.widget.button.nameReadout.element.html(file.name);
124
+ settings.widget.button.sizeReadout.element.html(size);
125
+ });
126
+ },
127
+ destroy:function(){
128
+ return this.each(function(){
129
+ var $this = $(this);
130
+ var settings = $this.data('cytoUpload');
131
+ if (!$this.hasClass('cytoUpload') || settings==null) return console.warn("You must instanciate $.cytoUpload before you call the destroy method!");
132
+
133
+ $this.removeClass('cytoUpload').unbind('.cytoUpload').data('cytoUpload',null).siblings('*').remove().end().unwrap().show();
134
+ });
135
+ },
136
+ refresh:function(){
137
+ return this.each(function(){
138
+ var $this = $(this);
139
+ var settings = $this.data('cytoUpload');
140
+ if (!$this.hasClass('cytoUpload') || settings==null) return console.warn("You must instanciate $.cytoUpload before you call the refresh method!");
141
+
142
+ methods.destroy.apply($this);
143
+ methods.init.apply($this,[settings,true]);
144
+ $this.trigger('change.cytoUpload');
145
+ });
146
+ },
147
+ error:function(message){
148
+ return this.each(function(){
149
+ var $this = $(this);
150
+ var settings = $this.data('cytoUpload');
151
+ if (!$this.hasClass('cytoUpload') || settings==null) return console.warn("You must instanciate $.cytoUpload before you call the error method!");
152
+
153
+ settings.widget.errorMessage.element.html(((typeof message == "string")?message:"An error occurred, please try again.")).show(settings.widget.errorMessage.animationTime);
154
+ settings.widget.button.element.removeClass('active');
155
+ methods.refresh.apply($this);
156
+ });
157
+ },
158
+ resize:function(){
159
+ return this.each(function(){
160
+ var $this = $(this);
161
+ var settings = $this.data('cytoUpload');
162
+ if (!$this.hasClass('cytoUpload') || settings==null) return console.warn("You must instanciate $.cytoUpload before you call the resize method!");
163
+
164
+ var w = settings.widget.wrapper.element.width(0);
165
+ setTimeout(function(){
166
+ w.width("100%").width(w.width()-2);
167
+ },1);
168
+ });
169
+ },
170
+ options:function(newOptions){
171
+ if (newOptions!=null) {
172
+ return this.each(function(){
173
+ var $this = $(this);
174
+ var settings = $this.data('cytoUpload');
175
+ if (!$this.hasClass("cytoUpload") || settings==null) return console.warn("You must instanciate $.cytoUpload before you call the options method!");
176
+ $this.data('cytoUpload',$.extend(true,{},settings,newOptions));
177
+ methods.refresh.apply($this);
178
+ });
179
+ } else {
180
+ var returnVal;
181
+ this.each(function(){
182
+ var $this = $(this);
183
+ var settings = $this.data('cytoUpload');
184
+ if (!$this.hasClass("cytoUpload") || settings==null) return console.warn("You must instanciate $.cytoUpload before you call the options method!");
185
+ returnVal = settings;
186
+ });
187
+ return returnVal;
188
+ }
189
+ }
190
+ };
191
+
192
+ $.fn.cytoUpload = function(method){
193
+ if (methods[method]) return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
194
+ else if (typeof method == 'object' || !method) return methods.init.apply(this,arguments);
195
+ else $.error('Method '+method+' does not exist on jQuery.cytoUpload!');
196
+ };
197
+
198
+ $(window).resize(function(){$('.cytoUpload').cytoUpload('resize');});
199
+ $.Cytoplasm("ready",function(){$('.cytoUpload').cytoUpload();});
200
+ })(jQuery);
@@ -0,0 +1,220 @@
1
+ // CytoPlasm jQuery Setup v0.1
2
+ // By MacKinley Smith
3
+
4
+ // Initialize global JS variables
5
+ var Cytoplasm;
6
+
7
+ (function($){
8
+ // Ensure that jQuery and jQuery UI get loaded
9
+ $.each(["/assets/jquery.js","/assets/jquery-ui.js"],function(i,script){if (!$('script[src="'+script+'"], script[src="'+script+'?body=1"]').is('*')) $('head').append("<script type='text/javascript' src='"+script+"'></script>");});
10
+
11
+ var fixInputs = function(){$('.cytoField').width("100%").each(function(){$(this).width($(this).width()-16);});};
12
+ $(window).resize(fixInputs);
13
+ $(document).ready(fixInputs);
14
+
15
+ $(document).ready(function(){
16
+ // Setup header
17
+ var header = $("header");
18
+ header.find('h1').click(function(){window.location = "<%=((defined? root_url) ? root_url : "/")%>";});
19
+
20
+ // Setup callback messages
21
+ $.each(["success","sending","error"],function(i,v){
22
+ var $this = $('#'+v+'_message');
23
+ if (!$this.is('*')) {
24
+ $this = $('<p />').addClass('callback_message').attr("id",v+"_message");
25
+ if (header.children(':first-child').is('h1')) $this.insertAfter(header.children(':first-child'));
26
+ else $this.prependTo(header);
27
+ $this.hide();
28
+ }
29
+ });
30
+ });
31
+ })(jQuery);
32
+
33
+ // Cytoplasm plugin
34
+ (function($){
35
+
36
+ var defaults = {
37
+
38
+ };
39
+ var conf = {};
40
+ var vars = {};
41
+ var ready = false;
42
+
43
+ var reverseGradient = function(orig){
44
+ if (typeof orig != "string") return console.warn("Cytoplasm.reverseGradient only accepts string arguments!");
45
+ // Return untouched if not gradient
46
+ if (orig.indexOf("gradient")==-1) return orig;
47
+ // Get direction
48
+ var dir = orig.split("(")[1].split(",")[0];
49
+ // Reverse direction
50
+ var newdir = dir;
51
+ if (dir.indexOf("top")>-1) newdir = newdir.replace("top","bottom");
52
+ else if (dir.indexOf("bottom")>-1) newdir = newdir.replace("bottom","top");
53
+ if (dir.indexOf("left")>-1) newdir = newdir.replace("left","right");
54
+ else if (dir.indexOf("right")>-1) newdir = newdir.replace("right","left");
55
+ return orig.replace(dir,newdir)
56
+ };
57
+ var compileStyles = function(element,styles){
58
+ output = "";
59
+ output += element+" { ";
60
+ $.each(styles,function(prop,value){output += (typeof value == "object") ? compileStyles(prop,value) : prop+" : "+value+"; ";});
61
+ output += " } ";
62
+ return output;
63
+ };
64
+
65
+ var methods = {
66
+ init:function(options){
67
+ var settings = $.extend(true,{},defaults,options);
68
+
69
+ // Fetch latest settings via AJAX
70
+ $.cytoAjax("/cytoplasm/settings/fetch",{},function(data){
71
+ conf = data.conf;
72
+ vars = data.vars;
73
+ methods.setStyles.apply(this);
74
+ $('body').data('cytoplasm',settings);
75
+ ready = true;
76
+ });
77
+ },
78
+ setStyles:function(){
79
+ // Remove existing cytoplasm styles
80
+ if ($('#cytoplasm_dynamic_styles').is("*")) $('#cytoplasm_dynamic_styles').remove();
81
+
82
+ // Set variables
83
+ var boldweight = (vars.fonts.faces.bold==vars.fonts.faces.regular)?"bold":"normal";
84
+ var lightweight = (vars.fonts.faces.light==vars.fonts.faces.regular)?"lighter":"normal";
85
+ var styletag = "";
86
+ var styles = {
87
+ body:{
88
+ background:vars.colors.global.background,
89
+ font:vars.fonts.sizes.normal+" "+vars.fonts.faces.regular,
90
+ color:vars.colors.global.text
91
+ },
92
+ '::selection':{
93
+ background:vars.colors.global.accent,
94
+ color:"contrast("+vars.colors.global.accent+",black,white)"
95
+ },
96
+ '::-moz-selection':{
97
+ background:vars.colors.global.accent,
98
+ color:"contrast("+vars.colors.global.accent+",black,white)"
99
+ },
100
+ a:{
101
+ "font-family":vars.fonts.faces.light,
102
+ "&:hover":{color:vars.colors.global.accent}
103
+ },
104
+ 'h1,h3,h5,b,strong':{
105
+ "font-family":vars.fonts.faces.bold,
106
+ "font-weight":boldweight
107
+ },
108
+ 'h2,h4,h6,table.cytoTable,.cytoButton':{
109
+ "font-family":vars.fonts.faces.light,
110
+ "font-weight":lightweight
111
+ },
112
+ header:{
113
+ '#logo':{
114
+ position:vars.layout.header.logo.position,
115
+ top:vars.layout.header.logo.y+10
116
+ },
117
+ h1:{
118
+ color:"contrast("+vars.colors.global.background+",black,white)"
119
+ }
120
+ },
121
+ 'table.cytoTable':{
122
+ background:vars.colors.plugins.cytoTable.background,
123
+ td:{
124
+ border:vars.colors.plugins.cytoTable.border,
125
+ "&.labelcell":{"font-size":vars.fonts.sizes.small}
126
+ }
127
+ },
128
+ 'input.cytoField':{"font-family":vars.fonts.faces.regular},
129
+ '.cytoButton':{
130
+ border:vars.colors.plugins.cytoButton.border,
131
+ color:vars.colors.plugins.cytoButton.text,
132
+ "&:not(.active),&:not(:active)":{background:vars.colors.plugins.cytoButton.background},
133
+ "&.active,&:active":{background:reverseGradient(vars.colors.plugins.cytoButton.background)}
134
+ }
135
+ };
136
+
137
+ // Heading sizes
138
+ $.each([1,2,3,4,5,6],function(i,num){$('h'+num.toString()).css("font-size",parseInt(vars.fonts.sizes.huge) - (parseInt(vars.fonts.sizes.heading_factor)*i));});
139
+ // Logo positioning
140
+ if (vars.layout.header.logo.align == "center") styles.header["#logo"].left = (($(window).width()-$('header #logo').width())/2) + vars.layout.header.logo.x;
141
+ else styles.header["#logo"][vars.layout.header.logo.align] = vars.layout.header.logo.x+10;
142
+
143
+ // Compile the styles for HTML and add to <head>
144
+ $.each(styles,function(e,s){styletag += compileStyles(e,s);});
145
+ var parser = new(less.Parser)({});
146
+ parser.parse(styletag,function(e,tree){$("<style type='text/css' rel='stylesheet' media='screen' id='cytoplasm_dynamic_styles'>"+tree.toCSS({compress:true})+"</style>").appendTo("head");});
147
+ },
148
+ conf:function(which,value){
149
+ var returnvar;
150
+ if (which==null) return conf;
151
+ if (typeof which != "string") return console.warn("Incorrect argument type passed to $.Cytoplasm(\"conf\")!");
152
+ if (which.indexOf(".")>-1) {
153
+ returnvar = conf;
154
+ var levels = [];
155
+ $.each(which.split("."),function(i,level){
156
+ levels.push(level);
157
+ if (returnvar[level]!=null) returnvar = returnvar[level];
158
+ });
159
+ } else returnvar = conf[which];
160
+ if (returnvar==null) return console.warn("Failed to find Cytoplasm config variable "+which+"!");
161
+ if (value==null) return returnvar;
162
+ else {
163
+ if (levels==null || levels==[]) return conf[which] = value;
164
+ var exp = "conf";
165
+ $.each(levels,function(i,level){exp += "["+level.toString()+"]"});
166
+ exp += " = "+value.toString();
167
+ return eval(exp);
168
+ }
169
+ },
170
+ vars:function(which,value){
171
+ var returnvar;
172
+ if (which==null) return vars;
173
+ if (typeof which != "string") return console.warn("Incorrect argument type passed to $.Cytoplasm(\"vars\")!");
174
+ if (which.indexOf(".")>-1) {
175
+ returnvar = vars;
176
+ var levels = [];
177
+ $.each(which.split("."),function(i,level){
178
+ levels.push(level);
179
+ if (returnvar[level]!=null) returnvar = returnvar[level];
180
+ });
181
+ } else returnvar = vars[which];
182
+ if (returnvar==null) return console.warn("Failed to find Cytoplasm variable "+which+"!");
183
+ if (value==null) {
184
+ return returnvar;
185
+ } else {
186
+ if (levels==null || levels==[]) return vars[which] = value;
187
+ var exp = "vars";
188
+ $.each(levels,function(i,level){exp += "["+level.toString()+"]"});
189
+ exp += " = "+value.toString();
190
+ return eval(exp);
191
+ }
192
+ },
193
+ style:function(){
194
+
195
+ },
196
+ refresh:function(){
197
+
198
+ },
199
+ destroy:function(){
200
+ $('body').data('cytoplasm',null);
201
+ },
202
+ ready:function(callback){
203
+ var interval = setInterval(function(){
204
+ if (ready) {
205
+ callback.apply();
206
+ clearInterval(interval)
207
+ }
208
+ },10);
209
+ }
210
+ };
211
+
212
+ $.Cytoplasm = function(method){
213
+ if (methods[method]) return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
214
+ else if (typeof method == 'object' || !method) return methods.init.apply(this,arguments);
215
+ else $.error('Method ' + method + ' does not exist on jQuery.Cytoplasm!');
216
+ };
217
+
218
+ $(document).ready(function(){$.Cytoplasm()});
219
+
220
+ })(jQuery);