Skip to content

Commit

Permalink
Merge pull request alexbeletsky#2 from jcutler/patch-2
Browse files Browse the repository at this point in the history
Implement a simple callback when complete
  • Loading branch information
alexbeletsky committed Nov 12, 2011
2 parents 4b25171 + 0aa12f4 commit 6d20266
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions js/github.commits.widget.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(function ($) {
function widget(element, options) {
function widget(element, options, callback) {
this.element = element;
this.options = options;
this.callback = $.isFunction(callback) ? callback : $.noop;
}

widget.prototype = (function() {
Expand All @@ -11,7 +12,7 @@
widget.element.append('<span class="error">Options for widget are not set.</span>');
return;
}

var callback = widget.callback;
var element = widget.element;
var user = widget.options.user;
var repo = widget.options.repo;
Expand All @@ -37,6 +38,7 @@
'</li>');
}
element.append('<br/><h5>by <a href="https://github.com/alexanderbeletsky/github.commits.widget">github.commits.widget</a></h5>');
callback(element);

function avatar(email) {
var emailHash = hex_md5(email);
Expand Down Expand Up @@ -88,8 +90,8 @@

})();

$.fn.githubInfoWidget = function(options) {
var w = new widget(this, options);
$.fn.githubInfoWidget = function(options, callback) {
var w = new widget(this, options, callback);
w.run();

return this;
Expand Down

0 comments on commit 6d20266

Please sign in to comment.