namibia
df0489e1eeeeab5a9bd44e1d84fce49924fe1bac
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
/* 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 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', { 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() { convertInlineHandlers( editor.container ); if ( editor.sharedSpaces ) { for ( var space in editor.sharedSpaces ) convertInlineHandlers( editor.sharedSpaces[ space ] ); } editor.on( 'elementsPathUpdate', function( evt ) { convertInlineHandlers( evt.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.preventDefault( true ); }); }); } }); 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 ) { setTimeout( arguments.callee, 30 ); return; } holder = panel._.holder; convertInlineHandlers( holder ); })(); } else if ( ui instanceof CKEDITOR.dialog ) convertInlineHandlers( ui._.element ); }); })(); 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 <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[^>]*>)([\s\S]*?)<\/style>/gi, function ( match, startTag, styleText ) { appendElement( head, 'style', startTag, styleText ); return ''; }); html = html.replace( /<base\b[^>]*\/>/i, function( match ) { appendElement( head, 'base', match ); return ''; }); html = html.replace( /<title>([\s\S]*)<\/title>/i, function( match, title ) { doc.$.title = title; return ''; }); // Move the rest of head stuff. html = html.replace( /<head>([\s\S]*)<\/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.setHtml( headHtml ); // Move the <div> nodes to <head>. div.moveChildren( head ); return ''; }); html.replace( /(<body[^>]*>)([\s\S]*)(?=$|<\/body>)/i, function( match, startTag, innerHTML ) { doc.getBody().setHtml( innerHTML ); var attrs = CKEDITOR.htmlParser.fragment.fromHtml( startTag ).children[ 0 ].attributes; attrs && doc.getBody().setAttributes( attrs ); }); } else original_write.apply( this, arguments ); }; }); |
Commits for namibiapublic/scripts/ckeditor/_source/plugins/adobeair/plugin.js
Revision | Author | Commited | Message |
---|---|---|---|
df0489 ... | Mark | Fri 14 Oct, 2016 10:01:00 +0000 | initial commit |