<|start_filename|>ui/javascript/display_functions.js<|end_filename|>
$(document).ready(function () {
    //initialize map, if applicable
    if ($('#mapcontainer').length > 0) {
        var id = $('title').attr('id');
        var path = $('#path').text();
        //initialize_timemap(id, path);
        initialize_map(id, path);
    }    
    
    if ($(".thumbImage").length > 0) {
        //popup non-IIIF images on EAD pages
        $(".thumbImage").fancybox({ helpers: {
                title: {
                    type: 'inside'
                }
            }
        });
    }
    
    //show/hide sections
    $('.toggle-button').click(function () {
        var div = $(this).attr('id').split('-')[1];
        $('#' + div).toggle();
        
        //replace minus with plus and vice versa
        var span = $(this).children('span');
        if (span.attr('class').indexOf('right') > 0) {
            span.removeClass('glyphicon-triangle-right');
            span.addClass('glyphicon-triangle-bottom');
        } else {
            span.removeClass('glyphicon-triangle-bottom');
            span.addClass('glyphicon-triangle-right');
        }
        return false;
    });
    
    //IIIF in popup on EAD pages
    if ($('.iiif-image').length > 0) {
        $('.iiif-image').fancybox({
            beforeShow: function () {
                var manifest = this.element.attr('manifest');
                //remove and replace #iiif-container, if different or new
                if (manifest != $('#manifest').text()) {
                    $('#iiif-container').remove();
                    $(".iiif-container-template").clone().removeAttr('class').attr('id', 'iiif-container').appendTo("#iiif-window");
                    $('#manifest').text(manifest);
                    render_image(manifest);
                }
            },
            helpers: {
                title: {
                    type: 'inside'
                }
            }
        });
    }
    
    
    //initialize Leaflet IIIF for MODS record pages
    if ($('#info-json').length > 0) {
        var manifest = $('#info-json').text();
        render_image(manifest);
    }
    
    function render_image(manifest) {
        var iiifImage = L.map('iiif-container', {
            center:[0, 0],
            crs: L.CRS.Simple,
            zoom: 0
        });
        
        // Grab a IIIF manifest
        $.getJSON(manifest, function (data) {
            //determine where it is a collection or image manifest
            if (data[ '@context'] == 'http://iiif.io/api/image/2/context.json' || data[ '@context'] == 'http://library.stanford.edu/iiif/image-api/1.1/context.json') {
                L.tileLayer.iiif(manifest).addTo(iiifImage);
            } else if (data[ '@context'] == 'http://iiif.io/api/presentation/2/context.json') {
                var iiifLayers = {
                };
                
                // For each image create a L.TileLayer.Iiif object and add that to an object literal for the layer control
                $.each(data.sequences[0].canvases, function (_, val) {
                    iiifLayers[val.label] = L.tileLayer.iiif(val.images[0].resource.service[ '@id'] + '/info.json');
                });
                // Add layers control to the map
                L.control.layers(iiifLayers).addTo(iiifImage);
                
                // Access the first Iiif object and add it to the map
                iiifLayers[Object.keys(iiifLayers)[0]].addTo(iiifImage);
            }
        });
    }
});

<|start_filename|>xforms/templates.xhtml<|end_filename|>
<!--
	Copyright (C) 2010 <NAME>
	EADitor: https://github.com/ewg118/eaditor
	Apache License 2.0: https://github.com/ewg118/eaditor
	
	Heavily modified from upload form developed by Orbeon	
-->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
	xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:xi="http://www.w3.org/2001/XInclude">
	<head>
		<title>EADitor: Upload EAD Finding Aid</title>
		<link rel="stylesheet" href="/fr/style/bootstrap/css/bootstrap.css" type="text/css"/>
		<link rel="stylesheet" href="/fr/style/form-runner-bootstrap-override.css" type="text/css"/>
		<link rel="stylesheet" href="/config/theme/examples.css" type="text/css" media="all"/>
		<link rel="shortcut icon" href="/ops/images/orbeon-icon-16.ico"/>
		<link rel="icon" href="/ops/images/orbeon-icon-16.png" type="image/png"/>		
		<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
		<script type="text/javascript" src="https://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

		<!-- EADitor styling -->
		<link rel="stylesheet" href="/apps/eaditor/xforms/css/xforms.css"/>

		<xforms:model>
			<xforms:instance id="exist-config">
				<xi:include href="../exist-config.xml"/>
			</xforms:instance>
			<xforms:instance id="config">
				<config xmlns=""/>
			</xforms:instance>
			
			<xforms:instance id="control-instance">
				<controls xmlns="">
					<collection-name/>
				</controls>
			</xforms:instance>
			
			<!-- authentication -->
			<xforms:instance id="collections-list" xxforms:exclude-result-prefixes="#all">
				<collections xmlns=""/>
			</xforms:instance>
			
			<xforms:instance id="dump">
				<dump xmlns=""/>
			</xforms:instance>
			
			<xforms:submission id="load-collections" serialization="none" method="get" action="{instance('exist-config')/url}eaditor/collections-list.xml" replace="instance" instance="collections-list"
				xxforms:username="{instance('exist-config')/username}" xxforms:password="{instance('exist-config')/password}">
				<!-- if the config loads successfully, set the collection names based on authentication -->
				<xforms:action ev:event="xforms-submit-done">
					<xforms:setvalue ref="instance('control-instance')/collection-name"
						value="instance('collections-list')/collection[@role=instance('control-instance')/request-security/role]/@name"/>
					<xforms:send submission="load-config"/>
				</xforms:action>
				<!-- if the config has not been created (given that the URL in exist-url.xml is correct), create it -->
				<xforms:message ev:event="xforms-submit-error" level="modal">Unable to load EADitor collections list.</xforms:message>
			</xforms:submission>

			<xforms:submission id="load-config" serialization="none" method="get" action="{instance('exist-config')/url}eaditor/{instance('control-instance')/collection-name}/config.xml"
				replace="instance" instance="config" xxforms:username="{instance('exist-config')/username}" xxforms:password="{instance('exist-config')/password}">
				<xforms:message level="modal" ev:event="xforms-submit-error">Error loading config.</xforms:message>
			</xforms:submission>

			<!-- ************************ xforms-model-construct-done ****************************** -->
			<xforms:action ev:event="xforms-model-construct-done">
				<xforms:action if="string(xxforms:get-session-attribute('collection-name'))">
					<xforms:setvalue ref="instance('control-instance')/collection-name" value="xxforms:get-session-attribute('collection-name')"/>
					<xforms:send submission="load-config"></xforms:send>
				</xforms:action>
				<xforms:action if="not(string(xxforms:get-session-attribute('collection-name')))">
					<xforms:insert context="instance('control-instance')" nodeset="collection-name" position="after"
						origin="xxforms:call-xpl('oxf:/apps/eaditor/xpl/get-authentication.xpl', 'dump', instance('dump'), 'data')"></xforms:insert>
					<xforms:send submission="load-collections"></xforms:send>
				</xforms:action>
			</xforms:action>
		</xforms:model>
	</head>
	<body>
		<!-- header -->
		<xforms:var name="display_path">../</xforms:var>
		<xi:include href="header.xml"/>
		<div class="container-fluid">
			<div class="row">
				<div class="col-md-12">	
					<div id="form">
						<p>
							<a href=".."><span class="glyphicon glyphicon-arrow-left"/> Return</a>
						</p>
						<h2>Template Manager</h2>
						<p> Use this feature to customize the default templates for the core of an EAD finding aid and its components. The prepackaged templates represent a bare-bones XML model
							with inputs required by the schema or for machine processing purposes (e. g., the id attribute in &lt;ead&gt;). The template editor enables a site administrator or
							archivist to add more elements or textual values. For example, the default EAD template only requires did/unititle in the Archival Description. An institution's best
							practices may require further detail in the archdesc, such as did/unitdate, did/container, access or use restriction statements, or an abstract. The template interface is
							nearly identical in functionality as the forms for editing EAD documents themselves.</p>
						<p>In addition to EAD templating, this section offers forms for setting very restrictive controlled vocabulary (drop down menus in the EAD editor as opposed to open-ended
							autocomplete for subject terms or personal names) that are more likely to vary from institution to institution. This includes institution names/codes and container
							types.</p>
						<h3> Options </h3>
						<ul>
							<li>
								<a href="../edit/core-template/">EAD Core Template</a>
							</li>
							<li>
								<a href="../edit/c-template/">EAD Component Template</a>
							</li>							
						</ul>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>


<|start_filename|>ui/javascript/display_mirador_functions.js<|end_filename|>
/* Author: <NAME>
    Date: September 2020
    Function: instantiate a Mirador 3.x viewer for IIIF manifests */
$(document).ready(function () {
    //get necessary variables
    var publisher = encodeURI($('#publisher').text());
    var manifestURI = $('#manifestURI').text();
    var hasAnnotations = ($('#hasAnnotations').text().toLowerCase() == 'true');
    
    //construct Mirador window objects dynamically
    var windowObjects =[];
    var windowOptions = {
    };
    
    if (window.location.hash) {
        var id = window.location.hash.substring(1);
        var canvasID = manifestURI + '/canvas/' + id;
        windowOptions[ "canvasId"] = canvasID;
    }
    
    windowOptions[ "loadedManifest"] = manifestURI;
    windowOptions[ "id"] = "default";
    windowOptions[ "thumbnailNavigationPosition"] = "far-bottom";
    windowObjects.push(windowOptions);
    
    var miradorInstance = Mirador.viewer({
        "id": "mirador-div",
        "manifests": {
            manifestURI: {
                "provider": publisher
            }
        },
        "windows": windowObjects,
        "window": {
            "allowClose": false,
            "allowMaximize": false,
            "defaultSideBarPanel": ((hasAnnotations == true) ? 'annotations' : 'info'),
            "defaultView": 'gallery',
            "sideBarOpenByDefault": hasAnnotations,
            "forceDrawAnnotations": true
        },
        "thumbnailNavigation": {
            "defaultPosition": 'off'
        },
        "workspace": {
            "type": 'mosaic'
        },
        "workspaceControlPanel": {
            "enabled": false
        },
        "theme": {
            "palette": {
                "annotations": {
                    "hidden": {
                        "globalAlpha": 1
                    }
                }
            }
        }
    });
    
    //pagination for index
    $('.page-image').click(function () {
        var canvasID = $(this).attr('canvas');
        var action = Mirador.actions.setCanvas('default', canvasID);
        miradorInstance.store.dispatch(action);
    });
});

<|start_filename|>xforms/javascript/get_components.js<|end_filename|>
/************************************
GET TABLE OF CONTENTS IN EAD GUIDE LIST (ADMIN HOME)
Written by <NAME>, <EMAIL>
Library: jQuery
Description: This calls the navigation/* pipeline to show/hide the table of contents for a finding aid
in the admin home file liest
 ************************************/

function expand() {
	var collection = ORBEON.xforms.Document.getValue('collection-name');
	var id = ORBEON.xforms.Document.getValue('eadid');
	
	var container = id + '_container';
	
	if (ORBEON.jQuery('.' + container).html().indexOf('<li>') < 0) {
		ORBEON.jQuery.get('navigation/?collection=' + collection + '&guide=' + id, {
		},
		function (data) {
			ORBEON.jQuery('.' + container).html(data);
			ORBEON.jQuery('.' + container).removeClass('hidden');
		});
	} else {
		if (ORBEON.jQuery('.' + container).hasClass('hidden')){
			ORBEON.jQuery('.' + container).removeClass('hidden');
		} else {
			ORBEON.jQuery('.' + container).addClass('hidden');
		}
	}
}

<|start_filename|>ui/javascript/sort_results.js<|end_filename|>
/************************************
SORT SEARCH RESULTS
Written by <NAME>, <EMAIL>
Library: jQuery
Description: Used to generate the query for adding
the sort parameter to solr.
************************************/
$(document).ready(function(){
	$('.sortForm_categories') .change(function(){
		var val = $(this).val();
		var sort_order = $('.sortForm_order').val();		
		if (val.length > 0) {
			sort_value = get_sort_value(val, sort_order);
			$('.sort_param') .attr('value', sort_value);
			$('#sort_button') .removeAttr('disabled');
		} else {
			$('#sort_button') .attr('disabled', 'disabled');
		}
	});
	
	$('.sortForm_order') .change(function(){
		var sort_order = $(this).val();
		var val = $('.sortForm_categories').val();
		if (val.length > 0) {
			sort_value = get_sort_value(val, sort_order);
			$('.sort_param') .attr('value', sort_value);
			$('#sort_button') .removeAttr('disabled');
		} else {
			$('#sort_button') .attr('disabled', 'disabled');
		}
	});
	
	$('#sort_button').click(function(){
		var q = $(this).siblings('input[name=q]').val();
		var sort = $(this).siblings('input[name=sort]').val();
		
		//apply lang if available
		if ($(this).siblings('input[name=lang]').length > 0){
			var lang = $(this).siblings('input[name=sort]').val();			
			window.location = './?q=' + q + '&sort=' + sort + '&lang=' + lang;
		} else {
			window.location = './?q=' + q + '&sort=' + sort
		}
		return false;
	});
	
	function get_sort_value (val, sort_order){
		if (val == 'year_num' || val == 'timestamp' || val == 'unittitle_display'){
			var category = val;
		} else {
			switch(sort_order){
			case 'asc':
				var category = val + '_min';
				break;
			case 'desc':
				var category = val + '_max';
			}
		}
		return category + ' ' + sort_order;
	}
});

<|start_filename|>xforms/javascript/annotext.js<|end_filename|>
/// annotext.js by <NAME>. ver 1.5, 2017-03-12. MIT license.
AnnoText = function(){
	this.basecontext[1][this.anbase.pfx] = this.anbase.uri;
};
AnnoText.prototype = {
	anbase: {"pfx": "anbase", "uri": "http://purl.org/net/ld/annot/masaka/"},
	basecontext : [
		"http://www.w3.org/ns/anno.jsonld",
		{}
	],
	whoswho: {},
	preflang: null,
	gettext: function(an, limit){
		if(typeof(an.bodyValue) !== "undefined"){
			return this.formattext(an.bodyValue, limit, an);
		}else if(an.body && typeof(an.body.value) !== "undefined"){
			return this.formattext(an.body.value, (limit || an.body.format ||
				 (an.body.type ? an.body.type.toLowerCase() : null)), an);
		}else if(an.description){
			return this.formattext(an.description, limit);
		}else{
			return "";
		}
	},
	formattext: function(text, fmt, an){
		if(typeof(text) === "object") text = this.get_lang_text(text);
		if(typeof(fmt) === "number"){
			text = text.replace(/<.*?>/g, "").replace(/</g, "&lt;");
			return (text.length > fmt) ? text.substr(0, fmt-2) + "..." : text;
		}else{
			switch(fmt){
			case "text/html":
				return text.replace(/<script/g, "&lt;script");
			case "text/xml":
				return text;
			default:
				if(fmt){
					var mimetop = fmt.substr(0, 5);
					if(mimetop === "image"){
						return "<img alt='' src='" + text + "'/>";
					}else if(["audio","video"].indexOf(mimetop) > -1){
						return "<" + mimetop + " alt='' controls src='" + text + "'/>";
					}
				}
				text =text.replace(/</g, "&lt;");
				if(an){
					var dsid = " data-source=\"" + an.target.source + "\" data-anid=\"" + an.id + "\"";
					if(an.hasPrev) text = text.replace(/^(\.\.\.|…)/, "<a href=\"#!prev\"" + dsid + " title=\"cont'd from prev\">...</a> ");
					if(an.hasNext) text = text.replace(/(\.\.\.|…)$/, " <a href=\"#!next\"" + dsid + "title=\"cont'd on next\">...</a>");
				}
				return this.md2link(text);
			}
		}
	},
	get_lang_text: function(text){
		if(Mut) return Mut.str.lang_val(text);
		if(!this.preflang){
			var lang = navigator.userLanguage || navigator.language;
			this.preflang = lang.substr(0,2).toLowerCase();
		}
		var en, none, other = [];
		for(var lang in text){
			if(lang.substr(0,2) === this.preflang) return text[lang].join(";");
			else if(lang.substr(0,2) === "en") en = text[lang].join(";");
			else if(lang === "@none") none = text[lang].join(";");
			else other.push(text[lang].join(";"));
		}
		return en || none || other.shift();
	},
	settext: function(an){
		if(an){
			if(an.hasPrev) an.text = an.text.replace(/^<a href="#!prev".*?<\/a>/, "...");
			if(an.hasNext) an.text = an.text.replace(/<a href="#!next".*?<\/a>$/, "...");
		}
		return this.link2md(an.text);
	},
	md2link: function(text){
		return this.mdhilite(text)
		.replace(/!\[([^\]]+)\]\(([^\)]+)\)/g, function(txt, alt, url){
			var elt, attr = " alt='" + alt + "'";
			if(url.match(/\.mp4$/)){elt = "video"; attr += " controls";}
			else if(url.match(/\.mp3$/)){elt = "audio"; attr += " controls";}
			else elt = "img";
			return "<" + elt + attr + " src='" + url + "'/>";
		})
		.replace(/\[([^\]]+)\]\(([^\)]+)\)/g, "<a href='$2'>$1</a>");
	},
	mdhilite: function(text){
		return text
		.replace(/\*\*([^\*]+)\*\*/, "<strong>$1</strong>")
		.replace(/\b_([^_]+)_\b/, "<em>$1</em>")
		.replace(/`([^`]+)`/, "<code>$1</code>");
	},
	link2md: function(text){
		if(text === "") return text;
		return text
		.replace(/<(img|video|audio) alt=['"](.*?)['"].* src=['"](.*?)['"]\/?>/g, "![$2]($3)")
		.replace(/<a href=['"](.*?)['"]>(.*?)<\/a>/g, "[$2]($1)");
	},
	getUTCdateTime: function(val){
		var date = val ? new Date(val) : new Date();
		return date.getUTCFullYear() + '-' +
		('0' + (date.getUTCMonth() + 1)).slice(-2) + '-' +
		('0' + date.getUTCDate()).slice(-2) + 'T' +
		('0' + date.getUTCHours()).slice(-2) + ':' +
		('0' + date.getMinutes()).slice(-2) + ':' +
		('0' + date.getSeconds()).slice(-2) + 'Z';
	},
	getLastUripart: function(uri){
		uri.match(/[\/#]([^\/#]+)$/);
		return RegExp.$1;
	},
	getCreator: function(an){
		if(!an.creator){
			return this.registWhoswho("anonymous");
		}else if(typeof(an.creator) === "string"){
			return this.registWhoswho(an.creator);
		}else{
			var uri = an.creator.id || an.creator["@id"] || an.creator.homepage || null;
			var id = "_" + uri;
			var name = an.creator.name || an.creator.nickname || an.creator.displayName || null;
			if(!id && name) id = name;
			if(!id) return this.registWhoswho("unknown");
			if(!this.whoswho[id]){
				this.whoswho[id] = {
					"meta": an.creator,
					"dispname": (name ? name : "\u200B"+this.getLastUripart(id))
				};
			}
			if(this.whoswho[uri] && this.whoswho[uri].dispname.substr(0,1)==="\u200B" && name){
				this.whoswho[uri].dispname = name;
			}
			return id;
		}
	},
	registWhoswho: function(user){
		if(!this.whoswho[user]){
			this.whoswho[user] = {"meta": user==="anonymous" || user==="unknown" ? "" : user};
			this.whoswho[user].dispname = user.match(/^(https?|urn):/) ?
			"\u200B"+this.getLastUripart(user) : user;
		}
		return user;
	},
	setCreator: function(id){
		if(!this.whoswho[id] || id==="anonymous") return "";
		return this.whoswho[id].meta;
	},
	
	getDate: function(an, type){
		var dval = type ? an[type] : an.created;
		if(!dval) return "";
		return new Date(dval).toLocaleDateString();
	},
	md5: function(str){
		var md5 = new yjdMd5();
		return md5.GetOfString(str);
	},
	crc32: function(str){
		var crcTable = this.ct(), crc = 0 ^ (-1);
		for (var i = 0; i < str.length; i++ ) crc = (crc >>> 8) ^ crcTable[(crc ^ str.charCodeAt(i)) & 0xFF];
		return (crc ^ (-1)) >>> 0;
	},
	ct: function(){
		var c, crcTable = [];
		for(var n =0; n < 256; n++){
			c = n;
			for(var k =0; k < 8; k++) c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
			crcTable[n] = c >>> 0;
		}
		return crcTable;
	},
};
var at = new AnnoText();


var yjdMd5 = function() {
	this.au32_state = new Uint32Array(4);
	this.au32_buffer = null;
	this.n_blocks = 0;
	
	this.Init = function() {
		this.au32_state[0] = 0x67452301;
		this.au32_state[1] = 0xefcdab89;
		this.au32_state[2] = 0x98badcfe;
		this.au32_state[3] = 0x10325476;
	};
	
	this.Transform = function() {
		var a, b, c, d;
		var x00, x01, x02, x03, x04, x05, x06, x07, x08, x09, x10, x11, x12, x13, x14, x15;
		var n_idx = 0;
		for( var i=0; i<this.n_blocks; i++) {
			a = this.au32_state[0];
			b = this.au32_state[1];
			c = this.au32_state[2];
			d = this.au32_state[3];
			
			x00 = this.au32_buffer[n_idx++];
			x01 = this.au32_buffer[n_idx++];
			x02 = this.au32_buffer[n_idx++];
			x03 = this.au32_buffer[n_idx++];
			x04 = this.au32_buffer[n_idx++];
			x05 = this.au32_buffer[n_idx++];
			x06 = this.au32_buffer[n_idx++];
			x07 = this.au32_buffer[n_idx++];
			x08 = this.au32_buffer[n_idx++];
			x09 = this.au32_buffer[n_idx++];
			x10 = this.au32_buffer[n_idx++];
			x11 = this.au32_buffer[n_idx++];
			x12 = this.au32_buffer[n_idx++];
			x13 = this.au32_buffer[n_idx++];
			x14 = this.au32_buffer[n_idx++];
			x15 = this.au32_buffer[n_idx++];
			
			a += ((b & c) | (~b & d)) + x00 + 0xd76aa478;	a = ((a << 7) | (a >>> 25)) + b;
			d += ((a & b) | (~a & c)) + x01 + 0xe8c7b756;	d = ((d << 12) | (d >>> 20)) + a;
			c += ((d & a) | (~d & b)) + x02 + 0x242070db;	c = ((c << 17) | (c >>> 15)) + d;
			b += ((c & d) | (~c & a)) + x03 + 0xc1bdceee;	b = ((b << 22) | (b >>> 10)) + c;
			a += ((b & c) | (~b & d)) + x04 + 0xf57c0faf;	a = ((a << 7) | (a >>> 25)) + b;
			d += ((a & b) | (~a & c)) + x05 + 0x4787c62a;	d = ((d << 12) | (d >>> 20)) + a;
			c += ((d & a) | (~d & b)) + x06 + 0xa8304613;	c = ((c << 17) | (c >>> 15)) + d;
			b += ((c & d) | (~c & a)) + x07 + 0xfd469501;	b = ((b << 22) | (b >>> 10)) + c;
			a += ((b & c) | (~b & d)) + x08 + 0x698098d8;	a = ((a << 7) | (a >>> 25)) + b;
			d += ((a & b) | (~a & c)) + x09 + 0x8b44f7af;	d = ((d << 12) | (d >>> 20)) + a;
			c += ((d & a) | (~d & b)) + x10 + 0xffff5bb1;	c = ((c << 17) | (c >>> 15)) + d;
			b += ((c & d) | (~c & a)) + x11 + 0x895cd7be;	b = ((b << 22) | (b >>> 10)) + c;
			a += ((b & c) | (~b & d)) + x12 + 0x6b901122;	a = ((a << 7) | (a >>> 25)) + b;
			d += ((a & b) | (~a & c)) + x13 + 0xfd987193;	d = ((d << 12) | (d >>> 20)) + a;
			c += ((d & a) | (~d & b)) + x14 + 0xa679438e;	c = ((c << 17) | (c >>> 15)) + d;
			b += ((c & d) | (~c & a)) + x15 + 0x49b40821;	b = ((b << 22) | (b >>> 10)) + c;
			a += ((b & d) | (c & ~d)) + x01 + 0xf61e2562;	a = ((a << 5) | (a >>> 27)) + b;
			d += ((a & c) | (b & ~c)) + x06 + 0xc040b340;	d = ((d << 9) | (d >>> 23)) + a;
			c += ((d & b) | (a & ~b)) + x11 + 0x265e5a51;	c = ((c << 14) | (c >>> 18)) + d;
			b += ((c & a) | (d & ~a)) + x00 + 0xe9b6c7aa;	b = ((b << 20) | (b >>> 12)) + c;
			a += ((b & d) | (c & ~d)) + x05 + 0xd62f105d;	a = ((a << 5) | (a >>> 27)) + b;
			d += ((a & c) | (b & ~c)) + x10 + 0x2441453;	d = ((d << 9) | (d >>> 23)) + a;
			c += ((d & b) | (a & ~b)) + x15 + 0xd8a1e681;	c = ((c << 14) | (c >>> 18)) + d;
			b += ((c & a) | (d & ~a)) + x04 + 0xe7d3fbc8;	b = ((b << 20) | (b >>> 12)) + c;
			a += ((b & d) | (c & ~d)) + x09 + 0x21e1cde6;	a = ((a << 5) | (a >>> 27)) + b;
			d += ((a & c) | (b & ~c)) + x14 + 0xc33707d6;	d = ((d << 9) | (d >>> 23)) + a;
			c += ((d & b) | (a & ~b)) + x03 + 0xf4d50d87;	c = ((c << 14) | (c >>> 18)) + d;
			b += ((c & a) | (d & ~a)) + x08 + 0x455a14ed;	b = ((b << 20) | (b >>> 12)) + c;
			a += ((b & d) | (c & ~d)) + x13 + 0xa9e3e905;	a = ((a << 5) | (a >>> 27)) + b;
			d += ((a & c) | (b & ~c)) + x02 + 0xfcefa3f8;	d = ((d << 9) | (d >>> 23)) + a;
			c += ((d & b) | (a & ~b)) + x07 + 0x676f02d9;	c = ((c << 14) | (c >>> 18)) + d;
			b += ((c & a) | (d & ~a)) + x12 + 0x8d2a4c8a;	b = ((b << 20) | (b >>> 12)) + c;
			a += (b ^ c ^ d) + x05 + 0xfffa3942;	a = ((a << 4) | (a >>> 28)) + b;
			d += (a ^ b ^ c) + x08 + 0x8771f681;	d = ((d << 11) | (d >>> 21)) + a;
			c += (d ^ a ^ b) + x11 + 0x6d9d6122;	c = ((c << 16) | (c >>> 16)) + d;
			b += (c ^ d ^ a) + x14 + 0xfde5380c;	b = ((b << 23) | (b >>> 9)) + c;
			a += (b ^ c ^ d) + x01 + 0xa4beea44;	a = ((a << 4) | (a >>> 28)) + b;
			d += (a ^ b ^ c) + x04 + 0x4bdecfa9;	d = ((d << 11) | (d >>> 21)) + a;
			c += (d ^ a ^ b) + x07 + 0xf6bb4b60;	c = ((c << 16) | (c >>> 16)) + d;
			b += (c ^ d ^ a) + x10 + 0xbebfbc70;	b = ((b << 23) | (b >>> 9)) + c;
			a += (b ^ c ^ d) + x13 + 0x289b7ec6;	a = ((a << 4) | (a >>> 28)) + b;
			d += (a ^ b ^ c) + x00 + 0xeaa127fa;	d = ((d << 11) | (d >>> 21)) + a;
			c += (d ^ a ^ b) + x03 + 0xd4ef3085;	c = ((c << 16) | (c >>> 16)) + d;
			b += (c ^ d ^ a) + x06 + 0x4881d05;	b = ((b << 23) | (b >>> 9)) + c;
			a += (b ^ c ^ d) + x09 + 0xd9d4d039;	a = ((a << 4) | (a >>> 28)) + b;
			d += (a ^ b ^ c) + x12 + 0xe6db99e5;	d = ((d << 11) | (d >>> 21)) + a;
			c += (d ^ a ^ b) + x15 + 0x1fa27cf8;	c = ((c << 16) | (c >>> 16)) + d;
			b += (c ^ d ^ a) + x02 + 0xc4ac5665;	b = ((b << 23) | (b >>> 9)) + c;
			a += (c ^ (b | ~d)) + x00 + 0xf4292244;	a = ((a << 6) | (a >>> 26)) + b;
			d += (b ^ (a | ~c)) + x07 + 0x432aff97;	d = ((d << 10) | (d >>> 22)) + a;
			c += (a ^ (d | ~b)) + x14 + 0xab9423a7;	c = ((c << 15) | (c >>> 17)) + d;
			b += (d ^ (c | ~a)) + x05 + 0xfc93a039;	b = ((b << 21) | (b >>> 11)) + c;
			a += (c ^ (b | ~d)) + x12 + 0x655b59c3;	a = ((a << 6) | (a >>> 26)) + b;
			d += (b ^ (a | ~c)) + x03 + 0x8f0ccc92;	d = ((d << 10) | (d >>> 22)) + a;
			c += (a ^ (d | ~b)) + x10 + 0xffeff47d;	c = ((c << 15) | (c >>> 17)) + d;
			b += (d ^ (c | ~a)) + x01 + 0x85845dd1;	b = ((b << 21) | (b >>> 11)) + c;
			a += (c ^ (b | ~d)) + x08 + 0x6fa87e4f;	a = ((a << 6) | (a >>> 26)) + b;
			d += (b ^ (a | ~c)) + x15 + 0xfe2ce6e0;	d = ((d << 10) | (d >>> 22)) + a;
			c += (a ^ (d | ~b)) + x06 + 0xa3014314;	c = ((c << 15) | (c >>> 17)) + d;
			b += (d ^ (c | ~a)) + x13 + 0x4e0811a1;	b = ((b << 21) | (b >>> 11)) + c;
			a += (c ^ (b | ~d)) + x04 + 0xf7537e82;	a = ((a << 6) | (a >>> 26)) + b;
			d += (b ^ (a | ~c)) + x11 + 0xbd3af235;	d = ((d << 10) | (d >>> 22)) + a;
			c += (a ^ (d | ~b)) + x02 + 0x2ad7d2bb;	c = ((c << 15) | (c >>> 17)) + d;
			b += (d ^ (c | ~a)) + x09 + 0xeb86d391;	b = ((b << 21) | (b >>> 11)) + c;
			
			this.au32_state[0] += a;
			this.au32_state[1] += b;
			this.au32_state[2] += c;
			this.au32_state[3] += d;
		}
	};
	
	this.Padding = function(n_length) {
		var n_mod = n_length % 4;
		var n_idx = (n_length - n_mod) / 4;
		this.au32_buffer[n_idx++] |= (0x80 << (n_mod * 8));
		while(n_idx % 16!=14) {
			this.au32_buffer[n_idx++] = 0;
		}
		var n_bit_len = n_length * 8;
		this.au32_buffer[n_idx++] = n_bit_len;
		this.au32_buffer[n_idx++] = Math.floor(n_bit_len / 4294967296);
		this.n_blocks = n_idx / 16;
	};
	
	this.SetString = function(s_str) {
		var n_max_bytes = s_str.length * 4;
		var n_buff_size = (Math.floor((n_max_bytes + 8) / 64) + 1) * 16;
		this.au32_buffer = new Uint32Array(n_buff_size);
		var n_len = s_str.length;
		var n_idx = 0, n_shift = 0, n_code;
		for(var i=0; i<n_len; i++) {
			n_code = s_str.charCodeAt(i);
			if(n_code < 0x80) {
				this.au32_buffer[n_idx] |= (n_code << n_shift);	(n_shift==24)? (n_idx++, n_shift=0): n_shift += 8;
			} else if(n_code < 0x800) {
				this.au32_buffer[n_idx] |= ((0xc0 | (n_code >>> 6)) << n_shift);	(n_shift==24)? (n_idx++, n_shift=0): n_shift += 8;
				this.au32_buffer[n_idx] |= ((0x80 | (n_code & 0x3f)) << n_shift);	(n_shift==24)? (n_idx++, n_shift=0): n_shift += 8;
			} else if(n_code < 0xd800 || n_code >= 0xe000) {
				this.au32_buffer[n_idx] |= ((0xe0 | (n_code >>> 12)) << n_shift);	(n_shift==24)? (n_idx++, n_shift=0): n_shift += 8;
				this.au32_buffer[n_idx] |= ((0x80 | ((n_code>>>6) & 0x3f)) << n_shift);	(n_shift==24)? (n_idx++, n_shift=0): n_shift += 8;
				this.au32_buffer[n_idx] |= ((0x80 | (n_code & 0x3f)) << n_shift);	(n_shift==24)? (n_idx++, n_shift=0): n_shift += 8;
			} else {
				this.au32_buffer[n_idx] |= ((0xf0 | (n_code >>>18)) << n_shift);	(n_shift==24)? (n_idx++, n_shift=0): n_shift += 8;
				this.au32_buffer[n_idx] |= ((0x80 | ((n_code>>>12) & 0x3f)) << n_shift);	(n_shift==24)? (n_idx++, n_shift=0): n_shift += 8;
				this.au32_buffer[n_idx] |= ((0x80 | ((n_code>>>6) & 0x3f)) << n_shift);	(n_shift==24)? (n_idx++, n_shift=0): n_shift += 8;
				this.au32_buffer[n_idx] |= ((0x80 | (n_code & 0x3f)) << n_shift);	(n_shift==24)? (n_idx++, n_shift=0): n_shift += 8;
			}
		}
		return n_idx * 4 + n_shift / 8;
	};

	
	this.GetValueByStr = function() {
		var n_reg, c0, c1, c2, c3, c4, c5, c6, c7;
		var s_str = '';
		for(var i=0; i<4; i++) {
			n_reg = this.au32_state[i];
			c0 = (n_reg >>> 4) & 0xF;
			c1 = n_reg & 0xF;
			c2 = (n_reg >>> 12) & 0xF;
			c3 = (n_reg >>> 8) & 0xF;
			c4 = (n_reg >>> 20) & 0xF;
			c5 = (n_reg >>> 16) & 0xF;
			c6 = (n_reg >>> 28) & 0xF;
			c7 = (n_reg >>> 24) & 0xF;
 			s_str += c0.toString(16) + c1.toString(16) + c2.toString(16) + c3.toString(16)
 					+ c4.toString(16) + c5.toString(16) + c6.toString(16) + c7.toString(16);
		}
		return s_str;
	};
	
	this.GetOfString = function(s_str) {
		this.Init();
		var n_bytes = this.SetString(s_str);
		this.Padding(n_bytes);
		this.Transform();
		return this.GetValueByStr();
	};
};


<|start_filename|>ui/javascript/get_facets.js<|end_filename|>
/************************************
GET FACET TERMS IN RESULTS PAGE
Written by <NAME>, <EMAIL>
Library: jQuery
Description: This utilizes ajax to populate the list of terms in the facet category in the results page.  
If the list is populated and then hidden, when it is re-activated, it fades in rather than executing the ajax call again.
************************************/
$(document).ready(function() {
	var popupStatus = 0;
	var langStr = getURLParameter('lang');
	var pipeline = $('#pipeline').text();
	var path = $('#path').text();
	if (langStr == 'null'){
		var lang = '';
	} else {
		var lang = langStr;
	}
	
	
	//set hierarchical labels on load
	$('.hierarchical-facet').each(function () {
		var field = $(this).attr('id').split('_hier')[0];
		var title = $(this).attr('title');
		hierarchyLabel(field, title);
	});
	
	/*if ($('#century_num').length > 0){
		if ($('#century_num-list').html().indexOf('<li') > 0) {
			dateLabel();
		}
	}*/
	
	$("#backgroundPopup").on('click', function (event) {
		disablePopup();
	});
	
	/***** SEARCH *****/
	$('#search_button') .click(function () {
		var q = getQuery();
		$('#facet_form_query').attr('value', q);
	});
	
	//multiselect facets
	$('.multiselect').multiselect({
		buttonWidth: '250px',
		enableCaseInsensitiveFiltering: true,
		maxHeight: 250,
		buttonText: function (options, select) {
			if (options.length == 0) {
				return select.attr('title');
			} else if (options.length > 2) {
				return select.attr('title') + ': ' + options.length + ' selected';
			} else {
				var selected = '';
				options.each(function () {
					selected += $(this).text() + ', ';
				});
				label = selected.substr(0, selected.length - 2);
				if (label.length > 20) {
					label = label.substr(0, 20) + '...';
				}
				return select.attr('title') + ': ' + label;
			}
		},
		onChange: function (element, checked) {
			//if there are 0 selected checks in the multiselect, re-initialize ajax to populate list
			id = element.parent('select').attr('id');
			if ($('#' + id).val() == null) {
				var q = getQuery();
				var category = id.split('-select')[0];
				$.get(path + 'get_facets/', {
					q: q, category: category, sort: 'index', lang: lang
				},
				function (data) {
					$('#ajax-temp').html(data);
					$('#' + id) .html('');
					$('#ajax-temp option').each(function () {
						$(this).clone().appendTo('#' + id);
					});
					$("#" + id).multiselect('rebuild');
				});
			}
		}
	});
	
	//on open
	$('button.multiselect').on('click', function () {
		var q = getQuery();
		var id = $(this).parent('div').prev('select').attr('id');
		var category = id.split('-select')[0];
		$.get(path + 'get_facets/', {
			q: q, category: category, sort: 'index', lang: lang, pipeline: pipeline
		},
		function (data) {
			$('#ajax-temp').html(data);
			$('#' + id) .html('');
			$('#ajax-temp option').each(function () {
				$(this).clone().appendTo('#' + id);
			});
			$("#" + id).multiselect('rebuild');
		});
	});
	
	/***************** DRILLDOWN HIERARCHICAL FACETS ********************/
	$('.hier-close').click(function () {
		disablePopup();
		return false;
	});
	
	$('.hierarchical-facet').click(function () {
		if (popupStatus == 0) {
			$("#backgroundPopup").fadeIn("fast");
			popupStatus = 1;
		}
		
		var q = getQuery();	
		var field = $(this).attr('id').split('_hier')[0];
		var list_id = $(this).attr('id').split('-btn')[0] + '-list';
		if ($('#' + list_id).html().indexOf('<li') < 0) {
			$.get('get_hier', {
				q: q, field: field, prefix: 'L1', fq: '*', link: '', lang: lang
			},
			function (data) {
				alert(data);
				$('#ajax-temp').html(data);
				$('#ajax-temp li').each(function () {
					$(this).clone().appendTo('#' + list_id);
				});
			});
		}
		
		$('#' + list_id).parent('div').addClass('open');
		$('#' + list_id).show();
	});
	
	//expand category when expand/compact image pressed
	$('.hier-list').on('click', 'li .expand_category', function () {
		var fq = $(this).next('input').val();
		var list = $(this).attr('id').split('__')[0].split('/')[1] + '__list';
		var field = $(this).attr('field');
		var prefix = $(this).attr('next-prefix');
		var q = getQuery();
		var section = $(this).attr('section');
		var link = $(this).attr('link');
		
		if ($(this).attr('class').indexOf('minus') > 0) {
			$(this).removeClass('glyphicon-minus');
			$(this).addClass('glyphicon-plus');
			$('#' + list).hide();
		} else {
			$(this).removeClass('glyphicon-plus');
			$(this).addClass('glyphicon-minus');
			//perform ajax load on first click of expand button
			if ($(this).parent('li').children('ul').html().indexOf('<li') < 0) {
				$.get('get_hier', {
					q: q, field: field, prefix: prefix, fq: '"' + fq + '"', link: link, section: section, lang: lang
				},
				function (data) {
					$('#ajax-temp').html(data);
					$('#ajax-temp li').each(function () {
						$(this).clone().appendTo('#' + list);
					});
				});
			}
			$('#' + list).show();
		}
	});
	
	//remove all ancestor or descendent checks on uncheck
	$('.hier-list').on('click', 'li input', function () {
		var field = $(this).attr('field');
		var title = $(this).closest('#' + field + '_hier-list').prev('button').attr('title');
		
		var count_checked = 0;
		$('#' + field + '_hier-list input:checked').each(function () {
			count_checked++;
		});
		
		if (count_checked > 0) {
			hierarchyLabel(field, title);
		} else {
			$('#' + field + '_hier-btn').children('span').text(title);
		}
	});	
	
	/***************** DRILLDOWN FOR DATES ********************/
	
	$('.century-close').on('click', function (event) {
		disablePopup();
		return false;
	});
	
	$('#century_num-btn').on('click', function (event) {
		if (popupStatus == 0) {
			$("#backgroundPopup").fadeIn("fast");
			popupStatus = 1;
		}
		
		q = getQuery();
		var list_id = $(this).attr('id').split('-btn')[0] + '-list';
		if ($('#' + list_id).html().indexOf('<li') < 0) {
			$.get('get_centuries', {
				q: q
			},
			function (data) {
				$('#ajax-temp').html(data);
				$('#ajax-temp li').each(function () {
					$(this).clone().appendTo('#' + list_id);
				});
			});
		}
		
		$('#' + list_id).parent('div').addClass('open');
		$('#' + list_id).show();
	});
	
	$('#century_num-list').on('click', 'li .expand_century', function () {
		var century = $(this).attr('century');
		var q = getQuery();
		//hide list if it is expanded
		if ($(this).attr('class').indexOf('minus') > 0) {
			$(this).removeClass('glyphicon-minus');
			$(this).addClass('glyphicon-plus');
			$('#century_' + century + '_list').hide();
		} else {
			$(this).removeClass('glyphicon-plus');
			$(this).addClass('glyphicon-minus');
			//perform ajax load on first click of expand button
			if ($(this).parent('li').children('ul').html().indexOf('<li') < 0) {
				$.get('get_decades', {
					q: q, century: century
				},
				function (data) {
					$('#ajax-temp').html(data);
					$('#ajax-temp li').each(function () {
						$(this).clone().appendTo('#century_' + century + '_list');
					});
				});
			}
			$('#century_' + century + '_list').show();
		}
	});
	
	//check parent century box when a decade box is checked
	$('#century_num-list').on('click', 'li ul li .decade_checkbox', function () {
		if ($(this).is(':checked')) {
			$(this).parent('li').parent('ul').parent('li').children('input').attr('checked', true);
		}
		//set label
		dateLabel();
	});
	//uncheck child decades when century is unchecked
	$('#century_num-list').on('click', 'li .century_checkbox', function () {
		if ($(this).not(':checked')) {
			$(this).parent('li').children('ul').children('li').children('.decade_checkbox').attr('checked', false);
		}
		//set label
		dateLabel();
	});

	/***************************/
	//@Author: Adrian "yEnS" <NAME>
	//@website: www.yensdesign.com
	//@email: <EMAIL>
	//@license: Feel free to use it, but keep this credits please!
	/***************************/
	
	//disabling popup with jQuery magic!
	function disablePopup() {
		//disables popup only if it is enabled
		if (popupStatus == 1) {	
			$("#backgroundPopup").fadeOut("fast");
			$('#century_num-list').parent('div').removeClass('open');
			popupStatus = 0;		
		}
	}
	
	function getURLParameter(name) {
	    return decodeURI(
	        (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
	    );
	}
});

<|start_filename|>ui/javascript/facet_functions.js<|end_filename|>
/*******************
FUNCTIONS USED IN FACET-BASED PAGES: BROWSE, COLLECTION, AND MAPS
********************/
function getQuery() {
	//get categories
	query = new Array();
	
	//get non-facet fields that may have been passed from search
	var query_terms = $('#facet_form_query').attr('value').split(' AND ');
	var non_facet_terms = new Array();
	for (i in query_terms) {
		if (query_terms[i].indexOf('_facet') < 0 && query_terms[i].indexOf('dob_num') < 0 && query_terms[i] != '*:*') {
			non_facet_terms.push(query_terms[i]);
		}
	}
	if (non_facet_terms.length > 0) {
		query.push(non_facet_terms.join(' AND '));
	}
	
	//hierarchical facets
	$('.hierarchical-list').each(function () {
		var field = $(this).attr('id').split('-list')[0];
		var categories = new Array();
		$(this).find('input:checked') .each(function () {
			if ($(this) .parent('.h_item') .html() .indexOf('category_level') < 0 || $(this) .parent('.h_item') .children('ul') .html() .indexOf('<li') < 0 || $(this) .parent('.h_item') .children('.category_level').find('input:checked').length == 0) {
				segment = new Array();
				$(this) .parents('.h_item').each(function () {
					segment.push('+"' + $(this).children('input').val() + '"');
				});
				var joined = field + ':(' + segment.join(' ') + ')';
				categories.push(joined);
			}
		});
		//if the categories array is not null, establish the category query string
		if (categories[0] != null) {
			if (categories.length > 1) {
				query.push('(' + categories.join(' OR ') + ')');
			} else {
				query.push(categories[0]);
			}
		}
	});
	
	//get century/decades
	var date = getDate();
	if (date.length > 0) {
		query.push(getDate());
	}
	
	$('select.multiselect').each(function () {
		var val = $(this).val();
		var facet = $(this).attr('id').split('-')[0];
		if (val != null) {
			segments = new Array();
			for (var i = 0; i < val.length; i++) {
				segments.push(facet + ':"' + val[i] + '"');
			}
			if (segments.length > 1) {
				query.push('(' + segments.join(' OR ') + ')');
			} else {
				query.push(segments[0]);
			}
		}
	});
	
	//keyword search (only implemented on collection page)
	if ($('#keyword').length > 0) {
		if ($('#keyword').val().length > 0) {
			query.push($('#keyword').val());
		}
	}
	
	//date range search (only implemented on collection page)
	if ($('#from_date').length > 0 || $('#to_date').length > 0) {
		if ($('#from_date') .val().length > 0 || $('#to_date') .val().length > 0) {
			var string = '';
			string += 'year_num:';
			var from_date = $('#from_date') .val().length > 0? $('#from_date') .val(): '*';
			var from_era = $('#from_era') .val() == 'minus'? '-': '';
			
			var to_date = $('#to_date') .val().length > 0? $('#to_date') .val(): '*';
			var to_era = $('#to_era') .val() == 'minus'? '-': '';
			
			string += '[' + (from_date == '*'? '': from_era) + from_date + ' TO ' + (to_date == '*'? '': to_era) + to_date + ']';
			query.push(string);
		}
	}
	
	//set the value attribute of the q param to the query assembled by javascript
	
	if (query.length > 0) {
		return query.join(' AND ');
	} else {
		return '*:*';
	}
}

//function for assembling the Lucene syntax string for querying on centuries and decades
function getDate() {
	var date_array = new Array();
	$('.century_checkbox:checked').each(function () {
		var val = $(this).val();
		if (val < 0) {
			val = '\\' + val;
		}
		var century = 'century_num:' + val;
		var decades = new Array();
		$(this).parent('li').children('ul').children('li').children('.decade_checkbox:checked').each(function () {
			var dval = $(this).val();
			if (dval < 0) {
				dval = '\\' + dval;
			}
			decades.push('decade_num:' + dval);
		});
		var decades_concat = '';
		if (decades.length > 1) {
			decades_concat = '(' + decades.join(' OR ') + ')';
			date_array.push(decades_concat);
		} else if (decades.length == 1) {
			date_array.push(decades[0]);
		} else {
			date_array.push(century);
		}
	});
	var date_query;
	if (date_array.length > 1) {
		date_query = '(' + date_array.join(' OR ') + ')'
	} else if (date_array.length == 1) {
		date_query = date_array[0];
	} else {
		date_query = '';
	}
	return date_query;
};

function dateLabel() {	
	var title = $('#century_num-btn').attr('title');
	if (title.indexOf(':') > 0){
		title = title.split(':')[0];
	}
	dates = new Array();
	$('.century_checkbox:checked').each(function () {
		if ($(this).parent('li').children('ul').children('li').children('.decade_checkbox:checked').length == 0) {
			var century = Math.abs($(this).val());
			var suffix;
			switch (century % 10) {
				case 1:
				suffix = 'st';
				break;
				case 2:
				suffix = 'nd';
				break;
				case 3:
				suffix = 'rd';
				break;
				default:
				suffix = 'th';
			}
			label = century + suffix;
			if ($(this).val() < 0) {
				label += ' B.C.';
			}
			dates.push(label);
		}
		$(this).parent('li').children('ul').children('li').children('.decade_checkbox:checked').each(function () {
			dates.push($(this).val());
		});
	});
	if (dates.length > 3) {
		var date_string = title + ': ' + dates.length + ' selected';
	} else if (dates.length > 0 && dates.length <= 3) {
		var date_string = title + ': ' + dates.join(', ');
	} else if (dates.length == 0) {
		var date_string = title;
	}
	//set labels
	$('#century_num-btn').attr('title', date_string);
	$('#century_num-btn').children('span:nth-child(2)').text(date_string);
}

function hierarchyLabel(field, title) {
	categories = new Array();
	$('#' + field + '_hier-list input:checked') .each(function () {
		if ($(this) .parent('.h_item') .html() .indexOf('category_level') < 0 || $(this) .parent('.h_item') .children('ul') .html() .indexOf('<li') < 0 || $(this) .parent('.h_item') .children('.category_level').find('input:checked').length == 0) {
			segment = new Array();
			$(this) .parents('.h_item').each(function () {
				segment.push($(this).children('input').val().split('|')[1]);
			});
			var joined = segment.reverse().join('--');
			categories.push(joined);
			if (categories.length > 0 && categories.length <= 3) {
				$('#' + field + '_hier_link').attr('title', title + ': ' + categories.join(', '));
				$('#' + field + '_hier_link').children('span:nth-child(2)').text(title + ': ' + categories.join(', '));
			} else if (categories.length > 3) {
				$('#' + field + '_hier_link').attr('title', title + ': ' + categories.length + ' selected');
				$('#' + field + '_hier_link').children('span:nth-child(2)').text(title + ': ' + categories.length + ' selected');
			}
		}
	});
}

<|start_filename|>xforms/xbl/permissions/permissions.css<|end_filename|>
ul li {
	list-style-type:none;
}
.component {
	border:1px solid silver;
	margin:5px 0;
	padding: 5px;
	border-radius:15px;
}

<|start_filename|>xforms/javascript/annotation_functions.js<|end_filename|>
/********
* Author: <NAME>
* Last modified: January 2019
* Function: Parse URIs pasted into WebAnnotorious annotations to extract human readable labels and construct HTML links
*********/

/********** URI PARSING **********/
//construct HTML links from regular expressions
function replaceURLWithHTMLLinks(text) {
    var exp = /((^|\s)?https?:\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])($|\s)/ig;
    return text.replace(exp, constructLink);
}

function constructLink(match, p1, offset, string) {
    var spacer = (p1.substring(0, 1) == ' ' ? ' ' : '')
    p1 = p1.trim();
    
    //perform API call to normalize the inserted link into the stable entity URI and preferred label
    entity = getLabel(p1);  
    
    return spacer + "<a href='" + entity.uri.replace('&', '&amp;') + "'>" + entity.label.replace('&', '&amp;') + "</a>";
}

//construct the linkable text depending on the URI (handle nomisma and Mantis URIs)
function getLabel(uri) {
    var label;
    var path = '../../../' + ORBEON.xforms.Document.getValue('collection-name') + '/';
    $.ajaxSetup({
        async: false
    });
    $.getJSON(path + 'get_label', {
        uri: uri
    },
    function (data) {
        label = data;
    });
    return label;
}

<|start_filename|>ui/javascript/result_map_functions.js<|end_filename|>
function initialize_map(q) {
	map = new OpenLayers.Map('resultMap', {
                    controls: [
                        new OpenLayers.Control.PanZoomBar(),
                        new OpenLayers.Control.Navigation(),
                        new OpenLayers.Control.ScaleLine(),
                    ]
	});
	
                var styleMap = new OpenLayers.Style({
                    pointRadius: "${radius}",
                    //pointRadius: "5",
                    fillColor: "#ffcc66",
                    fillOpacity: 0.8,
                    strokeColor: "#cc6633",
                    strokeWidth: 2,
                    strokeOpacity: 0.8
                }, {
                    context: {
                        radius: function(feature) {
                            return Math.min(feature.attributes.count, 7) + 3;
                        }
                    }
                });
	map.addLayer(new OpenLayers.Layer.Google("Google Physical", {type: google.maps.MapTypeId.TERRAIN}));
	var kmlLayer = new OpenLayers.Layer.Vector("KML", {
	 	styleMap: styleMap,
	 	
	 	eventListeners: {'loadend': kmlLoaded },
		strategies: [
				new OpenLayers.Strategy.Fixed(),
				new OpenLayers.Strategy.Cluster()
			],
		protocol: new OpenLayers.Protocol.HTTP({
	                url: "../query.kml?q=" + q,
	                format: new OpenLayers.Format.KML({
	                    extractStyles: false, 
	                    extractAttributes: true
	                })
	            })
	});
	map.addLayer(kmlLayer);

	function kmlLoaded(){
		map.zoomToExtent(kmlLayer.getDataExtent());
		if (q == '*:*'){
			map.zoomTo('2');
		} else {
			map.zoomTo('5');
		}
		
	}
	
	selectControl = new OpenLayers.Control.SelectFeature(
                [kmlLayer],
                {
                    clickout: true, 
                    //toggle: true,
                    multiple: false, 
                    hover: false,
                    //toggleKey: "ctrlKey",
                    //multipleKey: "shiftKey"
                }
            );
	
	map.addControl(selectControl);
	selectControl.activate();
	kmlLayer.events.on({"featureselected": onFeatureSelect, "featureunselected": onFeatureUnselect});
     
	function onPopupClose(evt) {		
		map.removePopup(map.popups[0]);
	}
	
	function onFeatureSelect(event) {
		var message = '';
		var places = new Array();
		if (event.feature.cluster.length > 12){
			message = '<div style="font-size:10px">'+ event.feature.cluster.length + ' places found at this location';	
			for (var i in event.feature.cluster) {
				places.push(event.feature.cluster[i].attributes['name']);
			}
		}
		else if (event.feature.cluster.length > 1 && event.feature.cluster.length <= 12){
			message = '<div style="font-size:10px;width:300px;">'+ event.feature.cluster.length + ' places found at this location: ';
			for (var i in event.feature.cluster) {
				places.push(event.feature.cluster[i].attributes['name']);
				message += event.feature.cluster[i].attributes['name'];
				if (i < event.feature.cluster.length - 1){
					message += ', ';
				}		
			}			
		} else if (event.feature.cluster.length == 1) {
			places.push(event.feature.cluster[0].attributes['name']);
			message =  '<div style="font-size:10px">' + event.feature.cluster[0].attributes['name'];
		}		
				
		message += '</div>';
		
		popup = new OpenLayers.Popup.FramedCloud("id", event.feature.geometry.bounds.getCenterLonLat(), null, message, null, true, onPopupClose);
		event.popup = popup;
		map.addPopup(popup);
	}
	
	function onFeatureUnselect(event) {
		map.removePopup(map.popups[0]);
	}     

}


<|start_filename|>xforms/javascript/webannotorious.js<|end_filename|>
/// webannotorious.js by KANZAKI, Masahide. ver 1.18, 2018-05-01. MIT license.
(function ($) {
    $.Viewer.prototype.annotator = function (osdv, options, myanno) {
        if (! this.antctrl || options) {
            options = options || {
            };
            options.viewer = this;
            options.touchdev = osdv.touchdev;
            this.antctrl = new $.AntriusCtrl(options, osdv.elt, myanno);
        }
    };
    $.AntriusCtrl = function (options, osdvelt, myanno) {
        $.extend(true, this, {
            prefixUrl: null,
            navImages: {
                annotator: {
                    REST: 'selection_rest.png',
                    GROUP: 'selection_grouphover.png',
                    HOVER: 'selection_hover.png',
                    DOWN: 'selection_pressed.png'
                }
            }
        },
        options);
        var handler = options.h ? function () {
            options.h(options.hparam);
            myanno.activateSelector();
        }: function () {
            myanno.activateSelector();
        };
        
        var prefix = this.prefixUrl || this.viewer.prefixUrl || '';
        var useGroup = this.viewer.buttons && this.viewer.buttons.buttons;
        var anyButton = useGroup ? this.viewer.buttons.buttons[0]: null;
        var onFocusHandler = anyButton ? anyButton.onFocus: null;
        var onBlurHandler = anyButton ? anyButton.onBlur: null;
        this.toggleButton = new $.Button({
            element: null,
            clickTimeThreshold: this.viewer.clickTimeThreshold,
            clickDistThreshold: this.viewer.clickDistThreshold,
            tooltip: 'Annotator',
            srcRest: prefix + this.navImages.annotator.REST,
            srcGroup: prefix + this.navImages.annotator.GROUP,
            srcHover: prefix + this.navImages.annotator.HOVER,
            srcDown: prefix + this.navImages.annotator.DOWN,
            onRelease: handler,
            onFocus: onFocusHandler,
            onBlur: onBlurHandler
        });
        if (useGroup) {
            this.viewer.buttons.buttons.push(this.toggleButton);
            this.viewer.buttons.element.appendChild(this.toggleButton.element);
        }
        if (options.touchdev) myanno.addHandler("onAnnotationCreated", function (annot) {
            options.viewer.antctrl.add_touch_listener_to_last(annot);
        });
        this.osdvelt = osdvelt;
        this.myanno = myanno;
    };
    $.AntriusCtrl.prototype.add_touch_listener_to_last = function (annot) {
        var boxes = this.get_annoboxes(),
        box = boxes[boxes.length -1];
        this.add_touch_listener(box, annot);
    };
    $.AntriusCtrl.prototype.add_touch_listener = function (box, annot) {
        var that = this;
        box.addEventListener('touchstart', function (e) {
            if (this.getAttribute("data-hilite")) {
                that.myanno.highlightAnnotation(undefined);
                this.setAttribute("data-hilite", "");
            } else {
                that.myanno.highlightAnnotation(annot);
                this.setAttribute("data-hilite", true);
            }
        });
    };
    $.AntriusCtrl.prototype.get_annoboxes = function () {
        return this.osdvelt.getElementsByClassName("annotorious-ol-boxmarker-outer");
    };
    $.AntriusCtrl.prototype.setup_touch_listener = function (annoset) {
        var box = this.get_annoboxes();
        for (var i = 0, n = box.length; i < n; i++) {
            this.add_touch_listener(box[i], annoset[i]);
        }
    };
    $.AntriusCtrl.prototype.cancel_anno_selector = function () {
        this.toggler(true);
    };
    $.AntriusCtrl.prototype.toggler = function (deactivate) {
        var ai = this.osdvelt.getElementsByClassName("annotorious-item");
        if (deactivate || ! ai[0].style.display) {
            ai[0].style.display = "none";
        } else {
            this.myanno.activateSelector();
        }
    };
})(OpenSeadragon);



var at, Miiif;
var WebAnnotorious = function (osdv, option) {
    this.mainviewer = null;
    this.metaprop =[ "created", "modified", "hasNext", "hasPrev"];
    if (osdv) this.setup(osdv, option);
};
WebAnnotorious.prototype = {
    setup: function (osdv, option) {
        this.mainviewer = osdv.viewer;
        if (! this.antrs) this.antrs = new Y();
        this.antrs.makeAnnotatable(osdv.viewer);
        if (! option.nobutton) osdv.viewer.annotator(osdv, option, this.antrs);
    },
    getanno: function (as_ratio, ajson, baseuri, dim, rtype, as_page) {
        var aj = ajson || anno.getAnnotations();
        if (! dim) dim = this.mainviewer.source.dimensions;
        var canvasurl = this.mainviewer.source ? this.mainviewer.source.url: null;
        var frag, item =[];
        for (var i = 0, n = aj.length; i < n; i++) {
            item[i] = this.get_oneanno(as_ratio, aj[i], baseuri, dim, rtype, canvasurl);
        }
        var annocollection = {
            "@context": at.basecontext
        };
        if (as_page) {
            annocollection.type = "AnnotationPage";
            annocollection.items = item;
        } else {
            annocollection[ "@graph"] = item;
        }
        return annocollection;
    },
    get_oneanno: function (as_ratio, aj, baseuri, dimensions, rtype, canvasurl) {
        var text,
        frag = aj.fragid,
        dim = aj.dim || dimensions;
        if (! aj.shapes && aj.target) {
            frag = aj.target.selector.value;
            text = aj.bodyValue;
        } else {
            if (! frag || (as_ratio && frag.match(/xywh=\d/)) || (! as_ratio && frag.match(/xywh=percent/) && dim)) frag = this.getfrag(aj, dim, as_ratio);
            text = at.settext(aj);
        }
        var imgurl = aj.imgurl || canvasurl;
        if (baseuri) imgurl = baseuri + imgurl;
        var item = {
            "type": "Annotation",
            "id": aj.id || this.genid(aj.id, imgurl, frag),
            "bodyValue": text,
            "target": {
                "id": imgurl + "#" + frag,
                "source": imgurl,
                "selector": {
                    "type": "FragmentSelector",
                    "conformsTo": "http://www.w3.org/TR/media-frags/",
                    "value": frag
                }
            }
        };
        if (rtype) item.target.type = rtype;
        var creator = at.setCreator(aj.creator);
        if (creator) item.creator = creator;
        for (var p in this.metaprop) {
            if (aj.hasOwnProperty(this.metaprop[p])) item[ this.metaprop[p]] = aj[ this.metaprop[p]];
        }
        return item;
    },
    getfrag: function (aj, dim, as_ratio) {
        var m = aj.fragid ? aj.fragid.match(/(t=[\d\.,]+)/): null,
        tfrag = m ? "&" + m[1]: "",
        frag;
        if (aj.pix) {
            frag = "xywh=" + aj.pix.join(",");
        } else if (as_ratio) {
            frag = "xywh=" + this.ratio2frag(aj);
        } else {
            var va = this.ratio2px(aj, dim);
            frag = "xywh=" + va.join(",");
        }
        return frag + tfrag;
    },
    genid: function (id, imgurl, frag) {
        //Modified by E.G., use the existing ID when provided by the TEI document/manifest
        if (id){
            //remove default blank node prefix
            return id.replace("_:", "");
        } else {
            return "an_" + at.md5(imgurl + "#" + frag);
            //return at.anbase.pfx + ":" + at.md5(imgurl + "#" + frag);
        }
    },
    ratio2frag: function (an) {
        var g = an.shapes[0].geometry;
        return "percent:" + //viewer.viewport.contentAspectY+"#"+
        Math.round(g.x * 10000) / 100 + "," +
        Math.round(g.y * this.mainviewer.viewport._contentAspectRatio * 10000) / 100 + "," +
        Math.round(g.width * 10000) / 100 + "," +
        Math.round(g.height * this.mainviewer.viewport._contentAspectRatio * 10000) / 100;
    },
    ratio2px: function (an, dim, usefixed, x_adjust) {
        var x = usefixed ? dim.x: ((an.dim && an.dim.x) ? an.dim.x: dim.x);
        var g = an.shapes[0].geometry;
        var x_offset = 0;
        if (x_adjust) {
            if (g.x > x_adjust.offset) {
                x_offset = x_adjust.offset;
                x_adjust.cvidx = 1;
                x = x_adjust.altdim.x;
            }
        }
        return[
        Math.round(x * (g.x - x_offset)),
        Math.round(x * g.y),
        Math.round(x * g.width),
        Math.round(x * g.height)];
    },
    px2ratio: function (frag, dim) {
        if (dim && dim.x_offset && dim.option.use_offset) frag[0] = Number(frag[0]) + dim.x_offset;
        return[
        frag[0] / dim.x,
        frag[1] / dim.x,
        
        frag[2] / dim.x,
        frag[3] / dim.x];
    },
    pct2ratio: function (frag, dim) {
        if (dim && dim.x_offset && dim.option.use_offset) frag[0] = Number(frag[0]) + (dim.x_offset / dim.x) * 100;
        var ar = this.mainviewer.viewport._contentAspectRatio;
        var res =[];
        frag.forEach(function (f) {
            res.push(Number(f) / 100);
        });
        res[1] /= ar;
        res[3] /= ar;
        return res;
    },
    pct2px: function (pct, dim) {
        return[
        Math.round(pct[0] * dim.x / 100),
        Math.round(pct[1] * dim.y / 100),
        Math.round(pct[2] * dim.x / 100),
        Math.round(pct[3] * dim.y / 100)];
    },
    
    setanno: function (annojson, src) {
        var dim = this.mainviewer.source.dimensions, idattr = Miiif ? Miiif.a.id: "@id";
        var imgurl = this.mainviewer.source ? (this.mainviewer.source.url || this.mainviewer.source.imgurl || this.mainviewer.source[idattr]): null;
        src = src || "dzi://openseadragon/something";
        
        if (annojson[ "@graph"]) {
            var annoset =[];
            annojson[ "@graph"].forEach(function (g) {
                var annobj = this.to_annotorious(g, src, dim, imgurl);
                anno.addAnnotation(annobj);
                annoset.push(annobj);
            });
            return annoset;
        } else {
            var annobj = this.to_annotorious(annojson, src, dim, imgurl);
            anno.addAnnotation(annobj);
            return annobj;
        }
    },
    to_annotorious: function (an, src, dim, imgurl, fraganno) {
        if (this.comp_source(an.target.source, imgurl) === false) return false;
        var selector = an.target.selector.value;
        if (an.target.selector.type === "SvgSelector") selector = this.calc_svg_rect(selector);
        var areafrag = an.afrag || selector;
        if (! areafrag || areafrag.substr(0, 4) !== "xywh") return false;
        var frag = this.selector2frag(areafrag, dim);
        var scheme = frag.length === 5 ? frag.pop(): null;
        var annobj = {
            "src": src,
            "text": at.gettext(an),
            "shapes":[ {
                "type": "rect"
            }],
            "id": an.id || this.genid(an.id, imgurl, selector),
            "fragid": selector,
            "creator": at.getCreator(an)
        };
        if (fraganno) this.savefrag(fraganno, annobj, selector);
        for (var p in this.metaprop) {
            if (an.hasOwnProperty(this.metaprop[p])) annobj[ this.metaprop[p]] = an[ this.metaprop[p]];
        }
        if (an.target[ "sc:naturalAngle"]) annobj.rotation = an.target[ "sc:naturalAngle"];
        if (dim) {
            this.setup_geometry(annobj, frag);
            if (! dim.temp) annobj.dimx = dim.x;
            
            //EG: Adding dimy
            if (! dim.temp) annobj.dimy = dim.y;
        } else {
            annobj.pix = frag;
            if (scheme) annobj.scheme = scheme;
        }
        if (imgurl) annobj.imgurl = imgurl;
        return annobj;
    },
    no_scheme: function (uri) {
        return uri.replace(/^https?/, "");
    },
    comp_source: function (u1, u2) {
        if (typeof (u1) !== "string") return "not string";
        if (u1 === u2) return true;
        if (getpath(u1) === getpath(u2)) return true;
        return false;
        
        function getpath(u) {
            var a = document.createElement("a");
            a.setAttribute("href", u);
            return a.pathname;
        }
    },
    savefrag: function (fraganno, annobj, selector) {
        if (fraganno[selector]) {
            fraganno[selector].push(annobj.id);
        } else {
            fraganno[selector] =[annobj.id];
        }
    },
    selector2frag: function (selector, dim) {
        var frag = selector.substr(5).split(',');
        if (frag[0].charAt(0) === "p") {
            var sf = frag[0].split(":");
            scheme = sf[0];
            frag[0] = sf[1];
            if (scheme === "pixel") {
                frag = this.px2ratio(frag, dim);
            } else {
                frag = this.pct2ratio(frag, dim);
                dim = {
                    "temp": true
                };
            }
            frag[4] = scheme;
        } else if (dim) {
            frag = this.px2ratio(frag, dim);
        } else {
            for (var i = 0; i < 4; i++) frag[i] = Number(frag[i]);
        }
        return frag;
    },
    setup_geometry: function (obj, frag) {
        obj.shapes[0].geometry = {
            "x": frag[0],
            "y": frag[1],
            "width": frag[2],
            "height": frag[3]
        };
    },
    check_geometry: function (annos) {
        var dim = this.mainviewer.source.dimensions;
        for (var i = 0, n = annos.length; i < n; i++) {
            frag = annos[i].scheme ? annos[i].pix: this.px2ratio(annos[i].pix, dim);
            this.setup_geometry(annos[i], frag);
            annos[i].pix = null;
        }
    },
    calc_svg_rect: function (selector, dimx) {
        if (! this.svgdiv) {
            this.svgdiv = document.createElement("div");
            this.svgdiv.style.position = "absolute";
            this.svgdiv.style.top = 0;
            this.svgdiv.style.right = 0;
            this.svgdiv.style.zIndex = -100;
            this.svgdiv.style.visibility = "hidden";
            document.body.appendChild(this.svgdiv);
        }
        this.svgdiv.innerHTML = selector;
        var svgelt, cnodes = this.svgdiv.childNodes;
        for (var i = 0, n = cnodes.length; i < n; i++) {
            if (cnodes[i].tagName === "svg") {
                svgelt = cnodes[i];
                break;
            }
        }
        var bbox = svgelt.getBBox(),
        w = svgelt.getAttribute("width");
        if (w && dimx) {
            var adjust = dimx / Number(w);
            for (var key in bbox) bbox[key] *= adjust;
        }
        return "xywh=" +[Math.round(bbox.x), Math.round(bbox.y), Math.round(bbox.width), Math.round(bbox.height)].join(",");
    },
    simpleanno: function (coord, text) {
        return this.setanno({
            "bodyValue": at.link2md(text),
            "target": {
                "selector": {
                    "value": "xywh=" + coord
                }
            }
        });
    }
};

<|start_filename|>ui/javascript/maps_functions.js<|end_filename|>
/************************************
GET FACET TERMS IN RESULTS PAGE
Written by <NAME>, <EMAIL>
Library: jQuery
Description: This utilizes ajax to populate the list of terms in the facet category in the results page.
If the list is populated and then hidden, when it is re-activated, it fades in rather than executing the ajax call again.
 ************************************/
$(document).ready(function () {
    var popupStatus = 0;
    
    var langStr = getURLParameter('lang');
    var pipeline = 'maps';
    if (langStr == 'null') {
        var lang = '';
    } else {
        var lang = langStr;
    }
    var path = $('#path').text();
    var mapboxKey = $('#mapboxKey').text();
    
    //set hierarchical labels on load
    /*$('.hierarchical-facet').each(function(){
    var field = $(this).attr('id').split('_hier')[0];
    var title = $(this).attr('title');
    hierarchyLabel(field, title);
    });
    dateLabel();
    
    $("#backgroundPopup").on('click', function (event) {
    disablePopup();
    });*/
    
    /* INITIALIZE MAP */
    var q = '*:*';
    
    //baselayers
    var mb_physical = L.tileLayer(
    'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=' + mapboxKey, {
        attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
        '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
        'Imagery © <a href="http://mapbox.com">Mapbox</a>', id: 'mapbox.streets'
    });
    
    var osm = L.tileLayer(
    'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
        attribution: 'OpenStreetMap',
        maxZoom: 18
    });
    
    var map = new L.Map('mapcontainer', {
        center: new L.LatLng(0, 0),
        zoom: 4,
        layers:mb_physical
    });
    
    //add mintLayer from AJAX
    var overlay = L.geoJson.ajax(path + "query.geojson?q=" + q);
    
    var baseMaps = {
        'Topography': mb_physical,
        'Open Street Map': osm
    };
    
    var layerControl = L.control.layers(baseMaps).addTo(map);
    
    
    //zoom to groups on AJAX complete
    overlay.on('data:loaded', function () {
        markers = L.markerClusterGroup();
        layerControl.addOverlay(markers, 'Related Places');
        markers.addLayer(overlay);
        map.addLayer(markers);
        
        var group = new L.featureGroup([overlay]);
        map.fitBounds(group.getBounds());
    }.bind(this));
    
    overlay.on('click', function (e) {
        renderPopup(e);
    });
    
    //multiselect facets
    $('.multiselect').multiselect({
        buttonWidth: '250px',
        enableCaseInsensitiveFiltering: true,
        maxHeight: 250,
        buttonText: function (options, select) {
            if (options.length == 0) {
                return select.attr('title');
            } else if (options.length > 2) {
                return select.attr('title') + ': ' + options.length + ' selected';
            } else {
                var selected = '';
                options.each(function () {
                    selected += $(this).text() + ', ';
                });
                label = selected.substr(0, selected.length - 2);
                if (label.length > 20) {
                    label = label.substr(0, 20) + '...';
                }
                return select.attr('title') + ': ' + label;
            }
        },
        onChange: function (element, checked) {
            //if there are 0 selected checks in the multiselect, re-initialize ajax to populate list
            id = element.parent('select').attr('id');
            if ($('#' + id).val() == null) {
                var q = getQuery();
                var category = id.split('-select')[0];
                $.get(path + 'get_facets/', {
                    q: q, category: category, sort: 'index', lang: lang
                },
                function (data) {
                    $('#ajax-temp').html(data);
                    $('#' + id).html('');
                    $('#ajax-temp option').each(function () {
                        $(this).clone().appendTo('#' + id);
                    });
                    $("#" + id).multiselect('rebuild');
                });
            }
            if ($('#mapcontainer').length > 0) {
                //update map
                refreshMap();
            }
        }
    });
    
    //on open
    $('button.multiselect').on('click', function () {
        var q = getQuery();
        var id = $(this).parent('div').prev('select').attr('id');
        var category = id.split('-select')[0];
        $.get(path + 'get_facets/', {
            q: q, category: category, sort: 'index', lang: lang, pipeline: pipeline
        },
        function (data) {
            $('#ajax-temp').html(data);
            $('#' + id).html('');
            $('#ajax-temp option').each(function () {
                $(this).clone().appendTo('#' + id);
            });
            $("#" + id).multiselect('rebuild');
        });
    });
    
    $('#results').on('click', '.paging_div .page-nos .btn-toolbar .pagination a.pagingBtn', function (event) {
        var href = path + 'results_ajax/' + $(this).attr('href');
        $.get(href, {
        },
        function (data) {
            $('#results').html(data);
        });
        return false;
    });
    
    //clear query
    $('#results').on('click', 'h1 small #clear_all', function () {
        $('#results').html('');
        return false;
    });
    
    /***************************/
    //@Author: Adrian "yEnS" <NAME>
    //@website: www.yensdesign.com
    //@email: <EMAIL>
    //@license: Feel free to use it, but keep this credits please!
    /***************************/
    
    //disabling popup with jQuery magic!
    function disablePopup() {
        //disables popup only if it is enabled
        if (popupStatus == 1) {
            $("#backgroundPopup").fadeOut("fast");
            $('#category_hier-list').parent('div').attr('style', 'width: 192px;');
            $('#century_num-list').parent('div').attr('style', 'width: 192px;');
            popupStatus = 0;
        }
    }
    
    function getURLParameter(name) {
        return decodeURI(
        (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search) ||[, null])[1]);
    }
    
    /*****
     * LEAFLET FUNCTIONS
     *****/
    function refreshMap() {
        var query = getQuery();
        url = path + "query.geojson?q=" + query + (lang.length > 0 ? '&lang=' + lang: '');
        
        layerControl.removeLayer(markers);
        map.removeLayer(markers);
        overlay.refresh(url);
    }
    
    /*****
     * Generate a popup for the various types of layers
     *****/
    function renderPopup(e) {
        var query = getQuery();
        query += ' AND ' + 'georef:"' + e.layer.feature.properties.georef + '"';
        var str = e.layer.feature.properties.type + ": <a href='#results' class='show_records' q='" + query + "'>" + e.layer.feature.properties.toponym + "</a> <a href='" + e.layer.feature.properties.gazetteer_uri + "' target='_blank'><span class='glyphicon glyphicon-new-window'/></a>";
        e.layer.bindPopup(str).openPopup();
        $('.show_records').on('click', function (event) {
            var query = $(this).attr('q');
            $.get(path + 'results_ajax/', {
                q: query,
                lang: lang
            },
            function (data) {
                $('#results').html(data);
            }).done(function () {
                $('div.thumbImage a').fancybox({ helpers: {
                        title: {
                            type: 'inside'
                        }
                    }
                });
            });
            return false;
        });
    }
});

<|start_filename|>xforms/xbl/tree-view/tree-view.css<|end_filename|>
ul li{
	list-style-type:none;	
}
.collapsed li {
	display:none;
	 
}
.expanded li {
	padding:5px;
	margin:5px;
	border:1px solid silver;
	border-radius:15px;
}
.nodename {
	cursor:pointer;
	 
}

<|start_filename|>xforms/css/imgannot.css<|end_filename|>
@charset "UTF-8";
/** general */
@font-face {
  font-family: 'Simpleg';
  font-style: normal;
  font-weight: 400;
  src: local('Simpleg'), local('Simpleg-Regular'), url(/parts/simpleg.woff) format('woff');
}
h1 .subtitle {
	font-size: 0.75em;
	color: #002177;
}

.iaview h1 {
	font-size: 22px; /*120%;*/
	height: 28px;
	line-height: 28px;
	margin-top: 0;
	margin-bottom: 3px;
	/*overflow: hidden;*/
}
html:lang(ja) *:lang(en),
html:lang(en) *:lang(ja) {
	display: none;
}
html.wait /*, html.wait #titleidx ul li*/ {
	cursor: wait;
}
html.full body {
	max-width: none;
}
span.mv {
	background: #ebefeb;
	padding: 0 0.5em;
}

h1 .logo {
	float: right;
	margin-left: 5px;
	margin-top: -5px;
	max-height: 36px;
	position: relative;
}
h1 .logo img {
	max-height: 36px;
	max-width: 200px;
}
h1 .logo img:hover {
	max-height: 200px;
	max-width: 400px;
	position: absolute;
	right: 0;
	background: rgba(255, 255, 255, 0.7);
	box-shadow: -1px 1px 1px rgba(140, 140, 140, 0.7);
	z-index: 10;
}

abbr[title]:hover {
	cursor: default;
}
.sideitem {
	float: right;
}
.metainfo a[href^="http"]:after {
	content: "";
}

/** basic width */
#openseadragon, #annoclip table, .refstrp,
.metainfo {
	width: 100%; 
}
.refstrp.rtl {
	width: 110px !important;
	height: 780px;
	overflow: scroll-y;
}
#openseadragon, #titleidx > ul {
	height: 780px;
}
#openseadragon.video {
	height: 600px;
}
#openseadragon,
.osdelt {
	position: relative;
}
#openseadragon {
	background: #f8f8f8;


}
.osdelt {
	background: rgb(60, 60, 60, 0.5);
}
/** message on osd */

p.msg {
	position: absolute;
	top: 33%;
	width: 100%;
	text-align: center;
	color: black;
	opacity: 1;
	user-select: none;
}
p.msg.loading {
	height: 3em;
	background: url("../../../xforms/images/loading.gif") no-repeat center bottom;
}
p.msg.error {
	color: #d00;
	user-select: auto;
	/*z-index: 1;*/
}
p.msg.annot {
	color: black;
	z-index: 20;
	background: #eeee;
	width: 70%;
	margin-left: 15%;
}

.osdelt p.msg {
	font-size: 80%;
}
#openseadragon.view,
.osdelt.view {
	background: black;
}
.view .msg,
.video .msg {
	color: white;
}
.view .msg.error,
.view .msg a {
	color: #ff9;
}
.view .msg a:hover {
	background-color: #666;
}

#openseadragon canvas,
.osdelt canvas {
	z-index: 0;
}

#openseadragon.hideanno .annotorious-ol-boxmarker-inner,
#openseadragon.hideanno svg {
	display: none;
}
#openseadragon.hideanno .annotorious-ol-boxmarker-outer {
	border: none;
}
#openseadragon.hideanno.showsvg svg {
	display: block;
}

.seqbtngrp:hover {
	cursor: pointer;
}
.seqbtngrp img {
	opacity: 0.5;
	width: 40px;
	height: 60px;
}
.seqbtngrp:hover img {
	opacity: 1;
}
/** title index */
#titleidx {
	position: absolute;
	width: 200px;
	right: 0;
	font-size: 95%;
}
#titleidx.sidx {
	width: 165px;
}
#titleidx.widx {
	width: 260px;
}
#titleidx > ul {
	overflow: scroll;
}
#titleidx ul {
	margin: 0;
	padding: 0 0 0 1em;
	list-style:none;
}
#titleidx li {
	text-indent: -1em;
	margin-bottom: 0;
	padding: 0.3em 0;
}
#titleidx li:before {
	font-family: 'Simpleg';
	content: "•";/*◦∘•▪►➢✧❏✣➠✦✧▸▻  */
	color: #aaa;
	margin-right: 1px;
	display:block;
	float: left;
	width: 1em;
}
/* .struct li is defined bellow section */
#titleidx li[data-an]:before,
#titleidx .struct li[data-an]:before {
	font-family: 'Simpleg';
	content: "✍";/*▻ ▸ ☛✑*/
}
#titleidx li[data-an]:before{
	color: #080;
}
#titleidx li[data-ovl]:before {
	/*font-family: 'Simpleg';*/
	content: "✽";/*❇✴✽❐❉▻ ▸ ☛✑❍*/
	color: #88a;
}
#titleidx ul li.loading {
	background: url("../../../xforms/images/loading.gif") no-repeat right center #fcfce0;
}
#titleidx li:nth-of-type(odd) {
	background: #f8f8f8;
}
#titleidx li:hover {
	background: #eee;
	cursor: pointer;
}
#titleidx li.prange {
	font-weight: bolder;
	background: #fcf8e6;
}
#titleidx li.current {
	font-weight: bolder;
	background: #f6ecec;
}
#titleidx li.current:hover {
	background: #f3eaec;
}
#titleidx li.current:before {
	font-family: 'Simpleg';
	content: "☞";/*☛▻ ▸ ✑*/
	color: maroon;
}

#titleidx li.fail {
	color: #f44;
}
#titleidx li.range {
	background: transparent;
}
li.range > ul {
	display: none;
}
li.range.openf > ul {
	display: block;
}
#titleidx li.range:before {
	color: black;
	/*content: "✦";◦∘•►➢✧❏✣➠✦✧▸▻  */
}
#titleidx .struct li.range:before {
	/*color: navy;*/
	content: "";
}
#titleidx li.range:hover {
	cursor: default;
}
#titleidx p {
	font-family: 'Simpleg';
	margin-top: 0.5em;
	margin-bottom: 0.2em;
	color: green;
}
#titleidx .posform {
	width: 2em;
	color: green;
}
/* ppos */

#ppos {
	position: absolute;
	top: -36px;
	left: 5px;
}

/* viewingHint/Direction */
#titleidx .vinfo {
	/*border: dotted 1px gray;*/
	box-shadow: 1px 1px 1px rgba(102, 102, 102, 0.4);
	background: #f8f8f8;
	padding: 0.3em;
	margin-left: -0.3em;
	margin-right: 2px;
	color: #666;
	position: relative;
	cursor: default;
}
.vinfo > div > span {
	display: inline-block;
}
.vinfo del a,
.vinfo del .pseudolink {
	text-decoration: none;
}
.vinfo a:link,
.vinfo .pseudolink {
	color: #449;
	text-decoration: underline dotted silver;
}
.vinfo a:link:hover,
.vinfo .pseudolink:hover {
	color: #44a;
	text-decoration: underline;
}
.vinfo a:visited {
	color: #a58484;
}
.vinfo em {
	font-style: normal;
	color: green;
}
.vinfo small {
	font-size: 75%;
}
.vinfo em.inuse,
.vinfo span.prepared {
	padding: 0 3px;
}
.inuse,
.prepared{
	border-width: 1px;
	border-color: silver;
	display: inline-block;
	min-width: 15px;
}
.inuse {
	border-style: none solid solid none;
	box-shadow: -1px -1px 1px #555;
	background: rgba(232, 224, 224, 0.6);
}
.prepared {
	border-style: solid none none solid;
	box-shadow: 1px 1px 1px #555;
	cursor: pointer;
}
.prepared:hover {
	background: #c6c6ef99;
	box-shadow: 1px 1px 1px #22f;
}
/* structure */
#titleidx .struct li:before {
	content: "▪";
	color: #99c;
}
#strctab:before {
	content: "▸";
}
#strctab span {
	padding: 0 4px 0 2px;
}
#strctab .active {
	color: black;
	background: rgba(232, 224, 224, 0.6);
}

/** info panels */
#showjld {
	display: none;
	clear: both;
} 
#jld {
	width:100%;
	height:100%;
	position: absolute;
	z-index:10;
	display: none;
} 
#imgdsc {
	min-height: 1em;
	max-height: 10em;
	overflow-y: auto;
}
#imgdsc.curation {
	max-height: none;
}
#imgdsc em[onclick]{
	cursor: pointer;
}
.otherCont {
	color: #080;
}
.metainfo {
	margin: 0.5em 0;
	background: #fdfdf9;
}
.metainfo ul {
	margin: 0.5em 0 0 0;
}
.metainfo > em {
	font-style: normal;
	color: maroon;
}
.metainfo > .doctype {
	color: black;
	font-size: 90%;
}
.metainfo > .doctype a {
	color: #449;
	text-decoration: none;
	border-bottom: dotted 1px gray;
}
.metainfo dl {
	margin-top: 0;
	margin-bottom: 0.5em;
}
.metainfo div {
	clear: left;
}
.metainfo dt {
	float: left;
	clear: left;
	min-width: 7.5em;
	margin-top: 0;
	margin-right: 0.5em;
}
.metainfo dt:after {
	content: ":";
	font-weight: normal;
}
.metainfo dt:before {
	content: "• ";/*"• "*/
	color: #a4a4a4;
	font-weight: normal;
}
.metainfo dd {
	margin-bottom: 0.25em;
	margin-left: 8em;/*4em;*/
}
.metainfo div dd:nth-of-type(even) {
	background: #f8f8f8;
}

#docdsc > .doctype:before {
	content: "(";
}
#docdsc > .doctype:after {
	content: ")";
}

#docdsc svg {
	margin-right: 3px;
}

#dirinfo {/* viewing direction info*/
	position: absolute;
	right: 0;
	bottom: -1.5em;
	font-size: 80%;
	background: #fdfdf9;
}

/** Annotorious */
a.annotorious-editor-button {
	color: #ddd;
}
.annotorious-popup {
	width: auto;
	min-width: 180px;
	max-width: 300px;
	/*width: 250px;*/
}
.annotorious-popup-text span[class] {
	border-bottom: #ddd solid 1px;
}
.annotorious-popup-text div.more {
	border-top: #aac dotted 1px;
	margin-top: 0.7em;
	padding-top: 0.6em;
}
.annotorious-popup-text em {
	color: #046b7c;
}
.annotorious-popup-text em.who {
	color: green;
}
.annotorious-popup-text em.who[onclick] {
	color: blue;
	cursor: pointer;
	text-decoration: underline;
}
.annotorious-popup-text a img {
	border: blue solid 1px;
}
.annotorious-popup-text a[href^="#!"] {
	color: blue;
}
.annotorious-popup-text img,
.annotorious-popup-text video,
.annotorious-popup-text audio
 {
	max-height: 300px;
	max-width: 300px;
}
span.annotorious-popup-text p {
	margin: 0.2em 0;
}
#annod {
	width: 100%;
	height: 16em;
	box-sizing: border-box;
	font-size: 1em;
	padding: 0.5em;
}

/** SVG */
g[data-motivation] * {
	stroke: rgb(255, 255, 100);
	stroke-width: 0.003;
	fill: none;
}
g[data-motivation] .filter {
	stroke: none;
	opacity: 0;
}
g[data-motivation=painting] *  {
	stroke: rgb(255, 100, 100);
	fill: rgba(255, 100, 100, 0.4);
}

g[data-motivation=nofrag] * {
	stroke: rgb(80, 160, 80);
	fill: rgba(80, 160, 80, 0.4);
}
g[data-context=hasReply] * {
	stroke: rgb(230, 25, 0);
	fill: none;
}
g[data-context=reply] * {
	/*stroke-dasharray: 0.006;*/
	stroke-width: 0.002;
}
path.dash {
	stroke-dasharray: 0.0025;
}

.hideanno.showsvg * {
	fill: none;

	stroke-width: 0;
}


/*g.hilite * {
	stroke-width: 0.006;
}
*/
g[data-motivation].hilite * {
	fill: none;
}
.filter:hover,
g[data-motivation].hilite .filter {
	fill: black;
	opacity: 0.4;
}

.annotorious-ol-boxmarker-outer.svg,
.svg .annotorious-ol-boxmarker-inner
{
	border-width: 0px;
}


/** Clipping / Gallery */
.fbox,
.gbox,
#annoclip {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	align-content: flex-start;
}

#annoclip td {
	vertical-align: top;
}
.fbox figure,
#annoclip figure {
	margin: 0.5em 1em 0.5em 0;
	padding: 0.5em;
	border: #eee 1px solid;
	box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3);
}
.fbox figure {
	max-width: 170px;
}
.fbox figure a img {
	border: blue 2px solid;
	max-width: 165px;
	max-height: 215px;
	display: block;
	margin: 0 auto;
}
#annoclip .clip
 {
	min-width: 100px;
	max-width: 250px !important;
	max-height: 250px !important;
	position: relative;
	overflow: hidden;
}
#annoclip .clip img {
	position: absolute;
}
.fbox figcaption,
#annoclip figcaption {
	font-size: 90%;
	margin-top: 5px;
	margin-bottom: -5px;
}
.gbox {
	/*z-index: 10;*/
	position: absolute;
	top: 0;
	background: black;
	overflow-y: scroll;
	align-items: center;
}
.gbox figure
 {

	min-width: 160px;
	min-height: 140px;
	text-align: center;
 	padding: 5px;
 	margin: 0;
}
.gbox img {
	max-width: 210px;
	max-height: 210px;
}
.gbox figcaption {
	font-size: 80%;
	margin-top: -4px;
	margin-bottom: -5px;
	color: #aaa;
}
.gbox .current {
	background: #ac9595;
	border: red 1px solid;
	padding: 4px;
}
.gbox figure:hover {
	border: silver 1px solid;
	padding: 4px;
	cursor: pointer;
}
.gbox .current figcaption {
	color: black;
}
/** search */
.searchres .annotorious-ol-boxmarker-inner
{
	background-color: rgba(250,50,50,0.3);
}
.searchres .annotorious-ol-boxmarker-outer {
	border-color: red;
}
#titleidx.searchres li[data-an]:before {
	font-family: 'Simpleg';
	content: "✑";/*▻ ▸ ☛✉*/
	color: #b58577;
}
#titleidx.searchres li:nth-of-type(odd) {
	background: #f9f5f5;
}
#titleidx.searchres li.notfound {
	background: transparent;
	color: maroon;
}
#titleidx.searchres li.notfound:hover {
	cursor: default;
}
#titleidx.searchres li.notfound:before {
	content: "-";
}
#titleidx.searchres li.reset {
	background: transparent;
	color: #3e3ec9;
}
#titleidx.searchres li.reset:before {
	content: "☛";
	color: #3e3ec9;
}

/** text folder */
span.expander {
	text-decoration: underline;
	cursor: pointer;
	color: blue;
}
h1 span.expander {
	font-size: 16px;
	font-weight: normal
}
span.opener, span.closer {
	cursor: pointer;
	color: #008;
}
span.opener:hover, span.closer:hover {
	border-bottom: dotted 1px;
}

.opener:after {
	content: " ▷";
	font-size: 70%;
}
.closer:after {
	content: " ▽";
	font-size: 70%;
}
.struct span.opener, .struct span.closer {
	color: black;
}
.struct span.opener:after, 
.struct span.closer:after {
	content: "";
}
.struct span.opener:before {
	content: "▶ ";
}
.struct span.closer:before {
	content: "▽ "; /* ▼ */
}
.struct span.opener:before,
.struct span.closer:before {
	color: #99c;
	font-size: 70%;
}
.struct span.opener:hover,
.struct span.closer:hover {
	border-bottom: none;
}

span.more, dl.more {
	display: none;
}
li dl {
	margin-top: 0.2em;
}

/** reference strip */
.refstrp {
	overflow-x: scroll;
	overflow-y: visible;
	vertical-align: bottom;
	min-height: 107px;
}

.referencestrip {
	height: 91px !important;
	top: 6px;
}
.referencestrip > div {
	width: 86px !important;
	border-width: 1px !important;
	border-style: solid !important;
	border-color: rgba(50,50,50,0.7) rgba(50,50,50,0.7) rgba(0,0,0,0.7) rgba(0,0,0,0.7) !important;
}
.referencestrip > div:hover {
	border-color: rgba(170,170,170,0.5) !important;
}
.refstgl {
	position: absolute;
	top: -23px;
	text-align: center; 
	width: 100%;
}
.refstgl span {
	font-size: 24px;
	line-height: 1.5;
	color: #db6468 ; /*#dba;*/
	text-shadow: 1px 1px 1px rgba(50,50,50,0.9);
}
.refstgl span:hover {
	color: rgba(240,240,200,1);
	text-shadow: 1px 1px 1px black;
	cursor: pointer;
}
/** filter controller */
#fltctrl {
	position: relative /*absolute*/;
	display: inline-block;
	vertical-align: top;
	height: 20px;
	padding: 5px;
	background: rgba(170,170,170,0.2);
	color: #ddd;
	text-shadow: 1px 1px 1px #222;
	font-size: 90%;
	cursor: pointer;
}
#fltctrl:hover {
	color: white;
	background: rgba(210,190,160,0.6);
}

div.panel {
	text-shadow: none;
	font-size: 80%;
	position: absolute;
}
#fltctrl div.panel {
	color: white;
	top: 30px;
	width: 120px;
	background: rgba(170,170,170,0.6);
	left: 0;
	padding: 5px;
}
#fltctrl .panel input[type=range]{
	width: 100%;
	vertical-align: 5px;
}
#fltctrl span {
	cursor: pointer;
	display: block;
}

/** Threed controller */
div.panel.threed {
	width: 250px;
	z-index: 1;
}
div.panel.threed > div {
	color: white;
	background: rgba(170, 170, 170, 0.9);
	border: white 1px solid;
	padding: 3px 5px;
}


div.panel.threed.hide > div {
	display: none;
}
div.panel.threed > div > span {


	color: rgb(244, 244, 121); /*#f8f8b7;*/
}
div.panel.threed > div > div {
	padding: 2px 0;
}
div.panel.threed div div div {
	/*padding: 1px 0; */
}
div.panel.threed input {
	vertical-align: middle;
}
div.panel.threed input[type=range],
div.panel.threed input[type=color] {
	width: 140px;
	padding: 0 3px;
}
div.panel.threed label {
	padding-left: 1em;
}
div.panel.threed > div > div > span {
	display: block;
	border-top: white 1px dotted;
}
div.panel.threed div div div span {
	width: 35px;
	display: inline-block;

	white-space: pre;
}
div.panel.threed div div div span:first-child {
	width: 50px;
}

div.panel.threed div.stat {
	position: absolute;
	background: transparent;
	border: none;
	top: 16px;
	right: 255px;
	color: #bbb;
	max-width: 200px;
	min-width: 130px;
	white-space: normal;
	z-index: -1; 
}
div.panel.threed .stat td{
	padding: 1px 2px;
	vertical-align: top;
}
div.panel.threed .stat tr td:first-child{
	color: rgba(244, 244, 121, 0.6);
}
div.panel.threed .stat tr td.calced:first-child{
	color: gray;
}
div.panel.threed table,
div.panel.threed td {
	border: none;
	margin: 0;
}
span.toggler {
	color: rgba(244, 244, 121, 0.6);
	background: rgba(0, 0, 0, 0.2);
	position: absolute;
	cursor: pointer;
}
div.panel.threed span.toggler {
	width: 50px;
	left: -50px;
	top: 3px;
}
span.toggler.animation {
	color: rgba(170, 170, 170, 0.6);
	font-size: 80%;
	width: 70px;
	bottom: 0;
	right: 0;
}

span.toggler:hover,
span.toggler.active {
	color: rgb(244, 244, 121);
}

button.toggler {
	position: absolute;
	bottom: -23px;
	right: 0;
}
/** layer controller */
#lyctrl {
	position: absolute;
	top: 0;
	right: 0;
	/*width: 100px;*/
	text-align: right;
	color: #dedede;
	font-size: 80%;
}
#lyctrl span {
	color: rgb(244, 244, 121);
	cursor: pointer;
}
#lyctrl span:hover {
	background: rgba(190,190,190,0.6);;
}
#lyctrl span.toggler {
	right: 0;
	padding: 0 2px;
}

#lyctrl .flipper {
	position: absolute;
	top: 0;
	left: 0;
	padding: 0 0.5em;
	color: #cfeaf4;
}
#lyctrl .flipper:hover {
	color: #d0f1fe;
}
#lyctrl > div {
	background: rgba(170, 170, 170, 0.67);
	padding: 20px 3px 3px;
}

#lyctrl img {
	width: 30px;
	max-height: 80px;
	margin-right: 2px;
	cursor: pointer;
	border: #f4f479 solid 1px;
}
#lyctrl .off img {
	border-color: gray;
}
.slider #lyctrl .off img {
	border-color: #f4f479;
}

#lyctrl input[type=range]{
	width: 90px;
	vertical-align: 5px;
}
#lyctrl button {
	width: 100%;
}

.slider canvas {
	cursor: crosshair;
}


/** PDF */

.pdf #openseadragon{
	text-align: center;
	height: 800px;
	max-width: 1000px;
}

.pdf h1 span {
	margin-right: 3px;
}
.pdf h1 span svg {
	margin-bottom: -2px;
}
.pdf .scroller {
	overflow-y: scroll;
	height: 100%;
	width: 100%;
}
.scroller.draggable {
	cursor: pointer;
	cursor: -webkit-grab;
}
.pdf .btncont {
	position: absolute;
}
.btncont.dir {
	top: 350px;
	width: 100%;
}
.btncont.zoom {
	top: 0;
	left: 0;
}
.btncont img {
	opacity: 0.5;
}
.btncont img:hover {
	cursor: pointer;
	opacity: 1;
}
.btncont img.rest {
	opacity: 0.15;
	cursor: default;
}
.btncont.dir img {
	position: absolute;
}
.btncont.dir img:nth-child(1) {
	left: 0;
}
.btncont.dir img:nth-child(2) {
	right: 16px;	##スクロールバー分
}
.zoom img {
	opacity: 0.6;
}

.txcont {
	display: inline-block;
	position: relative;
}
.txcont span {
	position: absolute;
	color: transparent;
	text-align: justify;
	text-align-last: justify;

	line-height: 1;
	cursor: text;
}

.txcont span::selection{
	color: rgba(100, 100, 255, 0);
	background: rgba(50, 50, 255, 0.25);

}
.txcont div {
	position: absolute;
	top: 0;
	width: 100%;
	height: 100%;
}
canvas.shadow {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
}



/** IIIF collection */
ul.collection {
	margin-top: 0.7em;
	margin-bottom: 0.7em;
}
ul.collection.mu {
	column-count: 2;
	padding-left: 2em;
}
ul.collection.mu li {
	text-indent: -1.2em;
	list-style-position: inside;
	padding-left: 0.8em;
}
ul.collection li {
	line-height: 1.42;
}
.collection li.collection {
	list-style-image: url(/parts/tri-r.png);
	margin-top: 0.52em;
	margin-bottom: 0.56em;
}
.collection span.opener, 
.collection span.closer {
	color: #00c;
	font-weight: bold;
}
.collection .descr {
	font-size: 92%;
}
.collection div.descr {
	margin: 0 1em 0.5em;
}
img.thumb {
	position: absolute;
	border: gray solid 1px;
	margin-left: 3px;
	box-shadow: 2px 1px 10px rgba(0, 0, 0, 0.7);
	max-width: 300px;
	max-height: 300px;
}
.collection td {
	vertical-align: top;
	background: white;
}
.collection tr th:nth-child(1) {
	min-width: 250px /*35%*/;
}
.collection tr th:nth-child(2) {
	min-width: 45%;
}

/** collection's general */
.collection h1 {
	margin-top: 0.3em;
}
.collection #imgdsc /*, 
.collection .mv*/ {
	display: none;
}

.collection td span.alt {
	font-size: 90%;
	display: block;
	margin-top: 0.2em;
}
.collection td span.alt:before {
	content: "(or ";
}
.collection td span.alt:after {
	content: ")";
}


/** misc **/
#ccbtn {
	position: absolute;
	right: 0;
	bottom: 0;
}

.collection #ccbtn {
	display: none;
}


/** *** A/V clock *****/
#openseadragon video {
	max-width: 100%;
	max-height: 100%;
}
#clock > button,
#clock > span {
	display: inline-block;
	vertical-align: top;
	margin-top: 4px;
}
#clock > span {
	margin-top: 5px;
}
#clock .disp {
	border: silver solid 1px;
	padding-right: 5px;
	box-sizing: border-box;
	font-size: 12px;
	text-align: right;
}
#clock #timeline {
	display: inline-block;
}
#timeline > * {
	width: 100%;
	margin-left: 0;
	margin-right: 0;
}
#tlcontainer {
	max-height: 120px;
}
#timeline > div > div:nth-of-type(odd) {
	background: #f8f8f8;
}
#timeline * {
	box-sizing: border-box;
}
#timeline div span {
	display: block;
	background-color: #d7ede0 /*#c2e1cf #add9bf*/;
	border: 1px #acc8b7 /*#98b8a3*/;
	border-style: none solid solid none;
	height: 8px;
}
#timeline div span.annot,
#timeline div span.Text
 {
	background-color: #ecfbd6;
	border-color: #c4c8ac;
}
#timeline div span.image {
	background-color: #dbebef;
}

#timeline div span.canvasd {
	position: absolute;
	top: 0;
	background: rgba(160,196,205,0.1);
	border: 1px silver;
	border-style: none solid solid none;
	color: gray;
	font-size: 10px;
	height: auto;
	text-align: center;
}
#timeline div span.canvasd:nth-of-type(odd) {
	background: rgba(160,196,205,0.3);
}
/** timed */
.textpaint,
.texthighlight,
.textlink {
	color: white; /*#111*/

	font-size: 85%;
	line-height: 1.45;
	box-sizing: border-box;
	box-shadow: 2px 2px 4px rgba(122, 122, 122, 0.5);
}
.textpaint,
.texthighlight {
	padding: 0.5em;
	overflow-x: hidden;
	overflow-y: auto;
}
.textpaint {
	background: rgba(120, 120, 120, 0.45); /*rgba(80,80,80,0.45);*/	/*rgba(250,222,222,0.3)*/

	border-radius: 3px;
}
.texthighlight {

	background: rgba(255,255,0,0.17);	/*rgba(250,222,222,0.3)*/
}
.textpaint.transp,

.texthighlight:hover {
	color: rgba(5,5,5,.45);
	text-shadow: 1px 1px 1px rgba(200,200,200,0.5);
	background: transparent;
	border: rgba(230,230,230,1) solid 1px;
	overflow: visible;
}

.textpaint.keepshow {
	border: rgba(230,230,230,0.6) solid 1px;
}
.textlink {
	background: rgba(0, 0, 255,0.07);	/*rgba(250,222,222,0.3)*/
	border: #9b9bd9 solid 1px;
}
.textlink:hover {
	border: #33f solid 1px;
}

.textlink a {
	display: block;
	width: 100%;
	height: 100%;
}
.textlink a:link,
.textlink a:visited {
	text-decoration: none;
}
.textlink:hover,
.textlink a:hover {
	background: transparent;
}
.textlink a[href^="http"]:after {
	content: "";
}
/** Sub canvas resize */
.moving {
	box-sizing: border-box;
	border: dotted 1px silver;
	opacity: 0.8;
}
.rframe {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
}

.rframe.resizing {
	border: #edab44 dotted 2px;
	z-index: 1;
}

.rhandle {
	position: absolute;
	bottom: 0;
	right: 0;
	z-index: 1;
	height: 32px;
	width: 32px;
}
.rhandle span {
	color: #555;
	font-size: 32px;
	line-height: 1;
	display: none;
	transform: rotate(45deg);
	user-select: none;
}

.rhandle:hover,
.rhandle.resizing {
	border: silver solid 1px;
	background: white;
	cursor: default;
}
.comback .rhandle.resizing {
	border: black solid 1px;
	background: yellow;
}
.rhandle:hover span,
.rhandle.resizing span {
	display: block;
}
.catche,
.guide {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: none;
}
.guide {
	background-image: linear-gradient(
		to top right,
		transparent, transparent 49.98%,
		rgba(249, 164, 164, 0.5) 49.98%,
		rgba(249, 164, 164, 0.5) 50%,
		transparent 50%, transparent
	);
}

/** Dual iframe panels */
#main > iframe {
	width: 49.5%;
	height: 800px;
	border: none;
}
#main > iframe:nth-child(1) {
	padding-right: 0.4%;
}
#main.landscape > iframe {
	width: 100%;
	height: 420px;
}
#main.landscape > iframe:nth-child(1) {
	padding-right: 0;
}

#gofar {
	background: #ffc;
	margin-left: 0.7em;
	padding-right: 0.6em;
}
/** audio */
#openseadragon.audio .msg {
	top: auto;
	bottom: 32px;
	padding-left: 20px;
	text-align: left;
	color: white;
	font-size: 80%;
	z-index: 1;
}
.audio .annotorious-popup {
	width: 300px;
}
.audio .annotorious-ol-boxmarker-inner:hover
{
	background-color: #5f91b0;
	cursor: pointer
}

/** media queries */
@media (max-width: 900px){
	body.sidx {
		padding-right: 3px;
	}
	body.threed {
		padding-right: 1em;
	}
	#titleidx.sidx {
		width: 120px;
	}
}
@media (max-height: 780px){
	#openseadragon, #titleidx > ul {
		height: 650px;
	}
	.referencestrip {
		height: 78px !important;
	}
}
@media (max-height: 650px){
	#openseadragon, #titleidx > ul {
		height: 560px;
		top: 12px;
	}
}

@media (max-width: 750px){
	#openseadragon, #annoclip table {
		width: 100%;
	}
	#openseadragon {
		height: 500px;
	}
	body.iaview,
	body.sidx {
		background-image: none;
		padding-right: 0.5em;
		padding-left: 1em;
	}
	#titleidx,
	#titleidx.sidx {
		position: static;
		width: 100%;
		max-width: 100%;
	}
	#titleidx ul {
		height: 160px;
	}
	.annotorious-popup {
		width: 180px;
	}
	.vinfo div {
		display: inline-block;
	}
	ul.collection.mu {
		column-count: 1;
	}
	iframe {
		width: 100%;
		height: 350px;
	}
	section p img,
	section li img {
		max-width: 180px;
	}
}

@media (max-height: 800px){
	#main.landscape > iframe {
		width: 90%;
		height: 350px;
		overflow: auto;
	}
}


<|start_filename|>ui/css/fullscreen.css<|end_filename|>
/*
  ***************************************
  GLOBAL
  ***************************************
 */
html, body {
	 height:100% 
}
a > img {
	border:none;
}
/*
  ***************************************
  FACETS
  ***************************************
 */
#map_filters {
	width:800px;
	height:400px;
}
ol li, ul li, dl li {
	list-style-type:none;
}
select {
	width:175px;
	margin-left:15px;
	margin-right:5px;
}
.category_list, .search_text {
	width:175px;
}
button.multiselect {
	margin-bottom:10px;
}
#close {
	position: absolute;
	bottom: 1em;
	right: 1em;
}
/*
  ***************************************
  MAPS/LEGEND
  ***************************************
 */
#legend {
	position: absolute;
	bottom: 2em;
	left: 2em;
	width: 180px;
	z-index: 1000;
	background-color: white;
	padding: 0.5em;
/* background-color:#F7F6ED; */
/* border:5px solid #C2B9A9; */
	border:5px solid gray;
}
#show_filters {
	font-size:80%;
	margin-left:25px;
}
#resultMap {
	width:600px;
	height:400px;
}
#clear_all {
	font-size:80%;
	margin-left:25px;
}
.olLayerGooglePoweredBy {
	display:none;
}
/*
  ***************************************
  Timemap CSS
  ***************************************
 */
div#mapcontainer {
	width:100%;
	height: 100%;
}
div.olFramedCloudPopupContent {
	width: 300px;
}
div#help {
	font-size: 12px;
	width: 45em;
	padding: 1em;
}
div.infotitle {
	font-size: 14px;
	font-weight: bold;
}
div.infodescription {
	font-size: 14px;
	font-style: italic;
}
div.custominfostyle {
	font-family: Georgia, Garamond, serif;
	font-size: 1.5em;
	font-style: italic;
	width: 20em;
}
/*
  ***************************************
  AJAX RESULTS
  ***************************************
 */
.g_doc {
	width:33%;
	float:left;
	height:325px;
}
/* gallery image container */
.gi_c {
	margin:5px 0;
	text-align:center;
}
/* gallery image */
.gi {
	padding:0px 5px;
	max-width:120px;
}
.result_link {
	font-size:120%;
}
/*
  ****************************************
  PAGINATION
  ****************************************
 */
.paging_div {
	padding:10px 0;
	vertical-align:baseline;
}
.page-nos {
	text-align:right;
}
.pagination {
	margin:0;
	padding:0;
}
.pagination a, .pagination button {
	height:32px;
}

<|start_filename|>ui/css/style.css<|end_filename|>
/*
  ****************************************
  GLOBAL
  ****************************************
 */
html{
	background-color:#F8F8F8;
}
.navbar{
	margin-bottom:0;
}
a > img{
	border:none;
}
.highlight{
	background-color:#F8F8F8;
	border:1px solid #E7E7E7;
	border-radius:4px;
	margin:10px 0;
	padding:10px 15px;
}
ul li,
ol li{
	list-style-type:none;
}
#iiif-container {
    background-color:white;
    width:100%;
    height:600px;
}
/*
  ***************************************
  FOOTER
  ***************************************
 */
#footer{
	background-color:#F8F8F8;
	border-top:1px solid #E7E7E7;
	padding-top:10px;
	padding-bottom:10px;
	text-align:center;
}
/*
  ****************************************
  EAD DISPLAY STYLING
  ****************************************
 */
#titlepage{
	text-align:center;
	margin-bottom:25px;
	padding-bottom:25px;
	border-bottom:1px solid silver;
}
#archdesc-did{
	margin-bottom:25px;
}
#archdesc-info{
	margin-bottom:25px;
	padding-bottom:25px;
	border-bottom:1px solid silver;
}
.toc_ul{
	padding:0;
	margin:0;
}
.toc_ul ul{
	margin-left:2em;
	padding:0;
}
.toc_ul li{
	list-style-type:none;
}
#dsc-toc li{
	list-style-type:circle;
}
#dsc-list li{
	list-style-type:none;
}
div.ctop{
	margin-bottom:25px;
	padding-bottom:25px;
	border-bottom:1px solid silver;
	display:table;
	width:100%;
}
div.cchild{
	margin-left:25px;
	margin-bottom:10px;
	display:table;
	width:95%;
}
.con1{
	width:80%;
	float:left;
}
.clevel{
	margin-left:10px;
}
.cchild p{
	margin:0 0 5px 0;
	padding:0px;
}
.external_link{
	margin-left:10px;
}
.display-thumb{
	height:160px;
}
.doc-icon{
	vertical-align:bottom;
	margin-left:10px;
}
/*
  ****************************************
  SEARCH PAGE
  ****************************************
 */
.option_container{
	width:200px;
	vertical-align:bottom;
}
.option_container select,
.option_container input{
	display:inline;
}
.category_list,
select[name = "interval"],
#stacking,
#image{
	width:175px;
	display:inline;
}
.sortForm_categories,
.sortForm_order{
	width:175px;
	margin-left:0px;
	margin-right:10px;
	display:inline;
}
.search_text{
	width:200px;
	margin-left:15px;
	margin-right:5px;
	display:inline;
}
#searchItemTemplate,
#sparqlItemTemplate{
	display:none;
}
.searchItemTemplate{
	padding-top:5px;
	padding-bottom:5px;
}
.year_int{
	width:30px;
	margin-left:0px;
	margin-right:5px;
}
.year_era{
	width:55px;
	margin-right:5px;
	margin-left:0px;
}
.year_range{
	margin-left:15px;
	margin-right:5px;
	width:101px;
}
/*
  ****************************************
  BROWSE RESULTS PAGE
  ****************************************
 */
.flickr-link{
	cursor:pointer;
}
#search_options{
	display:block;
	width:100%;
}
button.multiselect{
	margin:5px 0;
}
#qs_text{
	width:50%;
	display:inline;
	margin-right:20px;
}
.flickr-link{
	cursor:pointer;
}
.submit_div{
	text-align:center;
}
.stacked_term{
	margin:5px 0;
}
.right{
	text-align:right;
}
.remove_filter{
	float:right;
}
.sort_div{
	margin:10px 0;
}
#backgroundPopup{
	display:none;
	position:fixed;
	_position:absolute;
	/* hack for internet explorer 6 */
	height:100%;
	width:100%;
	top:0;
	left:0;
	z-index:2001;
}
.multiselect,
.hierarchical-facet,
.date-facet{
	width:250px;
	margin:5px 0;
}
#century_num-list,
.hier-list{
	max-height:250px;
	width:250px;
	overflow-y:auto;
	overflow-x:hidden;
	width:100%;
	z-index:3000;
}
.expand_century,
.expand_category{
	cursor:pointer;
	margin:1px;
}
/*
  ****************************************
  SPARQL
  ****************************************
 */
 #sparqlForm {
    margin: 20px 0;
}
#sparqlForm select {
    width: 200px;
}
.CodeMirror {
    background-color: #fff;
    background-image: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
    color: #555;
    padding: 6px 12px;
    transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;
}
.CodeMirror:focus {
    border-color: #66afe9;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset, 0 0 8px rgba(102, 175, 233, 0.6);
    outline: 0 none;
}
/*
  ****************************************
  PAGINATION
  ****************************************
 */
.paging_div{
	padding:10px 0;
	vertical-align:baseline;
}
.page-nos{
	text-align:right;
}
.pagination{
	margin:0;
	padding:0;
}
.pagination a,
.pagination button{
	height:32px;
}
/*
  ***************************************
  MAPS
  ***************************************
 */
#resultMap{
	width:600px;
	height:400px;
}
#clear_all{
	font-size:80%;
	margin-left:25px;
}
.ui-tabs .ui-tabs-hide{
	position:absolute;
	left:-10000px;
}
.olLayerGooglePoweredBy{
	display:none;
}
/*
  .olLayerGoogleCopyright {
  top:-1000px;
  }
 */
#add_filter{
	font-weight:bold;
	font-size:120%;
	text-transform:capitalize;
}
#add_filter:first-letter{
	font-size:140%;
}
.g_doc{
	width:30%;
	float:left;
	height:325px;
}
/* gallery image container */
.gi_c{
	margin:5px 0;
	text-align:center;
}
/* gallery image */
.gi{
	padding:0px 5px;
	max-width:120px;
}
#filter_list{
	margin:0;
	padding:0;
}
#filter_list li{
	list-style-type:none;
}
.fl{
	float:left;
	width:20%;
}
/*
  ***************************************
  TEI Display
  ***************************************
 */
/*
  #map-annotate-button {
  position:absolute;
  top:3px;
  right:3px;
  background-color:#000;
  color:#fff;
  padding:3px 8px;
  z-index:10000;
  font-size:11px;
  text-decoration:none;
  }
 */
#annot-parent{
	position:relative;
	width:50%;
	height:600px;
}
#annot{
	background-color:white;
	width:100%;
	height:600px;
}
#slider{
	border:1px solid silver;
	width:100%;
	margin:20px 0;
	table-layout:fixed;
}
#slider-thumbs{
	overflow-x:scroll;
	white-space:nowrap;
	height:250px;
}
#left-scroll,
#right-scroll{
	width:5%;
	height:250px;
	background-color:#ebebeb;
	font-size:32px;
	text-align:center;
	vertical-align:middle;
	cursor:pointer;
}
.page-image img{
	margin:5px;
	border:2px solid black;
	opacity:0.5;
	margin-top:20px;
}
img.selected{
	border:2px solid orange;
	opacity:1.0;
}
.page-image:hover img{
	border:2px solid orange;
	opacity:1.0;
}
#prev-page,
#goto-container,
#next-page{
	border-right:1px solid silver;
	padding:0 5px;
}
.disabled:link{
	color:black;
	font-style:italic;
	pointer-events:none;
}
#goto-page{
	max-width:250px;
	display:inline;
}
/*
  ***************************************
  Timemap CSS
  ***************************************
 */
div#timelinecontainer{
	width:100%;
	height:150px;
}
#map-page #mapcontainer{
	width:100%;
	height:600px;
}
#display-map #mapcontainer{
	width:100%;
	height:400px;
}
div.olFramedCloudPopupContent{
	width:300px;
}
div#help{
	font-size:12px;
	width:45em;
	padding:1em;
}
/*
  div#timemap {
  padding: 1em;
  }
 */
div#timeline{
	width:100%;
	height:100%;
	font-size:12px;
	background:#CCCCCC;
}
div#map{
	width:100%;
	height:100%;
	background:#EEEEEE;
}
div.infotitle{
	font-size:14px;
	font-weight:bold;
}
div.infodescription{
	font-size:14px;
	font-style:italic;
}
div.custominfostyle{
	font-family:Georgia, Garamond, serif;
	font-size:1.5em;
	font-style:italic;
	width:20em;
}

<|start_filename|>ui/javascript/search.js<|end_filename|>
/************************************
SEARCH
Written by <NAME>, <EMAIL>
Library: jQuery
Description: Portions of this originally authored by <NAME>.
Modified heavily to handle the search form functionality
and piecing together the search query.
************************************/
$(document).ready(function() {

	/***** TOGGLING FACET FORM*****/
	$('.inputContainer') .on('click', '.searchItemTemplate .gateTypeBtn', function () {
		gateTypeBtnClick($(this));
		//disable date select option if there is already a date select option
		if ($(this).closest('form').attr('id') == 'sparqlForm') {
			var count = countDate();
			if (count == 1) {
				$('#sparqlForm .searchItemTemplate').each(function () {
					//disable all new searchItemTemplates which are not already set to date
					if ($(this).children('.sparql_facets').val() != 'date') {
						$(this).find('option[value=date]').attr('disabled', true);
					}
				});
			}
		}
		
		return false;
	});
	$('.inputContainer').on('click', '.searchItemTemplate .removeBtn', function () {
		//enable date option in sparql form if the date is being removed
		if ($(this).closest('form').attr('id') == 'sparqlForm') {
			$('#sparqlForm .searchItemTemplate').each(function () {
				$(this).find('option[value=date]').attr('disabled', false);
				//enable submit
				$('#sparqlForm input[type=submit]').attr('disabled', false);
				//hide error
				$('#sparqlForm-alert').hide();
			});
		}
		
		// fade out the entire template
		$(this) .parent() .fadeOut('fast', function () {
			$(this) .remove();
		});
		return false;
	});
	
	$('.inputContainer').on('change', '.searchItemTemplate .category_list', function () {
		var selected_id = $(this) .children("option:selected") .attr('id');
		var num = $(this) .parent() .attr('id') .split('_')[1];
		var field = $(this).children('option:selected').val();
		if (field == 'text' || field.indexOf('_text') > 0 || field.indexOf('_display') > 0) {
			if ($(this) .parent() .children('.option_container') .children('input') .attr('class') != 'search_text') {
				$(this) .parent() .children('.option_container') .html('');
				$(this) .parent() .children('.option_container') .html('<input type="text" id="search_text" class="search_text"/>');
			}
		}
		//SELECTING OTHER DROP DOWN MENUS SECTION
		else {
			var category = $(this) .children("option:selected") .attr('value');
			$(this) .parent('.searchItemTemplate') .children('.option_container') .html('<select class="search_text"></select>');			
			$.get('../get_facets/', {
				q : category + ':[* TO *]', category:category, sort: 'index', limit:-1
			}, function (data) {
				$('#ajax-temp').html(data);
				if ($('#ajax-temp').html().indexOf('<option') > 0){
					$('#ajax-temp option').each(function(){
						$(this).clone().appendTo($('#container_' + num).children('.search_text'));
					});
					$('#container_' + num).children('.search_text').selectmenu({'style':'dropdown'});
				} else {
					$('#container_' + num).text('None found');
				}
			});				
		}
		
	});
	
	// activates the advanced search action
	$('#advancedSearchForm').submit(function() {
		var query = new Array();
		
		// loop through each ".searchItemTemplate" and build the query
		$('.inputContainer .searchItemTemplate') .each(function () {
			var field = $(this) .children('.category_list') .val();
			if ($(this).children('.option_container').html().indexOf('search_text') > 0 && $(this) .children('.option_container') .children('.search_text') .val().length > 0) {
				query.push (field + ':' + $(this) .children('.option_container') .children('.search_text') .val());
			} 
		});
		// pass the query to the search_results url passing the needed url params:
		if (query.length == 0){
			$('#q_input') .attr('value', '*:*');
		} else {
			$('#q_input') .attr('value', query.join(' AND '));
		}
		
	});
});

// copy the base template
function gateTypeBtnClick(btn) {
	var formId = btn.closest('form').attr('id');
	
	//clone the template
	var tpl = cloneTemplate(formId);
	
	// focus the text field after select
	$(tpl) .children('select') .change(function () {
		$(this) .siblings('input') .focus();
	});
	
	// add the new template to the dom
	$(btn) .parent() .after(tpl);
	
	tpl.children('.removeBtn').removeAttr('style');
	tpl.children('.removeBtn') .before(' |&nbsp;');
	
	// display the entire new template
	tpl.fadeIn('fast');
}

function cloneTemplate(formId) {
	if (formId == 'sparqlForm') {
		var tpl = $('#sparqlItemTemplate') .clone();
	} else {
		var tpl = $('#searchItemTemplate') .clone();
	}
	
	//remove id to avoid duplication with the template
	tpl.removeAttr('id');
	
	return tpl;
}
	


<|start_filename|>ui/javascript/display_map_functions.js<|end_filename|>
function initialize_timemap(id, path) {
    var path = $('#path').text();
    var url = path + "api/get?id=" + id + "&format=json&model=timemap";
    var datasets = new Array();
    
    //first dataset
    datasets.push({
        id: 'dist',
        title: "Distribution",
        type: "json",
        options: {
            url: url
        }
    });
    
    var tm;
    tm = TimeMap.init({
        mapId: "map", // Id of map div element (required)
        timelineId: "timeline", // Id of timeline div element (required)
        options: {
            eventIconPath: path + "images/timemap/"
        },
        datasets: datasets,
        bandIntervals:[
        Timeline.DateTime.YEAR,
        Timeline.DateTime.DECADE]
    });
}

function initialize_map(id, path) {
    var mapboxKey = $('#mapboxKey').text();
    
    //baselayers
    var mb_physical = L.tileLayer(
    'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=' + mapboxKey, {
        attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
        '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
        'Imagery © <a href="http://mapbox.com">Mapbox</a>', id: 'mapbox.streets'
    });
    
    var osm = L.tileLayer(
    'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
        attribution: 'OpenStreetMap',
        maxZoom: 18
    });
    
    var map = new L.Map('mapcontainer', {
        center: new L.LatLng(0, 0),
        zoom: 4,
        layers: mb_physical
    });
    
    //add mintLayer from AJAX
    var overlay = L.geoJson.ajax(id + ".geojson");
    
    var baseMaps = {
        'Topography': mb_physical,
        'Open Street Map': osm
    };
    
    var layerControl = L.control.layers(baseMaps).addTo(map);
    
    //zoom to groups on AJAX complete
    overlay.on('data:loaded', function () {
        markers = L.markerClusterGroup();
        layerControl.addOverlay(markers, 'Related Places');
        markers.addLayer(overlay);
        map.addLayer(markers);
        
        var group = new L.featureGroup([overlay]);
        map.fitBounds(group.getBounds());
    }.bind(this));
    
    overlay.on('click', function (e) {
        renderPopup(e);
    });
}

/*****
 * LEAFLET FUNCTIONS
 *****/

/*****
 * Generate a popup for the various types of layers
 *****/
function renderPopup(e) {
    var str = "<h4>" + e.layer.feature.properties.toponym + " <a href='" + e.layer.feature.properties.gazetteer_uri + "' target='_blank'><span class='glyphicon glyphicon-new-window'/></a></h4>";
    
    if (e.layer.feature.properties.relatedComponent.length > 0) {
        str += '<div><b>Related Components</b>';
        str += '<ul>';
        $.each(e.layer.feature.properties.relatedComponent, function (key, value) {
            str += "<li><a href='" + value.uri + "'>" + value.title + '</a></li>';
        });
        str += '</ul></div>';
    }
    
    e.layer.bindPopup(str).openPopup();
}

<|start_filename|>ui/javascript/toggle_search_options.js<|end_filename|>
/************************************
TOGGLE SEARCH OPTIONS
Written by <NAME>, <EMAIL>
Library: jQuery
Description: This javascript file handles the dynamic search form
in the search and search results pages.  Some fields require
text boxes, some require the entry of integers to search a range,
and the remaining query solr and return unique facets and write
them to the drop-down menu.
************************************/

$(document).ready(function() {		
	$('.category_list') .livequery('change', function(event){
		var selected_id = $(this) .children("option:selected") .attr('id');
		var num = $(this) .parent() .attr('id') .split('_')[1];
		var field = $(this).children('option:selected').val();
		if (field == 'text' || field.indexOf('_text') > 0 || field.indexOf('_display') > 0) {
			if ($(this) .parent() .children('.option_container') .children('input') .attr('class') != 'search_text') {
				$(this) .parent() .children('.option_container') .html('');
				$(this) .parent() .children('.option_container') .html('<input type="text" id="search_text" class="search_text"/>');
			}
		}
		//SELECTING OTHER DROP DOWN MENUS SECTION
		else {
			var category = $(this) .children("option:selected") .attr('value');
			$(this) .parent('.searchItemTemplate') .children('.option_container') .html('<select class="search_text"></select>');			
			$.get('../get_facets/', {
				q : category + ':[* TO *]', category:category, sort: 'index', limit:-1
			}, function (data) {
				$('#ajax-temp').html(data);
				if ($('#ajax-temp').html().indexOf('<option') > 0){
					$('#ajax-temp option').each(function(){
						$(this).clone().appendTo($('#container_' + num).children('.search_text'));
					});
					$('#container_' + num).children('.search_text').selectmenu({'style':'dropdown'});
				} else {
					$('#container_' + num).text('None found');
				}
			});				
		}
		
	});
});

<|start_filename|>xforms/xbl/tree-view/tree-view.js<|end_filename|>
/************************************
TREE VIEW
Written by <NAME>, ewg4xuva -at- gmail.com
Library: jQuery
Description: Expand and collapse the tree-view listing of EAD components
 ************************************/

$(document).ready(function () {
	$('.nodename').click(function () {
		if ($(this).parent('ul').attr('class') == 'collapsed') {
			$(this).parent('ul').attr('class', 'expanded');
			$(this).children('.xforms-group').children('.xforms-trigger').children('a').children('span').removeClass('glyphicon-plus');
			$(this).children('.xforms-group').children('.xforms-trigger').children('a').children('span').addClass('glyphicon-minus');
		} else {
			$(this).parent('ul').attr('class', 'collapsed');
			$(this).children('.xforms-group').children('.xforms-trigger').children('a').children('span').removeClass('glyphicon-minus');
			$(this).children('.xforms-group').children('.xforms-trigger').children('a').children('span').addClass('glyphicon-plus');
		}
	});
});

<|start_filename|>ui/javascript/display_annotation_functions.js<|end_filename|>
$(document).ready(function () {
	
	
	//automatically load image from hash
	if (window.location.hash) {
		var id = window.location.hash.substring(1);
		var image = $('#' + id).attr('href');
		
		//change selection class
		$('#' + id).children('img').attr('class', 'selected');
		$('#' + $('#image-id').text()).children('img').removeAttr('class');
	} else {
		var image = $('#image-path').text();
		var id = $('#image-id').text();
	}
	
	//call load_image function, which will wait until the image loads in the DOM before getting its height and width to initiate openlayers
	load_image(id, image);
	
	//activate slider image clicks to load large image in openlayers
	$('.page-image').click(function () {
		//get id, either from the page link or the thumbnail link
		if ($(this).attr('id')) {
			var id = $(this).attr('id');
		} else if ($(this).attr('facs')) {
			var id = $(this).attr('facs');
		}
		
		//first clear container div and annot div
		$('#image-container').html('');
		$('#annot').html('');
		
		//reset selected class
		$('img.selected').removeAttr('class');
		$('#' + id).children('img').attr('class', 'selected');
		
		//then destroy annotations before reloading
		anno.destroy();
		
		//reload
		var image = $(this).attr('href');
		load_image(id, image);
		
		//enable/disable prev/next page links
		if (id == $('#first-page').text()) {
			$('#prev-page').attr('class', 'disabled');
			$('#next-page').removeAttr('class');
		} else if (id == $('#last-page').text()) {
			$('#next-page').attr('class', 'disabled');
			$('#prev-page').removeAttr('class');
		} else {
			$('#next-page').removeAttr('class');
			$('#prev-page').removeAttr('class');
		}
		//alter goto page dropdown
		$('#goto-page').val(id);
		
		//scroll to top
		window.scrollTo(0, 0);
		return false;
	});
	
	/* navigation pagination */
	$('#prev-page').click(function () {
		var current_id = $('img.selected').parent('.page-image').attr('id');
		var prev_id = $('#' + current_id).prev('.page-image').attr('id');
		if (prev_id != null) {
			//first clear container div and annot div
			$('#image-container').html('');
			$('#annot').html('');
			
			//reset selected class
			$('img.selected').removeAttr('class');
			$('#' + prev_id).children('img').attr('class', 'selected');
			
			//then destroy annotations before reloading
			anno.destroy();
			
			//reload
			var image = $('#' + prev_id).attr('href');
			var id = $('#' + prev_id).attr('id');
			load_image(id, image);
		}
		//enable/disable prev/next page links
		if (prev_id == $('#first-page').text()) {
			$('#prev-page').attr('class', 'disabled');
			$('#next-page').removeAttr('class');
		} else {
			$('#next-page').removeAttr('class');
		}
		//alter goto page dropdown
		$('#goto-page').val(prev_id);
		return false;
	});
	$('#next-page').click(function () {
		var current_id = $('img.selected').parent('.page-image').attr('id');
		var next_id = $('#' + current_id).next('.page-image').attr('id');
		if (next_id != null) {
			//first clear container div and annot div
			$('#image-container').html('');
			$('#annot').html('');
			
			//reset selected class
			$('img.selected').removeAttr('class');
			$('#' + next_id).children('img').attr('class', 'selected');
			
			//then destroy annotations before reloading
			anno.destroy();
			
			//reload
			var image = $('#' + next_id).attr('href');
			var id = $('#' + next_id).attr('id');
			load_image(id, image);
		}
		//enable/disable link
		if (next_id == $('#last-page').text()) {
			$('#next-page').attr('class', 'disabled');
			$('#prev-page').removeAttr('class');
		} else {
			$('#prev-page').removeAttr('class');
		}
		//alter goto page dropdown
		$('#goto-page').val(next_id);
		return false;
	});
	
	/* go to page dropdown */
	$('#goto-page').change(function () {
		var id = $(this).val();
		
		//first clear container div and annot div
		$('#image-container').html('');
		$('#annot').html('');
		
		//reset selected class
		$('img.selected').removeAttr('class');
		$('#' + id).children('img').attr('class', 'selected');
		
		//then destroy annotations before reloading
		anno.destroy();
		
		//reload
		var image = $('#' + id).attr('href');
		load_image(id, image);
		
		//enable/disable link
		if (id == $('#first-page').text()) {
			$('#prev-page').attr('class', 'disabled');
			$('#next-page').removeAttr('class');
		} else if (id == $('#last-page').text()) {
			$('#next-page').attr('class', 'disabled');
			$('#prev-page').removeAttr('class');
		} else {
			$('#next-page').removeAttr('class');
			$('#prev-page').removeAttr('class');
		}
		return false;
	});
	
	/* image scroller */
	$('#left-scroll').on('click', function (event) {
		pos = $('#slider-thumbs').scrollLeft();
		$('#slider-thumbs').animate({
			scrollLeft: pos - 500
		},
		1000)
	});
	$('#right-scroll').on('click', function (event) {
		pos = $('#slider-thumbs').scrollLeft();
		$('#slider-thumbs').animate({
			scrollLeft: pos + 500
		},
		1000)
	});
});

function load_image(id, image) {
	var dimensions = new Array();
	$('<img/>').on("load", function () {
		dimensions[ "height"] = this.naturalHeight;
		dimensions[ "width"] = this.naturalWidth;
		render_map(id, image, dimensions);
	}).attr('src', image).appendTo('#image-container');
}

function render_map(id, image, dimensions) {
	
	var height = + dimensions[ "height"];
	var width = + dimensions[ "width"];
	
	//get ratio between height and width and set bounds
	if (height > width) {
		var ratio = height / width;
		var bounds = new Array(- 1, - Math.abs(ratio), 1, ratio);
	} else {
		var ratio = width / height;
		var bounds = new Array(- Math.abs(ratio), - 1, ratio, 1);
	}
	//instantiate map
	var map = new OpenLayers.Map('annot', {
		numZoomLevels: 3, units: "pixels", isBaseLayer: true
	});
	var baseLayer = new OpenLayers.Layer.Image('image', image, new OpenLayers.Bounds(bounds), new OpenLayers.Size(600 * ratio, 600));
	
	//add baseLayer, zoom to extent
	map.addLayer(baseLayer);
	map.zoomToMaxExtent();
	
	//handle annotations
	anno.makeAnnotatable(map);
	
	//import annotations
	import_annotations(id);
}

function import_annotations(id) {
	var path = $('#display_path').text();
	var doc = $('#doc').text();
	$.get(path + 'get_annotations/', {
		facsimile: id, doc: doc
	},
	function (data) {
		var obj = $.parseJSON(data);
		$.each(obj, function (index, value) {
			anno.addAnnotation(value);
		});
	});
}

<|start_filename|>ui/javascript/result_functions.js<|end_filename|>
$(document).ready(function () {
	$(".thumbImage a").fancybox({ helpers: {
			title: {
				type: 'inside'
			}
		}
	});
	
	//sort functions
	$('.sortForm_categories') .change(function () {
		var field = $(this).val();
		var sort_order = $('.sortForm_order').val();
		setValue(field, sort_order);
	});
	$('.sortForm_order') .change(function () {
		var field = $('.sortForm_categories').val();
		var sort_order = $(this).val();
		setValue(field, sort_order);
	});
	
	function setValue(field, sort_order) {
		var category;
		if (field.indexOf('_') > 0 || field == 'timestamp') {
			category = field;
		} else {
			if (sort_order == 'asc') {
				switch (field) {
					case 'year':
					category = field + '_minint';
					break;
					default:
					category = field + '_min';
				}
			} else if (sort_order == 'desc') {
				switch (field) {
					case 'year':
					category = field + '_maxint';
					break;
					default:
					category = field + '_max';
				}
			}
		}
		if (field != 'null') {
			$('.sort_button') .removeAttr('disabled');
			$('.sort_param') .attr('value', category + ' ' + sort_order);
		} else {
			$('.sort_button') .attr('disabled', 'disabled');
		}
	}
	
	//quick search
	$('#qs_form').submit(function () {
		assembleQuery();
	});
	
	function assembleQuery() {
		var search_text = $('#qs_text') .val();
		var query = $('#qs_query').val();
		if (search_text != null && search_text != '') {
			if (query == '*:*' || query.length == 0) {
				$('#qs_query') .attr('value', 'text:' + search_text);
			} else {
				$('#qs_query') .attr('value', query + ' AND text:' + search_text);
			}
		} else {
			$('#qs_query') .attr('value', '*:*');
		}
	}
});

<|start_filename|>xforms/css/xforms.css<|end_filename|>
/*
  ****************************************
  GLOBAL
  ****************************************
 */
 body {
	margin:20px auto;
	min-width:960px;
	max-width:100%;
}
.content {
	padding:5px;
}
/*
  ****************************************
  FORM LAYOUT
  ****************************************
 */
 #form h1,#form h2, #form h3, #form h4,#form h5,#form h6 {
	display:inline;
}
.submission {
	text-align:center;
	margin:10px 0;
	font-size:larger;
}
.xforms-submit {
	margin-left:10px;
	margin-right:10px;
}
.navigation {
	width:190px;
	float:left;
}
#expand_components, #refresh {
	cursor:pointer;
	color:#8BADCF
}
#expand_components:hover, #refresh:hover {
	cursor:pointer;
	color:#627eb7;
}
.list-hidden {
	display:none;
}
.pair_div {	
	border-radius: 5px;
	border:1px solid silver;
	margin-bottom:2px;
	padding:5px;
	display:table;
}
/*
  .xforms-group>div{
  display:table;
  }
 */
.section>div {
	display:table;
	width:100%;
}
.section {
	margin-bottom:25px;
	width:100%;
}
.subsection {
	padding:10px 0 10px 15px;
}
.alert-box {
	width:50%;
	margin:20px auto;
	padding:5px;
	border-radius: 10px;
}
/*
  ****************************************
  ORBEON XFORM SPECIFIC STYLE
  ****************************************
 */
.orbeon .xforms-control {
	margin-bottom: 10px;
}
.orbeon .xforms-label {
	font-weight: bold;
	display: inline-block;
	min-width: 12em
}
.orbeon .xforms-select1-appearance-full .xforms-label {
	vertical-align: top
}
.orbeon .xforms-input input[type=text], .orbeon .xforms-textarea textarea, .orbeon .xforms-select1 select {
	width: 24em;
	margin-bottom: 2px;
}
.orbeon .checkbox input {
	width: 5em;
	margin-bottom: 2px;
}
.orbeon .xforms-repeat-selected-item-1 .form-td {
	background-color: #f5f5f5
}
.orbeon .xforms-items {
	display: inline-block
}
.trigger_container {
	margin-bottom:20px;
}
.xforms-trigger-appearance-minimal img {
	vertical-align: middle
}
.xforms-output {
	margin:0;
}
.orbeon .xforms-output output[role=textbox] {
	display:inline;
	font-size:inherit;
	border:none;
	background-color:inherit;
	cursor:default;
	white-space:normal;
}
.xforms-trigger {
	text-decoration:none;
}
.xforms-repeat-selected-item-1, .xforms-repeat-selected-item-2, .xforms-repeat-selected-item-3, .xforms-repeat-selected-item-4 {
	background:inherit;
}
.xforms-repeat-selected-item-2 {
	background:none;
}
.xxforms-dialog-body>a, .xxforms-dialog-body>span {
	width:100px;
}
.xbl-component {
	margin:5px 0;
}
.trigger_container {
	margin-bottom:20px;
}
.add {
	display:inline;	
}
.xbl-eaditor-generic-elements, .xbl-eaditor-attributes, .xbl-eaditor-access-elements, .xbl-eaditor-delete-dialog {
	display:inline;
	color:gray;	
}
.orbeon .radio-inline .xforms-label {
    display:block;
}

/*
  ****************************************
  PAGINATION
  ****************************************
 */
.paging_div {
	width:100%;
	display:table;
	padding-top:10px;
	padding-bottom:10px;
}
.pagingBtn, .pagingSep {
	padding:2px;
	text-decoration:none;
}
.pagingBtn {
	font-weight:bold;
}
.pagingBtn:hover {
	background-color:#DDDDDD;
	text-decoration:underline;
}
/*
  ****************************************
  ADMIN PAGE
  ****************************************
 */
.page_toc {
	font-size:12px;
}
.browse_table {
	width:100%;
}
.odd-row {
	background-color:white;
	margin:10px 0;
	padding:10px 0;
	vertical-align:top;
}
.even-row {
	background-color:#EFEFEF;
	margin:10px 0;
	padding:10px 0px;
	vertical-align:top;
}
.center {
	text-align:center;
}
.expand {
	margin-left:25px;
	font-size:12px;
	color:#8BADCF;
	cursor:pointer;
	text-decoration:underline;
}
.reorder {
	margin-left:25px;
	font-size:12px;
	color:#8BADCF;
	text-decoration:underline;
}
/*
  ****************************************
  TEI ANNOTATIONS
  ****************************************
 */
.annot {
	width:100%;
	height:600px;
}
#image-container {
	display: none;
}