N°5621 Move mousetrap 1.6.5 to NPM

This commit is contained in:
Pierre Goiffon
2024-02-16 16:37:46 +01:00
parent d4c54b6e1c
commit ff079f7d01
33 changed files with 2947 additions and 2 deletions

29
node_modules/mousetrap/plugins/record/tests/index.html generated vendored Normal file
View File

@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<title>Jelly</title>
<meta charset=utf-8>
<link href="jelly.css" rel="stylesheet">
</head>
<body>
<h1>Jelly</h1>
<h2>For testing the <strong>record</strong> extension</h2>
<p>Click "Record" to test recording a sequence.</p>
<button class="test-record">Record</button>
<div class="test-record-result"></div>
<script type="text/javascript" src="../../../tests/libs/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="../../../mousetrap.js"></script>
<script type="text/javascript" src="../mousetrap-record.js"></script>
<script type="text/javascript" src="jelly.js"></script>
<script type="text/javascript">
Jelly.spread();
</script>
</body>
</html>

18
node_modules/mousetrap/plugins/record/tests/jelly.css generated vendored Normal file
View File

@@ -0,0 +1,18 @@
body {
font-family: helvetica, arial, sans-serif;
line-height: 20px;
}
kbd {
background-color: #ccc;
display: inline-block;
padding: 0.5ex 1em;
}
.test-record-result {
margin-top: 20px;
}
.test-record-result span:nth-child(n+2) {
margin-left: 10px;
}

53
node_modules/mousetrap/plugins/record/tests/jelly.js generated vendored Normal file
View File

@@ -0,0 +1,53 @@
/**
* Peanut butter goes great with jelly.
*
* @author Dan Tao <daniel.tao@gmail.com>
*/
var Jelly = (function() {
var recordButton = $("button.test-record"),
recordResult = $("div.test-record-result");
function _formatSequenceAsHtml(sequence) {
var combos = [],
i;
for (i = 0; i < sequence.length; ++i) {
combos.push('<span>' + _formatKeysAsHtml(sequence[i].split('+')) + '</span>');
}
return combos.join(' ');
}
function _formatKeysAsHtml(keys) {
var htmlKeys = [],
i;
for (i = 0; i < keys.length; ++i) {
htmlKeys.push('<kbd>' + keys[i] + '</kbd>');
}
return htmlKeys.join('+');
}
function _prepareRecordTest() {
recordButton.prop('disabled', true);
recordButton.text('Recording');
Mousetrap.record(function(sequence) {
recordResult.html(_formatSequenceAsHtml(sequence));
recordButton.prop('disabled', false);
recordButton.text('Record');
});
// take focus away from the button so that Mousetrap will actually
// capture keystrokes
recordButton.blur();
}
return {
spread: function() {
recordButton.click(_prepareRecordTest);
}
};
})();