summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-04-25 17:06:45 +0200
committerJules Laplace <julescarbon@gmail.com>2018-04-25 17:06:45 +0200
commit4a99effeb025e6ed6f1a2667a533894aa1fe2f46 (patch)
tree0eaa4d68865af4c3e1643035f8529f5bb9203a61 /public
parent0645d1ada0ad41cc9e53b1b3f452ecc35b35ab12 (diff)
focusing on mail
Diffstat (limited to 'public')
-rw-r--r--public/assets/js/lib/views/details/editcomment.js1
-rw-r--r--public/assets/js/lib/views/mail/compose.js11
-rw-r--r--public/assets/js/vendor/util.js20
3 files changed, 30 insertions, 2 deletions
diff --git a/public/assets/js/lib/views/details/editcomment.js b/public/assets/js/lib/views/details/editcomment.js
index 39d8a45..2f9a3b5 100644
--- a/public/assets/js/lib/views/details/editcomment.js
+++ b/public/assets/js/lib/views/details/editcomment.js
@@ -20,6 +20,7 @@ var EditCommentForm = FormView.extend({
this.action = "/api/comment/" + id
$.get(this.action, function(data){
this.$comment.val(data.comment.comment).focus()
+ setCaretToPos(this.$comment.get(0), 0, 0)
$("body").removeClass("loading")
}.bind(this))
},
diff --git a/public/assets/js/lib/views/mail/compose.js b/public/assets/js/lib/views/mail/compose.js
index f2592ea..3d75016 100644
--- a/public/assets/js/lib/views/mail/compose.js
+++ b/public/assets/js/lib/views/mail/compose.js
@@ -23,15 +23,22 @@ var ComposeView = FormView.extend({
.replace(/{{date}}/, date[0])
.replace(/{{time}}/, date[1])
.replace(/&nbsp;/g, " ")
- console.log(tmpl)
+ // console.log(tmpl)
this.$("[name=username]").val(message.sender)
this.$("[name=subject]").val(message.subject)
- this.$("[name=body]").val(tmpl + message.body)
+ this.$("[name=body]").val(tmpl + message.body).focus()
+ setCaretToPos(this.$("[name=body]").get(0), 0, 0)
$("body").removeClass('loading')
}.bind(this))
return
}
this.$("[name=username]").val(username)
+ if (!username) {
+ this.$("[name=username]").focus()
+ }
+ else {
+ this.$("[name=body]").focus()
+ }
$("body").removeClass('loading')
},
diff --git a/public/assets/js/vendor/util.js b/public/assets/js/vendor/util.js
index bcaa2d2..43ca81b 100644
--- a/public/assets/js/vendor/util.js
+++ b/public/assets/js/vendor/util.js
@@ -140,6 +140,26 @@ function range(m,n,s){
return a
}
+// manipulate text selection in an element
+function setSelectionRange(input, selectionStart, selectionEnd) {
+ if (input.setSelectionRange) {
+ input.focus();
+ input.setSelectionRange(selectionStart, selectionEnd);
+ }
+ else if (input.createTextRange) {
+ var range = input.createTextRange();
+ range.collapse(true);
+ range.moveEnd('character', selectionEnd);
+ range.moveStart('character', selectionStart);
+ range.select();
+ }
+}
+
+// place cursor at a specific point (usually the beginning)
+function setCaretToPos (input, pos) {
+ setSelectionRange(input, pos, pos);
+}
+
var guid_syllables = "iz az ez or iv ex baz el lo lum ot un no".split(" ")
var guid_n = 0
function guid(n){