Merge branch 'master' of github.com:designcreateplay/NodeBB

v1.18.x
Julian Lam 11 years ago
commit 4aef5bfb72

@ -331,6 +331,28 @@ var socket,
} }
app.openChat = function (username, touid) { app.openChat = function (username, touid) {
if (username === app.username) {
app.alert({
type: 'warning',
title: 'Invalid Chat',
message: "You can't chat with yourself!",
timeout: 5000
});
return;
}
if (!app.username) {
app.alert({
type: 'danger',
title: 'Not Logged In',
message: 'Please log in to chat with <strong>' + username + '</strong>',
timeout: 5000
});
return;
}
require(['chat'], function (chat) { require(['chat'], function (chat) {
var chatModal; var chatModal;
if (!chat.modalExists(touid)) { if (!chat.modalExists(touid)) {
@ -374,12 +396,15 @@ var socket,
app.infiniteLoaderActive = false; app.infiniteLoaderActive = false;
app.loadMorePosts = function (tid, callback) { app.loadMorePosts = function (tid, callback) {
if (app.infiniteLoaderActive) if (app.infiniteLoaderActive) {
return; return;
}
app.infiniteLoaderActive = true; app.infiniteLoaderActive = true;
if ($('#loading-indicator').attr('done') === '0') if ($('#loading-indicator').attr('done') === '0') {
$('#loading-indicator').removeClass('hide'); $('#loading-indicator').removeClass('hide');
}
socket.emit('api:topic.loadMore', { socket.emit('api:topic.loadMore', {
tid: tid, tid: tid,
@ -411,9 +436,9 @@ var socket,
} }
app.scrollToPost = function (pid) { app.scrollToPost = function (pid) {
if (!pid) {
if (!pid)
return; return;
}
var container = $(document.body), var container = $(document.body),
scrollTo = $('#post_anchor_' + pid), scrollTo = $('#post_anchor_' + pid),
@ -423,7 +448,6 @@ var socket,
$('body,html').animate({ $('body,html').animate({
scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop() - $('#header-menu').height() scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop() - $('#header-menu').height()
}, 400); }, 400);
//$('body,html').scrollTop(scrollTo.offset().top - container.offset().top + container.scrollTop() - $('#header-menu').height());
} }
if (!scrollTo.length && tid) { if (!scrollTo.length && tid) {

@ -362,9 +362,6 @@ define(function() {
var username = $(this).parents('li.row').attr('data-username'); var username = $(this).parents('li.row').attr('data-username');
var touid = $(this).parents('li.row').attr('data-uid'); var touid = $(this).parents('li.row').attr('data-uid');
if (username === app.username || !app.username)
return;
app.openChat(username, touid); app.openChat(username, touid);
}); });

@ -210,13 +210,17 @@ define(['taskbar'], function(taskbar) {
selectionEnd = postContentEl.selectionEnd, selectionEnd = postContentEl.selectionEnd,
selectionLength = selectionEnd - selectionStart; selectionLength = selectionEnd - selectionStart;
function insertIntoInput(element, value) {
var start = postContentEl.selectionStart;
element.value = element.value.slice(0, start) + value + element.value.slice(start, element.value.length);
postContentEl.selectionStart = postContentEl.selectionEnd = start + value.length;
}
switch(iconClass) { switch(iconClass) {
case 'icon-bold': case 'icon-bold':
if (selectionStart === selectionEnd) { if (selectionStart === selectionEnd) {
// Nothing selected // Nothing selected
postContentEl.value = postContentEl.value + '**bolded text**'; insertIntoInput(postContentEl, "**bolded text**");
postContentEl.selectionStart = cursorEnd+2;
postContentEl.selectionEnd = postContentEl.value.length - 2;
} else { } else {
// Text selected // Text selected
postContentEl.value = postContentEl.value.slice(0, selectionStart) + '**' + postContentEl.value.slice(selectionStart, selectionEnd) + '**' + postContentEl.value.slice(selectionEnd); postContentEl.value = postContentEl.value.slice(0, selectionStart) + '**' + postContentEl.value.slice(selectionStart, selectionEnd) + '**' + postContentEl.value.slice(selectionEnd);
@ -227,9 +231,7 @@ define(['taskbar'], function(taskbar) {
case 'icon-italic': case 'icon-italic':
if (selectionStart === selectionEnd) { if (selectionStart === selectionEnd) {
// Nothing selected // Nothing selected
postContentEl.value = postContentEl.value + '*italicised text*'; insertIntoInput(postContentEl, "*italicised text*");
postContentEl.selectionStart = cursorEnd+1;
postContentEl.selectionEnd = postContentEl.value.length - 1;
} else { } else {
// Text selected // Text selected
postContentEl.value = postContentEl.value.slice(0, selectionStart) + '*' + postContentEl.value.slice(selectionStart, selectionEnd) + '*' + postContentEl.value.slice(selectionEnd); postContentEl.value = postContentEl.value.slice(0, selectionStart) + '*' + postContentEl.value.slice(selectionStart, selectionEnd) + '*' + postContentEl.value.slice(selectionEnd);
@ -239,16 +241,12 @@ define(['taskbar'], function(taskbar) {
break; break;
case 'icon-list': case 'icon-list':
// Nothing selected // Nothing selected
postContentEl.value = postContentEl.value + "\n\n* list item"; insertIntoInput(postContentEl, "\n\n* list item");
postContentEl.selectionStart = cursorEnd+4;
postContentEl.selectionEnd = postContentEl.value.length;
break; break;
case 'icon-link': case 'icon-link':
if (selectionStart === selectionEnd) { if (selectionStart === selectionEnd) {
// Nothing selected // Nothing selected
postContentEl.value = postContentEl.value + '[link text](link url)'; insertIntoInput(postContentEl, "[link text](link url)");
postContentEl.selectionStart = cursorEnd+12;
postContentEl.selectionEnd = postContentEl.value.length - 1;
} else { } else {
// Text selected // Text selected
postContentEl.value = postContentEl.value.slice(0, selectionStart) + '[' + postContentEl.value.slice(selectionStart, selectionEnd) + '](link url)' + postContentEl.value.slice(selectionEnd); postContentEl.value = postContentEl.value.slice(0, selectionStart) + '[' + postContentEl.value.slice(selectionStart, selectionEnd) + '](link url)' + postContentEl.value.slice(selectionEnd);
@ -258,6 +256,7 @@ define(['taskbar'], function(taskbar) {
break; break;
} }
}); });
window.addEventListener('resize', function() { window.addEventListener('resize', function() {
if (composer.active !== undefined) composer.reposition(composer.active); if (composer.active !== undefined) composer.reposition(composer.active);
}); });

Loading…
Cancel
Save