PageSourceSearch

https://www.sariaya.gov.ph/wp-content/plugins/organization-chart/front/js/front_popup.js?ver=10.0

js sariaya.gov.ph collected 2026-10-02 17:01:33 UTC 16,711 bytes, 350 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 = 0;
129	this.innerElements['popupWindow'] = this.createHtmlElement('div', { 'id': 'wpdaOrgChartPopupWindow' });
130	this.innerElements['popupWindow'].appendChild(this.popupElements[elementIndex]['popupContent'].children[0]);
131	document.getElementsByTagName('body')[0].appendChild(this.innerElements['popupWindow']);
132	this.innerElements['popupWindow'].setAttribute('style', this.popupStyle(themeId));
133	// left and top value need generate after popup width and height is initial
134	this.innerElements['popupWindow'].style.left = this.leftPosition(themeId);
135	this.innerElements['popupWindow'].style.top = this.topPosition(themeId);
136	this.innerElements['popupWindow'].style.animationDuration = 0 + 'ms';
137	self.innerElements['popupWindow'].setAttribute('class', classs);
138	this.createCloseSection(elementIndex);	
139	this.innerElements['popupWindow'].getElementsByClassName('wpda_popup_innerhtml')[0].style.paddingTop = theme['padding'][this.defParams['currentView'] +'_top'] + 'px ';
140	this.innerElements['popupWindow'].getElementsByClassName('wpda_popup_innerhtml')[0].style.paddingRight = theme['padding'][this.defParams['currentView'] +'_right'] + 'px ';
141	this.innerElements['popupWindow'].getElementsByClassName('wpda_popup_innerhtml')[0].style.paddingBottom = theme['padding'][this.defParams['currentView'] +'_bottom'] + 'px ';
142	this.innerElements['popupWindow'].getElementsByClassName('wpda_popup_innerhtml')[0].style.paddingLeft = theme['padding'][this.defParams['currentView'] +'_left'] + 'px';
143	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';
144}
145
146wpdaOrgChartPopup.prototype.leftPosition = function (themeId) {
147	let theme = wpda_org_chart_popup_theme[themeId], metricView = 'metric_' + this.defParams['currentView'];
148	if (theme['popup_width'][this.defParams['currentView']] != '') {
149		var el_width = theme['popup_width'][this.defParams['currentView']] + theme['popup_width'][metricView];
150	}
151	if (this.innerElements['popupWindow'].getBoundingClientRect != null) {
152		var el_width = this.innerElements['popupWindow'].getBoundingClientRect().width;
153	}
154	if (!(typeof (el_width) != 'undefined' && el_width != 0)) {
155		var el_width = '550';
156	}
157	switch (parseInt(theme['popup_position'])) {
158		case 1:
159		case 4:
160		case 7:
161			return 0 + 'px';
162			break;
163		case 2:
164		case 5:
165		case 8:
166			return (this.innerElements['overlay'].offsetWidth - parseInt(el_width)) / 2 + 'px';
167			break;
168		case 3:
169		case 6:
170		case 9:
171			return (this.innerElements['overlay'].offsetWidth - parseInt(el_width)) + 'px';
172			break;
173	}
174}
175
176wpdaOrgChartPopup.prototype.topPosition = function (themeId) {
177	let theme = wpda_org_chart_popup_theme[themeId], metricView = 'metric_' + this.defParams['currentView'], offsetTop = 0;
178	if (theme['popup_width'][this.defParams['currentView']] != '') {
179		var el_height = theme['popup_height'][this.defParams['currentView']] + theme['popup_height'][metricView];
180	}
181	if (this.innerElements['popupWindow'].getBoundingClientRect != null) {
182		var el_height = this.innerElements['popupWindow'].getBoundingClientRect().height;
183	}
184	if (!(typeof (el_height) != 'undefined' && el_height != 0)) {
185		var el_height = '550';
186	}
187	if (theme['popup_fixed_postion'] == 'relative') {
188		offsetTop = window.scrollY;
189	}
190	switch (parseInt(theme['popup_position'])) {
191		case 1:
192		case 2:
193		case 3:
194			return offsetTop + 'px';
195			break;
196		case 4:
197		case 5:
198		case 6:
199			return (this.innerElements['overlay'].offsetHeight - parseInt(el_height)) / 2 + offsetTop + 'px';
200			break;
201		case 7:
202		case 8:
203		case 9:
204			return (this.innerElements['overlay'].offsetHeight - parseInt(el_height)) + offsetTop + 'px';
205			break;
206	}
207}
208
209wpdaOrgChartPopup.prototype.resizePopup = function () {
210	let self = this;
211	self.calcViewType();
212	if (self.innerElements['popupWindow'] != null) {
213		self.innerElements['popupWindow'].setAttribute('style', self.popupStyle(self.popupElements[self.defParams['elementIndex']]['popupTheme']));
214		self.innerElements['popupWindow'].style.left = self.leftPosition(self.popupElements[self.defParams['elementIndex']]['popupTheme']);
215		self.innerElements['popupWindow'].style.top = self.topPosition(self.popupElements[self.defParams['elementIndex']]['popupTheme']);
216	}
217}
218
219
220wpdaOrgChartPopup.prototype.OffsetFromTop = function () {
221	let top = (window.pageYOffset || document.documentElement.scrollTop) - (document.documentElement.clientTop || 0);
222	this.param.OffsetFromTop = top;
223}
224
225wpdaOrgChartPopup.prototype.remove = function () {
226	let self = this;
227	this.popupElements[this.defParams['elementIndex']]['popupContent'].appendChild(this.innerElements['popupWindow'].getElementsByClassName('wpda_popup_innerhtml')[0]);
228	for (let j = 0; j < self.defParams['events'].length; j++) {
229		self.defParams['events'][j]['element'].removeEventListener(self.defParams['events'][j]['eventName'], self.defParams['events'][j]['eventFunction']);
230	}
231	this.innerElements['popupWindow'].remove();
232	this.innerElements['overlay'].remove();
233}
234
235wpdaOrgChartPopup.prototype.calculateAdminBarHeight = function () {
236	wv = window.innerWidth;
237	wh = window.innerHeight;
238	let adminBar = document.getElementById('wpadminbar');
239	if (adminBar == null) return;
240	if (typeof (adminBar.getBoundingClientRect) != 'undefined') {
241		this.param.adminBarHeight = adminBar.getBoundingClientRect().height;
242		return;
243	}
244	this.param.adminBarHeight = '32';
245}
246
247wpdaOrgChartPopup.prototype.popupStyle = function (themeId) {
248	let self = this;
249	let style = '', positionConvert = { 'relative': 'absolute', 'fixed': 'fixed' }, theme = wpda_org_chart_popup_theme[themeId], metricView = 'metric_' + this.defParams['currentView'], animDuration = 50;
250	style += 'position:' + positionConvert[theme['popup_fixed_postion']]; // inside parameter value is fixed or relative
251	style += ';background-image: linear-gradient(' + this.gradientToString(theme['popup_bg_color']) + ');';
252	style += ';border:' + this.borderToString(theme['popup_border_width'], theme['popup_border_type'], theme['popup_border_color']);
253	style += ';border-radius:' + parseInt(theme['popup_border_radius']['desktop']) + theme['popup_border_radius']['metric_desktop'];
254	if (theme['popup_width'][this.defParams['currentView']] != '') {
255		style += ";max-width:" + theme['popup_width'][this.defParams['currentView']] + theme['popup_width'][metricView];
256	}
257	if (theme['popup_height'][this.defParams['currentView']] != '') {
258		style += ";max-height:" + theme['popup_height'][this.defParams['currentView']] + theme['popup_height'][metricView];
259	}
260	return style;
261}
262
263wpdaOrgChartPopup.prototype.calcViewType = function () {
264	if (window.innerWidth < parseInt(wpda_org_chart_responsive_sizes['mobile'])) {
265		this.defParams['currentView'] = 'mobile';
266		return;
267	}
268	if (window.innerWidth < parseInt(wpda_org_chart_responsive_sizes['tablet'])) {
269		this.defParams['currentView'] = 'tablet';
270		return;
271	}
272	this.defParams['currentView'] = 'desktop';
273	return;
274}
275/*helper functions*/
276wpdaOrgChartPopup.prototype.createHtmlElement = function (tag = "", attr = {}, innerHTML = "") {
277	let el = document.createElement(tag);
278	for (const key in attr) {
279		el.setAttribute(key, attr[key]);
280	}
281	if (innerHTML != '') {
282		el.innerHTML = innerHTML;
283	}
284	return el;
285}
286
287wpdaOrgChartPopup.prototype.gradientToString = function (gradient) {
288	if (gradient == null) {
289		return '';
290	}
291	let color1 = "rgba(255,255,255,0)", color2 = "rgba(255,255,255,0)", direction = "to left";
292	if ("color1" in gradient && "color2" in gradient && "gradient" in gradient) {
293		color1 = gradient['color1'];
294		color2 = gradient['color2'];
295		if (gradient['gradient'] != 'none') {
296			direction = gradient['gradient'];
297		} else {
298			color2 = color1;
299		}
300	}
301	return direction + ',' + color1 + ',' + color2;
302}
303
304wpdaOrgChartPopup.prototype.borderToString = function (borderWidth, borderType, borderColor) {
305	return border = parseInt(borderWidth['desktop']) + borderWidth['metric_desktop'] + " " + borderType + " " + borderColor;
306}
307
308wpdaOrgChartPopup.prototype.fixThemeValues = function () {
309	let types = ['desktop', 'tablet', 'mobile'];
310	if (typeof wpda_org_chart_popup_theme != 'undefined')
311		for (let i = 0; i < wpda_org_chart_popup_theme.length; i++) {
312			if (typeof (wpda_org_chart_popup_theme[i]) == 'undefined')
313				continue;
314			for (const key in wpda_org_chart_popup_theme[i]) {
315				// if value is not numeric then metric is empty
316				if (typeof (wpda_org_chart_popup_theme[i][key]) == 'object' && wpda_org_chart_popup_theme[i][key] != null) {					
317					for (let k = 0; k < types.length; k++) {
318						if (types[k] in wpda_org_chart_popup_theme[i][key] && wpda_org_chart_popup_theme[i][key]['desktop'] != '') {
319							if ('metric_' + types[k] in wpda_org_chart_popup_theme[i][key] && wpda_org_chart_popup_theme[i][key]['metric_' + types[k]] != '') {
320								if (isNaN(wpda_org_chart_popup_theme[i][key][types[k]])) {
321									wpda_org_chart_popup_theme[i][key]['metric_' + types[k]] = '';
322								}
323							}
324						}
325					}
326				}
327				// if mobile and tablet value don't filled it's equaled desktop value(on responsive parameters)
328				if (typeof (wpda_org_chart_popup_theme[i][key]) == 'object' && wpda_org_chart_popup_theme[i][key] != null) {
329					if ('desktop' in wpda_org_chart_popup_theme[i][key] && wpda_org_chart_popup_theme[i][key]['desktop'] != '') {
330						if ('mobile' in wpda_org_chart_popup_theme[i][key] && wpda_org_chart_popup_theme[i][key]['mobile'] == '') {
331							wpda_org_chart_popup_theme[i][key]['mobile'] = wpda_org_chart_popup_theme[i][key]['desktop'];
332							if ('metric_desktop' in wpda_org_chart_popup_theme[i][key] && 'metric_mobile' in wpda_org_chart_popup_theme[i][key])
333								wpda_org_chart_popup_theme[i][key]['metric_mobile'] = wpda_org_chart_popup_theme[i][key]['metric_desktop'];
334						}
335						if ('tablet' in wpda_org_chart_popup_theme[i][key] && wpda_org_chart_popup_theme[i][key]['tablet'] == '') {
336							wpda_org_chart_popup_theme[i][key]['tablet'] = wpda_org_chart_popup_theme[i][key]['desktop'];
337							if ('metric_desktop' in wpda_org_chart_popup_theme[i][key] && 'metric_tablet' in wpda_org_chart_popup_theme[i][key])
338								wpda_org_chart_popup_theme[i][key]['metric_tablet'] = wpda_org_chart_popup_theme[i][key]['metric_desktop'];
339						}
340					}
341				}
342
343			}
344		}
345}
346
347document.addEventListener('DOMContentLoaded', function () {
348	var wpdaOrgChartPopupObject = new wpdaOrgChartPopup();
349	wpdaOrgChartPopupObject.init();
350})

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.