Skip to content
Browse files

Language links refactoring and restyling

  • Loading branch information...
1 parent a56bbb8 commit 4e0abbfb79bcb0c8aa26f36050bc19227fc4dc78 @mishanga committed
View
2 blocks/b-card/b-card.bemhtml
@@ -15,7 +15,7 @@ block b-card {
var c = [];
- for(var i = this.ctx.langs.length; i--;) c.push({
+ for(var i = this.ctx.langs.length; i--;) c.unshift({
block: 'b-link',
mods: {
lang: this.ctx.langs[i],
View
11 blocks/b-card/b-card.css
@@ -36,11 +36,16 @@ body .b-card__side
.b-card__switch .b-link
{
+ display: none;
+
+ float: left;
+
margin-right: 0.5em;
+
+ line-height: 1;
}
-.b-card_lang_ru .b-link_lang_ru,
-.b-card_lang_en .b-link_lang_en
+.b-card__switch .b-link_js_inited
{
- display: none;
+ display: block;
}
View
5 blocks/b-card/b-card.deps.js
@@ -2,7 +2,10 @@
mustDeps: [
{
block: 'b-link',
- mods: { pseudo: 'yes' }
+ mods: {
+ pseudo: 'yes',
+ current: 'yes'
+ }
}
]
})
View
16 blocks/b-card/b-card.js
@@ -1,14 +1,28 @@
BEM.DOM.decl({ name: 'b-card' }, {
onSetMod : {
+
js : function() {
- var card = this;
+
+ var card = this,
+ currentLink;
+
$.each(this.findBlocksInside('switch', 'b-link'), function() {
+
+ card.getMod('lang') == this.getMod('lang') &&
+ (currentLink = this.setMod('current', 'yes').setMod('disabled', 'yes'));
+
this.on('click', function() {
+ console.log('switch to ' + this.getMod('lang'));
card.setMod('lang', this.getMod('lang'));
+ currentLink.delMod('current').delMod('disabled');
+ currentLink = this.setMod('current', 'yes').setMod('disabled', 'yes');
})
+
});
+
}
+
}
});
View
7 blocks/b-link/_current/b-link_current_yes.css
@@ -0,0 +1,7 @@
+.i-ua_js_yes .b-link_current_yes
+{
+ cursor: default;
+ color: #000 !important;
+
+ border-bottom: none;
+}
View
9 blocks/b-link/_pseudo/b-link_pseudo_yes.css
@@ -0,0 +1,9 @@
+.b-link_pseudo_yes
+{
+ color: #2879ac;
+}
+
+.b-link_pseudo_yes:hover
+{
+ color: #f00 !important;
+}

0 comments on commit 4e0abbf

Please sign in to comment.
Something went wrong with that request. Please try again.