Skip to content

Commit 3d5338a

Browse files
committed
feat(following): Added back ability to follow users
fixes #19
1 parent 99e0da6 commit 3d5338a

3 files changed

Lines changed: 58 additions & 25 deletions

File tree

less/profile-view.less

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,22 @@
128128
-ms-flex-pack: center;
129129
justify-content: center;
130130

131+
@option-offset: 30px;
132+
131133
&.profile {
132-
left: ~"calc((100% / 3) - 3px)";
134+
left: @option-offset;
133135
}
134136

137+
&.follow {
138+
left: ~"calc(((100% - 50px) / 4) + @{option-offset})";
139+
}
140+
135141
&.edit {
136-
left: ~"calc(50% - 3px)";
142+
left: ~"calc((((100% - 50px) / 4) * 2) + @{option-offset})";
137143
}
138144

139145
&.settings {
140-
left: ~"calc(((100% / 3) * 2) - 3px)";
146+
left: ~"calc((((100% - 50px) / 4) * 3) + @{option-offset})";
141147
}
142148

143149
a {
@@ -157,21 +163,33 @@
157163
z-index: 99;
158164

159165
&.profile {
160-
-webkit-transform: translate(-55px, 15px);
161-
-ms-transform: translate(-55px, 15px);
162-
transform: translate(-55px, 15px);
166+
-webkit-transform: translate(-50px, 11px);
167+
-ms-transform: translate(-50px, 11px);
168+
transform: translate(-50px, 11px);
163169
}
164170

165171
&.edit {
166-
-webkit-transform: translate(-10px, 35px);
167-
-ms-transform: translate(-10px, 35px);
168-
transform: translate(-10px, 35px);
172+
-webkit-transform: translate(5px, 35px);
173+
-ms-transform: translate(5px, 35px);
174+
transform: translate(5px, 35px);
175+
176+
/* The edit icon is slightly offset from the rest */
177+
i {
178+
margin-left: 3px;
179+
margin-top: 8px;
180+
}
169181
}
170182

183+
&.follow {
184+
-webkit-transform: translate(-27px, 35px);
185+
-ms-transform: translate(-27px, 35px);
186+
transform: translate(-27px, 35px);
187+
}
188+
171189
&.settings {
172-
-webkit-transform: translate(35px, 15px);
173-
-ms-transform: translate(35px, 15px);
174-
transform: translate(35px, 15px);
190+
-webkit-transform: translate(31px, 11px);
191+
-ms-transform: translate(31px, 11px);
192+
transform: translate(31px, 11px);
175193
}
176194

177195
a {

lib/material.js

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ $(document).ready(function() {
1717

1818
$(window).on('action:ajaxify.end', function(ev, data) {
1919
setTimeout(function(){ $('.material-load-bar').css('height', '0px'); }, 1000);
20-
20+
2121
});
2222
}
2323

@@ -42,24 +42,24 @@ $(document).ready(function() {
4242
}
4343

4444
function setupSideBar() {
45-
46-
$('body').on('click', '#menu-trigger', function(e){
45+
46+
$('body').on('click', '#menu-trigger', function(e){
4747
e.preventDefault();
4848
var x = $(this).data('trigger');
49-
49+
5050
$(x).toggleClass('toggled');
5151
$(this).toggleClass('open');
5252

53-
53+
5454
if (x == '#sidebar') {
5555
$elem = '#sidebar';
5656
$elem2 = '#menu-trigger';
57-
57+
5858
if (!$('#chat').hasClass('toggled')) {
5959
$('#header').toggleClass('sidebar-toggled');
6060
}
6161
}
62-
62+
6363
//When clicking outside
6464
if ($('#header').hasClass('sidebar-toggled')) {
6565
$(document).on('click', function (e) {
@@ -74,7 +74,7 @@ $(document).ready(function() {
7474
}
7575
});
7676

77-
77+
7878
//Get saved layout type from LocalStorage
7979
var layoutStatus = localStorage.getItem('ma-layout-status');
8080
if (layoutStatus == 1 && !config.menuInHeader) {
@@ -136,7 +136,7 @@ $(document).ready(function() {
136136
$('body').on('blur', '.form-control', function(){
137137
var p = $(this).closest('.form-group, .input-group');
138138
var i = p.find('.form-control').val();
139-
139+
140140
if (p.hasClass('fg-float')) {
141141
if (i.length == 0) {
142142
$(this).closest('.fg-line').removeClass('fg-toggled');
@@ -152,11 +152,11 @@ $(document).ready(function() {
152152
if($('.fg-float')[0]) {
153153
$('.fg-float .form-control').each(function(){
154154
var i = $(this).val();
155-
155+
156156
if (!i.length == 0) {
157157
$(this).closest('.fg-line').addClass('fg-toggled');
158158
}
159-
159+
160160
});
161161
}
162162
});
@@ -193,11 +193,25 @@ $(document).ready(function() {
193193
$('.profile-pic .close').toggleClass('open');
194194
});
195195

196+
$('body').on('click', '.profile-header-img .follow', function(e) {
197+
var type = $(this).find('i').hasClass('fa-plus') ? 'follow' : 'unfollow';
198+
199+
socket.emit('user.' + type, {uid: ajaxify.data.uid}, function(err) {
200+
if (err) {
201+
return app.alertError(err.message);
202+
}
203+
204+
app.alertSuccess('[[global:alert.' + type + ', ' + ajaxify.data.username + ']]');
205+
});
196206

197-
$('body').on('click', '#ms-menu-trigger', function(e){
207+
$(this).find('i').toggleClass('fa-plus').toggleClass('fa-heart');
208+
});
209+
210+
211+
$('body').on('click', '#ms-menu-trigger', function(e){
198212
e.preventDefault();
199213
$(this).toggleClass('open');
200214
$('.ms-menu').toggleClass('toggled');
201-
});
215+
});
202216
}
203217
});

templates/partials/account/header.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<div class="user-icon profile-header-img" style="<!-- IF picture -->background-image: url({picture}); background-size: cover; background-repeat: no-repeat; background-position: center center;<!-- ELSE -->background-color: {icon:bgColor};<!-- ENDIF picture -->"><!-- IF !picture -->{icon:text}<!-- ENDIF !picture -->
1717

1818
<div class="option profile"><a href="{config.relative_path}/user/{userslug}"><i class="fa fa-user"></i></a></div>
19+
<div class="option follow"><a><i class="fa fa-<!-- IF isFollowing -->heart<!-- ELSE -->plus<!-- ENDIF isFollowing -->"></i></a></div>
1920
<!-- IF showHidden -->
2021
<div class="option edit"><a href="{config.relative_path}/user/{userslug}/edit"><i class="fa fa-edit"></i></a></div>
2122
<div class="option settings"><a href="{config.relative_path}/user/{userslug}/settings"><i class="fa fa-gear"></i></a></div>

0 commit comments

Comments
 (0)