// Code cleaning (backoffice javascript)

This commit is contained in:
Damien Metzger
2013-10-11 10:40:57 +02:00
parent bb35a5b004
commit 28118cf33a
7 changed files with 134 additions and 121 deletions
+42 -11
View File
@@ -110,16 +110,6 @@ $( document ).ready(function() {
$('.expanded').removeClass('expanded');
});
function animateGoTop() {
if ($(window).scrollTop())
{
$('#go-top:hidden').stop(true, true).fadeIn();
$('#go-top:hidden').removeClass('hide');
}
else
$('#go-top').stop(true, true).fadeOut();
}
$("#go-top").click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow");
return false;
@@ -129,4 +119,45 @@ $( document ).ready(function() {
});
animateGoTop();
});
});
function animateGoTop() {
if ($(window).scrollTop())
{
$('#go-top:hidden').stop(true, true).fadeIn();
$('#go-top:hidden').removeClass('hide');
}
else
$('#go-top').stop(true, true).fadeOut();
}
function openModulesList()
{
if (!modules_list_loaded)
{
$.ajax({
type: "POST",
url : admin_modules_link,
async: true,
data : {
ajax : "1",
controller : "AdminModules",
action : "getTabModulesList",
tab_modules_list : tab_modules_list,
back_tab_modules_list : window.location.href
},
success : function(data)
{
$('#modules_list_container_tab').html(data).slideDown();
$('#modules_list_loader').hide();
modules_list_loaded = true;
}
});
}
else
{
$('#modules_list_container_tab').slideDown();
$('#modules_list_loader').hide();
}
return false;
}
@@ -1,4 +1,28 @@
{include file='controllers/modules/header.tpl'}
{*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{include file='controllers/modules/top.tpl'}
<div class="panel">
<div class="panel-heading">
<i class="icon-list-ul"></i>
@@ -22,28 +22,7 @@
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{$kpis}
<div class="page-head">
<h2 class="page-title">
{l s='List of modules'}
</h2>
<div class="page-bar toolbarBox">
<div class="btn-toolbar">
<ul class="cc_button nav nav-pills pull-right">
{if $add_permission eq '1'}
<li>
<a id="desc-module-new" class="toolbar_btn" href="#top_container" onclick="$('#module_install').slideToggle();" title="{l s='Add a new module'}">
<i class="process-icon-new-module" ></i>
<div>{l s='Add a new module'}</div>
</a>
</li>
{/if}
</ul>
</div>
</div>
</div>
{include file='controllers/modules/top.tpl'}
{if $add_permission eq '1'}
<div id="module_install" class="row" style="{if !isset($smarty.post.downloadflag)}display: none;{/if}">
@@ -0,0 +1,45 @@
{*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2013 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
{$kpis}
<div class="page-head">
<h2 class="page-title">
{l s='List of modules'}
</h2>
<div class="page-bar toolbarBox">
<div class="btn-toolbar">
<ul class="cc_button nav nav-pills pull-right">
{if $add_permission eq '1'}
<li>
<a id="desc-module-new" class="toolbar_btn" href="#top_container" onclick="$('#module_install').slideToggle();" title="{l s='Add a new module'}">
<i class="process-icon-new-module" ></i>
<div>{l s='Add a new module'}</div>
</a>
</li>
{/if}
</ul>
</div>
</div>
</div>
@@ -72,6 +72,8 @@
var currentIndex = '{$currentIndex}';
var default_language = '{$default_language|intval}';
var choose_language_translate = "{l s='Choose language' slashes=1}";
var admin_modules_link = '{$link->getAdminLink("AdminModules")|addslashes}';
var tab_modules_list = '{if isset($tab_modules_list) && $tab_modules_list}{$tab_modules_list|addslashes}{/if}';
</script>
{/if}
{if isset($css_files)}
@@ -68,8 +68,7 @@
if (btn_submit.html().length > 0)
lbl_save.find('span').html(btn_submit.html());
if (btn_save_and_stay.length > 0)
{
if (btn_save_and_stay.length > 0) {
//get reference on current save link label
lbl_save_and_stay = $('#page-header-desc-{$table}-save-and-stay');
@@ -100,12 +99,10 @@
return false;
});
if (btn_save_and_stay)
{
if (btn_save_and_stay) {
btn_save_and_stay.click(function() {
//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")+'AndStay" value="1" />');
$('#{$table}_form').submit();
return false;
});
@@ -113,47 +110,17 @@
{/block}
}
{if isset($tab_modules_open)}
if ({$tab_modules_open})
openModulesList();
{if isset($tab_modules_open) && $tab_modules_open}
$('#modules_list_container').modal('show');
openModulesList();
{/if}
});
{if isset($tab_modules_list)}
$('.process-icon-modules-list').parent('a').unbind().bind('click', function (){
openModulesList();
});
function openModulesList()
{
$('#modules_list_container').modal('show');
if (!modules_list_loaded)
{
$.ajax({
type: "POST",
url : '{$admin_module_ajax_url}',
async: true,
data : {
ajax : "1",
controller : "AdminModules",
action : "getTabModulesList",
tab_modules_list : '{$tab_modules_list}',
back_tab_modules_list : '{$back_tab_modules_list}'
},
success : function(data)
{
$('#modules_list_container_tab').html(data).slideDown();
$('#modules_list_loader').hide();
modules_list_loaded = true;
}
});
}
else
{
$('#modules_list_container_tab').slideDown();
$('#modules_list_loader').hide();
}
return false;
}
$('.process-icon-modules-list').parent('a').unbind().bind('click', function (){
$('#modules_list_container').modal('show');
openModulesList();
});
{/if}
//]]>
</script>
+9 -44
View File
@@ -46,7 +46,7 @@
{/foreach}
</ul>
<script language="javascript" type="text/javascript">
<script type="text/javascript">
//<![CDATA[
var submited = false
var modules_list_loaded = false;
@@ -71,16 +71,12 @@
if (btn_save_and_stay.length > 0)
{
//get reference on current save link label
lbl_save_and_stay = $('#desc-{$table}-save-and-stay div');
//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'} ");
}
}
//hide standard submit button
@@ -117,47 +113,16 @@
}
{/block}
}
{if isset($tab_modules_open)}
if ({$tab_modules_open})
openModulesList();
{if isset($tab_modules_open) && $tab_modules_open}
$('#modules_list_container').slideDown();
openModulesList();
{/if}
});
{if isset($tab_modules_list)}
$('.process-icon-modules-list').parent('a').unbind().bind('click', function (){
openModulesList();
});
function openModulesList()
{
$('#modules_list_container').slideDown();
if (!modules_list_loaded)
{
$.ajax({
type: "POST",
url : '{$admin_module_ajax_url}',
async: true,
data : {
ajax : "1",
controller : "AdminModules",
action : "getTabModulesList",
tab_modules_list : '{$tab_modules_list}',
back_tab_modules_list : '{$back_tab_modules_list}'
},
success : function(data)
{
$('#modules_list_container_tab').html(data).slideDown();
$('#modules_list_loader').hide();
modules_list_loaded = true;
}
});
}
else
{
$('#modules_list_container_tab').slideDown();
$('#modules_list_loader').hide();
}
return false;
}
{if isset($tab_modules_list) && $tab_modules_list}
$('.process-icon-modules-list').parent('a').unbind().bind('click', function (){
$('#modules_list_container').slideDown();
openModulesList();
});
{/if}
//]]>
</script>