show_users.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. $(document).ready(function() {
  2. styleRows();
  3. removeAbilityToShowSubUsersIfNone();
  4. $("tr.subusersShowHide").click(function(e){
  5. // Get UID
  6. var td = $(this).find('td.subUserShowHideTextTd');
  7. var showText = $(td).attr('showtext');
  8. var hideText = $(td).attr('hidetext');
  9. var tr = $(this);
  10. var uid = $(tr).attr('uid');
  11. if(typeof uid != typeof undefined && uid != null && uid !== false && uid != ""){
  12. if(td.hasClass('expand')){
  13. moveSubuserRowsAndShow(td, tr, uid);
  14. styleSubUserRows(td, tr, uid);
  15. td.removeClass('expand').addClass('collapse');
  16. td.html(hideText + "↑");
  17. }else if(td.hasClass('collapse')){
  18. hideSubuserRows(td, tr, uid);
  19. td.removeClass('collapse').addClass('expand');
  20. td.html(showText + "↓");
  21. }
  22. }
  23. });
  24. $('td.actions').click(function(e){
  25. e.stopPropagation();
  26. });
  27. });
  28. function moveSubuserRowsAndShow(td, tr, uid){
  29. var subuserRowsOwnedByUid = $("tr[ownedby='" + uid + "']");
  30. var subuserRow = null;
  31. if(subuserRowsOwnedByUid.length){
  32. subuserRowsOwnedByUid.each(function(e){
  33. subuserRow = $(this).detach();
  34. $(tr).after(subuserRow);
  35. $(this).removeClass('hide');
  36. });
  37. }
  38. }
  39. function hideSubuserRows(td, tr, uid){
  40. var subuserRowsOwnedByUid = $("tr[ownedby='" + uid + "']");
  41. if(subuserRowsOwnedByUid.length){
  42. $(subuserRowsOwnedByUid).addClass('hide');
  43. }
  44. }
  45. function styleRows(){
  46. $("tr:not(.subuser):odd").css('background-color', '#ededed');
  47. $("tr:not(.subuser):even").css('background-color', '#FFF');
  48. }
  49. function styleSubUserRows(){
  50. $("tr:not(.subuser)").each(function(e){
  51. var childrenSubUsers
  52. });
  53. }
  54. function styleSubUserRows(td, tr, uid){
  55. $("tr[ownedby='" + uid + "']:even").css('background-color', '#e5ffff');
  56. $("tr[ownedby='" + uid + "']:odd").css('background-color', '#dbf3ff');
  57. }
  58. function removeAbilityToShowSubUsersIfNone(){
  59. $("tr.subusersShowHide").each(function(e){
  60. var uid = $(this).attr('uid');
  61. if(typeof uid != typeof undefined && uid != null && uid !== false && uid != ""){
  62. if(!$("tr[ownedby='" + uid + "']").length){
  63. $(this).removeClass('subusersShowHide');
  64. $(this).find('td.subUserShowHideTextTd').html('');
  65. }
  66. }
  67. });
  68. }