0
+ var addMethods = function(source) {
0
+ var ancestor = this.superclass && this.superclass.prototype;
0
+ var properties = $.keys(source);
0
+ if (!$.keys({ toString: true }).length) properties.push("toString", "valueOf");
0
+ for (var i = 0, length = properties.length; i < length; i++) {
0
+ var property = properties[i], value = source[property];
0
+ if (ancestor && $.isFunction(value) && $.argumentNames(value)[0] == "$super") {
0
+ var method = value, value = $.extend($.wrap((function(m) {
0
+ return function() { return ancestor[m].apply(this, arguments) };
0
+ })(property), method), {
0
+ valueOf: function() { return method },
0
+ toString: function() { return method.toString() }
0
+ this.prototype[property] = value;
0
+ for (var key in obj) keys.push(key);
0
+ argumentNames: function(func) {
0
+ var names = func.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(/, ?/);
0
+ return names.length == 1 && !names[0] ? [] : names;
0
+ bind: function(func, scope) {
0
+ return func.apply(scope, $.makeArray(arguments));
0
+ wrap: function(func, wrapper) {
0
+ return wrapper.apply(this, [$.bind(__method, this)].concat($.makeArray(arguments)));
0
+ var parent = null, properties = $.makeArray(arguments);
0
+ if ($.isFunction(properties[0])) parent = properties.shift();
0
+ var klass = function() {
0
+ this.initialize.apply(this, arguments);
0
+ klass.superclass = parent;
0
+ klass.subclasses = [];
0
+ klass.addMethods = addMethods;
0
+ var subclass = function() { };
0
+ subclass.prototype = parent.prototype;
0
+ klass.prototype = new subclass;
0
+ parent.subclasses.push(klass);
0
+ for (var i = 0; i < properties.length; i++)
0
+ klass.addMethods(properties[i]);
0
+ if (!klass.prototype.initialize)
0
+ klass.prototype.initialize = function() {};
0
+ klass.prototype.constructor = klass;
0
+ var bindEvents = function(instance) {
0
+ for (var member in instance) {
0
+ if (member.match(/^on(.+)/) && typeof instance[member] == 'function') {
0
+ instance.element.bind(RegExp.$1, $.bind(instance[member], instance));
0
+ var attachBehavior = function(el, behavior, args) {
0
+ var instance = { element: $(el) };
0
+ instance.__proto__ = behavior.prototype;
0
+ behavior.apply(instance, args);
0
+ if (!behavior.instances) behavior.instances = [];
0
+ behavior.instances.push(instance);
0
+ var args = $.makeArray(arguments), behavior = args.shift();
0
+ if ($.livequery && this.selector) {
0
+ this.livequery(function() {
0
+ attachBehavior(this, behavior, args);
0
+ return this.each(function() {
0
+ attachBehavior(this, behavior, args);
0
+ attachAndReturn: function() {
0
+ var args = $.makeArray(arguments), behavior = args.shift();
0
+ return $.map(this, function(el) {
0
+ return attachBehavior(el, behavior, args);
0
+ initialize: function(options) {
0
+ if (this.element.attr('nodeName') == 'FORM') this.element.attach(Remote.Form, options);
0
+ else this.element.attach(Remote.Link, options);
0
+ Remote.Base = $.klass({
0
+ initialize : function(options) {
0
+ this.options = $.extend({
0
+ _makeRequest : function(options) {
0
+ Remote.Link = $.klass(Remote.Base, {
0
+ var options = $.extend({ url: this.element.attr('href'), type: 'GET' }, this.options);
0
+ return this._makeRequest(options);
0
+ Remote.Form = $.klass(Remote.Base, {
0
+ onclick: function(e) {
0
+ var target = e.target;
0
+ if ($.inArray(target.nodeName.toLowerCase(), ['input', 'button']) >= 0 && target.type == 'submit')
0
+ this._submitButton = target;
0
+ onsubmit: function() {
0
+ var data = this.element.serializeArray();
0
+ if (this._submitButton) data.push({ name: this._submitButton.name, value: this._submitButton.value });
0
+ var options = $.extend({
0
+ url : this.element.attr('action'),
0
+ type : this.element.attr('method') || 'GET',
0
+ this._makeRequest(options);
0
+ beforeSend: function(xhr) {
0
+ xhr.setRequestHeader("Accept", "text/javascript, text/html, application/xml, text/xml, */*");
0
\ No newline at end of file