2008-07-28 18:30:40 +02:00
|
|
|
var LSformElement_text_field = new Class({
|
|
|
|
initialize: function(name,input,parent){
|
|
|
|
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() {
|
|
|
|
var force=0;
|
|
|
|
if ($type(this.params)) {
|
|
|
|
if (this.params.autoGenerateOnModify) {
|
|
|
|
force = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((this.input.value=='')||(force)) {
|
|
|
|
if ($type(this.params)) {
|
|
|
|
if ($type(this.params['generate_value_format'])) {
|
|
|
|
this.format = this.params['generate_value_format'];
|
|
|
|
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-07-28 19:14:37 +02:00
|
|
|
this.oldBg=this.input.getStyle('background-color');
|
2008-07-28 18:30:40 +02:00
|
|
|
this.fx = new Fx.Tween(this.input,{property: 'background-color',duration:600});
|
2008-10-06 15:11:14 +02:00
|
|
|
this.generateBtn = new Element('img');
|
|
|
|
this.generateBtn.addClass('btn');
|
|
|
|
this.generateBtn.src='templates/images/generate.png';
|
|
|
|
this.generateBtn.addEvent('click',this.refreshValue.bind(this));
|
|
|
|
this.generateBtn.injectAfter(this.input);
|
2008-07-28 18:30:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getInput: function() {
|
|
|
|
return this.input;
|
|
|
|
},
|
|
|
|
|
|
|
|
getValue: function() {
|
|
|
|
return this.input.value;
|
|
|
|
},
|
|
|
|
|
|
|
|
refreshValue: function() {
|
|
|
|
if (this._auto) {
|
2008-10-06 15:11:14 +02:00
|
|
|
var val=getFData(this.format,this.parent,'getValue');
|
|
|
|
if ($type(this.params['withoutAccents'])) {
|
|
|
|
if(this.params['withoutAccents']) {
|
|
|
|
val = replaceAccents(val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
});
|