Skip to content

Commit

Permalink
add popup for when colorsettings is installed but not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ardittristan committed Jul 27, 2020
1 parent 9d29a72 commit 7ab88df
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.4.1

* Added one-time popup that asks the user if they want to enable colorsettings if it is installed but not enabled (when running as included library).

## 2.4.0

* Deprecated the use of `id="permanent"` in favor of `data-permanent`
Expand Down
43 changes: 32 additions & 11 deletions colorSetting.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ class colorPickerInput extends HTMLInputElement {
});
}

if(this.dataset.responsiveColor !== undefined && this.value != undefined && this.value.length != 0 && this.value.startsWith("#") && this.value.match(/[^A-Fa-f0-9#]+/g) == null) {
this.style.backgroundColor = this.value
this.style.color = getTextColor(this.value)
if (this.dataset.responsiveColor !== undefined && this.value != undefined && this.value.length != 0 && this.value.startsWith("#") && this.value.match(/[^A-Fa-f0-9#]+/g) == null) {
this.style.backgroundColor = this.value;
this.style.color = getTextColor(this.value);
}
}

Expand Down Expand Up @@ -322,18 +322,18 @@ class colorPickerButton extends HTMLButtonElement {
this._makePicker = this._makePicker.bind(this);
this.visible = false;
// check if picker should be always shown.

this.addEventListener("click", (event) => {
event.preventDefault()
event.preventDefault();
if (!this.visible) {
this.visible = true;
this._makePicker();
}
});

if(this.dataset.responsiveColor !== undefined && this.value != undefined && this.value.length != 0 && this.value.startsWith("#") && this.value.match(/[^A-Fa-f0-9#]+/g) == null) {
this.style.backgroundColor = this.value
this.style.color = getTextColor(this.value)
if (this.dataset.responsiveColor !== undefined && this.value != undefined && this.value.length != 0 && this.value.startsWith("#") && this.value.match(/[^A-Fa-f0-9#]+/g) == null) {
this.style.backgroundColor = this.value;
this.style.color = getTextColor(this.value);
}
}

Expand All @@ -350,7 +350,7 @@ class colorPickerButton extends HTMLButtonElement {
parent: this.parentElement,
cancelButton: true,
onDone: (color) => {

this.picker.destroy();
this.visible = false;
Hooks.call('pickerDone',
Expand All @@ -367,7 +367,7 @@ class colorPickerButton extends HTMLButtonElement {
}
});

jQuery(this.picker.domElement).insertAfter(this)
jQuery(this.picker.domElement).insertAfter(this);

if (this.picker._domCancel) {
this.picker._domCancel.textContent = " Eye Dropper";
Expand Down Expand Up @@ -521,9 +521,30 @@ Hooks.once('init', function () {
/** @type {String} */
const scriptLocation = getRunningScript()();
if (!scriptLocation.includes("modules/colorsettings/")) {
if (game.modules.get("colorsettings")) {
if (game.modules.has("colorsettings")) {
if (game.modules.get("colorsettings").active) {
return;
} else {
game.settings.register("colorsettings", "autoEnable", {
config: false,
type: Boolean,
default: true
})
Hooks.once("canvasReady", () => {
if (game.user.isGM && game.settings.get("colorsettings", "autoEnable")) {
Dialog.confirm({
title: "Enable Color Settings module?",
content: "<p>You seem to have Color Settings installed already, do you want to enable it?</p>",
yes: () => game.settings.set("core", ModuleManagement.CONFIG_SETTING, {
...game.settings.get("core", ModuleManagement.CONFIG_SETTING),
...{ colorsettings: true }
}),
no: () => game.settings.set("colorsettings", "autoEnable", false),
defaultYes: false
});

}
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "colorsettings",
"title": "lib - Color Settings",
"description": "Library that allows modules to add color settings and forms.",
"version": "2.4.0",
"version": "2.4.1",
"author": "ardittristan#0001",
"esmodules": ["colorSetting.js"],
"socket": true,
Expand Down

0 comments on commit 7ab88df

Please sign in to comment.