solidus_backend 2.4.2 → 2.5.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_backend might be problematic. Click here for more details.

Files changed (505) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +7 -7
  3. data/Rakefile +19 -13
  4. data/app/assets/javascripts/spree/backend.js +5 -17
  5. data/app/assets/javascripts/spree/backend/adjustments.js +26 -0
  6. data/app/assets/javascripts/spree/backend/admin.js +14 -78
  7. data/app/assets/javascripts/spree/backend/backbone-overrides.js +25 -0
  8. data/app/assets/javascripts/spree/backend/calculator.js +1 -1
  9. data/app/assets/javascripts/spree/backend/checkouts/edit.js +1 -1
  10. data/app/assets/javascripts/spree/backend/collections/index.js +1 -0
  11. data/app/assets/javascripts/spree/backend/collections/shipments.js +6 -0
  12. data/app/assets/javascripts/spree/backend/components/editable_table.js +5 -0
  13. data/app/assets/javascripts/spree/backend/components/number_with_currency.js +1 -1
  14. data/app/assets/javascripts/spree/backend/components/sortable_table.js +29 -0
  15. data/app/assets/javascripts/spree/backend/components/tabs.js +67 -0
  16. data/app/assets/javascripts/spree/backend/components/tooltips.js +19 -24
  17. data/app/assets/javascripts/spree/backend/datepicker.js +55 -0
  18. data/app/assets/javascripts/spree/backend/flash.js +20 -0
  19. data/app/assets/javascripts/spree/backend/gateway.js +22 -0
  20. data/app/assets/javascripts/spree/backend/handlebars_extensions.js +8 -0
  21. data/app/assets/javascripts/spree/backend/images/index.js +8 -0
  22. data/app/assets/javascripts/spree/backend/models/index.js +3 -0
  23. data/app/assets/javascripts/spree/backend/models/line_item.js +4 -0
  24. data/app/assets/javascripts/spree/backend/models/order.js +2 -1
  25. data/app/assets/javascripts/spree/backend/models/payment.js +5 -0
  26. data/app/assets/javascripts/spree/backend/models/shipment.js +27 -0
  27. data/app/assets/javascripts/spree/backend/models/stock_item.js +6 -0
  28. data/app/assets/javascripts/spree/backend/namespaces.js +5 -1
  29. data/app/assets/javascripts/spree/backend/navigation.js +14 -0
  30. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +1 -1
  31. data/app/assets/javascripts/spree/backend/option_value_picker.js +1 -0
  32. data/app/assets/javascripts/spree/backend/orders/cart.js +1 -1
  33. data/app/assets/javascripts/spree/backend/orders/edit.js +2 -2
  34. data/app/assets/javascripts/spree/backend/payments/edit.js +16 -0
  35. data/app/assets/javascripts/spree/backend/payments/new.js +1 -1
  36. data/app/assets/javascripts/spree/backend/product_picker.js +1 -1
  37. data/app/assets/javascripts/spree/backend/progress.js +9 -0
  38. data/app/assets/javascripts/spree/backend/promotions.js +35 -0
  39. data/app/assets/javascripts/spree/backend/promotions/activation.js +1 -1
  40. data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +1 -1
  41. data/app/assets/javascripts/spree/backend/routes.js +0 -12
  42. data/app/assets/javascripts/spree/backend/shipments.js +35 -68
  43. data/app/assets/javascripts/spree/backend/stock_location.js +23 -0
  44. data/app/assets/javascripts/spree/backend/stock_management.js +22 -0
  45. data/app/assets/javascripts/spree/backend/store_credits.js +25 -0
  46. data/app/assets/javascripts/spree/backend/style_guide.js +3 -0
  47. data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +1 -1
  48. data/app/assets/javascripts/spree/backend/taxonomy.js +121 -0
  49. data/app/assets/javascripts/spree/backend/taxons.js +75 -0
  50. data/app/assets/javascripts/spree/backend/templates/index.js +2 -2
  51. data/app/assets/javascripts/spree/backend/templates/orders/line_item.hbs +7 -5
  52. data/app/assets/javascripts/spree/backend/templates/orders/shipment_tracking.hbs +24 -0
  53. data/app/assets/javascripts/spree/backend/templates/orders/shipping_method.hbs +34 -0
  54. data/app/assets/javascripts/spree/backend/templates/promotions/calculators/fields/tiered_flat_rate.hbs +7 -3
  55. data/app/assets/javascripts/spree/backend/templates/promotions/calculators/fields/tiered_percent.hbs +6 -2
  56. data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +3 -1
  57. data/app/assets/javascripts/spree/backend/templates/variants/autocomplete_stock.hbs +10 -5
  58. data/app/assets/javascripts/spree/backend/templates/variants/split.hbs +5 -3
  59. data/app/assets/javascripts/spree/backend/translation.js +11 -0
  60. data/app/assets/javascripts/spree/backend/turbolinks-integration.js +21 -0
  61. data/app/assets/javascripts/spree/backend/user_picker.js +1 -1
  62. data/app/assets/javascripts/spree/backend/variant_autocomplete.js +60 -0
  63. data/app/assets/javascripts/spree/backend/views/calculators/tiered.js +54 -0
  64. data/app/assets/javascripts/spree/backend/views/cart/line_item_row.js +2 -1
  65. data/app/assets/javascripts/spree/backend/views/index.js +7 -0
  66. data/app/assets/javascripts/spree/backend/views/order/shipment_tracking.js +46 -0
  67. data/app/assets/javascripts/spree/backend/views/order/shipping_method.js +57 -0
  68. data/app/assets/javascripts/spree/backend/views/payment/payment_row.js +36 -0
  69. data/app/assets/javascripts/spree/backend/views/promotions/option_values_rule.js +79 -0
  70. data/app/assets/javascripts/spree/backend/views/state_select.js +6 -6
  71. data/app/assets/javascripts/spree/backend/views/stock/add_stock_item.js +63 -0
  72. data/app/assets/javascripts/spree/backend/views/stock/edit_stock_item_row.js +68 -0
  73. data/app/assets/javascripts/spree/backend/views/tables/editable_table.js +15 -0
  74. data/app/assets/javascripts/spree/backend/views/tables/editable_table_row.js +61 -0
  75. data/app/assets/javascripts/spree/backend/zone.js +1 -1
  76. data/app/assets/stylesheets/spree/backend.css +1 -2
  77. data/app/assets/stylesheets/spree/backend/components/_messages.scss +4 -1
  78. data/app/assets/stylesheets/spree/backend/components/_navigation.scss +4 -2
  79. data/app/assets/stylesheets/spree/backend/components/_number_with_currency.scss +8 -2
  80. data/app/assets/stylesheets/spree/backend/components/_progress.scss +4 -0
  81. data/app/assets/stylesheets/spree/backend/components/_tabs.scss +4 -2
  82. data/app/assets/stylesheets/spree/backend/globals/mixins/_line_through.scss +2 -1
  83. data/app/assets/stylesheets/spree/backend/plugins/_select2.scss +32 -7
  84. data/app/assets/stylesheets/spree/backend/plugins/_sortable.scss +3 -0
  85. data/app/assets/stylesheets/spree/backend/sections/_orders.scss +4 -20
  86. data/app/assets/stylesheets/spree/backend/sections/_products.scss +0 -1
  87. data/app/assets/stylesheets/spree/backend/sections/_promotions.scss +15 -7
  88. data/app/assets/stylesheets/spree/backend/sections/_store_credits.scss +17 -6
  89. data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +8 -4
  90. data/app/assets/stylesheets/spree/backend/sections/_taxonomies.scss +5 -19
  91. data/app/assets/stylesheets/spree/backend/sections/_variants.scss +5 -0
  92. data/app/assets/stylesheets/spree/backend/shared/_forms.scss +13 -17
  93. data/app/assets/stylesheets/spree/backend/shared/_layout.scss +9 -3
  94. data/app/assets/stylesheets/spree/backend/shared/_tables.scss +3 -27
  95. data/app/assets/stylesheets/spree/backend/spree_admin.scss +2 -6
  96. data/app/controllers/spree/admin/base_controller.rb +2 -3
  97. data/app/controllers/spree/admin/cancellations_controller.rb +3 -3
  98. data/app/controllers/spree/admin/images_controller.rb +1 -1
  99. data/app/controllers/spree/admin/option_types_controller.rb +1 -2
  100. data/app/controllers/spree/admin/orders/customer_details_controller.rb +2 -2
  101. data/app/controllers/spree/admin/orders_controller.rb +11 -11
  102. data/app/controllers/spree/admin/payment_methods_controller.rb +5 -6
  103. data/app/controllers/spree/admin/payments_controller.rb +5 -5
  104. data/app/controllers/spree/admin/products_controller.rb +4 -6
  105. data/app/controllers/spree/admin/promotion_actions_controller.rb +4 -4
  106. data/app/controllers/spree/admin/promotion_rules_controller.rb +3 -3
  107. data/app/controllers/spree/admin/promotions_controller.rb +5 -1
  108. data/app/controllers/spree/admin/reports_controller.rb +2 -2
  109. data/app/controllers/spree/admin/resource_controller.rb +17 -5
  110. data/app/controllers/spree/admin/return_authorizations_controller.rb +2 -2
  111. data/app/controllers/spree/admin/shipping_methods_controller.rb +1 -1
  112. data/app/controllers/spree/admin/stock_locations_controller.rb +1 -1
  113. data/app/controllers/spree/admin/store_credits_controller.rb +4 -4
  114. data/app/controllers/spree/admin/taxons_controller.rb +1 -1
  115. data/app/controllers/spree/admin/users_controller.rb +6 -6
  116. data/app/controllers/spree/admin/variants_controller.rb +0 -16
  117. data/app/helpers/spree/admin/adjustments_helper.rb +2 -2
  118. data/app/helpers/spree/admin/base_helper.rb +5 -11
  119. data/app/helpers/spree/admin/navigation_helper.rb +8 -8
  120. data/app/helpers/spree/admin/orders_helper.rb +2 -2
  121. data/app/helpers/spree/admin/products_helper.rb +0 -24
  122. data/app/helpers/spree/admin/store_credit_events_helper.rb +5 -5
  123. data/app/models/spree/backend_configuration.rb +1 -2
  124. data/app/views/spree/admin/adjustment_reasons/edit.html.erb +2 -2
  125. data/app/views/spree/admin/adjustment_reasons/index.html.erb +5 -5
  126. data/app/views/spree/admin/adjustment_reasons/new.html.erb +3 -3
  127. data/app/views/spree/admin/adjustments/_adjustments_table.html.erb +2 -2
  128. data/app/views/spree/admin/adjustments/_form.html.erb +1 -1
  129. data/app/views/spree/admin/adjustments/edit.html.erb +3 -3
  130. data/app/views/spree/admin/adjustments/index.html.erb +3 -3
  131. data/app/views/spree/admin/adjustments/new.html.erb +3 -3
  132. data/app/views/spree/admin/cancellations/index.html.erb +3 -3
  133. data/app/views/spree/admin/customer_returns/_reimbursements_table.html.erb +2 -2
  134. data/app/views/spree/admin/customer_returns/_return_item_decision.html.erb +7 -7
  135. data/app/views/spree/admin/customer_returns/_return_item_selection.html.erb +2 -2
  136. data/app/views/spree/admin/customer_returns/edit.html.erb +7 -7
  137. data/app/views/spree/admin/customer_returns/index.html.erb +4 -4
  138. data/app/views/spree/admin/customer_returns/new.html.erb +11 -11
  139. data/app/views/spree/admin/images/_image_row.html.erb +3 -3
  140. data/app/views/spree/admin/images/_new.html.erb +12 -0
  141. data/app/views/spree/admin/images/edit.html.erb +4 -4
  142. data/app/views/spree/admin/images/index.html.erb +7 -5
  143. data/app/views/spree/admin/images/new.html.erb +1 -12
  144. data/app/views/spree/admin/log_entries/index.html.erb +2 -2
  145. data/app/views/spree/admin/option_types/_option_value_fields.html.erb +1 -1
  146. data/app/views/spree/admin/option_types/edit.html.erb +1 -1
  147. data/app/views/spree/admin/option_types/index.html.erb +2 -2
  148. data/app/views/spree/admin/option_types/new.html.erb +1 -1
  149. data/app/views/spree/admin/orders/_add_product.html.erb +2 -2
  150. data/app/views/spree/admin/orders/_carton.html.erb +8 -8
  151. data/app/views/spree/admin/orders/_carton_manifest.html.erb +1 -1
  152. data/app/views/spree/admin/orders/_order_details.html.erb +4 -4
  153. data/app/views/spree/admin/orders/_risk_analysis.html.erb +10 -10
  154. data/app/views/spree/admin/orders/_shipment.html.erb +11 -69
  155. data/app/views/spree/admin/orders/_shipment_manifest.html.erb +3 -3
  156. data/app/views/spree/admin/orders/cart.html.erb +2 -2
  157. data/app/views/spree/admin/orders/confirm.html.erb +6 -6
  158. data/app/views/spree/admin/orders/confirm/_customer_details.html.erb +3 -3
  159. data/app/views/spree/admin/orders/confirm/_payments.html.erb +1 -1
  160. data/app/views/spree/admin/orders/confirm/_shipment.html.erb +2 -2
  161. data/app/views/spree/admin/orders/confirm/_shipment_manifest.html.erb +1 -1
  162. data/app/views/spree/admin/orders/confirm_advance.html.erb +3 -3
  163. data/app/views/spree/admin/orders/customer_details/_form.html.erb +19 -13
  164. data/app/views/spree/admin/orders/customer_details/edit.html.erb +2 -2
  165. data/app/views/spree/admin/orders/customer_details/show.html.erb +7 -7
  166. data/app/views/spree/admin/orders/edit.html.erb +2 -2
  167. data/app/views/spree/admin/orders/index.html.erb +30 -28
  168. data/app/views/spree/admin/payment_methods/_form.html.erb +24 -13
  169. data/app/views/spree/admin/payment_methods/edit.html.erb +2 -2
  170. data/app/views/spree/admin/payment_methods/index.html.erb +6 -6
  171. data/app/views/spree/admin/payment_methods/new.html.erb +3 -3
  172. data/app/views/spree/admin/payments/_capture_events.html.erb +2 -2
  173. data/app/views/spree/admin/payments/_list.html.erb +33 -13
  174. data/app/views/spree/admin/payments/credit.html.erb +1 -1
  175. data/app/views/spree/admin/payments/index.html.erb +3 -3
  176. data/app/views/spree/admin/payments/new.html.erb +4 -4
  177. data/app/views/spree/admin/payments/show.html.erb +2 -2
  178. data/app/views/spree/admin/payments/source_forms/_gateway.html.erb +22 -23
  179. data/app/views/spree/admin/payments/source_views/_gateway.html.erb +1 -1
  180. data/app/views/spree/admin/payments/source_views/_storecredit.html.erb +1 -1
  181. data/app/views/spree/admin/prices/_form.html.erb +1 -2
  182. data/app/views/spree/admin/prices/edit.html.erb +1 -1
  183. data/app/views/spree/admin/prices/index.html.erb +2 -2
  184. data/app/views/spree/admin/prices/new.html.erb +1 -1
  185. data/app/views/spree/admin/product_properties/_product_property_fields.html.erb +1 -1
  186. data/app/views/spree/admin/product_properties/index.html.erb +7 -14
  187. data/app/views/spree/admin/products/_form.html.erb +17 -14
  188. data/app/views/spree/admin/products/edit.html.erb +2 -2
  189. data/app/views/spree/admin/products/index.html.erb +6 -6
  190. data/app/views/spree/admin/products/new.html.erb +5 -59
  191. data/app/views/spree/admin/promotion_categories/index.html.erb +1 -1
  192. data/app/views/spree/admin/promotion_categories/new.html.erb +1 -1
  193. data/app/views/spree/admin/promotion_code_batches/index.html.erb +8 -8
  194. data/app/views/spree/admin/promotion_code_batches/new.html.erb +1 -1
  195. data/app/views/spree/admin/promotion_codes/index.html.erb +1 -1
  196. data/app/views/spree/admin/promotions/_actions.html.erb +6 -6
  197. data/app/views/spree/admin/promotions/_form.html.erb +13 -4
  198. data/app/views/spree/admin/promotions/_promotion_rule.html.erb +1 -1
  199. data/app/views/spree/admin/promotions/_rules.html.erb +8 -8
  200. data/app/views/spree/admin/promotions/actions/_create_quantity_adjustments.html.erb +4 -10
  201. data/app/views/spree/admin/promotions/actions/_promotion_calculators_with_custom_fields.html.erb +25 -29
  202. data/app/views/spree/admin/promotions/calculators/_default_fields.html.erb +5 -4
  203. data/app/views/spree/admin/promotions/calculators/distributed_amount/_fields.html.erb +6 -4
  204. data/app/views/spree/admin/promotions/calculators/flat_rate/_fields.html.erb +6 -4
  205. data/app/views/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb +5 -5
  206. data/app/views/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb +5 -5
  207. data/app/views/spree/admin/promotions/edit.html.erb +1 -1
  208. data/app/views/spree/admin/promotions/index.html.erb +7 -7
  209. data/app/views/spree/admin/promotions/new.html.erb +1 -1
  210. data/app/views/spree/admin/promotions/rules/_item_total.html.erb +10 -12
  211. data/app/views/spree/admin/promotions/rules/_nth_order.html.erb +8 -10
  212. data/app/views/spree/admin/promotions/rules/_option_value.html.erb +10 -14
  213. data/app/views/spree/admin/promotions/rules/_product.html.erb +12 -10
  214. data/app/views/spree/admin/promotions/rules/_taxon.html.erb +9 -15
  215. data/app/views/spree/admin/promotions/rules/_user.html.erb +3 -5
  216. data/app/views/spree/admin/promotions/rules/_user_role.html.erb +3 -3
  217. data/app/views/spree/admin/properties/index.html.erb +5 -5
  218. data/app/views/spree/admin/properties/new.html.erb +1 -1
  219. data/app/views/spree/admin/refund_reasons/edit.html.erb +2 -2
  220. data/app/views/spree/admin/refund_reasons/index.html.erb +5 -5
  221. data/app/views/spree/admin/refund_reasons/new.html.erb +3 -3
  222. data/app/views/spree/admin/refund_reasons/shared/_form.html.erb +1 -1
  223. data/app/views/spree/admin/refunds/edit.html.erb +3 -3
  224. data/app/views/spree/admin/refunds/new.html.erb +4 -4
  225. data/app/views/spree/admin/reimbursement_types/index.html.erb +2 -2
  226. data/app/views/spree/admin/reimbursements/edit.html.erb +9 -9
  227. data/app/views/spree/admin/reimbursements/index.html.erb +4 -4
  228. data/app/views/spree/admin/reimbursements/show.html.erb +4 -4
  229. data/app/views/spree/admin/reports/index.html.erb +3 -3
  230. data/app/views/spree/admin/reports/sales_total.html.erb +7 -7
  231. data/app/views/spree/admin/return_authorizations/_form.html.erb +3 -3
  232. data/app/views/spree/admin/return_authorizations/edit.html.erb +5 -5
  233. data/app/views/spree/admin/return_authorizations/index.html.erb +4 -4
  234. data/app/views/spree/admin/return_authorizations/new.html.erb +3 -3
  235. data/app/views/spree/admin/return_reasons/edit.html.erb +2 -2
  236. data/app/views/spree/admin/return_reasons/index.html.erb +3 -3
  237. data/app/views/spree/admin/return_reasons/new.html.erb +3 -3
  238. data/app/views/spree/admin/shared/_address_form.html.erb +2 -0
  239. data/app/views/spree/admin/shared/_calculator_fields.html.erb +4 -3
  240. data/app/views/spree/admin/shared/_edit_resource_links.html.erb +2 -2
  241. data/app/views/spree/admin/shared/_head.html.erb +13 -5
  242. data/app/views/spree/admin/shared/_js_locale_data.html.erb +24 -32
  243. data/app/views/spree/admin/shared/_navigation_footer.html.erb +32 -2
  244. data/app/views/spree/admin/shared/_new_resource_links.html.erb +2 -2
  245. data/app/views/spree/admin/shared/_no_objects_found.html.erb +2 -2
  246. data/app/views/spree/admin/shared/_number_with_currency.html.erb +9 -5
  247. data/app/views/spree/admin/shared/_order_submenu.html.erb +6 -6
  248. data/app/views/spree/admin/shared/_order_summary.html.erb +5 -5
  249. data/app/views/spree/admin/shared/_order_tabs.html.erb +1 -1
  250. data/app/views/spree/admin/shared/_product_tabs.html.erb +3 -3
  251. data/app/views/spree/admin/shared/_rebuild_vat_prices_checkbox.html.erb +2 -2
  252. data/app/views/spree/admin/shared/_refunds.html.erb +2 -2
  253. data/app/views/spree/admin/shared/_report_order_criteria.html.erb +8 -6
  254. data/app/views/spree/admin/shared/_spinner.html.erb +1 -1
  255. data/app/views/spree/admin/shared/_variant_search.html.erb +3 -3
  256. data/app/views/spree/admin/shared/named_types/_form.html.erb +4 -2
  257. data/app/views/spree/admin/shared/named_types/_index.html.erb +4 -4
  258. data/app/views/spree/admin/shared/preference_fields/_boolean.html.erb +9 -8
  259. data/app/views/spree/admin/shipping_categories/edit.html.erb +3 -3
  260. data/app/views/spree/admin/shipping_categories/index.html.erb +5 -5
  261. data/app/views/spree/admin/shipping_categories/new.html.erb +3 -3
  262. data/app/views/spree/admin/shipping_methods/_form.html.erb +10 -8
  263. data/app/views/spree/admin/shipping_methods/edit.html.erb +2 -2
  264. data/app/views/spree/admin/shipping_methods/index.html.erb +5 -5
  265. data/app/views/spree/admin/shipping_methods/new.html.erb +3 -3
  266. data/app/views/spree/admin/stock_items/_stock_management.html.erb +7 -7
  267. data/app/views/spree/admin/stock_items/index.html.erb +4 -4
  268. data/app/views/spree/admin/stock_locations/_form.html.erb +105 -103
  269. data/app/views/spree/admin/stock_locations/edit.html.erb +4 -6
  270. data/app/views/spree/admin/stock_locations/index.html.erb +5 -11
  271. data/app/views/spree/admin/stock_locations/new.html.erb +5 -7
  272. data/app/views/spree/admin/stock_movements/index.html.erb +3 -3
  273. data/app/views/spree/admin/store_credits/_form.html.erb +3 -3
  274. data/app/views/spree/admin/store_credits/_update_reason_field.html.erb +7 -8
  275. data/app/views/spree/admin/store_credits/edit_amount.html.erb +10 -6
  276. data/app/views/spree/admin/store_credits/edit_validity.html.erb +7 -5
  277. data/app/views/spree/admin/store_credits/index.html.erb +13 -13
  278. data/app/views/spree/admin/store_credits/new.html.erb +2 -2
  279. data/app/views/spree/admin/store_credits/show.html.erb +24 -32
  280. data/app/views/spree/admin/stores/_form.html.erb +1 -1
  281. data/app/views/spree/admin/stores/edit.html.erb +1 -1
  282. data/app/views/spree/admin/stores/index.html.erb +1 -1
  283. data/app/views/spree/admin/stores/new.html.erb +1 -1
  284. data/app/views/spree/admin/style_guide/topics/forms/_building_forms.html.erb +5 -3
  285. data/app/views/spree/admin/style_guide/topics/messaging/_loading.html.erb +1 -1
  286. data/app/views/spree/admin/tax_categories/_form.html.erb +4 -2
  287. data/app/views/spree/admin/tax_categories/edit.html.erb +2 -2
  288. data/app/views/spree/admin/tax_categories/index.html.erb +5 -5
  289. data/app/views/spree/admin/tax_categories/new.html.erb +3 -3
  290. data/app/views/spree/admin/tax_rates/_form.html.erb +17 -11
  291. data/app/views/spree/admin/tax_rates/edit.html.erb +2 -2
  292. data/app/views/spree/admin/tax_rates/index.html.erb +8 -8
  293. data/app/views/spree/admin/tax_rates/new.html.erb +3 -3
  294. data/app/views/spree/admin/taxonomies/edit.erb +3 -3
  295. data/app/views/spree/admin/taxonomies/index.html.erb +2 -2
  296. data/app/views/spree/admin/taxonomies/new.html.erb +2 -2
  297. data/app/views/spree/admin/taxons/_form.html.erb +5 -1
  298. data/app/views/spree/admin/taxons/edit.html.erb +4 -4
  299. data/app/views/spree/admin/taxons/index.html.erb +7 -7
  300. data/app/views/spree/admin/users/_addresses_form.html.erb +2 -2
  301. data/app/views/spree/admin/users/_form.html.erb +10 -5
  302. data/app/views/spree/admin/users/_sidebar.html.erb +6 -6
  303. data/app/views/spree/admin/users/_tabs.html.erb +5 -5
  304. data/app/views/spree/admin/users/edit.html.erb +14 -15
  305. data/app/views/spree/admin/users/index.html.erb +14 -12
  306. data/app/views/spree/admin/users/items.html.erb +7 -7
  307. data/app/views/spree/admin/users/new.html.erb +1 -1
  308. data/app/views/spree/admin/users/orders.html.erb +7 -7
  309. data/app/views/spree/admin/variants/_form.html.erb +2 -2
  310. data/app/views/spree/admin/variants/_table.html.erb +2 -2
  311. data/app/views/spree/admin/variants/_table_filter.html.erb +5 -5
  312. data/app/views/spree/admin/variants/index.html.erb +8 -8
  313. data/app/views/spree/admin/variants/new.html.erb +1 -1
  314. data/app/views/spree/admin/zones/_form.html.erb +10 -6
  315. data/app/views/spree/admin/zones/edit.html.erb +1 -1
  316. data/app/views/spree/admin/zones/index.html.erb +3 -3
  317. data/app/views/spree/admin/zones/new.html.erb +2 -2
  318. data/app/views/spree/layouts/admin.html.erb +1 -1
  319. data/app/views/spree/layouts/admin_style_guide.html.erb +2 -2
  320. data/config/routes.rb +1 -11
  321. data/lib/spree/backend.rb +1 -2
  322. data/solidus_backend.gemspec +1 -3
  323. data/spec/controllers/spree/admin/cancellations_controller_spec.rb +3 -3
  324. data/spec/controllers/spree/admin/orders_controller_spec.rb +9 -9
  325. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +1 -1
  326. data/spec/controllers/spree/admin/prices_controller_spec.rb +2 -2
  327. data/spec/controllers/spree/admin/products_controller_spec.rb +2 -1
  328. data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +1 -1
  329. data/spec/controllers/spree/admin/promotions_controller_spec.rb +7 -0
  330. data/spec/controllers/spree/admin/reports_controller_spec.rb +1 -1
  331. data/spec/controllers/spree/admin/resource_controller_spec.rb +2 -2
  332. data/spec/controllers/spree/admin/search_controller_spec.rb +1 -1
  333. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +4 -4
  334. data/spec/controllers/spree/admin/users_controller_spec.rb +1 -1
  335. data/spec/controllers/spree/admin/variants_controller_spec.rb +13 -3
  336. data/spec/features/admin/configuration/payment_methods_spec.rb +55 -16
  337. data/spec/features/admin/configuration/shipping_methods_spec.rb +40 -0
  338. data/spec/features/admin/homepage_spec.rb +25 -8
  339. data/spec/features/admin/orders/adjustments_spec.rb +2 -2
  340. data/spec/features/admin/orders/customer_details_spec.rb +24 -9
  341. data/spec/features/admin/orders/listing_spec.rb +6 -9
  342. data/spec/features/admin/orders/log_entries_spec.rb +0 -1
  343. data/spec/features/admin/orders/new_order_spec.rb +8 -2
  344. data/spec/features/admin/orders/order_details_spec.rb +116 -74
  345. data/spec/features/admin/orders/payments_spec.rb +7 -10
  346. data/spec/features/admin/orders/shipments_spec.rb +9 -5
  347. data/spec/features/admin/payments/store_credits_spec.rb +2 -2
  348. data/spec/features/admin/products/edit/images_spec.rb +0 -79
  349. data/spec/features/admin/products/products_spec.rb +3 -6
  350. data/spec/features/admin/products/variant_spec.rb +17 -0
  351. data/spec/features/admin/promotion_adjustments_spec.rb +105 -52
  352. data/spec/features/admin/promotions/option_value_rule_spec.rb +6 -3
  353. data/spec/features/admin/promotions/tiered_calculator_spec.rb +4 -2
  354. data/spec/features/admin/users_spec.rb +14 -11
  355. data/spec/javascripts/translation_spec.js +8 -0
  356. data/spec/javascripts/views/number_with_currency_spec.js +6 -6
  357. data/spec/spec_helper.rb +28 -37
  358. data/spec/teaspoon_env.rb +61 -14
  359. data/spec/views/spree/admin/shared/navigation_footer_spec.rb +41 -0
  360. data/vendor/assets/javascripts/solidus_admin/Sortable.js +1540 -0
  361. data/vendor/assets/javascripts/solidus_admin/bootstrap.js +1878 -1816
  362. data/vendor/assets/javascripts/solidus_admin/flatpickr/flatpickr.js +2218 -0
  363. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_es-MX.js +19 -0
  364. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_alert.scss +7 -4
  365. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_badge.scss +1 -2
  366. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_breadcrumb.scss +4 -4
  367. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_button-group.scss +32 -64
  368. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_buttons.scss +38 -36
  369. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_card.scss +78 -31
  370. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_carousel.scss +6 -0
  371. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_close.scss +8 -3
  372. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_code.scss +4 -12
  373. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_custom-forms.scss +132 -89
  374. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_dropdown.scss +46 -43
  375. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_forms.scss +47 -104
  376. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_functions.scss +8 -12
  377. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_grid.scss +0 -1
  378. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_images.scss +0 -1
  379. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_input-group.scss +103 -120
  380. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_list-group.scss +2 -1
  381. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_mixins.scss +1 -0
  382. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_modal.scss +36 -10
  383. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_nav.scss +7 -7
  384. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_navbar.scss +35 -8
  385. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_pagination.scss +33 -22
  386. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_popover.scss +106 -118
  387. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_print.scss +19 -6
  388. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_progress.scss +5 -4
  389. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_reboot.scss +39 -38
  390. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_root.scss +19 -0
  391. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_tables.scss +40 -28
  392. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_tooltip.scss +65 -57
  393. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_transitions.scss +2 -0
  394. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_type.scss +4 -2
  395. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_variables.scss +546 -489
  396. data/vendor/assets/stylesheets/solidus_admin/bootstrap/bootstrap-grid.scss +8 -13
  397. data/vendor/assets/stylesheets/solidus_admin/bootstrap/bootstrap-reboot.scss +7 -4
  398. data/vendor/assets/stylesheets/solidus_admin/bootstrap/bootstrap.scss +5 -4
  399. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_alert.scss +1 -1
  400. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_background-variant.scss +10 -1
  401. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_badge.scss +2 -2
  402. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_breakpoints.scss +25 -7
  403. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_buttons.scss +50 -24
  404. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_caret.scss +65 -0
  405. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_float.scss +2 -0
  406. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_forms.scss +72 -16
  407. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_gradients.scss +8 -0
  408. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_grid-framework.scss +15 -4
  409. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_grid.scss +10 -5
  410. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_hover.scss +25 -46
  411. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_image.scss +3 -3
  412. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_list-group.scss +10 -15
  413. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_navbar-align.scss +2 -1
  414. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_reset-text.scss +1 -2
  415. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_screen-reader.scss +3 -3
  416. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_text-emphasis.scss +2 -0
  417. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_text-hide.scss +1 -0
  418. data/vendor/assets/stylesheets/solidus_admin/bootstrap/mixins/_visibility.scss +2 -0
  419. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_align.scss +2 -0
  420. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_background.scss +16 -3
  421. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_borders.scss +10 -3
  422. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_display.scss +13 -28
  423. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_flex.scss +2 -0
  424. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_position.scss +12 -1
  425. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_sizing.scss +2 -0
  426. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_spacing.scss +24 -14
  427. data/vendor/assets/stylesheets/solidus_admin/bootstrap/utilities/_text.scss +7 -4
  428. data/vendor/assets/stylesheets/solidus_admin/flatpickr/flatpickr.css +857 -0
  429. metadata +57 -127
  430. data/Gemfile +0 -9
  431. data/app/assets/javascripts/spree/backend/address_states.js +0 -35
  432. data/app/assets/javascripts/spree/backend/adjustments.js.coffee +0 -17
  433. data/app/assets/javascripts/spree/backend/backbone-overrides.js.coffee +0 -23
  434. data/app/assets/javascripts/spree/backend/components/editable_table.js.coffee +0 -3
  435. data/app/assets/javascripts/spree/backend/components/tabs.coffee +0 -79
  436. data/app/assets/javascripts/spree/backend/flash.coffee +0 -17
  437. data/app/assets/javascripts/spree/backend/gateway.js.coffee +0 -21
  438. data/app/assets/javascripts/spree/backend/images/index.js.coffee +0 -13
  439. data/app/assets/javascripts/spree/backend/navigation.coffee +0 -10
  440. data/app/assets/javascripts/spree/backend/number_field_updater.coffee +0 -41
  441. data/app/assets/javascripts/spree/backend/payments/edit.js.coffee +0 -33
  442. data/app/assets/javascripts/spree/backend/progress.coffee +0 -7
  443. data/app/assets/javascripts/spree/backend/promotions.js.coffee +0 -99
  444. data/app/assets/javascripts/spree/backend/select_payments.js.coffee +0 -0
  445. data/app/assets/javascripts/spree/backend/states.coffee +0 -22
  446. data/app/assets/javascripts/spree/backend/stock_management/index_add_forms.coffee +0 -61
  447. data/app/assets/javascripts/spree/backend/stock_management/index_update_forms.coffee +0 -66
  448. data/app/assets/javascripts/spree/backend/stock_management/stock_item.coffee +0 -4
  449. data/app/assets/javascripts/spree/backend/stock_transfers/count_update_forms.coffee +0 -44
  450. data/app/assets/javascripts/spree/backend/stock_transfers/edit.coffee +0 -6
  451. data/app/assets/javascripts/spree/backend/stock_transfers/receive.coffee +0 -5
  452. data/app/assets/javascripts/spree/backend/stock_transfers/received_counter.coffee +0 -9
  453. data/app/assets/javascripts/spree/backend/stock_transfers/stock_transfer.coffee +0 -17
  454. data/app/assets/javascripts/spree/backend/stock_transfers/transfer_item.coffee +0 -48
  455. data/app/assets/javascripts/spree/backend/stock_transfers/transfer_item_deleting.coffee +0 -22
  456. data/app/assets/javascripts/spree/backend/stock_transfers/variant_form.coffee +0 -128
  457. data/app/assets/javascripts/spree/backend/store_credits.js.coffee +0 -40
  458. data/app/assets/javascripts/spree/backend/style_guide.coffee +0 -2
  459. data/app/assets/javascripts/spree/backend/taxonomy.js.coffee +0 -108
  460. data/app/assets/javascripts/spree/backend/taxons.js.coffee +0 -73
  461. data/app/assets/javascripts/spree/backend/templates/promotions/rules/option_values_select.hbs +0 -1
  462. data/app/assets/javascripts/spree/backend/templates/stock_transfers/transfer_item.hbs +0 -48
  463. data/app/assets/javascripts/spree/backend/variant_autocomplete.js.coffee +0 -39
  464. data/app/assets/javascripts/spree/backend/views/tables/editable_table.js.coffee +0 -14
  465. data/app/assets/javascripts/spree/backend/views/tables/editable_table_row.js.coffee +0 -45
  466. data/app/assets/stylesheets/spree/backend/components/_date-picker.scss +0 -154
  467. data/app/assets/stylesheets/spree/backend/components/_number_field_update.scss +0 -13
  468. data/app/assets/stylesheets/spree/backend/sections/_stock_transfers.scss +0 -7
  469. data/app/assets/stylesheets/spree/backend/sections/_transfer_items.scss +0 -49
  470. data/app/controllers/spree/admin/stock_transfers_controller.rb +0 -151
  471. data/app/helpers/spree/admin/general_settings_helper.rb +0 -13
  472. data/app/helpers/spree/admin/inventory_settings_helper.rb +0 -9
  473. data/app/helpers/spree/admin/stock_transfers_helper.rb +0 -35
  474. data/app/helpers/spree/admin/tables_helper.rb +0 -13
  475. data/app/helpers/spree/admin/taxons_helper.rb +0 -9
  476. data/app/views/spree/admin/products/new.js.erb +0 -4
  477. data/app/views/spree/admin/promotions/rules/_landing_page.html.erb +0 -7
  478. data/app/views/spree/admin/shared/_number_field_update_actions.html.erb +0 -5
  479. data/app/views/spree/admin/shared/_number_field_update_cell.html.erb +0 -4
  480. data/app/views/spree/admin/shared/_stock_sub_menu.html.erb +0 -8
  481. data/app/views/spree/admin/stock_transfers/_location.html.erb +0 -7
  482. data/app/views/spree/admin/stock_transfers/_transfer_item_actions.html.erb +0 -9
  483. data/app/views/spree/admin/stock_transfers/_transfer_item_table.html.erb +0 -72
  484. data/app/views/spree/admin/stock_transfers/edit.html.erb +0 -52
  485. data/app/views/spree/admin/stock_transfers/index.html.erb +0 -123
  486. data/app/views/spree/admin/stock_transfers/new.html.erb +0 -26
  487. data/app/views/spree/admin/stock_transfers/receive.html.erb +0 -38
  488. data/app/views/spree/admin/stock_transfers/show.html.erb +0 -50
  489. data/app/views/spree/admin/stock_transfers/tracking_info.html.erb +0 -46
  490. data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +0 -365
  491. data/spec/features/admin/stock_transfer_spec.rb +0 -115
  492. data/vendor/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  493. data/vendor/assets/images/jquery-ui/ui-bg_flat_0_eeeeee_40x100.png +0 -0
  494. data/vendor/assets/images/jquery-ui/ui-bg_flat_55_ffffff_40x100.png +0 -0
  495. data/vendor/assets/images/jquery-ui/ui-bg_flat_75_ffffff_40x100.png +0 -0
  496. data/vendor/assets/images/jquery-ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
  497. data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_100_f6f6f6_1x100.png +0 -0
  498. data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_25_0073ea_1x100.png +0 -0
  499. data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_50_dddddd_1x100.png +0 -0
  500. data/vendor/assets/images/jquery-ui/ui-icons_0073ea_256x240.png +0 -0
  501. data/vendor/assets/images/jquery-ui/ui-icons_454545_256x240.png +0 -0
  502. data/vendor/assets/images/jquery-ui/ui-icons_666666_256x240.png +0 -0
  503. data/vendor/assets/images/jquery-ui/ui-icons_ff0084_256x240.png +0 -0
  504. data/vendor/assets/images/jquery-ui/ui-icons_ffffff_256x240.png +0 -0
  505. data/vendor/assets/stylesheets/jquery-ui.datepicker.css.erb +0 -357
@@ -31,6 +31,8 @@ feature 'Promotion with option value rule' do
31
31
 
32
32
  within('#rules_container') { click_button "Update" }
33
33
 
34
+ expect(page).to have_content("has been successfully updated")
35
+
34
36
  first_rule = promotion.rules.reload.first
35
37
  expect(first_rule.class).to eq Spree::Promotion::Rules::OptionValue
36
38
  expect(first_rule.preferred_eligible_values).to eq Hash[product.id => [option_value.id]]
@@ -72,12 +74,13 @@ feature 'Promotion with option value rule' do
72
74
  end
73
75
 
74
76
  scenario "deleting a product", js: true do
75
- within(".promo-rule-option-value:last-child") do
76
- find(".remove").click
77
- end
77
+ expect(page).to have_css('.promo-rule-option-value', count: 2)
78
+ all('.promo-rule-option-value')[1].find('.remove').click
78
79
 
79
80
  within('#rules_container') { click_button "Update" }
80
81
 
82
+ expect(page).to have_content("has been successfully updated")
83
+
81
84
  first_rule = promotion.rules.reload.first
82
85
  expect(first_rule.preferred_eligible_values).to eq Hash[variant1.product_id => variant1.option_values.pluck(:id)]
83
86
  end
@@ -13,14 +13,14 @@ feature "Tiered Calculator Promotions" do
13
13
  select "Create whole-order adjustment", from: "Add action of type"
14
14
  within('#action_fields') { click_button "Add" }
15
15
 
16
- select "Tiered Percent", from: "Base Calculator"
16
+ select "Tiered Percent", from: I18n.t('spree.admin.promotions.actions.calculator_label')
17
17
  within('#actions_container') { click_button "Update" }
18
18
 
19
19
  within("#actions_container .settings") do
20
20
  expect(page).to have_content("Base Percent")
21
21
  expect(page).to have_content("Tiers")
22
22
 
23
- click_button "Add"
23
+ page.find('a.button').click
24
24
  end
25
25
 
26
26
  fill_in "Base Percent", with: 5
@@ -62,6 +62,8 @@ feature "Tiered Calculator Promotions" do
62
62
 
63
63
  within('#actions_container') { click_button "Update" }
64
64
 
65
+ expect(page).to have_text('has been successfully updated!')
66
+
65
67
  calculator = promotion.actions.first.calculator
66
68
  expect(calculator.preferred_tiers).to eq({
67
69
  BigDecimal(100) => 10,
@@ -25,7 +25,7 @@ describe 'Users', type: :feature do
25
25
  visit current_url # need to refresh after creating the orders for specs that did not require orders
26
26
  within("#user-lifetime-stats") do
27
27
  [:total_sales, :num_orders, :average_order_value, :member_since].each do |stat_name|
28
- expect(page).to have_content Spree.t(stat_name)
28
+ expect(page).to have_content I18n.t(stat_name, scope: 'spree')
29
29
  end
30
30
  expect(page).to have_content(order.total + order_2.total)
31
31
  expect(page).to have_content orders.count
@@ -39,15 +39,15 @@ describe 'Users', type: :feature do
39
39
  end
40
40
 
41
41
  it 'can navigate to the account page' do
42
- expect(page).to have_link Spree.t(:"admin.user.account"), href: spree.edit_admin_user_path(user_a)
42
+ expect(page).to have_link I18n.t("spree.admin.user.account"), href: spree.edit_admin_user_path(user_a)
43
43
  end
44
44
 
45
45
  it 'can navigate to the order history' do
46
- expect(page).to have_link Spree.t(:"admin.user.order_history"), href: spree.orders_admin_user_path(user_a)
46
+ expect(page).to have_link I18n.t("spree.admin.user.order_history"), href: spree.orders_admin_user_path(user_a)
47
47
  end
48
48
 
49
49
  it 'can navigate to the items purchased' do
50
- expect(page).to have_link Spree.t(:"admin.user.items"), href: spree.items_admin_user_path(user_a)
50
+ expect(page).to have_link I18n.t("spree.admin.user.items"), href: spree.items_admin_user_path(user_a)
51
51
  end
52
52
  end
53
53
 
@@ -99,15 +99,18 @@ describe 'Users', type: :feature do
99
99
  end
100
100
 
101
101
  context "member since" do
102
+ before do
103
+ user_a.update_column(:created_at, 2.weeks.ago)
104
+ end
105
+
102
106
  it_behaves_like "a sortable attribute" do
103
107
  let(:text_match_1) { user_a.email }
104
108
  let(:text_match_2) { user_b.email }
105
109
  let(:table_id) { "listing_users" }
106
- let(:sort_link) { Spree.t(:member_since) }
110
+ let(:sort_link) { I18n.t('spree.member_since') }
107
111
  end
108
112
 
109
113
  it 'displays the correct results for a user search by creation date' do
110
- user_a.update_column(:created_at, 2.weeks.ago)
111
114
  fill_in 'q_created_at_lt', with: 1.week.ago
112
115
  click_button 'Search'
113
116
  within_table('listing_users') do
@@ -238,7 +241,7 @@ describe 'Users', type: :feature do
238
241
  it 'can generate a new api key' do
239
242
  within("#admin_user_edit_api_key") do
240
243
  expect(user_a.spree_api_key).to be_blank
241
- click_button Spree.t('generate_key', scope: 'api')
244
+ click_button "Generate API key"
242
245
  end
243
246
 
244
247
  expect(user_a.reload.spree_api_key).to be_present
@@ -257,7 +260,7 @@ describe 'Users', type: :feature do
257
260
  it 'can clear an api key' do
258
261
  expect(page).to have_css('#current-api-key')
259
262
 
260
- click_button Spree.t('clear_key', scope: 'api')
263
+ click_button "Clear key"
261
264
 
262
265
  expect(page).to have_no_css('#current-api-key')
263
266
 
@@ -268,7 +271,7 @@ describe 'Users', type: :feature do
268
271
  old_key = user_a.spree_api_key
269
272
 
270
273
  within("#admin_user_edit_api_key") do
271
- click_button Spree.t('regenerate_key', scope: 'api')
274
+ click_button "Regenerate key"
272
275
  end
273
276
 
274
277
  expect(user_a.reload.spree_api_key).to be_present
@@ -283,7 +286,7 @@ describe 'Users', type: :feature do
283
286
  before do
284
287
  orders
285
288
  click_link user_a.email
286
- within(".tabs") { click_link Spree.t(:"admin.user.order_history") }
289
+ within(".tabs") { click_link I18n.t("spree.admin.user.order_history") }
287
290
  end
288
291
 
289
292
  it_behaves_like 'a user page'
@@ -320,7 +323,7 @@ describe 'Users', type: :feature do
320
323
  before do
321
324
  orders
322
325
  click_link user_a.email
323
- within(".tabs") { click_link Spree.t(:"admin.user.items") }
326
+ within(".tabs") { click_link I18n.t("spree.admin.user.items") }
324
327
  end
325
328
 
326
329
  it_behaves_like 'a user page'
@@ -31,6 +31,14 @@ describe('Spree.t', function() {
31
31
  expect(Spree.t('nested.key', {scope: 'deeply'})).to.equal('deeply nested key');
32
32
  expect(Spree.t('key', {scope: 'deeply.nested'})).to.equal('deeply nested key');
33
33
  });
34
+
35
+ it('ignores default when key exists', function() {
36
+ expect(Spree.t('simple', {default: 'foo'})).to.equal('simple');
37
+ });
38
+
39
+ it('returns a default for a missing key', function() {
40
+ expect(Spree.t('does_not_exist', {default: 'foo'})).to.equal('foo');
41
+ });
34
42
  });
35
43
 
36
44
  describe('Spree.human_attribute_name', function() {
@@ -24,15 +24,15 @@ describe("Spree.Views.NumberWithCurrency", function() {
24
24
  loadView();
25
25
  });
26
26
 
27
- it("has no currency selected", function() {
28
- expect($select).to.have.$val('');
29
- expect($symbol).to.have.$text('');
27
+ it("has a default currency selected", function() {
28
+ expect($select).to.have.$val('USD');
29
+ expect($symbol).to.have.$text('$');
30
30
  });
31
31
 
32
- it("can select USD", function() {
33
- $select.val('USD').trigger('change');
32
+ it("can select CAD", function() {
33
+ $select.val('CAD').trigger('change');
34
34
 
35
- expect($select).to.have.$val('USD');
35
+ expect($select).to.have.$val('CAD');
36
36
  expect($symbol).to.have.$text('$');
37
37
  });
38
38
 
data/spec/spec_helper.rb CHANGED
@@ -1,27 +1,21 @@
1
1
  if ENV["COVERAGE"]
2
- # Run Coverage report
3
2
  require 'simplecov'
4
- SimpleCov.start do
5
- add_group 'Controllers', 'app/controllers'
6
- add_group 'Helpers', 'app/helpers'
7
- add_group 'Mailers', 'app/mailers'
8
- add_group 'Models', 'app/models'
9
- add_group 'Views', 'app/views'
10
- add_group 'Libraries', 'lib'
11
- end
3
+ SimpleCov.start('rails')
12
4
  end
13
5
 
14
6
  # This file is copied to ~/spec when you run 'ruby script/generate rspec'
15
7
  # from the project root directory.
16
8
  ENV["RAILS_ENV"] ||= 'test'
17
9
 
18
- begin
19
- require File.expand_path("../dummy/config/environment", __FILE__)
20
- rescue LoadError
21
- $stderr.puts "Could not load dummy application. Please ensure you have run `bundle exec rake test_app`"
22
- exit 1
23
- end
10
+ require 'solidus_backend'
11
+ require 'spree/testing_support/dummy_app'
12
+ DummyApp.setup(
13
+ gem_root: File.expand_path('../../', __FILE__),
14
+ lib_name: 'solidus_backend'
15
+ )
24
16
 
17
+ require 'rails-controller-testing'
18
+ require 'rspec-activemodel-mocks'
25
19
  require 'rspec/rails'
26
20
 
27
21
  # Requires supporting files with custom matchers and macros, etc,
@@ -29,7 +23,7 @@ require 'rspec/rails'
29
23
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
30
24
 
31
25
  require 'database_cleaner'
32
- require 'ffaker'
26
+ require 'with_model'
33
27
 
34
28
  require 'spree/testing_support/authorization_helpers'
35
29
  require 'spree/testing_support/factories'
@@ -42,15 +36,26 @@ require 'spree/testing_support/capybara_ext'
42
36
 
43
37
  require 'capybara-screenshot/rspec'
44
38
  Capybara.save_path = ENV['CIRCLE_ARTIFACTS'] if ENV['CIRCLE_ARTIFACTS']
45
-
46
- require 'capybara/poltergeist'
47
- Capybara.javascript_driver = :poltergeist
48
39
  Capybara.exact = true
49
40
 
41
+ require "selenium/webdriver"
42
+
43
+ Capybara.register_driver :selenium_chrome_headless do |app|
44
+ browser_options = ::Selenium::WebDriver::Chrome::Options.new
45
+ browser_options.args << '--headless'
46
+ browser_options.args << '--disable-gpu'
47
+ browser_options.args << '--window-size=1440,1080'
48
+ Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
49
+ end
50
+
51
+ Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym
52
+
50
53
  ActionView::Base.raise_on_missing_translations = true
51
54
 
52
55
  Capybara.default_max_wait_time = ENV['DEFAULT_MAX_WAIT_TIME'].to_f if ENV['DEFAULT_MAX_WAIT_TIME'].present?
53
56
 
57
+ ActiveJob::Base.queue_adapter = :test
58
+
54
59
  RSpec.configure do |config|
55
60
  config.color = true
56
61
  config.infer_spec_type_from_file_location!
@@ -64,7 +69,7 @@ RSpec.configure do |config|
64
69
  # If you're not using ActiveRecord, or you'd prefer not to run each of your
65
70
  # examples within a transaction, comment the following line or assign false
66
71
  # instead of true.
67
- config.use_transactional_fixtures = false
72
+ config.use_transactional_fixtures = true
68
73
 
69
74
  config.before :suite do
70
75
  DatabaseCleaner.clean_with :truncation
@@ -79,27 +84,14 @@ RSpec.configure do |config|
79
84
  end
80
85
  end
81
86
 
82
- config.prepend_before(:each) do
83
- if RSpec.current_example.metadata[:js]
84
- DatabaseCleaner.strategy = :truncation
85
- else
86
- DatabaseCleaner.strategy = :transaction
87
- end
88
- DatabaseCleaner.start
89
- end
90
-
91
87
  config.before do
92
88
  Rails.cache.clear
93
89
  reset_spree_preferences
94
- if RSpec.current_example.metadata[:js]
90
+ if RSpec.current_example.metadata[:js] && page.driver.browser.respond_to?(:url_blacklist)
95
91
  page.driver.browser.url_blacklist = ['http://fonts.googleapis.com']
96
92
  end
97
93
  end
98
94
 
99
- config.append_after(:each) do
100
- DatabaseCleaner.clean
101
- end
102
-
103
95
  config.include BaseFeatureHelper, type: :feature
104
96
 
105
97
  config.after(:each, type: :feature) do |example|
@@ -110,7 +102,8 @@ RSpec.configure do |config|
110
102
  end
111
103
  end
112
104
 
113
- config.include FactoryGirl::Syntax::Methods
105
+ config.include FactoryBot::Syntax::Methods
106
+ config.include ActiveJob::TestHelper
114
107
 
115
108
  config.include Spree::TestingSupport::Preferences
116
109
  config.include Spree::TestingSupport::UrlHelpers
@@ -119,8 +112,6 @@ RSpec.configure do |config|
119
112
 
120
113
  config.extend WithModel
121
114
 
122
- config.fail_fast = ENV['FAIL_FAST'] || false
123
-
124
115
  config.example_status_persistence_file_path = "./spec/examples.txt"
125
116
 
126
117
  config.order = :random
data/spec/teaspoon_env.rb CHANGED
@@ -1,17 +1,64 @@
1
1
  ENV['RAILS_ENV'] = 'test'
2
- require File.expand_path("../dummy/config/environment", __FILE__)
3
-
4
- Teaspoon.configure do |config|
5
- config.mount_at = "/teaspoon"
6
- config.root = Spree::Backend::Engine.root
7
- config.asset_paths = ["spec/javascripts", "spec/javascripts/stylesheets"]
8
- config.fixture_paths = ["spec/javascripts/fixtures"]
9
-
10
- config.suite do |suite|
11
- suite.use_framework :mocha, "2.3.3"
12
- suite.matcher = "{spec/javascripts,app/assets}/**/*_spec.{js,js.coffee,coffee}"
13
- suite.helper = "spec_helper"
14
- suite.boot_partial = "/boot"
15
- suite.expand_assets = true
2
+
3
+ # Teaspoon doesn't allow you to pass client driver options to the Selenium WebDriver. This monkey patch
4
+ # is a temporary fix until this PR is merged: https://github.com/jejacks0n/teaspoon/pull/519.
5
+ require 'teaspoon/driver/selenium'
6
+
7
+ Teaspoon::Driver::Selenium.class_eval do
8
+ def run_specs(runner, url)
9
+ driver = ::Selenium::WebDriver.for(driver_options[:client_driver], @options.except(:client_driver) || {})
10
+ driver.navigate.to(url)
11
+
12
+ ::Selenium::WebDriver::Wait.new(driver_options).until do
13
+ done = driver.execute_script("return window.Teaspoon && window.Teaspoon.finished")
14
+ driver.execute_script("return window.Teaspoon && window.Teaspoon.getMessages() || []").each do |line|
15
+ runner.process("#{line}\n")
16
+ end
17
+ done
18
+ end
19
+ ensure
20
+ driver.quit if driver
21
+ end
22
+ end
23
+
24
+ # Similar to setup described in
25
+ # https://github.com/jejacks0n/teaspoon/wiki/Micro-Applications
26
+
27
+ if defined?(DummyApp)
28
+ DummyApp::Migrations.auto_migrate
29
+
30
+ require 'teaspoon-mocha'
31
+
32
+ Teaspoon.configure do |config|
33
+ config.mount_at = "/teaspoon"
34
+ config.root = Spree::Backend::Engine.root
35
+ config.asset_paths = ["spec/javascripts", "spec/javascripts/stylesheets"]
36
+ config.fixture_paths = ["spec/javascripts/fixtures"]
37
+
38
+ config.driver = :selenium
39
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
40
+ chromeOptions: { args: %w(headless disable-gpu window-size=1920,1440) }
41
+ )
42
+ config.driver_options = { client_driver: :chrome, desired_capabilities: capabilities }
43
+
44
+ config.suite do |suite|
45
+ suite.use_framework :mocha, "2.3.3"
46
+ suite.matcher = "{spec/javascripts,app/assets}/**/*_spec.{js,js.coffee,coffee}"
47
+ suite.helper = "spec_helper"
48
+ suite.boot_partial = "/boot"
49
+ suite.expand_assets = true
50
+ end
16
51
  end
52
+ else
53
+ require 'solidus_backend'
54
+
55
+ require 'teaspoon'
56
+
57
+ require 'spree/testing_support/dummy_app'
58
+
59
+ DummyApp.setup(
60
+ gem_root: File.expand_path('../../', __FILE__),
61
+ lib_name: 'solidus_backend',
62
+ auto_migrate: false
63
+ )
17
64
  end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe "spree/admin/shared/_navigation_footer", type: :view do
4
+ let(:user) { FactoryBot.build_stubbed(:admin_user) }
5
+ before do
6
+ allow(view).to receive(:try_spree_current_user).and_return(user)
7
+ end
8
+
9
+ it "has a a login-nav section" do
10
+ render
11
+ expect(rendered).to have_selector("#login-nav")
12
+ end
13
+
14
+ it "has a user-account-link" do
15
+ render
16
+ expect(rendered).to have_link(user.email, href: Spree::Core::Engine.routes.url_helpers.edit_admin_user_path(user))
17
+ end
18
+
19
+ context "with a required spree_logout_path helper" do
20
+ before do
21
+ allow(view).to receive(:spree_logout_path).and_return("/logout")
22
+ end
23
+
24
+ it "has user-logout-link" do
25
+ render
26
+ expect(rendered).to have_link(I18n.t('spree.logout'), href: "/logout")
27
+ end
28
+ end
29
+
30
+ context "with a spree.root_path" do
31
+ before do
32
+ allow(view.spree).to receive("root_path").and_return("/")
33
+ end
34
+
35
+ it "has a back to store link" do
36
+ render
37
+ expect(rendered).to have_link(I18n.t('spree.back_to_store'), href: "/")
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,1540 @@
1
+ /**!
2
+ * Sortable
3
+ * @author RubaXa <trash@rubaxa.org>
4
+ * @license MIT
5
+ */
6
+
7
+ (function sortableModule(factory) {
8
+ "use strict";
9
+
10
+ if (typeof define === "function" && define.amd) {
11
+ define(factory);
12
+ }
13
+ else if (typeof module != "undefined" && typeof module.exports != "undefined") {
14
+ module.exports = factory();
15
+ }
16
+ else {
17
+ /* jshint sub:true */
18
+ window["Sortable"] = factory();
19
+ }
20
+ })(function sortableFactory() {
21
+ "use strict";
22
+
23
+ if (typeof window === "undefined" || !window.document) {
24
+ return function sortableError() {
25
+ throw new Error("Sortable.js requires a window with a document");
26
+ };
27
+ }
28
+
29
+ var dragEl,
30
+ parentEl,
31
+ ghostEl,
32
+ cloneEl,
33
+ rootEl,
34
+ nextEl,
35
+ lastDownEl,
36
+
37
+ scrollEl,
38
+ scrollParentEl,
39
+ scrollCustomFn,
40
+
41
+ lastEl,
42
+ lastCSS,
43
+ lastParentCSS,
44
+
45
+ oldIndex,
46
+ newIndex,
47
+
48
+ activeGroup,
49
+ putSortable,
50
+
51
+ autoScroll = {},
52
+
53
+ tapEvt,
54
+ touchEvt,
55
+
56
+ moved,
57
+
58
+ /** @const */
59
+ R_SPACE = /\s+/g,
60
+ R_FLOAT = /left|right|inline/,
61
+
62
+ expando = 'Sortable' + (new Date).getTime(),
63
+
64
+ win = window,
65
+ document = win.document,
66
+ parseInt = win.parseInt,
67
+ setTimeout = win.setTimeout,
68
+
69
+ $ = win.jQuery || win.Zepto,
70
+ Polymer = win.Polymer,
71
+
72
+ captureMode = false,
73
+ passiveMode = false,
74
+
75
+ supportDraggable = ('draggable' in document.createElement('div')),
76
+ supportCssPointerEvents = (function (el) {
77
+ // false when IE11
78
+ if (!!navigator.userAgent.match(/(?:Trident.*rv[ :]?11\.|msie)/i)) {
79
+ return false;
80
+ }
81
+ el = document.createElement('x');
82
+ el.style.cssText = 'pointer-events:auto';
83
+ return el.style.pointerEvents === 'auto';
84
+ })(),
85
+
86
+ _silent = false,
87
+
88
+ abs = Math.abs,
89
+ min = Math.min,
90
+
91
+ savedInputChecked = [],
92
+ touchDragOverListeners = [],
93
+
94
+ _autoScroll = _throttle(function (/**Event*/evt, /**Object*/options, /**HTMLElement*/rootEl) {
95
+ // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
96
+ if (rootEl && options.scroll) {
97
+ var _this = rootEl[expando],
98
+ el,
99
+ rect,
100
+ sens = options.scrollSensitivity,
101
+ speed = options.scrollSpeed,
102
+
103
+ x = evt.clientX,
104
+ y = evt.clientY,
105
+
106
+ winWidth = window.innerWidth,
107
+ winHeight = window.innerHeight,
108
+
109
+ vx,
110
+ vy,
111
+
112
+ scrollOffsetX,
113
+ scrollOffsetY
114
+ ;
115
+
116
+ // Delect scrollEl
117
+ if (scrollParentEl !== rootEl) {
118
+ scrollEl = options.scroll;
119
+ scrollParentEl = rootEl;
120
+ scrollCustomFn = options.scrollFn;
121
+
122
+ if (scrollEl === true) {
123
+ scrollEl = rootEl;
124
+
125
+ do {
126
+ if ((scrollEl.offsetWidth < scrollEl.scrollWidth) ||
127
+ (scrollEl.offsetHeight < scrollEl.scrollHeight)
128
+ ) {
129
+ break;
130
+ }
131
+ /* jshint boss:true */
132
+ } while (scrollEl = scrollEl.parentNode);
133
+ }
134
+ }
135
+
136
+ if (scrollEl) {
137
+ el = scrollEl;
138
+ rect = scrollEl.getBoundingClientRect();
139
+ vx = (abs(rect.right - x) <= sens) - (abs(rect.left - x) <= sens);
140
+ vy = (abs(rect.bottom - y) <= sens) - (abs(rect.top - y) <= sens);
141
+ }
142
+
143
+
144
+ if (!(vx || vy)) {
145
+ vx = (winWidth - x <= sens) - (x <= sens);
146
+ vy = (winHeight - y <= sens) - (y <= sens);
147
+
148
+ /* jshint expr:true */
149
+ (vx || vy) && (el = win);
150
+ }
151
+
152
+
153
+ if (autoScroll.vx !== vx || autoScroll.vy !== vy || autoScroll.el !== el) {
154
+ autoScroll.el = el;
155
+ autoScroll.vx = vx;
156
+ autoScroll.vy = vy;
157
+
158
+ clearInterval(autoScroll.pid);
159
+
160
+ if (el) {
161
+ autoScroll.pid = setInterval(function () {
162
+ scrollOffsetY = vy ? vy * speed : 0;
163
+ scrollOffsetX = vx ? vx * speed : 0;
164
+
165
+ if ('function' === typeof(scrollCustomFn)) {
166
+ return scrollCustomFn.call(_this, scrollOffsetX, scrollOffsetY, evt);
167
+ }
168
+
169
+ if (el === win) {
170
+ win.scrollTo(win.pageXOffset + scrollOffsetX, win.pageYOffset + scrollOffsetY);
171
+ } else {
172
+ el.scrollTop += scrollOffsetY;
173
+ el.scrollLeft += scrollOffsetX;
174
+ }
175
+ }, 24);
176
+ }
177
+ }
178
+ }
179
+ }, 30),
180
+
181
+ _prepareGroup = function (options) {
182
+ function toFn(value, pull) {
183
+ if (value === void 0 || value === true) {
184
+ value = group.name;
185
+ }
186
+
187
+ if (typeof value === 'function') {
188
+ return value;
189
+ } else {
190
+ return function (to, from) {
191
+ var fromGroup = from.options.group.name;
192
+
193
+ return pull
194
+ ? value
195
+ : value && (value.join
196
+ ? value.indexOf(fromGroup) > -1
197
+ : (fromGroup == value)
198
+ );
199
+ };
200
+ }
201
+ }
202
+
203
+ var group = {};
204
+ var originalGroup = options.group;
205
+
206
+ if (!originalGroup || typeof originalGroup != 'object') {
207
+ originalGroup = {name: originalGroup};
208
+ }
209
+
210
+ group.name = originalGroup.name;
211
+ group.checkPull = toFn(originalGroup.pull, true);
212
+ group.checkPut = toFn(originalGroup.put);
213
+ group.revertClone = originalGroup.revertClone;
214
+
215
+ options.group = group;
216
+ }
217
+ ;
218
+
219
+ // Detect support a passive mode
220
+ try {
221
+ window.addEventListener('test', null, Object.defineProperty({}, 'passive', {
222
+ get: function () {
223
+ // `false`, because everything starts to work incorrectly and instead of d'n'd,
224
+ // begins the page has scrolled.
225
+ passiveMode = false;
226
+ captureMode = {
227
+ capture: false,
228
+ passive: passiveMode
229
+ };
230
+ }
231
+ }));
232
+ } catch (err) {}
233
+
234
+ /**
235
+ * @class Sortable
236
+ * @param {HTMLElement} el
237
+ * @param {Object} [options]
238
+ */
239
+ function Sortable(el, options) {
240
+ if (!(el && el.nodeType && el.nodeType === 1)) {
241
+ throw 'Sortable: `el` must be HTMLElement, and not ' + {}.toString.call(el);
242
+ }
243
+
244
+ this.el = el; // root element
245
+ this.options = options = _extend({}, options);
246
+
247
+
248
+ // Export instance
249
+ el[expando] = this;
250
+
251
+ // Default options
252
+ var defaults = {
253
+ group: Math.random(),
254
+ sort: true,
255
+ disabled: false,
256
+ store: null,
257
+ handle: null,
258
+ scroll: true,
259
+ scrollSensitivity: 30,
260
+ scrollSpeed: 10,
261
+ draggable: /[uo]l/i.test(el.nodeName) ? 'li' : '>*',
262
+ ghostClass: 'sortable-ghost',
263
+ chosenClass: 'sortable-chosen',
264
+ dragClass: 'sortable-drag',
265
+ ignore: 'a, img',
266
+ filter: null,
267
+ preventOnFilter: true,
268
+ animation: 0,
269
+ setData: function (dataTransfer, dragEl) {
270
+ dataTransfer.setData('Text', dragEl.textContent);
271
+ },
272
+ dropBubble: false,
273
+ dragoverBubble: false,
274
+ dataIdAttr: 'data-id',
275
+ delay: 0,
276
+ forceFallback: false,
277
+ fallbackClass: 'sortable-fallback',
278
+ fallbackOnBody: false,
279
+ fallbackTolerance: 0,
280
+ fallbackOffset: {x: 0, y: 0},
281
+ supportPointer: Sortable.supportPointer !== false
282
+ };
283
+
284
+
285
+ // Set default options
286
+ for (var name in defaults) {
287
+ !(name in options) && (options[name] = defaults[name]);
288
+ }
289
+
290
+ _prepareGroup(options);
291
+
292
+ // Bind all private methods
293
+ for (var fn in this) {
294
+ if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
295
+ this[fn] = this[fn].bind(this);
296
+ }
297
+ }
298
+
299
+ // Setup drag mode
300
+ this.nativeDraggable = options.forceFallback ? false : supportDraggable;
301
+
302
+ // Bind events
303
+ _on(el, 'mousedown', this._onTapStart);
304
+ _on(el, 'touchstart', this._onTapStart);
305
+ options.supportPointer && _on(el, 'pointerdown', this._onTapStart);
306
+
307
+ if (this.nativeDraggable) {
308
+ _on(el, 'dragover', this);
309
+ _on(el, 'dragenter', this);
310
+ }
311
+
312
+ touchDragOverListeners.push(this._onDragOver);
313
+
314
+ // Restore sorting
315
+ options.store && this.sort(options.store.get(this));
316
+ }
317
+
318
+
319
+ Sortable.prototype = /** @lends Sortable.prototype */ {
320
+ constructor: Sortable,
321
+
322
+ _onTapStart: function (/** Event|TouchEvent */evt) {
323
+ var _this = this,
324
+ el = this.el,
325
+ options = this.options,
326
+ preventOnFilter = options.preventOnFilter,
327
+ type = evt.type,
328
+ touch = evt.touches && evt.touches[0],
329
+ target = (touch || evt).target,
330
+ originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0]) || target,
331
+ filter = options.filter,
332
+ startIndex;
333
+
334
+ _saveInputCheckedState(el);
335
+
336
+
337
+ // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
338
+ if (dragEl) {
339
+ return;
340
+ }
341
+
342
+ if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
343
+ return; // only left button or enabled
344
+ }
345
+
346
+ // cancel dnd if original target is content editable
347
+ if (originalTarget.isContentEditable) {
348
+ return;
349
+ }
350
+
351
+ target = _closest(target, options.draggable, el);
352
+
353
+ if (!target) {
354
+ return;
355
+ }
356
+
357
+ if (lastDownEl === target) {
358
+ // Ignoring duplicate `down`
359
+ return;
360
+ }
361
+
362
+ // Get the index of the dragged element within its parent
363
+ startIndex = _index(target, options.draggable);
364
+
365
+ // Check filter
366
+ if (typeof filter === 'function') {
367
+ if (filter.call(this, evt, target, this)) {
368
+ _dispatchEvent(_this, originalTarget, 'filter', target, el, el, startIndex);
369
+ preventOnFilter && evt.preventDefault();
370
+ return; // cancel dnd
371
+ }
372
+ }
373
+ else if (filter) {
374
+ filter = filter.split(',').some(function (criteria) {
375
+ criteria = _closest(originalTarget, criteria.trim(), el);
376
+
377
+ if (criteria) {
378
+ _dispatchEvent(_this, criteria, 'filter', target, el, el, startIndex);
379
+ return true;
380
+ }
381
+ });
382
+
383
+ if (filter) {
384
+ preventOnFilter && evt.preventDefault();
385
+ return; // cancel dnd
386
+ }
387
+ }
388
+
389
+ if (options.handle && !_closest(originalTarget, options.handle, el)) {
390
+ return;
391
+ }
392
+
393
+ // Prepare `dragstart`
394
+ this._prepareDragStart(evt, touch, target, startIndex);
395
+ },
396
+
397
+ _prepareDragStart: function (/** Event */evt, /** Touch */touch, /** HTMLElement */target, /** Number */startIndex) {
398
+ var _this = this,
399
+ el = _this.el,
400
+ options = _this.options,
401
+ ownerDocument = el.ownerDocument,
402
+ dragStartFn;
403
+
404
+ if (target && !dragEl && (target.parentNode === el)) {
405
+ tapEvt = evt;
406
+
407
+ rootEl = el;
408
+ dragEl = target;
409
+ parentEl = dragEl.parentNode;
410
+ nextEl = dragEl.nextSibling;
411
+ lastDownEl = target;
412
+ activeGroup = options.group;
413
+ oldIndex = startIndex;
414
+
415
+ this._lastX = (touch || evt).clientX;
416
+ this._lastY = (touch || evt).clientY;
417
+
418
+ dragEl.style['will-change'] = 'all';
419
+
420
+ dragStartFn = function () {
421
+ // Delayed drag has been triggered
422
+ // we can re-enable the events: touchmove/mousemove
423
+ _this._disableDelayedDrag();
424
+
425
+ // Make the element draggable
426
+ dragEl.draggable = _this.nativeDraggable;
427
+
428
+ // Chosen item
429
+ _toggleClass(dragEl, options.chosenClass, true);
430
+
431
+ // Bind the events: dragstart/dragend
432
+ _this._triggerDragStart(evt, touch);
433
+
434
+ // Drag start event
435
+ _dispatchEvent(_this, rootEl, 'choose', dragEl, rootEl, rootEl, oldIndex);
436
+ };
437
+
438
+ // Disable "draggable"
439
+ options.ignore.split(',').forEach(function (criteria) {
440
+ _find(dragEl, criteria.trim(), _disableDraggable);
441
+ });
442
+
443
+ _on(ownerDocument, 'mouseup', _this._onDrop);
444
+ _on(ownerDocument, 'touchend', _this._onDrop);
445
+ _on(ownerDocument, 'touchcancel', _this._onDrop);
446
+ _on(ownerDocument, 'selectstart', _this);
447
+ options.supportPointer && _on(ownerDocument, 'pointercancel', _this._onDrop);
448
+
449
+ if (options.delay) {
450
+ // If the user moves the pointer or let go the click or touch
451
+ // before the delay has been reached:
452
+ // disable the delayed drag
453
+ _on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
454
+ _on(ownerDocument, 'touchend', _this._disableDelayedDrag);
455
+ _on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
456
+ _on(ownerDocument, 'mousemove', _this._disableDelayedDrag);
457
+ _on(ownerDocument, 'touchmove', _this._disableDelayedDrag);
458
+ options.supportPointer && _on(ownerDocument, 'pointermove', _this._disableDelayedDrag);
459
+
460
+ _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
461
+ } else {
462
+ dragStartFn();
463
+ }
464
+
465
+
466
+ }
467
+ },
468
+
469
+ _disableDelayedDrag: function () {
470
+ var ownerDocument = this.el.ownerDocument;
471
+
472
+ clearTimeout(this._dragStartTimer);
473
+ _off(ownerDocument, 'mouseup', this._disableDelayedDrag);
474
+ _off(ownerDocument, 'touchend', this._disableDelayedDrag);
475
+ _off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
476
+ _off(ownerDocument, 'mousemove', this._disableDelayedDrag);
477
+ _off(ownerDocument, 'touchmove', this._disableDelayedDrag);
478
+ _off(ownerDocument, 'pointermove', this._disableDelayedDrag);
479
+ },
480
+
481
+ _triggerDragStart: function (/** Event */evt, /** Touch */touch) {
482
+ touch = touch || (evt.pointerType == 'touch' ? evt : null);
483
+
484
+ if (touch) {
485
+ // Touch device support
486
+ tapEvt = {
487
+ target: dragEl,
488
+ clientX: touch.clientX,
489
+ clientY: touch.clientY
490
+ };
491
+
492
+ this._onDragStart(tapEvt, 'touch');
493
+ }
494
+ else if (!this.nativeDraggable) {
495
+ this._onDragStart(tapEvt, true);
496
+ }
497
+ else {
498
+ _on(dragEl, 'dragend', this);
499
+ _on(rootEl, 'dragstart', this._onDragStart);
500
+ }
501
+
502
+ try {
503
+ if (document.selection) {
504
+ // Timeout neccessary for IE9
505
+ _nextTick(function () {
506
+ document.selection.empty();
507
+ });
508
+ } else {
509
+ window.getSelection().removeAllRanges();
510
+ }
511
+ } catch (err) {
512
+ }
513
+ },
514
+
515
+ _dragStarted: function () {
516
+ if (rootEl && dragEl) {
517
+ var options = this.options;
518
+
519
+ // Apply effect
520
+ _toggleClass(dragEl, options.ghostClass, true);
521
+ _toggleClass(dragEl, options.dragClass, false);
522
+
523
+ Sortable.active = this;
524
+
525
+ // Drag start event
526
+ _dispatchEvent(this, rootEl, 'start', dragEl, rootEl, rootEl, oldIndex);
527
+ } else {
528
+ this._nulling();
529
+ }
530
+ },
531
+
532
+ _emulateDragOver: function () {
533
+ if (touchEvt) {
534
+ if (this._lastX === touchEvt.clientX && this._lastY === touchEvt.clientY) {
535
+ return;
536
+ }
537
+
538
+ this._lastX = touchEvt.clientX;
539
+ this._lastY = touchEvt.clientY;
540
+
541
+ if (!supportCssPointerEvents) {
542
+ _css(ghostEl, 'display', 'none');
543
+ }
544
+
545
+ var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
546
+ var parent = target;
547
+ var i = touchDragOverListeners.length;
548
+
549
+ if (target && target.shadowRoot) {
550
+ target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
551
+ parent = target;
552
+ }
553
+
554
+ if (parent) {
555
+ do {
556
+ if (parent[expando]) {
557
+ while (i--) {
558
+ touchDragOverListeners[i]({
559
+ clientX: touchEvt.clientX,
560
+ clientY: touchEvt.clientY,
561
+ target: target,
562
+ rootEl: parent
563
+ });
564
+ }
565
+
566
+ break;
567
+ }
568
+
569
+ target = parent; // store last element
570
+ }
571
+ /* jshint boss:true */
572
+ while (parent = parent.parentNode);
573
+ }
574
+
575
+ if (!supportCssPointerEvents) {
576
+ _css(ghostEl, 'display', '');
577
+ }
578
+ }
579
+ },
580
+
581
+
582
+ _onTouchMove: function (/**TouchEvent*/evt) {
583
+ if (tapEvt) {
584
+ var options = this.options,
585
+ fallbackTolerance = options.fallbackTolerance,
586
+ fallbackOffset = options.fallbackOffset,
587
+ touch = evt.touches ? evt.touches[0] : evt,
588
+ dx = (touch.clientX - tapEvt.clientX) + fallbackOffset.x,
589
+ dy = (touch.clientY - tapEvt.clientY) + fallbackOffset.y,
590
+ translate3d = evt.touches ? 'translate3d(' + dx + 'px,' + dy + 'px,0)' : 'translate(' + dx + 'px,' + dy + 'px)';
591
+
592
+ // only set the status to dragging, when we are actually dragging
593
+ if (!Sortable.active) {
594
+ if (fallbackTolerance &&
595
+ min(abs(touch.clientX - this._lastX), abs(touch.clientY - this._lastY)) < fallbackTolerance
596
+ ) {
597
+ return;
598
+ }
599
+
600
+ this._dragStarted();
601
+ }
602
+
603
+ // as well as creating the ghost element on the document body
604
+ this._appendGhost();
605
+
606
+ moved = true;
607
+ touchEvt = touch;
608
+
609
+ _css(ghostEl, 'webkitTransform', translate3d);
610
+ _css(ghostEl, 'mozTransform', translate3d);
611
+ _css(ghostEl, 'msTransform', translate3d);
612
+ _css(ghostEl, 'transform', translate3d);
613
+
614
+ evt.preventDefault();
615
+ }
616
+ },
617
+
618
+ _appendGhost: function () {
619
+ if (!ghostEl) {
620
+ var rect = dragEl.getBoundingClientRect(),
621
+ css = _css(dragEl),
622
+ options = this.options,
623
+ ghostRect;
624
+
625
+ ghostEl = dragEl.cloneNode(true);
626
+
627
+ _toggleClass(ghostEl, options.ghostClass, false);
628
+ _toggleClass(ghostEl, options.fallbackClass, true);
629
+ _toggleClass(ghostEl, options.dragClass, true);
630
+
631
+ _css(ghostEl, 'top', rect.top - parseInt(css.marginTop, 10));
632
+ _css(ghostEl, 'left', rect.left - parseInt(css.marginLeft, 10));
633
+ _css(ghostEl, 'width', rect.width);
634
+ _css(ghostEl, 'height', rect.height);
635
+ _css(ghostEl, 'opacity', '0.8');
636
+ _css(ghostEl, 'position', 'fixed');
637
+ _css(ghostEl, 'zIndex', '100000');
638
+ _css(ghostEl, 'pointerEvents', 'none');
639
+
640
+ options.fallbackOnBody && document.body.appendChild(ghostEl) || rootEl.appendChild(ghostEl);
641
+
642
+ // Fixing dimensions.
643
+ ghostRect = ghostEl.getBoundingClientRect();
644
+ _css(ghostEl, 'width', rect.width * 2 - ghostRect.width);
645
+ _css(ghostEl, 'height', rect.height * 2 - ghostRect.height);
646
+ }
647
+ },
648
+
649
+ _onDragStart: function (/**Event*/evt, /**boolean*/useFallback) {
650
+ var _this = this;
651
+ var dataTransfer = evt.dataTransfer;
652
+ var options = _this.options;
653
+
654
+ _this._offUpEvents();
655
+
656
+ if (activeGroup.checkPull(_this, _this, dragEl, evt)) {
657
+ cloneEl = _clone(dragEl);
658
+
659
+ cloneEl.draggable = false;
660
+ cloneEl.style['will-change'] = '';
661
+
662
+ _css(cloneEl, 'display', 'none');
663
+ _toggleClass(cloneEl, _this.options.chosenClass, false);
664
+
665
+ // #1143: IFrame support workaround
666
+ _this._cloneId = _nextTick(function () {
667
+ rootEl.insertBefore(cloneEl, dragEl);
668
+ _dispatchEvent(_this, rootEl, 'clone', dragEl);
669
+ });
670
+ }
671
+
672
+ _toggleClass(dragEl, options.dragClass, true);
673
+
674
+ if (useFallback) {
675
+ if (useFallback === 'touch') {
676
+ // Bind touch events
677
+ _on(document, 'touchmove', _this._onTouchMove);
678
+ _on(document, 'touchend', _this._onDrop);
679
+ _on(document, 'touchcancel', _this._onDrop);
680
+
681
+ if (options.supportPointer) {
682
+ _on(document, 'pointermove', _this._onTouchMove);
683
+ _on(document, 'pointerup', _this._onDrop);
684
+ }
685
+ } else {
686
+ // Old brwoser
687
+ _on(document, 'mousemove', _this._onTouchMove);
688
+ _on(document, 'mouseup', _this._onDrop);
689
+ }
690
+
691
+ _this._loopId = setInterval(_this._emulateDragOver, 50);
692
+ }
693
+ else {
694
+ if (dataTransfer) {
695
+ dataTransfer.effectAllowed = 'move';
696
+ options.setData && options.setData.call(_this, dataTransfer, dragEl);
697
+ }
698
+
699
+ _on(document, 'drop', _this);
700
+
701
+ // #1143: Бывает элемент с IFrame внутри блокирует `drop`,
702
+ // поэтому если вызвался `mouseover`, значит надо отменять весь d'n'd.
703
+ // Breaking Chrome 62+
704
+ // _on(document, 'mouseover', _this);
705
+
706
+ _this._dragStartId = _nextTick(_this._dragStarted);
707
+ }
708
+ },
709
+
710
+ _onDragOver: function (/**Event*/evt) {
711
+ var el = this.el,
712
+ target,
713
+ dragRect,
714
+ targetRect,
715
+ revert,
716
+ options = this.options,
717
+ group = options.group,
718
+ activeSortable = Sortable.active,
719
+ isOwner = (activeGroup === group),
720
+ isMovingBetweenSortable = false,
721
+ canSort = options.sort;
722
+
723
+ if (evt.preventDefault !== void 0) {
724
+ evt.preventDefault();
725
+ !options.dragoverBubble && evt.stopPropagation();
726
+ }
727
+
728
+ if (dragEl.animated) {
729
+ return;
730
+ }
731
+
732
+ moved = true;
733
+
734
+ if (activeSortable && !options.disabled &&
735
+ (isOwner
736
+ ? canSort || (revert = !rootEl.contains(dragEl)) // Reverting item into the original list
737
+ : (
738
+ putSortable === this ||
739
+ (
740
+ (activeSortable.lastPullMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) &&
741
+ group.checkPut(this, activeSortable, dragEl, evt)
742
+ )
743
+ )
744
+ ) &&
745
+ (evt.rootEl === void 0 || evt.rootEl === this.el) // touch fallback
746
+ ) {
747
+ // Smart auto-scrolling
748
+ _autoScroll(evt, options, this.el);
749
+
750
+ if (_silent) {
751
+ return;
752
+ }
753
+
754
+ target = _closest(evt.target, options.draggable, el);
755
+ dragRect = dragEl.getBoundingClientRect();
756
+
757
+ if (putSortable !== this) {
758
+ putSortable = this;
759
+ isMovingBetweenSortable = true;
760
+ }
761
+
762
+ if (revert) {
763
+ _cloneHide(activeSortable, true);
764
+ parentEl = rootEl; // actualization
765
+
766
+ if (cloneEl || nextEl) {
767
+ rootEl.insertBefore(dragEl, cloneEl || nextEl);
768
+ }
769
+ else if (!canSort) {
770
+ rootEl.appendChild(dragEl);
771
+ }
772
+
773
+ return;
774
+ }
775
+
776
+
777
+ if ((el.children.length === 0) || (el.children[0] === ghostEl) ||
778
+ (el === evt.target) && (_ghostIsLast(el, evt))
779
+ ) {
780
+ //assign target only if condition is true
781
+ if (el.children.length !== 0 && el.children[0] !== ghostEl && el === evt.target) {
782
+ target = el.lastElementChild;
783
+ }
784
+
785
+ if (target) {
786
+ if (target.animated) {
787
+ return;
788
+ }
789
+
790
+ targetRect = target.getBoundingClientRect();
791
+ }
792
+
793
+ _cloneHide(activeSortable, isOwner);
794
+
795
+ if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt) !== false) {
796
+ if (!dragEl.contains(el)) {
797
+ el.appendChild(dragEl);
798
+ parentEl = el; // actualization
799
+ }
800
+
801
+ this._animate(dragRect, dragEl);
802
+ target && this._animate(targetRect, target);
803
+ }
804
+ }
805
+ else if (target && !target.animated && target !== dragEl && (target.parentNode[expando] !== void 0)) {
806
+ if (lastEl !== target) {
807
+ lastEl = target;
808
+ lastCSS = _css(target);
809
+ lastParentCSS = _css(target.parentNode);
810
+ }
811
+
812
+ targetRect = target.getBoundingClientRect();
813
+
814
+ var width = targetRect.right - targetRect.left,
815
+ height = targetRect.bottom - targetRect.top,
816
+ floating = R_FLOAT.test(lastCSS.cssFloat + lastCSS.display)
817
+ || (lastParentCSS.display == 'flex' && lastParentCSS['flex-direction'].indexOf('row') === 0),
818
+ isWide = (target.offsetWidth > dragEl.offsetWidth),
819
+ isLong = (target.offsetHeight > dragEl.offsetHeight),
820
+ halfway = (floating ? (evt.clientX - targetRect.left) / width : (evt.clientY - targetRect.top) / height) > 0.5,
821
+ nextSibling = target.nextElementSibling,
822
+ after = false
823
+ ;
824
+
825
+ if (floating) {
826
+ var elTop = dragEl.offsetTop,
827
+ tgTop = target.offsetTop;
828
+
829
+ if (elTop === tgTop) {
830
+ after = (target.previousElementSibling === dragEl) && !isWide || halfway && isWide;
831
+ }
832
+ else if (target.previousElementSibling === dragEl || dragEl.previousElementSibling === target) {
833
+ after = (evt.clientY - targetRect.top) / height > 0.5;
834
+ } else {
835
+ after = tgTop > elTop;
836
+ }
837
+ } else if (!isMovingBetweenSortable) {
838
+ after = (nextSibling !== dragEl) && !isLong || halfway && isLong;
839
+ }
840
+
841
+ var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
842
+
843
+ if (moveVector !== false) {
844
+ if (moveVector === 1 || moveVector === -1) {
845
+ after = (moveVector === 1);
846
+ }
847
+
848
+ _silent = true;
849
+ setTimeout(_unsilent, 30);
850
+
851
+ _cloneHide(activeSortable, isOwner);
852
+
853
+ if (!dragEl.contains(el)) {
854
+ if (after && !nextSibling) {
855
+ el.appendChild(dragEl);
856
+ } else {
857
+ target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
858
+ }
859
+ }
860
+
861
+ parentEl = dragEl.parentNode; // actualization
862
+
863
+ this._animate(dragRect, dragEl);
864
+ this._animate(targetRect, target);
865
+ }
866
+ }
867
+ }
868
+ },
869
+
870
+ _animate: function (prevRect, target) {
871
+ var ms = this.options.animation;
872
+
873
+ if (ms) {
874
+ var currentRect = target.getBoundingClientRect();
875
+
876
+ if (prevRect.nodeType === 1) {
877
+ prevRect = prevRect.getBoundingClientRect();
878
+ }
879
+
880
+ _css(target, 'transition', 'none');
881
+ _css(target, 'transform', 'translate3d('
882
+ + (prevRect.left - currentRect.left) + 'px,'
883
+ + (prevRect.top - currentRect.top) + 'px,0)'
884
+ );
885
+
886
+ target.offsetWidth; // repaint
887
+
888
+ _css(target, 'transition', 'all ' + ms + 'ms');
889
+ _css(target, 'transform', 'translate3d(0,0,0)');
890
+
891
+ clearTimeout(target.animated);
892
+ target.animated = setTimeout(function () {
893
+ _css(target, 'transition', '');
894
+ _css(target, 'transform', '');
895
+ target.animated = false;
896
+ }, ms);
897
+ }
898
+ },
899
+
900
+ _offUpEvents: function () {
901
+ var ownerDocument = this.el.ownerDocument;
902
+
903
+ _off(document, 'touchmove', this._onTouchMove);
904
+ _off(document, 'pointermove', this._onTouchMove);
905
+ _off(ownerDocument, 'mouseup', this._onDrop);
906
+ _off(ownerDocument, 'touchend', this._onDrop);
907
+ _off(ownerDocument, 'pointerup', this._onDrop);
908
+ _off(ownerDocument, 'touchcancel', this._onDrop);
909
+ _off(ownerDocument, 'pointercancel', this._onDrop);
910
+ _off(ownerDocument, 'selectstart', this);
911
+ },
912
+
913
+ _onDrop: function (/**Event*/evt) {
914
+ var el = this.el,
915
+ options = this.options;
916
+
917
+ clearInterval(this._loopId);
918
+ clearInterval(autoScroll.pid);
919
+ clearTimeout(this._dragStartTimer);
920
+
921
+ _cancelNextTick(this._cloneId);
922
+ _cancelNextTick(this._dragStartId);
923
+
924
+ // Unbind events
925
+ _off(document, 'mouseover', this);
926
+ _off(document, 'mousemove', this._onTouchMove);
927
+
928
+ if (this.nativeDraggable) {
929
+ _off(document, 'drop', this);
930
+ _off(el, 'dragstart', this._onDragStart);
931
+ }
932
+
933
+ this._offUpEvents();
934
+
935
+ if (evt) {
936
+ if (moved) {
937
+ evt.preventDefault();
938
+ !options.dropBubble && evt.stopPropagation();
939
+ }
940
+
941
+ ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
942
+
943
+ if (rootEl === parentEl || Sortable.active.lastPullMode !== 'clone') {
944
+ // Remove clone
945
+ cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
946
+ }
947
+
948
+ if (dragEl) {
949
+ if (this.nativeDraggable) {
950
+ _off(dragEl, 'dragend', this);
951
+ }
952
+
953
+ _disableDraggable(dragEl);
954
+ dragEl.style['will-change'] = '';
955
+
956
+ // Remove class's
957
+ _toggleClass(dragEl, this.options.ghostClass, false);
958
+ _toggleClass(dragEl, this.options.chosenClass, false);
959
+
960
+ // Drag stop event
961
+ _dispatchEvent(this, rootEl, 'unchoose', dragEl, parentEl, rootEl, oldIndex);
962
+
963
+ if (rootEl !== parentEl) {
964
+ newIndex = _index(dragEl, options.draggable);
965
+
966
+ if (newIndex >= 0) {
967
+ // Add event
968
+ _dispatchEvent(null, parentEl, 'add', dragEl, parentEl, rootEl, oldIndex, newIndex);
969
+
970
+ // Remove event
971
+ _dispatchEvent(this, rootEl, 'remove', dragEl, parentEl, rootEl, oldIndex, newIndex);
972
+
973
+ // drag from one list and drop into another
974
+ _dispatchEvent(null, parentEl, 'sort', dragEl, parentEl, rootEl, oldIndex, newIndex);
975
+ _dispatchEvent(this, rootEl, 'sort', dragEl, parentEl, rootEl, oldIndex, newIndex);
976
+ }
977
+ }
978
+ else {
979
+ if (dragEl.nextSibling !== nextEl) {
980
+ // Get the index of the dragged element within its parent
981
+ newIndex = _index(dragEl, options.draggable);
982
+
983
+ if (newIndex >= 0) {
984
+ // drag & drop within the same list
985
+ _dispatchEvent(this, rootEl, 'update', dragEl, parentEl, rootEl, oldIndex, newIndex);
986
+ _dispatchEvent(this, rootEl, 'sort', dragEl, parentEl, rootEl, oldIndex, newIndex);
987
+ }
988
+ }
989
+ }
990
+
991
+ if (Sortable.active) {
992
+ /* jshint eqnull:true */
993
+ if (newIndex == null || newIndex === -1) {
994
+ newIndex = oldIndex;
995
+ }
996
+
997
+ _dispatchEvent(this, rootEl, 'end', dragEl, parentEl, rootEl, oldIndex, newIndex);
998
+
999
+ // Save sorting
1000
+ this.save();
1001
+ }
1002
+ }
1003
+
1004
+ }
1005
+
1006
+ this._nulling();
1007
+ },
1008
+
1009
+ _nulling: function() {
1010
+ rootEl =
1011
+ dragEl =
1012
+ parentEl =
1013
+ ghostEl =
1014
+ nextEl =
1015
+ cloneEl =
1016
+ lastDownEl =
1017
+
1018
+ scrollEl =
1019
+ scrollParentEl =
1020
+
1021
+ tapEvt =
1022
+ touchEvt =
1023
+
1024
+ moved =
1025
+ newIndex =
1026
+
1027
+ lastEl =
1028
+ lastCSS =
1029
+
1030
+ putSortable =
1031
+ activeGroup =
1032
+ Sortable.active = null;
1033
+
1034
+ savedInputChecked.forEach(function (el) {
1035
+ el.checked = true;
1036
+ });
1037
+ savedInputChecked.length = 0;
1038
+ },
1039
+
1040
+ handleEvent: function (/**Event*/evt) {
1041
+ switch (evt.type) {
1042
+ case 'drop':
1043
+ case 'dragend':
1044
+ this._onDrop(evt);
1045
+ break;
1046
+
1047
+ case 'dragover':
1048
+ case 'dragenter':
1049
+ if (dragEl) {
1050
+ this._onDragOver(evt);
1051
+ _globalDragOver(evt);
1052
+ }
1053
+ break;
1054
+
1055
+ case 'mouseover':
1056
+ this._onDrop(evt);
1057
+ break;
1058
+
1059
+ case 'selectstart':
1060
+ evt.preventDefault();
1061
+ break;
1062
+ }
1063
+ },
1064
+
1065
+
1066
+ /**
1067
+ * Serializes the item into an array of string.
1068
+ * @returns {String[]}
1069
+ */
1070
+ toArray: function () {
1071
+ var order = [],
1072
+ el,
1073
+ children = this.el.children,
1074
+ i = 0,
1075
+ n = children.length,
1076
+ options = this.options;
1077
+
1078
+ for (; i < n; i++) {
1079
+ el = children[i];
1080
+ if (_closest(el, options.draggable, this.el)) {
1081
+ order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
1082
+ }
1083
+ }
1084
+
1085
+ return order;
1086
+ },
1087
+
1088
+
1089
+ /**
1090
+ * Sorts the elements according to the array.
1091
+ * @param {String[]} order order of the items
1092
+ */
1093
+ sort: function (order) {
1094
+ var items = {}, rootEl = this.el;
1095
+
1096
+ this.toArray().forEach(function (id, i) {
1097
+ var el = rootEl.children[i];
1098
+
1099
+ if (_closest(el, this.options.draggable, rootEl)) {
1100
+ items[id] = el;
1101
+ }
1102
+ }, this);
1103
+
1104
+ order.forEach(function (id) {
1105
+ if (items[id]) {
1106
+ rootEl.removeChild(items[id]);
1107
+ rootEl.appendChild(items[id]);
1108
+ }
1109
+ });
1110
+ },
1111
+
1112
+
1113
+ /**
1114
+ * Save the current sorting
1115
+ */
1116
+ save: function () {
1117
+ var store = this.options.store;
1118
+ store && store.set(this);
1119
+ },
1120
+
1121
+
1122
+ /**
1123
+ * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
1124
+ * @param {HTMLElement} el
1125
+ * @param {String} [selector] default: `options.draggable`
1126
+ * @returns {HTMLElement|null}
1127
+ */
1128
+ closest: function (el, selector) {
1129
+ return _closest(el, selector || this.options.draggable, this.el);
1130
+ },
1131
+
1132
+
1133
+ /**
1134
+ * Set/get option
1135
+ * @param {string} name
1136
+ * @param {*} [value]
1137
+ * @returns {*}
1138
+ */
1139
+ option: function (name, value) {
1140
+ var options = this.options;
1141
+
1142
+ if (value === void 0) {
1143
+ return options[name];
1144
+ } else {
1145
+ options[name] = value;
1146
+
1147
+ if (name === 'group') {
1148
+ _prepareGroup(options);
1149
+ }
1150
+ }
1151
+ },
1152
+
1153
+
1154
+ /**
1155
+ * Destroy
1156
+ */
1157
+ destroy: function () {
1158
+ var el = this.el;
1159
+
1160
+ el[expando] = null;
1161
+
1162
+ _off(el, 'mousedown', this._onTapStart);
1163
+ _off(el, 'touchstart', this._onTapStart);
1164
+ _off(el, 'pointerdown', this._onTapStart);
1165
+
1166
+ if (this.nativeDraggable) {
1167
+ _off(el, 'dragover', this);
1168
+ _off(el, 'dragenter', this);
1169
+ }
1170
+
1171
+ // Remove draggable attributes
1172
+ Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {
1173
+ el.removeAttribute('draggable');
1174
+ });
1175
+
1176
+ touchDragOverListeners.splice(touchDragOverListeners.indexOf(this._onDragOver), 1);
1177
+
1178
+ this._onDrop();
1179
+
1180
+ this.el = el = null;
1181
+ }
1182
+ };
1183
+
1184
+
1185
+ function _cloneHide(sortable, state) {
1186
+ if (sortable.lastPullMode !== 'clone') {
1187
+ state = true;
1188
+ }
1189
+
1190
+ if (cloneEl && (cloneEl.state !== state)) {
1191
+ _css(cloneEl, 'display', state ? 'none' : '');
1192
+
1193
+ if (!state) {
1194
+ if (cloneEl.state) {
1195
+ if (sortable.options.group.revertClone) {
1196
+ rootEl.insertBefore(cloneEl, nextEl);
1197
+ sortable._animate(dragEl, cloneEl);
1198
+ } else {
1199
+ rootEl.insertBefore(cloneEl, dragEl);
1200
+ }
1201
+ }
1202
+ }
1203
+
1204
+ cloneEl.state = state;
1205
+ }
1206
+ }
1207
+
1208
+
1209
+ function _closest(/**HTMLElement*/el, /**String*/selector, /**HTMLElement*/ctx) {
1210
+ if (el) {
1211
+ ctx = ctx || document;
1212
+
1213
+ do {
1214
+ if ((selector === '>*' && el.parentNode === ctx) || _matches(el, selector)) {
1215
+ return el;
1216
+ }
1217
+ /* jshint boss:true */
1218
+ } while (el = _getParentOrHost(el));
1219
+ }
1220
+
1221
+ return null;
1222
+ }
1223
+
1224
+
1225
+ function _getParentOrHost(el) {
1226
+ var parent = el.host;
1227
+
1228
+ return (parent && parent.nodeType) ? parent : el.parentNode;
1229
+ }
1230
+
1231
+
1232
+ function _globalDragOver(/**Event*/evt) {
1233
+ if (evt.dataTransfer) {
1234
+ evt.dataTransfer.dropEffect = 'move';
1235
+ }
1236
+ evt.preventDefault();
1237
+ }
1238
+
1239
+
1240
+ function _on(el, event, fn) {
1241
+ el.addEventListener(event, fn, captureMode);
1242
+ }
1243
+
1244
+
1245
+ function _off(el, event, fn) {
1246
+ el.removeEventListener(event, fn, captureMode);
1247
+ }
1248
+
1249
+
1250
+ function _toggleClass(el, name, state) {
1251
+ if (el) {
1252
+ if (el.classList) {
1253
+ el.classList[state ? 'add' : 'remove'](name);
1254
+ }
1255
+ else {
1256
+ var className = (' ' + el.className + ' ').replace(R_SPACE, ' ').replace(' ' + name + ' ', ' ');
1257
+ el.className = (className + (state ? ' ' + name : '')).replace(R_SPACE, ' ');
1258
+ }
1259
+ }
1260
+ }
1261
+
1262
+
1263
+ function _css(el, prop, val) {
1264
+ var style = el && el.style;
1265
+
1266
+ if (style) {
1267
+ if (val === void 0) {
1268
+ if (document.defaultView && document.defaultView.getComputedStyle) {
1269
+ val = document.defaultView.getComputedStyle(el, '');
1270
+ }
1271
+ else if (el.currentStyle) {
1272
+ val = el.currentStyle;
1273
+ }
1274
+
1275
+ return prop === void 0 ? val : val[prop];
1276
+ }
1277
+ else {
1278
+ if (!(prop in style)) {
1279
+ prop = '-webkit-' + prop;
1280
+ }
1281
+
1282
+ style[prop] = val + (typeof val === 'string' ? '' : 'px');
1283
+ }
1284
+ }
1285
+ }
1286
+
1287
+
1288
+ function _find(ctx, tagName, iterator) {
1289
+ if (ctx) {
1290
+ var list = ctx.getElementsByTagName(tagName), i = 0, n = list.length;
1291
+
1292
+ if (iterator) {
1293
+ for (; i < n; i++) {
1294
+ iterator(list[i], i);
1295
+ }
1296
+ }
1297
+
1298
+ return list;
1299
+ }
1300
+
1301
+ return [];
1302
+ }
1303
+
1304
+
1305
+
1306
+ function _dispatchEvent(sortable, rootEl, name, targetEl, toEl, fromEl, startIndex, newIndex) {
1307
+ sortable = (sortable || rootEl[expando]);
1308
+
1309
+ var evt = document.createEvent('Event'),
1310
+ options = sortable.options,
1311
+ onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1);
1312
+
1313
+ evt.initEvent(name, true, true);
1314
+
1315
+ evt.to = toEl || rootEl;
1316
+ evt.from = fromEl || rootEl;
1317
+ evt.item = targetEl || rootEl;
1318
+ evt.clone = cloneEl;
1319
+
1320
+ evt.oldIndex = startIndex;
1321
+ evt.newIndex = newIndex;
1322
+
1323
+ rootEl.dispatchEvent(evt);
1324
+
1325
+ if (options[onName]) {
1326
+ options[onName].call(sortable, evt);
1327
+ }
1328
+ }
1329
+
1330
+
1331
+ function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvt, willInsertAfter) {
1332
+ var evt,
1333
+ sortable = fromEl[expando],
1334
+ onMoveFn = sortable.options.onMove,
1335
+ retVal;
1336
+
1337
+ evt = document.createEvent('Event');
1338
+ evt.initEvent('move', true, true);
1339
+
1340
+ evt.to = toEl;
1341
+ evt.from = fromEl;
1342
+ evt.dragged = dragEl;
1343
+ evt.draggedRect = dragRect;
1344
+ evt.related = targetEl || toEl;
1345
+ evt.relatedRect = targetRect || toEl.getBoundingClientRect();
1346
+ evt.willInsertAfter = willInsertAfter;
1347
+
1348
+ fromEl.dispatchEvent(evt);
1349
+
1350
+ if (onMoveFn) {
1351
+ retVal = onMoveFn.call(sortable, evt, originalEvt);
1352
+ }
1353
+
1354
+ return retVal;
1355
+ }
1356
+
1357
+
1358
+ function _disableDraggable(el) {
1359
+ el.draggable = false;
1360
+ }
1361
+
1362
+
1363
+ function _unsilent() {
1364
+ _silent = false;
1365
+ }
1366
+
1367
+
1368
+ /** @returns {HTMLElement|false} */
1369
+ function _ghostIsLast(el, evt) {
1370
+ var lastEl = el.lastElementChild,
1371
+ rect = lastEl.getBoundingClientRect();
1372
+
1373
+ // 5 — min delta
1374
+ // abs — нельзя добавлять, а то глюки при наведении сверху
1375
+ return (evt.clientY - (rect.top + rect.height) > 5) ||
1376
+ (evt.clientX - (rect.left + rect.width) > 5);
1377
+ }
1378
+
1379
+
1380
+ /**
1381
+ * Generate id
1382
+ * @param {HTMLElement} el
1383
+ * @returns {String}
1384
+ * @private
1385
+ */
1386
+ function _generateId(el) {
1387
+ var str = el.tagName + el.className + el.src + el.href + el.textContent,
1388
+ i = str.length,
1389
+ sum = 0;
1390
+
1391
+ while (i--) {
1392
+ sum += str.charCodeAt(i);
1393
+ }
1394
+
1395
+ return sum.toString(36);
1396
+ }
1397
+
1398
+ /**
1399
+ * Returns the index of an element within its parent for a selected set of
1400
+ * elements
1401
+ * @param {HTMLElement} el
1402
+ * @param {selector} selector
1403
+ * @return {number}
1404
+ */
1405
+ function _index(el, selector) {
1406
+ var index = 0;
1407
+
1408
+ if (!el || !el.parentNode) {
1409
+ return -1;
1410
+ }
1411
+
1412
+ while (el && (el = el.previousElementSibling)) {
1413
+ if ((el.nodeName.toUpperCase() !== 'TEMPLATE') && (selector === '>*' || _matches(el, selector))) {
1414
+ index++;
1415
+ }
1416
+ }
1417
+
1418
+ return index;
1419
+ }
1420
+
1421
+ function _matches(/**HTMLElement*/el, /**String*/selector) {
1422
+ if (el) {
1423
+ selector = selector.split('.');
1424
+
1425
+ var tag = selector.shift().toUpperCase(),
1426
+ re = new RegExp('\\s(' + selector.join('|') + ')(?=\\s)', 'g');
1427
+
1428
+ return (
1429
+ (tag === '' || el.nodeName.toUpperCase() == tag) &&
1430
+ (!selector.length || ((' ' + el.className + ' ').match(re) || []).length == selector.length)
1431
+ );
1432
+ }
1433
+
1434
+ return false;
1435
+ }
1436
+
1437
+ function _throttle(callback, ms) {
1438
+ var args, _this;
1439
+
1440
+ return function () {
1441
+ if (args === void 0) {
1442
+ args = arguments;
1443
+ _this = this;
1444
+
1445
+ setTimeout(function () {
1446
+ if (args.length === 1) {
1447
+ callback.call(_this, args[0]);
1448
+ } else {
1449
+ callback.apply(_this, args);
1450
+ }
1451
+
1452
+ args = void 0;
1453
+ }, ms);
1454
+ }
1455
+ };
1456
+ }
1457
+
1458
+ function _extend(dst, src) {
1459
+ if (dst && src) {
1460
+ for (var key in src) {
1461
+ if (src.hasOwnProperty(key)) {
1462
+ dst[key] = src[key];
1463
+ }
1464
+ }
1465
+ }
1466
+
1467
+ return dst;
1468
+ }
1469
+
1470
+ function _clone(el) {
1471
+ if (Polymer && Polymer.dom) {
1472
+ return Polymer.dom(el).cloneNode(true);
1473
+ }
1474
+ else if ($) {
1475
+ return $(el).clone(true)[0];
1476
+ }
1477
+ else {
1478
+ return el.cloneNode(true);
1479
+ }
1480
+ }
1481
+
1482
+ function _saveInputCheckedState(root) {
1483
+ var inputs = root.getElementsByTagName('input');
1484
+ var idx = inputs.length;
1485
+
1486
+ while (idx--) {
1487
+ var el = inputs[idx];
1488
+ el.checked && savedInputChecked.push(el);
1489
+ }
1490
+ }
1491
+
1492
+ function _nextTick(fn) {
1493
+ return setTimeout(fn, 0);
1494
+ }
1495
+
1496
+ function _cancelNextTick(id) {
1497
+ return clearTimeout(id);
1498
+ }
1499
+
1500
+ // Fixed #973:
1501
+ _on(document, 'touchmove', function (evt) {
1502
+ if (Sortable.active) {
1503
+ evt.preventDefault();
1504
+ }
1505
+ });
1506
+
1507
+ // Export utils
1508
+ Sortable.utils = {
1509
+ on: _on,
1510
+ off: _off,
1511
+ css: _css,
1512
+ find: _find,
1513
+ is: function (el, selector) {
1514
+ return !!_closest(el, selector, el);
1515
+ },
1516
+ extend: _extend,
1517
+ throttle: _throttle,
1518
+ closest: _closest,
1519
+ toggleClass: _toggleClass,
1520
+ clone: _clone,
1521
+ index: _index,
1522
+ nextTick: _nextTick,
1523
+ cancelNextTick: _cancelNextTick
1524
+ };
1525
+
1526
+
1527
+ /**
1528
+ * Create sortable instance
1529
+ * @param {HTMLElement} el
1530
+ * @param {Object} [options]
1531
+ */
1532
+ Sortable.create = function (el, options) {
1533
+ return new Sortable(el, options);
1534
+ };
1535
+
1536
+
1537
+ // Export
1538
+ Sortable.version = '1.7.0';
1539
+ return Sortable;
1540
+ });