summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
Diffstat (limited to 'public')
-rw-r--r--public/assets/css/hootstream.css1
-rw-r--r--public/assets/js/lib/views/stream/hootfilters.js66
-rw-r--r--public/assets/js/lib/views/stream/index.js3
3 files changed, 60 insertions, 10 deletions
diff --git a/public/assets/css/hootstream.css b/public/assets/css/hootstream.css
index 9cd3be3..c563ba6 100644
--- a/public/assets/css/hootstream.css
+++ b/public/assets/css/hootstream.css
@@ -328,6 +328,7 @@
opacity: 0.8;
transition: opacity 0.1s;
}
+#hootfilters input[type="checkbox"],
#hootfilters input[type="radio"] {
display: none;
}
diff --git a/public/assets/js/lib/views/stream/hootfilters.js b/public/assets/js/lib/views/stream/hootfilters.js
index 5b46a1d..f1cf107 100644
--- a/public/assets/js/lib/views/stream/hootfilters.js
+++ b/public/assets/js/lib/views/stream/hootfilters.js
@@ -15,7 +15,9 @@ var HootFilters = View.extend({
this.$hoots = this.$("[name=hoots]");
this.$sortOrder = this.$(".sort");
this.$sort = this.$("[name=sort]");
+ this.$classicLink = this.$(".classicLink");
this.state = {
+ unset: true,
images: true,
music: true,
files: true,
@@ -23,10 +25,6 @@ var HootFilters = View.extend({
sort: "date",
order: "desc",
};
- this.$images.prop("checked", this.state.images);
- this.$music.prop("checked", this.state.music);
- this.$files.prop("checked", this.state.files);
- this.$hoots.prop("checked", this.state.hoots);
this.$sort.filter(`[value=${this.state.sort}]`).prop("checked", true);
this.update(this.state);
},
@@ -48,9 +46,13 @@ var HootFilters = View.extend({
? this.state.order === "asc"
: this.state.order === "desc"
);
+ this.$images.prop("checked", this.state.images);
+ this.$music.prop("checked", this.state.music);
+ this.$files.prop("checked", this.state.files);
+ this.$hoots.prop("checked", this.state.hoots);
},
- load: function ({ threads, comments, files, hootbox, lastlog }) {
+ load: function ({ threads, comments, files, hootbox, lastlog }, target) {
const hoots = !!(hootbox?.length || lastlog?.length || comments?.length);
const music = !!files.some((file) => AUDIO_REGEXP.test(file.filename));
const images = !!files.some((file) => IMAGE_REGEXP.test(file.filename));
@@ -62,15 +64,61 @@ var HootFilters = View.extend({
this.$music.closest("label").toggle(music);
this.$hoots.closest("label").toggle(hoots);
this.$files.closest("label").toggle(normal_files);
+ if (target.thread || target.keyword || target.username) {
+ let classicHref, classicText;
+ if (target.thread) {
+ classicHref = `/details/${target.thread}`;
+ classicText = "thread";
+ } else if (target.keyword) {
+ classicHref = `/index/${target.keyword}`;
+ classicText = "keyword";
+ } else if (target.username) {
+ classicHref = `/profile/${target.username}`;
+ classicText = "profile";
+ }
+ console.log(classicHref, classicText);
+ this.$classicLink.show();
+ this.$classicLink.find("a").attr("href", classicHref).html(classicText);
+ } else {
+ this.$classicLink.hide();
+ }
},
filter: function (event) {
const { name, checked } = event.target;
// console.log(name, checked);
- this.update({
- ...this.state,
- [name]: checked,
- });
+ console.log(this.state.unset, name, checked);
+ if (this.state.unset) {
+ this.update({
+ ...this.state,
+ unset: false,
+ images: false,
+ music: false,
+ files: false,
+ hoots: false,
+ [name]: true,
+ });
+ // $(event.target).prop("checked", true);
+ } else if (this.state[name] === true) {
+ this.update({
+ ...this.state,
+ unset: true,
+ images: true,
+ music: true,
+ files: true,
+ hoots: true,
+ });
+ } else {
+ this.update({
+ ...this.state,
+ unset: false,
+ images: false,
+ music: false,
+ files: false,
+ hoots: false,
+ [name]: checked,
+ });
+ }
this.parent.onFilter(this.state);
},
diff --git a/public/assets/js/lib/views/stream/index.js b/public/assets/js/lib/views/stream/index.js
index e961fc2..bfd042a 100644
--- a/public/assets/js/lib/views/stream/index.js
+++ b/public/assets/js/lib/views/stream/index.js
@@ -10,6 +10,7 @@ var StreamView = View.extend({
load: function ({ ...target }) {
$("body").addClass("index");
+ this.target = target;
console.log("target", target);
$.get(this.action, target, this.populate.bind(this));
},
@@ -17,7 +18,7 @@ var StreamView = View.extend({
populate: function (data) {
$("body").removeClass("loading");
this.data = data;
- this.hootfilters.load(data);
+ this.hootfilters.load(data, this.target);
this.hootstream.load(data, this.hootfilters.state);
if (data.mail.count) {
$(".alert")