Skip to content

Commit e24042b

Browse files
author
danh
committed
Added AJAX loading box, appears after 1.5 seconds if the page has not loaded yet.
git-svn-id: http://svn.resourcespace.org/svn/resourcespace@3800 c08608d7-6e46-0410-86ca-f2a6f1370df5
1 parent 2726eb2 commit e24042b

File tree

5 files changed

+56
-5
lines changed

5 files changed

+56
-5
lines changed

Diff for: css/global.css

+25-1
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,30 @@ div.autocomplete ul li {
468468
box-shadow: 4px 5px 5px rgba(0, 0, 0, .5);
469469
}
470470

471+
#LoadingBox
472+
{
473+
position: absolute;
474+
top:300px;
475+
left: 30%;
476+
background-color:white;
477+
width:200px;padding:15px;
478+
border: 1px solid;
479+
border-radius:5px;
480+
font-size:150%;
471481

482+
-moz-border-radius: 5px;
483+
-webkit-border-radius: 5px;
484+
-webkit-box-shadow: 4px 5px 5px rgba(0, 0, 0, .2);
485+
-moz-box-shadow: 4px 5px 5px rgba(0, 0, 0, .2);
486+
box-shadow: 4px 5px 5px rgba(0, 0, 0, .2);
487+
z-index:99999;
488+
line-height:200%;
489+
color:black;
490+
display:none;
491+
}
472492

473-
493+
#LoadingBox img
494+
{
495+
float:right;
496+
vertical-align: middle;
497+
}

Diff for: gfx/interface/loading.gif

3.9 KB
Loading

Diff for: include/header.php

+4
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@
301301
?>
302302
<!--Main Part of the page-->
303303
<?php if (($pagename!="login") && ($pagename!="user_password") && ($pagename!="user_request")) { ?><div id="CentralSpaceContainer"><?php } ?>
304+
305+
<!-- Loading graphic -->
306+
<div id="LoadingBox"><?php echo $lang["pleasewait"] ?><img src="<?php echo $baseurl_short ?>/gfx/interface/loading.gif"></div>
307+
304308
<div id="<?php echo $div?>">
305309

306310

Diff for: lib/js/global.js

+26
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ function SetCookie (cookieName,cookieValue,nDays)
1414
/* Keep a global array of timers */
1515
var timers = new Array();
1616

17+
function ClearTimers()
18+
{
19+
// Remove all existing page timers.
20+
for (var i = 0; i < timers.length; i++)
21+
{
22+
clearTimeout(timers[i]);
23+
}
24+
}
25+
1726
/* AJAX loading of central space contents given a link */
1827
function CentralSpaceLoad (anchor,scrolltop)
1928
{
@@ -58,9 +67,12 @@ function CentralSpaceLoad (anchor,scrolltop)
5867
url += '?ajax=true';
5968
}
6069

70+
CentralSpaceShowLoading();
6171
jQuery('#CentralSpace').load(url, function ()
6272
{
6373
// Load completed
74+
CentralSpaceHideLoading();
75+
6476
if (rewriteUrls){
6577
relToAbs("#CentralSpace",url);
6678
}
@@ -102,8 +114,11 @@ function CentralSpacePost (form,scrolltop)
102114
{
103115
url += '?ajax=true';
104116
}
117+
118+
CentralSpaceShowLoading();
105119
jQuery.post(url,jQuery(form).serialize(),function(data)
106120
{
121+
CentralSpaceHideLoading();
107122
jQuery('#CentralSpace').html(data);
108123
if (rewriteUrls){relToAbs("#CentralSpace",url);}
109124

@@ -122,7 +137,18 @@ function CentralSpacePost (form,scrolltop)
122137
}
123138

124139

140+
function CentralSpaceShowLoading()
141+
{
142+
ClearTimers();
143+
timers.push(window.setTimeout("jQuery('#CentralSpace').fadeTo('fast',0.7);jQuery('#LoadingBox').fadeIn('fast');",1500));
144+
}
125145

146+
function CentralSpaceHideLoading()
147+
{
148+
ClearTimers();
149+
jQuery('#LoadingBox').fadeOut('fast');
150+
jQuery('#CentralSpace').css({opacity:1});
151+
}
126152

127153

128154

Diff for: pages/home.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,7 @@ function nextPhoto()
101101
jQuery(document).ready( function ()
102102
{
103103
/* Clear all old timers */
104-
for (var i = 0; i < timers.length; i++)
105-
{
106-
clearTimeout(timers[i]);
107-
}
104+
ClearTimers();
108105
timers.push(window.setTimeout("nextPhoto()", 1000 * photo_delay));
109106
}
110107
);

0 commit comments

Comments
 (0)