summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/site/EditSubscriptionModal.js
blob: 342e8be2b866b648902efdea1f3d757227fb9ba3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var EditSubscriptionModal = ModalFormView.extend({
	el: ".mediaDrawer.editSubscription",
	action: "/api/subscription",
	method: "put",
	
	fixedClose: true,
	
	events: {
	  "click [data-role='']": 'togglePasswordFields'
	},
	
	initialize: function(){
		this.$freePlan = this.$("#free_plan")
		this.$paidPlan = this.$("#paid_plan")
		this.$proLayoutRow = this.$("#proLayoutRow")

		this.$billingInterval = this.$("[data-role=billingInterval]")

		this.$planType = this.$("[data-role=planType]")
		this.$planName = this.$("[data-role=planName]")
		this.$planCost = this.$("[data-role=planCost]")

		this.$basicLayoutCost = this.$("[data-role=basicLayoutCost]")
		this.$basicLayoutQuantity = this.$("[data-role=basicLayoutQuantity]")

		this.$proLayoutCost = this.$("[data-role=proLayoutCost]")
		this.$proLayoutQuantity = this.$("[data-role=proLayoutQuantity]")

		this.$upgradeSubscription = this.$("[data-role=upgradeSubscription]")
		this.$cancelSubscription = this.$("[data-role=cancelSubscription]")
	},

	load: function(){
		this.reset()
		$.get("/api/subscription", function(data){
			if (data.error) {
				this.$freePlan.show()
				this.$paidPlan.hide()
				this.show()
				return
			}
			this.$freePlan.show()
			this.$paidPlan.hide()
			
			var plan = data.plans[ data.subscription.plan_name ]
			
			this.show()
			
			// layouts
		}.bind(this))
	},
	
	updateTotals: function(){
	},

})