1"use strict"; 2 3(function($, window, Popcorn){ 4 5 var vvg = { 6 } 7 8 window.vvg = vvg; 9 10 $(function(){ 11 function activateGalleryItem($item){ 12 var data = $item.data(); 13 var $gallery = $item.closest('.vvg-gallery'); 14 var $overlay = $gallery.find('.vvg-gallery-overlay'); 15 var $video = $overlay.find('.vvg-video'); 16 var $overlay_prev = $overlay.find('.prev'); 17 var $overlay_current = $overlay.find('.current'); 18 var $overlay_next = $overlay.find('.next'); 19 var $share = $overlay.find('.vvg-share'); 20 21 $video.html(''); 22 23 var $prev = $item.parent('.vvg-gallery-item').prev().find('a'); 24 var $next = $item.parent('.vvg-gallery-item').next().find('a'); 25 26 27 if( ! $prev.length){ 28 $prev = $item.parent('.vvg-gallery-item').siblings(':last').find('a'); 29 } 30 if( ! $next.length){ 31 $next = $item.parent('.vvg-gallery-item').siblings(':first').find('a'); 32 } 33 $overlay_prev.html('<a href="#"><span class="text">' + $prev.data('name') + '</span></a>'); 34 $overlay_prev.find('a').data('vvg-anchor', $prev); 35 $overlay_current.html('<span>'+data.name+'</span>'); 36 37 var encoded_video_url = encodeURI(data.video); 38 $share.html(''); 39 $share.append('<span class="facebook"><a href="https://www.facebook.com/sharer/sharer.php?u=' + encoded_video_url + '" target="_blank"></a></span>'); 40 $share.append('<span class="twitter"><a href="http://www.twitter.com/share?&text=Check+this+video&url=' + encoded_video_url + '" target="_blank"></a></span>'); 41 42 $overlay_next.html('<a href="#"><span class="text">' + $next.data('name') + '</span></a>'); 43 $overlay_next.find('a').data('vvg-anchor', $next); 44 45 var vid_options = "&controls=1" 46 var pop = Popcorn.smart( $video.get(0), data.video + vid_options ); 47 pop.controls(true); 48 pop.autoplay(true); 49 50 $overlay.fadeIn().css({ display: 'block' }); 51 } 52 53 $('.vvg-gallery').each(function(){ 54 var $gallery = $(this); 55 var $fwd = $(this).find('.fwd'); 56 var $back = $(this).find('.back'); 57 58 var vvgId = $gallery.data('vvg-id'); 59 var $menu = $(".vvg-menu[data-vvg-id=" + vvgId + "]"); 60 61 var speed = 400; 62 63 var iscroll = new IScroll($(this).get(0),{ 64 scrollX: true, 65 scrollY: false, 66 mouseWheel: false, 67 tap:true, 68 //these 2 are ESSENTIAL 69 eventPassthrough: true, 70 preventDefault: false 71 }); 72 73 $gallery.data('iScroll', iscroll); 74 75 //this one-time call seems to prevent odd breakage in chrome right after page load and before any browser resizing 76 setTimeout(function () { 77 iscroll.refresh(); 78 }, 0); 79 80 $fwd.click(function(){ 81 var $items = $( '.vvg-gallery-item', $gallery); 82 var gallery_right = $gallery.offset().left + $gallery.width(); 83 var found = false; 84 85 $items.each(function(){ 86 if(($(this).offset().left + $(this).width()) > gallery_right ){ 87 iscroll.scrollToElement(this, speed, -24, 0, IScroll.utils.ease.quadratic); 88 found = true; 89 return false; 90 } 91 }); 92 93 //if(!found){ 94 // iscroll.scrollToElement($items.get(0), speed, 0, 0, IScroll.utils.ease.quadratic); 95 //} 96 97 }); 98 $back.click(function(){ 99 var $items = $($( '.vvg-gallery-item', $gallery).get().reverse()); 100 var gallery_left = $gallery.offset().left; 101 var found = false; 102 $items.each(function(){ 103 if( $(this).offset().left < gallery_left ){ 104 iscroll.scrollToElement(this, speed, -$gallery.width() + $(this).width() + 24, 0, IScroll.utils.ease.quadratic); 105 found = true; 106 return false; 107 } 108 109 }); 110 111 //if(!found){ 112 // iscroll.scrollToElement($items.get(0), speed, 0, 0, IScroll.utils.ease.quadratic); 113 //} 114 }); 115 116 $menu.change(function(){ 117 var $selected = $(this).find("option:selected"); 118 if($selected.val() == -1) 119 return; 120 121 var item = $( '.vvg-gallery-item a', $gallery).get($selected.val()); 122 123 iscroll.scrollToElement(item, speed, 0, 0, IScroll.utils.ease.quadratic); 124 activateGalleryItem($(item)); 125 }); 126 127 }); 128 129 130 131 $('.vvg-gallery-item a').click(function(e){
132 e.preventDefault(false); 133 }).on('tap',function(e){ 134 activateGalleryItem($(this)); 135 }); 136 137 $('body').on('click', '.vvg-gallery-overlay .vvg-overlay-nav a', function(e){ 138 var data = $(this).data(); 139 var $list_item_anchor = $(this).data('vvg-anchor'); 140 141 activateGalleryItem($list_item_anchor); 142 e.stopPropagation(); 143 e.preventDefault(false); 144 }).on('click', '.vvg-share a', function(e){ 145 e.stopPropagation(); 146 147 }).on('click', '.vvg-gallery-overlay .vvg-overlay-close', function(e){ 148 var $overlay = $(this).parent('.vvg-gallery-overlay'); 149 var $video = $overlay.find('.vvg-video'); 150 $video.html(''); 151 $overlay.fadeOut(); 152 e.preventDefault(false); 153 });; 154 155 $(window).on('load resize', function(){ 156 $('.vvg-gallery').each(function(){ 157 var $window = $(window); 158 var $this = $(this); 159 //var vmin = Math.min($window.height(), $window.width()); 160 var vmin = $window.height(); 161 $this.height(vmin *.6); 162 163 //hack width correction 164 var $hackWidths = $this.find('.vvg-gallery-item img'); 165 //$hackWidths.height(vmin * 0.5); 166 $hackWidths.width(0); 167 $hackWidths.width('auto'); 168 169 var $items = $this.find('.vvg-gallery-item'); 170 171 var minExtraWidth = 25; 172 var totalWidth = minExtraWidth; 173 $items.each(function() { 174 totalWidth += $(this).outerWidth(true); 175 }); 176 177 if(totalWidth > minExtraWidth ){ 178 var $scroller = $this.find(".scroller"); 179 if($scroller.length){ 180 $scroller.innerWidth(totalWidth); 181 } 182 } 183 184 var iscroll = $(this).data('iScroll'); 185 setTimeout(function () { 186 iscroll.refresh(); 187 }, 1); 188 }); 189 }); 190 }); 191 192})(jQuery, window, Popcorn);
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.