Merge pull request #483 from fourplusone/ace2_inner_patch2

refactored ace_setProperty of ace2_inner.js
This commit is contained in:
John McLear 2012-02-24 09:00:18 -08:00
commit 64f04670ef
1 changed files with 37 additions and 49 deletions

View File

@ -1123,57 +1123,45 @@ function OUTER(gscope)
} }
} }
// This methed exposes a setter for some ace properties
// @param key the name of the parameter
// @param value the value to set to
editorInfo.ace_setProperty = function(key, value) editorInfo.ace_setProperty = function(key, value)
{ {
var k = key.toLowerCase();
if (k == "wraps") // Convinience function returning a setter for a class on an element
{ var setClassPresenceNamed = function(element, cls){
setWraps(value); return function(value){
} setClassPresence(element, cls, !! value)
else if (k == "showsauthorcolors") }
{ };
setClassPresence(root, "authorColors", !! value);
} // These properties are exposed
else if (k == "showsuserselections") var setters = {
{ wraps: setWraps,
setClassPresence(root, "userSelections", !! value); showsauthorcolors: setClassPresenceNamed(root, "authorColors"),
} showsuserselections: setClassPresenceNamed(root, "userSelections"),
else if (k == "showslinenumbers") showslinenumbers : function(value){
{ hasLineNumbers = !! value;
hasLineNumbers = !! value; // disable line numbers on mobile devices
// disable line numbers on mobile devices if (browser.mobile) hasLineNumbers = false;
if (browser.mobile) hasLineNumbers = false; setClassPresence(sideDiv, "sidedivhidden", !hasLineNumbers);
setClassPresence(sideDiv, "sidedivhidden", !hasLineNumbers); fixView();
fixView(); },
} grayedout: setClassPresenceNamed(outerWin.document.body, "grayedout"),
else if (k == "grayedout") dmesg: function(){ dmesg = window.dmesg = value; },
{ userauthor: function(value){ thisAuthor = String(value); },
setClassPresence(outerWin.document.body, "grayedout", !! value); styled: setStyled,
} textface: setTextFace,
else if (k == "dmesg") textsize: setTextSize,
{ rtlistrue: setClassPresenceNamed(root, "rtl")
dmesg = value; };
window.dmesg = value;
} var setter = setters[key.toLowerCase()];
else if (k == 'userauthor')
{ // check if setter is present
thisAuthor = String(value); if(setter !== undefined){
} setter(value)
else if (k == 'styled')
{
setStyled(value);
}
else if (k == 'textface')
{
setTextFace(value);
}
else if (k == 'textsize')
{
setTextSize(value);
}
else if (k == 'rtlistrue')
{
setClassPresence(root, "rtl", !! value);
} }
} }