3 * Text and full-page zoom
7 var zoom_levels = [ 1, 10, 25, 50, 75, 90, 100,
8 120, 150, 200, 300, 500, 1000, 2000 ];
10 function browser_zoom_set(buffer, full_zoom, value) {
11 if (value < zoom_levels[0])
12 value = zoom_levels[0];
13 if (value > zoom_levels[zoom_levels.length - 1])
14 value = zoom_levels[zoom_levels.length - 1];
15 buffer.markup_document_viewer[full_zoom ? "fullZoom" : "textZoom"] = value / 100.0;
16 buffer.window.minibuffer.message((full_zoom ? "Full" : "Text") + " zoom: " + value + "%");
19 function browser_zoom_change(buffer, full_zoom, count) {
22 var zoom = full_zoom ? "fullZoom" : "textZoom";
23 var cur_value = buffer.markup_document_viewer[zoom] * 100;
27 for (var i = zoom_levels.length - 1; i >= 0; --i)
29 if (zoom_levels[i] - 0.01 < cur_value) {
30 new_level = i + count;
35 new_level = zoom_levels.length - 1;
36 for (var i = 0; i < zoom_levels.length; ++i)
38 if (zoom_levels[i] + 0.01 > cur_value) {
39 new_level = i + count;
47 if (new_level >= zoom_levels.length)
48 new_level = zoom_levels.length - 1;
49 browser_zoom_set(buffer, full_zoom, zoom_levels[new_level]);
52 interactive("zoom-in-text", function (I) {browser_zoom_change(I.buffer, false /* not full zoom */, I.p);});
53 interactive("zoom-out-text", function (I) {browser_zoom_change(I.buffer, false /* not full zoom */, -I.p);});
54 interactive("zoom-in-text-more", function (I) {browser_zoom_change(I.buffer, false /* not full zoom */, I.p * 3);});
55 interactive("zoom-out-text-more", function (I) {browser_zoom_change(I.buffer, false /* not full zoom */, -I.p * 3);});
56 interactive("zoom-reset-text", function (I) {browser_zoom_set(I.buffer, false /* not full zoom */, I.p = 100);});
58 interactive("zoom-in-full", function (I) {browser_zoom_change(I.buffer, true /* full zoom */, I.p);});
59 interactive("zoom-out-full", function (I) {browser_zoom_change(I.buffer, true /* full zoom */, -I.p);});
60 interactive("zoom-in-full-more", function (I) {browser_zoom_change(I.buffer, true /* full zoom */, I.p * 3);});
61 interactive("zoom-out-full-more", function (I) {browser_zoom_change(I.buffer, true /* full zoom */, -I.p * 3);});
62 interactive("zoom-reset-full", function (I) {browser_zoom_set(I.buffer, true /* full zoom */, I.p = 100);});