Ticket #3673: 3673_8.patch

File 3673_8.patch, 32.2 KB (added by Martin Kou, 15 years ago)
  • _source/plugins/image/dialogs/image.js

     
    445445                                                                                        id : 'browse',
    446446                                                                                        align : 'center',
    447447                                                                                        label : editor.lang.common.browseServer,
    448                                                                                         onLoad : function()
    449                                                                                         {
    450                                                                                                 var dialog = this.getDialog();
    451                                                                                                 if ( !dialog.getParentEditor().config.image_browseServer )
    452                                                                                                         dialog.getContentElement( 'info', 'browse' ).getElement().hide();
    453                                                                                         },
    454                                                                                         onClick : function()
    455                                                                                         {
    456 
    457                                                                                         }
     448                                                                                        hidden : true,
     449                                                                                        filebrowser : 'info:txtUrl'
    458450                                                                                }
    459451                                                                        ]
    460452                                                                }
     
    930922                                                {
    931923                                                        type : 'button',
    932924                                                        id : 'browse',
     925                                                        filebrowser : 'Link:txtUrl',
    933926                                                        style : 'float:right',
    934                                                         label : editor.lang.common.browseServer,
    935                                                         onClick : function()
    936                                                         {
    937                                                         }
     927                                                        hidden : true,
     928                                                        label : editor.lang.common.browseServer
    938929                                                },
    939930                                                {
    940931                                                        id : 'cmbTarget',
     
    967958                                },
    968959                                {
    969960                                        id : 'Upload',
     961                                        hidden : true,
     962                                        filebrowser : 'uploadButton',
    970963                                        label : editor.lang.image.upload,
    971964                                        elements :
    972965                                        [
     
    974967                                                        type : 'file',
    975968                                                        id : 'upload',
    976969                                                        label : editor.lang.image.btnUpload,
    977                                                         action : editor.config.image_uploadAction,
    978970                                                        size : 38
    979971                                                },
    980972                                                {
    981973                                                        type : 'fileButton',
    982974                                                        id : 'uploadButton',
     975                                                        filebrowser : 'info:txtUrl',
    983976                                                        label : editor.lang.image.btnUpload,
    984977                                                        'for' : [ 'Upload', 'upload' ]
    985978                                                }
  • _source/plugins/image/plugin.js

     
    5454        }
    5555} );
    5656
    57 /**
    58  * Show Browse Server button.
    59  * @type Boolean
    60  * @default true
    61  */
    62 CKEDITOR.config.image_browseServer = true;
    63 
    64 /**
    65  * Upload action attribute.
    66  * @type URL
    67  */
    68 CKEDITOR.config.image_uploadAction = 'nowhere.php';
    69 
    7057CKEDITOR.config.image_removeLinkByEmptyURL = true;
  • _source/plugins/dialogui/plugin.js

     
    654654                                        this.validate = elementDefinition.validate;
    655655
    656656                                var myDefinition = CKEDITOR.tools.extend( {}, elementDefinition );
     657                                var onClick = myDefinition.onClick;
    657658                                myDefinition.className = ( myDefinition.className ? myDefinition.className + ' ' : '' ) + 'cke_dialog_ui_button';
    658659                                myDefinition.onClick = function( evt )
    659660                                {
    660661                                        var target = elementDefinition[ 'for' ];                // [ pageId, elementId ]
    661                                         dialog.getContentElement( target[0], target[1] ).submit();
    662                                         this.disable();
     662                                        if ( !onClick || onClick.call( this, evt ) !== false )
     663                                        {
     664                                                dialog.getContentElement( target[0], target[1] ).submit();
     665                                                this.disable();
     666                                        }
    663667                                };
    664668
    665669                                dialog.on( 'load', function()
     
    11971201                                },
    11981202
    11991203                                /**
     1204                                 * Get the action assigned to the form.
     1205                                 * @returns {String} The value of the action.
     1206                                 * @example
     1207                                 */
     1208                                getAction : function( action )
     1209                                {
     1210                                        return this.getInputElement().getParent().$.action;
     1211                                },
     1212
     1213                                /**
    12001214                                 * Redraws the file input and resets the file path in the file input.
    12011215                                 * The redraw logic is necessary because non-IE browsers tend to clear
    12021216                                 * the <iframe> containing the file input after closing the dialog.
    12031217                                 * @example
    12041218                                 */
    1205                                 reset : function()
     1219                                reset : function( action )
    12061220                                {
    12071221                                        var frameElement = CKEDITOR.document.getById( this._.frameId ),
    12081222                                                frameDocument = frameElement.getFrameDocument(),
     
    12191233
    12201234                                                frameDocument.$.write( [ '<html><head><title></title></head><body style="margin: 0; overflow: hidden; background: transparent;">',
    12211235                                                                '<form enctype="multipart/form-data" method="POST" action="',
    1222                                                                 CKEDITOR.tools.htmlEncode( elementDefinition.action ),
     1236                                                                CKEDITOR.tools.htmlEncode( action || elementDefinition.action ),
    12231237                                                                '">',
    12241238                                                                '<input type="file" name="',
    12251239                                                                CKEDITOR.tools.htmlEncode( elementDefinition.id || 'cke_upload' ),
  • _source/plugins/flash/dialogs/flash.js

     
    181181                        title : editor.lang.flash.title,
    182182                        minWidth : 420,
    183183                        minHeight : 310,
    184                         onLoad : function()
    185                         {
    186                                 if ( !editor.config.flashUploadTab )
    187                                         this.hidePage( 'Upload' );              // Hide Upload tab.
    188 
    189                                 if ( !editor.config.flashBrowseServer )
    190                                         this.getContentElement( 'info', 'browse' ).getElement().hide();
    191                         },
    192184                        onShow : function()
    193185                        {
    194186                                // Clear previously saved elements.
     
    347339                                                                                {
    348340                                                                                        type : 'button',
    349341                                                                                        id : 'browse',
     342                                                                                        filebrowser : 'src',
     343                                                                                        hidden : true,
    350344                                                                                        align : 'center',
    351345                                                                                        label : editor.lang.common.browseServer
    352346                                                                                }
     
    438432                                },
    439433                                {
    440434                                        id : 'Upload',
     435                                        hidden : true,
     436                                        filebrowser : 'uploadButton',
    441437                                        label : editor.lang.common.upload,
    442438                                        elements :
    443439                                        [
     
    445441                                                        type : 'file',
    446442                                                        id : 'upload',
    447443                                                        label : editor.lang.common.upload,
    448                                                         action : editor.config.image_uploadAction,
    449444                                                        size : 38
    450445                                                },
    451446                                                {
    452447                                                        type : 'fileButton',
    453448                                                        id : 'uploadButton',
    454449                                                        label : editor.lang.common.uploadSubmit,
     450                                                        filebrowser : 'src',
    455451                                                        'for' : [ 'Upload', 'upload' ]
    456452                                                }
    457453                                        ]
  • _source/plugins/flash/plugin.js

     
    142142
    143143CKEDITOR.tools.extend( CKEDITOR.config,
    144144{
    145         flashUploadTab : true,
    146         flashUploadAction : 'nowhere.php',
    147         flashBrowseServer : true,
    148 
    149145        /**
    150146         * Save as EMBED tag only. This tag is unrecommended.
    151147         * @type Boolean
  • _source/plugins/link/dialogs/link.js

     
    4141                {
    4242                        if ( editor.config.linkShowTargetTab )
    4343                                dialog.showPage( 'target' );
    44                         if ( editor.config.linkUploadTab )
     44                        if ( !dialog.isInitiallyHidden( 'upload' ) )
    4545                                dialog.showPage( 'upload' );
    4646                }
    4747                else
    4848                {
    4949                        dialog.hidePage( 'target' );
    50                         dialog.hidePage( 'upload' );
     50                        if ( !dialog.isInitiallyHidden( 'upload' ) )
     51                                dialog.hidePage( 'upload' );
    5152                }
    5253
    5354                for ( var i = 0 ; i < partIds.length ; i++ )
     
    388389                                                        {
    389390                                                                type : 'button',
    390391                                                                id : 'browse',
     392                                                                hidden : 'true',
     393                                                                filebrowser : 'url',
    391394                                                                label : editor.lang.common.browseServer
    392395                                                        }
    393396                                                ]
     
    815818                                id : 'upload',
    816819                                label : editor.lang.link.upload,
    817820                                title : editor.lang.link.upload,
     821                                hidden : true,
     822                                filebrowser : 'uploadButton',
    818823                                elements :
    819824                                [
    820825                                        {
    821826                                                type : 'file',
    822827                                                id : 'upload',
    823828                                                label : editor.lang.common.upload,
    824                                                 action : editor.config.linkUploadAction,
    825829                                                size : 38
    826830                                        },
    827831                                        {
    828832                                                type : 'fileButton',
    829833                                                id : 'uploadButton',
    830834                                                label : editor.lang.common.uploadSubmit,
     835                                                filebrowser : 'url',
    831836                                                'for' : [ 'upload', 'upload' ]
    832837                                        }
    833838                                ]
     
    10391044                                case 'url':
    10401045                                        var protocol = ( data.url && data.url.protocol != undefined ) ? data.url.protocol : 'http://',
    10411046                                                url = ( data.url && data.url.url ) || '';
    1042                                         attributes._cke_saved_href = protocol + url;
     1047                                        attributes._cke_saved_href = ( url.indexOf( '/' ) === 0 ) ? url : protocol + url;
    10431048                                        break;
    10441049                                case 'anchor':
    10451050                                        var name = ( data.anchor && data.anchor.name ),
     
    11951200                },
    11961201                onLoad : function()
    11971202                {
    1198                         if ( !editor.config.linkUploadTab )
    1199                                 this.hidePage( 'upload' );              //Hide Upload tab.
    1200 
    12011203                        if ( !editor.config.linkShowAdvancedTab )
    12021204                                this.hidePage( 'advanced' );            //Hide Advanded tab.
    12031205
    1204                         if ( !editor.config.linkBrowseServer )
    1205                                 this.getContentElement( 'info', 'browse' ).getElement().hide();
    1206 
    12071206                        if ( !editor.config.linkShowTargetTab )
    12081207                                this.hidePage( 'target' );              //Hide Target tab.
    12091208
  • _source/plugins/link/plugin.js

     
    183183
    184184CKEDITOR.tools.extend( CKEDITOR.config,
    185185{
    186         linkUploadTab : true,
    187         linkBrowseServer : true,
    188         linkUploadAction : 'nowhere.php',
    189186        linkShowAdvancedTab : true,
    190187        linkShowTargetTab : true
    191188} );
  • _source/plugins/dialog/plugin.js

     
    7373                return null;
    7474        }
    7575
     76        function deepCloneArray( list )
     77        {
     78                var retval = [];
     79
     80                for ( var i = 0 ; i < list.length ; i++ )
     81                {
     82                        if ( typeof( list[ i ].pop ) == 'function' )
     83                                retval.push( deepCloneArray( list[ i ] ) );
     84                        else if ( typeof( list[ i ] ) == 'object' )
     85                                retval.push( deepClone( list[ i ] ) );
     86                        else
     87                                retval.push( list[ i ] );
     88                }
     89
     90                return retval;
     91        }
     92
     93        function deepClone( obj )
     94        {
     95                var retval = {};
     96
     97                for ( var i in obj )
     98                {
     99                        var value = obj[ i ];
     100                        if ( typeof( value.pop ) == 'function' )
     101                                retval[ i ] = deepCloneArray( value );
     102                        else if ( typeof( value ) == 'object' )
     103                                retval[ i ] = deepClone( value );
     104                        else
     105                                retval[ i ] = value;
     106                }
     107
     108                return retval;
     109        }
     110
    76111        // Stores dialog related data from skin definitions. e.g. margin sizes.
    77112        var skinData = {};
    78113
     
    96131                }
    97132
    98133                // Completes the definition with the default values.
    99                 definition = CKEDITOR.tools.extend( definition( editor ), defaultDialogDefinition );
     134                definition = deepClone( CKEDITOR.tools.extend( definition( editor ), defaultDialogDefinition ) );
    100135
    101136                // Create a complex definition object, extending it with the API
    102137                // functions.
     
    756791                                        '<a class="cke_dialog_tab"',
    757792                                                ( this._.pageCount > 0 ? ' cke_last' : 'cke_first' ),
    758793                                                titleHtml,
     794                                                ( !!contents.hidden ? ' style="display:none"' : '' ),
    759795                                                ' id="', contents.id + '_', CKEDITOR.tools.getNextNumber(), '"' +
    760796                                                ' href="javascript:void(0)"',
    761797                                                ' hidefocus="true">',
     
    859895                },
    860896
    861897                /**
     898                 * Returns boolean variable indicating whether page was initially hidden.
     899                 * @param {String} id The page's Id.
     900                 * @returns {Boolean} true if hidden, false if not.
     901                 * @example
     902                 * dialog.isInitiallyHidden( 'upload' );
     903                 */
     904                isInitiallyHidden : function( id )
     905                {
     906                        return !!this.definition.getContents( id ).hidden;
     907                },
     908
     909                /**
    862910                 * Gets the root DOM element of the dialog.
    863911                 * @returns {CKEDITOR.dom.element} The &lt;span&gt; element containing this dialog.
    864912                 * @example
     
    871919                },
    872920
    873921                /**
     922                 * Gets the name of the dialog.
     923                 * @returns {String} The name of this dialog.
     924                 * @example
     925                 * var dialogName = dialogObj.getName();
     926                 */
     927                getName : function()
     928                {
     929                        return this._.name;
     930                },
     931
     932                /**
    874933                 * Gets a dialog UI element object from a dialog page.
    875934                 * @param {String} pageId id of dialog page.
    876935                 * @param {String} elementId id of UI element.
     
    17861845                         *      generate the final widget.</li>
    17871846                         *      <li><strong>title</strong> (Optional) The popup tooltip for the UI
    17881847                         *      element.</li>
     1848                         *      <li><strong>hidden</strong> (Optional) A flag that tells if the element
     1849                         *      should be initially visible.</li>
    17891850                         *      <li><strong>className</strong> (Optional) Additional CSS class names
    17901851                         *      to add to the UI element. Separated by space.</li>
    17911852                         *      <li><strong>style</strong> (Optional) Additional CSS inline styles
     
    18591920                                var styleStr = ( elementDefinition.style || '' ).split( ';' );
    18601921                                for ( i in styles )
    18611922                                        styleStr.push( i + ':' + styles[i] );
     1923                                if ( elementDefinition.hidden )
     1924                                        styleStr.push( 'display:none' );
    18621925                                for ( i = styleStr.length - 1 ; i >= 0 ; i-- )
    18631926                                {
    18641927                                        if ( styleStr[i] === '' )
    18651928                                                styleStr.splice( i, 1 );
    18661929                                }
    18671930                                if ( styleStr.length > 0 )
    1868                                         attributes.style = ( attributes.style || '' ) + styleStr.join( '; ' );
     1931                                        attributes.style = ( attributes.style ? ( attributes.style + '; ' ) : '' ) + styleStr.join( '; ' );
    18691932
    18701933                                // Write the attributes.
    18711934                                for ( i in attributes )
     
    21832246                },
    21842247
    21852248                /**
     2249                 * Gets the name of the parent tab of this element.
     2250                 * @returns {String} The name of selected tab.
     2251                 * @example
     2252                 * focus : function()
     2253                 * {
     2254                 *              this.getParentTab();
     2255                 *              // do something else.
     2256                 * }
     2257                 */
     2258                getParentTab : function()
     2259                {
     2260                        var element = this.getInputElement(),
     2261                                cursor = element,
     2262                                tabId;
     2263                        while ( ( cursor = cursor.getParent() ) && cursor.$.className.search( 'cke_dialog_page_contents' ) == -1 )
     2264                        { /*jsl:pass*/ }
     2265
     2266                        tabId = cursor.getAttribute( 'name' );
     2267
     2268                        return tabId;
     2269                },
     2270
     2271                /**
    21862272                 * Puts the focus to the UI object. Switches tabs if the UI object isn't in the active tab page.
    21872273                 * @returns {CKEDITOR.dialog.uiElement} The current UI element.
    21882274                 * @example
  • _source/plugins/filebrowser/plugin.js

     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6/**
     7 * @fileOverview The "filebrowser" plugin, it adds support for file uploads and
     8 *               browsing.
     9 *
     10 * When file is selected inside of the file browser or uploaded, its url is
     11 * inserted automatically to a field, which is described in the 'filebrowser'
     12 * attribute. To specify field that should be updated, pass the tab id and
     13 * element id, separated with a colon.
     14 *
     15 * Example 1: (Browse)
     16 *
     17 * <pre>
     18 * {
     19 *      type : 'button',
     20 *      id : 'browse',
     21 *      filebrowser : 'tabId:elementId',
     22 *      label : editor.lang.common.browseServer
     23 * }
     24 * </pre>
     25 *
     26 * If you set the 'filebrowser' attribute on any element other than
     27 * 'fileButton', the 'Browse' action will be triggered.
     28 *
     29 * Example 2: (Quick Upload)
     30 *
     31 * <pre>
     32 * {
     33 *      type : 'fileButton',
     34 *      id : 'uploadButton',
     35 *      filebrowser : 'tabId:elementId',
     36 *      label : editor.lang.common.uploadSubmit,
     37 *      'for' : [ 'upload', 'upload' ]
     38 * }
     39 * </pre>
     40 *
     41 * If you set the 'filebrowser' attribute on a fileButton element, the
     42 * 'QuickUpload' action will be executed.
     43 *
     44 * Filebrowser plugin also supports more advanced configuration (through
     45 * javascript object).
     46 *
     47 * The following settings are supported:
     48 *
     49 * <pre>
     50 *  [action] - Browse or QuickUpload
     51 *  [target] - field to update, tabId:elementId
     52 *  [params] - additional arguments to be passed to the server connector (optional)
     53 *  [onSelect] - function to execute when file is selected/uploaded (optional)
     54 *  [url] - the URL to be called (optional)
     55 * </pre>
     56 *
     57 * Example 3: (Quick Upload)
     58 *
     59 * <pre>
     60 * {
     61 *      type : 'fileButton',
     62 *      label : editor.lang.common.uploadSubmit,
     63 *      id : 'buttonId',
     64 *      filebrowser :
     65 *      {
     66 *              action : 'QuickUpload', //required
     67 *              target : 'tab1:elementId', //required
     68 *              params : //optional
     69 *              {
     70 *                      type : 'Files',
     71 *                      currentFolder : '/folder/'
     72 *              },
     73 *              onSelect : function( fileUrl, errorMessage ) //optional
     74 *              {
     75 *                      // Do not call the built-in selectFuntion
     76 *                      // return false;
     77 *              }
     78 *      },
     79 *      'for' : [ 'tab1', 'myFile' ]
     80 * }
     81 * </pre>
     82 *
     83 * Suppose we have a file element with id 'myFile', text field with id
     84 * 'elementId' and a fileButton. If filebowser.url is not specified explicitly,
     85 * form action will be set to 'filebrowser[DialogName]UploadUrl' or, if not
     86 * specified, to 'filebrowserUploadUrl'. Additional parameters from 'params'
     87 * object will be added to the query string. It is possible to create your own
     88 * uploadHandler and cancel the built-in updateTargetElement command.
     89 *
     90 * Example 4: (Browse)
     91 *
     92 * <pre>
     93 * {
     94 *      type : 'button',
     95 *      id : 'buttonId',
     96 *      label : editor.lang.common.browseServer,
     97 *      filebrowser :
     98 *      {
     99 *              action : 'Browse',
     100 *              url : '/ckfinder/ckfinder.html&amp;type=Images',
     101 *              target : 'tab1:elementId'
     102 *      }
     103 * }
     104 * </pre>
     105 *
     106 * In this example, after pressing a button, file browser will be opened in a
     107 * popup. If we don't specify filebrowser.url attribute,
     108 * 'filebrowser[DialogName]BrowseUrl' or 'filebrowserBrowseUrl' will be used.
     109 * After selecting a file in a file browser, an element with id 'elementId' will
     110 * be updated. Just like in the third example, a custom 'onSelect' function may be
     111 * defined.
     112 */
     113( function()
     114{
     115        /**
     116         * Adds (additional) arguments to given url.
     117         *
     118         * @param {String}
     119         *            url The url.
     120         * @param {Object}
     121         *            params Additional parameters.
     122         */
     123        function addQueryString( url, params )
     124        {
     125                var queryString = [];
     126
     127                if ( !params )
     128                        return url;
     129                else
     130                {
     131                        for ( var i in params )
     132                                queryString.push( i + "=" + encodeURIComponent( params[ i ] ) );
     133                }
     134
     135                return url + ( ( url.indexOf( "?" ) != -1 ) ? "&" : "?" ) + queryString.join( "&" );
     136        }
     137
     138        /**
     139         * Make a string's first character uppercase.
     140         *
     141         * @param {String}
     142         *            str String.
     143         */
     144        function ucFirst( str )
     145        {
     146                str += '';
     147                var f = str.charAt( 0 ).toUpperCase();
     148                return f + str.substr( 1 );
     149        }
     150
     151        /**
     152         * The onlick function assigned to the 'Browse Server' button. Opens the
     153         * file browser and updates target field when file is selected.
     154         *
     155         * @param {CKEDITOR.event}
     156         *            evt The event object.
     157         */
     158        function browseServer( evt )
     159        {
     160                var dialog = this.getDialog();
     161                var editor = dialog.getParentEditor();
     162
     163                editor._.filebrowserSe = this;
     164
     165                var width = editor.config[ 'filebrowser' + ucFirst( dialog.getName() ) + 'WindowWidth' ]
     166                                || editor.config.filebrowserWindowWidth || '80%';
     167                var height = editor.config[ 'filebrowser' + ucFirst( dialog.getName() ) + 'WindowHeight' ]
     168                                || editor.config.filebrowserWindowHeight || '70%';
     169                var url = this.filebrowser.url || editor.config[ 'filebrowser' + ucFirst( dialog.getName() ) + 'BrowseUrl' ]
     170                                || editor.config.filebrowserBrowseUrl;
     171
     172                var params = this.filebrowser.params || {};
     173                params.CKEditor = editor.name;
     174                params.CKEditorFuncNum = editor._.filebrowserFn;
     175                if ( !params.langCode )
     176                        params.langCode = editor.langCode;
     177
     178                url = addQueryString( url, params );
     179                editor.popup( url, width, height );
     180        }
     181
     182        /**
     183         * The onlick function assigned to the 'Upload' button. Makes the final
     184         * decision whether form is really submitted and updates target field when
     185         * file is uploaded.
     186         *
     187         * @param {CKEDITOR.event}
     188         *            evt The event object.
     189         */
     190        function uploadFile( evt )
     191        {
     192                var dialog = this.getDialog();
     193                var editor = dialog.getParentEditor();
     194                alert(this.id);
     195                alert(editor.name);
     196                editor._.filebrowserSe = this;
     197
     198                // If user didn't select the file, stop the upload.
     199                if ( !dialog.getContentElement( this[ 'for' ][ 0 ], this[ 'for' ][ 1 ] ).getInputElement().$.value )
     200                        return false;
     201
     202                if ( !dialog.getContentElement( this[ 'for' ][ 0 ], this[ 'for' ][ 1 ] ).getAction() )
     203                        return false;
     204
     205                return true;
     206        }
     207
     208        /**
     209         * Setups the file element.
     210         *
     211         * @param {CKEDITOR.ui.dialog.file}
     212         *            fileInput The file element used during file upload.
     213         * @param {Object}
     214         *            filebrowser Object containing filebrowser settings assigned to
     215         *            the fileButton associated with this file element.
     216         */
     217        function setupFileElement( editor, fileInput, filebrowser )
     218        {
     219                var params = filebrowser.params || {};
     220                params.CKEditor = editor.name;
     221                params.CKEditorFuncNum = editor._.filebrowserFn;
     222                if ( !params.langCode )
     223                        params.langCode = editor.langCode;
     224
     225                fileInput.action = addQueryString( filebrowser.url, params );
     226                fileInput.filebrowser = filebrowser;
     227        }
     228
     229        /**
     230         * Traverse through the content definition and attach filebrowser to
     231         * elements with 'filebrowser' attribute.
     232         *
     233         * @param String
     234         *            dialogName Dialog name.
     235         * @param {CKEDITOR.dialog.dialogDefinitionObject}
     236         *            definition Dialog definition.
     237         * @param {Array}
     238         *            elements Array of {@link CKEDITOR.dialog.contentDefinition}
     239         *            objects.
     240         */
     241        function attachFileBrowser( editor, dialogName, definition, elements )
     242        {
     243                var element, fileInput;
     244
     245                for ( var i in elements )
     246                {
     247                        element = elements[ i ];
     248
     249                        if ( element.type == 'hbox' || element.type == 'vbox' )
     250                                attachFileBrowser( editor, dialogName, definition, element.children );
     251
     252                        if ( !element.filebrowser )
     253                                continue;
     254
     255                        if ( typeof element.filebrowser == 'string' )
     256                        {
     257                                var fb =
     258                                {
     259                                        action : ( element.type == 'fileButton' ) ? 'QuickUpload' : 'Browse',
     260                                        target : element.filebrowser
     261                                };
     262                                element.filebrowser = fb;
     263                        }
     264
     265                        if ( element.filebrowser.action == 'Browse' )
     266                        {
     267                                var url = element.filebrowser.url || editor.config[ 'filebrowser' + ucFirst( dialogName ) + 'BrowseUrl' ]
     268                                                        || editor.config.filebrowserBrowseUrl;
     269
     270                                alert(1);
     271                                //editor.
     272                                /*
     273                                if ( url )
     274                                {
     275                                        element.onClick = browseServer;
     276                                        element.hidden = false;
     277                                }
     278                                */
     279                        }
     280                        else if ( element.filebrowser.action == 'QuickUpload' && element[ 'for' ] )
     281                        {
     282                                var url =  element.filebrowser.url || editor.config[ 'filebrowser' + ucFirst( dialogName ) + 'UploadUrl' ]
     283                                                        || editor.config.filebrowserUploadUrl;
     284
     285                                if ( url )
     286                                {
     287                                        element.onClick = uploadFile;
     288                                        element.filebrowser.url = url;
     289                                        element.hidden = false;
     290                                        setupFileElement( editor, definition.getContents( element[ 'for' ][ 0 ] ).get( element[ 'for' ][ 1 ] ), element.filebrowser );
     291                                }
     292                        }
     293                }
     294        }
     295
     296        /**
     297         * Updates the target element with the url of uploaded/selected file.
     298         *
     299         * @param {String}
     300         *            url The url of a file.
     301         */
     302        function updateTargetElement( url, sourceElement )
     303        {
     304                var dialog = sourceElement.getDialog();
     305                var targetElement = sourceElement.filebrowser.target || null;
     306                url = url.replace( /#/g, '%23' );
     307
     308                // If there is a reference to targetElement, update it.
     309                if ( targetElement )
     310                {
     311                        if ( targetElement === true )
     312                                targetElement = 'url';
     313
     314                        if ( targetElement.indexOf( ':' ) == -1 )
     315                        {
     316                                dialog.foreach( function( element )
     317                                {
     318                                        if ( element.id == targetElement )
     319                                        {
     320                                                element.setValue( url );
     321                                                dialog.selectPage( element.getParentTab() );
     322                                        }
     323                                } );
     324                        }
     325                        else
     326                        {
     327                                var target = targetElement.split( ':' );
     328                                var element = dialog.getContentElement( target[ 0 ], target[ 1 ] );
     329                                if ( element )
     330                                {
     331                                        element.setValue( url );
     332                                        dialog.selectPage( target[ 0 ] );
     333                                }
     334                        }
     335                }
     336        }
     337
     338        /**
     339         * Returns true if filebrowser is configured in one of the elements.   
     340         *
     341         * @param {CKEDITOR.dialog.dialogDefinitionObject}
     342         *            definition Dialog definition.
     343         * @param String
     344         *            tabId The tab id where element(s) can be found.
     345         * @param String
     346         *            elementId The element id (or ids, separated with a semicolon) to check.
     347         */
     348        function isConfigured( definition, tabId, elementId )
     349        {
     350                if ( elementId.indexOf( ";" ) !== -1 )
     351                {
     352                        var ids = elementId.split( ";" );
     353                        for ( var i = 0 ; i < ids.length ; i++ )
     354                        {
     355                                if ( isConfigured( definition, tabId, ids[i]) )
     356                                        return true;
     357                        }
     358                        return false;
     359                }
     360               
     361                return ( definition.getContents( tabId ).get( elementId ).filebrowser && definition.getContents( tabId ).get( elementId ).filebrowser.url );
     362        }
     363
     364        function setUrl( fileUrl, data )
     365        {
     366                var dialog = this._.filebrowserSe.getDialog(),
     367                        targetInput = this._.filebrowserSe[ 'for' ],
     368                        onSelect = this._.filebrowserSe.filebrowser.onSelect;
     369
     370                if ( targetInput )
     371                {
     372                        var formAction = dialog.getContentElement( targetInput[ 0 ], targetInput[ 1 ] ).getAction();
     373                        dialog.getContentElement( targetInput[ 0 ], targetInput[ 1 ] ).reset( formAction );
     374                }
     375
     376                if ( onSelect && onSelect.call( this._.filebrowserSe, fileUrl, data ) === false )
     377                        return;
     378
     379                // The "data" argument may be used to pass the error message to the editor.   
     380                if ( typeof data == 'string' && data )
     381                        alert( data );
     382
     383                if ( fileUrl )
     384                        updateTargetElement( fileUrl, this._.filebrowserSe );
     385        }
     386
     387        CKEDITOR.plugins.add( 'filebrowser',
     388        {
     389                init : function( editor, pluginPath )
     390                {
     391                        editor._.filebrowserFn = CKEDITOR.tools.addFunction( setUrl, editor );
     392
     393                        CKEDITOR.on( 'dialogDefinition', function( evt )
     394                        {
     395                                if ( evt.editor.name == 'editor1' )
     396                                {
     397                                        evt.data.definition.contents[0].elements[0].children[1].children[1].hidden = false;
     398                                }
     399                                else
     400                                {
     401                                        evt.data.definition.contents[0].elements[0].children[1].children[1].hidden = true;
     402                                }
     403                                /*
     404                                // Associate filebrowser to elements with 'filebrowser' attribute.
     405                                for ( var i in evt.data.definition.contents )
     406                                {
     407                                        attachFileBrowser( editor, evt.data.name, evt.data.definition, evt.data.definition.contents[ i ].elements );
     408                                        if ( evt.data.definition.contents[ i ].hidden && evt.data.definition.contents[ i ].filebrowser )
     409                                        {
     410                                                evt.data.definition.contents[ i ].hidden =
     411                                                        !isConfigured( evt.data.definition, evt.data.definition.contents[ i ][ 'id' ], evt.data.definition.contents[ i ].filebrowser );
     412                                        }
     413                                }
     414                                */
     415                        } );
     416                }
     417        } );
     418
     419} )();
  • _source/plugins/popup/plugin.js

     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6CKEDITOR.plugins.add( 'popup');
     7
     8CKEDITOR.tools.extend( CKEDITOR.editor.prototype,
     9{
     10        /**
     11         * Opens Browser in a popup. The "width" and "height" parameters accept
     12         * numbers (pixels) or percent (of screen size) values.
     13         * @param {String} url The url of the external file browser.
     14         * @param {String} width Popup window width.
     15         * @param {String} height Popup window height.
     16         */
     17        popup : function( url, width, height )
     18        {
     19                width = width || '80%';
     20                height = height || '70%';
     21
     22                if ( typeof width == 'string' && width.length > 1 && width.substr( width.length - 1, 1 ) == '%' )
     23                        width = parseInt( window.screen.width * parseInt( width, 10 ) / 100, 10 );
     24
     25                if ( typeof height == 'string' && height.length > 1 && height.substr( height.length - 1, 1 ) == '%' )
     26                        height = parseInt( window.screen.height * parseInt( height, 10 ) / 100, 10 );
     27
     28                if ( width < 640 )
     29                        width = 640;
     30
     31                if ( height < 420 )
     32                        height = 420;
     33
     34                var top = parseInt( ( window.screen.height - height ) / 2, 10 ),
     35                        left = parseInt( ( window.screen.width  - width ) / 2, 10 ),
     36                        options = 'location=no,menubar=no,toolbar=no,dependent=yes,minimizable=no,modal=yes,alwaysRaised=yes,resizable=yes' +
     37                        ',width='  + width +
     38                        ',height=' + height +
     39                        ',top='  + top +
     40                        ',left=' + left;
     41
     42                var popupWindow = window.open( '', null, options, true );
     43
     44                // Blocked by a popup blocker.
     45                if ( !popupWindow )
     46                        return false;
     47
     48                try
     49                {
     50                        popupWindow.moveTo( left, top );
     51                        popupWindow.resizeTo( width, height );
     52                        popupWindow.focus();
     53                        popupWindow.location.href = url;
     54                }
     55                catch (e)
     56                {
     57                        popupWindow = window.open( url, null, options, true );
     58                }
     59
     60                return true ;
     61        }
     62});
  • _source/core/config.js

     
    149149         * @example
    150150         * config.plugins = 'basicstyles,button,htmldataprocessor,toolbar,wysiwygarea';
    151151         */
    152 
    153         plugins : 'about,basicstyles,blockquote,button,clipboard,colorbutton,contextmenu,elementspath,enterkey,entities,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,maximize,newpage,pagebreak,pastefromword,pastetext,preview,print,removeformat,resize,save,scayt,smiley,showblocks,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
    154 
     152        plugins : 'about,basicstyles,blockquote,button,clipboard,colorbutton,contextmenu,elementspath,enterkey,entities,filebrowser,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,maximize,newpage,pagebreak,pastefromword,pastetext,popup,preview,print,removeformat,save,smiley,showblocks,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
    155153        /**
    156154         * List of additional plugins to be loaded. This is a tool setting which
    157155         * makes it easier to add new plugins, whithout having to touch and
  • ckeditor.pack

     
    153153                                        '_source/plugins/pagebreak/plugin.js',
    154154                                        '_source/plugins/pastefromword/plugin.js',
    155155                                        '_source/plugins/pastetext/plugin.js',
     156                                        '_source/plugins/popup/plugin.js',
    156157                                        '_source/plugins/preview/plugin.js',
    157158                                        '_source/plugins/print/plugin.js',
    158159                                        '_source/plugins/removeformat/plugin.js',
    159160                                        '_source/plugins/resize/plugin.js',
    160161                                        '_source/plugins/save/plugin.js',
     162                                        '_source/plugins/filebrowser/plugin.js',
    161163                                        '_source/plugins/scayt/plugin.js',
    162164                                        '_source/plugins/smiley/plugin.js',
    163165                                        '_source/plugins/showblocks/plugin.js',
  • _samples/replacebycode.html

     
    2424
    2525                                        // Replace the <textarea id="editor"> with an CKEditor
    2626                                        // instance, using default configurations.
    27                                         CKEDITOR.replace( 'editor1' );
     27                                        CKEDITOR.replace( 'editor1',
     28                                                        {
     29                                                                filebrowserBrowseUrl : '/external_ckfinder/ckfinder.html',
     30                                                                filebrowserImageBrowseUrl : '/external_ckfinder/ckfinder.html?Type=Images',
     31                                                                filebrowserFlashBrowseUrl : '/external_ckfinder/ckfinder.html?Type=Flash',
     32                                                                filebrowserUploadUrl : '/external_ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
     33                                                                filebrowserImageUploadUrl : '/external_ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
     34                                                                filebrowserFlashUploadUrl : '/external_ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
     35                                                        }
     36                                                         );
    2837
    2938                                //]]>
    3039                                </script>
     
    4251
    4352                                        // Replace the <textarea id="editor"> with an CKEditor
    4453                                        // instance, using default configurations.
    45                                         CKEDITOR.replace( 'editor2' );
     54                                        CKEDITOR.replace( 'editor2',
     55                                                        {
     56                                                /*
     57                                                                filebrowserBrowseUrl : '/external_ckfinder/ckfinder.html',
     58                                                                filebrowserUploadUrl : '/external_ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
     59                                                                */
     60                                                        }
     61                                        );
    4662
    4763                                //]]>
    4864                                </script>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy