You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

677 lines
34 KiB

/* Declare app constants */
const EV_STAT = {
disp: 'AVAILABLE',
comp: 'FULL',
annu: 'CANCEL',
};
const BO_STAT = {
/* En cours de création */
en_c: 0,
/* Publié */
pub: 1,
/* Ouvert */
ouv: 2,
/* Verrouillé */
ver: 3,
/* Fermé */
fer: 4,
/* Archivé */
arc: 5,
/* Deleted */
del: 6,
/* Terminé */
ter: 7,
};
const SEAT_FEATURE = {
/* Per date (assigned per event schedule) */
per_date: 1,
/* Per date (assigned per event) */
combined: 2,
};
const REG_TYPE = {
/* for normal registration */
normal_reg: 1,
/* for waiting list registration */
waitlist_reg: 2,
/* Cancellation */
cancel_reg: 3,
};
const PROCESS_TYPE = {
/* Event Registration, */
event_reg: 1,
/* Cancel Event Registration, */
cancel_reg: 2,
/* Register to Wait list, */
waitlist_reg: 3,
/* Cancel Wait list Registration, */
cancel_wl_reg: 4,
/* Update Profile */
update_profile: 5,
/* Modify reg */
modify_reg: 6,
/* Modify waitlist reg */
modify_wl_reg: 7,
};
const SUBSCRIBE_ACTION = {
/* Register, */
register: 1,
/* Modify, */
modify: 2,
/* Cancel */
cancel: 3,
};
const EVENT_CAT = [
'PAID_EVENT',
'REGULAR_EVENT',
'ONLINE_EVENT'
];
FontAwesomeConfig = {
autoAddCss: false,
showMissingIcons:true
}
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
}
});
/* Function to be used to check if action is allowed or not */
const authorize = (pageCode, action) => {
let userAccess = (USER_PRIVS[pageCode]).map(action => parseInt(action));
return userAccess.indexOf(action) >= 0;
};
function fixHistoryMethod(name) {
var oldMethod = window.history[name];
window.history[name] = function(state, title, url) {
if (url === undefined) {
oldMethod.apply(window.history, [state, title]);
} else {
oldMethod.apply(window.history, [state, title, url]);
}
}
}
fixHistoryMethod("replaceState");
fixHistoryMethod("pushState");
$.ajaxPrefilter(function(options, originalOptions, jqXHR){
if (options.type.toLowerCase() === "post") {
if(typeof options.data === "object") {
options.data.append("csrf_token", $('meta[name="csrf_token"]').attr('content'));
} else {
// initialize `data` to empty string if it does not exist
options.data = options.data || "";
// add leading ampersand if `data` is non-empty
options.data += options.data?"&":"";
// add _token entry
options.data += "csrf_token=" + encodeURIComponent($('meta[name="csrf_token"]').attr('content'));
}
}
});
/* Prevent returning to top of page when href with ## is clicked */
$(document).on('click', "[href*=\"##\"]", function(event) {
event.preventDefault();
/* Act on the event */
});
var app = function(o, t, a) {
var e = {}
return {
set_vars: function(t) {
o.extend(e, t || {})
},
get_vars: function() {
return e
},
get_cookie: function(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
},
get_loader: function(){
return '<div class="page-loader" style="">'
+'<div class="loader">'
+'<span class="dot dot_1"></span>'
+'<span class="dot dot_2"></span>'
+'<span class="dot dot_3"></span>'
+'<span class="dot dot_4"></span>'
+'</div></div>';
},
get_loader2: function(text){
return `<div class="page-loader2" style=""><div class="loader2"><span class="export-text">${text}</span><span class="dot dot_1">`
+`</span><span class="dot dot_2"></span><span class="dot dot_3"></span><span class="dot dot_4"></span></div> </div>`;
},
remove_loader: function(text){
setTimeout(function(){
$('.page-loader').remove();
$('.page-loader2').remove();
}, 900);
},
btn_loader: function(element){
$(`${element}`).attr('disabled', 'disabled');
$(`${element}`).append(` <i class="btn_loader fa fa-spin fa-spinner"/></i>`);
},
rmbtn_loader: function(element){
setTimeout(function(){
$(`${element}`).removeAttr('disabled');
$(`${element} .btn_loader`).remove();
}, 900);
},
_notify: function(t, a) {
var e = "glyphicon glyphicon-info-sign",
i = "info"
"success" == t
? (e = "glyphicon glyphicon-ok-sign", i = "success")
: "warning" == t || "session_timeout" == t
? (e = "glyphicon glyphicon-warning-sign", i = "warning")
: "error" == t && (e = "glyphicon glyphicon-exclamation-sign", i = "danger"),
o.notifyDefaults({
type: i,
allow_dismiss: !0,
z_index: 2031
}),
o.notify({
message: '<span class="system-message">' + a + "</span>",
icon: e
})
},
modal: {
loader: function(t) {
if (o.size) {
var size = o.size;
} else {
var size = 'small';
}
app.modal.focusout_solution("on")
var a = bootbox.dialog({
title: void 0 !== t.title
? t.title
: "",
closeButton: !1,
size: size,
message: '<div class="progress"><div class="progress-bar progress-bar-info progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"><span class="sr-only">100% Complete (info)</span></div></div>'
}).on("hide.bs.modal", function(t) {
o(this).off("hidden.bs.modal"),
app.modal.focusout_solution("off")
})
return a
},
confirm_box: function(o) {
if (o.size) {
var size = o.size;
} else {
var size = 'small';
}
var t = void 0 === o.buttons || void 0 === o.buttons.confirm,
a = void 0 === o.buttons || void 0 === o.buttons.cancel
bootbox.confirm({
id: void 0 !== o.id
? o.id
: "",
className: void 0 !== o.className
? o.className
: "",
title: void 0 === o.title
? app.get_vars()._app.modal.cma_title
: o.title,
message: void 0 === o.message
? "Would you like to continue?"
: o.message,
size: size,
onEscape: !0,
buttons: {
confirm: {
label: t || void 0 === o.buttons.confirm.label
? app.get_vars()._app.btn._continue
: o.buttons.confirm.label,
className: t || void 0 === o.buttons.confirm.className
? ""
: o.buttons.confirm.className
},
cancel: {
label: a || void 0 === o.buttons.cancel.label
? app.get_vars()._app.btn._cancel
: o.buttons.cancel.label,
className: a || void 0 === o.buttons.cancel.className
? ""
: o.buttons.cancel.className
}
},
callback: function(t) {
t
? void 0 !== o._continue && o._continue()
: void 0 !== o._close && o._close()
}
})
},
focusout_solution: function(t) {
var a = o(document)
"on" == t
? a.on({
"show.bs.modal": function() {
var t = 1040 + 10 * o(".modal:visible").length
o(this).css("z-index", t),
setTimeout(function() {
o(".modal-backdrop").not(".modal-stack").css("z-index", t - 1).addClass("modal-stack")
}, 0)
},
"hidden.bs.modal": function() {
o(".modal:visible").length > 0 && setTimeout(function() {
o(document.body).addClass("modal-open")
}, 0)
}
}, ".modal")
: a.off(".modal")
},
activate_tinymce: function(t) {
var a = o(document)
"on" == t
? o(document).on("focusin", function(t) {
o(t.target).closest(".mce-window").length && t.stopImmediatePropagation()
})
: a.off("focusin")
}
},
_form: {
format_inputs: function(o, t) {
switch (o) {
case "two_digits_datetime":
if ("" != t) {
var a = moment(t, "DD/MM/YYYY HH[h]mm", !1)
if (a.isValid())
return a.format("DD/MM/YYYY HH[h]mm")
}
return ""
case "datetime":
if ("" != t.trim()) {
var e = t.replace("h", ":"),
a = moment(e, "DD/MM/Y HH:mm", !1)
if (a.isValid())
return a.format("YYYY-MM-DD HH:mm")
}
return ""
case "date":
if ("" != t.trim()) {
var e = t.replace("h", ":"),
a = moment(e, "DD/MM/Y", !1)
if (a.isValid())
return a.format("YYYY-MM-DD")
}
return ""
case "euro":
if ("0" != t.trim() && "" != t.trim()) {
var i = t.replace(",", ".")
return i = accounting.unformat(i, "", 2, " ", ",")
}
return ""
case "unformat_datetime":
if ("" != t.trim()) {
var a = moment(t, "Y-MM-DD HH:mm", !1)
if (a.isValid())
return a.format("DD/MM/Y HH[h]mm")
}
return ""
case "unformat_euro":
if ("0" != t.trim() && "" != t.trim()) {
var i = accounting.formatMoney(t, "", 2, " ", ",")
return i = i.replace(",00", "")
}
return ""
}
},
_reset: function(t) {
o(t).find("form").trigger("reset")
},
_validate: function(t) {
if (void 0 === t.validation)
return app.modal.confirm_box(t.boot_box),
!1
var a = []
void 0 !== t.validation.custom && void 0 !== t.validation.custom.rules && o.map(t.validation.custom.rules, function(t, a) {
o.validator.addMethod(a, function(o, a, e) {
return t._fnc(o, a, e)
}, t.msg)
}),
void 0 !== t.validation.custom && void 0 !== t.validation.custom.informal_val && void 0 !== t.validation.custom.informal_val._rules && (a = t.validation.custom.informal_val._rules(
void 0 !== t.boot_box.action
? t.boot_box.action
: "")),
o(t.validation.form_id).validate({
ignore: void 0 !== t.validation.ignore
? t.validation.ignore
: ":hidden",
rules: t.validation.rules,
messages: "undefined" != t.validation.messages
? t.validation.messages
: {},
highlight: function(t) {
o(t).closest(".form-group").addClass("has-error");
},
unhighlight: function(t) {
o(t).closest(".form-group").removeClass("has-error");
},
errorElement: "span",
errorClass: "help-block",
errorPlacement: function(o, a) {
$('.with-fname-error').addClass('error-msg');
if (void 0 !== t.validation.displayClass && o.addClass(t.validation.displayClass), a.hasClass("input-group") && (a.hasClass("custom-dropdown")
? o.insertAfter(a.parent().parent().parent().parent())
: o.insertAfter(a.parent().parent())), a.hasClass("radio-group")) {
var e = a.parent().parent().parent().parent()
o.insertAfter(e).css("color", "#a94442")
} else {
var e = a.parent("div")
e.find(".input-group-addon").length
? o.insertAfter(a.parent())
: o.insertAfter(a)
}
},
focusInvalid: !0,
invalidHandler: function(a, e) {
if (e.numberOfInvalids()) {
var i = o(e.errorList[0].element)
return i.focus(),
void 0 === t.validation.displayClass && o("html").animate({
scrollTop: i.offset().top
}, 1e3),
!1
}
},
showErrors: function(o, t) {
this.defaultShowErrors()
},
submitHandler: function() {
return !1
}
})
var e = o(t.validation.form_id)
return e.valid() === !0 && e.valid() !== !1
? (
0 == a.length
? void 0 !== t.boot_box
? app.modal.confirm_box(t.boot_box)
: void 0 !== t.submitWhenValid && t.submitWhenValid()
: void 0 !== t.validation.custom && void 0 !== t.validation.custom.informal_val && void 0 !== t.validation.custom.informal_val._callback && t.validation.custom.informal_val._callback(a),
!1)
: (void 0 !== t.tab && o('.nav-tabs a[href="' + t.tab + '"]').tab("show"), !1)
},
_validateContactForm: function(t) {
if (void 0 === t.validation)
return app.modal.confirm_box(t.boot_box),
!1
var a = []
void 0 !== t.validation.custom && void 0 !== t.validation.custom.rules && o.map(t.validation.custom.rules, function(t, a) {
o.validator.addMethod(a, function(o, a, e) {
return t._fnc(o, a, e)
}, t.msg)
}),
void 0 !== t.validation.custom && void 0 !== t.validation.custom.informal_val && void 0 !== t.validation.custom.informal_val._rules && (a = t.validation.custom.informal_val._rules(
void 0 !== t.boot_box.action
? t.boot_box.action
: "")),
o(t.validation.form_id).validate({
ignore: void 0 !== t.validation.ignore
? t.validation.ignore
: ":hidden",
rules: t.validation.rules,
messages: "undefined" != t.validation.messages
? t.validation.messages
: {},
highlight: function(t) {
o(t).closest(".form-group").addClass("has-error");
o(t).closest(".form-label-group").addClass("has-error");
},
unhighlight: function(t) {
o(t).closest(".form-group").removeClass("has-error");
o(t).closest(".form-label-group").removeClass("has-error");
},
errorElement: "span",
errorClass: "help-block",
errorPlacement: function(o, a) {
if (a.attr("name") == "fname") {
o.insertAfter('.with-fname-error').addClass('error-msg');
$('.with-fname-error').addClass('error-msg');
}else if (a.attr("name") == "name") {
o.insertAfter('.with-name-error').addClass('error-msg');
$('.with-name-error').addClass('error-msg');
}else if (a.attr("name") == "sender") {
o.insertAfter('.with-sender-error').addClass('error-msg');
$('.with-sender-error').addClass('error-msg');
}else if (a.attr("id") == "nature") {
$(".select2-container--default .select2-selection--single").css({
"border-color": "#a94442 !important"
})
o.insertAfter('.with-nature-custom-error').addClass('error-msg');
$('.with-nature-custom-error').addClass('error-msg');
} else if (a.attr("name") == "comment") {
o.insertAfter('.with-comment-error').addClass('error-msg');
$('.with-comment-error').addClass('error-msg');
}
},
focusInvalid: !0,
invalidHandler: function(a, e) {
if (e.numberOfInvalids()) {
var i = o(e.errorList[0].element)
return i.focus(),
void 0 === t.validation.displayClass && o("html").animate({
scrollTop: i.offset().top
}, 1e3),
!1
}
},
showErrors: function(o, t) {
this.defaultShowErrors()
},
submitHandler: function() {
return !1
}
})
var e = o(t.validation.form_id)
return e.valid() === !0 && e.valid() !== !1
? (
0 == a.length
? void 0 !== t.boot_box
? app.modal.confirm_box(t.boot_box)
: void 0 !== t.submitWhenValid && t.submitWhenValid()
: void 0 !== t.validation.custom && void 0 !== t.validation.custom.informal_val && void 0 !== t.validation.custom.informal_val._callback && t.validation.custom.informal_val._callback(a),
!1)
: (void 0 !== t.tab && o('.nav-tabs a[href="' + t.tab + '"]').tab("show"), !1)
},
_populate_field_error: function(t, a, e) {
var i = o("#" + t)
0 == e && i.focus()
var n = i.closest(".form-group"),
s = n.find(".input-group")
n.addClass("has-error"),
s.length
? o('<span for="' + t + '" class="help-block custom-error-block" style="display: block;">' + a + "</span>").insertAfter(s)
: o('<span for="' + t + '" class="help-block custom-error-block" style="display: block;">' + a + "</span>").insertAfter(i)
},
_resetFormValidation: function(t) {
o(t + " .error").removeClass("error"),
o(t + " .form-group").each(function() {
o(this).removeClass("has-success")
}),
o(t + " .form-group").each(function() {
o(this).removeClass("has-error")
}),
o(t + " .form-group").each(function() {
o(this).removeClass("has-feedback")
}),
o(t + " .help-block").each(function() {
o(this).remove()
}),
o(t + " .form-control-feedback").each(function() {
o(this).remove()
}),
o(t + " input").closest(".form-group").removeClass("has-error"),
o("span.custom-error-block").remove()
},
_resetValidationByField: function(t) {
var a = o("#" + t).closest(".form-group")
a.removeClass("has-error"),
a.find(".form-control-feedback, .help-block").remove()
},
_removeValidation_by_fields: function(t) {
o.map(t, function(t) {
o("#" + t).prop("required", null)
})
},
_addValidation_by_fields: function(t) {
o.map(t, function(t) {
o("#" + t).prop("required", !0)
})
},
_populate_values: function(t) {
var a = t.dataHolder.data(t.dataIndex),
e = t.fields
o.map(e, function(t) {
o("#" + t).val(a[t])
})
},
_repopulate_values: function(t, a) {
var e = t.data,
i = t.fields
o.map(i, function(t) {
o("#" + t).val(e[t])
})
},
_form_submit_on_keypress: function(t, a, e) {
(void 0 === e || "null" == typeof e) && (e = ["hidden"])
var i = o("form#" + t)
i.off("keypress").on("keypress", function(t) {
13 == t.keyCode && -1 == e.indexOf(o(t.target).prop("name")) && (o(t.target).blur(), a())
})
},
_form_on_keypress: function(t) {
var a = o("form#" + t)
a.off("keypress").on("input", function(t) {
o(t.target).val().length > 0 && o(t.target).prop("name") && o(t.target).closest(".form-group").removeClass("has-error").find("span.help-block").text("")
})
},
custom_validation: function(o, t) {
switch (o) {
case "email":
var a = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(t)
return a
? {
status: a
}
: {
status : a,
message: "Entrer une adresse e-mail valide."
}
}
}
},
grid: {
create_action_btn: function(o, t, a, e, i) {
var n = null != i && void 0 !== i && "disabled" == i
? !0
: !1
return '<p class="custom-popover-tooltip col-sm-1 col-xs-1" data-placement="top" data-toggle="tooltip" data-title="' + o + '" title="' + o + '"><span ' + (
n
? 'disabled="disabled"'
: "") + " " + (
null != e
? 'onclick="' + e + '"'
: "") + ' class="btn btn-' + a + ' btn-xs"><span class="fa fa-fw fa-' + t + " " + (
n
? "text-muted"
: "") + '"></span></span></p>'
},
search_filter: function(t, a) {
o("#" + t + "_filter input").unbind().bind("keyup", function(t) {
"" == o(this).val().trim() && a.search(this.value).draw(),
13 == t.keyCode && a.search(this.value).draw()
})
}
},
_tooltip: {
_pop: function(t) {
var a = o((
void 0 !== t && null != t
? t + " "
: "") + ".custom-popover-tooltip").filter("[data-toggle='tooltip']")
void 0 !== a && a.tooltip({
trigger: "hover",
container: "body",
html: !0
})
},
_hide: function(t) {
var a = o((
void 0 !== t && null != t
? t + " "
: "") + ".custom-popover-tooltip").filter("[data-toggle='tooltip']")
void 0 !== a && (a.tooltip("destroy"), o("[data-toggle='tooltip']").tooltip("destroy"), o("div[role='tooltip']").remove())
}
},
setLocale: function(t, a, e) {
app.set_vars(a),
o.ajax({
async: !1,
cache: !1,
data: {
data: t,
reqtype: e
},
type: "GET",
url: app.get_vars().baseurl + "get_locale",
success: function(e) {
if (void 0 !== e) {
var i = {}
o.each(t, function(o, t) {
var a = t.split("|")
a.length > 0
? i[a[0]] = e[a[0]]
: i[t] = e[t]
}),
i._app = e._app,
app.set_vars(i)
app.isalive(a)
}
}
})
},
isalive: function(o) {
if ("string" == typeof o && "" != o && (o = JSON.parse(o)), void 0 !== o.timeout || "undefined" != o.mtype) {
var a = void 0 !== o.timeout
? o.timeout
: void 0 !== o.mtype
? o
: !1
if (a && "session_timeout" == a.mtype)
return app._notify(a.mtype, a.message),
t.setTimeout(function() {
t.location.href = a.mdetail.path
}, a.mdetail.redirect),
!1
}
return !0
}
}
}(jQuery, this, window);