Permalink
Browse files

IE8 fixes:

- added string.trim(),
- less.js usage for <= IE8
- base class for event dispatcher
- event dispatcher 'applies' w/o params when no params were passed
  • Loading branch information...
sdengineering77 committed Apr 4, 2013
1 parent 3a50b1b commit 68409dde2f6930e0095069e43731b87372a5bac9
@@ -18,6 +18,7 @@
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<script src="/static/script/lib/less.js"></script>
<![endif]-->
<!--[if lt IE 8]>
<link href="/static/styles/css/ie7andbelow.css" rel="stylesheet"/>
@@ -57,8 +57,8 @@ var Game = base2.Base.extend({
jQuery('.equal-cols-game').equalHeights('.col-game');
setTimeout(jQuery.proxy(function() {
this.videoplayer.addEvent("tick", this.onVideoTick.bind(this));
this.videoplayer.addEvent("fragmentEnd", this.endGame.bind(this));
this.videoplayer.addEvent("tick", jQuery.proxy(this.onVideoTick, this));
this.videoplayer.addEvent("fragmentEnd", jQuery.proxy(this.endGame, this));
this.videoplayer.play();
@@ -193,7 +193,7 @@ var Game = base2.Base.extend({
endGame: function() {
clearInterval(this.updateIntervalId);
location.href = "/game/" + this.gameId + "/recap/" + this.lastKnownUserId;
window.location.href = "/game/" + this.gameId + "/recap/" + this.lastKnownUserId;
}
});
@@ -4,6 +4,13 @@ var details;
var vidPlayerWidth = 618;
var vidPlayerHeight = 351;
if (typeof String.prototype.trim !== 'function') {
window.alert('create String.prototype.trim');
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
}
}
jQuery(function() {
// on-click of ...:
@@ -1,6 +1,33 @@
var NPOPlayer = base2.Base.extend({
var EventBase = base2.Base.extend({
evtHandles : [],
addEvent : function(evtName, handle) {
this.evtHandles.push({
evtName : evtName,
handle : handle
});
},
dispatchEvents : function(evtName, params) {
// loop through all event handles, match event names and fire
for ( var i = 0; i < this.evtHandles.length; i++) {
var handler = this.evtHandles[i];
if (handler.evtName == evtName) {
if (params == null || params == undefined || params.length == 0) {
handler.handle.apply(this); // IE 8 doesn't want params if no params present (or something)
} else {
handler.handle.apply(this, params);
}
}
}
return true;
}
});
var NPOPlayer = EventBase.extend({
constructor : function(elementId, config) {
this.evtHandles = [];
this.elementId = elementId;
var seekTime = Math.max(0, config.startTime);
@@ -47,22 +74,6 @@ var NPOPlayer = base2.Base.extend({
return this.elapsed;
},
addEvent : function(evtName, handle) {
this.evtHandles.push({
evtName : evtName,
handle : handle
});
},
dispatchEvents : function(evtName, params) {
// loop through all event handles, match event names and fire
for ( var i = 0; i < this.evtHandles.length; i++) {
if (this.evtHandles[i].evtName == evtName) {
this.evtHandles[i].handle.apply(this, params);
}
}
},
moveTo : function(sec) {
// this.player.sendEvent("SCRUB", sec);
},
@@ -110,9 +121,8 @@ var onSilverlightLoad = function() {
game.initVideoPlayer();
};
var JWPlayer = base2.Base.extend({
var JWPlayer = EventBase.extend({
constructor : function(elementId, imageUrl, sourceUrl) {
this.evtHandles = [];
this.elementId = elementId;
var self = this;
@@ -124,7 +134,7 @@ var JWPlayer = base2.Base.extend({
height: 351,
width: 618,
events: {
onComplete: function() { self.dispatchEvents("fragmentEnd"); },
onComplete: function() { self.dispatchEvents("fragmentEnd"); return true;},
onTime: function() {
var elapsed = Math.ceil(self.player.getPosition() * 1000);
var duration = Math.ceil(self.player.getDuration() * 1000);
@@ -133,6 +143,7 @@ var JWPlayer = base2.Base.extend({
if (duration != 0) {
self.dispatchEvents("tick", [ elapsed, duration ]);
}
return true;
}
}
});
@@ -142,22 +153,6 @@ var JWPlayer = base2.Base.extend({
return Math.ceil(this.player.getPosition() * 1000);
},
addEvent : function(evtName, handle) {
this.evtHandles.push({
evtName : evtName,
handle : handle
});
},
dispatchEvents : function(evtName, params) {
// loop through all event handles, match event names and fire
for ( var i = 0; i < this.evtHandles.length; i++) {
if (this.evtHandles[i].evtName == evtName) {
this.evtHandles[i].handle.apply(this, params);
}
}
},
moveTo : function(sec) {
this.player.seek(sec);
},

0 comments on commit 68409dd

Please sign in to comment.