This ui-template creates a momentary button that outputs true on mousedown/touchstart and false on mouseup/touchend
-
-
Save Hugobox/badf32e71913b09a2d8e2488a1b101a5 to your computer and use it in GitHub Desktop.
Momentary toggle button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "fa34fe67.be89c", | |
"type": "debug", | |
"z": "9f1175b5.c05ee8", | |
"name": "", | |
"active": true, | |
"tosidebar": true, | |
"console": false, | |
"tostatus": false, | |
"complete": "true", | |
"x": 790, | |
"y": 560, | |
"wires": [] | |
}, | |
{ | |
"id": "4a193389.e055ac", | |
"type": "ui_template", | |
"z": "9f1175b5.c05ee8", | |
"group": "4ba5d415.d302ec", | |
"name": "Toggle Button", | |
"order": 1, | |
"width": "6", | |
"height": "1", | |
"format": "<style>\n.nr-dashboard-template {\n padding: 0px;\n}\n</style>\n<div class=\"momentary\">\n <md-button style=\"width:100%; height:48px; margin: 0px\"> Momentary Button</md-button>\n</div>\n\n<script>\n\n(function($scope) {\n \n$('.momentary').on('touchstart mousedown', function(e) {\n e.preventDefault(); //prevent default behavior\n $scope.send({\"payload\": true});\n});\n\n$('.momentary').on('touchend mouseup', function(e) {\n e.preventDefault(); //prevent default behavior\n $scope.send({\"payload\": false});\n});\n \n})(scope);\n</script>", | |
"storeOutMessages": false, | |
"fwdInMessages": false, | |
"templateScope": "local", | |
"x": 610, | |
"y": 560, | |
"wires": [ | |
[ | |
"fa34fe67.be89c" | |
] | |
] | |
}, | |
{ | |
"id": "4ba5d415.d302ec", | |
"type": "ui_group", | |
"z": "", | |
"name": "Control", | |
"tab": "47f0556b.db072c", | |
"disp": true, | |
"width": "6", | |
"collapse": false | |
}, | |
{ | |
"id": "47f0556b.db072c", | |
"type": "ui_tab", | |
"z": "", | |
"name": "ICM", | |
"icon": "dashboard" | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment