1(function($){ 2 3 // responsive video 4 $.fn.gdlr_lms_fluid_video = function(){ 5 $(this).find('iframe[src^="http://www.youtube.com"], iframe[src^="https://www.youtube.com"], iframe[src^="//www.youtube.com"],' + 6 'iframe[src^="http://player.vimeo.com"], iframe[src^="https://player.vimeo.com"], iframe[src^="//player.vimeo.com"]').each(function(){ 7 if( ($(this).is('embed') && $(this).parent('object').length) || $(this).parent('.fluid-width-video-wrapper').length ){ return; } 8 if( !$(this).attr('id') ){ $(this).attr('id', 'gdlr-video-' + Math.floor(Math.random()*999999)); } 9 10 // ignore if inside layerslider 11 if( $(this).closest('.ls-container').length <= 0 ){ 12 var ratio = $(this).height() / $(this).width(); 13 $(this).removeAttr('height').removeAttr('width'); 14 $(this).wrap('<div class="gdlr-fluid-video-wrapper"></div>').parent().css('padding-top', (ratio * 100)+"%"); 15 } 16 17 }); 18 19 $(window).trigger('resize'); 20 } 21 22 // create the alert message 23 function gdlr_lms_confirm(options){ 24 var settings = $.extend({ 25 text: 'Are you sure you want to do this ?', 26 sub: '', 27 yes: 'Yes', 28 no: 'No', 29 success: function(){} 30 }, options); 31 32 var confirm_button = $('<a class="gdlr-lms-button blue">' + settings.yes + '</a>'); 33 var decline_button = $('<a class="gdlr-lms-button red">' + settings.no + '</a>'); 34 var confirm_box = $('<div class="gdlr-lms-confirm-wrapper"></div>'); 35 var confirm_overlay = $('<div class="gdlr-lms-confirm-overlay"></div>'); 36 37 confirm_box.append('<span class="head">' + settings.text + '</span>'); 38 if( settings.sub != '' ){ 39 confirm_box.append('<span class="sub">' + settings.sub + '</span>'); 40 } 41 confirm_box.append(confirm_button); 42 confirm_box.append(decline_button); 43 44 $('body').append(confirm_overlay).append(confirm_box); 45 46 // center the alert box position 47 confirm_box.css({ 'margin-left': -(confirm_box.outerWidth() / 2), 'margin-top': -(confirm_box.outerHeight() / 2)}); 48 49 // animate the alert box 50 confirm_box.animate({opacity:1},{duration: 200}); 51 confirm_overlay.animate({opacity:0.75},{duration: 150}); 52 53 confirm_button.click(function(){
54 if(typeof(settings.success) == 'function'){ settings.success(); } 55 confirm_box.fadeOut(200, function(){ $(this).remove(); }); 56 confirm_overlay.fadeOut(200, function(){ $(this).remove(); }); 57 }); 58 decline_button.click(function(){ 59 confirm_box.fadeOut(200, function(){ $(this).remove(); }); 60 confirm_overlay.fadeOut(200, function(){ $(this).remove(); }); 61 }); 62 } 63 function gdlr_lms_notice(options){ 64 var settings = $.extend({ 65 text: 'Please try again', 66 sub: '', 67 ok: 'Ok', 68 success: function(){} 69 }, options); 70 71 var confirm_button = $('<a class="gdlr-lms-button blue">' + settings.ok + '</a>'); 72 var confirm_box = $('<div class="gdlr-lms-confirm-wrapper"></div>'); 73 var confirm_overlay = $('<div class="gdlr-lms-confirm-overlay"></div>'); 74 75 confirm_box.append('<span class="head">' + settings.text + '</span>'); 76 if( settings.sub != '' ){ 77 confirm_box.append('<span class="sub">' + settings.sub + '</span>'); 78 } 79 confirm_box.append(confirm_button); 80 $('body').append(confirm_overlay).append(confirm_box); 81 82 // center the alert box position 83 confirm_box.css({ 'margin-left': -(confirm_box.outerWidth() / 2), 'margin-top': -(confirm_box.outerHeight() / 2)}); 84 85 // animate the alert box 86 confirm_box.animate({opacity:1},{duration: 200}); 87 confirm_overlay.animate({opacity:0.75},{duration: 150}); 88 89 confirm_button.click(function(){
90 if(typeof(settings.success) == 'function'){ settings.success(); } 91 confirm_box.fadeOut(200, function(){ $(this).remove(); }); 92 confirm_overlay.fadeOut(200, function(){ $(this).remove(); }); 93 }); 94 } 95 96 function gdlr_lms_lightbox(content, allow_close){ 97 var lightbox = $('<div class="gdlr-lms-lightbox-wrapper"></div>').appendTo('body'); 98 var overlay = $('<div class="gdlr-lms-lightbox-overlay" ></div>'); 99 100 var content_return = ''; 101 if( content.attr('data-return') == 'parent' ){ 102 content_return = content.parent(); 103 } 104 105 // close lightbox 106 if( allow_close ){ 107 overlay.click(function(){ 108 lightbox.fadeOut(200, function(){ 109 if( content_return ){ 110 content_return.append($(this).find('.gdlr-lms-lightbox-container')); 111 } 112 $(this).remove(); 113 }); 114 }); 115 116 content.find('.gdlr-lms-lightbox-close').click(function(){ 117 lightbox.fadeOut(200, function(){ 118 if( content_return ){ 119 content_return.append($(this).find('.gdlr-lms-lightbox-container')); 120 } 121 $(this).remove(); 122 }); 123 }); 124 } 125 126 127 128 content.find('.gdlr-lms-lightbox-printer').click(function(){ 129 var printContents = $($(this).siblings('.gdlr-printable').html()); 130 $('body').children('div, img').css('display', 'none'); 131 $('body').append(printContents); 132 $('html, body').css('background-color', '#fff'); 133 window.print(); 134 printContents.remove(); 135 $('html, body').css('background-color', ''); 136 $('body').children('div, img').css('display', 'block'); 137 }); 138 139 lightbox.append(overlay).append(content); 140 lightbox.fadeIn(200); 141 142 lightbox.gdlr_lms_fluid_video(); 143 144 // set height for certificate 145 if( content.children().is('.certificate-form-printable') ){ 146 content.css('margin-top', -content.height()/2); 147 } 148 } 149 150 function gdlr_lms_format_time(second){ 151 var hrs = parseInt(second / 3600); 152 second = second % 3600; 153 154 var mins = parseInt(second / 60); 155 mins = (mins < 10)? '0' + mins: mins; 156 157 second = second % 60; 158 second = (second < 10)? '0' + second: second; 159 160 return hrs + ':' + mins + ':' + second; 161 } 162 163 $(document).ready(function(){ 164 165 // date picker 166 $('input.gdlr-lms-date-picker').datepicker({ 167 dateFormat : 'yy-mm-dd' 168 }); 169 170 // rating 171 $('.rating-form .gdlr-rating-input').each(function(){ 172 $(this).children().hover(function(){ 173 $(this).parent().siblings('.rating-input').val($(this).attr("data-value")); 174 175 if($(this).is('i')){ $(this).removeClass().addClass('icon-star-half-empty fa fa-star-half-empty'); } 176 $(this).prevAll('i').removeClass().addClass('icon-star fa fa-star'); 177 $(this).nextAll('i').removeClass().addClass('icon-star-empty fa fa-star-o'); 178 }); 179 }); 180 181 // upload admin author image 182 $('#gdlr-admin-author-image').change(function(){ 183 $(this).parents('form').submit(); 184 }) 185 $('.gdlr-page-profile .gdlr-lms-admin-head-thumbnail').click(function(){ 186 $('#gdlr-admin-author-image').trigger('click'); 187 }); 188 189 // cancel booking 190 $('.gdlr-lms-cancel-booking, .gdlr-lms-delete-student').click(function(){ 191 var cancel_button = $(this); 192 var action = 'gdlr_lms_cancel_booking'; 193 if( $(this).is('.gdlr-lms-delete-student') ){ 194 action = 'gdlr_lms_delete_student'; 195 } 196 197 gdlr_lms_confirm({ 198 text: cancel_button.attr('data-title'), 199 yes: cancel_button.attr('data-yes'), 200 no: cancel_button.attr('data-no'), 201 success: function(){ 202 $.ajax({
203 type: 'POST', 204 url: cancel_button.attr('data-ajax'), 205 data: {'action':action,'id': cancel_button.attr('data-id')}, 206 dataType: 'json', 207 error: function(a, b, c){ console.log(a, b, c); }, 208 success: function(data){ 209 location.reload(); 210 } 211 }); 212 } 213 }); 214 215 return false; 216 }); 217 218 // view quiz answer 219 $('.gdlr-lms-view-correct-answer').click(function(){ 220 var view_button = $(this); 221 gdlr_lms_confirm({ 222 text: view_button.attr('data-title'), 223 sub: view_button.attr('data-sub-title'), 224 yes: view_button.attr('data-yes'), 225 no: view_button.attr('data-no'), 226 success: function(){ 227 location.href = view_button.attr('href'); 228 } 229 }); 230 231 return false; 232 }); 233 234 // equally set course style-2 height 235 $(window).resize(function(){ 236 $('.gdlr-lms-course-grid2-wrapper').each(function(){ 237 var max_height = 0; 238 var child_elements = $(this).find('.gdlr-lms-item'); 239 240 child_elements.css('height', 'auto'); 241 if($(window).width() <= '767') return; 242 243 child_elements.each(function(){ 244 if($(this).height() > max_height) max_height = $(this).height(); 245 }); 246 child_elements.height(max_height); 247 }); 248 }); 249 250 // init the lightbox 251 $('[data-rel="gdlr-lms-lightbox"]').click(function(){ 252 var content = $(this).siblings('.' + $(this).attr('data-lb-open')); 253 if( !content.attr('data-return') ){ 254 var content = $(this).siblings('.' + $(this).attr('data-lb-open')).clone(true); 255 } 256 if(content.length > 0){ gdlr_lms_lightbox(content, true); } 257 }); 258 $('[data-rel="gdlr-lms-lightbox2"]').click(function(){ 259 var content = $(this).siblings('.gdlr-lms-lightbox-container-wrapper').clone(true);
260 content.children('.' + $(this).attr('data-lb-open')).show(); 261 if(content.length > 0){ gdlr_lms_lightbox(content, true); } 262 }); 263 $('[data-rel="gdlr-lms-lightbox3"]').click(function(){ 264 $(this).parents('.gdlr-lms-lightbox-container').fadeOut(200) 265 .siblings('.' + $(this).attr('data-lb-open')).fadeIn(200); 266 }); 267 268 // quiz timer 269 $('.gdlr-lms-quiz-timer input[name="timeleft"]').each(function(){ 270 if($(this).attr('data-full') == '0' || $(this).attr('data-full') == '') return; 271 272 var timer = $(this); 273 var display = timer.siblings('.timer'); 274 var time_left = parseInt(timer.val()); 275 276 var i = setInterval(function(){ 277 if( time_left > 0 ){ 278 time_left = time_left - 1; 279 timer.val(time_left); 280 display.html(gdlr_lms_format_time(time_left)); 281 }else{ 282 var content = timer.siblings('.quiz-timeout-form').clone(true); 283 gdlr_lms_lightbox(content, false); 284 clearInterval(i); 285 } 286 }, 1000); 287 }); 288 $('.submit-quiz-timeout-form').click(function(){ 289 $(this).parents('.gdlr-lms-lightbox-wrapper').fadeOut(200, function(){ 290 $(this).remove(); 291 }); 292 293 $('.finish-quiz-form-button').trigger('click'); 294 }); 295 296 // quiz form submit 297 $('.submit-quiz-form').click(function(){ 298 var current_form = $(this).parents('form'); 299 300 if( current_form.length <= 0 ){ current_form = $('form.gdlr-lms-quiz-type'); } 301 302 current_form.attr('action', $(this).attr('href')); 303 current_form.submit(); 304 return false; 305 }); 306 307 // finish course button 308 $('.finish-quiz-form-button').click(function(){ 309 current_button = $(this); 310 if( current_button.html() == current_button.attr('data-loading') ){ 311 return false; 312 } 313 314 current_button.html(current_button.attr('data-loading')); 315 quiz_form = current_button.parents('form'); 316 317 $.ajax({ 318 type: 'POST', 319 url: current_button.attr('href'), 320 data: quiz_form.serialize(), 321 dataType: 'json', 322 error: function(a, b, c){ console.log(a, b, c); }, 323 success: function(){ 324 var content = current_button.siblings('.finish-quiz-form').clone(true); 325 gdlr_lms_lightbox(content, false); 326 } 327 }); 328 329 return false; 330 }); 331 332 // payment selection 333 $('.gdlr-payment-method input[name="payment-method"]').click(function(){ 334 $(this).parent('label').addClass('gdlr-active').siblings().removeClass('gdlr-active'); 335 }); 336 337 // buy / book button 338 $('.buy-form form, .book-form form').each(function(){ 339 if( $(this).hasClass('gdlr-no-ajax') ) return; 340 341 $(this).on('price-calculate', function(){ 342 var price_one = $(this).find('.price-one'); 343 var price_format = price_one.siblings('.format').val(); 344 var price = parseFloat(price_one.val()) * parseInt($(this).find('input[name="quantity"]').val()); 345 346 var discount = $(this).find('input.coupon-amount'); 347 var discount_type = discount.siblings('input.coupon-type'); 348 var discount_price = 0; 349 if( discount_type.val() == 'percent' ){ 350 discount_price = parseInt( price * parseInt(discount.val()) / 100 ); 351 }else if( discount_type.val() == 'amount' ){ 352 discount_price = parseInt( discount.val() ); 353 } 354 if( discount_price > price ){ 355 discount_price = price; 356 } 357 358 price = price - discount_price; 359 price_one.siblings('.price').val(price); 360 price_one.siblings('.price-display').val(price_format.replace('NUMBER', price)); 361 discount.siblings('.discount-amount').val(discount_price); 362 }); 363 364 $(this).find('input[name="quantity"]').on('keyup', function(){ 365 if( $(this).val() != '' ){ 366 $(this).closest('form').trigger('price-calculate'); 367 } 368 }); 369 370 $(this).find('.gdlr-lms-coupon-code').on('keyup', function(){ 371 var current_form = $(this).closest('form'); 372 var coupon_code = $(this); 373 374 if( $(this).val() != '' ){ 375 $(this).siblings('.gdlr-lms-coupon-head').removeClass().addClass('gdlr-lms-coupon-head coupon-loading'); 376 $(this).siblings('.gdlr-lms-coupon-status').slideUp(200); 377 378 $.ajax({
379 type: 'POST', 380 url: current_form.attr('data-ajax'), 381 data: {action:'lms_check_coupon_code', id: $(this).val(), course_id: current_form.find('input[name="course_id"]').val()}, 382 dataType: 'json', 383 error: function(a, b, c){ console.log(a, b, c); }, 384 success: function(data){ 385 if( data.status == 'failed' ){ 386 coupon_code.siblings('.gdlr-lms-coupon-head').removeClass().addClass('gdlr-lms-coupon-head coupon-wrong'); 387 if( data.message ){ 388 coupon_code.siblings('.gdlr-lms-coupon-status').html(data.message).slideDown(200); 389 }else{ 390 coupon_code.siblings('.gdlr-lms-coupon-status').slideUp(200); 391 } 392 }else if( data.status == 'success' ){ 393 coupon_code.siblings('input.coupon-amount').val(data.amount); 394 coupon_code.siblings('input.coupon-type').val(data.type); 395 coupon_code.siblings('.gdlr-lms-coupon-head').removeClass().addClass('gdlr-lms-coupon-head coupon-correct'); 396 if( data.message ){ 397 coupon_code.siblings('.gdlr-lms-coupon-status').html(data.message).slideDown(200); 398 }else{ 399 coupon_code.siblings('.gdlr-lms-coupon-status').slideUp(200); 400 } 401 } 402 403 current_form.trigger('price-calculate'); 404 } 405 }); 406 }else{ 407 $(this).siblings('.gdlr-lms-coupon-head').removeClass().addClass('gdlr-lms-coupon-head'); 408 $(this).siblings('.gdlr-lms-coupon-status').slideUp(200); 409 } 410 }); 411 412 $(this).submit(function(e){ 413 var current_form = $(this); 414 var notice = $(this).find('.gdlr-lms-notice').slideUp(200); 415 var loading = $(this).find('.gdlr-lms-loading').slideDown(200); 416 417 $.ajax({
418 type: 'POST', 419 url: $(this).attr('data-ajax'), 420 data: jQuery(this).serialize(), 421 dataType: 'json', 422 error: function(a, b, c){ console.log(a, b, c); }, 423 success: function(data){ 424 if( data.status == 'success' ){ 425 notice.addClass('success'); 426 }else{ 427 notice.removeClass('success'); 428 } 429 430 notice.html(data.message).slideDown(200); 431 loading.slideUp(200); 432 433 if( data.status == 'success' && data.redirect ){ 434 if( data.redirect == true ){ 435 if( data.id ){ 436 current_form.find('[name="invoice"]').val(data.id); 437 } 438 current_form[0].submit(); 439 }else{ 440 window.location.replace(data.redirect); 441 } 442 }else if( data.status == 'success' && data.payment == 'cloud' ){ 443 var payments = new cp.CloudPayments({ language: "en-US" }); 444 payments.charge( data.data, 445 function (options){ 446 $.ajax({ 447 type: 'POST', 448 url: current_form.attr('data-ajax'), 449 data: { action:'gdlr_lms_cloud_payment', return_val:options }, 450 dataType: 'json', 451 error: function(a, b, c){ console.log(a, b, c); }, 452 success: function(data2){ 453 if( data2.status == 'success' ){ 454 if( data2.redirect ){ 455 window.location.replace(data2.redirect); 456 } 457 }else{ 458 if( data2.message ){ 459 gdlr_lms_notice({ 460 text: data2.message, 461 sub: (data2.message_sub)? data2.message_sub: '', 462 ok: data.ok_button 463 }); 464 } 465 } 466 } 467 }); 468 }, 469 function (reason, options){ 470 gdlr_lms_notice({ 471 text: data.payment_failed_text, 472 sub: reason, 473 ok: data.ok_button 474 }); 475 } 476 ); 477 } 478 } 479 }); 480 481 e.preventDefault(); 482 e.returnValue = false; 483 }); 484 485 }); 486 }); 487 488 $(window).load(function(){ $(this).trigger('resize'); }); 489 490})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.