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

Change subject: Limiting number of registered event handlers in toolbar button 
widget
......................................................................


Limiting number of registered event handlers in toolbar button widget

Change-Id: I111e61f2505da49598a854b034bae3055271aba1
---
M lib/resources/Resources.php
M lib/resources/jquery.wikibase/toolbar/toolbarbutton.js
M repo/resources/Resources.php
M repo/resources/wikibase.ui.entityViewInit.js
4 files changed, 21 insertions(+), 28 deletions(-)

Approvals:
  Tobias Gritschacher: Looks good to me, approved
  Daniel Werner: Looks good to me, approved



diff --git a/lib/resources/Resources.php b/lib/resources/Resources.php
index 2da3613..824cd8b 100644
--- a/lib/resources/Resources.php
+++ b/lib/resources/Resources.php
@@ -407,8 +407,6 @@
                                'wikibase-error-ui-link-exists',
                                'wikibase-error-ui-session-failure',
                                'wikibase-error-ui-edit-conflict',
-                               'wikibase-restrictionedit-tooltip-message',
-                               'wikibase-blockeduser-tooltip-message',
                                'parentheses',
                        )
                ),
diff --git a/lib/resources/jquery.wikibase/toolbar/toolbarbutton.js 
b/lib/resources/jquery.wikibase/toolbar/toolbarbutton.js
index f3eb040..93779b0 100644
--- a/lib/resources/jquery.wikibase/toolbar/toolbarbutton.js
+++ b/lib/resources/jquery.wikibase/toolbar/toolbarbutton.js
@@ -11,9 +11,8 @@
 var PARENT = $.wikibase.toolbarlabel;
 
 /**
- * Represents a button within wikibase scope.
+ * Represents a toolbar button within wikibase scope.
  *
- * @constructor
  * @extends jQuery.wikibase.toolbarlabel
  * @since 0.4
  *
@@ -38,26 +37,6 @@
                        self._trigger( 'action' );
                        return true;
                } );
-
-               // disable button and attach tooltip when editing is restricted
-               $( wb ).on( 'restrictEntityPageActions blockEntityPageActions', 
function( event ) {
-                       self.disable();
-
-                       var messageId = ( event.type === 
'blockEntityPageActions' )
-                               ? 'wikibase-blockeduser-tooltip-message'
-                               : 'wikibase-restrictionedit-tooltip-message';
-
-                       self.setTooltip( mw.message( messageId ).escaped() );
-
-                       self._tooltip.setGravity( 'nw' );
-               } );
-       },
-
-       /**
-        * @see jQuery.Widget.destroy
-        */
-       destroy: function() {
-               PARENT.prototype.destroy.call( this );
        },
 
        /**
diff --git a/repo/resources/Resources.php b/repo/resources/Resources.php
index 37623ba..3a853fc 100644
--- a/repo/resources/Resources.php
+++ b/repo/resources/Resources.php
@@ -58,6 +58,8 @@
                                'wikibase-anonymouseditwarning',
                                'wikibase-entity-item',
                                'wikibase-entity-property',
+                               'wikibase-restrictionedit-tooltip-message',
+                               'wikibase-blockeduser-tooltip-message',
                        )
                ),
 
diff --git a/repo/resources/wikibase.ui.entityViewInit.js 
b/repo/resources/wikibase.ui.entityViewInit.js
index fced926..6985995 100644
--- a/repo/resources/wikibase.ui.entityViewInit.js
+++ b/repo/resources/wikibase.ui.entityViewInit.js
@@ -148,10 +148,24 @@
                        } );
                }
 
-               // handle edit restrictions
-               // TODO/FIXME: most about this system sucks, especially the 
part where the Button constructor is hacked to disable
-               //             all buttons when this is fired. it also doesn't 
effect any edit tools added after this point and
-               //             edit tool initialized above do not even know 
that they are disabled.
+               // Handle edit restrictions:
+               $( wb )
+               .on( 'restrictEntityPageActions blockEntityPageActions', 
function( event ) {
+                       $( '.wikibase-toolbarbutton' ).each( function( i, node 
) {
+                               var toolbarButton = $( node ).data( 
'toolbarbutton' );
+
+                               toolbarButton.disable();
+
+                               var messageId = ( event.type === 
'blockEntityPageActions' )
+                                       ? 'wikibase-blockeduser-tooltip-message'
+                                       : 
'wikibase-restrictionedit-tooltip-message';
+
+                               toolbarButton.setTooltip( mw.message( messageId 
).escaped() );
+
+                               toolbarButton._tooltip.setGravity( 'nw' );
+                       } );
+               } );
+
                if (
                        mw.config.get( 'wgRestrictionEdit' ) !== null &&
                        mw.config.get( 'wgRestrictionEdit' ).length === 1

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I111e61f2505da49598a854b034bae3055271aba1
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>
Gerrit-Reviewer: Daniel Werner <[email protected]>
Gerrit-Reviewer: Henning Snater <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to