From 002826d84fe22dc80516d779a981a5dd541b4675 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 18 Dec 2013 23:56:59 -0500 Subject: [PATCH] resizing the post composer now saves the size for future windows --- public/src/modules/composer.js | 26 +++++++++++++++----------- public/templates/composer.tpl | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) 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 @@ - +