From e91927a7bab8307b0bb384345af36aa803ccfc6b Mon Sep 17 00:00:00 2001 From: Ferran Mesas Date: Wed, 26 Oct 2016 10:00:06 +0200 Subject: [PATCH 1/3] Allow templating in sortAscending and sortDescending ARIA strings --- js/core/core.sort.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/js/core/core.sort.js b/js/core/core.sort.js index af42c2752..5f9495424 100644 --- a/js/core/core.sort.js +++ b/js/core/core.sort.js @@ -229,10 +229,14 @@ function _fnSortAria ( settings ) nextSort = asSorting[0]; } - label = sTitle + ( nextSort === "asc" ? - oAria.sSortAscending : - oAria.sSortDescending - ); + var sSortLabel = nextSort === "asc" ? oAria.sSortAscending : oAria.sSortDescending; + + if (sSortLabel.indexOf("_HEADER_") !== -1) { + label = sSortLabel.replace("_HEADER_", sTitle); + } + else { + label = sTitle + sSortLabel; + } } else { label = sTitle; From d8861f450f34e1bf479fe4a058ed72818dcfcba9 Mon Sep 17 00:00:00 2001 From: Ferran Mesas Date: Wed, 26 Oct 2016 10:23:15 +0200 Subject: [PATCH 2/3] Update documentation for sortAscending and sortDescending ARIA strings --- js/model/model.defaults.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/js/model/model.defaults.js b/js/model/model.defaults.js index 99d31bb79..cd4a34124 100644 --- a/js/model/model.defaults.js +++ b/js/model/model.defaults.js @@ -1417,9 +1417,10 @@ DataTable.defaults = { /** * ARIA label that is added to the table headers when the column may be * sorted ascending by activing the column (click or return when focused). - * Note that the column header is prefixed to this string. + * The variable _HEADER_ is replaced by the column header. If not present, + * the column header is prefixed to this string. * @type string - * @default : activate to sort column ascending + * @default _HEADER_: activate to sort column ascending * * @dtopt Language * @name DataTable.defaults.language.aria.sortAscending @@ -1429,20 +1430,21 @@ DataTable.defaults = { * $('#example').dataTable( { * "language": { * "aria": { - * "sortAscending": " - click/return to sort ascending" + * "sortAscending": "click to sort by _HEADER_ ascending" * } * } * } ); * } ); */ - "sSortAscending": ": activate to sort column ascending", + "sSortAscending": "_HEADER_: activate to sort column ascending", /** * ARIA label that is added to the table headers when the column may be * sorted descending by activing the column (click or return when focused). - * Note that the column header is prefixed to this string. + * The variable _HEADER_ is replaced by the column header. If not present, + * the column header is prefixed to this string. * @type string - * @default : activate to sort column ascending + * @default _HEADER_: activate to sort column ascending * * @dtopt Language * @name DataTable.defaults.language.aria.sortDescending @@ -1452,13 +1454,13 @@ DataTable.defaults = { * $('#example').dataTable( { * "language": { * "aria": { - * "sortDescending": " - click/return to sort descending" + * "sortDescending": "click to sort by _HEADER_ descending" * } * } * } ); * } ); */ - "sSortDescending": ": activate to sort column descending" + "sSortDescending": "_HEADER_: activate to sort column descending" }, /** From 795937403922cc226ab31d0a3696fa355dd4ce9e Mon Sep 17 00:00:00 2001 From: Ferran Mesas Date: Wed, 26 Oct 2016 10:28:28 +0200 Subject: [PATCH 3/3] Update documentation for sortAscending and sortDescending ARIA strings --- docs/option/language.aria.sortAscending.xml | 4 ++-- docs/option/language.aria.sortDescending.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/option/language.aria.sortAscending.xml b/docs/option/language.aria.sortAscending.xml index 2cbd6e74b..96a999bbf 100644 --- a/docs/option/language.aria.sortAscending.xml +++ b/docs/option/language.aria.sortAscending.xml @@ -10,14 +10,14 @@ ARIA label that is added to the table headers when the column may be sorted ascending by activating the column (click or return when focused). - Note that the column header text is prefixed to this string. + The variable _HEADER_ is replaced by the column header. If not present, the column header is prefixed to this string. ARIA label that is added to the table headers when the column may be sorted descending by activing the column (click or return when focused). - Note that the column header text is prefixed to this string. + The variable _HEADER_ is replaced by the column header. If not present, the column header is prefixed to this string.