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.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 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.js 6 years ago
tutor-admin.js
626 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='+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 multiple: false // Set to true to allow multiple files to be selected
191 });
192
193 // When an image is selected in the media frame...
194 frame.on( 'select', function() {
195 // Get media attachment details from the frame state
196 var attachment = frame.state().get('selection').first().toJSON();
197 $that.closest('.video_source_wrap_html5').find('span.video_media_id').text(attachment.id).closest('p').show();
198 $that.closest('.video_source_wrap_html5').find('input.input_source_video_id').val(attachment.id);
199 });
200 // Finally, open the modal on click
201 frame.open();
202 });
203
204 $(document).on('click', 'a.tutor-delete-attachment', function(e){
205 e.preventDefault();
206 $(this).closest('.tutor-added-attachment').remove();
207 });
208
209 $(document).on('click', '.tutorUploadAttachmentBtn', function(e){
210 e.preventDefault();
211
212 var $that = $(this);
213 var frame;
214 // If the media frame already exists, reopen it.
215 if ( frame ) {
216 frame.open();
217 return;
218 }
219 // Create a new media frame
220 frame = wp.media({
221 title: 'Select or Upload Media Of Your Chosen Persuasion',
222 button: {
223 text: 'Use this media'
224 },
225 multiple: true // Set to true to allow multiple files to be selected
226 });
227 // When an image is selected in the media frame...
228 frame.on( 'select', function() {
229 // Get media attachment details from the frame state
230 var attachments = frame.state().get('selection').toJSON();
231 if (attachments.length){
232 for (var i=0; i < attachments.length; i++){
233 var attachment = attachments[i];
234
235 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>';
236 $that.closest('.tutor-lesson-attachments-metabox').find('.tutor-added-attachments-wrap').append(inputHtml);
237 }
238 }
239 });
240 // Finally, open the modal on click
241 frame.open();
242 });
243
244 /**
245 * Open Sidebar Menu
246 */
247 if (tutor_data.open_tutor_admin_menu){
248 var $adminMenu = $('#adminmenu');
249 $adminMenu.find('[href="admin.php?page=tutor"]').closest('li.wp-has-submenu').addClass('wp-has-current-submenu');
250 $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');
251 }
252
253 $(document).on('click', '.tutor-option-media-upload-btn', function(e){
254 e.preventDefault();
255
256 var $that = $(this);
257 var frame;
258 if ( frame ) {
259 frame.open();
260 return;
261 }
262 frame = wp.media({
263 title: 'Select or Upload Media Of Your Chosen Persuasion',
264 button: {
265 text: 'Use this media'
266 },
267 multiple: false
268 });
269 frame.on( 'select', function() {
270 var attachment = frame.state().get('selection').first().toJSON();
271 $that.closest('.option-media-wrap').find('.option-media-preview').html('<img src="'+attachment.url+'" alt="" />');
272 $that.closest('.option-media-wrap').find('input').val(attachment.id);
273 $that.closest('.option-media-wrap').find('.tutor-media-option-trash-btn').show();
274 });
275 frame.open();
276 });
277
278 /**
279 * Remove option media
280 * @since v.1.4.3
281 */
282 $(document).on('click', '.tutor-media-option-trash-btn', function(e){
283 e.preventDefault();
284
285 var $that = $(this);
286 $that.closest('.option-media-wrap').find('img').remove();
287 $that.closest('.option-media-wrap').find('input').val('');
288 $that.closest('.option-media-wrap').find('.tutor-media-option-trash-btn').hide();
289 });
290
291
292 $(document).on('change', '.tutor_addons_list_item', function(e) {
293 var $that = $(this);
294
295 var isEnable = $that.prop('checked') ? 1 : 0;
296 var addonFieldName = $that.attr('name');
297
298 $.ajax({
299 url : ajaxurl,
300 type : 'POST',
301 data : {isEnable:isEnable, addonFieldName:addonFieldName, action : 'addon_enable_disable'},
302 success: function (data) {
303 if (data.success){
304 //Success
305 }
306 }
307 });
308 });
309
310 /**
311 * Add instructor
312 * @since v.1.0.3
313 */
314 $(document).on('submit', '#new-instructor-form', function(e){
315 e.preventDefault();
316
317 var $that = $(this);
318 var formData = $that.serialize()+'&action=tutor_add_instructor';
319
320 $.ajax({
321 url : ajaxurl,
322 type : 'POST',
323 data : formData,
324 success: function (data) {
325 if (data.success){
326 $that.trigger("reset");
327 $('#form-response').html('<p class="tutor-status-approved-context">'+data.data.msg+'</p>');
328 }else{
329 var errorMsg = '';
330
331 var errors = data.data.errors;
332 if (errors && Object.keys(errors).length){
333 $.each(data.data.errors, function( index, value ) {
334 if (isObject(value)){
335
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 function isObject (value) {
352 return value && typeof value === 'object' && value.constructor === Object;
353 }
354
355
356 /**
357 * Tutor Assignments JS
358 * @since v.1.3.3
359 */
360 $(document).on('click', '.tutor-create-assignments-btn', function(e){
361 e.preventDefault();
362
363 var $that = $(this);
364 var topic_id = $(this).attr('data-topic-id');
365 var course_id = $('#post_ID').val();
366
367 $.ajax({
368 url : ajaxurl,
369 type : 'POST',
370 data : {topic_id : topic_id, course_id : course_id, action: 'tutor_load_assignments_builder_modal'},
371 beforeSend: function () {
372 $that.addClass('tutor-updating-message');
373 },
374 success: function (data) {
375 $('.tutor-lesson-modal-wrap .modal-container').html(data.data.output);
376 $('.tutor-lesson-modal-wrap').attr('data-topic-id', topic_id).addClass('show');
377
378 $(document).trigger('assignment_modal_loaded', {topic_id : topic_id, course_id : course_id});
379
380 tinymce.init(tinyMCEPreInit.mceInit.tutor_editor_config);
381 tinymce.execCommand( 'mceRemoveEditor', false, 'tutor_assignments_modal_editor' );
382 tinyMCE.execCommand('mceAddEditor', false, "tutor_assignments_modal_editor");
383 },
384 complete: function () {
385 quicktags({id : "tutor_assignments_modal_editor"});
386 $that.removeClass('tutor-updating-message');
387 }
388 });
389 });
390
391 $(document).on('click', '.open-tutor-assignment-modal', function(e){
392 e.preventDefault();
393
394 var $that = $(this);
395 var assignment_id = $that.attr('data-assignment-id');
396 var topic_id = $that.attr('data-topic-id');
397 var course_id = $('#post_ID').val();
398
399 $.ajax({
400 url : ajaxurl,
401 type : 'POST',
402 data : {assignment_id : assignment_id, 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-assignment-id' : assignment_id, 'data-topic-id':topic_id}).addClass('show');
409
410 $(document).trigger('assignment_modal_loaded', {assignment_id : assignment_id, 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 /**
424 * Update Assignment Data
425 */
426 $(document).on( 'click', '.update_assignment_modal_btn', function( event ){
427 event.preventDefault();
428
429 var $that = $(this);
430 var content;
431 var inputid = 'tutor_assignments_modal_editor';
432 var editor = tinyMCE.get(inputid);
433 if (editor) {
434 content = editor.getContent();
435 } else {
436 content = $('#'+inputid).val();
437 }
438
439 var form_data = $(this).closest('form').serialize();
440 form_data += '&assignment_content='+content;
441
442 $.ajax({
443 url : ajaxurl,
444 type : 'POST',
445 data : form_data,
446 beforeSend: function () {
447 $that.addClass('tutor-updating-message');
448 },
449 success: function (data) {
450 if (data.success){
451 $('#tutor-course-content-wrap').html(data.data.course_contents);
452 enable_sorting_topic_lesson();
453
454 //Close the modal
455 $('.tutor-lesson-modal-wrap').removeClass('show');
456 }
457 },
458 complete: function () {
459 $that.removeClass('tutor-updating-message');
460 }
461 });
462 });
463
464 /**
465 * Add Assignment
466 */
467 $(document).on( 'click', '.add-assignment-attachments', function( event ){
468 event.preventDefault();
469
470 var $that = $(this);
471 var frame;
472 // If the media frame already exists, reopen it.
473 if ( frame ) {
474 frame.open();
475 return;
476 }
477
478 // Create a new media frame
479 frame = wp.media({
480 title: 'Select or Upload Media Of Your Chosen Persuasion',
481 button: {
482 text: 'Use this media'
483 },
484 multiple: false // Set to true to allow multiple files to be selected
485 });
486
487 // When an image is selected in the media frame...
488 frame.on( 'select', function() {
489 // Get media attachment details from the frame state
490 var attachment = frame.state().get('selection').first().toJSON();
491
492 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>';
493
494 $('#assignment-attached-file').append(field_markup);
495 $that.closest('.video_source_wrap_html5').find('input').val(attachment.id);
496 });
497 // Finally, open the modal on click
498 frame.open();
499 });
500
501 $(document).on( 'click', '.remove-assignment-attachment-a', function( event ){
502 event.preventDefault();
503 $(this).closest('.tutor-individual-attachment-file').remove();
504 });
505
506 /**
507 * Used for backend profile photo upload.
508 */
509
510 //tutor_video_poster_upload_btn
511 $(document).on( 'click', '.tutor_video_poster_upload_btn', function( event ){
512 event.preventDefault();
513
514 var $that = $(this);
515 var frame;
516 // If the media frame already exists, reopen it.
517 if ( frame ) {
518 frame.open();
519 return;
520 }
521
522 // Create a new media frame
523 frame = wp.media({
524 title: 'Select or Upload Media Of Your Chosen Persuasion',
525 button: {
526 text: 'Use this media'
527 },
528 multiple: false // Set to true to allow multiple files to be selected
529 });
530
531 // When an image is selected in the media frame...
532 frame.on( 'select', function() {
533 // Get media attachment details from the frame state
534 var attachment = frame.state().get('selection').first().toJSON();
535 $that.closest('.tutor-video-poster-wrap').find('.video-poster-img').html('<img src="'+attachment.url+'" alt="" />');
536 $that.closest('.tutor-video-poster-wrap').find('input').val(attachment.id);
537 });
538 // Finally, open the modal on click
539 frame.open();
540 });
541
542
543 /**
544 * Tutor Memberships toggle in Paid Membership Pro panel
545 * @since v.1.3.6
546 */
547
548 $(document).on( 'change', '#tutor_pmpro_membership_model_select', function( e ){
549 e.preventDefault();
550
551 var $that = $(this);
552
553 if ($that.val() === 'category_wise_membership'){
554 $('.membership_course_categories').show();
555 } else{
556 $('.membership_course_categories').hide();
557 }
558 });
559
560 $(document).on( 'change', '#tutor_pmpro_membership_model_select', function( e ){
561 e.preventDefault();
562
563 var $that = $(this);
564
565 if ($that.val() === 'category_wise_membership'){
566 $('.membership_course_categories').show();
567 } else{
568 $('.membership_course_categories').hide();
569 }
570 });
571
572 /**
573 * Find user/student from select2
574 * @since v.1.4.0
575 */
576
577 $('#select2_search_user_ajax').select2({
578 allowClear: true,
579 placeholder: "Search students",
580 minimumInputLength: '1',
581 escapeMarkup: function( m ) {
582 return m;
583 },
584 ajax: {
585 url : ajaxurl,
586 type : 'POST',
587 dataType: 'json',
588 delay: 1000,
589 data: function( params ) {
590 return {
591 term: params.term,
592 action: 'tutor_json_search_students'
593 };
594 },
595 processResults: function( data ) {
596 var terms = [];
597 if ( data ) {
598 $.each( data, function( id, text ) {
599 terms.push({
600 id: id,
601 text: text
602 });
603 });
604 }
605 return {
606 results: terms
607 };
608
609 },
610 cache: true
611 }
612 });
613
614 /**
615 * Confirm Alert for deleting enrollments data
616 *
617 * @since v.1.4.0
618 */
619 $(document).on( 'click', 'table.enrolments .delete a', function( e ){
620 if (! confirm(tutor_data.delete_confirm_text)) {
621 e.preventDefault();
622 }
623 });
624
625 });
626