Adrian Lang has uploaded a new change for review.
https://gerrit.wikimedia.org/r/163845
Change subject: Introduce wb.getMwApiForRepo
......................................................................
Introduce wb.getMwApiForRepo
This is supposed to be a replacement for most usages of wb.RepoApi and
should help with handling recent and upcoming breaking changes to wb.RepoApi.
Change-Id: I24f69b7e5af50763826c3b3bc9c482fdfc714bf1
---
M client/resources/Resources.php
A client/resources/wikibase.client.getMwApiForRepo.js
M client/resources/wikibase.client.linkitem.init.js
3 files changed, 28 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/45/163845/1
diff --git a/client/resources/Resources.php b/client/resources/Resources.php
index ecdc010..ba5d402 100644
--- a/client/resources/Resources.php
+++ b/client/resources/Resources.php
@@ -8,6 +8,15 @@
);
return array(
+ 'wikibase.client.getMwRepoForApi' => $moduleTemplate + array(
+ 'scripts' => array(
+ 'wikibase.client.getMwRepoForApi.js'
+ ),
+ 'dependencies' => array(
+ 'mw.config.values.wbRepo',
+ 'wikibase.api.getLocationAgnosticMwApi',
+ )
+ ),
'wikibase.client.init' => $moduleTemplate + array(
'position' => 'top',
'skinStyles' => array(
diff --git a/client/resources/wikibase.client.getMwApiForRepo.js
b/client/resources/wikibase.client.getMwApiForRepo.js
new file mode 100644
index 0000000..80cb85f
--- /dev/null
+++ b/client/resources/wikibase.client.getMwApiForRepo.js
@@ -0,0 +1,16 @@
+/*
+ * @licence GNU GPL v2+
+ * @author: Adrian Lang <[email protected]>
+ */
+( function( wb, $ ) {
+ 'use strict';
+
+ var MODULE = wb;
+
+ MODULE.getMwApiForRepo = function() {
+ var repoConfig = mw.config.get( 'wbRepo' ),
+ repoApiEndpoint = repoConfig.url +
repoConfig.scriptPath + '/api.php',
+ mwApiForRepo = wikibase.api.getLocationAgnosticMwApi(
repoApiEndpoint );
+ return mwApiForRepo;
+ };
+}( wikibase, jQuery ) );
diff --git a/client/resources/wikibase.client.linkitem.init.js
b/client/resources/wikibase.client.linkitem.init.js
index 6b5e66b..ad7fce9 100644
--- a/client/resources/wikibase.client.linkitem.init.js
+++ b/client/resources/wikibase.client.linkitem.init.js
@@ -21,19 +21,17 @@
'jquery.wikibase.linkitem',
'mediawiki.Title',
'mw.config.values.wbRepo',
- 'wikibase.api.getLocationAgnosticMwApi'
+ 'wikibase.client.getMwRepoForApi',
],
function() {
$spinner.remove();
- var repoConfig = mw.config.get( 'wbRepo' ),
- repoApiEndpoint = repoConfig.url +
repoConfig.scriptPath + '/api.php',
- mwApiForRepo =
wikibase.api.getLocationAgnosticMwApi( repoApiEndpoint );
+ var repoConfig = mw.config.get( 'wbRepo' );
$linkItemLink
.show()
.linkitem( {
- mwApiForRepo: mwApiForRepo,
+ mwApiForRepo:
wikibase.getMwApiForRepo(),
pageTitle: ( new mw.Title(
mw.config.get( 'wgTitle' ),
mw.config.get(
'wgNamespaceNumber' )
--
To view, visit https://gerrit.wikimedia.org/r/163845
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I24f69b7e5af50763826c3b3bc9c482fdfc714bf1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Adrian Lang <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits