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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.