Skip to content
This repository was archived by the owner on Mar 20, 2018. It is now read-only.

Commit a3ae1fa

Browse files
committed
Merge branch 'master' into gh-pages
2 parents f8c6ba3 + b76ea5c commit a3ae1fa

File tree

11 files changed

+148
-52
lines changed

11 files changed

+148
-52
lines changed

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
node_modules/
2+
3+
.DS_Store
4+
.idea
5+
.svn
6+
7+
*.gz
8+
*.db
9+
*.log
10+
*.bak
11+
*.dat
12+
*.out
13+
*.sublime-project
14+
*.sublime-workspace

Gruntfile.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module.exports = function(grunt) {
2+
3+
grunt.initConfig({
4+
pkg: grunt.file.readJSON('modal.jquery.json'),
5+
uglify: {
6+
options: {
7+
banner: [
8+
'/*!',
9+
' * @name <%= pkg.title %>',
10+
' * @author <%= pkg.author.name %> <<%= pkg.homepage %>>',
11+
' * @modified <%= grunt.template.today("dddd, mmmm dS, yyyy, HH:MM:ss") %>',
12+
' * @version <%= pkg.version %>',
13+
' */'].join('\n')
14+
},
15+
my_target: {
16+
files: {
17+
'dist/modal.js': ['<banner>', 'src/modal.js']
18+
}
19+
}
20+
},
21+
jshint: {
22+
all: ['Gruntfile.js', 'src/*.js'],
23+
options: {
24+
trailing: true,
25+
browser: true,
26+
globals: {
27+
jQuery: true,
28+
define: false,
29+
module: true
30+
}
31+
}
32+
}
33+
});
34+
35+
grunt.loadNpmTasks('grunt-contrib-jshint');
36+
grunt.loadNpmTasks('grunt-contrib-uglify');
37+
38+
grunt.registerTask('default', ['jshint', 'uglify']);
39+
40+
};

README.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ https://github.com/i-like-robots/jQuery-Modal/issues
2121

2222
## Versioning
2323

24-
The current version is `1.0.0`. Releases will be numbered in following format:
24+
The current version is `1.0.1`. Releases will be numbered in following format:
2525

2626
`<major>.<minor>.<patch>`
2727

dist/modal.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

grunt.js

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

index.html

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ <h2>Setup</h2>
6161
</pre>
6262
</figure>
6363

64+
<p>
65+
You can also 'namespace' plugin instances so that multiple modals can be attached to the same parent.
66+
67+
</p>
68+
69+
<figure>
70+
<pre class="syntax"><span class="kd">var</span> <span class="nx">$m</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">'body'</span><span class="p">);</span>
71+
72+
<span class="c1">// Attach two modal windows to the same parent</span>
73+
<span class="nx">$m</span><span class="p">.</span><span class="nx">modal</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="s1">'alpha'</span><span class="p">).</span><span class="nx">modal</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="s1">'beta'</span><span class="p">);</span>
74+
75+
<span class="kd">var</span> <span class="nx">alpha</span> <span class="o">=</span> <span class="nx">$m</span><span class="p">.</span><span class="nx">data</span><span class="p">(</span><span class="s1">'modal_alpha'</span><span class="p">);</span>
76+
<span class="kd">var</span> <span class="nx">beta</span> <span class="o">=</span> <span class="nx">$m</span><span class="p">.</span><span class="nx">data</span><span class="p">(</span><span class="s1">'modal_beta'</span><span class="p">);</span>
77+
</pre>
78+
</figure>
79+
6480
<p>
6581
The simplest example is to open a modal window instance with basic HTML content:
6682
</p>
@@ -211,8 +227,8 @@ <h2>Public methods</h2>
211227
<img style="position:absolute; top:0; right:0; border:0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" />
212228
</a>
213229

214-
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
215-
<script src="js/modal.js"></script>
230+
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
231+
<script src="src/modal.js"></script>
216232
<script>
217233
$(function()
218234
{

js/modal.min.js

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

jQuery-Modal.jquery.json renamed to modal.jquery.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "jQuery-Modal",
3-
"version": "1.0.0",
2+
"name": "modal",
3+
"version": "1.0.2",
44
"title": "jQuery Modal",
55
"description": "Every front-end developer needs their own modal window. The plugin is optimised and customisable and even supports multiple, nestable instances.",
66
"keywords": [
@@ -21,8 +21,8 @@
2121
}
2222
],
2323
"bugs": "https://github.com/i-like-robots/jQuery-Modal/issues",
24-
"homepage": "http://i-like-robots.github.com/jQuery-Modal/",
25-
"demo": "http://i-like-robots.github.com/jQuery-Modal/",
24+
"homepage": "http://i-like-robots.github.io/jQuery-Modal/",
25+
"demo": "http://i-like-robots.github.io/jQuery-Modal/",
2626
"dependencies": {
2727
"jquery": ">=1.7"
2828
}

package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "modal",
3+
"version": "1.0.2",
4+
"title": "jQuery Modal",
5+
"description": "Every front-end developer needs their own modal window. The plugin is optimised and customisable and even supports multiple, nestable instances.",
6+
"keywords": [
7+
"modal",
8+
"lightbox",
9+
"lightweight",
10+
"flexible"
11+
],
12+
"author": {
13+
"name": "Matt Hinchliffe",
14+
"email": "matt+jquery@maketea.co.uk",
15+
"url": "http://maketea.co.uk"
16+
},
17+
"licenses": [
18+
{
19+
"type": "CC BY-SA 3.0",
20+
"url": "http://creativecommons.org/licenses/by-sa/3.0/"
21+
}
22+
],
23+
"bugs": "https://github.com/i-like-robots/jQuery-Modal/issues",
24+
"homepage": "http://i-like-robots.github.io/jQuery-Modal/",
25+
"demo": "http://i-like-robots.github.io/jQuery-Modal/",
26+
"devDependencies": {
27+
"grunt": "0.4.x",
28+
"grunt-contrib-jshint": "0.1.x",
29+
"grunt-contrib-uglify": "0.2.x"
30+
}
31+
}

js/modal.js renamed to src/modal.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/*!
2-
* @name jQuery Modal
3-
* @author Matt Hinchliffe <https://github.com/i-like-robots/jQuery-Modal>
4-
* @modified 2012-12-10
5-
* @version 1.0.0
6-
*/
71
(function( $, undefined ) {
82

93
'use strict';
@@ -218,12 +212,23 @@
218212
};
219213

220214
// jQuery plugin wrapper
221-
$.fn.modal = function( options ) {
215+
$.fn.modal = function( options, namespace ) {
222216
return this.each(function() {
223-
if ( ! $.data(this, 'modal') ) {
224-
$.data(this, 'modal', new Modal(this, options) );
217+
var name = namespace ? 'modal_' + namespace : 'modal';
218+
if ( ! $.data(this, name) ) {
219+
$.data(this, name, new Modal(this, options) );
225220
}
226221
});
227222
};
228223

224+
// AMD and CommonJS module compatibility
225+
if ( typeof define === 'function' && define.amd ){
226+
define(function() {
227+
return Modal;
228+
});
229+
}
230+
else if ( typeof module !== 'undefined' && module.exports ) {
231+
module.exports = Modal;
232+
}
233+
229234
})(jQuery);

tests/qunit.html

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
<div id="qunit"></div>
3232
</section>
3333

34-
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
35-
<script src="../js/modal.js"></script>
34+
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
35+
<script src="../src/modal.js"></script>
3636
<script src="qunit-1.10.0.js"></script>
3737

3838
<script>
@@ -45,7 +45,7 @@
4545

4646
var lifecycle = {
4747
setup: function() {
48-
if ( ! api ) {
48+
if ( ! api) {
4949
$b = $('body').modal();
5050
api = $b.data('modal');
5151
}
@@ -64,6 +64,23 @@
6464
equal(api.isInitialized, false, "Check isInitialized is defined");
6565
});
6666

67+
test("$(collection).modal(null, namespace)", function() {
68+
69+
// Create a new instance
70+
var $m = $(document.body).modal(null, 'namespace');
71+
var api_namespaced = $('body').data('modal_namespace');
72+
73+
// Original
74+
equal(api.target, document.body, "Check modal target defined");
75+
equal(api.isOpen, false, "Check isOpen is defined");
76+
equal(api.isInitialized, false, "Check isInitialized is defined");
77+
78+
// Namespaced
79+
equal(api_namespaced.target, document.body, "Check namespaced modal target defined");
80+
equal(api_namespaced.isOpen, false, "Check namespaced isOpen is defined");
81+
equal(api_namespaced.isInitialized, false, "Check namespaced isInitialized is defined");
82+
});
83+
6784
//
6885
// API tests
6986
//

0 commit comments

Comments
 (0)