Deepali has uploaded a new change for review.
https://gerrit.wikimedia.org/r/142555
Change subject: Same readability options on all chapters of the book
......................................................................
Same readability options on all chapters of the book
Keep the readability options when navigating through book by clicking on
next/prev or table of contents links in navbar.
Bug:66957
Change-Id: Ic0045466596ec93e5e8511acb8a99d7a3cca933f
---
M modules/ext.BookManagerv2.js
M modules/ext.BookManagerv2js.css
2 files changed, 103 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BookManagerv2
refs/changes/55/142555/1
diff --git a/modules/ext.BookManagerv2.js b/modules/ext.BookManagerv2.js
index 0636289..4776808 100644
--- a/modules/ext.BookManagerv2.js
+++ b/modules/ext.BookManagerv2.js
@@ -20,6 +20,80 @@
// Title of the current book
var bookTitle = $( 'div.mw-bookmanagerv2-page-title' ).text();
+ if ( $( 'a.mw-bookmanagerv2-nav-prev' ).attr( 'href' ) ) {
+ var prevLink = $( 'a.mw-bookmanagerv2-nav-prev' ).attr( 'href'
);
+ }
+ else {
+ prevLink = '';
+ }
+ if ( $( 'a.mw-bookmanagerv2-nav-next' ).attr( 'href' ) ) {
+ var nextLink = $( 'a.mw-bookmanagerv2-nav-next' ).attr( 'href'
);
+ }
+ else {
+ nextLink = '';
+ }
+ var readabilityOptions = {},
+ getVars = {};
+
+ // Hide collapse option
+ $( 'a.mw-bookmanagerv2-nav-collapse' ).hide();
+
+ function updateLink() {
+ var prevQuerySeparator = prevLink.indexOf( '?' ) === -1 ? '?' :
'&',
+ nextQuerySeparator = nextLink.indexOf( '?' ) === -1 ?
'?' : '&',
+ parameterString = $.param( readabilityOptions );
+ if ( $( 'a.mw-bookmanagerv2-nav-prev' ).attr( 'href' ) ) {
+ $( 'a.mw-bookmanagerv2-nav-prev' ).attr( 'href',
prevLink + nextQuerySeparator + parameterString );
+ }
+ if ( $( 'a.mw-bookmanagerv2-nav-next' ).attr( 'href' ) ) {
+ $( 'a.mw-bookmanagerv2-nav-next' ).attr( 'href',
nextLink + nextQuerySeparator + parameterString );
+ }
+ }
+
+ function initialize() {
+ // Get $_GET variables from the page url
+ document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g,
function () {
+ function decode(s) {
+ return decodeURIComponent(s.split("+").join(" "));
+ }
+ getVars[decode(arguments[1])] = decode(arguments[2]);
+ });
+
+ readabilityOptions = getVars;
+
+ // Set readability options based on GET variables
+ if( getVars['fullscreen'] === 'true' ) {
+ $( 'div#mw-navigation' ).hide();
+ $( 'div#footer' ).hide();
+ $( 'a.mw-bookmanagerv2-nav-prev' ).hide();
+ $( 'a.mw-bookmanagerv2-nav-next' ).hide();
+ $( 'a.mw-bookmanagerv2-nav-collapse' ).show();
+ $( 'a.mw-bookmanagerv2-nav-fullscreen' ).hide();
+ $( 'div#content' ).addClass( 'fullscreen' );
+ updateLink();
+ }
+ if( getVars['font'] ) {
+ $( 'div#mw-content-text' ).css( 'font-family',
getVars['font'] );
+ }
+ if( getVars['align'] ) {
+ $( 'div#mw-content-text' ).css( 'text-align',
getVars['align'] );
+ }
+ if( getVars['size'] ) {
+ $( 'div#mw-content-text' ).css( 'font-size',
getVars['size'] + '%' );
+ }
+ if( getVars['line-space'] ) {
+ $( 'div#mw-content-text' ).css( 'line-height',
getVars['line-space'] + '%' );
+ }
+ if( getVars['layout'] === 'double' ) {
+ $( 'div#mw-content-text' ).addClass( 'doubleCol' );
+ }
+ if( getVars['bg'] === 'dark' ) {
+ $( 'div#mw-content-text' ).addClass( 'darkbg' );
+ $( 'div#mw-content-text' ).css( 'color', '#ffffff' );
+ }
+ }
+
+ initialize();
var getData = function ( input, pageIndex, pageSize, callback ) {
$.ajax({
@@ -110,16 +184,16 @@
$( '#mw-bookmanagerv2-contents-search-text' ).on( 'autocompleteselect',
function( event, ui ) {
$( '#mw-bookmanagerv2-contents-search-text' ).val(
ui.item.label );
- window.location.assign( mw.util.getUrl( ui.item.value ) );
+ var url = mw.util.getUrl( ui.item.value ),
+ querySeparator = url.indexOf( '?' ) === -1 ? '?' : '&',
+ parameterString = $.param( readabilityOptions );
+ window.location.assign( url + querySeparator + parameterString
);
return false;
});
$( '#mw-bookmanagerv2-contents-search-text' ).on( 'autocompletefocus',
function() {
return false;
});
-
- // Hide collapse option
- $( 'a.mw-bookmanagerv2-nav-collapse' ).hide();
// Move title below nav-bar
var $title = $( '#firstHeading' );
@@ -170,35 +244,55 @@
// Readability options
$( '.mw-bookmanagerv2-left-align' ).click( function () {
$( 'div#mw-content-text' ).css( 'text-align', 'left' );
+ readabilityOptions['align'] = 'left';
+ updateLink();
});
$( '.mw-bookmanagerv2-right-align' ).click( function () {
$( 'div#mw-content-text' ).css( 'text-align', 'right' );
+ readabilityOptions['align'] = 'right';
+ updateLink();
});
$( '.mw-bookmanagerv2-justify' ).click( function () {
$( 'div#mw-content-text' ).css( 'text-align', 'justify' );
+ readabilityOptions['align'] = 'justify';
+ updateLink();
});
$( '.mw-bookmanagerv2-light-bg' ).click( function () {
$( 'div#mw-content-text' ).removeClass( 'darkbg' );
$( 'div#mw-content-text' ).css( 'color', '#252525' );
+ readabilityOptions['bg'] = 'light';
+ updateLink();
});
$( '.mw-bookmanagerv2-dark-bg' ).click( function () {
$( 'div#mw-content-text' ).addClass( 'darkbg' );
$( 'div#mw-content-text' ).css( 'color', '#ffffff' );
+ readabilityOptions['bg'] = 'dark';
+ updateLink();
});
$( '.mw-bookmanagerv2-font' ).change( function () {
$( 'div#mw-content-text' ).css( 'font-family', $( this ).val()
);
+ readabilityOptions['font'] = $( this ).val();
+ updateLink();
});
$( '.mw-bookmanagerv2-size' ).change( function () {
$( 'div#mw-content-text' ).css( 'font-size', $( this ).val() +
'%' );
+ readabilityOptions['size'] = $( this ).val();
+ updateLink();
});
$( '.mw-bookmanagerv2-line-spacing' ).change( function () {
$( 'div#mw-content-text' ).css( 'line-height', $( this ).val()
+ '%' );
+ readabilityOptions['line-space'] = $( this ).val();
+ updateLink();
});
$( '.mw-bookmanagerv2-single-col' ).click( function () {
$( 'div#mw-content-text' ).removeClass( 'doubleCol' );
+ readabilityOptions['layout'] = 'single';
+ updateLink();
});
$( '.mw-bookmanagerv2-double-col' ).click( function () {
$( 'div#mw-content-text' ).addClass( 'doubleCol' );
+ readabilityOptions['layout'] = 'double';
+ updateLink();
});
// Fullscreen option
@@ -210,6 +304,8 @@
$( this ).hide();
$( 'a.mw-bookmanagerv2-nav-collapse' ).show();
$( 'div#content' ).addClass( 'fullscreen' );
+ readabilityOptions['fullscreen'] = 'true';
+ updateLink();
return false;
});
@@ -221,6 +317,8 @@
$( this ).hide();
$( 'a.mw-bookmanagerv2-nav-fullscreen' ).show();
$( 'div#content' ).removeClass( 'fullscreen' );
+ readabilityOptions['fullscreen'] = 'false';
+ updateLink();
return false;
});
diff --git a/modules/ext.BookManagerv2js.css b/modules/ext.BookManagerv2js.css
index 173da76..7da224b 100644
--- a/modules/ext.BookManagerv2js.css
+++ b/modules/ext.BookManagerv2js.css
@@ -139,6 +139,7 @@
div#mw-content-text.doubleCol h1#firstHeading {
border: none;
margin: 125px 0px 50px 0px;
+ padding-bottom: 120px;
}
div#mw-content-text.doubleCol h1#firstHeading span {
--
To view, visit https://gerrit.wikimedia.org/r/142555
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic0045466596ec93e5e8511acb8a99d7a3cca933f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BookManagerv2
Gerrit-Branch: master
Gerrit-Owner: Deepali <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits