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

Commit a4f3f73

Browse files
committed
Added optional callback arguments for open/close
1 parent c65fbcf commit a4f3f73

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

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 `0.6.4`. Releases will be numbered in following format:
24+
The current version is `0.6.6`. Releases will be numbered in following format:
2525

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

modal.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @name Simple modal
33
* @author Matt Hinchliffe
44
* @modified 08/03/2012
5-
* @version 0.6.5
5+
* @version 0.6.6
66
* @requires jQuery 1.7+
77
* @description A simple modal overlay
88
* @example
@@ -127,7 +127,7 @@
127127
/**
128128
* Open
129129
*
130-
* @description Open the modal window
130+
* @description Populate and open the modal window
131131
* @param {object} content
132132
* @param {function} callback
133133
*/
@@ -171,39 +171,51 @@
171171
this.align();
172172
this.isOpen = true;
173173

174+
// Callbacks
174175
if (this.opts.onopen)
175176
{
176177
this.opts.onopen.call(this);
177178
}
179+
if (callback)
180+
{
181+
callback.call(this);
182+
}
178183
},
179184

180185
/**
181186
* Update
182187
*
183188
* @description Change the modal window contents
184-
* @param content
189+
* @param {object} content
190+
* @param {function} callback
185191
*/
186-
update: function(content)
192+
update: function(content, callback)
187193
{
188194
this.content.html(content);
189195

190196
if (this.isOpen)
191197
{
192198
this.align();
193199

200+
// Callbacks
194201
if (this.opts.onupdate)
195202
{
196203
this.opts.onupdate.call(this);
197204
}
205+
if (callback)
206+
{
207+
callback.call(this);
208+
}
198209
}
199210
},
200211

201212
/**
202213
* Close
203214
*
204215
* @description Close the modal window and clear contents
216+
* @param {function} callback
205217
*/
206-
close: function()
218+
close: function(callback)
207219
{
208220
if ( ! this.isInitialized || ! this.isOpen)
209221
{
@@ -226,10 +238,15 @@
226238

227239
this.isOpen = false;
228240

241+
// Callbacks
229242
if (this.opts.onclose)
230243
{
231244
this.opts.onclose.call(this);
232245
}
246+
if (callback)
247+
{
248+
callback.call(this);
249+
}
233250
}
234251
};
235252

0 commit comments

Comments
 (0)