Chart.bundle.min.js
7 years ago
gutenberg_blocks.js
7 years ago
mce-button.js
7 years ago
tutor-admin.js
7 years ago
tutor-front.js
7 years ago
tutor-admin.js
1677 lines
| 1 | jQuery(document).ready(function($){ |
| 2 | 'use strict'; |
| 3 | |
| 4 | if (jQuery().select2){ |
| 5 | $('.tutor_select2').select2(); |
| 6 | } |
| 7 | |
| 8 | /** |
| 9 | * Option Settings Nav Tab |
| 10 | */ |
| 11 | $('.tutor-option-nav-tabs li a').click(function(e){ |
| 12 | e.preventDefault(); |
| 13 | var tab_page_id = $(this).attr('href'); |
| 14 | $('.option-nav-item').removeClass('current'); |
| 15 | $(this).closest('li').addClass('current'); |
| 16 | $('.tutor-option-nav-page').hide(); |
| 17 | $(tab_page_id).addClass('current-page').show(); |
| 18 | }); |
| 19 | |
| 20 | $('#save_tutor_option').click(function (e) { |
| 21 | e.preventDefault(); |
| 22 | $(this).closest('form').submit(); |
| 23 | }); |
| 24 | $('#tutor-option-form').submit(function(e){ |
| 25 | e.preventDefault(); |
| 26 | |
| 27 | var $form = $(this); |
| 28 | var data = $form.serialize(); |
| 29 | |
| 30 | $.ajax({ |
| 31 | url : ajaxurl, |
| 32 | type : 'POST', |
| 33 | data : data, |
| 34 | beforeSend: function () { |
| 35 | $form.find('.button').addClass('tutor-updating-message'); |
| 36 | }, |
| 37 | success: function (data) { |
| 38 | if (data.success) { |
| 39 | window.location.reload(); |
| 40 | } |
| 41 | }, |
| 42 | complete: function () { |
| 43 | $form.find('.button').removeClass('tutor-updating-message'); |
| 44 | } |
| 45 | }); |
| 46 | }); |
| 47 | |
| 48 | /** |
| 49 | * Withdraw nav tabs |
| 50 | * @since v.1.1.2 |
| 51 | */ |
| 52 | $(document).on('click', '.withdraw-method-nav li a', function(e){ |
| 53 | e.preventDefault(); |
| 54 | var tab_page_id = $(this).attr('data-target-id'); |
| 55 | $('.withdraw-method-form-wrap').hide(); |
| 56 | $('#'+tab_page_id).show(); |
| 57 | }); |
| 58 | |
| 59 | /** |
| 60 | * End Withdraw nav tabs |
| 61 | */ |
| 62 | |
| 63 | function tutor_slider_init(){ |
| 64 | $('.tutor-field-slider').each(function(){ |
| 65 | var $slider = $(this); |
| 66 | var $input = $slider.closest('.tutor-field-type-slider').find('input[type="hidden"]'); |
| 67 | var $showVal = $slider.closest('.tutor-field-type-slider').find('.tutor-field-type-slider-value'); |
| 68 | var min = parseFloat($slider.closest('.tutor-field-type-slider').attr('data-min')); |
| 69 | var max = parseFloat($slider.closest('.tutor-field-type-slider').attr('data-max')); |
| 70 | |
| 71 | $slider.slider({ |
| 72 | range: "max", |
| 73 | min: min, |
| 74 | max: max, |
| 75 | value: $input.val(), |
| 76 | slide: function( event, ui ) { |
| 77 | $showVal.text(ui.value); |
| 78 | $input.val(ui.value); |
| 79 | } |
| 80 | }); |
| 81 | }); |
| 82 | } |
| 83 | |
| 84 | tutor_slider_init(); |
| 85 | |
| 86 | /** |
| 87 | * Course and lesson sorting |
| 88 | */ |
| 89 | function enable_sorting_topic_lesson(){ |
| 90 | if (jQuery().sortable) { |
| 91 | $(".course-contents").sortable({ |
| 92 | handle: ".course-move-handle", |
| 93 | start: function (e, ui) { |
| 94 | ui.placeholder.css('visibility', 'visible'); |
| 95 | }, |
| 96 | stop: function (e, ui) { |
| 97 | tutor_sorting_topics_and_lesson(); |
| 98 | }, |
| 99 | }); |
| 100 | $(".tutor-lessons:not(.drop-lessons)").sortable({ |
| 101 | connectWith: ".tutor-lessons", |
| 102 | items: "div.course-content-item", |
| 103 | start: function (e, ui) { |
| 104 | ui.placeholder.css('visibility', 'visible'); |
| 105 | }, |
| 106 | stop: function (e, ui) { |
| 107 | tutor_sorting_topics_and_lesson(); |
| 108 | }, |
| 109 | }); |
| 110 | } |
| 111 | } |
| 112 | enable_sorting_topic_lesson(); |
| 113 | function tutor_sorting_topics_and_lesson(){ |
| 114 | var topics = {}; |
| 115 | $('.tutor-topics-wrap').each(function(index, item){ |
| 116 | var $topic = $(this); |
| 117 | var topics_id = parseInt($topic.attr('id').match(/\d+/)[0], 10); |
| 118 | var lessons = {}; |
| 119 | |
| 120 | $topic.find('.course-content-item').each(function(lessonIndex, lessonItem){ |
| 121 | var $lesson = $(this); |
| 122 | var lesson_id = parseInt($lesson.attr('id').match(/\d+/)[0], 10); |
| 123 | |
| 124 | lessons[lessonIndex] = lesson_id; |
| 125 | }); |
| 126 | topics[index] = { 'topic_id' : topics_id, 'lesson_ids' : lessons }; |
| 127 | }); |
| 128 | $('#tutor_topics_lessons_sorting').val(JSON.stringify(topics)); |
| 129 | } |
| 130 | |
| 131 | $(document).on('click', '.create_new_topic_btn', function (e) { |
| 132 | e.preventDefault(); |
| 133 | $('.tutor-metabox-add-topics').slideToggle(); |
| 134 | }); |
| 135 | |
| 136 | $(document).on('click', '#tutor-add-topic-btn', function (e) { |
| 137 | e.preventDefault(); |
| 138 | var $that = $(this); |
| 139 | var form_data = $that.closest('.tutor-metabox-add-topics').find('input, textarea').serialize()+'&action=tutor_add_course_topic'; |
| 140 | |
| 141 | $.ajax({ |
| 142 | url : ajaxurl, |
| 143 | type : 'POST', |
| 144 | data : form_data, |
| 145 | beforeSend: function () { |
| 146 | $that.addClass('tutor-updating-message'); |
| 147 | }, |
| 148 | success: function (data) { |
| 149 | if (data.success){ |
| 150 | $('#tutor-course-content-wrap').html(data.data.course_contents); |
| 151 | $that.closest('.tutor-metabox-add-topics').find('input[type!="hidden"], textarea').each(function () { |
| 152 | $(this).val(''); |
| 153 | }); |
| 154 | $that.closest('.tutor-metabox-add-topics').slideUp(); |
| 155 | enable_sorting_topic_lesson(); |
| 156 | } |
| 157 | }, |
| 158 | complete: function () { |
| 159 | $that.removeClass('tutor-updating-message'); |
| 160 | } |
| 161 | }); |
| 162 | }); |
| 163 | |
| 164 | $(document).on('change keyup', '.course-edit-topic-title-input', function (e) { |
| 165 | e.preventDefault(); |
| 166 | $(this).closest('.tutor-topics-top').find('.topic-inner-title').html($(this).val()); |
| 167 | }); |
| 168 | |
| 169 | $(document).on('click', '.topic-edit-icon', function (e) { |
| 170 | e.preventDefault(); |
| 171 | $(this).closest('.tutor-topics-top').find('.tutor-topics-edit-form').slideToggle(); |
| 172 | }); |
| 173 | |
| 174 | $(document).on('click', '.tutor-topics-edit-button', function(e){ |
| 175 | e.preventDefault(); |
| 176 | var $button = $(this); |
| 177 | var $topic = $button.closest('.tutor-topics-wrap'); |
| 178 | var topics_id = parseInt($topic.attr('id').match(/\d+/)[0], 10); |
| 179 | var topic_title = $button.closest('.tutor-topics-wrap').find('[name="topic_title"]').val(); |
| 180 | var topic_summery = $button.closest('.tutor-topics-wrap').find('[name="topic_summery"]').val(); |
| 181 | |
| 182 | var data = {topic_title: topic_title, topic_summery : topic_summery, topic_id : topics_id, action: 'tutor_update_topic'}; |
| 183 | $.ajax({ |
| 184 | url : ajaxurl, |
| 185 | type : 'POST', |
| 186 | data : data, |
| 187 | beforeSend: function () { |
| 188 | $button.addClass('tutor-updating-message'); |
| 189 | }, |
| 190 | success: function (data) { |
| 191 | if (data.success){ |
| 192 | $button.closest('.tutor-topics-wrap').find('span.topic-inner-title').text(topic_title); |
| 193 | $button.closest('.tutor-topics-wrap').find('.tutor-topics-edit-form').slideUp(); |
| 194 | } |
| 195 | }, |
| 196 | complete: function () { |
| 197 | $button.removeClass('tutor-updating-message'); |
| 198 | } |
| 199 | }); |
| 200 | }); |
| 201 | |
| 202 | /** |
| 203 | * Confirmation for deleting Topic |
| 204 | */ |
| 205 | $(document).on('click', '.topic-delete-btn a', function(e){ |
| 206 | var topic_id = $(this).attr('data-topic-id'); |
| 207 | |
| 208 | if ( ! confirm('Are you sure to delete?')){ |
| 209 | e.preventDefault(); |
| 210 | } |
| 211 | }); |
| 212 | |
| 213 | $(document).on('click', '.tutor-expand-all-topic', function (e) { |
| 214 | e.preventDefault(); |
| 215 | $('.tutor-topics-body').slideDown(); |
| 216 | $('.expand-collapse-wrap i').removeClass('tutor-icon-light-down').addClass('tutor-icon-light-up'); |
| 217 | }); |
| 218 | $(document).on('click', '.tutor-collapse-all-topic', function (e) { |
| 219 | e.preventDefault(); |
| 220 | $('.tutor-topics-body').slideUp(); |
| 221 | $('.expand-collapse-wrap i').removeClass('tutor-icon-light-up').addClass('tutor-icon-light-down'); |
| 222 | }); |
| 223 | $(document).on('click', '.topic-inner-title, .expand-collapse-wrap', function (e) { |
| 224 | e.preventDefault(); |
| 225 | var $that = $(this); |
| 226 | $that.closest('.tutor-topics-wrap').find('.tutor-topics-body').slideToggle(); |
| 227 | $that.closest('.tutor-topics-wrap').find('.expand-collapse-wrap i').toggleClass('tutor-icon-light-down tutor-icon-light-up'); |
| 228 | }); |
| 229 | |
| 230 | /** |
| 231 | * Update Lesson Modal |
| 232 | */ |
| 233 | $(document).on('click', '.open-tutor-lesson-modal', function(e){ |
| 234 | e.preventDefault(); |
| 235 | |
| 236 | var $that = $(this); |
| 237 | var lesson_id = $that.attr('data-lesson-id'); |
| 238 | var topic_id = $that.attr('data-topic-id'); |
| 239 | var course_id = $('#post_ID').val(); |
| 240 | |
| 241 | $.ajax({ |
| 242 | url : ajaxurl, |
| 243 | type : 'POST', |
| 244 | data : {lesson_id : lesson_id, topic_id : topic_id, course_id : course_id, action: 'tutor_load_edit_lesson_modal'}, |
| 245 | beforeSend: function () { |
| 246 | $that.addClass('tutor-updating-message'); |
| 247 | }, |
| 248 | success: function (data) { |
| 249 | $('.tutor-lesson-modal-wrap .modal-container').html(data.data.output); |
| 250 | $('.tutor-lesson-modal-wrap').attr({'data-lesson-id' : lesson_id, 'data-topic-id':topic_id}).addClass('show'); |
| 251 | |
| 252 | tinymce.init(tinyMCEPreInit.mceInit.content); |
| 253 | tinymce.execCommand( 'mceRemoveEditor', false, 'tutor_lesson_modal_editor' ); |
| 254 | tinyMCE.execCommand('mceAddEditor', false, "tutor_lesson_modal_editor"); |
| 255 | }, |
| 256 | complete: function () { |
| 257 | quicktags({id : "tutor_lesson_modal_editor"}); |
| 258 | $that.removeClass('tutor-updating-message'); |
| 259 | } |
| 260 | }); |
| 261 | }); |
| 262 | |
| 263 | $(document).on( 'click', '.lesson_thumbnail_upload_btn', function( event ){ |
| 264 | event.preventDefault(); |
| 265 | var $that = $(this); |
| 266 | var frame; |
| 267 | if ( frame ) { |
| 268 | frame.open(); |
| 269 | return; |
| 270 | } |
| 271 | frame = wp.media({ |
| 272 | title: 'Select or Upload Media Of Your Chosen Persuasion', |
| 273 | button: { |
| 274 | text: 'Use this media' |
| 275 | }, |
| 276 | multiple: false |
| 277 | }); |
| 278 | frame.on( 'select', function() { |
| 279 | var attachment = frame.state().get('selection').first().toJSON(); |
| 280 | $that.closest('.tutor-thumbnail-wrap').find('.thumbnail-img').html('<img src="'+attachment.url+'" alt="" />'); |
| 281 | $that.closest('.tutor-thumbnail-wrap').find('input').val(attachment.id); |
| 282 | }); |
| 283 | frame.open(); |
| 284 | }); |
| 285 | |
| 286 | /** |
| 287 | * Delete Lesson from course builder |
| 288 | */ |
| 289 | $(document).on('click', '.tutor-delete-lesson-btn', function(e){ |
| 290 | e.preventDefault(); |
| 291 | |
| 292 | if( ! confirm('Are you sure?')){ |
| 293 | return; |
| 294 | } |
| 295 | |
| 296 | var $that = $(this); |
| 297 | var lesson_id = $that.attr('data-lesson-id'); |
| 298 | |
| 299 | $.ajax({ |
| 300 | url : ajaxurl, |
| 301 | type : 'POST', |
| 302 | data : {lesson_id : lesson_id, action: 'tutor_delete_lesson_by_id'}, |
| 303 | beforeSend: function () { |
| 304 | $that.addClass('tutor-updating-message'); |
| 305 | }, |
| 306 | success: function (data) { |
| 307 | if (data.success){ |
| 308 | $that.closest('.tutor-lesson').remove(); |
| 309 | } |
| 310 | }, |
| 311 | complete: function () { |
| 312 | $that.removeClass('tutor-updating-message'); |
| 313 | } |
| 314 | }); |
| 315 | }); |
| 316 | |
| 317 | /** |
| 318 | * Delete quiz |
| 319 | */ |
| 320 | $(document).on('click', '.tutor-delete-quiz-btn', function(e){ |
| 321 | e.preventDefault(); |
| 322 | |
| 323 | if( ! confirm('Are you sure?')){ |
| 324 | return; |
| 325 | } |
| 326 | |
| 327 | var $that = $(this); |
| 328 | var quiz_id = $that.attr('data-quiz-id'); |
| 329 | |
| 330 | $.ajax({ |
| 331 | url : ajaxurl, |
| 332 | type : 'POST', |
| 333 | data : {quiz_id : quiz_id, action: 'tutor_delete_quiz_by_id'}, |
| 334 | beforeSend: function () { |
| 335 | $that.closest('.course-content-item').remove(); |
| 336 | } |
| 337 | }); |
| 338 | }); |
| 339 | |
| 340 | /** |
| 341 | * Lesson Update or Create Modal |
| 342 | */ |
| 343 | $(document).on( 'click', '.update_lesson_modal_btn', function( event ){ |
| 344 | event.preventDefault(); |
| 345 | |
| 346 | var $that = $(this); |
| 347 | var content; |
| 348 | var editor = tinyMCE.get('tutor_lesson_modal_editor'); |
| 349 | if (editor) { |
| 350 | content = editor.getContent(); |
| 351 | } else { |
| 352 | content = $('#'+inputid).val(); |
| 353 | } |
| 354 | |
| 355 | var form_data = $(this).closest('form').serialize(); |
| 356 | form_data += '&lesson_content='+content; |
| 357 | |
| 358 | $.ajax({ |
| 359 | url : ajaxurl, |
| 360 | type : 'POST', |
| 361 | data : form_data, |
| 362 | beforeSend: function () { |
| 363 | $that.addClass('tutor-updating-message'); |
| 364 | }, |
| 365 | success: function (data) { |
| 366 | if (data.success){ |
| 367 | $('#tutor-course-content-wrap').html(data.data.course_contents); |
| 368 | enable_sorting_topic_lesson(); |
| 369 | |
| 370 | //Close the modal |
| 371 | $('.tutor-lesson-modal-wrap').removeClass('show'); |
| 372 | } |
| 373 | }, |
| 374 | complete: function () { |
| 375 | $that.removeClass('tutor-updating-message'); |
| 376 | } |
| 377 | }); |
| 378 | }); |
| 379 | |
| 380 | /** |
| 381 | * Lesson Video |
| 382 | */ |
| 383 | $(document).on('change', '.tutor_lesson_video_source', function(e){ |
| 384 | var selector = $(this).val(); |
| 385 | $('[class^="video_source_wrap"]').hide(); |
| 386 | $('.video_source_wrap_'+selector).show(); |
| 387 | |
| 388 | if (selector === 'html5'){ |
| 389 | $('.tutor-video-poster-field').show(); |
| 390 | } else{ |
| 391 | $('.tutor-video-poster-field').hide(); |
| 392 | } |
| 393 | }); |
| 394 | |
| 395 | $(document).on( 'click', '.video_source_wrap_html5 .video_upload_btn', function( event ){ |
| 396 | event.preventDefault(); |
| 397 | |
| 398 | var $that = $(this); |
| 399 | var frame; |
| 400 | // If the media frame already exists, reopen it. |
| 401 | if ( frame ) { |
| 402 | frame.open(); |
| 403 | return; |
| 404 | } |
| 405 | |
| 406 | // Create a new media frame |
| 407 | frame = wp.media({ |
| 408 | title: 'Select or Upload Media Of Your Chosen Persuasion', |
| 409 | button: { |
| 410 | text: 'Use this media' |
| 411 | }, |
| 412 | multiple: false // Set to true to allow multiple files to be selected |
| 413 | }); |
| 414 | |
| 415 | // When an image is selected in the media frame... |
| 416 | frame.on( 'select', function() { |
| 417 | // Get media attachment details from the frame state |
| 418 | var attachment = frame.state().get('selection').first().toJSON(); |
| 419 | $that.closest('.video_source_wrap_html5').find('span.video_media_id').text(attachment.id).closest('p').show(); |
| 420 | $that.closest('.video_source_wrap_html5').find('input').val(attachment.id); |
| 421 | }); |
| 422 | // Finally, open the modal on click |
| 423 | frame.open(); |
| 424 | }); |
| 425 | |
| 426 | //tutor_video_poster_upload_btn |
| 427 | $(document).on( 'click', '.tutor_video_poster_upload_btn', function( event ){ |
| 428 | event.preventDefault(); |
| 429 | |
| 430 | var $that = $(this); |
| 431 | var frame; |
| 432 | // If the media frame already exists, reopen it. |
| 433 | if ( frame ) { |
| 434 | frame.open(); |
| 435 | return; |
| 436 | } |
| 437 | |
| 438 | // Create a new media frame |
| 439 | frame = wp.media({ |
| 440 | title: 'Select or Upload Media Of Your Chosen Persuasion', |
| 441 | button: { |
| 442 | text: 'Use this media' |
| 443 | }, |
| 444 | multiple: false // Set to true to allow multiple files to be selected |
| 445 | }); |
| 446 | |
| 447 | // When an image is selected in the media frame... |
| 448 | frame.on( 'select', function() { |
| 449 | // Get media attachment details from the frame state |
| 450 | var attachment = frame.state().get('selection').first().toJSON(); |
| 451 | $that.closest('.tutor-video-poster-wrap').find('.video-poster-img').html('<img src="'+attachment.url+'" alt="" />'); |
| 452 | $that.closest('.tutor-video-poster-wrap').find('input').val(attachment.id); |
| 453 | }); |
| 454 | // Finally, open the modal on click |
| 455 | frame.open(); |
| 456 | }); |
| 457 | |
| 458 | $(document).on('click', 'a.tutor-delete-attachment', function(e){ |
| 459 | e.preventDefault(); |
| 460 | $(this).closest('.tutor-added-attachment').remove(); |
| 461 | }); |
| 462 | |
| 463 | $(document).on('click', '.tutorUploadAttachmentBtn', function(e){ |
| 464 | e.preventDefault(); |
| 465 | |
| 466 | var $that = $(this); |
| 467 | var frame; |
| 468 | // If the media frame already exists, reopen it. |
| 469 | if ( frame ) { |
| 470 | frame.open(); |
| 471 | return; |
| 472 | } |
| 473 | // Create a new media frame |
| 474 | frame = wp.media({ |
| 475 | title: 'Select or Upload Media Of Your Chosen Persuasion', |
| 476 | button: { |
| 477 | text: 'Use this media' |
| 478 | }, |
| 479 | multiple: true // Set to true to allow multiple files to be selected |
| 480 | }); |
| 481 | // When an image is selected in the media frame... |
| 482 | frame.on( 'select', function() { |
| 483 | // Get media attachment details from the frame state |
| 484 | var attachments = frame.state().get('selection').toJSON(); |
| 485 | if (attachments.length){ |
| 486 | for (var i=0; i < attachments.length; i++){ |
| 487 | var attachment = attachments[i]; |
| 488 | |
| 489 | var inputHtml = '<div class="tutor-added-attachment"><p> <a href="javascript:;" class="tutor-delete-attachment">×</a> <span> <a href="'+attachment.url+'">'+attachment.filename+'</a> </span> </p><input type="hidden" name="tutor_attachments[]" value="'+attachment.id+'"></div>'; |
| 490 | $that.closest('.tutor-lesson-attachments-metabox').find('.tutor-added-attachments-wrap').append(inputHtml); |
| 491 | } |
| 492 | } |
| 493 | }); |
| 494 | // Finally, open the modal on click |
| 495 | frame.open(); |
| 496 | }); |
| 497 | |
| 498 | /** |
| 499 | * Open Sidebar Menu |
| 500 | */ |
| 501 | if (tutor_data.open_tutor_admin_menu){ |
| 502 | var $adminMenu = $('#adminmenu'); |
| 503 | $adminMenu.find('[href="admin.php?page=tutor"]').closest('li.wp-has-submenu').addClass('wp-has-current-submenu'); |
| 504 | $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'); |
| 505 | } |
| 506 | |
| 507 | /** |
| 508 | * Add question answer for quiz |
| 509 | */ |
| 510 | |
| 511 | $(document).on('change keyup paste', '.question_field_title', function(){ |
| 512 | var $that = $(this); |
| 513 | $that.closest('.single-question-item').find('.tutor-question-item-head').find('.question-title').text($that.val()); |
| 514 | }); |
| 515 | |
| 516 | $(document).on('change', '.question_type_field', function(){ |
| 517 | var $that = $(this); |
| 518 | var question_type = $that.val(); |
| 519 | |
| 520 | var option_text = $that.find('option[value="'+question_type+'"]').text(); |
| 521 | $that.closest('.single-question-item').find('.tutor-question-item-head').find('.question-type').text(option_text); |
| 522 | |
| 523 | var question_id = $that.closest('.single-question-item').attr('data-question-id'); |
| 524 | var data = {question_id: question_id, question_type : question_type, action: 'quiz_question_type_changed'}; |
| 525 | |
| 526 | $.ajax({ |
| 527 | url : ajaxurl, |
| 528 | type : 'POST', |
| 529 | data : data, |
| 530 | beforeSend: function () { |
| 531 | $that.closest('.single-question-item').find('.tutor-loading-icon-wrap').addClass('tutor-updating-message'); |
| 532 | }, |
| 533 | success: function (data) { |
| 534 | if (data.success){ |
| 535 | $that.closest('.quiz-question-form-wrap').find('.answer-entry-wrap').html(data.data.multi_answer_options); |
| 536 | |
| 537 | if (question_type === 'true_false' && $('.answer-option-row').length >= 2){ |
| 538 | $('.add_answer_option_wrap').hide(); |
| 539 | }else{ |
| 540 | $('.add_answer_option_wrap').show(); |
| 541 | } |
| 542 | } |
| 543 | }, |
| 544 | complete: function () { |
| 545 | $that.closest('.single-question-item').find('.tutor-loading-icon-wrap').removeClass('tutor-updating-message'); |
| 546 | } |
| 547 | }); |
| 548 | }); |
| 549 | |
| 550 | $(document).on('click', '.add_answer_option_btn', function(e){ |
| 551 | e.preventDefault(); |
| 552 | |
| 553 | var $that = $(this); |
| 554 | var question_id = $that.closest('.single-question-item').attr('data-question-id'); |
| 555 | var question_type = $that.closest('.quiz-question-form-wrap').find('select.question_type_field').val(); |
| 556 | var data = {question_id: question_id, action: 'quiz_add_answer_to_question'}; |
| 557 | |
| 558 | $.ajax({ |
| 559 | url : ajaxurl, |
| 560 | type : 'POST', |
| 561 | data : data, |
| 562 | beforeSend: function () { |
| 563 | $that.removeClass('updated-message').addClass('tutor-updating-message'); |
| 564 | }, |
| 565 | success: function (data) { |
| 566 | if (data.success){ |
| 567 | $that.closest('.answer-entry-wrap').find('table.multi-answers-options').append(data.data.data_tr); |
| 568 | |
| 569 | //Hide add answer button if true false and 2 option exists |
| 570 | if (question_type === 'true_false' && $that.closest('.answer-entry-wrap').find('tr.answer-option-row').length >= 2){ |
| 571 | $that.closest('.add_answer_option_wrap').hide(); |
| 572 | }else{ |
| 573 | $that.closest('.add_answer_option_wrap').show(); |
| 574 | } |
| 575 | } |
| 576 | }, |
| 577 | complete: function () { |
| 578 | $that.removeClass('tutor-updating-message').addClass('updated-message'); |
| 579 | } |
| 580 | }); |
| 581 | }); |
| 582 | |
| 583 | $(document).on('click', '.add_question_btn', function(e){ |
| 584 | e.preventDefault(); |
| 585 | |
| 586 | var $that = $(this); |
| 587 | var $title = $('[name="new_question_title"]'); |
| 588 | var question_title = $title.val(); |
| 589 | var question_type = $('[name="new_question_type"]').val(); |
| 590 | var quiz_id = $('#post_ID').val(); |
| 591 | |
| 592 | //If no question title, stop here |
| 593 | if ( ! question_title.length){ |
| 594 | $title.addClass('tutor-input-text-error'); |
| 595 | return; |
| 596 | }else{ |
| 597 | $title.removeClass('tutor-input-text-error'); |
| 598 | } |
| 599 | |
| 600 | var data = {question_title : question_title, question_type:question_type, quiz_id : quiz_id, action: 'quiz_page_add_new_question' }; |
| 601 | $.ajax({ |
| 602 | url : ajaxurl, |
| 603 | type : 'POST', |
| 604 | data : data, |
| 605 | beforeSend: function () { |
| 606 | $that.removeClass('updated-message').addClass('tutor-updating-message'); |
| 607 | }, |
| 608 | success: function (data) { |
| 609 | if (data.success){ |
| 610 | $('.single-question-item .quiz-question-form-wrap').hide(); |
| 611 | $('.tutor-quiz-questions-wrap').append(data.data.question_html); |
| 612 | $('.single-question-item:last-child .quiz-question-form-wrap').show(); |
| 613 | $title.val(''); |
| 614 | } |
| 615 | }, |
| 616 | complete: function () { |
| 617 | $that.removeClass('tutor-updating-message').addClass('updated-message'); |
| 618 | } |
| 619 | }); |
| 620 | }); |
| 621 | |
| 622 | //Show hide question settings |
| 623 | $(document).on('click', '.question-action-btn.down', function(e){ |
| 624 | e.preventDefault(); |
| 625 | $(this).closest('.single-question-item').find('.quiz-question-form-wrap').toggle(); |
| 626 | $(this).find('i.dashicons').toggleClass('dashicons-arrow-up-alt2 dashicons-arrow-down-alt2'); |
| 627 | }); |
| 628 | |
| 629 | $(document).on('change', '.single-question-item', function(e){ |
| 630 | e.preventDefault(); |
| 631 | |
| 632 | var $that = $(this); |
| 633 | var data = $(this).find("select, textarea, input").serialize()+'&action=update_tutor_question'; |
| 634 | $.ajax({ |
| 635 | url : ajaxurl, |
| 636 | type : 'POST', |
| 637 | data : data, |
| 638 | beforeSend: function () { |
| 639 | $that.find('.tutor-loading-icon-wrap').addClass('tutor-updating-message'); |
| 640 | }, |
| 641 | success: function (data) { |
| 642 | if (data.success){ |
| 643 | |
| 644 | } |
| 645 | }, |
| 646 | complete: function () { |
| 647 | $that.find('.tutor-loading-icon-wrap').removeClass('tutor-updating-message'); |
| 648 | } |
| 649 | }); |
| 650 | }); |
| 651 | |
| 652 | $(document).on('click', '.quiz-answer-option-delete-btn', function(e){ |
| 653 | e.preventDefault(); |
| 654 | var $that = $(this); |
| 655 | var $closestTable = $that.closest('table'); |
| 656 | var $loadingIcon = $that.closest('.single-question-item').find('.tutor-loading-icon-wrap'); |
| 657 | |
| 658 | var question_type = $that.closest('.quiz-question-form-wrap').find('select.question_type_field').val(); |
| 659 | var answer_option_id = $that.closest('tr').attr('data-answer-option-id'); |
| 660 | |
| 661 | $.ajax({ |
| 662 | url : ajaxurl, |
| 663 | type : 'POST', |
| 664 | data : {answer_option_id:answer_option_id, action: 'quiz_delete_answer_option'}, |
| 665 | beforeSend: function () { |
| 666 | $loadingIcon.addClass('tutor-updating-message'); |
| 667 | }, |
| 668 | success: function (data) { |
| 669 | if (data.success){ |
| 670 | $that.closest('tr').remove(); |
| 671 | //Hide add answer button if true false and 2 option exists |
| 672 | if (question_type === 'true_false' && $closestTable.find('tr.answer-option-row').length >= 2){ |
| 673 | $closestTable.closest('.answer-entry-wrap').find('.add_answer_option_wrap').hide(); |
| 674 | }else{ |
| 675 | $closestTable.closest('.answer-entry-wrap').find('.add_answer_option_wrap').show(); |
| 676 | } |
| 677 | } |
| 678 | }, |
| 679 | complete: function () { |
| 680 | $loadingIcon.removeClass('tutor-updating-message'); |
| 681 | } |
| 682 | }); |
| 683 | }); |
| 684 | |
| 685 | $(document).on('click', '.question-action-btn.trash', function(e){ |
| 686 | e.preventDefault(); |
| 687 | |
| 688 | var $that = $(this); |
| 689 | var question_id = $that.closest('.single-question-item').attr('data-question-id'); |
| 690 | var $loadingIcon = $that.closest('.single-question-item').find('.tutor-loading-icon-wrap'); |
| 691 | |
| 692 | $.ajax({ |
| 693 | url : ajaxurl, |
| 694 | type : 'POST', |
| 695 | data : {question_id:question_id, action: 'quiz_question_delete'}, |
| 696 | beforeSend: function () { |
| 697 | $loadingIcon.addClass('tutor-updating-message'); |
| 698 | }, |
| 699 | success: function (data) { |
| 700 | if (data.success){ |
| 701 | $that.closest('.single-question-item').remove(); |
| 702 | } |
| 703 | }, |
| 704 | complete: function () { |
| 705 | $loadingIcon.removeClass('tutor-updating-message'); |
| 706 | } |
| 707 | }); |
| 708 | }); |
| 709 | |
| 710 | /** |
| 711 | * Sort quiz questions |
| 712 | */ |
| 713 | |
| 714 | if (jQuery().sortable) { |
| 715 | $(".tutor-quiz-questions-wrap").sortable({ |
| 716 | handle: ".question-short", |
| 717 | start: function (e, ui) { |
| 718 | ui.placeholder.css('visibility', 'visible'); |
| 719 | }, |
| 720 | stop: function (e, ui) { |
| 721 | var questions = {}; |
| 722 | $('.single-question-item').each(function(index, item){ |
| 723 | var $question = $(this); |
| 724 | var question_id = parseInt($question.attr('data-question-id').match(/\d+/)[0], 10); |
| 725 | questions[index] = { 'question_id' : question_id }; |
| 726 | }); |
| 727 | |
| 728 | $.post(ajaxurl, {questions : questions, action: 'sorting_quiz_questions'}); |
| 729 | }, |
| 730 | }); |
| 731 | } |
| 732 | |
| 733 | /** |
| 734 | * Quiz Modal |
| 735 | */ |
| 736 | |
| 737 | $(document).on('click', '.modal-close-btn', function(e){ |
| 738 | e.preventDefault(); |
| 739 | $('.tutor-modal-wrap').removeClass('show'); |
| 740 | }); |
| 741 | $(document).on('keyup', function(e){ |
| 742 | if (e.keyCode === 27){ |
| 743 | $('.tutor-modal-wrap').removeClass('show'); |
| 744 | } |
| 745 | }); |
| 746 | |
| 747 | /* |
| 748 | $(document).on('click', '.tutor-add-quiz-btn', function(e){ |
| 749 | e.preventDefault(); |
| 750 | |
| 751 | var $that = $(this); |
| 752 | var quiz_for_post_id = $(this).closest('.tutor_add_quiz_wrap').attr('data-add-quiz-under'); |
| 753 | $.ajax({ |
| 754 | url : ajaxurl, |
| 755 | type : 'POST', |
| 756 | data : {quiz_for_post_id : quiz_for_post_id, action: 'tutor_load_quiz_modal'}, |
| 757 | beforeSend: function () { |
| 758 | $that.addClass('tutor-updating-message'); |
| 759 | }, |
| 760 | success: function (data) { |
| 761 | $('.tutor-quiz-modal-wrap .modal-container').html(data.data.output); |
| 762 | $('.tutor-quiz-modal-wrap').attr('quiz-for-post-id', quiz_for_post_id).addClass('show'); |
| 763 | }, |
| 764 | complete: function () { |
| 765 | $that.removeClass('tutor-updating-message'); |
| 766 | } |
| 767 | }); |
| 768 | }); |
| 769 | */ |
| 770 | |
| 771 | |
| 772 | |
| 773 | $(document).on('click', '.tutor-add-quiz-btn', function(e){ |
| 774 | e.preventDefault(); |
| 775 | |
| 776 | var $that = $(this); |
| 777 | var quiz_for_post_id = $(this).closest('.tutor_add_quiz_wrap').attr('data-add-quiz-under'); |
| 778 | $.ajax({ |
| 779 | url : ajaxurl, |
| 780 | type : 'POST', |
| 781 | data : {quiz_for_post_id : quiz_for_post_id, action: 'tutor_load_quiz_builder_modal'}, |
| 782 | beforeSend: function () { |
| 783 | $that.addClass('tutor-updating-message'); |
| 784 | }, |
| 785 | success: function (data) { |
| 786 | $('.tutor-quiz-builder-modal-wrap .modal-container').html(data.data.output); |
| 787 | $('.tutor-quiz-builder-modal-wrap').attr('quiz-for-post-id', quiz_for_post_id).addClass('show'); |
| 788 | }, |
| 789 | complete: function () { |
| 790 | $that.removeClass('tutor-updating-message'); |
| 791 | } |
| 792 | }); |
| 793 | }); |
| 794 | |
| 795 | /** |
| 796 | * Quiz Builder Modal Tabs |
| 797 | */ |
| 798 | $(document).on('click', '.tutor-quiz-modal-tab-item', function(e){ |
| 799 | e.preventDefault(); |
| 800 | |
| 801 | var $that = $(this); |
| 802 | |
| 803 | var $quizTitle = $('[name="quiz_title"]'); |
| 804 | var quiz_title = $quizTitle.val(); |
| 805 | if ( ! quiz_title){ |
| 806 | $quizTitle.closest('.tutor-quiz-builder-form-row').find('.quiz_form_msg').html('<p class="quiz-form-warning">Please save the quiz' + |
| 807 | ' first</p>'); |
| 808 | return; |
| 809 | }else{ |
| 810 | $quizTitle.closest('.tutor-quiz-builder-form-row').find('.quiz_form_msg').html(''); |
| 811 | } |
| 812 | |
| 813 | var tabSelector = $that.attr('href'); |
| 814 | $('.quiz-builder-tab-container').hide(); |
| 815 | $(tabSelector).show(); |
| 816 | |
| 817 | $('a.tutor-quiz-modal-tab-item').removeClass('active'); |
| 818 | $that.addClass('active'); |
| 819 | }); |
| 820 | |
| 821 | //Next Prev Tab |
| 822 | $(document).on('click', '.quiz-modal-btn-next, .quiz-modal-btn-back', function(e){ |
| 823 | e.preventDefault(); |
| 824 | |
| 825 | var tabSelector = $(this).attr('href'); |
| 826 | $('#tutor-quiz-modal-tab-items-wrap a[href="'+tabSelector+'"]').trigger('click'); |
| 827 | }); |
| 828 | |
| 829 | $(document).on('click', '.quiz-modal-tab-navigation-btn.quiz-modal-btn-cancel', function(e){ |
| 830 | e.preventDefault(); |
| 831 | $('.tutor-modal-wrap').removeClass('show'); |
| 832 | }); |
| 833 | |
| 834 | $(document).on('click', '.quiz-modal-btn-first-step', function(e){ |
| 835 | e.preventDefault(); |
| 836 | |
| 837 | var $that = $(this); |
| 838 | var $quizTitle = $('[name="quiz_title"]'); |
| 839 | var quiz_title = $quizTitle.val(); |
| 840 | var quiz_description = $('[name="quiz_description"]').val(); |
| 841 | |
| 842 | if ( ! quiz_title){ |
| 843 | $quizTitle.closest('.tutor-quiz-builder-group').find('.quiz_form_msg').html('Please enter quiz title'); |
| 844 | return; |
| 845 | }else{ |
| 846 | $quizTitle.closest('.tutor-quiz-builder-group').find('.quiz_form_msg').html(''); |
| 847 | } |
| 848 | |
| 849 | |
| 850 | |
| 851 | var course_id = $('#post_ID').val(); |
| 852 | var topic_id = $that.closest('.tutor-modal-wrap').attr('quiz-for-post-id'); |
| 853 | |
| 854 | |
| 855 | if ($('#tutor_quiz_builder_quiz_id').length) { |
| 856 | /** |
| 857 | * |
| 858 | * @type {jQuery} |
| 859 | * |
| 860 | * if quiz id exists, we are sending it to update quiz |
| 861 | */ |
| 862 | |
| 863 | var quiz_id = $('#tutor_quiz_builder_quiz_id').val(); |
| 864 | $.ajax({ |
| 865 | url : ajaxurl, |
| 866 | type : 'POST', |
| 867 | data : {quiz_title:quiz_title, quiz_description: quiz_description, quiz_id : quiz_id, topic_id : topic_id, action: 'tutor_quiz_builder_quiz_update'}, |
| 868 | beforeSend: function () { |
| 869 | $that.addClass('tutor-updating-message'); |
| 870 | }, |
| 871 | success: function (data) { |
| 872 | $('#tutor-quiz-'+quiz_id).html(data.data.output_quiz_row); |
| 873 | $('#tutor-quiz-modal-tab-items-wrap a[href="#quiz-builder-tab-questions"]').trigger('click'); |
| 874 | }, |
| 875 | complete: function () { |
| 876 | $that.removeClass('tutor-updating-message'); |
| 877 | } |
| 878 | }); |
| 879 | |
| 880 | return; |
| 881 | } |
| 882 | |
| 883 | $.ajax({ |
| 884 | url : ajaxurl, |
| 885 | type : 'POST', |
| 886 | data : {quiz_title:quiz_title, quiz_description: quiz_description, course_id : course_id, topic_id : topic_id, action: 'tutor_create_quiz_and_load_modal'}, |
| 887 | beforeSend: function () { |
| 888 | $that.addClass('tutor-updating-message'); |
| 889 | }, |
| 890 | success: function (data) { |
| 891 | $('.tutor-quiz-builder-modal-wrap .modal-container').html(data.data.output); |
| 892 | $('#tutor-topics-'+topic_id+' .tutor-lessons').append(data.data.output_quiz_row); |
| 893 | $('#tutor-quiz-modal-tab-items-wrap a[href="#quiz-builder-tab-questions"]').trigger('click'); |
| 894 | }, |
| 895 | complete: function () { |
| 896 | $that.removeClass('tutor-updating-message'); |
| 897 | } |
| 898 | }); |
| 899 | |
| 900 | }); |
| 901 | |
| 902 | /** |
| 903 | * Ope modal for edit quiz |
| 904 | */ |
| 905 | $(document).on('click', '.open-tutor-quiz-modal', function(e){ |
| 906 | e.preventDefault(); |
| 907 | |
| 908 | var $that = $(this); |
| 909 | var quiz_id = $that.attr('data-quiz-id'); |
| 910 | var topic_id = $that.attr('data-topic-id'); |
| 911 | var course_id = $('#post_ID').val(); |
| 912 | |
| 913 | $.ajax({ |
| 914 | url : ajaxurl, |
| 915 | type : 'POST', |
| 916 | data : {quiz_id : quiz_id, topic_id : topic_id, course_id : course_id, action: 'tutor_load_edit_quiz_modal'}, |
| 917 | beforeSend: function () { |
| 918 | $that.addClass('tutor-updating-message'); |
| 919 | }, |
| 920 | success: function (data) { |
| 921 | $('.tutor-quiz-builder-modal-wrap .modal-container').html(data.data.output); |
| 922 | $('.tutor-quiz-builder-modal-wrap').attr('data-quiz-id', quiz_id).addClass('show'); |
| 923 | |
| 924 | //Back to question Tab if exists |
| 925 | if ($that.attr('data-back-to-tab')){ |
| 926 | var tabSelector = $that.attr('data-back-to-tab'); |
| 927 | $('#tutor-quiz-modal-tab-items-wrap a[href="'+tabSelector+'"]').trigger('click'); |
| 928 | } |
| 929 | tutor_slider_init(); |
| 930 | enable_quiz_questions_sorting(); |
| 931 | }, |
| 932 | complete: function () { |
| 933 | $that.removeClass('tutor-updating-message'); |
| 934 | } |
| 935 | }); |
| 936 | }); |
| 937 | |
| 938 | |
| 939 | $(document).on('click', '.quiz-modal-settings-save-btn', function(e){ |
| 940 | e.preventDefault(); |
| 941 | |
| 942 | var $that = $(this); |
| 943 | var quiz_id = $('.tutor-quiz-builder-modal-wrap').attr('data-quiz-id'); |
| 944 | |
| 945 | var $formInput = $('#quiz-builder-tab-settings :input, #quiz-builder-tab-advanced-options :input').serialize()+'&quiz_id='+quiz_id+'&action=tutor_quiz_modal_update_settings'; |
| 946 | |
| 947 | $.ajax({ |
| 948 | url : ajaxurl, |
| 949 | type : 'POST', |
| 950 | data : $formInput, |
| 951 | beforeSend: function () { |
| 952 | $that.addClass('tutor-updating-message'); |
| 953 | }, |
| 954 | success: function (data) { |
| 955 | // |
| 956 | }, |
| 957 | complete: function () { |
| 958 | $that.removeClass('tutor-updating-message'); |
| 959 | if ($that.attr('data-action') === 'modal_close'){ |
| 960 | $('.tutor-modal-wrap').removeClass('show'); |
| 961 | } |
| 962 | } |
| 963 | }); |
| 964 | }); |
| 965 | |
| 966 | |
| 967 | /** |
| 968 | * Add Question to quiz modal |
| 969 | */ |
| 970 | $(document).on('click', '.tutor-quiz-open-question-form', function(e){ |
| 971 | e.preventDefault(); |
| 972 | |
| 973 | var $that = $(this); |
| 974 | |
| 975 | var quiz_id = $('#tutor_quiz_builder_quiz_id').val(); |
| 976 | var course_id = $('#post_ID').val(); |
| 977 | var question_id = $that.attr('data-question-id'); |
| 978 | |
| 979 | |
| 980 | var params = {quiz_id : quiz_id, course_id : course_id, action: 'tutor_quiz_builder_get_question_form'}; |
| 981 | |
| 982 | if (question_id) { |
| 983 | params.question_id = question_id; |
| 984 | } |
| 985 | |
| 986 | $.ajax({ |
| 987 | url : ajaxurl, |
| 988 | type : 'POST', |
| 989 | data : params, |
| 990 | beforeSend: function () { |
| 991 | $that.addClass('tutor-updating-message'); |
| 992 | }, |
| 993 | success: function (data) { |
| 994 | $('.tutor-quiz-builder-modal-contents').html(data.data.output); |
| 995 | |
| 996 | //Initializing Tutor Select |
| 997 | tutor_select().reInit(); |
| 998 | enable_quiz_answer_sorting(); |
| 999 | }, |
| 1000 | complete: function () { |
| 1001 | $that.removeClass('tutor-updating-message'); |
| 1002 | } |
| 1003 | }); |
| 1004 | |
| 1005 | }); |
| 1006 | |
| 1007 | $(document).on('click', '.quiz-modal-question-save-btn', function(e){ |
| 1008 | e.preventDefault(); |
| 1009 | |
| 1010 | var $that = $(this); |
| 1011 | var $formInput = $('.quiz_question_form :input').serialize()+'&action=tutor_quiz_modal_update_question'; |
| 1012 | $.ajax({ |
| 1013 | url : ajaxurl, |
| 1014 | type : 'POST', |
| 1015 | data : $formInput, |
| 1016 | beforeSend: function () { |
| 1017 | $that.addClass('tutor-updating-message'); |
| 1018 | }, |
| 1019 | success: function (data) { |
| 1020 | //ReOpen questions |
| 1021 | $that.closest('.quiz-questions-form').find('.open-tutor-quiz-modal').trigger('click'); |
| 1022 | }, |
| 1023 | complete: function () { |
| 1024 | $that.removeClass('tutor-updating-message'); |
| 1025 | } |
| 1026 | }); |
| 1027 | }); |
| 1028 | |
| 1029 | $(document).on('click', '.tutor-quiz-question-trash', function(e){ |
| 1030 | e.preventDefault(); |
| 1031 | |
| 1032 | var $that = $(this); |
| 1033 | var question_id = $that.attr('data-question-id'); |
| 1034 | |
| 1035 | $.ajax({ |
| 1036 | url : ajaxurl, |
| 1037 | type : 'POST', |
| 1038 | data : {question_id : question_id, action: 'tutor_quiz_builder_question_delete'}, |
| 1039 | beforeSend: function () { |
| 1040 | $that.closest('.quiz-builder-question-wrap').remove(); |
| 1041 | }, |
| 1042 | }); |
| 1043 | }); |
| 1044 | |
| 1045 | /** |
| 1046 | * Get question answers option form to save multiple/single/true-false options |
| 1047 | * |
| 1048 | * @since v.1.0.0 |
| 1049 | */ |
| 1050 | |
| 1051 | $(document).on('click', '.add_question_answers_option', function(e){ |
| 1052 | e.preventDefault(); |
| 1053 | |
| 1054 | var $that = $(this); |
| 1055 | var question_id = $that.attr('data-question-id'); |
| 1056 | var $formInput = $('.quiz_question_form :input').serialize()+'&question_id='+question_id+'&action=tutor_quiz_add_question_answers'; |
| 1057 | |
| 1058 | $.ajax({ |
| 1059 | url : ajaxurl, |
| 1060 | type : 'POST', |
| 1061 | data : $formInput, |
| 1062 | beforeSend: function () { |
| 1063 | $that.addClass('tutor-updating-message'); |
| 1064 | }, |
| 1065 | success: function (data) { |
| 1066 | $('#tutor_quiz_question_answer_form').html(data.data.output); |
| 1067 | }, |
| 1068 | complete: function () { |
| 1069 | $that.removeClass('tutor-updating-message'); |
| 1070 | } |
| 1071 | }); |
| 1072 | }); |
| 1073 | |
| 1074 | /** |
| 1075 | * Get question answers option edit form |
| 1076 | * |
| 1077 | * @since v.1.0.0 |
| 1078 | */ |
| 1079 | $(document).on('click', '.tutor-quiz-answer-edit a', function(e){ |
| 1080 | e.preventDefault(); |
| 1081 | |
| 1082 | var $that = $(this); |
| 1083 | var answer_id = $that.closest('.tutor-quiz-answer-wrap').attr('data-answer-id'); |
| 1084 | |
| 1085 | $.ajax({ |
| 1086 | url : ajaxurl, |
| 1087 | type : 'POST', |
| 1088 | data : {answer_id : answer_id, action : 'tutor_quiz_edit_question_answer'}, |
| 1089 | beforeSend: function () { |
| 1090 | $that.addClass('tutor-updating-message'); |
| 1091 | }, |
| 1092 | success: function (data) { |
| 1093 | $('#tutor_quiz_question_answer_form').html(data.data.output); |
| 1094 | }, |
| 1095 | complete: function () { |
| 1096 | $that.removeClass('tutor-updating-message'); |
| 1097 | } |
| 1098 | }); |
| 1099 | }); |
| 1100 | |
| 1101 | |
| 1102 | /** |
| 1103 | * Saving question answers options |
| 1104 | * Student should select the right answer at quiz attempts |
| 1105 | * |
| 1106 | * @since v.1.0.0 |
| 1107 | */ |
| 1108 | |
| 1109 | $(document).on('click', '#quiz-answer-save-btn', function(e){ |
| 1110 | e.preventDefault(); |
| 1111 | |
| 1112 | var $that = $(this); |
| 1113 | var $formInput = $('.quiz_question_form :input').serialize()+'&action=tutor_save_quiz_answer_options'; |
| 1114 | |
| 1115 | $.ajax({ |
| 1116 | url : ajaxurl, |
| 1117 | type : 'POST', |
| 1118 | data : $formInput, |
| 1119 | beforeSend: function () { |
| 1120 | $that.addClass('tutor-updating-message'); |
| 1121 | }, |
| 1122 | success: function (data) { |
| 1123 | $('#tutor_quiz_question_answers').trigger('refresh'); |
| 1124 | }, |
| 1125 | complete: function () { |
| 1126 | $that.removeClass('tutor-updating-message'); |
| 1127 | } |
| 1128 | }); |
| 1129 | }); |
| 1130 | |
| 1131 | /** |
| 1132 | * Updating Answer |
| 1133 | * |
| 1134 | * @since v.1.0.0 |
| 1135 | */ |
| 1136 | $(document).on('click', '#quiz-answer-edit-btn', function(e){ |
| 1137 | e.preventDefault(); |
| 1138 | |
| 1139 | var $that = $(this); |
| 1140 | var $formInput = $('.quiz_question_form :input').serialize()+'&action=tutor_update_quiz_answer_options'; |
| 1141 | |
| 1142 | $.ajax({ |
| 1143 | url : ajaxurl, |
| 1144 | type : 'POST', |
| 1145 | data : $formInput, |
| 1146 | beforeSend: function () { |
| 1147 | $that.addClass('tutor-updating-message'); |
| 1148 | }, |
| 1149 | success: function (data) { |
| 1150 | $('#tutor_quiz_question_answers').trigger('refresh'); |
| 1151 | }, |
| 1152 | complete: function () { |
| 1153 | $that.removeClass('tutor-updating-message'); |
| 1154 | } |
| 1155 | }); |
| 1156 | }); |
| 1157 | |
| 1158 | $(document).on('change', '.tutor-quiz-answers-mark-correct-wrap input', function(e){ |
| 1159 | e.preventDefault(); |
| 1160 | |
| 1161 | var $that = $(this); |
| 1162 | |
| 1163 | var answer_id = $that.val(); |
| 1164 | var inputValue = 1; |
| 1165 | if ( ! $that.prop('checked')) { |
| 1166 | inputValue = 0; |
| 1167 | } |
| 1168 | |
| 1169 | $.ajax({ |
| 1170 | url : ajaxurl, |
| 1171 | type : 'POST', |
| 1172 | data : {answer_id:answer_id, inputValue : inputValue, action : 'tutor_mark_answer_as_correct'}, |
| 1173 | }); |
| 1174 | }); |
| 1175 | |
| 1176 | |
| 1177 | $(document).on('refresh', '#tutor_quiz_question_answers', function(e){ |
| 1178 | e.preventDefault(); |
| 1179 | |
| 1180 | var $that = $(this); |
| 1181 | var question_id = $that.attr('data-question-id'); |
| 1182 | var question_type = $('.tutor_select_value_holder').val(); |
| 1183 | |
| 1184 | $.ajax({ |
| 1185 | url : ajaxurl, |
| 1186 | type : 'POST', |
| 1187 | data : {question_id : question_id, question_type : question_type, action: 'tutor_quiz_builder_get_answers_by_question'}, |
| 1188 | beforeSend: function () { |
| 1189 | $that.addClass('tutor-updating-message'); |
| 1190 | $('#tutor_quiz_question_answer_form').html(''); |
| 1191 | }, |
| 1192 | success: function (data) { |
| 1193 | if (data.success){ |
| 1194 | $that.html(data.data.output); |
| 1195 | } |
| 1196 | }, |
| 1197 | complete: function () { |
| 1198 | $that.removeClass('tutor-updating-message'); |
| 1199 | } |
| 1200 | }); |
| 1201 | }); |
| 1202 | |
| 1203 | /** |
| 1204 | * Delete answer for a question in quiz builder |
| 1205 | * |
| 1206 | * @since v.1.0.0 |
| 1207 | */ |
| 1208 | |
| 1209 | $(document).on('click', '.tutor-quiz-answer-trash-wrap a.answer-trash-btn', function(e){ |
| 1210 | e.preventDefault(); |
| 1211 | |
| 1212 | var $that = $(this); |
| 1213 | var answer_id = $that.attr('data-answer-id'); |
| 1214 | |
| 1215 | $.ajax({ |
| 1216 | url : ajaxurl, |
| 1217 | type : 'POST', |
| 1218 | data : {answer_id : answer_id, action: 'tutor_quiz_builder_delete_answer'}, |
| 1219 | beforeSend: function () { |
| 1220 | $that.closest('.tutor-quiz-answer-wrap').remove(); |
| 1221 | }, |
| 1222 | }); |
| 1223 | }); |
| 1224 | |
| 1225 | /** |
| 1226 | * Sort quiz questions |
| 1227 | */ |
| 1228 | function enable_quiz_questions_sorting(){ |
| 1229 | if (jQuery().sortable) { |
| 1230 | $(".quiz-builder-questions-wrap").sortable({ |
| 1231 | handle: ".question-sorting", |
| 1232 | start: function (e, ui) { |
| 1233 | ui.placeholder.css('visibility', 'visible'); |
| 1234 | }, |
| 1235 | stop: function (e, ui) { |
| 1236 | tutor_save_sorting_quiz_questions_order(); |
| 1237 | }, |
| 1238 | }); |
| 1239 | } |
| 1240 | } |
| 1241 | |
| 1242 | function tutor_save_sorting_quiz_questions_order(){ |
| 1243 | var questions = {}; |
| 1244 | $('.quiz-builder-question-wrap').each(function(index, item){ |
| 1245 | var $question = $(this); |
| 1246 | var question_id = parseInt($question.attr('data-question-id'), 10); |
| 1247 | questions[index] = question_id; |
| 1248 | }); |
| 1249 | |
| 1250 | $.ajax({url : ajaxurl, type : 'POST', |
| 1251 | data : {sorted_question_ids : questions, action: 'tutor_quiz_question_sorting'}, |
| 1252 | }); |
| 1253 | } |
| 1254 | |
| 1255 | /** |
| 1256 | * Save answer sorting placement |
| 1257 | * |
| 1258 | * @since v.1.0.0 |
| 1259 | */ |
| 1260 | function enable_quiz_answer_sorting(){ |
| 1261 | if (jQuery().sortable) { |
| 1262 | $("#tutor_quiz_question_answers").sortable({ |
| 1263 | handle: ".tutor-quiz-answer-sort-icon", |
| 1264 | start: function (e, ui) { |
| 1265 | ui.placeholder.css('visibility', 'visible'); |
| 1266 | }, |
| 1267 | stop: function (e, ui) { |
| 1268 | tutor_save_sorting_quiz_answer_order(); |
| 1269 | }, |
| 1270 | }); |
| 1271 | } |
| 1272 | } |
| 1273 | function tutor_save_sorting_quiz_answer_order(){ |
| 1274 | var answers = {}; |
| 1275 | $('.tutor-quiz-answer-wrap').each(function(index, item){ |
| 1276 | var $answer = $(this); |
| 1277 | var answer_id = parseInt($answer.attr('data-answer-id'), 10); |
| 1278 | answers[index] = answer_id; |
| 1279 | }); |
| 1280 | |
| 1281 | $.ajax({url : ajaxurl, type : 'POST', |
| 1282 | data : {sorted_answer_ids : answers, action: 'tutor_quiz_answer_sorting'}, |
| 1283 | }); |
| 1284 | } |
| 1285 | |
| 1286 | |
| 1287 | |
| 1288 | /** |
| 1289 | * Deprecated, should remove |
| 1290 | * @todo: should remove this |
| 1291 | */ |
| 1292 | |
| 1293 | $(document).on('click', '.add_quiz_to_post_btn', function(e){ |
| 1294 | e.preventDefault(); |
| 1295 | |
| 1296 | var $that = $(this); |
| 1297 | var $modal = $('.tutor-modal-wrap'); |
| 1298 | |
| 1299 | var quiz_for_post_id = $modal.attr('quiz-for-post-id'); |
| 1300 | var data = $modal.find('input').serialize()+'&action=tutor_add_quiz_to_post&parent_post_id='+quiz_for_post_id; |
| 1301 | |
| 1302 | $.ajax({ |
| 1303 | url : ajaxurl, |
| 1304 | type : 'POST', |
| 1305 | data : data, |
| 1306 | beforeSend: function () { |
| 1307 | $that.addClass('tutor-updating-message'); |
| 1308 | }, |
| 1309 | success: function (data) { |
| 1310 | if (data.success){ |
| 1311 | $('[data-add-quiz-under="'+quiz_for_post_id+'"] .tutor-available-quizzes').html(data.data.output); |
| 1312 | $('.tutor-modal-wrap').removeClass('show'); |
| 1313 | } |
| 1314 | }, |
| 1315 | complete: function () { |
| 1316 | $that.removeClass('tutor-updating-message'); |
| 1317 | } |
| 1318 | }); |
| 1319 | }); |
| 1320 | |
| 1321 | $(document).on('change keyup', '.tutor-quiz-modal-wrap .tutor-modal-search-input', function(e){ |
| 1322 | e.preventDefault(); |
| 1323 | |
| 1324 | var $that = $(this); |
| 1325 | var $modal = $('.tutor-modal-wrap'); |
| 1326 | |
| 1327 | tutor_delay(function(){ |
| 1328 | var search_terms = $that.val(); |
| 1329 | var quiz_for_post_id = $modal.attr('quiz-for-post-id'); |
| 1330 | |
| 1331 | $.ajax({ |
| 1332 | url : ajaxurl, |
| 1333 | type : 'POST', |
| 1334 | data : {quiz_for_post_id : quiz_for_post_id, search_terms : search_terms, action: 'tutor_load_quiz_modal'}, |
| 1335 | beforeSend: function () { |
| 1336 | $modal.addClass('loading'); |
| 1337 | }, |
| 1338 | success: function (data) { |
| 1339 | if (data.success){ |
| 1340 | $('.tutor-modal-wrap .modal-container').html(data.data.output); |
| 1341 | } |
| 1342 | }, |
| 1343 | complete: function () { |
| 1344 | $modal.removeClass('loading'); |
| 1345 | } |
| 1346 | }); |
| 1347 | |
| 1348 | }, 1000) |
| 1349 | }); |
| 1350 | |
| 1351 | var tutor_delay = (function(){ |
| 1352 | var timer = 0; |
| 1353 | return function(callback, ms){ |
| 1354 | clearTimeout (timer); |
| 1355 | timer = setTimeout(callback, ms); |
| 1356 | }; |
| 1357 | })(); |
| 1358 | |
| 1359 | $(document).on('click', '.tutor-quiz-delete-btn', function(e){ |
| 1360 | e.preventDefault(); |
| 1361 | |
| 1362 | var $that = $(this); |
| 1363 | var quiz_id = $that.closest('.added-quiz-item').attr('data-quiz-id'); |
| 1364 | |
| 1365 | $.ajax({ |
| 1366 | url : ajaxurl, |
| 1367 | type : 'POST', |
| 1368 | data : {quiz_id:quiz_id, action: 'remove_quiz_from_post'}, |
| 1369 | success: function (data) { |
| 1370 | if (data.success){ |
| 1371 | $that.closest('.added-quiz-item').remove(); |
| 1372 | } |
| 1373 | } |
| 1374 | }); |
| 1375 | }); |
| 1376 | |
| 1377 | /** |
| 1378 | * Add instructor modal |
| 1379 | */ |
| 1380 | $(document).on('click', '.tutor-add-instructor-btn', function(e){ |
| 1381 | e.preventDefault(); |
| 1382 | |
| 1383 | var $that = $(this); |
| 1384 | var course_id = $('#post_ID').val(); |
| 1385 | |
| 1386 | $.ajax({ |
| 1387 | url : ajaxurl, |
| 1388 | type : 'POST', |
| 1389 | data : {course_id : course_id, action: 'tutor_load_instructors_modal'}, |
| 1390 | beforeSend: function () { |
| 1391 | $that.addClass('tutor-updating-message'); |
| 1392 | }, |
| 1393 | success: function (data) { |
| 1394 | if (data.success){ |
| 1395 | $('.tutor-instructors-modal-wrap .modal-container').html(data.data.output); |
| 1396 | $('.tutor-instructors-modal-wrap').addClass('show'); |
| 1397 | } |
| 1398 | }, |
| 1399 | complete: function () { |
| 1400 | $that.removeClass('tutor-updating-message'); |
| 1401 | } |
| 1402 | }); |
| 1403 | }); |
| 1404 | |
| 1405 | $(document).on('change keyup', '.tutor-instructors-modal-wrap .tutor-modal-search-input', function(e){ |
| 1406 | e.preventDefault(); |
| 1407 | |
| 1408 | var $that = $(this); |
| 1409 | var $modal = $('.tutor-modal-wrap'); |
| 1410 | |
| 1411 | tutor_delay(function(){ |
| 1412 | var search_terms = $that.val(); |
| 1413 | var course_id = $('#post_ID').val(); |
| 1414 | |
| 1415 | $.ajax({ |
| 1416 | url : ajaxurl, |
| 1417 | type : 'POST', |
| 1418 | data : {course_id : course_id, search_terms : search_terms, action: 'tutor_load_instructors_modal'}, |
| 1419 | beforeSend: function () { |
| 1420 | $modal.addClass('loading'); |
| 1421 | }, |
| 1422 | success: function (data) { |
| 1423 | if (data.success){ |
| 1424 | $('.tutor-instructors-modal-wrap .modal-container').html(data.data.output); |
| 1425 | $('.tutor-instructors-modal-wrap').addClass('show'); |
| 1426 | } |
| 1427 | }, |
| 1428 | complete: function () { |
| 1429 | $modal.removeClass('loading'); |
| 1430 | } |
| 1431 | }); |
| 1432 | |
| 1433 | }, 1000) |
| 1434 | }); |
| 1435 | $(document).on('click', '.add_instructor_to_course_btn', function(e){ |
| 1436 | e.preventDefault(); |
| 1437 | |
| 1438 | var $that = $(this); |
| 1439 | var $modal = $('.tutor-modal-wrap'); |
| 1440 | var course_id = $('#post_ID').val(); |
| 1441 | var data = $modal.find('input').serialize()+'&course_id='+course_id+'&action=tutor_add_instructors_to_course'; |
| 1442 | |
| 1443 | $.ajax({ |
| 1444 | url : ajaxurl, |
| 1445 | type : 'POST', |
| 1446 | data : data, |
| 1447 | beforeSend: function () { |
| 1448 | $that.addClass('tutor-updating-message'); |
| 1449 | }, |
| 1450 | success: function (data) { |
| 1451 | if (data.success){ |
| 1452 | $('.tutor-course-available-instructors').html(data.data.output); |
| 1453 | $('.tutor-modal-wrap').removeClass('show'); |
| 1454 | } |
| 1455 | }, |
| 1456 | complete: function () { |
| 1457 | $that.removeClass('tutor-updating-message'); |
| 1458 | } |
| 1459 | }); |
| 1460 | }); |
| 1461 | |
| 1462 | $(document).on('click', '.tutor-instructor-delete-btn', function(e){ |
| 1463 | e.preventDefault(); |
| 1464 | |
| 1465 | var $that = $(this); |
| 1466 | var course_id = $('#post_ID').val(); |
| 1467 | var instructor_id = $that.closest('.added-instructor-item').attr('data-instructor-id'); |
| 1468 | |
| 1469 | $.ajax({ |
| 1470 | url : ajaxurl, |
| 1471 | type : 'POST', |
| 1472 | data : {course_id:course_id, instructor_id:instructor_id, action : 'detach_instructor_from_course'}, |
| 1473 | success: function (data) { |
| 1474 | if (data.success){ |
| 1475 | $that.closest('.added-instructor-item').remove(); |
| 1476 | } |
| 1477 | } |
| 1478 | }); |
| 1479 | }); |
| 1480 | |
| 1481 | $(document).on('click', '.tutor-option-media-upload-btn', function(e){ |
| 1482 | e.preventDefault(); |
| 1483 | |
| 1484 | var $that = $(this); |
| 1485 | var frame; |
| 1486 | if ( frame ) { |
| 1487 | frame.open(); |
| 1488 | return; |
| 1489 | } |
| 1490 | frame = wp.media({ |
| 1491 | title: 'Select or Upload Media Of Your Chosen Persuasion', |
| 1492 | button: { |
| 1493 | text: 'Use this media' |
| 1494 | }, |
| 1495 | multiple: false |
| 1496 | }); |
| 1497 | frame.on( 'select', function() { |
| 1498 | var attachment = frame.state().get('selection').first().toJSON(); |
| 1499 | $that.closest('.option-media-wrap').find('.option-media-preview').html('<img src="'+attachment.url+'" alt="" />'); |
| 1500 | $that.closest('.option-media-wrap').find('input').val(attachment.id); |
| 1501 | }); |
| 1502 | frame.open(); |
| 1503 | }); |
| 1504 | |
| 1505 | $(document).on('change', '.tutor_addons_list_item', function(e) { |
| 1506 | var $that = $(this); |
| 1507 | |
| 1508 | var isEnable = $that.prop('checked') ? 1 : 0; |
| 1509 | var addonFieldName = $that.attr('name'); |
| 1510 | |
| 1511 | $.ajax({ |
| 1512 | url : ajaxurl, |
| 1513 | type : 'POST', |
| 1514 | data : {isEnable:isEnable, addonFieldName:addonFieldName, action : 'addon_enable_disable'}, |
| 1515 | success: function (data) { |
| 1516 | if (data.success){ |
| 1517 | //Success |
| 1518 | } |
| 1519 | } |
| 1520 | }); |
| 1521 | }); |
| 1522 | |
| 1523 | /** |
| 1524 | * Tutor Custom Select |
| 1525 | */ |
| 1526 | |
| 1527 | function tutor_select(){ |
| 1528 | var obj = { |
| 1529 | init : function(){ |
| 1530 | $(document).on('click', '.tutor-select .tutor-select-option', function(e){ |
| 1531 | e.preventDefault(); |
| 1532 | |
| 1533 | var $that = $(this); |
| 1534 | if ($that.attr('data-is-pro') !== 'true') { |
| 1535 | var $html = $that.html().trim(); |
| 1536 | $that.closest('.tutor-select').find('.select-header .lead-option').html($html); |
| 1537 | $that.closest('.tutor-select').find('.select-header input.tutor_select_value_holder').val($that.attr('data-value')).trigger('change'); |
| 1538 | $that.closest('.tutor-select-options').hide(); |
| 1539 | }else{ |
| 1540 | alert('Tutor Pro version required'); |
| 1541 | } |
| 1542 | }); |
| 1543 | $(document).on('click', '.tutor-select .select-header', function(e){ |
| 1544 | e.preventDefault(); |
| 1545 | |
| 1546 | var $that = $(this); |
| 1547 | $that.closest('.tutor-select').find('.tutor-select-options').slideToggle(); |
| 1548 | }); |
| 1549 | |
| 1550 | this.setValue(); |
| 1551 | this.hideOnOutSideClick(); |
| 1552 | }, |
| 1553 | setValue : function(){ |
| 1554 | $('.tutor-select').each(function(){ |
| 1555 | var $that = $(this); |
| 1556 | var $option = $that.find('.tutor-select-option'); |
| 1557 | |
| 1558 | if ($option.length){ |
| 1559 | $option.each(function(){ |
| 1560 | var $thisOption = $(this); |
| 1561 | |
| 1562 | if ($thisOption.attr('data-selected') === 'selected'){ |
| 1563 | var $html = $thisOption.html().trim(); |
| 1564 | $thisOption.closest('.tutor-select').find('.select-header .lead-option').html($html); |
| 1565 | $thisOption.closest('.tutor-select').find('.select-header input.tutor_select_value_holder').val($thisOption.attr('data-value')); |
| 1566 | } |
| 1567 | }); |
| 1568 | } |
| 1569 | }); |
| 1570 | }, |
| 1571 | hideOnOutSideClick : function(){ |
| 1572 | $(document).mouseup(function(e) { |
| 1573 | var $option_wrap = $(".tutor-select-options"); |
| 1574 | if ( ! $(e.target).closest('.select-header').length && !$option_wrap.is(e.target) && $option_wrap.has(e.target).length === 0) { |
| 1575 | $option_wrap.hide(); |
| 1576 | } |
| 1577 | }); |
| 1578 | }, |
| 1579 | reInit : function(){ |
| 1580 | this.setValue(); |
| 1581 | } |
| 1582 | }; |
| 1583 | |
| 1584 | return obj; |
| 1585 | } |
| 1586 | tutor_select().init(); |
| 1587 | |
| 1588 | /** |
| 1589 | * If change question type from quiz builder question |
| 1590 | * |
| 1591 | * @since v.1.0.0 |
| 1592 | */ |
| 1593 | $(document).on('change', 'input.tutor_select_value_holder', function(e) { |
| 1594 | var $that = $(this); |
| 1595 | //$('#tutor_quiz_question_answer_form').html(''); |
| 1596 | $('.add_question_answers_option').trigger('click'); |
| 1597 | $('#tutor_quiz_question_answers').trigger('refresh'); |
| 1598 | }); |
| 1599 | |
| 1600 | $(document).on('click', '.tutor-media-upload-btn', function(e){ |
| 1601 | e.preventDefault(); |
| 1602 | |
| 1603 | var $that = $(this); |
| 1604 | var frame; |
| 1605 | if ( frame ) { |
| 1606 | frame.open(); |
| 1607 | return; |
| 1608 | } |
| 1609 | frame = wp.media({ |
| 1610 | title: 'Select or Upload Media Of Your Chosen Persuasion', |
| 1611 | button: { |
| 1612 | text: 'Use this media' |
| 1613 | }, |
| 1614 | multiple: false |
| 1615 | }); |
| 1616 | frame.on( 'select', function() { |
| 1617 | var attachment = frame.state().get('selection').first().toJSON(); |
| 1618 | $that.html('<img src="'+attachment.url+'" alt="" />'); |
| 1619 | $that.closest('.tutor-media-upload-wrap').find('input').val(attachment.id); |
| 1620 | }); |
| 1621 | frame.open(); |
| 1622 | }); |
| 1623 | $(document).on('click', '.tutor-media-upload-trash', function(e){ |
| 1624 | e.preventDefault(); |
| 1625 | |
| 1626 | var $that = $(this); |
| 1627 | $that.closest('.tutor-media-upload-wrap').find('.tutor-media-upload-btn').html('<i class="tutor-icon-image1"></i>'); |
| 1628 | $that.closest('.tutor-media-upload-wrap').find('input').val(''); |
| 1629 | }); |
| 1630 | |
| 1631 | /** |
| 1632 | * Add instructor |
| 1633 | * @since v.1.0.3 |
| 1634 | */ |
| 1635 | $(document).on('submit', '#new-instructor-form', function(e){ |
| 1636 | e.preventDefault(); |
| 1637 | |
| 1638 | var $that = $(this); |
| 1639 | var formData = $that.serialize()+'&action=tutor_add_instructor'; |
| 1640 | |
| 1641 | $.ajax({ |
| 1642 | url : ajaxurl, |
| 1643 | type : 'POST', |
| 1644 | data : formData, |
| 1645 | success: function (data) { |
| 1646 | if (data.success){ |
| 1647 | $that.trigger("reset"); |
| 1648 | $('#form-response').html('<p class="tutor-status-approved-context">'+data.data.msg+'</p>'); |
| 1649 | }else{ |
| 1650 | var errorMsg = ''; |
| 1651 | |
| 1652 | var errors = data.data.errors; |
| 1653 | if (errors && Object.keys(errors).length){ |
| 1654 | $.each(data.data.errors, function( index, value ) { |
| 1655 | if (isObject(value)){ |
| 1656 | |
| 1657 | $.each(value, function( key, value1 ) { |
| 1658 | errorMsg += '<p class="tutor-required-fields">'+value1[0]+'</p>'; |
| 1659 | }); |
| 1660 | } else{ |
| 1661 | errorMsg += '<p class="tutor-required-fields">'+value+'</p>'; |
| 1662 | } |
| 1663 | }); |
| 1664 | $('#form-response').html(errorMsg); |
| 1665 | } |
| 1666 | |
| 1667 | } |
| 1668 | } |
| 1669 | }); |
| 1670 | }); |
| 1671 | |
| 1672 | function isObject (value) { |
| 1673 | return value && typeof value === 'object' && value.constructor === Object; |
| 1674 | } |
| 1675 | |
| 1676 | }); |
| 1677 |