Files
edx-platform/lms/static/js/dashboard/credit.js
Clinton Blackburn 2653f0ad6b Fixed credit form submission bug
Firefox requires the form to be attached to a DOM element

ECOM-2492
2015-10-06 11:49:45 -04:00

48 lines
1.5 KiB
JavaScript

/**
* Student dashboard credit messaging.
*/
var edx = edx || {};
(function ($, analytics) {
'use strict';
$(document).ready(function () {
var $errorContainer = $(".credit-error-msg"),
creditStatusError = $errorContainer.data("credit-error");
if (creditStatusError === "True") {
$errorContainer.toggleClass("is-hidden");
}
// Fire analytics events when the "purchase credit" button is clicked
$(".purchase-credit-btn").on("click", function (event) {
var courseKey = $(event.target).data("course-key");
analytics.track(
"edx.bi.credit.clicked_purchase_credit",
{
category: "credit",
label: courseKey
}
);
});
// This event invokes credit request endpoint. It will initiate
// a credit request for the credit course for the provided user.
$(".pending-credit-btn").on("click", function (event) {
var $target = $(event.target),
courseKey = $target.data("course-key"),
username = $target.data("user"),
providerId = $target.data("provider");
event.preventDefault();
edx.commerce.credit.createCreditRequest(providerId, courseKey, username).fail(function () {
$(".credit-action").hide();
$errorContainer.toggleClass("is-hidden");
});
});
});
})(jQuery, window.analytics);