JAVASCRIPT   48
FooterControls
Guest on 18th September 2023 12:26:05 PM


  1. var FooterControls = function()
  2. {
  3.     return {
  4.         DOM:{
  5.             control:'ul.footer-item li.footer-item-header'
  6.         },
  7.         init:function()
  8.         {
  9.             var self = this;
  10.            
  11.             $(self.DOM.control).click(
  12.                 function()
  13.                 {  
  14.                     $(this).parent().find('li.footer-item-content').toggle();
  15.                 }
  16.             );
  17.         }
  18.     }
  19. }
  20.  
  21.  
  22. var SizesPopup = function()
  23. {
  24.         return {
  25.             DOM:{
  26.                 control:'a.footer-item-content-sizes',
  27.                 modal:  'div.modal'
  28.             },
  29.             init_popup_sizes:function(obj)
  30.             {
  31.                 var self = this;
  32.                
  33.                
  34.                 $(obj.content).find('li.size-icon-item').click(
  35.                     function()
  36.                     {
  37.                         var control = this;
  38.                         var tab = $(this).data('tab');
  39.                         $(control).closest('ul.sizes-form').find('ul.size-tab').hide();
  40.                         $(control).closest('ul.sizes-form').find('ul.' + tab).show();
  41.                     }
  42.                 );
  43.             },
  44.             init:function()
  45.             {
  46.                 var self = this;
  47.                
  48.                 $(self.DOM.control).click(
  49.                     function()
  50.                     {
  51.                         $(self.DOM.modal).modal();
  52.                         $(self.DOM.modal).css('height', 'auto');
  53.                         $(self.DOM.modal).find('li.loading').show();
  54.                         $(self.DOM.modal).find('li.content').html('');
  55.                        
  56.                         let show_tab = $(this).data('tab');
  57.                        
  58.                         $.ajax({
  59.                             url: AJAX_URL,
  60.                             type: 'POST',
  61.                             data: JSON.stringify({action:'getsizesform'})
  62.                         }).
  63.                         done(
  64.                             function(response)
  65.                             {
  66.                                 var res = JSON.parse(response);
  67.                                
  68.                                 $(self.DOM.modal).find('li.content').show();
  69.                                 $(self.DOM.modal).find('li.loading').hide();
  70.                                
  71.                                 $(self.DOM.modal).find('li.content').html(res.data);
  72.                                
  73.                                 $(self.DOM.modal).find('li.content').find('ul.' + show_tab).show();
  74.                                
  75.                                 self.init_popup_sizes({content:$(self.DOM.modal).find('li.content')});
  76.                             }
  77.                         );
  78.                        
  79. //                         if ($(window).width() > $(window).height())
  80. //                         {
  81. // //                             console.log($(this).data('landscape'));
  82. //                             $(self.DOM.modal).find('li.content').html($(this).data('landscape'));
  83. //                         }
  84. //                         else
  85. //                         {
  86. // //                             console.log($(this).data('portraite'));
  87. //                             $(self.DOM.modal).find('li.content').html($(this).data('portraite'));
  88. //                         }
  89.                        
  90.                         return false;
  91.                     }
  92.                 );
  93.             }
  94.         }    
  95. }
  96.  
  97. let GDPR = function()
  98. {
  99.     return {
  100.         DOM:{
  101.             control: 'div.gdpr button'
  102.         },
  103.         init:function()
  104.         {
  105.             let self = this;
  106.            
  107.             $(self.DOM.control).click(
  108.                 function()
  109.                 {
  110.                     $.ajax({
  111.                         url: AJAX_URL,
  112.                         type: 'POST',
  113.                         data: JSON.stringify({action:'gdpraccept', accept:1})
  114.                     }).
  115.                     done(
  116.                         function(response)
  117.                         {
  118.                             var res = JSON.parse(response);
  119.                             if (res.status)
  120.                             {
  121.                                 $(self.DOM.control).parent().hide();
  122.                             }
  123.                         }
  124.                     );
  125.                 }
  126.             );
  127.         }
  128.     }
  129.    
  130. }
  131.  
  132. $(document).ready(
  133.     function()
  134.     {
  135.         var footerControls = new FooterControls();
  136.         footerControls.init();
  137.        
  138.         var sizesPopup = new SizesPopup();
  139.         sizesPopup.init();
  140.        
  141.         let gdpr = new GDPR();
  142.         gdpr.init();
  143.     }
  144. );

Raw Paste

Login or Register to edit or fork this paste. It's free.