Skip to content

Commit

Permalink
remove close button and now displays blocking status using the toolba…
Browse files Browse the repository at this point in the history
…r icon badge
  • Loading branch information
thbishop committed Dec 27, 2010
1 parent f1c639c commit 9d14e7b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
8 changes: 0 additions & 8 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@
list-style-type: none;
}

#close_container{
text-align: center;
}

#close_window_button {
width: 110px;
}

.med_button {
padding: 2px 0px;
width: 110px;
Expand Down
22 changes: 12 additions & 10 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,23 @@ function registerBlockedUrlsRemoveButtons() {
}

// handles the text and style of our block sites button
function fillAndStyleBlockSitesButton() {
function styleForCurrentBlockingState() {
var sitesBlockElem = $('#block_sites_button');
if (settings.all.blockSites) {
if (sitesBlockElem.hasClass('green')) {
sitesBlockElem.removeClass('green');
}
sitesBlockElem.text("Don't Block Sites");
sitesBlockElem.text("Disable Site Blocking");
sitesBlockElem.addClass('red');
toggleBadge([255, 0, 0, 255], ' ');
}
else {
if (sitesBlockElem.hasClass('red')) {
sitesBlockElem.removeClass('red');
}
sitesBlockElem.text("Block Sites");
sitesBlockElem.text("Enable Site Blocking");
sitesBlockElem.addClass('green');
toggleBadge([119, 212, 42, 255], ' ');
}
}

Expand All @@ -134,11 +136,16 @@ function populateBlockedUrls() {
registerBlockedUrlsRemoveButtons();
}

function toggleBadge(rgbColor, badgeText) {
chrome.browserAction.setBadgeBackgroundColor({'color': rgbColor});
chrome.browserAction.setBadgeText({'text': badgeText});
}

$(document).ready(function() {
urlSet.load();
settings.load();

fillAndStyleBlockSitesButton();
styleForCurrentBlockingState();

populateBlockedUrls();

Expand All @@ -155,12 +162,7 @@ $(document).ready(function() {
// handler to toggle site blocking
$('#block_sites_button').click(function() {
settings.toggle_site_blocking('#block_sites_button');
fillAndStyleBlockSitesButton();
window.close();
});

// handler to close the window
$('#close_window_button').click(function() {
styleForCurrentBlockingState();
window.close();
});

Expand Down
3 changes: 0 additions & 3 deletions settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
<button id='block_this_site_button' class='grey med_button'>Block this site</button>
</div>
<div id="blocked_sites"></div>
<div id='close_container'>
<button id='close_window_button' class='grey med_button'>Close</button>
</div>
</div>
</body>
</html>

0 comments on commit 9d14e7b

Please sign in to comment.