diff options
author | apaskulin <apaskulin@wikimedia.org> | 2024-05-21 15:53:48 -0700 |
---|---|---|
committer | apaskulin <apaskulin@wikimedia.org> | 2024-05-24 13:28:49 -0700 |
commit | 02d07876ec793d8c02ee7e7e209a0d7370ba1a37 (patch) | |
tree | 6d390017553d178199d820aae423779b46e38047 /resources/src/mediawiki.cookie | |
parent | 31a72c9b718676912c419687356b48c652593579 (diff) | |
download | mediawikicore-02d07876ec793d8c02ee7e7e209a0d7370ba1a37.tar.gz mediawikicore-02d07876ec793d8c02ee7e7e209a0d7370ba1a37.zip |
docs: Document mediawiki.cookie as a module in JSDoc
Moves mediawiki.cookie from a namespace to a module, and
adds related jQuery plugins.
Bug: T353357
Change-Id: I4f890b42faf7777156510829f1aae9bf6622ee14
Diffstat (limited to 'resources/src/mediawiki.cookie')
-rw-r--r-- | resources/src/mediawiki.cookie/index.js | 8 | ||||
-rw-r--r-- | resources/src/mediawiki.cookie/jquery.js | 16 | ||||
-rw-r--r-- | resources/src/mediawiki.cookie/types.js | 2 |
3 files changed, 16 insertions, 10 deletions
diff --git a/resources/src/mediawiki.cookie/index.js b/resources/src/mediawiki.cookie/index.js index e0e7e8238c65..ae720c1ef543 100644 --- a/resources/src/mediawiki.cookie/index.js +++ b/resources/src/mediawiki.cookie/index.js @@ -17,12 +17,11 @@ require( './jquery.js' ); /** * Manage cookies in a way that is syntactically and functionally similar * to the `WebRequest#getCookie` and `WebResponse#setcookie` methods in PHP. - * Provided by the mediawiki.cookie ResourceLoader module. * * @author Sam Smith <samsmith@wikimedia.org> * @author Matthew Flaschen <mflaschen@wikimedia.org> * - * @namespace mw.cookie + * @module mediawiki.cookie * @example * mw.loader.using( 'mediawiki.cookie' ).then( () => { * mw.cookie.set('hello', 'world' ); @@ -51,7 +50,8 @@ mw.cookie = { * @param {string} key * @param {string|null} value Value of cookie. If `value` is `null` then this method will * instead remove a cookie by name of `key`. - * @param {mw.cookie.CookieOptions|Date|number} [options] Options object, or expiry date + * @param {module:mediawiki.cookie~CookieOptions|Date|number} [options] Options object, or expiry date + * @memberof module:mediawiki.cookie */ set: function ( key, value, options ) { @@ -98,6 +98,7 @@ mw.cookie = { * @param {null|string} [defaultValue] defaults to null * @return {string|null} If the cookie exists, then the value of the * cookie, otherwise `defaultValue` + * @memberof module:mediawiki.cookie */ get: function ( key, prefix, defaultValue ) { var result; @@ -125,6 +126,7 @@ mw.cookie = { * @param {null|string} [defaultValue] * @return {string|null} If the cookie exists, then the value of the * cookie, otherwise `defaultValue` + * @memberof module:mediawiki.cookie */ getCrossSite: function ( key, prefix, defaultValue ) { var value; diff --git a/resources/src/mediawiki.cookie/jquery.js b/resources/src/mediawiki.cookie/jquery.js index bb2908efd5da..49b62c5c2c2f 100644 --- a/resources/src/mediawiki.cookie/jquery.js +++ b/resources/src/mediawiki.cookie/jquery.js @@ -3,13 +3,15 @@ var jar = require( './jar.js' ); /** * Set a cookie. * - * @memberof jQueryPlugins - * @method cookie + * To use this {@link jQuery} plugin, load the `mediawiki.cookie` module using {@link mw.loader}. + * + * @memberof module:mediawiki.cookie + * @method * @param {string} [key] Cookie name or (when getting) omit to return an object with all * current cookie keys and values. * @param {string|null} [value] Cookie value to set. If `null`, this method will remove the cookie. * If omited, this method will get and return the current value. - * @param {mw.cookie.CookieOptions} [options] + * @param {module:mediawiki.cookie~CookieOptions} [options] * @return {string|Object} The current value (if getting a cookie), or an internal `document.cookie` * expression (if setting or removing). * @@ -23,15 +25,17 @@ $.cookie = jar.cookie; /** * Remove a cookie by key. * + * To use this {@link jQuery} plugin, load the `mediawiki.cookie` module using {@link mw.loader}. + * * @example * mw.loader.using( 'mediawiki.cookie' ).then( () => { * $.removeCookie( 'name', {} ); * } ); * - * @memberof jQueryPlugins - * @method removeCookie + * @memberof module:mediawiki.cookie + * @method * @param {string} key - * @param {mw.cookie.CookieOptions} options + * @param {module:mediawiki.cookie~CookieOptions} options * @return {boolean} True if the cookie previously existed */ $.removeCookie = jar.removeCookie; diff --git a/resources/src/mediawiki.cookie/types.js b/resources/src/mediawiki.cookie/types.js index 149c622384ce..17ccb19d47b5 100644 --- a/resources/src/mediawiki.cookie/types.js +++ b/resources/src/mediawiki.cookie/types.js @@ -1,5 +1,5 @@ /** - * @typedef {Object} mw.cookie.CookieOptions Custom scope for cookie key, must match the way it was set. + * @typedef {Object} module:mediawiki.cookie~CookieOptions Custom scope for cookie key, must match the way it was set. * @property {string} [path] The path attribute of the cookie. Defaults to wgCookiePath. * @property {string} [prefix] The prefix of the key. Defaults to wgCookiePrefix. * @property {string} [domain] Custom scope for cookie key. The domain attribute of the cookie. |