CKEDITOR.plugins.add( 'seting', {
    icons: 'seting',
    init: function( editor ) {
        editor.addCommand( 'seting', new CKEDITOR.dialogCommand( 'setingDialog' ) );
        editor.ui.addButton( 'seting', {
            label: 'Блок настроек',
            command: 'seting',
            toolbar: 'insert'
        });

		 if ( editor.contextMenu ) {
            editor.addMenuGroup( 'setingGroup' );
            editor.addMenuItem( 'setingItem', {
                label: 'Редактировать настройки ',
                icon: this.path + 'icons/seting.png',
                command: 'seting',
                group: 'setingGroup'
            });
			editor.on( 'doubleclick', function( evt ) {
				var element = evt.data.element;
				if ( element.getAttribute('id') == 'widgetseting' )
					evt.data.dialog = 'setingDialog';
			} );
            editor.contextMenu.addListener( function( element ) {
                if ( element.getAscendant( 'seting', true ) ) {
                    return { setingItem: CKEDITOR.TRISTATE_OFF };
                }
            });
        }

        CKEDITOR.dialog.add( 'setingDialog', this.path + 'dialogs/seting.js' );
    }
});

