/* ----------------------------------------------------------------------------- GALLY Template for Piwigo ------------------------------------------------------------------------------ file: gally/gallyjs-tpp.js file release: 1.2.0 ------------------------------------------------------------------------------ author: grum at grum.dnsalias.com << May the Little SpaceFrog be with you >> ------------------------------------------------------------------------------ JS for the pictures pages need jQuery 1.2.6 see the release_notes.txt file for more informations ----------------------------------------------------------------------------- */ var showtabs; var selectedTab; var interfaceTimerDelay; var isScrollable; $("document").ready( function(){inittoolbar(); } ); function inittoolbar() { $(document).data("initialized", 0); $(document).data("interface", false); if(jQuery.browser.msie) { //this features don't work with the f*****g msie browser options.interfaceAnimated="none"; options.imageAutoScroll=false; } if(options.imageAutoScroll) { $("html").css("overflow-x", "hidden"); } else { $("html").css("overflow-x", "scroll"); } if(options.imageCenterTopBorder == "imageHeaderBar") { options.imageCenterTopMin+=$("#imageHeaderBar").get(0).offsetTop+$("#imageHeaderBar").get(0).offsetHeight; } currentTab=-1; selectedTab=-1; interfaceTimerDelay = null; switchInterface('0', true); initializeImageMode("init"); if(options.interfaceOnImage=="always" || (options.interfaceOnImage=="noscroll" && !isScrollable)) { $("#theImg").bind("mouseenter", function () { switchInterface('y', true); } ) .bind("mouseleave", function () { switchInterface('n', true); } ) .bind("mousemove", function () { switchInterface('y', true); } ); } $("#imageHeaderBar").bind("mouseenter", function () { switchInterface('y', false); } ) .bind("mousemove", function () { switchInterface('y', false); } ); $("#imageToolBar").bind("mouseenter", function () { switchInterface('y', true); } ) .bind("mouseleave", function () { switchInterface('n', true); } ) .bind("mousemove", function () { switchInterface('y', true); } ); $("#navThumbPrev").bind("mouseenter", function () { switchInterface('Y', true); } ) .bind("mouseleave", function () { switchInterface('n', true); } ) .bind("mousemove", function () { switchInterface('y', true); } ) .css("top", $("#navThumbPrev").attr("offsetTop")+$("#theHeader").attr("offsetHeight")+"px"); $("#navThumbNext").bind("mouseenter", function () { switchInterface('Y', true); } ) .bind("mouseleave", function () { switchInterface('n', true); } ) .bind("mousemove", function () { switchInterface('y', true); } ) .css("top", $("#navThumbNext").attr("offsetTop")+$("#theHeader").attr("offsetHeight")+"px"); $("#theImage").css("top", $("#theImage").attr("offsetTop")+$("#theHeader").attr("offsetHeight")+"px"); $("#contentid").attr("rows", options.commentRows); /* fx duration option set to 0 doesn't work so... */ if(options.animateDelay>0) { $("#theTabs").tabs({ fx: { opacity: 'toggle', duration:options.animateDelay } } ); } else { $("#theTabs").tabs(); } switchTabs('n'); $('#theTabsContainer').bind("mouseenter", function () { switchInterface('Y', false); } ) .bind("mouseleave", function () { switchInterface('n'); } ) .bind("mousemove", function () { switchInterface('y', false); } ); $("#theTabs").bind('tabsselect', function(event, ui) { /* The "collapsible" option don't work with jQuery 1.2.6 * This function aims to reproduct this functionnality */ selectedTab=ui.index; } ); $('.tab a').click(function() { /* The "collapsible" option don't work with jQuery 1.2.6 * This function aims to reproduct this functionnality */ $(this).get(0).blur(); if(selectedTab == currentTab) { if (currentTab!=-1) switchTabs('n'); currentTab=-1; selectedTab=-1; } else { if(currentTab==-1) switchTabs('y'); currentTab=selectedTab; } } ); $(window).resize( function () { initializeImageMode("resize"); } ); $(document).data("initialized", 1); } function initializeImageMode(mode) { if(mode=="init") { $("#imageToolBar").css("top", $("#imageToolBar").attr("offsetTop")+$("#theHeader").attr("offsetHeight")+$("#imageHeaderBar").attr("offsetHeight")+"px"); if(options.tabsPosition=="bottom") { copyrightArea = $("#copyright").attr("clientHeight")+1; $("#theTabsContainer").css("bottom", copyrightArea+"px"); } else if(options.tabsPosition=="top") { toolBarArea = $("#imageToolBar").attr("offsetTop")+$("#imageToolBar").attr("offsetHeight"); $("#theTabsContainer").css("top", toolBarArea+"px"); } if($("#navThumbPrev").length>0) { $("#navThumbPrev").css("height", $("#copyright").attr("offsetTop")-$("#navThumbPrev").attr("offsetTop")-options.tabsHidden+"px"); } if($("#navThumbNext").length>0) { $("#navThumbNext").css("height", $("#copyright").attr("offsetTop")-$("#navThumbNext").attr("offsetTop")-options.tabsHidden+"px"); } } cssValues = new Object; cssValues.height = $("#theImg").attr("height")+"px"; // autoscroll if(options.imageAutoScroll && ($("#theImg").attr("scrollWidth")>($("#theImage").attr("clientWidth")-2*options.margin_container))) { cssValues.width = ($("#theImage").attr("clientWidth")- 2*options.margin_container)+"px"; $("#theImage").bind("mousemove", function(event){ deadArea = $("#navThumbPrev").attr("clientWidth")*1.2; mouse=Math.max(Math.min(event.clientX-this.offsetLeft, this.clientWidth - deadArea), deadArea); $("#theImg").css("left",Math.round(($("#theImg").attr("scrollWidth")-this.clientWidth) * -(mouse-deadArea)/(this.clientWidth-2*deadArea))+"px"); } ); isScrollable=true; } else { $("#theImage").unbind("mousemove"); $("#theImg").css("left", "0px"); cssValues.width = $("#theImg").attr("scrollWidth")+"px"; isScrollable=false; } $("#theImgContainer").css(cssValues); // imagecenter if($("#copyright").css("position")=="fixed") { $("#theImage").css("padding-bottom", $("#copyright").attr("offsetHeight")+"px"); } switch(options.imageCenterMode) { case "img": imgTop = $("#theImgContainer").attr('offsetHeight'); break; case "all": imgTop = $("#theImage").attr('offsetHeight'); break; default: imgTop = -10000; break; } imgTop = ($("#copyright").attr("offsetTop") - ($("#imageHeaderBar").attr("offsetTop") + $("#imageHeaderBar").attr("offsetHeight")) - imgTop)/2 + options.imageCenterOffset; if(imgTop0) interfaceTimerDelay=window.setInterval(switchInterface, options.interfaceTimerDelay, "n", false); }