2011-11-02 12:10:58 -04:00
|
|
|
/**
|
|
|
|
* A module of various browser polyfills
|
|
|
|
* @file polyfill.js
|
|
|
|
*/
|
|
|
|
|
2012-04-05 18:39:10 -04:00
|
|
|
// Console.log polyfill for IE 8 stupidity
|
|
|
|
if(typeof window.console === "undefined")
|
|
|
|
{
|
|
|
|
window.console = {
|
|
|
|
log:function(){}
|
|
|
|
};
|
|
|
|
}
|
2012-03-29 11:58:32 -04:00
|
|
|
|
2012-04-05 18:39:10 -04:00
|
|
|
// --------------------------------------------------------------------------
|
2012-03-29 11:58:32 -04:00
|
|
|
|
2012-04-05 18:39:10 -04:00
|
|
|
/**
|
|
|
|
* String trim function polyfill
|
|
|
|
*/
|
|
|
|
if(typeof String.prototype.trim === "undefined")
|
|
|
|
{
|
2011-11-02 12:10:58 -04:00
|
|
|
/**
|
2012-04-05 18:39:10 -04:00
|
|
|
* @private
|
2011-11-02 12:10:58 -04:00
|
|
|
*/
|
2012-04-05 18:39:10 -04:00
|
|
|
String.prototype.trim = function()
|
2011-11-03 16:04:35 -04:00
|
|
|
{
|
2012-04-05 18:39:10 -04:00
|
|
|
return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, "");
|
|
|
|
};
|
|
|
|
}
|
2012-01-24 08:55:21 -05:00
|
|
|
|
2012-04-05 18:39:10 -04:00
|
|
|
// --------------------------------------------------------------------------
|
2012-03-29 11:58:32 -04:00
|
|
|
|
2012-04-05 18:39:10 -04:00
|
|
|
/**
|
|
|
|
* event.preventDefault/e.stopPropagation polyfill
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
if(typeof Event.preventDefault === "undefined" && typeof window.event !== "undefined")
|
|
|
|
{
|
|
|
|
Event.prototype.preventDefault = function()
|
2011-12-12 11:47:20 -05:00
|
|
|
{
|
2012-04-05 18:39:10 -04:00
|
|
|
window.event.returnValue = false;
|
|
|
|
},
|
|
|
|
Event.prototype.stopPropagation = function()
|
2012-04-05 16:32:05 -04:00
|
|
|
{
|
2012-04-05 18:39:10 -04:00
|
|
|
window.event.cancelBubble = true;
|
2012-04-05 16:32:05 -04:00
|
|
|
}
|
2012-04-05 18:39:10 -04:00
|
|
|
}
|
2012-03-29 11:58:32 -04:00
|
|
|
|
2012-04-05 18:39:10 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Array.isArray polyfill
|
|
|
|
*/
|
|
|
|
if (typeof Array.isArray === "undefined")
|
|
|
|
{
|
|
|
|
Array.isArray = function(v)
|
|
|
|
{
|
|
|
|
return Object.prototype.toString.apply(v) === '[object Array]';
|
|
|
|
}
|
|
|
|
}
|