Skip to content

Commit 9e6b9c5

Browse files
Removed unused Health Metrics js (#2869)
1 parent 1fac851 commit 9e6b9c5

1 file changed

Lines changed: 0 additions & 140 deletions

File tree

dt-groups/groups.js

Lines changed: 0 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -3,146 +3,6 @@ jQuery(document).ready(function ($) {
33
let post_id = window.detailsSettings.post_id;
44
let post_type = window.detailsSettings.post_type;
55
let post = window.detailsSettings.post_fields;
6-
let field_settings = window.detailsSettings.post_settings.fields;
7-
8-
/* Health Metrics */
9-
let health_keys = Object.keys(field_settings.health_metrics.default);
10-
11-
function fillOutChurchHealthMetrics() {
12-
let practiced_items =
13-
window.detailsSettings.post_fields.health_metrics || [];
14-
15-
/* Make church commitment circle green */
16-
if (practiced_items.indexOf('church_commitment') !== -1) {
17-
$('#health-items-container').addClass('committed');
18-
$('#is-church-switch').prop('checked', true);
19-
}
20-
21-
/* Color church circle items that are being practiced */
22-
let items = $('div[id^="icon_"]');
23-
24-
items.each(function (k, v) {
25-
if (
26-
practiced_items.indexOf(v.id.replace('icon_', ''), practiced_items) !==
27-
-1
28-
) {
29-
$(this).children('img').attr('class', 'practiced-item');
30-
}
31-
});
32-
33-
/* Color group progress buttons */
34-
let icons = $('.group-progress-button');
35-
icons.each(function (k, v) {
36-
if (practiced_items.indexOf(v.id, practiced_items) !== -1) {
37-
$(this).addClass('practiced-button');
38-
}
39-
});
40-
}
41-
42-
fillOutChurchHealthMetrics();
43-
distributeItems();
44-
45-
$('.health-item').on('click', function () {
46-
let fieldId = $(this).attr('id').replace('icon_', '');
47-
let already_set = window.lodash
48-
.get(post, 'health_metrics', [])
49-
.includes(fieldId);
50-
let update = { values: [{ value: fieldId }] };
51-
if (already_set) {
52-
update.values[0].delete = true;
53-
}
54-
window.API.update_post(post_type, post_id, { health_metrics: update })
55-
.then((groupData) => {
56-
post = groupData;
57-
/* Update icon */
58-
if ($(this).attr('id') === 'church_commitment') {
59-
$('#health-items-container').toggleClass('committed');
60-
$(this).toggleClass('practiced-button');
61-
return true;
62-
}
63-
/* Toggle church health circle item color */
64-
$(this).children('img').toggleClass('practiced-item');
65-
$(this).children('i').toggleClass('practiced-item');
66-
})
67-
.catch((err) => {
68-
console.log(err);
69-
});
70-
});
71-
72-
$('#is-church-switch').on('click', function () {
73-
let fieldId = 'church_commitment';
74-
let already_set = window.lodash
75-
.get(post, 'health_metrics', [])
76-
.includes(fieldId);
77-
let update = { values: [{ value: fieldId }] };
78-
if (already_set) {
79-
update.values[0].delete = true;
80-
}
81-
window.API.update_post(post_type, post_id, { health_metrics: update })
82-
.then((groupData) => {
83-
post = groupData;
84-
/* Update commitment circle */
85-
$('#health-items-container').toggleClass('committed');
86-
})
87-
.catch((err) => {
88-
console.log(err);
89-
});
90-
});
91-
92-
/* Dynamically distribute items in Church Health Circle
93-
according to amount of health metric elements */
94-
function distributeItems() {
95-
let radius = 75;
96-
let items = $('.health-item'),
97-
container = $('#health-items-container'),
98-
item_count = items.length,
99-
fade_delay = 45,
100-
width = container.width(),
101-
height = container.height() + 66,
102-
angle = 0,
103-
step = (2 * Math.PI) / items.length,
104-
y_offset = -35;
105-
106-
if (item_count >= 5 && item_count < 7) {
107-
radius = 90;
108-
}
109-
110-
if ((item_count >= 7) & (item_count < 11)) {
111-
radius = 100;
112-
}
113-
114-
if (item_count >= 11) {
115-
radius = 110;
116-
}
117-
118-
if (item_count == 3) {
119-
angle = 22.5;
120-
}
121-
122-
items.each(function () {
123-
let X = Math.round(
124-
width / 2 + radius * Math.cos(angle) - $(this).width() / 2,
125-
);
126-
let y =
127-
Math.round(
128-
height / 2 + radius * Math.sin(angle) - $(this).height() / 2,
129-
) + y_offset;
130-
131-
if (item_count == 1) {
132-
X = 112.5;
133-
y = 68;
134-
}
135-
136-
$(this).css({
137-
left: X + 'px',
138-
top: y + 'px',
139-
});
140-
$(this).delay(fade_delay).fadeIn(1000, 'linear');
141-
angle += step;
142-
fade_delay += 45;
143-
});
144-
}
145-
/* End Health Metrics*/
1466

1477
let { template_dir } = window.wpApiShare;
1488

0 commit comments

Comments
 (0)