Ignore:
Timestamp:
Feb 10, 2012, 2:35:22 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #1655: GUI improvements

Select file/directory and "save as" dialogs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/filemanager/select_file.jsp

    r5713 r5953  
    4141<base:head >
    4242  <script language="JavaScript">
    43   var timer = 0;
    44   var inCall = false;
    45   function adjustIFrameSize()
    46   {
    47     if (inCall) return;
    48     inCall = true;
    49     var iframeElement = document.getElementById("idManager");
    50     // Find the top coordinate of the IFrame
    51     var offsetTop = 1;
    52     var offsetTrail = iframeElement;
    53     while (offsetTrail)
    54     {
    55       offsetTop += offsetTrail.offsetTop;
    56       offsetTrail = offsetTrail.offsetParent;
    57     }
    58 
    59     // Find the browser window height
    60     var windowHeight = Main.getWindowHeight();
    61     var controlsPos = Main.getElementPosition(document.getElementById('controls'));
    62     iframeElement.height = windowHeight-offsetTop - controlsPos.height - 15;
    63 
    64     // Adjust the height of the frames
    65     var iframe = window.frames['manager'];
    66     var directories = iframe.frames['directories'].document.getElementById('main');
    67     if (directories) directories.style.height = (iframeElement.height-1)+'px';
    68     var joust = iframe.frames['directories'].document.getElementById('joust');
    69     if (joust) joust.style.height = (iframeElement.height-1-30)+'px';
    70     var files = iframe.frames['files'].document.getElementById('main');
    71     if (files) files.style.height = iframeElement.height+'px';
    72     inCall = false;
    73   }
    74   function setTimer()
    75   {
    76     if (inCall) return;
    77     if (timer) clearTimeout(timer);
    78     timer = setTimeout('adjustIFrameSize()', 150);
    79   }
     43  var selected = new Array();
    8044  function setSelected(fileId, path)
    8145  {
    82     var frm = document.forms['file'];
    83     frm.file_id.value = fileId;
    84     frm.path.value = path;
     46    selected[0] = {'id': fileId, 'path': path};
     47    updatePath();
    8548  }
    8649  function addSelected(fileId, path)
    8750  {
    88     var frm = document.forms['file'];
    8951    if (getSelectedFileIndex(fileId) == -1)
    9052    {
    91       frm.paths[frm.paths.length] = new Option(path, fileId);
     53      selected[selected.length] = {'id': fileId, 'path': path};
    9254    }
     55    updatePath();
    9356  }
    9457  function removeSelected(fileId)
    9558  {
    96     var frm = document.forms['file'];
    9759    var index = getSelectedFileIndex(fileId);
    98     if (index >= 0) frm.paths[index] = null;
     60    if (index >= 0) selected.splice(index, 1);
     61    updatePath();
    9962  }
    10063 
    10164  function getSelectedFileIndex(fileId)
    10265  {
    103     var frm = document.forms['file'];
    104     for (var i = 0; i < frm.paths.length; i++)
     66    for (var i = 0; i < selected.length; i++)
    10567    {
    106       if (frm.paths[i].value == fileId) return i;
     68      if (selected[i].id == fileId) return i;
    10769    }
    10870    return -1;
    10971  }
    11072 
     73  function updatePath()
     74  {
     75    var path = '';
     76    for (var i = 0; i < selected.length; i++)
     77    {
     78      if (path != '') path += ', ';
     79      path += selected[i].path;
     80    }
     81    document.getElementById('files').innerHTML = path;
     82   
     83  }
    11184  function returnSelected()
    11285  {
    113     var frm = document.forms['file'];
    114     <%
    115     if (mode == ModeInfo.SELECTONE)
     86    for (var i = 0; i < selected.length; i++)
    11687    {
    117       %>
    118       if (frm.file_id.value)
    119       {
    120         window.opener.<%=callback%>(frm.file_id.value, frm.path.value);
    121       }
    122       <%
     88      window.opener.<%=callback%>(selected[i].id, selected[i].path);
    12389    }
    124     else
    125     {
    126       %>
    127       for (var i = 0; i < frm.paths.length; i++)
    128       {
    129         window.opener.<%=callback%>(frm.paths[i].value, frm.paths[i].text);
    130       }
    131       <%
    132     }
    133     %>   
    13490    window.close();
    13591  }
    13692  </script>
    13793</base:head>
    138 <base:body attributes="onresize='setTimer();'">
    139   <h3><%=requestTitle == null ? title : requestTitle%></h3>
    140   <iframe name="manager" id="idManager" src="frameset.jsp?ID=<%=ID%>&mode=<%=mode.getName()%>" width="100%"
    141     frameborder="0" vspace="0" hspace="0"
    142     marginwidth="0" marginheight="0" scrolling="no" style="overflow: visible"></iframe>
     94<base:body>
     95  <h1><%=requestTitle == null ? title : requestTitle%></h1>
     96  <div class="content bottomborder">
     97    <div id="f1" class="absolutefull" style="bottom: 5em;"><iframe
     98      name="manager" id="idManager" src="frameset.jsp?ID=<%=ID%>&mode=<%=mode.getName()%>"
     99      style="width: 100%; height: 100%;"></iframe></div>
    143100
    144   <div style="border-top: 1px solid #666666" id="controls">
    145   <form name="file">
    146   <input type="hidden" name="file_id" value="">
    147   <table class="form" align="center">
    148   <%
    149   if (mode == ModeInfo.SELECTONE)
    150   {
    151     %>
    152     <tr>
    153       <td class="prompt">Selected file</td>
    154       <td><input type="text" class="text" name="path" size="100" value=""></td>
    155     </tr>
    156     <%
    157   }
    158   else
    159   {
    160     %>
    161     <tr>
    162       <td class="prompt">Selected files</td>
    163       <td><select name="paths" size="5" multiple style="width: 50em;"></select></td>
    164     </tr>
    165     <%
    166   }
    167   %>
    168   </table>
    169   </form>
     101    <div class="absolutefull topborder" style="top: auto; height: 5em;" id="controls">
     102      <table class="fullform">
     103        <tr class="dynamic">
     104          <th>Selected file(s)</th>
     105          <td id="files"></td>
     106        </tr>
     107      </table>
     108    </div>
     109  </div>
    170110 
    171   <table align="center">
    172   <tr>
    173     <td width="50%"><base:button onclick="returnSelected();" title="Ok"  /></td>
    174     <td width="50%"><base:button onclick="window.top.close();" title="Cancel" /></td>
    175   </tr>
    176   </table>
    177   </div>
     111  <base:buttongroup subclass="dialogbuttons">
     112    <base:button onclick="returnSelected();" title="Ok"  />
     113    <base:button onclick="window.top.close();" title="Cancel" />
     114  </base:buttongroup>
    178115</base:body>
    179116</base:page>
Note: See TracChangeset for help on using the changeset viewer.