Skip to content

Commit

Permalink
Setting location option
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-Salmon committed Feb 24, 2018
1 parent 286d476 commit f622d5b
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions app/js/content-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ var defaultSettings = {
openVisible: true,
primary: "view",
placement: "default",
copySupported: false
copySupported: false,
settingPlacement: "seperate"
}

// Renderers
Expand All @@ -29,6 +30,14 @@ function renderUI() {
</a>`;
var copy = settings.copySupported ? `<a class="virCopyImage" ><span>Copy Image</span></a>` : '';
var save = `<a class="virSaveImage" ><span>Download</span></a>`;

var settingElement = `<a class="virSettingsBtn">
<span class="_RKw _wtf _Rtf">
<svg focusable="false" xmlns="http://www.w3.org/2000/svg" style="vertical-align: middle;align-content: center;" viewBox="-20 0 580 500"><path d="M61.2,341.538c4.9,16.8,11.7,33,20.3,48.2l-24.5,30.9c-8,10.1-7.1,24.5,1.9,33.6l42.2,42.2c9.1,9.1,23.5,9.899,33.6,1.899 l30.7-24.3c15.8,9.101,32.6,16.2,50.1,21.2l4.6,39.5c1.5,12.8,12.3,22.4,25.1,22.4h59.7c12.8,0,23.6-9.601,25.1-22.4l4.4-38.1 c18.8-4.9,36.8-12.2,53.7-21.7l29.7,23.5c10.1,8,24.5,7.1,33.6-1.9l42.2-42.2c9.1-9.1,9.9-23.5,1.9-33.6l-23.1-29.3 c9.6-16.601,17.1-34.3,22.1-52.8l35.6-4.1c12.801-1.5,22.4-12.3,22.4-25.1v-59.7c0-12.8-9.6-23.6-22.4-25.1l-35.1-4.1 c-4.801-18.3-12-35.8-21.199-52.2l21.6-27.3c8-10.1,7.1-24.5-1.9-33.6l-42.1-42.1c-9.1-9.1-23.5-9.9-33.6-1.9l-26.5,21 c-17.2-10.1-35.601-17.8-54.9-23l-4-34.3c-1.5-12.8-12.3-22.4-25.1-22.4h-59.7c-12.8,0-23.6,9.6-25.1,22.4l-4,34.3 c-19.8,5.3-38.7,13.3-56.3,23.8l-27.5-21.8c-10.1-8-24.5-7.1-33.6,1.9l-42.2,42.2c-9.1,9.1-9.9,23.5-1.9,33.6l23,29.1 c-9.2,16.6-16.2,34.3-20.8,52.7l-36.8,4.2c-12.8,1.5-22.4,12.3-22.4,25.1v59.7c0,12.8,9.6,23.6,22.4,25.1L61.2,341.538z M277.5,180.038c54.4,0,98.7,44.3,98.7,98.7s-44.3,98.7-98.7,98.7c-54.399,0-98.7-44.3-98.7-98.7S223.1,180.038,277.5,180.038z"></path></svg>
</span>
` + (settings.settingPlacement == "menu" ? '<span class="_WKw">Settings</span>' : '') + `
</a>`

var primary = '';
var sec1 = '';
var sec2 = '';
Expand Down Expand Up @@ -65,7 +74,7 @@ function renderUI() {
</a>
</div>
<div id="myDropdown" class="dropdown-content">
` + sec1 + sec2 + `
` + sec1 + sec2 + (settings.settingPlacement == "menu" ? settingElement : '') + `
</div>
</td>`;

Expand All @@ -78,20 +87,14 @@ function renderUI() {


// Settings btn
settingsTemplate.innerHTML = `<td class="customSettingsBtn"> <a>
<span class="_RKw _wtf _Rtf">
<svg focusable="false" xmlns="http://www.w3.org/2000/svg" style="vertical-align: middle;align-content: center;" viewBox="-20 0 580 500"><path d="M61.2,341.538c4.9,16.8,11.7,33,20.3,48.2l-24.5,30.9c-8,10.1-7.1,24.5,1.9,33.6l42.2,42.2c9.1,9.1,23.5,9.899,33.6,1.899 l30.7-24.3c15.8,9.101,32.6,16.2,50.1,21.2l4.6,39.5c1.5,12.8,12.3,22.4,25.1,22.4h59.7c12.8,0,23.6-9.601,25.1-22.4l4.4-38.1 c18.8-4.9,36.8-12.2,53.7-21.7l29.7,23.5c10.1,8,24.5,7.1,33.6-1.9l42.2-42.2c9.1-9.1,9.9-23.5,1.9-33.6l-23.1-29.3 c9.6-16.601,17.1-34.3,22.1-52.8l35.6-4.1c12.801-1.5,22.4-12.3,22.4-25.1v-59.7c0-12.8-9.6-23.6-22.4-25.1l-35.1-4.1 c-4.801-18.3-12-35.8-21.199-52.2l21.6-27.3c8-10.1,7.1-24.5-1.9-33.6l-42.1-42.1c-9.1-9.1-23.5-9.9-33.6-1.9l-26.5,21 c-17.2-10.1-35.601-17.8-54.9-23l-4-34.3c-1.5-12.8-12.3-22.4-25.1-22.4h-59.7c-12.8,0-23.6,9.6-25.1,22.4l-4,34.3 c-19.8,5.3-38.7,13.3-56.3,23.8l-27.5-21.8c-10.1-8-24.5-7.1-33.6,1.9l-42.2,42.2c-9.1,9.1-9.9,23.5-1.9,33.6l23,29.1 c-9.2,16.6-16.2,34.3-20.8,52.7l-36.8,4.2c-12.8,1.5-22.4,12.3-22.4,25.1v59.7c0,12.8,9.6,23.6,22.4,25.1L61.2,341.538z M277.5,180.038c54.4,0,98.7,44.3,98.7,98.7s-44.3,98.7-98.7,98.7c-54.399,0-98.7-44.3-98.7-98.7S223.1,180.038,277.5,180.038z"></path></svg>
</span>
</a></td>`;
settingsTemplate.innerHTML = `<td class="customSettingsBtn">` + settingElement + `</td>`;
var settingsBtn = settingsTemplate.content.firstChild;






for (var i = 0; i < pages.length; i++) {
pages[i].appendChild(document.importNode(settingsBtn, true));
if (settings.settingPlacement != "menu") {
pages[i].appendChild(document.importNode(settingsBtn, true));
}
if (settings.placement == "default") {
pages[i].insertBefore(document.importNode(viewBtn, true), pages[i].firstChild);
} else {
Expand Down Expand Up @@ -142,7 +145,7 @@ function renderUI() {
}));

// Open settings
document.querySelectorAll('.customSettingsBtn a').forEach(x => x.addEventListener("click", function(e) {
document.querySelectorAll('.virSettingsBtn').forEach(x => x.addEventListener("click", function(e) {
SettingsOpen();
e.preventDefault();
}));
Expand Down Expand Up @@ -223,6 +226,15 @@ function SettingsOpen() {
<label for="virPlacementTraditional">Google's Original</label>
</div>
<div class="settingItem">
<h3>Settings placement</h3>
<input type="radio" id="virSetPlacementSep" name="settingPlacement" value="seperate" ` + (settings.settingPlacement == "seperate" ? "checked" : "") + `>
<label for="virSetPlacementSep">Seperate Button</label><br>
<input type="radio" id="virSetPlacementMenu" name="settingPlacement" value="menu" ` + (settings.settingPlacement == "menu" ? "checked" : "") + `>
<label for="virSetPlacementMenu">In Dropdown</label>
</div>
<div class="settingItem">
<h3>Advanced option</h3>
<input id="cSettingsNewTab" name="newTab" type="checkbox" ` + (settings.newTab ? 'checked' : '') + `>'View Image' opens in new tab</input>
Expand Down

0 comments on commit f622d5b

Please sign in to comment.