1(function($) { 2$(document).ready(function() { 3 4 var colSets = $( '.colSet' ); 5 colSets.each( function( index, element ) { 6 var colSet = $(this); 7 var columns = colSet.children( '.sColumn' ); 8 var colNum = columns.length; 9 var freeCols = 12; 10 11 columns.each(function( index, element ) { 12 13 // column does not have specified width 14 if( ! $(this).is( '[class*=col-lg-]' ) ) { 15 return; 16 } 17 18 var columnClasses = $(this).attr( 'class' ).split(' '); 19 var numCols = 0; 20 21 // Get # of initial grid columns assigned for the column 22 for( var key in columnClasses ) { 23 var currClass = columnClasses[key]; 24 if( currClass.indexOf( 'col-lg-' ) >= 0 ) { 25 numCols = currClass.substr(currClass.length - 2); 26 if( numCols.substr(0, 1) == '-' ) { 27 numCols = numCols.substr( numCols.length - 1 ); 28 } 29 } 30 } 31 32 // Adjust the remaining freeCols accordingly 33 freeCols -= numCols; 34 35 // Check if user provided widths with total that exceeds 100%. 36 // If so, just divide all columns evenly. 37 // If number is not exactly divisible => add remainder to the last column. 38 if( freeCols < 0 ) { 39 freeCols = 12; 40 colNum = columns.length; 41 columns.each(function( index, element ) { 42 $(this).attr( 'class', function (i, c) { 43 return c.replace( /col-lg-(\d+)/, 'col-lg-' + freeCols/colNum ); 44 }); 45 freeCols -= freeCols/colNum; 46 colNum--; 47 }); 48 colNum = 0; 49 return; 50 } 51 52 // Account for all columns having the class col-lg-.. 53 colNum--; 54 }); 55 56 // Apply free width to the rest of the columns 57 if( colNum != 0 ) { 58 var numCols = Math.floor(freeCols / colNum); 59 columns.each(function(index, element) { 60 if( ! $(this).is( '[class*=col-lg-]' ) ) { 61 $(this).addClass( 'col-lg-' + numCols ); 62 freeCols -= numCols; 63 } 64 }); 65 } 66 67 // If all columns have set width, but freeWidth is remaining, add it to the last column 68 if( freeCols != 0 ) { 69 var $lastCol = columns.last(); 70 71 var lastColClasses = $lastCol.attr( 'class' ).split(' '); 72 for( var key in lastColClasses ) { 73 var currClass = lastColClasses[key]; 74 if( currClass.indexOf( 'col-lg-' ) >= 0 ) { 75 numCols = Number( currClass.substr(currClass.length - 1) ); 76 numCols += freeCols; 77 $lastCol.removeClass(currClass); 78 } 79 } 80 $lastCol.addClass( 'col-lg-' + numCols ); 81 } 82 83 }); 84 85}); 86})(jQuery);
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.