diff --git a/4chan_x.user.js b/4chan_x.user.js
index 053bc835a..94f7467b0 100644
--- a/4chan_x.user.js
+++ b/4chan_x.user.js
@@ -1144,7 +1144,6 @@
return Conf['Enable 4chan\'s extension'];
}
});
- $.on(d, 'AddSettingsSection', Settings.addSection);
if (!$.get('previousversion')) {
$.set('previousversion', g.VERSION);
$.on(d, '4chanXInitFinished', Settings.open);
@@ -1154,6 +1153,10 @@
Settings.addSection('Sauce', Settings.sauce);
Settings.addSection('Rice', Settings.rice);
Settings.addSection('Keybinds', Settings.keybinds);
+ $.on(d, 'AddSettingsSection', Settings.addSection);
+ $.on(d, 'OpenSettings', function(e) {
+ return Settings.open(e.detail.title);
+ });
if (Conf['Enable 4chan\'s extension']) {
return;
}
@@ -1164,13 +1167,13 @@
settings.disableAll = true;
return localStorage.setItem('4chan-settings', JSON.stringify(settings));
},
- open: function() {
- var html, link, links, overlay, section, _i, _len, _ref;
+ open: function(openSection) {
+ var html, link, links, overlay, section, sectionToOpen, _i, _len, _ref;
if (Settings.dialog) {
return;
}
$.event('CloseMenu');
- html = "
";
+ html = "";
Settings.dialog = overlay = $.el('div', {
id: 'overlay',
innerHTML: html
@@ -1185,9 +1188,16 @@
});
$.on(link, 'click', Settings.openSection.bind(section));
links.push(link, $.tn(' | '));
+ if (section.title === openSection) {
+ sectionToOpen = link;
+ }
}
links.pop();
- links[0].click();
+ if (sectionToOpen) {
+ sectionToOpen.click();
+ } else {
+ links[0].click();
+ }
$.add($('.sections-list', overlay), links);
$.on($('.close', overlay), 'click', Settings.close);
$.on(overlay, 'click', Settings.close);
@@ -1621,7 +1631,7 @@
save = $.get(type, '');
save = save ? "" + save + "\n" + re : re;
$.set(type, save);
- return Settings.open();
+ return Settings.open('Filter');
}
}
};
diff --git a/src/features.coffee b/src/features.coffee
index f8c9a6fce..cbebc9524 100644
--- a/src/features.coffee
+++ b/src/features.coffee
@@ -142,8 +142,6 @@ Settings =
order: 111
open: -> Conf['Enable 4chan\'s extension']
- $.on d, 'AddSettingsSection', Settings.addSection
-
unless $.get 'previousversion'
$.set 'previousversion', g.VERSION
$.on d, '4chanXInitFinished', Settings.open
@@ -153,6 +151,8 @@ Settings =
Settings.addSection 'Sauce', Settings.sauce
Settings.addSection 'Rice', Settings.rice
Settings.addSection 'Keybinds', Settings.keybinds
+ $.on d, 'AddSettingsSection', Settings.addSection
+ $.on d, 'OpenSettings', (e) -> Settings.open e.detail.title
return if Conf['Enable 4chan\'s extension']
settings = JSON.parse(localStorage.getItem '4chan-settings') or {}
@@ -160,7 +160,7 @@ Settings =
settings.disableAll = true
localStorage.setItem '4chan-settings', JSON.stringify settings
- open: ->
+ open: (openSection) ->
return if Settings.dialog
$.event 'CloseMenu'
@@ -170,7 +170,7 @@ Settings =
@@ -191,8 +191,12 @@ Settings =
href: 'javascript:;'
$.on link, 'click', Settings.openSection.bind section
links.push link, $.tn ' | '
+ sectionToOpen = link if section.title is openSection
links.pop()
- links[0].click()
+ if sectionToOpen
+ sectionToOpen.click()
+ else
+ links[0].click()
$.add $('.sections-list', overlay), links
$.on $('.close', overlay), 'click', Settings.close
@@ -589,11 +593,10 @@ Filter =
$.set type, save
# Open the settings and display & focus the relevant filter textarea.
- Settings.open()
+ Settings.open 'Filter'
# select = $ 'select[name=filter]', $.id 'options'
# select.value = type
# $.event select, new Event 'change'
- # $.id('filter_tab').checked = true
# ta = select.nextElementSibling
# tl = ta.textLength
# ta.setSelectionRange tl, tl