Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
29 changes: 22 additions & 7 deletions blocks-common/i-bem/i-bem.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,18 @@ this.BEM = $.inherit($.observable, /** @lends BEM.prototype */ {
* @param {String} modVal1 First modifier value
* @param {String} [modVal2] Second modifier value
* @param {Boolean} [condition] Condition
* @example
* // before: <div class='icon'>
* icon.toggleMod('size', 'big', 'small');
* // after: <div class='icon icon_size_big'>
* @example
* // before: <div class='icon'>
* icon.toggleMod('size', 'big', 'small', isNeedBig === false);
* // after: <div class='icon icon_size_small'>
* @example
* // before: <div class='icon icon_size_small'>
* icon.toggleMod('size', 'big', 'small');
* // after: <div class='icon icon_size_big'>
* @returns {BEM}
*/
toggleMod : function(elem, modName, modVal1, modVal2, condition) {
Expand All @@ -389,6 +401,7 @@ this.BEM = $.inherit($.observable, /** @lends BEM.prototype */ {
modName = elem;
elem = undefined;
}

if(typeof modVal2 == 'undefined') {
modVal2 = '';
} else if(typeof modVal2 == 'boolean') {
Expand All @@ -397,13 +410,15 @@ this.BEM = $.inherit($.observable, /** @lends BEM.prototype */ {
}

var modVal = this.getMod(elem, modName);
(modVal == modVal1 || modVal == modVal2) &&
this.setMod(
elem,
modName,
typeof condition === 'boolean'?
(condition? modVal1 : modVal2) :
this.hasMod(elem, modName, modVal1)? modVal2 : modVal1);

this.setMod(
elem,
modName,
// если есть condition, тогда не важно текущее значение
typeof condition === 'boolean' ? ( condition ? modVal1 : modVal2 )
// иначе, если текущее значение "modVal1", значит ставим значение "modVal2"
// и во всех остальных случаях "modVal1"
: ( modVal === modVal1 ) ? modVal2 : modVal1 );

return this;

Expand Down
7 changes: 6 additions & 1 deletion blocks-touch/b-slider/b-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@
_delayedInit: function() {

var slider = this,
images = slider.findBlocksInside('b-icon');
bIcons = slider.findBlocksInside('b-icon'),
icons = slider.findBlocksInside('icon'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а ничего что в bem-bl нет ни icon ни image ?

images = slider.findBlocksInside('image');

// объединяем все возможные блоки-картинки
images = images.concat(icons, bIcons);

// если внутри есть картинки (b-icon),
// то отложить инициализацию до момента их полной загрузки,
Expand Down