- LSform :

-> LSform_layout : Utilisation des id plutot que title pour repérer les div
		 et les li
This commit is contained in:
Benjamin Renard 2008-11-10 02:03:44 +00:00
parent 6448f263be
commit 9ed7425d0c
3 changed files with 50 additions and 34 deletions

View file

@ -55,6 +55,24 @@ var LSform = new Class({
} }
}, },
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) { onTabBtnClick: function(event,li) {
if ($type(event)) { if ($type(event)) {
event = new Event(event); event = new Event(event);
@ -62,22 +80,19 @@ var LSform = new Class({
event.target.blur(); event.target.blur();
} }
if (this._currentTab!=li) {
if (this._currentTab!='default_value') { if (this._currentTab!='default_value') {
var oldLi = $$('li.LSform_layout[title='+this._currentTab+']'); this._currentTab.removeClass('LSform_layout_current');
if ($type(oldLi)) { var oldDiv = this.getLayout(this._currentTab);
oldLi.removeClass('LSform_layout_current');
}
var oldDiv = $$('div.LSform_layout[title='+this._currentTab+']');
if ($type(oldDiv)) { if ($type(oldDiv)) {
oldDiv.removeClass('LSform_layout_current'); oldDiv.removeClass('LSform_layout_current');
} }
} }
this._currentTab = li.title; this._currentTab = li;
li.addClass('LSform_layout_current'); li.addClass('LSform_layout_current');
var div = $$('div.LSform_layout[title='+this._currentTab+']'); var div = this.getLayout(li);
if ($type(div)) { if ($type(div)) {
div = div[0];
div.addClass('LSform_layout_current'); div.addClass('LSform_layout_current');
// Focus // Focus
@ -97,6 +112,7 @@ var LSform = new Class({
} }
} }
} }
}
}, },
@ -201,7 +217,7 @@ var LSform = new Class({
var layout = ul.getParent('div.LSform_layout_active'); var layout = ul.getParent('div.LSform_layout_active');
if ($type(layout)) { if ($type(layout)) {
var li = document.getElement('li.LSform_layout[title='+layout.title+']'); var li = getLayoutBtn(layout);
if($type(li)) { if($type(li)) {
li.addClass('LSform_layout_errors'); li.addClass('LSform_layout_errors');
} }

View file

@ -4,7 +4,7 @@
<!-- Tabs - Start Title --> <!-- Tabs - Start Title -->
<ul class='LSform_layout'> <ul class='LSform_layout'>
{foreach from=$LSform_layout item=tab key=tab_key} {foreach from=$LSform_layout item=tab key=tab_key}
<li class='LSform_layout' title='{$tab_key}'><a href="#{$tab_key}">{$tab.label}</a></li> <li class='LSform_layout' id='LSform_layout_btn_{$tab_key}'><a href="#{$tab_key}">{$tab.label}</a></li>
{/foreach} {/foreach}
</ul> </ul>
<!-- Tabs - End Title --> <!-- Tabs - End Title -->
@ -13,7 +13,7 @@
{foreach from=$LSform_layout item=tab key=tab_key} {foreach from=$LSform_layout item=tab key=tab_key}
<a name='{$tab_key}'></a> <a name='{$tab_key}'></a>
<h2 class='LSform_layout'>{$tab.label}</h2> <h2 class='LSform_layout'>{$tab.label}</h2>
<div class='LSform LSform_layout' title='{$tab_key}'> <div class='LSform LSform_layout' id='LSform_layout_div_{$tab_key}'>
{if $LSformElement_image!='' && $tab.img==1} {if $LSformElement_image!='' && $tab.img==1}
<div class='LSformElement_image{if $LSformElement_image_errors} LSformElement_image_errors{/if}'> <div class='LSformElement_image{if $LSformElement_image_errors} LSformElement_image_errors{/if}'>
{if $LSformElement_image_actions!='' && !$LSformElement_image_errors} {if $LSformElement_image_actions!='' && !$LSformElement_image_errors}

View file

@ -4,7 +4,7 @@
<!-- Tabs - Start Title --> <!-- Tabs - Start Title -->
<ul class='LSform_layout'> <ul class='LSform_layout'>
{foreach from=$LSform_layout item=tab key=tab_key} {foreach from=$LSform_layout item=tab key=tab_key}
<li class='LSform_layout' title='{$tab_key}'><a href="#{$tab_key}">{$tab.label}</a></li> <li class='LSform_layout' id='LSform_layout_btn_{$tab_key}'><a href="#{$tab_key}">{$tab.label}</a></li>
{/foreach} {/foreach}
</ul> </ul>
<!-- Tabs - End Title --> <!-- Tabs - End Title -->
@ -13,7 +13,7 @@
{foreach from=$LSform_layout item=tab key=tab_key} {foreach from=$LSform_layout item=tab key=tab_key}
<a name='{$tab_key}'></a> <a name='{$tab_key}'></a>
<h2 class='LSform_layout'>{$tab.label}</h2> <h2 class='LSform_layout'>{$tab.label}</h2>
<div class='LSform LSform_layout' title='{$tab_key}'> <div class='LSform LSform_layout' id='LSform_layout_div_{$tab_key}'>
{if $LSformElement_image!='' && $tab.img==1} {if $LSformElement_image!='' && $tab.img==1}
<div class='LSformElement_image'> <div class='LSformElement_image'>