Ignore:
Timestamp:
2024-04-30T18:49:50+12:00 (3 weeks ago)
Author:
anupama
Message:

Certain user-customised GLI Collage classifier options need to go into the pageResponse to be incorporated into the applet shim. 1. buildConfigxml.pm modified to push these options out into buildConfig.xml. 2. AbstractBrowse.java (classifier Service) has been modified to push out any classifier option subelements out into the pageResponse. 3. classifier.xsl has been modified to construct its applet HTML element's parameter elements taking into account any customised values in the pageResponse or using the old defaults for fallback. 4. The JavaScript code in webswing-collage.xsl doesn't have ready access to the pageResponse elements (this may need revisiting for if the applet element was accidentally removed from the page), but was already taking into account any applet parameters. webswing-collage.xsl has been modified to use any static/dynamic width and height attributes set on the applet parameter to reset the width and height on the div id=webswing-collage element, as webswing uses the dimensions set on the HTML element housing the webswing instance if running the instance as an applet. It does not resize the webswing applet thereafter. So the most transparent way to allow the user customised dimensions to control the dimensions of the webswing application as intended by the user, is to modify the dimensions set on the webswing-collage element's div before launching the webswing application.

Location:
main/trunk/greenstone3/web/interfaces/default/transform
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/transform/layouts/webswing-collage.xsl

    r38956 r38964  
    164164       webswingParams["height"] = stripUnitOffAttribute("px", h);
    165165
    166        
     166       // Webswing only uses the width and height set on the webswing-collage element
     167       // Override this with any dimensions set on any applet element, as that is user-controlled
     168       // from GLI. style.setProperty failed without the important parameter to force the setting.
     169       // https://stackoverflow.com/questions/5191478/changing-element-style-attribute-dynamically-using-javascript
     170       document.getElementById("webswing-collage").style.setProperty("width", webswingParams["width"] + "px", "important");
     171       document.getElementById("webswing-collage").style.setProperty("height", webswingParams["height"] + "px", "important");
     172
    167173       // Having collected all the webswingParams, we can finally build up the single webswing customArgs string
    168174       var _args = "";
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/classifier.xsl

    r38950 r38964  
    151151  <xsl:template name="collage-applet-shim">
    152152    <!--<xsl:text>TODO: Here is the collage applet</xsl:text>-->
     153   
    153154    <!-- Copied from GS2.88's about.dm (document.dm has more applet params).
    154155
     
    173174    id="collage-applet-element"
    174175    code="org.greenstone.applet.GsdlCollageApplet.GsdlCollageApplet.class"
    175     archive="GsdlCollageApplet.jar, webswing-api.jar"
    176     width="800"
    177     height="400">
     176    archive="GsdlCollageApplet.jar, webswing-api.jar">
    178177      <xsl:attribute name="codebase">/<xsl:value-of select="$servlet_context"/>/applet</xsl:attribute>
    179 
     178      <xsl:choose>
     179        <xsl:when test="option[@name='geometry']/@value">
     180      <xsl:attribute name="width">
     181        <xsl:value-of select="substring-before(option[@name='geometry']/@value, 'x')" />
     182      </xsl:attribute>
     183      <xsl:attribute name="height">
     184        <xsl:value-of select="substring-after(option[@name='geometry']/@value, 'x')" />
     185      </xsl:attribute>
     186    </xsl:when>
     187      </xsl:choose>
     188     
    180189      <!-- declaring some local variables -->
    181190      <xsl:variable name="coll_name">
     
    183192      </xsl:variable>
    184193      <xsl:variable name="classifier">
    185         <xsl:value-of select="/page/pageRequest/paramList/param[@name='cl']/@value"/>
     194    <xsl:value-of select="/page/pageRequest/paramList/param[@name='cl']/@value"/>
    186195      </xsl:variable>
    187196      <xsl:variable name="fullURL">
    188         <xsl:value-of select="/page/pageRequest/@fullURL"/>
     197    <xsl:value-of select="/page/pageRequest/@fullURL"/>
    189198      </xsl:variable>
    190199      <xsl:variable name="url_protocol_prefix">
    191         <xsl:value-of select="substring-before (/page/pageRequest/@fullURL,'/')"/>
    192       </xsl:variable>
    193 
     200    <xsl:value-of select="substring-before (/page/pageRequest/@fullURL,'/')"/>
     201      </xsl:variable>
     202     
    194203      <!-- setting the applet parameters: first the dynamic ones -->
    195204     
     
    218227     
    219228      <!-- applet parameters that can be manually adjusted -->
    220       <param name="imageType" value=".jpg%.png" />     
     229      <!--
     230      <param name="imageType" value=".jpg%.png" />
    221231      <param name="verbosity" value="3" />
    222232      <param name="maxDepth" value="500"/>
     
    225235      <param name="isJava2" value="auto"/>
    226236      <param name="bgcolor" value="#96c29a" />
    227 The Collage Applet.
    228 
     237      -->
     238      <!--<param name="imageType" value="{option[@name='imageType']/@value}" />-->
     239      <xsl:call-template name="add-applet-param">
     240    <xsl:with-param name="paramName">imageType</xsl:with-param>
     241    <xsl:with-param name="paramDefaultValue">.jpg%.png</xsl:with-param>
     242      </xsl:call-template>
     243      <xsl:call-template name="add-applet-param">
     244    <xsl:with-param name="paramName">verbosity</xsl:with-param>
     245    <xsl:with-param name="paramDefaultValue">3</xsl:with-param>
     246      </xsl:call-template>
     247      <xsl:call-template name="add-applet-param">
     248    <xsl:with-param name="paramName">maxDepth</xsl:with-param>
     249    <xsl:with-param name="paramDefaultValue">500</xsl:with-param>
     250      </xsl:call-template>
     251      <xsl:call-template name="add-applet-param">
     252    <xsl:with-param name="paramName">maxDisplay</xsl:with-param>
     253    <xsl:with-param name="paramDefaultValue">25</xsl:with-param>
     254      </xsl:call-template>
     255      <xsl:call-template name="add-applet-param">
     256    <xsl:with-param name="paramName">refreshDelay</xsl:with-param>
     257    <xsl:with-param name="paramDefaultValue">1500</xsl:with-param>
     258      </xsl:call-template>
     259      <xsl:call-template name="add-applet-param">
     260    <xsl:with-param name="paramName">isJava2</xsl:with-param>
     261    <xsl:with-param name="paramDefaultValue">auto</xsl:with-param>
     262      </xsl:call-template>
     263      <xsl:call-template name="add-applet-param">
     264    <xsl:with-param name="paramName">bgcolor</xsl:with-param>
     265    <xsl:with-param name="paramDefaultValue">#96c29a</xsl:with-param>
     266      </xsl:call-template>     
     267      The Collage Applet.     
    229268   </applet>
    230269  </xsl:template>
    231270
     271  <!-- https://our.umbraco.com/forum/developers/xslt/9274-Return-Value-from-a-Template -->
     272 <xsl:template name="add-applet-param">
     273   <xsl:param name = "paramName" />
     274   <xsl:param name = "paramDefaultValue" />
     275   <param name="{$paramName}">
     276     <xsl:attribute name="value">
     277       <xsl:choose>
     278         <xsl:when test="option[@name=$paramName]/@value">
     279       <xsl:value-of select="option[@name=$paramName]/@value"/>
     280     </xsl:when>
     281         <xsl:otherwise>
     282       <xsl:value-of select="$paramDefaultValue"/>
     283     </xsl:otherwise>
     284      </xsl:choose>
     285     </xsl:attribute>
     286   </param>
     287 </xsl:template>
     288 
     289 
    232290  <xsl:template name="Collage_javascript_deprecated">
    233291    <script type="text/javascript" src="interfaces/{$interface_name}/js/collage_scripts.js"><xsl:text> </xsl:text></script>
     
    348406      <xsl:when test="@childType = 'Collage'">
    349407    <xsl:choose>
    350       <xsl:when test="not(*)">
     408      <!--test of not(*) means has no children, not(classNode) has no subelements classNode-->
     409      <xsl:when test="not(classifierNode)">
    351410        <!-- the order of calling these templates now matters since the collage applet now
    352411         serves as a shim in the javascript that gets loaded in the 2nd template call:
Note: See TracChangeset for help on using the changeset viewer.