2011-05-17 06:16:52 +02:00
$ ( document ) . ready ( function ( ) {
2011-05-17 06:32:48 +02:00
/ *
* The display is not yet object oriented . It ' s procedural code
* broken off into functions . It makes use of libphotofloat ' s
* PhotoFloat class for the network and management logic .
*
* All of this could potentially be object oriented , but presently
* it should be pretty readable and sufficient . The only thing to
* perhaps change in the future would be to consolidate calls to
* jQuery selectors . And perhaps it ' d be nice to move variable
* declarations to the top , to stress that JavaScript scope is
* for an entire function and always hoisted .
*
* None of the globals here polutes the global scope , as everything
* is enclosed in an anonymous function .
*
* /
/* Globals */
var currentAlbum = null ;
var currentPhoto = null ;
var currentPhotoIndex = - 1 ;
var previousAlbum = null ;
var previousPhoto = null ;
var originalTitle = document . title ;
var photoFloat = new PhotoFloat ( ) ;
2014-03-16 15:03:54 +01:00
var maxSize = 1024 ;
2011-05-17 06:32:48 +02:00
/* Displays */
2011-05-17 06:16:52 +02:00
function setTitle ( ) {
2011-05-18 05:50:02 +02:00
var title = "" , documentTitle = "" , last = "" , components , i ;
if ( ! currentAlbum . path . length )
2011-05-17 06:16:52 +02:00
components = [ originalTitle ] ;
else {
components = currentAlbum . path . split ( "/" ) ;
components . unshift ( originalTitle ) ;
}
2011-05-18 05:50:02 +02:00
if ( currentPhoto !== null )
2011-05-17 06:16:52 +02:00
documentTitle += photoFloat . trimExtension ( currentPhoto . name ) ;
2011-05-18 05:50:02 +02:00
for ( i = 0 ; i < components . length ; ++ i ) {
if ( i || currentPhoto !== null )
2011-05-17 06:16:52 +02:00
documentTitle += " \u00ab " ;
if ( i )
last += "/" + components [ i ] ;
2011-05-18 05:50:02 +02:00
if ( i < components . length - 1 || currentPhoto !== null )
title += "<a href=\"#!/" + ( i ? photoFloat . cachePath ( last . substring ( 1 ) ) : "" ) + "\">" ;
2011-05-17 06:16:52 +02:00
title += components [ i ] ;
documentTitle += components [ components . length - 1 - i ] ;
2011-05-18 05:50:02 +02:00
if ( i < components . length - 1 || currentPhoto !== null ) {
2011-05-17 06:16:52 +02:00
title += "</a>" ;
title += " » " ;
}
}
2011-05-18 05:50:02 +02:00
if ( currentPhoto !== null )
2011-05-17 06:16:52 +02:00
title += photoFloat . trimExtension ( currentPhoto . name ) ;
$ ( "#title" ) . html ( title ) ;
document . title = documentTitle ;
}
2011-05-18 05:50:02 +02:00
function scrollToThumb ( ) {
var photo , thumb ;
photo = currentPhoto ;
if ( photo === null ) {
photo = previousPhoto ;
if ( photo === null )
return ;
}
$ ( "#thumbs img" ) . each ( function ( ) {
if ( this . photo === photo ) {
thumb = $ ( this ) ;
return false ;
}
} ) ;
if ( typeof thumb === "undefined" )
return ;
if ( currentPhoto !== null ) {
var scroller = $ ( "#album-view" ) ;
scroller . stop ( ) . animate ( { scrollLeft : thumb . position ( ) . left + scroller . scrollLeft ( ) - scroller . width ( ) / 2 + thumb . width ( ) / 2 } , "slow" ) ;
} else
$ ( "html, body" ) . stop ( ) . animate ( { scrollTop : thumb . offset ( ) . top - $ ( window ) . height ( ) / 2 + thumb . height ( ) } , "slow" ) ;
if ( currentPhoto !== null ) {
$ ( "#thumbs img" ) . removeClass ( "current-thumb" ) ;
thumb . addClass ( "current-thumb" ) ;
}
}
2011-05-17 06:16:52 +02:00
function showAlbum ( populate ) {
2011-05-18 05:50:02 +02:00
var i , link , image , photos , thumbsElement , subalbums , subalbumsElement ;
if ( currentPhoto === null && previousPhoto === null )
2011-05-17 06:16:52 +02:00
$ ( "html, body" ) . stop ( ) . animate ( { scrollTop : 0 } , "slow" ) ;
if ( populate ) {
2011-05-18 05:50:02 +02:00
photos = [ ] ;
for ( i = 0 ; i < currentAlbum . photos . length ; ++ i ) {
link = $ ( "<a href=\"#!/" + photoFloat . photoHash ( currentAlbum , currentAlbum . photos [ i ] ) + "\"></a>" ) ;
image = $ ( "<img title=\"" + photoFloat . trimExtension ( currentAlbum . photos [ i ] . name ) + "\" alt=\"" + photoFloat . trimExtension ( currentAlbum . photos [ i ] . name ) + "\" src=\"" + photoFloat . photoPath ( currentAlbum , currentAlbum . photos [ i ] , 150 , true ) + "\" height=\"150\" width=\"150\" />" ) ;
2013-12-22 05:48:10 +01:00
if ( currentAlbum . photos [ i ] . mediaType == "video" )
image . css ( "background-image" , "url(" + image . attr ( "src" ) + ")" ) . attr ( "src" , "img/video-icon.png" ) ;
2011-05-17 06:16:52 +02:00
image . get ( 0 ) . photo = currentAlbum . photos [ i ] ;
2012-08-10 20:17:42 +02:00
link . append ( image ) ;
2011-05-17 06:16:52 +02:00
photos . push ( link ) ;
2012-08-10 20:17:42 +02:00
( function ( theLink , theImage , theAlbum ) {
theImage . error ( function ( ) {
photos . splice ( photos . indexOf ( theLink ) , 1 ) ;
theLink . remove ( ) ;
theAlbum . photos . splice ( theAlbum . photos . indexOf ( theImage . get ( 0 ) . photo ) , 1 ) ;
} ) ;
} ) ( link , image , currentAlbum ) ;
2011-05-17 06:16:52 +02:00
}
2011-05-18 05:50:02 +02:00
thumbsElement = $ ( "#thumbs" ) ;
2011-05-17 06:16:52 +02:00
thumbsElement . empty ( ) ;
thumbsElement . append . apply ( thumbsElement , photos ) ;
2011-05-18 05:50:02 +02:00
subalbums = [ ] ;
for ( i = currentAlbum . albums . length - 1 ; i >= 0 ; -- i ) {
link = $ ( "<a href=\"#!/" + photoFloat . albumHash ( currentAlbum . albums [ i ] ) + "\"></a>" ) ;
image = $ ( "<div title=\"" + currentAlbum . albums [ i ] . date + "\" class=\"album-button\">" + currentAlbum . albums [ i ] . path + "</div>" ) ;
2011-05-17 06:16:52 +02:00
link . append ( image ) ;
subalbums . push ( link ) ;
2012-08-10 20:17:42 +02:00
( function ( theContainer , theAlbum , theImage , theLink ) {
2011-05-17 06:16:52 +02:00
photoFloat . albumPhoto ( theAlbum , function ( album , photo ) {
theImage . css ( "background-image" , "url(" + photoFloat . photoPath ( album , photo , 150 , true ) + ")" ) ;
2012-08-10 20:17:42 +02:00
} , function error ( ) {
theContainer . albums . splice ( currentAlbum . albums . indexOf ( theAlbum ) , 1 ) ;
theLink . remove ( ) ;
subalbums . splice ( subalbums . indexOf ( theLink ) , 1 ) ;
2011-05-17 06:16:52 +02:00
} ) ;
2012-08-10 20:17:42 +02:00
} ) ( currentAlbum , currentAlbum . albums [ i ] , image , link ) ;
2011-05-17 06:16:52 +02:00
}
2011-05-18 05:50:02 +02:00
subalbumsElement = $ ( "#subalbums" ) ;
2011-05-17 06:16:52 +02:00
subalbumsElement . empty ( ) ;
subalbumsElement . append . apply ( subalbumsElement , subalbums ) ;
2011-06-24 09:02:50 +02:00
if ( currentAlbum . albums . length > 1 )
subalbumsElement . insertBefore ( thumbsElement ) ;
else
thumbsElement . insertBefore ( subalbumsElement ) ;
2011-05-17 06:16:52 +02:00
}
2011-05-18 05:50:02 +02:00
if ( currentPhoto === null ) {
2011-05-17 06:16:52 +02:00
$ ( "#thumbs img" ) . removeClass ( "current-thumb" ) ;
$ ( "#album-view" ) . removeClass ( "photo-view-container" ) ;
$ ( "#subalbums" ) . show ( ) ;
$ ( "#photo-view" ) . hide ( ) ;
2014-01-28 07:18:30 +01:00
$ ( "#video-box-inner" ) . empty ( ) ;
$ ( "#video-box" ) . hide ( ) ;
2011-05-17 06:16:52 +02:00
}
setTimeout ( scrollToThumb , 1 ) ;
}
function getDecimal ( fraction ) {
if ( fraction [ 0 ] < fraction [ 1 ] )
return fraction [ 0 ] + "/" + fraction [ 1 ] ;
return ( fraction [ 0 ] / fraction [ 1 ] ) . toString ( ) ;
}
function scaleImage ( ) {
2011-05-18 05:50:02 +02:00
var image , container ;
image = $ ( "#photo" ) ;
if ( image . get ( 0 ) === this )
2011-05-17 06:16:52 +02:00
$ ( window ) . bind ( "resize" , scaleImage ) ;
2011-05-18 05:50:02 +02:00
container = $ ( "#photo-view" ) ;
2011-07-11 21:28:18 +02:00
if ( image . css ( "width" ) !== "100%" && container . height ( ) * image . attr ( "ratio" ) > container . width ( ) )
2011-05-17 08:29:20 +02:00
image . css ( "width" , "100%" ) . css ( "height" , "auto" ) . css ( "position" , "absolute" ) . css ( "bottom" , 0 ) ;
2011-05-18 05:50:02 +02:00
else if ( image . css ( "height" ) !== "100%" )
2011-05-17 08:29:20 +02:00
image . css ( "height" , "100%" ) . css ( "width" , "auto" ) . css ( "position" , "" ) . css ( "bottom" , "" ) ;
2011-05-17 06:16:52 +02:00
}
2013-12-22 08:28:34 +01:00
function scaleVideo ( ) {
var video , container ;
video = $ ( "#video" ) ;
if ( video . get ( 0 ) === this )
$ ( window ) . bind ( "resize" , scaleVideo ) ;
container = $ ( "#photo-view" ) ;
if ( video . attr ( "width" ) > container . width ( ) && container . height ( ) * video . attr ( "ratio" ) > container . width ( ) )
video . css ( "width" , container . width ( ) ) . css ( "height" , container . width ( ) / video . attr ( "ratio" ) ) . parent ( ) . css ( "height" , container . width ( ) / video . attr ( "ratio" ) ) . css ( "margin-top" , - container . width ( ) / video . attr ( "ratio" ) / 2 ) . css ( "top" , "50%" ) ;
else if ( video . attr ( "height" ) > container . height ( ) && container . height ( ) * video . attr ( "ratio" ) < container . width ( ) )
video . css ( "height" , container . height ( ) ) . css ( "width" , container . height ( ) * video . attr ( "ratio" ) ) . parent ( ) . css ( "height" , "100%" ) . css ( "margin-top" , "0" ) . css ( "top" , "0" ) ;
else
video . css ( "height" , "" ) . css ( "width" , "" ) . parent ( ) . css ( "height" , video . attr ( "height" ) ) . css ( "margin-top" , - video . attr ( "height" ) / 2 ) . css ( "top" , "50%" ) ;
}
2011-05-17 06:16:52 +02:00
function showPhoto ( ) {
2013-12-21 04:40:25 +01:00
var width , height , photoSrc , videoSrc , previousPhoto , nextPhoto , nextLink , text ;
2014-01-28 07:18:30 +01:00
width = currentPhoto . size [ 0 ] ;
height = currentPhoto . size [ 1 ] ;
2013-12-21 04:40:25 +01:00
if ( currentPhoto . mediaType == "video" ) {
2014-01-28 07:18:30 +01:00
if ( ! Modernizr . video ) {
$ ( '<div id="video-unsupported"><p>Sorry, your browser doesn\'t support the HTML5 <video> element!</p><p>Here\'s a <a href="http://caniuse.com/video">list of which browsers do</a>.</p></div>' ) . appendTo ( '#video-box-inner' ) ;
}
2014-02-14 03:32:45 +01:00
else if ( ! Modernizr . video . webm ) {
2014-01-28 07:18:30 +01:00
$ ( '<div id="video-unsupported"><p>Sorry, your browser doesn\'t support the WebM video format!</p></div>' ) . appendTo ( '#video-box-inner' ) ;
}
else {
$ ( window ) . unbind ( "resize" , scaleVideo ) ;
$ ( window ) . unbind ( "resize" , scaleImage ) ;
videoSrc = photoFloat . videoPath ( currentAlbum , currentPhoto ) ;
$ ( '<video/>' , { id : 'video' , controls : true } ) . appendTo ( '#video-box-inner' )
. attr ( "width" , width ) . attr ( "height" , height ) . attr ( "ratio" , currentPhoto . size [ 0 ] / currentPhoto . size [ 1 ] )
. attr ( "src" , videoSrc )
. attr ( "alt" , currentPhoto . name )
. on ( 'loadstart' , scaleVideo ) ;
}
2013-12-22 09:04:30 +01:00
$ ( "head" ) . append ( "<link rel=\"video_src\" href=\"" + videoSrc + "\" />" ) ;
2013-12-22 08:28:34 +01:00
$ ( "#video-box-inner" ) . css ( 'height' , height + 'px' ) . css ( 'margin-top' , - height / 2 ) ;
$ ( "#photo-box" ) . hide ( ) ;
$ ( "#video-box" ) . show ( ) ;
2013-12-21 04:40:25 +01:00
}
else {
width = currentPhoto . size [ 0 ] ;
height = currentPhoto . size [ 1 ] ;
if ( width > height ) {
height = height / width * maxSize ;
width = maxSize ;
} else {
width = width / height * maxSize ;
height = maxSize ;
}
2013-12-22 08:28:34 +01:00
$ ( window ) . unbind ( "resize" , scaleVideo ) ;
2013-12-21 04:40:25 +01:00
$ ( window ) . unbind ( "resize" , scaleImage ) ;
photoSrc = photoFloat . photoPath ( currentAlbum , currentPhoto , maxSize , false ) ;
$ ( "#photo" )
. attr ( "width" , width ) . attr ( "height" , height ) . attr ( "ratio" , currentPhoto . size [ 0 ] / currentPhoto . size [ 1 ] )
. attr ( "src" , photoSrc )
. attr ( "alt" , currentPhoto . name )
. attr ( "title" , currentPhoto . date )
. load ( scaleImage ) ;
$ ( "head" ) . append ( "<link rel=\"image_src\" href=\"" + photoSrc + "\" />" ) ;
2014-01-28 07:18:30 +01:00
$ ( "#video-box-inner" ) . empty ( ) ;
2013-12-21 04:40:25 +01:00
$ ( "#video-box" ) . hide ( ) ;
$ ( "#photo-box" ) . show ( ) ;
2011-05-17 06:16:52 +02:00
}
2011-05-18 05:50:02 +02:00
previousPhoto = currentAlbum . photos [
2011-05-17 06:16:52 +02:00
( currentPhotoIndex - 1 < 0 ) ? ( currentAlbum . photos . length - 1 ) : ( currentPhotoIndex - 1 )
] ;
2011-05-18 05:50:02 +02:00
nextPhoto = currentAlbum . photos [
2011-05-17 06:16:52 +02:00
( currentPhotoIndex + 1 >= currentAlbum . photos . length ) ? 0 : ( currentPhotoIndex + 1 )
] ;
$ . preloadImages ( photoFloat . photoPath ( currentAlbum , nextPhoto , maxSize , false ) , photoFloat . photoPath ( currentAlbum , previousPhoto , maxSize , false ) ) ;
2011-05-18 05:50:02 +02:00
nextLink = "#!/" + photoFloat . photoHash ( currentAlbum , nextPhoto ) ;
2011-05-17 06:16:52 +02:00
$ ( "#next-photo" ) . attr ( "href" , nextLink ) ;
$ ( "#next" ) . attr ( "href" , nextLink ) ;
$ ( "#back" ) . attr ( "href" , "#!/" + photoFloat . photoHash ( currentAlbum , previousPhoto ) ) ;
$ ( "#original-link" ) . attr ( "target" , "_blank" ) . attr ( "href" , photoFloat . originalPhotoPath ( currentAlbum , currentPhoto ) ) ;
2011-05-18 05:50:02 +02:00
text = "<table>" ;
if ( typeof currentPhoto . make !== "undefined" ) text += "<tr><td>Camera Maker</td><td>" + currentPhoto . make + "</td></tr>" ;
if ( typeof currentPhoto . model !== "undefined" ) text += "<tr><td>Camera Model</td><td>" + currentPhoto . model + "</td></tr>" ;
if ( typeof currentPhoto . date !== "undefined" ) text += "<tr><td>Time Taken</td><td>" + currentPhoto . date + "</td></tr>" ;
if ( typeof currentPhoto . size !== "undefined" ) text += "<tr><td>Resolution</td><td>" + currentPhoto . size [ 0 ] + " x " + currentPhoto . size [ 1 ] + "</td></tr>" ;
if ( typeof currentPhoto . aperture !== "undefined" ) text += "<tr><td>Aperture</td><td> f/" + getDecimal ( currentPhoto . aperture ) + "</td></tr>" ;
if ( typeof currentPhoto . focalLength !== "undefined" ) text += "<tr><td>Focal Length</td><td>" + getDecimal ( currentPhoto . focalLength ) + " mm</td></tr>" ;
2011-06-27 23:12:59 +02:00
if ( typeof currentPhoto . subjectDistanceRange !== "undefined" ) text += "<tr><td>Subject Distance Range</td><td>" + currentPhoto . subjectDistanceRange + "</td></tr>" ;
2011-05-18 05:50:02 +02:00
if ( typeof currentPhoto . iso !== "undefined" ) text += "<tr><td>ISO</td><td>" + currentPhoto . iso + "</td></tr>" ;
2011-06-27 23:12:59 +02:00
if ( typeof currentPhoto . sceneCaptureType !== "undefined" ) text += "<tr><td>Scene Capture Type</td><td>" + currentPhoto . sceneCaptureType + "</td></tr>" ;
2011-05-18 05:50:02 +02:00
if ( typeof currentPhoto . exposureTime !== "undefined" ) text += "<tr><td>Exposure Time</td><td>" + getDecimal ( currentPhoto . exposureTime ) + " sec</td></tr>" ;
if ( typeof currentPhoto . exposureProgram !== "undefined" ) text += "<tr><td>Exposure Program</td><td>" + currentPhoto . exposureProgram + "</td></tr>" ;
if ( typeof currentPhoto . exposureCompensation !== "undefined" ) text += "<tr><td>Exposure Compensation</td><td>" + getDecimal ( currentPhoto . exposureCompensation ) + "</td></tr>" ;
if ( typeof currentPhoto . spectralSensitivity !== "undefined" ) text += "<tr><td>Spectral Sensitivity</td><td>" + currentPhoto . spectralSensitivity + "</td></tr>" ;
2011-06-27 23:12:59 +02:00
if ( typeof currentPhoto . sensingMethod !== "undefined" ) text += "<tr><td>Sensing Method</td><td>" + currentPhoto . sensingMethod + "</td></tr>" ;
if ( typeof currentPhoto . lightSource !== "undefined" ) text += "<tr><td>Light Source</td><td>" + currentPhoto . lightSource + "</td></tr>" ;
2011-05-18 05:50:02 +02:00
if ( typeof currentPhoto . flash !== "undefined" ) text += "<tr><td>Flash</td><td>" + currentPhoto . flash + "</td></tr>" ;
if ( typeof currentPhoto . orientation !== "undefined" ) text += "<tr><td>Orientation</td><td>" + currentPhoto . orientation + "</td></tr>" ;
2011-05-17 06:16:52 +02:00
text += "</table>" ;
$ ( "#metadata" ) . html ( text ) ;
$ ( "#album-view" ) . addClass ( "photo-view-container" ) ;
$ ( "#subalbums" ) . hide ( ) ;
$ ( "#photo-view" ) . show ( ) ;
}
2011-05-17 06:32:48 +02:00
/* Error displays */
2012-08-11 01:47:11 +02:00
function die ( error ) {
if ( error == 403 ) {
$ ( "#auth-text" ) . fadeIn ( 1000 ) ;
$ ( "#password" ) . focus ( ) ;
} else
$ ( "#error-text" ) . fadeIn ( 2500 ) ;
2011-05-17 06:16:52 +02:00
$ ( "#error-overlay" ) . fadeTo ( 500 , 0.8 ) ;
$ ( "body, html" ) . css ( "overflow" , "hidden" ) ;
}
function undie ( ) {
2012-08-11 01:47:11 +02:00
$ ( "#error-text, #error-overlay, #auth-text" ) . fadeOut ( 500 ) ;
2011-05-17 06:16:52 +02:00
$ ( "body, html" ) . css ( "overflow" , "auto" ) ;
}
2011-05-18 05:50:02 +02:00
2011-05-17 06:16:52 +02:00
2011-05-18 05:50:02 +02:00
/* Entry point for most events */
function hashParsed ( album , photo , photoIndex ) {
undie ( ) ;
$ ( "#loading" ) . hide ( ) ;
if ( album === currentAlbum && photo === currentPhoto )
return ;
previousAlbum = currentAlbum ;
previousPhoto = currentPhoto ;
currentAlbum = album ;
currentPhoto = photo ;
currentPhotoIndex = photoIndex ;
setTitle ( ) ;
if ( photo !== null )
showPhoto ( ) ;
2014-03-16 15:02:03 +01:00
showAlbum ( previousAlbum !== currentAlbum ) ;
2011-05-18 05:50:02 +02:00
}
2011-05-17 06:16:52 +02:00
2011-05-17 06:32:48 +02:00
/* Event listeners */
2011-05-17 06:16:52 +02:00
$ ( window ) . hashchange ( function ( ) {
$ ( "#loading" ) . show ( ) ;
$ ( "link[rel=image_src]" ) . remove ( ) ;
2013-12-22 09:04:30 +01:00
$ ( "link[rel=video_src]" ) . remove ( ) ;
2011-09-12 05:10:41 +02:00
if ( location . search . indexOf ( "?_escaped_fragment_=" ) === 0 ) {
location . hash = location . search . substring ( 20 ) ;
location . search = "" ;
}
2011-05-17 06:16:52 +02:00
photoFloat . parseHash ( location . hash , hashParsed , die ) ;
} ) ;
$ ( window ) . hashchange ( ) ;
$ ( document ) . keydown ( function ( e ) {
2011-05-18 05:50:02 +02:00
if ( currentPhoto === null )
2011-05-17 06:16:52 +02:00
return true ;
2011-05-18 05:50:02 +02:00
if ( e . keyCode === 39 ) {
2011-05-17 06:16:52 +02:00
window . location . href = $ ( "#next" ) . attr ( "href" ) ;
return false ;
2011-05-18 05:50:02 +02:00
} else if ( e . keyCode === 37 ) {
2011-05-17 06:16:52 +02:00
window . location . href = $ ( "#back" ) . attr ( "href" ) ;
return false ;
}
return true ;
} ) ;
$ ( document ) . mousewheel ( function ( event , delta ) {
2011-05-18 05:50:02 +02:00
if ( currentPhoto === null )
2011-05-17 06:16:52 +02:00
return true ;
if ( delta < 0 ) {
window . location . href = $ ( "#next" ) . attr ( "href" ) ;
return false ;
} else if ( delta > 0 ) {
window . location . href = $ ( "#back" ) . attr ( "href" ) ;
return false ;
}
return true ;
} ) ;
$ ( "#photo-box" ) . mouseenter ( function ( ) {
$ ( "#photo-links" ) . stop ( ) . fadeTo ( "slow" , 0.50 ) . css ( "display" , "inline" ) ;
} ) ;
$ ( "#photo-box" ) . mouseleave ( function ( ) {
$ ( "#photo-links" ) . stop ( ) . fadeOut ( "slow" ) ;
} ) ;
2012-04-19 20:52:41 +02:00
$ ( "#next, #back" ) . mouseenter ( function ( ) {
2012-04-19 20:17:12 +02:00
$ ( this ) . stop ( ) . fadeTo ( "slow" , 1 ) ;
2011-05-17 06:16:52 +02:00
} ) ;
$ ( "#next, #back" ) . mouseleave ( function ( ) {
2012-04-19 20:17:12 +02:00
$ ( this ) . stop ( ) . fadeTo ( "slow" , 0.35 ) ;
2011-05-17 06:16:52 +02:00
} ) ;
2012-04-18 07:38:04 +02:00
if ( $ . support . fullscreen ) {
2012-04-19 20:52:41 +02:00
$ ( "#fullscreen-divider" ) . show ( ) ;
2012-04-18 07:38:04 +02:00
$ ( "#fullscreen" ) . show ( ) . click ( function ( ) {
2012-04-19 20:52:41 +02:00
$ ( "#photo" ) . fullScreen ( { callback : function ( isFullscreen ) {
2014-03-16 15:03:54 +01:00
maxSize = isFullscreen ? 1600 : 1024 ;
2012-04-19 20:52:41 +02:00
showPhoto ( ) ;
} } ) ;
2012-04-18 07:38:04 +02:00
} ) ;
}
2011-05-17 06:16:52 +02:00
$ ( "#metadata-link" ) . click ( function ( ) {
if ( ! $ ( "#metadata" ) . is ( ":visible" ) )
$ ( "#metadata" ) . stop ( )
. css ( "height" , 0 )
. css ( "padding-top" , 0 )
. css ( "padding-bottom" , 0 )
. show ( )
. animate ( { height : $ ( "#metadata > table" ) . height ( ) , paddingTop : 3 , paddingBottom : 3 } , "slow" , function ( ) {
$ ( this ) . css ( "height" , "auto" ) ;
$ ( "#metadata-link" ) . text ( $ ( "#metadata-link" ) . text ( ) . replace ( "show" , "hide" ) ) ;
} ) ;
else
$ ( "#metadata" ) . stop ( ) . animate ( { height : 0 , paddingTop : 0 , paddingBottom : 0 } , "slow" , function ( ) {
$ ( this ) . hide ( ) ;
$ ( "#metadata-link" ) . text ( $ ( "#metadata-link" ) . text ( ) . replace ( "hide" , "show" ) ) ;
} ) ;
} ) ;
2012-08-11 01:47:11 +02:00
$ ( "#auth-form" ) . submit ( function ( ) {
var password = $ ( "#password" ) ;
password . css ( "background-color" , "rgb(128, 128, 200)" ) ;
photoFloat . authenticate ( password . val ( ) , function ( success ) {
password . val ( "" ) ;
if ( success ) {
password . css ( "background-color" , "rgb(200, 200, 200)" ) ;
$ ( window ) . hashchange ( ) ;
} else
password . css ( "background-color" , "rgb(255, 64, 64)" ) ;
} ) ;
return false ;
} ) ;
2011-05-17 06:16:52 +02:00
} ) ;