7 GreyBox = new AJS.Class({
8 init: function(options) {
11 this.overlay_click_close = false;
13 this.root_dir = GB_ROOT_DIR;
14 this.callback_fns = [];
15 this.reload_on_close = false;
16 this.src_loader = this.root_dir + 'loader_frame.html';
19 var h_www = window.location.hostname.indexOf('www');
20 var src_www = this.src_loader.indexOf('www');
21 if(h_www != -1 && src_www == -1)
22 this.src_loader = this.src_loader.replace('://', '://www.');
24 if(h_www == -1 && src_www != -1)
25 this.src_loader = this.src_loader.replace('://www.', '://');
27 this.show_loading = true;
28 AJS.update(this, options);
31 addCallback: function(fn) {
32 if(fn) this.callback_fns.push(fn);
39 var elms = [AJS.$bytc("object"), AJS.$bytc("select")];
40 AJS.map(AJS.flattenList(elms), function(elm) {
41 elm.style.visibility = "hidden";
44 this.createElements();
49 var c_bs = this.callback_fns;
51 AJS.map(c_bs, function(fn) {
58 var elm = this.overlay;
59 AJS.fx.fadeOut(this.overlay, {
60 onComplete: function() {
61 AJS.removeElement(elm);
66 AJS.removeElement(this.g_window);
69 AJS.removeElement(this.g_window, this.overlay);
74 AJS.REV(window, "scroll", _GB_setOverlayDimension);
75 AJS.REV(window, "resize", _GB_update);
77 var elms = [AJS.$bytc("object"), AJS.$bytc("select")];
78 AJS.map(AJS.flattenList(elms), function(elm) {
79 elm.style.visibility = "visible";
84 if(this.reload_on_close)
85 window.location.reload();
89 this.setOverlayDimension();
91 this.setWindowPosition();
94 createElements: function() {
97 this.g_window = AJS.DIV({'id': 'GB_window'});
98 AJS.hideElement(this.g_window);
99 AJS.getBody().insertBefore(this.g_window, this.overlay.nextSibling);
107 AJS.fx.fadeIn(this.overlay, {
110 onComplete: function() {
112 AJS.showElement(me.g_window);
118 AJS.setOpacity(this.overlay, 0.7);
119 AJS.showElement(this.g_window);
124 AJS.AEV(window, "scroll", _GB_setOverlayDimension);
125 AJS.AEV(window, "resize", _GB_update);
128 removeFrame: function() {
129 try{ AJS.removeElement(this.iframe); }
135 startLoading: function() {
136 this.iframe.src = this.src_loader + '?s='+this.salt++;
137 AJS.showElement(this.iframe);
140 setOverlayDimension: function() {
141 var page_size = AJS.getWindowSize();
142 if(AJS.isMozilla() || AJS.isOpera())
143 AJS.setWidth(this.overlay, "100%");
145 AJS.setWidth(this.overlay, page_size.w);
147 var max_height = Math.max(AJS.getScrollTop()+page_size.h, AJS.getScrollTop()+this.height);
149 if(max_height < AJS.getScrollTop())
150 AJS.setHeight(this.overlay, max_height);
152 AJS.setHeight(this.overlay, AJS.getScrollTop()+page_size.h);
155 initOverlay: function() {
156 this.overlay = AJS.DIV({'id': 'GB_overlay'});
158 if(this.overlay_click_close)
159 AJS.AEV(this.overlay, "click", GB_hide);
161 AJS.setOpacity(this.overlay, 0);
162 AJS.getBody().insertBefore(this.overlay, AJS.getBody().firstChild);
165 initFrame: function() {
167 var d = {'name': 'GB_frame', 'class': 'GB_frame', 'frameBorder': 0};
168 this.iframe = AJS.IFRAME(d);
169 this.middle_cnt = AJS.DIV({'class': 'content'}, this.iframe);
171 this.top_cnt = AJS.DIV();
172 this.bottom_cnt = AJS.DIV();
174 AJS.ACN(this.g_window, this.top_cnt, this.middle_cnt, this.bottom_cnt);
178 /* Can be implemented */
179 onHide: function() {},
180 onShow: function() {},
181 setFrameSize: function() {},
182 setWindowPosition: function() {},
183 initHook: function() {}
187 _GB_update = function() { if(GB_CURRENT) GB_CURRENT.update(); }
188 _GB_setOverlayDimension = function() { if(GB_CURRENT) GB_CURRENT.setOverlayDimension(); }
190 AJS.preloadImages(GB_ROOT_DIR+'indicator.gif');
192 script_loaded = true;