Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Default text size is now explicitly "normal" if not otherwise set.
Browse files Browse the repository at this point in the history
This is sort of a "partial cherry-pick" of commit
3e41b08 in that it doesn't move the CSS
outside of text.js; it just fixes #86, which is a much less volatile
change right now.
  • Loading branch information
toolness committed Jun 8, 2012
1 parent f96ae71 commit ee84049
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions js/fc/ui/text.js
Expand Up @@ -82,7 +82,11 @@ define(function() {
// refesh code mirror
codeMirror.refresh();
// update localstorage
if (supportsLocalStorage()) { localStorage["ThimbleTextSize"] = size; }
if (supportsLocalStorage()) try {
// TODO: Consider using lscache here, as it automatically deals
// w/ edge cases like out-of-space exceptions.
localStorage["ThimbleTextSize"] = size;
} catch (e) { /* Out of storage space, no big deal. */ }
// mark text size in drop-down
$("#text-nav-item li").removeClass("selected");
$("#text-nav-item li[data-size="+size+"]").addClass("selected");
Expand All @@ -94,14 +98,11 @@ define(function() {
t.click(fn);
});

/**
* If there is a thimble text size set, trigger it.
*/
if (supportsLocalStorage()) {
if (typeof localStorage["ThimbleTextSize"] !== "undefined") {
var textSize = localStorage["ThimbleTextSize"];
$("#text-nav-item li[data-size="+textSize+"]").click();
}
}
var defaultSize = "normal";
var lastSize = supportsLocalStorage() && localStorage["ThimbleTextSize"];
if (lastSize && $("#text-nav-item li[data-size="+lastSize+"]").length)
defaultSize = lastSize;

$("#text-nav-item li[data-size="+defaultSize+"]").click();
};
});

0 comments on commit ee84049

Please sign in to comment.