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.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
693 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').serialize();
478 form_data += '&assignment_content='+content;
479
480 $.ajax({
481 url : ajaxurl,
482 type : 'POST',
483 data : form_data,
484 beforeSend: function () {
485 $that.addClass('tutor-updating-message');
486 },
487 success: function (data) {
488 if (data.success){
489 $('#tutor-course-content-wrap').html(data.data.course_contents);
490 enable_sorting_topic_lesson();
491
492 //Close the modal
493 $('.tutor-lesson-modal-wrap').removeClass('show');
494 }
495 },
496 complete: function () {
497 $that.removeClass('tutor-updating-message');
498 }
499 });
500 });
501
502 /**
503 * Add Assignment
504 */
505 $(document).on( 'click', '.add-assignment-attachments', function( event ){
506 event.preventDefault();
507
508 var $that = $(this);
509 var frame;
510 // If the media frame already exists, reopen it.
511 if ( frame ) {
512 frame.open();
513 return;
514 }
515
516 // Create a new media frame
517 frame = wp.media({
518 title: 'Select or Upload Media Of Your Chosen Persuasion',
519 button: {
520 text: 'Use this media'
521 },
522 multiple: false // Set to true to allow multiple files to be selected
523 });
524
525 // When an image is selected in the media frame...
526 frame.on( 'select', function() {
527 // Get media attachment details from the frame state
528 var attachment = frame.state().get('selection').first().toJSON();
529
530 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>';
531
532 $('#assignment-attached-file').append(field_markup);
533 $that.closest('.video_source_wrap_html5').find('input').val(attachment.id);
534 });
535 // Finally, open the modal on click
536 frame.open();
537 });
538
539 $(document).on( 'click', '.remove-assignment-attachment-a', function( event ){
540 event.preventDefault();
541 $(this).closest('.tutor-individual-attachment-file').remove();
542 });
543
544 /**
545 * Used for backend profile photo upload.
546 */
547
548 //tutor_video_poster_upload_btn
549 $(document).on( 'click', '.tutor_video_poster_upload_btn', function( event ){
550 event.preventDefault();
551
552 var $that = $(this);
553 var frame;
554 // If the media frame already exists, reopen it.
555 if ( frame ) {
556 frame.open();
557 return;
558 }
559
560 // Create a new media frame
561 frame = wp.media({
562 title: 'Select or Upload Media Of Your Chosen Persuasion',
563 button: {
564 text: 'Use this media'
565 },
566 multiple: false // Set to true to allow multiple files to be selected
567 });
568
569 // When an image is selected in the media frame...
570 frame.on( 'select', function() {
571 // Get media attachment details from the frame state
572 var attachment = frame.state().get('selection').first().toJSON();
573 $that.closest('.tutor-video-poster-wrap').find('.video-poster-img').html('<img src="'+attachment.url+'" alt="" />');
574 $that.closest('.tutor-video-poster-wrap').find('input').val(attachment.id);
575 });
576 // Finally, open the modal on click
577 frame.open();
578 });
579
580
581 /**
582 * Tutor Memberships toggle in Paid Membership Pro panel
583 * @since v.1.3.6
584 */
585
586 $(document).on( 'change', '#tutor_pmpro_membership_model_select', function( e ){
587 e.preventDefault();
588
589 var $that = $(this);
590
591 if ($that.val() === 'category_wise_membership'){
592 $('.membership_course_categories').show();
593 } else{
594 $('.membership_course_categories').hide();
595 }
596 });
597
598 $(document).on( 'change', '#tutor_pmpro_membership_model_select', function( e ){
599 e.preventDefault();
600
601 var $that = $(this);
602
603 if ($that.val() === 'category_wise_membership'){
604 $('.membership_course_categories').show();
605 } else{
606 $('.membership_course_categories').hide();
607 }
608 });
609
610 /**
611 * Find user/student from select2
612 * @since v.1.4.0
613 */
614
615 $('#select2_search_user_ajax').select2({
616 allowClear: true,
617 placeholder: "Search students",
618 minimumInputLength: '1',
619 escapeMarkup: function( m ) {
620 return m;
621 },
622 ajax: {
623 url : ajaxurl,
624 type : 'POST',
625 dataType: 'json',
626 delay: 1000,
627 data: function( params ) {
628 return {
629 term: params.term,
630 action: 'tutor_json_search_students'
631 };
632 },
633 processResults: function( data ) {
634 var terms = [];
635 if ( data ) {
636 $.each( data, function( id, text ) {
637 terms.push({
638 id: id,
639 text: text
640 });
641 });
642 }
643 return {
644 results: terms
645 };
646
647 },
648 cache: true
649 }
650 });
651
652 /**
653 * Confirm Alert for deleting enrollments data
654 *
655 * @since v.1.4.0
656 */
657 $(document).on( 'click', 'table.enrolments .delete a', function( e ){
658 if (! confirm(tutor_data.delete_confirm_text)) {
659 e.preventDefault();
660 }
661 });
662
663
664 /**
665 * Show hide is course public checkbox (backend dashboard editor)
666 *
667 * @since v.1.7.2
668 */
669 var price_type = $('#tutor-attach-product [name="tutor_course_price_type"]');
670 if(price_type.length==0){
671 $('#_tutor_is_course_public_meta_checkbox').show();
672 }
673 else{
674 price_type.change(function(){
675 if($(this).prop('checked')){
676 var method = $(this).val()=='paid' ? 'hide' : 'show';
677 $('#_tutor_is_course_public_meta_checkbox')[method]();
678 }
679 }).trigger('change');
680 }
681
682
683 /**
684 * Focus selected instructor layout in setting page
685 *
686 * @since v.1.7.5
687 */
688 $(document).on('click', '.instructor-layout-template', function(){
689 $('.instructor-layout-template').removeClass('selected-template');
690 $(this).addClass('selected-template');
691 });
692 });
693