Opened 18 years ago
Last modified 11 years ago
#731 confirmed Bug
0 border tables have a border when sent to a printer
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | General | Version: | FCKeditor 2.5.1 |
Keywords: | SF | Cc: | Frederico Caldeira Knabben |
Description
fck_showtableborders_gecko.css defines the rules to show border="0" table borders on Gecko when editing. But those borders are present if you send your document to a printer, which is not a good thing... I link a patch i use for this file to hide the border="0" tables border on a printer.
Moved from SF:
http://sourceforge.net/tracker/index.php?func=detail&aid=1491546&group_id=75348&atid=543653
Attachments (1)
Change History (8)
comment:1 Changed 18 years ago by
Reporter: | changed from Martin Kou to rhum1@… |
---|
Changed 18 years ago by
Attachment: | fck_showtableborders_gecko.css added |
---|
comment:2 Changed 17 years ago by
Keywords: | Confirmed added |
---|---|
Version: | → FCKeditor 2.5.1 |
comment:6 Changed 11 years ago by
Here is a workaround for iframed editor:
function hideBorderZeroOnPrint( classname ){ var node = editor.document.$.getElementsByTagName( 'body' )[0];//iframed editor var elements = node.getElementsByTagName( 'table' ); for( var i=0, len=elements.length ; i<len ; i++ ){ var helper = elements[i].getAttribute('class'); if(helper) elements[i].setAttribute('class', helper.replace(classname,'')); } } function showBorderZeroAfterPrint( classname ){ var node = editor.document.$.getElementsByTagName( 'body' )[0];//iframed editor var elements = node.getElementsByTagName( 'table' ); for( var i=0, len=elements.length ; i<len ; i++ ){ var bor = elements[i].getAttribute('border'); if(bor && bor == 0){ var helper = elements[i].getAttribute('class'); elements[i].setAttribute('class', helper ? helper.concat(classname) : classname); } } } var editor = CKEDITOR.replace( 'editor1'); editor.on( 'instanceReady', function( evt ) { editor.on('beforeCommandExec', function( event ){ if( event.data.name == 'print' ) hideBorderZeroOnPrint('cke_show_border'); }); editor.on('afterCommandExec', function( event ){ if( event.data.name == 'print' ) showBorderZeroAfterPrint('cke_show_border'); }); });
comment:7 Changed 11 years ago by
This seems to work for inline editor:
<body onbeforeprint="hideBorderZeroOnPrint('cke_show_border');" onafterprint="showBorderZeroAfterPrint('cke_show_border');"> ... CKEDITOR.disableAutoInline = true; var editor = CKEDITOR.inline( 'editable' ); function hideBorderZeroOnPrint( classname ){ var node = document.getElementsByTagName( 'body' )[0];//inline editor var elements = node.getElementsByTagName( 'table' ); for( var i=0, len=elements.length ; i<len ; i++ ){ var helper = elements[i].getAttribute('class'); if(helper) elements[i].setAttribute('class', helper.replace(classname,'')); } } function showBorderZeroAfterPrint( classname ){ var node = document.getElementsByTagName( 'body' )[0];//inline editor var elements = node.getElementsByTagName( 'table' ); for( var i=0, len=elements.length ; i<len ; i++ ){ var bor = elements[i].getAttribute('border'); if(bor && bor == 0) elements[i].setAttribute('class', elements[i].getAttribute('class').concat(classname)); } }
Please note however that onbeforeprint and onafterprint are only supported in Firefox and IE.
I was able to have the same result by simply using "@media screen" for the current contents actually.
But it doesn't solve other things, like the anchor icon, for example.
More investigation will be done in this sense. For now, it is better to have the same output visible in the editor when printing, instead of having a mixture of final layout and current editor layout.
Moved from SF. Original poster: fredck