diff --git a/src/app.js b/src/app.js index 5a75c07ad2..2f7dd3ed8f 100644 --- a/src/app.js +++ b/src/app.js @@ -335,6 +335,8 @@ var run = function () { // ----------------- resizeable ui --------------- + var EDITOR_SIZE_KEY = 'editor-size-cache' + var dragging = false $('#dragbar').mousedown(function (e) { e.preventDefault() @@ -361,7 +363,7 @@ var run = function () { } function getEditorSize () { - storage.setEditorSize($('#righthand-panel').width()) + return $('#righthand-panel').width() } $(document).mouseup(function (e) { @@ -371,15 +373,16 @@ var run = function () { $(document).unbind('mousemove') dragging = false setEditorSize(delta) - storage.setEditorSize(delta) + storage.set(EDITOR_SIZE_KEY, delta) reAdjust() } }) - // set cached defaults - var cachedSize = storage.getEditorSize() - if (cachedSize) setEditorSize(cachedSize) - else getEditorSize() + if (storage.exists(EDITOR_SIZE_KEY)) { + setEditorSize(storage.get(EDITOR_SIZE_KEY)) + } else { + storage.set(EDITOR_SIZE_KEY, getEditorSize()) + } // ----------------- toggle right hand panel ----------------- diff --git a/src/app/storage.js b/src/app/storage.js index 3f77d37206..16d8f99e18 100644 --- a/src/app/storage.js +++ b/src/app/storage.js @@ -4,8 +4,6 @@ var utils = require('./utils') function Storage (updateFiles) { - var EDITOR_SIZE_CACHE_KEY = 'editor-size-cache' - this.rename = function (originalName, newName) { var content = this.get(originalName) this.set(newName, content) @@ -16,14 +14,6 @@ function Storage (updateFiles) { window.localStorage.removeItem(name) } - this.setEditorSize = function (size) { - this.set(EDITOR_SIZE_CACHE_KEY, size) - } - - this.getEditorSize = function () { - return this.get(EDITOR_SIZE_CACHE_KEY) - } - this.getFileContent = function (key) { return this.get(utils.fileKey(key)) }