Ignore:
Timestamp:
2016-04-20T22:56:11+12:00 (8 years ago)
Author:
davidb
Message:

Changes in the XSL and JS code to support the new approach taken to client-side XSLT (using Saxon-CE JS library in the browser). Also the reintroduction of the DirectEdit (Seaweed) template. Not on by default but a simple matter to call the re-instated template for projects that would like to make use of it, such as the digital music stand DL collection. Some white-space changes also occured. This was not deliberate, but would have been quite fiddly to tease out from other changes in the file, so consequently left in.

File:
1 edited

Legend:

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

    r30169 r30478  
    408408}
    409409
     410function retrieveFullTableOfContentsSuccess(newTOCElem)
     411{
     412    var tocStart = newTOCElem.indexOf(">") + 1;
     413    var tocEnd = newTOCElem.lastIndexOf("<");
     414   
     415    var newTOC = newTOCElem.substring(tocStart, tocEnd);
     416   
     417    //Add the "Expand document"/"Collapse document" links
     418    newTOC = "<table style=\"width:100%; text-align:center;\"><tr><td><a href=\"javascript:expandOrCollapseAll(true);\">Expand document</a></td><td><a href=\"javascript:expandOrCollapseAll(false);\">Collapse document</a></td></tr></table>" + newTOC;
     419   
     420    //Collapse the TOC
     421    newTOC = newTOC.replace(/display:block/g, "display:none");
     422    newTOC = newTOC.replace(/display:none/, "display:block");
     423    newTOC = newTOC.replace(/images\/collapse/g, "images/expand");
     424   
     425    var tocElem = $("#tableOfContents");
     426    tocElem.html(newTOC);
     427   
     428    gs.variables.tocLoaded = true;
     429}
     430
     431function retrieveFullTableOfContentsSuccessClientSideXSLT(newTOCElem)
     432{
     433    $('#client-side-xslt-ajax').remove();
     434    retrieveFullTableOfContentsSuccess(newTOCElem)
     435}
     436
    410437function retrieveFullTableOfContents()
    411438{
     
    419446        url += "&a=d&d=&alb=1&rl=1&href=" + gs.cgiParams.href;
    420447    }
    421 
     448   
     449    if (gs.xsltParams.use_client_side_xslt == "true") { // note xsltParams are of type string, so test needs to be in quotes
     450    url += "&callback=retrieveFullTableOfContentsSuccessClientSideXSLT"; // used in client-side-xslt.js, in combination with 'excerptid'
     451        $('<iframe src="'+url+'" id="client-side-xslt-ajax" tabindex="-1" style="position: absolute; width: 0px; height: 0px; border: none;"></iframe>').appendTo('body');
     452    }
     453    else { 
    422454    $.ajax(url)
    423     .success(function(newTOCElem)
    424     {
    425         var tocStart = newTOCElem.indexOf(">") + 1;
    426         var tocEnd = newTOCElem.lastIndexOf("<");
    427        
    428         var newTOC = newTOCElem.substring(tocStart, tocEnd);
    429        
    430         //Add the "Expand document"/"Collapse document" links
    431         newTOC = "<table style=\"width:100%; text-align:center;\"><tr><td><a href=\"javascript:expandOrCollapseAll(true);\">Expand document</a></td><td><a href=\"javascript:expandOrCollapseAll(false);\">Collapse document</a></td></tr></table>" + newTOC;
    432        
    433         //Collapse the TOC
    434         newTOC = newTOC.replace(/display:block/g, "display:none");
    435         newTOC = newTOC.replace(/display:none/, "display:block");
    436         newTOC = newTOC.replace(/images\/collapse/g, "images/expand");
    437        
    438         var tocElem = $("#tableOfContents");
    439         tocElem.html(newTOC);
    440        
    441         gs.variables.tocLoaded = true;
    442     })
    443     .error(function()
    444     {
     455        .success(retrieveFullTableOfContentsSuccess)
     456        .error(function() {
    445457        setTimeout(retrieveFullTableOfContents, 1000);
    446     });
     458        });
     459    }
    447460}
    448461
Note: See TracChangeset for help on using the changeset viewer.