Changeset 25142

Show
Ignore:
Timestamp:
23.02.2012 16:02:56 (8 years ago)
Author:
sjm84
Message:

Added the ability to edit the document directly on the page

Location:
main/trunk/greenstone3/web/interfaces/oran
Files:
7 modified

Legend:

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

    r25009 r25142  
    522522    flash_plug_html += '    <PARAM name="movie" value="Book.swf'; 
    523523    flash_plug_html += '?src_image=' + escape(img_cover); 
    524     flash_plug_html += '&doc_url=' + escape(doc_url) 
     524    flash_plug_html += '&doc_url=' + escape(doc_url); 
    525525    flash_plug_html += '" />\n'; 
    526526    flash_plug_html += '    <PARAM name="quality" value="high" />\n'; 
     
    540540    flash_div.innerHTML = flash_plug_html; 
    541541} 
     542 
     543function readyPageForEditing() 
     544{ 
     545    var textDivs = gs.functions.getElementsByClassName("sectionText"); 
     546     
     547    for(var i = 0; i < textDivs.length; i++) 
     548    { 
     549        de.doc.registerEditSection(textDivs[i]); 
     550    } 
     551     
     552    var editBar = document.getElementById("editBarLeft"); 
     553    var saveButton = document.createElement("BUTTON"); 
     554    saveButton.onclick = save; 
     555    saveButton.innerHTML = "Save changes"; 
     556    saveButton.setAttribute("id", "saveButton"); 
     557    editBar.appendChild(saveButton); 
     558     
     559    var statusBarDiv = document.createElement("DIV"); 
     560    editBar.appendChild(statusBarDiv); 
     561    _statusBar = new StatusBar(statusBarDiv); 
     562     
     563    _baseURL = gs.xsltParams.library_name; 
     564} 
  • main/trunk/greenstone3/web/interfaces/oran/js/documentmaker_scripts.js

    r25104 r25142  
    1111var _metadataSetList = new Array(); 
    1212 
    13 function init() 
    14 { 
    15     de.init(); 
     13function initDocumentMaker() 
     14{ 
    1615    //Get all of the links on the page 
    1716    var allLinks = document.getElementsByTagName("a"); 
     
    703702    } 
    704703} 
    705  
    706 YAHOO.util.Event.onDOMReady(init); 
  • main/trunk/greenstone3/web/interfaces/oran/js/documentmaker_scripts_util.js

    r25105 r25142  
    195195         
    196196        gs.functions.removeArchivesMetadata(gs.cgiParams.p_c /*bad*/, "localsite" /*bad*/, docID, name, null, value, function(){console.log("REMOVED ARCHIVES");}); 
    197         addCollectionToBuild(gs.cgiParams.p_c); 
     197        addCollectionToBuild(gs.cgiParams.p_c); /*bad*/ 
    198198         
    199199        removeFromParent(currentRow); 
     
    237237            saveTransaction('{"operation":"setText", "text":"' + changedElem.innerHTML.replace(/"/g, "\\\"").replace(/&/g, "%26") + '", "collection":"' + section.collection + '", "oid":"' + section.nodeID + '"}'); 
    238238            addCollectionToBuild(section.collection); 
     239        } 
     240        else if(hasClass(changedElem, "sectionText")) 
     241        { 
     242            var id = changedElem.getAttribute("id"); 
     243            var sectionID = id.substring(4); 
     244            saveTransaction('{"operation":"setText", "text":"' + changedElem.innerHTML.replace(/"/g, "\\\"").replace(/&/g, "%26") + '", "collection":"' + gs.cgiParams.c + '", "oid":"' + sectionID + '"}'); 
     245            addCollectionToBuild(gs.cgiParams.c); 
    239246        } 
    240247    } 
     
    285292        saveButton.innerHTML = "Saving..."; 
    286293        saveButton.disabled = true; 
    287          
     294 
    288295        statusID = _statusBar.addStatus("Modifying archive files..."); 
    289296        ajax.send("a=g&rt=r&s=DocumentExecuteTransaction&s1.transactions=" + request); 
  • main/trunk/greenstone3/web/interfaces/oran/js/javascript-global-functions.js

    r25105 r25142  
    2424    } 
    2525} 
     26 
     27gs.functions.getElementsByClassName = function(cl)  
     28{ 
     29    var nodes = new Array(); 
     30    var classRegEx = new RegExp('\\b'+cl+'\\b'); 
     31    var allElems = document.getElementsByTagName('*'); 
     32     
     33    for (var i = 0; i < allElems.length; i++)  
     34    { 
     35        var classes = allElems[i].className; 
     36        if (classRegEx.test(classes))  
     37        { 
     38            nodes.push(allElems[i]); 
     39        } 
     40    } 
     41    return nodes; 
     42};  
    2643 
    2744gs.functions.makeToggle = function(buttons, divs) 
  • main/trunk/greenstone3/web/interfaces/oran/transform/layouts/header.xsl

    r25123 r25142  
    2929        <xsl:choose> 
    3030            <xsl:when test="/page/pageResponse/interfaceOptions/option[@name = 'cssTheme']/@value"> 
     31                <!-- Get the theme from the interfaceConfig.xml file --> 
    3132                <link rel="stylesheet" href="{/page/pageResponse/interfaceOptions/option[@name = 'cssTheme']/@value}" type="text/css"/> 
    3233            </xsl:when> 
     
    4748            <xsl:call-template name="map-scripts"/> 
    4849        </xsl:if> 
    49         <xsl:call-template name="init-seaweed"/> 
     50         
     51        <xsl:call-template name="init-direct-edit"/> 
    5052        <xsl:call-template name="setup-gs-variable"/> 
    5153        <xsl:call-template name="additionalHeaderContent"/> 
     
    5658    </xsl:template> 
    5759     
    58     <xsl:template name="init-seaweed"> 
     60    <xsl:template name="init-direct-edit"> 
    5961        <script type="text/javascript"> 
    6062            <xsl:text disable-output-escaping="yes"> 
    61                 de.onready(function() { 
    62                     try { 
     63                de.onready(function()  
     64                { 
     65                    try  
     66                    { 
    6367                        de.init(); 
    6468                    } 
    65                     catch (err) { 
     69                    catch (err)  
     70                    { 
    6671                        alert("Seaweed failed to initialise: " + err.message); 
    6772                    } 
  • main/trunk/greenstone3/web/interfaces/oran/transform/pages/document.xsl

    r25106 r25142  
    127127    <!-- the page content --> 
    128128    <xsl:template match="/page/pageResponse/document"> 
     129        <xsl:if test="/page/pageRequest/paramList/param[@name = 'documentbasket']/@value = 'on'"> 
     130            <script type="text/javascript" src="interfaces/{$interface_name}/js/documentmaker_scripts.js"><xsl:text> </xsl:text></script> 
     131            <script type="text/javascript" src="interfaces/{$interface_name}/js/documentmaker_scripts_util.js"><xsl:text> </xsl:text></script> 
     132        </xsl:if> 
     133         
    129134        <xsl:if test="/page/pageRequest/paramList/param[@name = 'dmd']/@value = 'true'"> 
    130135            <gsf:metadata name="all"/> 
     
    151156             
    152157            <xsl:if test="/page/pageRequest/paramList/param[@name = 'documentbasket']/@value = 'on'"> 
    153                 <table style="width:100%"><tr><td style="width:70%"><xsl:text> </xsl:text></td> 
    154                     <td> 
     158                <table style="width:100%"><tr> 
     159                    <td id="editBarLeft" style="width:70%"><xsl:text> </xsl:text></td> 
     160                    <td id="editBarRight"> 
    155161                        <div style="text-align:center;"> 
    156                             <div class="ui-state-default ui-corner-all"> 
    157                                 <a style="padding: 3px; text-decoration:none;" href="{$library_name}?a=g&amp;sa=documentbasket&amp;c=&amp;s=DisplayDocumentList&amp;rt=r&amp;p.c={/page/pageResponse/collection/@name}&amp;docToEdit={/page/pageResponse/document/documentNode/@nodeID}">Edit this document</a> 
     162                            <div style="margin:5px;" class="ui-state-default ui-corner-all"> 
     163                                <a style="padding: 3px; text-decoration:none;" href="{$library_name}?a=g&amp;sa=documentbasket&amp;c=&amp;s=DisplayDocumentList&amp;rt=r&amp;p.c={/page/pageResponse/collection/@name}&amp;docToEdit={/page/pageResponse/document/documentNode/@nodeID}">Edit structure</a> 
     164                            </div> 
     165                            <div style="margin:5px;" class="ui-state-default ui-corner-all"> 
     166                                <a style="padding: 3px; text-decoration:none;" href="javascript:readyPageForEditing();">Edit content</a> 
    158167                            </div> 
    159168                        </div> 
  • main/trunk/greenstone3/web/interfaces/oran/transform/pages/documentbasket.xsl

    r24999 r25142  
    2121    <!-- the page content --> 
    2222    <xsl:template match="/page"> 
    23         <script src="interfaces/{$interface_name}/js/documentmaker_scripts.js"><xsl:text> </xsl:text></script> 
    24         <script src="interfaces/{$interface_name}/js/documentmaker_scripts_dd.js"><xsl:text> </xsl:text></script> 
    25         <script src="interfaces/{$interface_name}/js/documentmaker_scripts_util.js"><xsl:text> </xsl:text></script> 
     23        <script type="text/javascript" src="interfaces/{$interface_name}/js/documentmaker_scripts.js"><xsl:text> </xsl:text></script> 
     24        <script type="text/javascript" src="interfaces/{$interface_name}/js/documentmaker_scripts_dd.js"><xsl:text> </xsl:text></script> 
     25        <script type="text/javascript" src="interfaces/{$interface_name}/js/documentmaker_scripts_util.js"><xsl:text> </xsl:text></script> 
     26        <script type="text/javascript">YAHOO.util.Event.onDOMReady(initDocumentMaker);</script> 
     27 
    2628        <link src="interfaces/{$interface_name}/style/documentbasket.js"/> 
    2729        <xsl:for-each select="//item">