Completed
Push — js-scrutinizing ( fe8d2d...ccc639 )
by Maxence
02:15
created

navdiv.initAnimationNewCircle   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
/*
2
 * Circles - Bring cloud-users closer together.
3
 *
4
 * This file is licensed under the Affero General Public License version 3 or
5
 * later. See the COPYING file.
6
 *
7
 * @author Maxence Lange <[email protected]>
8
 * @copyright 2017
9
 * @license GNU AGPL version 3 or any later version
10
 *
11
 * This program is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License as
13
 * published by the Free Software Foundation, either version 3 of the
14
 * License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 */
25
26
27
var navdiv = {
28
29
30
	newTypeDefinition: null,
31
	newType: null,
32
	newSubmit: null,
33
	newName: null,
34
	navigation: null,
35
	circlesList: null,
36
	emptyContent: null,
37
	mainUI: null,
38
	mainUIMembers: null,
39
	membersSearchResult: null,
40
41
	joinCircleAccept: null,
42
	joinCircleReject: null,
43
	joinCircleRequest: null,
44
	joinCircleInvite: null,
45
	joinCircle: null,
46
	leaveCircle: null,
47
	addMember: null,
48
49
50
	initElements: function () {
51
52
		navdiv.newTypeDefinition = $('#circles_new_type_definition');
53
		navdiv.newType = $('#circles_new_type');
54
		navdiv.newSubmit = $('#circles_new_submit');
55
		navdiv.newName = $('#circles_new_name');
56
		navdiv.navigation = $('#app-navigation.circles');
57
		navdiv.circlesList = $('#circles_list');
58
		navdiv.emptyContent = $('#emptycontent');
59
		navdiv.mainUI = $('#mainui');
60
		navdiv.mainUIMembers = $('#memberslist_table');
61
		navdiv.membersSearchResult = $('#members_search_result');
62
63
		navdiv.joinCircleAccept = $('#joincircle_acceptinvit');
64
		navdiv.joinCircleReject = $('#joincircle_rejectinvit');
65
		navdiv.joinCircleRequest = $('#joincircle_request');
66
		navdiv.joinCircleInvite = $('#joincircle_invit');
67
		navdiv.joinCircle = $('#joincircle');
68
		navdiv.leaveCircle = $('#leavecircle');
69
		navdiv.addMember = $('#addmember');
70
71
		this.initElementsActions();
72
	},
73
74
75
	initUI: function () {
76
		navdiv.newTypeDefinition.children('div').fadeOut(0);
77
		$('#circles_new_type_' + navdiv.newType.children('option:selected').val()).fadeIn(
78
			0);
79
80
		navdiv.newType.hide();
81
		navdiv.newSubmit.hide();
82
		navdiv.newTypeDefinition.hide();
83
84
		$('.icon-circles').css('background-image',
85
			'url(' + OC.imagePath('circles', 'colored') + ')');
0 ignored issues
show
Bug introduced by
The variable OC seems to be never declared. If this is a global, consider adding a /** global: OC */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
86
87
		navdiv.membersSearchResult.hide();
88
	},
89
90
91
	initElementsActions: function () {
92
93
		navdiv.joinCircle.on('click', function () {
94
			api.joinCircle(curr.circle, actions.joinCircleResult);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable actions seems to be never declared. If this is a global, consider adding a /** global: actions */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable curr seems to be never declared. If this is a global, consider adding a /** global: curr */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
95
		});
96
97
		navdiv.leaveCircle.on('click', function () {
98
			api.leaveCircle(curr.circle, actions.leaveCircleResult);
0 ignored issues
show
Bug introduced by
The variable actions seems to be never declared. If this is a global, consider adding a /** global: actions */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable curr seems to be never declared. If this is a global, consider adding a /** global: curr */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
99
		});
100
101
		navdiv.joinCircleAccept.on('click', function () {
102
			api.joinCircle(curr.circle, actions.joinCircleResult);
0 ignored issues
show
Bug introduced by
The variable curr seems to be never declared. If this is a global, consider adding a /** global: curr */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable actions seems to be never declared. If this is a global, consider adding a /** global: actions */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
103
		});
104
105
		navdiv.joinCircleReject.on('click', function () {
106
			api.leaveCircle(curr.circle, actions.leaveCircleResult);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable actions seems to be never declared. If this is a global, consider adding a /** global: actions */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable curr seems to be never declared. If this is a global, consider adding a /** global: curr */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
107
		});
108
109
		navdiv.addMember.on('input propertychange paste focus', function () {
110
			actions.searchMembersRequest($(this).val().trim());
0 ignored issues
show
Bug introduced by
The variable actions seems to be never declared. If this is a global, consider adding a /** global: actions */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
111
		}).blur(function () {
112
			navdiv.membersSearchResult.fadeOut(400);
113
		});
114
	},
115
116
117
	/**
118
	 *
119
	 */
120
	initAnimationNewCircle: function () {
121
122
		navdiv.newName.on('keyup', function () {
123
			actions.onEventNewCircleName();
0 ignored issues
show
Bug introduced by
The variable actions seems to be never declared. If this is a global, consider adding a /** global: actions */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
124
		});
125
126
		navdiv.newType.on('change', function () {
127
			actions.onEventNewCircleType();
0 ignored issues
show
Bug introduced by
The variable actions seems to be never declared. If this is a global, consider adding a /** global: actions */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
128
		});
129
130
		navdiv.newSubmit.on('click', function () {
131
			api.createCircle(navdiv.newType.val(), navdiv.newName.val(),
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
132
				actions.createCircleResult);
0 ignored issues
show
Bug introduced by
The variable actions seems to be never declared. If this is a global, consider adding a /** global: actions */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
133
		});
134
135
	},
136
137
138
	fillMembersSearch: function (exact, partial) {
139
		this.fillExactMembersSearch(exact);
140
		this.fillPartialMembersSearch(partial);
141
		navdiv.membersSearchResult.children().first().css('border-top-width', '0px');
142
	},
143
144
	fillExactMembersSearch: function (exact) {
145
146
		$.each(exact, function (index, value) {
147
			navdiv.membersSearchResult.append(
148
				'<div class="members_search exact" searchresult="' +
149
				value.value.shareWith + '">' + value.label + '   (' +
150
				value.value.shareWith + ')</div>');
151
		});
152
153
	},
154
155
	fillPartialMembersSearch: function (partial) {
156
		$.each(partial, function (index, value) {
157
			var currSearch = $('#addmember').val().trim();
158
			var line = value.label + '   (' + value.value.shareWith + ')';
159
			if (currSearch.length > 0) {
160
				line =
161
					line.replace(new RegExp('(' + currSearch + ')', 'gi'),
162
						'<b>$1</b>');
163
			}
164
165
			navdiv.membersSearchResult.append(
166
				'<div class="members_search" searchresult="' +
167
				value.value.shareWith +
168
				'">' + line + '</div>');
169
		});
170
171
	},
172
173
174
	displayMembers: function (members) {
175
176
		navdiv.mainUIMembers.emptyTable();
177
178
		if (members === null) {
179
			navdiv.mainUIMembers.hide(200);
180
			return;
181
		}
182
183
		navdiv.mainUIMembers.show(200);
184
		for (var i = 0; i < members.length; i++) {
185
			navdiv.mainUIMembers.append(this.generateTmplMember(members[i]));
186
		}
187
188
		if (curr.circleLevel >= 6) {
0 ignored issues
show
Bug introduced by
The variable curr seems to be never declared. If this is a global, consider adding a /** global: curr */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
189
			navdiv.mainUIMembers.children("[member-level!='9']").each(function () {
190
				$(this).children('.delete').show(0);
191
			});
192
193
			navdiv.mainUIMembers.children('.delete').on('click', function () {
194
				var member = $(this).parent().attr('member-id');
195
				api.removeMember(curr.circle, member, actions.removeMemberResult);
0 ignored issues
show
Bug introduced by
The variable curr seems to be never declared. If this is a global, consider adding a /** global: curr */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable actions seems to be never declared. If this is a global, consider adding a /** global: actions */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
196
			});
197
		}
198
199
	}
200
201
};