@@ -307,34 +307,44 @@ define([
307307 if ( options === undefined || options . updated_view != this ) {
308308 // Add missing items to the DOM.
309309 var items = this . model . get ( '_options_labels' ) ;
310+ var icons = this . model . get ( 'icons' ) ;
311+ var previous_icons = this . model . previous ( 'icons' ) || [ ] ;
310312 var disabled = this . model . get ( 'disabled' ) ;
311313 var that = this ;
312314 var item_html ;
313315 _ . each ( items , function ( item , index ) {
314- if ( item . trim ( ) . length === 0 ) {
316+ if ( item . trim ( ) . length === 0 && ( ! icons [ index ] ||
317+ icons [ index ] . trim ( ) . length === 0 ) ) {
315318 item_html = " " ;
316319 } else {
317320 item_html = utils . escape_html ( item ) ;
318321 }
319322 var item_query = '[data-value="' + encodeURIComponent ( item ) + '"]' ;
320323 var $item_element = that . $buttongroup . find ( item_query ) ;
324+ var $icon_element = $item_element . find ( '.fa' ) ;
321325 if ( ! $item_element . length ) {
322326 $item_element = $ ( '<button/>' )
323327 . attr ( 'type' , 'button' )
324328 . addClass ( 'btn btn-default' )
325329 . html ( item_html )
326330 . appendTo ( that . $buttongroup )
327331 . attr ( 'data-value' , encodeURIComponent ( item ) )
332+ . attr ( 'data-toggle' , 'tooltip' )
328333 . attr ( 'value' , item )
329334 . on ( 'click' , $ . proxy ( that . handle_click , that ) ) ;
330335 that . update_style_traits ( $item_element ) ;
336+ $icon_element = $ ( '<i class="fa"></i>' ) . prependTo ( $item_element ) ;
331337 }
332338 if ( that . model . get ( 'selected_label' ) == item ) {
333339 $item_element . addClass ( 'active' ) ;
334340 } else {
335341 $item_element . removeClass ( 'active' ) ;
336342 }
337- $item_element . prop ( 'disabled' , disabled ) ;
343+ $item_element . prop ( 'disabled' , disabled ) ;
344+ $item_element . attr ( 'title' , that . model . get ( 'tooltips' ) [ index ] ) ;
345+ $icon_element
346+ . removeClass ( previous_icons [ index ] )
347+ . addClass ( icons [ index ] ) ;
338348 } ) ;
339349
340350 // Remove items that no longer exist.
0 commit comments