Merge pull request #6759 from iMattPro/ticket/17449

[ticket/17449] Better handling of emoji and mb chars in PWA manifest
This commit is contained in:
Marc Alexander 2024-12-06 20:13:03 +01:00 committed by GitHub
commit 0adcda10d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 23 additions and 2 deletions

View file

@ -162,6 +162,22 @@ function parse_document(container)
});
/**
* Dynamically control a text field's maxlength (allows emoji to be counted as 1 character)
*/
container.find('#sitename_short').each(function() {
const $this = this;
const maxLength = $this.maxLength;
$this.maxLength = maxLength * 2;
$this.addEventListener('input', () => {
const inputChars = Array.from($this.value);
if (inputChars.length > maxLength) {
$this.value = inputChars.slice(0, maxLength).join('');
}
});
});
/**
* Responsive tabs
*/

View file

@ -69,9 +69,12 @@ class manifest
$board_path = $this->config['force_server_vars'] ? $this->config['script_path'] : $this->path_helper->get_web_root_path();
$sitename = html_entity_decode($this->config['sitename'], ENT_QUOTES, 'UTF-8');
$sitename_short = html_entity_decode($this->config['sitename_short'], ENT_QUOTES, 'UTF-8');
$manifest = [
'name' => $this->config['sitename'],
'short_name' => $this->config['sitename_short'] ?: substr($this->config['sitename'], 0, 12),
'name' => $sitename,
'short_name' => $sitename_short ?: utf8_substr($sitename, 0, 12),
'display' => 'standalone',
'orientation' => 'portrait',
'dir' => $this->language->lang('DIRECTION'),

View file

@ -5,8 +5,10 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="{{ SITENAME }}">
<meta name="application-name" content="{{ SITENAME }}">
{META}
<title><!-- IF UNREAD_NOTIFICATIONS_COUNT -->({UNREAD_NOTIFICATIONS_COUNT}) <!-- ENDIF --><!-- IF not S_VIEWTOPIC and not S_VIEWFORUM -->{SITENAME} - <!-- ENDIF --><!-- IF S_IN_MCP -->{L_MCP} - <!-- ELSEIF S_IN_UCP -->{L_UCP} - <!-- ENDIF -->{PAGE_TITLE}<!-- IF S_VIEWTOPIC or S_VIEWFORUM --> - {SITENAME}<!-- ENDIF --></title>