1 | /** |
---|
2 | * @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. |
---|
3 | * For licensing, see LICENSE.html or http://ckeditor.com/license |
---|
4 | */ |
---|
5 | |
---|
6 | /** |
---|
7 | * @fileOverview Print Plugin |
---|
8 | */ |
---|
9 | |
---|
10 | CKEDITOR.plugins.add( 'print', { |
---|
11 | lang: 'af,ar,bg,bn,bs,ca,cs,cy,da,de,el,en,en-au,en-ca,en-gb,eo,es,et,eu,fa,fi,fo,fr,fr-ca,gl,gu,he,hi,hr,hu,is,it,ja,ka,km,ko,ku,lt,lv,mk,mn,ms,nb,nl,no,pl,pt,pt-br,ro,ru,si,sk,sl,sq,sr,sr-latn,sv,th,tr,ug,uk,vi,zh,zh-cn', // %REMOVE_LINE_CORE% |
---|
12 | icons: 'print,', // %REMOVE_LINE_CORE% |
---|
13 | init: function( editor ) { |
---|
14 | // Print plugin isn't available in inline mode yet. |
---|
15 | if ( editor.elementMode == CKEDITOR.ELEMENT_MODE_INLINE ) |
---|
16 | return; |
---|
17 | |
---|
18 | var pluginName = 'print'; |
---|
19 | |
---|
20 | // Register the command. |
---|
21 | var command = editor.addCommand( pluginName, CKEDITOR.plugins.print ); |
---|
22 | |
---|
23 | // Register the toolbar button. |
---|
24 | editor.ui.addButton && editor.ui.addButton( 'Print', { |
---|
25 | label: editor.lang.print.toolbar, |
---|
26 | command: pluginName, |
---|
27 | toolbar: 'document,50' |
---|
28 | }); |
---|
29 | } |
---|
30 | }); |
---|
31 | |
---|
32 | CKEDITOR.plugins.print = { |
---|
33 | exec: function( editor ) { |
---|
34 | if ( CKEDITOR.env.opera ) |
---|
35 | return; |
---|
36 | else if ( CKEDITOR.env.gecko ) |
---|
37 | editor.window.$.print(); |
---|
38 | else if ( CKEDITOR.env.air ) |
---|
39 | CKEDITOR.plugins.print.doPrintAir(); |
---|
40 | else |
---|
41 | editor.document.$.execCommand( "Print" ); |
---|
42 | }, |
---|
43 | canUndo: false, |
---|
44 | readOnly: 1, |
---|
45 | modes: { wysiwyg: !( CKEDITOR.env.opera ) }, // It is imposible to print the inner document in Opera. |
---|
46 | doPrintAir : function() { |
---|
47 | var pjob = new window.runtime.flash.printing.PrintJob; |
---|
48 | if ( pjob.start() ) { |
---|
49 | var poptions = new window.runtime.flash.printing.PrintJobOptions; |
---|
50 | poptions.printAsBitmap = true; |
---|
51 | try { |
---|
52 | pjob.addPage(window.htmlLoader, null, poptions); |
---|
53 | pjob.send(); |
---|
54 | } catch (err) { |
---|
55 | //console.log(err); |
---|
56 | } |
---|
57 | }//else{ |
---|
58 | //console.log("PrintJob couldn't start"); |
---|
59 | //} |
---|
60 | } |
---|
61 | }; |
---|