summaryrefslogtreecommitdiff
path: root/public/assets/js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-12-10 21:08:42 +0100
committerJules Laplace <julescarbon@gmail.com>2017-12-10 21:08:42 +0100
commit3c1acfab622d470aeb1f44a708d6023530e17ec8 (patch)
treece596f9190c3fe8bcfba063670a6ec5a5da9d546 /public/assets/js
parent3cc9ff370a5e3f5bf321dc56963ae3bc73e75284 (diff)
more desiiiiiiiign
Diffstat (limited to 'public/assets/js')
-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
-rw-r--r--public/assets/js/lib/views/index/index.js1
-rw-r--r--public/assets/js/lib/views/mail/mailbox.js16
-rw-r--r--public/assets/js/lib/views/mail/message.js1
-rw-r--r--public/assets/js/lib/views/search/results.js1
-rw-r--r--public/assets/js/util/format.js18
-rw-r--r--public/assets/js/vendor/view/formview.js7
10 files changed, 40 insertions, 25 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))
diff --git a/public/assets/js/lib/views/index/index.js b/public/assets/js/lib/views/index/index.js
index 171133b..c4d1330 100644
--- a/public/assets/js/lib/views/index/index.js
+++ b/public/assets/js/lib/views/index/index.js
@@ -18,6 +18,7 @@ var IndexView = View.extend({
},
populate: function(data){
+ $("body").removeClass('loading')
this.hootbox.load(data.hootbox)
this.threadbox.load(data)
this.lastlog.load(data.lastlog)
diff --git a/public/assets/js/lib/views/mail/mailbox.js b/public/assets/js/lib/views/mail/mailbox.js
index 199eeee..2f822aa 100644
--- a/public/assets/js/lib/views/mail/mailbox.js
+++ b/public/assets/js/lib/views/mail/mailbox.js
@@ -19,9 +19,16 @@ var MailboxView = View.extend({
},
populate: function(data){
+ $("body").removeClass('loading')
this.boxlist.load(data.boxes)
- data.messages.forEach(function(message){
- this.appendMessage(message, data.user)
+
+ var user = data.user
+ var max = data.messages.length-1
+ data.messages.forEach(function(message, i){
+ var $row = $( this.parse(message, user) )
+ if (i === 0) $row.addClass("first")
+ if (i === max) $row.addClass("last")
+ this.$el.append($row)
}.bind(this))
},
@@ -44,9 +51,4 @@ var MailboxView = View.extend({
return t
},
- appendMessage: function(message, user){
- var $row = $( this.parse(message, user) )
- this.$el.append($row)
- },
-
})
diff --git a/public/assets/js/lib/views/mail/message.js b/public/assets/js/lib/views/mail/message.js
index b6297d9..da5e1b4 100644
--- a/public/assets/js/lib/views/mail/message.js
+++ b/public/assets/js/lib/views/mail/message.js
@@ -15,6 +15,7 @@ var MessageView = View.extend({
populate: function(data){
this.parse(data)
+ $("body").removeClass('loading')
},
parse: function(data){
diff --git a/public/assets/js/lib/views/search/results.js b/public/assets/js/lib/views/search/results.js
index 89004e3..d01db96 100644
--- a/public/assets/js/lib/views/search/results.js
+++ b/public/assets/js/lib/views/search/results.js
@@ -53,6 +53,7 @@ var SearchResults = View.extend({
.replace(/{{file}}/, file_tag)
this.$("#results").append(t)
})
+ $("body").removeClass('loading')
},
})
diff --git a/public/assets/js/util/format.js b/public/assets/js/util/format.js
index a162229..a185b33 100644
--- a/public/assets/js/util/format.js
+++ b/public/assets/js/util/format.js
@@ -198,20 +198,22 @@ function is_image(url){
return !! url.match(/(gif|jpe?g|png)\??.*$/i)
}
function make_link(file){
+ if (file.storage) {
+ return "//" + file.storage + "/bucky/data/" + file.thread + "/" + encodeURIComponent(file.filename)
+ }
if (file.filename.indexOf("http") !== 0) {
return "/data/" + file.thread + "/" + encodeURIComponent(file.filename)
}
- else {
- return file.filename
- }
+ return file.filename
}
function make_thumb(file){
+ if (file.storage) {
+ return "//" + file.storage + "/bucky/data/" + file.thread + "/" + encodeURIComponent(file.filename)
+ }
if (file.filename.indexOf("http") !== 0) {
return "/data/" + file.thread + "/" + file.filename
}
- else {
- return "/data/" + file.thread + "/" + file.filename
- // var partz = file.filename.toLowerCase().split("/")
- // return partz.splice(partz.length-2, 0, ".thumb").join("/")
- }
+ return "/data/" + file.thread + "/" + file.filename
+ // var partz = file.filename.toLowerCase().split("/")
+ // return partz.splice(partz.length-2, 0, ".thumb").join("/")
} \ No newline at end of file
diff --git a/public/assets/js/vendor/view/formview.js b/public/assets/js/vendor/view/formview.js
index 485db7a..f71c550 100644
--- a/public/assets/js/vendor/view/formview.js
+++ b/public/assets/js/vendor/view/formview.js
@@ -37,8 +37,8 @@ var FormView = View.extend({
this.$("input[name], select[name], textarea[name]").each( function(){
if (this.type == "file") {
- if (this.files.length > 0) {
- fd.append(this.name, this.files[0]);
+ for (var i = 0; i < this.files.length; i++) {
+ fd.append(this.name, this.files[i]);
}
}
else if (this.type == "password") {
@@ -79,7 +79,7 @@ var FormView = View.extend({
var action = typeof this.action == "function" ? this.action() : this.action
if (! action) return
-
+
var request = $.ajax({
url: action,
type: this.method,
@@ -89,6 +89,7 @@ var FormView = View.extend({
processData: false,
contentType: false,
success: function(response){
+ console.log(response)
if (response.error) {
var errors = []
for (var key in response.error.errors) {