Browse Source

- removed '+' sign from end of splitted posts

- moved splitted post counter to end
- not forced anymore to add all mentions while replying
master
erqan 11 years ago
parent
commit
2563ce1def
  1. 19
      css/style.css
  2. 124
      js/interface_common.js
  3. 16
      js/twister_formatpost.js
  4. 4
      js/twister_timeline.js

19
css/style.css

@ -584,8 +584,14 @@ button.disabled:hover
} }
textarea.splited-post { textarea.splited-post {
box-shadow: none!important; box-shadow: none!important;
animation-name: sent-part; height: 28px;
animation-duration: 0,5s; transition: height 1s linear;
-webkit-transition: height 0.3s linear;
-moz-transition: height 0.3s linear;
-o-transition: height 0.3s linear;
-ms-transition: height 0.3s linear;
animation-name: splited-part;
animation-duration: 0.5s;
animation-easing-function: linear; animation-easing-function: linear;
-webkit-animation-name: sent-part; -webkit-animation-name: sent-part;
-webkit-animation-duration: 0.5s; -webkit-animation-duration: 0.5s;
@ -594,7 +600,7 @@ textarea.splited-post {
-moz-animation-duration: 0.5s; -moz-animation-duration: 0.5s;
-moz-animation-easing-function: linear; -moz-animation-easing-function: linear;
} }
@keyframes sent-part { @keyframes splited-part {
from { from {
height: 0px; height: 0px;
} }
@ -602,6 +608,13 @@ textarea.splited-post {
height: 80px; height: 80px;
} }
} }
.splited-post-counter {
color: rgba(0, 0, 0, 0.3);
font-weight: bold;
}
.splited-post-counter:before {
content: '\2026';
}
.post-area-extras .post-area-extras
{ {
overflow: hidden; overflow: hidden;

124
js/interface_common.js

@ -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,63 +554,42 @@ 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]);
for (var j = endings.length - 2; j >= 0 && ci > pml; j--) {
ci = $tas[i].value.lastIndexOf(endings[j], ci - 1);
}
ci = (ci > pml ? pml : ci);
if (i < splitedPostsCount - 1) {
$tas[i + 1].value = $tas[i].value.substr(ci) + $tas[i + 1].value; $tas[i + 1].value = $tas[i].value.substr(ci) + $tas[i + 1].value;
$tas[i].value = $tas[i].value.substr(0, ci); $tas[i].value = $tas[i].value.substr(0, ci);
} else {
var $oldta = $($tas[i]);
var $newta = $($oldta).clone(true);
var cp = $oldta.val();
} else if ($tas[i].value.length === 0) { $oldta.val(cp.substr(0, ci));
$($tas[i]).remove(); $oldta.on("click", function(e) {
splitedPostsCount--; e.stopPropagation();
} this.style.height = '80px';
} });
$oldta.unbind("keyup");
c = 140 - $this.val().length - (2 * splitedPostsCount.toString().length) - 6; $oldta.on("blur", replyTextKeypress);
if (typeof(reply_to) !== 'undefined' && $oldta.addClass('splited-post');
!(new RegExp('^.{0,' + (140 - c - reply_to.length).toString() + '}' + reply_to).test($this.val())))
c -= reply_to.length;
}
var remainingCount = tweetForm.find(".post-area-remaining");
if( c < 0 ) {
if (usePostSpliting){
var pml = 140 - (2 * splitedPostsCount.toString().length) - 6;
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); tweetForm.find(".textcomplete-wrapper").append($newta);
$newta.val(cp.substr(ci)); $newta.val(cp.substr(ci));
$newta.focus(); $newta.focus();
@ -613,10 +598,32 @@ function replyTextKeypress(e) {
else if ($newta[0].createTextRange) else if ($newta[0].createTextRange)
$newta[0].createTextRange().moveEnd('character', $newta.val().length); $newta[0].createTextRange().moveEnd('character', $newta.val().length);
c += ci - 1; $tas = tweetForm.find("textarea");
} else 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 - $tas[$tas.length - 1].value.length - (2 * splitedPostsCount.toString().length) - 4;
if (typeof(reply_to) !== 'undefined' &&
!checkPostForMentions($tas[$tas.length - 1].value, reply_to, 140 - c - reply_to.length))
c -= reply_to.length;
}
var remainingCount = tweetForm.find(".post-area-remaining");
if( c < 0 )
remainingCount.addClass("warn"); remainingCount.addClass("warn");
} else 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;

16
js/twister_formatpost.js

@ -156,9 +156,11 @@ function htmlFormatMsg( msg, output, mentions ) {
var index; var index;
var strUrlRegexp = "http[s]?://"; var strUrlRegexp = "http[s]?://";
var strEmailRegexp = "\\S+@\\S+\\.\\S+"; var strEmailRegexp = "\\S+@\\S+\\.\\S+";
var reAll = new RegExp("(?:^|[ \\n\\t.,:\\/?!])(#|@|" + strUrlRegexp + "|" + strEmailRegexp + ")"); var strSplitCounterR = "\\(\\d{1,2}\\/\\d{1,2}\\)$";
var reAll = new RegExp("(?:^|[ \\n\\t.,:\\/?!])(#|@|" + strUrlRegexp + "|" + strEmailRegexp + "|" + strSplitCounterR + ")");
var reHttp = new RegExp(strUrlRegexp); var reHttp = new RegExp(strUrlRegexp);
var reEmail = new RegExp(strEmailRegexp); var reEmail = new RegExp(strEmailRegexp);
var reSplitCounter = new RegExp(strSplitCounterR);
msg = escapeHtmlEntities(msg); msg = escapeHtmlEntities(msg);
@ -259,6 +261,18 @@ function htmlFormatMsg( msg, output, mentions ) {
msg = tmp; msg = tmp;
continue; continue;
} }
if (reSplitCounter.exec(match[1])) {
output.append(_formatText(msg.substr(0, index)));
tmp = msg.substring(index);
if( tmp.length ) {
var splitCounter = $('<span class="splited-post-counter"></span>');
splitCounter.text(tmp);
output.append(splitCounter);
msg = "";
continue;
}
}
} }
output.append(_formatText(msg)); output.append(_formatText(msg));

4
js/twister_timeline.js

@ -316,11 +316,11 @@ function willBeHidden(post){
if ($.Options.getHideRepliesOpt() !== 'disable' && if ($.Options.getHideRepliesOpt() !== 'disable' &&
/^\@/.test(msg) && /^\@/.test(msg) &&
!(new RegExp('@' + defaultScreenName + '( |,|;|\\.|:|\\/|\\?|\\!|\\\\|\'|"|\\n|$)').test(msg))) !(new RegExp('@' + defaultScreenName + '( |,|;|\\.|:|\\/|\\?|\\!|\\\\|\'|"|\\n|\\t|$)').test(msg)))
{ {
if ($.Options.getHideRepliesOpt() === 'only-me' || if ($.Options.getHideRepliesOpt() === 'only-me' ||
($.Options.getHideRepliesOpt() === 'following' && ($.Options.getHideRepliesOpt() === 'following' &&
followingUsers.indexOf(msg.substring(1, msg.search(/ |,|;|\.|:|\/|\?|\!|\\|'|"|\n/))) === -1 )) followingUsers.indexOf(msg.substring(1, msg.search(/ |,|;|\.|:|\/|\?|\!|\\|'|"|\n|\t|$/))) === -1 ))
{ {
hidden = true; hidden = true;
} }

Loading…
Cancel
Save