This module is used to provide custom events and convert the objects implementing this interface into an event transmitter.
// ================================================ ================/// Event transmitter module ================================ ============================ (function (global, doc) {var dom = global [Doc. URL. replace (/(#. + | \ W)/g, '')]; Dom. define ("emitter", "data", function () {var firetype = "", blank = "" Var fig =/\ bhover (\. \ s + )? /, Rtypenamespace =/^ ([^ \.] *)? (?: \. (. + ))? $/, Reprop =/[A-Z]/; var system = Dom. event = {special :{}, // used to process individual DOM events BIND: function (types, handler, selector) {// It adds an attribute named uniquenumber to the native event transmitter or any common JS object that can be an event transmitter for associating a cache body, // store the required data in it, and now we store all the objects named @ events in it, // The @ event table is used to place various event types and the corresponding callback function var target = This, events = Dom. _ data (target), nativeemitter = Dom ["@ emitter"] in target, all, TNS, type, namespace, special, handlerobj, hand Lers, FN; If (target. nodetype = 3 | target. nodetype = 8 |! Types | typeof handler! = "Function" |! Events) return; All = {handler: handler, UUID: Dom. UUID ++} // ensure that UUID, bag and callback UUID are consistent all. handler. UUID = All. UUID; If (nativeemitter) {// process DOM Event fn = events. handle | (events. handle = function (e) {return (E | event ). type! = Firetype )? System. handle. apply (fn.tar get, arguments): void 0 ;}); fn.tar get = target; types = types. replace (FIG, "Mouseover $1 mouseout $1")} events = events. events | (events. events = {}); // binds multiple events to types. replace (Dom. rword, function (type) {TNS = rtypenamespace.exe C (type) | []; type = TNS [1]; // obtain the event type namespace = (TNS [2] | ""). split (". "). sort (); // get the namespace // The Event impersonate is only used for native event transmitter special = nativeemitte R & system. Special [type] | |{}; type = (selector? Special. delegatetype: Special. bindtype) | type; Special = nativeemitter & system. special [type] | |{}; handlerobj = Dom. mix ({type: type, origtype: TNS [1], selector: selector, namespace: namespace. join (". ")}, all); // create event queue handlers = events [type] = events [type] | []; // only the native event transmitter can bind the DOM level2 multi-cast event if (nativeemitter &&! Handlers. Length) {If (! Special. setup | special. setup (target, selector, FN) = false) {// bind a global callback to this event type of the element. Your callback will execute DOM in this callback. BIND (target, type, FN ,!! Selector)} handlers. push (handlerobj) ;}}, unbind: function (types, handler, selector) {var target = This, events = Dom. _ data (target, "events") if (! Events) return; var T, TNS, type, namespace, origcount, nativeemitter = Dom ["@ emitter"] in target, J, special, handlers, handlerobj; types = nativeemitter? (Types | ""). replace (FIG, "Mouseover $1 mouseout $1"): types; types = (types | ""). split (""); For (t = 0; t