Improve language selection usability
This commit is contained in:
Serhan 2020-06-17 21:37:46 +02:00 committed by GitHub
commit 38db12b109
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 125 additions and 35 deletions

View File

@ -18,7 +18,7 @@
performTranslation();
var si = sysInfo.hyperion;
var libs = { "Bootstrap 3": "http://getbootstrap.com/", "JQuery": "https://jquery.com/", "Bootstrap Colorpicker": "https://itsjavi.com/bootstrap-colorpicker/", "Bootstrap Toggle": "https://www.bootstraptoggle.com/", "JSON-Editor": "http://jeremydorn.com/json-editor/", "jQuery.i18n": "https://github.com/wikimedia/jquery.i18n", "metisMenu": "http://mm.onokumus.com/index.html", "download.js": "http://danml.com/download.html", "gijgo": "http://gijgo.com/" };
var libs = { "Bootstrap 3": "http://getbootstrap.com/", "JQuery": "https://jquery.com/", "Bootstrap Colorpicker": "https://itsjavi.com/bootstrap-colorpicker/", "Bootstrap Toggle": "https://www.bootstraptoggle.com/", "Bootstrap Select": "https://developer.snapappointments.com/bootstrap-select/", "JSON-Editor": "http://jeremydorn.com/json-editor/", "jQuery.i18n": "https://github.com/wikimedia/jquery.i18n", "metisMenu": "http://mm.onokumus.com/index.html", "download.js": "http://danml.com/download.html", "gijgo": "http://gijgo.com/" };
var libh = "";
var lang = [];
var dcount = 0;

File diff suppressed because one or more lines are too long

View File

@ -47,6 +47,14 @@ h4 {
}
/*Buttons*/
.btn-transparent:hover {
color: #5db6ff;
}
.btn-transparent:focus{
color: #5db6ff;
}
.btn-default {
color: #DDDDDD;
background-color: #212121;

View File

@ -168,6 +168,12 @@ table label{margin:0}
border-color: #602060;
}
/*minimal visible button*/
.btn-transparent {
background-color: transparent;
border-style: none;
}
/*led preview & led visualisation*/
#leds_canvas {background-color:#AAAAAA; position:absolute; margin:15px; background-image:url(/img/hyperion/hyperionlogo.png); background-repeat:no-repeat; background-position: center;}
.led { display:inline-block; border: 1px solid black; position:absolute; opacity:0.8; text-align:center; vertical-align:middle; padding:4px; border-radius:2px;}

View File

@ -53,11 +53,14 @@
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-colorpicker.min.css" rel="stylesheet">
<link href="css/bootstrap-colorpicker.min.css" rel="stylesheet">
<!-- BSToggle -->
<script src="js/lib/bootstrap-toggle.min.js"></script>
<link href="css/bootstrap-toggle.min.css" rel="stylesheet">
<link href="css/bootstrap-toggle.min.css" rel="stylesheet">
<!-- BSSelect -->
<link href="css/bootstrap-select.min.css" rel="stylesheet">
<!-- MetisMenu CSS -->
<link href="css/metisMenu.css" rel="stylesheet">
@ -169,11 +172,13 @@
<i class="fa fa-wrench fa-fw"></i> <i class="fa fa-caret-down"></i>
</a>
<ul class="dropdown-menu dropdown-alerts">
<!-- /.language selector -->
<li id="btn_setlang">
<a>
<div>
<i class="fa fa-globe fa-fw"></i>
<span data-i18n="InfoDialog_lang_title"></span>
<i class="fa fa-globe"></i>
<select id="language-select" class="selectpicker" data-width="fit" data-style="btn-transparent" > </select>
</div>
</a>
</li>
@ -181,7 +186,7 @@
<li id="btn_setaccess">
<a>
<div>
<i class="fa fa-key fa-fw"></i>
<i class="fa fa-wrench fa-fw"></i>
<span data-i18n="InfoDialog_access_title"></span>
</div>
</a>
@ -197,6 +202,7 @@
</li>
</ul>
</li>
<!-- /.lock-ui -->
<li class="dropdown" id="btn_lock_ui" style="display:none">
<a>
@ -343,6 +349,12 @@
<!-- Bootstrap Core JavaScript -->
<script src="js/lib/bootstrap.min.js"></script>
<!-- BSToggle -->
<script src="js/lib/bootstrap-toggle.min.js"></script>
<!-- Bootstrap Select JavaScript -->
<script src="js/lib/bootstrap-select.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="js/lib/metisMenu.min.js"></script>

View File

@ -27,7 +27,7 @@ $(document).ready(function () {
$(window.hyperion).on("cmd-serverinfo", function (event) {
window.serverInfo = event.response.info;
// comps
window.comps = event.response.info.components
window.comps = event.response.info.components
$(window.hyperion).trigger("ready");
@ -56,6 +56,35 @@ $(document).ready(function () {
updateSessions();
}); // end cmd-serverinfo
// Update language selection
$("#language-select").on('changed.bs.select',function (e, clickedIndex, isSelected, previousValue){
var newLang = availLang[clickedIndex-1];
if (newLang !== storedLang)
{
setStorage("langcode", newLang);
reload();
}
});
$("#language-select").selectpicker(
{
container: 'body'
});
$(".bootstrap-select").click(function () {
$(this).addClass("open");
});
$(document).click(function(){
$(".bootstrap-select").removeClass("open");
});
$(".bootstrap-select").click(function(e){
e.stopPropagation();
});
//End language selection
$(window.hyperion).on("cmd-sessions-update", function (event) {
window.serverInfo.sessions = event.response.data;
updateSessions();

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,7 @@
var storedAccess;
var storedLang;
var availLang = ['en','de','es','it','cs','sv','nl','pl','ro'];
var availLangText = ['English','Deutsch','Español','Italiano','Čeština','Svenska','Nederlands','Polski','Română'];
var availAccess = ['default','advanced','expert'];
//$.i18n.debug = true;
@ -69,33 +70,7 @@ $(document).ready( function() {
$('#btn_setaccess').attr("disabled", true);
}
$('#btn_setlang').off().on('click',function() {
var newLang;
showInfoDialog('select', $.i18n('InfoDialog_lang_title'), $.i18n('InfoDialog_lang_text'));
for (var lcx = 0; lcx<availLang.length; lcx++)
{
$('#id_select').append(createSelOpt(availLang[lcx], $.i18n('general_speech_'+availLang[lcx])))
}
if (storedLang != "auto")
$('#id_select').val(storedLang);
$('#id_select').off().on('change',function() {
newLang = $('#id_select').val();
if (newLang == storedLang)
$('#id_btn_saveset').attr('disabled', true);
else
$('#id_btn_saveset').attr('disabled', false);
});
$('#id_btn_saveset').off().on('click',function() {
setStorage("langcode", newLang);
reload();
});
$('#id_select').trigger('change');
});
initLanguageSelection();
//access
storedAccess = getStorage("accesslevel");

View File

@ -178,6 +178,48 @@ function updateHyperionInstanceListing()
}
}
function initLanguageSelection()
{
// Initialise language selection list with languages supported
for (var i = 0; i < availLang.length; i++)
{
$("#language-select").append('<option value="'+i+'" selected="">'+availLangText[i]+'</option>');
}
var langLocale = storedLang;
// If no language has been set, resolve browser locale
if ( langLocale === 'auto' )
{
langLocale = $.i18n().locale.substring(0,2);
}
// Resolve text for language code
var langText = 'Please Select';
//Test, if language is supported by hyperion
langIdx = availLang.indexOf(langLocale)
if ( langIdx > -1 )
{
langText = availLangText[langIdx];
}
else
{
// If language is not supported by hyperion, try fallback language
langLocale = $.i18n().options.fallbackLocale.substring(0,2);
langIdx = availLang.indexOf(langLocale)
if ( langIdx > -1 )
{
langText = availLangText[langIdx];
}
}
//console.log("langLocale: ", langLocale, "langText: ", langText);
$('#language-select').prop('title', langText);
$("#language-select").val(langIdx);
$("#language-select").selectpicker("refresh");
}
function updateUiOnInstance(inst)
{
if(inst != 0)

View File

@ -9,6 +9,9 @@
#include <stdarg.h>
#include <map>
#include <QVector>
#ifdef _WIN32
#include <stdexcept>
#endif
#include <utils/global_defines.h>