/** * @license Copyright (c) 2003-2013, 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 convertInlineHandlers( container ) { // TODO: document.querySelectorAll is not supported in AIR. var children = container.getElementsByTag( '*' ), count = children.count(), child; for ( var i = 0; i < count; i++ ) { child = children.getItem( i ); (function( node ) { for ( var j = 0; j < eventNameList.length; j++ ) { (function( eventName ) { var inlineEventHandler = node.getAttribute( 'on' + eventName ); if ( node.hasAttribute( 'on' + eventName ) ) { node.removeAttribute( 'on' + eventName ); node.on( eventName, function( evt ) { var callFunc = /(return\s*)?CKEDITOR\.tools\.callFunction\(([^)]+)\)/.exec( inlineEventHandler ), hasReturn = callFunc && callFunc[ 1 ], callFuncArgs = callFunc && callFunc[ 2 ].split( ',' ), preventDefault = /return false;/.test( inlineEventHandler ); if ( callFuncArgs ) { var nums = callFuncArgs.length, argName; for ( var i = 0; i < nums; i++ ) { // Trim spaces around param. callFuncArgs[ i ] = argName = CKEDITOR.tools.trim( callFuncArgs[ i ] ); // 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', { onLoad: function() { if ( !CKEDITOR.env.air ) return; CKEDITOR.dom.document.prototype.write = CKEDITOR.tools.override( CKEDITOR.dom.document.prototype.write, function( original_write ) { function appendElement( parent, tagName, fullTag, text ) { var node = parent.append( tagName ), attrs = CKEDITOR.htmlParser.fragment.fromHtml( fullTag ).children[ 0 ].attributes; attrs && node.setAttributes( attrs ); text && node.append( parent.getDocument().createText( text ) ); } return function( html, mode ) { // 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 element doesn't work as expected. var doc = this, head = this.getHead(); // Create style nodes for inline css. (