[perf-web] Add +/- keyboard shortcuts for zooming
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [perf-web] Add +/- keyboard shortcuts for zooming
- Date: Sun, 14 Sep 2014 20:06:33 +0000 (UTC)
commit 66b0b0e736761e717b37c95d4d63e2e29d824a12
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Sun Sep 14 16:03:54 2014 -0400
Add +/- keyboard shortcuts for zooming
Once you've zoomed in with double-clicking, it's nice to have some way
to zoom out without having to navigate to the links.
static/main.js | 75 +++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 58 insertions(+), 17 deletions(-)
---
diff --git a/static/main.js b/static/main.js
index 6cfe2d6..29b1fb9 100644
--- a/static/main.js
+++ b/static/main.js
@@ -95,27 +95,11 @@ function Chart(svg) {
this.bottom = 10;
svg.addEventListener("dblclick", function(event) {
- var rangeType;
- switch (theDisplay.rangeType) {
- case 'day':
- return;
- case 'week':
- rangeType = 'day';
- break;
- case 'month':
- rangeType = 'week';
- break;
- case 'year':
- rangeType = 'month';
- break;
- }
-
var offset = $( this.body ).offset();
var x = event.pageX - offset.left;
var centerTime = this.time(x);
- theDisplay.setPositionAndRange(centerTime, rangeType, false);
- theDisplay.updateElementsForRange();
+ theDisplay.zoomIn(centerTime);
}.bind(this));
}
@@ -1328,6 +1312,52 @@ PerfDisplay.prototype.scrollByDeltaX = function(startTime, deltaX) {
true);
}
+PerfDisplay.prototype.zoomIn = function(centerTime) {
+ if (centerTime == null)
+ centerTime = this.centerTime;
+
+ var rangeType;
+ switch (this.rangeType) {
+ case 'day':
+ return;
+ case 'week':
+ rangeType = 'day';
+ break;
+ case 'month':
+ rangeType = 'week';
+ break;
+ case 'year':
+ rangeType = 'month';
+ break;
+ }
+
+ this.setPositionAndRange(centerTime, rangeType, false);
+ this.updateElementsForRange();
+}
+
+PerfDisplay.prototype.zoomOut = function(centerTime) {
+ if (centerTime == null)
+ centerTime = this.centerTime;
+
+ var rangeType;
+ switch (this.rangeType) {
+ case 'day':
+ rangeType = 'week';
+ break;
+ case 'week':
+ rangeType = 'month';
+ break;
+ case 'month':
+ rangeType = 'year';
+ break;
+ case 'year':
+ return;
+ }
+
+ this.setPositionAndRange(centerTime, rangeType, false);
+ this.updateElementsForRange();
+}
+
PerfDisplay.prototype.onWindowLoaded = function() {
this.updateElementsForRange();
@@ -1375,6 +1405,17 @@ PerfDisplay.prototype.onWindowLoaded = function() {
}
});
+ $( document.body ).keypress(function(e) {
+ console.log(e);
+ if (e.which == 43) { /* + */
+ e.preventDefault();
+ this.zoomIn();
+ } else if (e.which == 45) { /* - */
+ e.preventDefault();
+ this.zoomOut();
+ }
+ }.bind(this));
+
$( window ).resize(function() {
this.refresh();
}.bind(this));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]