Changeset 3610


Ignore:
Timestamp:
Jul 27, 2007, 2:53:11 PM (16 years ago)
Author:
Nicklas Nordborg
Message:

References #360: Make subsections on view pages hideable

Infrastructure is now in place. See below for examples.

Location:
trunk
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/ItemContext.java

    r3484 r3610  
    165165  private final Item itemType;
    166166  private final String subContext;
     167  private int contextId;
    167168  private int itemId;
    168169  private Set<Integer> selected;
     
    218219    this.subContext = context.getSubContext();
    219220    this.name = context.getName();
     221    this.contextId = context.getId();
    220222    this.itemId = context.getItemId();
    221223    this.rowsPerPage = context.getRowsPerPage();
     
    295297  }
    296298
     299  /**
     300    Get the database ID of this context. Can be used to load contexts
     301    @return The database ID of the context, or 0 if it hasn't been saved to
     302      the database
     303    @since 2.4
     304  */
     305  public int getContextId()
     306  {
     307    return contextId;
     308  }
     309 
    297310  /**
    298311    Get the ID of the current item in this context.
  • trunk/www/WEB-INF/base.tld

    r2949 r3610  
    438438    </attribute>
    439439  </tag>
     440  <tag>
     441    <name>section</name>
     442    <tagclass>net.sf.basedb.clients.web.taglib.HideableSection</tagclass>
     443    <attribute>
     444      <name>id</name>
     445      <required>true</required>
     446      <rtexprvalue>true</rtexprvalue>
     447    </attribute>
     448    <attribute>
     449      <name>clazz</name>
     450      <required>false</required>
     451      <rtexprvalue>true</rtexprvalue>
     452    </attribute>
     453    <attribute>
     454      <name>showclazz</name>
     455      <required>false</required>
     456      <rtexprvalue>true</rtexprvalue>
     457    </attribute>
     458    <attribute>
     459      <name>hideclazz</name>
     460      <required>false</required>
     461      <rtexprvalue>true</rtexprvalue>
     462    </attribute>
     463    <attribute>
     464      <name>style</name>
     465      <required>false</required>
     466      <rtexprvalue>true</rtexprvalue>
     467    </attribute>
     468    <attribute>
     469      <name>contentstyle</name>
     470      <required>false</required>
     471      <rtexprvalue>true</rtexprvalue>
     472    </attribute>
     473    <attribute>
     474      <name>title</name>
     475      <required>true</required>
     476      <rtexprvalue>true</rtexprvalue>
     477    </attribute>
     478    <attribute>
     479      <name>visible</name>
     480      <required>false</required>
     481      <rtexprvalue>true</rtexprvalue>
     482    </attribute>
     483    <attribute>
     484      <name>ontoggle</name>
     485      <required>false</required>
     486      <rtexprvalue>true</rtexprvalue>
     487    </attribute>
     488    <attribute>
     489      <name>initial</name>
     490      <required>false</required>
     491      <rtexprvalue>true</rtexprvalue>
     492    </attribute>
     493    <attribute>
     494      <name>context</name>
     495      <required>false</required>
     496      <rtexprvalue>true</rtexprvalue>
     497    </attribute>
     498  </tag>
    440499
    441500</taglib>
  • trunk/www/include/scripts/ajax.js

    r3068 r3610  
    2222  ------------------------------------------------------------------
    2323
    24   JavaScript functions for the Annotations
    25   /common/annotations/*
     24  JavaScript functions for sending Ajax request. Create a
     25  request with Main.getAjaxRequest() or Ajax.getXmlHttpRequest().
    2626
    2727  @author Nicklas
     
    3232function AjaxClass()
    3333{
     34  /**
     35    Create a new ajax request.
     36    @return A request object or null if the browser doesn't support ajax
     37  */
    3438  this.getXmlHttpRequest = function()
    3539  {
    36     var xmlHttp = null;
    37     if (window.XMLHttpRequest)
    38     {
    39       // Non-IE browswers
    40       xmlHttp = new XMLHttpRequest();
    41     }
    42     else if (window.ActiveXObject)
    43     {
    44       // IE browsers
    45       try
    46       {
    47         // IE #1
    48           xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    49       }
    50       catch (e)
    51       {
    52         try
    53         {
    54           // IE #2
    55           xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    56         }
    57         catch (e2)
    58         {}
    59       }
    60     }
    61     return xmlHttp;
     40    return Main.getAjaxRequest();
    6241  }
    6342 
     43  /**
     44    Register callback functions for a successful of failed request.
     45    When the request has been completed, the onSuccessHandler or
     46    onFailHandler will be called with the request as a parameter:
     47    onSuccessHandler(request);
     48  */
    6449  this.setReadyStateHandler = function(request, onSuccessHandler, onFailHandler)
    6550  {
  • trunk/www/include/scripts/main.js

    r3558 r3610  
    525525  }
    526526 
     527  /**
     528    Create a new ajax request.
     529    @return A request object or null if the browser doesn't support ajax
     530  */
     531  this.getAjaxRequest = function()
     532  {
     533    var xmlHttp = null;
     534    if (window.XMLHttpRequest)
     535    {
     536      // Non-IE browswers
     537      xmlHttp = new XMLHttpRequest();
     538    }
     539    else if (window.ActiveXObject)
     540    {
     541      // IE browsers
     542      try
     543      {
     544        // IE #1
     545          xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
     546      }
     547      catch (e)
     548      {
     549        try
     550        {
     551          // IE #2
     552          xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
     553        }
     554        catch (e2)
     555        {}
     556      }
     557    }
     558    return xmlHttp;
     559  }
     560 
     561 
    527562  this.viewSource = function()
    528563  {
     
    15551590    //alert("createHidden: name="+name+"; value="+value);
    15561591  }
     1592 
    15571593}
    15581594
     
    15691605}
    15701606
    1571 
     1607// Handle sections that can be shown/hidden and remembered by context settings
     1608var HideableSection = new HideableSectionClass();
     1609function HideableSectionClass()
     1610{
     1611  // Show/hide a section
     1612  this.toggle = function(sectionId)
     1613  {
     1614    var main = document.getElementById(sectionId);
     1615    var icon = document.getElementById(sectionId+'.icon');
     1616    var content = document.getElementById(sectionId+'.content');
     1617    var visible = true;
     1618    var showClass = main.attributes['showclass'];
     1619    var hideClass = main.attributes['hideclass'];
     1620   
     1621    if (content.style.display == 'none')
     1622    {
     1623      Main.show(content.id);
     1624      icon.src = getRoot() + '/images/hide_section.gif';
     1625      visible = true;
     1626      if (showClass) Main.addClass(main, showClass.value);
     1627      if (hideClass) Main.removeClass(main, hideClass.value);
     1628    }
     1629    else
     1630    {
     1631      Main.hide(content.id);
     1632      icon.src = getRoot() + '/images/show_section.gif';
     1633      visible = false;
     1634      if (showClass) Main.removeClass(main, showClass.value);
     1635      if (hideClass) Main.addClass(main, hideClass.value);
     1636    }
     1637    return visible;
     1638  }
     1639 
     1640  /**
     1641    Show/hide a section and send an Ajax request to the server with
     1642    the new status. If the browser doesn't support Ajax, this method is
     1643    identical to toggle()
     1644  */
     1645  this.toggleAndSendWithAjax = function(sectionId, itemType, subcontext)
     1646  {
     1647    var visible = this.toggle(sectionId);
     1648    var request = Main.getAjaxRequest();
     1649    if (request != null)
     1650    {
     1651      var url = getRoot()+'/common/store_show_hide_section.jsp?ID='+Main.getIdFromLocation();
     1652      url += '&sectionId='+sectionId;
     1653      url += '&itemType='+itemType;
     1654      url += '&subcontext='+subcontext;
     1655      url += '&visible='+(visible ? '1' : '0');
     1656      request.open("GET", url, true);
     1657      request.send(null);
     1658    }
     1659   
     1660  }
     1661 
     1662
     1663}
  • trunk/www/include/styles/main.css

    r3045 r3610  
    6767}
    6868
    69 h3.docked {
     69h3.docked, .docked h3 {
    7070  border-bottom: 0px;
    7171}
     
    8080}
    8181
    82 h4.docked {
     82h4.docked, .docked h4 {
    8383  border-bottom: 0px;
    8484  margin-bottom: 2px;
  • trunk/www/lims/arraydesigns/view_design.jsp

    r3608 r3610  
    245245      />
    246246      </tbl:toolbar>
     247     
    247248    <div class="boxedbottom">
    248249      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(design)%></i></div>
     
    336337      {
    337338        %>
    338         <h4 class="docked">Array batches</h4>
     339        <base:section
     340          id="batches"
     341          title="<%="Array batches (" + batches.size() +")"%>"
     342          context="<%=cc%>">
    339343        <tbl:table
    340344          id="batches"
     
    368372        </tbl:data>
    369373        </tbl:table>
     374        </base:section>
    370375        <%
    371376      }
     
    387392      {
    388393        %>
    389         <h4 class="docked">Plates</h4>
     394        <base:section
     395          id="plates"
     396          title="<%="Plates (" + plates.size() +")"%>"
     397          context="<%=cc%>">
    390398        <tbl:table
    391399          id="plates"
     
    434442        </tbl:data>
    435443        </tbl:table>
     444        </base:section>
    436445        <%
    437446      }
     
    449458      {
    450459        %>
    451         <h4 class="docked">Shared to</h4>
     460        <base:section
     461          id="sharedTo"
     462          title="Shared to"
     463          context="<%=cc%>">
    452464        <tbl:table
    453465          id="itemsSharedTo"
     
    518530          </tbl:data>
    519531        </tbl:table>
     532        </base:section>
    520533        <%
    521534      }
Note: See TracChangeset for help on using the changeset viewer.