function inIframe() { try { return window.self !== window.top; } catch (e) { return true; } } function getParentDocument() { if( inIframe ) return parent.document; else return document; } function getParentWindow() { if( inIframe ) return parent.window; else return window; } /* * INIT OOG LIGHTBOX * * Adds the html for lightbox to document and inits some variables/events. * * Parameter: * String phpBackEnd (path to requests.php) * String flowplayer (path to flowplayer swf) * * Returns: - */ function initOogLightbox( phpBackEnd, flowplayer ) { if( inIframe() ) { var core_path = document.location.href.substring(0, document.location.href.indexOf('/showalbum.php')) + '/'; $( '' ).appendTo( getParentDocument().getElementsByTagName("html") ); oogLightboxRequests = core_path + phpBackEnd; (function( childWindow ) { getParentWindow().next = function() { childWindow.next(); }; getParentWindow().previous = function() { childWindow.previous(); }; getParentWindow().exitlightbox = function() { childWindow.exitlightbox(); }; getParentWindow().slideshow = function() { childWindow.slideshow(); }; getParentWindow().save_file = function() { childWindow.save_file(); }; getParentWindow().refresh_lightbox_extended_box = function(a, b) { childWindow.refresh_lightbox_extended_box(a, b); }; })( window ); } else { oogLightboxRequests = phpBackEnd; } flowplayer_swf = flowplayer; var oog_lightbox_html = '' + '
' + '
' + '

Click here to cancel loading

' + '
' + '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
' + '' + '
' + '
' + '' + '
' + '
' + '
' + // Oog-Lightbox will paste content here! '
' + '
' + '' + '
' + '
' + '
' + '
' + '
' + '
'; if( !getParentDocument().getElementById('oog_lightbox_main') ) $( oog_lightbox_html ).appendTo( getParentDocument().getElementsByTagName("html") ); lightbox_overlay = getParentDocument().getElementById('oog_lightbox_overlay'); lightbox_main = getParentDocument().getElementById('oog_lightbox_main'); lightbox_loading = getParentDocument().getElementById('oog_lightbox_loading'); lightbox_overlay.style.display = 'block'; lightbox_main.style.display = 'block'; lightbox_loading.style.display = 'block'; var first_windowheight = (getParentWindow().innerHeight) ? getParentWindow().innerHeight : getParentWindow().document.documentElement.clientHeight; var first_windowwidth = (getParentWindow().innerWidth) ? getParentWindow().innerWidth : getParentWindow().document.documentElement.clientWidth; lightbox_main_height_percent = lightbox_main.offsetHeight / first_windowheight * 100; lightbox_main_width_percent = lightbox_main.offsetWidth / first_windowwidth * 100; lightbox_main_top_percent = (100 - lightbox_main_height_percent) / 2; lightbox_main_left_percent = (100 - lightbox_main_width_percent) / 2; lightbox_main.style.top = lightbox_main_top_percent + '%'; lightbox_main.style.left = lightbox_main_left_percent + '%'; getParentWindow().lightbox_slideshow = 0; lightbox_timeout = false; lightbox_extended = ''; lightbox_firsttitle = getParentDocument().title; isDescription = false; descriptionFocused = false; show_error_filedescription = true; lightbox_loading_height = lightbox_loading.offsetHeight; lightbox_loading_width = lightbox_loading.offsetWidth; getParentDocument().getElementById('oog_lightbox_next_radius').onmouseover = function() { getParentDocument().getElementById('oog_lightbox_next_but').style.backgroundPosition='-54px 0px'; } getParentDocument().getElementById('oog_lightbox_next_radius').onmouseout = function() { getParentDocument().getElementById('oog_lightbox_next_but').style.backgroundPosition='0px 0px'; } getParentDocument().getElementById('oog_lightbox_previous_radius').onmouseover = function() { getParentDocument().getElementById('oog_lightbox_previous_but').style.backgroundPosition='-54px 0px'; } getParentDocument().getElementById('oog_lightbox_previous_radius').onmouseout = function() { getParentDocument().getElementById('oog_lightbox_previous_but').style.backgroundPosition='0px 0px'; } /*getParentDocument().getElementById('oog_lightbox_playlist_but').onmouseover = function() { getParentDocument().getElementById('oog_lightbox_playlist_but').style.backgroundPosition = (getParentWindow().lightbox_slideshow == 0) ? '-17px 0px' : '-17px -17px'; } getParentDocument().getElementById('oog_lightbox_playlist_but').onmouseout = function() { getParentDocument().getElementById('oog_lightbox_playlist_but').style.backgroundPosition = (getParentWindow().lightbox_slideshow == 0) ? '0px 0px' : '0px -17px'; }*/ } /* * RESIZE LIGHTBOX * * * * Parameter: - * Returns: - */ function resizelightbox() { refresh_lightbox_extended_box('', false); var windowheight = (getParentWindow().innerHeight) ? getParentWindow().innerHeight : getParentWindow().document.documentElement.clientHeight; var windowwidth = (getParentWindow().innerWidth) ? getParentWindow().innerWidth : getParentWindow().document.documentElement.clientWidth; var extra_margin_top = 0; var extra_height = 0; if(lightbox_extended != '') { extra_margin_top = extra_margin_top - 100; extra_height = extra_height - 150; } if(isDescription) { extra_margin_top = extra_margin_top - 12; extra_height = extra_height - 36; } heightspace = Math.round(windowheight / 100 * lightbox_main_height_percent - 64 + extra_height); widthspace = Math.round(windowwidth / 100 * lightbox_main_width_percent - 54); new_photo_height = 0; new_photo_width = 0; if(resize_photos == 'all') { new_photo_height = heightspace; new_photo_width = heightspace * (firstimgwidth / firstimgheight); if(new_photo_width > widthspace) { new_photo_width = widthspace; new_photo_height = widthspace * (firstimgheight / firstimgwidth); } } else { if(firstimgheight > heightspace || firstimgwidth > widthspace) { new_photo_height = heightspace; new_photo_width = heightspace * (firstimgwidth / firstimgheight); if(new_photo_width > widthspace) { new_photo_width = widthspace; new_photo_height = widthspace * (firstimgheight / firstimgwidth); } } else { new_photo_height = firstimgheight; new_photo_width = firstimgwidth; } } if(firstimgwidth != 0 && firstimgheight != 0) { if(mediafile_extension == 'jpg' || mediafile_extension == 'jpeg' || mediafile_extension == 'gif' || mediafile_extension == 'png') { new_photo_width = ( new_photo_height - 7 ) * ( firstimgwidth / firstimgheight ); lightbox_photo.style.height = new_photo_height + 'px'; lightbox_photo.style.width = new_photo_width + 'px'; } else if(mediafile_extension == 'flv' || mediafile_extension == 'mp4') { new_photo_width = ( new_photo_height - 24 ) * ( firstimgwidth / firstimgheight ); flowplayer_video.style.height = new_photo_height + 'px'; flowplayer_video.style.width = new_photo_width + 'px'; } else if(mediafile_extension == 'mp3') { new_photo_width = ( new_photo_height - 7 ) * ( firstimgwidth / firstimgheight ); flowplayer_video.style.width = new_photo_width + 'px'; flowplayer_video.style.height = '40px'; } } $(getParentDocument().getElementById('oog_lightbox_filedescription')).css('width', new_photo_width + 'px'); lightbox_main_width = $(getParentDocument().getElementById('oog_lightbox_main')).width(); lightbox_main_height = $(getParentDocument().getElementById('oog_lightbox_main')).height(); getParentDocument().getElementById('oog_lightbox_next_radius').style.height = ( new_photo_height / 100 * 85 ) + 'px'; getParentDocument().getElementById('oog_lightbox_next_radius').style.width = ( new_photo_width / 100 * 45 ) + 'px'; getParentDocument().getElementById('oog_lightbox_next_radius').style.bottom = ( ( lightbox_main_height - ( new_photo_height + 64 ) ) / 2 + 34 - extra_margin_top ) + 'px'; getParentDocument().getElementById('oog_lightbox_next_radius').style.right = ( ( lightbox_main_width - ( new_photo_width + 54 ) ) / 2 - 16 ) + 'px'; getParentDocument().getElementById('oog_lightbox_previous_radius').style.height = ( new_photo_height / 100 * 85 ) + 'px'; getParentDocument().getElementById('oog_lightbox_previous_radius').style.width = ( new_photo_width / 100 * 45 ) + 'px'; getParentDocument().getElementById('oog_lightbox_previous_radius').style.bottom = ( ( lightbox_main_height - ( new_photo_height + 64 ) ) / 2 + 34 - extra_margin_top ) + 'px'; getParentDocument().getElementById('oog_lightbox_previous_radius').style.left = ( ( lightbox_main_width - ( new_photo_width + 54 ) ) / 2 - 16 ) + 'px'; getParentDocument().getElementById('oog_lightbox_close_but').style.top = ( ( lightbox_main_height - ( new_photo_height + 64 ) ) / 2 - 6 + extra_margin_top ) + 'px'; getParentDocument().getElementById('oog_lightbox_close_but').style.right = ( ( lightbox_main_width - ( new_photo_width + 54 ) ) / 2 - 10 ) + 'px'; getParentDocument().getElementById('oog_lightbox_photo_box').style.marginLeft = ( ( lightbox_main_width - ( new_photo_width + 54 ) ) / 2 ) + 'px'; getParentDocument().getElementById('oog_lightbox_photo_box').style.marginTop = ( ( lightbox_main_height - ( new_photo_height + 64 ) ) / 2 + extra_margin_top ) + 'px'; getParentDocument().getElementById('oog_lightbox_shad_top').style.width = new_photo_width + 28 + 'px'; getParentDocument().getElementById('oog_lightbox_shad_bottom').style.width = new_photo_width + 28 + 'px'; getParentDocument().getElementById('oog_lightbox_shad_left').style.height = new_photo_height + 28 + 'px'; getParentDocument().getElementById('oog_lightbox_shad_right').style.height = new_photo_height + 28 + 'px'; lightbox_main.style.top = Math.round( windowheight / 100 * lightbox_main_top_percent ) + 'px'; lightbox_main.style.left = Math.round( windowwidth / 100 * lightbox_main_left_percent ) + 'px'; lightbox_overlay.style.position = 'fixed'; lightbox_main.style.position = 'fixed'; lightbox_overlay.style.height = '100%'; lightbox_overlay.style.width = '100%'; } /* * LOAD MEDIA * * * * Parameter: - * Returns: - */ function load_media() { // make loading visible // $(getParentDocument().getElementById('oog_lightbox_loading')).fadeOut(0); lightbox_loading.style.visibility = 'visible'; $(getParentDocument().getElementById('oog_lightbox_loading')).fadeIn(fadeInOut_loading); // add name of file to document title // getParentDocument().title = lightbox_firsttitle + ' - ' + oog_photoname; // clear filewrapper & description // getParentDocument().getElementById('oog_lightbox_photo_wrapper').innerHTML = ''; getParentDocument().getElementById('oog_lightbox_filedescription').innerHTML = ''; // if have to load an image // if(mediafile_extension == 'jpg' || mediafile_extension == 'jpeg' || mediafile_extension == 'gif' || mediafile_extension == 'png') { // insert img element for photo into the filewrapper // var img_tag = getParentDocument().createElement('img'); var img_tag_id = getParentDocument().createAttribute('id'); img_tag_id.nodeValue = 'oog_lightbox_photo'; var img_tag_src = getParentDocument().createAttribute('src'); img_tag_src.nodeValue = ''; var img_tag_border = getParentDocument().createAttribute('border'); img_tag_border.nodeValue = '0px'; img_tag.setAttributeNode(img_tag_id); img_tag.setAttributeNode(img_tag_src); img_tag.setAttributeNode(img_tag_border); getParentDocument().getElementById('oog_lightbox_photo_wrapper').appendChild(img_tag); // resizelightbox() needs this for accessing height & width of photo element // lightbox_photo = getParentDocument().getElementById('oog_lightbox_photo'); lightbox_img = new Image(); lightbox_img.onload = function() { // loading photo done // // take original dimensions (resizelightbox() needs them) // firstimgheight = lightbox_img.height; firstimgwidth = lightbox_img.width; // resize before file will be visible // resizelightbox(); // hide loading // $(getParentDocument().getElementById('oog_lightbox_loading')).fadeOut(fadeInOut_loading, function() { lightbox_loading.style.visibility = 'hidden'; }); // make lightbox visible // $(getParentDocument().getElementById('oog_lightbox_main')).fadeOut(0); lightbox_main.style.visibility = 'visible'; getParentDocument().getElementById('oog_lightbox_photo_box').style.display = 'block'; //for IE7 $(getParentDocument().getElementById('oog_lightbox_main')).fadeIn(fadeInOut_file, function() { // display description // display_filedescription(); // if slideshow is active // if(getParentWindow().lightbox_slideshow == 1) lightbox_timeout = window.setTimeout('next()', timeout_slideshow); }); resizelightbox(); } // insert photo source to load // lightbox_img.src = oogLightboxRequests + 'stream&album=' + escape(oog_album) + '&file=' + escape(oog_photoname); lightbox_photo.src = oogLightboxRequests + 'stream&album=' + escape(oog_album) + '&file=' + escape(oog_photoname); } else if(mediafile_extension == 'flv' || mediafile_extension == 'mp4') { // if have to load a video // // insert a element for videoplayer (flowplayer) into the filewrapper // var player = getParentDocument().createElement('a'); var player_id = getParentDocument().createAttribute('id'); player_id.nodeValue = 'player'; player.setAttributeNode(player_id); var player_style = getParentDocument().createAttribute('style'); player_style.nodeValue = 'width: 1px; height: 1px; display: block; margin-left: 14px;'; player.setAttributeNode(player_style); getParentDocument().getElementById('oog_lightbox_photo_wrapper').appendChild(player); // set lightbox visible or onMetaData event will not fire // lightbox_main.style.visibility = 'visible'; getParentDocument().getElementById('oog_lightbox_photo_box').style.display = 'block'; //for IE7 $(getParentDocument().getElementById('oog_lightbox_main')).fadeIn(0); // we can hide lightbox by this: // $(getParentDocument().getElementById('oog_lightbox_main')).css('opacity', '0'); ///////////////////////////////////////////////// have to find solution!! // load/init flowplayer // flowplayer('player', {src: flowplayer_swf, wmode: 'window'},{ clip: { autoPlay: true, autoBuffering: true, onMetaData: function(clip) { // loading/initing flowplayer done // // resizelightbox() needs this for accessing height & width of flowplayer // flowplayer_video = this.getParent(); flpl = this; // hide loading // $(getParentDocument().getElementById('oog_lightbox_loading')).fadeOut(fadeInOut_loading, function() { lightbox_loading.style.visibility = 'hidden'; // get original dimensions (resizelightbox() needs them) // firstimgwidth = clip.metaData.width; firstimgheight = clip.metaData.height; // make lightbox visible // $(getParentDocument().getElementById('oog_lightbox_main')).css('opacity', '1'); ///////////////////////////////////////////////// have to find solution!! resizelightbox(); }); }, onFinish: function() { if(getParentWindow().lightbox_slideshow == 1) next(); }, url: escape(oogLightboxRequests + 'stream&album=' + oog_album + '&file=' + oog_photoname), scaling: "fit" } }); } else if(mediafile_extension == 'mp3') { // have to load an audio // // insert div element for audioplayer (flowplayer) into the filewrapper // var player = getParentDocument().createElement('div'); var player_href = getParentDocument().createAttribute('href'); player_href.nodeValue = oogLightboxRequests + 'read&album=' + escape(oog_album) + '&file=' + escape(oog_photoname); player.setAttributeNode(player_href); var player_id = getParentDocument().createAttribute('id'); player_id.nodeValue = 'player'; player.setAttributeNode(player_id); var player_style = getParentDocument().createAttribute('style'); player_style.nodeValue = 'width: 1px; height: 1px; display: block; margin-left: 14px;'; player.setAttributeNode(player_style); getParentDocument().getElementById('oog_lightbox_photo_wrapper').appendChild(player); // set following or onMetaData event will not fire // lightbox_main.style.visibility = 'visible'; getParentDocument().getElementById('oog_lightbox_photo_box').style.display = 'block'; //for IE7 $(getParentDocument().getElementById('oog_lightbox_main')).fadeIn(0); // we can hide lightbox by this: // $(getParentDocument().getElementById('oog_lightbox_main')).css('opacity', '0'); ///////////////////////////////////////////////// have to find solution!! // load/init flowplayer // flowplayer('player', {src: flowplayer_swf, wmode: 'window'},{ plugins: { controls: { fullscreen: false, height: 40 } }, clip: { autoPlay: true, onStart: function(clip) { // loading/initing flowplayer done // // resizelightbox() needs this for accessing height & width of flowplayer // flowplayer_video = this.getParent(); flpl = this; // hide loading // $(getParentDocument().getElementById('oog_lightbox_loading')).fadeOut(fadeInOut_loading, function() { lightbox_loading.style.visibility = 'hidden'; // set dimensions (resizelightbox() needs them) // firstimgwidth = 800; firstimgheight = 100; // make lightbox visible // $(getParentDocument().getElementById('oog_lightbox_main')).css('opacity', '1'); ///////////////////////////////////////////////// have to find solution!! resizelightbox(); }); }, onFinish: function() { if(getParentWindow().lightbox_slideshow == 1) next(); }, url: escape(oogLightboxRequests + 'stream&album=' + oog_album + '&file=' + oog_photoname), scaling: "fit" } }); } else { alert('Error: Unknown Format'); exitlightbox(); } } /* * START LIGHTBOX * * Have to be called if you want to show a file with Lightbox. * * Parameter: * String albumpath (path to album. format: '../albums/[somePath]/') * String photoname (filename to show in lightbox including extension) * Boolean descEditable (makes description editable) * Boolean focusDesc (focus the description.) * * Returns: - */ function startlightbox(albumpath, photoname, descEditable, focusDesc) { if(photoname == 'startSlideshow') { getParentWindow().lightbox_slideshow = 1; photoname = getParentDocument().getElementsByName('thumb')[0].title; } if(getParentWindow().lightbox_slideshow == 1) lightbox_timeout = null; // init onresize event // getParentWindow().onresize = function() { if(getParentDocument().getElementById('oog_lightbox_main').style.visibility == 'visible') resizelightbox(); } // init onkeydown event // getParentDocument().onkeydown = function(event) { if(!event) event = getParentWindow().event; var keycode = event.which || event.keyCode; // left arrowkey // if(keycode==37 && getParentDocument().getElementById('oog_lightbox_main').style.visibility=='visible' && !descriptionFocused) previous(); // right arrowkey // if(keycode==39 && getParentDocument().getElementById('oog_lightbox_main').style.visibility=='visible' && !descriptionFocused) next(); // esc // if(keycode==27) exitlightbox(); } // init original dimensions // firstimgwidth = 0; firstimgheight = 0; // make some parameters global // oog_album = albumpath; oog_photoname = photoname; if(descEditable) { descriptionEditable = true; } else { descriptionEditable = false; } if(focusDesc && descEditable) { focusDescription = true; } else { focusDescription = false; } // get extension of file // mediafile_extension = oog_photoname.substring(oog_photoname.lastIndexOf('.') + 1, oog_photoname.length).toLowerCase(); //mediafile_extension = oog_photoname.split('.').pop().toLowerCase(); // if a file is displayed at this moment // if(getParentDocument().getElementById('oog_lightbox_main').style.visibility == 'visible') { // hide lightbox, means the file & buttons and then start loading // $(getParentDocument().getElementById('oog_lightbox_main')).fadeOut(fadeInOut_file, function() { lightbox_main.style.visibility = 'hidden'; getParentDocument().getElementById('oog_lightbox_photo_box').style.display = 'none'; //for IE7 getParentDocument().getElementById('oog_lightbox_photo_wrapper').innerHTML = ''; getParentDocument().getElementById('oog_lightbox_filedescription').innerHTML = ''; // start loading file // load_media(); }); } else { // normal: no file is displayed // // make overlay visible // lightbox_overlay.style.width = '100%'; lightbox_overlay.style.height = '100%'; $(getParentDocument().getElementById('oog_lightbox_overlay')).fadeOut(0); lightbox_overlay.style.visibility = 'visible'; $(getParentDocument().getElementById('oog_lightbox_overlay')).fadeIn(fadeInOut_overlay); // start loading file // load_media(); } } /* * EXIT LIGHTBOX * * * * Parameter: - * Returns: - */ function exitlightbox() { // clear slideshow timeout and set slideshow off // if(getParentWindow().lightbox_slideshow == 1) { window.clearTimeout(lightbox_timeout); getParentWindow().lightbox_slideshow = 0; } // cancle current loading // if(mediafile_extension == 'jpg' || mediafile_extension == 'jpeg' || mediafile_extension == 'gif' || mediafile_extension == 'png') { lightbox_img.onload = null; lightbox_img.src = null; if(self.stop) { getParentWindow().stop(); } else if(getParentDocument().execCommand) { getParentDocument().execCommand('Stop'); } } else if(mediafile_extension == 'flv' || mediafile_extension == 'mp3' || mediafile_extension == 'mp4') { try { flpl.stop(); } catch(e) {} try { flpl.stopBuffering(); } catch(e) {} } $(getParentDocument().getElementById('oog_lightbox_extended_box')).css('display', 'none'); // hide loading // $(getParentDocument().getElementById('oog_lightbox_loading')).fadeOut(fadeInOut_loading, function() { lightbox_loading.style.visibility = 'hidden'; }); // hide lightbox // $(getParentDocument().getElementById('oog_lightbox_main')).fadeOut(fadeInOut_file, function() { lightbox_main.style.visibility = 'hidden'; getParentDocument().getElementById('oog_lightbox_photo_box').style.display = 'none'; //for IE7 getParentDocument().getElementById('oog_lightbox_photo_wrapper').innerHTML = ''; getParentDocument().getElementById('oog_lightbox_filedescription').innerHTML = ''; }); // restore document title // getParentDocument().title = lightbox_firsttitle; // hide overlay // $(getParentDocument().getElementById('oog_lightbox_overlay')).fadeOut(fadeInOut_overlay, function() { lightbox_overlay.style.width = '0px'; lightbox_overlay.style.height = '0px'; lightbox_overlay.style.visibility = 'hidden'; }); } /* * PREVIOUS * * Will call startlightbox() with previous mediafile of album as parameter. * If there are pages defined it will show previous page when previous file is there. * * Parameter: - * Returns: - */ function previous() { if(mediafile_extension == 'flv' || mediafile_extension == 'mp3' || mediafile_extension == 'mp4') { flpl.stop(); flpl.stopBuffering(); } // find out previousphoto // var count = document.getElementsByName('thumb').length; for(var i = 0; i < count; i++) { if(document.getElementsByName('thumb')[i].title == oog_photoname) { if(i == 0) { // if there are pages defined // if(typeof current_page != 'undefined' && typeof num_pages != 'undefined' && typeof all_thumbs != 'undefined' && typeof max_thumbs != 'undefined') { if(current_page != 0) { show_page(current_page - 1); } else { show_page(num_pages-1); } var previousphoto = document.getElementsByName('thumb')[document.getElementsByName('thumb').length - 1].title; } else { // if no pages // var previousphoto = document.getElementsByName('thumb')[count-1].title; } } else { var previousphoto = document.getElementsByName('thumb')[i-1].title; } break; } } // start presentation of previous file in album // startlightbox(oog_album, previousphoto, descriptionEditable, focusDescription); } /* * NEXT * * Will call startlightbox() with next mediafile of album as parameter. * If there are pages defined it will show next page when next file is there. * * Parameter: - * Returns: - */ function next() { if(mediafile_extension == 'flv' || mediafile_extension == 'mp3' || mediafile_extension == 'mp4') { flpl.stop(); flpl.stopBuffering(); } // find out nextphoto // var count = document.getElementsByName('thumb').length; for(var i = 0; i < count; i++) { if(document.getElementsByName('thumb')[i].title == oog_photoname) { if(i == count - 1) { // if there are pages defined // if(typeof current_page != 'undefined' && typeof num_pages != 'undefined' && typeof all_thumbs != 'undefined' && typeof max_thumbs != 'undefined') { if(current_page != num_pages-1) { show_page(current_page + 1); } else { show_page(0); } var nextphoto = document.getElementsByName('thumb')[0].title; } else { // if no pages // var nextphoto = document.getElementsByName('thumb')[0].title; } } else { var nextphoto = document.getElementsByName('thumb')[i+1].title; } break; } } // start presentation of next file in album // startlightbox(oog_album, nextphoto, descriptionEditable, focusDescription); } function save_file() { window.location.href = oogLightboxRequests + 'stream&album=' + escape(oog_album) + '&file=' + escape(oog_photoname); } /* * DISPLAY FILE DESCRIPTION * * Sends a get_filedescription request. * Needs global vars oog_album and oog_photoname! * Will display description if exists. * * Parameter: - * Returns: - */ function display_filedescription() { // define ajax_request to get filedescription // var filedescription_request = false; filedescription_request = new XMLHttpRequest(); filedescription_request.onreadystatechange = function() { if(filedescription_request.readyState == 4) { if(filedescription_request.status == 200) { if(descriptionEditable) { getParentDocument().getElementById('oog_lightbox_filedescription').contentEditable = 'true'; $(getParentDocument().getElementById('oog_lightbox_filedescription')).css('cursor', 'text'); } else { getParentDocument().getElementById('oog_lightbox_filedescription').contentEditable = 'false'; $(getParentDocument().getElementById('oog_lightbox_filedescription')).css('cursor', 'default'); } $(getParentDocument().getElementById('oog_lightbox_filedescription')).text(filedescription_request.responseText); if(filedescription_request.responseText == '' || filedescription_request.responseText == '
' || filedescription_request.responseText == '
' || filedescription_request.responseText == '
') { getParentDocument().getElementById('oog_lightbox_filedescription').style.height = '0px'; getParentDocument().getElementById('oog_lightbox_filedescription').innerHTML = ''; isDescription = false; } else { getParentDocument().getElementById('oog_lightbox_filedescription').style.height = ''; isDescription = true; } resizelightbox(); if(descriptionEditable) { var div = getParentDocument().getElementById('oog_lightbox_filedescription'); div.onfocus = function() { window.setTimeout(function() { if($(getParentDocument().getElementById('oog_lightbox_filedescription')).text() == '' && !descriptionFocused) $(getParentDocument().getElementById('oog_lightbox_filedescription')).text('Write some text in here..'); descriptionFocused = true; isDescription = true; resizelightbox(); getParentDocument().getElementById('oog_lightbox_filedescription').style.height = ''; var sel, range; if (getParentWindow().getSelection && getParentDocument().createRange) { range = getParentDocument().createRange(); range.selectNodeContents(div); sel = getParentWindow().getSelection(); sel.removeAllRanges(); sel.addRange(range); } else if (getParentDocument().body.createTextRange) { range = getParentDocument().body.createTextRange(); range.moveToElementText(div); range.select(); } }, 5); }; div.onblur = function() { window.setTimeout(function() { descriptionFocused = false; save_filedescription($(getParentDocument().getElementById('oog_lightbox_filedescription')).text()); if(getParentDocument().getElementById('oog_lightbox_filedescription').innerHTML == '
' || getParentDocument().getElementById('oog_lightbox_filedescription').innerHTML == '
' || getParentDocument().getElementById('oog_lightbox_filedescription').innerHTML == '
') { getParentDocument().getElementById('oog_lightbox_filedescription').innerHTML = ''; getParentDocument().getElementById('oog_lightbox_filedescription').style.height = '0px'; isDescription = false; } else { getParentDocument().getElementById('oog_lightbox_filedescription').style.height = ''; isDescription = true; } resizelightbox(); }, 5); }; $(getParentDocument().getElementById('oog_lightbox_filedescription')).live('keyup paste', function() { save_filedescription($(getParentDocument().getElementById('oog_lightbox_filedescription')).text()); }); if(focusDescription) div.focus(); } } } } // send get filedescription request // filedescription_request.open('GET', oogLightboxRequests + 'get_filedescription&album=' + escape(oog_album) + '&file=' + escape(oog_photoname), true); filedescription_request.send(null); } /* * SAVE FILE DESCRIPTION * * Sends a save_filedescription request. * Needs global vars oog_album and oog_photoname! * * Parameter: - * Returns: - */ function save_filedescription(description) { // define ajax_request to save filedescription // var save_filedescription_request = false; save_filedescription_request = new XMLHttpRequest(); save_filedescription_request.onreadystatechange = function() { if(save_filedescription_request.readyState == 4) { if(save_filedescription_request.status == 200) { // if saving description faild show error msg // if(save_filedescription_request.responseText != 'succeed') { if(show_error_filedescription) alert(save_filedescription_request.responseText); show_error_filedescription = false; setTimeout(function () { show_error_filedescription = true; }, 3000); } } } } // send save filedescription request // save_filedescription_request.open('GET', oogLightboxRequests + 'save_filedescription&album=' + escape(oog_album) + '&file=' + escape(oog_photoname) + '&description=' + escape(description), true); save_filedescription_request.send(null); } function refresh_lightbox_extended_box(command, resize) { if(!command) { command = ''; } var http_request = false; try { http_request = new XMLHttpRequest(); } catch(e) { alert('Error: Can not create XMLHttpRequest'); return false; } http_request.onreadystatechange = function() { if(http_request.readyState == 4) { if(http_request.status == 200) { getParentDocument().getElementById('oog_lightbox_extended_box_request').innerHTML = http_request.responseText; } else { http_request = false; alert('Error: Can not load data. Reload page and try again.'); lightbox_extended = ''; $(getParentDocument().getElementById('oog_lightbox_extended_box')).css('display', 'none'); resizelightbox(); return false; } } } if(command == 'exif' || command == 'comments') { if(lightbox_extended == command) { lightbox_extended = ''; $(getParentDocument().getElementById('oog_lightbox_extended_box')).css('display', 'none'); if(resize) { resizelightbox(); } return false; } lightbox_extended = command; $(getParentDocument().getElementById('oog_lightbox_extended_box')).css('display', 'block'); http_request.open('GET', oogLightboxRequests + command + '&album=' + escape(oog_album) + '&file=' + escape(oog_photoname), true); http_request.send(null); } else { if(lightbox_extended != '') { $(getParentDocument().getElementById('oog_lightbox_extended_box')).css('display', 'block'); http_request.open('GET', oogLightboxRequests + lightbox_extended + '&album=' + escape(oog_album) + '&file=' + escape(oog_photoname), true); http_request.send(null); } } if(resize) { resizelightbox(); } } function slideshow() { if(getParentWindow().lightbox_slideshow == 0) { if(mediafile_extension == 'jpg' || mediafile_extension == 'jpeg' || mediafile_extension == 'gif' || mediafile_extension == 'png') lightbox_timeout = window.setTimeout('next()',timeout_slideshow); getParentDocument().getElementById('oog_lightbox_slideshow_but').style.backgroundPosition = '-17px -17px'; getParentWindow().lightbox_slideshow = 1; } else { getParentDocument().getElementById('oog_lightbox_slideshow_but').style.backgroundPosition = '-17px 0px'; window.clearTimeout(lightbox_timeout); getParentWindow().lightbox_slideshow = 0; } }