|
|
@ -534,6 +534,12 @@ var unfocusThis = function() |
|
|
|
$this.removeClass( "open" ); |
|
|
|
$this.removeClass( "open" ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function checkPostForMentions(post, mentions, max) { |
|
|
|
|
|
|
|
var m = mentions.trim(); |
|
|
|
|
|
|
|
var ml = m.split(' ').join('|'); |
|
|
|
|
|
|
|
return new RegExp('^.{0,' + max.toString() + '}(' + ml + ')').test(post); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var splitedPostsCount = 1; |
|
|
|
var splitedPostsCount = 1; |
|
|
|
var usePostSpliting = false; |
|
|
|
var usePostSpliting = false; |
|
|
|
|
|
|
|
|
|
|
@ -548,75 +554,76 @@ function replyTextKeypress(e) { |
|
|
|
if (usePostSpliting) { |
|
|
|
if (usePostSpliting) { |
|
|
|
var $tas = tweetForm.find("textarea"); |
|
|
|
var $tas = tweetForm.find("textarea"); |
|
|
|
splitedPostsCount = $tas.length; |
|
|
|
splitedPostsCount = $tas.length; |
|
|
|
if ($tas.length > 1 && $tas[$tas.length - 1].value.length === 0) { |
|
|
|
if ($this.hasClass('splited-post')) |
|
|
|
$tas[$tas.length - 1].value = $tas[$tas.length - 2].value; |
|
|
|
$this.css('height', '24px'); |
|
|
|
$($tas[$tas.length - 2]).remove(); |
|
|
|
|
|
|
|
splitedPostsCount--; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var reply_to = $this.attr('data-reply-to'); |
|
|
|
var reply_to = $this.attr('data-reply-to'); |
|
|
|
for (var i = 0; i < splitedPostsCount - 1; i++) { |
|
|
|
for (var i = 0; i < $tas.length; i++) { |
|
|
|
var pml = 140 - (i+1).toString().length - splitedPostsCount.toString().length - 6; |
|
|
|
var pml = 140 - (i+1).toString().length - splitedPostsCount.toString().length - 4; |
|
|
|
//if mention exists, we shouldn't add it while posting.
|
|
|
|
//if mention exists, we shouldn't add it while posting.
|
|
|
|
if (typeof(reply_to) !== 'undefined' && |
|
|
|
if (typeof(reply_to) !== 'undefined' && |
|
|
|
!(new RegExp('^.{0,' + (pml - reply_to.length).toString() + '}' + reply_to).test($tas[i].value))) { |
|
|
|
!checkPostForMentions($tas[i].value, reply_to, pml - reply_to.length)) { |
|
|
|
pml -= reply_to.length; |
|
|
|
pml -= reply_to.length; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($tas[i].value.length > pml) { |
|
|
|
if ($tas[i].value.length > pml) { |
|
|
|
var ci = $tas[i].value.lastIndexOf(" ", pml); |
|
|
|
var endings = $tas[i].value.match(/ |,|;|\.|:|\/|\?|\!|\\|'|"|\n|\t/g); |
|
|
|
ci = (ci == -1 ? pml : ci); |
|
|
|
var ci = $tas[i].value.lastIndexOf(endings[endings.length - 1]); |
|
|
|
$tas[i + 1].value = $tas[i].value.substr(ci) + $tas[i + 1].value; |
|
|
|
for (var j = endings.length - 2; j >= 0 && ci > pml; j--) { |
|
|
|
$tas[i].value = $tas[i].value.substr(0, ci); |
|
|
|
ci = $tas[i].value.lastIndexOf(endings[j], ci - 1); |
|
|
|
|
|
|
|
} |
|
|
|
} else if ($tas[i].value.length === 0) { |
|
|
|
ci = (ci > pml ? pml : ci); |
|
|
|
$($tas[i]).remove(); |
|
|
|
if (i < splitedPostsCount - 1) { |
|
|
|
splitedPostsCount--; |
|
|
|
$tas[i + 1].value = $tas[i].value.substr(ci) + $tas[i + 1].value; |
|
|
|
|
|
|
|
$tas[i].value = $tas[i].value.substr(0, ci); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
var $oldta = $($tas[i]); |
|
|
|
|
|
|
|
var $newta = $($oldta).clone(true); |
|
|
|
|
|
|
|
var cp = $oldta.val(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$oldta.val(cp.substr(0, ci)); |
|
|
|
|
|
|
|
$oldta.on("click", function(e) { |
|
|
|
|
|
|
|
e.stopPropagation(); |
|
|
|
|
|
|
|
this.style.height = '80px'; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
$oldta.unbind("keyup"); |
|
|
|
|
|
|
|
$oldta.on("blur", replyTextKeypress); |
|
|
|
|
|
|
|
$oldta.addClass('splited-post'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tweetForm.find(".textcomplete-wrapper").append($newta); |
|
|
|
|
|
|
|
$newta.val(cp.substr(ci)); |
|
|
|
|
|
|
|
$newta.focus(); |
|
|
|
|
|
|
|
if ($newta[0].setSelectionRange) |
|
|
|
|
|
|
|
$newta[0].setSelectionRange($newta.val().length, $newta.val().length); |
|
|
|
|
|
|
|
else if ($newta[0].createTextRange) |
|
|
|
|
|
|
|
$newta[0].createTextRange().moveEnd('character', $newta.val().length); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$tas = tweetForm.find("textarea"); |
|
|
|
|
|
|
|
splitedPostsCount = $tas.length; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if ($tas.length > 1 && $tas[i].value.length === 0) { |
|
|
|
|
|
|
|
if (i === $tas.length - 1) { |
|
|
|
|
|
|
|
$tas[i].value = $tas[i - 1].value; |
|
|
|
|
|
|
|
$($tas[i - 1]).remove(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$($tas[i]).remove(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$tas = tweetForm.find("textarea"); |
|
|
|
|
|
|
|
splitedPostsCount = $tas.length; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
c = 140 - $this.val().length - (2 * splitedPostsCount.toString().length) - 6; |
|
|
|
c = 140 - $tas[$tas.length - 1].value.length - (2 * splitedPostsCount.toString().length) - 4; |
|
|
|
if (typeof(reply_to) !== 'undefined' && |
|
|
|
if (typeof(reply_to) !== 'undefined' && |
|
|
|
!(new RegExp('^.{0,' + (140 - c - reply_to.length).toString() + '}' + reply_to).test($this.val()))) |
|
|
|
!checkPostForMentions($tas[$tas.length - 1].value, reply_to, 140 - c - reply_to.length)) |
|
|
|
c -= reply_to.length; |
|
|
|
c -= reply_to.length; |
|
|
|
} |
|
|
|
} |
|
|
|
var remainingCount = tweetForm.find(".post-area-remaining"); |
|
|
|
var remainingCount = tweetForm.find(".post-area-remaining"); |
|
|
|
|
|
|
|
|
|
|
|
if( c < 0 ) { |
|
|
|
if( c < 0 ) |
|
|
|
if (usePostSpliting){ |
|
|
|
remainingCount.addClass("warn"); |
|
|
|
var pml = 140 - (2 * splitedPostsCount.toString().length) - 6; |
|
|
|
else |
|
|
|
var reply_to = $this.attr('data-reply-to'); |
|
|
|
|
|
|
|
//if mention exists, we shouldn't add it while posting.
|
|
|
|
|
|
|
|
if (typeof(reply_to) !== 'undefined' && |
|
|
|
|
|
|
|
!(new RegExp('^.{0,' + (pml - reply_to.length).toString() + '}' + reply_to).test(this.value))) { |
|
|
|
|
|
|
|
pml -= reply_to.length; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var cp = this.value; |
|
|
|
|
|
|
|
var ci = cp.lastIndexOf(" ", pml); |
|
|
|
|
|
|
|
ci = (ci == -1 ? pml : ci); |
|
|
|
|
|
|
|
this.value = cp.substr(0, ci); |
|
|
|
|
|
|
|
splitedPostsCount++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var $newta = $this.clone(true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var reply_to = $this.attr('data-reply-to'); |
|
|
|
|
|
|
|
$this.on("click", function(e) {e.stopPropagation()}); |
|
|
|
|
|
|
|
$this.unbind("keyup"); |
|
|
|
|
|
|
|
$this.on("blur", replyTextKeypress); |
|
|
|
|
|
|
|
$this.addClass('splited-post'); |
|
|
|
|
|
|
|
tweetForm.find(".textcomplete-wrapper").append($newta); |
|
|
|
|
|
|
|
$newta.val(cp.substr(ci)); |
|
|
|
|
|
|
|
$newta.focus(); |
|
|
|
|
|
|
|
if ($newta[0].setSelectionRange) |
|
|
|
|
|
|
|
$newta[0].setSelectionRange($newta.val().length, $newta.val().length); |
|
|
|
|
|
|
|
else if ($newta[0].createTextRange) |
|
|
|
|
|
|
|
$newta[0].createTextRange().moveEnd('character', $newta.val().length); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c += ci - 1; |
|
|
|
|
|
|
|
} else |
|
|
|
|
|
|
|
remainingCount.addClass("warn"); |
|
|
|
|
|
|
|
} else |
|
|
|
|
|
|
|
remainingCount.removeClass("warn"); |
|
|
|
remainingCount.removeClass("warn"); |
|
|
|
|
|
|
|
|
|
|
|
if (usePostSpliting) |
|
|
|
if (usePostSpliting) |
|
|
@ -1141,12 +1148,10 @@ var postSubmit = function(e) |
|
|
|
var postxt = ""; |
|
|
|
var postxt = ""; |
|
|
|
var reply_to = $replyText.attr('data-reply-to'); |
|
|
|
var reply_to = $replyText.attr('data-reply-to'); |
|
|
|
var val = $replyText.val(); |
|
|
|
var val = $replyText.val(); |
|
|
|
if (typeof(reply_to) === 'undefined' || val.indexOf(reply_to) > 0) |
|
|
|
if (typeof(reply_to) === 'undefined' || checkPostForMentions(val, reply_to, 140)) |
|
|
|
postxt = "(" + splitedPostsCount.toString() + "/" + splitedPostsCount.toString() + ") " + val; |
|
|
|
postxt = val + " (" + splitedPostsCount.toString() + "/" + splitedPostsCount.toString() + ")"; |
|
|
|
else if (val.indexOf(reply_to) === 0) |
|
|
|
|
|
|
|
postxt = val.replace(reply_to, reply_to + "(" + splitedPostsCount.toString() + "/" + splitedPostsCount.toString() + ") "); |
|
|
|
|
|
|
|
else |
|
|
|
else |
|
|
|
postxt = reply_to + "(" + splitedPostsCount.toString() + "/" + splitedPostsCount.toString() + ") " + val; |
|
|
|
postxt = reply_to + val + " (" + splitedPostsCount.toString() + "/" + splitedPostsCount.toString() + ")"; |
|
|
|
|
|
|
|
|
|
|
|
newPostMsg(postxt, $postOrig); |
|
|
|
newPostMsg(postxt, $postOrig); |
|
|
|
} else |
|
|
|
} else |
|
|
@ -1157,17 +1162,14 @@ var postSubmit = function(e) |
|
|
|
var postxt = ""; |
|
|
|
var postxt = ""; |
|
|
|
var reply_to = $replyText.attr('data-reply-to'); |
|
|
|
var reply_to = $replyText.attr('data-reply-to'); |
|
|
|
var val = $replyText[0].value; |
|
|
|
var val = $replyText[0].value; |
|
|
|
if (typeof(reply_to) === 'undefined' || val.indexOf(reply_to) > 0) |
|
|
|
if (typeof(reply_to) === 'undefined' || checkPostForMentions(val, reply_to, 140)) |
|
|
|
postxt = "(" + (splitedPostsCount - $replyText.length + 1).toString() + "/" + splitedPostsCount.toString() + ") " + val; |
|
|
|
postxt = val + " (" + (splitedPostsCount - $replyText.length + 1).toString() + "/" + splitedPostsCount.toString() + ")"; |
|
|
|
else if (val.indexOf(reply_to) === 0) { |
|
|
|
else |
|
|
|
postxt = val.replace(reply_to, reply_to + "(" + (splitedPostsCount - $replyText.length + 1).toString() + "/" + splitedPostsCount.toString() + ") "); |
|
|
|
postxt = reply_to + val + " (" + (splitedPostsCount - $replyText.length + 1).toString() + "/" + splitedPostsCount.toString() + ")"; |
|
|
|
//splitedPosts.shift();
|
|
|
|
|
|
|
|
} else |
|
|
|
|
|
|
|
postxt = reply_to + "(" + (splitedPostsCount - $replyText.length + 1).toString() + "/" + splitedPostsCount.toString() + ") " + val; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$($replyText[0]).remove(); |
|
|
|
$($replyText[0]).remove(); |
|
|
|
|
|
|
|
|
|
|
|
newPostMsg(postxt + " +", $postOrig); |
|
|
|
newPostMsg(postxt, $postOrig); |
|
|
|
setTimeout(postSubmit, 1000, $this); |
|
|
|
setTimeout(postSubmit, 1000, $this); |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|