Permalink
Browse files

Merge branch 'feature/changing-addevent-to-on'

  • Loading branch information...
heff committed Mar 26, 2012
2 parents f8b4367 + b52b9a1 commit a671e6b9d8f750b6b62d954e6d9778f048719c2d
Showing with 106 additions and 90 deletions.
  1. +1 −0 CHANGELOG.md
  2. +16 −7 src/component.js
  3. +39 −39 src/controls.js
  4. +12 −6 src/events.js
  5. +27 −27 src/player.js
  6. +11 −11 src/tracks.js
View
@@ -1,3 +1,4 @@
+* Changed addEvent function name to 'on'.
* Removed conflicting array.indexOf function
Added exitFullScreen to support BlackBerry devices (pull/143)
--------------------------------------------------------------------------------
View
@@ -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));
},
@@ -212,7 +221,7 @@ _V_.Component = _V_.Class.extend({
this.readyQueue = [];
// Allow for using event listeners also, in case you want to do something everytime a source is ready.
- this.triggerEvent("ready");
+ this.trigger("ready");
}
},
View
@@ -30,10 +30,10 @@ _V_.ControlBar = _V_.Component.extend({
init: function(player, options){
this._super(player, options);
- player.addEvent("play", this.proxy(function(){
+ player.on("play", this.proxy(function(){
this.fadeIn();
- this.player.addEvent("mouseover", this.proxy(this.fadeIn));
- this.player.addEvent("mouseout", this.proxy(this.fadeOut));
+ this.player.on("mouseover", this.proxy(this.fadeIn));
+ this.player.on("mouseout", this.proxy(this.fadeOut));
}));
},
@@ -46,12 +46,12 @@ _V_.ControlBar = _V_.Component.extend({
fadeIn: function(){
this._super();
- this.player.triggerEvent("controlsvisible");
+ this.player.trigger("controlsvisible");
},
fadeOut: function(){
this._super();
- this.player.triggerEvent("controlshidden");
+ this.player.trigger("controlshidden");
},
lockShowing: function(){
@@ -67,9 +67,9 @@ _V_.Button = _V_.Control.extend({
init: function(player, options){
this._super(player, options);
- this.addEvent("click", this.onClick);
- this.addEvent("focus", this.onFocus);
- this.addEvent("blur", this.onBlur);
+ this.on("click", this.onClick);
+ this.on("focus", this.onFocus);
+ this.on("blur", this.onBlur);
},
createElement: function(type, attrs){
@@ -89,7 +89,7 @@ _V_.Button = _V_.Control.extend({
// Focus - Add keyboard functionality to element
onFocus: function(){
- _V_.addEvent(document, "keyup", _V_.proxy(this, this.onKeyPress));
+ _V_.on(document, "keyup", _V_.proxy(this, this.onKeyPress));
},
// KeyPress (document level) - Trigger click when keys are pressed
@@ -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));
}
});
@@ -149,8 +149,8 @@ _V_.PlayToggle = _V_.Button.extend({
init: function(player, options){
this._super(player, options);
- player.addEvent("play", _V_.proxy(this, this.onPlay));
- player.addEvent("pause", _V_.proxy(this, this.onPause));
+ player.on("play", _V_.proxy(this, this.onPlay));
+ player.on("pause", _V_.proxy(this, this.onPause));
},
buildCSSClass: function(){
@@ -207,8 +207,8 @@ _V_.BigPlayButton = _V_.Button.extend({
init: function(player, options){
this._super(player, options);
- player.addEvent("play", _V_.proxy(this, this.hide));
- player.addEvent("ended", _V_.proxy(this, this.show));
+ player.on("play", _V_.proxy(this, this.hide));
+ player.on("ended", _V_.proxy(this, this.show));
},
createElement: function(){
@@ -234,18 +234,18 @@ _V_.LoadingSpinner = _V_.Component.extend({
init: function(player, options){
this._super(player, options);
- player.addEvent("canplay", _V_.proxy(this, this.hide));
- player.addEvent("canplaythrough", _V_.proxy(this, this.hide));
- player.addEvent("playing", _V_.proxy(this, this.hide));
+ player.on("canplay", _V_.proxy(this, this.hide));
+ player.on("canplaythrough", _V_.proxy(this, this.hide));
+ player.on("playing", _V_.proxy(this, this.hide));
- player.addEvent("seeking", _V_.proxy(this, this.show));
- player.addEvent("error", _V_.proxy(this, this.show));
+ player.on("seeking", _V_.proxy(this, this.show));
+ player.on("error", _V_.proxy(this, this.show));
// Not showing spinner on stalled any more. Browsers may stall and then not trigger any events that would remove the spinner.
// Checked in Chrome 16 and Safari 5.1.2. http://help.videojs.com/discussions/problems/883-why-is-the-download-progress-showing
- // player.addEvent("stalled", _V_.proxy(this, this.show));
+ // player.on("stalled", _V_.proxy(this, this.show));
- player.addEvent("waiting", _V_.proxy(this, this.show));
+ player.on("waiting", _V_.proxy(this, this.show));
},
createElement: function(){
@@ -278,7 +278,7 @@ _V_.CurrentTimeDisplay = _V_.Component.extend({
init: function(player, options){
this._super(player, options);
- player.addEvent("timeupdate", _V_.proxy(this, this.updateContent));
+ player.on("timeupdate", _V_.proxy(this, this.updateContent));
},
createElement: function(){
@@ -308,7 +308,7 @@ _V_.DurationDisplay = _V_.Component.extend({
init: function(player, options){
this._super(player, options);
- player.addEvent("timeupdate", _V_.proxy(this, this.updateContent));
+ player.on("timeupdate", _V_.proxy(this, this.updateContent));
},
createElement: function(){
@@ -348,7 +348,7 @@ _V_.RemainingTimeDisplay = _V_.Component.extend({
init: function(player, options){
this._super(player, options);
- player.addEvent("timeupdate", _V_.proxy(this, this.updateContent));
+ player.on("timeupdate", _V_.proxy(this, this.updateContent));
},
createElement: function(){
@@ -382,13 +382,13 @@ _V_.Slider = _V_.Component.extend({
init: function(player, options){
this._super(player, options);
- player.addEvent(this.playerEvent, _V_.proxy(this, this.update));
+ player.on(this.playerEvent, _V_.proxy(this, this.update));
- this.addEvent("mousedown", this.onMouseDown);
- this.addEvent("focus", this.onFocus);
- this.addEvent("blur", this.onBlur);
+ this.on("mousedown", this.onMouseDown);
+ this.on("focus", this.onFocus);
+ this.on("blur", this.onBlur);
- this.player.addEvent("controlsvisible", this.proxy(this.update));
+ this.player.on("controlsvisible", this.proxy(this.update));
// This is actually to fix the volume handle position. http://twitter.com/#!/gerritvanaaken/status/159046254519787520
// this.player.one("timeupdate", this.proxy(this.update));
@@ -412,16 +412,16 @@ _V_.Slider = _V_.Component.extend({
event.preventDefault();
_V_.blockTextSelection();
- _V_.addEvent(document, "mousemove", _V_.proxy(this, this.onMouseMove));
- _V_.addEvent(document, "mouseup", _V_.proxy(this, this.onMouseUp));
+ _V_.on(document, "mousemove", _V_.proxy(this, this.onMouseMove));
+ _V_.on(document, "mouseup", _V_.proxy(this, this.onMouseUp));
this.onMouseMove(event);
},
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();
},
@@ -491,7 +491,7 @@ _V_.Slider = _V_.Component.extend({
},
onFocus: function(event){
- _V_.addEvent(document, "keyup", _V_.proxy(this, this.onKeyPress));
+ _V_.on(document, "keyup", _V_.proxy(this, this.onKeyPress));
},
onKeyPress: function(event){
@@ -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));
}
});
@@ -602,7 +602,7 @@ _V_.LoadProgressBar = _V_.Component.extend({
init: function(player, options){
this._super(player, options);
- player.addEvent("progress", _V_.proxy(this, this.update));
+ player.on("progress", _V_.proxy(this, this.update));
},
createElement: function(){
@@ -726,7 +726,7 @@ _V_.MuteToggle = _V_.Button.extend({
init: function(player, options){
this._super(player, options);
- player.addEvent("volumechange", _V_.proxy(this, this.update));
+ player.on("volumechange", _V_.proxy(this, this.update));
},
createElement: function(){
@@ -772,7 +772,7 @@ _V_.PosterImage = _V_.Button.extend({
this.hide();
}
- player.addEvent("play", _V_.proxy(this, this.hide));
+ player.on("play", _V_.proxy(this, this.hide));
},
createElement: function(){
@@ -801,7 +801,7 @@ _V_.Menu = _V_.Component.extend({
addItem: function(component){
this.addComponent(component);
- component.addEvent("click", this.proxy(function(){
+ component.on("click", this.proxy(function(){
this.unlockShowing();
}));
},
View
@@ -15,7 +15,7 @@ _V_.extend({
// It stores the handler function in a separate cache object
// and adds a generic handler to the element's event,
// 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;
// We only need to generate one handler per element
@@ -61,8 +61,10 @@ _V_.extend({
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;
// If no events exist, nothing to unbind
if (!data.events) { return; }
@@ -94,6 +96,8 @@ _V_.extend({
_V_.cleanUpEvents(elem, type);
},
+ // Deprecated name for 'on' function
+ removeEvent: function(){ return _V_.off.apply(this, arguments); },
cleanUpEvents: function(elem, type) {
var data = _V_.getData(elem);
@@ -174,7 +178,7 @@ _V_.extend({
return event;
},
- triggerEvent: function(elem, event) {
+ trigger: function(elem, event) {
var data = _V_.getData(elem),
parent = elem.parentNode || elem.ownerDocument,
type = event.type || event,
@@ -227,10 +231,12 @@ _V_.extend({
// }
// }
},
-
+ // Deprecated name for 'on' function
+ triggerEvent: function(){ return _V_.trigger.apply(this, arguments); },
+
one: function(elem, type, fn) {
- _V_.addEvent(elem, type, function(){
- _V_.removeEvent(elem, type, arguments.callee)
+ _V_.on(elem, type, function(){
+ _V_.off(elem, type, arguments.callee)
fn.apply(this, arguments);
});
}
Oops, something went wrong.

0 comments on commit a671e6b

Please sign in to comment.