-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1393 from /issues/1392@v2
dropdown: get rid of wrapping root `div` node (close #1392)
- Loading branch information
Showing
32 changed files
with
177 additions
and
89 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
18 changes: 11 additions & 7 deletions
18
common.blocks/dropdown/_switcher/dropdown_switcher_button.bemhtml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
block('dropdown').mod('switcher', 'button').elem('switcher').content()(function() { | ||
var content = this.ctx.content; | ||
if(Array.isArray(content)) return content; | ||
block('dropdown').mod('switcher', 'button').elem('switcher').def()(function() { | ||
var dropdown = this._dropdown, | ||
switcher = dropdown.switcher; | ||
|
||
var res = this.isSimple(content)? | ||
{ block : 'button', text : content } : | ||
content; | ||
if(Array.isArray(switcher)) return switcher; | ||
|
||
var res = this.isSimple(switcher)? | ||
{ block : 'button', text : switcher } : | ||
switcher; | ||
|
||
if(res.block === 'button') { | ||
var resMods = res.mods || (res.mods = {}), | ||
dropdownMods = this.mods; | ||
resMods.size || (resMods.size = dropdownMods.size); | ||
resMods.theme || (resMods.theme = dropdownMods.theme); | ||
resMods.disabled = dropdownMods.disabled; | ||
|
||
res.mix = apply('mix'); | ||
} | ||
|
||
return res; | ||
return applyCtx(res); | ||
}); |
14 changes: 9 additions & 5 deletions
14
common.blocks/dropdown/_switcher/dropdown_switcher_button.bh.js
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
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
18 changes: 11 additions & 7 deletions
18
common.blocks/dropdown/_switcher/dropdown_switcher_link.bemhtml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
block('dropdown').mod('switcher', 'link').elem('switcher').content()(function() { | ||
var content = this.ctx.content; | ||
if(Array.isArray(content)) return content; | ||
block('dropdown').mod('switcher', 'link').elem('switcher').def()(function() { | ||
var dropdown = this._dropdown, | ||
switcher = dropdown.switcher; | ||
|
||
var res = this.isSimple(content)? | ||
{ block : 'link', mods : { pseudo : true }, content : content } : | ||
content; | ||
if(Array.isArray(switcher)) return switcher; | ||
|
||
var res = this.isSimple(switcher)? | ||
{ block : 'link', mods : { pseudo : true }, content : switcher } : | ||
switcher; | ||
|
||
if(res.block === 'link') { | ||
var resMods = res.mods || (res.mods = {}), | ||
dropdownMods = this.mods; | ||
resMods.theme || (resMods.theme = dropdownMods.theme); | ||
resMods.disabled = dropdownMods.disabled; | ||
|
||
res.mix = apply('mix'); | ||
} | ||
|
||
return res; | ||
return applyCtx(res); | ||
}); |
14 changes: 9 additions & 5 deletions
14
common.blocks/dropdown/_switcher/dropdown_switcher_link.bh.js
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,47 @@ | ||
module.exports = function(bh) { | ||
|
||
bh.match('dropdown', function(ctx, json) { | ||
ctx.js(true); | ||
bh.match({ | ||
'dropdown' : function(ctx) { | ||
var dropdown = ctx.json(); | ||
|
||
var popup = json.popup; | ||
ctx | ||
.js(ctx.extend({ id : ctx.generateId() }, ctx.js())) | ||
.tParam('dropdown', dropdown) | ||
.tParam('theme', ctx.mod('theme')) | ||
.tParam('mix', [dropdown].concat( | ||
dropdown.switcher.mix || [], | ||
dropdown.mix || [])); | ||
|
||
if(ctx.isSimple(popup) || popup.block !== 'popup') { | ||
popup = { block : 'popup', content : popup }; | ||
} | ||
return [{ elem : 'switcher' }, { elem : 'popup' }]; | ||
}, | ||
|
||
'dropdown__popup' : function(ctx) { | ||
var dropdown = ctx.tParam('dropdown'), | ||
popup = dropdown.popup; | ||
|
||
if(ctx.isSimple(popup) || popup.block !== 'popup') { | ||
popup = { block : 'popup', content : popup }; | ||
} | ||
|
||
var popupMods = popup.mods || (popup.mods = {}); | ||
popupMods.theme || (popupMods.theme = ctx.tParam('theme')); | ||
popupMods.hasOwnProperty('autoclosable') || (popupMods.autoclosable = true); | ||
|
||
var popupMods = popup.mods || (popup.mods = {}); | ||
popupMods.theme || (popupMods.theme = ctx.mod('theme')); | ||
popupMods.hasOwnProperty('autoclosable') || (popupMods.autoclosable = true); | ||
popupMods.target = 'anchor'; | ||
|
||
popupMods.target = 'anchor'; | ||
popup.mix = [dropdown].concat(popup.mix || []); | ||
|
||
ctx.content([ | ||
{ elem : 'switcher', content : json.switcher }, | ||
popup | ||
], true); | ||
return popup; | ||
}, | ||
|
||
'dropdown__switcher' : function(ctx) { | ||
var dropdown = ctx.tParam('dropdown'), | ||
switcher = dropdown.switcher; | ||
|
||
switcher.block && (switcher.mix = ctx.tParam('mix')); | ||
|
||
return switcher; | ||
} | ||
}); | ||
|
||
}; |
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
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
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
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
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
1 change: 1 addition & 0 deletions
1
common.blocks/dropdown/dropdown.tmpl-specs/10-default_link.bemjson.js
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
2 changes: 1 addition & 1 deletion
2
common.blocks/dropdown/dropdown.tmpl-specs/10-default_link.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<div class="dropdown dropdown_switcher_link dropdown_theme_islands dropdown_disabled i-bem" data-bem="{"dropdown":{}}"><span class="link link_pseudo link_theme_islands link_disabled link__control i-bem" data-bem="{"link":{}}">link</span><div class="popup popup_theme_islands popup_autoclosable popup_target_anchor i-bem" data-bem="{"popup":{}}">bemjson</div></div> | ||
<span class="link link_pseudo link_theme_islands link_disabled link__control dropdown dropdown_switcher_link dropdown_theme_islands dropdown_disabled i-bem" data-bem="{"link":{},"dropdown":{"id":"uniq14257605137441"}}">link</span><div class="popup popup_theme_islands popup_autoclosable popup_target_anchor dropdown dropdown_switcher_link dropdown_theme_islands dropdown_disabled i-bem" data-bem="{"popup":{},"dropdown":{"id":"uniq14257605137441"}}">bemjson</div> |
1 change: 1 addition & 0 deletions
1
common.blocks/dropdown/dropdown.tmpl-specs/20-default_button.bemjson.js
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
2 changes: 1 addition & 1 deletion
2
common.blocks/dropdown/dropdown.tmpl-specs/20-default_button.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<div class="dropdown dropdown_switcher_button dropdown_theme_islands dropdown_size_m dropdown_disabled i-bem" data-bem="{"dropdown":{}}"><button class="button button_size_m button_theme_islands button_disabled button__control i-bem" data-bem="{"button":{}}" role="button" type="button" disabled="disabled"><span class="button__text">button</span></button><div class="popup popup_theme_islands popup_autoclosable popup_target_anchor i-bem" data-bem="{"popup":{}}">bemjson</div></div> | ||
<button class="button button_size_m button_theme_islands button_disabled button__control dropdown dropdown_switcher_button dropdown_theme_islands dropdown_size_m dropdown_disabled i-bem" data-bem="{"button":{},"dropdown":{"id":"uniq14257605137441"}}" role="button" type="button" disabled="disabled"><span class="button__text">button</span></button><div class="popup popup_theme_islands popup_autoclosable popup_target_anchor dropdown dropdown_switcher_button dropdown_theme_islands dropdown_size_m dropdown_disabled i-bem" data-bem="{"popup":{},"dropdown":{"id":"uniq14257605137441"}}">bemjson</div> |
1 change: 1 addition & 0 deletions
1
common.blocks/dropdown/dropdown.tmpl-specs/30-switcher_link_custom_popup.bemjson.js
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
2 changes: 1 addition & 1 deletion
2
common.blocks/dropdown/dropdown.tmpl-specs/30-switcher_link_custom_popup.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<div class="dropdown dropdown_switcher_link i-bem" data-bem="{"dropdown":{}}"><a class="link link_theme_islands link__control i-bem" data-bem="{"link":{}}" tabindex="0">link</a><div class="popup popup_autoclosable popup_target_anchor i-bem" data-bem="{"popup":{}}"><a class="link link_theme_islands link__control i-bem" data-bem="{"link":{}}" tabindex="0">link</a></div></div> | ||
<a class="link link_theme_islands dropdown dropdown_switcher_link link__control i-bem" tabindex="0" data-bem="{"link":{},"dropdown":{"id":"uniq14257605137441"}}">link</a><div class="popup popup_autoclosable popup_target_anchor dropdown dropdown_switcher_link i-bem" data-bem="{"popup":{},"dropdown":{"id":"uniq14257605137441"}}"><a class="link link_theme_islands link__control i-bem" tabindex="0" data-bem="{"link":{}}">link</a></div> |
Oops, something went wrong.