Index: trunk/extensions/SlimboxThumbs/SlimboxThumbs.php |
— | — | @@ -1,25 +1,31 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * SlimboxThumbs extension, see http://www.mediawiki.org/wiki/Extension:SlimboxThumbs |
6 | | - * |
7 | | - * This extension includes a copy of Slimbox. You can however get your own copy at |
| 5 | + * SlimboxThumbs extension /REWRITTEN/ |
| 6 | + * Originally http://www.mediawiki.org/wiki/Extension:SlimboxThumbs |
| 7 | + * Now it does the same, but the code is totally different |
| 8 | + * Required MediaWiki: 1.13+ |
| 9 | + * |
| 10 | + * This extension includes a copy of Slimbox. |
| 11 | + * It has one small modification: caption is animated together |
| 12 | + * with image container, instead of original annoying consequential animation. |
| 13 | + * You can however get your own copy of Slimbox and use it by replacing the |
| 14 | + * included one, or pointing to it with $slimboxThumbsFilesDir |
8 | 15 | * http://www.digitalia.be/software/slimbox2 |
9 | | - * and use it by replacing the included one, or pointing to it with $slimboxThumbsFilesDir |
10 | 16 | * |
11 | | - * @license Creative Commons Attribution-ShareAlike license 3.0: http://creativecommons.org/licenses/by-sa/3.0/ |
| 17 | + * @license GNU GPL 3.0 or later: http://www.gnu.org/licenses/gpl.html |
| 18 | + * CC-BY-SA should not be used for software as it's incompatible with GPL, and MW is GPL. |
12 | 19 | * |
13 | 20 | * @file SlimboxThumbs.php |
14 | 21 | * |
15 | | - * @author David Raison |
16 | | - * @author Jeroen De Dauw |
| 22 | + * @author Vitaliy Filippov <vitalif@mail.ru> |
17 | 23 | */ |
18 | 24 | |
19 | 25 | if ( !defined( 'MEDIAWIKI' ) ) { |
20 | 26 | die( 'Not an entry point.' ); |
21 | 27 | } |
22 | 28 | |
23 | | -define( 'SlimboxThumbs_VERSION', '0.2' ); |
| 29 | +define( 'SlimboxThumbs_VERSION', '2011-12-30' ); |
24 | 30 | |
25 | 31 | // Register the extension credits. |
26 | 32 | $wgExtensionCredits['other'][] = array( |
— | — | @@ -27,9 +33,8 @@ |
28 | 34 | 'name' => 'SlimboxThumbs', |
29 | 35 | 'url' => 'https://www.mediawiki.org/wiki/Extension:SlimboxThumbs', |
30 | 36 | 'author' => array( |
31 | | - '[http://david.raison.lu Kwisatz]', |
32 | | - '[http://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw].' . |
33 | | - ' Inspired by [http://www.mediawiki.org/wiki/User:Alxndr Alexander]', |
| 37 | + '[http://yourcmc.ru/wiki/User:VitaliyFilippov Vitaliy Filippov], ' . |
| 38 | + '[http://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw].' |
34 | 39 | ), |
35 | 40 | 'descriptionmsg' => 'slimboxthumbs-desc', |
36 | 41 | 'version' => SlimboxThumbs_VERSION |
— | — | @@ -41,161 +46,52 @@ |
42 | 47 | // Include the settings file. |
43 | 48 | require_once 'SlimboxThumbs_Settings.php'; |
44 | 49 | |
45 | | -/** |
46 | | - * Other potential hooks would be http://www.mediawiki.org/wiki/Manual:Hooks/ImageOpenShowImageInlineBefore |
47 | | - * or http://www.mediawiki.org/wiki/Manual:Hooks/ImageBeforeProduceHTML |
48 | | - * or http://www.mediawiki.org/wiki/Manual:Hooks/BeforeGalleryFindFile |
49 | | - * or http://www.mediawiki.org/wiki/Manual:Hooks/BeforeParserrenderImageGallery |
50 | | - * but they would be called for each image, making the wiki even slower |
51 | | - */ |
52 | 50 | if ( $slimboxThumbsFilesDir ) { |
53 | | - $wgHooks['BeforeParserrenderImageGallery'][] = 'efSBTTestForGallery'; // this seems to fail on some pages :( |
54 | | - $hasGallery = true; // temporary fix |
55 | | - $wgHooks['BeforePageDisplay'][] = 'efSBTAddScripts'; |
56 | | - $wgHooks['BeforePageDisplay'][] = 'efSBTAddSlimboxCode'; |
| 51 | + $wgHooks['BeforePageDisplay'][] = 'efSBTAddScripts'; |
| 52 | + $wgHooks['ImageBeforeProduceHTML'][] = 'efSBTImageHTML'; |
| 53 | + $wgHooks['ParserAfterTidy'][] = 'efSBTAfterTidy'; |
57 | 54 | } |
58 | 55 | |
59 | | -function efSBTTestForGallery( $parser, $gallery ) { |
60 | | - global $hasGallery; |
61 | | - $hasGallery = $gallery instanceof ImageGallery; |
62 | | - return true; |
| 56 | +// Remembers the image dimensions to tell it to JS |
| 57 | +function efSBTImageHTML( $skin, $title, $file, $frameParams, &$handlerParams, $time, $res ) { |
| 58 | + global $slimboxImages; |
| 59 | + $slimboxImages[ $file->getName() ] = array( $file->getWidth(), $file->getHeight() ); |
| 60 | + return true; |
63 | 61 | } |
64 | 62 | |
65 | | -/** |
66 | | - * Add javascript files and stylesheets. |
67 | | - * Also add inline js that regulates the image width. |
68 | | - */ |
| 63 | +// Saves remembered image dimensions to parser output |
| 64 | +function efSBTAfterTidy( $parser, &$text, $clearState ) { |
| 65 | + global $slimboxImages; |
| 66 | + if ( !empty( $slimboxImages ) ) { |
| 67 | + $ws = array(); |
| 68 | + foreach( $slimboxImages as $n => $w ) { |
| 69 | + $ws[] = '"'.addslashes( $n ).'":['.$w[0].','.$w[1].']'; |
| 70 | + } |
| 71 | + $ws = 'var slimboxSizes = {'.implode( ',', $ws ).'}'; |
| 72 | + $parser->mOutput->addHeadItem( '<script language="JavaScript">'.$ws.'</script>', 'slimboxSizes' ); |
| 73 | + } |
| 74 | + return true; |
| 75 | +} |
| 76 | + |
| 77 | +// Adds javascript files and stylesheets. |
69 | 78 | function efSBTAddScripts( $out ) { |
70 | | - global $hasGallery, $wgVersion, $wgExtensionAssetsPath; |
71 | | - $eDir = $wgExtensionAssetsPath .'/SlimboxThumbs/slimbox'; |
72 | | - |
73 | | - // We don't want to load jQuery if there's no gallery here. |
74 | | - //if ( !$hasGallery ) return false; |
| 79 | + global $wgVersion, $wgExtensionAssetsPath, $wgUploadPath; |
| 80 | + $eDir = $wgExtensionAssetsPath . '/SlimboxThumbs/slimbox'; |
75 | 81 | |
76 | | - // 1.17 will require another setup |
77 | | - // (http://www.mediawiki.org/wiki/JQuery & http://www.mediawiki.org/wiki/ResourceLoader/Default_modules) |
78 | | - if ( substr($wgVersion,0,-2) < 1.16 ) { |
79 | | - $jQ = '$'; |
| 82 | + if ( substr( $wgVersion, 0, -2 ) < 1.16 ) { |
| 83 | + $j = '$'; |
80 | 84 | $out->addScript( '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>' . "\n" ); |
81 | | - } else { |
82 | | - $jQ = '$j'; |
83 | | - $out->includeJQuery(); // includes jquery.min.js |
| 85 | + } else { |
| 86 | + $j = '$j'; |
| 87 | + $out->includeJQuery(); |
84 | 88 | } |
85 | | - $out->addScript( '<script type="text/javascript" src="'. $eDir .'/js/slimbox2.js"></script>' . "\n" ); |
86 | | - $out->addExtensionStyle( $eDir . '/css/slimbox2.css', 'screen' ); |
87 | 89 | |
88 | | - // use thumb.php to resize pictures if browser window is smaller than the picture itself |
89 | | - $out->addInlineScript( $jQ.'(document).ready(function(){ |
90 | | - if('.$jQ.'("table.gallery").val() != undefined){ |
91 | | - var boxWidth = ('.$jQ.'(window).width() - 20); |
92 | | - var rxp = new RegExp(/([0-9]{2,})$/); |
93 | | - '.$jQ.'("a[rel=\'lightbox[gallery]\']").each(function(el){ |
94 | | - if(boxWidth < Number(this.search.match(rxp)[0])){ |
95 | | - this.href = this.pathname+this.search.replace(rxp,boxWidth); |
96 | | - } |
97 | | - }); |
98 | | - } |
99 | | - })' ); |
100 | | - |
101 | | - return true; |
102 | | -} |
| 90 | + $out->addScript( '<script type="text/javascript" src="' . $eDir . '/js/slimbox2.js"></script>' . "\n" ); |
| 91 | + $out->addExtensionStyle( $eDir . '/css/slimbox2.css', 'screen' ); |
| 92 | + $out->addScript( '<script type="text/javascript" src="' . $eDir . '/slimboxthumbs.js"></script>' . "\n" ); |
| 93 | + $out->addInlineScript( "addHandler( window, 'load', function() {". |
| 94 | + "makeSlimboxThumbs( $j, \"".addslashes( $wgUploadPath ). |
| 95 | + "\", \"".addslashes( $wgServer.$wgScriptPath )."\" ); } );" ); |
103 | 96 | |
104 | | -function efSBTDebugVar( $varName, $var ) { |
105 | | - return "\n\n<!--\n$varName: " . str_replace( '--', '__', print_r( $var, true ) ) . "\n-->\n\n"; |
106 | | -} |
107 | | - |
108 | | -/** |
109 | | - * This is a callback function that gets called by efBeforePageDisplay(). |
110 | | - */ |
111 | | -function efRewriteThumbImage( $matches ) { |
112 | | - global $wgOut, $slimboxThumbsDebug; |
113 | | - |
114 | | - if ( $slimboxThumbsDebug ) { global $wgContLang; } |
115 | | - |
116 | | - $titleObj = Title::newFromText( rawurldecode( 'File:'.$matches[2] ) ); |
117 | | - $image = wfFindFile( $titleObj, false, false, true ); # # wfFindFile($titleObj,false,false,true) to bypass cache |
118 | | - $output = $matches[1] // <a (not much else) |
119 | | - . 'href="' . $image->getURL() . '" class="image" rel="lightbox" title="' |
120 | | - . htmlspecialchars( $wgOut->parse( "'''[[:" . $titleObj->getFullText() . "|" . $titleObj->getText() . "]]:''' " ) ) |
121 | | - . '">'. $matches[3] . '</a>' //$matches[4] |
122 | | - . ( $slimboxThumbsDebug ? efSBTDebugVar( '$matches', $matches ) |
123 | | - . efSBTDebugVar( '$titleObj', $titleObj ) |
124 | | - . efSBTDebugVar( '$image', $image ) |
125 | | - . efSBTDebugVar( '$wgContLang->namespaceNames', $wgContLang->namespaceNames ):'' ); |
126 | | - |
127 | | - return $output; |
128 | | -} |
129 | | - |
130 | | -// Rewrite the gallery code. |
131 | | -function efRewriteGalleryImage( $matches ) { |
132 | | - global $wgOut, $slimboxThumbsDebug, $slimboxDefaultWidth, $wgScriptPath; |
133 | | - |
134 | | - $titleObj = Title::newFromText( rawurldecode( $matches[2] ) ); |
135 | | - $image = wfFindFile( $titleObj, false, false, true ); |
136 | | - $realwidth = (Integer) $image->getWidth(); |
137 | | - $width = ( $realwidth > $slimboxDefaultWidth ) ? $slimboxDefaultWidth : $realwidth -1; |
138 | | - $output = $matches[1] |
139 | | - .' href="'.$image->createThumb($width).'" class="image" rel="lightbox[gallery]" title="' |
140 | | - . htmlspecialchars( $wgOut->parse( "'''[[:" . $titleObj->getFullText() . "|" . $titleObj->getText() . "]]:''' " ) |
141 | | - . $matches[4] ) |
142 | | - . '" ' . $matches[3] . $matches[4] . "</div>" |
143 | | - . ( $slimboxThumbsDebug ? efSBTDebugVar( '$matches', $matches ) |
144 | | - . efSBTDebugVar( '$titleObj', $titleObj ) |
145 | | - . efSBTDebugVar( '$image', $image ):'' ); |
146 | | - |
147 | | - return $output; |
148 | | -} |
149 | | - |
150 | | - |
151 | | -function efSBTAddSlimboxCode( $out, $skin ) { |
152 | | - global $wgContLang, $hasGallery; |
153 | | - |
154 | | - // We don't want to run regular expressions if there's no gallery here. |
155 | | - if ( !$hasGallery ) { |
156 | | - return false; |
157 | | - } |
158 | | - |
159 | | - # # ideally we'd do this with XPath, but we'd need valid XML for that, so we'll do it with some ugly regexes |
160 | | - # # (could use a regex to pull out all div.thumb, maybe they're valid XML? ...probably not) |
161 | | - # # An other alternative would be to use javascript and the DOM |
162 | | - # # The jquery lightbox plugin does exactly that. |
163 | | - |
164 | | - // regex for thumbnails |
165 | | - $pattern = '/(<a[^>]+?)' // $1: start of opening <a> tag through start of href attribute in <a> tag |
166 | | - . '\s*href="[^"]*(?:' . $wgContLang->namespaceNames[6] . '):' // dont care about start of original link href... |
167 | | - . '([^"\/]+)' // $2: ...but end is wiki name for the image |
168 | | - . '"\s*class="image"\s*' // (1.16 title= gone) |
169 | | - . '[^>]*>\s*' |
170 | | - . '(<img[^>]+?[^>]*>)' // $3: the img tag itself (1.16 thumbimage class gone) |
171 | | - //.'(.*<\/*a>)' // $4 should get until >, but gets more... |
172 | | - .'/xs'; |
173 | | - |
174 | | - //by User:Cm |
175 | | - /*$pattern = '/(<a[^>]+?)' // $1 start of opening <a> tag through start of href attribute in <a> tag |
176 | | - .'\s*href="([^"]*)' // $2 link |
177 | | - .'"\s*class="image"\s*title="([^"]+)' // $3 title |
178 | | - .'"\s*([^>]*>)' // $4 end of <a> |
179 | | - .'\s*(<img[^>]+?class="thumbimage"[^>]*>)' // $5 img tag |
180 | | - .'(.*<\/*a>)/xs'; // $6 anything else |
181 | | - */ |
182 | | - |
183 | | - $thumbnailsDone = preg_replace_callback( $pattern, 'efRewriteThumbImage', $out->getHTML() ); |
184 | | - |
185 | | - /** |
186 | | - * Redone regex for galleries |
187 | | - * I don't get this, why am I regexxing code I'm creating in the first callback? WTF? |
188 | | - */ |
189 | | - $pattern = '/(<div\s*class="gallerybox".+?<div\s*class="thumb".+?)' # $1 |
190 | | - .'.+?href="\/wiki\/([^"]+)"\s*class="image"' # $2 (link) |
191 | | - .'([^>]*>.+?<div\s*class="gallerytext">)' # $3 rest |
192 | | - .'\s*(?:<p>\s*)?(.+?)' |
193 | | - .'(?:\s*(<\/p>|<br\s*\/?>))?\s*<\/div>' |
194 | | - .'/xs'; |
195 | | - |
196 | | - $allDone = preg_replace_callback( $pattern, 'efRewriteGalleryImage', $thumbnailsDone ); |
197 | | - |
198 | | - $out->clearHTML(); |
199 | | - $out->addHTML( $thumbnailsDone ); |
200 | | - //$out->addHTML( $allDone ); |
201 | 97 | return true; |
202 | 98 | } |
Index: trunk/extensions/SlimboxThumbs/SlimboxThumbs_Settings.php |
— | — | @@ -3,22 +3,19 @@ |
4 | 4 | /** |
5 | 5 | * Settings file for the SlimboxThumbs extension. |
6 | 6 | * For more info see http://www.mediawiki.org/wiki/Extension:SlimboxThumbs |
7 | | - * |
| 7 | + * |
8 | 8 | * NOTICE: |
9 | 9 | * Changing one of these settings can be done by copieng or cutting it, |
10 | 10 | * and placing it in LocalSettings.php, AFTER the inclusion of SlimboxThumbs. |
11 | | - * |
| 11 | + * |
12 | 12 | * @file SlimboxThumbs_Settings.php |
13 | 13 | * |
14 | 14 | * @author Jeroen De Dauw |
15 | 15 | */ |
16 | 16 | |
17 | | -# Default image width (integer). |
18 | | -$slimboxDefaultWidth = 680; |
19 | | - |
20 | 17 | # Path of the Slimbox directory (string). |
21 | 18 | $useExtensionPath = version_compare( $wgVersion, '1.16', '>=' ) && isset( $wgExtensionAssetsPath ) && $wgExtensionAssetsPath; |
22 | | -$slimboxThumbsFilesDir = ( $useExtensionPath ? $wgExtensionAssetsPath : $wgScriptPath . '/extensions' ) . '/SlimboxThumbs'; |
| 19 | +$slimboxThumbsFilesDir = ( $useExtensionPath ? $wgExtensionAssetsPath : $wgScriptPath . '/extensions' ) . '/SlimboxThumbs'; |
23 | 20 | unset( $useExtensionPath ); |
24 | 21 | |
25 | | -$slimboxThumbsFilesDir .= '/slimbox'; |
\ No newline at end of file |
| 22 | +$slimboxThumbsFilesDir .= '/slimbox'; |
Index: trunk/extensions/SlimboxThumbs/slimbox/src/slimbox2.js |
— | — | @@ -211,14 +211,17 @@ |
212 | 212 | } |
213 | 213 | $(center).queue(function() { |
214 | 214 | $(bottomContainer).css({width: centerWidth, top: top + centerHeight, marginLeft: -centerWidth/2, visibility: "hidden", display: ""}); |
215 | | - $(image).css({display: "none", visibility: "", opacity: ""}).fadeIn(options.imageFadeDuration, animateCaption); |
| 215 | + $(image).css({display: "none", visibility: "", opacity: ""}).fadeIn(options.imageFadeDuration); |
| 216 | + animateCaption(); |
216 | 217 | }); |
217 | 218 | } |
218 | 219 | |
219 | 220 | function animateCaption() { |
220 | 221 | if (prevImage >= 0) $(prevLink).show(); |
221 | 222 | if (nextImage >= 0) $(nextLink).show(); |
222 | | - $(bottom).css("marginTop", -bottom.offsetHeight).animate({marginTop: 0}, options.captionAnimationDuration); |
| 223 | + if (options.captionAnimationDuration) { |
| 224 | + $(bottom).css("marginTop", -bottom.offsetHeight).animate({marginTop: 0}, options.captionAnimationDuration); |
| 225 | + } |
223 | 226 | bottomContainer.style.visibility = ""; |
224 | 227 | } |
225 | 228 | |
Index: trunk/extensions/SlimboxThumbs/slimbox/slimboxthumbs.js |
— | — | @@ -0,0 +1,29 @@ |
| 2 | +/** |
| 3 | + * SlimboxThumbs extensions /rewritten/ |
| 4 | + * License: GNU GPL 3.0 or later |
| 5 | + * Contributor(s): Vitaliy Filippov <vitalif@mail.ru> |
| 6 | + */ |
| 7 | +var slimboxSizes = {}; |
| 8 | +function makeSlimboxThumbs( $, wgUploadPath, wgFullScriptPath ) { |
| 9 | + var re = new RegExp( wgUploadPath+'/thumb' ); |
| 10 | + var links = []; |
| 11 | + var ww = $( window ).width() * 0.8; |
| 12 | + var wh = $( window ).height() * 0.8; |
| 13 | + $( 'img' ).each( function( i, e ) { |
| 14 | + if ( re.exec( e.src ) && e.parentNode.nodeName == 'A' ) { |
| 15 | + var h = e.src.replace( '/thumb', '' ).replace( /\/[^/]+$/, '' ); |
| 16 | + var n = unescape( h.substr( h.lastIndexOf( '/' )+1 ).replace( /_/g, ' ' ) ); |
| 17 | + if ( slimboxSizes[n] && ( slimboxSizes[n][0] > ww || slimboxSizes[n][1] > wh ) ) { |
| 18 | + var sc = ww; |
| 19 | + var sh = Math.round( slimboxSizes[n][0] * wh / slimboxSizes[n][1] ); |
| 20 | + if ( sh < sc ) sc = sh; |
| 21 | + h = wgFullScriptPath + '/thumb.php?f=' + escape(n) + '&w=' + sc; |
| 22 | + } |
| 23 | + e.parentNode._lightbox = [ h, '<a href="'+e.parentNode.href+'">'+n+'</a>' ]; |
| 24 | + links.push( e.parentNode ); |
| 25 | + } |
| 26 | + } ); |
| 27 | + $( links ).slimbox({ captionAnimationDuration: 0 }, function( e, i ) { |
| 28 | + return e._lightbox; |
| 29 | + }, function() { return true; }); |
| 30 | +} |
Index: trunk/extensions/SlimboxThumbs/slimbox/js/slimbox2.js |
— | — | @@ -3,13 +3,4 @@ |
4 | 4 | (c) 2007-2010 Christophe Beyls <http://www.digitalia.be> |
5 | 5 | MIT-style license. |
6 | 6 | */ |
7 | | -(function(w){var E=w(window),u,f,F=-1,n,x,D,v,y,L,r,m=!window.XMLHttpRequest,s=[],l=document.documentElement,k={},t=new Image(),J=new Image(),H,a,g,p,I,d,G,c,A,K;w(function(){w("body").append(w([H=w('<div id="lbOverlay" />')[0],a=w('<div id="lbCenter" />')[0],G=w('<div id="lbBottomContainer" />')[0]]).css("display","none"));g=w('<div id="lbImage" />').appendTo(a).append(p=w('<div style="position: relative;" />').append([I=w('<a id="lbPrevLink" href="#" />').click(B)[0],d=w('<a id="lbNextLink" href="#" />').click(e)[0]])[0])[0];c=w('<div id="lbBottom" />').appendTo(G).append([w('<a id="lbCloseLink" href="#" />').add(H).click(C)[0],A=w('<div id="lbCaption" />')[0],K=w('<div id="lbNumber" />')[0],w('<div style="clear: both;" />')[0]])[0]});w.slimbox=function(O,N,M){u=w.extend({loop:false,overlayOpacity:0.8,overlayFadeDuration:400,resizeDuration:400,resizeEasing:"swing",initialWidth:250,initialHeight:250,imageFadeDuration:400,captionAnimationDuration:400,counterText:"Image {x} of {y}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},M);if(typeof O=="string"){O=[[O,N]];N=0}y=E.scrollTop()+(E.height()/2);L=u.initialWidth;r=u.initialHeight;w(a).css({top:Math.max(0,y-(r/2)),width:L,height:r,marginLeft:-L/2}).show();v=m||(H.currentStyle&&(H.currentStyle.position!="fixed"));if(v){H.style.position="absolute"}w(H).css("opacity",u.overlayOpacity).fadeIn(u.overlayFadeDuration);z();j(1);f=O;u.loop=u.loop&&(f.length>1);return b(N)};w.fn.slimbox=function(M,P,O){P=P||function(Q){return[Q.href,Q.title]};O=O||function(){return true};var N=this;return N.unbind("click").click(function(){var S=this,U=0,T,Q=0,R;T=w.grep(N,function(W,V){return O.call(S,W,V)});for(R=T.length;Q<R;++Q){if(T[Q]==S){U=Q}T[Q]=P(T[Q],Q)}return w.slimbox(T,U,M)})};function z(){var N=E.scrollLeft(),M=E.width();w([a,G]).css("left",N+(M/2));if(v){w(H).css({left:N,top:E.scrollTop(),width:M,height:E.height()})}}function j(M){if(M){w("object").add(m?"select":"embed").each(function(O,P){s[O]=[P,P.style.visibility];P.style.visibility="hidden"})}else{w.each(s,function(O,P){P[0].style.visibility=P[1]});s=[]}var N=M?"bind":"unbind";E[N]("scroll resize",z);w(document)[N]("keydown",o)}function o(O){var N=O.keyCode,M=w.inArray;return(M(N,u.closeKeys)>=0)?C():(M(N,u.nextKeys)>=0)?e():(M(N,u.previousKeys)>=0)?B():false}function B(){return b(x)}function e(){return b(D)}function b(M){if(M>=0){F=M;n=f[F][0];x=(F||(u.loop?f.length:0))-1;D=((F+1)%f.length)||(u.loop?0:-1);q();a.className="lbLoading";k=new Image();k.onload=i;k.src=n}return false}function i(){a.className="";w(g).css({backgroundImage:"url("+n+")",visibility:"hidden",display:""});w(p).width(k.width);w([p,I,d]).height(k.height);w(A).html(f[F][1]||"");w(K).html((((f.length>1)&&u.counterText)||"").replace(/{x}/,F+1).replace(/{y}/,f.length));if(x>=0){t.src=f[x][0]}if(D>=0){J.src=f[D][0]}L=g.offsetWidth;r=g.offsetHeight;var M=Math.max(0,y-(r/2));if(a.offsetHeight!=r){w(a).animate({height:r,top:M},u.resizeDuration,u.resizeEasing)}if(a.offsetWidth!=L){w(a).animate({width:L,marginLeft:-L/2},u.resizeDuration,u.resizeEasing)}w(a).queue(function(){w(G).css({width:L,top:M+r,marginLeft:-L/2,visibility:"hidden",display:""});w(g).css({display:"none",visibility:"",opacity:""}).fadeIn(u.imageFadeDuration,h)})}function h(){if(x>=0){w(I).show()}if(D>=0){w(d).show()}w(c).css("marginTop",-c.offsetHeight).animate({marginTop:0},u.captionAnimationDuration);G.style.visibility=""}function q(){k.onload=null;k.src=t.src=J.src=n;w([a,g,c]).stop(true);w([I,d,g,G]).hide()}function C(){if(F>=0){q();F=x=D=-1;w(a).hide();w(H).stop().fadeOut(u.overlayFadeDuration,j)}return false}})(jQuery); |
8 | | - |
9 | | -// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED) |
10 | | -if (!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)) { |
11 | | - jQuery(function($) { |
12 | | - $("a[rel^='lightbox']").slimbox({/* Put custom options here */}, null, function(el) { |
13 | | - return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel)); |
14 | | - }); |
15 | | - }); |
16 | | -} |
\ No newline at end of file |
| 7 | +(function(w){var E=w(window),u,f,F=-1,n,x,D,v,y,L,r,m=!window.XMLHttpRequest,s=[],l=document.documentElement,k={},t=new Image(),J=new Image(),H,a,g,p,I,d,G,c,A,K;w(function(){w("body").append(w([H=w('<div id="lbOverlay" />')[0],a=w('<div id="lbCenter" />')[0],G=w('<div id="lbBottomContainer" />')[0]]).css("display","none"));g=w('<div id="lbImage" />').appendTo(a).append(p=w('<div style="position: relative;" />').append([I=w('<a id="lbPrevLink" href="#" />').click(B)[0],d=w('<a id="lbNextLink" href="#" />').click(e)[0]])[0])[0];c=w('<div id="lbBottom" />').appendTo(G).append([w('<a id="lbCloseLink" href="#" />').add(H).click(C)[0],A=w('<div id="lbCaption" />')[0],K=w('<div id="lbNumber" />')[0],w('<div style="clear: both;" />')[0]])[0]});w.slimbox=function(O,N,M){u=w.extend({loop:false,overlayOpacity:0.8,overlayFadeDuration:400,resizeDuration:400,resizeEasing:"swing",initialWidth:250,initialHeight:250,imageFadeDuration:400,captionAnimationDuration:400,counterText:"Image {x} of {y}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},M);if(typeof O=="string"){O=[[O,N]];N=0}y=E.scrollTop()+(E.height()/2);L=u.initialWidth;r=u.initialHeight;w(a).css({top:Math.max(0,y-(r/2)),width:L,height:r,marginLeft:-L/2}).show();v=m||(H.currentStyle&&(H.currentStyle.position!="fixed"));if(v){H.style.position="absolute"}w(H).css("opacity",u.overlayOpacity).fadeIn(u.overlayFadeDuration);z();j(1);f=O;u.loop=u.loop&&(f.length>1);return b(N)};w.fn.slimbox=function(M,P,O){P=P||function(Q){return[Q.href,Q.title]};O=O||function(){return true};var N=this;return N.unbind("click").click(function(){var S=this,U=0,T,Q=0,R;T=w.grep(N,function(W,V){return O.call(S,W,V)});for(R=T.length;Q<R;++Q){if(T[Q]==S){U=Q}T[Q]=P(T[Q],Q)}return w.slimbox(T,U,M)})};function z(){var N=E.scrollLeft(),M=E.width();w([a,G]).css("left",N+(M/2));if(v){w(H).css({left:N,top:E.scrollTop(),width:M,height:E.height()})}}function j(M){if(M){w("object").add(m?"select":"embed").each(function(O,P){s[O]=[P,P.style.visibility];P.style.visibility="hidden"})}else{w.each(s,function(O,P){P[0].style.visibility=P[1]});s=[]}var N=M?"bind":"unbind";E[N]("scroll resize",z);w(document)[N]("keydown",o)}function o(O){var N=O.keyCode,M=w.inArray;return(M(N,u.closeKeys)>=0)?C():(M(N,u.nextKeys)>=0)?e():(M(N,u.previousKeys)>=0)?B():false}function B(){return b(x)}function e(){return b(D)}function b(M){if(M>=0){F=M;n=f[F][0];x=(F||(u.loop?f.length:0))-1;D=((F+1)%f.length)||(u.loop?0:-1);q();a.className="lbLoading";k=new Image();k.onload=i;k.src=n}return false}function i(){a.className="";w(g).css({backgroundImage:"url("+n+")",visibility:"hidden",display:""});w(p).width(k.width);w([p,I,d]).height(k.height);w(A).html(f[F][1]||"");w(K).html((((f.length>1)&&u.counterText)||"").replace(/{x}/,F+1).replace(/{y}/,f.length));if(x>=0){t.src=f[x][0]}if(D>=0){J.src=f[D][0]}L=g.offsetWidth;r=g.offsetHeight;var M=Math.max(0,y-(r/2));if(a.offsetHeight!=r){w(a).animate({height:r,top:M},u.resizeDuration,u.resizeEasing)}if(a.offsetWidth!=L){w(a).animate({width:L,marginLeft:-L/2},u.resizeDuration,u.resizeEasing)}w(a).queue(function(){w(G).css({width:L,top:M+r,marginLeft:-L/2,visibility:"hidden",display:""});w(g).css({display:"none",visibility:"",opacity:""}).fadeIn(u.imageFadeDuration);h()})}function h(){if(x>=0){w(I).show()}if(D>=0){w(d).show()}if(u.captionAnimationDuration){w(c).css("marginTop",-c.offsetHeight).animate({marginTop:0},u.captionAnimationDuration)}G.style.visibility=""}function q(){k.onload=null;k.src=t.src=J.src=n;w([a,g,c]).stop(true);w([I,d,g,G]).hide()}function C(){if(F>=0){q();F=x=D=-1;w(a).hide();w(H).stop().fadeOut(u.overlayFadeDuration,j)}return false}})(jQuery); |
\ No newline at end of file |