<input type="hidden" name="action" value="show_selection" />
<input type="submit" name="ok_button" value="OK" />
</fieldset>
- <fieldset>
- <legend>Move all graphs</legend>
- <input type="button" name="earlier" value="←" title="Earlier"
- onclick="nav_move_earlier ('*');" />
- <input type="button" name="zoom_out" value="-" title="Zoom out"
- onclick="nav_zoom_out ('*');" />
- <input type="button" name="zoom_in" value="+" title="Zoom in"
- onclick="nav_zoom_in ('*');" />
- <input type="button" name="later" value="→" title="Later"
- onclick="nav_move_later ('*');" />
- </fieldset>
</form>
HTML
} # show_selector
<div class="graph_float">
<img id="${id}" class="graph_image"
alt="A graph"
- src="$url"
- ondblclick="nav_handle_dblclick (event);" />
+ src="$url" />
<div class="controls zoom">
<div title="Earlier"
onclick="nav_move_earlier ('${id}');">←</div>
onclick="nav_time_reset ('${id}', 31 * 86400);">M</div>
<div title="Show current year"
onclick="nav_time_reset ('${id}', 366 * 86400);">Y</div>
+ <div title="Set all images to this timespan"
+ onclick="nav_set_reference ('${id}');">!</div>
</div>
</div>
</div>
all_images[i].navBaseURL = all_images[i].src.replace (/;(begin|end)=[^;]*/g, '');
if (all_images[i].addEventListener) /* Mozilla */
+ {
+ all_images[i].addEventListener ('dblclick', nav_handle_dblclick,
+ false /* == bubbling */);
all_images[i].addEventListener ('DOMMouseScroll', nav_handle_wheel,
false /* == bubbling */);
- all_images[i].onmousewheel = nav_handle_wheel;
+ }
+ else
+ {
+ all_images[i].ondblclick = nav_handle_dblclick;
+ all_images[i].onmousewheel = nav_handle_wheel;
+ }
}
return (true);
{
var diff;
- if (!img)
- return (false);
-
- if (!img.navTimeEnd || !img.navTimeBegin)
+ if (!img || !img.navBaseURL
+ || !img.navTimeBegin || !img.navTimeEnd)
return (false);
diff = img.navTimeEnd - img.navTimeBegin;
img.navTimeBegin += (diff * factor_begin);
img.navTimeEnd += (diff * factor_end);
- img.src = img.navBaseURL + ";"
- + "begin=" + img.navTimeBegin.toFixed (0) + ";"
- + "end=" + img.navTimeEnd.toFixed (0);
+ nav_image_repaint (img);
return (true);
} /* nav_time_change */
if (img_id == '*')
{
var all_images;
+ var i;
all_images = document.getElementsByTagName ("img");
for (i = 0; i < all_images.length; i++)
return (nav_time_change (img_id, (-1.0 / 3.0), (1.0 / 3.0)));
} /* nav_zoom_in */
+function nav_set_reference (img_id)
+{
+ var img;
+ var all_images;
+ var tmp;
+ var i;
+
+ img = document.getElementById (img_id);
+ if (!img || (img.className != "graph_image")
+ || !img.navTimeBegin || !img.navTimeEnd)
+ return;
+
+ all_images = document.getElementsByTagName ("img");
+ for (i = 0; i < all_images.length; i++)
+ {
+ tmp = all_images[i];
+ if (!tmp || (tmp.className != "graph_image")
+ || !tmp.navTimeBegin || !tmp.navTimeEnd)
+ continue;
+
+ if (tmp.id == img_id)
+ continue;
+
+ tmp.navTimeBegin = img.navTimeBegin;
+ tmp.navTimeEnd = img.navTimeEnd;
+
+ nav_image_repaint (tmp);
+ }
+} /* nav_set_reference */
+
+/*
+ * TODO: calculate the mouse position relative to the image in a cross-browser
+ * manner.
+ */
+function nav_calculate_offset_x (obj)
+{
+ var offset = 0;
+
+ if (!obj)
+ return (offset);
+
+ offset = obj.offsetLeft;
+ if (obj.offsetParent)
+ offset += nav_calculate_offset_x (obj.offsetParent);
+
+ return (offset);
+} /* nav_calculate_offset_x */
+
+function nav_calculate_event_x (e)
+{
+ var pos = 0;
+ var off = 0;
+
+ if (!e || !e.target)
+ return;
+
+ off = nav_calculate_offset_x (e.target);
+
+ if (e.pageX || e.pageY)
+ {
+ pos = e.pageX;
+ }
+ else if (e.clientX || e.clientY)
+ {
+ pos = e.clientX + document.body.scrollLeft
+ + document.documentElement.scrollLeft;
+ }
+
+ return (pos);
+} /* nav_calculate_event_x */
+
function nav_recenter (e)
{
var x;