Ticket #7981: 7981_2.patch
File 7981_2.patch, 7.7 KB (added by , 12 years ago) |
---|
-
_source/plugins/pastefromword/filter/default.js
261 261 { 262 262 // Deal with component/short-hand form. 263 263 var values = margin.split( ' ' ); 264 margin = plugin.utils.convertToPx( values[ 3 ] || values[ 1 ] || values [ 0 ] ); 265 margin = parseInt( margin, 10 ); 264 margin = CKEDITOR.tools.convertToPx( values[ 3 ] || values[ 1 ] || values [ 0 ] ); 266 265 267 266 // Figure out the indent unit by checking the first time of incrementation. 268 267 if ( !listBaseIndent && previousListItemMargin !== null && margin > previousListItemMargin ) … … 310 309 return false; 311 310 }, 312 311 313 // Convert various length units to 'px' in ignorance of DPI.314 convertToPx : ( function ()315 {316 var calculator = CKEDITOR.dom.element.createFromHtml(317 '<div style="position:absolute;left:-9999px;' +318 'top:-9999px;margin:0px;padding:0px;border:0px;"' +319 '></div>', CKEDITOR.document );320 CKEDITOR.document.getBody().append( calculator );321 322 return function( cssLength )323 {324 if ( cssLengthRelativeUnit.test( cssLength ) )325 {326 calculator.setStyle( 'width', cssLength );327 return calculator.$.clientWidth + 'px';328 }329 330 return cssLength;331 };332 } )(),333 334 312 // Providing a shorthand style then retrieve one or more style component values. 335 313 getStyleComponents : ( function() 336 314 { … … 423 401 [ 'tab-stops', null, function( val ) 424 402 { 425 403 var margin = val.split( ' ' )[ 1 ].match( cssLengthRelativeUnit ); 426 margin && ( previousListItemMargin = parseInt( plugin.utils.convertToPx( margin[ 0 ] ), 10) );404 margin && ( previousListItemMargin = CKEDITOR.tools.convertToPx( margin[ 0 ] ) ); 427 405 } ], 428 406 ( level == 1 ? [ 'mso-list', null, function( val ) 429 407 { … … 779 757 isListBulletIndicator = this.utils.isListBulletIndicator, 780 758 containsNothingButSpaces = this.utils.isContainingOnlySpaces, 781 759 resolveListItem = this.utils.resolveList, 782 convertToPx = this.utils.convertToPx, 760 convertToPx = function( value ) 761 { 762 value = CKEDITOR.tools.convertToPx( value ); 763 return isNaN( value ) ? value : value + 'px'; 764 }, 783 765 getStyleComponents = this.utils.getStyleComponents, 784 766 listDtdParents = this.utils.listDtdParents, 785 767 removeFontStyles = config.pasteFromWordRemoveFontStyles !== false, -
_source/plugins/iframe/dialogs/iframe.js
50 50 title : iframeLang.title, 51 51 minWidth : 350, 52 52 minHeight : 260, 53 onLoad : function()54 {55 var dialog = this,56 styles = dialog.getContentElement( 'advanced', 'advStyles' );57 58 styles && styles.on( 'change', function()59 {60 // Synchronize width value.61 var width = this.getStyle( 'width', '' ),62 txtWidth = dialog.getContentElement( 'info', 'width' );63 64 txtWidth && txtWidth.setValue( width, true );65 66 // Synchronize height value.67 var height = this.getStyle( 'height', '' ),68 txtHeight = dialog.getContentElement( 'info', 'height' );69 70 txtHeight && txtHeight.setValue( height, true );71 });72 },73 53 onShow : function() 74 54 { 75 55 // Clear previously saved elements. … … 83 63 var iframeNode = editor.restoreRealElement( fakeImage ); 84 64 this.iframeNode = iframeNode; 85 65 86 this.setupContent( iframeNode , fakeImage);66 this.setupContent( iframeNode ); 87 67 } 88 89 // Call the onChange method for the widht and height fields so90 // they get reflected into the Advanced tab.91 var widthInput = this.getContentElement( 'info', 'width' ),92 heightInput = this.getContentElement( 'info', 'height' );93 widthInput && widthInput.onChange();94 heightInput && heightInput.onChange();95 68 }, 96 69 onOk : function() 97 70 { … … 152 125 style : 'width:100%', 153 126 labelLayout : 'vertical', 154 127 label : commonLang.width, 155 validate : CKEDITOR.dialog.validate. cssLength( editor.lang.common.invalidCssLength ),128 validate : CKEDITOR.dialog.validate.htmlLength( editor.lang.common.invalidHtmlLength ), 156 129 getValue : defaultToPixel, 157 130 setup : function( iframeNode, fakeImage ) 158 131 { … … 164 137 commitValue.apply( this, arguments ); 165 138 var val = this.getValue(); 166 139 val && ( extraStyles.width = val ); 167 },168 onChange : function()169 {170 var styles = this.getDialog().getContentElement( 'advanced', 'advStyles' ),171 value = this.getValue();172 styles && styles.updateStyle( 'width', value );173 140 } 174 141 }, 175 142 { … … 178 145 style : 'width:100%', 179 146 labelLayout : 'vertical', 180 147 label : commonLang.height, 181 validate : CKEDITOR.dialog.validate. cssLength( editor.lang.common.invalidCssLength ),148 validate : CKEDITOR.dialog.validate.htmlLength( editor.lang.common.invalidHtmlLength ), 182 149 getValue : defaultToPixel, 183 150 setup : function( iframeNode, fakeImage ) 184 151 { … … 190 157 commitValue.apply( this, arguments ); 191 158 var val = this.getValue(); 192 159 val && ( extraStyles.height = val ); 193 },194 onChange : function()195 {196 var styles = this.getDialog().getContentElement( 'advanced', 'advStyles' ),197 value = this.getValue();198 styles && styles.updateStyle( 'height', value );199 160 } 200 161 }, 201 162 { -
_source/plugins/fakeobjects/plugin.js
33 33 var height = match && match[1]; 34 34 35 35 if ( width ) 36 realElement.attributes.width = width;36 realElement.attributes.width = CKEDITOR.tools.convertToPx( width ); 37 37 38 38 if ( height ) 39 realElement.attributes.height = height;39 realElement.attributes.height = CKEDITOR.tools.convertToPx( height ); 40 40 } 41 41 } 42 42 -
_source/core/tools.js
687 687 })(), 688 688 689 689 /** 690 * Convert the specified CSS length value to the calculated pixel length inside this page. 691 * <strong>Note:</strong> Percentage based value is left intact. 692 * @param {String} cssLength CSS length value. 693 */ 694 convertToPx : ( function () 695 { 696 var calculator; 697 698 return function( cssLength ) 699 { 700 if ( !calculator ) 701 { 702 calculator = CKEDITOR.dom.element.createFromHtml( 703 '<div style="position:absolute;left:-9999px;' + 704 'top:-9999px;margin:0px;padding:0px;border:0px;"' + 705 '></div>', CKEDITOR.document ); 706 CKEDITOR.document.getBody().append( calculator ); 707 } 708 709 if ( !/%$/.test( cssLength ) ) 710 { 711 calculator.setStyle( 'width', cssLength ); 712 return calculator.$.clientWidth; 713 } 714 715 return cssLength; 716 }; 717 } )(), 718 719 /** 690 720 * String specified by {@param str} repeats {@param times} times. 691 721 * @param str 692 722 * @param times