Hoo man has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/52178


Change subject: (bug 44710) Don't display (none) in case we don't have langlinks
......................................................................

(bug 44710) Don't display (none) in case we don't have langlinks

The "in other languages" box is now getting shown by the
linkItem.js by the time it's ready to be used (and to
add new items).

This required adding a new CSS module with position=top
as we can't hide this in JS (as JS is only run after the
element is already visible) nor in the existing CSS (there's
no way we can let it know whether there are langlinks or
not).

The message 'wikibase-nolanglinks' became obsolete by this.

Change-Id: I45790dfb959e7b79fb1581fe16bdb25e99c90102
---
M client/WikibaseClient.hooks.php
M client/WikibaseClient.i18n.php
M client/resources/Resources.php
M client/resources/wbclient.linkItem.js
A client/resources/wikibase.client.nolanglinks.css
5 files changed, 25 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/78/52178/1

diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php
index fbe0d19..a533530 100644
--- a/client/WikibaseClient.hooks.php
+++ b/client/WikibaseClient.hooks.php
@@ -571,10 +571,16 @@
 
                if ( in_array( $title->getNamespace(), Settings::get( 
'namespaces' ) ) ) {
                        $out->addModules( 'wikibase.client.init' );
-                       // Experimental for now
-                       // if ( !$out->getLanguageLinks() && 
\Action::getActionName( $skin->getContext() ) === 'view' && $title->exists() ) {
-                       //      $out->addModules( 'wbclient.linkItem' );
-                       // }
+
+                       if ( !$out->getLanguageLinks() && 
\Action::getActionName( $skin->getContext() ) === 'view' && $title->exists() ) {
+                               // Module with the sole purpose to hide #p-lang
+                               // Needed as we can't do that in the regular 
CSS nor in JavaScript
+                               // (as that only runs after the element 
initially appeared).
+                               $out->addModules( 'wikibase.client.nolanglinks' 
);
+
+                               // Experimental for now
+                               //      $out->addModules( 'wbclient.linkItem' );
+                       }
                }
 
                wfProfileOut( __METHOD__ );
@@ -607,9 +613,8 @@
                                // Placeholder in case the page doesn't have 
any langlinks yet
                                // self::onBeforePageDisplay adds the 
JavaScript module which will overwrite this with a link
                                $template->data['language_urls'][] = array(
-                                       'text' => wfMessage( 'parentheses', 
wfMessage( 'wikibase-nolanglinks' )->escaped() ),
                                        'id' => 'wbc-linkToItem',
-                                       'class' => 'wbc-editpage',
+                                       'class' => 'wbc-editpage 
wbc-nolanglinks',
                                );
 
                                wfProfileOut( __METHOD__ );
diff --git a/client/WikibaseClient.i18n.php b/client/WikibaseClient.i18n.php
index 3255822..f5a62f8 100644
--- a/client/WikibaseClient.i18n.php
+++ b/client/WikibaseClient.i18n.php
@@ -31,7 +31,6 @@
        'wikibase-comment-sitelink-change' => 'Language link changed from $1 to 
$2',
        'wikibase-comment-sitelink-remove' => 'Language link removed: $1',
        'wikibase-comment-multi' => '$1 {{PLURAL:$1|change|changes}}',
-       'wikibase-nolanglinks' => 'none',
        'wikibase-editlinks' => 'Edit links',
        'wikibase-editlinkstitle' => 'Edit interlanguage links',
        'wikibase-linkitem-addlinks' => 'Add links',
diff --git a/client/resources/Resources.php b/client/resources/Resources.php
index 0eec397..7c437af 100644
--- a/client/resources/Resources.php
+++ b/client/resources/Resources.php
@@ -12,6 +12,10 @@
                        'position' => 'top',
                        'styles' => 'wikibase.client.css',
                ),
+               'wikibase.client.nolanglinks' => $moduleTemplate + array(
+                       'position' => 'top',
+                       'styles' => 'wikibase.client.nolanglinks.css',
+               ),
                'wikibase.client.currentSite' => $moduleTemplate + array(
                        'class' => 'Wikibase\SiteModule'
                ),
diff --git a/client/resources/wbclient.linkItem.js 
b/client/resources/wbclient.linkItem.js
index 009cd63..7c37ac4 100644
--- a/client/resources/wbclient.linkItem.js
+++ b/client/resources/wbclient.linkItem.js
@@ -680,12 +680,16 @@
         */
        $( document ).ready( function() {
                $( '#wbc-linkToItem' )
-                       .find( 'a' )
+                       .empty()
+                       .append(
+                               $( '<a>' )
                                .attr( {
                                        href: '#',
                                        id: 'wbc-linkToItem-link'
                                } )
                                .text( mw.msg( 'wikibase-linkitem-addlinks' ) )
-                               .click( checkLoggedin );
+                               .click( checkLoggedin )
+                       );
+               $( '#p-lang' ).show();
        } );
 } )( wikibase, mediaWiki, jQuery );
diff --git a/client/resources/wikibase.client.nolanglinks.css 
b/client/resources/wikibase.client.nolanglinks.css
new file mode 100644
index 0000000..e38dc9d
--- /dev/null
+++ b/client/resources/wikibase.client.nolanglinks.css
@@ -0,0 +1,4 @@
+/* CSS with the sole purpose to hide #p-lang */
+#p-lang {
+       display: none;
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I45790dfb959e7b79fb1581fe16bdb25e99c90102
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>

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

Reply via email to