summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/views/details
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/js/lib/views/details')
-rw-r--r--public/assets/js/lib/views/details/audio.js5
-rw-r--r--public/assets/js/lib/views/details/commentform.js10
-rw-r--r--public/assets/js/lib/views/details/files.js2
-rw-r--r--public/assets/js/lib/views/details/index.js4
4 files changed, 14 insertions, 7 deletions
diff --git a/public/assets/js/lib/views/details/audio.js b/public/assets/js/lib/views/details/audio.js
index 6a8f5ed..42f5376 100644
--- a/public/assets/js/lib/views/details/audio.js
+++ b/public/assets/js/lib/views/details/audio.js
@@ -3,6 +3,7 @@ var audio = (function(){
var el, music = [], current_index = -1
var links, comment, parent
+ var playing = false
audio.init = function () {
links = document.querySelectorAll("a")
@@ -19,6 +20,7 @@ var audio = (function(){
audio.build = function () {
el = document.createElement("audio")
el.setAttribute("controls", true)
+ el.addEventListener("loadeddata", () => { if (playing) el.play() })
el.addEventListener("ended", audio.next)
el.src = music[0]
parent.appendChild(el)
@@ -33,8 +35,7 @@ var audio = (function(){
audio.play = function (index) {
current_index = (parseInt(index) + music.length) % music.length
el.src = music[current_index].href
- el.play()
- var playing = document.querySelector(".playing")
+ playing = document.querySelector(".playing")
if (playing) playing.classList.remove("playing")
music[current_index].classList.add("playing")
}
diff --git a/public/assets/js/lib/views/details/commentform.js b/public/assets/js/lib/views/details/commentform.js
index 3b82ac7..e082248 100644
--- a/public/assets/js/lib/views/details/commentform.js
+++ b/public/assets/js/lib/views/details/commentform.js
@@ -3,6 +3,7 @@ var CommentForm = FormView.extend({
el: "#comment_form",
events: {
+ "focus textarea": 'focus',
},
action: "",
@@ -17,11 +18,16 @@ var CommentForm = FormView.extend({
this.action = "/api/thread/" + thread.id + "/comment"
},
+ focus: function(){
+ this.$el.addClass('focused')
+ },
+
validate: function(){
var errors = []
var comment = $("[name=comment]").val()
- if (! comment || ! comment.length) {
- errors.push("Please enter a comment.")
+ var files = this.$("[name=files]").val()
+ if ((! comment || ! comment.length) && ! files) {
+ errors.push("Please enter a comment or add some files.")
}
return errors.length ? errors : null
},
diff --git a/public/assets/js/lib/views/details/files.js b/public/assets/js/lib/views/details/files.js
index b81d20c..ad2df85 100644
--- a/public/assets/js/lib/views/details/files.js
+++ b/public/assets/js/lib/views/details/files.js
@@ -19,7 +19,7 @@ var FilesView = FormView.extend({
var total = 0, has_music = false
files.forEach(function(file){
if (is_image(file.filename)) {
- return
+ // return
}
this.appendFile(file)
total += file.size
diff --git a/public/assets/js/lib/views/details/index.js b/public/assets/js/lib/views/details/index.js
index 25ae020..b8fa859 100644
--- a/public/assets/js/lib/views/details/index.js
+++ b/public/assets/js/lib/views/details/index.js
@@ -5,8 +5,7 @@ var DetailsView = View.extend({
action: "/api/thread/",
keywordAction: "/api/keyword/",
-
-
+
initialize: function(opt){
this.comments = new CommentsView ({ parent: this })
this.files = new FilesView ({ parent: this })
@@ -21,6 +20,7 @@ var DetailsView = View.extend({
},
populate: function(data){
+ $("body").removeClass('loading')
var thread = data.thread
$("h1").html(thread.title)
$(".subtitle").show().html("<a href='/'>&lt; Home</a> | " + metadata(thread))