Integrated bootstrap tabs into the backend services page.

This commit is contained in:
alext 2017-09-22 14:53:41 +02:00
parent 80c6b61686
commit 861f49c259
2 changed files with 167 additions and 173 deletions

View file

@ -22,15 +22,15 @@
</script> </script>
<div id="services-page" class="container-fluid backend-page"> <div id="services-page" class="container-fluid backend-page">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="services-tab tab active"><a><?= lang('services') ?></a></li> <li role="presentation" class="active"><a href="#services" aria-controls="services" role="tab" data-toggle="tab"><?= lang('services') ?></a></li>
<li role="presentation" class="categories-tab tab"><a><?= lang('categories') ?></a></li> <li role="presentation"><a href="#categories" aria-controls="categories" role="tab" data-toggle="tab"><?= lang('categories') ?></a></li>
</ul> </ul>
<div class="tab-content">
<!-- SERVICES TAB --> <!-- SERVICES TAB -->
<div id="services" class="tab-content"> <div role="tabpanel" class="tab-pane active" id="services">
<?php // FILTER SERVICES ?>
<div class="row"> <div class="row">
<div id="filter-services" class="filter-records column col-xs-12 col-sm-5"> <div id="filter-services" class="filter-records column col-xs-12 col-sm-5">
<form class="input-append"> <form class="input-append">
@ -139,7 +139,7 @@
<!-- CATEGORIES TAB --> <!-- CATEGORIES TAB -->
<div id="categories" class="tab-content" style="display:none;"> <div role="tabpanel" class="tab-pane" id="categories">
<div class="row"> <div class="row">
<div id="filter-categories" class="filter-records column col-xs-12 col-sm-5"> <div id="filter-categories" class="filter-records column col-xs-12 col-sm-5">
<form class="input-append"> <form class="input-append">
@ -204,4 +204,5 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</div> </div>

View file

@ -76,16 +76,10 @@ window.BackendServices = window.BackendServices || {};
* *
* Changes the displayed tab. * Changes the displayed tab.
*/ */
$('.tab').click(function() { $('a[data-toggle="tab"]').on('shown.bs.tab', function() {
$(this).parent().find('.active').removeClass('active'); if ($(this).attr('href') === '#services') {
$(this).addClass('active');
$('.tab-content').hide();
if ($(this).hasClass('services-tab')) { // display services tab
$('#services').show();
helper = servicesHelper; helper = servicesHelper;
} else if ($(this).hasClass('categories-tab')) { // display categories tab } else if ($(this).attr('href') === '#categories') {
$('#categories').show();
helper = categoriesHelper; helper = categoriesHelper;
} }
@ -105,13 +99,13 @@ window.BackendServices = window.BackendServices || {};
* Use this method every time a change is made to the service categories db table. * Use this method every time a change is made to the service categories db table.
*/ */
exports.updateAvailableCategories = function() { exports.updateAvailableCategories = function() {
var postUrl = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_service_categories'; var url = GlobalVariables.baseUrl + '/index.php/backend_api/ajax_filter_service_categories';
var postData = { var data = {
csrfToken: GlobalVariables.csrfToken, csrfToken: GlobalVariables.csrfToken,
key: '' key: ''
}; };
$.post(postUrl, postData, function(response) { $.post(url, data, function(response) {
if (!GeneralFunctions.handleAjaxExceptions(response)) { if (!GeneralFunctions.handleAjaxExceptions(response)) {
return; return;
} }
@ -125,6 +119,5 @@ window.BackendServices = window.BackendServices || {};
}); });
$select.append(new Option('- ' + EALang.no_category + ' -', null)).val('null'); $select.append(new Option('- ' + EALang.no_category + ' -', null)).val('null');
}, 'json').fail(GeneralFunctions.ajaxFailureHandler); }, 'json').fail(GeneralFunctions.ajaxFailureHandler);
} };
})(window.BackendServices); })(window.BackendServices);