From 9c599868cc00316fa808bd49ca9f2cd9002800c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Thu, 9 May 2019 14:38:13 +0200 Subject: [PATCH] documentation for truncate fitler + only space between dots and words in wordwise mode. --- .../src/common/filters/truncate.filter.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/filters/truncate.filter.js b/src/Umbraco.Web.UI.Client/src/common/filters/truncate.filter.js index 320b380393..5efe0f5fff 100644 --- a/src/Umbraco.Web.UI.Client/src/common/filters/truncate.filter.js +++ b/src/Umbraco.Web.UI.Client/src/common/filters/truncate.filter.js @@ -1,3 +1,15 @@ +/** + * @ngdoc filter + * @name umbraco.filters.filter:truncate + * @namespace truncateFilter + * + * param {any} wordwise if true, the string will be cut after last fully displayed word. + * param {any} max max length of the outputtet string + * param {any} tail option tail, defaults to: ' ...' + * + * @description + * Limits the length of a string, if a cut happens only the string will be appended with three dots to indicate that more is available. + */ angular.module("umbraco.filters").filter('truncate', function () { return function (value, wordwise, max, tail) { @@ -13,7 +25,7 @@ angular.module("umbraco.filters").filter('truncate', value = value.substr(0, lastspace); } } - return value + (tail || ' …'); + return value + (tail || (wordwise ? ' …' : '…')); }; } );