Changeset 23135


Ignore:
Timestamp:
2010-10-13T16:09:40+13:00 (12 years ago)
Author:
sjb48
Message:

Can now drag a metadata item and have it maintain selection

Location:
main/trunk/greenstone3/web/interfaces/oran
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/oran/js/gui_div.js

    r23046 r23135  
    55
    66    console.log("Document ready function\n");
     7
     8    var CURRENT_SELECT_VALUE = "";
    79
    810    /******************************************/
     
    5355
    5456    //$(".element_type_gsf_metadata").draggable({
    55     $(".gsf_metadata").draggable({
     57    $(".draggable_gsf_metadata").draggable({
    5658            cursor: 'crosshair',
    5759            connectToSortable: '.gsf_choose_metadata, .gsf_when, .gsf_otherwise, .td-div',
     
    6062    });
    6163
    62     $(".element_type_gsf_link").draggable({
     64    $(".draggable_gsf_link").draggable({
    6365            cursor: 'crosshair',
    6466            connectToSortable: '.td-div',
     
    215217function replace_with(item, me)
    216218{
     219    // Search me for select
     220    if(me.search("select") != -1)
     221    {
     222    // If select exists, then find CURRENT_SELECT_VALUE
     223        var index = me.search(CURRENT_SELECT_VALUE);
     224        if(index == -1)
     225            console.log("Did not find " + CURRENT_SELECT_VALUE);
     226        else
     227            console.log("Found " + CURRENT_SELECT_VALUE + " at index " + index);   
     228            index = index + CURRENT_SELECT_VALUE.length + 1;
     229            console.log("Attempt inserting select at new index "+index);
     230            a = me.substring(0,index);
     231            b = me.substring(index);
     232            me = a.concat("selected",b);
     233    }
     234
    217235    //console.log('function replace_with(item, me)');
    218236    item.replaceWith(me); //'<div class="element element-txt">This text box has been added!</div>');
     237    //item.find('select').attr("value", CURRENT_SELECT_VALUE);
     238
     239
     240    //if(select != null){
     241    //    console.log("Attempting to select " + CURRENT_SELECT_VALUE);
     242    //    console.log("length = "+select.length);
     243    //    for(index = 0; index < select.length; index++) {
     244    //          console.log(select[index].value); 
     245    //       if(select[index].value == CURRENT_SELECT_VALUE)
     246    //          console.log("Found "+CURRENT_SELECT_VALUE+" at index " + index);
     247    //          select.selectedIndex = index;
     248    //    }
     249    // }
    219250
    220251    resize_tables(item);
     
    337368            stop: function(event, ui) {
    338369                //alert("STOP");
    339                 //if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('element_type_gsf_metadata')) { replace_with(ui.item, gsf_metadata_element); }
     370                if (ui.item.hasClass("ui-draggable") && ui.item.hasClass('draggable_gsf_metadata')) {
     371                    console.log("Current select value = "+CURRENT_SELECT_VALUE);
     372                    var select = $(ui.item).find('select');
     373                    var value = select.attr("value");
     374                    console.log("We want this:"+value);
     375
     376                    replace_with(ui.item, gsf_metadata_element);
     377                   
     378                }
    340379                bind_all_sortables();
    341380            }
  • main/trunk/greenstone3/web/interfaces/oran/transform/layouts/main.xsl

    r23046 r23135  
    3737                <!-- <script type="text/javascript" src="interfaces/oran/js/jquery-ui-1.8.2.custom.min.js"><xsl:text> </xsl:text></script> -->
    3838                <script type="text/javascript" src="interfaces/oran/js/jquery-ui-1.8rc1/ui/jquery-ui.js"><xsl:text> </xsl:text></script>
     39                <script type="text/javascript" src="interfaces/oran/js/jquery.selectboxes.js"><xsl:text> </xsl:text></script>
    3940                <!-- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.js"><xsl:text> </xsl:text></script> -->
    4041                <!-- <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"><xsl:text> </xsl:text></script> -->
     
    121122
    122123<!-- *************************************************************************************** -->
     124
     125    <!-- <xsl:variable name="foo"> -->
     126    <!-- <xsl:value-of select="/page/pageRequest/paramList[@name='formatedit']"/> -->
     127
     128    <xsl:if test="/page/pageRequest/paramList/param[(@name='formatedit') and (@value='1')]">
    123129
    124130<!-- Sam2's div code -->
     
    192198        </script> -->
    193199        <div class="header element_type_gsf_choose_metadata css_gsf_choose_metadata" title="gsf:choose-metadata">CHOOSE-METADATA</div>
    194         <div class="gsf_metadata css_gsf_metadata block leaf" title="gsf:metadata"><table class="header"><tbody><tr><td class="header"><xsl:call-template name="meta-to-combo">
     200        <div class="draggable_gsf_metadata gsf_metadata css_gsf_metadata block leaf" title="gsf:metadata"><table class="header"><tbody><tr><td class="header"><xsl:call-template name="meta-to-combo">
    195201                        <xsl:with-param name="metadataSets" select="//metadataSetList"/>
    196202                        <xsl:with-param name="current" select="ex.Title"/>
    197203                     </xsl:call-template></td><td class="header"><a href="#" class="remove ui-icon ui-icon-closethick" title="Click me to remove"/></td></tr></tbody></table></div>
    198204        <!-- <div class="header element_type_gsf_metadata css_gsf_metadata" title="gsf:metadata">METADATA</div> -->
    199         <div class="header element_type_gsf_link css_gsf_link" title="gsf:link">LINK</div>
     205        <!-- <div class="header element_type_gsf_link css_gsf_link" title="gsf:link">LINK</div> -->
     206        <div class="draggable_gsf_link css_gsf_link block" title="gsf:link"><table class="header"><tbody><tr><td class="header">LINK<select>
     207                            <option value = "document" selected = "document">Document</option>
     208                            <option value = "classifier">Classifier</option>
     209                            <option value = "source">Source</option>
     210                            <option value = "horizontal">Horizontal</option>
     211                </select></td><td><a href="#" class="minmax ui-icon ui-icon-minusthick">[-]</a></td><td><a href="#" class="remove ui-icon ui-icon-closethick">[x]</a></td></tr></tbody></table></div>
    200212        <div class="header element_type_gsf_switch css_gsf_switch" title="gsf:switch">SWITCH</div>
    201213        <div class="header element_type_gsf_when css_gsf_when" title="gsf:when">WHEN</div>
     
    213225    <!-- <xsl:variable name="tok" select="fn:tokenize($fmt,'/s+')"/> -->
    214226
    215     <!--  <div id="format">
     227    <div id="format">
    216228        <p>
    217229          <b>Format string here</b>
     
    220232          </i>
    221233        </p>
    222         <p>
     234    </div>
     235    <!--    <p>
    223236          <i>
    224237              <xsl:value-of select="$meta"/>
     
    226239        </p>
    227240      </div> -->
     241      </xsl:if>
    228242
    229243<!-- *************************************************************************************** -->
  • main/trunk/greenstone3/web/interfaces/oran/transform/layouts/xml-to-gui.xsl

    r23046 r23135  
    9090        <xsl:choose>
    9191            <xsl:when test="$current = $meta">
    92                 <option value ="{$meta}" selected="{$meta}"><xsl:value-of select="$meta"/></option>
     92                <xsl:text disable-output-escaping="yes">&lt;option value="</xsl:text><xsl:value-of select="$meta"/><xsl:text disable-output-escaping="yes">" selected&gt;</xsl:text><xsl:value-of select="$meta"/><xsl:text disable-output-escaping="yes">&lt;/option&gt;</xsl:text>
     93                <!-- <option value ="{$meta}" selected="selected"><xsl:value-of select="$meta"/></option> -->
    9394            </xsl:when>
    9495            <xsl:otherwise>
Note: See TracChangeset for help on using the changeset viewer.