Skip to content
Snippets Groups Projects
Commit 50e4a206 authored by xamgore's avatar xamgore
Browse files

Refactor event inspector, rename it to «Popup»

parent 8eefc243
Branches
Tags
No related merge requests found
......@@ -3,48 +3,30 @@ var inspectorCounter = 0;
var inspectorMax = 10;
var inspectorList;
$(function()
{
$('body').append('<div class="EventInspectorList"></div>');
inspectorList = $('div.EventInspectorList');
inspectorList.on('click', 'div.EventItem', function()
{
$(this).remove();
//--inspectorCounter;
});
$(window).scroll(function () {
if ($(this).scrollTop() > 40) {
$('.EventInspectorList').css('top', '20px');
} else {
$('.EventInspectorList').css('top', '50px');
}
});
$(function () {
$('body').append('<div class="EventInspectorList"></div>');
inspectorList = $('div.EventInspectorList');
inspectorList.on('click', 'div.EventItem', _ => $(this).remove());
$(window).scroll(function () {
let size = $(this).scrollTop() > 40 ? '20px' : '50px';
inspectorList.css('top', size);
});
});
var EventInspector = {
TYPE: {
SUCCESS: 'success',
ERROR: 'error'
},
show: function (text, type) {
if (inspectorCounter >= inspectorMax)
inspectorList.children().first().remove();
++inspectorCounter;
var MsgDiv = inspectorList.append('<div class="EventItem ' + type + '">' + text + '</div>').children().last();
var MsgDiv = inspectorList.append(`<div class="EventItem ${type}">${text}</div>`).children().last();
let hideMsg = () => MsgDiv.animate({ opacity: 0 }, 1000, _ => MsgDiv.remove());
setTimeout(
function () {
--inspectorCounter;
MsgDiv.animate({ opacity: 0 }, 1000,
function () {
$(this).remove();
});
}, 4000);
setTimeout(() => { --inspectorCounter, hideMsg() }, 4000);
},
error: function (text) {
......@@ -54,4 +36,4 @@ var EventInspector = {
success: function (text) {
this.show(text, 'success');
}
};
}, Popup = EventInspector;
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment