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

View file

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