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.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 6 years ago gutenberg_blocks.js 6 years ago mce-button.js 6 years ago tutor-admin.js 6 years ago tutor-front.js 6 years ago tutor-setup.js 6 years ago tutor.js 6 years ago
tutor-admin.js
658 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 nonce_key = tutor_data.nonce_key;
365 var json_data = { instructor_id : instructor_id, action_name : action, action: 'instructor_approval_action'};
366 json_data[nonce_key] = tutor_data[nonce_key];
367
368 $.ajax({
369 url : ajaxurl,
370 type : 'POST',
371 data : json_data,
372 beforeSend: function () {
373 $that.addClass('tutor-updating-message');
374 },
375 success: function (data) {
376 location.reload(true);
377 },
378 complete: function () {
379 $that.removeClass('tutor-updating-message');
380 }
381 });
382 });
383
384 function isObject (value) {
385 return value && typeof value === 'object' && value.constructor === Object;
386 }
387
388 /**
389 * Tutor Assignments JS
390 * @since v.1.3.3
391 */
392 $(document).on('click', '.tutor-create-assignments-btn', function(e){
393 e.preventDefault();
394
395 var $that = $(this);
396 var topic_id = $(this).attr('data-topic-id');
397 var course_id = $('#post_ID').val();
398
399 $.ajax({
400 url : ajaxurl,
401 type : 'POST',
402 data : {topic_id : topic_id, course_id : course_id, action: 'tutor_load_assignments_builder_modal'},
403 beforeSend: function () {
404 $that.addClass('tutor-updating-message');
405 },
406 success: function (data) {
407 $('.tutor-lesson-modal-wrap .modal-container').html(data.data.output);
408 $('.tutor-lesson-modal-wrap').attr('data-topic-id', topic_id).addClass('show');
409
410 $(document).trigger('assignment_modal_loaded', {topic_id : topic_id, course_id : course_id});
411
412 tinymce.init(tinyMCEPreInit.mceInit.tutor_editor_config);
413 tinymce.execCommand( 'mceRemoveEditor', false, 'tutor_assignments_modal_editor' );
414 tinyMCE.execCommand('mceAddEditor', false, "tutor_assignments_modal_editor");
415 },
416 complete: function () {
417 quicktags({id : "tutor_assignments_modal_editor"});
418 $that.removeClass('tutor-updating-message');
419 }
420 });
421 });
422
423 $(document).on('click', '.open-tutor-assignment-modal', function(e){
424 e.preventDefault();
425
426 var $that = $(this);
427 var assignment_id = $that.attr('data-assignment-id');
428 var topic_id = $that.attr('data-topic-id');
429 var course_id = $('#post_ID').val();
430
431 $.ajax({
432 url : ajaxurl,
433 type : 'POST',
434 data : {assignment_id : assignment_id, topic_id : topic_id, course_id : course_id, action: 'tutor_load_assignments_builder_modal'},
435 beforeSend: function () {
436 $that.addClass('tutor-updating-message');
437 },
438 success: function (data) {
439 $('.tutor-lesson-modal-wrap .modal-container').html(data.data.output);
440 $('.tutor-lesson-modal-wrap').attr({'data-assignment-id' : assignment_id, 'data-topic-id':topic_id}).addClass('show');
441
442 $(document).trigger('assignment_modal_loaded', {assignment_id : assignment_id, topic_id : topic_id, course_id : course_id});
443
444 tinymce.init(tinyMCEPreInit.mceInit.tutor_editor_config);
445 tinymce.execCommand( 'mceRemoveEditor', false, 'tutor_assignments_modal_editor' );
446 tinyMCE.execCommand('mceAddEditor', false, "tutor_assignments_modal_editor");
447 },
448 complete: function () {
449 quicktags({id : "tutor_assignments_modal_editor"});
450 $that.removeClass('tutor-updating-message');
451 }
452 });
453 });
454
455 /**
456 * Update Assignment Data
457 */
458 $(document).on( 'click', '.update_assignment_modal_btn', function( event ){
459 event.preventDefault();
460
461 var $that = $(this);
462 var content;
463 var inputid = 'tutor_assignments_modal_editor';
464 var editor = tinyMCE.get(inputid);
465 if (editor) {
466 content = editor.getContent();
467 } else {
468 content = $('#'+inputid).val();
469 }
470
471 var form_data = $(this).closest('form').serialize();
472 form_data += '&assignment_content='+content;
473
474 $.ajax({
475 url : ajaxurl,
476 type : 'POST',
477 data : form_data,
478 beforeSend: function () {
479 $that.addClass('tutor-updating-message');
480 },
481 success: function (data) {
482 if (data.success){
483 $('#tutor-course-content-wrap').html(data.data.course_contents);
484 enable_sorting_topic_lesson();
485
486 //Close the modal
487 $('.tutor-lesson-modal-wrap').removeClass('show');
488 }
489 },
490 complete: function () {
491 $that.removeClass('tutor-updating-message');
492 }
493 });
494 });
495
496 /**
497 * Add Assignment
498 */
499 $(document).on( 'click', '.add-assignment-attachments', function( event ){
500 event.preventDefault();
501
502 var $that = $(this);
503 var frame;
504 // If the media frame already exists, reopen it.
505 if ( frame ) {
506 frame.open();
507 return;
508 }
509
510 // Create a new media frame
511 frame = wp.media({
512 title: 'Select or Upload Media Of Your Chosen Persuasion',
513 button: {
514 text: 'Use this media'
515 },
516 multiple: false // Set to true to allow multiple files to be selected
517 });
518
519 // When an image is selected in the media frame...
520 frame.on( 'select', function() {
521 // Get media attachment details from the frame state
522 var attachment = frame.state().get('selection').first().toJSON();
523
524 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>';
525
526 $('#assignment-attached-file').append(field_markup);
527 $that.closest('.video_source_wrap_html5').find('input').val(attachment.id);
528 });
529 // Finally, open the modal on click
530 frame.open();
531 });
532
533 $(document).on( 'click', '.remove-assignment-attachment-a', function( event ){
534 event.preventDefault();
535 $(this).closest('.tutor-individual-attachment-file').remove();
536 });
537
538 /**
539 * Used for backend profile photo upload.
540 */
541
542 //tutor_video_poster_upload_btn
543 $(document).on( 'click', '.tutor_video_poster_upload_btn', function( event ){
544 event.preventDefault();
545
546 var $that = $(this);
547 var frame;
548 // If the media frame already exists, reopen it.
549 if ( frame ) {
550 frame.open();
551 return;
552 }
553
554 // Create a new media frame
555 frame = wp.media({
556 title: 'Select or Upload Media Of Your Chosen Persuasion',
557 button: {
558 text: 'Use this media'
559 },
560 multiple: false // Set to true to allow multiple files to be selected
561 });
562
563 // When an image is selected in the media frame...
564 frame.on( 'select', function() {
565 // Get media attachment details from the frame state
566 var attachment = frame.state().get('selection').first().toJSON();
567 $that.closest('.tutor-video-poster-wrap').find('.video-poster-img').html('<img src="'+attachment.url+'" alt="" />');
568 $that.closest('.tutor-video-poster-wrap').find('input').val(attachment.id);
569 });
570 // Finally, open the modal on click
571 frame.open();
572 });
573
574
575 /**
576 * Tutor Memberships toggle in Paid Membership Pro panel
577 * @since v.1.3.6
578 */
579
580 $(document).on( 'change', '#tutor_pmpro_membership_model_select', function( e ){
581 e.preventDefault();
582
583 var $that = $(this);
584
585 if ($that.val() === 'category_wise_membership'){
586 $('.membership_course_categories').show();
587 } else{
588 $('.membership_course_categories').hide();
589 }
590 });
591
592 $(document).on( 'change', '#tutor_pmpro_membership_model_select', function( e ){
593 e.preventDefault();
594
595 var $that = $(this);
596
597 if ($that.val() === 'category_wise_membership'){
598 $('.membership_course_categories').show();
599 } else{
600 $('.membership_course_categories').hide();
601 }
602 });
603
604 /**
605 * Find user/student from select2
606 * @since v.1.4.0
607 */
608
609 $('#select2_search_user_ajax').select2({
610 allowClear: true,
611 placeholder: "Search students",
612 minimumInputLength: '1',
613 escapeMarkup: function( m ) {
614 return m;
615 },
616 ajax: {
617 url : ajaxurl,
618 type : 'POST',
619 dataType: 'json',
620 delay: 1000,
621 data: function( params ) {
622 return {
623 term: params.term,
624 action: 'tutor_json_search_students'
625 };
626 },
627 processResults: function( data ) {
628 var terms = [];
629 if ( data ) {
630 $.each( data, function( id, text ) {
631 terms.push({
632 id: id,
633 text: text
634 });
635 });
636 }
637 return {
638 results: terms
639 };
640
641 },
642 cache: true
643 }
644 });
645
646 /**
647 * Confirm Alert for deleting enrollments data
648 *
649 * @since v.1.4.0
650 */
651 $(document).on( 'click', 'table.enrolments .delete a', function( e ){
652 if (! confirm(tutor_data.delete_confirm_text)) {
653 e.preventDefault();
654 }
655 });
656
657 });
658