1/* 2* Bulk purchase product purchase css 3*/ 4(function ($) { 5 var dlgOverlyOpct = 0.8; 6 var dlgOverlyColor = "black"; 7 jQuery( document ).ready( 8 function () { 9 var div = '<div id="eb-lading-parent" class="eb-lading-parent-wrap"><div class="eb-loader-progsessing-anim"></div></div>'; 10 $( "body" ).append( div ); 11 div = '<div class="eb-background-div"></div>'; 12 13 /** 14 * Variable product support. 15 */ 16 $( ".single_variation_wrap" ).on( 17 "show_variation", 18 function (event, variation) { 19 // Fired when the user selects all the required dropdowns / attributes. 20 // and a final variation is selected / shown. 21 22 $( '.wdm_edwiser_bulk_purchase' ).css( 'display', 'none' ); 23 24 if ($( '#bp_enable_group_purchase_' + [variation.variation_id] ).length) { 25 $( '#bp_enable_group_purchase_' + [variation.variation_id] ).show(); 26 }/* else { 27 $('.wdm_edwiser_bulk_purchase').hide(); 28 }*/ 29 30 } 31 ); 32 33 /** 34 * Events to dismiss the responce messages on the enrolle student page. 35 */ 36 $( document ).on( 37 'click', 38 '.wdm_enroll_warning_msg_dismiss', 39 function () { 40 $( this ).parent().remove(); 41 // $('.wdm_user_list').remove(); 42 $( '#wdm_eb_message_divider' ).remove(); 43 // $('#wdm_eb_enroll_user_page').css("border", "0px solid white"); 44 } 45 ); 46 $( document ).on( 47 'click', 48 '.wdm_error_msg_dismiss', 49 function () { 50 $( this ).parent().remove(); 51 // $('.wdm_user_list').remove(); 52 $( '#wdm_eb_message_divider' ).remove(); 53 // $('#wdm_eb_enroll_user_page').css("border", "0px solid white"); 54 } 55 ); 56 $( document ).on( 57 'click', 58 '.wdm_success_msg_dismiss', 59 function () { 60 $( this ).parent().remove(); 61 // $('.wdm_user_list').remove(); 62 $( '#wdm_eb_message_divider' ).remove(); 63 // $('#wdm_eb_enroll_user_page').css("border", "0px solid white"); 64 } 65 ); 66 67 /** 68 * removing error msg 69 * 70 * @since 1.1.0 71 */ 72 73 $( document ).on( 74 'click', 75 '.wdm_success_msg_dismiss, .wdm_select_course_msg_dismiss', 76 function () { 77 $( '.wdm_select_course_msg' ).css( "display", "none" ); 78 $( '#wdm_eb_message_divider' ).remove(); 79 } 80 ); 81 82 $( document ).on( 83 'click', 84 '.wdm_enroll_warning_msg_dismiss', 85 function () { 86 $( '.wdm_enroll_warning_message' ).css( "display", "none" ); 87 $( '#wdm_eb_message_divider' ).remove(); 88 } 89 ); 90 91 $( document ).on( 92 'click', 93 '.wdm_success_msg_dismiss', 94 function () { 95 $( '.wdm_success_message' ).css( "display", "none" ); 96 $( '#wdm_eb_message_divider' ).remove(); 97 } 98 ); 99 100 $( document ).on( 101 'click', 102 '.wdm_grp_update_msg_dismiss', 103 function () { 104 $( this ).parent().css( "display", "none" ); 105 } 106 ); 107 108 $( "body" ).append( div ); 109 // Added this in the enroll students js. 110 /*$('#wdm_eb_upload_csv').hide(); 111 $('#wdm_avaliable_reg').hide(); 112 $('#enroll-new-user-btn-div').hide(); 113 $("#wdm_associated_courses_container").hide();*/ 114 var seat_limit = 0; 115 116 $( document ).on( 117 "change", 118 "#mucp-cart-group-checkbox", 119 function () { 120 if ($( this ).prop( "checked" ) == true) { 121 processGroupPurchaseCheckbox( 1 ); 122 } else if ($( this ).prop( "checked" ) == false) { 123 processGroupPurchaseCheckbox( 0 ); 124 } 125 } 126 ); 127 128 function isItemQtyEql() { 129 var allQty = []; 130 $( '.qty' ).each( 131 function () { 132 allQty.push( $( this ).val() ); 133 } 134 ) 135 var max = allQty[0]; 136 for (var cnt = 1; cnt < allQty.length; cnt++) { 137 if (max != allQty[cnt]) { 138 return false; 139 } 140 } 141 return true; 142 } 143 144 /** 145 * This will check is the bulk purchase option is present on screen 146 * if the checkbox is present on the screen then disable the quantity box. 147 */ 148 if ($( "#wdm_edwiser_self_enroll" ).length) { 149 var ischecked = $( this ).is( ':checked' ); 150 if ( ! ischecked) { 151 $( ".qty" ).prop( 'disabled', true ); 152 $( ".qty" ).attr( "value", "1" ); 153 } else { 154 $( ".qty" ).prop( 'disabled', false ); 155 } 156 } 157 158 /** 159 * Handle the group purchase enable disable events 160 * If the checkbox is enabled then enable the product quantity box 161 * Disable otherwise 162 */ 163 // add event listner for each checkbox 164 $( "input[name='wdm_edwiser_self_enroll']" ).change( 165 function () { 166 var ischecked = $( this ).is( ':checked' ); 167 if ( ! ischecked) { 168 $( ".qty" ).prop( 'disabled', true ); 169 $( ".qty" ).attr( "value", "1" ); 170 } else { 171 $( ".qty" ).prop( 'disabled', false ); 172 } 173 } 174 ); 175 176 function processGroupPurchaseCheckbox(isChecked) { 177 jQuery.ajax( 178 { 179 type: 'POST', 180 url: ebbpPublic.ajax_url, 181 dataType: 'json', 182 data: { 183 action: 'check_for_different_products', 184 single_group: isChecked, 185 }, 186 success: function (response) { 187 if (response.success == true) { 188 if (response.data.status) { 189 $( ".wdm-diff-prod-qty-error" ).addClass( "wdm-hide" ); 190 $( ".wdm-diff-prod-qty-success" ).removeClass( "wdm-hide" ); 191 $( "#wdm-diff-prod-qty-success-msg" ).html( response.data.msg ); 192 } else { 193 $( ".wdm-diff-prod-qty-error" ).removeClass( "wdm-hide" ); 194 $( ".wdm-diff-prod-qty-success" ).addClass( "wdm-hide" ); 195 $( "#wdm-diff-prod-qty-error-msg" ).html( response.data.msg ); 196 } 197 } else { 198 $( ".wdm-diff-prod-qty-error" ).removeClass( "wdm-hide" ); 199 $( ".wdm-diff-prod-qty-success" ).addClass( "wdm-hide" ); 200 $( "#wdm-diff-prod-qty-error-msg" ).html( response.data ); 201 $( "#mucp-cart-group-checkbox" ).prop( "checked", false ); 202 } 203 }, 204 error: function (error) { 205 errorMsgDialog( error ); 206 } 207 } 208 ); 209 210 } 211 212 // v1.1.1. 213 /** 214 * Show Error message. 215 */ 216 function errorMsgDialog(msg) { 217 var error = $( document.createElement( 'div' ) ); 218 msg = '<div class="ui-state-error ui-corner-all"><i class="dashicons dashicons-warning" aria-hidden="true"></i><p style = "margin-top:5%;">' + msg + '</p></div>'; 219 error.append( msg ); 220 error.dialog( 221 { 222 title: "Error", 223 autoOpen: false, 224 modal: true, 225 resizable: false, 226 dialogClass: "wdm-error-message-dialog", 227 buttons: [ 228 { 229 text: ebbpPublic.ok, 230 class: 'wdm-dialog-ok-button', 231 click: function () { 232 closeDialog( this ); 233 } 234 }, 235 ], 236 open: function (event, ui) { 237 $( ".ui-widget-overlay" ).css( 238 { 239 opacity: dlgOverlyOpct, 240 backgroundColor: dlgOverlyColor 241 } 242 ); 243 }, 244 create: function (event, ui) { 245 $( event.target ).parent().css( 'position', 'fixed' ); 246 }, 247 } 248 ).dialog( "open" ); 249 } 250 251 /** 252 * Handling change on input of Add Quantity Popup 253 */ 254 $( document ).on( 255 'keypress click input', 256 'input.add-more-quantity', 257 function (event) { 258 if (event.which == 45 || event.which == 46 || event.which == 189) { 259 event.preventDefault(); 260 } 261 var grand_total = 0; 262 var quantity = $( this ).val(); 263 if (quantity == "") { 264 quantity = 0; 265 } 266 var productId = $( this ).attr( "id" ); 267 var minQuantity = $( "#" + productId + "-min-quantity" ).html(); 268 var perProductPrice = $( "#" + productId + "-per-product-price" ).html(); 269 $( "#" + productId + "-total-quantity" ).html( parseInt( minQuantity ) + parseInt( quantity ) ); 270 $( "#" + productId + "-total-price" ).html( parseFloat( perProductPrice ) * parseInt( quantity ) ); 271 var totals = jQuery( '.wdm-quantity-total' ); 272 totals.each( 273 function (index, value) { 274 grand_total += parseFloat( $( this ).html() ); 275 } 276 ); 277 $( '#add-quantity-total-price' ).html( grand_total ); 278 } 279 ); 280 281 /** 282 * Functionality to caclulate the total price per product 283 * in the add more product/quantity popup 284 */ 285 $( document ).on( 286 'change DOMSubtreeModified', 287 '.wdm_new_qty_per_prod', 288 function (event) { 289 var wdmId = $( this ).attr( 'id' ); 290 var priceId = wdmId + "-per-product-price"; 291 var totalPriceId = wdmId + "-total-price"; 292 $( "#" + totalPriceId ).html( ($( "#" + wdmId ).html() * $( "#" + priceId ).html()).toFixed( 2 ) ); 293 } 294 ); 295 /** 296 * Functionality to caclulate the total price per product 297 * in the add more product/quantity popup 298 */ 299 $( document ).on( 300 'change DOMSubtreeModified', 301 '.wdm_new_qty_per_new_prod', 302 function (event) { 303 var wdmId = $( this ).attr( 'id' ); 304 var selectedProd = wdmId + "-wdm-sele-prod"; 305 if ($( "#" + selectedProd ).prop( 'checked' ) == true) { 306 var priceId = wdmId + "-per-product-price"; 307 var totalPriceId = wdmId + "-total-price"; 308 $( "#" + totalPriceId ).html( ($( "#" + wdmId ).html() * $( "#" + priceId ).html()).toFixed( 2 ) ); 309 } 310 } 311 ); 312 313 // v1.1.1. 314 /** 315 * Handling change on input of Add Product Popup 316 */ 317 $( document ).on( 318 'keypress click input', 319 'input.add-more-product,.wdm_selected_products', 320 function (event) { 321 if (event.which == 45 || event.which == 46 || event.which == 189) { 322 event.preventDefault(); 323 } 324 var minVal = $( this ).attr( 'min' ); 325 var grand_total = 0; 326 var quantity = $( this ).val(); 327 if (quantity == "" || quantity < minVal) { 328 quantity = minVal; 329 } 330 var selectedProducts = jQuery( ".wdm_selected_products" ); 331 var productId = $( this ).attr( "id" ); 332 var perProductPrice = $( "#" + productId + "-per-product-price" ).html(); 333 var total = parseInt( perProductPrice ) * parseInt( quantity ); 334 $( "#" + productId + "-total-price" ).html( total ); 335 var totals = jQuery( '.wdm-product-total' ); 336 totals.each( 337 function (index, value) { 338 if (jQuery( selectedProducts[index] ).is( ':checked' )) { 339 grand_total += parseInt( $( this ).html() ); 340 } 341 } 342 ); 343 $( '#add-product-total-price' ).html( grand_total ); 344 } 345 ); 346 347 $( document ).on( 348 'keypress', 349 '#add-quantity-inp', 350 function (event) { 351 if (event.which == 45 || event.which == 189) { 352 event.preventDefault(); 353 } 354 355 } 356 ); 357 358 function closeDialog(dialogObj) {
359 $( dialogObj ).dialog( 'destroy' ); 360 } 361 362 /** 363 * create fields for new user. 364 */ 365 jQuery( '#wdm_user_data' ).delegate( 366 '#btn_add_new', 367 'click', 368 function () { 369 var numItems = jQuery( '#wdm_enroll_fname' ).length; 370 if (numItems < seat_limit) { 371 jQuery( '.wdm_button' ).before( 372 "<ul class='wdm_new_user'>\n\ 373 <li>\n\ 374 <i class='dashicons dashicons-dismiss wdm_remove_user'></i>\n\ 375 </li>\n\ 376 <li>\n\ 377 <label for='lbl_first_name'>" + ebbpPublic.enterFirstName + "</label>\n\ 378 <input type=text class='txt_fname' name='firstname[]' required>\n\ 379 </li>\n\ 380 <li>\n\ 381 <label class='lbl_last_name'>" + ebbpPublic.enterLastName + "</label>\n\ 382 <input type=text class='txt_lname' name='lastname[]' required>\n\ 383 </li>\n\ 384 <li>\n\ 385 <label class='lbl_email'>" + ebbpPublic.enterEmailName + "</label>\n\ 386 <input type='email' class='txt_email' name='email[]' ' required>\n\ 387 </li>\n\ 388 </ul>" 389 ); 390 jQuery( '#btn_enroll' ).removeAttr( 'disabled' ); 391 $( this ).toggleClass( "active" ); 392 } 393 if (numItems + 1 == seat_limit) { 394 jQuery( this ).attr( 'disabled', 'disabled' ); 395 } 396 } 397 ); 398 399 $( document ).on( 400 'click', 401 'input', 402 '.txt_fname, .txt_lname, .txt_email', 403 function (event) { 404 jQuery( this ).css( 'border', 'solid 1px #000' ); 405 } 406 ); 407 408 /** 409 * Remove extra user fields. 410 */ 411 jQuery( '#enroll-user-form-csv' ).delegate( 412 '.wdm_remove_user', 413 'click', 414 function () { 415 jQuery( this ).parent().parent().remove(); 416 417 if (jQuery( '.wdm_remove_user' ).length <= 0) { 418 jQuery( '#enroll-user-form-csv' ).dialog( 'close' ); 419 jQuery( '#btn_enroll' ).attr( 'disabled', 'disabled' ); 420 } 421 jQuery( "#btn_add_new" ).removeAttr( 'disabled' ); 422 423 } 424 ); 425 426 $( document ).on( 427 'click', 428 '.ebbp_course_progress', 429 function () { 430 // loader. 431 // $("body").css("cursor", "progress"); 432 $( '#eb-lading-parent' ).css( 'display', 'block' ); 433 434 var cohortId = $( this ).data( 'cohortid' ); 435 var userId = $( this ).data( 'userid' ); 436 437 var courseProgress = { 438 resizable: false, 439 title: ebbpPublic.courseprogres, 440 autoOpen: false, 441 modal: true, 442 width: 550, 443 dialogClass: "ebbp_custom_field_dialog wdm-enroll-stud-page-dialog", 444 buttons: [ 445 { 446 text: ebbpPublic.close, 447 class: "wdm-dialog-cancel-button", 448 click: function () { 449 $( this ).dialog( "close" ); 450 } 451 } 452 ], 453 }; 454 455 $.ajax( 456 { 457 type: 'POST', 458 url: ebbpPublic.ajax_url, 459 dataType: 'json', 460 data: { 461 action: 'get_cohort_course_progress', 462 cohort_id: cohortId, 463 user_id: userId, 464 nonce: ebbpPublic.nonce_gp_mng 465 }, 466 success: function (response) { 467 468 // $("body").css("cursor", "default"); 469 $( '#eb-lading-parent' ).css( 'display', 'none' ); 470 471 if (response.success == true) { 472 473 /*$("#add-quantity-popup").empty(); 474 $("#add-quantity-popup").html(response.data); 475 476 $("#add-quantity-table").DataTable({ 477 searching: false, 478 ordering: false, 479 lengthChange: false, 480 paging : false 481 }); 482 483 $('#add-quantity-popup').prop('title', ebbpPublic.addQuantity); 484 $('.eb-background-div').show(); 485 $("#add-quantity-popup").dialog(addQuantity).dialog("open");*/ 486 487 $( response.data ).dialog( courseProgress ).dialog( "open" ); 488 489 } 490 // else { 491 492 // errorMsgDialog(response.data); 493 494 // } 495 // jQuery("#eb-lading-parent").hide(); 496 }, 497 error: function (response) { 498 499 // $("body").css("cursor", "default"); 500 $( '#eb-lading-parent' ).css( 'display', 'none' ); 501 502 // errorMsgDialog(response); 503 // jQuery("#eb-lading-parent").hide(); 504 } 505 } 506 ); 507 508 } 509 ); 510 511 } 512 ); 513 514})( jQuery ); 515 516/* 517 * VARIABLE PRODUCT JS 518 */
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.