Skip to content

Instantly share code, notes, and snippets.

@Takazudo
Created February 15, 2012 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Takazudo/1837821 to your computer and use it in GitHub Desktop.
Save Takazudo/1837821 to your computer and use it in GitHub Desktop.
(function() {
var SomeUI;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
SomeUI = (function() {
function SomeUI($el) {
this.$el = $el;
this.$content = $el.find('.content');
this.$button1 = $el.find('.button1');
this.$button2 = $el.find('.button2');
this._eventify();
}
SomeUI.prototype._eventify = function() {
this.$button1.click(__bind(function() {
return this.instantToggle();
}, this));
this.$button2.click(__bind(function() {
return this.delayedToggle();
}, this));
return this;
};
SomeUI.prototype.instantToggle = function() {
this.$content.fadeToggle();
return this;
};
SomeUI.prototype.delayedToggle = function() {
setTimeout((__bind(function() {
return this.$content.fadeToggle();
}, this)), 1000);
return this;
};
return SomeUI;
})();
$.fn.someUI = function() {
return this.each(function() {
return new SomeUI($(this));
});
};
$(function() {
return $('.someUI').someUI();
});
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment