docs
This commit is contained in:
parent
75c551347e
commit
5cfdfdbcca
4
DOCS.md
4
DOCS.md
@ -125,4 +125,8 @@ map.value(/* value для замены */); // Без аргументов ве
|
||||
map.id(/* ID элемента */); // Вернет экземпляр map для выбранного элемента
|
||||
map.tag(/* TAG элемента */); // Вернет экземпляр map для выбранного элемента
|
||||
map.attach(/* событие */, /* функция */); // EventHandler
|
||||
/*
|
||||
* Функция в attach может принимать параметр.
|
||||
* Этот параметр - обьект Find, map которого был вызван
|
||||
*/
|
||||
```
|
||||
15
Find/Find.js
15
Find/Find.js
@ -24,11 +24,12 @@
|
||||
const ERROR_CODE = "Find framework error:";
|
||||
|
||||
class FindObjectMap {
|
||||
constructor(_root) {
|
||||
constructor(_root, app) {
|
||||
this.root = _root;
|
||||
if (typeof this.root !== "object") {
|
||||
PrivateFind.error("Unknown root!");
|
||||
}
|
||||
this._app = app;
|
||||
return this;
|
||||
}
|
||||
select(q) {
|
||||
@ -37,7 +38,7 @@ class FindObjectMap {
|
||||
PrivateFind.error("No objects of selector");
|
||||
return undefined;
|
||||
}
|
||||
return new FindObjectMap(o);
|
||||
return new FindObjectMap(o, this._app);
|
||||
}
|
||||
read() {
|
||||
return this.root.innerHTML;
|
||||
@ -69,7 +70,7 @@ class FindObjectMap {
|
||||
PrivateFind.error("No objects of selector");
|
||||
return undefined;
|
||||
}
|
||||
return new FindObjectMap(o);
|
||||
return new FindObjectMap(o, this._app);
|
||||
}
|
||||
tag(q) {
|
||||
const o = this.root.getElementsByTagName(q);
|
||||
@ -77,10 +78,12 @@ class FindObjectMap {
|
||||
PrivateFind.error("No objects of selector");
|
||||
return undefined;
|
||||
}
|
||||
return new FindObjectMap(o);
|
||||
return new FindObjectMap(o, this._app);
|
||||
}
|
||||
attach(event, func) {
|
||||
this.root.addEventListener(event, func);
|
||||
this.root.addEventListener(event, () => {
|
||||
func(this._app);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +95,7 @@ export default class {
|
||||
this.root = root;
|
||||
this.groups = new Array();
|
||||
this.groups_count = 0;
|
||||
this._map = new FindObjectMap(this.root);
|
||||
this._map = new FindObjectMap(this.root, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user