From 47ab29d19252be8392c2df55d1494cd6df33ed83 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 5 Oct 2010 13:29:51 +0200 Subject: [PATCH] moved events to extra function --- frontend/javascripts/frontend.js | 32 +++++++++++++++++++++++++++++++- frontend/javascripts/init.js | 28 +--------------------------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/frontend/javascripts/frontend.js b/frontend/javascripts/frontend.js index 9f1a5cb..da070f7 100644 --- a/frontend/javascripts/frontend.js +++ b/frontend/javascripts/frontend.js @@ -70,7 +70,7 @@ vz.initInterface = function() { vz.uuids.add($('#addUUID input[type=text]').val()); $('#addUUID').dialog('close'); vz.entities.load(); - }) + }); // bind plot actions $('#move input').click(vz.handleControls); @@ -102,6 +102,36 @@ vz.initInterface = function() { }); }; +vz.bindEvents = function() { + // handle zooming & panning + $('#plot') + .bind("plotselected", function (event, ranges) { + vz.from = Math.floor(ranges.xaxis.from); + vz.to = Math.ceil(ranges.xaxis.to); + vz.options.plot.yaxis.min = 0; + vz.options.plot.yaxis.max = null; // autoscaling + vz.data.load(); + }) + /*.bind('plotpan', function (event, plot) { + var axes = vz.plot.getAxes(); + vz.from = Math.floor(axes.xaxis.min); + vz.to = Math.ceil(axes.xaxis.max); + vz.options.plot.yaxis.min = axes.yaxis.min; + vz.options.plot.yaxis.max = axes.yaxis.max; + })*/ + /*.bind('mouseup', function(event) { + loadData(); + })*/ + .bind('plotzoom', function (event, plot) { + var axes = vz.plot.getAxes(); + vz.from = Math.floor(axes.xaxis.min); + vz.to = Math.ceil(axes.xaxis.max); + vz.options.plot.yaxis.min = axes.yaxis.min; + vz.options.plot.yaxis.max = axes.yaxis.max; + vz.data.load(); + }); +}; + /** * Refresh plot with new data */ diff --git a/frontend/javascripts/init.js b/frontend/javascripts/init.js index 169e2c7..10210cc 100644 --- a/frontend/javascripts/init.js +++ b/frontend/javascripts/init.js @@ -114,33 +114,7 @@ $(document).ready(function() { // start auto refresh timer window.setInterval(vz.refresh, 5000); - // handle zooming & panning - $('#plot') - .bind("plotselected", function (event, ranges) { - vz.from = Math.floor(ranges.xaxis.from); - vz.to = Math.ceil(ranges.xaxis.to); - vz.options.plot.yaxis.min = 0; - vz.options.plot.yaxis.max = null; // autoscaling - vz.data.load(); - }) - /*.bind('plotpan', function (event, plot) { - var axes = vz.plot.getAxes(); - vz.from = Math.floor(axes.xaxis.min); - vz.to = Math.ceil(axes.xaxis.max); - vz.options.plot.yaxis.min = axes.yaxis.min; - vz.options.plot.yaxis.max = axes.yaxis.max; - })*/ - .bind('plotzoom', function (event, plot) { - var axes = vz.plot.getAxes(); - vz.from = Math.floor(axes.xaxis.min); - vz.to = Math.ceil(axes.xaxis.max); - vz.options.plot.yaxis.min = axes.yaxis.min; - vz.options.plot.yaxis.max = axes.yaxis.max; - vz.data.load(); - }) - .bind('mouseup', function(event) { - //loadData(); - }); + vz.bindEvents(); vz.entities.load(); });