Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/content/en/api/binders/progress.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ Returns a binder which binds an object property to a ``progress`` element value.
## Examples

```js
this.bindNode('myKey', '.my-progres', Matreshka.binders.progress());
this.bindNode('myKey', '.my-progress', Matreshka.binders.progress());
```
6 changes: 3 additions & 3 deletions docs/content/en/api/binders/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ The property value can be transformed using ``mappingFn`` argument.
## Examples

```js
this.bindNode('myKey', '.my-progres',
Matreshka.binders.style('backgroundColor'));
this.myKey = 'red'; // background-color of .my-progress is red now
this.bindNode('myKey', '.my-element',
Matreshka.binders.style('backgroundColor'));
this.myKey = 'red'; // background-color of .my-element is red now
```

**The usage of mapping function**
Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/api/matreshka-array/item-renderer.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ But sometimes you just need to move an object across few collections without re-
```js
this.push_(item, {
moveSandbox: true
})
});
```

#### ``itemRenderer`` reassigning
Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/api/matreshka-array/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Yet they work the same as the ``Array.prototype``. There are only a few remarks:
- The methods which should return a new array (``splice``, ``slice``, ``filter``, ``map``...) return a new ``Matreshka.Array`` instance.
- The ``keys``, ``values`` and ``entries`` methods return an array instead of an iterator.
- ``fill`` reports the replaced items as ``removed`` in the ``remove`` and ``modify`` events, and ``added`` holds one item per filled index.
- ``fill`` and ``copyWithin`` throw an error on a rendered array (one that has a ``container`` or a ``sandbox``).
- ``fill`` and ``copyWithin`` throw an error on a rendered array (one that has a ``container`` or a ``sandbox``) and leave it unchanged.

Moreover, the methods generate events which are fired on any array modification. For more detailed information look at [`Matreshka.Array`](/api/matreshka-array/).

Expand Down
7 changes: 5 additions & 2 deletions docs/content/en/api/matreshka-array/on-item-render.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ At the same time ``onRender`` method is called in a rendered item with the only

| Name | Type | Details |
| --- | --- | --- |
| `item` | [`object`](/api/types/object/) | A rendered node of a collection |
| `item` | [`object`](/api/types/object/) | A rendered item of a collection |
| `renderEvent` | [`object`](/api/types/object/) | ``"render"`` event object |

## Examples
Expand All @@ -44,7 +44,10 @@ class MyArray extends Matreshka.Array {
return MyModel;
}
itemRenderer() {
return '<li>'
return `<label>
<input type="checkbox" class="my-checkbox">
<span class="text"></span>
</label>`;
}
constructor() {
super().bindNode('sandbox', '.my-form');
Expand Down
3 changes: 3 additions & 0 deletions docs/content/en/api/matreshka-array/restore.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class MyModel extends Matreshka.Object {
}

class MyCollection extends Matreshka.Array {
get Model() {
return MyModel;
}
get itemRenderer() {
return ':sandbox .renderer';
}
Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/api/matreshka-array/to-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The method works recursively, calling ``toJSON`` for all items which have such m
## Examples

```js
const matreshkaArray = new Matreshka.Array(1, 2, new MatreshkaArray(3, 4));
const matreshkaArray = new Matreshka.Array(1, 2, new Matreshka.Array(3, 4));

// returns [1, 2, [3, 4]]
console.log(matreshkaArray.toJSON());
Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/api/matreshka-array/track-by.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ arr.recreate([
// the next recreate call
// removes an object with _id: 0
// adds an object with _id: 3
// updates an object with _id: 3 (changes name from Bar to BarNew)
// updates an object with _id: 1 (changes name from Bar to BarNew)
// updates an object with _id: 2 (changes name from Baz to BazNew)
// resorts collection
arr.recreate([
Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/api/matreshka-static/class.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const C = Matreshka.Class({
const D = Matreshka.Class({
// D is inherited from C
extends: C,
method3() {
method3(a, b) {
// calling the parent method
C.prototype.method3.apply(this, arguments);
}
Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/api/matreshka/bind-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const checkboxBinder = () => {
// to the beginning of the Matreshka.defaultBinders array
Matreshka.defaultBinders.unshift(node => {
// check if the element is a checkbox
if(node.tagName == 'INPUT' && node.type == 'checkbox') {
if(node.tagName === 'INPUT' && node.type === 'checkbox') {
// if checking is OK, return a new binder
return checkboxBinder();
}
Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/api/matreshka/instantiate.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class AppData extends Matreshka.Object {
super(data)
.instantiate({
friends: Friends,
settins: Settings
settings: Settings
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/content/en/api/matreshka/trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ importance: 1
**Method**

```js
Matreshka#trigger(names, [arg]) → matreshka
Matreshka#trigger(names, [arg]) → object
```

Fires an event
Expand All @@ -19,7 +19,7 @@ After adding event handlers using [`Matreshka#on`](/api/matreshka/on/), [`Matres

> Note that the method has [static alternative](/api/matreshka-static/trigger/)

**Returns:** [`matreshka`](/api/types/matreshka/) – self
**Returns:** [`object`](/api/types/object/) – self

## Arguments

Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/api/router.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ By changing these properties you can trigger needed procedures (update the path,
#### Methods

- ``subscribe(object, route)`` - subscribes object for route changes.
- ``init()`` - used for lazy initialization in ``subscribe`` method (no need to call it manually).
- ``init()`` - used for lazy initialization on first use of ``Matreshka.Router.hash`` or ``Matreshka.Router.history`` and in the ``subscribe`` method (no need to call it manually).

## Arguments

Expand Down
2 changes: 1 addition & 1 deletion docs/content/en/api/types/matreshka.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ importance: 2

```js
const matreshka = new Matreshka();
obj.calc('a', 'b');
matreshka.calc('a', 'b');
```
6 changes: 3 additions & 3 deletions docs/content/en/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ class User extends Matreshka.Object {
// pseudo-sandbox creation for syntax sugar at selectors
// (not required)
nodeA: node,
name: ':bound(nodeA) .name',
email: ':bound(nodeA) .email',
name: { node: ':bound(nodeA) .name', binder: Matreshka.binders.text() },
email: { node: ':bound(nodeA) .email', binder: Matreshka.binders.text() },
});
} else if(parentArray instanceof UsersB) {
this.bindNode({
nodeB: node,
name: ':bound(nodeB) .user-name',
name: { node: ':bound(nodeB) .user-name', binder: Matreshka.binders.text() },
});
}
}
Expand Down
12 changes: 6 additions & 6 deletions docs/content/ru/api/binders/class-name.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ Matreshka.binders.className(className, [bool=true]) → binder

```js
this.bindNode('myKey', '.my-element',
Matreshka.binders.className('blah'));
Matreshka.binders.className('foo'));

this.myKey = true; // добавляет класс 'blah'
this.myKey = true; // добавляет класс 'foo'

this.myKey = false; // убирает класс 'blah'
this.myKey = false; // убирает класс 'foo'
```

```js
this.bindNode('myKey', '.my-element',
Matreshka.binders.className('blah', false));
Matreshka.binders.className('foo', false));

this.myKey = false; // добавляет класс 'blah'
this.myKey = false; // добавляет класс 'foo'

this.myKey = true; // убирает класс 'blah'
this.myKey = true; // убирает класс 'foo'
```
2 changes: 1 addition & 1 deletion docs/content/ru/api/matreshka-array.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ new Matreshka.Array(42);
**Передача элементов при создании**

```js
new Matreshka.Array('Hi', { a: 'b' });
new Matreshka.Array('Hi', {a: 'b'});
```

**Наследование**
Expand Down
7 changes: 3 additions & 4 deletions docs/content/ru/api/matreshka-array/item-renderer.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ class MyArray extends Matreshka.Array {
itemRenderer = '<li>';
get Model() { return MyModel; }
constructor() {
super();
// определяем песочницу
this.bindNode('sandbox', '.my-list');
super().bindNode('sandbox', '.my-list');
}
}
```
Expand Down Expand Up @@ -197,7 +196,7 @@ const app = new MyArray();
Не забывайте, что в Matreshka.js реализована возможность отлова делегированных событий. Т. е. сам массив может отловить событие рендеринга элемента, используя имя события ``*@render`` (см. документацию к [`eventNames`](/ru/api/types/event-names/)).
```js
this.on('*@render', () => {
alert('Child element is rendered');
alert('Child item is rendered');
});
```

Expand Down Expand Up @@ -275,7 +274,7 @@ this.push_(item, {
#### Переопределение ``itemRenderer``
При переустановке свойства ``itemRenderer``, коллекция автоматически перерисовывается.
```js
this.itemRenderer = '<div>';
this.itemRenderer = '<div class="new-renderer"></div>';
```
Эта возможность полезна в том случае, когда разработчик желает загрузить шаблон с сервера.
```js
Expand Down
2 changes: 1 addition & 1 deletion docs/content/ru/api/matreshka-array/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Matreshka.Array#METHOD()
- Методы, которые в оригинальном виде возвращают новый массив (``splice``, ``slice``, ``filter``, ``map``...), возвращают новый экземпляр ``Matreshka.Array``.
- Методы ``keys``, ``values`` и ``entries`` возвращают массив вместо итератора.
- ``fill`` передаёт заменённые элементы как ``removed`` в события ``remove`` и ``modify``, а ``added`` содержит по одному элементу на каждый заполненный индекс.
- ``fill`` и ``copyWithin`` бросают ошибку на отрендеренном массиве (у которого есть ``container`` или ``sandbox``).
- ``fill`` и ``copyWithin`` бросают ошибку на отрендеренном массиве (у которого есть ``container`` или ``sandbox``) и не меняют его.

Кроме всего, методы генерируют события связанные с любой модификацией массива. Подробнее см. [`Matreshka.Array`](/ru/api/matreshka-array/).

Expand Down
7 changes: 5 additions & 2 deletions docs/content/ru/api/matreshka-array/on-item-render.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Matreshka.Array#onItemRender(item, renderEvent)

| Имя | Тип | Описание |
| --- | --- | --- |
| `item` | [`object`](/ru/api/types/object/) | Отрисованный элемент коллекции |
| `item` | [`object`](/ru/api/types/object/) | Отрисованный объект коллекции |
| `renderEvent` | [`object`](/ru/api/types/object/) | Объект события ``render`` |

## Примеры
Expand All @@ -44,7 +44,10 @@ class MyArray extends Matreshka.Array {
return MyModel;
}
itemRenderer() {
return '<li>'
return `<label>
<input type="checkbox" class="my-checkbox">
<span class="text"></span>
</label>`;
}
constructor() {
super().bindNode('sandbox', '.my-form');
Expand Down
3 changes: 3 additions & 0 deletions docs/content/ru/api/matreshka-array/restore.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class MyModel extends Matreshka.Object {
}

class MyCollection extends Matreshka.Array {
get Model() {
return MyModel;
}
get itemRenderer() {
return ':sandbox .renderer';
}
Expand Down
2 changes: 1 addition & 1 deletion docs/content/ru/api/matreshka-array/to-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Matreshka.Array#toJSON([recursive=true]) → array
## Примеры

```js
const matreshkaArray = new Matreshka.Array(1, 2, new MatreshkaArray(3, 4));
const matreshkaArray = new Matreshka.Array(1, 2, new Matreshka.Array(3, 4));

// возвращает [1, 2, [3, 4]]
console.log(matreshkaArray.toJSON());
Expand Down
2 changes: 1 addition & 1 deletion docs/content/ru/api/matreshka-object.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ this.toJSON();
При добавлении и изменении свойств, отвечающих за данные генерируется события ``set`` и ``modify``, при удалении - ``remove`` и ``modify``. Т. е. любые изменения данных можно слушать с помощью ``modify``.
```js
this.on('modify', () => {
alert('Object is modified');
alert('an object is modified');
});
```

Expand Down
2 changes: 1 addition & 1 deletion docs/content/ru/api/matreshka-object/each.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ this
.addDataKeys('c')
.each((value, key) => {
console.log(key, value);
});
}, this);
;
// >>> a 1, b 2, c undefined
```
6 changes: 3 additions & 3 deletions docs/content/ru/api/matreshka-static/parse-bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ Matreshka.parseBindings() → $nodes

```js
const object = {};
const $node = Matreshka.parseBindings(object, `<h3>
Hello, {{name}}
</h3>`);
const $node = Matreshka.parseBindings(object, `
<h3>Hello, {{name}}</h3>
`);
object.name = 'World';
```
7 changes: 4 additions & 3 deletions docs/content/ru/api/matreshka/bind-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ const uiSlider = (min, max) => {
}
}
};

```
```js
this.bindNode('myKey1', '.my-slider1', uiSlider(0, 100));
this.bindNode('myKey2', '.my-slider2', uiSlider(1, 1000));
this.myKey1 = 42;
Expand Down Expand Up @@ -309,15 +310,15 @@ setTimeout(() => {
Например, мы хотим связать ``input[type="text"]`` со свойством. По умолчанию, стандартный байндер для этого элемента содержит свойство ``"on"`` со значением ``"input"``. Это значит, что значение свойства экземпляра и состояние элемента будут синхронизированы сразу после ввода или удаления символа пользователем. В случае, если вы хотите, чтоб синхронизация происходила по DOM событию ``"blur"``, вам потребуется передать третьим аргументом объект, содержащий единственное свойство ``"on"``. Этот объект объединится со стандартным байндером, сохранив при этом значения ``getValue`` и ``setValue``.

```js
this.bindNode('x', '.my-input', { on: "blur" });
this.bindNode('myKey', '.my-input', { on: 'blur' });
```

Для отмены этого поведения и использования байндера как он есть, в объект события можно передать флаг ``useExactBinder`` со значением ``true``.

```js
this.bindNode('x', node, binder, {
useExactBinder: true
})
});
```

**Возвращает:** [`object`](/ru/api/types/object/) – self
Expand Down
2 changes: 1 addition & 1 deletion docs/content/ru/api/matreshka/instantiate.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class MyParentClass extends Matreshka {
**Нестандартный способ использования ``updateCallback`` для игнорирования любых изменений свойства.**

```js
this.instantiate('x', SubClass, () => {});
this.instantiate('x', MyClass, () => {});
```

**В случае, если ваш класс не подерживает использование оператора ``new``, вместо ``instantiate`` воспользуйтесь методом [`Matreshka#mediate`](/ru/api/matreshka/mediate/).**
Expand Down
4 changes: 3 additions & 1 deletion docs/content/ru/api/matreshka/mediate.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ importance: 2
**Метод**

```js
Matreshka#mediate(key, mediator)
Matreshka#mediate(key, mediator) → object
```

Трансформирует значение свойства при его изменении
Expand All @@ -25,6 +25,8 @@ mediate(object, key, mediator);
// вместо this.mediate(key, mediator);
```

**Возвращает:** [`object`](/ru/api/types/object/) – self

## Аргументы

| Имя | Тип | Описание |
Expand Down
4 changes: 2 additions & 2 deletions docs/content/ru/api/matreshka/off.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ importance: 1
**Метод**

```js
Matreshka#off([names], [callback], [context]) → matreshka
Matreshka#off([names], [callback], [context]) → object
```

Удаляет обработчик события
Expand All @@ -19,7 +19,7 @@ Matreshka#off([names], [callback], [context]) → matreshka

Без аргументов ``off`` удаляет все обработчики, добавленные через ``on``, ``once`` и ``onDebounce``, и генерирует ``removeevent`` для каждого из них. Привязки, зависимости ``calc`` и внутренние события ``Matreshka.Object`` и ``Matreshka.Array`` остаются.

**Возвращает:** [`matreshka`](/ru/api/types/matreshka/) – self
**Возвращает:** [`object`](/ru/api/types/object/) – self

**Генерирует события:** `removeevent`, `removeevent:NAME`

Expand Down
4 changes: 0 additions & 4 deletions docs/content/ru/api/matreshka/parse-bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,11 @@ JS: this.user = {name: 'Joe'}
JS: this.x = 'some value';
-->
<input type="text" value="{{x}}">
```
```html
<!--
Для привязки textarea и select нужно использовать атрибут value
-->
<textarea value="{{x}}"></textarea>
<select value="{{x}}">...</select>
```
```html
<!--
Свяжет свойство "x" экземпляра с чекбоксом
(двусторонняя привязка)
Expand Down
Loading
Loading