1/** 2 * Holds frontend script necessary to support WC blocks 3 * 4 */ 5( function($) { 6 7 "use strict"; 8 9 // Add a predefined color to element 10 var elements = $( '.has-background, .has-text-color' ); 11 12 elements.each( function( i ) 13 { 14 var element = $(this); 15 if( ! ( element.hasClass( 'has-background' ) || element.hasClass( 'has-text-color' ) ) ) 16 { 17 return; 18 } 19 20 var classList = element.attr( 'class' ).split( /\s+/ ); 21 var color = ''; 22 var style = ''; 23 24 if( element.hasClass( 'has-background' ) ) 25 { 26 $.each( classList, function( index, item ) { 27 item = item.trim().toLowerCase(); 28 if( 0 == item.indexOf( 'has-col-' ) && -1 != item.indexOf( '-background-color' ) ) 29 { 30 color = item.replace( 'has-col-', '' ); 31 color = color.replace( '-background-color', '' ); 32 color = color.replace( /-|[^0-9a-fA-F]/g, '' ); 33 if( color.length == 3 || color.length == 6 ) 34 { 35 element.css( { 'background-color': '', 'border-color': '' } ); // force hex instead rgb 36 style = 'undefined' != typeof element.attr( 'style' ) ? element.attr( 'style' ) : ''; 37 element.attr( 'style', style + ' background-color: #' + color + '; border-color: #' + color + ';' ); 38 } 39 } 40 }); 41 } 42 43 if( element.hasClass( 'has-text-color' ) ) 44 { 45 $.each( classList, function( index, item ) { 46 item = item.trim().toLowerCase(); 47 if( 0 == item.indexOf( 'has-col-' ) && -1 == item.indexOf( '-background-color' ) && -1 != item.indexOf( '-color' ) ) 48 { 49 var color = item.replace( 'has-col-', '' ); 50 color = color.replace( '-color', '' ); 51 color = color.replace( /-|[^0-9a-fA-F]/g, '' ); 52 if( color.length == 3 || color.length == 6 ) 53 { 54 element.css( 'color', '' ); // force hex instead rgb 55 style = 'undefined' != typeof element.attr( 'style' ) ? element.attr( 'style' ) : ''; 56 element.attr('style', style + ' color: #' + color + ';'); 57 } 58 } 59 }); 60 } 61 62 }); 63 64 65})( jQuery ); 66
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.