/global/js/global.js
JavaScript | 1792 lines | 1302 code | 330 blank | 160 comment | 276 complexity | 2374b39fe3aa34bdc3a9e2dc6dfcfa1b MD5 | raw file
Possible License(s): AGPL-3.0
Large files files are truncated, but you can click here to view the full file
- // Cdigital Functions.js
- // functions.js
- /*var tabs = 0;
- var next_tab;*/
- jQuery(function()
- {
- /*jQuery('#header .menu a').click(function() {
- var url = jQuery(this).attr('href');
-
- jQuery(this).parent().siblings().removeClass('current_page_item');
- jQuery(this).parent().siblings().removeClass('current-menu-item');
- jQuery(this).parent().addClass('current_page_item');
-
- jQuery('#content div.middle').addClass('old').fadeOut('fast');
- jQuery('#content').addClass('loading');
-
- jQuery.ajax({
- url : url,
- success : function(response) {
- jQuery('#content div.middle.old').remove();
-
- jQuery('#content').removeClass('loading').append(jQuery(response).find('#content div.middle'));
-
- jQuery('#content div.middle').fadeIn('fast');
- }
- });
-
- return false;
- }); */
-
- //Função de expandir e retrair
- jQuery(document).ready(function(){
- jQuery('a#retrair_todos').click(function() {
- jQuery('ul.sub-menu', jQuery(this).parent()).slideUp('fast');
- jQuery('a#expandir').html("<span>+</span>");
- return false;
- });
- });
-
- jQuery(document).ready(function(){
- jQuery('a#expandir_todos').click(function() {
- jQuery('ul.sub-menu', jQuery(this).parent()).slideDown('fast');
- jQuery('a#expandir').html("<span>-</span>");
- return false;
- });
- });
-
- jQuery(document).ready(function(){
- jQuery('ul li.parent a').click(function() {
- jQuery('ul.sub-menu', jQuery(this).parent()).slideToggle('fast');
- return false;
- });
- });
-
- jQuery(document).ready(function(){
- jQuery("a#expandir").click(function() {
- var text = jQuery(this).text();
- if (text == "+") {
- jQuery(this).html("<span>-</span>");
- }
- else {
- jQuery(this).html("<span>+</span>");
- }
- });
- });
- //**********************************************************************************************
-
- //Funcionalidade de acessibilidade - Aumentar, normalizar e diminuir fonte, além de contraste
- jQuery(document).ready(function(){
- var fonte = 13;
- jQuery('#aumenta_fonte').click(function(){
- if (fonte<19){
- fonte = fonte+1;
- jQuery('body').css({'font-size' : fonte+'px'});
- }
- });
- jQuery('#normaliza_fonte').click(function(){
- fonte = 12.4167;
- jQuery('body').css({'font-size' : fonte+'px'});
- });
- jQuery('#diminui_fonte').click(function(){
- if (fonte>10){
- fonte = fonte-1;
- jQuery('body').css({'font-size' : fonte+'px'});
- }
- });
- jQuery('#habilita_contraste').click(function(){
- css = document.getElementById("contraste");
- if (css.href.search("style.css") != -1) {
- css.disable = true;
- css.href = css.href + "contraste.css";
- css.href = css.href.replace("style.css", "");
- css.disable = false;
- }
- });
- jQuery('#desabilita_contraste').click(function(){
- css = document.getElementById("contraste");
- if (css.href.search("contraste.css") != -1) {
- css.disable = true;
- css.href = css.href + "style.css";
- css.href = css.href.replace("contraste.css", "");
- css.disable = false;
- }
- });
- });
-
- // Ativa o plugin back to top
- jQuery('#top-link').topLink({
- min: 400,
- fadeSpeed: 500
- });
-
- jQuery('#top-link').click(function(e) {
- e.preventDefault();
- jQuery.scrollTo(0,300);
- });
-
- // Carrega o tamanho do texto
- var cdigital_fontSize = jQuery.cookie('cdigital_fontSize');
- var fontSize = 100;
-
- if(cdigital_fontSize)
- {
- jQuery('#content, div.navFooter').css('fontSize', cdigital_fontSize+'%');
-
- fontSize = parseInt(cdigital_fontSize);
-
- if( fontSize >= 120 ) {
- jQuery('#header div.menu').css('fontSize', '120%');
- }
- }
-
- // Carrega o layout dos diretorios
- var cdigital_directory_layout = jQuery.cookie('cdigital_directory_layout');
-
- if(cdigital_directory_layout)
- {
- if( jQuery('ul.posts').length )
- jQuery('ul.posts').removeClass('two-columns');
- }
-
- // Carrega o contraste
- var cdigital_contrast = jQuery.cookie('cdigital_contrast');
-
- if(cdigital_contrast)
- {
- jQuery('html').addClass(cdigital_contrast);
- jQuery('head').append('<link id="contrast_css" rel="stylesheet" media="screen" href="http://'+ window.location.host +'/wp-content/themes/NewCdigital/global/css/contrast.css" />');
- }
- // Carrega o jquery tabs
- jQuery('div.tabs').tabs();
- var destaque = jQuery('div.hlTabs').tabs().tabs('rotate', 12000, true);
- var totalSize = jQuery('div.hlTabs div.panel').size() -1;
- var next = 0;
- var prev = 0;
- for( $i = 0; $i <= totalSize; $i++ ) {
- prev = ($i != 0) ? $i : totalSize;
- next = ($i != totalSize) ? $i + 2 : 1;
- jQuery( jQuery('div.hlTabs div.panel')[$i] ).append('<a href="#" class="bt_prev" rel="'+ prev +'">Anterior</a>');
- jQuery( jQuery('div.hlTabs div.panel')[$i] ).append('<a href="#" class="bt_next" rel="'+ next +'">Proximo</a>');
- }
- jQuery('.bt_prev, .bt_next', 'div.hlTabs div.panel').click(function() {
- var tab = parseInt(jQuery(this).attr('rel')) - 1;
- console.debug(tab);
- destaque.tabs('select', tab);
- return false;
- });
-
- // Adiciona os bts next e prev
- /*jQuery('div.widget_destaque .bt_prev').unbind().bind('click', function() {
- tabs--;
-
- if( tabs < 0 ) {
- tabs = jQuery('div.widget_destaque div.panel').length - 1;
- }
-
- jQuery('div.hlTabs').tabs("select", tabs );
-
- return false;
- });
-
- jQuery('div.widget_destaque .bt_next').unbind().bind('click', function() {
- tabs++;
-
- if( tabs > jQuery('div.widget_destaque div.panel').length - 1 ) {
- tabs = 0;
- }
-
- jQuery('div.hlTabs').tabs("select", tabs );
- return false;
- });*/
-
- // Adciona um bullet no menu dropdown
- jQuery('div#header ul.nav li').each(function()
- {
- if(jQuery('> ul', jQuery(this)).length)
- {
- jQuery(this).addClass('dropdown');
- }
- });
-
- // Reset Value Default
- jQuery.fn.resetDefaultValue = function()
- {
- function _clearDefaultValue() {
- var _$ = jQuery(this);
- if ( _$.val() == this.defaultValue ) { _$.val(''); jQuery(this).addClass('active'); }
- };
- function _resetDefaultValue() {
- var _$ = jQuery(this);
- if ( _$.val() == '' ) { _$.val(this.defaultValue); jQuery(this).removeClass('active'); }
- };
- return this.click(_clearDefaultValue).focus(_clearDefaultValue).blur(_resetDefaultValue);
- }
-
- jQuery('div#header input:not(input.submitDefault), div.widget_login input:not(input.submitDefault), div.comments div.inputDefault *').resetDefaultValue();
-
- var formWhatsNew = (jQuery('form#whats-new-form textarea').val() === undefined ? '' : jQuery('form#whats-new-form textarea').val() );
-
- if( formWhatsNew.indexOf('O que há de novo ') != -1 ) jQuery('form#whats-new-form textarea').resetDefaultValue();
-
- // Jquery tooltip
- jQuery('.widget ul#members-list li, .widget ul#groups-list li').tooltip({
- delay: 0,
- track: true,
- showURL: false,
- bodyHandler: function() {
- var title = jQuery(this).find('div.item-title a').text();
- var membros = jQuery(this).find('div.item-meta span').text();
- return '<h3>'+ title +'</h3>' + '<p>' + membros + '</p>';
- }
- });
-
- // Ajax pagination
- jQuery('div.widget_customPosts .more').click(function()
- {
- var $this = jQuery(this);
- var url = $this.attr('href');
-
- $this.addClass('loading');
-
- jQuery('div.widget_customPosts ul').load(url + '#labblog li', function(response)
- {
- jQuery('div.widget_customPosts ul li').remove();
-
- jQuery(response).find('div.widget_customPosts ul li').appendTo('div.widget_customPosts ul');
-
- var paged = jQuery(response).find('div.widget_customPosts .more').attr('href');
-
- $this.attr('href', paged);
-
- $this.removeClass('loading');
- });
-
- return false;
- });
-
- // Widget Login Validation
- jQuery('div.widget_login .submitDefault').not('div.widget_register .submitDefault').click(function()
- {
- var $this = jQuery(this);
- var form = jQuery('div.widget_login form');
- var login = jQuery('div.widget_login div.login input').val();
- var pw = jQuery('div.widget_login div.pw input').val();
- var erro = 0;
-
- if(login == 'Nome do usuário' || !login || pw == 'Senha' || !pw)
- {
- if(!jQuery('div.widget_login div.error').length)
- {
- jQuery('div.widget_login').prepend('<div class="error" style="display:none">Preencha todos os campos!</div>');
- jQuery('div.widget_login div.error').slideDown('fast');
- }
- else
- {
- jQuery('div.widget_login div.error').remove();
- jQuery('div.widget_login').prepend('<div class="error" style="display:none">Preencha todos os campos!</div>');
- jQuery('div.widget_login div.error').slideDown('fast');
- }
-
- erro++;
- }
- else
- erro = 0;
-
- if(erro == 0)
- {
- $this.addClass('loading');
- jQuery.post(form.attr('action'), form.serialize(), function(response)
- {
- if(jQuery(response).find('div#login_error').length)
- {
- var erro = jQuery(response).find('div#login_error');
-
- if(!jQuery('div.widget_login div.error').length)
- {
- jQuery('div.widget_login').prepend('<div class="error" style="display:none">' + erro.html() + '</div>');
- jQuery('div.widget_login div.error').slideDown('fast');
- jQuery('div.widget_login div.login input').val('Nome do usuário');
- jQuery('div.widget_login div.pw input').val('Senha');
- }
- else
- {
- jQuery('div.widget_login div.error').remove();
- jQuery('div.widget_login').prepend('<div class="error" style="display:none">' + erro.html() + '</div>');
- jQuery('div.widget_login div.error').slideDown('fast');
- jQuery('div.widget_login div.login input').val('Nome do usuário');
- jQuery('div.widget_login div.pw input').val('Senha');
- }
- $this.removeClass('loading');
- }
- else
- {
- document.location.href = 'http://'+ document.location.host + '/members/' + jQuery('div.widget_login div.login input').val();
- }
- });
- }
-
- return false;
- });
-
- // Controle de fontes
- jQuery('div.acc a').click(function()
- {
- if(jQuery(this).hasClass('fontMinus'))
- {
- if( fontSize == 100 || fontSize <= 100 ) {
- return false;
- }
-
- fontSize -= 20;
-
- jQuery('#content, #footer div.navFooter').css('fontSize', fontSize + '%');
- if( fontSize == 100 ) {
- jQuery('#header div.menu').css('fontSize', '100%');
- }
-
- jQuery.cookie('cdigital_fontSize', fontSize);
- }
- if(jQuery(this).hasClass('fontPlus'))
- {
- if( fontSize == 140 || fontSize >= 140 ) {
- return false;
- }
-
- fontSize += 20;
-
- jQuery('#content, #footer div.navFooter').css('fontSize', fontSize + '%');
- jQuery('#header div.menu').css('fontSize', '120%');
- jQuery.cookie('cdigital_fontSize', fontSize);
- }
-
- return false;
- });
- // Controle de contraste
- jQuery('div#wp-admin-bar li.color a').click(function()
- {
- var $contrast = jQuery(this).attr('id');
-
- if($contrast == 'contrast')
- {
- jQuery('html').attr('class', '');
- jQuery('#contrast_css').remove();
- jQuery.cookie('cdigital_contrast', '');
-
- return false;
- }
-
- jQuery.cookie('cdigital_contrast', $contrast);
-
- jQuery('html').attr('class', '');
- jQuery('html').toggleClass($contrast);
-
- jQuery('head').append('<link id="contrast_css" rel="stylesheet" media="screen" href="http://'+ window.location.host +'/wp/wp-content/themes/NewCdigital/global/css/contrast.css" />');
-
- return false;
- });
- jQuery('div#loading').remove();
- jQuery('div#content, div.navFooter').fadeIn(300);
-
- // Controle de layout dos diretorios
- jQuery('div.layoutControl a').click(function() {
- if(jQuery(this).hasClass('one-column')) {
- jQuery('ul.posts').removeClass('two-columns');
-
- jQuery.cookie('cdigital_directory_layout', 'one-column');
- } else {
- jQuery('ul.posts').addClass('two-columns');
-
- jQuery.cookie('cdigital_directory_layout', '');
- }
-
- return false;
- });
- });
- // Buddypress functions.js
- // AJAX Functions
- var j = jQuery;
- // Global variable to prevent multiple AJAX requests
- var bp_ajax_request = null;
- j(document).ready( function() {
- /**** Page Load Actions *******************************************************/
- /* Adicionando ação para q os links customizados abram em novas abas*/
- j(".menu-item-type-custom a").attr('target','_blank');
- j("#menu-item-66 a").attr('target','_self');
- /* Hide Forums Post Form */
- if ( j('div.forums').length )
- j('div#new-topic-post').hide();
- /* Activity filter and scope set */
- bp_init_activity();
- /* Object filter and scope set. */
- var objects = [ 'members', 'groups', 'blogs', 'forums' ];
- bp_init_objects( objects );
- /* @mention Compose Scrolling */
- if ( j.query.get('r') ) {
- if ( j('textarea#whats-new').length ) {
- j.scrollTo( j('textarea#whats-new'), 500, { offset:-125, easing:'easeout' } );
- j('textarea#whats-new').focus();
- }
- }
- /* @mention username help button display */
- if ( j( 'span.highlight span' ).length )
- j( 'span.highlight span' ).toggle();
- /**** Activity Posting ********************************************************/
- /* New posts */
- j("input#aw-whats-new-submit").click( function() {
- var button = j(this);
- var form = button.parent().parent().parent().parent();
- form.children().each( function() {
- if ( j.nodeName(this, "textarea") || j.nodeName(this, "input") )
- j(this).attr( 'disabled', 'disabled' );
- });
- j( 'form#' + form.attr('id') + ' span.ajax-loader' ).show();
- /* Remove any errors */
- j('div.error').remove();
- button.attr('disabled','disabled');
- /* Default POST values */
- var object = '';
- var item_id = j("#whats-new-post-in").val();
- var content = j("textarea#whats-new").val();
- /* Set object for non-profile posts */
- if ( item_id > 0 ) {
- object = j("#whats-new-post-object").val();
- }
- j.post( ajaxurl, {
- action: 'post_update',
- 'cookie': encodeURIComponent(document.cookie),
- '_wpnonce_post_update': j("input#_wpnonce_post_update").val(),
- 'content': content,
- 'object': object,
- 'item_id': item_id
- },
- function(response)
- {
- j( 'form#' + form.attr('id') + ' span.ajax-loader' ).hide();
- form.children().each( function() {
- if ( j.nodeName(this, "textarea") || j.nodeName(this, "input") )
- j(this).attr( 'disabled', '' );
- });
- /* Check for errors and append if found. */
- if ( response[0] + response[1] == '-1' ) {
- form.prepend( response.substr( 2, response.length ) );
- j( 'form#' + form.attr('id') + ' div.error').hide().fadeIn( 200 );
- button.attr("disabled", '');
- } else {
- if ( 0 == j("ul.activity-list").length ) {
- j("div.error").slideUp(100).remove();
- j("div#message").slideUp(100).remove();
- j("div.activity").append( '<ul id="activity-stream" class="activity-list item-list">' );
- }
- j("ul.activity-list").prepend(response);
- j("ul.activity-list li:first").addClass('new-update');
- j("li.new-update").hide().slideDown( 300 );
- j("li.new-update").removeClass( 'new-update' );
- j("textarea#whats-new").val('');
- /* Re-enable the submit button after 8 seconds. */
- setTimeout( function() { button.attr("disabled", ''); }, 8000 );
- }
- });
- return false;
- });
- /* List tabs event delegation */
- j('div.activity-type-tabs').click( function(event) {
- var target = j(event.target).parent();
- if ( event.target.nodeName == 'STRONG' || event.target.nodeName == 'SPAN' )
- target = target.parent();
- else if ( event.target.nodeName != 'A' )
- return false;
- /* Reset the page */
- j.cookie( 'bp-activity-oldestpage', 1, {path: '/'} );
- /* Activity Stream Tabs */
- var scope = target.attr('id').substr( 9, target.attr('id').length );
- var filter = j("#activity-filter-select select").val();
- if ( scope == 'mentions' )
- j( 'li#' + target.attr('id') + ' a strong' ).remove();
- bp_activity_request(scope, filter, target);
- return false;
- });
- /* Activity filter select */
- j('#activity-filter-select select').change( function() {
- var selected_tab = j( 'div.activity-type-tabs li.selected' );
- if ( !selected_tab.length )
- var scope = null;
- else
- var scope = selected_tab.attr('id').substr( 9, selected_tab.attr('id').length );
- var filter = j(this).val();
- bp_activity_request(scope, filter);
- return false;
- });
- /* Stream event delegation */
- j('div.activity').click( function(event) {
- var target = j(event.target);
- /* Favoriting activity stream items */
- if ( target.attr('class') == 'fav' || target.attr('class') == 'unfav' ) {
- var type = target.attr('class')
- var parent = target.parent().parent().parent();
- var parent_id = parent.attr('id').substr( 9, parent.attr('id').length );
- target.addClass('loading');
- j.post( ajaxurl, {
- action: 'activity_mark_' + type,
- 'cookie': encodeURIComponent(document.cookie),
- 'id': parent_id
- },
- function(response) {
- target.removeClass('loading');
- target.fadeOut( 100, function() {
- j(this).html(response);
- j(this).fadeIn(100);
- });
- if ( 'fav' == type ) {
- if ( !j('div.item-list-tabs li#activity-favorites').length )
- j('div.item-list-tabs ul li#activity-mentions').before( '<li id="activity-favorites"><a href="#">' + bp_terms_my_favs + ' (<span>0</span>)</a></li>');
- target.removeClass('fav');
- target.addClass('unfav');
- j('div.item-list-tabs ul li#activity-favorites span').html( Number( j('div.item-list-tabs ul li#activity-favorites span').html() ) + 1 );
- } else {
- target.removeClass('unfav');
- target.addClass('fav');
- j('div.item-list-tabs ul li#activity-favorites span').html( Number( j('div.item-list-tabs ul li#activity-favorites span').html() ) - 1 );
- if ( !Number( j('div.item-list-tabs ul li#activity-favorites span').html() ) ) {
- if ( j('div.item-list-tabs ul li#activity-favorites').hasClass('selected') )
- bp_activity_request( null, null );
- j('div.item-list-tabs ul li#activity-favorites').remove();
- }
- }
- if ( 'activity-favorites' == j( 'div.item-list-tabs li.selected').attr('id') )
- target.parent().parent().parent().slideUp(100);
- });
- return false;
- }
- /* Delete activity stream items */
- if ( target.hasClass('delete-activity') ) {
- var li = target.parents('div.activity ul li');
- var id = li.attr('id').substr( 9, li.attr('id').length );
- var link_href = target.attr('href');
- var nonce = link_href.split('_wpnonce=');
- nonce = nonce[1];
- target.addClass('loading');
- j.post( ajaxurl, {
- action: 'delete_activity',
- 'cookie': encodeURIComponent(document.cookie),
- 'id': id,
- '_wpnonce': nonce
- },
- function(response) {
- target.removeClass('loading');
- if ( response[0] + response[1] == '-1' ) {
- li.prepend( response.substr( 2, response.length ) );
- li.children('div#message').hide().fadeIn(200);
- } else {
- li.slideUp(200);
- }
- });
- return false;
- }
- /* Load more updates at the end of the page */
- if ( target.parent().attr('class') == 'load-more' ) {
- j("li.load-more").addClass('loading');
- if ( null == j.cookie('bp-activity-oldestpage') )
- j.cookie('bp-activity-oldestpage', 1, {path: '/'} );
- var oldest_page = ( j.cookie('bp-activity-oldestpage') * 1 ) + 1;
- j.post( ajaxurl, {
- action: 'activity_get_older_updates',
- 'cookie': encodeURIComponent(document.cookie),
- 'page': oldest_page
- },
- function(response)
- {
- j("li.load-more").removeClass('loading');
- j.cookie( 'bp-activity-oldestpage', oldest_page, {path: '/'} );
- j("ul.activity-list").append(response.contents);
- target.parent().hide();
- }, 'json' );
- return false;
- }
- });
- /**** Activity Comments *******************************************************/
- /* Hide all activity comment forms */
- j('form.ac-form').hide();
- /* Hide excess comments */
- if ( j('div.activity-comments').length )
- bp_dtheme_hide_comments();
- /* Activity list event delegation */
- j('div.activity').click( function(event) {
- var target = j(event.target);
- /* Comment / comment reply links */
- if ( target.attr('class') == 'acomment-reply' || target.parent().attr('class') == 'acomment-reply' ) {
- if ( target.parent().attr('class') == 'acomment-reply' )
- target = target.parent();
- var id = target.attr('id');
- ids = id.split('-');
- var a_id = ids[2]
- var c_id = target.attr('href').substr( 10, target.attr('href').length );
- var form = j( '#ac-form-' + a_id );
- var form = j( '#ac-form-' + ids[2] );
- form.css( 'display', 'none' );
- form.removeClass('root');
- j('.ac-form').hide();
- /* Hide any error messages */
- form.children('div').each( function() {
- if ( j(this).hasClass( 'error' ) )
- j(this).hide();
- });
- if ( ids[1] != 'comment' ) {
- j('div.activity-comments li#acomment-' + c_id).append( form );
- } else {
- j('li#activity-' + a_id + ' div.activity-comments').append( form );
- }
- if ( form.parent().attr( 'class' ) == 'activity-comments' )
- form.addClass('root');
- form.slideDown( 200 );
- j.scrollTo( form, 500, { offset:-100, easing:'easeout' } );
- j('#ac-form-' + ids[2] + ' textarea').focus();
- return false;
- }
- /* Activity comment posting */
- if ( target.attr('name') == 'ac_form_submit' ) {
- var form = target.parent().parent();
- var form_parent = form.parent();
- var form_id = form.attr('id').split('-');
- if ( 'activity-comments' !== form_parent.attr('class') ) {
- var tmp_id = form_parent.attr('id').split('-');
- var comment_id = tmp_id[1];
- } else {
- var comment_id = form_id[2];
- }
- /* Hide any error messages */
- j( 'form#' + form + ' div.error').hide();
- form.addClass('loading');
- target.css('disabled', 'disabled');
- j.post( ajaxurl, {
- action: 'new_activity_comment',
- 'cookie': encodeURIComponent(document.cookie),
- '_wpnonce_new_activity_comment': j("input._wpnonce_new_activity_comment").val(),
- 'comment_id': comment_id,
- 'form_id': form_id[2],
- 'content': j('form#' + form.attr('id') + ' textarea').val()
- },
- function(response)
- {
- form.removeClass('loading');
- /* Check for errors and append if found. */
- if ( response[0] + response[1] == '-1' ) {
- form.append( response.substr( 2, response.length ) ).hide().fadeIn( 200 );
- target.attr("disabled", '');
- } else {
- form.fadeOut( 200,
- function() {
- if ( 0 == form.parent().children('ul').length ) {
- if ( form.parent().attr('class') == 'activity-comments' )
- form.parent().prepend('<ul></ul>');
- else
- form.parent().append('<ul></ul>');
- }
- form.parent().children('ul').append(response).hide().fadeIn( 200 );
- form.children('textarea').val('');
- form.parent().parent().addClass('has-comments');
- }
- );
- j( 'form#' + form + ' textarea').val('');
- /* Increase the "Reply (X)" button count */
- j('li#activity-' + form_id[2] + ' a.acomment-reply span').html( Number( j('li#activity-' + form_id[2] + ' a.acomment-reply span').html() ) + 1 );
- /* Re-enable the submit button after 5 seconds. */
- setTimeout( function() { target.attr("disabled", ''); }, 5000 );
- }
- });
- return false;
- }
- /* Deleting an activity comment */
- if ( target.hasClass('acomment-delete') ) {
- var link_href = target.attr('href');
- var comment_li = target.parent().parent();
- var form = comment_li.parents('div.activity-comments').children('form');
- var nonce = link_href.split('_wpnonce=');
- nonce = nonce[1];
- var comment_id = link_href.split('cid=');
- comment_id = comment_id[1].split('&');
- comment_id = comment_id[0];
- target.addClass('loading');
- /* Remove any error messages */
- j('div.activity-comments ul div.error').remove();
- /* Reset the form position */
- comment_li.parents('div.activity-comments').append(form);
- j.post( ajaxurl, {
- action: 'delete_activity_comment',
- 'cookie': encodeURIComponent(document.cookie),
- '_wpnonce': nonce,
- 'id': comment_id
- },
- function(response)
- {
- /* Check for errors and append if found. */
- if ( response[0] + response[1] == '-1' ) {
- comment_li.prepend( response.substr( 2, response.length ) ).hide().fadeIn( 200 );
- } else {
- var children = j( 'li#' + comment_li.attr('id') + ' ul' ).children('li');
- var child_count = 0;
- j(children).each( function() {
- if ( !j(this).is(':hidden') )
- child_count++;
- });
- comment_li.fadeOut(200);
- /* Decrease the "Reply (X)" button count */
- var parent_li = comment_li.parents('ul#activity-stream > li');
- j('li#' + parent_li.attr('id') + ' a.acomment-reply span').html( j('li#' + parent_li.attr('id') + ' a.acomment-reply span').html() - ( 1 + child_count ) );
- }
- });
- return false;
- }
- /* Showing hidden comments - pause for half a second */
- if ( target.parent().hasClass('show-all') ) {
- target.parent().addClass('loading');
- setTimeout( function() {
- target.parent().parent().children('li').fadeIn(200, function() {
- target.parent().remove();
- });
- }, 600 );
- return false;
- }
- });
- /* Escape Key Press for cancelling comment forms */
- j(document).keydown( function(e) {
- e = e || window.event;
- if (e.target)
- element = e.target;
- else if (e.srcElement)
- element = e.srcElement;
- if( element.nodeType == 3)
- element = element.parentNode;
- if( e.ctrlKey == true || e.altKey == true || e.metaKey == true )
- return;
- var keyCode = (e.keyCode) ? e.keyCode : e.which;
- if ( keyCode == 27 ) {
- if (element.tagName == 'TEXTAREA') {
- if ( j(element).attr('class') == 'ac-input' )
- j(element).parent().parent().parent().slideUp( 200 );
- }
- }
- });
- /**** @mention username help tooltip **************************************/
- j('span.highlight span').click( function() {
- if ( !j('div.help').length ) {
- j(this).parent().after( '<div id="message" class="info help"><p>' + bp_terms_mention_explain + '</p></div>' );
- j('div.help').hide().slideDown(200);
- } else {
- j('div.help').hide().remove();
- }
- })
- /**** Directory Search ****************************************************/
- /* The search form on all directory pages */
- j('div.dir-search').click( function(event) {
- if ( j(this).hasClass('no-ajax') )
- return;
- var target = j(event.target);
- if ( target.attr('type') == 'submit' ) {
- var css_id = j('div.item-list-tabs li.selected').attr('id').split( '-' );
- var object = css_id[0];
- bp_filter_request( object, j.cookie('bp-' + object + '-filter'), j.cookie('bp-' + object + '-scope') , 'div.' + object, target.parent().children('label').children('input').val(), 1, j.cookie('bp-' + object + '-extras') );
- return false;
- }
- });
- /**** Tabs and Filters ****************************************************/
- /* When a navigation tab is clicked - e.g. | All Groups | My Groups | */
- j('div.item-list-tabs').click( function(event) {
- if ( j(this).hasClass('no-ajax') )
- return;
- var target = j(event.target).parent();
- if ( 'LI' == event.target.parentNode.nodeName && !target.hasClass('last') ) {
- var css_id = target.attr('id').split( '-' );
- var object = css_id[0];
- if ( 'activity' == object )
- return false;
- var scope = css_id[1];
- var filter = j("#" + object + "-order-select select").val();
- var search_terms = j("#" + object + "_search").val();
- bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, j.cookie('bp-' + object + '-extras') );
- return false;
- }
- });
- /* When the filter select box is changed re-query */
- j('li.filter select').change( function() {
- if ( j('div.item-list-tabs li.selected').length )
- var el = j('div.item-list-tabs li.selected');
- else
- var el = j(this);
- var css_id = el.attr('id').split('-');
- var object = css_id[0];
- var scope = css_id[1];
- var filter = j(this).val();
- var search_terms = false;
- if ( j('div.dir-search input').length )
- search_terms = j('div.dir-search input').val();
- if ( 'friends' == object )
- object = 'members';
- bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, j.cookie('bp-' + object + '-extras') );
- return false;
- });
- /* All pagination links run through this function */
- j('div#content').click( function(event) {
- var target = j(event.target);
- if ( target.hasClass('button') )
- return true;
- if ( target.parent().parent().hasClass('pagination') && !target.parent().parent().hasClass('no-ajax') ) {
- if ( target.hasClass('dots') || target.hasClass('current') )
- return false;
- if ( j('div.item-list-tabs li.selected').length )
- var el = j('div.item-list-tabs li.selected');
- else
- var el = j('li.filter select');
- var page_number = 1;
- var css_id = el.attr('id').split( '-' );
- var object = css_id[0];
- var search_terms = false;
- if ( j('div.dir-search input').length )
- search_terms = j('div.dir-search input').val();
- if ( j(target).hasClass('next') )
- var page_number = Number( j('div.pagination span.current').html() ) + 1;
- else if ( j(target).hasClass('prev') )
- var page_number = Number( j('div.pagination span.current').html() ) - 1;
- else
- var page_number = Number( j(target).html() );
- bp_filter_request( object, j.cookie('bp-' + object + '-filter'), j.cookie('bp-' + object + '-scope'), 'div.' + object, search_terms, page_number, j.cookie('bp-' + object + '-extras') );
- return false;
- }
- });
- /**** New Forum Directory Post **************************************/
- /* Hit the "New Topic" button on the forums directory page */
- j('a#new-topic-button').click( function() {
- if ( !j('div#new-topic-post').length )
- return false;
- if ( j('div#new-topic-post').is(":visible") )
- j('div#new-topic-post').slideUp(200);
- else
- j('div#new-topic-post').slideDown(200);
- return false;
- });
- /* Cancel the posting of a new forum topic */
- j('input#submit_topic_cancel').click( function() {
- if ( !j('div#new-topic-post').length )
- return false;
- j('div#new-topic-post').slideUp(200);
- return false;
- });
- /* Clicking a forum tag */
- j('div#forum-directory-tags a').click( function() {
- bp_filter_request( 'forums', 'tags', j.cookie('bp-forums-scope'), 'div.forums', j(this).html().replace( / /g, '-' ), 1, j.cookie('bp-forums-extras') );
- return false;
- });
- /** Invite Friends Interface ****************************************/
- /* Select a user from the list of friends and add them to the invite list */
- j("div#invite-list input").click( function() {
- j('.ajax-loader').toggle();
- var friend_id = j(this).val();
- if ( j(this).attr('checked') == true )
- var friend_action = 'invite';
- else
- var friend_action = 'uninvite';
- j('div.item-list-tabs li.selected').addClass('loading');
- j.post( ajaxurl, {
- action: 'groups_invite_user',
- 'friend_action': friend_action,
- 'cookie': encodeURIComponent(document.cookie),
- '_wpnonce': j("input#_wpnonce_invite_uninvite_user").val(),
- 'friend_id': friend_id,
- 'group_id': j("input#group_id").val()
- },
- function(response)
- {
- if ( j("#message") )
- j("#message").hide();
- j('.ajax-loader').toggle();
- if ( friend_action == 'invite' ) {
- j('#friend-list').append(response);
- } else if ( friend_action == 'uninvite' ) {
- j('#friend-list li#uid-' + friend_id).remove();
- }
- j('div.item-list-tabs li.selected').removeClass('loading');
- });
- });
- /* Remove a user from the list of users to invite to a group */
- j("#friend-list li a.remove").live('click', function() {
- j('.ajax-loader').toggle();
- var friend_id = j(this).attr('id');
- friend_id = friend_id.split('-');
- friend_id = friend_id[1];
- j.post( ajaxurl, {
- action: 'groups_invite_user',
- 'friend_action': 'uninvite',
- 'cookie': encodeURIComponent(document.cookie),
- '_wpnonce': j("input#_wpnonce_invite_uninvite_user").val(),
- 'friend_id': friend_id,
- 'group_id': j("input#group_id").val()
- },
- function(response)
- {
- j('.ajax-loader').toggle();
- j('#friend-list li#uid-' + friend_id).remove();
- j('#invite-list input#f-' + friend_id).attr('checked', false);
- });
- return false;
- });
- /** Friendship Requests **************************************/
- /* Accept and Reject friendship request buttons */
- j("ul#friend-list a.accept, ul#friend-list a.reject").click( function() {
- var button = j(this);
- var li = j(this).parents('ul#friend-list li');
- var action_div = j(this).parents('li div.action');
- var id = li.attr('id').substr( 11, li.attr('id').length );
- var link_href = button.attr('href');
- var nonce = link_href.split('_wpnonce=');
- nonce = nonce[1];
- if ( j(this).hasClass('accepted') || j(this).hasClass('rejected') )
- return false;
- if ( j(this).hasClass('accept') ) {
- var action = 'accept_friendship';
- action_div.children('a.reject').css( 'visibility', 'hidden' );
- } else {
- var action = 'reject_friendship';
- action_div.children('a.accept').css( 'visibility', 'hidden' );
- }
- button.addClass('loading');
- j.post( ajaxurl, {
- action: action,
- 'cookie': encodeURIComponent(document.cookie),
- 'id': id,
- '_wpnonce': nonce
- },
- function(response) {
- button.removeClass('loading');
- if ( response[0] + response[1] == '-1' ) {
- li.prepend( response.substr( 2, response.length ) );
- li.children('div#message').hide().fadeIn(200);
- } else {
- button.fadeOut( 100, function() {
- if ( j(this).hasClass('accept') ) {
- j(this).html( bp_terms_accepted ).fadeIn(50);
- j(this).addClass('accepted');
- } else {
- j(this).html( bp_terms_rejected ).fadeIn(50);
- j(this).addClass('rejected');
- }
- });
- }
- });
- return false;
- });
- /* Add / Remove friendship buttons */
- j("div.friendship-button a").live('click', function() {
- j(this).parent().addClass('loading');
- var fid = j(this).attr('id');
- fid = fid.split('-');
- fid = fid[1];
- var nonce = j(this).attr('href');
- nonce = nonce.split('?_wpnonce=');
- nonce = nonce[1].split('&');
- nonce = nonce[0];
- var thelink = j(this);
- j.post( ajaxurl, {
- action: 'addremove_friend',
- 'cookie': encodeURIComponent(document.cookie),
- 'fid': fid,
- '_wpnonce': nonce
- },
- function(response)
- {
- var action = thelink.attr('rel');
- var parentdiv = thelink.parent();
- if ( action == 'add' ) {
- j(parentdiv).fadeOut(200,
- function() {
- parentdiv.removeClass('add_friend');
- parentdiv.removeClass('loading');
- parentdiv.addClass('pending');
- parentdiv.fadeIn(200).html(response);
- }
- );
- } else if ( action == 'remove' ) {
- j(parentdiv).fadeOut(200,
- function() {
- parentdiv.removeClass('remove_friend');
- parentdiv.removeClass('loading');
- parentdiv.addClass('add');
- parentdiv.fadeIn(200).html(response);
- }
- );
- }
- });
- return false;
- } );
- /** Group Join / Leave Buttons **************************************/
- j("div.group-button a").live('click', function() {
- var gid = j(this).parent().attr('id');
- gid = gid.split('-');
- gid = gid[1];
- var nonce = j(this).attr('href');
- nonce = nonce.split('?_wpnonce=');
- nonce = nonce[1].split('&');
- nonce = nonce[0];
- var thelink = j(this);
- j.post( ajaxurl, {
- action: 'joinleave_group',
- 'cookie': encodeURIComponent(document.cookie),
- 'gid': gid,
- '_wpnonce': nonce
- },
- function(response)
- {
- var parentdiv = thelink.parent();
- if ( !j('body.directory').length )
- location.href = location.href;
- else {
- j(parentdiv).fadeOut(200,
- function() {
- parentdiv.fadeIn(200).html(response);
- }
- );
- }
- });
- return false;
- } );
- /** Button disabling ************************************************/
- j('div.pending').click(function() {
- return false;
- });
- /** Alternate Highlighting ******************************************/
- j('table tr, div.message-box, ul#topic-post-list li').each( function(i) {
- if ( i % 2 != 1 )
- j(this).addClass('alt');
- });
- /** Private Messaging ******************************************/
- /* AJAX send reply functionality */
- j("input#send_reply_button").click(
- function() {
- j('form#send-reply span.ajax-loader').toggle();
- j.post( ajaxurl, {
- action: 'messages_send_reply',
- 'cookie': encodeURIComponent(document.cookie),
- '_wpnonce': j("input#send_message_nonce").val(),
- 'content': j("#message_content").val(),
- 'send_to': j("input#send_to").val(),
- 'subject': j("input#subject").val(),
- 'thread_id': j("input#thread_id").val()
- },
- function(response)
- {
- if ( response[0] + response[1] == "-1" ) {
- j('form#send-reply').prepend( response.substr( 2, response.length ) );
- } else {
- j('form#send-reply div#message').remove();
- j("#message_content").val('');
- j('form#send-reply').before( response );
- j("div.new-message").hide().slideDown( 200, function() {
- j('div.new-message').removeClass('new-message');
- });
- j('div.message-box').each( function(i) {
- j(this).removeClass('alt');
- if ( i % 2 != 1 )
- j(this).addClass('alt');
- });
- }
- j('form#send-reply span.ajax-loader').toggle();
- });
- return false;
- }
- );
- /* Marking private messages as read and unread */
- j("a#mark_as_read, a#mark_as_unread").click(function() {
- var checkboxes_tosend = '';
- var checkboxes = j("#message-threads tr td input[type='checkbox']");
- if ( 'mark_as_unread' == j(this).attr('id') ) {
- var currentClass = 'read'
- var newClass = 'unread'
- var unreadCount = 1;
- var inboxCount = 0;
- var unreadCountDisplay = 'inline';
- var action = 'messages_markunread';
- } else {
- var currentClass = 'unread'
- var newClass = 'read'
- var unreadCount = 0;
- var inboxCount = 1;
- var unreadCountDisplay = 'none';
- var action = 'messages_markread';
- }
- checkboxes.each( function(i) {
- if(j(this).is(':checked')) {
- if ( j('tr#m-' + j(this).attr('value')).hasClass(currentClass) ) {
- checkboxes_tosend += j(this).attr('value');
- j('tr#m-' + j(this).attr('value')).removeClass(currentClass);
- j('tr#m-' + j(this).attr('value')).addClass(newClass);
- var thread_count = j('tr#m-' + j(this).attr('value') + ' td span.unread-count').html();
- j('tr#m-' + j(this).attr('value') + ' td span.unread-count').html(unreadCount);
- j('tr#m-' + j(this).attr('value') + ' td span.unread-count').css('display', unreadCountDisplay);
- var inboxcount = j('a#user-messages strong').html().substr( 1, j('a#user-messages strong').html().length );
- var inboxcount = inboxcount.substr( 0, inboxcount.length - 1 );
- if ( !inboxcount.length )
- inboxcount = 0;
- if ( parseInt(inboxcount) == inboxCount ) {
- j('a#user-messages strong').css('display', unreadCountDisplay);
- j('a#user-messages strong').html( '(' + unreadCount + ')' );
- } else {
- if ( 'read' == currentClass )
- j('a#user-messages strong').html('(' + ( parseInt(inboxcount) + 1 ) + ')');
- else
- j('a#user-messages strong').html('(' + ( parseInt(inboxcount) - thread_count ) + ')');
- }
- if ( i != checkboxes.length - 1 ) {
- checkboxes_tosend += ','
- }
- }
- }
- });
- j.post( ajaxurl, {
- action: action,
- 'thread_ids': checkboxes_tosend
- });
- return false;
- });
- /* Selecting unread and read messages in inbox */
- j("select#message-type-select").change(
- function() {
- var selection = j("select#message-type-select").val();
- var checkboxes = j("td input[type='checkbox']");
- checkboxes.each( function(i) {
- checkboxes[i].checked = "";
- });
- switch(selection) {
- case 'unread':
- var checkboxes = j("tr.unread td input[type='checkbox']");
- break;
- case 'read':
- var checkboxes = j("tr.read td input[type='checkbox']");
- break;
- }
- if ( selection != '' ) {
- checkboxes.each( function(i) {
- checkboxes[i].checked = "checked";
- });
- } else {
- checkboxes.each( function(i) {
- checkboxes[i].checked = "";
- });
- }
- }
- );
- /* Bulk delete messages */
- j("a#delete_inbox_messages").click( function() {
- checkboxes_tosend = '';
- checkboxes = j("#message-threads tr td input[type='checkbox']");
- j('div#message').remove();
- j(this).addClass('loading');
- j(checkboxes).each( function(i) {
- if( j(this).is(':checked') )
- checkboxes_tosend += j(this).attr('value') + ',';
- });
- if ( '' == checkboxes_tosend ) {
- j(this).removeClass('loading');
- return false;
- }
- j.post( ajaxurl, {
- action: 'messages_delete',
- 'thread_ids': checkboxes_tosend
- }, function(response) {
- if ( response[0] + response[1] == "-1" ) {
- j('#message-threads').prepend( response.substr( 2, response.length ) );
- } else {
- j('#message-threads').before( '<div id="message" class="updated"><p>' + response + '</p></div>' );
- j(checkboxes).each( function(i) {
- if( j(this).is(':checked') )
- j(this).parent().parent().fadeOut(150);
- });
- }
- j('div#message').hide().slideDown(150);
- j("a#delete_inbox_messages").removeClass('loading');
- });
- return false;
- });
- /* Close site wide notices in the sidebar */
- j("a#close-notice").click( function() {
- j(this).addClass('loading');
- j('div#sidebar div.error').remove();
- j.post( ajaxurl, {
- action: 'messages_close_notice',
- 'notice_id': j('.notice').attr('rel').substr( 2, j('.notice').attr('rel').length )
- },
- function(response) {
- j("a#close-notice").removeClass('loading');
- if ( response[0] + response[1] == '-1' ) {
- j('.notice').prepend( response.substr( 2, response.length ) );
- j( 'div#sidebar div.error').hide().fadeIn( 200 );
- } else {
- j('.notice').slideUp( 100 );
- }
- });
- return false;
- });
- /* Admin Bar Javascript */
- j("#wp-admin-bar ul.main-nav li").mouseover( function() {
- j(this).addClass('sfhover');
- });
- j("#wp-admin-bar ul.main-nav li").mouseout( function() {
- j(this).removeClass('sfhover');
- });
- /* Clear BP cookies on logout */
- j('a.logout').click( function() {
- j.cookie('bp-activity-scope', null, {path: '/'});
- j.cookie('bp-activity-filter', null, {path: '/'});
- j.cookie('bp-activity-oldestpage', null, {path: '/'});
- var objects = [ 'members', 'groups', 'blogs', 'forums' ];
- j(objects).each( function(i) {
- j.cookie('bp-' + objects[i] + '-scope', null, {path: '/'} );
- j.cookie('bp-' + objects[i] + '-filter', null, {path: '/'} );
- j.cookie('bp-' + objects[i] + '-extras', null, {path: '/'} );
- });
- });
-
- jQuery(".widget div#members-list-options a").live('click',
- function() {
- jQuery('#ajax-loader-members').toggle();
- jQuery(".widget div#members-list-options a").removeClass("selected");
- jQuery(this).addClass('selected');
- jQuery.post( ajaxurl, {
- action: 'widget_members',
- 'cookie': encodeURIComponent(document.cookie),
- '_wpnonce': jQuery("input#_wpnonce-members").val(),
- 'max-members': jQuery("input#members_widget_max").val(),
- 'filter': jQuery(this).attr('id')
- },
- function(response)
- {
- jQuery('#ajax-loader-members').toggle();
- member_wiget_response(response);
- });
- return false;
- }
- );
-
- jQuery(".widget div#groups-list-options a").live('click',
- function() {
- jQuery('#ajax-loader-groups').toggle();
- jQuery(".widget div#groups-list-options a").removeClass("selected");
- jQuery(this).addClass('selected');
- jQuery.post( ajaxurl, {
- action: 'widget_groups_list',
- 'cookie': encodeURIComponent(document.cookie),
- '_wpnonce': jQuery("input#_wpnonce-groups").val(),
- 'max_groups': jQuery("input#groups_widget_max").val(),
- 'filter': jQuery(this).attr('id')
- },
- function(response)
- {
- jQuery('#ajax-loader-groups').toggle();
- groups_wiget_response(response);
- });
- return false;
- }
- );
- });
- /* Setup activity scope and filter based on the current cookie settings. */
- function bp_init_activity() {
- /* Reset the page */
- j.cookie( 'bp-activity-oldestpage', 1, {path: '/'} );
- if ( null != j.cookie('bp-activity-filter') && j('#activity-filter-select').length )
- j('#activity-filter-select select option[value=' + j.cookie('bp-activity-filter') + ']').attr( 'selected', 'selected' );
- /* Activity Tab Set */
- if ( null != j.cookie('bp-activity-scope') && j('div.activity-type-tabs').length ) {
- j('div.activity-type-tabs li').each( function() {
- j(this).removeClass('selected');
- });
- j('li#activity-' + j.cookie('bp-activity-scope') + ', div.item-list-tabs li.current').addClass('selected');
- }
- }
- /* Setup object scope and filter based on the current cookie settings for the object. */
- function bp_init_objects(objects) {
- j(objects).each( function(i) {
- if ( null != j.cookie('bp-' + objects[i] + '-filter') && j('li#' + objects[i] + '-order-select select').length )
- j('li#' + objects[i] + '-order-select select option[value=' + j.cookie('bp-' + objects[i] + '-filter') + ']').attr( 'selected', 'selected' );
- if ( null != j.cookie('bp-' + objects[i] + '-scope') && j('div.' + objects[i]).length ) {
- j('div.item-list-tabs li').each( function() {
- j(this).removeClass('selected');
- });
- j('div.item-list-tabs li#' + objects[i] + '-' + j.cookie('bp-' + objects[i] + '-scope') + ', div.item-list-tabs#object-nav li.current').addClass('selected');
- }
- });
- }
- /* Filter the current content list (groups/members/blogs/topics) */
- function bp_filter_request( object, filter, scope, target, search_terms, page, extras ) {
- if ( 'activity' == object )
- return false;
- if ( j.query.get('s') )
- search_terms = j.query.get('s');
- if ( null == scope )
- scope = 'all';
- /* Save the settings we want to remain persistent to a cookie */
- j.cookie( 'bp-' + object + '-scope', scope, {path: '/'} );
- j.cookie( 'bp-' + object + '-filter', filter, {path: '/'} );
- j.cookie( 'bp-' + object + '-extras', extras, {path: '/'} );
- /* Set the correct selected nav and filter */
- j('div.item-list-tabs li').each( function() {
- j(this).removeClass('selected');
- });
- j('div.item-list-tabs li#' + object + '-' + scope + ', div.item-list-tabs#object-nav li.current').addClass('selected');
- j('div.item-list-tabs li.selected').addClass('loading');
- j('div.item-list-tabs select option[value=' + filter + ']').attr( 'selected', 'selected' );
- if ( 'friends' == object )
- object = 'members';
- if ( bp_ajax_request )
- bp_ajax_request.abort();
- bp_ajax_request = j.post( ajaxurl, {
- action: object + '_filter',
- 'cookie': encodeURIComponent(document.cookie),
- 'object': object,
- 'filter': filter,
- 'search_terms': search_terms,
- 'scope': scope,
- 'page': page,
- 'extras': extras
- },
- function(response)
- {
- j(target).fadeOut( 100, function() {
- j(this).html(response);
- j(this).fadeIn(100);
- });
- j('div.item-list-tabs li.selected').removeClass('loading');
- });
- }
- /* Activity Loop Requesting */
- function bp_activity_request(scope, filter) {
- /* Save the type and filter to a session cookie */
- j.cookie( 'bp-activity-scope', scope, {path: '/'} );
- j.cookie( 'bp-activity-filter', filter, {path: '/'} );
- j.cookie( 'bp-activity-oldestpage', 1 );
- /* Remove selected and loading classes from tabs */
- j('div.item-list-tabs li').each( function() {
- j(this).removeClass('selected loading');
- });
- /* Set the correct selected nav and filter */
- j('li#activity-' + scope + ', div.item-list-tabs li.current').addClass('selected');
- j('div#object-nav.item-list-tabs li.selected, div.activity-type-tabs li.selected').addClass('loading');
- j('#activity-filter-select select option[value=' + filter + ']').attr( 'selected', 'selected' );
- /* Reload the activity stream based on the selection */
- j('.widget_bp_activity_widget h2 span.ajax-loader').show();
- if ( bp_ajax_request )
- bp_ajax_request.abort();
- bp_ajax_request = j.post( ajaxurl, {
- action: 'activity_widget_filter',
- 'cookie': encodeURIComponent(document.cookie),
- '_wpnonce_activity_filter': j("input#_wpnonce_activity_filter").val(),
- 'scope': scope,
- 'filter': filter
- },
- function(response)
- {
- j('.widget_bp_activity_widget h2 span.ajax-loader').hide();
- j('div.activity').fadeOut( 100, function() {
- j(this).html(response.contents);
- j(this).fadeIn(100);
- });
- /* Update the feed link */
- if ( null != response.feed_url )
- j('.directory div#subnav li.feed a, .home-page div#subnav li.feed a').attr('href', response.feed_url);
- j('div.item-list-tabs li.selected').removeClass('loading');
- /* Selectively hide comments */
- bp_dtheme_hide_comments();
- }, 'json' );
- }
- /* Hide long lists of activity comments, only show the latest five root comments. */
- function bp_dtheme_hide_comments() {
- var comments_divs = j('div.activity-comments');
- if ( !comments_divs.length )
- return false;
- comments_divs.each( function() {
- if ( j(this).children('ul').children('li').length < 5 ) return;
- var comments_div = j(this);
- var parent_li = comments_div.parents('ul#activity-stream > li');
- var comment_lis = j(this).children('ul').children('li');
- var comment_count = ' ';
- if ( j('li#' + parent_li.attr('id') + ' a.acomment-reply span').length )
- var comment_count = j('li#' + parent_li.attr('id') + ' a.acomment-reply span').html();
- comment_lis.each( function(i) {
- /* Show the latest 5 root comments */
- if ( i < comment_lis.length - 5 ) {
- j(this).addClass('hidden');
- j(this).toggle();
- if ( !i )
- j(this).before( '<li class="show-all"><a href="#' + parent_li.attr('id') + '/show-all/" title="' + bp_terms_show_all_comments + '">' + bp_terms_show_all + ' ' + comment_count + ' ' + bp_terms_comments + '</a></li>' );
- }
- });
- });
- }
- function member_wiget_response(response) {
- response = response.substr(0, respo…
Large files files are truncated, but you can click here to view the full file