Skip to content

Commit

Permalink
make tag-it work under IE
Browse files Browse the repository at this point in the history
  • Loading branch information
cail committed Jul 8, 2010
1 parent 2eab518 commit 25ad314
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 5 deletions.
45 changes: 45 additions & 0 deletions js/ie-compat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
if (!Array.prototype.filter)
{
Array.prototype.filter = function(fun /*, thisp*/)
{
var len = this.length;
if (typeof fun != "function")
throw new TypeError();

var res = new Array();
var thisp = arguments[1];
for (var i = 0; i < len; i++)
{
if (i in this)
{
var val = this[i]; // in case fun mutates this
if (fun.call(thisp, val, i, this))
res.push(val);
}
}

return res;
};
};
if (!Array.prototype.indexOf)
{
Array.prototype.indexOf = function(elt /*, from*/)
{
var len = this.length;

var from = Number(arguments[1]) || 0;
from = (from < 0)
? Math.ceil(from)
: Math.floor(from);
if (from < 0)
from += len;

for (; from < len; from++)
{
if (from in this &&
this[from] === elt)
return from;
}
return -1;
};
};
10 changes: 5 additions & 5 deletions js/tag-it.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

var el = this;

const BACKSPACE = 8;
const ENTER = 13;
const SPACE = 32;
const COMMA = 44;
const TAB = 9;
var BACKSPACE = 8;
var ENTER = 13;
var SPACE = 32;
var COMMA = 44;
var TAB = 9;

// option defaults
if (!options.itemName) options.itemName = 'item';
Expand Down

0 comments on commit 25ad314

Please sign in to comment.