summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/site/EditSubscriptionModal.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-02-01 16:58:58 -0500
committerJules Laplace <jules@okfoc.us>2015-02-01 16:58:58 -0500
commit60aa806d65a90907c6a76cb017c167c8453260b3 (patch)
treeaa35d800d9a6df4572938254b751fd44c0c558e6 /public/assets/javascripts/ui/site/EditSubscriptionModal.js
parentfbf637f2210d281c8c6f41b72cf50746939a8ece (diff)
plan val from radio button
Diffstat (limited to 'public/assets/javascripts/ui/site/EditSubscriptionModal.js')
-rw-r--r--public/assets/javascripts/ui/site/EditSubscriptionModal.js110
1 files changed, 54 insertions, 56 deletions
diff --git a/public/assets/javascripts/ui/site/EditSubscriptionModal.js b/public/assets/javascripts/ui/site/EditSubscriptionModal.js
index fe93499..b9abd75 100644
--- a/public/assets/javascripts/ui/site/EditSubscriptionModal.js
+++ b/public/assets/javascripts/ui/site/EditSubscriptionModal.js
@@ -26,60 +26,10 @@ var EditSubscriptionModal = ModalView.extend({
"input [data-role=proLayoutInput]": "updateQuantity",
"click [data-role=saveQuantity]": "saveQuantity",
- "input [name=planRadio]": "updatePlan",
+ "change [name=planRadio]": "updatePlan",
"click [data-role=changePlan]": "savePlan",
},
- resetMode: function(e){
- e && e.preventDefault()
- this.$paidPlan.removeClass("editLayouts editPlan")
- this.reset()
- },
-
- layoutsMode: function(e){
- e && e.preventDefault()
- this.$paidPlan.addClass("editLayouts")
- this.tempSubscriber = defaults({}, this.subscriber)
- this.$basicLayoutInput.val( this.subscriber.basic_layouts )
- this.$proLayoutInput.val( this.subscriber.pro_layouts )
- this.$basicLayoutRow.show()
- this.$proLayoutRow.toggle(this.subscriber.plan_name == "pro")
- },
- updateQuantity: function(e){
- e && e.preventDefault()
- this.tempSubscriber.basic_layouts = this.$basicLayoutInput.int()
- this.tempSubscriber.pro_layouts = this.$proLayoutInput.int()
-
- var plan = this.getPlan( this.tempSubscriber.plan_type )
- this.displayTotals(this.tempSubscriber, plan)
- this.$basicLayoutRow.show()
- this.$proLayoutRow.toggle(plan.name == "pro")
- },
- saveQuantity: function(e){
- e && e.preventDefault()
- // blabla.. save
- this.subscriber = this.tempSubscriber
- this.resetMode()
- },
-
- planMode: function(e){
- e && e.preventDefault()
- this.$paidPlan.addClass("editPlan")
- this.$planRadio.val( this.subscriber.plan_type )
- this.tempSubscriber = defaults({}, this.subscriber)
- },
- updatePlan: function(e){
- e && e.preventDefault()
- var plan = this.getPlan( this.$("[name=planRadio]").val() )
- this.displayTotals(this.tempSubscriber, plan)
- },
- savePlan: function(e){
- e && e.preventDefault()
- this.subscriber.plan_type = this.$("[name=planRadio]").val()
- this.subscriber = this.tempSubscriber
- this.resetMode()
- },
-
initialize: function(){
// this.parent = opt.parent
this.__super__.initialize.call(this)
@@ -135,6 +85,8 @@ var EditSubscriptionModal = ModalView.extend({
this.$basicLayoutInput = this.$("[data-role=basicLayoutInput]")
this.$proLayoutInput = this.$("[data-role=proLayoutInput]")
this.$planRadio = this.$("[name=planRadio]")
+ this.$basicPlanInput = this.$("[data-role=basicPlanInput]")
+ this.$proPlanInput = this.$("[data-role=proPlanInput]")
this.$gear = this.$(".gear")
},
@@ -198,7 +150,7 @@ var EditSubscriptionModal = ModalView.extend({
var t = {}
t.is_pro = plan.name == "pro"
t.is_monthly = subscriber.plan_period == "monthly"
- t.plan_price = t.is_monthly ? plan.basic_layout_monthly_price : plan.yearly_price
+ t.plan_price = t.is_monthly ? plan.monthly_price : plan.yearly_price
t.basic_layout_price = t.is_monthly ? plan.basic_layout_monthly_price : plan.basic_layout_yearly_price
t.basic_layout_total = subscriber.basic_layouts * t.basic_layout_price
t.pro_layout_price = t.is_monthly ? plan.pro_layout_monthly_price : plan.pro_layout_yearly_price
@@ -232,13 +184,59 @@ var EditSubscriptionModal = ModalView.extend({
this.$planTotal.toDollars ( totals.plan_total )
},
- addLayouts: function(e){
- e.preventDefault()
+ resetMode: function(e){
+ e && e.preventDefault()
+ this.$paidPlan.removeClass("editLayouts editPlan")
+ this.reset()
},
- changePlan: function(e){
- e.preventDefault()
+
+ layoutsMode: function(e){
+ e && e.preventDefault()
+ this.$paidPlan.addClass("editLayouts")
+ this.tempSubscriber = defaults({}, this.subscriber)
+ this.$basicLayoutInput.val( this.subscriber.basic_layouts )
+ this.$proLayoutInput.val( this.subscriber.pro_layouts )
+ this.$basicLayoutRow.show()
+ this.$proLayoutRow.toggle(this.subscriber.plan_name == "pro")
+ },
+ updateQuantity: function(e){
+ e && e.preventDefault()
+ var plan = this.getPlan( this.tempSubscriber.plan_type )
+ this.tempSubscriber.basic_layouts = this.$basicLayoutInput.int()
+ this.tempSubscriber.pro_layouts = this.$proLayoutInput.int()
+ this.displayTotals(this.tempSubscriber, plan)
+ this.$basicLayoutRow.show()
+ this.$proLayoutRow.toggle(plan.name == "pro")
+ },
+ saveQuantity: function(e){
+ e && e.preventDefault()
+ this.subscriber = this.tempSubscriber
+ this.resetMode()
+ // blabla.. save
},
+ planMode: function(e){
+ e && e.preventDefault()
+ this.$paidPlan.addClass("editPlan")
+ switch (this.subscriber.plan_type) {
+ case 'basic': this.$basicPlanInput.prop('checked', true); break;
+ case 'pro': this.$proPlanInput.prop('checked', true); break;
+ }
+ this.tempSubscriber = defaults({}, this.subscriber)
+ },
+ updatePlan: function(e){
+ e && e.preventDefault()
+ var plan_type = this.$("[name=planRadio]:checked").val()
+ var plan = this.getPlan( plan_type )
+ this.displayTotals(this.tempSubscriber, plan)
+ },
+ savePlan: function(e){
+ e && e.preventDefault()
+ this.subscriber.plan_type = this.$("[name=planRadio]:checked").val()
+ this.subscriber = this.tempSubscriber
+ this.resetMode()
+ // blabla.. save
+ },
sync: function(){
this.$gear.addClass("turning")
$.ajax({