1(function($, _) { 2 if ( ! wp || ! wp.hooks ) return; 3 var scrollStartPost; 4 wp.hooks.addAction( 'PC.fe.start', 'MKL/PC/Themes/float', function( view ) { 5 // Move the form to the toolbar 6 view.footer.form.$el.insertAfter( view.toolbar.$selection ); 7 8 // view.footer.form_2 = new PC.fe.views.form( { el: clone } ); 9 view.$el.addClass( 'float' ); 10 11 if ( PC_config.config.disable_sticky_footer ) view.$el.addClass( 'no-sticky-footer' ); 12 13 // view.$('.layer-item').first().trigger('click'); 14 view.toolbar.$el.find('section.choices').on('scroll', function(e) { 15 var section = $( this ); 16 section.toggleClass( 'scrolled', ! ( e.target.scrollHeight - section.outerHeight() == section.scrollTop() ) ); 17 } ); 18 setTimeout( 19 function() { 20 view.toolbar.$el.find('section.choices').trigger( 'scroll' ); 21 }, 22 500 23 ); 24 }, 20 ); 25 26 wp.hooks.addFilter( 'PC.fe.steps_position', 'MKL/PC/Themes/float', function( position, $nav ) { 27 PC.fe.modal.toolbar.$( '.pc_configurator_form' ).before( $nav ); 28 return PC.fe.modal.toolbar.$el; 29 } ); 30 31 wp.hooks.addFilter( 'PC.fe.choices.where', 'MKL/PC/Themes/float', function( where, view ) { 32 if ( 'full-screen' === view.model.get( 'display_mode' ) ) { 33 if ( PC.fe.inline ) return 'body'; 34 return 'out'; 35 } 36 return 'in'; 37 } ); 38 39 wp.hooks.addFilter( 'PC.fe.validation.summary_placement', 'MKL/PC/Themes/float', function( placement, ctx ) { 40 var $choices = ( ctx.$selection && ctx.$selection.length ) ? ctx.$selection : ctx.$toolbar.find( 'section.choices' ).first(); 41 if ( $choices.length ) { 42 return { method: 'prepend', $target: $choices }; 43 } 44 return placement; 45 } ); 46 47 function maybe_focus( view ) { 48 if ( !view.choices ) return; 49 // Steps 50 if ( view.model.get( 'is_step' ) ) { 51 view.choices.$( '.layers-list-item > button.layer-item:visible' ).first().trigger( 'focus' ); 52 return; 53 } 54 view.choices.$( 'button.choice-item:visible' ).first().trigger( 'focus' ); 55 } 56 57 wp.hooks.addAction( 'PC.fe.layer.activate', 'MKL/PC/Themes/float', function( view ) { 58 if ( ! wp.hooks.applyFilters( 'pc.themes.float.toggle_choices', true, view ) ) return; 59 if ( PC.fe.inline ) { 60 view.$el.find( '.layer_choices' ).first().show(); 61 maybe_focus( view ); 62 if ( PC_config.config.auto_scroll ) view.el.offsetParent.scrollTo( 0, view.el.offsetTop ); 63 // if ( scrollStartPost ) $(document).scrollTop(scrollStartPost); 64 } else { 65 if ( 'dropdown' === view.model.get( 'display_mode' ) ) { 66 view.$el.find( '.layer_choices' ).first().delay( 40 ).slideDown( 100, () => { 67 maybe_focus( view ); 68 } ); 69 } else { 70 view.$el.find( '.layer_choices' ).first().delay( 40 ).slideDown( { 71 duration: 100, 72 step: function () { 73 if ( PC_config.config.auto_scroll && view.el.offsetParent ) view.el.offsetParent.scrollTo( 0, view.el.offsetTop ); 74 }, 75 complete: () => { 76 maybe_focus( view ); 77 } 78 } ); 79 } 80 } 81 82 } ); 83 wp.hooks.addAction( 'PC.fe.layer.deactivate', 'MKL/PC/Themes/float', function( view ) { 84 if ( ! wp.hooks.applyFilters( 'pc.themes.float.toggle_choices', true, view ) ) return; 85 if ( PC.fe.inline ) { 86 scrollStartPost = $(document).scrollTop(); 87 view.$el.find( '.layer_choices' ).first().hide(); 88 } else { 89 view.$el.find( '.layer_choices' ).first().slideUp(100); 90 } 91 if ( 'full-screen' == view.model.get( 'display_mode' ) ) { 92 view.$( '> button.layer-item' ).focus(); 93 } 94 } ); 95 96 // Conditional logic: do not show / hide choices list visibility 97 wp.hooks.addFilter( 'mkl_pc_conditionals.toggle_choices', 'MKL/PC/Themes/float', function( where ) { 98 return false; 99 } ); 100 101 // Scroll to newly opened layer, when onening it using conditional logic 102 wp.hooks.addAction( 'conditional.selected_layer', 'MKL/PC/Themes/float', function( model ) { 103 var scrollToView = null; 104 _.each( PC.fe.modal.toolbar.layers.items, function( view ) { 105 if ( view.model.id == model.id ) { 106 scrollToView = view; 107 } 108 } ); 109 110 if ( scrollToView ) { 111 setTimeout( function() { 112 scrollToView.el.offsetParent.scrollTo( 0, scrollToView.el.offsetTop ); 113 }, 150 ); 114 } 115 } ); 116 117 /** 118 * Display step: scroll back to the top 119 */ 120 wp.hooks.addAction( 'PC.fe.steps.display_step', 'MKL/PC/Themes/float', function( steps ) { 121 var scrollable = PC.fe.modal.$( 'section.choices' ); 122 if ( scrollable.length ) scrollable[0].scrollTo( 0, 0 ); 123 } ); 124 125 126})( jQuery, PC._us || window._ );
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.