Advertisement
towfiqi

core.js

Aug 31st, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.94 KB | None | 0 0
  1. jQuery(window).ready(function() {
  2.  
  3. /*CAROUSEL SHORTCODE*/
  4. jQuery(".looper-inner p, .looper-inner .item, .lts_pricing p, .lts_blocks p, .lts_blocks br, .lts_tab br, .lts_tabtitle").each(function(){
  5. if (!jQuery(this).text().trim().length) {
  6. jQuery(this).addClass("emptyp_clear");
  7. }
  8. });
  9.  
  10. jQuery('.looper-inner .item, .lts_pricing .pricebox, .lts_block, .lts_tab_child').siblings('.emptyp_clear').remove();
  11. jQuery('.price_body .emptyp_clear').remove();
  12.  
  13.  
  14. /*Responsive Video Shortcode*/
  15. jQuery('.thn_post_wrap .ast_vid, .frontpage_sidebar .widget .ast_vid').each( function(){
  16. var vidwidth = jQuery(this).data('width'); var vidheight = jQuery(this).data('width');
  17. jQuery(this).find('iframe').width(vidwidth).height(vidheight);
  18. });
  19.  
  20. jQuery('.thn_post_wrap .ast_vid iframe, .frontpage_sidebar .widget .ast_vid iframe').each(function () {
  21. var vidheights = jQuery(this).height();
  22. jQuery(this).closest('.ast_vid').css({ 'height':vidheights });
  23.  
  24. if(jQuery(this).closest('.widget_wrap').find('.video_on_video').length){
  25. jQuery(this).closest('.ast_vid').css({ 'height':vidheights -240 });
  26. }
  27. });
  28.  
  29.  
  30.  
  31.  
  32. /*Social Icons Widget Custom Color*/
  33. jQuery('.ast_scoial').each( function(){
  34. var iconscolor = jQuery(this).attr('data-icon-color');
  35. if(iconscolor == '#FFFFFF') {var iconscolor ='';}
  36. jQuery(this).find('a').css("background-color",iconscolor);
  37. });
  38. jQuery('.ast_scoial.social_style_round_text').each( function(){
  39. var iconscolor = jQuery(this).attr('data-icon-color');
  40. if(iconscolor == '#FFFFFF') {var iconscolor ='';}
  41. jQuery(this).find('i').css("background-color",iconscolor); jQuery(this).find('span').css("color",iconscolor);
  42. });
  43.  
  44. //ADD ID to Carousel and MAP
  45. for (var i=0; i<20; i++){
  46. jQuery('.lts_looper:eq('+i+')').attr('id', 'lts_looper'+i+'');
  47. jQuery('.lts_list:eq('+i+')').attr('id', 'lts_list'+i+'');
  48. jQuery('.lts_map_wrap:eq('+i+')').attr('id', 'map_'+i+'');
  49. }
  50.  
  51. jQuery('.lts_looper.lts_default, .lts_looper.lts_simple').each( function(){
  52. jQuery(this).find('br').remove();
  53. var button_color = jQuery(this).attr('data-buttoncolor');
  54. jQuery(this).find('nav').prepend('<a style="background:'+button_color+';" class="looper-control" data-looper="prev" href="#'+jQuery(this).attr('id')+'"><i class="fa fa-chevron-left"></i></a><a style="background:'+button_color+';" class="looper-control right" data-looper="next" href="#'+jQuery(this).attr('id')+'"><i class="fa fa-chevron-right"></i></a>');
  55. });
  56. jQuery('.lts_looper.lts_thick_border').each( function(){
  57. jQuery(this).find('br').remove();
  58. var button_color = jQuery(this).attr('data-buttoncolor');
  59. jQuery(this).find('nav').prepend('<a style="background:'+jQuery('body').css("background-color")+';" class="looper-control" data-looper="prev" href="#'+jQuery(this).attr('id')+'"><i style="color:'+button_color+'!important;" class="fa fa-chevron-left"></i></a><a style="background:'+jQuery('body').css("background-color")+';" class="looper-control right" data-looper="next" href="#'+jQuery(this).attr('id')+'"><i style="color:'+button_color+'!important;" class="fa fa-chevron-right"></i></a>');
  60. });
  61.  
  62.  
  63.  
  64. /*PRICING SHORTCODE*/
  65. jQuery('.pricebox').has('.pricebox_featured').addClass('feat_price');
  66.  
  67. jQuery(".lts_pricing").each(function(){
  68. var button_bg = jQuery(this).attr('data-button-bg');
  69. var button_color = jQuery(this).attr('data-button-txt');
  70. var pricebox_bg = jQuery(this).attr('data-price-bg');
  71. var pricebox_txt = jQuery(this).attr('data-price-txt');
  72. //Convert Background Color to RGBA
  73. var rgbaCol = 'rgba(' + parseInt(button_bg.slice(-6,-4),16)
  74. + ',' + parseInt(button_bg.slice(-4,-2),16)
  75. + ',' + parseInt(button_bg.slice(-2),16)
  76. +',0.3)';
  77.  
  78. jQuery(this).find('.price_button, .pricebox_featured').attr('style', 'color:'+button_color+'!important;background:'+button_bg+';');
  79. jQuery(this).find('.price_button').css({"borderColor":button_bg});
  80. jQuery(this).find('.pricebox').css({"background":pricebox_bg});
  81.  
  82. jQuery('.pricing_style1 .pricebox_inner').hover(function(){
  83. jQuery(this).css({"borderColor": rgbaCol});
  84. jQuery(this).find('.price_head h3').css({"backgroundColor": rgbaCol, "color":button_color});
  85. }, function(){
  86. jQuery(this).css({"borderColor": "rgba(0, 0, 0, 0.04)"});
  87. jQuery(this).find('.price_head h3').css({"backgroundColor": 'rgba(0, 0, 0, 0.02)', "color":pricebox_txt});
  88. });
  89. });
  90.  
  91. jQuery(".lts_pricing.pricing_style2, .lts_pricing.pricing_style3").each(function(){
  92. var button_bg = jQuery(this).attr('data-button-bg');
  93. jQuery(this).find('.price_head h3').css({"color":button_bg});
  94. jQuery(this).find('.pricebox_inner').hover(function(){
  95. jQuery(this).css({"borderColor": button_bg});
  96. }, function(){
  97. jQuery(this).css({"borderColor": "transparent"});
  98. });
  99. });
  100. jQuery(".lts_pricing.pricing_style5").each(function(){
  101. var button_bg = jQuery(this).attr('data-button-bg');
  102. var button_color = jQuery(this).attr('data-button-txt');
  103. var rgbaCol = 'rgba(' + parseInt(button_bg.slice(-6,-4),16)
  104. + ',' + parseInt(button_bg.slice(-4,-2),16)
  105. + ',' + parseInt(button_bg.slice(-2),16)
  106. +',0.5)';
  107. jQuery(this).find('.price_head h3').css({"backgroundColor":rgbaCol});
  108. jQuery(this).find('.pricebox').each(function(){
  109. jQuery(this).find('.price_ammount, .price_label').insertAfter(jQuery(this).find('.price_body'));
  110. });
  111. });
  112.  
  113.  
  114. jQuery(".lts_pricing").each(function(){
  115.  
  116. if(jQuery(this).find('.pricebox').length == 5){ jQuery(this).addClass('lts_pricebox5'); }
  117. if(jQuery(this).find('.pricebox').length == 4){ jQuery(this).addClass('lts_pricebox4'); }
  118. if(jQuery(this).find('.pricebox').length == 3){ jQuery(this).addClass('lts_pricebox3'); }
  119. if(jQuery(this).find('.pricebox').length == 2){ jQuery(this).addClass('lts_pricebox2'); }
  120. if(jQuery(this).find('.pricebox').length == 1){ jQuery(this).addClass('lts_pricebox1'); }
  121. //Equal Description Height
  122. var descheight = Math.max.apply(Math, jQuery(".price_desc").map(function () {return jQuery(this).outerHeight(); }));
  123. jQuery(this).find('.price_desc').outerHeight(descheight);
  124. //Equal Feature list box Height
  125. var featheight = Math.max.apply(Math, jQuery(".price_body ul").map(function () {return jQuery(this).outerHeight(); }));
  126. jQuery(this).find('.price_body ul').outerHeight(featheight);
  127. });
  128.  
  129.  
  130. /*Column Shortcode*/
  131. jQuery(".text_block_content, .thn_post_wrap, #slidera, .about_inner, .block_content").each(function(){
  132. jQuery(this).find('.col2:eq(1), .col2:eq(3), .col2:eq(5), .col2:eq(7), .col2:eq(9), .col2:eq(11), .col2:eq(13), .col2:eq(15), .col2:eq(17), .col2:eq(19)').after('<div class="colclear" style="clear:both" />');
  133. });
  134. jQuery(".text_block_content, .thn_post_wrap, #slidera, .about_inner, .block_content").each(function(){
  135. jQuery(this).find('.col3:eq(2), .col3:eq(5), .col3:eq(8), .col3:eq(11), .col3:eq(14), .col3:eq(17), .col3:eq(20), .col3:eq(23), .col3:eq(26), .col3:eq(29)').after('<div class="colclear" style="clear:both" />');
  136. });
  137. jQuery(".text_block_content, .thn_post_wrap, #slidera, .about_inner, .block_content").each(function(){
  138. jQuery(this).find('.col4:eq(3), .col4:eq(7), .col4:eq(11), .col4:eq(15), .col4:eq(19), .col4:eq(23), .col4:eq(27), .col4:eq(31), .col4:eq(35), .col4:eq(29)').after('<div class="colclear" style="clear:both" />');
  139. });
  140.  
  141. if (jQuery(window).width() >= 480) {
  142. jQuery(".text_block_content, .thn_post_wrap, #slidera, .about_inner, .block_content").each(function(){jQuery(this).find('.col2, .col3, .col4').matchHeight({ byRow: true, property: 'min-height'});});
  143. jQuery(window).on('load',function() {
  144. jQuery(".optimizer_front_carousel .looper .looper-inner li").matchHeight({ byRow: false, property: 'min-height'});
  145. });
  146. }
  147.  
  148.  
  149. //BLOCKS SHORTCODE
  150. jQuery('.lts_blocks .lts_block:empty').remove();
  151. jQuery(".lts_blocks").each(function(){
  152. jQuery(this).waitForImages(function() {
  153. jQuery(this).find('.lts_block').not('.block_full').matchHeight();
  154. });
  155.  
  156. if(jQuery(this).find('.lts_block').length == 4){ jQuery(this).addClass('lts_fourblocks'); }
  157. if(jQuery(this).find('.lts_block').length == 3){ jQuery(this).addClass('lts_threeblocks'); }
  158. if(jQuery(this).find('.lts_block').length == 2){ jQuery(this).addClass('lts_twoblocks'); }
  159. if(jQuery(this).find('.lts_block').length == 1){ jQuery(this).addClass('lts_oneblock'); }
  160. });
  161.  
  162.  
  163. //LIST Shortcode COLOR
  164. jQuery(".lts_list").each(function(){
  165. var bulletcolor = jQuery(this).attr('data-list-color');
  166. var listid = jQuery(this).attr('id');
  167. jQuery('<style>#'+listid+' li:before{color:'+bulletcolor+'}</style>').appendTo('head');
  168. });
  169.  
  170.  
  171.  
  172. //Shortcode JS
  173. //Tabs Javascript
  174. jQuery(".lts_tab p:empty").remove();
  175. jQuery(".lts_tabs .lts_tabtitle.emptyp_clear").remove();
  176. var i = 1;
  177. jQuery(".tabs-container").each(function (){ jQuery(this).find('a.tabtrigger').each(function (){
  178. jQuery(this).attr('href', '#tab-'+i+''); i++;
  179. });
  180. });
  181.  
  182. var i = 1;
  183. jQuery(".tabs-container").each(function (){
  184. jQuery(this).find(".lts_tab_child").not(':empty').each(function (){
  185. jQuery(this).attr('id', 'tab-'+i+''); i++;
  186. });
  187. });
  188.  
  189. var i = 1;
  190. jQuery(".tabs-container").each(function (){jQuery(this).attr('id', 'tabs-container_'+i+''); i++;});
  191.  
  192. jQuery(".tabs-container.tabs_default").each(function (){ var tabid = jQuery(this).attr('id'); var active_color = jQuery(this).data('active-color');
  193. jQuery('<style>body #'+tabid+' ul.tabs li.active a{color:'+active_color+'!important;border-color:'+active_color+'}</style>').appendTo('head');
  194. });
  195. jQuery(".tabs-container.tabs_circular").each(function (){ var tabid = jQuery(this).attr('id'); var active_color = jQuery(this).data('active-color');
  196. jQuery('<style>body #'+tabid+' ul.tabs li.active a{color:'+jQuery('body').css('background-color')+'!important;background:'+active_color+'}</style>').appendTo('head');
  197. });
  198. jQuery(".tabs-container.tabs_minimal").each(function (){ var tabid = jQuery(this).attr('id'); var active_color = jQuery(this).data('active-color');
  199. jQuery('<style>body #'+tabid+' ul.tabs li.active a{color:'+active_color+'!important;border-color:'+active_color+'}</style>').appendTo('head');
  200. });
  201. jQuery(".tabs-container.tabs_capsule").each(function (){ var tabid = jQuery(this).attr('id'); var active_color = jQuery(this).data('active-color');
  202. jQuery('<style>body #'+tabid+' ul.tabs li.active a{color:'+jQuery('body').css('background-color')+'!important;background:'+active_color+';border-color:'+active_color+'}</style>').appendTo('head');
  203. });
  204.  
  205. jQuery('.tabs-container').easytabs({updateHash: false});
  206.  
  207. //Toggle Shortcode
  208. jQuery('.lts_toggle_content').hide(); // Hide even though it's already hidden
  209. jQuery('.lts_toggle .trigger').click(function() {
  210. jQuery(this).closest('.lts_toggle').find('.lts_toggle_content').slideToggle("fast"); // First click should toggle to 'show'
  211. return false;
  212. });
  213. jQuery('.lts_toggle a.trigger').toggle(function(){
  214. jQuery(this).find('i').animateRotate(135);
  215. jQuery(this).addClass('down');
  216. }, function(){
  217. jQuery(this).find('i').animateRotate(-90);
  218. jQuery(this).removeClass('down');
  219. });
  220.  
  221. jQuery(".lts_toggle").each(function (){ if(jQuery(this).next('br')){ jQuery(this).next('br').addClass('tabsbr'); } });
  222.  
  223. //Widget image opacity animation
  224. jQuery('.widget_wrap a img').hover(function(){
  225. jQuery(this).stop().animate({ "opacity":"0.7" }, 300);
  226. }, function(){
  227. jQuery(this).stop().animate({ "opacity":"1" }, 300);
  228. });
  229.  
  230.  
  231. //add CLASS for Slider Widget
  232. for (var i=0; i<10; i++){
  233. jQuery('.ast_slider_widget .slide_wdgt:eq('+i+')').attr('id', 'lts_wdgt_nivo'+i+'');
  234. jQuery('.ast_slider_widget #lts_wdgt_nivo'+i+'').nivoSlider({effect: 'fade', directionNav: true, prevText: '<i class="fa fa-chevron-left"></i>', nextText: '<i class="fa fa-chevron-right"></i>', controlNav: false});
  235. }
  236. //Call to action shortcode animation
  237. jQuery('.act_right a').hover(function(){
  238. jQuery(this).addClass('animated pulse');
  239. }, function(){
  240. jQuery(this).removeClass('animated pulse');
  241. });
  242.  
  243.  
  244.  
  245. /*CHECK IF TOUCH ENABLED DEVICE*/
  246. function is_touch_device() {
  247. return (('ontouchstart' in window)
  248. || (navigator.MaxTouchPoints > 0)
  249. || (navigator.msMaxTouchPoints > 0));
  250. }
  251. if (is_touch_device()) { jQuery('body').addClass('touchon'); }else{ jQuery('body').addClass('notouchdevice'); }
  252.  
  253. /*BUG FIX: In iOS landscape, menu and posts widgets links has to be clicked twice.*/
  254. if (is_touch_device()) {
  255. if (jQuery(window).width() > 480) {
  256. jQuery('#topmenu ul li a').on('click touchend', function(e) {
  257. if((typeof jQuery(this).attr('href')) !== 'undefined') {
  258. var el = jQuery(this);
  259. var link = el.attr('href');
  260. window.location = link;
  261. }
  262. });
  263. }
  264. }
  265.  
  266. //CountDown Widget
  267. jQuery('.optim_countdown_widget').each(function(index, element) {
  268. jQuery(this).find(".ast_countdown ul").countdown(jQuery(this).find(".ast_countdown ul").attr('data-countdown')).on('update.countdown', function(event) {
  269. jQuery(this).html(event.strftime(''
  270. + '<li><span class="days">%D</span><p class="timeRefDays">'+optim.day+'</p></li>'
  271. + '<li><span class="hours">%H</span><p class="timeRefHours">'+optim.hour+'</p></li>'
  272. + '<li><span class="minutes">%M</span><p class="timeRefMinutes">'+optim.mins+'</p></li>'
  273. + '<li><span class="seconds">%S</span><p class="timeRefSeconds">'+optim.sec+'</p></li>'));
  274. });
  275. });
  276.  
  277. jQuery('.ast_scoial_widget .widget_wrap').has('.social_style_full, .social_style_full_text').addClass('has_full_social_icons');
  278.  
  279. //Radial Progress bar Shortcode
  280. jQuery('.circle_progress').each(function(index, element) {
  281. jQuery(this).circleProgress({ value: jQuery(this).data('progress'), size: 160, fill: { color: jQuery(this).data('background') } });
  282. });
  283. jQuery('.progress_circular').each(function(index, element) {
  284. if(jQuery(this).next().is('.progress_circular')){jQuery(this).addClass('float_progress');}else{jQuery(this).addClass('last_progress').after('<div style="clear:both" />');}
  285. });
  286.  
  287. //ToolTip Shortcode
  288. jQuery('.tooltip').miniTip({ fadeIn: 100 });
  289.  
  290. //post shortcode layout1 thumbnal resize
  291. var laywidth = jQuery('.lts_layout1 .listing-item').width();
  292. jQuery('.lts_layout1 .listing-item').height( (laywidth * 66)/100);
  293. jQuery(window).resize(function() {
  294. var laywidth = jQuery('.lts_layout1 .listing-item').width();
  295. jQuery('.lts_layout1 .listing-item').height( (laywidth * 66)/100);
  296. });
  297.  
  298. var flaywidth = jQuery('.lay1 .hentry').width();
  299. jQuery('.lay1 .ast_row').height( (flaywidth * 66)/100);
  300. jQuery(window).resize(function() {
  301. var flaywidth = jQuery('.lay1 .hentry').width();
  302. jQuery('.lay1 .ast_row').height( (flaywidth * 66)/100);
  303. });
  304.  
  305. jQuery(window).ready(function() {
  306.  
  307. if(jQuery('body .lts_layout3').length){
  308. jQuery('.lts_layout3 .listing-item').wrapAll('<div class="lts3_inner" />');
  309. //Layout3 Shortcode Masonry
  310. var container = document.querySelector('.lts3_inner');
  311. var msnry;
  312. imagesLoaded( container, function() {
  313. new Masonry( container, {
  314. // options
  315. itemSelector: '.listing-item'
  316. });
  317. });
  318. }
  319.  
  320. //Slider Widget
  321. jQuery('.slider_widget_nivo .the_slider_widget').each(function(index, element) {
  322.  
  323. var nivoautoplay = jQuery(this).attr('data-pausetime');
  324. if(nivoautoplay){ nautoplay = false; }else{ nautoplay = true;}
  325.  
  326. jQuery(this).nivoSlider({
  327. effect: 'fade',
  328. directionNav: true,
  329. controlNav: true,
  330. pauseOnHover:false,
  331. slices:1,
  332. pauseTime:jQuery(this).attr('data-pausetime'),
  333. manualAdvance: nautoplay ,
  334. afterChange: function(){
  335. if(jQuery(this).height() < jQuery(this).parent().find('.widget_slider_content').height()){
  336. jQuery(this).height( jQuery(this).parent().find('.widget_slider_content').height() + 30);
  337. jQuery(this).find('nivo-slice').height( jQuery(this).parent().find('.widget_slider_content').height() + 30);
  338. }
  339. }
  340.  
  341. });
  342. //Set Slider Height to the Content of the slider so the content is not cut off
  343. jQuery(this).waitForImages(function() {
  344. if(jQuery(this).height() < jQuery(this).parent().find('.widget_slider_content').height()){
  345. jQuery(this).addClass('expand_slider_height')
  346. jQuery(this).height(jQuery(this).parent().find('.widget_slider_content').height() + 30);
  347. jQuery(this).find('nivo-slice').height(jQuery(this).parent().find('.widget_slider_content').height() + 30);
  348. }
  349. });
  350.  
  351. });
  352.  
  353. //Slider Widget
  354. jQuery('.slider_widget_gallery .the_slider_widget').each(function(index, element) {
  355. jQuery(this).nivoSlider({
  356. effect: 'fade',
  357. directionNav: true,
  358. controlNav: true,
  359. controlNavThumbs: true,
  360. pauseOnHover:true,
  361. slices:1,
  362. pauseTime:jQuery(this).attr('data-pausetime'),
  363. });
  364. });
  365.  
  366. //Clients Logo widget - Pagination
  367. jQuery(window).bind('load', function(){
  368. jQuery('.clients_nav_on').waitForImages(function() {
  369. jQuery('.clients_nav_on').tinycarousel({"infinite ":false, "animationTime": 400});
  370. });
  371. });
  372.  
  373.  
  374. });
  375.  
  376. //MAP WIDGET SUBTITLE SWAP
  377. jQuery('.ast_map.no_map').each(function(index, element) {
  378. jQuery(this).find('.home_subtitle').insertAfter(jQuery(this).find('.optimizer_divider'));
  379. });
  380.  
  381.  
  382.  
  383. //Equal height - Gallery (Square)
  384. jQuery('div[data-gallery-style="1"], div[data-gallery-style="2"]').each(function(index, element) {
  385. jQuery(this).waitForImages(function() {
  386. jQuery(this).find('.gallery-item, .gallery-item img').matchHeight({ byRow: true, property: 'min-height'});
  387. });
  388. });
  389. jQuery('div[data-gallery-style="3"], div[data-gallery-style="4"]').each(function(index, element) {
  390. jQuery(this).waitForImages(function() {
  391. minigrid('div[data-gallery-style="3"]', '.gallery-item', 0);
  392. minigrid('div[data-gallery-style="4"]', '.gallery-item', 0);
  393. window.addEventListener('resize', function(){
  394. minigrid('div[data-gallery-style="3"]', '.gallery-item', 0);
  395. minigrid('div[data-gallery-style="4"]', '.gallery-item', 0);
  396. });
  397. });
  398. });
  399.  
  400.  
  401. jQuery('div[data-gallery-style="5"]').each(function (){
  402. jQuery(this).find('.gallery-item').css({"display":"none"});
  403. jQuery(this).append('<div class="slideshow_gallery" />')
  404. var tn_array = jQuery(this).find(".gallery-item a").map(function() {
  405. return jQuery(this).attr("href");
  406. });
  407. var tn_array_src = jQuery(this).find(".gallery-item img").map(function() {
  408. return jQuery(this).attr("src");
  409. });
  410. var pageLimit= jQuery(this).find(".gallery-item img").size() - 1;
  411. for (var i = 0; i <= pageLimit; i++) {
  412. var article = jQuery(this).find(".gallery-item a");
  413. jQuery(article[i]).addClass("" + i + "");
  414. jQuery(article[i]).attr('id' , "vis" + i + "");
  415. jQuery(this).find('.slideshow_gallery').append("<img id='mainImage" + i + "' src='"+tn_array[i]+"'/>");
  416.  
  417. }
  418.  
  419. jQuery(this).find('.slideshow_gallery').nivoSlider({effect: 'fade', directionNav: true, prevText: '<i class="fa fa-chevron-left"></i>', nextText: '<i class="fa fa-chevron-right"></i>', controlNav: false, });
  420.  
  421. });
  422.  
  423. });
  424.  
  425.  
  426. jQuery(window).on('load',function() {
  427. /*2columns Widget EQUAL HEIGHT*/
  428. jQuery('.frontpage_sidebar, #pagesidebar').each(function (){
  429. jQuery(this).waitForImages(function() {
  430. jQuery(this).find('.widget_col_2, .widget_col_2 .home_action').matchHeight({ property: 'min-height'});
  431. });
  432. });
  433. /*3columns Widget EQUAL HEIGHT*/
  434. jQuery('.frontpage_sidebar, #pagesidebar').each(function (){
  435. jQuery(this).waitForImages(function() {
  436. jQuery(this).find('.widget_col_3, .widget_col_3 .home_action').matchHeight({ property: 'min-height'});
  437. });
  438. });
  439. /*2 quarter Widget EQUAL HEIGHT*/
  440. jQuery('.frontpage_sidebar, #pagesidebar').each(function (){
  441. jQuery(this).waitForImages(function() {
  442. jQuery(this).find('.widget_col_4, .widget_col_3').matchHeight({ property: 'min-height'});
  443.  
  444. });
  445. });
  446. /*1 quarter Widget EQUAL HEIGHT*/
  447. jQuery('.frontpage_sidebar, #pagesidebar').each(function (){
  448. jQuery(this).waitForImages(function() {
  449. jQuery(this).find('.widget_col_2, .widget_col_5').matchHeight({ property: 'min-height'});
  450.  
  451. });
  452. });
  453. /*3 quarter Widget EQUAL HEIGHT*/
  454. jQuery('.frontpage_sidebar, #pagesidebar').each(function (){
  455. jQuery(this).waitForImages(function() {
  456. jQuery(this).find('.widget_col_6, .widget_col_2').matchHeight({ property: 'min-height'});
  457.  
  458. });
  459. });
  460. /*3 quarter Widget EQUAL HEIGHT*/
  461. jQuery('.frontpage_sidebar, #pagesidebar').each(function (){
  462. jQuery(this).waitForImages(function() {
  463. jQuery(this).find('.widget_col_5, .widget_col_5 .home_action, .widget_col_6, .widget_col_6 .home_action').matchHeight({ property: 'min-height'});
  464.  
  465. });
  466. });
  467.  
  468. });
  469.  
  470.  
  471. //CONTACT FORM FOR WIDGETS/
  472. function optimizerContact_validate(element) {
  473. console.log(element);
  474. jQuery('html, body').animate({scrollTop: jQuery(element).offset().top-100}, 150);
  475. jQuery(element).parent().addClass('contact_error');
  476. }
  477. function optimizerValidateEmail(val)
  478. {
  479.  
  480. if(val === ''){ //Check to see if value is empty
  481. return false;
  482. }
  483. if(!val.match(/\S+@\S+\.\S+/)){ //Check to see if has @
  484. return false;
  485. }
  486. if( val.indexOf(' ')!=-1 || val.indexOf('..')!=-1){
  487. return false;
  488. }
  489. }
  490.  
  491. function optimizerContact(buttonid) {
  492.  
  493. var formid = jQuery('#'+buttonid).parent().parent().attr('id');
  494.  
  495. var cname = jQuery('#'+formid).find('.contact_name');
  496. var cemail = jQuery('#'+formid).find('.contact_email');
  497. var csubject = jQuery('#'+formid).find('.contact_subject');
  498. var cextrafld = jQuery('#'+formid).find('.contact_extra');
  499. var cmessage = jQuery('#'+formid).find('.contact_message');
  500. var cgdpr = jQuery('#'+formid).find('.contact_cgdpr');
  501.  
  502. cname.parent().removeClass('contact_error'); cemail.parent().removeClass('contact_error'); csubject.parent().removeClass('contact_error'); cmessage.parent().removeClass('contact_error');
  503. cgdpr.parent().removeClass('contact_error');
  504.  
  505. if(cname.val() === '') {
  506. optimizerContact_validate(cname);
  507.  
  508. } else if(optimizerValidateEmail(cemail.val()) === false) {
  509. optimizerContact_validate(cemail);
  510.  
  511. } else if(csubject.val() === '') {
  512. optimizerContact_validate(csubject);
  513.  
  514. } else if(cmessage.val() === '') {
  515. optimizerContact_validate(cmessage);
  516.  
  517. } else if(cgdpr.is(":checked") === false) {
  518. optimizerContact_validate(cgdpr);
  519.  
  520. } else {
  521. jQuery('#'+buttonid).parent().append('<i class="fa fa-circle-o-notch fa-spin contact_buttn_spinner"></i>');
  522. var data = {
  523. 'action': 'optimizer_send_message',
  524. 'contact_name': cname.val(),
  525. 'contact_email': cemail.val(),
  526. 'contact_subject': csubject.val(),
  527. 'contact_extra': cextrafld.val(),
  528. 'contact_message': cmessage.val()
  529. };
  530.  
  531. var ajaxurl = optim.ajaxurl;
  532. jQuery.ajax({
  533. type: "POST",
  534. url: ajaxurl,
  535. data : {
  536. 'contact_name': cname.val(),
  537. 'contact_email': cemail.val(),
  538. 'contact_subject': csubject.val(),
  539. 'contact_message': cmessage.val() ,
  540. 'contact_extra': cextrafld.val(),
  541. 'action' : 'optimizer_send_message',
  542. }
  543. })
  544. .done(function(response,status,jqXHR) {
  545. console.log(response);
  546. jQuery('.contact_form_wrap .fa-circle-o-notch').remove();
  547. if(response === 'success'){
  548. alert(optim.sent);
  549. //console.log(response);
  550. cname.val(''); cemail.val(''); csubject.val(''); cmessage.val('');
  551. if(optim.redirect){
  552. location.href = optim.redirect;
  553. }
  554. }
  555. });
  556.  
  557. }
  558. }
  559.  
  560. /*VIDEO Widgets (Youtube)*/
  561. jQuery(window).bind('load', function(){
  562. setTimeout(function () {
  563. if ( jQuery( ".optimizer_front_video, .vid_iframe" ).length ) {
  564. var tag = document.createElement("script");
  565. tag.src = "https://www.youtube.com/player_api";
  566. var firstScriptTag = document.getElementsByTagName("script")[0];
  567. firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  568. }
  569. }, 1000);
  570. });
  571.  
  572. var players = {};
  573. function onYouTubePlayerAPIReady() {
  574.  
  575. jQuery(document).ready(function() {
  576. jQuery('.ytb_widget_iframe').each(function(event) {
  577.  
  578. var iframeID = jQuery(this).attr('id');
  579. var autoplay = jQuery(this).attr('data-autoplay');
  580. var position = jQuery(this).attr('data-position');
  581. if(autoplay == 1){var auto = 1;}else{var auto = 0;}
  582.  
  583. if(autoplay == 1 && position == 'on_video'){
  584.  
  585. players[iframeID] = new YT.Player(iframeID, {
  586. suggestedQuality: "large", videoId: jQuery(this).attr('data-video-id'), playerVars :{'autoplay': auto, 'loop':1, 'rel':0, 'playlist': jQuery(this).attr('data-video-id')}, events: {'onReady': muteVideo}
  587. });
  588.  
  589. }else{
  590. players[iframeID] = new YT.Player(iframeID, {
  591. suggestedQuality: "large", videoId: jQuery(this).attr('data-video-id'), playerVars :{'autoplay': auto, 'rel':0}
  592. });
  593. }
  594.  
  595. }); //END .ytb_widget_iframe each
  596. }); //End document.ready
  597.  
  598. }
  599.  
  600. function muteVideo(event) {
  601. event.target.mute();
  602. }
  603. function playYouTubeVideo(iframeID) {
  604. players[iframeID].playVideo();
  605. }
  606.  
  607. jQuery(document).ready(function() {
  608. jQuery('.astytb i.fa.fa-play').on('click', function() {
  609. var iframeID = jQuery(this).closest('.optimizer_video_wrap').find('iframe').attr('id');
  610. playYouTubeVideo(iframeID);
  611. jQuery(this).hide();
  612. jQuery(this).parent().parent('.video_on_video').find('.widget_video_content').hide();
  613. jQuery(this).next('.ytb_thumb').hide();
  614. });
  615. });
  616.  
  617.  
  618. /*VIDEO Widgets (Vimeo)*/
  619. jQuery(window).on('load',function() {
  620.  
  621. jQuery('.astvimeo').each(function(index, element) {
  622. var iframeid = jQuery(this).find('iframe').attr('id');
  623. var buttonid = jQuery(this).find('i.fa.fa-play').attr('id');
  624.  
  625. var iframe = document.getElementById(iframeid);
  626. var player = $f(iframe);
  627.  
  628. jQuery('#'+buttonid).on('click', function(){
  629. jQuery(this).parent().parent('.video_on_video').find('.widget_video_content').hide();
  630. jQuery(this).hide();
  631. jQuery(this).parent().removeClass('hidecontrols');
  632. jQuery(this).next('.vim_thumb').hide();
  633. });
  634.  
  635. var playButton = document.getElementById(buttonid);
  636. playButton.addEventListener("click", function() {
  637. player.api("play");
  638. });
  639.  
  640. if(jQuery(this).has('.autoPlay_vim')){
  641. player.api("play");
  642. }
  643. });
  644.  
  645. //Custom Video
  646. jQuery('.video_on_video .custom_vdo_wrap').each(function(index, element) {
  647. jQuery(this).find('.mejs-overlay-button').click(function() {
  648. jQuery(this).closest('.video_on_video').find('.widget_video_content').hide();
  649. jQuery(this).next('.customvdo_thumb').hide();
  650. });
  651. });
  652.  
  653. });
  654.  
  655.  
  656. //MAP SHORTCODE
  657. jQuery(document).ready(function() {
  658. //MAP SHORTCODE
  659. jQuery(".lts_map_wrap").each(function(){
  660. var lat = jQuery(this).find('.lts_map').attr('data-map-lat');
  661. var long = jQuery(this).find('.lts_map').attr('data-map-long');
  662. var text = jQuery(this).find('.lts_map').attr('data-map-text');
  663. var mapid = jQuery(this).attr('id');
  664.  
  665. function initialize() {
  666. var myLatlng = new google.maps.LatLng(lat,long);
  667. var mapOptions = {
  668. zoom: 16,
  669. scrollwheel: false,
  670. center: myLatlng
  671. }
  672. var map = new google.maps.Map(document.getElementById(mapid), mapOptions);
  673.  
  674. var marker = new google.maps.Marker({
  675. position: myLatlng,
  676. map: map,
  677. });
  678. var infowindow = new google.maps.InfoWindow();
  679. google.maps.event.addListener(marker, 'click', (function (marker, i) {
  680. return function () {
  681. infowindow.setContent(text);
  682. infowindow.open(map, marker);
  683. }
  684. })(marker));
  685. }
  686.  
  687. google.maps.event.addDomListener(window, 'load', initialize);
  688.  
  689. });
  690. });
  691.  
  692. //Check If IOS
  693. function getMobileOperatingSystem() {
  694. var userAgent = navigator.userAgent || navigator.vendor || window.opera;
  695. if( userAgent.match( /iPad/i ) || userAgent.match( /iPhone/i ) || userAgent.match( /iPod/i ) )
  696. { return 'iOS'; }
  697. }
  698.  
  699. var isSafari = !!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/);
  700.  
  701.  
  702. jQuery(window).bind('load', function(){
  703. jQuery('.toggle_style3').each(function(index, element) {
  704. var first = jQuery('<div/>').addClass('first_toggles');
  705. var mid = jQuery('<div/>').addClass('mid_toggles');
  706. var last = jQuery('<div/>').addClass('last_toggles');
  707.  
  708. var fElems = jQuery(this).find('div.lts_toggle:nth-child(3n+1)');
  709. var mElems = jQuery(this).find('div.lts_toggle:nth-child(3n+2)');
  710. var lElems = jQuery(this).find('div.lts_toggle:nth-child(3n+3)');
  711.  
  712. fElems.appendTo(first);
  713. mElems.appendTo(mid);
  714. lElems.appendTo(last);
  715. jQuery(this).append(first,mid,last);
  716. });
  717.  
  718. jQuery('.toggle_style2').each(function(index, element) {
  719. var first = jQuery('<div/>').addClass('first_toggles');
  720. var mid = jQuery('<div/>').addClass('mid_toggles');
  721.  
  722. var fElems = jQuery(this).find('div.lts_toggle:nth-child(2n+1)');
  723. var mElems = jQuery(this).find('div.lts_toggle:nth-child(2n+2)');
  724.  
  725. fElems.appendTo(first);
  726. mElems.appendTo(mid);
  727.  
  728. jQuery(this).append(first,mid);
  729. });
  730.  
  731. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement