index.js 1.3 KB
Newer Older
1 2
define(['jquery.form', 'js/index'], function() {
    'use strict';
3
    return function() {
4 5 6 7 8 9 10 11 12 13
        // showing/hiding creation rights UI
        $('.show-creationrights').click(function(e) {
            e.preventDefault();
            $(this)
                .closest('.wrapper-creationrights')
                    .toggleClass('is-shown')
                .find('.ui-toggle-control')
                    .toggleClass('current');
        });

14
        var reloadPage = function() {
15 16 17
            location.reload();
        };

18
        var showError = function() {
19 20 21 22 23
            $('#request-coursecreator-submit')
                .toggleClass('has-error')
                .find('.label')
                    .text('Sorry, there was error with your request');
            $('#request-coursecreator-submit')
24 25
                .find('.fa-cog')
                    .toggleClass('fa-spin');
26 27 28 29 30 31 32
        };

        $('#request-coursecreator').ajaxForm({
            error: showError,
            success: reloadPage
        });

33
        $('#request-coursecreator-submit').click(function(event) {
34 35
            $(this)
                .toggleClass('is-disabled is-submitting')
36
                .attr('aria-disabled', $(this).hasClass('is-disabled'))
37
                .find('.label')
38
                .text('Submitting Your Request');
39 40 41
        });
    };
});