Compare commits
2 Commits
fbfb09a545
...
b91c3be0b4
| Author | SHA1 | Date | |
|---|---|---|---|
| b91c3be0b4 | |||
| 3f95905578 |
+18
-4
@@ -14,8 +14,8 @@ module.exports = function (RED) {
|
||||
|
||||
var heightPx = config.buttonheight * sizes.sy - sizes.gy;
|
||||
|
||||
var html = `<div style="width=100%; height=100%">
|
||||
<md-button id="{{$index}}" style="width:${widthPx}px; height:${heightPx}px; margin: ${sizes.gx}px ${sizes.gy}px; background-color: {{button.color}}; white-space: pre-wrap; word-break: break-word;" ng-click="buttonClick($event)" ng-repeat="button in msg.buttons">{{button.label}}</md-button>
|
||||
var html = `<div style="width=100%; height=100%; display: flex; flex-wrap: wrap; justify-content: center;">
|
||||
<md-button id="{{$index}}" style="width:${widthPx}px; height:${heightPx}px; margin: ${sizes.gx}px ${sizes.gy}px; background-color: {{button.color}}; white-space: pre-wrap; word-break: break-word;" ng-click="buttonClick($event)" ng-mousedown="buttonDown($event)" ng-mouseup="buttonUp($event)" ng-repeat="button in msg.buttons">{{button.label}}</md-button>
|
||||
</div>`;
|
||||
|
||||
var done = ui.addWidget({
|
||||
@@ -45,8 +45,22 @@ module.exports = function (RED) {
|
||||
$scope.buttonClick = function (e) {
|
||||
e.preventDefault();
|
||||
var buttonId = e.target.id;
|
||||
if ($scope.msg.buttons[buttonId].payload) {
|
||||
$scope.send({ "payload": $scope.msg.buttons[buttonId].payload });
|
||||
if ($scope.msg.buttons[buttonId].click) {
|
||||
$scope.send($scope.msg.buttons[buttonId].click);
|
||||
}
|
||||
};
|
||||
$scope.buttonDown = function (e) {
|
||||
e.preventDefault();
|
||||
var buttonId = e.target.id;
|
||||
if ($scope.msg.buttons[buttonId].down) {
|
||||
$scope.send($scope.msg.buttons[buttonId].down);
|
||||
}
|
||||
};
|
||||
$scope.buttonUp = function (e) {
|
||||
e.preventDefault();
|
||||
var buttonId = e.target.id;
|
||||
if ($scope.msg.buttons[buttonId].up) {
|
||||
$scope.send($scope.msg.buttons[buttonId].up);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user