Skip to content

Commit 1aff4aa

Browse files
committed
JS fade in/out for flash messages - thanks to @beaver-dev
1 parent 050a5fb commit 1aff4aa

7 files changed

Lines changed: 143 additions & 47 deletions

File tree

‎controller/admin/users.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function display()
149149
$can_action = ($can_delete || $can_ban || $can_move) && $num_users > 0;
150150

151151
$page_title = array(feather_escape($this->config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Users'], $lang_admin_users['Results head']);
152-
$page_head = array('js' => '<script type="text/javascript" src="'.get_base_url().'/include/common.js"></script>');
152+
$page_head = array('js' => '<script type="text/javascript" src="'.get_base_url().'/js/common.js"></script>');
153153

154154
define('FEATHER_ACTIVE_PAGE', 'admin');
155155

‎include/functions.php‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ function get_admin_ids()
249249
function set_default_user()
250250
{
251251
global $db, $db_type, $feather_config;
252-
252+
253253
// Get Slim current session
254254
$feather = \Slim\Slim::getInstance();
255255

@@ -258,19 +258,19 @@ function set_default_user()
258258
// Fetch guest user
259259
$select_set_default_user = array('u.*', 'g.*', 'o.logged', 'o.last_post', 'o.last_search');
260260
$where_set_default_user = array('u.id' => '1');
261-
261+
262262
$result = ORM::for_table($feather->prefix.'users')
263263
->table_alias('u')
264264
->select_many($select_set_default_user)
265265
->inner_join($feather->prefix.'groups', array('u.group_id', '=', 'g.g_id'), 'g')
266266
->left_outer_join($feather->prefix.'online', array('o.ident', '=', $remote_addr), 'o', true)
267267
->where($where_set_default_user)
268268
->find_result_set();
269-
269+
270270
if (!$result) {
271271
exit('Unable to fetch guest information. Your database must contain both a guest user and a guest user group.');
272272
}
273-
273+
274274
foreach ($result as $feather->user);
275275

276276
// Update online list
@@ -353,7 +353,7 @@ function forum_setcookie($name, $value, $expire)
353353
function check_bans()
354354
{
355355
global $db, $feather_config, $lang_common, $feather_bans;
356-
356+
357357
// Get Slim current session
358358
$feather = \Slim\Slim::getInstance();
359359

@@ -470,7 +470,7 @@ function check_username($username, $errors, $exclude_id = null)
470470
break;
471471
}
472472
}
473-
473+
474474
return $errors;
475475
}
476476

@@ -486,11 +486,11 @@ function update_users_online()
486486

487487
// Fetch all online list entries that are older than "o_timeout_online"
488488
$select_update_users_online = array('user_id', 'ident', 'logged', 'idle');
489-
489+
490490
$result = \ORM::for_table($db->prefix.'online')->select_many($select_update_users_online)
491491
->where_lt('logged', $now-$feather_config['o_timeout_online'])
492492
->find_many();
493-
493+
494494
foreach ($result as $cur_user) {
495495
// If the entry is a guest, delete it
496496
if ($cur_user['user_id'] == '1') {
@@ -608,20 +608,20 @@ function get_tracked_topics()
608608
function update_forum($forum_id)
609609
{
610610
global $db;
611-
611+
612612
$stats_query = \ORM::for_table($db->prefix.'topics')
613613
->where('forum_id', $forum_id)
614614
->select_expr('COUNT(id)', 'total_topics')
615615
->select_expr('SUM(num_replies)', 'total_replies')
616616
->find_one();
617-
617+
618618
$num_topics = intval($stats_query['total_topics']);
619619
$num_replies = intval($stats_query['total_replies']);
620620

621621
$num_posts = $num_replies + $num_topics; // $num_posts is only the sum of all replies (we have to add the topic posts)
622622

623623
$select_update_forum = array('last_post', 'last_post_id', 'last_poster');
624-
624+
625625
$result = \ORM::for_table($db->prefix.'topics')->select_many($select_update_forum)
626626
->where('forum_id', $forum_id)
627627
->where_null('moved_to')
@@ -679,7 +679,7 @@ function delete_avatar($user_id)
679679
function delete_topic($topic_id)
680680
{
681681
global $db;
682-
682+
683683
// Delete the topic and any redirect topics
684684
$where_delete_topic = array(
685685
array('id' => $topic_id),
@@ -875,7 +875,7 @@ function paginate($num_pages, $cur_page, $link, $args = null)
875875
if ($num_pages > 1 && $cur_page > 1) {
876876
$pages[] = '<a rel="prev"'.(empty($pages) ? ' class="item1"' : '').' href="'.get_sublink($link, 'page/$1', ($cur_page - 1), $args).'">'.$lang_common['Previous'].'</a>';
877877
}
878-
878+
879879
if ($cur_page > 3) {
880880
$pages[] = '<a'.(empty($pages) ? ' class="item1"' : '').' href="'.$link.'">1</a>';
881881

@@ -985,7 +985,7 @@ function message($message, $no_back_link = false, $http_status = null, $dontStop
985985
if (!is_null($http_status)) {
986986
header('HTTP/1.1 ' . $http_status);
987987
}
988-
988+
989989
// Get Slim current session
990990
$feather = \Slim\Slim::getInstance();
991991

@@ -999,7 +999,7 @@ function message($message, $no_back_link = false, $http_status = null, $dontStop
999999
require_once FEATHER_ROOT.'controller/header.php';
10001000

10011001
$feather->config('templates.path', get_path_view());
1002-
1002+
10031003
$header = new \controller\header();
10041004

10051005
$header->setTitle($page_title)->display();
@@ -1011,7 +1011,7 @@ function message($message, $no_back_link = false, $http_status = null, $dontStop
10111011
'no_back_link' => $no_back_link,
10121012
)
10131013
);
1014-
1014+
10151015
require_once FEATHER_ROOT.'controller/footer.php';
10161016

10171017
$footer = new \controller\footer();
@@ -1034,7 +1034,7 @@ function format_time($timestamp, $date_only = false, $date_format = null, $time_
10341034
if ($timestamp == '') {
10351035
return $lang_common['Never'];
10361036
}
1037-
1037+
10381038
// Get Slim current session
10391039
$feather = \Slim\Slim::getInstance();
10401040

@@ -1178,7 +1178,7 @@ function feather_hash($str)
11781178
function get_remote_address()
11791179
{
11801180
$feather = \Slim\Slim::getInstance();
1181-
1181+
11821182
$remote_addr = $feather->request->getIp();
11831183

11841184
return $remote_addr;
@@ -1749,7 +1749,7 @@ function display_saved_queries()
17491749
<?php
17501750
++$i;
17511751
}
1752-
1752+
17531753
// TODO: To be removed
17541754
foreach ($saved_queries as $cur_query) {
17551755
$query_time_total += $cur_query[1];
@@ -1783,7 +1783,7 @@ function get_path_view($file = null)
17831783
{
17841784
// Get Slim current session
17851785
$feather = \Slim\Slim::getInstance();
1786-
1786+
17871787
if ($file && is_file('style/'.$feather->user->style)) {
17881788
return FEATHER_ROOT.'style/'.$feather->user->style.'/view';
17891789
}
@@ -1805,7 +1805,7 @@ function url_friendly($str)
18051805
$str = strtr($str, $url_replace);
18061806
$str = strtolower(utf8_decode($str));
18071807
$str = feather_trim(preg_replace(array('/[^a-z0-9\s]/', '/[\s]+/'), array('', '-'), $str), '-');
1808-
1808+
18091809
if (empty($str)) {
18101810
$str = 'view';
18111811
}

‎js/common.js‎

Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,96 @@
1-
21
/**
32
* Copyright (C) 2015 FeatherBB
43
* based on code by (C) 2008-2012 FluxBB
54
* and Rickard Andersson (C) 2002-2008 PunBB
65
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
76
*/
87

9-
function select_checkboxes(curFormId, link, new_string)
10-
{
8+
function select_checkboxes(curFormId, link, new_string) {
119
var curForm = document.getElementById(curFormId);
1210
var inputlist = curForm.getElementsByTagName("input");
13-
for (i = 0; i < inputlist.length; i++)
14-
{
11+
for (i = 0; i < inputlist.length; i++) {
1512
if (inputlist[i].getAttribute("type") == 'checkbox' && inputlist[i].disabled == false)
1613
inputlist[i].checked = true;
1714
}
18-
15+
1916
link.setAttribute('onclick', 'return unselect_checkboxes(\'' + curFormId + '\', this, \'' + link.innerHTML + '\')');
2017
link.innerHTML = new_string;
2118

2219
return false;
2320
}
2421

25-
function unselect_checkboxes(curFormId, link, new_string)
26-
{
22+
function unselect_checkboxes(curFormId, link, new_string) {
2723
var curForm = document.getElementById(curFormId);
2824
var inputlist = curForm.getElementsByTagName("input");
29-
for (i = 0; i < inputlist.length; i++)
30-
{
25+
for (i = 0; i < inputlist.length; i++) {
3126
if (inputlist[i].getAttribute("type") == 'checkbox' && inputlist[i].disabled == false)
3227
inputlist[i].checked = false;
3328
}
34-
29+
3530
link.setAttribute('onclick', 'return select_checkboxes(\'' + curFormId + '\', this, \'' + link.innerHTML + '\')');
3631
link.innerHTML = new_string;
3732

3833
return false;
3934
}
35+
36+
// Display message box so that it is always visible
37+
function isElementInViewport(el) {
38+
39+
//special bonus for those using jQuery
40+
if (typeof jQuery === "function" && el instanceof jQuery) {
41+
el = el[0];
42+
}
43+
44+
var rect = el.getBoundingClientRect();
45+
46+
return (
47+
rect.top >= 0 &&
48+
rect.left >= 0 &&
49+
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */
50+
rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */
51+
);
52+
}
53+
54+
function onVisibilityChange(el, callback) {
55+
function hasClass(element, cls) {
56+
return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
57+
}
58+
return function() {
59+
// if (!isElementInViewport(el) && !hasClass(el, 'sticky')) {
60+
// el.className = 'block sticky';
61+
// } else {
62+
// el.className = 'block';
63+
// }
64+
console.log('visibility ' + isElementInViewport(el));
65+
66+
}
67+
}
68+
69+
function fadeOut(id, val) {
70+
if (isNaN(val)) {
71+
val = 9;
72+
}
73+
document.getElementById(id).style.opacity = '0.' + val;
74+
//For IE
75+
document.getElementById(id).style.filter = 'alpha(opacity=' + val + '0)';
76+
if (val > 0) {
77+
val--;
78+
setTimeout('fadeOut("' + id + '",' + val + ')', 120);
79+
} else {
80+
return;
81+
}
82+
}
83+
84+
function fadeIn(id, val) {
85+
if (isNaN(val)) { val = 0; }
86+
document.getElementById(id).style.opacity = '0.' + val;
87+
//For IE
88+
document.getElementById(id).style.filter = 'alpha(opacity=' + val + '0)';
89+
90+
if (val < 9) {
91+
val++;
92+
setTimeout('fadeIn("' + id + '",' + val + ')', 120);
93+
} else {
94+
return;
95+
}
96+
}

‎style/FeatherBB.css‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ th {
2828
}
2929
#announce,
3030
#msg,
31+
#msgflash,
3132
#posterror {
3233
text-shadow: 0 1px 0 rgba(255, 255, 255, .5)
3334
}
@@ -1238,7 +1239,24 @@ footer .footer-link a {
12381239
#viewprofile .fakeform .inform fieldset dd {
12391240
margin: 0 0 15px
12401241
}
1242+
#msgflash {
1243+
opacity: 0;
1244+
position: fixed;
1245+
top: 40px;
1246+
right: 40px;
1247+
min-width: 230px;
1248+
max-width: 400px;
1249+
}
1250+
#msgflash .close {
1251+
float: right;
1252+
position: absolute;
1253+
top: 6px;
1254+
right: 6px;
1255+
background-color: transparent;
1256+
border: none;
1257+
}
12411258
#msg,
1259+
#msgflash,
12421260
#posterror {
12431261
margin: 15px 0;
12441262
padding: 8px 35px 8px 14px;
@@ -1248,11 +1266,13 @@ footer .footer-link a {
12481266
border-radius: 4px
12491267
}
12501268
#msg h2,
1269+
#msgflash h2,
12511270
#posterror h2 {
12521271
margin: 0 0 4px;
12531272
font-size: 18px
12541273
}
12551274
#msg p,
1275+
#msgflash p,
12561276
#posterror p {
12571277
margin: 0 0 2px
12581278
}

‎style/FeatherBB/view/admin/users/find_users.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* and Rickard Andersson (C) 2002-2008 PunBB
77
* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
88
*/
9-
9+
1010
// Make sure no one attempts to run this script "directly"
1111
if (!defined('FEATHER')) {
1212
exit;
@@ -97,4 +97,4 @@
9797
<div class="clearer"></div>
9898
</div>
9999
</div>
100-
</form>
100+
</form>

0 commit comments

Comments
 (0)