Skip to content

Instantly share code, notes, and snippets.

module Boo
module Hoo
class Doo
def Zoo
text <<-EOS.gsub(/^ *\|/, '')
|<?xml version="1.0" encoding="UTF-8"?>
|<response>
| <sid>#{sid}</sid>
|</response>
EOS
@kaievns
kaievns / gist:518654
Created August 11, 2010 07:52
RJS1 vs RJS2 example
/**
* the old Autocompleter constructor
* uses RightJS 1 and `Class`
*/
initialize: function(input, options) {
this.input = $(input); // don't low it down!
this.$super(options);
// storing the callbacks so we could detach them later
this._watch = this.watch.bind(this);
@kaievns
kaievns / gist:327969
Created March 10, 2010 15:20
RigthJS safe-mode example
RightJS.run(function(_) {
with (_) {
var Klass = new Class(Observer, {
EVENTS: $w('some darn events'),
initialize: function() {
alert("Holy Jack!")
}
});
@kaievns
kaievns / gist:263054
Created December 24, 2009 06:32
Private method example
var Klass = new Class((function() {
var private_method = function() {
// bla bla bla
};
return {
initialize: function() {
@kaievns
kaievns / gist:243579
Created November 26, 2009 17:17
events delegation in RightJS
Behavior.delegate = function(rules) {
return function(e) {
var element = $(e.target);
for (var selector in rules)
if (element.match(selector)) return rules[selector].apply(this, arguments);
}
};
".something".behave('click', Behavior.delegate({
".foo": function() { return 'foo'; },
@kaievns
kaievns / gist:243381
Created November 26, 2009 10:28
shared behavior in RightJS
var parent_removal_behavior = {
click: function() {
this.parent().hide();
}
};
// assigning to css-rules
".remove_parent".behave(parent_removal_behavior);
".some_other_rule".behave(parent_removal_behavior);