!function(d){window.llms=window.llms||{};window.llms.MetaboxStudents=new function(){this.init=function(){window.llms.post.post_type&&-1!==["course","llms_membership"].indexOf(window.llms.post.post_type)&&(this.$metabox=d("#lifterlms-students"),this.bind())},this.bind=function(){var e=this;this.$metabox.on("click","a.llms-remove-student",function(t){t.preventDefault(),e.remove_student(d(this))}),this.$metabox.on("click","a.llms-delete-enrollment",function(t){t.preventDefault(),e.delete_student_enrollment(d(this))}),this.$metabox.on("click","a.llms-add-student",function(t){t.preventDefault(),e.add_student(d(this))}),d("#llms-add-student-select").llmsStudentsSelect2({multiple:!0}),d("#llms-enroll-students").on("click",function(){e.enroll_students(d(this))})},this.add_student=function(t){this.update_student_enrollment(t.attr("data-id"),"add")},this.enroll_students=function(e){var n=d("#llms-add-student-select"),s=n.val(),l=this.$metabox.find(".llms-metabox-students-add-new");LLMS.Spinner.start(l),window.LLMS.Ajax.call({data:{action:"bulk_enroll_students",student_ids:s},beforeSend:function(t){s||(e.before('<span class="llms-error">'+LLMS.l10n.translate("Please select a student to enroll")+"</span>"),t.abort(),LLMS.Spinner.stop(l))},success:function(t){n.val(null).trigger("change"),LLMS.Spinner.stop(l),window.llms.admin_tables.reload(d("#llms-gb-table-student-management"))}})},this.remove_student=function(t){this.update_student_enrollment(t.attr("data-id"),"remove")},this.delete_student_enrollment=function(t){this.update_student_enrollment(t.attr("data-id"),"delete")},this.update_student_enrollment=function(t,e){var n=d("#llms-gb-table-student-management"),s=n.closest(".llms-table-wrap");LLMS.Spinner.start(s),window.LLMS.Ajax.call({data:{action:"update_student_enrollment",status:e,student_id:t},success:function(){window.llms.admin_tables.reload(n)}})},this.init()}}(jQuery); //# sourceMappingURL=../maps/js/llms-metabox-students.min.js.map