Changeset 2334575
- Timestamp:
- 07/03/2020 01:06:09 AM (6 years ago)
- Location:
- dse-divi-section-enhancer/trunk
- Files:
-
- 5 edited
-
dse-functions/dse-functions.php (modified) (8 diffs)
-
dse-functions/scripts/defree_scripts.js (modified) (3 diffs)
-
dse-functions/scripts/migvimeo.js (modified) (6 diffs)
-
main.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dse-divi-section-enhancer/trunk/dse-functions/dse-functions.php
r2286572 r2334575 21 21 ); 22 22 //free scripts 23 if ( null !== get_option( 'dse-enable-scrollbar' ) || null !== get_option( 'dse-enable-sidebar' ) ) { 24 if ( get_option( 'dse-enable-scrollbar' ) != 'no' || get_option( 'dse-enable-sidebar' ) != 'no' ) { 25 wp_enqueue_script( 26 'divi-sections-enhancer-jquery-mCustomScrollbar-concat', 27 plugin_dir_url( __FILE__ ) . 'scripts/jquery.mCustomScrollbar.concat.min.js', 28 '', 29 rand( 0, 100 ) 30 ); 31 } 32 } 33 if ( null !== get_option( 'dse-enable-youtube' ) ) { 34 if ( get_option( 'dse-enable-youtube' ) != 'no' ) { 35 wp_enqueue_script( 36 'divi-sections-enhancer-jquery-youtubebackground', 37 plugin_dir_url( __FILE__ ) . 'scripts/jquery.youtubebackground.js', 38 '', 39 rand( 0, 100 ) 40 ); 41 } 42 } 43 if ( null !== get_option( 'dse-enable-tilteffect' ) ) { 44 if ( get_option( 'dse-enable-tilteffect' ) != 'no' ) { 45 wp_enqueue_script( 46 'divi-sections-enhancer-tilt', 47 plugin_dir_url( __FILE__ ) . 'scripts/tilt.jquery.js', 48 '', 49 rand( 0, 100 ) 50 ); 51 } 52 } 53 if ( null !== get_option( 'dse-enable-sidebar' ) ) { 54 if ( get_option( 'dse-enable-sidebar' ) != 'no' ) { 55 wp_enqueue_script( 56 'divi-sections-enhancer-miguras-offCanvas', 57 plugin_dir_url( __FILE__ ) . 'scripts/miguras-offCanvas.js', 58 '', 59 rand( 0, 100 ) 60 ); 61 } 62 } 63 if ( null !== get_option( 'dse-enable-particles' ) ) { 64 if ( get_option( 'dse-enable-particles' ) != 'no' ) { 65 wp_enqueue_script( 66 'divi-sections-enhancer-particleground', 67 plugin_dir_url( __FILE__ ) . 'scripts/jquery.particleground.min.js', 68 '', 69 rand( 0, 100 ) 70 ); 71 } 72 } 73 if ( null !== get_option( 'dse-enable-vimeo' ) ) { 74 if ( get_option( 'dse-enable-vimeo' ) != 'no' ) { 75 wp_enqueue_script( 76 'migdivi-vimeo', 77 plugin_dir_url( __FILE__ ) . 'scripts/migvimeo.js', 78 '', 79 rand( 0, 100 ) 80 ); 81 } 82 } 23 wp_enqueue_script( 24 'divi-sections-enhancer-jquery-mCustomScrollbar-concat', 25 plugin_dir_url( __FILE__ ) . 'scripts/jquery.mCustomScrollbar.concat.min.js', 26 '', 27 rand( 0, 100 ) 28 ); 83 29 wp_enqueue_script( 84 30 'divi-sections-enhancer-freefrontend', … … 98 44 function dse_data_script() 99 45 { 100 wp_localize_script( 'migdivi-vimeo', 'dseData', array( 101 'url' => plugin_dir_url( __DIR__ ), 46 wp_localize_script( 'divi-sections-enhancer-freefrontend', 'dseData', array( 47 'url' => plugin_dir_url( __DIR__ ), 48 'pluginUrl' => plugin_dir_url( __FILE__ ), 102 49 ) ); 103 50 } … … 794 741 'description' => esc_html__( 'Time after video starts to remove the preloader', 'divi_sections_enhancer' ), 795 742 'show_if' => divi_sections_enhancer_check_for_if( 'vimeobg' ), 743 ); 744 $newfields['divi_se_vimeobg_fallback_source'] = array( 745 'default' => 'all', 746 'label' => esc_html__( 'Deactivate', 'divi_sections_enhancer' ), 747 'type' => 'select', 748 'options' => array( 749 'all' => esc_html__( 'All Mobile Devices', 'divi_sections_enhancer' ), 750 'some' => esc_html__( 'Mobile Devices that not support the autoplay option', 'divi_sections_enhancer' ), 751 ), 752 'tab_slug' => 'custom_css', 753 'toggle_slug' => 'custom_css', 754 'description' => esc_html__( '', 'divi_sections_enhancer' ), 755 'show_if' => divi_sections_enhancer_check_for_if( 'vimeobg' ), 796 756 ); 797 757 //YOUTUBE BACKGROUND … … 1699 1659 $vimeoytbgend = $module->props['divi_se_vimeobg_end']; 1700 1660 $vimeoytbgdelay = $module->props['divi_se_vimeobg_delay']; 1661 $vimeoytbgfallsource = $module->props['divi_se_vimeobg_fallback_source']; 1701 1662 $vimeobgwidth = $module->props['divi_se_vimeobg_width']; 1702 1663 $vimeobgresponsive = et_pb_responsive_options()->get_property_values( $module->props, 'divi_se_vimeobg_width' ); … … 1769 1730 $data = sprintf( 1770 1731 ' 1771 data-vimeobg=\'{"id": "%1$s", "muted": "%2$s", "loop": "%3$s", "width": "%4$s", "widthT": "%5$s", "widthP": "%6$s", "preloader": "%7$s", "delay": "%8$s" }\'',1732 data-vimeobg=\'{"id": "%1$s", "muted": "%2$s", "loop": "%3$s", "width": "%4$s", "widthT": "%5$s", "widthP": "%6$s", "preloader": "%7$s", "delay": "%8$s", "fallsource": "%9$s"}\'', 1772 1733 $vimeobgid, 1773 1734 $vimeobgmute, … … 1777 1738 $vimeobg_phone, 1778 1739 $vimeobgpreloader, 1779 $vimeoytbgdelay 1740 $vimeoytbgdelay, 1741 $vimeoytbgfallsource 1780 1742 ); 1781 1743 $output = str_replace( 'class="et_pb_with_border et_pb_section ', $data . ' class="et_pb_with_border et_pb_section ' . $vimeobg . ' ', $output ); … … 1786 1748 $data = sprintf( 1787 1749 ' 1788 data-youtubebg=\'{"videoId": "%1$s", "muted": "%2$s", "loop": "%3$s", "width": "%4$s", "widthT": "%5$s", "widthP": "%6$s", "preloader": "%7$s", "start": "%8$s", "end": "%9$s", "delay": "%10$s", "bgoverlay": "%11$s", "controls": "%12$s" }\'',1750 data-youtubebg=\'{"videoId": "%1$s", "muted": "%2$s", "loop": "%3$s", "width": "%4$s", "widthT": "%5$s", "widthP": "%6$s", "preloader": "%7$s", "start": "%8$s", "end": "%9$s", "delay": "%10$s", "bgoverlay": "%11$s", "controls": "%12$s", "fallsource": "%13$s"}\'', 1789 1751 $vimeobgid, 1790 1752 $vimeobgmute, … … 1798 1760 $vimeoytbgdelay, 1799 1761 $vimeoytbgoverlay, 1800 $vimeoytcontrols 1762 $vimeoytcontrols, 1763 $vimeoytbgfallsource 1801 1764 ); 1802 1765 $output = str_replace( 'class="et_pb_with_border et_pb_section ', $data . ' class="et_pb_with_border et_pb_section divi_se_youtubebgnew ', $output ); -
dse-divi-section-enhancer/trunk/dse-functions/scripts/defree_scripts.js
r2050056 r2334575 2 2 function divi_sections_enhancer_scripts_free(){ 3 3 4 5 function divi_se_scrollbar(){ 4 function dse_migvimeo_script_loader(){ 5 var youtube = jQuery('.divi_se_youtubebgnew'); 6 var vimeo = jQuery('.divi_se_vimeobg'); 7 var src = window.dseData.pluginUrl; 8 var documentHead = document.getElementsByTagName("head")[0]; 9 10 11 var vimeoyoutubeScript = document.createElement("script"); 12 vimeoyoutubeScript.src = `${src}scripts/migvimeo.js`; 13 vimeoyoutubeScript.id = `migdivi-vimeo`; 14 vimeoyoutubeScript.type = "text/javascript"; 15 vimeoyoutubeScript.async = true; 16 vimeoyoutubeScript.defer = true; 17 18 if(youtube.length > 0 || vimeo.length > 0){ 19 20 if(!window.dseData.vimeoyoutubeScript){ 21 documentHead.appendChild(vimeoyoutubeScript); 22 if(document.querySelector('#divienhancer-modernizr')){ 23 document.querySelector('#divienhancer-modernizr').addEventListener('load', function(){ 24 25 26 27 window.dseData.vimeoyoutubeScript = 'loaded'; 28 29 }) 30 } 31 32 33 } 34 } 35 36 } 37 38 39 function dse_free_particles_loader(){ 40 var element = jQuery('.divi_se_particles_bg'); 41 var src = window.dseData.pluginUrl; 42 var documentHead = document.getElementsByTagName("head")[0]; 43 44 45 var elementScript = document.createElement("script"); 46 elementScript.src = `${src}scripts/jquery.particleground.min.js`; 47 elementScript.id = `divi-sections-enhancer-particleground`; 48 elementScript.type = "text/javascript"; 49 elementScript.async = true; 50 elementScript.defer = true; 51 52 if(element.length > 0){ 53 54 if(!window.dseData.freeParticles){ 55 documentHead.appendChild(elementScript); 56 if(document.querySelector('#divi-sections-enhancer-particleground')){ 57 document.querySelector('#divi-sections-enhancer-particleground').addEventListener('load', function(){ 58 59 60 divi_se_particles_background(); 61 window.dseData.freeParticles = 'loaded'; 62 63 }) 64 } 65 66 67 } 68 } 69 70 } 71 72 73 function dse_tilt_loader(){ 74 var element = jQuery('.divi_se_tilteffect'); 75 var src = window.dseData.pluginUrl; 76 var documentHead = document.getElementsByTagName("head")[0]; 77 78 79 var elementScript = document.createElement("script"); 80 elementScript.src = `${src}scripts/tilt.jquery.js`; 81 elementScript.id = `divi-sections-enhancer-tilt`; 82 elementScript.type = "text/javascript"; 83 elementScript.async = true; 84 elementScript.defer = true; 85 86 if(element.length > 0){ 87 88 if(!window.dseData.tilt){ 89 documentHead.appendChild(elementScript); 90 if(document.querySelector('#divi-sections-enhancer-tilt')){ 91 document.querySelector('#divi-sections-enhancer-tilt').addEventListener('load', function(){ 92 93 94 divi_dse_tilt_effect(); 95 window.dseData.tilt = 'loaded'; 96 97 }) 98 } 99 100 101 } 102 } 103 104 } 105 106 function dse_sidebar_loader(){ 107 var element = jQuery('.divi_se_offcanvas'); 108 var src = window.dseData.pluginUrl; 109 var documentHead = document.getElementsByTagName("head")[0]; 110 111 112 var elementScript = document.createElement("script"); 113 elementScript.src = `${src}scripts/miguras-offCanvas.js`; 114 elementScript.id = `divi-sections-enhancer-miguras-offCanvas`; 115 elementScript.type = "text/javascript"; 116 elementScript.async = true; 117 elementScript.defer = true; 118 119 if(element.length > 0){ 120 121 if(!window.dseData.sidebar){ 122 documentHead.appendChild(elementScript); 123 if(document.querySelector('#divi-sections-enhancer-miguras-offCanvas')){ 124 document.querySelector('#divi-sections-enhancer-miguras-offCanvas').addEventListener('load', function(){ 125 126 127 divi_dse_offcanvas(); 128 window.dseData.sidebar = 'loaded'; 129 130 }) 131 } 132 133 134 } 135 } 136 137 } 138 139 function dse_youtube_loader(){ 140 var element = jQuery('.divi_se_youtubebg'); 141 var src = window.dseData.pluginUrl; 142 var documentHead = document.getElementsByTagName("head")[0]; 143 144 145 var elementScript = document.createElement("script"); 146 elementScript.src = `${src}scripts/jquery.youtubebackground.js`; 147 elementScript.id = `divi-sections-enhancer-jquery-youtubebackground`; 148 elementScript.type = "text/javascript"; 149 elementScript.async = true; 150 elementScript.defer = true; 151 152 if(element.length > 0){ 153 154 if(!window.dseData.youtube){ 155 documentHead.appendChild(elementScript); 156 if(document.querySelector('#divi-sections-enhancer-jquery-youtubebackground')){ 157 document.querySelector('#divi-sections-enhancer-jquery-youtubebackground').addEventListener('load', function(){ 158 159 160 divi_se_youtube_background(); 161 window.dseData.youtube = 'loaded'; 162 163 }) 164 } 165 166 167 } 168 } 169 170 } 171 172 173 174 175 function divi_se_scrollbar(){ 6 176 7 177 jQuery(function($){ … … 389 559 390 560 return { 561 dse_migvimeo_script_loader: dse_migvimeo_script_loader, 391 562 divi_se_scrollbar: divi_se_scrollbar, 392 d ivi_se_youtube_background: divi_se_youtube_background,393 d ivi_dse_tilt_effect: divi_dse_tilt_effect,394 d ivi_dse_offcanvas: divi_dse_offcanvas,395 d ivi_se_particles_background: divi_se_particles_background,563 dse_free_particles_loader: dse_free_particles_loader, 564 dse_sidebar_loader: dse_sidebar_loader, 565 dse_tilt_loader: dse_tilt_loader, 566 dse_youtube_loader: dse_youtube_loader, 396 567 }; 397 568 … … 423 594 424 595 if(jQuery("#et-fb-app").length == 0) { 425 596 divi_sections_enhancer_scripts_free().dse_migvimeo_script_loader(); 597 divi_sections_enhancer_scripts_free().dse_free_particles_loader(); 598 divi_sections_enhancer_scripts_free().dse_sidebar_loader(); 599 divi_sections_enhancer_scripts_free().dse_tilt_loader(); 600 divi_sections_enhancer_scripts_free().dse_youtube_loader(); 426 601 divi_sections_enhancer_scripts_free().divi_se_scrollbar(); 427 divi_sections_enhancer_scripts_free().divi_se_youtube_background();428 divi_sections_enhancer_scripts_free().divi_dse_tilt_effect();429 divi_sections_enhancer_scripts_free().divi_dse_offcanvas();430 divi_sections_enhancer_scripts_free().divi_se_particles_background();431 432 602 } 433 603 -
dse-divi-section-enhancer/trunk/dse-functions/scripts/migvimeo.js
r2287097 r2334575 1 1 let migvimeoplayer = function () { 2 3 let dseUrl = dseData.url; 2 3 4 let dseUrl = window.dseData.url; 4 5 5 6 … … 22 23 let playerContainers = document.querySelectorAll('.divi_se_vimeobg'); 23 24 24 25 window.mobileAndTabletCheck = function() { 26 let check = false; 27 (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera); 28 return check; 29 }; 25 30 playerContainers.forEach(function (thisContainer) { 26 27 // GET GENERAL SIZES TO ADJUST VALUES LATER DEPENDING ON USER SELECTION 28 let playerContainerWidth = thisContainer.offsetWidth; 29 let playerContainerHeight = thisContainer.offsetHeight; 30 let screenHeight = window.screen.availHeight; 31 32 33 // CREATE AN OUTER AN INNER WRAPPER TO ADJUST THE SIZE TO CONTAINER AND ALSO OVERSIZE THE INNER ONE 34 let videoOuterWrapper = document.createElement("div"); 35 videoOuterWrapper.setAttribute("class", "mig-vimeo-outer-wrapper"); 36 37 38 let vimeoWrapper = document.createElement("div"); 39 vimeoWrapper.setAttribute("class", "mig-vimeo-wrapper"); 40 41 let vimeoOverlay = document.createElement("div"); 42 vimeoOverlay.setAttribute("class", "mig-vimeo-overlay"); 43 44 45 thisContainer.prepend(videoOuterWrapper); 46 47 videoOuterWrapper.prepend(vimeoWrapper); 48 videoOuterWrapper.prepend(vimeoOverlay); 49 50 51 let defaultoptions = { 52 id: "15069551", 53 width: playerContainerWidth, 54 autopause: false, 55 autoplay: true, 56 byline: false, 57 controls: false, 58 height: null, 59 loop: true, 60 maxheight: null, 61 maxwidth: null, 62 playsinline: true, 63 portrait: false, 64 muted: true, 65 title: false, 66 transparent: true, 67 speed: false, 68 }; 69 70 let data, customoptions = {}; 71 if (thisContainer.getAttribute("data-vimeobg") !== null) { 72 data = JSON.parse(thisContainer.getAttribute("data-vimeobg")); 73 customoptions = JSON.parse(thisContainer.getAttribute("data-vimeobg")); 74 delete customoptions.widthT; 75 delete customoptions.widthP; 76 delete customoptions.preloader; 77 78 79 80 // create variable to notify vimeo events when is neccesary apply preloader 81 82 if (data.preloader !== "none" && data.preloader !== undefined) { 83 84 85 customoptions.autoplay = false; 86 let vimeoLoader = document.createElement("div"); 87 vimeoLoader.setAttribute("class", "mig-vimeo-loader"); 88 if (data.preloader !== "black") { 89 vimeoLoader.style.backgroundImage = `url("${dseUrl}/dse-functions/images/${data.preloader}.gif")`; 90 } 91 92 videoOuterWrapper.appendChild(vimeoLoader); 93 } 94 95 96 // FIRST WE ADJUST VALUES DEPENDING ON SCREEN WIDTH 97 if (playerContainerWidth < 980) { 98 99 // adjust preloader position on mobile devices to prevent wrong display on large sections 100 if (thisContainer.querySelector(".mig-vimeo-loader")) { 101 thisContainer.querySelector(".mig-vimeo-loader").style.backgroundPositionY = `${screenHeight / 2}px`; 102 } 103 104 (data.widthP) ? customoptions.width = data.widthP : customoptions.width = data.width; 105 } 106 107 108 // ADJUST VIDEO HEIGHT AND WIDTH 109 if (customoptions.width == "height" || customoptions.width == "regularheight") { 110 let overSizeWidth = playerContainerHeight * 2.65; 111 if(overSizeWidth <= playerContainerWidth){ 112 overSizeWidth = playerContainerWidth; 113 } 114 customoptions.width = overSizeWidth; 115 vimeoWrapper.style.width = overSizeWidth + "px"; 116 117 vimeoWrapper.style.marginLeft = "-" + ((overSizeWidth - playerContainerWidth) / 2 + "px"); 118 119 } 120 else if (customoptions.width == "screen") { 121 let overSizeScreen = screenHeight * 2.65; 122 customoptions.width = overSizeScreen; 123 vimeoWrapper.style.width = overSizeScreen + "px"; 124 125 vimeoWrapper.style.marginLeft = "-" + ((overSizeScreen - playerContainerWidth) / 2 + "px"); 126 127 } 128 else if (customoptions.width == "parallax") { 129 let overSizeScreen = screenHeight * 2.65; 130 customoptions.width = overSizeScreen; 131 vimeoWrapper.style.width = overSizeScreen + "px"; 132 133 vimeoWrapper.style.marginLeft = "-" + ((overSizeScreen - playerContainerWidth) / 2 + "px"); 134 135 136 window.addEventListener("scroll", function (e) { 137 138 //console.log(window.scrollY); 139 //console.log(thisContainer.offsetTop); 140 141 if (window.scrollY >= thisContainer.offsetTop && 142 window.scrollY <= thisContainer.offsetTop + thisContainer.offsetHeight 31 var allData = JSON.parse(thisContainer.getAttribute("data-vimeobg")); 32 var fallback = false; 33 var fallsource = allData.fallsource; 34 var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; 35 36 if(fallsource == 'some' && iOS == true){ 37 fallback = true; 38 } 39 if(fallsource == 'all' && document.querySelector('body').classList.contains('et_mobile_device')){ 40 fallback = true; 41 } 42 43 44 45 if(!fallback){ 46 // GET GENERAL SIZES TO ADJUST VALUES LATER DEPENDING ON USER SELECTION 47 let playerContainerWidth = thisContainer.offsetWidth; 48 let playerContainerHeight = thisContainer.offsetHeight; 49 let screenHeight = window.screen.availHeight; 50 51 52 // CREATE AN OUTER AN INNER WRAPPER TO ADJUST THE SIZE TO CONTAINER AND ALSO OVERSIZE THE INNER ONE 53 let videoOuterWrapper = document.createElement("div"); 54 videoOuterWrapper.setAttribute("class", "mig-vimeo-outer-wrapper"); 55 56 57 let vimeoWrapper = document.createElement("div"); 58 vimeoWrapper.setAttribute("class", "mig-vimeo-wrapper"); 59 60 let vimeoOverlay = document.createElement("div"); 61 vimeoOverlay.setAttribute("class", "mig-vimeo-overlay"); 62 63 64 thisContainer.prepend(videoOuterWrapper); 65 66 videoOuterWrapper.prepend(vimeoWrapper); 67 videoOuterWrapper.prepend(vimeoOverlay); 68 69 70 let defaultoptions = { 71 id: "15069551", 72 width: playerContainerWidth, 73 autopause: false, 74 autoplay: true, 75 byline: false, 76 controls: false, 77 height: null, 78 loop: true, 79 maxheight: null, 80 maxwidth: null, 81 playsinline: true, 82 portrait: false, 83 muted: true, 84 title: false, 85 transparent: true, 86 speed: false, 87 }; 88 89 let data, customoptions = {}; 90 if (thisContainer.getAttribute("data-vimeobg") !== null) { 91 data = JSON.parse(thisContainer.getAttribute("data-vimeobg")); 92 customoptions = JSON.parse(thisContainer.getAttribute("data-vimeobg")); 93 delete customoptions.widthT; 94 delete customoptions.widthP; 95 delete customoptions.preloader; 96 97 98 99 // create variable to notify vimeo events when is neccesary apply preloader 100 101 if (data.preloader !== "none" && data.preloader !== undefined) { 102 103 104 customoptions.autoplay = false; 105 let vimeoLoader = document.createElement("div"); 106 vimeoLoader.setAttribute("class", "mig-vimeo-loader"); 107 if (data.preloader !== "black") { 108 vimeoLoader.style.backgroundImage = `url("${dseUrl}/dse-functions/images/${data.preloader}.gif")`; 109 } 110 111 videoOuterWrapper.appendChild(vimeoLoader); 112 } 113 114 115 // FIRST WE ADJUST VALUES DEPENDING ON SCREEN WIDTH 116 if (playerContainerWidth < 980) { 117 118 // adjust preloader position on mobile devices to prevent wrong display on large sections 119 if (thisContainer.querySelector(".mig-vimeo-loader")) { 120 thisContainer.querySelector(".mig-vimeo-loader").style.backgroundPositionY = `${screenHeight / 2}px`; 121 } 122 123 (data.widthP) ? customoptions.width = data.widthP : customoptions.width = data.width; 124 } 125 126 127 // ADJUST VIDEO HEIGHT AND WIDTH 128 if (customoptions.width == "height" || customoptions.width == "regularheight") { 129 let overSizeWidth = playerContainerHeight * 2.65; 130 if(overSizeWidth <= playerContainerWidth){ 131 overSizeWidth = playerContainerWidth; 132 } 133 customoptions.width = overSizeWidth; 134 vimeoWrapper.style.width = overSizeWidth + "px"; 135 136 vimeoWrapper.style.marginLeft = "-" + ((overSizeWidth - playerContainerWidth) / 2 + "px"); 137 138 } 139 else if (customoptions.width == "screen") { 140 let overSizeScreen = screenHeight * 2.65; 141 customoptions.width = overSizeScreen; 142 vimeoWrapper.style.width = overSizeScreen + "px"; 143 144 vimeoWrapper.style.marginLeft = "-" + ((overSizeScreen - playerContainerWidth) / 2 + "px"); 145 146 } 147 else if (customoptions.width == "parallax") { 148 let overSizeScreen = screenHeight * 2.65; 149 customoptions.width = overSizeScreen; 150 vimeoWrapper.style.width = overSizeScreen + "px"; 151 152 vimeoWrapper.style.marginLeft = "-" + ((overSizeScreen - playerContainerWidth) / 2 + "px"); 153 154 155 window.addEventListener("scroll", function (e) { 156 157 //console.log(window.scrollY); 158 //console.log(thisContainer.offsetTop); 159 160 if (window.scrollY >= thisContainer.offsetTop && 161 window.scrollY <= thisContainer.offsetTop + thisContainer.offsetHeight 162 163 ) { 164 thisContainer.querySelector(".mig-vimeo-wrapper").style.position = "fixed"; 165 } 166 else { 167 thisContainer.querySelector(".mig-vimeo-wrapper").style.position = "relative"; 168 } 169 }) 170 171 } 172 else { 173 delete customoptions.width; 174 } 175 176 177 } 178 179 180 let finaloptions = { ...defaultoptions, ...customoptions }; 181 182 183 let embedHere = thisContainer.querySelector(".mig-vimeo-wrapper"); 184 185 let videoPlayer = new Vimeo.Player(embedHere, finaloptions); 186 187 188 videoPlayer.on("loaded", function () { 189 190 if(data.preloader != "none"){ 191 videoPlayer.play() 192 .then(function(event){}) 193 .catch(function(error){ 194 console.log("error vimeo"); 195 videoPlayer.setVolume(0).then(function(){ 196 videoPlayer.play(); 197 }); 143 198 144 ) {145 thisContainer.querySelector(".mig-vimeo-wrapper").style.position = "fixed";146 }147 else {148 thisContainer.querySelector(".mig-vimeo-wrapper").style.position = "relative";149 }150 })151 152 }153 else {154 delete customoptions.width;155 }156 157 158 }159 160 161 let finaloptions = { ...defaultoptions, ...customoptions };162 163 164 let embedHere = thisContainer.querySelector(".mig-vimeo-wrapper");165 166 let videoPlayer = new Vimeo.Player(embedHere, finaloptions);167 168 169 videoPlayer.on("loaded", function () {170 171 if(data.preloader != "none"){172 videoPlayer.play()173 .then(function(event){})174 .catch(function(error){175 console.log("error vimeo");176 videoPlayer.setVolume(0).then(function(){177 videoPlayer.play();178 199 }); 179 180 }); 181 } 182 183 })184 185 videoPlayer.on("play", function () {186 187 if (data.preloader != "none") {188 if (thisContainer.querySelector(".mig-vimeo-loader")) {189 setTimeout(function () {190 thisContainer.querySelector(".mig-vimeo-loader").style.backgroundColor = "transparent";191 thisContainer.querySelector(".mig-vimeo-loader").style.backgroundImage = "none";192 }, data.delay);193 } 194 } 195 196 } )197 198 }) 200 } 201 202 }) 203 204 videoPlayer.on("play", function () { 205 206 if (data.preloader != "none") { 207 if (thisContainer.querySelector(".mig-vimeo-loader")) { 208 setTimeout(function () { 209 thisContainer.querySelector(".mig-vimeo-loader").style.backgroundColor = "transparent"; 210 thisContainer.querySelector(".mig-vimeo-loader").style.backgroundImage = "none"; 211 }, data.delay); 212 } 213 } 214 215 }) 216 217 } // end of if fallback 218 219 }) //end of foreach 199 220 200 221 … … 212 233 213 234 let migyoutubeplayer = function () { 235 236 214 237 window.migYtplayersLoaded = {}; 215 238 … … 218 241 const mainWindow = this; 219 242 220 let dseUrl = dseData.url;243 let dseUrl = window.dseData.url; 221 244 222 245 … … 242 265 243 266 playerContainers.forEach(function (thisContainer, index) { 244 245 // GET GENERAL SIZES TO ADJUST VALUES LATER DEPENDING ON USER SELECTION 246 let playerContainerWidth = thisContainer.offsetWidth; 247 let playerContainerHeight = thisContainer.offsetHeight; 248 let screenHeight = window.screen.availHeight; 249 let background = getComputedStyle( thisContainer ,null).getPropertyValue('background'); 250 251 252 // CREATE AN OUTER AN INNER WRAPPER TO ADJUST THE SIZE TO CONTAINER AND ALSO OVERSIZE THE INNER ONE 253 let videoOuterWrapper = document.createElement("div"); 254 videoOuterWrapper.setAttribute("class", "mig-youtube-outer-wrapper"); 255 256 257 let youtubeWrapper = document.createElement("div"); 258 youtubeWrapper.setAttribute("class", "mig-youtube-wrapper"); 259 260 let youtubeWrapperIframe = document.createElement("div"); 261 youtubeWrapperIframe.setAttribute("class", "mig-youtube-wrapper-iframe"); 262 263 let youtubeOverlay = document.createElement("div"); 264 youtubeOverlay.setAttribute("class", "mig-youtube-overlay"); 265 266 let youtubeCustomOverlay = document.createElement("div"); 267 youtubeCustomOverlay.setAttribute("class", "mig-youtube-customoverlay"); 268 269 270 thisContainer.prepend(videoOuterWrapper); 271 videoOuterWrapper.prepend(youtubeWrapper); 272 273 videoOuterWrapper.prepend(youtubeOverlay); 274 youtubeWrapper.prepend(youtubeWrapperIframe); 275 276 277 278 279 280 281 282 283 let defaultoptions = { 284 height: "100%", 285 width: playerContainerWidth, 286 videoId: 'M7lc1UVf-VE', 287 playerVars: { 288 autoplay: 1, 289 controls: 0, 290 disablekb: 1, 291 enablejsapi: 1, 292 fs: 0, 293 iv_load_policy: 3, 294 loop: 0, 295 modestbranding: 1, 296 origin: window.location.origin, 297 rel: 0, 298 showinfo: 0, 299 start: null, 300 end: null 301 }, 267 var allData = JSON.parse(thisContainer.getAttribute("data-youtubebg")); 268 var fallback = false; 269 var fallsource = allData.fallsource; 270 var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; 271 272 if(fallsource == 'some' && iOS == true){ 273 fallback = true; 274 } 275 if(fallsource == 'all' && document.querySelector('body').classList.contains('et_mobile_device')){ 276 fallback = true; 277 } 278 279 280 if(fallback != 'caca'){ 281 // GET GENERAL SIZES TO ADJUST VALUES LATER DEPENDING ON USER SELECTION 282 let playerContainerWidth = thisContainer.offsetWidth; 283 let playerContainerHeight = thisContainer.offsetHeight; 284 let screenHeight = window.screen.availHeight; 285 let background = getComputedStyle( thisContainer ,null).getPropertyValue('background'); 286 287 288 // CREATE AN OUTER AN INNER WRAPPER TO ADJUST THE SIZE TO CONTAINER AND ALSO OVERSIZE THE INNER ONE 289 let videoOuterWrapper = document.createElement("div"); 290 videoOuterWrapper.setAttribute("class", "mig-youtube-outer-wrapper"); 291 292 293 let youtubeWrapper = document.createElement("div"); 294 youtubeWrapper.setAttribute("class", "mig-youtube-wrapper"); 295 296 let youtubeWrapperIframe = document.createElement("div"); 297 youtubeWrapperIframe.setAttribute("class", "mig-youtube-wrapper-iframe"); 298 299 let youtubeOverlay = document.createElement("div"); 300 youtubeOverlay.setAttribute("class", "mig-youtube-overlay"); 301 302 let youtubeCustomOverlay = document.createElement("div"); 303 youtubeCustomOverlay.setAttribute("class", "mig-youtube-customoverlay"); 304 305 306 thisContainer.prepend(videoOuterWrapper); 307 videoOuterWrapper.prepend(youtubeWrapper); 308 309 videoOuterWrapper.prepend(youtubeOverlay); 310 youtubeWrapper.prepend(youtubeWrapperIframe); 311 312 313 314 315 316 317 318 319 let defaultoptions = { 320 height: "100%", 321 width: playerContainerWidth, 322 videoId: 'M7lc1UVf-VE', 323 playerVars: { 324 autoplay: 1, 325 controls: 0, 326 disablekb: 1, 327 enablejsapi: 1, 328 fs: 0, 329 iv_load_policy: 3, 330 loop: 0, 331 modestbranding: 1, 332 origin: window.location.origin, 333 rel: 0, 334 showinfo: 0, 335 start: null, 336 end: null 337 }, 338 339 events: { 340 'onReady': migYTReady, 341 'onStateChange' : migYTPlay, 342 'onError' : migYTError 343 } 344 }; 345 346 let customoptions = {}; 347 if (thisContainer.getAttribute("data-youtubebg") !== null) { 348 customoptions = JSON.parse(thisContainer.getAttribute("data-youtubebg")); 349 350 351 // create variable to notify youtube events when is neccesary apply preloader 352 if(customoptions.bgoverlay == "yes"){ 353 videoOuterWrapper.prepend(youtubeCustomOverlay); 354 youtubeCustomOverlay.style.background = background; 355 } 356 357 358 if (customoptions.preloader !== "none" && customoptions.preloader !== undefined) { 359 360 361 362 let youtubeLoader = document.createElement("div"); 363 youtubeLoader.setAttribute("class", "mig-youtube-loader"); 364 if (customoptions.preloader !== "black") { 365 youtubeLoader.style.backgroundImage = `url("${dseUrl}/dse-functions/images/${customoptions.preloader}.gif")`; 366 } 367 368 videoOuterWrapper.appendChild(youtubeLoader); 369 } 370 371 372 // FIRST WE ADJUST VALUES DEPENDING ON SCREEN WIDTH 373 if (playerContainerWidth < 980) { 374 375 // adjust preloader position on mobile devices to prevent wrong display on large sections 376 if (thisContainer.querySelector(".mig-youtube-loader")) { 377 thisContainer.querySelector(".mig-youtube-loader").style.backgroundPositionY = `${screenHeight / 2}px`; 378 } 379 380 (customoptions.widthP) ? customoptions.width = customoptions.widthP : customoptions.width = customoptions.width; 381 } 382 383 384 // ADJUST VIDEO HEIGHT AND WIDTH 385 if (customoptions.width == "width") { 386 let adjustedHeight = playerContainerWidth * 0.562; 302 387 303 events: { 304 'onReady': migYTReady, 305 'onStateChange' : migYTPlay, 306 'onError' : migYTError 307 } 308 }; 309 310 let customoptions = {}; 311 if (thisContainer.getAttribute("data-youtubebg") !== null) { 312 customoptions = JSON.parse(thisContainer.getAttribute("data-youtubebg")); 313 314 315 // create variable to notify youtube events when is neccesary apply preloader 316 if(customoptions.bgoverlay == "yes"){ 317 videoOuterWrapper.prepend(youtubeCustomOverlay); 318 youtubeCustomOverlay.style.background = background; 319 } 320 321 322 if (customoptions.preloader !== "none" && customoptions.preloader !== undefined) { 323 324 325 326 let youtubeLoader = document.createElement("div"); 327 youtubeLoader.setAttribute("class", "mig-youtube-loader"); 328 if (customoptions.preloader !== "black") { 329 youtubeLoader.style.backgroundImage = `url("${dseUrl}/dse-functions/images/${customoptions.preloader}.gif")`; 330 } 331 332 videoOuterWrapper.appendChild(youtubeLoader); 333 } 334 335 336 // FIRST WE ADJUST VALUES DEPENDING ON SCREEN WIDTH 337 if (playerContainerWidth < 980) { 338 339 // adjust preloader position on mobile devices to prevent wrong display on large sections 340 if (thisContainer.querySelector(".mig-youtube-loader")) { 341 thisContainer.querySelector(".mig-youtube-loader").style.backgroundPositionY = `${screenHeight / 2}px`; 342 } 343 344 (customoptions.widthP) ? customoptions.width = customoptions.widthP : customoptions.width = customoptions.width; 345 } 346 347 348 // ADJUST VIDEO HEIGHT AND WIDTH 349 if (customoptions.width == "width") { 350 let adjustedHeight = playerContainerWidth * 0.562; 351 352 customoptions.height = adjustedHeight 353 } 354 355 if (customoptions.width == "height") { 356 let overSizeWidth = playerContainerHeight * 2.65; 357 if(overSizeWidth <= playerContainerWidth){ 358 overSizeWidth = playerContainerWidth; 359 } 360 customoptions.width = overSizeWidth; 361 youtubeWrapper.style.width = overSizeWidth + "px"; 362 363 youtubeWrapper.style.marginLeft = "-" + ((overSizeWidth - playerContainerWidth) / 2 + "px"); 364 customoptions.height = playerContainerHeight * 1; 365 } 366 else if (customoptions.width == "regularheight") { 367 customoptions.width = "100%"; 368 customoptions.height = playerContainerHeight; 369 } 370 else if (customoptions.width == "screen") { 371 let overSizeScreen = screenHeight * 2.65; 372 customoptions.width = overSizeScreen; 373 youtubeWrapper.style.width = overSizeScreen + "px"; 374 375 youtubeWrapper.style.marginLeft = "-" + ((overSizeScreen - playerContainerWidth) / 2 + "px"); 376 customoptions.height = screenHeight * 1; 377 } 378 else if (customoptions.width == "parallax") { 379 let overSizeScreen = screenHeight * 2.65; 380 customoptions.width = overSizeScreen; 381 youtubeWrapper.style.width = overSizeScreen + "px"; 382 383 youtubeWrapper.style.marginLeft = "-" + ((overSizeScreen - playerContainerWidth) / 2 + "px"); 384 customoptions.height = screenHeight * 1.05; 385 386 window.addEventListener("scroll", function (e) { 387 388 //console.log(window.scrollY); 389 //console.log(thisContainer.offsetTop); 390 391 if (window.scrollY >= thisContainer.offsetTop && 392 window.scrollY <= thisContainer.offsetTop + thisContainer.offsetHeight 393 394 ) { 395 thisContainer.querySelector(".mig-youtube-wrapper").style.position = "fixed"; 396 } 397 else { 398 thisContainer.querySelector(".mig-youtube-wrapper").style.position = "relative"; 399 } 400 }) 401 402 } 403 else { 404 delete customoptions.width; 405 } 406 407 408 } 409 410 411 let finaloptions = { ...defaultoptions, ...customoptions }; 412 (customoptions.start !== null)? finaloptions.playerVars.start = customoptions.start : ""; 413 (customoptions.end !== null)? finaloptions.playerVars.end = customoptions.end : ""; 414 if(customoptions.controls === "yes") { 415 finaloptions.playerVars.controls = 2; 416 if(thisContainer.querySelector(".mig-youtube-overlay") != null){ 417 thisContainer.querySelector(".mig-youtube-overlay").style.display = "none"; 418 } 419 420 if(thisContainer.querySelector(".mig-youtube-loader") != null){ 421 thisContainer.querySelector(".mig-youtube-loader").style.display = "none"; 422 } 423 424 } 425 426 427 //ASIGN AN ID INDEX DEPENDENT AND THEN INSERT IN THE MAIN OBJECT LO RESCUE LATER ON YOUTUBE FUNCTION 428 thisContainer.querySelector(".mig-youtube-wrapper").setAttribute("id", `mig-youtube-wrapper-${index}`); 388 customoptions.height = adjustedHeight 389 } 390 391 if (customoptions.width == "height") { 392 let overSizeWidth = playerContainerHeight * 2.65; 393 if(overSizeWidth <= playerContainerWidth){ 394 overSizeWidth = playerContainerWidth; 395 } 396 customoptions.width = overSizeWidth; 397 youtubeWrapper.style.width = overSizeWidth + "px"; 398 399 youtubeWrapper.style.marginLeft = "-" + ((overSizeWidth - playerContainerWidth) / 2 + "px"); 400 customoptions.height = playerContainerHeight * 1; 401 } 402 else if (customoptions.width == "regularheight") { 403 customoptions.width = "100%"; 404 customoptions.height = playerContainerHeight; 405 } 406 else if (customoptions.width == "screen") { 407 let overSizeScreen = screenHeight * 2.65; 408 customoptions.width = overSizeScreen; 409 youtubeWrapper.style.width = overSizeScreen + "px"; 410 411 youtubeWrapper.style.marginLeft = "-" + ((overSizeScreen - playerContainerWidth) / 2 + "px"); 412 customoptions.height = screenHeight * 1; 413 } 414 else if (customoptions.width == "parallax") { 415 let overSizeScreen = screenHeight * 2.65; 416 customoptions.width = overSizeScreen; 417 youtubeWrapper.style.width = overSizeScreen + "px"; 418 419 youtubeWrapper.style.marginLeft = "-" + ((overSizeScreen - playerContainerWidth) / 2 + "px"); 420 customoptions.height = screenHeight * 1.05; 421 422 window.addEventListener("scroll", function (e) { 423 424 //console.log(window.scrollY); 425 //console.log(thisContainer.offsetTop); 426 427 if (window.scrollY >= thisContainer.offsetTop && 428 window.scrollY <= thisContainer.offsetTop + thisContainer.offsetHeight 429 430 ) { 431 thisContainer.querySelector(".mig-youtube-wrapper").style.position = "fixed"; 432 } 433 else { 434 thisContainer.querySelector(".mig-youtube-wrapper").style.position = "relative"; 435 } 436 }) 437 438 } 439 else { 440 delete customoptions.width; 441 } 442 443 444 } 445 446 447 let finaloptions = { ...defaultoptions, ...customoptions }; 448 (customoptions.start !== null)? finaloptions.playerVars.start = customoptions.start : ""; 449 (customoptions.end !== null)? finaloptions.playerVars.end = customoptions.end : ""; 450 if(customoptions.controls === "yes") { 451 finaloptions.playerVars.controls = 2; 452 if(thisContainer.querySelector(".mig-youtube-overlay") != null){ 453 thisContainer.querySelector(".mig-youtube-overlay").style.display = "none"; 454 } 455 456 if(thisContainer.querySelector(".mig-youtube-loader") != null){ 457 thisContainer.querySelector(".mig-youtube-loader").style.display = "none"; 458 } 459 460 } 461 462 463 //ASIGN AN ID INDEX DEPENDENT AND THEN INSERT IN THE MAIN OBJECT LO RESCUE LATER ON YOUTUBE FUNCTION 464 thisContainer.querySelector(".mig-youtube-wrapper").setAttribute("id", `mig-youtube-wrapper-${index}`); 465 466 467 finaloptions.selector = `mig-youtube-wrapper-${index}`; 468 migYoutubePlayers.push(finaloptions); 469 thisContainer.querySelector(".mig-youtube-wrapper-iframe").setAttribute("data-youtubebg", JSON.stringify(finaloptions)); 470 471 } 429 472 430 431 finaloptions.selector = `mig-youtube-wrapper-${index}`; 432 migYoutubePlayers.push(finaloptions); 433 thisContainer.querySelector(".mig-youtube-wrapper-iframe").setAttribute("data-youtubebg", JSON.stringify(finaloptions)); 434 435 436 437 }) 473 }) // end of foreach 438 474 439 475 … … 527 563 }; 528 564 migyoutubeplayer(); 565 -
dse-divi-section-enhancer/trunk/main.php
r2287097 r2334575 5 5 * Plugin URI: https://miguras.com/divi_section_enhancer 6 6 * Description: Improves DIVI Sections capabilities 7 * Version: 2. 6.77 * Version: 2.7 8 8 * Author: Miguras 9 9 * Author URI: http://miguras.com … … 123 123 $pass = new DSE_Main_Class( 'vHiZc', 'NsFvw' ); 124 124 $pass->init(); 125 $divi enhancerpro = $pass->updater();126 $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker( $divi enhancerpro, __FILE__, 'dse-divi-section-enhancer' );125 $divisectionenhancerpro = $pass->updater(); 126 $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker( $divisectionenhancerpro, __FILE__, 'dse-divi-section-enhancer-premium' ); 127 127 if ( !function_exists( 'dse_fs' ) ) { 128 128 function dse_fs() -
dse-divi-section-enhancer/trunk/readme.txt
r2322729 r2334575 1 1 === DIVI Section Enhancer === 2 Contributors: miguras 2 Contributors: miguras, freemius 3 3 Donate link: http://miguras.com/ 4 4 Tags: divi, divi theme, divi plugin, divi modules, divi builder 5 5 Requires at least: 5.0 6 6 Tested up to: 5.4 7 Stable tag: 2. 6.77 Stable tag: 2.7 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 99 99 100 100 == Changelog == 101 = 2.7 = 102 * Script Improvements. Now Divi Section Enhancer is faster than ever. 103 101 104 = 2.6 = 102 105 * Added Divi Vimeo Background for sections.
Note: See TracChangeset
for help on using the changeset viewer.