From: Timo Tijhof Date: Sun, 27 Apr 2014 14:20:58 +0000 (+0200) Subject: jquery.makeCollapsible: Add jsduck documentation X-Git-Tag: 1.31.0-rc.0~15986 X-Git-Url: http://git.cyclocoop.org/%22%20.%20%20%20%24self2%20.%20%20%20%22&var_mode_affiche=boucle?a=commitdiff_plain;h=a9a5d5c157b18a160756cc04c12cca32ab0f6b97;p=lhc%2Fweb%2Fwiklou.git jquery.makeCollapsible: Add jsduck documentation Change-Id: I92417b62b11697a0e2ec9b8dcb4950ecedf617ac --- diff --git a/maintenance/jsduck/config.json b/maintenance/jsduck/config.json index 858154445f..5d2e304c58 100644 --- a/maintenance/jsduck/config.json +++ b/maintenance/jsduck/config.json @@ -23,6 +23,7 @@ "../../resources/src/jquery/jquery.client.js", "../../resources/src/jquery/jquery.colorUtil.js", "../../resources/src/jquery/jquery.localize.js", + "../../resources/src/jquery/jquery.makeCollapsible.js", "../../resources/src/jquery/jquery.spinner.js", "../../resources/lib/oojs", "../../resources/lib/oojs-ui" diff --git a/resources/src/jquery/jquery.makeCollapsible.js b/resources/src/jquery/jquery.makeCollapsible.js index 01fde4c4ef..c3fd626e03 100644 --- a/resources/src/jquery/jquery.makeCollapsible.js +++ b/resources/src/jquery/jquery.makeCollapsible.js @@ -1,27 +1,22 @@ /** * jQuery makeCollapsible * - * This will enable collapsible-functionality on all passed elements. - * - Will prevent binding twice to the same element. - * - Initial state is expanded by default, this can be overriden by adding class - * "mw-collapsed" to the "mw-collapsible" element. - * - Elements made collapsible have jQuery data "mw-made-collapsible" set to true. - * - The inner content is wrapped in a "div.mw-collapsible-content" (except for tables and lists). + * Dual licensed: + * - CC BY 3.0 + * - GPL2 * - * @author Krinkle, 2011-2012 - * - * Dual license: - * @license CC BY 3.0 - * @license GPL2 + * @class jQuery.plugin.makeCollapsible */ ( function ( $, mw ) { + /** * Handler for a click on a collapsible toggler. * + * @private * @param {jQuery} $collapsible * @param {string} action The action this function will take ('expand' or 'collapse'). - * @param {jQuery|null} [optional] $defaultToggle - * @param {Object|undefined} options + * @param {jQuery|null} [$defaultToggle] + * @param {Object|undefined} [options] */ function toggleElement( $collapsible, action, $defaultToggle, options ) { var $collapsibleContent, $containers, hookCallback; @@ -146,10 +141,11 @@ } /** - * Handles clicking/keypressing on the collapsible element toggle and other + * Handle clicking/keypressing on the collapsible element toggle and other * situations where a collapsible element is toggled (e.g. the initial * toggle for collapsed ones). * + * @private * @param {jQuery} $toggle the clickable toggle itself * @param {jQuery} $collapsible the collapsible element * @param {jQuery.Event|null} e either the event or null if unavailable @@ -209,28 +205,34 @@ } /** - * Make any element collapsible. + * Enable collapsible-functionality on all elements in the collection. + * + * - Will prevent binding twice to the same element. + * - Initial state is expanded by default, this can be overriden by adding class + * "mw-collapsed" to the "mw-collapsible" element. + * - Elements made collapsible have jQuery data "mw-made-collapsible" set to true. + * - The inner content is wrapped in a "div.mw-collapsible-content" (except for tables and lists). * - * Supported options: - * - collapseText: text to be used for the toggler when clicking it would - * collapse the element. Default: the 'data-collapsetext' attribute of - * the collapsible element or the content of 'collapsible-collapse' - * message. - * - expandText: text to be used for the toggler when clicking it would - * expand the element. Default: the 'data-expandtext' attribute of - * the collapsible element or the content of 'collapsible-expand' - * message. - * - collapsed: boolean, whether to collapse immediately. By default + * @param {Object} [options] + * @param {string} [options.collapseText] Text used for the toggler, when clicking it would + * collapse the element. Default: the 'data-collapsetext' attribute of the + * collapsible element or the content of 'collapsible-collapse' message. + * @param {string} [options.expandText] Text used for the toggler, when clicking it would + * expand the element. Default: the 'data-expandtext' attribute of the + * collapsible element or the content of 'collapsible-expand' message. + * @param {boolean} [options.collapsed] Whether to collapse immediately. By default * collapse only if the elements has the 'mw-collapsible' class. - * - $customTogglers: jQuerified list of elements to be used as togglers + * @param {jQuery} [options.$customTogglers] Elements to be used as togglers * for this collapsible element. By default, if the collapsible element * has an id attribute like 'mw-customcollapsible-XXX', elements with a * *class* of 'mw-customtoggle-XXX' are made togglers for it. - * - plainMode: boolean, whether to use a "plain mode" when making the + * @param {boolean} [options.plainMode=false] Whether to use a "plain mode" when making the * element collapsible - that is, hide entire tables and lists (instead * of hiding only all rows but first of tables, and hiding each list * item separately for lists) and don't wrap other elements in * div.mw-collapsible-content. May only be used with custom togglers. + * @return {jQuery} + * @chainable */ $.fn.makeCollapsible = function ( options ) { if ( options === undefined ) { @@ -391,4 +393,10 @@ } } ); }; + + /** + * @class jQuery + * @mixins jQuery.plugin.makeCollapsible + */ + }( jQuery, mediaWiki ) );