/administrator/components/com_easysocial/themes/default/groups/default.js

https://gitlab.com/vnsoftdev/swc · JavaScript · 118 lines · 92 code · 24 blank · 2 comment · 14 complexity · 3cda722737bd37b2c2306415a463f523 MD5 · raw file

  1. EasySocial.require()
  2. .script( 'admin/grid/grid' )
  3. .done(function($){
  4. // Implement grid item.
  5. $( '[data-table-grid]' ).implement( EasySocial.Controller.Grid );
  6. <?php if( $this->tmpl != 'component' ){ ?>
  7. $.Joomla('submitbutton', function(task) {
  8. var selected = new Array;
  9. $('[data-table-grid]').find('input[name=cid\\[\\]]:checked').each(function(i, el) {
  10. var val = $(el).val();
  11. selected.push(val);
  12. });
  13. if (task == 'makeFeatured' || task == 'removeFeatured') {
  14. $('[data-table-grid-task]').val(task);
  15. $('[data-table-grid]').submit();
  16. return false;
  17. }
  18. if (task == 'create') {
  19. EasySocial.dialog({
  20. content : EasySocial.ajax( 'admin/views/groups/createDialog' , {} ),
  21. bindings :
  22. {
  23. "{continueButton} click" : function()
  24. {
  25. var categoryId = this.category().val();
  26. window.location.href = '<?php echo rtrim( JURI::root() , '/' );?>/administrator/index.php?option=com_easysocial&view=groups&layout=form&category_id=' + categoryId;
  27. return false;
  28. }
  29. }
  30. });
  31. return false;
  32. }
  33. if( task == 'switchOwner' )
  34. {
  35. EasySocial.dialog(
  36. {
  37. content : EasySocial.ajax( 'admin/views/groups/switchOwner' , { "ids" : selected } )
  38. });
  39. return false;
  40. }
  41. if( task == 'delete' )
  42. {
  43. EasySocial.dialog(
  44. {
  45. content : EasySocial.ajax( 'admin/views/groups/deleteConfirmation' , {} ),
  46. bindings :
  47. {
  48. "{deleteButton} click" : function()
  49. {
  50. $.Joomla( 'submitform' , [task] );
  51. }
  52. }
  53. })
  54. return false;
  55. }
  56. if (task === 'switchCategory') {
  57. EasySocial.dialog({
  58. content: EasySocial.ajax('admin/views/groups/switchCategory', {
  59. ids: selected
  60. })
  61. });
  62. return false;
  63. }
  64. $.Joomal( 'submitform' , [task] );
  65. });
  66. window.switchOwner = function( user , groupIds )
  67. {
  68. EasySocial.dialog(
  69. {
  70. content : EasySocial.ajax( 'admin/views/groups/confirmSwitchOwner' , { "id" : groupIds , "userId" : user.id} ),
  71. bindings :
  72. {
  73. }
  74. });
  75. }
  76. <?php } else { ?>
  77. $( '[data-group-insert]' ).on('click', function( event )
  78. {
  79. event.preventDefault();
  80. // Supply all the necessary info to the caller
  81. var id = $( this ).data( 'id' ),
  82. avatar = $( this ).data( 'avatar' ),
  83. title = $( this ).data( 'title' ),
  84. alias = $(this).data( 'alias' );
  85. obj = {
  86. "id" : id,
  87. "title" : title,
  88. "avatar" : avatar,
  89. "alias" : alias
  90. };
  91. window.parent["<?php echo JRequest::getCmd( 'jscallback' );?>" ]( obj );
  92. });
  93. <?php } ?>
  94. });