1( function( $, elementor ) { 2 "use strict"; 3 var WPKoiElements = { 4 init: function() { 5 elementor.hooks.addAction( 'frontend/element_ready/section', WPKoiElements.elementorSection ); 6 }, 7 elementorSection: function( $scope ) { 8 var $target = $scope, 9 instance = null, 10 editMode = Boolean( elementor.isEditMode() ); 11 12 instance = new wpkoiSectionBGC( $target ); 13 instance.init(); 14 }, 15 }; 16 $( window ).on( 'elementor/frontend/init', WPKoiElements.init ); 17 18 window.wpkoiSectionBGC = function( $target ) { 19 var self = this, 20 sectionId = $target.data('id'), 21 settings = getSettings($target), 22 editMode = Boolean( elementor.isEditMode() ), 23 $window = $( window ), 24 $body = $( 'body' ); 25 26 self.init = function() { 27 if ( ! settings ) { 28 return false; 29 } 30 self.generateLayouts(); 31 }; 32 33 function getSettings($target) { 34 var dataSettings = $target.data('settings'); 35 if (!dataSettings) { 36 return false; 37 } 38 39 // Extract background color from dataSettings 40 var backgroundColor = $target.data('scbgc'); 41 42 return { 43 'wpkoi_bgc_section_list' : [{ 44 'sectionid' : $target.data('id'), 45 'wpkoi_bgc_background_color': backgroundColor, 46 'section_wpkoi_background_change_speed': dataSettings['section_wpkoi_background_change_speed'] ? dataSettings['section_wpkoi_background_change_speed']['size'] : 300, 47 'section_wpkoi_background_change_pos': dataSettings['section_wpkoi_background_change_pos'] || 2, 48 'section_wpkoi_background_change_mob': dataSettings['section_wpkoi_background_change_mob'] || false, 49 'section_wpkoi_background_change': dataSettings['section_wpkoi_background_change'] || false, 50 }] 51 } 52 } 53 54 self.generateLayouts = function() { 55 $.each( settings['wpkoi_bgc_section_list'], function( index, layout ) { 56 var section_wpkoi_background_change = layout['section_wpkoi_background_change'] || false, 57 section_wpkoi_background_change_speed = layout['section_wpkoi_background_change_speed'] || 300, 58 section_wpkoi_background_change_pos = layout['section_wpkoi_background_change_pos'] || 2, 59 section_wpkoi_background_change_mob = layout['section_wpkoi_background_change_mob'] || false, 60 sectionid = layout['sectionid'], 61 wpkoi_bgc_background_color = layout['wpkoi_bgc_background_color']; 62 63 if ( !section_wpkoi_background_change ) { 64 $target.removeClass( 'wpkoi-background-change-section' ); 65 return false; 66 } 67 68 if ( ! editMode ) { 69 if ( section_wpkoi_background_change === 'true' ) { 70 $target.addClass( 'wpkoi-background-change-section' ); 71 $target.addClass( 'wpkoi-bcs-mob' ); 72 if ( section_wpkoi_background_change_mob === "true" ) { 73 $target.removeClass( 'wpkoi-bcs-mob' ); 74 } 75 76 $(window).on("scroll touchmove", function() { 77 var $window = $(window); 78 var scroll = $window.scrollTop() + ($window.height() / section_wpkoi_background_change_pos); 79 var $this = $(".wpkoi-background-change-section.elementor-element-" + sectionid); 80 if ($this.position().top <= scroll && $this.position().top + $this.height() > scroll) { 81 $("body").css("transition-duration", section_wpkoi_background_change_speed + "ms"); 82 $("body").css("background", wpkoi_bgc_background_color); 83 } 84 }); 85 } 86 } 87 }); 88 }; 89 } 90}( jQuery, window.elementorFrontend ) );
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.