-
<static> clearConsole()
-
Will clear all data that's already logged in console.
- Source:
Example
Carpet.clearConsole()
// Console was cleared
-
<static> debug(debugType, Any)
-
Will debug something in console only if Carpet.loggingEnabled is true
Parameters:
Name |
Type |
Description |
debugType |
String
|
Type of debug info, can be 'log', 'warn' or 'error' |
Any |
Any[]
|
number of arguments of any type, all would be logged |
- Source:
Example
Carpet.debug('log', 'I want to log text'); // => Carpet:log (23/11/2012 16:18:42) ["I want to log text"]
Carpet.debug('warn', 'I want to log a warning'); // => Carpet:warn (23/11/2012 16:18:42) ["I want to log a warning"]
Carpet.debug('error', 'I want to log an error'); // => Carpet:error (23/11/2012 16:18:42) ["I want to log an error"]
-
<static> error(Any)
-
Will log something in console only if Carpet.loggingEnabled is true
Parameters:
Name |
Type |
Description |
Any |
Any[]
|
number of arguments of any type, all would be logged |
- Source:
Example
Carpet.error('I want to log an error'); // => Carpet:error (23/11/2012 16:18:42) ["I want to log an error"]
Carpet.error('I want to log an error', { and: 'a javascript object' }); // => Carpet:error (23/11/2012 16:19:01) ["I want to log an error", > Object]
-
<static> getComponent(componentName) → {Any}
-
Returns registered component by its name
Parameters:
Name |
Type |
Description |
componentName |
String
|
Name of the component you want to get |
- Source:
Returns:
Any type that component represents
-
Type
-
Any
Example
...
Carpet.registerComponent('uber', function () { return 1; });
...
Carpet.getComponent('uber'); // => 1
-
<static> getModule(moduleName) → {Object}
-
Returns module by given module name
Parameters:
Name |
Type |
Description |
moduleName |
String
|
Name of the module you want to get |
- Source:
Returns:
Module object
-
Type
-
Object
Example
...
Carpet.module('oneAnotherModule', function () {});
...
Carpet.getModule('oneAnotherModule'); // => { name: 'oneAnotherModule', methods: [...]}
-
<static> info(Any)
-
Will log something in console only if Carpet.loggingEnabled is true
Parameters:
Name |
Type |
Description |
Any |
Any[]
|
number of arguments of any type, all would be logged |
- Source:
Example
Carpet.info('I want to log an info'); // => Carpet:info (23/11/2012 16:18:42) ["I want to log an info"]
Carpet.info('I want to log an info', { and: 'a javascript object' }); // => Carpet:info (23/11/2012 16:19:01) ["I want to log an info", > Object]
-
<static> init()
-
Loads the modules if found in DOM ([data-module="myModule"])
It will automatically fire the `init` method if found inside the module
- Source:
Example
<div class="module" data-module="myModule"></div>
<script type="text/javascript">
Carpet.init();
</script>
-
<static> log(Any)
-
Will log something in console only if Carpet.loggingEnabled is true
Parameters:
Name |
Type |
Description |
Any |
Any[]
|
number of arguments of any type, all would be logged |
- Source:
Example
Carpet.log('I want to log text'); // => Carpet:log (23/11/2012 16:18:42) ["I want to log text"]
Carpet.log('I want to log text', { and: 'a javascript object' }); // => Carpet:log (23/11/2012 16:19:01) ["I want to log text", > Object]
-
<static> module(moduleName, callback)
-
Will create a new module and add returned methods to the modules namespace
Parameters:
Name |
Type |
Description |
moduleName |
String
|
Name of the module |
callback |
function
|
Actual module body |
- Source:
Example
// Single instance (the same for all modules, with shared settings etc)
Carpet.module('sampleModule', function (exports, settings, DOMContext) {
var config = {
privateVar: 123
};
var privateFunction = function () {
console.log('This is a private function. Do whatever you want.');
console.log('We have access to public ', settings, ' and public methods ', exports, ' and context :)');
};
exports.sampleMethod = function () {
console.log('This is a sample method');
console.log('We are working on ', DOMContext, ' element');
privateFunction();
};
exports.init = function () {
console.log('this is automatically called after module is loaded');
this.sampleMethod();
};
});
-
<static> warn(Any)
-
Will warn something in console only if Carpet.loggingEnabled is true
Parameters:
Name |
Type |
Description |
Any |
Any[]
|
number of arguments of any type, all would be warned |
- Source:
Example
Carpet.warn('I want to log a warning'); // => Carpet:warn (23/11/2012 16:18:42) ["I want to log a warning"]
Carpet.warn('I want to log a warning', { and: 'a javascript object' }); // => Carpet:warn (23/11/2012 16:19:01) ["I want to log a warning", > Object]