Browse Source

add follow button counter

main
ghost 3 years ago
parent
commit
b3d61e4e31
  1. 4
      src/application/view/common/module/menu.phtml
  2. 3
      src/bootstrap.php
  3. 3
      src/public/css/template/default/module/menu.css
  4. 4
      src/public/js/follow.js
  5. 25
      src/public/js/module/menu.js

4
src/application/view/common/module/menu.phtml

@ -3,12 +3,16 @@
<i class="bi bi-house"></i> <i class="bi bi-house"></i>
</a><a class="item" href="follow" title="<?php echo _('Follow') ?>"> </a><a class="item" href="follow" title="<?php echo _('Follow') ?>">
<i class="bi bi-person"></i> <i class="bi bi-person"></i>
<span></span>
</a><a class="item" href="#todo" title="<?php echo _('Bookmarks') ?>"> </a><a class="item" href="#todo" title="<?php echo _('Bookmarks') ?>">
<i class="bi bi-bookmarks"></i> <i class="bi bi-bookmarks"></i>
<span></span>
</a><a class="item" href="#todo" title="<?php echo _('Mentions') ?>"> </a><a class="item" href="#todo" title="<?php echo _('Mentions') ?>">
<i class="bi bi-at"></i> <i class="bi bi-at"></i>
<span></span>
</a><a class="item" href="#todo" title="<?php echo _('Messages') ?>"> </a><a class="item" href="#todo" title="<?php echo _('Messages') ?>">
<i class="bi bi-envelope"></i> <i class="bi bi-envelope"></i>
<span></span>
</a><a class="item" href="#todo" title="<?php echo _('Settings') ?>"> </a><a class="item" href="#todo" title="<?php echo _('Settings') ?>">
<i class="bi bi-gear"></i> <i class="bi bi-gear"></i>
</a> </a>

3
src/bootstrap.php

@ -76,6 +76,9 @@ if (isset($_GET['_route_'])) {
case 'api/post/get': case 'api/post/get':
require(PROJECT_DIR . '/application/controller/api/post/get.php'); require(PROJECT_DIR . '/application/controller/api/post/get.php');
break; break;
case 'api/follow/total':
require(PROJECT_DIR . '/application/controller/api/follow/total.php');
break;
case 'api/follow/get': case 'api/follow/get':
require(PROJECT_DIR . '/application/controller/api/follow/get.php'); require(PROJECT_DIR . '/application/controller/api/follow/get.php');
break; break;

3
src/public/css/template/default/module/menu.css

@ -20,5 +20,6 @@
.moduleMenu .item span { .moduleMenu .item span {
font-size: 12px; font-size: 12px;
margin: 0 8px margin: 0 8px;
display: none;
} }

4
src/public/js/follow.js

@ -4,4 +4,8 @@ $(document).ready(function() {
ModuleMenu.init('follow'); ModuleMenu.init('follow');
ModuleFollowing.load('#moduleFollowing', true); ModuleFollowing.load('#moduleFollowing', true);
// Event listeners
$(document).on('ModuleFollowing.unFollow:success', function(/*event, response*/) {
ModuleMenu.init('follow');
});
}); });

25
src/public/js/module/menu.js

@ -1,5 +1,30 @@
var ModuleMenu = { var ModuleMenu = {
init: function(href) { init: function(href) {
$('#moduleMenu a[href="' + href + '"]').addClass('active'); $('#moduleMenu a[href="' + href + '"]').addClass('active');
ModuleMenu.updateFollowTotal();
},
updateFollowTotal: function() {
$.ajax({
url: 'api/follow/total',
type: 'POST',
success: function (response) {
if (response.success) {
if (response.total) {
$('#moduleMenu a[href=follow] span').html(response.total).show();
}
} else {
alert(response.message);
}
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
});
} }
} }
Loading…
Cancel
Save