[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-groups/js/ -> widget-groups.js (source)

   1  jQuery(document).ready( function() {
   2      groups_widget_click_handler();
   3  
   4      // WP 4.5 - Customizer selective refresh support.
   5      if ( 'undefined' !== typeof wp && wp.customize && wp.customize.selectiveRefresh ) {
   6          wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function() {
   7              groups_widget_click_handler();
   8          } );
   9      }
  10  });
  11  
  12  function groups_widget_click_handler() {
  13      jQuery('.widget div#groups-list-options a').on('click',
  14          function() {
  15              var link = this;
  16              jQuery(link).addClass('loading');
  17  
  18              jQuery('.widget div#groups-list-options a').removeClass('selected');
  19              jQuery(this).addClass('selected');
  20  
  21              jQuery.post( ajaxurl, {
  22                  action: 'widget_groups_list',
  23                  'cookie': encodeURIComponent(document.cookie),
  24                  '_wpnonce': jQuery('input#_wpnonce-groups').val(),
  25                  'max_groups': jQuery('input#groups_widget_max').val(),
  26                  'filter': jQuery(this).attr('id')
  27              },
  28              function(response)
  29              {
  30                  jQuery(link).removeClass('loading');
  31                  groups_widget_response(response);
  32              });
  33  
  34              return false;
  35          }
  36      );
  37  }
  38  
  39  function groups_widget_response(response) {
  40      response = response.substr(0, response.length-1);
  41      response = response.split('[[SPLIT]]');
  42  
  43      if ( response[0] !== '-1' ) {
  44          jQuery('.widget ul#groups-list').fadeOut(200,
  45              function() {
  46                  jQuery('.widget ul#groups-list').html(response[1]);
  47                  jQuery('.widget ul#groups-list').fadeIn(200);
  48              }
  49          );
  50  
  51      } else {
  52          jQuery('.widget ul#groups-list').fadeOut(200,
  53              function() {
  54                  var message = '<p>' + response[1] + '</p>';
  55                  jQuery('.widget ul#groups-list').html(message);
  56                  jQuery('.widget ul#groups-list').fadeIn(200);
  57              }
  58          );
  59      }
  60  }


Generated: Sun Dec 22 01:00:54 2024 Cross-referenced by PHPXref 0.7.1