Merge pull request #8475 from sagorika1996/theme

Empty name not allowed in theming app
This commit is contained in:
Morris Jobke 2018-02-27 11:30:59 +01:00 committed by GitHub
commit 048ad0df1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 5 deletions

View File

@ -175,13 +175,40 @@ $(document).ready(function () {
$('#upload-login-background').click();
});
function checkName () {
var length = $('#theming-name').val().length;
try {
if (length > 0) {
return true;
} else {
throw t('theming', 'Name cannot be empty');
}
} catch (error) {
$('#theming-name').attr('title', error);
$('#theming-name').tooltip({placement: 'top', trigger: 'manual'});
$('#theming-name').tooltip('fixTitle');
$('#theming-name').tooltip('show');
$('#theming-name').addClass('error');
}
return false;
}
$('#theming-name').keyup(function() {
if (checkName()) {
$('#theming-name').tooltip('hide');
$('#theming-name').removeClass('error');
}
});
$('#theming-name').change(function(e) {
var el = $(this);
$.when(el.focusout()).then(function() {
setThemingValue('name', $(this).val());
});
if (e.keyCode == 13) {
setThemingValue('name', $(this).val());
if(checkName()){
$.when(el.focusout()).then(function() {
setThemingValue('name', $(this).val());
});
if (e.keyCode == 13) {
setThemingValue('name', $(this).val());
}
}
});