Dbrant has uploaded a new change for review. https://gerrit.wikimedia.org/r/176936
Change subject: [WIP] Make references collapsible (and collapse by default) ...................................................................... [WIP] 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, 89 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia refs/changes/36/176936/1 diff --git a/wikipedia/assets/bundle.js b/wikipedia/assets/bundle.js index 68544a1..3c44e7a 100644 --- a/wikipedia/assets/bundle.js +++ b/wikipedia/assets/bundle.js @@ -454,6 +454,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; @@ -520,6 +521,7 @@ content = transformer.transform( "section", content ); content = transformer.transform( "hideTables", content ); content = transformer.transform( "hideIPA", content ); + content = transformer.transform( "hideRefs", content ); return [ heading, content ]; } @@ -815,6 +817,47 @@ 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); + + //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 8a89e5c..1cf285c 100644 --- a/wikipedia/res/values-qq/strings.xml +++ b/wikipedia/res/values-qq/strings.xml @@ -357,4 +357,5 @@ Preceded by {{msg-wm|Wikipedia-android-strings-alpha update notification title}}.</string> <string name="dialog_close_description">Button description for the close image button. The text is mainly for screen readers. {{Identical|Close}}</string> + <string name="expand_refs">Title for a button that, when clicked, will expand the list of references at the bottom of a page.</string> </resources> diff --git a/wikipedia/res/values/strings.xml b/wikipedia/res/values/strings.xml index 0e15c6a..88c6728 100644 --- a/wikipedia/res/values/strings.xml +++ b/wikipedia/res/values/strings.xml @@ -276,4 +276,5 @@ <string name="alpha_update_notification_title">New alpha update available</string> <string name="alpha_update_notification_text">Tap to download</string> <string name="dialog_close_description">Close</string> + <string name="expand_refs">Expand to view references</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 e6449c1..8080382 100644 --- a/wikipedia/src/main/java/org/wikipedia/page/PageViewFragmentInternal.java +++ b/wikipedia/src/main/java/org/wikipedia/page/PageViewFragmentInternal.java @@ -205,6 +205,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 ebc9c2b..cccb1ef 100644 --- a/www/js/sections.js +++ b/www/js/sections.js @@ -44,6 +44,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; @@ -110,6 +111,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 aaeb572..486ea31 100644 --- a/www/js/transforms.js +++ b/www/js/transforms.js @@ -190,6 +190,47 @@ 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); + + //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: newchange Gerrit-Change-Id: I4d779aded8804398ea4134fad8cc90ce28b06849 Gerrit-PatchSet: 1 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: Dbrant <dbr...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits