Commit b72907b3 authored by Frank Bergmann's avatar Frank Bergmann

- OpenACS 5.9

parent 7a80df63
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* @fileOverview jQuery adapter provides easy use of basic CKEditor functions
* and access to internal API. It also integrates some aspects of CKEditor with
* jQuery framework.
*
* Every TEXTAREA, DIV and P elements can be converted to working editor.
*
* Plugin exposes some of editor's event to jQuery event system. All of those are namespaces inside
* ".ckeditor" namespace and can be binded/listened on supported textarea, div and p nodes.
*
* Available jQuery events:
* - instanceReady.ckeditor( editor, rootNode )
* Triggered when new instance is ready.
* - destroy.ckeditor( editor )
* Triggered when instance is destroyed.
* - getData.ckeditor( editor, eventData )
* Triggered when getData event is fired inside editor. It can change returned data using eventData reference.
* - setData.ckeditor( editor )
* Triggered when getData event is fired inside editor.
*
* @example
* <script src="jquery.js"></script>
* <script src="ckeditor.js"></script>
* <script src="adapters/jquery/adapter.js"></script>
*/
(function()
{
/**
* Allows CKEditor to override jQuery.fn.val(), making it possible to use the val()
* function on textareas, as usual, having it synchronized with CKEditor.<br>
* <br>
* This configuration option is global and executed during the jQuery Adapter loading.
* It can't be customized across editor instances.
* @type Boolean
* @example
* &lt;script&gt;
* CKEDITOR.config.jqueryOverrideVal = true;
* &lt;/script&gt;
* &lt;!-- Important: The JQuery adapter is loaded *after* setting jqueryOverrideVal --&gt;
* &lt;script src="/ckeditor/adapters/jquery.js"&gt;&lt;/script&gt;
* @example
* // ... then later in the code ...
*
* $( 'textarea' ).ckeditor();
* // ...
* $( 'textarea' ).val( 'New content' );
*/
CKEDITOR.config.jqueryOverrideVal = typeof CKEDITOR.config.jqueryOverrideVal == 'undefined'
? true : CKEDITOR.config.jqueryOverrideVal;
var jQuery = window.jQuery;
if ( typeof jQuery == 'undefined' )
return;
// jQuery object methods.
jQuery.extend( jQuery.fn,
/** @lends jQuery.fn */
{
/**
* Return existing CKEditor instance for first matched element.
* Allows to easily use internal API. Doesn't return jQuery object.
*
* Raised exception if editor doesn't exist or isn't ready yet.
*
* @name jQuery.ckeditorGet
* @return CKEDITOR.editor
* @see CKEDITOR.editor
*/
ckeditorGet: function()
{
var instance = this.eq( 0 ).data( 'ckeditorInstance' );
if ( !instance )
throw "CKEditor not yet initialized, use ckeditor() with callback.";
return instance;
},
/**
* Triggers creation of CKEditor in all matched elements (reduced to DIV, P and TEXTAREAs).
* Binds callback to instanceReady event of all instances. If editor is already created, than
* callback is fired right away.
*
* Mixed parameter order allowed.
*
* @param callback Function to be run on editor instance. Passed parameters: [ textarea ].
* Callback is fiered in "this" scope being ckeditor instance and having source textarea as first param.
*
* @param config Configuration options for new instance(s) if not already created.
* See URL
*
* @example
* $( 'textarea' ).ckeditor( function( textarea ) {
* $( textarea ).val( this.getData() )
* } );
*
* @name jQuery.fn.ckeditor
* @return jQuery.fn
*/
ckeditor: function( callback, config )
{
if ( !CKEDITOR.env.isCompatible )
return this;
if ( !jQuery.isFunction( callback ))
{
var tmp = config;
config = callback;
callback = tmp;
}
config = config || {};
this.filter( 'textarea, div, p' ).each( function()
{
var $element = jQuery( this ),
editor = $element.data( 'ckeditorInstance' ),
instanceLock = $element.data( '_ckeditorInstanceLock' ),
element = this;
if ( editor && !instanceLock )
{
if ( callback )
callback.apply( editor, [ this ] );
}
else if ( !instanceLock )
{
// CREATE NEW INSTANCE
// Handle config.autoUpdateElement inside this plugin if desired.
if ( config.autoUpdateElement
|| ( typeof config.autoUpdateElement == 'undefined' && CKEDITOR.config.autoUpdateElement ) )
{
config.autoUpdateElementJquery = true;
}
// Always disable config.autoUpdateElement.
config.autoUpdateElement = false;
$element.data( '_ckeditorInstanceLock', true );
// Set instance reference in element's data.
editor = CKEDITOR.replace( element, config );
$element.data( 'ckeditorInstance', editor );
// Register callback.
editor.on( 'instanceReady', function( event )
{
var editor = event.editor;
setTimeout( function()
{
// Delay bit more if editor is still not ready.
if ( !editor.element )
{
setTimeout( arguments.callee, 100 );
return;
}
// Remove this listener.
event.removeListener( 'instanceReady', this.callee );
// Forward setData on dataReady.
editor.on( 'dataReady', function()
{
$element.trigger( 'setData' + '.ckeditor', [ editor ] );
});
// Forward getData.
editor.on( 'getData', function( event ) {
$element.trigger( 'getData' + '.ckeditor', [ editor, event.data ] );
}, 999 );
// Forward destroy event.
editor.on( 'destroy', function()
{
$element.trigger( 'destroy.ckeditor', [ editor ] );
});
// Integrate with form submit.
if ( editor.config.autoUpdateElementJquery && $element.is( 'textarea' ) && $element.parents( 'form' ).length )
{
var onSubmit = function()
{
$element.ckeditor( function()
{
editor.updateElement();
});
};
// Bind to submit event.
$element.parents( 'form' ).submit( onSubmit );
// Bind to form-pre-serialize from jQuery Forms plugin.
$element.parents( 'form' ).bind( 'form-pre-serialize', onSubmit );
// Unbind when editor destroyed.
$element.bind( 'destroy.ckeditor', function()
{
$element.parents( 'form' ).unbind( 'submit', onSubmit );
$element.parents( 'form' ).unbind( 'form-pre-serialize', onSubmit );
});
}
// Garbage collect on destroy.
editor.on( 'destroy', function()
{
$element.data( 'ckeditorInstance', null );
});
// Remove lock.
$element.data( '_ckeditorInstanceLock', null );
// Fire instanceReady event.
$element.trigger( 'instanceReady.ckeditor', [ editor ] );
// Run given (first) code.
if ( callback )
callback.apply( editor, [ element ] );
}, 0 );
}, null, null, 9999);
}
else
{
// Editor is already during creation process, bind our code to the event.
CKEDITOR.on( 'instanceReady', function( event )
{
var editor = event.editor;
setTimeout( function()
{
// Delay bit more if editor is still not ready.
if ( !editor.element )
{
setTimeout( arguments.callee, 100 );
return;
}
if ( editor.element.$ == element )
{
// Run given code.
if ( callback )
callback.apply( editor, [ element ] );
}
}, 0 );
}, null, null, 9999);
}
});
return this;
}
});
// New val() method for objects.
if ( CKEDITOR.config.jqueryOverrideVal )
{
jQuery.fn.val = CKEDITOR.tools.override( jQuery.fn.val, function( oldValMethod )
{
/**
* CKEditor-aware val() method.
*
* Acts same as original jQuery val(), but for textareas which have CKEditor instances binded to them, method
* returns editor's content. It also works for settings values.
*
* @param oldValMethod
* @name jQuery.fn.val
*/
return function( newValue, forceNative )
{
var isSetter = typeof newValue != 'undefined',
result;
this.each( function()
{
var $this = jQuery( this ),
editor = $this.data( 'ckeditorInstance' );
if ( !forceNative && $this.is( 'textarea' ) && editor )
{
if ( isSetter )
editor.setData( newValue );
else
{
result = editor.getData();
// break;
return null;
}
}
else
{
if ( isSetter )
oldValMethod.call( $this, newValue );
else
{
result = oldValMethod.call( $this );
// break;
return null;
}
}
return true;
});
return isSetter ? this : result;
};
});
}
})();
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* @fileOverview Defines the {@link CKEDITOR.dom.comment} class, which represents
* a DOM comment node.
*/
CKEDITOR.dom.comment = CKEDITOR.tools.createClass(
{
base : CKEDITOR.dom.node,
$ : function( text, ownerDocument )
{
if ( typeof text == 'string' )
text = ( ownerDocument ? ownerDocument.$ : document ).createComment( text );
this.base( text );
},
proto :
{
type : CKEDITOR.NODE_COMMENT,
getOuterHtml : function()
{
return '<!--' + this.$.nodeValue + '-->';
}
}
});
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* @fileOverview Defines the {@link CKEDITOR.dom.document} class, which
* represents a DOM document.
*/
/**
* Represents a DOM document.
* @constructor
* @augments CKEDITOR.dom.domObject
* @param {Object} domDocument A native DOM document.
* @example
* var document = new CKEDITOR.dom.document( document );
*/
CKEDITOR.dom.document = function( domDocument )
{
CKEDITOR.dom.domObject.call( this, domDocument );
};
// PACKAGER_RENAME( CKEDITOR.dom.document )
CKEDITOR.dom.document.prototype = new CKEDITOR.dom.domObject();
CKEDITOR.tools.extend( CKEDITOR.dom.document.prototype,
/** @lends CKEDITOR.dom.document.prototype */
{
/**
* Appends a CSS file to the document.
* @param {String} cssFileUrl The CSS file URL.
* @example
* <b>CKEDITOR.document.appendStyleSheet( '/mystyles.css' )</b>;
*/
appendStyleSheet : function( cssFileUrl )
{
if ( this.$.createStyleSheet )
this.$.createStyleSheet( cssFileUrl );
else
{
var link = new CKEDITOR.dom.element( 'link' );
link.setAttributes(
{
rel :'stylesheet',
type : 'text/css',
href : cssFileUrl
});
this.getHead().append( link );
}
},
appendStyleText : function( cssStyleText )
{
if ( this.$.createStyleSheet )
{
var styleSheet = this.$.createStyleSheet( "" );
styleSheet.cssText = cssStyleText ;
}
else
{
var style = new CKEDITOR.dom.element( 'style', this );
style.append( new CKEDITOR.dom.text( cssStyleText, this ) );
this.getHead().append( style );
}
},
createElement : function( name, attribsAndStyles )
{
var element = new CKEDITOR.dom.element( name, this );
if ( attribsAndStyles )
{
if ( attribsAndStyles.attributes )
element.setAttributes( attribsAndStyles.attributes );
if ( attribsAndStyles.styles )
element.setStyles( attribsAndStyles.styles );
}
return element;
},
createText : function( text )
{
return new CKEDITOR.dom.text( text, this );
},
focus : function()
{
this.getWindow().focus();
},
/**
* Gets and element based on its id.
* @param {String} elementId The element id.
* @returns {CKEDITOR.dom.element} The element instance, or null if not found.
* @example
* var element = <b>CKEDITOR.document.getById( 'myElement' )</b>;
* alert( element.getId() ); // "myElement"
*/
getById : function( elementId )
{
var $ = this.$.getElementById( elementId );
return $ ? new CKEDITOR.dom.element( $ ) : null;
},
getByAddress : function( address, normalized )
{
var $ = this.$.documentElement;
for ( var i = 0 ; $ && i < address.length ; i++ )
{
var target = address[ i ];
if ( !normalized )
{
$ = $.childNodes[ target ];
continue;
}
var currentIndex = -1;
for (var j = 0 ; j < $.childNodes.length ; j++ )
{
var candidate = $.childNodes[ j ];
if ( normalized === true &&
candidate.nodeType == 3 &&
candidate.previousSibling &&
candidate.previousSibling.nodeType == 3 )
{
continue;
}
currentIndex++;
if ( currentIndex == target )
{
$ = candidate;
break;
}
}
}
return $ ? new CKEDITOR.dom.node( $ ) : null;
},
getElementsByTag : function( tagName, namespace )
{
if ( !( CKEDITOR.env.ie && ! ( document.documentMode > 8 ) ) && namespace )
tagName = namespace + ':' + tagName;
return new CKEDITOR.dom.nodeList( this.$.getElementsByTagName( tagName ) );
},
/**
* Gets the &lt;head&gt; element for this document.
* @returns {CKEDITOR.dom.element} The &lt;head&gt; element.
* @example
* var element = <b>CKEDITOR.document.getHead()</b>;
* alert( element.getName() ); // "head"
*/
getHead : function()
{
var head = this.$.getElementsByTagName( 'head' )[0];
if ( !head )
head = this.getDocumentElement().append( new CKEDITOR.dom.element( 'head' ), true );
else
head = new CKEDITOR.dom.element( head );
return (
this.getHead = function()
{
return head;
})();
},
/**
* Gets the &lt;body&gt; element for this document.
* @returns {CKEDITOR.dom.element} The &lt;body&gt; element.
* @example
* var element = <b>CKEDITOR.document.getBody()</b>;
* alert( element.getName() ); // "body"
*/
getBody : function()
{
var body = new CKEDITOR.dom.element( this.$.body );
return (
this.getBody = function()
{
return body;
})();
},
/**
* Gets the DOM document element for this document.
* @returns {CKEDITOR.dom.element} The DOM document element.
*/
getDocumentElement : function()
{
var documentElement = new CKEDITOR.dom.element( this.$.documentElement );
return (
this.getDocumentElement = function()
{
return documentElement;
})();
},
/**
* Gets the window object that holds this document.
* @returns {CKEDITOR.dom.window} The window object.
*/
getWindow : function()
{
var win = new CKEDITOR.dom.window( this.$.parentWindow || this.$.defaultView );
return (
this.getWindow = function()
{
return win;
})();
},
/**
* Defines the document contents through document.write. Note that the
* previous document contents will be lost (cleaned).
* @since 3.5
* @param {String} html The HTML defining the document contents.
* @example
* document.write(
* '&lt;html&gt;' +
* '&lt;head&gt;&lt;title&gt;Sample Doc&lt;/title&gt;&lt;/head&gt;' +
* '&lt;body&gt;Document contents created by code&lt;/body&gt;' +
* '&lt;/html&gt;' );
*/
write : function( html )
{
// Don't leave any history log in IE. (#5657)
this.$.open( 'text/html', 'replace' );
// Support for custom document.domain in IE.
CKEDITOR.env.isCustomDomain() && ( this.$.domain = document.domain );
this.$.write( html );
this.$.close();
}
});
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* @class DocumentFragment is a "lightweight" or "minimal" Document object. It is
* commonly used to extract a portion of a document's tree or to create a new
* fragment of a document. Various operations may take DocumentFragment objects
* as arguments and results in all the child nodes of the DocumentFragment being
* moved to the child list of this node.
* @param {Object} ownerDocument
*/
CKEDITOR.dom.documentFragment = function( ownerDocument )
{
ownerDocument = ownerDocument || CKEDITOR.document;
this.$ = ownerDocument.$.createDocumentFragment();
};
CKEDITOR.tools.extend( CKEDITOR.dom.documentFragment.prototype,
CKEDITOR.dom.element.prototype,
{
type : CKEDITOR.NODE_DOCUMENT_FRAGMENT,
insertAfterNode : function( node )
{
node = node.$;
node.parentNode.insertBefore( this.$, node.nextSibling );
}
},
true,
{
'append' : 1,
'appendBogus' : 1,
'getFirst' : 1,
'getLast' : 1,
'appendTo' : 1,
'moveChildren' : 1,
'insertBefore' : 1,
'insertAfterNode' : 1,
'replace' : 1,
'trim' : 1,
'type' : 1,
'ltrim' : 1,
'rtrim' : 1,
'getDocument' : 1,
'getChildCount' : 1,
'getChild' : 1,
'getChildren' : 1
} );
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* @fileOverview Defines the {@link CKEDITOR.editor} class, which is the base
* for other classes representing DOM objects.
*/
/**
* Represents a DOM object. This class is not intended to be used directly. It
* serves as the base class for other classes representing specific DOM
* objects.
* @constructor
* @param {Object} nativeDomObject A native DOM object.
* @augments CKEDITOR.event
* @example
*/
CKEDITOR.dom.domObject = function( nativeDomObject )
{
if ( nativeDomObject )
{
/**
* The native DOM object represented by this class instance.
* @type Object
* @example
* var element = new CKEDITOR.dom.element( 'span' );
* alert( element.$.nodeType ); // "1"
*/
this.$ = nativeDomObject;
}
};
CKEDITOR.dom.domObject.prototype = (function()
{
// Do not define other local variables here. We want to keep the native
// listener closures as clean as possible.
var getNativeListener = function( domObject, eventName )
{
return function( domEvent )
{
// In FF, when reloading the page with the editor focused, it may
// throw an error because the CKEDITOR global is not anymore
// available. So, we check it here first. (#2923)
if ( typeof CKEDITOR != 'undefined' )
domObject.fire( eventName, new CKEDITOR.dom.event( domEvent ) );
};
};
return /** @lends CKEDITOR.dom.domObject.prototype */ {
getPrivate : function()
{
var priv;
// Get the main private function from the custom data. Create it if not
// defined.
if ( !( priv = this.getCustomData( '_' ) ) )
this.setCustomData( '_', ( priv = {} ) );
return priv;
},
/** @ignore */
on : function( eventName )
{
// We customize the "on" function here. The basic idea is that we'll have
// only one listener for a native event, which will then call all listeners
// set to the event.
// Get the listeners holder object.
var nativeListeners = this.getCustomData( '_cke_nativeListeners' );
if ( !nativeListeners )
{
nativeListeners = {};
this.setCustomData( '_cke_nativeListeners', nativeListeners );
}
// Check if we have a listener for that event.
if ( !nativeListeners[ eventName ] )
{
var listener = nativeListeners[ eventName ] = getNativeListener( this, eventName );
if ( this.$.attachEvent )
this.$.attachEvent( 'on' + eventName, listener );
else if ( this.$.addEventListener )
this.$.addEventListener( eventName, listener, !!CKEDITOR.event.useCapture );
}
// Call the original implementation.
return CKEDITOR.event.prototype.on.apply( this, arguments );
},
/** @ignore */
removeListener : function( eventName )
{
// Call the original implementation.
CKEDITOR.event.prototype.removeListener.apply( this, arguments );
// If we don't have listeners for this event, clean the DOM up.
if ( !this.hasListeners( eventName ) )
{
var nativeListeners = this.getCustomData( '_cke_nativeListeners' );
var listener = nativeListeners && nativeListeners[ eventName ];
if ( listener )
{
if ( this.$.detachEvent )
this.$.detachEvent( 'on' + eventName, listener );
else if ( this.$.removeEventListener )
this.$.removeEventListener( eventName, listener, false );
delete nativeListeners[ eventName ];
}
}
},
/**
* Removes any listener set on this object.
* To avoid memory leaks we must assure that there are no
* references left after the object is no longer needed.
*/
removeAllListeners : function()
{
var nativeListeners = this.getCustomData( '_cke_nativeListeners' );
for ( var eventName in nativeListeners )
{
var listener = nativeListeners[ eventName ];
if ( this.$.detachEvent )
this.$.detachEvent( 'on' + eventName, listener );
else if ( this.$.removeEventListener )
this.$.removeEventListener( eventName, listener, false );
delete nativeListeners[ eventName ];
}
}
};
})();
(function( domObjectProto )
{
var customData = {};
CKEDITOR.on( 'reset', function()
{
customData = {};
});
/**
* Determines whether the specified object is equal to the current object.
* @name CKEDITOR.dom.domObject.prototype.equals
* @function
* @param {Object} object The object to compare with the current object.
* @returns {Boolean} "true" if the object is equal.
* @example
* var doc = new CKEDITOR.dom.document( document );
* alert( doc.equals( CKEDITOR.document ) ); // "true"
* alert( doc == CKEDITOR.document ); // "false"
*/
domObjectProto.equals = function( object )
{
return ( object && object.$ === this.$ );
};
/**
* Sets a data slot value for this object. These values are shared by all
* instances pointing to that same DOM object.
* <strong>Note:</strong> The created data slot is only guarantied to be available on this unique dom node,
* thus any wish to continue access it from other element clones (either created by clone node or from innerHtml)
* will fail, for such usage, please use {@link CKEDITOR.dom.element::setAttribute} instead.
* @name CKEDITOR.dom.domObject.prototype.setCustomData
* @function
* @param {String} key A key used to identify the data slot.
* @param {Object} value The value to set to the data slot.
* @returns {CKEDITOR.dom.domObject} This DOM object instance.
* @see CKEDITOR.dom.domObject.prototype.getCustomData
* @example
* var element = new CKEDITOR.dom.element( 'span' );
* element.setCustomData( 'hasCustomData', true );
*/
domObjectProto.setCustomData = function( key, value )
{
var expandoNumber = this.getUniqueId(),
dataSlot = customData[ expandoNumber ] || ( customData[ expandoNumber ] = {} );
dataSlot[ key ] = value;
return this;
};
/**
* Gets the value set to a data slot in this object.
* @name CKEDITOR.dom.domObject.prototype.getCustomData
* @function
* @param {String} key The key used to identify the data slot.
* @returns {Object} This value set to the data slot.
* @see CKEDITOR.dom.domObject.prototype.setCustomData
* @example
* var element = new CKEDITOR.dom.element( 'span' );
* alert( element.getCustomData( 'hasCustomData' ) ); // e.g. 'true'
*/
domObjectProto.getCustomData = function( key )
{
var expandoNumber = this.$[ 'data-cke-expando' ],
dataSlot = expandoNumber && customData[ expandoNumber ];
return dataSlot && dataSlot[ key ];
};
/**
* @name CKEDITOR.dom.domObject.prototype.removeCustomData
*/
domObjectProto.removeCustomData = function( key )
{
var expandoNumber = this.$[ 'data-cke-expando' ],
dataSlot = expandoNumber && customData[ expandoNumber ],
retval = dataSlot && dataSlot[ key ];
if ( typeof retval != 'undefined' )
delete dataSlot[ key ];
return retval || null;
};
/**
* Removes any data stored on this object.
* To avoid memory leaks we must assure that there are no
* references left after the object is no longer needed.
* @name CKEDITOR.dom.domObject.prototype.clearCustomData
* @function
*/
domObjectProto.clearCustomData = function()
{
// Clear all event listeners
this.removeAllListeners();
var expandoNumber = this.$[ 'data-cke-expando' ];
expandoNumber && delete customData[ expandoNumber ];
};
/**
* Gets an ID that can be used to identiquely identify this DOM object in
* the running session.
* @name CKEDITOR.dom.domObject.prototype.getUniqueId
* @function
* @returns {Number} A unique ID.
*/
domObjectProto.getUniqueId = function()
{
return this.$[ 'data-cke-expando' ] || ( this.$[ 'data-cke-expando' ] = CKEDITOR.tools.getNextNumber() );
};
// Implement CKEDITOR.event.
CKEDITOR.event.implementOn( domObjectProto );
})( CKEDITOR.dom.domObject.prototype );
This diff is collapsed.
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
(function()
{
// Elements that may be considered the "Block boundary" in an element path.
var pathBlockElements = { address:1,blockquote:1,dl:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1,li:1,dt:1,dd:1, legend:1,caption:1 };
// Elements that may be considered the "Block limit" in an element path.
var pathBlockLimitElements = { body:1,div:1,table:1,tbody:1,tr:1,td:1,th:1,form:1,fieldset:1 };
// Check if an element contains any block element.
var checkHasBlock = function( element )
{
var childNodes = element.getChildren();
for ( var i = 0, count = childNodes.count() ; i < count ; i++ )
{
var child = childNodes.getItem( i );
if ( child.type == CKEDITOR.NODE_ELEMENT && CKEDITOR.dtd.$block[ child.getName() ] )
return true;
}
return false;
};
/**
* @class
*/
CKEDITOR.dom.elementPath = function( lastNode )
{
var block = null;
var blockLimit = null;
var elements = [];
var e = lastNode;
while ( e )
{
if ( e.type == CKEDITOR.NODE_ELEMENT )
{
if ( !this.lastElement )
this.lastElement = e;
var elementName = e.getName();
if ( CKEDITOR.env.ie && e.$.scopeName != 'HTML' )
elementName = e.$.scopeName.toLowerCase() + ':' + elementName;
if ( !blockLimit )
{
if ( !block && pathBlockElements[ elementName ] )
block = e;
if ( pathBlockLimitElements[ elementName ] )
{
// DIV is considered the Block, if no block is available (#525)
// and if it doesn't contain other blocks.
if ( !block && elementName == 'div' && !checkHasBlock( e ) )
block = e;
else
blockLimit = e;
}
}
elements.push( e );
if ( elementName == 'body' )
break;
}
e = e.getParent();
}
this.block = block;
this.blockLimit = blockLimit;
this.elements = elements;
};
})();
CKEDITOR.dom.elementPath.prototype =
{
/**
* Compares this element path with another one.
* @param {CKEDITOR.dom.elementPath} otherPath The elementPath object to be
* compared with this one.
* @returns {Boolean} "true" if the paths are equal, containing the same
* number of elements and the same elements in the same order.
*/
compare : function( otherPath )
{
var thisElements = this.elements;
var otherElements = otherPath && otherPath.elements;
if ( !otherElements || thisElements.length != otherElements.length )
return false;
for ( var i = 0 ; i < thisElements.length ; i++ )
{
if ( !thisElements[ i ].equals( otherElements[ i ] ) )
return false;
}
return true;
},
contains : function( tagNames )
{
var elements = this.elements;
for ( var i = 0 ; i < elements.length ; i++ )
{
if ( elements[ i ].getName() in tagNames )
return elements[ i ];
}
return null;
}
};
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* @fileOverview Defines the {@link CKEDITOR.dom.event} class, which
* represents the a native DOM event object.
*/
/**
* Represents a native DOM event object.
* @constructor
* @param {Object} domEvent A native DOM event object.
* @example
*/
CKEDITOR.dom.event = function( domEvent )
{
/**
* The native DOM event object represented by this class instance.
* @type Object
* @example
*/
this.$ = domEvent;
};
CKEDITOR.dom.event.prototype =
{
/**
* Gets the key code associated to the event.
* @returns {Number} The key code.
* @example
* alert( event.getKey() ); "65" is "a" has been pressed
*/
getKey : function()
{
return this.$.keyCode || this.$.which;
},
/**
* Gets a number represeting the combination of the keys pressed during the
* event. It is the sum with the current key code and the {@link CKEDITOR.CTRL},
* {@link CKEDITOR.SHIFT} and {@link CKEDITOR.ALT} constants.
* @returns {Number} The number representing the keys combination.
* @example
* alert( event.getKeystroke() == 65 ); // "a" key
* alert( event.getKeystroke() == CKEDITOR.CTRL + 65 ); // CTRL + "a" key
* alert( event.getKeystroke() == CKEDITOR.CTRL + CKEDITOR.SHIFT + 65 ); // CTRL + SHIFT + "a" key
*/
getKeystroke : function()
{
var keystroke = this.getKey();
if ( this.$.ctrlKey || this.$.metaKey )
keystroke += CKEDITOR.CTRL;
if ( this.$.shiftKey )
keystroke += CKEDITOR.SHIFT;
if ( this.$.altKey )
keystroke += CKEDITOR.ALT;
return keystroke;
},
/**
* Prevents the original behavior of the event to happen. It can optionally
* stop propagating the event in the event chain.
* @param {Boolean} [stopPropagation] Stop propagating this event in the
* event chain.
* @example
* var element = CKEDITOR.document.getById( 'myElement' );
* element.on( 'click', function( ev )
* {
* // The DOM event object is passed by the "data" property.
* var domEvent = ev.data;
* // Prevent the click to chave any effect in the element.
* domEvent.preventDefault();
* });
*/
preventDefault : function( stopPropagation )
{
var $ = this.$;
if ( $.preventDefault )
$.preventDefault();
else
$.returnValue = false;
if ( stopPropagation )
this.stopPropagation();
},
stopPropagation : function()
{
var $ = this.$;
if ( $.stopPropagation )
$.stopPropagation();
else
$.cancelBubble = true;
},
/**
* Returns the DOM node where the event was targeted to.
* @returns {CKEDITOR.dom.node} The target DOM node.
* @example
* var element = CKEDITOR.document.getById( 'myElement' );
* element.on( 'click', function( ev )
* {
* // The DOM event object is passed by the "data" property.
* var domEvent = ev.data;
* // Add a CSS class to the event target.
* domEvent.getTarget().addClass( 'clicked' );
* });
*/
getTarget : function()
{
var rawNode = this.$.target || this.$.srcElement;
return rawNode ? new CKEDITOR.dom.node( rawNode ) : null;
}
};
// For the followind constants, we need to go over the Unicode boundaries
// (0x10FFFF) to avoid collision.
/**
* CTRL key (0x110000).
* @constant
* @example
*/
CKEDITOR.CTRL = 0x110000;
/**
* SHIFT key (0x220000).
* @constant
* @example
*/
CKEDITOR.SHIFT = 0x220000;
/**
* ALT key (0x440000).
* @constant
* @example
*/
CKEDITOR.ALT = 0x440000;
This diff is collapsed.
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* @class
*/
CKEDITOR.dom.nodeList = function( nativeList )
{
this.$ = nativeList;
};
CKEDITOR.dom.nodeList.prototype =
{
count : function()
{
return this.$.length;
},
getItem : function( index )
{
var $node = this.$[ index ];
return $node ? new CKEDITOR.dom.node( $node ) : null;
}
};
This diff is collapsed.
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
(function()
{
/**
* Represents a list os CKEDITOR.dom.range objects, which can be easily
* iterated sequentially.
* @constructor
* @param {CKEDITOR.dom.range|Array} [ranges] The ranges contained on this list.
* Note that, if an array of ranges is specified, the range sequence
* should match its DOM order. This class will not help to sort them.
*/
CKEDITOR.dom.rangeList = function( ranges )
{
if ( ranges instanceof CKEDITOR.dom.rangeList )
return ranges;
if ( !ranges )
ranges = [];
else if ( ranges instanceof CKEDITOR.dom.range )
ranges = [ ranges ];
return CKEDITOR.tools.extend( ranges, mixins );
};
var mixins =
/** @lends CKEDITOR.dom.rangeList.prototype */
{
/**
* Creates an instance of the rangeList iterator, it should be used
* only when the ranges processing could be DOM intrusive, which
* means it may pollute and break other ranges in this list.
* Otherwise, it's enough to just iterate over this array in a for loop.
* @returns {CKEDITOR.dom.rangeListIterator}
*/
createIterator : function()
{
var rangeList = this,
bookmark = CKEDITOR.dom.walker.bookmark(),
guard = function( node ) { return ! ( node.is && node.is( 'tr' ) ); },
bookmarks = [],
current;
/**
* @lends CKEDITOR.dom.rangeListIterator.prototype
*/
return {
/**
* Retrieves the next range in the list.
* @param {Boolean} mergeConsequent Whether join two adjacent ranges into single, e.g. consequent table cells.
*/
getNextRange : function( mergeConsequent )
{
current = current == undefined ? 0 : current + 1;
var range = rangeList[ current ];
// Multiple ranges might be mangled by each other.
if ( range && rangeList.length > 1 )
{
// Bookmarking all other ranges on the first iteration,
// the range correctness after it doesn't matter since we'll
// restore them before the next iteration.
if ( !current )
{
// Make sure bookmark correctness by reverse processing.
for ( var i = rangeList.length - 1; i >= 0; i-- )
bookmarks.unshift( rangeList[ i ].createBookmark( true ) );
}
if ( mergeConsequent )
{
// Figure out how many ranges should be merged.
var mergeCount = 0;
while ( rangeList[ current + mergeCount + 1 ] )
{
var doc = range.document,
found = 0,
left = doc.getById( bookmarks[ mergeCount ].endNode ),
right = doc.getById( bookmarks[ mergeCount + 1 ].startNode ),
next;
// Check subsequent range.
while ( 1 )
{
next = left.getNextSourceNode( false );
if ( !right.equals( next ) )
{
// This could be yet another bookmark or
// walking across block boundaries.
if ( bookmark( next ) || ( next.type == CKEDITOR.NODE_ELEMENT && next.isBlockBoundary() ) )
{
left = next;
continue;
}
}
else
found = 1;
break;
}
if ( !found )
break;
mergeCount++;
}
}
range.moveToBookmark( bookmarks.shift() );
// Merge ranges finally after moving to bookmarks.
while( mergeCount-- )
{
next = rangeList[ ++current ];
next.moveToBookmark( bookmarks.shift() );
range.setEnd( next.endContainer, next.endOffset );
}
}
return range;
}
};
},
createBookmarks : function( serializable )
{
var retval = [], bookmark;
for ( var i = 0; i < this.length ; i++ )
{
retval.push( bookmark = this[ i ].createBookmark( serializable, true) );
// Updating the container & offset values for ranges
// that have been touched.
for ( var j = i + 1; j < this.length; j++ )
{
this[ j ] = updateDirtyRange( bookmark, this[ j ] );
this[ j ] = updateDirtyRange( bookmark, this[ j ], true );
}
}
return retval;
},
createBookmarks2 : function( normalized )
{
var bookmarks = [];
for ( var i = 0 ; i < this.length ; i++ )
bookmarks.push( this[ i ].createBookmark2( normalized ) );
return bookmarks;
},
/**
* Move each range in the list to the position specified by a list of bookmarks.
* @param {Array} bookmarks The list of bookmarks, each one matching a range in the list.
*/
moveToBookmarks : function( bookmarks )
{
for ( var i = 0 ; i < this.length ; i++ )
this[ i ].moveToBookmark( bookmarks[ i ] );
}
};
// Update the specified range which has been mangled by previous insertion of
// range bookmark nodes.(#3256)
function updateDirtyRange( bookmark, dirtyRange, checkEnd )
{
var serializable = bookmark.serializable,
container = dirtyRange[ checkEnd ? 'endContainer' : 'startContainer' ],
offset = checkEnd ? 'endOffset' : 'startOffset';
var bookmarkStart = serializable ?
dirtyRange.document.getById( bookmark.startNode )
: bookmark.startNode;
var bookmarkEnd = serializable ?
dirtyRange.document.getById( bookmark.endNode )
: bookmark.endNode;
if ( container.equals( bookmarkStart.getPrevious() ) )
{
dirtyRange.startOffset = dirtyRange.startOffset
- container.getLength()
- bookmarkEnd.getPrevious().getLength();
container = bookmarkEnd.getNext();
}
else if ( container.equals( bookmarkEnd.getPrevious() ) )
{
dirtyRange.startOffset = dirtyRange.startOffset - container.getLength();
container = bookmarkEnd.getNext();
}
container.equals( bookmarkStart.getParent() ) && dirtyRange[ offset ]++;
container.equals( bookmarkEnd.getParent() ) && dirtyRange[ offset ]++;
// Update and return this range.
dirtyRange[ checkEnd ? 'endContainer' : 'startContainer' ] = container;
return dirtyRange;
}
})();
/**
* (Virtual Class) Do not call this constructor. This class is not really part
* of the API. It just describes the return type of {@link CKEDITOR.dom.rangeList#createIterator}.
* @name CKEDITOR.dom.rangeListIterator
* @constructor
* @example
*/
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* @fileOverview Defines the {@link CKEDITOR.dom.text} class, which represents
* a DOM text node.
*/
/**
* Represents a DOM text node.
* @constructor
* @augments CKEDITOR.dom.node
* @param {Object|String} text A native DOM text node or a string containing
* the text to use to create a new text node.
* @param {CKEDITOR.dom.document} [ownerDocument] The document that will contain
* the node in case of new node creation. Defaults to the current document.
* @example
* var nativeNode = document.createTextNode( 'Example' );
* var text = CKEDITOR.dom.text( nativeNode );
* @example
* var text = CKEDITOR.dom.text( 'Example' );
*/
CKEDITOR.dom.text = function( text, ownerDocument )
{
if ( typeof text == 'string' )
text = ( ownerDocument ? ownerDocument.$ : document ).createTextNode( text );
// Theoretically, we should call the base constructor here
// (not CKEDITOR.dom.node though). But, IE doesn't support expando
// properties on text node, so the features provided by domObject will not
// work for text nodes (which is not a big issue for us).
//
// CKEDITOR.dom.domObject.call( this, element );
/**
* The native DOM text node represented by this class instance.
* @type Object
* @example
* var element = new CKEDITOR.dom.text( 'Example' );
* alert( element.$.nodeType ); // "3"
*/
this.$ = text;
};
CKEDITOR.dom.text.prototype = new CKEDITOR.dom.node();
CKEDITOR.tools.extend( CKEDITOR.dom.text.prototype,
/** @lends CKEDITOR.dom.text.prototype */
{
/**
* The node type. This is a constant value set to
* {@link CKEDITOR.NODE_TEXT}.
* @type Number
* @example
*/
type : CKEDITOR.NODE_TEXT,
getLength : function()
{
return this.$.nodeValue.length;
},
getText : function()
{
return this.$.nodeValue;
},
setText : function( text )
{
this.$.nodeValue = text;
},
/**
* Breaks this text node into two nodes at the specified offset,
* keeping both in the tree as siblings. This node then only contains
* all the content up to the offset point. A new text node, which is
* inserted as the next sibling of this node, contains all the content
* at and after the offset point. When the offset is equal to the
* length of this node, the new node has no data.
* @param {Number} The position at which to split, starting from zero.
* @returns {CKEDITOR.dom.text} The new text node.
*/
split : function( offset )
{
// If the offset is after the last char, IE creates the text node
// on split, but don't include it into the DOM. So, we have to do
// that manually here.
if ( CKEDITOR.env.ie && offset == this.getLength() )
{
var next = this.getDocument().createText( '' );
next.insertAfter( this );
return next;
}
var doc = this.getDocument();
var retval = new CKEDITOR.dom.text( this.$.splitText( offset ), doc );
// IE BUG: IE8 does not update the childNodes array in DOM after splitText(),
// we need to make some DOM changes to make it update. (#3436)
if ( CKEDITOR.env.ie8 )
{
var workaround = new CKEDITOR.dom.text( '', doc );
workaround.insertAfter( retval );
workaround.remove();
}
return retval;
},
/**
* Extracts characters from indexA up to but not including indexB.
* @param {Number} indexA An integer between 0 and one less than the
* length of the text.
* @param {Number} [indexB] An integer between 0 and the length of the
* string. If omitted, extracts characters to the end of the text.
*/
substring : function( indexA, indexB )
{
// We need the following check due to a Firefox bug
// https://bugzilla.mozilla.org/show_bug.cgi?id=458886
if ( typeof indexB != 'number' )
return this.$.nodeValue.substr( indexA );
else
return this.$.nodeValue.substring( indexA, indexB );
}
});
This diff is collapsed.
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* @fileOverview Defines the {@link CKEDITOR.dom.document} class, which
* represents a DOM document.
*/
/**
* Represents a DOM window.
* @constructor
* @augments CKEDITOR.dom.domObject
* @param {Object} domWindow A native DOM window.
* @example
* var document = new CKEDITOR.dom.window( window );
*/
CKEDITOR.dom.window = function( domWindow )
{
CKEDITOR.dom.domObject.call( this, domWindow );
};
CKEDITOR.dom.window.prototype = new CKEDITOR.dom.domObject();
CKEDITOR.tools.extend( CKEDITOR.dom.window.prototype,
/** @lends CKEDITOR.dom.window.prototype */
{
/**
* Moves the selection focus to this window.
* @function
* @example
* var win = new CKEDITOR.dom.window( window );
* <b>win.focus()</b>;
*/
focus : function()
{
// Webkit is sometimes failed to focus iframe, blur it first(#3835).
if ( CKEDITOR.env.webkit && this.$.parent )
this.$.parent.focus();
this.$.focus();
},
/**
* Gets the width and height of this window's viewable area.
* @function
* @returns {Object} An object with the "width" and "height"
* properties containing the size.
* @example
* var win = new CKEDITOR.dom.window( window );
* var size = <b>win.getViewPaneSize()</b>;
* alert( size.width );
* alert( size.height );
*/
getViewPaneSize : function()
{
var doc = this.$.document,
stdMode = doc.compatMode == 'CSS1Compat';
return {
width : ( stdMode ? doc.documentElement.clientWidth : doc.body.clientWidth ) || 0,
height : ( stdMode ? doc.documentElement.clientHeight : doc.body.clientHeight ) || 0
};
},
/**
* Gets the current position of the window's scroll.
* @function
* @returns {Object} An object with the "x" and "y" properties
* containing the scroll position.
* @example
* var win = new CKEDITOR.dom.window( window );
* var pos = <b>win.getScrollPosition()</b>;
* alert( pos.x );
* alert( pos.y );
*/
getScrollPosition : function()
{
var $ = this.$;
if ( 'pageXOffset' in $ )
{
return {
x : $.pageXOffset || 0,
y : $.pageYOffset || 0
};
}
else
{
var doc = $.document;
return {
x : doc.documentElement.scrollLeft || doc.body.scrollLeft || 0,
y : doc.documentElement.scrollTop || doc.body.scrollTop || 0
};
}
}
});
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.htmlParser.basicWriter = CKEDITOR.tools.createClass(
{
$ : function()
{
this._ =
{
output : []
};
},
proto :
{
/**
* Writes the tag opening part for a opener tag.
* @param {String} tagName The element name for this tag.
* @param {Object} attributes The attributes defined for this tag. The
* attributes could be used to inspect the tag.
* @example
* // Writes "&lt;p".
* writer.openTag( 'p', { class : 'MyClass', id : 'MyId' } );
*/
openTag : function( tagName, attributes )
{
this._.output.push( '<', tagName );
},
/**
* Writes the tag closing part for a opener tag.
* @param {String} tagName The element name for this tag.
* @param {Boolean} isSelfClose Indicates that this is a self-closing tag,
* like "br" or "img".
* @example
* // Writes "&gt;".
* writer.openTagClose( 'p', false );
* @example
* // Writes " /&gt;".
* writer.openTagClose( 'br', true );
*/
openTagClose : function( tagName, isSelfClose )
{
if ( isSelfClose )
this._.output.push( ' />' );
else
this._.output.push( '>' );
},
/**
* Writes an attribute. This function should be called after opening the
* tag with {@link #openTagClose}.
* @param {String} attName The attribute name.
* @param {String} attValue The attribute value.
* @example
* // Writes ' class="MyClass"'.
* writer.attribute( 'class', 'MyClass' );
*/
attribute : function( attName, attValue )
{
// Browsers don't always escape special character in attribute values. (#4683, #4719).
if ( typeof attValue == 'string' )
attValue = CKEDITOR.tools.htmlEncodeAttr( attValue );
this._.output.push( ' ', attName, '="', attValue, '"' );
},
/**
* Writes a closer tag.
* @param {String} tagName The element name for this tag.
* @example
* // Writes "&lt;/p&gt;".
* writer.closeTag( 'p' );
*/
closeTag : function( tagName )
{
this._.output.push( '</', tagName, '>' );
},
/**
* Writes text.
* @param {String} text The text value
* @example
* // Writes "Hello Word".
* writer.text( 'Hello Word' );
*/
text : function( text )
{
this._.output.push( text );
},
/**
* Writes a comment.
* @param {String} comment The comment text.
* @example
* // Writes "&lt;!-- My comment --&gt;".
* writer.comment( ' My comment ' );
*/
comment : function( comment )
{
this._.output.push( '<!--', comment, '-->' );
},
/**
* Writes any kind of data to the ouput.
* @example
* writer.write( 'This is an &lt;b&gt;example&lt;/b&gt;.' );
*/
write : function( data )
{
this._.output.push( data );
},
/**
* Empties the current output buffer.
* @example
* writer.reset();
*/
reset : function()
{
this._.output = [];
this._.indent = false;
},
/**
* Empties the current output buffer.
* @param {Boolean} reset Indicates that the {@link reset} function is to
* be automatically called after retrieving the HTML.
* @returns {String} The HTML written to the writer so far.
* @example
* var html = writer.getHtml();
*/
getHtml : function( reset )
{
var html = this._.output.join( '' );
if ( reset )
this.reset();
return html;
}
}
});
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
(function()
{
/**
* A lightweight representation of HTML text.
* @constructor
* @example
*/
CKEDITOR.htmlParser.cdata = function( value )
{
/**
* The CDATA value.
* @type String
* @example
*/
this.value = value;
};
CKEDITOR.htmlParser.cdata.prototype =
{
/**
* CDATA has the same type as {@link CKEDITOR.htmlParser.text} This is
* a constant value set to {@link CKEDITOR.NODE_TEXT}.
* @type Number
* @example
*/
type : CKEDITOR.NODE_TEXT,
/**
* Writes write the CDATA with no special manipulations.
* @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML.
*/
writeHtml : function( writer )
{
writer.write( this.value );
}
};
})();
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* A lightweight representation of an HTML comment.
* @constructor
* @example
*/
CKEDITOR.htmlParser.comment = function( value )
{
/**
* The comment text.
* @type String
* @example
*/
this.value = value;
/** @private */
this._ =
{
isBlockLike : false
};
};
CKEDITOR.htmlParser.comment.prototype =
{
/**
* The node type. This is a constant value set to {@link CKEDITOR.NODE_COMMENT}.
* @type Number
* @example
*/
type : CKEDITOR.NODE_COMMENT,
/**
* Writes the HTML representation of this comment to a CKEDITOR.htmlWriter.
* @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML.
* @example
*/
writeHtml : function( writer, filter )
{
var comment = this.value;
if ( filter )
{
if ( !( comment = filter.onComment( comment, this ) ) )
return;
if ( typeof comment != 'string' )
{
comment.parent = this.parent;
comment.writeHtml( writer, filter );
return;
}
}
writer.comment( comment );
}
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
(function()
{
/**
* A lightweight representation of HTML text.
* @constructor
* @example
*/
CKEDITOR.htmlParser.text = function( value )
{
/**
* The text value.
* @type String
* @example
*/
this.value = value;
/** @private */
this._ =
{
isBlockLike : false
};
};
CKEDITOR.htmlParser.text.prototype =
{
/**
* The node type. This is a constant value set to {@link CKEDITOR.NODE_TEXT}.
* @type Number
* @example
*/
type : CKEDITOR.NODE_TEXT,
/**
* Writes the HTML representation of this text to a CKEDITOR.htmlWriter.
* @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML.
* @example
*/
writeHtml : function( writer, filter )
{
var text = this.value;
if ( filter && !( text = filter.onText( text, this ) ) )
return;
writer.text( text );
}
};
})();
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* @fileOverview Plugin definition for the a11yhelp, which provides a dialog
* with accessibility related help.
*/
(function()
{
var pluginName = 'a11yhelp',
commandName = 'a11yHelp';
CKEDITOR.plugins.add( pluginName,
{
// List of available localizations.
availableLangs : { en:1, he:1 },
init : function( editor )
{
var plugin = this;
editor.addCommand( commandName,
{
exec : function()
{
var langCode = editor.langCode;
langCode = plugin.availableLangs[ langCode ] ? langCode : 'en';
CKEDITOR.scriptLoader.load(
CKEDITOR.getUrl( plugin.path + 'lang/' + langCode + '.js' ),
function()
{
CKEDITOR.tools.extend( editor.lang, plugin.langEntries[ langCode ] );
editor.openDialog( commandName );
});
},
modes : { wysiwyg:1, source:1 },
readOnly : 1,
canUndo : false
});
CKEDITOR.dialog.add( commandName, this.path + 'dialogs/a11yhelp.js' );
}
});
})();
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.plugins.add( 'about',
{
requires : [ 'dialog' ],
init : function( editor )
{
var command = editor.addCommand( 'about', new CKEDITOR.dialogCommand( 'about' ) );
command.modes = { wysiwyg:1, source:1 };
command.canUndo = false;
command.readOnly = 1;
editor.ui.addButton( 'About',
{
label : editor.lang.about.title,
command : 'about'
});
CKEDITOR.dialog.add( 'about', this.path + 'dialogs/about.js' );
}
});
This diff is collapsed.
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* @fileOverview Defines the {@link CKEDITOR.ajax} object, which holds ajax methods for
* data loading.
*/
(function()
{
CKEDITOR.plugins.add( 'ajax',
{
requires : [ 'xml' ]
});
/**
* Ajax methods for data loading.
* @namespace
* @example
*/
CKEDITOR.ajax = (function()
{
var createXMLHttpRequest = function()
{
// In IE, using the native XMLHttpRequest for local files may throw
// "Access is Denied" errors.
if ( !CKEDITOR.env.ie || location.protocol != 'file:' )
try { return new XMLHttpRequest(); } catch(e) {}
try { return new ActiveXObject( 'Msxml2.XMLHTTP' ); } catch (e) {}
try { return new ActiveXObject( 'Microsoft.XMLHTTP' ); } catch (e) {}
return null;
};
var checkStatus = function( xhr )
{
// HTTP Status Codes:
// 2xx : Success
// 304 : Not Modified
// 0 : Returned when running locally (file://)
// 1223 : IE may change 204 to 1223 (see http://dev.jquery.com/ticket/1450)
return ( xhr.readyState == 4 &&
( ( xhr.status >= 200 && xhr.status < 300 ) ||
xhr.status == 304 ||
xhr.status === 0 ||
xhr.status == 1223 ) );
};
var getResponseText = function( xhr )
{
if ( checkStatus( xhr ) )
return xhr.responseText;
return null;
};
var getResponseXml = function( xhr )
{
if ( checkStatus( xhr ) )
{
var xml = xhr.responseXML;
return new CKEDITOR.xml( xml && xml.firstChild ? xml : xhr.responseText );
}
return null;
};
var load = function( url, callback, getResponseFn )
{
var async = !!callback;
var xhr = createXMLHttpRequest();
if ( !xhr )
return null;
xhr.open( 'GET', url, async );
if ( async )
{
// TODO: perform leak checks on this closure.
/** @ignore */
xhr.onreadystatechange = function()
{
if ( xhr.readyState == 4 )
{
callback( getResponseFn( xhr ) );
xhr = null;
}
};
}
xhr.send(null);
return async ? '' : getResponseFn( xhr );
};
return /** @lends CKEDITOR.ajax */ {
/**
* Loads data from an URL as plain text.
* @param {String} url The URL from which load data.
* @param {Function} [callback] A callback function to be called on
* data load. If not provided, the data will be loaded
* synchronously.
* @returns {String} The loaded data. For asynchronous requests, an
* empty string. For invalid requests, null.
* @example
* // Load data synchronously.
* var data = CKEDITOR.ajax.load( 'somedata.txt' );
* alert( data );
* @example
* // Load data asynchronously.
* var data = CKEDITOR.ajax.load( 'somedata.txt', function( data )
* {
* alert( data );
* } );
*/
load : function( url, callback )
{
return load( url, callback, getResponseText );
},
/**
* Loads data from an URL as XML.
* @param {String} url The URL from which load data.
* @param {Function} [callback] A callback function to be called on
* data load. If not provided, the data will be loaded
* synchronously.
* @returns {CKEDITOR.xml} An XML object holding the loaded data. For asynchronous requests, an
* empty string. For invalid requests, null.
* @example
* // Load XML synchronously.
* var xml = CKEDITOR.ajax.loadXml( 'somedata.xml' );
* alert( xml.getInnerXml( '//' ) );
* @example
* // Load XML asynchronously.
* var data = CKEDITOR.ajax.loadXml( 'somedata.xml', function( xml )
* {
* alert( xml.getInnerXml( '//' ) );
* } );
*/
loadXml : function( url, callback )
{
return load( url, callback, getResponseXml );
}
};
})();
})();
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment