Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to hide the size #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions css/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ select {
background-repeat: no-repeat;
}

input[type='checkbox'] {
-webkit-appearance: checkbox
}

select:hover:enabled,
input[type='checkbox']:hover:enabled,
input[type='radio']:hover:enabled,
Expand Down
3 changes: 2 additions & 1 deletion js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ var ReticleBg = {
overlayOpacity: isNaN(parseFloat(localStorage.getItem('overlayOpacity'))) ? 0.4 : parseFloat(localStorage.getItem('overlayOpacity')),
primaryHex: localStorage.getItem('primaryHex') || '#000000',
altHex: localStorage.getItem('altHex') || '#C4E2FA',
overlayBg: localStorage.getItem('overlayBg') || 'primary'
overlayBg: localStorage.getItem('overlayBg') || 'primary',
hideSize: (localStorage.getItem('hideSize') === 'true') || false
};
},

Expand Down
5 changes: 5 additions & 0 deletions js/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ window.__Reticle = {
},

updateInfoText: function() {
if (this.hideSize) {
this.els.info.style.display = 'none';
return;
}
this.els.info.style.display = (this.overlayW > 0 && this.overlayH > 0) ? 'block' : 'none';
this.els.info.textContent = this.overlayW + ' x ' + this.overlayH;
this.els.info.style.marginLeft = '-' + (this.els.info.clientWidth / 2) + 'px';
Expand Down Expand Up @@ -226,6 +230,7 @@ window.__Reticle = {
this.primaryRgb = this.hexToRgb(settings.primaryHex);
this.altRgb = this.hexToRgb(settings.altHex);
this.overlayBg = settings.overlayBg;
this.hideSize = settings.hideSize;
this.updateOverlayBgCss();
},

Expand Down
6 changes: 6 additions & 0 deletions js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ var ReticleSettings = {
me.opacityInput = document.getElementById('overlay-opacity');
me.primHexInput = document.getElementById('primary-hex');
me.altHexInput = document.getElementById('alt-hex');
me.hideSizeInput = document.getElementById('hide-size');

chrome.runtime.sendMessage({action: 'load-settings'}, function(response) {
me.opacityInput.value = response.settings.overlayOpacity.toFixed(1);
me.primHexInput.value = response.settings.primaryHex;
me.altHexInput.value = response.settings.altHex;
me.hideSizeInput.checked = response.settings.hideSize;
});

me.opacityInput.addEventListener('change', function(e) {
Expand All @@ -35,6 +37,10 @@ var ReticleSettings = {
me.save({altHex: me.altHexInput.value});
});

me.hideSizeInput.addEventListener('change', function(e) {
me.save({hideSize: me.hideSizeInput.checked});
});

for(var i=0; i < me.tabList.childNodes.length; i++) {
if(me.tabList.childNodes[i].tagName === 'LI') {
me.tabList.childNodes[i].addEventListener('click', function(e) {
Expand Down
5 changes: 5 additions & 0 deletions settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ <h3>Overlay opacity</h3>
<option value="1.0">100%</option>
</select>
</section>
<section>
<h3>Hide size</h3>
<label for="hide-size" class="settings-row">For hiding the size label if you only wish to use this extension for highlighting content.</label>
<input type="checkbox" id="hide-size" />
</section>
</div>
<div class="tab-content" id="tab-content-help">
<h2 class="content-heading">Shortcuts</h2>
Expand Down