diff --git a/public/src/modules/composer.js b/public/src/modules/composer.js
index 71b3fac24f..98f9fbf0a5 100644
--- a/public/src/modules/composer.js
+++ b/public/src/modules/composer.js
@@ -292,12 +292,10 @@ define(['taskbar'], function(taskbar) {
return false;
});
- postContainer.find('.nav-tabs a').on('shown.bs.tab', function (e) {
- if($(e.target).attr('data-pane') === '.tab-preview') {
- socket.emit('modules.composer.renderPreview', bodyEl.val(), function(err, preview) {
- postContainer.find('.preview').html(preview);
- });
- }
+ bodyEl.on('blur', function() {
+ socket.emit('modules.composer.renderPreview', bodyEl.val(), function(err, preview) {
+ postContainer.find('.preview').html(preview);
+ });
});
@@ -305,20 +303,19 @@ define(['taskbar'], function(taskbar) {
resizeCenterY = 0,
resizeOffset = 0,
resizeStart = function(e) {
- bodyRect = document.body.getBoundingClientRect();
resizeRect = resizeEl.getBoundingClientRect();
resizeCenterY = resizeRect.top + (resizeRect.height/2);
resizeOffset = resizeCenterY - e.clientY;
resizeActive = true;
- $(document.body).on('mousemove', resizeAction);
- $(document.body).on('mouseup', resizeStop);
+ $(window).on('mousemove', resizeAction);
+ $(window).on('mouseup', resizeStop);
document.body.addEventListener('touchmove', resizeTouchAction);
},
resizeStop = function() {
resizeActive = false;
- $(document.body).off('mousemove', resizeAction);
- $(document.body).off('mouseup', resizeStop);
+ $(window).off('mousemove', resizeAction);
+ $(window).off('mouseup', resizeStop);
document.body.removeEventListener('touchmove', resizeTouchAction);
},
resizeTouchAction = function(e) {
@@ -328,17 +325,21 @@ define(['taskbar'], function(taskbar) {
resizeAction = function(e) {
if (resizeActive) {
position = (e.clientY + resizeOffset);
-
- postContainer.css('height', $(window).height() - position);
- resizeSavePosition($(window).height() - position);
+ var newHeight = $(window).height() - position;
+ if(newHeight > $(window).height() - $('#header-menu').height() - 20) {
+ newHeight = $(window).height() - $('#header-menu').height() - 20;
+ }
+ postContainer.css('height', newHeight);
+ resizeSavePosition(newHeight);
}
+ e.preventDefault();
return false;
},
resizeSavePosition = function(px) {
var percentage = px / $(window).height();
localStorage.setItem('composer:resizePercentage', percentage);
},
- resizeRect, bodyRect;
+ resizeRect;
var resizeEl = postContainer.find('.resizer')[0];
diff --git a/src/messaging.js b/src/messaging.js
index 8ef3954f20..dce2ba6d0f 100644
--- a/src/messaging.js
+++ b/src/messaging.js
@@ -63,13 +63,11 @@ var db = require('./database'),
return next(err);
}
- Messaging.parse(message.content, message.fromuid, fromuid, tousername, function(result) {
- message.content = result;
- messages.push(message);
- next(null);
- });
-
-
+ Messaging.parse(message.content, message.fromuid, fromuid, tousername, function(result) {
+ message.content = result;
+ messages.push(message);
+ next(null);
+ });
});
}
@@ -84,21 +82,21 @@ var db = require('./database'),
});
};
- Messaging.parse = function (message, fromuid, myuid, tousername, callback) {
- plugins.fireHook('filter:post.parse', message, function(err, parsed) {
- if (err) {
- return callback(message);
- }
- var username;
- if (fromuid === myuid) {
- username = "You: ";
- } else {
- username = "" + tousername + ": ";
- }
- var result = username + parsed;
- callback(result);
- });
- };
+ Messaging.parse = function (message, fromuid, myuid, tousername, callback) {
+ plugins.fireHook('filter:post.parse', message, function(err, parsed) {
+ if (err) {
+ return callback(message);
+ }
+ var username;
+ if (fromuid === myuid) {
+ username = "You: ";
+ } else {
+ username = "" + tousername + ": ";
+ }
+
+ callback(username + parsed);
+ });
+ };
Messaging.updateChatTime = function(uid, toUid, callback) {
db.sortedSetAdd('uid:' + uid + ':chats', Date.now(), toUid, function(err) {
diff --git a/src/socket.io/modules.js b/src/socket.io/modules.js
index dd38c62207..b2bc6b0940 100644
--- a/src/socket.io/modules.js
+++ b/src/socket.io/modules.js
@@ -7,6 +7,7 @@ var posts = require('../posts'),
Messaging = require('../messaging'),
user = require('../user'),
notifications = require('../notifications'),
+ plugins = require('../plugins'),
async = require('async'),
S = require('string'),
@@ -64,8 +65,7 @@ SocketModules.composer.editCheck = function(socket, pid, callback) {
};
SocketModules.composer.renderPreview = function(socket, content, callback) {
- var preview = require('marked')(content);
- callback(null, preview);
+ plugins.fireHook('filter:post.parse', content, callback);
}
/* Chat */