index.js 1.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
define(['jquery.form', 'js/index'], function() {
    'use strict';
    return function () {
        // 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');
        });

        var reloadPage = function () {
            location.reload();
        };

        var showError = function ()  {
            $('#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 33 34 35
        };

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

        $('#request-coursecreator-submit').click(function(event){
            $(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
        });
    };
});