From 51f959e16007ffa5f7802ad121f253633316da4c Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Tue, 20 Aug 2013 11:33:59 +0200 Subject: [PATCH] a little better handling of paste in queet boxes --- js/qvitter-1.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/js/qvitter-1.js b/js/qvitter-1.js index 02e3a1c..c3e6ca1 100644 --- a/js/qvitter-1.js +++ b/js/qvitter-1.js @@ -1165,7 +1165,7 @@ $('#queet-toolbar button').click(function () { /* · · - · Count chars in queet box on keyuo + · Count chars in queet box on keyup · · · · · · · · · · · · · · */ @@ -1215,11 +1215,11 @@ $('#queet-box').bind('paste',function () { setTimeout(function () { // clean all html (but keep linebreaks) - var $keep_br = $('
').append($('#queet-box').html().replace(/
/gi,'{{br}}')); + var $keep_br = $('
').append($('#queet-box').html().replace(/(
\s*)+$/,'').replace(/
/gi,'{{br}}')); $('#queet-box').html($keep_br.text().replace(/{{br}}/gi,'
')); // shorten urls - shortenUrlsInBox($('#queet-box'),$('#queet-counter'),$('#queet-toolbar button')); +// shortenUrlsInBox($('#queet-box'),$('#queet-counter'),$('#queet-toolbar button')); $('#queet-box').css('color','#333333'); placeCaretAtEnd(document.getElementById("queet-box")); @@ -1229,11 +1229,13 @@ $('#queet-box').bind('paste',function () { $('#feed').on('paste','.queet-box-template',function(e){ window.current_box_id = '#' + $(this).attr('id'); setTimeout(function () { - // clean all html - $(window.current_box_id).html($(window.current_box_id).text()); - + + // clean all html (but keep linebreaks) + var $keep_br = $('
').append($(window.current_box_id).html().replace(/(
\s*)+$/,'').replace(/
/gi,'{{br}}')); + $(window.current_box_id).html($keep_br.text().replace(/{{br}}/gi,'
')); + // shorten urls - shortenUrlsInBox($(window.current_box_id),$(window.current_box_id).find('.queet-counter'),$(window.current_box_id).find('.queet-toolbar button')); +// shortenUrlsInBox($(window.current_box_id),$(window.current_box_id).find('.queet-counter'),$(window.current_box_id).find('.queet-toolbar button')); placeCaretAtEnd(document.getElementById($(window.current_box_id).attr('id'))); countCharsInQueetBox($(window.current_box_id),$(window.current_box_id).find('.queet-counter'),$(window.current_box_id).find('.queet-toolbar button'));