Ticket #3673: 3673_2.patch

File 3673_2.patch, 25.4 KB (added by Wiktor Walc, 15 years ago)
  • _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
  • _source/lang/en.js

     
    545545                panelTitle3 : 'Object Styles'
    546546        },
    547547
     548        filebrowser :
     549        {
     550                errorUnknown : 'Unknown error: %1',
     551                browserNotConfigured : 'Unable to open file browser due to missing configuration settings',
     552                uploaderNotConfigured : 'Unable to upload file due to missing configuration settings',
     553        },
     554       
    548555        format :
    549556        {
    550557                label : 'Format',
  • _source/plugins/dialog/plugin.js

     
    871871                },
    872872
    873873                /**
     874                 * Gets the name of the dialog.
     875                 * @returns {String} The name of this dialog.
     876                 * @example
     877                 * var dialogName = dialogObj.getName();
     878                 */
     879                getName : function()
     880                {
     881                        return this._.name;
     882                },
     883
     884                /**
    874885                 * Gets a dialog UI element object from a dialog page.
    875886                 * @param {String} pageId id of dialog page.
    876887                 * @param {String} elementId id of UI element.
     
    21772188                },
    21782189
    21792190                /**
     2191                 * Gets the name of the parent tab of this element.
     2192                 * @returns {String} The name of selected tab.
     2193                 * @example
     2194                 * focus : function()
     2195                 * {
     2196                 *              this.getParentTab();
     2197                 *              // do something else.
     2198                 * }
     2199                 */
     2200                getParentTab : function()
     2201                {
     2202                        var element = this.getInputElement(),
     2203                                cursor = element,
     2204                                tabId;
     2205                        while ( ( cursor = cursor.getParent() ) && cursor.$.className.search( 'cke_dialog_page_contents' ) == -1 )
     2206                        { /*jsl:pass*/ }
     2207
     2208                        tabId = cursor.getAttribute( 'name' );
     2209
     2210                        return tabId;
     2211                },
     2212
     2213                /**
    21802214                 * Puts the focus to the UI object. Switches tabs if the UI object isn't in the active tab page.
    21812215                 * @returns {CKEDITOR.dialog.uiElement} The current UI element.
    21822216                 * @example
  • _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/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 browsing.
     8 *
     9 * When file is selected inside of the file browser or uploaded, its url is inserted automatically to
     10 * a field, which is described in the 'filebrowser' attribute.
     11 * To specify field that should be updated, pass the tab id and element id, separated with a colon.
     12 *
     13 * Example 1: (Browse)
     14 *      {
     15 *              type : 'button',
     16 *              id : 'browse',
     17 *              filebrowser : 'tabId:elementId',
     18 *              label : editor.lang.common.browseServer
     19 *      }
     20 *
     21 * If you set the 'filebrowser' attribute on any element other than 'fileButton', the 'Browse'
     22 * action will be triggered.
     23 *
     24 * Example 2: (Quick Upload)
     25 *      {
     26 *              type : 'fileButton',
     27 *              id : 'uploadButton',
     28 *              filebrowser : 'tabId:elementId',
     29 *              label : editor.lang.common.uploadSubmit,
     30 *              'for' : [ 'upload', 'upload' ]
     31 *      }
     32 *
     33 * If you set the 'filebrowser' attribute on a fileButton element, the 'QuickUpload'
     34 * action will be executed.
     35 *
     36 * Filebrowser plugin also supports more advanced configuration (through javascript object).
     37 *
     38 * The following settings are supported:
     39 *  [action] - Browse or QuickUpload
     40 *  [target] - field to update, tabId:elementId
     41 *  [params] - additional arguments to be passed to the server connector (optional)
     42 *  [selectFunction] - name of the javascript function called by the server connector when file is
     43 *                                      selected/uploaded, default value is 'SetUrl'.
     44 *  [onSelect] - function to execute when file is selected/uploaded (optional)
     45 *  [url] - the URL to be called (optional)
     46 *
     47 * Example 3: (Quick Upload)
     48 *  {
     49 *      type : 'fileButton',
     50 *      label : editor.lang.common.uploadSubmit,
     51 *      id : 'buttonId',
     52 *      filebrowser :
     53 *      {
     54 *              action : 'QuickUpload', //required
     55 *              target : 'tab1:elementId', //required
     56 *              params : { type : 'Files', currentFolder : '/folder/' }, //optional
     57 *              onSelect : function( fileUrl, errorMessage ) //optional
     58 *              {
     59 *                      // Do not call the built-in selectFuntion
     60 *                      // return false;
     61 *              }
     62 *      },
     63 *      'for' : ['tab1', 'myFile']
     64 *      }
     65 *
     66 * Suppose we have a file element with id 'myFile', text field with id 'elementId' and a fileButton.
     67 * If filebowser.url is not specified explicitly, form action will be set to
     68 * 'filebrowser[DialogName]UploadUrl' or, if not specified, to 'filebrowserUploadUrl'.
     69 * Additional parameters from 'params' object will be added to the query string.
     70 * It is possible to create your own uploadHandler and cancel the built-in updateTargetElement command.
     71 *
     72 * Example 4: (Browse)
     73 *      {
     74 *              type : 'button',
     75 *              id : 'buttonId',
     76 *              label : editor.lang.common.browseServer,
     77 *              filebrowser :
     78 *              {
     79 *                      action : 'Browse',
     80 *                      url : '/ckfinder/ckfinder.html?action=js&func=SetUrl&thumbFunc=SetUrl&type=Images',
     81 *                      target : 'tab1:elementId'
     82 *              }
     83 *      }
     84 * 
     85 *  In this example, after pressing a button, file browser will be opened in a popup.
     86 *  If we don't specify filebrowser.url attribute, 'filebrowser[DialogName]BrowseUrl' or 
     87 *  'filebrowserBrowseUrl' will be used.
     88 *  After selecting a file in a file browser, an element with id 'elementId' will be updated.
     89 */
     90CKEDITOR.plugins.add( 'filebrowser',
     91{
     92        /**
     93         * Reference to the last opened dialog. Required by 'selectFunction'.
     94         * @type {CKEDITOR.dialog}
     95         */
     96        _dialog : null,
     97        /**
     98         * The "action" attribute that will be passed to the {@see CKEDITOR.ui.dialog.file#reset} function.
     99         * The "action" attribute is generated automatically in some cases.
     100         * @type String
     101         */
     102        _formAction : null,
     103        /**
     104         * Holds the reference to the file input element to reset after file is uploaded.
     105         * Syntax: [ pageId, elementId ]
     106         * @type Array
     107         */
     108        _targetInput : null,
     109        /**
     110         * Holds the reference to the UI element that will be updated when file is selected/uploaded.
     111         * Syntax: pageId:elementId
     112         * @type Array
     113         */
     114        _targetElement : null,
     115        /**
     116         * The user defined function (if defined) that will be called when file is selected/uploaded.
     117         * @type Function
     118         */
     119        _onSelect : null,
     120       
     121        init : function( editor, pluginPath )
     122        {
     123                /**
     124                 * Updates the target element with the url of uploaded/selected file.
     125                 * @param {String} url The url of a file.
     126                 */
     127                var updateTargetElement = function( url )
     128                {
     129                        url = url.replace( /#/g, '%23' );
     130                        var plugin = editor.plugins.filebrowser;
     131                        var targetElement = plugin._targetElement;
     132
     133                        // If there is a reference to targetElement, update it.
     134                        if ( targetElement )
     135                        {
     136                                if ( targetElement === true )
     137                                        targetElement = 'url';
     138
     139                                if ( targetElement.indexOf( ':' ) == -1 )
     140                                {
     141                                        plugin._dialog.foreach( function ( e ) {
     142                                                if ( e.id == plugin._targetElement )
     143                                                {
     144                                                        e.setValue( url );
     145                                                        plugin._dialog.selectPage( e.getParentTab() );
     146                                                }
     147                                        });
     148                                }
     149                                else
     150                                {
     151                                        var target = plugin._targetElement.split( ':' );
     152                                        var element = plugin._dialog.getContentElement( target[0], target[1] );
     153                                        if ( element )
     154                                        {
     155                                                element.setValue( url );
     156                                                plugin._dialog.selectPage( target[0] );
     157                                        }
     158                                }
     159                        }
     160                };
     161
     162                /**
     163                 * Make a string's first character uppercase.
     164                 * @param {String} str String.
     165                 */
     166                var ucFirst = function( str )
     167                {
     168                        str += '';
     169                        var f = str.charAt( 0 ).toUpperCase();
     170                        return f + str.substr( 1 );
     171                };
     172
     173                /**
     174                 * The onlick function assigned to the 'Browse Server' button.
     175                 * Opens the file browser and updates target field when file is selected.
     176                 * @param {CKEDITOR.event} evt The event object.
     177                 */
     178                var browseServer = function( evt )
     179                {
     180                        var dialog = this.getDialog();
     181                        var editor = dialog.getParentEditor();
     182                        var plugin = editor.plugins.filebrowser;
     183                        var params = this.filebrowser.params || {};
     184
     185                        // Save references to fields required by the 'selectFunction'.
     186                        plugin._dialog = dialog;
     187                        plugin._targetElement = this.filebrowser.target || null;
     188                        plugin._onSelect = this.filebrowser.onSelect;
     189
     190                        // Function that is called when the user selects a file in external file browser.
     191                        var selectFunction = this.filebrowser.selectFunction || editor.config['filebrowserSelectFunction'] || 'SetUrl';
     192
     193                        this.getElement().getWindow().$[selectFunction] = function( fileUrl, data )
     194                        {
     195                                if ( plugin._onSelect && plugin._onSelect( fileUrl, data ) === false )
     196                                        return;
     197
     198                                updateTargetElement( fileUrl );
     199                        };
     200
     201                        var width = editor.config['filebrowser' + ucFirst( dialog.getName() ) + 'WindowWidth'] || editor.config.filebrowserWindowWidth || '80%';
     202                        var height = editor.config['filebrowser' + ucFirst( dialog.getName() ) + 'WindowHeight'] || editor.config.filebrowserWindowHeight || '70%';
     203                        var url = this.filebrowser.url || editor.config['filebrowser' + ucFirst( dialog.getName() ) + 'BrowseUrl'] || editor.config.filebrowserBrowseUrl;
     204
     205                        if ( !url )
     206                        {
     207                                alert( editor.lang.filebrowser.browserNotConfigured );
     208                                return;
     209                        }
     210
     211                        if ( !params.langCode )
     212                                params.langCode = editor.langCode;
     213
     214                        params.CKEditor = 1;
     215                        url = addQueryString( url, params );
     216
     217                        editor.popup( url, width, height );
     218                };
     219
     220                /**
     221                 * The onlick function assigned to the 'Upload' button.
     222                 * Makes the final decision whether form is really submitted and updates target field when file is uploaded.
     223                 * @param {CKEDITOR.event} evt The event object.
     224                 */
     225                var uploadFile = function( evt )
     226                {
     227                        var dialog = this.getDialog();
     228                        var editor = dialog.getParentEditor();
     229                        var plugin = editor.plugins.filebrowser;
     230
     231                        // Update variables that will be used by the 'selectFunction' function.
     232                        plugin._onSelect = this.filebrowser.onSelect;
     233                        plugin._dialog = dialog;
     234                        plugin._targetInput = this['for'];
     235                        plugin._formAction = dialog.getContentElement( this['for'][0], this['for'][1] ).getAction();
     236
     237                        // If user didn't select the file, stop the upload.
     238                        if ( !dialog.getContentElement( this['for'][0], this['for'][1] ).getInputElement().$.value )
     239                        {
     240                                alert( editor.lang.filebrowser.fileNotSelected );
     241                                return false;
     242                        }
     243
     244                        if ( !plugin._formAction )
     245                        {
     246                                alert( editor.lang.filebrowser.uploaderNotConfigured );
     247                                return false;
     248                        }
     249                       
     250                        // targetElement will be updated with the url of uploaded file.
     251                        plugin._targetElement = this.filebrowser.target || null;
     252
     253                        // Function to be called by the server connector after file is uploaded.
     254                        var selectFunction = this.filebrowser.selectFunction || editor.config['filebrowserSelectFunction'] || 'SetUrl';
     255
     256                        this.getElement().getWindow().$[selectFunction] = function( fileUrl, errorMessage )
     257                        {
     258                                plugin._dialog.getContentElement( plugin._targetInput[0], plugin._targetInput[1] ).reset( plugin._formAction );
     259
     260                                if ( plugin._onSelect && plugin._onSelect( fileUrl, errorMessage ) === false )
     261                                        return;
     262                               
     263                                if ( errorMessage )
     264                                        alert( errorMessage );
     265
     266                                if ( fileUrl )
     267                                        updateTargetElement( fileUrl );
     268                        };
     269                       
     270                        return true;
     271                };
     272
     273                /**
     274                 * Adds (additional) arguments to given url.
     275                 * @param {String} url The url.
     276                 * @param {Object} params Additional parameters.
     277                 */     
     278                var addQueryString = function( url, params )
     279                {
     280                        var queryString = [];
     281
     282                        if ( !params )
     283                                return url;
     284                        else
     285                        {
     286                                for ( var i in params )
     287                                        queryString.push( i + "=" + encodeURIComponent( params[i] ) );
     288                        }
     289
     290                        return url + ( ( url.indexOf( "?" ) != -1 ) ? "&" : "?" ) + queryString.join( "&" );
     291                };
     292
     293                /**
     294                 * Setups the file element.
     295                 * @param {CKEDITOR.ui.dialog.file} fileInput The file element used during file upload.
     296                 * @param {Object} filebrowser Object containing filebrowser settings assigned to the fileButton
     297                 * associated with this file element.
     298                 */
     299                var setupFileElement = function( dialogName, fileInput, filebrowser )
     300                {
     301                        var params = filebrowser.params || {};
     302
     303                        params.CKEditor = 1;
     304                        if ( !params.langCode )
     305                                params.langCode = editor.langCode;
     306
     307                        var url = filebrowser.url || editor.config['filebrowser' + ucFirst( dialogName ) + 'UploadUrl'] || editor.config.filebrowserUploadUrl;
     308
     309                        fileInput.action = url ? addQueryString( url, params ) : '';
     310                        fileInput.filebrowser = filebrowser;
     311                };
     312
     313                /**
     314                 * Traverse through the content definition and attach filebrowser
     315                 * to elements with 'filebrowser' attribute.
     316                 * @param {CKEDITOR.dialog.dialogDefinitionObject} definition
     317                 * @param {Array} elements Array of {@link CKEDITOR.dialog.contentDefinition} objects.
     318                 */
     319                var attachFileBrowser = function( dialogName, definition, elements )
     320                {
     321                        var element, fileInput;
     322
     323                        for ( var i in elements )
     324                        {
     325                                element = elements[i];
     326
     327                                if ( element.type == 'hbox' || element.type == 'vbox' )
     328                                        attachFileBrowser( dialogName, definition, element.children );
     329
     330                                if ( !element.filebrowser )
     331                                        continue;
     332
     333                                if ( typeof element.filebrowser == 'string' )
     334                                {
     335                                        var fb = {
     336                                                action : ( element.type == 'fileButton' ) ? 'QuickUpload' : 'Browse',
     337                                                target : element.filebrowser
     338                                        };
     339                                        element.filebrowser = fb;
     340                                }
     341
     342                                if ( element.filebrowser.action == 'Browse' )
     343                                {
     344                                        element.onClick = browseServer;
     345                                }
     346                                else if ( element.filebrowser.action == 'QuickUpload' && element['for'] )
     347                                {
     348                                        setupFileElement( dialogName, definition.getContents( element['for'][0] ).get( element['for'][1] ), element.filebrowser );
     349                                        element.onClick = uploadFile;
     350                                }
     351                        }
     352                };
     353
     354                CKEDITOR.on( 'dialogDefinition', function( evt )
     355                                {
     356                                        var i, browseButton, fileButton;
     357
     358                                        // Associate filebrowser to elements with 'filebrowser' attribute.
     359                                        for ( i in evt.data.definition.contents )
     360                                                attachFileBrowser( evt.data.name, evt.data.definition, evt.data.definition.contents[i].elements );
     361                                });
     362        }
     363} );
  • _source/plugins/flash/dialogs/flash.js

     
    347347                                                                                {
    348348                                                                                        type : 'button',
    349349                                                                                        id : 'browse',
     350                                                                                        filebrowser : 'src',
    350351                                                                                        align : 'center',
    351352                                                                                        label : editor.lang.common.browseServer
    352353                                                                                }
     
    445446                                                        type : 'file',
    446447                                                        id : 'upload',
    447448                                                        label : editor.lang.common.upload,
    448                                                         action : editor.config.image_uploadAction,
    449449                                                        size : 38
    450450                                                },
    451451                                                {
    452452                                                        type : 'fileButton',
    453453                                                        id : 'uploadButton',
    454454                                                        label : editor.lang.common.uploadSubmit,
     455                                                        filebrowser : 'src',
    455456                                                        'for' : [ 'Upload', 'upload' ]
    456457                                                }
    457458                                        ]
  • _source/plugins/flash/plugin.js

     
    143143CKEDITOR.tools.extend( CKEDITOR.config,
    144144{
    145145        flashUploadTab : true,
    146         flashUploadAction : 'nowhere.php',
    147146        flashBrowseServer : true,
    148147
    149148        /**
  • _source/plugins/image/dialogs/image.js

     
    445445                                                                                        id : 'browse',
    446446                                                                                        align : 'center',
    447447                                                                                        label : editor.lang.common.browseServer,
     448                                                                                        filebrowser : 'info:txtUrl',
    448449                                                                                        onLoad : function()
    449450                                                                                        {
    450451                                                                                                var dialog = this.getDialog();
    451452                                                                                                if ( !dialog.getParentEditor().config.image_browseServer )
    452453                                                                                                        dialog.getContentElement( 'info', 'browse' ).getElement().hide();
    453                                                                                         },
    454                                                                                         onClick : function()
    455                                                                                         {
    456 
    457454                                                                                        }
    458455                                                                                }
    459456                                                                        ]
     
    930927                                                {
    931928                                                        type : 'button',
    932929                                                        id : 'browse',
     930                                                        filebrowser : 'Link:txtUrl',
    933931                                                        style : 'float:right',
    934                                                         label : editor.lang.common.browseServer,
    935                                                         onClick : function()
    936                                                         {
    937                                                         }
     932                                                        label : editor.lang.common.browseServer
    938933                                                },
    939934                                                {
    940935                                                        id : 'cmbTarget',
     
    974969                                                        type : 'file',
    975970                                                        id : 'upload',
    976971                                                        label : editor.lang.image.btnUpload,
    977                                                         action : editor.config.image_uploadAction,
    978972                                                        size : 38
    979973                                                },
    980974                                                {
    981975                                                        type : 'fileButton',
    982976                                                        id : 'uploadButton',
     977                                                        filebrowser : 'info:txtUrl',
    983978                                                        label : editor.lang.image.btnUpload,
    984979                                                        'for' : [ 'Upload', 'upload' ]
    985980                                                }
  • _source/plugins/image/plugin.js

     
    6161 */
    6262CKEDITOR.config.image_browseServer = true;
    6363
    64 /**
    65  * Upload action attribute.
    66  * @type URL
    67  */
    68 CKEDITOR.config.image_uploadAction = 'nowhere.php';
    69 
    7064CKEDITOR.config.image_removeLinkByEmptyURL = true;
  • _source/plugins/link/dialogs/link.js

     
    388388                                                        {
    389389                                                                type : 'button',
    390390                                                                id : 'browse',
     391                                                                filebrowser : 'url',
    391392                                                                label : editor.lang.common.browseServer
    392393                                                        }
    393394                                                ]
     
    821822                                                type : 'file',
    822823                                                id : 'upload',
    823824                                                label : editor.lang.common.upload,
    824                                                 action : editor.config.linkUploadAction,
    825825                                                size : 38
    826826                                        },
    827827                                        {
    828828                                                type : 'fileButton',
    829829                                                id : 'uploadButton',
    830830                                                label : editor.lang.common.uploadSubmit,
     831                                                filebrowser : 'url',
    831832                                                'for' : [ 'upload', 'upload' ]
    832833                                        }
    833834                                ]
     
    10391040                                case 'url':
    10401041                                        var protocol = ( data.url && data.url.protocol != undefined ) ? data.url.protocol : 'http://',
    10411042                                                url = ( data.url && data.url.url ) || '';
    1042                                         attributes._cke_saved_href = protocol + url;
     1043                                        attributes._cke_saved_href = ( url.indexOf( '/' ) === 0 ) ? url : protocol + url;
    10431044                                        break;
    10441045                                case 'anchor':
    10451046                                        var name = ( data.anchor && data.anchor.name ),
  • _source/plugins/link/plugin.js

     
    185185{
    186186        linkUploadTab : true,
    187187        linkBrowseServer : true,
    188         linkUploadAction : 'nowhere.php',
    189188        linkShowAdvancedTab : true,
    190189        linkShowTargetTab : true
    191190} );
  • _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});
     63 No newline at end of file
  • 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',
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy