[feature] add random theme name control

This commit is contained in:
zombieFox 2020-01-21 07:35:09 +00:00
parent 3b7cda4199
commit 52e5e9b783
5 changed files with 32 additions and 14 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "nighttab", "name": "nighttab",
"version": "4.26.0", "version": "4.27.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "nighttab", "name": "nighttab",
"version": "4.26.0", "version": "4.27.0",
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.", "description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -1705,22 +1705,40 @@ var theme = (function() {
options = helper.applyOptions(options, override); options = helper.applyOptions(options, override);
}; };
var form = helper.node("form|class:group-form"); var form = helper.node("form|class:group-form");
var fieldset = helper.node("fieldset");
var inputWrap = helper.node("div|class:form-wrap"); var nameFieldset = helper.node("fieldset");
var label = helper.node("label:Name|for:theme-name"); var nameFormWrap = helper.node("div|class:form-wrap");
var input = helper.node("input|id:theme-name,class:theme-name mb-0,type:text,tabindex:1,placeholder:Example theme,autocomplete:off,autocorrect:off,autocapitalize:off,spellcheck:false"); var nameLabel = helper.node("label:Name|for:theme-name");
inputWrap.appendChild(label); var nameInput = helper.node("input|id:theme-name,class:theme-name mb-0,type:text,tabindex:1,placeholder:Example theme,autocomplete:off,autocorrect:off,autocapitalize:off,spellcheck:false");
inputWrap.appendChild(input);
fieldset.appendChild(inputWrap); var randomFormWrap = helper.node("div|class:form-wrap");
form.appendChild(fieldset); var randomButton = helper.node("button:Random Theme name|class:button,type:button,tabindex:1");
randomFormWrap.appendChild(randomButton);
nameFormWrap.appendChild(nameLabel);
nameFormWrap.appendChild(nameInput);
nameFieldset.appendChild(nameFormWrap);
nameFieldset.appendChild(randomFormWrap);
form.appendChild(nameFieldset);
if (options.useStagedTheme) { if (options.useStagedTheme) {
input.value = stagedThemeCustom.theme.name; nameInput.value = stagedThemeCustom.theme.name;
}; };
input.addEventListener("input", function() { nameInput.addEventListener("input", function() {
stagedThemeCustom.theme.name = this.value; stagedThemeCustom.theme.name = this.value;
}, false); }, false);
randomButton.addEventListener("click", function(event) {
var randomName = helper.randomString({
mix: true
});
stagedThemeCustom.theme.name = randomName;
nameInput.value = randomName;
}, false);
form.addEventListener("keydown", function(event) { form.addEventListener("keydown", function(event) {
if (event.keyCode == 13) { if (event.keyCode == 13) {
event.preventDefault(); event.preventDefault();

View File

@ -1,6 +1,6 @@
var version = (function() { var version = (function() {
var current = "4.26.0"; var current = "4.27.0";
var name = "Naughty Goose"; var name = "Naughty Goose";

View File

@ -2,7 +2,7 @@
"name": "nightTab", "name": "nightTab",
"short_name": "nightTab", "short_name": "nightTab",
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.", "description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
"version": "4.26.0", "version": "4.27.0",
"manifest_version": 2, "manifest_version": 2,
"chrome_url_overrides": { "chrome_url_overrides": {
"newtab": "index.html" "newtab": "index.html"