jenkins-bot has submitted this change and it was merged.

Change subject: Make references collapsible (and collapse by default)
......................................................................


Make references collapsible (and collapse by default)

- Uses the same logic and styling as collapsing of infoboxes.

Change-Id: I4d779aded8804398ea4134fad8cc90ce28b06849
---
M wikipedia/assets/bundle.js
M wikipedia/res/values-qq/strings.xml
M wikipedia/res/values/strings.xml
M wikipedia/src/main/java/org/wikipedia/page/PageViewFragmentInternal.java
M www/js/sections.js
M www/js/transforms.js
6 files changed, 95 insertions(+), 0 deletions(-)

Approvals:
  BearND: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/wikipedia/assets/bundle.js b/wikipedia/assets/bundle.js
index 55f8b41..4370b72 100644
--- a/wikipedia/assets/bundle.js
+++ b/wikipedia/assets/bundle.js
@@ -450,6 +450,7 @@
     window.string_table_infobox = payload.string_table_infobox;
     window.string_table_other = payload.string_table_other;
     window.string_table_close = payload.string_table_close;
+    window.string_expand_refs = payload.string_expand_refs;
     window.pageTitle = payload.title;
     window.isMainPage = payload.isMainPage;
 
@@ -515,6 +516,7 @@
     content = transformer.transform( "section", content );
     content = transformer.transform( "hideTables", content );
     content = transformer.transform( "hideIPA", content );
+    content = transformer.transform( "hideRefs", content );
 
     return [ heading, content ];
 }
@@ -814,6 +816,50 @@
     return content;
 } );
 
+transformer.register( "hideRefs", function( content ) {
+    var refLists = content.querySelectorAll( "div.reflist" );
+    for (var i = 0; i < refLists.length; i++) {
+        var caption = "<strong>" + window.string_expand_refs + "</strong>";
+
+        //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.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 = tableCollapseClickHandler;
+        bottomDiv.onclick = tableCollapseClickHandler;
+    }
+    return content;
+} );
+
 /*
 OnClick handler function for IPA spans.
 */
diff --git a/wikipedia/res/values-qq/strings.xml 
b/wikipedia/res/values-qq/strings.xml
index 1cc35a8..3fb50ed 100644
--- a/wikipedia/res/values-qq/strings.xml
+++ b/wikipedia/res/values-qq/strings.xml
@@ -384,4 +384,5 @@
     * The first parameter is the title of the page the text snippet is from.
     * The second parameter is an HTML link to the page.
   </string>
+  <string name="expand_refs">Title for a button that, when clicked, will 
expand the list of references or notes at the bottom of a page.</string>
 </resources>
diff --git a/wikipedia/res/values/strings.xml b/wikipedia/res/values/strings.xml
index e1fb8e2..2fae47b 100644
--- a/wikipedia/res/values/strings.xml
+++ b/wikipedia/res/values/strings.xml
@@ -290,4 +290,5 @@
     <string name="gallery_save_success">Image saved successfully.</string>
     <string name="err_cannot_save_file">Cannot save file</string>
     <string name="snippet_share_intro">Interesting fact on @Wikipedia %1$s: 
%2$s</string>
+    <string name="expand_refs">Tap to expand</string>
 </resources>
diff --git 
a/wikipedia/src/main/java/org/wikipedia/page/PageViewFragmentInternal.java 
b/wikipedia/src/main/java/org/wikipedia/page/PageViewFragmentInternal.java
index ddd94c6..6464227 100644
--- a/wikipedia/src/main/java/org/wikipedia/page/PageViewFragmentInternal.java
+++ b/wikipedia/src/main/java/org/wikipedia/page/PageViewFragmentInternal.java
@@ -199,6 +199,7 @@
             leadSectionPayload.put("string_table_infobox", 
getString(R.string.table_infobox));
             leadSectionPayload.put("string_table_other", 
getString(R.string.table_other));
             leadSectionPayload.put("string_table_close", 
getString(R.string.table_close));
+            leadSectionPayload.put("string_expand_refs", 
getString(R.string.expand_refs));
             leadSectionPayload.put("isBeta", app.getReleaseType() != 
WikipediaApp.RELEASE_PROD);
             leadSectionPayload.put("isMainPage", 
page.getPageProperties().isMainPage());
             leadSectionPayload.put("apiLevel", Build.VERSION.SDK_INT);
diff --git a/www/js/sections.js b/www/js/sections.js
index dbb9c41..01dd228 100644
--- a/www/js/sections.js
+++ b/www/js/sections.js
@@ -48,6 +48,7 @@
     window.string_table_infobox = payload.string_table_infobox;
     window.string_table_other = payload.string_table_other;
     window.string_table_close = payload.string_table_close;
+    window.string_expand_refs = payload.string_expand_refs;
     window.pageTitle = payload.title;
     window.isMainPage = payload.isMainPage;
 
@@ -113,6 +114,7 @@
     content = transformer.transform( "section", content );
     content = transformer.transform( "hideTables", content );
     content = transformer.transform( "hideIPA", content );
+    content = transformer.transform( "hideRefs", content );
 
     return [ heading, content ];
 }
diff --git a/www/js/transforms.js b/www/js/transforms.js
index fd5fed0..2964241 100644
--- a/www/js/transforms.js
+++ b/www/js/transforms.js
@@ -190,6 +190,50 @@
     return content;
 } );
 
+transformer.register( "hideRefs", function( content ) {
+    var refLists = content.querySelectorAll( "div.reflist" );
+    for (var i = 0; i < refLists.length; i++) {
+        var caption = "<strong>" + window.string_expand_refs + "</strong>";
+
+        //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.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 = tableCollapseClickHandler;
+        bottomDiv.onclick = tableCollapseClickHandler;
+    }
+    return content;
+} );
+
 /*
 OnClick handler function for IPA spans.
 */

-- 
To view, visit https://gerrit.wikimedia.org/r/176936
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4d779aded8804398ea4134fad8cc90ce28b06849
Gerrit-PatchSet: 5
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <[email protected]>
Gerrit-Reviewer: BearND <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to