1/** 2 * Virgo 3 */ 4 5var Design = { 6 7 data : { 8 9 activeSetLink : undefined, 10 timeOutId : undefined, 11 firstClickFlag : false, 12 centerVertical : undefined, 13 verticalMargin : 0, 14 slideshownavThreshold : 28, 15 calculatedMargin : 0, 16 thumbWidth: 0, 17 columnizeSlideThumbs: true 18 19 }, 20 21 22 init: function(){ 23 24 Design.data.thumbWidth = Cargo.Model.DisplayOptions.get('thumb_size').w; 25 26 if ( Cargo.Helper.isPhone() && Design.data.thumbWidth > Design.Mobile.data.thumbWidth ){ 27 28 Design.data.thumbWidth = Design.Mobile.data.thumbWidth ; 29 30 }; 31 32 // Don't allow padding set on Search view 33 if ( Cargo.Helper.IsSearch() ){ 34 35 Design.data.centerVertical = false; 36 37 } else { 38 39 Design.data.centerVertical = Cargo.Model.DisplayOptions.get('image_scale_vertical'); 40 41 } 42 43 if ( Cargo.Model.DisplayOptions.get("use_set_links") && Cargo.Model.DisplayOptions.get("projects_in_text_nav") ) { 44 45 Cargo.Collection.Navigation.url = Cargo.API.GetNavigationCargoPath(0, 9999); 46 Cargo.Collection.Navigation.fetch({reset: true}); 47 48 } 49 }, 50 51 Mobile : { 52 53 data : { 54 55 mobileMargin : 0, 56 thumbWidth : 240, 57 headerHeight: 0 58 59 }, 60 61 init: function(){ 62 63 64 if ( Cargo.Helper.isMobile() ) { 65 Design.Mobile.setMobileMargin(); 66 67 // Give button elements touch active state, allow :active styling 68 $('.project_nav a, .header_text a, .navigation_toggle').bind( "touchstart", function(){ 69 return true; 70 }); 71 72 73 // Deal with device rotations 74 $(window).resize(function(){ 75 76 setTimeout(function(){ 77 78 Design.SetProjectBlockImagePadding(); 79 80 }, 250); 81 82 }); 83 84 } 85 86 if ( Cargo.Helper.isTablet()){ 87 88 $('body').addClass("tablet"); 89 90 } 91 92 if ( Cargo.Helper.isPhone() ){ 93 $('body').addClass("mobile"); 94 $('body').css("max-width", screen.width + "px"); 95 $('head').append('<meta name="viewport" content="width=device-width">'); 96 97 Design.Mobile.data.headerHeight = $('.site_header').outerHeight(true); 98 99 // Set thumbnails to columnize at ideal width of 240 100 $('#thumbnails').attr("data-columnize-width", Design.Mobile.data.thumbWidth ); 101 102 103 $('.navigation_toggle').bind("click", function(){ 104 105 Design.Mobile.toggleNav(); 106 107 }); 108 109 $('.navigation').bind( "touchstart", function(e){ 110 111 var touchtarget = $(e.target); 112 113 if ( !touchtarget.is('a') ) { 114 115 Design.Mobile.toggleNav(); 116 117 } 118 119 }); 120 121 122 $(window).scroll(function() { 123 124 if ( $(window).scrollTop() > Design.Mobile.data.headerHeight){ 125 126 $('body').addClass("scrolled"); 127 128 } else { 129 130 $('body').removeClass("scrolled"); 131 132 } 133 134 }); 135 136 137 Cargo.Event.on("project_load_complete", function(pid) { 138 139 Design.Mobile.toggleNav(true); 140 141 }); 142 143 } 144 }, 145 146 setMobileMargin: function(){ 147 148 149 if ( Design.data.centerVertical ){ 150 151 152 var listenForChange = null, 153 prevHeight = 0, 154 currentHeight = 0; 155 156 157 // Deal with iOS UI Chrome 158 clearInterval(listenForChange); 159 160 listenForChange = setInterval(function(){ 161 162 currentHeight = window.innerHeight; 163 164 if (currentHeight !== prevHeight ) { 165 166 Design.Mobile.data.mobileMargin = document.documentElement.clientHeight - window.innerHeight; 167 Design.setVerticalMargin(); 168 Cargo.Plugins.elementResizer.refresh(); 169 170 } 171 172 prevHeight = currentHeight; 173 174 }, 100); 175 176 177 } 178 }, 179 180 181 toggleNav: function(closeNav){ 182 183 if ( $('.navigation_toggle').is(".active") || closeNav ){ 184 185 $(".navigation, .navigation_toggle").removeClass("active"); 186 187 } else { 188 189 $(".navigation, .navigation_toggle").addClass("active"); 190 191 } 192 193 } 194 195 }, 196 197 setVerticalMargin: function(){ 198 Design.data.calculatedMargin = 0; 199 200 // Set additional margin for slideshow text nav on top 201 if ( $('.first_block').is('.slide.block') && 202 Cargo.Model.DisplayOptions.get("slide_text_nav").enabled ){ 203 204 Design.data.calculatedMargin = Design.data.slideshownavThreshold * 2; 205 206 } 207 208 // Set Margin from project content top 209 if ( $('.project_content').length > 0 ){ 210 211 Design.data.verticalMargin = $(".project_content", Cargo.View.ProjectDetail.$el).offset().top * 2; 212 213 } 214 215 Cargo.Plugins.elementResizer.setOptions({ 216 217 adjustElementsToWindowHeight: Design.data.centerVertical, 218 forceVerticalMargin: ( Design.data.verticalMargin + Design.data.calculatedMargin) + Design.Mobile.data.mobileMargin 219 220 }); 221 222 223 }, 224 225 226 /** 227 * Set the padding of each image block inside the content 228 * to ensure that each block has enough padding to show completely 229 */ 230 SetProjectBlockImagePadding: function(el, obj){ 231 232 if ( $(".project_content", Cargo.View.ProjectDetail.$el).length < 1 ){ 233 return 234 } 235 236 var container_height = window.innerHeight, 237 parentBlock, 238 padding, 239 topPadding, 240 bottomPadding, 241 this_height; 242 243 if(el !== undefined){ 244 245 // if slideshow transition, we just change one block 246 parentBlock = el.closest('.block'); 247 248 } else { 249 250 // if not slideshow transition, we change all blocks 251 parentBlock = $(".project_content .block", Cargo.View.ProjectDetail.$el); 252 253 } 254 255 parentBlock.each(function(){ 256 257 // for slideshow transitions 258 if (el !== undefined){ 259 260 // For navigating straight to the thumbnails 261 //if ( obj.getActiveSlide().height() < 1 ) 262 263 this_height = obj.getActiveSlide().height() + (el.height() - $('.slideshow_container', el).height() ); 264 265 if (this_height < 1){ 266 267 padding = 0; 268 Design.RemoveSlideBlockTransitions(el); 269 270 $(this).css("visibility", "visible"); 271 272 } else { 273 274 padding = Math.max(((container_height - this_height) / 2), 0); 275 276 $(this).css({ 277 'height': this_height+'px', 278 'visibility': 'visible' 279 }); 280 281 } 282 283 // for everything else 284 } else { 285 286 this_height = $(this).height(); 287 288 if( $(this).is('.slide') ){ 289 290 291 // if not transition, but still a slideshow. setting height prevents bottom from creeping up 292 this_height = $('.slideshow', this).height() ; 293 $(this).css("height", this_height + "px"); 294 295 } else { 296 297 $(this).css("height", "auto"); 298 299 } 300 301 padding = Math.max(Math.floor((container_height - this_height) / 2), 0); 302 303 }; 304 305 topPadding = Math.max(padding - $(".project_content", Cargo.View.ProjectDetail.$el).offset().top, 0); 306 bottomPadding = Math.max(padding - ( $(".project_footer", Cargo.View.ProjectDetail.$el).outerHeight(true) ), 0 ); 307 308 $(this).css({ 309 'padding-top' : padding + 'px', 310 'padding-bottom' : padding + 'px' 311 }); 312 313 if ( $(this).is(".first_block") ){ 314 315 $(this).css({ 316 'padding-top' : topPadding + 'px' 317 }); 318 319 } 320 321 if ($(this).is(".last_block") && !$('body').is('.mobile') ) { 322 323 $(this).css({ 324 'padding-bottom' : bottomPadding + 'px' 325 }); 326 327 } 328 329 330 }); 331 332 }, 333 334 335 SetSlidecontainerTransition : function(){ 336 337 if ( $('#slideContainerTransition').length < 1 ) { 338 339 $('head').append('<style id="slideContainerTransition"></style>'); 340 341 }; 342 343 var slideTransitionLength = Cargo.Model.DisplayOptions.get("slide_transition_duration"); 344 345 $('#slideContainerTransition').text( 346 '.slideshow.slideshow_transitioning .slideshow_container { \n\ 347 -webkit-transition: all ' +slideTransitionLength + 's ease; \n\ 348 -moz-transition: all ' + slideTransitionLength + 's ease; \n\ 349 -ms-transition: all ' + slideTransitionLength + 's ease; \n\ 350 transition: all ' + slideTransitionLength + 's ease; \n\ 351 }' 352 ); 353 354 }, 355 356 SetSlideshowWidth: function(){ 357 var largeWidth, projectContentWidth; 358 359 if ( $('#slideshowWidth').length < 1 ) { 360 361 $('head').append('<style id="slideshowWidth"></style>'); 362 363 }; 364 365 if ( Cargo.View.ProjectDetail !== undefined ) { 366 largeWidth = $(Cargo.View.ProjectDetail.$el).width(); 367 projectContentWidth = $(".project_content", Cargo.View.ProjectDetail.$el).width(); 368 369 } else { 370 371 largeWidth = $('body').width(); 372 projectContentWidth = largeWidth; 373 374 } 375 376 $('#slideshowWidth').text( 377 '.slideshow { \n\ 378 width: ' + largeWidth + 'px !important; \n\ 379 margin-left: -' + ((largeWidth - projectContentWidth) / 2) + 'px !important; \n\ 380 }' 381 ); 382 383 }, 384 385 RemoveSlideBlockTransitions: function(el){ 386 387 var styleTag = $("#slideblockTransition_" + el.attr('data-id')); 388 389 if ( styleTag.length > 0){ 390 391 styleTag[0].disabled = true; 392 393 } 394 395 }, 396 397 398 SetSlideBlockTransitions: function(el) { 399 400 401 var dataId = el.attr('data-id'), 402 styleTag = $('#slideblockTransition_' + dataId), 403 slideTransitionLength = Cargo.Model.DisplayOptions.get("slide_transition_duration"); 404 405 if (styleTag.length > 0 ) { 406 407 styleTag[0].disabled = false;
408 409 } else { 410 411 $('head').append('<style id="slideblockTransition_' + dataId + '"></style>'); 412 413 $('#slideblockTransition_' + dataId).text( 414 '#slideblock_' + dataId + '.slide.block { \n\ 415 -webkit-transition: all ' + slideTransitionLength + 's ease; \n\ 416 -moz-transition: ' + slideTransitionLength + 's all ease; \n\ 417 -ms-transition: all ' + slideTransitionLength + 's ease; \n\ 418 transition: all ' + slideTransitionLength + 's ease; \n\ 419 }' 420 ); 421 422 } 423 424 }, 425 426 427 ResizeWindowListener: function() { 428 429 clearTimeout(Design.data.timeOutId); 430 431 if(!Design.data.firstClickFlag){ 432 433 Cargo.Event.trigger("site_resize_start", "Cargo"); 434 Design.data.firstClickFlag = true; 435 436 } 437 438 Design.data.timeOutId = setTimeout(function(){ 439 440 Design.data.firstClickFlag = false; 441 Cargo.Event.trigger("site_resize_end", "Cargo"); 442 443 }, 80); 444 445 }, 446 447 448 /** 449 * Wrap all contents inside div blocks 450 */ 451 FormatProjectContent: function() { 452 453 $(".project_content", Cargo.View.ProjectDetail.$el) 454 .contents() 455 .filter(function() { 456 return this.nodeName == "IMG"; 457 }) 458 .wrap('<div class="block image" />') 459 .end(); 460 461 $(".audio_component", Cargo.View.ProjectDetail.$el).wrap('<div class="block audio" />'); 462 $(".project_content > div", Cargo.View.ProjectDetail.$el).each(function(){ 463 464 if (this.attributes.length ===0 ){ 465 466 $(this).addClass('block text'); 467 468 } 469 470 }); 471 472 $(".slideshow", Cargo.View.ProjectDetail.$el).each(function(){ 473 $(this).wrap('<div id="slideblock_'+ $(this).attr("data-id")+'" class="block slide" />'); 474 }); 475 476 $(".project_content > .video_component", Cargo.View.ProjectDetail.$el).not('.slideshow .video_component').wrap('<div class="block video" />'); 477 $(".project_content > iframe", Cargo.View.ProjectDetail.$el).not('.slideshow iframe').wrap('<div class="block iframe" />'); 478 479 // Format the text into blocks 480 this.formatText($(".project_content")); 481 482 483 $('.block:first-child', Cargo.View.ProjectDetail.$el).addClass('first_block'); 484 $('.block:last-child', Cargo.View.ProjectDetail.$el).addClass('last_block'); 485 486 $('.block', Cargo.View.ProjectDetail.$el).each(function(i){ 487 488 $(this).attr("data-block", i); 489 490 }); 491 492 }, 493 494 495 formatText: function(node, includeWhitespaceNodes) { 496 497 var c = node.contents(), 498 validTags = ['img', 'object', 'video', 'audio', 'iframe', 'div'], 499 pageCache = [], 500 pageCount = 0, 501 textPages = {}, 502 newPageFromCache = true; 503 504 c.each(function(key, val) { 505 506 if ($.inArray(getTag(val), validTags) >= 0) { 507 // save cache as new page 508 if (pageCache.length > 0) { 509 textPages[pageCount] = pageCache; 510 pageCache = []; 511 pageCount++; 512 } 513 } else { 514 if (isValidText(val.data) && val.nodeType != 8) { 515 pageCache.push(val); 516 } 517 } 518 519 }); 520 521 // Still some stuff left in cache 522 if (pageCache.length > 0) { 523 // Check if it needs a new page 524 for (var i = 0; i < pageCache.length; i++) { 525 if (pageCache[i].nodeType == 8 || pageCache[i].nodeName == "SCRIPT" || pageCache[i].nodeName == "STYLE") { 526 // Contains text, create new page 527 newPageFromCache = false; 528 } 529 } 530 531 if (newPageFromCache) { 532 // Create new page 533 textPages[pageCount] = pageCache; 534 pageCache = []; 535 pageCount++; 536 } else { 537 for (var i = 0; i < pageCache.length; i++) { 538 // Dump and hide remaining elements 539 $(pageCache[i]).hide().appendTo($('.project_footer')); 540 } 541 } 542 } 543 544 $.each(textPages, function(key, arr) { 545 var breaks = 0; 546 547 $.each(arr, function(key, el) { 548 if (el.nodeName == "BR") { 549 breaks++; 550 } 551 }); 552 553 if (breaks < arr.length) { 554 var first = arr[0]; 555 var parent = $('<div class="text" />'); 556 $(first).before(parent); 557 558 $.each(arr, function(key, el) { 559 $(el).appendTo(parent); 560 }); 561 } else { 562 $.each(arr, function(key, el) { 563 $(el).remove(); 564 }); 565 } 566 }); 567 568 function isValidText(txt, strict) { 569 if (txt !== undefined) { 570 txt = txt.replace(/<!--([\s\S]*?)-->/mig, ""); 571 txt = txt.replace(/(\r\n|\n|\r|\t| )/gm, ""); 572 txt = txt.replace(/[^A-Za-z0-9\s!?\.,-\/#!$%\^&\*;:{}=\-_`~()[[\]]/g, ""); 573 574 if (txt.length > 0) { 575 return true; 576 } 577 } else { 578 if (strict) { 579 return false;
580 } else { 581 return true; 582 } 583 } 584 585 return false; 586 } 587 588 function getTag(el) { 589 if (typeof el !== "undefined") { 590 var tag = el.tagName; 591 if (typeof tag === "undefined") { 592 tag = 'text'; 593 } 594 595 return tag.toLowerCase(); 596 } 597 } 598 }, 599 600 601 scroll: { 602 603 indexPosition : 0, 604 605 defaultScroll : function() { 606 // Configured on setup 607 }, 608 609 610 project : function() { 611 612 // Set the data if we were on an index page 613 if ( ! $('body').is('[data-pagetype]') ) { 614 615 this.indexPosition = $(window).scrollTop(); 616 617 } 618 619 // Default scroll method 620 //Design.scroll.defaultScroll(); 621 622 }, 623 624 index : function() { 625 626 $(window).scrollTop(this.indexPosition); 627 628 }, 629 630 setup : function() { 631 632 var self = this; 633 634 // Set the default scroll event 635 this.defaultScroll = Cargo.Helper.ScrollToTop; 636 637 // Reset helper methods 638 Cargo.Helper.ScrollToTop = function() { 639 640 // Only scroll if project/page is open 641 if ( Cargo.Helper.GetCurrentPageType() ){ 642 643 Design.scroll.defaultScroll(); 644 645 } 646 647 648 // Close mobile nav if on Phone 649 if( Cargo.Helper.isPhone()){ 650 651 Design.Mobile.toggleNav(true); 652 653 } 654 }; 655 656 } 657 658 }, 659 660 661 keybindings: function() { 662 663 // Remove previous bindings 664 Cargo.Core.KeyboardShortcut.Remove("Left"); 665 Cargo.Core.KeyboardShortcut.Remove("Right"); 666 667 Cargo.Core.KeyboardShortcut.Add("Left", 37, function() { 668 Action.Project.Prev(); 669 return false; 670 }); 671 672 Cargo.Core.KeyboardShortcut.Add("Right", 39, function() { 673 Action.Project.Next(); 674 return false; 675 }); 676 677 Cargo.Core.KeyboardShortcut.Add("Escape", 27, function() { 678 679 // Don't go to index if lightbox is open 680 if ( lightbox.isActive ){ 681 return; 682 683 } else { 684 Action.Project.Index(); 685 return; 686 } 687 688 }); 689 690 }, 691 692 clickBlockToAdvance: function(speed, clickToThumbs) { 693 694 var clickToThumbs = clickToThumbs, 695 transitionSpeed = speed, 696 lastIndex = $('.project_content .block').length - 1, 697 currentIndex = 0; 698 699 $('.project_content .block').click(function(){ 700 701 currentIndex = parseInt($(this).attr("data-block")); 702 nextIndex = currentIndex + 1; 703 704 if ( currentIndex == lastIndex && !clickToThumbs ) { 705 706 $('body, html').animate({ 707 'scrollTop' : 0 708 }, ( lastIndex * transitionSpeed + transitionSpeed ) / 5 ); 709 710 } else if (currentIndex == lastIndex && clickToThumbs ) { 711 712 $('body, html').animate({ 713 'scrollTop' : $('.thumbnails').offset().top 714 }, transitionSpeed ); 715 716 } else { 717 718 $('body, html').animate({ 719 'scrollTop' : $('.block[data-block="'+ nextIndex +'"]').offset().top 720 }, transitionSpeed ); 721 722 }; 723 724 }); 725 726 }, 727 728 randomizeThumbnails: function() { 729 730 var thumbs = $(".thumbnail[data-randomized!='true']"); 731 732 thumbs.attr('data-randomized', 'true'); 733 thumbs.shuffle(); 734 735 }, 736 737 formatThumbnails: function() { 738 739 $(".thumbnail[data-formatted!='true']").each(function() { 740 741 if ($(this).find(".thumb_image img").attr("src") == "/_gfx/thumb_custom.gif") { 742 $(this).addClass("default_thumb"); 743 } 744 745 $(this).attr("data-formatted", "true"); 746 747 }); 748 749 }, 750 751 formatNavigation: function() { 752 753 if ( Cargo.Model.DisplayOptions.get("use_set_links") ) { 754 755 if ( Cargo.Model.DisplayOptions.get("projects_in_text_nav") === false ) { 756 $('.set_link').addClass('no_projects'); 757 } 758 759 760 $(".set_link").each(function(i){ 761 762 if ( $(this).prev().not(".set_wrapper, .set_link.no_projects").length > 0 ) { 763 $(this).addClass("first") 764 } 765 766 if ( $(this).next().not(".set_link").length > 0 ) { 767 $(this).addClass("last") 768 } 769 770 }) 771 772 } 773 774 } 775 776}; 777 778/** 779 * Events 780 */ 781 782$(function() { 783 $('body').css('visibility', 'hidden'); 784 785 if ( Cargo.View.ProjectDetail !== undefined ) { 786 Design.init(); 787 Design.Mobile.init(); 788 $('body').css('visibility', 'visible'); 789 Design.scroll.setup(); 790 Design.keybindings(); 791 792 if ( !Cargo.Helper.IsSearch() ) { 793 794 Design.SetSlideshowWidth(); 795 Design.SetSlidecontainerTransition(); 796 Design.formatThumbnails(); 797 798 } 799 800 Design.formatNavigation(); 801 802 } else { 803 $('body').css('visibility', 'visible'); 804 } 805 806}); 807 808$(window).resize(function(){ 809 810 Design.ResizeWindowListener(); 811 Design.SetSlideshowWidth(); 812 813 if ( Design.data.centerVertical ) { 814 815 Design.SetProjectBlockImagePadding(); 816 817 } 818 819}); 820 821Cargo.Event.on("site_resize_start", function() { 822 if ( Design.data.centerVertical ) { 823 Design.SetProjectBlockImagePadding(); 824 } 825 826}); 827 828Cargo.Event.on("site_resize_end", function() { 829 830 if ( Design.data.centerVertical ) { 831 832 Design.SetProjectBlockImagePadding(); 833 834 } 835 836}); 837 838Cargo.Event.on("slideshow_thumbnails_toggle", function(el, obj) { 839 840 if ( Design.data.centerVertical ) { 841 Design.SetProjectBlockImagePadding(el, obj); 842 } 843 844}); 845 846 847Cargo.Event.on("slideshow_on", function(el, obj) { 848 849 // Fix for firefox sloppy resize 850 851 _.delay(function(){ 852 obj.endTransition(); 853 }, 15) 854 855 $(el).removeClass("slideshow_transitioning"); 856 857 $('.slideshow .video_component').each(function(){ 858 859 $(this).attr({ 860 861 width: $('object', this).attr("width"), 862 height: $('object', this).attr("height"), 863 "data-elementresizer-child": "data-elementresizer-child" 864 865 }); 866 867 }); 868 869 870 Cargo.Plugins.elementResizer.refresh(); 871 872 // Add classes for slideshow if nav is active 873 if ( Cargo.Model.DisplayOptions.get("slide_text_nav").enabled ) { 874 875 if ( Cargo.Model.DisplayOptions.get("slide_nav_position") == "top" ){ 876 877 el.addClass("slideshow_navigation_on_top"); 878 879 } else { 880 881 el.addClass("slideshow_navigation_on_bottom"); 882 883 } 884 885 } 886 887 888 $('.slideshow_toggle_thumbnails').click(function(){ 889 890 Design.RemoveSlideBlockTransitions(el); 891 el.find('.slideshow_thumbnails img.slideshow_active').removeClass('slideshow_active') 892 893 if ( Design.data.centerVertical ) { 894 895 window.requestAnimationFrame(function(){ 896 897 Cargo.Plugins.columnizer.updateTargets(); 898 Design.SetProjectBlockImagePadding(); 899 900 }); 901 902 } else { 903 904 window.requestAnimationFrame(function(){ 905 906 Cargo.Plugins.columnizer.updateTargets(); 907 908 }); 909 910 } 911 912 }); 913 914 915 if ( Design.data.centerVertical ) { 916 917 Design.SetProjectBlockImagePadding(el, obj); 918 919 } 920 921 $('.slideshow_thumbnails > *', el).click(function(){ 922 923 // hack to prevent flashing on click 924 el.find('.slideshow_container').css('visibility', 'hidden') 925 if ( Design.data.centerVertical ){ 926 927 if (el.closest('.block').is('[data-block="0"]') && el.closest('.block').is('.project_content > div:first-child') ){ 928 929 $('body, html').scrollTop( 0 ); 930 931 } else { 932 933 $('body, html').scrollTop( el.closest('.block').offset().top); 934 935 } 936 937 } else { 938 939 $('body, html').scrollTop( el.offset().top ); 940 941 }; 942 943 Design.RemoveSlideBlockTransitions(el); 944 945 }); 946 947}); 948 949 950Cargo.Event.on("element_resizer_init", function(plugin) { 951 952 Design.setVerticalMargin(); 953 954}); 955 956 957Cargo.Event.on("slideshow_transition_start", function(el, obj) { 958 Design.SetSlideBlockTransitions(el); 959 Design.SetProjectBlockImagePadding(el, obj); 960 el.find('.slideshow_thumbnails img.slideshow_active').removeClass('slideshow_active') 961 962}); 963 964Cargo.Event.on("slideshow_transition_finish", function(el, obj) { 965 966 el.find('.slideshow_container').css('visibility', '') 967 Design.RemoveSlideBlockTransitions(el); 968 $('#slideContainerTransition')[0].disabled = false;
969 Design.SetProjectBlockImagePadding(el, obj); 970 971}); 972 973Cargo.Event.on("fullscreen_destroy_hotkeys", function() { 974 975 Design.keybindings(); 976 977}); 978 979Cargo.Event.on("columnizer_update_complete", function() { 980 981 if ( Design.data.centerVertical ){ 982 983 Design.SetProjectBlockImagePadding(); 984 985 } 986 987}); 988 989Cargo.Event.on("columnizer_update_targets", function() { 990 991 if ( Cargo.Model.DisplayOptions.get('randomize_thumbs') ) { 992 Design.randomizeThumbnails(); 993 } 994 995 if ( Design.data.centerVertical ){ 996 Design.SetProjectBlockImagePadding(); 997 } 998 999}); 1000 1001Cargo.Event.on("project_collection_reset", function() { 1002 1003 if ( Design.data.centerVertical ){ 1004 1005 Design.SetProjectBlockImagePadding(); 1006 1007 } 1008 1009 Design.formatThumbnails(); 1010 1011}); 1012 1013Cargo.Event.on("direct_link_loaded", function(){ 1014 1015 Design.init(); 1016 Design.SetSlideshowWidth(); 1017 Cargo.Plugins.elementResizer.refresh(); 1018 1019}); 1020 1021Cargo.Event.on("project_load_start", function(pid) { 1022 1023 Design.scroll.project(); 1024 1025}); 1026 1027 1028Cargo.Event.on("project_load_complete", function(pid) { 1029 1030 if ( Cargo.View.ProjectDetail !== undefined ) { 1031 1032 var imgs, 1033 randomImgIndex; 1034 1035 Design.SetSlideshowWidth(); 1036 1037 //set splash page 1038 if ( $('.splash', Cargo.View.ProjectDetail.$el).length > 0){ 1039 1040 1041 $('#thumbnails').hide(); 1042 1043 // select random image in the splash 1044 $('.splash', Cargo.View.ProjectDetail.$el).each(function(){ 1045 1046 if ( $(this).is('a') && !$(this)[0].attributes.href ) { 1047 1048 $(this).css("cursor", "pointer").attr("rel", "show_index"); 1049 1050 }; 1051 1052 imgs = $('img', this); 1053 randomImgIndex = Math.floor( Math.random() * imgs.length ); 1054 1055 $(this).css("background-image", "url(" + imgs.eq( randomImgIndex ).attr("src_o") + ")"); 1056 1057 }); 1058 1059 $('.project_footer').hide(); 1060 1061 } 1062 1063 // Remove active state on Set link if thumbnails are hidden 1064 if ( (Cargo.Helper.GetCurrentPageType() =="page" && !Cargo.Model.DisplayOptions.get("thumbs_below_pages") && Cargo.Helper.IsOnSet()) || 1065 $('.splash', Cargo.View.ProjectDetail.$el).length > 0) { 1066 1067 $('.set_link.active').removeClass("active"); 1068 1069 } 1070 1071 1072 1073 if ( Design.data.centerVertical && Cargo.Helper.GetCurrentPageType() !== "page"){ 1074 1075 Design.FormatProjectContent(); 1076 Design.setVerticalMargin(); 1077 Cargo.Plugins.elementResizer.refresh(); 1078 Design.SetProjectBlockImagePadding(); 1079 1080 /* hack for direct links */ 1081 setTimeout(function(){ 1082 1083 if ( !Design.data.columnizeSlideThumbs ) { 1084 $('.slideshow_thumbnails').removeAttr("data-columnize"); 1085 1086 $('.slideshow_thumbnails .column').each(function(){ 1087 $('.padding_helper', this).unwrap(); 1088 $(this).unwrap(); 1089 }) 1090 1091 if (Cargo.Plugins.hasOwnProperty("columnizer")) { 1092 Cargo.Plugins.columnizer.updateTargets(); 1093 } 1094 } 1095 1096 Design.SetProjectBlockImagePadding(); 1097 1098 }, 10); 1099 } 1100 1101 } 1102 1103/* 1104 if (Cargo.Model.Project.GetType() == "project") { 1105 if (!Cargo.Model.DisplayOptions.attributes.thumbs_below_projects || Cargo.Helper.IsOnSet()) { 1106 $(".show_index").show(); 1107 } 1108 } 1109 */ 1110 1111 if ( Design.data.columnizeSlideThumbs ) { 1112 1113 $('.slideshow_thumbnails').each(function(){ 1114 1115 this.setAttribute('data-columnize', 'img'); 1116 this.setAttribute('data-columnize-equalize', 'true'); 1117 this.setAttribute('data-columnize-width', Design.data.thumbWidth); 1118 this.setAttribute('data-columnize-fluid', 'true'); 1119 1120 }); 1121 1122 } 1123 1124}); 1125 1126 1127Cargo.Event.on("pagination_complete", function() { 1128 1129 if (Cargo.Plugins.hasOwnProperty("columnizer")) { 1130 Cargo.Plugins.columnizer.updateTargets(); 1131 } 1132 1133 Design.formatThumbnails(); 1134 1135}); 1136 1137Cargo.Event.on("navigation_reset", function() { 1138 Design.formatNavigation(); 1139}); 1140 1141// Re-trigger start page active state after nav is reloaded 1142Cargo.Event.on("navigation_reset project_load_complete", function(){ 1143 if ( $('body').is('.start_project') || Cargo.Helper.IsOnStartProject() ) { 1144 $('#menu_' + Cargo.Helper.GetStartProjectId() ).addClass("active"); 1145 } 1146}); 1147 1148 1149Cargo.Event.on("inspector_open", function() { 1150 1151 var prevProjectOffset = 0, 1152 currProjectOffset = 0; 1153 1154 setInterval(function(){ 1155 1156 if ( $('.project_content').length > 0) { 1157 1158 currProjectOffset = $('.project_content', Cargo.View.ProjectDetail.$el).offset().top; 1159 1160 if ( currProjectOffset !== prevProjectOffset ) { 1161 1162 Design.setVerticalMargin(); 1163 Cargo.Plugins.elementResizer.refresh(); 1164 Design.SetProjectBlockImagePadding(); 1165 1166 } 1167 1168 prevProjectOffset = currProjectOffset; 1169 } 1170 1171 }, 400); 1172 1173}); 1174 1175 1176$(document).ready(function(){ 1177 1178 Cargo.Event.on("show_index_complete", function(pid) { 1179 1180 Design.scroll.index(); 1181 1182 if (Cargo.Plugins.hasOwnProperty("columnizer")) { 1183 Cargo.Plugins.columnizer.updateTargets(); 1184 } 1185 1186 }); 1187 1188}); 1189 1190 1191/** 1192 * Shuffling
1193 * http://css-tricks.com/snippets/jquery/shuffle-dom-elements/ 1194 */ 1195 1196(function($){ 1197 1198 $.fn.shuffle = function() { 1199 1200 var allElems = this.get(), 1201 getRandom = function(max) { 1202 return Math.floor(Math.random() * max); 1203 }, 1204 shuffled = $.map(allElems, function(){ 1205 var random = getRandom(allElems.length), 1206 randEl = $(allElems[random]).clone(true)[0]; 1207 allElems.splice(random, 1); 1208 return randEl; 1209 }); 1210 1211 this.each(function(i){ 1212 $(this).replaceWith($(shuffled[i])); 1213 }); 1214 1215 return $(shuffled); 1216 1217 }; 1218 1219})(jQuery); 1220 1221// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ 1222// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating 1223 1224// requestAnimationFrame polyfill by Erik Moeller. fixes from Paul Irish and Tino Zijdel 1225 1226// MIT license 1227 1228(function() { 1229 var lastTime = 0; 1230 var vendors = ['ms', 'moz', 'webkit', 'o']; 1231 for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { 1232 window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; 1233 window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] 1234 || window[vendors[x]+'CancelRequestAnimationFrame']; 1235 } 1236 1237 if (!window.requestAnimationFrame) 1238 window.requestAnimationFrame = function(callback, element) { 1239 var currTime = new Date().getTime(); 1240 var timeToCall = Math.max(0, 16 - (currTime - lastTime)); 1241 var id = window.setTimeout(function() { callback(currTime + timeToCall); }, 1242 timeToCall); 1243 lastTime = currTime + timeToCall; 1244 return id; 1245 }; 1246 1247 if (!window.cancelAnimationFrame) 1248 window.cancelAnimationFrame = function(id) { 1249 clearTimeout(id); 1250 }; 1251}());
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.