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.
1484 lines
66 KiB
1484 lines
66 KiB
$( window ).load(function() {
|
|
//mention legales editor
|
|
personalization.tinymce_mentios_legales_set_content();
|
|
personalization.tinymce_privacy_set_content();
|
|
});
|
|
|
|
var announcement_table = $('#announcement_table').DataTable({
|
|
"responsive": true,
|
|
"autoWidth": false,
|
|
"processing": true, //Feature control the processing indicator.
|
|
"serverSide": false, //Feature control DataTables' server-side processing mode.
|
|
"oLanguage": fr_onload_lang.oLanguage,
|
|
//Set column definition initialisation properties.
|
|
"columnDefs": [
|
|
{
|
|
"targets": [ 2, 3],
|
|
"width": "200px"
|
|
},
|
|
],
|
|
"ajax": {
|
|
"url": app.get_vars().baseurl + "personalization/personalization/get_announcement",
|
|
"type": "POST",
|
|
dataSrc:""
|
|
},
|
|
"aaSorting": [],
|
|
"columns": [
|
|
{"data": "title"},
|
|
{"data": "content"},
|
|
{"data": "expiration"},
|
|
{ data: null,
|
|
render: function (data, type, full, meta ) {
|
|
if(data.status=='enable'){
|
|
return '<div class="mb-4">' +
|
|
'<input class="enable-btn" id="'+data.id+'" type="radio" name="announcement_status'+data.id+'" value="enable" checked> ' +
|
|
'<label style="margin: 5px;" class="label label-success"> Enable </label>' +
|
|
'<input class="disable-btn" id="'+data.id+'" type="radio" name="announcement_status'+data.id+'" value="disable">' +
|
|
'<label style="margin: 5px;" class="label label-danger"> Disable </label>' +
|
|
'</div>' +
|
|
'<br>' +
|
|
'<button class= "view-btn btn" id="'+data.id+'"><i class="fa fa-eye"></i></button> <button class= "edit-btn btn" id="'+data.id+'"><i class="fa fa-pencil"></i></button> <button class= "delete-btn btn" id="'+data.id+'"><i class="fa fa-trash"></i></button>';
|
|
}else{
|
|
return '<div class="mb-4">' +
|
|
'<input class="enable-btn" id="'+data.id+'" type="radio" name="announcement_status'+data.id+'" value="enable"> ' +
|
|
'<label style="margin: 5px;" class="label label-success"> Enable </label>' +
|
|
'<input class="disable-btn" id="'+data.id+'" type="radio" name="announcement_status'+data.id+'" value="disable" checked>' +
|
|
'<label style="margin: 5px;" class="label label-danger"> Disable </label>' +
|
|
'</div>' +
|
|
'<br>' +
|
|
'<button class= "view-btn btn" id="'+data.id+'"><i class="fa fa-eye"></i></button> <button class= "edit-btn btn" id="'+data.id+'"><i class="fa fa-pencil"></i></button> <button class= "delete-btn btn" id="'+data.id+'"><i class="fa fa-trash"></i></button>';
|
|
}
|
|
|
|
}
|
|
}
|
|
]
|
|
});
|
|
|
|
|
|
var personalization = (function ($, window, jQuery) {
|
|
var _vars_ = {};
|
|
var $uploadCrop;
|
|
var upload = $('#upload');
|
|
var container = $('#container-image');
|
|
var upload_result = $('.upload-result');
|
|
var form = $('#form');
|
|
var banner_folder = 'resources/images/frontoffice/banner/';
|
|
|
|
return {
|
|
"set_vars": function (options) {
|
|
$.extend(_vars_, options || {});
|
|
},
|
|
"get_vars" : function(){
|
|
return _vars_;
|
|
},
|
|
set_require: function()
|
|
{
|
|
var set_require = $("#set_require");
|
|
var validated;
|
|
|
|
set_require.on('click', function (ev) {
|
|
|
|
$('#registration_form_list input[type=checkbox]').each(function(){
|
|
var req = !this.checked ? 0 : 1;
|
|
var ids = this.value;
|
|
var json = {
|
|
"req": req,
|
|
"ids": ids
|
|
}
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"personalize/update_reg_form",
|
|
type: 'POST',
|
|
data : json,
|
|
dataType: "json",
|
|
success: function(result) {
|
|
validated = true;
|
|
}
|
|
});
|
|
|
|
})
|
|
|
|
app._notify("success", "Mise à jour réussie");
|
|
|
|
});
|
|
},
|
|
registration : function()
|
|
{
|
|
var registration_form_list = $("#registration_form_list");
|
|
var cnt;
|
|
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"personalize/get_reg_form",
|
|
type: 'GET',
|
|
dataType: 'json',
|
|
success: function(res) {
|
|
for (var i = 0; i < res.length; i++) {
|
|
var req = res[i].is_required == 1 ? "checked=checked" : "";
|
|
var name = res[i].name.toUpperCase();
|
|
|
|
cnt += '<tr><td>'+( i + 1)+'</td><td>'+app.get_vars().set_preferences[res[i].name]+'</td><td>'+res[i].type.toUpperCase()+'</td><td><input value='+res[i].id+' name="req" type="checkbox" '+req+' /></td></tr>';
|
|
};
|
|
registration_form_list.append(cnt);
|
|
}
|
|
});
|
|
},
|
|
banner_load_box_cropper : function()
|
|
{
|
|
|
|
$uploadCrop = container.croppie({
|
|
viewport: {
|
|
// width: 750,
|
|
// height: 180,
|
|
width: 800,
|
|
height: 270,
|
|
type: 'square'
|
|
},
|
|
showZoomer: true
|
|
// enableResize: true,
|
|
//enableOrientation: true
|
|
,
|
|
boundary: {
|
|
// width: 800,
|
|
// height: 220,
|
|
width: 850,
|
|
height: 330,
|
|
}
|
|
});
|
|
|
|
upload.on('change', function () { personalization.banner_readFile(this); });
|
|
upload_result.on('click', function (ev) {
|
|
|
|
var dialog = bootbox.dialog({
|
|
message: '<p class="text-center"><i class="fa fa-spin fa-spinner"/>'+app.get_vars()._app.notif.loading+'</p>',
|
|
closeButton: false
|
|
});
|
|
|
|
if( $(".cr-image").attr('src') == undefined || $(".cr-image").attr('src') == "")
|
|
{
|
|
var formData1 = new FormData( $("#form_banner")[0] );
|
|
formData1.append('description', tinyMCE.activeEditor.getContent({format : 'raw'}) )
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"personalize/upload_description",
|
|
type : 'POST',
|
|
data : formData1,
|
|
async : false,
|
|
cache : false,
|
|
contentType : false,
|
|
processData : false,
|
|
success: function(res) {
|
|
$('#uploadBannerModal').modal('hide');
|
|
$(".cr-image").attr('src','');
|
|
$("textarea#description").val('');
|
|
dialog.modal('hide')
|
|
location.reload();
|
|
}
|
|
});
|
|
}
|
|
else
|
|
{
|
|
$uploadCrop.croppie('result', {
|
|
type: 'canvas',
|
|
size: 'original',
|
|
format : 'jpg'
|
|
}).then(function (resp) {
|
|
$('#imagebase64').val(resp);
|
|
if (typeof FormData !== 'undefined') {
|
|
var formData2 = new FormData( $("#form_banner")[0] );
|
|
formData2.append('description', tinyMCE.activeEditor.getContent({format : 'raw'}) )
|
|
if( document.getElementById("upload").value != "" )
|
|
{
|
|
$.ajax({
|
|
url : app.get_vars().baseurl+"personalize/upload_banner",
|
|
type : 'POST',
|
|
data : formData2,
|
|
async : false,
|
|
cache : false,
|
|
contentType : false,
|
|
processData : false,
|
|
success: function( data, textStatus, jQxhr )
|
|
{
|
|
$('#image_banner').attr('src', app.get_vars().baseurl+''+banner_folder+''+data['banner']);
|
|
$('#image_label').html(data['description']);
|
|
$('#uploadBannerModal').modal('hide');
|
|
$(".cr-image").attr('src','');
|
|
$("textarea#description").val('');
|
|
location.reload();
|
|
dialog.modal('hide')
|
|
},
|
|
error: function( jqXhr, textStatus, errorThrown )
|
|
{
|
|
console.log( errorThrown );
|
|
dialog.modal('hide')
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
});
|
|
},
|
|
banner_readFile : function(input)
|
|
{
|
|
if (input.files && input.files[0]) {
|
|
var reader = new FileReader();
|
|
reader.onload = function (e) {
|
|
$uploadCrop.croppie('bind', {
|
|
url: e.target.result
|
|
});
|
|
$('.upload-go').addClass('ready');
|
|
}
|
|
reader.readAsDataURL(input.files[0]);
|
|
}
|
|
},
|
|
banner_get_image : function(type)
|
|
{
|
|
var banner = $('#image_banner');
|
|
var label = $('#image_label');
|
|
var container_image = $('#container-image');
|
|
var upload_btn = $('#upload');
|
|
|
|
// container_image.click(function(){
|
|
// upload_btn.trigger('click');
|
|
// })
|
|
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"personalize/get_banner",
|
|
type: 'POST',
|
|
dataType: "json",
|
|
success: function(res) {
|
|
// if( res['image'] !== undefined )
|
|
banner.attr('src', res['image'])
|
|
// else
|
|
// banner.attr('src', app.get_vars().baseurl+'resources/images/frontoffice/homepage/caroussel.png')
|
|
// if( res['description'] !== undefined && res['description'] !== "" )
|
|
label.html(res['description']);
|
|
if(!type){
|
|
tinymce.get('description').setContent( res['description'] )
|
|
}
|
|
// else
|
|
// label.html( "<p> En remerciement de votre fidélité, <em>Company For Madagascar</em> vous propose d'assister gratuitement aux spectacles et événements ci-dessous. </p>" +
|
|
// "<p> Réservez vos places en vous connectant au moyen de vos identifiants <em>LeMonde.fr</em> </p>" );
|
|
|
|
|
|
}
|
|
});
|
|
},
|
|
tinymce_mentios_legales : function(element,height)
|
|
{
|
|
|
|
tinymce.init({
|
|
code_dialog_height: 500,
|
|
force_hex_style_colors : true,
|
|
//force_p_newlines : true,
|
|
//invalid_elements : "id",
|
|
//forced_root_block : false,
|
|
force_br_newlines : true,
|
|
force_p_newlines : false,
|
|
forced_root_block : '', // Needed for 3.x
|
|
selector: element,
|
|
language: 'fr_FR',
|
|
height: height,
|
|
menubar: false,
|
|
plugins: [
|
|
'advlist autolink lists link image charmap print preview anchor',
|
|
'searchreplace visualblocks code fullscreen',
|
|
'insertdatetime media table contextmenu paste code',
|
|
'anchor code',
|
|
'textcolor colorpicker',
|
|
],
|
|
toolbar: 'code | anchor | undo redo | insert | styleselect | bold italic | fontselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
|
|
font_formats: 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;AkrutiKndPadmini=Akpdmi-n',
|
|
content_css: [
|
|
'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
|
|
'//www.tinymce.com/css/codepen.min.css']
|
|
});
|
|
},
|
|
tinymce_mentios_legales_set_content : function()
|
|
{
|
|
|
|
var status , description;
|
|
var status_mentios_legales = $("#status_mentios_legales");
|
|
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"personalization/append_mentions_legales",
|
|
type: 'GET',
|
|
dataType: 'json',
|
|
success: function(res) {
|
|
status = res.status;
|
|
description = res.description;
|
|
|
|
status_mentios_legales.val(status);
|
|
//tinymce.activeEditor.setContent(description);
|
|
tinymce.get('tinymce_mentios_legales').setContent(description)
|
|
}
|
|
});
|
|
},
|
|
tinymce_mentios_legales_update_content : function()
|
|
{
|
|
var update_button = $("#update_mentions_legales");
|
|
|
|
update_button.on('click', function () {
|
|
var description = tinyMCE.activeEditor.getContent({format : 'raw'}) ;
|
|
var update_button = $("#update_mentions_legales");
|
|
//var description = tinymce.get('tinymce_mentios_legales').getContent() ;
|
|
var status = $("#status_mentios_legales").val();
|
|
var json = {'description':description, 'status':status};
|
|
|
|
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"personalization/update_mentions_legales",
|
|
type: 'POST',
|
|
data : json,
|
|
success: function(result) {
|
|
app._notify(result.mtype, result.message);
|
|
}
|
|
});
|
|
});
|
|
},
|
|
/**
|
|
* Terms and Privacy
|
|
*/
|
|
tinymce_privacy : function(element,height)
|
|
{
|
|
tinymce.init({
|
|
code_dialog_height: 500,
|
|
force_hex_style_colors : true,
|
|
force_br_newlines : true,
|
|
force_p_newlines : false,
|
|
forced_root_block : '', // Needed for 3.x
|
|
selector: element,
|
|
language: 'fr_FR',
|
|
height: height,
|
|
menubar: false,
|
|
plugins: [
|
|
'advlist autolink lists link image charmap print preview anchor',
|
|
'searchreplace visualblocks code fullscreen',
|
|
'insertdatetime media table contextmenu paste code',
|
|
'anchor code',
|
|
'textcolor colorpicker',
|
|
],
|
|
toolbar: 'code | anchor | undo redo | insert | styleselect | bold italic | fontselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
|
|
font_formats: 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;AkrutiKndPadmini=Akpdmi-n',
|
|
content_css: [
|
|
'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
|
|
'//www.tinymce.com/css/codepen.min.css']
|
|
});
|
|
},
|
|
tinymce_privacy_set_content : function()
|
|
{
|
|
|
|
var status , description;
|
|
var status_privacy = $("#status_privacy");
|
|
console.log(app.get_vars().baseurl+"personalization/append_privacy");
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"personalization/append_privacy",
|
|
type: 'GET',
|
|
dataType: 'json',
|
|
success: function(res) {
|
|
status = res.status;
|
|
description = res.description;
|
|
status_privacy.val(status);
|
|
// tinyMCE.activeEditor.setContent('');
|
|
// tinymce.get('tinymce_privacy').setContent(description)
|
|
tinymce.init({
|
|
selector:'#tinymce_privacy',
|
|
code_dialog_height: 500,
|
|
force_hex_style_colors : true,
|
|
force_br_newlines : true,
|
|
force_p_newlines : false,
|
|
forced_root_block : '', // Needed for 3.x
|
|
language: 'fr_FR',
|
|
height: 500,
|
|
menubar: false,
|
|
plugins: [
|
|
'advlist autolink lists link image charmap print preview anchor',
|
|
'searchreplace visualblocks code fullscreen',
|
|
'insertdatetime media table contextmenu paste code',
|
|
'anchor code',
|
|
'textcolor colorpicker',
|
|
],
|
|
toolbar: 'code | anchor | undo redo | insert | styleselect | bold italic | fontselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
|
|
font_formats: 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;AkrutiKndPadmini=Akpdmi-n',
|
|
content_css: [
|
|
'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
|
|
'//www.tinymce.com/css/codepen.min.css'],
|
|
init_instance_callback : function(editor) {
|
|
editor.setContent(description);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
},
|
|
/** end */
|
|
|
|
event_logo_load : function(){
|
|
var logo_prev = $('#logo_prev');
|
|
var input_choose = $('[name="logo"]');
|
|
var form_logo = $('#form_logo');
|
|
var append_logo = $("img#prev_logo");
|
|
|
|
|
|
logo_prev.imagepreview({
|
|
input: '[name="logo"]',
|
|
// reset: '#reset1',
|
|
preview: '#logo_prev'
|
|
});
|
|
input_choose.on('change', function () {
|
|
var formData = new FormData( $('#form_logo')[0] );
|
|
|
|
$.ajax({
|
|
url : app.get_vars().baseurl+"personalize/upload_logo",
|
|
type : 'POST',
|
|
data : formData,
|
|
async : false,
|
|
cache : false,
|
|
contentType : false,
|
|
processData : false,
|
|
success: function( result, textStatus, jQxhr )
|
|
{
|
|
|
|
append_logo.attr('src' , result.image)
|
|
app._notify(result.mtype, result.message);
|
|
form_logo.trigger('reset');
|
|
|
|
if( result.mtype == "error")
|
|
logo_prev.hide()
|
|
},
|
|
error: function( jqXhr, textStatus, errorThrown )
|
|
{
|
|
console.log( errorThrown );
|
|
}
|
|
});
|
|
});
|
|
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"personalize/upload_get_logo",
|
|
type: 'GET',
|
|
success: function(result) {
|
|
console.log(result);
|
|
if( result.length ){
|
|
logo_prev.show();
|
|
append_logo.attr('src' , result)
|
|
}
|
|
}
|
|
});
|
|
},
|
|
announcement_content: function (element, height) {
|
|
function image_upload_handler (blobInfo, success, failure, progress) {
|
|
var xhr, formData;
|
|
xhr = new XMLHttpRequest();
|
|
xhr.withCredentials = false;
|
|
xhr.open('POST', app.get_vars().baseurl + "personalization/post_acceptor", true);
|
|
|
|
xhr.upload.onprogress = function (e) {
|
|
progress(e.loaded / e.total * 100);
|
|
};
|
|
|
|
xhr.onload = function() {
|
|
var json;
|
|
|
|
if (xhr.status === 403) {
|
|
failure('HTTP Error: ' + xhr.status, { remove: true });
|
|
return;
|
|
}
|
|
|
|
if (xhr.status < 200 || xhr.status >= 300) {
|
|
failure('HTTP Error: ' + xhr.status);
|
|
return;
|
|
}
|
|
|
|
json = JSON.parse(xhr.responseText);
|
|
|
|
if (!json || typeof json.location != 'string') {
|
|
failure('Invalid JSON: ' + xhr.responseText);
|
|
return;
|
|
}
|
|
|
|
success(json.location);
|
|
};
|
|
|
|
xhr.onerror = function () {
|
|
failure('Image upload failed due to a XHR Transport error. Code: ' + xhr.status);
|
|
};
|
|
|
|
formData = new FormData();
|
|
formData.append('file', blobInfo.blob(), blobInfo.filename());
|
|
|
|
// append CSRF token in the form data
|
|
formData.append('csrf_token', $('meta[name="csrf_token"]').attr('content'));
|
|
|
|
|
|
|
|
xhr.send(formData);
|
|
};
|
|
tinymce.init({
|
|
selector:element,
|
|
code_dialog_height: 500,
|
|
force_hex_style_colors: true,
|
|
//force_p_newlines : true,
|
|
//invalid_elements : "id",
|
|
//forced_root_block : false,
|
|
force_br_newlines: true,
|
|
force_p_newlines: false,
|
|
forced_root_block: '', // Needed for 3.x
|
|
language: 'fr_FR',
|
|
height: height,
|
|
menubar: false,
|
|
plugins: [
|
|
'advlist autolink lists link image charmap print preview anchor',
|
|
'searchreplace visualblocks code fullscreen',
|
|
'insertdatetime media table contextmenu paste code',
|
|
'anchor code',
|
|
'textcolor colorpicker',
|
|
],
|
|
a11y_advanced_options: true,
|
|
|
|
convert_urls : false,
|
|
relative_urls: false,
|
|
remove_script_host: false,
|
|
paste_data_images: true,
|
|
|
|
/* enable title field in the Image dialog*/
|
|
image_title: true,
|
|
/* enable automatic uploads of images represented by blob or data URIs*/
|
|
automatic_uploads: true,
|
|
// images_upload_url: app.get_vars().baseurl + "personalization/post_acceptor",
|
|
images_upload_handler: image_upload_handler,
|
|
/*
|
|
URL of our upload handler (for more details check: https://www.tiny.cloud/docs/configure/file-image-upload/#images_upload_url)
|
|
images_upload_url: 'postAcceptor.php',
|
|
here we add custom filepicker only to Image dialog
|
|
*/
|
|
file_picker_types: 'image',
|
|
/* and here's our custom image picker*/
|
|
file_picker_callback: function (cb, value, meta) {
|
|
var input = document.createElement('input');
|
|
input.setAttribute('type', 'file');
|
|
input.setAttribute('accept', 'image/*');
|
|
|
|
/*
|
|
Note: In modern browsers input[type="file"] is functional without
|
|
even adding it to the DOM, but that might not be the case in some older
|
|
or quirky browsers like IE, so you might want to add it to the DOM
|
|
just in case, and visually hide it. And do not forget do remove it
|
|
once you do not need it anymore.
|
|
*/
|
|
|
|
input.onchange = function () {
|
|
var file = this.files[0];
|
|
|
|
var reader = new FileReader();
|
|
reader.onload = function () {
|
|
/*
|
|
Note: Now we need to register the blob in TinyMCEs image blob
|
|
registry. In the next release this part hopefully won't be
|
|
necessary, as we are looking to handle it internally.
|
|
*/
|
|
var id = 'blobid' + (new Date()).getTime();
|
|
var blobCache = tinymce.activeEditor.editorUpload.blobCache;
|
|
var base64 = reader.result.split(',')[1];
|
|
var blobInfo = blobCache.create(id, file, base64);
|
|
blobCache.add(blobInfo);
|
|
|
|
/* call the callback and populate the Title field with the file name */
|
|
cb(blobInfo.blobUri(), { title: file.name });
|
|
};
|
|
reader.readAsDataURL(file);
|
|
};
|
|
|
|
input.click();
|
|
},
|
|
toolbar: 'code | anchor | undo redo | insert | styleselect | bold italic | fontselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
|
|
font_formats: 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;AkrutiKndPadmini=Akpdmi-n',
|
|
content_css: [
|
|
'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
|
|
'//www.tinymce.com/css/codepen.min.css']
|
|
});
|
|
|
|
},
|
|
announcement_content_edit: function (element, height) {
|
|
function image_upload_handler (blobInfo, success, failure, progress) {
|
|
var xhr, formData;
|
|
xhr = new XMLHttpRequest();
|
|
xhr.withCredentials = false;
|
|
xhr.open('POST', app.get_vars().baseurl + "personalization/post_acceptor", true);
|
|
|
|
xhr.upload.onprogress = function (e) {
|
|
progress(e.loaded / e.total * 100);
|
|
};
|
|
|
|
xhr.onload = function() {
|
|
var json;
|
|
|
|
if (xhr.status === 403) {
|
|
failure('HTTP Error: ' + xhr.status, { remove: true });
|
|
return;
|
|
}
|
|
|
|
if (xhr.status < 200 || xhr.status >= 300) {
|
|
failure('HTTP Error: ' + xhr.status);
|
|
return;
|
|
}
|
|
|
|
json = JSON.parse(xhr.responseText);
|
|
|
|
if (!json || typeof json.location != 'string') {
|
|
failure('Invalid JSON: ' + xhr.responseText);
|
|
return;
|
|
}
|
|
|
|
success(json.location);
|
|
};
|
|
|
|
xhr.onerror = function () {
|
|
failure('Image upload failed due to a XHR Transport error. Code: ' + xhr.status);
|
|
};
|
|
|
|
formData = new FormData();
|
|
formData.append('file', blobInfo.blob(), blobInfo.filename());
|
|
|
|
// append CSRF token in the form data
|
|
formData.append('csrf_token', $('meta[name="csrf_token"]').attr('content'));
|
|
|
|
|
|
|
|
xhr.send(formData);
|
|
};
|
|
tinymce.init({
|
|
selector:element,
|
|
code_dialog_height: 500,
|
|
force_hex_style_colors: true,
|
|
//force_p_newlines : true,
|
|
//invalid_elements : "id",
|
|
//forced_root_block : false,
|
|
force_br_newlines: true,
|
|
force_p_newlines: false,
|
|
forced_root_block: '', // Needed for 3.x
|
|
language: 'fr_FR',
|
|
height: height,
|
|
menubar: false,
|
|
plugins: [
|
|
'advlist autolink lists link image charmap print preview anchor',
|
|
'searchreplace visualblocks code fullscreen',
|
|
'insertdatetime media table contextmenu paste code',
|
|
'anchor code',
|
|
'textcolor colorpicker',
|
|
],
|
|
a11y_advanced_options: true,
|
|
|
|
convert_urls : false,
|
|
relative_urls: false,
|
|
remove_script_host: false,
|
|
paste_data_images: true,
|
|
|
|
/* enable title field in the Image dialog*/
|
|
image_title: true,
|
|
/* enable automatic uploads of images represented by blob or data URIs*/
|
|
automatic_uploads: true,
|
|
// images_upload_url: app.get_vars().baseurl + "personalization/post_acceptor",
|
|
images_upload_handler: image_upload_handler,
|
|
/*
|
|
URL of our upload handler (for more details check: https://www.tiny.cloud/docs/configure/file-image-upload/#images_upload_url)
|
|
images_upload_url: 'postAcceptor.php',
|
|
here we add custom filepicker only to Image dialog
|
|
*/
|
|
file_picker_types: 'image',
|
|
/* and here's our custom image picker*/
|
|
file_picker_callback: function (cb, value, meta) {
|
|
var input = document.createElement('input');
|
|
input.setAttribute('type', 'file');
|
|
input.setAttribute('accept', 'image/*');
|
|
|
|
/*
|
|
Note: In modern browsers input[type="file"] is functional without
|
|
even adding it to the DOM, but that might not be the case in some older
|
|
or quirky browsers like IE, so you might want to add it to the DOM
|
|
just in case, and visually hide it. And do not forget do remove it
|
|
once you do not need it anymore.
|
|
*/
|
|
|
|
input.onchange = function () {
|
|
var file = this.files[0];
|
|
|
|
var reader = new FileReader();
|
|
reader.onload = function () {
|
|
/*
|
|
Note: Now we need to register the blob in TinyMCEs image blob
|
|
registry. In the next release this part hopefully won't be
|
|
necessary, as we are looking to handle it internally.
|
|
*/
|
|
var id = 'blobid' + (new Date()).getTime();
|
|
var blobCache = tinymce.activeEditor.editorUpload.blobCache;
|
|
var base64 = reader.result.split(',')[1];
|
|
var blobInfo = blobCache.create(id, file, base64);
|
|
blobCache.add(blobInfo);
|
|
|
|
/* call the callback and populate the Title field with the file name */
|
|
cb(blobInfo.blobUri(), { title: file.name });
|
|
};
|
|
reader.readAsDataURL(file);
|
|
};
|
|
|
|
input.click();
|
|
},
|
|
toolbar: 'code | anchor | undo redo | insert | styleselect | bold italic | fontselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
|
|
font_formats: 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;AkrutiKndPadmini=Akpdmi-n',
|
|
content_css: [
|
|
'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
|
|
'//www.tinymce.com/css/codepen.min.css']
|
|
});
|
|
|
|
// Prevent bootstrap dialog from blocking focusin
|
|
$(document).on('focusin', function(e) {
|
|
if ($(e.target).closest(".tox-tinymce-aux, .moxman-window, .tam-assetmanager-root").length) {
|
|
e.stopImmediatePropagation();
|
|
}
|
|
});
|
|
|
|
|
|
},
|
|
tinymce_announcement_content: function () {
|
|
var t, a, n, save_button = $("#save_announcement");
|
|
|
|
save_button.on('click', function () {
|
|
var save_button = $("#save_announcement");
|
|
var description = tinyMCE.activeEditor.getContent({format: 'raw'});
|
|
var announcement_title = $("#announcement_title").val();
|
|
var announcement_expiration = $("#announcement_expiration").val();
|
|
//var description = tinymce.get('tinymce_mentios_legales').getContent() ;
|
|
var status = $("#announcement_status").val();
|
|
var json = {
|
|
'announcement_title': announcement_title,
|
|
'content': description,
|
|
'announcement_expiration': announcement_expiration,
|
|
'status': status
|
|
};
|
|
|
|
if(description!=''&&announcement_title!=''&&announcement_expiration!=''){
|
|
$.ajax({
|
|
url: app.get_vars().baseurl + "personalization/personalization/check_enable_announcement",
|
|
type: "GET",
|
|
success: function(e) {
|
|
if(e=='full'){
|
|
bootbox.dialog({
|
|
title: "Edit Announcement",
|
|
className: "my-modal-with-sm event-normal-registration-modal table",
|
|
message: 'There are is an existing announcement that was ENABLED. Saving this announcement will DISABLE the active announcement.',
|
|
cache: !1,
|
|
show: !1,
|
|
size: 'large',
|
|
buttons: [{
|
|
label: "RETOUR",
|
|
className: "btn btn-default",
|
|
callback: function() {
|
|
announcement_table.ajax.reload();
|
|
}
|
|
}, {
|
|
label: "CONFIRMER",
|
|
className: "btn btn-primary",
|
|
callback: function() {
|
|
$.trim($("#announcement_title").val()), a = $.trim($("#announcement_expiration").val()), n = tinymce.get("announcement_content").getContent(), "Choisissez un sujet de question ..." == a || "" == t || "" == n || "" == a ? app._notify("error", "Merci de remplir les champs suivants.") : $.ajax({
|
|
url: app.get_vars().baseurl + "personalization/save_announcement",
|
|
type: 'POST',
|
|
data: json,
|
|
success: function (result) {
|
|
announcement_table.ajax.reload();
|
|
app._notify(result.mtype, result.message);
|
|
$("#announcement_title").val("");
|
|
$("#announcement_expiration").val("");
|
|
$("#announcement_content").val("");
|
|
tinyMCE.activeEditor.setContent('');
|
|
}
|
|
});
|
|
|
|
}
|
|
}]
|
|
}).on("shown.bs.modal", function() {
|
|
|
|
|
|
|
|
}).on("hide.bs.modal", function() {
|
|
|
|
|
|
|
|
}).modal("show")
|
|
}else{
|
|
$.trim($("#announcement_title").val()), a = $.trim($("#announcement_expiration").val()), n = tinymce.get("announcement_content").getContent(), "Choisissez un sujet de question ..." == a || "" == t || "" == n || "" == a ? app._notify("error", "Merci de remplir les champs suivants.") : $.ajax({
|
|
url: app.get_vars().baseurl + "personalization/save_announcement",
|
|
type: 'POST',
|
|
data: json,
|
|
success: function (result) {
|
|
announcement_table.ajax.reload();
|
|
app._notify(result.mtype, result.message);
|
|
$("#announcement_title").val("");
|
|
$("#announcement_expiration").val("");
|
|
$("#announcement_content").val("");
|
|
tinyMCE.activeEditor.setContent('');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
})
|
|
}else{
|
|
app._notify('error', 'All fields are required.');
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
},
|
|
"update_homepage_title": function(text) {
|
|
if(text) {
|
|
$.ajax({
|
|
url: app.get_vars().baseurl + "personalization/update-homepage-title",
|
|
type: "POST",
|
|
data: {title: text},
|
|
success: function(result) {
|
|
app._notify(result.mtype, "Successfully saved");
|
|
}
|
|
});
|
|
}else{
|
|
app._notify('error', 'Field is required.');
|
|
}
|
|
},
|
|
"get_homepage_title": function() {
|
|
$.ajax({
|
|
url: app.get_vars().baseurl + "personalization/get-homepage-title",
|
|
type: "GET",
|
|
success: function(result) {
|
|
console.log(result)
|
|
}
|
|
});
|
|
},
|
|
'get_past_workshops': function() {
|
|
$('#past-event-container').empty()
|
|
$("#selected-workshop").empty()
|
|
let past_events = $('<select class="form-control d-none" id="past-field" name="past-field" multiple="multiple"></select>')
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"past_events",
|
|
type: "get",
|
|
success: function( result ){
|
|
if(result.mtype == "success"){
|
|
const options = result.mdata;
|
|
for(let i=0; i<options.length; i++) {
|
|
past_events.append($('<option>', {
|
|
value: options[i].event_id,
|
|
text : options[i].title+' ['+options[i].workshop_author+']'
|
|
}))
|
|
}
|
|
$("#past-event-container").append(past_events);
|
|
$("#past-event-container").append(`<button id="save_past_events" onclick="personalization.save_selected_past_events()" class="btn btn-primary pull-right">Save</button>`)
|
|
$(past_events).multiselect({
|
|
enableFiltering: true,
|
|
filterPlaceholder: 'Type to search event ...',
|
|
maxHeight: 250
|
|
});
|
|
$('#past-field').change(function() {
|
|
if($('#past-field').val()!== null && $('#past-field').val().length >= 3) {
|
|
$('#past-field option').each((index, element) =>{
|
|
const x = $("input.form-check-input[value='"+element.value+"']");
|
|
x.closest($('button.multiselect-option')).attr('disabled', true)
|
|
x.closest($('button.multiselect-option.dropdown-item > .form-check > .form-check-input')).attr('disabled', true)
|
|
x.closest($('button.multiselect-option.dropdown-item.active')).removeAttr('disabled')
|
|
x.closest($('button.multiselect-option.dropdown-item.active > .form-check > .form-check-input')).removeAttr('disabled')
|
|
});
|
|
} else {
|
|
$('#save_past_events').removeAttr('disabled')
|
|
$('#past-field option').each((index, element) =>{
|
|
const x = $("input.form-check-input[value='"+element.value+"']");
|
|
x.closest($('button.multiselect-option')).removeAttr('disabled')
|
|
x.closest($('button.multiselect-option.dropdown-item > .form-check > .form-check-input')).removeAttr('disabled')
|
|
});
|
|
}
|
|
})
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"get_selected_past_events",
|
|
type: "get",
|
|
success: function( result ){
|
|
if(result.mtype == "success"){
|
|
const selectedEvents = result.mdata;
|
|
if(selectedEvents) {
|
|
selectedEvents.forEach( (event) => {
|
|
$('#past-field option').each((index, element) =>{
|
|
if(event.event_id.indexOf(element.value) > -1) {
|
|
// personalization.append_past_event(event)
|
|
const x = $("input.form-check-input[value='"+element.value+"']");
|
|
x.closest($('button.multiselect-option')).click()
|
|
}
|
|
});
|
|
})
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
},
|
|
'append_past_event': function (event) {
|
|
const html = `
|
|
<div class="col-md-4">
|
|
<div class="mc-workshop-card card no-sponsor">
|
|
<div class="mc-workshop-img-card">
|
|
<div class="mc-card-img">
|
|
<img src="${app.get_vars().baseurl}resources/images/frontoffice/events/${event.file_name}" class="card-img-top" alt="...">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
`
|
|
$("#selected-workshop").append(html);
|
|
},
|
|
'save_selected_past_events': function() {
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"add_selected_past_events",
|
|
type: "post",
|
|
data: {
|
|
events: JSON.stringify($('#past-field').val())
|
|
},
|
|
success: function( result ){
|
|
if(result.mtype == "success"){
|
|
app._notify("success", 'Selected past events updated');
|
|
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
};
|
|
|
|
})(jQuery, this);
|
|
|
|
$(function() {
|
|
$("#banner_modal").on('click', function () {
|
|
//$("#description").val($("#image_label").text())
|
|
|
|
personalization.tinymce_mentios_legales('textarea#description', 200 );
|
|
personalization.banner_get_image(false);
|
|
$('#uploadBannerModal').modal('show');
|
|
|
|
});
|
|
|
|
personalization.banner_load_box_cropper();
|
|
personalization.banner_get_image(true);
|
|
|
|
//registration set required
|
|
personalization.registration();
|
|
personalization.set_require();
|
|
personalization.get_past_workshops();
|
|
|
|
//mention legales editor
|
|
personalization.tinymce_mentios_legales('textarea#tinymce_mentios_legales', 500 );
|
|
personalization.tinymce_mentios_legales_update_content();
|
|
|
|
//announcementeditor
|
|
personalization.announcement_content('textarea#announcement_content', 500 );
|
|
personalization.tinymce_announcement_content();
|
|
$("#announcement_table").on("click", ".enable-btn", function() {
|
|
var e = this.id
|
|
$(this).closest("tr").attr("id")
|
|
$.ajax({
|
|
url: app.get_vars().baseurl + "personalization/personalization/enable_announcement",
|
|
type: "POST",
|
|
data: {
|
|
id: e
|
|
},
|
|
success: function(e) {
|
|
if(e=='full'){
|
|
app._notify('error', 'Only 1 announcement will be enabled at a time.');
|
|
announcement_table.ajax.reload();
|
|
}else{
|
|
app._notify('success', 'Annonce activée et publiée avec succés.');
|
|
announcement_table.ajax.reload();
|
|
}
|
|
}
|
|
})
|
|
// bootbox.dialog({
|
|
// title: "Confirmer la suppression de la question",
|
|
// className: "my-modal-with-sm event-normal-registration-modal table",
|
|
// message: $("#delete-question"),
|
|
// cache: !1,
|
|
// show: !1,
|
|
// buttons: [{
|
|
// label: "RETOUR",
|
|
// className: "btn btn-default",
|
|
// callback: function() {
|
|
// $("#delete-question").empty(), window.setTimeout(function() {
|
|
// window.location.href = app.get_vars().baseurl + "faqs"
|
|
// }, 500)
|
|
// }
|
|
// }, {
|
|
// label: "CONFIRMER",
|
|
// className: "btn btn-primary",
|
|
// callback: function() {
|
|
// $.ajax({
|
|
// url: app.get_vars().baseurl + "faqs/faqs/delete_question",
|
|
// type: "POST",
|
|
// data: {
|
|
// question: e
|
|
// },
|
|
// success: function(e) {
|
|
// 1 == e && (app._notify("success", "Supprimé avec succès"), window.setTimeout(function() {
|
|
// window.location.href = app.get_vars().baseurl + "faqs"
|
|
// }, 2e3))
|
|
// }
|
|
// })
|
|
// }
|
|
// }]
|
|
// }).on("shown.bs.modal", function() {}).on("hide.bs.modal", function() {
|
|
// $("#delete-question").empty()
|
|
// }).modal("show")
|
|
});
|
|
$("#announcement_table").on("click", ".disable-btn", function() {
|
|
var e = this.id
|
|
$(this).closest("tr").attr("id")
|
|
$.ajax({
|
|
url: app.get_vars().baseurl + "personalization/personalization/disable_announcement",
|
|
type: "POST",
|
|
data: {
|
|
id: e
|
|
},
|
|
success: function(e) {
|
|
app._notify('success', 'Annonce désactivée avec succés');
|
|
announcement_table.ajax.reload();
|
|
}
|
|
})
|
|
// bootbox.dialog({
|
|
// title: "Confirmer la suppression de la question",
|
|
// className: "my-modal-with-sm event-normal-registration-modal table",
|
|
// message: $("#delete-question"),
|
|
// cache: !1,
|
|
// show: !1,
|
|
// buttons: [{
|
|
// label: "RETOUR",
|
|
// className: "btn btn-default",
|
|
// callback: function() {
|
|
// $("#delete-question").empty(), window.setTimeout(function() {
|
|
// window.location.href = app.get_vars().baseurl + "faqs"
|
|
// }, 500)
|
|
// }
|
|
// }, {
|
|
// label: "CONFIRMER",
|
|
// className: "btn btn-primary",
|
|
// callback: function() {
|
|
// $.ajax({
|
|
// url: app.get_vars().baseurl + "faqs/faqs/delete_question",
|
|
// type: "POST",
|
|
// data: {
|
|
// question: e
|
|
// },
|
|
// success: function(e) {
|
|
// 1 == e && (app._notify("success", "Supprimé avec succès"), window.setTimeout(function() {
|
|
// window.location.href = app.get_vars().baseurl + "faqs"
|
|
// }, 2e3))
|
|
// }
|
|
// })
|
|
// }
|
|
// }]
|
|
// }).on("shown.bs.modal", function() {}).on("hide.bs.modal", function() {
|
|
// $("#delete-question").empty()
|
|
// }).modal("show")
|
|
});
|
|
$("#announcement_table").on("click", ".delete-btn", function() {
|
|
var e = this.id
|
|
$(this).closest("tr").attr("id")
|
|
$.ajax({
|
|
url: app.get_vars().baseurl + "personalization/personalization/delete_announcement",
|
|
type: "POST",
|
|
data: {
|
|
id: e
|
|
},
|
|
success: function(e) {
|
|
app._notify('success', 'Announcement deleted successfully.');
|
|
announcement_table.ajax.reload();
|
|
}
|
|
})
|
|
// bootbox.dialog({
|
|
// title: "Confirmer la suppression de la question",
|
|
// className: "my-modal-with-sm event-normal-registration-modal table",
|
|
// message: $("#delete-question"),
|
|
// cache: !1,
|
|
// show: !1,
|
|
// buttons: [{
|
|
// label: "RETOUR",
|
|
// className: "btn btn-default",
|
|
// callback: function() {
|
|
// $("#delete-question").empty(), window.setTimeout(function() {
|
|
// window.location.href = app.get_vars().baseurl + "faqs"
|
|
// }, 500)
|
|
// }
|
|
// }, {
|
|
// label: "CONFIRMER",
|
|
// className: "btn btn-primary",
|
|
// callback: function() {
|
|
// $.ajax({
|
|
// url: app.get_vars().baseurl + "faqs/faqs/delete_question",
|
|
// type: "POST",
|
|
// data: {
|
|
// question: e
|
|
// },
|
|
// success: function(e) {
|
|
// 1 == e && (app._notify("success", "Supprimé avec succès"), window.setTimeout(function() {
|
|
// window.location.href = app.get_vars().baseurl + "faqs"
|
|
// }, 2e3))
|
|
// }
|
|
// })
|
|
// }
|
|
// }]
|
|
// }).on("shown.bs.modal", function() {}).on("hide.bs.modal", function() {
|
|
// $("#delete-question").empty()
|
|
// }).modal("show")
|
|
});
|
|
$("#announcement_table").on("click", ".edit-btn", function() {
|
|
|
|
var e = this.id;
|
|
$(this).closest("tr").attr("id");
|
|
|
|
$("#edit_announcement_content").addClass('edit_announcement_content'+e);
|
|
function image_upload_handler (blobInfo, success, failure, progress) {
|
|
var xhr, formData;
|
|
xhr = new XMLHttpRequest();
|
|
xhr.withCredentials = false;
|
|
xhr.open('POST', app.get_vars().baseurl + "personalization/post_acceptor", true);
|
|
|
|
xhr.upload.onprogress = function (e) {
|
|
progress(e.loaded / e.total * 100);
|
|
};
|
|
|
|
xhr.onload = function() {
|
|
var json;
|
|
|
|
if (xhr.status === 403) {
|
|
failure('HTTP Error: ' + xhr.status, { remove: true });
|
|
return;
|
|
}
|
|
|
|
if (xhr.status < 200 || xhr.status >= 300) {
|
|
failure('HTTP Error: ' + xhr.status);
|
|
return;
|
|
}
|
|
|
|
json = JSON.parse(xhr.responseText);
|
|
|
|
if (!json || typeof json.location != 'string') {
|
|
failure('Invalid JSON: ' + xhr.responseText);
|
|
return;
|
|
}
|
|
|
|
success(json.location);
|
|
};
|
|
|
|
xhr.onerror = function () {
|
|
failure('Image upload failed due to a XHR Transport error. Code: ' + xhr.status);
|
|
};
|
|
|
|
formData = new FormData();
|
|
formData.append('file', blobInfo.blob(), blobInfo.filename());
|
|
|
|
// append CSRF token in the form data
|
|
formData.append('csrf_token', $('meta[name="csrf_token"]').attr('content'));
|
|
|
|
|
|
|
|
xhr.send(formData);
|
|
};
|
|
tinymce.init({
|
|
selector:"textarea",
|
|
code_dialog_height: 500,
|
|
force_hex_style_colors: true,
|
|
//force_p_newlines : true,
|
|
//invalid_elements : "id",
|
|
//forced_root_block : false,
|
|
force_br_newlines: true,
|
|
force_p_newlines: false,
|
|
forced_root_block: '', // Needed for 3.x
|
|
language: 'fr_FR',
|
|
height: 500,
|
|
menubar: false,
|
|
plugins: [
|
|
'advlist autolink lists link image charmap print preview anchor',
|
|
'searchreplace visualblocks code fullscreen',
|
|
'insertdatetime media table contextmenu paste code',
|
|
'anchor code',
|
|
'textcolor colorpicker',
|
|
],
|
|
a11y_advanced_options: true,
|
|
convert_urls : false,
|
|
relative_urls: false,
|
|
remove_script_host: false,
|
|
paste_data_images: true,
|
|
|
|
/* enable title field in the Image dialog*/
|
|
image_title: true,
|
|
/* enable automatic uploads of images represented by blob or data URIs*/
|
|
automatic_uploads: true,
|
|
// images_upload_url: app.get_vars().baseurl + "personalization/post_acceptor",
|
|
images_upload_handler: image_upload_handler,
|
|
/*
|
|
URL of our upload handler (for more details check: https://www.tiny.cloud/docs/configure/file-image-upload/#images_upload_url)
|
|
images_upload_url: 'postAcceptor.php',
|
|
here we add custom filepicker only to Image dialog
|
|
*/
|
|
file_picker_types: 'image',
|
|
/* and here's our custom image picker*/
|
|
file_picker_callback: function (cb, value, meta) {
|
|
var input = document.createElement('input');
|
|
input.setAttribute('type', 'file');
|
|
input.setAttribute('accept', 'image/*');
|
|
|
|
/*
|
|
Note: In modern browsers input[type="file"] is functional without
|
|
even adding it to the DOM, but that might not be the case in some older
|
|
or quirky browsers like IE, so you might want to add it to the DOM
|
|
just in case, and visually hide it. And do not forget do remove it
|
|
once you do not need it anymore.
|
|
*/
|
|
|
|
input.onchange = function () {
|
|
var file = this.files[0];
|
|
|
|
var reader = new FileReader();
|
|
reader.onload = function () {
|
|
/*
|
|
Note: Now we need to register the blob in TinyMCEs image blob
|
|
registry. In the next release this part hopefully won't be
|
|
necessary, as we are looking to handle it internally.
|
|
*/
|
|
var id = 'blobid' + (new Date()).getTime();
|
|
var blobCache = tinymce.activeEditor.editorUpload.blobCache;
|
|
var base64 = reader.result.split(',')[1];
|
|
var blobInfo = blobCache.create(id, file, base64);
|
|
blobCache.add(blobInfo);
|
|
|
|
/* call the callback and populate the Title field with the file name */
|
|
cb(blobInfo.blobUri(), { title: file.name });
|
|
};
|
|
reader.readAsDataURL(file);
|
|
};
|
|
|
|
input.click();
|
|
},
|
|
toolbar: 'code | anchor | undo redo | insert | styleselect | bold italic | fontselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
|
|
toolbar_mode: 'wrap',
|
|
font_formats: 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;AkrutiKndPadmini=Akpdmi-n',
|
|
content_css: [
|
|
'//fonts.googleapis.com/css?family=Lato:300,300i,400,400i',
|
|
'//www.tinymce.com/css/codepen.min.css']
|
|
});
|
|
// Prevent bootstrap dialog from blocking focusin
|
|
$(document).on('focusin', function(e) {
|
|
if ($(e.target).closest(".tox-tinymce-aux, .moxman-window, .tam-assetmanager-root").length) {
|
|
e.stopImmediatePropagation();
|
|
}
|
|
});
|
|
|
|
|
|
$('#edit-announcement').modal('show');
|
|
|
|
$.ajax({
|
|
url: app.get_vars().baseurl + "personalization/personalization/get_specific_announcement",
|
|
type: "POST",
|
|
data: {
|
|
id: e
|
|
},
|
|
success: function(e) {
|
|
$('#announcement_title_edit').val(e[0].title);
|
|
$('#announcement_date_edit').val(e[0].expiration);
|
|
tinymce.activeEditor.setContent(e[0].content);
|
|
|
|
|
|
$(".edit_announcement_content"+e[0].id).one('click',function() {
|
|
if (requestRunning) { // don't do anything if an AJAX request is pending
|
|
return;
|
|
}
|
|
|
|
var t = $('#announcement_title_edit').val();
|
|
var d = $('#announcement_date_edit').val();
|
|
var c = tinymce.activeEditor.getContent();
|
|
var id = e[0].id;
|
|
|
|
var requestRunning = false;
|
|
var ajaxOpts = {
|
|
url: app.get_vars().baseurl + "personalization/personalization/update_announcement",
|
|
type: "POST",
|
|
data: {
|
|
title: t,date:d,content:c,id:id
|
|
},
|
|
success: function(e) {
|
|
1 == e && (app._notify("success", "Contenu mis à jour avec succès."), window.setTimeout(function() {
|
|
announcement_table.ajax.reload();
|
|
$("#edit-announcement").removeClass('fade').modal('hide');
|
|
$('#announcement_title_edit').val('');
|
|
$('#announcement_date_edit').val('');
|
|
tinymce.activeEditor.setContent('');
|
|
tinymce.remove('#announcement_content_edit');
|
|
app._form._reset('.edit-announcement-form');
|
|
$('#edit-announcement').data('bs.modal', null);
|
|
$('#edit-announcement').off('hidden.bs.modal');
|
|
}, 2e3))
|
|
|
|
0 == e && (app._notify("success", "Contenu mis à jour avec succès."), window.setTimeout(function() {
|
|
announcement_table.ajax.reload();
|
|
$("#edit-announcement").removeClass('fade').modal('hide');
|
|
$('#announcement_title_edit').val('');
|
|
$('#announcement_date_edit').val('');
|
|
tinymce.activeEditor.setContent('');
|
|
tinymce.remove('#announcement_content_edit');
|
|
app._form._reset('.edit-announcement-form');
|
|
$('#edit-announcement').data('bs.modal', null);
|
|
$('#edit-announcement').off('hidden.bs.modal');
|
|
}, 2e3))
|
|
},
|
|
complete: function() {
|
|
requestRunning = false;
|
|
}
|
|
};
|
|
|
|
requestRunning = true;
|
|
$.ajax(ajaxOpts)
|
|
return false;
|
|
|
|
$("#edit_announcement_content").removeClass('edit_announcement_content'+e[0].id);
|
|
});
|
|
|
|
|
|
$("#edit-announcement").on("hidden.bs.modal", function(){
|
|
$("#edit_announcement_content").removeClass('edit_announcement_content'+e[0].id)
|
|
});
|
|
|
|
|
|
|
|
|
|
// bootbox.dialog({
|
|
// title: "Edit Announcement",
|
|
// className: "my-modal-with-sm event-normal-registration-modal table",
|
|
// message: $(".edit-announcement").html(),
|
|
// cache: !1,
|
|
// show: !1,
|
|
// size: 'large',
|
|
// buttons: [{
|
|
// label: "RETOUR",
|
|
// className: "btn btn-default",
|
|
// callback: function() {
|
|
// tinymce.remove('#announcement_content_edit')
|
|
// announcement_table.ajax.reload();
|
|
// bootbox.hideAll();
|
|
// location.reload();
|
|
// // window.setTimeout(function(){window.location.href = app.get_vars().baseurl+"personalization#announcement";},500);
|
|
// }
|
|
// }, {
|
|
// label: "CONFIRMER",
|
|
// className: "btn btn-primary",
|
|
// callback: function() {
|
|
// var t = $('#announcement_title_edit','.bootbox').val();
|
|
// var c = tinymce.activeEditor.getContent();
|
|
// var id = e[0].id;
|
|
// $.ajax({
|
|
// url: app.get_vars().baseurl + "personalization/personalization/update_announcement",
|
|
// type: "POST",
|
|
// data: {
|
|
// title: t,content:c,id:id
|
|
// },
|
|
// success: function(e) {
|
|
// 1 == e && (app._notify("success", "Supprimé avec succès"), window.setTimeout(function() {
|
|
// announcement_table.ajax.reload();
|
|
// bootbox.hideAll();
|
|
// location.reload();
|
|
// // window.setTimeout(function(){window.location.href = app.get_vars().baseurl+"personalization#announcement";},500);
|
|
// }, 2e3))
|
|
// }
|
|
// })
|
|
// }
|
|
// }]
|
|
// })
|
|
// .on("shown.bs.modal", function() {
|
|
//
|
|
// personalization.announcement_content_edit('textarea#announcement_content_edit', 500);
|
|
// $('#announcement_title_edit','.bootbox').val(e[0].title);
|
|
// tinymce.activeEditor.setContent(e[0].content);
|
|
// $(this).off('shown.bs.modal');
|
|
//
|
|
// })
|
|
// .on("hide.bs.modal", function() {
|
|
//
|
|
// try {
|
|
// tinymce.remove('#announcement_content_edit')
|
|
// tinyMCE.editors=[];
|
|
// } catch (e) {}
|
|
// app._form._reset(this);
|
|
// $("#announcement_content_edit").html("");
|
|
// app.modal.focusout_solution("off");
|
|
// app.modal.activate_tinymce("off");
|
|
// $(this).data('bs.modal', null);
|
|
// $(this).off('hidden.bs.modal');
|
|
//
|
|
// }).modal("show")
|
|
// .init(function(){
|
|
//
|
|
// personalization.announcement_content_edit('textarea#announcement_content_edit', 500);
|
|
// // //load wysiwyg html editor
|
|
// // try {
|
|
// // tinymce.remove('#announcement_content_edit')
|
|
// // tinyMCE.editors=[];
|
|
// // personalization.announcement_content_edit('textarea#announcement_content_edit', 500);
|
|
// // // tinymce.EditorManager.execCommand('mceAddEditor',true, 'announcement_content_edit');
|
|
// // } catch (e) {}
|
|
// });
|
|
}
|
|
})
|
|
|
|
});
|
|
$("#announcement_table").on("click", ".view-btn", function() {
|
|
|
|
var e = this.id;
|
|
$(this).closest("tr").attr("id")
|
|
$.ajax({
|
|
url: app.get_vars().baseurl + "personalization/personalization/get_specific_announcement",
|
|
type: "POST",
|
|
data: {
|
|
id: e
|
|
},
|
|
success: function(e) {
|
|
$('#announcement-modal-title-view').html(e[0].title);
|
|
$('#announcement-content').html(e[0].content);
|
|
$("#announcement-modal").modal('show');
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
//logo
|
|
personalization.event_logo_load();
|
|
});
|
|
|
|
/* Edit Privacy */
|
|
$("#update_privacy").click(function() {
|
|
var description = tinyMCE.activeEditor.getContent({format : 'raw'}) ;
|
|
var status = $("#status_privacy").val();
|
|
var json = {'description':description, 'status':status};
|
|
|
|
|
|
$.ajax({
|
|
url: app.get_vars().baseurl+"personalization/update_privacy",
|
|
type: 'POST',
|
|
data : json,
|
|
success: function(result) {
|
|
app._notify(result.mtype, result.message);
|
|
}
|
|
});
|
|
});
|
|
|
|
$("#update_homepage_title").click(function() {
|
|
personalization.update_homepage_title($("#homepage_title_text").val())
|
|
})
|