0

Hello All,

Assume i have the following code:

// This code is defined in one file :
editor.addMenuItem = function( name, definition )
  			{
  				if ( groupsOrder[ definition.group ] )
  					menuItems[ name ] = new CKEDITOR.menuItem( this, name, definition );
  			};

// This code is defined in another file:
if (editor.addMenuItems) 			{
				editor.addMenuItems({
						footnote : {
							label : 'Footnote',
							command : 'footnote',
							group : 'footnote'
						},
						citation : {
							label : 'Citation',
							command : 'citation',
							group : 'footnote'
						}
					});

Can someone explain to me what the 2nd block of code means?
Does it mean : If the function editor.addMenuItems exists, then call it with the following parameters?? i.e If the function exists then execute the following:

{
				editor.addMenuItems({
						footnote : {
							label : 'Footnote',
							command : 'footnote',
							group : 'footnote'
						},
						citation : {
							label : 'Citation',
							command : 'citation',
							group : 'footnote'
						}
					});
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Airshow
0

Yes, exactly so. The if clause is a "safety wrapper" to ensure the method is called only if it exists.

Airshow

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.