fixing issue where composer pushing didn't wait for the template to

properly render :P
v1.18.x
Julian Lam 11 years ago
parent f2d631e42d
commit 99fba3b83a

@ -158,7 +158,8 @@ define(['taskbar'], function(taskbar) {
// Post Window events
var jPostContainer = $(composer.postContainer),
postContentEl = composer.postContainer.querySelector('textarea');
postContentEl = composer.postContainer.querySelector('textarea'),
resizeEl = jPostContainer.find('.resizer');
jPostContainer.on('change', 'input, textarea', function() {
var uuid = $(this).parents('.post-window')[0].getAttribute('data-uuid');
@ -174,7 +175,6 @@ define(['taskbar'], function(taskbar) {
uuid = $(this).parents('.post-window').attr('data-uuid');
switch(action) {
case 'post': composer.post(uuid); break;
case 'minimize': composer.minimize(uuid); break;
case 'discard':
if (composer.posts[uuid].modified) {
bootbox.confirm('Are you sure you wish to discard this post?', function(discard) {
@ -241,6 +241,10 @@ define(['taskbar'], function(taskbar) {
}
});
resizeEl.on('dragstart', function() {
console.log('dragging');
});
window.addEventListener('resize', function() {
if (composer.active !== undefined) composer.reposition(composer.active);
});
@ -277,12 +281,19 @@ define(['taskbar'], function(taskbar) {
}
composer.push = function(tid, cid, pid, text) {
socket.emit('api:composer.push', {
tid: tid, // Replying
cid: cid, // Posting
pid: pid, // Editing
body: text // Predefined text
});
if (!composer.initialized) {
var args = arguments;
setTimeout(function() {
composer.push.apply(composer, args);
}, 500);
} else {
socket.emit('api:composer.push', {
tid: tid, // Replying
cid: cid, // Posting
pid: pid, // Editing
body: text // Predefined text
});
}
}
composer.load = function(post_uuid) {
@ -290,6 +301,7 @@ define(['taskbar'], function(taskbar) {
titleEl = composer.postContainer.querySelector('input'),
bodyEl = composer.postContainer.querySelector('textarea');
console.log('load');
composer.reposition(post_uuid);
composer.active = post_uuid;
@ -319,17 +331,18 @@ define(['taskbar'], function(taskbar) {
}
composer.reposition = function(post_uuid) {
var postWindowEl = composer.postContainer.querySelector('.col-md-5'),
console.log('reposition');
var postWindowEl = composer.postContainer.querySelector('.col-md-5')/*,
taskbarBtn = document.querySelector('#taskbar [data-uuid="' + post_uuid + '"]'),
btnRect = taskbarBtn.getBoundingClientRect(),
taskbarRect = document.getElementById('taskbar').getBoundingClientRect(),
windowRect, leftPos;
windowRect, leftPos*/;
composer.postContainer.style.display = 'block';
windowRect = postWindowEl.getBoundingClientRect();
leftPos = btnRect.left + btnRect.width - windowRect.width;
postWindowEl.style.left = (leftPos > 0 ? leftPos : 0) + 'px';
composer.postContainer.style.bottom = taskbarRect.height + "px";
composer.postContainer.style.visibility = 'visible';
// windowRect = postWindowEl.getBoundingClientRect();
// leftPos = btnRect.left + btnRect.width - windowRect.width;
// postWindowEl.style.left = (leftPos > 0 ? leftPos : 0) + 'px';
// composer.postContainer.style.bottom = taskbarRect.height + "px";
}
composer.post = function(post_uuid) {

@ -13,7 +13,6 @@
<div class="imagedrop"><div>Drag and Drop Images Here</div></div>
<div class="btn-toolbar action-bar">
<div class="btn-group pull-right">
<button data-action="minimize" class="btn hidden-xs" tabIndex="4"><i class="fa fa-download"></i> Minimize</button>
<button class="btn" data-action="discard" tabIndex="5"><i class="fa fa-times"></i> Discard</button>
<button data-action="post" class="btn" tabIndex="3"><i class="fa fa-check"></i> Submit</button>
</div>

Loading…
Cancel
Save