/[drupal]/contributions/modules/dbfmgreybox/dbfmgreybox.js
ViewVC logotype

Contents of /contributions/modules/dbfmgreybox/dbfmgreybox.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Tue Aug 25 14:36:06 2009 UTC (3 months ago) by geoffeagles
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +13 -6 lines
File MIME type: text/javascript
by Geoff - needed to update the refresh code - if you are calling a properties window from attach then you don't need to refresh the dbfm browser when you hide the greybox
1 /* Greybox Redux
2 * Required: http://jquery.com/
3 * Written by: John Resig
4 * Based on code by: 4mir Salihefendic (http://amix.dk)
5 * License: LGPL (read more in LGPL.txt)
6 */
7
8 var GB_DONE = false;
9 var GB_HEIGHT = 400;
10 var GB_WIDTH = 400;
11 var GB_ANIMATION = false;
12 var GB_REFRESHFM = 0; //possible values: 0 = no refresh, 1 = refresh file browser, 2 = refresh file and tree browser
13
14 //a new parameter has been added allowing you to specify whether the dbFM browser should be refreshed
15 function GB_show(caption, url, height, width, refreshit) {
16 var closepath;
17 GB_HEIGHT = height || 400;
18 GB_WIDTH = width || 400;
19 GB_REFRESHFM = refreshit;
20 if(!GB_DONE) {
21 closepath = getGreyPath() + '/close.gif';
22 $(document.body)
23 .append("<div id='GB_overlay'></div><div id='GB_window'><div id='GB_caption'></div>"
24 + "<img src='" + closepath + "' id='closeme' alt='Close window'/></div>");
25
26 $("#GB_window img").click(GB_hide);
27 $("#GB_overlay").click(GB_hide);
28 $(window).resize(GB_position);
29 $(window).scroll(GB_position);
30 GB_DONE = true;
31 }
32
33 $("#GB_frame").remove();
34 $("#GB_window").append("<iframe id='GB_frame' src='"+url+"'></iframe>");
35
36 $("#GB_caption").html(caption);
37 $("#GB_overlay").show();
38 GB_position();
39
40 if(GB_ANIMATION)
41 $("#GB_window").slideDown("slow");
42 else
43 $("#GB_window").show();
44 }
45
46
47 function GB_hide() {
48 //need some code here to allow us to decide whether we're refreshing one or both lists.
49 var retval;
50 retval = dbFM.dirListObj;
51 if (retval == null) {
52 $("#GB_window,#GB_overlay").hide();
53 }
54
55 if (GB_REFRESHFM > 0) {
56 //this is here to refresh the browser - the only difficulty here is with replication
57 //it takes a while for the database to be updated and we don't want to refresh until that's happened
58 //ZZZZZZZZ the delay should really be moved to the greybox config options
59 if (dowereplicate() == 'T') {
60 setTimeout(refreshit(),500);
61 }
62 else {
63 refreshit();
64 }
65 }
66 else {
67 $("#GB_window,#GB_overlay").hide();
68 }
69 }
70
71 function refreshit(){
72
73 //ok, we've got a problem here - if the greybox has been called from dbfm then we need to refresh the dbfm browser BUT
74 //the properties box may have been called from an attachment so there will be no browser to refresh...
75 try {
76 dbFM.dirListObj.refresh();
77 if (GB_REFRESHFM > 1) {
78 dbFM.dirTreeObj.fetch();
79 }
80 }
81 catch (err) {
82 //don't actually need to worry - if it couldn't do it then it doesn't matter
83 }
84 $("#GB_window,#GB_overlay").hide();
85
86 return;
87 }
88
89 function GB_position()
90 {
91 var de = document.documentElement;
92 var h = self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
93 var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
94 var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
95 var dsocleft=document.all? iebody.scrollLeft : pageXOffset;
96 var dsoctop=document.all? iebody.scrollTop : pageYOffset;
97
98 var height = h < GB_HEIGHT ? h - 32 : GB_HEIGHT;
99 var top = (h - height)/2 + dsoctop;
100
101 $("#GB_window").css({width:GB_WIDTH+"px",height:height+"px",
102 left: ((w - GB_WIDTH)/2)+"px", top: top+"px" });
103 $("#GB_frame").css("height",height - 32 +"px");
104 $("#GB_overlay").css({height:h, top:dsoctop + "px", width:w});
105 }

  ViewVC Help
Powered by ViewVC 1.1.2