This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// inside your beforeEach hook | |
spyOn(window, 'setTimeout').andCallFake(function(fn){ | |
fn.apply(null, [].slice.call(arguments, 2)); | |
return +new Date; | |
}); | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
code snippet by Fabio Miranda Costa | |
Its just for the purpose of understanding how the 'new' operator works. | |
Should work on gecko and webkit. | |
WARNING - DO NOT USE IT ON YOUR PROJECTS | |
*/ | |
var niw = function(_constructor, args){ | |
var newObj = {'__proto__': _constructor.prototype}; | |
var ret = _constructor.apply(newObj, args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
--- | |
Port from the YUI3 event-simulate functionality to vanilla javascript. | |
... | |
*/ | |
(function(global, document){ | |
var mix = function(obj1, obj2){ | |
for (var key in obj2){ | |
obj1[key] = obj2[key]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var crypto = require("crypto"); | |
var repeat = function(str, times){ | |
var _str = str; | |
while(--times){ | |
str += _str; | |
} | |
return str; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// live demo: http://jsbin.com/oxuri5/9 | |
var div = document.createElement('div'); | |
div.setAttribute('attr', 'test'); | |
console.log(div.msMatchesSelector('[attr="test"]'), ' should be true'); | |
console.log(div.msMatchesSelector('[attr^="test"]'), ' should be true'); | |
console.log(div.msMatchesSelector('[attr$="test"]'), ' should be true'); | |
document.body.appendChild(div); | |
console.log(div.msMatchesSelector('[attr="test"]'), ' should be true'); | |
console.log(div.msMatchesSelector('[attr^="test"]'), ' should be true'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(context){ | |
var Configuration = context.Configuration = {}; | |
Configuration.name = 'MooTools Slick'; | |
Configuration.presets = { | |
'slick-1.0': { | |
sets: ['1.0'], | |
helpers: ['1.0'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getParent = function(expression){ | |
var parsed = Slick.parse(expression); | |
parsed = parsed && parsed.expressions; | |
for (var i = parsed.length; i--;){ | |
parsed[i][0] = '!'; | |
} | |
return Slick.find(this, parsed); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
--- | |
script: Elements.From.js | |
description: Returns a collection of elements from a string of html. | |
license: MIT-style license | |
requires: [Element] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!Browser.Element){ | |
Element.parent = Object; | |
Element.ProtoType = {'$family': function(){ return 'element'; }.hide()}; | |
Element.mirror(function(name, method){ | |
Element.ProtoType[name] = method; | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Type.isEnumerable = function(item){ | |
return (typeof item != 'object' && typeof item != 'string' && typeof item.length == 'number'); | |
}; |