Mercurial > nebulaweb3
comparison default/node_modules/shoestring/src/events/trigger.js @ 0:1d038bc9b3d2 default tip
Up:default
author | Liny <dev@neowd.com> |
---|---|
date | Sat, 31 May 2025 09:21:51 +0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1d038bc9b3d2 |
---|---|
1 //>>excludeStart("exclude", pragmas.exclude); | |
2 define([ "shoestring" ], function(){ | |
3 //>>excludeEnd("exclude"); | |
4 | |
5 /** | |
6 * Trigger an event on each of the DOM elements in the current set. | |
7 * | |
8 * @param {string} event The event(s) to trigger. | |
9 * @param {object} args Arguments to append to callback invocations. | |
10 * @return shoestring | |
11 * @this shoestring | |
12 */ | |
13 shoestring.fn.trigger = function( event, args ){ | |
14 var evts = event.split( " " ); | |
15 | |
16 return this.each(function(){ | |
17 var split, evt, namespace; | |
18 for( var i = 0, il = evts.length; i < il; i++ ){ | |
19 split = evts[ i ].split( "." ), | |
20 evt = split[ 0 ], | |
21 namespace = split.length > 0 ? split[ 1 ] : null; | |
22 | |
23 if( evt === "click" ){ | |
24 if( this.tagName === "INPUT" && this.type === "checkbox" && this.click ){ | |
25 this.click(); | |
26 return false; | |
27 } | |
28 } | |
29 | |
30 if( doc.createEvent ){ | |
31 var event = doc.createEvent( "Event" ); | |
32 event.initEvent( evt, true, true ); | |
33 event._args = args; | |
34 event._namespace = namespace; | |
35 | |
36 this.dispatchEvent( event ); | |
37 } | |
38 } | |
39 }); | |
40 }; | |
41 | |
42 //>>excludeStart("exclude", pragmas.exclude); | |
43 }); | |
44 //>>excludeEnd("exclude"); |