Skip to content

Node.js based forum software built for the modern web

resizing the post composer now saves the size for future windows

Julian Lam002826d84fe2
diff --git a/public/src/modules/composer.js b/public/src/modules/composer.js
index 3ea750f8a9..ab1f6ce37f 100644
--- a/public/src/modules/composer.js
+++ b/public/src/modules/composer.js
@@ -250,18 +250,26 @@ define(['taskbar'], function(taskbar) {
if (Math.abs(position - resizeSnaps.half) <= 15) {
// Half snap
jPostContainer.css('width', resizeSnaps.half);
+ resizeSavePosition(resizeSnaps.half);
} else if (Math.abs(position - resizeSnaps.none) <= 15) {
// Minimize snap
jPostContainer.css('width', bodyRect.width - resizeSnaps.none);
+ resizeSavePosition(resizeSnaps.none);
} else if (position <= 15) {
// Full snap
jPostContainer.css('width', bodyRect.width - 15);
+ resizeSavePosition(bodyRect.width - 15);
} else {
// OH SNAP, NO SNAPS!
jPostContainer.css('width', bodyRect.width - position);
+ resizeSavePosition(bodyRect.width - position);
}
}
},
+ resizeSavePosition = function(px) {
+ var percentage = px/bodyRect.width;
+ localStorage.setItem('composer:resizePercentage', percentage);
+ },
resizeSnaps = {
none: 0,
half: 0,
@@ -342,7 +350,6 @@ 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;
@@ -372,18 +379,15 @@ define(['taskbar'], function(taskbar) {
}
composer.reposition = function(post_uuid) {
- 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*/;
+ // Resize the composer to the saved size
+ var percentage = localStorage.getItem('composer:resizePercentage'),
+ bodyRect = document.body.getBoundingClientRect();
+
+ if (bodyRect.width >= 768) {
+ composer.postContainer.style.width = Math.floor(bodyRect.width * percentage) + '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) {
diff --git a/public/templates/composer.tpl b/public/templates/composer.tpl
index daaaa9ec71..14936352fe 100644
--- a/public/templates/composer.tpl
+++ b/public/templates/composer.tpl
@@ -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-link"></i></span>
</div>
- <div class="btn btn-link pull-right">Preview</div>
+ <!-- <div class="btn btn-link pull-right">Preview</div> -->
</div>
<textarea tabIndex="2"></textarea>
<div class="preview"></div>