- 🇩🇪Germany gngn
Trying to sort out the diffs between #19, #20, #21, #22
- @JurgenR wrote in #20
Patch #19 can't apply on 8.x-1.0-beta4.
This is caused by changed line numbers, I've updated the patch to work against 8.x-1.0-beta4.But #20 differs from #19 by missing the following change in #19 in js/menu_link_weight.js:
// Checking and unchecking the checkbox may also update the link title. $checkbox.on('change', function() { if ($checkbox.is(':checked') && !$link_title.data('menuLinkAutomaticTitleOverridden')) { if ($title.val() !== undefined) { - $current_selection.html($title.val().substring(0, 30)); + $current_selection.html(Drupal.menu_truncate($title.val(), $truncate, $add_ellipsis)); } } });
So #20 drops the support for "Checking and unchecking the checkbox" (by keeping the hardcoded 30).
- 8.x-1.0-beta5 added a check
$title.val() !== undefined)
to the same part:
< $current_selection.html($title.val().substring(0, 30)); --- > if ($title.val() !== undefined) { > $current_selection.html($title.val().substring(0, 30)); > }
This change made it into #21 (meant for 8.x-1.0-beta4):
// Checking and unchecking the checkbox may also update the link title. $checkbox.on('change', function() { if ($checkbox.is(':checked') && !$link_title.data('menuLinkAutomaticTitleOverridden')) { - $current_selection.html($title.val().substring(0, 30)); + if ($title.val() !== undefined) { + $current_selection.html($title.val().substring(0, 30)); + } } }); });
which still keeps the hardcoded 30.
#21 also changes the behavoiur of Drupal.menu_truncate - I think that is meant by
ellipsis behaviour was not working as expected when dealing with long words
- #19 and #20 had:
+ Drupal.menu_truncate = function (title, max_length, add_ellipsis) { + var truncated = jQuery.trim(title).substring(0, max_length); + if (add_ellipsis) { + // Thanx to + // https://stackoverflow.com/questions/2248742/jquery-text-truncation-read-more-style/2249591#2249591 + truncated = truncated.split(" ") // separate characters into an array of words + .slice(0, -1) // remove the last full or partial wordc + .join(" ") + "..."; // remove the last full or partial word + } + return truncated; + }
- #21 has:
+ Drupal.menu_truncate = function (title, max_length, add_ellipsis) { + var ellipsis = add_ellipsis ? "..." : ""; + return jQuery.trim(title).length > max_length ? title.slice(0, max_length) + ellipsis : title; + };
I did not test this change.
- #19 and #20 had:
- #22 is #21 applied to 8.x-1.0-beta5 (I think).
Since 8.x-1.0-beta5 added the mentioned check$title.val() !== undefined)
#22 does not include this change.
So I think we should
- Reintroduce the mentioned use of Drupal.menu_truncate() (introduced in #19, dropped in #20, #21, #22).
- Decide wether ellipsis behaviour is better handled in #19 or in #21.
@JurgenR can you name an example for ?
Patch coming.
- @JurgenR wrote in #20
- last update
over 1 year ago Composer error. Unable to continue.