diff options
| author | lsces <lester@lsces.co.uk> | 2013-07-15 14:18:47 +0100 |
|---|---|---|
| committer | lsces <lester@lsces.co.uk> | 2013-07-15 14:18:47 +0100 |
| commit | de6d09676a9527919813a4474cc28af554a35fe1 (patch) | |
| tree | a2b3c2ddf01eca1600e130125733d324b59744bb /plugins/tabletools | |
| parent | 1d0d1733baef4dbab3f8cd7d7150a55ef2828464 (diff) | |
| download | ckeditor-de6d09676a9527919813a4474cc28af554a35fe1.tar.gz ckeditor-de6d09676a9527919813a4474cc28af554a35fe1.tar.bz2 ckeditor-de6d09676a9527919813a4474cc28af554a35fe1.zip | |
Upgrade to CKEditor V4
Directory structure changed so many files removed and replace in a new location
This batch is the actuall file changes
Diffstat (limited to 'plugins/tabletools')
| -rw-r--r-- | plugins/tabletools/dialogs/tableCell.js | 424 |
1 files changed, 417 insertions, 7 deletions
diff --git a/plugins/tabletools/dialogs/tableCell.js b/plugins/tabletools/dialogs/tableCell.js index eaa89ee..fff7e0e 100644 --- a/plugins/tabletools/dialogs/tableCell.js +++ b/plugins/tabletools/dialogs/tableCell.js @@ -1,8 +1,418 @@ -/*
-Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
-For licensing, see LICENSE.html or http://ckeditor.com/license
-*/
+/**
+ * @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.html or http://ckeditor.com/license
+ */
-CKEDITOR.dialog.add('cellProperties',function(a){var b=a.lang.table,c=b.cell,d=a.lang.common,e=CKEDITOR.dialog.validate,f=/^(\d+(?:\.\d+)?)(px|%)$/,g=/^(\d+(?:\.\d+)?)px$/,h=CKEDITOR.tools.bind,i={type:'html',html:' '},j=a.lang.dir=='rtl';function k(l,m){var n=function(){var r=this;p(r);m(r,r._.parentDialog);r._.parentDialog.changeFocus();},o=function(){p(this);this._.parentDialog.changeFocus();},p=function(r){r.removeListener('ok',n);r.removeListener('cancel',o);},q=function(r){r.on('ok',n);r.on('cancel',o);};a.execCommand(l);if(a._.storedDialogs.colordialog)q(a._.storedDialogs.colordialog);else CKEDITOR.on('dialogDefinition',function(r){if(r.data.name!=l)return;var s=r.data.definition;r.removeListener();s.onLoad=CKEDITOR.tools.override(s.onLoad,function(t){return function(){q(this);s.onLoad=t;if(typeof t=='function')t.call(this);};});});};return{title:c.title,minWidth:CKEDITOR.env.ie&&CKEDITOR.env.quirks?450:410,minHeight:CKEDITOR.env.ie&&(CKEDITOR.env.ie7Compat||CKEDITOR.env.quirks)?230:200,contents:[{id:'info',label:c.title,accessKey:'I',elements:[{type:'hbox',widths:['40%','5%','40%'],children:[{type:'vbox',padding:0,children:[{type:'hbox',widths:['70%','30%'],children:[{type:'text',id:'width',width:'100px',label:d.width,validate:e.number(c.invalidWidth),onLoad:function(){var l=this.getDialog().getContentElement('info','widthType'),m=l.getElement(),n=this.getInputElement(),o=n.getAttribute('aria-labelledby');n.setAttribute('aria-labelledby',[o,m.$.id].join(' '));},setup:function(l){var m=parseInt(l.getAttribute('width'),10),n=parseInt(l.getStyle('width'),10);!isNaN(m)&&this.setValue(m);!isNaN(n)&&this.setValue(n);},commit:function(l){var m=parseInt(this.getValue(),10),n=this.getDialog().getValueOf('info','widthType');if(!isNaN(m))l.setStyle('width',m+n);else l.removeStyle('width');l.removeAttribute('width');},'default':''},{type:'select',id:'widthType',label:a.lang.table.widthUnit,labelStyle:'visibility:hidden','default':'px',items:[[b.widthPx,'px'],[b.widthPc,'%']],setup:function(l){var m=f.exec(l.getStyle('width')||l.getAttribute('width'));if(m)this.setValue(m[2]);}}]},{type:'hbox',widths:['70%','30%'],children:[{type:'text',id:'height',label:d.height,width:'100px','default':'',validate:e.number(c.invalidHeight),onLoad:function(){var l=this.getDialog().getContentElement('info','htmlHeightType'),m=l.getElement(),n=this.getInputElement(),o=n.getAttribute('aria-labelledby');n.setAttribute('aria-labelledby',[o,m.$.id].join(' '));},setup:function(l){var m=parseInt(l.getAttribute('height'),10),n=parseInt(l.getStyle('height'),10);
-!isNaN(m)&&this.setValue(m);!isNaN(n)&&this.setValue(n);},commit:function(l){var m=parseInt(this.getValue(),10);if(!isNaN(m))l.setStyle('height',CKEDITOR.tools.cssLength(m));else l.removeStyle('height');l.removeAttribute('height');}},{id:'htmlHeightType',type:'html',html:'<br />'+b.widthPx}]},i,{type:'select',id:'wordWrap',label:c.wordWrap,'default':'yes',items:[[c.yes,'yes'],[c.no,'no']],setup:function(l){var m=l.getAttribute('noWrap'),n=l.getStyle('white-space');if(n=='nowrap'||m)this.setValue('no');},commit:function(l){if(this.getValue()=='no')l.setStyle('white-space','nowrap');else l.removeStyle('white-space');l.removeAttribute('noWrap');}},i,{type:'select',id:'hAlign',label:c.hAlign,'default':'',items:[[d.notSet,''],[d.alignLeft,'left'],[d.alignCenter,'center'],[d.alignRight,'right']],setup:function(l){var m=l.getAttribute('align'),n=l.getStyle('text-align');this.setValue(n||m||'');},commit:function(l){var m=this.getValue();if(m)l.setStyle('text-align',m);else l.removeStyle('text-align');l.removeAttribute('align');}},{type:'select',id:'vAlign',label:c.vAlign,'default':'',items:[[d.notSet,''],[d.alignTop,'top'],[d.alignMiddle,'middle'],[d.alignBottom,'bottom'],[c.alignBaseline,'baseline']],setup:function(l){var m=l.getAttribute('vAlign'),n=l.getStyle('vertical-align');switch(n){case 'top':case 'middle':case 'bottom':case 'baseline':break;default:n='';}this.setValue(n||m||'');},commit:function(l){var m=this.getValue();if(m)l.setStyle('vertical-align',m);else l.removeStyle('vertical-align');l.removeAttribute('vAlign');}}]},i,{type:'vbox',padding:0,children:[{type:'select',id:'cellType',label:c.cellType,'default':'td',items:[[c.data,'td'],[c.header,'th']],setup:function(l){this.setValue(l.getName());},commit:function(l){l.renameNode(this.getValue());}},i,{type:'text',id:'rowSpan',label:c.rowSpan,'default':'',validate:e.integer(c.invalidRowSpan),setup:function(l){var m=parseInt(l.getAttribute('rowSpan'),10);if(m&&m!=1)this.setValue(m);},commit:function(l){var m=parseInt(this.getValue(),10);if(m&&m!=1)l.setAttribute('rowSpan',this.getValue());else l.removeAttribute('rowSpan');}},{type:'text',id:'colSpan',label:c.colSpan,'default':'',validate:e.integer(c.invalidColSpan),setup:function(l){var m=parseInt(l.getAttribute('colSpan'),10);if(m&&m!=1)this.setValue(m);},commit:function(l){var m=parseInt(this.getValue(),10);if(m&&m!=1)l.setAttribute('colSpan',this.getValue());else l.removeAttribute('colSpan');}},i,{type:'hbox',padding:0,widths:['60%','40%'],children:[{type:'text',id:'bgColor',label:c.bgColor,'default':'',setup:function(l){var m=l.getAttribute('bgColor'),n=l.getStyle('background-color');
-this.setValue(n||m);},commit:function(l){var m=this.getValue();if(m)l.setStyle('background-color',this.getValue());else l.removeStyle('background-color');l.removeAttribute('bgColor');}},{type:'button',id:'bgColorChoose','class':'colorChooser',label:c.chooseColor,onLoad:function(){this.getElement().getParent().setStyle('vertical-align','bottom');},onClick:function(){var l=this;k('colordialog',function(m){l.getDialog().getContentElement('info','bgColor').setValue(m.getContentElement('picker','selectedColor').getValue());});}}]},i,{type:'hbox',padding:0,widths:['60%','40%'],children:[{type:'text',id:'borderColor',label:c.borderColor,'default':'',setup:function(l){var m=l.getAttribute('borderColor'),n=l.getStyle('border-color');this.setValue(n||m);},commit:function(l){var m=this.getValue();if(m)l.setStyle('border-color',this.getValue());else l.removeStyle('border-color');l.removeAttribute('borderColor');}},{type:'button',id:'borderColorChoose','class':'colorChooser',label:c.chooseColor,style:(j?'margin-right':'margin-left')+': 10px',onLoad:function(){this.getElement().getParent().setStyle('vertical-align','bottom');},onClick:function(){var l=this;k('colordialog',function(m){l.getDialog().getContentElement('info','borderColor').setValue(m.getContentElement('picker','selectedColor').getValue());});}}]}]}]}]}],onShow:function(){var l=this;l.cells=CKEDITOR.plugins.tabletools.getSelectedCells(l._.editor.getSelection());l.setupContent(l.cells[0]);},onOk:function(){var p=this;var l=p._.editor.getSelection(),m=l.createBookmarks(),n=p.cells;for(var o=0;o<n.length;o++)p.commitContent(n[o]);p._.editor.forceNextSelectionCheck();l.selectBookmarks(m);p._.editor.selectionChange();}};});
+CKEDITOR.dialog.add( 'cellProperties', function( editor ) {
+ var langTable = editor.lang.table,
+ langCell = langTable.cell,
+ langCommon = editor.lang.common,
+ validate = CKEDITOR.dialog.validate,
+ widthPattern = /^(\d+(?:\.\d+)?)(px|%)$/,
+ heightPattern = /^(\d+(?:\.\d+)?)px$/,
+ bind = CKEDITOR.tools.bind,
+ spacer = { type: 'html', html: ' ' },
+ rtl = editor.lang.dir == 'rtl',
+ colorDialog = editor.plugins.colordialog;
+
+ return {
+ title: langCell.title,
+ minWidth: CKEDITOR.env.ie && CKEDITOR.env.quirks ? 450 : 410,
+ minHeight: CKEDITOR.env.ie && ( CKEDITOR.env.ie7Compat || CKEDITOR.env.quirks ) ? 230 : 220,
+ contents: [
+ {
+ id: 'info',
+ label: langCell.title,
+ accessKey: 'I',
+ elements: [
+ {
+ type: 'hbox',
+ widths: [ '40%', '5%', '40%' ],
+ children: [
+ {
+ type: 'vbox',
+ padding: 0,
+ children: [
+ {
+ type: 'hbox',
+ widths: [ '70%', '30%' ],
+ children: [
+ {
+ type: 'text',
+ id: 'width',
+ width: '100px',
+ label: langCommon.width,
+ validate: validate[ 'number' ]( langCell.invalidWidth ),
+
+ // Extra labelling of width unit type.
+ onLoad: function() {
+ var widthType = this.getDialog().getContentElement( 'info', 'widthType' ),
+ labelElement = widthType.getElement(),
+ inputElement = this.getInputElement(),
+ ariaLabelledByAttr = inputElement.getAttribute( 'aria-labelledby' );
+
+ inputElement.setAttribute( 'aria-labelledby', [ ariaLabelledByAttr, labelElement.$.id ].join( ' ' ) );
+ },
+
+ setup: function( element ) {
+ var widthAttr = parseInt( element.getAttribute( 'width' ), 10 ),
+ widthStyle = parseInt( element.getStyle( 'width' ), 10 );
+
+ !isNaN( widthAttr ) && this.setValue( widthAttr );
+ !isNaN( widthStyle ) && this.setValue( widthStyle );
+ },
+ commit: function( element ) {
+ var value = parseInt( this.getValue(), 10 ),
+ unit = this.getDialog().getValueOf( 'info', 'widthType' );
+
+ if ( !isNaN( value ) )
+ element.setStyle( 'width', value + unit );
+ else
+ element.removeStyle( 'width' );
+
+ element.removeAttribute( 'width' );
+ },
+ 'default': ''
+ },
+ {
+ type: 'select',
+ id: 'widthType',
+ label: editor.lang.table.widthUnit,
+ labelStyle: 'visibility:hidden',
+ 'default': 'px',
+ items: [
+ [ langTable.widthPx, 'px' ],
+ [ langTable.widthPc, '%' ]
+ ],
+ setup: function( selectedCell ) {
+ var widthMatch = widthPattern.exec( selectedCell.getStyle( 'width' ) || selectedCell.getAttribute( 'width' ) );
+ if ( widthMatch )
+ this.setValue( widthMatch[ 2 ] );
+ }
+ }
+ ]
+ },
+ {
+ type: 'hbox',
+ widths: [ '70%', '30%' ],
+ children: [
+ {
+ type: 'text',
+ id: 'height',
+ label: langCommon.height,
+ width: '100px',
+ 'default': '',
+ validate: validate[ 'number' ]( langCell.invalidHeight ),
+
+ // Extra labelling of height unit type.
+ onLoad: function() {
+ var heightType = this.getDialog().getContentElement( 'info', 'htmlHeightType' ),
+ labelElement = heightType.getElement(),
+ inputElement = this.getInputElement(),
+ ariaLabelledByAttr = inputElement.getAttribute( 'aria-labelledby' );
+
+ inputElement.setAttribute( 'aria-labelledby', [ ariaLabelledByAttr, labelElement.$.id ].join( ' ' ) );
+ },
+
+ setup: function( element ) {
+ var heightAttr = parseInt( element.getAttribute( 'height' ), 10 ),
+ heightStyle = parseInt( element.getStyle( 'height' ), 10 );
+
+ !isNaN( heightAttr ) && this.setValue( heightAttr );
+ !isNaN( heightStyle ) && this.setValue( heightStyle );
+ },
+ commit: function( element ) {
+ var value = parseInt( this.getValue(), 10 );
+
+ if ( !isNaN( value ) )
+ element.setStyle( 'height', CKEDITOR.tools.cssLength( value ) );
+ else
+ element.removeStyle( 'height' );
+
+ element.removeAttribute( 'height' );
+ }
+ },
+ {
+ id: 'htmlHeightType',
+ type: 'html',
+ html: '<br />' + langTable.widthPx
+ }
+ ]
+ },
+ spacer,
+ {
+ type: 'select',
+ id: 'wordWrap',
+ label: langCell.wordWrap,
+ 'default': 'yes',
+ items: [
+ [ langCell.yes, 'yes' ],
+ [ langCell.no, 'no' ]
+ ],
+ setup: function( element ) {
+ var wordWrapAttr = element.getAttribute( 'noWrap' ),
+ wordWrapStyle = element.getStyle( 'white-space' );
+
+ if ( wordWrapStyle == 'nowrap' || wordWrapAttr )
+ this.setValue( 'no' );
+ },
+ commit: function( element ) {
+ if ( this.getValue() == 'no' )
+ element.setStyle( 'white-space', 'nowrap' );
+ else
+ element.removeStyle( 'white-space' );
+
+ element.removeAttribute( 'noWrap' );
+ }
+ },
+ spacer,
+ {
+ type: 'select',
+ id: 'hAlign',
+ label: langCell.hAlign,
+ 'default': '',
+ items: [
+ [ langCommon.notSet, '' ],
+ [ langCommon.alignLeft, 'left' ],
+ [ langCommon.alignCenter, 'center' ],
+ [ langCommon.alignRight, 'right' ]
+ ],
+ setup: function( element ) {
+ var alignAttr = element.getAttribute( 'align' ),
+ textAlignStyle = element.getStyle( 'text-align' );
+
+ this.setValue( textAlignStyle || alignAttr || '' );
+ },
+ commit: function( selectedCell ) {
+ var value = this.getValue();
+
+ if ( value )
+ selectedCell.setStyle( 'text-align', value );
+ else
+ selectedCell.removeStyle( 'text-align' );
+
+ selectedCell.removeAttribute( 'align' );
+ }
+ },
+ {
+ type: 'select',
+ id: 'vAlign',
+ label: langCell.vAlign,
+ 'default': '',
+ items: [
+ [ langCommon.notSet, '' ],
+ [ langCommon.alignTop, 'top' ],
+ [ langCommon.alignMiddle, 'middle' ],
+ [ langCommon.alignBottom, 'bottom' ],
+ [ langCell.alignBaseline, 'baseline' ]
+ ],
+ setup: function( element ) {
+ var vAlignAttr = element.getAttribute( 'vAlign' ),
+ vAlignStyle = element.getStyle( 'vertical-align' );
+
+ switch ( vAlignStyle ) {
+ // Ignore all other unrelated style values..
+ case 'top':
+ case 'middle':
+ case 'bottom':
+ case 'baseline':
+ break;
+ default:
+ vAlignStyle = '';
+ }
+
+ this.setValue( vAlignStyle || vAlignAttr || '' );
+ },
+ commit: function( element ) {
+ var value = this.getValue();
+
+ if ( value )
+ element.setStyle( 'vertical-align', value );
+ else
+ element.removeStyle( 'vertical-align' );
+
+ element.removeAttribute( 'vAlign' );
+ }
+ }
+ ]
+ },
+ spacer,
+ {
+ type: 'vbox',
+ padding: 0,
+ children: [
+ {
+ type: 'select',
+ id: 'cellType',
+ label: langCell.cellType,
+ 'default': 'td',
+ items: [
+ [ langCell.data, 'td' ],
+ [ langCell.header, 'th' ]
+ ],
+ setup: function( selectedCell ) {
+ this.setValue( selectedCell.getName() );
+ },
+ commit: function( selectedCell ) {
+ selectedCell.renameNode( this.getValue() );
+ }
+ },
+ spacer,
+ {
+ type: 'text',
+ id: 'rowSpan',
+ label: langCell.rowSpan,
+ 'default': '',
+ validate: validate.integer( langCell.invalidRowSpan ),
+ setup: function( selectedCell ) {
+ var attrVal = parseInt( selectedCell.getAttribute( 'rowSpan' ), 10 );
+ if ( attrVal && attrVal != 1 )
+ this.setValue( attrVal );
+ },
+ commit: function( selectedCell ) {
+ var value = parseInt( this.getValue(), 10 );
+ if ( value && value != 1 )
+ selectedCell.setAttribute( 'rowSpan', this.getValue() );
+ else
+ selectedCell.removeAttribute( 'rowSpan' );
+ }
+ },
+ {
+ type: 'text',
+ id: 'colSpan',
+ label: langCell.colSpan,
+ 'default': '',
+ validate: validate.integer( langCell.invalidColSpan ),
+ setup: function( element ) {
+ var attrVal = parseInt( element.getAttribute( 'colSpan' ), 10 );
+ if ( attrVal && attrVal != 1 )
+ this.setValue( attrVal );
+ },
+ commit: function( selectedCell ) {
+ var value = parseInt( this.getValue(), 10 );
+ if ( value && value != 1 )
+ selectedCell.setAttribute( 'colSpan', this.getValue() );
+ else
+ selectedCell.removeAttribute( 'colSpan' );
+ }
+ },
+ spacer,
+ {
+ type: 'hbox',
+ padding: 0,
+ widths: [ '60%', '40%' ],
+ children: [
+ {
+ type: 'text',
+ id: 'bgColor',
+ label: langCell.bgColor,
+ 'default': '',
+ setup: function( element ) {
+ var bgColorAttr = element.getAttribute( 'bgColor' ),
+ bgColorStyle = element.getStyle( 'background-color' );
+
+ this.setValue( bgColorStyle || bgColorAttr );
+ },
+ commit: function( selectedCell ) {
+ var value = this.getValue();
+
+ if ( value )
+ selectedCell.setStyle( 'background-color', this.getValue() );
+ else
+ selectedCell.removeStyle( 'background-color' );
+
+ selectedCell.removeAttribute( 'bgColor' );
+ }
+ },
+ colorDialog ? {
+ type: 'button',
+ id: 'bgColorChoose',
+ "class": 'colorChooser',
+ label: langCell.chooseColor,
+ onLoad: function() {
+ // Stick the element to the bottom (#5587)
+ this.getElement().getParent().setStyle( 'vertical-align', 'bottom' );
+ },
+ onClick: function() {
+ editor.getColorFromDialog( function( color ) {
+ if ( color )
+ this.getDialog().getContentElement( 'info', 'bgColor' ).setValue( color );
+ this.focus();
+ }, this );
+ }
+ } : spacer
+ ]
+ },
+ spacer,
+ {
+ type: 'hbox',
+ padding: 0,
+ widths: [ '60%', '40%' ],
+ children: [
+ {
+ type: 'text',
+ id: 'borderColor',
+ label: langCell.borderColor,
+ 'default': '',
+ setup: function( element ) {
+ var borderColorAttr = element.getAttribute( 'borderColor' ),
+ borderColorStyle = element.getStyle( 'border-color' );
+
+ this.setValue( borderColorStyle || borderColorAttr );
+ },
+ commit: function( selectedCell ) {
+ var value = this.getValue();
+ if ( value )
+ selectedCell.setStyle( 'border-color', this.getValue() );
+ else
+ selectedCell.removeStyle( 'border-color' );
+
+ selectedCell.removeAttribute( 'borderColor' );
+ }
+ },
+
+ colorDialog ? {
+ type: 'button',
+ id: 'borderColorChoose',
+ "class": 'colorChooser',
+ label: langCell.chooseColor,
+ style: ( rtl ? 'margin-right' : 'margin-left' ) + ': 10px',
+ onLoad: function() {
+ // Stick the element to the bottom (#5587)
+ this.getElement().getParent().setStyle( 'vertical-align', 'bottom' );
+ },
+ onClick: function() {
+ editor.getColorFromDialog( function( color ) {
+ if ( color )
+ this.getDialog().getContentElement( 'info', 'borderColor' ).setValue( color );
+ this.focus();
+ }, this );
+ }
+ } : spacer
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ onShow: function() {
+ this.cells = CKEDITOR.plugins.tabletools.getSelectedCells( this._.editor.getSelection() );
+ this.setupContent( this.cells[ 0 ] );
+ },
+ onOk: function() {
+ var selection = this._.editor.getSelection(),
+ bookmarks = selection.createBookmarks();
+
+ var cells = this.cells;
+ for ( var i = 0; i < cells.length; i++ )
+ this.commitContent( cells[ i ] );
+
+ this._.editor.forceNextSelectionCheck();
+ selection.selectBookmarks( bookmarks );
+ this._.editor.selectionChange();
+ }
+ };
+});
|
