PageSourceSearch

https://mlexp.com/wiki/greybox/greybox.js

js mlexp.com collected 2026-09-25 06:07:26 UTC 5,445 bytes, 200 lines download raw bytes

1/****
2Last Modified: 28/04/06 16:23:20
3
4 GreyBox - The pop-up window thingie
5   Copyright Amir Salihefendic 2006
6 AUTHOR
7   4mir Salihefendic (http://amix.dk) - [email protected]
8 VERSION
9	 1.92
10 LICENSE
11  LGPL (read more in LGPL.txt)
12 SITE
13   http://amix.dk/greybox
14****/
15var GB_HEADER = null;
16var GB_WINDOW = null;
17var GB_IFRAME = null;
18var GB_OVERLAY = null;
19var GB_TIMEOUT = null;
20
21var GB_URL;
22
23var GB_HEIGHT = 400;
24var GB_WIDTH = 400;
25
26var GB_caption = null;
27
28//The url that was visited last
29var GB_last_win_url = null;
30
31function GB_show(caption, url /* optional */, height, width, return_win) {
32  if(height != 'undefined')
33    GB_HEIGHT = height;
34  if(width != 'undefined')
35    GB_WIDTH = width;
36
37  initIfNeeded();
38
39  GB_caption.innerHTML = caption;
40
41  GB_setPosition();
42  if(GB_ANIMATION) {
43    positionRightVertically(GB_HEADER, -(GB_HEIGHT));
44    positionRightVertically(GB_WINDOW, -(GB_HEIGHT+22));
45  }
46
47  AJS.showElement(GB_OVERLAY);
48  AJS.showElement(GB_HEADER);
49  AJS.showElement(GB_WINDOW);
50
51  GB_setWidth();
52
53  if(GB_ANIMATION) {
54    GB_animateOut(-GB_HEIGHT);
55    GB_URL = url;
56  }
57  else {
58    GB_IFRAME.src = url;
59    GB_IFRAME.opener = this;
60  }
61  return false;
62}
63
64function GB_hide() {
65  GB_IFRAME.src = GB_IMG_DIR + "blank.html";
66  AJS.hideElement(GB_WINDOW);
67  AJS.hideElement(GB_HEADER);
68  AJS.hideElement(GB_OVERLAY);
69}
70
71function GB_setPosition() {
72  positionRightVertically(GB_HEADER, 0);
73  positionRightVertically(GB_WINDOW, 22);
74}
75
76function GB_animateOut(top) {
77  if(top+getScrollTop() < 0) {
78    positionRightVertically(GB_WINDOW, top+22);
79    positionRightVertically(GB_HEADER, top);
80    GB_TIMEOUT = window.setTimeout(function() { GB_animateOut(top+50); }, 1);
81  }
82  else {
83    GB_IFRAME.src = GB_URL;
84    GB_IFRAME.opener = this;
85    GB_WINDOW.style.top = getScrollTop()+22+"px";
86    GB_HEADER.style.top = getScrollTop()+"px";
87    clearTimeout(GB_TIMEOUT);
88  }
89}
90
91function GB_setWidth() {
92  var array_page_size = GB_getWindowSize();
93
94  //Set size
95  GB_WINDOW.style.width = GB_WIDTH + "px";
96  GB_IFRAME.style.width = GB_WIDTH + "px";
97  GB_HEADER.style.width = GB_WIDTH + "px";
98
99  GB_WINDOW.style.height = GB_HEIGHT + "px";
100  GB_IFRAME.style.height = GB_HEIGHT - 5 + "px";
101
102  if((navigator.userAgent.toLowerCase().indexOf("firefox") != -1))
103    GB_OVERLAY.style.width = "100%";
104  else
105    GB_OVERLAY.style.width = array_page_size[0] + "px";
106
107  var max_height = Math.max(getScrollTop()+array_page_size[1], getScrollTop()+GB_HEIGHT+30);
108  GB_OVERLAY.style.height = max_height + "px";
109
110  GB_WINDOW.style.left = ((array_page_size[0] - GB_WINDOW.offsetWidth) /2) + "px";
111  GB_HEADER.style.left = ((array_page_size[0] - GB_HEADER.offsetWidth) /2) + "px";
112  
113}
114
115function GB_init() {
116  //Create the overlay
117  GB_OVERLAY = AJS.DIV({'id': 'GB_overlay'});
118  if(AJS.isIe()) {
119    GB_OVERLAY.style.backgroundColor = "#000000";
120    GB_OVERLAY.style.backgroundColor = "transparent";
121    GB_OVERLAY.style.backgroundImage = "url("+ GB_IMG_DIR +"blank.gif)";
122    GB_OVERLAY.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + GB_IMG_DIR + "overlay.png',sizingMethod='scale')";
123  }
124  else 
125    GB_OVERLAY.style.backgroundImage = "url("+ GB_IMG_DIR +"overlay.png)";
126
127  if(GB_overlay_click_close)
128    GB_OVERLAY.onclick = GB_hide;
129
130  AJS.getBody().insertBefore(GB_OVERLAY, AJS.getBody().firstChild);
131
132  //Create the window
133  GB_WINDOW = AJS.DIV({'id': 'GB_window'});
134
135  GB_HEADER = AJS.DIV({'id': 'GB_header'});
136  GB_caption = AJS.DIV({'id': 'GB_caption'}, "");
137
138  var close = AJS.DIV({'id': 'GB_close'}, AJS.IMG({'src': GB_IMG_DIR + 'close.gif', 'alt': 'Close window'}));
139  close.onclick = GB_hide;
140  AJS.appendChildNodes(GB_HEADER, close, GB_caption);
141
142  AJS.getBody().insertBefore(GB_WINDOW, GB_OVERLAY.nextSibling);
143  AJS.getBody().insertBefore(GB_HEADER, GB_OVERLAY.nextSibling);
144
145}
146
147function initIfNeeded() {
148  if(GB_OVERLAY == null) {
149    GB_init();
150    GB_addOnWinResize(GB_setWidth);
151    window.onscroll = function() { GB_setPosition(); GB_setWidth(); };
152  } 
153  //Remove the old iFrame
154  var new_frame = AJS.IFRAME({'id': 'GB_frame', 'name': 'GB_frame'});
155  if (GB_IFRAME != null)
156    AJS.removeElement(GB_IFRAME);
157  AJS.appendChildNodes(GB_WINDOW, new_frame);
158  GB_IFRAME = new_frame;
159}
160
161function GB_getWindowSize(){
162	var window_width, window_height;
163	if (self.innerHeight) {	// all except Explorer
164		window_width = self.innerWidth;
165		window_height = self.innerHeight;
166	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
167		window_width = document.documentElement.clientWidth;
168		window_height = document.documentElement.clientHeight;
169	} else if (document.body) { // other Explorers
170		window_width = document.body.clientWidth;
171		window_height = document.body.clientHeight;
172	}	
173	return [window_width, window_height];
174}
175
176function GB_addOnWinResize(func) {
177  var oldonrezise = window.onresize;
178  if (typeof window.onresize != 'function')
179    window.onresize = func;
180  else {
181    window.onresize = function() {
182      oldonrezise();
183      func();
184    }
185  }
186}
187
188function positionRightVertically(elm, value) {
189  elm.style.top = getScrollTop()+value+"px";
190}
191
192function getScrollTop() {
193  //From: http://www.quirksmode.org/js/doctypes.html
194  var theTop;
195  if (document.documentElement && document.documentElement.scrollTop)
196      theTop = document.documentElement.scrollTop;
197  else if (document.body)
198      theTop = document.body.scrollTop;
199  return theTop;
200}

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.