2 * (C) Copyright 2007-2008 Jeremy Maitin-Shepard
4 * Portions of this file were derived from Vimperator,
5 * (C) Copyright 2006-2007 Martin Stubenschrott.
7 * Use, modification, and distribution are subject to the terms specified in the
12 * Text and full-page zoom
16 var zoom_levels = [ 1, 10, 25, 50, 75, 90, 100,
17 120, 150, 200, 300, 500, 1000, 2000 ];
19 function browser_zoom_set(buffer, full_zoom, value) {
20 if (value < zoom_levels[0])
21 value = zoom_levels[0];
22 if (value > zoom_levels[zoom_levels.length - 1])
23 value = zoom_levels[zoom_levels.length - 1];
24 buffer.markup_document_viewer[full_zoom ? "fullZoom" : "textZoom"] = value / 100.0;
25 buffer.window.minibuffer.message((full_zoom ? "Full" : "Text") + " zoom: " + value + "%");
28 function browser_zoom_change(buffer, full_zoom, count) {
31 var zoom = full_zoom ? "fullZoom" : "textZoom";
32 var cur_value = buffer.markup_document_viewer[zoom] * 100;
36 for (var i = zoom_levels.length - 1; i >= 0; --i)
38 if (zoom_levels[i] - 0.01 < cur_value) {
39 new_level = i + count;
44 new_level = zoom_levels.length - 1;
45 for (var i = 0; i < zoom_levels.length; ++i)
47 if (zoom_levels[i] + 0.01 > cur_value) {
48 new_level = i + count;
56 if (new_level >= zoom_levels.length)
57 new_level = zoom_levels.length - 1;
58 browser_zoom_set(buffer, full_zoom, zoom_levels[new_level]);
61 interactive("zoom-in-text", null, function (I) {browser_zoom_change(I.buffer, false /* not full zoom */, I.p);});
62 interactive("zoom-out-text", null, function (I) {browser_zoom_change(I.buffer, false /* not full zoom */, -I.p);});
63 interactive("zoom-in-text-more", null, function (I) {browser_zoom_change(I.buffer, false /* not full zoom */, I.p * 3);});
64 interactive("zoom-out-text-more", null, function (I) {browser_zoom_change(I.buffer, false /* not full zoom */, -I.p * 3);});
65 interactive("zoom-reset-text", null, function (I) {browser_zoom_set(I.buffer, false /* not full zoom */, I.p = 100);});
67 interactive("zoom-in-full", null, function (I) {browser_zoom_change(I.buffer, true /* full zoom */, I.p);});
68 interactive("zoom-out-full", null, function (I) {browser_zoom_change(I.buffer, true /* full zoom */, -I.p);});
69 interactive("zoom-in-full-more", null, function (I) {browser_zoom_change(I.buffer, true /* full zoom */, I.p * 3);});
70 interactive("zoom-out-full-more", null, function (I) {browser_zoom_change(I.buffer, true /* full zoom */, -I.p * 3);});
71 interactive("zoom-reset-full", null, function (I) {browser_zoom_set(I.buffer, true /* full zoom */, I.p = 100);});