Ticket #5909: 5909_4.patch

File 5909_4.patch, 8.0 KB (added by Tobiasz Cudnik, 14 years ago)
  • _source/skins/office2003/icons.css

     
    322322{
    323323        background-position: 0 -1200px;
    324324}
     325
     326.cke_skin_office2003 .cke_button_bidirtl .cke_icon
     327{
     328        background-position: 0 -1072px;
     329}
     330
     331.cke_skin_office2003 .cke_button_bidiltr .cke_icon
     332{
     333        background-position: 0 -1056px;
     334}
     335 No newline at end of file
  • _source/lang/en.js

     
    744744        },
    745745
    746746        toolbarCollapse : 'Collapse Toolbar',
    747         toolbarExpand   : 'Expand Toolbar'
     747        toolbarExpand   : 'Expand Toolbar',
     748
     749        bidi :
     750        {
     751                ltr :"Text direction from left to right",
     752                rtl : "Text direction from right to left"
     753        }
    748754};
  • _source/skins/v2/icons.css

     
    322322{
    323323        background-position: 0 -1200px;
    324324}
     325
     326.cke_skin_v2 .cke_button_bidirtl .cke_icon
     327{
     328        background-position: 0 -1072px;
     329}
     330
     331.cke_skin_v2 .cke_button_bidiltr .cke_icon
     332{
     333        background-position: 0 -1056px;
     334}
     335 No newline at end of file
  • _source/skins/kama/icons.css

     
    320320{
    321321        background-position: 0 -1040px;
    322322}
    323 .cke_skin_office2003 .cke_button_editdiv .cke_icon
     323
     324.cke_skin_kama .cke_button_editdiv .cke_icon
    324325{
    325326        background-position: 0 -1184px;
    326327}
     328
     329.cke_skin_kama .cke_button_bidirtl .cke_icon
     330{
     331        background-position: 0 -1072px;
     332}
     333
     334.cke_skin_kama .cke_button_bidiltr .cke_icon
     335{
     336        background-position: 0 -1056px;
     337}
  • _source/plugins/bidi/plugin.js

     
     1/*
     2Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5(function(){
     6
     7        var guardElements = { table:1, ul:1, ol:1, blockquote:1, div:1 };
     8        var directSelectionGuardElements = {};
     9        CKEDITOR.tools.extend( directSelectionGuardElements, guardElements, { tr:1 } );
     10
     11        function onSelectionChange( evt )
     12        {
     13                evt.editor.getCommand( 'bidirtl' ).setState( getState( evt.editor, evt.data.path, 'rtl' ) );
     14                evt.editor.getCommand( 'bidiltr' ).setState( getState( evt.editor, evt.data.path, 'ltr' ) );
     15        }
     16       
     17        function getState( editor, path, dir )
     18        {
     19                var selection = editor.getSelection(),
     20                        ranges = selection.getRanges();
     21
     22                var selectedElement = ranges && ranges[ 0 ].getEnclosedNode();
     23
     24                // If this is not our element of interest, apply to fully selected elements from guardElements.
     25                if ( !selectedElement || selectedElement
     26                                && !( selectedElement.type == CKEDITOR.NODE_ELEMENT && selectedElement.getName() in directSelectionGuardElements )
     27                        )
     28                        selectedElement = getFullySelected( selection, guardElements );
     29               
     30                selectedElement = selectedElement || path.block || path.blockLimit;
     31
     32                if ( !selectedElement || selectedElement.getName() == 'body' )
     33                        return CKEDITOR.TRISTATE_OFF;
     34
     35                return ( selectedElement.getAttribute( 'dir' ) == dir ) ?
     36                        CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF;
     37        }
     38
     39        /**
     40         *
     41         * @param {CKEDITOR.dom.selection} selection
     42         * @param {Object<name,int>} elements
     43         *
     44         * @return {?CKEDITOR.dom.element} Fully selected element.
     45         */
     46        function getFullySelected( selection, elements )
     47        {
     48                var selectedElement = selection.getCommonAncestor();
     49                while( selectedElement.type == CKEDITOR.NODE_ELEMENT
     50                                && !( selectedElement.getName() in elements )
     51                                && selectedElement.getParent().getChildCount() == 1
     52                        )
     53                        selectedElement = selectedElement.getParent();
     54
     55                return selectedElement.type == CKEDITOR.NODE_ELEMENT
     56                        && ( selectedElement.getName() in elements )
     57                        && selectedElement;
     58        }
     59
     60        function bidiCommand( dir )
     61        {
     62                return function( editor )
     63                {
     64                        var selection = editor.getSelection(),
     65                                enterMode = editor.config.enterMode,
     66                                ranges = selection.getRanges();
     67
     68                        if ( ranges )
     69                        {
     70                                // Apply do directly selected elements from guardElements.
     71                                var selectedElement = ranges[ 0 ].getEnclosedNode();
     72
     73                                // If this is not our element of interest, apply to fully selected elements from guardElements.
     74                                if ( !selectedElement || selectedElement
     75                                                && !( selectedElement.type == CKEDITOR.NODE_ELEMENT && selectedElement.getName() in directSelectionGuardElements )
     76                                        )
     77                                        selectedElement = getFullySelected( selection, guardElements );
     78                               
     79                                if ( selectedElement )
     80                                {
     81                                        if ( selectedElement.hasAttribute( 'dir' ) && selectedElement.getAttribute( 'dir' ).toLowerCase()  == dir )
     82                                                selectedElement.removeAttribute( 'dir' );
     83                                        else
     84                                                selectedElement.setAttribute( 'dir', dir );
     85                                       
     86                                        editor.forceNextSelectionCheck();
     87                                }
     88                                else
     89                                {
     90                                        // Creates bookmarks for selection, as we may split some blocks.
     91                                        var bookmarks = selection.createBookmarks();
     92
     93                                        var iterator,
     94                                                block;
     95
     96                                        for ( var i = ranges.length - 1 ; i >= 0 ; i-- )
     97                                        {
     98                                                iterator = ranges[ i ].createIterator();
     99                                                iterator.enlargeBr = enterMode != CKEDITOR.ENTER_BR;
     100
     101                                                while ( ( block = iterator.getNextParagraph( enterMode == CKEDITOR.ENTER_P ? 'p' : 'div' ) ) )
     102                                                {
     103                                                        if ( block.hasAttribute( 'dir' ) && block.getAttribute( 'dir' ).toLowerCase()  == dir )
     104                                                                block.removeAttribute( 'dir' );
     105                                                        else
     106                                                                block.setAttribute( 'dir', dir );
     107                                                }
     108                                        }
     109                                       
     110                                        editor.forceNextSelectionCheck();
     111                                        // Restore selection position.
     112                                        selection.selectBookmarks( bookmarks );
     113                                }
     114
     115                                editor.focus();
     116                        }
     117                };
     118        }
     119
     120        CKEDITOR.plugins.add( 'bidi',
     121        {
     122                requires : [ 'styles', 'button' ],
     123
     124                init : function( editor )
     125                {
     126                        // All buttons use the same code to register. So, to avoid
     127                        // duplications, let's use this tool function.
     128                        var addButtonCommand = function( buttonName, buttonLabel, commandName, commandExec )
     129                        {
     130                                editor.addCommand( commandName, new CKEDITOR.command( editor, { exec : commandExec }) );
     131
     132                                editor.ui.addButton( buttonName,
     133                                        {
     134                                                label : buttonLabel,
     135                                                command : commandName
     136                                        });
     137                        };
     138
     139                        var lang = editor.lang.bidi;
     140
     141                        addButtonCommand( 'BidiLtr', lang.rtl, 'bidiltr', bidiCommand( 'ltr' ) );
     142                        addButtonCommand( 'BidiRtl', lang.ltr, 'bidirtl', bidiCommand( 'rtl' ) );
     143
     144                        editor.on( 'selectionChange', onSelectionChange );
     145                }
     146        });
     147       
     148})();
  • _source/core/config.js

     
    243243         * @type String
    244244         * @example
    245245         */
    246         plugins : 'about,a11yhelp,basicstyles,blockquote,button,clipboard,colorbutton,colordialog,contextmenu,div,elementspath,enterkey,entities,filebrowser,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,liststyle,maximize,newpage,pagebreak,pastefromword,pastetext,popup,preview,print,removeformat,resize,save,scayt,smiley,showblocks,showborders,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
     246        plugins : 'about,a11yhelp,basicstyles,bidi,blockquote,button,clipboard,colorbutton,colordialog,contextmenu,div,elementspath,enterkey,entities,filebrowser,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,liststyle,maximize,newpage,pagebreak,pastefromword,pastetext,popup,preview,print,removeformat,resize,save,scayt,smiley,showblocks,showborders,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
    247247
    248248        /**
    249249         * List of additional plugins to be loaded. This is a tool setting which
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy