1/* 2Shutter Reloaded for NextGEN Gallery 3http://www.laptoptips.ca/javascripts/shutter-reloaded/ 4Version: 1.3.0 5Copyright (C) 2007-2008 Andrew Ozz 6Released under the GPL, http://www.gnu.org/copyleft/gpl.html 7 8Acknowledgement: some ideas are from: Shutter by Andrew Sutherland - http://code.jalenack.com, WordPress - http://wordpress.org, Lightbox by Lokesh Dhakar - http://www.huddletogether.com, the icons are from Crystal Project Icons, Everaldo Coelho, http://www.everaldo.com 9 10*/ 11 12shutterOnload = function(){shutterReloaded.init('sh');} 13 14if (typeof shutterOnload == 'function') { 15 if ('undefined' != typeof jQuery) jQuery(document).ready(function(){shutterOnload();}); 16 else if( typeof window.onload != 'function' ) window.onload = shutterOnload; 17 else {oldonld = window.onload;window.onload = function(){if(oldonld){oldonld();};shutterOnload();}}; 18} 19 20shutterReloaded = { 21 22 I : function (a) { 23 return document.getElementById(a); 24 }, 25 26 settings : function() { 27 var t = this, s = shutterSettings; 28 29 t.imageCount = s.imageCount || 0; 30 t.msgLoading = s.msgLoading || 'L O A D I N G'; 31 t.msgClose = s.msgClose || 'Click to Close'; 32 }, 33 34 init : function (a) { 35 var t = this, L, T, ext, i, m, setid, inset, shfile, shMenuPre, k, img; 36 shutterLinks = {}, shutterSets = {}; 37 if ( 'object' != typeof shutterSettings ) shutterSettings = {}; 38 39 for ( i = 0; i < document.links.length; i++ ) { 40 L = document.links[i]; 41 ext = ( L.href.indexOf('?') == -1 ) ? L.href.slice(-4).toLowerCase() : L.href.substring( 0, L.href.indexOf('?') ).slice(-4).toLowerCase(); 42 if ( ext != '.jpg' && ext != '.png' && ext != '.gif' && ext != 'jpeg' ) continue; 43 if ( a == 'sh' && L.className.toLowerCase().indexOf('shutter') == -1 ) continue; 44 if ( a == 'lb' && L.rel.toLowerCase().indexOf('lightbox') == -1 ) continue; 45 46 if ( L.className.toLowerCase().indexOf('shutterset') != -1 ) 47 setid = L.className.replace(/\s/g, '_'); 48 else if ( L.rel.toLowerCase().indexOf('lightbox[') != -1 ) 49 setid = L.rel.replace(/\s/g, '_'); 50 else setid = 0, inset = -1; 51 52 if( setid ) { 53 if ( ! shutterSets[setid] ) shutterSets[setid] = []; 54 inset = shutterSets[setid].push(i); 55 } 56 57 shfile = L.href.slice(L.href.lastIndexOf('/')+1); 58 T = ( L.title && L.title != shfile ) ? L.title : ''; 59 60 shutterLinks[i] = {link:L.href,num:inset,set:setid,title:T} 61 L.onclick = new Function('shutterReloaded.make("' + i + '");return false;'); 62 } 63 64 t.settings(); 65 66 }, 67 68 make : function(ln,fs) { 69 var t = this, prev, next, prevlink = '', nextlink = '', previmg, nextimg, D, S, W, fsarg = -1, imgNum, NavBar; 70 71 if ( ! t.Top ) { 72 if ( typeof window.pageYOffset != 'undefined' ) t.Top = window.pageYOffset; 73 else t.Top = (document.documentElement.scrollTop > 0) ? document.documentElement.scrollTop : document.body.scrollTop; 74 } 75 76 if ( typeof t.pgHeight == 'undefined' ) 77 t.pgHeight = Math.max(document.documentElement.scrollHeight,document.body.scrollHeight); 78 79 if ( fs ) t.FS = ( fs > 0 ) ? 1 : 0; 80 else t.FS = shutterSettings.FS || 0; 81 82 if ( t.resizing ) t.resizing = null; 83 window.onresize = new Function('shutterReloaded.resize("'+ln+'");'); 84 85 document.documentElement.style.overflowX = 'hidden'; 86 if ( ! t.VP ) { 87 t._viewPort(); 88 t.VP = true; 89 } 90 91 if ( ! (S = t.I('shShutter')) ) { 92 S = document.createElement('div'); 93 S.setAttribute('id','shShutter'); 94 document.getElementsByTagName('body')[0].appendChild(S); 95 t.hideTags(); 96 } 97 98 if ( ! (D = t.I('shDisplay')) ) { 99 D = document.createElement('div'); 100 D.setAttribute('id','shDisplay'); 101 D.style.top = t.Top + 'px'; 102 document.getElementsByTagName('body')[0].appendChild(D); 103 } 104 105 S.style.height = t.pgHeight + 'px'; 106 107 var dv = t.textBtns ? ' | ' : ''; 108 if ( shutterLinks[ln].num > 1 ) { 109 prev = shutterSets[shutterLinks[ln].set][shutterLinks[ln].num - 2]; 110 prevlink = '<a href="#" onclick="shutterReloaded.make('+prev+');return false"><<</a>'+dv; 111 previmg = new Image(); 112 previmg.src = shutterLinks[prev].link; 113 } else { 114 prevlink = ''; 115 } 116 117 if ( shutterLinks[ln].num != -1 && shutterLinks[ln].num < (shutterSets[shutterLinks[ln].set].length) ) { 118 next = shutterSets[shutterLinks[ln].set][shutterLinks[ln].num]; 119 nextlink = '<a href="#" onclick="shutterReloaded.make('+next+');return false">>></a>'+dv; 120 nextimg = new Image(); 121 nextimg.src = shutterLinks[next].link; 122 } else { 123 nextlink = ''; 124 } 125 126 imgNum = ( (shutterLinks[ln].num > 0) && t.imageCount ) ? '<div id="shCount"> ( ' + shutterLinks[ln].num + ' / ' + shutterSets[shutterLinks[ln].set].length + ' ) </div>' : ''; 127 128 NavBar = '<div id="shTitle"><div id="shPrev">' + prevlink + '</div><div id="shNext">' + nextlink + '</div><div id="shName">' + shutterLinks[ln].title + '</div>' + imgNum + '</div>'; 129 130 D.innerHTML = '<div id="shWrap"><img src="'+shutterLinks[ln].link+'" id="shTopImg" title="' + t.msgClose + '" onload="shutterReloaded.showImg();" onclick="shutterReloaded.hideShutter();" />' + NavBar +'</div>'; 131 132 window.setTimeout(function(){shutterReloaded.loading();},2000); 133 }, 134 135 loading : function() { 136 var t = this, S, WB, W; 137 if ( (W = t.I('shWrap')) && W.style.visibility == 'visible' ) return; 138 if ( ! (S = t.I('shShutter')) ) return; 139 if ( t.I('shWaitBar') ) return; 140 WB = document.createElement('div'); 141 WB.setAttribute('id','shWaitBar'); 142 WB.style.top = t.Top + 'px'; 143 WB.innerHTML = t.msgLoading; 144 S.appendChild(WB); 145 }, 146
147 hideShutter : function() { 148 var t = this, D, S; 149 if ( D = t.I('shDisplay') ) D.parentNode.removeChild(D); 150 if ( S = t.I('shShutter') ) S.parentNode.removeChild(S); 151 t.hideTags(true); 152 window.scrollTo(0,t.Top); 153 window.onresize = t.FS = t.Top = t.VP = null; 154 document.documentElement.style.overflowX = ''; 155 }, 156 157 resize : function(ln) { 158 var t = this; 159 160 if ( t.resizing ) return; 161 if ( ! t.I('shShutter') ) return; 162 var W = t.I('shWrap'); 163 if ( W ) W.style.visibility = 'hidden'; 164 165 window.setTimeout(function(){shutterReloaded.resizing = null},500); 166 window.setTimeout(new Function('shutterReloaded.VP = null;shutterReloaded.make("'+ln+'");'),100); 167 t.resizing = true; 168 }, 169 170 _viewPort : function() { 171 var t = this; 172 var wiH = window.innerHeight ? window.innerHeight : 0; 173 var dbH = document.body.clientHeight ? document.body.clientHeight : 0; 174 var deH = document.documentElement ? document.documentElement.clientHeight : 0; 175 176 if( wiH > 0 ) { 177 t.wHeight = ( (wiH - dbH) > 1 && (wiH - dbH) < 30 ) ? dbH : wiH; 178 t.wHeight = ( (t.wHeight - deH) > 1 && (t.wHeight - deH) < 30 ) ? deH : t.wHeight; 179 } else t.wHeight = ( deH > 0 ) ? deH : dbH; 180 181 var deW = document.documentElement ? document.documentElement.clientWidth : 0; 182 var dbW = window.innerWidth ? window.innerWidth : document.body.clientWidth; 183 t.wWidth = ( deW > 1 ) ? deW : dbW; 184 }, 185 186 showImg : function() { 187 var t = this, S = t.I('shShutter'), D = t.I('shDisplay'), TI = t.I('shTopImg'), T = t.I('shTitle'), NB = t.I('shNavBar'), W, WB, wHeight, wWidth, shHeight, maxHeight, itop, mtop, resized = 0; 188 189 if ( ! S ) return; 190 if ( (W = t.I('shWrap')) && W.style.visibility == 'visible' ) return; 191 if ( WB = t.I('shWaitBar') ) WB.parentNode.removeChild(WB); 192 193 S.style.width = D.style.width = ''; 194 T.style.width = (TI.width - 4) + 'px'; 195 196 shHeight = t.wHeight - 7; 197 198 if ( t.FS ) { 199 if ( TI.width > (t.wWidth - 10) ) 200 S.style.width = D.style.width = TI.width + 10 + 'px'; 201 document.documentElement.style.overflowX = ''; 202 } else { 203 window.scrollTo(0,t.Top); 204 if ( TI.height > shHeight ) { 205 TI.width = TI.width * (shHeight / TI.height); 206 TI.height = shHeight; 207 resized = 1; 208 } 209 if ( TI.width > (t.wWidth - 16) ) { 210 TI.height = TI.height * ((t.wWidth - 16) / TI.width); 211 TI.width = t.wWidth - 16; 212 resized = 1; 213 } 214 T.style.width = (TI.width - 4) + 'px'; 215 } 216 217 maxHeight = t.Top + TI.height + 10; 218 if ( maxHeight > t.pgHeight ) S.style.height = maxHeight + 'px'; 219 window.scrollTo(0,t.Top); 220 221 itop = (shHeight - TI.height) * 0.45; 222 mtop = (itop > 3) ? Math.floor(itop) : 3; 223 D.style.top = t.Top + mtop + 'px'; 224 W.style.visibility = 'visible'; 225 }, 226 227 hideTags : function(arg) { 228 var sel = document.getElementsByTagName('select'); 229 var obj = document.getElementsByTagName('object'); 230 var emb = document.getElementsByTagName('embed'); 231 var ifr = document.getElementsByTagName('iframe'); 232 233 var vis = ( arg ) ? 'visible' : 'hidden'; 234 235 for (i = 0; i < sel.length; i++) sel[i].style.visibility = vis; 236 for (i = 0; i < obj.length; i++) obj[i].style.visibility = vis; 237 for (i = 0; i < emb.length; i++) emb[i].style.visibility = vis; 238 for (i = 0; i < ifr.length; i++) ifr[i].style.visibility = vis; 239 } 240}
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.