Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

jsarnowski / jsarnowski/jet-engine   php

Repository URL to install this package:

Version: 2.7.7 

/ js / admin / blocks-views / src / common / styles.js

/**
 * Apply custom CSS inside editor
 */
( function( $ ) {

	"use strict";

	var JEBlocksCSS = {
		cssInput: null,

		init: function() {

			var self = this,
				css  = null;

			self.cssInput = $( '.jet_engine_listing_css' );

			if ( self.cssInput.length ) {
				$( document ).on( 'change', '.jet_engine_listing_css', self.updateStyles );

				css = self.cssInput.val();

				if ( css ) {
					css = self.parseCSS( css );
				}

				$( 'head' ).append( '<style id="jet_engine_listing_styles">' + css + '</style>' );
			}

		},
		updateStyles: function() {
			var css = $( this ).val();

			if ( css ) {
				css = JEBlocksCSS.parseCSS( css );
			}

			$( '#jet_engine_listing_styles' ).text( css );

		},
		parseCSS: function( css ) {
			return css.replace( /selector/g, '#editor' );
		}
	};

	JEBlocksCSS.init();

}( jQuery ) );