@@ -10,7 +10,10 @@ $(document).ready(function() {
10
10
$ ( 'div.genericCommunities' ) . show ( ) ;
11
11
$ ( 'div.genericStats' ) . show ( ) ;
12
12
$ ( 'div.viewInfo' ) . hide ( ) ;
13
+ $ ( 'div.memberSelection' ) . hide ( ) ;
14
+ $ ( 'div.groupUsersSelection' ) . hide ( ) ;
13
15
$ ( 'div.viewAction' ) . hide ( ) ;
16
+ $ ( 'td.tdUser input' ) . removeAttr ( 'checked' ) ;
14
17
}
15
18
} ) ;
16
19
$ ( "#tabsGeneric" ) . show ( ) ;
@@ -50,10 +53,10 @@ $(document).ready(function() {
50
53
{
51
54
"sScrollY" : "100px" ,
52
55
"bScrollCollapse" : true ,
53
- "bPaginate" : false ,
56
+ "bPaginate" : true ,
54
57
"bLengthChange" : false ,
55
58
"bFilter" : false ,
56
- "bSort" : false ,
59
+ "bSort" : true ,
57
60
"bInfo" : false ,
58
61
"bAutoWidth" : true ,
59
62
"oLanguage" : {
@@ -75,7 +78,7 @@ $(document).ready(function() {
75
78
$ ( "table#browseTable" ) . show ( ) ;
76
79
77
80
initDragAndDrop ( ) ;
78
-
81
+ $ ( 'td.tdUser input' ) . removeAttr ( 'checked' ) ;
79
82
} ) ;
80
83
81
84
@@ -183,6 +186,8 @@ function init()
183
186
184
187
$ ( 'a#createGroupLink' ) . click ( function ( )
185
188
{
189
+ $ ( 'div.groupUsersSelection' ) . hide ( ) ;
190
+ $ ( 'td.tdUser input' ) . removeAttr ( 'checked' ) ;
186
191
$ ( 'div.MainDialogContent' ) . html ( '' ) ;
187
192
$ ( 'div.MainDialogContent' ) . html ( '' ) ;
188
193
$ ( 'div#createGroupFrom' ) . find ( 'input[name=groupId]' ) . val ( '0' ) ;
@@ -211,13 +216,8 @@ function init()
211
216
$ ( 'div.groupList' ) . hide ( ) ;
212
217
var id = $ ( this ) . attr ( 'groupid' ) ;
213
218
$ ( 'div#groupList_' + id ) . show ( ) ;
214
- $ ( 'div#memberList td.tdUser' ) . show ( ) ;
215
- $ ( 'td.tdUser input' ) . attr ( 'checked' , '' ) ;
219
+ $ ( 'td.tdUser input' ) . removeAttr ( 'checked' ) ;
216
220
groupSelected = id ;
217
- $ ( 'div#groupList_' + id + ' input' ) . each ( function ( )
218
- {
219
- $ ( 'div#memberList td.userid_' + $ ( this ) . attr ( 'userid' ) ) . hide ( ) ;
220
- } ) ;
221
221
} ) ;
222
222
223
223
$ ( 'td.tdUser input' ) . click ( function ( )
@@ -278,26 +278,23 @@ var memberSelected=new Array();
278
278
function initCheckboxSelection ( )
279
279
{
280
280
$ ( 'td#userGroupSelected' ) . html ( '' ) ;
281
- $ ( 'td#userMemberSelected' ) . html ( '' ) ;
281
+ $ ( '.memberSelection' ) . hide ( ) ;
282
+ $ ( '.groupUsersSelection' ) . hide ( ) ;
282
283
groupUsersSelected = new Array ( ) ;
283
284
memberSelected = new Array ( ) ;
284
285
$ ( 'div.groupMemberList input:checked' ) . each ( function ( )
285
286
{
286
287
groupUsersSelected . push ( $ ( this ) . attr ( 'userid' ) ) ;
288
+ $ ( '.groupUsersSelection' ) . show ( ) ;
287
289
} ) ;
288
290
$ ( 'div.communityMemberList input:checked' ) . each ( function ( )
289
291
{
290
292
memberSelected . push ( $ ( this ) . attr ( 'userid' ) ) ;
293
+ $ ( '.memberSelection' ) . show ( ) ;
291
294
} ) ;
292
- if ( groupUsersSelected . length > 0 )
293
- {
294
- $ ( 'td#userGroupSelected' ) . html ( groupUsersSelected . length + ' user(s) selected<br/><a href="javascript:;" id="removeUserLink">Remove users From Group</a>' ) ;
295
- }
296
- if ( memberSelected . length > 0 )
297
- {
298
- $ ( 'td#userMemberSelected' ) . html ( memberSelected . length + ' user(s) selected<br/><a href="javascript:;" id="addUserLink">Add users to Group</a>' ) ;
299
- }
300
- $ ( 'a#removeUserLink' ) . click ( function ( )
295
+
296
+
297
+ $ ( 'a.removeUserLink' ) . click ( function ( )
301
298
{
302
299
var users = '' ;
303
300
$ . each ( groupUsersSelected , function ( i , v ) {
@@ -314,16 +311,40 @@ function initCheckboxSelection()
314
311
if ( jsonResponse [ 0 ] )
315
312
{
316
313
createNotive ( jsonResponse [ 1 ] , 4000 ) ;
317
- $ ( 'div.groupMemberList input:checked' ) . each ( function ( )
318
- {
319
- $ ( 'div#memberList td.userid_' + $ ( this ) . attr ( 'userid' ) ) . show ( ) ;
320
- $ ( this ) . parent ( 'td' ) . remove ( ) ;
321
- init ( )
322
- } ) ;
323
- $ ( 'td#userGroupSelected' ) . html ( '' ) ;
324
- $ ( 'td#userMemberSelected' ) . html ( '' ) ;
325
- $ ( 'td.tdUser input' ) . attr ( 'checked' , '' ) ;
326
- init ( ) ;
314
+ window . location . replace ( json . global . webroot + '/community/manage?communityId=' + json . community [ 'community_id' ] + '#tabs-2' ) ;
315
+ window . location . reload ( ) ;
316
+ }
317
+ else
318
+ {
319
+ createNotive ( jsonResponse [ 1 ] , 4000 ) ;
320
+ }
321
+ } ) ;
322
+
323
+ } ) ;
324
+
325
+ $ ( 'a.removeFromCommunity' ) . click ( function ( )
326
+ {
327
+ var users = '' ;
328
+ $ . each ( memberSelected , function ( i , v ) {
329
+ if ( $ ( 'div#memberList input[admin=false][userid=' + v + ']' ) . length > 0 )
330
+ {
331
+ users += v + '-' ;
332
+ }
333
+
334
+ } ) ;
335
+ $ . post ( json . global . webroot + '/community/manage' , { communityId : json . community . community_id , removeUser : 'true' , groupId :json . community . memberGroup . group_id , users :users } ,
336
+ function ( data ) {
337
+ jsonResponse = jQuery . parseJSON ( data ) ;
338
+ if ( jsonResponse == null )
339
+ {
340
+ createNotive ( 'Error' , 4000 ) ;
341
+ return ;
342
+ }
343
+ if ( jsonResponse [ 0 ] )
344
+ {
345
+ createNotive ( jsonResponse [ 1 ] , 4000 ) ;
346
+ window . location . replace ( json . global . webroot + '/community/manage?communityId=' + json . community [ 'community_id' ] + '#tabs-2' ) ;
347
+ window . location . reload ( ) ;
327
348
}
328
349
else
329
350
{
@@ -333,13 +354,41 @@ function initCheckboxSelection()
333
354
334
355
} ) ;
335
356
336
- $ ( 'a#addUserLink' ) . click ( function ( )
357
+ $ ( 'a.addUserLink' ) . click ( function ( )
358
+ {
359
+ var users = '' ;
360
+ $ . each ( memberSelected , function ( i , v ) {
361
+ users += v + '-' ;
362
+ } ) ;
363
+ $ . post ( json . global . webroot + '/community/manage' , { communityId : json . community . community_id , addUser : 'true' , groupId :$ ( this ) . attr ( 'element' ) , users :users } ,
364
+ function ( data ) {
365
+ jsonResponse = jQuery . parseJSON ( data ) ;
366
+ if ( jsonResponse == null )
367
+ {
368
+ createNotive ( 'Error' , 4000 ) ;
369
+ return ;
370
+ }
371
+ if ( jsonResponse [ 0 ] )
372
+ {
373
+ createNotive ( jsonResponse [ 1 ] , 4000 ) ;
374
+ window . location . replace ( json . global . webroot + '/community/manage?communityId=' + json . community [ 'community_id' ] + '#tabs-2' ) ;
375
+ window . location . reload ( ) ;
376
+ }
377
+ else
378
+ {
379
+ createNotive ( jsonResponse [ 1 ] , 4000 ) ;
380
+ }
381
+ } ) ;
382
+ $ ( this ) . remove ( ) ;
383
+ } ) ;
384
+
385
+ $ ( 'a.addModeratorLink' ) . click ( function ( )
337
386
{
338
387
var users = '' ;
339
388
$ . each ( memberSelected , function ( i , v ) {
340
389
users += v + '-' ;
341
390
} ) ;
342
- $ . post ( json . global . webroot + '/community/manage' , { communityId : json . community . community_id , addUser : 'true' , groupId :groupSelected , users :users } ,
391
+ $ . post ( json . global . webroot + '/community/manage' , { communityId : json . community . community_id , addUser : 'true' , groupId :json . community . moderatorGroup . group_id , users :users } ,
343
392
function ( data ) {
344
393
jsonResponse = jQuery . parseJSON ( data ) ;
345
394
if ( jsonResponse == null )
@@ -350,27 +399,15 @@ function initCheckboxSelection()
350
399
if ( jsonResponse [ 0 ] )
351
400
{
352
401
createNotive ( jsonResponse [ 1 ] , 4000 ) ;
353
- $ ( 'div.communityMemberList input:checked' ) . each ( function ( )
354
- {
355
- datatable [ groupSelected ] . fnAddData ( [
356
- $ ( this ) . parent ( 'td' ) . html ( ) + '<span id="newRow"/>' ,
357
- ] ) ;
358
- $ ( 'span#newRow' ) . parent ( 'td' ) . addClass ( 'tdUser' ) ;
359
- $ ( 'span#newRow' ) . parent ( 'td' ) . addClass ( 'userid_' + $ ( this ) . attr ( 'userid' ) ) ;
360
- $ ( 'span#newRow' ) . remove ( ) ;
361
- $ ( this ) . parent ( 'td' ) . hide ( ) ;
362
- init ( )
363
- } ) ;
364
- $ ( 'td.tdUser input' ) . attr ( 'checked' , '' ) ;
365
- $ ( 'td#userGroupSelected' ) . html ( '' ) ;
366
- $ ( 'td#userMemberSelected' ) . html ( '' ) ;
367
- init ( ) ;
402
+ window . location . replace ( json . global . webroot + '/community/manage?communityId=' + json . community [ 'community_id' ] + '#tabs-2' ) ;
403
+ window . location . reload ( ) ;
368
404
}
369
405
else
370
406
{
371
407
createNotive ( jsonResponse [ 1 ] , 4000 ) ;
372
408
}
373
409
} ) ;
410
+ $ ( this ) . remove ( ) ;
374
411
} ) ;
375
412
}
376
413
function validateGroupChange ( formData , jqForm , options ) {
0 commit comments