Changeset 30464

Show
Ignore:
Timestamp:
04.04.2016 10:07:34 (4 years ago)
Author:
litvinovg
Message:

Fixed webeditor hierarchy suggestions menu.

Files:
1 modified

Legend:

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

    r30382 r30464  
    231231     
    232232    var input = $(row.getElementsByClassName("metaTableCellArea")[0]).val(); 
    233     //RegExp to get SuggestionsMenu with dot 
    234     var SuggestionsMenuExp = new RegExp("^" + input.replace(/\./g, '\\.') + "[0-9]+$"); 
    235     //RegExp to get SuggestionsMenu without dot 
    236     var ChildrenExp = new RegExp("^" + input.replace(/\./g, '\\.') + "\\.[0-9]+$") 
     233     
     234    //RegExp to get SuggestionsMenu 
     235    var SuggestionsMenuExp = new RegExp("^0*" + input.replace(/\./g, '\\.0*') + "\\.?[0-9]+$") 
    237236    //Hierarchy suggestions menu 
    238237    var SuggestionsMenu = ""; 
    239     //Item number for SuggestionsMenu                        
    240     var i = 1; 
    241238    for(var key in hierarchyData) 
    242239    { 
    243240    var SuggestionsMenuItems = {}; 
    244     // Test if input ends with dot and key relates to appropriate input 
    245         if (SuggestionsMenuExp.test(key) && /\.$/.test(input))  
     241         
     242        if (SuggestionsMenuExp.test(key))  
    246243        { 
    247              
    248             SuggestionsMenuItems[key]='<li class="hierarchySuggestionsMenu" id="'+key+'" ><button onclick="setHierarchyId(this)" >' + i + " "  + hierarchyData[key] + '</button></li>'; 
    249             i++;                         
    250         } 
    251          
    252         if (ChildrenExp.test(key))  
    253         { 
    254              
    255             SuggestionsMenuItems[key]='<li class="hierarchySuggestionsMenu" id="'+key+'" ><button onclick="setHierarchyId(this)" >.' + i + " "  + hierarchyData[key] + '</button></li>'; 
    256             i++;                         
     244            SuggestionsMenuItems[key]='<li class="hierarchySuggestionsMenu" id="'+key+'" ><button onclick="setHierarchyId(this)" >' + key.substring(String(input).length) + " "  + hierarchyData[key] + '</button></li>'; 
    257245        } 
    258246