diff options
Diffstat (limited to 'StoneIsland/platforms/android/assets/www/js/lib/account/ConsentModal.js')
| -rw-r--r-- | StoneIsland/platforms/android/assets/www/js/lib/account/ConsentModal.js | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/ConsentModal.js b/StoneIsland/platforms/android/assets/www/js/lib/account/ConsentModal.js new file mode 100644 index 00000000..dfeb4fac --- /dev/null +++ b/StoneIsland/platforms/android/assets/www/js/lib/account/ConsentModal.js @@ -0,0 +1,85 @@ +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]") + this.$consentError = this.$("#consent_error") + }, + + check: function(){ + var status = localStorage.getItem('account_terms.consent') + if (status !== 'true') { + app.demand_consent = true + this.show() + return true + } else { + this.hide() + app.demand_consent = false + return false + } + }, + + show: function(){ + app.demand_consent = true + this.$el.show() + setTimeout(function(){ + this.$el.addClass('visible') + }.bind(this), 20) + app.curtain.show() + app.curtain.classList.add('opaque') + }, + + hide: function(){ + app.curtain.hide() + this.$el.removeClass('visible') + setTimeout(function(){ + this.$el.hide() + app.curtain.classList.remove('opaque') + }.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.$consentError.removeClass('visible') + } else { + this.$consentError.addClass('visible') + } + }, + + proceed: function(){ + var state = this.$checkbox.prop("checked") + if (!state) { + this.$consentError.addClass('visible') + return + } + app.demand_consent = false + this.hide() + localStorage.setItem('account_terms.consent', 'true') + }, + + logout: function(){ + app.demand_consent = false + this.hide() + localStorage.setItem('account_terms.consent', 'false') + app.router.go("account/logout") + }, + +})
\ No newline at end of file |
