Advertisement
towfiqi

core.js

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