Вход Регистрация
Файл: public/js/3rd_party/ckeditor/plugins/adobeair/plugin.js
Строк: 298
<?php

/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/

(function()
{
    var 
eventNameList = [ 'click''keydown''mousedown''keypress''mouseover''mouseout' ];

    
// Inline event callbacks assigned via innerHTML/outerHTML, such as
    // onclick/onmouseover, are ignored in AIR.
    // Use DOM2 event listeners to substitue inline handlers instead.
    
function convertInlineHandlerscontainer )
    {
        
// TODO: document.querySelectorAll is not supported in AIR.
        
var children container.getElementsByTag'*' ),
            
count children.count(),
            
child;

        for ( var 
0counti++ )
        {
            
child children.getItem);

            (function( 
node )
            {
                for ( var 
0eventNameList.lengthj++ )
                {
                    (function( 
eventName )
                    {
                        var 
inlineEventHandler node.getAttribute'on' eventName );
                        if ( 
node.hasAttribute'on' eventName ) )
                        {
                            
node.removeAttribute'on' eventName );
                            
node.oneventName, function( evt )
                            {
                                var 
callFunc = /(returns*)?CKEDITOR.tools.callFunction(([^)]+))/.execinlineEventHandler ),
                                    
hasReturn callFunc && callFunc],
                                    
callFuncArgs callFunc &&  callFunc].split',' ),
                                    
preventDefault = /return false;/.testinlineEventHandler );

                                if ( 
callFuncArgs )
                                {
                                    var 
nums callFuncArgs.length,
                                        
argName;

                                    for ( var 
0numsi++ )
                                    {
                                        
// Trim spaces around param.
                                        
callFuncArgs] = argName CKEDITOR.tools.trimcallFuncArgs] );

                                        
// String form param.
                                        
var strPattern argName.match( /^(["'])([^"']*?)1$/ );
                                        if ( strPattern )
                                        {
                                            callFuncArgs[ i ] = strPattern[ 2 ];
                                            continue;
                                        }

                                        // Integer form param.
                                        if ( argName.match( /d+/ ) )
                                        {
                                            callFuncArgs[ i ] = parseInt( argName, 10 );
                                            continue;
                                        }

                                        // Speical variables.
                                        switch( argName )
                                        {
                                            case '
this' :
                                                callFuncArgs[ i ] = node.$;
                                                break;
                                            case '
event' :
                                                callFuncArgs[ i ] = evt.data.$;
                                                break;
                                            case '
null' :
                                                callFuncArgs [ i ] = null;
                                                break;
                                        }
                                    }

                                    var retval = CKEDITOR.tools.callFunction.apply( window, callFuncArgs );
                                    if ( hasReturn && retval === false )
                                         preventDefault = 1;
                                }

                                if ( preventDefault )
                                    evt.data.preventDefault();
                            });
                        }
                    })( eventNameList[ j ] );
                }
            })( child );
        }
    }

    CKEDITOR.plugins.add( '
adobeair',
    {
        init : function( editor )
        {
            if ( !CKEDITOR.env.air )
                return;

            // Body doesn'
t get default margin on AIR.
            
editor.addCss'body { padding: 8px }' );

            
editor.on'uiReady', function()
                {
                    
convertInlineHandlerseditor.container );

                    if ( 
editor.sharedSpaces )
                    {
                        for ( var 
space in editor.sharedSpaces )
                            
convertInlineHandlerseditor.sharedSpacesspace ] );
                    }

                    
editor.on'elementsPathUpdate', function( evt ) { convertInlineHandlersevt.data.space ); } );
                });

            
editor.on'contentDom', function()
                {
                    
// Hyperlinks are enabled in editable documents in Adobe
                    // AIR. Prevent their click behavior.
                    
editor.document.on'click', function( ev )
                        {
                            
ev.data.preventDefaulttrue );
                        });
                });
        }
    });

    
CKEDITOR.ui.on'ready', function( evt )
        {
            var 
ui evt.data;
            
// richcombo, panelbutton and menu
            
if ( ui._.panel )
            {
                var 
panel ui._.panel._.panel,
                        
holder;

                ( function()
                {
                    
// Adding dom event listeners off-line are not supported in AIR,
                    // waiting for panel iframe loaded.
                    
if ( !panel.isLoaded )
                    {
                        
setTimeoutarguments.callee30 );
                        return;
                    }
                    
holder panel._.holder;
                    
convertInlineHandlersholder );
                })();
            }
            else if ( 
ui instanceof CKEDITOR.dialog )
                
convertInlineHandlersui._.element );
        });
})();

CKEDITOR.dom.document.prototype.write CKEDITOR.tools.overrideCKEDITOR.dom.document.prototype.write,
    function( 
original_write )
    {
        function 
appendElementparenttagNamefullTagtext )
        {
            var 
node parent.appendtagName ),
                
attrs CKEDITOR.htmlParser.fragment.fromHtmlfullTag ).children].attributes;
            
attrs && node.setAttributesattrs );
            
text && node.appendparent.getDocument().createTexttext ) );
        }

        return function( 
htmlmode )
            {
                
// document.write() or document.writeln() fail silently after
                // the page load event in Adobe AIR.
                // DOM manipulation could be used instead.
                
if ( this.getBody() )
                {
                    
// We're taking the below extra work only because innerHTML
                    // on <html> element doesn't work as expected.
                    
var doc this,
                        
head this.getHead();

                    
// Create style nodes for inline css. ( <style> content doesn't applied when setting via innerHTML )
                    
html html.replace( /(<style[^>]*>)([sS]*?)</style>/gi,
                        function ( 
matchstartTagstyleText )
                        {
                            
appendElementhead'style'startTagstyleText );
                            return 
'';
                        });

                    
html html.replace( /<baseb[^>]*/>/i,
                        function( 
match )
                        {
                            
appendElementhead'base'match );
                            return 
'';
                        });

                    
html html.replace( /<title>([sS]*)</title>/i,
                        function( 
matchtitle )
                        {
                            
doc.$.title title;
                            return 
'';
                        });

                    
// Move the rest of head stuff.
                    
html html.replace( /<head>([sS]*)</head>/i,
                        function( 
headHtml )
                        {
                            
// Inject the <head> HTML inside a <div>.
                            // Do that before getDocumentHead because WebKit moves
                            // <link css> elements to the <head> at this point.
                            
var div = new CKEDITOR.dom.element'div'doc );
                            
div.setHtmlheadHtml );
                            
// Move the <div> nodes to <head>.
                            
div.moveChildrenhead );
                            return 
'';
                        });

                    
html.replace( /(<body[^>]*>)([sS]*)(?=$|</body>)/i,
                        function( 
matchstartTaginnerHTML )
                        {
                            
doc.getBody().setHtmlinnerHTML );
                            var 
attrs CKEDITOR.htmlParser.fragment.fromHtmlstartTag ).children].attributes;
                            
attrs && doc.getBody().setAttributesattrs );
                        });
                }
                else
                    
original_write.applythisarguments );
            };
    });
?>
Онлайн: 0
Реклама