Skip to content
Snippets Groups Projects
Select Git revision
  • 737c0b2ade4ea92ea85ad9c536553abfcbc96877
  • main default protected
  • step-3263
  • feature/plugins-cli
  • feature/vite
  • step-2484-peerreview
  • biest/issue-5051
  • tests/simplify-jsonapi-tests
  • fix/typo-in-1a70031
  • feature/broadcasting
  • database-seeders-and-factories
  • feature/peer-review-2
  • feature-feedback-jsonapi
  • feature/peerreview
  • feature/balloon-plus
  • feature/stock-images-unsplash
  • tic-2588
  • 5.0
  • 5.2
  • biest/unlock-blocks
  • biest-1514
21 results

settings.js

Blame
  • Forked from Stud.IP / Stud.IP
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    settings.js 2.23 KiB
    // Copy elements value to another element on change
    // Used for title choosers
    $(document).on('change', '[data-target]', function() {
        var target = $(this).data().target;
        $(target).val(this.value);
    });
    
    STUDIP.domReady(() => {
        $('#edit_userdata').on('change', 'input[name^=email]', function() {
            var changed = false;
            $('#edit_userdata input[name^=email]').each(function() {
                changed = changed || this.value !== this.defaultValue;
            });
            $('#edit_userdata .email-change-confirm').toggle(changed);
        });
    
        $('#edit_userdata .email-change-confirm').hide();
    });
    
    //
    $(document).on('change', '#settings-notifications :checkbox', function() {
        var name = $(this).attr('name');
    
        if (name === 'all[all]') {
            $(this)
                .closest('table')
                .find(':checkbox')
                .prop('checked', this.checked);
            return;
        }
    
        if (/all\[columns\]/.test(name)) {
            var index =
                $(this)
                    .closest('td')
                    .index() + 2;
            $(this)
                .closest('table')
                .find('tbody td:nth-child(' + index + ') :checkbox')
                .prop('checked', this.checked);
        } else if (/all\[rows\]/.test(name)) {
            $(this)
                .closest('td')
                .siblings()
                .find(':checkbox')
                .prop('checked', this.checked);
        }
    
        $('.notification.settings tbody :checkbox[name^=all]').each(function() {
            var other = $(this)
                .closest('td')
                .siblings()
                .find(':checkbox');
            this.checked = other.filter(':not(:checked)').length === 0;
        });
    
        $('.notification.settings thead :checkbox').each(function() {
            var index =
                    $(this)
                        .closest('td')
                        .index() + 2,
                other = $(this)
                    .closest('table')
                    .find('tbody td:nth-child(' + index + ') :checkbox');
            this.checked = other.filter(':not(:checked)').length === 0;
        });
    });
    
    $(document).on('input', '#new_password', function() {
        var message = $(this).data().message;
        if (this.validity.patternMismatch) {
            this.setCustomValidity(message);
        } else {
            this.setCustomValidity('');
        }
    });