Ticket #4893: 4893.patch
File 4893.patch, 9.7 KB (added by , 13 years ago) |
---|
-
_source/plugins/tabletools/dialogs/tableCell.js
104 104 widths : [ '71%', '29%' ], 105 105 labelLayout : 'horizontal', 106 106 validate : validate[ 'number' ]( langCell.invalidWidth ), 107 setup : function( selectedCell)107 setup : function( element ) 108 108 { 109 var widthMatch = widthPattern.exec( selectedCell.$.style.width ); 110 if ( widthMatch ) 111 this.setValue( widthMatch[1] ); 109 var widthAttr = parseInt( element.getAttribute( 'width' ), 10 ), 110 widthStyle = parseInt( element.getStyle( 'width' ), 10 ); 111 112 !isNaN( widthAttr ) && this.setValue( widthAttr ); 113 !isNaN( widthStyle ) && this.setValue( widthStyle ); 112 114 }, 113 commit : function( selectedCell)115 commit : function( element ) 114 116 { 115 var unit = this.getDialog().getValueOf( 'info', 'widthType' ); 116 if ( this.getValue() !== '' ) 117 selectedCell.$.style.width = this.getValue() + unit; 117 var value = parseInt( this.getValue(), 10 ), 118 unit = this.getDialog().getValueOf( 'info', 'widthType' ); 119 120 if ( !isNaN( value ) ) 121 element.setStyle( 'width', value + unit ); 118 122 else 119 selectedCell.$.style.width = ''; 123 element.removeStyle( 'width' ); 124 125 element.removeAttribute( 'width' ); 120 126 }, 121 127 'default' : '' 122 128 }, … … 154 160 widths : [ '71%', '29%' ], 155 161 labelLayout : 'horizontal', 156 162 validate : validate[ 'number' ]( langCell.invalidHeight ), 157 setup : function( selectedCell)163 setup : function( element ) 158 164 { 159 var heightMatch = heightPattern.exec( selectedCell.$.style.height ); 160 if ( heightMatch ) 161 this.setValue( heightMatch[1] ); 165 var heightAttr = parseInt( element.getAttribute( 'height' ), 10 ), 166 heightStyle = parseInt( element.getStyle( 'height' ), 10 ); 167 168 !isNaN( heightAttr ) && this.setValue( heightAttr ); 169 !isNaN( heightStyle ) && this.setValue( heightStyle ); 162 170 }, 163 commit : function( selectedCell)171 commit : function( element ) 164 172 { 165 if ( this.getValue() !== '' ) 166 selectedCell.$.style.height = this.getValue() + 'px'; 173 var value = parseInt( this.getValue(), 10 ); 174 175 if ( !isNaN( value ) ) 176 element.setStyle( 'height', CKEDITOR.tools.cssLength( value ) ); 167 177 else 168 selectedCell.$.style.height = ''; 178 element.removeStyle( 'height' ); 179 180 element.removeAttribute( 'height' ); 169 181 } 170 182 }, 171 183 { … … 187 199 [ langCell.yes, 'yes' ], 188 200 [ langCell.no, 'no' ] 189 201 ], 190 setup : function( selectedCell)202 setup : function( element ) 191 203 { 192 if ( selectedCell.getAttribute( 'noWrap' ) ) 204 var wordWrapAttr = element.getAttribute( 'noWrap' ), 205 wordWrapStyle = element.getStyle( 'white-space' ); 206 207 if ( wordWrapStyle == 'nowrap' || wordWrapAttr ) 193 208 this.setValue( 'no' ); 194 209 }, 195 commit : function( selectedCell)210 commit : function( element ) 196 211 { 197 212 if ( this.getValue() == 'no' ) 198 selectedCell.setAttribute( 'noWrap', 'nowrap' );213 element.setStyle( 'white-space', 'nowrap' ); 199 214 else 200 selectedCell.removeAttribute( 'noWrap' ); 215 element.removeStyle( 'white-space' ); 216 217 element.removeAttribute( 'noWrap' ); 201 218 } 202 219 }, 203 220 spacer(), … … 215 232 [ langTable.alignCenter, 'center' ], 216 233 [ langTable.alignRight, 'right' ] 217 234 ], 218 setup : function( selectedCell)235 setup : function( element ) 219 236 { 220 this.setValue( selectedCell.getAttribute( 'align' ) || '' ); 237 var alignAttr = element.getAttribute( 'align' ), 238 textAlignStyle = element.getStyle( 'text-align'); 239 240 this.setValue( textAlignStyle || alignAttr ); 221 241 }, 222 242 commit : function( selectedCell ) 223 243 { 224 if ( this.getValue() ) 225 selectedCell.setAttribute( 'align', this.getValue() ); 244 var value = this.getValue(); 245 246 if ( value ) 247 selectedCell.setStyle( 'text-align', value ); 226 248 else 227 selectedCell.removeAttribute( 'align' ); 249 selectedCell.removeStyle( 'text-align' ); 250 251 selectedCell.removeAttribute( 'align' ); 228 252 } 229 253 }, 230 254 { … … 242 266 [ langCell.alignBottom, 'bottom' ], 243 267 [ langCell.alignBaseline, 'baseline' ] 244 268 ], 245 setup : function( selectedCell)269 setup : function( element ) 246 270 { 247 this.setValue( selectedCell.getAttribute( 'vAlign' ) || '' ); 271 var vAlignAttr = element.getAttribute( 'vAlign' ), 272 vAlignStyle = element.getStyle( 'vertical-align' ); 273 274 switch( vAlignStyle ) 275 { 276 // Ignore all other unrelated style values.. 277 case 'top': 278 case 'middle': 279 case 'bottom': 280 case 'baseline': 281 break; 282 default: 283 vAlignStyle = ''; 284 } 285 286 this.setValue( vAlignStyle || vAlignAttr ); 248 287 }, 249 commit : function( selectedCell)288 commit : function( element ) 250 289 { 251 if ( this.getValue() ) 252 selectedCell.setAttribute( 'vAlign', this.getValue() ); 290 var value = this.getValue(); 291 292 if ( value ) 293 element.setStyle( 'vertical-align', value ); 253 294 else 254 selectedCell.removeAttribute( 'vAlign' ); 295 element.removeStyle( 'vertical-align' ); 296 297 element.removeAttribute( 'vAlign' ); 255 298 } 256 299 } 257 300 ] … … 294 337 validate : validate.integer( langCell.invalidRowSpan ), 295 338 setup : function( selectedCell ) 296 339 { 297 this.setValue( selectedCell.getAttribute( 'rowSpan' ) || '' ); 340 var attrVal = parseInt( selectedCell.getAttribute( 'rowSpan' ), 10 ); 341 attrVal != 1 && this.setValue( attrVal ); 298 342 }, 299 343 commit : function( selectedCell ) 300 344 { … … 312 356 widths : [ '50%', '50%' ], 313 357 'default' : '', 314 358 validate : validate.integer( langCell.invalidColSpan ), 315 setup : function( selectedCell)359 setup : function( element ) 316 360 { 317 this.setValue( selectedCell.getAttribute( 'colSpan' ) || '' ); 361 var attrVal = parseInt( element.getAttribute( 'colSpan' ), 10 ); 362 attrVal != 1 && this.setValue( attrVal ); 318 363 }, 319 364 commit : function( selectedCell ) 320 365 { … … 338 383 labelLayout : 'horizontal', 339 384 widths : [ '70%', '30%' ], 340 385 'default' : '', 341 setup : function( selectedCell)386 setup : function( element ) 342 387 { 343 this.setValue( selectedCell.getAttribute( 'bgColor' ) || '' ); 388 var bgColorAttr = element.getAttribute( 'bgColor' ), 389 bgColorStyle = element.getStyle( 'background-color' ); 390 391 this.setValue( bgColorStyle || bgColorAttr ); 344 392 }, 345 393 commit : function( selectedCell ) 346 394 { 347 if ( this.getValue() ) 348 selectedCell.setAttribute( 'bgColor', this.getValue() ); 395 var value = this.getValue(); 396 397 if ( value ) 398 selectedCell.setStyle( 'background-color', this.getValue() ); 349 399 else 350 selectedCell.removeAttribute( 'bgColor' ); 400 selectedCell.removeStyle( 'background-color' ); 401 402 selectedCell.removeAttribute( 'bgColor'); 351 403 } 352 404 }, 353 405 { … … 382 434 labelLayout : 'horizontal', 383 435 widths : [ '70%', '30%' ], 384 436 'default' : '', 385 setup : function( selectedCell)437 setup : function( element ) 386 438 { 387 this.setValue( selectedCell.getStyle( 'border-color' ) || '' ); 439 var borderColorAttr = element.getAttribute( 'borderColor' ), 440 borderColorStyle = element.getStyle( 'background-color' ); 441 442 this.setValue( borderColorStyle || borderColorAttr ); 388 443 }, 389 444 commit : function( selectedCell ) 390 445 { 391 if ( this.getValue() ) 446 var value = this.getValue(); 447 if ( value ) 392 448 selectedCell.setStyle( 'border-color', this.getValue() ); 393 449 else 394 450 selectedCell.removeStyle( 'border-color' ); 451 452 selectedCell.removeAttribute( 'borderColor'); 395 453 } 396 454 }, 397 455 {