update code formatting, and general cleanup

This commit is contained in:
nightwing 2013-04-13 23:00:37 +04:00
commit 5894667b41
19 changed files with 1166 additions and 1237 deletions

View file

@ -44,9 +44,10 @@ function bindKey(win, mac) {
exports.commands = [{ exports.commands = [{
name: "showSettingsMenu", name: "showSettingsMenu",
bindKey: bindKey("Ctrl-,", "Command-,"), bindKey: bindKey("Ctrl-,", "Command-,"),
exec: function (editor) { exec: function(editor) {
config.loadModule("ace/ext/show_keyboard_shortcuts", function (e) { config.loadModule("ace/ext/settings_menu", function(module) {
e(editor); module.init(editor);
editor.showSettingsMenu();
}); });
}, },
readOnly: true readOnly: true

View file

@ -117,7 +117,7 @@ var ElasticTabstopsLite = function(editor) {
// todo: support multicursor // todo: support multicursor
var tabs = [-1].concat(this.$tabsForRow(row)); var tabs = [-1].concat(this.$tabsForRow(row));
var widths = tabs.map(function (el) { return 0; } ).slice(1); var widths = tabs.map(function(el) { return 0; } ).slice(1);
var line = this.$editor.session.getLine(row); var line = this.$editor.session.getLine(row);
for (var i = 0, len = tabs.length - 1; i < len; i++) { for (var i = 0, len = tabs.length - 1; i < len; i++) {

View file

@ -30,17 +30,8 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
/*jslint /*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/
indent: 4, /*global define, require */
maxerr: 50,
white: true,
browser: true,
vars: true
*/
/*global
define,
require
*/
/** /**
* Show Keyboard Shortcuts * Show Keyboard Shortcuts
@ -68,7 +59,7 @@ define(function(require, exports, module) {
var getEditorKeybordShortcuts = require('./menu_tools/get_editor_keyboard_shortcuts').getEditorKeybordShortcuts; var getEditorKeybordShortcuts = require('./menu_tools/get_editor_keyboard_shortcuts').getEditorKeybordShortcuts;
var kb = getEditorKeybordShortcuts(editor); var kb = getEditorKeybordShortcuts(editor);
var el = document.createElement('div'); var el = document.createElement('div');
var commands = kb.reduce(function (previous, current) { var commands = kb.reduce(function(previous, current) {
return previous + '<div><b>' + current.command + '</b> : ' + return previous + '<div><b>' + current.command + '</b> : ' +
current.key + '</div>'; current.key + '</div>';
}, ''); }, '');
@ -79,8 +70,8 @@ define(function(require, exports, module) {
overlayPage(editor, el, '0', '0', '0', null); overlayPage(editor, el, '0', '0', '0', null);
} }
}; };
module.exports.init = function (editor) { module.exports.init = function(editor) {
Editor.prototype.showKeyboardShortcuts = function () { Editor.prototype.showKeyboardShortcuts = function() {
showKeyboardShortcuts(this); showKeyboardShortcuts(this);
}; };
editor.commands.addCommands([{ editor.commands.addCommands([{

View file

@ -30,17 +30,8 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
/*jslint /*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/
indent: 4, /*global define, require */
maxerr: 50,
white: true,
browser: true,
vars: true
*/
/*global
define,
require
*/
/** /**
* Add Editor Menu Options * Add Editor Menu Options
@ -84,14 +75,14 @@ module.exports.addEditorMenuOptions = function addEditorMenuOptions (editor) {
"setMode" : [] "setMode" : []
}; };
editor.menuOptions.setTheme = themelist.themes.map(function (theme) { editor.menuOptions.setTheme = themelist.themes.map(function(theme) {
return { return {
'textContent' : theme.desc, 'textContent' : theme.desc,
'value' : theme.theme 'value' : theme.theme
}; };
}); });
editor.menuOptions.setMode = modelist.modes.map(function (mode) { editor.menuOptions.setMode = modelist.modes.map(function(mode) {
return { return {
'textContent' : mode.name, 'textContent' : mode.name,
'value' : mode.mode 'value' : mode.mode

View file

@ -30,17 +30,8 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
/*jslint /*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/
indent: 4, /*global define, require */
maxerr: 50,
white: true,
browser: true,
vars: true
*/
/*global
define,
require
*/
/** /**
* Element Generator * Element Generator
@ -148,7 +139,7 @@ module.exports.createSelection = function createSelection (id, values, clss) {
el.setAttribute('id', id); el.setAttribute('id', id);
el.setAttribute('name', id); el.setAttribute('name', id);
el.setAttribute('class', clss); el.setAttribute('class', clss);
values.forEach(function (item) { values.forEach(function(item) {
el.appendChild(module.exports.createOption(item)); el.appendChild(module.exports.createOption(item));
}); });
return el; return el;

View file

@ -78,7 +78,7 @@ module.exports.generateSettingsMenu = function generateSettingsMenu (editor) {
* ☭ Hial Atropa!! ☭ * ☭ Hial Atropa!! ☭
*/ */
function cleanupElementsList() { function cleanupElementsList() {
elements.sort(function (a, b) { elements.sort(function(a, b) {
var x = a.getAttribute('contains'); var x = a.getAttribute('contains');
var y = b.getAttribute('contains'); var y = b.getAttribute('contains');
return x.localeCompare(y); return x.localeCompare(y);
@ -94,7 +94,7 @@ module.exports.generateSettingsMenu = function generateSettingsMenu (editor) {
function wrapElements() { function wrapElements() {
var topmenu = document.createElement('div'); var topmenu = document.createElement('div');
topmenu.setAttribute('id', 'settingsmenu'); topmenu.setAttribute('id', 'settingsmenu');
elements.forEach(function (element) { elements.forEach(function(element) {
topmenu.appendChild(element); topmenu.appendChild(element);
}); });
return topmenu; return topmenu;
@ -135,9 +135,9 @@ module.exports.generateSettingsMenu = function generateSettingsMenu (editor) {
if(Array.isArray(val)) { if(Array.isArray(val)) {
el = egen.createSelection(item, val, clss); el = egen.createSelection(item, val, clss);
el.addEventListener('change', function (e) { el.addEventListener('change', function(e) {
try{ try{
editor.menuOptions[e.target.id].forEach(function (x) { editor.menuOptions[e.target.id].forEach(function(x) {
if(x.textContent !== e.target.textContent) { if(x.textContent !== e.target.textContent) {
delete x.selected; delete x.selected;
} }
@ -150,7 +150,7 @@ module.exports.generateSettingsMenu = function generateSettingsMenu (editor) {
}); });
} else if(typeof val === 'boolean') { } else if(typeof val === 'boolean') {
el = egen.createCheckbox(item, val, clss); el = egen.createCheckbox(item, val, clss);
el.addEventListener('change', function (e) { el.addEventListener('change', function(e) {
try{ try{
// renderer['setHighlightGutterLine'](true); // renderer['setHighlightGutterLine'](true);
obj[e.target.id](!!e.target.checked); obj[e.target.id](!!e.target.checked);
@ -163,7 +163,7 @@ module.exports.generateSettingsMenu = function generateSettingsMenu (editor) {
// post and get requests. // post and get requests.
// /ace_editor.html?setMode=ace/mode/html&setOverwrite=true // /ace_editor.html?setMode=ace/mode/html&setOverwrite=true
el = egen.createInput(item, val, clss); el = egen.createInput(item, val, clss);
el.addEventListener('blur', function (e) { el.addEventListener('blur', function(e) {
try{ try{
if(e.target.value === 'true') { if(e.target.value === 'true') {
obj[e.target.id](true); obj[e.target.id](true);
@ -197,7 +197,7 @@ module.exports.generateSettingsMenu = function generateSettingsMenu (editor) {
*/ */
function makeDropdown(item, esr, clss, fn) { function makeDropdown(item, esr, clss, fn) {
var val = editor.menuOptions[item]; var val = editor.menuOptions[item];
val = val.map(function (valuex) { val = val.map(function(valuex) {
if(valuex.value === esr[fn]()) { if(valuex.value === esr[fn]()) {
valuex.selected = 'selected'; valuex.selected = 'selected';
} else if(valuex.value === esr.$modeId) { } else if(valuex.value === esr.$modeId) {
@ -258,7 +258,7 @@ module.exports.generateSettingsMenu = function generateSettingsMenu (editor) {
} }
addEditorMenuOptions(editor); addEditorMenuOptions(editor);
// gather the set functions // gather the set functions
getSetFunctions(editor).forEach(function (setObj) { getSetFunctions(editor).forEach(function(setObj) {
// populate the elements array with good stuff. // populate the elements array with good stuff.
handleSet(setObj); handleSet(setObj);
}); });

View file

@ -30,17 +30,8 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
/*jslint /*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/
indent: 4, /*global define, require */
maxerr: 50,
white: true,
browser: true,
vars: true
*/
/*global
define,
require
*/
/** /**
* Get Editor Keyboard Shortcuts * Get Editor Keyboard Shortcuts

View file

@ -131,7 +131,7 @@ module.exports.getSetFunctions = function getSetFunctions (editor) {
'renderer', 'renderer',
'session', 'session',
'editor' 'editor'
].forEach(function (esra) { ].forEach(function(esra) {
var fn; var fn;
var esr = my[esra]; var esr = my[esra];
var clss = esra; var clss = esra;

View file

@ -30,17 +30,8 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
/*jslint /*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/
indent: 4, /*global define, require */
maxerr: 50,
white: true,
browser: true,
vars: true
*/
/*global
define,
require
*/
/** /**
* Overlay Page * Overlay Page
@ -87,7 +78,7 @@ module.exports.overlayPage = function overlayPage (editor, contentElement, top,
'position: fixed; top:0; bottom:0; left:0; right:0;' + 'position: fixed; top:0; bottom:0; left:0; right:0;' +
'z-index: 9990; ' + 'z-index: 9990; ' +
'background-color: rgba(0, 0, 0, 0.2);'; 'background-color: rgba(0, 0, 0, 0.2);';
closer.addEventListener('click', function () { closer.addEventListener('click', function() {
document.removeEventListener('keydown', documentEscListener); document.removeEventListener('keydown', documentEscListener);
closer.parentNode.removeChild(closer); closer.parentNode.removeChild(closer);
editor.focus(); editor.focus();
@ -103,7 +94,7 @@ module.exports.overlayPage = function overlayPage (editor, contentElement, top,
'box-shadow: rgba(126, 126, 126, 0.25) -20px 10px 25px; ' + 'box-shadow: rgba(126, 126, 126, 0.25) -20px 10px 25px; ' +
'background-color: rgba(255, 255, 255, 0.6);' + 'background-color: rgba(255, 255, 255, 0.6);' +
'color: black; overflow: auto;'; 'color: black; overflow: auto;';
contentContainer.addEventListener('click', function (e) { contentContainer.addEventListener('click', function(e) {
e.stopPropagation(); e.stopPropagation();
}); });

View file

@ -224,7 +224,7 @@ var SearchBox = function(editor, range, showReplaceForm) {
this.editor.replaceAll(this.replaceInput.value); this.editor.replaceAll(this.replaceInput.value);
}; };
this.hide = function () { this.hide = function() {
this.element.style.display = "none"; this.element.style.display = "none";
this.editor.keyBinding.removeKeyboardHandler(this.$closeSearchBarKb); this.editor.keyBinding.removeKeyboardHandler(this.$closeSearchBarKb);
this.editor.focus(); this.editor.focus();

View file

@ -30,18 +30,8 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
/*jslint /*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/
indent: 4, /*global define, require */
maxerr: 50,
white: true,
browser: true,
vars: true
*/
/*global
define,
require,
getComputedStyle
*/
/** /**
* Show Settings Menu * Show Settings Menu
@ -77,18 +67,10 @@ define(function(require, exports, module) {
* to the editor with appropriate keyboard shortcuts. * to the editor with appropriate keyboard shortcuts.
* @param {ace.Editor} editor An instance of the Editor. * @param {ace.Editor} editor An instance of the Editor.
*/ */
module.exports.init = function (editor) { module.exports.init = function(editor) {
var Editor = require("ace/editor").Editor; var Editor = require("ace/editor").Editor;
Editor.prototype.showSettingsMenu = function () { Editor.prototype.showSettingsMenu = function() {
showSettingsMenu(this); showSettingsMenu(this);
}; };
editor.commands.addCommands([{
name: "showSettingsMenu",
bindKey: {win: "Ctrl-q", mac: "Command-q"},
exec: function(editor, line) {
editor.showSettingsMenu();
},
readOnly: true
}]);
}; };
}); });

View file

@ -62,7 +62,7 @@ exports.render = function(input, mode, theme, lineStart, disableGutter, callback
// then we need to lazily load them. // then we need to lazily load them.
if (typeof theme == "string") { if (typeof theme == "string") {
waiting++; waiting++;
config.loadModule(['theme', theme], function (m) { config.loadModule(['theme', theme], function(m) {
theme = m; theme = m;
--waiting || done(); --waiting || done();
}); });
@ -70,7 +70,7 @@ exports.render = function(input, mode, theme, lineStart, disableGutter, callback
if (typeof mode == "string") { if (typeof mode == "string") {
waiting++; waiting++;
config.loadModule(['mode', mode], function (m) { config.loadModule(['mode', mode], function(m) {
mode = new m.Mode() mode = new m.Mode()
--waiting || done(); --waiting || done();
}); });

View file

@ -50,7 +50,7 @@ function hello (a, b, c) {\n\
next(); next();
}, },
"test theme classname should be in output html": function (next) { "test theme classname should be in output html": function(next) {
var theme = require("../theme/tomorrow"); var theme = require("../theme/tomorrow");
var snippet = "\ var snippet = "\
/** this is a function\n\ /** this is a function\n\

View file

@ -30,17 +30,8 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
/*jslint /*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/
indent: 4, /*global define, require */
maxerr: 50,
white: true,
browser: true,
vars: true
*/
/*global
define,
require
*/
/** /**
* Generates a list of themes available when ace was built. * Generates a list of themes available when ace was built.
@ -70,7 +61,7 @@ module.exports.ThemeDescription = function(name) {
this.name = name; this.name = name;
this.desc = name.split('_' this.desc = name.split('_'
).map( ).map(
function (namePart) { function(namePart) {
return namePart[0].toUpperCase() + namePart.slice(1); return namePart[0].toUpperCase() + namePart.slice(1);
} }
).join(' '); ).join(' ');
@ -79,7 +70,7 @@ module.exports.ThemeDescription = function(name) {
module.exports.themesByName = {}; module.exports.themesByName = {};
module.exports.themes = module.exports.themes.map(function (name) { module.exports.themes = module.exports.themes.map(function(name) {
module.exports.themesByName[name] = new module.exports.ThemeDescription(name); module.exports.themesByName[name] = new module.exports.ThemeDescription(name);
return module.exports.themesByName[name]; return module.exports.themesByName[name];
}); });