CLICK HERE TO BUY IT TODAY! OR GET IT FREE VIA TRIALPAY  

PHP Demo Application - Source Code

/Framework/Model/Vendor/CkEditor/_source/plugins/stylescombo/plugin.js



/*
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
(function()
{
	    CKEDITOR.plugins.add'stylescombo',
	    {
		        requires : [ 'richcombo''styles' ],
		        init : function( editor )
		        {
			            var config editor.config,
			                lang editor.lang.stylesCombo,
			                styles {},
			                stylesList [];
			            function loadStylesSetcallback )
			            {
				                editor.getStylesSet( function( stylesDefinitions )
				                {
					                    if ( !stylesList.length )
					                    {
						                        var style,
						                            styleName;
						                        // Put all styles into an Array.
						                        for ( var ;
						 stylesDefinitions.length ;
						 i++ )
						                        {
							                            var styleDefinition stylesDefinitions];
							                            styleName styleDefinition.name;
							                            style stylesstyleName ] = new CKEDITOR.stylestyleDefinition );
							                            style._name styleName;
							                            style._.enterMode config.enterMode;
							                            stylesList.pushstyle );
							                        }
						                        // Sorts the Array, so the styles get grouped by type.
						                        stylesList.sortsortStyles );
						                    }
					                    callback && callback();
					                });
				            }
			            editor.ui.addRichCombo'Styles',
			                {
				                    label lang.label,
				                    title lang.panelTitle,
				                    className 'cke_styles',
				                    panel :
				                    {
					                        css editor.skin.editor.css.concatconfig.contentsCss ),
					                        multiSelect true,
					                        attributes : { 'aria-label' lang.panelTitle
						}
					                    },
				                    init : function()
				                    {
					                        var combo this;
					                        loadStylesSet( function()
					                            {
						                                var stylestyleName;
						                                // Loop over the Array, adding all items to the
						                                // combo.
						                                var lastType;
						                                for ( var ;
						 stylesList.length ;
						 i++ )
						                                {
							                                    style stylesList];
							                                    styleName style._name;
							                                    var type style.type;
							                                    if ( type != lastType )
							                                    {
								                                        combo.startGrouplang'panelTitle' Stringtype ) ] );
								                                        lastType type;
								                                    }
							                                    combo.add(
							                                        styleName,
							                                        style.type == CKEDITOR.STYLE_OBJECT styleName style.buildPreview(),
							                                        styleName );
							                                }
						                                combo.commit();
						                                combo.onOpen();
						                            });
					                    },
				                    onClick : function( value )
				                    {
					                        editor.focus();
					                        editor.fire'saveSnapshot' );
					                        var style stylesvalue ],
					                            selection editor.getSelection();
					                        var elementPath = new CKEDITOR.dom.elementPathselection.getStartElement() );
					                        if ( style.type == CKEDITOR.STYLE_INLINE && style.checkActiveelementPath ) )
					                            style.removeeditor.document );
					                        else if ( style.type == CKEDITOR.STYLE_OBJECT && style.checkActiveelementPath ) )
					                            style.removeeditor.document );
					                        else
					                            style.applyeditor.document );
					                        editor.fire'saveSnapshot' );
					                    },
				                    onRender : function()
				                    {
					                        editor.on'selectionChange', function( ev )
					                            {
						                                var currentValue this.getValue();
						                                var elementPath ev.data.path,
						                                    elements elementPath.elements;
						                                // For each element into the elements path.
						                                for ( var 0element ;
						 elements.length ;
						 i++ )
						                                {
							                                    element elements[i];
							                                    // Check if the element is removable by any of
							                                    // the styles.
							                                    for ( var value in styles )
							                                    {
								                                        if ( stylesvalue ].checkElementRemovableelementtrue ) )
								                                        {
									                                            if ( value != currentValue )
									                                                this.setValuevalue );
									                                            return;
									                                        }
								                                    }
							                                }
						                                // If no styles match, just empty it.
						                                this.setValue'' );
						                            },
					                            this);
					                    },
				                    onOpen : function()
				                    {
					                        if ( CKEDITOR.env.ie || CKEDITOR.env.webkit )
					                            editor.focus();
					                        var selection editor.getSelection();
					                        var element selection.getSelectedElement(),
					                            elementPath = new CKEDITOR.dom.elementPathelement || selection.getStartElement() );
					                        var counter = [ 000];
					                        this.showAll();
					                        this.unmarkAll();
					                        for ( var name in styles )
					                        {
						                            var style stylesname ],
						                                type style.type;
						                            if ( style.checkActiveelementPath ) )
						                                this.markname );
						                            else if ( type == CKEDITOR.STYLE_OBJECT && !style.checkApplicableelementPath ) )
						                            {
							                                this.hideItemname );
							                                countertype ]--;
							                            }
						                            countertype ]++;
						                        }
					                        if ( !counterCKEDITOR.STYLE_BLOCK ] )
					                            this.hideGrouplang'panelTitle' StringCKEDITOR.STYLE_BLOCK ) ] );
					                        if ( !counterCKEDITOR.STYLE_INLINE ] )
					                            this.hideGrouplang'panelTitle' StringCKEDITOR.STYLE_INLINE ) ] );
					                        if ( !counterCKEDITOR.STYLE_OBJECT ] )
					                            this.hideGrouplang'panelTitle' StringCKEDITOR.STYLE_OBJECT ) ] );
					                    }
				                });
			            editor.on'instanceReady', function() {
				loadStylesSet();
				} );
			        }
		    });
	    function sortStylesstyleAstyleB )
	    {
		        var typeA styleA.type,
		            typeB styleB.type;
		        return typeA == typeB :
		            typeA == CKEDITOR.STYLE_OBJECT ? -:
		            typeB == CKEDITOR.STYLE_OBJECT :
		            typeB == CKEDITOR.STYLE_BLOCK :
		            -1;
		    }
	})();





PHP Demo Source Code Index