From 50e4a206c9dcda2e65767cfb6b2c678bbad63e70 Mon Sep 17 00:00:00 2001
From: xamgore <xamgore@ya.ru>
Date: Sat, 11 Jun 2016 00:20:30 +0300
Subject: [PATCH] =?UTF-8?q?Refactor=20event=20inspector,=20rename=20it=20t?=
 =?UTF-8?q?o=20=C2=ABPopup=C2=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 media/js/event_inspector/eventInspector.js | 46 +++++++---------------
 1 file changed, 14 insertions(+), 32 deletions(-)

diff --git a/media/js/event_inspector/eventInspector.js b/media/js/event_inspector/eventInspector.js
index b60da1730..635e89d5d 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;
-- 
GitLab