aboutsummaryrefslogtreecommitdiffstats
path: root/apps/theming/js/settings-admin.js
diff options
context:
space:
mode:
authorSagorika Das <sagorika1996@gmail.com>2018-02-21 13:14:19 +0530
committerRoeland Jago Douma <roeland@famdouma.nl>2018-02-27 10:54:21 +0100
commit7394e8ae581c3fc1970e026b268481e4a45cd1b5 (patch)
treebd521a5262bdb2bab8fbd53c1766a37414a2a661 /apps/theming/js/settings-admin.js
parentd0a6368a8bc9b03cba66c4a485aa001da187b2e3 (diff)
downloadnextcloud-server-7394e8ae581c3fc1970e026b268481e4a45cd1b5.tar.gz
nextcloud-server-7394e8ae581c3fc1970e026b268481e4a45cd1b5.zip
Empty name not allowed
Do not allow empty name in theming app. Signed-off-by: Sagorika Das <sagorika1996@gmail.com>
Diffstat (limited to 'apps/theming/js/settings-admin.js')
-rw-r--r--apps/theming/js/settings-admin.js37
1 files changed, 32 insertions, 5 deletions
diff --git a/apps/theming/js/settings-admin.js b/apps/theming/js/settings-admin.js
index 7df1bbf1125..1f416bb2940 100644
--- a/apps/theming/js/settings-admin.js
+++ b/apps/theming/js/settings-admin.js
@@ -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());
+ }
}
});