From cc8394de32a5ef0d2944d07ec744f6ee8785214c Mon Sep 17 00:00:00 2001 From: Misode Date: Wed, 23 Oct 2019 15:30:35 +0200 Subject: [PATCH 1/7] Add tooltips --- custom.css | 14 ++++++++++++++ view.js | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/custom.css b/custom.css index 1d873ce5..ef2eef47 100644 --- a/custom.css +++ b/custom.css @@ -1,4 +1,18 @@ +.btn-circle { + width: 30px; + height: 30px; + padding: 6px 0px; + border-radius: 20px; + text-align: center; + font-size: 1rem; + line-height: 1; + margin: auto; + background-color: #E9ECEF; + border-width: 1px; + border-color: #CED4DA; +} + .card.bg-info { background-color: #91cdd6 !important; color: black !important; diff --git a/view.js b/view.js index 593ee93c..3b955ac2 100644 --- a/view.js +++ b/view.js @@ -178,6 +178,9 @@ function generateEnum(data, struct) { } } $el.find('select').val(collection.includes(data) ? data : correctNamespace(data)); + if (struct.help) { + $el.append(generateTooltip(struct.translateValue + '.' + data.replace(/.*:/, ''))); + } return {out: data, component: $el}; } @@ -432,6 +435,12 @@ function generateField(data, field, parent) { return false; } +function generateTooltip(str) { + let $el = $(''); + $el.tooltip({title: i18next.t('$help.' + str)}); + return $el; +} + function preventNewline(e) { if (e.which === 13) { $(e.target).trigger('change'); From ef9efaf0e18579a6775a199e7078bc7e744a5155 Mon Sep 17 00:00:00 2001 From: Misode Date: Wed, 23 Oct 2019 15:43:56 +0200 Subject: [PATCH 2/7] Add help for entry type --- locales/en.json | 14 ++++++++++++++ schemas/1.13.json | 1 + schemas/1.14.json | 1 + schemas/1.15.json | 1 + 4 files changed, 17 insertions(+) diff --git a/locales/en.json b/locales/en.json index 542eeb64..12cbc02c 100644 --- a/locales/en.json +++ b/locales/en.json @@ -1,4 +1,18 @@ { + "$help": { + "$entry": { + "$type": { + "empty": "Adds nothing to the pool", + "item": "Adds a single item", + "tag": "Adds the contents of an item tag", + "loot_table": "Adds the contents of another loot table", + "alternatives": "Tests conditions of the child entries and executes the first that can run", + "sequence": "Executes child entries until the first one that can't run due to conditions", + "group": "Executes all child entries when own conditions pass", + "dynamic": "Gets block specific drops" + } + } + }, "$condition": { "$type": { "alternative": "Alternative", diff --git a/schemas/1.13.json b/schemas/1.13.json index 9b2e13ff..f1b177b1 100644 --- a/schemas/1.13.json +++ b/schemas/1.13.json @@ -52,6 +52,7 @@ "type": "enum", "translate": "$entry.type", "translateValue": "$entry.$type", + "help": true, "default": "minecraft:item", "values": [ "minecraft:empty", diff --git a/schemas/1.14.json b/schemas/1.14.json index bc49c3e9..0a3d6079 100644 --- a/schemas/1.14.json +++ b/schemas/1.14.json @@ -74,6 +74,7 @@ "type": "enum", "translate": "$entry.type", "translateValue": "$entry.$type", + "help": true, "default": "minecraft:item", "values": [ "minecraft:empty", diff --git a/schemas/1.15.json b/schemas/1.15.json index fa9202d7..b92c3e63 100644 --- a/schemas/1.15.json +++ b/schemas/1.15.json @@ -74,6 +74,7 @@ "type": "enum", "translate": "$entry.type", "translateValue": "$entry.$type", + "help": true, "default": "minecraft:item", "values": [ "minecraft:empty", From 3d6c60f6f72bdb1415a2f1d66b5d1dbce3545802 Mon Sep 17 00:00:00 2001 From: Misode Date: Thu, 24 Oct 2019 10:06:53 +0200 Subject: [PATCH 3/7] Add help to other field types --- custom.css | 2 +- locales/en.json | 3 +++ schemas/1.14.json | 3 ++- view.js | 27 ++++++++++++++++++++++++++- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/custom.css b/custom.css index ef2eef47..eb686555 100644 --- a/custom.css +++ b/custom.css @@ -1,5 +1,5 @@ -.btn-circle { +.help-tooltip { width: 30px; height: 30px; padding: 6px 0px; diff --git a/locales/en.json b/locales/en.json index 12cbc02c..73a6e2b2 100644 --- a/locales/en.json +++ b/locales/en.json @@ -11,6 +11,9 @@ "group": "Executes all child entries when own conditions pass", "dynamic": "Gets block specific drops" } + }, + "$pool": { + "rolls": "The amount of entries that are randomly chosen" } }, "$condition": { diff --git a/schemas/1.14.json b/schemas/1.14.json index 0a3d6079..6c4b418a 100644 --- a/schemas/1.14.json +++ b/schemas/1.14.json @@ -33,7 +33,8 @@ { "id": "rolls", "type": "random", - "translate": "$pool.rolls" + "translate": "$pool.rolls", + "help": true }, { "id": "bonus_rolls", diff --git a/view.js b/view.js index 3b955ac2..06850e59 100644 --- a/view.js +++ b/view.js @@ -2,6 +2,13 @@ let structure; let components; let collections; +i18next.on('initialized', () => { + $('[data-help]').each(function() { + console.log('ahhh'); + $(this).tooltip({title: i18next.t('$help.' + $(this).attr('data-help'))}); + }); +}); + changeVersion('1.14'); function changeVersion(version) { $.getJSON('schemas/' + version + '.json', json => { @@ -95,6 +102,9 @@ function generateString(data, struct) { $el.attr('data-index', struct.id); $el.find('[data-name]').attr('data-i18n', struct.translate); $el.find('input').val(data); + if (struct.help) { + $el.append(generateTooltip(struct.translate)); + } return {out: data, component: $el}; } @@ -107,6 +117,9 @@ function generateBoolean(data, struct) { } else if (data === false) { $el.find('[value="false"]').addClass('active'); } + if (struct.help) { + $el.append(generateTooltip(struct.translate)); + } return {out: data, component: $el}; } @@ -128,6 +141,9 @@ function generateRandom(data, struct) { $el.find('.exact').removeClass('d-none'); $el.find('.exact').val(data); } + if (struct.help) { + $el.append(generateTooltip(struct.translate)); + } return {out: data, component: $el}; } @@ -143,6 +159,9 @@ function generateRange(data, struct) { $el.find('.exact').removeClass('d-none'); $el.find('.exact').val(data); } + if (struct.help) { + $el.append(generateTooltip(struct.translate)); + } return {out: data, component: $el}; } @@ -154,6 +173,9 @@ function generateBoundary(data, struct) { $el.find('.range.min').val(data.min); $el.find('.range.max').val(data.max); } + if (struct.help) { + $el.append(generateTooltip(struct.translate)); + } return {out: data, component: $el}; } @@ -258,6 +280,9 @@ function generateJson(data, struct) { data = JSON.stringify(data); } $el.find('textarea').val(data).keydown(e => preventNewline(e)); + if (struct.help) { + $el.append(generateTooltip(struct.translate)); + } return {out: data, component: $el}; } @@ -436,7 +461,7 @@ function generateField(data, field, parent) { } function generateTooltip(str) { - let $el = $(''); + let $el = $(''); $el.tooltip({title: i18next.t('$help.' + str)}); return $el; } From 9377dfd78d6337490905ea5dad9df2b626e47f71 Mon Sep 17 00:00:00 2001 From: Misode Date: Thu, 14 Nov 2019 11:33:20 +0100 Subject: [PATCH 4/7] Add help translation strings --- locales/en.json | 9 +++++++++ view.js | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/locales/en.json b/locales/en.json index 67c8ba9e..66c961c0 100644 --- a/locales/en.json +++ b/locales/en.json @@ -206,6 +206,15 @@ "function.zoom": "Zoom", "function_add": "Add Function", "function_remove": "Remove Function", + "help.entry.type.alternatives": "Tests conditions of the child entries and executes the first that can run", + "help.entry.type.dynamic": "Gets block specific drops", + "help.entry.type.empty": "Adds nothing to the pool", + "help.entry.type.group": "Executes all child entries when own conditions pass", + "help.entry.type.item": "Adds a single item", + "help.entry.type.loot_table": "Adds the contents of another loot table", + "help.entry.type.sequence": "Executes child entries until the first one that can't run due to conditions", + "help.entry.type.tag": "Adds the contents of an item tag", + "help.pool.rolls": "The amount of entries that are randomly chosen", "hide_source": "Hide Source", "item.count": "Count", "item.durability": "Durability", diff --git a/view.js b/view.js index 06850e59..901ce1e5 100644 --- a/view.js +++ b/view.js @@ -5,7 +5,7 @@ let collections; i18next.on('initialized', () => { $('[data-help]').each(function() { console.log('ahhh'); - $(this).tooltip({title: i18next.t('$help.' + $(this).attr('data-help'))}); + $(this).tooltip({title: i18next.t('help.' + $(this).attr('data-help'))}); }); }); @@ -462,7 +462,7 @@ function generateField(data, field, parent) { function generateTooltip(str) { let $el = $(''); - $el.tooltip({title: i18next.t('$help.' + str)}); + $el.tooltip({title: i18next.t('help.' + str)}); return $el; } From 7f8b6a9470f98f0696340a40ed7770f97cce1d26 Mon Sep 17 00:00:00 2001 From: Misode Date: Thu, 14 Nov 2019 11:38:34 +0100 Subject: [PATCH 5/7] Add expand help --- locales/en.json | 1 + schemas/1.14.json | 1 + 2 files changed, 2 insertions(+) diff --git a/locales/en.json b/locales/en.json index 66c961c0..feee9401 100644 --- a/locales/en.json +++ b/locales/en.json @@ -206,6 +206,7 @@ "function.zoom": "Zoom", "function_add": "Add Function", "function_remove": "Remove Function", + "help.entry.expand": "If false, entry will return all contents of tag, otherwise entry will behave as multiple item entries", "help.entry.type.alternatives": "Tests conditions of the child entries and executes the first that can run", "help.entry.type.dynamic": "Gets block specific drops", "help.entry.type.empty": "Adds nothing to the pool", diff --git a/schemas/1.14.json b/schemas/1.14.json index a7d0a8af..d492021e 100644 --- a/schemas/1.14.json +++ b/schemas/1.14.json @@ -115,6 +115,7 @@ "type": "boolean", "default": "false", "translate": "entry.expand", + "help": true, "require": [ "minecraft:tag" ] From f96a515d77c991812a9e19a42e774bc622d0364e Mon Sep 17 00:00:00 2001 From: Misode Date: Thu, 19 Dec 2019 01:02:52 +0100 Subject: [PATCH 6/7] Fix tooltips not being localized on load --- i18n.js | 4 ++-- schemas/1.15.json | 1 + view.js | 7 ------- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/i18n.js b/i18n.js index d379e9d3..faee506f 100644 --- a/i18n.js +++ b/i18n.js @@ -17,11 +17,11 @@ i18next }) .then(() => { jqueryI18next.init(i18next, $, { parseDefaultValueFromContent: false }) - $('html').localize() + updateView() }) function changeLng(code) { i18next.changeLanguage(code).then(() => { - $('html').localize() + updateView() }) } diff --git a/schemas/1.15.json b/schemas/1.15.json index 06461363..cb512856 100644 --- a/schemas/1.15.json +++ b/schemas/1.15.json @@ -126,6 +126,7 @@ "type": "boolean", "default": "false", "translate": "entry.expand", + "help": true, "require": [ "minecraft:tag" ] diff --git a/view.js b/view.js index cc4bcb93..6b892c2e 100644 --- a/view.js +++ b/view.js @@ -2,13 +2,6 @@ let structure; let components; let collections; -i18next.on('initialized', () => { - $('[data-help]').each(function() { - console.log('ahhh'); - $(this).tooltip({title: i18next.t('help.' + $(this).attr('data-help'))}); - }); -}); - changeVersion('1.15'); function changeVersion(version) { $.getJSON('schemas/' + version + '.json', json => { From 494490d28b1d2630d7a2370a28f6730324abef16 Mon Sep 17 00:00:00 2001 From: Misode Date: Thu, 19 Dec 2019 02:43:10 +0100 Subject: [PATCH 7/7] Convert tabs to spaces --- locales/en.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/locales/en.json b/locales/en.json index 43e5e9c7..7c007b44 100644 --- a/locales/en.json +++ b/locales/en.json @@ -208,13 +208,13 @@ "function_add": "Add Function", "function_remove": "Remove Function", "help.entry.expand": "If false, entry will return all contents of tag, otherwise entry will behave as multiple item entries", - "help.entry.type.alternatives": "Tests conditions of the child entries and executes the first that can run", - "help.entry.type.dynamic": "Gets block specific drops", + "help.entry.type.alternatives": "Tests conditions of the child entries and executes the first that can run", + "help.entry.type.dynamic": "Gets block specific drops", "help.entry.type.empty": "Adds nothing to the pool", - "help.entry.type.group": "Executes all child entries when own conditions pass", + "help.entry.type.group": "Executes all child entries when own conditions pass", "help.entry.type.item": "Adds a single item", - "help.entry.type.loot_table": "Adds the contents of another loot table", - "help.entry.type.sequence": "Executes child entries until the first one that can't run due to conditions", + "help.entry.type.loot_table": "Adds the contents of another loot table", + "help.entry.type.sequence": "Executes child entries until the first one that can't run due to conditions", "help.entry.type.tag": "Adds the contents of an item tag", "help.pool.rolls": "The amount of entries that are randomly chosen", "hide_source": "Hide Source",