1(function ($) { 2 'use strict'; 3 4 /** 5 * All of the code for your public-facing JavaScript source 6 * should reside in this file. 7 * 8 * Note that this assume you're going to use jQuery, so it prepares 9 * the $ function reference to be used within the scope of this 10 * function. 11 * 12 * From here, you're able to define handlers for when the DOM is 13 * ready: 14 * 15 * $(function() { 16 * 17 * }); 18 * 19 * Or when the window is loaded: 20 * 21 * $( window ).load(function() { 22 * 23 * }); 24 * 25 * ...and so on. 26 * 27 * Remember that ideally, we should not attach any more than a single DOM-ready or window-load handler 28 * for any particular page. Though other scripts in WordPress core, other plugins, and other themes may 29 * be doing this, we should try to minimize doing that in our own work. 30 */ 31 32 /** 33 * Provides the functionality to place the new order on click of the Take this course button. 34 */ 35 function placeOrder(formSubmit) { 36 var course_id = $("input[name='item_number']").val(); 37 var order_id = ''; 38 var buyer_id = $("input[name='custom']").val(); 39 var custom_data = {}; 40 41 $.ajax({
42 method: 'post', 43 async: false, 44 url: eb_public_js_object.ajaxurl, 45 dataType: 'json', 46 data: { 47 action: 'createNewOrderAjaxWrapper', 48 buyer_id: buyer_id, 49 course_id: course_id, 50 _wpnonce_field: eb_public_js_object.nonce, 51 }, 52 success: function (response) { 53 //prepare response for user 54 if (response.success == 1) { 55 //create custom data encoded in json 56 custom_data['buyer_id'] = parseInt(buyer_id); 57 custom_data['order_id'] = parseInt(response.order_id); 58 // custom_data['eb_nonce'] = response.nonce; 59 60 $("input[name='custom']").val(JSON.stringify(custom_data)); 61 62 /* 63 *--------------------------------------- 64 *Added code to solve payment pending issue 65 * ------------------------------------- 66 */ 67 // submitting form if the submit form is on. 68 // added button click event on class as there are 2 payment forms in the single course page with 2 submit buttons with same id. 69 if (formSubmit) { 70 $('.eb-paid-course').click(); 71 } 72 } else { 73 e.preventDefault(); 74 alert(eb_public_js_object.msg_ordr_pro_err); 75 } 76 }, 77 }); 78 } 79 80 $(window).on('load', function () { 81 function getUrlParameter(sParam) { 82 var sPageURL = decodeURIComponent(window.location.search.substring(1)), 83 sURLVariables = sPageURL.split('&'), 84 sParameterName, 85 i; 86 87 for (i = 0; i < sURLVariables.length; i++) { 88 sParameterName = sURLVariables[i].split('='); 89 90 if (sParameterName[0] === sParam) { 91 return sParameterName[1] === undefined ? true : sParameterName[1]; 92 } 93 } 94 } 95 96 if (getUrlParameter('auto_enroll') === 'true') { 97 if (eb_public_js_object.eb_single_course_override === '1') { 98 $(window).on('eb_course_btn_loaded', function () { 99 $.blockUI({ 100 message: eb_public_js_object.msg_processing, 101 }); 102 103 var btn = document.getElementById('eb_course_payment_button'); 104 if (btn == null) { 105 btn = document.getElementById('wdm-btn'); 106 if (btn == null) { 107 $.unblockUI(); 108 } else if (btn.text != eb_public_js_object.access_course) { 109 btn.click(); 110 } else { 111 $.unblockUI(); 112 } 113 } else { 114 /* 115 * --------------------------------- 116 * Commented the btn.click() to solve pending payment issue. 117 * -------------------------------- 118 */ 119 /*btn.click();*/ 120 placeOrder(1); 121 } 122 }); 123 } else { 124 $.blockUI({ 125 message: eb_public_js_object.msg_processing, 126 }); 127 128 var btn = document.getElementById('eb_course_payment_button'); 129 if (btn == null) { 130 btn = document.getElementById('wdm-btn'); 131 if (btn == null) { 132 $.unblockUI(); 133 } else if (btn.text != eb_public_js_object.access_course) { 134 btn.click(); 135 } else { 136 $.unblockUI(); 137 } 138 } else { 139 /* 140 * --------------------------------- 141 * Commented the btn.click() to solve pending payment issue. 142 * -------------------------------- 143 */ 144 /*btn.click();*/ 145 placeOrder(1); 146 } 147 } 148 } 149 150 /* Change required fields error messages for login / register page */ 151 var intputElements = document.getElementsByTagName('INPUT'); 152 for (var i = 0; i < intputElements.length; i++) { 153 intputElements[i].oninvalid = function (e) { 154 e.target.setCustomValidity(''); 155 if (!e.target.validity.valid) { 156 if (e.target.name == 'firstname') { 157 e.target.setCustomValidity(eb_public_js_object.msg_val_fn); 158 } else if (e.target.name == 'lastname') { 159 e.target.setCustomValidity(eb_public_js_object.msg_val_ln); 160 } else if (e.target.name == 'email') { 161 e.target.setCustomValidity(eb_public_js_object.msg_val_mail); 162 } 163 } 164 }; 165 } 166 167 /** 168 * datatable js for user order history table 169 */ 170 $('#wdm_user_order_history').dataTable({ 171 aLengthMenu: [ 172 [5, 10, 25, -1], 173 [5, 10, 25, ebDataTable.all], 174 ], 175 iDisplayLength: 10, 176 order: [[1, 'desc']], 177 columnDefs: [ 178 { 179 targets: 'no-sort', 180 orderable: true, 181 }, 182 ], 183 language: { 184 search: ebDataTable.search, 185 sEmptyTable: ebDataTable.sEmptyTable, 186 sLoadingRecords: ebDataTable.sLoadingRecords, 187 sSearch: ebDataTable.sSearch, 188 sZeroRecords: ebDataTable.sZeroRecords, 189 sProcessing: ebDataTable.sProcessing, 190 sInfo: ebDataTable.sInfo, 191 sInfoEmpty: ebDataTable.sInfoEmpty, 192 sInfoFiltered: ebDataTable.sInfoFiltered, 193 sInfoPostFix: ebDataTable.sInfoPostFix, 194 sInfoThousands: ebDataTable.sInfoThousands, 195 sLengthMenu: ebDataTable.sLengthMenu, 196 oPaginate: { 197 sFirst: ebDataTable.sFirst, 198 sLast: ebDataTable.sLast, 199 sNext: ebDataTable.sNext, 200 sPrevious: ebDataTable.sPrevious, 201 }, 202 oAria: { 203 sSortAscending: ebDataTable.sSortAscending, 204 sSortDescending: ebDataTable.sSortDescending, 205 }, 206 }, 207 });
208 209 /** 210 * jquery blockui js to block UI on clicking take course button for paid courses. 211 */ 212 213 /** 214 * called by 'take this course' button for paid courses. 215 * calls create_new_order_ajax_wrapper() function to create a new order 216 * add the newly created order it in form to be sent to paypal. 217 * 218 */ 219 $('body').on('click', '.eb-paid-course', function (e) { 220 if ( 221 getUrlParameter('auto_enroll') === 'true' && 222 eb_public_js_object.eb_single_course_override === '1' 223 ) { 224 return; 225 } 226 227 placeOrder(0); 228 }); 229 }); 230 231 $(document).ready(function () { 232 if ($('#reg_terms_and_cond').length) { 233 $("input[name='register']").prop('disabled', true); 234 $("input[name='register']").css('cursor', 'no-drop'); 235 $('#reg_terms_and_cond').change(function () { 236 if (this.checked) { 237 $("input[name='register']").prop('disabled', false); 238 $("input[name='register']").css('cursor', 'pointer'); 239 } else { 240 $("input[name='register']").prop('disabled', true); 241 $("input[name='register']").css('cursor', 'no-drop'); 242 } 243 }); 244 } 245 246 $('#eb_terms_cond_check').click(function () { 247 var checkbox = $(this).parent().parent(); 248 checkbox = checkbox.find("input[name='reg_terms_and_cond']"); 249 $('#eb-user-account-terms-content').dialog({ 250 modal: true, 251 resizable: true, 252 width: 500, 253 dialogClass: 'eb_admin_terms_dialog', 254 buttons: [ 255 { 256 text: 'Agree', 257 class: 'eb_terms_button_agree', 258 click: function () { 259 checkbox.prop('checked', true); 260 $("input[name='register']").prop('disabled', false); 261 $("input[name='register']").css('cursor', 'pointer'); 262 $(this).dialog('close'); 263 }, 264 }, 265 { 266 text: 'Disagree', 267 class: 'eb_terms_button_disagree', 268 click: function () { 269 checkbox.prop('checked', false); 270 $(this).dialog('close'); 271 }, 272 }, 273 ], 274 }); 275 276 // $('.eb-user-account-terms div').dialog(); 277 }); 278 279 /*Submit filters form on the selction of filter*/ 280 $('#eb_category_filter').on('change', function (event) { 281 var form = $(this).closest('form'); 282 $(form).trigger('submit'); 283 }); 284 285 $('#eb_category_sort').on('change', function (event) { 286 $(this).closest('form').trigger('submit'); 287 }); 288 289 /** 290 * Scroll left 291 */ 292 $('.eb-scroll-left').on('click', function (event) { 293 event.preventDefault(); 294 var parent = $(this).parents('.eb-cat-courses-cont'); 295 var newScrollLeft = parent.scrollLeft(); 296 var width = parent.width(); 297 var scrollWidth = parent.get(0).scrollWidth; 298 var scrollOffcet = width / 2; 299 300 parent.animate( 301 { scrollLeft: parent.scrollLeft() - scrollOffcet }, 302 'fast' 303 ); 304 if (newScrollLeft <= 0 + scrollOffcet) { 305 $(this).hide(); 306 } 307 if (scrollWidth >= newScrollLeft) { 308 parent.children('.eb-scroll-right').show(); 309 } 310 }); 311 312 /** 313 * Scroll right 314 */ 315 $('.eb-scroll-right').on('click', function (event) { 316 event.preventDefault(); 317 var parent = $(this).parents('.eb-cat-courses-cont'); 318 var newScrollLeft = parent.scrollLeft(); 319 var width = parent.width(); 320 var scrollWidth = parent.get(0).scrollWidth; 321 var scrollOffcet = width / 2; 322 $(parent).children('.eb-scroll-left').show(); 323 parent.animate( 324 { scrollLeft: parent.scrollLeft() + scrollOffcet }, 325 'fast' 326 ); 327 if (scrollWidth <= newScrollLeft + width + scrollOffcet) { 328 $(this).hide(); 329 } 330 if (newScrollLeft <= 0) { 331 parent.children('.eb-scroll-left').show(); 332 } 333 }); 334 335 $('.eb-cat-courses-cont').each(function () { 336 var documentScrollLeft = jQuery('.eb-cat-courses-cont').scrollLeft(); 337 var lastScrollLeft = 0; 338 var width = $(this).width(); 339 var scrollWidth = $(this).get(0).scrollWidth; 340 if (scrollWidth <= width) { 341 lastScrollLeft = documentScrollLeft; 342 $(this).children('.eb-scroll-right').hide(); 343 } 344 $(this).children('.eb-scroll-left').hide(); 345 });
346 347 if (typeof eb_user_email_verification != 'undefined') { 348 // Show the message in the dialog box 349 $('<div></div>') 350 .html(eb_user_email_verification.message) 351 .dialog({ 352 modal: false, 353 resizable: false, 354 width: 500, 355 dialogClass: 'eb_admin_terms_dialog eb_email_verify_dialog', 356 buttons: [ 357 { 358 text: 'Ok', 359 class: 'eb_terms_button_agree', 360 click: function () { 361 $(this).dialog('close'); 362 }, 363 }, 364 ], 365 }); 366 } 367 368 // disable woocomerce quantity input field 369 $('.eb-pro-product-page-sidebar .quantity-wrap') 370 .find('input') 371 .prop('disabled', true); 372 $('.eb-pro-product-page-sidebar .quantity-wrap .quantity-minus').prop( 373 'disabled', 374 true 375 ); 376 $('.eb-pro-product-page-sidebar .quantity-wrap .quantity-plus').prop( 377 'disabled', 378 true 379 ); 380 381 $('.eb-pro-product-page-sidebar .grouped-product-quantity') 382 .find('input') 383 .prop('disabled', false); 384 $( 385 '.eb-pro-product-page-sidebar .grouped-product-quantity .quantity-minus' 386 ).prop('disabled', false); 387 $( 388 '.eb-pro-product-page-sidebar .grouped-product-quantity .quantity-plus' 389 ).prop('disabled', false); 390 391 if ($('#wdm_edwiser_self_enroll').length) { 392 var is_checked = $('#wdm_edwiser_self_enroll').is(':checked'); 393 if (is_checked) { 394 $('.eb-pro-product-page-sidebar .quantity-wrap') 395 .find('input') 396 .prop('disabled', false); 397 $('.eb-pro-product-page-sidebar .quantity-wrap .quantity-minus').prop( 398 'disabled', 399 false 400 ); 401 $('.eb-pro-product-page-sidebar .quantity-wrap .quantity-plus').prop( 402 'disabled', 403 false 404 ); 405 } 406 } 407 408 $('#wdm_edwiser_self_enroll').change(function () { 409 if (this.checked) { 410 $('.eb-pro-product-page-sidebar .quantity-wrap') 411 .find('input') 412 .prop('disabled', false); 413 $('.eb-pro-product-page-sidebar .quantity-wrap .quantity-minus').prop( 414 'disabled', 415 false 416 ); 417 $('.eb-pro-product-page-sidebar .quantity-wrap .quantity-plus').prop( 418 'disabled', 419 false 420 ); 421 } else { 422 $('.eb-pro-product-page-sidebar .quantity-wrap') 423 .find('input') 424 .prop('disabled', true); 425 $('.eb-pro-product-page-sidebar .quantity-wrap .quantity-minus').prop( 426 'disabled', 427 true 428 ); 429 $('.eb-pro-product-page-sidebar .quantity-wrap .quantity-plus').prop( 430 'disabled', 431 true 432 ); 433 $('.eb-pro-product-page-sidebar .quantity-wrap').find('input').val(1); 434 } 435 }); 436 }); 437})(jQuery); 438 439function ebSubmitCaptchaForm(token) { 440 document.getElementById('eb-user-account-form').submit(); 441}
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.