Ignore:
Timestamp:
2011-06-27T11:07:20+12:00 (13 years ago)
Author:
sjb48
Message:

Working on document-level format editting

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

Legend:

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

    r24136 r24202  
    22console.log("Loading gui_div.js\n");
    33
    4 // var initialised_iframe = "false";
     4/* DOCUMENT SPECIFIC FUNCTIONS */
     5
     6function displayTOC(checkbox)
     7{
     8    if (checkbox.checked == true)
     9    {
     10        console.log("Show the TOC!");
     11        displaySideBar(true);
     12        $("#tableOfContents").css("display", "block");
     13    }
     14    else
     15    {
     16        console.log("Hide the TOC!");
     17        $("#tableOfContents").css("display", "none");
     18        if ($("#coverImage").css("display") == "none")
     19            displaySideBar(false);
     20    }
     21
     22    return;
     23}
     24
     25function displayBookCover(checkbox)
     26{
     27    if (checkbox.checked == true)
     28    {
     29        console.log("Show the book cover!");
     30        displaySideBar(true);
     31        $("#coverImage").css("display", "block");
     32    }
     33    else
     34    {
     35        console.log("Hide the book cover!");
     36        $("#coverImage").css("display", "none");
     37        if ($("#tableOfContents").css("display") == "none")
     38            displaySideBar(false);
     39    }
     40
     41    return;
     42}
     43
     44function displaySideBar(toggle)
     45{
     46    if (toggle == true)
     47    {
     48        console.log("Show the sidebar!");
     49        $("#rightSidebar").css("display", "block");
     50    }
     51    else
     52    {
     53        console.log("Hide the sidebar!");
     54        $("#rightSidebar").css("display", "none");
     55    }
     56
     57    return;
     58}
     59
     60
     61function checkDocumentRadio()
     62{
     63    var selection = $('input[name="documentChanges"]'); //document.quiz.colour;
     64
     65    for (i=0; i<selection.length; i++)
     66
     67        if (selection[i].checked == true)
     68            return selection[i].value;
     69
     70    return "this";
     71}
     72
     73function saveDocumentChanges()
     74{
     75    console.log("Saving changes to "+checkDocumentRadio());
     76}
     77
     78
     79
     80/* FUNCTIONS FOR FORMAT EDITING */                                                                   
    581
    682function onTextChange(item, text)
     
    2399    //item.setAttribute("selected","selected");
    24100}
    25 
    26101
    27102//function createFormatStatement()
     
    84159}
    85160
     161function checkClassifierRadio()
     162{
     163    var selection = $('input[name="classifiers"]'); //document.quiz.colour;
     164
     165    for (i=0; i<selection.length; i++)
     166
     167          if (selection[i].checked == true)
     168              return selection[i].value;
     169
     170    return "this";
     171
     172}
     173
    86174function updateFormatStatement()
    87175{
    88176    var formatStatement = getFormatStatement();
     177
     178    var thisOrAll = checkClassifierRadio();
     179    console.log(thisOrAll);
     180    var myurl = document.URL;
     181
     182    var collection_name = getSubstring(myurl, "&c", "&");
     183    var service_name = getSubstring(myurl, "&s", "&"); 
     184
     185    if(thisOrAll == "all")
     186        service_name = "AllClassifierBrowse";
     187
     188    var classifier_name = null;
     189
     190    if(service_name == "ClassifierBrowse")
     191        classifier_name = getSubstring(myurl, "&cl", "&");
     192
     193    var post_url = "http://localhost:8989/greenstone3/format?a=f&sa=update&c=" + collection_name +"&s=" + service_name;
     194
     195    if(classifier_name != null)
     196        post_url = post_url + "&cl=" + classifier_name;
     197
     198    $.post(post_url, {data: formatStatement}, function(data) {
     199        //$('.result').innerHTML = data; //html(data);
     200   
     201        // An error is returned because there is no valid XSLT for a format update action, there probably shouldn't be one so we ignore what the post returns.   
     202        console.log("Successfully updated");
     203        //console.log(data);
     204        }, 'html');
     205}
     206
     207function saveFormatStatement()
     208{
     209    var formatStatement = getFormatStatement();
     210    var thisOrAll = checkClassifierRadio();
    89211
    90212    var myurl = document.URL;
     
    94216    var classifier_name = null;
    95217
     218    if(thisOrAll == "all")
     219        service_name = "AllClassifierBrowse";
     220
    96221    if(service_name == "ClassifierBrowse")
    97222        classifier_name = getSubstring(myurl, "&cl", "&");
    98223
    99     var post_url = "http://localhost:8989/greenstone3/format?a=f&sa=update&c=" + collection_name +"&s=" + service_name;
     224    var post_url = "http://localhost:8989/greenstone3/format?a=f&sa=save&c=" + collection_name +"&s=" + service_name;
    100225
    101226    if(classifier_name != null)
     
    104229    $.post(post_url, {data: formatStatement}, function(data) {
    105230        //$('.result').innerHTML = data; //html(data);
    106         console.log("Success, we have received data");
    107         console.log(data);
     231       
     232        // An error is returned because there is no valid XSLT for a format update action, there probably shouldn't be one so we ignore what the post returns.   
     233        console.log("Successfully saved");
     234        //console.log(data);
    108235        }, 'html');
    109236}
    110237
    111 function saveFormatStatement()
    112 {
    113     var formatStatement = getFormatStatement();
    114 
     238function getXSLT(classname)
     239{
    115240    var myurl = document.URL;
    116241
    117242    var collection_name = getSubstring(myurl, "&c", "&");
    118     var service_name = getSubstring(myurl, "&s", "&");
    119     var classifier_name = null;
    120 
    121     if(service_name == "ClassifierBrowse")
    122         classifier_name = getSubstring(myurl, "&cl", "&");
    123 
    124     var post_url = "http://localhost:8989/greenstone3/format?a=f&sa=save&c=" + collection_name +"&s=" + service_name;
    125 
    126     if(classifier_name != null)
    127         post_url = post_url + "&cl=" + classifier_name;
    128 
    129     $.post(post_url, {data: formatStatement}, function(data) {
    130         //$('.result').innerHTML = data; //html(data);
    131         console.log("Success, we have received data");
    132         console.log(data);
    133         }, 'html');
     243    var document_id = getSubstring(myurl, "&d", "&");
     244    var document_type = getSubstring(myurl, "&dt", "&");
     245    var prev_action = getSubstring(myurl, "&p.a", "&");
     246    var prev_service = getSubstring(myurl, "&p.s", "&");
     247    //var classifier_name = null;
     248
     249    //if(service_name == "ClassifierBrowse")
     250    //    classifier_name = getSubstring(myurl, "&cl", "&");
     251
     252
     253    //var post_url = "http://localhost:8989/greenstone3/format?a=f&sa=getXSLT&c=" + collection_name +"&s=" + service_name+"&d=" + document_id + "&o=skinandlib";
     254    var post_url = "http://localhost:8989/greenstone3/format?a=d&c=" + collection_name + "&d=" + document_id + "&dt=" + document_type + "&p.a=" + prev_action + "&p.s=" + prev_service + "&o=skinandlib";
     255
     256    //if(classifier_name != null)
     257    //    post_url = post_url + "&cl=" + classifier_name;
     258
     259    $.post(post_url, {data: classname}, function(data) {
     260            //$('.result').innerHTML = data; //html(data);
     261            console.log("Success, we have received data");
     262            //console.log(data);
     263            classname = "." + classname;
     264            console.log(classname); //data.getElementsByTagName("div"));
     265            var content = $( data ).find(classname);
     266            console.log(content.xml());
     267            $("#XSLTcode").val(content.xml());
     268            }, 'xml');
    134269}
    135270
     
    344479    var CURRENT_SELECT_VALUE = "";
    345480
     481    /* DOCUMENT SPECIFIC FUNCTIONS */
     482
     483    $('.sectionHeader').click(function () {
     484        console.log('section Header click *');
     485        getXSLT("sectionHeader");
     486        return false; //don't event bubble
     487    });
     488
     489    $('.sectionContainer').click(function () {
     490        console.log('section Container click *');
     491        getXSLT("sectionContainer");
     492        return false; // don't event bubble
     493    });
     494
    346495    /*
    347496    var iframe = document.getElementById('iframe');
     
    567716    //$('.tr').resize_tables($(this)); //equalHeights();
    568717
     718    $('#sectionHeader').click(function () {
     719         console.log('section Header click *');
     720         return true;
     721    });
    569722   
    570     $('td').click(function () {
    571          console.log('td click *');
    572          return false;
     723    $('#sectionContainer').click(function () {
     724         console.log('section Container click *');
     725         return true;
    573726    });
    574727
  • main/trunk/greenstone3/web/interfaces/oran/transform/layouts/formatmanager.xsl

    r24139 r24202  
    1919        <!-- Sam2's div code -->
    2020
     21        <script type="text/javascript" src="interfaces/oran/js/jquery-1.4.2.js"><xsl:text> </xsl:text></script>
     22        <script type="text/javascript" src="interfaces/oran/js/jquery-ui-1.8rc1/ui/jquery-ui.js"><xsl:text> </xsl:text></script>
     23        <script type="text/javascript" src="interfaces/oran/js/jquery.selectboxes.js"><xsl:text> </xsl:text></script>
    2124        <script type="text/javascript" src="interfaces/oran/js/innerxhtml.js"><xsl:text> </xsl:text></script>
     25        <script type="text/javascript" src="interfaces/oran/js/jquery.xml.js"><xsl:text> </xsl:text></script>
    2226        <script type="text/javascript" src="interfaces/oran/js/gui_div.js"><xsl:text> </xsl:text></script>
    2327       
     
    5357            .droppable_hl { border: dashed 1px #ccc; background-color:#FFFFCC; }
    5458
     59            #XSLTcode {width: 99%; }
     60
    5561            .elementToolBox {position: fixed; top: 25%; right: 0px; background: none repeat scroll 0% 0% white; width: 250px; }
    5662
     
    6268        <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css"/>
    6369
     70
     71
    6472        <table width="100%" border="1">
    6573
    66         <td width="75%">
    67 
    68         <button id="updateFormatStatement" type="button" onclick="updateFormatStatement()">Update Format Statement</button>
    69         <button id="saveFormatStatement" type="button" onclick="saveFormatStatement()">Save Format Statement</button>
    70 
    71         <div id="formatStatement">
    72             <div id="formatRoot">
    73        
    74         <xsl:call-template name="xml-to-gui">
    75             <xsl:with-param name="node-set" select="//format"/> <!-- [@type='browse']"/>  -->
    76             <xsl:with-param name="metadataSets" select="//metadataSetList"/>
    77         </xsl:call-template>
    78             </div>
    79         </div>
    80         </td>   
    81 
    82 
    83         <td class="elementToolBox">
     74            <td width="100%">
     75                <xsl:choose>
     76                    <xsl:when test="/page/pageRequest/@action = 'd'">
     77                        <!-- TOC on or off -->
     78                        <xsl:choose>
     79                            <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[(@name='TOC') and (@value='true')]">
     80                                <input type="checkbox" name="TOC" checked="checked" onclick="displayTOC(this)">Display Table of Contents (set to true)</input>
     81                            </xsl:when>
     82                            <xsl:otherwise>
     83                                <input type="checkbox" name="TOC" onclick="displayTOC(this)">Display Table of Contents (set to false)</input>
     84                            </xsl:otherwise>
     85                        </xsl:choose> <br/>
     86
     87                        <!-- book cover image on or off -->
     88                        <xsl:choose>
     89                            <xsl:when test="/page/pageResponse/format[@type='display']/gsf:option[(@name='coverImage') and (@value='true')]">
     90                                <input type="checkbox" name="bookCover" checked="checked" onclick="displayBookCover(this)">Display Book Cover Image (set to true)</input>
     91                            </xsl:when>
     92                            <xsl:otherwise>
     93                                <input type="checkbox" name="bookCover" onclick="displayBookCover(this)">Display Book Cover Image (set to false)</input>
     94                            </xsl:otherwise>
     95                        </xsl:choose> <br/>
     96
     97                        <textarea id="XSLTcode" rows="5">
     98                        The XSLT code for the relevant part of the page will be displayed here.
     99                        </textarea>
     100                        <!-- What are we doing?  It might be possible to tweak saveFormatStatement() if we are only dealing with format stuff but are we? -->
     101                        <br/>
     102                        <table>
     103                            <td>
     104                                <button id="saveDocumentChanges" type="button" onclick="saveDocumentChanges()">Save Changes</button>
     105                            </td>
     106                            <td>
     107                                <form>
     108                                    <input name="documentChanges" type="radio" id="applyToDocument" value="document" checked="true"/>Apply to this document only
     109                                    <input name="documentChanges" type="radio" id="applyToCollection" value="collection" />Apply to collection
     110                                </form>
     111                            </td>
     112                        </table>
     113                    </xsl:when>
     114                    <xsl:otherwise>
     115                        <table>
     116                            <td>
     117                                <button id="updateFormatStatement" type="button" onclick="updateFormatStatement()">Update Format Statement</button>
     118                            </td>
     119                            <td>
     120                                <button id="saveFormatStatement" type="button" onclick="saveFormatStatement()">Save Format Statement</button>
     121                            </td>
     122                            <td>
     123                                <form>
     124                                    <input name="classifiers" type="radio" id="applyToThis" value="this" checked="true"/>This Classifier
     125                                    <input name="classifiers" type="radio" id="applyToAll" value="all" />All Classifiers
     126                                </form>
     127                            </td>
     128                        </table>
     129
     130                        <div id="formatStatement">
     131                            <div id="formatRoot">
     132                                <xsl:call-template name="xml-to-gui">
     133                                    <xsl:with-param name="node-set" select="//format"/> <!-- [@type='browse']"/>  -->
     134                                    <xsl:with-param name="metadataSets" select="//metadataSetList"/>
     135                                </xsl:call-template>
     136                            </div>
     137                        </div>
     138                    </xsl:otherwise>
     139                </xsl:choose>
     140            </td>   
     141        </table>
     142
     143        <div class="elementToolBox">
    84144            <h2> Elements to add </h2>
    85145            <!-- <div class="header element_type_gsf_template css_gsf_template" title="gsf:template">TEMPLATE</div> -->
     
    212272                <div class="draggable_td css_td" title="gsf:column">NEW TABLE COLUMN</div>
    213273
    214             </td>
    215         </table>
     274         </div>
    216275
    217276        <!--
  • main/trunk/greenstone3/web/interfaces/oran/transform/pages/classifier.xsl

    r24115 r24202  
    4848    TEMPLATE FOR DOCUMENTS
    4949    -->
    50     <xsl:template match="documentNode">
     50
     51    <!--<xsl:template match="documentNode" priority="3">-->
     52        <!-- show the document details -->
     53        <!--<li class="document">
     54            <a>
     55                <xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;c=<xsl:value-of select="/page/pageResponse/collection/@name"/>&amp;d=<xsl:value-of select="@nodeID"/>&amp;dt=<xsl:value-of select="@docType"/>&amp;p.a=b&amp;p.s=<xsl:value-of select="/page/pageResponse/service/@name"/>&amp;ed=1</xsl:attribute><xsl:value-of disable-output-escaping="yes"  select="metadataList/metadata[@name='Title']"/>
     56            </a>
     57        </li>
     58    </xsl:template>-->
     59
     60    <xsl:template match="documentNode" priority="3">
    5161        <!-- The book icon -->
    5262        <td>
     
    6878            <xsl:call-template name="documentBerryForClassifierOrSearchPage"/>
    6979        </td>
    70     </xsl:template>
     80    </xsl:template>-->
    7181
    7282
  • main/trunk/greenstone3/web/interfaces/oran/transform/pages/document.xsl

    r24115 r24202  
    9090
    9191                        <!-- the book's cover image -->
    92                         <div id="coverImage"><gslib:coverImage/></div>
    93 
    94                         <!-- the contents -->
    95                         <div id="tableOfContents">
    96                             <xsl:apply-templates select="documentNode" mode="TOC"/>
    97                         </div>
     92                        <!-- COULD BE WORTH SETTING THE STYLE TO DISPLAY:BLOCK OR DISPLAY:NONE BASED ON WHETHER FLAG IS TRUE OR FALSE -->
     93                        <!-- OTHERWISE, IF FLAG IS FALSE AND WE WANT TO TURN BOOK COVER ON, NEED TO REQUEST THE NEW PAGE WITH FLAG SET -->
     94                        <xsl:if test="/page/pageResponse/format[@type='display']/gsf:option[@name='coverImage']/@value='true'">
     95                            <div id="coverImage"><gslib:coverImage/></div>
     96                        </xsl:if>
     97
     98                        <!-- the contents (if enabled) -->
     99                        <!-- VALUE=<xsl:value-of select="/page/pageResponse/format[@type='display']/gsf:option[@name='TOC']/@value"/> -->
     100                        <xsl:if test="/page/pageResponse/format[@type='display']/gsf:option[@name='TOC']/@value='true'">
     101                            <div id="tableOfContents">
     102                                <xsl:apply-templates select="documentNode" mode="TOC"/>
     103                            </div>
     104                        </xsl:if>
    98105                    </div>
    99106                </td></tr>
     
    142149        <a name="{@nodeID}"><xsl:text> </xsl:text></a>
    143150        <!-- Section header -->
    144         <table><tr>
     151        <table class="sectionHeader"><tr>
    145152            <!-- Expand/collapse button -->
    146153            <td class="headerTD">
     
    163170                        </span>
    164171                    </xsl:if>
    165                     <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/>
     172                    <!-- Display the title for the section regardless of whether automatic section numbering is turned on -->
     173                    <span class="sectionTitle"><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/></span>
    166174                </p>
    167175            </td>
  • main/trunk/greenstone3/web/interfaces/oran/transform/pages/pref.xsl

    r24009 r24202  
    146146                    <br class="clear"/>
    147147
     148                    <!-- format editing -->
     149                    <div id="formateditprefs">
     150                        <xsl:variable name="formatedit"><xsl:choose><xsl:when test="/page/pageRequest/paramList/param[@name='formatedit']"><xsl:value-of select="/page/pageRequest/paramList/param[@name='formatedit']/@value"/></xsl:when><xsl:otherwise>off</xsl:otherwise></xsl:choose></xsl:variable>
     151                        <div class="paramLabel">
     152                            <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.formatedit')"/>
     153                        </div>
     154                        <div class="paramValue">
     155                            <select name="formatedit">
     156                                <option value="on"><xsl:if test="$formatedit='on'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.formatedit.on')"/></option>
     157                                <option value="off"><xsl:if test="$formatedit='off'"><xsl:attribute name="selected"></xsl:attribute></xsl:if><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'pref.formatedit.off')"/></option>
     158                            </select>
     159                        </div>
     160                        <br class="clear"/>
     161                    </div>
    148162                </div>
    149163
Note: See TracChangeset for help on using the changeset viewer.