Skip to:
Content

BuddyPress.org

Changeset 8378


Ignore:
Timestamp:
05/04/2014 05:18:57 PM (12 years ago)
Author:
djpaul
Message:

Javascript: first pass at improvements for jshint

See #5613

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/admin/js/admin.js

    r8030 r8378  
     1/* global bp_activity_admin_vars, postboxes, wpAjax */
    12(function( $ ) {
    23
     
    2021                // Close textarea on escape
    2122                $(document).on( 'keyup', '#bp-activities:visible', function( e ) {
    22                         if ( 27 == e.which ) {
     23                        if ( 27 === e.which ) {
    2324                                activityReply.close();
    2425                        }
     
    3132         * @since BuddyPress (1.6)
    3233         */
    33         open : function( e ) {
     34        open : function() {
    3435                // Hide the container row, and move it to the new location
    3536                var box = $( '#bp-activities-container' ).hide();
     
    4849         * @since BuddyPress (1.6)
    4950         */
    50         close : function( e ) {
     51        close : function() {
    5152                // Hide the container row
    52                 $('#bp-activities-container').fadeOut( '200', function () { 
     53                $('#bp-activities-container').fadeOut( '200', function () {
    5354
    5455                        // Empty and unfocus the text area
     
    6869         * @since BuddyPress (1.6)
    6970         */
    70         send : function( e ) {
     71        send : function() {
    7172                // Hide any existing error message, and show the loading spinner
    7273                $( '#bp-replysubmit .error' ).hide();
     
    124125
    125126                // Handle any errors in the response
    126                 if ( typeof( xml ) == 'string' ) {
     127                if ( typeof( xml ) === 'string' ) {
    127128                        activityReply.error( { 'responseText': xml } );
    128129                        return false;
     
    137138
    138139                // Close and reset the reply row, and add the new Activity item into the list.
    139                 $('#bp-activities-container').fadeOut( '200', function () { 
     140                $('#bp-activities-container').fadeOut( '200', function () {
    140141
    141142                        // Empty and unfocus the text area
  • trunk/src/bp-core/js/confirm.js

    r8091 r8378  
     1/* jshint devel: true */
     2/* global BP_Confirm */
     3
    14jQuery( document ).ready( function() {
    25        jQuery( 'a.confirm').click( function() {
    3                 if ( confirm( BP_Confirm.are_you_sure ) )
    4                         return true; else return false;
     6                if ( confirm( BP_Confirm.are_you_sure ) ) {
     7                        return true;
     8                } else {
     9                        return false;
     10                }
    511        });
    612});
  • trunk/src/bp-core/js/widget-members.js

    r6635 r8378  
    11jQuery(document).ready( function() {
    2         jQuery(".widget div#members-list-options a").on('click',
     2        jQuery('.widget div#members-list-options a').on('click',
    33                function() {
    44                        var link = this;
    55                        jQuery(link).addClass('loading');
    66
    7                         jQuery(".widget div#members-list-options a").removeClass("selected");
     7                        jQuery('.widget div#members-list-options a').removeClass('selected');
    88                        jQuery(this).addClass('selected');
    99
     
    1111                                action: 'widget_members',
    1212                                'cookie': encodeURIComponent(document.cookie),
    13                                 '_wpnonce': jQuery("input#_wpnonce-members").val(),
    14                                 'max-members': jQuery("input#members_widget_max").val(),
     13                                '_wpnonce': jQuery('input#_wpnonce-members').val(),
     14                                'max-members': jQuery('input#members_widget_max').val(),
    1515                                'filter': jQuery(this).attr('id')
    1616                        },
     
    3030        response = response.split('[[SPLIT]]');
    3131
    32         if ( response[0] != "-1" ) {
    33                 jQuery(".widget ul#members-list").fadeOut(200,
     32        if ( response[0] !== '-1' ) {
     33                jQuery('.widget ul#members-list').fadeOut(200,
    3434                        function() {
    35                                 jQuery(".widget ul#members-list").html(response[1]);
    36                                 jQuery(".widget ul#members-list").fadeIn(200);
     35                                jQuery('.widget ul#members-list').html(response[1]);
     36                                jQuery('.widget ul#members-list').fadeIn(200);
    3737                        }
    3838                );
    3939
    4040        } else {
    41                 jQuery(".widget ul#members-list").fadeOut(200,
     41                jQuery('.widget ul#members-list').fadeOut(200,
    4242                        function() {
    4343                                var message = '<p>' + response[1] + '</p>';
    44                                 jQuery(".widget ul#members-list").html(message);
    45                                 jQuery(".widget ul#members-list").fadeIn(200);
     44                                jQuery('.widget ul#members-list').html(message);
     45                                jQuery('.widget ul#members-list').fadeIn(200);
    4646                        }
    4747                );
  • trunk/src/bp-friends/js/widget-friends.js

    r7392 r8378  
    11jQuery(document).ready( function() {
    2         jQuery(".widget div#friends-list-options a").on('click',
     2        jQuery('.widget div#friends-list-options a').on('click',
    33                function() {
    44                        var link = this;
    55                        jQuery(link).addClass('loading');
    66
    7                         jQuery(".widget div#friends-list-options a").removeClass("selected");
     7                        jQuery('.widget div#friends-list-options a').removeClass('selected');
    88                        jQuery(this).addClass('selected');
    99
     
    1111                                action: 'widget_friends',
    1212                                'cookie': encodeURIComponent(document.cookie),
    13                                 '_wpnonce': jQuery("input#_wpnonce-friends").val(),
    14                                 'max-friends': jQuery("input#friends_widget_max").val(),
     13                                '_wpnonce': jQuery('input#_wpnonce-friends').val(),
     14                                'max-friends': jQuery('input#friends_widget_max').val(),
    1515                                'filter': jQuery(this).attr('id')
    1616                        },
     
    3030        response = response.split('[[SPLIT]]');
    3131
    32         if ( response[0] != "-1" ) {
    33                 jQuery(".widget ul#friends-list").fadeOut(200,
     32        if ( response[0] !== '-1' ) {
     33                jQuery('.widget ul#friends-list').fadeOut(200,
    3434                        function() {
    35                                 jQuery(".widget ul#friends-list").html(response[1]);
    36                                 jQuery(".widget ul#friends-list").fadeIn(200);
     35                                jQuery('.widget ul#friends-list').html(response[1]);
     36                                jQuery('.widget ul#friends-list').fadeIn(200);
    3737                        }
    3838                );
    3939
    4040        } else {
    41                 jQuery(".widget ul#friends-list").fadeOut(200,
     41                jQuery('.widget ul#friends-list').fadeOut(200,
    4242                        function() {
    4343                                var message = '<p>' + response[1] + '</p>';
    44                                 jQuery(".widget ul#friends-list").html(message);
    45                                 jQuery(".widget ul#friends-list").fadeIn(200);
     44                                jQuery('.widget ul#friends-list').html(message);
     45                                jQuery('.widget ul#friends-list').fadeIn(200);
    4646                        }
    4747                );
  • trunk/src/bp-groups/admin/js/admin.js

    r7159 r8378  
     1/* global BP_Group_Admin, group_id, isRtl */
     2
    13(function($) {
    24        function add_member_to_list( e, ui ) {
     
    3941                });
    4042
    41                 window.onbeforeunload = function(e) {
     43                window.onbeforeunload = function() {
    4244                        if ( window.warn_on_leave ) {
    4345                                return BP_Group_Admin.warn_on_leave;
  • trunk/src/bp-groups/js/widget-groups.js

    r6635 r8378  
    11jQuery(document).ready( function() {
    2         jQuery(".widget div#groups-list-options a").on('click',
     2        jQuery('.widget div#groups-list-options a').on('click',
    33                function() {
    44                        var link = this;
    55                        jQuery(link).addClass('loading');
    66
    7                         jQuery(".widget div#groups-list-options a").removeClass("selected");
     7                        jQuery('.widget div#groups-list-options a').removeClass('selected');
    88                        jQuery(this).addClass('selected');
    99
     
    1111                                action: 'widget_groups_list',
    1212                                'cookie': encodeURIComponent(document.cookie),
    13                                 '_wpnonce': jQuery("input#_wpnonce-groups").val(),
    14                                 'max_groups': jQuery("input#groups_widget_max").val(),
     13                                '_wpnonce': jQuery('input#_wpnonce-groups').val(),
     14                                'max_groups': jQuery('input#groups_widget_max').val(),
    1515                                'filter': jQuery(this).attr('id')
    1616                        },
     
    3030        response = response.split('[[SPLIT]]');
    3131
    32         if ( response[0] != "-1" ) {
    33                 jQuery(".widget ul#groups-list").fadeOut(200,
     32        if ( response[0] !== '-1' ) {
     33                jQuery('.widget ul#groups-list').fadeOut(200,
    3434                        function() {
    35                                 jQuery(".widget ul#groups-list").html(response[1]);
    36                                 jQuery(".widget ul#groups-list").fadeIn(200);
     35                                jQuery('.widget ul#groups-list').html(response[1]);
     36                                jQuery('.widget ul#groups-list').fadeIn(200);
    3737                        }
    3838                );
    3939
    4040        } else {
    41                 jQuery(".widget ul#groups-list").fadeOut(200,
     41                jQuery('.widget ul#groups-list').fadeOut(200,
    4242                        function() {
    4343                                var message = '<p>' + response[1] + '</p>';
    44                                 jQuery(".widget ul#groups-list").html(message);
    45                                 jQuery(".widget ul#groups-list").fadeIn(200);
     44                                jQuery('.widget ul#groups-list').html(message);
     45                                jQuery('.widget ul#groups-list').fadeIn(200);
    4646                        }
    4747                );
  • trunk/src/bp-members/admin/js/admin.js

    r8021 r8378  
     1/* exported clear */
     2
    13( function( $ ) {
    24        // Profile Visibility Settings
  • trunk/src/bp-templates/bp-legacy/js/buddypress.js

    r8264 r8378  
    1313
    1414        /* Hide Forums Post Form */
    15         if ( '-1' == window.location.search.indexOf('new') && jq('div.forums').length )
     15        if ( '-1' === window.location.search.indexOf('new') && jq('div.forums').length ) {
    1616                jq('#new-topic-post').hide();
    17         else
     17        } else {
    1818                jq('#new-topic-post').show();
     19        }
    1920
    2021        /* Activity filter and scope set */
    2122        bp_init_activity();
    2223
     24        var objects  = [ 'members', 'groups', 'blogs', 'forums', 'group_members' ],
     25                $whats_new = jq('#whats-new');
     26
    2327        /* Object filter and scope set. */
    24         var objects = [ 'members', 'groups', 'blogs', 'forums', 'group_members' ];
    2528        bp_init_objects( objects );
    2629
    2730        /* @mention Compose Scrolling */
    28         var $whats_new = jq('#whats-new');
    2931        if ( jq.query.get('r') && $whats_new.length ) {
    3032                jq('#whats-new-options').animate({
    3133                        height:'40px'
    3234                });
    33                 jq("#whats-new-form textarea").animate({
     35                jq('#whats-new-form textarea').animate({
    3436                        height:'50px'
    3537                });
     
    3840                        easing:'easeOutQuad'
    3941                } );
    40                 var whats_new_content = $whats_new.val();
    41                 $whats_new.val('').focus().val(whats_new_content);
     42                $whats_new.val('').focus().val( $whats_new.val() );
    4243        }
    4344
     
    4647        /* Textarea focus */
    4748        $whats_new.focus( function(){
    48                 jq("#whats-new-options").animate({
     49                jq('#whats-new-options').animate({
    4950                        height:'40px'
    5051                });
    51                 jq("#whats-new-form textarea").animate({
     52                jq('#whats-new-form textarea').animate({
    5253                        height:'50px'
    5354                });
    54                 jq("#aw-whats-new-submit").prop("disabled", false);
    55 
    56                 var $whats_new_form = jq("form#whats-new-form");
    57                 if ( $whats_new_form.hasClass("submitted") ) {
    58                         $whats_new_form.removeClass("submitted");
     55                jq('#aw-whats-new-submit').prop('disabled', false);
     56
     57                var $whats_new_form = jq('form#whats-new-form'),
     58                        $activity_all = jq( '#activity-all' );
     59
     60                if ( $whats_new_form.hasClass('submitted') ) {
     61                        $whats_new_form.removeClass('submitted');
    5962                }
    6063
    6164                // Return to the 'All Members' tab and 'Everything' filter,
    6265                // to avoid inconsistencies with the heartbeat integration
    63                 var $activity_all = jq( '#activity-all' );
    6466                if ( $activity_all.length  ) {
    6567                        if ( ! $activity_all.hasClass( 'selected' ) ) {
    6668                                // reset to everyting
    6769                                jq( '#activity-filter-select select' ).val( '-1' );
    68                                 $activity_all.children( 'a' ).trigger( "click" );
    69                         } else if ( '-1' != jq( '#activity-filter-select select' ).val() ) {
     70                                $activity_all.children( 'a' ).trigger( 'click' );
     71                        } else if ( '-1' !== jq( '#activity-filter-select select' ).val() ) {
    7072                                jq( '#activity-filter-select select' ).val( '-1' );
    7173                                jq( '#activity-filter-select select' ).trigger( 'change' );
     
    7678        /* On blur, shrink if it's empty */
    7779        $whats_new.blur( function(){
    78                 if ( document.activeElement != this ) {
     80                if ( document.activeElement !== this ) {
    7981                        if (!this.value.match(/\S+/)) {
    80                                 this.value = "";
    81                                 jq("#whats-new-options").animate({
     82                                this.value = '';
     83                                jq('#whats-new-options').animate({
    8284                                        height:'40px'
    8385                                });
    84                                 jq("form#whats-new-form textarea").animate({
     86                                jq('form#whats-new-form textarea').animate({
    8587                                        height:'20px'
    8688                                });
    87                                 jq("#aw-whats-new-submit").prop("disabled", true);
     89                                jq('#aw-whats-new-submit').prop('disabled', true);
    8890                        }
    8991                }
     
    9193
    9294        /* New posts */
    93         jq("#aw-whats-new-submit").on( 'click', function() {
    94                 var last_date_recorded = 0;
    95                 var button = jq(this);
    96                 var form = button.closest("form#whats-new-form");
     95        jq('#aw-whats-new-submit').on( 'click', function() {
     96                var last_date_recorded = 0,
     97                        button = jq(this),
     98                        form   = button.closest('form#whats-new-form');
    9799
    98100                form.children().each( function() {
    99                         if ( jq.nodeName(this, "textarea") || jq.nodeName(this, "input") )
     101                        if ( jq.nodeName(this, 'textarea') || jq.nodeName(this, 'input') ) {
    100102                                jq(this).prop( 'disabled', true );
     103                        }
    101104                });
    102105
     
    105108                button.addClass('loading');
    106109                button.prop('disabled', true);
    107                 form.addClass("submitted");
     110                form.addClass('submitted');
    108111
    109112                /* Default POST values */
    110                 var object = '';
    111                 var item_id = jq("#whats-new-post-in").val();
    112                 var content = jq("#whats-new").val();
    113                 var firstrow = jq( '#buddypress ul.activity-list li' ).first();
    114                 var activity_row = firstrow;
    115                 var timestamp = null;
     113                object = '';
     114                item_id = jq('#whats-new-post-in').val();
     115                content = jq('#whats-new').val();
     116                firstrow = jq( '#buddypress ul.activity-list li' ).first();
     117                activity_row = firstrow;
     118                timestamp = null;
    116119
    117120                // Checks if at least one activity exists
     
    124127                        timestamp = activity_row.prop( 'class' ).match( /date-recorded-([0-9]+)/ );
    125128                }
    126                
    127                 if ( timestamp ) {
     129
     130                if ( timestamp ) {
    128131                        last_date_recorded = timestamp[1];
    129132                }
     
    131134                /* Set object for non-profile posts */
    132135                if ( item_id > 0 ) {
    133                         object = jq("#whats-new-post-object").val();
     136                        object = jq('#whats-new-post-object').val();
    134137                }
    135138
     
    137140                        action: 'post_update',
    138141                        'cookie': bp_get_cookies(),
    139                         '_wpnonce_post_update': jq("#_wpnonce_post_update").val(),
     142                        '_wpnonce_post_update': jq('#_wpnonce_post_update').val(),
    140143                        'content': content,
    141144                        'object': object,
     
    147150
    148151                        form.children().each( function() {
    149                                 if ( jq.nodeName(this, "textarea") || jq.nodeName(this, "input") ) {
     152                                if ( jq.nodeName(this, 'textarea') || jq.nodeName(this, 'input') ) {
    150153                                        jq(this).prop( 'disabled', false );
    151154                                }
     
    153156
    154157                        /* Check for errors and append if found. */
    155                         if ( response[0] + response[1] == '-1' ) {
     158                        if ( response[0] + response[1] === '-1' ) {
    156159                                form.prepend( response.substr( 2, response.length ) );
    157160                                jq( '#' + form.attr('id') + ' div.error').hide().fadeIn( 200 );
    158161                        } else {
    159                                 if ( 0 == jq("ul.activity-list").length ) {
    160                                         jq("div.error").slideUp(100).remove();
    161                                         jq("#message").slideUp(100).remove();
    162                                         jq("div.activity").append( '<ul id="activity-stream" class="activity-list item-list">' );
     162                                if ( 0 === jq('ul.activity-list').length ) {
     163                                        jq('div.error').slideUp(100).remove();
     164                                        jq('#message').slideUp(100).remove();
     165                                        jq('div.activity').append( '<ul id="activity-stream" class="activity-list item-list">' );
    163166                                }
    164167
    165                                 if ( firstrow.hasClass( 'load-newest' ) )
     168                                if ( firstrow.hasClass( 'load-newest' ) ) {
    166169                                        firstrow.remove();
    167 
    168                                 jq("#activity-stream").prepend(response);
    169 
    170                                 if ( ! last_date_recorded )
    171                                         jq("#activity-stream li:first").addClass('new-update just-posted');
    172 
    173                                 if ( 0 != jq("#latest-update").length ) {
    174                                         var l = jq("#activity-stream li.new-update .activity-content .activity-inner p").html();
    175                                         var v = jq("#activity-stream li.new-update .activity-content .activity-header p a.view").attr('href');
    176 
    177                                         var ltext = jq("#activity-stream li.new-update .activity-content .activity-inner p").text();
    178 
    179                                         var u = '';
    180                                         if ( ltext != '' )
     170                                }
     171
     172                                jq('#activity-stream').prepend(response);
     173
     174                                if ( ! last_date_recorded ) {
     175                                        jq('#activity-stream li:first').addClass('new-update just-posted');
     176                                }
     177
     178                                if ( 0 !== jq('#latest-update').length ) {
     179                                        var l   = jq('#activity-stream li.new-update .activity-content .activity-inner p').html(),
     180                                                v     = jq('#activity-stream li.new-update .activity-content .activity-header p a.view').attr('href').
     181                                                ltext = jq('#activity-stream li.new-update .activity-content .activity-inner p').text(),
     182                                                u     = '';
     183
     184                                        if ( ltext !== '' ) {
    181185                                                u = l + ' ';
     186                                        }
    182187
    183188                                        u += '<a href="' + v + '" rel="nofollow">' + BP_DTheme.view + '</a>';
    184189
    185                                         jq("#latest-update").slideUp(300,function(){
    186                                                 jq("#latest-update").html( u );
    187                                                 jq("#latest-update").slideDown(300);
     190                                        jq('#latest-update').slideUp(300,function(){
     191                                                jq('#latest-update').html( u );
     192                                                jq('#latest-update').slideDown(300);
    188193                                        });
    189194                                }
    190195
    191                                 jq("li.new-update").hide().slideDown( 300 );
    192                                 jq("li.new-update").removeClass( 'new-update' );
    193                                 jq("#whats-new").val('');
     196                                jq('li.new-update').hide().slideDown( 300 );
     197                                jq('li.new-update').removeClass( 'new-update' );
     198                                jq('#whats-new').val('');
    194199
    195200                                // reset vars to get newest activities
     
    198203                        }
    199204
    200                         jq("#whats-new-options").animate({
     205                        jq('#whats-new-options').animate({
    201206                                height:'0px'
    202207                        });
    203                         jq("#whats-new-form textarea").animate({
     208                        jq('#whats-new-form textarea').animate({
    204209                                height:'20px'
    205210                        });
    206                         jq("#aw-whats-new-submit").prop("disabled", true).removeClass('loading');
     211                        jq('#aw-whats-new-submit').prop('disabled', true).removeClass('loading');
    207212                });
    208213
     
    212217        /* List tabs event delegation */
    213218        jq('div.activity-type-tabs').on( 'click', function(event) {
    214                 var target = jq(event.target).parent();
    215 
    216                 if ( event.target.nodeName == 'STRONG' || event.target.nodeName == 'SPAN' )
     219                var target = jq(event.target).parent(),
     220                        scope, filter;
     221
     222                if ( event.target.nodeName === 'STRONG' || event.target.nodeName === 'SPAN' ) {
    217223                        target = target.parent();
    218                 else if ( event.target.nodeName != 'A' )
    219                         return false;
     224                } else if ( event.target.nodeName !== 'A' ) {
     225                        return false;
     226                }
    220227
    221228                /* Reset the page */
     
    225232
    226233                /* Activity Stream Tabs */
    227                 var scope = target.attr('id').substr( 9, target.attr('id').length );
    228                 var filter = jq("#activity-filter-select select").val();
    229 
    230                 if ( scope == 'mentions' )
     234                scope = target.attr('id').substr( 9, target.attr('id').length );
     235                filter = jq('#activity-filter-select select').val();
     236
     237                if ( scope === 'mentions' ) {
    231238                        jq( '#' + target.attr('id') + ' a strong' ).remove();
     239                }
    232240
    233241                bp_activity_request(scope, filter);
     
    238246        /* Activity filter select */
    239247        jq('#activity-filter-select select').change( function() {
    240                 var selected_tab = jq( 'div.activity-type-tabs li.selected' );
    241 
    242                 if ( !selected_tab.length )
    243                         var scope = null;
    244                 else
    245                         var scope = selected_tab.attr('id').substr( 9, selected_tab.attr('id').length );
    246 
    247                 var filter = jq(this).val();
     248                var selected_tab = jq( 'div.activity-type-tabs li.selected' ),
     249                        filter = jq(this).val(),
     250                        scope;
     251
     252                if ( !selected_tab.length ) {
     253                        scope = null;
     254                } else {
     255                        scope = selected_tab.attr('id').substr( 9, selected_tab.attr('id').length );
     256                }
    248257
    249258                bp_activity_request(scope, filter);
     
    254263        /* Stream event delegation */
    255264        jq('div.activity').on( 'click', function(event) {
    256                 var target = jq(event.target);
     265                var target = jq(event.target),
     266                        type, parent, parent_id,
     267                        li, id, link_href, nonce, timestamp,
     268                        oldest_page, just_posted;
    257269
    258270                /* Favoriting activity stream items */
    259271                if ( target.hasClass('fav') || target.hasClass('unfav') ) {
    260                         var type = target.hasClass('fav') ? 'fav' : 'unfav';
    261                         var parent = target.closest('.activity-item');
    262                         var parent_id = parent.attr('id').substr( 9, parent.attr('id').length );
     272                        type      = target.hasClass('fav') ? 'fav' : 'unfav';
     273                        parent    = target.closest('.activity-item');
     274                        parent_id = parent.attr('id').substr( 9, parent.attr('id').length );
    263275
    264276                        target.addClass('loading');
     
    274286                                target.fadeOut( 200, function() {
    275287                                        jq(this).html(response);
    276                                         jq(this).attr('title', 'fav' == type ? BP_DTheme.remove_fav : BP_DTheme.mark_as_fav);
     288                                        jq(this).attr('title', 'fav' === type ? BP_DTheme.remove_fav : BP_DTheme.mark_as_fav);
    277289                                        jq(this).fadeIn(200);
    278290                                });
    279291
    280                                 if ( 'fav' == type ) {
     292                                if ( 'fav' === type ) {
    281293                                        if ( !jq('.item-list-tabs #activity-favs-personal-li').length ) {
    282                                                 if ( !jq('.item-list-tabs #activity-favorites').length )
     294                                                if ( !jq('.item-list-tabs #activity-favorites').length ) {
    283295                                                        jq('.item-list-tabs ul #activity-mentions').before( '<li id="activity-favorites"><a href="#">' + BP_DTheme.my_favs + ' <span>0</span></a></li>');
     296                                                }
    284297
    285298                                                jq('.item-list-tabs ul #activity-favorites span').html( Number( jq('.item-list-tabs ul #activity-favorites span').html() ) + 1 );
     
    296309
    297310                                        if ( !Number( jq('.item-list-tabs ul #activity-favorites span').html() ) ) {
    298                                                 if ( jq('.item-list-tabs ul #activity-favorites').hasClass('selected') )
     311                                                if ( jq('.item-list-tabs ul #activity-favorites').hasClass('selected') ) {
    299312                                                        bp_activity_request( null, null );
     313                                                }
    300314
    301315                                                jq('.item-list-tabs ul #activity-favorites').remove();
     
    303317                                }
    304318
    305                                 if ( 'activity-favorites' == jq( '.item-list-tabs li.selected').attr('id') )
     319                                if ( 'activity-favorites' === jq( '.item-list-tabs li.selected').attr('id') ) {
    306320                                        target.closest( '.activity-item' ).slideUp( 100 );
     321                                }
    307322                        });
    308323
     
    312327                /* Delete activity stream items */
    313328                if ( target.hasClass('delete-activity') ) {
    314                         var li        = target.parents('div.activity ul li');
    315                         var id        = li.attr('id').substr( 9, li.attr('id').length );
    316                         var link_href = target.attr('href');
    317                         var nonce     = link_href.split('_wpnonce=');
    318                         var timestamp = li.prop( 'class' ).match( /date-recorded-([0-9]+)/ );
    319 
    320                         nonce = nonce[1];
     329                        li        = target.parents('div.activity ul li');
     330                        id        = li.attr('id').substr( 9, li.attr('id').length );
     331                        link_href = target.attr('href');
     332                        nonce     = link_href.split('_wpnonce=');
     333                        timestamp = li.prop( 'class' ).match( /date-recorded-([0-9]+)/ );
     334                        nonce     = nonce[1];
    321335
    322336                        target.addClass('loading');
     
    330344                        function(response) {
    331345
    332                                 if ( response[0] + response[1] == '-1' ) {
     346                                if ( response[0] + response[1] === '-1' ) {
    333347                                        li.prepend( response.substr( 2, response.length ) );
    334348                                        li.children('#message').hide().fadeIn(300);
     
    337351
    338352                                        // reset vars to get newest activities
    339                                         if ( timestamp && activity_last_recorded == timestamp[1] ) {
     353                                        if ( timestamp && activity_last_recorded === timestamp[1] ) {
    340354                                                newest_activities = '';
    341355                                                activity_last_recorded  = 0;
     
    349363                // Spam activity stream items
    350364                if ( target.hasClass( 'spam-activity' ) ) {
    351                         var li        = target.parents( 'div.activity ul li' );
    352                         var timestamp = li.prop( 'class' ).match( /date-recorded-([0-9]+)/ );
     365                        li        = target.parents( 'div.activity ul li' );
     366                        timestamp = li.prop( 'class' ).match( /date-recorded-([0-9]+)/ );
    353367                        target.addClass( 'loading' );
    354368
     
    367381                                        li.slideUp( 300 );
    368382                                        // reset vars to get newest activities
    369                                         if ( timestamp && activity_last_recorded == timestamp[1] ) {
     383                                        if ( timestamp && activity_last_recorded === timestamp[1] ) {
    370384                                                newest_activities = '';
    371385                                                activity_last_recorded  = 0;
     
    379393                /* Load more updates at the end of the page */
    380394                if ( target.parent().hasClass('load-more') ) {
    381                         jq("#buddypress li.load-more").addClass('loading');
    382 
    383                         if ( null == jq.cookie('bp-activity-oldestpage') )
     395                        jq('#buddypress li.load-more').addClass('loading');
     396
     397                        if ( null === jq.cookie('bp-activity-oldestpage') ) {
    384398                                jq.cookie('bp-activity-oldestpage', 1, {
    385399                                        path: '/'
    386400                                } );
    387 
    388                         var oldest_page = ( jq.cookie('bp-activity-oldestpage') * 1 ) + 1;
    389 
    390                         var just_posted = [];
     401                        }
     402
     403                        oldest_page = ( jq.cookie('bp-activity-oldestpage') * 1 ) + 1;
     404                        just_posted = [];
    391405
    392406                        jq('.activity-list li.just-posted').each( function(){
     
    402416                        function(response)
    403417                        {
    404                                 jq("#buddypress li.load-more").removeClass('loading');
     418                                jq('#buddypress li.load-more').removeClass('loading');
    405419                                jq.cookie( 'bp-activity-oldestpage', oldest_page, {
    406420                                        path: '/'
    407421                                } );
    408                                 jq("#buddypress ul.activity-list").append(response.contents);
     422                                jq('#buddypress ul.activity-list').append(response.contents);
    409423
    410424                                target.parent().hide();
     
    429443                       
    430444                        jq.each( activity_html, function( i, el ){
    431                                 if( 'LI' == el.nodeName && jq(el).hasClass( 'just-posted' ) ) {
    432                                         if( jq( '#' + jq(el).attr( 'id' ) ).length )
     445                                if( 'LI' === el.nodeName && jq(el).hasClass( 'just-posted' ) ) {
     446                                        if( jq( '#' + jq(el).attr( 'id' ) ).length ) {
    433447                                                jq( '#' + jq(el).attr( 'id' ) ).remove();
     448                                        }
    434449                                }
    435450                        } );
     
    445460        // Activity "Read More" links
    446461        jq('div.activity').on('click', '.activity-read-more a', function(event) {
    447                 var target = jq(event.target);
    448                 var link_id = target.parent().attr('id').split('-');
    449                 var a_id = link_id[3];
    450                 var type = link_id[0]; /* activity or acomment */
    451 
    452                 var inner_class = type == 'acomment' ? 'acomment-content' : 'activity-inner';
    453                 var a_inner = jq('#' + type + '-' + a_id + ' .' + inner_class + ':first' );
     462                var target = jq(event.target),
     463                        link_id = target.parent().attr('id').split('-'),
     464                        a_id    = link_id[3],
     465                        type    = link_id[0], /* activity or acomment */
     466                        inner_class, a_inner;
     467
     468                inner_class = type === 'acomment' ? 'acomment-content' : 'activity-inner';
     469                a_inner = jq('#' + type + '-' + a_id + ' .' + inner_class + ':first' );
    454470                jq(target).addClass('loading');
    455471
     
    471487
    472488        /* Hide excess comments */
    473         if ( jq('.activity-comments').length )
     489        if ( jq('.activity-comments').length ) {
    474490                bp_legacy_theme_hide_comments();
     491        }
    475492
    476493        /* Activity list event delegation */
    477494        jq('div.activity').on( 'click', function(event) {
    478                 var target = jq(event.target);
     495                var target = jq(event.target),
     496                        id, ids, a_id, c_id, form,
     497                        form_parent, form_id,
     498                        tmp_id, comment_id, comment,
     499                        ajaxdata,
     500                        ak_nonce,
     501                        show_all_a, new_count,
     502                        link_href, comment_li, nonce;
    479503
    480504                /* Comment / comment reply links */
    481505                if ( target.hasClass('acomment-reply') || target.parent().hasClass('acomment-reply') ) {
    482                         if ( target.parent().hasClass('acomment-reply') )
     506                        if ( target.parent().hasClass('acomment-reply') ) {
    483507                                target = target.parent();
    484 
    485                         var id = target.attr('id');
     508                        }
     509
     510                        id  = target.attr('id');
    486511                        ids = id.split('-');
    487512
    488                         var a_id = ids[2]
    489                         var c_id = target.attr('href').substr( 10, target.attr('href').length );
    490                         var form = jq( '#ac-form-' + a_id );
     513                        a_id = ids[2];
     514                        c_id = target.attr('href').substr( 10, target.attr('href').length );
     515                        form = jq( '#ac-form-' + a_id );
    491516
    492517                        form.css( 'display', 'none' );
     
    496521                        /* Hide any error messages */
    497522                        form.children('div').each( function() {
    498                                 if ( jq(this).hasClass( 'error' ) )
     523                                if ( jq(this).hasClass( 'error' ) ) {
    499524                                        jq(this).hide();
     525                                }
    500526                        });
    501527
    502                         if ( ids[1] != 'comment' ) {
     528                        if ( ids[1] !== 'comment' ) {
    503529                                jq('#acomment-' + c_id).append( form );
    504530                        } else {
     
    506532                        }
    507533
    508                         if ( form.parent().hasClass( 'activity-comments' ) )
     534                        if ( form.parent().hasClass( 'activity-comments' ) ) {
    509535                                form.addClass('root');
     536                        }
    510537
    511538                        form.slideDown( 200 );
     
    520547
    521548                /* Activity comment posting */
    522                 if ( target.attr('name') == 'ac_form_submit' ) {
    523                         var form = target.parents( 'form' );
    524                         var form_parent = form.parent();
    525                         var form_id = form.attr('id').split('-');
     549                if ( target.attr('name') === 'ac_form_submit' ) {
     550                        form = target.parents( 'form' );
     551                        form_parent = form.parent();
     552                        form_id = form.attr('id').split('-');
    526553
    527554                        if ( !form_parent.hasClass('activity-comments') ) {
    528                                 var tmp_id = form_parent.attr('id').split('-');
    529                                 var comment_id = tmp_id[1];
     555                                tmp_id = form_parent.attr('id').split('-');
     556                                comment_id = tmp_id[1];
    530557                        } else {
    531                                 var comment_id = form_id[2];
    532                         }
    533 
    534                         var content = jq( '#' + form.attr('id') + ' textarea' );
     558                                comment_id = form_id[2];
     559                        }
     560
     561                        content = jq( '#' + form.attr('id') + ' textarea' );
    535562
    536563                        /* Hide any error messages */
     
    539566                        content.addClass('loading').prop('disabled', true);
    540567
    541                         var ajaxdata = {
     568                        ajaxdata = {
    542569                                action: 'new_activity_comment',
    543570                                'cookie': bp_get_cookies(),
    544                                 '_wpnonce_new_activity_comment': jq("#_wpnonce_new_activity_comment").val(),
     571                                '_wpnonce_new_activity_comment': jq('#_wpnonce_new_activity_comment').val(),
    545572                                'comment_id': comment_id,
    546573                                'form_id': form_id[2],
     
    549576
    550577                        // Akismet
    551                         var ak_nonce = jq('#_bp_as_nonce_' + comment_id).val();
     578                        ak_nonce = jq('#_bp_as_nonce_' + comment_id).val();
    552579                        if ( ak_nonce ) {
    553580                                ajaxdata['_bp_as_nonce_' + comment_id] = ak_nonce;
     
    559586
    560587                                /* Check for errors and append if found. */
    561                                 if ( response[0] + response[1] == '-1' ) {
     588                                if ( response[0] + response[1] === '-1' ) {
    562589                                        form.append( jq( response.substr( 2, response.length ) ).hide().fadeIn( 200 ) );
    563590                                } else {
    564591                                        var activity_comments = form.parent();
    565592                                        form.fadeOut( 200, function() {
    566                                                 if ( 0 == activity_comments.children('ul').length ) {
     593                                                if ( 0 === activity_comments.children('ul').length ) {
    567594                                                        if ( activity_comments.hasClass('activity-comments') ) {
    568595                                                                activity_comments.prepend('<ul></ul>');
     
    585612
    586613                                        // Increment the 'Show all x comments' string, if present
    587                                         var show_all_a = activity_comments.find('.show-all').find('a');
     614                                        show_all_a = activity_comments.find('.show-all').find('a');
    588615                                        if ( show_all_a ) {
    589                                                 var new_count = jq('li#activity-' + form_id[2] + ' a.acomment-reply span').html();
     616                                                new_count = jq('li#activity-' + form_id[2] + ' a.acomment-reply span').html();
    590617                                                show_all_a.html( BP_DTheme.show_x_comments.replace( '%d', new_count ) );
    591618                                        }
    592619                                }
    593620
    594                                 jq(target).prop("disabled", false);
    595                                 jq(content).prop("disabled", false);
     621                                jq(target).prop('disabled', false);
     622                                jq(content).prop('disabled', false);
    596623                        });
    597624
     
    601628                /* Deleting an activity comment */
    602629                if ( target.hasClass('acomment-delete') ) {
    603                         var link_href = target.attr('href');
    604                         var comment_li = target.parent().parent();
    605                         var form = comment_li.parents('div.activity-comments').children('form');
    606 
    607                         var nonce = link_href.split('_wpnonce=');
     630                        link_href = target.attr('href');
     631                        comment_li = target.parent().parent();
     632                        form = comment_li.parents('div.activity-comments').children('form');
     633
     634                        nonce = link_href.split('_wpnonce=');
    608635                        nonce = nonce[1];
    609636
    610                         var comment_id = link_href.split('cid=');
     637                        comment_id = link_href.split('cid=');
    611638                        comment_id = comment_id[1].split('&');
    612639                        comment_id = comment_id[0];
     
    628655                        function(response) {
    629656                                /* Check for errors and append if found. */
    630                                 if ( response[0] + response[1] == '-1' ) {
     657                                if ( response[0] + response[1] === '-1' ) {
    631658                                        comment_li.prepend( jq( response.substr( 2, response.length ) ).hide().fadeIn( 200 ) );
    632659                                } else {
    633                                         var children = jq( '#' + comment_li.attr('id') + ' ul' ).children('li');
    634                                         var child_count = 0;
     660                                        var children  = jq( '#' + comment_li.attr('id') + ' ul' ).children('li');
     661                                                child_count = 0,
     662                                                count_span, new_count, show_all_a;
     663
    635664                                        jq(children).each( function() {
    636                                                 if ( !jq(this).is(':hidden') )
     665                                                if ( !jq(this).is(':hidden') ) {
    637666                                                        child_count++;
     667                                                }
    638668                                        });
    639669                                        comment_li.fadeOut(200, function() {
     
    642672
    643673                                        /* Decrease the "Reply (X)" button count */
    644                                         var count_span = jq('#' + comment_li.parents('#activity-stream > li').attr('id') + ' a.acomment-reply span');
    645                                         var new_count = count_span.html() - ( 1 + child_count );
     674                                        count_span = jq('#' + comment_li.parents('#activity-stream > li').attr('id') + ' a.acomment-reply span');
     675                                        new_count = count_span.html() - ( 1 + child_count );
    646676                                        count_span.html(new_count);
    647677
    648678                                        // Change the 'Show all x comments' text
    649                                         var show_all_a = comment_li.siblings('.show-all').find('a');
     679                                        show_all_a = comment_li.siblings('.show-all').find('a');
    650680                                        if ( show_all_a ) {
    651681                                                show_all_a.html( BP_DTheme.show_x_comments.replace( '%d', new_count ) );
     
    653683
    654684                                        /* If that was the last comment for the item, remove the has-comments class to clean up the styling */
    655                                         if ( 0 == new_count ) {
     685                                        if ( 0 === new_count ) {
    656686                                                jq(comment_li.parents('#activity-stream > li')).removeClass('has-comments');
    657687                                        }
     
    664694                // Spam an activity stream comment
    665695                if ( target.hasClass( 'spam-activity-comment' ) ) {
    666                         var link_href  = target.attr( 'href' );
    667                         var comment_li = target.parent().parent();
     696                        link_href  = target.attr( 'href' );
     697                        comment_li = target.parent().parent();
    668698
    669699                        target.addClass('loading');
     
    684714                        function ( response ) {
    685715                                // Check for errors and append if found.
    686                                 if ( response[0] + response[1] == '-1' ) {
     716                                if ( response[0] + response[1] === '-1' ) {
    687717                                        comment_li.prepend( jq( response.substr( 2, response.length ) ).hide().fadeIn( 200 ) );
    688718
    689719                                } else {
    690                                         var children = jq( '#' + comment_li.attr( 'id' ) + ' ul' ).children( 'li' );
    691                                         var child_count = 0;
     720                                        var children  = jq( '#' + comment_li.attr( 'id' ) + ' ul' ).children( 'li' ),
     721                                                child_count = 0,
     722                                                parent_li;
     723
    692724                                        jq(children).each( function() {
    693725                                                if ( !jq( this ).is( ':hidden' ) ) {
     
    698730
    699731                                        // Decrease the "Reply (X)" button count
    700                                         var parent_li = comment_li.parents( '#activity-stream > li' );
     732                                        parent_li = comment_li.parents( '#activity-stream > li' );
    701733                                        jq( '#' + parent_li.attr( 'id' ) + ' a.acomment-reply span' ).html( jq( '#' + parent_li.attr( 'id' ) + ' a.acomment-reply span' ).html() - ( 1 + child_count ) );
    702734                                }
     
    723755                        jq(target).closest('.ac-form').slideUp( 200 );
    724756                        return false;
    725                 };
     757                }
    726758        });
    727759
     
    729761        jq(document).keydown( function(e) {
    730762                e = e || window.event;
    731                 if (e.target)
     763                if (e.target) {
    732764                        element = e.target;
    733                 else if (e.srcElement)
     765                } else if (e.srcElement) {
    734766                        element = e.srcElement;
    735 
    736                 if( element.nodeType == 3)
     767                }
     768
     769                if( element.nodeType === 3) {
    737770                        element = element.parentNode;
    738 
    739                 if( e.ctrlKey == true || e.altKey == true || e.metaKey == true )
     771                }
     772
     773                if( e.ctrlKey === true || e.altKey === true || e.metaKey === true ) {
    740774                        return;
     775                }
    741776
    742777                var keyCode = (e.keyCode) ? e.keyCode : e.which;
    743778
    744                 if ( keyCode == 27 ) {
    745                         if (element.tagName == 'TEXTAREA') {
    746                                 if ( jq(element).hasClass('ac-input') )
     779                if ( keyCode === 27 ) {
     780                        if (element.tagName === 'TEXTAREA') {
     781                                if ( jq(element).hasClass('ac-input') ) {
    747782                                        jq(element).parent().parent().parent().slideUp( 200 );
     783                                }
    748784                        }
    749785                }
     
    754790        /* The search form on all directory pages */
    755791        jq( '.dir-search, .groups-members-search' ).on( 'click', function(event) {
    756                 if ( jq(this).hasClass('no-ajax') )
     792                if ( jq(this).hasClass('no-ajax') ) {
    757793                        return;
    758 
    759                 var target = jq(event.target);
    760 
    761                 if ( target.attr('type') == 'submit' ) {
    762                         var css_id = jq('.item-list-tabs li.selected').attr('id').split( '-' );
    763                         var object = css_id[0];
    764                         var template = null;
     794                }
     795
     796                var target = jq(event.target),
     797                        css_id, object, template;
     798
     799                if ( target.attr('type') === 'submit' ) {
     800                        css_id = jq('.item-list-tabs li.selected').attr('id').split( '-' );
     801                        object = css_id[0];
     802                        template = null;
    765803
    766804                        // The Group Members page specifies its own template
    767                         if ( 'members' == object && 'groups' == css_id[1] ) {
     805                        if ( 'members' === object && 'groups' === css_id[1] ) {
    768806                                object = 'group_members';
    769807                                template = 'groups/single/members';
     
    780818        /* When a navigation tab is clicked - e.g. | All Groups | My Groups | */
    781819        jq('div.item-list-tabs').on( 'click', function(event) {
    782                 if ( jq(this).hasClass('no-ajax') )
     820                if ( jq(this).hasClass('no-ajax') )  {
    783821                        return;
    784 
    785                 var targetElem = ( event.target.nodeName == 'SPAN' ) ? event.target.parentNode : event.target;
    786                 var target     = jq( targetElem ).parent();
    787                 if ( 'LI' == target[0].nodeName && !target.hasClass( 'last' ) ) {
    788                         var css_id = target.attr('id').split( '-' );
    789                         var object = css_id[0];
    790 
    791                         if ( 'activity' == object )
     822                }
     823
     824                var targetElem = ( event.target.nodeName === 'SPAN' ) ? event.target.parentNode : event.target.
     825                        target       = jq( targetElem ).parent(),
     826                        css_id, object, scope, filter, search_terms;
     827
     828                if ( 'LI' === target[0].nodeName && !target.hasClass( 'last' ) ) {
     829                        css_id = target.attr('id').split( '-' );
     830                        object = css_id[0];
     831
     832                        if ( 'activity' === object ) {
    792833                                return false;
    793 
    794                         var scope = css_id[1];
    795                         var filter = jq("#" + object + "-order-select select").val();
    796                         var search_terms = jq("#" + object + "_search").val();
     834                        }
     835
     836                        scope = css_id[1];
     837                        filter = jq('#" + object + "-order-select select').val();
     838                        search_terms = jq('#" + object + "_search').val();
    797839
    798840                        bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras') );
     
    804846        /* When the filter select box is changed re-query */
    805847        jq('li.filter select').change( function() {
    806                 if ( jq('.item-list-tabs li.selected').length )
    807                         var el = jq('.item-list-tabs li.selected');
    808                 else
    809                         var el = jq(this);
    810 
    811                 var css_id = el.attr('id').split('-');
    812                 var object = css_id[0];
    813                 var scope = css_id[1];
    814                 var filter = jq(this).val();
    815                 var search_terms = false;
    816                 var template = null;
    817 
    818                 if ( jq('.dir-search input').length )
     848                var el,
     849                        css_id, object, scope, filter, search_terms, template,
     850                        $gm_search;
     851
     852                if ( jq('.item-list-tabs li.selected').length ) {
     853                        el = jq('.item-list-tabs li.selected');
     854                } else {
     855                        el = jq(this);
     856                }
     857
     858                css_id = el.attr('id').split('-');
     859                object = css_id[0];
     860                scope = css_id[1];
     861                filter = jq(this).val();
     862                search_terms = false;
     863                template = null;
     864
     865                if ( jq('.dir-search input').length ) {
    819866                        search_terms = jq('.dir-search input').val();
     867                }
    820868
    821869                // The Group Members page has a different selector for its
    822870                // search terms box
    823                 var $gm_search = jq( '.groups-members-search input' );
     871                $gm_search = jq( '.groups-members-search input' );
    824872                if ( $gm_search.length ) {
    825873                        search_terms = $gm_search.val();
     
    827875
    828876                // On the Groups Members page, we specify a template
    829                 if ( 'members' == object && 'groups' == scope ) {
     877                if ( 'members' === object && 'groups' === scope ) {
    830878                        object = 'group_members';
    831879                        template = 'groups/single/members';
    832880                }
    833881
    834                 if ( 'friends' == object )
     882                if ( 'friends' === object ) {
    835883                        object = 'members';
     884                }
    836885
    837886                bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras'), null, template );
     
    842891        /* All pagination links run through this function */
    843892        jq('#buddypress').on( 'click', function(event) {
    844                 var target = jq(event.target);
    845 
    846                 if ( target.hasClass('button') )
     893                var target = jq(event.target),
     894                        el,
     895                        css_id, object, search_terms, pagination_id, template, page_number,
     896                        $gm_search,
     897                        caller;
     898
     899                if ( target.hasClass('button') ) {
    847900                        return true;
     901                }
    848902
    849903                if ( target.parent().parent().hasClass('pagination') && !target.parent().parent().hasClass('no-ajax') ) {
    850                         if ( target.hasClass('dots') || target.hasClass('current') )
     904                        if ( target.hasClass('dots') || target.hasClass('current') ) {
    851905                                return false;
    852 
    853                         if ( jq('.item-list-tabs li.selected').length )
    854                                 var el = jq('.item-list-tabs li.selected');
    855                         else
    856                                 var el = jq('li.filter select');
    857 
    858                         var css_id = el.attr('id').split( '-' );
    859                         var object = css_id[0];
    860                         var search_terms = false;
    861                         var pagination_id = jq(target).closest('.pagination-links').attr('id');
    862                         var template = null;
    863 
    864                         var page_number = target.attr('href').split( '=' );
     906                        }
     907
     908                        if ( jq('.item-list-tabs li.selected').length ) {
     909                                el = jq('.item-list-tabs li.selected');
     910                        } else {
     911                                el = jq('li.filter select');
     912                        }
     913
     914                        css_id = el.attr('id').split( '-' );
     915                        object = css_id[0];
     916                        search_terms = false;
     917                        pagination_id = jq(target).closest('.pagination-links').attr('id');
     918                        template = null;
     919
     920                        page_number = target.attr('href').split( '=' );
    865921                        page_number = page_number[1];
    866922
    867923                        // Search terms
    868                         if ( jq('div.dir-search input').length )
     924                        if ( jq('div.dir-search input').length ) {
    869925                                search_terms = jq('.dir-search input').val();
     926                        }
    870927
    871928                        // The Group Members page has a different selector for
    872929                        // its search terms box
    873                         var $gm_search = jq( '.groups-members-search input' );
     930                        $gm_search = jq( '.groups-members-search input' );
    874931                        if ( $gm_search.length ) {
    875932                                search_terms = $gm_search.val();
     
    877934
    878935                        // On the Groups Members page, we specify a template
    879                         if ( 'members' == object && 'groups' == css_id[1] ) {
     936                        if ( 'members' === object && 'groups' === css_id[1] ) {
    880937                                object = 'group_members';
    881938                                template = 'groups/single/members';
     
    884941                        // On the Admin > Requests page, we need to reset the object,
    885942                        // since "admin" isn't specific enough
    886                         if ( 'admin' == object && jq( 'body' ).hasClass( 'membership-requests' ) ) {
     943                        if ( 'admin' === object && jq( 'body' ).hasClass( 'membership-requests' ) ) {
    887944                                object = 'requests';
    888945                        }
    889946
    890947                        if ( pagination_id.indexOf( 'pag-bottom' ) !== -1 ) {
    891                                 var caller = 'pag-bottom';
     948                                caller = 'pag-bottom';
    892949                        } else {
    893                                 var caller = null;
     950                                caller = null;
    894951                        }
    895952
     
    905962        /* Hit the "New Topic" button on the forums directory page */
    906963        jq('a.show-hide-new').on( 'click', function() {
    907                 if ( !jq('#new-topic-post').length )
    908                         return false;
    909 
    910                 if ( jq('#new-topic-post').is(":visible") )
     964                if ( !jq('#new-topic-post').length ) {
     965                        return false;
     966                }
     967
     968                if ( jq('#new-topic-post').is(':visible') ) {
    911969                        jq('#new-topic-post').slideUp(200);
    912                 else
     970                } else {
    913971                        jq('#new-topic-post').slideDown(200, function() {
    914972                                jq('#topic_title').focus();
    915973                        } );
     974                }
    916975
    917976                return false;
     
    920979        /* Cancel the posting of a new forum topic */
    921980        jq('#submit_topic_cancel').on( 'click', function() {
    922                 if ( !jq('#new-topic-post').length )
    923                         return false;
     981                if ( !jq('#new-topic-post').length ) {
     982                        return false;
     983                }
    924984
    925985                jq('#new-topic-post').slideUp(200);
     
    936996
    937997        /* Select a user from the list of friends and add them to the invite list */
    938         jq("#send-invite-form").on( 'click', '#invite-list input', function() {
     998        jq('#send-invite-form').on( 'click', '#invite-list input', function() {
    939999                // invites-loop template contains a div with the .invite class
    9401000                // We use the existence of this div to check for old- vs new-
    9411001                // style templates.
    942                 var invites_new_template = jq( "#send-invite-form > .invite" ).length;
     1002                var invites_new_template = jq( '#send-invite-form > .invite' ).length,
     1003                        friend_id, friend_action;
    9431004
    9441005                jq('.ajax-loader').toggle();
     
    9491010                }
    9501011
    951                 var friend_id = jq(this).val();
    952 
    953                 if ( jq(this).prop('checked') == true ) {
    954                         var friend_action = 'invite';
     1012                friend_id = jq(this).val();
     1013
     1014                if ( jq(this).prop('checked') === true ) {
     1015                        friend_action = 'invite';
    9551016                } else {
    956                         var friend_action = 'uninvite';
     1017                        friend_action = 'uninvite';
    9571018                }
    9581019
     
    9651026                        'friend_action': friend_action,
    9661027                        'cookie': bp_get_cookies(),
    967                         '_wpnonce': jq("#_wpnonce_invite_uninvite_user").val(),
     1028                        '_wpnonce': jq('#_wpnonce_invite_uninvite_user').val(),
    9681029                        'friend_id': friend_id,
    969                         'group_id': jq("#group_id").val()
     1030                        'group_id': jq('#group_id').val()
    9701031                },
    9711032                function(response)
    9721033                {
    973                         if ( jq("#message") ) {
    974                                 jq("#message").hide();
     1034                        if ( jq('#message') ) {
     1035                                jq('#message').hide();
    9751036                        }
    9761037
     
    9841045                                jq('.ajax-loader').toggle();
    9851046
    986                                 if ( friend_action == 'invite' ) {
     1047                                if ( friend_action === 'invite' ) {
    9871048                                        jq('#friend-list').append(response);
    988                                 } else if ( friend_action == 'uninvite' ) {
     1049                                } else if ( friend_action === 'uninvite' ) {
    9891050                                        jq('#friend-list li#uid-' + friend_id).remove();
    9901051                                }
     
    9961057
    9971058        /* Remove a user from the list of users to invite to a group */
    998         jq("#send-invite-form").on('click', 'a.remove', function() {
     1059        jq('#send-invite-form').on('click', 'a.remove', function() {
    9991060                // invites-loop template contains a div with the .invite class
    10001061                // We use the existence of this div to check for old- vs new-
    10011062                // style templates.
    1002                 var invites_new_template = jq("#send-invite-form > .invite").length;
     1063                var invites_new_template = jq('#send-invite-form > .invite').length,
     1064                        friend_id = jq(this).attr('id');
    10031065
    10041066                jq('.ajax-loader').toggle();
    10051067
    1006                 var friend_id = jq(this).attr('id');
    10071068                friend_id = friend_id.split('-');
    10081069                friend_id = friend_id[1];
     
    10121073                        'friend_action': 'uninvite',
    10131074                        'cookie': bp_get_cookies(),
    1014                         '_wpnonce': jq("#_wpnonce_invite_uninvite_user").val(),
     1075                        '_wpnonce': jq('#_wpnonce_invite_uninvite_user').val(),
    10151076                        'friend_id': friend_id,
    1016                         'group_id': jq("#group_id").val()
     1077                        'group_id': jq('#group_id').val()
    10171078                },
    10181079                function(response)
     
    10541115        } );
    10551116
    1056         jq("#profile-edit-form input:not(:submit), #profile-edit-form textarea, #profile-edit-form select, #signup_form input:not(:submit), #signup_form textarea, #signup_form select").change( function() {
     1117        jq('#profile-edit-form input:not(:submit), #profile-edit-form textarea, #profile-edit-form select, #signup_form input:not(:submit), #signup_form textarea, #signup_form select').change( function() {
    10571118                var shouldconfirm = true;
    10581119
     
    10711132
    10721133        /* Accept and Reject friendship request buttons */
    1073         jq("#friend-list a.accept, #friend-list a.reject").on( 'click', function() {
    1074                 var button = jq(this);
    1075                 var li = jq(this).parents('#friend-list li');
    1076                 var action_div = jq(this).parents('li div.action');
    1077 
    1078                 var id = li.attr('id').substr( 11, li.attr('id').length );
    1079                 var link_href = button.attr('href');
    1080 
    1081                 var nonce = link_href.split('_wpnonce=');
    1082                 nonce = nonce[1];
    1083 
    1084                 if ( jq(this).hasClass('accepted') || jq(this).hasClass('rejected') )
    1085                         return false;
     1134        jq('#friend-list a.accept, #friend-list a.reject').on( 'click', function() {
     1135                var button   = jq(this),
     1136                        li         = jq(this).parents('#friend-list li'),
     1137                        action_div = jq(this).parents('li div.action'),
     1138                        id         = li.attr('id').substr( 11, li.attr('id').length ),
     1139                        link_href  = button.attr('href'),
     1140                        nonce      = link_href.split('_wpnonce=')[1],
     1141                        action;
     1142
     1143                if ( jq(this).hasClass('accepted') || jq(this).hasClass('rejected') ) {
     1144                        return false;
     1145                }
    10861146
    10871147                if ( jq(this).hasClass('accept') ) {
    1088                         var action = 'accept_friendship';
     1148                        action = 'accept_friendship';
    10891149                        action_div.children('a.reject').css( 'visibility', 'hidden' );
    10901150                } else {
    1091                         var action = 'reject_friendship';
     1151                        action = 'reject_friendship';
    10921152                        action_div.children('a.accept').css( 'visibility', 'hidden' );
    10931153                }
     
    11041164                        button.removeClass('loading');
    11051165
    1106                         if ( response[0] + response[1] == '-1' ) {
     1166                        if ( response[0] + response[1] === '-1' ) {
    11071167                                li.prepend( response.substr( 2, response.length ) );
    11081168                                li.children('#message').hide().fadeIn(200);
     
    11261186        jq( '#members-dir-list, #members-group-list' ).on('click', '.friendship-button a', function() {
    11271187                jq(this).parent().addClass('loading');
    1128                 var fid = jq(this).attr('id');
     1188                var fid   = jq(this).attr('id'),
     1189                        nonce   = jq(this).attr('href'),
     1190                        thelink = jq(this);
     1191
    11291192                fid = fid.split('-');
    11301193                fid = fid[1];
    11311194
    1132                 var nonce = jq(this).attr('href');
    11331195                nonce = nonce.split('?_wpnonce=');
    11341196                nonce = nonce[1].split('&');
    11351197                nonce = nonce[0];
    1136 
    1137                 var thelink = jq(this);
    11381198
    11391199                jq.post( ajaxurl, {
     
    11451205                function(response)
    11461206                {
    1147                         var action = thelink.attr('rel');
    1148                         var parentdiv = thelink.parent();
    1149 
    1150                         if ( action == 'add' ) {
     1207                        var action  = thelink.attr('rel');
     1208                                parentdiv = thelink.parent();
     1209
     1210                        if ( action === 'add' ) {
    11511211                                jq(parentdiv).fadeOut(200,
    11521212                                        function() {
     
    11581218                                        );
    11591219
    1160                         } else if ( action == 'remove' ) {
     1220                        } else if ( action === 'remove' ) {
    11611221                                jq(parentdiv).fadeOut(200,
    11621222                                        function() {
     
    11761236        // Confirmation when clicking Leave Group in group headers
    11771237        jq('#buddypress').on('click', '.group-button .leave-group', function() {
    1178                 if ( false == confirm( BP_DTheme.leave_group_confirm ) ) {
     1238                if ( false === confirm( BP_DTheme.leave_group_confirm ) ) {
    11791239                        return false;
    11801240                }
     
    11821242
    11831243        jq('#groups-dir-list').on('click', '.group-button a', function() {
    1184                 var gid = jq(this).parent().attr('id');
     1244                var gid   = jq(this).parent().attr('id').
     1245                        nonce   = jq(this).attr('href'),
     1246                        thelink = jq(this);
     1247
    11851248                gid = gid.split('-');
    11861249                gid = gid[1];
    11871250
    1188                 var nonce = jq(this).attr('href');
    11891251                nonce = nonce.split('?_wpnonce=');
    11901252                nonce = nonce[1].split('&');
    11911253                nonce = nonce[0];
    11921254
    1193                 var thelink = jq(this);
    1194 
    11951255                // Leave Group confirmation within directories - must intercept
    11961256                // AJAX request
    1197                 if ( thelink.hasClass( 'leave-group' ) && false == confirm( BP_DTheme.leave_group_confirm ) ) {
     1257                if ( thelink.hasClass( 'leave-group' ) && false === confirm( BP_DTheme.leave_group_confirm ) ) {
    11981258                        return false;
    11991259                }
     
    12191279                                                parentdiv.fadeIn(200).html(response);
    12201280
    1221                                                 var mygroups = jq('#groups-personal span');
    1222                                                 var add      = 1;
     1281                                                var mygroups = jq('#groups-personal span'),
     1282                                                        add        = 1;
    12231283
    12241284                                                if( thelink.hasClass( 'leave-group' ) ) {
     
    12591319        /** Message search*/
    12601320        jq('.message-search').on( 'click', function(event) {
    1261                 if ( jq(this).hasClass('no-ajax') )
     1321                if ( jq(this).hasClass('no-ajax') ) {
    12621322                        return;
    1263 
    1264                 var target = jq(event.target);
    1265 
    1266                 if ( target.attr('type') == 'submit' ) {
     1323                }
     1324
     1325                var target = jq(event.target),
     1326                        object;
     1327
     1328                if ( target.attr('type') === 'submit' ) {
    12671329                        //var css_id = jq('.item-list-tabs li.selected').attr('id').split( '-' );
    1268                         var object = 'messages';
     1330                        object = 'messages';
    12691331
    12701332                        bp_filter_request( object, jq.cookie('bp-' + object + '-filter'), jq.cookie('bp-' + object + '-scope') , 'div.' + object, target.parent().children('label').children('input').val(), 1, jq.cookie('bp-' + object + '-extras') );
     
    12751337
    12761338        /* AJAX send reply functionality */
    1277         jq("#send_reply_button").click(
     1339        jq('#send_reply_button').click(
    12781340                function() {
    12791341                        var order = jq('#messages_order').val() || 'ASC',
    1280                         offset = jq('#message-recipients').offset();
    1281 
    1282                         var button = jq("#send_reply_button");
     1342                                offset  = jq('#message-recipients').offset(),
     1343                                button  = jq('#send_reply_button');
     1344
    12831345                        jq(button).addClass('loading');
    12841346
     
    12861348                                action: 'messages_send_reply',
    12871349                                'cookie': bp_get_cookies(),
    1288                                 '_wpnonce': jq("#send_message_nonce").val(),
    1289 
    1290                                 'content': jq("#message_content").val(),
    1291                                 'send_to': jq("#send_to").val(),
    1292                                 'subject': jq("#subject").val(),
    1293                                 'thread_id': jq("#thread_id").val()
     1350                                '_wpnonce': jq('#send_message_nonce').val(),
     1351
     1352                                'content': jq('#message_content').val(),
     1353                                'send_to': jq('#send_to').val(),
     1354                                'subject': jq('#subject').val(),
     1355                                'thread_id': jq('#thread_id').val()
    12941356                        },
    12951357                        function(response)
    12961358                        {
    1297                                 if ( response[0] + response[1] == "-1" ) {
     1359                                if ( response[0] + response[1] === '-1' ) {
    12981360                                        jq('#send-reply').prepend( response.substr( 2, response.length ) );
    12991361                                } else {
    13001362                                        jq('#send-reply #message').remove();
    1301                                         jq("#message_content").val('');
    1302 
    1303                                         if ( 'ASC' == order ) {
     1363                                        jq('#message_content').val('');
     1364
     1365                                        if ( 'ASC' === order ) {
    13041366                                                jq('#send-reply').before( response );
    13051367                                        } else {
     
    13081370                                        }
    13091371
    1310                                         jq(".new-message").hide().slideDown( 200, function() {
     1372                                        jq('.new-message').hide().slideDown( 200, function() {
    13111373                                                jq('.new-message').removeClass('new-message');
    13121374                                        });
     
    13201382
    13211383        /* Marking private messages as read and unread */
    1322         jq("#mark_as_read, #mark_as_unread").click(function() {
    1323                 var checkboxes_tosend = '';
    1324                 var checkboxes = jq("#message-threads tr td input[type='checkbox']");
    1325 
    1326                 if ( 'mark_as_unread' == jq(this).attr('id') ) {
    1327                         var currentClass = 'read'
    1328                         var newClass = 'unread'
    1329                         var unreadCount = 1;
    1330                         var inboxCount = 0;
    1331                         var unreadCountDisplay = 'inline';
    1332                         var action = 'messages_markunread';
     1384        jq('#mark_as_read, #mark_as_unread').click(function() {
     1385                var checkboxes_tosend = '',
     1386                        checkboxes = jq('#message-threads tr td input[type="checkbox"]'),
     1387                        currentClass, newClass, unreadCount, inboxCount, unreadCountDisplay, action,
     1388                        inboxcount, thread_count;
     1389
     1390                if ( 'mark_as_unread' === jq(this).attr('id') ) {
     1391                        currentClass = 'read';
     1392                        newClass = 'unread';
     1393                        unreadCount = 1;
     1394                        inboxCount = 0;
     1395                        unreadCountDisplay = 'inline';
     1396                        action = 'messages_markunread';
    13331397                } else {
    1334                         var currentClass = 'unread'
    1335                         var newClass = 'read'
    1336                         var unreadCount = 0;
    1337                         var inboxCount = 1;
    1338                         var unreadCountDisplay = 'none';
    1339                         var action = 'messages_markread';
     1398                        currentClass = 'unread';
     1399                        newClass = 'read';
     1400                        unreadCount = 0;
     1401                        inboxCount = 1;
     1402                        unreadCountDisplay = 'none';
     1403                        action = 'messages_markread';
    13401404                }
    13411405
     
    13461410                                        jq('#m-' + jq(this).attr('value')).removeClass(currentClass);
    13471411                                        jq('#m-' + jq(this).attr('value')).addClass(newClass);
    1348                                         var thread_count = jq('#m-' + jq(this).attr('value') + ' td span.unread-count').html();
     1412                                        thread_count = jq('#m-' + jq(this).attr('value') + ' td span.unread-count').html();
    13491413
    13501414                                        jq('#m-' + jq(this).attr('value') + ' td span.unread-count').html(unreadCount);
    13511415                                        jq('#m-' + jq(this).attr('value') + ' td span.unread-count').css('display', unreadCountDisplay);
    13521416
    1353                                         var inboxcount = jq('tr.unread').length;
     1417                                        inboxcount = jq('tr.unread').length;
    13541418
    13551419                                        jq('#user-messages span').html( inboxcount );
    13561420
    1357                                         if ( i != checkboxes.length - 1 ) {
    1358                                                 checkboxes_tosend += ','
     1421                                        if ( i !== checkboxes.length - 1 ) {
     1422                                                checkboxes_tosend += ',';
    13591423                                        }
    13601424                                }
     
    13701434        /* Selecting unread and read messages in inbox */
    13711435        jq( 'body.messages #item-body div.messages' ).on( 'change', '#message-type-select', function() {
    1372                 var selection = this.value;
    1373                 var checkboxes = jq( "td input[type='checkbox']" );
     1436                var selection   = this.value,
     1437                        checkboxes    = jq( 'td input[type="checkbox"]' ),
     1438                        checked_value = 'checked';
    13741439
    13751440                checkboxes.each( function(i) {
    1376                         checkboxes[i].checked = "";
    1377                 });
    1378 
    1379                 var checked_value = "checked";
     1441                        checkboxes[i].checked = '';
     1442                });
     1443
    13801444                switch ( selection ) {
    1381                         case 'unread' :
    1382                                 checkboxes = jq("tr.unread td input[type='checkbox']");
     1445                        case 'unread':
     1446                                checkboxes = jq('tr.unread td input[type="checkbox"]');
    13831447                                break;
    1384                         case 'read' :
    1385                                 checkboxes = jq("tr.read td input[type='checkbox']");
     1448                        case 'read':
     1449                                checkboxes = jq('tr.read td input[type="checkbox"]');
    13861450                                break;
    1387                         case '' :
    1388                                 checked_value = "";
     1451                        case '':
     1452                                checked_value = '';
    13891453                                break;
    13901454                }
     
    13971461        /* Bulk delete messages */
    13981462        jq( 'body.messages #item-body div.messages' ).on( 'click', '.messages-options-nav a', function() {
    1399                 if ( -1 == jq.inArray( this.id, Array( 'delete_sentbox_messages', 'delete_inbox_messages' ) ) ) {
     1463                if ( -1 === jq.inArray( this.id, Array( 'delete_sentbox_messages', 'delete_inbox_messages' ) ) ) {
    14001464                        return;
    14011465                }
    14021466
    14031467                checkboxes_tosend = '';
    1404                 checkboxes = jq("#message-threads tr td input[type='checkbox']");
     1468                checkboxes = jq('#message-threads tr td input[type="checkbox"]');
    14051469
    14061470                jq('#message').remove();
     
    14081472
    14091473                jq(checkboxes).each( function(i) {
    1410                         if( jq(this).is(':checked') )
     1474                        if( jq(this).is(':checked') ) {
    14111475                                checkboxes_tosend += jq(this).attr('value') + ',';
    1412                 });
    1413 
    1414                 if ( '' == checkboxes_tosend ) {
     1476                        }
     1477                });
     1478
     1479                if ( '' === checkboxes_tosend ) {
    14151480                        jq(this).removeClass('loading');
    14161481                        return false;
     
    14211486                        'thread_ids': checkboxes_tosend
    14221487                }, function(response) {
    1423                         if ( response[0] + response[1] == "-1" ) {
     1488                        if ( response[0] + response[1] === '-1' ) {
    14241489                                jq('#message-threads').prepend( response.substr( 2, response.length ) );
    14251490                        } else {
     
    14371502
    14381503                        jq('#message').hide().slideDown(150);
    1439                         jq("#delete_inbox_messages, #delete_sentbox_messages").removeClass('loading');
     1504                        jq('#delete_inbox_messages, #delete_sentbox_messages').removeClass('loading');
    14401505                });
    14411506
     
    14441509
    14451510        /* Close site wide notices in the sidebar */
    1446         jq("#close-notice").on( 'click', function() {
     1511        jq('#close-notice').on( 'click', function() {
    14471512                jq(this).addClass('loading');
    14481513                jq('#sidebar div.error').remove();
     
    14531518                },
    14541519                function(response) {
    1455                         jq("#close-notice").removeClass('loading');
    1456 
    1457                         if ( response[0] + response[1] == '-1' ) {
     1520                        jq('#close-notice').removeClass('loading');
     1521
     1522                        if ( response[0] + response[1] === '-1' ) {
    14581523                                jq('.notice').prepend( response.substr( 2, response.length ) );
    14591524                                jq( '#sidebar div.error').hide().fadeIn( 200 );
     
    14661531
    14671532        /* Toolbar & wp_list_pages Javascript IE6 hover class */
    1468         jq("#wp-admin-bar ul.main-nav li, #nav li").mouseover( function() {
     1533        jq('#wp-admin-bar ul.main-nav li, #nav li').mouseover( function() {
    14691534                jq(this).addClass('sfhover');
    14701535        });
    14711536
    1472         jq("#wp-admin-bar ul.main-nav li, #nav li").mouseout( function() {
     1537        jq('#wp-admin-bar ul.main-nav li, #nav li').mouseout( function() {
    14731538                jq(this).removeClass('sfhover');
    14741539        });
     
    15011566
    15021567        /* if js is enabled then replace the no-js class by a js one */
    1503         if( jq('body').hasClass('no-js') )
     1568        if( jq('body').hasClass('no-js') ) {
    15041569                jq('body').attr('class', jq('body').attr('class').replace( /no-js/,'js' ) );
     1570        }
    15051571
    15061572        /** Activity HeartBeat ************************************************/
    15071573
    15081574        // Set the interval and the namespace event
    1509         if ( typeof wp != 'undefined' && typeof wp.heartbeat != 'undefined' && typeof BP_DTheme.pulse != 'undefined' ) {
     1575        if ( typeof wp !== 'undefined' && typeof wp.heartbeat !== 'undefined' && typeof BP_DTheme.pulse !== 'undefined' ) {
    15101576
    15111577                wp.heartbeat.interval( Number( BP_DTheme.pulse ) );
     
    15131579                jq.fn.extend({
    15141580                        'heartbeat-send': function() {
    1515                         return this.bind( 'heartbeat-send.buddypress' );
    1516                 },
    1517             });
    1518 
     1581                                return this.bind( 'heartbeat-send.buddypress' );
     1582                        }
     1583                });
    15191584        }
    15201585
     
    15341599                }
    15351600
    1536                 if ( 0 == activity_last_recorded || Number( firstrow ) > activity_last_recorded )
     1601                if ( 0 === activity_last_recorded || Number( firstrow ) > activity_last_recorded ) {
    15371602                        activity_last_recorded = Number( firstrow );
    1538 
    1539                 data['bp_activity_last_recorded'] = activity_last_recorded;
     1603                }
     1604
     1605                data.bp_activity_last_recorded = activity_last_recorded;
    15401606        });
    15411607
     
    15441610
    15451611                // Only proceed if we have newest activities
    1546                 if ( ! data['bp_activity_newest_activities'] ) {
     1612                if ( ! data.bp_activity_newest_activities ) {
    15471613                        return;
    15481614                }
    15491615
    1550                 newest_activities = data['bp_activity_newest_activities']['activities'] + newest_activities;
    1551                 activity_last_recorded  = Number( data['bp_activity_newest_activities']['last_recorded'] );
    1552 
    1553                 if ( jq( '#buddypress ul.activity-list li' ).first().hasClass( 'load-newest' ) )
     1616                newest_activities = data.bp_activity_newest_activities.activities + newest_activities;
     1617                activity_last_recorded  = Number( data.bp_activity_newest_activities.last_recorded );
     1618
     1619                if ( jq( '#buddypress ul.activity-list li' ).first().hasClass( 'load-newest' ) ) {
    15541620                        return;
     1621                }
    15551622
    15561623                jq( '#buddypress ul.activity-list' ).prepend( '<li class="load-newest"><a href="#newest">' + BP_DTheme.newest + '</a></li>' );
     
    15651632        } );
    15661633
    1567         if ( null != jq.cookie('bp-activity-filter') && jq('#activity-filter-select').length )
     1634        if ( null != jq.cookie('bp-activity-filter') && jq('#activity-filter-select').length ) {
    15681635                jq('#activity-filter-select select option[value="' + jq.cookie('bp-activity-filter') + '"]').prop( 'selected', true );
     1636        }
    15691637
    15701638        /* Activity Tab Set */
     
    15801648function bp_init_objects(objects) {
    15811649        jq(objects).each( function(i) {
    1582                 if ( null != jq.cookie('bp-' + objects[i] + '-filter') && jq('#' + objects[i] + '-order-select select').length )
     1650                if ( null != jq.cookie('bp-' + objects[i] + '-filter') && jq('#' + objects[i] + '-order-select select').length ) {
    15831651                        jq('#' + objects[i] + '-order-select select option[value="' + jq.cookie('bp-' + objects[i] + '-filter') + '"]').prop( 'selected', true );
     1652                }
    15841653
    15851654                if ( null != jq.cookie('bp-' + objects[i] + '-scope') && jq('div.' + objects[i]).length ) {
     
    15941663/* Filter the current content list (groups/members/blogs/topics) */
    15951664function bp_filter_request( object, filter, scope, target, search_terms, page, extras, caller, template ) {
    1596         if ( 'activity' == object )
     1665        if ( 'activity' === object ) {
    15971666                return false;
    1598 
    1599         if ( jq.query.get('s') && !search_terms )
     1667        }
     1668
     1669        if ( jq.query.get('s') && !search_terms ) {
    16001670                search_terms = jq.query.get('s');
    1601 
    1602         if ( null == scope )
     1671        }
     1672
     1673        if ( null === scope ) {
    16031674                scope = 'all';
     1675        }
    16041676
    16051677        /* Save the settings we want to remain persistent to a cookie */
     
    16221694        jq('.item-list-tabs select option[value="' + filter + '"]').prop( 'selected', true );
    16231695
    1624         if ( 'friends' == object || 'group_members' == object ) {
     1696        if ( 'friends' === object || 'group_members' === object ) {
    16251697                object = 'members';
    16261698        }
    16271699
    1628         if ( bp_ajax_request )
     1700        if ( bp_ajax_request ) {
    16291701                bp_ajax_request.abort();
     1702        }
    16301703
    16311704        bp_ajax_request = jq.post( ajaxurl, {
     
    16431716        {
    16441717                /* animate to top if called from bottom pagination */
    1645                 if ( caller == 'pag-bottom' && jq('#subnav').length ) {
     1718                if ( caller === 'pag-bottom' && jq('#subnav').length ) {
    16461719                        var top = jq('#subnav').parent();
    16471720                        jq('html,body').animate({scrollTop: top.offset().top}, 'slow', function() {
     
    16491722                                        jq(this).html(response);
    16501723                                        jq(this).fadeIn(100);
    1651                                 });
     1724                                });
    16521725                        });
    16531726
     
    16561729                                jq(this).html(response);
    16571730                                jq(this).fadeIn(100);
    1658                         });
     1731                        });
    16591732                }
    16601733
     
    16881761        jq('.widget_bp_activity_widget h2 span.ajax-loader').show();
    16891762
    1690         if ( bp_ajax_request )
     1763        if ( bp_ajax_request ) {
    16911764                bp_ajax_request.abort();
     1765        }
    16921766
    16931767        bp_ajax_request = jq.post( ajaxurl, {
    16941768                action: 'activity_widget_filter',
    16951769                'cookie': bp_get_cookies(),
    1696                 '_wpnonce_activity_filter': jq("#_wpnonce_activity_filter").val(),
     1770                '_wpnonce_activity_filter': jq('#_wpnonce_activity_filter').val(),
    16971771                'scope': scope,
    16981772                'filter': filter
     
    17111785
    17121786                /* Update the feed link */
    1713                 if ( null != response.feed_url )
     1787                if ( null != response.feed_url ) {
    17141788                        jq('.directory #subnav li.feed a, .home-page #subnav li.feed a').attr('href', response.feed_url);
     1789                }
    17151790
    17161791                jq('.item-list-tabs li.selected').removeClass('loading');
     
    17211796/* Hide long lists of activity comments, only show the latest five root comments. */
    17221797function bp_legacy_theme_hide_comments() {
    1723         var comments_divs = jq('div.activity-comments');
    1724 
    1725         if ( !comments_divs.length )
     1798        var comments_divs = jq('div.activity-comments'),
     1799                parent_li, comment_lis, comment_count;
     1800
     1801        if ( !comments_divs.length ) {
    17261802                return false;
     1803        }
    17271804
    17281805        comments_divs.each( function() {
    1729                 if ( jq(this).children('ul').children('li').length < 5 ) return;
    1730 
    1731                 var comments_div = jq(this);
    1732                 var parent_li = comments_div.parents('#activity-stream > li');
    1733                 var comment_lis = jq(this).children('ul').children('li');
    1734                 var comment_count = ' ';
    1735 
    1736                 if ( jq('#' + parent_li.attr('id') + ' a.acomment-reply span').length )
    1737                         var comment_count = jq('#' + parent_li.attr('id') + ' a.acomment-reply span').html();
     1806                if ( jq(this).children('ul').children('li').length < 5 ) {
     1807                        return;
     1808                }
     1809
     1810                comments_div = jq(this);
     1811                parent_li = comments_div.parents('#activity-stream > li');
     1812                comment_lis = jq(this).children('ul').children('li');
     1813                comment_count = ' ';
     1814
     1815                if ( jq('#' + parent_li.attr('id') + ' a.acomment-reply span').length ) {
     1816                        comment_count = jq('#' + parent_li.attr('id') + ' a.acomment-reply span').html();
     1817                }
    17381818
    17391819                comment_lis.each( function(i) {
     
    17431823                                jq(this).toggle();
    17441824
    1745                                 if ( !i )
     1825                                if ( !i ) {
    17461826                                        jq(this).before( '<li class="show-all"><a href="#' + parent_li.attr('id') + '/show-all/" title="' + BP_DTheme.show_all_comments + '">' + BP_DTheme.show_x_comments.replace( '%d', comment_count ) + '</a></li>' );
     1827                                }
    17471828                        }
    17481829                });
     
    17541835
    17551836function checkAll() {
    1756         var checkboxes = document.getElementsByTagName("input");
    1757         for(var i=0; i<checkboxes.length; i++) {
    1758                 if(checkboxes[i].type == "checkbox") {
    1759                         if($("check_all").checked == "") {
    1760                                 checkboxes[i].checked = "";
     1837        var checkboxes = document.getElementsByTagName('input'),
     1838                i;
     1839
     1840        for(i=0; i<checkboxes.length; i++) {
     1841                if(checkboxes[i].type === 'checkbox') {
     1842                        if($('check_all').checked === '') {
     1843                                checkboxes[i].checked = '';
    17611844                        }
    17621845                        else {
    1763                                 checkboxes[i].checked = "checked";
     1846                                checkboxes[i].checked = 'checked';
    17641847                        }
    17651848                }
     
    17981881/* Returns a querystring of BP cookies (cookies beginning with 'bp-') */
    17991882function bp_get_cookies() {
    1800         // get all cookies and split into an array
    1801         var allCookies   = document.cookie.split(";");
    1802 
    1803         var bpCookies    = {};
    1804         var cookiePrefix = 'bp-';
     1883        var allCookies = document.cookie.split(';'),  // get all cookies and split into an array
     1884                bpCookies      = {},
     1885                cookiePrefix   = 'bp-',
     1886                i, cookie, delimiter, name, value;
    18051887
    18061888        // loop through cookies
    1807         for (var i = 0; i < allCookies.length; i++) {
    1808                 var cookie    = allCookies[i];
    1809                 var delimiter = cookie.indexOf("=");
    1810                 var name      = jq.trim( unescape( cookie.slice(0, delimiter) ) );
    1811                 var value     = unescape( cookie.slice(delimiter + 1) );
     1889        for (i = 0; i < allCookies.length; i++) {
     1890                cookie    = allCookies[i];
     1891                delimiter = cookie.indexOf('=');
     1892                name      = jq.trim( unescape( cookie.slice(0, delimiter) ) );
     1893                value     = unescape( cookie.slice(delimiter + 1) );
    18121894
    18131895                // if BP cookie, store it
    1814                 if ( name.indexOf(cookiePrefix) == 0 ) {
     1896                if ( name.indexOf(cookiePrefix) === 0 ) {
    18151897                        bpCookies[name] = value;
    18161898                }
  • trunk/src/bp-xprofile/admin/js/admin.js

    r8180 r8378  
     1/* exported add_option, show_options, hide, fixHelper */
     2/* jshint scripturl: true */
     3
    14function add_option(forWhat) {
    2         var holder    = document.getElementById(forWhat + "_more");
    3         var theId     = document.getElementById(forWhat + '_option_number').value;
    4         var newDiv    = document.createElement('p');
    5         var newOption = document.createElement('input');
    6         var span      = document.createElement( 'span' );
    7         var txt       = document.createTextNode( "\u00A0\u039E\u00A0" );
    8         var isDefault = document.createElement( 'input' );
    9         var span1     = document.createElement( 'span' );
    10         var txt1      = document.createTextNode( " Default Value " );
     5        var holder  = document.getElementById(forWhat + '_more'),
     6                theId     = document.getElementById(forWhat + '_option_number').value,
     7                newDiv    = document.createElement('p'),
     8                newOption = document.createElement('input'),
     9                span      = document.createElement( 'span' ),
     10                txt       = document.createTextNode( '\u00A0\u039E\u00A0' ),
     11                isDefault = document.createElement( 'input' ),
     12                span1     = document.createElement( 'span' ),
     13                txt1      = document.createTextNode( ' Default Value ' ),
     14
     15                toDelete     = document.createElement( 'a' ),
     16                toDeleteText = document.createTextNode( '[x]' );
     17
    1118
    1219        newDiv.setAttribute('id', forWhat + '_div' + theId);
     
    1926        span.appendChild( txt );
    2027
    21         if ( forWhat == 'checkbox' || forWhat == 'multiselectbox' ) {
     28        if ( forWhat === 'checkbox' || forWhat === 'multiselectbox' ) {
    2229                isDefault.setAttribute( 'type', 'checkbox' );
    2330                isDefault.setAttribute( 'name', 'isDefault_' + forWhat + '_option[' + theId + ']' );
     
    3138        span1.appendChild( txt1 );
    3239
    33         var toDelete     = document.createElement( 'a' );
    34         var toDeleteText = document.createTextNode( '[x]' );
    35 
    36         toDelete.setAttribute( 'href', "javascript:hide('" + forWhat + '_div' + theId + "')" );
     40
     41        toDelete.setAttribute( 'href', 'javascript:hide("' + forWhat + '_div' + theId + '")' );
    3742        toDelete.setAttribute( 'class', 'delete' );
    3843        toDelete.appendChild( toDeleteText );
     
    4045        newDiv.appendChild( span );
    4146        newDiv.appendChild( newOption );
    42         newDiv.appendChild( document.createTextNode( " " ) );
     47        newDiv.appendChild( document.createTextNode( ' ' ) );
    4348        newDiv.appendChild( isDefault );
    4449        newDiv.appendChild( span1 );
     
    5055
    5156        // set focus on newly created element
    52         document.getElementById(forWhat + "_option" + theId).focus();
     57        document.getElementById(forWhat + '_option' + theId).focus();
    5358
    5459        theId++;
    5560
    56         document.getElementById(forWhat + "_option_number").value = theId;
     61        document.getElementById(forWhat + '_option_number').value = theId;
    5762}
    5863
     
    6368        document.getElementById( 'checkbox'       ).style.display = 'none';
    6469
    65         if ( forWhat == 'radio' )
    66                 document.getElementById( 'radio' ).style.display = "";
    67 
    68         if ( forWhat == 'selectbox' )
    69                 document.getElementById( 'selectbox' ).style.display = "";
    70 
    71         if ( forWhat == 'multiselectbox' )
    72                 document.getElementById( 'multiselectbox' ).style.display = "";
    73 
    74         if ( forWhat == 'checkbox' )
    75                 document.getElementById( 'checkbox' ).style.display = "";
     70        if ( forWhat === 'radio' ) {
     71                document.getElementById( 'radio' ).style.display = '';
     72        }
     73
     74        if ( forWhat === 'selectbox' ) {
     75                document.getElementById( 'selectbox' ).style.display = '';
     76        }
     77
     78        if ( forWhat === 'multiselectbox' ) {
     79                document.getElementById( 'multiselectbox' ).style.display = '';
     80        }
     81
     82        if ( forWhat === 'checkbox' ) {
     83                document.getElementById( 'checkbox' ).style.display = '';
     84        }
    7685}
    7786
    7887function hide( id ) {
    79         if ( !document.getElementById( id ) ) return false;
    80 
    81         document.getElementById( id ).style.display = "none";
     88        if ( !document.getElementById( id ) ) {
     89                return false;
     90        }
     91
     92        document.getElementById( id ).style.display = 'none';
    8293        // the field id is [fieldtype]option[iterator] and not [fieldtype]div[iterator]
    83         field_id = id.replace( 'div', 'option' );
     94        var field_id = id.replace( 'div', 'option' );
    8495        document.getElementById( field_id ).value = '';
    8596}
     
    126137                        'option_id': theId
    127138                },
    128                 function( response ) {} );
     139                function() {} );
    129140        } );
    130141
    131142        //
    132143        jQuery( '[id^="sort_order_"]' ).change(function() {
    133                 if ( jQuery( this ).val() != 'custom' ) {
     144                if ( jQuery( this ).val() !== 'custom' ) {
    134145                        destroySortableFieldOptions();
    135146                } else {
     
    156167                                'group_order': jQuery( this ).sortable( 'serialize' )
    157168                        },
    158                         function( response ) {} );
     169                        function() {} );
    159170                }
    160171        }).disableSelection();
     
    175186                                'field_group_id': jQuery(this).attr( 'id' )
    176187                        },
    177                         function( response ) {} );
     188                        function() {} );
    178189                }
    179190        })
     
    189200
    190201        // tabs init with a custom tab template and an "add" callback filling in the content
    191         var $tab_items;
    192         var $tabs = jQuery( '#tabs' ).tabs();
     202        var $tab_items,
     203                $tabs = jQuery( '#tabs' ).tabs();
     204
    193205        set_tab_items( $tabs );
    194206
     
    203215                        // When field is dropped on tab
    204216                        drop: function( ev, ui ) {
    205                                 // The tab
    206                                 var $item = jQuery(this);
    207 
    208                                 // The tab body
    209                                 var $list = jQuery( $item.find( 'a' ).attr( 'href' ) ).find( '.connectedSortable' );
     217                                var $item = jQuery(this),  // The tab
     218                                        $list   = jQuery( $item.find( 'a' ).attr( 'href' ) ).find( '.connectedSortable' );  // The tab body
    210219
    211220                                // Remove helper class
     
    219228
    220229                                        // Show new placement
    221                                         jQuery(this).appendTo($list).show( 'slow' ).animate( {opacity: "1"}, 500 );
     230                                        jQuery(this).appendTo($list).show( 'slow' ).animate( {opacity: '1'}, 500 );
    222231
    223232                                        // Refresh $list variable
     
    229238                                                action: 'xprofile_reorder_fields',
    230239                                                'cookie': encodeURIComponent(document.cookie),
    231                                                 '_wpnonce_reorder_fields': jQuery( "input#_wpnonce_reorder_fields" ).val(),
     240                                                '_wpnonce_reorder_fields': jQuery( 'input#_wpnonce_reorder_fields' ).val(),
    232241                                                'field_order': jQuery( $list ).sortable( 'serialize' ),
    233242                                                'field_group_id': jQuery( $list ).attr( 'id' )
    234243                                        },
    235                                         function( response ) {} );
     244                                        function() {} );
    236245                                });
    237246                        },
    238                         over: function( event, ui ) {
     247                        over: function() {
    239248                                jQuery(this).addClass( 'drop-candidate' );
    240249                        },
    241                         out: function( event, ui ) {
     250                        out: function() {
    242251                                jQuery(this).removeClass( 'drop-candidate' );
    243252                        }
Note: See TracChangeset for help on using the changeset viewer.