mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 11:22:41 +01:00
passing the ToolbarItem to the callback
This commit is contained in:
parent
0c52fb5e30
commit
602380abb7
2 changed files with 16 additions and 8 deletions
|
@ -138,10 +138,10 @@ _.extend(SelectButton.prototype, Button.prototype, {
|
||||||
render: function () {
|
render: function () {
|
||||||
var attributes = {
|
var attributes = {
|
||||||
id: this.attributes.id,
|
id: this.attributes.id,
|
||||||
"data-key": "",
|
"data-key": this.attributes.command,
|
||||||
"data-type": "select"
|
"data-type": "select"
|
||||||
};
|
};
|
||||||
return this.li(attributes,
|
return tag("li", attributes,
|
||||||
this.select({ id: this.attributes.selectId })
|
this.select({ id: this.attributes.selectId })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,13 @@ ToolbarItem.prototype.getValue = function () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ToolbarItem.prototype.setValue = function (val) {
|
||||||
|
if (this.isSelect()) {
|
||||||
|
return this.$el.find("select").val(val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
ToolbarItem.prototype.getType = function () {
|
ToolbarItem.prototype.getType = function () {
|
||||||
return this.$el.attr("data-type");
|
return this.$el.attr("data-type");
|
||||||
};
|
};
|
||||||
|
@ -53,15 +60,16 @@ ToolbarItem.prototype.isButton = function () {
|
||||||
|
|
||||||
ToolbarItem.prototype.bind = function (callback) {
|
ToolbarItem.prototype.bind = function (callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (self.isButton()) {
|
if (self.isButton()) {
|
||||||
self.$el.click(function (event) {
|
self.$el.click(function (event) {
|
||||||
callback(self.getCommand());
|
callback(self.getCommand(), self);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (self.isSelect()) {
|
else if (self.isSelect()) {
|
||||||
self.$el.find("select").change(function () {
|
self.$el.find("select").change(function () {
|
||||||
callback(self.getCommand(), self.getValue());
|
callback(self.getCommand(), self);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -134,8 +142,8 @@ var padeditbar = (function()
|
||||||
$("#editbar .editbarbutton").attr("unselectable", "on"); // for IE
|
$("#editbar .editbarbutton").attr("unselectable", "on"); // for IE
|
||||||
$("#editbar").removeClass("disabledtoolbar").addClass("enabledtoolbar");
|
$("#editbar").removeClass("disabledtoolbar").addClass("enabledtoolbar");
|
||||||
$("#editbar [data-key]").each(function () {
|
$("#editbar [data-key]").each(function () {
|
||||||
(new ToolbarItem($(this))).bind(function (command, value) {
|
(new ToolbarItem($(this))).bind(function (command, item) {
|
||||||
self.triggerCommand(command, value);
|
self.triggerCommand(command, item);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -173,9 +181,9 @@ var padeditbar = (function()
|
||||||
}, cmd, true);
|
}, cmd, true);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
triggerCommand: function (cmd, value) {
|
triggerCommand: function (cmd, item) {
|
||||||
if (self.isEnabled() && this.commands[cmd]) {
|
if (self.isEnabled() && this.commands[cmd]) {
|
||||||
this.commands[cmd](cmd, padeditor.ace, value);
|
this.commands[cmd](cmd, padeditor.ace, item);
|
||||||
}
|
}
|
||||||
if(padeditor.ace) padeditor.ace.focus();
|
if(padeditor.ace) padeditor.ace.focus();
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue