jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/384090 )
Change subject: Fix collapsing of References.
......................................................................
Fix collapsing of References.
The page library collapses tables that are contained in a <table> element.
However, the list of references at the bottom of articles is not actually
a table, so it needs to be manually wrapped in a <table> tag.
The iOS app actually does this in native code (?) before passing the HTML
to the WebView, but we can do it as part of our transforms.
Bug: T177863
Change-Id: I1212b8336635cf6d6742ff659c0794ea6ea93254
---
M app/src/main/assets/bundle.js
M www/js/transforms/hideRefs.js
2 files changed, 25 insertions(+), 73 deletions(-)
Approvals:
jenkins-bot: Verified
Cooltey: Looks good to me, approved
diff --git a/app/src/main/assets/bundle.js b/app/src/main/assets/bundle.js
index 6baef47..5aeed8d 100644
--- a/app/src/main/assets/bundle.js
+++ b/app/src/main/assets/bundle.js
@@ -769,51 +769,27 @@
},{"../transformer":11,"wikimedia-page-library":19}],13:[function(require,module,exports){
var transformer = require("../transformer");
-var collapseTables = require("./collapseTables");
transformer.register( "hideRefs", function( content ) {
var refLists = content.querySelectorAll( "div.reflist" );
for (var i = 0; i < refLists.length; i++) {
- var caption = "<strong class='app_table_collapsed_caption'>" +
window.string_expand_refs + "</strong>";
+ // Wrap this div in a <table>, so that it will be caught by the
pagelibrary for collapsing.
+ var table = document.createElement( 'table' );
+ var tr = document.createElement( 'tr' );
+ var th = document.createElement( 'th' );
+ var td = document.createElement( 'td' );
+ th.style.display = "none";
+ th.innerHTML = window.string_expand_refs;
+ table.appendChild(th);
+ table.appendChild(tr);
+ tr.appendChild(td);
- //create the container div that will contain both the original table
- //and the collapsed version.
- var containerDiv = document.createElement( 'div' );
- containerDiv.className = 'app_table_container';
- refLists[i].parentNode.insertBefore(containerDiv, refLists[i]);
+ refLists[i].parentNode.insertBefore(table, refLists[i]);
refLists[i].parentNode.removeChild(refLists[i]);
-
- //create the collapsed div
- var collapsedDiv = document.createElement( 'div' );
- collapsedDiv.classList.add('app_table_collapsed_container');
- collapsedDiv.classList.add('app_table_collapsed_open');
- collapsedDiv.innerHTML = caption;
-
- //create the bottom collapsed div
- var bottomDiv = document.createElement( 'div' );
- bottomDiv.classList.add('app_table_collapsed_bottom');
- bottomDiv.classList.add('app_table_collapse_icon');
- bottomDiv.innerHTML = window.string_table_close;
-
- //add our stuff to the container
- containerDiv.appendChild(collapsedDiv);
- containerDiv.appendChild(refLists[i]);
- containerDiv.appendChild(bottomDiv);
-
- //give it just a little padding
- refLists[i].style.padding = "4px";
-
- //set initial visibility
- refLists[i].style.display = 'none';
- collapsedDiv.style.display = 'block';
- bottomDiv.style.display = 'none';
-
- //assign click handler to the collapsed divs
- collapsedDiv.onclick = collapseTables.handleTableCollapseOrExpandClick;
- bottomDiv.onclick = collapseTables.handleTableCollapseOrExpandClick;
+ td.appendChild(refLists[i]);
}
} );
-},{"../transformer":11,"./collapseTables":12}],14:[function(require,module,exports){
+},{"../transformer":11}],14:[function(require,module,exports){
var transformer = require("../../transformer");
transformer.register( "anchorPopUpMediaTransforms", function( content ) {
diff --git a/www/js/transforms/hideRefs.js b/www/js/transforms/hideRefs.js
index 98e1e59..6700b19 100644
--- a/www/js/transforms/hideRefs.js
+++ b/www/js/transforms/hideRefs.js
@@ -1,45 +1,21 @@
var transformer = require("../transformer");
-var collapseTables = require("./collapseTables");
transformer.register( "hideRefs", function( content ) {
var refLists = content.querySelectorAll( "div.reflist" );
for (var i = 0; i < refLists.length; i++) {
- var caption = "<strong class='app_table_collapsed_caption'>" +
window.string_expand_refs + "</strong>";
+ // Wrap this div in a <table>, so that it will be caught by the
pagelibrary for collapsing.
+ var table = document.createElement( 'table' );
+ var tr = document.createElement( 'tr' );
+ var th = document.createElement( 'th' );
+ var td = document.createElement( 'td' );
+ th.style.display = "none";
+ th.innerHTML = window.string_expand_refs;
+ table.appendChild(th);
+ table.appendChild(tr);
+ tr.appendChild(td);
- //create the container div that will contain both the original table
- //and the collapsed version.
- var containerDiv = document.createElement( 'div' );
- containerDiv.className = 'app_table_container';
- refLists[i].parentNode.insertBefore(containerDiv, refLists[i]);
+ refLists[i].parentNode.insertBefore(table, refLists[i]);
refLists[i].parentNode.removeChild(refLists[i]);
-
- //create the collapsed div
- var collapsedDiv = document.createElement( 'div' );
- collapsedDiv.classList.add('app_table_collapsed_container');
- collapsedDiv.classList.add('app_table_collapsed_open');
- collapsedDiv.innerHTML = caption;
-
- //create the bottom collapsed div
- var bottomDiv = document.createElement( 'div' );
- bottomDiv.classList.add('app_table_collapsed_bottom');
- bottomDiv.classList.add('app_table_collapse_icon');
- bottomDiv.innerHTML = window.string_table_close;
-
- //add our stuff to the container
- containerDiv.appendChild(collapsedDiv);
- containerDiv.appendChild(refLists[i]);
- containerDiv.appendChild(bottomDiv);
-
- //give it just a little padding
- refLists[i].style.padding = "4px";
-
- //set initial visibility
- refLists[i].style.display = 'none';
- collapsedDiv.style.display = 'block';
- bottomDiv.style.display = 'none';
-
- //assign click handler to the collapsed divs
- collapsedDiv.onclick = collapseTables.handleTableCollapseOrExpandClick;
- bottomDiv.onclick = collapseTables.handleTableCollapseOrExpandClick;
+ td.appendChild(refLists[i]);
}
} );
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/384090
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1212b8336635cf6d6742ff659c0794ea6ea93254
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Cooltey <[email protected]>
Gerrit-Reviewer: Sharvaniharan <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits