mirror of
https://framagit.org/hubzilla/core.git
synced 2026-06-21 00:52:33 -04:00
Changed behavior in the user interaction of the languages selection. Now works...
This commit is contained in:
@@ -7,6 +7,52 @@ use Zotlabs\Web\Controller;
|
||||
|
||||
class Lang extends Controller {
|
||||
|
||||
const MYP = 'ZIN';
|
||||
const VERSION = '2.0.0';
|
||||
|
||||
function post() {
|
||||
|
||||
$re = [];
|
||||
$isajax = is_ajax();
|
||||
$eol = $isajax ? "\n" : EOL;
|
||||
|
||||
if (! Apps::system_app_installed(local_channel(), 'Language')) {
|
||||
$re['msg'] = 'ZIN0202E, ' . t('Language App') . ' (' . t('Not Installed') . ')' ;
|
||||
notice( $re['msg'] . EOL);
|
||||
if ($isajax) {
|
||||
echo json_encode( $re );
|
||||
killme();
|
||||
exit;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$lc = x($_POST['zinlc']) && preg_match('/^\?\?|[a-z]{2,2}[x_\-]{0,1}[a-zA-Z]{0,2}$/', $_POST['zinlc'])
|
||||
? $_POST['zinlc'] : '';
|
||||
$lcs= x($_POST['zinlcs']) && preg_match('/^[a-z,_\-]{0,191}$/', $_POST['zinlcs'])
|
||||
? $_POST['zinlcs'] : '';
|
||||
|
||||
if ($isajax) {
|
||||
|
||||
if ($lc == '??') {
|
||||
$re['lc'] = get_best_language();
|
||||
$re['lcs'] = language_list();
|
||||
} else {
|
||||
$re['lc'] = $lc;
|
||||
$re['alc'] = App::$language;
|
||||
$re['slc'] = $_SESSION['language'];
|
||||
$_SESSION['language'] = $lc;
|
||||
App::$language = $lc;
|
||||
load_translation_table($lc, true);
|
||||
}
|
||||
|
||||
echo json_encode( $re );
|
||||
killme();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function get() {
|
||||
|
||||
if(local_channel()) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
version: 2
|
||||
version: 5.6
|
||||
url: $baseurl/lang
|
||||
name: Language
|
||||
photo: icon:language
|
||||
|
||||
@@ -78,6 +78,65 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
// @hilmar |->
|
||||
if ( typeof(window.tao) == 'undefined' ) {
|
||||
window.tao = {};
|
||||
}
|
||||
if ( typeof(window.tao.zin) == 'undefined' ) {
|
||||
tao.zin = { syslc: '', syslcs: {}, htm: '', me: '', debug: '' };
|
||||
tao.zin.axim = '<div class="zinpax fa fa-sync fa-spin"> </div>';
|
||||
$('.navbar-app[href*="/lang"]').attr({"data-toggle": "dropdown", "aria-expand": "true", "id": "zintog"})
|
||||
.removeAttr('href').addClass('zinlcx zinlcxp dropdown dropdown-toggle');
|
||||
$('.dropdown-item[href*="/lang"]').addClass('zinlcxmi zinlcx').removeAttr('href').css('cursor','pointer');
|
||||
}
|
||||
$('.zinlcx').on('click', function(e) {
|
||||
if (tao.zin.syslc == '') {
|
||||
$('.zinlcx').append(tao.zin.axim);
|
||||
$.ajax({
|
||||
type: 'POST', url: 'lang',
|
||||
data: { zinlc: '??' }
|
||||
}).done( function(re) {
|
||||
tao.zin.re = JSON.parse(re);
|
||||
tao.zin.syslc = tao.zin.re.lc;
|
||||
tao.zin.syslcs = tao.zin.re.lcs;
|
||||
tao.zin.htm = '<ul class="zinlcs fa-ul">';
|
||||
$.each( tao.zin.syslcs, function( k, v ) {
|
||||
tao.zin.htm += '<li><a id="zinlc' + k + '" class="zinlc dropdown-item fakelink">' + k + ' ' + v + '</a></li>';
|
||||
});
|
||||
tao.zin.htm += '</ul>';
|
||||
$('.zinpax').remove();
|
||||
$('.zinlcx').append(tao.zin.htm);
|
||||
$('.zinlcxp > ul').addClass('dropdown dropdown-menu dropdown-menu-right').css('left','-16em');
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
if (e.target.id == '') {
|
||||
// noop click on lang again
|
||||
return false;
|
||||
}
|
||||
tao.zin.me = e.target.id.substr(5);
|
||||
$('#right_aside_wrapper').append(tao.zin.axim);
|
||||
$.ajax({
|
||||
type: 'POST', url: 'lang',
|
||||
data: { zinlc: tao.zin.me }
|
||||
}).done( function(re) {
|
||||
tao.zin.re = JSON.parse(re);
|
||||
location.reload(true);
|
||||
});
|
||||
}
|
||||
});
|
||||
$('#zintog').on('click', function() {
|
||||
$('.zinlcs').toggle();
|
||||
});
|
||||
$('#dropdown-menu').on('shown.bs.dropdown', function() {
|
||||
tao.zin.debug += 'e,';
|
||||
//$('.zinlcs').removeAttr('display');
|
||||
})
|
||||
.on('mouseleave', function() {
|
||||
$(this).trigger('click');
|
||||
});
|
||||
// @hilmar <-|
|
||||
|
||||
var tf = new Function('n', 's', 'var k = s.split("/")['+aStr['plural_func']+']; return (k ? k : s);');
|
||||
|
||||
jQuery.timeago.settings.strings = {
|
||||
|
||||
Reference in New Issue
Block a user