mirror of
https://github.com/pebble-dev/clay.git
synced 2026-08-29 13:26:59 -04:00
WIP - no love for minified.js anymore :(
This commit is contained in:
@@ -29,11 +29,30 @@ var ClayEvents = require('./clay-events');
|
||||
function ClayConfig(settings, config, $rootContainer) {
|
||||
var self = this;
|
||||
|
||||
self.test = Math.random();
|
||||
|
||||
var _settings = _.copyObj(settings);
|
||||
var _items = [];
|
||||
var _itemsById = {};
|
||||
var _itemsByAppKey = {};
|
||||
|
||||
self.EVENTS = {
|
||||
/**
|
||||
* Called before framework has initialized. This is when you would attach your
|
||||
* custom items.
|
||||
* @const
|
||||
*/
|
||||
BEFORE_BUILD: 'BEFORE_BUILD',
|
||||
|
||||
/**
|
||||
* Called after the config has been parsed and all items have their initial value
|
||||
* set
|
||||
* @const
|
||||
*/
|
||||
AFTER_BUILD: 'AFTER_BUILD'
|
||||
};
|
||||
utils.updateProperties(self.EVENTS, {writable: false});
|
||||
|
||||
/**
|
||||
* @param {string} key
|
||||
* @returns {ClayItem}
|
||||
@@ -73,6 +92,13 @@ function ClayConfig(settings, config, $rootContainer) {
|
||||
// attach event methods
|
||||
ClayEvents.call(self, $rootContainer);
|
||||
|
||||
self.build = function() {
|
||||
self.trigger(self.EVENTS.BEFORE_BUILD);
|
||||
// initialize the config
|
||||
_addItems(config, $rootContainer);
|
||||
self.trigger(self.EVENTS.AFTER_BUILD);
|
||||
};
|
||||
|
||||
/**
|
||||
* Add item(s) to the config
|
||||
* @param {Clay~ConfigItem|array} items
|
||||
@@ -114,8 +140,6 @@ function ClayConfig(settings, config, $rootContainer) {
|
||||
// prevent external modifications of properties
|
||||
utils.updateProperties(self, { writable: false, configurable: false });
|
||||
|
||||
// initialize the config
|
||||
_addItems(config, $rootContainer);
|
||||
}
|
||||
|
||||
module.exports = ClayConfig;
|
||||
|
||||
@@ -5,7 +5,7 @@ var $ = require('../vendor/minified/minified').$;
|
||||
/**
|
||||
* Attaches event methods to the context.
|
||||
* Call with ClayEvents.call(yourObject, $eventTarget)
|
||||
* @param {EventEmitter} $eventTarget - An object that will be used as the event
|
||||
* @param {EventEmitter|M} $eventTarget - An object that will be used as the event
|
||||
* target. Must implement EventEmitter
|
||||
* @constructor
|
||||
*/
|
||||
@@ -70,7 +70,7 @@ function ClayEvents($eventTarget) {
|
||||
* @returns {object}
|
||||
*/
|
||||
self.trigger = function(name, eventObj) {
|
||||
$eventTarget.trigger(name, eventObj);
|
||||
$eventTarget.trigger(name);
|
||||
return self;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user