-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an observer to make sure the hide class is removed when necessary.
- Loading branch information
Rémy HUBSCHER
committed
Aug 12, 2015
1 parent
ccc1fb0
commit c2ef507
Showing
3 changed files
with
25 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,29 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
self.port.on("cardCounterRefresh", function() { | ||
function showCounters() { | ||
var list = document.getElementsByClassName("list-header-num-cards"); | ||
if (list === null) setTimeout(showCounters, 100); | ||
for (var i = 0; i < list.length; i++) { | ||
list[i].classList.remove("hide"); | ||
if (list[i].classList.contains("hide")) { | ||
list[i].classList.remove("hide"); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
function setupObserver() { | ||
console.debug('Init observers'); | ||
var observer = new MutationObserver(function(mutations) { | ||
console.debug("Mutation detected on num cards headers"); | ||
showCounters(); | ||
}); | ||
var list = document.querySelector('.list-header-num-cards'); | ||
if (list === null) setTimeout(setupObserver, 100); | ||
observer.observe(list, { | ||
attributes: true, | ||
characterData: true | ||
}); | ||
} | ||
|
||
self.port.on("setupObserver", setupObserver); | ||
self.port.on("cardCounterRefresh", showCounters); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,5 @@ | |
"description": "Display Trello list number of cards", | ||
"author": "Rémy HUBSCHER <[email protected]>", | ||
"license": "MPL 2.0", | ||
"version": "0.2" | ||
"version": "0.3" | ||
} |