Skip to content

Instantly share code, notes, and snippets.

@JiLiZART
Created July 11, 2016 15:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JiLiZART/efce467bad81b956fd33831776c7c5d5 to your computer and use it in GitHub Desktop.
Save JiLiZART/efce467bad81b956fd33831776c7c5d5 to your computer and use it in GitHub Desktop.
bem ym page modal
/**
* @module Page
*/
modules.define(
'page',
['i-bem__dom', 'BEMHTML', 'jquery' 'modal'],
function (provide, BEMDOM, BEMHTML, $, Modal) {
/**
* @exports
* @class Page
* @bem
*
*/
provide(BEMDOM.decl(this.name, /** @lends Page.prototype */{
getDefaultParams: function () {
return {
modal: {
block: 'modal',
js: true,
mods: {theme: 'default'},
content: 'Modal has no content'
}
};
},
onSetMod: {
'js': {
'inited': function () {
this.__self._setInstance(this);
}
}
}
},/** @lends Page */{
getModal: function () {
if (!this._modal) {
var template = this._instance.params.modal,
$template = BEMDOM.init(BEMHTML.apply(template));
BEMDOM.append(
this.scope,
$template
);
this._modal = this.findBlockInside($template, Modal.getName());
}
return this._modal;
},
findBlockInside : function() {
return this._instance.findBlockInside.apply(this._instance, arguments);
},
findBlocksInside: function () {
return this._instance.findBlocksInside.apply(this._instance, arguments);
},
setMod: function () {
return this._instance.setMod.apply(this._instance, arguments);
},
delMod: function () {
return this._instance.delMod.apply(this._instance, arguments);
},
_setInstance: function(instance) {
this._instance = instance;
}
}));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment