Skip to content

Update to bem-components v5 #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
update syntax
aristov committed Aug 18, 2016
commit 383b0c715bd8b36a803b23acb748738b2ba00d4b
4 changes: 2 additions & 2 deletions blocks/sg-datalist/sg-datalist.deps.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[{
mustDeps : { block : 'i-bem', elems : 'dom' },
mustDeps : { block : 'i-bem-dom' },
shouldDeps : [
'sg-dataprovider',
'menu'
]
},
{
tech : 'js',
mustDeps : { block : 'menu-item', tech : 'bemhtml' }
mustDeps : { block : 'menu', tech : 'bemhtml' }
}]
18 changes: 9 additions & 9 deletions blocks/sg-datalist/sg-datalist.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
modules.define(
'sg-datalist',
['i-bem__dom', 'menu', 'BEMHTML'],
['i-bem-dom', 'menu', 'BEMHTML'],
function(provide, BemDom, Menu, BEMHTML) {

provide(BemDom.decl(this.name, {
onSetMod : {
'js' : {
'inited' : function() {
this._dataprovider = null;
this._menu = this.findBlockOn(Menu.getName())
this._events(this._menu = this.findMixedBlock(Menu))
.on({
'item-hover' : this._onMenuItemHover,
'item-click' : this._onMenuItemClick
}, this);
}
},

'focused' : function(modNam, modVal) {
this._menu.setMod(modNam, modVal);
'focused' : function(modName, modVal) {
this._menu.setMod(modName, modVal);
}
},

@@ -103,25 +103,25 @@ provide(BemDom.decl(this.name, {
},

_onMenuItemHover : function(e, data) {
this.emit('item-hover', data);
this._emit('item-hover', data);
},

_onMenuItemClick : function(e, data) {
this.emit('item-click', data);
this._emit('item-click', data);
},

_onProviderGotData : function(e, data) {
this
.emit('items', data)
._emit('items', data)
._updateMenu(data.result);
},

_onProviderGotError : function(e, data) {
// TODO: _onProviderGotError
this.emit('error', data);
this._emit('error', data);
}
}, {
live : true
lazyInit : true
}));

});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
modules.define('suggest', function(provide, Suggest) {

provide(Suggest.decl({ modName : 'has-dataprovider' }, {
provide(Suggest.declMod({ modName : 'has-dataprovider' }, {
onSetMod : {
'js' : {
'inited' : function() {
2 changes: 1 addition & 1 deletion blocks/suggest/suggest.deps.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
({
mustDeps : [
{ block : 'i-bem', elems : 'dom' },
{ block : 'i-bem-dom' },
{ block : 'jquery', elems : 'event', mods : { type : 'pointer' } }
],
shouldDeps : [
69 changes: 34 additions & 35 deletions blocks/suggest/suggest.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
modules.define(
'suggest',
['i-bem__dom', 'keyboard__codes', 'sg-datalist', 'popup', 'input'],
function(provide, BemDom, keyCodes, Datalist, Popup, Input) {
['i-bem-dom', 'keyboard__codes', 'sg-datalist', 'popup', 'input', 'menu'],
function(provide, BemDom, keyCodes, Datalist, Popup, Input, Menu) {

var CHANGE_SOURCE_DATALIST = 'datalist';

provide(BemDom.decl(this.name, {
provide(BemDom.declBlock(this.name, {
beforeSetMod : {
'opened' : {
'true' : function() {
@@ -23,16 +23,16 @@ provide(BemDom.decl(this.name, {
onSetMod : {
'js' : {
'inited' : function() {
this._input = this.findBlockInside(Input.getName())
this._input = this.findChildBlock(Input)
.on('change', this._onInputChange, this);

this._popup = this.findBlockInside(Popup.getName())
.setAnchor(this._input)
.on({ modName : 'visible', modVal : '' }, this._onPopupHide, this);
var popup = this._popup = this.findChildBlock(Popup);
popup.setAnchor(this._input);
this._events(popup).on({ modName : 'visible', modVal : false }, this._onPopupHide, this);

this._datalist = this._popup.findBlockInside(Datalist.getName())
.on('item-click', this._onMenuItemClick, this);
this._menu = this._datalist.findBlockOn('menu');
var datalist = this._datalist = this._popup.findChildBlock(Datalist);
this._events(datalist).on('item-click', this._onMenuItemClick, this);
this._menu = datalist.findMixedBlock(Menu);

this.hasMod('focused') && this._focus();

@@ -49,14 +49,12 @@ provide(BemDom.decl(this.name, {
},

'' : function() {
this._datalist.un('items', this._onMenuGotItems, this);
this
.unbindFrom(this._popup.domElem, 'pointerpress', this._onPopupPointerPress)
.unbindFromDoc('keydown', this._onKeyDown)
.unbindFromDoc('keypress', this._onKeyPress)
.delMod('opened')
._input
.delMod('focused');
this._events(this._datalist).un('items', this._onMenuGotItems, this);
this._domEvents(this._popup.domElem).un('pointerpress', this._onPopupPointerPress);
this._domEvents(document).un('keydown', this._onKeyDown);
this._domEvents(document).un('keypress', this._onKeyPress);
this.delMod('opened');
this._input.delMod('focused');
}
},

@@ -67,12 +65,12 @@ provide(BemDom.decl(this.name, {

'true' : function() {
this._popup.setMod('visible');
this._datalist.on('item-hover', this._onMenuItemHover, this);
this._events(this._datalist).on('item-hover', this._onMenuItemHover, this);
},

'' : function() {
this._popup.delMod('visible');
this._datalist.un('item-hover', this._onMenuItemHover, this);
this._events(this._datalist).un('item-hover', this._onMenuItemHover, this);

this._isMenuEmpty = null;
this._hoveredItem = null;
@@ -126,19 +124,17 @@ provide(BemDom.decl(this.name, {
},

_focus : function() {
this
.bindToDoc('keydown', this._onKeyDown)
.bindToDoc('keypress', this._onKeyPress)
.bindTo(this._popup.domElem, 'pointerpress', this._onPopupPointerPress)
._input
.setMod('focused');
this._datalist.on('items', this._onMenuGotItems, this);
this._domEvents(document).on('keydown', this._onKeyDown);
this._domEvents(document).on('keypress', this._onKeyPress);
this._domEvents(this._popup.domElem).on('pointerpress', this._onPopupPointerPress);
this._input.setMod('focused');
this._events(this._datalist).on('items', this._onMenuGotItems, this);
},

_refocusControl : function() {
this._needRefocusControl = false;
this._input.setMod('focused');
this.unbindFromDoc('pointerrelease', this._refocusControl);
this._domEvents(document).un('pointerrelease', this._refocusControl);
},

_hoverNextMenuItem : function(dir) {
@@ -192,14 +188,14 @@ provide(BemDom.decl(this.name, {

_onPopupPointerPress : function() {
this._needRefocusControl = true;
this.unbindFrom(this._popup.domElem, 'pointerpress', this._onPopupPointerPress);
this.bindToDoc('pointerrelease', this._refocusControl);
this._domEvents(this._popup.domElem).un('pointerpress', this._onPopupPointerPress);
this._domEvents(document).on('pointerrelease', this._refocusControl);
},

_onMenuGotItems : function(e, data) {
this._hoveredItem = null;
if(this._isMenuEmpty = !data.result.length) {
this.delMod('opened')
this.delMod('opened');
} else {
this
.setMod('opened')
@@ -221,16 +217,19 @@ provide(BemDom.decl(this.name, {
if(this.hasMod('focused')) {
this._requestData(e.target.getVal());
}
this.emit('change', data);
this._emit('change', data);
},

_onInputFocusChange : function(e, data) {
this.setMod('focused', data.modVal);
}
}, {
live : function() {
this.liveInitOnBlockInsideEvent({ modName : 'focused', modVal : '*' }, Input.getName(),
this.prototype._onInputFocusChange);
lazyInit : true,
onInit : function() {
this._events(Input).on({
modName : 'focused',
modVal : '*'
}, this.prototype._onInputFocusChange);
}
}));

3 changes: 1 addition & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -6,8 +6,7 @@
"Vladimir Varankin <nek.narqo@gmail.com> (http://github.com/narqo)"
],
"dependencies": {
"bem-core": "^2.4.0",
"bem-components": "^2.1.0"
"bem-components": "#v5-aristov"
},
"devDependencies": {
"bem-pr": "~0.10.0"