1 | <!DOCTYPE html> |
---|
2 | <html> |
---|
3 | <head> |
---|
4 | <script src="https://code.jquery.com/jquery-1.8.3.min.js"></script> |
---|
5 | <script src="../../ckeditor.js"></script> |
---|
6 | <meta charset=utf-8 /> |
---|
7 | <title>Issue with Firefox and immediately setting data.</title> |
---|
8 | </head> |
---|
9 | <body> |
---|
10 | <h2>Firefox Bug</h2> |
---|
11 | <textarea id="editor1" cols="50" rows="5">First Content</textarea> |
---|
12 | <script> |
---|
13 | |
---|
14 | //Possible workaround |
---|
15 | //Comment it and clear FF cache to see css request aborted. |
---|
16 | CKEDITOR.tools.buildStyleHtml = function (css) { |
---|
17 | css = [].concat(css); |
---|
18 | var item, |
---|
19 | retval = []; |
---|
20 | for (var i = 0; i < css.length; i++) { |
---|
21 | if ((item = css[i])) { |
---|
22 | // Is CSS style text ? |
---|
23 | if (/@import|[{}]/.test(item)) { |
---|
24 | retval.push('<style>' + item + '</style>'); |
---|
25 | } else { |
---|
26 | item += "?ts=" + new Date().getTime(); |
---|
27 | retval.push('<link type="text/css" rel=stylesheet href="' + item + '">'); |
---|
28 | |
---|
29 | } |
---|
30 | } |
---|
31 | } |
---|
32 | return retval.join(''); |
---|
33 | }; |
---|
34 | |
---|
35 | //Editor initialization |
---|
36 | CKEDITOR.replace('editor1', { |
---|
37 | width: '400px', |
---|
38 | height: '200px', |
---|
39 | contentsCss: 'https://s3.amazonaws.com/hat6/contents.css', |
---|
40 | toolbar: [], |
---|
41 | disallowedContent: 'script', |
---|
42 | on: { |
---|
43 | instanceReady: function (ev) { |
---|
44 | var _this = this; |
---|
45 | setTimeout(function () { |
---|
46 | _this.setData("Second Content - Red if CSS loaded correctly"); |
---|
47 | // You can get this to load by bumping the timeout to something longer than the transfer time from S3. For me, it's somewhere between 150 and 900ms. |
---|
48 | }, 10); |
---|
49 | } |
---|
50 | } |
---|
51 | }); |
---|
52 | </script> |
---|
53 | </body> |
---|
54 | </html> |
---|