Skip to content

Commit 2926d42

Browse files
committed
Version 2.0.0.
1 parent c2a7e05 commit 2926d42

15 files changed

+323
-117
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/*.min.js

.eslintrc

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
{
2+
"env": {
3+
"es6": true,
4+
"jquery": true,
5+
"browser": true
6+
},
7+
"parserOptions": {
8+
"sourceType": "module",
9+
"ecmaVersion": 7,
10+
"requireConfigFile": false
11+
},
12+
"parser": "@babel\\eslint-parser",
13+
"extends": "eslint:all",
14+
"rules": {
15+
"array-element-newline": "off",
16+
"capitalized-comments": "off",
17+
"class-methods-use-this": "off",
18+
"complexity": "off",
19+
"consistent-this": "off",
20+
"default-case": "off",
21+
"dot-location": "off",
22+
"func-names": "off",
23+
"function-call-argument-newline": "off",
24+
"global-require": "off",
25+
"id-length": "off",
26+
"indent": [
27+
"error", 4, {
28+
"SwitchCase": 1
29+
}
30+
],
31+
"init-declarations": "off",
32+
"line-comment-position": "off",
33+
"linebreak-style": "off",
34+
"lines-around-comment": "off",
35+
"max-depth": "off",
36+
"max-len": "off",
37+
"max-lines": "off",
38+
"max-lines-per-function": "off",
39+
"max-params": "off",
40+
"max-statements": "off",
41+
"multiline-comment-style": "off",
42+
"multiline-ternary": "off",
43+
"new-cap": [
44+
"error",
45+
{"properties": false}
46+
],
47+
"newline-per-chained-call": "off",
48+
"no-await-in-loop": "off",
49+
"no-confusing-arrow": "off",
50+
"no-console": "off",
51+
"no-continue": "off",
52+
"no-empty": "off",
53+
"no-empty-function": "off",
54+
"no-implicit-coercion": "off",
55+
"no-inline-comments": "off",
56+
"no-invalid-this": "off",
57+
"no-loop-func": "off",
58+
"no-magic-numbers": "off",
59+
"no-mixed-operators": "off",
60+
"no-mixed-requires": "off",
61+
"no-nested-ternary": "off",
62+
"no-param-reassign": "off",
63+
"no-plusplus": "off",
64+
"no-process-env": "off",
65+
"no-return-assign": "off",
66+
"no-ternary": "off",
67+
"no-trailing-spaces": [
68+
"error",
69+
{"ignoreComments": false}
70+
],
71+
"no-underscore-dangle": "off",
72+
"no-useless-constructor": "off",
73+
"no-void": "off",
74+
"object-property-newline": "off",
75+
"one-var": [
76+
"off", {
77+
"const": "always"
78+
}
79+
],
80+
"padded-blocks": "off",
81+
"prefer-destructuring": [
82+
"error", {
83+
"array": false
84+
}, {
85+
"enforceForRenamedProperties": true
86+
}
87+
],
88+
"prefer-promise-reject-errors": [
89+
"error", {"allowEmptyReject": true}
90+
],
91+
"require-atomic-updates": "off",
92+
"require-jsdoc": ["error", {
93+
"require": {
94+
"FunctionDeclaration": true,
95+
"MethodDefinition": true,
96+
"ClassDeclaration": true,
97+
"ArrowFunctionExpression": true,
98+
"FunctionExpression": true
99+
}
100+
}],
101+
"require-unicode-regexp": "off",
102+
"sort-keys": "off",
103+
"sort-vars": "off",
104+
"space-before-function-paren": "off",
105+
"quote-props": "off",
106+
"valid-jsdoc": [
107+
"error", {
108+
"prefer": {
109+
"return": "return"
110+
}
111+
}
112+
]
113+
}
114+
}

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: /
5+
schedule:
6+
interval: "daily"
7+
time: "05:00"
8+
timezone: "America/Los_Angeles"

.gitignore

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Created by https://www.gitignore.io/api/node
2+
3+
### Node ###
4+
# Logs
5+
logs
6+
*.log
7+
npm-debug.log*
8+
yarn-debug.log*
9+
yarn-error.log*
10+
11+
# Runtime data
12+
pids
13+
*.pid
14+
*.seed
15+
*.pid.lock
16+
17+
# Directory for instrumented libs generated by jscoverage/JSCover
18+
lib-cov
19+
20+
# Coverage directory used by tools like istanbul
21+
coverage
22+
23+
# nyc test coverage
24+
.nyc_output
25+
26+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
27+
.grunt
28+
29+
# Bower dependency directory (https://bower.io/)
30+
bower_components
31+
32+
# node-waf configuration
33+
.lock-wscript
34+
35+
# Compiled binary addons (http://nodejs.org/api/addons.html)
36+
build/Release
37+
38+
# Dependency directories
39+
node_modules/
40+
jspm_packages/
41+
42+
# Typescript v1 declaration files
43+
typings/
44+
45+
# Optional npm cache directory
46+
.npm
47+
48+
# Optional eslint cache
49+
.eslintcache
50+
51+
# Optional REPL history
52+
.node_repl_history
53+
54+
# Output of 'npm pack'
55+
*.tgz
56+
57+
# Yarn Integrity file
58+
.yarn-integrity
59+
60+
# dotenv environment variables file
61+
.env
62+
63+
64+
65+
# End of https://www.gitignore.io/api/node
File renamed without changes.

README.md

Lines changed: 22 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,22 @@
1-
# Default Button
2-
### Version 1.2 - 2011-12-18
3-
4-
A jQuery plugin to easily define a default button<br />
5-
Requires jQuery 1.7+
6-
7-
(c)2010-2011 [Ronald M. Clifford](mailto:[email protected])
8-
9-
Licensed under the MIT license:<br />
10-
[MIT license](http://www.opensource.org/licenses/mit-license.php)<br />
11-
12-
## Example Usage
13-
14-
The following HTML and script demonstrates how to use the plugin.
15-
16-
<html>
17-
<head>
18-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
19-
<script src="jquery-defaultButton.min.js"></script>
20-
</head>
21-
<body>
22-
<div id="Div1">
23-
Pressing enter in either of these textboxes will press Button1.<br />
24-
<input type="text"/>
25-
<input type="text"/>
26-
</div>
27-
<div id="Div2">
28-
Pressing enter in either of these textboxes will press Button2.<br />
29-
<input type="text"/>
30-
<input type="text"/>
31-
</div>
32-
<input type="button" id="Button1" value="Button1" />
33-
<input type="button" id="Button2" value="Button2" />
34-
<script>
35-
$(document).ready(function()
36-
{
37-
$("#Div1").defaultButton("#Button1");
38-
$("#Div2").defaultButton("#Button2");
39-
$("input[type=button]").on("click", function()
40-
{
41-
alert("You pressed " + $(this).attr("id"));
42-
});
43-
});
44-
</script>
45-
</body>
46-
</html>
1+
# jquery-default-button
2+
A jQuery plugin to easily define a default button.
3+
4+
## Installation
5+
6+
You can download the `/dist/jquery-default-button.min.js` file into your project. You can also use npm to install it that way:
7+
8+
```
9+
npm install jquery-default-button
10+
```
11+
12+
## Usage
13+
14+
See the `/examples` directory for an example of how to use the plugin. Note that in a normal project you will need to expose the `/dist/jquery-default-button.min.js` file in some way.
15+
16+
## Version History
17+
18+
### v2.0.0 - 8/10/2022
19+
* Modernized for latest jQuery.
20+
21+
### v1.2.0 - 12/18/2011
22+
* Initial version posted to GitHub.

defaultButton.jquery.json

Lines changed: 0 additions & 23 deletions
This file was deleted.

dist/jquery-default-button.min.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* jquery-default-button - A jQuery plugin to easily define a default button.
3+
* v2.0.0
4+
* ©2010-2022 Ronald M. Clifford ([email protected])
5+
*/
6+
($=>{$.fn.defaultButton=function(a){return $(this).off("keypress").on("keypress",b=>{"INPUT"===b.target.nodeName&&"Enter"===b.key&&$(a).trigger("click")}),this}})(jQuery)

examples/index.htm

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
5+
<script src="../dist/jquery-default-button.min.js"></script>
6+
</head>
7+
<body>
8+
<div id="Div1">
9+
Pressing enter in either of these textboxes will press Button1.<br />
10+
<input type="text"/>
11+
<input type="text"/>
12+
</div>
13+
<div id="Div2">
14+
Pressing enter in either of these textboxes will press Button2.<br />
15+
<input type="text"/>
16+
<input type="text"/>
17+
</div>
18+
<input type="button" id="Button1" value="Button1" />
19+
<input type="button" id="Button2" value="Button2" />
20+
<script>
21+
$(document).ready(function()
22+
{
23+
$("#Div1").defaultButton("#Button1");
24+
$("#Div2").defaultButton("#Button2");
25+
$("input[type=button]").on("click", function()
26+
{
27+
alert("You pressed " + $(this).attr("id"));
28+
});
29+
});
30+
</script>
31+
</body>
32+
</html>

index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
interface JQuery {
2+
/**
3+
* Sets the default button to click when enter is pressed for all child elements.
4+
* @param element The element of the default button that is clicked on when enter is pressed.
5+
*/
6+
defaultButton(element: HTMLSelectElement): JQuery;
7+
}

0 commit comments

Comments
 (0)