PageSourceSearch

https://waaserfgoed.be/assets/ca/js/ca.genericpanel.js

js waaserfgoed.be collected 2026-10-02 13:46:10 UTC 6,378 bytes, 166 lines download raw bytes

1/* ----------------------------------------------------------------------
2 * js/ca/ca.genericpanel.js
3 * ----------------------------------------------------------------------
4 * CollectiveAccess
5 * Open-source collections management software
6 * ----------------------------------------------------------------------
7 *
8 * Software by Whirl-i-Gig (http://www.whirl-i-gig.com)
9 * Copyright 2010-2025 Whirl-i-Gig
10 *
11 * For more information visit http://www.CollectiveAccess.org
12 *
13 * This program is free software; you may redistribute it and/or modify it under
14 * the terms of the provided license as published by Whirl-i-Gig
15 *
16 * CollectiveAccess is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTIES whatsoever, including any implied warranty of 
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
19 *
20 * This source code is free and modifiable under the terms of 
21 * GNU General Public License. (http://www.gnu.org/copyleft/gpl.html). See
22 * the "license.txt" file for details, or visit the CollectiveAccess web site at
23 * http://www.CollectiveAccess.org
24 *
25 * ----------------------------------------------------------------------
26 */
27var caUI = caUI || {};
28
29// Global panel count; provides for control of mask when nested panels are opened
30if(caUI.panelCount === undefined) { caUI.panelCount = 0; }
31
32(function ($) {
33	caUI.initPanel = function(options) {
34		// --------------------------------------------------------------------------------
35		// setup options
36		var that = jQuery.extend({
37			panelID: 'caPanel',							/* id of enclosing panel div */
38			panelContentID: 'caPanelContent',			/* id of div within enclosing panel div that contains content */
39	
40			panelTransitionSpeed: 200,
41			allowMobileSafariZooming: false,
42			mobileSafariViewportTagID: '_msafari_viewport',
43			mobileSafariInitialZoom: "1.0",
44			mobileSafariMinZoom: "1.0",
45			mobileSafariMaxZoom: "10.0",
46			mobileSafariDeviceWidth:  "device-width",
47			mobileSafariDeviceHeight:  "device-height",
48			mobileSafariUserScaleable: false,
49			onOpenCallback: null,
50			onCloseCallback: null,
51			finallyCallback: null,
52			onEscapeCallback: null,	// called if panel is closed by escape key
53			callbackData: null,
54			
55			center: false,
56			centerHorizontal: false,
57			centerVertical : false,
58			
59			isChanging: false,
60			clearOnClose: false,
61			closeOnEsc: true
62		}, options);
63		
64		
65		// --------------------------------------------------------------------------------
66		// Define methods
67		// --------------------------------------------------------------------------------
68		that.showPanel = function(url, onCloseCallback, clearOnClose, postData, callbackData) {
69			that.setZoom(that.allowMobileSafariZooming);
70			that.isChanging = true;
71			caUI.panelCount++;
72			
73			// Set reference to panel in <div> being used
74			jQuery('#' + that.panelID).data("panel", that);
75			
76			if (that.center || that.centerHorizontal) {
77				jQuery('#' + that.panelID).css("left", ((jQuery(window).width() - jQuery('#' + that.panelID).width())/2) + "px");
78			}
79			
80			if (that.center || that.centerVertical) {
81				jQuery('#' + that.panelID).css("top", ((jQuery(window).height() - jQuery('#' + that.panelID).height())/2) + "px");
82			}
83			
84			jQuery('#' + that.panelID).fadeIn(that.panelTransitionSpeed, function() { that.isChanging = false; });
85			
86			that.callbackData = callbackData;
87			if (onCloseCallback) {
88				that.onCloseCallback = onCloseCallback;
89			}
90			
91			// Apply close behavior to selected elements
92			if (!postData) { postData = {}; }
93			if (url) {
94				jQuery('#' + that.panelContentID).load(url, postData, that.closeButtonSelector ? function() {			
95					jQuery(that.closeButtonSelector).click(function() {
96						that.hidePanel();
97					})
98				} : null);
99				that.clearOnClose = (clearOnClose == undefined) ? true : clearOnClose;
100			} else {
101				if (clearOnClose != undefined) { that.clearOnClose = clearOnClose; }
102			}
103			
104			if (that.onOpenCallback) {
105				that.onOpenCallback(url, that.callbackData);
106			}
107		}
108		
109		that.hidePanel = function(opts) {
110		    if(!opts) { opts = {}; }
111			caUI.panelCount--;
112			if (that.onCloseCallback && !opts['dontUseCallback']) {
113				that.onCloseCallback(that.callbackData);
114			}
115			that.setZoom(false);
116			that.isChanging = true;
117			jQuery('#' + that.panelID).fadeOut(that.panelTransitionSpeed, function() { that.isChanging = false; });
118			
119			if (that.clearOnClose) {
120				jQuery('#' + that.panelContentID).empty();
121				that.clearOnClose = false;
122			}
123			if(that.finallyCallback) { that.finallyCallback(that.callbackData); }
124		}
125		
126		that.panelIsVisible = function() {
127			return (jQuery('#' + that.panelID + ':visible').length > 0) ? true : false;
128		}
129		
130		that.getPanelID = function() {
131			return that.panelID;
132		}
133		
134		that.getPanelContentID = function() {
135			return that.panelContentID;
136		}
137		
138		// --------------------------------------------------------------------------------
139		// Mobile Safari zooming
140		// --------------------------------------------------------------------------------
141		that.setZoom = function(allow) {
142			if (allow) {
143				jQuery('#' + that.mobileSafariViewportTagID).attr('content','width=' + that.mobileSafariDeviceWidth + ', height=' + that.mobileSafariDeviceHeight + ', initial-scale=' + that.mobileSafariInitialZoom + ', minimum-scale=' + that.mobileSafariMinZoom + ', maximum-scale=' + that.mobileSafariMaxZoom + ', user-scalable=' + (that.mobileSafariUserScaleable ? 'yes' : 'no') + '');
144			} else {
145				jQuery('#' + that.mobileSafariViewportTagID).attr('content', 'width=' + that.mobileSafariDeviceWidth + ', height=' + that.mobileSafariDeviceHeight + ', initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=yes');
146			}
147		}
148
149		// --------------------------------------------------------------------------------
150		// Set up handler to trigger appearance of panel
151		// --------------------------------------------------------------------------------
152		jQuery(document).ready(function() {
153			// hide panel if escape key is clicked
154			jQuery(document).keyup(function(event) {
155				if (that.closeOnEsc && (event.keyCode == 27) && !that.isChanging && that.panelIsVisible()) {
156					if(that.onEscapeCallback) { that.onEscapeCallback(that.callbackData); }
157					that.hidePanel();
158				}
159			});
160		});
161		
162		// --------------------------------------------------------------------------------
163		
164		return that;
165	};	
166})(jQuery);

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.