Skip to content

Instantly share code, notes, and snippets.

View roykolak's full-sized avatar

Roy Kolak roykolak

  • Detective.io
  • Chicago, IL USA
View GitHub Profile
(function($){
jQuery.fn.mouseyDialog = function() {
// Classic Class Structure (note: no var, it's exposed for TDD)
MouseyDialog = function(anchor) {
this.anchor = $(anchor);
this.dialog = $(this.anchor.attr('href'));
this.button = $('<a href="#" class="mouseyDialog_close">close</a>');
};
MouseyDialog.prototype = {
(function($){
jQuery.fn.mouseyDialog = function() {
// Classic Class Structure (note: no var, it's exposed for TDD)
MouseyDialog = function(element) {
// Constructor
}
MouseyDialog.prototype = {
sweetMethod: function() {
// Code
.DS_Store
*.swp
*~.nib
build/
*.pbxuser
*.perspective
*.perspectivev3
new Ajax.Request(this.element.readAttribute('href'), {
method:'post',
onSuccess: function(response) {
this.hideSpinner();
$('promotion_list').insert({top: response.responseText}).down('li').hide().appear();
}.bind(this)
});
var JSClassObserver = Class.create({
findElements: function(class_name) {
var self = this;
$('.' + class_name).each(function(index, element) {
if(element.js_attached == null) {
element.js_attached = {};
}
if(element.js_attached[class_name] != true) {
self.attachBehavior(element, index);
element.js_attached[class_name] = true;
var Person = Micro.extend(function(name) {
this.name = name;
});
Person.include({
greet: function() {
print('Hello, ' + this.name + '!');
}
});
var Micro = (function() {
var proxy = function() {};
var wrap = function(zuper, fn) {
return function() {
var saved = this.zuper;
this.zuper = zuper;
try {
return fn.apply(this, arguments);
} finally {
this.zuper = saved;
@roykolak
roykolak / debug.css
Created February 12, 2009 16:44
highlights bad HTML, incomplete tag attributes, and inline javascript
/*
This is a combination of:
http://meyerweb.com/eric/thoughts/2007/09/07/diagnostic-styling/
http://www.nealgrosskopf.com/tech/thread.asp?pid=17
.. with some additional tweaking and additions
*/
/* Empty Attributes */
img[alt=""],
/* Clone and Insert Attacher -------------------------------- */
AttachOnceClass.add('CloneAndInsert', 'js_clone_and_insert', function(jquery_selector) {
// TODO: conside refactoring into a class
jquery_selector.click(function() {
var parent = $(this).parent();
var insert = parent.find('.js_insert');
var clone = parent.find('.js_clone').clone(true);
var count = insert.children().length + 2;
// Recursively make attributes unique in cloned html
@roykolak
roykolak / ObserverAttacher.js
Created January 30, 2009 18:13
Safe observer attaching
function AttachOnce() {
this.behavior($('.' + this.target_class));
this.clean();
}
AttachOnce.prototype.clean = function() {
$('.' + this.target_class).removeClass(this.target_class);
}
AttachOnce.prototype.behavior = function() {
// Will be overwritten.
}