2010-01-27 10:17:02 +00:00
/ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2010-12-12 09:05:23 +00:00
* Class : prettyPhoto
* Use : Lightbox clone for jQuery
* Author : Stephane Caron ( http : //www.no-margin-for-errors.com)
* Version : 3.0 . 1
* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - * /
2010-01-27 10:17:02 +00:00
2010-12-12 09:05:23 +00:00
( function ( $ ) { $ . prettyPhoto = { version : '3.0' } ; $ . fn . prettyPhoto = function ( pp _settings ) { pp _settings = jQuery . extend ( { animation _speed : 'fast' , slideshow : false , autoplay _slideshow : false , opacity : 0.80 , show _title : true , allow _resize : true , default _width : 500 , default _height : 344 , counter _separator _label : '/' , theme : 'facebook' , hideflash : false , wmode : 'opaque' , autoplay : true , modal : false , overlay _gallery : true , keyboard _shortcuts : true , changepicturecallback : function ( ) { } , callback : function ( ) { } , markup : ' < div class = "pp_pic_holder" > \
< div class = "ppt" > & nbsp ; < / d i v > \
2010-01-27 10:17:02 +00:00
< div class = "pp_top" > \
< div class = "pp_left" > < / d i v > \
< div class = "pp_middle" > < / d i v > \
< div class = "pp_right" > < / d i v > \
< / d i v > \
< div class = "pp_content_container" > \
< div class = "pp_left" > \
< div class = "pp_right" > \
< div class = "pp_content" > \
< div class = "pp_loaderIcon" > < / d i v > \
< div class = "pp_fade" > \
< a href = "#" class = "pp_expand" title = "Expand the image" > Expand < / a > \
< div class = "pp_hoverContainer" > \
< a class = "pp_next" href = "#" > next < / a > \
< a class = "pp_previous" href = "#" > previous < / a > \
< / d i v > \
< div id = "pp_full_res" > < / d i v > \
< div class = "pp_details clearfix" > \
< p class = "pp_description" > < / p > \
2010-12-12 09:05:23 +00:00
< a class = "pp_close" href = "#" > Close < / a > \
2010-01-27 10:17:02 +00:00
< div class = "pp_nav" > \
< a href = "#" class = "pp_arrow_previous" > Previous < / a > \
< p class = "currentTextHolder" > 0 / 0 < / p > \
< a href = "#" class = "pp_arrow_next" > Next < / a > \
< / d i v > \
< / d i v > \
< / d i v > \
< / d i v > \
< / d i v > \
< / d i v > \
< / d i v > \
< div class = "pp_bottom" > \
< div class = "pp_left" > < / d i v > \
< div class = "pp_middle" > < / d i v > \
< div class = "pp_right" > < / d i v > \
< / d i v > \
< / d i v > \
2010-12-12 09:05:23 +00:00
< div class = "pp_overlay" > < / d i v > ' , g a l l e r y _ m a r k u p : ' < d i v c l a s s = " p p _ g a l l e r y " > \
< a href = "#" class = "pp_arrow_previous" > Previous < / a > \
< ul > \
{ gallery } \
< / u l > \
< a href = "#" class = "pp_arrow_next" > Next < / a > \
< /div>',image_markup:'<img id="fullResImage" src="" / > ',flash_markup:' < object classid = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width = "{width}" height = "{height}" > < param name = "wmode" value = "{wmode}" / > < param name = "allowfullscreen" value = "true" / > < param name = "allowscriptaccess" value = "always" / > < param name = "movie" value = "{path}" / > < embed src = "{path}" type = "application/x-shockwave-flash" allowfullscreen = "true" allowscriptaccess = "always" width = "{width}" height = "{height}" wmode = "{wmode}" > < / e m b e d > < / o b j e c t > ' , q u i c k t i m e _ m a r k u p : ' < o b j e c t c l a s s i d = " c l s i d : 0 2 B F 2 5 D 5 - 8 C 1 7 - 4 B 2 3 - B C 8 0 - D 3 4 8 8 A B D D C 6 B " c o d e b a s e = " h t t p : / / w w w . a p p l e . c o m / q t a c t i v e x / q t p l u g i n . c a b " h e i g h t = " { h e i g h t } " w i d t h = " { w i d t h } " > < p a r a m n a m e = " s r c " v a l u e = " { p a t h } " > < p a r a m n a m e = " a u t o p l a y " v a l u e = " { a u t o p l a y } " > < p a r a m n a m e = " t y p e " v a l u e = " v i d e o / q u i c k t i m e " > < e m b e d s r c = " { p a t h } " h e i g h t = " { h e i g h t } " w i d t h = " { w i d t h } " a u t o p l a y = " { a u t o p l a y } " t y p e = " v i d e o / q u i c k t i m e " p l u g i n s p a g e = " h t t p : / / w w w . a p p l e . c o m / q u i c k t i m e / d o w n l o a d / " > < / e m b e d > < / o b j e c t > ' , i f r a m e _ m a r k u p : ' < i f r a m e s r c = " { p a t h } " w i d t h = " { w i d t h } " h e i g h t = " { h e i g h t } " f r a m e b o r d e r = " n o " > < / i f r a m e > ' , i n l i n e _ m a r k u p : ' < d i v c l a s s = " p p _ i n l i n e c l e a r f i x " > { c o n t e n t } < / d i v > ' , c u s t o m _ m a r k u p : ' ' } , p p _ s e t t i n g s ) ; v a r m a t c h e d O b j e c t s = t h i s , p e r c e n t B a s e d = f a l s e , c o r r e c t S i z e s , p p _ o p e n , p p _ c o n t e n t H e i g h t , p p _ c o n t e n t W i d t h , p p _ c o n t a i n e r H e i g h t , p p _ c o n t a i n e r W i d t h , w i n d o w H e i g h t = $ ( w i n d o w ) . h e i g h t ( ) , w i n d o w W i d t h = $ ( w i n d o w ) . w i d t h ( ) , p p _ s l i d e s h o w ; d o r e s i z e = t r u e , s c r o l l _ p o s = _ g e t _ s c r o l l ( ) ; $ ( w i n d o w ) . u n b i n d ( ' r e s i z e ' ) . r e s i z e ( f u n c t i o n ( ) { _ c e n t e r _ o v e r l a y ( ) ; _ r e s i z e _ o v e r l a y ( ) ; } ) ; i f ( p p _ s e t t i n g s . k e y b o a r d _ s h o r t c u t s ) { $ ( d o c u m e n t ) . u n b i n d ( ' k e y d o w n ' ) . k e y d o w n ( f u n c t i o n ( e ) { i f ( t y p e o f $ p p _ p i c _ h o l d e r ! = ' u n d e f i n e d ' ) { i f ( $ p p _ p i c _ h o l d e r . i s ( ' : v i s i b l e ' ) ) { s w i t c h ( e . k e y C o d e ) { c a s e 3 7 : $ . p r e t t y P h o t o . c h a n g e P a g e ( ' p r e v i o u s ' ) ; b r e a k ; c a s e 3 9 : $ . p r e t t y P h o t o . c h a n g e P a g e ( ' n e x t ' ) ; b r e a k ; c a s e 2 7 : i f ( ! s e t t i n g s . m o d a l )
$ . prettyPhoto . close ( ) ; break ; } ; return false ; } ; } ; } ) ; }
$ . prettyPhoto . initialize = function ( ) { settings = pp _settings ; if ( $ . browser . msie && parseInt ( $ . browser . version ) == 6 ) settings . theme = "light_square" ; _buildOverlay ( this ) ; if ( settings . allow _resize )
$ ( window ) . scroll ( function ( ) { _center _overlay ( ) ; } ) ; _center _overlay ( ) ; set _position = jQuery . inArray ( $ ( this ) . attr ( 'href' ) , pp _images ) ; $ . prettyPhoto . open ( ) ; return false ; }
$ . prettyPhoto . open = function ( event ) { if ( typeof settings == "undefined" ) { settings = pp _settings ; if ( $ . browser . msie && $ . browser . version == 6 ) settings . theme = "light_square" ; _buildOverlay ( event . target ) ; pp _images = $ . makeArray ( arguments [ 0 ] ) ; pp _titles = ( arguments [ 1 ] ) ? $ . makeArray ( arguments [ 1 ] ) : $ . makeArray ( "" ) ; pp _descriptions = ( arguments [ 2 ] ) ? $ . makeArray ( arguments [ 2 ] ) : $ . makeArray ( "" ) ; isSet = ( pp _images . length > 1 ) ? true : false ; set _position = 0 ; }
if ( $ . browser . msie && $ . browser . version == 6 ) $ ( 'select' ) . css ( 'visibility' , 'hidden' ) ; if ( settings . hideflash ) $ ( 'object,embed' ) . css ( 'visibility' , 'hidden' ) ; _checkPosition ( $ ( pp _images ) . size ( ) ) ; $ ( '.pp_loaderIcon' ) . show ( ) ; if ( $ppt . is ( ':hidden' ) ) $ppt . css ( 'opacity' , 0 ) . show ( ) ; $pp _overlay . show ( ) . fadeTo ( settings . animation _speed , settings . opacity ) ; $pp _pic _holder . find ( '.currentTextHolder' ) . text ( ( set _position + 1 ) + settings . counter _separator _label + $ ( pp _images ) . size ( ) ) ; $pp _pic _holder . find ( '.pp_description' ) . show ( ) . html ( unescape ( pp _descriptions [ set _position ] ) ) ; ( settings . show _title && pp _titles [ set _position ] != "" && typeof pp _titles [ set _position ] != "undefined" ) ? $ppt . html ( unescape ( pp _titles [ set _position ] ) ) : $ppt . html ( ' ' ) ; movie _width = ( parseFloat ( grab _param ( 'width' , pp _images [ set _position ] ) ) ) ? grab _param ( 'width' , pp _images [ set _position ] ) : settings . default _width . toString ( ) ; movie _height = ( parseFloat ( grab _param ( 'height' , pp _images [ set _position ] ) ) ) ? grab _param ( 'height' , pp _images [ set _position ] ) : settings . default _height . toString ( ) ; if ( movie _width . indexOf ( '%' ) != - 1 || movie _height . indexOf ( '%' ) != - 1 ) { movie _height = parseFloat ( ( $ ( window ) . height ( ) * parseFloat ( movie _height ) / 100 ) - 150 ) ; movie _width = parseFloat ( ( $ ( window ) . width ( ) * parseFloat ( movie _width ) / 100 ) - 150 ) ; percentBased = true ; } else { percentBased = false ; }
$pp _pic _holder . fadeIn ( function ( ) { imgPreloader = "" ; switch ( _getFileType ( pp _images [ set _position ] ) ) { case 'image' : imgPreloader = new Image ( ) ; nextImage = new Image ( ) ; if ( isSet && set _position > $ ( pp _images ) . size ( ) ) nextImage . src = pp _images [ set _position + 1 ] ; prevImage = new Image ( ) ; if ( isSet && pp _images [ set _position - 1 ] ) prevImage . src = pp _images [ set _position - 1 ] ; $pp _pic _holder . find ( '#pp_full_res' ) [ 0 ] . innerHTML = settings . image _markup ; $pp _pic _holder . find ( '#fullResImage' ) . attr ( 'src' , pp _images [ set _position ] ) ; imgPreloader . onload = function ( ) { correctSizes = _fitToViewport ( imgPreloader . width , imgPreloader . height ) ; _showContent ( ) ; } ; imgPreloader . onerror = function ( ) { alert ( 'Image cannot be loaded. Make sure the path is correct and image exist.' ) ; $ . prettyPhoto . close ( ) ; } ; imgPreloader . src = pp _images [ set _position ] ; break ; case 'youtube' : correctSizes = _fitToViewport ( movie _width , movie _height ) ; movie = 'http://www.youtube.com/v/' + grab _param ( 'v' , pp _images [ set _position ] ) ; if ( settings . autoplay ) movie += "&autoplay=1" ; toInject = settings . flash _markup . replace ( /{width}/g , correctSizes [ 'width' ] ) . replace ( /{height}/g , correctSizes [ 'height' ] ) . replace ( /{wmode}/g , settings . wmode ) . replace ( /{path}/g , movie ) ; break ; case 'vimeo' : correctSizes = _fitToViewport ( movie _width , movie _height ) ; movie _id = pp _images [ set _position ] ; var regExp = /http:\/\/(www\.)?vimeo.com\/(\d+)/ ; var match = movie _id . match ( regExp ) ; movie = 'http://player.vimeo.com/video/' + match [ 2 ] + '?title=0&byline=0&portrait=0' ; if ( settings . autoplay ) movie += "&autoplay=1;" ; vimeo _width = correctSizes [ 'width' ] + '/embed/?moog_width=' + correctSizes [ 'width' ] ; toInject = settings . iframe _markup . replace ( /{width}/g , vimeo _width ) . replace ( /{height}/g , correctSizes [ 'height' ] ) . replace ( /{path}/g , movie ) ; break ; case 'quicktime' : correctSizes = _fitToViewport ( movie _width , movie _height ) ; correctSizes [ 'height' ] += 15 ; correctSizes [ 'contentHeight' ] += 15 ; correctSizes [ 'containerHeight' ] += 15 ; toInject = settings . quicktime _markup . replace ( /{width}/g , correctSizes [ 'width' ] ) . replace ( /{height}/g , correctSizes [ 'height' ] ) . replace ( /{wmode}/g , settings . wmode ) . replace ( /{path}/g , pp _images [ set _position ] ) . replace ( /{autoplay}/g , settings . autoplay ) ; break ; case 'flash' : correctSizes = _fitToViewport ( movie _width , movie _height ) ; flash _vars = pp _images [ set _position ] ; flash _vars = flash _vars . substring ( pp _images [ set _position ] . indexOf ( 'flashvars' ) + 10 , pp _images [ set _position ] . length ) ; filename = pp _images [ set _position ] ; filename = filename . substring ( 0 , filename . indexOf ( '?' ) ) ; toInject = settings . flash _markup . replace ( /{width}/g , correctSizes [ 'width' ] ) . replace ( /{height}/g , correctSizes [ 'height' ] ) . replace ( /{wmode}/g , settings . wmode ) . replace ( /{path}/g , filename + '?' + flash _vars ) ; break ; case 'iframe' : correctSizes = _fitToViewport ( movie _width , movie _height ) ; frame _url = pp _images [ set _position ] ; frame _url = frame _url . substr ( 0 , frame _url . indexOf ( 'iframe' ) - 1 ) ; toInject = settings . iframe _markup . replace ( /{width}/g , correctSizes [ 'width' ] ) . replace ( /{height}/g , correctSizes [ 'height' ] ) . replace ( /{path}/g , frame _url ) ; break ; case 'custom' : correctSizes = _fitToViewport ( movie _width , movie _height ) ; toInject = settings . custom _markup ; break ; case 'inline' : myClone = $ ( pp _images [ set _position ] ) . clone ( ) . css ( { 'width' : settings . default _width } ) . wrapInner ( '<div id="pp_full_res"><div class="pp_inline clearfix"></div></div>' ) . appendTo ( $ ( 'body' ) ) ; correctSizes = _fitToViewport ( $ ( myClone ) . width ( ) , $ ( myClone ) . height ( ) ) ; $ ( myClone ) . remove ( ) ; toInject = settings . inline _markup . replace ( /{content}/g , $ ( pp _images [ set _position ] ) . html ( ) ) ; break ; } ; if ( ! imgPreloader ) { $pp _pic _holder . find ( '#pp_full_res' ) [ 0 ] . innerHTML = toInject ; _showContent ( ) ; } ; } ) ; return false ; } ; $ . prettyPhoto . changePage = function ( direction ) { currentGalleryPage = 0 ; if ( direction == 'previous' ) { set _position -- ; if ( set _position < 0 ) { set _position = 0 ; return ; } ; } else if ( direction == 'next' ) { set _position ++ ; if ( set _position > $ ( pp _images ) . size ( ) - 1 ) { set _position = 0 ; } } else { set _position = direction ; } ; if ( ! doresize ) doresize = true ; $ ( '.pp_contract' ) . removeClass ( 'pp_contract' ) . addClass ( 'pp_expand' ) ; _hideContent ( function ( ) { $ . prettyPhoto . open ( ) ; } ) ; } ; $ . prettyPhoto . changeGalleryPage = function ( direction ) { if ( direction == 'next' ) { currentGalleryPage ++ ; if ( currentGalleryPage > totalPage ) { currentGalleryPage = 0 ; } ; } else if ( direction == ' previous
$ . prettyPhoto . stopSlideshow = function ( ) { $pp _pic _holder . find ( '.pp_pause' ) . unbind ( 'click' ) . removeClass ( 'pp_pause' ) . addClass ( 'pp_play' ) . click ( function ( ) { $ . prettyPhoto . startSlideshow ( ) ; return false ; } ) ; clearInterval ( pp _slideshow ) ; pp _slideshow = undefined ; }
$ . prettyPhoto . close = function ( ) { clearInterval ( pp _slideshow ) ; $pp _pic _holder . stop ( ) . find ( 'object,embed' ) . css ( 'visibility' , 'hidden' ) ; $ ( 'div.pp_pic_holder,div.ppt,.pp_fade' ) . fadeOut ( settings . animation _speed , function ( ) { $ ( this ) . remove ( ) ; } ) ; $pp _overlay . fadeOut ( settings . animation _speed , function ( ) { if ( $ . browser . msie && $ . browser . version == 6 ) $ ( 'select' ) . css ( 'visibility' , 'visible' ) ; if ( settings . hideflash ) $ ( 'object,embed' ) . css ( 'visibility' , 'visible' ) ; $ ( this ) . remove ( ) ; $ ( window ) . unbind ( 'scroll' ) ; settings . callback ( ) ; doresize = true ; pp _open = false ; delete settings ; } ) ; } ; _showContent = function ( ) { $ ( '.pp_loaderIcon' ) . hide ( ) ; $ppt . fadeTo ( settings . animation _speed , 1 ) ; projectedTop = scroll _pos [ 'scrollTop' ] + ( ( windowHeight / 2 ) - ( correctSizes [ 'containerHeight' ] / 2 ) ) ; if ( projectedTop < 0 ) projectedTop = 0 ; $pp _pic _holder . find ( '.pp_content' ) . animate ( { 'height' : correctSizes [ 'contentHeight' ] } , settings . animation _speed ) ; $pp _pic _holder . animate ( { 'top' : projectedTop , 'left' : ( windowWidth / 2 ) - ( correctSizes [ 'containerWidth' ] / 2 ) , 'width' : correctSizes [ 'containerWidth' ] } , settings . animation _speed , function ( ) { $pp _pic _holder . find ( '.pp_hoverContainer,#fullResImage' ) . height ( correctSizes [ 'height' ] ) . width ( correctSizes [ 'width' ] ) ; $pp _pic _holder . find ( '.pp_fade' ) . fadeIn ( settings . animation _speed ) ; if ( isSet && _getFileType ( pp _images [ set _position ] ) == "image" ) { $pp _pic _holder . find ( '.pp_hoverContainer' ) . show ( ) ; } else { $pp _pic _holder . find ( '.pp_hoverContainer' ) . hide ( ) ; }
if ( correctSizes [ 'resized' ] ) $ ( 'a.pp_expand,a.pp_contract' ) . fadeIn ( settings . animation _speed ) ; if ( settings . autoplay _slideshow && ! pp _slideshow && ! pp _open ) $ . prettyPhoto . startSlideshow ( ) ; settings . changepicturecallback ( ) ; pp _open = true ; } ) ; _insert _gallery ( ) ; } ; function _hideContent ( callback ) { $pp _pic _holder . find ( '#pp_full_res object,#pp_full_res embed' ) . css ( 'visibility' , 'hidden' ) ; $pp _pic _holder . find ( '.pp_fade' ) . fadeOut ( settings . animation _speed , function ( ) { $ ( '.pp_loaderIcon' ) . show ( ) ; callback ( ) ; } ) ; } ; function _checkPosition ( setCount ) { if ( set _position == setCount - 1 ) { $pp _pic _holder . find ( 'a.pp_next' ) . css ( 'visibility' , 'hidden' ) ; $pp _pic _holder . find ( 'a.pp_next' ) . addClass ( 'disabled' ) . unbind ( 'click' ) ; } else { $pp _pic _holder . find ( 'a.pp_next' ) . css ( 'visibility' , 'visible' ) ; $pp _pic _holder . find ( 'a.pp_next.disabled' ) . removeClass ( 'disabled' ) . bind ( 'click' , function ( ) { $ . prettyPhoto . changePage ( 'next' ) ; return false ; } ) ; } ; if ( set _position == 0 ) { $pp _pic _holder . find ( 'a.pp_previous' ) . css ( 'visibility' , 'hidden' ) . addClass ( 'disabled' ) . unbind ( 'click' ) ; } else { $pp _pic _holder . find ( 'a.pp_previous.disabled' ) . css ( 'visibility' , 'visible' ) . removeClass ( 'disabled' ) . bind ( 'click' , function ( ) { $ . prettyPhoto . changePage ( 'previous' ) ; return false ; } ) ; } ; ( setCount > 1 ) ? $ ( '.pp_nav' ) . s how ( ) : $ ( '.pp_nav' ) . hide ( ) ; } ; function _fitToViewport ( width , height ) { resized = false ; _getDimensions ( width , height ) ; imageWidth = width , imageHeight = height ; if ( ( ( pp _containerWidth > windowWidth ) || ( pp _containerHeight > windowHeight ) ) && doresize && settings . allow _resize && ! percentBased ) { resized = true , fitting = false ; while ( ! fitting ) { if ( ( pp _containerWidth > windowWidth ) ) { imageWidth = ( windowWidth - 200 ) ; imageHeight = ( height / width ) * imageWidth ; } else if ( ( pp _containerHeight > windowHeight ) ) { imageHeight = ( windowHeight - 200 ) ; imageWidth = ( width / height ) * imageHeight ; } else { fitting = true ; } ; pp _containerHeight = imageHeight , pp _containerWidth = imageWidth ; } ; _getDimensions ( imageWidth , imageHeight ) ; } ; return { width : Math . floor ( imageWidth ) , height : Math . floor ( imageHeight ) , containerHeight : Math . floor ( pp _containerHeight ) , containerWidth : Math . floor ( pp _containerWidth ) + 40 , contentHeight : Math . floor ( pp _contentHeight ) , contentWidth : Math . floor ( pp _contentWidth ) , resized : resized } ; } ; function _getDimensions ( width , height ) { width = parseFloat ( width ) ; height = parseFloat ( height ) ; $pp _details = $pp _pic _holder . find ( '.pp_details' ) ; $pp _details . width ( width ) ; detailsHeight = parseFloat ( $pp _details . css ( 'marginTop' ) ) + parseFloat ( $pp _details . css ( 'marginBottom' ) ) ; $pp _details = $pp _details . clone ( ) . appendTo ( $ ( 'body' ) ) . css ( { 'position' : 'absolute' , 'top' : - 10000 } ) ; detailsHeight += $pp _details . height ( ) ; detailsHeight = ( detailsHeight <= 34 ) ? 36 : detailsHeight ; if ( $ . browser . msie && $ . browser . version == 7 ) detailsHeight += 8 ; $pp _details . remove ( ) ; pp _contentHeight = height + detailsHeight ; pp _contentWidth = width ; pp _containerHeight = pp _contentHeight + $ppt . height ( ) + $pp _pic _holder . find ( '.pp_top' ) . height ( ) + $pp _pic _holder . find ( '.pp_bottom' ) . height ( ) ; pp _containerWidth = width ; }
function _getFileType ( itemSrc ) { if ( itemSrc . match ( /youtube\.com\/watch/i ) ) { return 'youtube' ; } else if ( itemSrc . match ( /vimeo\.com/i ) ) { return 'vimeo' ; } else if ( itemSrc . indexOf ( '.mov' ) != - 1 ) { return 'quicktime' ; } else if ( itemSrc . indexOf ( '.swf' ) != - 1 ) { return 'flash' ; } else if ( itemSrc . indexOf ( 'iframe' ) != - 1 ) { return 'iframe' ; } else if ( itemSrc . indexOf ( 'custom' ) != - 1 ) { return 'custom' ; } else if ( itemSrc . substr ( 0 , 1 ) == '#' ) { return 'inline' ; } else { return 'image' ; } ; } ; function _center _overlay ( ) { if ( doresize && typeof $pp _pic _holder != 'undefined' ) { scroll _pos = _get _scroll ( ) ; titleHeight = $ppt . height ( ) , contentHeight = $pp _pic _holder . height ( ) , contentwidth = $pp _pic _holder . width ( ) ; projectedTop = ( windowHeight / 2 ) + scroll _pos [ 'scrollTop' ] - ( contentHeight / 2 ) ; $pp _pic _holder . css ( { 'top' : projectedTop , 'left' : ( windowWidth / 2 ) + scroll _pos [ 'scrollLeft' ] - ( contentwidth / 2 ) } ) ; } ; } ; function _get _scroll ( ) { if ( self . pageYOffset ) { return { scrollTop : self . pageYOffset , scrollLeft : self . pageXOffset } ; } else if ( document . documentElement && document . documentElement . scrollTop ) { return { scrollTop : document . documentElement . scrollTop , scrollLeft : document . documentElement . scrollLeft } ; } else if ( document . body ) { return { scrollTop : document . body . scrollTop , scrollLeft : document . body . scrollLeft } ; } ; } ; function _resize _overlay ( ) { windowHeight = $ ( window ) . height ( ) , windowWidth = $ ( window ) . width ( ) ; if ( typeof $pp _overlay != "undefined" ) $pp _overlay . height ( $ ( document ) . height ( ) ) ; } ; function _insert _gallery ( ) { if ( isSet && settings . overlay _gallery && _getFileType ( pp _images [ set _position ] ) == "image" ) { itemWidth = 52 + 5 ; navWidth = ( settings . theme == "facebook" ) ? 58 : 38 ; itemsPerPage = Math . floor ( ( correctSizes [ 'containerWidth' ] - 100 - navWidth ) / itemWidth ) ; itemsPerPage = ( itemsPerPage < pp _images . length ) ? itemsPerPage : pp _images . length ; totalPage = Math . ceil ( pp _images . length / itemsPerPage ) - 1 ; if ( totalPage == 0 ) { navWidth = 0 ; $pp _pic _holder . find ( '.pp_gallery .pp_arrow_next,.pp_gallery .pp_arrow_previous' ) . hide ( ) ; } else { $pp _pic _holder . find ( '.pp_gallery .pp_arrow_next,.pp_gallery .pp_arrow_previous' ) . show ( ) ; } ; galleryWidth = itemsPerPage * itemWidth + navWidth ; $pp _pic _holder . find ( '.pp_gallery' ) . width ( galleryWidth ) . css ( 'margin-left' , - ( galleryWidth / 2 ) ) ; $pp _pic _holder . find ( '.pp_gallery ul' ) . width ( itemsPerPage * itemWidth ) . find ( 'li.selected' ) . removeClass ( 'selected' ) ; goToPage = ( Math . floor ( set _position / itemsPerPage ) <= totalPage ) ? Math . floor ( set _position / itemsPerPage ) : totalPage ; if ( itemsPerPage ) { $pp _pic _holder . find ( '.pp_gallery' ) . hide ( ) . show ( ) . removeClass ( 'disabled' ) ; } else { $pp _pic _holder . find ( '.pp_gallery' ) . hide ( ) . addClass ( 'disabled' ) ; }
$ . prettyPhoto . changeGalleryPage ( goToPage ) ; $pp _pic _holder . find ( '.pp_gallery ul li:eq(' + set _position + ')' ) . addClass ( 'selected' ) ; } else { $pp _pic _holder . find ( '.pp_content' ) . unbind ( 'mouseenter mouseleave' ) ; $pp _pic _holder . find ( '.pp_gallery' ) . hide ( ) ; } }
function _buildOverlay ( caller ) { theRel = $ ( caller ) . attr ( 'rel' ) ; galleryRegExp = /\[(?:.*)\]/ ; isSet = ( galleryRegExp . exec ( theRel ) ) ? true : false ; pp _images = ( isSet ) ? jQuery . map ( matchedObjects , function ( n , i ) { if ( $ ( n ) . attr ( 'rel' ) . indexOf ( theRel ) != - 1 ) return $ ( n ) . attr ( 'href' ) ; } ) : $ . makeArray ( $ ( caller ) . attr ( 'href' ) ) ; pp _titles = ( isSet ) ? jQuery . map ( matchedObjects , function ( n , i ) { if ( $ ( n ) . attr ( 'rel' ) . indexOf ( theRel ) != - 1 ) return ( $ ( n ) . find ( 'img' ) . attr ( 'alt' ) ) ? $ ( n ) . find ( 'img' ) . attr ( 'alt' ) : "" ; } ) : $ . makeArray ( $ ( caller ) . find ( 'img' ) . attr ( 'alt' ) ) ; pp _descriptions = ( isSet ) ? jQuery . map ( matchedObjects , function ( n , i ) { if ( $ ( n ) . attr ( 'rel' ) . indexOf ( theRel ) != - 1 ) return ( $ ( n ) . attr ( 'title' ) ) ? $ ( n ) . attr ( 'title' ) : "" ; } ) : $ . makeArray ( $ ( caller ) . attr ( 'title' ) ) ; $ ( 'body' ) . append ( settings . markup ) ; $pp _pic _holder = $ ( '.pp_pic_holder' ) , $ppt = $ ( '.ppt' ) , $pp _overlay = $ ( 'div.pp_overlay' ) ; if ( isSet && settings . overlay _gallery ) { currentGalleryPage = 0 ; toInject = "" ; for ( var i = 0 ; i < pp _images . length ; i ++ ) { var regex = new RegExp ( "(.*?)\.(jpg|jpeg|png|gif)$" ) ; var results = regex . exec ( pp _images [ i ] ) ; if ( ! results ) { classname = 'default' ; } else { classname = '' ; }
toInject += "<li class='" + classname + "'><a href='#'><img src='" + pp _images [ i ] + "' width='50' alt='' /></a></li>" ; } ; toInject = settings . gallery _markup . replace ( /{gallery}/g , toInject ) ; $pp _pic _holder . find ( '#pp_full_res' ) . after ( toInject ) ; $pp _pic _holder . find ( '.pp_gallery .pp_arrow_next' ) . click ( function ( ) { $ . prettyPhoto . changeGalleryPage ( 'next' ) ; $ . prettyPhoto . stopSlideshow ( ) ; return false ; } ) ; $pp _pic _holder . find ( '.pp_gallery .pp_arrow_previous' ) . click ( function ( ) { $ . prettyPhoto . changeGalleryPage ( 'previous' ) ; $ . prettyPhoto . stopSlideshow ( ) ; return false ; } ) ; $pp _pic _holder . find ( '.pp_content' ) . hover ( function ( ) { $pp _pic _holder . find ( '.pp_gallery:not(.disabled)' ) . fadeIn ( ) ; } , function ( ) { $pp _pic _holder . find ( '.pp_gallery:not(.disabled)' ) . fadeOut ( ) ; } ) ; itemWidth = 52 + 5 ; $pp _pic _holder . find ( '.pp_gallery ul li' ) . each ( function ( i ) { $ ( this ) . css ( { 'position' : 'absolute' , 'left' : i * itemWidth } ) ; $ ( this ) . find ( 'a' ) . unbind ( 'click' ) . click ( function ( ) { $ . prettyPhoto . changePage ( i ) ; $ . prettyPhoto . stopSlideshow ( ) ; return false ; } ) ; } ) ; } ; if ( settings . slideshow ) { $pp _pic _holder . find ( '.pp_nav' ) . prepend ( '<a href="#" class="pp_play">Play</a>' )
$pp _pic _holder . find ( '.pp_nav .pp_play' ) . click ( function ( ) { $ . prettyPhoto . startSlideshow ( ) ; return false ; } ) ; }
$pp _pic _holder . attr ( 'class' , 'pp_pic_holder ' + settings . theme ) ; $pp _overlay . css ( { 'opacity' : 0 , 'height' : $ ( document ) . height ( ) , 'width' : $ ( document ) . width ( ) } ) . bind ( 'click' , function ( ) { if ( ! settings . modal ) $ . prettyPhoto . close ( ) ; } ) ; $ ( 'a.pp_close' ) . bind ( 'click' , function ( ) { $ . prettyPhoto . close ( ) ; return false ; } ) ; $ ( 'a.pp_expand' ) . bind ( 'click' , function ( e ) { if ( $ ( this ) . hasClass ( 'pp_expand' ) ) { $ ( this ) . removeClass ( 'pp_expand' ) . addClass ( 'pp_contract' ) ; doresize = false ; } else { $ ( this ) . removeClass ( 'pp_contract' ) . addClass ( 'pp_expand' ) ; doresize = true ; } ; _hideContent ( function ( ) { $ . prettyPhoto . open ( ) ; } ) ; return false ; } ) ; $pp _pic _holder . find ( '.pp_previous, .pp_nav .pp_arrow_previous' ) . bind ( 'click' , function ( ) { $ . prettyPhoto . changePage ( 'previous' ) ; $ . prettyPhoto . stopSlideshow ( ) ; return false ; } ) ; $pp _pic _holder . find ( '.pp_next, .pp_nav .pp_arrow_next' ) . bind ( 'click' , function ( ) { $ . prettyPhoto . changePage ( 'next' ) ; $ . prettyPhoto . stopSlideshow ( ) ; return false ; } ) ; _center _overlay ( ) ; } ; return this . unbind ( 'click' ) . click ( $ . prettyPhoto . initialize ) ; } ; function grab _param ( name , url ) { name = name . replace ( /[\[]/ , "\\\[" ) . replace ( /[\]]/ , "\\\]" ) ; var regexS = "[\\?&]" + name + "=([^&#]*)" ; var regex = new RegExp ( regexS ) ; var results = regex . exec ( url ) ; return ( results == null ) ? "" : results [ 1 ] ; } } ) ( jQuery ) ;