Ticket #6462: 6462.patch
File 6462.patch, 9.3 KB (added by , 14 years ago) |
---|
-
_source/plugins/flash/dialogs/flash.js
366 366 id : 'width', 367 367 style : 'width:95px', 368 368 label : editor.lang.flash.width, 369 validate : CKEDITOR.dialog.validate.integer( editor.lang.flash.validateWidth ), 369 validate : CKEDITOR.dialog.validate.cssLength( editor.lang.flash.validateWidth ), 370 setValue : function( val ) { return isNaN( parseInt( val, 10 ) ) ? '' : val; }, 371 getValue : function( raw ) { return raw + ( isNaN( Number( raw ) ) ? '' : 'px' ); }, 370 372 setup : function( objectNode, embedNode, paramMap, fakeImage ) 371 373 { 372 374 loadValue.apply( this, arguments ); 373 375 if ( fakeImage ) 374 { 375 var fakeImageWidth = parseInt( fakeImage.$.style.width, 10 ); 376 if ( !isNaN( fakeImageWidth ) ) 377 this.setValue( fakeImageWidth ); 378 } 376 this.setValue( fakeImage.$.style.width ); 379 377 }, 380 378 commit : function( objectNode, embedNode, paramMap, extraStyles ) 381 379 { 382 380 commitValue.apply( this, arguments ); 383 if ( this.getValue() )384 extraStyles.width = this.getValue() + 'px';381 var val = this.getValue(); 382 val && ( extraStyles.width = val ); 385 383 } 386 384 }, 387 385 { … … 389 387 id : 'height', 390 388 style : 'width:95px', 391 389 label : editor.lang.flash.height, 392 validate : CKEDITOR.dialog.validate.integer( editor.lang.flash.validateHeight ), 390 validate : CKEDITOR.dialog.validate.cssLength( editor.lang.flash.validateHeight ), 391 setValue : function( val ) { return isNaN( parseInt( val, 10 ) ) ? '' : val; }, 392 getValue : function( raw ) { return raw + ( isNaN( Number( raw ) ) ? '' : 'px' ); }, 393 393 setup : function( objectNode, embedNode, paramMap, fakeImage ) 394 394 { 395 395 loadValue.apply( this, arguments ); 396 396 if ( fakeImage ) 397 { 398 var fakeImageHeight = parseInt( fakeImage.$.style.height, 10 ); 399 if ( !isNaN( fakeImageHeight ) ) 400 this.setValue( fakeImageHeight ); 401 } 397 this.setValue( fakeImage.$.style.height ); 402 398 }, 403 399 commit : function( objectNode, embedNode, paramMap, extraStyles ) 404 400 { 405 401 commitValue.apply( this, arguments ); 406 if ( this.getValue() )407 extraStyles.height = this.getValue() + 'px';402 var val = this.getValue(); 403 val && ( extraStyles.height = val ); 408 404 } 409 405 }, 410 406 { -
_source/plugins/dialog/plugin.js
2158 2158 if ( typeof( elementDefinition.isChanged ) == 'function' ) 2159 2159 this.isChanged = elementDefinition.isChanged; 2160 2160 2161 // Overload 'get(set)Value' on definition. 2162 if ( typeof( elementDefinition.setValue ) == 'function' ) 2163 { 2164 this.setValue = CKEDITOR.tools.override( this.setValue, function( org ) 2165 { 2166 return function( val ){ org.call( this, elementDefinition.setValue.call( this, val ) ); }; 2167 } ); 2168 } 2169 2170 if ( typeof( elementDefinition.getValue ) == 'function' ) 2171 { 2172 this.getValue = CKEDITOR.tools.override( this.getValue, function( org ) 2173 { 2174 return function(){ return elementDefinition.getValue.call( this, org.call( this ) ); }; 2175 } ); 2176 } 2177 2161 2178 // Add events. 2162 2179 CKEDITOR.event.implementOn( this ); 2163 2180 … … 2741 2758 { 2742 2759 var notEmptyRegex = /^([a]|[^a])+$/, 2743 2760 integerRegex = /^\d*$/, 2744 numberRegex = /^\d*(?:\.\d+)?$/; 2761 numberRegex = /^\d*(?:\.\d+)?$/, 2762 cssLengthRegex = /(^[+-]?\d+(px|em|ex|in|cm|mm|pt|pc|\%)?$)|^$/i; 2745 2763 2746 2764 CKEDITOR.VALIDATE_OR = 1; 2747 2765 CKEDITOR.VALIDATE_AND = 2; … … 2750 2768 { 2751 2769 functions : function() 2752 2770 { 2771 var args = arguments; 2753 2772 return function() 2754 2773 { 2755 2774 /** … … 2758 2777 * combine validate functions together to make more sophisticated 2759 2778 * validators. 2760 2779 */ 2761 var value = this && this.getValue ? this.getValue() : arg uments[0];2780 var value = this && this.getValue ? this.getValue() : args[0]; 2762 2781 2763 2782 var msg = undefined, 2764 2783 relation = CKEDITOR.VALIDATE_AND, 2765 2784 functions = [], i; 2766 2785 2767 for ( i = 0 ; i < arg uments.length ; i++ )2786 for ( i = 0 ; i < args.length ; i++ ) 2768 2787 { 2769 if ( typeof( arg uments[i] ) == 'function' )2770 functions.push( arg uments[i] );2788 if ( typeof( args[i] ) == 'function' ) 2789 functions.push( args[i] ); 2771 2790 else 2772 2791 break; 2773 2792 } 2774 2793 2775 if ( i < arg uments.length && typeof( arguments[i] ) == 'string' )2794 if ( i < args.length && typeof( args[i] ) == 'string' ) 2776 2795 { 2777 msg = arg uments[i];2796 msg = args[i]; 2778 2797 i++; 2779 2798 } 2780 2799 2781 if ( i < arg uments.length && typeof( arguments[i]) == 'number' )2782 relation = arg uments[i];2800 if ( i < args.length && typeof( args[i]) == 'number' ) 2801 relation = args[i]; 2783 2802 2784 2803 var passed = ( relation == CKEDITOR.VALIDATE_AND ? true : false ); 2785 2804 for ( i = 0 ; i < functions.length ; i++ ) … … 2844 2863 return this.regex( numberRegex, msg ); 2845 2864 }, 2846 2865 2866 'cssLength' : function( msg ) 2867 { 2868 return this.functions( function( val ){ return cssLengthRegex.test( CKEDITOR.tools.trim( val ) ); }, msg ); 2869 }, 2870 2847 2871 equals : function( value, msg ) 2848 2872 { 2849 2873 return this.functions( function( val ){ return val == value; }, msg ); -
_source/plugins/table/dialogs/table.js
547 547 id : 'txtCellSpace', 548 548 style : 'width:3em', 549 549 label : editor.lang.table.cellSpace, 550 'default' : 1, 551 validate : CKEDITOR.dialog.validate['number']( editor.lang.table.invalidCellSpacing ), 550 'default' : '1px', 551 validate : CKEDITOR.dialog.validate.cssLength( editor.lang.table.invalidCellSpacing ), 552 setValue : function( val ) { return isNaN( parseInt( val, 10 ) ) ? '' : val; }, 553 getValue : function( raw ) { return raw + ( isNaN( Number( raw ) ) ? '' : 'px' ); }, 552 554 setup : function( selectedTable ) 553 555 { 554 this.setValue( selectedTable.getAttribute( 'cellSpacing' ) || '');556 this.setValue( selectedTable.getAttribute( 'cellSpacing' ) ); 555 557 }, 556 558 commit : function( data, selectedTable ) 557 559 { 558 if ( this.getValue() ) 559 selectedTable.setAttribute( 'cellSpacing', this.getValue() ); 560 else 561 selectedTable.removeAttribute( 'cellSpacing' ); 560 var val = this.getValue(); 561 val ? selectedTable.setAttribute( 'cellSpacing', val ) 562 : selectedTable.removeAttribute( 'cellSpacing' ); 562 563 } 563 564 }, 564 565 { … … 566 567 id : 'txtCellPad', 567 568 style : 'width:3em', 568 569 label : editor.lang.table.cellPad, 569 'default' : 1, 570 validate : CKEDITOR.dialog.validate['number']( editor.lang.table.invalidCellPadding ), 570 'default' : '1px', 571 validate : CKEDITOR.dialog.validate.cssLength( editor.lang.table.invalidCellPadding ), 572 setValue : function( val ) { return isNaN( parseInt( val, 10 ) ) ? '' : val; }, 573 getValue : function( raw ) { return raw + ( isNaN( Number( raw ) ) ? '' : 'px' ); }, 571 574 setup : function( selectedTable ) 572 575 { 573 this.setValue( selectedTable.getAttribute( 'cellPadding' ) || '');576 this.setValue( selectedTable.getAttribute( 'cellPadding' ) ); 574 577 }, 575 578 commit : function( data, selectedTable ) 576 579 { 577 if ( this.getValue() ) 578 selectedTable.setAttribute( 'cellPadding', this.getValue() ); 579 else 580 selectedTable.removeAttribute( 'cellPadding' ); 580 var val = this.getValue(); 581 val ? selectedTable.setAttribute( 'cellPadding', val ) 582 : selectedTable.removeAttribute( 'cellPadding' ); 581 583 } 582 584 } 583 585 ] -
_source/plugins/fakeobjects/plugin.js
25 25 if ( style ) 26 26 { 27 27 // Get the width from the style. 28 var match = /(?:^|\s)width\s*:\s*( \d+)/i.exec( style ),28 var match = /(?:^|\s)width\s*:\s*(.*?)(:?;|$)/i.exec( style ), 29 29 width = match && match[1]; 30 30 31 31 // Get the height from the style. 32 match = /(?:^|\s)height\s*:\s*( \d+)/i.exec( style );32 match = /(?:^|\s)height\s*:\s*(.*?)(:?;|$)/i.exec( style ); 33 33 var height = match && match[1]; 34 34 35 35 if ( width )