Changeset 7001


Ignore:
Timestamp:
Nov 5, 2015, 1:39:34 PM (6 years ago)
Author:
Nicklas Nordborg
Message:

References #1963: Improve list handling callback javascript code

Added Items.onItemSelected callback handler that can be attached to 'base-selected' event. The handler will insert or update the list it is attached with the item information sent in the event. If the new information is different from the currently selected a 'change' event is firef.

Most old event handlers should now be replaced with the new handler.

Location:
trunk
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/taglib/Select.java

    r6999 r7001  
    598598    sb.append("<div class=\"interactable ").append(getButtonclass()).append(disabled ? " disabled": "").append("\"");
    599599    sb.append(" id=\"").append(getId()).append(".select\"");
    600     sb.append(" data-list-name=\"").append(getId()).append("\"");
     600    sb.append(" data-list-name=\"").append(getId()).append(".list\"");
    601601    if (!disabled)
    602602    {
  • trunk/www/admin/itemsubtypes/subtypes.js

    r7000 r7001  
    5454      {
    5555        Buttons.addClickHandler('related.'+itemTypes[i]+'.select', subTypes.relatedItemOnClick)
    56         Events.addEventHandler('related.'+itemTypes[i], 'base-selected', subTypes.relatedItemSelected);
     56        Events.addEventHandler('related.'+itemTypes[i], 'base-selected', Items.onItemSelected);
    5757      }
    5858      subTypes.itemTypeOnChange();
     
    187187
    188188  /**
    189     Callback function for setting the selected related subtype.
    190   */
    191   subTypes.relatedItemSelected = function(event)
    192   {
    193     var frm = document.forms['subtype'];
    194     var list = frm[event.currentTarget.id];
    195     if (list.length < 2 || list[1].value == 'NaN')
    196     {
    197       Forms.addListOption(list, 1, new Option());
    198     }
    199     list[1].value = event.detail.id;
    200     list[1].text = event.detail.name;
    201     list.selectedIndex = 1;
    202   }
    203 
    204   /**
    205189    Open a popup dialog for selecting related file types.
    206190  */
  • trunk/www/admin/pluginconfigurations/configurations.js

    r7000 r7001  
    4949      // Select plugin
    5050      Buttons.addClickHandler('plugindefinition_id.select', configurations.selectPluginOnClick);
    51       Events.addEventHandler('plugindefinition_id', 'base-selected', configurations.setPluginCallback);
     51      Events.addEventHandler('plugindefinition_id', 'base-selected', Items.onItemSelected);
    5252    }
    5353    else if (pageId == 'view-page')
     
    190190  }
    191191 
    192   configurations.setPluginCallback = function(event)
    193   {
    194     var id = event.detail.id;
    195     var name = event.detail.name;
    196     var frm = document.forms['configuration'];
    197     var list = frm.plugindefinition_id;
    198     if (list.length < 1 || list[0].value == 'NaN')
    199     {
    200       Forms.addListOption(list, 0, new Option());
    201     }
    202     list[0].value = id;
    203     list[0].text = name;
    204     list.selectedIndex = 0;
    205   }
    206 
    207192 
    208193  return configurations;
  • trunk/www/admin/protocols/protocols.js

    r7000 r7001  
    4848      // Select file
    4949      Buttons.addClickHandler('file_id.select', protocols.selectFile);
    50       Events.addEventHandler('file_id', 'base-selected', protocols.setFileCallback);
     50      Events.addEventHandler('file_id', 'base-selected', Items.onItemSelected);
    5151
    5252      // Subtype
     
    157157  }
    158158 
    159   /**
    160     Callback for selecting a file.
    161   */
    162   protocols.setFileCallback = function(event)
    163   {
    164     var id = event.detail.id;
    165     var name = event.detail.name;
    166     var frm = document.forms['protocol'];
    167     var list = frm.file_id;
    168     if (list.length < 2 || list[1].value == 'NaN')
    169     {
    170       Forms.addListOption(list, 1, new Option());
    171     }
    172     list[1].value = id;
    173     list[1].text = name;
    174     list.selectedIndex = 1;
    175   }
    176 
    177159 
    178160  protocols.subtypeOnChange = function()
  • trunk/www/biomaterials/bioplates/events/events.js

    r7000 r7001  
    4343      // Hardware
    4444      Buttons.addClickHandler('hardware_id.select', plateevents.selectHardware);
    45       Events.addEventHandler('hardware_id', 'base-selected', plateevents.setHardwareCallback);
     45      Events.addEventHandler('hardware_id', 'base-selected', Items.onItemSelected);
    4646
    4747      // Protocol
    4848      Buttons.addClickHandler('protocol_id.select', plateevents.selectProtocol);
    49       Events.addEventHandler('protocol_id', 'base-selected', plateevents.setProtocolCallback);
     49      Events.addEventHandler('protocol_id', 'base-selected', Items.onItemSelected);
    5050
    5151      // Kit
    5252      Buttons.addClickHandler('kit_id.select', plateevents.selectKit);
    53       Events.addEventHandler('kit_id', 'base-selected', plateevents.setKitCallback);
     53      Events.addEventHandler('kit_id', 'base-selected', Items.onItemSelected);
    5454    }
    5555    else if (pageId == 'view-page')
     
    145145  }
    146146 
    147   plateevents.setHardwareCallback = function(event)
    148   {
    149     var frm = document.forms['event'];
    150     var list = frm.hardware_id;
    151     if (list.length < 2 || list[1].value == 'NaN')
    152     {
    153       Forms.addListOption(list, 1, new Option());
    154     }
    155     list[1].value = event.detail.id;
    156     list[1].text = event.detail.name;
    157     list.selectedIndex = 1;
    158   }
    159  
    160147  plateevents.selectProtocol = function()
    161148  {
     
    170157  }
    171158 
    172   plateevents.setProtocolCallback = function(event)
    173   {
    174     var frm = document.forms['event'];
    175     var list = frm.protocol_id;
    176     if (list.length < 2 || list[1].value == 'NaN')
    177     {
    178       Forms.addListOption(list, 1, new Option());
    179     }
    180     list[1].value = event.detail.id;
    181     list[1].text = event.detail.name;
    182     list.selectedIndex = 1;
    183   }
    184 
    185159  plateevents.selectKit = function()
    186160  {
     
    196170  }
    197171 
    198   plateevents.setKitCallback = function(event)
    199   {
    200     var frm = document.forms['event'];
    201     var list = frm.kit_id;
    202     if (list.length < 2 || list[1].value == 'NaN')
    203     {
    204       Forms.addListOption(list, 1, new Option());
    205     }
    206     list[1].value = event.detail.id;
    207     list[1].text = event.detail.name;
    208     list.selectedIndex = 1;
    209   }
    210 
    211172  return plateevents;
    212173}();
  • trunk/www/biomaterials/bioplates/wells/biowells.js

    r7000 r7001  
    4343      // Biomaterial
    4444      Buttons.addClickHandler('biomaterial_id.select', biowells.selectBioMaterial);
    45       Events.addEventHandler('biomaterial_id', 'base-selected', biowells.setBioMaterialCallback);
     45      Events.addEventHandler('biomaterial_id', 'base-selected', Items.onItemSelected);
    4646    }
    4747    else if (pageId == 'list-page')
     
    131131  }
    132132 
    133   biowells.setBioMaterialCallback = function(event)
    134   {
    135     var frm = document.forms['biowell'];
    136     var list = frm.biomaterial_id;
    137     if (list.length < 2 || list[1].value == 'NaN')
    138     {
    139       Forms.addListOption(list, 1, new Option());
    140     }
    141     list[1].value = event.detail.id;
    142     list[1].text = event.detail.name;
    143     list.selectedIndex = 1;
    144   }
    145 
    146133 
    147134  return biowells;
  • trunk/www/biomaterials/events/events.js

    r7000 r7001  
    4444      // Protocol
    4545      Buttons.addClickHandler('protocol_id.select', biomaterialevents.selectProtocol);
    46       Events.addEventHandler('protocol_id', 'base-selected', biomaterialevents.setProtocolCallback);
     46      Events.addEventHandler('protocol_id', 'base-selected', Items.onItemSelected);
    4747      // Kit
    4848      Buttons.addClickHandler('kit_id.select', biomaterialevents.selectKit);
    49       Events.addEventHandler('kit_id', 'base-selected', biomaterialevents.setKitCallback);
     49      Events.addEventHandler('kit_id', 'base-selected', Items.onItemSelected);
    5050     
    5151      // Used quantity
     
    123123  }
    124124 
    125   biomaterialevents.setProtocolCallback = function(event)
    126   {
    127     var id = event.detail.id;
    128     var name = event.detail.name;
    129     var frm = document.forms['event'];
    130     var list = frm.protocol_id;
    131     if (list.length < 2 || list[1].value == 'NaN')
    132     {
    133       Forms.addListOption(list, 1, new Option());
    134     }
    135     list[1].value = id;
    136     list[1].text = name;
    137     list.selectedIndex = 1;
    138   }
    139 
    140125  biomaterialevents.selectKit = function()
    141126  {
     
    151136  }
    152137 
    153   biomaterialevents.setKitCallback = function(event)
    154   {
    155     var id = event.detail.id;
    156     var name = event.detail.name;
    157     var frm = document.forms['event'];
    158     var list = frm.kit_id;
    159     if (list.length < 2 || list[1].value == 'NaN')
    160     {
    161       Forms.addListOption(list, 1, new Option());
    162     }
    163     list[1].value = id;
    164     list[1].text = name;
    165     list.selectedIndex = 1;
    166   }
    167 
    168138  return biomaterialevents;
    169139}();
  • trunk/www/biomaterials/extracts/extracts.js

    r7000 r7001  
    4848      // Tag
    4949      Buttons.addClickHandler('tag_id.select', extracts.selectTag);
    50       Events.addEventHandler('tag_id', 'base-selected', extracts.setTagCallback);
     50      Events.addEventHandler('tag_id', 'base-selected', Items.onItemSelected);
    5151
    5252      // Protocol
    5353      Buttons.addClickHandler('protocol_id.select', extracts.selectProtocol);
    54       Events.addEventHandler('protocol_id', 'base-selected', extracts.setProtocolCallback);
     54      Events.addEventHandler('protocol_id', 'base-selected', Items.onItemSelected);
    5555      // Kit
    5656      Buttons.addClickHandler('kit_id.select', extracts.selectKit);
    57       Events.addEventHandler('kit_id', 'base-selected', extracts.setKitCallback);
     57      Events.addEventHandler('kit_id', 'base-selected', Items.onItemSelected);
    5858      // Subtype
    5959      Events.addEventHandler('subtype_id', 'change', extracts.subtypeOnChange);
     
    6161      // Bioplate and biowell
    6262      Buttons.addClickHandler('bioplate_id.select', extracts.selectBioPlate);
    63       Events.addEventHandler('bioplate_id', 'base-selected', extracts.setBioPlateCallback);
     63      Events.addEventHandler('bioplate_id', 'base-selected', Items.onItemSelected);
    6464      Events.addEventHandler('bioplate_id', 'change', extracts.bioPlateOnChange);
    6565      Buttons.addClickHandler('biowell_id.select', extracts.selectBioWell);
    66       Events.addEventHandler('biowell_id', 'base-selected', extracts.setBioWellCallback);
     66      Events.addEventHandler('biowell_id', 'base-selected', Items.onItemSelected);
    6767      extracts.initBioWell();
    6868
     
    7171      Events.addEventHandler('parentType.extract', 'click', extracts.parentTypeOnClick);
    7272      Buttons.addClickHandler('sample_id.select', extracts.selectSample);
    73       Events.addEventHandler('sample_id', 'base-selected', extracts.setSampleCallback);
     73      Events.addEventHandler('sample_id', 'base-selected', Items.onItemSelected);
     74      Events.addEventHandler('sample_id', 'base-selected', extracts.sampleOnChange);
    7475      Events.addEventHandler('used_from_sample', 'keypress', Events.numberOnly);
    7576      Events.addEventHandler('used_from_sample', 'blur', extracts.usedFromSampleOnBlur);
     
    301302  }
    302303 
    303   extracts.setTagCallback = function(event)
    304   {
    305     var frm = document.forms['extract'];
    306     var list = frm.tag_id;
    307     if (list.length < 2 || list[1].value == 'NaN')
    308     {
    309       Forms.addListOption(list, 1, new Option());
    310     }
    311     list[1].value = event.detail.id;
    312     list[1].text = event.detail.name;
    313     list.selectedIndex = 1;
    314   }
    315 
    316  
    317304  extracts.selectProtocol = function()
    318305  {
     
    328315  }
    329316 
    330   extracts.setProtocolCallback = function(event)
    331   {
    332     var frm = document.forms['extract'];
    333     var list = frm.protocol_id;
    334     if (list.length < 2 || list[1].value == 'NaN')
    335     {
    336       Forms.addListOption(list, 1, new Option());
    337     }
    338     list[1].value = event.detail.id;
    339     list[1].text = event.detail.name;
    340     list.selectedIndex = 1;
    341   }
    342 
    343317  extracts.selectKit = function()
    344318  {
     
    354328    Dialogs.selectItem('KIT', 'kit_id', 0, url);
    355329  }
    356  
    357   extracts.setKitCallback = function(event)
    358   {
    359     var frm = document.forms['extract'];
    360     var list = frm.kit_id;
    361     if (list.length < 2 || list[1].value == 'NaN')
    362     {
    363       Forms.addListOption(list, 1, new Option());
    364     }
    365     list[1].value = event.detail.id;
    366     list[1].text = event.detail.name;
    367     list.selectedIndex = 1;
    368   }
    369 
    370330 
    371331  extracts.selectBioPlate = function()
     
    381341  }
    382342 
    383   extracts.setBioPlateCallback = function(event)
    384   {
    385     var frm = document.forms['extract'];
    386     var list = frm.bioplate_id;
    387     if (list.length < 2 || list[1].value == 'NaN')
    388     {
    389       Forms.addListOption(list, 1, new Option());
    390     }
    391     list[1].value = event.detail.id;
    392     list[1].text = event.detail.name;
    393     list.selectedIndex = 1;
    394     extracts.bioPlateOnChange();
    395   }
    396 
    397343  extracts.bioPlateOnChange = function()
    398344  {
     
    432378  }
    433379 
    434   extracts.setBioWellCallback = function(event)
    435   {
    436     var frm = document.forms['extract'];
    437     var list = frm.biowell_id;
    438     if (list.length < 2 || list[1].value == 'NaN')
    439     {
    440       Forms.addListOption(list, 1, new Option());
    441     }
    442     list[1].value = event.detail.id;
    443     list[1].text = event.detail.name;
    444     list.selectedIndex = 1;
    445   }
    446 
    447380  extracts.parentTypeOnClick = function()
    448381  {
     
    468401  }
    469402 
    470   extracts.setSampleCallback = function(event)
    471   {
    472     var frm = document.forms['extract'];
    473     var list = frm.sample_id;
    474     if (list.length < 2 || list[1].value == 'NaN')
    475     {
    476       Forms.addListOption(list, 1, new Option());
    477     }
    478     list[1].value = event.detail.id;
    479     list[1].text = event.detail.name;
    480     list.selectedIndex = 1;
    481 
     403  extracts.sampleOnChange = function(event)
     404  {
     405    var frm = document.forms['extract'];
    482406    frm.parentType[0].checked = true;
    483407    frm.parentType[1].checked = false;
  • trunk/www/biomaterials/samples/samples.js

    r7000 r7001  
    4848      // Protocol
    4949      Buttons.addClickHandler('protocol_id.select', samples.selectProtocol);
    50       Events.addEventHandler('protocol_id', 'base-selected', samples.setProtocolCallback);
    51       // Protocol
     50      Events.addEventHandler('protocol_id', 'base-selected', Items.onItemSelected);
     51      // Kit
    5252      Buttons.addClickHandler('kit_id.select', samples.selectKit);
    53       Events.addEventHandler('kit_id', 'base-selected', samples.setKitCallback);
     53      Events.addEventHandler('kit_id', 'base-selected', Items.onItemSelected);
    5454      // Subtype
    5555      Events.addEventHandler('subtype_id', 'change', samples.subtypeOnChange);
     
    5757      // Bioplate and biowell
    5858      Buttons.addClickHandler('bioplate_id.select', samples.selectBioPlate);
    59       Events.addEventHandler('bioplate_id', 'base-selected', samples.setBioPlateCallback);
     59      Events.addEventHandler('bioplate_id', 'base-selected', Items.onItemSelected);
    6060      Events.addEventHandler('bioplate_id', 'change', samples.bioPlateOnChange);
    6161      Buttons.addClickHandler('biowell_id.select', samples.selectBioWell);
    62       Events.addEventHandler('biowell_id', 'base-selected', samples.setBioWellCallback);
     62      Events.addEventHandler('biowell_id', 'base-selected', Items.onItemSelected);
    6363      samples.initBioWell();
    6464     
     
    6767      Events.addEventHandler('parentType.sample', 'click', samples.parentTypeOnClick);
    6868      Buttons.addClickHandler('biosource_id.select', samples.selectBioSource);
    69       Events.addEventHandler('biosource_id', 'base-selected', samples.setBioSourceCallback);
     69      Events.addEventHandler('biosource_id', 'base-selected', Items.onItemSelected);
     70      Events.addEventHandler('biosource_id', 'base-selected', samples.bioSourceOnChange);
    7071
    7172      Events.addEventHandler('samples', 'change', samples.samplesOnChange);
     
    223224    Dialogs.selectItem('BIOPLATE', 'bioplate_id', 0, url);
    224225  }
    225  
    226   samples.setBioPlateCallback = function(event)
    227   {
    228     var frm = document.forms['sample'];
    229     var list = frm.bioplate_id;
    230     if (list.length < 2 || list[1].value == 'NaN')
    231     {
    232       Forms.addListOption(list, 1, new Option());
    233     }
    234     list[1].value = event.detail.id;
    235     list[1].text = event.detail.name;
    236     list.selectedIndex = 1;
    237     samples.bioPlateOnChange();
    238   }
     226
    239227
    240228  samples.bioPlateOnChange = function()
     
    274262    Dialogs.selectItem('BIOWELL', 'biowell_id', 0, url);
    275263  }
    276   samples.setBioWellCallback = function(event)
    277   {
    278     var frm = document.forms['sample'];
    279     var list = frm.biowell_id;
    280     if (list.length < 2 || list[1].value == 'NaN')
    281     {
    282       Forms.addListOption(list, 1, new Option());
    283     }
    284     list[1].value = event.detail.id;
    285     list[1].text = event.detail.name;
    286     list.selectedIndex = 1;
    287   }
    288264 
    289265  samples.loadAnnotationsFrame = function()
     
    331307  }
    332308 
    333   samples.setProtocolCallback = function(event)
    334   {
    335     var frm = document.forms['sample'];
    336     var list = frm.protocol_id;
    337     if (list.length < 2 || list[1].value == 'NaN')
    338     {
    339       Forms.addListOption(list, 1, new Option());
    340     }
    341     list[1].value = event.detail.id;
    342     list[1].text = event.detail.name;
    343     list.selectedIndex = 1;
    344   }
    345  
    346309  samples.selectKit = function()
    347310  {
     
    358321  }
    359322 
    360   samples.setKitCallback = function(event)
    361   {
    362     var frm = document.forms['sample'];
    363     var list = frm.kit_id;
    364     if (list.length < 2 || list[1].value == 'NaN')
    365     {
    366       Forms.addListOption(list, 1, new Option());
    367     }
    368     list[1].value = event.detail.id;
    369     list[1].text = event.detail.name;
    370     list.selectedIndex = 1;
    371   }
    372 
    373323  samples.subtypeOnChange = function()
    374324  {
     
    403353  }
    404354 
    405   samples.setBioSourceCallback = function(event)
    406   {
    407     var frm = document.forms['sample'];
    408     var list = frm.biosource_id;
    409     if (list.length < 2 || list[1].value == 'NaN')
    410     {
    411       Forms.addListOption(list, 1, new Option());
    412     }
    413     list[1].value = event.detail.id;
    414     list[1].text = event.detail.name;
    415     list.selectedIndex = 1;
    416 
     355  samples.bioSourceOnChange = function(event)
     356  {
     357    var frm = document.forms['sample'];
    417358    frm.parentType[0].checked = true;
    418359    frm.parentType[1].checked = false;
    419360    samples.parentTypeOnClick();
    420361  }
    421 
    422362 
    423363  samples.addSamplesOnClick = function(event)
  • trunk/www/biomaterials/wizards/create_child_bioplate.js

    r7000 r7001  
    5858      // Hardware
    5959      Buttons.addClickHandler('hardware_id.select', child.selectHardware);
    60       Events.addEventHandler('hardware_id', 'base-selected', Wizards.setHardwareCallback);
     60      Events.addEventHandler('hardware_id', 'base-selected', Items.onItemSelected);
    6161
    6262      // Protocol
    6363      Buttons.addClickHandler('protocol_id.select', child.selectProtocol);
    64       Events.addEventHandler('protocol_id', 'base-selected', Wizards.setProtocolCallback);
     64      Events.addEventHandler('protocol_id', 'base-selected', Items.onItemSelected);
    6565
    6666      // Protocol
    6767      Buttons.addClickHandler('kit_id.select', child.selectKit);
    68       Events.addEventHandler('kit_id', 'base-selected', Wizards.setKitCallback);
     68      Events.addEventHandler('kit_id', 'base-selected', Items.onItemSelected);
    6969
    7070      // Tag
    7171      Buttons.addClickHandler('tag_id.select', child.selectTag);
    72       Events.addEventHandler('tag_id', 'base-selected', child.setTagCallback);
     72      Events.addEventHandler('tag_id', 'base-selected', Items.onItemSelected);
    7373     
    7474      // Quantities
     
    8181      // Plate geometry
    8282      Buttons.addClickHandler('plategeometry_id.select', child.selectPlateGeometry);
    83       Events.addEventHandler('plategeometry_id', 'base-selected', child.setPlateGeometryCallback);
     83      Events.addEventHandler('plategeometry_id', 'base-selected', Items.onItemSelected);
    8484
    8585      // Bioplate type
    8686      Buttons.addClickHandler('bioplatetype_id.select', child.selectBioPlateType);
    87       Events.addEventHandler('bioplatetype_id', 'base-selected', child.setBioPlateTypeCallback);
     87      Events.addEventHandler('bioplatetype_id', 'base-selected', Items.onItemSelected);
    8888     
    8989      // Storage location
    9090      Buttons.addClickHandler('freezer_id.select', child.selectFreezer);
    91       Events.addEventHandler('freezer_id', 'base-selected', child.setFreezerCallback);
     91      Events.addEventHandler('freezer_id', 'base-selected', Items.onItemSelected);
    9292     
    9393      // Plates
     
    216216  }
    217217
    218   child.setTagCallback = function(event)
    219   {
    220     var frm = document.forms['main'];
    221     var list = frm.tag_id;
    222     if (list.length < 2 || list[1].value == 'NaN')
    223     {
    224       Forms.addListOption(list, 1, new Option());
    225     }
    226     list[1].value = event.detail.id;
    227     list[1].text = event.detail.name;
    228     list.selectedIndex = 1;
    229   }
    230  
    231218  child.selectFreezer = function()
    232219  {
     
    242229  }
    243230 
    244   child.setFreezerCallback = function(event)
    245   {
    246     var frm = document.forms['main'];
    247     var list = frm.freezer_id;
    248     if (list.length < 2 || list[1].value == 'NaN')
    249     {
    250       Forms.addListOption(list, 1, new Option());
    251     }
    252     list[1].value = event.detail.id;
    253     list[1].text = event.detail.name;
    254     list.selectedIndex = 1;
    255   }
    256 
    257231  child.selectPlateGeometry = function()
    258232  {
     
    261235    if (frm.plategeometry_id.length > 0) url += '&item_id='+frm.plategeometry_id[0].value;
    262236    Dialogs.selectItem('PLATEGEOMETRY', 'plategeometry_id', 0, url);
    263   }
    264  
    265   child.setPlateGeometryCallback = function(event)
    266   {
    267     var frm = document.forms['main'];
    268     var list = frm.plategeometry_id;
    269     if (list.length < 1 || list[0].value == 'NaN')
    270     {
    271       Forms.addListOption(list, 0, new Option());
    272     }
    273     list[0].value = event.detail.id;
    274     list[0].text = event.detail.name;
    275     list.selectedIndex = 0;
    276237  }
    277238 
     
    295256  }
    296257 
    297   child.setBioPlateTypeCallback = function(event)
    298   {
    299     var frm = document.forms['main'];
    300     var list = frm.bioplatetype_id;
    301     if (list.length < 1 || list[0].disabled)
    302     {
    303       Forms.addListOption(list, 0, new Option());
    304     }
    305     list[0].value = event.detail.id;
    306     list[0].text = event.detail.name;
    307     list.selectedIndex = 0;
    308   }
    309 
    310258  child.childTypeOnChange = function()
    311259  {
  • trunk/www/biomaterials/wizards/wizards.js

    r7000 r7001  
    4545  }
    4646 
    47  
    48   wizards.setHardwareCallback = function(event)
    49   {
    50     var frm = document.forms['main'];
    51     var list = frm.hardware_id;
    52     if (list.length < 2 || list[1].value == 'NaN')
    53     {
    54       Forms.addListOption(list, 1, new Option());
    55     }
    56     list[1].value = event.detail.id;
    57     list[1].text = event.detail.name;
    58     list.selectedIndex = 1;
    59   }
    60 
    61  
    6247  wizards.selectProtocol = function()
    6348  {
     
    7762  }
    7863 
    79   wizards.setProtocolCallback = function(event)
    80   {
    81     var frm = document.forms['main'];
    82     var list = frm.protocol_id;
    83     if (list.length < 2 || list[1].value == 'NaN')
    84     {
    85       Forms.addListOption(list, 1, new Option());
    86     }
    87     list[1].value = event.detail.id;
    88     list[1].text = event.detail.name;
    89     list.selectedIndex = 1;
    90   }
    91 
    9264  wizards.selectKit = function()
    9365  {
     
    10880  }
    10981 
    110   wizards.setKitCallback = function(event)
    111   {
    112     var frm = document.forms['main'];
    113     var list = frm.kit_id;
    114     if (list.length < 2 || list[1].value == 'NaN')
    115     {
    116       Forms.addListOption(list, 1, new Option());
    117     }
    118     list[1].value = event.detail.id;
    119     list[1].text = event.detail.name;
    120     list.selectedIndex = 1;
    121   }
    122 
    12382  return wizards;
    12483}();
  • trunk/www/common/ownership/ownership.js

    r7000 r7001  
    3737   
    3838    Buttons.addClickHandler('owner_id.select', owner.selectUser);
    39     Events.addEventHandler('owner_id', 'base-selected', owner.setOwnerCallback);
     39    Events.addEventHandler('owner_id', 'base-selected', Items.onItemSelected);
    4040  }
    4141 
     
    5656  }
    5757
    58   owner.setOwnerCallback = function(event)
    59   {
    60     var id = event.detail.id;
    61     var name = event.detail.name;
    62     var frm = document.forms['ownership'];
    63     var list = frm.owner_id;
    64     if (list.length < 2 || list[1].value == 'NaN')
    65     {
    66       Forms.addListOption(list, 1, new Option());
    67     }
    68     list[1].value = id;
    69     list[1].text = name;
    70     list.selectedIndex = 1;
    71   }
    72  
    7358  /**
    7459    Save settings and close the dialog.
  • trunk/www/filemanager/files/files.js

    r7000 r7001  
    4949      // Select fileserver
    5050      Buttons.addClickHandler('server_id.select', fileManager.selectFileServer);
    51       Events.addEventHandler('server_id', 'base-selected', fileManager.setFileServerCallback);
     51      Events.addEventHandler('server_id', 'base-selected', Items.onItemSelected);
    5252     
    5353      // URL
     
    414414  }
    415415 
    416   fileManager.setFileServerCallback = function(event)
    417   {
    418     var frm = document.forms['file'];
    419     var list = frm.server_id;
    420     if (list.length < 2 || list[1].value == 'NaN')
    421     {
    422       Forms.addListOption(list, 1, new Option());
    423     }
    424     list[1].value = event.detail.id;
    425     list[1].text = event.detail.name;
    426     list.selectedIndex = 1;
    427   }
    428  
    429416  fileManager.urlOnChange = function()
    430417  {
  • trunk/www/include/scripts/main-2.js

    r6991 r7001  
    803803    element = Doc.element(element);
    804804    var changeEvent = element.ownerDocument.createEvent('HTMLEvents');
    805     changeEvent.initEvent('change', false, true);
     805    changeEvent.initEvent('change', true, true);
    806806    element.dispatchEvent(changeEvent);
    807807  }
     
    18811881    }
    18821882    internal.itemCommand(cmd, itemType, itemId, extraUrl, {width: 750, height: 500});
     1883  }
     1884 
     1885  /**
     1886    Generic callback for handling 'base-selected' event that is sent
     1887    to the selection list when a single item has been selected.
     1888   */
     1889  items.onItemSelected = function(event)
     1890  {
     1891    var list = event.currentTarget;
     1892    if (!list.options) list = Doc.element(list.id+'.list');
     1893   
     1894    // If 'none' is first option, insert at index=1, otherwise at index=0
     1895    var insertIndex = list.length > 0 && list[0].value == '0' ? 1 : 0;
     1896   
     1897    // Create the new option
     1898    var option = new Option(event.detail.name, event.detail.id);
     1899    option.title = option.text;
     1900   
     1901    var changed = true;
     1902    if (list.length <= insertIndex)
     1903    {
     1904      // Add the new option to the end
     1905      list[list.length] = option;
     1906    }
     1907    else if (list[insertIndex].value == 'NaN')
     1908    {
     1909      // Add a new option before the current
     1910      list.add(option, list[insertIndex]);
     1911    }
     1912    else
     1913    {
     1914      // Replace the current option
     1915      changed = list[list.selectedIndex].value != option.value;
     1916      list[insertIndex] = option;
     1917    }
     1918    list.selectedIndex = insertIndex;
     1919    if (changed) Events.sendChangeEvent(list);
    18831920  }
    18841921 
  • trunk/www/lims/arraybatches/batches.js

    r7000 r7001  
    4545      // Array design
    4646      Buttons.addClickHandler('arraydesign_id.select', arrayBatches.selectArrayDesign);
    47       Events.addEventHandler('arraydesign_id', 'base-selected', arrayBatches.setArrayDesignCallback);
     47      Events.addEventHandler('arraydesign_id', 'base-selected', Items.onItemSelected);
    4848
    4949      // Protocol
    5050      Buttons.addClickHandler('protocol_id.select', arrayBatches.selectProtocol);
    51       Events.addEventHandler('protocol_id', 'base-selected', arrayBatches.setProtocolCallback);
     51      Events.addEventHandler('protocol_id', 'base-selected', Items.onItemSelected);
    5252
    5353      // Print robot
    5454      Buttons.addClickHandler('printrobot_id.select', arrayBatches.selectPrintRobot);
    55       Events.addEventHandler('printrobot_id', 'base-selected', arrayBatches.setPrintRobotCallback);
     55      Events.addEventHandler('printrobot_id', 'base-selected', Items.onItemSelected);
    5656
    5757    }
     
    191191  }
    192192 
    193   arrayBatches.setArrayDesignCallback = function(event)
    194   {
    195     var frm = document.forms['batch'];
    196     var list = frm.arraydesign_id;
    197     if (list.length < 1 || list[0].value == 'NaN')
    198     {
    199       Forms.addListOption(list, 0, new Option());
    200     }
    201     list[0].value = event.detail.id;
    202     list[0].text = event.detail.name;
    203     list.selectedIndex = 0;
    204   }
    205 
    206193  arrayBatches.selectProtocol = function()
    207194  {
     
    217204  }
    218205 
    219   arrayBatches.setProtocolCallback = function(event)
    220   {
    221     var frm = document.forms['batch'];
    222     var list = frm.protocol_id;
    223     if (list.length < 2 || list[1].value == 'NaN')
    224     {
    225       Forms.addListOption(list, 1, new Option());
    226     }
    227     list[1].value = event.detail.id;
    228     list[1].text = event.detail.name;
    229     list.selectedIndex = 1;
    230   }
    231  
    232206  arrayBatches.selectPrintRobot = function()
    233207  {
     
    243217  }
    244218 
    245   arrayBatches.setPrintRobotCallback = function(event)
    246   {
    247     var frm = document.forms['batch'];
    248     var list = frm.printrobot_id;
    249     if (list.length < 2 || list[1].value == 'NaN')
    250     {
    251       Forms.addListOption(list, 1, new Option());
    252     }
    253     list[1].value = event.detail.id;
    254     list[1].text = event.detail.name;
    255     list.selectedIndex = 1;
    256   }
    257  
    258219  return arrayBatches;
    259220}();
  • trunk/www/lims/arrayslides/slides.js

    r7000 r7001  
    4545      // Array batch
    4646      Buttons.addClickHandler('arraybatch_id.select', arraySlides.selectArrayBatch);
    47       Events.addEventHandler('arraybatch_id', 'base-selected', arraySlides.setArrayBatchCallback);
     47      Events.addEventHandler('arraybatch_id', 'base-selected', Items.onItemSelected);
    4848     
    4949      // Batch order
     
    151151  }
    152152 
    153   arraySlides.setArrayBatchCallback = function(event)
    154   {
    155     var frm = document.forms['slide'];
    156     var list = frm.arraybatch_id;
    157     if (list.length < 1 || list[0].value == 'NaN')
    158     {
    159       Forms.addListOption(list, 0, new Option());
    160     }
    161     list[0].value = event.detail.id;
    162     list[0].text = event.detail.name;
    163     list.selectedIndex = 0;
    164   }
    165 
    166  
    167153  return arraySlides;
    168154}();
  • trunk/www/lims/arrayslides/wizard.js

    r7000 r7001  
    4444      // Array batch
    4545      Buttons.addClickHandler('arraybatch_id.select', wizard.selectArrayBatch);
    46       Events.addEventHandler('arraybatch_id', 'base-selected', wizard.setArrayBatchCallback);
     46      Events.addEventHandler('arraybatch_id', 'base-selected', Items.onItemSelected);
    4747     
    4848    }
     
    140140  }
    141141 
    142   wizard.setArrayBatchCallback = function(event)
    143   {
    144     var frm = document.forms['WizardStep1'];
    145     var list = frm.arraybatch_id;
    146     if (list.length < 1 || list[0].value == 'NaN')
    147     {
    148       Forms.addListOption(list, 0, new Option());
    149     }
    150     list[0].value = event.detail.id;
    151     list[0].text = event.detail.name;
    152     list.selectedIndex = 0;
    153   }
    154 
    155142  wizard.pasteMultiple = function(event)
    156143  {
  • trunk/www/lims/plates/events/events.js

    r7000 r7001  
    4444      // Protocol
    4545      Buttons.addClickHandler('protocol_id.select', plateEvents.selectProtocol);
    46       Events.addEventHandler('protocol_id', 'base-selected', plateEvents.setProtocolCallback);
     46      Events.addEventHandler('protocol_id', 'base-selected', Items.onItemSelected);
    4747     
    4848      // Hardware
    4949      Buttons.addClickHandler('hardware_id.select', plateEvents.selectHardware);
    50       Events.addEventHandler('hardware_id', 'base-selected', plateEvents.setHardwareCallback);
     50      Events.addEventHandler('hardware_id', 'base-selected', Items.onItemSelected);
    5151    }
    5252    else if (pageId == 'view-page')
     
    129129  }
    130130 
    131   plateEvents.setHardwareCallback = function(event)
    132   {
    133     var frm = document.forms['event'];
    134     var list = frm.hardware_id;
    135     if (list.length < 2 || list[1].value == 'NaN')
    136     {
    137       Forms.addListOption(list, 1, new Option());
    138     }
    139     list[1].value = event.detail.id;
    140     list[1].text = event.detail.name;
    141     list.selectedIndex = 1;
    142   }
    143 
    144131  plateEvents.selectProtocol = function()
    145132  {
     
    169156  }
    170157 
    171   plateEvents.setProtocolCallback = function(event)
    172   {
    173     var frm = document.forms['event'];
    174     var list = frm.protocol_id;
    175     if (list.length < 2 || list[1].value == 'NaN')
    176     {
    177       Forms.addListOption(list, 1, new Option());
    178     }
    179     list[1].value = event.detail.id;
    180     list[1].text = event.detail.name;
    181     list.selectedIndex = 1;
    182   }
    183 
    184158  return plateEvents;
    185159}();
  • trunk/www/lims/plates/merge_plates.js

    r7000 r7001  
    4040      // Plate mapping
    4141      Buttons.addClickHandler('platemapping_id.select', merge.selectPlateMapping);
    42       Events.addEventHandler('platemapping_id', 'base-selected', merge.setPlateMappingCallback);
     42      Events.addEventHandler('platemapping_id', 'base-selected', Items.onItemSelected);
    4343
    4444      // Plate type
    4545      Buttons.addClickHandler('platetype_id.select', merge.selectPlateType);
    46       Events.addEventHandler('platetype_id', 'base-selected', merge.setPlateTypeCallback);
     46      Events.addEventHandler('platetype_id', 'base-selected', Items.onItemSelected);
    4747     
    4848    }
     
    9393  }
    9494 
    95   merge.setPlateMappingCallback = function(event)
    96   {
    97     var frm = document.forms['merge'];
    98     var list = frm.platemapping_id;
    99     if (list.length < 1 || list[0].value == 'NaN')
    100     {
    101       Forms.addListOption(list, 0, new Option());
    102     }
    103     list[0].value = event.detail.id;
    104     list[0].text = event.detail.name;
    105     list.selectedIndex = 0;
    106   }
    107  
    10895  merge.selectPlateType = function()
    10996  {
    11097    Dialogs.selectItem('PLATETYPE', 'platetype_id');
    11198  }
    112  
    113   merge.setPlateTypeCallback = function(event)
    114   {
    115     var frm = document.forms['merge'];
    116     var list = frm.platetype_id;
    117     if (list.length < 1 || list[0].value == 'NaN')
    118     {
    119       Forms.addListOption(list, 0, new Option());
    120     }
    121     list[0].value = event.detail.id;
    122     list[0].text = event.detail.name;
    123     list.selectedIndex = 0;
    124   }
    125  
    12699 
    127100  merge.validateStep2 = function()
  • trunk/www/login.js

    r7000 r7001  
    247247  {
    248248    Buttons.addClickHandler('user_id.select', impersonate.selectUser);
    249     Events.addEventHandler('user_id', 'base-selected', impersonate.setUserCallback);
     249    Events.addEventHandler('user_id', 'base-selected', Items.onItemSelected);
    250250  }
    251251 
     
    265265  }
    266266 
    267   /**
    268     Callback for setting the selected user.
    269   */
    270   impersonate.setUserCallback = function(event)
    271   {
    272     var frm = document.forms[pForm];
    273     var list = frm.user_id;
    274     if (list.length < 1 || list[0].value == 'NaN')
    275     {
    276       Forms.addListOption(list, 0, new Option());
    277     }
    278     list[0].value = event.detail.id;
    279     list[0].text = event.detail.name;
    280     list.selectedIndex = 0;
    281   }
    282 
    283267  return impersonate;
    284268}();
  • trunk/www/my_base/projects/projects.js

    r7000 r7001  
    7474      // Permission templates
    7575      Buttons.addClickHandler('permissiontemplate_id.select', projects.selectPermissionTemplate);
    76       Events.addEventHandler('permissiontemplate_id', 'base-selected', projects.setPermissionTemplateCallback);
     76      Events.addEventHandler('permissiontemplate_id', 'base-selected', Items.onItemSelected);
    7777      Events.addEventHandler('permissiontemplate_id', 'change', projects.permissionTemplateOnChange);
    7878      projects.permissionTemplateOnChange();
     
    328328  }
    329329 
    330   projects.setPermissionTemplateCallback = function(event)
    331   {
    332     var frm = document.forms['project'];
    333     var list = frm.permissiontemplate_id;
    334     if (list.length < 2 || list[1].value == 'NaN')
    335     {
    336       Forms.addListOption(list, 1, new Option());
    337     }
    338     list[1].value = event.detail.id;
    339     list[1].text = event.detail.name;
    340     list.selectedIndex = 1;
    341     projects.permissionTemplateOnChange();
    342   }
    343 
    344330  projects.permissionTemplateOnChange = function()
    345331  {
  • trunk/www/plugins/net/sf/basedb/plugins/jep_extra_value_calculator.js

    r7000 r7001  
    4242    // Extra value type
    4343    Buttons.addClickHandler('parameter:extraValueType.select', jep.selectExtraValueType);
    44     Events.addEventHandler('parameter:extraValueType', 'base-selected', jep.setExtraValueTypeCallback);
     44    Events.addEventHandler('parameter:extraValueType', 'base-selected', Items.onItemSelected);
    4545   
    4646    // Preset formulas
     
    7878    }
    7979    Dialogs.selectItem('EXTRAVALUETYPE', 'parameter:extraValueType', 0, url);
    80   }
    81  
    82   jep.setExtraValueTypeCallback = function(event)
    83   {
    84     var frm = document.forms['extraValue'];
    85     var list = frm['parameter:extraValueType'];
    86     if (list.length < 1 || list[0].value == 'NaN')
    87     {
    88       Forms.addListOption(list, 0, new Option());
    89     }
    90     list[0].value = event.detail.id;
    91     list[0].text = event.detail.name;
    92     list.selectedIndex = 0;
    9380  }
    9481 
  • trunk/www/views/derivedbioassays/bioassays.js

    r7000 r7001  
    4949      // Extract
    5050      Buttons.addClickHandler('extract_id.select', bioassays.selectExtract);
    51       Events.addEventHandler('extract_id', 'base-selected', bioassays.setExtractCallback);
     51      Events.addEventHandler('extract_id', 'base-selected', Items.onItemSelected);
    5252     
    5353      // Protocol
    5454      Buttons.addClickHandler('protocol_id.select', bioassays.selectProtocol);
    55       Events.addEventHandler('protocol_id', 'base-selected', bioassays.setProtocolCallback);
     55      Events.addEventHandler('protocol_id', 'base-selected', Items.onItemSelected);
    5656
    5757      // Kit
    5858      Buttons.addClickHandler('kit_id.select', bioassays.selectKit);
    59       Events.addEventHandler('kit_id', 'base-selected', bioassays.setKitCallback);
     59      Events.addEventHandler('kit_id', 'base-selected', Items.onItemSelected);
    6060     
    6161      // Hardware
    6262      Buttons.addClickHandler('hardware_id.select', bioassays.selectHardware);
    63       Events.addEventHandler('hardware_id', 'base-selected', bioassays.setHardwareCallback);
     63      Events.addEventHandler('hardware_id', 'base-selected', Items.onItemSelected);
    6464     
    6565      // Software
    6666      Buttons.addClickHandler('software_id.select', bioassays.selectSoftware);
    67       Events.addEventHandler('software_id', 'base-selected', bioassays.setSoftwareCallback);
     67      Events.addEventHandler('software_id', 'base-selected', Items.onItemSelected);
    6868     
    6969      // Parent derived bioassays
     
    276276  }
    277277 
    278   bioassays.setProtocolCallback = function(event)
    279   {
    280     var frm = document.forms['bioAssay'];
    281     var list = frm.protocol_id;
    282     if (list.length < 2 || list[1].value == 'NaN')
    283     {
    284       Forms.addListOption(list, 1, new Option());
    285     }
    286     list[1].value = event.detail.id;
    287     list[1].text = event.detail.name;
    288     list.selectedIndex = 1;
    289   }
    290 
    291278  bioassays.selectKit = function()
    292279  {
     
    303290  }
    304291 
    305   bioassays.setKitCallback = function(event)
    306   {
    307     var frm = document.forms['bioAssay'];
    308     var list = frm.kit_id;
    309     if (list.length < 2 || list[1].value == 'NaN')
    310     {
    311       Forms.addListOption(list, 1, new Option());
    312     }
    313     list[1].value = event.detail.id;
    314     list[1].text = event.detail.name;
    315     list.selectedIndex = 1;
    316   }
    317 
    318292  bioassays.selectHardware = function()
    319293  {
     
    329303  }
    330304 
    331   bioassays.setHardwareCallback = function(event)
    332   {
    333     var frm = document.forms['bioAssay'];
    334     var list = frm.hardware_id;
    335     if (list.length < 2 || list[1].value == 'NaN')
    336     {
    337       Forms.addListOption(list, 1, new Option());
    338     }
    339     list[1].value = event.detail.id;
    340     list[1].text = event.detail.name;
    341     list.selectedIndex = 1;
    342   }
    343 
    344305  bioassays.selectSoftware = function()
    345306  {
     
    353314    }
    354315    Dialogs.selectItem('SOFTWARE', 'software_id', 0, url);
    355   }
    356  
    357   bioassays.setSoftwareCallback = function(event)
    358   {
    359     var frm = document.forms['bioAssay'];
    360     var list = frm.software_id;
    361     if (list.length < 2 || list[1].value == 'NaN')
    362     {
    363       Forms.addListOption(list, 1, new Option());
    364     }
    365     list[1].value = event.detail.id;
    366     list[1].text = event.detail.name;
    367     list.selectedIndex = 1;
    368316  }
    369317 
     
    452400  }
    453401 
    454   bioassays.setExtractCallback = function(event)
    455   {
    456     var frm = document.forms['bioAssay'];
    457     var list = frm.extract_id;
    458     if (list.length < 2 || list[1].value == 'NaN')
    459     {
    460       Forms.addListOption(list, 1, new Option());
    461     }
    462     list[1].value = event.detail.id;
    463     list[1].text = event.detail.name;
    464     list.selectedIndex = 1;
    465   }
    466  
    467402  return bioassays;
    468403}();
  • trunk/www/views/experiments/clone_reporters.js

    r7000 r7001  
    3838    // Template
    3939    Buttons.addClickHandler('reporterclonetemplate_id.select', cloneReporters.selectTemplate);
    40     Events.addEventHandler('reporterclonetemplate_id', 'base-selected', cloneReporters.setTemplateCallback);
     40    Events.addEventHandler('reporterclonetemplate_id', 'base-selected', Items.onItemSelected);
    4141  }
    4242 
     
    7777  }
    7878 
    79   cloneReporters.setTemplateCallback = function(event)
    80   {
    81     var frm = document.forms['clone'];
    82     var list = frm.reporterclonetemplate_id;
    83     if (list.length < 2 || list[1].value == 'NaN')
    84     {
    85       Forms.addListOption(list, 1, new Option());
    86     }
    87     list[1].value = event.detail.id;
    88     list[1].text = event.detail.name;
    89     list.selectedIndex = 1;
    90   }
    91 
    92 
    93  
    9479  return cloneReporters;
    9580}();
  • trunk/www/views/experiments/experiments.js

    r7000 r7001  
    4848      // Directory
    4949      Buttons.addClickHandler('directory_id.select', experiments.selectDirectory);
    50       Events.addEventHandler('directory_id', 'base-selected', experiments.setDirectoryCallback);
     50      Events.addEventHandler('directory_id', 'base-selected', Items.onItemSelected);
    5151     
    5252    }
     
    267267  }
    268268 
    269   experiments.setDirectoryCallback = function(event)
    270   {
    271     var frm = document.forms['experiment'];
    272     var list = frm.directory_id;
    273     if (list.length < 2 || list[1].value == 'NaN')
    274     {
    275       Forms.addListOption(list, 1, new Option());
    276     }
    277     list[1].value = event.detail.id;
    278     list[1].text = event.detail.name;
    279     list.selectedIndex = 1;
    280   }
    281 
    282  
    283269  return experiments;
    284270}();
  • trunk/www/views/physicalbioassays/bioassays.js

    r7000 r7001  
    4848      // Protocol
    4949      Buttons.addClickHandler('protocol_id.select', bioassays.selectProtocol);
    50       Events.addEventHandler('protocol_id', 'base-selected', bioassays.setProtocolCallback);
     50      Events.addEventHandler('protocol_id', 'base-selected', Items.onItemSelected);
    5151
    5252      // Subtype
     
    5555      // Hardware
    5656      Buttons.addClickHandler('hardware_id.select', bioassays.selectHardware);
    57       Events.addEventHandler('hardware_id', 'base-selected', bioassays.setHardwareCallback);
     57      Events.addEventHandler('hardware_id', 'base-selected', Items.onItemSelected);
    5858
    5959      // Kit
    6060      Buttons.addClickHandler('kit_id.select', bioassays.selectKit);
    61       Events.addEventHandler('kit_id', 'base-selected', bioassays.setKitCallback);
     61      Events.addEventHandler('kit_id', 'base-selected', Items.onItemSelected);
    6262     
    6363      // Array slide
    6464      Buttons.addClickHandler('arrayslide_id.select', bioassays.selectArraySlide);
    65       Events.addEventHandler('arrayslide_id', 'base-selected', bioassays.setArraySlideCallback);
     65      Events.addEventHandler('arrayslide_id', 'base-selected', Items.onItemSelected);
    6666      Events.addEventHandler('arrayslide_id', 'change', bioassays.arraySlideOnChange);
    6767     
     
    229229  }
    230230 
    231   bioassays.setProtocolCallback = function(event)
    232   {
    233     var frm = document.forms['bioassay'];
    234     var list = frm.protocol_id;
    235     if (list.length < 2 || list[1].value == 'NaN')
    236     {
    237       Forms.addListOption(list, 1, new Option());
    238     }
    239     list[1].value = event.detail.id;
    240     list[1].text = event.detail.name;
    241     list.selectedIndex = 1;
    242   }
    243  
    244231  bioassays.selectKit = function()
    245232  {
     
    256243  }
    257244 
    258   bioassays.setKitCallback = function(event)
    259   {
    260     var frm = document.forms['bioassay'];
    261     var list = frm.kit_id;
    262     if (list.length < 2 || list[1].value == 'NaN')
    263     {
    264       Forms.addListOption(list, 1, new Option());
    265     }
    266     list[1].value = event.detail.id;
    267     list[1].text = event.detail.name;
    268     list.selectedIndex = 1;
    269   }
    270 
    271245  bioassays.subtypeOnChange = function()
    272246  {
     
    293267  }
    294268 
    295   bioassays.setHardwareCallback = function(event)
    296   {
    297     var frm = document.forms['bioassay'];
    298     var list = frm.hardware_id;
    299     if (list.length < 2 || list[1].value == 'NaN')
    300     {
    301       Forms.addListOption(list, 1, new Option());
    302     }
    303     list[1].value = event.detail.id;
    304     list[1].text = event.detail.name;
    305     list.selectedIndex = 1;
    306   }
    307 
    308269  bioassays.selectArraySlide = function()
    309270  {
     
    320281  }
    321282 
    322   bioassays.setArraySlideCallback = function(event)
    323   {
    324     var frm = document.forms['bioassay'];
    325     if (frm.arrayslide_id.length < 2)
    326     {
    327       frm.arrayslide_id[frm.arrayslide_id.length] = new Option();
    328     }
    329     frm.arrayslide_id[1].value = event.detail.id;
    330     frm.arrayslide_id[1].text = event.detail.name;
    331     frm.arrayslide_id.selectedIndex = 1;
    332     bioassays.updateSize(event.detail.id);
    333   }
    334 
    335283  bioassays.arraySlideOnChange = function()
    336284  {
  • trunk/www/views/rawbioassays/bioassays.js

    r7000 r7001  
    5050      // Protocol
    5151      Buttons.addClickHandler('protocol_id.select', bioassays.selectProtocol);
    52       Events.addEventHandler('protocol_id', 'base-selected', bioassays.setProtocolCallback);
     52      Events.addEventHandler('protocol_id', 'base-selected', Items.onItemSelected);
    5353
    5454      // Software
    5555      Buttons.addClickHandler('software_id.select', bioassays.selectSoftware);
    56       Events.addEventHandler('software_id', 'base-selected', bioassays.setSoftwareCallback);
     56      Events.addEventHandler('software_id', 'base-selected', Items.onItemSelected);
    5757     
    5858      // Parent bioassay
    5959      Buttons.addClickHandler('bioassay_id.select', bioassays.selectBioAssay);
    60       Events.addEventHandler('bioassay_id', 'base-selected', bioassays.setBioAssayCallback);
     60      Events.addEventHandler('bioassay_id', 'base-selected', Items.onItemSelected);
    6161      Events.addEventHandler('bioassay_id', 'change', bioassays.bioAssayOnChange);
    6262
    6363      // Array design
    6464      Buttons.addClickHandler('arraydesign_id.select', bioassays.selectArrayDesign);
    65       Events.addEventHandler('arraydesign_id', 'base-selected', bioassays.setArrayDesignCallback);
     65      Events.addEventHandler('arraydesign_id', 'base-selected', Items.onItemSelected);
    6666      Events.addEventHandler('arraydesign_id', 'change', bioassays.arrayDesignOnChange);
    6767
    6868      // Extract
    6969      Buttons.addClickHandler('extract_id.select', bioassays.selectExtract);
    70       Events.addEventHandler('extract_id', 'base-selected', bioassays.setExtractCallback);
     70      Events.addEventHandler('extract_id', 'base-selected', Items.onItemSelected);
    7171    }
    7272    else if (pageId == 'view-page')
     
    259259  }
    260260 
    261   bioassays.setProtocolCallback = function(event)
    262   {
    263     var frm = document.forms['rawbioassay'];
    264     var list = frm.protocol_id;
    265     if (list.length < 2 || list[1].value == 'NaN')
    266     {
    267       Forms.addListOption(list, 1, new Option());
    268     }
    269     list[1].value = event.detail.id;
    270     list[1].text = event.detail.name;
    271     list.selectedIndex = 1;
    272   }
    273 
    274261  bioassays.selectSoftware = function()
    275262  {
     
    285272  }
    286273 
    287   bioassays.setSoftwareCallback = function(event)
    288   {
    289     var frm = document.forms['rawbioassay'];
    290     var list = frm.software_id;
    291     if (list.length < 2 || list[1].value == 'NaN')
    292     {
    293       Forms.addListOption(list, 1, new Option());
    294     }
    295     list[1].value = event.detail.id;
    296     list[1].text = event.detail.name;
    297     list.selectedIndex = 1;
    298   }
    299 
    300274  bioassays.selectBioAssay = function()
    301275  {
     
    310284  }
    311285 
    312   bioassays.setBioAssayCallback = function(event)
    313   {
    314     var frm = document.forms['rawbioassay'];
    315     var list = frm.bioassay_id;
    316     if (list.length < 2 || list[1].value == 'NaN')
    317     {
    318       Forms.addListOption(list, 1, new Option());
    319     }
    320     list[1].value = event.detail.id;
    321     list[1].text = event.detail.name;
    322     list.selectedIndex = 1;
    323     bioassays.bioAssayOnChange();
    324   }
    325 
    326286  bioassays.bioAssayOnChange = function()
    327287  {
     
    350310    if (response.id)
    351311    {
    352       var designList = frm.arraydesign_id;
    353       if (designList.length < 2 || designList[1].value == 'NaN')
    354       {
    355         Forms.addListOption(designList, 1, new Option());
    356       }
    357       designList[1].value = response.id;
    358       designList[1].text = response.name;
    359       designList.selectedIndex = 1;
    360       bioassays.arrayDesignOnChange();
     312      // Update the 'array design' field
     313      Events.sendCustomEvent('arraydesign_id', 'base-selected',
     314        { 'id': response.id, 'name': response.name, 'itemType': 'ARRAYDESIGN'}
     315      );
    361316    }
    362317  }
     
    380335  }
    381336 
    382   bioassays.setArrayDesignCallback = function(event)
    383   {
    384     var frm = document.forms['rawbioassay'];
    385     var list = frm.arraydesign_id;
    386     if (list.length < 2 || list[1].value == 'NaN')
    387     {
    388       Forms.addListOption(list, 1, new Option());
    389     }
    390     list[1].value = event.detail.id;
    391     list[1].text = event.detail.name;
    392     list.selectedIndex = 1;
    393     bioassays.arrayDesignOnChange();
    394   }
    395 
    396337  bioassays.arrayDesignOnChange = function()
    397338  {
     
    449390  }
    450391 
    451   bioassays.setExtractCallback = function(event)
    452   {
    453     var frm = document.forms['rawbioassay'];
    454     var list = frm.extract_id;
    455     if (list.length < 2 || list[1].value == 'NaN')
    456     {
    457       Forms.addListOption(list, 1, new Option());
    458     }
    459     list[1].value = event.detail.id;
    460     list[1].text = event.detail.name;
    461     list.selectedIndex = 1;
    462   }
    463 
    464  
    465392  return bioassays;
    466393}();
Note: See TracChangeset for help on using the changeset viewer.