Henning Snater has submitted this change and it was merged.
Change subject: Performance improvement for jQuery.wikibase.entityview edit
toolbars handling
......................................................................
Performance improvement for jQuery.wikibase.entityview edit toolbars handling
Change-Id: I93d9b87dd8d3a91a351f204c26ba4643ad0614b9
---
M lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
1 file changed, 23 insertions(+), 24 deletions(-)
Approvals:
Henning Snater: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
index d348016..eada4ee 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js
@@ -73,6 +73,26 @@
* @return {function}
*/
var toolbarStatesSetter = function( action ) {
+ function findToolbars( $range ) {
+ var $wbToolbars = $range.find(
'.wikibase-toolbar' ),
+ $wbToolbarGroups = $wbToolbars.find(
$wbToolbars );
+
+ return $wbToolbars
+ // Filter out toolbar groups:
+ .not( $wbToolbarGroups )
+ // Re-add "new UI" toolbars:
+ // TODO Improve selection mechanism as
soon as old UI classes have
+ // converted or get rid of this
toolbarStatesSetter.
+ .add( $wbToolbarGroups.filter(
+ function() {
+ var $toolbarNode = $(
this.parentNode.parentNode );
+ return
$toolbarNode.hasClass( 'wb-edittoolbar' )
+ ||
$toolbarNode.hasClass( 'wb-removetoolbar' )
+ ||
$toolbarNode.hasClass( 'wb-addtoolbar' );
+ }
+ ) );
+ }
+
return function( event, origin, options ) {
// TODO: at some point, this should rather
disable/enable the widgets for editing,
// there could be other ways for entering
edit mode than using the toolbar!
@@ -83,35 +103,14 @@
var originToolbars = null;
if ( options ) {
if ( typeof options.exclusive ===
'boolean' && !options.exclusive ) {
- originToolbars = $( origin )
- .find(
'.wikibase-toolbar' )
- // Filter out toolbar
groups:
- .not(
'.wikibase-toolbar .wikibase-toolbar' )
- // Re-add "new UI"
toolbars:
- // TODO Improve
selection mechanism as soon as old UI classes have
- // converted or get
rid of this toolbarStatesSetter.
- .add( $( origin ).find(
-
'.wb-edittoolbar > .wb-editsection > .wikibase-toolbar,'
- +
'.wb-removetoolbar > .wb-editsection > .wikibase-toolbar,'
- +
'.wb-addtoolbar > .wb-editsection > .wikibase-toolbar'
- ) );
- } else if ( $.isArray(
options.exclusive ) !== -1 ) {
+ originToolbars = findToolbars(
$( origin ) );
+ } else if ( typeof options.exclusive
=== 'string' ) {
originToolbars = $( origin
).find( options.exclusive );
}
}
// find and disable/enable all toolbars in this
edit view except,...
- self.element
- .find( '.wikibase-toolbar' )
- // Filter out toolbar groups:
- .not( '.wikibase-toolbar .wikibase-toolbar' )
- // Re-add "new UI" toolbars:
- .add(
- '.wb-edittoolbar > .wb-editsection >
.wikibase-toolbar,'
- + '.wb-removetoolbar > .wb-editsection
> .wikibase-toolbar,'
- + '.wb-addtoolbar > .wb-editsection >
.wikibase-toolbar'
- )
- .each( function() {
+ findToolbars( self.element ).each( function() {
var $toolbar = $( this ),
toolbar = $toolbar.data(
'toolbar' );
// ... don't disable toolbar if it has
an edit group which is in edit mode
--
To view, visit https://gerrit.wikimedia.org/r/76490
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I93d9b87dd8d3a91a351f204c26ba4643ad0614b9
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Werner <[email protected]>
Gerrit-Reviewer: Henning Snater <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits