MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / triggerEvent

Method triggerEvent

src/common/commontypes/Events.js:355–393  ·  view source on GitHub ↗

* @function Events.prototype.triggerEvent * @description 触发一个特定的注册事件。 * @param {string} type - 触发事件类型。 * @param {Event} evt - 事件对象。 * @returns {Event|boolean} 监听对象,如果返回是 false,则停止监听。

(type, evt)

Source from the content-addressed store, hash-verified

353 * @returns {Event|boolean} 监听对象,如果返回是 false,则停止监听。
354 */
355 triggerEvent(type, evt) {
356 var listeners = this.listeners[type];
357
358 // fast path
359 if (!listeners || listeners.length == 0) {
360 return undefined;
361 }
362
363 // prep evt object with object & div references
364 if (evt == null) {
365 evt = {};
366 }
367 evt.object = this.object;
368 evt.element = this.element;
369 if (!evt.type) {
370 evt.type = type;
371 }
372
373 // execute all callbacks registered for specified type
374 // get a clone of the listeners array to
375 // allow for splicing during callbacks
376 listeners = listeners.slice();
377 var continueChain;
378 for (var i = 0, len = listeners.length; i < len; i++) {
379 var callback = listeners[i];
380 // bind the context to callback.obj
381 continueChain = callback.func.apply(callback.obj, [evt]);
382
383 if ((continueChain != undefined) && (continueChain === false)) {
384 // if callback returns false, execute no more callbacks.
385 break;
386 }
387 }
388 // don't fall through to other DOM elements
389 if (!this.fallThrough) {
390 Event.stop(evt, true);
391 }
392 return continueChain;
393 }
394
395
396 /**

Callers 15

handleBrowserEventMethod · 0.95
WebMap.jsFile · 0.80
startMethod · 0.80
pauseMethod · 0.80
stopMethod · 0.80
_fireFailedEventMethod · 0.80
getDatasetInfoMethod · 0.80

Calls 1

stopMethod · 0.45

Tested by

no test coverage detected