root/afridex/plugins/Flutter/js/greybox/gb_scripts.js @ 21

Revision 21, 11.6 kB (checked in by admin, 18 years ago)
Line 
1var GB_CURRENT=null;
2GB_hide=function(cb){
3GB_CURRENT.hide(cb);
4};
5GreyBox=new AJS.Class({init:function(_2){
6this.use_fx=AJS.fx;
7this.type="page";
8this.overlay_click_close=false;
9this.salt=0;
10this.root_dir=GB_ROOT_DIR;
11this.callback_fns=[];
12this.reload_on_close=false;
13this.src_loader=this.root_dir+"loader_frame.html";
14var _3=window.location.hostname.indexOf("www");
15var _4=this.src_loader.indexOf("www");
16if(_3!=-1&&_4==-1){
17this.src_loader=this.src_loader.replace("://","://www.");
18}
19if(_3==-1&&_4!=-1){
20this.src_loader=this.src_loader.replace("://www.","://");
21}
22this.show_loading=true;
23AJS.update(this,_2);
24},addCallback:function(fn){
25if(fn){
26this.callback_fns.push(fn);
27}
28},show:function(_6){
29GB_CURRENT=this;
30this.url=_6;
31var _7=[AJS.$bytc("object"),AJS.$bytc("select")];
32AJS.map(AJS.flattenList(_7),function(_8){
33_8.style.visibility="hidden";
34});
35this.createElements();
36return false;
37},hide:function(cb){
38var me=this;
39AJS.callLater(function(){
40var _b=me.callback_fns;
41if(_b!=[]){
42AJS.map(_b,function(fn){
43fn();
44});
45}
46me.onHide();
47if(me.use_fx){
48var _d=me.overlay;
49AJS.fx.fadeOut(me.overlay,{onComplete:function(){
50AJS.removeElement(_d);
51_d=null;
52},duration:300});
53AJS.removeElement(me.g_window);
54}else{
55AJS.removeElement(me.g_window,me.overlay);
56}
57me.removeFrame();
58AJS.REV(window,"scroll",_GB_setOverlayDimension);
59AJS.REV(window,"resize",_GB_update);
60var _e=[AJS.$bytc("object"),AJS.$bytc("select")];
61AJS.map(AJS.flattenList(_e),function(_f){
62_f.style.visibility="visible";
63});
64GB_CURRENT=null;
65if(me.reload_on_close){
66window.location.reload();
67}
68if(AJS.isFunction(cb)){
69cb();
70}
71},10);
72},update:function(){
73this.setOverlayDimension();
74this.setFrameSize();
75this.setWindowPosition();
76},createElements:function(){
77this.initOverlay();
78this.g_window=AJS.DIV({"id":"GB_window"});
79AJS.hideElement(this.g_window);
80AJS.getBody().insertBefore(this.g_window,this.overlay.nextSibling);
81this.initFrame();
82this.initHook();
83this.update();
84var me=this;
85if(this.use_fx){
86AJS.fx.fadeIn(this.overlay,{duration:300,to:0.7,onComplete:function(){
87me.onShow();
88AJS.showElement(me.g_window);
89me.startLoading();
90}});
91}else{
92AJS.setOpacity(this.overlay,0.7);
93AJS.showElement(this.g_window);
94this.onShow();
95this.startLoading();
96}
97AJS.AEV(window,"scroll",_GB_setOverlayDimension);
98AJS.AEV(window,"resize",_GB_update);
99},removeFrame:function(){
100try{
101AJS.removeElement(this.iframe);
102}
103catch(e){
104}
105this.iframe=null;
106},startLoading:function(){
107this.iframe.src=this.src_loader+"?s="+this.salt++;
108AJS.showElement(this.iframe);
109},setOverlayDimension:function(){
110var _11=AJS.getWindowSize();
111if(AJS.isMozilla()||AJS.isOpera()){
112AJS.setWidth(this.overlay,"100%");
113}else{
114AJS.setWidth(this.overlay,_11.w);
115}
116var _12=Math.max(AJS.getScrollTop()+_11.h,AJS.getScrollTop()+this.height);
117if(_12<AJS.getScrollTop()){
118AJS.setHeight(this.overlay,_12);
119}else{
120AJS.setHeight(this.overlay,AJS.getScrollTop()+_11.h);
121}
122},initOverlay:function(){
123this.overlay=AJS.DIV({"id":"GB_overlay"});
124if(this.overlay_click_close){
125AJS.AEV(this.overlay,"click",GB_hide);
126}
127AJS.setOpacity(this.overlay,0);
128AJS.getBody().insertBefore(this.overlay,AJS.getBody().firstChild);
129},initFrame:function(){
130if(!this.iframe){
131var d={"name":"GB_frame","class":"GB_frame","frameBorder":0};
132if(AJS.isIe()){
133d.src="javascript:false;document.write(\"\");";
134}
135this.iframe=AJS.IFRAME(d);
136this.middle_cnt=AJS.DIV({"class":"content"},this.iframe);
137this.top_cnt=AJS.DIV();
138this.bottom_cnt=AJS.DIV();
139AJS.ACN(this.g_window,this.top_cnt,this.middle_cnt,this.bottom_cnt);
140}
141},onHide:function(){
142},onShow:function(){
143},setFrameSize:function(){
144},setWindowPosition:function(){
145},initHook:function(){
146}});
147_GB_update=function(){
148if(GB_CURRENT){
149GB_CURRENT.update();
150}
151};
152_GB_setOverlayDimension=function(){
153if(GB_CURRENT){
154GB_CURRENT.setOverlayDimension();
155}
156};
157AJS.preloadImages(GB_ROOT_DIR+"indicator.gif");
158script_loaded=true;
159var GB_SETS={};
160function decoGreyboxLinks(){
161var as=AJS.$bytc("a");
162AJS.map(as,function(a){
163if(a.getAttribute("href")&&a.getAttribute("rel")){
164var rel=a.getAttribute("rel");
165if(rel.indexOf("gb_")==0){
166var _17=rel.match(/\w+/)[0];
167var _18=rel.match(/\[(.*)\]/)[1];
168var _19=0;
169var _1a={"caption":a.title||"","url":a.href};
170if(_17=="gb_pageset"||_17=="gb_imageset"){
171if(!GB_SETS[_18]){
172GB_SETS[_18]=[];
173}
174GB_SETS[_18].push(_1a);
175_19=GB_SETS[_18].length;
176}
177if(_17=="gb_pageset"){
178a.onclick=function(){
179GB_showFullScreenSet(GB_SETS[_18],_19);
180return false;
181};
182}
183if(_17=="gb_imageset"){
184a.onclick=function(){
185GB_showImageSet(GB_SETS[_18],_19);
186return false;
187};
188}
189if(_17=="gb_image"){
190a.onclick=function(){
191GB_showImage(_1a.caption,_1a.url);
192return false;
193};
194}
195if(_17=="gb_page"){
196a.onclick=function(){
197var sp=_18.split(/, ?/);
198GB_show(_1a.caption,_1a.url,parseInt(sp[1]),parseInt(sp[0]));
199return false;
200};
201}
202if(_17=="gb_page_fs"){
203a.onclick=function(){
204GB_showFullScreen(_1a.caption,_1a.url);
205return false;
206};
207}
208if(_17=="gb_page_center"){
209a.onclick=function(){
210var sp=_18.split(/, ?/);
211GB_showCenter(_1a.caption,_1a.url,parseInt(sp[1]),parseInt(sp[0]));
212return false;
213};
214}
215}
216}
217});
218}
219AJS.AEV(window,"load",decoGreyboxLinks);
220GB_showImage=function(_1d,url,_1f){
221var _20={width:300,height:300,type:"image",fullscreen:false,center_win:true,caption:_1d,callback_fn:_1f};
222var win=new GB_Gallery(_20);
223return win.show(url);
224};
225GB_showPage=function(_22,url,_24){
226var _25={type:"page",caption:_22,callback_fn:_24,fullscreen:true,center_win:false};
227var win=new GB_Gallery(_25);
228return win.show(url);
229};
230GB_Gallery=GreyBox.extend({init:function(_27){
231this.parent({});
232this.img_close=this.root_dir+"g_close.gif";
233AJS.update(this,_27);
234this.addCallback(this.callback_fn);
235},initHook:function(){
236AJS.addClass(this.g_window,"GB_Gallery");
237var _28=AJS.DIV({"class":"inner"});
238this.header=AJS.DIV({"class":"GB_header"},_28);
239AJS.setOpacity(this.header,0);
240AJS.getBody().insertBefore(this.header,this.overlay.nextSibling);
241var _29=AJS.TD({"id":"GB_caption","class":"caption","width":"40%"},this.caption);
242var _2a=AJS.TD({"id":"GB_middle","class":"middle","width":"20%"});
243var _2b=AJS.IMG({"src":this.img_close});
244AJS.AEV(_2b,"click",GB_hide);
245var _2c=AJS.TD({"class":"close","width":"40%"},_2b);
246var _2d=AJS.TBODY(AJS.TR(_29,_2a,_2c));
247var _2e=AJS.TABLE({"cellspacing":"0","cellpadding":0,"border":0},_2d);
248AJS.ACN(_28,_2e);
249if(this.fullscreen){
250AJS.AEV(window,"scroll",AJS.$b(this.setWindowPosition,this));
251}else{
252AJS.AEV(window,"scroll",AJS.$b(this._setHeaderPos,this));
253}
254},setFrameSize:function(){
255var _2f=this.overlay.offsetWidth;
256var _30=AJS.getWindowSize();
257if(this.fullscreen){
258this.width=_2f-40;
259this.height=_30.h-80;
260}
261AJS.setWidth(this.iframe,this.width);
262AJS.setHeight(this.iframe,this.height);
263AJS.setWidth(this.header,_2f);
264},_setHeaderPos:function(){
265AJS.setTop(this.header,AJS.getScrollTop()+10);
266},setWindowPosition:function(){
267var _31=this.overlay.offsetWidth;
268var _32=AJS.getWindowSize();
269AJS.setLeft(this.g_window,((_31-50-this.width)/2));
270var _33=AJS.getScrollTop()+55;
271if(!this.center_win){
272AJS.setTop(this.g_window,_33);
273}else{
274var fl=((_32.h-this.height)/2)+20+AJS.getScrollTop();
275if(fl<0){
276fl=0;
277}
278if(_33>fl){
279fl=_33;
280}
281AJS.setTop(this.g_window,fl);
282}
283this._setHeaderPos();
284},onHide:function(){
285AJS.removeElement(this.header);
286AJS.removeClass(this.g_window,"GB_Gallery");
287},onShow:function(){
288if(this.use_fx){
289AJS.fx.fadeIn(this.header,{to:1});
290}else{
291AJS.setOpacity(this.header,1);
292}
293}});
294AJS.preloadImages(GB_ROOT_DIR+"g_close.gif");
295GB_showFullScreenSet=function(set,_36,_37){
296var _38={type:"page",fullscreen:true,center_win:false};
297var _39=new GB_Sets(_38,set);
298_39.addCallback(_37);
299_39.showSet(_36-1);
300return false;
301};
302GB_showImageSet=function(set,_3b,_3c){
303var _3d={type:"image",fullscreen:false,center_win:true,width:300,height:300};
304var _3e=new GB_Sets(_3d,set);
305_3e.addCallback(_3c);
306_3e.showSet(_3b-1);
307return false;
308};
309GB_Sets=GB_Gallery.extend({init:function(_3f,set){
310this.parent(_3f);
311if(!this.img_next){
312this.img_next=this.root_dir+"next.gif";
313}
314if(!this.img_prev){
315this.img_prev=this.root_dir+"prev.gif";
316}
317this.current_set=set;
318},showSet:function(_41){
319this.current_index=_41;
320var _42=this.current_set[this.current_index];
321this.show(_42.url);
322this._setCaption(_42.caption);
323this.btn_prev=AJS.IMG({"class":"left",src:this.img_prev});
324this.btn_next=AJS.IMG({"class":"right",src:this.img_next});
325AJS.AEV(this.btn_prev,"click",AJS.$b(this.switchPrev,this));
326AJS.AEV(this.btn_next,"click",AJS.$b(this.switchNext,this));
327GB_STATUS=AJS.SPAN({"class":"GB_navStatus"});
328AJS.ACN(AJS.$("GB_middle"),this.btn_prev,GB_STATUS,this.btn_next);
329this.updateStatus();
330},updateStatus:function(){
331AJS.setHTML(GB_STATUS,(this.current_index+1)+" / "+this.current_set.length);
332if(this.current_index==0){
333AJS.addClass(this.btn_prev,"disabled");
334}else{
335AJS.removeClass(this.btn_prev,"disabled");
336}
337if(this.current_index==this.current_set.length-1){
338AJS.addClass(this.btn_next,"disabled");
339}else{
340AJS.removeClass(this.btn_next,"disabled");
341}
342},_setCaption:function(_43){
343AJS.setHTML(AJS.$("GB_caption"),_43);
344},updateFrame:function(){
345var _44=this.current_set[this.current_index];
346this._setCaption(_44.caption);
347this.url=_44.url;
348this.startLoading();
349},switchPrev:function(){
350if(this.current_index!=0){
351this.current_index--;
352this.updateFrame();
353this.updateStatus();
354}
355},switchNext:function(){
356if(this.current_index!=this.current_set.length-1){
357this.current_index++;
358this.updateFrame();
359this.updateStatus();
360}
361}});
362AJS.AEV(window,"load",function(){
363AJS.preloadImages(GB_ROOT_DIR+"next.gif",GB_ROOT_DIR+"prev.gif");
364});
365GB_show=function(_45,url,_47,_48,_49){
366var _4a={caption:_45,height:_47||500,width:_48||500,fullscreen:false,callback_fn:_49};
367var win=new GB_Window(_4a);
368return win.show(url);
369};
370GB_showCenter=function(_4c,url,_4e,_4f,_50){
371var _51={caption:_4c,center_win:true,height:_4e||500,width:_4f||500,fullscreen:false,callback_fn:_50};
372var win=new GB_Window(_51);
373return win.show(url);
374};
375GB_showFullScreen=function(_53,url,_55){
376var _56={caption:_53,fullscreen:true,callback_fn:_55};
377var win=new GB_Window(_56);
378return win.show(url);
379};
380GB_Window=GreyBox.extend({init:function(_58){
381this.parent({});
382this.img_header=this.root_dir+"header_bg.gif";
383this.img_close=this.root_dir+"w_close.gif";
384this.show_close_img=true;
385AJS.update(this,_58);
386this.addCallback(this.callback_fn);
387},initHook:function(){
388AJS.addClass(this.g_window,"GB_Window");
389this.header=AJS.TABLE({"class":"header"});
390this.header.style.backgroundImage="url("+this.img_header+")";
391var _59=AJS.TD({"class":"caption"},this.caption);
392var _5a=AJS.TD({"class":"close"});
393if(this.show_close_img){
394var _5b=AJS.IMG({"src":this.img_close});
395var _5c=AJS.SPAN("Close");
396var btn=AJS.DIV(_5b,_5c);
397AJS.AEV([_5b,_5c],"mouseover",function(){
398AJS.addClass(_5c,"on");
399});
400AJS.AEV([_5b,_5c],"mouseout",function(){
401AJS.removeClass(_5c,"on");
402});
403AJS.AEV([_5b,_5c],"mousedown",function(){
404AJS.addClass(_5c,"click");
405});
406AJS.AEV([_5b,_5c],"mouseup",function(){
407AJS.removeClass(_5c,"click");
408});
409AJS.AEV([_5b,_5c],"click",GB_hide);
410AJS.ACN(_5a,btn);
411}
412tbody_header=AJS.TBODY();
413AJS.ACN(tbody_header,AJS.TR(_59,_5a));
414AJS.ACN(this.header,tbody_header);
415AJS.ACN(this.top_cnt,this.header);
416if(this.fullscreen){
417AJS.AEV(window,"scroll",AJS.$b(this.setWindowPosition,this));
418}
419},setFrameSize:function(){
420if(this.fullscreen){
421var _5e=AJS.getWindowSize();
422overlay_h=_5e.h;
423this.width=Math.round(this.overlay.offsetWidth-(this.overlay.offsetWidth/100)*10);
424this.height=Math.round(overlay_h-(overlay_h/100)*10);
425}
426AJS.setWidth(this.header,this.width+6);
427AJS.setWidth(this.iframe,this.width);
428AJS.setHeight(this.iframe,this.height);
429},setWindowPosition:function(){
430var _5f=AJS.getWindowSize();
431AJS.setLeft(this.g_window,((_5f.w-this.width)/2)-13);
432if(!this.center_win){
433AJS.setTop(this.g_window,AJS.getScrollTop());
434}else{
435var fl=((_5f.h-this.height)/2)-20+AJS.getScrollTop();
436if(fl<0){
437fl=0;
438}
439AJS.setTop(this.g_window,fl);
440}
441}});
442AJS.preloadImages(GB_ROOT_DIR+"w_close.gif",GB_ROOT_DIR+"header_bg.gif");
443
444
445script_loaded=true;
Note: See TracBrowser for help on using the browser.