code review + fine tuning UI

This commit is contained in:
gorhill 2014-10-07 10:46:10 -04:00
parent a61975b798
commit 9ed6d9bac0
5 changed files with 37 additions and 23 deletions

View File

@ -86,10 +86,20 @@ p {
text-align: center;
cursor: pointer;
}
#dynamicFilteringToggler::after {
#dynamicFilteringToggler a {
padding: 0 2px;
position: absolute;
__MSG_@@bidi_end_edge__: 0;
color: #aaa;
visibility: hidden;
}
#dynamicFilteringToggler.on a {
visibility: visible;
}
#dynamicFilteringToggler::before {
content: '\f107';
}
#dynamicFilteringToggler.on::after {
#dynamicFilteringToggler.on::before {
content: '\f106';
}
#dynamicFilteringContainer {
@ -116,10 +126,10 @@ p {
}
.dynamicFiltering > div {
margin: 0;
border: 1px solid #eee;
border: 1px solid #e6e6e6;
padding: 0;
box-sizing: border-box;
background-color: #eee;
background-color: #e6e6e6;
position: absolute;
cursor: pointer;
}
@ -173,14 +183,14 @@ p {
background-color: transparent;
}
.dynamicFiltering > div.blocked {
border-color: #fdd;
background-color: #fdd;
border-color: #fbb;
background-color: #fbb;
}
.dynamicFiltering > div.ownFilter {
border-color: #bbb;
background-color: #bbb;
}
.dynamicFiltering > div.blocked.ownFilter {
border-color: #eaa;
background-color: #eaa;
border-color: #f66;
background-color: #f66;
}

View File

@ -650,27 +650,24 @@ var getUserData = function(callback) {
/******************************************************************************/
var restoreUserData = function(userData) {
var onUserFiltersSaved = function() {
µb.XAL.restart();
};
µb.destroySelfie();
// If we are going to restore all, might as well wipe out clean local
// storage
µb.XAL.keyvalRemoveAll();
µBlock.saveLocalSettings();
µb.XAL.keyvalSetMany(userData.userSettings);
µb.XAL.keyvalSetOne('remoteBlacklists', userData.filterLists);
µb.XAL.keyvalSetOne('netWhitelist', userData.netWhitelist);
µb.assets.put('assets/user/filters.txt', userData.userFilters, onUserFiltersSaved);
µb.assets.put('assets/user/filters.txt', userData.userFilters);
µb.XAL.restart();
};
/******************************************************************************/
var resetUserData = function() {
var onAllDone = function() {
µb.XAL.restart();
};
µb.XAL.keyvalRemoveAll();
// Keep global counts, people can become quite attached to numbers
var onAllRemoved = function() {
µBlock.saveLocalSettings(onAllDone);
};
µb.XAL.keyvalRemoveAll(onAllRemoved);
µBlock.saveLocalSettings();
µb.XAL.restart();
};
/******************************************************************************/

View File

@ -235,7 +235,11 @@ var onDynamicFilterClicked = function(ev) {
/******************************************************************************/
var toggleDynamicFiltering = function() {
var toggleDynamicFiltering = function(ev) {
// Discard events destined to child elements.
if ( ev !== undefined && ev.target !== this ) {
return;
}
var el = uDom('#dynamicFilteringToggler');
el.toggleClass('on');
messaging.tell({

View File

@ -28,6 +28,7 @@
/******************************************************************************/
var exports = {};
var noopFunc = function(){};
/******************************************************************************/
@ -74,7 +75,7 @@ exports.keyvalSetMany = function(dict) {
/******************************************************************************/
exports.keyvalRemoveAll = function(callback) {
chrome.storage.local.clear(callback);
chrome.storage.local.clear(callback || noopFunc);
};
/******************************************************************************/

View File

@ -24,7 +24,9 @@
<p id="total-blocked">?</p>
</div>
<div id="dynamicFilteringToggler" class="fa on"></div>
<div id="dynamicFilteringToggler" class="fa on">
<a href="https://github.com/gorhill/uBlock/wiki/Dynamic-filtering" target="_blank">?</a>
</div>
<div id="dynamicFilteringContainer">
<div class="dynamicFiltering local" data-scope=".">