equal
deleted
inserted
replaced
96 // so matching terms can be combined. |
96 // so matching terms can be combined. |
97 term = term.replace( / /g, ')(?=.*' ); |
97 term = term.replace( / /g, ')(?=.*' ); |
98 match = new RegExp( '^(?=.*' + term + ').+', 'i' ); |
98 match = new RegExp( '^(?=.*' + term + ').+', 'i' ); |
99 |
99 |
100 this.each( function ( data ) { |
100 this.each( function ( data ) { |
101 haystack = [ data.get( 'name' ), data.get( 'id' ), data.get( 'description' ) ].join( ' ' ); |
101 haystack = [ data.get( 'name' ), data.get( 'description' ) ].join( ' ' ); |
102 data.set( 'search_matched', match.test( haystack ) ); |
102 data.set( 'search_matched', match.test( haystack ) ); |
103 } ); |
103 } ); |
104 } |
104 } |
105 }); |
105 }); |
106 api.Widgets.availableWidgets = new api.Widgets.WidgetCollection( api.Widgets.data.availableWidgets ); |
106 api.Widgets.availableWidgets = new api.Widgets.WidgetCollection( api.Widgets.data.availableWidgets ); |
193 } |
193 } |
194 } ); |
194 } ); |
195 |
195 |
196 // Clear the search results and trigger an `input` event to fire a new search. |
196 // Clear the search results and trigger an `input` event to fire a new search. |
197 this.$clearResults.on( 'click', function() { |
197 this.$clearResults.on( 'click', function() { |
198 self.$search.val( '' ).focus().trigger( 'input' ); |
198 self.$search.val( '' ).trigger( 'focus' ).trigger( 'input' ); |
199 } ); |
199 } ); |
200 |
200 |
201 // Close the panel if the URL in the preview changes. |
201 // Close the panel if the URL in the preview changes. |
202 api.previewer.bind( 'url', this.close ); |
202 api.previewer.bind( 'url', this.close ); |
203 }, |
203 }, |
363 |
363 |
364 // Reset search. |
364 // Reset search. |
365 this.collection.doSearch( '' ); |
365 this.collection.doSearch( '' ); |
366 |
366 |
367 if ( ! api.settings.browser.mobile ) { |
367 if ( ! api.settings.browser.mobile ) { |
368 this.$search.focus(); |
368 this.$search.trigger( 'focus' ); |
369 } |
369 } |
370 }, |
370 }, |
371 |
371 |
372 /** |
372 /** |
373 * Closes the panel. |
373 * Closes the panel. |
419 } |
419 } |
420 |
420 |
421 this.select( selected ); |
421 this.select( selected ); |
422 |
422 |
423 if ( selected ) { |
423 if ( selected ) { |
424 selected.focus(); |
424 selected.trigger( 'focus' ); |
425 } else { |
425 } else { |
426 this.$search.focus(); |
426 this.$search.trigger( 'focus' ); |
427 } |
427 } |
428 |
428 |
429 return; |
429 return; |
430 } |
430 } |
431 |
431 |
816 $( this ).prepend( self.container.find( '.widget-title' ).text() + ': ' ); |
816 $( this ).prepend( self.container.find( '.widget-title' ).text() + ': ' ); |
817 } ).on( 'click keypress', function( event ) { |
817 } ).on( 'click keypress', function( event ) { |
818 if ( event.type === 'keypress' && ( event.which !== 13 && event.which !== 32 ) ) { |
818 if ( event.type === 'keypress' && ( event.which !== 13 && event.which !== 32 ) ) { |
819 return; |
819 return; |
820 } |
820 } |
821 $( this ).focus(); |
821 $( this ).trigger( 'focus' ); |
822 |
822 |
823 if ( $( this ).is( '.move-widget' ) ) { |
823 if ( $( this ).is( '.move-widget' ) ) { |
824 self.toggleWidgetMoveArea(); |
824 self.toggleWidgetMoveArea(); |
825 } else { |
825 } else { |
826 var isMoveDown = $( this ).is( '.move-widget-down' ), |
826 var isMoveDown = $( this ).is( '.move-widget-down' ), |
837 } else { |
837 } else { |
838 self.moveDown(); |
838 self.moveDown(); |
839 wp.a11y.speak( l10n.widgetMovedDown ); |
839 wp.a11y.speak( l10n.widgetMovedDown ); |
840 } |
840 } |
841 |
841 |
842 $( this ).focus(); // Re-focus after the container was moved. |
842 $( this ).trigger( 'focus' ); // Re-focus after the container was moved. |
843 } |
843 } |
844 } ); |
844 } ); |
845 |
845 |
846 /** |
846 /** |
847 * Handle selecting a sidebar to move to |
847 * Handle selecting a sidebar to move to |
1101 _setInputState: function ( input, state ) { |
1101 _setInputState: function ( input, state ) { |
1102 input = $( input ); |
1102 input = $( input ); |
1103 if ( input.is( ':radio, :checkbox' ) ) { |
1103 if ( input.is( ':radio, :checkbox' ) ) { |
1104 input.prop( 'checked', state ); |
1104 input.prop( 'checked', state ); |
1105 } else if ( input.is( 'select[multiple]' ) ) { |
1105 } else if ( input.is( 'select[multiple]' ) ) { |
1106 if ( ! $.isArray( state ) ) { |
1106 if ( ! Array.isArray( state ) ) { |
1107 state = []; |
1107 state = []; |
1108 } else { |
1108 } else { |
1109 // Make sure all state items are strings since the DOM value is a string. |
1109 // Make sure all state items are strings since the DOM value is a string. |
1110 state = _.map( state, function ( value ) { |
1110 state = _.map( state, function ( value ) { |
1111 return String( value ); |
1111 return String( value ); |
2087 if ( widget.get( 'is_multi' ) && ! widgetNumber ) { |
2087 if ( widget.get( 'is_multi' ) && ! widgetNumber ) { |
2088 widget.set( 'multi_number', widget.get( 'multi_number' ) + 1 ); |
2088 widget.set( 'multi_number', widget.get( 'multi_number' ) + 1 ); |
2089 widgetNumber = widget.get( 'multi_number' ); |
2089 widgetNumber = widget.get( 'multi_number' ); |
2090 } |
2090 } |
2091 |
2091 |
2092 controlHtml = $.trim( $( '#widget-tpl-' + widget.get( 'id' ) ).html() ); |
2092 controlHtml = $( '#widget-tpl-' + widget.get( 'id' ) ).html().trim(); |
2093 if ( widget.get( 'is_multi' ) ) { |
2093 if ( widget.get( 'is_multi' ) ) { |
2094 controlHtml = controlHtml.replace( /<[^<>]+>/g, function( m ) { |
2094 controlHtml = controlHtml.replace( /<[^<>]+>/g, function( m ) { |
2095 return m.replace( /__i__|%i%/g, widgetNumber ); |
2095 return m.replace( /__i__|%i%/g, widgetNumber ); |
2096 } ); |
2096 } ); |
2097 } else { |
2097 } else { |