Add possibility to open a specific settings section.
This commit is contained in:
parent
64b09feac3
commit
80ede65e38
@ -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 = "<div id=settings class=dialog>\n <nav>\n <div class=sections-list></div>\n <div class=credits>\n <a href='http://mayhemydg.github.com/4chan-x/' target=_blank>4chan X Alpha</a> |\n <a href='https://github.com/MayhemYDG/4chan-x/blob/v3/changelog' target=_blank>3.0.0</a> |\n <a href='https://github.com/MayhemYDG/4chan-x/issues' target=_blank>Issues</a> |\n <a href=javascript:; class=close title=Close>×</a>\n </div>\n </nav>\n <hr>\n <div class=section-container><section></section></div>\n</div>";
|
||||
html = "<div id=settings class=dialog>\n <nav>\n <div class=sections-list></div>\n <div class=credits>\n <a href='http://mayhemydg.github.com/4chan-x/' target=_blank>4chan X Alpha</a> |\n <a href='https://github.com/MayhemYDG/4chan-x/blob/v3/changelog' target=_blank>" + g.VERSION + "</a> |\n <a href='https://github.com/MayhemYDG/4chan-x/issues' target=_blank>Issues</a> |\n <a href=javascript:; class=close title=Close>×</a>\n </div>\n </nav>\n <hr>\n <div class=section-container><section></section></div>\n</div>";
|
||||
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');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -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 =
|
||||
<div class=sections-list></div>
|
||||
<div class=credits>
|
||||
<a href='<%= meta.page %>' target=_blank><%= meta.name %></a> |
|
||||
<a href='<%= meta.repo %>blob/<%= meta.mainBranch %>/changelog' target=_blank><%= version %></a> |
|
||||
<a href='<%= meta.repo %>blob/<%= meta.mainBranch %>/changelog' target=_blank>#{g.VERSION}</a> |
|
||||
<a href='<%= meta.repo %>issues' target=_blank>Issues</a> |
|
||||
<a href=javascript:; class=close title=Close>×</a>
|
||||
</div>
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user