diff --git a/MainPage.cs b/MainPage.cs index d739c1b..f8acad3 100644 --- a/MainPage.cs +++ b/MainPage.cs @@ -372,7 +372,10 @@ @media screen and (max-width: 1090px) and (min-width: 650.01px) {{ new H4(translation.linkOption), translation.Selectables.Select(sel => new DIV( new INPUT { type = itype.radio, class_ = "set-selectable", name = "selectable", id = $"selectable-{sel.PropName}" }.Data("selectable", sel.PropName), " ", - new LABEL { class_ = "set-selectable", id = $"selectable-label-{sel.PropName}", for_ = $"selectable-{sel.PropName}", accesskey = sel.Accel?.ToString().ToLowerInvariant() }._(sel.HumanReadable.Accel(sel.Accel))))), + new LABEL { class_ = "set-selectable", id = $"selectable-label-{sel.PropName}", for_ = $"selectable-{sel.PropName}", accesskey = sel.Accel?.ToString().ToLowerInvariant() }._(sel.HumanReadable.Accel(sel.Accel)))), + new INPUT { type = itype.checkbox, class_= "set-new-tab", id = "set-new-tab"}, + new LABEL {for_ = "set-new-tab"}._(translation.newTab) + ), new DIV { class_ = "option-group" }._(new H4(translation.languagesOption), new DIV { id = "languages-option" }), new BUTTON { class_ = "toggle-all-languages" }._(translation.languagesToggle)), diff --git a/Resources/KtaneWeb.js b/Resources/KtaneWeb.js index 49fbec6..8dfa7a0 100644 --- a/Resources/KtaneWeb.js +++ b/Resources/KtaneWeb.js @@ -154,6 +154,7 @@ function initializePage(modules, initIcons, initDocDirs, initFilters, initSelect try { filter = JSON.parse(lStorage.getItem('filters') || '{}') || {}; } catch (exc) { } let selectable = lStorage.getItem('selectable') || 'manual'; + let currentTarget = lStorage.getItem('currentTarget') || '_self'; if (initSelectables.map(sel => sel.PropName).indexOf(selectable) === -1) selectable = 'manual'; let preferredManuals = {}; @@ -1605,8 +1606,19 @@ function initializePage(modules, initIcons, initDocDirs, initFilters, initSelect // This also calls updateFilter() setSelectable(selectable); - + $('input.set-selectable').click(function() { setSelectable($(this).data('selectable')); }); + $('input.set-new-tab').change(function(event){ + currentTarget = event.target.checked?"_blank":"_self"; + lStorage.setItem('currentTarget', currentTarget); + for (let el of document.getElementsByClassName("modlink")){ + el.setAttribute('target', currentTarget); + } + }); + $('input.set-new-tab')[0].checked = (lStorage.getItem('currentTarget') === "_blank"); + for (let el of document.getElementsByClassName("modlink")){ + el.setAttribute('target', currentTarget); + } $('input.filter').click(function() { updateFilter(); }); $("input.results-mode").click(function() { setResultsMode(this.value, resultsLimit); }); $("input#results-limit").change(function() { setResultsMode(resultsMode, this.value | 0); }); diff --git a/TranslationInfo.cs b/TranslationInfo.cs index 1cffbfa..c35fcad 100644 --- a/TranslationInfo.cs +++ b/TranslationInfo.cs @@ -232,6 +232,7 @@ private static TranslationInfo makeDefault() public string selectableSource = "Source code"; public string selectableSourceClone = "Source code (clone)"; public string selectableTutorial = "Tutorial videos"; + public string newTab = "Always open in new tab"; public string displayOption = "Display"; public string displayOriginalName = "Original name"; public string displayOriginalNameTooltip = "Displays the original (English-language) name in addition to the translated name.";