Skip to content
Permalink
Browse files

Merge branch 't/9990' into major

  • Loading branch information...
Reinmar committed Feb 15, 2013
2 parents 85dfc91 + 05c1c01 commit c7cf98306c98f95bb3037338a43c416de7ebb1b4
@@ -195,6 +195,15 @@
* @property {String} title
*/

/**
* The content that needs to be allowed to enable this UI element.
* All formats accepted by {@link CKEDITOR.filter#check} may be used.
*
* When all UI elements in a tab are disabled, this tab will be disabled automatically.
*
* @property {String/Object/CKEDITOR.style} requiredContent
*/

/**
* CSS class names to append to the UI element.
*
@@ -1024,6 +1024,9 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
* @param {Object} contents Content definition.
*/
addPage: function( contents ) {
if ( contents.requiredContent && !this._.editor.filter.check( contents.requiredContent ) )
return;

var pageHtml = [],
titleHtml = contents.label ? ' title="' + CKEDITOR.tools.htmlEncode( contents.label ) + '"' : '',
elements = contents.elements,
@@ -1036,6 +1039,25 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
style: contents.style || 'width: 100%;'
}, pageHtml );

var contentMap = this._.contents[ contents.id ] = {},
cursor,
children = vbox.getChild(),
enabledFields = 0;

while ( ( cursor = children.shift() ) ) {
// Count all allowed fields.
if ( !cursor.notAllowed && cursor.type != 'hbox' && cursor.type != 'vbox' )
enabledFields++;

contentMap[ cursor.id ] = cursor;
if ( typeof( cursor.getChild ) == 'function' )
children.push.apply( children, cursor.getChild() );
}

// If all fields are disabled (because they are not allowed) hide this tab.
if ( !enabledFields )
contents.hidden = true;

// Create the HTML for the tab and the content block.
var page = CKEDITOR.dom.element.createFromHtml( pageHtml.join( '' ) );
page.setAttribute( 'role', 'tabpanel' );
@@ -1065,16 +1087,6 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
this._.lastTab = tab;
this.updateStyle();

var contentMap = this._.contents[ contents.id ] = {},
cursor,
children = vbox.getChild();

while ( ( cursor = children.shift() ) ) {
contentMap[ cursor.id ] = cursor;
if ( typeof( cursor.getChild ) == 'function' )
children.push.apply( children, cursor.getChild() );
}

// Attach the DOM nodes.

page.setAttribute( 'name', contents.id );
@@ -1422,6 +1434,20 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
return CKEDITOR.dialog._.currentTop;
},

/**
* Check whether tab wasn't removed by {@link CKEDITOR.config#removeDialogTabs}.
*
* @param {CKEDITOR.editor} editor
* @param {String} dialogName
* @param {String} tabName
* @returns {Boolean}
*/
isTabEnabled: function( editor, dialogName, tabName ) {
var cfg = editor.config.removeDialogTabs;

return !( cfg && cfg.match( new RegExp( '(?:^|;)' + dialogName + ':' + tabName + '(?:$|;)', 'i' ) ) );
},

/**
* The default OK button for dialogs. Fires the `ok` event and closes the dialog if the event succeeds.
*
@@ -2191,6 +2217,11 @@ CKEDITOR.DIALOG_RESIZE_BOTH = 3;
id = this.id = elementDefinition.id,
i;

if ( elementDefinition.requiredContent && !dialog.getParentEditor().filter.check( elementDefinition.requiredContent ) ) {
styles.display = 'none';
this.notAllowed = true;
}

// Set the id, a unique id is required for getElement() to work.
attributes.id = domId;

@@ -68,7 +68,7 @@

// @param tabConfig
// id, dir, classes, styles
createAdvancedTab: function( editor, tabConfig ) {
createAdvancedTab: function( editor, tabConfig, element ) {
if ( !tabConfig )
tabConfig = defaultTabConfig;

@@ -95,6 +95,7 @@
id: 'advId',
att: 'id',
type: 'text',
requiredContent: element ? element + '[id]' : null,
label: lang.id,
setup: setupAdvParams,
commit: commitAdvParams
@@ -106,6 +107,7 @@
id: 'advLangDir',
att: 'dir',
type: 'select',
requiredContent: element ? element + '[dir]' : null,
label: lang.langDir,
'default': '',
style: 'width:100%',
@@ -134,6 +136,7 @@
id: 'advStyles',
att: 'style',
type: 'text',
requiredContent: element ? element + '{cke-xyz}' : null,
label: lang.styles,
'default': '',

@@ -172,6 +175,7 @@
id: 'advCSSClasses',
att: 'class',
type: 'text',
requiredContent: element ? element + '(cke-xyz)' : null,
label: lang.cssClasses,
'default': '',
setup: setupAdvParams,
@@ -275,6 +275,7 @@
{
id: 'class',
type: 'text',
requiredContent: 'div(cke-xyz)', // Random text like 'xyz' will check if all are allowed.
label: editor.lang.common.cssClass,
'default': ''
}
@@ -298,12 +299,14 @@
{
type: 'text',
id: 'id',
requiredContent: 'div[id]',
label: editor.lang.common.id,
'default': ''
},
{
type: 'text',
id: 'lang',
requiredContent: 'div[lang]',
label: editor.lang.common.langCode,
'default': ''
}
@@ -315,6 +318,7 @@
{
type: 'text',
id: 'style',
requiredContent: 'div{cke-xyz}', // Random text like 'xyz' will check if all are allowed.
style: 'width: 100%;',
label: editor.lang.common.cssStyle,
'default': '',
@@ -330,6 +334,7 @@
{
type: 'text',
id: 'title',
requiredContent: 'div[title]',
style: 'width: 100%;',
label: editor.lang.common.advisoryTitle,
'default': ''
@@ -339,6 +344,7 @@
{
type: 'select',
id: 'dir',
requiredContent: 'div[dir]',
style: 'width: 100%;',
label: editor.lang.common.langDir,
'default': '',
@@ -368,19 +374,21 @@

// Reuse the 'stylescombo' plugin's styles definition.
editor.getStylesSet( function( stylesDefinitions ) {
var styleName;
var styleName, style;

if ( stylesDefinitions ) {
// Digg only those styles that apply to 'div'.
for ( var i = 0; i < stylesDefinitions.length; i++ ) {
var styleDefinition = stylesDefinitions[ i ];
if ( styleDefinition.element && styleDefinition.element == 'div' ) {
styleName = styleDefinition.name;
styles[ styleName ] = new CKEDITOR.style( styleDefinition );
styles[ styleName ] = style = new CKEDITOR.style( styleDefinition );

// Populate the styles field options with style name.
stylesField.items.push( [ styleName, styleName ] );
stylesField.add( styleName, styleName );
if ( editor.filter.check( style ) ) {
// Populate the styles field options with style name.
stylesField.items.push( [ styleName, styleName ] );
stylesField.add( styleName, styleName );
}
}
}
}
@@ -17,10 +17,14 @@
if ( editor.blockless )
return;

var lang = editor.lang.div;
var lang = editor.lang.div,
allowed = 'div(*)';

if ( CKEDITOR.dialog.isTabEnabled( editor, 'editdiv', 'advanced' ) )
allowed += ';div[dir,id,lang,title]{*}';

editor.addCommand( 'creatediv', new CKEDITOR.dialogCommand( 'creatediv', {
allowedContent: 'div(*)[dir,id,lang,title]{*}',
allowedContent: allowed,
requiredContent: 'div',
contextSensitive: true,
refresh: function( editor, path ) {
@@ -373,6 +373,7 @@
{
type: 'text',
id: 'width',
requiredContent: 'embed[width]',
style: 'width:95px',
label: editor.lang.common.width,
validate: CKEDITOR.dialog.validate.htmlLength( editor.lang.common.invalidHtmlLength.replace( '%1', editor.lang.common.width ) ),
@@ -382,6 +383,7 @@
{
type: 'text',
id: 'height',
requiredContent: 'embed[height]',
style: 'width:95px',
label: editor.lang.common.height,
validate: CKEDITOR.dialog.validate.htmlLength( editor.lang.common.invalidHtmlLength.replace( '%1', editor.lang.common.height ) ),
@@ -391,6 +393,7 @@
{
type: 'text',
id: 'hSpace',
requiredContent: 'embed[hspace]',
style: 'width:95px',
label: editor.lang.flash.hSpace,
validate: CKEDITOR.dialog.validate.integer( editor.lang.flash.validateHSpace ),
@@ -400,6 +403,7 @@
{
type: 'text',
id: 'vSpace',
requiredContent: 'embed[vspace]',
style: 'width:95px',
label: editor.lang.flash.vSpace,
validate: CKEDITOR.dialog.validate.integer( editor.lang.flash.validateVSpace ),
@@ -454,6 +458,7 @@
{
id: 'scale',
type: 'select',
requiredContent: 'embed[scale]',
label: editor.lang.flash.scale,
'default': '',
style: 'width : 100%;',
@@ -469,6 +474,7 @@
{
id: 'allowScriptAccess',
type: 'select',
requiredContent: 'embed[allowscriptaccess]',
label: editor.lang.flash.access,
'default': '',
style: 'width : 100%;',
@@ -490,6 +496,7 @@
{
id: 'wmode',
type: 'select',
requiredContent: 'embed[wmode]',
label: editor.lang.flash.windowMode,
'default': '',
style: 'width : 100%;',
@@ -505,6 +512,7 @@
{
id: 'quality',
type: 'select',
requiredContent: 'embed[quality]',
label: editor.lang.flash.quality,
'default': 'high',
style: 'width : 100%;',
@@ -529,6 +537,7 @@
{
id: 'align',
type: 'select',
requiredContent: 'object[align]',
label: editor.lang.common.align,
'default': '',
style: 'width : 100%;',
@@ -613,6 +622,7 @@
{
type: 'text',
id: 'id',
requiredContent: 'object[id]',
label: editor.lang.common.id,
setup: loadValue,
commit: commitValue
@@ -626,13 +636,15 @@
{
type: 'text',
id: 'bgcolor',
requiredContent: 'embed[bgcolor]',
label: editor.lang.flash.bgcolor,
setup: loadValue,
commit: commitValue
},
{
type: 'text',
id: 'class',
requiredContent: 'embed(cke-xyz)', // Random text like 'xyz' will check if all are allowed.
label: editor.lang.common.cssClass,
setup: loadValue,
commit: commitValue
@@ -642,6 +654,7 @@
{
type: 'text',
id: 'style',
requiredContent: 'embed{cke-xyz}', // Random text like 'xyz' will check if all are allowed.
validate: CKEDITOR.dialog.validate.inlineStyle( editor.lang.common.invalidInlineStyle ),
label: editor.lang.common.cssStyle,
setup: loadValue,
@@ -34,10 +34,17 @@

},
init: function( editor ) {
var allowed = 'object[classid,codebase,height,hspace,vspace,width];' +
'param[name,value];' +
'embed[height,hspace,pluginspage,src,type,vspace,width]';

if ( CKEDITOR.dialog.isTabEnabled( editor, 'flash', 'properties' ) )
allowed += ';object[align]; embed[allowscriptaccess,quality,scale,wmode]';
if ( CKEDITOR.dialog.isTabEnabled( editor, 'flash', 'advanced' ) )
allowed += ';object[id]{*}; embed[bgcolor]{*}(*)';

editor.addCommand( 'flash', new CKEDITOR.dialogCommand( 'flash', {
allowedContent: 'object[align,classid,codebase,height,hspace,vspace,width]{*}(*);' +
'param[name,value];' +
'embed[allowscriptaccess,bgcolor,height,hspace,pluginspage,quality,scale,src,type,vspace,width,wmode]{*}(*)',
allowedContent: allowed,
requiredContent: 'embed'
} ) );
editor.ui.addButton && editor.ui.addButton( 'Flash', {
Oops, something went wrong.

0 comments on commit c7cf983

Please sign in to comment.
You can’t perform that action at this time.