Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // was this...
  2.  
  3.     $('.cookie-warning .accept').click(function(e){
  4.         e.preventDefault();
  5.         Cookies.set('allowed', 'yes');
  6.         $('.cookie-warning').fadeOut();
  7.     });
  8.  
  9.     $('.cookie-warning .decline').click(function(e){
  10.         e.preventDefault();
  11.         $('.cookie-warning').fadeOut();
  12.     });
  13.  
  14.     if (Cookies.get('allowed') == 'yes') {
  15.         Cookies.set('quotes', 'hide');
  16.         $('.cookie-warning').hide();
  17.     } else {
  18.         $('.cookie-warning').hide();
  19.         $('.cookie-warning').delay(4000).fadeIn();
  20.     }
  21.  
  22.  
  23. // now this...
  24.  
  25.     var cookie = {
  26.         init: function(){
  27.             this.cacheDom();
  28.             this.bindEvents();
  29.             this.showQuotes();
  30.         },
  31.         cacheDom: function() {
  32.             this.$warning = $('.cookie-warning');
  33.             this.$accept = this.$warning.find('.accept');
  34.             this.$decline = this.$warning.find('.decline');
  35.         },
  36.         bindEvents: function() {
  37.             this.$accept.on('click', this.acceptCookie.bind(this));
  38.             this.$decline.on('click', this.declineCookie.bind(this));
  39.         },
  40.         acceptCookie: function() {
  41.             this.$warning.fadeOut();
  42.             Cookies.set('allowed', 'yes');
  43.         },
  44.         declineCookie: function() {
  45.             this.$warning.fadeOut();
  46.         },
  47.         showQuotes: function() {
  48.             if (Cookies.get('allowed') == 'yes') {
  49.                 Cookies.set('quotes', 'hide');
  50.                 this.$warning.hide();
  51.             } else {
  52.                 this.$warning.hide();
  53.                 this.$warning.delay(4000).fadeIn();
  54.             }
  55.         }
  56.     }
  57.  
  58.     cookie.init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement