Created
January 25, 2019 13:47
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($){ | |
$('.wplms_clp_step_read_more').on('click',function(event){ | |
event.preventDefault(); | |
var $this = $(this); | |
if( $this.hasClass('active') ){ | |
$this.removeClass('active'); | |
$this.parent().find('.wplms_clp_step_read').addClass('hide'); | |
$this.parent().find('.wplms_clp_step_initial').removeClass('hide'); | |
var read_more_text = $this.attr('data-read-more-text'); | |
$this.text(read_more_text); | |
return; | |
} | |
$this.addClass('active'); | |
var read_less_text = $this.attr('data-read-less-text'); | |
$this.parent().find('.wplms_clp_step_read').removeClass('hide'); | |
$this.parent().find('.wplms_clp_step_initial').addClass('hide'); | |
$this.text(read_less_text); | |
}); | |
$('#enroll_in_wplms_clp_button').on('click',function(event){ | |
event.preventDefault(); | |
var $this = $(this); | |
if($this.hasClass('loading')) | |
return; | |
$this.addClass('loading'); | |
$.confirm({ | |
text: $this.attr('data-confirm'), | |
confirm: function() { | |
//Ajax Call to enroll in custom learningpath | |
$("#enroll_in_wplms_clp_button").hide(); | |
$.ajax({ | |
type: "POST", | |
url: ajaxurl, | |
dataType: 'json', | |
data: { action: 'enroll_in_wplms_clp', | |
security: $('#enroll_inout_wplms_clp').val(), | |
id: $this.attr('data-id'), | |
}, | |
cache: false, | |
success: function (html) { | |
$this.removeClass('loading'); | |
$this.after(html.data); | |
location.reload(true); | |
} | |
}); | |
}, | |
cancel: function() { | |
$this.removeClass('loading'); | |
}, | |
confirmButton: vibe_course_module_strings.confirm, | |
cancelButton: vibe_course_module_strings.cancel | |
}); | |
}); | |
$('#enroll_out_wplms_clp_button').on('click',function(event){ | |
event.preventDefault(); | |
var $this = $(this); | |
if($this.hasClass('loading')) | |
return; | |
$this.addClass('loading'); | |
$.confirm({ | |
text: $this.attr('data-confirm'), | |
confirm: function() { | |
//Ajax Call to enroll out of custom learningpath | |
$.ajax({ | |
type: "POST", | |
url: ajaxurl, | |
dataType: 'json', | |
data: { action: 'enroll_out_wplms_clp', | |
security: $('#enroll_inout_wplms_clp').val(), | |
id: $this.attr('data-id'), | |
}, | |
cache: false, | |
success: function (html) { | |
$this.after(html.data); | |
location.reload(true); | |
} | |
}); | |
}, | |
cancel: function() { | |
$this.removeClass('loading'); | |
}, | |
confirmButton: vibe_course_module_strings.confirm, | |
cancelButton: vibe_course_module_strings.cancel | |
}); | |
}); | |
$('.wplms_clp_stats li').on('click',function(event){ | |
event.preventDefault(); | |
var $this = $(this); | |
var defaultxt = $this.html(); | |
var content = $('.wplms_clp_steps_container'); | |
var id = $this.attr('id'); | |
if(id == 'desc'){ | |
$('.wplms_clp_steps').show(); | |
$('.stats_content').hide(); | |
}else{ | |
if($this.hasClass('loaded')){ | |
$('.wplms_clp_steps').hide(); | |
$('.stats_content').show(); | |
}else{ | |
$this.addClass('loaded'); | |
$('.wplms_clp_steps').hide(); | |
$(this).html('<i class="fa fa-spinner"></i>'); | |
var lp_id = $this.parent().attr('data-id'); | |
var type = $this.parent().attr('data-type'); | |
$.ajax({ | |
type: "POST", | |
url: ajaxurl, | |
data: { action: 'wplms_clp_load_stats', | |
cpttype: type, | |
id: lp_id | |
}, | |
cache: false, | |
success: function (html) { | |
$('.wplms_clp_steps').after(html); | |
setTimeout(function(){$this.html(defaultxt); }, 1000); | |
} | |
}); | |
} | |
} | |
$this.parent().find('.active').removeClass('active'); | |
$this.addClass('active'); | |
}); | |
}); | |
jQuery(document).ready(function(){ | |
jQuery('table#wplms_clp_leaderboard').DataTable({ | |
"bProcessing": true, | |
"bServerSide": true, | |
"sAjaxSource": ajaxurl | |
}); | |
jQuery('.wplms_clp_loggedout').click(function(){ | |
jQuery('.vbplogin').trigger('click'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment