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.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / assets / js / tutor-admin.js
tutor / assets / js Last commit date
Chart.bundle.min.js 5 years ago gutenberg_blocks.js 5 years ago mce-button.js 5 years ago tutor-admin.js 5 years ago tutor-front.js 5 years ago tutor-setup.js 5 years ago tutor.js 5 years ago
tutor-admin.js
701 lines
1 jQuery(document).ready(function($){
2 'use strict';
3
4 /**
5 * Color Picker
6 * @since v.1.2.21
7 */
8 if (jQuery().wpColorPicker) {
9 $('.tutor_colorpicker').wpColorPicker();
10 }
11
12 if (jQuery().select2){
13 $('.tutor_select2').select2();
14 }
15
16 /**
17 * Option Settings Nav Tab
18 */
19 $('.tutor-option-nav-tabs li a').click(function(e){
20 e.preventDefault();
21 var tab_page_id = $(this).attr('data-tab');
22 $('.option-nav-item').removeClass('current');
23 $(this).closest('li').addClass('current');
24 $('.tutor-option-nav-page').hide();
25 $(tab_page_id).addClass('current-page').show();
26 window.history.pushState('obj', '', $(this).attr('href'));
27 });
28
29 $('#save_tutor_option').click(function (e) {
30 e.preventDefault();
31 $(this).closest('form').submit();
32 });
33 $('#tutor-option-form').submit(function(e){
34 e.preventDefault();
35
36 var $form = $(this);
37 var data = $form.serialize();
38
39 $.ajax({
40 url : ajaxurl,
41 type : 'POST',
42 data : data,
43 beforeSend: function () {
44 $form.find('.button').addClass('tutor-updating-message');
45 },
46 success: function (data) {
47 if (data.success) {
48 //window.location.reload();
49 }
50 },
51 complete: function () {
52 $form.find('.button').removeClass('tutor-updating-message');
53 }
54 });
55 });
56
57 /**
58 * Withdraw nav tabs
59 * @since v.1.1.2
60 */
61 $(document).on('click', '.withdraw-method-nav li a', function(e){
62 e.preventDefault();
63 var tab_page_id = $(this).attr('data-target-id');
64 $('.withdraw-method-form-wrap').hide();
65 $('#'+tab_page_id).show();
66 });
67
68 /**
69 * End Withdraw nav tabs
70 */
71
72 /**
73 * Don't move it to anywhere?
74 */
75 function enable_sorting_topic_lesson(){
76 if (jQuery().sortable) {
77 $(".course-contents").sortable({
78 handle: ".course-move-handle",
79 start: function (e, ui) {
80 ui.placeholder.css('visibility', 'visible');
81 },
82 stop: function (e, ui) {
83 tutor_sorting_topics_and_lesson();
84 },
85 });
86 $(".tutor-lessons:not(.drop-lessons)").sortable({
87 connectWith: ".tutor-lessons",
88 items: "div.course-content-item",
89 start: function (e, ui) {
90 ui.placeholder.css('visibility', 'visible');
91 },
92 stop: function (e, ui) {
93 tutor_sorting_topics_and_lesson();
94 },
95 });
96 }
97 }
98 enable_sorting_topic_lesson();
99 function tutor_sorting_topics_and_lesson(){
100 var topics = {};
101 $('.tutor-topics-wrap').each(function(index, item){
102 var $topic = $(this);
103 var topics_id = parseInt($topic.attr('id').match(/\d+/)[0], 10);
104 var lessons = {};
105
106 $topic.find('.course-content-item').each(function(lessonIndex, lessonItem){
107 var $lesson = $(this);
108 var lesson_id = parseInt($lesson.attr('id').match(/\d+/)[0], 10);
109
110 lessons[lessonIndex] = lesson_id;
111 });
112 topics[index] = { 'topic_id' : topics_id, 'lesson_ids' : lessons };
113 });
114 $('#tutor_topics_lessons_sorting').val(JSON.stringify(topics));
115 }
116
117 /**
118 * Lesson Update or Create Modal
119 */
120 $(document).on( 'click', '.update_lesson_modal_btn', function( event ){
121 event.preventDefault();
122
123 var $that = $(this);
124 var content;
125 var inputid = 'tutor_lesson_modal_editor';
126 var editor = tinyMCE.get(inputid);
127 if (editor) {
128 content = editor.getContent();
129 } else {
130 content = $('#'+inputid).val();
131 }
132
133 var form_data = $(this).closest('form').serialize();
134 form_data += '&lesson_content='+encodeURIComponent(content);
135
136 $.ajax({
137 url : ajaxurl,
138 type : 'POST',
139 data : form_data,
140 beforeSend: function () {
141 $that.addClass('tutor-updating-message');
142 },
143 success: function (data) {
144 if (data.success){
145 $('#tutor-course-content-wrap').html(data.data.course_contents);
146 enable_sorting_topic_lesson();
147
148 //Close the modal
149 $('.tutor-lesson-modal-wrap').removeClass('show');
150 }
151 },
152 complete: function () {
153 $that.removeClass('tutor-updating-message');
154 }
155 });
156 });
157
158 /**
159 * Lesson Video
160 */
161 $(document).on('change', '.tutor_lesson_video_source', function(e){
162 var selector = $(this).val();
163 $('[class^="video_source_wrap"]').hide();
164 $('.video_source_wrap_'+selector).show();
165
166 if (selector === 'html5'){
167 $('.tutor-video-poster-field').show();
168 } else{
169 $('.tutor-video-poster-field').hide();
170 }
171 });
172
173 $(document).on( 'click', '.video_source_wrap_html5 .video_upload_btn', function( event ){
174 event.preventDefault();
175
176 var $that = $(this);
177 var frame;
178 // If the media frame already exists, reopen it.
179 if ( frame ) {
180 frame.open();
181 return;
182 }
183
184 // Create a new media frame
185 frame = wp.media({
186 title: 'Select or Upload Media Of Your Chosen Persuasion',
187 button: {
188 text: 'Use this media'
189 },
190 library: { type: 'video' },
191 multiple: false // Set to true to allow multiple files to be selected
192 });
193
194 // When an image is selected in the media frame...
195 frame.on( 'select', function() {
196 // Get media attachment details from the frame state
197 var attachment = frame.state().get('selection').first().toJSON();
198 $that.closest('.video_source_wrap_html5').find('span.video_media_id').text(attachment.id).closest('p').show();
199 $that.closest('.video_source_wrap_html5').find('input.input_source_video_id').val(attachment.id);
200 });
201 // Finally, open the modal on click
202 frame.open();
203 });
204
205 $(document).on('click', 'a.tutor-delete-attachment', function(e){
206 e.preventDefault();
207 $(this).closest('.tutor-added-attachment').remove();
208 });
209
210 $(document).on('click', '.tutorUploadAttachmentBtn', function(e){
211 e.preventDefault();
212
213 var $that = $(this);
214 var frame;
215 // If the media frame already exists, reopen it.
216 if ( frame ) {
217 frame.open();
218 return;
219 }
220 // Create a new media frame
221 frame = wp.media({
222 title: 'Select or Upload Media Of Your Chosen Persuasion',
223 button: {
224 text: 'Use this media'
225 },
226 multiple: true // Set to true to allow multiple files to be selected
227 });
228 // When an image is selected in the media frame...
229 frame.on( 'select', function() {
230 // Get media attachment details from the frame state
231 var attachments = frame.state().get('selection').toJSON();
232 if (attachments.length){
233 for (var i=0; i < attachments.length; i++){
234 var attachment = attachments[i];
235
236 var inputHtml = '<div class="tutor-added-attachment"><i class="tutor-icon-archive"></i> <a href="javascript:;" class="tutor-delete-attachment tutor-icon-line-cross"></a> <span> <a href="'+attachment.url+'">'+attachment.filename+'</a> </span><input type="hidden" name="tutor_attachments[]" value="'+attachment.id+'"></div>';
237 $that.closest('.tutor-lesson-attachments-metabox').find('.tutor-added-attachments-wrap').append(inputHtml);
238 }
239 }
240 });
241 // Finally, open the modal on click
242 frame.open();
243 });
244
245 /**
246 * Open Sidebar Menu
247 */
248 if (tutor_data.open_tutor_admin_menu){
249 var $adminMenu = $('#adminmenu');
250 $adminMenu.find('[href="admin.php?page=tutor"]').closest('li.wp-has-submenu').addClass('wp-has-current-submenu');
251 $adminMenu.find('[href="admin.php?page=tutor"]').closest('li.wp-has-submenu').find('a.wp-has-submenu').removeClass('wp-has-current-submenu').addClass('wp-has-current-submenu');
252 }
253
254 $(document).on('click', '.tutor-option-media-upload-btn', function(e){
255 e.preventDefault();
256
257 var $that = $(this);
258 var frame;
259 if ( frame ) {
260 frame.open();
261 return;
262 }
263 frame = wp.media({
264 title: 'Select or Upload Media Of Your Chosen Persuasion',
265 button: {
266 text: 'Use this media'
267 },
268 multiple: false
269 });
270 frame.on( 'select', function() {
271 var attachment = frame.state().get('selection').first().toJSON();
272 $that.closest('.option-media-wrap').find('.option-media-preview').html('<img src="'+attachment.url+'" alt="" />');
273 $that.closest('.option-media-wrap').find('input').val(attachment.id);
274 $that.closest('.option-media-wrap').find('.tutor-media-option-trash-btn').show();
275 });
276 frame.open();
277 });
278
279 /**
280 * Remove option media
281 * @since v.1.4.3
282 */
283 $(document).on('click', '.tutor-media-option-trash-btn', function(e){
284 e.preventDefault();
285
286 var $that = $(this);
287 $that.closest('.option-media-wrap').find('img').remove();
288 $that.closest('.option-media-wrap').find('input').val('');
289 $that.closest('.option-media-wrap').find('.tutor-media-option-trash-btn').hide();
290 });
291
292
293 $(document).on('change', '.tutor_addons_list_item', function(e) {
294 var $that = $(this);
295
296 var isEnable = $that.prop('checked') ? 1 : 0;
297 var addonFieldName = $that.attr('name');
298
299 $.ajax({
300 url : ajaxurl,
301 type : 'POST',
302 data : {isEnable:isEnable, addonFieldName:addonFieldName, action : 'addon_enable_disable'},
303 success: function (data) {
304 if (data.success){
305 //Success
306 }
307 }
308 });
309 });
310
311 /**
312 * Add instructor
313 * @since v.1.0.3
314 */
315 $(document).on('submit', '#new-instructor-form', function(e){
316 e.preventDefault();
317
318 var $that = $(this);
319 var formData = $that.serialize()+'&action=tutor_add_instructor';
320
321 $.ajax({
322 url : ajaxurl,
323 type : 'POST',
324 data : formData,
325 success: function (data) {
326 if (data.success){
327 $that.trigger("reset");
328 $('#form-response').html('<p class="tutor-status-approved-context">'+data.data.msg+'</p>');
329 }else{
330 var errorMsg = '';
331
332 var errors = data.data.errors;
333 if (errors && Object.keys(errors).length){
334 $.each(data.data.errors, function( index, value ) {
335 if (isObject(value)){
336 $.each(value, function( key, value1 ) {
337 errorMsg += '<p class="tutor-required-fields">'+value1[0]+'</p>';
338 });
339 } else{
340 errorMsg += '<p class="tutor-required-fields">'+value+'</p>';
341 }
342 });
343 $('#form-response').html(errorMsg);
344 }
345
346 }
347 }
348 });
349 });
350
351
352 /**
353 * Instructor block unblock action
354 * @since v.1.5.3
355 */
356
357 $(document).on('click', 'a.instructor-action', function(e){
358 e.preventDefault();
359
360 var $that = $(this);
361 var action = $that.attr('data-action');
362 var instructor_id = $that.attr('data-instructor-id');
363
364 var prompt_message = $that.attr('data-prompt-message');
365 if(prompt_message && !confirm(prompt_message)){
366 // Avoid Accidental CLick
367 return;
368 }
369
370 var nonce_key = tutor_data.nonce_key;
371 var json_data = { instructor_id : instructor_id, action_name : action, action: 'instructor_approval_action'};
372 json_data[nonce_key] = tutor_data[nonce_key];
373
374 $.ajax({
375 url : ajaxurl,
376 type : 'POST',
377 data : json_data,
378 beforeSend: function () {
379 $that.addClass('tutor-updating-message');
380 },
381 success: function (data) {
382 location.reload(true);
383 },
384 complete: function () {
385 $that.removeClass('tutor-updating-message');
386 }
387 });
388 });
389
390 function isObject (value) {
391 return value && typeof value === 'object' && value.constructor === Object;
392 }
393
394 /**
395 * Tutor Assignments JS
396 * @since v.1.3.3
397 */
398 $(document).on('click', '.tutor-create-assignments-btn', function(e){
399 e.preventDefault();
400
401 var $that = $(this);
402 var topic_id = $(this).attr('data-topic-id');
403 var course_id = $('#post_ID').val();
404
405 $.ajax({
406 url : ajaxurl,
407 type : 'POST',
408 data : {topic_id : topic_id, course_id : course_id, action: 'tutor_load_assignments_builder_modal'},
409 beforeSend: function () {
410 $that.addClass('tutor-updating-message');
411 },
412 success: function (data) {
413 $('.tutor-lesson-modal-wrap .modal-container').html(data.data.output);
414 $('.tutor-lesson-modal-wrap').attr('data-topic-id', topic_id).addClass('show');
415
416 $(document).trigger('assignment_modal_loaded', {topic_id : topic_id, course_id : course_id});
417
418 tinymce.init(tinyMCEPreInit.mceInit.tutor_editor_config);
419 tinymce.execCommand( 'mceRemoveEditor', false, 'tutor_assignments_modal_editor' );
420 tinyMCE.execCommand('mceAddEditor', false, "tutor_assignments_modal_editor");
421 },
422 complete: function () {
423 quicktags({id : "tutor_assignments_modal_editor"});
424 $that.removeClass('tutor-updating-message');
425 }
426 });
427 });
428
429 $(document).on('click', '.open-tutor-assignment-modal', function(e){
430 e.preventDefault();
431
432 var $that = $(this);
433 var assignment_id = $that.attr('data-assignment-id');
434 var topic_id = $that.attr('data-topic-id');
435 var course_id = $('#post_ID').val();
436
437 $.ajax({
438 url : ajaxurl,
439 type : 'POST',
440 data : {assignment_id : assignment_id, topic_id : topic_id, course_id : course_id, action: 'tutor_load_assignments_builder_modal'},
441 beforeSend: function () {
442 $that.addClass('tutor-updating-message');
443 },
444 success: function (data) {
445 $('.tutor-lesson-modal-wrap .modal-container').html(data.data.output);
446 $('.tutor-lesson-modal-wrap').attr({'data-assignment-id' : assignment_id, 'data-topic-id':topic_id}).addClass('show');
447
448 $(document).trigger('assignment_modal_loaded', {assignment_id : assignment_id, topic_id : topic_id, course_id : course_id});
449
450 tinymce.init(tinyMCEPreInit.mceInit.tutor_editor_config);
451 tinymce.execCommand( 'mceRemoveEditor', false, 'tutor_assignments_modal_editor' );
452 tinyMCE.execCommand('mceAddEditor', false, "tutor_assignments_modal_editor");
453 },
454 complete: function () {
455 quicktags({id : "tutor_assignments_modal_editor"});
456 $that.removeClass('tutor-updating-message');
457 }
458 });
459 });
460
461 /**
462 * Update Assignment Data
463 */
464 $(document).on( 'click', '.update_assignment_modal_btn', function( event ){
465 event.preventDefault();
466
467 var $that = $(this);
468 var content;
469 var inputid = 'tutor_assignments_modal_editor';
470 var editor = tinyMCE.get(inputid);
471 if (editor) {
472 content = editor.getContent();
473 } else {
474 content = $('#'+inputid).val();
475 }
476
477 var form_data = $(this).closest('form').serializeArray();
478
479 var data = {};
480 /**
481 * pushing data in data obj
482 */
483 for(let d of form_data){
484 data[d.name] = d.value
485 }
486 data.assignment_content = content;
487
488 $.ajax({
489 url : ajaxurl,
490 type : 'POST',
491 data : data,
492 beforeSend: function () {
493 $that.addClass('tutor-updating-message');
494 },
495 success: function (data) {
496 if (data.success){
497 $('#tutor-course-content-wrap').html(data.data.course_contents);
498 enable_sorting_topic_lesson();
499
500 //Close the modal
501 $('.tutor-lesson-modal-wrap').removeClass('show');
502 }
503 },
504 complete: function () {
505 $that.removeClass('tutor-updating-message');
506 }
507 });
508 });
509
510 /**
511 * Add Assignment
512 */
513 $(document).on( 'click', '.add-assignment-attachments', function( event ){
514 event.preventDefault();
515
516 var $that = $(this);
517 var frame;
518 // If the media frame already exists, reopen it.
519 if ( frame ) {
520 frame.open();
521 return;
522 }
523
524 // Create a new media frame
525 frame = wp.media({
526 title: 'Select or Upload Media Of Your Chosen Persuasion',
527 button: {
528 text: 'Use this media'
529 },
530 multiple: false // Set to true to allow multiple files to be selected
531 });
532
533 // When an image is selected in the media frame...
534 frame.on( 'select', function() {
535 // Get media attachment details from the frame state
536 var attachment = frame.state().get('selection').first().toJSON();
537
538 var field_markup = '<div class="tutor-individual-attachment-file"><p class="attachment-file-name">'+attachment.filename+'</p><input type="hidden" name="tutor_assignment_attachments[]" value="'+attachment.id+'"><a href="javascript:;" class="remove-assignment-attachment-a text-muted"> &times; Remove</a></div>';
539
540 $('#assignment-attached-file').append(field_markup);
541 $that.closest('.video_source_wrap_html5').find('input').val(attachment.id);
542 });
543 // Finally, open the modal on click
544 frame.open();
545 });
546
547 $(document).on( 'click', '.remove-assignment-attachment-a', function( event ){
548 event.preventDefault();
549 $(this).closest('.tutor-individual-attachment-file').remove();
550 });
551
552 /**
553 * Used for backend profile photo upload.
554 */
555
556 //tutor_video_poster_upload_btn
557 $(document).on( 'click', '.tutor_video_poster_upload_btn', function( event ){
558 event.preventDefault();
559
560 var $that = $(this);
561 var frame;
562 // If the media frame already exists, reopen it.
563 if ( frame ) {
564 frame.open();
565 return;
566 }
567
568 // Create a new media frame
569 frame = wp.media({
570 title: 'Select or Upload Media Of Your Chosen Persuasion',
571 button: {
572 text: 'Use this media'
573 },
574 multiple: false // Set to true to allow multiple files to be selected
575 });
576
577 // When an image is selected in the media frame...
578 frame.on( 'select', function() {
579 // Get media attachment details from the frame state
580 var attachment = frame.state().get('selection').first().toJSON();
581 $that.closest('.tutor-video-poster-wrap').find('.video-poster-img').html('<img src="'+attachment.url+'" alt="" />');
582 $that.closest('.tutor-video-poster-wrap').find('input').val(attachment.id);
583 });
584 // Finally, open the modal on click
585 frame.open();
586 });
587
588
589 /**
590 * Tutor Memberships toggle in Paid Membership Pro panel
591 * @since v.1.3.6
592 */
593
594 $(document).on( 'change', '#tutor_pmpro_membership_model_select', function( e ){
595 e.preventDefault();
596
597 var $that = $(this);
598
599 if ($that.val() === 'category_wise_membership'){
600 $('.membership_course_categories').show();
601 } else{
602 $('.membership_course_categories').hide();
603 }
604 });
605
606 $(document).on( 'change', '#tutor_pmpro_membership_model_select', function( e ){
607 e.preventDefault();
608
609 var $that = $(this);
610
611 if ($that.val() === 'category_wise_membership'){
612 $('.membership_course_categories').show();
613 } else{
614 $('.membership_course_categories').hide();
615 }
616 });
617
618 /**
619 * Find user/student from select2
620 * @since v.1.4.0
621 */
622
623 $('#select2_search_user_ajax').select2({
624 allowClear: true,
625 placeholder: "Search students",
626 minimumInputLength: '1',
627 escapeMarkup: function( m ) {
628 return m;
629 },
630 ajax: {
631 url : ajaxurl,
632 type : 'POST',
633 dataType: 'json',
634 delay: 1000,
635 data: function( params ) {
636 return {
637 term: params.term,
638 action: 'tutor_json_search_students'
639 };
640 },
641 processResults: function( data ) {
642 var terms = [];
643 if ( data ) {
644 $.each( data, function( id, text ) {
645 terms.push({
646 id: id,
647 text: text
648 });
649 });
650 }
651 return {
652 results: terms
653 };
654
655 },
656 cache: true
657 }
658 });
659
660 /**
661 * Confirm Alert for deleting enrollments data
662 *
663 * @since v.1.4.0
664 */
665 $(document).on( 'click', 'table.enrolments .delete a', function( e ){
666 if (! confirm(tutor_data.delete_confirm_text)) {
667 e.preventDefault();
668 }
669 });
670
671
672 /**
673 * Show hide is course public checkbox (backend dashboard editor)
674 *
675 * @since v.1.7.2
676 */
677 var price_type = $('#tutor-attach-product [name="tutor_course_price_type"]');
678 if(price_type.length==0){
679 $('#_tutor_is_course_public_meta_checkbox').show();
680 }
681 else{
682 price_type.change(function(){
683 if($(this).prop('checked')){
684 var method = $(this).val()=='paid' ? 'hide' : 'show';
685 $('#_tutor_is_course_public_meta_checkbox')[method]();
686 }
687 }).trigger('change');
688 }
689
690
691 /**
692 * Focus selected instructor layout in setting page
693 *
694 * @since v.1.7.5
695 */
696 $(document).on('click', '.instructor-layout-template', function(){
697 $('.instructor-layout-template').removeClass('selected-template');
698 $(this).addClass('selected-template');
699 });
700 });
701