function parseClasses( aRules, skipSelectors, validSelectors ) {
		// aRules are just the different rules in the style sheets
		// We want to merge them and them split them by commas, so we end up with only
		// the selectors
		var s = aRules.join( ' ' );
		// Remove selectors splitting the elements, leave only the class selector (.)
		s = s.replace( /(,|>|\+|~)/g, ' ' );
		// Remove attribute selectors: table[border="0"]
		s = s.replace( /\[[^\]]*/g, '' );
		// Remove Ids: div#main
		s = s.replace( /#[^\s]*/g, '' );
		// Remove pseudo-selectors and pseudo-elements: :hover :nth-child(2n+1) ::before
		s = s.replace( /\:{1,2}[^\s]*/g, '' );

		s = s.replace( /\s+/g, ' ' );

		var aSelectors = s.split( ' ' ),
			aClasses = [];

		for ( var i = 0; i < aSelectors.length; i++ ) {
			var selector = aSelectors[ i ];

			if ( validSelectors.test( selector ) && !skipSelectors.test( selector ) ) {
				// If we still don't know about this one, add it
				if ( CKEDITOR.tools.indexOf( aClasses, selector ) == -1 )
					aClasses.push( selector );
			}
		}

		return aClasses;
	}
// We want to extract only the elements with classes defined in the stylesheets:
We want to extract only the elements with classes defined in the stylesheets.
We want to extract only the elements with classes defined in the stylesheets .
function parseClasses( aRules, skipSelectors, validSelectors ) {
		var s = aRules.join( ' ' );
		s = s.replace( /(,|>|\+|~)/g, ' ' );
		s = s.replace( /\[[^\]]*/g, '' );
		s = s.replace( /#[^\s]*/g, '' );
		s = s.replace( /\:{1,2}[^\s]*/g, '' );
		s = s.replace( /\s+/g, ' ' );
		var aSelectors = s.split( ' ' ),
			aClasses = [];
		for ( var i = 0; i < aSelectors.length; i++ ) {
			var selector = aSelectors[ i ];
			if ( validSelectors.test( selector ) && !skipSelectors.test( selector ) ) {
				if ( CKEDITOR.tools.indexOf( aClasses, selector ) == -1 )
					aClasses.push( selector );
			}
		}
		return aClasses;
	}
function parseClasses ( aRules , skipSelectors , validSelectors ) { var s = aRules . join ( ' ' ) ; s = s . replace ( / (,|>|\+|~) / g , ' ' ) ; s = s . replace ( / \[[^\]]* / g , '' ) ; s = s . replace ( / #[^\s]* / g , '' ) ; s = s . replace ( / \:{1,2}[^\s]* / g , '' ) ; s = s . replace ( / \s+ / g , ' ' ) ; var aSelectors = s . split ( ' ' ) , aClasses = [ ] ; for ( var i = 0 ; i < aSelectors . length ; i ++ ) { var selector = aSelectors [ i ] ; if ( validSelectors . test ( selector ) && ! skipSelectors . test ( selector ) ) { if ( CKEDITOR . tools . indexOf ( aClasses , selector ) == - 1 ) aClasses . push ( selector ) ; } } return aClasses ; }
We want to extract only the elements with classes defined in the stylesheets:
We want to extract only the elements with classes defined in the stylesheets :
// aRules are just the different rules in the style sheets // We want to merge them and them split them by commas, so we end up with only // the selectors // Remove selectors splitting the elements, leave only the class selector (.) // Remove attribute selectors: table[border="0"] // Remove Ids: div#main // Remove pseudo-selectors and pseudo-elements: :hover :nth-child(2n+1) ::before // If we still don't know about this one, add it