// Toolbar improvement

This commit is contained in:
Jerome Nadaud
2013-10-09 15:18:54 +02:00
parent 4242e485c7
commit 81677cff44
2 changed files with 23 additions and 29 deletions
@@ -24,17 +24,17 @@
*}
{if $show_toolbar}
<div class="panel-footer">
<div class="panel-footer">
{foreach from=$toolbar_btn item=btn key=k}
{if $k != 'modules-list'}
<a id="desc-{$table}-{if isset($btn.imgclass)}{$btn.imgclass}{else}{$k}{/if}" class="btn btn-default" {if isset($btn.href)}href="{$btn.href}"{/if} {if isset($btn.target) && $btn.target}target="_blank"{/if}{if isset($btn.js) && $btn.js}onclick="{$btn.js}"{/if}>
<i class="process-icon-{if isset($btn.imgclass)}{$btn.imgclass}{else}{$k}{/if} {if isset($btn.class)}{$btn.class}{/if}" ></i> {l s=$btn.desc}
<i class="process-icon-{if isset($btn.imgclass)}{$btn.imgclass}{else}{$k}{/if} {if isset($btn.class)}{$btn.class}{/if}" ></i> <span {if isset($btn.force_desc) && $btn.force_desc == true } class="locked" {/if}>{$btn.desc}</span>
</a>
{/if}
{/foreach}
<script language="javascript" type="text/javascript">
//<![CDATA[
var submited = false
var submited = false;
$(function() {
//get reference on save link
@@ -49,30 +49,26 @@
btn_save_and_stay = $('i[class~="process-icon-save-and-stay"]').parent();
//get reference on current save link label
lbl_save = $('#desc-{$table}-save div');
lbl_save = $('#desc-{$table}-save');
//override save link label with submit button value
if (btn_submit.val().length > 0)
lbl_save.html(btn_submit.attr("value"));
if (btn_submit.html().length > 0)
lbl_save.find('span').html(btn_submit.html());
if (btn_save_and_stay.length > 0)
{
//get reference on current save link label
lbl_save_and_stay = $('#desc-{$table}-save-and-stay div');
lbl_save_and_stay = $('#desc-{$table}-save-and-stay');
//override save and stay link label with submit button value
if (btn_submit.val().length > 0 && lbl_save_and_stay && !lbl_save_and_stay.hasClass('locked'))
{
lbl_save_and_stay.html(btn_submit.val() + " {l s='and stay'} ");
}
if (btn_submit.html().length > 0 && lbl_save_and_stay && !lbl_save_and_stay.hasClass('locked'))
lbl_save_and_stay.find('span').html(btn_submit.html() + " {l s='and stay'} ");
}
//hide standard submit button
btn_submit.hide();
//bind enter key press to validate form
$('#{$table}_form').keypress(function (e) {
$('#{$table}_form').find('input').keypress(function (e) {
if (e.which == 13 && e.target.localName != 'textarea')
$('#desc-{$table}-save').click();
});
@@ -38,7 +38,7 @@
<li>
<a id="page-header-desc-{$table}-{if isset($btn.imgclass)}{$btn.imgclass}{else}{$k}{/if}" class="toolbar_btn" {if isset($btn.href)}href="{$btn.href}"{/if} title="{$btn.desc}" {if isset($btn.target) && $btn.target}target="_blank"{/if}{if isset($btn.js) && $btn.js}onclick="{$btn.js}"{/if}>
<i class="{if isset($btn.icon)}{$btn.icon}{else}process-icon-{if isset($btn.imgclass)}{$btn.imgclass}{else}{$k}{/if}{/if} {if isset($btn.class)}{$btn.class}{/if}" ></i>
<div {if isset($btn.force_desc) && $btn.force_desc == true } class="locked" {/if}>{$btn.desc}</div>
<span {if isset($btn.force_desc) && $btn.force_desc == true } class="locked" {/if}>{$btn.desc}</span>
</a>
</li>
{/foreach}
@@ -46,8 +46,9 @@
<script language="javascript" type="text/javascript">
//<![CDATA[
var submited = false
var submited = false;
var modules_list_loaded = false;
$(function() {
//get reference on save link
btn_save = $('i[class~="process-icon-save"]').parent();
@@ -61,32 +62,28 @@
btn_save_and_stay = $('i[class~="process-icon-save-and-stay"]').parent();
//get reference on current save link label
lbl_save = $('#desc-{$table}-save div');
lbl_save = $('#page-header-desc-{$table}-save');
//override save link label with submit button value
if (btn_submit.val().length > 0)
lbl_save.html(btn_submit.attr("value"));
if (btn_submit.html().length > 0)
lbl_save.find('span').html(btn_submit.html());
if (btn_save_and_stay.length > 0)
{
//get reference on current save link label
lbl_save_and_stay = $('#desc-{$table}-save-and-stay div');
lbl_save_and_stay = $('#page-header-desc-{$table}-save-and-stay');
//override save and stay link label with submit button value
if (btn_submit.val().length > 0 && lbl_save_and_stay && !lbl_save_and_stay.hasClass('locked'))
{
lbl_save_and_stay.html(btn_submit.val() + " {l s='and stay'} ");
}
if (btn_submit.html().length > 0 && lbl_save_and_stay && !lbl_save_and_stay.hasClass('locked'))
lbl_save_and_stay.find('span').html(btn_submit.html() + " {l s='and stay'} ");
}
//hide standard submit button
btn_submit.hide();
//bind enter key press to validate form
$('#{$table}_form').keypress(function (e) {
$('#{$table}_form').find('input').keypress(function (e) {
if (e.which == 13 && e.target.localName != 'textarea')
$('#desc-{$table}-save').click();
$('#page-header-desc-{$table}-save').click();
});
//submit the form
{block name=formSubmit}
@@ -95,7 +92,7 @@
if (submited)
return false;
submited = true;
//add hidden input to emulate submit button click when posting the form -> field name posted
btn_submit.before('<input type="hidden" name="'+btn_submit.attr("name")+'" value="1" />');
@@ -115,6 +112,7 @@
}
{/block}
}
{if isset($tab_modules_open)}
if ({$tab_modules_open})
openModulesList();