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-front.js
2201 lines
| 1 | jQuery(document).ready(function($){ |
| 2 | 'use strict'; |
| 3 | |
| 4 | /** |
| 5 | * Initiate Select2 |
| 6 | * @since v.1.3.4 |
| 7 | */ |
| 8 | if (jQuery().select2){ |
| 9 | $('.tutor_select2').select2({ |
| 10 | escapeMarkup : function(markup) { |
| 11 | return markup; |
| 12 | } |
| 13 | }); |
| 14 | } |
| 15 | //END: select2 |
| 16 | |
| 17 | $(document).on('change', '.tutor-course-filter-form', function(e){ |
| 18 | e.preventDefault(); |
| 19 | $(this).closest('form').submit(); |
| 20 | }); |
| 21 | |
| 22 | const videoPlayer = { |
| 23 | nonce_key : _tutorobject.nonce_key, |
| 24 | video_track_data : $('#tutor_video_tracking_information').val(), |
| 25 | track_player : function(){ |
| 26 | var that = this; |
| 27 | |
| 28 | var video_data = this.video_track_data ? JSON.parse(this.video_track_data) : {}; |
| 29 | |
| 30 | if (typeof Plyr !== 'undefined') { |
| 31 | const player = new Plyr('#tutorPlayer'); |
| 32 | |
| 33 | player.on('ready', function(event){ |
| 34 | const instance = event.detail.plyr; |
| 35 | if (video_data.best_watch_time > 0) { |
| 36 | instance.media.currentTime = video_data.best_watch_time; |
| 37 | } |
| 38 | that.sync_time(instance); |
| 39 | }); |
| 40 | |
| 41 | var tempTimeNow = 0; |
| 42 | var intervalSeconds = 60; //Send to tutor backend about video playing time in this interval |
| 43 | player.on('timeupdate', function(event){ |
| 44 | const instance = event.detail.plyr; |
| 45 | |
| 46 | var tempTimeNowInSec = (tempTimeNow / 4); //timeupdate firing 250ms interval |
| 47 | if (tempTimeNowInSec >= intervalSeconds){ |
| 48 | that.sync_time(instance); |
| 49 | tempTimeNow = 0; |
| 50 | } |
| 51 | tempTimeNow++; |
| 52 | }); |
| 53 | |
| 54 | player.on('ended', function(event){ |
| 55 | const instance = event.detail.plyr; |
| 56 | |
| 57 | var data = {is_ended:true}; |
| 58 | that.sync_time(instance, data) |
| 59 | }); |
| 60 | } |
| 61 | }, |
| 62 | sync_time: function(instance, options){ |
| 63 | /** |
| 64 | * TUTOR is sending about video playback information to server. |
| 65 | */ |
| 66 | var video_data = this.video_track_data ? JSON.parse(this.video_track_data) : {}; |
| 67 | var data = {action: 'sync_video_playback', currentTime : instance.currentTime, duration:instance.duration, post_id : video_data.post_id}; |
| 68 | data[this.nonce_key] = _tutorobject[this.nonce_key]; |
| 69 | |
| 70 | var data_send = data; |
| 71 | if(options){ |
| 72 | data_send = Object.assign(data, options); |
| 73 | } |
| 74 | $.post(_tutorobject.ajaxurl, data_send); |
| 75 | }, |
| 76 | init: function(){ |
| 77 | this.track_player(); |
| 78 | } |
| 79 | }; |
| 80 | |
| 81 | /** |
| 82 | * Fire TUTOR video |
| 83 | * @since v.1.0.0 |
| 84 | */ |
| 85 | if ($('#tutorPlayer').length){ |
| 86 | videoPlayer.init(); |
| 87 | } |
| 88 | |
| 89 | $(document).on('change keyup paste', '.tutor_user_name', function(){ |
| 90 | $(this).val(tutor_slugify($(this).val())); |
| 91 | }); |
| 92 | |
| 93 | function tutor_slugify(text) { |
| 94 | return text.toString().toLowerCase() |
| 95 | .replace(/\s+/g, '-') // Replace spaces with - |
| 96 | .replace(/[^\w\-]+/g, '') // Remove all non-word chars |
| 97 | .replace(/\-\-+/g, '-') // Replace multiple - with single - |
| 98 | .replace(/^-+/, '') // Trim - from start of text |
| 99 | .replace(/-+$/, ''); // Trim - from end of text |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Hover tutor rating and set value |
| 104 | */ |
| 105 | $(document).on('hover', '.tutor-write-review-box .tutor-star-rating-group i', function(){ |
| 106 | $(this).closest('.tutor-star-rating-group').find('i').removeClass('tutor-icon-star-full').addClass('tutor-icon-star-line'); |
| 107 | var currentRateValue = $(this).attr('data-rating-value'); |
| 108 | for (var i = 1; i<= currentRateValue; i++){ |
| 109 | $(this).closest('.tutor-star-rating-group').find('i[data-rating-value="'+i+'"]').removeClass('tutor-icon-star-line').addClass('tutor-icon-star-full'); |
| 110 | } |
| 111 | $(this).closest('.tutor-star-rating-group').find('input[name="tutor_rating_gen_input"]').val(currentRateValue); |
| 112 | }); |
| 113 | |
| 114 | $(document).on('click', '.tutor-star-rating-group i', function(){ |
| 115 | var rating = $(this).attr('data-rating-value'); |
| 116 | $(this).closest('.tutor-star-rating-group').find('input[name="tutor_rating_gen_input"]').val(rating); |
| 117 | }); |
| 118 | |
| 119 | $(document).on('click', '.tutor_submit_review_btn', function (e) { |
| 120 | e.preventDefault(); |
| 121 | var $that = $(this); |
| 122 | var rating = $that.closest('form').find('input[name="tutor_rating_gen_input"]').val(); |
| 123 | var review = $that.closest('form').find('textarea[name="review"]').val(); |
| 124 | review = review.trim(); |
| 125 | |
| 126 | var course_id = $('input[name="tutor_course_id"]').val(); |
| 127 | var data = {course_id : course_id, rating : rating, review:review, action: 'tutor_place_rating' }; |
| 128 | |
| 129 | if (review) { |
| 130 | $.ajax({ |
| 131 | url: _tutorobject.ajaxurl, |
| 132 | type: 'POST', |
| 133 | data: data, |
| 134 | beforeSend: function () { |
| 135 | $that.addClass('updating-icon'); |
| 136 | }, |
| 137 | success: function (data) { |
| 138 | var review_id = data.data.review_id; |
| 139 | var review = data.data.review; |
| 140 | $('.tutor-review-'+review_id+' .review-content').html(review); |
| 141 | location.reload(); |
| 142 | } |
| 143 | }); |
| 144 | } |
| 145 | }); |
| 146 | |
| 147 | $(document).on('click', '.write-course-review-link-btn', function(e){ |
| 148 | e.preventDefault(); |
| 149 | $(this).siblings('.tutor-write-review-form').slideToggle(); |
| 150 | }); |
| 151 | |
| 152 | $(document).on('click', '.tutor-ask-question-btn', function(e){ |
| 153 | e.preventDefault(); |
| 154 | $('.tutor-add-question-wrap').slideToggle(); |
| 155 | }); |
| 156 | $(document).on('click', '.tutor_question_cancel', function(e){ |
| 157 | e.preventDefault(); |
| 158 | $('.tutor-add-question-wrap').toggle(); |
| 159 | }); |
| 160 | |
| 161 | $(document).on('submit', '#tutor-ask-question-form', function(e){ |
| 162 | e.preventDefault(); |
| 163 | |
| 164 | var $form = $(this); |
| 165 | var data = $(this).serialize()+'&action=tutor_ask_question'; |
| 166 | |
| 167 | $.ajax({ |
| 168 | url: _tutorobject.ajaxurl, |
| 169 | type: 'POST', |
| 170 | data: data, |
| 171 | beforeSend: function () { |
| 172 | $form.find('.tutor_ask_question_btn').addClass('updating-icon'); |
| 173 | }, |
| 174 | success: function (data) { |
| 175 | if (data.success){ |
| 176 | $('.tutor-add-question-wrap').hide(); |
| 177 | window.location.reload(); |
| 178 | } |
| 179 | }, |
| 180 | complete: function () { |
| 181 | $form.find('.tutor_ask_question_btn').removeClass('updating-icon'); |
| 182 | } |
| 183 | }); |
| 184 | }); |
| 185 | |
| 186 | $(document).on('submit', '.tutor-add-answer-form', function(e){ |
| 187 | e.preventDefault(); |
| 188 | |
| 189 | var $form = $(this); |
| 190 | var data = $(this).serialize()+'&action=tutor_add_answer'; |
| 191 | |
| 192 | $.ajax({ |
| 193 | url: _tutorobject.ajaxurl, |
| 194 | type: 'POST', |
| 195 | data: data, |
| 196 | beforeSend: function () { |
| 197 | $form.find('.tutor_add_answer_btn').addClass('updating-icon'); |
| 198 | }, |
| 199 | success: function (data) { |
| 200 | if (data.success){ |
| 201 | window.location.reload(); |
| 202 | } |
| 203 | }, |
| 204 | complete: function () { |
| 205 | $form.find('.tutor_add_answer_btn').removeClass('updating-icon'); |
| 206 | } |
| 207 | }); |
| 208 | }); |
| 209 | |
| 210 | $(document).on('focus', '.tutor_add_answer_textarea', function(e){ |
| 211 | e.preventDefault(); |
| 212 | |
| 213 | var question_id = $(this).closest('.tutor_add_answer_wrap').attr('data-question-id'); |
| 214 | var conf = { |
| 215 | tinymce: { |
| 216 | wpautop:true, |
| 217 | //plugins : 'charmap colorpicker compat3x directionality fullscreen hr image lists media paste tabfocus textcolor wordpress wpautoresize wpdialogs wpeditimage wpemoji wpgallery wplink wptextpattern wpview', |
| 218 | toolbar1: 'bold italic underline bullist strikethrough numlist blockquote alignleft aligncenter alignright undo redo link unlink spellchecker fullscreen' |
| 219 | }, |
| 220 | }; |
| 221 | wp.editor.initialize('tutor_answer_'+question_id, conf); |
| 222 | }); |
| 223 | |
| 224 | $(document).on('click', '.tutor_cancel_wp_editor', function(e){ |
| 225 | e.preventDefault(); |
| 226 | $(this).closest('.tutor_wp_editor_wrap').toggle(); |
| 227 | $(this).closest('.tutor_add_answer_wrap').find('.tutor_wp_editor_show_btn_wrap').toggle(); |
| 228 | var question_id = $(this).closest('.tutor_add_answer_wrap').attr('data-question-id'); |
| 229 | wp.editor.remove('tutor_answer_'+question_id); |
| 230 | }); |
| 231 | |
| 232 | $(document).on('click', '.tutor_wp_editor_show_btn', function(e){ |
| 233 | e.preventDefault(); |
| 234 | $(this).closest('.tutor_add_answer_wrap').find('.tutor_wp_editor_wrap').toggle(); |
| 235 | $(this).closest('.tutor_wp_editor_show_btn_wrap').toggle(); |
| 236 | }); |
| 237 | |
| 238 | /** |
| 239 | * Quiz attempt |
| 240 | */ |
| 241 | var $tutor_quiz_time_update = $('#tutor-quiz-time-update'); |
| 242 | var attempt_settings = null; |
| 243 | if ($tutor_quiz_time_update.length){ |
| 244 | attempt_settings = JSON.parse($tutor_quiz_time_update.attr('data-attempt-settings')); |
| 245 | var attempt_meta = JSON.parse($tutor_quiz_time_update.attr('data-attempt-meta')); |
| 246 | |
| 247 | if (attempt_meta.time_limit.time_limit_seconds > 0) { |
| 248 | //No time Zero limit for |
| 249 | var countDownDate = new Date(attempt_settings.attempt_started_at).getTime() + (attempt_meta.time_limit.time_limit_seconds * 1000); |
| 250 | var time_now = new Date(attempt_meta.date_time_now).getTime(); |
| 251 | |
| 252 | var tutor_quiz_interval = setInterval(function () { |
| 253 | var distance = countDownDate - time_now; |
| 254 | |
| 255 | var days = Math.floor(distance / (1000 * 60 * 60 * 24)); |
| 256 | var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); |
| 257 | var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); |
| 258 | var seconds = Math.floor((distance % (1000 * 60)) / 1000); |
| 259 | |
| 260 | var countdown_human = ''; |
| 261 | |
| 262 | if (days) { |
| 263 | countdown_human += days + "d "; |
| 264 | } |
| 265 | if (hours) { |
| 266 | countdown_human += hours + "h "; |
| 267 | } |
| 268 | if (minutes) { |
| 269 | countdown_human += minutes + "m "; |
| 270 | } |
| 271 | if (seconds) { |
| 272 | countdown_human += seconds + "s "; |
| 273 | } |
| 274 | |
| 275 | if (distance < 0) { |
| 276 | clearInterval(tutor_quiz_interval); |
| 277 | countdown_human = "EXPIRED"; |
| 278 | //Set the quiz attempt to timeout in ajax |
| 279 | |
| 280 | if (_tutorobject.options.quiz_when_time_expires === 'autosubmit') { |
| 281 | /** |
| 282 | * Auto Submit |
| 283 | */ |
| 284 | $('form#tutor-answering-quiz').submit(); |
| 285 | |
| 286 | } else if (_tutorobject.options.quiz_when_time_expires === 'autoabandon') { |
| 287 | /** |
| 288 | * |
| 289 | * @type {jQuery} |
| 290 | * |
| 291 | * Current attempt will be cancel with attempt status attempt_timeout |
| 292 | */ |
| 293 | |
| 294 | var quiz_id = $('#tutor_quiz_id').val(); |
| 295 | var tutor_quiz_remaining_time_secs = $('#tutor_quiz_remaining_time_secs').val(); |
| 296 | var quiz_timeout_data = {quiz_id: quiz_id, action: 'tutor_quiz_timeout'}; |
| 297 | |
| 298 | $.ajax({ |
| 299 | url: _tutorobject.ajaxurl, |
| 300 | type: 'POST', |
| 301 | data: quiz_timeout_data, |
| 302 | success: function (data) { |
| 303 | if (data.success) { |
| 304 | window.location.reload(true); |
| 305 | } |
| 306 | }, |
| 307 | complete: function () { |
| 308 | $('#tutor-quiz-body').html(''); |
| 309 | window.location.reload(true); |
| 310 | } |
| 311 | }); |
| 312 | } |
| 313 | |
| 314 | } |
| 315 | time_now = time_now + 1000; |
| 316 | $tutor_quiz_time_update.html(countdown_human); |
| 317 | }, 1000); |
| 318 | }else{ |
| 319 | $tutor_quiz_time_update.closest('.time-remaining').remove(); |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | var $quiz_start_form = $('#tutor-quiz-body form#tutor-start-quiz'); |
| 324 | if ($quiz_start_form.length){ |
| 325 | if (_tutorobject.quiz_options.quiz_auto_start === '1'){ |
| 326 | $quiz_start_form.submit(); |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | // tutor course content accordion |
| 331 | $('.tutor-course-topic.tutor-active').find('.tutor-course-lessons').slideDown(); |
| 332 | $('.tutor-course-title').on('click', function () { |
| 333 | var lesson = $(this).siblings('.tutor-course-lessons'); |
| 334 | $(this).closest('.tutor-course-topic').toggleClass('tutor-active'); |
| 335 | lesson.slideToggle(); |
| 336 | }); |
| 337 | |
| 338 | $(document).on('click', '.tutor-topics-title h3 .toogle-informaiton-icon', function (e) { |
| 339 | $(this).closest('.tutor-topics-in-single-lesson').find('.tutor-topics-summery').slideToggle(); |
| 340 | e.stopPropagation(); |
| 341 | }); |
| 342 | |
| 343 | $(document).on('click', '.tutor-course-wishlist-btn', function (e) { |
| 344 | e.preventDefault(); |
| 345 | |
| 346 | var $that = $(this); |
| 347 | var course_id = $that.attr('data-course-id'); |
| 348 | |
| 349 | $.ajax({ |
| 350 | url: _tutorobject.ajaxurl, |
| 351 | type: 'POST', |
| 352 | data: {course_id : course_id, 'action': 'tutor_course_add_to_wishlist'}, |
| 353 | beforeSend: function () { |
| 354 | $that.addClass('updating-icon'); |
| 355 | }, |
| 356 | success: function (data) { |
| 357 | if (data.success){ |
| 358 | if (data.data.status === 'added'){ |
| 359 | $that.addClass('has-wish-listed'); |
| 360 | }else{ |
| 361 | $that.removeClass('has-wish-listed'); |
| 362 | } |
| 363 | }else{ |
| 364 | window.location = data.data.redirect_to; |
| 365 | } |
| 366 | }, |
| 367 | complete: function () { |
| 368 | $that.removeClass('updating-icon'); |
| 369 | } |
| 370 | }); |
| 371 | }); |
| 372 | |
| 373 | $(document).on('click', '.tutor-single-lesson-a', function (e) { |
| 374 | e.preventDefault(); |
| 375 | |
| 376 | var $that = $(this); |
| 377 | var lesson_id = $that.attr('data-lesson-id'); |
| 378 | var $wrap = $('#tutor-single-entry-content'); |
| 379 | |
| 380 | $.ajax({ |
| 381 | url: _tutorobject.ajaxurl, |
| 382 | type: 'POST', |
| 383 | data: {lesson_id : lesson_id, 'action': 'tutor_render_lesson_content'}, |
| 384 | beforeSend: function () { |
| 385 | var page_title = $that.find('.lesson_title').text(); |
| 386 | $('head title').text(page_title); |
| 387 | window.history.pushState('obj', page_title, $that.attr('href')); |
| 388 | $wrap.addClass('loading-lesson'); |
| 389 | $('.tutor-single-lesson-items').removeClass('active'); |
| 390 | $that.closest('.tutor-single-lesson-items').addClass('active'); |
| 391 | }, |
| 392 | success: function (data) { |
| 393 | $wrap.html(data.data.html); |
| 394 | videoPlayer.init(); |
| 395 | $('.tutor-lesson-sidebar').css('display', ''); |
| 396 | }, |
| 397 | complete: function () { |
| 398 | $wrap.removeClass('loading-lesson'); |
| 399 | } |
| 400 | }); |
| 401 | }); |
| 402 | |
| 403 | $(document).on('click', '.sidebar-single-quiz-a', function (e) { |
| 404 | e.preventDefault(); |
| 405 | |
| 406 | var $that = $(this); |
| 407 | var quiz_id = $that.attr('data-quiz-id'); |
| 408 | var page_title = $that.find('.lesson_title').text(); |
| 409 | var $wrap = $('#tutor-single-entry-content'); |
| 410 | |
| 411 | $.ajax({ |
| 412 | url: _tutorobject.ajaxurl, |
| 413 | type: 'POST', |
| 414 | data: {quiz_id : quiz_id, 'action': 'tutor_render_quiz_content'}, |
| 415 | beforeSend: function () { |
| 416 | $('head title').text(page_title); |
| 417 | window.history.pushState('obj', page_title, $that.attr('href')); |
| 418 | $wrap.addClass('loading-lesson'); |
| 419 | $('.tutor-single-lesson-items').removeClass('active'); |
| 420 | $that.closest('.tutor-single-lesson-items').addClass('active'); |
| 421 | }, |
| 422 | success: function (data) { |
| 423 | $wrap.html(data.data.html); |
| 424 | init_quiz_builder(); |
| 425 | $('.tutor-lesson-sidebar').css('display', ''); |
| 426 | }, |
| 427 | complete: function () { |
| 428 | $wrap.removeClass('loading-lesson'); |
| 429 | } |
| 430 | }); |
| 431 | }); |
| 432 | |
| 433 | /** |
| 434 | * @date 05 Feb, 2019 |
| 435 | */ |
| 436 | |
| 437 | $(document).on('click', '.tutor-lesson-sidebar-hide-bar', function(e){ |
| 438 | e.preventDefault(); |
| 439 | $('.tutor-lesson-sidebar').toggle(); |
| 440 | }); |
| 441 | |
| 442 | $(".tutor-tabs-btn-group a").on('click touchstart', function (e) { |
| 443 | e.preventDefault(); |
| 444 | var $that = $(this); |
| 445 | var tabSelector = $that.attr('href'); |
| 446 | $('.tutor-lesson-sidebar-tab-item').hide(); |
| 447 | $(tabSelector).show(); |
| 448 | |
| 449 | $('.tutor-tabs-btn-group a').removeClass('active'); |
| 450 | $that.addClass('active'); |
| 451 | }); |
| 452 | /** |
| 453 | * @date 18 Feb, 2019 |
| 454 | * @since v.1.0.0 |
| 455 | */ |
| 456 | |
| 457 | function init_quiz_builder() { |
| 458 | if (jQuery().sortable) { |
| 459 | $(".tutor-quiz-answers-wrap").sortable({ |
| 460 | handle: ".answer-sorting-bar", |
| 461 | start: function (e, ui) { |
| 462 | ui.placeholder.css('visibility', 'visible'); |
| 463 | }, |
| 464 | stop: function (e, ui) { |
| 465 | |
| 466 | //Sorting Stopped... |
| 467 | }, |
| 468 | }).disableSelection(); |
| 469 | ; |
| 470 | |
| 471 | |
| 472 | $(".quiz-draggable-rand-answers, .quiz-answer-matching-droppable").sortable({ |
| 473 | connectWith: ".quiz-answer-matching-droppable", |
| 474 | placeholder: "drop-hover" |
| 475 | |
| 476 | }).disableSelection(); |
| 477 | } |
| 478 | } |
| 479 | init_quiz_builder(); |
| 480 | /** |
| 481 | * Quiz view |
| 482 | * @date 22 Feb, 2019 |
| 483 | * @since v.1.0.0 |
| 484 | */ |
| 485 | |
| 486 | $(document).on('click', '.tutor-quiz-answer-next-btn', function (e) { |
| 487 | e.preventDefault(); |
| 488 | var $that = $(this); |
| 489 | var question_id = parseInt($that.closest('.quiz-attempt-single-question').attr('id').match(/\d+/)[0], 10); |
| 490 | |
| 491 | var next_question_id = $that.closest('.quiz-attempt-single-question').attr('data-next-question-id'); |
| 492 | |
| 493 | if (next_question_id) { |
| 494 | var $nextQuestion = $(next_question_id); |
| 495 | if ($nextQuestion && $nextQuestion.length) { |
| 496 | $('.quiz-attempt-single-question').hide(); |
| 497 | $nextQuestion.show(); |
| 498 | |
| 499 | /** |
| 500 | * If pagination exists, set active class |
| 501 | */ |
| 502 | |
| 503 | if ($('.tutor-quiz-questions-pagination').length){ |
| 504 | $('.tutor-quiz-question-paginate-item').removeClass('active'); |
| 505 | $('.tutor-quiz-questions-pagination a[href="'+next_question_id+'"]').addClass('active'); |
| 506 | } |
| 507 | |
| 508 | } |
| 509 | } |
| 510 | }); |
| 511 | $(document).on('click', '.tutor-quiz-question-paginate-item', function (e) { |
| 512 | e.preventDefault(); |
| 513 | var $that = $(this); |
| 514 | var $question = $($that.attr('href')); |
| 515 | $('.quiz-attempt-single-question').hide(); |
| 516 | $question.show(); |
| 517 | |
| 518 | //Active Class |
| 519 | $('.tutor-quiz-question-paginate-item').removeClass('active'); |
| 520 | $that.addClass('active'); |
| 521 | }); |
| 522 | |
| 523 | /** |
| 524 | * Limit Short Answer Question Type |
| 525 | */ |
| 526 | $(document).on('keyup', 'textarea.question_type_short_answer', function (e) { |
| 527 | var $that = $(this); |
| 528 | var value = $that.val(); |
| 529 | var limit = _tutorobject.quiz_options.short_answer_characters_limit; |
| 530 | var remaining = limit - value.length; |
| 531 | |
| 532 | if (remaining < 1){ |
| 533 | $that.val(value.substr(0, limit)); |
| 534 | remaining = 0; |
| 535 | } |
| 536 | $that.closest('.tutor-quiz-answers-wrap').find('.characters_remaining').html(remaining); |
| 537 | }); |
| 538 | |
| 539 | /** |
| 540 | * Add to cart in guest mode, show login form |
| 541 | * |
| 542 | * @since v.1.0.4 |
| 543 | */ |
| 544 | |
| 545 | $(document).on('submit click', '.cart-required-login, .cart-required-login a, .cart-required-login form', function (e) { |
| 546 | e.preventDefault(); |
| 547 | |
| 548 | $('.tutor-cart-box-login-form').fadeIn(100); |
| 549 | }); |
| 550 | |
| 551 | $('.tutor-popup-form-close, .login-overlay-close').on('click', function () { |
| 552 | $('.tutor-cart-box-login-form').fadeOut(100); |
| 553 | }); |
| 554 | |
| 555 | $(document).on('keyup', function (e) { |
| 556 | if (e.keyCode === 27) { |
| 557 | $('.tutor-frontend-modal').hide(); |
| 558 | $('.tutor-cart-box-login-form').fadeOut(100); |
| 559 | } |
| 560 | }); |
| 561 | /** |
| 562 | * Share Link enable |
| 563 | * |
| 564 | * @since v.1.0.4 |
| 565 | */ |
| 566 | if($.fn.ShareLink){ |
| 567 | var $social_share_wrap = $('.tutor-social-share-wrap'); |
| 568 | if ($social_share_wrap.length) { |
| 569 | var share_config = JSON.parse($social_share_wrap.attr('data-social-share-config')); |
| 570 | |
| 571 | $('.tutor_share').ShareLink({ |
| 572 | title: share_config.title, |
| 573 | text: share_config.text, |
| 574 | image: share_config.image, |
| 575 | class_prefix: 's_', |
| 576 | width: 640, |
| 577 | height: 480, |
| 578 | }); |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | /** |
| 583 | * Datepicker initiate |
| 584 | * |
| 585 | * @since v.1.1.2 |
| 586 | */ |
| 587 | if (jQuery.datepicker){ |
| 588 | $( ".tutor_report_datepicker" ).datepicker({"dateFormat" : 'yy-mm-dd'}); |
| 589 | } |
| 590 | |
| 591 | |
| 592 | /** |
| 593 | * Withdraw Form Tab/Toggle |
| 594 | * |
| 595 | * @since v.1.1.2 |
| 596 | */ |
| 597 | |
| 598 | $(".withdraw-method-select-input").on('change', function(e){ |
| 599 | var $that = $(this); |
| 600 | $('.withdraw-method-form').hide(); |
| 601 | $('#withdraw-method-form-'+$that.closest('.withdraw-method-select').attr('data-withdraw-method')).show(); |
| 602 | }); |
| 603 | |
| 604 | $('.withdraw-method-select-input').each(function () { |
| 605 | var $that = $(this); |
| 606 | if($that.is(":checked")){ |
| 607 | $('.withdraw-method-form').hide(); |
| 608 | $('#withdraw-method-form-'+$that.closest('.withdraw-method-select').attr('data-withdraw-method')).show(); |
| 609 | } |
| 610 | }); |
| 611 | |
| 612 | |
| 613 | |
| 614 | /** |
| 615 | * Setting account for withdraw earning |
| 616 | * |
| 617 | * @since v.1.2.0 |
| 618 | */ |
| 619 | $(document).on('submit', '#tutor-withdraw-account-set-form', function(e){ |
| 620 | e.preventDefault(); |
| 621 | |
| 622 | var $form = $(this); |
| 623 | var $btn = $form.find('.tutor_set_withdraw_account_btn'); |
| 624 | var data = $form.serialize(); |
| 625 | |
| 626 | $.ajax({ |
| 627 | url: _tutorobject.ajaxurl, |
| 628 | type: 'POST', |
| 629 | data: data, |
| 630 | beforeSend: function () { |
| 631 | $form.find('.tutor-success-msg').remove(); |
| 632 | $btn.addClass('updating-icon'); |
| 633 | }, |
| 634 | success: function (data) { |
| 635 | if (data.success){ |
| 636 | var successMsg = '<div class="tutor-success-msg" style="display: none;"><i class="tutor-icon-mark"></i> '+data.data.msg+' </div>'; |
| 637 | $btn.closest('.withdraw-account-save-btn-wrap').append(successMsg); |
| 638 | if ($form.find('.tutor-success-msg').length) { |
| 639 | $form.find('.tutor-success-msg').slideDown(); |
| 640 | } |
| 641 | setTimeout(function () { |
| 642 | $form.find('.tutor-success-msg').slideUp(); |
| 643 | }, 5000) |
| 644 | } |
| 645 | }, |
| 646 | complete: function () { |
| 647 | $btn.removeClass('updating-icon'); |
| 648 | } |
| 649 | }); |
| 650 | }); |
| 651 | |
| 652 | /** |
| 653 | * Make Withdraw Form |
| 654 | * |
| 655 | * @since v.1.2.0 |
| 656 | */ |
| 657 | |
| 658 | $(document).on('click', 'a.open-withdraw-form-btn', function(e){ |
| 659 | e.preventDefault(); |
| 660 | $('.tutor-earning-withdraw-form-wrap').slideToggle(); |
| 661 | }); |
| 662 | |
| 663 | $(document).on('submit', '#tutor-earning-withdraw-form', function(e){ |
| 664 | e.preventDefault(); |
| 665 | |
| 666 | var $form = $(this); |
| 667 | var $btn = $('#tutor-earning-withdraw-btn'); |
| 668 | var $responseDiv = $('#tutor-withdraw-form-response'); |
| 669 | var data = $form.serialize(); |
| 670 | |
| 671 | $.ajax({ |
| 672 | url: _tutorobject.ajaxurl, |
| 673 | type: 'POST', |
| 674 | data: data, |
| 675 | beforeSend: function () { |
| 676 | $form.find('.tutor-success-msg').remove(); |
| 677 | $btn.addClass('updating-icon'); |
| 678 | }, |
| 679 | success: function (data) { |
| 680 | var Msg; |
| 681 | if (data.success){ |
| 682 | |
| 683 | if (data.data.available_balance !== 'undefined') { |
| 684 | $('.withdraw-balance-col .available_balance').html(data.data.available_balance); |
| 685 | } |
| 686 | Msg = '<div class="tutor-success-msg"><i class="tutor-icon-mark"></i> '+data.data.msg+' </div>'; |
| 687 | |
| 688 | }else{ |
| 689 | Msg = '<div class="tutor-error-msg"><i class="tutor-icon-line-cross"></i> '+data.data.msg+' </div>'; |
| 690 | } |
| 691 | |
| 692 | $responseDiv.html(Msg); |
| 693 | setTimeout(function () { |
| 694 | $responseDiv.html(''); |
| 695 | }, 5000) |
| 696 | }, |
| 697 | complete: function () { |
| 698 | $btn.removeClass('updating-icon'); |
| 699 | } |
| 700 | }); |
| 701 | }); |
| 702 | |
| 703 | var frontEndModal = $('.tutor-frontend-modal'); |
| 704 | frontEndModal.each(function () { |
| 705 | var modal = $(this), |
| 706 | action = $(this).data('popup-rel'); |
| 707 | $('[href="'+action+'"]').on('click', function (e) { |
| 708 | modal.fadeIn(); |
| 709 | e.preventDefault(); |
| 710 | }); |
| 711 | }); |
| 712 | $(document).on('click', '.tm-close, .tutor-frontend-modal-overlay, .tutor-modal-btn-cancel', function () { |
| 713 | frontEndModal.fadeOut(); |
| 714 | }); |
| 715 | |
| 716 | /** |
| 717 | * Delete Course |
| 718 | */ |
| 719 | $(document).on('click', '.tutor-mycourse-delete-btn', function (e) { |
| 720 | e.preventDefault(); |
| 721 | var course_id = $(this).attr('data-course-id'); |
| 722 | $('#tutor-course-delete-id').val(course_id); |
| 723 | }); |
| 724 | $(document).on('submit', '#tutor-delete-course-form', function (e) { |
| 725 | e.preventDefault(); |
| 726 | |
| 727 | var course_id = $('#tutor-course-delete-id').val(); |
| 728 | var $btn = $('.tutor-modal-course-delete-btn'); |
| 729 | var data = $(this).serialize(); |
| 730 | |
| 731 | $.ajax({ |
| 732 | url: _tutorobject.ajaxurl, |
| 733 | type: 'POST', |
| 734 | data: data, |
| 735 | beforeSend: function () { |
| 736 | $btn.addClass('updating-icon'); |
| 737 | }, |
| 738 | success: function (data) { |
| 739 | if (data.success){ |
| 740 | $('#tutor-dashboard-course-'+course_id).remove(); |
| 741 | } |
| 742 | }, |
| 743 | complete: function () { |
| 744 | $btn.removeClass('updating-icon'); |
| 745 | $('.tutor-frontend-modal').hide(); |
| 746 | } |
| 747 | }); |
| 748 | }); |
| 749 | |
| 750 | /** |
| 751 | * Frontend Profile |
| 752 | */ |
| 753 | |
| 754 | if (! $('#tutor_profile_photo_id').val()) { |
| 755 | $('.tutor-profile-photo-delete-btn').hide(); |
| 756 | } |
| 757 | // Uploading files |
| 758 | var file_frame; |
| 759 | $( document ).on( 'click', '.tutor-profile-photo-upload-btn', function( event ) { |
| 760 | event.preventDefault(); |
| 761 | |
| 762 | if ( file_frame ) { |
| 763 | file_frame.open(); |
| 764 | return; |
| 765 | } |
| 766 | file_frame = wp.media.frames.downloadable_file = wp.media({ |
| 767 | title: 'Choose an image', |
| 768 | button: { |
| 769 | text: 'Use image' |
| 770 | }, |
| 771 | multiple: false |
| 772 | }); |
| 773 | file_frame.on( 'select', function() { |
| 774 | var attachment = file_frame.state().get( 'selection' ).first().toJSON(); |
| 775 | var attachment_thumbnail = attachment.sizes.thumbnail || attachment.sizes.full; |
| 776 | |
| 777 | $( '#tutor_profile_photo_id' ).val( attachment.id ); |
| 778 | $( '.tutor-profile-photo-upload-wrap' ).find( 'img' ).attr( 'src', attachment_thumbnail.url ); |
| 779 | $( '.tutor-profile-photo-delete-btn' ).show(); |
| 780 | }); |
| 781 | file_frame.open(); |
| 782 | }); |
| 783 | |
| 784 | $( document ).on( 'click', '.tutor-profile-photo-delete-btn', function() { |
| 785 | $( '.tutor-profile-photo-upload-wrap' ).find( 'img' ).attr( 'src', _tutorobject.placeholder_img_src ); |
| 786 | $( '#tutor_profile_photo_id' ).val( '' ); |
| 787 | $( '.tutor-profile-photo-delete-btn' ).hide(); |
| 788 | return false; |
| 789 | }); |
| 790 | |
| 791 | |
| 792 | /** |
| 793 | * Assignment |
| 794 | * |
| 795 | * @since v.1.3.3 |
| 796 | */ |
| 797 | |
| 798 | $( document ).on( 'submit', '#tutor_assignment_start_form', function(e) { |
| 799 | e.preventDefault(); |
| 800 | |
| 801 | var $that = $(this); |
| 802 | var form_data = $that.serialize()+'&action=tutor_start_assignment'; |
| 803 | |
| 804 | $.ajax({ |
| 805 | url: _tutorobject.ajaxurl, |
| 806 | type: 'POST', |
| 807 | data: form_data, |
| 808 | beforeSend: function () { |
| 809 | $('#tutor_assignment_start_btn').addClass('updating-icon'); |
| 810 | }, |
| 811 | success: function (data) { |
| 812 | if (data.success){ |
| 813 | location.reload(); |
| 814 | } |
| 815 | }, |
| 816 | complete : function () { |
| 817 | $('#tutor_assignment_start_btn').removeClass('updating-icon'); |
| 818 | } |
| 819 | }); |
| 820 | }); |
| 821 | |
| 822 | /** |
| 823 | * Course builder video |
| 824 | * @since v.1.3.4 |
| 825 | */ |
| 826 | |
| 827 | |
| 828 | $(document).on( 'click', '.video_source_upload_wrap_html5 .video_upload_btn', function( event ){ |
| 829 | event.preventDefault(); |
| 830 | |
| 831 | var $that = $(this); |
| 832 | var frame; |
| 833 | // If the media frame already exists, reopen it. |
| 834 | if ( frame ) { |
| 835 | frame.open(); |
| 836 | return; |
| 837 | } |
| 838 | frame = wp.media({ |
| 839 | title: 'Select or Upload Media Of Your Chosen Persuasion', |
| 840 | button: { |
| 841 | text: 'Use this media' |
| 842 | }, |
| 843 | multiple: false // Set to true to allow multiple files to be selected |
| 844 | }); |
| 845 | frame.on( 'select', function() { |
| 846 | // Get media attachment details from the frame state |
| 847 | var attachment = frame.state().get('selection').first().toJSON(); |
| 848 | $that.closest('.video_source_upload_wrap_html5').find('span.video_media_id').text(attachment.id).closest('p').show(); |
| 849 | $that.closest('.video_source_upload_wrap_html5').find('input').val(attachment.id); |
| 850 | }); |
| 851 | frame.open(); |
| 852 | }); |
| 853 | |
| 854 | /** |
| 855 | * Tutor Course builder JS |
| 856 | */ |
| 857 | |
| 858 | |
| 859 | function tutor_slider_init(){ |
| 860 | $('.tutor-field-slider').each(function(){ |
| 861 | var $slider = $(this); |
| 862 | var $input = $slider.closest('.tutor-field-type-slider').find('input[type="hidden"]'); |
| 863 | var $showVal = $slider.closest('.tutor-field-type-slider').find('.tutor-field-type-slider-value'); |
| 864 | var min = parseFloat($slider.closest('.tutor-field-type-slider').attr('data-min')); |
| 865 | var max = parseFloat($slider.closest('.tutor-field-type-slider').attr('data-max')); |
| 866 | |
| 867 | $slider.slider({ |
| 868 | range: "max", |
| 869 | min: min, |
| 870 | max: max, |
| 871 | value: $input.val(), |
| 872 | slide: function( event, ui ) { |
| 873 | $showVal.text(ui.value); |
| 874 | $input.val(ui.value); |
| 875 | } |
| 876 | }); |
| 877 | }); |
| 878 | } |
| 879 | |
| 880 | tutor_slider_init(); |
| 881 | |
| 882 | /** |
| 883 | * Course and lesson sorting |
| 884 | */ |
| 885 | function enable_sorting_topic_lesson(){ |
| 886 | if (jQuery().sortable) { |
| 887 | $(".course-contents").sortable({ |
| 888 | handle: ".course-move-handle", |
| 889 | start: function (e, ui) { |
| 890 | ui.placeholder.css('visibility', 'visible'); |
| 891 | }, |
| 892 | stop: function (e, ui) { |
| 893 | tutor_sorting_topics_and_lesson(); |
| 894 | }, |
| 895 | }); |
| 896 | $(".tutor-lessons:not(.drop-lessons)").sortable({ |
| 897 | connectWith: ".tutor-lessons", |
| 898 | items: "div.course-content-item", |
| 899 | start: function (e, ui) { |
| 900 | ui.placeholder.css('visibility', 'visible'); |
| 901 | }, |
| 902 | stop: function (e, ui) { |
| 903 | tutor_sorting_topics_and_lesson(); |
| 904 | }, |
| 905 | }); |
| 906 | } |
| 907 | } |
| 908 | enable_sorting_topic_lesson(); |
| 909 | function tutor_sorting_topics_and_lesson(){ |
| 910 | var topics = {}; |
| 911 | $('.tutor-topics-wrap').each(function(index, item){ |
| 912 | var $topic = $(this); |
| 913 | var topics_id = parseInt($topic.attr('id').match(/\d+/)[0], 10); |
| 914 | var lessons = {}; |
| 915 | |
| 916 | $topic.find('.course-content-item').each(function(lessonIndex, lessonItem){ |
| 917 | var $lesson = $(this); |
| 918 | var lesson_id = parseInt($lesson.attr('id').match(/\d+/)[0], 10); |
| 919 | |
| 920 | lessons[lessonIndex] = lesson_id; |
| 921 | }); |
| 922 | topics[index] = { 'topic_id' : topics_id, 'lesson_ids' : lessons }; |
| 923 | }); |
| 924 | $('#tutor_topics_lessons_sorting').val(JSON.stringify(topics)); |
| 925 | } |
| 926 | |
| 927 | $(document).on('click', '.create_new_topic_btn', function (e) { |
| 928 | e.preventDefault(); |
| 929 | $('.tutor-metabox-add-topics').slideToggle(); |
| 930 | }); |
| 931 | |
| 932 | $(document).on('click', '#tutor-add-topic-btn', function (e) { |
| 933 | e.preventDefault(); |
| 934 | var $that = $(this); |
| 935 | var form_data = $that.closest('.tutor-metabox-add-topics').find('input, textarea').serialize()+'&action=tutor_add_course_topic'; |
| 936 | |
| 937 | $.ajax({ |
| 938 | url : ajaxurl, |
| 939 | type : 'POST', |
| 940 | data : form_data, |
| 941 | beforeSend: function () { |
| 942 | $that.addClass('tutor-updating-message'); |
| 943 | }, |
| 944 | success: function (data) { |
| 945 | if (data.success){ |
| 946 | $('#tutor-course-content-wrap').html(data.data.course_contents); |
| 947 | $that.closest('.tutor-metabox-add-topics').find('input[type!="hidden"], textarea').each(function () { |
| 948 | $(this).val(''); |
| 949 | }); |
| 950 | $that.closest('.tutor-metabox-add-topics').slideUp(); |
| 951 | enable_sorting_topic_lesson(); |
| 952 | } |
| 953 | }, |
| 954 | complete: function () { |
| 955 | $that.removeClass('tutor-updating-message'); |
| 956 | } |
| 957 | }); |
| 958 | }); |
| 959 | |
| 960 | $(document).on('change keyup', '.course-edit-topic-title-input', function (e) { |
| 961 | e.preventDefault(); |
| 962 | $(this).closest('.tutor-topics-top').find('.topic-inner-title').html($(this).val()); |
| 963 | }); |
| 964 | |
| 965 | $(document).on('click', '.topic-edit-icon', function (e) { |
| 966 | e.preventDefault(); |
| 967 | $(this).closest('.tutor-topics-top').find('.tutor-topics-edit-form').slideToggle(); |
| 968 | }); |
| 969 | |
| 970 | $(document).on('click', '.tutor-topics-edit-button', function(e){ |
| 971 | e.preventDefault(); |
| 972 | var $button = $(this); |
| 973 | var $topic = $button.closest('.tutor-topics-wrap'); |
| 974 | var topics_id = parseInt($topic.attr('id').match(/\d+/)[0], 10); |
| 975 | var topic_title = $button.closest('.tutor-topics-wrap').find('[name="topic_title"]').val(); |
| 976 | var topic_summery = $button.closest('.tutor-topics-wrap').find('[name="topic_summery"]').val(); |
| 977 | |
| 978 | var data = {topic_title: topic_title, topic_summery : topic_summery, topic_id : topics_id, action: 'tutor_update_topic'}; |
| 979 | $.ajax({ |
| 980 | url : ajaxurl, |
| 981 | type : 'POST', |
| 982 | data : data, |
| 983 | beforeSend: function () { |
| 984 | $button.addClass('tutor-updating-message'); |
| 985 | }, |
| 986 | success: function (data) { |
| 987 | if (data.success){ |
| 988 | $button.closest('.tutor-topics-wrap').find('span.topic-inner-title').text(topic_title); |
| 989 | $button.closest('.tutor-topics-wrap').find('.tutor-topics-edit-form').slideUp(); |
| 990 | } |
| 991 | }, |
| 992 | complete: function () { |
| 993 | $button.removeClass('tutor-updating-message'); |
| 994 | } |
| 995 | }); |
| 996 | }); |
| 997 | |
| 998 | /** |
| 999 | * Confirmation for deleting Topic |
| 1000 | */ |
| 1001 | $(document).on('click', '.topic-delete-btn a', function(e){ |
| 1002 | var topic_id = $(this).attr('data-topic-id'); |
| 1003 | |
| 1004 | if ( ! confirm('Are you sure to delete?')){ |
| 1005 | e.preventDefault(); |
| 1006 | } |
| 1007 | }); |
| 1008 | |
| 1009 | $(document).on('click', '.tutor-expand-all-topic', function (e) { |
| 1010 | e.preventDefault(); |
| 1011 | $('.tutor-topics-body').slideDown(); |
| 1012 | $('.expand-collapse-wrap i').removeClass('tutor-icon-light-down').addClass('tutor-icon-light-up'); |
| 1013 | }); |
| 1014 | $(document).on('click', '.tutor-collapse-all-topic', function (e) { |
| 1015 | e.preventDefault(); |
| 1016 | $('.tutor-topics-body').slideUp(); |
| 1017 | $('.expand-collapse-wrap i').removeClass('tutor-icon-light-up').addClass('tutor-icon-light-down'); |
| 1018 | }); |
| 1019 | $(document).on('click', '.topic-inner-title, .expand-collapse-wrap', function (e) { |
| 1020 | e.preventDefault(); |
| 1021 | var $that = $(this); |
| 1022 | $that.closest('.tutor-topics-wrap').find('.tutor-topics-body').slideToggle(); |
| 1023 | $that.closest('.tutor-topics-wrap').find('.expand-collapse-wrap i').toggleClass('tutor-icon-light-down tutor-icon-light-up'); |
| 1024 | }); |
| 1025 | |
| 1026 | /** |
| 1027 | * Update Lesson Modal |
| 1028 | */ |
| 1029 | $(document).on('click', '.open-tutor-lesson-modal', function(e){ |
| 1030 | e.preventDefault(); |
| 1031 | |
| 1032 | var $that = $(this); |
| 1033 | var lesson_id = $that.attr('data-lesson-id'); |
| 1034 | var topic_id = $that.attr('data-topic-id'); |
| 1035 | var course_id = $('#post_ID').val(); |
| 1036 | |
| 1037 | $.ajax({ |
| 1038 | url : ajaxurl, |
| 1039 | type : 'POST', |
| 1040 | data : {lesson_id : lesson_id, topic_id : topic_id, course_id : course_id, action: 'tutor_load_edit_lesson_modal'}, |
| 1041 | beforeSend: function () { |
| 1042 | $that.addClass('tutor-updating-message'); |
| 1043 | }, |
| 1044 | success: function (data) { |
| 1045 | $('.tutor-lesson-modal-wrap .modal-container').html(data.data.output); |
| 1046 | $('.tutor-lesson-modal-wrap').attr({'data-lesson-id' : lesson_id, 'data-topic-id':topic_id}).addClass('show'); |
| 1047 | |
| 1048 | tinymce.init(tinyMCEPreInit.mceInit.course_description); |
| 1049 | tinymce.execCommand( 'mceRemoveEditor', false, 'tutor_lesson_modal_editor' ); |
| 1050 | tinyMCE.execCommand('mceAddEditor', false, "tutor_lesson_modal_editor"); |
| 1051 | |
| 1052 | }, |
| 1053 | complete: function () { |
| 1054 | quicktags({id : "tutor_lesson_modal_editor"}); |
| 1055 | $that.removeClass('tutor-updating-message'); |
| 1056 | } |
| 1057 | }); |
| 1058 | }); |
| 1059 | |
| 1060 | $(document).on( 'click', '.lesson_thumbnail_upload_btn', function( event ){ |
| 1061 | event.preventDefault(); |
| 1062 | var $that = $(this); |
| 1063 | var frame; |
| 1064 | if ( frame ) { |
| 1065 | frame.open(); |
| 1066 | return; |
| 1067 | } |
| 1068 | frame = wp.media({ |
| 1069 | title: 'Select or Upload Media Of Your Chosen Persuasion', |
| 1070 | button: { |
| 1071 | text: 'Use this media' |
| 1072 | }, |
| 1073 | multiple: false |
| 1074 | }); |
| 1075 | frame.on( 'select', function() { |
| 1076 | var attachment = frame.state().get('selection').first().toJSON(); |
| 1077 | $that.closest('.tutor-thumbnail-wrap').find('.thumbnail-img').html('<img src="'+attachment.url+'" alt="" />'); |
| 1078 | $that.closest('.tutor-thumbnail-wrap').find('input').val(attachment.id); |
| 1079 | }); |
| 1080 | frame.open(); |
| 1081 | }); |
| 1082 | |
| 1083 | /** |
| 1084 | * Delete Lesson from course builder |
| 1085 | */ |
| 1086 | $(document).on('click', '.tutor-delete-lesson-btn', function(e){ |
| 1087 | e.preventDefault(); |
| 1088 | |
| 1089 | if( ! confirm('Are you sure?')){ |
| 1090 | return; |
| 1091 | } |
| 1092 | |
| 1093 | var $that = $(this); |
| 1094 | var lesson_id = $that.attr('data-lesson-id'); |
| 1095 | |
| 1096 | $.ajax({ |
| 1097 | url : ajaxurl, |
| 1098 | type : 'POST', |
| 1099 | data : {lesson_id : lesson_id, action: 'tutor_delete_lesson_by_id'}, |
| 1100 | beforeSend: function () { |
| 1101 | $that.addClass('tutor-updating-message'); |
| 1102 | }, |
| 1103 | success: function (data) { |
| 1104 | if (data.success){ |
| 1105 | $that.closest('.course-content-item').remove(); |
| 1106 | } |
| 1107 | }, |
| 1108 | complete: function () { |
| 1109 | $that.removeClass('tutor-updating-message'); |
| 1110 | } |
| 1111 | }); |
| 1112 | }); |
| 1113 | |
| 1114 | /** |
| 1115 | * Delete quiz |
| 1116 | */ |
| 1117 | $(document).on('click', '.tutor-delete-quiz-btn', function(e){ |
| 1118 | e.preventDefault(); |
| 1119 | |
| 1120 | if( ! confirm('Are you sure?')){ |
| 1121 | return; |
| 1122 | } |
| 1123 | |
| 1124 | var $that = $(this); |
| 1125 | var quiz_id = $that.attr('data-quiz-id'); |
| 1126 | |
| 1127 | $.ajax({ |
| 1128 | url : ajaxurl, |
| 1129 | type : 'POST', |
| 1130 | data : {quiz_id : quiz_id, action: 'tutor_delete_quiz_by_id'}, |
| 1131 | beforeSend: function () { |
| 1132 | $that.closest('.course-content-item').remove(); |
| 1133 | } |
| 1134 | }); |
| 1135 | }); |
| 1136 | |
| 1137 | /** |
| 1138 | * Lesson Update or Create Modal |
| 1139 | */ |
| 1140 | $(document).on( 'click', '.update_lesson_modal_btn', function( event ){ |
| 1141 | event.preventDefault(); |
| 1142 | |
| 1143 | var $that = $(this); |
| 1144 | var content; |
| 1145 | var editor = tinyMCE.get('tutor_lesson_modal_editor'); |
| 1146 | if (editor) { |
| 1147 | content = editor.getContent(); |
| 1148 | } else { |
| 1149 | content = $('#'+inputid).val(); |
| 1150 | } |
| 1151 | |
| 1152 | var form_data = $(this).closest('form').serialize(); |
| 1153 | form_data += '&lesson_content='+content; |
| 1154 | |
| 1155 | $.ajax({ |
| 1156 | url : ajaxurl, |
| 1157 | type : 'POST', |
| 1158 | data : form_data, |
| 1159 | beforeSend: function () { |
| 1160 | $that.addClass('tutor-updating-message'); |
| 1161 | }, |
| 1162 | success: function (data) { |
| 1163 | if (data.success){ |
| 1164 | $('#tutor-course-content-wrap').html(data.data.course_contents); |
| 1165 | enable_sorting_topic_lesson(); |
| 1166 | |
| 1167 | //Close the modal |
| 1168 | $('.tutor-lesson-modal-wrap').removeClass('show'); |
| 1169 | } |
| 1170 | }, |
| 1171 | complete: function () { |
| 1172 | $that.removeClass('tutor-updating-message'); |
| 1173 | } |
| 1174 | }); |
| 1175 | }); |
| 1176 | |
| 1177 | /** |
| 1178 | * END: Tutor Course builder JS |
| 1179 | */ |
| 1180 | |
| 1181 | /** |
| 1182 | * Modal Close |
| 1183 | */ |
| 1184 | |
| 1185 | $(document).on('click', '.modal-close-btn', function(e){ |
| 1186 | e.preventDefault(); |
| 1187 | $('.tutor-modal-wrap').removeClass('show'); |
| 1188 | }); |
| 1189 | $(document).on('keyup', function(e){ |
| 1190 | if (e.keyCode === 27){ |
| 1191 | $('.tutor-modal-wrap').removeClass('show'); |
| 1192 | } |
| 1193 | }); |
| 1194 | /** |
| 1195 | * END: Modal Close |
| 1196 | */ |
| 1197 | |
| 1198 | |
| 1199 | /** |
| 1200 | * Instructor in the course builder frontend |
| 1201 | * @since v.1.3.4 |
| 1202 | */ |
| 1203 | |
| 1204 | |
| 1205 | /** |
| 1206 | * Add instructor modal |
| 1207 | */ |
| 1208 | $(document).on('click', '.tutor-add-instructor-btn', function(e){ |
| 1209 | e.preventDefault(); |
| 1210 | |
| 1211 | var $that = $(this); |
| 1212 | var course_id = $('#post_ID').val(); |
| 1213 | |
| 1214 | $.ajax({ |
| 1215 | url : ajaxurl, |
| 1216 | type : 'POST', |
| 1217 | data : {course_id : course_id, action: 'tutor_load_instructors_modal'}, |
| 1218 | beforeSend: function () { |
| 1219 | $that.addClass('tutor-updating-message'); |
| 1220 | }, |
| 1221 | success: function (data) { |
| 1222 | if (data.success){ |
| 1223 | $('.tutor-instructors-modal-wrap .modal-container').html(data.data.output); |
| 1224 | $('.tutor-instructors-modal-wrap').addClass('show'); |
| 1225 | } |
| 1226 | }, |
| 1227 | complete: function () { |
| 1228 | $that.removeClass('tutor-updating-message'); |
| 1229 | } |
| 1230 | }); |
| 1231 | }); |
| 1232 | |
| 1233 | $(document).on('change keyup', '.tutor-instructors-modal-wrap .tutor-modal-search-input', function(e){ |
| 1234 | e.preventDefault(); |
| 1235 | |
| 1236 | var $that = $(this); |
| 1237 | var $modal = $('.tutor-modal-wrap'); |
| 1238 | |
| 1239 | tutor_delay(function(){ |
| 1240 | var search_terms = $that.val(); |
| 1241 | var course_id = $('#post_ID').val(); |
| 1242 | |
| 1243 | $.ajax({ |
| 1244 | url : ajaxurl, |
| 1245 | type : 'POST', |
| 1246 | data : {course_id : course_id, search_terms : search_terms, action: 'tutor_load_instructors_modal'}, |
| 1247 | beforeSend: function () { |
| 1248 | $modal.addClass('loading'); |
| 1249 | }, |
| 1250 | success: function (data) { |
| 1251 | if (data.success){ |
| 1252 | $('.tutor-instructors-modal-wrap .modal-container').html(data.data.output); |
| 1253 | $('.tutor-instructors-modal-wrap').addClass('show'); |
| 1254 | } |
| 1255 | }, |
| 1256 | complete: function () { |
| 1257 | $modal.removeClass('loading'); |
| 1258 | } |
| 1259 | }); |
| 1260 | |
| 1261 | }, 1000) |
| 1262 | }); |
| 1263 | $(document).on('click', '.add_instructor_to_course_btn', function(e){ |
| 1264 | e.preventDefault(); |
| 1265 | |
| 1266 | var $that = $(this); |
| 1267 | var $modal = $('.tutor-modal-wrap'); |
| 1268 | var course_id = $('#post_ID').val(); |
| 1269 | var data = $modal.find('input').serialize()+'&course_id='+course_id+'&action=tutor_add_instructors_to_course'; |
| 1270 | |
| 1271 | $.ajax({ |
| 1272 | url : ajaxurl, |
| 1273 | type : 'POST', |
| 1274 | data : data, |
| 1275 | beforeSend: function () { |
| 1276 | $that.addClass('tutor-updating-message'); |
| 1277 | }, |
| 1278 | success: function (data) { |
| 1279 | if (data.success){ |
| 1280 | $('.tutor-course-available-instructors').html(data.data.output); |
| 1281 | $('.tutor-modal-wrap').removeClass('show'); |
| 1282 | } |
| 1283 | }, |
| 1284 | complete: function () { |
| 1285 | $that.removeClass('tutor-updating-message'); |
| 1286 | } |
| 1287 | }); |
| 1288 | }); |
| 1289 | |
| 1290 | $(document).on('click', '.tutor-instructor-delete-btn', function(e){ |
| 1291 | e.preventDefault(); |
| 1292 | |
| 1293 | var $that = $(this); |
| 1294 | var course_id = $('#post_ID').val(); |
| 1295 | var instructor_id = $that.closest('.added-instructor-item').attr('data-instructor-id'); |
| 1296 | |
| 1297 | $.ajax({ |
| 1298 | url : ajaxurl, |
| 1299 | type : 'POST', |
| 1300 | data : {course_id:course_id, instructor_id:instructor_id, action : 'detach_instructor_from_course'}, |
| 1301 | success: function (data) { |
| 1302 | if (data.success){ |
| 1303 | $that.closest('.added-instructor-item').remove(); |
| 1304 | } |
| 1305 | } |
| 1306 | }); |
| 1307 | }); |
| 1308 | |
| 1309 | |
| 1310 | /** |
| 1311 | * Attachment in forntend course builder |
| 1312 | * @since v.1.3.4 |
| 1313 | */ |
| 1314 | $(document).on('click', 'a.tutor-delete-attachment', function(e){ |
| 1315 | e.preventDefault(); |
| 1316 | $(this).closest('.tutor-added-attachment').remove(); |
| 1317 | }); |
| 1318 | $(document).on('click', '.tutorUploadAttachmentBtn', function(e){ |
| 1319 | e.preventDefault(); |
| 1320 | |
| 1321 | var $that = $(this); |
| 1322 | var frame; |
| 1323 | if ( frame ) { |
| 1324 | frame.open(); |
| 1325 | return; |
| 1326 | } |
| 1327 | frame = wp.media({ |
| 1328 | title: 'Select or Upload Media Of Your Chosen Persuasion', |
| 1329 | button: { |
| 1330 | text: 'Use this media' |
| 1331 | }, |
| 1332 | multiple: true // Set to true to allow multiple files to be selected |
| 1333 | }); |
| 1334 | frame.on( 'select', function() { |
| 1335 | var attachments = frame.state().get('selection').toJSON(); |
| 1336 | if (attachments.length){ |
| 1337 | for (var i=0; i < attachments.length; i++){ |
| 1338 | var attachment = attachments[i]; |
| 1339 | |
| 1340 | 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>'; |
| 1341 | $that.closest('.tutor-lesson-attachments-metabox').find('.tutor-added-attachments-wrap').append(inputHtml); |
| 1342 | } |
| 1343 | } |
| 1344 | }); |
| 1345 | frame.open(); |
| 1346 | }); |
| 1347 | |
| 1348 | |
| 1349 | /** |
| 1350 | * Single Assignment Upload Button |
| 1351 | * @since v.1.3.4 |
| 1352 | */ |
| 1353 | $('form').on('change', '.tutor-assignment-file-upload', function () { |
| 1354 | $(this).siblings("label").find('span').html($(this).val().replace(/.*(\/|\\)/, '')); |
| 1355 | }); |
| 1356 | |
| 1357 | /** |
| 1358 | * Lesson Sidebar Topic Toggle |
| 1359 | * @since v.1.3.4 |
| 1360 | */ |
| 1361 | |
| 1362 | $(document).on('click', '.tutor-topics-in-single-lesson .tutor-topics-title h3, .tutor-single-lesson-topic-toggle', function (e) { |
| 1363 | var $that = $(this); |
| 1364 | var $parent = $that.closest('.tutor-topics-in-single-lesson'); |
| 1365 | $parent.toggleClass('tutor-topic-active'); |
| 1366 | $parent.find('.tutor-lessons-under-topic').slideToggle(); |
| 1367 | }); |
| 1368 | |
| 1369 | $('.tutor-single-lesson-items.active').closest('.tutor-lessons-under-topic').show(); |
| 1370 | $('.tutor-single-lesson-items.active').closest('.tutor-topics-in-single-lesson').addClass('tutor-topic-active'); |
| 1371 | |
| 1372 | /** |
| 1373 | * Frontend Course Builder |
| 1374 | * @backend Support |
| 1375 | * |
| 1376 | * @since v.1.3.4 |
| 1377 | */ |
| 1378 | |
| 1379 | $(document).on('click', '.tutor-add-quiz-btn', function(e){ |
| 1380 | e.preventDefault(); |
| 1381 | |
| 1382 | var $that = $(this); |
| 1383 | var quiz_for_post_id = $(this).closest('.tutor_add_quiz_wrap').attr('data-add-quiz-under'); |
| 1384 | $.ajax({ |
| 1385 | url : ajaxurl, |
| 1386 | type : 'POST', |
| 1387 | data : {quiz_for_post_id : quiz_for_post_id, action: 'tutor_load_quiz_builder_modal'}, |
| 1388 | beforeSend: function () { |
| 1389 | $that.addClass('tutor-updating-message'); |
| 1390 | }, |
| 1391 | success: function (data) { |
| 1392 | $('.tutor-quiz-builder-modal-wrap .modal-container').html(data.data.output); |
| 1393 | $('.tutor-quiz-builder-modal-wrap').attr('quiz-for-post-id', quiz_for_post_id).addClass('show'); |
| 1394 | }, |
| 1395 | complete: function () { |
| 1396 | $that.removeClass('tutor-updating-message'); |
| 1397 | } |
| 1398 | }); |
| 1399 | }); |
| 1400 | |
| 1401 | /** |
| 1402 | * Quiz Builder Modal Tabs |
| 1403 | */ |
| 1404 | $(document).on('click', '.tutor-quiz-modal-tab-item', function(e){ |
| 1405 | e.preventDefault(); |
| 1406 | |
| 1407 | var $that = $(this); |
| 1408 | |
| 1409 | var $quizTitle = $('[name="quiz_title"]'); |
| 1410 | var quiz_title = $quizTitle.val(); |
| 1411 | if ( ! quiz_title){ |
| 1412 | $quizTitle.closest('.tutor-quiz-builder-form-row').find('.quiz_form_msg').html('<p class="quiz-form-warning">Please save the quiz' + |
| 1413 | ' first</p>'); |
| 1414 | return; |
| 1415 | }else{ |
| 1416 | $quizTitle.closest('.tutor-quiz-builder-form-row').find('.quiz_form_msg').html(''); |
| 1417 | } |
| 1418 | |
| 1419 | var tabSelector = $that.attr('href'); |
| 1420 | $('.quiz-builder-tab-container').hide(); |
| 1421 | $(tabSelector).show(); |
| 1422 | |
| 1423 | $('a.tutor-quiz-modal-tab-item').removeClass('active'); |
| 1424 | $that.addClass('active'); |
| 1425 | }); |
| 1426 | |
| 1427 | //Next Prev Tab |
| 1428 | $(document).on('click', '.quiz-modal-btn-next, .quiz-modal-btn-back', function(e){ |
| 1429 | e.preventDefault(); |
| 1430 | |
| 1431 | var tabSelector = $(this).attr('href'); |
| 1432 | $('#tutor-quiz-modal-tab-items-wrap a[href="'+tabSelector+'"]').trigger('click'); |
| 1433 | }); |
| 1434 | |
| 1435 | $(document).on('click', '.quiz-modal-tab-navigation-btn.quiz-modal-btn-cancel', function(e){ |
| 1436 | e.preventDefault(); |
| 1437 | $('.tutor-modal-wrap').removeClass('show'); |
| 1438 | }); |
| 1439 | |
| 1440 | $(document).on('click', '.quiz-modal-btn-first-step', function(e){ |
| 1441 | e.preventDefault(); |
| 1442 | |
| 1443 | var $that = $(this); |
| 1444 | var $quizTitle = $('[name="quiz_title"]'); |
| 1445 | var quiz_title = $quizTitle.val(); |
| 1446 | var quiz_description = $('[name="quiz_description"]').val(); |
| 1447 | |
| 1448 | if ( ! quiz_title){ |
| 1449 | $quizTitle.closest('.tutor-quiz-builder-group').find('.quiz_form_msg').html('Please enter quiz title'); |
| 1450 | return; |
| 1451 | }else{ |
| 1452 | $quizTitle.closest('.tutor-quiz-builder-group').find('.quiz_form_msg').html(''); |
| 1453 | } |
| 1454 | |
| 1455 | var course_id = $('#post_ID').val(); |
| 1456 | var topic_id = $that.closest('.tutor-modal-wrap').attr('quiz-for-post-id'); |
| 1457 | |
| 1458 | if ($('#tutor_quiz_builder_quiz_id').length) { |
| 1459 | /** |
| 1460 | * |
| 1461 | * @type {jQuery} |
| 1462 | * |
| 1463 | * if quiz id exists, we are sending it to update quiz |
| 1464 | */ |
| 1465 | |
| 1466 | var quiz_id = $('#tutor_quiz_builder_quiz_id').val(); |
| 1467 | $.ajax({ |
| 1468 | url : ajaxurl, |
| 1469 | type : 'POST', |
| 1470 | data : {quiz_title:quiz_title, quiz_description: quiz_description, quiz_id : quiz_id, topic_id : topic_id, action: 'tutor_quiz_builder_quiz_update'}, |
| 1471 | beforeSend: function () { |
| 1472 | $that.addClass('tutor-updating-message'); |
| 1473 | }, |
| 1474 | success: function (data) { |
| 1475 | $('#tutor-quiz-'+quiz_id).html(data.data.output_quiz_row); |
| 1476 | $('#tutor-quiz-modal-tab-items-wrap a[href="#quiz-builder-tab-questions"]').trigger('click'); |
| 1477 | }, |
| 1478 | complete: function () { |
| 1479 | $that.removeClass('tutor-updating-message'); |
| 1480 | } |
| 1481 | }); |
| 1482 | |
| 1483 | return; |
| 1484 | } |
| 1485 | |
| 1486 | $.ajax({ |
| 1487 | url : ajaxurl, |
| 1488 | type : 'POST', |
| 1489 | data : {quiz_title:quiz_title, quiz_description: quiz_description, course_id : course_id, topic_id : topic_id, action: 'tutor_create_quiz_and_load_modal'}, |
| 1490 | beforeSend: function () { |
| 1491 | $that.addClass('tutor-updating-message'); |
| 1492 | }, |
| 1493 | success: function (data) { |
| 1494 | $('.tutor-quiz-builder-modal-wrap .modal-container').html(data.data.output); |
| 1495 | $('#tutor-topics-'+topic_id+' .tutor-lessons').append(data.data.output_quiz_row); |
| 1496 | $('#tutor-quiz-modal-tab-items-wrap a[href="#quiz-builder-tab-questions"]').trigger('click'); |
| 1497 | }, |
| 1498 | complete: function () { |
| 1499 | $that.removeClass('tutor-updating-message'); |
| 1500 | } |
| 1501 | }); |
| 1502 | |
| 1503 | }); |
| 1504 | |
| 1505 | /** |
| 1506 | * Ope modal for edit quiz |
| 1507 | */ |
| 1508 | $(document).on('click', '.open-tutor-quiz-modal', function(e){ |
| 1509 | e.preventDefault(); |
| 1510 | |
| 1511 | var $that = $(this); |
| 1512 | var quiz_id = $that.attr('data-quiz-id'); |
| 1513 | var topic_id = $that.attr('data-topic-id'); |
| 1514 | var course_id = $('#post_ID').val(); |
| 1515 | |
| 1516 | $.ajax({ |
| 1517 | url : ajaxurl, |
| 1518 | type : 'POST', |
| 1519 | data : {quiz_id : quiz_id, topic_id : topic_id, course_id : course_id, action: 'tutor_load_edit_quiz_modal'}, |
| 1520 | beforeSend: function () { |
| 1521 | $that.addClass('tutor-updating-message'); |
| 1522 | }, |
| 1523 | success: function (data) { |
| 1524 | $('.tutor-quiz-builder-modal-wrap .modal-container').html(data.data.output); |
| 1525 | $('.tutor-quiz-builder-modal-wrap').attr('data-quiz-id', quiz_id).addClass('show'); |
| 1526 | |
| 1527 | //Back to question Tab if exists |
| 1528 | if ($that.attr('data-back-to-tab')){ |
| 1529 | var tabSelector = $that.attr('data-back-to-tab'); |
| 1530 | $('#tutor-quiz-modal-tab-items-wrap a[href="'+tabSelector+'"]').trigger('click'); |
| 1531 | } |
| 1532 | tutor_slider_init(); |
| 1533 | enable_quiz_questions_sorting(); |
| 1534 | }, |
| 1535 | complete: function () { |
| 1536 | $that.removeClass('tutor-updating-message'); |
| 1537 | } |
| 1538 | }); |
| 1539 | }); |
| 1540 | |
| 1541 | $(document).on('click', '.quiz-modal-settings-save-btn', function(e){ |
| 1542 | e.preventDefault(); |
| 1543 | |
| 1544 | var $that = $(this); |
| 1545 | var quiz_id = $('.tutor-quiz-builder-modal-wrap').attr('data-quiz-id'); |
| 1546 | |
| 1547 | var $formInput = $('#quiz-builder-tab-settings :input, #quiz-builder-tab-advanced-options :input').serialize()+'&quiz_id='+quiz_id+'&action=tutor_quiz_modal_update_settings'; |
| 1548 | |
| 1549 | $.ajax({ |
| 1550 | url : ajaxurl, |
| 1551 | type : 'POST', |
| 1552 | data : $formInput, |
| 1553 | beforeSend: function () { |
| 1554 | $that.addClass('tutor-updating-message'); |
| 1555 | }, |
| 1556 | success: function (data) { |
| 1557 | // |
| 1558 | }, |
| 1559 | complete: function () { |
| 1560 | $that.removeClass('tutor-updating-message'); |
| 1561 | if ($that.attr('data-action') === 'modal_close'){ |
| 1562 | $('.tutor-modal-wrap').removeClass('show'); |
| 1563 | } |
| 1564 | } |
| 1565 | }); |
| 1566 | }); |
| 1567 | |
| 1568 | |
| 1569 | /** |
| 1570 | * Add Question to quiz modal |
| 1571 | */ |
| 1572 | $(document).on('click', '.tutor-quiz-open-question-form', function(e){ |
| 1573 | e.preventDefault(); |
| 1574 | |
| 1575 | var $that = $(this); |
| 1576 | |
| 1577 | var quiz_id = $('#tutor_quiz_builder_quiz_id').val(); |
| 1578 | var course_id = $('#post_ID').val(); |
| 1579 | var question_id = $that.attr('data-question-id'); |
| 1580 | |
| 1581 | |
| 1582 | var params = {quiz_id : quiz_id, course_id : course_id, action: 'tutor_quiz_builder_get_question_form'}; |
| 1583 | |
| 1584 | if (question_id) { |
| 1585 | params.question_id = question_id; |
| 1586 | } |
| 1587 | |
| 1588 | $.ajax({ |
| 1589 | url : ajaxurl, |
| 1590 | type : 'POST', |
| 1591 | data : params, |
| 1592 | beforeSend: function () { |
| 1593 | $that.addClass('tutor-updating-message'); |
| 1594 | }, |
| 1595 | success: function (data) { |
| 1596 | $('.tutor-quiz-builder-modal-contents').html(data.data.output); |
| 1597 | |
| 1598 | //Initializing Tutor Select |
| 1599 | tutor_select().reInit(); |
| 1600 | enable_quiz_answer_sorting(); |
| 1601 | }, |
| 1602 | complete: function () { |
| 1603 | $that.removeClass('tutor-updating-message'); |
| 1604 | } |
| 1605 | }); |
| 1606 | |
| 1607 | }); |
| 1608 | |
| 1609 | $(document).on('click', '.quiz-modal-question-save-btn', function(e){ |
| 1610 | e.preventDefault(); |
| 1611 | |
| 1612 | var $that = $(this); |
| 1613 | var $formInput = $('.quiz_question_form :input').serialize()+'&action=tutor_quiz_modal_update_question'; |
| 1614 | $.ajax({ |
| 1615 | url : ajaxurl, |
| 1616 | type : 'POST', |
| 1617 | data : $formInput, |
| 1618 | beforeSend: function () { |
| 1619 | $that.addClass('tutor-updating-message'); |
| 1620 | }, |
| 1621 | success: function (data) { |
| 1622 | //ReOpen questions |
| 1623 | $that.closest('.quiz-questions-form').find('.open-tutor-quiz-modal').trigger('click'); |
| 1624 | }, |
| 1625 | complete: function () { |
| 1626 | $that.removeClass('tutor-updating-message'); |
| 1627 | } |
| 1628 | }); |
| 1629 | }); |
| 1630 | |
| 1631 | $(document).on('click', '.tutor-quiz-question-trash', function(e){ |
| 1632 | e.preventDefault(); |
| 1633 | |
| 1634 | var $that = $(this); |
| 1635 | var question_id = $that.attr('data-question-id'); |
| 1636 | |
| 1637 | $.ajax({ |
| 1638 | url : ajaxurl, |
| 1639 | type : 'POST', |
| 1640 | data : {question_id : question_id, action: 'tutor_quiz_builder_question_delete'}, |
| 1641 | beforeSend: function () { |
| 1642 | $that.closest('.quiz-builder-question-wrap').remove(); |
| 1643 | }, |
| 1644 | }); |
| 1645 | }); |
| 1646 | |
| 1647 | /** |
| 1648 | * Get question answers option form to save multiple/single/true-false options |
| 1649 | * |
| 1650 | * @since v.1.0.0 |
| 1651 | */ |
| 1652 | |
| 1653 | $(document).on('click', '.add_question_answers_option', function(e){ |
| 1654 | e.preventDefault(); |
| 1655 | |
| 1656 | var $that = $(this); |
| 1657 | var question_id = $that.attr('data-question-id'); |
| 1658 | var $formInput = $('.quiz_question_form :input').serialize()+'&question_id='+question_id+'&action=tutor_quiz_add_question_answers'; |
| 1659 | |
| 1660 | $.ajax({ |
| 1661 | url : ajaxurl, |
| 1662 | type : 'POST', |
| 1663 | data : $formInput, |
| 1664 | beforeSend: function () { |
| 1665 | $that.addClass('tutor-updating-message'); |
| 1666 | }, |
| 1667 | success: function (data) { |
| 1668 | $('#tutor_quiz_question_answer_form').html(data.data.output); |
| 1669 | }, |
| 1670 | complete: function () { |
| 1671 | $that.removeClass('tutor-updating-message'); |
| 1672 | } |
| 1673 | }); |
| 1674 | }); |
| 1675 | |
| 1676 | /** |
| 1677 | * Get question answers option edit form |
| 1678 | * |
| 1679 | * @since v.1.0.0 |
| 1680 | */ |
| 1681 | $(document).on('click', '.tutor-quiz-answer-edit a', function(e){ |
| 1682 | e.preventDefault(); |
| 1683 | |
| 1684 | var $that = $(this); |
| 1685 | var answer_id = $that.closest('.tutor-quiz-answer-wrap').attr('data-answer-id'); |
| 1686 | |
| 1687 | $.ajax({ |
| 1688 | url : ajaxurl, |
| 1689 | type : 'POST', |
| 1690 | data : {answer_id : answer_id, action : 'tutor_quiz_edit_question_answer'}, |
| 1691 | beforeSend: function () { |
| 1692 | $that.addClass('tutor-updating-message'); |
| 1693 | }, |
| 1694 | success: function (data) { |
| 1695 | $('#tutor_quiz_question_answer_form').html(data.data.output); |
| 1696 | }, |
| 1697 | complete: function () { |
| 1698 | $that.removeClass('tutor-updating-message'); |
| 1699 | } |
| 1700 | }); |
| 1701 | }); |
| 1702 | |
| 1703 | |
| 1704 | /** |
| 1705 | * Saving question answers options |
| 1706 | * Student should select the right answer at quiz attempts |
| 1707 | * |
| 1708 | * @since v.1.0.0 |
| 1709 | */ |
| 1710 | |
| 1711 | $(document).on('click', '#quiz-answer-save-btn', function(e){ |
| 1712 | e.preventDefault(); |
| 1713 | |
| 1714 | var $that = $(this); |
| 1715 | var $formInput = $('.quiz_question_form :input').serialize()+'&action=tutor_save_quiz_answer_options'; |
| 1716 | |
| 1717 | $.ajax({ |
| 1718 | url : ajaxurl, |
| 1719 | type : 'POST', |
| 1720 | data : $formInput, |
| 1721 | beforeSend: function () { |
| 1722 | $that.addClass('tutor-updating-message'); |
| 1723 | }, |
| 1724 | success: function (data) { |
| 1725 | $('#tutor_quiz_question_answers').trigger('refresh'); |
| 1726 | }, |
| 1727 | complete: function () { |
| 1728 | $that.removeClass('tutor-updating-message'); |
| 1729 | } |
| 1730 | }); |
| 1731 | }); |
| 1732 | |
| 1733 | /** |
| 1734 | * Updating Answer |
| 1735 | * |
| 1736 | * @since v.1.0.0 |
| 1737 | */ |
| 1738 | $(document).on('click', '#quiz-answer-edit-btn', function(e){ |
| 1739 | e.preventDefault(); |
| 1740 | |
| 1741 | var $that = $(this); |
| 1742 | var $formInput = $('.quiz_question_form :input').serialize()+'&action=tutor_update_quiz_answer_options'; |
| 1743 | |
| 1744 | $.ajax({ |
| 1745 | url : ajaxurl, |
| 1746 | type : 'POST', |
| 1747 | data : $formInput, |
| 1748 | beforeSend: function () { |
| 1749 | $that.addClass('tutor-updating-message'); |
| 1750 | }, |
| 1751 | success: function (data) { |
| 1752 | $('#tutor_quiz_question_answers').trigger('refresh'); |
| 1753 | }, |
| 1754 | complete: function () { |
| 1755 | $that.removeClass('tutor-updating-message'); |
| 1756 | } |
| 1757 | }); |
| 1758 | }); |
| 1759 | |
| 1760 | $(document).on('change', '.tutor-quiz-answers-mark-correct-wrap input', function(e){ |
| 1761 | e.preventDefault(); |
| 1762 | |
| 1763 | var $that = $(this); |
| 1764 | |
| 1765 | var answer_id = $that.val(); |
| 1766 | var inputValue = 1; |
| 1767 | if ( ! $that.prop('checked')) { |
| 1768 | inputValue = 0; |
| 1769 | } |
| 1770 | |
| 1771 | $.ajax({ |
| 1772 | url : ajaxurl, |
| 1773 | type : 'POST', |
| 1774 | data : {answer_id:answer_id, inputValue : inputValue, action : 'tutor_mark_answer_as_correct'}, |
| 1775 | }); |
| 1776 | }); |
| 1777 | |
| 1778 | |
| 1779 | $(document).on('refresh', '#tutor_quiz_question_answers', function(e){ |
| 1780 | e.preventDefault(); |
| 1781 | |
| 1782 | var $that = $(this); |
| 1783 | var question_id = $that.attr('data-question-id'); |
| 1784 | var question_type = $('.tutor_select_value_holder').val(); |
| 1785 | |
| 1786 | $.ajax({ |
| 1787 | url : ajaxurl, |
| 1788 | type : 'POST', |
| 1789 | data : {question_id : question_id, question_type : question_type, action: 'tutor_quiz_builder_get_answers_by_question'}, |
| 1790 | beforeSend: function () { |
| 1791 | $that.addClass('tutor-updating-message'); |
| 1792 | $('#tutor_quiz_question_answer_form').html(''); |
| 1793 | }, |
| 1794 | success: function (data) { |
| 1795 | if (data.success){ |
| 1796 | $that.html(data.data.output); |
| 1797 | } |
| 1798 | }, |
| 1799 | complete: function () { |
| 1800 | $that.removeClass('tutor-updating-message'); |
| 1801 | } |
| 1802 | }); |
| 1803 | }); |
| 1804 | |
| 1805 | /** |
| 1806 | * Delete answer for a question in quiz builder |
| 1807 | * |
| 1808 | * @since v.1.0.0 |
| 1809 | */ |
| 1810 | |
| 1811 | $(document).on('click', '.tutor-quiz-answer-trash-wrap a.answer-trash-btn', function(e){ |
| 1812 | e.preventDefault(); |
| 1813 | |
| 1814 | var $that = $(this); |
| 1815 | var answer_id = $that.attr('data-answer-id'); |
| 1816 | |
| 1817 | $.ajax({ |
| 1818 | url : ajaxurl, |
| 1819 | type : 'POST', |
| 1820 | data : {answer_id : answer_id, action: 'tutor_quiz_builder_delete_answer'}, |
| 1821 | beforeSend: function () { |
| 1822 | $that.closest('.tutor-quiz-answer-wrap').remove(); |
| 1823 | }, |
| 1824 | }); |
| 1825 | }); |
| 1826 | |
| 1827 | /** |
| 1828 | * Sort quiz questions |
| 1829 | */ |
| 1830 | function enable_quiz_questions_sorting(){ |
| 1831 | if (jQuery().sortable) { |
| 1832 | $(".quiz-builder-questions-wrap").sortable({ |
| 1833 | handle: ".question-sorting", |
| 1834 | start: function (e, ui) { |
| 1835 | ui.placeholder.css('visibility', 'visible'); |
| 1836 | }, |
| 1837 | stop: function (e, ui) { |
| 1838 | tutor_save_sorting_quiz_questions_order(); |
| 1839 | }, |
| 1840 | }); |
| 1841 | } |
| 1842 | } |
| 1843 | |
| 1844 | function tutor_save_sorting_quiz_questions_order(){ |
| 1845 | var questions = {}; |
| 1846 | $('.quiz-builder-question-wrap').each(function(index, item){ |
| 1847 | var $question = $(this); |
| 1848 | var question_id = parseInt($question.attr('data-question-id'), 10); |
| 1849 | questions[index] = question_id; |
| 1850 | }); |
| 1851 | |
| 1852 | $.ajax({url : ajaxurl, type : 'POST', |
| 1853 | data : {sorted_question_ids : questions, action: 'tutor_quiz_question_sorting'}, |
| 1854 | }); |
| 1855 | } |
| 1856 | |
| 1857 | /** |
| 1858 | * Save answer sorting placement |
| 1859 | * |
| 1860 | * @since v.1.0.0 |
| 1861 | */ |
| 1862 | function enable_quiz_answer_sorting(){ |
| 1863 | if (jQuery().sortable) { |
| 1864 | $("#tutor_quiz_question_answers").sortable({ |
| 1865 | handle: ".tutor-quiz-answer-sort-icon", |
| 1866 | start: function (e, ui) { |
| 1867 | ui.placeholder.css('visibility', 'visible'); |
| 1868 | }, |
| 1869 | stop: function (e, ui) { |
| 1870 | tutor_save_sorting_quiz_answer_order(); |
| 1871 | }, |
| 1872 | }); |
| 1873 | } |
| 1874 | } |
| 1875 | function tutor_save_sorting_quiz_answer_order(){ |
| 1876 | var answers = {}; |
| 1877 | $('.tutor-quiz-answer-wrap').each(function(index, item){ |
| 1878 | var $answer = $(this); |
| 1879 | var answer_id = parseInt($answer.attr('data-answer-id'), 10); |
| 1880 | answers[index] = answer_id; |
| 1881 | }); |
| 1882 | |
| 1883 | $.ajax({url : ajaxurl, type : 'POST', |
| 1884 | data : {sorted_answer_ids : answers, action: 'tutor_quiz_answer_sorting'}, |
| 1885 | }); |
| 1886 | } |
| 1887 | |
| 1888 | |
| 1889 | /** |
| 1890 | * Assignments Addons |
| 1891 | * @backend Support |
| 1892 | * |
| 1893 | */ |
| 1894 | |
| 1895 | |
| 1896 | /** |
| 1897 | * Tutor Custom Select |
| 1898 | */ |
| 1899 | |
| 1900 | function tutor_select(){ |
| 1901 | var obj = { |
| 1902 | init : function(){ |
| 1903 | $(document).on('click', '.tutor-select .tutor-select-option', function(e){ |
| 1904 | e.preventDefault(); |
| 1905 | |
| 1906 | var $that = $(this); |
| 1907 | if ($that.attr('data-is-pro') !== 'true') { |
| 1908 | var $html = $that.html().trim(); |
| 1909 | $that.closest('.tutor-select').find('.select-header .lead-option').html($html); |
| 1910 | $that.closest('.tutor-select').find('.select-header input.tutor_select_value_holder').val($that.attr('data-value')).trigger('change'); |
| 1911 | $that.closest('.tutor-select-options').hide(); |
| 1912 | }else{ |
| 1913 | alert('Tutor Pro version required'); |
| 1914 | } |
| 1915 | }); |
| 1916 | $(document).on('click', '.tutor-select .select-header', function(e){ |
| 1917 | e.preventDefault(); |
| 1918 | |
| 1919 | var $that = $(this); |
| 1920 | $that.closest('.tutor-select').find('.tutor-select-options').slideToggle(); |
| 1921 | }); |
| 1922 | |
| 1923 | this.setValue(); |
| 1924 | this.hideOnOutSideClick(); |
| 1925 | }, |
| 1926 | setValue : function(){ |
| 1927 | $('.tutor-select').each(function(){ |
| 1928 | var $that = $(this); |
| 1929 | var $option = $that.find('.tutor-select-option'); |
| 1930 | |
| 1931 | if ($option.length){ |
| 1932 | $option.each(function(){ |
| 1933 | var $thisOption = $(this); |
| 1934 | |
| 1935 | if ($thisOption.attr('data-selected') === 'selected'){ |
| 1936 | var $html = $thisOption.html().trim(); |
| 1937 | $thisOption.closest('.tutor-select').find('.select-header .lead-option').html($html); |
| 1938 | $thisOption.closest('.tutor-select').find('.select-header input.tutor_select_value_holder').val($thisOption.attr('data-value')); |
| 1939 | } |
| 1940 | }); |
| 1941 | } |
| 1942 | }); |
| 1943 | }, |
| 1944 | hideOnOutSideClick : function(){ |
| 1945 | $(document).mouseup(function(e) { |
| 1946 | var $option_wrap = $(".tutor-select-options"); |
| 1947 | if ( ! $(e.target).closest('.select-header').length && !$option_wrap.is(e.target) && $option_wrap.has(e.target).length === 0) { |
| 1948 | $option_wrap.hide(); |
| 1949 | } |
| 1950 | }); |
| 1951 | }, |
| 1952 | reInit : function(){ |
| 1953 | this.setValue(); |
| 1954 | } |
| 1955 | }; |
| 1956 | |
| 1957 | return obj; |
| 1958 | } |
| 1959 | tutor_select().init(); |
| 1960 | |
| 1961 | /** |
| 1962 | * If change question type from quiz builder question |
| 1963 | * |
| 1964 | * @since v.1.0.0 |
| 1965 | */ |
| 1966 | $(document).on('change', 'input.tutor_select_value_holder', function(e) { |
| 1967 | var $that = $(this); |
| 1968 | //$('#tutor_quiz_question_answer_form').html(''); |
| 1969 | $('.add_question_answers_option').trigger('click'); |
| 1970 | $('#tutor_quiz_question_answers').trigger('refresh'); |
| 1971 | }); |
| 1972 | |
| 1973 | $(document).on('click', '.tutor-media-upload-btn', function(e){ |
| 1974 | e.preventDefault(); |
| 1975 | |
| 1976 | var $that = $(this); |
| 1977 | var frame; |
| 1978 | if ( frame ) { |
| 1979 | frame.open(); |
| 1980 | return; |
| 1981 | } |
| 1982 | frame = wp.media({ |
| 1983 | title: 'Select or Upload Media Of Your Chosen Persuasion', |
| 1984 | button: { |
| 1985 | text: 'Use this media' |
| 1986 | }, |
| 1987 | multiple: false |
| 1988 | }); |
| 1989 | frame.on( 'select', function() { |
| 1990 | var attachment = frame.state().get('selection').first().toJSON(); |
| 1991 | $that.html('<img src="'+attachment.url+'" alt="" />'); |
| 1992 | $that.closest('.tutor-media-upload-wrap').find('input').val(attachment.id); |
| 1993 | }); |
| 1994 | frame.open(); |
| 1995 | }); |
| 1996 | $(document).on('click', '.tutor-media-upload-trash', function(e){ |
| 1997 | e.preventDefault(); |
| 1998 | |
| 1999 | var $that = $(this); |
| 2000 | $that.closest('.tutor-media-upload-wrap').find('.tutor-media-upload-btn').html('<i class="tutor-icon-image1"></i>'); |
| 2001 | $that.closest('.tutor-media-upload-wrap').find('input').val(''); |
| 2002 | }); |
| 2003 | |
| 2004 | |
| 2005 | /** |
| 2006 | * Tutor Assignments JS |
| 2007 | * @since v.1.3.3 |
| 2008 | */ |
| 2009 | $(document).on('click', '.tutor-create-assignments-btn', function(e){ |
| 2010 | e.preventDefault(); |
| 2011 | |
| 2012 | var $that = $(this); |
| 2013 | var topic_id = $(this).attr('data-topic-id'); |
| 2014 | var course_id = $('#post_ID').val(); |
| 2015 | |
| 2016 | $.ajax({ |
| 2017 | url : ajaxurl, |
| 2018 | type : 'POST', |
| 2019 | data : {topic_id : topic_id, course_id : course_id, action: 'tutor_load_assignments_builder_modal'}, |
| 2020 | beforeSend: function () { |
| 2021 | $that.addClass('tutor-updating-message'); |
| 2022 | }, |
| 2023 | success: function (data) { |
| 2024 | $('.tutor-lesson-modal-wrap .modal-container').html(data.data.output); |
| 2025 | $('.tutor-lesson-modal-wrap').attr('data-topic-id', topic_id).addClass('show'); |
| 2026 | |
| 2027 | tinymce.init(tinyMCEPreInit.mceInit.course_description); |
| 2028 | tinymce.execCommand( 'mceRemoveEditor', false, 'tutor_assignments_modal_editor' ); |
| 2029 | tinyMCE.execCommand('mceAddEditor', false, "tutor_assignments_modal_editor"); |
| 2030 | }, |
| 2031 | complete: function () { |
| 2032 | quicktags({id : "tutor_assignments_modal_editor"}); |
| 2033 | $that.removeClass('tutor-updating-message'); |
| 2034 | } |
| 2035 | }); |
| 2036 | }); |
| 2037 | |
| 2038 | $(document).on('click', '.open-tutor-assignment-modal', function(e){ |
| 2039 | e.preventDefault(); |
| 2040 | |
| 2041 | var $that = $(this); |
| 2042 | var assignment_id = $that.attr('data-assignment-id'); |
| 2043 | var topic_id = $that.attr('data-topic-id'); |
| 2044 | var course_id = $('#post_ID').val(); |
| 2045 | |
| 2046 | $.ajax({ |
| 2047 | url : ajaxurl, |
| 2048 | type : 'POST', |
| 2049 | data : {assignment_id : assignment_id, topic_id : topic_id, course_id : course_id, action: 'tutor_load_assignments_builder_modal'}, |
| 2050 | beforeSend: function () { |
| 2051 | $that.addClass('tutor-updating-message'); |
| 2052 | }, |
| 2053 | success: function (data) { |
| 2054 | $('.tutor-lesson-modal-wrap .modal-container').html(data.data.output); |
| 2055 | $('.tutor-lesson-modal-wrap').attr({'data-assignment-id' : assignment_id, 'data-topic-id':topic_id}).addClass('show'); |
| 2056 | |
| 2057 | tinymce.init(tinyMCEPreInit.mceInit.course_description); |
| 2058 | tinymce.execCommand( 'mceRemoveEditor', false, 'tutor_assignments_modal_editor' ); |
| 2059 | tinyMCE.execCommand('mceAddEditor', false, "tutor_assignments_modal_editor"); |
| 2060 | }, |
| 2061 | complete: function () { |
| 2062 | quicktags({id : "tutor_assignments_modal_editor"}); |
| 2063 | $that.removeClass('tutor-updating-message'); |
| 2064 | } |
| 2065 | }); |
| 2066 | }); |
| 2067 | |
| 2068 | /** |
| 2069 | * Update Assignment Data |
| 2070 | */ |
| 2071 | $(document).on( 'click', '.update_assignment_modal_btn', function( event ){ |
| 2072 | event.preventDefault(); |
| 2073 | |
| 2074 | var $that = $(this); |
| 2075 | var content; |
| 2076 | var editor = tinyMCE.get('tutor_assignments_modal_editor'); |
| 2077 | if (editor) { |
| 2078 | content = editor.getContent(); |
| 2079 | } else { |
| 2080 | content = $('#'+inputid).val(); |
| 2081 | } |
| 2082 | |
| 2083 | var form_data = $(this).closest('form').serialize(); |
| 2084 | form_data += '&assignment_content='+content; |
| 2085 | |
| 2086 | $.ajax({ |
| 2087 | url : ajaxurl, |
| 2088 | type : 'POST', |
| 2089 | data : form_data, |
| 2090 | beforeSend: function () { |
| 2091 | $that.addClass('tutor-updating-message'); |
| 2092 | }, |
| 2093 | success: function (data) { |
| 2094 | if (data.success){ |
| 2095 | $('#tutor-course-content-wrap').html(data.data.course_contents); |
| 2096 | enable_sorting_topic_lesson(); |
| 2097 | |
| 2098 | //Close the modal |
| 2099 | $('.tutor-lesson-modal-wrap').removeClass('show'); |
| 2100 | } |
| 2101 | }, |
| 2102 | complete: function () { |
| 2103 | $that.removeClass('tutor-updating-message'); |
| 2104 | } |
| 2105 | }); |
| 2106 | }); |
| 2107 | |
| 2108 | /** |
| 2109 | * Add Assignment |
| 2110 | */ |
| 2111 | $(document).on( 'click', '.add-assignment-attachments', function( event ){ |
| 2112 | event.preventDefault(); |
| 2113 | |
| 2114 | var $that = $(this); |
| 2115 | var frame; |
| 2116 | // If the media frame already exists, reopen it. |
| 2117 | if ( frame ) { |
| 2118 | frame.open(); |
| 2119 | return; |
| 2120 | } |
| 2121 | |
| 2122 | // Create a new media frame |
| 2123 | frame = wp.media({ |
| 2124 | title: 'Select or Upload Media Of Your Chosen Persuasion', |
| 2125 | button: { |
| 2126 | text: 'Use this media' |
| 2127 | }, |
| 2128 | multiple: false // Set to true to allow multiple files to be selected |
| 2129 | }); |
| 2130 | |
| 2131 | // When an image is selected in the media frame... |
| 2132 | frame.on( 'select', function() { |
| 2133 | // Get media attachment details from the frame state |
| 2134 | var attachment = frame.state().get('selection').first().toJSON(); |
| 2135 | |
| 2136 | 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"> × Remove</a></div>'; |
| 2137 | |
| 2138 | $('#assignment-attached-file').append(field_markup); |
| 2139 | $that.closest('.video_source_upload_wrap_html5').find('input').val(attachment.id); |
| 2140 | }); |
| 2141 | // Finally, open the modal on click |
| 2142 | frame.open(); |
| 2143 | }); |
| 2144 | |
| 2145 | $(document).on( 'click', '.remove-assignment-attachment-a', function( event ){ |
| 2146 | event.preventDefault(); |
| 2147 | $(this).closest('.tutor-individual-attachment-file').remove(); |
| 2148 | }); |
| 2149 | |
| 2150 | |
| 2151 | /** |
| 2152 | * |
| 2153 | * @type {jQuery} |
| 2154 | * |
| 2155 | * Course builder auto draft save |
| 2156 | * |
| 2157 | * @since v.1.3.4 |
| 2158 | */ |
| 2159 | var tutor_course_builder = $('input[name="tutor_action"]').val(); |
| 2160 | if (tutor_course_builder === 'tutor_add_course_builder'){ |
| 2161 | setInterval(auto_draft_save_course_builder, 30000); |
| 2162 | } |
| 2163 | |
| 2164 | function auto_draft_save_course_builder(){ |
| 2165 | var form_data = $('form#tutor-frontend-course-builder').serialize(); |
| 2166 | $.ajax({ |
| 2167 | //url : _tutorobject.ajaxurl, |
| 2168 | type : 'POST', |
| 2169 | data : form_data+'&tutor_ajax_action=tutor_course_builder_draft_save', |
| 2170 | beforeSend: function () { |
| 2171 | $('.tutor-dashboard-builder-draft-btn span').text('Saving...'); |
| 2172 | }, |
| 2173 | success: function (data) { |
| 2174 | |
| 2175 | }, |
| 2176 | complete: function () { |
| 2177 | $('.tutor-dashboard-builder-draft-btn span').text('Save'); |
| 2178 | } |
| 2179 | }); |
| 2180 | } |
| 2181 | |
| 2182 | /** |
| 2183 | * |
| 2184 | * @type {jQuery} |
| 2185 | * |
| 2186 | * Course builder section toggle |
| 2187 | * |
| 2188 | * @since v.1.3.5 |
| 2189 | */ |
| 2190 | |
| 2191 | $('.tutor-course-builder-section-title').on('click', function () { |
| 2192 | if($(this).find('i').hasClass("tutor-icon-up")){ |
| 2193 | $(this).find('i').removeClass('tutor-icon-up').addClass('tutor-icon-down'); |
| 2194 | }else{ |
| 2195 | $(this).find('i').removeClass('tutor-icon-down').addClass('tutor-icon-up'); |
| 2196 | } |
| 2197 | $(this).next('div').slideToggle(); |
| 2198 | }) |
| 2199 | |
| 2200 | |
| 2201 | }); |