Sha256: 34825473a70a86f887a966231c2a5ca88b6f1b0534f487cce846f4b8d17e9911
Contents?: true
Size: 1.6 KB
Versions: 3
Compression:
Stored size: 1.6 KB
Contents
/* * L.Mixin.Events adds custom events functionality to Leaflet classes */ L.Mixin = {}; L.Mixin.Events = { addEventListener: function (/*String*/ type, /*Function*/ fn, /*(optional) Object*/ context) { var events = this._leaflet_events = this._leaflet_events || {}; events[type] = events[type] || []; events[type].push({ action: fn, context: context || this }); return this; }, hasEventListeners: function (/*String*/ type) /*-> Boolean*/ { var k = '_leaflet_events'; return (k in this) && (type in this[k]) && (this[k][type].length > 0); }, removeEventListener: function (/*String*/ type, /*Function*/ fn, /*(optional) Object*/ context) { if (!this.hasEventListeners(type)) { return this; } for (var i = 0, events = this._leaflet_events, len = events[type].length; i < len; i++) { if ( (events[type][i].action === fn) && (!context || (events[type][i].context === context)) ) { events[type].splice(i, 1); return this; } } return this; }, fireEvent: function (/*String*/ type, /*(optional) Object*/ data) { if (!this.hasEventListeners(type)) { return this; } var event = L.Util.extend({ type: type, target: this }, data); var listeners = this._leaflet_events[type].slice(); for (var i = 0, len = listeners.length; i < len; i++) { listeners[i].action.call(listeners[i].context || this, event); } return this; } }; L.Mixin.Events.on = L.Mixin.Events.addEventListener; L.Mixin.Events.off = L.Mixin.Events.removeEventListener; L.Mixin.Events.fire = L.Mixin.Events.fireEvent;
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
leaflet-ruby-0.3.beta4 | lib/leaflet/src/core/Events.js |
leaflet-ruby-0.3.beta3 | lib/leaflet/src/core/Events.js |
leaflet-ruby-0.3.beta1 | lib/leaflet/src/core/Events.js |