diff --git a/tildes/static/js/behaviors/comment-text.js b/tildes/static/js/behaviors/comment-text.js index c14aa6f..b542b93 100644 --- a/tildes/static/js/behaviors/comment-text.js +++ b/tildes/static/js/behaviors/comment-text.js @@ -1,4 +1,7 @@ $.onmount('[data-js-comment-text]', function() { - // Make all links in comment open in new tab - $(this).find('a').attr('target', '_blank'); + // Check for setting (default to false if not set) + if (localStorage.getItem('open_new_tab_text') == 'true') { + // Make all links in comment open in new tab + $(this).find('a').attr('target', '_blank'); + } }); diff --git a/tildes/static/js/behaviors/open-new-tab-text-input.js b/tildes/static/js/behaviors/open-new-tab-text-input.js new file mode 100644 index 0000000..4bebbb9 --- /dev/null +++ b/tildes/static/js/behaviors/open-new-tab-text-input.js @@ -0,0 +1,5 @@ +$.onmount('[data-js-open-new-tab-text]', function() { + $(this).change(function() { + localStorage.setItem('open_new_tab_text', $(this).is(':checked')); + }); +}); diff --git a/tildes/tildes/templates/settings.jinja2 b/tildes/tildes/templates/settings.jinja2 index 1000614..1299756 100644 --- a/tildes/tildes/templates/settings.jinja2 +++ b/tildes/tildes/templates/settings.jinja2 @@ -80,6 +80,7 @@ type="checkbox" id="open_new_tab_text" name="open_new_tab_text" + data-js-open-new-tab-text data-js-autosubmit-on-change {% if request.user.open_new_tab_text %}checked{% endif %} >