-
Notifications
You must be signed in to change notification settings - Fork 10
/
banFriendManage.js
297 lines (294 loc) · 9.53 KB
/
banFriendManage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
function __processArg(obj, key) {
var arg = null;
if (obj) {
arg = obj[key] || null;
delete obj[key];
}
return arg;
}
function Controller() {
function cancleBan(contactM) {
banContactsCol.remove(contactM, {
remove: false
});
drawBanFriend();
var tempContactM = Alloy.createModel("contacts");
tempContactM.save({
objectId: contactM.id,
isBlock: false
}, {
success: function() {
contactM.set({
isBlock: false
}, {
change: "false"
});
},
error: function() {
banContactsCol.add(contactM, {
add: false
});
drawBanFriend();
Alloy.Globals.alert("c_alertMsgDefault");
}
});
}
function hideFriend(contactM) {
banContactsCol.remove(contactM, {
remove: false
});
drawBanFriend();
var tempContactM = Alloy.createModel("contacts");
tempContactM.save({
objectId: contactM.id,
isHidden: true,
isBlock: false
}, {
success: function() {
contactM.set({
isHidden: true,
isBlock: false
}, {
change: "false"
});
},
error: function() {
banContactsCol.add(contactM, {
add: false
});
drawBanFriend();
Alloy.Globals.alert("c_alertMsgDefault");
}
});
}
function drawBanFriend() {
var items = [];
banContactsCol.each(function(contactM) {
var friend = contactM.getUserInfo();
items.push({
template: "rowTemplate",
profileImage: {
image: friend.imageUrl || "/images/friendlist_profile_default_img.png"
},
profileName: {
text: friend.name
},
rowRightBtnLabel: {
text: L("c_manage")
},
properties: {
itemId: contactM.id
}
});
});
$.section.setItems(items);
}
require("alloy/controllers/BaseController").apply(this, Array.prototype.slice.call(arguments));
this.__controllerPath = "setting/banFriendManage";
this.args = arguments[0] || {};
if (arguments[0]) {
{
__processArg(arguments[0], "__parentSymbol");
}
{
__processArg(arguments[0], "$model");
}
{
__processArg(arguments[0], "__itemTemplate");
}
}
var $ = this;
var exports = {};
$.__views.container = Ti.UI.createWindow({
backgroundColor: "#f7f7f7",
barColor: "#54EE92",
translucent: false,
navTintColor: "white",
titleAttributes: {
color: "white"
},
statusBarStyle: Titanium.UI.iPhone.StatusBar.LIGHT_CONTENT,
id: "container"
});
$.__views.container && $.addTopLevelView($.__views.container);
var __alloyId274 = {};
var __alloyId277 = [];
var __alloyId279 = {
type: "Ti.UI.View",
childTemplates: function() {
var __alloyId280 = [];
var __alloyId282 = {
type: "Ti.UI.View",
childTemplates: function() {
var __alloyId283 = [];
var __alloyId285 = {
type: "Ti.UI.ImageView",
bindId: "profileImage",
properties: {
preventDefaultImage: true,
height: 38,
width: 38,
borderRadius: 19,
font: {
fontFamily: "Ionicons",
fontSize: 30
},
color: "#77787f",
backgroundColor: "#bebfc3",
bindId: "profileImage"
}
};
__alloyId283.push(__alloyId285);
var __alloyId287 = {
type: "Ti.UI.ImageView",
properties: {
preventDefaultImage: true,
height: 40,
width: 40,
image: "/images/friendlist_profile_pic_outline.png"
}
};
__alloyId283.push(__alloyId287);
return __alloyId283;
}(),
properties: {
left: 0,
height: 40,
width: 40
}
};
__alloyId280.push(__alloyId282);
var __alloyId289 = {
type: "Ti.UI.Label",
bindId: "profileName",
properties: {
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
color: "#3a3a3a",
font: {
fontSize: 16,
fontWeight: "Medium"
},
textAlign: "center",
left: 13,
bindId: "profileName"
}
};
__alloyId280.push(__alloyId289);
return __alloyId280;
}(),
properties: {
layout: "horizontal",
height: Ti.UI.SIZE,
width: Ti.UI.SIZE,
left: 13
}
};
__alloyId277.push(__alloyId279);
var __alloyId291 = {
type: "Ti.UI.View",
childTemplates: function() {
var __alloyId292 = [];
var __alloyId294 = {
type: "Ti.UI.View",
childTemplates: function() {
var __alloyId295 = [];
var __alloyId297 = {
type: "Ti.UI.Label",
bindId: "rowRightBtnLabel",
properties: {
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
color: "#6C6C6C",
font: {
fontSize: "18sp"
},
textAlign: "center",
left: 6,
right: 6,
top: 3,
bottom: 3,
bindId: "rowRightBtnLabel"
}
};
__alloyId295.push(__alloyId297);
return __alloyId295;
}(),
properties: {
layout: "composite",
width: Titanium.UI.SIZE,
height: Titanium.UI.SIZE,
backgroundColor: "#D9D9D9",
borderRadius: 10,
right: 0
}
};
__alloyId292.push(__alloyId294);
return __alloyId292;
}(),
properties: {
layout: "composite",
height: Ti.UI.SIZE,
width: "55%",
right: 13
}
};
__alloyId277.push(__alloyId291);
var __alloyId276 = {
properties: {
backgroundColor: "white",
layout: "composite",
height: 56.67,
width: Ti.UI.FILL,
selectionStyle: Titanium.UI.iPhone.ListViewCellSelectionStyle.NONE,
name: "rowTemplate"
},
childTemplates: __alloyId277
};
__alloyId274["rowTemplate"] = __alloyId276;
$.__views.section = Ti.UI.createListSection({
id: "section"
});
var __alloyId299 = [];
__alloyId299.push($.__views.section);
$.__views.listView = Ti.UI.createListView({
sections: __alloyId299,
templates: __alloyId274,
id: "listView"
});
$.__views.container.add($.__views.listView);
exports.destroy = function() {};
_.extend($, $.__views);
arguments[0] || {};
$.container.title = L("sb_banFriendTitle");
Alloy.Globals.Q;
var banContactsCol;
$.getView().addEventListener("open", function() {
var allContactsCol = Alloy.Collections.instance("contacts");
var models = allContactsCol.filter(function(model) {
return model.get("User_objectId_To") && model.get("isBlock");
});
banContactsCol = Alloy.createCollection("contacts");
banContactsCol.reset(models);
drawBanFriend();
});
$.listView.addEventListener("itemclick", function(e) {
var itemId = e.itemId;
var contactM = banContactsCol.get(itemId);
var opts = {
cancleBan: 0,
ban: 1
};
opts.options = [ L("sb_cancleBanFriend"), L("sb_changeBlocktToHidden"), L("c_cancle") ];
var dialog = Ti.UI.createOptionDialog(opts);
dialog.addEventListener("click", function(e) {
if (e.index > 1) return;
e.index == e.source.cancleBan && cancleBan(contactM);
e.index == e.source.ban && hideFriend(contactM);
});
dialog.show();
});
_.extend($, exports);
}
var Alloy = require("alloy"), Backbone = Alloy.Backbone, _ = Alloy._;
module.exports = Controller;