kis-js/src/polyfill.js

49 lines
966 B
JavaScript
Raw Normal View History

2011-11-02 12:10:58 -04:00
/**
* A module of various browser polyfills
* @file polyfill.js
*/
/**
* String trim function polyfill
*/
if(typeof String.prototype.trim === "undefined")
{
2011-11-02 12:10:58 -04:00
/**
* @private
2011-11-02 12:10:58 -04:00
*/
String.prototype.trim = function()
2011-11-03 16:04:35 -04:00
{
return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, "");
};
}
// --------------------------------------------------------------------------
2012-03-29 11:58:32 -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
{
window.event.returnValue = false;
},
Event.prototype.stopPropagation = function()
2012-04-05 16:32:05 -04:00
{
window.event.cancelBubble = true;
2012-04-05 16:32:05 -04:00
}
}
2012-03-29 11:58:32 -04:00
// --------------------------------------------------------------------------
/**
* Array.isArray polyfill
*/
if (typeof Array.isArray === "undefined")
{
Array.isArray = function(v)
{
return Object.prototype.toString.apply(v) === '[object Array]';
}
}