js_composer_front.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. /**
  2. * Created by duhuan on 2017/9/14.
  3. */
  4. document.documentElement.className += ' js_active ';
  5. document.documentElement.className += 'ontouchstart' in document.documentElement ? ' vc_mobile ' : ' vc_desktop ';
  6. (function () {
  7. var prefix = ['-webkit-', '-o-', '-moz-', '-ms-', ""];
  8. for (var i in prefix) {
  9. if (prefix[i] + 'transform' in document.documentElement.style) document.documentElement.className += " vc_transform ";
  10. }
  11. })();
  12. jQuery(window).load(function () {
  13. });
  14. var vc_js = function () {
  15. vc_twitterBehaviour();
  16. vc_toggleBehaviour();
  17. vc_tabsBehaviour();
  18. vc_accordionBehaviour();
  19. vc_teaserGrid();
  20. vc_carouselBehaviour();
  21. vc_slidersBehaviour();
  22. vc_prettyPhoto();
  23. vc_googleplus();
  24. vc_pinterest();
  25. vc_progress_bar();
  26. vc_plugin_flexslider();
  27. vc_google_fonts();
  28. window.setTimeout(vc_waypoints, 1500);
  29. };
  30. jQuery(document).ready(function ($) {
  31. window.vc_js();
  32. }); // END jQuery(document).ready
  33. if (typeof window['vc_plugin_flexslider'] !== 'function') {
  34. function vc_plugin_flexslider($parent) {
  35. var $slider = $parent ? $parent.find('.wpb_flexslider') : jQuery('.wpb_flexslider');
  36. $slider.each(function () {
  37. var this_element = jQuery(this);
  38. var sliderSpeed = 800,
  39. sliderTimeout = parseInt(this_element.attr('data-interval')) * 1000,
  40. sliderFx = this_element.attr('data-flex_fx'),
  41. slideshow = true;
  42. if (sliderTimeout == 0) slideshow = false;
  43. this_element.is(':visible') && this_element.flexslider({
  44. animation:sliderFx,
  45. slideshow:slideshow,
  46. slideshowSpeed:sliderTimeout,
  47. sliderSpeed:sliderSpeed,
  48. smoothHeight:true
  49. });
  50. });
  51. }
  52. }
  53. /* Twitter
  54. ---------------------------------------------------------- */
  55. if (typeof window['vc_twitterBehaviour'] !== 'function') {
  56. function vc_twitterBehaviour() {
  57. jQuery('.wpb_twitter_widget .tweets').each(function (index) {
  58. var this_element = jQuery(this),
  59. tw_name = this_element.attr('data-tw_name');
  60. tw_count = this_element.attr('data-tw_count');
  61. this_element.tweet({
  62. username:tw_name,
  63. join_text:"auto",
  64. avatar_size:0,
  65. count:tw_count,
  66. template:"{avatar}{join}{text}{time}",
  67. auto_join_text_default:"",
  68. auto_join_text_ed:"",
  69. auto_join_text_ing:"",
  70. auto_join_text_reply:"",
  71. auto_join_text_url:"",
  72. loading_text:'<span class="loading_tweets">loading tweets...</span>'
  73. });
  74. });
  75. }
  76. }
  77. /* Google plus
  78. ---------------------------------------------------------- */
  79. if (typeof window['vc_googleplus'] !== 'function') {
  80. function vc_googleplus() {
  81. if (jQuery('.wpb_googleplus').length > 0) {
  82. (function () {
  83. var po = document.createElement('script');
  84. po.type = 'text/javascript';
  85. po.async = true;
  86. po.src = 'https://apis.google.com/js/plusone.js';
  87. var s = document.getElementsByTagName('script')[0];
  88. s.parentNode.insertBefore(po, s);
  89. })();
  90. }
  91. }
  92. }
  93. /* Pinterest
  94. ---------------------------------------------------------- */
  95. if (typeof window['vc_pinterest'] !== 'function') {
  96. function vc_pinterest() {
  97. if (jQuery('.wpb_pinterest').length > 0) {
  98. (function () {
  99. var po = document.createElement('script');
  100. po.type = 'text/javascript';
  101. po.async = true;
  102. po.src = 'http://assets.pinterest.com/js/pinit.js';
  103. var s = document.getElementsByTagName('script')[0];
  104. s.parentNode.insertBefore(po, s);
  105. //<script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>
  106. })();
  107. }
  108. }
  109. }
  110. /* Progress bar
  111. ---------------------------------------------------------- */
  112. if (typeof window['vc_progress_bar'] !== 'function') {
  113. function vc_progress_bar() {
  114. if (typeof jQuery.fn.waypoint !== 'undefined') {
  115. jQuery('.vc_progress_bar').waypoint(function () {
  116. jQuery(this).find('.vc_single_bar').each(function (index) {
  117. var $this = jQuery(this),
  118. bar = $this.find('.vc_bar'),
  119. val = bar.data('percentage-value');
  120. setTimeout(function () {
  121. bar.css({"width":val + '%'});
  122. }, index * 200);
  123. });
  124. }, { offset:'85%' });
  125. }
  126. }
  127. }
  128. /* Waypoints magic
  129. ---------------------------------------------------------- */
  130. if (typeof window['vc_waypoints'] !== 'function') {
  131. function vc_waypoints() {
  132. if (typeof jQuery.fn.waypoint !== 'undefined') {
  133. jQuery('.wpb_animate_when_almost_visible:not(.wpb_start_animation)').waypoint(function () {
  134. jQuery(this).addClass('wpb_start_animation');
  135. }, { offset:'85%' });
  136. }
  137. }
  138. }
  139. /* Toggle
  140. ---------------------------------------------------------- */
  141. if (typeof window['vc_toggleBehaviour'] !== 'function') {
  142. function vc_toggleBehaviour() {
  143. jQuery(".wpb_toggle").unbind('click').click(function (e) {
  144. if (jQuery(this).next().is(':animated')) {
  145. return false;
  146. }
  147. if (jQuery(this).hasClass('wpb_toggle_title_active')) {
  148. jQuery(this).removeClass('wpb_toggle_title_active').next().slideUp(500);
  149. } else {
  150. jQuery(this).addClass('wpb_toggle_title_active').next().slideDown(500);
  151. }
  152. });
  153. jQuery('.wpb_toggle_content').each(function (index) {
  154. if (jQuery(this).next().is('h4.wpb_toggle') == false) {
  155. jQuery('<div class="last_toggle_el_margin"></div>').insertAfter(this);
  156. }
  157. });
  158. }
  159. }
  160. /* Tabs + Tours
  161. ---------------------------------------------------------- */
  162. if (typeof window['vc_tabsBehaviour'] !== 'function') {
  163. function vc_tabsBehaviour($tab) {
  164. jQuery(function ($) {
  165. $(document.body).off('click.preview', 'a')
  166. });
  167. var $call = $tab || jQuery('.wpb_tabs, .wpb_tour'),
  168. ver = jQuery.ui && jQuery.ui.version ? jQuery.ui.version.split('.') : '1.10',
  169. old_version = parseInt(ver[0]) == 1 && parseInt(ver[1]) < 9;
  170. // if($call.hasClass('ui-widget')) $call.tabs('destroy');
  171. $call.each(function (index) {
  172. var $tabs,
  173. interval = jQuery(this).attr("data-interval"),
  174. tabs_array = [];
  175. //
  176. $tabs = jQuery(this).find('.wpb_tour_tabs_wrapper').tabs({
  177. show:function (event, ui) {
  178. wpb_prepare_tab_content(event, ui);
  179. },
  180. beforeActivate: function(event, ui) {
  181. ui.newPanel.index() !== 1 && ui.newPanel.find('.vc_pie_chart:not(.vc_ready)');
  182. },
  183. activate:function (event, ui) {
  184. wpb_prepare_tab_content(event, ui);
  185. }
  186. }).tabs('rotate', interval * 1000);
  187. jQuery(this).find('.wpb_tab').each(function () {
  188. tabs_array.push(this.id);
  189. });
  190. jQuery(this).find('.wpb_tabs_nav a').click(function (e) {
  191. e.preventDefault();
  192. if (jQuery.inArray(jQuery(this).attr('href'), tabs_array)) {
  193. if (old_version) {
  194. $tabs.tabs("select", jQuery(this).attr('href'));
  195. } else {
  196. $tabs.tabs("option", "active", jQuery(jQuery(this).attr('href')).index() - 1);
  197. }
  198. return false;
  199. }
  200. });
  201. jQuery(this).find('.wpb_prev_slide a, .wpb_next_slide a').click(function (e) {
  202. e.preventDefault();
  203. if (old_version) {
  204. var index = $tabs.tabs('option', 'selected');
  205. if (jQuery(this).parent().hasClass('wpb_next_slide')) {
  206. index++;
  207. }
  208. else {
  209. index--;
  210. }
  211. if (index < 0) {
  212. index = $tabs.tabs("length") - 1;
  213. }
  214. else if (index >= $tabs.tabs("length")) {
  215. index = 0;
  216. }
  217. $tabs.tabs("select", index);
  218. } else {
  219. var index = $tabs.tabs("option", "active"),
  220. length = $tabs.find('.wpb_tab').length;
  221. if (jQuery(this).parent().hasClass('wpb_next_slide')) {
  222. index = (index + 1) >= length ? 0 : index + 1;
  223. } else {
  224. index = index - 1 < 0 ? length - 1 : index - 1;
  225. }
  226. $tabs.tabs("option", "active", index);
  227. }
  228. });
  229. });
  230. }
  231. }
  232. /* Tabs + Tours
  233. ---------------------------------------------------------- */
  234. if (typeof window['vc_accordionBehaviour'] !== 'function') {
  235. function vc_accordionBehaviour() {
  236. jQuery('.wpb_accordion').each(function (index) {
  237. var $tabs,
  238. interval = jQuery(this).attr("data-interval"),
  239. active_tab = !isNaN(jQuery(this).data('active-tab')) && parseInt(jQuery(this).data('active-tab')) > 0 ? parseInt(jQuery(this).data('active-tab')) - 1 : false,
  240. collapsible = active_tab === false || jQuery(this).data('collapsible') === 'yes';
  241. //
  242. $tabs = jQuery(this).find('.wpb_accordion_wrapper').accordion({
  243. header:"> div > h3",
  244. autoHeight:false,
  245. heightStyle:"content",
  246. active:active_tab,
  247. collapsible:collapsible,
  248. navigation:true,
  249. activate: vc_accordionActivate,
  250. change:function (event, ui) {
  251. if (jQuery.fn.isotope != undefined) {
  252. ui.newContent.find('.isotope').isotope("layout");
  253. }
  254. vc_carouselBehaviour(ui.newPanel);
  255. }
  256. });
  257. //.tabs().tabs('rotate', interval*1000, true);
  258. });
  259. }
  260. }
  261. /* Teaser grid: isotope
  262. ---------------------------------------------------------- */
  263. if (typeof window['vc_teaserGrid'] !== 'function') {
  264. function vc_teaserGrid() {
  265. var layout_modes = {
  266. fitrows:'fitRows',
  267. masonry:'masonry'
  268. }
  269. jQuery('.wpb_grid .teaser_grid_container:not(.wpb_carousel), .wpb_filtered_grid .teaser_grid_container:not(.wpb_carousel)').each(function () {
  270. var $container = jQuery(this);
  271. var $thumbs = $container.find('.wpb_thumbnails');
  272. var layout_mode = $thumbs.attr('data-layout-mode');
  273. $thumbs.isotope({
  274. // options
  275. itemSelector:'.isotope-item',
  276. layoutMode:(layout_modes[layout_mode] == undefined ? 'fitRows' : layout_modes[layout_mode])
  277. });
  278. $container.find('.categories_filter a').data('isotope', $thumbs).click(function (e) {
  279. e.preventDefault();
  280. var $thumbs = jQuery(this).data('isotope');
  281. jQuery(this).parent().parent().find('.active').removeClass('active');
  282. jQuery(this).parent().addClass('active');
  283. $thumbs.isotope({filter:jQuery(this).attr('data-filter')});
  284. });
  285. jQuery(window).bind('load resize', function () {
  286. $thumbs.isotope("layout");
  287. });
  288. });
  289. }
  290. }
  291. if (typeof window['vc_carouselBehaviour'] !== 'function') {
  292. function vc_carouselBehaviour($parent) {
  293. var $carousel = $parent ? $parent.find(".wpb_carousel") : jQuery(".wpb_carousel");
  294. $carousel.each(function () {
  295. var $this = jQuery(this);
  296. if ($this.data('carousel_enabled') !== true && $this.is(':visible')) {
  297. $this.data('carousel_enabled', true);
  298. var carousel_width = jQuery(this).width(),
  299. visible_count = getColumnsCount(jQuery(this)),
  300. carousel_speed = 500;
  301. if (jQuery(this).hasClass('columns_count_1')) {
  302. carousel_speed = 900;
  303. }
  304. /* Get margin-left value from the css grid and apply it to the carousele li items (margin-right), before carousele initialization */
  305. var carousele_li = jQuery(this).find('.wpb_thumbnails-fluid li');
  306. carousele_li.css({"margin-right":carousele_li.css("margin-left"), "margin-left":0 });
  307. jQuery(this).find('.wpb_wrapper:eq(0)').jCarouselLite({
  308. btnNext:jQuery(this).find('.next'),
  309. btnPrev:jQuery(this).find('.prev'),
  310. visible:visible_count,
  311. speed:carousel_speed
  312. })
  313. .width('100%');//carousel_width
  314. var fluid_ul = jQuery(this).find('ul.wpb_thumbnails-fluid');
  315. fluid_ul.width(fluid_ul.width() + 300);
  316. jQuery(window).resize(function () {
  317. var before_resize = screen_size;
  318. screen_size = getSizeName();
  319. if (before_resize != screen_size) {
  320. window.setTimeout('location.reload()', 20);
  321. }
  322. });
  323. }
  324. });
  325. }
  326. }
  327. if (typeof window['vc_slidersBehaviour'] !== 'function') {
  328. function vc_slidersBehaviour() {
  329. //var sliders_count = 0;
  330. jQuery('.wpb_gallery_slides').each(function (index) {
  331. var this_element = jQuery(this);
  332. var ss_count = 0;
  333. if (this_element.hasClass('wpb_slider_nivo')) {
  334. var sliderSpeed = 800,
  335. sliderTimeout = this_element.attr('data-interval') * 1000;
  336. if (sliderTimeout == 0) sliderTimeout = 9999999999;
  337. this_element.find('.nivoSlider').nivoSlider({
  338. effect:'boxRainGrow,boxRain,boxRainReverse,boxRainGrowReverse', // Specify sets like: 'fold,fade,sliceDown'
  339. slices:15, // For slice animations
  340. boxCols:8, // For box animations
  341. boxRows:4, // For box animations
  342. animSpeed:sliderSpeed, // Slide transition speed
  343. pauseTime:sliderTimeout, // How long each slide will show
  344. startSlide:0, // Set starting Slide (0 index)
  345. directionNav:true, // Next & Prev navigation
  346. directionNavHide:true, // Only show on hover
  347. controlNav:true, // 1,2,3... navigation
  348. keyboardNav:false, // Use left & right arrows
  349. pauseOnHover:true, // Stop animation while hovering
  350. manualAdvance:false, // Force manual transitions
  351. prevText:'Prev', // Prev directionNav text
  352. nextText:'Next' // Next directionNav text
  353. });
  354. }
  355. else if (this_element.hasClass('wpb_flexslider') && 1 == 2) { /* TODO: remove this */
  356. }
  357. else if (this_element.hasClass('wpb_image_grid')) {
  358. var isotope = this_element.find('.wpb_image_grid_ul');
  359. isotope.isotope({
  360. // options
  361. itemSelector:'.isotope-item',
  362. layoutMode:'fitRows'
  363. });
  364. jQuery(window).load(function () {
  365. isotope.isotope("layout");
  366. });
  367. }
  368. });
  369. }
  370. }
  371. if (typeof window['vc_prettyPhoto'] !== 'function') {
  372. function vc_prettyPhoto() {
  373. try {
  374. // just in case. maybe prettyphoto isnt loaded on this site
  375. jQuery('a.prettyphoto, .gallery-icon a[href*=".jpg"]').prettyPhoto({
  376. animationSpeed:'normal', /* fast/slow/normal */
  377. padding:15, /* padding for each side of the picture */
  378. opacity:0.7, /* Value betwee 0 and 1 */
  379. showTitle:true, /* true/false */
  380. allowresize:true, /* true/false */
  381. counter_separator_label:'/', /* The separator for the gallery counter 1 "of" 2 */
  382. //theme: 'light_square', /* light_rounded / dark_rounded / light_square / dark_square */
  383. hideflash:false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
  384. deeplinking:false, /* Allow prettyPhoto to update the url to enable deeplinking. */
  385. modal:false, /* If set to true, only the close button will close the window */
  386. callback:function () {
  387. var url = location.href;
  388. var hashtag = (url.indexOf('#!prettyPhoto')) ? true : false;
  389. if (hashtag) location.hash = "!";
  390. } /* Called when prettyPhoto is closed */,
  391. social_tools:''
  392. });
  393. } catch (err) {
  394. }
  395. }
  396. }
  397. if ( typeof window['vc_google_fonts'] !== 'function' ) {
  398. function vc_google_fonts() {
  399. return;
  400. }
  401. }
  402. /* Helper
  403. ---------------------------------------------------------- */
  404. function getColumnsCount(el) {
  405. var find = false,
  406. i = 1;
  407. while (find == false) {
  408. if (el.hasClass('columns_count_' + i)) {
  409. find = true;
  410. return i;
  411. }
  412. i++;
  413. }
  414. }
  415. var screen_size = getSizeName();
  416. function getSizeName() {
  417. var screen_size = '',
  418. screen_w = jQuery(window).width();
  419. if (screen_w > 1170) {
  420. screen_size = "desktop_wide";
  421. }
  422. else if (screen_w > 960 && screen_w < 1169) {
  423. screen_size = "desktop";
  424. }
  425. else if (screen_w > 768 && screen_w < 959) {
  426. screen_size = "tablet";
  427. }
  428. else if (screen_w > 300 && screen_w < 767) {
  429. screen_size = "mobile";
  430. }
  431. else if (screen_w < 300) {
  432. screen_size = "mobile_portrait";
  433. }
  434. return screen_size;
  435. }
  436. function loadScript(url, $obj, callback) {
  437. var script = document.createElement("script")
  438. script.type = "text/javascript";
  439. if (script.readyState) { //IE
  440. script.onreadystatechange = function () {
  441. if (script.readyState == "loaded" ||
  442. script.readyState == "complete") {
  443. script.onreadystatechange = null;
  444. callback();
  445. }
  446. };
  447. } else { //Others
  448. /*
  449. script.onload = function(){
  450. callback();
  451. };
  452. */
  453. }
  454. script.src = url;
  455. $obj.get(0).appendChild(script);
  456. }
  457. function wpb_prepare_tab_content(event, ui) {
  458. var panel = ui.panel || ui.newPanel,
  459. $pie_charts = panel.find('.vc_pie_chart:not(.vc_ready)'),
  460. $carousel = panel.find('[data-ride="vc_carousel"]'),
  461. $ui_panel, $google_maps;
  462. vc_carouselBehaviour();
  463. vc_plugin_flexslider(panel);
  464. $pie_charts.length && jQuery.fn.vcChat && $pie_charts.vcChat();
  465. $carousel.length && jQuery.fn.carousel && $carousel.carousel('resizeAction');
  466. $ui_panel = panel.find('.isotope');
  467. $google_maps = panel.find('.wpb_gmaps_widget');
  468. if ($ui_panel.length > 0) {
  469. $ui_panel.isotope("layout");
  470. }
  471. if ($google_maps.length && !$google_maps.is('.map_ready')) {
  472. var $frame = $google_maps.find('iframe');
  473. $frame.attr('src', $frame.attr('src'));
  474. $google_maps.addClass('map_ready');
  475. }
  476. if(panel.parents('.isotope').length) {
  477. panel.parents('.isotope').each(function(){
  478. jQuery(this).isotope("layout");
  479. });
  480. }
  481. }
  482. var vc_accordionActivate = function(event, ui) {
  483. var $pie_charts = ui.newPanel.find('.vc_pie_chart:not(.vc_ready)'),
  484. $carousel = ui.newPanel.find('[data-ride="vc_carousel"]');
  485. if (jQuery.fn.isotope != undefined) {
  486. ui.newPanel.find('.isotope').isotope("layout");
  487. }
  488. vc_carouselBehaviour(ui.newPanel);
  489. vc_plugin_flexslider(ui.newPanel);
  490. $pie_charts.length && jQuery.fn.vcChat && $pie_charts.vcChat();
  491. $carousel.length && jQuery.fn.carousel && $carousel.carousel('resizeAction');
  492. if(ui.newPanel.parents('.isotope').length) {
  493. ui.newPanel.parents('.isotope').each(function(){
  494. jQuery(this).isotope("layout");
  495. });
  496. }
  497. }