summaryrefslogtreecommitdiff
path: root/public/assets/js/lib
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/js/lib')
-rw-r--r--public/assets/js/lib/views/details/commentform.js3
-rw-r--r--public/assets/js/lib/views/details/comments.js10
-rw-r--r--public/assets/js/lib/views/details/index.js6
-rw-r--r--public/assets/js/lib/views/details/settings.js27
4 files changed, 36 insertions, 10 deletions
diff --git a/public/assets/js/lib/views/details/commentform.js b/public/assets/js/lib/views/details/commentform.js
index e082248..b3f37bc 100644
--- a/public/assets/js/lib/views/details/commentform.js
+++ b/public/assets/js/lib/views/details/commentform.js
@@ -16,6 +16,9 @@ var CommentForm = FormView.extend({
load: function(thread){
this.action = "/api/thread/" + thread.id + "/comment"
+ if (thread.settings.noupload) {
+ this.$("[type=file]").hide()
+ }
},
focus: function(){
diff --git a/public/assets/js/lib/views/details/comments.js b/public/assets/js/lib/views/details/comments.js
index 473fb22..4c217a4 100644
--- a/public/assets/js/lib/views/details/comments.js
+++ b/public/assets/js/lib/views/details/comments.js
@@ -14,8 +14,14 @@ var CommentsView = FormView.extend({
this.$formRow = this.$("#comment_form")
},
- load: function(comments){
- comments.forEach(this.appendComment.bind(this))
+ load: function(comments, thread){
+ if (thread.settings.hootbox) {
+ comments.forEach(this.prependComment.bind(this))
+ this.$el.prepend(this.$formRow)
+ }
+ else {
+ comments.forEach(this.appendComment.bind(this))
+ }
},
parse: function(comment){
diff --git a/public/assets/js/lib/views/details/index.js b/public/assets/js/lib/views/details/index.js
index f8e9d50..871ac62 100644
--- a/public/assets/js/lib/views/details/index.js
+++ b/public/assets/js/lib/views/details/index.js
@@ -37,9 +37,9 @@ var DetailsView = View.extend({
$(".metadata").html(metadata(thread))
$(".settings_link").attr("href", "/details/" + thread.id + "/settings")
this.form.load(data.thread)
- this.comments.load(data.comments)
- this.files.load(data.files)
- this.gallery.load(data.files)
+ this.comments.load(data.comments, data.thread)
+ this.files.load(data.files, data.thread)
+ this.gallery.load(data.files, data.thread)
if (data.thread.keyword) {
$.get(this.keywordAction + data.thread.keyword, this.populateKeyword.bind(this))
}
diff --git a/public/assets/js/lib/views/details/settings.js b/public/assets/js/lib/views/details/settings.js
index eacbec4..777a9ba 100644
--- a/public/assets/js/lib/views/details/settings.js
+++ b/public/assets/js/lib/views/details/settings.js
@@ -19,9 +19,6 @@ var ThreadSettingsForm = FormView.extend({
},
populate: function(){
- // this.action = "/api/thread/" + data.id
- $("body").removeClass("loading")
-
var data = this.options.parent.data
var keywords = data.keywords
var keyword = data.keyword
@@ -31,10 +28,16 @@ var ThreadSettingsForm = FormView.extend({
var settings = thread.settings
var display = thread.display
+ this.action = "/api/thread/" + thread.id
+
this.$(".close_link").attr("href", "/details/" + thread.id)
this.$(".metadata").html(metadata(thread))
this.$("[name=title]").val(sanitize(thread.title))
+ this.$("[name=hootbox]").prop("checked", !!thread.settings.hootbox)
+ this.$("[name=shorturls]").prop("checked", !!thread.settings.shorturls)
+ this.$("[name=noupload]").prop("checked", !!thread.settings.noupload)
+
var $color = this.$('[name=color]')
Object.keys(COLORS).forEach((color) => {
var option = document.createElement('option')
@@ -57,6 +60,8 @@ var ThreadSettingsForm = FormView.extend({
})
$keyword.val(thread.keyword)
}.bind(this))
+
+ $("body").removeClass("loading")
},
validate: function(){
@@ -67,12 +72,24 @@ var ThreadSettingsForm = FormView.extend({
}
return errors.length ? errors : null
},
-
+
serialize: function(){
+ var data = {
+ title: $("[name=title]").val(),
+ keyword: $("[name=keyword]").val(),
+ color: $("[name=color]").val(),
+ settings: {
+ hootbox: $("[name=hootbox]:checked").val() ? true : false,
+ shorturls: $("[name=shorturls]:checked").val() ? true : false,
+ noupload: $("[name=noupload]:checked").val() ? true : false,
+ }
+ }
+ return JSON.stringify(data)
},
success: function(data){
- window.location.href = "/details/" + data.comment.thread
+ console.log(data)
+ window.location.href = "/details/" + this.options.parent.data.thread.id
},
visible: false,