Created
July 11, 2016 15:58
-
-
Save JiLiZART/efce467bad81b956fd33831776c7c5d5 to your computer and use it in GitHub Desktop.
bem ym page modal
This file contains hidden or 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
/** | |
* @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