Skip to content

Commit

Permalink
Implemented 'callback' option to enable chaining.
Browse files Browse the repository at this point in the history
  • Loading branch information
alup committed Nov 9, 2010
1 parent e650165 commit 3760c43
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions jquery.notifyBar.js
Expand Up @@ -45,6 +45,9 @@ jQuery.notifyBar = function(settings) {
//Set up own class
notifyBarNS.cls = settings.cls || "";

//Set your callback function
notifyBarNS.callback = settings.callback || null;

if( notifyBarNS.jqObject) {
bar = notifyBarNS.jqObject;
notifyBarNS.html = bar.html();
Expand Down Expand Up @@ -79,7 +82,12 @@ jQuery.notifyBar = function(settings) {
if( notifyBarNS.jqObject) {
jQuery("#" + id).slideUp(animDuration);
} else {
jQuery("#" + id).slideUp(animDuration, function() { jQuery("#" + id).remove() });
jQuery("#" + id).slideUp(animDuration, function() {
jQuery("#" + id).remove();
if(notifyBarNS.callback && $.isFunction(notifyBarNS.callback)){
notifyBarNS.callback.call();
}
});
}
return false;
});
Expand All @@ -89,10 +97,20 @@ jQuery.notifyBar = function(settings) {
if( notifyBarNS.sticky == false) {
// If taken from DOM dot not remove just hide
if( notifyBarNS.jqObject) {
setTimeout("jQuery('#" + id + "').slideUp(" + animDuration +", function() {jQuery('#" + id + "')});", notifyBarNS.duration + animDuration);
var callable = "jQuery('#" + id + "').slideUp(" + animDuration +", function() {jQuery('#" + id + "');\
if(notifyBarNS.callback && $.isFunction(notifyBarNS.callback)){\
notifyBarNS.callback.call();\
}\
});";
setTimeout(callable, notifyBarNS.duration + animDuration);
} else {
setTimeout("jQuery('#" + id + "').slideUp(" + animDuration +", function() {jQuery('#" + id + "').remove()});", notifyBarNS.duration + animDuration);
var callable = "jQuery('#" + id + "').slideUp(" + animDuration +", function() {jQuery('#" + id + "').remove();\
if(notifyBarNS.callback && $.isFunction(notifyBarNS.callback)){\
notifyBarNS.callback.call();\
}\
});";
setTimeout(callable, notifyBarNS.duration + animDuration);
}
}

})(jQuery) };
})(jQuery) };

0 comments on commit 3760c43

Please sign in to comment.