From 9b1cb29e1f693aed0aad3e287bd9631f4ee0ae5c Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Wed, 30 Jan 2013 12:13:20 -0800 Subject: [PATCH] Don't store fontSize and fontFamily as instance variables --- spec/app/root-view-spec.coffee | 2 +- src/app/editor.coffee | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/spec/app/root-view-spec.coffee b/spec/app/root-view-spec.coffee index 20b5bca36..b046bef30 100644 --- a/spec/app/root-view-spec.coffee +++ b/spec/app/root-view-spec.coffee @@ -567,9 +567,9 @@ describe "RootView", -> editor = null beforeEach -> editor = rootView.getActiveEditor() + editor.attachToDom() it "increases/decreases font size when increase/decrease-font-size events are triggered", -> - editor = rootView.getActiveEditor() fontSizeBefore = editor.getFontSize() rootView.trigger 'window:increase-font-size' expect(editor.getFontSize()).toBe fontSizeBefore + 1 diff --git a/src/app/editor.coffee b/src/app/editor.coffee index a4dd22579..47517e043 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -682,29 +682,30 @@ class Editor extends View autosave: -> @save() if @getPath()? - setFontSize: (@fontSize) -> + setFontSize: (fontSize) -> headTag = $("head") styleTag = headTag.find("style.font-size") if styleTag.length == 0 styleTag = $$ -> @style class: 'font-size' headTag.append styleTag - styleTag.text(".editor {font-size: #{@fontSize}px}") + styleTag.text(".editor {font-size: #{fontSize}px}") @redraw() - getFontSize: -> @fontSize + getFontSize: -> + parseInt(@css("font-size")) - setFontFamily: (@fontFamily) -> + setFontFamily: (fontFamily) -> headTag = $("head") styleTag = headTag.find("style.font-family") if styleTag.length == 0 styleTag = $$ -> @style class: 'font-family' headTag.append styleTag - styleTag.text(".editor {font-family: #{@fontFamily}}") + styleTag.text(".editor {font-family: #{fontFamily}}") @redraw() - getFontFamily: -> @fontFamily + getFontFamily: -> @css("font-family") redraw: -> return unless @attached