Changeset 28044
- Timestamp:
- 04/08/2014 08:11:33 AM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/customize-widgets.js
r28034 r28044 37 37 params: [], 38 38 width: null, 39 height: null 39 height: null, 40 search_matched: true 40 41 }); 41 42 … … 72 73 // Useful for resetting the views when you clean the input 73 74 if ( this.terms === '' ) { 74 this.reset( api.Widgets.data.availableWidgets ); 75 } 76 77 // Trigger an 'update' event 78 this.trigger( 'update' ); 75 this.each( function ( widget ) { 76 widget.set( 'search_matched', true ); 77 } ); 78 } 79 79 }, 80 80 … … 82 82 // @uses RegExp 83 83 search: function( term ) { 84 var match, results, haystack; 85 86 // Start with a full collection 87 this.reset( api.Widgets.data.availableWidgets, { silent: true } ); 84 var match, haystack; 88 85 89 86 // Escape the term string for RegExp meta characters … … 95 92 match = new RegExp( '^(?=.*' + term + ').+', 'i' ); 96 93 97 results = this.filter( function( data ) { 98 haystack = _.union( data.get( 'name' ), data.get( 'id' ), data.get( 'description' ) ); 99 100 return match.test( haystack ); 101 }); 102 103 this.reset( results ); 94 this.each( function ( data ) { 95 haystack = [ data.get( 'name' ), data.get( 'id' ), data.get( 'description' ) ].join( ' ' ); 96 data.set( 'search_matched', match.test( haystack ) ); 97 } ); 104 98 } 105 99 }); … … 177 171 _.bindAll( this, 'close' ); 178 172 179 this.listenTo( this.collection, 'update', this.updateList );180 173 this.listenTo( this.collection, 'change', this.updateList ); 181 174 … … 223 216 }, 224 217 225 // Changes visibil ty of available widgets218 // Changes visibility of available widgets 226 219 updateList: function() { 227 // First hide all widgets...228 this.$el.find( '.widget-tpl' ).hide();229 230 // ..and then show only available widgets which could be filtered231 220 this.collection.each( function( widget ) { 232 221 var widgetTpl = $( '#widget-tpl-' + widget.id ); 233 widgetTpl.toggle( ! widget.get( 'is_disabled' ) );222 widgetTpl.toggle( widget.get( 'search_matched' ) && ! widget.get( 'is_disabled' ) ); 234 223 if ( widget.get( 'is_disabled' ) && widgetTpl.is( this.selected ) ) { 235 224 this.selected = null; … … 238 227 }, 239 228 240 // High tlights a widget229 // Highlights a widget 241 230 select: function( widgetTpl ) { 242 231 this.selected = $( widgetTpl ); … … 245 234 }, 246 235 247 // High tlights a widget on focus236 // Highlights a widget on focus 248 237 focus: function( event ) { 249 238 this.select( $( event.currentTarget ) ); … … 1602 1591 /** 1603 1592 * @param {string} widgetId or an id_base for adding a previously non-existing widget 1604 * @returns {object } widget_form control instance1593 * @returns {object|false} widget_form control instance, or false on error 1605 1594 */ 1606 1595 addWidget: function( widgetId ) { … … 1613 1602 1614 1603 if ( ! widget ) { 1615 return ;1604 return false; 1616 1605 } 1617 1606 1618 1607 if ( widgetNumber && ! widget.get( 'is_multi' ) ) { 1619 return ;1608 return false; 1620 1609 } 1621 1610 -
trunk/src/wp-includes/class-wp-customize-widgets.php
r27985 r28044 1151 1151 if ( ! empty( $_POST['sanitized_widget_setting'] ) ) { 1152 1152 $sanitized_widget_setting = json_decode( $this->get_post_value( 'sanitized_widget_setting' ), true ); 1153 if ( empty( $sanitized_widget_setting )) {1153 if ( false === $sanitized_widget_setting ) { 1154 1154 $this->stop_capturing_option_updates(); 1155 1155 return new WP_Error( 'widget_setting_malformed' );
Note: See TracChangeset
for help on using the changeset viewer.