[TASK] Drop faulty getIcons() method from "Icons" module
[Packages/TYPO3.CMS.git] / typo3 / sysext / recordlist / Resources / Public / JavaScript / Recordlist.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 * Usability improvements for the record list
16 */
17 define(['jquery', 'TYPO3/CMS/Backend/Storage', 'TYPO3/CMS/Backend/Icons'], function($, Storage, Icons) {
18 'use strict';
19
20 var Recordlist = {
21 identifier: {
22 toggle: '.t3js-toggle-recordlist',
23 icons: {
24 collapse: 'actions-view-list-collapse',
25 expand: 'actions-view-list-expand'
26 }
27 }
28 };
29
30 Recordlist.toggleClick = function(e) {
31 e.preventDefault();
32
33 var $me = $(this),
34 table = $me.data('table'),
35 $target = $($me.data('target')),
36 isExpanded = $target.data('state') === 'expanded',
37 $collapseIcon = $me.find('.collapseIcon'),
38 toggleIcon = isExpanded ? Recordlist.identifier.icons.expand : Recordlist.identifier.icons.collapse;
39
40 Icons.getIcon(toggleIcon, Icons.sizes.small).done(function(toggleIcon) {
41 $collapseIcon.html(toggleIcon);
42 });
43
44 // Store collapse state in UC
45 var storedModuleDataList = {};
46
47 if (Storage.Persistent.isset('moduleData.list')) {
48 storedModuleDataList = Storage.Persistent.get('moduleData.list');
49 }
50
51 var collapseConfig = {};
52 collapseConfig[table] = isExpanded ? 1 : 0;
53
54 $.extend(true, storedModuleDataList, collapseConfig);
55 Storage.Persistent.set('moduleData.list', storedModuleDataList).done(function() {
56 $target.data('state', isExpanded ? 'collapsed' : 'expanded');
57 });
58 };
59
60 $(function() {
61 $(document).on('click', Recordlist.identifier.toggle, Recordlist.toggleClick);
62 });
63
64 return Recordlist;
65 });