Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
awinogradov committed Jul 17, 2015
1 parent 1bb3e32 commit a930dbb
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 7 deletions.
29 changes: 26 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,39 @@
{
"name": "bem-forms",
"version": "0.0.0",
"authors": [
"version": "0.1.0",
"keywords": [
"bem",
"form",
"forms"
],
"author": [
"Vyacheslav Aristov <[email protected]>"
],
"contributors": [
{
"name": "Ivan Voischev",
"email": "[email protected]"
},
{
"name": "Anton Winogradov",
"email": "[email protected]"
},
{
"name": "Alexej Yaroshevich",
"email": "[email protected]"
},
{
"name": "Daniel Sabelnikov",
"email": "[email protected]"
}
],
"ignore": [
"node_modules",
"libs",
"bundles"
],
"dependencies": {
"bem-components": "bem/bem-components#v2"
"bem-components": "2.2.1"
},
"devDependencies": {
"bem-pr": "~0.10.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
display: none;

&.message_visible
&.message_showed
{
display: inherit;
}
Expand Down
2 changes: 1 addition & 1 deletion desktop.bundles/index/index.bemjson.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
type : 'input',
'has-validation' : true,
required : true,
message : 'text'
message : 'popup'
},
js : {
required : {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* @module form-field
*/
modules.define('form-field',
['i-bem__dom', 'validation'],
function(provide, BEMDOM, Validation, FormField) {

/**
* Field block
*/
FormField.decl({ block : this.name, modName : 'has-validation', modVal : true }, /** @lends form-field.prototype */{

onSetMod : {
'js' : {
'inited' : function() {
this.__base.apply(this, arguments);
}
}
},
/**
* Extend by custom logic
*/
_updateStatus : function() {
this.__base.apply(this, arguments);

if(this.getStatus() && this.getMessage()) {
this.setMessageVal(this.getStatus());
this.getMessage().show();
}
}
});

provide(FormField);

});
5 changes: 3 additions & 2 deletions test.blocks/test-form/test-form.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ provide(BEMDOM.decl(this.name, /** @lends test-form.prototype */{
this._prepare(val);
}.bind(this));

// You can bind to anothe form events
// this._form.on('change', function(e, data) {
// console.log('changed form', data);
// });
Expand All @@ -42,9 +43,9 @@ provide(BEMDOM.decl(this.name, /** @lends test-form.prototype */{
// true - valid
// false - invalid
if(this._form.getStatus()) {
console.log('valid');
console.log('form valid');
} else {
console.log('invalid');
console.log('form invalid');
}

}
Expand Down

0 comments on commit a930dbb

Please sign in to comment.