var op = window.op || ( window.op = {} ); op.themeColors = { 'primary-color': '#6ba1d6', 'complementary-color': '#9ac2b3', 'dark-color': '#003259', 'light-color': '#f2f2f2', 'white-color': '#ffffff' }; op.gbGradients = {}; /* * Merge the global block gradient objects into the op objects list of needed gradients * so we have a master list to compare against. Any gradients not in the master list, pass * along to be added to the page via css. */ op.gbGradientMerge = function( gradients, id ) { var temp = {}; Object.keys( gradients ).forEach( function( gradientKey ) { if( !op.gbGradients[ gradientKey ] ) { op.gbGradients[ gradientKey ] = gradients[ gradientKey ]; } } ); if( op.makeGradientCSS && Object.keys( op.gbGradients ).length ) { op.addGbGradientCss( op.gbGradients ); } }; /* * Add a style tag that contains the gradients defined in gbGradients to the DOM * @param gbGradients {object} * @param id {string} block uuid */ op.addGbGradientCss = function( gbGradients ) { var styles = op.makeGradientCSS( gbGradients, op.themeColors ); var head = document.head; var styleTag = document.createElement('style'); styleTag.innerHTML = styles; head.appendChild( styleTag ); } ;