/branches/jsdoc_tk_gui/setup/workingDirectory/Webeo/gui/form/TextField.js

http://jsdoc-toolkit.googlecode.com/ · JavaScript · 32 lines · 14 code · 10 blank · 8 comment · 3 complexity · 1d5128ad4ad5e5d7ca13758e23bed6a8 MD5 · raw file

  1. ek.register("gui.form.TextField");
  2. /**
  3. * Affiche un Champs text
  4. */
  5. function TextField(domId){
  6. this.textDOM = document.getElementById(domId);
  7. this.textDOM.model = this;
  8. this.textDOM.onkeyup = this.onKeyUp ;
  9. this.currentPattern = /([a-zA-Z]+)/;
  10. }
  11. /**
  12. onKeydown (en appuyant sur une touche)
  13. onKeypress (en maintenant une touche appuyée)
  14. onKeyup (en relâchant la touche)
  15. */
  16. TextField.prototype.onKeyUp = function (e){
  17. if (this.value.substring(this.value.length-1, this.value.length) == 1)
  18. releaseEvents(Event.KEYUP);
  19. while(this.value.length >0 && !this.value.match(this.model.currentPattern)){
  20. this.value = this.value.substring(0, this.value.length-2);
  21. }
  22. }