Index: extensions/pAnchor/CHANGELOG
===================================================================
--- extensions/pAnchor/CHANGELOG (revision 7862)
+++ extensions/pAnchor/CHANGELOG (revision 7862)
@@ -0,0 +1,4 @@
+2010-11-23 0.5b
+ svn commit: 'first release'
+2010-11-23 0.5b
+ Plugin creation.
Index: extensions/pAnchor/main.inc.php
===================================================================
--- extensions/pAnchor/main.inc.php (revision 7862)
+++ extensions/pAnchor/main.inc.php (revision 7862)
@@ -0,0 +1,47 @@
+ ');
+define('PANCHOR_CSS_SLIDESHOW', '');
+
+//include the plugin code
+include_once( PANCHOR_PATH . 'pAnchor.php');
+?>
Index: extensions/pAnchor/pAnchor.js
===================================================================
--- extensions/pAnchor/pAnchor.js (revision 7862)
+++ extensions/pAnchor/pAnchor.js (revision 7862)
@@ -0,0 +1,67 @@
+// JavaScript Document
+
+//pAnchor plugin for piwigo - ease to anchor javascript functions (uses jquery)
+$(document).ready(function() {
+ //check for pAnchor anchor - name of anchor can be customized in main.inc.php
+ if ($('#pAnchor').attr('name')) {
+ //alert('pAnchor exists');
+ var url = window.location.href;
+ if (url.indexOf('#') == -1) {
+ //defaut values a=0.20, t=16 and delay=250
+ easeToInit('pAnchor', 0.20, 16, 250);
+ }
+ }
+});
+
+
+function easeTo(yDest, yTemp, a, t) {
+ //easeTo function to scroll from 0 to yDest. X will scroll to 0 also.
+ //yDest is y value of destination
+ //YTemp is temp value as scroll progresses to yDest
+ //a = a || 0.2; //about 0.2
+ //t = t || 20; //about 15-20 milliseconds
+
+ var x1 = 0;
+ var y1 = 0;
+ var x2 = 0;
+ var y2 = 0;
+ var x3 = 0;
+ var y3 = 0;
+
+ if (document.documentElement) {
+ x1 = document.documentElement.scrollLeft || 0;
+ y1 = document.documentElement.scrollTop || 0;
+ }
+ if (document.body) {
+ x2 = document.body.scrollLeft || 0;
+ y2 = document.body.scrollTop || 0;
+ }
+ x3 = window.scrollX || 0;
+ y3 = window.scrollY || 0;
+
+ var x = Math.max(x1, Math.max(x2, x3));
+ var y = Math.max(y1, Math.max(y2, y3));
+
+ var speed = 1 + a;
+ var yTemp = Math.floor(yTemp / speed);
+ window.scrollTo(Math.floor(x / speed), yDest - yTemp);
+ if(x > 0 || yTemp > 1) {
+ var f = "easeTo(" + yDest + ", " + yTemp + ", " + a + ", " + t + ")";
+ //alert(f);
+ window.setTimeout(f, t);
+ } else {
+ //alert('done');
+ }
+}
+
+function easeToInit(elem, a, t, delay){
+ //easeToInit initializes and easeTo operation
+ //elem is id of document element, a is psuedo-acceleration, t is timer for interative calls
+ //delay is just a small time delay before easeTo actually begins. give the page a chance to be static before
+ //easeTo the desired element. The position can be fined with params in the main.inc.php file.
+ //ALSO NOTE: DIFFERENT BROWSERS WILL YEILDLY SLIGHLY DIFFERENT RESULTS, but typically within a few pixels.
+ y = document.getElementById(elem).offsetTop;
+ var f = "easeTo(" + y + ", " + y + ", " + a + ", " + t + ")";
+ window.setTimeout(f, delay);
+}
+
Index: extensions/pAnchor/pAnchor.php
===================================================================
--- extensions/pAnchor/pAnchor.php (revision 7862)
+++ extensions/pAnchor/pAnchor.php (revision 7862)
@@ -0,0 +1,113 @@
+ to URL string variable
+ global $template;
+
+ //picture nav buttons
+ $links = array('first','previous','next','last');
+ $tags = array('U_IMG');
+ foreach ($links as $link) {
+ $temp = $template->get_template_vars($link);
+ foreach ($tags as $tag) {
+ if (isset($temp[$tag])) {
+ $temp[$tag] .= '#'.PANCHOR_NAME;
+ $template->assign($link, $temp);
+ }
+ }
+ }
+
+ //slideshow nav buttons
+ $links = array('slideshow');
+ $tags = array('U_START_PLAY', 'U_STOP_PLAY', 'U_START_REPEAT', 'U_STOP_REPEAT', 'U_DEC_PERIOD', 'U_INC_PERIOD');
+ foreach ($links as $link) {
+ $temp = $template->get_template_vars($link);
+ foreach ($tags as $tag) {
+ if (isset($temp[$tag])) {
+ $temp[$tag] .= '#'.PANCHOR_NAME;
+ $template->assign($link, $temp);
+ }
+ }
+ }
+
+ //start slideshow nav button
+ $temp = $template->get_template_vars('U_SLIDESHOW_START');
+ if (isset($temp)) {
+ $temp .= '#'.PANCHOR_NAME;
+ $template->assign('U_SLIDESHOW_START', $temp);
+ }
+ //stop slideshow nav button
+ $temp = $template->get_template_vars('U_SLIDESHOW_STOP');
+ if (isset($temp)) {
+ $temp .= '#'.PANCHOR_NAME;
+ $template->assign('U_SLIDESHOW_STOP', $temp);
+ }
+
+ //assign anchor name to template var
+ $template->assign('PANCHOR_NAME', PANCHOR_NAME);
+ return $content;
+} //end function pAnchor_links
+
+function pAnchor_picture_prefilter($content, &$smarty) {
+ //add the HTML page anchor tag into picture template via search string
+ global $template;
+
+ $search = '#'.PANCHOR_PICTURE_SEARCH_TAG.'#';
+ $replacement = ''.PANCHOR_PICTURE_SEARCH_TAG;
+ return preg_replace($search, $replacement, $content);
+}
+
+function pAnchor_slideshow_prefilter($content, &$smarty) {
+ //add the HTML page anchor tag into slideshow template via search string
+ global $template;
+
+ $search = '#'.PANCHOR_SLIDESHOW_SEARCH_TAG.'#';
+ $replacement = ''.PANCHOR_SLIDESHOW_SEARCH_TAG;
+ return preg_replace($search, $replacement, $content);
+}
+
+function pAnchor_add_anchor() {
+ //setup add anchor prefilters for picture.tpl and slideshow.tpl
+ global $template;
+ $template->set_prefilter('picture', 'pAnchor_picture_prefilter');
+ $template->set_prefilter('slideshow', 'pAnchor_slideshow_prefilter');
+
+}
+
+function pAnchor_adj_meta_refresh() {
+ //adjust the get_template_vars('page_refresh');
+ if (isset($temp['U_REFRESH'])) {
+ $temp['U_REFRESH'] = $temp['U_REFRESH'].'#'.PANCHOR_NAME;
+ $template->assign('page_refresh', $temp);
+ }
+ if (isset($page['slideshow'])) {
+ if ($page['slideshow']) {
+ //add CSS for pAnchor to document head
+ $template->append('head_elements', PANCHOR_CSS_SLIDESHOW);
+ //load js for pAnchor
+ } else {
+ //add CSS for pAnchor to document head
+ $template->append('head_elements', PANCHOR_CSS_PICTURE);
+ }
+ }
+ //experimental feature to auto ease scroll to pAnchor when navigating
+ //to picture or slideshow from another page (that does not have # in url)
+ if ( PANCHOR_EASE_ENABLE == true) {
+ $template->append('head_elements', '');
+ }
+}
+
+//do NOT add anchors on ADMIN side of piwigo
+if (!defined('IN_ADMIN')) {
+ add_event_handler('render_element_content', 'pAnchor_links');
+
+ add_event_handler('loc_end_picture', 'pAnchor_add_anchor');
+ add_event_handler('loc_end_page_header', 'pAnchor_adj_meta_refresh');
+}
+
+?>