Etemplate: let break_title be optional based on space, and keep the actual characters

This commit is contained in:
nathangray 2021-05-10 11:55:22 -06:00
parent b8eacf5332
commit 5ecba984cf
2 changed files with 16 additions and 3 deletions

View File

@ -1144,8 +1144,6 @@ var et2_link = /** @class */ (function (_super) {
_value.title = ""; _value.title = "";
} }
} }
if (this.options.break_title && _value.title)
_value.title = _value.title.replace(this.options.break_title, "\r\n");
this.set_title(this.link, _value.title); this.set_title(this.link, _value.title);
}; };
/** /**
@ -1158,6 +1156,13 @@ var et2_link = /** @class */ (function (_super) {
et2_link.prototype.set_title = function (node, _value) { et2_link.prototype.set_title = function (node, _value) {
if (_value === false || _value === null) if (_value === false || _value === null)
_value = ""; _value = "";
if (this.options.break_title) {
// Set up title to optionally break on the provided character - replace all space with nbsp, add a
// zero-width space after the break string
_value = _value
.replace(this.options.break_title, this.options.break_title + "\u200B")
.replace(/ /g, '\u00a0');
}
jQuery(node).text(_value + ""); jQuery(node).text(_value + "");
}; };
/** /**

View File

@ -1446,7 +1446,6 @@ export class et2_link extends et2_valueWidget implements et2_IDetachedDOM
_value.title = ""; _value.title = "";
} }
} }
if (this.options.break_title && _value.title) _value.title = _value.title.replace(this.options.break_title, "\r\n");
this.set_title(this.link, _value.title); this.set_title(this.link, _value.title);
} }
@ -1460,6 +1459,15 @@ export class et2_link extends et2_valueWidget implements et2_IDetachedDOM
set_title( node, _value) set_title( node, _value)
{ {
if(_value === false || _value === null) _value = ""; if(_value === false || _value === null) _value = "";
if (this.options.break_title)
{
// Set up title to optionally break on the provided character - replace all space with nbsp, add a
// zero-width space after the break string
_value = _value
.replace(this.options.break_title, this.options.break_title+"\u200B")
.replace(/ /g, '\u00a0');
}
jQuery(node).text(_value+""); jQuery(node).text(_value+"");
} }