PageSourceSearch

https://www.aua.ac.ke/wp-content/plugins/organization-chart/front/js/front_popup.js?ver=2.0

js aua.ac.ke collected 2026-09-30 21:46:09 UTC 17,140 bytes, 359 lines download raw bytes

1function wpdaOrgChartPopup() {
2	this.defParams = {
3		'ClickAreaClass': 'wpda_tree_open_popup_el',
4		'contentClass': 'wpda_tree_popup_content',
5		'adminBarHeight': '0',
6		'currentView': 'desktop',
7		'elementIndex': 0,
8		'offsettop': 0,
9		'closeSectionHeight': 0,
10		'popupWindowHeight': 0,
11		'popupWindowWidth': 0,
12		'events': new Array(),
13	};
14	this.innerElements = {};
15	this.popupElements = new Array();
16}
17
18wpdaOrgChartPopup.prototype.init = function () {
19	let self = this;
20	this.calcViewType();
21	this.loadElements();
22	this.fixThemeValues();
23	this.addElementsFunctionality();
24	window.addEventListener('resize', function () {
25		self.resizePopup();
26	});
27}
28
29wpdaOrgChartPopup.prototype.loadElements = function () {
30	let popupLinks = document.getElementsByClassName(this.defParams.ClickAreaClass), i = 0;
31	while (i in popupLinks) {
32		this.popupElements[i] = {};
33		this.popupElements[i]['clickElement'] = popupLinks[i];
34		if (this.popupElements[i]['clickElement'].getElementsByClassName('wpda_tree_popup_content')[0] != null) {
35			this.popupElements[i]['popupContent'] = this.popupElements[i]['clickElement'].getElementsByClassName('wpda_tree_popup_content')[0];
36		} else {
37			this.popupElements[i]['popupContent'] = this.popupElements[i]['clickElement'].parentElement.getElementsByClassName('wpda_tree_popup_content')[0];
38		}
39		this.popupElements[i]['popupTheme'] = this.popupElements[i]['popupContent'].getAttribute('date-popup-theme');
40		i++;
41		if (i > 10000) {
42			alert("error in js");
43			break;
44		}
45	}
46}
47wpdaOrgChartPopup.prototype.addElementsFunctionality = function () {
48	let self = this, i = 0;
49	while (i in this.popupElements) {
50		(function (j) {
51			self.popupElements[j]['clickElement'].addEventListener('click', function () {
52				self.defParams['elementIndex'] = j;
53				self.createOverlay(j);
54				self.createPopup(j);
55			})
56		}(i))
57		i++;
58	}
59}
60
61wpdaOrgChartPopup.prototype.createOverlay = function (elementIndex) {
62	let self = this, themeId = this.popupElements[elementIndex]['popupTheme']
63	this.innerElements['overlay'] = this.createHtmlElement('div', { 'id': 'wpdaOrgChartOverlay', 'style': 'position:fixed;left:0px;top:0px;width:100%;height:100%;background-image: linear-gradient(' + this.gradientToString(wpda_org_chart_popup_theme[themeId]['overlay_bg_color']) + ');' });
64	document.getElementsByTagName('body')[0].appendChild(this.innerElements['overlay']);
65	if (wpda_org_chart_popup_theme[themeId]['close_aditional'] == 'esc_click') {
66		this.innerElements['overlay'].addEventListener('click', function () {
67			self.remove();
68		})
69		let eventObject = {};
70		eventObject['eventFunction'] = function (e) {
71			if (e.code == 'Escape' || e.key == 'escape') {
72				self.remove();
73			}
74		}
75		eventObject['eventName'] = 'keydown';
76		eventObject['element'] = document;
77		self.defParams['events'].push(eventObject);
78		eventObject['element'].addEventListener(eventObject['eventName'], eventObject['eventFunction'])
79	}
80	if (wpda_org_chart_popup_theme[themeId]['close_aditional'] == 'esc') {
81		let eventObject = {};
82		eventObject['eventFunction'] = function (e) {
83			if (e.code == 'Escape' || e.key == 'escape') {
84				self.remove();
85			}
86		}
87		eventObject['eventName'] = 'keydown';
88		eventObject['element'] = document;
89		self.defParams['events'].push(eventObject);
90		eventObject['element'].addEventListener(eventObject['eventName'], eventObject['eventFunction'])
91	}
92	if (wpda_org_chart_popup_theme[themeId]['close_aditional'] == 'click') {
93		this.innerElements['overlay'].addEventListener('click', function () {
94			self.remove();
95		})
96	}
97}
98
99wpdaOrgChartPopup.prototype.createCloseSection = function (elementIndex) {
100	let self = this, themeId = this.popupElements[elementIndex]['popupTheme'], theme = wpda_org_chart_popup_theme[themeId];
101	if (theme['close_button_text']['desktop'] != '') {
102		let fontStyle = '';
103		fontStyle += 'font-family:' + theme['close_button_text_font_family'] + ';';
104		fontStyle += 'color:' + theme['close_button_text_color'] + ';';
105		fontStyle += 'font-size:' + theme['close_button_text_font_size']['desktop'] + theme['close_button_text_font_size']['metric_desktop'] + ';';
106		fontStyle += 'letter-spacing:' + theme['close_button_text_letter_spacing']['desktop'] + theme['close_button_text_letter_spacing']['metric_desktop'] + ';';
107		fontStyle += 'line-height:' + theme['close_button_text_line_height']['desktop'] + theme['close_button_text_line_height']['metric_desktop'] + ';';
108		fontStyle += 'font-weight:' + theme['close_button_text_font_weight'] + ';'
109		fontStyle += 'font-style:' + theme['close_button_text_font_style'] + ';'
110
111		if (theme['close_section_type'] == 'section') {
112			this.innerElements['closeSection'] = this.createHtmlElement('div', { 'id': 'wpd
112aOrgChartCloseSection', 'style': 'text-align: right;border-bottom:' + this.borderToString(theme['close_section_border_bottom_width'], theme['close_section_border_bottom_type'], theme['close_section_border_bottom_color'] + ';' + 'background-color:' + theme['close_button_section_bg_color'] + ';') });
113			var textSpan = this.createHtmlElement('span', { 'style': fontStyle }, theme['close_button_text']['desktop']);
114			this.innerElements['closeSection'].appendChild(textSpan);
115			this.innerElements['popupWindow'].prepend(this.innerElements['closeSection']);
116			this.defParams['closeSectionHeight'] = this.innerElements['closeSection'].getBoundingClientRect().height;
117		} else {
118			var textSpan = this.createHtmlElement('span', { 'style': 'position:absolute;right: 5px;z-index:9999;' + fontStyle }, theme['close_button_text']['desktop']);
119			this.innerElements['popupWindow'].prepend(textSpan);
120		}
121		textSpan.addEventListener('click', function () {
122			self.remove();
123		})
124	}
125}
126
127wpdaOrgChartPopup.prototype.createPopup = function (elementIndex) {
128	let self = this, themeId = this.popupElements[elementIndex]['popupTheme'], theme = wpda_org_chart_popup_theme[themeId], classs = '', duration = 50;
129	if( theme['popup_animation_time'] != null && typeof(theme['popup_animation_time']['desktop']) != 'undefined' ){
130		duration = Math.max(50, parseInt(theme['popup_animation_time']['desktop']));
131	}
132	if (theme['popup_animation_type'] != 'disable') {
133		classs = 'wpda_animation_' + theme['popup_animation_type'];
134		setTimeout(function () {
135			self.innerElements['popupWindow'].setAttribute('class', '');
136		}, duration)
137	}
138	this.innerElements['popupWindow'] = this.createHtmlElement('div', { 'id': 'wpdaOrgChartPopupWindow' });
139	this.innerElements['popupWindow'].appendChild(this.popupElements[elementIndex]['popupContent'].children[0]);
140	document.getElementsByTagName('body')[0].appendChild(this.innerElements['popupWindow']);
141	this.innerElements['popupWindow'].setAttribute('style', this.popupStyle(themeId));
142	// left and top value need generate after popup width and height is initial
143	this.innerElements['popupWindow'].style.left = this.leftPosition(themeId);
144	this.innerElements['popupWindow'].style.top = this.topPosition(themeId);
145	this.innerElements['popupWindow'].style.animationDuration = duration + 'ms';
146	self.innerElements['popupWindow'].setAttribute('class', classs);
147	this.createCloseSection(elementIndex);	
148	this.innerElements['popupWindow'].getElementsByClassName('wpda_popup_innerhtml')[0].style.paddingTop = theme['padding'][this.defParams['currentView'] +'_top'] + 'px ';
149	this.innerElements['popupWindow'].getElementsByClassName('wpda_popup_innerhtml')[0].style.paddingRight = theme['padding'][this.defParams['currentView'] +'_right'] + 'px ';
150	this.innerElements['popupWindow'].getElementsByClassName('wpda_popup_innerhtml')[0].style.paddingBottom = theme['padding'][this.defParams['currentView'] +'_bottom'] + 'px ';
151	this.innerElements['popupWindow'].getElementsByClassName('wpda_popup_innerhtml')[0].style.paddingLeft = theme['padding'][this.defParams['currentView'] +'_left'] + 'px';
152	this.innerElements['popupWindow'].getElementsByClassName('wpda_popup_innerhtml')[0].style.maxHeight = this.innerElements['popupWindow'].offsetHeight - parseInt(theme['popup_border_width']['desktop']) * 2 - parseInt(this.defParams['closeSectionHeight']) + 1 + 'px';
153}
154
155wpdaOrgChartPopup.prototype.leftPosition = function (themeId) {
156	let theme = wpda_org_chart_popup_theme[themeId], metricView = 'metric_' + this.defParams['currentView'];
157	if (theme['popup_width'][this.defParams['currentView']] != '') {
158		var el_width = theme['popup_width'][this.defParams['currentView']] + theme['popup_width'][metricView];
159	}
160	if (this.innerElements['popupWindow'].getBoundingClientRect != null) {
161		var el_width = this.innerElements['popupWindow'].getBoundingClientRect().width;
162	}
163	if (!(typeof (el_width) != 'undefined' && el_width != 0)) {
164		var el_width = '550';
165	}
166	switch (parseInt(theme['popup_position'])) {
167		case 1:
168		case 4:
169		case 7:
170			return 0 + 'px';
171			break;
172		case 2:
173		case 5:
174		case 8:
175			return (this.innerElements['overlay'].offsetWidth - parseInt(el_width)) / 2 + 'px';
176			break;
177		case 3:
178		case 6:
179		case 9:
180			return (this.innerElements['overlay'].offsetWidth - parseInt(el_width)) + 'px';
181			break;
182	}
183}
184
185wpdaOrgChartPopup.prototype.topPosition = function (themeId) {
186	let theme = wpda_org_chart_popup_theme[themeId], metricView = 'metric_' + this.defParams['currentView'], offsetTop = 0;
187	if (theme['popup_width'][this.defParams['currentView']] != '') {
188		var el_height = theme['popup_height'][this.defParams['currentView']] + theme['popup_height'][metricView];
189	}
190	if (this.innerElements['popupWindow'].getBoundingClientRect != null) {
191		var el_height = this.innerElements['popupWindow'].getBoundingClientRect().height;
192	}
193	if (!(typeof (el_height) != 'undefined' && el_height != 0)) {
194		var el_height = '550';
195	}
196	if (theme['popup_fixed_postion'] == 'relative') {
197		offsetTop = window.scrollY;
198	}
199	switch (parseInt(theme['popup_position'])) {
200		case 1:
201		case 2:
202		case 3:
203			return offsetTop + 'px';
204			break;
205		case 4:
206		case 5:
207		case 6:
208			return (this.innerElements['overlay'].offsetHeight - parseInt(el_height)) / 2 + offsetTop + 'px';
209			break;
210		case 7:
211		case 8:
212		case 9:
213			return (this.innerElements['overlay'].offsetHeight - parseInt(el_height)) + offsetTop + 'px';
214			break;
215	}
216}
217
218wpdaOrgChartPopup.prototype.resizePopup = function () {
219	let self = this;
220	self.calcViewType();
221	if (self.innerElements['popupWindow'] != null) {
222		self.innerElements['popupWindow'].setAttribute('style', self.popupStyle(self.popupElements[self.defParams['elementIndex']]['popupTheme']));
223		self.innerElements['popupWindow'].style.left = self.leftPosition(self.popupElements[self.defParams['elementIndex']]['popupTheme']);
224		self.innerElements['popupWindow'].style.top = self.topPosition(self.popupElements[self.defParams['elementIndex']]['popupTheme']);
225	}
226}
227
228
229wpdaOrgChartPopup.prototype.OffsetFromTop = function () {
230	let top = (window.pageYOffset || document.documentElement.scrollTop) - (document.documentElement.clientTop || 0);
231	this.param.OffsetFromTop = top;
232}
233
234wpdaOrgChartPopup.prototype.remove = function () {
235	let self = this;
236	this.popupElements[this.defParams['elementIndex']]['popupContent'].appendChild(this.innerElements['popupWindow'].getElementsByClassName('wpda_popup_innerhtml')[0]);
237	for (let j = 0; j < self.defParams['events'].length; j++) {
238		self.defParams['events'][j]['element'].removeEventListener(self.defParams['events'][j]['eventName'], self.defParams['events'][j]['eventFunction']);
239	}
240	this.innerElements['popupWindow'].remove();
241	this.innerElements['overlay'].remove();
242}
243
244wpdaOrgChartPopup.prototype.calculateAdminBarHeight = function () {
245	wv = window.innerWidth;
246	wh = window.innerHeight;
247	let adminBar = document.getElementById('wpadminbar');
248	if (adminBar == null) return;
249	if (typeof (adminBar.getBoundingClientRect) != 'undefined') {
250		this.param.adminBarHeight = adminBar.getBoundingClientRect().height;
251		return;
252	}
253	this.param.adminBarHeight = '32';
254}
255
256wpdaOrgChartPopup.prototype.popupStyle = function (themeId) {
257	let self = this;
258	let style = '', positionConvert = { 'relative': 'absolute', 'fixed': 'fixed' }, theme = wpda_org_chart_popup_theme[themeId], metricView = 'metric_' + this.defParams['currentView'], animDuration = 50;
259	style += 'position:' + positionConvert[theme['popup_fixed_postion']]; // inside parameter value is fixed or relative
260	style += ';background-image: linear-gradient(' + this.gradientToString(theme['popup_bg_color']) + ');';
261	style += ';border:' + this.borderToString(theme['popup_border_width'], theme['popup_border_type'], theme['popup_border_color']);
262	style += ';border-radius:' + parseInt(theme['popup_border_radius']['desktop']) + theme['popup_border_radius']['metric_desktop'];
263	if (theme['popup_width'][this.defParams['currentView']] != '') {
264		style += ";max-width:" + theme['popup_width'][this.defParams['currentView']] + theme['popup_width'][metricView];
265	}
266	if (theme['popup_height'][this.defParams['currentView']] != '') {
267		style += ";max-height:" + theme['popup_height'][this.defParams['currentView']] + theme['popup_height'][metricView];
268	}
269	return style;
270}
271
272wpdaOrgChartPopup.prototype.calcViewType = function () {
273	if (window.innerWidth < parseInt(wpda_org_chart_responsive_sizes['mobile'])) {
274		this.defParams['currentView'] = 'mobile';
275		return;
276	}
277	if (window.innerWidth < parseInt(wpda_org_chart_responsive_sizes['tablet'])) {
278		this.defParams['currentView'] = 'tablet';
279		return;
280	}
281	this.defParams['currentView'] = 'desktop';
282	return;
283}
284/*helper functions*/
285wpdaOrgChartPopup.prototype.createHtmlElement = function (tag = "", attr = {}, innerHTML = "") {
286	let el = document.createElement(tag);
287	for (const key in attr) {
288		el.setAttribute(key, attr[key]);
289	}
290	if (innerHTML != '') {
291		el.innerHTML = innerHTML;
292	}
293	return el;
294}
295
296wpdaOrgChartPopup.prototype.gradientToString = function (gradient) {
297	if (gradient == null) {
298		return '';
299	}
300	let color1 = "rgba(255,255,255,0)", color2 = "rgba(255,255,255,0)", direction = "to left";
301	if ("color1" in gradient && "color2" in gradient && "gradient" in gradient) {
302		color1 = gradient['color1'];
303		color2 = gradient['color2'];
304		if (gradient['gradient'] != 'none') {
305			direction = gradient['gradient'];
306		} else {
307			color2 = color1;
308		}
309	}
310	return direction + ',' + color1 + ',' + color2;
311}
312
313wpdaOrgChartPopup.prototype.borderToString = function (borderWidth, borderType, borderColor) {
314	return border = parseInt(borderWidth['desktop']) + borderWidth['metric_desktop'] + " " + borderType + " " + borderColor;
315}
316
317wpdaOrgChartPopup.prototype.fixThemeValues = function () {
318	let types = ['desktop', 'tablet', 'mobile'];
319	if (typeof wpda_org_chart_popup_theme != 'undefined')
320		for (let i = 0; i < wpda_org_chart_popup_theme.length; i++) {
321			if (typeof (wpda_org_chart_popup_theme[i]) == 'undefined')
322				continue;
323			for (const key in wpda_org_chart_popup_theme[i]) {
324				// if value is not numeric then metric is empty
325				if (typeof (wpda_org_chart_popup_theme[i][key]) == 'object' && wpda_org_chart_popup_theme[i][key] != null) {
326					for (let k = 0; k < types.length; k++) {
327						if (types[k] in wpda_org_chart_popup_theme[i][key] && wpda_org_chart_popup_theme[i][key]['desktop'] != '') {
328							if ('metric_' + types[k] in wpda_org_chart_popup_theme[i][key] && wpda_org_chart_popup_theme[i][key]['metric_' + types[k]] != '') {
329								if (isNaN(wpda_org_chart_popup_theme[i][key][types[k]])) {
330									wpda_org_chart_popup_theme[i][key]['metric_' + types[k]] = '';
331								}
332							}
333						}
334					}
335				}
336				// if mobile and tablet value don't filled it's equaled desktop value(on responsive parameters)
337				if (typeof (wpda_org_chart_popup_theme[i][key]) == 'object' && wpda_org_chart_popup_theme[i][key] != null) {
338					if ('desktop' in wpda_org_chart_popup_theme[i][key] && wpda_org_chart_popup_theme[i][key]['desktop'] != '') {
339						if ('mobile' in wpda_org_chart_popup_theme[i][key] && wpda_org_chart_popup_theme[i][key]['mobile'] == '') {
340							wpda_org_chart_popup_theme[i][key]['mobile'] = wpda_org_chart_popup_theme[i][key]['desktop'];
341							if ('metric_desktop' in wpda_org_chart_popup_theme[i][key] && 'metric_mobile' in wpda_org_chart_popup_theme[i][key])
342								wpda_org_chart_popup_theme[i][key]['metric_mobile'] = wpda_org_chart_popup_theme[i][key]['metric_desktop'];
343						}
344						if ('tablet' in wpda_org_chart_popup_theme[i][key] && wpda_org_chart_popup_theme[i][key]['tablet'] == '') {
345							wpda_org_chart_popup_theme[i][key]['tablet'] = wpda_org_chart_popup_theme[i][key]['desktop'];
346							if ('metric_desktop' in wpda_org_chart_popup_theme[i][key] && 'metric_tablet' in wpda_org_chart_popup_theme[i][key])
347								wpda_org_chart_popup_theme[i][key]['metric_tablet'] = wpda_org_chart_popup_theme[i][key]['metric_desktop'];
348						}
349					}
350				}
351
352			}
353		}
354}
355
356document.addEventListener('DOMContentLoaded', function () {
357	var wpdaOrgChartPopupObject = new wpdaOrgChartPopup();
358	wpdaOrgChartPopupObject.init();
359})

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.