Bug 1414169 - pt 7 - Refactor folding sections into reusable code. r=ng

MozReview-Commit-ID: Dah8zYC2OdH

--HG--
extra : rebase_source : dd608ac3097ddf072fa2b95c6221c79672345f21
This commit is contained in:
Michael Froman 2017-11-30 15:03:18 -06:00
Родитель e49fa718b2
Коммит 7445e1ec24
1 изменённых файлов: 24 добавлений и 22 удалений

Просмотреть файл

@ -389,15 +389,10 @@ var AboutWebRTC = {
return content;
}
let div = document.createElement("div");
let sectionCtrl = document.createElement("div");
sectionCtrl.className = "section-ctrl no-print";
let foldEffect = new FoldEffect(div, {
let div = new FoldableSection(content, {
showMsg: getString("log_show_msg"),
hideMsg: getString("log_hide_msg")
});
sectionCtrl.appendChild(foldEffect.render());
content.appendChild(sectionCtrl);
}).render();
for (let line of this._log) {
elem = document.createElement("p");
@ -420,12 +415,7 @@ PeerConnection.prototype = {
pc.className = "peer-connection";
pc.appendChild(this.renderHeading());
let div = document.createElement("div");
let sectionCtrl = document.createElement("div");
sectionCtrl.className = "section-ctrl no-print";
let foldEffect = new FoldEffect(div);
sectionCtrl.appendChild(foldEffect.render());
pc.appendChild(sectionCtrl);
let div = new FoldableSection(pc).render();
div.appendChild(this.renderDesc());
div.appendChild(new ICEStats(this._report).render());
@ -755,15 +745,10 @@ ICEStats.prototype = {
heading.textContent = getString("raw_candidates_heading");
section.appendChild(heading);
let div = document.createElement("div");
let sectionCtrl = document.createElement("div");
sectionCtrl.className = "section-ctrl no-print";
let foldEffect = new FoldEffect(div, {
showMsg: getString("raw_cand_show_msg"),
hideMsg: getString("raw_cand_hide_msg")
});
sectionCtrl.appendChild(foldEffect.render());
section.appendChild(sectionCtrl);
let div = new FoldableSection(section, {
showMsg: getString("raw_cand_show_msg"),
hideMsg: getString("raw_cand_hide_msg")
}).render();
div.appendChild(this.renderRawICECandidates());
@ -881,6 +866,23 @@ ICEStats.prototype = {
}
};
function FoldableSection(parentElement, options = {}) {
this._foldableElement = document.createElement("div");
if (parentElement) {
let sectionCtrl = document.createElement("div");
sectionCtrl.className = "section-ctrl no-print";
let foldEffect = new FoldEffect(this._foldableElement, options);
sectionCtrl.appendChild(foldEffect.render());
parentElement.appendChild(sectionCtrl);
}
}
FoldableSection.prototype = {
render() {
return this._foldableElement;
}
};
function SimpleTable(heading, data, caption) {
this._heading = heading || [];
this._data = data;