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

Diff of /contributions/modules/dbfmgreybox/dbfmgreybox.js

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

revision 1.2, Wed Mar 26 12:49:03 2008 UTC revision 1.3, Mon Jun 2 12:10:15 2008 UTC
# Line 1  Line 1 
1  /* Greybox Redux  /* Greybox Redux
2   * Required: http://jquery.com/   * Required: http://jquery.com/
3   * Written by: John Resig   * Written by: John Resig
4   * Based on code by: 4mir Salihefendic (http://amix.dk)   * Based on code by: 4mir Salihefendic (http://amix.dk)
5   * License: LGPL (read more in LGPL.txt)   * License: LGPL (read more in LGPL.txt)
6   */   */
7    
8  var GB_DONE = false;  var GB_DONE = false;
9  var GB_HEIGHT = 400;  var GB_HEIGHT = 400;
10  var GB_WIDTH = 400;  var GB_WIDTH = 400;
11  var GB_ANIMATION = false;  var GB_ANIMATION = false;
12  var GB_REFRESHFM = 0;          //possible values: 0 = no refresh, 1 = refresh file browser, 2 = refresh file and tree browser  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 adde allowing you to specify whether the dbFM browser should be refreshed  //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) {  function GB_show(caption, url, height, width, refreshit) {
16    var closepath;    var closepath;
17    GB_HEIGHT = height || 400;    GB_HEIGHT = height || 400;
18    GB_WIDTH = width || 400;    GB_WIDTH = width || 400;
19    GB_REFRESHFM = refreshit;    GB_REFRESHFM = refreshit;
20    if(!GB_DONE) {    if(!GB_DONE) {
21      closepath = getGreyPath() + '/close.gif';      closepath = getGreyPath() + '/close.gif';
22      $(document.body)      $(document.body)
23        .append("<div id='GB_overlay'></div><div id='GB_window'><div id='GB_caption'></div>"        .append("<div id='GB_overlay'></div><div id='GB_window'><div id='GB_caption'></div>"
24          + "<img src='" + closepath + "' alt='Close window'/></div>");          + "<img src='" + closepath + "' id='closeme' alt='Close window'/></div>");
25    
26      $("#GB_window img").click(GB_hide);      $("#GB_window img").click(GB_hide);
27      $("#GB_overlay").click(GB_hide);      $("#GB_overlay").click(GB_hide);
28      $(window).resize(GB_position);      $(window).resize(GB_position);
29      $(window).scroll(GB_position);      $(window).scroll(GB_position);
30      GB_DONE = true;      GB_DONE = true;
31    }    }
32    
33    $("#GB_frame").remove();    $("#GB_frame").remove();
34    $("#GB_window").append("<iframe id='GB_frame' src='"+url+"'></iframe>");    $("#GB_window").append("<iframe id='GB_frame' src='"+url+"'></iframe>");
35    
36    $("#GB_caption").html(caption);    $("#GB_caption").html(caption);
37    $("#GB_overlay").show();    $("#GB_overlay").show();
38    GB_position();    GB_position();
39    
40    if(GB_ANIMATION)    if(GB_ANIMATION)
41      $("#GB_window").slideDown("slow");      $("#GB_window").slideDown("slow");
42    else    else
43      $("#GB_window").show();      $("#GB_window").show();
44  }  }
45    
46  function GB_hide() {  
47  //need some code here to allow us to decide whether we're refreshing one or both lists.  function GB_hide() {
48  var retval;  //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) {    retval = dbFM.dirListObj;
52      $("#GB_window,#GB_overlay").hide();    if (retval == null) {
53    }      $("#GB_window,#GB_overlay").hide();
54      }
55    if (GB_REFRESHFM > 0) {  
56      //this is here to refresh the browser - the only difficulty here is with replication    if (GB_REFRESHFM > 0) {
57      //it takes a while for the database to be updated and we don't want to refresh until that's happened      //this is here to refresh the browser - the only difficulty here is with replication
58      //ZZZZthe delay should really be moved to the greybox config options      //it takes a while for the database to be updated and we don't want to refresh until that's happened
59      if (dowereplicate() == 'T') {      //ZZZZthe delay should really be moved to the greybox config options
60        setTimeout(refreshit(),500);      if (dowereplicate() == 'T') {
61      }        setTimeout(refreshit(),500);
62      else {      }
63        refreshit();      else {
64      }        refreshit();
65    }      }
66    else {    }
67      $("#GB_window,#GB_overlay").hide();    else {
68    }      $("#GB_window,#GB_overlay").hide();
69  }    }
70    }
71  function refreshit()  
72  {  function refreshit()
73    dbFM.dirListObj.refresh();  {
74    if (GB_REFRESHFM > 1) {    dbFM.dirListObj.refresh();
75      dbFM.dirTreeObj.fetch();    if (GB_REFRESHFM > 1) {
76    }      dbFM.dirTreeObj.fetch();
77    $("#GB_window,#GB_overlay").hide();    }
78      $("#GB_window,#GB_overlay").hide();
79    return;  
80  }    return;
81    }
82  function GB_position()  
83  {  function GB_position()
84      var de = document.documentElement;  {
85      var h = self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;      var de = document.documentElement;
86      var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;      var h = self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
87      var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;      var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
88      var dsocleft=document.all? iebody.scrollLeft : pageXOffset;      var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
89      var dsoctop=document.all? iebody.scrollTop : pageYOffset;      var dsocleft=document.all? iebody.scrollLeft : pageXOffset;
90        var dsoctop=document.all? iebody.scrollTop : pageYOffset;
91      var height = h < GB_HEIGHT ? h - 32 : GB_HEIGHT;  
92      var top = (h - height)/2 + dsoctop;      var height = h < GB_HEIGHT ? h - 32 : GB_HEIGHT;
93        var top = (h - height)/2 + dsoctop;
94      $("#GB_window").css({width:GB_WIDTH+"px",height:height+"px",  
95        left: ((w - GB_WIDTH)/2)+"px", top: top+"px" });      $("#GB_window").css({width:GB_WIDTH+"px",height:height+"px",
96      $("#GB_frame").css("height",height - 32 +"px");        left: ((w - GB_WIDTH)/2)+"px", top: top+"px" });
97      $("#GB_overlay").css({height:h, top:dsoctop + "px", width:w});      $("#GB_frame").css("height",height - 32 +"px");
98  }      $("#GB_overlay").css({height:h, top:dsoctop + "px", width:w});
99    }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.2