1/* 2 Plugin Name: Ultimate Member 3 Description: Frontend scripts 4 Version: 2.1.16 5 Author: Ultimate Member 6 Author URI: http://ultimatemember.com/ 7 */ 8 9if ( typeof (window.UM) !== 'object' ) { 10 window.UM = {}; 11} 12 13UM.dropdown = { 14 /** 15 * Hide the menu 16 * @param {object} menu 17 * @returns {undefined} 18 */ 19 hide: function (menu) { 20 21 var $menu = jQuery(menu); 22 $menu.parents('div').find('a').removeClass('active'); 23 $menu.hide(); 24 25 }, 26 /** 27 * Hide all menus 28 * @returns {undefined} 29 */ 30 hideAll: function () { 31 32 var $menu = jQuery('.um-dropdown'); 33 $menu.parents('div').find('a').removeClass('active'); 34 $menu.hide(); 35 36 }, 37 /** 38 * Update the menu position 39 * @param {object} menu 40 * @returns {undefined} 41 */ 42 setPosition: function (menu) { 43 44 var $menu = jQuery(menu), 45 menu_width = 200; 46 47 var direction = jQuery('html').attr('dir'), 48 element = $menu.attr('data-element'), 49 position = $menu.attr('data-position'), 50 trigger = $menu.attr('data-trigger'); 51 52 var $element = element && jQuery(element).length ? jQuery(element) : ($menu.siblings('a').length ? $menu.siblings('a').first() : $menu.parent()); 53 $element.addClass('um-trigger-menu-on-' + trigger); 54 55 var gap_right = 0, 56 left_p = ($element.outerWidth() - menu_width) / 2, 57 top_p = $element.outerHeight(), 58 coord = $element.offset(); 59 60 // profile photo 61 if ( $element.is('.um-profile-photo') ) { 62 var $imgBox = $element.find('.um-profile-photo-img'); 63 if ( $element.closest('div.uimob340,div.uimob500').length ) { 64 top_p = $element.outerHeight() - $imgBox.outerHeight() / 4; 65 } else { 66 left_p = ($imgBox.outerWidth() - menu_width) / 2; 67 top_p = $imgBox.outerHeight() / 4; 68 } 69 } 70 71 // cover photo 72 if ( $element.is('.um-cover') ) { 73 var $imgBox = $element.find('.um-cover-e'); 74 if ( $element.closest('div.uimob340,div.uimob500').length ) { 75 left_p = ($imgBox.outerWidth() - menu_width) / 2; 76 top_p = $imgBox.outerHeight() / 2 + 24; 77 } else { 78 left_p = ($imgBox.outerWidth() - menu_width) / 2; 79 top_p = $imgBox.outerHeight() / 2 + 46; 80 } 81 } 82 83 // position 84 if ( position === 'lc' && direction === 'rtl' ) { 85 position = 'rc'; 86 } 87 if( $element.outerWidth() < menu_width ){ 88 if ( direction === 'rtl' && coord.left < menu_width*0.5 ){ 89 position = 'rc'; 90 }
90 else if ( direction !== 'rtl' && (window.innerWidth - coord.left - $element.outerWidth()) < menu_width*0.5 ){ 91 position = 'lc'; 92 } 93 } 94 95 switch ( position ) { 96 case 'lc': 97 98 gap_right = $element.width() + 17; 99 $menu.css({ 100 'top': 0, 101 'width': menu_width, 102 'left': 'auto', 103 'right': gap_right + 'px', 104 'text-align': 'center' 105 }); 106 107 $menu.find('.um-dropdown-arr').css({ 108 'top': '4px', 109 'left': 'auto', 110 'right': '-17px' 111 }).find('i').removeClass().addClass('um-icon-arrow-right-b'); 112 break; 113 114 case 'rc': 115 116 gap_right = $element.width() + 25; 117 $menu.css({ 118 'top': 0, 119 'width': menu_width, 120 'left': gap_right + 'px', 121 'right': 'auto', 122 'text-align': 'center' 123 }); 124 125 $menu.find('.um-dropdown-arr').css({ 126 'top': '4px', 127 'left': '-17px', 128 'right': 'auto' 129 }).find('i').removeClass().addClass('um-icon-arrow-left-b'); 130 break; 131 132 case 'bc': 133 default: 134 135 var top_offset = $menu.data('top-offset'); 136 if ( typeof top_offset !== 'undefined' ) { 137 top_p += top_offset; 138 } 139 140 $menu.css({ 141 'top': top_p + 6, 142 'width': menu_width, 143 'left': left_p, 144 'right': 'auto', 145 'text-align': 'center' 146 }); 147 148 $menu.find('.um-dropdown-arr').css({ 149 'top': '-17px', 150 'left': ($menu.width() / 2) - 12, 151 'right': 'auto' 152 }).find('i').removeClass().addClass('um-icon-arrow-up-b'); 153 break; 154 } 155 }, 156 /** 157 * Show the menu 158 * @param {object} menu 159 * @returns {undefined} 160 */ 161 show: function (menu) { 162 163 var $menu = jQuery(menu); 164 UM.dropdown.hideAll(); 165 UM.dropdown.setPosition($menu); 166 $menu.show(); 167 168 } 169}; 170 171/** 172 * Update menu position 173 */ 174function UM_domenus() { 175 jQuery('.um-dropdown').each( function( i, menu ) { 176 UM.dropdown.setPosition( menu ); 177 }); 178} 179 180 181function UM_check_password_matched() { 182 jQuery(document).on('keyup', 'input[data-key=user_password],input[data-key=confirm_user_password]', function(e) { 183 var value = jQuery('input[data-key=user_password]').val(); 184 var match = jQuery('input[data-key=confirm_user_password]').val(); 185 var field = jQuery('input[data-key=user_password],input[data-key=confirm_user_password]'); 186 187 if(!value && !match) { 188 field.removeClass('um-validate-matched').removeClass('um-validate-not-matched'); 189 } else if(value !== match) { 190 field.removeClass('um-validate-matched').addClass('um-validate-not-matched'); 191 } else { 192 field.removeClass('um-validate-not-matched').addClass('um-validate-matched'); 193 } 194 }); 195} 196 197 198function um_responsive(){ 199 200 jQuery('.um').each(function(){ 201 202 element_width = jQuery(this).width(); 203 204 if ( element_width <= 340 ) { 205 206 jQuery(this).removeClass('uimob340'); 207 jQuery(this).removeClass('uimob500'); 208 jQuery(this).removeClass('uimob800'); 209 jQuery(this).removeClass('uimob960'); 210 211 jQuery(this).addClass('uimob340'); 212 213 } else if ( element_width <= 500 ) { 214 215 jQuery(this).removeClass('uimob340'); 216 jQuery(this).removeClass('uimob500'); 217 jQuery(this).removeClass('uimob800'); 218 jQuery(this).removeClass('uimob960'); 219 220 jQuery(this).addClass('uimob500'); 221 222 } else if ( element_width <= 800 ) { 223 224 jQuery(this).removeClass('uimob340'); 225 jQuery(this).removeClass('uimob500'); 226 jQuery(this).removeClass('uimob800'); 227 jQuery(this).removeClass('uimob960'); 228 229 jQuery(this).addClass('uimob800'); 230 231 } else if ( element_width <= 960 ) { 232 233 jQuery(this).removeClass('uimob340'); 234 jQuery(this).removeClass('uimob500'); 235 jQuery(this).removeClass('uimob800'); 236 jQuery(this).removeClass('uimob960'); 237 238 jQuery(this).addClass('uimob960'); 239 240 } else if ( element_width > 960 ) { 241 242 jQuery(this).removeClass('uimob340'); 243 jQuery(this).removeClass('uimob500'); 244 jQuery(this).removeClass('uimob800'); 245 jQuery(this).removeClass('uimob960'); 246 247 } 248 249 if ( jQuery('.um-account-nav').length > 0 && jQuery('.um-account-side').is(':visible') && jQuery('.um-account-tab:visible').length == 0 ) { 250 jQuery('.um-account-side li a.current').trigger('click'); 251 } 252 253 // set iframe height and width. 254 const $iframes = jQuery(this).find('.um-field-value iframe[height][width]'); 255 $iframes.each(function (i, item) { 256 let itemAttrHeight = parseInt(item.getAttribute('height')); 257 let itemAttrWidth = parseInt(item.getAttribute('width')); 258 let parentWidth = item.parentElement.clientWidth; 259 let scale = parentWidth / itemAttrWidth; 260 261 item.height = parseInt(itemAttrHeight * scale); 262 item.width = parseInt(itemAttrWidth * scale); 263 }); 264 265 jQuery(this).css('opacity',1); 266 }); 267 268 jQuery('.um-cover, .um-member-cover, .um-cover-e').each(function(){ 269 270 var elem = jQuery(this); 271 var ratio = elem.data('ratio'); 272 var width = elem.width(); 273 var ratios = ratio.split(':'); 274 275 calcHeight = Math.round( width / ratios[0] ) + 'px'; 276 elem.height( calcHeight );
277 elem.find('.um-cover-add').height( calcHeight ); 278 279 }); 280 281 UM_domenus(); 282} 283 284 285function initImageUpload_UM( trigger ) { 286 if ( ! trigger.length ) { 287 return; 288 } 289 290 if (trigger.data('upload_help_text')){ 291 upload_help_text = '<span class="help">' + trigger.data('upload_help_text') + '</span>'; 292 } else { 293 upload_help_text = ''; 294 } 295 296 if ( trigger.data('icon') ) { 297 icon = '<span class="icon"><i class="'+ trigger.data('icon') + '"></i></span>'; 298 } else { 299 icon = ''; 300 } 301 302 if ( trigger.data('upload_text') ) { 303 upload_text = '<span class="str">' + trigger.data('upload_text') + '</span>'; 304 } else { 305 upload_text = ''; 306 } 307 308 var user_id = 0; 309 310 if( jQuery('#um_upload_single:visible').data('user_id') ){ 311 user_id = jQuery('#um_upload_single:visible').data('user_id'); 312 } 313 314 trigger.uploadFile({ 315 url: wp.ajax.settings.url, 316 method: "POST", 317 multiple: false, 318 formData: { 319 action: 'um_imageupload', 320 key: trigger.data('key'), 321 set_id: trigger.data('set_id'), 322 set_mode: trigger.data('set_mode'), 323 _wpnonce: trigger.data('nonce'), 324 timestamp: trigger.data('timestamp'), 325 user_id: user_id 326 }, 327 fileName: trigger.data('key'), 328 uploadButtonClass: 'upload', 329 allowedTypes: trigger.data('allowed_types'), 330 acceptFiles: trigger.data('accept'), 331 maxFileSize: trigger.data('max_size'), 332 dragDropStr: icon + upload_text + upload_help_text, 333 sizeErrorStr: trigger.data('max_size_error'), 334 extErrorStr: trigger.data('extension_error'), 335 maxFileCountErrorStr: trigger.data('max_files_error'), 336 maxFileCount: 1, 337 showDelete: false, 338 showAbort: false, 339 showDone: false, 340 showFileCounter: false, 341 showStatusAfterSuccess: true, 342 returnType: 'json', 343 onSubmit:function(files){ 344 345 trigger.parents('.um-modal-body').find('.um-error-block').remove(); 346 347 }, 348 onSuccess:function( files, response, xhr ){ 349 350 trigger.selectedFiles = 0; 351 352 if ( response.success && response.success == false || typeof response.data.error !== 'undefined' ) { 353 354 trigger.parents('.um-modal-body').append('<div class="um-error-block">'+response.data.error+'</div>'); 355 trigger.parents('.um-modal-body').find('.upload-statusbar').hide(0); 356 um_modal_responsive(); 357 358 } else { 359 360 jQuery.each( response.data, function( i, d ) { 361 362 var img_id = trigger.parents('.um-modal-body').find('.um-single-image-preview img'); 363 var img_id_h = trigger.parents('.um-modal-body').find('.um-single-image-preview'); 364 365 var cache_ts = new Date(); 366 367 img_id.removeAttr("loading"); 368 img_id.attr("src", d.url + "?"+cache_ts.getTime() ); 369 img_id.data("file", d.file ); 370 371 img_id.on( 'load', function() { 372 373 trigger.parents('.um-modal-body').find('.um-modal-btn.um-finish-upload.disabled').removeClass('disabled'); 374 trigger.parents('.um-modal-body').find('.ajax-upload-dragdrop,.upload-statusbar').hide(0); 375 img_id_h.show(0); 376 um_modal_responsive(); 377 378 }); 379 380 }); 381 382 } 383 384 }, 385 onError: function ( e ){ 386 console.log( e ); 387 } 388 }); 389 390} 391 392function initFileUpload_UM( trigger ) { 393 if ( ! trigger.length ) { 394 return; 395 } 396 397 if (trigger.data('upload_help_text')){ 398 upload_help_text = '<span class="help">' + trigger.data('upload_help_text') + '</span>'; 399 } else { 400 upload_help_text = ''; 401 } 402 403 if ( trigger.data('icon') ) { 404 icon = '<span class="icon"><i class="'+ trigger.data('icon') + '"></i></span>'; 405 } else { 406 icon = ''; 407 } 408 409 if ( trigger.data('upload_text') ) { 410 upload_text = '<span class="str">' + trigger.data('upload_text') + '</span>'; 411 } else { 412 upload_text = ''; 413 } 414 415 if( jQuery('#um_upload_single:visible').data('user_id') ){ 416 user_id = jQuery('#um_upload_single:visible').data('user_id'); 417 } 418 419 trigger.uploadFile({ 420 url: wp.ajax.settings.url, 421 method: "POST", 422 multiple: false, 423 formData: { 424 action: 'um_fileupload', 425 key: trigger.data('key'), 426 set_id: trigger.data('set_id'), 427 user_id: trigger.data('user_id'), 428 set_mode: trigger.data('set_mode'), 429 _wpnonce: trigger.data('nonce'), 430 timestamp: trigger.data('timestamp') 431 }, 432 fileName: trigger.data('key'), 433 uploadButtonClass: 'upload', 434 allowedTypes: trigger.data('allowed_types'), 435 acceptFiles: trigger.data('accept'), 436 maxFileSize: trigger.data('max_size'),
437 dragDropStr: icon + upload_text + upload_help_text, 438 sizeErrorStr: trigger.data('max_size_error'), 439 extErrorStr: trigger.data('extension_error'), 440 maxFileCountErrorStr: trigger.data('max_files_error'), 441 maxFileCount: 1, 442 showDelete: false, 443 showAbort: false, 444 showDone: false, 445 showFileCounter: false, 446 showStatusAfterSuccess: true, 447 onSubmit:function(files){ 448 449 trigger.parents('.um-modal-body').find('.um-error-block').remove(); 450 451 }, 452 onSuccess:function( files, response ,xhr ){ 453 454 trigger.selectedFiles = 0; 455 456 if ( response.success && response.success == false || typeof response.data.error !== 'undefined' ) { 457 458 trigger.parents('.um-modal-body').append('<div class="um-error-block">'+ response.data.error+'</div>'); 459 trigger.parents('.um-modal-body').find('.upload-statusbar').hide(0); 460 461 setTimeout(function(){ 462 um_modal_responsive(); 463 },1000); 464 465 } else { 466 467 jQuery.each( response.data , function(key, value) { 468 469 trigger.parents('.um-modal-body').find('.um-modal-btn.um-finish-upload.disabled').removeClass('disabled'); 470 trigger.parents('.um-modal-body').find('.ajax-upload-dragdrop,.upload-statusbar').hide(0); 471 trigger.parents('.um-modal-body').find('.um-single-file-preview').show(0); 472 473 if ( key == 'icon' ) { 474 475 trigger.parents('.um-modal-body').find('.um-single-fileinfo i').removeClass().addClass( value ); 476 477 } else if ( key == 'icon_bg' ) { 478 479 trigger.parents('.um-modal-body').find('.um-single-fileinfo span.icon').css({'background-color' : value } ); 480 481 } else if ( key == 'filename' ) { 482 483 trigger.parents('.um-modal-body').find('.um-single-fileinfo a').attr('data-file', value ); 484 485 }else if( key == 'original_name' ){ 486 487 trigger.parents('.um-modal-body').find('.um-single-fileinfo a').attr('data-orignal-name', value ); 488 trigger.parents('.um-modal-body').find('.um-single-fileinfo span.filename').html( value ); 489 490 } else if ( key == 'url' ) { 491 492 trigger.parents('.um-modal-body').find('.um-single-fileinfo a').attr('href', value); 493 494 } 495 496 }); 497 498 setTimeout(function(){ 499 um_modal_responsive(); 500 },1000); 501 502 } 503 504 }, 505 onError: function ( e ){ 506 console.log( e ); 507 } 508 }); 509 510} 511 512function um_new_modal( id, size, isPhoto, source ) { 513 var modalOverlay = jQuery('.um-modal-overlay'); 514 if ( modalOverlay.length !== 0 ) { 515 modalOverlay.hide(); 516 modalOverlay.next('.um-modal').hide(); 517 } 518 519 UM.common.tipsy.hide(); 520 521 UM.dropdown.hideAll(); 522 523 jQuery( 'body,html,textarea' ).css( 'overflow', 'hidden' ); 524 525 jQuery( document ).bind( "touchmove", function(e){e.preventDefault();}); 526 jQuery( '.um-modal' ).on('touchmove', function(e){e.stopPropagation();}); 527 528 var $tpl = jQuery( '<div class="um-modal-overlay"></div><div class="um-modal"></div>' ); 529 var $modal = $tpl.filter('.um-modal'); 530 $modal.append( jQuery( '#' + id ) ); 531 532 jQuery('body').append( $tpl ); 533 534 if ( isPhoto ) { 535 var photo_ = jQuery('<img src="' + source + '" />'), 536 photo_maxw = jQuery(window).width() - 60, 537 photo_maxh = jQuery(window).height() - jQuery(window).height() * 0.25; 538 539 photo_.on( 'load', function() { 540 $modal.find('.um-modal-photo').html( photo_ ); 541 542 $modal.addClass('is-photo').css({ 543 'width': photo_.width(), 544 'margin-left': '-' + photo_.width() / 2 + 'px' 545 }).show().children().show(); 546 547 photo_.css({ 548 'opacity': 0, 549 'max-width': photo_maxw, 550 'max-height': photo_maxh 551 }).animate({'opacity' : 1}, 1000); 552 553 um_modal_responsive(); 554 }); 555 } else { 556 557 $modal.addClass('no-photo').show().children().show(); 558 559 um_modal_size( size ); 560 561 initImageUpload_UM( jQuery('.um-modal:visible .um-single-image-upload') ); 562 initFileUpload_UM( jQuery('.um-modal:visible .um-single-file-upload') ); 563 564 um_modal_responsive(); 565 566 } 567 568} 569 570function um_modal_responsive() { 571 var w = window.innerWidth 572 || document.documentElement.clientWidth 573 || document.body.clientWidth; 574 575 var h = window.innerHeight 576 || document.documentElement.clientHeight 577 || document.body.clientHeight; 578 579 var modal = jQuery('.um-modal:visible').not('.um-modal-hidden'); 580 var photo_modal = modal.find('.um-modal-body.photo:visible'); 581 582 if ( ! photo_modal.length && ! modal.length ) { 583 return; 584 } 585
586 let half_gap = ( h - modal.innerHeight() ) / 2 + 'px'; 587 588 modal.removeClass('uimob340').removeClass('uimob500'); 589 590 if ( photo_modal.length ) { 591 var photo_ = jQuery('.um-modal-photo img'); 592 var photo_maxw = w - 60; 593 var photo_maxh = h - ( h * 0.25 ); 594 595 photo_.css({'opacity': 0}); 596 photo_.css({'max-width': photo_maxw }); 597 photo_.css({'max-height': photo_maxh }); 598 599 modal.css({ 600 'width': photo_.width(), 601 'margin-left': '-' + photo_.width() / 2 + 'px' 602 }); 603 604 photo_.animate({'opacity' : 1}, 1000); 605 606 modal.animate({ 'bottom' : half_gap }, 300); 607 608 } else if ( modal.length ) { 609 if ( w <= 340 ) { 610 modal.addClass('uimob340'); 611 } else if ( w <= 500 ) { 612 modal.addClass('uimob500'); 613 } 614 UM.frontend.cropper.init(); 615 if ( w <= 500 ) { 616 modal.animate({ 'bottom' : 0 }, 300); 617 } else { 618 if ( h - parseInt(half_gap) > h ) { 619 modal.animate({ 'bottom' : 0 }, 300); 620 } else { 621 modal.animate({ 'bottom' : half_gap }, 300); 622 } 623 } 624 } 625} 626 627function um_remove_modal() { 628 wp.hooks.doAction( 'um_remove_modal' ); 629 630 jQuery('body,html,textarea').css("overflow", "auto"); 631 632 jQuery(document).unbind('touchmove'); 633 634 jQuery('body > .um-modal div[id^="um_"]').hide().appendTo('body'); 635 jQuery('body > .um-modal, body > .um-modal-overlay').remove(); 636 637} 638 639function um_modal_size( aclass ) { 640 jQuery('.um-modal:visible').not('.um-modal-hidden').addClass( aclass ); 641} 642 643function prepare_Modal() { 644 if ( jQuery('.um-popup-overlay').length == 0 ) { 645 jQuery('body').append('<div class="um-popup-overlay"></div>'); 646 jQuery('body').append('<div class="um-popup"></div>'); 647 jQuery('.um-popup').addClass('loading'); 648 jQuery("body,html").css({ overflow: 'hidden' }); 649 } 650} 651 652function remove_Modal() { 653 if ( jQuery('.um-popup-overlay').length ) { 654 wp.hooks.doAction( 'um_before_modal_removed', jQuery('.um-popup') ); 655 656 UM.common.tipsy.hide(); 657 jQuery('.um-popup').empty().remove(); 658 jQuery('.um-popup-overlay').empty().remove(); 659 jQuery("body,html").css({ overflow: 'auto' }); 660 } 661} 662 663function show_Modal( contents ) { 664 if ( jQuery('.um-popup-overlay').length ) { 665 jQuery('.um-popup').removeClass('loading').html( contents ); 666 UM.common.tipsy.init(); 667 } 668} 669 670function responsive_Modal() { 671 if ( jQuery('.um-popup-overlay').length ) { 672 673 ag_height = jQuery(window).height() - jQuery('.um-popup .um-popup-header').outerHeight() - jQuery('.um-popup .um-popup-footer').outerHeight() - 80; 674 if ( ag_height > 350 ) { 675 ag_height = 350; 676 } 677 678 if ( jQuery('.um-popup-autogrow:visible').length ) { 679 680 jQuery('.um-popup-autogrow:visible').css({'height': ag_height + 'px'}); 681 682 } else if ( jQuery('.um-popup-autogrow2:visible').length ) { 683 684 jQuery('.um-popup-autogrow2:visible').css({'max-height': ag_height + 'px'}); 685 686 } 687 } 688} 689 690function um_reset_field( dOm ){ 691 //console.log(dOm); 692 jQuery(dOm) 693 .find('div.um-field-area') 694 .find('input,textarea,select') 695 .not(':button, :submit, :reset, :hidden') 696 .val('') 697 .prop('checked', false) 698 .prop('selected', false); 699} 700 701jQuery(function(){ 702 703 // Submit search form on keypress 'Enter' 704 jQuery(".um-search form *").on( 'keypress', function(e){ 705 if (e.which == 13) { 706 jQuery('.um-search form').trigger('submit'); 707 return false; 708 } 709 }); 710 711 if( jQuery('input[data-key=user_password],input[data-key=confirm_user_password]').length == 2 ) { 712 UM_check_password_matched(); 713 } 714 715});
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.