source: trunk/filemanager/tp/ckeditor/_source/plugins/clipboard/dialogs/paste.js @ 2000

Revision 2000, 4.8 KB checked in by amuller, 14 years ago (diff)

Ticket #597 - Implementação do módulo gerenciador de arquivos

Line 
1/*
2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
3For licensing, see LICENSE.html or http://ckeditor.com/license
4*/
5
6CKEDITOR.dialog.add( 'paste', function( editor )
7{
8        var isCustomDomain = CKEDITOR.env.isCustomDomain();
9
10        return {
11                title : editor.lang.clipboard.title,
12
13                minWidth : CKEDITOR.env.ie && CKEDITOR.env.quirks ? 370 : 350,
14                minHeight : CKEDITOR.env.quirks ? 250 : 245,
15                htmlToLoad : '<!doctype html><script type="text/javascript">'
16                                + 'window.onload = function()'
17                                + '{'
18                                        + 'if ( ' + CKEDITOR.env.ie + ' ) '
19                                                + 'document.body.contentEditable = "true";'
20                                        + 'else '
21                                                + 'document.designMode = "on";'
22                                        + 'var iframe = new window.parent.CKEDITOR.dom.element( frameElement );'
23                                        + 'var dialog = iframe.getCustomData( "dialog" );'
24                      + ''
25                                        + 'iframe.getFrameDocument().on( "keydown", function( e )\
26                                                {\
27                                                        if ( e.data.getKeystroke() == 27 )\
28                                                                dialog.hide();\
29                                                });'
30                                + '};'
31                                + '</script><style>body { margin: 3px; height: 95%; } </style><body></body>',
32
33                onShow : function()
34                {
35                        if ( CKEDITOR.env.ie )
36                                this.getParentEditor().document.getBody().$.contentEditable = 'false';
37
38                        // FIREFOX BUG: Force the browser to render the dialog to make the to-be-
39                        // inserted iframe editable. (#3366)
40                        this.parts.dialog.$.offsetHeight;
41
42                        var container = this.getContentElement( 'general', 'editing_area' ).getElement(),
43                                iframe = CKEDITOR.dom.element.createFromHtml( '<iframe src="javascript:void(0)" frameborder="0" allowtransparency="1"></iframe>' );
44
45                        var lang = this.getParentEditor().lang;
46
47                        iframe.setStyles(
48                                {
49                                        width : '346px',
50                                        height : '130px',
51                                        'background-color' : 'white',
52                                        border : '1px solid black'
53                                } );
54                        iframe.setCustomData( 'dialog', this );
55
56                        var accTitle = lang.editorTitle.replace( '%1', lang.clipboard.title );
57
58                        if ( CKEDITOR.env.ie )
59                                container.setHtml( '<legend style="position:absolute;top:-1000000px;left:-1000000px;">'
60                                                + CKEDITOR.tools.htmlEncode( accTitle )
61                                                + '</legend>' );
62                        else
63                        {
64                                container.setHtml( '' );
65                                container.setAttributes(
66                                        {
67                                                role : 'region',
68                                                title : accTitle
69                                        } );
70                                iframe.setAttributes(
71                                        {
72                                                role : 'region',
73                                                title : ' '
74                                        } );
75                        }
76                        container.append( iframe );
77                        if ( CKEDITOR.env.ie )
78                                container.setStyle( 'height', ( iframe.$.offsetHeight + 2 ) + 'px' );
79
80                        if ( isCustomDomain )
81                        {
82                                CKEDITOR._cke_htmlToLoad = this.definition.htmlToLoad;
83                                iframe.setAttribute( 'src',
84                                        'javascript:void( (function(){' +
85                                                   'document.open();' +
86                                                   'document.domain="' + document.domain + '";' +
87                                                   'document.write( window.parent.CKEDITOR._cke_htmlToLoad );' +
88                                                   'delete window.parent.CKEDITOR._cke_htmlToLoad;' +
89                                                   'document.close();' +
90                                        '})() )' );
91                        }
92                        else
93                        {
94                                var doc = iframe.$.contentWindow.document;
95                                doc.open();
96                                doc.write( this.definition.htmlToLoad );
97                                doc.close();
98                        }
99                },
100
101                onHide : function()
102                {
103                        if ( CKEDITOR.env.ie )
104                                this.getParentEditor().document.getBody().$.contentEditable = 'true';
105                },
106
107                onLoad : function()
108                {
109                        if ( ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) && editor.lang.dir == 'rtl' )
110                                this.parts.contents.setStyle( 'overflow', 'hidden' );
111                },
112
113                onOk : function()
114                {
115                        var container = this.getContentElement( 'general', 'editing_area' ).getElement(),
116                                iframe = container.getElementsByTag( 'iframe' ).getItem( 0 ),
117                                editor = this.getParentEditor(),
118                                html = iframe.$.contentWindow.document.body.innerHTML;
119
120                        setTimeout( function(){
121                                editor.insertHtml( html );
122                        }, 0 );
123
124                },
125
126                contents : [
127                        {
128                                id : 'general',
129                                label : editor.lang.common.generalTab,
130                                elements : [
131                                        {
132                                                type : 'html',
133                                                id : 'securityMsg',
134                                                html : '<div style="white-space:normal;width:340px;">' + editor.lang.clipboard.securityMsg + '</div>'
135                                        },
136                                        {
137                                                type : 'html',
138                                                id : 'pasteMsg',
139                                                html : '<div style="white-space:normal;width:340px;">'+editor.lang.clipboard.pasteMsg +'</div>'
140                                        },
141                                        {
142                                                type : 'html',
143                                                id : 'editing_area',
144                                                style : 'width: 100%; height: 100%;',
145                                                html : '<fieldset></fieldset>',
146                                                focus : function()
147                                                {
148                                                        var div = this.getElement();
149                                                        var iframe = div.getElementsByTag( 'iframe' );
150                                                        if ( iframe.count() < 1 )
151                                                                return;
152                                                        iframe = iframe.getItem( 0 );
153
154                                                        // #3291 : JAWS needs the 500ms delay to detect that the editor iframe
155                                                        // iframe is no longer editable. So that it will put the focus into the
156                                                        // Paste from Word dialog's editable area instead.
157                                                        setTimeout( function()
158                                                        {
159                                                                iframe.$.contentWindow.focus();
160                                                        }, 500 );
161                                                }
162                                        }
163                                ]
164                        }
165                ]
166        };
167});
Note: See TracBrowser for help on using the repository browser.