function $W(path){ // var path_parts = path.split('/'); // var wdgt; // for (var i=0; i < path_parts.length; i++){ // wdgt = $('.widget.id-'+path_parts[i]); // } if (Spider.widgets[path]) return Spider.widgets[path]; var wdgt_id = path.replace(/\//g, '-'); var wdgt = $('#'+wdgt_id); if (!wdgt) return null; return Spider.Widget.initFromEl(wdgt); } Spider = function(){}; Spider.widgets = {}; Widgets = function(){}; Spider.Widget = Class.extend({ init: function(container, path, config){ this.el = container; this.path = path; this.backend = new Spider.WidgetBackend(this); this.readyFunctions = []; config = $.extend({}, config); this.config = config; this.model = config.model; Spider.widgets[path] = this; this.events = []; this.startup(); this.ready(); this.applyReady(); }, remote: function(){ var args = Array.prototype.slice.call(arguments); var method = args.shift(); return this.backend.send(method, args); }, onReady: function(callback){ this.readyFunctions.push(callback); callback.apply(this); }, applyReady: function(){ for (var i=0; i