/site/samples/TatamiDemo1.3/com.objetdirect.tatami.demo.TatamiDemo/dojox/form/MultiComboBox.js

http://tatami.googlecode.com/ · JavaScript · 61 lines · 48 code · 8 blank · 5 comment · 8 complexity · 2eabbbb40313893c342c580dd353b172 MD5 · raw file

  1. if(!dojo._hasResource["dojox.form.MultiComboBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  2. dojo._hasResource["dojox.form.MultiComboBox"] = true;
  3. dojo.provide("dojox.form.MultiComboBox");
  4. dojo.experimental("dojox.form.MultiComboBox");
  5. dojo.require("dijit.form.ComboBox");
  6. dojo.require("dijit.form.ValidationTextBox");
  7. dojo.declare("dojox.form.MultiComboBox",
  8. [dijit.form.ValidationTextBox, dijit.form.ComboBoxMixin],{
  9. //
  10. // summary: A ComboBox that accpets multiple inputs on a single line?
  11. //
  12. // delimiter: String
  13. // The character to use to separate items in the ComboBox input
  14. delimiter: ",",
  15. _previousMatches: false,
  16. _setValueAttr: function(value){
  17. if (this.delimiter && value.length != 0){
  18. value = value+this.delimiter+" ";
  19. arguments[0] = this._addPreviousMatches(value);
  20. }
  21. this.inherited(arguments);
  22. },
  23. _addPreviousMatches: function(/* String */text){
  24. if(this._previousMatches){
  25. if(!text.match(new RegExp("^"+this._previousMatches))){
  26. text = this._previousMatches+text;
  27. }
  28. text = this._cleanupDelimiters(text);
  29. }
  30. return text; // String
  31. },
  32. _cleanupDelimiters: function(/* String */text){
  33. if(this.delimiter){
  34. text = text.replace(new RegExp(" +"), " ");
  35. text = text.replace(new RegExp("^ *"+this.delimiter+"* *"), "");
  36. text = text.replace(new RegExp(this.delimiter+" *"+this.delimiter), this.delimiter);
  37. }
  38. return text;
  39. },
  40. _autoCompleteText: function(/* String */text){
  41. arguments[0] = this._addPreviousMatches(text);
  42. this.inherited(arguments);
  43. },
  44. _startSearch: function(/* String */text){
  45. text = this._cleanupDelimiters(text);
  46. var re = new RegExp("^.*"+this.delimiter+" *");
  47. if((this._previousMatches = text.match(re))){
  48. arguments[0] = text.replace(re, "");
  49. }
  50. this.inherited(arguments);
  51. }
  52. });
  53. }