PageRenderTime 39ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/themes/Divi/includes/builder/scripts/frontend-builder-global-functions.js

https://gitlab.com/gregtyka/lfmawordpress
JavaScript | 127 lines | 103 code | 20 blank | 4 comment | 24 complexity | accf5da72ea7a24e571abe415e8f5d70 MD5 | raw file
  1. (function($){
  2. window.et_pb_smooth_scroll = function( $target, $top_section, speed, easing ) {
  3. var $window_width = $( window ).width();
  4. if ( $( 'body' ).hasClass( 'et_fixed_nav' ) && $window_width > 980 ) {
  5. $menu_offset = $( '#top-header' ).outerHeight() + $( '#main-header' ).outerHeight() - 1;
  6. } else {
  7. $menu_offset = -1;
  8. }
  9. if ( $ ('#wpadminbar').length && $window_width > 600 ) {
  10. $menu_offset += $( '#wpadminbar' ).outerHeight();
  11. }
  12. //fix sidenav scroll to top
  13. if ( $top_section ) {
  14. $scroll_position = 0;
  15. } else {
  16. $scroll_position = $target.offset().top - $menu_offset;
  17. }
  18. // set swing (animate's scrollTop default) as default value
  19. if( typeof easing === 'undefined' ){
  20. easing = 'swing';
  21. }
  22. $( 'html, body' ).animate( { scrollTop : $scroll_position }, speed, easing );
  23. }
  24. window.et_fix_video_wmode = function( video_wrapper ) {
  25. $( video_wrapper ).each( function() {
  26. if ( $(this).find( 'iframe' ).length ) {
  27. var $this_el = $(this).find( 'iframe' ),
  28. src_attr = $this_el.attr('src'),
  29. wmode_character = src_attr.indexOf( '?' ) == -1 ? '?' : '&',
  30. this_src = src_attr + wmode_character + 'wmode=opaque';
  31. $this_el.attr('src', this_src);
  32. }
  33. } );
  34. }
  35. window.et_pb_form_placeholders_init = function( $form ) {
  36. $form.find('input:text, textarea').each(function(index,domEle){
  37. var $et_current_input = jQuery(domEle),
  38. $et_comment_label = $et_current_input.siblings('label'),
  39. et_comment_label_value = $et_current_input.siblings('label').text();
  40. if ( $et_comment_label.length ) {
  41. $et_comment_label.hide();
  42. if ( $et_current_input.siblings('span.required') ) {
  43. et_comment_label_value += $et_current_input.siblings('span.required').text();
  44. $et_current_input.siblings('span.required').hide();
  45. }
  46. $et_current_input.val(et_comment_label_value);
  47. }
  48. }).bind('focus',function(){
  49. var et_label_text = jQuery(this).siblings('label').text();
  50. if ( jQuery(this).siblings('span.required').length ) et_label_text += jQuery(this).siblings('span.required').text();
  51. if (jQuery(this).val() === et_label_text) jQuery(this).val("");
  52. }).bind('blur',function(){
  53. var et_label_text = jQuery(this).siblings('label').text();
  54. if ( jQuery(this).siblings('span.required').length ) et_label_text += jQuery(this).siblings('span.required').text();
  55. if (jQuery(this).val() === "") jQuery(this).val( et_label_text );
  56. });
  57. }
  58. window.et_duplicate_menu = function( menu, append_to, menu_id, menu_class, menu_click_event ){
  59. append_to.each( function() {
  60. var $this_menu = $(this),
  61. $cloned_nav;
  62. // make this function work with existing menus, without cloning
  63. if ( '' !== menu ) {
  64. menu.clone().attr('id',menu_id).removeClass().attr('class',menu_class).appendTo( $this_menu );
  65. }
  66. $cloned_nav = $this_menu.find('> ul');
  67. $cloned_nav.find('.menu_slide').remove();
  68. $cloned_nav.find('li:first').addClass('et_first_mobile_item');
  69. $cloned_nav.find( 'a' ).on( 'click', function(){
  70. $this_menu.trigger( 'click' );
  71. } );
  72. if ( 'no_click_event' !== menu_click_event ) {
  73. $this_menu.on( 'click', '.mobile_menu_bar', function(){
  74. if ( $this_menu.hasClass('closed') ){
  75. $this_menu.removeClass( 'closed' ).addClass( 'opened' );
  76. $cloned_nav.stop().slideDown( 500 );
  77. } else {
  78. $this_menu.removeClass( 'opened' ).addClass( 'closed' );
  79. $cloned_nav.stop().slideUp( 500 );
  80. }
  81. return false;
  82. } );
  83. }
  84. } );
  85. $('#mobile_menu .centered-inline-logo-wrap').remove();
  86. }
  87. // remove placeholder text before form submission
  88. window.et_pb_remove_placeholder_text = function( $form ) {
  89. $form.find('input:text, textarea').each(function(index,domEle){
  90. var $et_current_input = jQuery(domEle),
  91. $et_label = $et_current_input.siblings('label'),
  92. et_label_value = $et_current_input.siblings('label').text();
  93. if ( $et_label.length && $et_label.is(':hidden') ) {
  94. if ( $et_label.text() == $et_current_input.val() )
  95. $et_current_input.val( '' );
  96. }
  97. });
  98. }
  99. window.et_fix_fullscreen_section = function() {
  100. var $et_window = $(window);
  101. $( 'section.et_pb_fullscreen' ).each( function(){
  102. var $this_section = $( this );
  103. $.proxy( et_calc_fullscreen_section, $this_section )();
  104. $et_window.on( 'resize', $.proxy( et_calc_fullscreen_section, $this_section ) );
  105. });
  106. }
  107. })(jQuery)