jenkins-bot has submitted this change and it was merged.
Change subject: Wikieditor: Rework deferred building of toolbar
......................................................................
Wikieditor: Rework deferred building of toolbar
Currently sections of the toolbar can be built deferred. This
is done for the help section and the special characters. The
disadvantage is, that you can't modify such sections before
they are really loaded.
This patch modifies the behavior by doing the following:
* Toolbars are always built directly. After all, deferring isn't
used there anyway in the standard configuration.
* When a booklet is requested to be built only when it's needed,
the index and all pages will be built immediately, only the
content of the pages is deferred and built only when it is
needed.
Even on slow machines building all pages immediately doesn't cause
noticeable pauses, in fact, opening a page with special characters
seems even faster because only the page you need is built, not all
pages.
Since all pages exist from beginning, you can remove and add pages
from user scripts. It is still not possible to modify an existing
page (add or remove a row to a help page, add or remove a character,
unless it is the page that was opened last time), but this is something
that shouldn't be needed very often, so it should be acceptable that
it still doesn't work.
Bug: T25479
Bug: T70791
Change-Id: I0e61b1fd4f6139a251e53a1fac28b3821bc6b860
---
M modules/jquery.wikiEditor.toolbar.js
1 file changed, 24 insertions(+), 37 deletions(-)
Approvals:
GOIII: Looks good to me, but someone else must approve
TheDJ: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/jquery.wikiEditor.toolbar.js
b/modules/jquery.wikiEditor.toolbar.js
index 184c468..6322b9e 100644
--- a/modules/jquery.wikiEditor.toolbar.js
+++ b/modules/jquery.wikiEditor.toolbar.js
@@ -429,7 +429,7 @@
} )
.click( function ( event ) {
$( this ).parent().parent().find( '.page'
).hide();
- $( this ).parent().parent().find( '.page-' + $(
this ).attr( 'rel' ) ).show();
+ $( this ).parent().parent().find( '.page-' + $(
this ).attr( 'rel' ) ).show().trigger( 'loadPage' );
$( this ).siblings().removeClass( 'current' );
$( this ).addClass( 'current' );
var section = $( this ).parent().parent().attr(
'rel' );
@@ -444,12 +444,24 @@
return false;
} );
},
- buildPage: function ( context, id, page ) {
- var html, i;
+ buildPage: function ( context, id, page, deferLoad ) {
var $page = $( '<div>' ).attr( {
'class': 'page page-' + id,
'rel': id
} );
+ if ( deferLoad ) {
+ $page.addClass( 'loading' ).append( $( '<div>'
).addClass( 'spinner' ) );
+ $page.bind( 'loadPage', function () {
+
$.wikiEditor.modules.toolbar.fn.reallyBuildPage( context, id, page, $page );
+ $page.removeClass( 'loading' );
+ } );
+ } else {
+ $.wikiEditor.modules.toolbar.fn.reallyBuildPage(
context, id, page, $page );
+ }
+ return $page;
+ },
+ reallyBuildPage: function ( context, id, page, $page ) {
+ var html, i;
switch ( page.layout ) {
case 'table':
$page.addClass( 'page-table' );
@@ -507,7 +519,6 @@
$page.append( $characters );
break;
}
- return $page;
},
buildHeading: function ( context, headings ) {
var html = '<tr>';
@@ -614,33 +625,18 @@
$( this ).parent().parent().find( 'a'
).removeClass( 'current' );
$sections.css( 'overflow', 'hidden' );
- var animate = function ( $that ) {
- $sections
- .animate( { 'height':
$section.outerHeight() }, $section.outerHeight() * 2, function () {
- $that.css( 'overflow',
'visible' ).css( 'height', 'auto' );
- context.fn.trigger(
'resize' );
- } );
- };
if ( show ) {
$section.removeClass(
'section-hidden' )
.attr( 'aria-expanded',
'true' )
.animate( { opacity:
100.0 }, 'fast', 'linear', function () {
$( this
).addClass( 'section-visible' );
} );
-
- if ( $section.hasClass(
'loading' ) ) {
- // Loading of this
section was deferred, load it now
- var $that = $( this );
- $that.addClass(
'current loading' );
- setTimeout( function ()
{
-
$section.trigger( 'loadSection' );
- animate( $that
);
-
$that.removeClass( 'loading' );
+ $sections
+ .animate( { 'height':
$section.outerHeight() }, $section.outerHeight() * 2, function () {
+ $( this ).css(
'overflow', 'visible' ).css( 'height', 'auto' );
+
context.fn.trigger( 'resize' );
} );
- } else {
- animate( $( this ) );
- $( this ).addClass(
'current' );
- }
+ $( this ).addClass( 'current' );
} else {
$sections
.css( 'height',
$section.outerHeight() )
@@ -674,16 +670,7 @@
var selected = $.cookie( 'wikiEditor-' + context.instance +
'-toolbar-section' );
var show = selected === id;
- if ( section.deferLoad !== undefined && section.deferLoad && id
!== 'main' && !show ) {
- // This class shows the spinner and serves as a marker
for the click handler in buildTab()
- $section.addClass( 'loading' ).append( $( '<div>'
).addClass( 'spinner' ) );
- $section.bind( 'loadSection', function () {
-
$.wikiEditor.modules.toolbar.fn.reallyBuildSection( context, id, section,
$section );
- $section.removeClass( 'loading' );
- } );
- } else {
- $.wikiEditor.modules.toolbar.fn.reallyBuildSection(
context, id, section, $section );
- }
+ $.wikiEditor.modules.toolbar.fn.reallyBuildSection( context,
id, section, $section, section.deferLoad );
// Show or hide section
if ( id !== 'main' ) {
@@ -697,7 +684,7 @@
}
return $section;
},
- reallyBuildSection: function ( context, id, section, $section ) {
+ reallyBuildSection: function ( context, id, section, $section,
deferLoad ) {
context.$textarea.trigger( 'wikiEditor-toolbar-buildSection-' +
$section.attr( 'rel' ), [section] );
switch ( section.type ) {
case 'toolbar':
@@ -715,7 +702,7 @@
if ( 'pages' in section ) {
for ( var page in section.pages ) {
$pages.append(
-
$.wikiEditor.modules.toolbar.fn.buildPage( context, page, section.pages[page] )
+
$.wikiEditor.modules.toolbar.fn.buildPage( context, page, section.pages[page],
deferLoad )
);
$index.append(
$.wikiEditor.modules.toolbar.fn.buildBookmark( context, page,
section.pages[page] )
@@ -740,7 +727,7 @@
selected = $selectedIndex.attr( 'rel' );
}
$pages.children().hide();
- $pages.find( '*[rel="' + selected + '"]' ).show();
+ $pages.find( '*[rel="' + selected + '"]' ).show().trigger(
'loadPage' );
$index.children().removeClass( 'current' );
$selectedIndex.addClass( 'current' );
},
--
To view, visit https://gerrit.wikimedia.org/r/226676
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0e61b1fd4f6139a251e53a1fac28b3821bc6b860
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/WikiEditor
Gerrit-Branch: master
Gerrit-Owner: Gerrit Patch Uploader <[email protected]>
Gerrit-Reviewer: Fomafix
Gerrit-Reviewer: GOIII <[email protected]>
Gerrit-Reviewer: Gerrit Patch Uploader <[email protected]>
Gerrit-Reviewer: Schnark <[email protected]>
Gerrit-Reviewer: TheDJ <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits