Changeset 6503


Ignore:
Timestamp:
Aug 6, 2014, 9:04:46 AM (8 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1825: Remember positions of popup windows

The positions are remembered as long as the main BASE site is open.

Also added a configuration settings that allows a user to disable this feature.

Location:
branches/3.3-stable
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-stable/src/clients/web/net/sf/basedb/clients/web/taglib/Body.java

    r6192 r6503  
    217217          sb.append(" data-project-id=\"").append(sc.getActiveProjectId()).append("\"");
    218218        }
     219        sb.append(" data-remember-dialog-positions=\"").append(Values.getString(sc.getUserClientSetting("dialogs.remember-positions"), "1")).append("\"");
    219220        if (message == null)
    220221        {
  • branches/3.3-stable/src/clients/web/net/sf/basedb/clients/web/taglib/Head.java

    r6402 r6503  
    183183      allScripts.add("menu.js");
    184184    }
     185    if (pageType == Page.PAGE_TYPE_POPUP) allScripts.add("popup.js");
    185186    if (getScripts() != null)
    186187    {
  • branches/3.3-stable/www/include/scripts/main-2.js

    r6489 r6503  
    5252  app.getLoggedInUserId = function()
    5353  {
    54     return Data.get(document.body, 'user-id');
     54    return Data.int(document.body, 'user-id');
    5555  }
    5656
     
    6060  app.getActiveProjectId = function()
    6161  {
    62     return Data.get(document.body, 'project-id');
     62    return Data.int(document.body, 'project-id');
    6363  }
    6464
     
    6969  app.getScale = function()
    7070  {
    71     return Data.get(document.body, 'gui-scale');
     71    return Data.int(document.body, 'gui-scale');
    7272  }
    7373 
     
    7979  app.getMaxUrlLength = function()
    8080  {
    81     return Data.get(document.body, 'max-url-length', 0);
     81    return Data.int(document.body, 'max-url-length', 0);
     82  }
     83 
     84  /**
     85    Check if popup dialog positions should be remembered or not.
     86   */
     87  app.rememberDialogPositions = function()
     88  {
     89    return Data.int(document.body, 'remember-dialog-positions', 1);
    8290  }
    8391 
     
    11971205  dialogs.openPopup = function(url, name, width, height)
    11981206  {
    1199    
    1200     // Rescale according to user settings
    1201     var scale = App.getScale();
    1202     width = width * scale;
    1203     height = height * scale;
    1204 
    1205     /*
    1206       We will try to position the popup window in the center of
    1207       the parent window.
    1208     */
    1209     var pos = App.getWindowPosition(window.top);
    1210     var top = Math.ceil(pos.top+(pos.height-height) / 2);
    1211     var left = Math.ceil(pos.left+(pos.width-width) / 2);
    1212     if (top < 0 && pos.top >= 0) top = 0;
    1213     if (left < 0 && pos.left >= 0) left = 0;
     1207    // Get last position of the window
     1208    var position = null;
     1209    if (App.rememberDialogPositions())
     1210    {
     1211      position = Data.getPageValue("last-position", name);
     1212    }
     1213
     1214    if (!position)
     1215    {
     1216      // If no last position is know, use the specified settings
     1217      position = {};
     1218      // Rescale according to user settings
     1219      var scale = App.getScale();
     1220      position.width = width * scale;
     1221      position.height = height * scale;
     1222     
     1223      //  Try to position the popup window in the center of the parent window.
     1224      var pos = App.getWindowPosition(window.top);
     1225      var top = Math.ceil(pos.top+(pos.height-height) / 2);
     1226      var left = Math.ceil(pos.left+(pos.width-width) / 2);
     1227      position.top = (top < 0 && pos.top >= 0) ? 0 : top;
     1228      position.left = (left < 0 && pos.left >= 0) ? 0 : left;
     1229    }
    12141230
    12151231    var options = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes";
    1216     options += ",top="+top+",left="+left+",width="+width+",height="+height;
    1217 
    12181232    // Check if another window with the same name already exists
    1219     var oldWin = window.open('', name, options);
     1233    var oldWin = window.open('', name, options+",top="+position.top+",left="+position.left+",width="+position.width+",height="+position.height);
    12201234    try
    12211235    {
     
    12291243          return;
    12301244        }
     1245        position = App.getWindowPosition(oldWin);
    12311246        oldWin.close();
    12321247        url += '&warnIfOpen=0';
     
    12361251    {}
    12371252   
     1253    options += ",top="+position.top+",left="+position.left+",width="+position.width+",height="+position.height;
    12381254    var newWin;
    12391255    if (App.isTooLongUrl(url))
  • branches/3.3-stable/www/my_base/user/preferences.jsp

    r6187 r6503  
    7575  final String maxColor = Values.getString(sc.getUserClientSetting("ratiocolor.max"), "FFFF00");
    7676 
     77  final boolean rememberDialogPositions = Values.getBoolean(sc.getUserClientSetting("dialogs.remember-positions"), true);
     78 
    7779  ItemContext cc = sc.getCurrentContext(Item.USERCLIENTSETTING);
    7880  List<String> recentColors = cc.getRecent("colors");
     
    295297          </td>
    296298        </tr>
     299        <tr>
     300          <th>Dialogs</th>
     301          <td>
     302            <label><input type="checkbox" name="remember_positions" value="1"
     303              <%=rememberDialogPositions ? "checked" : "" %>
     304              >Remember positions</label>
     305          </td>
     306        </tr>   
    297307        <tr class="dynamic">
    298308          <th></th>
  • branches/3.3-stable/www/my_base/user/submit_user.jsp

    r6428 r6503  
    152152    FormatterSettings.setNumDecimals(sc, numDecimals);
    153153   
     154    sc.setUserClientSetting("dialogs.remember-positions", Values.getBoolean(request.getParameter("remember_positions")) ? "1" : "0");
     155   
    154156    // Plugins tab
    155157    sc.setUserClientSetting("plugins.sendmessage", Values.getString(request.getParameter("sendmessage"), "0"));
Note: See TracChangeset for help on using the changeset viewer.