mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 06:55:46 +01:00
resizing the post composer now saves the size for future windows
This commit is contained in:
@@ -250,18 +250,26 @@ define(['taskbar'], function(taskbar) {
|
|||||||
if (Math.abs(position - resizeSnaps.half) <= 15) {
|
if (Math.abs(position - resizeSnaps.half) <= 15) {
|
||||||
// Half snap
|
// Half snap
|
||||||
jPostContainer.css('width', resizeSnaps.half);
|
jPostContainer.css('width', resizeSnaps.half);
|
||||||
|
resizeSavePosition(resizeSnaps.half);
|
||||||
} else if (Math.abs(position - resizeSnaps.none) <= 15) {
|
} else if (Math.abs(position - resizeSnaps.none) <= 15) {
|
||||||
// Minimize snap
|
// Minimize snap
|
||||||
jPostContainer.css('width', bodyRect.width - resizeSnaps.none);
|
jPostContainer.css('width', bodyRect.width - resizeSnaps.none);
|
||||||
|
resizeSavePosition(resizeSnaps.none);
|
||||||
} else if (position <= 15) {
|
} else if (position <= 15) {
|
||||||
// Full snap
|
// Full snap
|
||||||
jPostContainer.css('width', bodyRect.width - 15);
|
jPostContainer.css('width', bodyRect.width - 15);
|
||||||
|
resizeSavePosition(bodyRect.width - 15);
|
||||||
} else {
|
} else {
|
||||||
// OH SNAP, NO SNAPS!
|
// OH SNAP, NO SNAPS!
|
||||||
jPostContainer.css('width', bodyRect.width - position);
|
jPostContainer.css('width', bodyRect.width - position);
|
||||||
|
resizeSavePosition(bodyRect.width - position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
resizeSavePosition = function(px) {
|
||||||
|
var percentage = px/bodyRect.width;
|
||||||
|
localStorage.setItem('composer:resizePercentage', percentage);
|
||||||
|
},
|
||||||
resizeSnaps = {
|
resizeSnaps = {
|
||||||
none: 0,
|
none: 0,
|
||||||
half: 0,
|
half: 0,
|
||||||
@@ -342,7 +350,6 @@ 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;
|
||||||
|
|
||||||
@@ -372,18 +379,15 @@ define(['taskbar'], function(taskbar) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
composer.reposition = function(post_uuid) {
|
composer.reposition = function(post_uuid) {
|
||||||
console.log('reposition');
|
// Resize the composer to the saved size
|
||||||
var postWindowEl = composer.postContainer.querySelector('.col-md-5')/*,
|
var percentage = localStorage.getItem('composer:resizePercentage'),
|
||||||
taskbarBtn = document.querySelector('#taskbar [data-uuid="' + post_uuid + '"]'),
|
bodyRect = document.body.getBoundingClientRect();
|
||||||
btnRect = taskbarBtn.getBoundingClientRect(),
|
|
||||||
taskbarRect = document.getElementById('taskbar').getBoundingClientRect(),
|
if (bodyRect.width >= 768) {
|
||||||
windowRect, leftPos*/;
|
composer.postContainer.style.width = Math.floor(bodyRect.width * percentage) + 'px';
|
||||||
|
}
|
||||||
|
|
||||||
composer.postContainer.style.visibility = 'visible';
|
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) {
|
composer.post = function(post_uuid) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<span class="btn btn-link" tabindex="-1"><i class="fa fa-list"></i></span>
|
<span class="btn btn-link" tabindex="-1"><i class="fa fa-list"></i></span>
|
||||||
<span class="btn btn-link" tabindex="-1"><i class="fa fa-link"></i></span>
|
<span class="btn btn-link" tabindex="-1"><i class="fa fa-link"></i></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn btn-link pull-right">Preview</div>
|
<!-- <div class="btn btn-link pull-right">Preview</div> -->
|
||||||
</div>
|
</div>
|
||||||
<textarea tabIndex="2"></textarea>
|
<textarea tabIndex="2"></textarea>
|
||||||
<div class="preview"></div>
|
<div class="preview"></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user