Bonaparte Core - API
var bp = ;
bp.attribute
Utility functions that should be used to handle attributes.
They automatically handle both name
and data-name
attributes in one go and normalize events across browsers.
bp.attribute.get();
Get an attribute from the given tag by attribute name. Automatically checks for data-[name] as well.
Return: attribute value.
bpattribute
bp.attribute.matchName();
Compares two attribute names and checks if they are the same with: "attributeName" === "data-attributeName"
Returns: true|false
bpattribute
bp.attribute.remove();
Removes an attribute from the given tag. Checks automatically if the attribute exists with or without data- prefix.
bpattribute
bp.attribute.set();
Set an attribute on the given tag. Checks automatically if the attribute exists with or without data- prefix.
bpattribute
bp.module
bp.module.mixin()
Combines modules into a new module
Returns a module.
var module = bpmodules
Modules are combinded to an
objct
. Read more about the objct library here
bp.tag
bp.tag.closest();
Traverses up the element tree to find the first element that matches the given selector.
Returns: Element|undefined
bptag
bp.tag.contains();
Checks one Element is placed inside another.
Returns: true|false
bptag
bp.tag.create();
Creates a new bonaparte-tag from modules.
Returns Tag Factory.
var tag = bptag ////////////// Static functions tag; // Registers tag in HTML. After calling this function, the tag can be used in HTML.tag; // Initializes the tag on an existion HTMLElement.tag; // Define mixins to chustomize existing tags behaviors.
The returned Tag Factory that can be.
- Used as a mixin in other tags to extend their functionality.
- Registered to the DOM with
tag.register()
- Initiated on an existing element in the DOM with
tag.initialize(element)
- Extended with modules through
tag.mixin(module)
A Tag Factory is an
objct
. Read more about the objct library here
Static methods on modules become static methods on the Tag Factory.
bp.tag.DOMReady();
Calls the handler function when the DOM is ready. If the DOM is already completed, the handler is called imediately.
bptag
bp.tag.observe();
Sets on observer on the given Element.
The observed element now emits bonaparte.tag.attributeChanged
and bonaparte.tag.attributeUpdated
events.
bptag
bp.tag.triggerEvent();
Triggers a event on the given HTMLElement
Returns: undefined
bptag