[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",
"version": "4.26.0",
"version": "4.27.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"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.",
"main": "index.js",
"scripts": {

View File

@ -1705,22 +1705,40 @@ var theme = (function() {
options = helper.applyOptions(options, override);
};
var form = helper.node("form|class:group-form");
var fieldset = helper.node("fieldset");
var inputWrap = helper.node("div|class:form-wrap");
var label = helper.node("label:Name|for:theme-name");
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");
inputWrap.appendChild(label);
inputWrap.appendChild(input);
fieldset.appendChild(inputWrap);
form.appendChild(fieldset);
var nameFieldset = helper.node("fieldset");
var nameFormWrap = helper.node("div|class:form-wrap");
var nameLabel = helper.node("label:Name|for:theme-name");
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");
var randomFormWrap = helper.node("div|class:form-wrap");
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) {
input.value = stagedThemeCustom.theme.name;
nameInput.value = stagedThemeCustom.theme.name;
};
input.addEventListener("input", function() {
nameInput.addEventListener("input", function() {
stagedThemeCustom.theme.name = this.value;
}, 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) {
if (event.keyCode == 13) {
event.preventDefault();

View File

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

View File

@ -2,7 +2,7 @@
"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.",
"version": "4.26.0",
"version": "4.27.0",
"manifest_version": 2,
"chrome_url_overrides": {
"newtab": "index.html"