luci-base: ui.js: use standard indicator framework to display uci changes
authorJo-Philipp Wich <jo@mein.io>
Mon, 13 Apr 2020 10:31:54 +0000 (12:31 +0200)
committerJo-Philipp Wich <jo@mein.io>
Thu, 7 May 2020 17:40:50 +0000 (19:40 +0200)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit b6e93d54a0f9c6be310e07a66ac08532ba6400b0)

modules/luci-base/htdocs/luci-static/resources/ui.js

index 73e9947363ed3ebd4f21596b7543249e048b5eb6..80ee0f7c88d8f520cad73d2074fc1ea9dabd8220 100644 (file)
@@ -3814,26 +3814,13 @@ var UI = baseclass.extend(/** @lends LuCI.ui.prototype */ {
                 * The number of changes to indicate.
                 */
                setIndicator: function(n) {
-                       var i = document.querySelector('.uci_change_indicator');
-                       if (i == null) {
-                               var poll = document.getElementById('xhr_poll_status');
-                               i = poll.parentNode.insertBefore(E('a', {
-                                       'href': '#',
-                                       'class': 'uci_change_indicator label notice',
-                                       'click': L.bind(this.displayChanges, this)
-                               }), poll);
-                       }
-
                        if (n > 0) {
-                               dom.content(i, [ _('Unsaved Changes'), ': ', n ]);
-                               i.classList.add('flash');
-                               i.style.display = '';
-                               document.dispatchEvent(new CustomEvent('uci-new-changes'));
+                               UI.prototype.showIndicator('uci-changes',
+                                       '%s: %d'.format(_('Unsaved Changes'), n),
+                                       L.bind(this.displayChanges, this));
                        }
                        else {
-                               i.classList.remove('flash');
-                               i.style.display = 'none';
-                               document.dispatchEvent(new CustomEvent('uci-clear-changes'));
+                               UI.prototype.hideIndicator('uci-changes');
                        }
                },