From ee3f348c88656f88fdc0b00d9c9086f56c4e250f Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Tue, 7 Oct 2008 15:48:48 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSformElement=5Ftext=5Ffield.js=20:=20Bouto?= =?UTF-8?q?n=20auto-g=C3=A9n=C3=A9ration=20manuelle=20pour=20tout=20les=20?= =?UTF-8?q?=09champs=20dont=20l'auro=20g=C3=A9n=C3=A9ration=20est=20config?= =?UTF-8?q?ur=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trunk/includes/js/LSformElement_text_field.js | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/trunk/includes/js/LSformElement_text_field.js b/trunk/includes/js/LSformElement_text_field.js index 6a36751c..b0502b3d 100644 --- a/trunk/includes/js/LSformElement_text_field.js +++ b/trunk/includes/js/LSformElement_text_field.js @@ -10,28 +10,31 @@ var LSformElement_text_field = new Class({ }, 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']; + 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'); + this.generateBtn.src='templates/images/generate.png'; + this.generateBtn.addEvent('click',this.refreshValue.bind(this)); + this.generateBtn.injectAfter(this.input); + + // Auto + var force=0; + if (this.params.autoGenerateOnModify) { + force = 1; + } + if ((this.input.value=='')||(force)) { 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); - this.oldBg=this.input.getStyle('background-color'); - this.fx = new Fx.Tween(this.input,{property: 'background-color',duration:600}); - 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); } } }