From 2216eb03e328a330bfca2bb10914e554095aad2c Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Fri, 14 Nov 2008 15:32:09 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSformElement=5Fselect=5Fobject=20:=20Pour?= =?UTF-8?q?=20une=20meilleur=20compatibilit=C3=A9=20(IE),=20le=20=09tablea?= =?UTF-8?q?u=20pour=20l'ajout=20rapide=20d'une=20valeur=20est=20cr=C3=A9?= =?UTF-8?q?=C3=A9=20directement=20dans=20le=20=20=20template.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default/LSformElement_select_object.css | 8 ++--- .../js/LSformElement_select_object_field.js | 29 ++++++++++--------- .../default/LSformElement_select_object.tpl | 25 +++++++++++----- 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/trunk/css/default/LSformElement_select_object.css b/trunk/css/default/LSformElement_select_object.css index 08ca7da1..7c3d5ac7 100644 --- a/trunk/css/default/LSformElement_select_object.css +++ b/trunk/css/default/LSformElement_select_object.css @@ -40,15 +40,15 @@ img.LSformElement_select_object_deleteBtn { /* LSformElement_select_object_searchAdd */ input.LSformElement_select_object_searchAdd { border: 1px solid #ccc; - width: 134px; - background-image: url(../../images/default/find.png); - background-repeat: no-repeat; + width: 140px !important; + background: #fff url(../../images/default/find.png) !important; + background-repeat: no-repeat !important; padding-left: 18px; } ul.LSformElement_select_object_searchAdd { border: 1px solid #ccc; - width: 152px; + width: 138px; margin: 0; margin-top: 0.1em; max-height: 10em; diff --git a/trunk/includes/js/LSformElement_select_object_field.js b/trunk/includes/js/LSformElement_select_object_field.js index edfa3382..5046976d 100644 --- a/trunk/includes/js/LSformElement_select_object_field.js +++ b/trunk/includes/js/LSformElement_select_object_field.js @@ -162,6 +162,16 @@ var LSformElement_select_object_field = new Class({ addLi: function(name,dn) { if (this.params.multiple) { // Multiple + var current = 0; + this.ul.getElements("input[type=hidden]").each(function(input){ + if ((input.value==dn)&&(input.name != this.name+'[]')) { + current=input; + } + },this); + if (current) { + this.toggleDeleteLi(current.getParent()); + return true; + } var li = new Element('li'); li.addClass('LSformElement_select_object'); @@ -249,6 +259,10 @@ var LSformElement_select_object_field = new Class({ onDeleteBtnClick: function(img) { var li = img.getParent(); + this.toggleDeleteLi(li); + }, + + toggleDeleteLi: function(li) { var a = li.getFirst('a'); var input = li.getFirst('input'); if (input.value!="") { @@ -267,23 +281,12 @@ var LSformElement_select_object_field = new Class({ if (this._searchAddOpen==0) { this._searchAddOpen = 1; if (!$type(this.searchAddInput)) { - this.table = new Element('table'); - this.table.addClass('LSformElement_select_object_searchAdd'); - this.tr = new Element('tr'); - this.tr.addClass('LSformElement_select_object_searchAdd'); - this.tr.injectInside(this.table); - this.td = new Element('td'); - this.td.addClass('LSformElement_select_object_searchAdd'); - this.td.injectInside(this.tr); + this.tr = this.ul.getParent().getParent(); this.td2 = new Element('td'); this.td2.addClass('LSformElement_select_object_searchAdd'); this.td2.injectInside(this.tr); - - this.ul.injectInside(this.td); - this.table.injectInside(this.dd); - this.searchAddInput = new Element('input'); this.searchAddInput.addClass('LSformElement_select_object_searchAdd'); this.searchAddInput.addEvent('keydown',this.onKeyUpSearchAddInput.bindWithEvent(this)); @@ -352,7 +355,7 @@ var LSformElement_select_object_field = new Class({ addSearchAddLi: function(name,dn) { var current = 0; this.ul.getElements("input[type=hidden]").each(function(input){ - if (input.value==dn) { + if ((input.value==dn)&&(input.name == this.name+'[]')) { current=1; } },this); diff --git a/trunk/templates/default/LSformElement_select_object.tpl b/trunk/templates/default/LSformElement_select_object.tpl index 570411ec..64ecff2f 100644 --- a/trunk/templates/default/LSformElement_select_object.tpl +++ b/trunk/templates/default/LSformElement_select_object.tpl @@ -1,7 +1,18 @@ - +{if !$freeze} + + + + + +
+{/if} +
    + {foreach from=$values item=txt key=dn} +
  • {include file=$fieldTemplate}
  • + {foreachelse} +
  • {include file=$fieldTemplate}
  • + {/foreach} +
+{if !$freeze} +
+{/if}