Skip to content

Instantly share code, notes, and snippets.

View RStankov's full-sized avatar
🤖
👨‍💻

Radoslav Stankov RStankov

🤖
👨‍💻
View GitHub Profile
/*
var Person = Class.create(function(){
initialize: function(firstName, lastName){
this.firstName = firstName;
this.lastName = lastName;
},
toString: function(){
return this.firstName + ' ' + this.lastName;
}
});
// more on Event.register: https://prototype.lighthouseapp.com/projects/8886/tickets/477-custom-event-register#ticket-477-4
(function(){
// mouse:wheel ( DOMMouseScroll )
function wheel(event){
var realDelta;
// normalize the delta
if (event.detail){
realDelta = -event.detail / 3; // W3C
} else if (event.wheelDelta){
$H(Element.Storage).inject(0, function(m, p){
var registry;
if (p.value.get && (registry = p.value.get('prototype_event_registry'))){
m += registry.values().flatten().size();
}
return m;
});
// bookmarked, witch uses Element.Storage or Event.cache dependent on the Prototype version
(Element.Storage ? $H(Element.Storage).values().slice(1).invoke('get', 'prototype_event_registry').compact() :
//= require "http://gist.github.com/66568"
//= require "http://gist.github.com/162593"
<div class="tab_panel">
<nav>
<ul>
<li class="tab selected" tabindex="1">tab 1</li>
<li class="tab" tabindex="2">tab 2</li>
<li class="tab" tabindex="3">tab 3</li>
</ul>
//= require "http://gist.github.com/66568"
//= require "http://gist.github.com/162593"
<div class="tab-panel">
<nav class="tabs">
<ul>
<li href="#sect-1" tagindex="1">tab 1</li>
<li href="#sect-2" tagindex="2">tab 2</li>
<li href="#sect-3" tagindex="3">tab 3</li>
</ul>
<div class="tab-panel">
<nav class="tabs">
<ul>
<li href="#sect-1" tabindex="1">tab 1</li>
<li href="#sect-2" tabindex="2">tab 2</li>
<li href="#sect-3" tabindex="3">tab 3</li>
</ul>
</nav>
<section id="sect-1"></section>
<section id="sect-2"></section>
Event.allHandlers = function(eventName){
return $H(Element.Storage).inject([], function(m, p){
var registry;
if (!p.value.get || !(registry = p.value.get('prototype_event_registry'))){
return m;
}
if (!eventName){
return m.concat(registry.values().flatten().pluck('handler'));
//
// ------------------------
// Class.Mixin.Delegator
// ------------------------
//
// Usage:
// adding:
// - MyClass.addMethods(Class.Mixin);
// usage (in MyClass):
// this.delegate('element', 'observe', 'setPosition');
<?php
class JsConcatinator {
private $path;
private $included;
public function __construct($path){
$this->path = rtrim($path, '/') . '/';
$this->included = array();
}
(function(){
var CODE_FOR_KEYS = {
8: 'backspace',
9: 'tab',
13: 'return',
27: 'esc',
37: 'left',
38: 'up',
39: 'right',
40: 'down',