Ignore:
Timestamp:
2018-09-18T13:54:31+12:00 (6 years ago)
Author:
kjdon
Message:

moved some functions from documentedit_scripts to documentedit_scripts_util, as the util file was calling functions from main script. seemd the wrong way round and hard to find when you are debugging

Location:
main/trunk/greenstone3/web/interfaces/default/js
Files:
3 edited

Legend:

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

    r32307 r32471  
    22var default_link_type = "document"; // "source" or "document"
    33// use the appropriate one of these to override the default for particular collections.
    4 var source_link_collections = new Array(); // or add list of collections like ["pdfberry", "mgppdemo"];
     4var source_link_collections = ["pdfberry"]; //new Array(); // or add list of collections like ["pdfberry", "mgppdemo"];
    55var document_link_collections = new Array(); // or add list of collections as above.
    66//these are the default metadata items used by  berry baskets.
  • main/trunk/greenstone3/web/interfaces/default/js/documentedit_scripts.js

    r32439 r32471  
    328328
    329329
    330 /************************************
    331 *    TEXT EDIT (CKEDITOR) SCRIPTS    *
    332 **************************************/
    333 
    334 //  not using this anymore as the instanceready never seems to get called
    335 function addCKEEditableState(evt,stateArray)
    336 {
    337     // Event->Editor->CKE DOM Inline Element that editor was for->underlying jquery element
    338     element = evt.editor.element.$;
    339     nodeText = element.innerHTML;
    340          stateArray.push({
    341              editableNode : element,
    342              initHTML : nodeText
    343          });
    344 }
    345 
    346 function addEditableState(editable,stateArray)
    347 {
    348 
    349     if(editable.tagName == 'TEXTAREA')
    350     {
    351         nodeText = editable.value;
    352     }
    353     else
    354     {
    355         nodeText = editable.innerHTML;
    356     }
    357 
    358         stateArray.push({
    359                 editableNode : editable,
    360                 initHTML : nodeText
    361         });
    362 
    363 }
    364 
    365 function getLastEditableStates()
    366 {   
    367     editableLastStates = [];
    368         $(".sectionText").each(function(){addEditableState(this,editableLastStates);});
    369         $(".metaTableCellArea").each(function(){addEditableState(this,editableLastStates);});
    370 
    371 }
    372 
    373 function changesToUpdate()
    374 {
    375     var resultArray = new Array();
    376     getLastEditableStates();
    377     for (var j in editableLastStates)
    378     {   
    379         if (isNodeChanged(editableLastStates[j]))
    380         {
    381             resultArray.push(editableLastStates[j].editableNode);
    382         }
    383     }
    384     return resultArray;
    385 }
    386 
    387 
    388 function isNodeChanged(StateToCheck){
    389     for (var i in editableInitStates)
    390     {
    391         if ((StateToCheck.editableNode === editableInitStates[i].editableNode)) {
    392         if ( StateToCheck.initHTML === editableInitStates[i].initHTML )
    393         {
    394             return false;
    395         }
    396         return true;
    397         }
    398    
    399     }
    400     // if get here, this must be a new node, as wasn't in init states
    401     // make sure its not empty - we won't add empty nodes.
    402     if (StateToCheck.initHTML == "") {
    403     return false;
    404     }
    405 
    406     return true;
    407    
    408 }
    409 
     330
  • main/trunk/greenstone3/web/interfaces/default/js/documentedit_scripts_util.js

    r32440 r32471  
    253253    _transactions = null;   
    254254    location.reload(true); // force reload, not from cache, https://www.w3schools.com/jsref/met_loc_reload.asp
     255}
     256
     257/************************************
     258*    TEXT EDIT (CKEDITOR) SCRIPTS    *
     259**************************************/
     260
     261//  not using this anymore as the instanceready never seems to get called
     262function addCKEEditableState(evt,stateArray)
     263{
     264    // Event->Editor->CKE DOM Inline Element that editor was for->underlying jquery element
     265    element = evt.editor.element.$;
     266    nodeText = element.innerHTML;
     267         stateArray.push({
     268             editableNode : element,
     269             initHTML : nodeText
     270         });
     271}
     272
     273function addEditableState(editable,stateArray)
     274{
     275
     276    if(editable.tagName == 'TEXTAREA')
     277    {
     278        nodeText = editable.value;
     279    }
     280    else
     281    {
     282        nodeText = editable.innerHTML;
     283    }
     284
     285        stateArray.push({
     286                editableNode : editable,
     287                initHTML : nodeText
     288        });
     289
     290}
     291
     292function getLastEditableStates()
     293{   
     294    editableLastStates = [];
     295        $(".sectionText").each(function(){addEditableState(this,editableLastStates);});
     296        $(".metaTableCellArea").each(function(){addEditableState(this,editableLastStates);});
     297
     298}
     299
     300function changesToUpdate()
     301{
     302    var resultArray = new Array();
     303    getLastEditableStates();
     304    for (var j in editableLastStates)
     305    {   
     306        if (isNodeChanged(editableLastStates[j]))
     307        {
     308            resultArray.push(editableLastStates[j].editableNode);
     309        }
     310    }
     311    return resultArray;
     312}
     313
     314
     315function isNodeChanged(StateToCheck){
     316    for (var i in editableInitStates)
     317    {
     318        if ((StateToCheck.editableNode === editableInitStates[i].editableNode)) {
     319        if ( StateToCheck.initHTML === editableInitStates[i].initHTML )
     320        {
     321            return false;
     322        }
     323            //console.log("current="+StateToCheck.initHTML);
     324            //console.log("init="+editableInitStates[i].initHTML);
     325        return true;
     326        }
     327   
     328    }
     329    // if get here, this must be a new node, as wasn't in init states
     330    // make sure its not empty - we won't add empty nodes.
     331    if (StateToCheck.initHTML == "") {
     332    return false;
     333    }
     334
     335    return true;
     336   
    255337}
    256338
Note: See TracChangeset for help on using the changeset viewer.