mirror of
https://github.com/pebble-dev/clay.git
synced 2026-09-03 07:37:46 -04:00
refactor components to be in a registry.
This commit is contained in:
@@ -18,6 +18,7 @@ var _ = require('../vendor/minified/minified')._;
|
||||
var ClayItem = require('./clay-item');
|
||||
var utils = require('../lib/utils');
|
||||
var ClayEvents = require('./clay-events');
|
||||
var componentStore = require('./component-registry');
|
||||
|
||||
/**
|
||||
* @extends ClayEvents
|
||||
@@ -89,8 +90,20 @@ function ClayConfig(settings, config, $rootContainer) {
|
||||
return _settings;
|
||||
};
|
||||
|
||||
// attach event methods
|
||||
ClayEvents.call(self, $rootContainer);
|
||||
/**
|
||||
* Register a component to Clay. This must be called prior to .build();
|
||||
* @param {{}} component - the clay component to register
|
||||
* @param {string} component.name - the name of the component
|
||||
* @param {string} component.template - HTML template to use for the component
|
||||
* @param {{}} component.manipulator - methods to attach to the component
|
||||
* @param {function} component.manipulator.set - set manipulator method
|
||||
* @param {function} component.manipulator.get - get manipulator method
|
||||
* @param {{}} component.defaults - template defaults
|
||||
* @param {function} [component.initialize] - method to scaffold the component
|
||||
*/
|
||||
self.registerComponent = function(component) {
|
||||
componentStore[component.name] = component;
|
||||
};
|
||||
|
||||
self.build = function() {
|
||||
self.trigger(self.EVENTS.BEFORE_BUILD);
|
||||
@@ -99,6 +112,9 @@ function ClayConfig(settings, config, $rootContainer) {
|
||||
self.trigger(self.EVENTS.AFTER_BUILD);
|
||||
};
|
||||
|
||||
// attach event methods
|
||||
ClayEvents.call(self, $rootContainer);
|
||||
|
||||
/**
|
||||
* Add item(s) to the config
|
||||
* @param {Clay~ConfigItem|array} items
|
||||
|
||||
Reference in New Issue
Block a user