Skip to content

Commit

Permalink
Moved common flash rendering functionality into its own plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
baphled committed Jun 25, 2010
1 parent e0316a7 commit 89f7f70
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions public/javascripts/jquery.render.flash.message.js
@@ -0,0 +1,30 @@
(function($) {
/**
* A simple flash message render used for when we return an AJAX response
* @todo Add optional animation functionality
**/
$.fn.renderFlashMessage = function(options) {
var opts = $.extend({}, $.fn.renderFlashMessage.defaults, options);

return this.each(function() {
var $this = $(this),
$flashDiv = $("<div>").addClass("flash"),
$flashNoticeDiv = $("<div>").addClass("notice").html(opts.flashMessage);

$this.before($flashDiv.html($flashNoticeDiv));
});

// private function for debugging
function debug($obj) {
if (window.console && window.console.log) {
window.console.log($obj);
}
}
};

// default options
$.fn.renderFlashMessage.defaults = {
flashMessage: 'Default flash message'
};

})(jQuery);

0 comments on commit 89f7f70

Please sign in to comment.