jenkins-bot has submitted this change and it was merged.
Change subject: Fix triggering of 'restrictEntityPageActions' and
'blockEntityPageActions'
......................................................................
Fix triggering of 'restrictEntityPageActions' and 'blockEntityPageActions'
Don't trigger these before we have the entity (with the toolbars)
actually in place.
Bug: 68322
Change-Id: I840dda703784e31270952f4d39fb4b486cd892d2
---
M repo/resources/wikibase.ui.entityViewInit.js
1 file changed, 41 insertions(+), 35 deletions(-)
Approvals:
Hoo man: Looks good to me, but someone else must approve
WikidataJenkins: Verified
Thiemo Mättig (WMDE): Looks good to me, approved
jenkins-bot: Verified
diff --git a/repo/resources/wikibase.ui.entityViewInit.js
b/repo/resources/wikibase.ui.entityViewInit.js
index 69b7a18..487abb9 100644
--- a/repo/resources/wikibase.ui.entityViewInit.js
+++ b/repo/resources/wikibase.ui.entityViewInit.js
@@ -63,6 +63,8 @@
new wb.ui.DescriptionEditTool( this, { api: repoApi } );
} );
+ registerEditRestrictionHandlers();
+
if( mw.config.get( 'wbEntity' ) !== null ) {
// if there are no aliases yet, the DOM structure for
creating new ones is created manually since it is not
// needed for running the page without JS
@@ -109,42 +111,8 @@
entityInitializer.getEntity().done( function( entity ) {
createEntityDom( entity, $claims,
$claimsParent, repoApi );
+ triggerEditRestrictionHandlers();
} );
- }
-
- // 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.element.wbtooltip( {
- content: mw.message( messageId
).escaped(),
- gravity: 'nw'
- } );
- } );
- } );
-
- if ( mw.config.get( 'wbUserIsBlocked' ) ) {
- $( wb ).triggerHandler( 'blockEntityPageActions' );
- } else if ( !mw.config.get( 'wbUserCanEdit' ) ) {
- $( wb ).triggerHandler( 'restrictEntityPageActions' );
- }
-
- if( !mw.config.get( 'wbIsEditView' ) ) {
- // no need to implement a 'disableEntityPageActions'
since hiding all the toolbars directly like this is
- // not really worse than hacking the Toolbar prototype
to achieve this:
- $( '.wikibase-toolbar' ).hide();
- $( 'body' ).addClass( 'wb-editing-disabled' );
- // make it even harder to edit stuff, e.g. if someone
is trying to be smart, using
- // firebug to show hidden nodes again to click on them:
- $( wb ).triggerHandler( 'restrictEntityPageActions' );
}
$( wb ).on( 'startItemPageEditMode', function( event, origin,
options ) {
@@ -348,6 +316,44 @@
wb.ui.initTermBox( entity, repoApi );
}
+ function registerEditRestrictionHandlers() {
+ $( 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.element.wbtooltip( {
+ content: mw.message( messageId
).escaped(),
+ gravity: 'nw'
+ } );
+ } );
+ } );
+ }
+
+ function triggerEditRestrictionHandlers() {
+ if ( mw.config.get( 'wbUserIsBlocked' ) ) {
+ $( wb ).triggerHandler( 'blockEntityPageActions' );
+ } else if ( !mw.config.get( 'wbUserCanEdit' ) ) {
+ $( wb ).triggerHandler( 'restrictEntityPageActions' );
+ }
+
+ if( !mw.config.get( 'wbIsEditView' ) ) {
+ // no need to implement a 'disableEntityPageActions'
since hiding all the toolbars directly like this is
+ // not really worse than hacking the Toolbar prototype
to achieve this:
+ $( '.wikibase-toolbar' ).hide();
+ $( 'body' ).addClass( 'wb-editing-disabled' );
+ // make it even harder to edit stuff, e.g. if someone
is trying to be smart, using
+ // firebug to show hidden nodes again to click on them:
+ $( wb ).triggerHandler( 'restrictEntityPageActions' );
+ }
+ }
+
} )(
jQuery,
mediaWiki,
--
To view, visit https://gerrit.wikimedia.org/r/148093
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I840dda703784e31270952f4d39fb4b486cd892d2
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Henning Snater <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: WikidataJenkins <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits