mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
add close option in toast
This commit is contained in:
parent
36d15f3de5
commit
72e32ab5de
@ -530,15 +530,34 @@ if ($config['menu_type'] == 'classic') {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_toast(title, subtitle, severity, url, id, onclick) {
|
function closeToast(event) {
|
||||||
|
var match = /notification-(.*)-id-([0-9]+)/.exec(event.target.id);
|
||||||
|
var div_id = document.getElementById(match.input);
|
||||||
|
$(div_id).attr("hidden",true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function print_toast(title, subtitle, severity, url, id, onclick, closeToast) {
|
||||||
// TODO severity.
|
// TODO severity.
|
||||||
severity = '';
|
severity = '';
|
||||||
|
|
||||||
// Start the toast.
|
// Start the toast.
|
||||||
|
|
||||||
|
var parent_div = document.createElement('div');
|
||||||
|
|
||||||
|
// Print close image
|
||||||
|
var img = document.createElement('img');
|
||||||
|
img.setAttribute('id', id);
|
||||||
|
img.setAttribute("src", './images/close_button_dialog.png');
|
||||||
|
img.setAttribute('onclick', closeToast);
|
||||||
|
img.setAttribute('style', 'margin-left: 95%;');
|
||||||
|
parent_div.appendChild(img);
|
||||||
|
|
||||||
|
// Print a element
|
||||||
var toast = document.createElement('a');
|
var toast = document.createElement('a');
|
||||||
toast.setAttribute('onclick', onclick);
|
|
||||||
toast.setAttribute('href', url);
|
|
||||||
toast.setAttribute('target', '_blank');
|
toast.setAttribute('target', '_blank');
|
||||||
|
toast.setAttribute('href', url);
|
||||||
|
toast.setAttribute('onclick', onclick);
|
||||||
|
|
||||||
|
var link_div = document.createElement('div');
|
||||||
|
|
||||||
// Fill toast.
|
// Fill toast.
|
||||||
var toast_div = document.createElement('div');
|
var toast_div = document.createElement('div');
|
||||||
@ -548,9 +567,13 @@ if ($config['menu_type'] == 'classic') {
|
|||||||
var toast_text = document.createElement('p');
|
var toast_text = document.createElement('p');
|
||||||
toast_title.innerHTML = title;
|
toast_title.innerHTML = title;
|
||||||
toast_text.innerHTML = subtitle;
|
toast_text.innerHTML = subtitle;
|
||||||
toast_div.appendChild(toast_title);
|
|
||||||
|
// Append Elements
|
||||||
|
toast_div.appendChild(img);
|
||||||
|
link_div.appendChild(toast_title);
|
||||||
|
toast.appendChild(link_div);
|
||||||
|
toast_div.appendChild(toast);
|
||||||
toast_div.appendChild(toast_text);
|
toast_div.appendChild(toast_text);
|
||||||
toast.appendChild(toast_div);
|
|
||||||
|
|
||||||
// Show and program the hide event.
|
// Show and program the hide event.
|
||||||
toast_div.className = toast_div.className + ' show';
|
toast_div.className = toast_div.className + ' show';
|
||||||
@ -558,9 +581,11 @@ if ($config['menu_type'] == 'classic') {
|
|||||||
toast_div.className = toast_div.className.replace("show", "");
|
toast_div.className = toast_div.className.replace("show", "");
|
||||||
}, 8000);
|
}, 8000);
|
||||||
|
|
||||||
return toast;
|
toast_div.appendChild(parent_div);
|
||||||
}
|
|
||||||
|
|
||||||
|
return toast_div;
|
||||||
|
}
|
||||||
|
|
||||||
function check_new_notifications() {
|
function check_new_notifications() {
|
||||||
var last_id = document.getElementById('notification-ball-header')
|
var last_id = document.getElementById('notification-ball-header')
|
||||||
.getAttribute('last_id');
|
.getAttribute('last_id');
|
||||||
@ -617,9 +642,11 @@ if ($config['menu_type'] == 'classic') {
|
|||||||
ele.criticity,
|
ele.criticity,
|
||||||
ele.full_url,
|
ele.full_url,
|
||||||
'notification-toast-id-' + ele.id_mensaje,
|
'notification-toast-id-' + ele.id_mensaje,
|
||||||
'click_on_notification_toast(event)'
|
'click_on_notification_toast(event)',
|
||||||
|
'closeToast(event)'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user