Name-ui tool, an html element ui tool based on name attribute.
Contents
- Tools
Resource tools
Initializing tools
Example
var nmui= require("nmui");
Methods
(inner) addCss(cssText)
Add css text to document style
Parameters:
Name | Type | Description |
---|---|---|
cssText |
string | Css stylesheet text |
Returns:
void
(inner) bindEvent(thisObj, nameMapping, eventConfig)
Bind event process from event config array
Parameters:
Name | Type | Description |
---|---|---|
thisObj |
object | A |
nameMapping |
object | An object mapping dom elements' |
eventConfig |
Array.<eventConfigItem> | An array of eventConfigItem, to configure event binding. |
Returns:
void
(inner) getId(ele, prefixopt)
Get the id
of a dom element. If there's none, create and set a unique id for the element.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
ele |
element | A dom element |
|
prefix |
string |
<optional> |
Prefix string for new id, default is "nmui_". |
Returns:
The id
of the ei
(inner) getMapping(ele)
Get an object that mapping dom elements' name
attributes to their id
s.
Parameters:
Name | Type | Description |
---|---|---|
ele |
element | A dom element |
Returns:
An object
- mapping descendant's
name
to theirid
- mapping
""
to theid
of theele
itself
(inner) init(ei, uiObject, configopt)
Initialize a nmui object
This function will add following properties to the uiObject
,
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
ei |
element | A dom element |
|
uiObject |
object | A javascript object that bound to |
|
config |
object |
<optional> |
A config object of nmuiConfig type.
|
Returns:
void
(inner) nme(name)
Get the name mapping dom element, by document.getElementById(...)
.
This is a property function, in which the this
is a nmuiObject object
This:
- nmuiObject
Parameters:
Name | Type | Description |
---|---|---|
name |
string | An element's name string |
Returns:
-
A dom element
-
null
if unfound
Type Definitions
eventConfigItem
Event config item
[
name
,eventName
,func
,argArray
]
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string |
|
|
eventName |
string |
|
|
func |
string | function |
<optional> |
|
argArray |
array |
<optional> |
|
Example
[ 'btn1', 'click', 'btn1_onClick' ]
//or
[ 'divMsg', 'dblclick', 'divMsg_onDblclick', [1,2,3] ] //with extra argument
//or
[ 'spanHint', 'mouseover' ] //string "spanHint_onMouseover" is set as function name
nmuiConfig
Nmui config object
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
html |
string | A html string for dom element |
|
event |
Array.<eventConfigItem> | An array of eventConfigItem, to configure event binding. |
|
css |
string | Css stylesheet text |
|
cssLoaded |
boolean |
<optional> |
A flag, that is set to |
nmuiObject
Nmui object
Properties:
Name | Type | Description |
---|---|---|
config |
object | An object of nmuiConfig type |
nm |
object | A name mapping object, for saving the result of mapping dom elements' |
nme |
function | A function to get the name mapping dom element, refer .nme(). |