mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Custom buttons
This commit is contained in:
parent
fbb7dd4c3f
commit
60c8a2c598
@ -67,24 +67,53 @@
|
||||
this.topContainer.addClass(this.options.class);
|
||||
}
|
||||
|
||||
var buttons = this.options.buttons || [];
|
||||
|
||||
if (this.options.addButton !== false) {
|
||||
var addLabel;
|
||||
var addLabel, addTittle;
|
||||
if (typeof this.options.addButton === 'string') {
|
||||
addLabel = this.options.addButton
|
||||
} else {
|
||||
if (RED && RED._) {
|
||||
addLabel = RED._("editableList.add");
|
||||
addTitle = RED._("editableList.addTitle");
|
||||
} else {
|
||||
addLabel = 'add';
|
||||
addTitle = 'add new item';
|
||||
}
|
||||
}
|
||||
$('<a href="#" class="red-ui-button red-ui-button-small red-ui-editableList-addButton" style="margin-top: 4px;"><i class="fa fa-plus"></i> '+addLabel+'</a>')
|
||||
.appendTo(this.topContainer)
|
||||
buttons.unshift({
|
||||
label: addLabel,
|
||||
icon: "fa fa-plus",
|
||||
click: function(evt) {
|
||||
that.addItem({});
|
||||
},
|
||||
title: addTitle
|
||||
});
|
||||
}
|
||||
|
||||
buttons.forEach(function(button) {
|
||||
var innerHtml = "";
|
||||
var titleAttribute="";
|
||||
if (button.icon) {
|
||||
innerHtml = '<i class="'+button.icon+'"></i> ';
|
||||
}
|
||||
if (button.label) {
|
||||
innerHtml += button.label;
|
||||
}
|
||||
if (button.title) {
|
||||
titleAttribute = 'title="'+button.title+'"';
|
||||
}
|
||||
$('<a href="#" class="red-ui-button red-ui-button-small red-ui-editableList-addButton" style="margin-top: 4px; margin-right: 5px;" '+titleAttribute+'>'+innerHtml+'</a>')
|
||||
.appendTo(that.topContainer)
|
||||
.on("click", function(evt) {
|
||||
evt.preventDefault();
|
||||
that.addItem({});
|
||||
if (button.click !== undefined) {
|
||||
button.click();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (this.element.css("position") === "absolute") {
|
||||
["top","left","bottom","right"].forEach(function(s) {
|
||||
var v = that.element.css(s);
|
||||
|
Loading…
Reference in New Issue
Block a user