2011-12-13 12:29:05 +01:00
/ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Class : prettyPhoto
Use : Lightbox clone for jQuery
Author : Stephane Caron ( http : //www.no-margin-for-errors.com)
2012-03-28 12:05:21 +02:00
Version : 3.1 . 4
2011-12-13 12:29:05 +01:00
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - * /
2012-03-28 12:05:21 +02:00
( function ( $ ) { $ . prettyPhoto = { version : '3.1.4' } ; $ . fn . prettyPhoto = function ( pp _settings ) { pp _settings = jQuery . extend ( { hook : 'rel' , animation _speed : 'fast' , ajaxcallback : function ( ) { } , slideshow : 5000 , autoplay _slideshow : false , opacity : 0.80 , show _title : true , allow _resize : true , allow _expand : true , default _width : 500 , default _height : 344 , counter _separator _label : '/' , theme : 'pp_default' , horizontal _padding : 20 , hideflash : false , wmode : 'opaque' , autoplay : true , modal : false , deeplinking : true , overlay _gallery : true , overlay _gallery _max : 30 , keyboard _shortcuts : true , changepicturecallback : function ( ) { } , callback : function ( ) { } , ie6 _fallback : true , markup : ' < div class = "pp_pic_holder" > \
< div class = "ppt" > & nbsp ; < / d i v > \
< 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" > \
< 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 > \
< p class = "pp_description" > < / p > \
< div class = "pp_social" > { pp _social } < / d i v > \
< a class = "pp_close" href = "#" > Close < / a > \
< / 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 > \
< 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 > \
< div > \
< ul > \
{ gallery } \
< / u l > \
< / d i v > \
< a href = "#" class = "pp_arrow_next" > Next < / a > \
< /div>',image_markup:'<img id="fullResImage" src="{path}" / > ',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 o n t e n t } < / d i v > ' , c u s t o m _ m a r k u p : ' ' , s o c i a l _ t o o l s : ' < d i v c l a s s = " t w i t t e r " > < a h r e f = " h t t p : / / t w i t t e r . c o m / s h a r e " c l a s s = " t w i t t e r - s h a r e - b u t t o n " d a t a - c o u n t = " n o n e " > T w e e t < / a > < s c r i p t t y p e = " t e x t / j a v a s c r i p t " s r c = " h t t p : / / p l a t f o r m . t w i t t e r . c o m / w i d g e t s . j s " > < / s c r i p t > < / d i v > < d i v c l a s s = " f a c e b o o k " > < i f r a m e s r c = " / / w w w . f a c e b o o k . c o m / p l u g i n s / l i k e . p h p ? l o c a l e = e n _ U S & h r e f = { l o c a t i o n _ h r e f } & a m p ; l a y o u t = b u t t o n _ c o u n t & a m p ; s h o w _ f a c e s = t r u e & a m p ; w i d t h = 5 0 0 & a m p ; a c t i o n = l i k e & a m p ; f o n t & a m p ; c o l o r s c h e m e = l i g h t & a m p ; h e i g h t = 2 3 " s c r o l l i n g = " n o " f r a m e b o r d e r = " 0 " s t y l e = " b o r d e r : n o n e ; o v e r f l o w : h i d d e n ; w i d t h : 5 0 0 p x ; h e i g h t : 2 3 p x ; " a l l o w T r a n s p a r e n c y = " t r u e " > < / i f r a m e > < / d i v > ' } , 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 , p p _ d i m e n s i o n 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 . p r e t t y p h o t o ' ) . b i n d ( ' r e s i z e . p r e t t y p h o t o ' , 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 . p r e t t y p h o t o ' ) . b i n d ( ' k e y d o w n . p r e t t y p h o t o ' , 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 ' ) ; e . p r e v e n t D e f a u l t ( ) ; 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 ' ) ; e . p r e v e n t D e f a u l 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 ( ) ; e . preventDefault ( ) ; break ; } ; } ; } ; } ) ; } ; $ . prettyPhoto . initialize = function ( ) { settings = pp _settings ; if ( settings . theme == 'pp_default' ) settings . horizontal _padding = 16 ; if ( settings . ie6 _fallback && $ . browser . msie && parseInt ( $ . browser . version ) == 6 ) settings . theme = "light_square" ; theRel = $ ( this ) . attr ( settings . hook ) ; galleryRegExp = /\[(?:.*)\]/ ; isSet = ( galleryRegExp . exec ( theRel ) ) ? true : false ; pp _images = ( isSet ) ? jQuery . map ( matchedObjects , function ( n , i ) { if ( $ ( n ) . attr ( settings . hook ) . indexOf ( theRel ) != - 1 ) return $ ( n ) . attr ( 'href' ) ; } ) : $ . makeArray ( $ ( this ) . attr ( 'href' ) ) ; pp _titles = ( isSet ) ? jQuery . map ( matchedObjects , function ( n , i ) { if ( $ ( n ) . attr ( settings . hook ) . indexOf ( theRel ) != - 1 ) return ( $ ( n ) . find ( 'img' ) . attr ( 'alt' ) ) ? $ ( n ) . find ( 'img' ) . attr ( 'alt' ) : "" ; } ) : $ . makeArray ( $ ( this ) . find ( 'img' ) . attr ( 'alt' ) ) ; pp _descriptions = ( isSet ) ? jQuery . map ( matchedObjects , function ( n , i ) { if ( $ ( n ) . attr ( settings . hook ) . indexOf ( theRel ) != - 1 ) return ( $ ( n ) . attr ( 'title' ) ) ? $ ( n ) . attr ( 'title' ) : "" ; } ) : $ . makeArray ( $ ( this ) . attr ( 'title' ) ) ; if ( pp _images . length > settings . overlay _gallery _max ) settings . overlay _gallery = false ; set _position = jQuery . inArray ( $ ( this ) . attr ( 'href' ) , pp _images ) ; rel _index = ( isSet ) ? set _position : $ ( "a[" + settings . hook + "^='" + theRel + "']" ) . index ( $ ( this ) ) ; _build _overlay ( this ) ; if ( settings . allow _resize )
2011-12-13 12:29:05 +01:00
$ ( window ) . bind ( 'scroll.prettyphoto' , function ( ) { _center _overlay ( ) ; } ) ; $ . prettyPhoto . open ( ) ; return false ; }
2012-03-28 12:05:21 +02:00
$ . prettyPhoto . open = function ( event ) { if ( typeof settings == "undefined" ) { settings = pp _settings ; if ( $ . browser . msie && $ . browser . version == 6 ) settings . theme = "light_square" ; 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 = ( arguments [ 3 ] ) ? arguments [ 3 ] : 0 ; _build _overlay ( event . target ) ; }
if ( $ . browser . msie && $ . browser . version == 6 ) $ ( 'select' ) . css ( 'visibility' , 'hidden' ) ; if ( settings . hideflash ) $ ( 'object,embed,iframe[src*=youtube],iframe[src*=vimeo]' ) . css ( 'visibility' , 'hidden' ) ; _checkPosition ( $ ( pp _images ) . size ( ) ) ; $ ( '.pp_loaderIcon' ) . show ( ) ; if ( settings . deeplinking )
setHashtag ( ) ; if ( settings . social _tools ) { facebook _like _link = settings . social _tools . replace ( '{location_href}' , encodeURIComponent ( location . href ) ) ; $pp _pic _holder . find ( '.pp_social' ) . html ( facebook _like _link ) ; }
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 ( ) ) ; if ( typeof pp _descriptions [ set _position ] != 'undefined' && pp _descriptions [ set _position ] != "" ) { $pp _pic _holder . find ( '.pp_description' ) . show ( ) . html ( unescape ( pp _descriptions [ set _position ] ) ) ; } else { $pp _pic _holder . find ( '.pp_description' ) . hide ( ) ; }
2011-12-13 12:29:05 +01:00
movie _width = ( parseFloat ( getParam ( 'width' , pp _images [ set _position ] ) ) ) ? getParam ( 'width' , pp _images [ set _position ] ) : settings . default _width . toString ( ) ; movie _height = ( parseFloat ( getParam ( 'height' , pp _images [ set _position ] ) ) ) ? getParam ( 'height' , pp _images [ set _position ] ) : settings . default _height . toString ( ) ; percentBased = false ; if ( movie _height . indexOf ( '%' ) != - 1 ) { movie _height = parseFloat ( ( $ ( window ) . height ( ) * parseFloat ( movie _height ) / 100 ) - 150 ) ; percentBased = true ; }
if ( movie _width . indexOf ( '%' ) != - 1 ) { movie _width = parseFloat ( ( $ ( window ) . width ( ) * parseFloat ( movie _width ) / 100 ) - 150 ) ; percentBased = true ; }
2012-03-28 12:05:21 +02:00
$pp _pic _holder . fadeIn ( function ( ) { ( settings . show _title && pp _titles [ set _position ] != "" && typeof pp _titles [ set _position ] != "undefined" ) ? $ppt . html ( unescape ( pp _titles [ set _position ] ) ) : $ppt . html ( ' ' ) ; imgPreloader = "" ; skipInjection = false ; switch ( _getFileType ( pp _images [ set _position ] ) ) { case 'image' : imgPreloader = new Image ( ) ; nextImage = new Image ( ) ; if ( isSet && set _position < $ ( pp _images ) . size ( ) - 1 ) 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 . replace ( /{path}/g , pp _images [ set _position ] ) ; imgPreloader . onload = function ( ) { pp _dimensions = _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' : pp _dimensions = _fitToViewport ( movie _width , movie _height ) ; movie _id = getParam ( 'v' , pp _images [ set _position ] ) ; if ( movie _id == "" ) { movie _id = pp _images [ set _position ] . split ( 'youtu.be/' ) ; movie _id = movie _id [ 1 ] ; if ( movie _id . indexOf ( '?' ) > 0 )
movie _id = movie _id . substr ( 0 , movie _id . indexOf ( '?' ) ) ; if ( movie _id . indexOf ( '&' ) > 0 )
movie _id = movie _id . substr ( 0 , movie _id . indexOf ( '&' ) ) ; }
movie = 'http://www.youtube.com/embed/' + movie _id ; ( getParam ( 'rel' , pp _images [ set _position ] ) ) ? movie += "?rel=" + getParam ( 'rel' , pp _images [ set _position ] ) : movie += "?rel=1" ; if ( settings . autoplay ) movie += "&autoplay=1" ; toInject = settings . iframe _markup . replace ( /{width}/g , pp _dimensions [ 'width' ] ) . replace ( /{height}/g , pp _dimensions [ 'height' ] ) . replace ( /{wmode}/g , settings . wmode ) . replace ( /{path}/g , movie ) ; break ; case 'vimeo' : pp _dimensions = _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 = pp _dimensions [ 'width' ] + '/embed/?moog_width=' + pp _dimensions [ 'width' ] ; toInject = settings . iframe _markup . replace ( /{width}/g , vimeo _width ) . replace ( /{height}/g , pp _dimensions [ 'height' ] ) . replace ( /{path}/g , movie ) ; break ; case 'quicktime' : pp _dimensions = _fitToViewport ( movie _width , movie _height ) ; pp _dimensions [ 'height' ] += 15 ; pp _dimensions [ 'contentHeight' ] += 15 ; pp _dimensions [ 'containerHeight' ] += 15 ; toInject = settings . quicktime _markup . replace ( /{width}/g , pp _dimensions [ 'width' ] ) . replace ( /{height}/g , pp _dimensions [ 'height' ] ) . replace ( /{wmode}/g , settings . wmode ) . replace ( /{path}/g , pp _images [ set _position ] ) . replace ( /{autoplay}/g , settings . autoplay ) ; break ; case 'flash' : pp _dimensions = _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 , pp _dimensions [ 'width' ] ) . replace ( /{height}/g , pp _dimensions [ 'height' ] ) . replace ( /{wmode}/g , settings . wmode ) . replace ( /{path}/g , filename + '?' + flash _vars ) ; break ; case 'iframe' : pp _dimensions = _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 , pp _dimensions [ 'width' ] ) . replace ( /{height}/g , pp _dimensions [ 'height' ] ) . replace ( /{path}/g , frame _url ) ; break ; case 'ajax' : doresize = false ; pp _dimensions = _fitToViewport ( movie _width , movie _height ) ; doresize = true ; skipInjection = true ; $ . get ( pp _images [ set _position ] , function ( responseHTML ) { toInject = settings . inline _markup . replace ( /{content}/g , responseHTML ) ; $pp _pic _holder . find ( '#pp_full_res' ) [ 0 ] . innerHTML = toInject ; _showContent ( ) ; } ) ; break ; case 'custom' : pp _dimensions = _fitToViewport ( movie _width , movie _height ) ; toInject = settings . custom _markup ; break ; case 'inline' : myClone = $ ( pp _images [ set _position ] ) . clone ( ) . append ( '<br clear="all" />' ) . css ( { 'width' : settings . default _width } ) . wrapInner ( '<div id="pp_full_res"><div class="pp_inline"></div></div>' ) . appendTo ( $ ( 'body' ) ) . show ( ) ; doresize = false ; pp _dimensions = _fitToViewport ( $ ( myClone ) . width ( ) , $ ( myClone ) . height ( ) ) ; doresize = true ; $ ( myClone ) . remove ( ) ; toInject = settings . inline _markup . replace ( /{content}/g , $ ( pp _images [ set _position ] ) . html ( ) ) ; break ; } ; if ( ! imgPreloader && ! skipInjection ) { $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 = $ ( pp _images ) . size ( ) - 1 ; } else if ( direction == 'next' ) { set _position ++ ; if ( set _position > $ ( pp _images ) . size ( ) - 1 ) set _position = 0 ; } else { set _position = direction ; } ; rel _index = set _position ; if ( ! doresize ) doresize = true ; if ( settings . allow _expand ) { $ ( '.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' ) { currentGalleryPage -- ; if ( currentGalleryPage < 0 ) currentGalleryPage = totalPage ; } else { currentGalleryPage = direction ; } ; slide _speed = ( direction == 'next' || direction == 'previous' ) ? settings . animation _speed : 0 ; slide _to = currentGalleryPage * ( itemsPerPage * itemWidth ) ; $pp _gallery . find ( 'ul' ) . animate ( { left : - slide _to } , slide _speed ) ; } ; $ . prettyPhoto . startSlideshow = function ( ) { if ( typeof pp _slideshow == 'undefined' ) { $pp _pic _holder . find ( '.pp_play' ) . unbind ( 'click' ) . removeClass ( 'pp_play' ) . addClass ( 'pp_pause' ) . click ( function ( ) { $ . prettyPhoto . stopSlideshow ( ) ; return false ; } ) ; pp _slideshow = setInterval ( $ . prettyPhoto . startSlideshow , settings . slideshow ) ; } else { $ . prettyPhoto . changePage ( 'next' ) ; } ; }
2011-12-13 12:29:05 +01:00
$ . 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 ; }
2012-03-28 12:05:21 +02:00
$ . prettyPhoto . close = function ( ) { if ( $pp _overlay . is ( ":animated" ) ) return ; $ . prettyPhoto . stopSlideshow ( ) ; $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,iframe[src*=youtube],iframe[src*=vimeo]' ) . css ( 'visibility' , 'visible' ) ; $ ( this ) . remove ( ) ; $ ( window ) . unbind ( 'scroll.prettyphoto' ) ; clearHashtag ( ) ; settings . callback ( ) ; doresize = true ; pp _open = false ; delete settings ; } ) ; } ; function _showContent ( ) { $ ( '.pp_loaderIcon' ) . hide ( ) ; projectedTop = scroll _pos [ 'scrollTop' ] + ( ( windowHeight / 2 ) - ( pp _dimensions [ 'containerHeight' ] / 2 ) ) ; if ( projectedTop < 0 ) projectedTop = 0 ; $ppt . fadeTo ( settings . animation _speed , 1 ) ; $pp _pic _holder . find ( '.pp_content' ) . animate ( { height : pp _dimensions [ 'contentHeight' ] , width : pp _dimensions [ 'contentWidth' ] } , settings . animation _speed ) ; $pp _pic _holder . animate ( { 'top' : projectedTop , 'left' : ( ( windowWidth / 2 ) - ( pp _dimensions [ 'containerWidth' ] / 2 ) < 0 ) ? 0 : ( windowWidth / 2 ) - ( pp _dimensions [ 'containerWidth' ] / 2 ) , width : pp _dimensions [ 'containerWidth' ] } , settings . animation _speed , function ( ) { $pp _pic _holder . find ( '.pp_hoverContainer,#fullResImage' ) . height ( pp _dimensions [ 'height' ] ) . width ( pp _dimensions [ '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 ( settings . allow _expand ) { if ( pp _dimensions [ 'resized' ] ) { $ ( 'a.pp_expand,a.pp_contract' ) . show ( ) ; } else { $ ( 'a.pp_expand' ) . hide ( ) ; } }
if ( settings . autoplay _slideshow && ! pp _slideshow && ! pp _open ) $ . prettyPhoto . startSlideshow ( ) ; settings . changepicturecallback ( ) ; pp _open = true ; } ) ; _insert _gallery ( ) ; pp _settings . ajaxcallback ( ) ; } ; 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 ) { ( setCount > 1 ) ? $ ( '.pp_nav' ) . show ( ) : $ ( '.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 ) ; if ( ( pp _containerWidth > windowWidth ) || ( pp _containerHeight > windowHeight ) ) { _fitToViewport ( pp _containerWidth , pp _containerHeight ) } ; } ; return { width : Math . floor ( imageWidth ) , height : Math . floor ( imageHeight ) , containerHeight : Math . floor ( pp _containerHeight ) , containerWidth : Math . floor ( pp _containerWidth ) + ( settings . horizontal _padding * 2 ) , 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 ( ) . addClass ( settings . theme ) . width ( width ) . 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 _title = $pp _pic _holder . find ( '.ppt' ) ; $pp _title . width ( width ) ; titleHeight = parseFloat ( $pp _title . css ( 'marginTop' ) ) + parseFloat ( $pp _title . css ( 'marginBottom' ) ) ; $pp _title = $pp _title . clone ( ) . appendTo ( $ ( 'body' ) ) . css ( { 'position' : 'absolute' , 'top' : - 10000 } ) ; titleHeight += $pp _title . height ( ) ; $pp _title . remove ( ) ; pp _contentHeight = height + detailsHeight ; pp _contentWidth = width ; pp _containerHeight = pp _contentHeight + titleHeight + $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 ) || itemSrc . match ( /youtu\.be/i ) ) { return 'youtube' ; } else if ( itemSrc . match ( /vimeo\.com/i ) ) { return 'vimeo' ; } else if ( itemSrc . match ( /\b.mov\b/i ) ) { return 'quicktime' ; } else if ( itemSrc . match ( /\b.swf\b/i ) ) { return 'flash' ; } else if ( itemSrc . match ( /\biframe=true\b/i ) ) { return 'iframe' ; } else if ( itemSrc . match ( /\bajax=true\b/i ) ) { return 'ajax' ; } else if ( itemSrc . match ( /\bcustom=true\b/i ) ) { 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 ( ) ; contentHeight = $pp _pic _holder . height ( ) , contentwidth = $pp _pic _holder . width ( ) ; projectedTop = ( windowHeight / 2 ) + scroll _pos [ 'scrollTop' ] - ( contentHeight / 2 ) ; if ( projectedTop < 0 ) projectedTop = 0 ; if ( contentHeight > windowHeight )
2011-12-13 12:29:05 +01:00
return ; $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 ( ) ) . width ( windowWidth ) ; } ; function _insert _gallery ( ) { if ( isSet && settings . overlay _gallery && _getFileType ( pp _images [ set _position ] ) == "image" && ( settings . ie6 _fallback && ! ( $ . browser . msie && parseInt ( $ . browser . version ) == 6 ) ) ) { itemWidth = 52 + 5 ; navWidth = ( settings . theme == "facebook" || settings . theme == "pp_default" ) ? 50 : 30 ; itemsPerPage = Math . floor ( ( pp _dimensions [ '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 _gallery . find ( '.pp_arrow_next,.pp_arrow_previous' ) . hide ( ) ; } else { $pp _gallery . find ( '.pp_arrow_next,.pp_arrow_previous' ) . show ( ) ; } ; galleryWidth = itemsPerPage * itemWidth ; fullGalleryWidth = pp _images . length * itemWidth ; $pp _gallery . css ( 'margin-left' , - ( ( galleryWidth / 2 ) + ( navWidth / 2 ) ) ) . find ( 'div:first' ) . width ( galleryWidth + 5 ) . find ( 'ul' ) . width ( fullGalleryWidth ) . find ( 'li.selected' ) . removeClass ( 'selected' ) ; goToPage = ( Math . floor ( set _position / itemsPerPage ) < totalPage ) ? Math . floor ( set _position / itemsPerPage ) : totalPage ; $ . prettyPhoto . changeGalleryPage ( goToPage ) ; $pp _gallery _li . filter ( ':eq(' + set _position + ')' ) . addClass ( 'selected' ) ; } else { $pp _pic _holder . find ( '.pp_content' ) . unbind ( 'mouseenter mouseleave' ) ; } }
2012-03-28 12:05:21 +02:00
function _build _overlay ( caller ) { if ( settings . social _tools )
facebook _like _link = settings . social _tools . replace ( '{location_href}' , encodeURIComponent ( location . href ) ) ; settings . markup = settings . markup . replace ( '{pp_social}' , '' ) ; $ ( '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 ++ ) { if ( ! pp _images [ i ] . match ( /\b(jpg|jpeg|png|gif)\b/gi ) ) { classname = 'default' ; img _src = '' ; } else { classname = '' ; img _src = pp _images [ i ] ; }
2011-12-13 12:29:05 +01:00
toInject += "<li class='" + classname + "'><a href='#'><img src='" + img _src + "' width='50' alt='' /></a></li>" ; } ; toInject = settings . gallery _markup . replace ( /{gallery}/g , toInject ) ; $pp _pic _holder . find ( '#pp_full_res' ) . after ( toInject ) ; $pp _gallery = $ ( '.pp_pic_holder .pp_gallery' ) , $pp _gallery _li = $pp _gallery . find ( 'li' ) ; $pp _gallery . find ( '.pp_arrow_next' ) . click ( function ( ) { $ . prettyPhoto . changeGalleryPage ( 'next' ) ; $ . prettyPhoto . stopSlideshow ( ) ; return false ; } ) ; $pp _gallery . find ( '.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 _gallery _li . each ( function ( i ) { $ ( this ) . find ( 'a' ) . 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 ; } ) ; }
2012-03-28 12:05:21 +02:00
$pp _pic _holder . attr ( 'class' , 'pp_pic_holder ' + settings . theme ) ; $pp _overlay . css ( { 'opacity' : 0 , 'height' : $ ( document ) . height ( ) , 'width' : $ ( window ) . width ( ) } ) . bind ( 'click' , function ( ) { if ( ! settings . modal ) $ . prettyPhoto . close ( ) ; } ) ; $ ( 'a.pp_close' ) . bind ( 'click' , function ( ) { $ . prettyPhoto . close ( ) ; return false ; } ) ; if ( settings . allow _expand ) { $ ( '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 ( ) ; } ; if ( ! pp _alreadyInitialized && getHashtag ( ) ) { pp _alreadyInitialized = true ; hashIndex = getHashtag ( ) ; hashRel = hashIndex ; hashIndex = hashIndex . substring ( hashIndex . indexOf ( '/' ) + 1 , hashIndex . length - 1 ) ; hashRel = hashRel . substring ( 0 , hashRel . indexOf ( '/' ) ) ; setTimeout ( function ( ) { $ ( "a[" + pp _settings . hook + "^='" + hashRel + "']:eq(" + hashIndex + ")" ) . trigger ( 'click' ) ; } , 50 ) ; }
return this . unbind ( 'click.prettyphoto' ) . bind ( 'click.prettyphoto' , $ . prettyPhoto . initialize ) ; } ; function getHashtag ( ) { url = location . href ; hashtag = ( url . indexOf ( '#prettyPhoto' ) !== - 1 ) ? decodeURI ( url . substring ( url . indexOf ( '#prettyPhoto' ) + 1 , url . length ) ) : false ; return hashtag ; } ; function setHashtag ( ) { if ( typeof theRel == 'undefined' ) return ; location . hash = theRel + '/' + rel _index + '/' ; } ; function clearHashtag ( ) { if ( location . href . indexOf ( '#prettyPhoto' ) !== - 1 ) location . hash = "prettyPhoto" ; }
function getParam ( 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 ) ; var pp _alreadyInitialized = false ;