Changeset 8378
- Timestamp:
- 05/04/2014 05:18:57 PM (10 years ago)
- 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 */ 1 2 (function( $ ) { 2 3 … … 20 21 // Close textarea on escape 21 22 $(document).on( 'keyup', '#bp-activities:visible', function( e ) { 22 if ( 27 == e.which ) {23 if ( 27 === e.which ) { 23 24 activityReply.close(); 24 25 } … … 31 32 * @since BuddyPress (1.6) 32 33 */ 33 open : function( e) {34 open : function() { 34 35 // Hide the container row, and move it to the new location 35 36 var box = $( '#bp-activities-container' ).hide(); … … 48 49 * @since BuddyPress (1.6) 49 50 */ 50 close : function( e) {51 close : function() { 51 52 // Hide the container row 52 $('#bp-activities-container').fadeOut( '200', function () { 53 $('#bp-activities-container').fadeOut( '200', function () { 53 54 54 55 // Empty and unfocus the text area … … 68 69 * @since BuddyPress (1.6) 69 70 */ 70 send : function( e) {71 send : function() { 71 72 // Hide any existing error message, and show the loading spinner 72 73 $( '#bp-replysubmit .error' ).hide(); … … 124 125 125 126 // Handle any errors in the response 126 if ( typeof( xml ) == 'string' ) {127 if ( typeof( xml ) === 'string' ) { 127 128 activityReply.error( { 'responseText': xml } ); 128 129 return false; … … 137 138 138 139 // 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 () { 140 141 141 142 // Empty and unfocus the text area -
trunk/src/bp-core/js/confirm.js
r8091 r8378 1 /* jshint devel: true */ 2 /* global BP_Confirm */ 3 1 4 jQuery( document ).ready( function() { 2 5 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 } 5 11 }); 6 12 }); -
trunk/src/bp-core/js/widget-members.js
r6635 r8378 1 1 jQuery(document).ready( function() { 2 jQuery( ".widget div#members-list-options a").on('click',2 jQuery('.widget div#members-list-options a').on('click', 3 3 function() { 4 4 var link = this; 5 5 jQuery(link).addClass('loading'); 6 6 7 jQuery( ".widget div#members-list-options a").removeClass("selected");7 jQuery('.widget div#members-list-options a').removeClass('selected'); 8 8 jQuery(this).addClass('selected'); 9 9 … … 11 11 action: 'widget_members', 12 12 '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(), 15 15 'filter': jQuery(this).attr('id') 16 16 }, … … 30 30 response = response.split('[[SPLIT]]'); 31 31 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, 34 34 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); 37 37 } 38 38 ); 39 39 40 40 } else { 41 jQuery( ".widget ul#members-list").fadeOut(200,41 jQuery('.widget ul#members-list').fadeOut(200, 42 42 function() { 43 43 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); 46 46 } 47 47 ); -
trunk/src/bp-friends/js/widget-friends.js
r7392 r8378 1 1 jQuery(document).ready( function() { 2 jQuery( ".widget div#friends-list-options a").on('click',2 jQuery('.widget div#friends-list-options a').on('click', 3 3 function() { 4 4 var link = this; 5 5 jQuery(link).addClass('loading'); 6 6 7 jQuery( ".widget div#friends-list-options a").removeClass("selected");7 jQuery('.widget div#friends-list-options a').removeClass('selected'); 8 8 jQuery(this).addClass('selected'); 9 9 … … 11 11 action: 'widget_friends', 12 12 '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(), 15 15 'filter': jQuery(this).attr('id') 16 16 }, … … 30 30 response = response.split('[[SPLIT]]'); 31 31 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, 34 34 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); 37 37 } 38 38 ); 39 39 40 40 } else { 41 jQuery( ".widget ul#friends-list").fadeOut(200,41 jQuery('.widget ul#friends-list').fadeOut(200, 42 42 function() { 43 43 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); 46 46 } 47 47 ); -
trunk/src/bp-groups/admin/js/admin.js
r7159 r8378 1 /* global BP_Group_Admin, group_id, isRtl */ 2 1 3 (function($) { 2 4 function add_member_to_list( e, ui ) { … … 39 41 }); 40 42 41 window.onbeforeunload = function( e) {43 window.onbeforeunload = function() { 42 44 if ( window.warn_on_leave ) { 43 45 return BP_Group_Admin.warn_on_leave; -
trunk/src/bp-groups/js/widget-groups.js
r6635 r8378 1 1 jQuery(document).ready( function() { 2 jQuery( ".widget div#groups-list-options a").on('click',2 jQuery('.widget div#groups-list-options a').on('click', 3 3 function() { 4 4 var link = this; 5 5 jQuery(link).addClass('loading'); 6 6 7 jQuery( ".widget div#groups-list-options a").removeClass("selected");7 jQuery('.widget div#groups-list-options a').removeClass('selected'); 8 8 jQuery(this).addClass('selected'); 9 9 … … 11 11 action: 'widget_groups_list', 12 12 '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(), 15 15 'filter': jQuery(this).attr('id') 16 16 }, … … 30 30 response = response.split('[[SPLIT]]'); 31 31 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, 34 34 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); 37 37 } 38 38 ); 39 39 40 40 } else { 41 jQuery( ".widget ul#groups-list").fadeOut(200,41 jQuery('.widget ul#groups-list').fadeOut(200, 42 42 function() { 43 43 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); 46 46 } 47 47 ); -
trunk/src/bp-members/admin/js/admin.js
r8021 r8378 1 /* exported clear */ 2 1 3 ( function( $ ) { 2 4 // Profile Visibility Settings -
trunk/src/bp-templates/bp-legacy/js/buddypress.js
r8264 r8378 13 13 14 14 /* 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 ) { 16 16 jq('#new-topic-post').hide(); 17 else17 } else { 18 18 jq('#new-topic-post').show(); 19 } 19 20 20 21 /* Activity filter and scope set */ 21 22 bp_init_activity(); 22 23 24 var objects = [ 'members', 'groups', 'blogs', 'forums', 'group_members' ], 25 $whats_new = jq('#whats-new'); 26 23 27 /* Object filter and scope set. */ 24 var objects = [ 'members', 'groups', 'blogs', 'forums', 'group_members' ];25 28 bp_init_objects( objects ); 26 29 27 30 /* @mention Compose Scrolling */ 28 var $whats_new = jq('#whats-new');29 31 if ( jq.query.get('r') && $whats_new.length ) { 30 32 jq('#whats-new-options').animate({ 31 33 height:'40px' 32 34 }); 33 jq( "#whats-new-form textarea").animate({35 jq('#whats-new-form textarea').animate({ 34 36 height:'50px' 35 37 }); … … 38 40 easing:'easeOutQuad' 39 41 } ); 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() ); 42 43 } 43 44 … … 46 47 /* Textarea focus */ 47 48 $whats_new.focus( function(){ 48 jq( "#whats-new-options").animate({49 jq('#whats-new-options').animate({ 49 50 height:'40px' 50 51 }); 51 jq( "#whats-new-form textarea").animate({52 jq('#whats-new-form textarea').animate({ 52 53 height:'50px' 53 54 }); 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'); 59 62 } 60 63 61 64 // Return to the 'All Members' tab and 'Everything' filter, 62 65 // to avoid inconsistencies with the heartbeat integration 63 var $activity_all = jq( '#activity-all' );64 66 if ( $activity_all.length ) { 65 67 if ( ! $activity_all.hasClass( 'selected' ) ) { 66 68 // reset to everyting 67 69 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() ) { 70 72 jq( '#activity-filter-select select' ).val( '-1' ); 71 73 jq( '#activity-filter-select select' ).trigger( 'change' ); … … 76 78 /* On blur, shrink if it's empty */ 77 79 $whats_new.blur( function(){ 78 if ( document.activeElement != this ) {80 if ( document.activeElement !== this ) { 79 81 if (!this.value.match(/\S+/)) { 80 this.value = "";81 jq( "#whats-new-options").animate({82 this.value = ''; 83 jq('#whats-new-options').animate({ 82 84 height:'40px' 83 85 }); 84 jq( "form#whats-new-form textarea").animate({86 jq('form#whats-new-form textarea').animate({ 85 87 height:'20px' 86 88 }); 87 jq( "#aw-whats-new-submit").prop("disabled", true);89 jq('#aw-whats-new-submit').prop('disabled', true); 88 90 } 89 91 } … … 91 93 92 94 /* 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'); 97 99 98 100 form.children().each( function() { 99 if ( jq.nodeName(this, "textarea") || jq.nodeName(this, "input") )101 if ( jq.nodeName(this, 'textarea') || jq.nodeName(this, 'input') ) { 100 102 jq(this).prop( 'disabled', true ); 103 } 101 104 }); 102 105 … … 105 108 button.addClass('loading'); 106 109 button.prop('disabled', true); 107 form.addClass( "submitted");110 form.addClass('submitted'); 108 111 109 112 /* Default POST values */ 110 varobject = '';111 var item_id = jq("#whats-new-post-in").val();112 var content = jq("#whats-new").val();113 varfirstrow = jq( '#buddypress ul.activity-list li' ).first();114 varactivity_row = firstrow;115 vartimestamp = 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; 116 119 117 120 // Checks if at least one activity exists … … 124 127 timestamp = activity_row.prop( 'class' ).match( /date-recorded-([0-9]+)/ ); 125 128 } 126 127 129 130 if ( timestamp ) { 128 131 last_date_recorded = timestamp[1]; 129 132 } … … 131 134 /* Set object for non-profile posts */ 132 135 if ( item_id > 0 ) { 133 object = jq( "#whats-new-post-object").val();136 object = jq('#whats-new-post-object').val(); 134 137 } 135 138 … … 137 140 action: 'post_update', 138 141 'cookie': bp_get_cookies(), 139 '_wpnonce_post_update': jq( "#_wpnonce_post_update").val(),142 '_wpnonce_post_update': jq('#_wpnonce_post_update').val(), 140 143 'content': content, 141 144 'object': object, … … 147 150 148 151 form.children().each( function() { 149 if ( jq.nodeName(this, "textarea") || jq.nodeName(this, "input") ) {152 if ( jq.nodeName(this, 'textarea') || jq.nodeName(this, 'input') ) { 150 153 jq(this).prop( 'disabled', false ); 151 154 } … … 153 156 154 157 /* Check for errors and append if found. */ 155 if ( response[0] + response[1] == '-1' ) {158 if ( response[0] + response[1] === '-1' ) { 156 159 form.prepend( response.substr( 2, response.length ) ); 157 160 jq( '#' + form.attr('id') + ' div.error').hide().fadeIn( 200 ); 158 161 } 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">' ); 163 166 } 164 167 165 if ( firstrow.hasClass( 'load-newest' ) ) 168 if ( firstrow.hasClass( 'load-newest' ) ) { 166 169 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 !== '' ) { 181 185 u = l + ' '; 186 } 182 187 183 188 u += '<a href="' + v + '" rel="nofollow">' + BP_DTheme.view + '</a>'; 184 189 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); 188 193 }); 189 194 } 190 195 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(''); 194 199 195 200 // reset vars to get newest activities … … 198 203 } 199 204 200 jq( "#whats-new-options").animate({205 jq('#whats-new-options').animate({ 201 206 height:'0px' 202 207 }); 203 jq( "#whats-new-form textarea").animate({208 jq('#whats-new-form textarea').animate({ 204 209 height:'20px' 205 210 }); 206 jq( "#aw-whats-new-submit").prop("disabled", true).removeClass('loading');211 jq('#aw-whats-new-submit').prop('disabled', true).removeClass('loading'); 207 212 }); 208 213 … … 212 217 /* List tabs event delegation */ 213 218 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' ) { 217 223 target = target.parent(); 218 else if ( event.target.nodeName != 'A' ) 219 return false; 224 } else if ( event.target.nodeName !== 'A' ) { 225 return false; 226 } 220 227 221 228 /* Reset the page */ … … 225 232 226 233 /* 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' ) { 231 238 jq( '#' + target.attr('id') + ' a strong' ).remove(); 239 } 232 240 233 241 bp_activity_request(scope, filter); … … 238 246 /* Activity filter select */ 239 247 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 } 248 257 249 258 bp_activity_request(scope, filter); … … 254 263 /* Stream event delegation */ 255 264 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; 257 269 258 270 /* Favoriting activity stream items */ 259 271 if ( target.hasClass('fav') || target.hasClass('unfav') ) { 260 var type= target.hasClass('fav') ? 'fav' : 'unfav';261 var parent= target.closest('.activity-item');262 varparent_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 ); 263 275 264 276 target.addClass('loading'); … … 274 286 target.fadeOut( 200, function() { 275 287 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); 277 289 jq(this).fadeIn(200); 278 290 }); 279 291 280 if ( 'fav' == type ) {292 if ( 'fav' === type ) { 281 293 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 ) { 283 295 jq('.item-list-tabs ul #activity-mentions').before( '<li id="activity-favorites"><a href="#">' + BP_DTheme.my_favs + ' <span>0</span></a></li>'); 296 } 284 297 285 298 jq('.item-list-tabs ul #activity-favorites span').html( Number( jq('.item-list-tabs ul #activity-favorites span').html() ) + 1 ); … … 296 309 297 310 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') ) { 299 312 bp_activity_request( null, null ); 313 } 300 314 301 315 jq('.item-list-tabs ul #activity-favorites').remove(); … … 303 317 } 304 318 305 if ( 'activity-favorites' == jq( '.item-list-tabs li.selected').attr('id') )319 if ( 'activity-favorites' === jq( '.item-list-tabs li.selected').attr('id') ) { 306 320 target.closest( '.activity-item' ).slideUp( 100 ); 321 } 307 322 }); 308 323 … … 312 327 /* Delete activity stream items */ 313 328 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]; 321 335 322 336 target.addClass('loading'); … … 330 344 function(response) { 331 345 332 if ( response[0] + response[1] == '-1' ) {346 if ( response[0] + response[1] === '-1' ) { 333 347 li.prepend( response.substr( 2, response.length ) ); 334 348 li.children('#message').hide().fadeIn(300); … … 337 351 338 352 // reset vars to get newest activities 339 if ( timestamp && activity_last_recorded == timestamp[1] ) {353 if ( timestamp && activity_last_recorded === timestamp[1] ) { 340 354 newest_activities = ''; 341 355 activity_last_recorded = 0; … … 349 363 // Spam activity stream items 350 364 if ( target.hasClass( 'spam-activity' ) ) { 351 varli = target.parents( 'div.activity ul li' );352 vartimestamp = 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]+)/ ); 353 367 target.addClass( 'loading' ); 354 368 … … 367 381 li.slideUp( 300 ); 368 382 // reset vars to get newest activities 369 if ( timestamp && activity_last_recorded == timestamp[1] ) {383 if ( timestamp && activity_last_recorded === timestamp[1] ) { 370 384 newest_activities = ''; 371 385 activity_last_recorded = 0; … … 379 393 /* Load more updates at the end of the page */ 380 394 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') ) { 384 398 jq.cookie('bp-activity-oldestpage', 1, { 385 399 path: '/' 386 400 } ); 387 388 var oldest_page = ( jq.cookie('bp-activity-oldestpage') * 1 ) + 1; 389 390 varjust_posted = [];401 } 402 403 oldest_page = ( jq.cookie('bp-activity-oldestpage') * 1 ) + 1; 404 just_posted = []; 391 405 392 406 jq('.activity-list li.just-posted').each( function(){ … … 402 416 function(response) 403 417 { 404 jq( "#buddypress li.load-more").removeClass('loading');418 jq('#buddypress li.load-more').removeClass('loading'); 405 419 jq.cookie( 'bp-activity-oldestpage', oldest_page, { 406 420 path: '/' 407 421 } ); 408 jq( "#buddypress ul.activity-list").append(response.contents);422 jq('#buddypress ul.activity-list').append(response.contents); 409 423 410 424 target.parent().hide(); … … 429 443 430 444 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 ) { 433 447 jq( '#' + jq(el).attr( 'id' ) ).remove(); 448 } 434 449 } 435 450 } ); … … 445 460 // Activity "Read More" links 446 461 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' ); 454 470 jq(target).addClass('loading'); 455 471 … … 471 487 472 488 /* Hide excess comments */ 473 if ( jq('.activity-comments').length ) 489 if ( jq('.activity-comments').length ) { 474 490 bp_legacy_theme_hide_comments(); 491 } 475 492 476 493 /* Activity list event delegation */ 477 494 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; 479 503 480 504 /* Comment / comment reply links */ 481 505 if ( target.hasClass('acomment-reply') || target.parent().hasClass('acomment-reply') ) { 482 if ( target.parent().hasClass('acomment-reply') ) 506 if ( target.parent().hasClass('acomment-reply') ) { 483 507 target = target.parent(); 484 485 var id = target.attr('id'); 508 } 509 510 id = target.attr('id'); 486 511 ids = id.split('-'); 487 512 488 var a_id = ids[2]489 varc_id = target.attr('href').substr( 10, target.attr('href').length );490 varform = 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 ); 491 516 492 517 form.css( 'display', 'none' ); … … 496 521 /* Hide any error messages */ 497 522 form.children('div').each( function() { 498 if ( jq(this).hasClass( 'error' ) ) 523 if ( jq(this).hasClass( 'error' ) ) { 499 524 jq(this).hide(); 525 } 500 526 }); 501 527 502 if ( ids[1] != 'comment' ) {528 if ( ids[1] !== 'comment' ) { 503 529 jq('#acomment-' + c_id).append( form ); 504 530 } else { … … 506 532 } 507 533 508 if ( form.parent().hasClass( 'activity-comments' ) ) 534 if ( form.parent().hasClass( 'activity-comments' ) ) { 509 535 form.addClass('root'); 536 } 510 537 511 538 form.slideDown( 200 ); … … 520 547 521 548 /* Activity comment posting */ 522 if ( target.attr('name') == 'ac_form_submit' ) {523 varform = target.parents( 'form' );524 varform_parent = form.parent();525 varform_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('-'); 526 553 527 554 if ( !form_parent.hasClass('activity-comments') ) { 528 vartmp_id = form_parent.attr('id').split('-');529 varcomment_id = tmp_id[1];555 tmp_id = form_parent.attr('id').split('-'); 556 comment_id = tmp_id[1]; 530 557 } else { 531 varcomment_id = form_id[2];532 } 533 534 varcontent = jq( '#' + form.attr('id') + ' textarea' );558 comment_id = form_id[2]; 559 } 560 561 content = jq( '#' + form.attr('id') + ' textarea' ); 535 562 536 563 /* Hide any error messages */ … … 539 566 content.addClass('loading').prop('disabled', true); 540 567 541 varajaxdata = {568 ajaxdata = { 542 569 action: 'new_activity_comment', 543 570 '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(), 545 572 'comment_id': comment_id, 546 573 'form_id': form_id[2], … … 549 576 550 577 // Akismet 551 varak_nonce = jq('#_bp_as_nonce_' + comment_id).val();578 ak_nonce = jq('#_bp_as_nonce_' + comment_id).val(); 552 579 if ( ak_nonce ) { 553 580 ajaxdata['_bp_as_nonce_' + comment_id] = ak_nonce; … … 559 586 560 587 /* Check for errors and append if found. */ 561 if ( response[0] + response[1] == '-1' ) {588 if ( response[0] + response[1] === '-1' ) { 562 589 form.append( jq( response.substr( 2, response.length ) ).hide().fadeIn( 200 ) ); 563 590 } else { 564 591 var activity_comments = form.parent(); 565 592 form.fadeOut( 200, function() { 566 if ( 0 == activity_comments.children('ul').length ) {593 if ( 0 === activity_comments.children('ul').length ) { 567 594 if ( activity_comments.hasClass('activity-comments') ) { 568 595 activity_comments.prepend('<ul></ul>'); … … 585 612 586 613 // Increment the 'Show all x comments' string, if present 587 varshow_all_a = activity_comments.find('.show-all').find('a');614 show_all_a = activity_comments.find('.show-all').find('a'); 588 615 if ( show_all_a ) { 589 varnew_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(); 590 617 show_all_a.html( BP_DTheme.show_x_comments.replace( '%d', new_count ) ); 591 618 } 592 619 } 593 620 594 jq(target).prop( "disabled", false);595 jq(content).prop( "disabled", false);621 jq(target).prop('disabled', false); 622 jq(content).prop('disabled', false); 596 623 }); 597 624 … … 601 628 /* Deleting an activity comment */ 602 629 if ( target.hasClass('acomment-delete') ) { 603 varlink_href = target.attr('href');604 varcomment_li = target.parent().parent();605 varform = comment_li.parents('div.activity-comments').children('form');606 607 varnonce = 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='); 608 635 nonce = nonce[1]; 609 636 610 varcomment_id = link_href.split('cid=');637 comment_id = link_href.split('cid='); 611 638 comment_id = comment_id[1].split('&'); 612 639 comment_id = comment_id[0]; … … 628 655 function(response) { 629 656 /* Check for errors and append if found. */ 630 if ( response[0] + response[1] == '-1' ) {657 if ( response[0] + response[1] === '-1' ) { 631 658 comment_li.prepend( jq( response.substr( 2, response.length ) ).hide().fadeIn( 200 ) ); 632 659 } 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 635 664 jq(children).each( function() { 636 if ( !jq(this).is(':hidden') ) 665 if ( !jq(this).is(':hidden') ) { 637 666 child_count++; 667 } 638 668 }); 639 669 comment_li.fadeOut(200, function() { … … 642 672 643 673 /* Decrease the "Reply (X)" button count */ 644 varcount_span = jq('#' + comment_li.parents('#activity-stream > li').attr('id') + ' a.acomment-reply span');645 varnew_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 ); 646 676 count_span.html(new_count); 647 677 648 678 // Change the 'Show all x comments' text 649 varshow_all_a = comment_li.siblings('.show-all').find('a');679 show_all_a = comment_li.siblings('.show-all').find('a'); 650 680 if ( show_all_a ) { 651 681 show_all_a.html( BP_DTheme.show_x_comments.replace( '%d', new_count ) ); … … 653 683 654 684 /* 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 ) { 656 686 jq(comment_li.parents('#activity-stream > li')).removeClass('has-comments'); 657 687 } … … 664 694 // Spam an activity stream comment 665 695 if ( target.hasClass( 'spam-activity-comment' ) ) { 666 varlink_href = target.attr( 'href' );667 varcomment_li = target.parent().parent();696 link_href = target.attr( 'href' ); 697 comment_li = target.parent().parent(); 668 698 669 699 target.addClass('loading'); … … 684 714 function ( response ) { 685 715 // Check for errors and append if found. 686 if ( response[0] + response[1] == '-1' ) {716 if ( response[0] + response[1] === '-1' ) { 687 717 comment_li.prepend( jq( response.substr( 2, response.length ) ).hide().fadeIn( 200 ) ); 688 718 689 719 } 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 692 724 jq(children).each( function() { 693 725 if ( !jq( this ).is( ':hidden' ) ) { … … 698 730 699 731 // Decrease the "Reply (X)" button count 700 varparent_li = comment_li.parents( '#activity-stream > li' );732 parent_li = comment_li.parents( '#activity-stream > li' ); 701 733 jq( '#' + parent_li.attr( 'id' ) + ' a.acomment-reply span' ).html( jq( '#' + parent_li.attr( 'id' ) + ' a.acomment-reply span' ).html() - ( 1 + child_count ) ); 702 734 } … … 723 755 jq(target).closest('.ac-form').slideUp( 200 ); 724 756 return false; 725 } ;757 } 726 758 }); 727 759 … … 729 761 jq(document).keydown( function(e) { 730 762 e = e || window.event; 731 if (e.target) 763 if (e.target) { 732 764 element = e.target; 733 else if (e.srcElement)765 } else if (e.srcElement) { 734 766 element = e.srcElement; 735 736 if( element.nodeType == 3) 767 } 768 769 if( element.nodeType === 3) { 737 770 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 ) { 740 774 return; 775 } 741 776 742 777 var keyCode = (e.keyCode) ? e.keyCode : e.which; 743 778 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') ) { 747 782 jq(element).parent().parent().parent().slideUp( 200 ); 783 } 748 784 } 749 785 } … … 754 790 /* The search form on all directory pages */ 755 791 jq( '.dir-search, .groups-members-search' ).on( 'click', function(event) { 756 if ( jq(this).hasClass('no-ajax') ) 792 if ( jq(this).hasClass('no-ajax') ) { 757 793 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; 765 803 766 804 // The Group Members page specifies its own template 767 if ( 'members' == object && 'groups'== css_id[1] ) {805 if ( 'members' === object && 'groups' === css_id[1] ) { 768 806 object = 'group_members'; 769 807 template = 'groups/single/members'; … … 780 818 /* When a navigation tab is clicked - e.g. | All Groups | My Groups | */ 781 819 jq('div.item-list-tabs').on( 'click', function(event) { 782 if ( jq(this).hasClass('no-ajax') ) 820 if ( jq(this).hasClass('no-ajax') ) { 783 821 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 ) { 792 833 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(); 797 839 798 840 bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras') ); … … 804 846 /* When the filter select box is changed re-query */ 805 847 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 ) { 819 866 search_terms = jq('.dir-search input').val(); 867 } 820 868 821 869 // The Group Members page has a different selector for its 822 870 // search terms box 823 var$gm_search = jq( '.groups-members-search input' );871 $gm_search = jq( '.groups-members-search input' ); 824 872 if ( $gm_search.length ) { 825 873 search_terms = $gm_search.val(); … … 827 875 828 876 // On the Groups Members page, we specify a template 829 if ( 'members' == object && 'groups'== scope ) {877 if ( 'members' === object && 'groups' === scope ) { 830 878 object = 'group_members'; 831 879 template = 'groups/single/members'; 832 880 } 833 881 834 if ( 'friends' == object )882 if ( 'friends' === object ) { 835 883 object = 'members'; 884 } 836 885 837 886 bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras'), null, template ); … … 842 891 /* All pagination links run through this function */ 843 892 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') ) { 847 900 return true; 901 } 848 902 849 903 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') ) { 851 905 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( '=' ); 865 921 page_number = page_number[1]; 866 922 867 923 // Search terms 868 if ( jq('div.dir-search input').length ) 924 if ( jq('div.dir-search input').length ) { 869 925 search_terms = jq('.dir-search input').val(); 926 } 870 927 871 928 // The Group Members page has a different selector for 872 929 // its search terms box 873 var$gm_search = jq( '.groups-members-search input' );930 $gm_search = jq( '.groups-members-search input' ); 874 931 if ( $gm_search.length ) { 875 932 search_terms = $gm_search.val(); … … 877 934 878 935 // 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] ) { 880 937 object = 'group_members'; 881 938 template = 'groups/single/members'; … … 884 941 // On the Admin > Requests page, we need to reset the object, 885 942 // since "admin" isn't specific enough 886 if ( 'admin' == object && jq( 'body' ).hasClass( 'membership-requests' ) ) {943 if ( 'admin' === object && jq( 'body' ).hasClass( 'membership-requests' ) ) { 887 944 object = 'requests'; 888 945 } 889 946 890 947 if ( pagination_id.indexOf( 'pag-bottom' ) !== -1 ) { 891 varcaller = 'pag-bottom';948 caller = 'pag-bottom'; 892 949 } else { 893 varcaller = null;950 caller = null; 894 951 } 895 952 … … 905 962 /* Hit the "New Topic" button on the forums directory page */ 906 963 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') ) { 911 969 jq('#new-topic-post').slideUp(200); 912 else970 } else { 913 971 jq('#new-topic-post').slideDown(200, function() { 914 972 jq('#topic_title').focus(); 915 973 } ); 974 } 916 975 917 976 return false; … … 920 979 /* Cancel the posting of a new forum topic */ 921 980 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 } 924 984 925 985 jq('#new-topic-post').slideUp(200); … … 936 996 937 997 /* 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() { 939 999 // invites-loop template contains a div with the .invite class 940 1000 // We use the existence of this div to check for old- vs new- 941 1001 // 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; 943 1004 944 1005 jq('.ajax-loader').toggle(); … … 949 1010 } 950 1011 951 varfriend_id = jq(this).val();952 953 if ( jq(this).prop('checked') == true ) {954 varfriend_action = 'invite';1012 friend_id = jq(this).val(); 1013 1014 if ( jq(this).prop('checked') === true ) { 1015 friend_action = 'invite'; 955 1016 } else { 956 varfriend_action = 'uninvite';1017 friend_action = 'uninvite'; 957 1018 } 958 1019 … … 965 1026 'friend_action': friend_action, 966 1027 'cookie': bp_get_cookies(), 967 '_wpnonce': jq( "#_wpnonce_invite_uninvite_user").val(),1028 '_wpnonce': jq('#_wpnonce_invite_uninvite_user').val(), 968 1029 'friend_id': friend_id, 969 'group_id': jq( "#group_id").val()1030 'group_id': jq('#group_id').val() 970 1031 }, 971 1032 function(response) 972 1033 { 973 if ( jq( "#message") ) {974 jq( "#message").hide();1034 if ( jq('#message') ) { 1035 jq('#message').hide(); 975 1036 } 976 1037 … … 984 1045 jq('.ajax-loader').toggle(); 985 1046 986 if ( friend_action == 'invite' ) {1047 if ( friend_action === 'invite' ) { 987 1048 jq('#friend-list').append(response); 988 } else if ( friend_action == 'uninvite' ) {1049 } else if ( friend_action === 'uninvite' ) { 989 1050 jq('#friend-list li#uid-' + friend_id).remove(); 990 1051 } … … 996 1057 997 1058 /* 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() { 999 1060 // invites-loop template contains a div with the .invite class 1000 1061 // We use the existence of this div to check for old- vs new- 1001 1062 // 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'); 1003 1065 1004 1066 jq('.ajax-loader').toggle(); 1005 1067 1006 var friend_id = jq(this).attr('id');1007 1068 friend_id = friend_id.split('-'); 1008 1069 friend_id = friend_id[1]; … … 1012 1073 'friend_action': 'uninvite', 1013 1074 'cookie': bp_get_cookies(), 1014 '_wpnonce': jq( "#_wpnonce_invite_uninvite_user").val(),1075 '_wpnonce': jq('#_wpnonce_invite_uninvite_user').val(), 1015 1076 'friend_id': friend_id, 1016 'group_id': jq( "#group_id").val()1077 'group_id': jq('#group_id').val() 1017 1078 }, 1018 1079 function(response) … … 1054 1115 } ); 1055 1116 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() { 1057 1118 var shouldconfirm = true; 1058 1119 … … 1071 1132 1072 1133 /* 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 } 1086 1146 1087 1147 if ( jq(this).hasClass('accept') ) { 1088 varaction = 'accept_friendship';1148 action = 'accept_friendship'; 1089 1149 action_div.children('a.reject').css( 'visibility', 'hidden' ); 1090 1150 } else { 1091 varaction = 'reject_friendship';1151 action = 'reject_friendship'; 1092 1152 action_div.children('a.accept').css( 'visibility', 'hidden' ); 1093 1153 } … … 1104 1164 button.removeClass('loading'); 1105 1165 1106 if ( response[0] + response[1] == '-1' ) {1166 if ( response[0] + response[1] === '-1' ) { 1107 1167 li.prepend( response.substr( 2, response.length ) ); 1108 1168 li.children('#message').hide().fadeIn(200); … … 1126 1186 jq( '#members-dir-list, #members-group-list' ).on('click', '.friendship-button a', function() { 1127 1187 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 1129 1192 fid = fid.split('-'); 1130 1193 fid = fid[1]; 1131 1194 1132 var nonce = jq(this).attr('href');1133 1195 nonce = nonce.split('?_wpnonce='); 1134 1196 nonce = nonce[1].split('&'); 1135 1197 nonce = nonce[0]; 1136 1137 var thelink = jq(this);1138 1198 1139 1199 jq.post( ajaxurl, { … … 1145 1205 function(response) 1146 1206 { 1147 var action = thelink.attr('rel');1148 varparentdiv = thelink.parent();1149 1150 if ( action == 'add' ) {1207 var action = thelink.attr('rel'); 1208 parentdiv = thelink.parent(); 1209 1210 if ( action === 'add' ) { 1151 1211 jq(parentdiv).fadeOut(200, 1152 1212 function() { … … 1158 1218 ); 1159 1219 1160 } else if ( action == 'remove' ) {1220 } else if ( action === 'remove' ) { 1161 1221 jq(parentdiv).fadeOut(200, 1162 1222 function() { … … 1176 1236 // Confirmation when clicking Leave Group in group headers 1177 1237 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 ) ) { 1179 1239 return false; 1180 1240 } … … 1182 1242 1183 1243 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 1185 1248 gid = gid.split('-'); 1186 1249 gid = gid[1]; 1187 1250 1188 var nonce = jq(this).attr('href');1189 1251 nonce = nonce.split('?_wpnonce='); 1190 1252 nonce = nonce[1].split('&'); 1191 1253 nonce = nonce[0]; 1192 1254 1193 var thelink = jq(this);1194 1195 1255 // Leave Group confirmation within directories - must intercept 1196 1256 // 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 ) ) { 1198 1258 return false; 1199 1259 } … … 1219 1279 parentdiv.fadeIn(200).html(response); 1220 1280 1221 var mygroups = jq('#groups-personal span') ;1222 var add= 1;1281 var mygroups = jq('#groups-personal span'), 1282 add = 1; 1223 1283 1224 1284 if( thelink.hasClass( 'leave-group' ) ) { … … 1259 1319 /** Message search*/ 1260 1320 jq('.message-search').on( 'click', function(event) { 1261 if ( jq(this).hasClass('no-ajax') ) 1321 if ( jq(this).hasClass('no-ajax') ) { 1262 1322 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' ) { 1267 1329 //var css_id = jq('.item-list-tabs li.selected').attr('id').split( '-' ); 1268 varobject = 'messages';1330 object = 'messages'; 1269 1331 1270 1332 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') ); … … 1275 1337 1276 1338 /* AJAX send reply functionality */ 1277 jq( "#send_reply_button").click(1339 jq('#send_reply_button').click( 1278 1340 function() { 1279 1341 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 1283 1345 jq(button).addClass('loading'); 1284 1346 … … 1286 1348 action: 'messages_send_reply', 1287 1349 '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() 1294 1356 }, 1295 1357 function(response) 1296 1358 { 1297 if ( response[0] + response[1] == "-1") {1359 if ( response[0] + response[1] === '-1' ) { 1298 1360 jq('#send-reply').prepend( response.substr( 2, response.length ) ); 1299 1361 } else { 1300 1362 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 ) { 1304 1366 jq('#send-reply').before( response ); 1305 1367 } else { … … 1308 1370 } 1309 1371 1310 jq( ".new-message").hide().slideDown( 200, function() {1372 jq('.new-message').hide().slideDown( 200, function() { 1311 1373 jq('.new-message').removeClass('new-message'); 1312 1374 }); … … 1320 1382 1321 1383 /* 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'; 1333 1397 } else { 1334 var currentClass = 'unread'1335 var newClass = 'read'1336 varunreadCount = 0;1337 varinboxCount = 1;1338 varunreadCountDisplay = 'none';1339 varaction = 'messages_markread';1398 currentClass = 'unread'; 1399 newClass = 'read'; 1400 unreadCount = 0; 1401 inboxCount = 1; 1402 unreadCountDisplay = 'none'; 1403 action = 'messages_markread'; 1340 1404 } 1341 1405 … … 1346 1410 jq('#m-' + jq(this).attr('value')).removeClass(currentClass); 1347 1411 jq('#m-' + jq(this).attr('value')).addClass(newClass); 1348 varthread_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(); 1349 1413 1350 1414 jq('#m-' + jq(this).attr('value') + ' td span.unread-count').html(unreadCount); 1351 1415 jq('#m-' + jq(this).attr('value') + ' td span.unread-count').css('display', unreadCountDisplay); 1352 1416 1353 varinboxcount = jq('tr.unread').length;1417 inboxcount = jq('tr.unread').length; 1354 1418 1355 1419 jq('#user-messages span').html( inboxcount ); 1356 1420 1357 if ( i != checkboxes.length - 1 ) {1358 checkboxes_tosend += ',' 1421 if ( i !== checkboxes.length - 1 ) { 1422 checkboxes_tosend += ','; 1359 1423 } 1360 1424 } … … 1370 1434 /* Selecting unread and read messages in inbox */ 1371 1435 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'; 1374 1439 1375 1440 checkboxes.each( function(i) { 1376 checkboxes[i].checked = ""; 1377 }); 1378 1379 var checked_value = "checked"; 1441 checkboxes[i].checked = ''; 1442 }); 1443 1380 1444 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"]'); 1383 1447 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"]'); 1386 1450 break; 1387 case '' 1388 checked_value = "";1451 case '': 1452 checked_value = ''; 1389 1453 break; 1390 1454 } … … 1397 1461 /* Bulk delete messages */ 1398 1462 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' ) ) ) { 1400 1464 return; 1401 1465 } 1402 1466 1403 1467 checkboxes_tosend = ''; 1404 checkboxes = jq( "#message-threads tr td input[type='checkbox']");1468 checkboxes = jq('#message-threads tr td input[type="checkbox"]'); 1405 1469 1406 1470 jq('#message').remove(); … … 1408 1472 1409 1473 jq(checkboxes).each( function(i) { 1410 if( jq(this).is(':checked') ) 1474 if( jq(this).is(':checked') ) { 1411 1475 checkboxes_tosend += jq(this).attr('value') + ','; 1412 }); 1413 1414 if ( '' == checkboxes_tosend ) { 1476 } 1477 }); 1478 1479 if ( '' === checkboxes_tosend ) { 1415 1480 jq(this).removeClass('loading'); 1416 1481 return false; … … 1421 1486 'thread_ids': checkboxes_tosend 1422 1487 }, function(response) { 1423 if ( response[0] + response[1] == "-1") {1488 if ( response[0] + response[1] === '-1' ) { 1424 1489 jq('#message-threads').prepend( response.substr( 2, response.length ) ); 1425 1490 } else { … … 1437 1502 1438 1503 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'); 1440 1505 }); 1441 1506 … … 1444 1509 1445 1510 /* Close site wide notices in the sidebar */ 1446 jq( "#close-notice").on( 'click', function() {1511 jq('#close-notice').on( 'click', function() { 1447 1512 jq(this).addClass('loading'); 1448 1513 jq('#sidebar div.error').remove(); … … 1453 1518 }, 1454 1519 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' ) { 1458 1523 jq('.notice').prepend( response.substr( 2, response.length ) ); 1459 1524 jq( '#sidebar div.error').hide().fadeIn( 200 ); … … 1466 1531 1467 1532 /* 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() { 1469 1534 jq(this).addClass('sfhover'); 1470 1535 }); 1471 1536 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() { 1473 1538 jq(this).removeClass('sfhover'); 1474 1539 }); … … 1501 1566 1502 1567 /* 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') ) { 1504 1569 jq('body').attr('class', jq('body').attr('class').replace( /no-js/,'js' ) ); 1570 } 1505 1571 1506 1572 /** Activity HeartBeat ************************************************/ 1507 1573 1508 1574 // 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' ) { 1510 1576 1511 1577 wp.heartbeat.interval( Number( BP_DTheme.pulse ) ); … … 1513 1579 jq.fn.extend({ 1514 1580 'heartbeat-send': function() { 1515 return this.bind( 'heartbeat-send.buddypress' ); 1516 }, 1517 }); 1518 1581 return this.bind( 'heartbeat-send.buddypress' ); 1582 } 1583 }); 1519 1584 } 1520 1585 … … 1534 1599 } 1535 1600 1536 if ( 0 == activity_last_recorded || Number( firstrow ) > activity_last_recorded )1601 if ( 0 === activity_last_recorded || Number( firstrow ) > activity_last_recorded ) { 1537 1602 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; 1540 1606 }); 1541 1607 … … 1544 1610 1545 1611 // Only proceed if we have newest activities 1546 if ( ! data ['bp_activity_newest_activities']) {1612 if ( ! data.bp_activity_newest_activities ) { 1547 1613 return; 1548 1614 } 1549 1615 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' ) ) { 1554 1620 return; 1621 } 1555 1622 1556 1623 jq( '#buddypress ul.activity-list' ).prepend( '<li class="load-newest"><a href="#newest">' + BP_DTheme.newest + '</a></li>' ); … … 1565 1632 } ); 1566 1633 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 ) { 1568 1635 jq('#activity-filter-select select option[value="' + jq.cookie('bp-activity-filter') + '"]').prop( 'selected', true ); 1636 } 1569 1637 1570 1638 /* Activity Tab Set */ … … 1580 1648 function bp_init_objects(objects) { 1581 1649 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 ) { 1583 1651 jq('#' + objects[i] + '-order-select select option[value="' + jq.cookie('bp-' + objects[i] + '-filter') + '"]').prop( 'selected', true ); 1652 } 1584 1653 1585 1654 if ( null != jq.cookie('bp-' + objects[i] + '-scope') && jq('div.' + objects[i]).length ) { … … 1594 1663 /* Filter the current content list (groups/members/blogs/topics) */ 1595 1664 function bp_filter_request( object, filter, scope, target, search_terms, page, extras, caller, template ) { 1596 if ( 'activity' == object )1665 if ( 'activity' === object ) { 1597 1666 return false; 1598 1599 if ( jq.query.get('s') && !search_terms ) 1667 } 1668 1669 if ( jq.query.get('s') && !search_terms ) { 1600 1670 search_terms = jq.query.get('s'); 1601 1602 if ( null == scope ) 1671 } 1672 1673 if ( null === scope ) { 1603 1674 scope = 'all'; 1675 } 1604 1676 1605 1677 /* Save the settings we want to remain persistent to a cookie */ … … 1622 1694 jq('.item-list-tabs select option[value="' + filter + '"]').prop( 'selected', true ); 1623 1695 1624 if ( 'friends' == object || 'group_members'== object ) {1696 if ( 'friends' === object || 'group_members' === object ) { 1625 1697 object = 'members'; 1626 1698 } 1627 1699 1628 if ( bp_ajax_request ) 1700 if ( bp_ajax_request ) { 1629 1701 bp_ajax_request.abort(); 1702 } 1630 1703 1631 1704 bp_ajax_request = jq.post( ajaxurl, { … … 1643 1716 { 1644 1717 /* animate to top if called from bottom pagination */ 1645 if ( caller == 'pag-bottom' && jq('#subnav').length ) {1718 if ( caller === 'pag-bottom' && jq('#subnav').length ) { 1646 1719 var top = jq('#subnav').parent(); 1647 1720 jq('html,body').animate({scrollTop: top.offset().top}, 'slow', function() { … … 1649 1722 jq(this).html(response); 1650 1723 jq(this).fadeIn(100); 1651 1724 }); 1652 1725 }); 1653 1726 … … 1656 1729 jq(this).html(response); 1657 1730 jq(this).fadeIn(100); 1658 1731 }); 1659 1732 } 1660 1733 … … 1688 1761 jq('.widget_bp_activity_widget h2 span.ajax-loader').show(); 1689 1762 1690 if ( bp_ajax_request ) 1763 if ( bp_ajax_request ) { 1691 1764 bp_ajax_request.abort(); 1765 } 1692 1766 1693 1767 bp_ajax_request = jq.post( ajaxurl, { 1694 1768 action: 'activity_widget_filter', 1695 1769 'cookie': bp_get_cookies(), 1696 '_wpnonce_activity_filter': jq( "#_wpnonce_activity_filter").val(),1770 '_wpnonce_activity_filter': jq('#_wpnonce_activity_filter').val(), 1697 1771 'scope': scope, 1698 1772 'filter': filter … … 1711 1785 1712 1786 /* Update the feed link */ 1713 if ( null != response.feed_url ) 1787 if ( null != response.feed_url ) { 1714 1788 jq('.directory #subnav li.feed a, .home-page #subnav li.feed a').attr('href', response.feed_url); 1789 } 1715 1790 1716 1791 jq('.item-list-tabs li.selected').removeClass('loading'); … … 1721 1796 /* Hide long lists of activity comments, only show the latest five root comments. */ 1722 1797 function 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 ) { 1726 1802 return false; 1803 } 1727 1804 1728 1805 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 } 1738 1818 1739 1819 comment_lis.each( function(i) { … … 1743 1823 jq(this).toggle(); 1744 1824 1745 if ( !i ) 1825 if ( !i ) { 1746 1826 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 } 1747 1828 } 1748 1829 }); … … 1754 1835 1755 1836 function 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 = ''; 1761 1844 } 1762 1845 else { 1763 checkboxes[i].checked = "checked";1846 checkboxes[i].checked = 'checked'; 1764 1847 } 1765 1848 } … … 1798 1881 /* Returns a querystring of BP cookies (cookies beginning with 'bp-') */ 1799 1882 function 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; 1805 1887 1806 1888 // loop through cookies 1807 for ( vari = 0; i < allCookies.length; i++) {1808 varcookie = allCookies[i];1809 var delimiter = cookie.indexOf("=");1810 varname = jq.trim( unescape( cookie.slice(0, delimiter) ) );1811 va r 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) ); 1812 1894 1813 1895 // if BP cookie, store it 1814 if ( name.indexOf(cookiePrefix) == 0 ) {1896 if ( name.indexOf(cookiePrefix) === 0 ) { 1815 1897 bpCookies[name] = value; 1816 1898 } -
trunk/src/bp-xprofile/admin/js/admin.js
r8180 r8378 1 /* exported add_option, show_options, hide, fixHelper */ 2 /* jshint scripturl: true */ 3 1 4 function 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 11 18 12 19 newDiv.setAttribute('id', forWhat + '_div' + theId); … … 19 26 span.appendChild( txt ); 20 27 21 if ( forWhat == 'checkbox' || forWhat== 'multiselectbox' ) {28 if ( forWhat === 'checkbox' || forWhat === 'multiselectbox' ) { 22 29 isDefault.setAttribute( 'type', 'checkbox' ); 23 30 isDefault.setAttribute( 'name', 'isDefault_' + forWhat + '_option[' + theId + ']' ); … … 31 38 span1.appendChild( txt1 ); 32 39 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 + '")' ); 37 42 toDelete.setAttribute( 'class', 'delete' ); 38 43 toDelete.appendChild( toDeleteText ); … … 40 45 newDiv.appendChild( span ); 41 46 newDiv.appendChild( newOption ); 42 newDiv.appendChild( document.createTextNode( " ") );47 newDiv.appendChild( document.createTextNode( ' ' ) ); 43 48 newDiv.appendChild( isDefault ); 44 49 newDiv.appendChild( span1 ); … … 50 55 51 56 // set focus on newly created element 52 document.getElementById(forWhat + "_option"+ theId).focus();57 document.getElementById(forWhat + '_option' + theId).focus(); 53 58 54 59 theId++; 55 60 56 document.getElementById(forWhat + "_option_number").value = theId;61 document.getElementById(forWhat + '_option_number').value = theId; 57 62 } 58 63 … … 63 68 document.getElementById( 'checkbox' ).style.display = 'none'; 64 69 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 } 76 85 } 77 86 78 87 function 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'; 82 93 // 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' ); 84 95 document.getElementById( field_id ).value = ''; 85 96 } … … 126 137 'option_id': theId 127 138 }, 128 function( response) {} );139 function() {} ); 129 140 } ); 130 141 131 142 // 132 143 jQuery( '[id^="sort_order_"]' ).change(function() { 133 if ( jQuery( this ).val() != 'custom' ) {144 if ( jQuery( this ).val() !== 'custom' ) { 134 145 destroySortableFieldOptions(); 135 146 } else { … … 156 167 'group_order': jQuery( this ).sortable( 'serialize' ) 157 168 }, 158 function( response) {} );169 function() {} ); 159 170 } 160 171 }).disableSelection(); … … 175 186 'field_group_id': jQuery(this).attr( 'id' ) 176 187 }, 177 function( response) {} );188 function() {} ); 178 189 } 179 190 }) … … 189 200 190 201 // 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 193 205 set_tab_items( $tabs ); 194 206 … … 203 215 // When field is dropped on tab 204 216 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 210 219 211 220 // Remove helper class … … 219 228 220 229 // 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 ); 222 231 223 232 // Refresh $list variable … … 229 238 action: 'xprofile_reorder_fields', 230 239 'cookie': encodeURIComponent(document.cookie), 231 '_wpnonce_reorder_fields': jQuery( "input#_wpnonce_reorder_fields").val(),240 '_wpnonce_reorder_fields': jQuery( 'input#_wpnonce_reorder_fields' ).val(), 232 241 'field_order': jQuery( $list ).sortable( 'serialize' ), 233 242 'field_group_id': jQuery( $list ).attr( 'id' ) 234 243 }, 235 function( response) {} );244 function() {} ); 236 245 }); 237 246 }, 238 over: function( event, ui) {247 over: function() { 239 248 jQuery(this).addClass( 'drop-candidate' ); 240 249 }, 241 out: function( event, ui) {250 out: function() { 242 251 jQuery(this).removeClass( 'drop-candidate' ); 243 252 }
Note: See TracChangeset
for help on using the changeset viewer.