kis-js/src/polyfill.js

52 lines
1.0 KiB
JavaScript
Raw Normal View History

2011-11-02 12:10:58 -04:00
/**
* A module of various browser polyfills
* @file polyfill.js
2012-03-29 11:58:32 -04:00
* @todo create ES5 Foreach polyfill
2011-11-02 12:10:58 -04:00
*/
2011-11-03 16:04:35 -04:00
(function(){
2011-11-02 12:10:58 -04:00
2011-11-03 16:04:35 -04:00
"use strict";
2012-03-29 11:58:32 -04:00
2011-11-03 16:04:35 -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
2011-11-03 16:04:35 -04:00
// --------------------------------------------------------------------------
2012-03-29 11:58:32 -04:00
2011-11-02 12:10:58 -04:00
/**
2011-11-03 16:04:35 -04:00
* String trim function polyfill
2011-11-02 12:10:58 -04:00
*/
2011-11-03 16:04:35 -04:00
if(typeof String.prototype.trim === "undefined")
{
/**
* @private
*/
String.prototype.trim = function()
{
return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, "");
};
}
2011-11-06 17:11:34 -05:00
// --------------------------------------------------------------------------
2012-03-29 11:58:32 -04:00
2011-11-06 17:11:34 -05:00
/**
* event.preventDefault/e.stopPropagation polyfill
* @private
*/
2011-12-12 11:47:20 -05:00
if(typeof Event.preventDefault === "undefined" && typeof window.event !== "undefined")
{
2012-03-29 11:58:32 -04:00
Event.prototype.preventDefault = function()
2011-12-12 11:47:20 -05:00
{
2012-02-23 12:42:33 -05:00
window.event.returnValue = false;
2011-12-12 11:47:20 -05:00
},
Event.prototype.stopPropagation = function()
{
2012-02-23 12:42:33 -05:00
window.event.cancelBubble = true;
2012-03-29 11:58:32 -04:00
}
2011-12-12 11:47:20 -05:00
}
2012-03-29 11:58:32 -04:00
2011-11-03 16:04:35 -04:00
}());