diff --git a/media/js/event_inspector/eventInspector.js b/media/js/event_inspector/eventInspector.js index b60da1730d578b8cb7653552911b816bf0a57c83..635e89d5dab57605f0b0b6bbca3f5822bdc364c1 100644 --- a/media/js/event_inspector/eventInspector.js +++ b/media/js/event_inspector/eventInspector.js @@ -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;