From: Timo Tijhof Date: Sun, 27 Apr 2014 14:45:22 +0000 (+0200) Subject: jquery.hidpi: Add jsduck documentation X-Git-Tag: 1.31.0-rc.0~15974^2 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=28ae883;p=lhc%2Fweb%2Fwiklou.git jquery.hidpi: Add jsduck documentation Change-Id: Ib33eaa488f967efbf45cee83d903e6279b8b782a --- diff --git a/maintenance/jsduck/config.json b/maintenance/jsduck/config.json index 344e5c2f03..fb8166bf05 100644 --- a/maintenance/jsduck/config.json +++ b/maintenance/jsduck/config.json @@ -26,6 +26,7 @@ "../../resources/src/jquery/jquery.colorUtil.js", "../../resources/src/jquery/jquery.footHovzer.js", "../../resources/src/jquery/jquery.getAttrs.js", + "../../resources/src/jquery/jquery.hidpi.js", "../../resources/src/jquery/jquery.localize.js", "../../resources/src/jquery/jquery.makeCollapsible.js", "../../resources/src/jquery/jquery.spinner.js", diff --git a/resources/src/jquery/jquery.hidpi.js b/resources/src/jquery/jquery.hidpi.js index eb29db9906..99889f1952 100644 --- a/resources/src/jquery/jquery.hidpi.js +++ b/resources/src/jquery/jquery.hidpi.js @@ -1,21 +1,26 @@ /** - * Responsive images based on 'srcset' and 'window.devicePixelRatio' emulation where needed. + * Responsive images based on `srcset` and `window.devicePixelRatio` emulation where needed. * - * Call $().hidpi() on a document or part of a document to replace image srcs in that section. + * Call `.hidpi()` on a document or part of a document to proces image srcsets within that section. * - * $.devicePixelRatio() can be used to supplement window.devicePixelRatio with support on - * some additional browsers. + * `$.devicePixelRatio()` can be used as a substitute for `window.devicePixelRatio`. + * It provides a familiar interface to retrieve the pixel ratio for browsers that don't + * implement `window.devicePixelRatio` but do have a different way of getting it. + * + * @class jQuery.plugin.hidpi */ ( function ( $ ) { /** - * Detect reported or approximate device pixel ratio. - * 1.0 means 1 CSS pixel is 1 hardware pixel - * 2.0 means 1 CSS pixel is 2 hardware pixels - * etc + * Get reported or approximate device pixel ratio. + * + * - 1.0 means 1 CSS pixel is 1 hardware pixel + * - 2.0 means 1 CSS pixel is 2 hardware pixels + * - etc. * - * Uses window.devicePixelRatio if available, or CSS media queries on IE. + * Uses `window.devicePixelRatio` if available, or CSS media queries on IE. * + * @static * @return {number} Device pixel ratio */ $.devicePixelRatio = function () { @@ -51,6 +56,7 @@ $.devicePixelRatio = function () { * native srcset support. * * @return {jQuery} This selection + * @chainable */ $.fn.hidpi = function () { var $target = this, @@ -81,9 +87,11 @@ $.fn.hidpi = function () { * * Exposed for testing. * + * @private + * @static * @param {number} devicePixelRatio * @param {string} srcset - * @return {mixed} null or the matching src string + * @return {Mixed} null or the matching src string */ $.matchSrcSet = function ( devicePixelRatio, srcset ) { var candidates, @@ -112,4 +120,9 @@ $.matchSrcSet = function ( devicePixelRatio, srcset ) { return selectedSrc; }; +/** + * @class jQuery + * @mixins jQuery.plugin.hidpi + */ + }( jQuery ) );