Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 67.22 KB | None | 0 0
  1. /*-----------------------------------------------------------------------------------
  2.  
  3. Theme Name: BuddyApp
  4. Theme URI: http://themeforest.net/user/SeventhQueen
  5. Description: First Mobile Private Community Premium WordPress theme
  6. Author: SeventhQueen
  7. Author URI: http://themeforest.net/user/SeventhQueen
  8. Javascript theme logic v1.0.0
  9.  
  10. == Table of contents ==
  11. 1. General functions
  12. 2. Header functions
  13. 3. BuddyPress functions
  14.  
  15. -----------------------------------------------------------------------------------*/
  16.  
  17.  
  18.  
  19. /* -----------------------------------------
  20. requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
  21. MIT license
  22. ----------------------------------------- */
  23. (function () {
  24. var lastTime = 0;
  25. var vendors = ['ms', 'moz', 'webkit', 'o'];
  26. for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
  27. window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
  28. window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame']
  29. || window[vendors[x] + 'CancelRequestAnimationFrame'];
  30. }
  31.  
  32. if (!window.requestAnimationFrame)
  33. window.requestAnimationFrame = function (callback, element) {
  34. var currTime = new Date().getTime();
  35. var timeToCall = Math.max(0, 16 - (currTime - lastTime));
  36. var id = window.setTimeout(function () {
  37. callback(currTime + timeToCall);
  38. },
  39. timeToCall);
  40. lastTime = currTime + timeToCall;
  41. return id;
  42. };
  43.  
  44. if (!window.cancelAnimationFrame)
  45. window.cancelAnimationFrame = function (id) {
  46. clearTimeout(id);
  47. };
  48. }());
  49.  
  50.  
  51.  
  52.  
  53. var KLEO = KLEO || {};
  54. (function ($) {
  55.  
  56. // USE STRICT
  57. "use strict";
  58.  
  59. /* Image resize function */
  60. var photoContainer = $(".image-wrapper");
  61. var photoImage = $(".image-wrapper .image");
  62.  
  63. function imageResize() {
  64. photoContainer.each(function(){
  65. var wrapperWidth = $(this).width();
  66. var wrapperHeight = $(this).height();
  67. var wrapperRatio = wrapperWidth / wrapperHeight;
  68.  
  69. var imageWidth = $(this).find(".image").width();
  70. var imageHeight = $(this).find(".image").height();
  71. var imageRatio = imageWidth / imageHeight;
  72.  
  73.  
  74. if(wrapperWidth == 0 || wrapperHeight == 0) {
  75. return false;
  76. }
  77.  
  78. //console.log("wrapper W-H:" + wrapperWidth + " & " + wrapperHeight);
  79. //console.log("image W-H:" + imageWidth + " & " + imageHeight);
  80.  
  81. $(this).css("opacity", "0");
  82.  
  83. if(imageRatio <= wrapperRatio) {
  84. var newImageHeight = wrapperWidth / imageRatio;
  85. newImageHeight = parseInt(newImageHeight);
  86. var semiImageHeight = parseInt(newImageHeight / 2);
  87.  
  88. //console.log("imageRatio <= wrapperRatio");
  89.  
  90.  
  91. $(this).find(".image").css({
  92. width: wrapperWidth,
  93. height: newImageHeight,
  94. marginTop:-semiImageHeight,
  95. marginLeft:0,
  96. top: "50%",
  97. left:"0"
  98. });
  99.  
  100.  
  101. $(this).css("opacity", "1");
  102.  
  103. } else {
  104.  
  105. //console.log("imageRatio > wrapperRatio");
  106.  
  107. var newImageWidth = wrapperHeight * imageRatio;
  108. newImageWidth = parseInt(newImageWidth);
  109. var semiImageWidth = parseInt(newImageWidth / 2);
  110.  
  111.  
  112. $(this).find(".image").css({
  113. width: newImageWidth,
  114. height: wrapperHeight,
  115. marginTop:0,
  116. marginLeft:-semiImageWidth,
  117. top: "0",
  118. left:"50%"
  119. });
  120. $(this).css("opacity", "1");
  121. }
  122. });
  123. }
  124.  
  125.  
  126. var fadeStart=0; // 100px scroll or less will equiv to 1 opacity
  127. var fadeUntil=800; // 200px scroll or more will equiv to 0 opacity
  128. var fadingHalf = $('.fade-on-scroll-half');
  129. var fading = $('.fade-on-scroll');
  130. var fadingSecond = $('.fade-on-scroll-second');
  131. var topTop = $('.top-on-scroll');
  132. var bottomBottom = $('.bottom-on-scroll');
  133.  
  134. $(window).bind('scroll', function(){
  135. var offset = $(document).scrollTop();
  136. var opacity=0;
  137. var opacity2=0;
  138. var opacity3=0;
  139.  
  140. var top = 0;
  141. var bottom = 40;
  142.  
  143. if( offset<=fadeStart ){
  144. opacity=0.5;
  145. opacity2 = 1;
  146. opacity3 = 1;
  147. top = 0;
  148.  
  149. }else if( offset<=fadeUntil ){
  150. opacity=0.5-offset/fadeUntil;
  151. opacity2=1-offset/(fadeUntil-50);
  152. opacity3=(0.5-offset/fadeUntil)/4;
  153.  
  154. top = top + offset/2;
  155. bottom=bottom - offset/2.5;
  156.  
  157. }
  158.  
  159. fadingHalf.css('opacity',opacity);
  160. fading.css('opacity',opacity2);
  161. fadingSecond.css('opacity',opacity2);
  162. topTop.css("top", top);
  163. bottomBottom.css("bottom", bottom);
  164. });
  165.  
  166. KLEO.isMobile = {
  167. Android: function () {
  168. return navigator.userAgent.match(/Android/i);
  169. },
  170. BlackBerry: function () {
  171. return navigator.userAgent.match(/BlackBerry/i);
  172. },
  173. iOS: function () {
  174. return navigator.userAgent.match(/iPhone|iPad|iPod/i);
  175. },
  176. Opera: function () {
  177. return navigator.userAgent.match(/Opera Mini/i);
  178. },
  179. Windows: function () {
  180. return navigator.userAgent.match(/IEMobile/i);
  181. },
  182. mobileWidth: function () {
  183. if (window.matchMedia) {
  184. return window.matchMedia('(max-width: 480px)').matches;
  185. } else {
  186. return $(window).innerWidth() < 465;
  187. }
  188.  
  189. },
  190. tabletWidth: function () {
  191. if (window.matchMedia) {
  192. return window.matchMedia('(max-width: 767px)').matches;
  193. } else {
  194. return $(window).innerWidth() < 753;
  195. }
  196. },
  197. any: function () {
  198. return (KLEO.isMobile.Android() || KLEO.isMobile.BlackBerry() || KLEO.isMobile.iOS() || KLEO.isMobile.Opera() || KLEO.isMobile.Windows());
  199. }
  200. };
  201.  
  202. KLEO.isHighDensity = function () {
  203. return ((window.matchMedia && (window.matchMedia('only screen and (min-resolution: 124dpi), only screen and (min-resolution: 1.3dppx), only screen and (min-resolution: 48.8dpcm)').matches || window.matchMedia('only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3)').matches)) || (window.devicePixelRatio && window.devicePixelRatio > 1.3));
  204. };
  205.  
  206. /* -----------------------------------------
  207. 1. General functions
  208. ----------------------------------------- */
  209. KLEO.main = {
  210.  
  211. init: function () {
  212. KLEO.main.responsiveClasses();
  213. KLEO.main.pageTransition();
  214. KLEO.main.imageFade();
  215. KLEO.main.animations();
  216. KLEO.main.toggles();
  217. KLEO.main.accordions();
  218. KLEO.main.linkScroll();
  219.  
  220. KLEO.main.lightBox();
  221. KLEO.main.resizeVideos();
  222. $body.on('lightBoxAjaxAdded', function () {
  223. KLEO.main.resizeVideos();
  224. });
  225. KLEO.main.loadFlexSlider();
  226.  
  227. KLEO.main.applyRetina();
  228. KLEO.main.ajaxLogin();
  229. KLEO.main.ajaxLostPass();
  230. KLEO.main.menuWidget();
  231.  
  232.  
  233.  
  234. /* Ajax search functionality */
  235. if ($('.kleo_ajax_results').length) {
  236. KLEO.main.toggleAjaxSearch();
  237. KLEO.main.doAjaxSearch();
  238. }
  239.  
  240. if (KLEO.isMobile.any()) {
  241. $body.addClass('device-touch');
  242. }
  243.  
  244. KLEO.main.onScroll();
  245.  
  246. photoContainer.css("opacity", "0");
  247.  
  248. $("body").on( "sidemenu-moving-start", function() {
  249. if($("#page-title").hasClass("blog-full") && !($("body").hasClass("device-xs") || $("body").hasClass("device-xxs")) ) {
  250. photoImage.css("opacity","0");
  251. }
  252. });
  253.  
  254. $("body").on( "sidemenu-moving", function() {
  255. if($("#page-title").hasClass("blog-full") && !($("body").hasClass("device-xs") || $("body").hasClass("device-xxs")) ) {
  256. imageResize();
  257. photoImage.css("opacity",".5");
  258. }
  259. });
  260.  
  261. },
  262.  
  263. onLoad: function () {
  264. KLEO.main.kleoIsotope();
  265. imageResize();
  266. KLEO.main.charts();
  267. },
  268.  
  269. onResize: function () {
  270. imageResize();
  271.  
  272. },
  273.  
  274. onScroll: function () {
  275.  
  276. $window.on('scroll', function () {
  277. //
  278. });
  279.  
  280. },
  281.  
  282. setCookie: function (cname, cvalue, path, exdays) {
  283. if (typeof path === 'undefined') {
  284. path = '/';
  285. }
  286. var d = new Date();
  287. d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
  288. var expires = "expires=" + d.toUTCString();
  289. document.cookie = cname + "=" + cvalue + "; " + expires + "; path=" + path;
  290. },
  291.  
  292. // Sidebar menu toggle
  293. menuWidget: function () {
  294. var submenuParent = jQuery(".widget_nav_menu ul.sub-menu").parent('li');
  295. submenuParent.addClass('parent');
  296. submenuParent.children("a").after('<span class="menu-arrow"></span>');
  297. submenuParent.find(".menu-arrow").click(function () {
  298. jQuery(this).closest(".parent").children('.sub-menu').stop(true, true).slideToggle('fast');
  299. jQuery(this).toggleClass('active');
  300. return false;
  301. });
  302.  
  303. var pagesParent = jQuery(".widget_pages ul.children").parent('li');
  304. pagesParent.addClass('parent');
  305. pagesParent.children("a").after('<span class="menu-arrow"></span>');
  306. pagesParent.find(".menu-arrow").click(function () {
  307. jQuery(this).closest(".parent").children('.children').stop(true, true).slideToggle('fast');
  308. jQuery(this).toggleClass('active');
  309. return false;
  310. });
  311. if (pagesParent.find('.current_page_item').length) {
  312. $('.widget_pages ul.children .current_page_item').closest('.children').stop(true, true).slideToggle('fast')
  313. }
  314.  
  315. /* If tho submenus on the same level then move the last as the children to the first one */
  316. if ($(".submenu").next(".submenu").length) {
  317. $(".submenu").next(".submenu").each(function () {
  318. $(this).prev(".submenu").append($(this).html());
  319. $(this).remove();
  320. });
  321. }
  322.  
  323. },
  324.  
  325. /* Add classes based on the device viewport */
  326. responsiveClasses: function () {
  327. var jRes = jRespond([
  328. {
  329. label: 'small-mobile',
  330. enter: 0,
  331. exit: 479
  332. }, {
  333. label: 'mobile',
  334. enter: 480,
  335. exit: 767
  336. }, {
  337. label: 'tablet',
  338. enter: 768,
  339. exit: 991
  340. }, {
  341. label: 'desktop',
  342. enter: 992,
  343. exit: 1199
  344. }, {
  345. label: 'large-desktop',
  346. enter: 1200,
  347. exit: 10000
  348. }
  349. ]);
  350. jRes.addFunc([
  351. {
  352. breakpoint: 'large-desktop',
  353. enter: function () {
  354. $body.addClass('device-lg');
  355. },
  356. exit: function () {
  357. $body.removeClass('device-lg');
  358. }
  359. }, {
  360. breakpoint: 'desktop',
  361. enter: function () {
  362. $body.addClass('device-md');
  363. },
  364. exit: function () {
  365. $body.removeClass('device-md');
  366. }
  367. }, {
  368. breakpoint: 'tablet',
  369. enter: function () {
  370. $body.addClass('device-sm');
  371. },
  372. exit: function () {
  373. $body.removeClass('device-sm');
  374. }
  375. }, {
  376. breakpoint: 'mobile',
  377. enter: function () {
  378. $body.addClass('device-xs');
  379. },
  380. exit: function () {
  381. $body.removeClass('device-xs');
  382. }
  383. }, {
  384. breakpoint: 'small-mobile',
  385. enter: function () {
  386. $body.addClass('device-xxs');
  387. },
  388. exit: function () {
  389. $body.removeClass('device-xxs');
  390. }
  391. }
  392. ]);
  393. },
  394.  
  395. /* Preload images */
  396. imagePreload: function (selector, parameters) {
  397. var params = {
  398. delay: 250,
  399. transition: 400,
  400. easing: 'linear'
  401. };
  402. $.extend(params, parameters);
  403.  
  404. $(selector).each(function () {
  405. var image = $(this);
  406. image.css({visibility: 'hidden', opacity: 0, display: 'block'});
  407. image.wrap('<span class="preloader" />');
  408. image.one("load", function (evt) {
  409. $(this).delay(params.delay).css({visibility: 'visible'}).animate({opacity: 1}, params.transition, params.easing, function () {
  410. $(this).unwrap('<span class="preloader" />');
  411. });
  412. }).each(function () {
  413. if (this.complete) $(this).trigger("load");
  414. });
  415. });
  416. },
  417.  
  418. /* Nice page transitions */
  419. pageTransition: function () {
  420. if ($('html').hasClass('js') && $body.hasClass('page-transition')) {
  421. var animationIn = $body.attr('data-animation-in'),
  422. animationOut = $body.attr('data-animation-out'),
  423. durationIn = $body.attr('data-speed-in'),
  424. durationOut = $body.attr('data-speed-out'),
  425. loaderStyle = $body.attr('data-loader'),
  426. loaderStyleHtml = '<div class="css3-spinner-bounce1"></div><div class="css3-spinner-bounce2"></div><div class="css3-spinner-bounce3"></div>';
  427.  
  428. if (!animationIn) {
  429. animationIn = 'fadeIn';
  430. }
  431. if (!animationOut) {
  432. animationOut = 'fadeOut';
  433. }
  434. if (!durationIn) {
  435. durationIn = 1500;
  436. }
  437. if (!durationOut) {
  438. durationOut = 800;
  439. }
  440.  
  441. if (loaderStyle == '2') {
  442. loaderStyleHtml = '<div class="css3-spinner-flipper"></div>';
  443. } else if (loaderStyle == '3') {
  444. loaderStyleHtml = '<div class="css3-spinner-double-bounce1"></div><div class="css3-spinner-double-bounce2"></div>';
  445. } else if (loaderStyle == '4') {
  446. loaderStyleHtml = '<div class="css3-spinner-rect1"></div><div class="css3-spinner-rect2"></div><div class="css3-spinner-rect3"></div><div class="css3-spinner-rect4"></div><div class="css3-spinner-rect5"></div>';
  447. } else if (loaderStyle == '5') {
  448. loaderStyleHtml = '<div class="css3-spinner-cube1"></div><div class="css3-spinner-cube2"></div>';
  449. } else if (loaderStyle == '6') {
  450. loaderStyleHtml = '<div class="css3-spinner-scaler"></div>';
  451. }
  452.  
  453. $wrapper.animsition({
  454. inClass: animationIn,
  455. outClass: animationOut,
  456. inDuration: Number(durationIn),
  457. outDuration: Number(durationOut),
  458. linkElement: '#primary-menu ul li a:not([target="_blank"]):not([href^=#])',
  459. loading: true,
  460. loadingParentElement: 'body',
  461. loadingClass: 'css3-spinner',
  462. loadingHtml: loaderStyleHtml,
  463. unSupportCss: [
  464. 'animation-duration',
  465. '-webkit-animation-duration',
  466. '-o-animation-duration'
  467. ],
  468. overlay: false,
  469. overlayClass: 'animsition-overlay-slide',
  470. overlayParentElement: 'body'
  471. });
  472. }
  473. },
  474.  
  475. /* Image fade on Hover */
  476. imageFade: function () {
  477. $('.image_fade').hover(function () {
  478. $(this).filter(':not(:animated)').animate({opacity: 0.8}, 400);
  479. }, function () {
  480. $(this).animate({opacity: 1}, 400);
  481. });
  482. },
  483.  
  484. animations: function () {
  485. var $dataAnimateEl = $('[data-animate]');
  486. if ($dataAnimateEl.length > 0) {
  487. if ($body.hasClass('device-lg') || $body.hasClass('device-md') || $body.hasClass('device-sm')) {
  488. $dataAnimateEl.each(function () {
  489. var element = $(this),
  490. animationDelay = element.attr('data-delay'),
  491. animationDelayTime = 0;
  492.  
  493. if (animationDelay) {
  494. animationDelayTime = Number(animationDelay) + 500;
  495. } else {
  496. animationDelayTime = 500;
  497. }
  498.  
  499. if (!element.hasClass('animated')) {
  500. element.addClass('not-animated');
  501. var elementAnimation = element.attr('data-animate');
  502. element.appear(function () {
  503. setTimeout(function () {
  504. element.removeClass('not-animated').addClass(elementAnimation + ' animated');
  505. }, animationDelayTime);
  506. }, {accX: 0, accY: -120}, 'easeInCubic');
  507. }
  508. });
  509. }
  510. }
  511. },
  512.  
  513.  
  514. /* Calculate Top page offset */
  515. topScrollOffset: function () {
  516. var topOffsetScroll = 0;
  517.  
  518. return topOffsetScroll;
  519. },
  520.  
  521.  
  522. linkScroll: function () {
  523. $("a[data-scrollto]").click(function () {
  524. var element = $(this),
  525. divScrollToAnchor = element.attr('data-scrollto'),
  526. divScrollSpeed = element.attr('data-speed'),
  527. divScrollOffset = element.attr('data-offset'),
  528. divScrollEasing = element.attr('data-easing');
  529.  
  530. if (!divScrollSpeed) {
  531. divScrollSpeed = 750;
  532. }
  533. if (!divScrollOffset) {
  534. divScrollOffset = KLEO.main.topScrollOffset();
  535. }
  536. if (!divScrollEasing) {
  537. divScrollEasing = 'easeOutQuad';
  538. }
  539.  
  540. $('html,body').stop(true).animate({
  541. 'scrollTop': $(divScrollToAnchor).offset().top - Number(divScrollOffset)
  542. }, Number(divScrollSpeed), divScrollEasing);
  543.  
  544. return false;
  545. });
  546. },
  547.  
  548. toggles: function () {
  549. var $toggle = $('.toggle');
  550. if ($toggle.length > 0) {
  551. $toggle.each(function () {
  552. var element = $(this),
  553. elementState = element.attr('data-state');
  554.  
  555. if (elementState != 'open') {
  556. element.find('.togglec').hide();
  557. } else {
  558. element.find('.togglet').addClass("toggleta");
  559. }
  560.  
  561. element.find('.togglet').click(function () {
  562. $(this).toggleClass('toggleta').next('.togglec').slideToggle(300);
  563. return true;
  564. });
  565. });
  566. }
  567. },
  568.  
  569. accordions: function () {
  570. var $accordionEl = $('.accordion');
  571. if ($accordionEl.length > 0) {
  572. $accordionEl.each(function () {
  573. var element = $(this),
  574. elementState = element.attr('data-state'),
  575. accordionActive = element.attr('data-active');
  576.  
  577. if (!accordionActive) {
  578. accordionActive = 0;
  579. } else {
  580. accordionActive = accordionActive - 1;
  581. }
  582.  
  583. element.find('.acc_content').hide();
  584.  
  585. if (elementState != 'closed') {
  586. element.find('.acctitle:eq(' + Number(accordionActive) + ')').addClass('acctitlec').next().show();
  587. }
  588.  
  589. element.find('.acctitle').click(function () {
  590.  
  591. if ($(this).next().is(':visible')) {
  592. $(this).removeClass('acctitlec').next().slideUp("normal");
  593. }else{
  594. $(this).addClass('acctitlec').next().slideDown("normal");
  595. }
  596.  
  597. return false;
  598. });
  599. });
  600. }
  601. },
  602.  
  603. lightBox: function () {
  604. var $lightboxImageEl = $('[data-lightbox="image"]'),
  605. $lightboxGalleryEl = $('[data-lightbox="gallery"]'),
  606. $lightboxIframeEl = $('[data-lightbox="iframe"]'),
  607. $lightboxAjaxEl = $('[data-lightbox="ajax"]'),
  608. $lightboxAjaxGalleryEl = $('[data-lightbox="ajax-gallery"]');
  609.  
  610. if ($lightboxImageEl.length > 0) {
  611. $lightboxImageEl.magnificPopup({
  612. type: 'image',
  613. closeOnContentClick: true,
  614. closeBtnInside: false,
  615. fixedContentPos: true,
  616. mainClass: 'mfp-no-margins mfp-fade', // class to remove default margin from left and right side
  617. image: {
  618. verticalFit: true
  619. }
  620. });
  621. }
  622.  
  623. if ($lightboxGalleryEl.length > 0) {
  624. $lightboxGalleryEl.each(function () {
  625. var element = $(this);
  626.  
  627. if (element.find('a[data-lightbox="gallery-item"]').parent('.clone').hasClass('clone')) {
  628. element.find('a[data-lightbox="gallery-item"]').parent('.clone').find('a[data-lightbox="gallery-item"]').attr('data-lightbox', '');
  629. }
  630.  
  631. element.magnificPopup({
  632. delegate: 'a[data-lightbox="gallery-item"]',
  633. type: 'image',
  634. closeOnContentClick: true,
  635. closeBtnInside: false,
  636. fixedContentPos: true,
  637. mainClass: 'mfp-no-margins mfp-fade', // class to remove default margin from left and right side
  638. image: {
  639. verticalFit: true
  640. },
  641. gallery: {
  642. enabled: true,
  643. navigateByImgClick: true,
  644. preload: [0, 1] // Will preload 0 - before current, and 1 after the current image
  645. }
  646. });
  647. });
  648. }
  649.  
  650. if ($lightboxIframeEl.length > 0) {
  651. $lightboxIframeEl.magnificPopup({
  652. disableOn: 600,
  653. type: 'iframe',
  654. removalDelay: 160,
  655. preloader: false,
  656. fixedContentPos: false
  657. });
  658. }
  659.  
  660. if ($lightboxAjaxEl.length > 0) {
  661. $lightboxAjaxEl.magnificPopup({
  662. type: 'ajax',
  663. closeBtnInside: false,
  664. callbacks: {
  665. ajaxContentAdded: function (mfpResponse) {
  666. $body.trigger("lightBoxAjaxAdded");
  667. },
  668. open: function () {
  669. $body.addClass('ohidden');
  670. },
  671. close: function () {
  672. $body.removeClass('ohidden');
  673. }
  674. }
  675. });
  676. }
  677.  
  678. if ($lightboxAjaxGalleryEl.length > 0) {
  679. $lightboxAjaxGalleryEl.magnificPopup({
  680. delegate: 'a[data-lightbox="ajax-gallery-item"]',
  681. type: 'ajax',
  682. closeBtnInside: false,
  683. gallery: {
  684. enabled: true,
  685. preload: 0,
  686. navigateByImgClick: false
  687. },
  688. callbacks: {
  689. ajaxContentAdded: function (mfpResponse) {
  690. $body.trigger("lightBoxAjaxAdded");
  691. },
  692. open: function () {
  693. $body.addClass('ohidden');
  694. },
  695. close: function () {
  696. $body.removeClass('ohidden');
  697. }
  698. }
  699. });
  700. }
  701. },
  702. loadFlexSlider: function () {
  703. $('.fslider').addClass('preloader2');
  704. var $flexSliderEl = $('.fslider').find('.flexslider');
  705. if ($flexSliderEl.length > 0) {
  706. $flexSliderEl.each(function () {
  707. var $flexsSlider = $(this),
  708. flexsAnimation = $flexsSlider.parent('.fslider').attr('data-animation'),
  709. flexsEasing = $flexsSlider.parent('.fslider').attr('data-easing'),
  710. flexsDirection = $flexsSlider.parent('.fslider').attr('data-direction'),
  711. flexsSlideshow = $flexsSlider.parent('.fslider').attr('data-slideshow'),
  712. flexsPause = $flexsSlider.parent('.fslider').attr('data-pause'),
  713. flexsSpeed = $flexsSlider.parent('.fslider').attr('data-speed'),
  714. flexsVideo = $flexsSlider.parent('.fslider').attr('data-video'),
  715. flexsPagi = $flexsSlider.parent('.fslider').attr('data-pagi'),
  716. flexsArrows = $flexsSlider.parent('.fslider').attr('data-arrows'),
  717. flexsThumbs = $flexsSlider.parent('.fslider').attr('data-thumbs'),
  718. flexsHover = $flexsSlider.parent('.fslider').attr('data-hover'),
  719. flexsSheight = true,
  720. flexsUseCSS = false;
  721.  
  722. if (!flexsAnimation) {
  723. flexsAnimation = 'slide';
  724. }
  725. if (!flexsEasing || flexsEasing == 'swing') {
  726. flexsEasing = 'swing';
  727. flexsUseCSS = true;
  728. }
  729. if (!flexsDirection) {
  730. flexsDirection = 'horizontal';
  731. }
  732. if (!flexsSlideshow) {
  733. flexsSlideshow = true;
  734. } else {
  735. flexsSlideshow = false;
  736. }
  737. if (!flexsPause) {
  738. flexsPause = 5000;
  739. }
  740. if (!flexsSpeed) {
  741. flexsSpeed = 600;
  742. }
  743. if (!flexsVideo) {
  744. flexsVideo = false;
  745. }
  746. if (flexsDirection == 'vertical') {
  747. flexsSheight = false;
  748. }
  749. if (flexsPagi == 'false') {
  750. flexsPagi = false;
  751. } else {
  752. flexsPagi = true;
  753. }
  754. if (flexsThumbs == 'true') {
  755. flexsPagi = 'thumbnails';
  756. } else {
  757. flexsPagi = flexsPagi;
  758. }
  759. if (flexsArrows == 'false') {
  760. flexsArrows = false;
  761. } else {
  762. flexsArrows = true;
  763. }
  764. if (flexsHover == 'false') {
  765. flexsHover = false;
  766. } else {
  767. flexsHover = true;
  768. }
  769.  
  770. $flexsSlider.flexslider({
  771. selector: ".slider-wrap > .slide",
  772. animation: flexsAnimation,
  773. easing: flexsEasing,
  774. direction: flexsDirection,
  775. slideshow: flexsSlideshow,
  776. slideshowSpeed: Number(flexsPause),
  777. animationSpeed: Number(flexsSpeed),
  778. pauseOnHover: flexsHover,
  779. video: flexsVideo,
  780. controlNav: flexsPagi,
  781. directionNav: flexsArrows,
  782. smoothHeight: flexsSheight,
  783. useCSS: flexsUseCSS,
  784. start: function (slider) {
  785. KLEO.main.animations();
  786.  
  787. slider.parent().removeClass('preloader2');
  788. var t = setTimeout(function () {
  789. $('#portfolio.portfolio-masonry,#portfolio.portfolio-full,#posts.post-masonry').isotope('layout');
  790. }, 1200);
  791. KLEO.main.lightBox();
  792. $('.flex-prev').html('<i class="icon-angle-left"></i>');
  793. $('.flex-next').html('<i class="icon-angle-right"></i>');
  794. }
  795. });
  796. });
  797. }
  798. },
  799.  
  800. resizeVideos: function () {
  801. if ($().fitVids) {
  802. $("#content, .entry-content, .activity-inner").fitVids({
  803. ignore: '.no-fv'
  804. });
  805. }
  806. },
  807.  
  808. toggleAjaxSearch: function () {
  809. $('.search-trigger').click(function () {
  810. if ($('#ajax_search_container').hasClass('searchHidden')) {
  811. $('#ajax_search_container').removeClass('searchHidden').addClass('show_search_pop');
  812. $(this).next().find(".ajax_s").focus();
  813. }
  814. return false;
  815. });
  816. },
  817.  
  818. doAjaxSearch: function (options) {
  819. var defaults = {
  820. delay: 350, //delay in ms for typing
  821. minChars: 3, //no. of characters after we start the search
  822. scope: 'body'
  823. };
  824.  
  825. this.options = $.extend({}, defaults, options);
  826. this.scope = $(this.options.scope);
  827. this.body = $("body");
  828. this.timer = false;
  829. this.doingSearch = false;
  830. this.lastVal = "";
  831. this.request = "";
  832. this.bind_ev = function () {
  833. this.scope.on('keyup', '.ajax_s', $.proxy(this.test_search, this));
  834. this.body.on('mousedown', $.proxy(this.hide_search, this));
  835.  
  836. /* Show the results on input click */
  837. $(".ajax_s").on('click focus', function () {
  838.  
  839. if ($(this).hasClass('ui-autocomplete-input') === true) {
  840. return false;
  841. }
  842.  
  843. if ($('body').hasClass('device-xs') === true) {
  844. return false;
  845. }
  846.  
  847. var res = $(this).closest(".kleo-search-form").find(".kleo_ajax_results");
  848.  
  849. if (!res.is(":empty") && $.trim($(this).val()) != '') {
  850. res.slideDown('slow');
  851. }
  852. res.css("opacity", "1");
  853. $("body").addClass("header-submenu-open");
  854. });
  855.  
  856. /* Hide the results on outside click */
  857. this.body.on('mousedown', function (e) {
  858. var element = $(e.target);
  859. if (!element.is('.kleo_ajax_results, .ajax_s') && element.closest('.kleo_ajax_results').length == 0) {
  860. $(".kleo-search-form .kleo_ajax_results").css("opacity", "0.5").slideUp('slow');
  861. }
  862. });
  863.  
  864. };
  865. this.test_search = function (e) {
  866. clearTimeout(this.timer);
  867. if ($.trim(e.currentTarget.value) == '' || $.trim(e.currentTarget.value.length) >= this.options.minChars) {
  868. this.timer = setTimeout($.proxy(this.search, this, e), this.options.delay);
  869. }
  870. };
  871. this.hide_search = function (e) {
  872. var element = $(e.target);
  873. if (!element.is('#ajax_search_container') && element.parents('#ajax_search_container').length == 0) {
  874. $('#ajax_search_container').addClass('searchHidden').removeClass('show_search_pop');
  875. }
  876. };
  877. this.search = function (e) {
  878.  
  879. var element = e.currentTarget;
  880.  
  881. if ($(element).hasClass('ui-autocomplete-input') === true) {
  882. return false;
  883. }
  884.  
  885. if ($('body').hasClass('device-xs') === true) {
  886. return false;
  887. }
  888.  
  889. var $this = this,
  890. form = $(element).closest("form"),
  891. results = form.find(".kleo_ajax_results"),
  892. loading = form.children("button"),
  893. values = form.serialize();
  894.  
  895. values += "&action=kleo_ajax_search";
  896.  
  897. if (form.data('context')) {
  898. values += "&context=" + form.data('context');
  899. }
  900.  
  901. //if it is not ajax search, bail out
  902. if (!results.length) {
  903. return;
  904. }
  905.  
  906. //if it is another search in place
  907. if ($this.doingSearch === true) {
  908. //return;
  909. this.request.abort();
  910. }
  911.  
  912. //if current valuer matches last search value
  913. if (this.lastVal == $.trim(element.value)) {
  914. results.slideDown();
  915. return;
  916. }
  917.  
  918. //if current value is blank
  919. if ($.trim(element.value) == '') {
  920. results.slideUp('fast');
  921. return;
  922. }
  923.  
  924.  
  925. this.lastVal = $.trim(element.value);
  926.  
  927. this.request = $.ajax({
  928. url: KLEO.ajaxurl,
  929. type: "POST",
  930. data: values,
  931. beforeSend: function () {
  932. loading.addClass('animate-spin');
  933. $this.doingSearch = true;
  934. },
  935. success: function (response) {
  936. if (response == 0) {
  937. response = "";
  938. }
  939. ;
  940. if (results.is(":empty")) {
  941. results.hide().html(response).slideDown('slow');
  942. } else {
  943. results.html(response).slideDown('slow');
  944. }
  945. },
  946. complete: function () {
  947. loading.removeClass('animate-spin');
  948. $this.doingSearch = false;
  949. clearTimeout($this.timer);
  950. }
  951. });
  952. };
  953.  
  954. //do search...
  955. this.bind_ev();
  956. },
  957. applyRetina: function () {
  958. if (!KLEO.isHighDensity()) {
  959. return;
  960. }
  961.  
  962. $('[data-retina]').each(function () {
  963. if ($(this).data("retina") != '') {
  964. $(this).find('img').attr('src', $(this).data('retina'));
  965. }
  966. });
  967.  
  968. },
  969. ajaxLogin: function () {
  970.  
  971. $("#kleo-login-modal.mfp-hide .username").removeAttr("name");
  972.  
  973. if ($("#kleo-login-modal .kleo-login-wrap").length) {
  974.  
  975. $('.show-login, .kleo-show-login, .bp-menu.bp-login-nav a, .must-log-in > a').magnificPopup({
  976. items: {
  977. src: '#kleo-login-modal',
  978. type: 'inline',
  979. focus: '.username'
  980. },
  981. preloader: false,
  982. mainClass: 'kleo-mfp-zoom',
  983.  
  984. // When element is focused, some mobile browsers in some cases zoom in
  985. // It looks not nice, so we disable it:
  986. callbacks: {
  987. beforeOpen: function () {
  988. $("#kleo-login-modal .username").attr("name", "log");
  989.  
  990. if ($(window).width() < 700) {
  991. this.st.focus = false;
  992. } else {
  993. this.st.focus = '.username';
  994. }
  995. },
  996. open: function() {
  997.  
  998. }
  999.  
  1000. }
  1001. });
  1002.  
  1003. } else {
  1004. $('.show-login, .kleo-show-login, .bp-menu.bp-login-nav a, .must-log-in > a').on('click', function () {
  1005. $.magnificPopup.close();
  1006. })
  1007.  
  1008. }
  1009.  
  1010. $('form.sq-login-form').on('submit', function (e) {
  1011.  
  1012. var theForm = $(this);
  1013. var resultEl = theForm.find(".kleo-login-result");
  1014.  
  1015. var values = $(this).serialize();
  1016. values += "&action=kleoajaxlogin";
  1017.  
  1018.  
  1019. resultEl.show().html(KLEO.loadingMessage);
  1020. $.ajax({
  1021. type: 'POST',
  1022. url: KLEO.loginUrl,
  1023. data: values,
  1024. success: function (data) {
  1025. if (KLEO.main.isJsonString(data)) {
  1026. data = JSON.parse(data);
  1027. }
  1028.  
  1029. resultEl.html(data.message);
  1030. if (data.loggedin == true) {
  1031. if (data.redirecturl == null || data.redirecturl == false) {
  1032. document.location.reload();
  1033. }
  1034. else {
  1035. document.location.href = data.redirecturl;
  1036. }
  1037. }
  1038. KLEO.main.ajaxLostPass();
  1039. },
  1040. complete: function () {
  1041.  
  1042. },
  1043. error: function () {
  1044. // theForm.off('submit');
  1045. // theForm.submit();
  1046. }
  1047. });
  1048. e.preventDefault();
  1049. })
  1050. },
  1051.  
  1052. isJsonString: function(str) {
  1053. try {
  1054. JSON.parse(str);
  1055. } catch (e) {
  1056. return false;
  1057. }
  1058. return true;
  1059. },
  1060.  
  1061. ajaxLostPass: function () {
  1062.  
  1063. /* Lost Pass modal */
  1064. $('.show-lostpass, span.wrong-response a[href*=lostpassword]').magnificPopup({
  1065. items: {
  1066. src: '#kleo-lostpass-modal',
  1067. type: 'inline',
  1068. focus: 'input'
  1069. },
  1070. preloader: false,
  1071. mainClass: 'kleo-mfp-zoom',
  1072.  
  1073. // When elemened is focused, some mobile browsers in some cases zoom in
  1074. // It looks not nice, so we disable it:
  1075. callbacks: {
  1076. beforeOpen: function () {
  1077. if ($(window).width() < 700) {
  1078. this.st.focus = false;
  1079. } else {
  1080. this.st.focus = '#forgot-email';
  1081. }
  1082. }
  1083. }
  1084. });
  1085.  
  1086. $(".sq-forgot-form").on("submit", function () {
  1087.  
  1088. var theForm = $(this);
  1089. var resultEl = theForm.find(".kleo-lost-result");
  1090.  
  1091. resultEl.show().html(KLEO.loadingMessage);
  1092. $.ajax({
  1093. url: KLEO.ajaxurl,
  1094. type: 'POST',
  1095. data: {
  1096. action: 'kleo_lost_password',
  1097. user_login: $("#forgot-email").val(),
  1098. security_lost_pass: $("#security-lost-pass").val()
  1099. },
  1100. success: function (data) {
  1101. resultEl.html(data);
  1102. },
  1103. error: function () {
  1104. resultEl.html(KLEO.errorMessage).css('color', 'red');
  1105. }
  1106.  
  1107. });
  1108. return false;
  1109. });
  1110. },
  1111. kleoIsotope: function () {
  1112. $('.row-masonry-enabled').isotope({
  1113. // options
  1114. itemSelector: '.vc_column_container',
  1115. });
  1116. },
  1117. charts: function () {
  1118. if (typeof google !== 'undefined' && $.isFunction(google.setOnLoadCallback)) {
  1119. google.charts.setOnLoadCallback(function () {
  1120. KLEO.main.kleoIsotope();
  1121. });
  1122. }
  1123. }
  1124.  
  1125. };
  1126.  
  1127. /* -----------------------------------------
  1128. 2. Header functions
  1129. ----------------------------------------- */
  1130. KLEO.header = {
  1131. init: function () {
  1132. KLEO.header.adminBarScrollClass();
  1133.  
  1134. // Sidemenu trigger
  1135. $('.sidemenu-trigger').on("click touchstart",function () {
  1136.  
  1137. // close the dropdowns
  1138. $(".menu-list .active .submenu").stop(true, true).slideUp(200);
  1139. $(".menu-list li").removeClass("open");
  1140.  
  1141. /* Mobile and tablet specific logic for saved sidemenu state */
  1142. if($('body').hasClass('force-close-sidemenu')) {
  1143. $('body').removeClass('force-close-sidemenu');
  1144.  
  1145. if ($('body').hasClass("device-md") || $('body').hasClass("device-lg")) {
  1146. $('body').toggleClass('sidemenu-is-open');
  1147. }
  1148. } else {
  1149. $('body').toggleClass('sidemenu-is-open');
  1150. }
  1151.  
  1152. $("body").trigger( "sidemenu-moving-start" );
  1153. setTimeout(function () {
  1154. KLEO.bp.bpIsotope();
  1155. KLEO.main.kleoIsotope();
  1156. //trigger the sidemenu-open event
  1157. $("body").trigger( "sidemenu-moving" );
  1158. }, 300);
  1159.  
  1160. /* Remember left sidemenu open state */
  1161. if ( $('body').hasClass("device-md") || $('body').hasClass("device-lg")) {
  1162. if ($('body').hasClass('sidemenu-is-open')) {
  1163. KLEO.main.setCookie('kleo-side', 'open', '/', 30);
  1164. } else {
  1165. KLEO.main.setCookie('kleo-side', '', '/', -1);
  1166. }
  1167. }
  1168.  
  1169.  
  1170. return false;
  1171. });
  1172.  
  1173. // Secondmenu trigger
  1174. $('.second-menu-trigger').on("click touchstart",function () {
  1175. $('body').toggleClass('second-menu-is-open');
  1176. return false;
  1177. });
  1178.  
  1179. // SideMenu list dropdown
  1180. $('.menu-list .has-submenu > .menu-arrow').click(function () {
  1181. var el = $(this);
  1182.  
  1183. if ($('body').hasClass('device-xxs') || $('body').hasClass('device-xs')) {
  1184. //for mobile
  1185. } else if ($('body').hasClass('device-sm')) {
  1186.  
  1187. // for Tablet
  1188. if (! $('body').hasClass('sidemenu-is-open')) {
  1189. $('body').addClass('sidemenu-is-open');
  1190. }
  1191.  
  1192. } else {
  1193.  
  1194. // for Desktop
  1195. if ($('body').hasClass('sidemenu-is-open')) {
  1196. $('body').removeClass('sidemenu-is-open');
  1197. }
  1198. }
  1199. });
  1200.  
  1201. // Search expand on tablet
  1202.  
  1203. $('#main-search').on("focus", function () {
  1204. if ($('body').hasClass("device-sm")) {
  1205. $("#searchform").addClass("expand");
  1206. }
  1207. }).on("blur", function () {
  1208. if ($('body').hasClass("device-sm")) {
  1209. $("#searchform").removeClass("expand");
  1210. }
  1211. });
  1212.  
  1213. /* Open menu if submenu item is active */
  1214. if ($(".menu-list .current_page_item").parents(".current-menu-ancestor").length) {
  1215. $(".menu-list .current_page_item").parents(".current-menu-ancestor").addClass("open");
  1216. }
  1217.  
  1218. /* Close sidemenu and second menu when clicking outside only on mobile XS */
  1219. $body.on('click', function(event) {
  1220. if ( $body.hasClass('device-xs') || $body.hasClass('device-xxs') ) {
  1221.  
  1222. if ($(event.target).closest('.second-menu').length === 0) {
  1223. $("body").removeClass("second-menu-is-open");
  1224. }
  1225. if ($(event.target).closest('#sidemenu-wrapper').length === 0) {
  1226. $("body").removeClass("sidemenu-is-open");
  1227. }
  1228. }
  1229. });
  1230.  
  1231. /* Close the opened submenus when clicking outside */
  1232. $body.on('click', function (e) {
  1233. var element = $(e.target);
  1234. if (!element.is('.submenu') && element.closest('.submenu').length === 0) {
  1235.  
  1236. $(".basic-menu .has-submenu.open").removeClass("open");
  1237.  
  1238. if ( !element.is('.ajax_s') ) {
  1239. $("body").removeClass("header-submenu-open");
  1240. }
  1241. }
  1242.  
  1243. });
  1244.  
  1245. // dropdown functionality for specific class
  1246. $body.on('click', ".open-submenu", function (e) {
  1247.  
  1248. KLEO.header.menuDropdown(this);
  1249. e.stopImmediatePropagation();
  1250.  
  1251. return false;
  1252. });
  1253.  
  1254. // header icons dropdown only when click action is set on theme options - header
  1255. $body.on('click', ".click-menu .header-icons .has-submenu > a", function (e) {
  1256.  
  1257. KLEO.header.menuDropdown(this);
  1258. e.stopImmediatePropagation();
  1259.  
  1260. return false;
  1261. });
  1262.  
  1263. //general dropdown functionality
  1264. $body.on('click', ".has-submenu .menu-arrow, .has-submenu > a[href='#']", function (e) {
  1265.  
  1266. //enable only on mobile devices or on click menus
  1267. if ( ! $(this).closest("li").parent(".basic-menu").length || $(this).closest('.click-menu').length || KLEO.isMobile.tabletWidth() || KLEO.isMobile.any() ) {
  1268. KLEO.header.menuDropdown(this);
  1269. }
  1270. e.stopImmediatePropagation();
  1271.  
  1272. return false;
  1273. });
  1274.  
  1275. KLEO.header.onScroll();
  1276. },
  1277.  
  1278. onScroll: function () {
  1279.  
  1280. $window.on('scroll touchmove', function () {
  1281.  
  1282. KLEO.header.adminBarScrollClass();
  1283. });
  1284.  
  1285. },
  1286.  
  1287. onLoad: function () {
  1288.  
  1289. },
  1290.  
  1291. onResize: function () {
  1292.  
  1293. /* Remove sidemenu-is-open class if it was set by cookie */
  1294. /*if( $('body').hasClass('sidemenu-saved') && ! $('body').hasClass('device-lg') && ! $('body').hasClass('device-md') ) {
  1295. $('body').removeClass('sidemenu-is-open');
  1296. }*/
  1297.  
  1298. },
  1299.  
  1300. menuDropdown: function(e) {
  1301. var hasSubmenuParents = $(e).parents(".has-submenu").length;
  1302. var parent = $(e).closest(".has-submenu");
  1303. if(hasSubmenuParents > 1 ) {
  1304. if(parent.hasClass('open')) {
  1305. parent.siblings(".has-submenu").removeClass("open");
  1306. parent.removeClass('open');
  1307. $("body").removeClass("header-submenu-open");
  1308. } else {
  1309. parent.addClass('open');
  1310. $("body").addClass("header-submenu-open");
  1311. }
  1312. } else {
  1313. if(parent.hasClass('open')) {
  1314. parent.removeClass('open');
  1315. $(".basic-menu .has-submenu").removeClass("open");
  1316. $("body").removeClass("header-submenu-open");
  1317. } else {
  1318. parent.removeClass('open');
  1319. $(".basic-menu .has-submenu").removeClass("open");
  1320. parent.addClass('open');
  1321. $("body").addClass("header-submenu-open");
  1322. }
  1323. }
  1324. },
  1325. /* Admin bar fix on small-mobile & mobile */
  1326. /* Add a class when header is scrolled just for max window width 600px */
  1327. adminBarScrollClass: function () {
  1328. if ($(window).width() < 601) {
  1329. $('html').toggleClass('header-scrolled', $(document).scrollTop() > 0);
  1330. } else {
  1331. $('html').removeClass('header-scrolled');
  1332. }
  1333. }
  1334. };
  1335.  
  1336. /* -----------------------------------------
  1337. 3. BuddyPress functions
  1338. ----------------------------------------- */
  1339. KLEO.bp = {
  1340. init: function () {
  1341.  
  1342. //Enable masonry isotope
  1343. $("body").on('gridLoaded', function () {
  1344. KLEO.bp.bpIsotope();
  1345. });
  1346.  
  1347. // Adjust videos on Activity posted
  1348. $("body").on('bpActivityLoaded', function () {
  1349. KLEO.main.resizeVideos();
  1350. });
  1351.  
  1352. if ($(".kleo-notifications-nav").length) {
  1353. $("#header").on("click", ".kleo-notifications-nav a.mark-as-read", function (e) {
  1354. KLEO.bp.notificationsRead($(this));
  1355. e.preventDefault();
  1356. });
  1357. }
  1358. if ($(".kleo-notifications-nav").length || $(".kleo-messages-nav").length) {
  1359. if (KLEO.hasOwnProperty('bpAjaxRefresh') && KLEO.bpAjaxRefresh != '0') {
  1360. KLEO.bp.ajaxCalls();
  1361. }
  1362. }
  1363. },
  1364. bpIsotope: function () {
  1365. $(".main-content #members-list, .main-content #member-list, .main-content .groups-dir-list #groups-list, .main-content .groups #groups-list").isotope({
  1366. //options
  1367. itemSelector: "li"
  1368. })
  1369. },
  1370. ajaxCalls: function () {
  1371.  
  1372. if ($body.hasClass('customize-preview')) {
  1373. return false;
  1374. }
  1375.  
  1376. KLEO.bp.rehreshID = setInterval(function () {
  1377.  
  1378. var values = 'action=kleo_bp_ajax_call';
  1379. if ($(".kleo-notifications-nav").length) {
  1380. values += '&current_notifications=' + $(".kleo-notifications b").first().text();
  1381. }
  1382. if ($(".kleo-messages-nav").length) {
  1383. values += '&current_messages=' + $(".kleo-messages-nav b").first().text();
  1384. }
  1385.  
  1386. $.ajax({
  1387. url: KLEO.ajaxurl,
  1388. type: "GET",
  1389. dataType: "json",
  1390. data: values,
  1391. success: function (response) {
  1392. if (response === null) {
  1393. return;
  1394. }
  1395. if (response.statusNotif == 'success') {
  1396. if (response.countNotif == '0') {
  1397. $('.kleo-notifications-nav .footer-item').hide();
  1398. $(".kleo-notifications-nav b").removeClass("new-alert").addClass("no-alert");
  1399. $(".kleo-notifications-nav .submenu").removeClass("has-notif");
  1400. } else {
  1401. $('.kleo-notifications-nav').addClass("kleo-loading");
  1402. $(".kleo-notifications-nav b").removeClass("no-alert").addClass("new-alert");
  1403. $(".kleo-notifications-nav .submenu").addClass("has-notif");
  1404. $('.kleo-notifications-nav .footer-item').show();
  1405. }
  1406.  
  1407. $(".kleo-notifications-nav b").text(response.countNotif);
  1408. $('.kleo-notifications-nav .kleo-submenu-item').remove();
  1409. $('.kleo-notifications-nav .submenu').prepend(response.dataNotif);
  1410. } else {
  1411. //
  1412. }
  1413.  
  1414. if (response.statusMessages == 'success') {
  1415. if (response.countMessagew == '0') {
  1416. $('.kleo-messages-nav .footer-item').hide();
  1417. $(".kleo-messages-nav b").removeClass("new-alert").addClass("no-alert");
  1418. $(".kleo-messages-nav .submenu").removeClass("has-notif");
  1419. } else {
  1420. $('.kleo-messages-nav').addClass("kleo-loading");
  1421. $(".kleo-messages-nav b").removeClass("no-alert").addClass("new-alert");
  1422. $(".kleo-messages-nav .submenu").addClass("has-notif");
  1423. $('.kleo-messages-nav .footer-item').show();
  1424. }
  1425.  
  1426. $(".kleo-messages-nav b").text(response.countMessages);
  1427. $('.kleo-messages-nav .kleo-submenu-item').remove();
  1428. $('.kleo-messages-nav .submenu').prepend(response.dataMessages);
  1429. } else {
  1430. //
  1431. }
  1432.  
  1433. }
  1434. });
  1435.  
  1436. }, KLEO.bpAjaxRefresh);
  1437.  
  1438.  
  1439. },
  1440.  
  1441. notificationsRead: function (e) {
  1442.  
  1443. var values = {action: "kleo_bp_notification_mark_read"};
  1444.  
  1445. $.ajax({
  1446. url: KLEO.ajaxurl,
  1447. type: "GET",
  1448. dataType: "json",
  1449. data: values,
  1450. beforeSend: function () {
  1451. $(".kleo-notifications-nav").addClass("kleo-loading");
  1452. },
  1453. success: function (response) {
  1454. if (response.status == 'success') {
  1455. if (response.count == '0') {
  1456. $('.kleo-notifications-nav .kleo-submenu-item').remove();
  1457. $('.kleo-notifications-nav .submenu').prepend(response.empty);
  1458. $('.kleo-notifications-nav .footer-item').hide();
  1459. $(".kleo-notifications-nav b").removeClass("new-alert").addClass("no-alert");
  1460. $(".kleo-notifications-nav .submenu").removeClass("has-notif");
  1461. } else {
  1462. $(".kleo-notifications-nav b").removeClass("no-alert").addClass("new-alert");
  1463. $(".kleo-notifications-nav .submenu").addClass("has-notif");
  1464. $('.kleo-notifications-nav .footer-item').show();
  1465. }
  1466. $(".kleo-notifications-nav b").text(response.count);
  1467. } else {
  1468. //
  1469. }
  1470.  
  1471. },
  1472. complete: function () {
  1473. $(".kleo-notifications-nav").removeClass("kleo-loading");
  1474. }
  1475. });
  1476.  
  1477. }
  1478. }
  1479.  
  1480. /* Some extra useful functions */
  1481. $.fn.inlineStyle = function (prop) {
  1482. return this.prop("style")[$.camelCase(prop)];
  1483. };
  1484. $.fn.doOnce = function (func) {
  1485. this.length && func.apply(this);
  1486. return this;
  1487. };
  1488.  
  1489.  
  1490. var $window = $(window),
  1491. $body = $('body'),
  1492. $wrapper = $('#page-wrapper');
  1493.  
  1494.  
  1495. $(document).ready(function () {
  1496. KLEO.main.init();
  1497. KLEO.header.init();
  1498. KLEO.bp.init();
  1499. });
  1500.  
  1501. $window.load(function () {
  1502. KLEO.main.onLoad();
  1503. KLEO.header.onLoad();
  1504. /* Isotope */
  1505. KLEO.bp.bpIsotope();
  1506. });
  1507.  
  1508. $window.on('resize', function () {
  1509. KLEO.main.onResize();
  1510. KLEO.header.onResize();
  1511. });
  1512.  
  1513. })(jQuery);
  1514.  
  1515.  
  1516. /* jQuery.flexMenu 1.2
  1517. https://github.com/352Media/flexMenu
  1518. Description: If a list is too long for all items to fit on one line, display a popup menu instead.
  1519. Dependencies: jQuery, Modernizr (optional). Without Modernizr, the menu can only be shown on click (not hover). */
  1520.  
  1521. (function ($) {
  1522. $.fn.flexMenu = function (options) {
  1523.  
  1524. var checkFlexObject,
  1525. s = $.extend({
  1526. 'threshold' : 2, // [integer] If there are this many items or fewer in the list, we will not display a "View More" link and will instead let the list break to the next line. This is useful in cases where adding a "view more" link would actually cause more things to break to the next line.
  1527. 'cutoff' : 2, // [integer] If there is space for this many or fewer items outside our "more" popup, just move everything into the more menu. In that case, also use linkTextAll and linkTitleAll instead of linkText and linkTitle. To disable this feature, just set this value to 0.
  1528. 'linkText' : '&#xe8c0;', // [string] What text should we display on the "view more" link?
  1529. 'linkTitle' : '&#xe8c0;', // [string] What should the title of the "view more" button be?
  1530. 'linkTextAll' : '&#xe8c0;', // [string] If we hit the cutoff, what text should we display on the "view more" link?
  1531. 'linkTitleAll' : 'Open/Close Menu', // [string] If we hit the cutoff, what should the title of the "view more" button be?
  1532. 'showOnHover' : true, // [boolean] Should we we show the menu on hover? If not, we'll require a click. If we're on a touch device - or if Modernizr is not available - we'll ignore this setting and only show the menu on click. The reason for this is that touch devices emulate hover events in unpredictable ways, causing some taps to do nothing.
  1533. 'popupAbsolute' : true, // [boolean] Should we absolutely position the popup? Usually this is a good idea. That way, the popup can appear over other content and spill outside a parent that has overflow: hidden set. If you want to do something different from this in CSS, just set this option to false.
  1534. 'undo' : false // [boolean] Move the list items back to where they were before, and remove the "View More" link.
  1535. }, options);
  1536. this.options = s; // Set options on object
  1537. checkFlexObject = $.inArray(this, flexObjects); // Checks if this object is already in the flexObjects array
  1538. if (checkFlexObject >= 0) {
  1539. flexObjects.splice(checkFlexObject, 1); // Remove this object if found
  1540. } else {
  1541. flexObjects.push(this); // Add this object to the flexObjects array
  1542. }
  1543. return this.each(function () {
  1544. var $this = $(this),
  1545. $items = $this.find('> li'),
  1546. $self = $this,
  1547. $firstItem = $items.first(),
  1548. $lastItem = $items.last(),
  1549. numItems = $this.find('li').length,
  1550. firstItemTop = Math.floor($firstItem.offset().top),
  1551. firstItemHeight = Math.floor($firstItem.outerHeight(true)),
  1552. $lastChild,
  1553. keepLooking,
  1554. $moreItem,
  1555. $moreLink,
  1556. numToRemove,
  1557. allInPopup = false,
  1558. $menu,
  1559. i;
  1560. function needsMenu($itemOfInterest) {
  1561. var result = (Math.ceil($itemOfInterest.offset().top) >= (firstItemTop + firstItemHeight)) ? true : false;
  1562. // Values may be calculated from em and give us something other than round numbers. Browsers may round these inconsistently. So, let's round numbers to make it easier to trigger flexMenu.
  1563. return result;
  1564. }
  1565.  
  1566. if (needsMenu($lastItem) && numItems > s.threshold && !s.undo && $this.is(':visible') && ! KLEO.isMobile.tabletWidth() ) {
  1567. var $popup = $('<ul class="flexMenu-popup submenu" style="' + ((s.popupAbsolute) ? ' position: absolute;' : '') + '"></ul>'),
  1568. // Move all list items after the first to this new popup ul
  1569. firstItemOffset = $firstItem.offset().top;
  1570. for (i = numItems; i > 1; i--) {
  1571. // Find all of the list items that have been pushed below the first item. Put those items into the popup menu. Put one additional item into the popup menu to cover situations where the last item is shorter than the "more" text.
  1572. $lastChild = $this.find('> li:last-child');
  1573. keepLooking = (needsMenu($lastChild));
  1574. $lastChild.appendTo($popup);
  1575. // If there only a few items left in the navigation bar, move them all to the popup menu.
  1576. if ((i - 1) <= s.cutoff) { // We've removed the ith item, so i - 1 gives us the number of items remaining.
  1577. $($this.children().get().reverse()).appendTo($popup);
  1578. allInPopup = true;
  1579. break;
  1580. }
  1581. if (!keepLooking) {
  1582. break;
  1583. }
  1584. }
  1585. if (allInPopup) {
  1586. $this.append('<li class="more-wrapper flexMenu-allInPopup has-submenu"><a class="more" href="#" title="' + s.linkTitleAll + '">' + s.linkTextAll + '</a></li>');
  1587. } else {
  1588. $this.append('<li class="more-wrapper has-submenu"><a href="#" class="more" title="' + s.linkTitle + '">' + s.linkText + '</a></li>');
  1589. }
  1590. $moreItem = $this.find('> li.more-wrapper');
  1591. /// Check to see whether the more link has been pushed down. This might happen if the link immediately before it is especially wide.
  1592. if (needsMenu($moreItem)) {
  1593. $this.find('> li:nth-last-child(2)').appendTo($popup);
  1594. }
  1595. // Our popup menu is currently in reverse order. Let's fix that.
  1596. $popup.children().each(function (i, li) {
  1597. $popup.prepend(li);
  1598. });
  1599. $moreItem.append($popup);
  1600. $moreLink = $this.find('> li.more-wrapper > a');
  1601. /*$moreLink.click(function (e) {
  1602. // Collapsing any other open flexMenu
  1603. collapseAllExcept($moreItem);
  1604. //Open and Set active the one being interacted with.
  1605. $popup.toggle();
  1606. $moreItem.toggleClass('active');
  1607. e.preventDefault();
  1608. });*/
  1609. if (s.showOnHover && (typeof Modernizr !== 'undefined') && !Modernizr.touch) { // If requireClick is false AND touch is unsupported, then show the menu on hover. If Modernizr is not available, assume that touch is unsupported. Through the magic of lazy evaluation, we can check for Modernizr and start using it in the same if statement. Reversing the order of these variables would produce an error.
  1610. $moreItem.hover(
  1611. function () {
  1612. $popup.show();
  1613. $(this).addClass('active');
  1614. },
  1615. function () {
  1616. $popup.hide();
  1617. $(this).removeClass('active');
  1618. });
  1619. }
  1620. } else if (s.undo && $this.find('ul.flexMenu-popup')) {
  1621. $menu = $this.find('ul.flexMenu-popup');
  1622. numToRemove = $menu.find('li').length;
  1623. for (i = 1; i <= numToRemove; i++) {
  1624. $menu.find('> li:first-child').appendTo($this);
  1625. }
  1626. $menu.remove();
  1627. $this.find('> li.more-wrapper').remove();
  1628. }
  1629. });
  1630. };
  1631.  
  1632. $(document).ready(function(){
  1633. if ( $('.header-menu > li').length > 1 ) {
  1634. $('.header-menu').flexMenu({
  1635. /*showOnHover: function () {
  1636. return !KLEO.isMobile.tabletWidth();
  1637. },*/
  1638. showOnHover: false,
  1639. popupAbsolute : false
  1640. });
  1641. }
  1642.  
  1643. if ( $('.header-icons > li').length > 1 ) {
  1644. $('.header-icons').flexMenu({
  1645. /*showOnHover: function () {
  1646. return !KLEO.isMobile.tabletWidth();
  1647. }*/
  1648. showOnHover: false,
  1649. popupAbsolute : false
  1650. });
  1651. }
  1652.  
  1653. $("body").on( "sidemenu-moving", function() {
  1654. adjustFlexMenu();
  1655. });
  1656.  
  1657. });
  1658.  
  1659. var flexObjects = [], // Array of all flexMenu objects
  1660. resizeTimeout;
  1661. // When the page is resized, adjust the flexMenus.
  1662. function adjustFlexMenu() {
  1663. $(flexObjects).each(function () {
  1664. $(this).flexMenu({
  1665. 'undo' : true
  1666. }).flexMenu(this.options);
  1667. });
  1668. }
  1669.  
  1670. function collapseAllExcept($menuToAvoid) {
  1671. var $activeMenus,
  1672. $menusToCollapse;
  1673. $activeMenus = $('li.more-wrapper.active');
  1674. $menusToCollapse = $activeMenus.not($menuToAvoid);
  1675. $menusToCollapse.removeClass('active').find('> ul').hide();
  1676. }
  1677. $(window).resize(function () {
  1678. clearTimeout(resizeTimeout);
  1679.  
  1680. resizeTimeout = setTimeout(function () {
  1681. adjustFlexMenu();
  1682. }, 200);
  1683. });
  1684. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement