1jQuery(function($) { 2 photoswipe_masonry($); 3}); 4 5var photoswipe_masonry = function($){ 6 7 var $pswp = $('.pswp')[0]; 8 var image = []; 9 10 ///////////////////////////////////////////////////////////////////////////////////////////// 11 // Gallery 12 $('.psgal').each( function() { 13 14 var $pic = $(this), 15 getItems = function() { 16 var items = []; 17 $pic.find('a').each(function() { 18 19 var $href = $(this).attr('href'), 20 $size = $(this).data('size').split('x'), 21 $width = $size[0], 22 $height = $size[1]; 23 24 var item = { 25 src : $href, 26 w : $width, 27 h : $height, 28 el : $(this), 29 msrc : $(this).find('img').attr('src'), 30 title : $(this).attr('data-caption') 31 } 32 items.push(item); 33 }); 34 return items; 35 } 36 37 var items = getItems(); 38 39 /*$.each(items, function(index, value) { 40 image[index] = new Image(); 41 image[index].src = value['src']; 42 });*/ 43 44 $pic.on('click', 'figure', function(event) { 45 46 event.preventDefault(); 47 var $index = $(this).index(); 48 49 var options = { 50 index: $index, 51 bgOpacity: 0.9, 52 showHideOpacity: false, 53 galleryUID: $(this).parents('.psgal').attr('id'), 54 getThumbBoundsFn: function(index) { 55 var image = items[index].el.find('img'), 56 offset = image.offset(); 57 return {x:offset.left, y:offset.top, w:image.width()}; 58 } 59 } 60 61 var lightBox = new PhotoSwipe($pswp, PhotoSwipeUI_Default, items, options); 62 lightBox.init(); 63 64 }); 65 66 }); 67 68 ///////////////////////////////////////////////////////////////////////////////////////////// 69 // Single image 70 $('.single_photoswipe').each( function() { 71 72 var $pic = $(this), 73 getItems = function() { 74 var items = []; 75 $pic.each(function() { 76 var $href = $(this).attr('href'), 77 $size = $(this).data('size').split('x'), 78 $width = $size[0], 79 $height = $size[1]; 80 81 var item = { 82 src : $href, 83 w : $width, 84 h : $height, 85 el : $(this), 86 msrc: $(this).find('img').attr('src'), 87 title: $(this).find('img').attr('title') 88 } 89 90 items.push(item); 91 }); 92 return items; 93 } 94 95 var items = getItems(); 96 97 /*$.each(items, function(index, value) { 98 image[index] = new Image(); 99 image[index].src = value['src']; 100 });*/ 101 102 $pic.on('click', 'img', function(event) { 103 104 event.preventDefault(); 105 106 var $index = $(this).index(); 107 108 var options = { 109 index: $index, 110 shareEl: false, 111 //galleryUID: $(this).parent().attr('id'), 112 //bgOpacity: 0.9, 113 //showHideOpacity: true, 114 getThumbBoundsFn: function(index) { 115 var image = items[index].el.find('img'), 116 offset = image.offset(); 117 return {x:offset.left, y:offset.top, w:image.width()}; 118 } 119 } 120 121 var lightBox = new PhotoSwipe($pswp, PhotoSwipeUI_Default, items, options); 122 lightBox.init(); 123 }); 124 125 }); 126 127 ///////////////////////////////////////////////////////////////////////////////////////////// 128 // Parse URL and open gallery if it contains #&pid=3&gid=1 129 var hashData = parseHash(); 130 131 if(hashData.gid) { 132 133 $('#' + hashData.gid).each( function() { 134 135 var $pic = $(this), 136 getItems = function() { 137 138 var items = []; 139 140 $pic.find('a').each(function() { 141 142 var $href = $(this).attr('href'), 143 $size = $(this).data('size').split('x'), 144 $width = $size[0], 145 $height = $size[1]; 146 147 var item = { 148 src : $href, 149 w : $width, 150 h : $height, 151 el : $(this), 152 msrc : $(this).find('img').attr('src'), 153 title : $(this).attr('data-caption') 154 } 155 items.push(item); 156 }); 157 return items; 158 } 159 160 var items = getItems(); 161 $.each(items, function(index, value) { 162 image[index] = new Image(); 163 image[index].src = value['src']; 164 }); 165 166 var $index = $(this).index(); 167 var options = { 168 index: $index, 169 bgOpacity: 0.9, 170 showHideOpacity: false, 171 galleryUID: '#' + hashData.gid, 172 getThumbBoundsFn: function(index) { 173 var image = items[index].el.find('img'), 174 offset = image.offset(); 175 return {x:offset.left, y:offset.top, w:image.width()}; 176 } 177 } 178 179 var lightBox = new PhotoSwipe($pswp, PhotoSwipeUI_Default, items, options); 180 lightBox.init(); 181 182 }); 183 } 184}; 185 186var parseHash = function() { 187 188 var hash = window.location.hash.substring(1), 189 params = {}; 190 191 if(hash.length < 5) { 192 return params; 193 } 194 195 var vars = hash.split('&'); 196 for (var i = 0; i < vars.length; i++) { 197 if(!vars[i]) { 198 continue; 199 } 200 var pair = vars[i].split('='); 201 if(pair.length < 2) { 202 continue; 203 } 204 params[pair[0]] = pair[1]; 205 } 206 207 params.pid = parseInt(params.pid, 10); 208 return params; 209};
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.