Skip to content

Commit

Permalink
Disable not allowed input elements and tabs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Jasiun committed Oct 31, 2013
1 parent 2dc0a00 commit bac48a1
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
27 changes: 26 additions & 1 deletion plugins/dialog/plugin.js
Expand Up @@ -238,6 +238,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
contents: {},
buttons: {},
accessKeyMap: {},
wasDisabled: [],

// Initialize the tab and page map.
tabs: {},
Expand Down Expand Up @@ -837,6 +838,24 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
// Reset the hasFocus state.
this._.hasFocus = false;

this.foreach( function( obj ) {
if ( obj.requiredContent && !this._.editor.activeFilter.check( obj.requiredContent ) ) {
this._.wasDisabled[ obj.domId ] = !obj.isEnabled();
obj.disable();
} else if ( this._.wasDisabled[ obj.domId ] )
obj.disable();
else
obj.enable();
} );

for ( var i in definition.contents ) {
var requiredContent = definition.contents[ i ].requiredContent;
if( requiredContent && !this._.editor.activeFilter.check( requiredContent ) )
this._.tabs[ definition.contents[ i ].id ][ 0 ].addClass( 'cke_dialog_tab_disabled' );
else
this._.tabs[ definition.contents[ i ].id ][ 0 ].removeClass( 'cke_dialog_tab_disabled' );
}

CKEDITOR.tools.setTimeout( function() {
this.layout();
resizeWithWindow( this );
Expand Down Expand Up @@ -1113,6 +1132,12 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
if ( this._.currentTabId == id )
return;

var tabIndex = CKEDITOR.tools.indexOf( this._.tabIdList, id ),
requiredContent = this.definition.contents[ tabIndex ].requiredContent;

if( requiredContent && !this._.editor.activeFilter.check( requiredContent ) )
return;

// Returning true means that the event has been canceled
if ( this.fire( 'selectPage', { page: id, currentPage: this._.currentTabId } ) === true )
return;
Expand Down Expand Up @@ -1144,7 +1169,7 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
selected[ 1 ].show();

this._.currentTabId = id;
this._.currentTabIndex = CKEDITOR.tools.indexOf( this._.tabIdList, id );
this._.currentTabIndex = tabIndex;
},

/**
Expand Down
6 changes: 6 additions & 0 deletions skins/kama/dialog.css
Expand Up @@ -229,6 +229,12 @@ a.cke_dialog_tab_selected
border-width: 3px;
}

a.cke_dialog_tab_disabled
{
color: #bababa;
cursor: default;
}

/* The .cke_single_page class is appended to the dialog outer element in case
of dialogs that has no tabs. */
.cke_single_page .cke_dialog_tabs
Expand Down
6 changes: 6 additions & 0 deletions skins/moono/dialog.css
Expand Up @@ -301,6 +301,12 @@ a.cke_dialog_tab_selected:hover
padding: 2px 6px;
}

a.cke_dialog_tab_disabled
{
color: #bababa;
cursor: default;
}

/* The .cke_single_page class is appended to the dialog outer element in case
of dialogs that has no tabs. */
.cke_single_page .cke_dialog_tabs
Expand Down

0 comments on commit bac48a1

Please sign in to comment.