Skip to content
This repository was archived by the owner on Nov 15, 2017. It is now read-only.

Commit 2137e77

Browse files
committed
fixed more kinks re collapsing rows
1 parent eee7662 commit 2137e77

File tree

2 files changed

+37
-14
lines changed

2 files changed

+37
-14
lines changed

js/popup.js

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ function getPageStats() {
4949
var userSettingsCached = {
5050
};
5151

52-
function getUserSetting(setting) {
53-
if ( userSettingsCached[setting] === undefined ) {
52+
function getUserSetting(setting, bypassCache) {
53+
if ( bypassCache || userSettingsCached[setting] === undefined ) {
5454
userSettingsCached[setting] = getHTTPSB().userSettings[setting];
5555
}
5656
return userSettingsCached[setting];
@@ -514,6 +514,21 @@ function getNextAction(hostname, type, leaning) {
514514

515515
/******************************************************************************/
516516

517+
// This is required for when we update the matrix while it is open:
518+
// the user might have collapsed/expanded one or more domains, and we don't
519+
// want to lose all his hardwork.
520+
521+
var explicitlyToggledDomains = {};
522+
523+
function getCollapseState(domain) {
524+
if ( explicitlyToggledDomains[domain] !== undefined ) {
525+
return explicitlyToggledDomains[domain];
526+
}
527+
return getUserSetting('popupCollapseDomains');
528+
}
529+
530+
/******************************************************************************/
531+
517532
// Update visual of matrix cells(s)
518533

519534
function updateMatrixCells() {
@@ -532,15 +547,16 @@ function updateMatrixCells() {
532547
// Update behavior of matrix:
533548
// - Whether a section is collapsible or not. It is collapsible if:
534549
// - It has at least one subdomain AND
535-
// - There is no explicit rule anywhere in the subdomain cells
550+
// - There is no explicit rule anywhere in the subdomain cells AND
551+
// - It is not part of group 3 (blacklisted hostnames)
536552

537553
function updateMatrixBehavior() {
538554
var sections = $('.matSection', HTTPSBPopup.matrixList);
539555
var i = sections.length;
540556
var section, subdomainRows;
541557
while ( i-- ) {
542558
section = $(sections[i]);
543-
subdomainRows = section.children('.l2');
559+
subdomainRows = section.children('.l2:not(.g3)');
544560
section.toggleClass('collapsible', subdomainRows.length > 0 && subdomainRows.children('.gdt,.rdt').length === 0);
545561
}
546562
}
@@ -810,7 +826,8 @@ function makeMatrixGroup0Section(hostnames) {
810826
var domain = hostnames[0];
811827
var domainDiv = $('<div>')
812828
.addClass('matSection')
813-
.toggleClass('collapsed', getUserSetting('popupCollapseDomains'));
829+
.toggleClass('collapsed', getCollapseState(domain))
830+
.prop('domain', domain);
814831
if ( hostnames.length > 1 ) {
815832
makeMatrixGroup0SectionMetaDomain(hostnames)
816833
.appendTo(domainDiv);
@@ -865,7 +882,8 @@ function makeMatrixGroup1Section(hostnames) {
865882
var domain = hostnames[0];
866883
var domainDiv = $('<div>')
867884
.addClass('matSection')
868-
.toggleClass('collapsed', getUserSetting('popupCollapseDomains'));
885+
.toggleClass('collapsed', getCollapseState(domain))
886+
.prop('domain', domain);
869887
if ( hostnames.length > 1 ) {
870888
makeMatrixGroup1SectionMetaDomain(hostnames)
871889
.appendTo(domainDiv);
@@ -920,7 +938,8 @@ function makeMatrixGroup2Section(hostnames) {
920938
var domain = hostnames[0];
921939
var domainDiv = $('<div>')
922940
.addClass('matSection')
923-
.toggleClass('collapsed', getUserSetting('popupCollapseDomains'));
941+
.toggleClass('collapsed', getCollapseState(domain))
942+
.prop('domain', domain);
924943
if ( hostnames.length > 1 ) {
925944
makeMatrixGroup2SectionMetaDomain(hostnames)
926945
.appendTo(domainDiv);
@@ -964,7 +983,8 @@ function makeMatrixGroup3SectionSubomain(domain, subdomain) {
964983
function makeMatrixGroup3Section(hostnames) {
965984
var domain = hostnames[0];
966985
var domainDiv = $('<div>')
967-
.addClass('matSection');
986+
.addClass('matSection')
987+
.prop('domain', domain);
968988
makeMatrixGroup3SectionDomain(domain)
969989
.appendTo(domainDiv);
970990
for ( var i = 1; i < hostnames.length; i++ ) {
@@ -981,7 +1001,7 @@ function makeMatrixGroup3(group) {
9811001
.addClass('matGroup g3');
9821002
$('<div>')
9831003
.addClass('matSection g3Meta')
984-
.toggleClass('g3Collapsed', !!getUserSetting('popupHideBlacklisted'))
1004+
.toggleClass('g3Collapsed', !!getUserSetting('popupHideBlacklisted', true))
9851005
.appendTo(groupDiv);
9861006
makeMatrixMetaRow(computeMatrixGroupMetaStats(group), 'g3')
9871007
.appendTo(groupDiv);
@@ -1284,8 +1304,11 @@ function initAll() {
12841304
});
12851305
$('#domainOnly', popup.matrixCellHotspots)
12861306
.on('click', function() {
1287-
var section = $(this).parents('.matSection.collapsible');
1288-
section.toggleClass('collapsed');
1307+
var section = $(this)
1308+
.parents('.matSection.collapsible')
1309+
.toggleClass('collapsed');
1310+
explicitlyToggledDomains[section.prop('domain')] =
1311+
section.hasClass('collapsed');
12891312
return false;
12901313
});
12911314

popup.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,13 @@
374374
border: 0;
375375
padding: 0;
376376
position: absolute;
377-
left: 10%;
378-
bottom: -3px;
377+
left: calc(50% - 6px);
378+
bottom: -4px;
379379
width: 13px;
380380
height: 13px;
381381
visibility: hidden;
382382
background: transparent url('img/domain-collapse.png') no-repeat;
383-
opacity: 0.25;
383+
opacity: 0.2;
384384
z-index: 10000;
385385
}
386386
.matSection.collapsed #domainOnly {

0 commit comments

Comments
 (0)