PageSourceSearch

https://robust-themes.com/themes/js/add_sections.js?v=52

js robust-themes.com collected 2026-09-24 12:36:10 UTC 17,461 bytes, 518 lines download raw bytes

1
2
3    $(document).ready(function(){
4
5        remove_empty_sections();
6 
7        $.get('/themes/sections.json?v=45',function(res){
8            play_site_video_on_body_click()
9            
10            SECTIONS = res;
11            populate_demos_sidebar()
12            if ($('.page').hasClass('dark-mode')){
13                SELECTED_SECTIONS_GROUP = 'Dark 1'
14            } else {
15                SELECTED_SECTIONS_GROUP = 'Popular'
16            }
17            
18            load_sections(DEMOS[SELECTED_SECTIONS_GROUP])
19            //section_color_replace()
20            //initiate_counters()
21        })
22 
23    })
24
25
26
27$('body').on('click','.show_headers_footers_catalog',function (e){
28    e.stopPropagation()
29    $('.addS_demos > div ,.show_headers_footers_catalog,.addS_sidebar_categories > div,.addS_demos_3top_Popular').removeClass('active')
30    $(this).addClass('active')
31    var objs = HEADERS
32    var st = '<div class="select_header_white">White Background</div>';
33    var sType = $(this).data('key')
34    if (sType == 'Footer'){
35        var objs = FOOTERS
36        st = '';
37    }
38
39    
40    for (item of objs){
41        if (item.name == 'barcelona'){
42            st += '<div class="select_header_white select_header_trans">
42Transparent Background</div>';
43        }
44        st +=  `
45            <div class="select_header_item" data-name="`+item.name+`"  >
46                <img src="`+item.img+`"/>
47                <div data-name="`+item.name+`" data-transparent="`+item.transparent+`"  data-stype="`+sType+`" class="addS_select_header"><span>Select `+sType+`</span><i class="fas fa-plus"></i></div>
48            </div>`
49    }
50    $('.addS_sections').html(st)
51})
52 
53 
54 $('body').on('click','.addS_demos > div , .addS_sidebar_categories  > div, .addS_demos_3top_Popular',function(){
55     if ($(this).hasClass('show_headers_footers_catalog')){ return }
56     $('.addS_demos > div ,.addS_sidebar_categories > div,.show_headers_footers_catalog, .addS_demos_3top_Popular').removeClass('active')
57     $(this).addClass('active')
58     SELECTED_SECTIONS_GROUP = $(this).text()
59     load_sections(DEMOS[SELECTED_SECTIONS_GROUP])
60 });
61 
62 $('.te_add_section_btn, .tip_add_section').click(function(){
63    $('.tip_popup_overlay').hide()
64     add_section_btn()
65 });
66 $('body').on('click','.addS_ad_section_btn',function(){
67     add_section_to_theme($(this))
68 });
69 
70 $('.te_stop_move_sections_btn,.sidebar_sections .sbw_back').click(function(){
71    stop_move_sections()
72 });    
73 
74 $('.addS_tabs > div').click(function () {
75     add_section_sidebar_tab($(this))
76 })
77 
78
79 $('body').on('click','.add_sections_delete',function(){
80        remove_section($(this).closest('div[data-section-id]').attr('data-section-id'))
81  });
82
83 
84
85 
86 function add_section_btn(){
87    $('.show-demos_added_style').remove()
88
89    if (typeof SECTIONS == 'undefined'){
90        $('.inpage_loading_overaly').css('display','flex')
91        setTimeout(function (){
92            $('.inpage_loading_overaly').css('display','none')
93            add_section_btn()
94        },500)
95        return
96    }
97
98     NEW_SECTION_ID = false
99     $('.addS_wrap').show()
100     setTimeout(function (){
101     reload_alll_swipers()
102     $('.page').scrollTop(0)
103     $('.addS_sections').scrollTop(0)
104     },200)
105     move_sections()
106 
107     sidebar_block_show('sections')
108 }
109 
110 
111 
112 
113 function remove_empty_sections(){
114     $('div[data-section-id]').each(function (){
115         if ($(this).html() == '' ){
116             $(this).remove()
117         }
118     })
119 }
120 
121 
122 
123 function populate_demos_sidebar(){
124     st = `<div class="addS_demos_3top">
125        <div class="addS_demos_3top_Popular category_dark" data-key="Dark 1"><i class="fas fa-lightbulb-slash"></i><span>Dark 1</span></div>
126        <div class="addS_demos_3top_Popular category_dark" data-key="Dark 2"><i class="fas fa-lightbulb-slash"></i><span>Dark 2</span></div>
127        <div class="addS_demos_3top_Popular category_dark" data-key="Dark 3"><i class="fas fa-lightbulb-slash"></i><span>Dark 3</span></div>
128        <div class="addS_demos_3top_Popular active" data-key="Popular"><i class="fas fa-star"></i><span>Popular</span></div>
129        <div class="show_headers_footers_catalog" data-key="Header"><i class='fas fa-border-top'></i><span>Headers</span></div>
130        <div class="show_headers_footers_catalog" data-key="Footer"><i class='fas fa-border-bottom'></i><span>Footers</span></div>
131     </div>`
132     st += '<div class="addS_demos">'
133     for (key in DEMOS ){
134         if (key == 'Popular') {break;}
135         var icon = DEMOS_ICON[key][0].replace(/linear-gradient/g,'#linear-gradient__')
136         st+= '<div>'+icon+'<span>'+key+'</span></div>';
137     }
138     st+= '</div>'
139     $('.addS_sidebar_demos').html(st)
140 }
141 
142 
143 function load_sections(section_names,scroll_to_section = true) {
144     if (scroll_to_section){
145         $('.addS_sections').scrollTop(0)
146     }
147 
148     $('.addS_sections').html('')
149     for (section_name of section_names){
150 
151         try {
152             let new_section = SECTIONS[section_name].replace(/data-aos/g,'data-aos1')
153             let rnum = Math.floor(Math.random() * 99999);
154             
155             new_section = new_section.replace(/wistia_42isirdu7n/g,'wistia_c1ludijve5')
156             new_section = new_section.replace(/wistia_c1ludijve5/g,'wistia_c1ludijve5_'+rnum)
157             
158             $section_html = $(new_section).prepend('')
159             $section_html.attr('data-name',section_name)
160     
161             //let st = '<div class="adj_color"><input type="text"/><span>U</span></div>'
162             //$section_html.append(st)
163     
164             let btn_st = '<div class="add_sec-wrapper"><div class="addS_section_name">
164'+section_name+'</div> <div data-name="'+section_name+'" class="addS_ad_section_btn"><i class="fas fa-plus"></i><span>Add Section</span></div></div>';
165             $section_html.prepend(btn_st)
166             $section_html.find('.data-countUp').removeClass('data-countUp')
167      
168     
169             $('.addS_sections').append($section_html.get(0).outerHTML);
170         } catch (e) {
171             console.log('ERROR loading - ' + section_name)
172         }
173 
174         
175     }
176     if ($('.page_wrap').attr('class').includes('btn_amsterdam')){
177         $('.addS_sections .a_button span').after('<i class="fal fa-long-arrow-alt-right hide-false m-l-12"></i>')
178     }
179 
180     transition_shapes_colors()
181     reload_alll_swipers()
182 
183 }
184 
185 
186 function reload_alll_swipers(){
187     $('.swiper-container').each(function (){
188 
189         let swiper = $(this)[0].swiper
190         if (swiper != undefined){
191             $(this)[0].swiper.update()
192         } else {
193             let section_id = $(this).closest('div[data-section-id]').attr('data-section-id')
194             window["swiper_"+section_id+"_function"]();
195         }
196         
197         
198     })
199 }
200
201
202 function remove_section(section_id){
203     $('[data-content-for-index] [data-section-id="'+section_id+'"]').remove()
204     sections_update_url()
205 }
206
207        
208
209 
210 console.log('add_sections.js') 
211 function add_section_to_theme($this){ 
212     let section_name = $this.closest('[data-section-id]').data('name')
213     NEW_SECTION_ID = $this.closest('[data-section-id]').attr('id')
214     let new_section = SECTIONS[section_name].replace(/data-aos/g,'data-aos1')
215     var $new_section = $(new_section).css('transform','scale(0)')
216     $new_section.prepend('<div class="add_sections_delete"></div>')
217     $('#section-footer').before($new_section.get(0).outerHTML);
218     $('.addS_layover_wrap').hide()
219     $('.page').scrollTop(100000)
220     $('.addS_sections').css('opacity','0.2')
221 
222     flicker_newly_added_section()
223 
224     sections_update_url();
225
226   
227 }
228 
229 function sections_update_url(){
230    replace_other_links()
231
232     var theme_sections = []
233     $('.page section[data-name]').each(function (){
234         let name = $(this).attr('data-name').replace(/  /g,' ').trim()
235         //if (['Header','Footer','Exit Pop',''].includes(name)){return}
236         let code = names2codes[name]
237         theme_sections.push(code)
238     })
239     DEMO.sections = theme_sections.join('-')
240     set_url();
241 }
242 
243 function flicker_newly_added_section(){
244     $flicker_elm = $('#section-footer').prev()
245     $flicker_elm.css('transform','scale(1)');
246     setTimeout(function (){
247         $flicker_elm.css('box-shadow','0px 0px 0px 0px #fffb86b0');
248         setTimeout(function (){
249             $flicker_elm.css('box-shadow','0px 0px 80px 80px #fffb86b0');
250             setTimeout(function (){
251                 $flicker_elm.css('box-shadow','0px 0px 0px 0px #fffb86b0');
252                 $('.addS_sections').css('opacity','1')
253             },500)
254         },500)
255     },500)
256 }
257 
258 
259 function move_sections(){
260     close_account_page_before_showing_sections()
261 
262     $('[data-aos]').attr('data-aos','data-aos1')
263     $('.page').css('transform','scale(0.2)')
264     $('body').addClass('move_mode')
265     $('body').addClass('move_mode_outline')
266
267     
268 
269     zoomScale = 0.2;
270     $( "div[data-content-for-index]" ).sortable(
271         {
272             start: function(e, ui) {
273                 var items = $(this).data()['uiSortable'].items;
274                 items.forEach(function(item) {
275                 item.height *= zoomScale;
276                 item.width *= zoomScale;
277                 });
278             },
279             sort: function(e, ui) {
280             let correction = window.width / 6.2
281             var changeLeft = ui.position.left - ui.originalPosition.left + correction  ;
282             var newLeft = ui.originalPosition.left + changeLeft / zoomScale - ui.item.parent().offset().left;
283             let continaer_offset = $('.move_mode_outline .page').scrollTop();
284             if (continaer_offset > 0 ){
285                 continaer_offset = continaer_offset - (continaer_offset * 0.2)
286             }    
287             var newTop = (ui.position.top - continaer_offset)   / zoomScale  ;         
288             ui.helper.css({
289                 left: newLeft,
290                 top: newTop
291             });
292             },
293             update:function(e, ui) {
294                 sections_update_url();
295             }
296         } 
297     );
298 
299     $( "div[data-content-for-index]" ).sortable( "option", "disabled", false );
300     $( "div[data-content-for-index]" ).disableSelection();
301
302     $( "div[data-content-for-index] div[data-section-id]" ).each(function (){
303         $(this).prepend('<div class="add_sections_delete"></div>')
304     })
305 
306 }
307 
308 
309 
310 
311 function stop_move_sections(){
312     $('.addS_wrap').hide()
313     //$('[data-aos]').attr('data-aos','data-aos1')
314     $( "div[data-content-for-index]" ).sortable("disable");
315     $('.page').css('transform','unset')
316     $('body').removeClass('move_mode_outline')
317 
318     $('.add_sections_delete').remove()
319 
320     sidebar_block_hide('sections')
321 
322     $('body').removeClass('move_mode')
323 
324     if (NEW_SECTION_ID){
325         $('.page_wrap').scrollTop(0)
326         setTimeout(function (){
327             $('.page_wrap').animate({
328                 scrollTop: $(".page #"+NEW_SECTION_ID).offset().top
329             }, 800)
330         },500)
331     }
332 
333     transition_shapes_colors()
334 
335 }
336 
337 
338 
339 function add_section_sidebar_tab($this){
340     $('.addS_tabs > div').removeClass('active')
341     $this.addClass('active')
342    
343     $('.sbw_middle').scrollTop(0)
344     if ($this.text() == 'Categories'){
345         $('.addS_sidebar_categories').show()
346         $('.addS_sidebar_demos').hide()
347     } else {
348         $('.addS_sidebar_categories').hide()
349         $('.addS_sidebar_demos').show()
350     }
351 }
352 
353 
354 
355 
356
357 
358 
359 $('body').on('click','.addS_select_header',function(){
360     select_header($(this).data('name'),$(this).data('transparent'),$(this).data('stype'))
361 });
362 
363 
364 $(document).ready(function(){
365      if ($('#section-header .sizer').length == 0){return}
366      var $first_section = $('div[data-dynamic-sections]>div:nth-child(1) .sizer')
367      INITIAL_HERO_PADDING = parseInt(getComputedStyle($first_section[0], null).getPropertyValue('padding-top').replace('px',''))  
368      INITIAL_HEADER_HEIGHT =  header_height_before = $('#section-header .sizer')[0].offsetHeight
369      INITIAL_HEADER_IS_TRANSPARENT = false
370      if ( $('.nsection.n_header').hasClass('transparent_header')){
371         INITIAL_HEADER_IS_TRANSPARENT = true
372      }
373      
374 })
375 
376 function select_header(theme_name,is_transparent,sType){
377 
378     let new_header = SECTIONS[theme_name + ' - '+ sType].replace(/data-aos/g,'data-aos1')
379     
380     if (sType == 'Header'){
381         $('.content-wrapper #section-header').replaceWith(new_header)
382     }
383     if (sType == 'Footer'){
384         $('.content-wrapper #section-footer').replaceWith(new_header)
385     }     
386 
387     $('.addS_wrap').hide()
388     $('.page').css('transform','unset')
389     $('body').removeClass('move_mode_outline')
390 
391     sidebar_block_hide('sections')
392     $('body').removeClass('move_mode')
393     transition_shapes_colors()
394 
395     if (sType == 'Header'){
396          adjust_hero_padding(is_transparent)
397          replace_header_menu_links()
398     }
399     if (sType == 'Footer'){
400         setTimeout(function (){
401             $('.page_wrap').animate({scrollTop: 10000}, 800)
402         },500)
403         replace_footer_menu_links()
404     }   
405     stop_move_sections()
406     sections_update_url();
407     
408 }
409 
410 /*
411 HEROS_PADDING = {
412 
413     'Uppsala - Hero': '0'
414     'Tokyo - Hero': ''
415     'Tokyo - Details':
416     'Uppsala - Hero':
417     'Palma - Hero':
418     'Basel - Hero':
419     'Osaka - Hero':
420     'Lyon - Hero':
421     'Melbourne - Hero'
422 }*/
423 
424 adjust_hero_padding_onload()
425 function adjust_hero_padding_onload(){
426     var queryString = window.location.search;
427     URL_PARMS = new URLSearchParams(queryString);
428 
429     var sections_parm = URL_PARMS.get('sections')
430     if(sections_parm){
431         let header_name = document.querySelector('#section-header section').getAttribute('data-name')
432         let first_section_name = document.querySelector('div[data-dynamic-sections]>div:nth-child(2) section').getAttribute('data-name')
433         header_name = header_name.split(' ')[0].toLowerCase()
434         first_section_name = first_section_name.split(' ')[0].toLowerCase()
435         if (header_name == first_section_name){
436             return
437         }
438     } else {
439         return
440     }
441 
442     adjust_hero_padding()
443 }
444 
445 
446 function adjust_hero_padding(){
447 
448     XCNT = 0
449     header_padding_Interval = setInterval(function (){
450         XCNT++
451         if (document.querySelector('#section-header .sizer') == undefined || XCNT > 40){
452             return
453         }
454         clearInterval(header_padding_Interval)
455 
456         if (document.querySelector('#section-header .transparent_header') != undefined ){
457             header_height = document.querySelector('#section-header .sizer').offsetHeight
458             var first_section = document.querySelector('div[data-dynamic-sections]>div:nth-child(2) .sizer')
459             first_section.style.paddingTop = header_height + 'px';
460 
461             let first_section_name = document.querySelector('div[data-dynamic-sections]>div:nth-child(2) section').getAttribute('data-name')
462             first_section_name = first_section_name.split(' ')[0]
463             if (['Uppsala','Tokyo','Kyoto','Stockholm','Rome','Venice','Milan','Varanasi','Patras','Vienna','Monaco'].includes(first_section_name)){
464                 $('#section-header').append('<style>.header-top:before{opacity:50% !important;}</style>')
465             }
466 
467         }
468     },500)
469     
470 }
471 
472 
473 $('.addS_search_remove').click(function () {
474    $('.addS_search_wrap input').val('')
475    SELECTED_SECTIONS_GROUP = 'Tokyo'
476    load_sections(DEMOS[SELECTED_SECTIONS_GROUP])
477})
478
479 $('.addS_search_wrap input').keyup(function () {
480    console.log($(this).val())
481    var results = []
482    var cnt = 0
483    for (section_name of Object.keys(SECTIONS)){
484        if (section_name.toLowerCase().includes($(this).val().toLowerCase())){
485            results.push(section_name)
486            cnt++
487            if (cnt > 10){break}
488        }
489        
490    }
491    console.log(results)
492    load_sections(results)
493 })
494 
495 
496 /*
497 function adjust_hero_padding_old(is_transparent) {
498 
499     header_height_after = $('#section-header .sizer')[0].offsetHeight
500 
501     var $first_section = $('div[data-dynamic-sections]>div:nth-child(2) .sizer')
502 
503     if (INITIAL_HEADER_IS_TRANSPARENT  && is_transparent){
504         var new_padding =  (header_height_after - INITIAL_HEADER_HEIGHT) + INITIAL_HERO_PADDING
505     } else if (!(INITIAL_HEADER_IS_TRANSPARENT)  && is_transparent) {
506         var new_padding =  header_height_after + INITIAL_HERO_PADDING
507         $('#section-header').append('<style>.   header-top:before{opacity:50% !important;}</style>')
508     } else if (!(INITIAL_HEADER_IS_TRANSPARENT)  && !(is_transparent))  {
509         var new_padding = INITIAL_HERO_PADDING
510     } else if (INITIAL_HEADER_IS_TRANSPARENT  && !(is_transparent))  {
511         var new_padding = INITIAL_HERO_PADDING - INITIAL_HEADER_HEIGHT
512     }
513 
514 
515     $first_section[0].style.paddingTop = new_padding + 'px';
516 }*/
517 
518    

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.