/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011 * http://benalman.com/ * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */ (function($) { var o = $({}); $.subscribe = function() { o.on.apply(o, arguments); }; $.unsubscribe = function() { o.off.apply(o, arguments); }; $.publish = function() { o.trigger.apply(o, arguments); }; $.multiarmed = function (a){ var events = a.events, callback = a.callback, stored = {}, fired = 0, slice = Array.prototype.slice; return function (e){ var idxE = $.inArray(e.type, events), type = e.type; if ( -1 === idxE ) return true; stored[type] = slice.call(arguments, 1); delete events[idxE]; fired += 1; if (fired === events.length){ callback.call(a.context || {}, stored); } }; }; }(jQuery));