refactor(edit) show: rm cssMode, add ifExec

This commit is contained in:
coderaiser 2014-04-01 09:42:20 -04:00
parent a0a579b84d
commit 4fc31d89a9

View file

@ -32,9 +32,10 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
]);
}
this.show = function(pValue) {
var lMode, htmlMode, cssMode, url,
lName = Info.name,
this.show = function(value) {
var mode, htmlMode, isHTML,
isStr = Util.isString(value),
name = Info.name,
isDir = Info.isDir,
lExt = Info.ext;
@ -48,7 +49,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
'width : 100%;' +
'height : 100%;' +
'font : 16px "Droid Sans Mono";' +
'position: absolute;',
'position : absolute;',
not_append : true
});
@ -56,18 +57,23 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
}
if (isDir)
lMode = Modelist.modesByName.json.mode;
mode = Modelist.modesByName.json.mode;
else
lMode = Modelist.getModeForPath(lName).mode;
mode = Modelist.getModeForPath(name).mode;
htmlMode = Modelist.modesByName.html.mode;
cssMode = Modelist.modesByName.css.mode;
htmlMode = Modelist.modesByName.html.mode;
isHTML = mode === htmlMode;
Session.setMode(lMode);
Session.setMode(mode);
if (lMode === htmlMode) {
Util.ifExec(Emmet, function() {
if (Emmet)
Ace.setOption('enableEmmet', true);
Ace.setOption('enableEmmet', isHTML);
}, function(callback) {
var url;
if (!isHTML)
Util.exec(callback);
else {
url = CloudFunc.getJoinURL([
DIR + 'emmet.js',
@ -77,15 +83,13 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip;
DOM.jsload(url, function() {
Emmet = ace.require('ace/ext/emmet');
Emmet.setCore(window.emmet);
Ace.setOption('enableEmmet', true);
Util.exec(callback);
});
}
} else if (Emmet) {
Ace.setOption('enableEmmet', false);
}
});
if (Util.isString(pValue)) {
Ace.setValue(pValue);
if (isStr) {
Ace.setValue(value);
CloudCmd.View.show(Element, focus);
Key.unsetBind();
} else