some cleanup and better scoping.

This commit is contained in:
cohitre 2012-06-21 21:24:27 -07:00
parent 5328871ba6
commit d939fd1ef4

View file

@ -1,7 +1,6 @@
var _ = require('ep_etherpad-lite/static/js/underscore') var _ = require('ep_etherpad-lite/static/js/underscore')._
, padeditor = require('ep_etherpad-lite/static/js/pad_editor').padeditor , padeditor = require('ep_etherpad-lite/static/js/pad_editor').padeditor
, padeditbar = require('ep_etherpad-lite/static/js/pad_editbar').padeditbar , padeditbar = require('ep_etherpad-lite/static/js/pad_editbar').padeditbar;
, simpleCommands = ["bold", "italic", "underline", "strikethrough"];
function registerCallWithAceCommand(commandName, callback) { function registerCallWithAceCommand(commandName, callback) {
padeditbar.registerToolbarCommand(commandName, function () { padeditbar.registerToolbarCommand(commandName, function () {
@ -10,13 +9,16 @@ function registerCallWithAceCommand(commandName, callback) {
} }
exports.postAceInit = function () { exports.postAceInit = function () {
var simpleCommands = ["bold", "italic", "underline", "strikethrough"]
, undoRedoCommands = ["undo", "redo"];
_.each(simpleCommands, function (commandName) { _.each(simpleCommands, function (commandName) {
registerCallWithAceCommand(commandName, function (ace) { registerCallWithAceCommand(commandName, function (ace) {
ace.ace_toggleAttributeOnSelection(commandName) ace.ace_toggleAttributeOnSelection(commandName)
}); });
}); });
_.each(["undo", "redo"], function (commandName) { _.each(undoRedoCommands, function (commandName) {
registerCallWithAceCommand(commandName, function (ace) { registerCallWithAceCommand(commandName, function (ace) {
ace.ace_doUndoRedo(commandName); ace.ace_doUndoRedo(commandName);
}); });