diff options
-rw-r--r-- | perllib/Page.pm | 5 | ||||
-rw-r--r-- | web/js.js | 20 |
2 files changed, 17 insertions, 8 deletions
diff --git a/perllib/Page.pm b/perllib/Page.pm index 8e3815931..73c19f105 100644 --- a/perllib/Page.pm +++ b/perllib/Page.pm @@ -6,7 +6,7 @@ # Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: Page.pm,v 1.58 2007-06-22 14:20:45 matthew Exp $ +# $Id: Page.pm,v 1.59 2007-08-20 10:39:30 matthew Exp $ # package Page; @@ -244,6 +244,7 @@ sub compass ($$$) { $compass[$i][$j] = NewURL($q, x=>$i, y=>$j); } } + my $recentre = NewURL($q, x=>undef, y=>undef); return <<EOF; <table cellpadding="0" cellspacing="0" border="0" id="compass"> <tr valign="bottom"> @@ -253,7 +254,7 @@ sub compass ($$$) { </tr> <tr> <td><a href="${compass[$x-1][$y]}"><img src="/i/arrow-west.gif" hspace="3" alt="W"></a></td> -<td align="center"><img src="/i/rose.gif" alt=""></td> +<td align="center"><a href="$recentre"><img src="/i/rose.gif" alt="Recentre"></a></td> <td><a href="${compass[$x+1][$y]}"><img src="/i/arrow-east.gif" hspace="3" alt="E"></a></td> </tr> <tr valign="top"> @@ -17,6 +17,10 @@ YAHOO.util.Event.onContentReady('pc', function() { function compass_pan(e, a) { YAHOO.util.Event.preventDefault(e); + if (a.home) { + a.x = a.orig_x-drag_x; + a.y = a.orig_y-drag_y; + } pan(a.x, a.y); } @@ -27,12 +31,13 @@ YAHOO.util.Event.onContentReady('compass', function() { var points = this.getElementsByTagName('a'); YAHOO.util.Event.addListener(points[1], 'click', compass_pan, { x:0, y:tileheight }); YAHOO.util.Event.addListener(points[3], 'click', compass_pan, { x:tilewidth, y:0 }); - YAHOO.util.Event.addListener(points[4], 'click', compass_pan, { x:-tilewidth, y:0 }); - YAHOO.util.Event.addListener(points[6], 'click', compass_pan, { x:0, y:-tileheight }); + YAHOO.util.Event.addListener(points[5], 'click', compass_pan, { x:-tilewidth, y:0 }); + YAHOO.util.Event.addListener(points[7], 'click', compass_pan, { x:0, y:-tileheight }); YAHOO.util.Event.addListener(points[0], 'click', compass_pan, { x:tilewidth, y:tileheight }); YAHOO.util.Event.addListener(points[2], 'click', compass_pan, { x:-tilewidth, y:tileheight }); - YAHOO.util.Event.addListener(points[5], 'click', compass_pan, { x:tilewidth, y:-tileheight }); - YAHOO.util.Event.addListener(points[7], 'click', compass_pan, { x:-tilewidth, y:-tileheight }); + YAHOO.util.Event.addListener(points[6], 'click', compass_pan, { x:tilewidth, y:-tileheight }); + YAHOO.util.Event.addListener(points[8], 'click', compass_pan, { x:-tilewidth, y:-tileheight }); + YAHOO.util.Event.addListener(points[4], 'click', compass_pan, { home:1, orig_x:drag_x, orig_y:drag_y }); }); YAHOO.util.Event.onContentReady('map', function() { @@ -111,8 +116,11 @@ function pan(x, y) { if (!myAnim || !myAnim.isAnimated()) { myAnim = new YAHOO.util.Motion('drag', { points:{by:[x,y]} }, 10, YAHOO.util.Easing.easeOut); myAnim.useSeconds = false; - myAnim.onTween.subscribe(function(){ update_tiles(x/10, y/10, false); }); - myAnim.onComplete.subscribe(function(){ cleanCache(); }); + //myAnim.onTween.subscribe(function(){ update_tiles(x/10, y/10, false); }); + myAnim.onComplete.subscribe(function(){ + update_tiles(x, y, false); + cleanCache(); + }); myAnim.animate(); } } |