Fix code styles

This commit is contained in:
Cheng-Han, Wu 2016-04-24 12:30:16 +08:00
parent 0bb3e53d58
commit efb188c9c1

View file

@ -4,9 +4,9 @@ var defaultExtraKeys = {
"F10": function (cm) { "F10": function (cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen")); cm.setOption("fullScreen", !cm.getOption("fullScreen"));
}, },
"Esc": function(cm) { "Esc": function (cm) {
if (cm.getOption('keyMap').substr(0, 3) === 'vim') return CodeMirror.Pass; if (cm.getOption('keyMap').substr(0, 3) === 'vim') return CodeMirror.Pass;
else if(cm.getOption("fullScreen")) cm.setOption("fullScreen", false); else if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
}, },
"Cmd-S": function () { "Cmd-S": function () {
return CodeMirror.Pass return CodeMirror.Pass
@ -15,7 +15,7 @@ var defaultExtraKeys = {
return CodeMirror.Pass return CodeMirror.Pass
}, },
"Enter": "newlineAndIndentContinueMarkdownList", "Enter": "newlineAndIndentContinueMarkdownList",
"Tab": function(cm) { "Tab": function (cm) {
var tab = '\t'; var tab = '\t';
var spaces = Array(parseInt(cm.getOption("indentUnit")) + 1).join(" "); var spaces = Array(parseInt(cm.getOption("indentUnit")) + 1).join(" ");
//auto indent whole line when in list or blockquote //auto indent whole line when in list or blockquote
@ -370,7 +370,7 @@ function setIndent() {
} }
setUnit(); setUnit();
type.click(function() { type.click(function () {
if (editor.getOption('indentWithTabs')) { if (editor.getOption('indentWithTabs')) {
editor.setOption('indentWithTabs', false); editor.setOption('indentWithTabs', false);
cookieSpaceUnits = parseInt(Cookies.get('space_units')); cookieSpaceUnits = parseInt(Cookies.get('space_units'));
@ -387,7 +387,7 @@ function setIndent() {
setType(); setType();
setUnit(); setUnit();
}); });
widthLabel.click(function() { widthLabel.click(function () {
if (widthLabel.is(':visible')) { if (widthLabel.is(':visible')) {
widthLabel.addClass('hidden'); widthLabel.addClass('hidden');
widthInput.removeClass('hidden'); widthInput.removeClass('hidden');
@ -398,7 +398,7 @@ function setIndent() {
widthInput.addClass('hidden'); widthInput.addClass('hidden');
} }
}); });
widthInput.on('change', function() { widthInput.on('change', function () {
var val = parseInt(widthInput.val()); var val = parseInt(widthInput.val());
if (!val) val = editor.getOption('indentUnit'); if (!val) val = editor.getOption('indentUnit');
if (val < 1) val = 1; if (val < 1) val = 1;
@ -410,7 +410,7 @@ function setIndent() {
editor.setOption('indentUnit', val); editor.setOption('indentUnit', val);
setUnit(); setUnit();
}); });
widthInput.on('blur', function() { widthInput.on('blur', function () {
widthLabel.removeClass('hidden'); widthLabel.removeClass('hidden');
widthInput.addClass('hidden'); widthInput.addClass('hidden');
}); });
@ -435,15 +435,15 @@ function setKeymap() {
} }
setKeymapLabel(); setKeymapLabel();
sublime.click(function() { sublime.click(function () {
editor.setOption('keyMap', 'sublime'); editor.setOption('keyMap', 'sublime');
setKeymapLabel(); setKeymapLabel();
}); });
emacs.click(function() { emacs.click(function () {
editor.setOption('keyMap', 'emacs'); editor.setOption('keyMap', 'emacs');
setKeymapLabel(); setKeymapLabel();
}); });
vim.click(function() { vim.click(function () {
editor.setOption('keyMap', 'vim'); editor.setOption('keyMap', 'vim');
setKeymapLabel(); setKeymapLabel();
}); });
@ -1096,12 +1096,12 @@ function uploadToGoogleDrive(accessToken) {
var uploader = new MediaUploader({ var uploader = new MediaUploader({
file: blob, file: blob,
token: accessToken, token: accessToken,
onComplete: function(data) { onComplete: function (data) {
data = JSON.parse(data); data = JSON.parse(data);
showMessageModal('<i class="fa fa-cloud-upload"></i> Export to Google Drive', 'Export Complete!', data.alternateLink, 'Click here to view your file', true); showMessageModal('<i class="fa fa-cloud-upload"></i> Export to Google Drive', 'Export Complete!', data.alternateLink, 'Click here to view your file', true);
ui.spinner.hide(); ui.spinner.hide();
}, },
onError: function(data) { onError: function (data) {
var modal = $('.export-modal'); var modal = $('.export-modal');
showMessageModal('<i class="fa fa-cloud-upload"></i> Export to Google Drive', 'Export Error :(', '', data, false); showMessageModal('<i class="fa fa-cloud-upload"></i> Export to Google Drive', 'Export Error :(', '', data, false);
ui.spinner.hide(); ui.spinner.hide();
@ -1115,7 +1115,7 @@ function googleApiAuth(immediate, callback) {
'client_id': GOOGLE_CLIENT_ID, 'client_id': GOOGLE_CLIENT_ID,
'scope': 'https://www.googleapis.com/auth/drive.file', 'scope': 'https://www.googleapis.com/auth/drive.file',
'immediate': immediate 'immediate': immediate
}, callback ? callback : function() {}); }, callback ? callback : function () { });
} }
function onGoogleClientLoaded() { function onGoogleClientLoaded() {
googleApiAuth(true); googleApiAuth(true);
@ -1127,7 +1127,7 @@ ui.toolbar.export.googleDrive.click(function (e) {
if (token) { if (token) {
uploadToGoogleDrive(token.access_token); uploadToGoogleDrive(token.access_token);
} else { } else {
googleApiAuth(false, function(result) { googleApiAuth(false, function (result) {
uploadToGoogleDrive(result.access_token); uploadToGoogleDrive(result.access_token);
}); });
} }
@ -1155,18 +1155,17 @@ function buildImportFromGoogleDrive() {
apiKey: GOOGLE_API_KEY, apiKey: GOOGLE_API_KEY,
clientId: GOOGLE_CLIENT_ID, clientId: GOOGLE_CLIENT_ID,
buttonEl: ui.toolbar.import.googleDrive, buttonEl: ui.toolbar.import.googleDrive,
onSelect: function(file) { onSelect: function (file) {
if (file.downloadUrl) { if (file.downloadUrl) {
ui.spinner.show(); ui.spinner.show();
var accessToken = gapi.auth.getToken().access_token; var accessToken = gapi.auth.getToken().access_token;
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
beforeSend: function (request) beforeSend: function (request) {
{
request.setRequestHeader('Authorization', 'Bearer ' + accessToken); request.setRequestHeader('Authorization', 'Bearer ' + accessToken);
}, },
url: file.downloadUrl, url: file.downloadUrl,
success: function(data) { success: function (data) {
if (file.fileExtension == 'html') if (file.fileExtension == 'html')
parseToEditor(data); parseToEditor(data);
else else
@ -1278,8 +1277,8 @@ function updateScrollspy() {
function applyScrollspyActive(top, headerMap, headers, target, offset) { function applyScrollspyActive(top, headerMap, headers, target, offset) {
var index = 0; var index = 0;
for(var i = headerMap.length - 1; i >= 0; i--) { for (var i = headerMap.length - 1; i >= 0; i--) {
if(top >= (headerMap[i] + offset) && headerMap[i + 1] && top < (headerMap[i + 1] + offset)) { if (top >= (headerMap[i] + offset) && headerMap[i + 1] && top < (headerMap[i + 1] + offset)) {
index = i; index = i;
break; break;
} }
@ -2199,10 +2198,10 @@ editor.on('beforeChange', function (cm, change) {
if (cmClient && !socket.connected) if (cmClient && !socket.connected)
cmClient.editorAdapter.ignoreNextChange = true; cmClient.editorAdapter.ignoreNextChange = true;
}); });
editor.on('cut', function() { editor.on('cut', function () {
windowResize(); //workaround for scrollMap windowResize(); //workaround for scrollMap
}); });
editor.on('paste', function() { editor.on('paste', function () {
windowResize(); //workaround for scrollMap windowResize(); //workaround for scrollMap
}); });
editor.on('changes', function (cm, changes) { editor.on('changes', function (cm, changes) {
@ -2889,7 +2888,7 @@ $(editor.getInputField())
return !isInCode; return !isInCode;
} }
} }
], { ], {
appendTo: $('.cursor-menu') appendTo: $('.cursor-menu')
}) })
.on({ .on({