mirror of
https://github.com/pebble-dev/clay.git
synced 2026-08-30 05:46:57 -04:00
JSDoc all the things
This commit is contained in:
@@ -15,14 +15,14 @@ var clayConfig = new ClayConfig(settings, config, $mainForm);
|
||||
clayConfig.on(clayConfig.EVENTS.BEFORE_BUILD, function() {
|
||||
|
||||
// register components here
|
||||
this.registerComponent(require('pebble-clay-components/dist/components/heading'));
|
||||
this.registerComponent(require('pebble-clay-components/dist/components/text'));
|
||||
this.registerComponent(require('pebble-clay-components/dist/components/footer'));
|
||||
this.registerComponent(require('pebble-clay-components/dist/components/input'));
|
||||
this.registerComponent(require('pebble-clay-components/dist/components/color'));
|
||||
this.registerComponent(require('pebble-clay-components/dist/components/select'));
|
||||
this.registerComponent(require('pebble-clay-components/dist/components/toggle'));
|
||||
this.registerComponent(require('pebble-clay-components/dist/components/submit'));
|
||||
this.registerComponent(require('pebble-clay-components').heading);
|
||||
this.registerComponent(require('pebble-clay-components').text);
|
||||
this.registerComponent(require('pebble-clay-components').footer);
|
||||
this.registerComponent(require('pebble-clay-components').input);
|
||||
this.registerComponent(require('pebble-clay-components').color);
|
||||
this.registerComponent(require('pebble-clay-components').select);
|
||||
this.registerComponent(require('pebble-clay-components').toggle);
|
||||
this.registerComponent(require('pebble-clay-components').submit);
|
||||
});
|
||||
|
||||
clayConfig.on(clayConfig.EVENTS.AFTER_BUILD, function() {
|
||||
|
||||
@@ -23,9 +23,9 @@ var manipulators = require('./manipulators');
|
||||
|
||||
/**
|
||||
* @extends ClayEvents
|
||||
* @param settings
|
||||
* @param config
|
||||
* @param $rootContainer
|
||||
* @param {{}} settings - setting that were set from a previous session
|
||||
* @param {[]|{}} config
|
||||
* @param {M} $rootContainer
|
||||
* @constructor
|
||||
*/
|
||||
function ClayConfig(settings, config, $rootContainer) {
|
||||
@@ -39,10 +39,11 @@ function ClayConfig(settings, config, $rootContainer) {
|
||||
|
||||
/**
|
||||
* Add item(s) to the config
|
||||
* @param {Clay~ConfigItem|array} items
|
||||
* @param {M} [$container]
|
||||
* @param {Clay~ConfigItem|array} item
|
||||
* @param {M} $container
|
||||
* @return {void}
|
||||
*/
|
||||
var _addItems = function(item, $container) {
|
||||
function _addItems(item, $container) {
|
||||
if (Array.isArray(item)) {
|
||||
item.forEach(function(item) {
|
||||
_addItems(item, $container);
|
||||
@@ -73,14 +74,15 @@ function ClayConfig(settings, config, $rootContainer) {
|
||||
|
||||
$container.add(clayItem.$element);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Throws if the config has not been built yet.
|
||||
* @param {string} fnName
|
||||
* @returns {boolean}
|
||||
* @private
|
||||
*/
|
||||
var _checkBuilt = function(fnName) {
|
||||
function _checkBuilt(fnName) {
|
||||
if (!_isBuilt) {
|
||||
throw new Error(
|
||||
'ClayConfig not built. build() must be run before ' +
|
||||
@@ -88,7 +90,7 @@ function ClayConfig(settings, config, $rootContainer) {
|
||||
);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
self.EVENTS = {
|
||||
/**
|
||||
@@ -134,8 +136,8 @@ function ClayConfig(settings, config, $rootContainer) {
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} key
|
||||
* @returns {[ClayItem]}
|
||||
* @param {string} type
|
||||
* @returns {Array.<ClayItem>}
|
||||
*/
|
||||
self.getItemsByType = function(type) {
|
||||
_checkBuilt('getItemsByType');
|
||||
@@ -188,6 +190,7 @@ function ClayConfig(settings, config, $rootContainer) {
|
||||
* @param {function} component.manipulator.get - get manipulator method
|
||||
* @param {{}} component.defaults - template defaults
|
||||
* @param {function} [component.initialize] - method to scaffold the component
|
||||
* @return {void}
|
||||
*/
|
||||
ClayConfig.registerComponent = function(component) {
|
||||
var _component = _.copyObj(component);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
var $ = require('../vendor/minified/minified').$;
|
||||
var _ = require('../vendor/minified/minified')._;
|
||||
|
||||
/**
|
||||
* Attaches event methods to the context.
|
||||
* Call with ClayEvents.call(yourObject, $eventTarget)
|
||||
@@ -19,13 +20,19 @@ function ClayEvents($eventTarget) {
|
||||
* @returns {string}
|
||||
* @private
|
||||
*/
|
||||
var _transformEventNames = function(events) {
|
||||
function _transformEventNames(events) {
|
||||
return events.split(' ').map(function(event) {
|
||||
return '|' + event.replace(/^\|/, '');
|
||||
}).join(' ');
|
||||
};
|
||||
}
|
||||
|
||||
var _registerEventProxy = function(handler, proxy) {
|
||||
/**
|
||||
* @param {function} handler
|
||||
* @param {function} proxy
|
||||
* @returns {function}
|
||||
* @private
|
||||
*/
|
||||
function _registerEventProxy(handler, proxy) {
|
||||
var eventProxy = _.find(_eventProxies, function(item) {
|
||||
return item.handler === handler ? item : null;
|
||||
});
|
||||
@@ -35,13 +42,18 @@ function ClayEvents($eventTarget) {
|
||||
_eventProxies.push(eventProxy);
|
||||
}
|
||||
return eventProxy.proxy;
|
||||
};
|
||||
}
|
||||
|
||||
var _getEventProxy = function(handler) {
|
||||
/**
|
||||
* @param {function} handler
|
||||
* @returns {function}
|
||||
* @private
|
||||
*/
|
||||
function _getEventProxy(handler) {
|
||||
return _.find(_eventProxies, function(item) {
|
||||
return item.handler === handler ? item.proxy : null;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach an event listener to the item.
|
||||
@@ -60,8 +72,8 @@ function ClayEvents($eventTarget) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove the given event handler.
|
||||
* @see {@link http://minifiedjs.com/api/off.html|$.off()}
|
||||
* Remove the given event handler. NOTE: This will remove the handler from all
|
||||
* registered events
|
||||
* @param {function} handler
|
||||
* @returns {ClayEvents}
|
||||
*/
|
||||
@@ -74,11 +86,10 @@ function ClayEvents($eventTarget) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Trigger an event. This proxies minified.js' trigger.
|
||||
* Trigger an event.
|
||||
* @param {string} name - a single event name to trigger
|
||||
* @param {object} [eventObj] - an object to pass to the event handler,
|
||||
* provided the handler does not have custom arguments.
|
||||
* @see {@link http://minifiedjs.com/api/trigger.html|.trigger()}
|
||||
* @returns {ClayEvents}
|
||||
*/
|
||||
self.trigger = function(name, eventObj) {
|
||||
|
||||
@@ -8,7 +8,7 @@ var ClayEvents = require('./clay-events');
|
||||
|
||||
/**
|
||||
* @extends ClayEvents
|
||||
* @param config
|
||||
* @param {Clay~ConfigItem} config
|
||||
* @constructor
|
||||
*/
|
||||
function ClayItem(config) {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
* @param {boolean} [descriptor.writable]
|
||||
* @param {function} [descriptor.get]
|
||||
* @param {function} [descriptor.set]
|
||||
* @return {void}
|
||||
*/
|
||||
module.exports.updateProperties = function(obj, descriptor) {
|
||||
Object.getOwnPropertyNames(obj).forEach(function(prop) {
|
||||
|
||||
Reference in New Issue
Block a user