Advertisement
Guest User

Untitled

a guest
Jan 27th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. _initGallery: function(settings){
  2.             var self = this;
  3.  
  4.             var HTML = "", HTMLmobile = "";
  5.  
  6.             var desktopContainer = document.createElement('div')
  7.             var mobileContainer = document.createElement('div')
  8.        
  9.             desktopContainer.className = "app-desktop";
  10.             mobileContainer.className = "app-mobile";
  11.  
  12.             var colums = settings.colums;
  13.             $(settings.id).addClass('row');
  14.             var collections = $(settings.id).find('.grid-item');
  15.             var galleryTitle = $('#app-title').text()
  16.    
  17.             var itemsInColums = collections.length / colums;
  18.             var subArraySize = Math.ceil(itemsInColums);
  19.    
  20.             var array = self._colSplit(collections, colums)
  21.             var blockArray = self._colSplit(array, 3)
  22.    
  23.             var arrayMobile = self._colSplit(collections, settings.responsive.mobile.colums)
  24.             var blockArrayMobile = self._colSplit(arrayMobile, 1);
  25.    
  26.    
  27.    
  28.             function renderApp(arr) {
  29.              
  30.               for(var k = 0; k < arr.length; k++) { // 3 lG COLUMN
  31.                            
  32.    
  33.                 if(k == 1) {
  34.                   HTML = HTML + `<div class="column-lg column-middle">`;
  35.                  
  36.                   HTML = HTML + `<div class="row-grid">`
  37.                      
  38.                       for(var s = 0; s < arr[k].length; s++) { // 3 COLUMN
  39.                         HTML = HTML + `<div class="${ self._columnOptions(colums) }">`
  40.                         for(var z = 0; z < 1; z++) { // 9 COLUMN
  41.                           HTML = HTML + `<div class="grid-item">${arr[1][s][z].innerHTML}</div>`
  42.                         }
  43.                         HTML = HTML + `</div>`
  44.                       }
  45.    
  46.                   HTML = HTML + `</div>`
  47.    
  48.                   HTML = HTML + `<div class="row-grid gallery-title">${galleryTitle}</div>`
  49.    
  50.                  
  51.                
  52.                   HTML = HTML + `<div class="row-grid">`
  53.                     for(var s = 0; s < arr[k].length; s++) { // 3 COLUMN
  54.                         HTML = HTML + `<div class="${ self._columnOptions(colums) }">`
  55.                         for(var z = 1; z < arr[k][s].length; z++) { // 9 COLUMN
  56.                           HTML = HTML + `<div class="grid-item">${arr[1][s][z].innerHTML}</div>`
  57.                         }
  58.                         HTML = HTML + `</div>`
  59.                     }
  60.                   HTML = HTML + `</div>`
  61.    
  62.                 } else {
  63.                   HTML = HTML + `<div class="column-lg">`;
  64.                     for(var s = 0; s < arr[k].length; s++) { // 3 COLUMN
  65.                   HTML = HTML + `<div class="${ self._columnOptions(colums) }">`
  66.                   for(var z = 0; z < arr[k][s].length; z++) { // 9 COLUMN
  67.                     HTML = HTML + `<div class="grid-item">${arr[k][s][z].innerHTML}</div>`
  68.                   }
  69.                     HTML = HTML + `</div>`
  70.                   }
  71.                 }
  72.                
  73.    
  74.                 HTML = HTML + `</div>`
  75.               }
  76.    
  77.             }
  78.    
  79.    
  80.             function renderAppMobile(arr) {
  81.              
  82.               for(var k = 0; k < arr.length; k++) { // 3 lG COLUMN
  83.    
  84.    
  85.                       HTMLmobile = HTMLmobile + `<div class="column-lg">`;
  86.                       HTMLmobile = HTMLmobile + `<div class="row-grid">`
  87.                       for(var s = 0; s < arr[k].length; s++) { // 3 COLUMN
  88.    
  89.                      
  90.                       HTMLmobile = HTMLmobile + `<div class="column">`
  91.                       for(var z = 0; z < 1; z++) { // 9 COLUMN
  92.                         if(arr[k][0]) {
  93.                           HTMLmobile = HTMLmobile + `<div class="grid-item">${arr[k][s][z].innerHTML}</div>`
  94.                         }
  95.                      
  96.                       }
  97.                       HTMLmobile = HTMLmobile + `</div>`  
  98.                     }
  99.                    
  100.    
  101.                 HTMLmobile = HTMLmobile + `</div>`
  102.                 HTMLmobile = HTMLmobile + `<div class="row-grid gallery-title">${galleryTitle}</div>`
  103.    
  104.                 HTMLmobile = HTMLmobile + `<div class="row-grid">`
  105.                     for(var s = 0; s < arr[k].length; s++) { // 3 COLUMN
  106.                       HTMLmobile = HTMLmobile + `<div class="column">`
  107.                         for(var z = 1; z < arr[k][s].length; z++) { // 9 COLUMN
  108.                           HTMLmobile = HTMLmobile + `<div class="grid-item">${arr[k][s][z].innerHTML}</div>`
  109.                         }
  110.                         HTMLmobile = HTMLmobile + `</div>`
  111.                     }
  112.                     HTMLmobile = HTMLmobile + `</div>`
  113.                 HTMLmobile = HTMLmobile + `</div>`
  114.               }
  115.                            
  116.             }
  117.    
  118.             // Cleaning APP Container and push new structure
  119.             renderApp(blockArray, blockArray.length)
  120.             renderAppMobile(blockArrayMobile, blockArrayMobile.length)
  121.    
  122.               $(settings.id).empty();
  123.               $('#app-gallery').append(desktopContainer);
  124.               $('#app-gallery').append(mobileContainer);
  125.               $('.app-desktop').append(HTML);
  126.               $('.app-mobile').append(HTMLmobile);
  127.    
  128.    
  129.         },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement