88a3a1a31bf3e44690f1cc1fe6aa7dbc46550516
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Resources / Public / JavaScript / ColorPicker.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 define(["require", "exports", "jquery", "TYPO3/CMS/Core/Contrib/jquery.minicolors"], function (require, exports, $) {
14 "use strict";
15 /**
16 * Module: TYPO3/CMS/Backend/ColorPicker
17 * contains all logic for the color picker used in FormEngine
18 * @exports TYPO3/CMS/Backend/ColorPicker
19 */
20 var ColorPicker = (function () {
21 /**
22 * The constructor, set the class properties default values
23 */
24 function ColorPicker() {
25 this.selector = '.t3js-color-picker';
26 }
27 /**
28 * Initialize the color picker for the given selector
29 */
30 ColorPicker.prototype.initialize = function () {
31 $(this.selector).minicolors({
32 format: 'hex',
33 position: 'bottom left',
34 theme: 'bootstrap',
35 });
36 $(document).on('change', '.t3js-colorpicker-value-trigger', function () {
37 $(this)
38 .closest('.t3js-formengine-field-item')
39 .find('.t3js-color-picker')
40 .val(this.value)
41 .trigger('paste');
42 $(this).val('');
43 });
44 };
45 return ColorPicker;
46 }());
47 return new ColorPicker();
48 });