[BUGFIX] RTE Image Wizard
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / Resources / Public / JavaScript / SelectImage.js
1 /*
2 * This file is part of the TYPO3 CMS project.
3 *
4 * It is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, either version 2
6 * of the License, or any later version.
7 *
8 * For the full copyright and license information, please read the
9 * LICENSE.txt file that was distributed with this source code.
10 *
11 * The TYPO3 project - inspiring people to share!
12 */
13
14
15
16 /**
17 * Module: TYPO3/CMS/Rtehtmlarea/SelectImage
18 * This module is used by the RTE SelectImage module
19 */
20 define(['jquery', 'TYPO3/CMS/Recordlist/LinkBrowser'], function($, LinkBrowser) {
21 'use strict';
22
23 /**
24 *
25 * @type {{plugin: Object, initialize: Function, getCurrentImage: Function, setImagesInRTE: Function}}
26 * @exports TYPO3/CMS/Rtehtmlarea/SelectImage
27 */
28 var SelectImage = {
29 plugin: null,
30
31 initialize: function() {
32 SelectImage.plugin = window.parent.RTEarea[LinkBrowser.urlParameters.editorNo].editor.getPlugin("TYPO3Image");
33 },
34
35 getCurrentImage: function() {
36 return SelectImage.plugin.image;
37 },
38
39 setImagesInRTE: function(uidList) {
40 var parameters = LinkBrowser.urlParameters;
41
42 parameters.uidList = uidList;
43
44 var selectedImageRef = SelectImage.getCurrentImage();
45 if (selectedImageRef) {
46 parameters.cWidth = selectedImageRef.style.width;
47 parameters.cHeight = selectedImageRef.style.height;
48 }
49
50 $.ajax({
51 url: TYPO3.settings.ajaxUrls['rte_insert_image'],
52 data: parameters,
53 method: 'GET',
54 success: function(data) {
55 if (data.images) {
56 SelectImage.plugin.insertImage(data.images);
57 }
58 }
59 });
60 }
61 };
62
63 $(SelectImage.initialize);
64
65 return SelectImage;
66 });