Skip to content
credentials.js 1.13 KiB
Newer Older
(function () {

    window.credentials = {
        init: function (path) {
            restPath = path;
        },
        saveClicked: function (event) {
Sonia Zorba's avatar
Sonia Zorba committed
            if (event.keyCode === 13) {
Sonia Zorba's avatar
Sonia Zorba committed
                event.preventDefault();
                return false;
            }
        },
        editClicked: function (event) {
            if (event.status === 'success') {
                $('#credentials-modal').modal('show');
            }
        },
        credentialsSaved: function (event) {
            if (event.status === 'success') {
                if ($('#credentials-modal .text-danger').length === 0) {
                    $('#credentials-modal').modal('hide');
                }
            }
        }
    };

    $(document).ready(function () {
        $('body').on('shown.bs.modal', '#credentials-modal', function ( ) {
            $.post(restPath + "/credentialsDialog?opened=true");
        });
        $('body').on('hidden.bs.modal', '#credentials-modal', function ( ) {
            $.post(restPath + "/credentialsDialog?opened=false");
        });
    });