mirror of
https://github.com/videojs/video.js.git
synced 2025-01-06 06:50:51 +02:00
Added on/off/trigger events to replace addEvent/removeEvent/triggerEvent.
This commit is contained in:
parent
f8b43676ba
commit
d907f4aac2
@ -15,7 +15,7 @@ _V_.extend({
|
|||||||
// It stores the handler function in a separate cache object
|
// It stores the handler function in a separate cache object
|
||||||
// and adds a generic handler to the element's event,
|
// and adds a generic handler to the element's event,
|
||||||
// along with a unique id (guid) to the element.
|
// along with a unique id (guid) to the element.
|
||||||
addEvent: function(elem, type, fn){
|
on: function(elem, type, fn){
|
||||||
var data = _V_.getData(elem), handlers;
|
var data = _V_.getData(elem), handlers;
|
||||||
|
|
||||||
// We only need to generate one handler per element
|
// We only need to generate one handler per element
|
||||||
@ -61,8 +61,10 @@ _V_.extend({
|
|||||||
|
|
||||||
handlers.push(fn);
|
handlers.push(fn);
|
||||||
},
|
},
|
||||||
|
// Deprecated name for 'on' function
|
||||||
|
addEvent: function(){ return _V_.on.apply(this, arguments); },
|
||||||
|
|
||||||
removeEvent: function(elem, type, fn) {
|
off: function(elem, type, fn) {
|
||||||
var data = _V_.getData(elem), handlers;
|
var data = _V_.getData(elem), handlers;
|
||||||
// If no events exist, nothing to unbind
|
// If no events exist, nothing to unbind
|
||||||
if (!data.events) { return; }
|
if (!data.events) { return; }
|
||||||
@ -94,6 +96,8 @@ _V_.extend({
|
|||||||
|
|
||||||
_V_.cleanUpEvents(elem, type);
|
_V_.cleanUpEvents(elem, type);
|
||||||
},
|
},
|
||||||
|
// Deprecated name for 'on' function
|
||||||
|
removeEvent: function(){ return _V_.off.apply(this, arguments); },
|
||||||
|
|
||||||
cleanUpEvents: function(elem, type) {
|
cleanUpEvents: function(elem, type) {
|
||||||
var data = _V_.getData(elem);
|
var data = _V_.getData(elem);
|
||||||
@ -174,7 +178,7 @@ _V_.extend({
|
|||||||
return event;
|
return event;
|
||||||
},
|
},
|
||||||
|
|
||||||
triggerEvent: function(elem, event) {
|
trigger: function(elem, event) {
|
||||||
var data = _V_.getData(elem),
|
var data = _V_.getData(elem),
|
||||||
parent = elem.parentNode || elem.ownerDocument,
|
parent = elem.parentNode || elem.ownerDocument,
|
||||||
type = event.type || event,
|
type = event.type || event,
|
||||||
@ -227,7 +231,9 @@ _V_.extend({
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
|
// Deprecated name for 'on' function
|
||||||
|
triggerEvent: function(){ return _V_.trigger.apply(this, arguments); },
|
||||||
|
|
||||||
one: function(elem, type, fn) {
|
one: function(elem, type, fn) {
|
||||||
_V_.addEvent(elem, type, function(){
|
_V_.addEvent(elem, type, function(){
|
||||||
_V_.removeEvent(elem, type, arguments.callee)
|
_V_.removeEvent(elem, type, arguments.callee)
|
||||||
|
Loading…
Reference in New Issue
Block a user