Skip to content

Commit

Permalink
Updated on/addevent names on components.
Browse files Browse the repository at this point in the history
  • Loading branch information
heff committed Mar 26, 2012
1 parent 9cad8bf commit eff300c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 23 deletions.
21 changes: 15 additions & 6 deletions src/component.js
Expand Up @@ -170,15 +170,24 @@ _V_.Component = _V_.Class.extend({

/* Events
================================================================================ */
addEvent: function(type, fn, uid){
return _V_.addEvent(this.el, type, _V_.proxy(this, fn));
on: function(type, fn, uid){
return _V_.on(this.el, type, _V_.proxy(this, fn));
},
removeEvent: function(type, fn){
return _V_.removeEvent(this.el, type, fn);
// Deprecated name for 'on' function
addEvent: function(){ return this.on.apply(this, arguments); },

off: function(type, fn){
return _V_.off(this.el, type, fn);
},
triggerEvent: function(type, e){
return _V_.triggerEvent(this.el, type, e);
// Deprecated name for 'off' function
removeEvent: function(){ return this.off.apply(this, arguments); },

trigger: function(type, e){
return _V_.trigger(this.el, type, e);
},
// Deprecated name for 'off' function
triggerEvent: function(){ return this.trigger.apply(this, arguments); },

one: function(type, fn) {
_V_.one(this.el, type, _V_.proxy(this, fn));
},
Expand Down
8 changes: 4 additions & 4 deletions src/controls.js
Expand Up @@ -103,7 +103,7 @@ _V_.Button = _V_.Control.extend({

// Blur - Remove keyboard triggers
onBlur: function(){
_V_.removeEvent(document, "keyup", _V_.proxy(this, this.onKeyPress));
_V_.off(document, "keyup", _V_.proxy(this, this.onKeyPress));
}

});
Expand Down Expand Up @@ -420,8 +420,8 @@ _V_.Slider = _V_.Component.extend({

onMouseUp: function(event) {
_V_.unblockTextSelection();
_V_.removeEvent(document, "mousemove", this.onMouseMove, false);
_V_.removeEvent(document, "mouseup", this.onMouseUp, false);
_V_.off(document, "mousemove", this.onMouseMove, false);
_V_.off(document, "mouseup", this.onMouseUp, false);

this.update();
},
Expand Down Expand Up @@ -505,7 +505,7 @@ _V_.Slider = _V_.Component.extend({
},

onBlur: function(event){
_V_.removeEvent(document, "keyup", _V_.proxy(this, this.onKeyPress));
_V_.off(document, "keyup", _V_.proxy(this, this.onKeyPress));
}
});

Expand Down
26 changes: 13 additions & 13 deletions src/player.js
Expand Up @@ -71,11 +71,11 @@ _V_.Player = _V_.Component.extend({

this.addClass("vjs-paused");

this.addEvent("ended", this.onEnded);
this.addEvent("play", this.onPlay);
this.addEvent("pause", this.onPause);
this.addEvent("progress", this.onProgress);
this.addEvent("error", this.onError);
this.on("ended", this.onEnded);
this.on("play", this.onPlay);
this.on("pause", this.onPause);
this.on("progress", this.onProgress);
this.on("error", this.onError);

// When the API is ready, loop through the components and add to the player.
if (options.controls) {
Expand Down Expand Up @@ -256,7 +256,7 @@ _V_.Player = _V_.Component.extend({
// Watch for a native progress event call on the tech element
// In HTML5, some older versions don't support the progress event
// So we're assuming they don't, and turning off manual progress if they do.
this.tech.addEvent("progress", function(){
this.tech.on("progress", function(){

// Remove this listener from the element
this.removeEvent("progress", arguments.callee);
Expand Down Expand Up @@ -293,12 +293,12 @@ _V_.Player = _V_.Component.extend({
manualTimeUpdatesOn: function(){
this.manualTimeUpdates = true;

this.addEvent("play", this.trackCurrentTime);
this.addEvent("pause", this.stopTrackingCurrentTime);
this.on("play", this.trackCurrentTime);
this.on("pause", this.stopTrackingCurrentTime);
// timeupdate is also called by .currentTime whenever current time is set

// Watch for native timeupdate event
this.tech.addEvent("timeupdate", function(){
this.tech.on("timeupdate", function(){

// Remove this listener from the element
this.removeEvent("timeupdate", arguments.callee);
Expand Down Expand Up @@ -570,7 +570,7 @@ _V_.Player = _V_.Component.extend({
if (requestFullScreen) {

// Trigger fullscreenchange event after change
_V_.addEvent(document, requestFullScreen.eventName, this.proxy(function(){
_V_.on(document, requestFullScreen.eventName, this.proxy(function(){
this.isFullScreen = document[requestFullScreen.isFullScreen];

// If cancelling fullscreen, remove event listener.
Expand All @@ -588,7 +588,7 @@ _V_.Player = _V_.Component.extend({
this.pause();
this.unloadTech();

_V_.addEvent(document, requestFullScreen.eventName, this.proxy(function(){
_V_.on(document, requestFullScreen.eventName, this.proxy(function(){
_V_.removeEvent(document, requestFullScreen.eventName, arguments.callee);
this.loadTech(this.techName, { src: this.values.src });
}));
Expand Down Expand Up @@ -626,7 +626,7 @@ _V_.Player = _V_.Component.extend({
this.pause();
this.unloadTech();

_V_.addEvent(document, requestFullScreen.eventName, this.proxy(function(){
_V_.on(document, requestFullScreen.eventName, this.proxy(function(){
_V_.removeEvent(document, requestFullScreen.eventName, arguments.callee);
this.loadTech(this.techName, { src: this.values.src })
}));
Expand Down Expand Up @@ -657,7 +657,7 @@ _V_.Player = _V_.Component.extend({
this.docOrigOverflow = document.documentElement.style.overflow;

// Add listener for esc key to exit fullscreen
_V_.addEvent(document, "keydown", _V_.proxy(this, this.fullWindowOnEscKey));
_V_.on(document, "keydown", _V_.proxy(this, this.fullWindowOnEscKey));

// Hide any scroll bars
document.documentElement.style.overflow = 'hidden';
Expand Down

0 comments on commit eff300c

Please sign in to comment.