mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
pad_editbar: Use this
instead of self
This commit is contained in:
parent
118c66e5d0
commit
bdaa66c346
1 changed files with 23 additions and 26 deletions
|
@ -64,17 +64,15 @@ ToolbarItem.prototype.isButton = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
ToolbarItem.prototype.bind = function (callback) {
|
ToolbarItem.prototype.bind = function (callback) {
|
||||||
const self = this;
|
if (this.isButton()) {
|
||||||
|
this.$el.click((event) => {
|
||||||
if (self.isButton()) {
|
|
||||||
self.$el.click((event) => {
|
|
||||||
$(':focus').blur();
|
$(':focus').blur();
|
||||||
callback(self.getCommand(), self);
|
callback(this.getCommand(), this);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
} else if (self.isSelect()) {
|
} else if (this.isSelect()) {
|
||||||
self.$el.find('select').change(() => {
|
this.$el.find('select').change(() => {
|
||||||
callback(self.getCommand(), self);
|
callback(this.getCommand(), this);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -129,15 +127,14 @@ const padeditbar = (function () {
|
||||||
|
|
||||||
const self = {
|
const self = {
|
||||||
init() {
|
init() {
|
||||||
const self = this;
|
this.dropdowns = [];
|
||||||
self.dropdowns = [];
|
|
||||||
|
|
||||||
$('#editbar .editbarbutton').attr('unselectable', 'on'); // for IE
|
$('#editbar .editbarbutton').attr('unselectable', 'on'); // for IE
|
||||||
this.enable();
|
this.enable();
|
||||||
$('#editbar [data-key]').each(function () {
|
$('#editbar [data-key]').each((i, elt) => {
|
||||||
$(this).unbind('click');
|
$(elt).unbind('click');
|
||||||
(new ToolbarItem($(this))).bind((command, item) => {
|
new ToolbarItem($(elt)).bind((command, item) => {
|
||||||
self.triggerCommand(command, item);
|
this.triggerCommand(command, item);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -148,13 +145,13 @@ const padeditbar = (function () {
|
||||||
$('.show-more-icon-btn').click(() => {
|
$('.show-more-icon-btn').click(() => {
|
||||||
$('.toolbar').toggleClass('full-icons');
|
$('.toolbar').toggleClass('full-icons');
|
||||||
});
|
});
|
||||||
self.checkAllIconsAreDisplayedInToolbar();
|
this.checkAllIconsAreDisplayedInToolbar();
|
||||||
$(window).resize(_.debounce(self.checkAllIconsAreDisplayedInToolbar, 100));
|
$(window).resize(_.debounce(() => this.checkAllIconsAreDisplayedInToolbar(), 100));
|
||||||
|
|
||||||
registerDefaultCommands(self);
|
registerDefaultCommands(this);
|
||||||
|
|
||||||
hooks.callAll('postToolbarInit', {
|
hooks.callAll('postToolbarInit', {
|
||||||
toolbar: self,
|
toolbar: this,
|
||||||
ace: padeditor.ace,
|
ace: padeditor.ace,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -187,9 +184,9 @@ const padeditbar = (function () {
|
||||||
},
|
},
|
||||||
registerDropdownCommand(cmd, dropdown) {
|
registerDropdownCommand(cmd, dropdown) {
|
||||||
dropdown = dropdown || cmd;
|
dropdown = dropdown || cmd;
|
||||||
self.dropdowns.push(dropdown);
|
this.dropdowns.push(dropdown);
|
||||||
this.registerCommand(cmd, () => {
|
this.registerCommand(cmd, () => {
|
||||||
self.toggleDropDown(dropdown);
|
this.toggleDropDown(dropdown);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
registerAceCommand(cmd, callback) {
|
registerAceCommand(cmd, callback) {
|
||||||
|
@ -200,12 +197,12 @@ const padeditbar = (function () {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
triggerCommand(cmd, item) {
|
triggerCommand(cmd, item) {
|
||||||
if (self.isEnabled() && this.commands[cmd]) {
|
if (this.isEnabled() && this.commands[cmd]) {
|
||||||
this.commands[cmd](cmd, padeditor.ace, item);
|
this.commands[cmd](cmd, padeditor.ace, item);
|
||||||
}
|
}
|
||||||
if (padeditor.ace) padeditor.ace.focus();
|
if (padeditor.ace) padeditor.ace.focus();
|
||||||
},
|
},
|
||||||
toggleDropDown: (moduleName, cb) => {
|
toggleDropDown(moduleName, cb) {
|
||||||
// do nothing if users are sticked
|
// do nothing if users are sticked
|
||||||
if (moduleName === 'users' && $('#users').hasClass('stickyUsers')) {
|
if (moduleName === 'users' && $('#users').hasClass('stickyUsers')) {
|
||||||
return;
|
return;
|
||||||
|
@ -217,8 +214,8 @@ const padeditbar = (function () {
|
||||||
// hide all modules and remove highlighting of all buttons
|
// hide all modules and remove highlighting of all buttons
|
||||||
if (moduleName === 'none') {
|
if (moduleName === 'none') {
|
||||||
const returned = false;
|
const returned = false;
|
||||||
for (let i = 0; i < self.dropdowns.length; i++) {
|
for (let i = 0; i < this.dropdowns.length; i++) {
|
||||||
const thisModuleName = self.dropdowns[i];
|
const thisModuleName = this.dropdowns[i];
|
||||||
|
|
||||||
// skip the userlist
|
// skip the userlist
|
||||||
if (thisModuleName === 'users') continue;
|
if (thisModuleName === 'users') continue;
|
||||||
|
@ -238,8 +235,8 @@ const padeditbar = (function () {
|
||||||
} else {
|
} else {
|
||||||
// hide all modules that are not selected and remove highlighting
|
// hide all modules that are not selected and remove highlighting
|
||||||
// respectively add highlighting to the corresponding button
|
// respectively add highlighting to the corresponding button
|
||||||
for (let i = 0; i < self.dropdowns.length; i++) {
|
for (let i = 0; i < this.dropdowns.length; i++) {
|
||||||
const thisModuleName = self.dropdowns[i];
|
const thisModuleName = this.dropdowns[i];
|
||||||
const module = $(`#${thisModuleName}`);
|
const module = $(`#${thisModuleName}`);
|
||||||
|
|
||||||
if (module.hasClass('popup-show')) {
|
if (module.hasClass('popup-show')) {
|
||||||
|
|
Loading…
Reference in a new issue