Changeset 32853


Ignore:
Timestamp:
2019-03-04T21:57:57+13:00 (5 years ago)
Author:
ak19
Message:

Cleanup stage one: 1. Not calling addFunctionalityToTable() on GPSmapcontainer, and no need for a cutdown addFunctionalityToGPSMap(), since the GPS map editor doesn't use any of the added functionality anyway, going out of its way to set the css to display:hide on all the added functionality (metaNameField, addRowButton and addAllButton). 2. Selecting divs that have attribute contenteditable='true' rather than all elements with .sectionText class to get a list of all the editable elements that will get converted to CKEditors. I think it's only divs that have contenteditable set to true, in which case don't need to look for any and all elements with that attribute and value. 3. Some cleanup.

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

Legend:

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

    r32852 r32853  
    233233    mapGPScontainer.css("display", "none");
    234234
    235     addFunctionalityToTable(mapGPScontainer); // **********************************
    236     mapGPScontainer.metaNameField.css("display", "none");
    237     mapGPScontainer.addRowButton.css("display", "none");
    238     if (enable_add_all_metadata_button == true) {
    239         mapGPScontainer.addAllButton.css("display", "none");
    240     }
    241 
    242235}
    243236
     
    290283function readyPageForEditing() {
    291284
    292     //   CKEDITOR.on('instanceReady', function(evt) {
    293     //  addCKEEditableState(evt,editableInitStates);
    294     //   });
    295 
    296285    if ($("#metadataSetList").length) {
    297286        var setList = $("#metadataSetList");
     
    307296    //wait for 0.5 sec to let ckeditor up
    308297   
    309     // The following is now done in the CKEDTIOR.on('instanceReady') handler, which is added when docReady, see documentedit_scripts_util::$( document ).ready(...)
    310     // Attempting CKEDTIOR.on('instanceReady') at the start of this method didn't work because it was probably too late in page load phase to add the event handler then
     298    // Initialising editableInitStates for CKEDITOR instances now happens in the CKEDITOR.on('instanceReady') handler, which is added upon docReady, see documentedit_scripts_util::$( document ).ready(...)
     299    // Attempting CKEDITOR.on('instanceReady') at the start of this method or anywhere in this method didn't work because it was probably too late in page load phase to add the event handler then
    311300    // (the instanceReady() event would have been triggered before this method finally got called).
    312     /*
    313     setTimeout(function () {
    314         $(".sectionText").each(function () {
    315             addEditableState(this, editableInitStates);
    316         });
    317     }, 500);
    318     */
     301
    319302    var editBar = $("#editBarLeft");
    320303
     
    380363    // We need to keep track of editableElementsInitialisationProgress: the number of editable elements that need to be initialised/need to finish initialising
    381364    // As CKEditors will be added, meaning more editable elements, must increment our counter editableElementsInitialisationProgress
    382     var $num_editable_textareas = $(".sectionText"); // consider searching for 'contenteditable="true"' as this is what CKEDITOR is looking for (we think!)
     365    //var $num_editable_textareas = $(".sectionText"); // consider searching for 'contenteditable="true"' as this is what CKEDITOR is looking for (we think!)       
     366    // I think for us it's always a <div> that has contenteditable="true", but to get all elements with attr contenteditable set to true,
     367    // see https://stackoverflow.com/questions/4958081/find-all-elements-with-a-certain-attribute-value-in-jquery
     368    // which has inefficient and slightly more efficient ways of doing that
     369    var $num_editable_textareas = $('div[contenteditable="true"]');
    383370    editableElementsInitialisationProgress += $num_editable_textareas.length;
    384371   
  • main/trunk/greenstone3/web/interfaces/default/js/documentedit_scripts_util.js

    r32852 r32853  
    945945}
    946946
    947 function addFunctionalityToMapGPS(mapGPScontainer)
    948 {
    949    
    950 }
    951 
    952947function addFunctionalityToTable(table)
    953948{
     
    10131008
    10141009    // add metadata field selector
    1015         var metaNameField = createMetadataElementSelector();   
     1010    var metaNameField = createMetadataElementSelector();   
    10161011    table.after(metaNameField);
    10171012    table.metaNameField = metaNameField;
Note: See TracChangeset for help on using the changeset viewer.