- 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

@ -54,6 +54,24 @@ var LSform = new Class({
document.getElement('li.LSform_layout').getFirst('a').fireEvent('click'); 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) { onTabBtnClick: function(event,li) {
if ($type(event)) { if ($type(event)) {
@ -62,37 +80,35 @@ var LSform = new Class({
event.target.blur(); event.target.blur();
} }
if (this._currentTab!='default_value') { if (this._currentTab!=li) {
var oldLi = $$('li.LSform_layout[title='+this._currentTab+']'); if (this._currentTab!='default_value') {
if ($type(oldLi)) { this._currentTab.removeClass('LSform_layout_current');
oldLi.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 this._currentTab = li;
var ul = div.getElement('ul.LSform'); li.addClass('LSform_layout_current');
if ($type(ul)) { var div = this.getLayout(li);
var el = ul.getElement('input'); if ($type(div)) {
if (!$type(el)) { div.addClass('LSform_layout_current');
el = ul.getElement('textarea');
} // Focus
if (!$type(el)) { var ul = div.getElement('ul.LSform');
el = ul.getElement('select'); if ($type(ul)) {
} var el = ul.getElement('input');
if ($type(el)) { if (!$type(el)) {
if(el.type!='hidden') { el = ul.getElement('textarea');
el.focus(); }
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'); 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'>