mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 23:15:48 +01:00
fixing issue where composer pushing didn't wait for the template to
properly render :P
This commit is contained in:
@@ -158,7 +158,8 @@ define(['taskbar'], function(taskbar) {
|
|||||||
|
|
||||||
// Post Window events
|
// Post Window events
|
||||||
var jPostContainer = $(composer.postContainer),
|
var jPostContainer = $(composer.postContainer),
|
||||||
postContentEl = composer.postContainer.querySelector('textarea');
|
postContentEl = composer.postContainer.querySelector('textarea'),
|
||||||
|
resizeEl = jPostContainer.find('.resizer');
|
||||||
|
|
||||||
jPostContainer.on('change', 'input, textarea', function() {
|
jPostContainer.on('change', 'input, textarea', function() {
|
||||||
var uuid = $(this).parents('.post-window')[0].getAttribute('data-uuid');
|
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');
|
uuid = $(this).parents('.post-window').attr('data-uuid');
|
||||||
switch(action) {
|
switch(action) {
|
||||||
case 'post': composer.post(uuid); break;
|
case 'post': composer.post(uuid); break;
|
||||||
case 'minimize': composer.minimize(uuid); break;
|
|
||||||
case 'discard':
|
case 'discard':
|
||||||
if (composer.posts[uuid].modified) {
|
if (composer.posts[uuid].modified) {
|
||||||
bootbox.confirm('Are you sure you wish to discard this post?', function(discard) {
|
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() {
|
window.addEventListener('resize', function() {
|
||||||
if (composer.active !== undefined) composer.reposition(composer.active);
|
if (composer.active !== undefined) composer.reposition(composer.active);
|
||||||
});
|
});
|
||||||
@@ -277,12 +281,19 @@ define(['taskbar'], function(taskbar) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
composer.push = function(tid, cid, pid, text) {
|
composer.push = function(tid, cid, pid, text) {
|
||||||
socket.emit('api:composer.push', {
|
if (!composer.initialized) {
|
||||||
tid: tid, // Replying
|
var args = arguments;
|
||||||
cid: cid, // Posting
|
setTimeout(function() {
|
||||||
pid: pid, // Editing
|
composer.push.apply(composer, args);
|
||||||
body: text // Predefined text
|
}, 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) {
|
composer.load = function(post_uuid) {
|
||||||
@@ -290,6 +301,7 @@ define(['taskbar'], function(taskbar) {
|
|||||||
titleEl = composer.postContainer.querySelector('input'),
|
titleEl = composer.postContainer.querySelector('input'),
|
||||||
bodyEl = composer.postContainer.querySelector('textarea');
|
bodyEl = composer.postContainer.querySelector('textarea');
|
||||||
|
|
||||||
|
console.log('load');
|
||||||
composer.reposition(post_uuid);
|
composer.reposition(post_uuid);
|
||||||
composer.active = post_uuid;
|
composer.active = post_uuid;
|
||||||
|
|
||||||
@@ -319,17 +331,18 @@ define(['taskbar'], function(taskbar) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
composer.reposition = function(post_uuid) {
|
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 + '"]'),
|
taskbarBtn = document.querySelector('#taskbar [data-uuid="' + post_uuid + '"]'),
|
||||||
btnRect = taskbarBtn.getBoundingClientRect(),
|
btnRect = taskbarBtn.getBoundingClientRect(),
|
||||||
taskbarRect = document.getElementById('taskbar').getBoundingClientRect(),
|
taskbarRect = document.getElementById('taskbar').getBoundingClientRect(),
|
||||||
windowRect, leftPos;
|
windowRect, leftPos*/;
|
||||||
|
|
||||||
composer.postContainer.style.display = 'block';
|
composer.postContainer.style.visibility = 'visible';
|
||||||
windowRect = postWindowEl.getBoundingClientRect();
|
// windowRect = postWindowEl.getBoundingClientRect();
|
||||||
leftPos = btnRect.left + btnRect.width - windowRect.width;
|
// leftPos = btnRect.left + btnRect.width - windowRect.width;
|
||||||
postWindowEl.style.left = (leftPos > 0 ? leftPos : 0) + 'px';
|
// postWindowEl.style.left = (leftPos > 0 ? leftPos : 0) + 'px';
|
||||||
composer.postContainer.style.bottom = taskbarRect.height + "px";
|
// composer.postContainer.style.bottom = taskbarRect.height + "px";
|
||||||
}
|
}
|
||||||
|
|
||||||
composer.post = function(post_uuid) {
|
composer.post = function(post_uuid) {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
<div class="imagedrop"><div>Drag and Drop Images Here</div></div>
|
<div class="imagedrop"><div>Drag and Drop Images Here</div></div>
|
||||||
<div class="btn-toolbar action-bar">
|
<div class="btn-toolbar action-bar">
|
||||||
<div class="btn-group pull-right">
|
<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 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>
|
<button data-action="post" class="btn" tabIndex="3"><i class="fa fa-check"></i> Submit</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user