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);
|
this.topContainer.addClass(this.options.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var buttons = this.options.buttons || [];
|
||||||
|
|
||||||
if (this.options.addButton !== false) {
|
if (this.options.addButton !== false) {
|
||||||
var addLabel;
|
var addLabel, addTittle;
|
||||||
if (typeof this.options.addButton === 'string') {
|
if (typeof this.options.addButton === 'string') {
|
||||||
addLabel = this.options.addButton
|
addLabel = this.options.addButton
|
||||||
} else {
|
} else {
|
||||||
if (RED && RED._) {
|
if (RED && RED._) {
|
||||||
addLabel = RED._("editableList.add");
|
addLabel = RED._("editableList.add");
|
||||||
|
addTitle = RED._("editableList.addTitle");
|
||||||
} else {
|
} else {
|
||||||
addLabel = 'add';
|
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>')
|
buttons.unshift({
|
||||||
.appendTo(this.topContainer)
|
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) {
|
.on("click", function(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
that.addItem({});
|
if (button.click !== undefined) {
|
||||||
|
button.click();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
if (this.element.css("position") === "absolute") {
|
if (this.element.css("position") === "absolute") {
|
||||||
["top","left","bottom","right"].forEach(function(s) {
|
["top","left","bottom","right"].forEach(function(s) {
|
||||||
var v = that.element.css(s);
|
var v = that.element.css(s);
|
||||||
|
Loading…
Reference in New Issue
Block a user