124 lines
4.6 KiB
JavaScript
124 lines
4.6 KiB
JavaScript
/*
|
|
* Module made by Nukium
|
|
*
|
|
* @author Nukium
|
|
* @copyright 2018 Nukium SAS
|
|
* @license All rights reserved
|
|
*
|
|
* ███ ██ ██ ██ ██ ██ ██ ██ ██ ███ ███
|
|
* ████ ██ ██ ██ ██ ██ ██ ██ ██ ████ ████
|
|
* ██ ██ ██ ██ ██ █████ ██ ██ ██ ██ ████ ██
|
|
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
|
* ██ ████ ██████ ██ ██ ██ ██████ ██ ██
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
* THE SOFTWARE.
|
|
*/
|
|
$(document).ready(function() {
|
|
|
|
$('.module-page .btn.start').on('click', function(e) {
|
|
e.preventDefault();
|
|
$('#form-nav .nav-item:eq(1) a').tab('show');
|
|
});
|
|
|
|
$('#form-gls_log').hide();
|
|
|
|
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
|
if($(e.target).is('a[href="#nkmgls-tab-4"]')) {
|
|
$('#form-gls_log').show();
|
|
} else {
|
|
$('#form-gls_log').hide();
|
|
}
|
|
$('.accordion-link').removeClass('active');
|
|
$(e.target).addClass('active');
|
|
if ($(window).width() < 768) {
|
|
$('html, body').animate({ scrollTop: $(e.target).offset().top }, 'slow');
|
|
}
|
|
});
|
|
|
|
$('.module-page .js-tabs .nav-link').each(function(idx) {
|
|
var navlink = $(this).clone(true).addClass('accordion-link');
|
|
if(idx == 0) {
|
|
navlink.addClass('active');
|
|
}
|
|
$(navlink).insertBefore($(this).attr('href'))
|
|
});
|
|
|
|
$('.module-page .js-btn-save').on('click', function(e) {
|
|
e.preventDefault();
|
|
$('#module_form_submit_btn_1').trigger('click');
|
|
});
|
|
|
|
$('#module_form').on('submit', function(e) {
|
|
$('#module_form').attr('action', $('#module_form').attr('action') + '&tab=' + $('#form-nav .nav-item.active > a').attr('href').substr(1));
|
|
});
|
|
|
|
if($('form#form-gls_log').length > 0) {
|
|
$('#form-gls_log').attr('action', $('#form-gls_log').attr('action').replace('#', '&tab=nkmgls-tab-4#'));
|
|
}
|
|
|
|
$('.table.gls_log a').each(function() {
|
|
$(this).attr('href', $(this).attr('href') + '&tab=nkmgls-tab-4');
|
|
});
|
|
|
|
$('.form-footer .btn.save').tooltip();
|
|
|
|
$('input[name="GLS_API_SHOP_RETURN_ADDRESS"]').on('change', function(e) {
|
|
|
|
if($(this).is(':checked')) {
|
|
|
|
$(this).closest('.form-group').nextAll().hide();
|
|
|
|
if($(this).val() == '1') {
|
|
|
|
$(this).closest('.form-group').nextAll('.default-address').show();
|
|
$(this).closest('.form-group').nextAll(':not(.default-address)').find('input, select, textarea').prop('disabled', true);
|
|
|
|
} else {
|
|
|
|
$(this).closest('.form-group').nextAll(':not(.default-address)').find('input, select, textarea').prop('disabled', false);
|
|
$(this).closest('.form-group').nextAll(':not(.default-address)').show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$('input[name="GLS_API_SHOP_RETURN_SERVICE"]').on('change', function(e) {
|
|
|
|
if($(this).is(':checked')) {
|
|
|
|
if($(this).val() == '1') {
|
|
|
|
if($('input[name="GLS_API_SHOP_RETURN_ADDRESS"]:checked').val() == '1') {
|
|
$(this).closest('.form-group').nextAll().stop(true, false).slideDown();
|
|
} else {
|
|
$(this).closest('.form-group').nextAll().stop(true, false).slideDown();
|
|
}
|
|
|
|
} else {
|
|
|
|
$(this).closest('.form-group').nextAll().stop(true, false).slideUp();
|
|
|
|
}
|
|
|
|
$('input[name="GLS_API_SHOP_RETURN_ADDRESS"]').trigger('change');
|
|
|
|
}
|
|
|
|
});
|
|
$('input[name="GLS_API_SHOP_RETURN_SERVICE"]').trigger('change');
|
|
|
|
var match = RegExp('[?&]tab=([^&]*)').exec(window.location.search);
|
|
var result = (match && decodeURIComponent(match[1].replace(/\+/g, ' ')));
|
|
if(result !== null) {
|
|
jQuery('#form-nav .nav-item a[href="#' + result + '"]').tab('show');
|
|
}
|
|
|
|
}); |