a little better handling of paste in queet boxes

This commit is contained in:
Hannes Mannerheim 2013-08-20 11:33:59 +02:00
parent 12675b5504
commit 51f959e160

View File

@ -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 () { setTimeout(function () {
// clean all html (but keep linebreaks) // clean all html (but keep linebreaks)
var $keep_br = $('<div/>').append($('#queet-box').html().replace(/<br>/gi,'{{br}}')); var $keep_br = $('<div/>').append($('#queet-box').html().replace(/(<br>\s*)+$/,'').replace(/<br>/gi,'{{br}}'));
$('#queet-box').html($keep_br.text().replace(/{{br}}/gi,'<br>')); $('#queet-box').html($keep_br.text().replace(/{{br}}/gi,'<br>'));
// shorten urls // shorten urls
shortenUrlsInBox($('#queet-box'),$('#queet-counter'),$('#queet-toolbar button')); // shortenUrlsInBox($('#queet-box'),$('#queet-counter'),$('#queet-toolbar button'));
$('#queet-box').css('color','#333333'); $('#queet-box').css('color','#333333');
placeCaretAtEnd(document.getElementById("queet-box")); placeCaretAtEnd(document.getElementById("queet-box"));
@ -1229,11 +1229,13 @@ $('#queet-box').bind('paste',function () {
$('#feed').on('paste','.queet-box-template',function(e){ $('#feed').on('paste','.queet-box-template',function(e){
window.current_box_id = '#' + $(this).attr('id'); window.current_box_id = '#' + $(this).attr('id');
setTimeout(function () { setTimeout(function () {
// clean all html
$(window.current_box_id).html($(window.current_box_id).text()); // clean all html (but keep linebreaks)
var $keep_br = $('<div/>').append($(window.current_box_id).html().replace(/(<br>\s*)+$/,'').replace(/<br>/gi,'{{br}}'));
$(window.current_box_id).html($keep_br.text().replace(/{{br}}/gi,'<br>'));
// shorten urls // 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'))); 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')); countCharsInQueetBox($(window.current_box_id),$(window.current_box_id).find('.queet-counter'),$(window.current_box_id).find('.queet-toolbar button'));