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/settings.js38
1 files changed, 19 insertions, 19 deletions
diff --git a/public/assets/js/lib/views/details/settings.js b/public/assets/js/lib/views/details/settings.js
index 1d048ab..c8e53db 100644
--- a/public/assets/js/lib/views/details/settings.js
+++ b/public/assets/js/lib/views/details/settings.js
@@ -1,7 +1,7 @@
var ThreadSettingsForm = FormView.extend({
-
+
el: "#thread_settings",
-
+
events: {
"click": "hide",
"click .inner": "stopPropagation",
@@ -14,17 +14,17 @@ var ThreadSettingsForm = FormView.extend({
"keydown [name=allowed_field]": "keydownAllowed",
"blur [name=allowed_field]": "updateAllowed",
},
-
+
action: "",
method: 'put',
-
+
initialize: function(){
this.__super__.initialize.call(this)
this.template = this.$(".template").html()
this.allowedTemplate = this.$(".allowedTemplate").html()
this.filesTemplate = this.$(".settingsFilesTemplate").html()
},
-
+
populate: function(){
var data = this.options.parent.data
var keywords = data.keywords
@@ -34,7 +34,7 @@ var ThreadSettingsForm = FormView.extend({
var files = data.files
var settings = thread.settings
var display = thread.display
-
+
this.thread = thread
this.files = data.files
this.action = "/api/thread/" + thread.id
@@ -48,7 +48,7 @@ var ThreadSettingsForm = FormView.extend({
this.$("[name=shorturls]").prop("checked", !!thread.settings.shorturls)
this.$("[name=noupload]").prop("checked", !!thread.settings.noupload)
this.$("[name=privacy]").prop("checked", !!thread.privacy)
-
+
var $color = this.$('[name=color]')
Object.keys(COLORS).forEach((color) => {
var option = document.createElement('option')
@@ -57,10 +57,10 @@ var ThreadSettingsForm = FormView.extend({
$color.append(option)
})
$color.val(thread && thread.color? thread.color: keyword? keyword.color: "")
-
+
this.toggleAllowed()
this.fetchKeywords()
-
+
var $files = this.$(".files")
$files.empty()
files.sort((a,b) => cmp(a.filename, b.filename))
@@ -84,7 +84,7 @@ var ThreadSettingsForm = FormView.extend({
$("body").removeClass("loading")
},
-
+
fetchKeywords: function(thread){
$.get('/api/keywords', function(data){
var $keyword = this.$('[name=keyword]')
@@ -100,7 +100,7 @@ var ThreadSettingsForm = FormView.extend({
$keyword.val(this.thread.keyword)
}.bind(this))
},
-
+
toggleAllowed: function(e){
var checked = this.$('[name=privacy]').prop('checked')
this.$(".allowed_field_container").toggle(checked)
@@ -109,7 +109,7 @@ var ThreadSettingsForm = FormView.extend({
this.$("[name=allowed_field]").focus()
this.displayAllowed()
},
-
+
displayAllowed: function(e){
var $allowedNames = this.$(".allowed_names").empty()
this.allowed.forEach(username => {
@@ -117,7 +117,7 @@ var ThreadSettingsForm = FormView.extend({
$allowedNames.append(t)
})
},
-
+
keydownAllowed: function(e){
if (e.keyCode === 13) { // enter
e.preventDefault()
@@ -125,7 +125,7 @@ var ThreadSettingsForm = FormView.extend({
this.updateAllowed()
}
},
-
+
updateAllowed: function(){
var usernames = this.$('[name=allowed_field]').val().replace(/,/g, ' ').split(' ').map(s => s.trim()).filter(s => !! s)
this.$('[name=allowed_field]').val('')
@@ -145,14 +145,14 @@ var ThreadSettingsForm = FormView.extend({
}.bind(this),
})
},
-
+
removeAllowed: function(){
this.allowed = this.$("#allowed_names input[type=checkbox]:checked").map(function(){
return $(this).val()
})
this.displayAllowed()
},
-
+
validate: function(){
var errors = []
var title = $("[name=title]").val()
@@ -184,7 +184,7 @@ var ThreadSettingsForm = FormView.extend({
},
visible: false,
-
+
show: function(){
this.visible = true
app.typing = true
@@ -205,7 +205,7 @@ var ThreadSettingsForm = FormView.extend({
if (this.visible) this.hide()
else this.show()
},
-
+
changeColor: function(){
var color_name = this.$("[name=color]").val()
set_background_color(color_name)
@@ -264,4 +264,4 @@ var ThreadSettingsForm = FormView.extend({
}
},
-}) \ No newline at end of file
+})