diff options
| author | lsces <lester@lsces.co.uk> | 2012-06-10 19:03:48 +0100 |
|---|---|---|
| committer | lsces <lester@lsces.co.uk> | 2012-06-10 19:03:48 +0100 |
| commit | f3ce03a71d3dd1c7dcbe474197fb1588949735db (patch) | |
| tree | 7c31cd62ef0e2790966f96498e553f22fa4e08d3 /_source/plugins/stylescombo | |
| parent | 23b8cf2a890c7de389616702fd23c9c465311a59 (diff) | |
| download | ckeditor-f3ce03a71d3dd1c7dcbe474197fb1588949735db.tar.gz ckeditor-f3ce03a71d3dd1c7dcbe474197fb1588949735db.tar.bz2 ckeditor-f3ce03a71d3dd1c7dcbe474197fb1588949735db.zip | |
Update to CKEditor version 3.6.3
Diffstat (limited to '_source/plugins/stylescombo')
| -rw-r--r-- | _source/plugins/stylescombo/plugin.js | 423 | ||||
| -rw-r--r-- | _source/plugins/stylescombo/styles/default.js | 85 |
2 files changed, 218 insertions, 290 deletions
diff --git a/_source/plugins/stylescombo/plugin.js b/_source/plugins/stylescombo/plugin.js index b4d9f49..f690602 100644 --- a/_source/plugins/stylescombo/plugin.js +++ b/_source/plugins/stylescombo/plugin.js @@ -1,205 +1,218 @@ -/* -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 loadStylesSet( callback ) - { - editor.getStylesSet( function( stylesDefinitions ) - { - if ( !stylesList.length ) - { - var style, - styleName; - - // Put all styles into an Array. - for ( var i = 0 ; i < stylesDefinitions.length ; i++ ) - { - var styleDefinition = stylesDefinitions[ i ]; - - styleName = styleDefinition.name; - - style = styles[ styleName ] = new CKEDITOR.style( styleDefinition ); - style._name = styleName; - style._.enterMode = config.enterMode; - - stylesList.push( style ); - } - - // Sorts the Array, so the styles get grouped by type. - stylesList.sort( sortStyles ); - } - - callback && callback(); - }); - } - - editor.ui.addRichCombo( 'Styles', - { - label : lang.label, - title : lang.panelTitle, - className : 'cke_styles', - - panel : - { - css : editor.skin.editor.css.concat( config.contentsCss ), - multiSelect : true, - attributes : { 'aria-label' : lang.panelTitle } - }, - - init : function() - { - var combo = this; - - loadStylesSet( function() - { - var style, styleName; - - // Loop over the Array, adding all items to the - // combo. - var lastType; - for ( var i = 0 ; i < stylesList.length ; i++ ) - { - style = stylesList[ i ]; - styleName = style._name; - - var type = style.type; - - if ( type != lastType ) - { - combo.startGroup( lang[ 'panelTitle' + String( type ) ] ); - 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 = styles[ value ], - selection = editor.getSelection(); - - var elementPath = new CKEDITOR.dom.elementPath( selection.getStartElement() ); - - if ( style.type == CKEDITOR.STYLE_INLINE && style.checkActive( elementPath ) ) - style.remove( editor.document ); - else - style.apply( editor.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 i = 0, element ; i < elements.length ; i++ ) - { - element = elements[i]; - - // Check if the element is removable by any of - // the styles. - for ( var value in styles ) - { - if ( styles[ value ].checkElementRemovable( element, true ) ) - { - if ( value != currentValue ) - this.setValue( value ); - 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.elementPath( element || selection.getStartElement() ); - - var counter = [ 0, 0, 0, 0 ]; - this.showAll(); - this.unmarkAll(); - for ( var name in styles ) - { - var style = styles[ name ], - type = style.type; - - if ( style.checkActive( elementPath ) ) - this.mark( name ); - else if ( type == CKEDITOR.STYLE_OBJECT && !style.checkApplicable( elementPath ) ) - { - this.hideItem( name ); - counter[ type ]--; - } - - counter[ type ]++; - } - - if ( !counter[ CKEDITOR.STYLE_BLOCK ] ) - this.hideGroup( lang[ 'panelTitle' + String( CKEDITOR.STYLE_BLOCK ) ] ); - - if ( !counter[ CKEDITOR.STYLE_INLINE ] ) - this.hideGroup( lang[ 'panelTitle' + String( CKEDITOR.STYLE_INLINE ) ] ); - - if ( !counter[ CKEDITOR.STYLE_OBJECT ] ) - this.hideGroup( lang[ 'panelTitle' + String( CKEDITOR.STYLE_OBJECT ) ] ); - } - }); - - editor.on( 'instanceReady', function() { loadStylesSet(); } ); - } - }); - - function sortStyles( styleA, styleB ) - { - var typeA = styleA.type, - typeB = styleB.type; - - return typeA == typeB ? 0 : - typeA == CKEDITOR.STYLE_OBJECT ? -1 : - typeB == CKEDITOR.STYLE_OBJECT ? 1 : - typeB == CKEDITOR.STYLE_BLOCK ? 1 : - -1; - } -})(); +/*
+Copyright (c) 2003-2012, 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 = [],
+ combo;
+
+ function loadStylesSet( callback )
+ {
+ editor.getStylesSet( function( stylesDefinitions )
+ {
+ if ( !stylesList.length )
+ {
+ var style,
+ styleName;
+
+ // Put all styles into an Array.
+ for ( var i = 0, count = stylesDefinitions.length ; i < count ; i++ )
+ {
+ var styleDefinition = stylesDefinitions[ i ];
+
+ styleName = styleDefinition.name;
+
+ style = styles[ styleName ] = new CKEDITOR.style( styleDefinition );
+ style._name = styleName;
+ style._.enterMode = config.enterMode;
+
+ stylesList.push( style );
+ }
+
+ // Sorts the Array, so the styles get grouped by type.
+ stylesList.sort( sortStyles );
+ }
+
+ callback && callback();
+ });
+ }
+
+ editor.ui.addRichCombo( 'Styles',
+ {
+ label : lang.label,
+ title : lang.panelTitle,
+ className : 'cke_styles',
+
+ panel :
+ {
+ css : editor.skin.editor.css.concat( config.contentsCss ),
+ multiSelect : true,
+ attributes : { 'aria-label' : lang.panelTitle }
+ },
+
+ init : function()
+ {
+ combo = this;
+
+ loadStylesSet( function()
+ {
+ var style,
+ styleName,
+ lastType,
+ type,
+ i,
+ count;
+
+ // Loop over the Array, adding all items to the
+ // combo.
+ for ( i = 0, count = stylesList.length ; i < count ; i++ )
+ {
+ style = stylesList[ i ];
+ styleName = style._name;
+ type = style.type;
+
+ if ( type != lastType )
+ {
+ combo.startGroup( lang[ 'panelTitle' + String( type ) ] );
+ lastType = type;
+ }
+
+ combo.add(
+ styleName,
+ style.type == CKEDITOR.STYLE_OBJECT ? styleName : style.buildPreview(),
+ styleName );
+ }
+
+ combo.commit();
+
+ });
+ },
+
+ onClick : function( value )
+ {
+ editor.focus();
+ editor.fire( 'saveSnapshot' );
+
+ var style = styles[ value ],
+ selection = editor.getSelection(),
+ elementPath = new CKEDITOR.dom.elementPath( selection.getStartElement() );
+
+ style[ style.checkActive( elementPath ) ? 'remove' : 'apply' ]( editor.document );
+
+ editor.fire( 'saveSnapshot' );
+ },
+
+ onRender : function()
+ {
+ editor.on( 'selectionChange', function( ev )
+ {
+ var currentValue = this.getValue(),
+ elementPath = ev.data.path,
+ elements = elementPath.elements;
+
+ // For each element into the elements path.
+ for ( var i = 0, count = elements.length, element ; i < count ; i++ )
+ {
+ element = elements[i];
+
+ // Check if the element is removable by any of
+ // the styles.
+ for ( var value in styles )
+ {
+ if ( styles[ value ].checkElementRemovable( element, true ) )
+ {
+ if ( value != currentValue )
+ this.setValue( value );
+ 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(),
+ element = selection.getSelectedElement(),
+ elementPath = new CKEDITOR.dom.elementPath( element || selection.getStartElement() ),
+ counter = [ 0, 0, 0, 0 ];
+
+ this.showAll();
+ this.unmarkAll();
+ for ( var name in styles )
+ {
+ var style = styles[ name ],
+ type = style.type;
+
+ if ( style.checkActive( elementPath ) )
+ this.mark( name );
+ else if ( type == CKEDITOR.STYLE_OBJECT && !style.checkApplicable( elementPath ) )
+ {
+ this.hideItem( name );
+ counter[ type ]--;
+ }
+
+ counter[ type ]++;
+ }
+
+ if ( !counter[ CKEDITOR.STYLE_BLOCK ] )
+ this.hideGroup( lang[ 'panelTitle' + String( CKEDITOR.STYLE_BLOCK ) ] );
+
+ if ( !counter[ CKEDITOR.STYLE_INLINE ] )
+ this.hideGroup( lang[ 'panelTitle' + String( CKEDITOR.STYLE_INLINE ) ] );
+
+ if ( !counter[ CKEDITOR.STYLE_OBJECT ] )
+ this.hideGroup( lang[ 'panelTitle' + String( CKEDITOR.STYLE_OBJECT ) ] );
+ },
+
+ // Force a reload of the data
+ reset: function()
+ {
+ if ( combo )
+ {
+ delete combo._.panel;
+ delete combo._.list;
+ combo._.committed = 0;
+ combo._.items = {};
+ combo._.state = CKEDITOR.TRISTATE_OFF;
+ }
+ styles = {};
+ stylesList = [];
+ loadStylesSet();
+ }
+ });
+
+ editor.on( 'instanceReady', function() { loadStylesSet(); } );
+ }
+ });
+
+ function sortStyles( styleA, styleB )
+ {
+ var typeA = styleA.type,
+ typeB = styleB.type;
+
+ return typeA == typeB ? 0 :
+ typeA == CKEDITOR.STYLE_OBJECT ? -1 :
+ typeB == CKEDITOR.STYLE_OBJECT ? 1 :
+ typeB == CKEDITOR.STYLE_BLOCK ? 1 :
+ -1;
+ }
+})();
diff --git a/_source/plugins/stylescombo/styles/default.js b/_source/plugins/stylescombo/styles/default.js deleted file mode 100644 index fe92de3..0000000 --- a/_source/plugins/stylescombo/styles/default.js +++ /dev/null @@ -1,85 +0,0 @@ -/*
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
-For licensing, see LICENSE.html or http://ckeditor.com/license
-*/
-
-CKEDITOR.stylesSet.add( 'default',
-[
- /* Block Styles */
-
- // These styles are already available in the "Format" combo, so they are
- // not needed here by default. You may enable them to avoid placing the
- // "Format" combo in the toolbar, maintaining the same features.
- /*
- { name : 'Paragraph' , element : 'p' },
- { name : 'Heading 1' , element : 'h1' },
- { name : 'Heading 2' , element : 'h2' },
- { name : 'Heading 3' , element : 'h3' },
- { name : 'Heading 4' , element : 'h4' },
- { name : 'Heading 5' , element : 'h5' },
- { name : 'Heading 6' , element : 'h6' },
- { name : 'Preformatted Text', element : 'pre' },
- { name : 'Address' , element : 'address' },
- */
-
- { name : 'Blue Title' , element : 'h3', styles : { 'color' : 'Blue' } },
- { name : 'Red Title' , element : 'h3', styles : { 'color' : 'Red' } },
-
- /* Inline Styles */
-
- // These are core styles available as toolbar buttons. You may opt enabling
- // some of them in the Styles combo, removing them from the toolbar.
- /*
- { name : 'Strong' , element : 'strong', overrides : 'b' },
- { name : 'Emphasis' , element : 'em' , overrides : 'i' },
- { name : 'Underline' , element : 'u' },
- { name : 'Strikethrough' , element : 'strike' },
- { name : 'Subscript' , element : 'sub' },
- { name : 'Superscript' , element : 'sup' },
- */
-
- { name : 'Marker: Yellow' , element : 'span', styles : { 'background-color' : 'Yellow' } },
- { name : 'Marker: Green' , element : 'span', styles : { 'background-color' : 'Lime' } },
-
- { name : 'Big' , element : 'big' },
- { name : 'Small' , element : 'small' },
- { name : 'Typewriter' , element : 'tt' },
-
- { name : 'Computer Code' , element : 'code' },
- { name : 'Keyboard Phrase' , element : 'kbd' },
- { name : 'Sample Text' , element : 'samp' },
- { name : 'Variable' , element : 'var' },
-
- { name : 'Deleted Text' , element : 'del' },
- { name : 'Inserted Text' , element : 'ins' },
-
- { name : 'Cited Work' , element : 'cite' },
- { name : 'Inline Quotation' , element : 'q' },
-
- { name : 'Language: RTL' , element : 'span', attributes : { 'dir' : 'rtl' } },
- { name : 'Language: LTR' , element : 'span', attributes : { 'dir' : 'ltr' } },
-
- /* Object Styles */
-
- {
- name : 'Image on Left',
- element : 'img',
- attributes :
- {
- 'style' : 'padding: 5px; margin-right: 5px',
- 'border' : '2',
- 'align' : 'left'
- }
- },
-
- {
- name : 'Image on Right',
- element : 'img',
- attributes :
- {
- 'style' : 'padding: 5px; margin-left: 5px',
- 'border' : '2',
- 'align' : 'right'
- }
- }
-]);
|
