PageSourceSearch

http://arda-maps.org/opensource/js/timeglider/ba-tinyPubSub.js

js arda-maps.org collected 2026-10-03 00:56:32 UTC 1,621 bytes, 48 lines download raw bytes

1/*!
2 * jQuery Tiny Pub/Sub - v0.6 - 1/10/2011
3 * http://benalman.com/
4 *
5 * Copyright (c) 2010 "Cowboy" Ben Alman
6 * Dual licensed under the MIT and GPL licenses.
7 * http://benalman.com/about/license/
8 */
9
10(function($){
11
12  // Create a "dummy" jQuery object on which to bind, unbind and trigger event
13  // handlers. Note that $({}) works in jQuery 1.4.3+, but because .unbind on
14  // a "plain object" throws errors in older versions of jQuery, an element is
15  // used here.
16  var o = $('<b/>');
17
18  // Subscribe to a topic. Works just like bind, except the passed handler
19  // is wrapped in a function so that the event object can be stripped out.
20  // Even though the event object might be useful, it is unnecessary and
21  // will only complicate things in the future should the user decide to move
22  // to a non-$.event-based pub/sub implementation.
23  $.subscribe = function( topic, fn ) {
24
25    // Call fn, stripping out the 1st argument (the event object).
26    function wrapper() {
27      return fn.apply( this, Array.prototype.slice.call( arguments, 1 ) );
28    }
29
30    // Add .guid property to function to allow it to be easily unbound. Note
31    // that $.guid is new in jQuery 1.4+, and $.event.guid was used before.
32    wrapper.guid = fn.guid = fn.guid || ( $.guid ? $.guid++ : $.event.guid++ );
33
34    // Bind the handler.
35    o.bind( topic, wrapper );
36  };
37
38  // Unsubscribe from a topic. Works exactly like unbind.
39  $.unsubscribe = function() {
40    o.unbind.apply( o, arguments );
41  };
42
43  // Publish a topic. Works exactly like trigger.
44  $.publish = function() {
45    o.trigger.apply( o, arguments );
46  };
47
48})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.