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(){ | |
function delegateHandler(e){ | |
((this.retrieve('prototype_delegates') || $H()).get(e.eventName || e.type) || []).each(function(pair){ | |
if (element = e.findElement(pair.key)){ | |
pair.value.invoke('call', element, e, element); | |
} | |
}); | |
} | |
function delegate(element, selector, event, handler){ |
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
String.prototype.namespace = function(objects, scope){ | |
scope = scope || window; | |
this.split('.').each(function(name){ | |
if (Object.isUndefined(scope[name])) scope[name] = {}; | |
scope = scope[name]; | |
}); | |
if (objects) Object.extent(scope, objects); | |
return scope; | |
} |
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
// used for setting css styles | |
// example: | |
// setCssRule('tag-name', {display: none}); | |
function setCssRule(selector, styles){ | |
var i, x, sheet, rules; | |
for (x = document.styleSheets.length - 1; 0 <= x ; x--){ | |
sheet = document.styleSheets[x]; | |
rules = sheet.cssRules || sheet.rules; | |
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
Element.addMethods({ | |
unsetStorage: function(element){ | |
if (!(element = $(element))) return; | |
if (element === window){ | |
delete(Element.Storage[0]); | |
} else if (typeof element._prototypeUID !== "undefined") { | |
var uid = element._prototypeUID[0]; | |
if (uid in Element.Storage) | |
delete(Element.Storage[uid]); |
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
// credits to YUI ( http://developer.yahoo.com/yui/ ) | |
// credits to kangax ( Juriy Zaytsev http://thinkweb2.com/projects/prototype/ ) | |
var fire = (function(){ | |
var mouseEvent = /^(click|dblclick|mouseover|mouseout|mousedown|mouseup|mousemove|mouseenter|mouseleave|contextmenu)$/, | |
keyEvent = /^(keydown|keyup|keypress)$/; | |
var defaultOptions = { | |
event: { | |
bubbles: true, | |
cancelable: 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
/* | |
* Usage: | |
* Code: | |
* var Widget = Class.create({ | |
* initialize: function(){ | |
* this.overlay = new Element('div', {className: 'overlay'}); | |
* this.frame = new Element('div', {className: 'frame'}); | |
* this.header = new Element('header'); | |
* this.title = new Element('h2'); | |
* this.section = new Element('section'); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Github - participation graph</title> | |
</head> | |
<body> | |
<script src="http://www.prototypejs.org/assets/2009/6/16/prototype.js" type="text/javascript"></script> | |
<script> | |
var GHPG = Class.create({ | |
initialize: function(data){ |
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
// Lazy loading function | |
Function.prototype.lazyLoad = function(){ | |
var __method = this; | |
function loaded(){ | |
loaded = __method(); | |
delete(__method); | |
return loaded.apply(this, arguments); | |
}; | |
return function(){ |
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(){ | |
function focusInHandler(e){ | |
Event.findElement(e).fire("focus:in"); | |
} | |
function focusOutHandler(e){ | |
Event.findElement(e).fire("focus:out"); | |
} | |
if (document.addEventListener){ | |
document.addEventListener("focus", focusInHandler, 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
/* | |
* $(element).insert({ into: document.body }); | |
*/ | |
Element._insertionTranslations.into = function(element, node){ | |
node.appendChild(element); | |
}; | |
/* | |
* $(element).insert({ instead: element2 }) |
OlderNewer