From 9ed7425d0c69269c793a93e2ced37ba1d883244f Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 10 Nov 2008 02:03:44 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSform=20:=20=09->=20LSform=5Flayout=20:=20?= =?UTF-8?q?Utilisation=20des=20id=20plutot=20que=20title=20pour=20rep?= =?UTF-8?q?=C3=A9rer=20les=20div=20=09=09=20et=20les=20li?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trunk/includes/js/LSform.js | 76 +++++++++++++++---------- trunk/templates/default/LSform.tpl | 4 +- trunk/templates/default/LSform_view.tpl | 4 +- 3 files changed, 50 insertions(+), 34 deletions(-) diff --git a/trunk/includes/js/LSform.js b/trunk/includes/js/LSform.js index 7907dd02..a1a95cce 100644 --- a/trunk/includes/js/LSform.js +++ b/trunk/includes/js/LSform.js @@ -54,6 +54,24 @@ var LSform = new Class({ document.getElement('li.LSform_layout').getFirst('a').fireEvent('click'); } }, + + getLayoutBtn: function(div) { + var getName = new RegExp('LSform_layout_div_(.*)'); + var name = getName.exec(div.id); + if (!name) { + return; + } + return $('LSform_layout_btn_'+name[1]); + }, + + getLayout: function(btn) { + var getName = new RegExp('LSform_layout_btn_(.*)'); + var name = getName.exec(btn.id); + if (!name) { + return; + } + return $('LSform_layout_div_'+name[1]); + }, onTabBtnClick: function(event,li) { if ($type(event)) { @@ -62,37 +80,35 @@ var LSform = new Class({ event.target.blur(); } - if (this._currentTab!='default_value') { - var oldLi = $$('li.LSform_layout[title='+this._currentTab+']'); - if ($type(oldLi)) { - oldLi.removeClass('LSform_layout_current'); + if (this._currentTab!=li) { + if (this._currentTab!='default_value') { + this._currentTab.removeClass('LSform_layout_current'); + var oldDiv = this.getLayout(this._currentTab); + if ($type(oldDiv)) { + oldDiv.removeClass('LSform_layout_current'); + } } - var oldDiv = $$('div.LSform_layout[title='+this._currentTab+']'); - if ($type(oldDiv)) { - oldDiv.removeClass('LSform_layout_current'); - } - } - - this._currentTab = li.title; - li.addClass('LSform_layout_current'); - var div = $$('div.LSform_layout[title='+this._currentTab+']'); - if ($type(div)) { - div = div[0]; - div.addClass('LSform_layout_current'); - // Focus - var ul = div.getElement('ul.LSform'); - if ($type(ul)) { - var el = ul.getElement('input'); - if (!$type(el)) { - el = ul.getElement('textarea'); - } - if (!$type(el)) { - el = ul.getElement('select'); - } - if ($type(el)) { - if(el.type!='hidden') { - el.focus(); + this._currentTab = li; + li.addClass('LSform_layout_current'); + var div = this.getLayout(li); + if ($type(div)) { + div.addClass('LSform_layout_current'); + + // Focus + var ul = div.getElement('ul.LSform'); + if ($type(ul)) { + var el = ul.getElement('input'); + if (!$type(el)) { + el = ul.getElement('textarea'); + } + if (!$type(el)) { + el = ul.getElement('select'); + } + if ($type(el)) { + if(el.type!='hidden') { + el.focus(); + } } } } @@ -201,7 +217,7 @@ var LSform = new Class({ var layout = ul.getParent('div.LSform_layout_active'); if ($type(layout)) { - var li = document.getElement('li.LSform_layout[title='+layout.title+']'); + var li = getLayoutBtn(layout); if($type(li)) { li.addClass('LSform_layout_errors'); } diff --git a/trunk/templates/default/LSform.tpl b/trunk/templates/default/LSform.tpl index bcdd75a3..76cbc9e1 100644 --- a/trunk/templates/default/LSform.tpl +++ b/trunk/templates/default/LSform.tpl @@ -4,7 +4,7 @@ @@ -13,7 +13,7 @@ {foreach from=$LSform_layout item=tab key=tab_key}

{$tab.label}

-
+
{if $LSformElement_image!='' && $tab.img==1}
{if $LSformElement_image_actions!='' && !$LSformElement_image_errors} diff --git a/trunk/templates/default/LSform_view.tpl b/trunk/templates/default/LSform_view.tpl index 2bbea67e..00fa895e 100644 --- a/trunk/templates/default/LSform_view.tpl +++ b/trunk/templates/default/LSform_view.tpl @@ -4,7 +4,7 @@ @@ -13,7 +13,7 @@ {foreach from=$LSform_layout item=tab key=tab_key}

{$tab.label}

-
+
{if $LSformElement_image!='' && $tab.img==1}