Module i-bem
Augments:events:Emitter
Base block for creating BEM blocks
Instance methods:
on(e, [data], fn, [ctx]):BEM description
Adds an event handler
parameters
eString, Object
Event type dataObject
Additional data that the handler gets as e.data description
Removes event handler or handlers
parameters
eString, Object
Event type emit(e, [data]):BEMprotected description
Executes the block's event handlers and live event handlers
parameters
dataObject
Additional information hasMod([elem], modName, [modVal]):Boolean description
Checks whether a block or nested element has a modifier
parameters
modNameString
Modifier name modValString, Boolean
Modifier value. If defined and not of type String or Boolean, it is casted to String getMod([elem], modName):String,Boolean description
Returns the value of the modifier of the block/nested element
parameters
modNameString
Modifier name getMods([elem], [...modNames]):Object description
Returns values of modifiers of the block/nested element
parameters
...modNamesString
Modifier names setMod([elem], modName, [modVal]):BEM description
Sets the modifier for a block/nested element
parameters
modNameString
Modifier name modValString, Boolean
Modifier value. If not of type String or Boolean, it is casted to String _onSetMod(modName, modVal, oldModVal, [elem], [elemName])protected description
Function after successfully changing the modifier of the block/nested element
parameters
modNameString
Modifier name modValString
Modifier value oldModValString
Old modifier value elemNameString
Element name toggleMod([elem], modName, [modVal1], [modVal2], [condition]):BEM description
Sets a modifier for a block/nested element, depending on conditions.
If the condition parameter is passed: when true, modVal1 is set; when false, modVal2 is set.
If the condition parameter is not passed: modVal1 is set if modVal2 was set, or vice versa.
parameters
modNameString
Modifier name modVal1String
First modifier value, optional for boolean modifiers modVal2String
Second modifier value conditionBoolean
Condition delMod([elem], modName):BEMprotected description
Removes a modifier from a block/nested element
parameters
modNameString
Modifier name getDefaultParams():Objectprotected description
Returns a block's default parameters
nextTick(fn):BEMprotected description
Executes given callback on next turn eventloop in block's context
Static methods:
description
Storage for block declarations (hash by block name)
decl(decl, decl.block|decl.name, [decl.baseBlock], [decl.baseMix], [decl.modName], [decl.modVal], [props], [staticProps]):Function description
Declares blocks and creates a block class
parameters
declString, Object
Block name (simple syntax) or description decl.block|decl.nameString
Block name decl.baseBlockString
Name of the parent block decl.baseMixArray
Mixed block names decl.modNameString
Modifier name decl.modValString, Array
Modifier value staticPropsObject
Static methods create(block, [params]):BEM description
Factory method for creating an instance of the block named
parameters
blockString, Object
Block name or description paramsObject
Block parameters description
Returns the name of the current block
on(e, [data], fn, [ctx]):Function description
Adds an event handler
parameters
eString, Object
Event type dataObject
Additional data that the handler gets as e.data un([e], [fn], [ctx]):Function description
Removes event handler or handlers
parameters
eString, Object
Event type i-bem__collection
Augments:Array
Base class for collections. Create collection of similar objects.
Static methods:
description
Get method names that will be implemented in collection
description
Get base prototype for collection
description
Create collection instance
parameters
aArray
list of similar objects i-bem__dom
Base block for creating BEM blocks that have DOM representation
Instance methods:
findBlocksInside([elem], block):BEMDOM description
Finds blocks inside the current block or its elements (including context)
parameters
elemString, jQuery
Block element blockString, Object
Name or description (block,modName,modVal) of the block to find findBlockInside([elem], block):BEMDOM description
Finds the first block inside the current block or its elements (including context)
parameters
elemString, jQuery
Block element blockString, Object
Name or description (block,modName,modVal) of the block to find findBlocksOutside([elem], block):BEMDOM description
Finds blocks outside the current block or its elements (including context)
parameters
elemString, jQuery
Block element blockString, Object
Name or description (block,modName,modVal) of the block to find findBlockOutside([elem], block):BEMDOM description
Finds the first block outside the current block or its elements (including context)
parameters
elemString, jQuery
Block element blockString, Object
Name or description (block,modName,modVal) of the block to find findBlocksOn([elem], block):BEMDOM description
Finds blocks on DOM elements of the current block or its elements
parameters
elemString, jQuery
Block element blockString, Object
Name or description (block,modName,modVal) of the block to find findBlockOn([elem], block):BEMDOM description
Finds the first block on DOM elements of the current block or its elements
parameters
elemString, jQuery
Block element blockString, Object
Name or description (block,modName,modVal) of the block to find bindToDomElem(domElem, event, [data], fn):BEMDOMprotected description
Adds an event handler for any DOM element
parameters
domElemjQuery
DOM element where the event will be listened for eventString, Object
Event name or event object dataObject
Additional event data fnFunction
Handler function, which will be executed in the block's context bindToDoc(event, [data], fn):BEMDOMprotected description
Adds an event handler to the document
parameters
eventString, Object
Event name or event object dataObject
Additional event data fnFunction
Handler function, which will be executed in the block's context bindToWin(event, [data], fn):BEMDOMprotected description
Adds an event handler to the window
parameters
eventString, Object
Event name or event object dataObject
Additional event data fnFunction
Handler function, which will be executed in the block's context bindTo([elem], event, [data], fn):BEMDOMprotected description
Adds an event handler to the block's main DOM elements or its nested elements
parameters
elemjQuery, String
Element eventString, Object
Event name or event object dataObject
Additional event data fnFunction
Handler function, which will be executed in the block's context unbindFromDomElem(domElem, event, [fn]):BEMDOMprotected description
Removes event handlers from any DOM element
parameters
domElemjQuery
DOM element where the event was being listened for eventString, Object
Event name or event object fnFunction
Handler function unbindFromDoc(event, [fn]):BEMDOMprotected description
Removes event handler from document
parameters
eventString, Object
Event name or event object fnFunction
Handler function unbindFromWin(event, [fn]):BEMDOMprotected description
Removes event handler from window
parameters
eventString, Object
Event name or event object fnFunction
Handler function unbindFrom([elem], event, [fn]):BEMDOMprotected description
Removes event handlers from the block's main DOM elements or its nested elements
parameters
elemjQuery, String
Nested element eventString, Object
Event name or event object fnFunction
Handler function setMod([elem], modName, [modVal]):BEMDOM description
Sets a modifier for a block/nested element
parameters
modNameString
Modifier name modValString, Boolean
Modifier value findElem([ctx], names, [modName], [modVal], [strictMode]):jQuery description
Finds elements nested in a block
parameters
ctxjQuery
Element where search is being performed namesString
Nested element name (or names separated by spaces) modNameString
Modifier name modValString
Modifier value _filterFindElemResults(res):jQuery description
Filters results of findElem helper execution in strict mode
elem(names, [modName], [modVal]):jQuery description
Lazy search for elements nested in a block (caches results)
parameters
namesString
Nested element name (or names separated by spaces) modNameString
Modifier name modValString, Boolean
Modifier value closestElem(ctx, elemName):jQuery description
Finds elements outside the context
parameters
elemNameString
Element name dropElemCache([names], [modName], [modVal]):BEMDOMprotected description
Clearing the cache for elements
parameters
namesString
Nested element name (or names separated by spaces) modNameString
Modifier name modValString
Modifier value description
Retrieves parameters of a block element
parameters
elemString, jQuery
Element elemify(elem, elemName):jQuery description
Elemify given element
containsDomElem([ctx], domElem):Booleanprotected description
Checks whether a DOM element is in a block
parameters
ctxjQuery
Element where check is being performed buildSelector([elem], [modName], [modVal]):String description
Builds a CSS selector corresponding to a block/element and modifier
parameters
modNameString
Modifier name modValString
Modifier value Static methods:
description
Document shortcut
description
Window shortcut
description
Initializes blocks on a fragment of the DOM tree
parameters
ctxjQuery, String
Root DOM node destruct(ctx, [excludeSelf]) description
Destroys blocks on a fragment of the DOM tree
parameters
excludeSelfBoolean
Exclude the main domElem detach(ctx, [excludeSelf]) description
Detaches blocks on a fragment of the DOM tree without destructing DOM tree
parameters
excludeSelfBoolean
Exclude the main domElem update(ctx, content):jQuery description
Replaces a fragment of the DOM tree inside the context, destroying old blocks and intializing new ones
parameters
contentjQuery, String
New content replace(ctx, content):jQuery description
Changes a fragment of the DOM tree including the context and initializes blocks.
parameters
contentjQuery, String
Content to be added append(ctx, content):jQuery description
Adds a fragment of the DOM tree at the end of the context and initializes blocks
parameters
contentjQuery, String
Content to be added prepend(ctx, content):jQuery description
Adds a fragment of the DOM tree at the beginning of the context and initializes blocks
parameters
contentjQuery, String
Content to be added before(ctx, content):jQuery description
Adds a fragment of the DOM tree before the context and initializes blocks
parameters
ctxjQuery
Contextual DOM node contentjQuery, String
Content to be added after(ctx, content):jQuery description
Adds a fragment of the DOM tree after the context and initializes blocks
parameters
ctxjQuery
Contextual DOM node contentjQuery, String
Content to be added liveInitOnEvent([elemName], event, [callback])protected description
Helper for live initialization for an event on DOM elements of a block or its elements
parameters
elemNameString
Element name or names (separated by spaces) callbackFunction
Handler to call after successful initialization liveBindTo([to], event, [callback])protected description
Helper for subscribing to live events on DOM elements of a block or its elements
parameters
toString, Object
Description (object with modName, modVal, elem) or name of the element or elements (space-separated) liveUnbindFrom([elem], event, [callback])protected description
Helper for unsubscribing from live events on DOM elements of a block or its elements
parameters
elemString
Name of the element or elements (space-separated) liveInitOnBlockEvent(event, blockName, callback)protected description
Helper for live initialization for a different block's event on the current block's DOM element
parameters
blockNameString
Name of the block that should trigger a reaction when initialized callbackFunction
Handler to be called after successful initialization in the new block's context liveInitOnBlockInsideEvent(event, blockName, [callback])protected description
Helper for live initialization for a different block's event inside the current block
parameters
blockNameString
Name of the block that should trigger a reaction when initialized callbackFunction
Handler to be called after successful initialization in the new block's context on([ctx], e, [data], fn, [fnCtx]) description
Adds a live event handler to a block, based on a specified element where the event will be listened for
parameters
ctxjQuery
The element in which the event will be listened for dataObject
Additional information that the handler gets as e.data fnCtxObject
Handler's context un([ctx], e, [fn], [fnCtx]) description
Removes the live event handler from a block, based on a specified element where the event was being listened for
parameters
ctxjQuery
The element in which the event was being listened for fnCtxObject
Handler context buildClass([elem], [modName], [modVal]):String description
Builds a CSS class corresponding to the block/element and modifier
parameters
modNameString
Modifier name modValString
Modifier value buildSelector([elem], [modName], [modVal]):String description
Builds a CSS selector corresponding to the block/element and modifier
parameters
modNameString
Modifier name modValString
Modifier value i-bem__collection_type_dom
Augments:i-bem__collection
Collection of BEM.DOM blocks. Implementation of BEM.DOM methods for array of blocks.
Static methods:
getMethods():Arrayoverride description
Get methods that will be implemented in BEMDOMCollection
i-bem__dom_collection_yes
Augments:BEMDOM
Overrides BEM.DOM.findBlocks* methods that they return i-bem__collection_type_dom
i-bem__dom_init
Initializes blocks on a fragment of the DOM tree
returns
jQuery
ctx Initialization context