Commit cf4908f1 authored by Julien Cigar's avatar Julien Cigar
Browse files

remove ie8 support

parent 18efb243
......@@ -33,136 +33,6 @@
}
/***********************************************************************
Global Javascript objects
Workarounds for browsers which do not natively support some ECMA
standards.
Although extending the DOM is a very bad idea and considered "evil",
adding missing methods to global javascript objects is perfectly
acceptable.
************************************************************************/
/* Array.indexOf
* Returns the first (least) index of an element within the array equal
* to the specified value, or -1 if none is found.
*
* Implementation is taken from https://developer.mozilla.org and is
* exactly the one specified in ECMA-262.
*/
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
"use strict";
if (this == null) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (len === 0) {
return -1;
}
var n = 0;
if (arguments.length > 0) {
n = Number(arguments[1]);
if (n != n) { // shortcut for verifying if it's NaN
n = 0;
} else if (n != 0 && n != Infinity && n != -Infinity) {
n = (n > 0 || -1) * Math.floor(Math.abs(n));
}
}
if (n >= len) {
return -1;
}
var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
for (; k < len; k++) {
if (k in t && t[k] === searchElement) {
return k;
}
}
return -1;
}
}
/* Array.lastIndexOf
* Returns the last (greatest) index of an element within the array equal
* to the specified value, or -1 if none is found.
*
* Implementation is taken from https://developer.mozilla.org and is
* exactly the one specified in ECMA-262.
*/
if (!Array.prototype.lastIndexOf) {
Array.prototype.lastIndexOf = function(searchElement /*, fromIndex*/) {
"use strict";
if (this == null) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (len === 0) {
return -1;
}
var n = len;
if (arguments.length > 1) {
n = Number(arguments[1]);
if (n != n) {
n = 0;
} else if (n != 0 && n != (1 / 0) && n != -(1 / 0)) {
n = (n > 0 || -1) * Math.floor(Math.abs(n));
}
}
var k = n >= 0 ? Math.min(n, len - 1) : len - Math.abs(n);
for (; k >= 0; k--) {
if (k in t && t[k] === searchElement) {
return k;
}
}
return -1;
};
}
/* Array.forEach
* Executes a provided function once per array element.
*/
if (!Array.prototype.forEach) {
Array.prototype.forEach = function(callable, scope) {
for(var i=0, _len = this.length; i < _len; ++i) {
callable.call(scope, this[i], i, this);
}
}
}
/* String.trim
* Removes whitespace from both ends of the string.
*/
if (!String.prototype.trim) {
String.prototype.trim = function () {
return this.replace(/^\s+|\s+$/g, '');
};
}
/***********************************************************************
Str
************************************************************************/
......@@ -328,103 +198,6 @@
}
/***********************************************************************
JSON
************************************************************************/
Yeti.JSON = {};
/* Yeti.JSON.parse
* Parses a string as JSON and returns the parsed value.
*/
Yeti.JSON.parse = function(data) {
return typeof(JSON) !== 'undefined' ?
JSON.parse(data) :
(function(src) {
// Taken from RFC 4627 (http://tools.ietf.org/html/rfc4627)
var json = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(src.replace(/"(\\.|[^"\\])*"/g, '')));
return json ? eval('(' + json + ')') : null;
})(data);
}
/***********************************************************************
Event
************************************************************************/
Yeti.Evt = {};
/* Yeti.Evt.preventDefault
* Cancels the event if it is cancelable, without stopping further
* propagation of the event.
*/
Yeti.Evt.preventDefault = function(e) {
e.preventDefault ? e.preventDefault()
: e.returnValue = false;
}
/* Yeti.Evt.bind
* Wrapper for .addEventListener and .attachEvent.
*/
Yeti.Evt.bind = function(obj, type, listener, capture) {
if ((type.substr(0,2).toLowerCase()) == 'on') {
type = type.substr(2);
}
if (typeof(capture) != 'boolean') {
capture = false;
}
if (obj.addEventListener) {
obj.addEventListener(type, listener, capture);
} else if (obj.attachEvent) {
obj['__e' + type + listener] = listener;
obj[type + listener] = function() {
obj['__e' + type + listener](window.event);
}
obj.attachEvent('on' + type, obj[type + listener] );
} else {
;
}
}
/* Yeti.Evt.unbind
* Wrapper for .removeEventListener and .detachEvent.
*/
Yeti.Evt.unbind = function(obj, type, listener, capture) {
if ((type.substr(0,2).toLowerCase()) == 'on') {
type = type.substr(2);
}
if (typeof(capture) != 'boolean') {
capture = false;
}
if (obj.removeEventListener) {
obj.removeEventListener(type, listener, capture);
} else if (obj.detachEvent) {
obj.detachEvent('on' + type, obj[type + listener]);
// Prevent a memory leak in IE.
try {
// Check if delete is supported
delete(obj[type + listener]);
delete(obj['__e' + type + listener]);
} catch(e) {
obj[type + listener] = null;
obj['__e' + type + listener] = null;
}
} else {
;
}
}
/***********************************************************************
DOM
************************************************************************/
......@@ -531,35 +304,11 @@
})(elem);
}
/* Yeti.DOM.getElementsByClassName
* Returns a set of elements which have all the given class names.
*/
Yeti.DOM.getElementsByClassName = function(name, src) {
var src = src || document;
return src.getElementsByClassName ?
src.getElementsByClassName(name) :
(function(name, src) {
var class_pattern = new RegExp("(?:^|\\s)" + name + "(?:\\s|$)"),
elems = [],
selection = src.getElementsByTagName('*')
;
for (var i=0, _len=selection.length; i<_len; i++) {
if (class_pattern.test(selection[i].className)) {
elems.push(selection[i]);
}
}
return elems;
})(name, src);
}
/* Yeti.DOM.firstElementTag
* Returns a reference to the first child node of that element which is of
* nodeType 1 and of tag <tag>.
*/
Yeti.DOM.firstElementTag = function(elem, tag) {
var tag = tag.toUpperCase();
for (var i=0, _len=elem.childNodes.length; i<_len; i++) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment