Sha256: 6333346a8196572ce4e999c828414e9fd50f73fa6fce35354b377c2fae5218fe
Contents?: true
Size: 1.43 KB
Versions: 46
Compression:
Stored size: 1.43 KB
Contents
pageflow.WidgetTypes = pageflow.Object.extend({ initialize: function() { this._clientSideConfigs = {}; this._optionalRoles = {}; }, register: function(name, config) { if (this._setup) { throw 'Widget types already set up. Register widget types before initializers run.'; } this._clientSideConfigs[name] = config; }, setup: function(serverSideConfigsByRole) { this._setup = true; this._widgetTypesByName = {}; var roles = _.keys(serverSideConfigsByRole); this._widgetTypesByRole = roles.reduce(_.bind(function(result, role) { result[role] = serverSideConfigsByRole[role].map(_.bind(function(serverSideConfig) { var clientSideConfig = this._clientSideConfigs[serverSideConfig.name] || {}; var widgetType = new pageflow.WidgetType(serverSideConfig, clientSideConfig); this._widgetTypesByName[serverSideConfig.name] = widgetType; return widgetType; }, this)); return result; }, this), {}); }, findAllByRole: function(role) { return this._widgetTypesByRole[role] || []; }, findByName: function(name) { if (!this._widgetTypesByName[name]) { throw('Could not find widget type with name "' + name +'"'); } return this._widgetTypesByName[name]; }, registerRole: function(role, options) { this._optionalRoles[role] = options.isOptional; }, isOptional: function(role) { return !!this._optionalRoles[role]; } });
Version data entries
46 entries across 46 versions & 1 rubygems