summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib/account/ConsentModal.js
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/www/js/lib/account/ConsentModal.js')
-rw-r--r--StoneIsland/www/js/lib/account/ConsentModal.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/StoneIsland/www/js/lib/account/ConsentModal.js b/StoneIsland/www/js/lib/account/ConsentModal.js
new file mode 100644
index 00000000..fcf2804c
--- /dev/null
+++ b/StoneIsland/www/js/lib/account/ConsentModal.js
@@ -0,0 +1,74 @@
+var ConsentModal = View.extend({
+
+ el: "#consent_modal",
+
+ events: {
+ "change [name=AccountTermsConsent]": "changeConsent",
+ "click #consent_proceed": "proceed",
+ "click #consent_logout": "logout",
+ "click a": "navigate",
+ },
+
+ initialize: function(){
+ this.$form = this.$(".form")
+ this.$msg = this.$(".msg")
+ this.$checkbox = this.$("[name=AccountTermsConsent]")
+ },
+
+ check: function(){
+ var status = localStorage.getItem('account_terms.consent')
+ if (status !== 'true') {
+ this.show()
+ } else {
+ this.hide()
+ }
+ },
+
+ show: function(){
+ this.$el.show()
+ setTimeout(function(){
+ this.$el.addClass('visible')
+ }.bind(this), 20)
+ app.curtain.show()
+ },
+
+ hide: function(){
+ app.curtain.hide()
+ this.$el.removeClass('visible')
+ setTimeout(function(){
+ this.$el.hide()
+ }.bind(this), 300)
+ },
+
+ navigate: function(e){
+ var href = $(e.currentTarget).attr('href').replace('#', '')
+ console.log(href)
+ this.hide()
+ app.router.go(href)
+ },
+
+ changeConsent: function(){
+ var state = this.$checkbox.prop("checked")
+ if (state) {
+ this.$el.addClass('consent-yes').removeClass('consent-no')
+ } else {
+ this.$el.addClass('consent-no').removeClass('consent-yes')
+ }
+ },
+
+ proceed: function(){
+ var state = this.$checkbox.prop("checked")
+ if (!state) {
+ return
+ }
+ this.hide()
+ localStorage.setItem('account_terms.consent', 'true')
+ },
+
+ logout: function(){
+ this.hide()
+ localStorage.setItem('account_terms.consent', 'false')
+ app.router.go("account/logout")
+ },
+
+}) \ No newline at end of file