Changeset 6543


Ignore:
Timestamp:
Sep 30, 2014, 8:40:14 AM (8 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1851: Scale factor rounding causes popup dialog problems

Also fixed an issue when trying to open dialog that was bigger than screen size. The browser will not let you which is causing a possible large correction factor to be used the next time.

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

    r6530 r6543  
    7575  app.getScale = function()
    7676  {
    77     return Data.int(document.body, 'gui-scale');
     77    return Data.float(document.body, 'gui-scale');
    7878  }
    7979 
     
    12611261      // If no last position is know, use the specified settings
    12621262      position = {};
    1263       // Rescale according to user settings
     1263      // Rescale according to user settings -- but not larger than current screen
    12641264      var scale = App.getScale();
    1265       position.width = width * scale;
    1266       position.height = height * scale;
     1265      position.width = Math.ceil(Math.min(width * scale, screen.availWidth));
     1266      position.height = Math.ceil(Math.min(height * scale, screen.availHeight));
    12671267     
    12681268      //  Try to position the popup window in the center of the parent window.
    12691269      var pos = App.getWindowPosition(window.top);
    1270       var top = Math.ceil(pos.top+(pos.height-height) / 2);
    1271       var left = Math.ceil(pos.left+(pos.width-width) / 2);
     1270      var top = Math.ceil(pos.top+(pos.height-position.height) / 2);
     1271      var left = Math.ceil(pos.left+(pos.width-position.width) / 2);
    12721272      position.top = (top < 0 && pos.top >= 0) ? 0 : top;
    12731273      position.left = (left < 0 && pos.left >= 0) ? 0 : left;
  • branches/3.3-stable/www/include/scripts/popup.js

    r6529 r6543  
    4242  {
    4343    saveDialogPosition = window.top.name && App.rememberDialogPositions();
    44     if (saveDialogPosition) setTimeout(internal.initPosition, 500);
     44    if (saveDialogPosition) setTimeout(internal.initPosition, 200);
    4545  }
    4646 
     
    5151    var key = 'dialog-position-req:'+window.top.name;
    5252    var rpos = JSON.parse(App.getLocal(key));
    53 //    alert('['+window.screenX+', '+window.screenY+'], ['+rpos.width+', ' + rpos.height+'], ['+window.innerWidth+', ' + window.innerHeight+'], [' + window.outerWidth+', '+window.outerHeight+']');
    5453    if (rpos)
    5554    {
    5655      App.removeLocal(key);
    5756      var cpos = App.getWindowPosition(window.top);
    58       dx = rpos.width-cpos.width;
    59       dy = rpos.height-cpos.height;
     57      dx = Math.min(rpos.width, screen.availWidth) - cpos.width;
     58      dy = Math.min(rpos.height, screen.availHeight) - cpos.height;
     59//      window.top.opener.App.debug('requested:'+JSON.stringify(rpos));
     60//      window.top.opener.App.debug('actual:'+JSON.stringify(cpos));
     61//      window.top.opener.App.debug('delta:'+dx+','+dy);
     62//      window.top.opener.App.debug('screen:'+screen.availWidth+','+screen.availHeight);
    6063    }
    6164  }
Note: See TracChangeset for help on using the changeset viewer.