fix some weirdness

This commit is contained in:
Michael Foster 2013-09-16 03:51:36 +10:00
parent 769dfd95fa
commit 5d108319eb
2 changed files with 24 additions and 15 deletions

View File

@ -206,20 +206,29 @@ var show_quick_reply = function(){
$postForm.attr('id', 'quick-reply'); $postForm.attr('id', 'quick-reply');
$postForm.appendTo($('body')).hide(); $postForm.appendTo($('body')).hide();
$origPostForm = $('form[name="post"]:first');
// Synchronise body text with original post form // 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"]').val($(this).val());
}); });
$postForm.find('textarea[name="body"]').bind('change input propertychange', function() { $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 // 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('[name="' + $(this).attr('name') + '"]').val($(this).val());
}); });
$postForm.find('input[type="text"],select').bind('change input propertychange', function() { $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') { if (typeof $postForm.draggable != 'undefined') {
@ -256,8 +265,6 @@ var show_quick_reply = function(){
$postForm.show(); $postForm.show();
$(window).trigger('quick-reply'); $(window).trigger('quick-reply');
$origPostForm = $('form[name="post"]');
$(window).ready(function() { $(window).ready(function() {
$(window).scroll(function() { $(window).scroll(function() {
if ($(this).width() <= 800) if ($(this).width() <= 800)

View File

@ -185,25 +185,27 @@ function dopost(form) {
} }
function citeReply(id, with_link) { function citeReply(id, with_link) {
var body = document.getElementById('body'); var textarea = document.getElementById('body');
if (document.selection) { if (document.selection) {
// IE // IE
body.focus(); textarea.focus();
var sel = document.selection.createRange(); var sel = document.selection.createRange();
sel.text = '>>' + id + '\n'; sel.text = '>>' + id + '\n';
} else if (body.selectionStart || body.selectionStart == '0') { } else if (textarea.selectionStart || textarea.selectionStart == '0') {
// Mozilla var start = textarea.selectionStart;
var start = body.selectionStart; var end = textarea.selectionEnd;
var end = body.selectionEnd; textarea.value = textarea.value.substring(0, start) + '>>' + id + '\n' + textarea.value.substring(end, textarea.value.length);
body.value = body.value.substring(0, start) + '>>' + id + '\n' + body.value.substring(end, body.value.length);
textarea.selectionStart += ('>>' + id).length + 1;
textarea.selectionEnd = textarea.selectionStart;
} else { } else {
// ??? // ???
body.value += '>>' + id + '\n'; textarea.value += '>>' + id + '\n';
} }
if (typeof $ != 'undefined') { if (typeof $ != 'undefined') {
$(window).trigger('cite', [id, with_link]); $(window).trigger('cite', [id, with_link]);
$(body).change(); $(textarea).change();
} }
} }