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'
						}
					});

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

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.