var matched, browser;
$.ajaxSetup({
beforeSend: function (xhr)
{
xhr.setRequestHeader("X-CSRF-Token",$('[name="_csrfToken"]').val());
}
});
jQuery.uaMatch = function (ua) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
/(webkit)[ \/]([\w.]+)/.exec(ua) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
/(msie)[\s?]([\w.]+)/.exec(ua) ||
/(trident)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
[];
return {
browser: match[1] || "",
version: match[2] || "0"
};
};
matched = jQuery.uaMatch(navigator.userAgent);
//IE 11+ fix (Trident)
matched.browser = matched.browser == 'trident' ? 'msie' : matched.browser;
browser = {};
if (matched.browser) {
browser[matched.browser] = true;
browser.version = matched.version;
}
// Chrome is Webkit, but Webkit is also Safari.
if (browser.chrome) {
browser.webkit = true;
} else if (browser.webkit) {
browser.safari = true;
}
jQuery.browser = browser;
// log removed - adds an extra dependency
//log(jQuery.browser)
$(document).ready(function () {
// $("button[type=submit]").on("click", function () {
// if ($("form").attr("id").length > 0){
// var formid = '#' + $("form").attr("id");
// $(formid).submit(function (event) {
// alert('fgsd');
// $("#loadingGIF").show();
// });
// }
// });
// Handle null pointer with ex_tax
var exTax = exTax || 'noET';
if ($(".ex_tax").length > 0) {
$(".ex_tax").text(exTax);
}
//Production
$.fn.dataTable.ext.errMode = 'none';
$(document).ajaxStart(function () {
//check session
$(document).bind("ajaxComplete", function (event, xmlHttprequest, ajaxOptions) {
if (xmlHttprequest.status == 403) {
this.location = loginUrl
return false;
}
});
$('#background-overlay').fadeIn(500);
$('#loadingGIF').show();
});
$(document).ajaxStop(function () {
$('#loadingGIF').hide();
$('#background-overlay').fadeOut(500);
});
var currentHref = $(location).attr('href').split('/');
if ((currentHref[4] == "stocks" || currentHref[4] == "products") && (currentHref[5] == "add" || currentHref[5] == "add-carton" || currentHref[5] == "edit-carton")) {
} else {
$('form:not(.filter) :input[type="text"]:visible:enabled:first').focus(); // default focus on each and every form after we load the page
}
// Alertify general configuration
alertify.defaults.transition = "slide";
alertify.defaults.glossary.title = "Alert";
alertify.defaults.theme.ok = "btn btn-primary";
alertify.defaults.theme.cancel = "btn btn-danger";
// Toster settings
toastr.options = {
"closeButton": false,
"debug": false,
"newestOnTop": false,
"progressBar": false,
"positionClass": "toast-top-right-custom",
"preventDuplicates": false,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
}
// dependent Dropdown
$(".dropdown_selection").chosen().change(function () {
var depedentElement = "." + $(this).attr('depedentClass');
var depedentEmptyText = $(this).attr('depedentEmptyText');
var depedentAllowEmpty = $(this).attr('depedentAllowEmpty');
var status = $(this).attr('data-status');
//console.log($(this).attr('depedentEmptyText'));
smRegionId = '';
if($(this).attr('ajaxActionCase') == 'fetchRetailerDataWithRegionAndBrand'){
var smRegionId = $('#user_region_id').val();
}
$.ajax({
url: ajaxCallUrl,
data: {
action: $(this).attr('ajaxActionCase'),
refId: this.value,
depedentAllowEmpty: depedentAllowEmpty,
mul_id: $(this).val(),
smRegionId:smRegionId,
status: status
},
type: 'post',
/*beforeSend: function(xhr){
xhr.setRequestHeader("X-CSRF-Token", $('[name="_csrfToken"]').val());
},*/
success: function (output) {
output = JSON.parse(output);
$(depedentElement).empty();
$(depedentElement).append($('