summaryrefslogtreecommitdiff
path: root/public/assets/js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-01-08 18:51:49 +0100
committerJules Laplace <julescarbon@gmail.com>2018-01-08 18:51:49 +0100
commit2e9e542bfb81c3aff407801e3ae3f08eee0fb3d9 (patch)
tree462542e7fe929739e192f97eeaa760c49537227d /public/assets/js
parentdb77b7514625354118641581459b6d3423aad153 (diff)
cmd-s to save
Diffstat (limited to 'public/assets/js')
-rw-r--r--public/assets/js/lib/views/details/commentform.js9
-rw-r--r--public/assets/js/lib/views/details/editcomment.js11
-rw-r--r--public/assets/js/lib/views/index/threadform.js9
3 files changed, 28 insertions, 1 deletions
diff --git a/public/assets/js/lib/views/details/commentform.js b/public/assets/js/lib/views/details/commentform.js
index db08ef1..9a748f9 100644
--- a/public/assets/js/lib/views/details/commentform.js
+++ b/public/assets/js/lib/views/details/commentform.js
@@ -5,6 +5,7 @@ var CommentForm = FormView.extend({
events: {
"focus textarea": 'focus',
"mouseup input[type=file]": 'focus',
+ "keydown textarea": 'keydown',
},
action: "",
@@ -22,6 +23,14 @@ var CommentForm = FormView.extend({
}
},
+ keydown: function(e){
+ if ((e.ctrlKey || e.metaKey || e.altKey) && e.keyCode == 83) { // "s" key
+ e.preventDefault()
+ e.stopPropagation()
+ this.save()
+ }
+ },
+
focus: function(){
this.$el.addClass('focused')
$("[name=comment]").prop("required", false)
diff --git a/public/assets/js/lib/views/details/editcomment.js b/public/assets/js/lib/views/details/editcomment.js
index a290ac4..39d8a45 100644
--- a/public/assets/js/lib/views/details/editcomment.js
+++ b/public/assets/js/lib/views/details/editcomment.js
@@ -4,6 +4,7 @@ var EditCommentForm = FormView.extend({
events: {
"focus textarea": 'focus',
+ "keydown textarea": 'keydown',
},
action: "",
@@ -26,7 +27,15 @@ var EditCommentForm = FormView.extend({
focus: function(){
this.$el.addClass('focused')
},
-
+
+ keydown: function(e){
+ if ((e.ctrlKey || e.metaKey || e.altKey) && e.keyCode == 83) { // "s" key
+ e.preventDefault()
+ e.stopPropagation()
+ this.save()
+ }
+ },
+
validate: function(){
var errors = []
var comment = $("[name=comment]").val()
diff --git a/public/assets/js/lib/views/index/threadform.js b/public/assets/js/lib/views/index/threadform.js
index b2e1963..b71eea0 100644
--- a/public/assets/js/lib/views/index/threadform.js
+++ b/public/assets/js/lib/views/index/threadform.js
@@ -3,6 +3,7 @@ var ThreadForm = FormView.extend({
el: "#thread_form",
events: {
+ "keydown textarea": "keydown",
},
action: "/api/thread",
@@ -34,6 +35,14 @@ var ThreadForm = FormView.extend({
}.bind(this))
},
+ keydown: function(e){
+ if ((e.ctrlKey || e.metaKey || e.altKey) && e.keyCode == 83) { // "s" key
+ e.preventDefault()
+ e.stopPropagation()
+ this.save()
+ }
+ },
+
validate: function(){
var errors = []
var title = this.$("[name=title]").val()