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
17 var zoom_levels = [ 1, 10, 25, 50, 75, 90, 100,
18 120, 150, 200, 300, 500, 1000, 2000 ];
20 function browser_zoom_set (buffer, full_zoom, value) {
21 var txt = full_zoom ? "Zoom: " : "Text zoom: ";
22 if (value < zoom_levels[0])
23 value = zoom_levels[0];
24 if (value > zoom_levels[zoom_levels.length - 1])
25 value = zoom_levels[zoom_levels.length - 1];
26 buffer.markup_document_viewer[full_zoom ? "fullZoom" : "textZoom"] = value / 100.0;
27 buffer.window.minibuffer.message(txt + value + "%");
30 function browser_zoom_change (buffer, full_zoom, count) {
33 var zoom = full_zoom ? "fullZoom" : "textZoom";
34 var cur_value = buffer.markup_document_viewer[zoom] * 100;
38 for (var i = zoom_levels.length - 1; i >= 0; --i) {
39 if (zoom_levels[i] - 0.01 < cur_value) {
40 new_level = i + count;
45 new_level = zoom_levels.length - 1;
46 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);});