Bmansurov has uploaded a new change for review.
https://gerrit.wikimedia.org/r/180898
Change subject: Update WikiGrok and specials/nearby documentation
......................................................................
Update WikiGrok and specials/nearby documentation
Change-Id: I886d01833e88da4728d63445c3f838634a4c4901
---
M javascripts/modules/wikigrok/WikiDataApi.js
M javascripts/modules/wikigrok/WikiGrokAbTest.js
M javascripts/modules/wikigrok/WikiGrokDialog.js
M javascripts/modules/wikigrok/WikiGrokResponseApi.js
M javascripts/modules/wikigrok/init.js
M javascripts/modules/wikigrok/wikiGrokCampaigns.js
M javascripts/modules/wikigrok/wikigrokuser.js
M javascripts/specials/nearby.js
8 files changed, 51 insertions(+), 18 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/98/180898/1
diff --git a/javascripts/modules/wikigrok/WikiDataApi.js
b/javascripts/modules/wikigrok/WikiDataApi.js
index ad4b4b2..be2ddc9 100644
--- a/javascripts/modules/wikigrok/WikiDataApi.js
+++ b/javascripts/modules/wikigrok/WikiDataApi.js
@@ -16,6 +16,11 @@
this.subjectId = options.itemId;
Api.prototype.initialize.apply( this, arguments );
},
+ /**
+ * Get claims via the API
+ * @method
+ * @return {jQuery.Deferred}
+ */
getClaims: function () {
var self = this,
id = this.subjectId;
@@ -86,7 +91,7 @@
/**
* Get labels for an item from Wikidata
* See: https://www.wikidata.org/wiki/Help:Label
- *
+ * @method
* @param {Array} itemIds for items in Wikidata
* @return {jQuery.Deferred} Object returned by ajax call
*/
@@ -114,7 +119,7 @@
/**
* Expand item ids to find associated data such as labels and
urls
* for the wikidata entities for the current sitename.
- *
+ * @method
* @param {Array} itemIds for items in Wikidata
* @return {jQuery.Deferred} Object returned by ajax call
*/
diff --git a/javascripts/modules/wikigrok/WikiGrokAbTest.js
b/javascripts/modules/wikigrok/WikiGrokAbTest.js
index e2fa1a1..a8fbb5c 100644
--- a/javascripts/modules/wikigrok/WikiGrokAbTest.js
+++ b/javascripts/modules/wikigrok/WikiGrokAbTest.js
@@ -12,7 +12,7 @@
/**
* Initialises a new instance of the WikiGrokAbTest
class.
- *
+ * @method
* @param {Boolean} isEnabled Whether or not the A/B
test is enabled
*/
initialize: function ( isEnabled ) {
@@ -21,7 +21,7 @@
/**
* Gets the version of WikiGrok to show to the user.
- *
+ * @method
* @param {Object} wikiGrokUser The WikiGrok user
* @return {String} `'A'` or `'B'`
*/
@@ -35,7 +35,7 @@
/**
* Creates a new instance of the WikiGrokAbTest using
`wgMFEnableWikiGrok` as
* the `isEnabled` parameter.
- *
+ * @method
* @return {WikiGrokAbTest}
*/
WikiGrokAbTest.newFromMwConfig = function () {
diff --git a/javascripts/modules/wikigrok/WikiGrokDialog.js
b/javascripts/modules/wikigrok/WikiGrokDialog.js
index 000abc8..4c92453 100644
--- a/javascripts/modules/wikigrok/WikiGrokDialog.js
+++ b/javascripts/modules/wikigrok/WikiGrokDialog.js
@@ -92,10 +92,10 @@
/**
* Log data to the schema
* @method
- * @param {string} action to log as described in schema
+ * @param {String} action to log as described in schema
* See [Schema][1] for details on valid values.
*
- * [1]:
https://meta.wikimedia.org/wiki/Schema:MobileWebWikiGrok}
+ * [1]: https://meta.wikimedia.org/wiki/Schema:MobileWebWikiGrok
*/
log: function ( action ) {
var data = {
@@ -117,10 +117,10 @@
/**
* Log data to the error schema
* @method
- * @param {string} error to log as described in schema
+ * @param {String} error to log as described in schema
* See [Schema][1] for details on valid values.
*
- * [1]:
https://meta.wikimedia.org/wiki/Schema:MobileWebWikiGrok}
+ * [1]: https://meta.wikimedia.org/wiki/Schema:MobileWebWikiGrok
*/
logError: function ( error ) {
var data = {
@@ -148,10 +148,11 @@
},
/**
- * Return a new array from 'array' with 'count' randomly
selected elements.
+ * Randomly select 'count' elements from 'array'
+ * @method
* @param {Array} array Array from which random elements are
selected
- * @param {number} count - Positive number of random elements
to select
- * @returns {Array}
+ * @param {Number} count - Positive number of random elements
to select
+ * @returns {Array} a new array from 'array' with 'count'
randomly selected elements
*/
chooseRandomItemsFromArray: function ( array, count ) {
var arrayCopy, i, randomIndex,
@@ -235,6 +236,7 @@
/**
* Show the error message
+ * @method
*/
showError: function () {
this.$( '.pane.content' ).hide();
@@ -242,8 +244,13 @@
this.show();
},
- // Record answer in temporary database for analysis.
- // Eventually answers will be recorded directly to Wikidata.
+ /**
+ * Record answer in temporary database for analysis.
+ * Eventually answers will be recorded directly to WikiData.
+ * Thank the user after recording claims. In case of fail show
an error message.
+ * @method
+ * @param {Object} options
+ */
recordClaim: function ( options ) {
var self = this,
claim = {
@@ -272,6 +279,7 @@
/**
* Save the page title in localStorage so that we don't show
WikiGrok on this page
* the next time the user sees the page.
+ * @method
*/
rememberWikiGrokContribution: function () {
var pages = $.parseJSON(
@@ -282,6 +290,13 @@
settings.save( 'pagesWithWikiGrokContributions',
JSON.stringify( pages ), false );
},
+ /**
+ * Show a thank you message to the user for their contribution.
+ * @method
+ * @param {Object} options
+ * @param {Boolean} claimAttempted has the user attempted to
answer or
+ * just responded with 'not sure'?
+ */
thankUser: function ( options, claimAttempted ) {
this.rememberWikiGrokContribution();
options.thankUser = true;
@@ -300,7 +315,7 @@
* Check if at least half of the element's height and half of
its width are in viewport
* @method
* @param {jQuery.Object} $el - element that's being tested
- * @return {boolean}
+ * @return {Boolean}
*/
isElementInViewport: function ( $el ) {
var windowHeight = $window.height(),
@@ -320,6 +335,7 @@
/**
* Log widget-impression if the widget is in viewport.
* Stop listening to events that are namespaced with the
taskToken.
+ * @method
* @param {jQuery.Object} $el WikiGrokDialog element
*/
logWidgetImpression: function ( $el ) {
@@ -443,6 +459,7 @@
/**
* Show WikiGrok dialog
+ * @method
* @param {Object} options
*/
reveal: function ( options ) {
diff --git a/javascripts/modules/wikigrok/WikiGrokResponseApi.js
b/javascripts/modules/wikigrok/WikiGrokResponseApi.js
index 922eb9d..7f74e3a 100644
--- a/javascripts/modules/wikigrok/WikiGrokResponseApi.js
+++ b/javascripts/modules/wikigrok/WikiGrokResponseApi.js
@@ -6,6 +6,7 @@
/**
* Record claims to the WikiGrok API
* @class WikiGrokApi
+ * @extends Api
*/
WikiGrokResponseApi = Api.extend( {
/**
diff --git a/javascripts/modules/wikigrok/init.js
b/javascripts/modules/wikigrok/init.js
index c1973c6..a135aad 100644
--- a/javascripts/modules/wikigrok/init.js
+++ b/javascripts/modules/wikigrok/init.js
@@ -27,7 +27,9 @@
/**
* Checks whether the user has already seen and responded to a WikiGrok
question
* before on this article and device.
+ * @method
* @ignore
+ * @returns {Boolean}
*/
function hasUserAlreadyContributedToWikiGrok() {
var pages = $.parseJSON(
@@ -50,8 +52,8 @@
*
* If the user is eligible to enter the WikiGrok AB test, then the test
* determines which version to use.
+ * @method
* @ignore
- *
* @return {Object|null}
*/
function getWikiGrokConfig() {
diff --git a/javascripts/modules/wikigrok/wikiGrokCampaigns.js
b/javascripts/modules/wikigrok/wikiGrokCampaigns.js
index 89e0c3e..0f7f083 100644
--- a/javascripts/modules/wikigrok/wikiGrokCampaigns.js
+++ b/javascripts/modules/wikigrok/wikiGrokCampaigns.js
@@ -7,6 +7,7 @@
var wikiGrokCampaigns = {
/**
* Randomly pick a campaign for the current page
+ * @method
* @returns {Object|null} Object with campaign data. Includes
these properties:
* name: Name of the campaign chosen, e.g. 'album'
* property: Wikidata ID for the relevant property, e.g.
'P31'
@@ -31,7 +32,7 @@
/**
* Get WikiGrok campaigns that are present on the page
* This is a method rather than a variable because we need it in tests
- *
+ * @method
* @ignore
* @returns {Object|null} campaigns
*/
@@ -41,6 +42,7 @@
/**
* Randomly pick a property
+ * @method
* @ignore
* @param {Object} object
* @returns {String} object's property
diff --git a/javascripts/modules/wikigrok/wikigrokuser.js
b/javascripts/modules/wikigrok/wikigrokuser.js
index 900ae68..55622a8 100644
--- a/javascripts/modules/wikigrok/wikigrokuser.js
+++ b/javascripts/modules/wikigrok/wikigrokuser.js
@@ -17,7 +17,7 @@
* Gets the user's token from the "-wikiGrokUserToken"
cookie. If the cookie
* isn't set, then a token is generated and then stored
in the cookie for 90
* days, and then returned.
- *
+ * @method
* @return {String}
*/
getToken: function () {
diff --git a/javascripts/specials/nearby.js b/javascripts/specials/nearby.js
index d361382..66f1136 100644
--- a/javascripts/specials/nearby.js
+++ b/javascripts/specials/nearby.js
@@ -27,6 +27,12 @@
} );
$icon = $( icon.toHtmlString() ).on( 'click',
refreshCurrentLocation ).appendTo( '.header' );
+ /**
+ * Initialize or instantiate Nearby with options
+ * @method
+ * @ignore
+ * @param {Object} options
+ */
function refresh( options ) {
if ( nearby ) {
nearby.initialize( options );
--
To view, visit https://gerrit.wikimedia.org/r/180898
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I886d01833e88da4728d63445c3f838634a4c4901
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits