jenkins-bot has submitted this change and it was merged. Change subject: Add class name to protected pages, to allow for specific CSS styling of edit area ......................................................................
Add class name to protected pages, to allow for specific CSS styling of edit area Also get rid of checking for NS_MEDIAWIKI explictly and use MWNamespace::getRestrictionLevels instead Bug: 50783 Change-Id: I5986ddb9b6f17e4a2aca12dbb551cce4a6cfd663 --- M ApiVisualEditor.php M modules/ve-mw/init/ve.init.mw.Target.js 2 files changed, 13 insertions(+), 2 deletions(-) Approvals: Catrope: Looks good to me, approved jenkins-bot: Verified diff --git a/ApiVisualEditor.php b/ApiVisualEditor.php index c023eca..4a1444d 100644 --- a/ApiVisualEditor.php +++ b/ApiVisualEditor.php @@ -330,13 +330,19 @@ } } - if ( $page->getNamespace() != NS_MEDIAWIKI ) { + // Look at protection status to set up notices + surface class(es) + $protectedClasses = array(); + if ( MWNamespace::getRestrictionLevels( $page->getNamespace() ) !== array( '' ) ) { // Page protected from editing if ( $page->isProtected( 'edit' ) ) { # Is the title semi-protected? if ( $page->isSemiProtected() ) { + $protectedClasses[] = 'mw-textarea-sprotected'; + $noticeMsg = 'semiprotectedpagewarning'; } else { + $protectedClasses[] = 'mw-textarea-protected'; + # Then it must be protected based on static groups (regular) $noticeMsg = 'protectedpagewarning'; } @@ -347,6 +353,8 @@ // Deal with cascading edit protection list( $sources, $restrictions ) = $page->getCascadeProtectionSources(); if ( isset( $restrictions['edit'] ) ) { + $protectedClasses[] = ' mw-textarea-cprotected'; + $notice = $this->msg( 'cascadeprotectedwarning' )->parseAsBlock() . '<ul>'; // Unfortunately there's no nice way to get only the pages which cause // editing to be restricted @@ -439,6 +447,7 @@ 'notices' => $notices, 'checkboxes' => $checkboxes, 'links' => $links, + 'protectedClasses' => implode( ' ', $protectedClasses ) ), $parsed['result'] ); diff --git a/modules/ve-mw/init/ve.init.mw.Target.js b/modules/ve-mw/init/ve.init.mw.Target.js index 941db9a..dc72a5b 100644 --- a/modules/ve-mw/init/ve.init.mw.Target.js +++ b/modules/ve-mw/init/ve.init.mw.Target.js @@ -394,6 +394,7 @@ this.constructor.static.fixBase( this.doc, document ); this.remoteNotices = ve.getObjectValues( data.notices ); + this.protectedClasses = data.protectedClasses; this.$checkboxes = $( ve.getObjectValues( data.checkboxes ).join( '' ) ); // Populate checkboxes with default values for minor and watch this.$checkboxes @@ -1311,7 +1312,8 @@ setTimeout( function () { // Create ui.Surface (also creates ce.Surface and dm.Surface and builds CE tree) target.surface = target.createSurface( dmDoc ); - target.surface.$element.addClass( 've-init-mw-viewPageTarget-surface' ); + target.surface.$element.addClass( 've-init-mw-viewPageTarget-surface' ) + .addClass( target.protectedClasses ); setTimeout( function () { // Initialize surface target.surface.getContext().hide(); -- To view, visit https://gerrit.wikimedia.org/r/130665 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5986ddb9b6f17e4a2aca12dbb551cce4a6cfd663 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Alex Monk <kren...@wikimedia.org> Gerrit-Reviewer: Catrope <roan.katt...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits