towfiqi

custom-javascript.php

Feb 21st, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.88 KB | None | 0 0
  1. <?php
  2. /**
  3. * The Custom Javascript for LayerFramework
  4. *
  5. * Loads the Custom Javascript of the template in the footer.
  6. *
  7. * @package LayerFramework
  8. *
  9. * @since LayerFramework 1.0
  10. */
  11. global $optimizer;?>
  12. <?php if(!empty( $optimizer['custom-js'])) { ?>
  13. <script type="text/javascript">
  14. <?php echo stripslashes(htmlspecialchars_decode($optimizer['custom-js'])); ?>
  15. </script>
  16. <?php } ?>
  17. <?php if($optimizer['slider_type_id'] == "nivo"){ ?>
  18. <script type="text/javascript">
  19. jQuery(window).bind('load', function(){
  20. jQuery('#zn_nivo').waitForImages(function() {
  21. // nivoslider init
  22. jQuery('#zn_nivo').nivoSlider({
  23. effect: 'fade',
  24. animSpeed:700,
  25. pauseTime:<?php echo $optimizer['n_slide_time_id']; ?>,
  26. startSlide:0,
  27. slices:10,
  28. directionNav:true,
  29. directionNavHide:true,
  30. controlNav:true,
  31. controlNavThumbs:false,
  32. keyboardNav:true,
  33. <?php if(is_home() || is_page_template('template_parts/page-frontpage_template.php')) {?>
  34. manualAdvance: false,
  35. <?php }else{ ?>
  36. manualAdvance: true,
  37. <?php } ?>
  38. pauseOnHover:true,
  39. captionOpacity:0.8,
  40. afterLoad: function(){
  41. jQuery("#zn_nivo .nivo-main-image").attr('src', jQuery('#zn_nivo img:eq(0)').attr('data-src'));
  42.  
  43. },
  44. beforeChange: function(){
  45.  
  46. },
  47. afterChange: function(){
  48.  
  49.  
  50. }
  51. });
  52. jQuery('#zn_nivo').css({"height":"auto"});
  53. });
  54. });
  55. </script>
  56. <?php } ?>
  57.  
  58.  
  59. <?php if($optimizer['slider_type_id'] == "accordion"){ ?>
  60. <script type="text/javascript">
  61. jQuery(window).bind('load', function(){
  62. //Accordion
  63. if (jQuery(window).width() > 500) {
  64. jQuery('.kwicks').kwicks({maxSize : '80%', behavior: 'menu', spacing: 0});
  65. } else {
  66. jQuery(".kwicks .dlthref").attr("href", "#");
  67. var index = jQuery('.kwicks').kwicks({maxSize : '80%', spacing: 0, behavior: 'slideshow'});
  68. jQuery('.kwicks').kwicks('select', <?php echo optimizer_accordion_mobile_default_slide();?>);
  69. }
  70. });
  71. </script>
  72. <?php } ?>
  73. <?php if($optimizer['slider_type_id'] == "static" && empty($optimizer['head_transparent'])){ ?>
  74. <script type="text/javascript">
  75. jQuery(window).load(function() {
  76. //STATIC SLIDER IMAGE FIXED
  77. var statimgheight = jQuery(".stat_has_img .stat_bg_img").height();
  78. var hheight = jQuery(".header").height() + jQuery('.admin-bar #wpadminbar').height() + jQuery('#customizer_topbar').height();
  79. jQuery('.stat_bg img').css({"top":hheight+"px"});
  80. jQuery('.not_trans_header .stat_bg, .not_trans_header .stat_bg_overlay').css({"top":hheight+"px"});
  81. });
  82. jQuery(window).on('scroll', function() {
  83. var scrollTop = jQuery(this).scrollTop();
  84.  
  85. var hheight = jQuery(".header").height() + jQuery('.admin-bar #wpadminbar').height() + jQuery('#customizer_topbar').height();
  86. if ( !scrollTop ) {
  87. jQuery('.stat_bg img').css({"top":hheight+"px"});
  88. jQuery('.stat_bg').css({"background-position-y":hheight+"px"});
  89. }else{
  90. jQuery('.stat_bg img').css({"top":"0px"});
  91. jQuery('.stat_bg').css({"background-position-y":"0px"});
  92. }
  93.  
  94. });
  95.  
  96. </script>
  97. <?php } ?>
  98.  
  99.  
  100. <?php
  101. if($optimizer['static_textbox_bottom'] == '0'){
  102. echo '<script>jQuery(".stat_content_inner").find("p:last").css({"marginBottom":"0"});</script>';
  103. }
  104. ?>
  105.  
  106.  
  107. <?php if(!empty($optimizer['head_sticky'])){ ?>
  108. <script type="text/javascript">
  109. jQuery(window).bind('load', function(){
  110. if (jQuery("body").hasClass('admin-bar')) {
  111. if (jQuery(window).width() > 601) {
  112. jQuery(".header").sticky({topSpacing:27});
  113. resizeStickyLogo()
  114. }else{
  115. jQuery(".header").sticky({topSpacing:0});
  116. resizeStickyLogo()
  117. }
  118. }else {
  119. jQuery(".header").sticky({topSpacing:0});
  120. resizeStickyLogo()
  121. }
  122. jQuery('body.site_boxed .header, body .header_wrap .sticky-wrapper .header').css({"width":jQuery('.header_wrap').width()});
  123. });
  124. jQuery(window).on('resize',optimizerStickyResize);
  125.  
  126. function optimizerStickyResize(){
  127. //Sticky Header width for Boxed Layout
  128. jQuery('body.site_boxed .header, body .header_wrap .sticky-wrapper .header').css({"width":jQuery('.header_wrap').width()});
  129. }
  130. function resizeStickyLogo(){
  131. <?php if(!empty($optimizer['logo_image_id']['url']) && !empty($optimizer['head_sticky'])){ ?>
  132. <?php $logoimgid = optimizer_attachment_id_by_url($optimizer['logo_image_id']['url']); $imgaltraw = wp_prepare_attachment_for_js($logoimgid); $logoheight = $imgaltraw['height']; ?>
  133. <?php if($logoheight > '60') { ?>
  134. jQuery('.header').on('sticky-start', function() { jQuery('.logo img').animate({"height": "60px"}, 300 ) });
  135. jQuery('.header').on('sticky-end', function() { jQuery('.logo img').animate({"height": "<?php echo $logoheight; ?>px"}, 300 ) });
  136. <?php } ?>
  137. <?php } ?>
  138. }
  139.  
  140. </script>
  141. <?php } ?>
  142.  
  143.  
  144. <?php /*?><!------------------------------------------------------------Other Javascripts--------------------------------------------------------><?php */?>
  145.  
  146. <script type="text/javascript">
  147.  
  148. //Hide Slider until its loaded
  149. jQuery('#zn_nivo, .nivo-controlNav').css({"display":"none"});
  150.  
  151. //Midrow Blocks Equal Width
  152. if(jQuery('.midrow_block').length == 4){ jQuery('.midrow_blocks').addClass('fourblocks'); }
  153. if(jQuery('.midrow_block').length == 3){ jQuery('.midrow_blocks').addClass('threeblocks'); }
  154. if(jQuery('.midrow_block').length == 2){ jQuery('.midrow_blocks').addClass('twoblocks'); }
  155. if(jQuery('.midrow_block').length == 1){ jQuery('.midrow_blocks').addClass('oneblock'); }
  156.  
  157.  
  158.  
  159. <?php if(is_page_template('template_parts/page-contact_template.php') ) { ?>
  160. jQuery(window).bind('load', function(){
  161. //FORM VALIDATION
  162. jQuery('#layer_contact_form').isHappy({
  163. fields: {
  164. '#layer_cntct_name': {required: true,message: '<?php _e('Name is Required!', 'optimizer'); ?>'},
  165. '#layer_cntct_email': {required: true,message: '<?php _e('Email is Required!', 'optimizer'); ?>',},
  166. '#layer_cntct_subject': {required: true,message: '<?php _e('Subject is Required!', 'optimizer'); ?>',},
  167. '#layer_cntct_msg': {required: true,message: '<?php _e('Your Message is Required!', 'optimizer'); ?>', },
  168. '#layer_cntct_math': {required: true,message: '<?php _e('Please solve the math!', 'optimizer'); ?>'}
  169. }
  170. });
  171. });
  172. <?php } ?>
  173.  
  174.  
  175. <?php if(($optimizer['cat_layout_id'] == "3")){ ?>
  176. <?php if(is_category() || (is_tag()) || (is_archive())) { ?>
  177. jQuery(window).bind('load', function(){
  178. //Layout3 Masonry
  179. var container = document.querySelector('.lay3_wrap');
  180. var msnry;
  181. if(container){
  182. imagesLoaded( container, function() {
  183. new Masonry( container, {
  184. // options
  185. itemSelector: '.hentry'
  186. });
  187. });
  188. }
  189. });
  190. <?php } ?>
  191. <?php } ?>
  192.  
  193. <?php if(($optimizer['blog_layout_id'] == "5")){ ?>
  194. <?php if( $optimizer['blog_layout_id'] == '5' && is_page_template('template_parts/page-blog_template.php') ) { ?>
  195. jQuery(window).bind('load', function(){
  196. //Layout3 Masonry
  197. var container = document.querySelector('.blog_layout5 .lay4_wrap');
  198. var msnry;
  199. if(container){
  200. imagesLoaded( container, function() {
  201. new Masonry( container, {
  202. // options
  203. itemSelector: '.hentry'
  204. });
  205. });
  206. }
  207. });
  208. <?php } ?>
  209. <?php } ?>
  210.  
  211. <?php if(empty($optimizer['static_video_id']['url']) && !empty($optimizer['slide_ytbid'])){ ?>
  212. // YOUTUBE VIDEO ON FRONTPAGE
  213. var tag = document.createElement('script');
  214.  
  215. tag.src = "https://www.youtube.com/iframe_api";
  216. var firstScriptTag = document.getElementsByTagName('script')[0];
  217. firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  218.  
  219. var player;
  220. function onYouTubeIframeAPIReady() {
  221. player = new YT.Player('ytplayer', {
  222. height: '',
  223. width: '',
  224. suggestedQuality: 'large',
  225. videoId: '<?php echo $optimizer['slide_ytbid']; ?>',
  226. playerVars :{'controls':0, 'showinfo': 0, 'autoplay': 1, <?php if( $optimizer['static_vid_loop'] == true){?>'loop':1, 'playlist':'<?php echo $optimizer['slide_ytbid']; ?>'<?php }else{ ?> 'loop':0<?php } ?>, 'rel':0},
  227.  
  228. events: {
  229. 'onReady': onPlayerReady,
  230. 'onStateChange': onPlayerStateChange
  231. }
  232.  
  233. });
  234. }
  235.  
  236. function onPlayerReady(event) {
  237. //event.target.setPlaybackQuality('hd720');
  238. <?php if( $optimizer['static_vid_mute'] == true){?>event.target.mute();<?php } ?>
  239. }
  240. function onPlayerStateChange(event) {
  241. event.target.setPlaybackQuality('large');
  242. var id = '<?php echo $optimizer['slide_ytbid']; ?>';
  243.  
  244. if(event.data === YT.PlayerState.ENDED){
  245. player.loadVideoById(id);
  246.  
  247. <?php if( !$optimizer['static_vid_loop'] == true){?>
  248. player.pauseVideo();
  249. <?php } ?>
  250. }
  251. }
  252. <?php } ?>
  253.  
  254. jQuery(window).bind('load', function(){
  255. jQuery('.stat_has_slideshow').css({"maxHeight":"none"});
  256. jQuery('.static_gallery').nivoSlider({effect: 'fade', directionNav: false, controlNav: false, pauseOnHover:false, slices:6, pauseTime:<?php echo optimizer_statslideshow_time(); ?>});
  257. });
  258.  
  259. jQuery(document).ready(function() {
  260. jQuery('.pd_flick_gallery li img').addClass('hasimg');
  261. });
  262.  
  263.  
  264. <?php if(is_page_template('template_parts/page-contact_template.php') ) { ?>
  265. <?php if(!empty($optimizer['contact_latlong_id'])){ ?>
  266. jQuery(document).ready(function() {
  267. //MAP SHORTCODE
  268. var text = '<?php echo str_replace(array("\r\n", "\n"),"",nl2br(do_shortcode(addslashes($optimizer['contact_location_id'])))); ?>';
  269. var mapid = 'asthemap';
  270.  
  271. function initialize() {
  272. var myLatlng = new google.maps.LatLng(<?php echo $optimizer['contact_latlong_id']; ?>);
  273. var mapOptions = {
  274. zoom: 16,
  275. scrollwheel: false,
  276. center: myLatlng,
  277. }
  278. var map = new google.maps.Map(document.getElementById(mapid), mapOptions);
  279.  
  280. var marker = new google.maps.Marker({
  281. position: myLatlng,
  282. map: map,
  283. });
  284. var infowindow = new google.maps.InfoWindow();
  285. google.maps.event.addListener(marker, 'click', (function (marker, i) {
  286. return function () {
  287. infowindow.setContent(text);
  288. infowindow.open(map, marker);
  289. }
  290. })(marker));
  291. }
  292.  
  293. google.maps.event.addDomListener(window, 'load', initialize);
  294.  
  295. });
  296. <?php } ?>
  297. <?php } ?>
  298.  
  299. <?php if ( class_exists( 'WooCommerce' ) && ($optimizer['woo_archive_layout'] == 'layout5' )){ ?>
  300. jQuery('.archive.woocommerce-page.woo_archive_layout5 ul.products li.product').each(function(index, element) {
  301. // jQuery(this).find('h3').prependTo(jQuery(this).find('.post_content'));
  302. });
  303. <?php } ?>
  304. jQuery(window).bind('load', function(){
  305. jQuery('.single-product .single_post .thumbnails').looper({interval: false});
  306. jQuery('.archive.woocommerce-page.woo_archive_layout4 ul.products li.product').matchHeight({ property: 'min-height', byRow: 'height'});
  307. jQuery('.woocommerce.single.woo_single_layout1 .yith-wcwl-add-to-wishlist').insertBefore('div[itemprop="offers"]');
  308. jQuery('.woocommerce.single.woo_single_layout4 #content .onsale').prependTo('.woocommerce.single.woo_single_layout4 #content .product .images');
  309. });
  310. </script>
Add Comment
Please, Sign In to add comment