YUI().add("Core.PlaceholderDataCenter", function (Y) { function PlaceholderDataCenter(data){ initializeMembers.call(this, data); } var initializeMembers = function(data) { var me = this, widgets = [], listeners = []; this.setWidget = function (elementId, widget) { var widgetData = { elementId: elementId, widget: widget }; widgets.push(widgetData); for (var i = 0 ; i < listeners.length; ++i) { listeners[i].fn.call(listeners[i].scope, widgetData); } }; this.getWidgetById = function (elementId) { for (var i = 0; i < widgets.length; ++i) { if (widgets[i].elementId == elementId) { return widgets[i].widget; } } return null; }; this.getDataById = function (id) { for (var i = 0; i < data.length; ++i) { if (data[i].id == id) { return data[i].data; } } return null; }; this.onWidgetAdded = function (fn, scope) { listeners.push({ fn: fn, scope: scope }); }; }; Y.Core = Y.Core || {}; Y.Core.PlaceholderDataCenter = PlaceholderDataCenter; });