PageSourceSearch

https://www.kunitachi.ac.jp/shared/thickbox/thickbox.js

js kunitachi.ac.jp collected 2026-09-24 19:55:38 UTC 12,651 bytes, 324 lines download raw bytes

1/*
2 * Thickbox 3.1 - One Box To Rule Them All.
3 * By Cody Lindley (http://www.codylindley.com)
4 * Copyright (c) 2007 cody lindley
5 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
6*/
7		  
8var tb_pathToImage = "/shared/thickbox/loadingAnimation.gif";
9
10/*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/
11
12//on page load call tb_init
13$(document).ready(function(){   
14	tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
15	imgLoader = new Image();// preload image
16	imgLoader.src = tb_pathToImage;
17});
18
19//add thickbox to href & area elements that have a class of .thickbox
20function tb_init(domChunk){
21	$(domChunk).click(function(){
22	var t = this.title || this.name || null;
23	var a = this.href || this.alt;
24	var g = this.rel || false;
25	tb_show(t,a,g);
26	this.blur();
27	return false;
28	});
29}
30
31function tb_show(caption, url, imageGroup) {//function called when the user clicks on a thickbox link
32
33	try {
34		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
35			$("body","html").css({height: "100%", width: "100%"});
36			$("html").css("overflow","hidden");
37			if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
38				$("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
39				$("#TB_overlay").click(tb_remove);
40			}
41		}else{//all others
42			if(document.getElementById("TB_overlay") === null){
43				$("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
44				$("#TB_overlay").click(tb_remove);
45			}
46		}
47		
48		if(tb_detectMacXFF()){
49			$("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
50		}else{
51			$("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
52		}
53		
54		if(caption===null){caption="";}
55		$("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");//add loader to the page
56		$('#TB_load').show();//show loader
57		
58		var baseURL;
59	   if(url.indexOf("?")!==-1){ //ff there is a query string involved
60			baseURL = url.substr(0, url.indexOf("?"));
61	   }else{ 
62	   		baseURL = url;
63	   }
64	   
65	   var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/;
66	   var urlType = baseURL.toLowerCase().match(urlString);
67
68		if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images
69				
70			TB_PrevCaption = "";
71			TB_PrevURL = "";
72			TB_PrevHTML = "";
73			TB_NextCaption = "";
74			TB_NextURL = "";
75			TB_NextHTML = "";
76			TB_imageCount = "";
77			TB_FoundURL = false;
78			if(imageGroup){
79				TB_TempArray = $("a[@rel="+imageGroup+"]").get();
80				for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML === "")); TB_Counter++) {
81					var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString);
82						if (!(TB_TempArray[TB_Counter].href == url)) {						
83							if (TB_FoundURL) {
84								TB_NextCaption = TB_TempArray[TB_Counter].title;
85								TB_NextURL = TB_TempArray[TB_Counter].href;
86								TB_NextHTML = "<span id='TB_next'>&nbsp;&nbsp;<a href='#'>Next &gt;</a></span>";
87							} else {
88								TB_PrevCaption = TB_TempArray[TB_Counter].title;
89								TB_PrevURL = TB_TempArray[TB_Counter].href;
90								TB_PrevHTML = "<span id='TB_prev'>&nbsp;&nbsp;<a href='#'>&lt; Prev</a></span>";
91							}
92						} else {
93							TB_FoundURL = true;
94							TB_imageCount = "Image " + (TB_Counter + 1) +" of "+ (TB_TempArray.length);											
95						}
96				}
97			}
98
99			imgPreloader = new Image();
100			imgPreloader.onload = function(){		
101			imgPreloader.onload = null;
102				
103			// Resizing large images - orginal by Christian Montoya edited by me.
104			var pagesize = tb_getPageSize();
105			var x = pagesize[0] - 150;
106			var y = pagesize[1] - 150;
107			var imageWidth = imgPreloader.width;
108			var imageHeight = imgPreloader.height;
109			if (imageWidth > x) {
110				imageHeight = imageHeight * (x / imageWidth); 
111				imageWidth = x; 
112				if (imageHeight > y) { 
113					imageWidth = imageWidth * (y / imageHeight); 
114					imageHeight = y; 
115				}
116			} else if (imageHeight > y) { 
117				imageWidth = imageWidth * (y / imageHeight); 
118				imageHeight = y; 
119				if (imageWidth > x) { 
120					imageHeight = imageHeight * (x / imageWidth); 
121					imageWidth = x;
122				}
123			}
124			// End Resizing
125			
126			TB_WIDTH = imageWidth + 30;
127			TB_HEIGHT = imageHeight + 60;
128			//$("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div>"); 		
129			$("#TB_window").append("<div id='frameEtype'><div id='HEADER-AREA'><p class='wm_right'><a href='#' id='TB_closeWindowButton' title='Close'>CLOSE</a> or Esc Key</p></div></div>"); 		
130			
131			//$("#TB_closeWindowButton").click(tb_remove);
132			$("#frameEtype #HEADER-AREA").click(tb_remove);
133			
134			if (!(TB_PrevHTML === "")) {
135				function goPrev(){
136					if($(document).unbind("click",goPrev)){$(document).unbind("click",goPrev);}
137					$("#TB_window").remove();
138					$("body").append("<div id='TB_window'></div>");
139					tb_show(TB_PrevCaption, TB_PrevURL, imageGroup);
140					return false;	
141				}
142				$("#TB_prev").click(goPrev);
143			}
144			
145			if (!(TB_NextHTML === "")) {		
146				function goNext(){
147					$("#TB_window").remove();
148					$("body").append("<div id='TB_window'></div>");
149					tb_show(TB_NextCaption, TB_NextURL, imageGroup);				
150					return false;	
151				}
152				$("#TB_next").click(goNext);
153				
154			}
155
156			document.onkeydown = function(e){ 	
157				if (e == null) { // ie
158					keycode = event.keyCode;
159				} else { // mozilla
160					keycode = e.which;
161				}
162				if(keycode == 27){ // close
163					tb_remove();
164				} else if(keycode == 190){ // display previous image
165					if(!(TB_NextHTML == "")){
166						document.onkeydown = "";
167						goNext();
168					}
169				} else if(keycode == 188){ // display next image
170					if(!(TB_PrevHTML == "")){
171						document.onkeydown = "";
172						goPrev();
173					}
174				}	
175			};
176			
177			tb_position();
178			$("#TB_load").remove();
179			$("#TB_ImageOff").click(tb_remove);
180			$("#TB_window").css({display:"block"}); //for safari using css instead of show
181			};
182			
183			imgPreloader.src = url;
184		}else{//code to show html
185			
186			var queryString = url.replace(/^[^\?]+\??/,'');
187			var params = tb_parseQuery( queryString );
188
189			TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL
190			TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL
191			ajaxContentW = TB_WIDTH - 30;
192			ajaxContentH = TB_HEIGHT - 45;
193			
194			if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window		
195					urlNoQuery = url.split('TB_');
196					$("#TB_iframeContent").remove();
197					if(params['modal'] != "true"){//iframe no modal
198						//$("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' > </iframe>");
199						$("#TB_window").append("<div id='frameEtype'><div id='HEADER-AREA'><p class='wm_right'><a href='#' id='TB_closeWindowButton' title='Close'>CLOSE</a> or Esc Key</p></div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' > </iframe>");
200					}else{//iframe modal
201					$("#TB_overlay").unbind();
202						$("#TB_window").append("<iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent"+Math.round(Math.random()*1000)+"' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;'> </iframe>");
203					}
204			}else{// not an iframe, ajax
205					if($("#TB_window").css("display") != "block"){
206						if(params['modal'] != "true"){//ajax no modal
207						//$("#TB_window").append("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>close</a> or Esc Key</div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>");
208						$("#TB_window").append("<div id='frameEtype'><div id='HEADER-AREA'><p class='wm_right'><a href='#' id='TB_closeWindowButton' title='Close'>CLOSE</a> or Esc Key</p></div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px'></div>");
209						}else{//ajax modal
210						$("#TB_overlay").unbind();
211						$("#TB_window").append("<div id='TB_ajaxContent' class='TB_modal' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>");	
212						}
213					}else{//this means the window is already up, we are just loading new content via ajax
214						$("#TB_ajaxContent")[0].style.width = ajaxContentW +"px";
215						$("#TB_ajaxContent")[0].style.height = ajaxContentH +"px";
216						$("#TB_ajaxContent")[0].scrollTop = 0;
217						$("#TB_ajaxWindowTitle").html(caption);
218					}
219			}
220					
221			//$("#TB_closeWindowButton").click(tb_remove);
222			$("#frameEtype #HEADER-AREA").click(tb_remove);
223			
224				if(url.indexOf('TB_inline') != -1){	
225					$("#TB_ajaxContent").append($('#' + params['inlineId']).children());
226					$("#TB_window").unload(function () {
227						$('#' + params['inlineId']).append( $("#TB_ajaxContent").children() ); // move elements back when you're finished
228					});
229					tb_position();
230					$("#TB_load").remove();
231					$("#TB_window").css({display:"block"}); 
232				}else if(url.indexOf('TB_iframe') != -1){
233					tb_position();
234					if($.browser.safari){//safari needs help because it will not fire iframe onload
235						$("#TB_load").remove();
236						$("#TB_window").css({display:"block"});
237					}
238				}else{
239					$("#TB_ajaxContent").load(url += "&random=" + (new Date().getTime()),function(){//to do a post change this load method
240						tb_position();
241						$("#TB_load").remove();
242						tb_init("#TB_ajaxContent a.thickbox");
243						$("#TB_window").css({display:"block"});
244					});
245				}
246			
247		}
248
249		if(!params['modal']){
250			document.onkeyup = function(e){ 	
251				if (e == null) { // ie
252					keycode = event.keyCode;
253				} else { // mozilla
254					keycode = e.which;
255				}
256				if(keycode == 27){ // close
257					tb_remove();
258				}	
259			};
260		}
261		
262	} catch(e) {
263		//nothing here
264	}
265}
266
267//helper functions below
268function tb_showIframe(){
269	$("#TB_load").remove();
270	$("#TB_window").css({display:"block"});
271}
272
273function tb_remove() {
274 	$("#TB_imageOff").unbind("click");
275	$("#TB_closeWindowButton").unbind("click");
276	$("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').trigger("unload").unbind().remove();});
277	$("#TB_load").remove();
278	if (typeof document.body.style.maxHeight == "undefined") {//if IE 6
279		$("body","html").css({height: "auto", width: "auto"});
280		$("html").css("overflow","");
281	}
282	document.onkeydown = "";
283	document.onkeyup = "";
284	return false;
285}
286
287function tb_position() {
288$("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
289//	if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
290		$("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
291		//	}
292}
293
294function tb_parseQuery ( query ) {
295   var Params = {};
296   if ( ! query ) {return Params;}// return empty object
297   var Pairs = query.split(/[;&]/);
298   for ( var i = 0; i < Pairs.length; i++ ) {
299      var KeyVal = Pairs[i].split('=');
300      if ( ! KeyVal || KeyVal.length != 2 ) {continue;}
301      var key = unescape( KeyVal[0] );
302      var val = unescape( KeyVal[1] );
303      val = val.replace(/\+/g, ' ');
304      Params[key] = val;
305   }
306   return Params;
307}
308
309function tb_getPageSize(){
310	var de = document.documentElement;
311	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
312	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
313	arrayPageSize = [w,h];
314	return arrayPageSize;
315}
316
317function tb_detectMacXFF() {
318  var userAgent = navigator.userAgent.toLowerCase();
319  if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) {
320    return true;
321  }
322}
323
324

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