1/* 2 * Copyright (c) 2021 Marketify 3 * Author: Marketify 4 * This file is made for CURRENT THEME 5*/ 6 7 8/* 9 10 @Author: Marketify 11 @URL: http://themeforest.net/user/marketify 12 13 14 This file contains the jquery functions for the actual theme, this 15 is the file you need to edit to change the structure of the 16 theme. 17 18 This files contents are outlined below. 19 20*/ 21 22 23// All other theme functions 24(function ($){ 25 26 "use strict"; 27 28 var TokyoInit = { 29 30 31 32 pageNumber: 1, 33 34 init: function () { 35 this.cursor(); 36 this.blog_info(); 37 this.menuScroll(); 38 this.minHeightForPages(); 39 this.url_fixer(); 40 this.textSkin(); 41 this.projectCategoryFitler(); 42 this.portfolioFilter(); 43 this.hamburgerOpener__Mobile(); 44 this.submenu__Mobile(); 45 this.imgToSVG(); 46 this.isotopeMasonry(); 47 this.dataFnBgImg(); 48 this.estimateWidgetHeight(); 49 this.runPlayer(); 50 this.newPlayer(); 51 this.right_bar_opener(); 52 this.categoryHook(); 53 this.right_bar_height(); 54 this.toTopJumper(); 55 this.like(); 56 this.rating(); 57 this.recipe_video(); 58 this.search_opener(); 59 this.fixedTotopScroll(); 60 this.prev_next_posts(); 61 this.widget__pages(); 62 this.widget__archives(); 63 this.dataFnStyle(); 64 this.portfolioContentHeight(); 65 this.inputCheckBoxInComment(); 66 this.inlineStyle(); 67 this.tokyo_fn_fixedsub(); 68 this.tokyo_fn_fixedsubReCalc(); 69 this.projectHover(); 70 }, 71 72 blog_info: function(){ 73 if($('.blog_info').height() === 0){ 74 $('.tokyo_fn_comment').addClass('margin-no-top'); 75 } 76 if($('.wp-calendar-nav').length){ 77 $('.wp-calendar-nav').each(function(){ 78 var e = $(this); 79 if(!e.find('a').length){ 80 e.remove(); 81 } 82 }); 83 } 84 }, 85 86 projectPopup: function(){ 87 $('.tokyo_popup_gallery').each(function() { // the containers for all your galleries 88 $(this).magnificPopup({ 89 delegate: 'a.zoom', // the selector for gallery item 90 type: 'image', 91 gallery: { 92 enabled:true 93 }, 94 removalDelay: 300, 95 mainClass: 'mfp-fade' 96 }); 97 98 }); 99 $('.tokyo_popup_youtube, .tokyo_popup_vimeo').each(function() { // the containers for all your galleries 100 $(this).magnificPopup({ 101 type: 'iframe', 102 mainClass: 'mfp-fade', 103 removalDelay: 160, 104 preloader: false, 105 fixedContentPos: false 106 }); 107 }); 108 109 $('.tokyo_popup_soundcloude').each(function(){ 110 $(this).magnificPopup({ 111 type : 'image', 112 gallery: { 113 enabled: true, 114 }, 115 }); 116 }); 117 }, 118 119 projectHover: function(){ 120 $('.tokyo_fn_ajax_portfolio .posts_list .item').on('mouseenter', function() { 121 if ($(this).data('title')) { 122 $('.tokyo_fn_portfolio_titles').html($(this).data('title') + '<span class="work__cat">' + $(this).data('category') + '</span>'); 123 $('.tokyo_fn_portfolio_titles').addClass('visible'); 124 } 125 126 $(document).on('mousemove', function(e) { 127 $('.tokyo_fn_portfolio_titles').css({ 128 left: e.clientX - 10, 129 top: e.clientY + 25 130 }); 131 }); 132 }).on('mouseleave', function() { 133 $('.tokyo_fn_portfolio_titles').removeClass('visible'); 134 }); 135 this.projectPopup(); 136 }, 137 138 tokyo_fn_fixedsub: function(){ 139 var self = this; 140 var fixedsub = $('#tokyo_fn_fixedsub'); 141 var li = $('ul.tokyo_fn_main_nav li'); 142 var leftpartW = $('.tokyo_fn_header').outerWidth(); 143 var rightpart = $('.tokyo_fn_pages, .tokyo_fn_header .fn_logo'); 144 var adminBar = 0; 145 if($('body').hasClass('admin-bar')){ 146 adminBar = 32; 147 } 148 149 fixedsub.css({left:leftpartW}); 150 151 152 li.on('mouseenter', function(){ 153 var parentLi = $(this); 154 var subMenu = parentLi.children('ul.sub-menu'); 155 var subMenuHtml = subMenu.html(); 156 //parentLi; 157 if(subMenu.length){ 158 li.removeClass('hovered'); 159 parentLi.addClass('hovered').parent().addClass('hovered'); 160 fixedsub.removeClass('opened').children('ul').html('').html(subMenuHtml); 161 fixedsub.addClass('opened'); 162 }else{ 163 fixedsub.removeClass('opened'); 164 parentLi.removeClass('hovered').parent().removeClass('hovered'); 165 } 166 var topOffSet = parentLi.offset().top; 167 var menuBar = $('.tokyo_fn_header'); 168 var menuBarOffSet = menuBar.offset().top; 169 var asd = topOffSet-menuBarOffSet+adminBar; 170 leftpartW = $('.tokyo_fn_header').outerWidth(); 171 172 fixedsub.css({top:asd,left:leftpartW}); 173 abc(); 174 }); 175 function abc(){ 176 rightpart.on('mouseenter', function(){ 177 fixedsub.removeClass('opened'); 178 li.removeClass('hovered').parent().removeClass('hovered'); 179 }); 180 } 181 abc(); 182 }, 183 tokyo_fn_fixedsubReCalc: function(){ 184 var fixedsub = $('#tokyo_fn_fixedsub'); 185 var leftpartW = $('.tokyo_fn_header').outerWidth(); 186 fixedsub.css({left:leftpartW}); 187 }, 188 189 runPreloader: function(){ 190 var speed = 500,self = this; 191 setTimeout(function(){self.preloader();},speed); 192 }, 193 194 preloader: function(){ 195 var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ? true : false; 196 var preloader = $('.tokyo_fn_pageloader'); 197 if (!isMobile) { 198 setTimeout(function() { 199 preloader.addClass('fn_ready'); 200 }, 800); 201 setTimeout(function() { 202 preloader.remove(); 203 }, 2000); 204 }else{ 205 preloader.remove(); 206 } 207 }, 208
209 inlineStyle: function(){ 210 var s = ''; 211 $('.tokyo_fn_style').each(function(){ 212 var e = $(this), v = e.val(); e.val(''); s+= v; 213 }); 214 $('body').append(s); 215 }, 216 217 inputCheckBoxInComment: function(){ 218 if($('p.comment-form-cookies-consent input[type=checkbox]').length){ 219 $('p.comment-form-cookies-consent input[type=checkbox]').wrap('<label class="fn_checkbox"></label>').after('<span></span>'); 220 } 221 }, 222 223 portfolioContentHeight: function(){ 224 var portfolio = $('.tokyo_fn_portfolio_page .portfolio_content'); 225 if(portfolio.height() === 0){ 226 portfolio.css({display: 'none'}); 227 } 228 }, 229 230 dataFnStyle: function(){ 231 $('[data-fn-style]').each(function(){ 232 var el = $(this); 233 var s = el.attr('data-fn-style'); 234 $.each(s.split(';'),function(i,e){ 235 el.css(e.split(':')[0],e.split(':')[1]); 236 }); 237 }); 238 }, 239 240 menuScroll: function(){ 241 var H = $(window).height(), 242 header = $('.tokyo_fn_header'), 243 nav = header.find('.header_nav'), 244 logoH = header.find('.fn_logo').outerHeight(true,true), 245 searchH = header.find('.search_wrap').outerHeight(true,true), 246 copyH = header.find('.header_copyright').outerHeight(true,true), 247 adminBarH = 0; 248 if($('body').hasClass('admin-bar')){ 249 adminBarH = 32; 250 } 251 nav.css({maxHeight: (H-logoH-searchH-copyH-adminBarH-100) + 'px'}); 252 if($().niceScroll){ 253 nav.getNiceScroll().remove(); 254 nav.niceScroll({ 255 touchbehavior: false, 256 cursorwidth: 0, 257 autohidemode: true, 258 cursorborder: "0px solid #e5e5e5" 259 }); 260 } 261 }, 262 263 minHeightForPages: function(){ 264 var H = $(window).height(), 265 W = $(window).width(), 266 headerH = 0, 267 mobileH = 0, 268 adminBarH = 0, 269 footerH = $('.tokyo_fn_footer').height(), 270 mobile = $('.tokyo_fn_mobilemenu_wrap'), 271 header = $('.tokyo_fn_header'); 272 if($('.tokyo-fn-wrapper').data('pos') === 'relative'){ 273 headerH = header.height(); 274 } 275 if(mobile.css('display') !== 'none'){ 276 mobileH = mobile.height(); 277 headerH = 0; 278 } 279 if($('body').hasClass('admin-bar')){ 280 if(W<782){ 281 adminBarH = 46; 282 }else{ 283 adminBarH = 32; 284 } 285 } 286 $('.tokyo_fn_pages,.tokyo_fn_404').css({minHeight: (H-mobileH-headerH-footerH-adminBarH) + 'px'}); 287 }, 288 289 url_fixer: function(){ 290 $('a[href*="fn_ex_link"]').each(function(){ 291 var oldUrl = $(this).attr('href'), 292 array = oldUrl.split('fn_ex_link/'), 293 newUrl = TokyoAjaxObject.siteurl + "/" + array[1]; 294 $(this).attr('href', newUrl); 295 }); 296 }, 297 298 textSkin: function(){ 299 $('body').addClass('fn__text_skin_'+$('.tokyo-fn-wrapper').data('text-skin')); 300 }, 301 302 303 304 portfolioFilter: function(){ 305 var self = this; 306 $('.tokyo_fn_portfolio_page .fn_ajax_more a').off().on('click',function(){ 307 var thisButton = $(this); 308 var more = thisButton.closest('.fn_ajax_more'); 309 var input = more.find('input'); 310 var abb = thisButton.closest('.tokyo_fn_portfolio_page'); 311 var filter_page = parseInt(input.val()); 312 if(thisButton.hasClass('active')){ 313 return false; 314 } 315 if(!abb.hasClass('go') && !more.hasClass('disabled')){ 316 abb.addClass('go'); 317 318 var requestData = { 319 action: 'tokyo_fn_ajax_portfolio', 320 filter_page: filter_page, 321 security: TokyoAjaxObject.nonce 322 }; 323 324 325 $.ajax({
326 type: 'POST', 327 url: TokyoAjaxObject.ajax_url, 328 cache: false, 329 data: requestData, 330 success: function(data) { 331 var fnQueriedObj = $.parseJSON(data); 332 var html = fnQueriedObj.data; 333 var $grid = abb.find('.posts_list'); 334 var $items; 335 $items = $(html); 336 input.val(filter_page+1); 337 input.change(); 338 339 if(fnQueriedObj.disabled === 'disabled'){ 340 more.addClass('disabled'); 341 } 342 $grid.append( $items ).isotope( 'appended', $items ); 343 setTimeout(function(){ 344 $grid.isotope({ 345 itemSelector: 'li', 346 masonry: {}, 347 stagger: 30 348 }); 349 },500); 350 self.dataFnStyle(); 351 self.dataFnBgImg(); 352 self.projectHover(); 353 abb.removeClass('go'); 354 }, 355 error: function(xhr, textStatus, errorThrown){ 356 abb.removeClass('go'); 357 } 358 }); 359 } 360 361 362 return false; 363 }); 364 }, 365 366 projectCategoryFitler: function(){ 367 if($().isotope){ 368 var items = $('.tokyo_fn_ajax_portfolio'); 369 items.each(function() { 370 var thisItem = $(this); 371 var list = thisItem.find('.posts_list'); 372 var filter = thisItem.find('.posts_filter'); 373 374 list.isotope({ 375 itemSelector: 'li', 376 masonry: {}, 377 stagger: 30 378 }); 379 380 // Isotope Filter 381 filter.find('a').off().on('click', function() { 382 var selector = $(this).attr('data-filter'); 383 list = thisItem.find('.posts_list'); 384 filter.find('a').removeClass('current'); 385 $(this).addClass('current'); 386 list.isotope({ 387 filter: selector, 388 animationOptions: { 389 duration: 750, 390 easing: 'linear', 391 queue: false 392 } 393 }); 394 return false; 395 }); 396 397 }); 398 } 399 400 }, 401 402 cursor: function () { 403 var myCursor = $('.marketify-cursor'); 404 if (myCursor.length) { 405 if ($("body").length) { 406 const e = document.querySelector(".cursor-inner"), 407 t = document.querySelector(".cursor-outer"); 408 var n, i = 0,W = 0,intro = 0, 409 o = !1; 410 if($('.tokyo_fn_intro').length){intro=1;} 411 412 var buttons = "fn_cs_intro_testimonials .prev, .fn_cs_intro_testimonials .next, .fn_cs_swiper_nav_next, .fn_cs_swiper_nav_prev, .fn_dots, .swiper-button-prev, .swiper-button-next, .fn_cs_accordion .acc_head, .tokyo_fn_popupshare .share_closer, .tokyo_fn_header .fn_finder, .tokyo_fn_header .fn_trigger, a, input[type='submit'], .cursor-link, button"; 413 var sliders = ".owl-carousel, .swiper-container, .cursor-link"; 414 // link mouse enter + move 415 window.onmousemove = function(s) { 416 o || (t.style.transform = "translate(" + s.clientX + "px, " + s.clientY + "px)"), e.style.transform = "translate(" + s.clientX + "px, " + s.clientY + "px)", n = s.clientY, i = s.clientX 417 }, $("body").on("mouseenter", buttons, function() { 418 e.classList.add("cursor-hover"), t.classList.add("cursor-hover") 419 }), $("body").on("mouseleave", buttons, function() { 420 $(this).is("a") && $(this).closest(".cursor-link").length || (e.classList.remove("cursor-hover"), t.classList.remove("cursor-hover")) 421 }), e.style.visibility = "visible", t.style.visibility = "visible"; 422 423 424 // Intro functions 425 var intro_left = '.tokyo_fn_intro .left'; 426 var intro_right = '.tokyo_fn_intro .right'; 427 var intro_price = '.tokyo_fn_intro_fixed_price .anim'; 428 $('body').on('mouseenter', intro_left, function(){ 429 e.classList.add('left-demo'); 430 t.classList.add('left-demo'); 431 }).on('mouseleave', intro_left,function(){ 432 e.classList.remove('left-demo'); 433 t.classList.remove('left-demo'); 434 }); 435 $('body').on('mouseenter', intro_right, function(){ 436 e.classList.add('right-demo'); 437 t.classList.add('right-demo'); 438 }).on('mouseleave', intro_right,function(){ 439 e.classList.remove('right-demo'); 440 t.classList.remove('right-demo'); 441 }); 442 $('body').on('mouseenter', intro_price, function(){ 443 e.classList.add('intro-price'); 444 t.classList.add('intro-price'); 445 }).on('mouseleave', intro_price,function(){ 446 e.classList.remove('intro-price'); 447 t.classList.remove('intro-price'); 448 });
449 450 // slider mouse enter 451 $('body').on('mouseenter', sliders, function(){ 452 e.classList.add('cursor-slider'); 453 t.classList.add('cursor-slider'); 454 }).on('mouseleave', sliders,function(){ 455 e.classList.remove('cursor-slider'); 456 t.classList.remove('cursor-slider'); 457 }); 458 459 // slider mouse hold 460 $('body').on('mousedown', sliders, function(){ 461 e.classList.add('mouse-down'); 462 t.classList.add('mouse-down'); 463 }).on('mouseup', sliders, function(){ 464 e.classList.remove('mouse-down'); 465 t.classList.remove('mouse-down'); 466 }); 467 } 468 } 469 }, 470 471 widget__archives: function(){ 472 $('.widget_archive li').each(function(){ 473 var e = $(this); 474 var a = e.find('a').clone(); 475 $('body').append('<div class="marketify_hidden_item"></div>'); 476 $('.marketify_hidden_item').html(e.html()); 477 $('.marketify_hidden_item').find('a').remove(); 478 var suffix = $('.marketify_hidden_item').html().match(/\d+/); // 123456 479 $('.marketify_hidden_item').remove(); 480 suffix = parseInt(suffix); 481 if(isNaN(suffix)){ 482 return false; 483 } 484 suffix = '<span class="count">'+suffix+'</span>'; 485 e.html(a); 486 e.append(suffix); 487 }); 488 }, 489 490 prev_next_posts: function(){ 491 if($('.tokyo_fn_siblings')){ 492 $(document).keyup(function(e) { 493 if(e.key.toLowerCase() === 'p') { 494 var a = $('.tokyo_fn_siblings').find('a.previous_project_link'); 495 if(a.length){ 496 window.location.href = a.attr('href'); 497 return false; 498 } 499 } 500 if(e.key.toLowerCase() === 'n') { 501 var b = $('.tokyo_fn_siblings').find('a.next_project_link'); 502 if(b.length){ 503 window.location.href = b.attr('href'); 504 return false; 505 } 506 } 507 }); 508 } 509 }, 510 511 fixedTotopScroll: function(){ 512 var totop = $('.tokyo_fn_totop'); 513 var height = parseInt(totop.find('input').val()); 514 if(totop.length){ 515 if($(window).scrollTop() > height){ 516 totop.addClass('scrolled'); 517 }else{ 518 totop.removeClass('scrolled'); 519 } 520 } 521 }, 522 523 search_placeholder: function(searchinput,text,i,speed){ 524 setTimeout(function(){ 525 searchinput.attr('placeholder',text); 526 },i*speed); 527 }, 528 529 search_opener: function(){ 530 var self = this; 531 var speed = 10; 532 var searchbox = $('.tokyo_fn_searchpopup'); 533 var opener = $('.tokyo_fn_header .fn_finder'); 534 var searchinput = $('.tokyo_fn_searchpopup input[type=text]'); 535 if(opener.length){ 536 opener.off().on('click',function(){ 537 if($('body').hasClass('open_search_popup')){ 538 searchbox.removeClass('focused'); 539 $('body').removeClass('open_search_popup'); 540 }else{ 541 var placeholder = searchinput.attr('placeholder'); 542 searchinput.attr('placeholder',''); 543 var array = placeholder.split(''); 544 $('body').addClass('open_search_popup'); 545 setTimeout(function(){ 546 var text = ''; 547 for(var i=0;i<array.length;i++){ 548 text+= array[i]; 549 self.search_placeholder(searchinput,text,i,speed); 550 } 551 setTimeout(function(){ 552 searchinput.focus(); 553 searchinput.trigger('click'); 554 },speed*array.length); 555 },500); 556 } 557 return false; 558 }); 559 } 560 if(searchbox.length){ 561 var closer = searchbox.find('.search_closer,.extra_closer'); 562 var inputText = searchbox.find('input[type=text]'); 563 var inputSubmit = searchbox.find('input[type=submit]'); 564 searchbox.find('.search_inner').off().on('click',function(){ 565 searchbox.removeClass('focused'); 566 }); 567 inputText.off().on('click',function(event){ 568 searchbox.addClass('focused'); 569 event.stopPropagation(); 570 }); 571 inputSubmit.off().on('click',function(event){ 572 event.stopPropagation(); 573 }); 574 closer.off().on('click',function(event){ 575 event.stopPropagation(); 576 searchbox.removeClass('focused'); 577 $('body').removeClass('open_search_popup'); 578 closer.addClass('closed'); 579 setTimeout(function(){ 580 closer.removeClass('closed'); 581 },500); 582 }); 583 } 584 }, 585 586 right_bar_opener: function(){ 587 var hamburger = $('.tokyo_fn_header .fn_trigger');hamburger.addClass('ready'); 588 var trigger = $('.tokyo_fn_right_panel .extra_closer, .tokyo_fn_right_panel .fn_closer'); 589 trigger.off().on('click',function(){ 590 $('body').toggleClass('fn_opened'); 591 return false; 592 }); 593 hamburger.on('click',function(){ 594 $('body').addClass('fn_opened'); 595 return false; 596 }); 597 var i = null; 598 hamburger.on('mouseenter',function(){ 599 i = setTimeout(function(){ 600 $('body').addClass('fn_opened'); 601 },700); 602 }).on('mouseleave',function(){ 603 clearTimeout(i); 604 }); 605 }, 606 607 categoryHook: function(){ 608 var self = this; 609 var list = $('.wp-block-archives li, .widget_tokyo_custom_categories li, .widget_categories li, .widget_archive li'); 610 list.each(function(){ 611 var item = $(this); 612 if(item.find('ul').length){ 613 item.addClass('has-child'); 614 } 615 }); 616 617 618 var html = $('.tokyo_fn_hidden.more_cats').html(); 619 var cats = $('.widget_categories,.widget_archive,.widget_tokyo_custom_categories'); 620 if(cats.length){ 621 cats.each(function(){ 622 var element = $(this); 623 var limit = 3; 624 element.append(html); 625 var li = element.find('ul:not(.children) > li'); 626 if(li.length > limit){ 627 var h = 0; 628 li.each(function(i,e){ 629 if(i < limit){ 630 h += $(e).outerHeight(true,true); 631 }else{ 632 return false; 633 } 634 });
635 element.find('ul:not(.children)').css({height: h + 'px'}); 636 element.find('.tokyo_fn_more_categories .fn_count').html('('+(li.length-limit)+')'); 637 }else{ 638 element.addClass('all_active'); 639 } 640 }); 641 self.categoryHookAction(); 642 } 643 }, 644 645 categoryHookAction: function(){ 646 var self = this; 647 $('.tokyo_fn_more_categories').find('a').off().on('click',function(){ 648 var e = $(this); 649 var limit = 3; 650 var myLimit = limit; 651 var parent = e.closest('.widget_block'); 652 var li = parent.find('ul:not(.children) > li'); 653 var liHeight = li.outerHeight(true,true); 654 var h = liHeight*limit; 655 var liLength = li.length; 656 var speed = (liLength-limit)*50; 657 e.toggleClass('show'); 658 if(e.hasClass('show')){ 659 myLimit = liLength; 660 h = liHeight*liLength; 661 e.find('.text').html(e.data('less')); 662 e.find('.fn_count').html(''); 663 }else{ 664 e.find('.text').html(e.data('more')); 665 e.find('.fn_count').html('('+(liLength-limit)+')'); 666 } 667 668 669 var H = 0; 670 li.each(function(i,e){ 671 if(i < myLimit){ 672 H += $(e).outerHeight(true,true); 673 }else{ 674 return false; 675 } 676 }); 677 678 speed = (speed > 300) ? speed : 300; 679 speed = (speed < 1500) ? speed : 1500; 680 parent.find('ul:not(.children)').animate({height:H},speed); 681 682 setTimeout(function(){ 683 self.right_bar_height(); 684 },(speed+1)); 685 686 687 return false; 688 }); 689 }, 690 691 recipe_video: function(){ 692 $('.tokyo_fn_single_recipe .popup-youtube').each(function() { // the containers for all your galleries 693 $(this).magnificPopup({ 694 disableOn: 700, 695 type: 'iframe', 696 mainClass: 'mfp-fade', 697 removalDelay: 160, 698 preloader: false, 699 fixedContentPos: false 700 }); 701 }); 702 }, 703 704 rating: function(){ 705 var radio = $('.comments-rating input[type="radio"]'); 706 radio.on('click',function(){ 707 var el = $(this); 708 var id = el.attr('id'); 709 $('.comments-rating .fn_radio').removeClass('clicked'); 710 $('.comments-rating .'+id).addClass('clicked'); 711 }).on('mouseenter',function(){ 712 var el = $(this); 713 var id = el.attr('id'); 714 $('.comments-rating .fn_radio').removeClass('hovered'); 715 $('.comments-rating .'+id).addClass('hovered'); 716 }).on('mouseleave',function(){ 717 $('.comments-rating .fn_radio').removeClass('hovered'); 718 }); 719 }, 720 721 722 723 724 725 726 727 right_bar_height: function(){ 728 var H = $(window).height(), 729 bar = $('.tokyo_fn_popup_sidebar'), 730 inner = bar.find('.sidebar_wrapper'); 731 bar.height(H + 'px'); 732 if($().niceScroll){ 733 inner.getNiceScroll().remove(); 734 inner.height('100%').niceScroll({ 735 touchbehavior: false, 736 cursorwidth: 0, 737 autohidemode: true, 738 cursorborder: "0px solid #e5e5e5" 739 }); 740 } 741 }, 742 743 744 toTopJumper: function(){ 745 var totop = $('.tokyo_fn_footer .footer_totop a,a.tokyo_fn_totop,.tokyo_fn_footer .footer_right_totop a'); 746 if(totop.length){ 747 totop.on('click', function(e) { 748 e.preventDefault(); 749 $("html, body").animate( 750 { scrollTop: 0 }, 'slow'); 751 return false; 752 }); 753 } 754 }, 755 756 757 758 runPlayer: function(){ 759 var parent = $('.tokyo_fn_main_audio'); 760 var audioVideo = parent.find('audio,video'); 761 audioVideo.each(function(){ 762 var element = $(this); 763 element.mediaelementplayer({ 764 // Do not forget to put a final slash (/) 765 pluginPath: 'https://cdnjs.com/libraries/mediaelement/', 766 // this will allow the CDN to use Flash without restrictions 767 // (by default, this is set as `sameDomain`) 768 shimScriptAccess: 'always', 769 success: function(mediaElement, domObject) { 770 mediaElement.addEventListener('play', function() { 771 parent.removeClass('fn_pause').addClass('fn_play'); 772 }, false); 773 mediaElement.addEventListener('pause', function() { 774 parent.removeClass('fn_play').addClass('fn_pause'); 775 }, false); 776 }, 777 }); 778 }); 779 }, 780 781 newPlayer: function(){ 782 var parent = $('.tokyo_fn_main_audio'); 783 var closer = parent.find('.fn_closer'); 784 var audioVideo = parent.find('audio,video'); 785 var icon = parent.find('.podcast_icon'); 786 var audios = $('.tokyo_fn_audio_button'); 787 var playButton = $('.tokyo_fn_audio_button a'); 788 var self = this; 789 audioVideo.each(function(){ 790 var element = $(this); 791 element.mediaelementplayer({
792 // Do not forget to put a final slash (/) 793 pluginPath: 'https://cdnjs.com/libraries/mediaelement/', 794 // this will allow the CDN to use Flash without restrictions 795 // (by default, this is set as `sameDomain`) 796 shimScriptAccess: 'always', 797 success: function(mediaElement, domObject) { 798 mediaElement.addEventListener('pause', function() { 799 parent.removeClass('fn_play').addClass('fn_pause'); 800 }, false); 801 mediaElement.addEventListener('play', function() { 802 parent.removeClass('fn_pause').addClass('fn_play'); 803 }, false); 804 }, 805 }); 806 }); 807 closer.off().on('click', function(){ 808 if(parent.hasClass('closed')){ 809 parent.removeClass('closed'); 810 closer.find('span').html(closer.attr('data-close-text')); 811 }else{ 812 parent.addClass('closed'); 813 closer.find('span').html(closer.attr('data-open-text')); 814 } 815 }); 816 icon.off().on('click', function(){ 817 if(parent.find('audio,video').length){ 818 if(parent.hasClass('fn_pause')){ 819 parent.removeClass('fn_pause').addClass('fn_play').find('audio,video')[0].play(); 820 }else{ 821 parent.removeClass('fn_play').addClass('fn_pause').find('audio,video')[0].pause(); 822 } 823 } 824 }); 825 playButton.off().on('click',function(){ 826 var button = $(this); 827 var wrapper = button.parent(); 828 if(!wrapper.hasClass('active')){ 829 audios.removeClass('active fn_play fn_pause'); 830 wrapper.addClass('active'); 831 } 832 if(wrapper.hasClass('fn_pause')){ 833 wrapper.removeClass('fn_pause').addClass('fn_play'); 834 parent.find('audio,video')[0].play(); 835 }else if(wrapper.hasClass('fn_play')){ 836 wrapper.removeClass('fn_play').addClass('fn_pause'); 837 parent.find('audio,video')[0].pause(); 838 }else{ 839 wrapper.addClass('fn_play'); 840 var src = wrapper.attr('data-mp3'); 841 var audio = '<audio controls><source src="'+src+'" type="audio/mpeg"></audio>'; 842 $('.tokyo_fn_main_audio .audio_player').html(audio); 843 self.runPlayer(); 844 setTimeout(function(){ 845 parent.find('audio,video')[0].play(); 846 parent.removeClass('fn_pause').addClass('fn_play'); 847 parent.removeClass('closed'); 848 closer.find('span').html(closer.attr('data-close-text')); 849 self.playerSpace(); 850 },50); 851 } 852 853 return false; 854 }); 855 }, 856 857 858 widget__pages: function(){ 859 var nav = $('.widget_pages ul'); 860 nav.each(function(){ 861 $(this).find('a').off().on('click', function(e){ 862 var element = $(this); 863 var parentItem = element.parent('li'); 864 var parentItems = element.parents('li'); 865 var parentUls = parentItem.parents('ul.children'); 866 var subMenu = element.next(); 867 var allSubMenusParents = nav.find('li'); 868 869 allSubMenusParents.removeClass('opened'); 870 871 if(subMenu.length){ 872 e.preventDefault(); 873 874 if(!(subMenu.parent('li').hasClass('active'))){ 875 if(!(parentItems.hasClass('opened'))){parentItems.addClass('opened');} 876 877 allSubMenusParents.each(function(){ 878 var el = $(this); 879 if(!el.hasClass('opened')){el.find('ul.children').slideUp();} 880 }); 881 882 allSubMenusParents.removeClass('active'); 883 parentUls.parent('li').addClass('active'); 884 subMenu.parent('li').addClass('active'); 885 subMenu.slideDown(); 886 887 888 }else{ 889 subMenu.parent('li').removeClass('active'); 890 subMenu.slideUp(); 891 } 892 return false; 893 } 894 }); 895 }); 896 }, 897 898 submenu__Mobile: function(){ 899 var nav = $('ul.vert_menu_list, .widget_nav_menu ul.menu'); 900 var mobileAutoCollapse = $('.tokyo-fn-wrapper').data('mobile-autocollapse'); 901 nav.each(function(){ 902 $(this).find('a').off().on('click', function(e){ 903 var element = $(this); 904 var parentItem = element.parent('li'); 905 var parentItems = element.parents('li'); 906 var parentUls = parentItem.parents('ul.sub-menu'); 907 var subMenu = element.next(); 908 var allSubMenusParents = nav.find('li'); 909 910 allSubMenusParents.removeClass('opened'); 911 912 if(subMenu.length){ 913 e.preventDefault(); 914 915 if(!(subMenu.parent('li').hasClass('active'))){ 916 if(!(parentItems.hasClass('opened'))){parentItems.addClass('opened');} 917 918 allSubMenusParents.each(function(){ 919 var el = $(this); 920 if(!el.hasClass('opened')){el.find('ul.sub-menu').slideUp();} 921 });
922 923 allSubMenusParents.removeClass('active'); 924 parentUls.parent('li').addClass('active'); 925 subMenu.parent('li').addClass('active'); 926 subMenu.slideDown(); 927 928 929 }else{ 930 subMenu.parent('li').removeClass('active'); 931 subMenu.slideUp(); 932 } 933 return false; 934 } 935 if(mobileAutoCollapse === 'enable'){ 936 if(nav.parent().parent().hasClass('opened')){ 937 nav.parent().parent().removeClass('opened').slideUp(); 938 $('.tokyo_fn_mobilemenu_wrap .hamburger').removeClass('is-active'); 939 } 940 } 941 }); 942 }); 943 }, 944 945 hamburgerOpener__Mobile: function(){ 946 var hamburger = $('.tokyo_fn_mobilemenu_wrap .hamburger'); 947 hamburger.off().on('click',function(){ 948 var element = $(this); 949 var menupart = $('.tokyo_fn_mobilemenu_wrap .mobilemenu'); 950 if(element.hasClass('is-active')){ 951 element.removeClass('is-active'); 952 menupart.removeClass('opened'); 953 menupart.slideUp(500); 954 }else{ 955 element.addClass('is-active'); 956 menupart.addClass('opened'); 957 menupart.slideDown(500); 958 }return false; 959 }); 960 }, 961 962 like: function(){ 963 var svg; 964 var self = this; 965 if($('.tokyo-fn-wrapper').length){ 966 svg = $('.tokyo-fn-wrapper').data('like-url'); 967 } 968 var ajaxRunningForLike = false; 969 $('.tokyo_fn_like').off().on('click', function(e) { 970 e.preventDefault(); 971 972 var likeLink = $(this), 973 ID = $(this).data('id'), 974 likeAction,addAction; 975 976 likeLink = $('.tokyo_fn_like[data-id="'+ID+'"]'); 977 978 if(ajaxRunningForLike === true) {return false;} 979 980 if(likeLink.hasClass('liked')){ 981 likeAction = 'liked'; 982 addAction = 'not-rated'; 983 }else{ 984 likeAction = 'not-rated'; 985 addAction = 'liked'; 986 } 987 ajaxRunningForLike = true; 988 989 var requestData = { 990 action: 'tokyo_fn_like', 991 ID: ID, 992 likeAction: likeAction, 993 security: TokyoAjaxObject.nonce 994 }; 995 996 $.ajax({
997 type: 'POST', 998 url: TokyoAjaxObject.ajax_url, 999 cache: false, 1000 data: requestData, 1001 success: function(data) { 1002 var fnQueriedObj = $.parseJSON(data); //get the data object 1003 likeLink.removeClass('animate ' + likeAction).addClass(addAction); 1004 likeLink.find('.tokyo_w_fn_svg').remove(); 1005 likeLink.find('.tokyo_fn_like_count').before('<img src="'+fnQueriedObj.svg+'" class="tokyo_w_fn_svg" alt="" />'); 1006 self.imgToSVG(); 1007 likeLink.find('.count').html(fnQueriedObj.count); 1008 likeLink.find('.text').html(fnQueriedObj.like_text); 1009 likeLink.attr('title',fnQueriedObj.title); 1010 likeLink.addClass('animate'); 1011 ajaxRunningForLike = false; 1012 }, 1013 error: function(MLHttpRequest, textStatus, errorThrown) { 1014 console.log(MLHttpRequest); 1015 console.log(textStatus); 1016 console.log(errorThrown); 1017 } 1018 }); 1019 1020 return false; 1021 }); 1022 }, 1023 1024 1025 imgToSVG: function(){ 1026 $('img.tokyo_fn_svg,img.tokyo_w_fn_svg').each(function(){ 1027 var img = $(this); 1028 var imgClass = img.attr('class'); 1029 var imgURL = img.attr('src'); 1030 1031 $.get(imgURL, function(data) { 1032 var svg = $(data).find('svg'); 1033 if(typeof imgClass !== 'undefined') { 1034 svg = svg.attr('class', imgClass+' replaced-svg'); 1035 } 1036 img.replaceWith(svg); 1037 1038 }, 'xml'); 1039 1040 }); 1041 }, 1042 1043 1044 dataFnBgImg: function(){ 1045 var bgImage = $('*[data-fn-bg-img]'); 1046 bgImage.each(function(){ 1047 var element = $(this); 1048 var attrBg = element.attr('data-fn-bg-img'); 1049 var bgImg = element.data('fn-bg-img'); 1050 if(typeof(attrBg) !== 'undefined'){ 1051 element.addClass('marketify-ready').css({backgroundImage:'url('+bgImg+')'}); 1052 } 1053 }); 1054 }, 1055 1056 isotopeMasonry: function(){ 1057 var masonry = $('.tokyo_fn_masonry'); 1058 if($().isotope){ 1059 masonry.each(function(){ 1060 $(this).isotope({ 1061 itemSelector: '.tokyo_fn_masonry_in', 1062 masonry: {} 1063 }); 1064 }); 1065 } 1066 }, 1067 1068 estimateWidgetHeight: function(){ 1069 var est = $('.tokyo_fn_widget_estimate'); 1070 est.each(function(){ 1071 var el = $(this); 1072 var h1 = el.find('.helper1'); 1073 var h2 = el.find('.helper2'); 1074 var h3 = el.find('.helper3'); 1075 var h4 = el.find('.helper4'); 1076 var h5 = el.find('.helper5'); 1077 var h6 = el.find('.helper6'); 1078 var eW = el.outerWidth(); 1079 var w1 = Math.floor((eW * 80) / 300); 1080 var w2 = eW-w1; 1081 var e1 = Math.floor((w1 * 55) / 80); 1082 h1.css({borderLeftWidth: w1+'px', borderTopWidth: e1+'px'}); 1083 h2.css({borderRightWidth: w2+'px', borderTopWidth: e1+'px'}); 1084 h3.css({borderLeftWidth: w1+'px', borderTopWidth: w1+'px'}); 1085 h4.css({borderRightWidth: w2+'px', borderTopWidth: w1+'px'}); 1086 h5.css({borderLeftWidth: w1+'px', borderTopWidth: w1+'px'}); 1087 h6.css({borderRightWidth: w2+'px', borderTopWidth: w1+'px'}); 1088 }); 1089 }, 1090 }; 1091 1092 1093 1094 // ready functions 1095 $(document).ready(function(){ 1096 TokyoInit.init(); 1097 }); 1098 1099 // resize functions 1100 $(window).on('resize',function(e){ 1101 e.preventDefault(); 1102 TokyoInit.tokyo_fn_fixedsubReCalc(); 1103 TokyoInit.menuScroll(); 1104 TokyoInit.isotopeMasonry(); 1105 TokyoInit.projectCategoryFitler(); 1106 TokyoInit.right_bar_height(); 1107 TokyoInit.estimateWidgetHeight(); 1108 }); 1109 1110 // scroll functions 1111 $(window).on('scroll', function(e) { 1112 e.preventDefault(); 1113 TokyoInit.fixedTotopScroll(); 1114 }); 1115 1116 // load functions 1117 $(window).on('load', function(e) { 1118 e.preventDefault(); 1119 TokyoInit.runPreloader(); 1120 TokyoInit.isotopeMasonry(); 1121 TokyoInit.projectCategoryFitler(); 1122 setTimeout(function(){ 1123 TokyoInit.isotopeMasonry(); 1124 TokyoInit.projectCategoryFitler(); 1125 },100); 1126 }); 1127 1128})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.