summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Foster <savetheinternet@tinyboard.org>2013-09-16 03:51:36 +1000
committerMichael Foster <savetheinternet@tinyboard.org>2013-09-16 03:51:36 +1000
commit5d108319eb527ad91d362d8eecc3f24303e31dfa (patch)
tree2335e0c6ddc869d99b765a004e90db5e78e68621
parent769dfd95fabb52e3bf664d5c30bf8f609bc5f1dd (diff)
fix some weirdness
-rw-r--r--js/quick-reply.js19
-rw-r--r--templates/main.js20
2 files changed, 24 insertions, 15 deletions
diff --git a/js/quick-reply.js b/js/quick-reply.js
index 61832ea7..376c44fd 100644
--- a/js/quick-reply.js
+++ b/js/quick-reply.js
@@ -206,20 +206,29 @@ var show_quick_reply = function(){
$postForm.attr('id', 'quick-reply');
$postForm.appendTo($('body')).hide();
+ $origPostForm = $('form[name="post"]:first');
// Synchronise body text with original post form
- $('#body').bind('change input propertychange', function() {
+ $origPostForm.find('textarea[name="body"]').bind('change input propertychange', function() {
$postForm.find('textarea[name="body"]').val($(this).val());
});
$postForm.find('textarea[name="body"]').bind('change input propertychange', function() {
- $('#body').val($(this).val());
+ $origPostForm.find('textarea[name="body"]').val($(this).val());
+ });
+ $postForm.find('textarea[name="body"]').focus(function() {
+ $origPostForm.find('textarea[name="body"]').removeAttr('id');
+ $(this).attr('id', 'body');
+ });
+ $origPostForm.find('textarea[name="body"]').focus(function() {
+ $postForm.find('textarea[name="body"]').removeAttr('id');
+ $(this).attr('id', 'body');
});
// Synchronise other inputs
- $('form[name="post"]:first input[type="text"],select').bind('change input propertychange', function() {
+ $origPostForm.find('input[type="text"],select').bind('change input propertychange', function() {
$postForm.find('[name="' + $(this).attr('name') + '"]').val($(this).val());
});
$postForm.find('input[type="text"],select').bind('change input propertychange', function() {
- $('form[name="post"]:first [name="' + $(this).attr('name') + '"]').val($(this).val());
+ $origPostForm.find('[name="' + $(this).attr('name') + '"]').val($(this).val());
});
if (typeof $postForm.draggable != 'undefined') {
@@ -255,8 +264,6 @@ var show_quick_reply = function(){
$postForm.show();
$(window).trigger('quick-reply');
-
- $origPostForm = $('form[name="post"]');
$(window).ready(function() {
$(window).scroll(function() {
diff --git a/templates/main.js b/templates/main.js
index 984b1976..235b52db 100644
--- a/templates/main.js
+++ b/templates/main.js
@@ -185,25 +185,27 @@ function dopost(form) {
}
function citeReply(id, with_link) {
- var body = document.getElementById('body');
+ var textarea = document.getElementById('body');
if (document.selection) {
// IE
- body.focus();
+ textarea.focus();
var sel = document.selection.createRange();
sel.text = '>>' + id + '\n';
- } else if (body.selectionStart || body.selectionStart == '0') {
- // Mozilla
- var start = body.selectionStart;
- var end = body.selectionEnd;
- body.value = body.value.substring(0, start) + '>>' + id + '\n' + body.value.substring(end, body.value.length);
+ } else if (textarea.selectionStart || textarea.selectionStart == '0') {
+ var start = textarea.selectionStart;
+ var end = textarea.selectionEnd;
+ textarea.value = textarea.value.substring(0, start) + '>>' + id + '\n' + textarea.value.substring(end, textarea.value.length);
+
+ textarea.selectionStart += ('>>' + id).length + 1;
+ textarea.selectionEnd = textarea.selectionStart;
} else {
// ???
- body.value += '>>' + id + '\n';
+ textarea.value += '>>' + id + '\n';
}
if (typeof $ != 'undefined') {
$(window).trigger('cite', [id, with_link]);
- $(body).change();
+ $(textarea).change();
}
}