1/*jshint undef: true, unused: false, vars: true, plusplus: true */ 2/*global jQuery:false, window: false, setInterval: false, clearTimeout: false, setTimeout: false, mo_options:false, mo_theme:false, template_dir:false, document:false */ 3 4jQuery.noConflict(); 5 6var MO_THEME; // theme namespace 7 8/*================================ Global Function init ==================================*/ 9// Helps to avoid continuous method execution as can happen in the case of scroll or window resize. Useful specially 10// when DOM access/manipulation is involved 11var mo_wait_for_final_event = (function () { 12 "use strict"; 13 var timers = {}; 14 return function (callback, ms, uniqueId) { 15 if (!uniqueId) { 16 uniqueId = "Don't call this twice without a uniqueId"; 17 } 18 if (timers[uniqueId]) { 19 clearTimeout(timers[uniqueId]); 20 } 21 timers[uniqueId] = setTimeout(callback, ms); 22 }; 23})(); 24 25/*---- Enter negative percentage to darken; assumes presence of # - Credit: http://stackoverflow.com/questions/5560248/programmatically-lighten-or-darken-a-hex-color --*/ 26var mo_shadeColor = (function () { 27 "use strict"; 28 return function (color, percent) { 29 var num = parseInt(color.slice(1), 16), amt = Math.round(2.55 * percent), R = (num >> 16) + amt, G = (num >> 8 & 0x00FF) + amt, B = (num & 0x0000FF) + amt; 30 return "#" + (0x1000000 + (R < 255 ? R < 1 ? 0 : R : 255) * 0x10000 + (G < 255 ? G < 1 ? 0 : G : 255) * 0x100 + (B < 255 ? B < 1 ? 0 : B : 255)).toString(16).slice(1); 31 }; 32})(); 33 34var mo_isIE = (function () { 35 "use strict"; 36 return function (version) { 37 var exp = new RegExp('msie' + (!isNaN(version) ? ('\\s' + version) : ''), 'i'); 38 return exp.test(navigator.userAgent); 39 }; 40})(); 41 42var mo_isMobile = (function () { 43 "use strict"; 44 return function () { 45 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { 46 return true; 47 } 48 return false; 49 }; 50})(); 51 52var mo_toggle_html5_video_volume = function (video) { 53 "use strict"; 54 55 if (video.muted) { 56 video.muted = false; 57 } 58 else { 59 video.muted = true; 60 } 61}; 62 63/*================================== Theme Function init =======================================*/ 64 65(function ($) { 66 67 "use strict"; 68 69 MO_THEME = { 70 71 add_body_classes: function () { 72 if (mo_isMobile()) { 73 $('body').addClass('mobile-device'); 74 } 75 if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) { 76 $('body').addClass('ios-device'); 77 } 78 if (navigator.userAgent.match(/Android/i) !== null) { 79 $('body').addClass('android-device'); 80 } 81 }, 82 83 manipulate_dom: function () { 84 $(".single-event strong:contains('Date/Time'),.single-event strong:contains('Location'), .single-event strong:contains('Categories')").addClass('heading-title'); 85 $(".single-location strong:contains('Address')").addClass('heading-title'); 86 }, 87 88 toggle_mobile_menu: function () { 89 $('#mobile-menu-toggle').toggleClass('menu-open'); 90 $('body').toggleClass('push-right'); 91 $('#mobile-menu').toggleClass('slide-open'); 92 }, 93 94 display_stats: function () { 95 /* ------- Skill Bar --------- */ 96 $('.stats-bar-content').each(function () { 97 var dataperc = $(this).attr('data-perc'); 98 $(this).animate({ "width": dataperc + "%"}, dataperc * 20); 99 }); 100 101 }, 102 103 display_piecharts: function () { 104 105 /* -------- Charts like Pie Chart -------- */ 106 var charts = $('.piechart .percentage'), 107 bar_color = mo_options.theme_skin, 108 track_color = mo_shadeColor(bar_color, 26); 109 /* Lighten */ 110 charts.easyPieChart({ 111 animate: 2000, 112 lineWidth: 20, 113 barColor: bar_color, 114 trackColor: track_color, 115 scaleColor: false, 116 lineCap: 'square', 117 size: 250 118 119 }); 120 }, 121 122 get_internal_link: function (urlString) { 123 var internal_link = null;
124 if (urlString.indexOf("#") !== -1) { 125 var arr = urlString.split('#'); 126 if (arr.length === 2) { 127 var url = arr[0]; 128 internal_link = '#' + arr[1]; 129 // check if this internal link belongs to current URL 130 if (url === (document.URL + '/') || url === document.URL) { 131 return internal_link; 132 } 133 } else if (arr.length === 1) { 134 internal_link = '#' + arr[0]; 135 return internal_link; 136 } 137 } 138 return internal_link; 139 140 }, 141 142 highlight_menu: function () { 143 144 var $active_menu_item; 145 146 /* Do not highlight internal links */ 147 // make the current page active for highlight - top list cannot have both a parent and current page item 148 $active_menu_item = $('#primary-menu > ul > li.current_page_item > a').not('a[href*="#"]').first(); 149 150 if ($active_menu_item.length === 0) 151 $active_menu_item = $('#primary-menu > ul > li.current-menu-item > a').not('a[href*="#"]').first(); 152 153 if ($active_menu_item.length === 1) 154 $active_menu_item.parent().addClass('active'); 155 156 }, 157 158 init_page_navigation: function () { 159 160 MO_THEME.highlight_menu(); 161 162 var delay = (function () { 163 var timer = 0; 164 return function (callback, ms) { 165 clearTimeout(timer); 166 timer = setTimeout(callback, ms); 167 }; 168 })(); 169 170 171 /*--- Sticky Menu -------*/ 172 var width = $(window).width(); 173 if (width > 768 && mo_options.sticky_menu) { 174 $('#header').waypoint('sticky', { 175 stuckClass: 'sticky', 176 offset: -300, 177 handler: function (direction) { 178 if (direction === "up") { 179 /* Reached the top and hence highlight current page link */ 180 $('#primary-menu > ul > li').not(".hover-bg").each(function () { 181 $(this).removeClass('active'); 182 MO_THEME.highlight_menu(); 183 }); 184 } 185 } 186 187 }) 188 } 189 ; 190 191 /* ----- Smooth Scroll --------*/ 192 193 if ($().smoothScroll !== undefined) { 194 $('#primary-menu > ul > li > a[href*="#"]').smoothScroll( 195 { preventDefault: true, easing: 'swing', speed: 700, offset: -50, exclude: ['.external a']}); 196 $('#mobile-menu a[href*="#"]').smoothScroll( 197 {easing: 'swing', speed: 700, offset: 0, exclude: ['.external a']}); 198 } 199 200 201 /* --------- One Page Menu --------- */ 202 $('#primary-menu > ul > li > a[href*="#"]').click(function () { 203 $(this).closest('ul').children('li').each(function () { 204 $(this).removeClass('active'); 205 }); 206 $(this).parent('li').addClass('active'); 207 }); 208 $('#primary-menu > ul > li > a[href*="#"]').each(function () { 209 var current_div_selector = MO_THEME.get_internal_link($(this).attr('href')); // Give ids of div's with ids like #work,#service, #portfolio etc. 210 211 $(current_div_selector).waypoint(function (direction) { 212 if (direction === "up") { 213 $('#primary-menu > ul > li').each(function () { 214 $(this).removeClass('active'); 215 if ($(this).find('a').attr('href').indexOf(current_div_selector) !== -1) { 216 $(this).addClass('active'); 217 } 218 }); 219 } 220 }, { 221 offset: function () { 222 var half_browser_height = $.waypoints('viewportHe
222ight') / 2; 223 var element_height = $(this).height(); 224 var result = 0; 225 if (element_height > half_browser_height) { 226 result = -( element_height - (half_browser_height)); // enable when top of the div is half exposed on the screen 227 } 228 else { 229 result = -(element_height / 2); // enable the menu when everything is visible 230 } 231 return result; 232 } 233 } 234 ); 235 $(current_div_selector).waypoint(function (direction) { 236 if (direction === "down") { 237 $('#primary-menu > ul > li').each(function () { 238 $(this).removeClass('active'); 239 if ($(this).find('a').attr('href').indexOf(current_div_selector) !== -1) { 240 $(this).addClass('active'); 241 } 242 }); 243 } 244 }, { offset: '50%' }); 245 }); 246 247 }, 248 249 init_menus: function () { 250 /* For sticky and primary menu navigation */ 251 $('.dropdown-menu-wrap > ul').superfish({ 252 delay: 100, // one second delay on mouseout 253 animation: {height: 'show'}, // fade-in and slide-down animation 254 speed: 'fast', // faster animation speed
255 autoArrows: false // disable generation of arrow mark-up 256 }); 257 258 259 /* Take care of internal links too - close the menu when scrolling from internal links */ 260 $('#mobile-menu-toggle, #mobile-menu a[href*="#"]').click(function () { 261 MO_THEME.toggle_mobile_menu(); 262 return true; 263 /* must return true to record click event for smooth scroll of internal links */ 264 }); 265 266 /* Close the mobile menu if the user touches the right document when mobile menu is open */ 267 $('#container').on('click touchstart', function () { 268 if ($('body').hasClass('push-right')) { 269 MO_THEME.toggle_mobile_menu(); 270 return false; 271 /* no need to do anything else for now until menu closes */ 272 } 273 return true; 274 /* continue with normal click activity */ 275 }); 276 277 $("#mobile-menu ul li").each(function () { 278 var sub_menu = $(this).find("> ul"); 279 if (sub_menu.length > 0 && $(this).addClass("has-ul")) { 280 $(this).append('<div class="sf-sub-indicator"><i class="icon-uniF488"></i></div>'); 281 } 282 }); 283 284 $('#mobile-menu ul li:has(">ul") > div').click(function () { 285 $(this).siblings("ul.sub-menu").stop(true, true).slideToggle(); 286 $(this).parent().toggleClass("open"); 287 return false; 288 }); 289 290 this.init_page_navigation(); 291 }, 292 293 scroll_effects: function () { 294 if ($().waypoint === undefined) { 295 return; 296 } 297 298 $(".features-list-alternate img").css('opacity', 0); 299 300 $(".features-list-alternate img").waypoint(function (direction) { 301 $(this).addClass("animated fadeIn"); 302 }, { offset: $.waypoints('viewportHeight') - 150, 303 triggerOnce: true}); 304 305 306 /* ------------------- Stats -----------------------------*/ 307 308 $(".stats-bar").waypoint(function (direction) { 309 310 MO_THEME.display_stats(); 311 312 }, { offset: $.waypoints('viewportHeight') - 200, 313 triggerOnce: true}); 314 315 $(".piechart").waypoint(function (direction) { 316 317 MO_THEME.display_piecharts(); 318 319 }, { offset: $.waypoints('viewportHeight') - 200, 320 triggerOnce: true}); 321 322 }, 323 324 prettyPhoto: function () { 325 326 if ($().prettyPhoto === undefined) { 327 return; 328 } 329 330 var theme_selected = 'pp_default'; 331 332 $('a[data-gal^="prettyPhoto"]').prettyPhoto({ 333 theme: theme_selected, /* light_rounded / dark_rounded / light_square / dark_square / facebook */ 334 hook: 'data-gal', 335 social_tools: false 336 }); 337 }, 338 339 toggle_state: function (toggle_element) { 340 var active_class; 341 var current_content; 342 343 active_class = 'active-toggle'; 344 345 // close all others first 346 toggle_element.siblings().removeClass(active_class); 347 toggle_element.siblings().find('.toggle-content').slideUp("fast"); 348 349 current_content = toggle_element.find('.toggle-content'); 350 351 if (toggle_element.hasClass(active_class)) { 352 toggle_element.removeClass(active_class); 353 current_content.slideUp("fast"); 354 } 355 else { 356 toggle_element.addClass(active_class); 357 current_content.slideDown("fast"); 358 } 359 }, 360 361 validate_contact_form: function () { 362 /* ------------------- Contact Form Validation ------------------------ */ 363 var rules = { 364 contact_name: { 365 required: true, 366 minlength: 5 367 }, 368 contact_email: { 369 required: true, 370 email: true 371 }, 372 contact_phone: { 373 required: false, 374 minlength: 5 375 }, 376 contact_url: { 377 required: false, 378 url: true 379 }, 380 message: { 381 required: true, 382 minlength: 15 383 } 384 }; 385 var messages = { 386 contact_name: { 387 required: mo_theme.name_required, 388 minlength: mo_theme.name_format 389 }, 390 contact_email: mo_theme.email_required, 391 contact_url: mo_theme.url_required, 392 contact_phone: { 393 minlength: mo_theme.phone_required 394 }, 395 message: { 396 required: mo_theme.message_required, 397 minlength: mo_theme.message_format 398 } 399 }; 400 $("#content .contact-form").validate({ 401 rules: rules, 402 messages: messages, 403 errorClass: 'form-error', 404 submitHandler: function (theForm) { 405 $.post( 406 theForm.action, 407 $(theForm).serialize(), 408 function (response) { 409 $("#content .feedback").html('<div class="success-msg">' + mo_theme.success_message + '</div>'); 410 theForm.reset(); 411 }); 412 } 413 414 }); 415 $(".widget .contact-form").validate({ 416 rules: rules, 417 messages: messages, 418 errorClass: 'form-error', 419 submitHandler: function (theForm) { 420 $.post( 421 theForm.action, 422 $(theForm).serialize(), 423 function (response) { 424 $(".widget .feedback").html('<div class="success-msg">' + mo_theme.success_message + '</div>'); 425 theForm.reset(); 426 }); 427 } 428 429 }); 430 } 431 432 433 }; 434 435})(jQuery); 436 437/*======================== Document event handling ======================*/ 438 439jQuery(document).ready(function ($) { 440 441 "use strict"; 442 443 /* -------------------------- Initialize document based on platform type -------------------- */ 444 445 MO_THEME.add_body_classes(); 446 MO_THEME.manipulate_dom(); 447 448 /* ---------------------------------- Drop-down Menu.-------------------------- */ 449 450 MO_THEME.init_menus(); 451 452 /* --------- Back to top function ------------ */ 453 $(window).scroll(function () { 454 mo_wait_for_final_event(function () { 455 var yPos = $(window).scrollTop(); 456 /* show back to top after screen has scrolled down 200px from the top in desktop and big size tablets only */ 457 if (yPos > 200) { 458 if (!mo_options.disable_back_to_top) { 459 $("#go-to-top").fadeIn(); 460 } 461 } else { 462 $("#go-to-top").fadeOut(); 463 } 464 }, 200, 'go-to-top'); 465 }); 466 467 468 // Animate the scroll to top 469 $('#go-to-top').click(function (event) { 470 event.preventDefault(); 471 $('html, body').animate({scrollTop: 0}, 600); 472 }); 473 474 /* ------------------- Scroll Effects ----------------------------- */ 475 476 477 var width = $(window).width(); 478 if (width > 1100 && !mo_options.disable_animations_on_page && !mo_isIE() && !mo_isMobile()) { 479 MO_THEME.scroll_effects(); 480 } 481 else { 482 483 //Show stats without waiting for user to scroll to the element 484 MO_THEME.display_stats(); 485 486 MO_THEME.display_piecharts(); 487 488 // Show elements rightaway without animation 489 $('#feature-pointers img').css({ opacity: 1}); 490 } 491 492 /* ------------------- Tabs plus Tooltips ------------------------ */ 493 494 $("ul.tabs").tabs(".pane", { 495 onClick: function(event, tabIndex) { 496 var html_content = $('.js-isotope'); 497 // layout Isotope again after all images have loaded 498 html_content.imagesLoaded(function () { 499 html_content.isotope('layout'); 500 }); 501 } 502 }); 503 504 $(".social-list li a[title]").not('#sidebar-header .social-list li a').tooltip(); 505 506 $(".composite-page .page_section a.edit-button[title]").tooltip(); 507 508 509 /* ------------------- Back to Top and Close ------------------------ */ 510 511 $(".back-to-top").click(function (e) { 512 $('html,body').animate({ 513 scrollTop: 0 514 }, 600); 515 e.preventDefault(); 516 }); 517 518 $('a.close').click(function (e) { 519 e.preventDefault(); 520 $(this).closest('.message-box').fadeOut(); 521 }); 522 523 524 $(".toggle-label").toggle( 525 function () { 526 MO_THEME.toggle_state($(this).parent()); 527 }, 528 function () { 529 MO_THEME.toggle_state($(this).parent()); 530 } 531 ); 532 533 // Hide the honeypot trap field 534 $("p.trap-field").hide(); 535 536 MO_THEME.validate_contact_form(); 537 /* -------------------------------- PrettyPhoto Lightbox --------------------------*/ 538 539 540 MO_THEME.prettyPhoto(); 541 542 /* --------------------------- YouTube Video display ------------------------- */ 543 544 if (!mo_isMobile()) { 545 var video_showcase = $(".ytp-video-showcase .ytp-player"); 546 $(".ytp-video-showcase .ytp-player").mb_YTPlayer({ 547 startAt: 0, 548 showYTLogo: false, 549 showControls: false,
550 autoPlay: false, 551 mute: false 552 }); 553 554 $('.ytp-video-showcase .play-btn').click(function () { 555 // Hide the placeholder image when user clicks on play button 556 $('.ytp-video-showcase .img-bg').fadeOut(); 557 }); 558 559 var autoplay = $('.ytp-video-showcase .video-bg').data("video-autoplay"); 560 if (autoplay === true) { 561 $('.ytp-video-showcase .img-bg').fadeOut(); 562 } 563 564 video_showcase.on("YTPStart", function () { 565 jQuery(".ytp-video-showcase .video-controls").fadeIn(); 566 jQuery(".ytp-video-showcase .header-content").fadeOut(); 567 }); 568 video_showcase.on("YTPPause", function () { 569 jQuery(".ytp-video-showcase .video-controls").fadeOut(); 570 jQuery(".ytp-video-showcase .header-content").fadeIn(); 571 }); 572 573 var video_section = $(".ytp-video-section .ytp-player"); 574 video_section.mb_YTPlayer({ 575 startAt: 0, 576 showYTLogo: false, 577 showControls: false, 578 autoPlay: true, 579 mute: true 580 }); 581 582 } 583 584 /* --------------------------- HTML5 Video display ------------------------- */ 585 586 if (!mo_isMobile()) { 587 588 $('.video-showcase .play-btn').click(function () { 589 // Hide the placeholder image when user clicks on play button 590 $('.video-showcase .img-bg').fadeOut(); 591 jQuery(".video-showcase .video-controls").fadeIn(); 592 jQuery(".video-showcase .header-content").fadeOut(); 593 }); 594 595 $('.video-showcase .small-pause-btn').click(function () { 596 jQuery(".video-showcase .video-controls").fadeOut(); 597 jQuery(".video-showcase .header-content").fadeIn(); 598 }); 599 600 } 601 602 603 /*-----------------------------------------------------------------------------------*/ 604 /* jQuery isotope functions and Infinite Scroll 605 /*-----------------------------------------------------------------------------------*/ 606 607 $(function () { 608 609 if ($().isotope === undefined) { 610 return; 611 } 612 613 var html_content = $('.js-isotope'); 614 // layout Isotope again after all images have loaded 615 html_content.imagesLoaded(function () { 616 html_content.isotope('layout'); 617 }); 618 619 var container = $('#showcase-items'); 620 if (container.length === 0) { 621 return; 622 } 623 624 $('#showcase-filter a').click(function (e) { 625 e.preventDefault(); 626 627 var selector = $(this).attr('data-value'); 628 container.isotope({ filter: selector }); 629 return false; 630 }); 631 632 if (mo_options.ajax_showcase) { 633 if ($().infinitescroll !== undefined && $('.pagination').length) { 634 635 container.infinitescroll({ 636 navSelector: '.pagination', // selector for the paged navigation 637 nextSelector: '.pagination .next', // selector for the NEXT link (to page 2) 638 itemSelector: '.showcase-item', // selector for all items you'll retrieve 639 loading: { 640 msgText: mo_theme.loading_portfolio, 641 finishedMsg: mo_theme.finished_loading, 642 img: template_dir + '/images/loader.gif', 643 selector: '#main' 644 } 645 }, 646 // call Isotope as a callback 647 function (newElements) { 648 var $newElems = $(newElements); 649 $newElems.imagesLoaded(function () { 650 container.isotope('appended', $newElems); 651 }); 652 MO_THEME.prettyPhoto(); 653 }); 654 } 655 } 656 }); 657 658 /*-----------------------------------------------------------------------------------*/ 659 /* Handle videos in responsive layout - Credit - http://css-tricks.com/NetMag/FluidWidthVideo/Article-FluidWidthVideo.php 660 /*-----------------------------------------------------------------------------------*/ 661 662 $("#content, #sidebar-primary, #footer").fitVids(); 663 664 // Take care of maps too - https://github.com/davatron5000/FitVids.js - customSelector option 665 $("#content").fitVids({ customSelector: "iframe[src^='http://maps.google.com/'], iframe[src^='https://maps.google.com/'], iframe[src^='https://www.google.com/maps/'], iframe[src^='http://www.google.com/maps/']"}); 666 667 /*----------------- Parallax Effects - only on desktop ------------------ */ 668 669 width = $(window).width(); 670 if (width > 1100) { 671 672 $('.parallax-banner').parallax("50%", 0.6); 673 674 } 675 676 /*------------- Skrollr Animations Pre-setup ----------------*/ 677 678 $('#content > .hfeed > .page_section:first-child .video-showcase, #custom-title-area .video-showcase').wrap("<div class='dim-wrap'></div>"); 679 680 681}); 682 683jQuery(window).load(function () { 684 685 /*------------- Skrollr Animations ----------------*/ 686 687 var width = jQuery(window).width(); 688 if (width > 1100 && !mo_isIE() && !mo_isMobile()) { 689 690 jQuery('#title-area').wrap("<div class='dim-wrap'></div>").attr('data-top', "opacity:1;background-position: 0px 0px;").attr('data-top-bottom', "opacity: 0.6;background-position:0px -250px;"); 691 692 jQuery('#content > .hfeed > .page_section:first-child .video-showcase, #custom-title-area .video-showcase').attr('data-top', "opacity:1;transform: matrix(1, 0, 0, 1, 0, 0);").attr('data-top-bottom', "opacity: 0.6;transform:matrix(1, 0, 0, 1, 0, 450);"); 693 694 jQuery('#title-area h1, #title-area h2').attr('data-0', "opacity:1;").attr('data-top-bottom', "opacity: 0;"); 695 696 jQuery('#title-area p').attr('data-0', "opacity:1;").attr('data-top-bottom', "opacity: 0;"); 697 698 var s = skrollr.init({ 699 smoothScrolling: false, 700 forceHeight: false, 701 mobileCheck: function () { 702 return false;
703 } 704 }); 705 } 706 707 /*------------ Show the page now that all have been loaded ---------*/ 708 709 710 if (!mo_options.disable_smooth_page_load) { 711 jQuery("#page-loading").delay(500).fadeOut("slow"); 712 } 713 714 /* Temporary fix for Chrome 33 Build Fonts display issue */ 715 jQuery('body').width(jQuery('body').width() + 1).width('auto'); 716 717 718});
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.