mechanize_store 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (383) hide show
  1. checksums.yaml +15 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +60 -0
  4. data/Rakefile +28 -0
  5. data/app/assets/javascripts/mechanize_store/application.js +22 -0
  6. data/app/assets/javascripts/mechanize_store/sb-admin/bootstrap.js +1951 -0
  7. data/app/assets/javascripts/mechanize_store/sb-admin/custom.js +58 -0
  8. data/app/assets/javascripts/mechanize_store/sb-admin/flot/excanvas.min.js +1 -0
  9. data/app/assets/javascripts/mechanize_store/sb-admin/flot/jquery.flot.js +3137 -0
  10. data/app/assets/javascripts/mechanize_store/sb-admin/flot/jquery.flot.pie.js +817 -0
  11. data/app/assets/javascripts/mechanize_store/sb-admin/flot/main.js +20 -0
  12. data/app/assets/javascripts/mechanize_store/sb-admin/jquery-file-upload/canvas-to-blob.min.js +1 -0
  13. data/app/assets/javascripts/mechanize_store/sb-admin/jquery-file-upload/jquery.blueimp-gallery.min.js +1 -0
  14. data/app/assets/javascripts/mechanize_store/sb-admin/jquery-file-upload/jquery.fileupload-angular.js +429 -0
  15. data/app/assets/javascripts/mechanize_store/sb-admin/jquery-file-upload/jquery.fileupload-audio.js +106 -0
  16. data/app/assets/javascripts/mechanize_store/sb-admin/jquery-file-upload/jquery.fileupload-image.js +309 -0
  17. data/app/assets/javascripts/mechanize_store/sb-admin/jquery-file-upload/jquery.fileupload-jquery-ui.js +152 -0
  18. data/app/assets/javascripts/mechanize_store/sb-admin/jquery-file-upload/jquery.fileupload-process.js +172 -0
  19. data/app/assets/javascripts/mechanize_store/sb-admin/jquery-file-upload/jquery.fileupload-ui.js +699 -0
  20. data/app/assets/javascripts/mechanize_store/sb-admin/jquery-file-upload/jquery.fileupload-validate.js +119 -0
  21. data/app/assets/javascripts/mechanize_store/sb-admin/jquery-file-upload/jquery.fileupload-video.js +106 -0
  22. data/app/assets/javascripts/mechanize_store/sb-admin/jquery-file-upload/jquery.fileupload.js +1426 -0
  23. data/app/assets/javascripts/mechanize_store/sb-admin/jquery-file-upload/jquery.iframe-transport.js +214 -0
  24. data/app/assets/javascripts/mechanize_store/sb-admin/jquery-file-upload/jquery.ui.widget.js +530 -0
  25. data/app/assets/javascripts/mechanize_store/sb-admin/jquery-file-upload/load-image.min.js +1 -0
  26. data/app/assets/javascripts/mechanize_store/sb-admin/jquery-file-upload/main.js +14 -0
  27. data/app/assets/javascripts/mechanize_store/sb-admin/jquery-file-upload/tmpl.min.js +1 -0
  28. data/app/assets/javascripts/mechanize_store/sb-admin/jquery-ui.js +2256 -0
  29. data/app/assets/javascripts/mechanize_store/sb-admin/jquery.activity-indicator-1.0.0.min.js +223 -0
  30. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/dataTables/dataTables.bootstrap.js +245 -0
  31. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/dataTables/jquery.dataTables.js +14013 -0
  32. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/flot/excanvas.min.js +1 -0
  33. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/flot/jquery.flot.js +2599 -0
  34. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/flot/jquery.flot.pie.js +750 -0
  35. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/flot/jquery.flot.resize.js +60 -0
  36. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/flot/jquery.flot.tooltip.min.js +12 -0
  37. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/metisMenu/jquery.metisMenu.js +45 -0
  38. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/morris/morris.js +1888 -0
  39. data/app/assets/javascripts/mechanize_store/sb-admin/plugins/morris/raphael-2.1.0.min.js +10 -0
  40. data/app/assets/javascripts/mechanize_store/sb-admin/sb-admin.js +18 -0
  41. data/app/assets/stylesheets/mechanize_store/application.css +197 -0
  42. data/app/assets/stylesheets/mechanize_store/sb-admin/bootstrap.css +5831 -0
  43. data/app/assets/stylesheets/mechanize_store/sb-admin/plugins/dataTables/dataTables.bootstrap.css +233 -0
  44. data/app/assets/stylesheets/mechanize_store/sb-admin/plugins/morris/morris-0.4.3.min.css +2 -0
  45. data/app/assets/stylesheets/mechanize_store/sb-admin/plugins/social-buttons/social-buttons.css +68 -0
  46. data/app/assets/stylesheets/mechanize_store/sb-admin/plugins/timeline/timeline.css +144 -0
  47. data/app/assets/stylesheets/mechanize_store/sb-admin/sb-admin.css +307 -0
  48. data/app/controllers/mechanize_store/application_controller.rb +4 -0
  49. data/app/controllers/mechanize_store/flags_controller.rb +77 -0
  50. data/app/controllers/mechanize_store/order_statuses_controller.rb +77 -0
  51. data/app/controllers/mechanize_store/orders_controller.rb +28 -0
  52. data/app/controllers/mechanize_store/payment_statuses_controller.rb +77 -0
  53. data/app/controllers/mechanize_store/payment_types_controller.rb +77 -0
  54. data/app/controllers/mechanize_store/product_categories_controller.rb +77 -0
  55. data/app/controllers/mechanize_store/product_photos_controller.rb +49 -0
  56. data/app/controllers/mechanize_store/products_controller.rb +77 -0
  57. data/app/helpers/mechanize_store/application_helper.rb +7 -0
  58. data/app/models/mechanize_store/flag.rb +4 -0
  59. data/app/models/mechanize_store/freight.rb +5 -0
  60. data/app/models/mechanize_store/order.rb +47 -0
  61. data/app/models/mechanize_store/order_item.rb +10 -0
  62. data/app/models/mechanize_store/order_status.rb +10 -0
  63. data/app/models/mechanize_store/payment.rb +8 -0
  64. data/app/models/mechanize_store/payment_status.rb +19 -0
  65. data/app/models/mechanize_store/payment_type.rb +5 -0
  66. data/app/models/mechanize_store/product.rb +11 -0
  67. data/app/models/mechanize_store/product_category.rb +5 -0
  68. data/app/models/mechanize_store/product_photo.rb +16 -0
  69. data/app/views/mechanize_store/flags/_form.html.erb +11 -0
  70. data/app/views/mechanize_store/flags/edit.html.erb +12 -0
  71. data/app/views/mechanize_store/flags/index.html.erb +46 -0
  72. data/app/views/mechanize_store/flags/new.html.erb +9 -0
  73. data/app/views/mechanize_store/flags/show.html.erb +15 -0
  74. data/app/views/mechanize_store/order_statuses/_form.html.erb +11 -0
  75. data/app/views/mechanize_store/order_statuses/edit.html.erb +12 -0
  76. data/app/views/mechanize_store/order_statuses/index.html.erb +46 -0
  77. data/app/views/mechanize_store/order_statuses/new.html.erb +9 -0
  78. data/app/views/mechanize_store/order_statuses/show.html.erb +15 -0
  79. data/app/views/mechanize_store/orders/index.html.erb +84 -0
  80. data/app/views/mechanize_store/orders/show.html.erb +0 -0
  81. data/app/views/mechanize_store/payment_statuses/_form.html.erb +11 -0
  82. data/app/views/mechanize_store/payment_statuses/edit.html.erb +12 -0
  83. data/app/views/mechanize_store/payment_statuses/index.html.erb +46 -0
  84. data/app/views/mechanize_store/payment_statuses/new.html.erb +9 -0
  85. data/app/views/mechanize_store/payment_statuses/show.html.erb +15 -0
  86. data/app/views/mechanize_store/payment_types/_form.html.erb +11 -0
  87. data/app/views/mechanize_store/payment_types/edit.html.erb +12 -0
  88. data/app/views/mechanize_store/payment_types/index.html.erb +46 -0
  89. data/app/views/mechanize_store/payment_types/new.html.erb +9 -0
  90. data/app/views/mechanize_store/payment_types/show.html.erb +15 -0
  91. data/app/views/mechanize_store/product_categories/_form.html.erb +12 -0
  92. data/app/views/mechanize_store/product_categories/edit.html.erb +12 -0
  93. data/app/views/mechanize_store/product_categories/index.html.erb +46 -0
  94. data/app/views/mechanize_store/product_categories/new.html.erb +9 -0
  95. data/app/views/mechanize_store/product_categories/show.html.erb +19 -0
  96. data/app/views/mechanize_store/product_photos/create.json.jbuilder +9 -0
  97. data/app/views/mechanize_store/product_photos/index.json.jbuilder +9 -0
  98. data/app/views/mechanize_store/products/_form.html.erb +18 -0
  99. data/app/views/mechanize_store/products/edit.html.erb +12 -0
  100. data/app/views/mechanize_store/products/index.html.erb +50 -0
  101. data/app/views/mechanize_store/products/new.html.erb +9 -0
  102. data/app/views/mechanize_store/products/show.html.erb +197 -0
  103. data/app/views/shared/_flashes.html.erb +8 -0
  104. data/config/locales/mechanize_store.pt-BR.yml +65 -0
  105. data/config/routes.rb +11 -0
  106. data/db/migrate/20140401203200_create_mechanize_store_freights.rb +12 -0
  107. data/db/migrate/20140401203246_create_mechanize_store_order_statuses.rb +9 -0
  108. data/db/migrate/20140402140318_create_mechanize_store_payment_statuses.rb +9 -0
  109. data/db/migrate/20140402140325_create_mechanize_store_payment_types.rb +9 -0
  110. data/db/migrate/20140402140539_create_mechanize_store_payments.rb +15 -0
  111. data/db/migrate/20140402140549_create_mechanize_store_flags.rb +9 -0
  112. data/db/migrate/20140402140832_create_mechanize_store_products.rb +16 -0
  113. data/db/migrate/20140402140942_create_mechanize_store_product_photos.rb +10 -0
  114. data/db/migrate/20140402153139_create_mechanize_store_orders.rb +11 -0
  115. data/db/migrate/20140402192058_create_mechanize_store_product_categories.rb +10 -0
  116. data/db/migrate/20140407193412_add_width_to_mechanize_store_product.rb +6 -0
  117. data/db/migrate/20140409191426_create_mechanize_store_order_items.rb +12 -0
  118. data/db/migrate/20140416123100_add_payment_type_id_to_payment.rb +6 -0
  119. data/db/migrate/20140417200520_add_time_to_freight.rb +5 -0
  120. data/lib/mechanize_store.rb +4 -0
  121. data/lib/mechanize_store/engine.rb +17 -0
  122. data/lib/mechanize_store/version.rb +3 -0
  123. data/lib/tasks/mechanize_store_tasks.rake +4 -0
  124. data/lib/templates/erb/scaffold/_form.html.erb +13 -0
  125. data/lib/templates/erb/scaffold/edit.html.erb +12 -0
  126. data/lib/templates/erb/scaffold/index.html.erb +50 -0
  127. data/lib/templates/erb/scaffold/new.html.erb +9 -0
  128. data/lib/templates/erb/scaffold/show.html.erb +17 -0
  129. data/lib/templates/rails/scaffold_controller/controller.rb +79 -0
  130. data/spec/controllers/mechanize_store/flags_controller_spec.rb +138 -0
  131. data/spec/controllers/mechanize_store/order_statuses_controller_spec.rb +138 -0
  132. data/spec/controllers/mechanize_store/orders_controller_spec.rb +29 -0
  133. data/spec/controllers/mechanize_store/payment_statuses_controller_spec.rb +139 -0
  134. data/spec/controllers/mechanize_store/payment_types_controller_spec.rb +139 -0
  135. data/spec/controllers/mechanize_store/product_categories_controller_spec.rb +138 -0
  136. data/spec/controllers/mechanize_store/product_photos_controller_spec.rb +75 -0
  137. data/spec/controllers/mechanize_store/products_controller_spec.rb +135 -0
  138. data/spec/dummy/README.rdoc +28 -0
  139. data/spec/dummy/Rakefile +6 -0
  140. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  141. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  142. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  143. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  144. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  145. data/spec/dummy/bin/bundle +3 -0
  146. data/spec/dummy/bin/rails +4 -0
  147. data/spec/dummy/bin/rake +4 -0
  148. data/spec/dummy/config.ru +4 -0
  149. data/spec/dummy/config/application.rb +25 -0
  150. data/spec/dummy/config/boot.rb +5 -0
  151. data/spec/dummy/config/database.yml +25 -0
  152. data/spec/dummy/config/environment.rb +5 -0
  153. data/spec/dummy/config/environments/development.rb +29 -0
  154. data/spec/dummy/config/environments/production.rb +80 -0
  155. data/spec/dummy/config/environments/test.rb +36 -0
  156. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  157. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  158. data/spec/dummy/config/initializers/inflections.rb +16 -0
  159. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  160. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  161. data/spec/dummy/config/initializers/session_store.rb +3 -0
  162. data/spec/dummy/config/initializers/simple_form.rb +145 -0
  163. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  164. data/spec/dummy/config/locales/en.yml +23 -0
  165. data/spec/dummy/config/locales/pt-BR.yml +23 -0
  166. data/spec/dummy/config/routes.rb +3 -0
  167. data/spec/dummy/db/development.sqlite3 +0 -0
  168. data/spec/dummy/db/migrate/20140407144119_create_mechanize_store_freights.mechanize_store.rb +13 -0
  169. data/spec/dummy/db/migrate/20140407144120_create_mechanize_store_order_statuses.mechanize_store.rb +10 -0
  170. data/spec/dummy/db/migrate/20140407144121_create_mechanize_store_payment_statuses.mechanize_store.rb +10 -0
  171. data/spec/dummy/db/migrate/20140407144122_create_mechanize_store_payment_types.mechanize_store.rb +10 -0
  172. data/spec/dummy/db/migrate/20140407144123_create_mechanize_store_payments.mechanize_store.rb +17 -0
  173. data/spec/dummy/db/migrate/20140407144124_create_mechanize_store_flags.mechanize_store.rb +10 -0
  174. data/spec/dummy/db/migrate/20140407144125_create_mechanize_store_products.mechanize_store.rb +17 -0
  175. data/spec/dummy/db/migrate/20140407144126_create_mechanize_store_product_photos.mechanize_store.rb +11 -0
  176. data/spec/dummy/db/migrate/20140407144127_create_mechanize_store_orders.mechanize_store.rb +12 -0
  177. data/spec/dummy/db/migrate/20140407144128_create_mechanize_store_product_categories.mechanize_store.rb +11 -0
  178. data/spec/dummy/db/migrate/20140407193949_add_width_to_mechanize_store_product.mechanize_store.rb +7 -0
  179. data/spec/dummy/db/migrate/20140409191457_create_mechanize_store_order_items.mechanize_store.rb +13 -0
  180. data/spec/dummy/db/schema.rb +125 -0
  181. data/spec/dummy/db/test.sqlite3 +0 -0
  182. data/spec/dummy/log/development.log +24931 -0
  183. data/spec/dummy/log/test.log +42225 -0
  184. data/spec/dummy/public/404.html +58 -0
  185. data/spec/dummy/public/422.html +58 -0
  186. data/spec/dummy/public/500.html +57 -0
  187. data/spec/dummy/public/favicon.ico +0 -0
  188. data/spec/dummy/tmp/cache/assets/development/sprockets/015a50b3ac7ad70aa90ce0a95c99df04 +0 -0
  189. data/spec/dummy/tmp/cache/assets/development/sprockets/020540bcd9f6782692071f17f50f43b0 +0 -0
  190. data/spec/dummy/tmp/cache/assets/development/sprockets/0378e5799bf84efc4c9b8ac61252a081 +0 -0
  191. data/spec/dummy/tmp/cache/assets/development/sprockets/04032662bf2ebfb00b4218e459ab14bf +0 -0
  192. data/spec/dummy/tmp/cache/assets/development/sprockets/043663643ec7f44e8f7baeb7856605bb +0 -0
  193. data/spec/dummy/tmp/cache/assets/development/sprockets/059883583379e5e373caaa73ac8f18ca +0 -0
  194. data/spec/dummy/tmp/cache/assets/development/sprockets/05f7ba95ff1ffeab9cb378fcb7b0289f +0 -0
  195. data/spec/dummy/tmp/cache/assets/development/sprockets/069b62a9f82e145a95c6dbcada54860d +0 -0
  196. data/spec/dummy/tmp/cache/assets/development/sprockets/06ce3d4f3b99f90fa0ced1db38c5fb13 +0 -0
  197. data/spec/dummy/tmp/cache/assets/development/sprockets/0a70c895b23487214ec56a6cd4bd9552 +0 -0
  198. data/spec/dummy/tmp/cache/assets/development/sprockets/0e42ab04670f4d8017b5eeb5ec7f080b +0 -0
  199. data/spec/dummy/tmp/cache/assets/development/sprockets/0f2edd5bf10b0d769d20d28769abf705 +0 -0
  200. data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  201. data/spec/dummy/tmp/cache/assets/development/sprockets/14464296f672d2910982229137d66535 +0 -0
  202. data/spec/dummy/tmp/cache/assets/development/sprockets/19456f04c83f78d9ab6e5d57031015ef +0 -0
  203. data/spec/dummy/tmp/cache/assets/development/sprockets/1a5faaf1e18d5f49d129459ae565f1af +0 -0
  204. data/spec/dummy/tmp/cache/assets/development/sprockets/1a78a9c2facea31464f84e54fdc36059 +0 -0
  205. data/spec/dummy/tmp/cache/assets/development/sprockets/1da2c163f7f6bbd029786010cd788bce +0 -0
  206. data/spec/dummy/tmp/cache/assets/development/sprockets/250ad25722c066145272032ad82f4561 +0 -0
  207. data/spec/dummy/tmp/cache/assets/development/sprockets/2593c6406f0e0ba8eb5271badc1fbef1 +0 -0
  208. data/spec/dummy/tmp/cache/assets/development/sprockets/262f77e6bb6c8e1453f5477c82a17b11 +0 -0
  209. data/spec/dummy/tmp/cache/assets/development/sprockets/27479abec405e7ea5ee309699b19c495 +0 -0
  210. data/spec/dummy/tmp/cache/assets/development/sprockets/2b16e3dfbce9d1bb0de91f424f03694a +0 -0
  211. data/spec/dummy/tmp/cache/assets/development/sprockets/2b89581781ce2529d6435ae4a831dcb9 +0 -0
  212. data/spec/dummy/tmp/cache/assets/development/sprockets/2c8d436d977e56045cd16cc55f33e24f +0 -0
  213. data/spec/dummy/tmp/cache/assets/development/sprockets/2d8950ff6bb73413e9deb6e196bfffd0 +0 -0
  214. data/spec/dummy/tmp/cache/assets/development/sprockets/2dc34152e91278da6990e448dccf297a +0 -0
  215. data/spec/dummy/tmp/cache/assets/development/sprockets/2e2c50f356deda30cee516e501b1eb70 +0 -0
  216. data/spec/dummy/tmp/cache/assets/development/sprockets/2ee1b9592bbe1ba628925e28b31fdc2a +0 -0
  217. data/spec/dummy/tmp/cache/assets/development/sprockets/2f378010bb54f8ca9c2a38c7df245b26 +0 -0
  218. data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  219. data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  220. data/spec/dummy/tmp/cache/assets/development/sprockets/38aa872dea852cc952801236dfc073fc +0 -0
  221. data/spec/dummy/tmp/cache/assets/development/sprockets/3c562eb64c2c0fc045f18356d3ddd84e +0 -0
  222. data/spec/dummy/tmp/cache/assets/development/sprockets/3daa6dd7a3804d55f1896a2d40ccea5f +0 -0
  223. data/spec/dummy/tmp/cache/assets/development/sprockets/436e4923cef6508f9572309894ad3afb +0 -0
  224. data/spec/dummy/tmp/cache/assets/development/sprockets/43db98f3f4043e28dd241d4bcf40a382 +0 -0
  225. data/spec/dummy/tmp/cache/assets/development/sprockets/4517526bf21c2e0d4475812a0801ff73 +0 -0
  226. data/spec/dummy/tmp/cache/assets/development/sprockets/45e8f86d32c088635371e9d83d481ff0 +0 -0
  227. data/spec/dummy/tmp/cache/assets/development/sprockets/46c7525f809be6b9a6da46ec5281b90d +0 -0
  228. data/spec/dummy/tmp/cache/assets/development/sprockets/48710380827190cf4c297aeb8ff8f521 +0 -0
  229. data/spec/dummy/tmp/cache/assets/development/sprockets/48c25b92a4e1841bd519a77588afb5df +0 -0
  230. data/spec/dummy/tmp/cache/assets/development/sprockets/4b3b499b73fde3f086615d203a4cd9ee +0 -0
  231. data/spec/dummy/tmp/cache/assets/development/sprockets/4c1f9a5156d1c8724067d833a65dc486 +0 -0
  232. data/spec/dummy/tmp/cache/assets/development/sprockets/4e1d544283e15d5f8e7575f717a440a4 +0 -0
  233. data/spec/dummy/tmp/cache/assets/development/sprockets/54843f9a3a2ac75ad7ebde3307ce8606 +0 -0
  234. data/spec/dummy/tmp/cache/assets/development/sprockets/55116814eac2aaa3b60343e4269a18f9 +0 -0
  235. data/spec/dummy/tmp/cache/assets/development/sprockets/55d45208b6b824293fd70642ec435749 +0 -0
  236. data/spec/dummy/tmp/cache/assets/development/sprockets/593ece65492f611f990932db9d09f2c7 +0 -0
  237. data/spec/dummy/tmp/cache/assets/development/sprockets/59bb66920183998fcca5f2c787d0180e +0 -0
  238. data/spec/dummy/tmp/cache/assets/development/sprockets/5c19a1c0836acd88cf90128587c8a9f2 +0 -0
  239. data/spec/dummy/tmp/cache/assets/development/sprockets/5cbd47d1e56ce6ad12324dc100b18435 +0 -0
  240. data/spec/dummy/tmp/cache/assets/development/sprockets/5dd2138848e347d174c374d012420ae3 +0 -0
  241. data/spec/dummy/tmp/cache/assets/development/sprockets/5e2b19c7c137f093e3a17e2eed13b00e +0 -0
  242. data/spec/dummy/tmp/cache/assets/development/sprockets/5f29f414f1d3e6a4c8eacd4974e20369 +0 -0
  243. data/spec/dummy/tmp/cache/assets/development/sprockets/5fc8e81b247da7b93af8a2eb06017a5e +0 -0
  244. data/spec/dummy/tmp/cache/assets/development/sprockets/646c6b9465381d825591b427e65cfa6f +0 -0
  245. data/spec/dummy/tmp/cache/assets/development/sprockets/6554b2d6606c5f90f91a8a1f01ee5207 +0 -0
  246. data/spec/dummy/tmp/cache/assets/development/sprockets/662f5fc7888fcf74ff719aea443f1e0e +0 -0
  247. data/spec/dummy/tmp/cache/assets/development/sprockets/66c3c3a1daf01d2edc14fb56645814af +0 -0
  248. data/spec/dummy/tmp/cache/assets/development/sprockets/69f57e81929c085cfd164a7b30f9cb5f +0 -0
  249. data/spec/dummy/tmp/cache/assets/development/sprockets/6a7af764897e94acc0adc4f6855846ea +0 -0
  250. data/spec/dummy/tmp/cache/assets/development/sprockets/6ddd5e3587977e83d7dc7b7124cc4044 +0 -0
  251. data/spec/dummy/tmp/cache/assets/development/sprockets/70894d30d9a638ae5cb410c1bf51d436 +0 -0
  252. data/spec/dummy/tmp/cache/assets/development/sprockets/746b6834bc4167c8495578a1b7b05cd2 +0 -0
  253. data/spec/dummy/tmp/cache/assets/development/sprockets/748419e05355441fbf8b5177841a01ae +0 -0
  254. data/spec/dummy/tmp/cache/assets/development/sprockets/75b6e2b76634cd778e12a60b8862cc83 +0 -0
  255. data/spec/dummy/tmp/cache/assets/development/sprockets/75e995d7f41c3d87054f39654ee96276 +0 -0
  256. data/spec/dummy/tmp/cache/assets/development/sprockets/7a6ffbc3e76322931e50faa267bf2ccd +0 -0
  257. data/spec/dummy/tmp/cache/assets/development/sprockets/7dbc97a9be7f04dc0f5cb28337fe9f4c +0 -0
  258. data/spec/dummy/tmp/cache/assets/development/sprockets/7e908a7a32793f07298fa2f32f7a1da6 +0 -0
  259. data/spec/dummy/tmp/cache/assets/development/sprockets/80137a3a1ee5336154baaea4290aa0fa +0 -0
  260. data/spec/dummy/tmp/cache/assets/development/sprockets/80a4a7e08ffe3c1b0ad632a9f69dae61 +0 -0
  261. data/spec/dummy/tmp/cache/assets/development/sprockets/875373523edad14b9efdc32d30056b88 +0 -0
  262. data/spec/dummy/tmp/cache/assets/development/sprockets/8b2a3bdfdd87982dbcdf9beaa4883771 +0 -0
  263. data/spec/dummy/tmp/cache/assets/development/sprockets/8c29fc18ccf7320aa1f9d9fbc277adbc +0 -0
  264. data/spec/dummy/tmp/cache/assets/development/sprockets/8c48b01bb6fe5d3f87c3e2d8796bfe57 +0 -0
  265. data/spec/dummy/tmp/cache/assets/development/sprockets/8c880b8aef8a9168cf039ff966dde072 +0 -0
  266. data/spec/dummy/tmp/cache/assets/development/sprockets/8e1041b3a7abe8f1431f078dd04e52f2 +0 -0
  267. data/spec/dummy/tmp/cache/assets/development/sprockets/8e1509b014a325c41eb6d6d060697d5b +0 -0
  268. data/spec/dummy/tmp/cache/assets/development/sprockets/9295c97f3680de471db1138760883721 +0 -0
  269. data/spec/dummy/tmp/cache/assets/development/sprockets/932ff26d70c7f83db540941e70fbc256 +0 -0
  270. data/spec/dummy/tmp/cache/assets/development/sprockets/95d1184dee9d6ad8efbb18992ef7f3bd +0 -0
  271. data/spec/dummy/tmp/cache/assets/development/sprockets/9a57b3781439b98aa17111614be63659 +0 -0
  272. data/spec/dummy/tmp/cache/assets/development/sprockets/9a958d65f5d84cf81a860fe6b98f7586 +0 -0
  273. data/spec/dummy/tmp/cache/assets/development/sprockets/9ba78083ca4f55d2e3dbb4c16f5108a4 +0 -0
  274. data/spec/dummy/tmp/cache/assets/development/sprockets/9bf7f52d56b17c5fcacc89e0196ec9ec +0 -0
  275. data/spec/dummy/tmp/cache/assets/development/sprockets/9dcc41c3f740c89aa23972f9f0fb7682 +0 -0
  276. data/spec/dummy/tmp/cache/assets/development/sprockets/9dd69825bb5d22668e78fcadbcc384bf +0 -0
  277. data/spec/dummy/tmp/cache/assets/development/sprockets/9f7694dc7aa37365dca45aa754f46e75 +0 -0
  278. data/spec/dummy/tmp/cache/assets/development/sprockets/a119b32f75ff105e311edc0f31ca67f6 +0 -0
  279. data/spec/dummy/tmp/cache/assets/development/sprockets/a388745aef9974ea0f378a3b83f6f8e7 +0 -0
  280. data/spec/dummy/tmp/cache/assets/development/sprockets/a80b32eb0130473db70817a2464be54a +0 -0
  281. data/spec/dummy/tmp/cache/assets/development/sprockets/a97cfb7a9ba4204c2c02cb794e0b529e +0 -0
  282. data/spec/dummy/tmp/cache/assets/development/sprockets/a9d026eb5dcf44bbad77067be7ccc216 +0 -0
  283. data/spec/dummy/tmp/cache/assets/development/sprockets/ac2422a2e7c30bbcf41620f5eadf6c9a +0 -0
  284. data/spec/dummy/tmp/cache/assets/development/sprockets/aca81e68e9477c36988579e16d099f7a +0 -0
  285. data/spec/dummy/tmp/cache/assets/development/sprockets/ad821e6998f57556c2bbebeac574bbd3 +0 -0
  286. data/spec/dummy/tmp/cache/assets/development/sprockets/adc26899d70ead5b9321d6b6be5cb73a +0 -0
  287. data/spec/dummy/tmp/cache/assets/development/sprockets/ae2d91de359a9f7f39d93f379705b07c +0 -0
  288. data/spec/dummy/tmp/cache/assets/development/sprockets/b1909373f0eb96fc7eb1a16b13cf9d9c +0 -0
  289. data/spec/dummy/tmp/cache/assets/development/sprockets/b2d360ac92a3862e54a81752fac14f04 +0 -0
  290. data/spec/dummy/tmp/cache/assets/development/sprockets/b32edcdd838f74e3b0b694bb4fb78135 +0 -0
  291. data/spec/dummy/tmp/cache/assets/development/sprockets/b80b1d0da5126d78830d5cc9d33bb939 +0 -0
  292. data/spec/dummy/tmp/cache/assets/development/sprockets/b80ff122a6e6cb26a8726574c9ed9843 +0 -0
  293. data/spec/dummy/tmp/cache/assets/development/sprockets/b8788a2d9cd7867f9732a0d1218b3be3 +0 -0
  294. data/spec/dummy/tmp/cache/assets/development/sprockets/c01c09c7af2805825d421efe97369c92 +0 -0
  295. data/spec/dummy/tmp/cache/assets/development/sprockets/c096a28eb3fb4f6a5943814c1d83de28 +0 -0
  296. data/spec/dummy/tmp/cache/assets/development/sprockets/c1c5e3bf6b463ce593f544553cd61880 +0 -0
  297. data/spec/dummy/tmp/cache/assets/development/sprockets/c206d760825f5d60935bc162372aae5f +0 -0
  298. data/spec/dummy/tmp/cache/assets/development/sprockets/c276778eb885b31ac5c72899422f687b +0 -0
  299. data/spec/dummy/tmp/cache/assets/development/sprockets/c381ab6aead4f08abb9b7da1fd2c5cbe +0 -0
  300. data/spec/dummy/tmp/cache/assets/development/sprockets/c3fae7c3a4d1eb0934a03e3508994894 +0 -0
  301. data/spec/dummy/tmp/cache/assets/development/sprockets/c532dcbd254ee5454d453f8dca2ea356 +0 -0
  302. data/spec/dummy/tmp/cache/assets/development/sprockets/c5febc1300d6cd4c2f85a5dcc4ccca65 +0 -0
  303. data/spec/dummy/tmp/cache/assets/development/sprockets/c6337ac9ac53de67c5e4e0bbd8e0b98f +0 -0
  304. data/spec/dummy/tmp/cache/assets/development/sprockets/c63f6f599121de54f10407499bdeb95d +0 -0
  305. data/spec/dummy/tmp/cache/assets/development/sprockets/c6ccf7b3128d1693a850e8014129e21b +0 -0
  306. data/spec/dummy/tmp/cache/assets/development/sprockets/c884f6ae49a257a9b8218d60cddc22c1 +0 -0
  307. data/spec/dummy/tmp/cache/assets/development/sprockets/c9053dba65ec180c37b513c1e0a02953 +0 -0
  308. data/spec/dummy/tmp/cache/assets/development/sprockets/c9274eaf6338c910a014211f057bb10f +0 -0
  309. data/spec/dummy/tmp/cache/assets/development/sprockets/c9b7bfc895f9ef763149e886eed1c12a +0 -0
  310. data/spec/dummy/tmp/cache/assets/development/sprockets/ca5d6127a6b6cb20b3137c6ed1b086e4 +0 -0
  311. data/spec/dummy/tmp/cache/assets/development/sprockets/ca68d3d42cc489b72f5a9caa1bec8a0f +0 -0
  312. data/spec/dummy/tmp/cache/assets/development/sprockets/cbb3bbaeb5cbb28714fc2d854e55d759 +0 -0
  313. data/spec/dummy/tmp/cache/assets/development/sprockets/cbc8f4f72d68f84e285b14c13c615e94 +0 -0
  314. data/spec/dummy/tmp/cache/assets/development/sprockets/cbf5cac128a3b9fd8567cf02d8b5c7f4 +0 -0
  315. data/spec/dummy/tmp/cache/assets/development/sprockets/cf62df2949741a6dfcbdf6dae39a376e +0 -0
  316. data/spec/dummy/tmp/cache/assets/development/sprockets/cfe2122c3660d4bf29e621b13cc1e4c0 +0 -0
  317. data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  318. data/spec/dummy/tmp/cache/assets/development/sprockets/d1ebcb314c13703007e0a6e9c5604655 +0 -0
  319. data/spec/dummy/tmp/cache/assets/development/sprockets/d4db7fd1c1ad160335e9abc86e49a138 +0 -0
  320. data/spec/dummy/tmp/cache/assets/development/sprockets/d5a9b12dc73b0e530314f93a2e7d4270 +0 -0
  321. data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  322. data/spec/dummy/tmp/cache/assets/development/sprockets/d84c8af9dd2dd84ac27282b753d2b33c +0 -0
  323. data/spec/dummy/tmp/cache/assets/development/sprockets/d86a26ce11fa0095e076b69ecd98fbf6 +0 -0
  324. data/spec/dummy/tmp/cache/assets/development/sprockets/dba3e0db21349797be91d79366b2e6d9 +0 -0
  325. data/spec/dummy/tmp/cache/assets/development/sprockets/dcfc0ac1daceac33f1f1d348341a8c75 +0 -0
  326. data/spec/dummy/tmp/cache/assets/development/sprockets/dd149c63c658dcacd022a8bbd0136c9f +0 -0
  327. data/spec/dummy/tmp/cache/assets/development/sprockets/de287cf9a2ea50ebc178bcc7cd8e0f4c +0 -0
  328. data/spec/dummy/tmp/cache/assets/development/sprockets/de35fa3c2360ca5a0479c6ec6c8c0d62 +0 -0
  329. data/spec/dummy/tmp/cache/assets/development/sprockets/dfc074e83f62650815ec91d5e6ae716a +0 -0
  330. data/spec/dummy/tmp/cache/assets/development/sprockets/e4806a3aea27283bdce20bcb1cc894a6 +0 -0
  331. data/spec/dummy/tmp/cache/assets/development/sprockets/e9075a2c21b7e2c0543aceff4975485a +0 -0
  332. data/spec/dummy/tmp/cache/assets/development/sprockets/e9c2ccf818891a7575ec2200367bbf52 +0 -0
  333. data/spec/dummy/tmp/cache/assets/development/sprockets/eb3496f8d86eed2469155f90f146a7bd +0 -0
  334. data/spec/dummy/tmp/cache/assets/development/sprockets/ec5d87f50983b6156db79eb4c4b0ae6d +0 -0
  335. data/spec/dummy/tmp/cache/assets/development/sprockets/f0bb04309f0742e927d269899c6b9a4a +0 -0
  336. data/spec/dummy/tmp/cache/assets/development/sprockets/f0fdb965c01e31547d9058c609918712 +0 -0
  337. data/spec/dummy/tmp/cache/assets/development/sprockets/f2de92b01852702a49c9e9e5cd3b320f +0 -0
  338. data/spec/dummy/tmp/cache/assets/development/sprockets/f478e4dc1bdfe5240e3ca48440488e32 +0 -0
  339. data/spec/dummy/tmp/cache/assets/development/sprockets/f51cc05ee2ec6ed667257568e527f522 +0 -0
  340. data/spec/dummy/tmp/cache/assets/development/sprockets/f535bdc9ad7f7f6ce6009b846c2fc2d7 +0 -0
  341. data/spec/dummy/tmp/cache/assets/development/sprockets/f61f3d9d282d0c092d604b8433071c77 +0 -0
  342. data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  343. data/spec/dummy/tmp/cache/assets/development/sprockets/f97dc728e6d15fb7ba9f14ad2b8b6bcb +0 -0
  344. data/spec/dummy/tmp/cache/assets/development/sprockets/faeec0db256cfb91ad104e66a9453bd9 +0 -0
  345. data/spec/dummy/tmp/cache/assets/development/sprockets/fbbf6a435d522871a2d29d97e370bfce +0 -0
  346. data/spec/dummy/tmp/cache/assets/development/sprockets/ffbf6316da17c85bd6bda4bdb1961baf +0 -0
  347. data/spec/factories/mechanize_store_order_items.rb +10 -0
  348. data/spec/factories/mechanize_store_products.rb +14 -0
  349. data/spec/factories/store_flags.rb +7 -0
  350. data/spec/factories/store_freights.rb +10 -0
  351. data/spec/factories/store_order_statuses.rb +7 -0
  352. data/spec/factories/store_orders.rb +8 -0
  353. data/spec/factories/store_payment_statuses.rb +7 -0
  354. data/spec/factories/store_payment_types.rb +7 -0
  355. data/spec/factories/store_payments.rb +14 -0
  356. data/spec/factories/store_product_categories.rb +8 -0
  357. data/spec/factories/store_product_photos.rb +8 -0
  358. data/spec/factories/store_stores.rb +10 -0
  359. data/spec/features/orders_flow_spec.rb +0 -0
  360. data/spec/features/products_flow_test.rb +68 -0
  361. data/spec/fixtures/rails.png +0 -0
  362. data/spec/models/mechanize_store/order_item_spec.rb +7 -0
  363. data/spec/models/store/flag_spec.rb +7 -0
  364. data/spec/models/store/freight_spec.rb +7 -0
  365. data/spec/models/store/order_spec.rb +7 -0
  366. data/spec/models/store/order_status_spec.rb +7 -0
  367. data/spec/models/store/payment_spec.rb +7 -0
  368. data/spec/models/store/payment_status_spec.rb +7 -0
  369. data/spec/models/store/payment_type_spec.rb +7 -0
  370. data/spec/models/store/product_category_spec.rb +7 -0
  371. data/spec/models/store/product_photo_spec.rb +7 -0
  372. data/spec/models/store/product_spec.rb +7 -0
  373. data/spec/models/store/store_spec.rb +7 -0
  374. data/spec/routing/store/flags_routing_spec.rb +39 -0
  375. data/spec/routing/store/order_statuses_routing_spec.rb +39 -0
  376. data/spec/routing/store/orders_routing_spec.rb +18 -0
  377. data/spec/routing/store/payment_statuses_routing_spec.rb +38 -0
  378. data/spec/routing/store/payment_types_routing_spec.rb +38 -0
  379. data/spec/routing/store/product_categories_routing_spec.rb +39 -0
  380. data/spec/routing/store/products_photos_routing_spec.rb +19 -0
  381. data/spec/routing/store/products_routing_spec.rb +39 -0
  382. data/spec/spec_helper.rb +22 -0
  383. metadata +876 -0
@@ -0,0 +1,60 @@
1
+ /* Flot plugin for automatically redrawing plots as the placeholder resizes.
2
+
3
+ Copyright (c) 2007-2013 IOLA and Ole Laursen.
4
+ Licensed under the MIT license.
5
+
6
+ It works by listening for changes on the placeholder div (through the jQuery
7
+ resize event plugin) - if the size changes, it will redraw the plot.
8
+
9
+ There are no options. If you need to disable the plugin for some plots, you
10
+ can just fix the size of their placeholders.
11
+
12
+ */
13
+
14
+ /* Inline dependency:
15
+ * jQuery resize event - v1.1 - 3/14/2010
16
+ * http://benalman.com/projects/jquery-resize-plugin/
17
+ *
18
+ * Copyright (c) 2010 "Cowboy" Ben Alman
19
+ * Dual licensed under the MIT and GPL licenses.
20
+ * http://benalman.com/about/license/
21
+ */
22
+
23
+ (function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);
24
+
25
+ (function ($) {
26
+ var options = { }; // no options
27
+
28
+ function init(plot) {
29
+ function onResize() {
30
+ var placeholder = plot.getPlaceholder();
31
+
32
+ // somebody might have hidden us and we can't plot
33
+ // when we don't have the dimensions
34
+ if (placeholder.width() == 0 || placeholder.height() == 0)
35
+ return;
36
+
37
+ plot.resize();
38
+ plot.setupGrid();
39
+ plot.draw();
40
+ }
41
+
42
+ function bindEvents(plot, eventHolder) {
43
+ plot.getPlaceholder().resize(onResize);
44
+ }
45
+
46
+ function shutdown(plot, eventHolder) {
47
+ plot.getPlaceholder().unbind("resize", onResize);
48
+ }
49
+
50
+ plot.hooks.bindEvents.push(bindEvents);
51
+ plot.hooks.shutdown.push(shutdown);
52
+ }
53
+
54
+ $.plot.plugins.push({
55
+ init: init,
56
+ options: options,
57
+ name: 'resize',
58
+ version: '1.0'
59
+ });
60
+ })(jQuery);
@@ -0,0 +1,12 @@
1
+ /*
2
+ * jquery.flot.tooltip
3
+ *
4
+ * description: easy-to-use tooltips for Flot charts
5
+ * version: 0.6.2
6
+ * author: Krzysztof Urbas @krzysu [myviews.pl]
7
+ * website: https://github.com/krzysu/flot.tooltip
8
+ *
9
+ * build on 2013-09-30
10
+ * released under MIT License, 2012
11
+ */
12
+ (function(t){var o={tooltip:!1,tooltipOpts:{content:"%s | X: %x | Y: %y",xDateFormat:null,yDateFormat:null,shifts:{x:10,y:20},defaultTheme:!0,onHover:function(){}}},i=function(t){this.tipPosition={x:0,y:0},this.init(t)};i.prototype.init=function(o){function i(t){var o={};o.x=t.pageX,o.y=t.pageY,s.updateTooltipPosition(o)}function e(t,o,i){var e=s.getDomElement();if(i){var n;n=s.stringFormat(s.tooltipOptions.content,i),e.html(n),s.updateTooltipPosition({x:o.pageX,y:o.pageY}),e.css({left:s.tipPosition.x+s.tooltipOptions.shifts.x,top:s.tipPosition.y+s.tooltipOptions.shifts.y}).show(),"function"==typeof s.tooltipOptions.onHover&&s.tooltipOptions.onHover(i,e)}else e.hide().html("")}var s=this;o.hooks.bindEvents.push(function(o,n){s.plotOptions=o.getOptions(),s.plotOptions.tooltip!==!1&&void 0!==s.plotOptions.tooltip&&(s.tooltipOptions=s.plotOptions.tooltipOpts,s.getDomElement(),t(o.getPlaceholder()).bind("plothover",e),t(n).bind("mousemove",i))}),o.hooks.shutdown.push(function(o,s){t(o.getPlaceholder()).unbind("plothover",e),t(s).unbind("mousemove",i)})},i.prototype.getDomElement=function(){var o;return t("#flotTip").length>0?o=t("#flotTip"):(o=t("<div />").attr("id","flotTip"),o.appendTo("body").hide().css({position:"absolute"}),this.tooltipOptions.defaultTheme&&o.css({background:"#fff","z-index":"100",padding:"0.4em 0.6em","border-radius":"0.5em","font-size":"0.8em",border:"1px solid #111",display:"none","white-space":"nowrap"})),o},i.prototype.updateTooltipPosition=function(o){var i=t("#flotTip").outerWidth()+this.tooltipOptions.shifts.x,e=t("#flotTip").outerHeight()+this.tooltipOptions.shifts.y;o.x-t(window).scrollLeft()>t(window).innerWidth()-i&&(o.x-=i),o.y-t(window).scrollTop()>t(window).innerHeight()-e&&(o.y-=e),this.tipPosition.x=o.x,this.tipPosition.y=o.y},i.prototype.stringFormat=function(t,o){var i=/%p\.{0,1}(\d{0,})/,e=/%s/,s=/%x\.{0,1}(?:\d{0,})/,n=/%y\.{0,1}(?:\d{0,})/;return"function"==typeof t&&(t=t(o.series.label,o.series.data[o.dataIndex][0],o.series.data[o.dataIndex][1],o)),o.series.percent!==void 0&&(t=this.adjustValPrecision(i,t,o.series.percent)),o.series.label!==void 0&&(t=t.replace(e,o.series.label)),this.isTimeMode("xaxis",o)&&this.isXDateFormat(o)&&(t=t.replace(s,this.timestampToDate(o.series.data[o.dataIndex][0],this.tooltipOptions.xDateFormat))),this.isTimeMode("yaxis",o)&&this.isYDateFormat(o)&&(t=t.replace(n,this.timestampToDate(o.series.data[o.dataIndex][1],this.tooltipOptions.yDateFormat))),"number"==typeof o.series.data[o.dataIndex][0]&&(t=this.adjustValPrecision(s,t,o.series.data[o.dataIndex][0])),"number"==typeof o.series.data[o.dataIndex][1]&&(t=this.adjustValPrecision(n,t,o.series.data[o.dataIndex][1])),o.series.xaxis.tickFormatter!==void 0&&(t=t.replace(s,o.series.xaxis.tickFormatter(o.series.data[o.dataIndex][0],o.series.xaxis))),o.series.yaxis.tickFormatter!==void 0&&(t=t.replace(n,o.series.yaxis.tickFormatter(o.series.data[o.dataIndex][1],o.series.yaxis))),t},i.prototype.isTimeMode=function(t,o){return o.series[t].options.mode!==void 0&&"time"===o.series[t].options.mode},i.prototype.isXDateFormat=function(){return this.tooltipOptions.xDateFormat!==void 0&&null!==this.tooltipOptions.xDateFormat},i.prototype.isYDateFormat=function(){return this.tooltipOptions.yDateFormat!==void 0&&null!==this.tooltipOptions.yDateFormat},i.prototype.timestampToDate=function(o,i){var e=new Date(o);return t.plot.formatDate(e,i)},i.prototype.adjustValPrecision=function(t,o,i){var e,s=o.match(t);return null!==s&&""!==RegExp.$1&&(e=RegExp.$1,i=i.toFixed(e),o=o.replace(t,i)),o};var e=function(t){new i(t)};t.plot.plugins.push({init:e,options:o,name:"tooltip",version:"0.6.1"})})(jQuery);
@@ -0,0 +1,45 @@
1
+ ;(function ($, window, document, undefined) {
2
+
3
+ var pluginName = "metisMenu",
4
+ defaults = {
5
+ toggle: true
6
+ };
7
+
8
+ function Plugin(element, options) {
9
+ this.element = element;
10
+ this.settings = $.extend({}, defaults, options);
11
+ this._defaults = defaults;
12
+ this._name = pluginName;
13
+ this.init();
14
+ }
15
+
16
+ Plugin.prototype = {
17
+ init: function () {
18
+
19
+ var $this = $(this.element),
20
+ $toggle = this.settings.toggle;
21
+
22
+ $this.find('li.active').has('ul').children('ul').addClass('collapse in');
23
+ $this.find('li').not('.active').has('ul').children('ul').addClass('collapse');
24
+
25
+ $this.find('li').has('ul').children('a').on('click', function (e) {
26
+ e.preventDefault();
27
+
28
+ $(this).parent('li').toggleClass('active').children('ul').collapse('toggle');
29
+
30
+ if ($toggle) {
31
+ $(this).parent('li').siblings().removeClass('active').children('ul.in').collapse('hide');
32
+ }
33
+ });
34
+ }
35
+ };
36
+
37
+ $.fn[ pluginName ] = function (options) {
38
+ return this.each(function () {
39
+ if (!$.data(this, "plugin_" + pluginName)) {
40
+ $.data(this, "plugin_" + pluginName, new Plugin(this, options));
41
+ }
42
+ });
43
+ };
44
+
45
+ })(jQuery, window, document);
@@ -0,0 +1,1888 @@
1
+ (function() {
2
+ var $, Morris, minutesSpecHelper, secondsSpecHelper,
3
+ __slice = [].slice,
4
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
5
+ __hasProp = {}.hasOwnProperty,
6
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
7
+ __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
8
+
9
+ Morris = window.Morris = {};
10
+
11
+ $ = jQuery;
12
+
13
+ Morris.EventEmitter = (function() {
14
+ function EventEmitter() {}
15
+
16
+ EventEmitter.prototype.on = function(name, handler) {
17
+ if (this.handlers == null) {
18
+ this.handlers = {};
19
+ }
20
+ if (this.handlers[name] == null) {
21
+ this.handlers[name] = [];
22
+ }
23
+ this.handlers[name].push(handler);
24
+ return this;
25
+ };
26
+
27
+ EventEmitter.prototype.fire = function() {
28
+ var args, handler, name, _i, _len, _ref, _results;
29
+ name = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
30
+ if ((this.handlers != null) && (this.handlers[name] != null)) {
31
+ _ref = this.handlers[name];
32
+ _results = [];
33
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
34
+ handler = _ref[_i];
35
+ _results.push(handler.apply(null, args));
36
+ }
37
+ return _results;
38
+ }
39
+ };
40
+
41
+ return EventEmitter;
42
+
43
+ })();
44
+
45
+ Morris.commas = function(num) {
46
+ var absnum, intnum, ret, strabsnum;
47
+ if (num != null) {
48
+ ret = num < 0 ? "-" : "";
49
+ absnum = Math.abs(num);
50
+ intnum = Math.floor(absnum).toFixed(0);
51
+ ret += intnum.replace(/(?=(?:\d{3})+$)(?!^)/g, ',');
52
+ strabsnum = absnum.toString();
53
+ if (strabsnum.length > intnum.length) {
54
+ ret += strabsnum.slice(intnum.length);
55
+ }
56
+ return ret;
57
+ } else {
58
+ return '-';
59
+ }
60
+ };
61
+
62
+ Morris.pad2 = function(number) {
63
+ return (number < 10 ? '0' : '') + number;
64
+ };
65
+
66
+ Morris.Grid = (function(_super) {
67
+ __extends(Grid, _super);
68
+
69
+ function Grid(options) {
70
+ this.resizeHandler = __bind(this.resizeHandler, this);
71
+ var _this = this;
72
+ if (typeof options.element === 'string') {
73
+ this.el = $(document.getElementById(options.element));
74
+ } else {
75
+ this.el = $(options.element);
76
+ }
77
+ if ((this.el == null) || this.el.length === 0) {
78
+ throw new Error("Graph container element not found");
79
+ }
80
+ if (this.el.css('position') === 'static') {
81
+ this.el.css('position', 'relative');
82
+ }
83
+ this.options = $.extend({}, this.gridDefaults, this.defaults || {}, options);
84
+ if (typeof this.options.units === 'string') {
85
+ this.options.postUnits = options.units;
86
+ }
87
+ this.raphael = new Raphael(this.el[0]);
88
+ this.elementWidth = null;
89
+ this.elementHeight = null;
90
+ this.dirty = false;
91
+ this.selectFrom = null;
92
+ if (this.init) {
93
+ this.init();
94
+ }
95
+ this.setData(this.options.data);
96
+ this.el.bind('mousemove', function(evt) {
97
+ var left, offset, right, width, x;
98
+ offset = _this.el.offset();
99
+ x = evt.pageX - offset.left;
100
+ if (_this.selectFrom) {
101
+ left = _this.data[_this.hitTest(Math.min(x, _this.selectFrom))]._x;
102
+ right = _this.data[_this.hitTest(Math.max(x, _this.selectFrom))]._x;
103
+ width = right - left;
104
+ return _this.selectionRect.attr({
105
+ x: left,
106
+ width: width
107
+ });
108
+ } else {
109
+ return _this.fire('hovermove', x, evt.pageY - offset.top);
110
+ }
111
+ });
112
+ this.el.bind('mouseleave', function(evt) {
113
+ if (_this.selectFrom) {
114
+ _this.selectionRect.hide();
115
+ _this.selectFrom = null;
116
+ }
117
+ return _this.fire('hoverout');
118
+ });
119
+ this.el.bind('touchstart touchmove touchend', function(evt) {
120
+ var offset, touch;
121
+ touch = evt.originalEvent.touches[0] || evt.originalEvent.changedTouches[0];
122
+ offset = _this.el.offset();
123
+ _this.fire('hover', touch.pageX - offset.left, touch.pageY - offset.top);
124
+ return touch;
125
+ });
126
+ this.el.bind('click', function(evt) {
127
+ var offset;
128
+ offset = _this.el.offset();
129
+ return _this.fire('gridclick', evt.pageX - offset.left, evt.pageY - offset.top);
130
+ });
131
+ if (this.options.rangeSelect) {
132
+ this.selectionRect = this.raphael.rect(0, 0, 0, this.el.innerHeight()).attr({
133
+ fill: this.options.rangeSelectColor,
134
+ stroke: false
135
+ }).toBack().hide();
136
+ this.el.bind('mousedown', function(evt) {
137
+ var offset;
138
+ offset = _this.el.offset();
139
+ return _this.startRange(evt.pageX - offset.left);
140
+ });
141
+ this.el.bind('mouseup', function(evt) {
142
+ var offset;
143
+ offset = _this.el.offset();
144
+ _this.endRange(evt.pageX - offset.left);
145
+ return _this.fire('hovermove', evt.pageX - offset.left, evt.pageY - offset.top);
146
+ });
147
+ }
148
+ if (this.options.resize) {
149
+ $(window).bind('resize', function(evt) {
150
+ if (_this.timeoutId != null) {
151
+ window.clearTimeout(_this.timeoutId);
152
+ }
153
+ return _this.timeoutId = window.setTimeout(_this.resizeHandler, 100);
154
+ });
155
+ }
156
+ if (this.postInit) {
157
+ this.postInit();
158
+ }
159
+ }
160
+
161
+ Grid.prototype.gridDefaults = {
162
+ dateFormat: null,
163
+ axes: true,
164
+ grid: true,
165
+ gridLineColor: '#aaa',
166
+ gridStrokeWidth: 0.5,
167
+ gridTextColor: '#888',
168
+ gridTextSize: 12,
169
+ gridTextFamily: 'sans-serif',
170
+ gridTextWeight: 'normal',
171
+ hideHover: false,
172
+ yLabelFormat: null,
173
+ xLabelAngle: 0,
174
+ numLines: 5,
175
+ padding: 25,
176
+ parseTime: true,
177
+ postUnits: '',
178
+ preUnits: '',
179
+ ymax: 'auto',
180
+ ymin: 'auto 0',
181
+ goals: [],
182
+ goalStrokeWidth: 1.0,
183
+ goalLineColors: ['#666633', '#999966', '#cc6666', '#663333'],
184
+ events: [],
185
+ eventStrokeWidth: 1.0,
186
+ eventLineColors: ['#005a04', '#ccffbb', '#3a5f0b', '#005502'],
187
+ rangeSelect: null,
188
+ rangeSelectColor: '#eef',
189
+ resize: false
190
+ };
191
+
192
+ Grid.prototype.setData = function(data, redraw) {
193
+ var e, idx, index, maxGoal, minGoal, ret, row, step, total, y, ykey, ymax, ymin, yval, _ref;
194
+ if (redraw == null) {
195
+ redraw = true;
196
+ }
197
+ this.options.data = data;
198
+ if ((data == null) || data.length === 0) {
199
+ this.data = [];
200
+ this.raphael.clear();
201
+ if (this.hover != null) {
202
+ this.hover.hide();
203
+ }
204
+ return;
205
+ }
206
+ ymax = this.cumulative ? 0 : null;
207
+ ymin = this.cumulative ? 0 : null;
208
+ if (this.options.goals.length > 0) {
209
+ minGoal = Math.min.apply(Math, this.options.goals);
210
+ maxGoal = Math.max.apply(Math, this.options.goals);
211
+ ymin = ymin != null ? Math.min(ymin, minGoal) : minGoal;
212
+ ymax = ymax != null ? Math.max(ymax, maxGoal) : maxGoal;
213
+ }
214
+ this.data = (function() {
215
+ var _i, _len, _results;
216
+ _results = [];
217
+ for (index = _i = 0, _len = data.length; _i < _len; index = ++_i) {
218
+ row = data[index];
219
+ ret = {
220
+ src: row
221
+ };
222
+ ret.label = row[this.options.xkey];
223
+ if (this.options.parseTime) {
224
+ ret.x = Morris.parseDate(ret.label);
225
+ if (this.options.dateFormat) {
226
+ ret.label = this.options.dateFormat(ret.x);
227
+ } else if (typeof ret.label === 'number') {
228
+ ret.label = new Date(ret.label).toString();
229
+ }
230
+ } else {
231
+ ret.x = index;
232
+ if (this.options.xLabelFormat) {
233
+ ret.label = this.options.xLabelFormat(ret);
234
+ }
235
+ }
236
+ total = 0;
237
+ ret.y = (function() {
238
+ var _j, _len1, _ref, _results1;
239
+ _ref = this.options.ykeys;
240
+ _results1 = [];
241
+ for (idx = _j = 0, _len1 = _ref.length; _j < _len1; idx = ++_j) {
242
+ ykey = _ref[idx];
243
+ yval = row[ykey];
244
+ if (typeof yval === 'string') {
245
+ yval = parseFloat(yval);
246
+ }
247
+ if ((yval != null) && typeof yval !== 'number') {
248
+ yval = null;
249
+ }
250
+ if (yval != null) {
251
+ if (this.cumulative) {
252
+ total += yval;
253
+ } else {
254
+ if (ymax != null) {
255
+ ymax = Math.max(yval, ymax);
256
+ ymin = Math.min(yval, ymin);
257
+ } else {
258
+ ymax = ymin = yval;
259
+ }
260
+ }
261
+ }
262
+ if (this.cumulative && (total != null)) {
263
+ ymax = Math.max(total, ymax);
264
+ ymin = Math.min(total, ymin);
265
+ }
266
+ _results1.push(yval);
267
+ }
268
+ return _results1;
269
+ }).call(this);
270
+ _results.push(ret);
271
+ }
272
+ return _results;
273
+ }).call(this);
274
+ if (this.options.parseTime) {
275
+ this.data = this.data.sort(function(a, b) {
276
+ return (a.x > b.x) - (b.x > a.x);
277
+ });
278
+ }
279
+ this.xmin = this.data[0].x;
280
+ this.xmax = this.data[this.data.length - 1].x;
281
+ this.events = [];
282
+ if (this.options.events.length > 0) {
283
+ if (this.options.parseTime) {
284
+ this.events = (function() {
285
+ var _i, _len, _ref, _results;
286
+ _ref = this.options.events;
287
+ _results = [];
288
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
289
+ e = _ref[_i];
290
+ _results.push(Morris.parseDate(e));
291
+ }
292
+ return _results;
293
+ }).call(this);
294
+ } else {
295
+ this.events = this.options.events;
296
+ }
297
+ this.xmax = Math.max(this.xmax, Math.max.apply(Math, this.events));
298
+ this.xmin = Math.min(this.xmin, Math.min.apply(Math, this.events));
299
+ }
300
+ if (this.xmin === this.xmax) {
301
+ this.xmin -= 1;
302
+ this.xmax += 1;
303
+ }
304
+ this.ymin = this.yboundary('min', ymin);
305
+ this.ymax = this.yboundary('max', ymax);
306
+ if (this.ymin === this.ymax) {
307
+ if (ymin) {
308
+ this.ymin -= 1;
309
+ }
310
+ this.ymax += 1;
311
+ }
312
+ if (((_ref = this.options.axes) === true || _ref === 'both' || _ref === 'y') || this.options.grid === true) {
313
+ if (this.options.ymax === this.gridDefaults.ymax && this.options.ymin === this.gridDefaults.ymin) {
314
+ this.grid = this.autoGridLines(this.ymin, this.ymax, this.options.numLines);
315
+ this.ymin = Math.min(this.ymin, this.grid[0]);
316
+ this.ymax = Math.max(this.ymax, this.grid[this.grid.length - 1]);
317
+ } else {
318
+ step = (this.ymax - this.ymin) / (this.options.numLines - 1);
319
+ this.grid = (function() {
320
+ var _i, _ref1, _ref2, _results;
321
+ _results = [];
322
+ for (y = _i = _ref1 = this.ymin, _ref2 = this.ymax; step > 0 ? _i <= _ref2 : _i >= _ref2; y = _i += step) {
323
+ _results.push(y);
324
+ }
325
+ return _results;
326
+ }).call(this);
327
+ }
328
+ }
329
+ this.dirty = true;
330
+ if (redraw) {
331
+ return this.redraw();
332
+ }
333
+ };
334
+
335
+ Grid.prototype.yboundary = function(boundaryType, currentValue) {
336
+ var boundaryOption, suggestedValue;
337
+ boundaryOption = this.options["y" + boundaryType];
338
+ if (typeof boundaryOption === 'string') {
339
+ if (boundaryOption.slice(0, 4) === 'auto') {
340
+ if (boundaryOption.length > 5) {
341
+ suggestedValue = parseInt(boundaryOption.slice(5), 10);
342
+ if (currentValue == null) {
343
+ return suggestedValue;
344
+ }
345
+ return Math[boundaryType](currentValue, suggestedValue);
346
+ } else {
347
+ if (currentValue != null) {
348
+ return currentValue;
349
+ } else {
350
+ return 0;
351
+ }
352
+ }
353
+ } else {
354
+ return parseInt(boundaryOption, 10);
355
+ }
356
+ } else {
357
+ return boundaryOption;
358
+ }
359
+ };
360
+
361
+ Grid.prototype.autoGridLines = function(ymin, ymax, nlines) {
362
+ var gmax, gmin, grid, smag, span, step, unit, y, ymag;
363
+ span = ymax - ymin;
364
+ ymag = Math.floor(Math.log(span) / Math.log(10));
365
+ unit = Math.pow(10, ymag);
366
+ gmin = Math.floor(ymin / unit) * unit;
367
+ gmax = Math.ceil(ymax / unit) * unit;
368
+ step = (gmax - gmin) / (nlines - 1);
369
+ if (unit === 1 && step > 1 && Math.ceil(step) !== step) {
370
+ step = Math.ceil(step);
371
+ gmax = gmin + step * (nlines - 1);
372
+ }
373
+ if (gmin < 0 && gmax > 0) {
374
+ gmin = Math.floor(ymin / step) * step;
375
+ gmax = Math.ceil(ymax / step) * step;
376
+ }
377
+ if (step < 1) {
378
+ smag = Math.floor(Math.log(step) / Math.log(10));
379
+ grid = (function() {
380
+ var _i, _results;
381
+ _results = [];
382
+ for (y = _i = gmin; step > 0 ? _i <= gmax : _i >= gmax; y = _i += step) {
383
+ _results.push(parseFloat(y.toFixed(1 - smag)));
384
+ }
385
+ return _results;
386
+ })();
387
+ } else {
388
+ grid = (function() {
389
+ var _i, _results;
390
+ _results = [];
391
+ for (y = _i = gmin; step > 0 ? _i <= gmax : _i >= gmax; y = _i += step) {
392
+ _results.push(y);
393
+ }
394
+ return _results;
395
+ })();
396
+ }
397
+ return grid;
398
+ };
399
+
400
+ Grid.prototype._calc = function() {
401
+ var bottomOffsets, gridLine, h, i, w, yLabelWidths, _ref, _ref1;
402
+ w = this.el.width();
403
+ h = this.el.height();
404
+ if (this.elementWidth !== w || this.elementHeight !== h || this.dirty) {
405
+ this.elementWidth = w;
406
+ this.elementHeight = h;
407
+ this.dirty = false;
408
+ this.left = this.options.padding;
409
+ this.right = this.elementWidth - this.options.padding;
410
+ this.top = this.options.padding;
411
+ this.bottom = this.elementHeight - this.options.padding;
412
+ if ((_ref = this.options.axes) === true || _ref === 'both' || _ref === 'y') {
413
+ yLabelWidths = (function() {
414
+ var _i, _len, _ref1, _results;
415
+ _ref1 = this.grid;
416
+ _results = [];
417
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
418
+ gridLine = _ref1[_i];
419
+ _results.push(this.measureText(this.yAxisFormat(gridLine)).width);
420
+ }
421
+ return _results;
422
+ }).call(this);
423
+ this.left += Math.max.apply(Math, yLabelWidths);
424
+ }
425
+ if ((_ref1 = this.options.axes) === true || _ref1 === 'both' || _ref1 === 'x') {
426
+ bottomOffsets = (function() {
427
+ var _i, _ref2, _results;
428
+ _results = [];
429
+ for (i = _i = 0, _ref2 = this.data.length; 0 <= _ref2 ? _i < _ref2 : _i > _ref2; i = 0 <= _ref2 ? ++_i : --_i) {
430
+ _results.push(this.measureText(this.data[i].text, -this.options.xLabelAngle).height);
431
+ }
432
+ return _results;
433
+ }).call(this);
434
+ this.bottom -= Math.max.apply(Math, bottomOffsets);
435
+ }
436
+ this.width = Math.max(1, this.right - this.left);
437
+ this.height = Math.max(1, this.bottom - this.top);
438
+ this.dx = this.width / (this.xmax - this.xmin);
439
+ this.dy = this.height / (this.ymax - this.ymin);
440
+ if (this.calc) {
441
+ return this.calc();
442
+ }
443
+ }
444
+ };
445
+
446
+ Grid.prototype.transY = function(y) {
447
+ return this.bottom - (y - this.ymin) * this.dy;
448
+ };
449
+
450
+ Grid.prototype.transX = function(x) {
451
+ if (this.data.length === 1) {
452
+ return (this.left + this.right) / 2;
453
+ } else {
454
+ return this.left + (x - this.xmin) * this.dx;
455
+ }
456
+ };
457
+
458
+ Grid.prototype.redraw = function() {
459
+ this.raphael.clear();
460
+ this._calc();
461
+ this.drawGrid();
462
+ this.drawGoals();
463
+ this.drawEvents();
464
+ if (this.draw) {
465
+ return this.draw();
466
+ }
467
+ };
468
+
469
+ Grid.prototype.measureText = function(text, angle) {
470
+ var ret, tt;
471
+ if (angle == null) {
472
+ angle = 0;
473
+ }
474
+ tt = this.raphael.text(100, 100, text).attr('font-size', this.options.gridTextSize).attr('font-family', this.options.gridTextFamily).attr('font-weight', this.options.gridTextWeight).rotate(angle);
475
+ ret = tt.getBBox();
476
+ tt.remove();
477
+ return ret;
478
+ };
479
+
480
+ Grid.prototype.yAxisFormat = function(label) {
481
+ return this.yLabelFormat(label);
482
+ };
483
+
484
+ Grid.prototype.yLabelFormat = function(label) {
485
+ if (typeof this.options.yLabelFormat === 'function') {
486
+ return this.options.yLabelFormat(label);
487
+ } else {
488
+ return "" + this.options.preUnits + (Morris.commas(label)) + this.options.postUnits;
489
+ }
490
+ };
491
+
492
+ Grid.prototype.drawGrid = function() {
493
+ var lineY, y, _i, _len, _ref, _ref1, _ref2, _results;
494
+ if (this.options.grid === false && ((_ref = this.options.axes) !== true && _ref !== 'both' && _ref !== 'y')) {
495
+ return;
496
+ }
497
+ _ref1 = this.grid;
498
+ _results = [];
499
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
500
+ lineY = _ref1[_i];
501
+ y = this.transY(lineY);
502
+ if ((_ref2 = this.options.axes) === true || _ref2 === 'both' || _ref2 === 'y') {
503
+ this.drawYAxisLabel(this.left - this.options.padding / 2, y, this.yAxisFormat(lineY));
504
+ }
505
+ if (this.options.grid) {
506
+ _results.push(this.drawGridLine("M" + this.left + "," + y + "H" + (this.left + this.width)));
507
+ } else {
508
+ _results.push(void 0);
509
+ }
510
+ }
511
+ return _results;
512
+ };
513
+
514
+ Grid.prototype.drawGoals = function() {
515
+ var color, goal, i, _i, _len, _ref, _results;
516
+ _ref = this.options.goals;
517
+ _results = [];
518
+ for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
519
+ goal = _ref[i];
520
+ color = this.options.goalLineColors[i % this.options.goalLineColors.length];
521
+ _results.push(this.drawGoal(goal, color));
522
+ }
523
+ return _results;
524
+ };
525
+
526
+ Grid.prototype.drawEvents = function() {
527
+ var color, event, i, _i, _len, _ref, _results;
528
+ _ref = this.events;
529
+ _results = [];
530
+ for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
531
+ event = _ref[i];
532
+ color = this.options.eventLineColors[i % this.options.eventLineColors.length];
533
+ _results.push(this.drawEvent(event, color));
534
+ }
535
+ return _results;
536
+ };
537
+
538
+ Grid.prototype.drawGoal = function(goal, color) {
539
+ return this.raphael.path("M" + this.left + "," + (this.transY(goal)) + "H" + this.right).attr('stroke', color).attr('stroke-width', this.options.goalStrokeWidth);
540
+ };
541
+
542
+ Grid.prototype.drawEvent = function(event, color) {
543
+ return this.raphael.path("M" + (this.transX(event)) + "," + this.bottom + "V" + this.top).attr('stroke', color).attr('stroke-width', this.options.eventStrokeWidth);
544
+ };
545
+
546
+ Grid.prototype.drawYAxisLabel = function(xPos, yPos, text) {
547
+ return this.raphael.text(xPos, yPos, text).attr('font-size', this.options.gridTextSize).attr('font-family', this.options.gridTextFamily).attr('font-weight', this.options.gridTextWeight).attr('fill', this.options.gridTextColor).attr('text-anchor', 'end');
548
+ };
549
+
550
+ Grid.prototype.drawGridLine = function(path) {
551
+ return this.raphael.path(path).attr('stroke', this.options.gridLineColor).attr('stroke-width', this.options.gridStrokeWidth);
552
+ };
553
+
554
+ Grid.prototype.startRange = function(x) {
555
+ this.hover.hide();
556
+ this.selectFrom = x;
557
+ return this.selectionRect.attr({
558
+ x: x,
559
+ width: 0
560
+ }).show();
561
+ };
562
+
563
+ Grid.prototype.endRange = function(x) {
564
+ var end, start;
565
+ if (this.selectFrom) {
566
+ start = Math.min(this.selectFrom, x);
567
+ end = Math.max(this.selectFrom, x);
568
+ this.options.rangeSelect.call(this.el, {
569
+ start: this.data[this.hitTest(start)].x,
570
+ end: this.data[this.hitTest(end)].x
571
+ });
572
+ return this.selectFrom = null;
573
+ }
574
+ };
575
+
576
+ Grid.prototype.resizeHandler = function() {
577
+ this.timeoutId = null;
578
+ this.raphael.setSize(this.el.width(), this.el.height());
579
+ return this.redraw();
580
+ };
581
+
582
+ return Grid;
583
+
584
+ })(Morris.EventEmitter);
585
+
586
+ Morris.parseDate = function(date) {
587
+ var isecs, m, msecs, n, o, offsetmins, p, q, r, ret, secs;
588
+ if (typeof date === 'number') {
589
+ return date;
590
+ }
591
+ m = date.match(/^(\d+) Q(\d)$/);
592
+ n = date.match(/^(\d+)-(\d+)$/);
593
+ o = date.match(/^(\d+)-(\d+)-(\d+)$/);
594
+ p = date.match(/^(\d+) W(\d+)$/);
595
+ q = date.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+)(Z|([+-])(\d\d):?(\d\d))?$/);
596
+ r = date.match(/^(\d+)-(\d+)-(\d+)[ T](\d+):(\d+):(\d+(\.\d+)?)(Z|([+-])(\d\d):?(\d\d))?$/);
597
+ if (m) {
598
+ return new Date(parseInt(m[1], 10), parseInt(m[2], 10) * 3 - 1, 1).getTime();
599
+ } else if (n) {
600
+ return new Date(parseInt(n[1], 10), parseInt(n[2], 10) - 1, 1).getTime();
601
+ } else if (o) {
602
+ return new Date(parseInt(o[1], 10), parseInt(o[2], 10) - 1, parseInt(o[3], 10)).getTime();
603
+ } else if (p) {
604
+ ret = new Date(parseInt(p[1], 10), 0, 1);
605
+ if (ret.getDay() !== 4) {
606
+ ret.setMonth(0, 1 + ((4 - ret.getDay()) + 7) % 7);
607
+ }
608
+ return ret.getTime() + parseInt(p[2], 10) * 604800000;
609
+ } else if (q) {
610
+ if (!q[6]) {
611
+ return new Date(parseInt(q[1], 10), parseInt(q[2], 10) - 1, parseInt(q[3], 10), parseInt(q[4], 10), parseInt(q[5], 10)).getTime();
612
+ } else {
613
+ offsetmins = 0;
614
+ if (q[6] !== 'Z') {
615
+ offsetmins = parseInt(q[8], 10) * 60 + parseInt(q[9], 10);
616
+ if (q[7] === '+') {
617
+ offsetmins = 0 - offsetmins;
618
+ }
619
+ }
620
+ return Date.UTC(parseInt(q[1], 10), parseInt(q[2], 10) - 1, parseInt(q[3], 10), parseInt(q[4], 10), parseInt(q[5], 10) + offsetmins);
621
+ }
622
+ } else if (r) {
623
+ secs = parseFloat(r[6]);
624
+ isecs = Math.floor(secs);
625
+ msecs = Math.round((secs - isecs) * 1000);
626
+ if (!r[8]) {
627
+ return new Date(parseInt(r[1], 10), parseInt(r[2], 10) - 1, parseInt(r[3], 10), parseInt(r[4], 10), parseInt(r[5], 10), isecs, msecs).getTime();
628
+ } else {
629
+ offsetmins = 0;
630
+ if (r[8] !== 'Z') {
631
+ offsetmins = parseInt(r[10], 10) * 60 + parseInt(r[11], 10);
632
+ if (r[9] === '+') {
633
+ offsetmins = 0 - offsetmins;
634
+ }
635
+ }
636
+ return Date.UTC(parseInt(r[1], 10), parseInt(r[2], 10) - 1, parseInt(r[3], 10), parseInt(r[4], 10), parseInt(r[5], 10) + offsetmins, isecs, msecs);
637
+ }
638
+ } else {
639
+ return new Date(parseInt(date, 10), 0, 1).getTime();
640
+ }
641
+ };
642
+
643
+ Morris.Hover = (function() {
644
+ Hover.defaults = {
645
+ "class": 'morris-hover morris-default-style'
646
+ };
647
+
648
+ function Hover(options) {
649
+ if (options == null) {
650
+ options = {};
651
+ }
652
+ this.options = $.extend({}, Morris.Hover.defaults, options);
653
+ this.el = $("<div class='" + this.options["class"] + "'></div>");
654
+ this.el.hide();
655
+ this.options.parent.append(this.el);
656
+ }
657
+
658
+ Hover.prototype.update = function(html, x, y) {
659
+ this.html(html);
660
+ this.show();
661
+ return this.moveTo(x, y);
662
+ };
663
+
664
+ Hover.prototype.html = function(content) {
665
+ return this.el.html(content);
666
+ };
667
+
668
+ Hover.prototype.moveTo = function(x, y) {
669
+ var hoverHeight, hoverWidth, left, parentHeight, parentWidth, top;
670
+ parentWidth = this.options.parent.innerWidth();
671
+ parentHeight = this.options.parent.innerHeight();
672
+ hoverWidth = this.el.outerWidth();
673
+ hoverHeight = this.el.outerHeight();
674
+ left = Math.min(Math.max(0, x - hoverWidth / 2), parentWidth - hoverWidth);
675
+ if (y != null) {
676
+ top = y - hoverHeight - 10;
677
+ if (top < 0) {
678
+ top = y + 10;
679
+ if (top + hoverHeight > parentHeight) {
680
+ top = parentHeight / 2 - hoverHeight / 2;
681
+ }
682
+ }
683
+ } else {
684
+ top = parentHeight / 2 - hoverHeight / 2;
685
+ }
686
+ return this.el.css({
687
+ left: left + "px",
688
+ top: parseInt(top) + "px"
689
+ });
690
+ };
691
+
692
+ Hover.prototype.show = function() {
693
+ return this.el.show();
694
+ };
695
+
696
+ Hover.prototype.hide = function() {
697
+ return this.el.hide();
698
+ };
699
+
700
+ return Hover;
701
+
702
+ })();
703
+
704
+ Morris.Line = (function(_super) {
705
+ __extends(Line, _super);
706
+
707
+ function Line(options) {
708
+ this.hilight = __bind(this.hilight, this);
709
+ this.onHoverOut = __bind(this.onHoverOut, this);
710
+ this.onHoverMove = __bind(this.onHoverMove, this);
711
+ this.onGridClick = __bind(this.onGridClick, this);
712
+ if (!(this instanceof Morris.Line)) {
713
+ return new Morris.Line(options);
714
+ }
715
+ Line.__super__.constructor.call(this, options);
716
+ }
717
+
718
+ Line.prototype.init = function() {
719
+ if (this.options.hideHover !== 'always') {
720
+ this.hover = new Morris.Hover({
721
+ parent: this.el
722
+ });
723
+ this.on('hovermove', this.onHoverMove);
724
+ this.on('hoverout', this.onHoverOut);
725
+ return this.on('gridclick', this.onGridClick);
726
+ }
727
+ };
728
+
729
+ Line.prototype.defaults = {
730
+ lineWidth: 3,
731
+ pointSize: 4,
732
+ lineColors: ['#0b62a4', '#7A92A3', '#4da74d', '#afd8f8', '#edc240', '#cb4b4b', '#9440ed'],
733
+ pointStrokeWidths: [1],
734
+ pointStrokeColors: ['#ffffff'],
735
+ pointFillColors: [],
736
+ smooth: true,
737
+ xLabels: 'auto',
738
+ xLabelFormat: null,
739
+ xLabelMargin: 24,
740
+ continuousLine: true,
741
+ hideHover: false
742
+ };
743
+
744
+ Line.prototype.calc = function() {
745
+ this.calcPoints();
746
+ return this.generatePaths();
747
+ };
748
+
749
+ Line.prototype.calcPoints = function() {
750
+ var row, y, _i, _len, _ref, _results;
751
+ _ref = this.data;
752
+ _results = [];
753
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
754
+ row = _ref[_i];
755
+ row._x = this.transX(row.x);
756
+ row._y = (function() {
757
+ var _j, _len1, _ref1, _results1;
758
+ _ref1 = row.y;
759
+ _results1 = [];
760
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
761
+ y = _ref1[_j];
762
+ if (y != null) {
763
+ _results1.push(this.transY(y));
764
+ } else {
765
+ _results1.push(y);
766
+ }
767
+ }
768
+ return _results1;
769
+ }).call(this);
770
+ _results.push(row._ymax = Math.min.apply(Math, [this.bottom].concat((function() {
771
+ var _j, _len1, _ref1, _results1;
772
+ _ref1 = row._y;
773
+ _results1 = [];
774
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
775
+ y = _ref1[_j];
776
+ if (y != null) {
777
+ _results1.push(y);
778
+ }
779
+ }
780
+ return _results1;
781
+ })())));
782
+ }
783
+ return _results;
784
+ };
785
+
786
+ Line.prototype.hitTest = function(x) {
787
+ var index, r, _i, _len, _ref;
788
+ if (this.data.length === 0) {
789
+ return null;
790
+ }
791
+ _ref = this.data.slice(1);
792
+ for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) {
793
+ r = _ref[index];
794
+ if (x < (r._x + this.data[index]._x) / 2) {
795
+ break;
796
+ }
797
+ }
798
+ return index;
799
+ };
800
+
801
+ Line.prototype.onGridClick = function(x, y) {
802
+ var index;
803
+ index = this.hitTest(x);
804
+ return this.fire('click', index, this.data[index].src, x, y);
805
+ };
806
+
807
+ Line.prototype.onHoverMove = function(x, y) {
808
+ var index;
809
+ index = this.hitTest(x);
810
+ return this.displayHoverForRow(index);
811
+ };
812
+
813
+ Line.prototype.onHoverOut = function() {
814
+ if (this.options.hideHover !== false) {
815
+ return this.displayHoverForRow(null);
816
+ }
817
+ };
818
+
819
+ Line.prototype.displayHoverForRow = function(index) {
820
+ var _ref;
821
+ if (index != null) {
822
+ (_ref = this.hover).update.apply(_ref, this.hoverContentForRow(index));
823
+ return this.hilight(index);
824
+ } else {
825
+ this.hover.hide();
826
+ return this.hilight();
827
+ }
828
+ };
829
+
830
+ Line.prototype.hoverContentForRow = function(index) {
831
+ var content, j, row, y, _i, _len, _ref;
832
+ row = this.data[index];
833
+ content = "<div class='morris-hover-row-label'>" + row.label + "</div>";
834
+ _ref = row.y;
835
+ for (j = _i = 0, _len = _ref.length; _i < _len; j = ++_i) {
836
+ y = _ref[j];
837
+ content += "<div class='morris-hover-point' style='color: " + (this.colorFor(row, j, 'label')) + "'>\n " + this.options.labels[j] + ":\n " + (this.yLabelFormat(y)) + "\n</div>";
838
+ }
839
+ if (typeof this.options.hoverCallback === 'function') {
840
+ content = this.options.hoverCallback(index, this.options, content, row.src);
841
+ }
842
+ return [content, row._x, row._ymax];
843
+ };
844
+
845
+ Line.prototype.generatePaths = function() {
846
+ var c, coords, i, r, smooth;
847
+ return this.paths = (function() {
848
+ var _i, _ref, _ref1, _results;
849
+ _results = [];
850
+ for (i = _i = 0, _ref = this.options.ykeys.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
851
+ smooth = typeof this.options.smooth === "boolean" ? this.options.smooth : (_ref1 = this.options.ykeys[i], __indexOf.call(this.options.smooth, _ref1) >= 0);
852
+ coords = (function() {
853
+ var _j, _len, _ref2, _results1;
854
+ _ref2 = this.data;
855
+ _results1 = [];
856
+ for (_j = 0, _len = _ref2.length; _j < _len; _j++) {
857
+ r = _ref2[_j];
858
+ if (r._y[i] !== void 0) {
859
+ _results1.push({
860
+ x: r._x,
861
+ y: r._y[i]
862
+ });
863
+ }
864
+ }
865
+ return _results1;
866
+ }).call(this);
867
+ if (this.options.continuousLine) {
868
+ coords = (function() {
869
+ var _j, _len, _results1;
870
+ _results1 = [];
871
+ for (_j = 0, _len = coords.length; _j < _len; _j++) {
872
+ c = coords[_j];
873
+ if (c.y !== null) {
874
+ _results1.push(c);
875
+ }
876
+ }
877
+ return _results1;
878
+ })();
879
+ }
880
+ if (coords.length > 1) {
881
+ _results.push(Morris.Line.createPath(coords, smooth, this.bottom));
882
+ } else {
883
+ _results.push(null);
884
+ }
885
+ }
886
+ return _results;
887
+ }).call(this);
888
+ };
889
+
890
+ Line.prototype.draw = function() {
891
+ var _ref;
892
+ if ((_ref = this.options.axes) === true || _ref === 'both' || _ref === 'x') {
893
+ this.drawXAxis();
894
+ }
895
+ this.drawSeries();
896
+ if (this.options.hideHover === false) {
897
+ return this.displayHoverForRow(this.data.length - 1);
898
+ }
899
+ };
900
+
901
+ Line.prototype.drawXAxis = function() {
902
+ var drawLabel, l, labels, prevAngleMargin, prevLabelMargin, row, ypos, _i, _len, _results,
903
+ _this = this;
904
+ ypos = this.bottom + this.options.padding / 2;
905
+ prevLabelMargin = null;
906
+ prevAngleMargin = null;
907
+ drawLabel = function(labelText, xpos) {
908
+ var label, labelBox, margin, offset, textBox;
909
+ label = _this.drawXAxisLabel(_this.transX(xpos), ypos, labelText);
910
+ textBox = label.getBBox();
911
+ label.transform("r" + (-_this.options.xLabelAngle));
912
+ labelBox = label.getBBox();
913
+ label.transform("t0," + (labelBox.height / 2) + "...");
914
+ if (_this.options.xLabelAngle !== 0) {
915
+ offset = -0.5 * textBox.width * Math.cos(_this.options.xLabelAngle * Math.PI / 180.0);
916
+ label.transform("t" + offset + ",0...");
917
+ }
918
+ labelBox = label.getBBox();
919
+ if (((prevLabelMargin == null) || prevLabelMargin >= labelBox.x + labelBox.width || (prevAngleMargin != null) && prevAngleMargin >= labelBox.x) && labelBox.x >= 0 && (labelBox.x + labelBox.width) < _this.el.width()) {
920
+ if (_this.options.xLabelAngle !== 0) {
921
+ margin = 1.25 * _this.options.gridTextSize / Math.sin(_this.options.xLabelAngle * Math.PI / 180.0);
922
+ prevAngleMargin = labelBox.x - margin;
923
+ }
924
+ return prevLabelMargin = labelBox.x - _this.options.xLabelMargin;
925
+ } else {
926
+ return label.remove();
927
+ }
928
+ };
929
+ if (this.options.parseTime) {
930
+ if (this.data.length === 1 && this.options.xLabels === 'auto') {
931
+ labels = [[this.data[0].label, this.data[0].x]];
932
+ } else {
933
+ labels = Morris.labelSeries(this.xmin, this.xmax, this.width, this.options.xLabels, this.options.xLabelFormat);
934
+ }
935
+ } else {
936
+ labels = (function() {
937
+ var _i, _len, _ref, _results;
938
+ _ref = this.data;
939
+ _results = [];
940
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
941
+ row = _ref[_i];
942
+ _results.push([row.label, row.x]);
943
+ }
944
+ return _results;
945
+ }).call(this);
946
+ }
947
+ labels.reverse();
948
+ _results = [];
949
+ for (_i = 0, _len = labels.length; _i < _len; _i++) {
950
+ l = labels[_i];
951
+ _results.push(drawLabel(l[0], l[1]));
952
+ }
953
+ return _results;
954
+ };
955
+
956
+ Line.prototype.drawSeries = function() {
957
+ var i, _i, _j, _ref, _ref1, _results;
958
+ this.seriesPoints = [];
959
+ for (i = _i = _ref = this.options.ykeys.length - 1; _ref <= 0 ? _i <= 0 : _i >= 0; i = _ref <= 0 ? ++_i : --_i) {
960
+ this._drawLineFor(i);
961
+ }
962
+ _results = [];
963
+ for (i = _j = _ref1 = this.options.ykeys.length - 1; _ref1 <= 0 ? _j <= 0 : _j >= 0; i = _ref1 <= 0 ? ++_j : --_j) {
964
+ _results.push(this._drawPointFor(i));
965
+ }
966
+ return _results;
967
+ };
968
+
969
+ Line.prototype._drawPointFor = function(index) {
970
+ var circle, row, _i, _len, _ref, _results;
971
+ this.seriesPoints[index] = [];
972
+ _ref = this.data;
973
+ _results = [];
974
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
975
+ row = _ref[_i];
976
+ circle = null;
977
+ if (row._y[index] != null) {
978
+ circle = this.drawLinePoint(row._x, row._y[index], this.colorFor(row, index, 'point'), index);
979
+ }
980
+ _results.push(this.seriesPoints[index].push(circle));
981
+ }
982
+ return _results;
983
+ };
984
+
985
+ Line.prototype._drawLineFor = function(index) {
986
+ var path;
987
+ path = this.paths[index];
988
+ if (path !== null) {
989
+ return this.drawLinePath(path, this.colorFor(null, index, 'line'), index);
990
+ }
991
+ };
992
+
993
+ Line.createPath = function(coords, smooth, bottom) {
994
+ var coord, g, grads, i, ix, lg, path, prevCoord, x1, x2, y1, y2, _i, _len;
995
+ path = "";
996
+ if (smooth) {
997
+ grads = Morris.Line.gradients(coords);
998
+ }
999
+ prevCoord = {
1000
+ y: null
1001
+ };
1002
+ for (i = _i = 0, _len = coords.length; _i < _len; i = ++_i) {
1003
+ coord = coords[i];
1004
+ if (coord.y != null) {
1005
+ if (prevCoord.y != null) {
1006
+ if (smooth) {
1007
+ g = grads[i];
1008
+ lg = grads[i - 1];
1009
+ ix = (coord.x - prevCoord.x) / 4;
1010
+ x1 = prevCoord.x + ix;
1011
+ y1 = Math.min(bottom, prevCoord.y + ix * lg);
1012
+ x2 = coord.x - ix;
1013
+ y2 = Math.min(bottom, coord.y - ix * g);
1014
+ path += "C" + x1 + "," + y1 + "," + x2 + "," + y2 + "," + coord.x + "," + coord.y;
1015
+ } else {
1016
+ path += "L" + coord.x + "," + coord.y;
1017
+ }
1018
+ } else {
1019
+ if (!smooth || (grads[i] != null)) {
1020
+ path += "M" + coord.x + "," + coord.y;
1021
+ }
1022
+ }
1023
+ }
1024
+ prevCoord = coord;
1025
+ }
1026
+ return path;
1027
+ };
1028
+
1029
+ Line.gradients = function(coords) {
1030
+ var coord, grad, i, nextCoord, prevCoord, _i, _len, _results;
1031
+ grad = function(a, b) {
1032
+ return (a.y - b.y) / (a.x - b.x);
1033
+ };
1034
+ _results = [];
1035
+ for (i = _i = 0, _len = coords.length; _i < _len; i = ++_i) {
1036
+ coord = coords[i];
1037
+ if (coord.y != null) {
1038
+ nextCoord = coords[i + 1] || {
1039
+ y: null
1040
+ };
1041
+ prevCoord = coords[i - 1] || {
1042
+ y: null
1043
+ };
1044
+ if ((prevCoord.y != null) && (nextCoord.y != null)) {
1045
+ _results.push(grad(prevCoord, nextCoord));
1046
+ } else if (prevCoord.y != null) {
1047
+ _results.push(grad(prevCoord, coord));
1048
+ } else if (nextCoord.y != null) {
1049
+ _results.push(grad(coord, nextCoord));
1050
+ } else {
1051
+ _results.push(null);
1052
+ }
1053
+ } else {
1054
+ _results.push(null);
1055
+ }
1056
+ }
1057
+ return _results;
1058
+ };
1059
+
1060
+ Line.prototype.hilight = function(index) {
1061
+ var i, _i, _j, _ref, _ref1;
1062
+ if (this.prevHilight !== null && this.prevHilight !== index) {
1063
+ for (i = _i = 0, _ref = this.seriesPoints.length - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
1064
+ if (this.seriesPoints[i][this.prevHilight]) {
1065
+ this.seriesPoints[i][this.prevHilight].animate(this.pointShrinkSeries(i));
1066
+ }
1067
+ }
1068
+ }
1069
+ if (index !== null && this.prevHilight !== index) {
1070
+ for (i = _j = 0, _ref1 = this.seriesPoints.length - 1; 0 <= _ref1 ? _j <= _ref1 : _j >= _ref1; i = 0 <= _ref1 ? ++_j : --_j) {
1071
+ if (this.seriesPoints[i][index]) {
1072
+ this.seriesPoints[i][index].animate(this.pointGrowSeries(i));
1073
+ }
1074
+ }
1075
+ }
1076
+ return this.prevHilight = index;
1077
+ };
1078
+
1079
+ Line.prototype.colorFor = function(row, sidx, type) {
1080
+ if (typeof this.options.lineColors === 'function') {
1081
+ return this.options.lineColors.call(this, row, sidx, type);
1082
+ } else if (type === 'point') {
1083
+ return this.options.pointFillColors[sidx % this.options.pointFillColors.length] || this.options.lineColors[sidx % this.options.lineColors.length];
1084
+ } else {
1085
+ return this.options.lineColors[sidx % this.options.lineColors.length];
1086
+ }
1087
+ };
1088
+
1089
+ Line.prototype.drawXAxisLabel = function(xPos, yPos, text) {
1090
+ return this.raphael.text(xPos, yPos, text).attr('font-size', this.options.gridTextSize).attr('font-family', this.options.gridTextFamily).attr('font-weight', this.options.gridTextWeight).attr('fill', this.options.gridTextColor);
1091
+ };
1092
+
1093
+ Line.prototype.drawLinePath = function(path, lineColor, lineIndex) {
1094
+ return this.raphael.path(path).attr('stroke', lineColor).attr('stroke-width', this.lineWidthForSeries(lineIndex));
1095
+ };
1096
+
1097
+ Line.prototype.drawLinePoint = function(xPos, yPos, pointColor, lineIndex) {
1098
+ return this.raphael.circle(xPos, yPos, this.pointSizeForSeries(lineIndex)).attr('fill', pointColor).attr('stroke-width', this.pointStrokeWidthForSeries(lineIndex)).attr('stroke', this.pointStrokeColorForSeries(lineIndex));
1099
+ };
1100
+
1101
+ Line.prototype.pointStrokeWidthForSeries = function(index) {
1102
+ return this.options.pointStrokeWidths[index % this.options.pointStrokeWidths.length];
1103
+ };
1104
+
1105
+ Line.prototype.pointStrokeColorForSeries = function(index) {
1106
+ return this.options.pointStrokeColors[index % this.options.pointStrokeColors.length];
1107
+ };
1108
+
1109
+ Line.prototype.lineWidthForSeries = function(index) {
1110
+ if (this.options.lineWidth instanceof Array) {
1111
+ return this.options.lineWidth[index % this.options.lineWidth.length];
1112
+ } else {
1113
+ return this.options.lineWidth;
1114
+ }
1115
+ };
1116
+
1117
+ Line.prototype.pointSizeForSeries = function(index) {
1118
+ if (this.options.pointSize instanceof Array) {
1119
+ return this.options.pointSize[index % this.options.pointSize.length];
1120
+ } else {
1121
+ return this.options.pointSize;
1122
+ }
1123
+ };
1124
+
1125
+ Line.prototype.pointGrowSeries = function(index) {
1126
+ return Raphael.animation({
1127
+ r: this.pointSizeForSeries(index) + 3
1128
+ }, 25, 'linear');
1129
+ };
1130
+
1131
+ Line.prototype.pointShrinkSeries = function(index) {
1132
+ return Raphael.animation({
1133
+ r: this.pointSizeForSeries(index)
1134
+ }, 25, 'linear');
1135
+ };
1136
+
1137
+ return Line;
1138
+
1139
+ })(Morris.Grid);
1140
+
1141
+ Morris.labelSeries = function(dmin, dmax, pxwidth, specName, xLabelFormat) {
1142
+ var d, d0, ddensity, name, ret, s, spec, t, _i, _len, _ref;
1143
+ ddensity = 200 * (dmax - dmin) / pxwidth;
1144
+ d0 = new Date(dmin);
1145
+ spec = Morris.LABEL_SPECS[specName];
1146
+ if (spec === void 0) {
1147
+ _ref = Morris.AUTO_LABEL_ORDER;
1148
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1149
+ name = _ref[_i];
1150
+ s = Morris.LABEL_SPECS[name];
1151
+ if (ddensity >= s.span) {
1152
+ spec = s;
1153
+ break;
1154
+ }
1155
+ }
1156
+ }
1157
+ if (spec === void 0) {
1158
+ spec = Morris.LABEL_SPECS["second"];
1159
+ }
1160
+ if (xLabelFormat) {
1161
+ spec = $.extend({}, spec, {
1162
+ fmt: xLabelFormat
1163
+ });
1164
+ }
1165
+ d = spec.start(d0);
1166
+ ret = [];
1167
+ while ((t = d.getTime()) <= dmax) {
1168
+ if (t >= dmin) {
1169
+ ret.push([spec.fmt(d), t]);
1170
+ }
1171
+ spec.incr(d);
1172
+ }
1173
+ return ret;
1174
+ };
1175
+
1176
+ minutesSpecHelper = function(interval) {
1177
+ return {
1178
+ span: interval * 60 * 1000,
1179
+ start: function(d) {
1180
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours());
1181
+ },
1182
+ fmt: function(d) {
1183
+ return "" + (Morris.pad2(d.getHours())) + ":" + (Morris.pad2(d.getMinutes()));
1184
+ },
1185
+ incr: function(d) {
1186
+ return d.setUTCMinutes(d.getUTCMinutes() + interval);
1187
+ }
1188
+ };
1189
+ };
1190
+
1191
+ secondsSpecHelper = function(interval) {
1192
+ return {
1193
+ span: interval * 1000,
1194
+ start: function(d) {
1195
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes());
1196
+ },
1197
+ fmt: function(d) {
1198
+ return "" + (Morris.pad2(d.getHours())) + ":" + (Morris.pad2(d.getMinutes())) + ":" + (Morris.pad2(d.getSeconds()));
1199
+ },
1200
+ incr: function(d) {
1201
+ return d.setUTCSeconds(d.getUTCSeconds() + interval);
1202
+ }
1203
+ };
1204
+ };
1205
+
1206
+ Morris.LABEL_SPECS = {
1207
+ "decade": {
1208
+ span: 172800000000,
1209
+ start: function(d) {
1210
+ return new Date(d.getFullYear() - d.getFullYear() % 10, 0, 1);
1211
+ },
1212
+ fmt: function(d) {
1213
+ return "" + (d.getFullYear());
1214
+ },
1215
+ incr: function(d) {
1216
+ return d.setFullYear(d.getFullYear() + 10);
1217
+ }
1218
+ },
1219
+ "year": {
1220
+ span: 17280000000,
1221
+ start: function(d) {
1222
+ return new Date(d.getFullYear(), 0, 1);
1223
+ },
1224
+ fmt: function(d) {
1225
+ return "" + (d.getFullYear());
1226
+ },
1227
+ incr: function(d) {
1228
+ return d.setFullYear(d.getFullYear() + 1);
1229
+ }
1230
+ },
1231
+ "month": {
1232
+ span: 2419200000,
1233
+ start: function(d) {
1234
+ return new Date(d.getFullYear(), d.getMonth(), 1);
1235
+ },
1236
+ fmt: function(d) {
1237
+ return "" + (d.getFullYear()) + "-" + (Morris.pad2(d.getMonth() + 1));
1238
+ },
1239
+ incr: function(d) {
1240
+ return d.setMonth(d.getMonth() + 1);
1241
+ }
1242
+ },
1243
+ "week": {
1244
+ span: 604800000,
1245
+ start: function(d) {
1246
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate());
1247
+ },
1248
+ fmt: function(d) {
1249
+ return "" + (d.getFullYear()) + "-" + (Morris.pad2(d.getMonth() + 1)) + "-" + (Morris.pad2(d.getDate()));
1250
+ },
1251
+ incr: function(d) {
1252
+ return d.setDate(d.getDate() + 7);
1253
+ }
1254
+ },
1255
+ "day": {
1256
+ span: 86400000,
1257
+ start: function(d) {
1258
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate());
1259
+ },
1260
+ fmt: function(d) {
1261
+ return "" + (d.getFullYear()) + "-" + (Morris.pad2(d.getMonth() + 1)) + "-" + (Morris.pad2(d.getDate()));
1262
+ },
1263
+ incr: function(d) {
1264
+ return d.setDate(d.getDate() + 1);
1265
+ }
1266
+ },
1267
+ "hour": minutesSpecHelper(60),
1268
+ "30min": minutesSpecHelper(30),
1269
+ "15min": minutesSpecHelper(15),
1270
+ "10min": minutesSpecHelper(10),
1271
+ "5min": minutesSpecHelper(5),
1272
+ "minute": minutesSpecHelper(1),
1273
+ "30sec": secondsSpecHelper(30),
1274
+ "15sec": secondsSpecHelper(15),
1275
+ "10sec": secondsSpecHelper(10),
1276
+ "5sec": secondsSpecHelper(5),
1277
+ "second": secondsSpecHelper(1)
1278
+ };
1279
+
1280
+ Morris.AUTO_LABEL_ORDER = ["decade", "year", "month", "week", "day", "hour", "30min", "15min", "10min", "5min", "minute", "30sec", "15sec", "10sec", "5sec", "second"];
1281
+
1282
+ Morris.Area = (function(_super) {
1283
+ var areaDefaults;
1284
+
1285
+ __extends(Area, _super);
1286
+
1287
+ areaDefaults = {
1288
+ fillOpacity: 'auto',
1289
+ behaveLikeLine: false
1290
+ };
1291
+
1292
+ function Area(options) {
1293
+ var areaOptions;
1294
+ if (!(this instanceof Morris.Area)) {
1295
+ return new Morris.Area(options);
1296
+ }
1297
+ areaOptions = $.extend({}, areaDefaults, options);
1298
+ this.cumulative = !areaOptions.behaveLikeLine;
1299
+ if (areaOptions.fillOpacity === 'auto') {
1300
+ areaOptions.fillOpacity = areaOptions.behaveLikeLine ? .8 : 1;
1301
+ }
1302
+ Area.__super__.constructor.call(this, areaOptions);
1303
+ }
1304
+
1305
+ Area.prototype.calcPoints = function() {
1306
+ var row, total, y, _i, _len, _ref, _results;
1307
+ _ref = this.data;
1308
+ _results = [];
1309
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1310
+ row = _ref[_i];
1311
+ row._x = this.transX(row.x);
1312
+ total = 0;
1313
+ row._y = (function() {
1314
+ var _j, _len1, _ref1, _results1;
1315
+ _ref1 = row.y;
1316
+ _results1 = [];
1317
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
1318
+ y = _ref1[_j];
1319
+ if (this.options.behaveLikeLine) {
1320
+ _results1.push(this.transY(y));
1321
+ } else {
1322
+ total += y || 0;
1323
+ _results1.push(this.transY(total));
1324
+ }
1325
+ }
1326
+ return _results1;
1327
+ }).call(this);
1328
+ _results.push(row._ymax = Math.max.apply(Math, row._y));
1329
+ }
1330
+ return _results;
1331
+ };
1332
+
1333
+ Area.prototype.drawSeries = function() {
1334
+ var i, range, _i, _j, _k, _len, _ref, _ref1, _results, _results1, _results2;
1335
+ this.seriesPoints = [];
1336
+ if (this.options.behaveLikeLine) {
1337
+ range = (function() {
1338
+ _results = [];
1339
+ for (var _i = 0, _ref = this.options.ykeys.length - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; 0 <= _ref ? _i++ : _i--){ _results.push(_i); }
1340
+ return _results;
1341
+ }).apply(this);
1342
+ } else {
1343
+ range = (function() {
1344
+ _results1 = [];
1345
+ for (var _j = _ref1 = this.options.ykeys.length - 1; _ref1 <= 0 ? _j <= 0 : _j >= 0; _ref1 <= 0 ? _j++ : _j--){ _results1.push(_j); }
1346
+ return _results1;
1347
+ }).apply(this);
1348
+ }
1349
+ _results2 = [];
1350
+ for (_k = 0, _len = range.length; _k < _len; _k++) {
1351
+ i = range[_k];
1352
+ this._drawFillFor(i);
1353
+ this._drawLineFor(i);
1354
+ _results2.push(this._drawPointFor(i));
1355
+ }
1356
+ return _results2;
1357
+ };
1358
+
1359
+ Area.prototype._drawFillFor = function(index) {
1360
+ var path;
1361
+ path = this.paths[index];
1362
+ if (path !== null) {
1363
+ path = path + ("L" + (this.transX(this.xmax)) + "," + this.bottom + "L" + (this.transX(this.xmin)) + "," + this.bottom + "Z");
1364
+ return this.drawFilledPath(path, this.fillForSeries(index));
1365
+ }
1366
+ };
1367
+
1368
+ Area.prototype.fillForSeries = function(i) {
1369
+ var color;
1370
+ color = Raphael.rgb2hsl(this.colorFor(this.data[i], i, 'line'));
1371
+ return Raphael.hsl(color.h, this.options.behaveLikeLine ? color.s * 0.9 : color.s * 0.75, Math.min(0.98, this.options.behaveLikeLine ? color.l * 1.2 : color.l * 1.25));
1372
+ };
1373
+
1374
+ Area.prototype.drawFilledPath = function(path, fill) {
1375
+ return this.raphael.path(path).attr('fill', fill).attr('fill-opacity', this.options.fillOpacity).attr('stroke', 'none');
1376
+ };
1377
+
1378
+ return Area;
1379
+
1380
+ })(Morris.Line);
1381
+
1382
+ Morris.Bar = (function(_super) {
1383
+ __extends(Bar, _super);
1384
+
1385
+ function Bar(options) {
1386
+ this.onHoverOut = __bind(this.onHoverOut, this);
1387
+ this.onHoverMove = __bind(this.onHoverMove, this);
1388
+ this.onGridClick = __bind(this.onGridClick, this);
1389
+ if (!(this instanceof Morris.Bar)) {
1390
+ return new Morris.Bar(options);
1391
+ }
1392
+ Bar.__super__.constructor.call(this, $.extend({}, options, {
1393
+ parseTime: false
1394
+ }));
1395
+ }
1396
+
1397
+ Bar.prototype.init = function() {
1398
+ this.cumulative = this.options.stacked;
1399
+ if (this.options.hideHover !== 'always') {
1400
+ this.hover = new Morris.Hover({
1401
+ parent: this.el
1402
+ });
1403
+ this.on('hovermove', this.onHoverMove);
1404
+ this.on('hoverout', this.onHoverOut);
1405
+ return this.on('gridclick', this.onGridClick);
1406
+ }
1407
+ };
1408
+
1409
+ Bar.prototype.defaults = {
1410
+ barSizeRatio: 0.75,
1411
+ barGap: 3,
1412
+ barColors: ['#0b62a4', '#7a92a3', '#4da74d', '#afd8f8', '#edc240', '#cb4b4b', '#9440ed'],
1413
+ barOpacity: 1.0,
1414
+ barRadius: [0, 0, 0, 0],
1415
+ xLabelMargin: 50
1416
+ };
1417
+
1418
+ Bar.prototype.calc = function() {
1419
+ var _ref;
1420
+ this.calcBars();
1421
+ if (this.options.hideHover === false) {
1422
+ return (_ref = this.hover).update.apply(_ref, this.hoverContentForRow(this.data.length - 1));
1423
+ }
1424
+ };
1425
+
1426
+ Bar.prototype.calcBars = function() {
1427
+ var idx, row, y, _i, _len, _ref, _results;
1428
+ _ref = this.data;
1429
+ _results = [];
1430
+ for (idx = _i = 0, _len = _ref.length; _i < _len; idx = ++_i) {
1431
+ row = _ref[idx];
1432
+ row._x = this.left + this.width * (idx + 0.5) / this.data.length;
1433
+ _results.push(row._y = (function() {
1434
+ var _j, _len1, _ref1, _results1;
1435
+ _ref1 = row.y;
1436
+ _results1 = [];
1437
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
1438
+ y = _ref1[_j];
1439
+ if (y != null) {
1440
+ _results1.push(this.transY(y));
1441
+ } else {
1442
+ _results1.push(null);
1443
+ }
1444
+ }
1445
+ return _results1;
1446
+ }).call(this));
1447
+ }
1448
+ return _results;
1449
+ };
1450
+
1451
+ Bar.prototype.draw = function() {
1452
+ var _ref;
1453
+ if ((_ref = this.options.axes) === true || _ref === 'both' || _ref === 'x') {
1454
+ this.drawXAxis();
1455
+ }
1456
+ return this.drawSeries();
1457
+ };
1458
+
1459
+ Bar.prototype.drawXAxis = function() {
1460
+ var i, label, labelBox, margin, offset, prevAngleMargin, prevLabelMargin, row, textBox, ypos, _i, _ref, _results;
1461
+ ypos = this.bottom + (this.options.xAxisLabelTopPadding || this.options.padding / 2);
1462
+ prevLabelMargin = null;
1463
+ prevAngleMargin = null;
1464
+ _results = [];
1465
+ for (i = _i = 0, _ref = this.data.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
1466
+ row = this.data[this.data.length - 1 - i];
1467
+ label = this.drawXAxisLabel(row._x, ypos, row.label);
1468
+ textBox = label.getBBox();
1469
+ label.transform("r" + (-this.options.xLabelAngle));
1470
+ labelBox = label.getBBox();
1471
+ label.transform("t0," + (labelBox.height / 2) + "...");
1472
+ if (this.options.xLabelAngle !== 0) {
1473
+ offset = -0.5 * textBox.width * Math.cos(this.options.xLabelAngle * Math.PI / 180.0);
1474
+ label.transform("t" + offset + ",0...");
1475
+ }
1476
+ if (((prevLabelMargin == null) || prevLabelMargin >= labelBox.x + labelBox.width || (prevAngleMargin != null) && prevAngleMargin >= labelBox.x) && labelBox.x >= 0 && (labelBox.x + labelBox.width) < this.el.width()) {
1477
+ if (this.options.xLabelAngle !== 0) {
1478
+ margin = 1.25 * this.options.gridTextSize / Math.sin(this.options.xLabelAngle * Math.PI / 180.0);
1479
+ prevAngleMargin = labelBox.x - margin;
1480
+ }
1481
+ _results.push(prevLabelMargin = labelBox.x - this.options.xLabelMargin);
1482
+ } else {
1483
+ _results.push(label.remove());
1484
+ }
1485
+ }
1486
+ return _results;
1487
+ };
1488
+
1489
+ Bar.prototype.drawSeries = function() {
1490
+ var barWidth, bottom, groupWidth, idx, lastTop, left, leftPadding, numBars, row, sidx, size, top, ypos, zeroPos;
1491
+ groupWidth = this.width / this.options.data.length;
1492
+ numBars = this.options.stacked != null ? 1 : this.options.ykeys.length;
1493
+ barWidth = (groupWidth * this.options.barSizeRatio - this.options.barGap * (numBars - 1)) / numBars;
1494
+ leftPadding = groupWidth * (1 - this.options.barSizeRatio) / 2;
1495
+ zeroPos = this.ymin <= 0 && this.ymax >= 0 ? this.transY(0) : null;
1496
+ return this.bars = (function() {
1497
+ var _i, _len, _ref, _results;
1498
+ _ref = this.data;
1499
+ _results = [];
1500
+ for (idx = _i = 0, _len = _ref.length; _i < _len; idx = ++_i) {
1501
+ row = _ref[idx];
1502
+ lastTop = 0;
1503
+ _results.push((function() {
1504
+ var _j, _len1, _ref1, _results1;
1505
+ _ref1 = row._y;
1506
+ _results1 = [];
1507
+ for (sidx = _j = 0, _len1 = _ref1.length; _j < _len1; sidx = ++_j) {
1508
+ ypos = _ref1[sidx];
1509
+ if (ypos !== null) {
1510
+ if (zeroPos) {
1511
+ top = Math.min(ypos, zeroPos);
1512
+ bottom = Math.max(ypos, zeroPos);
1513
+ } else {
1514
+ top = ypos;
1515
+ bottom = this.bottom;
1516
+ }
1517
+ left = this.left + idx * groupWidth + leftPadding;
1518
+ if (!this.options.stacked) {
1519
+ left += sidx * (barWidth + this.options.barGap);
1520
+ }
1521
+ size = bottom - top;
1522
+ if (this.options.stacked) {
1523
+ top -= lastTop;
1524
+ }
1525
+ this.drawBar(left, top, barWidth, size, this.colorFor(row, sidx, 'bar'), this.options.barOpacity, this.options.barRadius);
1526
+ _results1.push(lastTop += size);
1527
+ } else {
1528
+ _results1.push(null);
1529
+ }
1530
+ }
1531
+ return _results1;
1532
+ }).call(this));
1533
+ }
1534
+ return _results;
1535
+ }).call(this);
1536
+ };
1537
+
1538
+ Bar.prototype.colorFor = function(row, sidx, type) {
1539
+ var r, s;
1540
+ if (typeof this.options.barColors === 'function') {
1541
+ r = {
1542
+ x: row.x,
1543
+ y: row.y[sidx],
1544
+ label: row.label
1545
+ };
1546
+ s = {
1547
+ index: sidx,
1548
+ key: this.options.ykeys[sidx],
1549
+ label: this.options.labels[sidx]
1550
+ };
1551
+ return this.options.barColors.call(this, r, s, type);
1552
+ } else {
1553
+ return this.options.barColors[sidx % this.options.barColors.length];
1554
+ }
1555
+ };
1556
+
1557
+ Bar.prototype.hitTest = function(x) {
1558
+ if (this.data.length === 0) {
1559
+ return null;
1560
+ }
1561
+ x = Math.max(Math.min(x, this.right), this.left);
1562
+ return Math.min(this.data.length - 1, Math.floor((x - this.left) / (this.width / this.data.length)));
1563
+ };
1564
+
1565
+ Bar.prototype.onGridClick = function(x, y) {
1566
+ var index;
1567
+ index = this.hitTest(x);
1568
+ return this.fire('click', index, this.data[index].src, x, y);
1569
+ };
1570
+
1571
+ Bar.prototype.onHoverMove = function(x, y) {
1572
+ var index, _ref;
1573
+ index = this.hitTest(x);
1574
+ return (_ref = this.hover).update.apply(_ref, this.hoverContentForRow(index));
1575
+ };
1576
+
1577
+ Bar.prototype.onHoverOut = function() {
1578
+ if (this.options.hideHover !== false) {
1579
+ return this.hover.hide();
1580
+ }
1581
+ };
1582
+
1583
+ Bar.prototype.hoverContentForRow = function(index) {
1584
+ var content, j, row, x, y, _i, _len, _ref;
1585
+ row = this.data[index];
1586
+ content = "<div class='morris-hover-row-label'>" + row.label + "</div>";
1587
+ _ref = row.y;
1588
+ for (j = _i = 0, _len = _ref.length; _i < _len; j = ++_i) {
1589
+ y = _ref[j];
1590
+ content += "<div class='morris-hover-point' style='color: " + (this.colorFor(row, j, 'label')) + "'>\n " + this.options.labels[j] + ":\n " + (this.yLabelFormat(y)) + "\n</div>";
1591
+ }
1592
+ if (typeof this.options.hoverCallback === 'function') {
1593
+ content = this.options.hoverCallback(index, this.options, content, row.src);
1594
+ }
1595
+ x = this.left + (index + 0.5) * this.width / this.data.length;
1596
+ return [content, x];
1597
+ };
1598
+
1599
+ Bar.prototype.drawXAxisLabel = function(xPos, yPos, text) {
1600
+ var label;
1601
+ return label = this.raphael.text(xPos, yPos, text).attr('font-size', this.options.gridTextSize).attr('font-family', this.options.gridTextFamily).attr('font-weight', this.options.gridTextWeight).attr('fill', this.options.gridTextColor);
1602
+ };
1603
+
1604
+ Bar.prototype.drawBar = function(xPos, yPos, width, height, barColor, opacity, radiusArray) {
1605
+ var maxRadius, path;
1606
+ maxRadius = Math.max.apply(Math, radiusArray);
1607
+ if (maxRadius === 0 || maxRadius > height) {
1608
+ path = this.raphael.rect(xPos, yPos, width, height);
1609
+ } else {
1610
+ path = this.raphael.path(this.roundedRect(xPos, yPos, width, height, radiusArray));
1611
+ }
1612
+ return path.attr('fill', barColor).attr('fill-opacity', opacity).attr('stroke', 'none');
1613
+ };
1614
+
1615
+ Bar.prototype.roundedRect = function(x, y, w, h, r) {
1616
+ if (r == null) {
1617
+ r = [0, 0, 0, 0];
1618
+ }
1619
+ return ["M", x, r[0] + y, "Q", x, y, x + r[0], y, "L", x + w - r[1], y, "Q", x + w, y, x + w, y + r[1], "L", x + w, y + h - r[2], "Q", x + w, y + h, x + w - r[2], y + h, "L", x + r[3], y + h, "Q", x, y + h, x, y + h - r[3], "Z"];
1620
+ };
1621
+
1622
+ return Bar;
1623
+
1624
+ })(Morris.Grid);
1625
+
1626
+ Morris.Donut = (function(_super) {
1627
+ __extends(Donut, _super);
1628
+
1629
+ Donut.prototype.defaults = {
1630
+ colors: ['#0B62A4', '#3980B5', '#679DC6', '#95BBD7', '#B0CCE1', '#095791', '#095085', '#083E67', '#052C48', '#042135'],
1631
+ backgroundColor: '#FFFFFF',
1632
+ labelColor: '#000000',
1633
+ formatter: Morris.commas,
1634
+ resize: false
1635
+ };
1636
+
1637
+ function Donut(options) {
1638
+ this.resizeHandler = __bind(this.resizeHandler, this);
1639
+ this.select = __bind(this.select, this);
1640
+ this.click = __bind(this.click, this);
1641
+ var _this = this;
1642
+ if (!(this instanceof Morris.Donut)) {
1643
+ return new Morris.Donut(options);
1644
+ }
1645
+ this.options = $.extend({}, this.defaults, options);
1646
+ if (typeof options.element === 'string') {
1647
+ this.el = $(document.getElementById(options.element));
1648
+ } else {
1649
+ this.el = $(options.element);
1650
+ }
1651
+ if (this.el === null || this.el.length === 0) {
1652
+ throw new Error("Graph placeholder not found.");
1653
+ }
1654
+ if (options.data === void 0 || options.data.length === 0) {
1655
+ return;
1656
+ }
1657
+ this.raphael = new Raphael(this.el[0]);
1658
+ if (this.options.resize) {
1659
+ $(window).bind('resize', function(evt) {
1660
+ if (_this.timeoutId != null) {
1661
+ window.clearTimeout(_this.timeoutId);
1662
+ }
1663
+ return _this.timeoutId = window.setTimeout(_this.resizeHandler, 100);
1664
+ });
1665
+ }
1666
+ this.setData(options.data);
1667
+ }
1668
+
1669
+ Donut.prototype.redraw = function() {
1670
+ var C, cx, cy, i, idx, last, max_value, min, next, seg, total, value, w, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _results;
1671
+ this.raphael.clear();
1672
+ cx = this.el.width() / 2;
1673
+ cy = this.el.height() / 2;
1674
+ w = (Math.min(cx, cy) - 10) / 3;
1675
+ total = 0;
1676
+ _ref = this.values;
1677
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1678
+ value = _ref[_i];
1679
+ total += value;
1680
+ }
1681
+ min = 5 / (2 * w);
1682
+ C = 1.9999 * Math.PI - min * this.data.length;
1683
+ last = 0;
1684
+ idx = 0;
1685
+ this.segments = [];
1686
+ _ref1 = this.values;
1687
+ for (i = _j = 0, _len1 = _ref1.length; _j < _len1; i = ++_j) {
1688
+ value = _ref1[i];
1689
+ next = last + min + C * (value / total);
1690
+ seg = new Morris.DonutSegment(cx, cy, w * 2, w, last, next, this.data[i].color || this.options.colors[idx % this.options.colors.length], this.options.backgroundColor, idx, this.raphael);
1691
+ seg.render();
1692
+ this.segments.push(seg);
1693
+ seg.on('hover', this.select);
1694
+ seg.on('click', this.click);
1695
+ last = next;
1696
+ idx += 1;
1697
+ }
1698
+ this.text1 = this.drawEmptyDonutLabel(cx, cy - 10, this.options.labelColor, 15, 800);
1699
+ this.text2 = this.drawEmptyDonutLabel(cx, cy + 10, this.options.labelColor, 14);
1700
+ max_value = Math.max.apply(Math, this.values);
1701
+ idx = 0;
1702
+ _ref2 = this.values;
1703
+ _results = [];
1704
+ for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
1705
+ value = _ref2[_k];
1706
+ if (value === max_value) {
1707
+ this.select(idx);
1708
+ break;
1709
+ }
1710
+ _results.push(idx += 1);
1711
+ }
1712
+ return _results;
1713
+ };
1714
+
1715
+ Donut.prototype.setData = function(data) {
1716
+ var row;
1717
+ this.data = data;
1718
+ this.values = (function() {
1719
+ var _i, _len, _ref, _results;
1720
+ _ref = this.data;
1721
+ _results = [];
1722
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1723
+ row = _ref[_i];
1724
+ _results.push(parseFloat(row.value));
1725
+ }
1726
+ return _results;
1727
+ }).call(this);
1728
+ return this.redraw();
1729
+ };
1730
+
1731
+ Donut.prototype.click = function(idx) {
1732
+ return this.fire('click', idx, this.data[idx]);
1733
+ };
1734
+
1735
+ Donut.prototype.select = function(idx) {
1736
+ var row, s, segment, _i, _len, _ref;
1737
+ _ref = this.segments;
1738
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1739
+ s = _ref[_i];
1740
+ s.deselect();
1741
+ }
1742
+ segment = this.segments[idx];
1743
+ segment.select();
1744
+ row = this.data[idx];
1745
+ return this.setLabels(row.label, this.options.formatter(row.value, row));
1746
+ };
1747
+
1748
+ Donut.prototype.setLabels = function(label1, label2) {
1749
+ var inner, maxHeightBottom, maxHeightTop, maxWidth, text1bbox, text1scale, text2bbox, text2scale;
1750
+ inner = (Math.min(this.el.width() / 2, this.el.height() / 2) - 10) * 2 / 3;
1751
+ maxWidth = 1.8 * inner;
1752
+ maxHeightTop = inner / 2;
1753
+ maxHeightBottom = inner / 3;
1754
+ this.text1.attr({
1755
+ text: label1,
1756
+ transform: ''
1757
+ });
1758
+ text1bbox = this.text1.getBBox();
1759
+ text1scale = Math.min(maxWidth / text1bbox.width, maxHeightTop / text1bbox.height);
1760
+ this.text1.attr({
1761
+ transform: "S" + text1scale + "," + text1scale + "," + (text1bbox.x + text1bbox.width / 2) + "," + (text1bbox.y + text1bbox.height)
1762
+ });
1763
+ this.text2.attr({
1764
+ text: label2,
1765
+ transform: ''
1766
+ });
1767
+ text2bbox = this.text2.getBBox();
1768
+ text2scale = Math.min(maxWidth / text2bbox.width, maxHeightBottom / text2bbox.height);
1769
+ return this.text2.attr({
1770
+ transform: "S" + text2scale + "," + text2scale + "," + (text2bbox.x + text2bbox.width / 2) + "," + text2bbox.y
1771
+ });
1772
+ };
1773
+
1774
+ Donut.prototype.drawEmptyDonutLabel = function(xPos, yPos, color, fontSize, fontWeight) {
1775
+ var text;
1776
+ text = this.raphael.text(xPos, yPos, '').attr('font-size', fontSize).attr('fill', color);
1777
+ if (fontWeight != null) {
1778
+ text.attr('font-weight', fontWeight);
1779
+ }
1780
+ return text;
1781
+ };
1782
+
1783
+ Donut.prototype.resizeHandler = function() {
1784
+ this.timeoutId = null;
1785
+ this.raphael.setSize(this.el.width(), this.el.height());
1786
+ return this.redraw();
1787
+ };
1788
+
1789
+ return Donut;
1790
+
1791
+ })(Morris.EventEmitter);
1792
+
1793
+ Morris.DonutSegment = (function(_super) {
1794
+ __extends(DonutSegment, _super);
1795
+
1796
+ function DonutSegment(cx, cy, inner, outer, p0, p1, color, backgroundColor, index, raphael) {
1797
+ this.cx = cx;
1798
+ this.cy = cy;
1799
+ this.inner = inner;
1800
+ this.outer = outer;
1801
+ this.color = color;
1802
+ this.backgroundColor = backgroundColor;
1803
+ this.index = index;
1804
+ this.raphael = raphael;
1805
+ this.deselect = __bind(this.deselect, this);
1806
+ this.select = __bind(this.select, this);
1807
+ this.sin_p0 = Math.sin(p0);
1808
+ this.cos_p0 = Math.cos(p0);
1809
+ this.sin_p1 = Math.sin(p1);
1810
+ this.cos_p1 = Math.cos(p1);
1811
+ this.is_long = (p1 - p0) > Math.PI ? 1 : 0;
1812
+ this.path = this.calcSegment(this.inner + 3, this.inner + this.outer - 5);
1813
+ this.selectedPath = this.calcSegment(this.inner + 3, this.inner + this.outer);
1814
+ this.hilight = this.calcArc(this.inner);
1815
+ }
1816
+
1817
+ DonutSegment.prototype.calcArcPoints = function(r) {
1818
+ return [this.cx + r * this.sin_p0, this.cy + r * this.cos_p0, this.cx + r * this.sin_p1, this.cy + r * this.cos_p1];
1819
+ };
1820
+
1821
+ DonutSegment.prototype.calcSegment = function(r1, r2) {
1822
+ var ix0, ix1, iy0, iy1, ox0, ox1, oy0, oy1, _ref, _ref1;
1823
+ _ref = this.calcArcPoints(r1), ix0 = _ref[0], iy0 = _ref[1], ix1 = _ref[2], iy1 = _ref[3];
1824
+ _ref1 = this.calcArcPoints(r2), ox0 = _ref1[0], oy0 = _ref1[1], ox1 = _ref1[2], oy1 = _ref1[3];
1825
+ return ("M" + ix0 + "," + iy0) + ("A" + r1 + "," + r1 + ",0," + this.is_long + ",0," + ix1 + "," + iy1) + ("L" + ox1 + "," + oy1) + ("A" + r2 + "," + r2 + ",0," + this.is_long + ",1," + ox0 + "," + oy0) + "Z";
1826
+ };
1827
+
1828
+ DonutSegment.prototype.calcArc = function(r) {
1829
+ var ix0, ix1, iy0, iy1, _ref;
1830
+ _ref = this.calcArcPoints(r), ix0 = _ref[0], iy0 = _ref[1], ix1 = _ref[2], iy1 = _ref[3];
1831
+ return ("M" + ix0 + "," + iy0) + ("A" + r + "," + r + ",0," + this.is_long + ",0," + ix1 + "," + iy1);
1832
+ };
1833
+
1834
+ DonutSegment.prototype.render = function() {
1835
+ var _this = this;
1836
+ this.arc = this.drawDonutArc(this.hilight, this.color);
1837
+ return this.seg = this.drawDonutSegment(this.path, this.color, this.backgroundColor, function() {
1838
+ return _this.fire('hover', _this.index);
1839
+ }, function() {
1840
+ return _this.fire('click', _this.index);
1841
+ });
1842
+ };
1843
+
1844
+ DonutSegment.prototype.drawDonutArc = function(path, color) {
1845
+ return this.raphael.path(path).attr({
1846
+ stroke: color,
1847
+ 'stroke-width': 2,
1848
+ opacity: 0
1849
+ });
1850
+ };
1851
+
1852
+ DonutSegment.prototype.drawDonutSegment = function(path, fillColor, strokeColor, hoverFunction, clickFunction) {
1853
+ return this.raphael.path(path).attr({
1854
+ fill: fillColor,
1855
+ stroke: strokeColor,
1856
+ 'stroke-width': 3
1857
+ }).hover(hoverFunction).click(clickFunction);
1858
+ };
1859
+
1860
+ DonutSegment.prototype.select = function() {
1861
+ if (!this.selected) {
1862
+ this.seg.animate({
1863
+ path: this.selectedPath
1864
+ }, 150, '<>');
1865
+ this.arc.animate({
1866
+ opacity: 1
1867
+ }, 150, '<>');
1868
+ return this.selected = true;
1869
+ }
1870
+ };
1871
+
1872
+ DonutSegment.prototype.deselect = function() {
1873
+ if (this.selected) {
1874
+ this.seg.animate({
1875
+ path: this.path
1876
+ }, 150, '<>');
1877
+ this.arc.animate({
1878
+ opacity: 0
1879
+ }, 150, '<>');
1880
+ return this.selected = false;
1881
+ }
1882
+ };
1883
+
1884
+ return DonutSegment;
1885
+
1886
+ })(Morris.EventEmitter);
1887
+
1888
+ }).call(this);