mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
* Add a global setting for Ctrl-F focus (improve #14947) * Move this new global setting to user setting (improve #14947) * Update preferences.blade.php Cleaner wording, and Copy & Paste bled through. * Fix indents and @endif position in menu.blade.php --------- Co-authored-by: Justin Lentz <monkeybrains7@gmail.com>
This commit is contained in:
@@ -75,6 +75,7 @@ class UserPreferencesController extends Controller
|
||||
'site_styles' => $styles,
|
||||
'timezone' => UserPref::getPref($user, 'timezone'),
|
||||
'hide_dashboard_editor' => UserPref::getPref($user, 'hide_dashboard_editor') ?? 0,
|
||||
'global_search_ctrlf_focus' => UserPref::getPref($user, 'global_search_ctrlf_focus'),
|
||||
];
|
||||
|
||||
if (Config::get('twofactor')) {
|
||||
@@ -116,6 +117,7 @@ class UserPreferencesController extends Controller
|
||||
Rule::in(array_merge(['default'], timezone_identifiers_list())),
|
||||
],
|
||||
'hide_dashboard_editor' => 'required|integer',
|
||||
'global_search_ctrlf_focus' => 'required|integer',
|
||||
];
|
||||
|
||||
$this->validate($request, [
|
||||
|
@@ -256,6 +256,7 @@ class MenuComposer
|
||||
|
||||
// Search bar
|
||||
$vars['typeahead_limit'] = Config::get('webui.global_search_result_limit');
|
||||
$vars['global_search_ctrlf_focus'] = UserPref::getPref(Auth::user(), 'global_search_ctrlf_focus');
|
||||
|
||||
// Plugins
|
||||
$vars['has_v1_plugins'] = Plugins::count() != 0;
|
||||
|
@@ -761,21 +761,22 @@
|
||||
}
|
||||
@endif
|
||||
|
||||
$(document).ready(function(){
|
||||
// Function to focus Global Search on Ctrl-F
|
||||
window.addEventListener("keydown",function (e) {
|
||||
if (e.keyCode === 114 || (e.ctrlKey && e.keyCode === 70)){
|
||||
if($('#gsearch').is(":focus")) {
|
||||
//allow normal Ctrl-F on a 2nd Hit
|
||||
return true;
|
||||
} else {
|
||||
//set Focus on Global Search and ignore Browsers defaults
|
||||
e.preventDefault();
|
||||
$('#gsearch').focus();
|
||||
}
|
||||
}
|
||||
@if($global_search_ctrlf_focus)
|
||||
$(document).ready(function(){
|
||||
// Function to focus Global Search on Ctrl-F
|
||||
window.addEventListener("keydown",function (e) {
|
||||
if (e.keyCode === 114 || (e.ctrlKey && e.keyCode === 70)){
|
||||
if($('#gsearch').is(":focus")) {
|
||||
//allow normal Ctrl-F on a 2nd Hit
|
||||
return true;
|
||||
} else {
|
||||
//set Focus on Global Search and ignore Browsers defaults
|
||||
e.preventDefault();
|
||||
$('#gsearch').focus();
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
@endif
|
||||
|
||||
</script>
|
||||
|
@@ -109,6 +109,12 @@
|
||||
<input id="notetodevice" type="checkbox" name="notetodevice" @if($note_to_device) checked @endif>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="global_search_ctrlf_focus" class="col-sm-4 control-label">{{ __('Ctrl-F to focus the global search bar') }}</label>
|
||||
<div class="col-sm-4">
|
||||
<input id="global_search_ctrlf_focus" type="checkbox" name="global_search_ctrlf_focus" @if($global_search_ctrlf_focus) checked @endif>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</x-panel>
|
||||
|
||||
@@ -230,6 +236,34 @@
|
||||
});
|
||||
});
|
||||
|
||||
$("[name='global_search_ctrlf_focus']")
|
||||
.bootstrapSwitch('offColor', 'danger')
|
||||
.on('switchChange.bootstrapSwitch', function (e, state) {
|
||||
var $this = $(this);
|
||||
$.ajax({
|
||||
url: '{{ route('preferences.store') }}',
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
data: {
|
||||
pref: 'global_search_ctrlf_focus',
|
||||
value: state ? 1 : 0
|
||||
},
|
||||
success: function () {
|
||||
$this.closest('.form-group').addClass('has-success');
|
||||
setTimeout(function () {
|
||||
$this.closest('.form-group').removeClass('has-success');
|
||||
}, 2000);
|
||||
},
|
||||
error: function () {
|
||||
$this.bootstrapSwitch('toggleState', true);
|
||||
$this.closest('.form-group').addClass('has-error');
|
||||
setTimeout(function(){
|
||||
$this.closest('.form-group').removeClass('has-error');
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.ajax-select').on("change", function () {
|
||||
var $this = $(this);
|
||||
var value = $this.val();
|
||||
|
Reference in New Issue
Block a user