Revision 2862,
1.2 KB
checked in by rodsouza, 14 years ago
(diff) |
Ticket #663 - Atualizando e centralizando o CKEditor (v. 3.2.1)
|
Line | |
---|
1 | /*
|
---|
2 | Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
|
---|
3 | For licensing, see LICENSE.html or http://ckeditor.com/license
|
---|
4 | */
|
---|
5 |
|
---|
6 | (function()
|
---|
7 | {
|
---|
8 | var loaded = {};
|
---|
9 |
|
---|
10 | var loadImage = function( image, callback )
|
---|
11 | {
|
---|
12 | var doCallback = function()
|
---|
13 | {
|
---|
14 | img.removeAllListeners();
|
---|
15 | loaded[ image ] = 1;
|
---|
16 | callback();
|
---|
17 | };
|
---|
18 |
|
---|
19 | var img = new CKEDITOR.dom.element( 'img' );
|
---|
20 | img.on( 'load', doCallback );
|
---|
21 | img.on( 'error', doCallback );
|
---|
22 | img.setAttribute( 'src', image );
|
---|
23 | };
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * Load images into the browser cache.
|
---|
27 | * @namespace
|
---|
28 | * @example
|
---|
29 | */
|
---|
30 | CKEDITOR.imageCacher =
|
---|
31 | {
|
---|
32 | /**
|
---|
33 | * Loads one or more images.
|
---|
34 | * @param {Array} images The URLs for the images to be loaded.
|
---|
35 | * @param {Function} callback The function to be called once all images
|
---|
36 | * are loaded.
|
---|
37 | */
|
---|
38 | load : function( images, callback )
|
---|
39 | {
|
---|
40 | var pendingCount = images.length;
|
---|
41 |
|
---|
42 | var checkPending = function()
|
---|
43 | {
|
---|
44 | if ( --pendingCount === 0 )
|
---|
45 | callback();
|
---|
46 | };
|
---|
47 |
|
---|
48 | for ( var i = 0 ; i < images.length ; i++ )
|
---|
49 | {
|
---|
50 | var image = images[ i ];
|
---|
51 |
|
---|
52 | if ( loaded[ image ] )
|
---|
53 | checkPending();
|
---|
54 | else
|
---|
55 | loadImage( image, checkPending );
|
---|
56 | }
|
---|
57 | }
|
---|
58 | };
|
---|
59 | })();
|
---|
Note: See
TracBrowser
for help on using the repository browser.