@carpages/jquery-boiler 0.6.0-alpha.1 → 0.6.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jquery.boiler.js +70 -0
- package/dist/jquery.boiler.min.js +1 -0
- package/jquery.boiler.js +51 -51
- package/package.json +32 -14
- package/.editorconfig +0 -13
- package/.eslintrc.js +0 -6
- package/.travis.yml +0 -17
- package/.vscode/settings.json +0 -2
- package/.vscode/tasks.json +0 -12
- package/Gruntfile.js +0 -57
- package/bower.json +0 -26
- package/example/jquery.boiler.example.js +0 -63
- package/example/jquery.boiler.template.js +0 -23
- package/test/.eslintrc.js +0 -4
- package/test/jquery-boiler.test.html +0 -57
- package/test/jquery-boiler.test.js +0 -332
- package/test/qunit.config.js +0 -8
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['jquery'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.jQuery = factory(global.$));
|
|
5
|
+
})(this, (function ($) { 'use strict';
|
|
6
|
+
|
|
7
|
+
$.boiler = function (namespace, base) {
|
|
8
|
+
$.fn[namespace] = function () {
|
|
9
|
+
var args = Array.prototype.slice.call(arguments);
|
|
10
|
+
var method = args[0];
|
|
11
|
+
var options = args.slice(1);
|
|
12
|
+
return this.each(function () {
|
|
13
|
+
var cachedPlugin = $(this).data(namespace);
|
|
14
|
+
if (cachedPlugin === undefined) {
|
|
15
|
+
// make a clone of the base
|
|
16
|
+
var plugin = {};
|
|
17
|
+
$.extend(plugin, base);
|
|
18
|
+
|
|
19
|
+
// cache the element
|
|
20
|
+
plugin.el = this;
|
|
21
|
+
plugin.$el = $(this);
|
|
22
|
+
|
|
23
|
+
// cache the plugin
|
|
24
|
+
plugin.$el.data(namespace, plugin);
|
|
25
|
+
|
|
26
|
+
// cache the options
|
|
27
|
+
if (method !== undefined) plugin.options = method;
|
|
28
|
+
|
|
29
|
+
// check for data attributes
|
|
30
|
+
if (plugin.data) {
|
|
31
|
+
var dataList = plugin.data;
|
|
32
|
+
plugin.data = {};
|
|
33
|
+
$.each(dataList, function (index, name) {
|
|
34
|
+
plugin.data[name] = plugin.$el.data(name);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// overwrite options with data and defaults
|
|
39
|
+
plugin.settings = $.extend({}, plugin.defaults, plugin.options, plugin.data);
|
|
40
|
+
|
|
41
|
+
// check for events
|
|
42
|
+
if (plugin.events) {
|
|
43
|
+
$.each(plugin.events, function (eventString, handler) {
|
|
44
|
+
var tmp = eventString.split(' ');
|
|
45
|
+
var event = tmp[0];
|
|
46
|
+
var selector = tmp.slice(1).join(' ') || null;
|
|
47
|
+
plugin.$el.on(event, selector, function (e) {
|
|
48
|
+
plugin[handler].call(plugin, e, this);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// fire up the plugin!
|
|
54
|
+
if (plugin.init) plugin.init();
|
|
55
|
+
} else if (cachedPlugin[method] && method.charAt(0) !== '_') {
|
|
56
|
+
// if method is a function
|
|
57
|
+
if (typeof cachedPlugin[method] === 'function') {
|
|
58
|
+
cachedPlugin[method].apply(cachedPlugin, options);
|
|
59
|
+
// otherwise, treat it as a propery and reset it
|
|
60
|
+
} else {
|
|
61
|
+
cachedPlugin[method] = options[0];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return $;
|
|
69
|
+
|
|
70
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).jQuery=t(e.$)}(this,function(e){"use strict";return e.boiler=function(t,i){e.fn[t]=function(){var n=Array.prototype.slice.call(arguments),a=n[0],o=n.slice(1);return this.each(function(){var n=e(this).data(t);if(void 0===n){var l={};if(e.extend(l,i),l.el=this,l.$el=e(this),l.$el.data(t,l),void 0!==a&&(l.options=a),l.data){var f=l.data;l.data={},e.each(f,function(e,t){l.data[t]=l.$el.data(t)})}l.settings=e.extend({},l.defaults,l.options,l.data),l.events&&e.each(l.events,function(e,t){var i=e.split(" "),n=i[0],a=i.slice(1).join(" ")||null;l.$el.on(n,a,function(e){l[t].call(l,e,this)})}),l.init&&l.init()}else n[a]&&"_"!==a.charAt(0)&&("function"==typeof n[a]?n[a].apply(n,o):n[a]=o[0])})}},e});
|
package/jquery.boiler.js
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
1
|
import $ from 'jquery';
|
|
2
2
|
|
|
3
|
-
$.boiler = function(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
$.boiler = function (namespace, base) {
|
|
4
|
+
$.fn[namespace] = function () {
|
|
5
|
+
var args = Array.prototype.slice.call(arguments);
|
|
6
|
+
var method = args[0];
|
|
7
|
+
var options = args.slice(1);
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
return this.each(function () {
|
|
10
|
+
var cachedPlugin = $(this).data(namespace);
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
if (cachedPlugin === undefined) {
|
|
13
|
+
// make a clone of the base
|
|
14
|
+
var plugin = {};
|
|
15
|
+
$.extend(plugin, base);
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
// cache the element
|
|
18
|
+
plugin.el = this;
|
|
19
|
+
plugin.$el = $(this);
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
// cache the plugin
|
|
22
|
+
plugin.$el.data(namespace, plugin);
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
// cache the options
|
|
25
|
+
if (method !== undefined) plugin.options = method;
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
// check for data attributes
|
|
28
|
+
if (plugin.data) {
|
|
29
|
+
var dataList = plugin.data;
|
|
30
|
+
plugin.data = {};
|
|
31
|
+
$.each(dataList, function (index, name) {
|
|
32
|
+
plugin.data[name] = plugin.$el.data(name);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
// overwrite options with data and defaults
|
|
37
|
+
plugin.settings = $.extend({}, plugin.defaults, plugin.options, plugin.data);
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
// check for events
|
|
40
|
+
if (plugin.events) {
|
|
41
|
+
$.each(plugin.events, function (eventString, handler) {
|
|
42
|
+
var tmp = eventString.split(' ');
|
|
43
|
+
var event = tmp[0];
|
|
44
|
+
var selector = tmp.slice(1).join(' ') || null;
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
46
|
+
plugin.$el.on(event, selector, function (e) {
|
|
47
|
+
plugin[handler].call(plugin, e, this);
|
|
49
48
|
});
|
|
50
|
-
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
52
|
+
// fire up the plugin!
|
|
53
|
+
if (plugin.init) plugin.init();
|
|
54
|
+
} else if (cachedPlugin[method] && method.charAt(0) !== '_') {
|
|
55
|
+
// if method is a function
|
|
56
|
+
if (typeof cachedPlugin[method] === 'function') {
|
|
57
|
+
cachedPlugin[method].apply(cachedPlugin, options);
|
|
58
|
+
// otherwise, treat it as a propery and reset it
|
|
59
|
+
} else {
|
|
60
|
+
cachedPlugin[method] = options[0];
|
|
62
61
|
}
|
|
63
|
-
}
|
|
64
|
-
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
65
64
|
};
|
|
65
|
+
};
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
export default $;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carpages/jquery-boiler",
|
|
3
|
-
"version": "0.6.0-alpha.
|
|
3
|
+
"version": "0.6.0-alpha.2",
|
|
4
4
|
"description": "A jQuery plugin to help you quickly write custom jQuery plugins",
|
|
5
5
|
"author": "Matt Rose <matt@mattrose.ca> (http://mattrose.ca)",
|
|
6
6
|
"contributors": [
|
|
@@ -10,21 +10,39 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/carpages/jquery-boiler"
|
|
12
12
|
},
|
|
13
|
-
"main": "jquery.boiler.js",
|
|
13
|
+
"main": "dist/jquery.boiler.js",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"jquery.boiler.js"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "rollup -c"
|
|
20
|
+
},
|
|
14
21
|
"dependencies": {
|
|
15
|
-
"jquery": "
|
|
22
|
+
"jquery": "^4.0.0"
|
|
16
23
|
},
|
|
17
24
|
"devDependencies": {
|
|
18
|
-
"
|
|
19
|
-
"eslint-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
25
|
+
"@babel/core": "^7.29.0",
|
|
26
|
+
"@babel/eslint-parser": "^7.28.6",
|
|
27
|
+
"@babel/preset-env": "^7.29.0",
|
|
28
|
+
"@eslint/compat": "^2.0.2",
|
|
29
|
+
"@eslint/eslintrc": "^3.3.4",
|
|
30
|
+
"@eslint/js": "^9.39.3",
|
|
31
|
+
"@rollup/plugin-babel": "^6.1.0",
|
|
32
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
33
|
+
"@rollup/plugin-inject": "^5.0.5",
|
|
34
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
35
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
36
|
+
"eslint": "^9.39.3",
|
|
37
|
+
"eslint-config-carpages": "^8.1.1",
|
|
38
|
+
"eslint-config-prettier": "^10.1.8",
|
|
39
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
40
|
+
"eslint-plugin-qunit": "^8.2.6",
|
|
41
|
+
"prettier": "^3.8.1",
|
|
42
|
+
"rollup": "^4.59.0"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
28
46
|
},
|
|
29
47
|
"license": "MIT"
|
|
30
|
-
}
|
|
48
|
+
}
|
package/.editorconfig
DELETED
package/.eslintrc.js
DELETED
package/.travis.yml
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
language: node_js
|
|
2
|
-
|
|
3
|
-
node_js:
|
|
4
|
-
- '8'
|
|
5
|
-
- '10'
|
|
6
|
-
- '12'
|
|
7
|
-
|
|
8
|
-
before_script:
|
|
9
|
-
- npm install -g grunt-cli bower
|
|
10
|
-
- bower update
|
|
11
|
-
|
|
12
|
-
script: grunt ci --verbose
|
|
13
|
-
|
|
14
|
-
env:
|
|
15
|
-
global:
|
|
16
|
-
- secure: o7uB6fF7d8uu+4CtXzQ69HrwAJnHHmlAq2Pg5pyanCkjk0pGEqOUI+cDXBL/MpPVTPQGk78Soq0/gHcyeCsQmpTc9Ww8fDae02VzCIEwjPuihfDU291V8NHBD9cBkA82CtWYtYfT005TqySrrCkguLo2qr3sNjOJG86lj5Zn1KXZw9vRezRTQA3oXngfPOJSEAsgVVTKXUPeApXoZliaAslqQs8G2tzxW2cEBHE3Qs5rZKkdv9a2WC4+MvTdABIy9+PC6FNbBxEruoEWHMen50LBrOgzrJ6URXFvkf50BuhG8hH8t3SAJWt3zS6+Txot8z1qih8eTWKp8NM43IBNZrBAEJv4Z7rg8kGA1BOloK2XBMgQ0R/o+TjMjb+/g4L8etbrYzGVj3Fgynohl6MnD7LUoQYZDlwrm1DgCJijgUl7unUwG3OAvSPi/1ZN1PgYNr3PQy/850jurDshMiJoyOyld0CZDYhQKu1d3j3u3+HnMdUsOXHMX8mU59kjg5By5tDM/z4n4lS/Wn71FVrQgWzUAlzS6Oi7NMxzg8WcF88HT21kfHX+FfBgLa5K9BEMI9BQpmytqj2X4D8fBL1QKeAel6fglgEuNJVpwKJPdFxbR4gTk2/0DWMIbvWIjNO9thh+tZ09cIq/tD1aJ+Hs8lwjYXt/ISNJo8n3I0K7U5M=
|
|
17
|
-
- secure: puvL8GSrmQygXF09Q8g1DoHb8PRajm4+keOBFsGKjBjRdkttsIxQ2V13IZvwdmIb+icH0XcwcOKS1MVKEGic9sixDglObthSO2koNI1rfyYqMWJ6Ye4NAOvnZ2w2B8LLJDkTjmp0dvJYHTHiDPNnb2zjbGsFHb5dVNdmds3hTADXdBGPbZV8szQ8x8doeL55Eps/ZYhPTu6KfA/yvjy/7UXQ9/0PqWnI09I5e6qdtHMPtAuFKRGasZdMsPW+vYni6MTdKOIG5dyutm3mAMD903ozx/yiaIiMavDRcPSbC4Aflh4E7Z87Pl9oQnX3YMnOBbC4Nv4Fkg9RVHCvaVU09QhKVzhz3Smibx9BsyTIx1krV9XbDJqzSI94oSVcl+kzx2U+FmxsVfvDaswUZFjSmJYGKvbnPPhUVnEdNHfTNJ3BbH7phFXjavNr87nueWxK3KDRritKegque3HhaCFpzfgZzjwIN2SO2RA5vPbsn7iCyHpY8ISazubfuEFX4vUyvK3QAX8bDdPCtVGDQmd1m3mEq2nx+7muaA8BhLjjVTbAk2dQtklLwoVyyIztzggbwHQdNiUzQk64RwerZomhokQsnkaaGayQpFQTfycsi9NDSArsOafp0vLsp6kKl/GKUKuThO2B9jXkRNXZY75WlQvvNfhr53vA+Tr96EGwLTQ=
|
package/.vscode/settings.json
DELETED
package/.vscode/tasks.json
DELETED
package/Gruntfile.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports = function( grunt ) {
|
|
4
|
-
// Load all grunt tasks
|
|
5
|
-
require( 'load-grunt-tasks' )( grunt );
|
|
6
|
-
|
|
7
|
-
// Show elapsed time at the end
|
|
8
|
-
require( 'time-grunt' )( grunt );
|
|
9
|
-
|
|
10
|
-
// Project configuration.
|
|
11
|
-
grunt.initConfig({
|
|
12
|
-
// Metadata.
|
|
13
|
-
pkg: grunt.file.readJSON( 'package.json' ),
|
|
14
|
-
banner:
|
|
15
|
-
'/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
|
|
16
|
-
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
|
|
17
|
-
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
|
|
18
|
-
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
|
|
19
|
-
' Licensed MIT */\n',
|
|
20
|
-
|
|
21
|
-
// Task configuration.
|
|
22
|
-
qunit: {
|
|
23
|
-
all: {
|
|
24
|
-
options: {
|
|
25
|
-
inject: [ './test/qunit.config.js', './node_modules/grunt-contrib-qunit/chrome/bridge.js' ],
|
|
26
|
-
urls: [ 'http://localhost:9000/test/jquery-boiler.test.html' ],
|
|
27
|
-
page: {
|
|
28
|
-
viewportSize: { width: 1280, height: 800 }
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
eslint: {
|
|
35
|
-
target: [ 'jquery.boiler.js' ]
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
connect: {
|
|
39
|
-
tests: {
|
|
40
|
-
options: {
|
|
41
|
-
hostname: '*',
|
|
42
|
-
port: 9000
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// Default Task
|
|
49
|
-
grunt.registerTask( 'default', [ 'eslint', 'test:qunit' ]);
|
|
50
|
-
|
|
51
|
-
// Testing Tasks
|
|
52
|
-
grunt.registerTask( 'test:all', [ 'connect', 'qunit' ]);
|
|
53
|
-
grunt.registerTask( 'test:qunit', [ 'connect', 'qunit' ]);
|
|
54
|
-
|
|
55
|
-
// CI Task
|
|
56
|
-
grunt.registerTask( 'ci', [ 'eslint', 'test:all' ]);
|
|
57
|
-
};
|
package/bower.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "jquery-boiler",
|
|
3
|
-
"title": "jQuery Boiler",
|
|
4
|
-
"description": "A jQuery plugin to help you quickly write custom jQuery plugins.",
|
|
5
|
-
"keywords": ["jquery", "plugin", "boiler", "boilerplate", "jquery-plugin", "jquery-boilerplate"],
|
|
6
|
-
"homepage": "https://github.com/mattdrose/jquery-boiler",
|
|
7
|
-
"authors": [
|
|
8
|
-
"Matt Rose <matt@mattrose.ca> (http://mattrose.ca)",
|
|
9
|
-
"Jeff Andrews <jeffandrews@me.com>"
|
|
10
|
-
],
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "git://github.com/mattdrose/jquery-boiler.git"
|
|
14
|
-
},
|
|
15
|
-
"bugs": "https://github.com/mattdrose/jquery-boiler/issues",
|
|
16
|
-
"license": "MIT",
|
|
17
|
-
"main": "jquery.boiler.js",
|
|
18
|
-
"ignore": ["test", "Gruntfile.js", "package.json", "*.md"],
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"jquery": "3.x"
|
|
21
|
-
},
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"qunit": "2.x",
|
|
24
|
-
"requirejs": "2.x"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is an example of creating a plugin with jquery.boiler.
|
|
3
|
-
* It acts as reference and will not actually create a functioning plugin :)
|
|
4
|
-
*
|
|
5
|
-
* jquery.boiler
|
|
6
|
-
* @param {string} namespace - The name of your plugin
|
|
7
|
-
* @param {object} base - The base of your plugin
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
$.boiler( 'tooltip', {
|
|
11
|
-
/* The default settings for the plugin. These can be overwritten by the
|
|
12
|
-
options passed on initiation. */
|
|
13
|
-
defaults: {
|
|
14
|
-
tip: 'This is a tip!',
|
|
15
|
-
animationSpeed: 500
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
/* Events to bind onto the plugins dom element(s). You can use these events
|
|
19
|
-
to call a function within the plugin. */
|
|
20
|
-
events: {
|
|
21
|
-
mouseEnter: 'open',
|
|
22
|
-
mouseLeave: 'close'
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
/* A list of supported data-attribute variables. These will overwrite
|
|
26
|
-
both the defaults and the options in the plugins settings. */
|
|
27
|
-
data: [ 'tip' ],
|
|
28
|
-
|
|
29
|
-
/* The function which runs on initiation. A good time to cache. */
|
|
30
|
-
init: function() {
|
|
31
|
-
/* 'this' always refers to the plugin. It's good practice to store a
|
|
32
|
-
reference. */
|
|
33
|
-
var plugin = this;
|
|
34
|
-
|
|
35
|
-
/* cache */
|
|
36
|
-
plugin.$wrapper = $( '<div/>' ).addClass( 'js-tooltip__wrapper' );
|
|
37
|
-
|
|
38
|
-
plugin.$tip = $( '<div/>' )
|
|
39
|
-
.addClass( 'js-tooltip__tip' )
|
|
40
|
-
.html( plugin.settings.tip );
|
|
41
|
-
|
|
42
|
-
/* plugin.el and plugin.$el are references to the dom element. */
|
|
43
|
-
plugin.$el.wrap( plugin.$wrapper );
|
|
44
|
-
plugin.$wrapper.append( plugin.$tip );
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
/* Public methods like this are accessible outside of the plugin. Private
|
|
48
|
-
methods begin with _. These methods can't be accessed outside of the
|
|
49
|
-
plugin. */
|
|
50
|
-
open: function() {
|
|
51
|
-
/* The plugin object gives you full access to the plugin */
|
|
52
|
-
var plugin = this;
|
|
53
|
-
|
|
54
|
-
/* The plugin settings are created from data, options, and defaults.
|
|
55
|
-
Settings take priority as follows: data > options > defaults */
|
|
56
|
-
plugin.$tip.fadeIn( plugin.settings.animationSpeed );
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
close: function() {
|
|
60
|
-
var plugin = this;
|
|
61
|
-
plugin.$tip.fadeOut( plugin.settings.animationSpeed );
|
|
62
|
-
}
|
|
63
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is a starting template for creating jQuery plugins with jquery.boiler
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
$.boiler( 'pluginName', {
|
|
6
|
-
defaults: {},
|
|
7
|
-
|
|
8
|
-
events: {},
|
|
9
|
-
|
|
10
|
-
data: [],
|
|
11
|
-
|
|
12
|
-
init: function() {
|
|
13
|
-
var plugin = this;
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
_privateMethod: function() {
|
|
17
|
-
var plugin = this;
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
publicMethod: function() {
|
|
21
|
-
var plugin = this;
|
|
22
|
-
}
|
|
23
|
-
});
|
package/test/.eslintrc.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<title>jQuery Boiler Test</title>
|
|
6
|
-
|
|
7
|
-
<!-- Load local jQuery. -->
|
|
8
|
-
<script src="../bower_components/jquery/dist/jquery.js"></script>
|
|
9
|
-
|
|
10
|
-
<!-- Load CSS. -->
|
|
11
|
-
<link rel="stylesheet" href="../bower_components/qunit/qunit/qunit.css" media="screen" />
|
|
12
|
-
|
|
13
|
-
<!-- Load RequireJS. -->
|
|
14
|
-
<script src="../bower_components/requirejs/require.js"></script>
|
|
15
|
-
|
|
16
|
-
<!-- Load tests. -->
|
|
17
|
-
<script src="qunit.config.js"></script>
|
|
18
|
-
<script src="jquery-boiler.test.js"></script>
|
|
19
|
-
|
|
20
|
-
<!--
|
|
21
|
-
Removing access to jQuery and $. But it'll still be available as _$,
|
|
22
|
-
if you REALLY want to mess around with jQuery in the console. REMEMBER WE
|
|
23
|
-
ARE TESTING A PLUGIN HERE, THIS HELPS ENSURE BEST PRACTICES. REALLY.
|
|
24
|
-
-->
|
|
25
|
-
<script>
|
|
26
|
-
window._$ = jQuery.noConflict(true);
|
|
27
|
-
</script>
|
|
28
|
-
</head>
|
|
29
|
-
|
|
30
|
-
<body>
|
|
31
|
-
<div id="qunit"></div>
|
|
32
|
-
|
|
33
|
-
<p id="js-test-1" class="js-test" data-one="ONE">
|
|
34
|
-
Sausage salami turducken, spare ribs strip steak jowl ball tip turkey shankle.
|
|
35
|
-
</p>
|
|
36
|
-
<p id="js-test-2" class="js-test">
|
|
37
|
-
Pig strip steak kielbasa swine. Doner ham hock spare ribs jowl, swine bacon corned beef
|
|
38
|
-
drumstick salami beef t-bone pastrami pancetta sirloin beef ribs.
|
|
39
|
-
</p>
|
|
40
|
-
|
|
41
|
-
<ul id="js-test-3">
|
|
42
|
-
<li>
|
|
43
|
-
<span id="js-target-1">Brisket</span> biltong porchetta doner boudin, hamburger capicola
|
|
44
|
-
andouille pastrami ham hock flank turducken bresaola beef.
|
|
45
|
-
</li>
|
|
46
|
-
<li>
|
|
47
|
-
<strong id="js-target-2">Tail</strong> jowl biltong pancetta, hamburger shank kevin rump
|
|
48
|
-
salami. Swine sirloin pig hamburger frankfurter spare ribs turducken pork chop.
|
|
49
|
-
</li>
|
|
50
|
-
<li>
|
|
51
|
-
<span id="js-target-3">Spare</span> ribs brisket bacon hamburger short ribs, tri-tip cow
|
|
52
|
-
capicola pastrami boudin porchetta swine ball tip. Landjaeger boudin spare ribs, capicola
|
|
53
|
-
bresaola doner pork loin biltong pig tail.
|
|
54
|
-
</li>
|
|
55
|
-
</ul>
|
|
56
|
-
</body>
|
|
57
|
-
</html>
|
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
require([ 'qunit', 'jquery', 'jquery.boiler' ], function( QUnit, $ ) {
|
|
2
|
-
/*
|
|
3
|
-
* Added for Saucelabs
|
|
4
|
-
* https://github.com/axemclion/grunt-saucelabs#test-result-details-with-qunit
|
|
5
|
-
*/
|
|
6
|
-
var log = [];
|
|
7
|
-
var testName;
|
|
8
|
-
|
|
9
|
-
QUnit.done( function( test_results ) {
|
|
10
|
-
var tests = [];
|
|
11
|
-
for ( var i = 0, len = log.length; i < len; i++ ) {
|
|
12
|
-
var details = log[i];
|
|
13
|
-
tests.push({
|
|
14
|
-
name: details.name,
|
|
15
|
-
result: details.result,
|
|
16
|
-
expected: details.expected,
|
|
17
|
-
actual: details.actual,
|
|
18
|
-
source: details.source
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
test_results.tests = tests;
|
|
22
|
-
|
|
23
|
-
window.global_test_results = test_results;
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
QUnit.testStart( function( testDetails ) {
|
|
27
|
-
QUnit.log( function( details ) {
|
|
28
|
-
if ( !details.result ) {
|
|
29
|
-
details.name = testDetails.name;
|
|
30
|
-
log.push( details );
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
/*
|
|
36
|
-
======== A Handy Little QUnit Reference ========
|
|
37
|
-
http://api.qunitjs.com/
|
|
38
|
-
|
|
39
|
-
Test methods:
|
|
40
|
-
QUnit.module(name, {[beforeEach], [afterEach]})
|
|
41
|
-
QUnit.test(name, callbaassertck)
|
|
42
|
-
QUnit.expect(numberOfAssertions)
|
|
43
|
-
QUnit.stop(increment)
|
|
44
|
-
QUnit.start(decrement)
|
|
45
|
-
Test assertions:
|
|
46
|
-
assert.ok(value, [message])
|
|
47
|
-
assert.equal(actual, expected, [message])
|
|
48
|
-
assert.notEqual(actual, expected, [message])
|
|
49
|
-
assert.deepEqual(actual, expected, [message])
|
|
50
|
-
assert.notDeepEqual(actual, expected, [message])
|
|
51
|
-
assert.strictEqual(actual, expected, [message])
|
|
52
|
-
assert.notStrictEqual(actual, expected, [message])
|
|
53
|
-
assert.throws(block, [expected], [message])
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
QUnit.start();
|
|
57
|
-
|
|
58
|
-
QUnit.module( 'Basic Plugin Functionality', {
|
|
59
|
-
// This will run before each test in this module.
|
|
60
|
-
beforeEach: function() {
|
|
61
|
-
this.$el1 = $( '#js-test-1' );
|
|
62
|
-
this.$el2 = $( '#js-test-2' );
|
|
63
|
-
this.$els = $( '.js-test' );
|
|
64
|
-
|
|
65
|
-
$.boiler( 'test', {});
|
|
66
|
-
},
|
|
67
|
-
afterEach: function() {
|
|
68
|
-
this.$els.removeData( 'test' );
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
QUnit.test( 'Added to fn namespace', function( assert ) {
|
|
73
|
-
assert.expect( 1 );
|
|
74
|
-
|
|
75
|
-
assert.ok( !!$.fn.test );
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
QUnit.test( 'Chainable', function( assert ) {
|
|
79
|
-
assert.expect( 1 );
|
|
80
|
-
|
|
81
|
-
assert.strictEqual( this.$els.test(), this.$els );
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
QUnit.test( 'Plugin cached in elements data attribute', function( assert ) {
|
|
85
|
-
assert.expect( 1 );
|
|
86
|
-
|
|
87
|
-
this.$el1.test();
|
|
88
|
-
assert.ok( !!this.$el1.data( 'test' ));
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
QUnit.test( 'Plugin applied to each element in a group', function( assert ) {
|
|
92
|
-
assert.expect( 1 );
|
|
93
|
-
|
|
94
|
-
var isOk = true;
|
|
95
|
-
|
|
96
|
-
this.$els.test();
|
|
97
|
-
|
|
98
|
-
this.$els.each( function() {
|
|
99
|
-
if ( !$( this ).data( 'test' )) {
|
|
100
|
-
isOk = false;
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
assert.ok( isOk );
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
QUnit.test( 'Each instance of plugin is seperate', function( assert ) {
|
|
108
|
-
assert.expect( 1 );
|
|
109
|
-
|
|
110
|
-
this.$els.test();
|
|
111
|
-
|
|
112
|
-
assert.notStrictEqual( this.$el1.data( 'test' ), this.$el2.data( 'test' ));
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
/*
|
|
116
|
-
*
|
|
117
|
-
*/
|
|
118
|
-
|
|
119
|
-
QUnit.module( 'Caching Dom Objects', {
|
|
120
|
-
// This will run before each test in this module.
|
|
121
|
-
beforeEach: function() {
|
|
122
|
-
this.$el = $( '#js-test-1' );
|
|
123
|
-
|
|
124
|
-
$.boiler( 'test', {});
|
|
125
|
-
},
|
|
126
|
-
afterEach: function() {
|
|
127
|
-
this.$el.removeData( 'test' );
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
QUnit.test( 'Dom element is cached', function( assert ) {
|
|
132
|
-
assert.expect( 2 );
|
|
133
|
-
|
|
134
|
-
this.$el.test();
|
|
135
|
-
|
|
136
|
-
assert.strictEqual( this.$el[0], this.$el.data( 'test' ).$el[0]);
|
|
137
|
-
assert.strictEqual( this.$el[0], this.$el.data( 'test' ).el );
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
/*
|
|
141
|
-
*
|
|
142
|
-
*/
|
|
143
|
-
|
|
144
|
-
QUnit.module( 'Plugin Methods and Variables', {
|
|
145
|
-
// This will run before each test in this module.
|
|
146
|
-
beforeEach: function() {
|
|
147
|
-
this.$el = $( '<div>' );
|
|
148
|
-
|
|
149
|
-
$.boiler( 'test', {
|
|
150
|
-
pub: 'public',
|
|
151
|
-
_private: true,
|
|
152
|
-
exclaim: function( input ) {
|
|
153
|
-
return input + '!';
|
|
154
|
-
},
|
|
155
|
-
getThis: function() {
|
|
156
|
-
return this;
|
|
157
|
-
},
|
|
158
|
-
setText: function( val ) {
|
|
159
|
-
this.$el.text( val );
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
this.$el.test();
|
|
164
|
-
},
|
|
165
|
-
afterEach: function() {
|
|
166
|
-
this.$el.removeData( 'test' );
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
QUnit.test( 'Plugin object gives access to passed objects', function( assert ) {
|
|
171
|
-
assert.expect( 2 );
|
|
172
|
-
|
|
173
|
-
assert.strictEqual( this.$el.data( 'test' ).pub, 'public' );
|
|
174
|
-
assert.strictEqual( this.$el.data( 'test' ).exclaim( 'itemTwo' ), 'itemTwo!' );
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
QUnit.test( 'Easily set public variables', function( assert ) {
|
|
178
|
-
assert.expect( 1 );
|
|
179
|
-
|
|
180
|
-
this.$el.test( 'pub', 'foo' );
|
|
181
|
-
|
|
182
|
-
assert.strictEqual( this.$el.data( 'test' ).pub, 'foo' );
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
QUnit.test( "'this' gives context to plugin within method", function( assert ) {
|
|
186
|
-
assert.expect( 1 );
|
|
187
|
-
|
|
188
|
-
assert.strictEqual( this.$el.data( 'test' ).getThis(), this.$el.data( 'test' ));
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
QUnit.test( 'Easily call methods', function( assert ) {
|
|
192
|
-
assert.expect( 1 );
|
|
193
|
-
|
|
194
|
-
this.$el.test( 'setText', 'Hello World!' );
|
|
195
|
-
|
|
196
|
-
assert.strictEqual( this.$el.text(), 'Hello World!' );
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
/*
|
|
200
|
-
*
|
|
201
|
-
*/
|
|
202
|
-
|
|
203
|
-
QUnit.module( 'Settings', {
|
|
204
|
-
// This will run before each test in this module.
|
|
205
|
-
beforeEach: function() {
|
|
206
|
-
this.$el = $( '#js-test-1' );
|
|
207
|
-
|
|
208
|
-
$.boiler( 'test', {
|
|
209
|
-
defaults: {
|
|
210
|
-
one: '1',
|
|
211
|
-
two: '2',
|
|
212
|
-
three: '3'
|
|
213
|
-
},
|
|
214
|
-
data: [ 'one' ]
|
|
215
|
-
});
|
|
216
|
-
},
|
|
217
|
-
afterEach: function() {
|
|
218
|
-
this.$el.removeData( 'test' );
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
QUnit.test( 'Defaults are cached', function( assert ) {
|
|
223
|
-
assert.expect( 1 );
|
|
224
|
-
|
|
225
|
-
this.$el.test();
|
|
226
|
-
|
|
227
|
-
assert.deepEqual( this.$el.data( 'test' ).defaults, {
|
|
228
|
-
one: '1',
|
|
229
|
-
two: '2',
|
|
230
|
-
three: '3'
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
QUnit.test( 'Data attributes are cached', function( assert ) {
|
|
235
|
-
assert.expect( 1 );
|
|
236
|
-
|
|
237
|
-
this.$el.test();
|
|
238
|
-
|
|
239
|
-
assert.deepEqual( this.$el.data( 'test' ).data, {
|
|
240
|
-
one: 'ONE'
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
QUnit.test( 'User options are cached', function( assert ) {
|
|
245
|
-
assert.expect( 1 );
|
|
246
|
-
|
|
247
|
-
this.$el.test({
|
|
248
|
-
foo: 'bar'
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
assert.deepEqual( this.$el.data( 'test' ).options, {
|
|
252
|
-
foo: 'bar'
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
QUnit.test( 'Settings properly give priority to data > options > defaults', function( assert ) {
|
|
257
|
-
assert.expect( 1 );
|
|
258
|
-
|
|
259
|
-
this.$el.test({
|
|
260
|
-
one: 'one',
|
|
261
|
-
two: 'two'
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
assert.deepEqual( this.$el.data( 'test' ).settings, {
|
|
265
|
-
one: 'ONE',
|
|
266
|
-
two: 'two',
|
|
267
|
-
three: '3'
|
|
268
|
-
});
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
/*
|
|
272
|
-
*
|
|
273
|
-
*/
|
|
274
|
-
|
|
275
|
-
QUnit.module( 'Events', {
|
|
276
|
-
// This will run before each test in this module.
|
|
277
|
-
beforeEach: function() {
|
|
278
|
-
this.$el = $( '<div>' );
|
|
279
|
-
},
|
|
280
|
-
afterEach: function() {
|
|
281
|
-
this.$el.removeData( 'test' );
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
QUnit.test( 'Events run properly', function( assert ) {
|
|
286
|
-
assert.expect( 2 );
|
|
287
|
-
|
|
288
|
-
$.boiler( 'test', {
|
|
289
|
-
events: {
|
|
290
|
-
click: 'onClick',
|
|
291
|
-
mouseenter: 'onHover'
|
|
292
|
-
},
|
|
293
|
-
foo: 'bar',
|
|
294
|
-
onClick: function() {
|
|
295
|
-
this.foo = 'click';
|
|
296
|
-
},
|
|
297
|
-
onHover: function() {
|
|
298
|
-
this.foo = 'hover';
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
this.$el.test();
|
|
303
|
-
|
|
304
|
-
this.$el.trigger( 'click' );
|
|
305
|
-
assert.strictEqual( this.$el.data( 'test' ).foo, 'click' );
|
|
306
|
-
|
|
307
|
-
this.$el.trigger( 'mouseenter' );
|
|
308
|
-
assert.strictEqual( this.$el.data( 'test' ).foo, 'hover' );
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
QUnit.test( 'Propogated events run properly', function( assert ) {
|
|
312
|
-
assert.expect( 3 );
|
|
313
|
-
|
|
314
|
-
$.boiler( 'test', {
|
|
315
|
-
events: {
|
|
316
|
-
'click li span': 'onClick'
|
|
317
|
-
},
|
|
318
|
-
onClick: function( e, el ) {
|
|
319
|
-
$( el ).addClass( 'is-clicked' );
|
|
320
|
-
}
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
$( '#js-test-3' ).test();
|
|
324
|
-
$( '#js-target-1' ).click();
|
|
325
|
-
$( '#js-target-2' ).click();
|
|
326
|
-
$( '#js-target-3' ).click();
|
|
327
|
-
|
|
328
|
-
assert.ok( $( '#js-target-1' ).hasClass( 'is-clicked' ));
|
|
329
|
-
assert.ok( !$( '#js-target-2' ).hasClass( 'is-clicked' ));
|
|
330
|
-
assert.ok( $( '#js-target-3' ).hasClass( 'is-clicked' ));
|
|
331
|
-
});
|
|
332
|
-
});
|