Вход Регистрация
Файл: fckeditor/ckfinder/ckfinder.js
Строк: 452
<?php

/*
 * CKFinder
 * ========
 * http://www.ckfinder.com
 * Copyright (C) 2007-2008 Frederico Caldeira Knabben (FredCK.com)
 *
 * The software, this file and its contents are subject to the CKFinder
 * License. Please read the license.txt file before using, installing, copying,
 * modifying or distribute this file or part of its contents. The contents of
 * this file is part of the Source Code of CKFinder.
 *
 * $Revision: 471 $
 */

var CKFinder = function( basePathwidthheightselectFunction )
{
    
// The URL path for the installation folder of CKFinder (default = "/ckfinder/").
    
this.BasePath basePath || CKFinder.DEFAULT_BASEPATH ;

    
// The CKFinder width (ex: 600, '80%') (default = "100%").
    
this.Width    width || '100%' ;

    
// The CKFinder height (ex: 500, '100%') (default = 400).
    
this.Height    height || 400 ;

    
// An optional function to be called when the user selects a file in CKFinder.
    
this.SelectFunction selectFunction || null ;
    
    
// (Optional) argument of type string that will be passed to the "SelectFunction".
    
this.SelectFunctionData null ;

    
// An optional function to be called when the user selects a thumbnail in CKFinder.
    
this.SelectThumbnailFunction selectFunction || null ;

    
// (Optional) argument of type string that will be passed to the "SelectThumbnailFunction".
    
this.SelectThumbnailFunctionData null ;

    
// If set to true, "Select thumbnail" item will not appear in the context menu.
    
this.DisableThumbnailSelection false ;

    
// The name of the CSS class rule assigned to the CKFinder frame (default = "CKFinderFrame").
    
this.ClassName null || 'CKFinderFrame' ;

    
// Resource Type and the name of the startup folder, separated with a colon (i.e. "Files:/", "Images:/cars/").
    
this.StartupPath null ;
    
    
// Used only when StartupPath is set. If set to true, the initial folder will be opened automatically on startup.
    
this.StartupFolderExpanded false ;
    
    
// If set to true, the last opened folder will be opened automatically on startup (if StartupPath is not set).
    
this.RememberLastFolder true ;
    
    
// Used to identify the CKFinder object, optional.
    // If set, the Id variable will be passed to the server connector on each request.
    // When RememberLastFolder is enabled and the "Id" is set, CKFinder will remember the last directory in a separate cookie.
    
this.Id null ;
    
    
// The server language of the connector
    
this.ConnectorLanguage 'php' ;
}

CKFinder.DEFAULT_BASEPATH '/ckfinder/' ;

CKFinder.prototype = {

    
// Renders CKFinder in the current document.
    
Create : function()
    {
        
document.writethis.CreateHtml() ) ;
    },

    
// Gets the HTML needed to create a CKFinder instance.
    
CreateHtml : function()
    {
        var 
className this.ClassName ;
        if ( 
className && className.length )
            
className ' class="' className '"' ;

        var 
id this.Id ;
        if ( 
id && id.length )
            
id ' id="' id '"' ;
            
        return 
'<iframe src="' this._BuildUrl() + '" width="' this.Width '" ' +
            
'height="' this.Height '"' className id ' frameborder="0" scrolling="no"></iframe>' ;
    },

    
// Opens CKFinder in a popup. The "width" and "height" parameters accept
    // numbers (pixels) or percent (of screen size) values.
    
Popup : function( widthheight )
    {
        
width width || '80%' ;
        
height height || '70%' ;

        if ( 
typeof width == 'string' && width.length && width.substrwidth.length 1) == '%' )
            
width parseIntwindow.screen.width parseIntwidth ) / 100 ) ;

        if ( 
typeof height == 'string' && height.length && height.substrheight.length 1) == '%' )
            
height parseIntwindow.screen.height parseIntheight ) / 100 ) ;

        if ( 
width 200 )
            
width 200 ;

        if ( 
height 200 )
            
height 200 ;

        var 
top parseInt( ( window.screen.height height ) / ) ;
        var 
left parseInt( ( window.screen.width  width ) / ) ;

        var 
options 'location=no,menubar=no,toolbar=no,dependent=yes,minimizable=no,modal=yes,alwaysRaised=yes,resizable=yes' +
            
',width='  width +
            
',height=' height +
            
',top='  top +
            
',left=' left ;

        var 
popupWindow window.open'''CKFinderPopup'optionstrue ) ;

        
// Blocked by a popup blocker.
        
if ( !popupWindow )
            return 
false ;

        try
        {
            
popupWindow.moveTolefttop ) ;
            
popupWindow.resizeTowidthheight ) ;
            
popupWindow.focus() ;
            
popupWindow.location.href this._BuildUrl() ;
        }
        catch (
e)
        {
            
popupWindow window.openthis._BuildUrl(), 'CKFinderPopup'optionstrue ) ;
        }

        return 
true ;
    },

    
_BuildUrl : function( url )
    {
        var 
url url || this.BasePath ;
        var 
qs "" ;

        if ( !
url || url.length == )
            
url CKFinder.DEFAULT_BASEPATH ;

        if ( 
url.substrurl.length 1) != '/' )
            
url url '/' ;

        
url += 'ckfinder.html' ;

        if ( 
this.SelectFunction )
        {
            var 
functionName this.SelectFunction ;
            if ( 
typeof functionName == 'function' )
                
functionName functionName.toString().match( /function ([^(]+)/ )[1] ;

            
qs += '?action=js&amp;func=' functionName ;
        }

        if ( 
this.SelectFunctionData )
        {
            
qs += qs '&amp;' '?' ;
            
qs += 'data=' encodeURIComponentthis.SelectFunctionData ) ;
        }

        if ( 
this.DisableThumbnailSelection )
        {
            
qs += qs "&amp;" "?" ;
            
qs += 'dts=1' ;
        }
        else if ( 
this.SelectThumbnailFunction || this.SelectFunction )
        {
            var 
functionName this.SelectThumbnailFunction || this.SelectFunction ;
            if ( 
typeof functionName == 'function' )
                
functionName functionName.toString().match( /function ([^(]+)/ )[1] ;

            
qs += qs "&amp;" "?" ;
            
qs += 'thumbFunc=' functionName ;
            
            if ( 
this.SelectThumbnailFunctionData )
                
qs += '&amp;tdata=' encodeURIComponentthis.SelectThumbnailFunctionData ) ;
            else if ( !
this.SelectThumbnailFunction && this.SelectFunctionData )
                
qs += '&amp;tdata=' encodeURIComponentthis.SelectFunctionData ) ;
        }

        if ( 
this.StartupPath )
        {
            
qs += qs "&amp;" "?" ;
            
qs += "start=" encodeURIComponentthis.StartupPath + ( this.StartupFolderExpanded ':1' ':0' ) ) ;
        }

        if ( !
this.RememberLastFolder )
        {
            
qs += qs "&amp;" "?" ;
            
qs += "rlf=0" ;
        }

        if ( 
this.Id )
        {
            
qs += qs "&amp;" "?" ;
            
qs += "id=" encodeURIComponentthis.Id ) ;
        }
        
        return 
url qs ;
    }

} ;

// Static "Create".
// Accepts four arguments to set the most basic properties of CKFinder.
// Example:    
//         CKFinder.Create( '/ckfinder/', '100%', 400 ) ;
// It is possible to pass an object with selected properties as the only argument.
// Example:
//        CKFinder.Create( { BasePath : '/ckfinder/', Height : '400' } ) ;
CKFinder.Create = function( basePathwidthheightselectFunction )
{
    var 
ckfinder ;
    
    if ( 
basePath != null && typeofbasePath ) == 'object' )
    {
        
ckfinder = new CKFinder( ) ;
        for ( var 
_property in basePath )
            
ckfinder[_property] = basePath[_property] ;
    }
    else
        
ckfinder = new CKFinderbasePathwidthheightselectFunction ) ;

    
ckfinder.Create() ;
}

// Static "Popup".
// Accepts four arguments to set the most basic properties of CKFinder.
// Example:    
//        CKFinder.Popup( '/ckfinder/', '100%', 400 ) ;
// It is possible to pass an object with selected properties as the only argument.
// Example:
//        CKFinder.Popup( { BasePath : '/ckfinder/', Height : '400' } ) ;
CKFinder.Popup = function( basePathwidthheightselectFunction )
{
    var 
ckfinder ;
    
    if ( 
basePath != null && typeofbasePath ) == 'object' )
    {
        
ckfinder = new CKFinder( ) ;
        for ( var 
_property in basePath )
            
ckfinder[_property] = basePath[_property] ;
    }
    else
        
ckfinder = new CKFinderbasePathwidthheightselectFunction ) ;

    
ckfinder.Popupwidthheight ) ;
}

// Static "SetupFCKeditor".
// It is possible to pass an object with selected properties as a second argument.
CKFinder.SetupFCKeditor = function( editorObjbasePathimageTypeflashType )
{
    var 
ckfinder ;

    if ( 
basePath != null && typeofbasePath ) == 'object' )
    {
        
ckfinder = new CKFinder( ) ;
        for ( var 
_property in basePath )
        {
            
ckfinder[_property] = basePath[_property] ;
            
            if ( 
_property == 'Width' )
            {
                var 
width ckfinder[_property] || 800 ;
                if ( 
typeof width == 'string' && width.length && width.substrwidth.length 1) == '%' )
                    
width parseIntwindow.screen.width parseIntwidth ) / 100 ) ;

                
editorObj.Config['LinkBrowserWindowWidth'] = width ;
                
editorObj.Config['ImageBrowserWindowWidth'] = width ;
                
editorObj.Config['FlashBrowserWindowWidth'] = width ;
            }
            else if ( 
_property == 'Height' )
            {
                var 
height ckfinder[_property] || 600 ;
                if ( 
typeof height == 'string' && height.length && height.substrheight.length 1) == '%' )
                    
height parseIntwindow.screen.height parseIntheight ) / 100 ) ;

                
editorObj.Config['LinkBrowserWindowHeight'] = height ;
                
editorObj.Config['ImageBrowserWindowHeight'] = height ;
                
editorObj.Config['FlashBrowserWindowHeight'] = height ;
            }
        }
    }
    else
        
ckfinder = new CKFinderbasePath ) ;

    var 
url ckfinder.BasePath ;

    
// If it is a path relative to the current page.
    
if ( url.substr0) != '/' )
        
url document.location.pathname.substring0document.location.pathname.lastIndexOf('/') + ) + url ;

    
url ckfinder._BuildUrlurl ) ;
    var 
qs = ( url.indexOf"?" ) !== -) ? "&amp;" "?" ;

    
editorObj.Config['LinkBrowserURL'] = url ;
    
editorObj.Config['ImageBrowserURL'] = url qs 'type=' + ( imageType || 'Images' ) ;
    
editorObj.Config['FlashBrowserURL'] = url qs 'type=' + ( flashType || 'Flash' ) ;

    var 
dir url.substring(0url.lastIndexOf("/"));
    
editorObj.Config['LinkUploadURL'] = dir "core/connector/" ckfinder.ConnectorLanguage "/connector." 
        
ckfinder.ConnectorLanguage "?command=QuickUpload&type=Files" ;
    
editorObj.Config['ImageUploadURL'] = dir "core/connector/" ckfinder.ConnectorLanguage "/connector." 
        
ckfinder.ConnectorLanguage "?command=QuickUpload&type=" + ( imageType || 'Images' ) ;
    
editorObj.Config['FlashUploadURL'] = dir "core/connector/" ckfinder.ConnectorLanguage "/connector." 
        
ckfinder.ConnectorLanguage "?command=QuickUpload&type=" + ( flashType || 'Flash' ) ;
}
?>
Онлайн: 1
Реклама