caboose-cms 0.7.85 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/caboose/{admin_edit_order.js → admin_edit_invoice.js} +332 -189
  3. data/app/assets/javascripts/caboose/cart.js +15 -15
  4. data/app/assets/javascripts/caboose/cart_old.js +2 -2
  5. data/app/assets/javascripts/caboose/checkout/authnet_payment_method_controller.js +120 -0
  6. data/app/assets/javascripts/caboose/checkout/billing_address_controller.js +85 -0
  7. data/app/assets/javascripts/caboose/checkout/cart_controller.js +257 -0
  8. data/app/assets/javascripts/caboose/checkout/checkout_controller.js +258 -0
  9. data/app/assets/javascripts/caboose/checkout/gift_cards_controller.js +57 -0
  10. data/app/assets/javascripts/caboose/checkout/shipping_address_controller.js +86 -0
  11. data/app/assets/javascripts/caboose/checkout/shipping_method_controller.js +121 -0
  12. data/app/assets/javascripts/caboose/checkout/stripe_payment_method_controller.js +155 -0
  13. data/app/assets/javascripts/caboose/checkout_login_register.js +2 -2
  14. data/app/assets/javascripts/caboose/checkout_module.js +8 -8
  15. data/app/assets/javascripts/caboose/checkout_old.js +151 -0
  16. data/app/assets/javascripts/caboose/{checkout_payment.js → checkout_payment_authnet.js} +1 -1
  17. data/app/assets/javascripts/caboose/checkout_payment_stripe.js +212 -0
  18. data/app/assets/javascripts/caboose/checkout_shipping.js +1 -1
  19. data/app/assets/javascripts/caboose/jquery.payment.js +1 -0
  20. data/app/assets/javascripts/caboose/model/attribute.js +3 -2
  21. data/app/assets/javascripts/caboose/model/bound_control.js +56 -14
  22. data/app/assets/javascripts/caboose/model/bound_select.js +9 -11
  23. data/app/assets/javascripts/caboose/model/bound_select_simple.js +215 -0
  24. data/app/assets/javascripts/caboose/model/bound_text.js +7 -8
  25. data/app/assets/javascripts/caboose/{my_account_edit_order.js → my_account_edit_invoice.js} +55 -55
  26. data/app/assets/javascripts/caboose/united_states.js +65 -0
  27. data/app/assets/stylesheets/caboose/{my_account_edit_order.css.scss → my_account_edit_invoice.css.scss} +1 -1
  28. data/app/assets/templates/caboose/cart/line_items.jst.ejs +3 -3
  29. data/app/assets/templates/caboose/checkout/line_items.jst.ejs +7 -7
  30. data/app/controllers/caboose/ab_options_controller.rb +4 -4
  31. data/app/controllers/caboose/ab_variants_controller.rb +5 -5
  32. data/app/controllers/caboose/admin_controller.rb +0 -6
  33. data/app/controllers/caboose/application_controller.rb +16 -15
  34. data/app/controllers/caboose/billing_addresses_controller.rb +22 -22
  35. data/app/controllers/caboose/block_type_sources_controller.rb +8 -8
  36. data/app/controllers/caboose/block_types_controller.rb +2 -42
  37. data/app/controllers/caboose/blocks_controller.rb +26 -26
  38. data/app/controllers/caboose/calendars_controller.rb +5 -5
  39. data/app/controllers/caboose/cart_controller.rb +55 -36
  40. data/app/controllers/caboose/categories_controller.rb +78 -76
  41. data/app/controllers/caboose/checkout_controller.rb +313 -340
  42. data/app/controllers/caboose/checkout_controller_bak.rb +620 -0
  43. data/app/controllers/caboose/domains_controller.rb +5 -5
  44. data/app/controllers/caboose/event_groups_controller.rb +26 -4
  45. data/app/controllers/caboose/events_controller.rb +7 -6
  46. data/app/controllers/caboose/fonts_controller.rb +2 -2
  47. data/app/controllers/caboose/gift_cards_controller.rb +113 -139
  48. data/app/controllers/caboose/google_spreadsheets_controller.rb +1 -1
  49. data/app/controllers/caboose/{order_packages_controller.rb → invoice_packages_controller.rb} +49 -49
  50. data/app/controllers/caboose/{order_reports_controller.rb → invoice_reports_controller.rb} +11 -13
  51. data/app/controllers/caboose/invoice_transactions_controller.rb +35 -0
  52. data/app/controllers/caboose/invoices_controller.rb +328 -0
  53. data/app/controllers/caboose/line_items_controller.rb +35 -34
  54. data/app/controllers/caboose/login_controller.rb +7 -7
  55. data/app/controllers/caboose/login_logs_controller.rb +4 -4
  56. data/app/controllers/caboose/logout_controller.rb +3 -1
  57. data/app/controllers/caboose/media_categories_controller.rb +9 -9
  58. data/app/controllers/caboose/media_controller.rb +21 -46
  59. data/app/controllers/caboose/modal_controller.rb +4 -3
  60. data/app/controllers/caboose/modification_values_controller.rb +6 -6
  61. data/app/controllers/caboose/modifications_controller.rb +7 -6
  62. data/app/controllers/caboose/my_account_controller.rb +2 -2
  63. data/app/controllers/caboose/my_account_invoices_controller.rb +166 -0
  64. data/app/controllers/caboose/my_account_line_items_controller.rb +15 -13
  65. data/app/controllers/caboose/page_custom_fields_controller.rb +9 -8
  66. data/app/controllers/caboose/page_permissions_controller.rb +3 -3
  67. data/app/controllers/caboose/pages_controller.rb +132 -135
  68. data/app/controllers/caboose/permissions_controller.rb +8 -7
  69. data/app/controllers/caboose/post_categories_controller.rb +22 -7
  70. data/app/controllers/caboose/post_custom_fields_controller.rb +9 -8
  71. data/app/controllers/caboose/posts_controller.rb +35 -43
  72. data/app/controllers/caboose/product_images_controller.rb +5 -5
  73. data/app/controllers/caboose/products_controller.rb +53 -47
  74. data/app/controllers/caboose/redirects_controller.rb +7 -7
  75. data/app/controllers/caboose/register_controller.rb +2 -2
  76. data/app/controllers/caboose/retargeting_controller.rb +2 -61
  77. data/app/controllers/caboose/reviews_controller.rb +1 -0
  78. data/app/controllers/caboose/roles_controller.rb +10 -9
  79. data/app/controllers/caboose/settings_controller.rb +9 -7
  80. data/app/controllers/caboose/shipping_addresses_controller.rb +18 -18
  81. data/app/controllers/caboose/shipping_packages_controller.rb +24 -21
  82. data/app/controllers/caboose/sites_controller.rb +35 -25
  83. data/app/controllers/caboose/smtp_controller.rb +3 -3
  84. data/app/controllers/caboose/sns_controller.rb +6 -6
  85. data/app/controllers/caboose/social_controller.rb +5 -6
  86. data/app/controllers/caboose/stackable_groups_controller.rb +10 -8
  87. data/app/controllers/caboose/station_controller.rb +3 -3
  88. data/app/controllers/caboose/store_controller.rb +93 -87
  89. data/app/controllers/caboose/subscriptions_controller.rb +153 -0
  90. data/app/controllers/caboose/users_controller.rb +25 -22
  91. data/app/controllers/caboose/variants_controller.rb +72 -93
  92. data/app/controllers/caboose/vendors_controller.rb +35 -32
  93. data/app/mailers/caboose/{orders_mailer.rb → invoices_mailer.rb} +21 -21
  94. data/app/mailers/caboose/login_mailer.rb +3 -3
  95. data/app/models/caboose/authnet.rb +295 -195
  96. data/app/models/caboose/comment_routes.rb +68 -41
  97. data/app/models/caboose/core_plugin.rb +1 -1
  98. data/app/models/caboose/discount.rb +14 -3
  99. data/app/models/caboose/domain_constraint.rb +11 -3
  100. data/app/models/caboose/gift_card.rb +8 -8
  101. data/app/models/caboose/invoice.rb +706 -0
  102. data/app/models/caboose/invoice_discount.rb +10 -0
  103. data/app/models/caboose/invoice_package.rb +76 -0
  104. data/app/models/caboose/{order_package_calculator.rb → invoice_package_calculator.rb} +20 -20
  105. data/app/models/caboose/{order_pdf.rb → invoice_pdf.rb} +30 -30
  106. data/app/models/caboose/{order_reporter.rb → invoice_reporter.rb} +5 -5
  107. data/app/models/caboose/invoice_transaction.rb +169 -0
  108. data/app/models/caboose/line_item.rb +11 -8
  109. data/app/models/caboose/payment_processors/authorizenet.rb +15 -15
  110. data/app/models/caboose/payment_processors/base.rb +3 -3
  111. data/app/models/caboose/{pending_orders_pdf.rb → pending_invoices_pdf.rb} +31 -31
  112. data/app/models/caboose/product.rb +2 -4
  113. data/app/models/caboose/schema.rb +159 -111
  114. data/app/models/caboose/shipping_calculator.rb +41 -139
  115. data/app/models/caboose/smtp_config.rb +2 -1
  116. data/app/models/caboose/store_config.rb +7 -7
  117. data/app/models/caboose/subscription.rb +32 -0
  118. data/app/models/caboose/tax_calculator.rb +36 -36
  119. data/app/models/caboose/user.rb +6 -0
  120. data/app/models/caboose/user_subscription.rb +142 -0
  121. data/app/models/caboose/wish_list.rb +14 -0
  122. data/app/models/caboose/wish_list_line_item.rb +13 -0
  123. data/app/views/caboose/blocks/_products.html.erb +10 -13
  124. data/app/views/caboose/checkout/_address_form.html.erb +14 -14
  125. data/app/views/caboose/checkout/_billing_form.html.erb +3 -3
  126. data/app/views/caboose/checkout/_cart.html.erb +7 -7
  127. data/app/views/caboose/checkout/_cart_old.html.erb +9 -9
  128. data/app/views/caboose/checkout/_confirm.html.erb +9 -9
  129. data/app/views/caboose/checkout/_order_discount.html.erb +3 -3
  130. data/app/views/caboose/checkout/_shipping_address.html.erb +1 -1
  131. data/app/views/caboose/checkout/_shipping_method.html.erb +1 -1
  132. data/app/views/caboose/checkout/addresses.html.erb +10 -10
  133. data/app/views/caboose/checkout/authnet.html.erb +34 -0
  134. data/app/views/caboose/checkout/authnet_response_handler.html.erb +3 -0
  135. data/app/views/caboose/checkout/checkout.html.erb +100 -0
  136. data/app/views/caboose/checkout/confirm_without_payment.html.erb +6 -6
  137. data/app/views/caboose/checkout/discount.html.erb +1 -1
  138. data/app/views/caboose/checkout/index.html.erb +4 -4
  139. data/app/views/caboose/checkout/payment_authnet.html.erb +140 -0
  140. data/app/views/caboose/checkout/payment_stripe.html.erb +95 -0
  141. data/app/views/caboose/checkout/shipping.html.erb +4 -4
  142. data/app/views/caboose/checkout/thanks.html.erb +3 -3
  143. data/app/views/caboose/gift_cards/admin_edit.html.erb +19 -19
  144. data/app/views/caboose/gift_cards/admin_index.html.erb +9 -9
  145. data/app/views/caboose/{orders → invoices}/_admin_footer.html.erb +0 -0
  146. data/app/views/caboose/{orders → invoices}/_admin_header.html.erb +0 -0
  147. data/app/views/caboose/{orders/_quickbooks_order.html.erb → invoices/_quickbooks_invoice.html.erb} +0 -0
  148. data/app/views/caboose/{orders → invoices}/admin_city_report.html.erb +1 -1
  149. data/app/views/caboose/invoices/admin_delete_form.html.erb +18 -0
  150. data/app/views/caboose/{orders → invoices}/admin_edit.html.erb +14 -14
  151. data/app/views/caboose/{orders → invoices}/admin_index.html.erb +24 -24
  152. data/app/views/caboose/{orders → invoices}/admin_invalid_order.html.erb +2 -2
  153. data/app/views/caboose/{orders → invoices}/admin_new.html.erb +7 -7
  154. data/app/views/caboose/{orders → invoices}/admin_print.html.erb +15 -15
  155. data/app/views/caboose/{orders → invoices}/admin_summary_report.html.erb +4 -4
  156. data/app/views/caboose/{orders_mailer/customer_new_order.html.erb → invoices_mailer/customer_new_invoice.html.erb} +21 -21
  157. data/app/views/caboose/invoices_mailer/customer_payment_authorization.html.erb +5 -0
  158. data/app/views/caboose/{orders_mailer → invoices_mailer}/customer_status_updated.html.erb +22 -22
  159. data/app/views/caboose/{orders_mailer/fulfillment_new_order.html.erb → invoices_mailer/fulfillment_new_invoice.html.erb} +23 -23
  160. data/app/views/caboose/{orders_mailer/shipping_order_ready.html.erb → invoices_mailer/shipping_invoice_ready.html.erb} +0 -0
  161. data/app/views/caboose/{orders_mailer → invoices_mailer}/test_email.html.erb +0 -0
  162. data/app/views/caboose/line_items/admin_new.html.erb +1 -1
  163. data/app/views/caboose/login_mailer/forgot_password_email.html.erb +2 -3
  164. data/app/views/caboose/my_account/index.html.erb +1 -1
  165. data/app/views/caboose/{my_account_orders → my_account_invoices}/authnet_relay.html.erb +0 -0
  166. data/app/views/caboose/{my_account_orders → my_account_invoices}/authnet_response.html.erb +0 -0
  167. data/app/views/caboose/{my_account_orders → my_account_invoices}/edit.html.erb +9 -9
  168. data/app/views/caboose/my_account_invoices/index.html.erb +36 -0
  169. data/app/views/caboose/{my_account_orders → my_account_invoices}/payment_form.html.erb +10 -10
  170. data/app/views/caboose/post_categories/admin_index.html.erb +1 -1
  171. data/app/views/caboose/sites/admin_edit.html.erb +1 -1
  172. data/app/views/caboose/store/admin_edit_general.html.erb +5 -3
  173. data/app/views/caboose/store/admin_edit_packages.html.erb +6 -6
  174. data/app/views/caboose/store/admin_edit_shipping.html.erb +3 -3
  175. data/app/views/caboose/store/admin_edit_tax.html.erb +1 -1
  176. data/app/views/caboose/subscriptions/admin_edit.html.erb +82 -0
  177. data/app/views/caboose/subscriptions/admin_index.html.erb +45 -0
  178. data/config/routes.rb +1 -759
  179. data/config/routes_old.rb +759 -0
  180. data/lib/caboose/version.rb +1 -1
  181. data/lib/tasks/caboose.rake +41 -15
  182. metadata +101 -61
  183. data/app/controllers/caboose/my_account_orders_controller.rb +0 -165
  184. data/app/controllers/caboose/orders_controller.rb +0 -310
  185. data/app/models/caboose/order.rb +0 -479
  186. data/app/models/caboose/order_discount.rb +0 -10
  187. data/app/models/caboose/order_package.rb +0 -133
  188. data/app/models/caboose/order_transaction.rb +0 -41
  189. data/app/models/caboose/payment_processors/payscape.rb +0 -94
  190. data/app/views/caboose/checkout/payment.html.erb +0 -146
  191. data/app/views/caboose/my_account_orders/index.html.erb +0 -36
  192. data/app/views/caboose/orders/admin_delete_form.html.erb +0 -21
  193. data/app/views/caboose/orders_mailer/customer_payment_authorization.html.erb +0 -5
@@ -18,7 +18,7 @@ Caboose.Store.Modules.CheckoutShipping = (function() {
18
18
  url: '/checkout/shipping',
19
19
  type: 'put',
20
20
  data: {
21
- order_package_id: $(event.target).data('order_package_id'),
21
+ invoice_package_id: $(event.target).data('invoice_package_id'),
22
22
  shipping_method_id: $(event.target).data('shipping_method_id'),
23
23
  total: $(event.target).data('total')
24
24
  },
@@ -0,0 +1 @@
1
+ (function(){var t,e,n,r,a,o,i,l,u,s,c,h,p,g,v,f,d,m,y,C,T,w,$,D,S=[].slice,k=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};t=window.jQuery||window.Zepto||window.$,t.payment={},t.payment.fn={},t.fn.payment=function(){var e,n;return n=arguments[0],e=2<=arguments.length?S.call(arguments,1):[],t.payment.fn[n].apply(this,e)},a=/(\d{1,4})/g,t.payment.cards=r=[{type:"visaelectron",patterns:[4026,417500,4405,4508,4844,4913,4917],format:a,length:[16],cvcLength:[3],luhn:!0},{type:"maestro",patterns:[5018,502,503,56,58,639,6220,67],format:a,length:[12,13,14,15,16,17,18,19],cvcLength:[3],luhn:!0},{type:"forbrugsforeningen",patterns:[600],format:a,length:[16],cvcLength:[3],luhn:!0},{type:"dankort",patterns:[5019],format:a,length:[16],cvcLength:[3],luhn:!0},{type:"visa",patterns:[4],format:a,length:[13,16],cvcLength:[3],luhn:!0},{type:"mastercard",patterns:[51,52,53,54,55,22,23,24,25,26,27],format:a,length:[16],cvcLength:[3],luhn:!0},{type:"amex",patterns:[34,37],format:/(\d{1,4})(\d{1,6})?(\d{1,5})?/,length:[15],cvcLength:[3,4],luhn:!0},{type:"dinersclub",patterns:[30,36,38,39],format:/(\d{1,4})(\d{1,6})?(\d{1,4})?/,length:[14],cvcLength:[3],luhn:!0},{type:"discover",patterns:[60,64,65,622],format:a,length:[16],cvcLength:[3],luhn:!0},{type:"unionpay",patterns:[62,88],format:a,length:[16,17,18,19],cvcLength:[3],luhn:!1},{type:"jcb",patterns:[35],format:a,length:[16],cvcLength:[3],luhn:!0}],e=function(t){var e,n,a,o,i,l,u,s;for(t=(t+"").replace(/\D/g,""),o=0,l=r.length;l>o;o++)for(e=r[o],s=e.patterns,i=0,u=s.length;u>i;i++)if(a=s[i],n=a+"",t.substr(0,n.length)===n)return e},n=function(t){var e,n,a;for(n=0,a=r.length;a>n;n++)if(e=r[n],e.type===t)return e},p=function(t){var e,n,r,a,o,i;for(r=!0,a=0,n=(t+"").split("").reverse(),o=0,i=n.length;i>o;o++)e=n[o],e=parseInt(e,10),(r=!r)&&(e*=2),e>9&&(e-=9),a+=e;return a%10===0},h=function(t){var e;return null!=t.prop("selectionStart")&&t.prop("selectionStart")!==t.prop("selectionEnd")?!0:null!=("undefined"!=typeof document&&null!==document&&null!=(e=document.selection)?e.createRange:void 0)&&document.selection.createRange().text?!0:!1},$=function(t,e){var n,r,a;try{n=e.prop("selectionStart")}catch(o){r=o,n=null}return a=e.val(),e.val(t),null!==n&&e.is(":focus")?(n===a.length&&(n=t.length),e.prop("selectionStart",n),e.prop("selectionEnd",n)):void 0},m=function(t){var e,n,r,a,o,i,l,u;for(null==t&&(t=""),r="0123456789",a="0123456789",i="",e=t.split(""),l=0,u=e.length;u>l;l++)n=e[l],o=r.indexOf(n),o>-1&&(n=a[o]),i+=n;return i},d=function(e){var n;return n=t(e.currentTarget),setTimeout(function(){var t;return t=n.val(),t=m(t),t=t.replace(/\D/g,""),$(t,n)})},v=function(e){var n;return n=t(e.currentTarget),setTimeout(function(){var e;return e=n.val(),e=m(e),e=t.payment.formatCardNumber(e),$(e,n)})},l=function(n){var r,a,o,i,l,u,s;return o=String.fromCharCode(n.which),!/^\d+$/.test(o)||(r=t(n.currentTarget),s=r.val(),a=e(s+o),i=(s.replace(/\D/g,"")+o).length,u=16,a&&(u=a.length[a.length.length-1]),i>=u||null!=r.prop("selectionStart")&&r.prop("selectionStart")!==s.length)?void 0:(l=a&&"amex"===a.type?/^(\d{4}|\d{4}\s\d{6})$/:/(?:^|\s)(\d{4})$/,l.test(s)?(n.preventDefault(),setTimeout(function(){return r.val(s+" "+o)})):l.test(s+o)?(n.preventDefault(),setTimeout(function(){return r.val(s+o+" ")})):void 0)},o=function(e){var n,r;return n=t(e.currentTarget),r=n.val(),8!==e.which||null!=n.prop("selectionStart")&&n.prop("selectionStart")!==r.length?void 0:/\d\s$/.test(r)?(e.preventDefault(),setTimeout(function(){return n.val(r.replace(/\d\s$/,""))})):/\s\d?$/.test(r)?(e.preventDefault(),setTimeout(function(){return n.val(r.replace(/\d$/,""))})):void 0},f=function(e){var n;return n=t(e.currentTarget),setTimeout(function(){var e;return e=n.val(),e=m(e),e=t.payment.formatExpiry(e),$(e,n)})},u=function(e){var n,r,a;return r=String.fromCharCode(e.which),/^\d+$/.test(r)?(n=t(e.currentTarget),a=n.val()+r,/^\d$/.test(a)&&"0"!==a&&"1"!==a?(e.preventDefault(),setTimeout(function(){return n.val("0"+a+" / ")})):/^\d\d$/.test(a)?(e.preventDefault(),setTimeout(function(){var t,e;return t=parseInt(a[0],10),e=parseInt(a[1],10),e>2&&0!==t?n.val("0"+t+" / "+e):n.val(""+a+" / ")})):void 0):void 0},s=function(e){var n,r,a;return r=String.fromCharCode(e.which),/^\d+$/.test(r)?(n=t(e.currentTarget),a=n.val(),/^\d\d$/.test(a)?n.val(""+a+" / "):void 0):void 0},c=function(e){var n,r,a;return a=String.fromCharCode(e.which),"/"===a||" "===a?(n=t(e.currentTarget),r=n.val(),/^\d$/.test(r)&&"0"!==r?n.val("0"+r+" / "):void 0):void 0},i=function(e){var n,r;return n=t(e.currentTarget),r=n.val(),8!==e.which||null!=n.prop("selectionStart")&&n.prop("selectionStart")!==r.length?void 0:/\d\s\/\s$/.test(r)?(e.preventDefault(),setTimeout(function(){return n.val(r.replace(/\d\s\/\s$/,""))})):void 0},g=function(e){var n;return n=t(e.currentTarget),setTimeout(function(){var t;return t=n.val(),t=m(t),t=t.replace(/\D/g,"").slice(0,4),$(t,n)})},w=function(t){var e;return t.metaKey||t.ctrlKey?!0:32===t.which?!1:0===t.which?!0:t.which<33?!0:(e=String.fromCharCode(t.which),!!/[\d\s]/.test(e))},C=function(n){var r,a,o,i;return r=t(n.currentTarget),o=String.fromCharCode(n.which),/^\d+$/.test(o)&&!h(r)?(i=(r.val()+o).replace(/\D/g,""),a=e(i),a?i.length<=a.length[a.length.length-1]:i.length<=16):void 0},T=function(e){var n,r,a;return n=t(e.currentTarget),r=String.fromCharCode(e.which),/^\d+$/.test(r)&&!h(n)?(a=n.val()+r,a=a.replace(/\D/g,""),a.length>6?!1:void 0):void 0},y=function(e){var n,r,a;return n=t(e.currentTarget),r=String.fromCharCode(e.which),/^\d+$/.test(r)&&!h(n)?(a=n.val()+r,a.length<=4):void 0},D=function(e){var n,a,o,i,l;return n=t(e.currentTarget),l=n.val(),i=t.payment.cardType(l)||"unknown",n.hasClass(i)?void 0:(a=function(){var t,e,n;for(n=[],t=0,e=r.length;e>t;t++)o=r[t],n.push(o.type);return n}(),n.removeClass("unknown"),n.removeClass(a.join(" ")),n.addClass(i),n.toggleClass("identified","unknown"!==i),n.trigger("payment.cardType",i))},t.payment.fn.formatCardCVC=function(){return this.on("keypress",w),this.on("keypress",y),this.on("paste",g),this.on("change",g),this.on("input",g),this},t.payment.fn.formatCardExpiry=function(){return this.on("keypress",w),this.on("keypress",T),this.on("keypress",u),this.on("keypress",c),this.on("keypress",s),this.on("keydown",i),this.on("change",f),this.on("input",f),this},t.payment.fn.formatCardNumber=function(){return this.on("keypress",w),this.on("keypress",C),this.on("keypress",l),this.on("keydown",o),this.on("keyup",D),this.on("paste",v),this.on("change",v),this.on("input",v),this.on("input",D),this},t.payment.fn.restrictNumeric=function(){return this.on("keypress",w),this.on("paste",d),this.on("change",d),this.on("input",d),this},t.payment.fn.cardExpiryVal=function(){return t.payment.cardExpiryVal(t(this).val())},t.payment.cardExpiryVal=function(t){var e,n,r,a;return a=t.split(/[\s\/]+/,2),e=a[0],r=a[1],2===(null!=r?r.length:void 0)&&/^\d+$/.test(r)&&(n=(new Date).getFullYear(),n=n.toString().slice(0,2),r=n+r),e=parseInt(e,10),r=parseInt(r,10),{month:e,year:r}},t.payment.validateCardNumber=function(t){var n,r;return t=(t+"").replace(/\s+|-/g,""),/^\d+$/.test(t)?(n=e(t),n?(r=t.length,k.call(n.length,r)>=0&&(n.luhn===!1||p(t))):!1):!1},t.payment.validateCardExpiry=function(e,n){var r,a,o;return"object"==typeof e&&"month"in e&&(o=e,e=o.month,n=o.year),e&&n?(e=t.trim(e),n=t.trim(n),/^\d+$/.test(e)&&/^\d+$/.test(n)&&e>=1&&12>=e?(2===n.length&&(n=70>n?"20"+n:"19"+n),4!==n.length?!1:(a=new Date(n,e),r=new Date,a.setMonth(a.getMonth()-1),a.setMonth(a.getMonth()+1,1),a>r)):!1):!1},t.payment.validateCardCVC=function(e,r){var a,o;return e=t.trim(e),/^\d+$/.test(e)?(a=n(r),null!=a?(o=e.length,k.call(a.cvcLength,o)>=0):e.length>=3&&e.length<=4):!1},t.payment.cardType=function(t){var n;return t?(null!=(n=e(t))?n.type:void 0)||null:null},t.payment.formatCardNumber=function(n){var r,a,o,i;return n=n.replace(/\D/g,""),(r=e(n))?(o=r.length[r.length.length-1],n=n.slice(0,o),r.format.global?null!=(i=n.match(r.format))?i.join(" "):void 0:(a=r.format.exec(n),null!=a?(a.shift(),a=t.grep(a,function(t){return t}),a.join(" ")):void 0)):n},t.payment.formatExpiry=function(t){var e,n,r,a;return(n=t.match(/^\D*(\d{1,2})(\D+)?(\d{1,4})?/))?(e=n[1]||"",r=n[2]||"",a=n[3]||"",a.length>0?r=" / ":" /"===r?(e=e.substring(0,1),r=""):2===e.length||r.length>0?r=" / ":1===e.length&&"0"!==e&&"1"!==e&&(e="0"+e,r=" / "),e+r+a):""}}).call(this);
@@ -29,6 +29,7 @@ Attribute.prototype = {
29
29
  hour_increment: 1,
30
30
  show_check_all: true,
31
31
  show_empty_option: false,
32
+ empty_option_text: false,
32
33
  quick_add_url: false,
33
34
  quick_add_text: 'Add New',
34
35
 
@@ -37,9 +38,9 @@ Attribute.prototype = {
37
38
  options: false,
38
39
  s3: false,
39
40
 
40
- save: function(after) {
41
- //if (this.before_update) this.before_update();
41
+ save: function(after) {
42
42
  var this2 = this;
43
+ //if (this.before_update) this.before_update(this2);
43
44
  $.ajax({
44
45
  url: this.update_url,
45
46
  type: 'put',
@@ -13,9 +13,40 @@ BoundControl = Class.extend({
13
13
  cancel: function() {}, // Cancels the edit
14
14
  error: function(str) {}, // Shows an error
15
15
 
16
+ //show_loader: function() {
17
+ // var w = $('#'+this.el).outerWidth();
18
+ // var h = 40; //$('#'+this.el).outerHeight();
19
+ // var this2 = this;
20
+ //
21
+ // if (!$('#'+this.el+'_check').length)
22
+ // {
23
+ // $('#'+this.el+'_container').prepend($('<div/>')
24
+ // .attr('id', this.el + '_check')
25
+ // .addClass('mb_bound_input_check')
26
+ // .css('position', 'absolute')
27
+ // .css('top', 0)
28
+ // .css('right', w-h-1)
29
+ // .css('width', h+2)
30
+ // .css('overflow', 'hidden')
31
+ // .append($('<a/>')
32
+ // .addClass('loading')
33
+ // .html('&#10003;')
34
+ // .css('width', h)
35
+ // .css('margin-left', h)
36
+ // .attr('href', '#')
37
+ // .click(function(event) { event.preventDefault(); })
38
+ // )
39
+ // );
40
+ // }
41
+ // $('#'+this.el+'_check a')
42
+ // .addClass('mb_loading')
43
+ // .css('margin-left', h);
44
+ // $('#'+this.el+'_check a').animate({ 'margin-left': 0 }, 300);
45
+ //},
46
+
16
47
  show_loader: function() {
17
48
  var w = $('#'+this.el).outerWidth();
18
- var h = 40; //$('#'+this.el).outerHeight();
49
+ var h = $('#'+this.el).outerHeight();
19
50
  var this2 = this;
20
51
 
21
52
  if (!$('#'+this.el+'_check').length)
@@ -25,30 +56,31 @@ BoundControl = Class.extend({
25
56
  .addClass('mb_bound_input_check')
26
57
  .css('position', 'absolute')
27
58
  .css('top', 0)
28
- .css('left', w-h-1)
29
- .css('width', h+2)
59
+ .css('right', 0-h)
60
+ .css('width', h)
30
61
  .css('overflow', 'hidden')
62
+ .css('border', '0')
31
63
  .append($('<a/>')
32
64
  .addClass('loading')
33
65
  .html('&#10003;')
34
66
  .css('width', h)
35
- .css('margin-left', h)
67
+ .css('height', h)
68
+ .css('text-decoration', 'none')
69
+ .css('border', '0')
36
70
  .attr('href', '#')
37
71
  .click(function(event) { event.preventDefault(); })
38
72
  )
39
73
  );
40
74
  }
41
- $('#'+this.el+'_check a')
42
- .addClass('mb_loading')
43
- .css('margin-left', h);
44
- $('#'+this.el+'_check a').animate({ 'margin-left': 0 }, 300);
75
+ $('#'+this.el+'_check a').addClass('loading');
76
+ $('#'+this.el+'_check').animate({ 'right': -1 }, 300);
45
77
  },
46
78
 
47
79
  hide_loader: function() {
48
80
  this.hide_check();
49
81
  },
50
82
 
51
- show_check: function(duration) {
83
+ show_check: function(duration) {
52
84
  $('#'+this.el+'_check a').removeClass('loading');
53
85
  if (duration)
54
86
  {
@@ -57,12 +89,22 @@ BoundControl = Class.extend({
57
89
  }
58
90
  },
59
91
 
92
+ //hide_check: function() {
93
+ // var w = $('#'+this.el).outerWidth();
94
+ // var h = 40;
95
+ //
96
+ // var this2 = this;
97
+ // $('#'+this.el+'_check a').animate({ 'margin-left': h }, 300, function() {
98
+ // $('#'+this2.check).remove();
99
+ // });
100
+ //},
101
+
60
102
  hide_check: function() {
61
- var h = $('#'+this.el).outerHeight();
62
- var this2 = this;
63
- $('#'+this.el+'_check a').animate({ 'margin-left': h }, 300, function() {
64
- $('#'+this2.check).remove();
103
+ var that = this;
104
+ var h = $('#'+this.el).outerHeight();
105
+ $('#'+that.el+'_check').animate({ 'right': 0-h }, 300, function() {
106
+ $('#'+that.el+'_check').remove();
65
107
  });
66
- }
108
+ },
67
109
 
68
110
  });
@@ -18,12 +18,11 @@ BoundSelect = BoundControl.extend({
18
18
  this.el = this.el ? this.el : this.model.name.toLowerCase() + '_' + this.model.id + '_' + this.attribute.name;
19
19
  this.message = this.el + '_message';
20
20
  this.placeholder = this.el + '_placeholder';
21
-
22
- $('#'+this.el).wrap($('<div/>')
23
- .attr('id', this.el + '_container')
24
- .addClass('mb_container')
25
- .css('position', 'relative')
26
- );
21
+
22
+ var wrapper = $('<div/>').attr('id', this.el + '_container').addClass('mb_container').css('position', 'relative');
23
+ if (this.attribute.wrapper_class)
24
+ wrapper.addClass(this.attribute.wrapper_class);
25
+ $('#'+this.el).wrap(wrapper);
27
26
  $('#'+this.el+'_container').empty();
28
27
  if (this.attribute.fixed_placeholder == true)
29
28
  {
@@ -74,8 +73,8 @@ BoundSelect = BoundControl.extend({
74
73
  caboose_modal_close_handler = function(new_id) {
75
74
  this2.attribute.populate_options(function() {
76
75
  var select2 = $('#' + this2.el + '_select');
77
- select2.empty();
78
- if (this2.attribute.show_empty_option) select.append($('<option/>').val('').html('-- Empty --'));
76
+ select2.empty();
77
+ if (this2.attribute.show_empty_option) select.append($('<option/>').val('').html(this2.attribute.empty_text ? this2.attribute.empty_text : '-- Empty --'));
79
78
  if (this2.attribute.quick_add_url) select.append($('<option/>').val('quickadd').html('-- ' + this2.attribute.quick_add_text + ' --'));
80
79
  $.each(this2.attribute.options, function(i, option) {
81
80
  var opt = $('<option/>').val(option.value).html(option.text);
@@ -117,9 +116,8 @@ BoundSelect = BoundControl.extend({
117
116
  value: this2.attribute.value,
118
117
  text: this2.attribute.text
119
118
  });
120
- }
121
- if (this2.attribute.show_empty_option)
122
- select.append($('<option/>').val('').html('-- Empty --'));
119
+ }
120
+ if (this2.attribute.show_empty_option) select.append($('<option/>').val('').html(this2.attribute.empty_text ? this2.attribute.empty_text : '-- Empty --'));
123
121
  if (this2.attribute.quick_add_url)
124
122
  select.append($('<option/>').val('quickadd').html('-- ' + this2.attribute.quick_add_text + ' --'));
125
123
  $.each(this2.attribute.options, function(i, option) {
@@ -0,0 +1,215 @@
1
+
2
+ BoundSelectSimple = BoundControl.extend({
3
+
4
+ //el: false,
5
+ //model: false,
6
+ //attribute: false,
7
+ //binder: false,
8
+
9
+ message: false,
10
+ placeholder: false,
11
+
12
+ init: function(params) {
13
+ //console.log('control.model.id = ' + this.model.id);
14
+ for (var thing in params)
15
+ this[thing] = params[thing];
16
+ //console.log('control.model.id = ' + this.model.id);
17
+
18
+ this.el = this.el ? this.el : this.model.name.toLowerCase() + '_' + this.model.id + '_' + this.attribute.name;
19
+ this.message = this.el + '_message';
20
+ this.placeholder = this.el + '_placeholder';
21
+
22
+ var wrapper = $('<div/>').attr('id', this.el + '_container').addClass('mb_container').css('position', 'relative');
23
+ if (this.attribute.wrapper_class)
24
+ wrapper.addClass(this.attribute.wrapper_class);
25
+ $('#'+this.el).wrap(wrapper);
26
+ $('#'+this.el+'_container').empty();
27
+ if (this.attribute.fixed_placeholder == true)
28
+ {
29
+ $('#'+this.el+'_container').append($('<div/>')
30
+ .attr('id', this.placeholder)
31
+ .addClass('mb_placeholder')
32
+ .append($('<span/>')
33
+ .html(this.attribute.nice_name + ': ')
34
+ )
35
+ );
36
+ }
37
+ var this2 = this;
38
+ $('#'+this.el+'_container').append($('<input/>')
39
+ .attr('type', 'text')
40
+ .attr('id', this.el)
41
+ .addClass('mb_fake_option')
42
+ .attr('placeholder', this.attribute.empty_text)
43
+ .click(function() { this2.edit(); })
44
+ .val(this.attribute.text && this.attribute.text.length > 0 ? this.attribute.text : this.attribute.empty_text)
45
+ );
46
+ if (this.attribute.width)
47
+ $('#'+this.el).css('width', this.attribute.width);
48
+
49
+ if (this.attribute.fixed_placeholder)
50
+ {
51
+ var w = $('#'+this.placeholder).outerWidth();
52
+ $('#'+this.el)
53
+ .css('padding-left', '+=' + w)
54
+ .css('width', '-=' + w);
55
+ }
56
+
57
+ //this.update_options();
58
+
59
+ //var this2 = this;
60
+ //this.attribute.populate_options(function() {
61
+ // this2.print_options(this2);
62
+ //});
63
+
64
+ this.attribute.populate_options(function() {
65
+ var select = $('<select/>')
66
+ .attr('id', this2.el + '_select')
67
+ .addClass('mb_fake')
68
+ .css('width', $('#'+this2.el).outerWidth())
69
+ .on('change', function() {
70
+ var v = $('#'+this2.el+'_select').val();
71
+ if (this2.attribute.quick_add_url && v == 'quickadd')
72
+ {
73
+ caboose_modal_close_handler = function(new_id) {
74
+ this2.attribute.populate_options(function() {
75
+ var select2 = $('#' + this2.el + '_select');
76
+ select2.empty();
77
+ if (this2.attribute.show_empty_option) select.append($('<option/>').val('').html('-- Empty --'));
78
+ if (this2.attribute.quick_add_url) select.append($('<option/>').val('quickadd').html('-- ' + this2.attribute.quick_add_text + ' --'));
79
+ $.each(this2.attribute.options, function(i, option) {
80
+ var opt = $('<option/>').val(option.value).html(option.text);
81
+ if (option.value == new_id)
82
+ {
83
+ this2.attribute.text = option.text;
84
+ $('#'+this2.el).val(this2.attribute.text);
85
+ opt.attr('selected', 'true');
86
+ }
87
+ select.append(opt);
88
+ });
89
+ $('#'+this2.el).val(new_id);
90
+ this2.save();
91
+ }, true);
92
+ }
93
+ if (typeof this2.attribute.quick_add_url == 'string')
94
+ caboose_modal_url(this2.attribute.quick_add_url);
95
+ else
96
+ caboose_modal_url(this2.attribute.quick_add_url(this2.model()));
97
+ }
98
+ else
99
+ {
100
+ $('#'+this2.el).val(v);
101
+ this2.save();
102
+ }
103
+ });
104
+ // Make sure the existing value is in the list of options
105
+ var exists = false;
106
+ $.each(this2.attribute.options, function(i, option) {
107
+ if (option.value == this2.attribute.value)
108
+ {
109
+ exists = true;
110
+ return false;
111
+ }
112
+ });
113
+ if (!exists && !(this2.attribute.show_empty_option && (this2.attribute.value == '' || this2.attribute.value == null)))
114
+ {
115
+ this2.attribute.options.unshift({
116
+ value: this2.attribute.value,
117
+ text: this2.attribute.text
118
+ });
119
+ }
120
+ if (this2.attribute.show_empty_option)
121
+ select.append($('<option/>').val('').html('-- Empty --'));
122
+ if (this2.attribute.quick_add_url)
123
+ select.append($('<option/>').val('quickadd').html('-- ' + this2.attribute.quick_add_text + ' --'));
124
+ $.each(this2.attribute.options, function(i, option) {
125
+ var opt = $('<option/>')
126
+ .val(option.value)
127
+ .html(option.text);
128
+ if (option.value == this2.attribute.value)
129
+ {
130
+ this2.attribute.text = option.text;
131
+ $('#'+this2.el).val(this2.attribute.text);
132
+ opt.attr('selected', 'true');
133
+ }
134
+ select.append(opt);
135
+ });
136
+ $('#'+this2.el+'_container').append(select);
137
+ $('#'+this2.el+'_select').css('width', $('#'+this2.el).outerWidth());
138
+ });
139
+ },
140
+
141
+ //update_options: function() {
142
+ // var that = this;
143
+ // this.attribute.populate_options(function() {
144
+ // var select = $('<select/>')
145
+ // .attr('id', that.el + '_select')
146
+ // .addClass('fake')
147
+ // .css('width', $('#'+that.el).outerWidth())
148
+ // .on('change', function() {
149
+ // $('#'+that.el).val($('#'+that.el+'_select').val());
150
+ // that.save();
151
+ // });
152
+ //
153
+ // $.each(that.attribute.options, function(i, option) {
154
+ // var opt = $('<option/>')
155
+ // .val(option.value)
156
+ // .html(option.text);
157
+ // if (option.value == that.attribute.value)
158
+ // opt.attr('selected', 'true');
159
+ // select.append(opt);
160
+ // });
161
+ //
162
+ // if ($('#' + that.el + '_select').length)
163
+ // $('#' + that.el + '_select').remove();
164
+ //
165
+ // $('#'+that.el+'_container').append(select);
166
+ // $('#'+that.el+'_select').css('width', $('#'+that.el).outerWidth());
167
+ // });
168
+ //},
169
+
170
+ view: function() {
171
+
172
+ },
173
+
174
+ edit: function() {
175
+ },
176
+
177
+ save: function() {
178
+ this.attribute.value = $('#'+this.el).val();
179
+ var i = $('#' + this.el + "_container option[value='" + this.attribute.value + "']").index();
180
+ this.attribute.text = $('#' + this.el + " option").eq(i).text();
181
+ if (this.attribute.text == '' && this.attribute.show_empty_option)
182
+ this.attribute.text = '-- Empty --';
183
+
184
+ var this2 = this;
185
+ this.binder.save(this.attribute, function(resp) {
186
+ $(this2.attribute.options).each(function(i,opt) {
187
+ if (opt.value == this2.attribute.value)
188
+ this2.attribute.text = opt.text;
189
+ });
190
+ if (this2.attribute.text)
191
+ $('#'+this2.el).val(this2.attribute.text);
192
+ $('#'+this2.el+'_check a').removeClass('loading');
193
+ if (resp.error) this2.error(resp.error);
194
+ else
195
+ {
196
+ if (this2.binder.success)
197
+ this2.binder.success(this2);
198
+ this2.view();
199
+ }
200
+ });
201
+ },
202
+
203
+ cancel: function() {
204
+ this.attribute.value = this.attribute.value_clean;
205
+ $('#'+this.el).val(this.attribute.value);
206
+ this.view();
207
+ },
208
+
209
+ error: function(str) {
210
+ if (!$('#'+this.message).length)
211
+ $('#'+this.el+'_container').prepend($('<div/>').attr('id', this.message));
212
+ $('#'+this.message).html("<p class='note error'>" + str + "</p>");
213
+ }
214
+
215
+ });
@@ -13,13 +13,12 @@ BoundText = BoundControl.extend({
13
13
  for (var thing in params)
14
14
  this[thing] = params[thing];
15
15
 
16
- this.el = this.el ? this.el : this.model.name.toLowerCase() + '_' + this.model.id + '_' + this.attribute.name;
17
- $('#'+this.el).wrap($('<div/>')
18
- .attr('id', this.el + '_container')
19
- .addClass('mb_container')
20
- .css('position', 'relative')
21
- );
22
- $('#'+this.el+'_container').empty();
16
+ this.el = this.el ? this.el : this.model.name.toLowerCase() + '_' + this.model.id + '_' + this.attribute.name;
17
+ var wrapper = $('<div/>').attr('id', this.el + '_container').addClass('mb_container').css('position', 'relative');
18
+ if (this.attribute.wrapper_class)
19
+ wrapper.addClass(this.attribute.wrapper_class);
20
+ $('#'+this.el).wrap(wrapper);
21
+ $('#'+this.el+'_container').empty();
23
22
  $('#'+this.el+'_container').append($('<input/>')
24
23
  .attr('id', this.el)
25
24
  .attr('type', 'text')
@@ -76,7 +75,7 @@ BoundText = BoundControl.extend({
76
75
  }
77
76
  else
78
77
  {
79
- this2.show_check(500);
78
+ this2.show_check(500);
80
79
  $('#'+this2.el).val(this2.attribute.value);
81
80
  $('#'+this2.el).removeClass('mb_dirty');
82
81
 
@@ -1,10 +1,10 @@
1
1
 
2
- var MyAccountOrderController = function(params) { this.init(params); }
2
+ var MyAccountInvoiceController = function(params) { this.init(params); }
3
3
 
4
- MyAccountOrderController.prototype = {
4
+ MyAccountInvoiceController.prototype = {
5
5
 
6
- order_id: false,
7
- order: false,
6
+ invoice_id: false,
7
+ invoice: false,
8
8
  authenticity_token: false,
9
9
 
10
10
  init: function(params)
@@ -20,20 +20,20 @@ MyAccountOrderController.prototype = {
20
20
  refresh: function(after)
21
21
  {
22
22
  var that = this;
23
- that.refresh_order(function() {
24
- $('#order_table').html("<p class='loading'>Getting order...</p>");
23
+ that.refresh_invoice(function() {
24
+ $('#invoice_table').html("<p class='loading'>Getting invoice...</p>");
25
25
  that.print();
26
26
  if (after) after();
27
27
  });
28
28
  },
29
29
 
30
- refresh_order: function(after)
30
+ refresh_invoice: function(after)
31
31
  {
32
32
  var that = this;
33
33
  $.ajax({
34
- url: '/my-account/orders/' + that.order_id + '/json',
35
- success: function(order) {
36
- that.order = order;
34
+ url: '/my-account/invoices/' + that.invoice_id + '/json',
35
+ success: function(invoice) {
36
+ that.invoice = invoice;
37
37
  if (after) after();
38
38
  }
39
39
  });
@@ -41,12 +41,12 @@ MyAccountOrderController.prototype = {
41
41
 
42
42
  /******************************************************************************/
43
43
 
44
- line_items_for_order_package: function(order_package_id)
44
+ line_items_for_invoice_package: function(invoice_package_id)
45
45
  {
46
46
  var that = this;
47
47
  var line_items = [];
48
- $.each(that.order.line_items, function(i, li) {
49
- if (li.order_package_id == order_package_id)
48
+ $.each(that.invoice.line_items, function(i, li) {
49
+ if (li.invoice_package_id == invoice_package_id)
50
50
  line_items.push(li);
51
51
  });
52
52
  return line_items;
@@ -56,13 +56,13 @@ MyAccountOrderController.prototype = {
56
56
  {
57
57
  var that = this;
58
58
 
59
- if (that.order.line_items && that.order.line_items.length > 0)
59
+ if (that.invoice.line_items && that.invoice.line_items.length > 0)
60
60
  {
61
61
  var count_packaged = 0;
62
62
  var count_unpackaged = 0;
63
63
  var count_downloadable = 0;
64
- $.each(that.order.line_items, function(i, li) {
65
- if (li.order_package_id)
64
+ $.each(that.invoice.line_items, function(i, li) {
65
+ if (li.invoice_package_id)
66
66
  count_packaged++;
67
67
  else if (li.variant.downloadable == true)
68
68
  count_downloadable++;
@@ -73,18 +73,18 @@ MyAccountOrderController.prototype = {
73
73
  var table = that.overview_table();
74
74
  $('#overview_table').empty().append(table).append($('<br />'));
75
75
 
76
- table = $('<table/>').addClass('order').css('width', '100%');
76
+ table = $('<table/>').addClass('invoice').css('width', '100%');
77
77
  if (count_packaged > 0) that.packaged_line_items_table(table);
78
78
  if (count_unpackaged > 0) that.unpackaged_line_items_table(table);
79
79
  if (count_downloadable > 0) that.downloadable_line_items_table(table);
80
80
  that.summary_table(table);
81
- $('#order_table').empty().append(table);
81
+ $('#invoice_table').empty().append(table);
82
82
  }
83
83
  else
84
84
  {
85
85
  $('#overview_table').empty();
86
- $('#order_table').empty();
87
- $('#message').empty().html("This order is empty.");
86
+ $('#invoice_table').empty();
87
+ $('#message').empty().html("This invoice is empty.");
88
88
  }
89
89
  },
90
90
 
@@ -92,25 +92,25 @@ MyAccountOrderController.prototype = {
92
92
  {
93
93
  var that = this;
94
94
 
95
- var fstatus = $('<div/>').append($('<p/>').html(capitalize_first_letter(that.order.financial_status)));
96
- if (that.order.financial_status == 'pending')
95
+ var fstatus = $('<div/>').append($('<p/>').html(capitalize_first_letter(that.invoice.financial_status)));
96
+ if (that.invoice.financial_status == 'pending')
97
97
  {
98
98
  fstatus.append($('<p/>').append($('<input/>').attr('type', 'button').addClass('btn').val('Pay now').click(function(e) { e.preventDefault(); that.payment_form(); })));
99
99
  }
100
100
 
101
- var table = $('<table/>').addClass('order');
101
+ var table = $('<table/>').addClass('invoice');
102
102
  table.append($('<tr/>')
103
103
  .append($('<th/>').html('Customer'))
104
104
  .append($('<th/>').html('Shipping Address'))
105
105
  .append($('<th/>').html('Billing Address'))
106
- .append($('<th/>').html('Order Status'))
106
+ .append($('<th/>').html('Status'))
107
107
  .append($('<th/>').html('Payment Status'))
108
108
  );
109
109
  table.append($('<tr/>')
110
110
  .append($('<td/>').attr('valign', 'top').attr('id', 'customer' ).append(that.noneditable_customer()))
111
111
  .append($('<td/>').attr('valign', 'top').attr('id', 'shipping_address' ).append(that.noneditable_shipping_address()))
112
112
  .append($('<td/>').attr('valign', 'top').attr('id', 'billing_address' ).append(that.noneditable_billing_address()))
113
- .append($('<td/>').attr('valign', 'top').attr('align', 'center').append($('<p/>').html(capitalize_first_letter(that.order.status))))
113
+ .append($('<td/>').attr('valign', 'top').attr('align', 'center').append($('<p/>').html(capitalize_first_letter(that.invoice.status))))
114
114
  .append($('<td/>').attr('valign', 'top').attr('id', 'financial_status' ).attr('align', 'center').append(fstatus))
115
115
  );
116
116
  return table;
@@ -119,7 +119,7 @@ MyAccountOrderController.prototype = {
119
119
  noneditable_customer: function()
120
120
  {
121
121
  var that = this;
122
- c = that.order.customer;
122
+ c = that.invoice.customer;
123
123
  str = '';
124
124
  if (c)
125
125
  {
@@ -138,7 +138,7 @@ MyAccountOrderController.prototype = {
138
138
  var div = $('<div/>');
139
139
  if (that.has_shippable_items())
140
140
  {
141
- var sa = that.order.shipping_address;
141
+ var sa = that.invoice.shipping_address;
142
142
  str = '';
143
143
  str += (sa.first_name ? sa.first_name : '[Empty first name]') + ' ';
144
144
  str += (sa.last_name ? sa.last_name : '[Empty last name]');
@@ -149,12 +149,12 @@ MyAccountOrderController.prototype = {
149
149
  div.append($('<div/>').attr('id', 'shipping_address').append(str));
150
150
  div.append($('<a/>').attr('href', '#').html('Edit').click(function(e) {
151
151
  var a = $(this);
152
- that.refresh_order(function() { that.edit_shipping_address(); });
152
+ that.refresh_invoice(function() { that.edit_shipping_address(); });
153
153
  }));
154
154
  }
155
155
  else
156
156
  {
157
- div.append("This order does not require shipping.");
157
+ div.append("This invoice does not require shipping.");
158
158
  }
159
159
  return div;
160
160
  },
@@ -162,7 +162,7 @@ MyAccountOrderController.prototype = {
162
162
  edit_shipping_address: function()
163
163
  {
164
164
  var that = this;
165
- var sa = that.order.shipping_address;
165
+ var sa = that.invoice.shipping_address;
166
166
  var table = $('<table/>').addClass('shipping_address')
167
167
  .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
168
168
  .append($('<td/>').append($('<div/>').attr('id', 'shippingaddress_' + sa.id + '_first_name')))
@@ -183,13 +183,13 @@ MyAccountOrderController.prototype = {
183
183
  .append(table)
184
184
  .append($('<a/>').attr('href', '#').html('Finished').click(function(e) {
185
185
  var a = $(this);
186
- that.refresh_order(function() { $('#shipping_address').empty().append(that.noneditable_shipping_address()); });
186
+ that.refresh_invoice(function() { $('#shipping_address').empty().append(that.noneditable_shipping_address()); });
187
187
  }));
188
188
 
189
189
  new ModelBinder({
190
190
  name: 'ShippingAddress',
191
191
  id: sa.id,
192
- update_url: '/my-account/orders/' + that.order.id + '/shipping-address',
192
+ update_url: '/my-account/invoices/' + that.invoice.id + '/shipping-address',
193
193
  authenticity_token: that.authenticity_token,
194
194
  attributes: [
195
195
  { name: 'first_name' , nice_name: 'First Name' , type: 'text' , value: sa.first_name , width: 150, fixed_placeholder: false },
@@ -207,7 +207,7 @@ MyAccountOrderController.prototype = {
207
207
  {
208
208
  var that = this;
209
209
 
210
- var sa = that.order.billing_address;
210
+ var sa = that.invoice.billing_address;
211
211
  if (!sa) sa = {};
212
212
  var str = '';
213
213
  str += (sa.first_name ? sa.first_name : '[Empty first name]') + ' ';
@@ -221,7 +221,7 @@ MyAccountOrderController.prototype = {
221
221
  .append("<br />")
222
222
  .append($('<a/>').attr('href', '#').html('Edit').click(function(e) {
223
223
  var a = $(this);
224
- that.refresh_order(function() { that.edit_billing_address(); });
224
+ that.refresh_invoice(function() { that.edit_billing_address(); });
225
225
  }));
226
226
  return div;
227
227
  },
@@ -229,7 +229,7 @@ MyAccountOrderController.prototype = {
229
229
  edit_billing_address: function()
230
230
  {
231
231
  var that = this;
232
- var sa = that.order.billing_address;
232
+ var sa = that.invoice.billing_address;
233
233
  if (!sa) sa = { id: 1 };
234
234
  var table = $('<table/>').addClass('billing_address')
235
235
  .append($('<tr/>').append($('<td/>').append($('<table/>').append($('<tr/>')
@@ -251,13 +251,13 @@ MyAccountOrderController.prototype = {
251
251
  .append(table)
252
252
  .append($('<a/>').attr('href', '#').html('Finished').click(function(e) {
253
253
  var a = $(this);
254
- that.refresh_order(function() { $('#billing_address').empty().append(that.noneditable_billing_address()); });
254
+ that.refresh_invoice(function() { $('#billing_address').empty().append(that.noneditable_billing_address()); });
255
255
  }));
256
256
 
257
257
  new ModelBinder({
258
258
  name: 'BillingAddress',
259
259
  id: sa.id,
260
- update_url: '/my-account/orders/' + that.order.id + '/billing-address',
260
+ update_url: '/my-account/invoices/' + that.invoice.id + '/billing-address',
261
261
  authenticity_token: that.authenticity_token,
262
262
  attributes: [
263
263
  { name: 'first_name' , nice_name: 'First Name' , type: 'text' , value: sa.first_name , width: 150, fixed_placeholder: false },
@@ -275,8 +275,8 @@ MyAccountOrderController.prototype = {
275
275
  packaged_line_items_table: function(table)
276
276
  {
277
277
  var that = this;
278
- $.each(that.order.order_packages, function(i, op) {
279
- var line_items = that.line_items_for_order_package(op.id);
278
+ $.each(that.invoice.invoice_packages, function(i, op) {
279
+ var line_items = that.line_items_for_invoice_package(op.id);
280
280
  if (line_items && line_items.length > 0)
281
281
  {
282
282
  table.append($('<tr/>').append($('<th/>').attr('colspan', '5').addClass('package_header').html("Package " + (i+1) + ": " + op.shipping_method.service_name + "<br />" + op.status)));
@@ -304,8 +304,8 @@ MyAccountOrderController.prototype = {
304
304
  unpackaged_line_items_table: function(table)
305
305
  {
306
306
  var that = this;
307
- $.each(that.order.order_packages, function(i, op) {
308
- var line_items = that.line_items_for_order_package(op.id);
307
+ $.each(that.invoice.invoice_packages, function(i, op) {
308
+ var line_items = that.line_items_for_invoice_package(op.id);
309
309
  if (line_items && line_items.length > 0)
310
310
  {
311
311
  table.append($('<tr/>').append($('<th/>').attr('colspan', '5').addClass('package_header').html("Unpackaged Items")));
@@ -332,8 +332,8 @@ MyAccountOrderController.prototype = {
332
332
  downloadable_line_items_table: function(table)
333
333
  {
334
334
  var that = this;
335
- $.each(that.order.order_packages, function(i, op) {
336
- var line_items = that.line_items_for_order_package(op.id);
335
+ $.each(that.invoice.invoice_packages, function(i, op) {
336
+ var line_items = that.line_items_for_invoice_package(op.id);
337
337
  if (line_items && line_items.length > 0)
338
338
  {
339
339
  table.append($('<tr/>').append($('<th/>').attr('colspan', '5').addClass('package_header').html("Downloadable Items")));
@@ -387,32 +387,32 @@ MyAccountOrderController.prototype = {
387
387
  }
388
388
  if (li.variant.downloadable)
389
389
  {
390
- div.append($('<p/>').append($('<a/>').attr('href', '/my-account/orders/' + that.order.id + '/line-items/' + li.id + '/download').html('Download')));
390
+ div.append($('<p/>').append($('<a/>').attr('href', '/my-account/invoices/' + that.invoice.id + '/line-items/' + li.id + '/download').html('Download')));
391
391
  }
392
392
 
393
393
  return div;
394
394
  },
395
395
 
396
- // Show the order summary
396
+ // Show the invoice summary
397
397
  summary_table: function(table)
398
398
  {
399
399
  var that = this;
400
400
  table.append($('<tr/>').append($('<th/>').attr('colspan', '5').addClass('totals_header').html('Totals')));
401
- table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', '4').attr('align', 'right').html('Subtotal' )).append($('<td/>').attr('align', 'right').attr('id', 'subtotal').html(curr(that.order.subtotal ))));
402
- table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', '4').attr('align', 'right').html('Tax' )).append($('<td/>').attr('align', 'right').attr('id', 'tax' ).html(curr(that.order.tax ))));
403
- table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', '4').attr('align', 'right').html('Shipping' )).append($('<td/>').attr('align', 'right').attr('id', 'shipping').html(curr(that.order.shipping ))));
404
- table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', '4').attr('align', 'right').html('Handling' )).append($('<td/>').attr('align', 'right').attr('id', 'handling').html(curr(that.order.handling ))));
405
- if (that.order.discounts)
401
+ table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', '4').attr('align', 'right').html('Subtotal' )).append($('<td/>').attr('align', 'right').attr('id', 'subtotal').html(curr(that.invoice.subtotal ))));
402
+ table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', '4').attr('align', 'right').html('Tax' )).append($('<td/>').attr('align', 'right').attr('id', 'tax' ).html(curr(that.invoice.tax ))));
403
+ table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', '4').attr('align', 'right').html('Shipping' )).append($('<td/>').attr('align', 'right').attr('id', 'shipping').html(curr(that.invoice.shipping ))));
404
+ table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', '4').attr('align', 'right').html('Handling' )).append($('<td/>').attr('align', 'right').attr('id', 'handling').html(curr(that.invoice.handling ))));
405
+ if (that.invoice.discounts)
406
406
  {
407
- $.each(that.order.discounts, function(i, d) {
407
+ $.each(that.invoice.discounts, function(i, d) {
408
408
  table.append($('<tr/>').addClass('totals_row')
409
409
  .append($('<td/>').attr('colspan', '4').attr('align', 'right').append(' "' + d.gift_card.code + '" Discount'))
410
410
  .append($('<td/>').attr('align', 'right').html(curr(d.amount)))
411
411
  );
412
412
  });
413
413
  }
414
- table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', '4').attr('align', 'right').html('Discount')).append($('<td/>').attr('align', 'right').attr('id', 'custom_discount').html(curr(that.order.custom_discount))));
415
- table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', '4').attr('align', 'right').html('Total' )).append($('<td/>').attr('align', 'right').attr('id', 'total' ).html(curr(that.order.total))));
414
+ table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', '4').attr('align', 'right').html('Discount')).append($('<td/>').attr('align', 'right').attr('id', 'custom_discount').html(curr(that.invoice.custom_discount))));
415
+ table.append($('<tr/>').addClass('totals_row').append($('<td/>').attr('colspan', '4').attr('align', 'right').html('Total' )).append($('<td/>').attr('align', 'right').attr('id', 'total' ).html(curr(that.invoice.total))));
416
416
  },
417
417
 
418
418
  /****************************************************************************/
@@ -430,7 +430,7 @@ MyAccountOrderController.prototype = {
430
430
 
431
431
  $('#payment_message').empty().html("<p class='loading'>Getting payment form...</p>");
432
432
  $.ajax({
433
- url: '/my-account/orders/' + that.order.id + '/payment-form',
433
+ url: '/my-account/invoices/' + that.invoice.id + '/payment-form',
434
434
  type: 'get',
435
435
  success: function(html) {
436
436
  form.empty().append(html);
@@ -468,7 +468,7 @@ MyAccountOrderController.prototype = {
468
468
  {
469
469
  var that = this;
470
470
  var needs_shipping = false;
471
- $.each(that.order.line_items, function(i, li) {
471
+ $.each(that.invoice.line_items, function(i, li) {
472
472
  if (li.variant.downloadable == false)
473
473
  needs_shipping = true;
474
474
  });