Skip to content

Commit

Permalink
fix arguments bug
Browse files Browse the repository at this point in the history
  • Loading branch information
staaky committed Nov 1, 2014
1 parent 6944b35 commit 199c6b5
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
tests/
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "voila",
"version": "1.0.1",
"version": "1.0.2",
"description": "A jQuery plugin that provides callbacks for images, letting you know when they've loaded.",
"keywords": [
"image",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "voila",
"title": "Voilà",
"version": "1.0.1",
"version": "1.0.2",
"description": "A jQuery plugin that provides callbacks for images, letting you know when they've loaded.",
"keywords": [
"image",
Expand Down
13 changes: 9 additions & 4 deletions src/voila.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
function Voila(elements, options, callback) {
function Voila(elements, opts, cb) {
if (!(this instanceof Voila)) {
return new Voila(elements, options, callback);
return new Voila(elements, opts, cb);
}

var argTypeOne = $.type(arguments[1]),
options = (argTypeOne === 'object' ? arguments[1] : {});
callback = argTypeOne === 'function' ? arguments[1] :
$.type(arguments[2]) === 'function' ? arguments[2] : false;

this.options = $.extend({
render: true
}, $.type(options) == 'object' ? options : callback || {});
}, options);

this.deferred = new jQuery.Deferred();

// if there's a callback, push it onto the stack
if ($.type(callback) == 'function') {
if (callback) {
this.always(callback);
}

Expand Down
15 changes: 10 additions & 5 deletions voila.pkgd.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Voilà - v1.0.1
* Voilà - v1.0.2
* (c) 2014 Nick Stakenburg
*
* MIT License
Expand All @@ -22,19 +22,24 @@ var Supports = {
})()
};

function Voila(elements, options, callback) {
function Voila(elements, opts, cb) {
if (!(this instanceof Voila)) {
return new Voila(elements, options, callback);
return new Voila(elements, opts, cb);
}

var argTypeOne = $.type(arguments[1]),
options = (argTypeOne === 'object' ? arguments[1] : {});
callback = argTypeOne === 'function' ? arguments[1] :
$.type(arguments[2]) === 'function' ? arguments[2] : false;

this.options = $.extend({
render: true
}, $.type(options) == 'object' ? options : callback || {});
}, options);

this.deferred = new jQuery.Deferred();

// if there's a callback, push it onto the stack
if ($.type(callback) == 'function') {
if (callback) {
this.always(callback);
}

Expand Down
4 changes: 2 additions & 2 deletions voila.pkgd.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 199c6b5

Please sign in to comment.