Last active
August 29, 2015 14:10
-
-
Save megatolya/98da2cf92286859f7194 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var App = Backbone.Model.extend({ | |
defaults: { | |
headerText: 'hello world' | |
} | |
}); | |
var app = new App; | |
var mybemjson = [{ | |
block: 'b-page', | |
content: [{ | |
block: 'checkbox', | |
bind: 'app', | |
attrs: { | |
disabled: function(app) { | |
return Boolean(app.get('headerText')); | |
} | |
} | |
}] | |
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mybemjson = { | |
block: 'b-page', | |
content: { | |
block: 'list', | |
content: [ | |
{block: 'item', content: 'Сделать что-то'}, | |
{block: 'item', content: 'Сделать что-то еще'} | |
] | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var App = Backbone.Model.extend({ | |
defaults: { | |
headerText: 'hello world' | |
} | |
}); | |
var app = new App; | |
var mybemjson = [{ | |
block: 'b-page', | |
content: [{ | |
block: 'header', | |
bind: 'app', | |
// меняется в зависимости от изменении `model` | |
content: function(app) { | |
return app.get('headerText'); | |
} | |
}] | |
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEM.DOM.decl(‘b-page’, { | |
onSetMod: {…}, | |
showSettings: function() {}, | |
showAdvertisement: function() {}, | |
showAnotherShtonibut: function() {} | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
block: 'task', | |
iterate: 'task in tasks,', | |
bind: 'task', | |
content: function(task) { | |
var name = task.get('name'); | |
if (task.get('done')) { | |
name += ' [done]'; | |
} | |
return name; | |
}, | |
onClick: function(event) { | |
task.set('done', true); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Tasks = Backbone.Collection.extend(); | |
var Task = Backbone.Model.extend({ | |
initialize: function(text) { | |
this.set('name', text); | |
}, | |
defaults: { | |
done: false | |
} | |
}); | |
var tasks = new Tasks([ | |
new Task('Сделать что-то'), | |
new Task('Сделать что-то еще'), | |
new Task('Сделать все остальное'), | |
new Task('Все переделать') | |
]); | |
var mybemjson = [{ | |
block: 'b-page', | |
content: [{ | |
block: 'list', | |
content: { | |
block: 'item', | |
iterate: 'task in tasks', | |
bind: 'task', | |
content: function(task) { | |
var name = task.get('name'); | |
if (task.get('done')) { | |
name += ' [done]'; | |
} | |
return name; | |
} | |
} | |
}] | |
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var App = Backbone.Model.extend({ | |
defaults: { | |
headerText: 'hello world' | |
} | |
}); | |
var app = new App; | |
var mybemjson = [{ | |
block: 'b-page', | |
content: [{ | |
block: 'checkbox', | |
bind: 'app', | |
mods: { | |
disabled: function(app) { | |
return !Boolean(app.get('headerText')); | |
} | |
} | |
}] | |
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var model = new Backbone.Model.extend(); | |
var mybemjson = [{ | |
block: 'b-page', | |
content: [{ | |
block: 'header', | |
// меняется в зависимости от изменении `model` | |
content: function() { | |
return model.get('something'); | |
} | |
}] | |
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// auth.js | |
channels(‘api’).on(‘authChanged’, function() {}}); | |
channels(‘api’).on(‘backgroundChanged’, function() {}); | |
BEM.DOM.decl(‘auth’, {...}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEM.DOM.decl('task', { | |
onSetMod: { | |
js: function() { | |
this.bindTo('click', function() { | |
this.getModel().set('done', true); | |
}); | |
} | |
}, | |
getModel: function() {..} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// b-page.js | |
this.trigger('authChanged', authState); | |
// auth.js | |
BEM.blocks['b-page'].on('something-happened', doSomething); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment