Skip to content

Commit 217c415

Browse files
feat: add ZM_WEB_BUTTON_STYLE config for icons+text, icons, or text buttons
Add a web config option to control toolbar button display: - icons+text (default): show both icon and label - icons: show only the icon, hide text labels - text: show only the label, hide icons on buttons that have labels Body class (btn-icons-only / btn-text-only) is set in getBodyTopHTML() and CSS rules in skin.css toggle visibility of .text spans and icon elements. Add title tooltips to console.php buttons so they remain usable in icon-only mode. Migration appended to zm_update-1.39.4.sql. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0de4753 commit 217c415

File tree

6 files changed

+55
-8
lines changed

6 files changed

+55
-8
lines changed

db/zm_update-1.39.4.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,17 @@ UPDATE Config SET
1717
No: Checkbox is shown and unchecked by default. Users may check it to persist the session.
1818
'
1919
WHERE Name = 'ZM_OPT_USE_REMEMBER_ME';
20+
21+
--
22+
-- Add ZM_WEB_BUTTON_STYLE config option
23+
--
24+
25+
SET @s = (SELECT IF(
26+
(SELECT COUNT(*) FROM Config WHERE Name = 'ZM_WEB_BUTTON_STYLE') > 0,
27+
"SELECT 'ZM_WEB_BUTTON_STYLE already exists'",
28+
"INSERT INTO Config SET Id = 251, Name = 'ZM_WEB_BUTTON_STYLE', Value = 'icons+text', Type = 'string', DefaultValue = 'icons+text', Hint = 'icons+text|icons|text', Pattern = '(?^i:^([it]))', Format = ' $1 ', Prompt = 'How to display toolbar buttons throughout the interface', Help = 'Controls the display of toolbar buttons across the web interface. Icons + Text: Show both icon and label (default). Icons Only: Show only the icon; labels are hidden. Text Only: Show only the label; icons are hidden on buttons that have labels.', Category = 'web', Readonly = '0', Requires = ''"
29+
));
30+
31+
PREPARE stmt FROM @s;
32+
EXECUTE stmt;
33+
DEALLOCATE PREPARE stmt;

scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3017,6 +3017,24 @@ our @options = (
30173017
requires => [ { name=>'ZM_WEB_NAVBAR_TYPE', value=>'left' } ],
30183018
category => 'web',
30193019
},
3020+
{
3021+
name => 'ZM_WEB_BUTTON_STYLE',
3022+
default => 'icons+text',
3023+
description => 'How to display toolbar buttons throughout the interface.',
3024+
help => q`
3025+
Controls the display of toolbar buttons across the web interface.
3026+
Icons + Text: Show both icon and label (default).
3027+
Icons Only: Show only the icon; labels are hidden.
3028+
Text Only: Show only the label; icons are hidden on buttons that have labels.
3029+
`,
3030+
type => {
3031+
db_type => 'string',
3032+
hint => 'icons+text|icons|text',
3033+
pattern => qr|^([it])|i,
3034+
format => q( $1 )
3035+
},
3036+
category => 'web',
3037+
},
30203038
{
30213039
name => 'ZM_WEB_H_REFRESH_MAIN',
30223040
default => '240',

web/skins/classic/css/base/skin.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,4 +1633,18 @@ video-stream[id^='liveStream'] video{
16331633
.invisible {
16341634
visibility: hidden;
16351635
}
1636+
1637+
/* Button style: icons only — hide text labels */
1638+
.btn-icons-only button .text,
1639+
.btn-icons-only .btn .text {
1640+
display: none;
1641+
}
1642+
1643+
/* Button style: text only — hide icons on buttons that have a text label */
1644+
.btn-text-only button:has(.text) > i.material-icons,
1645+
.btn-text-only button:has(.text) > i.fa,
1646+
.btn-text-only .btn:has(.text) > i.material-icons,
1647+
.btn-text-only .btn:has(.text) > i.fa {
1648+
display: none;
1649+
}
16361650
/* --- This block should always be located at the end! */

web/skins/classic/includes/functions.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ function getBodyTopHTML() {
159159
$classes = $view.'-page';
160160
if (defined('ZM_WEB_NAVBAR_STICKY') and ZM_WEB_NAVBAR_STICKY) $classes .= ' sticky';
161161
if (defined('ZM_WEB_FILTER_SETTINGS_POSITION') and ZM_WEB_FILTER_SETTINGS_POSITION == 'inline') $classes .= ' filter-inline';
162+
if (defined('ZM_WEB_BUTTON_STYLE') and ZM_WEB_BUTTON_STYLE == 'icons') $classes .= ' btn-icons-only';
163+
else if (defined('ZM_WEB_BUTTON_STYLE') and ZM_WEB_BUTTON_STYLE == 'text') $classes .= ' btn-text-only';
162164
$classHTML = ' class="'.$classes.'"';
163165
echo '
164166
<body data-swipe-threshold="10" data-swipe-unit="vw" data-swipe-timeout="300"'.$classHTML.'>

web/skins/classic/js/skin.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,8 +847,7 @@ function isJSON(str) {
847847
const result = JSON.parse(str);
848848
const type = Object.prototype.toString.call(result);
849849
return type === '[object Object]' || type === '[object Array]'; // We only pass objects and arrays
850-
} catch (e) {
851-
console.log('This is not JSON', str, e);
850+
} catch {
852851
return false; // This is also not JSON
853852
}
854853
}

web/skins/classic/views/console.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,31 +190,31 @@
190190
}
191191
?>
192192
<button type="button" name="addBtn" data-on-click="addMonitor"
193-
<?php echo $canCreateMonitors ? '' : ' disabled="disabled" title="'.translate('AddMonitorDisabled').'"' ?>
193+
<?php echo $canCreateMonitors ? 'title="'.translate('Add Monitor').'"' : ' disabled="disabled" title="'.translate('AddMonitorDisabled').'"' ?>
194194
>
195195
<i class="material-icons">add_circle</i>
196196
<span class="text">&nbsp;<?php echo translate('AddNewMonitor') ?></span>
197197
</button>
198-
<button type="button" name="cloneBtn" data-on-click-this="cloneMonitor" disabled="disabled">
198+
<button type="button" name="cloneBtn" data-on-click-this="cloneMonitor" disabled="disabled" title="<?php echo translate('Clone')?>">
199199
<i class="material-icons">content_copy</i>
200200
<!--content_copy used instead of file_copy as there is a bug in material-icons -->
201201
<span class="text">&nbsp;<?php echo translate('CloneMonitor') ?></span>
202202
</button>
203-
<button type="button" name="editBtn" data-on-click-this="editMonitor" disabled="disabled">
203+
<button type="button" name="editBtn" data-on-click-this="editMonitor" disabled="disabled" title="<?php echo translate('Edit')?>">
204204
<i class="material-icons">edit</i>
205205
<span class="text">&nbsp;<?php echo translate('Edit') ?></span>
206206
</button>
207-
<button type="button" name="deleteBtn" data-on-click-this="deleteMonitor" disabled="disabled">
207+
<button type="button" name="deleteBtn" data-on-click-this="deleteMonitor" disabled="disabled" title="<?php echo translate('Delete')?>">
208208
<i class="material-icons">delete</i>
209209
<span class="text">&nbsp;<?php echo translate('Delete') ?></span>
210210
</button>
211-
<button type="button" name="selectBtn" data-on-click-this="selectMonitor" disabled="disabled">
211+
<button type="button" name="selectBtn" data-on-click-this="selectMonitor" disabled="disabled" title="<?php echo translate('Select')?>">
212212
<i class="material-icons">view_list</i>
213213
<span class="text">&nbsp;<?php echo translate('Select') ?></span>
214214
</button>
215215
</div>
216216
<div class="rightButtons">
217-
<button type="button" id="sortBtn" data-on-click-this="sortMonitors">
217+
<button type="button" id="sortBtn" data-on-click-this="sortMonitors" title="<?php echo translate('Sort')?>">
218218
<i class="material-icons sort" title="Click and drag rows to change order">swap_vert</i>
219219
<span class="text"><?php echo translate('Sort') ?></span>
220220
</button>

0 commit comments

Comments
 (0)