From 9a8cebe4a1c298b3d6ff13332a2daded90506d3c Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 15 Sep 2013 07:17:02 +1000 Subject: add real quick reply (wtf was the other thing?) --- templates/main.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'templates/main.js') diff --git a/templates/main.js b/templates/main.js index 144c5f62..c0961878 100644 --- a/templates/main.js +++ b/templates/main.js @@ -198,6 +198,10 @@ function citeReply(id) { // ??? body.value += '>>' + id + '\n'; } + if ($) { + $(window).trigger('cite', id); + $(body).change(); + } } function rememberStuff() { -- cgit v1.3 From c8f2f00320dd90ff51dec4de0286a9415aba4b0b Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 15 Sep 2013 07:31:05 +1000 Subject: fix bug with quick-reply and make it nicer --- js/quick-reply.js | 13 +++++++++++-- templates/main.js | 6 +++--- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'templates/main.js') diff --git a/js/quick-reply.js b/js/quick-reply.js index 3ff6002c..6f5c79d8 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -13,7 +13,9 @@ var show_quick_reply = function(){ if($('div.banner').length == 0) - return; // not index + return; + if($('#quick-reply').length != 0) + return; $('').appendTo($('head')); + console.log('h'); +}; + +var show_quick_reply = function(){ + if($('div.banner').length == 0) + return; + if($('#quick-reply').length != 0) + return; + + do_css(); + var $postForm = $('form[name="post"]').clone(); $postForm.clone(); @@ -193,7 +206,7 @@ var show_quick_reply = function(){ $postForm.fadeOut(100); else $postForm.fadeIn(100); - }); + }).on('stylesheet', do_css); }; $(window).on('cite', function(e, id, with_link) { diff --git a/templates/main.js b/templates/main.js index a395852a..984b1976 100644 --- a/templates/main.js +++ b/templates/main.js @@ -67,6 +67,9 @@ function changeStyle(styleName, link) { if (link) { link.className = 'selected'; } + + if (typeof $ != 'undefined') + $(window).trigger('stylesheet', styleName); } @@ -198,7 +201,7 @@ function citeReply(id, with_link) { // ??? body.value += '>>' + id + '\n'; } - if ($) { + if (typeof $ != 'undefined') { $(window).trigger('cite', [id, with_link]); $(body).change(); } -- cgit v1.3 From 5d108319eb527ad91d362d8eecc3f24303e31dfa Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Mon, 16 Sep 2013 03:51:36 +1000 Subject: fix some weirdness --- js/quick-reply.js | 19 +++++++++++++------ templates/main.js | 20 +++++++++++--------- 2 files changed, 24 insertions(+), 15 deletions(-) (limited to 'templates/main.js') 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(); } } -- cgit v1.3