home/theblueo/tv/wp-content/plugins/sfwd-lms/assets/js/sfwd_module.js 0000604 00000220751 15214240770 0022040 0 ustar 00 jQuery(document).ready(function() { if ( ( jQuery( 'body.wp-admin.post-type-sfwd-quiz form#posts-filter' ).length ) || ( jQuery( 'body.wp-admin.post-type-sfwd-topic form#posts-filter' ).length ) || ( jQuery( 'body.wp-admin.post-type-sfwd-essays form#posts-filter' ).length ) || ( jQuery( 'body.wp-admin.post-type-sfwd-assignment form#posts-filter' ).length ) ) { if ( ( jQuery( 'form#posts-filter select#course_id' ).length ) && ( jQuery( 'form#posts-filter select#lesson_id' ).length ) ) { var selected_course_id = jQuery( 'form#posts-filter select#course_id' ).val(); var selected_lesson_id = jQuery( 'form#posts-filter select#course_id' ).val(); var lesson_default_label = jQuery( 'form#posts-filter select#lesson_id option[value=""]').text(); if ( jQuery( 'body.wp-admin.post-type-sfwd-essays form#posts-filter' ).length ) { var selected_quiz_id = jQuery( 'form#posts-filter select#quiz_id' ).val(); var quiz_default_label = jQuery( 'form#posts-filter select#quiz_id option[value=""]').text(); } jQuery( 'form#posts-filter select#course_id' ).change(function(e) { var course_id = this.value; if ( jQuery( 'body.wp-admin.post-type-sfwd-topic form#posts-filter' ).length ) { var lesson_action = 'select_a_lesson'; } else { var lesson_action = 'select_a_lesson_or_topic'; } if ( course_id != '' ) { var data = { 'action': lesson_action, 'course_id': course_id }; if ( jQuery('form#posts-filter select#lesson_id').length ) { var lesson_selector_nonce = jQuery('form#posts-filter select#lesson_id').data('ld_selector_nonce'); if (typeof lesson_selector_nonce !== 'undefined') { data.ld_selector_nonce = lesson_selector_nonce; } var lesson_selector_default = jQuery('form#posts-filter select#lesson_id').data('ld_selector_default'); if (typeof lesson_selector_default !== 'undefined') { data.ld_selector_default = lesson_selector_default; } // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php jQuery.post(ajaxurl, data, function(json) { var html = ''; html += ""; jQuery.each(json.opt, function(i, opt) { if ( opt.key != '' && opt.key != '0' ) { selected = ( opt.key == selected_lesson_id ) ? 'selected=selected': ''; html += ""; } }); jQuery('form#posts-filter select#lesson_id').html(html); }, "json"); } } else { var html = ''; html += ""; jQuery('form#posts-filter select#lesson_id').html(html); } if ( jQuery( 'body.wp-admin.post-type-sfwd-essays form#posts-filter' ).length ) { var data = { 'action': 'select_a_quiz', 'course_id': course_id, 'lesson_id': selected_lesson_id }; if (jQuery('form#posts-filter select#quiz_id').length) { var lesson_selector_nonce = jQuery('form#posts-filter select#quiz_id').data('ld_selector_nonce'); if (typeof lesson_selector_nonce !== 'undefined') { data.ld_selector_nonce = lesson_selector_nonce; } var lesson_selector_default = jQuery('form#posts-filter select#quiz_id').data('ld_selector_default'); if (typeof lesson_selector_default !== 'undefined') { data.ld_selector_default = lesson_selector_default; } // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php jQuery.post(ajaxurl, data, function(json) { var html = ''; html += ""; jQuery.each(json.opt, function(i, opt) { if ( opt.key != '' && opt.key != '0' ) { selected = ( opt.key == selected_quiz_id ) ? 'selected=selected': ''; html += ""; } }); jQuery('form#posts-filter select#quiz_id').html(html); }, "json"); } } else { var html = ''; html += ""; jQuery('form#posts-filter select#quiz_id').html(html); } }); } if ( jQuery( 'body.wp-admin.post-type-sfwd-essays form#posts-filter' ).length ) { jQuery( 'form#posts-filter select#lesson_id' ).change(function(e) { var selected_course_id = jQuery( 'form#posts-filter select#course_id' ).val(); var lesson_id = this.value; var data = { 'action': 'select_a_quiz', 'course_id': selected_course_id, 'lesson_id': lesson_id }; // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php jQuery.post(ajaxurl, data, function(json) { var html = ''; html += ""; jQuery.each(json.opt, function(i, opt) { if ( opt.key != '' && opt.key != '0' ) { selected = ( opt.key == selected_quiz_id ) ? 'selected=selected': ''; html += ""; } }); jQuery('form#posts-filter select#quiz_id').html(html); }, "json"); }); } } }); if ( typeof sfwd_data.json !== 'undefined' ) { sfwd_data = sfwd_data.json.replace(/"/g, '"'); sfwd_data = jQuery.parseJSON( sfwd_data ); } function toggleVisibility(id) { var e = document.getElementById(id); if (e.style.display == 'block') e.style.display = 'none'; else e.style.display = 'block'; } function countChars(field,cntfield) { cntfield.value = field.value.length; } jQuery('.sfwd_datepicker').each(function () { jQuery('#' + jQuery(this).attr('id')).datepicker(); }); function sfwd_do_condshow_match( index, value ) { if ( typeof value !== 'undefined' ) { matches = true; jQuery.each(value, function(subopt, setting) { cur = jQuery('[name=' + subopt + ']'); type = cur.attr('type'); if ( type == "checkbox" || type == "radio" ) cur = jQuery('input[name=' + subopt + ']:checked'); cur = cur.val(); if ( cur != setting ) { matches = false; return false; } }); if ( matches ) { jQuery('#' + index ).show(); } else { jQuery('#' + index ).hide(); } return matches; } return false; } function sfwd_add_condshow_handlers( index, value ) { if ( typeof value !== 'undefined' ) { jQuery.each(value, function(subopt, setting) { jQuery('[name=' + subopt + ']').change(function() { sfwd_do_condshow_match( index, value ); }); }); } } function sfwd_do_condshow( condshow ) { if ( typeof sfwd_data.condshow !== 'undefined' ) { jQuery.each(sfwd_data.condshow, function(index, value) { sfwd_do_condshow_match( index, value ); sfwd_add_condshow_handlers( index, value ); }); } } function sfwd_show_pointer( handle, value ) { if ( typeof( jQuery( value.pointer_target ).pointer) !== 'undefined' ) { jQuery(value.pointer_target).pointer({ content : value.pointer_text, close : function() { jQuery.post( ajaxurl, { pointer: handle, action: 'dismiss-wp-pointer' }); } }).pointer('open'); } } jQuery(document).ready(function(){ if (typeof sfwd_data !== 'undefined') { if ( typeof sfwd_data.condshow !== 'undefined' ) { sfwd_do_condshow( sfwd_data.condshow ); } } // jQuery( '#ld_course_info' ).on( 'click', 'a.user_statistic', show_user_statistic ); // jQuery( '#learndash_profile' ).on( 'click', 'a.user_statistic', show_user_statistic ); /* function show_user_statistic( e ) { e.preventDefault(); var refId = jQuery(this).data('ref_id'); var quizId = jQuery(this).data('quiz_id'); var userId = jQuery(this).data('user_id'); var statistic_nonce = jQuery(this).data('statistic_nonce'); var post_data = { 'action': 'wp_pro_quiz_admin_ajax', 'func': 'statisticLoadUser', 'data': { 'quizId': quizId, 'userId': userId, 'refId': refId, 'statistic_nonce': statistic_nonce, 'avg': 0 } } jQuery('#wpProQuiz_user_overlay, #wpProQuiz_loadUserData').show(); var content = jQuery('#wpProQuiz_user_content').hide(); jQuery.ajax({ type: "POST", url: ajaxurl, dataType: "json", cache: false, data: post_data, error: function(jqXHR, textStatus, errorThrown ) { }, success: function(reply_data) { if ( typeof reply_data.html !== 'undefined' ) { content.html(reply_data.html); jQuery('#wpProQuiz_user_content').show(); //console.log('trigger event change - sfwd_module'); //jQuery('body').trigger('learndash-statistics-contentchanged'); jQuery('#wpProQuiz_loadUserData').hide(); content.find('.statistic_data').click(function() { jQuery(this).parents('tr').next().toggle('fast'); return false; }); } } }); jQuery('#wpProQuiz_overlay_close').click(function() { jQuery('#wpProQuiz_user_overlay').hide(); }); } */ }); jQuery(document).ready(function() { var image_field; jQuery('.sfwd_upload_image_button').click(function() { window.send_to_editor = newSendToEditor; image_field = jQuery(this).next(); formfield = image_field.attr('name'); tb_show('', 'media-upload.php?type=image&TB_iframe=true'); return false; }); storeSendToEditor = window.send_to_editor; newSendToEditor = function(html) { imgurl = jQuery('img',html).attr('src'); image_field.val(imgurl); tb_remove(); window.send_to_editor = storeSendToEditor; }; }); /** * The following three functions are related to an 8 year old issue with the jQuery UI library and how it handles the cloning * of items like metaboxes when they are dragged on a page. Seems there was an issue with radio button form element loosing * their on state. This is not still happening. So we are no longer using this code. */ // props to commentluv for this fix // workaround for bug that causes radio inputs to lose settings when meta box is dragged. // http://core.trac.wordpress.org/ticket/16972 /* jQuery(document).ready(function(){ // listen for drag drop of metaboxes , bind mousedown to .hndle so it only fires when starting to drag jQuery('.hndle').mousedown(function(){ // set live event listener for mouse up on the content .wrap and wait a tick to give the dragged div time to settle before firing the reclick function jQuery('.wrap').mouseup(function(){store_radio(); setTimeout('reclick_radio();',50);}); }) }); */ /** * stores object of all radio buttons that are checked for entire form */ /* if(typeof store_radio != 'function') { function store_radio(){ var radioshack = {}; jQuery('input[type="radio"]').each(function(){ if(jQuery(this).is(':checked')){ radioshack[jQuery(this).attr('name')] = jQuery(this).val(); } jQuery(document).data('radioshack',radioshack); }); } } */ /** * detect mouseup and restore all radio buttons that were checked */ /* if(typeof reclick_radio != 'function') { function reclick_radio(){ // get object of checked radio button names and values var radios = jQuery(document).data('radioshack'); //step thru each object element and trigger a click on it's corresponding radio button for(key in radios){ jQuery('input[name="'+key+'"]').filter('[value="'+radios[key]+'"]').trigger('click'); } // unbind the event listener on .wrap (prevents clicks on inputs from triggering function) jQuery('.wrap').unbind('mouseup'); } } */ jQuery(document).ready(function() { if ( typeof sfwd_data.pointers !== 'undefined' ) { jQuery.each(sfwd_data.pointers, function(index, value) { if ( value !== 'undefined' && value.pointer_text != '' ) { sfwd_show_pointer( index, value ); } }); } jQuery(".sfwd_tab:not(:first)").hide(); jQuery(".sfwd_tab:first").show(); jQuery(".sfwd_header_tabs a").click(function(){ stringref = jQuery(this).attr("href").split('#')[1]; jQuery('.sfwd_tab:not(#'+stringref+')').hide(); jQuery('.sfwd_tab#' + stringref).show(); jQuery('.sfwd_header_tab[href!=#'+stringref+']').removeClass('active'); jQuery('.sfwd_header_tab#[href=#' + stringref+']').addClass('active'); return false; }); jQuery("body.post-type-sfwd-courses #categorydiv > h3 > span, body.post-type-sfwd-lessons #categorydiv > h3 > span, body.post-type-sfwd-topic #categorydiv > h3 > span, body.post-type-sfwd-courses #categorydiv > h3 > span").html(sfwd_data.learndash_categories_lang); if(jQuery(".sfwd-lessons_settings").length) learndash_lesson_edit_page_javascript(); if(jQuery(".sfwd-courses_settings").length) learndash_course_edit_page_javascript(); if(jQuery(".sfwd-topic_settings").length) { learndash_topic_edit_page_javascript(); } if(jQuery("body.post-type-sfwd-assignment #learndash_assignment_metabox").length ) { learndash_assignment_edit_page_javascript(); } if(jQuery(".sfwd-quiz_settings").length) { learndash_quiz_edit_page_javascript(); } }); function learndash_lesson_edit_page_javascript() { jQuery("input[name='sfwd-lessons_lesson_assignment_upload']").change(function(){ checked = jQuery("input[name=sfwd-lessons_lesson_assignment_upload]:checked").length; if(checked) { jQuery("#sfwd-lessons_auto_approve_assignment").slideDown(); jQuery("#sfwd-lessons_lesson_assignment_points_enabled").slideDown(); jQuery("#sfwd-lessons_assignment_upload_limit_extensions").slideDown(); jQuery("#sfwd-lessons_assignment_upload_limit_size").slideDown(); //jQuery("#sfwd-lessons_lesson_assignment_points_amount").show(); jQuery("input[name='sfwd-lessons_lesson_assignment_points_enabled']").change(); // We uncheck the Video Progression option because we don't support Assignments and Videos if ( jQuery("input[name='sfwd-lessons_lesson_video_enabled']").length ) { jQuery("input[name='sfwd-lessons_lesson_video_enabled']").attr('checked', false); jQuery("#sfwd-lessons_lesson_video_enabled").hide(); } jQuery("#sfwd-lessons_lesson_assignment_deletion_enabled").slideDown(); } else { jQuery("#sfwd-lessons_auto_approve_assignment").slideUp(); jQuery("#sfwd-lessons_lesson_assignment_points_enabled").slideUp(); jQuery("#sfwd-lessons_assignment_upload_limit_extensions").slideUp(); jQuery("#sfwd-lessons_assignment_upload_limit_size").slideUp(); jQuery("#sfwd-lessons_lesson_assignment_deletion_enabled").slideUp(); // We force the checkbox for 'Award Points for Assignment' to false then trigger the logic to hide the sub-input element(s) jQuery("input[name='sfwd-lessons_lesson_assignment_points_enabled']").attr('checked', false); //jQuery("#sfwd-lessons_lesson_assignment_points_amount").hide(); jQuery("input[name='sfwd-lessons_lesson_assignment_points_enabled']").change(); if ( jQuery("input[name='sfwd-lessons_lesson_video_enabled']").length ) { jQuery("#sfwd-lessons_lesson_video_enabled").slideDown(); } } if( jQuery("[name='sfwd-lessons_auto_approve_assignment']").length ) { jQuery("[name='sfwd-lessons_auto_approve_assignment']").change(); } }); if(jQuery("input[name='sfwd-lessons_lesson_assignment_upload']").length) { jQuery("input[name='sfwd-lessons_lesson_assignment_upload']").change(); } jQuery("[name='sfwd-lessons_lesson_assignment_points_enabled']").change(function(){ checked = jQuery("[name=sfwd-lessons_lesson_assignment_points_enabled]:checked").length; if(checked) { jQuery("#sfwd-lessons_lesson_assignment_points_amount").slideDown(); } else { jQuery("#sfwd-lessons_lesson_assignment_points_amount").slideUp(); // Clear out the Points amount value jQuery("[name='sfwd-lessons_lesson_assignment_points_amount']").val('0'); } }); if(jQuery("[name='sfwd-lessons_lesson_assignment_points_enabled']").length) { jQuery("[name='sfwd-lessons_lesson_assignment_points_enabled']").change(); } jQuery('[name="sfwd-lessons_auto_approve_assignment"]').change(function(){ checked = jQuery("[name=sfwd-lessons_lesson_assignment_upload]:checked").length; if ( checked ) { checked = jQuery("[name=sfwd-lessons_auto_approve_assignment]:checked").length; if(checked) { jQuery("#sfwd-lessons_assignment_upload_limit_count").slideUp(); jQuery("#sfwd-lessons_lesson_assignment_deletion_enabled").slideUp(); } else { jQuery("#sfwd-lessons_assignment_upload_limit_count").slideDown(); jQuery("#sfwd-lessons_lesson_assignment_deletion_enabled").slideDown(); } } else { jQuery("#sfwd-lessons_assignment_upload_limit_count").slideUp(); jQuery("#sfwd-lessons_lesson_assignment_deletion_enabled").slideUp(); } }); if(jQuery("[name='sfwd-lessons_auto_approve_assignment']").length) { jQuery("[name='sfwd-lessons_auto_approve_assignment']").change(); } var video_enabled_checked = false; var video_shown_checked = false; var video_shown_selected = false; var video_auto_complete_checked = false; if ( jQuery("input[name='sfwd-lessons_lesson_video_enabled']").length ) { jQuery("input[name='sfwd-lessons_lesson_video_enabled']").change( function() { video_enabled_checked = jQuery("input[name=sfwd-lessons_lesson_video_enabled]:checked").length; if( video_enabled_checked ) { jQuery("#sfwd-lessons_lesson_video_url").slideDown(); jQuery("#sfwd-lessons_lesson_video_auto_start").slideDown(); jQuery("#sfwd-lessons_lesson_video_show_controls").slideDown(); jQuery("#sfwd-lessons_lesson_video_shown").slideDown(); if ( jQuery("input[name='sfwd-lessons_lesson_assignment_upload']").length ) { jQuery("input[name='sfwd-lessons_lesson_assignment_upload']").attr('checked', false); jQuery("#sfwd-lessons_lesson_assignment_upload").hide(); } } else { jQuery("#sfwd-lessons_lesson_video_url").hide(); jQuery("#sfwd-lessons_lesson_video_auto_start").hide(); jQuery("#sfwd-lessons_lesson_video_show_controls").hide(); jQuery("#sfwd-lessons_lesson_video_shown").hide(); jQuery("#sfwd-lessons_lesson_video_auto_complete").hide(); jQuery("#sfwd-lessons_lesson_video_auto_complete_delay").hide(); if ( jQuery("input[name='sfwd-lessons_lesson_assignment_upload']").length ) { jQuery("#sfwd-lessons_lesson_assignment_upload").slideDown(); } } if ( jQuery("select[name='sfwd-lessons_lesson_video_shown']").length ) { jQuery("select[name='sfwd-lessons_lesson_video_shown']").change(); } }); jQuery("input[name='sfwd-lessons_lesson_video_enabled']").change(); } if ( jQuery("select[name='sfwd-lessons_lesson_video_shown']").length ) { jQuery("select[name='sfwd-lessons_lesson_video_shown']").change( function() { video_shown_checked = jQuery("input[name=sfwd-lessons_lesson_video_enabled]:checked").length; video_shown_selected = jQuery("select[name='sfwd-lessons_lesson_video_shown']").val(); if ( ( video_enabled_checked ) && ( video_shown_checked ) && ( video_shown_selected == 'AFTER' ) ) { jQuery("#sfwd-lessons_lesson_video_auto_complete").slideDown(); } else { jQuery("#sfwd-lessons_lesson_video_auto_complete").hide(); } if ( jQuery("input[name='sfwd-lessons_lesson_video_auto_complete']").length ) { jQuery("input[name='sfwd-lessons_lesson_video_auto_complete']").change(); } }); jQuery("select[name='sfwd-lessons_lesson_video_shown']").change(); } if ( jQuery("input[name='sfwd-lessons_lesson_video_auto_complete']").length ) { jQuery("input[name='sfwd-lessons_lesson_video_auto_complete']").change( function() { video_auto_complete_checked = jQuery("input[name=sfwd-lessons_lesson_video_auto_complete]:checked").length; if ( ( video_enabled_checked ) && ( video_shown_selected == 'AFTER') && ( video_auto_complete_checked ) ) { jQuery("#sfwd-lessons_lesson_video_auto_complete_delay").slideDown(); jQuery("#sfwd-lessons_lesson_video_hide_complete_button").slideDown(); } else { jQuery("#sfwd-lessons_lesson_video_auto_complete_delay").hide(); jQuery("#sfwd-lessons_lesson_video_hide_complete_button").hide(); } }); jQuery("input[name='sfwd-lessons_lesson_video_auto_complete']").change(); } //load_datepicker(); jQuery("input[name='sfwd-lessons_visible_after']").blur(function() { var visible_after = jQuery("input[name='sfwd-lessons_visible_after']").val(); if ( typeof visible_after !== 'undefined' ) { visible_after = parseInt( visible_after ); } else { visible_after = 0; } if ( Math.abs( visible_after ) > 0 ) { jQuery("#sfwd-lessons_visible_after_specific_date input").attr("disabled", "disabled"); jQuery("#sfwd-lessons_visible_after_specific_date select").attr("disabled", "disabled"); } else { //jQuery("input[name='sfwd-lessons_visible_after']").val('0'); jQuery("#sfwd-lessons_visible_after_specific_date input").removeAttr("disabled"); jQuery("#sfwd-lessons_visible_after_specific_date select").removeAttr("disabled"); } }); if(jQuery("input[name='sfwd-lessons_visible_after']").length) { jQuery("input[name='sfwd-lessons_visible_after']").blur(); jQuery("input[name='sfwd-lessons_visible_after']").change(function() { jQuery("input[name='sfwd-lessons_visible_after']").blur(); }); } jQuery("#sfwd-lessons_visible_after_specific_date .ld_date_selector").change(function() { var visible_specific_mm = jQuery("#sfwd-lessons_visible_after_specific_date .ld_date_selector select.ld_date_mm").val(); if ( typeof visible_specific_mm === 'undefined' ) visible_specific_mm = ''; var visible_specific_jj = jQuery("#sfwd-lessons_visible_after_specific_date .ld_date_selector input.ld_date_jj").val(); if ( typeof visible_specific_jj === 'undefined' ) visible_specific_jj = ''; var visible_specific_aa = jQuery("#sfwd-lessons_visible_after_specific_date .ld_date_selector input.ld_date_aa").val(); if ( typeof visible_specific_aa === 'undefined' ) visible_specific_aa = ''; var visible_specific_hh = jQuery("#sfwd-lessons_visible_after_specific_date .ld_date_selector input.ld_date_hh").val(); if ( typeof visible_specific_hh === 'undefined' ) visible_specific_hh = ''; var visible_specific_mn = jQuery("#sfwd-lessons_visible_after_specific_date .ld_date_selector input.ld_date_mn").val(); if ( typeof visible_specific_mn === 'undefined' ) visible_specific_mn = ''; if (( visible_specific_mm == '' ) && ( visible_specific_jj == '' ) && ( visible_specific_aa == '' ) && ( visible_specific_hh == '') && ( visible_specific_mn == '')) { jQuery("input[name='sfwd-lessons_visible_after']").removeAttr("disabled"); } else { jQuery("input[name='sfwd-lessons_visible_after']").attr("disabled", "disabled"); } }); if(jQuery("#sfwd-lessons_visible_after_specific_date .ld_date_selector").length) { jQuery("#sfwd-lessons_visible_after_specific_date .ld_date_selector").change(); } jQuery("#sfwd-lessons_visible_after_specific_date .ld_date_selector select.ld_date_mm").change(function() { var select_date_mm = jQuery("#sfwd-lessons_visible_after_specific_date .ld_date_selector select.ld_date_mm").val(); if ( typeof select_date_mm === 'undefined' ) select_date_mm = ''; if ( select_date_mm == '' ) { jQuery("#sfwd-lessons_visible_after_specific_date .ld_date_selector input.ld_date_jj").val(''); jQuery("#sfwd-lessons_visible_after_specific_date .ld_date_selector input.ld_date_aa").val(''); jQuery("#sfwd-lessons_visible_after_specific_date .ld_date_selector input.ld_date_hh").val(''); jQuery("#sfwd-lessons_visible_after_specific_date .ld_date_selector input.ld_date_mn").val(''); } }); } //function load_datepicker() { // Wait until the #ui-datepicker-div element is added to the DOM //jQuery(document).on('DOMNodeInserted', function(e) { // if (e.target.id == 'ui-datepicker-div') { // jQuery('#ui-datepicker-div').addClass('learndash-datepicker'); // } //}); //jQuery( "input[name='sfwd-lessons_visible_after_specific_date']" ).datepicker({ // changeMonth: true, // changeYear: true, // dateFormat : 'yy-mm-dd', //'MM d, yy', // onSelect: function(dateText, inst) { // jQuery("input[name='sfwd-lessons_visible_after']").val('0'); // jQuery("input[name='sfwd-lessons_visible_after']").prop('disabled', true); // } //}); // jQuery("input[name='sfwd-lessons_visible_after_specific_date']").blur(function() { // var specific_data = jQuery("input[name='sfwd-lessons_visible_after_specific_date']").val(); // if( specific_data != '') { // jQuery("input[name='sfwd-lessons_visible_after']").val('0'); // jQuery("input[name='sfwd-lessons_visible_after']").attr("disabled", "disabled"); // } else { // jQuery("input[name='sfwd-lessons_visible_after']").removeAttr("disabled"); // } // }); // jQuery("input[name='sfwd-lessons_visible_after']").click(function() { // var specific_data = jQuery("input[name='sfwd-lessons_visible_after_specific_date']").val(); // if( specific_data != '') { // jQuery("input[name='sfwd-lessons_visible_after']").val('0'); // jQuery("input[name='sfwd-lessons_visible_after']").attr("disabled", "disabled"); // } else { // jQuery("input[name='sfwd-lessons_visible_after']").removeAttr("disabled"); // } // }); //} function learndash_course_edit_page_javascript() { jQuery("select[name=sfwd-courses_course_price_type]").change(function(){ var price_type = jQuery("select[name=sfwd-courses_course_price_type]").val(); if(price_type == "open" || price_type == "free") { jQuery("input[name=sfwd-courses_course_price]").val(''); jQuery("#sfwd-courses_course_price").hide(); } else jQuery("#sfwd-courses_course_price").show(); if(price_type == "closed") jQuery("#sfwd-courses_custom_button_url").show(); else jQuery("#sfwd-courses_custom_button_url").hide(); if(price_type == "subscribe") { jQuery("#sfwd-courses_course_price_billing_cycle").show(); /*jQuery("#sfwd-courses_course_no_of_cycles").show(); jQuery("#sfwd-courses_course_remove_access_on_subscription_end").show();*/ } else { jQuery("#sfwd-courses_course_price_billing_cycle").hide(); /*jQuery("#sfwd-courses_course_no_of_cycles").hide(); jQuery("#sfwd-courses_course_remove_access_on_subscription_end").hide(); */ } }); jQuery("select[name=sfwd-courses_course_price_type]").change(); jQuery("input[name=sfwd-courses_expire_access]").change( function() { if(jQuery("input[name=sfwd-courses_expire_access]:checked").val() == undefined) { jQuery("#sfwd-courses_expire_access_days").hide(); jQuery("#sfwd-courses_expire_access_delete_progress").hide(); } else { jQuery("#sfwd-courses_expire_access_days").slideDown('slow'); jQuery("#sfwd-courses_expire_access_delete_progress").slideDown('slow'); } } ); jQuery("input[name=sfwd-courses_expire_access]").change(); jQuery("select[name=sfwd-courses_course_lesson_per_page]").change( function() { if ( jQuery("select[name=sfwd-courses_course_lesson_per_page]").val() == '' ) { jQuery("#sfwd-courses_course_lesson_per_page_custom").hide(); } else { jQuery("#sfwd-courses_course_lesson_per_page_custom").slideDown('slow'); } } ); jQuery("select[name=sfwd-courses_course_lesson_per_page]").change(); jQuery("input[name=sfwd-courses_course_prerequisite_enabled]").change( function() { if(jQuery("input[name=sfwd-courses_course_prerequisite_enabled]:checked").val() == undefined) { jQuery("#sfwd-courses_course_prerequisite").hide(); jQuery("#sfwd-courses_course_prerequisite_compare").hide(); } else { jQuery("#sfwd-courses_course_prerequisite").slideDown('slow'); jQuery("#sfwd-courses_course_prerequisite_compare").slideDown('slow'); } } ); jQuery("input[name=sfwd-courses_course_prerequisite_enabled]").change(); jQuery("input[name=sfwd-courses_course_points_enabled]").change( function() { if(jQuery("input[name=sfwd-courses_course_points_enabled]:checked").val() == undefined) { jQuery("#sfwd-courses_course_points").hide(); jQuery("#sfwd-courses_course_points_access").hide(); } else { jQuery("#sfwd-courses_course_points").slideDown('slow'); jQuery("#sfwd-courses_course_points_access").slideDown('slow'); } } ); jQuery("input[name=sfwd-courses_course_points_enabled]").change(); } function learndash_quiz_edit_page_javascript() { jQuery("select[name=sfwd-quiz_quiz_pro]").change(function() { var quiz_pro = jQuery("select[name=sfwd-quiz_quiz_pro]").val(); if(window['sfwd-quiz_quiz_pro'] != quiz_pro) { var html = jQuery("#sfwd-quiz_quiz_pro_html").html(); if ( (typeof html !== 'undefined') && (html.length > 10) ) window['sfwd-quiz_quiz_pro_html'] = html; jQuery("#sfwd-quiz_quiz_pro_html").hide(); jQuery("input[name=disable_advance_quiz_save]").val(1); } else { jQuery("#sfwd-quiz_quiz_pro_html").show(); jQuery("input[name=disable_advance_quiz_save]").val(0); } if(quiz_pro > 0) jQuery("#advanced_quiz_preview").attr("href",sfwd_data.advanced_quiz_preview_link + quiz_pro); else jQuery("#advanced_quiz_preview").attr("href","#"); jQuery.fn.wpProQuiz_preview(); }); var quiz_pro = jQuery("select[name=sfwd-quiz_quiz_pro]").val(); window['sfwd-quiz_quiz_pro'] = sfwd_data.quiz_pro; jQuery("form#post").append("
"); jQuery("select[name=sfwd-quiz_quiz_pro]").change(); jQuery("select[name=sfwd-quiz_course]").change(function() { if(window['sfwd_quiz_lesson'] == undefined) window['sfwd_quiz_lesson'] = jQuery("select[name=sfwd-quiz_lesson]").val(); jQuery("select[name=sfwd-quiz_lesson]").html(''); var data = { 'action': 'select_a_lesson_or_topic', 'course_id': jQuery(this).val() }; // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php jQuery.post(ajaxurl, data, function(json) { window['response'] = json; html = ''; jQuery.each(json.opt, function(i, opt) { if(opt.key != '' && opt.key != '0') { selected = (opt.key == window['sfwd_quiz_lesson'])? 'selected=selected': ''; html += ""; } }); jQuery("select[name=sfwd-quiz_lesson]").html(html); //jQuery("select[name=sfwd-topic_lesson]").val(window['sfwd_topic_lesson']); }, "json"); }); //jQuery("#postimagediv").addClass("hidden_by_sfwd_lms_sfwd_module.js"); //jQuery("#postimagediv").hide(); //Hide the Featured Image Metabox } // Handle logic for Assignments function learndash_assignment_edit_page_javascript() { jQuery("select[name=sfwd-assignment_course]").change(function() { if(window['sfwd-assignment_lesson'] == undefined) window['sfwd-assignment_lesson'] = jQuery("select[name=sfwd-assignment_lesson]").val(); jQuery("select[name=sfwd-assignment_lesson]").html(''); var course_id = jQuery(this).val(); var data = { 'action': 'select_a_lesson_or_topic', 'course_id': jQuery(this).val() }; jQuery.post(ajaxurl, data, function(json) { window['response'] = json; html = ''; jQuery.each(json.opt, function(i, opt) { if(opt.key != '' && opt.key != '0') { selected = (opt.key == window['sfwd-assignment_lesson'])? 'selected=selected': ''; html += ""; } }); jQuery("select[name=sfwd-assignment_lesson]").html(html); }, "json"); }); } // Handle checkbox combination logic for Lesson Topics function learndash_topic_edit_page_javascript() { jQuery('[name="sfwd-topic_lesson_assignment_upload"]').change(function(){ checked = jQuery("[name=sfwd-topic_lesson_assignment_upload]:checked").length; if(checked) { jQuery("#sfwd-topic_auto_approve_assignment").slideDown(); jQuery("#sfwd-topic_lesson_assignment_points_enabled").slideDown(); jQuery("#sfwd-topic_assignment_upload_limit_extensions").slideDown(); jQuery("#sfwd-topic_assignment_upload_limit_size").slideDown(); // We uncheck the Video Progression option because we don't support Assignments and Videos if ( jQuery("input[name='sfwd-topic_lesson_video_enabled']").length ) { jQuery("input[name='sfwd-topic_lesson_video_enabled']").attr('checked', false); jQuery("#sfwd-topic_lesson_video_enabled").hide(); } } else { jQuery("#sfwd-topic_auto_approve_assignment").slideUp(); jQuery("#sfwd-topic_assignment_upload_limit_count").slideUp(); jQuery("#sfwd-topic_lesson_assignment_points_enabled").slideUp(); jQuery("#sfwd-topic_assignment_upload_limit_extensions").slideUp(); jQuery("#sfwd-topic_assignment_upload_limit_size").slideUp(); jQuery("[name='sfwd-topic_lesson_assignment_points_enabled']").prop('checked', false); jQuery("[name='sfwd-topic_lesson_assignment_points_enabled']").change(); if ( jQuery("input[name='sfwd-topic_lesson_video_enabled']").length ) { jQuery("#sfwd-topic_lesson_video_enabled").slideDown(); } } if( jQuery("[name='sfwd-topic_auto_approve_assignment']").length ) { jQuery("[name='sfwd-topic_auto_approve_assignment']").change(); } }); if(jQuery("[name='sfwd-topic_lesson_assignment_upload']").length) { jQuery("[name='sfwd-topic_lesson_assignment_upload']").change(); } jQuery('[name="sfwd-topic_lesson_assignment_points_enabled"]').change(function(){ checked = jQuery("[name=sfwd-topic_lesson_assignment_points_enabled]:checked").length; if(checked) { jQuery("#sfwd-topic_lesson_assignment_points_amount").slideDown(); } else { jQuery("#sfwd-topic_lesson_assignment_points_amount").slideUp(); // Clear out the Points amount value jQuery("[name='sfwd-topic_lesson_assignment_points_amount']").val('0'); } }); if(jQuery("[name='sfwd-topic_lesson_assignment_points_enabled']").length) { jQuery("[name='sfwd-topic_lesson_assignment_points_enabled']").change(); } jQuery('[name="sfwd-topic_auto_approve_assignment"]').change(function(){ checked = jQuery("[name=sfwd-topic_lesson_assignment_upload]:checked").length; if ( checked ) { checked = jQuery("[name=sfwd-topic_auto_approve_assignment]:checked").length; if(checked) { jQuery("#sfwd-topic_assignment_upload_limit_count").slideUp(); jQuery("#sfwd-topic_lesson_assignment_deletion_enabled").slideUp(); } else { jQuery("#sfwd-topic_assignment_upload_limit_count").slideDown(); jQuery("#sfwd-topic_lesson_assignment_deletion_enabled").slideDown(); } } else { jQuery("#sfwd-topic_assignment_upload_limit_count").slideUp(); jQuery("#sfwd-topic_lesson_assignment_deletion_enabled").slideUp(); } }); if(jQuery("[name='sfwd-topic_auto_approve_assignment']").length) { jQuery("[name='sfwd-topic_auto_approve_assignment']").change(); } var video_enabled_checked = false; var video_shown_checked = false; var video_shown_selected = false; var video_auto_complete_checked = false; if ( jQuery("input[name='sfwd-topic_lesson_video_enabled']").length ) { jQuery("input[name='sfwd-topic_lesson_video_enabled']").change( function() { video_enabled_checked = jQuery("input[name=sfwd-topic_lesson_video_enabled]:checked").length; if( video_enabled_checked ) { jQuery("#sfwd-topic_lesson_video_url").slideDown(); jQuery("#sfwd-topic_lesson_video_auto_start").slideDown(); jQuery("#sfwd-topic_lesson_video_show_controls").slideDown(); jQuery("#sfwd-topic_lesson_video_shown").slideDown(); if ( jQuery("input[name='sfwd-topic_lesson_assignment_upload']").length ) { jQuery("input[name='sfwd-topic_lesson_assignment_upload']").attr('checked', false); jQuery("#sfwd-topic_lesson_assignment_upload").hide(); } } else { jQuery("#sfwd-topic_lesson_video_url").hide(); jQuery("#sfwd-topic_lesson_video_auto_start").hide(); jQuery("#sfwd-topic_lesson_video_show_controls").hide(); jQuery("#sfwd-topic_lesson_video_shown").hide(); jQuery("#sfwd-topic_lesson_video_auto_complete").hide(); jQuery("#sfwd-topic_lesson_video_auto_complete_delay").hide(); if ( jQuery("input[name='sfwd-topic_lesson_assignment_upload']").length ) { jQuery("#sfwd-topic_lesson_assignment_upload").slideDown(); } } if ( jQuery("select[name='sfwd-topic_lesson_video_shown']").length ) { jQuery("select[name='sfwd-topic_lesson_video_shown']").change(); } }); jQuery("input[name='sfwd-topic_lesson_video_enabled']").change(); } if ( jQuery("select[name='sfwd-topic_lesson_video_shown']").length ) { jQuery("select[name='sfwd-topic_lesson_video_shown']").change( function() { video_shown_checked = jQuery("input[name=sfwd-topic_lesson_video_enabled]:checked").length; video_shown_selected = jQuery("select[name='sfwd-topic_lesson_video_shown']").val(); if ( ( video_enabled_checked ) && ( video_shown_checked ) && ( video_shown_selected == 'AFTER' ) ) { jQuery("#sfwd-topic_lesson_video_auto_complete").slideDown(); } else { jQuery("#sfwd-topic_lesson_video_auto_complete").hide(); } if ( jQuery("input[name='sfwd-topic_lesson_video_auto_complete']").length ) { jQuery("input[name='sfwd-topic_lesson_video_auto_complete']").change(); } }); jQuery("select[name='sfwd-topic_lesson_video_shown']").change(); } if ( jQuery("input[name='sfwd-topic_lesson_video_auto_complete']").length ) { jQuery("input[name='sfwd-topic_lesson_video_auto_complete']").change( function() { video_auto_complete_checked = jQuery("input[name=sfwd-topic_lesson_video_auto_complete]:checked").length; if ( ( video_enabled_checked ) && ( video_shown_selected == 'AFTER') && ( video_auto_complete_checked ) ) { jQuery("#sfwd-topic_lesson_video_auto_complete_delay").slideDown(); jQuery("#sfwd-topic_lesson_video_hide_complete_button").slideDown(); } else { jQuery("#sfwd-topic_lesson_video_auto_complete_delay").hide(); jQuery("#sfwd-topic_lesson_video_hide_complete_button").hide(); } }); jQuery("input[name='sfwd-topic_lesson_video_auto_complete']").change(); } jQuery("select[name=sfwd-topic_course]").change(function() { if(window['sfwd_topic_lesson'] == undefined) window['sfwd_topic_lesson'] = jQuery("select[name=sfwd-topic_lesson]").val(); jQuery("select[name=sfwd-topic_lesson]").html(''); var data = { 'action': 'select_a_lesson', 'course_id': jQuery(this).val() }; // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php /* jQuery.post(ajaxurl, data, function(json) { window['response'] = json; html = ''; jQuery.each(json, function(key, value) { if(key != '' && key != '0') { selected = (key == window['sfwd_topic_lesson'])? 'selected=selected': ''; html += ""; } }); jQuery("select[name=sfwd-topic_lesson]").html(html); //jQuery("select[name=sfwd-topic_lesson]").val(window['sfwd_topic_lesson']); }, "json"); */ jQuery.post(ajaxurl, data, function(json) { window['response'] = json; html = ''; jQuery.each(json.opt, function(i, opt) { if(opt.key != '' && opt.key != '0') { selected = (opt.key == window['sfwd_quiz_lesson'])? 'selected=selected': ''; html += ""; } }); jQuery("select[name=sfwd-topic_lesson]").html(html); }, "json"); }); } // The following functions are also found in /templates/learndash_template_script.js but as that is a template and the admin // can choose to remove them I copied them into this JS file loaded for admin. I couldn't take the chance the admin // would create a version in the theme and remove the functions. if (typeof flip_expand_collapse === 'undefined') { function flip_expand_collapse(what, id) { if (jQuery( what + '-' + id + ' .list_arrow.flippable' ).hasClass( 'expand' ) ) { jQuery( what + '-' + id + ' .list_arrow.flippable' ).removeClass( 'expand' ); jQuery( what + '-' + id + ' .list_arrow.flippable' ).addClass( 'collapse' ); jQuery( what + '-' + id + ' .flip' ).slideUp(); } else { jQuery( what + '-' + id + ' .list_arrow.flippable' ).removeClass( 'collapse' ); jQuery( what + '-' + id + ' .list_arrow.flippable' ).addClass( 'expand' ); jQuery( what + '-' + id + ' .flip' ).slideDown(); } return false; } } if (typeof flip_expand_all === 'undefined') { function flip_expand_all(what) { jQuery( what + ' .list_arrow.flippable' ).removeClass( 'collapse' ); jQuery( what + ' .list_arrow.flippable' ).addClass( 'expand' ); jQuery( what + ' .flip' ).slideDown(); return false; } } if (typeof flip_collapse_all === 'undefined') { function flip_collapse_all(what) { jQuery( what + ' .list_arrow.flippable' ).removeClass( 'expand' ); jQuery( what + ' .list_arrow.flippable' ).addClass( 'collapse' ); jQuery( what + ' .flip' ).slideUp(); return false; } } /* Setup logic for lazy loading data for