2008-07-28 18:30:40 +02:00
|
|
|
var LSformElement_text_field = new Class({
|
|
|
|
initialize: function(name,input,parent){
|
2008-10-15 19:40:04 +02:00
|
|
|
this._start = false;
|
2008-07-28 18:30:40 +02:00
|
|
|
this.name = name;
|
|
|
|
this.parent = parent;
|
|
|
|
this.input = input;
|
|
|
|
this.params = varLSdefault.LSjsConfig[this.name];
|
|
|
|
this._auto=1;
|
|
|
|
this.input.addEvent('change',this.unauto.bind(this));
|
2008-07-28 19:14:37 +02:00
|
|
|
this.onChangeColor = '#f16d6d';
|
2008-07-28 18:30:40 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
start: function() {
|
2008-10-15 19:40:04 +02:00
|
|
|
if (this._start) {
|
|
|
|
return true;
|
|
|
|
}
|
2008-07-28 18:30:40 +02:00
|
|
|
if ($type(this.params)) {
|
2008-10-07 17:48:48 +02:00
|
|
|
if ($type(this.params['generate_value_format'])) {
|
|
|
|
this.format = this.params['generate_value_format'];
|
|
|
|
this.oldBg=this.input.getStyle('background-color');
|
|
|
|
|
|
|
|
this.fx = new Fx.Tween(this.input,{property: 'background-color',duration:600});
|
|
|
|
|
|
|
|
// GenerateBtn
|
|
|
|
this.generateBtn = new Element('img');
|
|
|
|
this.generateBtn.addClass('btn');
|
2008-10-09 03:31:33 +02:00
|
|
|
this.generateBtn.src=varLSdefault.imagePath('generate.png');
|
2008-10-27 15:33:31 +01:00
|
|
|
this.generateBtn.addEvent('click',this.refreshValue.bind(this,true));
|
2008-10-07 17:48:48 +02:00
|
|
|
this.generateBtn.injectAfter(this.input);
|
2008-11-10 04:06:54 +01:00
|
|
|
varLSdefault.addHelpInfo(this.generateBtn,'LSformElement_text','generate');
|
2008-10-07 17:48:48 +02:00
|
|
|
|
|
|
|
// Auto
|
|
|
|
var force=0;
|
|
|
|
if (this.params.autoGenerateOnModify) {
|
|
|
|
force = 1;
|
|
|
|
}
|
2008-10-14 16:33:51 +02:00
|
|
|
if (((this.input.value=='')&&(this.params.autoGenerateOnCreate))||(force)) {
|
2008-07-28 18:30:40 +02:00
|
|
|
this.dependsFields = this.parent.getDependsFields(this.format);
|
|
|
|
this.dependsFields.each(function(el) {
|
|
|
|
var input = this.parent.getInput.bind(this.parent)(el);
|
|
|
|
input.addEvent('change',this.refreshValue.bind(this));
|
|
|
|
},this);
|
|
|
|
}
|
2008-10-15 19:40:04 +02:00
|
|
|
this._start=true;
|
2008-07-28 18:30:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getInput: function() {
|
|
|
|
return this.input;
|
|
|
|
},
|
|
|
|
|
|
|
|
getValue: function() {
|
|
|
|
return this.input.value;
|
|
|
|
},
|
|
|
|
|
2008-10-27 15:33:31 +01:00
|
|
|
refreshValue: function(force) {
|
|
|
|
if (force==true) {
|
|
|
|
this._auto=1;
|
|
|
|
}
|
|
|
|
if ((this._auto)||(force==true)) {
|
2008-10-06 15:11:14 +02:00
|
|
|
var val=getFData(this.format,this.parent,'getValue');
|
2008-10-07 18:10:44 +02:00
|
|
|
if ($type(this.params['withoutAccent'])) {
|
|
|
|
if(this.params['withoutAccent']) {
|
2008-10-06 15:11:14 +02:00
|
|
|
val = replaceAccents(val);
|
|
|
|
}
|
|
|
|
}
|
2008-10-07 18:10:44 +02:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
2008-10-06 15:11:14 +02:00
|
|
|
this.input.value = val;
|
2008-07-28 19:14:37 +02:00
|
|
|
this.fx.start(this.onChangeColor);
|
2008-07-28 18:30:40 +02:00
|
|
|
(function() {this.fx.start(this.oldBg);}).delay(1000,this);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
unauto: function() {
|
|
|
|
this._auto=0;
|
|
|
|
}
|
|
|
|
});
|