add randomize button
This commit is contained in:
parent
a62a175768
commit
0808fa850f
2 changed files with 15 additions and 0 deletions
|
@ -4,6 +4,8 @@
|
||||||
%><wbr/><%
|
%><wbr/><%
|
||||||
%><input class='mousetrap' type='submit' value='Search'/><%
|
%><input class='mousetrap' type='submit' value='Search'/><%
|
||||||
%><wbr/><%
|
%><wbr/><%
|
||||||
|
%><button id="random-button" style="padding:0.2em; margin-right:0.25em; margin-bottom:0.25em;"><i class="fa fa-random"></button><%
|
||||||
|
%><wbr/><%
|
||||||
%><% if (ctx.enableSafety) { %><%
|
%><% if (ctx.enableSafety) { %><%
|
||||||
%><input data-safety=safe type='button' class='mousetrap safety safety-safe <%- ctx.settings.listPosts.safe ? '' : 'disabled' %>'/><%
|
%><input data-safety=safe type='button' class='mousetrap safety safety-safe <%- ctx.settings.listPosts.safe ? '' : 'disabled' %>'/><%
|
||||||
%><input data-safety=sketchy type='button' class='mousetrap safety safety-sketchy <%- ctx.settings.listPosts.sketchy ? '' : 'disabled' %>'/><%
|
%><input data-safety=sketchy type='button' class='mousetrap safety safety-sketchy <%- ctx.settings.listPosts.sketchy ? '' : 'disabled' %>'/><%
|
||||||
|
|
|
@ -145,6 +145,7 @@ class PostsHeaderView extends events.EventTarget {
|
||||||
'click', e => this._evtSafetyButtonClick(e));
|
'click', e => this._evtSafetyButtonClick(e));
|
||||||
}
|
}
|
||||||
this._formNode.addEventListener('submit', e => this._evtFormSubmit(e));
|
this._formNode.addEventListener('submit', e => this._evtFormSubmit(e));
|
||||||
|
this._randomButtonNode.addEventListener('click', e => this._evtRandomButtonClick(e));
|
||||||
|
|
||||||
this._bulkEditors = [];
|
this._bulkEditors = [];
|
||||||
if (this._bulkEditTagsNode) {
|
if (this._bulkEditTagsNode) {
|
||||||
|
@ -191,6 +192,10 @@ class PostsHeaderView extends events.EventTarget {
|
||||||
return this._hostNode.querySelector('form [name=search-text]');
|
return this._hostNode.querySelector('form [name=search-text]');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get _randomButtonNode() {
|
||||||
|
return this._hostNode.querySelector('#random-button');
|
||||||
|
}
|
||||||
|
|
||||||
get _bulkEditTagsNode() {
|
get _bulkEditTagsNode() {
|
||||||
return this._hostNode.querySelector('.bulk-edit-tags');
|
return this._hostNode.querySelector('.bulk-edit-tags');
|
||||||
}
|
}
|
||||||
|
@ -242,6 +247,14 @@ class PostsHeaderView extends events.EventTarget {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this._navigate();
|
this._navigate();
|
||||||
}
|
}
|
||||||
|
_evtRandomButtonClick(e) {
|
||||||
|
if (!this._queryInputNode.value.includes('sort:random')) {
|
||||||
|
this._queryInputNode.value += ' sort:random';
|
||||||
|
} else {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
this._navigate();
|
||||||
|
}
|
||||||
|
|
||||||
_navigate() {
|
_navigate() {
|
||||||
this._autoCompleteControl.hide();
|
this._autoCompleteControl.hide();
|
||||||
|
|
Reference in a new issue