1 /// <reference path="lib/jquery-1.7.js" />
\r
2 /// <reference path="lib/jquery.validate.js" />
\r
3 /// <reference path="util.js" />
\r
4 /// <reference path="data.js" />
\r
5 /// <reference path="ajaxCall.js" />
\r
8 $.fn.fanButton = function (loggedIn, numberHolder) {
\r
9 this.each(function (index, item) {
\r
11 var status = parseInt(i.attr('data-status'));
\r
12 renderUserButton(status, i);
\r
14 i.on('click', function (event) {
\r
19 var status = parseInt(i.attr('data-status'));
\r
20 var targetUser = i.attr('data-target-user');
\r
21 if (status & 2) { // I am watching him
\r
22 ajaxUnfanUser(true, targetUser, function () {
\r
23 if (typeof renderUser != 'undefined') {
\r
24 globalUser.hasMyAttention = false;
\r
25 globalUser.numberOfFans--;
\r
26 globalUser.relation = globalUser.relation - 2;
\r
30 renderUserButton(status - 2, i);
\r
32 numberHolder.text(numberHolder.text().charCodeAt() - 1);
\r
38 ajaxFanUser(true, targetUser, function () {
\r
39 if (typeof renderUser != 'undefined') {
\r
40 globalUser.hasMyAttention = true;
\r
41 globalUser.numberOfFans++;
\r
42 globalUser.relation = globalUser.relation + 2;
\r
46 renderUserButton(status + 2, i);
\r
48 numberHolder.text(numberHolder.text().charCodeAt() + 1);
\r
58 function renderUserButton(status, btn) {
\r
59 btn.removeClass('HxGz');
\r
60 btn.removeClass('yjGz');
\r
61 btn.removeClass('GzW');
\r
62 btn.removeClass('MsR');
\r
63 var watching = status & 2;
\r
64 var watchingMe = status & 1;
\r
67 btn.addClass('HxGz'); // 互相关注
\r
71 btn.addClass('yjGz'); // 已关注
\r
77 btn.addClass('GzW'); // 关注我
\r
81 btn.addClass('MsR'); // 陌生人
\r
85 btn.attr('data-status', status);
\r