From 90bfe69e4fb300eba255e74aa49d1891aa7e758e Mon Sep 17 00:00:00 2001
From: Matthew Gilliard <matthew.gilliard@hp.com>
Date: Wed, 1 Oct 2014 08:34:42 +0100
Subject: [PATCH] Prevents double-execution of ci_page_loaded

As gerrit is a big JS-based webapp, traditional hooks for executing code
on page-load (window.onload and friends) don't get executed on every
page as a user is exploring the UI. Instead we rely on the appearance
and disappearance of the "working..." message to know when a user is
looking at a new page.  The test for this was not precise enough, which
was causing the ci_page_loaded function to be called twice on page load.

This patch changes the MutationObserver so that it only calls the
function once, by checking that it is the "style" attribute that has
changed. The other call was being triggered by a change to the
"aria-hidden" attribute.

Change-Id: If870d53b5760c140c84e5711ada94609a60e0cdb
---
 modules/openstack_project/files/gerrit/hideci.js | 1 +
 1 file changed, 1 insertion(+)

diff --git a/modules/openstack_project/files/gerrit/hideci.js b/modules/openstack_project/files/gerrit/hideci.js
index 8dd9f9d115..faa4c19179 100644
--- a/modules/openstack_project/files/gerrit/hideci.js
+++ b/modules/openstack_project/files/gerrit/hideci.js
@@ -291,6 +291,7 @@ window.onload = function() {
         var span = $("span.rpcStatus");
         $.each(mutations, function(i, mutation) {
             if (mutation.target === span[0] &&
+                mutation.attributeName === "style" &&
                 (!(span.is(":visible:")))) {
                 ci_page_loaded();
             }