|
1 | 1 | Mautic.contactclientTimelineOnLoad = function (container, response) { |
2 | 2 |
|
3 | | - if (typeof window.contactclientTimelineLoaded === 'undefined') { |
4 | | - |
5 | | - window.contactclientTimelineLoaded = true; |
6 | | - |
7 | | - var codeMirror = function ($el) { |
8 | | - if (!$el.hasClass('codemirror-active')) { |
9 | | - var $textarea = $el.find('textarea.codeMirror-yaml'); |
10 | | - if ($textarea.length) { |
11 | | - CodeMirror.fromTextArea($textarea[0], { |
12 | | - mode: 'yaml', |
13 | | - theme: 'material', |
14 | | - gutters: [], |
15 | | - lineNumbers: false, |
16 | | - lineWrapping: true, |
17 | | - readOnly: true |
18 | | - }); |
19 | | - } |
20 | | - $el.addClass('codemirror-active'); |
21 | | - } |
22 | | - }; |
23 | | - mQuery('#contactclient-timeline a[data-activate-details=\'all\']').on('click', function () { |
24 | | - if (mQuery(this).find('span').first().hasClass('fa-level-down')) { |
25 | | - mQuery('#contactclient-timeline a[data-activate-details!=\'all\']').each(function () { |
26 | | - var detailsId = mQuery(this).data('activate-details'), |
27 | | - $details = mQuery('#timeline-details-' + detailsId); |
28 | | - if (detailsId && $details.length) { |
29 | | - $details.removeClass('hide'); |
30 | | - codeMirror($details); |
31 | | - mQuery(this).addClass('active'); |
32 | | - } |
33 | | - }); |
34 | | - mQuery(this).find('span').first().removeClass('fa-level-down').addClass('fa-level-up'); |
35 | | - } |
36 | | - else { |
37 | | - mQuery('#contactclient-timeline a[data-activate-details!=\'all\']').each(function () { |
38 | | - var detailsId = mQuery(this).data('activate-details'), |
39 | | - $details = mQuery('#timeline-details-' + detailsId); |
40 | | - if (detailsId && $details.length) { |
41 | | - $details.addClass('hide'); |
42 | | - mQuery(this).removeClass('active'); |
43 | | - } |
| 3 | + var codeMirror = function ($el) { |
| 4 | + if (!$el.hasClass('codemirror-active')) { |
| 5 | + var $textarea = $el.find('textarea.codeMirror-yaml'); |
| 6 | + if ($textarea.length) { |
| 7 | + CodeMirror.fromTextArea($textarea[0], { |
| 8 | + mode: 'yaml', |
| 9 | + theme: 'material', |
| 10 | + gutters: [], |
| 11 | + lineNumbers: false, |
| 12 | + lineWrapping: true, |
| 13 | + readOnly: true |
44 | 14 | }); |
45 | | - mQuery(this).find('span').first().removeClass('fa-level-up').addClass('fa-level-down'); |
46 | 15 | } |
47 | | - }); |
48 | | - mQuery('#contactclient-timeline a[data-activate-details!=\'all\']').on('click', function () { |
49 | | - var detailsId = mQuery(this).data('activate-details'); |
50 | | - if (detailsId && mQuery('#timeline-details-' + detailsId).length) { |
51 | | - var activateDetailsState = mQuery(this).hasClass('active'), |
| 16 | + $el.addClass('codemirror-active'); |
| 17 | + } |
| 18 | + }; |
| 19 | + mQuery('#contactclient-timeline a[data-activate-details=\'all\']').on('click', function () { |
| 20 | + if (mQuery(this).find('span').first().hasClass('fa-level-down')) { |
| 21 | + mQuery('#contactclient-timeline a[data-activate-details!=\'all\']').each(function () { |
| 22 | + var detailsId = mQuery(this).data('activate-details'), |
52 | 23 | $details = mQuery('#timeline-details-' + detailsId); |
53 | | - |
54 | | - if (activateDetailsState) { |
55 | | - $details.addClass('hide'); |
56 | | - mQuery(this).removeClass('active'); |
57 | | - } |
58 | | - else { |
| 24 | + if (detailsId && $details.length) { |
59 | 25 | $details.removeClass('hide'); |
60 | 26 | codeMirror($details); |
61 | 27 | mQuery(this).addClass('active'); |
62 | 28 | } |
63 | | - } |
64 | | - }); |
| 29 | + }); |
| 30 | + mQuery(this).find('span').first().removeClass('fa-level-down').addClass('fa-level-up'); |
| 31 | + } |
| 32 | + else { |
| 33 | + mQuery('#contactclient-timeline a[data-activate-details!=\'all\']').each(function () { |
| 34 | + var detailsId = mQuery(this).data('activate-details'), |
| 35 | + $details = mQuery('#timeline-details-' + detailsId); |
| 36 | + if (detailsId && $details.length) { |
| 37 | + $details.addClass('hide'); |
| 38 | + mQuery(this).removeClass('active'); |
| 39 | + } |
| 40 | + }); |
| 41 | + mQuery(this).find('span').first().removeClass('fa-level-up').addClass('fa-level-down'); |
| 42 | + } |
| 43 | + }); |
| 44 | + mQuery('#contactclient-timeline a[data-activate-details!=\'all\']').on('click', function () { |
| 45 | + var detailsId = mQuery(this).data('activate-details'); |
| 46 | + if (detailsId && mQuery('#timeline-details-' + detailsId).length) { |
| 47 | + var activateDetailsState = mQuery(this).hasClass('active'), |
| 48 | + $details = mQuery('#timeline-details-' + detailsId); |
65 | 49 |
|
66 | | - if (response && typeof response.timelineCount !== 'undefined') { |
67 | | - mQuery('#TimelineCount').html(response.timelineCount); |
| 50 | + if (activateDetailsState) { |
| 51 | + $details.addClass('hide'); |
| 52 | + mQuery(this).removeClass('active'); |
| 53 | + } |
| 54 | + else { |
| 55 | + $details.removeClass('hide'); |
| 56 | + codeMirror($details); |
| 57 | + mQuery(this).addClass('active'); |
| 58 | + } |
68 | 59 | } |
| 60 | + }); |
| 61 | + |
| 62 | + if (response && typeof response.timelineCount !== 'undefined') { |
| 63 | + mQuery('#TimelineCount').html(response.timelineCount); |
69 | 64 | } |
70 | 65 | }; |
0 commit comments