Changeset 6507


Ignore:
Timestamp:
Aug 7, 2014, 10:04:34 AM (8 years ago)
Author:
Nicklas Nordborg
Message:

References #1825: Remember positions of popup windows

More fixes since browsers doesn't make the window the exact size as requested. Thus, when saving the previous position and then re-opening the window with those values it will shift slightly in size each time.

  • Firefox: -1 pixel in height
  • IE: +4 pixels in width/height
Location:
branches/3.3-stable/www/include/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-stable/www/include/scripts/main-2.js

    r6506 r6507  
    12511251    {}
    12521252   
     1253    if (App.rememberDialogPositions())
     1254    {
     1255      Data.setPageValue('requested-position', JSON.stringify(position), name);
     1256    }
    12531257    options += ",top="+position.top+",left="+position.left+",width="+position.width+",height="+position.height;
    12541258    var newWin;
     
    12631267      newWin = window.open(url, name, options);
    12641268    }
     1269   
    12651270    newWin.focus();
    12661271    return newWin;
  • branches/3.3-stable/www/include/scripts/popup.js

    r6506 r6507  
    2626  var popup = {};
    2727  var internal = {};
     28  var dx = 0;
     29  var dy = 0;
    2830 
    2931  // If the popup dialog is read-only BASE will not
     
    3436  }
    3537 
     38  // Need short delay to ensure that window is properly initialized
     39  internal.delayInitPosition = function()
     40  {
     41    setTimeout(internal.initPosition, 20);
     42  }
     43 
     44  // Correct size of the window if the actual size is different from the requested
     45  // Firefox has -1 pixel height and IE has +4 pixels width and height
     46  internal.initPosition = function()
     47  {
     48    if (window.top.name && App.rememberDialogPositions())
     49    {
     50      var rpos = JSON.parse(Data.getPageValue("requested-position", window.top.name));
     51      var cpos = App.getWindowPosition(window.top);
     52      dx = rpos.width-cpos.width;
     53      dy = rpos.height-cpos.height;
     54    }
     55  }
     56 
    3657  internal.savePosition = function()
    3758  {
    3859    if (window.top.name && App.rememberDialogPositions())
    3960    {
    40       var pos = JSON.stringify(App.getWindowPosition(window.top));
    41       Data.setPageValue("last-position", pos, window.top.name);
     61      var pos = App.getWindowPosition(window.top);
     62      pos.width += dx;
     63      pos.height += dy;
     64      Data.setPageValue("last-position", JSON.stringify(pos), window.top.name);
    4265    }
    4366  }
    4467 
     68  document.addEventListener('DOMContentLoaded', internal.delayInitPosition, false);
    4569  window.addEventListener('beforeunload', internal.savePosition, false);
    4670 
Note: See TracChangeset for help on using the changeset viewer.