diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-06-15 20:30:30 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-06-15 20:30:30 -0400 |
commit | 57dd45839b3ed61fc38b15621b688b088f57b04f (patch) | |
tree | 17f8c2f627d4900e359817a75a14ec92de777b5c | |
parent | 100330c989873d535785fdb1586d3602b1def202 (diff) |
Use css to truncate the page title
-rw-r--r-- | app/Helper/Text.php | 4 | ||||
-rw-r--r-- | app/Template/layout.php | 2 | ||||
-rw-r--r-- | assets/css/app.css | 5 | ||||
-rw-r--r-- | assets/css/src/header.css | 5 | ||||
-rw-r--r-- | tests/units/TextHelperTest.php | 2 |
5 files changed, 13 insertions, 5 deletions
diff --git a/app/Helper/Text.php b/app/Helper/Text.php index cfb557b1..790fc411 100644 --- a/app/Helper/Text.php +++ b/app/Helper/Text.php @@ -51,10 +51,10 @@ class Text extends \Core\Base */ public function truncate($value, $max_length = 85, $end = '[...]') { - $length = strlen($value); + $length = mb_strlen($value); if ($length > $max_length) { - return substr($value, 0, $max_length).' '.$end; + return mb_substr($value, 0, $max_length).' '.$end; } return $value; diff --git a/app/Template/layout.php b/app/Template/layout.php index 989afe18..0d9326f4 100644 --- a/app/Template/layout.php +++ b/app/Template/layout.php @@ -38,7 +38,7 @@ <?php else: ?> <header> <nav> - <h1><?= $this->url->link('K<span>B</span>', 'app', 'index', array(), false, 'logo', t('Dashboard')).' '.$this->text->truncate($this->e($title)) ?> + <h1><?= $this->url->link('K<span>B</span>', 'app', 'index', array(), false, 'logo', t('Dashboard')).' '.$this->e($title) ?> <?php if (! empty($description)): ?> <span class="column-tooltip" title='<?= $this->e($this->text->markdown($description)) ?>'> <i class="fa fa-info-circle"></i> diff --git a/assets/css/app.css b/assets/css/app.css index 73df92fc..f86f5051 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -653,13 +653,16 @@ div.ui-tooltip { header { margin-top: 10px; padding-bottom: 15px; - clear: both; border-bottom: 1px solid #dedede; } header h1 { margin: 0; padding: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + width: 75%; float: left; } diff --git a/assets/css/src/header.css b/assets/css/src/header.css index 2490b125..bcb9dcd7 100644 --- a/assets/css/src/header.css +++ b/assets/css/src/header.css @@ -2,13 +2,16 @@ header { margin-top: 10px; padding-bottom: 15px; - clear: both; border-bottom: 1px solid #dedede; } header h1 { margin: 0; padding: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + width: 75%; float: left; } diff --git a/tests/units/TextHelperTest.php b/tests/units/TextHelperTest.php index 20b89fa8..01652d5c 100644 --- a/tests/units/TextHelperTest.php +++ b/tests/units/TextHelperTest.php @@ -45,6 +45,8 @@ class TextHelperTest extends Base $this->assertEquals('abc', $h->truncate('abc')); $this->assertEquals(str_repeat('a', 85).' [...]', $h->truncate(str_repeat('a', 200))); + + $this->assertEquals('Настольная рекл [...]', $h->truncate('Настольная реклама в фудкорте ГЧ', 15)); } public function testContains() |