kis-js/src/polyfill.js

51 lines
983 B
JavaScript
Raw Normal View History

2011-11-02 12:10:58 -04:00
/**
* A module of various browser polyfills
* @file polyfill.js
*/
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";
// Console.log polyfill for IE 8 stupidity
if(typeof window.console === "undefined")
{
window.console = {
log:function(){}
};
}
// --------------------------------------------------------------------------
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
// --------------------------------------------------------------------------
/**
* event.preventDefault/e.stopPropagation polyfill
* @private
*/
2011-12-12 11:47:20 -05:00
if(typeof Event.preventDefault === "undefined" && typeof window.event !== "undefined")
{
Event.prototype.preventDefault = function()
{
window.event.stop();
},
Event.prototype.stopPropagation = function()
{
window.event.returnValue = false;
}
}
2011-11-06 17:11:34 -05:00
2011-11-03 16:04:35 -04:00
}());