(function($) {
$.fn.galleryViewer = function(setup)
{
setup = quickGallerySetup;
var dimensions = jQuery.extend({
pWidth:0,
pHeight:0,
wWidth:0,
wHeight:0,
posTop:0,
posLeft:0,
scroll:0
},dimensions);
var imgElements = this;
var resizing = false;
var origImgWidth = 0;
var origImgHeight = 0;
var myPlayer = null;
getUrlVars();
var uf = jv2getAlbumFromUrl();
if(uf!=null)
{
setup.folder = encodeURIComponent(uf);
setup.folderPath = encodeURIComponent(uf + '/');
}
getWindowDimensions();
if(setup.allowMobileView)
{
if(setup.forceMobileView || dimensions.wWidth < 1025)
setup.isMobile = true;
else
setup.isMobile = false;
}
function executeLink()
{
if($('#gJv2overlay').length==0)
initViewer(this,imgElements);
else
findImageToView(this);
return false;
}
$(document).keyup(function(objEvent) {
eventKeyPress(objEvent);
});
function initViewer(elClicked,imgElements)
{
$('embed,object,select').css({'visibility':'hidden'});
createViewer();
setup.imageArray.length = 0;
setup.currentImage = 0;
for( var i = 0; i < imgElements.length; i++ )
{
setup.imageArray.push( {
href : $(imgElements[i]).attr('href'),
title: $(imgElements[i]).attr('title'),
caption : $(imgElements[i]).attr('caption'),
author : $(imgElements[i]).attr('author'),
orig : $(imgElements[i]).attr('orig'),
video : $(imgElements[i]).attr('video')
});
if($(imgElements[i]).attr('orig') == $(elClicked).attr('orig'))
setup.currentImage = i;
}
viewImage();
}
function findImageToView(elClicked)
{
var img = $(elClicked).attr('orig');
var imgNum = null;
for( var i = 0; i < setup.imageArray.length; i++ )
{
if(setup.imageArray[i].orig == img)
{
imgNum = i;
break;
}
}
if(imgNum != null)
{
setup.currentImage = imgNum;
viewImage();
}
}
function createViewer()
{
getWindowDimensions();
if(setup.isMobile)
{
setup.overlayBgColor = setup.viewerBgColor ;
opacity:setup.overlayOpacity = 1;
}
$('
').appendTo("body").css({ backgroundColor:setup.overlayBgColor, opacity:setup.overlayOpacity, width:dimensions.pWidth, height:dimensions.pHeight }).click(function() {
closeOverlay();
}).fadeIn();
viewer = ''
+ '
'
+ '
'
+ '
'
+ '
'
+ '
';
$('').html(viewer).appendTo("body").css({ top:dimensions.posTop, left:dimensions.posLeft }).click(function() {
closeOverlay();
}).show();
if(setup.isMobile)
$('#imgDiv').css({'padding':'5px 5px 10px 5px'});
$("#imgInfoBox").click(function(event){
event.stopPropagation();
});
//myPlayer = _V_("videoPlayer");
if(setup.imageInfo)
{
$('').appendTo('#imgInfo');
$(''+setup.txtImageInfo+'').appendTo('#viewExif').click(function(event) {
imageInfo();
return false;
});
}
if(setup.shareEnabled)
{
var jv2Share = $('#jv2Share');
var jv2ShareLinks = $('#jv2ShareLinks');
$('').click(function(event){$('#jv2ShareLinks').slideToggle();return false;}).appendTo(jv2Share);
if(setup.shareFacebook)
$('').click(function(event){share('facebook');return false;}).appendTo(jv2ShareLinks);
if(setup.shareGoogleplus)
$('').click(function(event){share('googleplus');return false;}).appendTo(jv2ShareLinks);
if(setup.shareTwitter)
$('').click(function(event){share('twitter');return false;}).appendTo(jv2ShareLinks);
if(setup.shareLinkedIn)
$('').click(function(event){share('linkedin');return false;}).appendTo(jv2ShareLinks);
if(setup.shareStumbleupon)
$('').click(function(event){share('stumbleupon');return false;}).appendTo(jv2ShareLinks);
if(setup.sharePinterest)
$('').click(function(event){share('pinterest');return false;}).appendTo(jv2ShareLinks);
}
if(setup.customShare)
{
$('').appendTo('#imgInfo');
$(''+setup.txtShare+'').appendTo('#viewShare').click(function(event) {
customShare();
return false;
});
}
if(setup.showDownloadLink)
$(''+setup.txtDownload+'').appendTo('#imgInfo');
if(setup.downloadOptions && !setup.openInNewTab)
$(' S/M/L').appendTo('#downloadLink');
if(setup.showPrintLink)
{
$('').appendTo('#imgInfo');
$(''+setup.txtPrint+'').appendTo('#printLink').click(function(event) {
printImage();
return false;
});
}
if(setup.genericOverlay1enabled)
{
$('').appendTo('#imgInfo');
$(''+setup.genericOverlay1txtShow+'').appendTo('#genericOverlay1').click(function(event) {
showGenericOverlayHtml($(this),setup.genericOverlay1txtShow,setup.genericOverlay1txtHide,setup.genericOverlay1html);
return false;
});
}
if(setup.genericOverlay2enabled)
{
$('').appendTo('#imgInfo');
$(''+setup.genericOverlay2txtShow+'').appendTo('#genericOverlay2').click(function(event) {
showGenericOverlayHtml($(this),setup.genericOverlay2txtShow,setup.genericOverlay2txtHide,setup.genericOverlay2html);
return false;
});
}
if(setup.disqus_enabled)
{
$('').click(function(){
toggleGalleryDisqus();
return false;
}).appendTo('#jv2Comments');
$('').click(function() {
toggleGalleryDisqus();
return false;
}).appendTo('#jv2Comments');
}
if(setup.slideshow)
{
var ssLink = $('').appendTo("#imgSlideShow").click(function() {
startSlideShow();
}).show();
if(setup.slideshowAutoStart)
ssLink.trigger('click');
}
$('').appendTo("#viewerClose").click(function() {
closeOverlay();
}).show();
// resizing window
$(window).resize(function() {
getWindowDimensions();
$('#gJv2overlay').css({ width:dimensions.wWidth, height:dimensions.wHeight });
if(resizing != true)
{
resizing = true;
$.gDoTimeout( 'resize', 1000 , function(){
resizeViewer(false);
resizing = false;
});
}
});
}
function getWindowDimensions()
{
dimensions.wWidth = $(window).width();
dimensions.wHeight = $(window).height();
dimensions.pWidth = $(document).width();
dimensions.pHeight = $(document).height();
dimensions.scroll = $(window).scrollTop();
dimensions.posTop = dimensions.scroll + (dimensions.wHeight / 10);
dimensions.posLeft = $(window).scrollLeft();
}
function videoPlayer()
{
$('#imgDiv').hide();
if(myPlayer != null)
{
if(myPlayer.techName == "html5")
{
myPlayer.tag.src = "";
myPlayer.tech.removeTriggers();
myPlayer.load();
}
//myPlayer.tech.destroy();
myPlayer.destroy();
$(myPlayer.el).remove();
}
var code = '';
$(code).prependTo('#imgDivWrap');
$("#gJv2videoPlayerWrap").click(function(event){
event.stopPropagation();
});
myPlayer = _V_("videoPlayer");
}
function viewImage()
{
getUrlVars();
var uf = jv2getAlbumFromUrl();
if(uf!=null)
{
setup.folder = encodeURIComponent(uf);
setup.folderPath = encodeURIComponent(uf + '/');
}
removeImageInfo();
hideGenericOverlayHtml();
hideGalleryDisqus();
$('#imgLoading').show();
$('#imgImg, #imgNav, #imgInfoBox').hide();
if(setup.imageArray[setup.currentImage].video != null)
videoPlayer();
else
{
$('#gJv2videoPlayerWrap').remove();
myPlayer = null;
var preloadImage = new Image();
preloadImage.onload = function() {
$('#imgDiv').show();
$('#imgImg').attr('src', setup.imageArray[setup.currentImage].href);
origImgWidth = preloadImage.width;
origImgHeight = preloadImage.height;
resizeViewer(true);
};
preloadImage.src = setup.imageArray[setup.currentImage].href;
}
currentImage = setup.imageArray[setup.currentImage].orig;
updateURL({i:setup.imageArray[setup.currentImage].orig});
if(setup.disqus_enabled)
{
$(document).ready (function () {
getUrlVars();
var uf = jv2getAlbumFromUrl();
var identifier = disqus_identifier_prefix+(uf!=null?uf.replace('/','_')+'_':'')+furi.i;
$('#disqusCount').attr('data-disqus-identifier',identifier);
loadDisqusCount(identifier);
});
}
}
function imageMaxSize(imgWidth,imgHeight,widthAdjust,heightAdjust)
{
if(typeof(widthAdjust)=='undefined')
widthAdjust = 0;
if(typeof(heightAdjust)=='undefined')
heightAdjust = 0;
var extraHeight = 60;
if(setup.isMobile)
var imgTotalMargin = setup.containerBorderSize;
else
var imgTotalMargin = (setup.containerBorderSize*4);
var maxHeight = dimensions.wHeight - imgTotalMargin + heightAdjust - extraHeight;
var maxWidth = dimensions.wWidth - imgTotalMargin + widthAdjust;
if( imgHeight > maxHeight )
{
var newHeight = maxHeight;
var newWidth = Math.floor((newHeight / imgHeight) * imgWidth);
if( newWidth > maxWidth )
{
newWidth = maxWidth;
newHeight = Math.floor((newWidth / imgWidth) * imgHeight);
}
dimensions.imgHeight = newHeight;
dimensions.imgWidth = newWidth;
}
else if( imgWidth > maxWidth )
{
var newWidth = maxWidth;
var newHeight = Math.floor((newWidth / imgWidth) * imgHeight);
if( newHeight > maxHeight )
{
newHeight = maxHeight;
newWidth = Math.floor((newHeight / imgHeight) * newWidth);
}
dimensions.imgHeight = newHeight;
dimensions.imgWidth = newWidth;
}
else
{
dimensions.imgHeight = imgHeight;
dimensions.imgWidth = imgWidth;
}
}
function resizeViewer(initImg,addHeight)
{
var widthAdjust = 0;
var heightAdjust = 0;
if(typeof(addHeight)!='undefined' && addHeight == true)
{
heightAdjust = $('#imgCaption').height() * -1;
}
var extraHeight = 60;
if(setup.isMobile)
var imgMargin = setup.containerBorderSize;
else
var imgMargin = (setup.containerBorderSize*2);
imageMaxSize(origImgWidth,origImgHeight,widthAdjust,heightAdjust);
var imgWrapWidth = (dimensions.imgWidth + imgMargin);
var imgWrapHeight = (dimensions.imgHeight + imgMargin);
dimensions.posTop = dimensions.scroll + ((dimensions.wHeight - imgWrapHeight)/2) - (extraHeight/2) + (heightAdjust/2);
if(dimensions.posTop < imgMargin)
dimensions.posTop = imgMargin;
if(setup.fastImageSwitch)
$('#gJv2imgViewer').css({ top: dimensions.posTop });
else
$('#gJv2imgViewer').animate({ top: dimensions.posTop }, setup.containerResizeSpeed);
//$('#disqusBg').animate({ top:dimensions.posTop+setup.containerBorderSize }, setup.containerResizeSpeed);
if(setup.fastImageSwitch)
{
$('#imgImg').css({ width:dimensions.imgWidth, height:dimensions.imgHeight });
$('#imgDivWrap').css({ width: imgWrapWidth });
$('#imgNav').css({ height: imgWrapHeight });
$('#imgDiv, #disqusBg').css({ width: dimensions.imgWidth, height: dimensions.imgHeight });
if(initImg)
showImg(dimensions.imgWidth,dimensions.imgHeight);
$('#disqus_thread').css({ width: (dimensions.imgWidth-40), height: (dimensions.imgHeight-40) });
if(initImg)
showImg(dimensions.imgWidth,dimensions.imgHeight);
}
else
{
if(!initImg)
$('#imgImg').animate({ width:dimensions.imgWidth, height:dimensions.imgHeight }, setup.containerResizeSpeed);
$('#imgDivWrap').animate({ width: imgWrapWidth });
$('#imgNav').css({ height: imgWrapHeight });
$('#imgDiv, #disqusBg').animate({ width: dimensions.imgWidth, height: dimensions.imgHeight }, setup.containerResizeSpeed, function() {
if(initImg)
showImg(dimensions.imgWidth,dimensions.imgHeight);
});
$('#disqus_thread').animate({ width: (dimensions.imgWidth-40), height: (dimensions.imgHeight-40) }, setup.containerResizeSpeed, function() {
if(initImg)
showImg(dimensions.imgWidth,dimensions.imgHeight);
});
}
if(myPlayer != null)
{
myPlayer.width(dimensions.imgWidth);
myPlayer.height(dimensions.imgHeight);
}
$('#imgInfoBox').css({ width: dimensions.imgWidth });
$('#imgPrevious, #imgNext').css({ height: dimensions.imgHeight + (setup.containerBorderSize * 2) });
};
function showImg(w,h)
{
$('#imgLoading').hide();
if(setup.fastImageSwitch)
$('#imgImg').css({width:w,height:h}).show(function(){ showImgDetails(); });
else
$('#imgImg').css({width:w,height:h}).fadeIn(function(){ showImgDetails(); });
preloadNextPrev();
};
function imgViewerPrevious()
{
if(setup.currentImage==0)
setup.currentImage = setup.imageArray.length-1;
else
setup.currentImage--;
viewImage();
}
function imgViewerNext()
{
if(setup.sshowOn)
stopSlideshow();
if( setup.currentImage == setup.imageArray.length-1 )
setup.currentImage=0;
else
setup.currentImage++;
viewImage();
}
function showImgDetails()
{
$('#imgNav').show();
$('#imgPrevious, #imgNext').unbind().css({'background':'transparent url(' + setup.imageBlank + ') no-repeat'});
if(setup.alwaysShowArrows)
{
$('#imgPrevious span').css('display','block');
$('#imgNext span').css('display','block');
}
$('#imgNav').swipe({
swipeLeft:function(event, direction, distance, duration, fingerCount, fingerData) {
imgViewerNext();
},
swipeRight:function(event, direction, distance, duration, fingerCount, fingerData) {
imgViewerPrevious();
},
threshold:50
});
if( (setup.currentImage != 0 || setup.viewerLoop) && setup.imageArray.length>1)
{
if(!setup.alwaysShowArrows)
{
$('#imgPrevious').hover(function() {
$('#imgPrevious span').css('display','block');
},function() {
$('#imgPrevious span').css('display','none');
});
}
$('#imgPrevious').show().bind('click',function() {
imgViewerPrevious();
return false;
});
}
if( (setup.currentImage != setup.imageArray.length-1 || setup.viewerLoop) && setup.imageArray.length>1)
{
if(!setup.alwaysShowArrows)
{
$('#imgNext').hover(function() {
$('#imgNext span').css('display','block');
},function() {
$('#imgNext span').css('display','none');
});
}
$('#imgNext').show().bind('click',function() {
imgViewerNext();
return false;
});
}
$('#imgInfoBox').slideDown('fast',function(){resizeViewer(false,true)});
if( setup.imageArray[setup.currentImage].title )
$('#imgTitle').html(setup.txtNamePrepend+setup.imageArray[setup.currentImage].title).show();
else
$('#imgTitle').html('').show();
if(setup.imageArray[setup.currentImage].caption!=null)
$('#imgCaption').html(setup.imageArray[setup.currentImage].caption).show();
else
$('#imgCaption').html(setup.txtDefaultCaption).show();
if(setup.linkify_enabled)
$('#imgCaption').linkify({target: "_blank"});
if(setup.imageArray[setup.currentImage].author!=null)
$('#imgAuthor').html(' '+setup.txtAuthor+' '+setup.imageArray[setup.currentImage].author).show();
else
$('#imgAuthor').html('').show();
var origVal = setup.imageArray[setup.currentImage].orig;
$('#imgCurrentOriginal').val(origVal);
if(setup.showDownloadLink)
{
if(setup.openInNewTab)
{
$('#downloadLinkRef').attr('href',setup.galleryfolder+setup.folderPath+origVal).attr('target','_blank');
}
else
{
$('#downloadLinkRef').attr('href',setup.downloadLink+setup.galleryfolder+setup.folderPath+origVal);
$('#downloadLinkRefS').attr('href',setup.downloadLink+setup.galleryfolder+setup.folderPath+origVal+'&size=S');
$('#downloadLinkRefM').attr('href',setup.downloadLink+setup.galleryfolder+setup.folderPath+origVal+'&size=M');
$('#downloadLinkRefL').attr('href',setup.downloadLink+setup.galleryfolder+setup.folderPath+origVal+'&size=L');
}
}
if( setup.imageArray.length > 1 )
$('#imgCount').html(setup.txtImage+' '+(setup.currentImage+1)+' '+setup.txtOf+' '+setup.imageArray.length).show();
}
function toggleGalleryDisqus()
{
if($('#disqus_thread').is(':visible'))
hideGalleryDisqus();
else
showGalleryDisqus();
}
function showGalleryDisqus()
{
if(setup.sshowOn)
stopSlideshow();
var w = $('#imgDiv').width();
var h = $('#imgDiv').height();
if($('#disqusBg').length == 0)
$('').css({ opacity:0.5, width:w, height:h , display:'none'}).appendTo('#imgNav').bind('click',function(event){event.stopPropagation();removeExif();});
$("#disqusBg").fadeIn();
//$("#disqusBgContent").fadeIn();
if($('#disqus_thread').length == 0)
$('').css({ width:(w-40), height:(h-40) }).appendTo('#imgNav').bind('click',function(event){event.stopPropagation();});
loadDisqus();
$('#disqus_thread').fadeIn();
}
function hideGalleryDisqus()
{
$("#disqusBg").fadeOut();
$("#disqus_thread").fadeOut();
$("#showDisqus").show();
$("#hideDisqus").hide();
}
function printImage()
{
var imgWin = window.open(setup.imageArray[setup.currentImage].href);
imgWin.window.print();
imgWin.document.close();
}
function imageInfo()
{
if($('#exifBg').length == 0)
{
removeShare();
hideGenericOverlayHtml();
var src = $('#imgCurrentOriginal').val();
src = encodeURIComponent(src);
var w = $('#imgDiv').width();
var h = $('#imgDiv').height();
$('').css({ opacity:0.5, width:w, height:h }).appendTo('#imgNav');
$('').css({ width:(w-40), height:(h-40) }).load(setup.imageInfoLink+setup.folderPath+src.replace(setup.galleryfolder,'')).appendTo('#imgNav').bind('click',function(event){event.stopPropagation();removeImageInfo();});
$('#viewExif a').text(setup.txtImageInfoHide);
}
else
{
removeImageInfo();
}
}
function removeImageInfo()
{
$('#exifInfo').remove();
$('#exifBg').remove();
$('#viewExif a').text(setup.txtImageInfo);
}
function showGenericOverlayHtml(link,txtShow,txtHide,html)
{
if($(link).text()==txtShow)
{
hideGenericOverlayHtml();
$(link).text(txtHide);
removeShare();
removeImageInfo();
var src = $('#imgCurrentOriginal').val();
src = escape(src);
var w = $('#imgDiv').width();
var h = $('#imgDiv').height();
$('').css({ width:(w-40), height:(h-40) }).html(html).prependTo('#imgNav');
$('').css({ opacity:0.5, width:w, height:h }).prependTo('#imgNav');
}
else
{
hideGenericOverlayHtml();
}
}
function hideGenericOverlayHtml()
{
$('#shareInfo').remove();
$('#shareBg').remove();
$('#genericOverlay1 a').text(setup.genericOverlay1txtShow);
$('#genericOverlay2 a').text(setup.genericOverlay2txtShow);
return false;
}
function customShare()
{
if($('#shareBg').length == 0)
{
removeImageInfo();
var src = $('#imgCurrentOriginal').val();
src = escape(src);
var w = $('#imgDiv').width();
var h = $('#imgDiv').height();
$('').css({ opacity:0.5, width:w, height:h }).appendTo('#imgNav');
$('').css({ width:(w-40), height:(h-40) }).load(setup.shareLink+src.replace(setup.galleryfolder,'')).appendTo('#imgNav').bind('click',function(event){event.stopPropagation();removeShare();});
$('#viewShare a').text(setup.txtShareHide);
}
else
{
removeShare();
}
}
function removeShare()
{
$('#shareInfo').remove();
$('#shareBg').remove();
$('#viewShare a').text(setup.txtShare);
}
function clearImage()
{
$('#imgTitle').html('');
$('#imgCaption').html('');
$('#imgAuthor').html('');
}
function nextSlide()
{
clearImage();
setup.currentImage++;
viewImage();
if(setup.sshowOn)
slideshowTimeout();
return false;
}
function slideshowTimeout()
{
$.gDoTimeout( 'sss', setup.slideShowDuration , function(){
if(setup.currentImage == setup.imageArray.length-1)
{
if(setup.slideshowLoop)
{
setup.currentImage = -1;
nextSlide();
}
else
closeOverlay();
}
else if(setup.currentImage < setup.imageArray.length-1)
nextSlide();
});
}
function startSlideShow()
{
setup.sshowOn = true;
$("#imgSlideShow img").remove();
$('').appendTo("#imgSlideShow").click(function() {
stopSlideshow();
}).show();
slideshowTimeout();
}
function stopSlideshow()
{
setup.sshowOn = false;
$.gDoTimeout( 'ss' );
$.gDoTimeout( 'sss' );
$("#imgSlideShow img").remove();
$('').appendTo("#imgSlideShow").click(function() {
startSlideShow();
}).show();
}
function preloadNextPrev()
{
if ( (setup.imageArray.length -1) > setup.currentImage ) {
objNext = new Image();
objNext.src = setup.imageArray[setup.currentImage + 1].href;
}
if ( setup.currentImage > 0 ) {
objPrev = new Image();
objPrev.src = setup.imageArray[setup.currentImage -1].href;
}
}
function closeOverlay()
{
if(setup.sshowOn)
stopSlideshow();
updateURL({i:null});
jv2RemoveViewer();
}
function eventKeyPress(objEvent)
{
if(typeof(objEvent.DOM_VK_ESCAPE) != 'undefined')
{
keycode = objEvent.keyCode;
escapeKey = objEvent.DOM_VK_ESCAPE;
}
else
{
keycode = objEvent.keyCode;
escapeKey = 27;
}
if(keycode == escapeKey)
closeOverlay();
else if(keycode==39 && setup.currentImage!=(setup.imageArray.length-1) )
{
setup.currentImage++;
viewImage();
}
else if(keycode==37 && setup.currentImage!=0)
{
setup.currentImage--;
viewImage();
}
}
function share(site)
{
getUrlVars();
var uf = jv2getAlbumFromUrl();
var directUrl = window.location.href;
var shareDomain = window.location.protocol + '//' + window.location.host;
var shareUrl = '';
var imageurl = '';
var serviceUrl = '';
var title = $('#imgTitle').text();
var p = [];
p.push('s=1');
if(uf!=null)
p.push('f='+uf);
if(typeof(furi.i)!='undefined')
p.push('i='+furi.i);
var newPath = [];
var pathArray = window.location.pathname.split( '/' );
var pathPartNum = pathArray.length;
for ( i = 0; i < pathPartNum; i++ )
{
if(i < pathPartNum-1 && pathArray[i]!='' && pathArray[i]!='index.php')
newPath.push(pathArray[i]);
}
// use shareUrl for services that do not use hashbangs and _escaped_fragment_ GET conversion)
if(jv2includemode && jv2includeGalleryIndexUrl != '')
shareUrl = jv2includeGalleryIndexUrl;
else if(newPath.length)
shareUrl = shareDomain + '/' + newPath.join('/') + '/';
else
shareUrl = shareDomain;
imageurl = shareUrl;
if(p.length)
shareUrl = shareUrl + '?' + p.join('&');
if(jv2includemode && jv2includeGalleryIndexUrl != '')
directUrl = shareUrl;
if(uf!=null)
imageurl = imageurl + uf + '/';
if(typeof(furi.i)!='undefined')
imageurl = imageurl + furi.i;
if(site=='facebook')
serviceUrl = "https://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(directUrl);
else if(site=='googleplus')
serviceUrl = "https://plus.google.com/share?url="+encodeURIComponent(directUrl);
else if(site=='twitter')
serviceUrl = "http://twitter.com/share?url="+encodeURIComponent(shareUrl)+"&text="+encodeURIComponent(title);
else if(site=='linkedin')
serviceUrl = "http://www.linkedin.com/shareArticle?mini=true&url="+encodeURIComponent(shareUrl);
else if(site=='stumbleupon')
serviceUrl = "http://www.stumbleupon.com/submit?url="+encodeURIComponent(directUrl)+"&title="+encodeURIComponent(title);
else if(site=='pinterest')
serviceUrl = "//www.pinterest.com/pin/create/button/?url="+encodeURIComponent(directUrl)+"&media="+encodeURIComponent(imageurl)+"&description="+encodeURIComponent(title);
window.open( serviceUrl, site+'-share-dialog', 'width=626,height=436' );
return false;
}
return this.unbind('click').click(executeLink);
};
})(jQuery);
function updateGalleryContent(time,frequency,prepend)
{
var galleryUrl = '';
if(jv2includemode)
galleryUrl = jv2includeModeAjaxUrl;
$.ajax({
type: "GET",
url: galleryUrl,
data: 'newItems=true&checkTime='+time,
cache: false,
dataType:'json',
success: function(r) {
if(prepend)
$(r.html).prependTo( $('#galleryPage') );
else
$(r.html).insertBefore( $('#galleryDivEnd') );
$.gDoTimeout( 'update', (frequency*1000) , function(){
updateGalleryContent(r.time,frequency,prepend);
});
},
error: function() { }
});
}
function loadDisqusCount(identifier)
{
disqus_identifier = identifier;
disqus_url = window.location.href;
if(window.DISQUS)
DISQUSWIDGETS.getCount();
else
$.getScript ("//"+disqus_shortname+".disqus.com/count.js");
}
function loadDisqus()
{
getUrlVars();
var uf = jv2getAlbumFromUrl();
var identifier = disqus_identifier_prefix+(uf!=null?uf.replace('/','_')+'_':'')+furi.i;
if(window.DISQUS)
{
DISQUS.reset({
reload: true,
config: function () {
this.page.identifier = identifier;
this.page.url = window.location.href;
}
});
}
else
{
disqus_identifier = identifier;
disqus_url = window.location.href;
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
$('head').append(dsq);
}
};
function uploadAnother( ref ) {
var tempFile = window.document.createElement( 'INPUT' );
tempFile.setAttribute( 'type', 'file' );
tempFile.className = 'fileupload';
tempFile.setAttribute( 'name', 'fileupload[]' );
var tempForm = false;
var tempParent = false;
var ok = true;
try {
while( ok == true ) {
if( tempParent == false ) {
tempParent = ref.parentNode;
} else if ( tempParent.nodeName.toLowerCase() == 'form' ) {
tempForm = tempParent;
ok = false;
} else {
tempParent = tempParent.parentNode;
}
} // ends while
} catch( e ) {};
ok = null;
tempForm.insertBefore( tempFile, ref );
if (tempForm.length-1 >= 5){
tempForm.removeChild(ref);
}
return false;
} // ends uploadAnother
/*
* jQuery doTimeout: Like setTimeout, but better! - v1.0 - 3/3/2010
* http://benalman.com/projects/jquery-dotimeout-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($){var a={},c="gDoTimeout",d=Array.prototype.slice;$[c]=function(){return b.apply(window,[0].concat(d.call(arguments)))};$.fn[c]=function(){var f=d.call(arguments),e=b.apply(this,[c+f[0]].concat(f));return typeof f[0]==="number"||typeof f[1]==="number"?this:e};function b(l){var m=this,h,k={},g=l?$.fn:$,n=arguments,i=4,f=n[1],j=n[2],p=n[3];if(typeof f!=="string"){i--;f=l=0;j=n[1];p=n[2]}if(l){h=m.eq(0);h.data(l,k=h.data(l)||{})}else{if(f){k=a[f]||(a[f]={})}}k.id&&clearTimeout(k.id);delete k.id;function e(){if(l){h.removeData(l)}else{if(f){delete a[f]}}}function o(){k.id=setTimeout(function(){k.fn()},j)}if(p){k.fn=function(q){if(typeof p==="string"){p=g[p]}p.apply(m,d.call(n,i))===true&&!q?o():e()};o()}else{if(k.fn){j===undefined?e():k.fn(j===false);return true}else{e()}}}})(jQuery);
(function($)
{
var $document = $(document),
iframe,
hash = '',
needHistoryAdd = /MSIE/.test(navigator.userAgent),
afterHistoryRead = false,
afterHistoryAdd = false;
function checkHashChange()
{
if(hash != (hash = document.location.hash))
{
if(!afterHistoryRead && needHistoryAdd)
historyAdd(hash);
afterHistoryRead = false;
$document.trigger('hashChange', [hash]);
}
setTimeout(checkHashChange, 100);
}
function historyAdd(hash)
{
if (!iframe) iframe = $('').appendTo('body')[0];
var d = iframe.contentDocument || (iframe.contentWindow ? iframe.contentWindow.document : iframe.document);
d.open();
d.write('' + document.title + '');
d.write($('').append($('').text(hash)).html());
d.write('');
afterHistoryAdd = true;
d.close();
}
if('onpropertychange' in document && 'attachEvent' in document)
{
document.attachEvent('onpropertychange', function()
{
if(event.propertyName=='location')
checkHashChange();
});
}
if(needHistoryAdd)
{
window._historyRead = function()
{
if(!afterHistoryAdd)
{
var newHash = this._hash;
if(document.location.hash != newHash)
{
afterHistoryRead = true;
document.location.hash = newHash;
}
}
afterHistoryAdd = false;
};
}
$(function(){ setTimeout(checkHashChange, 1) });
})(jQuery);
var uri = new URI();
URI.fragmentPrefix = "!";
var ruri = new Object;
var furi = new Object;
var ruriPrevious = new Object;
var furiPrevious = new Object;
var urlVars = new Object;
var urlVarsPrevious = new Object;
var currentAlbum = '/';
var currentImage = null;
function getUrlVars(prev)
{
if(typeof(prev)!='undefined' && prev)
{
ruriPrevious = jQuery.extend({},ruri);
furiPrevious = jQuery.extend({},furi);
uri = new URI();
}
try
{
ruri = uri.search(true);
furi = uri.fragment(true);
}
catch(err) {}
}
function updateURL(params)
{
if(params == null || params == undefined)
params = {};
// var hash = [];
// urlVarsTemp = jQuery.extend(urlVars,params);
// jQuery.each(urlVarsTemp, function(i,val) {
// if(val!=null || (i=='f' && val!='/' && val!=null) )
// hash.push( i + '=' + escape(val) ); //encodeURIComponent
// });
// window.location.hash = '!/'+hash.join('&');
jQuery.each(params, function(i,val) {
uri.removeFragment(i);
if(val!=null)
uri.addFragment(i, val);
});
window.location = uri.toString();
}
function jv2RemoveViewer()
{
currentImage = null;
$('#gJv2imgViewer').fadeOut(200,function() {
$(this).remove();
$('#gJv2overlay').fadeOut(500,function() {
$(this).remove();
$('embed, object, select').css({ 'visibility':'visible' });
});
});
}
function jv2getAlbumFromUrl()
{
if(typeof(furi.f)!='undefined')
return furi.f;
else if(typeof(ruri.f)!='undefined')
return ruri.f;
else
return null;
}
function addLoadingOverlay(elementId)
{
pageElement = $('#'+elementId);
if(($(pageElement).outerHeight(true))!=null)
{
var marginLeft = $(pageElement).css('margin-left');
if(typeof(marginLeft)=='undefined')
marginLeft = 0;
$('').addClass('loadingFade')
.attr('id',elementId+'loading')
.height( $(pageElement).outerHeight(true) )
.width( $(pageElement).outerWidth() )
.css('margin-left',marginLeft)
.insertBefore(pageElement)
.fadeIn();
}
}
function removeLoadingOverlay(elementId)
{
$('#'+elementId+'loading').remove();
}
function jv2loadAlbum(folder)
{
if(folder=='')
folder=null;
updateURL({f:folder});
return false;
}
function jv2loadAlbumAjax(folder)
{
var galleryUrl = '';
if(jv2includemode)
galleryUrl = jv2includeModeAjaxUrl;
$.gDoTimeout('gLoad',500,function(){
addLoadingOverlay('gJv2');
});
$.ajax({
type: 'GET',
url: galleryUrl,
data: 'f='+folder,
cache: false,
dataType:'html',
success: function(content) {
$('#gJv2').html(content);
jv2loadImageFromHash();
currentAlbum = folder;
},
complete: function() {
$.gDoTimeout('gLoad');
removeLoadingOverlay('gJv2');
}
});
return false;
}
function jv2loadImageFromHash()
{
furi = uri.fragment(true);
if(typeof(furi.i)!='undefined' && currentImage != furi.i)
{
$(".gItem").each(function(){
if($(this).attr('orig') == furi.i)
$(this).click();
});
}
}
function jv2handleGalleryHash()
{
getUrlVars(true);
var uf = jv2getAlbumFromUrl();
if(typeof(furi.f)!='undefined' && uf != currentAlbum)
{
jv2RemoveViewer();
jv2loadAlbumAjax(uf);
}
else if(typeof(furi.i)!='undefined')
{
jv2loadImageFromHash();
}
else if(typeof(furi.f)=='undefined')
{
if($('#gJv2overlay').length==0 && typeof(furiPrevious.f)!='undefined' )
jv2loadAlbumAjax('/');
else
{
jv2RemoveViewer();
}
}
if((uf == currentAlbum || !jv2ajax) && typeof(furi.i)=='undefined')
{
jv2RemoveViewer();
}
}
function jv2LoginForm()
{
$('#loginUsernameEntry').bind('focus',function(){
if($(this).val() == quickGallerySetup.txtUsername)
$(this).val('');
}).bind('blur',function(){
if($(this).val() == '')
$(this).val(quickGallerySetup.txtUsername);
});
$('#fakepasswordEntry').bind('focus',function(){
$(this).hide();
$('#passwordEntry').show().focus();
});
$('#passwordEntry').bind('blur',function(){
if($(this).val() == '')
{
$(this).hide();
$('#fakepasswordEntry').show();
}
});
}
$(function() {
if(jv2ajax && window.location.hash=='')
window.location.hash = '#!/';
$(document).bind('hashChange', jv2handleGalleryHash);
});
if(jv2imgHoverOpacity)
{
$(function() {
$('#gJv2').on('mouseenter','.imgWrap',function(){
$(this).animate({'opacity':0.7},500);
});
$('#gJv2').on('mouseleave','.imgWrap',function(){
$(this).animate({'opacity':1},300);
});
});
}