1/* 2 Name: Bloggy 3 Description: Responsive Template 4 Version: 1.0 5 Author: Pixelwars 6*/ 7 8 9(function ($) { 10 11 /* DOCUMENT LOAD */ 12 $(function() { 13 14 15 16 //********************************** 17 //NAV MENU 18 $('.main-navigation li').hover(function() { 19 var subMenu = $(this).find('ul:first'); 20 $(this).siblings().find('a').removeClass("selected"); 21 //if has sub menu 22 if(subMenu.length) { 23 $(this).find('a').eq(0).addClass("selected"); 24 subMenu.show(); 25 } 26 }, function(e) { //hover out 27 var subMenu = $(this).find('ul:first'); 28 subMenu.hide(); 29 $(this).find('a').eq(0).removeClass("selected"); 30 }); 31 //NAV MENU 32 //********************************** 33 34 35 36 // MOBIL NAV MENU - SELECT LIST 37 //********************************** 38 /* Clone our navigation */ 39 var mainNavigation = $('.main-navigation > ul').clone(); 40 41 /* Replace unordered list with a "select" element to be populated with options, and create a variable to select our new empty option menu */ 42 $('.main-navigation').prepend('<select class="menu"></select>'); 43 var selectMenu = $('select.menu'); 44 //$(selectMenu).append('<option value="null">'+"MENU"+'</option>'); 45 46 /* Navigate our nav clone for information needed to populate options */ 47 $(mainNavigation).children('li').each(function() { 48 49 /* menu - LEVEL 1 */ 50 $(selectMenu).append(generateSelectLink($(this), '')); 51 52 /* menu - LEVEL 2 */ 53 if ($(this).children('ul').length > 0) { 54 $(this).children('ul').children('li').each(function() { 55 56 /* Append this option to our "select" */ 57 $(selectMenu).append(generateSelectLink($(this), ' » ')); 58 59 /* menu - LEVEL 3 */ 60 if ($(this).children('ul').length > 0) { 61 $(this).children('ul').children('li').each(function() { 62 63 /* Append this option to our "select" */ 64 $(selectMenu).append(generateSelectLink($(this), ' »» ')); 65 66 67 /* menu - LEVEL 4 */ 68 if ($(this).children('ul').length > 0) { 69 $(this).children('ul').children('li').each(function() { 70 71 /* Append this option to our "select" */ 72 $(selectMenu).append(generateSelectLink($(this), ' »»» ')); 73 74 });
75 } 76 77 }); 78 } 79 80 }); 81 } 82 }); 83 84 function generateSelectLink(li, prefix) { 85 var navLink = li.children('a'); 86 if(navLink.length) { 87 return '<option value="' + navLink.attr('href') + '"> ' + prefix + navLink.text() + '</option>'; 88 } 89 var sForm = li.children('form'); 90 if(sForm.length) { 91 return '<option value="search"> ' + sForm.find('label').text() + '</option>'; 92 } 93 } 94 95 /* When our select menu is changed, change the window location to match the value of the selected option. */ 96 $(selectMenu).change(function() { 97 98 var url = this.options[this.selectedIndex].value; 99 if(url == 'search') { 100 $('.search-mobile').slideDown().find('#search-mobile-input').focus(); 101 } else if (url != "null") { 102 location = this.options[this.selectedIndex].value; 103 } 104 }); 105 //********************************** 106 107 108 //********************************** 109 // header search 110 $('#header-search-link').click(function() { 111 $(this).toggleClass('active'); 112 $('.header-search').slideToggle(); 113 }); 114 //********************************** 115 116 117 118 //********************************** 119 // WP FIX 120 //button with icons 121 $('input[type=submit], input[type=button], button, a.button').each(function(index, element) { 122 if($(this).find('i').length) { 123 $(this).addClass('button-icon'); 124 } 125 }); 126 //********************************** 127 128 129 //********************************** 130 // CODE PRETTIFY 131 if($('.prettyprint').length) { 132 window.prettyPrint && prettyPrint(); 133 } 134 //********************************** 135 136 137 138 139 //********************************** 140 // UNIFORM 141 $("select:not([multiple]), input:checkbox, input:radio, input:file").uniform(); 142 var ua = navigator.userAgent.toLowerCase(); 143 var isAndroid = ua.indexOf("android") > -1; 144 if(isAndroid) { 145 $('html').addClass('android'); 146 } 147 //********************************** 148 149 150 151 152 //********************************** 153 // TABS 154 $('.tabs').each(function() { 155 if(!$(this).find('.tab-titles li a.active').length) { 156 $(this).find('.tab-titles li:first-child a').addClass('active'); 157 $(this).find('.tab-content > div:first-child').show(); 158 } else { 159 $(this).find('.tab-content > div').eq($(this).find('.tab-titles li a.active').parent().index()).show(); 160 } 161 }); 162 163 $('.tabs .tab-titles li a').click(function() { 164 if($(this).hasClass('active')) { return; } 165 $(this).parent().siblings().find('a').removeClass('active'); 166 $(this).addClass('active'); 167 $(this).parents('.tabs').find('.tab-content > div').hide().eq($(this).parent().index()).show(); 168 return false; 169 }); 170 //********************************** 171 172 173 //********************************** 174 // TOGGLES 175 var toggleSpeed = 300; 176 $('.toggle h4.active + .toggle-content').show(); 177 178 $('.toggle h4').click(function() { 179 if($(this).hasClass('active')) { 180 $(this).removeClass('active'); 181 $(this).next('.toggle-content').stop(true,true).slideUp(toggleSpeed); 182 } else { 183 184 $(this).addClass('active'); 185 $(this).next('.toggle-content').stop(true,true).slideDown(toggleSpeed); 186 187 //accordion 188 if($(this).parents('.toggle-group').hasClass('accordion')) { 189 $(this).parent().siblings().find('h4').removeClass('active'); 190 $(this).parent().siblings().find('.toggle-content').stop(true,true).slideUp(toggleSpeed); 191 } 192 193 } 194 return false; 195 }); 196 //********************************** 197 198 199 200 201 //********************************** 202 // RESPONSIVE VIDEOS 203 $(".media-wrap").fitVids(); 204 //********************************** 205 206 207 208 //********************************** 209 // PREVIEW ONLY - BUTTONS 210 $('.show-buttons a.button').click(function() { return false; }); 211 //********************************** 212 213 214 215 216 217 //********************************** 218 // PORTFOLIO FILTERING - ISOTOPE 219 // cache container 220 var $container = $('.portfolio-items'); 221 if($container.length) { 222 223 var page = 0, 224 itemPerPage = parseInt($container.attr('data-itemPerPage')), 225 result, 226 moreLink = $( '#loadmore' ); 227 var url = moreLink.attr('href'); 228 229 $container.imagesLoaded(function() { 230 231 setMasonry(); 232 $(window).resize(function() { 233 setMasonry(); 234 }); 235 236 // initialize isotope 237 $container.isotope({ 238 itemSelector: '.hentry', 239 layoutMode: 'masonry' 240 }); 241 242 // fix v1.1 243 setTimeout(function() { setMasonry(); $container.isotope({ filter: "*" }); }, 0); 244 245 // filter items when filter link is clicked 246 $('#filters a').click(function(){ 247 var selector = $(this).attr('data-filter'); 248 setMasonry(); 249 $container.isotope({ filter: selector }); 250 $(this).parent().addClass('current').siblings().removeClass('current'); 251 return false; 252 }); 253 254 }); 255 256 257 // Get All Images via Ajax 258 if(!$container.find('.hentry').length) { 259 260 $.get(url, function(data) { 261 result = data; 262 263 addItems();
264 265 ++page; 266 handleMoreLink(); 267 268 },'html'); 269 } 270 271 // Show more images 272 moreLink.on( 'click', function() { 273 274 moreLink.addClass('loading'); 275 addItems(); 276 ++page; 277 handleMoreLink(); 278 279 // fix v1.1 280 setTimeout(function() { setMasonry(); }, 0); 281 282 return false; 283 } ); 284 285 // Hide more link if there is no image left to show 286 function handleMoreLink() { 287 if(getNewItems().length == 0) { 288 moreLink.hide(); 289 } 290 } 291 292 // Get New Images 293 function getNewItems() { 294 var iMin = page * itemPerPage; 295 var iMax = iMin + itemPerPage; 296 297 return iMin == 0 ? $(result).find('.portfolio-items .hentry:lt('+ itemPerPage +')') 298 : $(result).find('.portfolio-items .hentry:gt(' + (iMin-1) +'):lt('+ itemPerPage +')'); 299 } 300 301 function addItems() { 302 var newItems = getNewItems(); 303 newItems.imagesLoaded(function() { 304 $container.removeClass('loading').isotope( 'insert', newItems ); 305 setupLigtbox(); 306 setMasonry(); 307 setTimeout( function() { moreLink.removeClass('loading'); }, 1000); 308 }); 309 } 310 311 } // if($container.length) 312 313 314 // change the number of masonry columns based on the current container's width 315 function setMasonry() { 316 317 var containerW = $container.width(); 318 var items = $container.children('.hentry'); 319 var columns, columnWidth; 320 var viewports = [ { 321 width : 1600, 322 columns : 6 323 }, { 324 width : 1200, 325 columns : 5 326 }, { 327 width : 900, 328 columns : 4 329 }, { 330 width : 500, 331 columns : 3 332 }, { 333 width : 320, 334 columns : 2 335 }, { 336 width : 0, 337 columns : 2 338 } ]; 339 340 for( var i = 0, len = viewports.length; i < len; ++i ) { 341 342 var viewport = viewports[i]; 343 344 if( containerW > viewport.width ) { 345 346 columns = viewport.columns; 347 break; 348 349 } 350 } 351 352 // set the widths (%) for each of item 353 items.each(function(index, element) { 354 var multiplier = $(this).hasClass('x2') ? 2 : 1; 355 var itemWidth = (Math.floor( containerW / columns ) * 100 / containerW) * multiplier ; 356 $(this).css( 'width', itemWidth + '%' ); 357 }); 358 if($container.isotope()) { 359 columnWidth = Math.floor( containerW / columns ); 360 $container.isotope( 'reLayout' ).isotope( 'option', { masonry: { columnWidth: columnWidth } } ); 361 } 362 363 } // setMasonry 364 365 //********************************** 366 367 368 369 370 371 372 //********************************** 373 /* Gamma Gallery */ 374 var gammaGallery = $('.gamma-gallery'); 375 if(gammaGallery.length) { 376 377 var g_page = 0, 378 g_itemPerPage = parseInt(gammaGallery.attr('data-itemPerPage')), 379 g_result, 380 g_moreLink = $( '#loadmore' ); 381 var g_url = g_moreLink.attr('href'); 382 383 var GammaSettings = { 384 interval : parseInt(gammaGallery.attr('data-slideshowInterval')), 385 circular : gammaGallery.attr('data-circular') != "false", 386 nextOnClickImage : gammaGallery.attr('data-nextOnClickImage') != "false", 387 // order is important! 388 viewport : [ { 389 width : 1200, 390 columns : 5 391 }, { 392 width : 900, 393 columns : 4 394 }, { 395 width : 500, 396 columns : 3 397 }, { 398 width : 320, 399 columns : 2 400 }, { 401 width : 0, 402 columns : 2 403 } ] 404 }; 405 406 407 // Get All Images via Ajax 408 if(!gammaGallery.find('li').length) { 409 410 $.get(g_url, function(data) { 411 g_result = data; 412 413 gammaGallery.html(getNewImages()); 414 ++g_page; 415 g_handleMoreLink(); 416 Gamma.init( GammaSettings ); 417 },'html'); 418 } else { 419 Gamma.init( GammaSettings ); 420 } 421 422 423 // Show more images 424 g_moreLink.on( 'click', function() { 425 g_moreLink.addClass('loading'); 426 Gamma.add( getNewImages(), function() { 427 setTimeout( function() { g_moreLink.removeClass('loading'); }, 1000); 428 } ); 429 g_page++; 430 g_handleMoreLink(); 431 return false; 432 } ); 433 434 // Hide more link if there is no image left to show 435 function g_handleMoreLink() { 436 if(getNewImages().length == 0) { 437 g_moreLink.hide(); 438 } 439 } 440 441 // Get New Images 442 function getNewImages() { 443 var iMin = g_page * g_itemPerPage; 444 var iMax = iMin + g_itemPerPage; 445 return iMin == 0 ? $(g_result).find('.gamma-gallery li:lt('+ g_itemPerPage +')') 446 : $(g_result).find('.gamma-gallery li:gt(' + (iMin-1) +'):lt('+ g_itemPerPage +')'); 447 } 448 449 }//if .gamma-gallery.length 450 //********************************** 451 452 453 454 455 // LIGHTBOX 456 //********************************** 457 setupLigtbox(); 458 //********************************** 459 460 461 // SHARE LINKS 462 //********************************** 463 $('.share-links').hover(function() { 464 $(this).find('.share-wrap').show(); 465 }); 466 467 $('body, body *').click(function (e) { 468 if ($(e.target).is('.share-links *')) return; 469 $('.share-links').find('.share-wrap').hide(); 470 }); 471 //********************************** 472 473 474 475 476 477 //********************************** 478 // BLOG MASONRY
479 // cache container 480 var $containerBlog = $('.blog-masonry'); 481 if($containerBlog.length) { 482 483 $containerBlog.imagesLoaded(function() { 484 485 setMasonryBlog(); 486 $(window).resize(function() { 487 setMasonryBlog(); 488 }); 489 490 // initialize isotope 491 $containerBlog.isotope({ 492 itemSelector : '.hentry', 493 layoutMode : 'masonry' 494 }); 495 496 setTimeout(function() { setMasonryBlog(); }, 1000); 497 498 }); 499 500 } // if($container.length) 501 502 503 // change the number of masonry columns based on the current container's width 504 function setMasonryBlog() { 505 506 var containerW = $containerBlog.width(); 507 var items = $containerBlog.children('.hentry'); 508 var columns, columnWidth; 509 var viewports = [ { 510 width : 1900, 511 columns : 5 512 }, { 513 width : 1200, 514 columns : 4 515 }, { 516 width : 768, 517 columns : 3 518 }, { 519 width : 480, 520 columns : 2 521 }, { 522 width : 0, 523 columns : 1 524 } ]; 525 526 for( var i = 0, len = viewports.length; i < len; ++i ) { 527 528 var viewport = viewports[i]; 529 530 if( containerW > viewport.width ) { 531 532 columns = viewport.columns; 533 break; 534 535 } 536 } 537 538 // set the widths (%) for each of item 539 items.each(function(index, element) { 540 var multiplier = $(this).hasClass('x2') ? 2 : 1; 541 var itemWidth = (Math.floor( containerW / columns ) * 100 / containerW) * multiplier ; 542 $(this).css( 'width', itemWidth + '%' ); 543 }); 544 if($containerBlog.isotope()) { 545 columnWidth = Math.floor( containerW / columns ); 546 $containerBlog.isotope( 'reLayout' ).isotope( 'option', { masonry: { columnWidth: columnWidth } } ); 547 } 548 549 } // setMasonry 550 551 //********************************** 552 553 554 555 556 557 //********************************** 558 /* FLEX SLIDER */ 559 // cache container 560 var $flexslider = $('.flexslider'); 561 if($flexslider.length) { 562 563 $flexslider.each(function() { 564 565 //wait for images 566 $(this).imagesLoaded(function() { 567 568 //remove loading 569 $(this).find('.loading').remove(); 570 571 //setup slider 572 $(this).flexslider({ 573 smoothHeight: true, 574 slideshow: $(this).attr('data-autoplay') != "false", 575 slideshowSpeed: $(this).attr('data-interval'), 576 animationSpeed : $(this).attr('data-animationSpeed'), 577 animation: $(this).attr('data-animation'), 578 direction : $(this).attr('data-direction'), 579 directionNav : $(this).attr('data-directionNav') != "false", 580 controlNav : $(this).attr('data-controlNav') != "false", 581 randomize : $(this).attr('data-randomize') == "true", 582 startAt : $(this).attr('data-startAt') != null ? parseInt($(this).attr('data-startAt')) : 0, 583 animationLoop : $(this).attr('data-animationLoop') != "false", 584 pauseOnHover : $(this).attr('data-pauseOnHover') != "false", 585 reverse : $(this).attr('data-reverse') == "true", 586 prevText: "", 587 nextText: "" 588 }); 589 590 }); 591 592 }); 593 } 594 //********************************** 595 596 597 598 //********************************** 599 /* MEDIAELEMENT.JS - self hosted html5 video and audio player */ 600 if($('video,audio').length) { 601 $('video,audio').mediaelementplayer({}); 602 } 603 //********************************** 604 605 606 607 608 //************************************* 609 // FORM VALIDATION - v1.1 610 611 // comment form validation fix 612 $('#commentform').addClass('validate-form'); 613 $('#commentform').find('input,textarea').each(function(index, element) { 614 if($(this).attr('aria-required') == "true") { 615 $(this).addClass('required'); 616 } 617 if($(this).attr('name') == "email") { 618 $(this).addClass('email'); 619 } 620 }); 621 622 // validate form 623 if($('.validate-form').length) { 624 $('.validate-form').each(function() { 625 $(this).validate(); 626 }); 627 } 628 //************************************* 629 630 631 //************************************* 632 // DETECT BLOG WITH SIDEBAR 633 if($('#secondary').length) { 634 $('#main > .row-fluid').addClass('blog-with-sidebar'); 635 } 636 //************************************* 637 638 639 }); 640 /* DOCUMENT LOAD */ 641 642 643 644 645 // ------------------------------ 646 // LIGHTBOX 647 function setupLigtbox() { 648 649 //html5 validate fix 650 $('.lightbox').each(function(index, element) { 651 $(this).attr('rel', $(this).attr('data-lightbox-gallery')); 652 }); 653 654 if($("a[rel^='fancybox']").length) { 655 $("a[rel^='fancybox']").fancybox({ 656 centerOnScroll : true, 657 padding : 0, 658 margin : 44, 659 width : 640, 660 height : 360, 661 transitionOut : 'none', 662 overlayColor : '#000', 663 overlayOpacity : '.9', 664 onComplete : function() { 665 if ($(this).attr('href').indexOf("soundcloud.com") >= 0) { 666 $('#fancybox-content').height(166); 667 } 668 } 669 }); 670 } 671 } 672 // ------------------------------ 673 674 675})(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.