- LSformElement_text_field.js

-> Ajout d'une possibilite de mise en majuscule ou en minuscule
	-> Ajout d'une possibilite de replacement d'espace/tabulation
This commit is contained in:
Benjamin Renard 2008-10-07 16:10:44 +00:00
parent ee3f348c88
commit ea63665516
3 changed files with 42 additions and 5 deletions

View file

@ -266,10 +266,12 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
'mail' => array ( 'mail' => array (
'label' => _('Adresse e-mail'), 'label' => _('Adresse e-mail'),
'ldap_type' => 'ascii', 'ldap_type' => 'ascii',
'html_type' => 'mail', 'html_type' => 'text',
'html_options' => array( 'html_options' => array(
'generate_value_format' => '%{uid}@ls.com', 'generate_value_format' => '%{givenName}.%{sn}@ls.com',
'autoGenerateOnModify' => true 'withoutAccent' => 1,
'replaceSpaces' => '.',
'lowerCase' => 1
), ),
'required' => 1, 'required' => 1,
'check_data' => array ( 'check_data' => array (

View file

@ -51,11 +51,26 @@ var LSformElement_text_field = new Class({
refreshValue: function() { refreshValue: function() {
if (this._auto) { if (this._auto) {
var val=getFData(this.format,this.parent,'getValue'); var val=getFData(this.format,this.parent,'getValue');
if ($type(this.params['withoutAccents'])) { if ($type(this.params['withoutAccent'])) {
if(this.params['withoutAccents']) { if(this.params['withoutAccent']) {
val = replaceAccents(val); val = replaceAccents(val);
} }
} }
if ($type(this.params['replaceSpaces'])) {
if(this.params['replaceSpaces']) {
val = replaceSpaces(val,this.params['replaceSpaces']);
}
}
if ($type(this.params['upperCase'])) {
if(this.params['upperCase']) {
val = val.toUpperCase();
}
}
if ($type(this.params['lowerCase'])) {
if(this.params['lowerCase']) {
val = val.toLowerCase();
}
}
this.input.value = val; this.input.value = val;
this.fx.start(this.onChangeColor); this.fx.start(this.onChangeColor);
(function() {this.fx.start(this.oldBg);}).delay(1000,this); (function() {this.fx.start(this.oldBg);}).delay(1000,this);

View file

@ -95,3 +95,23 @@ function replaceAccents(str) {
} }
return new_str; return new_str;
} }
/**
* Remplace les espaces ou les tabulations d'une chaine
*
* @param[in] $string La chaine originale
* @param[in] $string Le caractère à mettre à la place
*
* @retval string La chaine sans espace
*/
function replaceSpaces(str,to) {
if (!$type(to)) {
to = '';
}
var new_str = String(str);
if (str && str!= "") {
var reg_exp= RegExp('[ \t]', "gi");
new_str = new_str.replace (reg_exp, to);
}
return new_str;
}