| 1 | | // AJAX Functions |
| 2 | | var jq = jQuery; |
| 3 | | |
| 4 | | // Global variable to prevent multiple AJAX requests |
| 5 | | var bp_ajax_request = null; |
| 6 | | |
| 7 | | jq(document).ready( function() { |
| 8 | | /**** Page Load Actions *******************************************************/ |
| 9 | | |
| 10 | | /* Hide Forums Post Form */ |
| 11 | | if ( jq('div.forums').length ) |
| 12 | | jq('div#new-topic-post').hide(); |
| 13 | | |
| 14 | | /* Activity filter and scope set */ |
| 15 | | bp_init_activity(); |
| 16 | | |
| 17 | | /* Object filter and scope set. */ |
| 18 | | var objects = [ 'members', 'groups', 'blogs', 'forums' ]; |
| 19 | | bp_init_objects( objects ); |
| 20 | | |
| 21 | | /* @mention Compose Scrolling */ |
| 22 | | if ( jq.query.get('r') ) { |
| 23 | | if ( jq('textarea#whats-new').length ) { |
| 24 | | jq.scrollTo( jq('textarea#whats-new'), 500, { offset:-125, easing:'easeout' } ); |
| 25 | | jq('textarea#whats-new').focus(); |
| 26 | | } |
| 27 | | } |
| 28 | | |
| 29 | | /* @mention username help button display */ |
| 30 | | if ( jq( 'span.highlight span' ).length ) |
| 31 | | jq( 'span.highlight span' ).toggle(); |
| 32 | | |
| 33 | | /**** Activity Posting ********************************************************/ |
| 34 | | |
| 35 | | /* New posts */ |
| 36 | | jq("input#aw-whats-new-submit").click( function() { |
| 37 | | var button = jq(this); |
| 38 | | var form = button.parent().parent().parent().parent(); |
| 39 | | |
| 40 | | form.children().each( function() { |
| 41 | | if ( jq.nodeName(this, "textarea") || jq.nodeName(this, "input") ) |
| 42 | | jq(this).attr( 'disabled', 'disabled' ); |
| 43 | | }); |
| 44 | | |
| 45 | | jq( 'form#' + form.attr('id') + ' span.ajax-loader' ).show(); |
| 46 | | |
| 47 | | /* Remove any errors */ |
| 48 | | jq('div.error').remove(); |
| 49 | | button.attr('disabled','disabled'); |
| 50 | | |
| 51 | | /* Default POST values */ |
| 52 | | var object = ''; |
| 53 | | var item_id = jq("#whats-new-post-in").val(); |
| 54 | | var content = jq("textarea#whats-new").val(); |
| 55 | | |
| 56 | | /* Set object for non-profile posts */ |
| 57 | | if ( item_id > 0 ) { |
| 58 | | object = jq("#whats-new-post-object").val(); |
| 59 | | } |
| 60 | | |
| 61 | | jq.post( ajaxurl, { |
| 62 | | action: 'post_update', |
| 63 | | 'cookie': encodeURIComponent(document.cookie), |
| 64 | | '_wpnonce_post_update': jq("input#_wpnonce_post_update").val(), |
| 65 | | 'content': content, |
| 66 | | 'object': object, |
| 67 | | 'item_id': item_id |
| 68 | | }, |
| 69 | | function(response) |
| 70 | | { |
| 71 | | jq( 'form#' + form.attr('id') + ' span.ajax-loader' ).hide(); |
| 72 | | |
| 73 | | form.children().each( function() { |
| 74 | | if ( jq.nodeName(this, "textarea") || jq.nodeName(this, "input") ) |
| 75 | | jq(this).attr( 'disabled', '' ); |
| 76 | | }); |
| 77 | | |
| 78 | | /* Check for errors and append if found. */ |
| 79 | | if ( response[0] + response[1] == '-1' ) { |
| 80 | | form.prepend( response.substr( 2, response.length ) ); |
| 81 | | jq( 'form#' + form.attr('id') + ' div.error').hide().fadeIn( 200 ); |
| 82 | | button.attr("disabled", ''); |
| 83 | | } else { |
| 84 | | if ( 0 == jq("ul.activity-list").length ) { |
| 85 | | jq("div.error").slideUp(100).remove(); |
| 86 | | jq("div#message").slideUp(100).remove(); |
| 87 | | jq("div.activity").append( '<ul id="activity-stream" class="activity-list item-list">' ); |
| 88 | | } |
| 89 | | |
| 90 | | jq("ul.activity-list").prepend(response); |
| 91 | | jq("ul.activity-list li:first").addClass('new-update'); |
| 92 | | jq("li.new-update").hide().slideDown( 300 ); |
| 93 | | jq("li.new-update").removeClass( 'new-update' ); |
| 94 | | jq("textarea#whats-new").val(''); |
| 95 | | |
| 96 | | /* Re-enable the submit button after 8 seconds. */ |
| 97 | | setTimeout( function() { button.attr("disabled", ''); }, 8000 ); |
| 98 | | } |
| 99 | | }); |
| 100 | | |
| 101 | | return false; |
| 102 | | }); |
| 103 | | |
| 104 | | /* List tabs event delegation */ |
| 105 | | jq('div.activity-type-tabs').click( function(event) { |
| 106 | | var target = jq(event.target).parent(); |
| 107 | | |
| 108 | | if ( event.target.nodeName == 'STRONG' || event.target.nodeName == 'SPAN' ) |
| 109 | | target = target.parent(); |
| 110 | | else if ( event.target.nodeName != 'A' ) |
| 111 | | return false; |
| 112 | | |
| 113 | | /* Reset the page */ |
| 114 | | jq.cookie( 'bp-activity-oldestpage', 1, {path: '/'} ); |
| 115 | | |
| 116 | | /* Activity Stream Tabs */ |
| 117 | | var scope = target.attr('id').substr( 9, target.attr('id').length ); |
| 118 | | var filter = jq("#activity-filter-select select").val(); |
| 119 | | |
| 120 | | if ( scope == 'mentions' ) |
| 121 | | jq( 'li#' + target.attr('id') + ' a strong' ).remove(); |
| 122 | | |
| 123 | | bp_activity_request(scope, filter, target); |
| 124 | | |
| 125 | | return false; |
| 126 | | }); |
| 127 | | |
| 128 | | /* Activity filter select */ |
| 129 | | jq('#activity-filter-select select').change( function() { |
| 130 | | var selected_tab = jq( 'div.activity-type-tabs li.selected' ); |
| 131 | | |
| 132 | | if ( !selected_tab.length ) |
| 133 | | var scope = null; |
| 134 | | else |
| 135 | | var scope = selected_tab.attr('id').substr( 9, selected_tab.attr('id').length ); |
| 136 | | |
| 137 | | var filter = jq(this).val(); |
| 138 | | |
| 139 | | bp_activity_request(scope, filter); |
| 140 | | |
| 141 | | return false; |
| 142 | | }); |
| 143 | | |
| 144 | | /* Stream event delegation */ |
| 145 | | jq('div.activity').click( function(event) { |
| 146 | | var target = jq(event.target); |
| 147 | | |
| 148 | | /* Favoriting activity stream items */ |
| 149 | | if ( target.attr('class') == 'fav' || target.attr('class') == 'unfav' ) { |
| 150 | | var type = target.attr('class') |
| 151 | | var parent = target.parent().parent().parent(); |
| 152 | | var parent_id = parent.attr('id').substr( 9, parent.attr('id').length ); |
| 153 | | |
| 154 | | target.addClass('loading'); |
| 155 | | |
| 156 | | jq.post( ajaxurl, { |
| 157 | | action: 'activity_mark_' + type, |
| 158 | | 'cookie': encodeURIComponent(document.cookie), |
| 159 | | 'id': parent_id |
| 160 | | }, |
| 161 | | function(response) { |
| 162 | | target.removeClass('loading'); |
| 163 | | |
| 164 | | target.fadeOut( 100, function() { |
| 165 | | jq(this).html(response); |
| 166 | | jq(this).fadeIn(100); |
| 167 | | }); |
| 168 | | |
| 169 | | if ( 'fav' == type ) { |
| 170 | | if ( !jq('div.item-list-tabs li#activity-favorites').length ) |
| 171 | | jq('div.item-list-tabs ul li#activity-mentions').before( '<li id="activity-favorites"><a href="#">' + BP_DTheme.my_favs + ' (<span>0</span>)</a></li>'); |
| 172 | | |
| 173 | | target.removeClass('fav'); |
| 174 | | target.addClass('unfav'); |
| 175 | | |
| 176 | | jq('div.item-list-tabs ul li#activity-favorites span').html( Number( jq('div.item-list-tabs ul li#activity-favorites span').html() ) + 1 ); |
| 177 | | } else { |
| 178 | | target.removeClass('unfav'); |
| 179 | | target.addClass('fav'); |
| 180 | | |
| 181 | | jq('div.item-list-tabs ul li#activity-favorites span').html( Number( jq('div.item-list-tabs ul li#activity-favorites span').html() ) - 1 ); |
| 182 | | |
| 183 | | if ( !Number( jq('div.item-list-tabs ul li#activity-favorites span').html() ) ) { |
| 184 | | if ( jq('div.item-list-tabs ul li#activity-favorites').hasClass('selected') ) |
| 185 | | bp_activity_request( null, null ); |
| 186 | | |
| 187 | | jq('div.item-list-tabs ul li#activity-favorites').remove(); |
| 188 | | } |
| 189 | | } |
| 190 | | |
| 191 | | if ( 'activity-favorites' == jq( 'div.item-list-tabs li.selected').attr('id') ) |
| 192 | | target.parent().parent().parent().slideUp(100); |
| 193 | | }); |
| 194 | | |
| 195 | | return false; |
| 196 | | } |
| 197 | | |
| 198 | | /* Delete activity stream items */ |
| 199 | | if ( target.hasClass('delete-activity') ) { |
| 200 | | var li = target.parents('div.activity ul li'); |
| 201 | | var id = li.attr('id').substr( 9, li.attr('id').length ); |
| 202 | | var link_href = target.attr('href'); |
| 203 | | |
| 204 | | var nonce = link_href.split('_wpnonce='); |
| 205 | | nonce = nonce[1]; |
| 206 | | |
| 207 | | target.addClass('loading'); |
| 208 | | |
| 209 | | jq.post( ajaxurl, { |
| 210 | | action: 'delete_activity', |
| 211 | | 'cookie': encodeURIComponent(document.cookie), |
| 212 | | 'id': id, |
| 213 | | '_wpnonce': nonce |
| 214 | | }, |
| 215 | | function(response) { |
| 216 | | target.removeClass('loading'); |
| 217 | | |
| 218 | | if ( response[0] + response[1] == '-1' ) { |
| 219 | | li.prepend( response.substr( 2, response.length ) ); |
| 220 | | li.children('div#message').hide().fadeIn(200); |
| 221 | | } else { |
| 222 | | li.slideUp(200); |
| 223 | | } |
| 224 | | }); |
| 225 | | |
| 226 | | return false; |
| 227 | | } |
| 228 | | |
| 229 | | /* Load more updates at the end of the page */ |
| 230 | | if ( target.parent().attr('class') == 'load-more' ) { |
| 231 | | jq("#content li.load-more").addClass('loading'); |
| 232 | | |
| 233 | | if ( null == jq.cookie('bp-activity-oldestpage') ) |
| 234 | | jq.cookie('bp-activity-oldestpage', 1, {path: '/'} ); |
| 235 | | |
| 236 | | var oldest_page = ( jq.cookie('bp-activity-oldestpage') * 1 ) + 1; |
| 237 | | |
| 238 | | jq.post( ajaxurl, { |
| 239 | | action: 'activity_get_older_updates', |
| 240 | | 'cookie': encodeURIComponent(document.cookie), |
| 241 | | 'page': oldest_page |
| 242 | | }, |
| 243 | | function(response) |
| 244 | | { |
| 245 | | jq("#content li.load-more").removeClass('loading'); |
| 246 | | jq.cookie( 'bp-activity-oldestpage', oldest_page, {path: '/'} ); |
| 247 | | jq("#content ul.activity-list").append(response.contents); |
| 248 | | |
| 249 | | target.parent().hide(); |
| 250 | | }, 'json' ); |
| 251 | | |
| 252 | | return false; |
| 253 | | } |
| 254 | | }); |
| 255 | | |
| 256 | | /**** Activity Comments *******************************************************/ |
| 257 | | |
| 258 | | /* Hide all activity comment forms */ |
| 259 | | jq('form.ac-form').hide(); |
| 260 | | |
| 261 | | /* Hide excess comments */ |
| 262 | | if ( jq('div.activity-comments').length ) |
| 263 | | bp_dtheme_hide_comments(); |
| 264 | | |
| 265 | | /* Activity list event delegation */ |
| 266 | | jq('div.activity').click( function(event) { |
| 267 | | var target = jq(event.target); |
| 268 | | |
| 269 | | /* Comment / comment reply links */ |
| 270 | | if ( target.attr('class') == 'acomment-reply' || target.parent().attr('class') == 'acomment-reply' ) { |
| 271 | | if ( target.parent().attr('class') == 'acomment-reply' ) |
| 272 | | target = target.parent(); |
| 273 | | |
| 274 | | var id = target.attr('id'); |
| 275 | | ids = id.split('-'); |
| 276 | | |
| 277 | | var a_id = ids[2] |
| 278 | | var c_id = target.attr('href').substr( 10, target.attr('href').length ); |
| 279 | | var form = jq( '#ac-form-' + a_id ); |
| 280 | | |
| 281 | | var form = jq( '#ac-form-' + ids[2] ); |
| 282 | | |
| 283 | | form.css( 'display', 'none' ); |
| 284 | | form.removeClass('root'); |
| 285 | | jq('.ac-form').hide(); |
| 286 | | |
| 287 | | /* Hide any error messages */ |
| 288 | | form.children('div').each( function() { |
| 289 | | if ( jq(this).hasClass( 'error' ) ) |
| 290 | | jq(this).hide(); |
| 291 | | }); |
| 292 | | |
| 293 | | if ( ids[1] != 'comment' ) { |
| 294 | | jq('div.activity-comments li#acomment-' + c_id).append( form ); |
| 295 | | } else { |
| 296 | | jq('li#activity-' + a_id + ' div.activity-comments').append( form ); |
| 297 | | } |
| 298 | | |
| 299 | | if ( form.parent().attr( 'class' ) == 'activity-comments' ) |
| 300 | | form.addClass('root'); |
| 301 | | |
| 302 | | form.slideDown( 200 ); |
| 303 | | jq.scrollTo( form, 500, { offset:-100, easing:'easeout' } ); |
| 304 | | jq('#ac-form-' + ids[2] + ' textarea').focus(); |
| 305 | | |
| 306 | | return false; |
| 307 | | } |
| 308 | | |
| 309 | | /* Activity comment posting */ |
| 310 | | if ( target.attr('name') == 'ac_form_submit' ) { |
| 311 | | var form = target.parent().parent(); |
| 312 | | var form_parent = form.parent(); |
| 313 | | var form_id = form.attr('id').split('-'); |
| 314 | | |
| 315 | | if ( 'activity-comments' !== form_parent.attr('class') ) { |
| 316 | | var tmp_id = form_parent.attr('id').split('-'); |
| 317 | | var comment_id = tmp_id[1]; |
| 318 | | } else { |
| 319 | | var comment_id = form_id[2]; |
| 320 | | } |
| 321 | | |
| 322 | | /* Hide any error messages */ |
| 323 | | jq( 'form#' + form + ' div.error').hide(); |
| 324 | | form.addClass('loading'); |
| 325 | | target.css('disabled', 'disabled'); |
| 326 | | |
| 327 | | jq.post( ajaxurl, { |
| 328 | | action: 'new_activity_comment', |
| 329 | | 'cookie': encodeURIComponent(document.cookie), |
| 330 | | '_wpnonce_new_activity_comment': jq("input#_wpnonce_new_activity_comment").val(), |
| 331 | | 'comment_id': comment_id, |
| 332 | | 'form_id': form_id[2], |
| 333 | | 'content': jq('form#' + form.attr('id') + ' textarea').val() |
| 334 | | }, |
| 335 | | function(response) |
| 336 | | { |
| 337 | | form.removeClass('loading'); |
| 338 | | |
| 339 | | /* Check for errors and append if found. */ |
| 340 | | if ( response[0] + response[1] == '-1' ) { |
| 341 | | form.append( response.substr( 2, response.length ) ).hide().fadeIn( 200 ); |
| 342 | | target.attr("disabled", ''); |
| 343 | | } else { |
| 344 | | form.fadeOut( 200, |
| 345 | | function() { |
| 346 | | if ( 0 == form.parent().children('ul').length ) { |
| 347 | | if ( form.parent().attr('class') == 'activity-comments' ) |
| 348 | | form.parent().prepend('<ul></ul>'); |
| 349 | | else |
| 350 | | form.parent().append('<ul></ul>'); |
| 351 | | } |
| 352 | | |
| 353 | | form.parent().children('ul').append(response).hide().fadeIn( 200 ); |
| 354 | | form.children('textarea').val(''); |
| 355 | | form.parent().parent().addClass('has-comments'); |
| 356 | | } |
| 357 | | ); |
| 358 | | jq( 'form#' + form + ' textarea').val(''); |
| 359 | | |
| 360 | | /* Increase the "Reply (X)" button count */ |
| 361 | | jq('li#activity-' + form_id[2] + ' a.acomment-reply span').html( Number( jq('li#activity-' + form_id[2] + ' a.acomment-reply span').html() ) + 1 ); |
| 362 | | |
| 363 | | /* Re-enable the submit button after 5 seconds. */ |
| 364 | | setTimeout( function() { target.attr("disabled", ''); }, 5000 ); |
| 365 | | } |
| 366 | | }); |
| 367 | | |
| 368 | | return false; |
| 369 | | } |
| 370 | | |
| 371 | | /* Deleting an activity comment */ |
| 372 | | if ( target.hasClass('acomment-delete') ) { |
| 373 | | var link_href = target.attr('href'); |
| 374 | | var comment_li = target.parent().parent(); |
| 375 | | var form = comment_li.parents('div.activity-comments').children('form'); |
| 376 | | |
| 377 | | var nonce = link_href.split('_wpnonce='); |
| 378 | | nonce = nonce[1]; |
| 379 | | |
| 380 | | var comment_id = link_href.split('cid='); |
| 381 | | comment_id = comment_id[1].split('&'); |
| 382 | | comment_id = comment_id[0]; |
| 383 | | |
| 384 | | target.addClass('loading'); |
| 385 | | |
| 386 | | /* Remove any error messages */ |
| 387 | | jq('div.activity-comments ul div.error').remove(); |
| 388 | | |
| 389 | | /* Reset the form position */ |
| 390 | | comment_li.parents('div.activity-comments').append(form); |
| 391 | | |
| 392 | | jq.post( ajaxurl, { |
| 393 | | action: 'delete_activity_comment', |
| 394 | | 'cookie': encodeURIComponent(document.cookie), |
| 395 | | '_wpnonce': nonce, |
| 396 | | 'id': comment_id |
| 397 | | }, |
| 398 | | function(response) |
| 399 | | { |
| 400 | | /* Check for errors and append if found. */ |
| 401 | | if ( response[0] + response[1] == '-1' ) { |
| 402 | | comment_li.prepend( response.substr( 2, response.length ) ).hide().fadeIn( 200 ); |
| 403 | | } else { |
| 404 | | var children = jq( 'li#' + comment_li.attr('id') + ' ul' ).children('li'); |
| 405 | | var child_count = 0; |
| 406 | | jq(children).each( function() { |
| 407 | | if ( !jq(this).is(':hidden') ) |
| 408 | | child_count++; |
| 409 | | }); |
| 410 | | comment_li.fadeOut(200); |
| 411 | | |
| 412 | | /* Decrease the "Reply (X)" button count */ |
| 413 | | var parent_li = comment_li.parents('ul#activity-stream > li'); |
| 414 | | jq('li#' + parent_li.attr('id') + ' a.acomment-reply span').html( jq('li#' + parent_li.attr('id') + ' a.acomment-reply span').html() - ( 1 + child_count ) ); |
| 415 | | } |
| 416 | | }); |
| 417 | | |
| 418 | | return false; |
| 419 | | } |
| 420 | | |
| 421 | | /* Showing hidden comments - pause for half a second */ |
| 422 | | if ( target.parent().hasClass('show-all') ) { |
| 423 | | target.parent().addClass('loading'); |
| 424 | | |
| 425 | | setTimeout( function() { |
| 426 | | target.parent().parent().children('li').fadeIn(200, function() { |
| 427 | | target.parent().remove(); |
| 428 | | }); |
| 429 | | }, 600 ); |
| 430 | | |
| 431 | | return false; |
| 432 | | } |
| 433 | | }); |
| 434 | | |
| 435 | | /* Escape Key Press for cancelling comment forms */ |
| 436 | | jq(document).keydown( function(e) { |
| 437 | | e = e || window.event; |
| 438 | | if (e.target) |
| 439 | | element = e.target; |
| 440 | | else if (e.srcElement) |
| 441 | | element = e.srcElement; |
| 442 | | |
| 443 | | if( element.nodeType == 3) |
| 444 | | element = element.parentNode; |
| 445 | | |
| 446 | | if( e.ctrlKey == true || e.altKey == true || e.metaKey == true ) |
| 447 | | return; |
| 448 | | |
| 449 | | var keyCode = (e.keyCode) ? e.keyCode : e.which; |
| 450 | | |
| 451 | | if ( keyCode == 27 ) { |
| 452 | | if (element.tagName == 'TEXTAREA') { |
| 453 | | if ( jq(element).attr('class') == 'ac-input' ) |
| 454 | | jq(element).parent().parent().parent().slideUp( 200 ); |
| 455 | | } |
| 456 | | } |
| 457 | | }); |
| 458 | | |
| 459 | | /**** @mention username help tooltip **************************************/ |
| 460 | | |
| 461 | | jq('span.highlight span').click( function() { |
| 462 | | if ( !jq('div.help').length ) { |
| 463 | | jq(this).parent().after( '<div id="message" class="info help"><p>' + BP_DTheme.mention_explain + '</p></div>' ); |
| 464 | | jq('div.help').hide().slideDown(200); |
| 465 | | } else { |
| 466 | | jq('div.help').hide().remove(); |
| 467 | | } |
| 468 | | }) |
| 469 | | |
| 470 | | /**** Directory Search ****************************************************/ |
| 471 | | |
| 472 | | /* The search form on all directory pages */ |
| 473 | | jq('div.dir-search').click( function(event) { |
| 474 | | if ( jq(this).hasClass('no-ajax') ) |
| 475 | | return; |
| 476 | | |
| 477 | | var target = jq(event.target); |
| 478 | | |
| 479 | | if ( target.attr('type') == 'submit' ) { |
| 480 | | var css_id = jq('div.item-list-tabs li.selected').attr('id').split( '-' ); |
| 481 | | var object = css_id[0]; |
| 482 | | |
| 483 | | 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') ); |
| 484 | | |
| 485 | | return false; |
| 486 | | } |
| 487 | | }); |
| 488 | | |
| 489 | | /**** Tabs and Filters ****************************************************/ |
| 490 | | |
| 491 | | /* When a navigation tab is clicked - e.g. | All Groups | My Groups | */ |
| 492 | | jq('div.item-list-tabs').click( function(event) { |
| 493 | | if ( jq(this).hasClass('no-ajax') ) |
| 494 | | return; |
| 495 | | |
| 496 | | var target = jq(event.target).parent(); |
| 497 | | |
| 498 | | if ( 'LI' == event.target.parentNode.nodeName && !target.hasClass('last') ) { |
| 499 | | var css_id = target.attr('id').split( '-' ); |
| 500 | | var object = css_id[0]; |
| 501 | | |
| 502 | | if ( 'activity' == object ) |
| 503 | | return false; |
| 504 | | |
| 505 | | var scope = css_id[1]; |
| 506 | | var filter = jq("#" + object + "-order-select select").val(); |
| 507 | | var search_terms = jq("#" + object + "_search").val(); |
| 508 | | |
| 509 | | bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras') ); |
| 510 | | |
| 511 | | return false; |
| 512 | | } |
| 513 | | }); |
| 514 | | |
| 515 | | /* When the filter select box is changed re-query */ |
| 516 | | jq('li.filter select').change( function() { |
| 517 | | if ( jq('div.item-list-tabs li.selected').length ) |
| 518 | | var el = jq('div.item-list-tabs li.selected'); |
| 519 | | else |
| 520 | | var el = jq(this); |
| 521 | | |
| 522 | | var css_id = el.attr('id').split('-'); |
| 523 | | var object = css_id[0]; |
| 524 | | var scope = css_id[1]; |
| 525 | | var filter = jq(this).val(); |
| 526 | | var search_terms = false; |
| 527 | | |
| 528 | | if ( jq('div.dir-search input').length ) |
| 529 | | search_terms = jq('div.dir-search input').val(); |
| 530 | | |
| 531 | | if ( 'friends' == object ) |
| 532 | | object = 'members'; |
| 533 | | |
| 534 | | bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras') ); |
| 535 | | |
| 536 | | return false; |
| 537 | | }); |
| 538 | | |
| 539 | | /* All pagination links run through this function */ |
| 540 | | jq('div#content').click( function(event) { |
| 541 | | var target = jq(event.target); |
| 542 | | |
| 543 | | if ( target.hasClass('button') ) |
| 544 | | return true; |
| 545 | | |
| 546 | | if ( target.parent().parent().hasClass('pagination') && !target.parent().parent().hasClass('no-ajax') ) { |
| 547 | | if ( target.hasClass('dots') || target.hasClass('current') ) |
| 548 | | return false; |
| 549 | | |
| 550 | | if ( jq('div.item-list-tabs li.selected').length ) |
| 551 | | var el = jq('div.item-list-tabs li.selected'); |
| 552 | | else |
| 553 | | var el = jq('li.filter select'); |
| 554 | | |
| 555 | | var page_number = 1; |
| 556 | | var css_id = el.attr('id').split( '-' ); |
| 557 | | var object = css_id[0]; |
| 558 | | var search_terms = false; |
| 559 | | |
| 560 | | if ( jq('div.dir-search input').length ) |
| 561 | | search_terms = jq('div.dir-search input').val(); |
| 562 | | |
| 563 | | if ( jq(target).hasClass('next') ) |
| 564 | | var page_number = Number( jq('div.pagination span.current').html() ) + 1; |
| 565 | | else if ( jq(target).hasClass('prev') ) |
| 566 | | var page_number = Number( jq('div.pagination span.current').html() ) - 1; |
| 567 | | else |
| 568 | | var page_number = Number( jq(target).html() ); |
| 569 | | |
| 570 | | bp_filter_request( object, jq.cookie('bp-' + object + '-filter'), jq.cookie('bp-' + object + '-scope'), 'div.' + object, search_terms, page_number, jq.cookie('bp-' + object + '-extras') ); |
| 571 | | |
| 572 | | return false; |
| 573 | | } |
| 574 | | |
| 575 | | }); |
| 576 | | |
| 577 | | /**** New Forum Directory Post **************************************/ |
| 578 | | |
| 579 | | /* Hit the "New Topic" button on the forums directory page */ |
| 580 | | jq('a#new-topic-button').click( function() { |
| 581 | | if ( !jq('div#new-topic-post').length ) |
| 582 | | return false; |
| 583 | | |
| 584 | | if ( jq('div#new-topic-post').is(":visible") ) |
| 585 | | jq('div#new-topic-post').slideUp(200); |
| 586 | | else |
| 587 | | jq('div#new-topic-post').slideDown(200); |
| 588 | | |
| 589 | | return false; |
| 590 | | }); |
| 591 | | |
| 592 | | /* Cancel the posting of a new forum topic */ |
| 593 | | jq('input#submit_topic_cancel').click( function() { |
| 594 | | if ( !jq('div#new-topic-post').length ) |
| 595 | | return false; |
| 596 | | |
| 597 | | jq('div#new-topic-post').slideUp(200); |
| 598 | | return false; |
| 599 | | }); |
| 600 | | |
| 601 | | /* Clicking a forum tag */ |
| 602 | | jq('div#forum-directory-tags a').click( function() { |
| 603 | | bp_filter_request( 'forums', 'tags', jq.cookie('bp-forums-scope'), 'div.forums', jq(this).html().replace( / /g, '-' ), 1, jq.cookie('bp-forums-extras') ); |
| 604 | | return false; |
| 605 | | }); |
| 606 | | |
| 607 | | /** Invite Friends Interface ****************************************/ |
| 608 | | |
| 609 | | /* Select a user from the list of friends and add them to the invite list */ |
| 610 | | jq("div#invite-list input").click( function() { |
| 611 | | jq('.ajax-loader').toggle(); |
| 612 | | |
| 613 | | var friend_id = jq(this).val(); |
| 614 | | |
| 615 | | if ( jq(this).attr('checked') == true ) |
| 616 | | var friend_action = 'invite'; |
| 617 | | else |
| 618 | | var friend_action = 'uninvite'; |
| 619 | | |
| 620 | | jq('div.item-list-tabs li.selected').addClass('loading'); |
| 621 | | |
| 622 | | jq.post( ajaxurl, { |
| 623 | | action: 'groups_invite_user', |
| 624 | | 'friend_action': friend_action, |
| 625 | | 'cookie': encodeURIComponent(document.cookie), |
| 626 | | '_wpnonce': jq("input#_wpnonce_invite_uninvite_user").val(), |
| 627 | | 'friend_id': friend_id, |
| 628 | | 'group_id': jq("input#group_id").val() |
| 629 | | }, |
| 630 | | function(response) |
| 631 | | { |
| 632 | | if ( jq("#message") ) |
| 633 | | jq("#message").hide(); |
| 634 | | |
| 635 | | jq('.ajax-loader').toggle(); |
| 636 | | |
| 637 | | if ( friend_action == 'invite' ) { |
| 638 | | jq('#friend-list').append(response); |
| 639 | | } else if ( friend_action == 'uninvite' ) { |
| 640 | | jq('#friend-list li#uid-' + friend_id).remove(); |
| 641 | | } |
| 642 | | |
| 643 | | jq('div.item-list-tabs li.selected').removeClass('loading'); |
| 644 | | }); |
| 645 | | }); |
| 646 | | |
| 647 | | /* Remove a user from the list of users to invite to a group */ |
| 648 | | jq("#friend-list li a.remove").live('click', function() { |
| 649 | | jq('.ajax-loader').toggle(); |
| 650 | | |
| 651 | | var friend_id = jq(this).attr('id'); |
| 652 | | friend_id = friend_id.split('-'); |
| 653 | | friend_id = friend_id[1]; |
| 654 | | |
| 655 | | jq.post( ajaxurl, { |
| 656 | | action: 'groups_invite_user', |
| 657 | | 'friend_action': 'uninvite', |
| 658 | | 'cookie': encodeURIComponent(document.cookie), |
| 659 | | '_wpnonce': jq("input#_wpnonce_invite_uninvite_user").val(), |
| 660 | | 'friend_id': friend_id, |
| 661 | | 'group_id': jq("input#group_id").val() |
| 662 | | }, |
| 663 | | function(response) |
| 664 | | { |
| 665 | | jq('.ajax-loader').toggle(); |
| 666 | | jq('#friend-list li#uid-' + friend_id).remove(); |
| 667 | | jq('#invite-list input#f-' + friend_id).attr('checked', false); |
| 668 | | }); |
| 669 | | |
| 670 | | return false; |
| 671 | | }); |
| 672 | | |
| 673 | | /** Friendship Requests **************************************/ |
| 674 | | |
| 675 | | /* Accept and Reject friendship request buttons */ |
| 676 | | jq("ul#friend-list a.accept, ul#friend-list a.reject").click( function() { |
| 677 | | var button = jq(this); |
| 678 | | var li = jq(this).parents('ul#friend-list li'); |
| 679 | | var action_div = jq(this).parents('li div.action'); |
| 680 | | |
| 681 | | var id = li.attr('id').substr( 11, li.attr('id').length ); |
| 682 | | var link_href = button.attr('href'); |
| 683 | | |
| 684 | | var nonce = link_href.split('_wpnonce='); |
| 685 | | nonce = nonce[1]; |
| 686 | | |
| 687 | | if ( jq(this).hasClass('accepted') || jq(this).hasClass('rejected') ) |
| 688 | | return false; |
| 689 | | |
| 690 | | if ( jq(this).hasClass('accept') ) { |
| 691 | | var action = 'accept_friendship'; |
| 692 | | action_div.children('a.reject').css( 'visibility', 'hidden' ); |
| 693 | | } else { |
| 694 | | var action = 'reject_friendship'; |
| 695 | | action_div.children('a.accept').css( 'visibility', 'hidden' ); |
| 696 | | } |
| 697 | | |
| 698 | | button.addClass('loading'); |
| 699 | | |
| 700 | | jq.post( ajaxurl, { |
| 701 | | action: action, |
| 702 | | 'cookie': encodeURIComponent(document.cookie), |
| 703 | | 'id': id, |
| 704 | | '_wpnonce': nonce |
| 705 | | }, |
| 706 | | function(response) { |
| 707 | | button.removeClass('loading'); |
| 708 | | |
| 709 | | if ( response[0] + response[1] == '-1' ) { |
| 710 | | li.prepend( response.substr( 2, response.length ) ); |
| 711 | | li.children('div#message').hide().fadeIn(200); |
| 712 | | } else { |
| 713 | | button.fadeOut( 100, function() { |
| 714 | | if ( jq(this).hasClass('accept') ) { |
| 715 | | jq(this).html( BP_DTheme.accepted ).fadeIn(50); |
| 716 | | jq(this).addClass('accepted'); |
| 717 | | } else { |
| 718 | | jq(this).html( BP_DTheme.rejected ).fadeIn(50); |
| 719 | | jq(this).addClass('rejected'); |
| 720 | | } |
| 721 | | }); |
| 722 | | } |
| 723 | | }); |
| 724 | | |
| 725 | | return false; |
| 726 | | }); |
| 727 | | |
| 728 | | /* Add / Remove friendship buttons */ |
| 729 | | jq("div.friendship-button a").live('click', function() { |
| 730 | | jq(this).parent().addClass('loading'); |
| 731 | | var fid = jq(this).attr('id'); |
| 732 | | fid = fid.split('-'); |
| 733 | | fid = fid[1]; |
| 734 | | |
| 735 | | var nonce = jq(this).attr('href'); |
| 736 | | nonce = nonce.split('?_wpnonce='); |
| 737 | | nonce = nonce[1].split('&'); |
| 738 | | nonce = nonce[0]; |
| 739 | | |
| 740 | | var thelink = jq(this); |
| 741 | | |
| 742 | | jq.post( ajaxurl, { |
| 743 | | action: 'addremove_friend', |
| 744 | | 'cookie': encodeURIComponent(document.cookie), |
| 745 | | 'fid': fid, |
| 746 | | '_wpnonce': nonce |
| 747 | | }, |
| 748 | | function(response) |
| 749 | | { |
| 750 | | var action = thelink.attr('rel'); |
| 751 | | var parentdiv = thelink.parent(); |
| 752 | | |
| 753 | | if ( action == 'add' ) { |
| 754 | | jq(parentdiv).fadeOut(200, |
| 755 | | function() { |
| 756 | | parentdiv.removeClass('add_friend'); |
| 757 | | parentdiv.removeClass('loading'); |
| 758 | | parentdiv.addClass('pending'); |
| 759 | | parentdiv.fadeIn(200).html(response); |
| 760 | | } |
| 761 | | ); |
| 762 | | |
| 763 | | } else if ( action == 'remove' ) { |
| 764 | | jq(parentdiv).fadeOut(200, |
| 765 | | function() { |
| 766 | | parentdiv.removeClass('remove_friend'); |
| 767 | | parentdiv.removeClass('loading'); |
| 768 | | parentdiv.addClass('add'); |
| 769 | | parentdiv.fadeIn(200).html(response); |
| 770 | | } |
| 771 | | ); |
| 772 | | } |
| 773 | | }); |
| 774 | | return false; |
| 775 | | } ); |
| 776 | | |
| 777 | | /** Group Join / Leave Buttons **************************************/ |
| 778 | | |
| 779 | | jq("div.group-button a").live('click', function() { |
| 780 | | var gid = jq(this).parent().attr('id'); |
| 781 | | gid = gid.split('-'); |
| 782 | | gid = gid[1]; |
| 783 | | |
| 784 | | var nonce = jq(this).attr('href'); |
| 785 | | nonce = nonce.split('?_wpnonce='); |
| 786 | | nonce = nonce[1].split('&'); |
| 787 | | nonce = nonce[0]; |
| 788 | | |
| 789 | | var thelink = jq(this); |
| 790 | | |
| 791 | | jq.post( ajaxurl, { |
| 792 | | action: 'joinleave_group', |
| 793 | | 'cookie': encodeURIComponent(document.cookie), |
| 794 | | 'gid': gid, |
| 795 | | '_wpnonce': nonce |
| 796 | | }, |
| 797 | | function(response) |
| 798 | | { |
| 799 | | var parentdiv = thelink.parent(); |
| 800 | | |
| 801 | | if ( !jq('body.directory').length ) |
| 802 | | location.href = location.href; |
| 803 | | else { |
| 804 | | jq(parentdiv).fadeOut(200, |
| 805 | | function() { |
| 806 | | parentdiv.fadeIn(200).html(response); |
| 807 | | } |
| 808 | | ); |
| 809 | | } |
| 810 | | }); |
| 811 | | return false; |
| 812 | | } ); |
| 813 | | |
| 814 | | /** Button disabling ************************************************/ |
| 815 | | |
| 816 | | jq('div.pending').click(function() { |
| 817 | | return false; |
| 818 | | }); |
| 819 | | |
| 820 | | /** Alternate Highlighting ******************************************/ |
| 821 | | |
| 822 | | jq('body#bp-default table.zebra tbody tr').mouseover( function() { |
| 823 | | jq(this).addClass('over'); |
| 824 | | }).mouseout( function() { |
| 825 | | jq(this).removeClass('over'); |
| 826 | | }); |
| 827 | | |
| 828 | | jq('body#bp-default table.zebra tbody tr:odd').addClass('alt'); |
| 829 | | |
| 830 | | jq('div.message-box').each( function(i) { |
| 831 | | if ( i % 2 == 1 ) |
| 832 | | jq(this).addClass('alt'); |
| 833 | | }); |
| 834 | | |
| 835 | | /** Private Messaging ******************************************/ |
| 836 | | |
| 837 | | /* AJAX send reply functionality */ |
| 838 | | jq("input#send_reply_button").click( |
| 839 | | function() { |
| 840 | | jq('form#send-reply span.ajax-loader').toggle(); |
| 841 | | |
| 842 | | jq.post( ajaxurl, { |
| 843 | | action: 'messages_send_reply', |
| 844 | | 'cookie': encodeURIComponent(document.cookie), |
| 845 | | '_wpnonce': jq("input#send_message_nonce").val(), |
| 846 | | |
| 847 | | 'content': jq("#message_content").val(), |
| 848 | | 'send_to': jq("input#send_to").val(), |
| 849 | | 'subject': jq("input#subject").val(), |
| 850 | | 'thread_id': jq("input#thread_id").val() |
| 851 | | }, |
| 852 | | function(response) |
| 853 | | { |
| 854 | | if ( response[0] + response[1] == "-1" ) { |
| 855 | | jq('form#send-reply').prepend( response.substr( 2, response.length ) ); |
| 856 | | } else { |
| 857 | | jq('form#send-reply div#message').remove(); |
| 858 | | jq("#message_content").val(''); |
| 859 | | jq('form#send-reply').before( response ); |
| 860 | | |
| 861 | | jq("div.new-message").hide().slideDown( 200, function() { |
| 862 | | jq('div.new-message').removeClass('new-message'); |
| 863 | | }); |
| 864 | | |
| 865 | | jq('div.message-box').each( function(i) { |
| 866 | | jq(this).removeClass('alt'); |
| 867 | | if ( i % 2 != 1 ) |
| 868 | | jq(this).addClass('alt'); |
| 869 | | }); |
| 870 | | } |
| 871 | | jq('form#send-reply span.ajax-loader').toggle(); |
| 872 | | }); |
| 873 | | |
| 874 | | return false; |
| 875 | | } |
| 876 | | ); |
| 877 | | |
| 878 | | /* Marking private messages as read and unread */ |
| 879 | | jq("a#mark_as_read, a#mark_as_unread").click(function() { |
| 880 | | var checkboxes_tosend = ''; |
| 881 | | var checkboxes = jq("#message-threads tr td input[type='checkbox']"); |
| 882 | | |
| 883 | | if ( 'mark_as_unread' == jq(this).attr('id') ) { |
| 884 | | var currentClass = 'read' |
| 885 | | var newClass = 'unread' |
| 886 | | var unreadCount = 1; |
| 887 | | var inboxCount = 0; |
| 888 | | var unreadCountDisplay = 'inline'; |
| 889 | | var action = 'messages_markunread'; |
| 890 | | } else { |
| 891 | | var currentClass = 'unread' |
| 892 | | var newClass = 'read' |
| 893 | | var unreadCount = 0; |
| 894 | | var inboxCount = 1; |
| 895 | | var unreadCountDisplay = 'none'; |
| 896 | | var action = 'messages_markread'; |
| 897 | | } |
| 898 | | |
| 899 | | checkboxes.each( function(i) { |
| 900 | | if(jq(this).is(':checked')) { |
| 901 | | if ( jq('tr#m-' + jq(this).attr('value')).hasClass(currentClass) ) { |
| 902 | | checkboxes_tosend += jq(this).attr('value'); |
| 903 | | jq('tr#m-' + jq(this).attr('value')).removeClass(currentClass); |
| 904 | | jq('tr#m-' + jq(this).attr('value')).addClass(newClass); |
| 905 | | var thread_count = jq('tr#m-' + jq(this).attr('value') + ' td span.unread-count').html(); |
| 906 | | |
| 907 | | jq('tr#m-' + jq(this).attr('value') + ' td span.unread-count').html(unreadCount); |
| 908 | | jq('tr#m-' + jq(this).attr('value') + ' td span.unread-count').css('display', unreadCountDisplay); |
| 909 | | var inboxcount = jq('a#user-messages strong').html().substr( 1, jq('a#user-messages strong').html().length ); |
| 910 | | var inboxcount = inboxcount.substr( 0, inboxcount.length - 1 ); |
| 911 | | |
| 912 | | if ( !inboxcount.length ) |
| 913 | | inboxcount = 0; |
| 914 | | if ( parseInt(inboxcount) == inboxCount ) { |
| 915 | | jq('a#user-messages strong').css('display', unreadCountDisplay); |
| 916 | | jq('a#user-messages strong').html( '(' + unreadCount + ')' ); |
| 917 | | } else { |
| 918 | | if ( 'read' == currentClass ) |
| 919 | | jq('a#user-messages strong').html('(' + ( parseInt(inboxcount) + 1 ) + ')'); |
| 920 | | else |
| 921 | | jq('a#user-messages strong').html('(' + ( parseInt(inboxcount) - thread_count ) + ')'); |
| 922 | | } |
| 923 | | |
| 924 | | if ( i != checkboxes.length - 1 ) { |
| 925 | | checkboxes_tosend += ',' |
| 926 | | } |
| 927 | | } |
| 928 | | } |
| 929 | | }); |
| 930 | | jq.post( ajaxurl, { |
| 931 | | action: action, |
| 932 | | 'thread_ids': checkboxes_tosend |
| 933 | | }); |
| 934 | | return false; |
| 935 | | }); |
| 936 | | |
| 937 | | /* Selecting unread and read messages in inbox */ |
| 938 | | jq("select#message-type-select").change( |
| 939 | | function() { |
| 940 | | var selection = jq("select#message-type-select").val(); |
| 941 | | var checkboxes = jq("td input[type='checkbox']"); |
| 942 | | checkboxes.each( function(i) { |
| 943 | | checkboxes[i].checked = ""; |
| 944 | | }); |
| 945 | | |
| 946 | | switch(selection) { |
| 947 | | case 'unread': |
| 948 | | var checkboxes = jq("tr.unread td input[type='checkbox']"); |
| 949 | | break; |
| 950 | | case 'read': |
| 951 | | var checkboxes = jq("tr.read td input[type='checkbox']"); |
| 952 | | break; |
| 953 | | } |
| 954 | | if ( selection != '' ) { |
| 955 | | checkboxes.each( function(i) { |
| 956 | | checkboxes[i].checked = "checked"; |
| 957 | | }); |
| 958 | | } else { |
| 959 | | checkboxes.each( function(i) { |
| 960 | | checkboxes[i].checked = ""; |
| 961 | | }); |
| 962 | | } |
| 963 | | } |
| 964 | | ); |
| 965 | | |
| 966 | | /* Bulk delete messages */ |
| 967 | | jq("a#delete_inbox_messages, a#delete_sentbox_messages").click( function() { |
| 968 | | checkboxes_tosend = ''; |
| 969 | | checkboxes = jq("#message-threads tr td input[type='checkbox']"); |
| 970 | | |
| 971 | | jq('div#message').remove(); |
| 972 | | jq(this).addClass('loading'); |
| 973 | | |
| 974 | | jq(checkboxes).each( function(i) { |
| 975 | | if( jq(this).is(':checked') ) |
| 976 | | checkboxes_tosend += jq(this).attr('value') + ','; |
| 977 | | }); |
| 978 | | |
| 979 | | if ( '' == checkboxes_tosend ) { |
| 980 | | jq(this).removeClass('loading'); |
| 981 | | return false; |
| 982 | | } |
| 983 | | |
| 984 | | jq.post( ajaxurl, { |
| 985 | | action: 'messages_delete', |
| 986 | | 'thread_ids': checkboxes_tosend |
| 987 | | }, function(response) { |
| 988 | | if ( response[0] + response[1] == "-1" ) { |
| 989 | | jq('#message-threads').prepend( response.substr( 2, response.length ) ); |
| 990 | | } else { |
| 991 | | jq('#message-threads').before( '<div id="message" class="updated"><p>' + response + '</p></div>' ); |
| 992 | | |
| 993 | | jq(checkboxes).each( function(i) { |
| 994 | | if( jq(this).is(':checked') ) |
| 995 | | jq(this).parent().parent().fadeOut(150); |
| 996 | | }); |
| 997 | | } |
| 998 | | |
| 999 | | jq('div#message').hide().slideDown(150); |
| 1000 | | jq("a#delete_inbox_messages, a#delete_sentbox_messages").removeClass('loading'); |
| 1001 | | }); |
| 1002 | | return false; |
| 1003 | | }); |
| 1004 | | |
| 1005 | | /* Close site wide notices in the sidebar */ |
| 1006 | | jq("a#close-notice").click( function() { |
| 1007 | | jq(this).addClass('loading'); |
| 1008 | | jq('div#sidebar div.error').remove(); |
| 1009 | | |
| 1010 | | jq.post( ajaxurl, { |
| 1011 | | action: 'messages_close_notice', |
| 1012 | | 'notice_id': jq('.notice').attr('rel').substr( 2, jq('.notice').attr('rel').length ) |
| 1013 | | }, |
| 1014 | | function(response) { |
| 1015 | | jq("a#close-notice").removeClass('loading'); |
| 1016 | | |
| 1017 | | if ( response[0] + response[1] == '-1' ) { |
| 1018 | | jq('.notice').prepend( response.substr( 2, response.length ) ); |
| 1019 | | jq( 'div#sidebar div.error').hide().fadeIn( 200 ); |
| 1020 | | } else { |
| 1021 | | jq('.notice').slideUp( 100 ); |
| 1022 | | } |
| 1023 | | }); |
| 1024 | | return false; |
| 1025 | | }); |
| 1026 | | |
| 1027 | | /* Admin Bar & wp_list_pages Javascript IE6 hover class */ |
| 1028 | | jq("#wp-admin-bar ul.main-nav li, #nav li.page_item ").mouseover( function() { |
| 1029 | | jq(this).addClass('sfhover'); |
| 1030 | | }); |
| 1031 | | |
| 1032 | | jq("#wp-admin-bar ul.main-nav li, #nav li.page_item ").mouseout( function() { |
| 1033 | | jq(this).removeClass('sfhover'); |
| 1034 | | }); |
| 1035 | | |
| 1036 | | /* Clear BP cookies on logout */ |
| 1037 | | jq('a.logout').click( function() { |
| 1038 | | jq.cookie('bp-activity-scope', null, {path: '/'}); |
| 1039 | | jq.cookie('bp-activity-filter', null, {path: '/'}); |
| 1040 | | jq.cookie('bp-activity-oldestpage', null, {path: '/'}); |
| 1041 | | |
| 1042 | | var objects = [ 'members', 'groups', 'blogs', 'forums' ]; |
| 1043 | | jq(objects).each( function(i) { |
| 1044 | | jq.cookie('bp-' + objects[i] + '-scope', null, {path: '/'} ); |
| 1045 | | jq.cookie('bp-' + objects[i] + '-filter', null, {path: '/'} ); |
| 1046 | | jq.cookie('bp-' + objects[i] + '-extras', null, {path: '/'} ); |
| 1047 | | }); |
| 1048 | | }); |
| 1049 | | }); |
| 1050 | | |
| 1051 | | /* Setup activity scope and filter based on the current cookie settings. */ |
| 1052 | | function bp_init_activity() { |
| 1053 | | /* Reset the page */ |
| 1054 | | jq.cookie( 'bp-activity-oldestpage', 1, {path: '/'} ); |
| 1055 | | |
| 1056 | | if ( null != jq.cookie('bp-activity-filter') && jq('#activity-filter-select').length ) |
| 1057 | | jq('#activity-filter-select select option[value=' + jq.cookie('bp-activity-filter') + ']').attr( 'selected', 'selected' ); |
| 1058 | | |
| 1059 | | /* Activity Tab Set */ |
| 1060 | | if ( null != jq.cookie('bp-activity-scope') && jq('div.activity-type-tabs').length ) { |
| 1061 | | jq('div.activity-type-tabs li').each( function() { |
| 1062 | | jq(this).removeClass('selected'); |
| 1063 | | }); |
| 1064 | | jq('li#activity-' + jq.cookie('bp-activity-scope') + ', div.item-list-tabs li.current').addClass('selected'); |
| 1065 | | } |
| 1066 | | } |
| 1067 | | |
| 1068 | | /* Setup object scope and filter based on the current cookie settings for the object. */ |
| 1069 | | function bp_init_objects(objects) { |
| 1070 | | jq(objects).each( function(i) { |
| 1071 | | if ( null != jq.cookie('bp-' + objects[i] + '-filter') && jq('li#' + objects[i] + '-order-select select').length ) |
| 1072 | | jq('li#' + objects[i] + '-order-select select option[value=' + jq.cookie('bp-' + objects[i] + '-filter') + ']').attr( 'selected', 'selected' ); |
| 1073 | | |
| 1074 | | if ( null != jq.cookie('bp-' + objects[i] + '-scope') && jq('div.' + objects[i]).length ) { |
| 1075 | | jq('div.item-list-tabs li').each( function() { |
| 1076 | | jq(this).removeClass('selected'); |
| 1077 | | }); |
| 1078 | | jq('div.item-list-tabs li#' + objects[i] + '-' + jq.cookie('bp-' + objects[i] + '-scope') + ', div.item-list-tabs#object-nav li.current').addClass('selected'); |
| 1079 | | } |
| 1080 | | }); |
| 1081 | | } |
| 1082 | | |
| 1083 | | /* Filter the current content list (groups/members/blogs/topics) */ |
| 1084 | | function bp_filter_request( object, filter, scope, target, search_terms, page, extras ) { |
| 1085 | | if ( 'activity' == object ) |
| 1086 | | return false; |
| 1087 | | |
| 1088 | | if ( jq.query.get('s') && !search_terms ) |
| 1089 | | search_terms = jq.query.get('s'); |
| 1090 | | |
| 1091 | | if ( null == scope ) |
| 1092 | | scope = 'all'; |
| 1093 | | |
| 1094 | | /* Save the settings we want to remain persistent to a cookie */ |
| 1095 | | jq.cookie( 'bp-' + object + '-scope', scope, {path: '/'} ); |
| 1096 | | jq.cookie( 'bp-' + object + '-filter', filter, {path: '/'} ); |
| 1097 | | jq.cookie( 'bp-' + object + '-extras', extras, {path: '/'} ); |
| 1098 | | |
| 1099 | | /* Set the correct selected nav and filter */ |
| 1100 | | jq('div.item-list-tabs li').each( function() { |
| 1101 | | jq(this).removeClass('selected'); |
| 1102 | | }); |
| 1103 | | jq('div.item-list-tabs li#' + object + '-' + scope + ', div.item-list-tabs#object-nav li.current').addClass('selected'); |
| 1104 | | jq('div.item-list-tabs li.selected').addClass('loading'); |
| 1105 | | jq('div.item-list-tabs select option[value=' + filter + ']').attr( 'selected', 'selected' ); |
| 1106 | | |
| 1107 | | if ( 'friends' == object ) |
| 1108 | | object = 'members'; |
| 1109 | | |
| 1110 | | if ( bp_ajax_request ) |
| 1111 | | bp_ajax_request.abort(); |
| 1112 | | |
| 1113 | | bp_ajax_request = jq.post( ajaxurl, { |
| 1114 | | action: object + '_filter', |
| 1115 | | 'cookie': encodeURIComponent(document.cookie), |
| 1116 | | 'object': object, |
| 1117 | | 'filter': filter, |
| 1118 | | 'search_terms': search_terms, |
| 1119 | | 'scope': scope, |
| 1120 | | 'page': page, |
| 1121 | | 'extras': extras |
| 1122 | | }, |
| 1123 | | function(response) |
| 1124 | | { |
| 1125 | | jq(target).fadeOut( 100, function() { |
| 1126 | | jq(this).html(response); |
| 1127 | | jq(this).fadeIn(100); |
| 1128 | | }); |
| 1129 | | jq('div.item-list-tabs li.selected').removeClass('loading'); |
| 1130 | | }); |
| 1131 | | } |
| 1132 | | |
| 1133 | | /* Activity Loop Requesting */ |
| 1134 | | function bp_activity_request(scope, filter) { |
| 1135 | | /* Save the type and filter to a session cookie */ |
| 1136 | | jq.cookie( 'bp-activity-scope', scope, {path: '/'} ); |
| 1137 | | jq.cookie( 'bp-activity-filter', filter, {path: '/'} ); |
| 1138 | | jq.cookie( 'bp-activity-oldestpage', 1 ); |
| 1139 | | |
| 1140 | | /* Remove selected and loading classes from tabs */ |
| 1141 | | jq('div.item-list-tabs li').each( function() { |
| 1142 | | jq(this).removeClass('selected loading'); |
| 1143 | | }); |
| 1144 | | /* Set the correct selected nav and filter */ |
| 1145 | | jq('li#activity-' + scope + ', div.item-list-tabs li.current').addClass('selected'); |
| 1146 | | jq('div#object-nav.item-list-tabs li.selected, div.activity-type-tabs li.selected').addClass('loading'); |
| 1147 | | jq('#activity-filter-select select option[value=' + filter + ']').attr( 'selected', 'selected' ); |
| 1148 | | |
| 1149 | | /* Reload the activity stream based on the selection */ |
| 1150 | | jq('.widget_bp_activity_widget h2 span.ajax-loader').show(); |
| 1151 | | |
| 1152 | | if ( bp_ajax_request ) |
| 1153 | | bp_ajax_request.abort(); |
| 1154 | | |
| 1155 | | bp_ajax_request = jq.post( ajaxurl, { |
| 1156 | | action: 'activity_widget_filter', |
| 1157 | | 'cookie': encodeURIComponent(document.cookie), |
| 1158 | | '_wpnonce_activity_filter': jq("input#_wpnonce_activity_filter").val(), |
| 1159 | | 'scope': scope, |
| 1160 | | 'filter': filter |
| 1161 | | }, |
| 1162 | | function(response) |
| 1163 | | { |
| 1164 | | jq('.widget_bp_activity_widget h2 span.ajax-loader').hide(); |
| 1165 | | |
| 1166 | | jq('div.activity').fadeOut( 100, function() { |
| 1167 | | jq(this).html(response.contents); |
| 1168 | | jq(this).fadeIn(100); |
| 1169 | | |
| 1170 | | /* Selectively hide comments */ |
| 1171 | | bp_dtheme_hide_comments(); |
| 1172 | | }); |
| 1173 | | |
| 1174 | | /* Update the feed link */ |
| 1175 | | if ( null != response.feed_url ) |
| 1176 | | jq('.directory div#subnav li.feed a, .home-page div#subnav li.feed a').attr('href', response.feed_url); |
| 1177 | | |
| 1178 | | jq('div.item-list-tabs li.selected').removeClass('loading'); |
| 1179 | | |
| 1180 | | }, 'json' ); |
| 1181 | | } |
| 1182 | | |
| 1183 | | /* Hide long lists of activity comments, only show the latest five root comments. */ |
| 1184 | | function bp_dtheme_hide_comments() { |
| 1185 | | var comments_divs = jq('div.activity-comments'); |
| 1186 | | |
| 1187 | | if ( !comments_divs.length ) |
| 1188 | | return false; |
| 1189 | | |
| 1190 | | comments_divs.each( function() { |
| 1191 | | if ( jq(this).children('ul').children('li').length < 5 ) return; |
| 1192 | | |
| 1193 | | var comments_div = jq(this); |
| 1194 | | var parent_li = comments_div.parents('ul#activity-stream > li'); |
| 1195 | | var comment_lis = jq(this).children('ul').children('li'); |
| 1196 | | var comment_count = ' '; |
| 1197 | | |
| 1198 | | if ( jq('li#' + parent_li.attr('id') + ' a.acomment-reply span').length ) |
| 1199 | | var comment_count = jq('li#' + parent_li.attr('id') + ' a.acomment-reply span').html(); |
| 1200 | | |
| 1201 | | comment_lis.each( function(i) { |
| 1202 | | /* Show the latest 5 root comments */ |
| 1203 | | if ( i < comment_lis.length - 5 ) { |
| 1204 | | jq(this).addClass('hidden'); |
| 1205 | | jq(this).toggle(); |
| 1206 | | |
| 1207 | | if ( !i ) |
| 1208 | | jq(this).before( '<li class="show-all"><a href="#' + parent_li.attr('id') + '/show-all/" title="' + BP_DTheme.show_all_comments + '">' + BP_DTheme.show_all + ' ' + comment_count + ' ' + BP_DTheme.comments + '</a></li>' ); |
| 1209 | | } |
| 1210 | | }); |
| 1211 | | |
| 1212 | | }); |
| 1213 | | } |
| 1214 | | |
| 1215 | | /* Helper Functions */ |
| 1216 | | |
| 1217 | | function checkAll() { |
| 1218 | | var checkboxes = document.getElementsByTagName("input"); |
| 1219 | | for(var i=0; i<checkboxes.length; i++) { |
| 1220 | | if(checkboxes[i].type == "checkbox") { |
| 1221 | | if($("check_all").checked == "") { |
| 1222 | | checkboxes[i].checked = ""; |
| 1223 | | } |
| 1224 | | else { |
| 1225 | | checkboxes[i].checked = "checked"; |
| 1226 | | } |
| 1227 | | } |
| 1228 | | } |
| 1229 | | } |
| 1230 | | |
| 1231 | | function clear(container) { |
| 1232 | | if( !document.getElementById(container) ) return; |
| 1233 | | |
| 1234 | | var container = document.getElementById(container); |
| 1235 | | |
| 1236 | | if ( radioButtons = container.getElementsByTagName('INPUT') ) { |
| 1237 | | for(var i=0; i<radioButtons.length; i++) { |
| 1238 | | radioButtons[i].checked = ''; |
| 1239 | | } |
| 1240 | | } |
| 1241 | | |
| 1242 | | if ( options = container.getElementsByTagName('OPTION') ) { |
| 1243 | | for(var i=0; i<options.length; i++) { |
| 1244 | | options[i].selected = false; |
| 1245 | | } |
| 1246 | | } |
| 1247 | | |
| 1248 | | return; |
| 1249 | | } |
| 1250 | | |
| 1251 | | /* ScrollTo plugin - just inline and minified */ |
| 1252 | | ;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery); |
| 1253 | | jQuery.extend({easing:{easein:function(x,t,b,c,d){return c*(t/=d)*t+b},easeinout:function(x,t,b,c,d){if(t<d/2)return 2*c*t*t/(d*d)+b;var ts=t-d/2;return-2*c*ts*ts/(d*d)+2*c*ts/d+c/2+b},easeout:function(x,t,b,c,d){return-c*t*t/(d*d)+2*c*t/d+b},expoin:function(x,t,b,c,d){var flip=1;if(c<0){flip*=-1;c*=-1}return flip*(Math.exp(Math.log(c)/d*t))+b},expoout:function(x,t,b,c,d){var flip=1;if(c<0){flip*=-1;c*=-1}return flip*(-Math.exp(-Math.log(c)/d*(t-d))+c+1)+b},expoinout:function(x,t,b,c,d){var flip=1;if(c<0){flip*=-1;c*=-1}if(t<d/2)return flip*(Math.exp(Math.log(c/2)/(d/2)*t))+b;return flip*(-Math.exp(-2*Math.log(c/2)/d*(t-d))+c+1)+b},bouncein:function(x,t,b,c,d){return c-jQuery.easing['bounceout'](x,d-t,0,c,d)+b},bounceout:function(x,t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b}},bounceinout:function(x,t,b,c,d){if(t<d/2)return jQuery.easing['bouncein'](x,t*2,0,c,d)*.5+b;return jQuery.easing['bounceout'](x,t*2-d,0,c,d)*.5+c*.5+b},elasin:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b},elasout:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b},elasinout:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d/2)==2)return b+c;if(!p)p=d*(.3*1.5);if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);if(t<1)return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b},backin:function(x,t,b,c,d){var s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b},backout:function(x,t,b,c,d){var s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},backinout:function(x,t,b,c,d){var s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b},linear:function(x,t,b,c,d){return c*t/d+b}}}); |
| 1254 | | |
| 1255 | | /* jQuery Cookie plugin */ |
| 1256 | | jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}expires='; expires='+date.toUTCString();}var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}return cookieValue;}}; |
| 1257 | | |
| 1258 | | /* jQuery querystring plugin */ |
| 1259 | | eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('M 6(A){4 $11=A.11||\'&\';4 $V=A.V===r?r:j;4 $1p=A.1p===r?\'\':\'[]\';4 $13=A.13===r?r:j;4 $D=$13?A.D===j?"#":"?":"";4 $15=A.15===r?r:j;v.1o=M 6(){4 f=6(o,t){8 o!=1v&&o!==x&&(!!t?o.1t==t:j)};4 14=6(1m){4 m,1l=/\\[([^[]*)\\]/g,T=/^([^[]+)(\\[.*\\])?$/.1r(1m),k=T[1],e=[];19(m=1l.1r(T[2]))e.u(m[1]);8[k,e]};4 w=6(3,e,7){4 o,y=e.1b();b(I 3!=\'X\')3=x;b(y===""){b(!3)3=[];b(f(3,L)){3.u(e.h==0?7:w(x,e.z(0),7))}n b(f(3,1a)){4 i=0;19(3[i++]!=x);3[--i]=e.h==0?7:w(3[i],e.z(0),7)}n{3=[];3.u(e.h==0?7:w(x,e.z(0),7))}}n b(y&&y.T(/^\\s*[0-9]+\\s*$/)){4 H=1c(y,10);b(!3)3=[];3[H]=e.h==0?7:w(3[H],e.z(0),7)}n b(y){4 H=y.B(/^\\s*|\\s*$/g,"");b(!3)3={};b(f(3,L)){4 18={};1w(4 i=0;i<3.h;++i){18[i]=3[i]}3=18}3[H]=e.h==0?7:w(3[H],e.z(0),7)}n{8 7}8 3};4 C=6(a){4 p=d;p.l={};b(a.C){v.J(a.Z(),6(5,c){p.O(5,c)})}n{v.J(1u,6(){4 q=""+d;q=q.B(/^[?#]/,\'\');q=q.B(/[;&]$/,\'\');b($V)q=q.B(/[+]/g,\' \');v.J(q.Y(/[&;]/),6(){4 5=1e(d.Y(\'=\')[0]||"");4 c=1e(d.Y(\'=\')[1]||"");b(!5)8;b($15){b(/^[+-]?[0-9]+\\.[0-9]*$/.1d(c))c=1A(c);n b(/^[+-]?[0-9]+$/.1d(c))c=1c(c,10)}c=(!c&&c!==0)?j:c;b(c!==r&&c!==j&&I c!=\'1g\')c=c;p.O(5,c)})})}8 p};C.1H={C:j,1G:6(5,1f){4 7=d.Z(5);8 f(7,1f)},1h:6(5){b(!f(5))8 d.l;4 K=14(5),k=K[0],e=K[1];4 3=d.l[k];19(3!=x&&e.h!=0){3=3[e.1b()]}8 I 3==\'1g\'?3:3||""},Z:6(5){4 3=d.1h(5);b(f(3,1a))8 v.1E(j,{},3);n b(f(3,L))8 3.z(0);8 3},O:6(5,c){4 7=!f(c)?x:c;4 K=14(5),k=K[0],e=K[1];4 3=d.l[k];d.l[k]=w(3,e.z(0),7);8 d},w:6(5,c){8 d.N().O(5,c)},1s:6(5){8 d.O(5,x).17()},1z:6(5){8 d.N().1s(5)},1j:6(){4 p=d;v.J(p.l,6(5,7){1y p.l[5]});8 p},1F:6(Q){4 D=Q.B(/^.*?[#](.+?)(?:\\?.+)?$/,"$1");4 S=Q.B(/^.*?[?](.+?)(?:#.+)?$/,"$1");8 M C(Q.h==S.h?\'\':S,Q.h==D.h?\'\':D)},1x:6(){8 d.N().1j()},N:6(){8 M C(d)},17:6(){6 F(G){4 R=I G=="X"?f(G,L)?[]:{}:G;b(I G==\'X\'){6 1k(o,5,7){b(f(o,L))o.u(7);n o[5]=7}v.J(G,6(5,7){b(!f(7))8 j;1k(R,5,F(7))})}8 R}d.l=F(d.l);8 d},1B:6(){8 d.N().17()},1D:6(){4 i=0,U=[],W=[],p=d;4 16=6(E){E=E+"";b($V)E=E.B(/ /g,"+");8 1C(E)};4 1n=6(1i,5,7){b(!f(7)||7===r)8;4 o=[16(5)];b(7!==j){o.u("=");o.u(16(7))}1i.u(o.P(""))};4 F=6(R,k){4 12=6(5){8!k||k==""?[5].P(""):[k,"[",5,"]"].P("")};v.J(R,6(5,7){b(I 7==\'X\')F(7,12(5));n 1n(W,12(5),7)})};F(d.l);b(W.h>0)U.u($D);U.u(W.P($11));8 U.P("")}};8 M C(1q.S,1q.D)}}(v.1o||{});',62,106,'|||target|var|key|function|value|return|||if|val|this|tokens|is||length||true|base|keys||else||self||false|||push|jQuery|set|null|token|slice|settings|replace|queryObject|hash|str|build|orig|index|typeof|each|parsed|Array|new|copy|SET|join|url|obj|search|match|queryString|spaces|chunks|object|split|get||separator|newKey|prefix|parse|numbers|encode|COMPACT|temp|while|Object|shift|parseInt|test|decodeURIComponent|type|number|GET|arr|EMPTY|add|rx|path|addFields|query|suffix|location|exec|REMOVE|constructor|arguments|undefined|for|empty|delete|remove|parseFloat|compact|encodeURIComponent|toString|extend|load|has|prototype'.split('|'),0,{})) |
| | 1 | // AJAX Functions |
| | 2 | var jq = jQuery; |
| | 3 | |
| | 4 | // Global variable to prevent multiple AJAX requests |
| | 5 | var bp_ajax_request = null; |
| | 6 | |
| | 7 | jq(document).ready( function() { |
| | 8 | /**** Page Load Actions *******************************************************/ |
| | 9 | |
| | 10 | /* Hide Forums Post Form */ |
| | 11 | if ( jq('div.forums').length ) |
| | 12 | jq('div#new-topic-post').hide(); |
| | 13 | |
| | 14 | /* Activity filter and scope set */ |
| | 15 | bp_init_activity(); |
| | 16 | |
| | 17 | /* Object filter and scope set. */ |
| | 18 | var objects = [ 'members', 'groups', 'blogs', 'forums' ]; |
| | 19 | bp_init_objects( objects ); |
| | 20 | |
| | 21 | /* @mention Compose Scrolling */ |
| | 22 | if ( jq.query.get('r') ) { |
| | 23 | if ( jq('textarea#whats-new').length ) { |
| | 24 | jq.scrollTo( jq('textarea#whats-new'), 500, { offset:-125, easing:'easeout' } ); |
| | 25 | jq('textarea#whats-new').focus(); |
| | 26 | } |
| | 27 | } |
| | 28 | |
| | 29 | /* @mention username help button display */ |
| | 30 | if ( jq( 'span.highlight span' ).length ) |
| | 31 | jq( 'span.highlight span' ).toggle(); |
| | 32 | |
| | 33 | /**** Activity Posting ********************************************************/ |
| | 34 | |
| | 35 | /* New posts */ |
| | 36 | jq("input#aw-whats-new-submit").click( function() { |
| | 37 | var button = jq(this); |
| | 38 | var form = button.parent().parent().parent().parent(); |
| | 39 | |
| | 40 | form.children().each( function() { |
| | 41 | if ( jq.nodeName(this, "textarea") || jq.nodeName(this, "input") ) |
| | 42 | jq(this).attr( 'disabled', 'disabled' ); |
| | 43 | }); |
| | 44 | |
| | 45 | jq( 'form#' + form.attr('id') + ' span.ajax-loader' ).show(); |
| | 46 | |
| | 47 | /* Remove any errors */ |
| | 48 | jq('div.error').remove(); |
| | 49 | button.attr('disabled','disabled'); |
| | 50 | |
| | 51 | /* Default POST values */ |
| | 52 | var object = ''; |
| | 53 | var item_id = jq("#whats-new-post-in").val(); |
| | 54 | var content = jq("textarea#whats-new").val(); |
| | 55 | |
| | 56 | /* Set object for non-profile posts */ |
| | 57 | if ( item_id > 0 ) { |
| | 58 | object = jq("#whats-new-post-object").val(); |
| | 59 | } |
| | 60 | |
| | 61 | jq.post( ajaxurl, { |
| | 62 | action: 'post_update', |
| | 63 | 'cookie': encodeURIComponent(document.cookie), |
| | 64 | '_wpnonce_post_update': jq("input#_wpnonce_post_update").val(), |
| | 65 | 'content': content, |
| | 66 | 'object': object, |
| | 67 | 'item_id': item_id |
| | 68 | }, |
| | 69 | function(response) |
| | 70 | { |
| | 71 | jq( 'form#' + form.attr('id') + ' span.ajax-loader' ).hide(); |
| | 72 | |
| | 73 | form.children().each( function() { |
| | 74 | if ( jq.nodeName(this, "textarea") || jq.nodeName(this, "input") ) |
| | 75 | jq(this).attr( 'disabled', '' ); |
| | 76 | }); |
| | 77 | |
| | 78 | /* Check for errors and append if found. */ |
| | 79 | if ( response[0] + response[1] == '-1' ) { |
| | 80 | form.prepend( response.substr( 2, response.length ) ); |
| | 81 | jq( 'form#' + form.attr('id') + ' div.error').hide().fadeIn( 200 ); |
| | 82 | button.attr("disabled", ''); |
| | 83 | } else { |
| | 84 | if ( 0 == jq("ul.activity-list").length ) { |
| | 85 | jq("div.error").slideUp(100).remove(); |
| | 86 | jq("div#message").slideUp(100).remove(); |
| | 87 | jq("div.activity").append( '<ul id="activity-stream" class="activity-list item-list">' ); |
| | 88 | } |
| | 89 | |
| | 90 | jq("ul.activity-list").prepend(response); |
| | 91 | jq("ul.activity-list li:first").addClass('new-update'); |
| | 92 | jq("li.new-update").hide().slideDown( 300 ); |
| | 93 | jq("li.new-update").removeClass( 'new-update' ); |
| | 94 | jq("textarea#whats-new").val(''); |
| | 95 | |
| | 96 | /* Re-enable the submit button after 8 seconds. */ |
| | 97 | setTimeout( function() { button.attr("disabled", ''); }, 8000 ); |
| | 98 | } |
| | 99 | }); |
| | 100 | |
| | 101 | return false; |
| | 102 | }); |
| | 103 | |
| | 104 | /* List tabs event delegation */ |
| | 105 | jq('div.activity-type-tabs').click( function(event) { |
| | 106 | var target = jq(event.target).parent(); |
| | 107 | |
| | 108 | if ( event.target.nodeName == 'STRONG' || event.target.nodeName == 'SPAN' ) |
| | 109 | target = target.parent(); |
| | 110 | else if ( event.target.nodeName != 'A' ) |
| | 111 | return false; |
| | 112 | |
| | 113 | /* Reset the page */ |
| | 114 | jq.cookie( 'bp-activity-oldestpage', 1, {path: '/'} ); |
| | 115 | |
| | 116 | /* Activity Stream Tabs */ |
| | 117 | var scope = target.attr('id').substr( 9, target.attr('id').length ); |
| | 118 | var filter = jq("#activity-filter-select select").val(); |
| | 119 | |
| | 120 | if ( scope == 'mentions' ) |
| | 121 | jq( 'li#' + target.attr('id') + ' a strong' ).remove(); |
| | 122 | |
| | 123 | bp_activity_request(scope, filter, target); |
| | 124 | |
| | 125 | return false; |
| | 126 | }); |
| | 127 | |
| | 128 | /* Activity filter select */ |
| | 129 | jq('#activity-filter-select select').change( function() { |
| | 130 | var selected_tab = jq( 'div.activity-type-tabs li.selected' ); |
| | 131 | |
| | 132 | if ( !selected_tab.length ) |
| | 133 | var scope = null; |
| | 134 | else |
| | 135 | var scope = selected_tab.attr('id').substr( 9, selected_tab.attr('id').length ); |
| | 136 | |
| | 137 | var filter = jq(this).val(); |
| | 138 | |
| | 139 | bp_activity_request(scope, filter); |
| | 140 | |
| | 141 | return false; |
| | 142 | }); |
| | 143 | |
| | 144 | /* Stream event delegation */ |
| | 145 | jq('div.activity').click( function(event) { |
| | 146 | var target = jq(event.target); |
| | 147 | |
| | 148 | /* Favoriting activity stream items */ |
| | 149 | if ( target.attr('class') == 'fav' || target.attr('class') == 'unfav' ) { |
| | 150 | var type = target.attr('class') |
| | 151 | var parent = target.parent().parent().parent(); |
| | 152 | var parent_id = parent.attr('id').substr( 9, parent.attr('id').length ); |
| | 153 | |
| | 154 | target.addClass('loading'); |
| | 155 | |
| | 156 | jq.post( ajaxurl, { |
| | 157 | action: 'activity_mark_' + type, |
| | 158 | 'cookie': encodeURIComponent(document.cookie), |
| | 159 | 'id': parent_id |
| | 160 | }, |
| | 161 | function(response) { |
| | 162 | target.removeClass('loading'); |
| | 163 | |
| | 164 | target.fadeOut( 100, function() { |
| | 165 | jq(this).html(response); |
| | 166 | jq(this).fadeIn(100); |
| | 167 | }); |
| | 168 | |
| | 169 | if ( 'fav' == type ) { |
| | 170 | if ( !jq('div.item-list-tabs li#activity-favorites').length ) |
| | 171 | jq('div.item-list-tabs ul li#activity-mentions').before( '<li id="activity-favorites"><a href="#">' + BP_DTheme.my_favs + ' (<span>0</span>)</a></li>'); |
| | 172 | |
| | 173 | target.removeClass('fav'); |
| | 174 | target.addClass('unfav'); |
| | 175 | |
| | 176 | jq('div.item-list-tabs ul li#activity-favorites span').html( Number( jq('div.item-list-tabs ul li#activity-favorites span').html() ) + 1 ); |
| | 177 | } else { |
| | 178 | target.removeClass('unfav'); |
| | 179 | target.addClass('fav'); |
| | 180 | |
| | 181 | jq('div.item-list-tabs ul li#activity-favorites span').html( Number( jq('div.item-list-tabs ul li#activity-favorites span').html() ) - 1 ); |
| | 182 | |
| | 183 | if ( !Number( jq('div.item-list-tabs ul li#activity-favorites span').html() ) ) { |
| | 184 | if ( jq('div.item-list-tabs ul li#activity-favorites').hasClass('selected') ) |
| | 185 | bp_activity_request( null, null ); |
| | 186 | |
| | 187 | jq('div.item-list-tabs ul li#activity-favorites').remove(); |
| | 188 | } |
| | 189 | } |
| | 190 | |
| | 191 | if ( 'activity-favorites' == jq( 'div.item-list-tabs li.selected').attr('id') ) |
| | 192 | target.parent().parent().parent().slideUp(100); |
| | 193 | }); |
| | 194 | |
| | 195 | return false; |
| | 196 | } |
| | 197 | |
| | 198 | /* Delete activity stream items */ |
| | 199 | if ( target.hasClass('delete-activity') ) { |
| | 200 | var li = target.parents('div.activity ul li'); |
| | 201 | var id = li.attr('id').substr( 9, li.attr('id').length ); |
| | 202 | var link_href = target.attr('href'); |
| | 203 | |
| | 204 | var nonce = link_href.split('_wpnonce='); |
| | 205 | nonce = nonce[1]; |
| | 206 | |
| | 207 | target.addClass('loading'); |
| | 208 | |
| | 209 | jq.post( ajaxurl, { |
| | 210 | action: 'delete_activity', |
| | 211 | 'cookie': encodeURIComponent(document.cookie), |
| | 212 | 'id': id, |
| | 213 | '_wpnonce': nonce |
| | 214 | }, |
| | 215 | function(response) { |
| | 216 | target.removeClass('loading'); |
| | 217 | |
| | 218 | if ( response[0] + response[1] == '-1' ) { |
| | 219 | li.prepend( response.substr( 2, response.length ) ); |
| | 220 | li.children('div#message').hide().fadeIn(200); |
| | 221 | } else { |
| | 222 | li.slideUp(200); |
| | 223 | } |
| | 224 | }); |
| | 225 | |
| | 226 | return false; |
| | 227 | } |
| | 228 | |
| | 229 | /* Load more updates at the end of the page */ |
| | 230 | if ( target.parent().attr('class') == 'load-more' ) { |
| | 231 | jq("#content li.load-more").addClass('loading'); |
| | 232 | |
| | 233 | if ( null == jq.cookie('bp-activity-oldestpage') ) |
| | 234 | jq.cookie('bp-activity-oldestpage', 1, {path: '/'} ); |
| | 235 | |
| | 236 | var oldest_page = ( jq.cookie('bp-activity-oldestpage') * 1 ) + 1; |
| | 237 | |
| | 238 | jq.post( ajaxurl, { |
| | 239 | action: 'activity_get_older_updates', |
| | 240 | 'cookie': encodeURIComponent(document.cookie), |
| | 241 | 'page': oldest_page |
| | 242 | }, |
| | 243 | function(response) |
| | 244 | { |
| | 245 | jq("#content li.load-more").removeClass('loading'); |
| | 246 | jq.cookie( 'bp-activity-oldestpage', oldest_page, {path: '/'} ); |
| | 247 | jq("#content ul.activity-list").append(response.contents); |
| | 248 | |
| | 249 | target.parent().hide(); |
| | 250 | }, 'json' ); |
| | 251 | |
| | 252 | return false; |
| | 253 | } |
| | 254 | }); |
| | 255 | |
| | 256 | /**** Activity Comments *******************************************************/ |
| | 257 | |
| | 258 | /* Hide all activity comment forms */ |
| | 259 | jq('form.ac-form').hide(); |
| | 260 | |
| | 261 | /* Hide excess comments */ |
| | 262 | if ( jq('div.activity-comments').length ) |
| | 263 | bp_dtheme_hide_comments(); |
| | 264 | |
| | 265 | /* Activity list event delegation */ |
| | 266 | jq('div.activity').click( function(event) { |
| | 267 | var target = jq(event.target); |
| | 268 | |
| | 269 | /* Comment / comment reply links */ |
| | 270 | if ( target.attr('class') == 'acomment-reply' || target.parent().attr('class') == 'acomment-reply' ) { |
| | 271 | if ( target.parent().attr('class') == 'acomment-reply' ) |
| | 272 | target = target.parent(); |
| | 273 | |
| | 274 | var id = target.attr('id'); |
| | 275 | ids = id.split('-'); |
| | 276 | |
| | 277 | var a_id = ids[2] |
| | 278 | var c_id = target.attr('href').substr( 10, target.attr('href').length ); |
| | 279 | var form = jq( '#ac-form-' + a_id ); |
| | 280 | |
| | 281 | var form = jq( '#ac-form-' + ids[2] ); |
| | 282 | |
| | 283 | form.css( 'display', 'none' ); |
| | 284 | form.removeClass('root'); |
| | 285 | jq('.ac-form').hide(); |
| | 286 | |
| | 287 | /* Hide any error messages */ |
| | 288 | form.children('div').each( function() { |
| | 289 | if ( jq(this).hasClass( 'error' ) ) |
| | 290 | jq(this).hide(); |
| | 291 | }); |
| | 292 | |
| | 293 | if ( ids[1] != 'comment' ) { |
| | 294 | jq('div.activity-comments li#acomment-' + c_id).append( form ); |
| | 295 | } else { |
| | 296 | jq('li#activity-' + a_id + ' div.activity-comments').append( form ); |
| | 297 | } |
| | 298 | |
| | 299 | if ( form.parent().attr( 'class' ) == 'activity-comments' ) |
| | 300 | form.addClass('root'); |
| | 301 | |
| | 302 | form.slideDown( 200 ); |
| | 303 | jq.scrollTo( form, 500, { offset:-100, easing:'easeout' } ); |
| | 304 | jq('#ac-form-' + ids[2] + ' textarea').focus(); |
| | 305 | |
| | 306 | return false; |
| | 307 | } |
| | 308 | |
| | 309 | /* Activity comment posting */ |
| | 310 | if ( target.attr('name') == 'ac_form_submit' ) { |
| | 311 | var form = target.parent().parent(); |
| | 312 | var form_parent = form.parent(); |
| | 313 | var form_id = form.attr('id').split('-'); |
| | 314 | |
| | 315 | if ( 'activity-comments' !== form_parent.attr('class') ) { |
| | 316 | var tmp_id = form_parent.attr('id').split('-'); |
| | 317 | var comment_id = tmp_id[1]; |
| | 318 | } else { |
| | 319 | var comment_id = form_id[2]; |
| | 320 | } |
| | 321 | |
| | 322 | /* Hide any error messages */ |
| | 323 | jq( 'form#' + form + ' div.error').hide(); |
| | 324 | form.addClass('loading'); |
| | 325 | target.css('disabled', 'disabled'); |
| | 326 | |
| | 327 | jq.post( ajaxurl, { |
| | 328 | action: 'new_activity_comment', |
| | 329 | 'cookie': encodeURIComponent(document.cookie), |
| | 330 | '_wpnonce_new_activity_comment': jq("input#_wpnonce_new_activity_comment").val(), |
| | 331 | 'comment_id': comment_id, |
| | 332 | 'form_id': form_id[2], |
| | 333 | 'content': jq('form#' + form.attr('id') + ' textarea').val() |
| | 334 | }, |
| | 335 | function(response) |
| | 336 | { |
| | 337 | form.removeClass('loading'); |
| | 338 | |
| | 339 | /* Check for errors and append if found. */ |
| | 340 | if ( response[0] + response[1] == '-1' ) { |
| | 341 | form.append( response.substr( 2, response.length ) ).hide().fadeIn( 200 ); |
| | 342 | target.attr("disabled", ''); |
| | 343 | } else { |
| | 344 | form.fadeOut( 200, |
| | 345 | function() { |
| | 346 | if ( 0 == form.parent().children('ul').length ) { |
| | 347 | if ( form.parent().attr('class') == 'activity-comments' ) |
| | 348 | form.parent().prepend('<ul></ul>'); |
| | 349 | else |
| | 350 | form.parent().append('<ul></ul>'); |
| | 351 | } |
| | 352 | |
| | 353 | form.parent().children('ul').append(response).hide().fadeIn( 200 ); |
| | 354 | form.children('textarea').val(''); |
| | 355 | form.parent().parent().addClass('has-comments'); |
| | 356 | } |
| | 357 | ); |
| | 358 | jq( 'form#' + form + ' textarea').val(''); |
| | 359 | |
| | 360 | /* Increase the "Reply (X)" button count */ |
| | 361 | jq('li#activity-' + form_id[2] + ' a.acomment-reply span').html( Number( jq('li#activity-' + form_id[2] + ' a.acomment-reply span').html() ) + 1 ); |
| | 362 | |
| | 363 | /* Re-enable the submit button after 5 seconds. */ |
| | 364 | setTimeout( function() { target.attr("disabled", ''); }, 5000 ); |
| | 365 | } |
| | 366 | }); |
| | 367 | |
| | 368 | return false; |
| | 369 | } |
| | 370 | |
| | 371 | /* Deleting an activity comment */ |
| | 372 | if ( target.hasClass('acomment-delete') ) { |
| | 373 | var link_href = target.attr('href'); |
| | 374 | var comment_li = target.parent().parent(); |
| | 375 | var form = comment_li.parents('div.activity-comments').children('form'); |
| | 376 | |
| | 377 | var nonce = link_href.split('_wpnonce='); |
| | 378 | nonce = nonce[1]; |
| | 379 | |
| | 380 | var comment_id = link_href.split('cid='); |
| | 381 | comment_id = comment_id[1].split('&'); |
| | 382 | comment_id = comment_id[0]; |
| | 383 | |
| | 384 | target.addClass('loading'); |
| | 385 | |
| | 386 | /* Remove any error messages */ |
| | 387 | jq('div.activity-comments ul div.error').remove(); |
| | 388 | |
| | 389 | /* Reset the form position */ |
| | 390 | comment_li.parents('div.activity-comments').append(form); |
| | 391 | |
| | 392 | jq.post( ajaxurl, { |
| | 393 | action: 'delete_activity_comment', |
| | 394 | 'cookie': encodeURIComponent(document.cookie), |
| | 395 | '_wpnonce': nonce, |
| | 396 | 'id': comment_id |
| | 397 | }, |
| | 398 | function(response) |
| | 399 | { |
| | 400 | /* Check for errors and append if found. */ |
| | 401 | if ( response[0] + response[1] == '-1' ) { |
| | 402 | comment_li.prepend( response.substr( 2, response.length ) ).hide().fadeIn( 200 ); |
| | 403 | } else { |
| | 404 | var children = jq( 'li#' + comment_li.attr('id') + ' ul' ).children('li'); |
| | 405 | var child_count = 0; |
| | 406 | jq(children).each( function() { |
| | 407 | if ( !jq(this).is(':hidden') ) |
| | 408 | child_count++; |
| | 409 | }); |
| | 410 | comment_li.fadeOut(200); |
| | 411 | |
| | 412 | /* Decrease the "Reply (X)" button count */ |
| | 413 | var parent_li = comment_li.parents('ul#activity-stream > li'); |
| | 414 | jq('li#' + parent_li.attr('id') + ' a.acomment-reply span').html( jq('li#' + parent_li.attr('id') + ' a.acomment-reply span').html() - ( 1 + child_count ) ); |
| | 415 | } |
| | 416 | }); |
| | 417 | |
| | 418 | return false; |
| | 419 | } |
| | 420 | |
| | 421 | /* Showing hidden comments - pause for half a second */ |
| | 422 | if ( target.parent().hasClass('show-all') ) { |
| | 423 | target.parent().addClass('loading'); |
| | 424 | |
| | 425 | setTimeout( function() { |
| | 426 | target.parent().parent().children('li').fadeIn(200, function() { |
| | 427 | target.parent().remove(); |
| | 428 | }); |
| | 429 | }, 600 ); |
| | 430 | |
| | 431 | return false; |
| | 432 | } |
| | 433 | }); |
| | 434 | |
| | 435 | /* Escape Key Press for cancelling comment forms */ |
| | 436 | jq(document).keydown( function(e) { |
| | 437 | e = e || window.event; |
| | 438 | if (e.target) |
| | 439 | element = e.target; |
| | 440 | else if (e.srcElement) |
| | 441 | element = e.srcElement; |
| | 442 | |
| | 443 | if( element.nodeType == 3) |
| | 444 | element = element.parentNode; |
| | 445 | |
| | 446 | if( e.ctrlKey == true || e.altKey == true || e.metaKey == true ) |
| | 447 | return; |
| | 448 | |
| | 449 | var keyCode = (e.keyCode) ? e.keyCode : e.which; |
| | 450 | |
| | 451 | if ( keyCode == 27 ) { |
| | 452 | if (element.tagName == 'TEXTAREA') { |
| | 453 | if ( jq(element).attr('class') == 'ac-input' ) |
| | 454 | jq(element).parent().parent().parent().slideUp( 200 ); |
| | 455 | } |
| | 456 | } |
| | 457 | }); |
| | 458 | |
| | 459 | /**** @mention username help tooltip **************************************/ |
| | 460 | |
| | 461 | jq('span.highlight span').click( function() { |
| | 462 | if ( !jq('div.help').length ) { |
| | 463 | jq(this).parent().after( '<div id="message" class="info help"><p>' + BP_DTheme.mention_explain + '</p></div>' ); |
| | 464 | jq('div.help').hide().slideDown(200); |
| | 465 | } else { |
| | 466 | jq('div.help').hide().remove(); |
| | 467 | } |
| | 468 | }) |
| | 469 | |
| | 470 | /**** Directory Search ****************************************************/ |
| | 471 | |
| | 472 | /* The search form on all directory pages */ |
| | 473 | jq('div.dir-search').click( function(event) { |
| | 474 | if ( jq(this).hasClass('no-ajax') ) |
| | 475 | return; |
| | 476 | |
| | 477 | var target = jq(event.target); |
| | 478 | |
| | 479 | if ( target.attr('type') == 'submit' ) { |
| | 480 | var css_id = jq('div.item-list-tabs li.selected').attr('id').split( '-' ); |
| | 481 | var object = css_id[0]; |
| | 482 | |
| | 483 | 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') ); |
| | 484 | |
| | 485 | return false; |
| | 486 | } |
| | 487 | }); |
| | 488 | |
| | 489 | /**** Tabs and Filters ****************************************************/ |
| | 490 | |
| | 491 | /* When a navigation tab is clicked - e.g. | All Groups | My Groups | */ |
| | 492 | jq('div.item-list-tabs').click( function(event) { |
| | 493 | if ( jq(this).hasClass('no-ajax') ) |
| | 494 | return; |
| | 495 | |
| | 496 | var target = jq(event.target).parent(); |
| | 497 | |
| | 498 | if ( 'LI' == event.target.parentNode.nodeName && !target.hasClass('last') ) { |
| | 499 | var css_id = target.attr('id').split( '-' ); |
| | 500 | var object = css_id[0]; |
| | 501 | |
| | 502 | if ( 'activity' == object ) |
| | 503 | return false; |
| | 504 | |
| | 505 | var scope = css_id[1]; |
| | 506 | var filter = jq("#" + object + "-order-select select").val(); |
| | 507 | var search_terms = jq("#" + object + "_search").val(); |
| | 508 | |
| | 509 | bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras') ); |
| | 510 | |
| | 511 | return false; |
| | 512 | } |
| | 513 | }); |
| | 514 | |
| | 515 | /* When the filter select box is changed re-query */ |
| | 516 | jq('li.filter select').change( function() { |
| | 517 | if ( jq('div.item-list-tabs li.selected').length ) |
| | 518 | var el = jq('div.item-list-tabs li.selected'); |
| | 519 | else |
| | 520 | var el = jq(this); |
| | 521 | |
| | 522 | var css_id = el.attr('id').split('-'); |
| | 523 | var object = css_id[0]; |
| | 524 | var scope = css_id[1]; |
| | 525 | var filter = jq(this).val(); |
| | 526 | var search_terms = false; |
| | 527 | |
| | 528 | if ( jq('div.dir-search input').length ) |
| | 529 | search_terms = jq('div.dir-search input').val(); |
| | 530 | |
| | 531 | if ( 'friends' == object ) |
| | 532 | object = 'members'; |
| | 533 | |
| | 534 | bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras') ); |
| | 535 | |
| | 536 | return false; |
| | 537 | }); |
| | 538 | |
| | 539 | /* All pagination links run through this function */ |
| | 540 | jq('div#content').click( function(event) { |
| | 541 | var target = jq(event.target); |
| | 542 | |
| | 543 | if ( target.hasClass('button') ) |
| | 544 | return true; |
| | 545 | |
| | 546 | if ( target.parent().parent().hasClass('pagination') && !target.parent().parent().hasClass('no-ajax') ) { |
| | 547 | if ( target.hasClass('dots') || target.hasClass('current') ) |
| | 548 | return false; |
| | 549 | |
| | 550 | if ( jq('div.item-list-tabs li.selected').length ) |
| | 551 | var el = jq('div.item-list-tabs li.selected'); |
| | 552 | else |
| | 553 | var el = jq('li.filter select'); |
| | 554 | |
| | 555 | var page_number = 1; |
| | 556 | var css_id = el.attr('id').split( '-' ); |
| | 557 | var object = css_id[0]; |
| | 558 | var search_terms = false; |
| | 559 | |
| | 560 | if ( jq('div.dir-search input').length ) |
| | 561 | search_terms = jq('div.dir-search input').val(); |
| | 562 | |
| | 563 | if ( jq(target).hasClass('next') ) |
| | 564 | var page_number = Number( jq('div.pagination span.current').html() ) + 1; |
| | 565 | else if ( jq(target).hasClass('prev') ) |
| | 566 | var page_number = Number( jq('div.pagination span.current').html() ) - 1; |
| | 567 | else |
| | 568 | var page_number = Number( jq(target).html() ); |
| | 569 | |
| | 570 | bp_filter_request( object, jq.cookie('bp-' + object + '-filter'), jq.cookie('bp-' + object + '-scope'), 'div.' + object, search_terms, page_number, jq.cookie('bp-' + object + '-extras') ); |
| | 571 | |
| | 572 | return false; |
| | 573 | } |
| | 574 | |
| | 575 | }); |
| | 576 | |
| | 577 | /**** New Forum Directory Post **************************************/ |
| | 578 | |
| | 579 | /* Hit the "New Topic" button on the forums directory page */ |
| | 580 | jq('a#new-topic-button').click( function() { |
| | 581 | if ( !jq('div#new-topic-post').length ) |
| | 582 | return false; |
| | 583 | |
| | 584 | if ( jq('div#new-topic-post').is(":visible") ) |
| | 585 | jq('div#new-topic-post').slideUp(200); |
| | 586 | else |
| | 587 | jq('div#new-topic-post').slideDown(200); |
| | 588 | |
| | 589 | return false; |
| | 590 | }); |
| | 591 | |
| | 592 | /* Cancel the posting of a new forum topic */ |
| | 593 | jq('input#submit_topic_cancel').click( function() { |
| | 594 | if ( !jq('div#new-topic-post').length ) |
| | 595 | return false; |
| | 596 | |
| | 597 | jq('div#new-topic-post').slideUp(200); |
| | 598 | return false; |
| | 599 | }); |
| | 600 | |
| | 601 | /* Clicking a forum tag */ |
| | 602 | jq('div#forum-directory-tags a').click( function() { |
| | 603 | bp_filter_request( 'forums', 'tags', jq.cookie('bp-forums-scope'), 'div.forums', jq(this).html().replace( / /g, '-' ), 1, jq.cookie('bp-forums-extras') ); |
| | 604 | return false; |
| | 605 | }); |
| | 606 | |
| | 607 | /** Invite Friends Interface ****************************************/ |
| | 608 | |
| | 609 | /* Select a user from the list of friends and add them to the invite list */ |
| | 610 | jq("div#invite-list input").click( function() { |
| | 611 | jq('.ajax-loader').toggle(); |
| | 612 | |
| | 613 | var friend_id = jq(this).val(); |
| | 614 | |
| | 615 | if ( jq(this).attr('checked') == true ) |
| | 616 | var friend_action = 'invite'; |
| | 617 | else |
| | 618 | var friend_action = 'uninvite'; |
| | 619 | |
| | 620 | jq('div.item-list-tabs li.selected').addClass('loading'); |
| | 621 | |
| | 622 | jq.post( ajaxurl, { |
| | 623 | action: 'groups_invite_user', |
| | 624 | 'friend_action': friend_action, |
| | 625 | 'cookie': encodeURIComponent(document.cookie), |
| | 626 | '_wpnonce': jq("input#_wpnonce_invite_uninvite_user").val(), |
| | 627 | 'friend_id': friend_id, |
| | 628 | 'group_id': jq("input#group_id").val() |
| | 629 | }, |
| | 630 | function(response) |
| | 631 | { |
| | 632 | if ( jq("#message") ) |
| | 633 | jq("#message").hide(); |
| | 634 | |
| | 635 | jq('.ajax-loader').toggle(); |
| | 636 | |
| | 637 | if ( friend_action == 'invite' ) { |
| | 638 | jq('#friend-list').append(response); |
| | 639 | } else if ( friend_action == 'uninvite' ) { |
| | 640 | jq('#friend-list li#uid-' + friend_id).remove(); |
| | 641 | } |
| | 642 | |
| | 643 | jq('div.item-list-tabs li.selected').removeClass('loading'); |
| | 644 | }); |
| | 645 | }); |
| | 646 | |
| | 647 | /* Remove a user from the list of users to invite to a group */ |
| | 648 | jq("#friend-list li a.remove").live('click', function() { |
| | 649 | jq('.ajax-loader').toggle(); |
| | 650 | |
| | 651 | var friend_id = jq(this).attr('id'); |
| | 652 | friend_id = friend_id.split('-'); |
| | 653 | friend_id = friend_id[1]; |
| | 654 | |
| | 655 | jq.post( ajaxurl, { |
| | 656 | action: 'groups_invite_user', |
| | 657 | 'friend_action': 'uninvite', |
| | 658 | 'cookie': encodeURIComponent(document.cookie), |
| | 659 | '_wpnonce': jq("input#_wpnonce_invite_uninvite_user").val(), |
| | 660 | 'friend_id': friend_id, |
| | 661 | 'group_id': jq("input#group_id").val() |
| | 662 | }, |
| | 663 | function(response) |
| | 664 | { |
| | 665 | jq('.ajax-loader').toggle(); |
| | 666 | jq('#friend-list li#uid-' + friend_id).remove(); |
| | 667 | jq('#invite-list input#f-' + friend_id).attr('checked', false); |
| | 668 | }); |
| | 669 | |
| | 670 | return false; |
| | 671 | }); |
| | 672 | |
| | 673 | /** Friendship Requests **************************************/ |
| | 674 | |
| | 675 | /* Accept and Reject friendship request buttons */ |
| | 676 | jq("ul#friend-list a.accept, ul#friend-list a.reject").click( function() { |
| | 677 | var button = jq(this); |
| | 678 | var li = jq(this).parents('ul#friend-list li'); |
| | 679 | var action_div = jq(this).parents('li div.action'); |
| | 680 | |
| | 681 | var id = li.attr('id').substr( 11, li.attr('id').length ); |
| | 682 | var link_href = button.attr('href'); |
| | 683 | |
| | 684 | var nonce = link_href.split('_wpnonce='); |
| | 685 | nonce = nonce[1]; |
| | 686 | |
| | 687 | if ( jq(this).hasClass('accepted') || jq(this).hasClass('rejected') ) |
| | 688 | return false; |
| | 689 | |
| | 690 | if ( jq(this).hasClass('accept') ) { |
| | 691 | var action = 'accept_friendship'; |
| | 692 | action_div.children('a.reject').css( 'visibility', 'hidden' ); |
| | 693 | } else { |
| | 694 | var action = 'reject_friendship'; |
| | 695 | action_div.children('a.accept').css( 'visibility', 'hidden' ); |
| | 696 | } |
| | 697 | |
| | 698 | button.addClass('loading'); |
| | 699 | |
| | 700 | jq.post( ajaxurl, { |
| | 701 | action: action, |
| | 702 | 'cookie': encodeURIComponent(document.cookie), |
| | 703 | 'id': id, |
| | 704 | '_wpnonce': nonce |
| | 705 | }, |
| | 706 | function(response) { |
| | 707 | button.removeClass('loading'); |
| | 708 | |
| | 709 | if ( response[0] + response[1] == '-1' ) { |
| | 710 | li.prepend( response.substr( 2, response.length ) ); |
| | 711 | li.children('div#message').hide().fadeIn(200); |
| | 712 | } else { |
| | 713 | button.fadeOut( 100, function() { |
| | 714 | if ( jq(this).hasClass('accept') ) { |
| | 715 | jq(this).html( BP_DTheme.accepted ).fadeIn(50); |
| | 716 | jq(this).addClass('accepted'); |
| | 717 | } else { |
| | 718 | jq(this).html( BP_DTheme.rejected ).fadeIn(50); |
| | 719 | jq(this).addClass('rejected'); |
| | 720 | } |
| | 721 | }); |
| | 722 | } |
| | 723 | }); |
| | 724 | |
| | 725 | return false; |
| | 726 | }); |
| | 727 | |
| | 728 | /* Add / Remove friendship buttons */ |
| | 729 | jq("div.friendship-button a").live('click', function() { |
| | 730 | jq(this).parent().addClass('loading'); |
| | 731 | var fid = jq(this).attr('id'); |
| | 732 | fid = fid.split('-'); |
| | 733 | fid = fid[1]; |
| | 734 | |
| | 735 | var nonce = jq(this).attr('href'); |
| | 736 | nonce = nonce.split('?_wpnonce='); |
| | 737 | nonce = nonce[1].split('&'); |
| | 738 | nonce = nonce[0]; |
| | 739 | |
| | 740 | var thelink = jq(this); |
| | 741 | |
| | 742 | jq.post( ajaxurl, { |
| | 743 | action: 'addremove_friend', |
| | 744 | 'cookie': encodeURIComponent(document.cookie), |
| | 745 | 'fid': fid, |
| | 746 | '_wpnonce': nonce |
| | 747 | }, |
| | 748 | function(response) |
| | 749 | { |
| | 750 | var action = thelink.attr('rel'); |
| | 751 | var parentdiv = thelink.parent(); |
| | 752 | |
| | 753 | if ( action == 'add' ) { |
| | 754 | jq(parentdiv).fadeOut(200, |
| | 755 | function() { |
| | 756 | parentdiv.removeClass('add_friend'); |
| | 757 | parentdiv.removeClass('loading'); |
| | 758 | parentdiv.addClass('pending'); |
| | 759 | parentdiv.fadeIn(200).html(response); |
| | 760 | } |
| | 761 | ); |
| | 762 | |
| | 763 | } else if ( action == 'remove' ) { |
| | 764 | jq(parentdiv).fadeOut(200, |
| | 765 | function() { |
| | 766 | parentdiv.removeClass('remove_friend'); |
| | 767 | parentdiv.removeClass('loading'); |
| | 768 | parentdiv.addClass('add'); |
| | 769 | parentdiv.fadeIn(200).html(response); |
| | 770 | } |
| | 771 | ); |
| | 772 | } |
| | 773 | }); |
| | 774 | return false; |
| | 775 | } ); |
| | 776 | |
| | 777 | /** Group Join / Leave Buttons **************************************/ |
| | 778 | |
| | 779 | jq("div.group-button a").live('click', function() { |
| | 780 | var gid = jq(this).parent().attr('id'); |
| | 781 | gid = gid.split('-'); |
| | 782 | gid = gid[1]; |
| | 783 | |
| | 784 | var nonce = jq(this).attr('href'); |
| | 785 | nonce = nonce.split('?_wpnonce='); |
| | 786 | nonce = nonce[1].split('&'); |
| | 787 | nonce = nonce[0]; |
| | 788 | |
| | 789 | var thelink = jq(this); |
| | 790 | |
| | 791 | jq.post( ajaxurl, { |
| | 792 | action: 'joinleave_group', |
| | 793 | 'cookie': encodeURIComponent(document.cookie), |
| | 794 | 'gid': gid, |
| | 795 | '_wpnonce': nonce |
| | 796 | }, |
| | 797 | function(response) |
| | 798 | { |
| | 799 | var parentdiv = thelink.parent(); |
| | 800 | |
| | 801 | if ( !jq('body.directory').length ) |
| | 802 | location.href = location.href; |
| | 803 | else { |
| | 804 | jq(parentdiv).fadeOut(200, |
| | 805 | function() { |
| | 806 | parentdiv.fadeIn(200).html(response); |
| | 807 | } |
| | 808 | ); |
| | 809 | } |
| | 810 | }); |
| | 811 | return false; |
| | 812 | } ); |
| | 813 | |
| | 814 | /** Button disabling ************************************************/ |
| | 815 | |
| | 816 | jq('div.pending').click(function() { |
| | 817 | return false; |
| | 818 | }); |
| | 819 | |
| | 820 | /** Alternate Highlighting ******************************************/ |
| | 821 | |
| | 822 | jq('body#bp-default table.zebra tbody tr').mouseover( function() { |
| | 823 | jq(this).addClass('over'); |
| | 824 | }).mouseout( function() { |
| | 825 | jq(this).removeClass('over'); |
| | 826 | }); |
| | 827 | |
| | 828 | jq('body#bp-default table.zebra tbody tr:odd').addClass('alt'); |
| | 829 | |
| | 830 | jq('div.message-box').each( function(i) { |
| | 831 | if ( i % 2 == 1 ) |
| | 832 | jq(this).addClass('alt'); |
| | 833 | }); |
| | 834 | |
| | 835 | /** Private Messaging ******************************************/ |
| | 836 | |
| | 837 | /* AJAX send reply functionality */ |
| | 838 | jq("input#send_reply_button").click( |
| | 839 | function() { |
| | 840 | var order = jq('#messages_order').val() || 'ASC', |
| | 841 | offset = jq('#message-recipients').offset(); |
| | 842 | |
| | 843 | jq('form#send-reply span.ajax-loader').toggle(); |
| | 844 | |
| | 845 | jq.post( ajaxurl, { |
| | 846 | action: 'messages_send_reply', |
| | 847 | 'cookie': encodeURIComponent(document.cookie), |
| | 848 | '_wpnonce': jq("input#send_message_nonce").val(), |
| | 849 | |
| | 850 | 'content': jq("#message_content").val(), |
| | 851 | 'send_to': jq("input#send_to").val(), |
| | 852 | 'subject': jq("input#subject").val(), |
| | 853 | 'thread_id': jq("input#thread_id").val() |
| | 854 | }, |
| | 855 | function(response) |
| | 856 | { |
| | 857 | if ( response[0] + response[1] == "-1" ) { |
| | 858 | jq('form#send-reply').prepend( response.substr( 2, response.length ) ); |
| | 859 | } else { |
| | 860 | jq('form#send-reply div#message').remove(); |
| | 861 | jq("#message_content").val(''); |
| | 862 | |
| | 863 | if ( 'ASC' == order ) { |
| | 864 | jq('form#send-reply').before( response ); |
| | 865 | } else { |
| | 866 | jq('#message-recipients').after( response ); |
| | 867 | jq(window).scrollTop(offset.top); |
| | 868 | } |
| | 869 | |
| | 870 | jq("div.new-message").hide().slideDown( 200, function() { |
| | 871 | jq('div.new-message').removeClass('new-message'); |
| | 872 | }); |
| | 873 | |
| | 874 | jq('div.message-box').each( function(i) { |
| | 875 | jq(this).removeClass('alt'); |
| | 876 | if ( i % 2 != 1 ) |
| | 877 | jq(this).addClass('alt'); |
| | 878 | }); |
| | 879 | } |
| | 880 | jq('form#send-reply span.ajax-loader').toggle(); |
| | 881 | }); |
| | 882 | |
| | 883 | return false; |
| | 884 | } |
| | 885 | ); |
| | 886 | |
| | 887 | /* Marking private messages as read and unread */ |
| | 888 | jq("a#mark_as_read, a#mark_as_unread").click(function() { |
| | 889 | var checkboxes_tosend = ''; |
| | 890 | var checkboxes = jq("#message-threads tr td input[type='checkbox']"); |
| | 891 | |
| | 892 | if ( 'mark_as_unread' == jq(this).attr('id') ) { |
| | 893 | var currentClass = 'read' |
| | 894 | var newClass = 'unread' |
| | 895 | var unreadCount = 1; |
| | 896 | var inboxCount = 0; |
| | 897 | var unreadCountDisplay = 'inline'; |
| | 898 | var action = 'messages_markunread'; |
| | 899 | } else { |
| | 900 | var currentClass = 'unread' |
| | 901 | var newClass = 'read' |
| | 902 | var unreadCount = 0; |
| | 903 | var inboxCount = 1; |
| | 904 | var unreadCountDisplay = 'none'; |
| | 905 | var action = 'messages_markread'; |
| | 906 | } |
| | 907 | |
| | 908 | checkboxes.each( function(i) { |
| | 909 | if(jq(this).is(':checked')) { |
| | 910 | if ( jq('tr#m-' + jq(this).attr('value')).hasClass(currentClass) ) { |
| | 911 | checkboxes_tosend += jq(this).attr('value'); |
| | 912 | jq('tr#m-' + jq(this).attr('value')).removeClass(currentClass); |
| | 913 | jq('tr#m-' + jq(this).attr('value')).addClass(newClass); |
| | 914 | var thread_count = jq('tr#m-' + jq(this).attr('value') + ' td span.unread-count').html(); |
| | 915 | |
| | 916 | jq('tr#m-' + jq(this).attr('value') + ' td span.unread-count').html(unreadCount); |
| | 917 | jq('tr#m-' + jq(this).attr('value') + ' td span.unread-count').css('display', unreadCountDisplay); |
| | 918 | var inboxcount = jq('a#user-messages strong').html().substr( 1, jq('a#user-messages strong').html().length ); |
| | 919 | var inboxcount = inboxcount.substr( 0, inboxcount.length - 1 ); |
| | 920 | |
| | 921 | if ( !inboxcount.length ) |
| | 922 | inboxcount = 0; |
| | 923 | if ( parseInt(inboxcount) == inboxCount ) { |
| | 924 | jq('a#user-messages strong').css('display', unreadCountDisplay); |
| | 925 | jq('a#user-messages strong').html( '(' + unreadCount + ')' ); |
| | 926 | } else { |
| | 927 | if ( 'read' == currentClass ) |
| | 928 | jq('a#user-messages strong').html('(' + ( parseInt(inboxcount) + 1 ) + ')'); |
| | 929 | else |
| | 930 | jq('a#user-messages strong').html('(' + ( parseInt(inboxcount) - thread_count ) + ')'); |
| | 931 | } |
| | 932 | |
| | 933 | if ( i != checkboxes.length - 1 ) { |
| | 934 | checkboxes_tosend += ',' |
| | 935 | } |
| | 936 | } |
| | 937 | } |
| | 938 | }); |
| | 939 | jq.post( ajaxurl, { |
| | 940 | action: action, |
| | 941 | 'thread_ids': checkboxes_tosend |
| | 942 | }); |
| | 943 | return false; |
| | 944 | }); |
| | 945 | |
| | 946 | /* Selecting unread and read messages in inbox */ |
| | 947 | jq("select#message-type-select").change( |
| | 948 | function() { |
| | 949 | var selection = jq("select#message-type-select").val(); |
| | 950 | var checkboxes = jq("td input[type='checkbox']"); |
| | 951 | checkboxes.each( function(i) { |
| | 952 | checkboxes[i].checked = ""; |
| | 953 | }); |
| | 954 | |
| | 955 | switch(selection) { |
| | 956 | case 'unread': |
| | 957 | var checkboxes = jq("tr.unread td input[type='checkbox']"); |
| | 958 | break; |
| | 959 | case 'read': |
| | 960 | var checkboxes = jq("tr.read td input[type='checkbox']"); |
| | 961 | break; |
| | 962 | } |
| | 963 | if ( selection != '' ) { |
| | 964 | checkboxes.each( function(i) { |
| | 965 | checkboxes[i].checked = "checked"; |
| | 966 | }); |
| | 967 | } else { |
| | 968 | checkboxes.each( function(i) { |
| | 969 | checkboxes[i].checked = ""; |
| | 970 | }); |
| | 971 | } |
| | 972 | } |
| | 973 | ); |
| | 974 | |
| | 975 | /* Bulk delete messages */ |
| | 976 | jq("a#delete_inbox_messages, a#delete_sentbox_messages").click( function() { |
| | 977 | checkboxes_tosend = ''; |
| | 978 | checkboxes = jq("#message-threads tr td input[type='checkbox']"); |
| | 979 | |
| | 980 | jq('div#message').remove(); |
| | 981 | jq(this).addClass('loading'); |
| | 982 | |
| | 983 | jq(checkboxes).each( function(i) { |
| | 984 | if( jq(this).is(':checked') ) |
| | 985 | checkboxes_tosend += jq(this).attr('value') + ','; |
| | 986 | }); |
| | 987 | |
| | 988 | if ( '' == checkboxes_tosend ) { |
| | 989 | jq(this).removeClass('loading'); |
| | 990 | return false; |
| | 991 | } |
| | 992 | |
| | 993 | jq.post( ajaxurl, { |
| | 994 | action: 'messages_delete', |
| | 995 | 'thread_ids': checkboxes_tosend |
| | 996 | }, function(response) { |
| | 997 | if ( response[0] + response[1] == "-1" ) { |
| | 998 | jq('#message-threads').prepend( response.substr( 2, response.length ) ); |
| | 999 | } else { |
| | 1000 | jq('#message-threads').before( '<div id="message" class="updated"><p>' + response + '</p></div>' ); |
| | 1001 | |
| | 1002 | jq(checkboxes).each( function(i) { |
| | 1003 | if( jq(this).is(':checked') ) |
| | 1004 | jq(this).parent().parent().fadeOut(150); |
| | 1005 | }); |
| | 1006 | } |
| | 1007 | |
| | 1008 | jq('div#message').hide().slideDown(150); |
| | 1009 | jq("a#delete_inbox_messages, a#delete_sentbox_messages").removeClass('loading'); |
| | 1010 | }); |
| | 1011 | return false; |
| | 1012 | }); |
| | 1013 | |
| | 1014 | /* Close site wide notices in the sidebar */ |
| | 1015 | jq("a#close-notice").click( function() { |
| | 1016 | jq(this).addClass('loading'); |
| | 1017 | jq('div#sidebar div.error').remove(); |
| | 1018 | |
| | 1019 | jq.post( ajaxurl, { |
| | 1020 | action: 'messages_close_notice', |
| | 1021 | 'notice_id': jq('.notice').attr('rel').substr( 2, jq('.notice').attr('rel').length ) |
| | 1022 | }, |
| | 1023 | function(response) { |
| | 1024 | jq("a#close-notice").removeClass('loading'); |
| | 1025 | |
| | 1026 | if ( response[0] + response[1] == '-1' ) { |
| | 1027 | jq('.notice').prepend( response.substr( 2, response.length ) ); |
| | 1028 | jq( 'div#sidebar div.error').hide().fadeIn( 200 ); |
| | 1029 | } else { |
| | 1030 | jq('.notice').slideUp( 100 ); |
| | 1031 | } |
| | 1032 | }); |
| | 1033 | return false; |
| | 1034 | }); |
| | 1035 | |
| | 1036 | /* Admin Bar & wp_list_pages Javascript IE6 hover class */ |
| | 1037 | jq("#wp-admin-bar ul.main-nav li, #nav li.page_item ").mouseover( function() { |
| | 1038 | jq(this).addClass('sfhover'); |
| | 1039 | }); |
| | 1040 | |
| | 1041 | jq("#wp-admin-bar ul.main-nav li, #nav li.page_item ").mouseout( function() { |
| | 1042 | jq(this).removeClass('sfhover'); |
| | 1043 | }); |
| | 1044 | |
| | 1045 | /* Clear BP cookies on logout */ |
| | 1046 | jq('a.logout').click( function() { |
| | 1047 | jq.cookie('bp-activity-scope', null, {path: '/'}); |
| | 1048 | jq.cookie('bp-activity-filter', null, {path: '/'}); |
| | 1049 | jq.cookie('bp-activity-oldestpage', null, {path: '/'}); |
| | 1050 | |
| | 1051 | var objects = [ 'members', 'groups', 'blogs', 'forums' ]; |
| | 1052 | jq(objects).each( function(i) { |
| | 1053 | jq.cookie('bp-' + objects[i] + '-scope', null, {path: '/'} ); |
| | 1054 | jq.cookie('bp-' + objects[i] + '-filter', null, {path: '/'} ); |
| | 1055 | jq.cookie('bp-' + objects[i] + '-extras', null, {path: '/'} ); |
| | 1056 | }); |
| | 1057 | }); |
| | 1058 | }); |
| | 1059 | |
| | 1060 | /* Setup activity scope and filter based on the current cookie settings. */ |
| | 1061 | function bp_init_activity() { |
| | 1062 | /* Reset the page */ |
| | 1063 | jq.cookie( 'bp-activity-oldestpage', 1, {path: '/'} ); |
| | 1064 | |
| | 1065 | if ( null != jq.cookie('bp-activity-filter') && jq('#activity-filter-select').length ) |
| | 1066 | jq('#activity-filter-select select option[value=' + jq.cookie('bp-activity-filter') + ']').attr( 'selected', 'selected' ); |
| | 1067 | |
| | 1068 | /* Activity Tab Set */ |
| | 1069 | if ( null != jq.cookie('bp-activity-scope') && jq('div.activity-type-tabs').length ) { |
| | 1070 | jq('div.activity-type-tabs li').each( function() { |
| | 1071 | jq(this).removeClass('selected'); |
| | 1072 | }); |
| | 1073 | jq('li#activity-' + jq.cookie('bp-activity-scope') + ', div.item-list-tabs li.current').addClass('selected'); |
| | 1074 | } |
| | 1075 | } |
| | 1076 | |
| | 1077 | /* Setup object scope and filter based on the current cookie settings for the object. */ |
| | 1078 | function bp_init_objects(objects) { |
| | 1079 | jq(objects).each( function(i) { |
| | 1080 | if ( null != jq.cookie('bp-' + objects[i] + '-filter') && jq('li#' + objects[i] + '-order-select select').length ) |
| | 1081 | jq('li#' + objects[i] + '-order-select select option[value=' + jq.cookie('bp-' + objects[i] + '-filter') + ']').attr( 'selected', 'selected' ); |
| | 1082 | |
| | 1083 | if ( null != jq.cookie('bp-' + objects[i] + '-scope') && jq('div.' + objects[i]).length ) { |
| | 1084 | jq('div.item-list-tabs li').each( function() { |
| | 1085 | jq(this).removeClass('selected'); |
| | 1086 | }); |
| | 1087 | jq('div.item-list-tabs li#' + objects[i] + '-' + jq.cookie('bp-' + objects[i] + '-scope') + ', div.item-list-tabs#object-nav li.current').addClass('selected'); |
| | 1088 | } |
| | 1089 | }); |
| | 1090 | } |
| | 1091 | |
| | 1092 | /* Filter the current content list (groups/members/blogs/topics) */ |
| | 1093 | function bp_filter_request( object, filter, scope, target, search_terms, page, extras ) { |
| | 1094 | if ( 'activity' == object ) |
| | 1095 | return false; |
| | 1096 | |
| | 1097 | if ( jq.query.get('s') && !search_terms ) |
| | 1098 | search_terms = jq.query.get('s'); |
| | 1099 | |
| | 1100 | if ( null == scope ) |
| | 1101 | scope = 'all'; |
| | 1102 | |
| | 1103 | /* Save the settings we want to remain persistent to a cookie */ |
| | 1104 | jq.cookie( 'bp-' + object + '-scope', scope, {path: '/'} ); |
| | 1105 | jq.cookie( 'bp-' + object + '-filter', filter, {path: '/'} ); |
| | 1106 | jq.cookie( 'bp-' + object + '-extras', extras, {path: '/'} ); |
| | 1107 | |
| | 1108 | /* Set the correct selected nav and filter */ |
| | 1109 | jq('div.item-list-tabs li').each( function() { |
| | 1110 | jq(this).removeClass('selected'); |
| | 1111 | }); |
| | 1112 | jq('div.item-list-tabs li#' + object + '-' + scope + ', div.item-list-tabs#object-nav li.current').addClass('selected'); |
| | 1113 | jq('div.item-list-tabs li.selected').addClass('loading'); |
| | 1114 | jq('div.item-list-tabs select option[value=' + filter + ']').attr( 'selected', 'selected' ); |
| | 1115 | |
| | 1116 | if ( 'friends' == object ) |
| | 1117 | object = 'members'; |
| | 1118 | |
| | 1119 | if ( bp_ajax_request ) |
| | 1120 | bp_ajax_request.abort(); |
| | 1121 | |
| | 1122 | bp_ajax_request = jq.post( ajaxurl, { |
| | 1123 | action: object + '_filter', |
| | 1124 | 'cookie': encodeURIComponent(document.cookie), |
| | 1125 | 'object': object, |
| | 1126 | 'filter': filter, |
| | 1127 | 'search_terms': search_terms, |
| | 1128 | 'scope': scope, |
| | 1129 | 'page': page, |
| | 1130 | 'extras': extras |
| | 1131 | }, |
| | 1132 | function(response) |
| | 1133 | { |
| | 1134 | jq(target).fadeOut( 100, function() { |
| | 1135 | jq(this).html(response); |
| | 1136 | jq(this).fadeIn(100); |
| | 1137 | }); |
| | 1138 | jq('div.item-list-tabs li.selected').removeClass('loading'); |
| | 1139 | }); |
| | 1140 | } |
| | 1141 | |
| | 1142 | /* Activity Loop Requesting */ |
| | 1143 | function bp_activity_request(scope, filter) { |
| | 1144 | /* Save the type and filter to a session cookie */ |
| | 1145 | jq.cookie( 'bp-activity-scope', scope, {path: '/'} ); |
| | 1146 | jq.cookie( 'bp-activity-filter', filter, {path: '/'} ); |
| | 1147 | jq.cookie( 'bp-activity-oldestpage', 1 ); |
| | 1148 | |
| | 1149 | /* Remove selected and loading classes from tabs */ |
| | 1150 | jq('div.item-list-tabs li').each( function() { |
| | 1151 | jq(this).removeClass('selected loading'); |
| | 1152 | }); |
| | 1153 | /* Set the correct selected nav and filter */ |
| | 1154 | jq('li#activity-' + scope + ', div.item-list-tabs li.current').addClass('selected'); |
| | 1155 | jq('div#object-nav.item-list-tabs li.selected, div.activity-type-tabs li.selected').addClass('loading'); |
| | 1156 | jq('#activity-filter-select select option[value=' + filter + ']').attr( 'selected', 'selected' ); |
| | 1157 | |
| | 1158 | /* Reload the activity stream based on the selection */ |
| | 1159 | jq('.widget_bp_activity_widget h2 span.ajax-loader').show(); |
| | 1160 | |
| | 1161 | if ( bp_ajax_request ) |
| | 1162 | bp_ajax_request.abort(); |
| | 1163 | |
| | 1164 | bp_ajax_request = jq.post( ajaxurl, { |
| | 1165 | action: 'activity_widget_filter', |
| | 1166 | 'cookie': encodeURIComponent(document.cookie), |
| | 1167 | '_wpnonce_activity_filter': jq("input#_wpnonce_activity_filter").val(), |
| | 1168 | 'scope': scope, |
| | 1169 | 'filter': filter |
| | 1170 | }, |
| | 1171 | function(response) |
| | 1172 | { |
| | 1173 | jq('.widget_bp_activity_widget h2 span.ajax-loader').hide(); |
| | 1174 | |
| | 1175 | jq('div.activity').fadeOut( 100, function() { |
| | 1176 | jq(this).html(response.contents); |
| | 1177 | jq(this).fadeIn(100); |
| | 1178 | |
| | 1179 | /* Selectively hide comments */ |
| | 1180 | bp_dtheme_hide_comments(); |
| | 1181 | }); |
| | 1182 | |
| | 1183 | /* Update the feed link */ |
| | 1184 | if ( null != response.feed_url ) |
| | 1185 | jq('.directory div#subnav li.feed a, .home-page div#subnav li.feed a').attr('href', response.feed_url); |
| | 1186 | |
| | 1187 | jq('div.item-list-tabs li.selected').removeClass('loading'); |
| | 1188 | |
| | 1189 | }, 'json' ); |
| | 1190 | } |
| | 1191 | |
| | 1192 | /* Hide long lists of activity comments, only show the latest five root comments. */ |
| | 1193 | function bp_dtheme_hide_comments() { |
| | 1194 | var comments_divs = jq('div.activity-comments'); |
| | 1195 | |
| | 1196 | if ( !comments_divs.length ) |
| | 1197 | return false; |
| | 1198 | |
| | 1199 | comments_divs.each( function() { |
| | 1200 | if ( jq(this).children('ul').children('li').length < 5 ) return; |
| | 1201 | |
| | 1202 | var comments_div = jq(this); |
| | 1203 | var parent_li = comments_div.parents('ul#activity-stream > li'); |
| | 1204 | var comment_lis = jq(this).children('ul').children('li'); |
| | 1205 | var comment_count = ' '; |
| | 1206 | |
| | 1207 | if ( jq('li#' + parent_li.attr('id') + ' a.acomment-reply span').length ) |
| | 1208 | var comment_count = jq('li#' + parent_li.attr('id') + ' a.acomment-reply span').html(); |
| | 1209 | |
| | 1210 | comment_lis.each( function(i) { |
| | 1211 | /* Show the latest 5 root comments */ |
| | 1212 | if ( i < comment_lis.length - 5 ) { |
| | 1213 | jq(this).addClass('hidden'); |
| | 1214 | jq(this).toggle(); |
| | 1215 | |
| | 1216 | if ( !i ) |
| | 1217 | jq(this).before( '<li class="show-all"><a href="#' + parent_li.attr('id') + '/show-all/" title="' + BP_DTheme.show_all_comments + '">' + BP_DTheme.show_all + ' ' + comment_count + ' ' + BP_DTheme.comments + '</a></li>' ); |
| | 1218 | } |
| | 1219 | }); |
| | 1220 | |
| | 1221 | }); |
| | 1222 | } |
| | 1223 | |
| | 1224 | /* Helper Functions */ |
| | 1225 | |
| | 1226 | function checkAll() { |
| | 1227 | var checkboxes = document.getElementsByTagName("input"); |
| | 1228 | for(var i=0; i<checkboxes.length; i++) { |
| | 1229 | if(checkboxes[i].type == "checkbox") { |
| | 1230 | if($("check_all").checked == "") { |
| | 1231 | checkboxes[i].checked = ""; |
| | 1232 | } |
| | 1233 | else { |
| | 1234 | checkboxes[i].checked = "checked"; |
| | 1235 | } |
| | 1236 | } |
| | 1237 | } |
| | 1238 | } |
| | 1239 | |
| | 1240 | function clear(container) { |
| | 1241 | if( !document.getElementById(container) ) return; |
| | 1242 | |
| | 1243 | var container = document.getElementById(container); |
| | 1244 | |
| | 1245 | if ( radioButtons = container.getElementsByTagName('INPUT') ) { |
| | 1246 | for(var i=0; i<radioButtons.length; i++) { |
| | 1247 | radioButtons[i].checked = ''; |
| | 1248 | } |
| | 1249 | } |
| | 1250 | |
| | 1251 | if ( options = container.getElementsByTagName('OPTION') ) { |
| | 1252 | for(var i=0; i<options.length; i++) { |
| | 1253 | options[i].selected = false; |
| | 1254 | } |
| | 1255 | } |
| | 1256 | |
| | 1257 | return; |
| | 1258 | } |
| | 1259 | |
| | 1260 | /* ScrollTo plugin - just inline and minified */ |
| | 1261 | ;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery); |
| | 1262 | jQuery.extend({easing:{easein:function(x,t,b,c,d){return c*(t/=d)*t+b},easeinout:function(x,t,b,c,d){if(t<d/2)return 2*c*t*t/(d*d)+b;var ts=t-d/2;return-2*c*ts*ts/(d*d)+2*c*ts/d+c/2+b},easeout:function(x,t,b,c,d){return-c*t*t/(d*d)+2*c*t/d+b},expoin:function(x,t,b,c,d){var flip=1;if(c<0){flip*=-1;c*=-1}return flip*(Math.exp(Math.log(c)/d*t))+b},expoout:function(x,t,b,c,d){var flip=1;if(c<0){flip*=-1;c*=-1}return flip*(-Math.exp(-Math.log(c)/d*(t-d))+c+1)+b},expoinout:function(x,t,b,c,d){var flip=1;if(c<0){flip*=-1;c*=-1}if(t<d/2)return flip*(Math.exp(Math.log(c/2)/(d/2)*t))+b;return flip*(-Math.exp(-2*Math.log(c/2)/d*(t-d))+c+1)+b},bouncein:function(x,t,b,c,d){return c-jQuery.easing['bounceout'](x,d-t,0,c,d)+b},bounceout:function(x,t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b}},bounceinout:function(x,t,b,c,d){if(t<d/2)return jQuery.easing['bouncein'](x,t*2,0,c,d)*.5+b;return jQuery.easing['bounceout'](x,t*2-d,0,c,d)*.5+c*.5+b},elasin:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b},elasout:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b},elasinout:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d/2)==2)return b+c;if(!p)p=d*(.3*1.5);if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);if(t<1)return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b},backin:function(x,t,b,c,d){var s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b},backout:function(x,t,b,c,d){var s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},backinout:function(x,t,b,c,d){var s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b},linear:function(x,t,b,c,d){return c*t/d+b}}}); |
| | 1263 | |
| | 1264 | /* jQuery Cookie plugin */ |
| | 1265 | jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;}var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}expires='; expires='+date.toUTCString();}var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}return cookieValue;}}; |
| | 1266 | |
| | 1267 | /* jQuery querystring plugin */ |
| | 1268 | eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('M 6(A){4 $11=A.11||\'&\';4 $V=A.V===r?r:j;4 $1p=A.1p===r?\'\':\'[]\';4 $13=A.13===r?r:j;4 $D=$13?A.D===j?"#":"?":"";4 $15=A.15===r?r:j;v.1o=M 6(){4 f=6(o,t){8 o!=1v&&o!==x&&(!!t?o.1t==t:j)};4 14=6(1m){4 m,1l=/\\[([^[]*)\\]/g,T=/^([^[]+)(\\[.*\\])?$/.1r(1m),k=T[1],e=[];19(m=1l.1r(T[2]))e.u(m[1]);8[k,e]};4 w=6(3,e,7){4 o,y=e.1b();b(I 3!=\'X\')3=x;b(y===""){b(!3)3=[];b(f(3,L)){3.u(e.h==0?7:w(x,e.z(0),7))}n b(f(3,1a)){4 i=0;19(3[i++]!=x);3[--i]=e.h==0?7:w(3[i],e.z(0),7)}n{3=[];3.u(e.h==0?7:w(x,e.z(0),7))}}n b(y&&y.T(/^\\s*[0-9]+\\s*$/)){4 H=1c(y,10);b(!3)3=[];3[H]=e.h==0?7:w(3[H],e.z(0),7)}n b(y){4 H=y.B(/^\\s*|\\s*$/g,"");b(!3)3={};b(f(3,L)){4 18={};1w(4 i=0;i<3.h;++i){18[i]=3[i]}3=18}3[H]=e.h==0?7:w(3[H],e.z(0),7)}n{8 7}8 3};4 C=6(a){4 p=d;p.l={};b(a.C){v.J(a.Z(),6(5,c){p.O(5,c)})}n{v.J(1u,6(){4 q=""+d;q=q.B(/^[?#]/,\'\');q=q.B(/[;&]$/,\'\');b($V)q=q.B(/[+]/g,\' \');v.J(q.Y(/[&;]/),6(){4 5=1e(d.Y(\'=\')[0]||"");4 c=1e(d.Y(\'=\')[1]||"");b(!5)8;b($15){b(/^[+-]?[0-9]+\\.[0-9]*$/.1d(c))c=1A(c);n b(/^[+-]?[0-9]+$/.1d(c))c=1c(c,10)}c=(!c&&c!==0)?j:c;b(c!==r&&c!==j&&I c!=\'1g\')c=c;p.O(5,c)})})}8 p};C.1H={C:j,1G:6(5,1f){4 7=d.Z(5);8 f(7,1f)},1h:6(5){b(!f(5))8 d.l;4 K=14(5),k=K[0],e=K[1];4 3=d.l[k];19(3!=x&&e.h!=0){3=3[e.1b()]}8 I 3==\'1g\'?3:3||""},Z:6(5){4 3=d.1h(5);b(f(3,1a))8 v.1E(j,{},3);n b(f(3,L))8 3.z(0);8 3},O:6(5,c){4 7=!f(c)?x:c;4 K=14(5),k=K[0],e=K[1];4 3=d.l[k];d.l[k]=w(3,e.z(0),7);8 d},w:6(5,c){8 d.N().O(5,c)},1s:6(5){8 d.O(5,x).17()},1z:6(5){8 d.N().1s(5)},1j:6(){4 p=d;v.J(p.l,6(5,7){1y p.l[5]});8 p},1F:6(Q){4 D=Q.B(/^.*?[#](.+?)(?:\\?.+)?$/,"$1");4 S=Q.B(/^.*?[?](.+?)(?:#.+)?$/,"$1");8 M C(Q.h==S.h?\'\':S,Q.h==D.h?\'\':D)},1x:6(){8 d.N().1j()},N:6(){8 M C(d)},17:6(){6 F(G){4 R=I G=="X"?f(G,L)?[]:{}:G;b(I G==\'X\'){6 1k(o,5,7){b(f(o,L))o.u(7);n o[5]=7}v.J(G,6(5,7){b(!f(7))8 j;1k(R,5,F(7))})}8 R}d.l=F(d.l);8 d},1B:6(){8 d.N().17()},1D:6(){4 i=0,U=[],W=[],p=d;4 16=6(E){E=E+"";b($V)E=E.B(/ /g,"+");8 1C(E)};4 1n=6(1i,5,7){b(!f(7)||7===r)8;4 o=[16(5)];b(7!==j){o.u("=");o.u(16(7))}1i.u(o.P(""))};4 F=6(R,k){4 12=6(5){8!k||k==""?[5].P(""):[k,"[",5,"]"].P("")};v.J(R,6(5,7){b(I 7==\'X\')F(7,12(5));n 1n(W,12(5),7)})};F(d.l);b(W.h>0)U.u($D);U.u(W.P($11));8 U.P("")}};8 M C(1q.S,1q.D)}}(v.1o||{});',62,106,'|||target|var|key|function|value|return|||if|val|this|tokens|is||length||true|base|keys||else||self||false|||push|jQuery|set|null|token|slice|settings|replace|queryObject|hash|str|build|orig|index|typeof|each|parsed|Array|new|copy|SET|join|url|obj|search|match|queryString|spaces|chunks|object|split|get||separator|newKey|prefix|parse|numbers|encode|COMPACT|temp|while|Object|shift|parseInt|test|decodeURIComponent|type|number|GET|arr|EMPTY|add|rx|path|addFields|query|suffix|location|exec|REMOVE|constructor|arguments|undefined|for|empty|delete|remove|parseFloat|compact|encodeURIComponent|toString|extend|load|has|prototype'.split('|'),0,{})) |