Advertisement
towfiqi

core.js

May 16th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.86 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. /*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 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 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 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: false, property: 'min-height'});});
  143. }
  144.  
  145. //BLOCKS SHORTCODE
  146. jQuery('.lts_blocks .lts_block:empty').remove();
  147. jQuery(".lts_blocks").each(function(){
  148. jQuery(this).waitForImages(function() {
  149. jQuery(this).find('.lts_block').not('.block_full').matchHeight();
  150. });
  151.  
  152. if(jQuery(this).find('.lts_block').length == 4){ jQuery(this).addClass('lts_fourblocks'); }
  153. if(jQuery(this).find('.lts_block').length == 3){ jQuery(this).addClass('lts_threeblocks'); }
  154. if(jQuery(this).find('.lts_block').length == 2){ jQuery(this).addClass('lts_twoblocks'); }
  155. if(jQuery(this).find('.lts_block').length == 1){ jQuery(this).addClass('lts_oneblock'); }
  156. });
  157.  
  158.  
  159. //LIST Shortcode COLOR
  160. jQuery(".lts_list").each(function(){
  161. var bulletcolor = jQuery(this).attr('data-list-color');
  162. var listid = jQuery(this).attr('id');
  163. jQuery('<style>#'+listid+' li:before{color:'+bulletcolor+'}</style>').appendTo('head');
  164. });
  165.  
  166.  
  167.  
  168. //Shortcode JS
  169. //Tabs Javascript
  170. jQuery(".lts_tab p:empty").remove();
  171. jQuery(".lts_tabs .lts_tabtitle.emptyp_clear").remove();
  172. var i = 1;
  173. jQuery(".tabs-container").each(function (){ jQuery(this).find('a.tabtrigger').each(function (){
  174. jQuery(this).attr('href', '#tab-'+i+''); i++;
  175. });
  176. });
  177.  
  178. var i = 1;
  179. jQuery(".tabs-container").each(function (){
  180. jQuery(this).find(".lts_tab_child").not(':empty').each(function (){
  181. jQuery(this).attr('id', 'tab-'+i+''); i++;
  182. });
  183. });
  184.  
  185. var i = 1;
  186. jQuery(".tabs-container").each(function (){jQuery(this).attr('id', 'tabs-container_'+i+''); i++;});
  187.  
  188. jQuery(".tabs-container.tabs_default").each(function (){ var tabid = jQuery(this).attr('id'); var active_color = jQuery(this).data('active-color');
  189. jQuery('<style>body #'+tabid+' ul.tabs li.active a{color:'+active_color+'!important;border-color:'+active_color+'}</style>').appendTo('head');
  190. });
  191. jQuery(".tabs-container.tabs_circular").each(function (){ var tabid = jQuery(this).attr('id'); var active_color = jQuery(this).data('active-color');
  192. jQuery('<style>body #'+tabid+' ul.tabs li.active a{color:'+jQuery('body').css('background-color')+'!important;background:'+active_color+'}</style>').appendTo('head');
  193. });
  194. jQuery(".tabs-container.tabs_minimal").each(function (){ var tabid = jQuery(this).attr('id'); var active_color = jQuery(this).data('active-color');
  195. jQuery('<style>body #'+tabid+' ul.tabs li.active a{color:'+active_color+'!important;border-color:'+active_color+'}</style>').appendTo('head');
  196. });
  197. jQuery(".tabs-container.tabs_capsule").each(function (){ var tabid = jQuery(this).attr('id'); var active_color = jQuery(this).data('active-color');
  198. 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');
  199. });
  200.  
  201. jQuery('.tabs-container').easytabs({updateHash: false});
  202.  
  203. //Toggle Shortcode
  204. jQuery('.lts_toggle_content').hide(); // Hide even though it's already hidden
  205. jQuery('.lts_toggle .trigger').click(function() {
  206. jQuery(this).closest('.lts_toggle').find('.lts_toggle_content').slideToggle("fast"); // First click should toggle to 'show'
  207. return false;
  208. });
  209. jQuery('.lts_toggle a.trigger').toggle(function(){
  210. jQuery(this).find('i').animateRotate(135);
  211. jQuery(this).addClass('down');
  212. }, function(){
  213. jQuery(this).find('i').animateRotate(-90);
  214. jQuery(this).removeClass('down');
  215. });
  216.  
  217. jQuery(".lts_toggle").each(function (){ if(jQuery(this).next('br')){ jQuery(this).next('br').addClass('tabsbr'); } });
  218.  
  219. //Widget image opacity animation
  220. jQuery('.widget_wrap a img').hover(function(){
  221. jQuery(this).stop().animate({ "opacity":"0.7" }, 300);
  222. }, function(){
  223. jQuery(this).stop().animate({ "opacity":"1" }, 300);
  224. });
  225.  
  226.  
  227. //add CLASS for Slider Widget
  228. for (var i=0; i<10; i++){
  229. jQuery('.ast_slider_widget .slide_wdgt:eq('+i+')').attr('id', 'lts_wdgt_nivo'+i+'');
  230. 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, });
  231. }
  232. //Call to action shortcode animation
  233. jQuery('.act_right a').hover(function(){
  234. jQuery(this).addClass('animated pulse');
  235. }, function(){
  236. jQuery(this).removeClass('animated pulse');
  237. });
  238.  
  239.  
  240.  
  241. /*CHECK IF TOUCH ENABLED DEVICE*/
  242. function is_touch_device() {
  243. return (('ontouchstart' in window)
  244. || (navigator.MaxTouchPoints > 0)
  245. || (navigator.msMaxTouchPoints > 0));
  246. }
  247. if (is_touch_device()) { jQuery('body').addClass('touchon'); }else{ jQuery('body').addClass('notouchdevice'); }
  248.  
  249. /*BUG FIX: In iOS landscape, menu and posts widgets links has to be clicked twice.*/
  250. if (is_touch_device()) {
  251. jQuery('#topmenu ul li a').on('click touchend', function(e) {
  252. if((typeof jQuery(this).attr('href')) !== 'undefined') {
  253. var el = jQuery(this);
  254. var link = el.attr('href');
  255. window.location = link;
  256. }
  257. });
  258. }
  259.  
  260. //CountDown Widget
  261. jQuery('.optim_countdown_widget').each(function(index, element) {
  262. jQuery(this).find(".ast_countdown ul").countdown(jQuery(this).find(".ast_countdown ul").attr('data-countdown')).on('update.countdown', function(event) {
  263. jQuery(this).html(event.strftime(''
  264. + '<li><span class="days">%D</span><p class="timeRefDays">'+optim.day+'</p></li>'
  265. + '<li><span class="hours">%H</span><p class="timeRefHours">'+optim.hour+'</p></li>'
  266. + '<li><span class="minutes">%M</span><p class="timeRefMinutes">'+optim.mins+'</p></li>'
  267. + '<li><span class="seconds">%S</span><p class="timeRefSeconds">'+optim.sec+'</p></li>'));
  268. });
  269. });
  270.  
  271. jQuery('.ast_scoial_widget .widget_wrap').has('.social_style_full, .social_style_full_text').addClass('has_full_social_icons');
  272.  
  273. //Radial Progress bar Shortcode
  274. jQuery('.circle_progress').each(function(index, element) {
  275. jQuery(this).circleProgress({ value: jQuery(this).data('progress'), size: 160, fill: { color: jQuery(this).data('background') } });
  276. });
  277. jQuery('.progress_circular').each(function(index, element) {
  278. if(jQuery(this).next().is('.progress_circular')){jQuery(this).addClass('float_progress');}else{jQuery(this).addClass('last_progress').after('<div style="clear:both" />');}
  279. });
  280.  
  281. //ToolTip Shortcode
  282. jQuery('.tooltip').miniTip({ fadeIn: 100 });
  283.  
  284. //post shortcode layout1 thumbnal resize
  285. var laywidth = jQuery('.lts_layout1 .listing-item').width();
  286. jQuery('.lts_layout1 .listing-item').height( (laywidth * 66)/100);
  287. jQuery(window).resize(function() {
  288. var laywidth = jQuery('.lts_layout1 .listing-item').width();
  289. jQuery('.lts_layout1 .listing-item').height( (laywidth * 66)/100);
  290. });
  291.  
  292. var flaywidth = jQuery('.lay1 .hentry').width();
  293. jQuery('.lay1 .ast_row').height( (flaywidth * 66)/100);
  294. jQuery(window).resize(function() {
  295. var flaywidth = jQuery('.lay1 .hentry').width();
  296. jQuery('.lay1 .ast_row').height( (flaywidth * 66)/100);
  297. });
  298.  
  299. jQuery(window).ready(function() {
  300.  
  301. if(jQuery('body .lts_layout3').length){
  302. jQuery('.lts_layout3 .listing-item').wrapAll('<div class="lts3_inner" />');
  303. //Layout3 Shortcode Masonry
  304. var container = document.querySelector('.lts3_inner');
  305. var msnry;
  306. imagesLoaded( container, function() {
  307. new Masonry( container, {
  308. // options
  309. itemSelector: '.listing-item'
  310. });
  311. });
  312. }
  313.  
  314. //Slider Widget
  315. jQuery('.slider_widget_nivo .the_slider_widget').each(function(index, element) {
  316. jQuery(this).nivoSlider({
  317. effect: 'fade',
  318. directionNav: true,
  319. controlNav: true,
  320. //controlNavThumbs: jQuery(this).is('.slider_nav_thumbnav', '.slider_nav_thumb') ? 'true' :'false',
  321. pauseOnHover:false,
  322. slices:1,
  323. pauseTime:4000,
  324. });
  325. });
  326.  
  327. //Slider Widget
  328. jQuery('.slider_widget_gallery .the_slider_widget').each(function(index, element) {
  329. jQuery(this).nivoSlider({
  330. effect: 'fade',
  331. directionNav: true,
  332. controlNav: true,
  333. controlNavThumbs: true,
  334. pauseOnHover:true,
  335. slices:1,
  336. pauseTime:4000,
  337. });
  338. });
  339.  
  340.  
  341. });
  342.  
  343. //MAP WIDGET SUBTITLE SWAP
  344. jQuery('.ast_map.no_map').each(function(index, element) {
  345. jQuery(this).find('.home_subtitle').insertAfter(jQuery(this).find('.optimizer_divider'));
  346. });
  347.  
  348.  
  349.  
  350. //Equal height - Gallery (Square)
  351. jQuery('div[data-gallery-style="1"], div[data-gallery-style="2"]').each(function(index, element) {
  352. jQuery(this).waitForImages(function() {
  353. jQuery(this).find('.gallery-item, .gallery-item img').matchHeight({ byRow: true, property: 'min-height'});
  354. });
  355. });
  356. jQuery('div[data-gallery-style="3"], div[data-gallery-style="4"]').each(function(index, element) {
  357. jQuery(this).waitForImages(function() {
  358. minigrid('div[data-gallery-style="3"]', '.gallery-item', 0);
  359. minigrid('div[data-gallery-style="4"]', '.gallery-item', 0);
  360. window.addEventListener('resize', function(){
  361. minigrid('div[data-gallery-style="3"]', '.gallery-item', 0);
  362. minigrid('div[data-gallery-style="4"]', '.gallery-item', 0);
  363. });
  364. });
  365. });
  366.  
  367.  
  368. jQuery('div[data-gallery-style="5"]').each(function (){
  369. jQuery(this).find('.gallery-item').css({"display":"none"});
  370. jQuery(this).append('<div class="slideshow_gallery" />')
  371. var tn_array = jQuery(this).find(".gallery-item a").map(function() {
  372. return jQuery(this).attr("href");
  373. });
  374. var tn_array_src = jQuery(this).find(".gallery-item img").map(function() {
  375. return jQuery(this).attr("src");
  376. });
  377. var pageLimit= jQuery(this).find(".gallery-item img").size() - 1;
  378. for (var i = 0; i <= pageLimit; i++) {
  379. var article = jQuery(this).find(".gallery-item a");
  380. jQuery(article[i]).addClass("" + i + "");
  381. jQuery(article[i]).attr('id' , "vis" + i + "");
  382. jQuery(this).find('.slideshow_gallery').append("<img id='mainImage" + i + "' src='"+tn_array[i]+"'/>");
  383.  
  384. }
  385.  
  386. 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, });
  387.  
  388. });
  389.  
  390. });
  391.  
  392.  
  393. jQuery(window).on('load',function() {
  394. /*2columns Widget EQUAL HEIGHT*/
  395. jQuery('.frontpage_sidebar, #pagesidebar').each(function (){
  396. jQuery(this).waitForImages(function() {
  397. jQuery(this).find('.widget_col_2').matchHeight({ property: 'min-height'});
  398. });
  399. });
  400. /*3columns Widget EQUAL HEIGHT*/
  401. jQuery('.frontpage_sidebar, #pagesidebar').each(function (){
  402. jQuery(this).waitForImages(function() {
  403. jQuery(this).find('.widget_col_3').matchHeight({ property: 'min-height'});
  404. });
  405. });
  406. /*3 quarter Widget EQUAL HEIGHT*/
  407. jQuery('.frontpage_sidebar, #pagesidebar').each(function (){
  408. jQuery(this).waitForImages(function() {
  409. jQuery(this).find('.widget_col_4, .widget_col_3').matchHeight({ property: 'min-height'});
  410.  
  411. });
  412. });
  413. });
  414.  
  415.  
  416. //CONTACT FORM FOR WIDGETS/
  417. function optimizerContact_validate(element) {
  418. console.log(element);
  419. jQuery('html, body').animate({scrollTop: jQuery(element).offset().top-100}, 150);
  420. jQuery(element).parent().addClass('contact_error');
  421. }
  422. function optimizerValidateEmail(val)
  423. {
  424.  
  425. if(val === ''){ //Check to see if value is empty
  426. return false;
  427. }
  428. if(!val.match(/\S+@\S+\.\S+/)){ //Check to see if has @
  429. return false;
  430. }
  431. if( val.indexOf(' ')!=-1 || val.indexOf('..')!=-1){
  432. return false;
  433. }
  434. }
  435.  
  436. function optimizerContact(buttonid) {
  437.  
  438. var formid = jQuery('#'+buttonid).parent().parent().attr('id');
  439.  
  440. var cname = jQuery('#'+formid).find('.contact_name');
  441. var cemail = jQuery('#'+formid).find('.contact_email');
  442. var csubject = jQuery('#'+formid).find('.contact_subject');
  443. var cextrafld = jQuery('#'+formid).find('.contact_extra');
  444. var cmessage = jQuery('#'+formid).find('.contact_message');
  445.  
  446. cname.parent().removeClass('contact_error'); cemail.parent().removeClass('contact_error'); csubject.parent().removeClass('contact_error'); cmessage.parent().removeClass('contact_error');
  447.  
  448. if(cname.val() === '') {
  449. optimizerContact_validate(cname);
  450.  
  451. } else if(optimizerValidateEmail(cemail.val()) === false) {
  452. optimizerContact_validate(cemail);
  453.  
  454. } else if(csubject.val() === '') {
  455. optimizerContact_validate(csubject);
  456.  
  457. } else if(cmessage.val() === '') {
  458. optimizerContact_validate(cmessage);
  459.  
  460. } else {
  461. jQuery('#'+buttonid).parent().append('<i class="fa fa-circle-o-notch fa-spin contact_buttn_spinner"></i>');
  462. var data = {
  463. 'action': 'optimizer_send_message',
  464. 'contact_name': cname.val(),
  465. 'contact_email': cemail.val(),
  466. 'contact_subject': csubject.val(),
  467. 'contact_extra': cextrafld.val(),
  468. 'contact_message': cmessage.val()
  469. };
  470.  
  471. var ajaxurl = optim.ajaxurl;
  472. jQuery.ajax({
  473. type: "POST",
  474. url: ajaxurl,
  475. data : {
  476. 'contact_name': cname.val(),
  477. 'contact_email': cemail.val(),
  478. 'contact_subject': csubject.val(),
  479. 'contact_message': cmessage.val() ,
  480. 'contact_extra': cextrafld.val(),
  481. 'action' : 'optimizer_send_message',
  482. }
  483. })
  484. .done(function(response,status,jqXHR) {
  485. console.log(response);
  486. jQuery('.contact_form_wrap .fa-circle-o-notch').remove();
  487. if(response === 'success'){
  488. alert(optim.sent);
  489. //console.log(response);
  490. cname.val(''); cemail.val(''); csubject.val(''); cmessage.val('');
  491. }
  492. });
  493.  
  494. }
  495. }
  496.  
  497. /*VIDEO Widgets (Youtube)*/
  498. var players = {};
  499. function onYouTubePlayerAPIReady() {
  500.  
  501. jQuery(document).ready(function() {
  502. jQuery('.ytb_widget_iframe').each(function(event) {
  503.  
  504. var iframeID = jQuery(this).attr('id');
  505. var autoplay = jQuery(this).attr('data-autoplay');
  506. var position = jQuery(this).attr('data-position');
  507. if(autoplay == 1){var auto = 1;}else{var auto = 0;}
  508.  
  509. if(autoplay == 1 && position == 'on_video'){
  510.  
  511. players[iframeID] = new YT.Player(iframeID, {
  512. 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}
  513. });
  514.  
  515. }else{
  516. players[iframeID] = new YT.Player(iframeID, {
  517. suggestedQuality: "large", videoId: jQuery(this).attr('data-video-id'), playerVars :{'autoplay': auto, 'rel':0}
  518. });
  519. }
  520.  
  521. }); //END .ytb_widget_iframe each
  522. }); //End document.ready
  523.  
  524. }
  525.  
  526. function muteVideo(event) {
  527. event.target.mute();
  528. }
  529. function playYouTubeVideo(iframeID) {
  530. players[iframeID].playVideo();
  531. }
  532.  
  533. jQuery(document).ready(function() {
  534. jQuery('.astytb i.fa.fa-play').on('click', function() {
  535. var iframeID = jQuery(this).closest('.optimizer_video_wrap').find('iframe').attr('id');
  536. playYouTubeVideo(iframeID);
  537. jQuery(this).hide();
  538. jQuery(this).parent().parent('.video_on_video').find('.widget_video_content').hide();
  539. jQuery(this).next('.ytb_thumb').hide();
  540. });
  541. });
  542.  
  543.  
  544. /*VIDEO Widgets (Vimeo)*/
  545. jQuery(window).on('load',function() {
  546.  
  547. jQuery('.astvimeo').each(function(index, element) {
  548. var iframeid = jQuery(this).find('iframe').attr('id');
  549. var buttonid = jQuery(this).find('i.fa.fa-play').attr('id');
  550.  
  551. var iframe = document.getElementById(iframeid);
  552. var player = $f(iframe);
  553.  
  554. jQuery('#'+buttonid).on('click', function(){
  555. jQuery(this).parent().parent('.video_on_video').find('.widget_video_content').hide();
  556. jQuery(this).hide();
  557. jQuery(this).parent().removeClass('hidecontrols');
  558. jQuery(this).next('.vim_thumb').hide();
  559. });
  560.  
  561. var playButton = document.getElementById(buttonid);
  562. playButton.addEventListener("click", function() {
  563. player.api("play");
  564. });
  565. });
  566.  
  567. //Custom Video
  568. jQuery('.video_on_video .custom_vdo_wrap').each(function(index, element) {
  569. jQuery(this).find('.mejs-overlay-button').click(function() {
  570. jQuery(this).closest('.video_on_video').find('.widget_video_content').hide();
  571. jQuery(this).next('.customvdo_thumb').hide();
  572. });
  573. });
  574.  
  575.  
  576. });
  577.  
  578.  
  579. //MAP SHORTCODE
  580. jQuery(document).ready(function() {
  581. //MAP SHORTCODE
  582. jQuery(".lts_map_wrap").each(function(){
  583. var lat = jQuery(this).find('.lts_map').attr('data-map-lat');
  584. var long = jQuery(this).find('.lts_map').attr('data-map-long');
  585. var text = jQuery(this).find('.lts_map').attr('data-map-text');
  586. var mapid = jQuery(this).attr('id');
  587.  
  588. function initialize() {
  589. var myLatlng = new google.maps.LatLng(lat,long);
  590. var mapOptions = {
  591. zoom: 16,
  592. scrollwheel: false,
  593. center: myLatlng
  594. }
  595. var map = new google.maps.Map(document.getElementById(mapid), mapOptions);
  596.  
  597. var marker = new google.maps.Marker({
  598. position: myLatlng,
  599. map: map,
  600. });
  601. var infowindow = new google.maps.InfoWindow();
  602. google.maps.event.addListener(marker, 'click', (function (marker, i) {
  603. return function () {
  604. infowindow.setContent(text);
  605. infowindow.open(map, marker);
  606. }
  607. })(marker));
  608. }
  609.  
  610. google.maps.event.addDomListener(window, 'load', initialize);
  611.  
  612. });
  613. });
  614.  
  615. //Check If IOS
  616. function getMobileOperatingSystem() {
  617. var userAgent = navigator.userAgent || navigator.vendor || window.opera;
  618. if( userAgent.match( /iPad/i ) || userAgent.match( /iPhone/i ) || userAgent.match( /iPod/i ) )
  619. { return 'iOS'; }
  620. }
  621.  
  622. var isSafari = !!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement