summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/views/details/details.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-12-15 06:52:54 +0100
committerJules Laplace <julescarbon@gmail.com>2017-12-15 06:52:54 +0100
commita1b33089877660ba33331d76281e68790f35ae44 (patch)
tree168692d34f8af123ef2bab505a3cdbe4d1d57229 /public/assets/js/lib/views/details/details.js
parent7ad469291c015b33a2d20587db26b9621ed82d00 (diff)
keywords list
Diffstat (limited to 'public/assets/js/lib/views/details/details.js')
-rw-r--r--public/assets/js/lib/views/details/details.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/public/assets/js/lib/views/details/details.js b/public/assets/js/lib/views/details/details.js
new file mode 100644
index 0000000..1b67b92
--- /dev/null
+++ b/public/assets/js/lib/views/details/details.js
@@ -0,0 +1,60 @@
+var DetailsView = View.extend({
+
+ events: {
+ },
+
+ action: "/api/thread/",
+ keywordAction: "/api/keyword/",
+
+ initialize: function(opt){
+ this.comments = new CommentsView ({ parent: this })
+ this.files = new FilesView ({ parent: this })
+ this.gallery = new GalleryView ({ parent: this })
+ this.form = new CommentForm ({ parent: this })
+ this.threadbox = new ThreadBox ({ parent: this })
+ this.settings = new ThreadSettingsForm ({ parent: this })
+ $(".settings_link").click(this.openSettings.bind(this))
+ },
+
+ load: function(id){
+ id = id.replace(/\D/g, "")
+ $.ajax({
+ method: "get",
+ url: this.action + id,
+ success: this.populate.bind(this),
+ error: app.router.error404,
+ })
+ },
+
+ populate: function(data){
+ this.data = data
+ // console.log(data)
+ set_background_color(data.thread.color || (data.keyword ? data.keyword.color : 'plain'))
+ $("body").removeClass('loading')
+ var thread = data.thread
+ $("h1").html(sanitize(thread.title))
+ $("title").html(sanitize(thread.title))
+ $(".metadata").html(metadata(thread))
+ $(".settings_link").attr("href", "/details/" + thread.id + "/settings")
+ this.form.load(data.thread)
+ 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))
+ }
+ if (this.options.settings) {
+ this.openSettings()
+ }
+ },
+
+ populateKeyword: function(data){
+ this.threadbox.load(data)
+ },
+
+ openSettings: function(e){
+ e && e.preventDefault()
+ this.settings.show()
+ },
+
+})