Changeset 29214


Ignore:
Timestamp:
08/18/14 14:13:26 (7 years ago)
Author:
kjdon
Message:

style the remove link separately; metadata element input cna now be a select element, or an input element, which can optionally have autocomplete data. based on availableMetadataElements var, and new_metadata_field_input_type var. addMetaSetToList function changed name to addOptionTolist, as it can be used for adding any options. Added new param so can have different value and display text for the options.

File:
1 edited

Legend:

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

    r29174 r29214  
    633633    var selectedOption = options[index];
    634634   
    635     var selectedSet = selectedOption.innerHTML;
     635    var selectedSet = selectedOption.value;
    636636    changeVisibleMetadata(selectedSet);
    637637}
     
    686686}
    687687
    688 function addMetaSetToList(list, set, selected) {
     688function addOptionToList(list, optionvalue, optiontext, selected) {
    689689  var newOption = $("<option>");
    690   newOption.html(set);
     690  if (optiontext) {
     691    newOption.html(optiontext);
     692    newOption.attr("value", optionvalue);
     693  } else {
     694    newOption.html(optionvalue);
     695  }
    691696  if (selected) {
    692697    newOption.attr("selected", true);
     
    695700}
    696701
     702/* returns either an input or a select element. Data based on
     703   availableMetadataElements var. */
     704function createMetadataElementSelector() {
     705  var metaNameField;
     706  if (new_metadata_field_input_type == "fixedlist") {
     707    metaNameField =  $("<select>", {"class": "ui-state-default"});
     708    for(var i=0; i<availableMetadataElements.length; i++) {
     709      addOptionToList(metaNameField, availableMetadataElements[i]);
     710    }
     711    return metaNameField;
     712  }
     713  metaNameField = $("<input>", {"type": "text","style":"margin: 5px; border: 1px solid #000;"});
     714  if (new_metadata_field_input_type == "autocomplete") {
     715    metaNameField.autocomplete({
     716    minLength: 0,
     717      source: availableMetadataElements
     718      });
     719    metaNameField.attr("title", "Enter a metadata name, or use the down arrow to select one, then click 'Add New Metadata'");
     720  } else {
     721metaNameField.attr("title", "Enter a metadata name, then click 'Add New Metadata'");
     722  }
     723 
     724  return metaNameField;
     725}
     726
     727
     728
    697729function addFunctionalityToTable(table)
    698730{
     
    702734        var metadataName = $(cells[0]).html();
    703735       
    704         if(dynamic_metadata_list == true && metadataName.indexOf(".") != -1)
     736        if(dynamic_metadata_set_list == true && metadataName.indexOf(".") != -1)
    705737        {
    706738            var metadataSetName = metadataName.substring(0, metadataName.lastIndexOf("."));
     
    719751            {
    720752                _metadataSetList.push(metadataSetName);
    721                 addMetaSetToList( $("#metadataSetList"), metadataSetName);
     753                addOptionToList( $("#metadataSetList"), metadataSetName);
    722754            }
    723755        }
     
    727759    });
    728760
    729    
    730     var metaNameField = $("<input>", {"type": "text","style":"margin: 5px; border: 1px solid #000;"});
     761    var metaNameField = createMetadataElementSelector();   
    731762    table.after(metaNameField);
    732763    table.metaNameField = metaNameField;
     
    736767    addRowButton.click(function()
    737768    {
    738         var name = metaNameField.val();
     769            var name = metaNameField.val();
    739770        if(!name || name == "")
    740771        {
     
    764795    table.addRowButton = addRowButton;
    765796    metaNameField.after(addRowButton);
     797
    766798}
    767799
     
    783815    });
    784816    newCell.append(removeLink);
    785     newCell.attr({"class": "metaTableCell", "style": "font-size:0.6em; padding-left: 3px; padding-right: 3px;"});
     817    newCell.attr({"class": "metaTableCellRemove", "style": "font-size:0.6em; padding-left: 3px; padding-right: 3px;"});
    786818    $(row).append(newCell);
    787819}
Note: See TracChangeset for help on using the changeset viewer.