TOC
Intro
The core library contains the minimum of functionality, which is necessary
to enable the CoreJs functions.
The core.js and project based bootstrap.js are the only files, which
need to be loaded in the head of the document(project main page).
A typical project main page:
<!DOCTYPE html>
<html>
<head>
<title>Loading...</title>
<script src="node_modules/corejs-w3c/src/core.js"></script>
<script src="src/bootstrap.js"></script>
</head>
<body></body>
</html>
The most easy way to deploy an application, based of CoreJS-W3C is, to
install the corejs-w3c via npm.
package.json
{
"name": "project name",
"version": "1.0.0",
"description": "Project desciption",
"author": "project author",
"main": "src/Main.js",
"scripts": {
"test": "mocha tests/index.js"
},
"repository": {
"type": "git",
"url": "Project source code URL"
},
"bugs": {
"url": "https://github.com/enbock/pager-manager/issues"
},
"dependencies": {
"corejs-w3c": "*"
},
"devDependencies": {
"mocha": "*",
"chai": "*",
"sinon": "*",
"sinon-chai": "*"
},
"license": "GPL3"
}
Shell
$ npm install
Alternativley is the CoreJS-W3C also standalone usable:
<script src="//rawgit.com/enbock/corejs-w3c/master/src/core.js"></script>
Reference
CoreJs.Event(type, detail)
The factory of CustomEvent objects.
Parameters:
eventString The event type for which the user is registering.detailObject Custom data to transport.
Inheritance
Internal class name
CoreEvent
CoreJs.Event.Handler
The implementation of the DOM Level 2 EventListener interface.
It contains only the structure for receiving events.
Inheritance
Internal class name
CoreEventHandler
handleEvent(event)
Parameters:
eventEvent The received event object.
CoreJs.Event.Listener
The event listener is the core of the event systems. Its implement the DOM Level 2 EventTarget interface. Its uses the browser event implementation via using the DOM Level 2 HTMLElement interface implementation of the browser
Inheritance
- EventTarget
- (mixin) CoreJs.Event.Handler
(static) document
The standard Document injection.
Internal class name
DOMEventListener
handleEvent(event)
Inheritance of CoreJs.Event.Handler
Parameters:
eventEvent The received event object.
addEventListener(event, listener, useCapture)
This method allows the registration of event listeners on the event target.
Parameters:
eventString The event type for which the user is registeringlistenerEventListener,Function The event observer.useCapture[optional] Boolean Enable or disable event capturing.
See also DOM Level 2.
removeEventListener(event, listener, useCapture)
This method allows the removal of event listeners from the event target.
Calling removeEventListener with arguments which do not identify any
currently registered EventListener
on the Event.Listener has no effect.
Parameters:
eventString The event type for which the user is registeringlistenerEventListener,Function The event observer.useCapture[optional] Boolean Enable or disable event capturing.
See also DOM Level 2.
dispatchEvent(event)
This method allows the dispatch of events into the CoreJs.Event.Listener.
The target of the event is the CoreJs.Event.Listener on which
dispatchEvent is called.
Parameters:
eventEvent The received event object.
See also DOM Level 2.
CoreJs.Ajax(method, url, sendData)
Asynchronous JavaScript and XML.
Wrapper to equalize and simplify the usage for AJAX calls.
Parameters:
methodString Type of request (get, post, put, …).urlString Request address.sendDataObject ,String Data to send.
Inheritance
Internal class name
Ajax
(statix) XHRSystem
The constructor of the XMLHttpRequest implementation.
(static) factory(method, url, sendData)
Factory to create CoreJs.Ajax objects.
Parameters:
methodString Type of request (get, post, put, …).urlString Request address.sendDataObject ,String Data to send.
load()
Execute the ajax request and start the asynchronous loading.
CoreJs.Ajax.Event(type, detail)
Ajax events.
Parameters:
eventString The event type for which the user is registering.detailObject Custom data to transport.
Inheritance
Internal class name
Ajax.Event
(constant) LOAD
String of the ajax load event type.
The ajax process event detail contains follow data:
responsemixed Contains response body.responseTextStringresponseTypeString The type of the response.responseURLString,Null The response url.responseXMLContains the [https://xhr.spec.whatwg.org/#document-response] if theresponseTypeis'document'statusNumber Integer value of the response status.lengthComputableBoolean Flag if the length computable.loadedNumber The loaded amount of data.totalNumber Response size.
Depent of the ajax method, the response type and the browser implementations are not all keys filled with data.
(constant) PROGRESS
String of the ajax process event type.
The ajax process event detail contains follow data:
lengthComputableBoolean Flag if the length computable.loadedNumber The loaded amount of data.totalNumber Response size.
(function) use(fullQualifiedClassName)
Load via CoreJs.Ajax the project code.
Typical is the use placed in the loading code of the namespace.
The source url will be configured in the PSR-4
setup.
Info
The use works together with namespace. In the moment a file is loaded
via PSR-4 configured class definition, will use configure the namespace
automatically.
Since 0.3.2 is it not anymore necessary to wrap the class code with a
namespace call.
(static) use.context
The destination context object. The default value is window.
(static) use.classPathDelimiter
Defines the delimiter character of the fullQualifiedClassName and
fullQualifiedNameSpace Strings.
The default value is the dot(.).
(static) use.fileExtension
The file extension String to convert PSR-4 definition into resource names.
(static) use.basePath
The url String of the project’s source location.
(static) use.psr4(psr4Name, path)
Configure the resouce root of a namespace.
This is an equivalent to the composer.js
autoload:psr-4 config.
Parameters:
psr4NameString PSR-4 name (namespace definition).pathString The relative path or url of the resource location for the namespace.
(function) namespace(fullQualifiedNameSpace, contentCall)
Code isolation and organization system.
The namespace organize the code of the project. This is very helpful
for domain driven design development.
Parameters:
Example
namespace('Test.Implementation', function() {
use('Test.Logger');
var log = new Test.Logger(); // Use imported class
log.debug("Create class...");
function UseIt() {};
UseIt.protoType = Object.create(Object.protoType);
this.UseIt = UseIt; // propagate to Test.Implementation.UseIt
});