Ticket #14429: torbutton-resizer.patch

File torbutton-resizer.patch, 1.0 KB (added by cypherpunks, 20 months ago)

patch to implement resizing of windows to common browser window sizes

  • src/chrome/content/torbutton.js

    diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
    index 2f1f689..3cc5a88 100644
    a b function torbutton_init_user_manual_links() { 
    23862386  });
    23872387}
    23882388
     2389var resolutions = [
     2390    {x: 1366, y:768},
     2391    {x: 1920, y:1080},
     2392    {x: 1600, y:900},
     2393    {x: 1280, y:1024},
     2394    {x: 1440, y:900},
     2395    {x: 1280, y:800}]
     2396
     2397function bestFit(x, y) {
     2398    var m = resolutions[0];
     2399    for (var i = 1; i < resolutions.length; i++) {
     2400        var r = resolutions[i];
     2401        if (Math.abs(x - r.x) < Math.abs(x - m.x) || Math.abs(y - r.y) < Math.abs( y - m.y)) {
     2402            m = r;
     2403        }
     2404    }
     2405
     2406    return m;
     2407}
     2408
     2409window.addEventListener("resize", function (event) {
     2410    var r = bestFit(window.outerWidth, window.outerHeight);
     2411    window.gBrowser.minWidth = r.x;
     2412    window.gBrowser.minHeight = r.y;
     2413    window.gBrowser.maxWidth = r.x;
     2414    window.gBrowser.maxHeight = r.y;
     2415    resizeTo(r.x, r.y);
     2416}, false);
     2417
    23892418//vim:set ts=4