mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-03-13 05:51:03 +00:00
make post size (display and editor) configurable.
default is now 256.
This commit is contained in:
parent
097d84847b
commit
baf464b761
@ -1667,8 +1667,9 @@ function replyTextInput(event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getPostSplitingPML() {
|
function getPostSplitingPML() {
|
||||||
|
var MaxPostSize = $.Options.MaxPostEditorChars.val;
|
||||||
if (splitedPostsCount > 1) {
|
if (splitedPostsCount > 1) {
|
||||||
var pml = 140 - (i+1).toString().length - splitedPostsCount.toString().length - 4;
|
var pml = MaxPostSize - (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' &&
|
||||||
@ -1676,7 +1677,7 @@ function replyTextInput(event) {
|
|||||||
pml -= reply_to.length;
|
pml -= reply_to.length;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
var pml = 140;
|
var pml = MaxPostSize;
|
||||||
return pml;
|
return pml;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1723,7 +1724,8 @@ function replyTextUpdateRemaining(ta) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!disable && c >= 0 && c < 140 && textArea.val() !== textArea.attr('data-reply-to')) {
|
if (!disable && c >= 0 && c < $.Options.MaxPostEditorChars.val &&
|
||||||
|
textArea.val() !== textArea.attr('data-reply-to')) {
|
||||||
remainingCount.removeClass('warn');
|
remainingCount.removeClass('warn');
|
||||||
$.MAL.enableButton(buttonSend);
|
$.MAL.enableButton(buttonSend);
|
||||||
} else {
|
} else {
|
||||||
@ -1739,14 +1741,15 @@ function replyTextCountRemaining(ta) {
|
|||||||
var textArea = $(ta);
|
var textArea = $(ta);
|
||||||
var c;
|
var c;
|
||||||
|
|
||||||
|
var MaxPostSize = $.Options.MaxPostEditorChars.val;
|
||||||
if (usePostSpliting && !textArea.closest('.directMessages').length && splitedPostsCount > 1) {
|
if (usePostSpliting && !textArea.closest('.directMessages').length && splitedPostsCount > 1) {
|
||||||
c = 140 - ta.value.length - (textArea.closest('form').find('textarea').index(ta) + 1).toString().length - splitedPostsCount.toString().length - 4;
|
c = MaxPostSize - ta.value.length - (textArea.closest('form').find('textarea').index(ta) + 1).toString().length - splitedPostsCount.toString().length - 4;
|
||||||
var reply_to = textArea.attr('data-reply-to');
|
var reply_to = textArea.attr('data-reply-to');
|
||||||
if (typeof reply_to !== 'undefined' &&
|
if (typeof reply_to !== 'undefined' &&
|
||||||
!checkPostForMentions(ta.value, reply_to, 140 -c -reply_to.length))
|
!checkPostForMentions(ta.value, reply_to, MaxPostSize -c -reply_to.length))
|
||||||
c -= reply_to.length;
|
c -= reply_to.length;
|
||||||
} else
|
} else
|
||||||
c = 140 - ta.value.length;
|
c = MaxPostSize - ta.value.length;
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@ -2211,7 +2214,7 @@ function postSubmit(e, oldLastPostId) {
|
|||||||
var postText = '';
|
var postText = '';
|
||||||
var reply_to = textArea.attr('data-reply-to');
|
var reply_to = textArea.attr('data-reply-to');
|
||||||
var val = textArea.val();
|
var val = textArea.val();
|
||||||
if (typeof reply_to === 'undefined' || checkPostForMentions(val, reply_to, 140))
|
if (typeof reply_to === 'undefined' || checkPostForMentions(val, reply_to, $.Options.MaxPostEditorChars.val))
|
||||||
postText = val + ' (' + splitedPostsCount.toString() + '/' + splitedPostsCount.toString() + ')';
|
postText = val + ' (' + splitedPostsCount.toString() + '/' + splitedPostsCount.toString() + ')';
|
||||||
else
|
else
|
||||||
postText = reply_to + val + ' (' + splitedPostsCount.toString() + '/' + splitedPostsCount.toString() + ')';
|
postText = reply_to + val + ' (' + splitedPostsCount.toString() + '/' + splitedPostsCount.toString() + ')';
|
||||||
@ -2225,7 +2228,7 @@ function postSubmit(e, oldLastPostId) {
|
|||||||
var postText = '';
|
var postText = '';
|
||||||
var reply_to = textArea.attr('data-reply-to');
|
var reply_to = textArea.attr('data-reply-to');
|
||||||
var val = textArea[0].value;
|
var val = textArea[0].value;
|
||||||
if (typeof reply_to === 'undefined' || checkPostForMentions(val, reply_to, 140))
|
if (typeof reply_to === 'undefined' || checkPostForMentions(val, reply_to, $.Options.MaxPostEditorChars.val))
|
||||||
postText = val + ' (' + (splitedPostsCount - textArea.length + 1).toString() + '/' + splitedPostsCount.toString() + ')';
|
postText = val + ' (' + (splitedPostsCount - textArea.length + 1).toString() + '/' + splitedPostsCount.toString() + ')';
|
||||||
else
|
else
|
||||||
postText = reply_to + val + ' (' + (splitedPostsCount - textArea.length + 1).toString() + '/' + splitedPostsCount.toString() + ')';
|
postText = reply_to + val + ' (' + (splitedPostsCount - textArea.length + 1).toString() + '/' + splitedPostsCount.toString() + ')';
|
||||||
@ -2242,7 +2245,7 @@ function postSubmit(e, oldLastPostId) {
|
|||||||
closePrompt(btnPostSubmit);
|
closePrompt(btnPostSubmit);
|
||||||
else {
|
else {
|
||||||
textArea.val('').attr('placeholder', polyglot.t('Your message was sent!'));
|
textArea.val('').attr('placeholder', polyglot.t('Your message was sent!'));
|
||||||
btnPostSubmit.closest('form').find('.post-area-remaining').text('140');
|
btnPostSubmit.closest('form').find('.post-area-remaining').text('');
|
||||||
|
|
||||||
if (btnPostSubmit.closest('.post-area,.post-reply-content')) {
|
if (btnPostSubmit.closest('.post-area,.post-reply-content')) {
|
||||||
$('.post-area-new').removeClass('open').find('textarea').blur();
|
$('.post-area-new').removeClass('open').find('textarea').blur();
|
||||||
|
@ -190,6 +190,20 @@ function twisterOptions() {
|
|||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
valDefault: false
|
valDefault: false
|
||||||
});
|
});
|
||||||
|
this.add({
|
||||||
|
name: 'MaxPostDisplayChars',
|
||||||
|
type: 'numeric',
|
||||||
|
valDefault: '256',
|
||||||
|
valMes: 'characters',
|
||||||
|
getMethod: function (val) {return parseInt(val);}
|
||||||
|
});
|
||||||
|
this.add({
|
||||||
|
name: 'MaxPostEditorChars',
|
||||||
|
type: 'numeric',
|
||||||
|
valDefault: '256',
|
||||||
|
valMes: 'characters',
|
||||||
|
getMethod: function (val) {return parseInt(val);}
|
||||||
|
});
|
||||||
this.add({
|
this.add({
|
||||||
name: 'splitPosts',
|
name: 'splitPosts',
|
||||||
valDefault: 'disable'
|
valDefault: 'disable'
|
||||||
|
@ -89,6 +89,10 @@ function postToElem(post, kind, promoted) {
|
|||||||
if (typeof msg !== 'string')
|
if (typeof msg !== 'string')
|
||||||
msg = '';
|
msg = '';
|
||||||
|
|
||||||
|
if (msg.length > $.Options.MaxPostDisplayChars.val) {
|
||||||
|
msg = msg.slice(0,$.Options.MaxPostDisplayChars.val) + "\u2026";
|
||||||
|
}
|
||||||
|
|
||||||
// Now create the html elements
|
// Now create the html elements
|
||||||
var elem = $.MAL.getPostTemplate().clone(true).appendTo(twister.html.detached);
|
var elem = $.MAL.getPostTemplate().clone(true).appendTo(twister.html.detached);
|
||||||
elem.removeAttr('id')
|
elem.removeAttr('id')
|
||||||
|
12
options.html
12
options.html
@ -312,6 +312,12 @@
|
|||||||
<input name="" id="useProxyForImgOnly" class="container" type="checkbox" /> <span class="label">Use proxy for image preview only</span>
|
<input name="" id="useProxyForImgOnly" class="container" type="checkbox" /> <span class="label">Use proxy for image preview only</span>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<form action="">
|
||||||
|
<p class="label">Maximum post size to show</p>
|
||||||
|
<input type="text" id="MaxPostDisplayChars" class="container" maxlength="5" size="5"/> <span class="label">characters</span>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="module">
|
<div class="module">
|
||||||
<p class="label label-h"> Top Trends </p>
|
<p class="label label-h"> Top Trends </p>
|
||||||
@ -417,6 +423,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="container">
|
||||||
|
<form action="">
|
||||||
|
<p class="label">Maximum post size to send</p>
|
||||||
|
<input type="text" id="MaxPostEditorChars" class="container" maxlength="5" size="5"/> <span class="label">characters</span>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<form action="" id="splitPostsOpt">
|
<form action="" id="splitPostsOpt">
|
||||||
<p class="label">Split long posts</p>
|
<p class="label">Split long posts</p>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user