Commit 81d2e23c authored by Julien Cigar's avatar Julien Cigar
Browse files
parents 98e87967 7438c9e7
...@@ -30,8 +30,12 @@ ...@@ -30,8 +30,12 @@
acceptable. acceptable.
************************************************************************/ ************************************************************************/
/* This is taken from https://developer.mozilla.org and is exactly the /* Array.indexOf
* one specified in ECMA-262. * 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) { if (!Array.prototype.indexOf) {
...@@ -76,8 +80,12 @@ ...@@ -76,8 +80,12 @@
} }
} }
/* This is taken from https://developer.mozilla.org and is exactly the /* Array.lastIndexOf
* one specified in ECMA-262. * 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) { if (!Array.prototype.lastIndexOf) {
...@@ -118,6 +126,16 @@ ...@@ -118,6 +126,16 @@
}; };
} }
/* 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 Str
...@@ -125,16 +143,6 @@ ...@@ -125,16 +143,6 @@
Yeti.Str = new Object() Yeti.Str = new Object()
/* Yeti.Str.trim
* Returns the string stripped of whitespace from both ends.
*/
Yeti.Str.trim = function(src) {
return src.trim ?
src.trim() :
src.replace(/^\s+|\s+$/g, '');
}
/* Yeti.Str.reverse /* Yeti.Str.reverse
* Returns the string reversed. * Returns the string reversed.
*/ */
...@@ -538,7 +546,7 @@ ...@@ -538,7 +546,7 @@
new_cls = new_cls.replace(values[i], ' '); new_cls = new_cls.replace(values[i], ' ');
} }
elem.className = Yeti.Str.trim(new_cls.replace(/\s{2,}/g, ' ')) elem.className = new_cls.replace(/\s{2,}/g, ' ').trim();
} }
} }
......
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