mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-18 17:13:31 +00:00
Don't render contents of collapsed sections
(speeds things up if raw tag editor is hidden)
This commit is contained in:
@@ -51,14 +51,17 @@ export function uiDisclosure(context, key, expandedDefault) {
|
||||
var wrap = selection.selectAll('.disclosure-wrap')
|
||||
.data([0]);
|
||||
|
||||
// enter/update
|
||||
wrap = wrap.enter()
|
||||
.append('div')
|
||||
.attr('class', 'disclosure-wrap disclosure-wrap-' + key)
|
||||
.merge(wrap);
|
||||
.merge(wrap)
|
||||
.classed('hide', !_expanded);
|
||||
|
||||
wrap
|
||||
.classed('hide', !_expanded)
|
||||
.call(_content);
|
||||
if (_expanded) {
|
||||
wrap
|
||||
.call(_content);
|
||||
}
|
||||
|
||||
|
||||
function toggle() {
|
||||
@@ -78,6 +81,11 @@ export function uiDisclosure(context, key, expandedDefault) {
|
||||
: (textDirection === 'rtl') ? '#iD-icon-backward' : '#iD-icon-forward'
|
||||
);
|
||||
|
||||
if (_expanded) {
|
||||
wrap
|
||||
.call(_content);
|
||||
}
|
||||
|
||||
wrap
|
||||
.call(uiToggle(_expanded));
|
||||
|
||||
@@ -86,30 +94,30 @@ export function uiDisclosure(context, key, expandedDefault) {
|
||||
};
|
||||
|
||||
|
||||
disclosure.title = function(_) {
|
||||
disclosure.title = function(val) {
|
||||
if (!arguments.length) return _title;
|
||||
_title = _;
|
||||
_title = val;
|
||||
return disclosure;
|
||||
};
|
||||
|
||||
|
||||
disclosure.expanded = function(_) {
|
||||
disclosure.expanded = function(val) {
|
||||
if (!arguments.length) return _expanded;
|
||||
_expanded = _;
|
||||
_expanded = val;
|
||||
return disclosure;
|
||||
};
|
||||
|
||||
|
||||
disclosure.updatePreference = function(_) {
|
||||
disclosure.updatePreference = function(val) {
|
||||
if (!arguments.length) return _updatePreference;
|
||||
_updatePreference = _;
|
||||
_updatePreference = val;
|
||||
return disclosure;
|
||||
};
|
||||
|
||||
|
||||
disclosure.content = function(_) {
|
||||
disclosure.content = function(val) {
|
||||
if (!arguments.length) return _content;
|
||||
_content = _;
|
||||
_content = val;
|
||||
return disclosure;
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@ describe('iD.uiRawTagEditor', function() {
|
||||
taglist = iD.uiRawTagEditor(context)
|
||||
.entityID(entity.id)
|
||||
.preset({isFallback: function() { return false; }})
|
||||
.tags(tags);
|
||||
.tags(tags)
|
||||
.expanded(true);
|
||||
|
||||
element = d3.select('body')
|
||||
.append('div')
|
||||
|
||||
Reference in New Issue
Block a user