PageSourceSearch

https://escuelamundopastel.com/wp-content/themes/wplms/assets/js/old_files/buddypress.js?ver=4.930

js escuelamundopastel.com collected 2026-09-26 09:43:04 UTC 65,211 bytes, 1,892 lines download raw bytes

1/* ScrollTo plugin - just inline and minified */
2;(function($){var h=$.scrollTo=function(a,b,c){$(window).scrollTo(a,b,c)};h.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1,limit:true};h.window=function(a){return $(window)._scrollable()};$.fn._scrollable=function(){return this.map(function(){var a=this,isWin=!a.nodeName||$.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)return a;var b=(a.contentWindow||a).document||a.ownerDocument||a;return/webkit/i.test(navigator.userAgent)||b.compatMode=='BackCompat'?b.body:b.documentElement})};$.fn.scrollTo=function(e,f,g){if(typeof f=='object'){g=f;f=0}if(typeof g=='function')g={onAfter:g};if(e=='max')e=9e9;g=$.extend({},h.defaults,g);f=f||g.duration;g.queue=g.queue&&g.axis.length>1;if(g.queue)f/=2;g.offset=both(g.offset);g.over=both(g.over);return this._scrollable().each(function(){if(e==null)return;var d=this,$elem=$(d),targ=e,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break}targ=$(targ,this);if(!targ.length)return;case'object':if(targ.is||targ.style)toff=(targ=$(targ)).offset()}$.each(g.axis.split(''),function(i,a){var b=a=='x'?'Left':'Top',pos=b.toLowerCase(),key='scroll'+b,old=d[key],max=h.max(d,a);if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(g.margin){attr[key]-=parseInt(targ.css('margin'+b))||0;attr[key]-=parseInt(targ.css('border'+b+'Width'))||0}attr[key]+=g.offset[pos]||0;if(g.over[pos])attr[key]+=targ[a=='x'?'width':'height']()*g.over[pos]}else{var c=targ[pos];attr[key]=c.slice&&c.slice(-1)=='%'?parseFloat(c)/100*max:c}if(g.limit&&/^\d+$/.test(attr[key]))attr[key]=attr[key]<=0?0:Math.min(attr[key],max);if(!i&&g.queue){if(old!=attr[key])animate(g.onAfterFirst);delete attr[key]}});animate(g.onAfter);function animate(a){$elem.animate(attr,f,g.easing,a&&function(){a.call(this,e,g)})}}).end()};h.max=function(a,b){var c=b=='x'?'Width':'Height',scroll='scroll'+c;if(!$(a).is('html,body'))return a[scroll]-$(a)[c.toLowerCase()]();var d='client'+c,html=a.ownerDocument.documentElement,body=a.ownerDocument.body;return Math.max(html[scroll],body[scroll])-Math.min(html[d],body[d])};function both(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
3
4/* jQuery Easing Plugin, v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ */
5jQuery.easing.jswing=jQuery.easing.swing;jQuery.extend(jQuery.easing,{def:"easeOutQuad",swing:function(e,f,a,h,g){return jQuery.easing[jQuery.easing.def](e,f,a,h,g)},easeInQuad:function(e,f,a,h,g){return h*(f/=g)*f+a},easeOutQuad:function(e,f,a,h,g){return -h*(f/=g)*(f-2)+a},easeInOutQuad:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f+a}return -h/2*((--f)*(f-2)-1)+a},easeInCubic:function(e,f,a,h,g){return h*(f/=g)*f*f+a},easeOutCubic:function(e,f,a,h,g){return h*((f=f/g-1)*f*f+1)+a},easeInOutCubic:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f+a}return h/2*((f-=2)*f*f+2)+a},easeInQuart:function(e,f,a,h,g){return h*(f/=g)*f*f*f+a},easeOutQuart:function(e,f,a,h,g){return -h*((f=f/g-1)*f*f*f-1)+a},easeInOutQuart:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f*f+a}return -h/2*((f-=2)*f*f*f-2)+a},easeInQuint:function(e,f,a,h,g){return h*(f/=g)*f*f*f*f+a},easeOutQuint:function(e,f,a,h,g){return h*((f=f/g-1)*f*f*f*f+1)+a},easeInOutQuint:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f*f*f+a}return h/2*((f-=2)*f*f*f*f+2)+a},easeInSine:function(e,f,a,h,g){return -h*Math.cos(f/g*(Math.PI/2))+h+a},easeOutSine:function(e,f,a,h,g){return h*Math.sin(f/g*(Math.PI/2))+a},easeInOutSine:function(e,f,a,h,g){return -h/2*(Math.cos(Math.PI*f/g)-1)+a},easeInExpo:function(e,f,a,h,g){return(f==0)?a:h*Math.pow(2,10*(f/g-1))+a},easeOutExpo:function(e,f,a,h,g){return(f==g)?a+h:h*(-Math.pow(2,-10*f/g)+1)+a},easeInOutExpo:function(e,f,a,h,g){if(f==0){return a}if(f==g){return a+h}if((f/=g/2)<1){return h/2*Math.pow(2,10*(f-1))+a}return h/2*(-Math.pow(2,-10*--f)+2)+a},easeInCirc:function(e,f,a,h,g){return -h*(Math.sqrt(1-(f/=g)*f)-1)+a},easeOutCirc:function(e,f,a,h,g){return h*Math.sqrt(1-(f=f/g-1)*f)+a},easeInOutCirc:function(e,f,a,h,g){if((f/=g/2)<1){return -h/2*(Math.sqrt(1-f*f)-1)+a}return h/2*(Math.sqrt(1-(f-=2)*f)+1)+a},easeInElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k)==1){return e+l}if(!j){j=k*0.3}if(g<Math.abs(l)){g=l;var i=j/4}else{var i=j/(2*Math.PI)*Math.asin(l/g)}return -(g*Math.pow(2,10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j))+e},easeOutElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k)==1){return e+l}if(!j){j=k*0.3}if(g<Math.abs(l)){g=l;var i=j/4}else{var i=j/(2*Math.PI)*Math.asin(l/g)}return g*Math.pow(2,-10*h)*Math.sin((h*k-i)*(2*Math.PI)/j)+l+e},easeInOutElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k/2)==2){return e+l}if(!j){j=k*(0.3*1.5)}if(g<Math.abs(l)){g=l;var i=j/4}else{var i=j/(2*Math.PI)*Math.asin(l/g)}if(h<1){return -0.5*(g*Math.pow(2,10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j))+e}return g*Math.pow(2,-10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j)*0.5+l+e},easeInBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}return i*(f/=h)*f*((g+1)*f-g)+a},easeOutBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}return i*((f=f/h-1)*f*((g+1)*f+g)+1)+a},easeInOutBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}if((f/=h/2)<1){return i/2*(f*f*(((g*=(1.525))+1)*f-g))+a}return i/2*((f-=2)*f*(((g*=(1.525))+1)*f+g)+2)+a},easeInBounce:function(e,f,a,h,g){return h-jQuery.easing.easeOutBounce(e,g-f,0,h,g)+a},easeOutBounce:function(e,f,a,h,g){if((f/=g)<(1/2.75)){return h*(7.5625*f*f)+a}else{if(f<(2/2.75)){return h*(7.5625*(f-=(1.5/2.75))*f+0.75)+a}else{if(f<(2.5/2.75)){return h*(7.5625*(f-=(2.25/2.75))*f+0.9375)+a}else{return h*(7.5625*(f-=(2.625/2.75))*f+0.984375)+a}}}},easeInOutBounce:function(e,f,a,h,g){if(f<g/2){return jQuery.easing.easeInBounce(e,f*2,0,h,g)*0.5+a}return jQuery.easing.easeOutBounce(e,f*2-g,0,h,g)*0.5+h*0.5+a}});
6
7/* jQuery Cookie plugin */
8jQuery.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;}};
9
10/* jQuery querystring plugin */
11eval(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");
118 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,{}))
12
13// AJAX Functions
14var jq = jQuery;
15
16// Global variable to prevent multiple AJAX requests
17var bp_ajax_request = null;
18
19jq(document).ready( function() {
20	/**** Page Load Actions *******************************************************/
21	if(typeof jq == 'undefined'){
22		var jq = jQuery;
23	}
24	/* Hide Forums Post Form */
25	if ( '-1' == window.location.search.indexOf('new') && jq('div.forums').length )
26		jq('#new-topic-post').hide();
27	else
28		jq('#new-topic-post').show();
29
30	/* Activity filter and scope set */
31	bp_init_activity();
32
33	/* Object filter and scope set. */
34	var objects = [ 'members', 'groups', 'blogs', 'forums','course' ];
35	bp_init_objects( objects );
36
37	/* @mention Compose Scrolling */
38	var $whats_new = jq('#whats-new');
39	if ( jq.query.get('r') && $whats_new.length ) {
40		jq('#whats-new-options').animate({
41			height:'50px'
42		});
43		jq("#whats-new-form textarea").animate({
44			height:'50px'
45		});
46		jq.scrollTo( $whats_new, 500, {
47			offset:-125,
48			easing:'easeOutQuad'
49		} );
50		var whats_new_content = $whats_new.val();
51		$whats_new.val('').focus().val(whats_new_content);
52	}
53
54	/**** Activity Posting ********************************************************/
55
56	/* Textarea focus */
57	$whats_new.focus( function(){
58		jq("#whats-new-options").animate({
59			height:'40px'
60		});
61		jq("#whats-new-form textarea").animate({
62			height:'50px'
63		});
64		jq("#aw-whats-new-submit").prop("disabled", false);
65		
66		var $whats_new_form = jq("form#whats-new-form");
67		if ( $whats_new_form.hasClass("submitted") ) {
68			$whats_new_form.removeClass("submitted");	
69		}
70	});
71
72	/* On blur, shrink if it's empty */
73	$whats_new.blur( function(){
74		if (!this.value.match(/\S+/)) {
75			this.value = "";
76			jq("#whats-new-options").animate({
77				height:'40px'
78			});
79			jq("form#whats-new-form textarea").animate({
80				height:'30px'
81			});
82			jq("#aw-whats-new-submit").prop("disabled", true);
83		}
84	});
85
86	/* New posts */
87	jq("#aw-whats-new-submit").on( 'click', function() {
88		var button = jq(this);
89		var form = button.closest("form#whats-new-form");
90
91		form.children().each( function() {
92			if ( jq.nodeName(this, "textarea") || jq.nodeName(this, "input") )
93				jq(this).prop( 'disabled', true );
94		});
95
96		/* Remove any errors */
97		jq('div.error').remove();
98		button.addClass('loading');
99		button.prop('disabled', true);
100		form.addClass("submitted");
101
102		/* Default POST values */
103		var object = '';
104		var item_id = jq("#whats-new-post-in").val();
105		var content = jq("#whats-new").val();
106
107		/* Set object for non-profile posts */
108		if ( item_id > 0 ) {
109			object = jq("#whats-new-post-object").val();
110		}
111
112		jq.post( ajaxurl, {
113			action: 'post_update',
114			'cookie': bp_get_cookies(),
115			'_wpnonce_post_update': jq("#_wpnonce_post_update").val(),
116			'content': content,
117			'object': object,
118			'item_id': item_id,
119			'_bp_as_nonce': jq('#_bp_as_nonce').val() || ''
120		},
121		function(response) {
122
123			form.children().each( function() {
124				if ( jq.nodeName(this, "textarea") || jq.nodeName(this, "input") ) {
125					jq(this).prop( 'disabled', false );
126				}
127			});
128
129			/* Check for errors and append if found. */
130			if ( response[0] + response[1] == '-1' ) {
131				form.prepend( response.substr( 2, response.length ) );
132				jq( '#' + form.attr('id') + ' div.error').hide().fadeIn( 200 );
133			} else {
134				if ( 0 == jq("ul.activity-list").length ) {
135					jq("div.error").slideUp(100).remove();
136					jq("#message").slideUp(100).remove();
137					jq("div.activity").append( '<ul id="activity-stream" class="activity-list item-list">' );
138				}
139
140				jq("#activity-stream").prepend(response);
141				jq("#activity-stream li:first").addClass('new-update just-posted');
142
143				if ( 0 != jq("#latest-update").length ) {
144					var l = jq("#activity-stream li.new-update .activity-content .activity-inner p").html();
145					var v = jq("#activity-stream li.new-update .activity-content .activity-header p a.view").attr('href');
146
147					var ltext = jq("#activity-stream li.new-update .activity-content .activity-inner p").text();
148
149					var u = '';
150					if ( ltext != '' )
151						u = l + ' ';
152
153					u += '<a href="' + v + '" rel="nofollow">' + BP_DTheme.view + '</a>';
154
155					jq("#latest-update").slideUp(300,function(){
156						jq("#latest-update").html( u );
157						jq("#latest-update").slideDown(300);
158					});
159				}
160
161				jq("li.new-update").hide().slideDown( 300 );
162				jq("li.new-update").removeClass( 'new-update' );
163				jq("#whats-new").val('');
164			}
165
166			jq("#whats-new-options").animate({
167				height:'0px'
168			});
169			jq("#whats-new-form textarea").animate({
170				height:'20px'
171			});
172			jq("#aw-whats-new-submit").prop("disabled", true).removeClass('loading');
173		});
174
175		return false;
176	});
177
178	/* List tabs event delegation */
179	jq('div.activity-type-tabs').on( 'click', function(event) {
180		var target = jq(event.target).parent();
181
182		if ( event.target.nodeName == 'STRONG' || event.target.nodeName == 'SPAN' )
183			target = target.parent();
184		else if ( event.target.nodeName != 'A' )
185			return false;
186
187		/* Reset the page */
188		jq.cookie( 'bp-activity-oldestpage', 1, {
189			path: '/'
190		} );
191
192		/* Activity Stream Tabs */
193		var scope = target.attr('id').substr( 9, target.attr('id').length );
194		var filter = jq("#activity-filter-select select").val();
195
196		if ( scope == 'mentions' )
197			jq( '#' + target.attr('id') + ' a strong' ).remove();
198
199		bp_activity_request(scope, filter);
200
201		return false;
202	});
203
204	/* Activity filter select */
205	jq('#activity-filter-select select').change( function() {
206		var selected_tab = jq( 'div.activity-type-tabs li.selected' );
207
208		if ( !selected_tab.length )
209			var scope = null;
210		else
211			var scope = selected_tab.attr('id').substr( 9, selected_tab.attr('id').length );
212
213		var filter = jq(this).val();
214
215		bp_activity_request(scope, filter);
216
217		return false;
218	});
219
220	/* Stream event delegation */
221	jq('div.activity').on( 'click', function(event) {
222		var target = jq(event.target);
223
224		if(target.hasClass('activity-time-since')){
225			return false;
226		}
227		
228		/* Favoriting activity stream items */
229		if ( target.hasClass('fav') || target.hasClass('unfav') ) {
230			var type = target.hasClass('fav') ? 'fav' : 'unfav';
231			var parent = target.closest('.activity-item');
232			var parent_id = parent.attr('id').substr( 9, parent.attr('id').length );
233
234			target.addClass('loading');
235
236			jq.post( ajaxurl, {
237				action: 'activity_mark_' + type,
238				'cookie': bp_get_cookies(),
239				'id': parent_id
240			},
241			function(response) {
242				target.removeClass('loading');
243
244				target.fadeOut( 200, function() {
245					jq(this).html(response);
246					jq(this).attr('title', 'fav' == type ? BP_DTheme.remove_fav : BP_DTheme.mark_as_fav);
247					jq(this).fadeIn(200);
248				});
249
250				if ( 'fav' == type ) {
251					if ( !jq('.item-list-tabs #activity-favs-personal-li').length ) {
252						if ( !jq('.item-list-tabs #activity-favorites').length )
253							jq('.item-list-tabs ul #activity-mentions').before( '<li id="activity-favorites"><a href="#">' + BP_DTheme.my_favs + ' <span>0</span></a></li>');
254
255						jq('.item-list-tabs ul #activity-favorites span').html( Number( jq('.item-list-tabs ul #activity-favorites span').html() ) + 1 );
256					}
257
258					target.removeClass('fav');
259					target.addClass('unfav');
260
261				} else {
262					target.removeClass('unfav');
263					target.addClass('fav');
264
265					jq('.item-list-tabs ul #activity-favorites span').html( Number( jq('.item-list-tabs ul #activity-favorites span').html() ) - 1 );
266
267					if ( !Number( jq('.item-list-tabs ul #activity-favorites span').html() ) ) {
268						if ( jq('.item-list-tabs ul #activity-favorites').hasClass('selected') )
269							bp_activity_request( null, null );
270
271						jq('.item-list-tabs ul #activity-favorites').remove();
272					}
273				}
274
275				if ( 'activity-favorites' == jq( '.item-list-tabs li.selected').attr('id') )
276					target.parent().parent().parent().slideUp(100);
277			});
278
279			return false;
280		}
281
282		/* Delete activity stream items */
283		if ( target.hasClass('delete-activity') ) {
284			var li        = target.parents('div.activity ul li');
285			var id        = li.attr('id').substr( 9, li.attr('id').length );
286			var link_href = target.attr('href');
287			var nonce     = link_href.split('_wpnonce=');
288
289			nonce = nonce[1];
290
291			target.addClass('loading');
292
293			jq.post( ajaxurl, {
294				action: 'delete_activity',
295				'cookie': bp_get_cookies(),
296				'id': id,
297				'_wpnonce': nonce
298			},
299			function(response) {
300
301				if ( response[0] + response[1] == '-1' ) {
302					li.prepend( response.substr( 2, response.length ) );
303					li.children('#message').hide().fadeIn(300);
304				} else {
305					li.slideUp(300);
306				}
307			});
308
309			return false;
310		}
311
312		// Spam activity stream items
313		if ( target.hasClass( 'spam-activity' ) ) {
314			var li = target.parents( 'div.activity ul li' );
315			target.addClass( 'loading' );
316
317			jq.post( ajaxurl, {
318				action: 'bp_spam_activity',
319				'cookie': encodeURIComponent( document.cookie ),
320				'id': li.attr( 'id' ).substr( 9, li.attr( 'id' ).length ),
321				'_wpnonce': target.attr( 'href' ).split( '_wpnonce=' )[1]
322			},
323
324			function(response) {
325				if ( response[0] + response[1] === '-1' ) {
326					li.prepend( response.substr( 2, response.length ) );
327					li.children( '#message' ).hide().fadeIn(300);
328				} else {
329					li.slideUp( 300 );
330				}
331			});
332
333			return false;
334		}
335
336		/* Load more updates at the end of the page */
337		if ( target.parent().hasClass('load-more') ) {
338			jq("#buddypress li.load-more").addClass('loading');
339
340			if ( null == jq.cookie('bp-activity-oldestpage') )
341				jq.cookie('bp-activity-oldestpage', 1, {
342					path: '/'
343				} );
344
345			var oldest_page = ( jq.cookie('bp-activity-oldestpage') * 1 ) + 1;
346
347			var just_posted = [];
348			
349			jq('.activity-list li.just-posted').each( function(){
350				just_posted.push( jq(this).attr('id').replace( 'activity-','' ) );
351			});
352
353			jq.post( ajaxurl, {
354				action: 'activity_get_older_updates',
355				'cookie': bp_get_cookies(),
356				'page': oldest_page,
357				'exclude_just_posted': just_posted.join(',')
358			},
359			function(response)
360			{
361				jq("#buddypress li.load-more").removeClass('loading');
362				jq.cookie( 'bp-activity-oldestpage', oldest_page, {
363					path: '/'
364				} );
365				jq("#buddypress ul.activity-list").append(response.contents);
366
367				target.parent().hide();
368			}, 'json' );
369
370			return false;
371		}
372	});
373
374	// Activity "Read More" links
375	jq('div.activity').on('click', '.activity-read-more a', function(event) {
376		var target = jq(event.target);
377		var link_id = target.parent().attr('id').split('-');
378		var a_id = link_id[3];
379		var type = link_id[0]; /* activity or acomment */
380
381		var inner_class = type == 'acomment' ? 'acomment-content' : 'activity-inner';
382		var a_inner = jq('#' + type + '-' + a_id + ' .' + inner_class + ':first' );
383		jq(target).addClass('loading');
384
385		jq.post( ajaxurl, {
386			action: 'get_single_activity_content',
387			'activity_id': a_id
388		},
389		function(response) {
390			jq(a_inner).slideUp(300).html(response).slideDown(300);
391		});
392
393		return false;
394	});
395
396	/**** Activity Comments *******************************************************/
397
398	/* Hide all activity comment forms */
399	jq('form.ac-form').hide();
400
401	/* Hide excess comments */
402	if ( jq('.activity-comments').length )
403		bp_legacy_theme_hide_comments();
404
405	/* Activity list event delegation */
406	jq('div.activity').on( 'click', function(event) {
407		var target = jq(event.target);
408
409		/* Comment / comment reply links */
410		if ( target.hasClass('acomment-reply') || target.parent().hasClass('acomment-reply') ) {
411			if ( target.parent().hasClass('acomment-reply') )
412				target = target.parent();
413
414			var id = target.attr('id');
415			ids = id.split('-');
416
417			var a_id = ids[2]
418			var c_id = target.attr('href').substr( 10, target.attr('href').length );
419			var form = jq( '#ac-form-' + a_id );
420
421			form.css( 'display', 'none' );
422			form.removeClass('root');
423			jq('.ac-form').hide();
424
425			/* Hide any error messages */
426			form.children('div').each( function() {
427				if ( jq(this).hasClass( 'error' ) )
428					jq(this).hide();
429			});
430
431			if ( ids[1] != 'comment' ) {
432				jq('#acomment-' + c_id).append( form );
433			} else {
434				jq('#activity-' + a_id + ' .activity-comments').append( form );
435			}
436
437			if ( form.parent().hasClass( 'activity-comments' ) )
438				form.addClass('root');
439
440			form.slideDown( 200 );
441			jq.scrollTo( form, 500, {
442				offset:-100,
443				easing:'easeOutQuad'
444			} );
445			jq('#ac-form-' + ids[2] + ' textarea').focus();
446
447			return false;
448		}
449
450		/* Activity comment posting */
451		if ( target.attr('name') == 'ac_form_submit' ) {
452			var form = target.parents( 'form' );
453			var form_parent = form.parent();
454			var form_id = form.attr('id').split('-');
455
456			if ( !form_parent.hasClass('activity-comments') ) {
457				var tmp_id = form_parent.attr('id').split('-');
458				var comment_id = tmp_id[1];
459			} else {
460				var comment_id = form_id[2];
461			}
462
463			var content = jq( '#' + form.attr('id') + ' textarea' );
464
465			/* Hide any error messages */
466			jq( '#' + form.attr('id') + ' div.error').hide();
467			target.addClass('loading').prop('disabled', true);
468			content.addClass('loading').prop('disabled', true);
469
470			var ajaxdata = {
471				action: 'new_activity_comment',
472				'cookie': bp_get_cookies(),
473				'_wpnonce_new_activity_comment': jq("#_wpnonce_new_activity_comment").val(),
474				'comment_id': comment_id,
475				'form_id': form_id[2],
476				'content': content.val()
477			};
478
479			// Akismet
480			var ak_nonce = jq('#_bp_as_nonce_' + comment_id).val();
481			if ( ak_nonce ) {
482				ajaxdata['_bp_as_nonce_' + comment_id] = ak_nonce;
483			}
484
485			jq.post( ajaxurl, ajaxdata, function(response) {
486				target.removeClass('loading');
487				content.removeClass('loading');
488
489				/* Check for errors and append if found. */
490				if ( response[0] + response[1] == '-1' ) {
491					form.append( jq( response.substr( 2, response.length ) ).hide().fadeIn( 200 ) );
492				} else {
493					var activity_comments = form.parent();
494					form.fadeOut( 200, function() {
495						if ( 0 == activity_comments.children('ul').length ) {
496							if ( activity_comments.hasClass('activity-comments') ) {
497								activity_comments.prepend('<ul></ul>');
498							} else {
499								activity_comments.append('<ul></ul>');
500							}
501						}
502
503						/* Preceeding whitespace breaks output with jQuery 1.9.0 */
504						var the_comment = jq.trim( response );
505
506						activity_comments.children('ul').append( jq( the_comment ).hide().fadeIn( 200 ) );
507						form.children('textarea').val('');
508						activity_comments.parent().addClass('has-comments');
509					} );
510					jq( '#' + form.attr('id') + ' textarea').val('');
511
512					/* Increase the "Reply (X)" button count */
513					jq('#activity-' + form_id[2] + ' a.acomment-reply span').html( Number( jq('#activity-' + form_id[2] + ' a.acomment-reply span').html() ) + 1 );
514
515					// Increment the 'Show all x comments' string, if present
516					var show_all_a = activity_comments.find('.show-all').find('a');
517					if ( show_all_a ) {
518						var new_count = jq('li#activity-' + form_id[2] + ' a.acomment-reply span').html();
519						show_all_a.html( BP_DTheme.show_x_comments.replace( '%d', new_count ) );
520					}
521				}
522
523				jq(target).prop("disabled", false);
524				jq(content).prop("disabled", false);
525			});
526
527			return false;
528		}
529
530		/* Deleting an activity comment */
531		if ( target.hasClass('acomment-delete') ) {
532			var link_href = target.attr('href');
533			var comment_li = target.parent().parent();
534			var form = comment_li.parents('div.activity-comments').children('form');
535
536			var nonce = link_href.split('_wpnonce=');
537			nonce = nonce[1];
538
539			var comment_id = link_href.split('cid=');
540			comment_id = comment_id[1].split('&');
541			comment_id = comment_id[0];
542
543			target.addClass('loading');
544
545			/* Remove any error messages */
546			jq('.activity-comments ul .error').remove();
547
548			/* Reset the form position */
549			comment_li.parents('.activity-comments').append(form);
550
551			jq.post( ajaxurl, {
552				action: 'delete_activity_comment',
553				'cookie': bp_get_cookies(),
554				'_wpnonce': nonce,
555				'id': comment_id
556			},
557			function(response) {
558				/* Check for errors and append if found. */
559				if ( response[0] + response[1] == '-1' ) {
560					comment_li.prepend( jq( response.substr( 2, response.length ) ).hide().fadeIn( 200 ) );
561				} else {
562					var children = jq( '#' + comment_li.attr('id') + ' ul' ).children('li');
563					var child_count = 0;
564					jq(children).each( function() {
565						if ( !jq(this).is(':hidden') )
566							child_count++;
567					});
568					comment_li.fadeOut(200, function() {
569						comment_li.remove();
570					});
571
572					/* Decrease the "Reply (X)" button count */
573					var count_span = jq('#' + comment_li.parents('#activity-stream > li').attr('id') + ' a.acomment-reply span');
574					var new_count = count_span.html() - ( 1 + child_count );
575					count_span.html(new_count);
576					
577					// Change the 'Show all x comments' text
578					var show_all_a = comment_li.siblings('.show-all').find('a');
579					if ( show_all_a ) {
580						show_all_a.html( BP_DTheme.show_x_comments.replace( '%d', new_count ) );
581					}
582
583					/* If that was the last comment for the item, remove the has-comments class to clean up the styling */
584					if ( 0 == new_count ) {
585						jq(comment_li.parents('#activity-stream > li')).removeClass('has-comments');
586					}
587				}
588			});
589
590			return false;
591		}
592
593		// Spam an activity stream comment
594		if ( target.hasClass( 'spam-activity-comment' ) ) {
595			var link_href  = target.attr( 'href' );
596			var comment_li = target.parent().parent();
597
598			target.addClass('loading');
599
600			// Remove any error messages
601			jq( '.activity-comments ul div.error' ).remove();
602
603			// Reset the form position
604			comment_li.parents( '.activity-comments' ).append( comment_li.parents( '.activity-comments' ).children( 'form' ) );
605
606			jq.post( ajaxurl, {
607				action: 'bp_spam_activity_comment',
608				'cookie': encodeURIComponent( document.cookie ),
609				'_wpnonce': link_href.split( '_wpnonce=' )[1],
610				'id': link_href.split( 'cid=' )[1].split( '&' )[0]
611			},
612
613			function ( response ) {
614				// Check for errors and append if found.
615				if ( response[0] + response[1] == '-1' ) {
616					comment_li.prepend( jq( response.substr( 2, response.length ) ).hide().fadeIn( 200 ) );
617
618				} else {
619					var children = jq( '#' + comment_li.attr( 'id' ) + ' ul' ).children( 'li' );
620					var child_count = 0;
621					jq(children).each( function() {
622						if ( !jq( this ).is( ':hidden' ) ) {
623							child_count++;
624						}
625					});
626					comment_li.fadeOut( 200 );
627
628					// Decrease the "Reply (X)" button count
629					var parent_li = comment_li.parents( '#activity-stream > li' );
630					jq( '#' + parent_li.attr( 'id' ) + ' a.acomment-reply span' ).html( jq( '#' + parent_li.attr( 'id' ) + ' a.acomment-reply span' ).html() - ( 1 + child_count ) );
631				}
632			});
633
634			return false;
635		}
636
637		/* Showing hidden comments - pause for half a second */
638		if ( target.parent().hasClass('show-all') ) {
639			target.parent().addClass('loading');
640
641			setTimeout( function() {
642				target.parent().parent().children('li').fadeIn(200, function() {
643					target.parent().remove();
644				});
645			}, 600 );
646
647			return false;
648		}
649
650		// Canceling an activity comment	
651		if ( target.hasClass( 'ac-reply-cancel' ) ) {
652			jq(target).closest('.ac-form').slideUp( 200 );
653			return false;
654		};
655	});
656
657	/* Escape Key Press for cancelling comment forms */
658	jq(document).keydown( function(e) {
659		e = e || window.event;
660		if (e.target)
661			element = e.target;
662		else if (e.srcElement)
663			element = e.srcElement;
664
665		if( element.nodeType == 3)
666			element = element.parentNode;
667
668		if( e.ctrlKey == true || e.altKey == true || e.metaKey == true )
669			return;
670
671		var keyCode = (e.keyCode) ? e.keyCode : e.which;
672
673		if ( keyCode == 27 ) {
674			if (element.tagName == 'TEXTAREA') {
675				if ( jq(element).hasClass('ac-input') )
676					jq(element).parent().parent().parent().slideUp( 200 );
677			}
678		}
679	});
680
681	/**** Directory Search ****************************************************/
682	/* The search form on all directory pages */
683	jq(document).on('keyup','.dir-search input',function(event){
684        var value = jq(this).val();
685		/* The search form on all directory pages */
686
687		var target = jq(event.target);
688		var id;
689
690		//if ( target.attr('type') == 'submit' ) {
691		if(jq('.item-list-tabs li.selected').length){
692			id = jq('.item-list-tabs li.selected').attr('id');
693		}else{
694			if(jq('body').hasClass('course')){
695				id = 'course-all';
696			}else if(jq('body').hasClass('members')){
697				id = 'members-all';
698			}else if(jq('body').hasClass('groups')){
699				id = 'groups-all';
700			}
701		}
702	
703		if(typeof id !== 'undefined'){
704			if(id.indexOf('-')>=0){
705				var css_id = id.split( '-' );
706				var object = css_id[0];
707				jq(this).closest('.dir-search').addClass('loading');
708				bp_filter_request( object, jq.cookie('bp-' + object + '-filter'), jq.cookie('bp-' + object + '-scope') , 'div.' + object, value, 1, jq.cookie('bp-' + object + '-extras') );
709			}
710		}
711
712			return false;
713		//}
714	});
715
716	/**** Tabs and Filters ****************************************************/
717
718	/* When a navigation tab is clicked - e.g. | All Groups | My Groups | */
719	jq('div.item-list-tabs').click( function(event) {
720		if ( jq(this).hasClass('no-ajax') )
721			return;
722
723		var targetElem = ( event.target.nodeName == 'SPAN' ) ? event.target.parentNode : event.target;
724		var target     = jq( targetElem ).parent();
725		if ( 'LI' == target[0].nodeName && !target.hasClass('last') ) {
726			var css_id = target.attr('id').split( '-' );
727			var object = css_id[0];
728
729			if ( 'activity' == object )
730				return false;
731
732			var scope = css_id[1];
733			var filter = jq("#" + object + "-order-select select").val();
734			var search_terms = jq("#" + object + "_search").val();
735
736			bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras') );
737
738			return false;
739		}
740	});
741
742	/* When the filter select box is changed re-query */
743	jq('li.filter select').change( function() {
744		if ( jq('.item-list-tabs li.selected').length )
745			var el = jq('.item-list-tabs li.selected');
746		else
747			var el = jq(this);
748
749		var css_id = el.attr('id').split('-');
750		var object = css_id[0];
751		var scope = css_id[1];
752		var filter = jq(this).val();
753		var search_terms = false;
754
755		if(jq('body').hasClass('instructor-courses')){
756			if(jq('#instructor-courses-personal-li').hasClass('current')){
757				scope = 'instructor';
758			}
759		}
760
761		if ( jq('.dir-search input').length )
762			search_terms = jq('.dir-search input').val();
763
764		if ( 'friends' == object )
765			object = 'members';
766
767		bp_filter_request( object, filter, scope, 'div.' + object, search_terms, 1, jq.cookie('bp-' + object + '-extras') );
768		
769		return false;
770	});
771
772	/* All pagination links run through this function */
773	jq('#buddypress').on( 'click', function(event) {
774		var target = jq(event.target);
775
776		if ( target.hasClass('button') )
777			return true;
778
779		if ( target.parent().parent().hasClass('pagination') && !target.parent().parent().hasClass('no-ajax') ) {
780			if ( target.hasClass('dots') || target.hasClass('current') )
781				return false;
782
783			if ( jq('.item-list-tabs li.selected').length )
784				var el = jq('.item-list-tabs li.selected');
785			else
786				var el = jq('li.filter select');
787
788			var page_number = 1;
789			var css_id = el.attr('id').split( '-' );
790			var object = css_id[0];
791			var search_terms = false;
792			var pagination_id = jq(target).closest('.pagination-links').attr('id');
793
794			if ( jq('div.dir-search input').length )
795				search_terms = jq('.dir-search input').val();
796
797			if ( jq(target).hasClass('next') )
798				var page_number = Number( jq('.pagination span.current').html() ) + 1;
799			else if ( jq(target).hasClass('prev') )
800				var page_number = Number( jq('.pagination span.current').html() ) - 1;
801			else
802				var page_number = Number( jq(target).html() );
803			
804			if ( pagination_id && pagination_id.indexOf( 'pag-bottom' ) !== -1 ) {
805				var caller = 'pag-bottom';
806			} else {
807				var caller = null;
808			}
809
810			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'), caller );
811
812			return false;
813		}
814
815	});
816
817	/**** New Forum Directory Post **************************************/
818
819	/* Hit the "New Topic" button on the forums directory page */
820	jq('a.show-hide-new').on( 'click', function() {
821		if ( !jq('#new-topic-post').length )
822			return false;
823
824		if ( jq('#new-topic-post').is(":visible") )
825			jq('#new-topic-post').slideUp(200);
826		else
827			jq('#new-topic-post').slideDown(200, function() {
828				jq('#topic_title').focus();
829			} );
830
831		return false;
832	});
833
834	/* Cancel the posting of a new forum topic */
835	jq('#submit_topic_cancel').on( 'click', function() {
836		if ( !jq('#new-topic-post').length )
837			return false;
838
839		jq('#new-topic-post').slideUp(200);
840		return false;
841	});
842
843	/* Clicking a forum tag */
844	jq('#forum-directory-tags a').on( 'click', function() {
845		bp_filter_request( 'forums', 'tags', jq.cookie('bp-forums-scope'), 'div.forums', jq(this).html().replace( /&nbsp;/g, '-' ), 1, jq.cookie('bp-forums-extras') );
846		return false;
847	});
848
849	/** Invite Friends Interface ****************************************/
850
851	/* Select a user from the list of friends and add them to the invite list */
852	jq("#invite-list input").on( 'click', function() {
853		jq('.ajax-loader').toggle();
854
855		var friend_id = jq(this).val();
856
857		if ( jq(this).prop('checked') == true )
858			var friend_action = 'invite';
859		else
860			var friend_action = 'uninvite';
861
862		jq('.item-list-tabs li.selected').addClass('loading');
863
864		jq.post( ajaxurl, {
865			action: 'groups_invite_user',
866			'friend_action': friend_action,
867			'cookie': bp_get_cookies(),
868			'_wpnonce': jq("#_wpnonce_invite_uninvite_user").val(),
869			'friend_id': friend_id,
870			'group_id': jq("#group_id").val()
871		},
872		function(response)
873		{
874			if ( jq("#message") )
875				jq("#message").hide();
876
877			jq('.ajax-loader').toggle();
878
879			if ( friend_action == 'invite' ) {
880				jq('#friend-list').append(response);
881			} else if ( friend_action == 'uninvite' ) {
882				jq('#friend-list li#uid-' + friend_id).remove();
883			}
884			jq('.item-list-tabs li.selected').removeClass('loading');
885		});
886	});
887
888	/* Remove a user from the list of users to invite to a group */
889	jq("#friend-list").on('click', 'li a.remove', function() {
890		jq('.ajax-loader').toggle();
891
892		var friend_id = jq(this).attr('id');
893		friend_id = friend_id.split('-');
894		friend_id = friend_id[1];
895
896		jq.post( ajaxurl, {
897			action: 'groups_invite_user',
898			'friend_action': 'uninvite',
899			'cookie': bp_get_cookies(),
900			'_wpnonce': jq("#_wpnonce_invite_uninvite_user").val(),
901			'friend_id': friend_id,
902			'group_id': jq("#group_id").val()
903		},
904		function(response)
905		{
906			jq('.ajax-loader').toggle();
907			jq('#friend-list #uid-' + friend_id).remove();
908			jq('#invite-list #f-' + friend_id).prop('checked', false);
909		});
910
911		return false;
912	});
913
914	/** Profile Visibility Settings *********************************/
915	jq('.field-visibility-settings').hide();
916	jq('.visibility-toggle-link').on( 'click', function() {
917		var toggle_div = jq(this).parent();
918
919		jq(toggle_div).fadeOut( 600, function(){
920			jq(toggle_div).siblings('.field-visibility-settings').slideDown(400);
921		});
922
923		return false;
924	} );
925
926	jq('.field-visibility-settings-close').on( 'click', function() {
927		var settings_div = jq(this).parent();
928		var vis_setting_text = settings_div.find('input:checked').parent().text();
929
930		settings_div.slideUp( 400, function() {
931			settings_div.siblings('.field-visibility-settings-toggle').fadeIn(800);
932			settings_div.siblings('.field-visibility-settings-toggle').children('.current-visibility-level').html(vis_setting_text);
933		} );
934
935		return false;
936	} );
937
938	jq("#profile-edit-form input:not(:submit), #profile-edit-form textarea, #profile-edit-form select, #signup_form input:not(:submit), #signup_form textarea, #signup_form select").change( function() {
939		var shouldconfirm = true;
940
941		jq('#profile-edit-form input:submit, #signup_form input:submit').on( 'click', function() {
942			shouldconfirm = false;
943		});
944		
945		window.onbeforeunload = function(e) {
946			if ( shouldconfirm ) {
947				return BP_DTheme.unsaved_changes;
948			}
949		};
950	});
951
952	/** Friendship Requests **************************************/
953
954	/* Accept and Reject friendship request buttons */
955	jq("#friend-list a.accept, #friend-list a.reject").on( 'click', function() {
956		var button = jq(this);
957		var li = jq(this).parents('#friend-list li');
958		var action_div = jq(this).parents('li div.action');
959
960		var id = li.attr('id').substr( 11, li.attr('id').length );
961		var link_href = button.attr('href');
962
963		var nonce = link_href.split('_wpnonce=');
964		nonce = nonce[1];
965
966		if ( jq(this).hasClass('accepted') || jq(this).hasClass('rejected') )
967			return false;
968
969		if ( jq(this).hasClass('accept') ) {
970			var action = 'accept_friendship';
971			action_div.children('a.reject').css( 'visibility', 'hidden' );
972		} else {
973			var action = 'reject_friendship';
974			action_div.children('a.accept').css( 'visibility', 'hidden' );
975		}
976
977		button.addClass('loading');
978
979		jq.post( ajaxurl, {
980			action: action,
981			'cookie': bp_get_cookies(),
982			'id': id,
983			'_wpnonce': nonce
984		},
985		function(response) {
986			button.removeClass('loading');
987
988			if ( response[0] + response[1] == '-1' ) {
989				li.prepend( response.substr( 2, response.length ) );
990				li.children('#message').hide().fadeIn(200);
991			} else {
992				button.fadeOut( 100, function() {
993					if ( jq(this).hasClass('accept') ) {
994						action_div.children('a.reject').hide();
995						jq(this).html( BP_DTheme.accepted ).contents().unwrap();
996					} else {
997						action_div.children('a.accept').hide();
998						jq(this).html( BP_DTheme.rejected ).contents().unwrap();
999					}
1000				});
1001			}
1002		});
1003
1004		return false;
1005	});
1006
1007	/* Add / Remove friendship buttons */
1008	jq('#members-dir-list').on('click', '.friendship-button a', function() {
1009		jq(this).parent().addClass('loading');
1010		var fid = jq(this).attr('id');
1011		fid = fid.split('-');
1012		fid = fid[1];
1013
1014		var nonce = jq(this).attr('href');
1015		nonce = nonce.split('?_wpnonce=');
1016		nonce = nonce[1].split('&');
1017		nonce = nonce[0];
1018
1019		var thelink = jq(this);
1020
1021		jq.post( ajaxurl, {
1022			action: 'addremove_friend',
1023			'cookie': bp_get_cookies(),
1024			'fid': fid,
1025			'_wpnonce': nonce
1026		},
1027		function(response)
1028		{
1029			var action = thelink.attr('rel');
1030			var parentdiv = thelink.parent();
1031
1032			if ( action == 'add' ) {
1033				jq(parentdiv).fadeOut(200,
1034					function() {
1035						parentdiv.removeClass('add_friend');
1036						parentdiv.removeClass('loading');
1037						parentdiv.addClass('pending_friend');
1038						parentdiv.fadeIn(200).html(response);
1039					}
1040					);
1041
1042			} else if ( action == 'remove' ) {
1043				jq(parentdiv).fadeOut(200,
1044					function() {
1045						parentdiv.removeClass('remove_friend');
1046						parentdiv.removeClass('loading');
1047						parentdiv.addClass('add');
1048						parentdiv.fadeIn(200).html(response);
1049					}
1050					);
1051			}
1052		});
1053		return false;
1054	} );
1055
1056	/** Group Join / Leave Buttons **************************************/
1057
1058	// Confirmation when clicking Leave Group in group headers
1059	jq('#buddypress').on('click', '.group-button .leave-group', function() {
1060		if ( false == confirm( BP_DTheme.leave_group_confirm ) ) {
1061			return false;
1062		}
1063	});
1064
1065	jq('#groups-dir-list').on('click', '.group-button a', function() {
1066		var gid = jq(this).parent().attr('id');
1067		gid = gid.split('-');
1068		gid = gid[1];
1069
1070		var nonce = jq(this).attr('href');
1071		nonce = nonce.split('?_wpnonce=');
1072		nonce = nonce[1].split('&');
1073		nonce = nonce[0];
1074
1075		var thelink = jq(this);
1076
1077		// Leave Group confirmation within directories - must intercept
1078		// AJAX request
1079		if ( thelink.hasClass( 'leave-group' ) && false == confirm( BP_DTheme.leave_group_confirm ) ) {
1080			return false;
1081		}
1082
1083		jq.post( ajaxurl, {
1084			action: 'joinleave_group',
1085			'cookie': bp_get_cookies(),
1086			'gid': gid,
1087			'_wpnonce': nonce
1088		},
1089		function(response)
1090		{
1091			var parentdiv = thelink.parent();
1092
1093			// user groups page
1094			if ( ! jq('body.directory').length ) {
1095				location.href = location.href;
1096
1097			// groups directory
1098			} else {
1099				jq(parentdiv).fadeOut(200,
1100					function() {
1101						parentdiv.fadeIn(200).html(response);
1102
1103						var mygroups = jq('#groups-personal span');
1104						var add      = 1;
1105
1106						if( thelink.hasClass( 'leave-group' ) ) {
1107							// hidden groups slide up
1108							if ( parentdiv.hasClass( 'hidden' ) ) {
1109								parentdiv.closest('li').slideUp( 200 );
1110							}
1111
1112							add = 0;
1113						} else if ( thelink.hasClass( 'request-membership' ) ) {
1114							add = false;
1115						}
1116
1117						// change the "My Groups" value
1118						if ( mygroups.length && add !== false ) {
1119							if ( add ) {
1120								mygroups.text( ( mygroups.text() >> 0 ) + 1 );
1121							} else {
1122								mygroups.text( ( mygroups.text() >> 0 ) - 1 );
1123							}
1124						}
1125
1126					}
1127				);
1128			}
1129		});
1130		return false;
1131	} );
1132
1133	/** Button disabling ************************************************/
1134
1135	jq('#buddypress').on( 'click', '.pending', function() {
1136		return false;
1137	});
1138
1139	/** Private Messaging ******************************************/
1140
1141	/** Message search*/
1142	jq('.message-search').on( 'click', function(event) {
1143		if ( jq(this).hasClass('no-ajax') )
1144			return;
1145
1146		var target = jq(event.target);
1147
1148		if ( target.attr('type') == 'submit' ) {
1149			//var css_id = jq('.item-list-tabs li.selected').attr('id').split( '-' );
1150			var object = 'messages';
1151
1152			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') );
1153
1154			return false;
1155		}
1156	});
1157
1158	/* AJAX send reply functionality */
1159	jq("#send_reply_button").click(
1160		function() {
1161			var order = jq('#messages_order').val() || 'ASC',
1162			offset = jq('#message-recipients').offset();
1163
1164			var button = jq("#send_reply_button");
1165			jq(button).addClass('loading');
1166
1167			jq.post( ajaxurl, {
1168				action: 'messages_send_reply',
1169				'cookie': bp_get_cookies(),
1170				'_wpnonce': jq("#send_message_nonce").val(),
1171
1172				'content': jq("#message_content").val(),
1173				'send_to': jq("#send_to").val(),
1174				'subject': jq("#subject").val(),
1175				'thread_id': jq("#thread_id").val()
1176			},
1177			function(response)
1178			{
1179				if ( response[0] + response[1] == "-1" ) {
1180					jq('#send-reply').prepend( response.substr( 2, response.length ) );
1181				} else {
1182					jq('#send-reply #message').remove();
1183					jq("#message_content").val('');
1184
1185					if ( 'ASC' == order ) {
1186						jq('#send-reply').before( response );
1187					} else {
1188						jq('#message-recipients').after( response );
1189						jq(window).scrollTop(offset.top);
1190					}
1191
1192					jq(".new-message").hide().slideDown( 200, function() {
1193						jq('.new-message').removeClass('new-message');
1194					});
1195				}
1196				jq(button).removeClass('loading');
1197			});
1198
1199			return false;
1200		}
1201	);
1202
1203	/* Marking private messages as read and unread */
1204	jq("#mark_as_read, #mark_as_unread").click(function() {
1205		var checkboxes_tosend = '';
1206		var checkboxes = jq("#message-threads tr td input[type='checkbox']");
1207
1208		if ( 'mark_as_unread' == jq(this).attr('id') ) {
1209			var currentClass = 'read'
1210			var newClass = 'unread'
1211			var unreadCount = 1;
1212			var inboxCount = 0;
1213			var unreadCountDisplay = 'inline';
1214			var action = 'messages_markunread';
1215		} else {
1216			var currentClass = 'unread'
1217			var newClass = 'read'
1218			var unreadCount = 0;
1219			var inboxCount = 1;
1220			var unreadCountDisplay = 'none';
1221			var action = 'messages_markread';
1222		}
1223
1224		checkboxes.each( function(i) {
1225			if(jq(this).is(':checked')) {
1226				if ( jq('#m-' + jq(this).attr('value')).hasClass(currentClass) ) {
1227					checkboxes_tosend += jq(this).attr('value');
1228					jq('#m-' + jq(this).attr('value')).removeClass(currentClass);
1229					jq('#m-' + jq(this).attr('value')).addClass(newClass);
1230					var thread_count = jq('#m-' + jq(this).attr('value') + ' td span.unread-count').html();
1231
1232					jq('#m-' + jq(this).attr('value') + ' td span.unread-count').html(unreadCount);
1233					jq('#m-' + jq(this).attr('value') + ' td span.unread-count').css('display', unreadCountDisplay);
1234
1235					var inboxcount = jq('tr.unread').length;
1236
1237					jq('#user-messages span').html( inboxcount );
1238
1239					if ( i != checkboxes.length - 1 ) {
1240						checkboxes_tosend += ','
1241					}
1242				}
1243			}
1244		});
1245		jq.post( ajaxurl, {
1246			action: action,
1247			'thread_ids': checkboxes_tosend
1248		});
1249		return false;
1250	});
1251
1252	/* Selecting unread and read messages in inbox */
1253	jq( 'body.messages #item-body div.messages' ).on( 'change', '#message-type-select', function() {
1254		var selection = this.value;
1255		var checkboxes = jq( "td input[type='checkbox']" );
1256
1257		checkboxes.each( function(i) {
1258			checkboxes[i].checked = "";
1259		});
1260
1261		var checked_value = "checked";
1262		switch ( selection ) {
1263			case 'unread' :
1264				checkboxes = jq("tr.unread td input[type='checkbox']");
1265				break;
1266			case 'read' :
1267				checkboxes = jq("tr.read td input[type='checkbox']");
1268				break;
1269			case '' :
1270				checked_value = "";
1271				break;
1272		}
1273
1274		checkboxes.each( function(i) {
1275			checkboxes[i].checked = checked_value;
1276		});
1277	});
1278	
1279	/* Bulk delete messages */
1280	jq( 'body.messages #item-body div.messages' ).on( 'click', '.messages-options-nav a', function(event) {
1281		event.preventDefault();
1282		if ( -1 == jq.inArray( this.id , Array( 'delete_sentbox_messages', 'delete_inbox_messages' ) )) {
1283			return;
1284		}
1285		checkboxes_tosend = '';
1286		checkboxes = jq("#message-threads tr td input[type='checkbox']");
1287
1288		jq('#message').remove();
1289		jq(this).addClass('loading');
1290
1291		jq(checkboxes).each( function(i) {
1292			if( jq(this).is(':checked') )
1293				checkboxes_tosend += jq(this).attr('value') + ',';
1294		});
1295
1296		if ( '' == checkboxes_tosend ) {
1297			jq(this).removeClass('loading');
1298			return false;
1299		}
1300		jq.post( ajaxurl, {
1301			action: 'messages_delete',
1302			'thread_ids': checkboxes_tosend
1303		}, function(response) {
1304			if ( response[0] + response[1] == "-1" ) {
1305				jq('#message-threads').prepend( response.substr( 2, response.length ) );
1306			} else {
1307				jq('#message-threads').before( '<div id="message" class="updated"><p>' + response + '</p></div>' );
1308
1309				jq(checkboxes).each( function(i) {
1310					if( jq(this).is(':checked') ) {
1311						// We need to uncheck because message is only hidden
1312						// Otherwise, AJAX will be fired again with same data 
1313						jq(this).attr( 'checked', false );
1314						jq(this).parent().parent().fadeOut(150);
1315					}
1316				});
1317			}
1318
1319			jq('#message').hide().slideDown(150);
1320			jq("#delete_inbox_messages, #delete_sentbox_messages").removeClass('loading');
1321		});
1322
1323		return false;
1324	});
1325	
1326
1327	/* Star action function */
1328	starAction = function() {
1329		var link = jq(this);
1330
1331		jq.post( ajaxurl, {
1332			action: 'messages_star',
1333			'message_id': link.data('message-id'),
1334			'star_status': link.data('star-status'),
1335			'nonce': link.data('star-nonce'),
1336			'bulk': link.data('star-bulk')
1337		},
1338		function(response) {
1339			if ( 1 === parseInt( response, 10 ) ) {
1340				if ( 'unstar' === link.data('star-status') ) {
1341					link.data('star-status', 'star');
1342					link.removeClass('message-action-unstar').addClass('message-action-star');
1343					link.find('.bp-screen-reader-text').text( BP_PM_Star.strings.text_star );
1344
1345					if ( 1 === BP_PM_Star.is_single_thread ) {
1346						link.prop('title', BP_PM_Star.strings.title_star );
1347					} else {
1348						link.prop('title', BP_PM_Star.strings.title_star_thread );
1349					}
1350
1351				} else {
1352					link.data('star-status', 'unstar');
1353					link.removeClass('message-action-star').addClass('message-action-unstar');
1354					link.find('.bp-screen-reader-text').text(BP_PM_Star.strings.text_unstar);
1355
1356					if ( 1 === BP_PM_Star.is_single_thread ) {
1357						link.prop('title', BP_PM_Star.strings.title_unstar );
1358					} else {
1359						link.prop('title', BP_PM_Star.strings.title_unstar_thread );
1360					}
1361				}
1362			}
1363		});
1364		return false;
1365	};
1366
1367	/* Star actions */
1368	jq('#message-threads').on('click', 'td.thread-star a', starAction );
1369	jq('#message-thread').on('click', '.message-star-actions a', starAction );
1370	
1371	/* Star bulk manage - Show only the valid action based on the starred item. */
1372	jq('#message-threads td.bulk-select-check :checkbox').on('change', function() {
1373		var box = jq(this),
1374			star = box.closest('tr').find('.thread-star a');
1375
1376		if ( box.prop('checked') ) {
1377			if( 'unstar' === star.data('star-status') ) {
1378				BP_PM_Star.star_counter++;
1379			} else {
1380				BP_PM_Star.unstar_counter++;
1381			}
1382		} else {
1383			if( 'unstar' === star.data('star-status') ) {
1384				BP_PM_Star.star_counter--;
1385			} else {
1386				BP_PM_Star.unstar_counter--;
1387			}
1388		}
1389
1390		if ( BP_PM_Star.star_counter > 0 && parseInt( BP_PM_Star.unstar_counter, 10 ) === 0 ) {
1391			jq('option[value="star"]').hide();
1392		} else {
1393			jq('option[value="star"]').show();
1394		}
1395
1396		if ( BP_PM_Star.unstar_counter > 0 && parseInt( BP_PM_Star.star_counter, 10 ) === 0 ) {
1397			jq('option[value="unstar"]').hide();
1398		} else {
1399			jq('option[value="unstar"]').show();
1400		}
1401	});
1402	/** Notifications **********************************************/
1403
1404	/* Selecting/Deselecting all notifications */
1405	jq('#select-all-notifications').click(function(event) {
1406		if( this.checked ) {
1407			jq('.notification-check').each(function() {
1408				this.checked = true;
1409			});
1410		} else {
1411			jq('.notification-check').each(function() {
1412				this.checked = false;
1413			});
1414		}
1415	});
1416
1417	/* Make sure a 'Bulk Action' is selected before submitting the form */
1418	jq('#notification-bulk-manage').attr('disabled', 'disabled');
1419
1420	/* Remove the disabled attribute from the form submit button when bulk action has a value */
1421	jq('#notification-select').on('change', function(){
1422		jq('#notification-bulk-manage').attr('disabled', jq(this).val().length <= 0);
1423	});
1424
1425
1426	/* Close site wide notices in the sidebar */
1427	jq("#close-notice").on( 'click', function() {
1428		jq(this).addClass('loading');
1429		jq('#sidebar div.error').remove();
1430
1431		jq.post( ajaxurl, {
1432			action: 'messages_close_notice',
1433			'notice_id': jq('.notice').attr('rel').substr( 2, jq('.notice').attr('rel').length )
1434		},
1435		function(response) {
1436			jq("#close-notice").removeClass('loading');
1437
1438			if ( response[0] + response[1] == '-1' ) {
1439				jq('.notice').prepend( response.substr( 2, response.length ) );
1440				jq( '#sidebar div.error').hide().fadeIn( 200 );
1441			} else {
1442				jq('.notice').slideUp( 100 );
1443			}
1444		});
1445		return false;
1446	});
1447
1448	/* Toolbar & wp_list_pages Javascript IE6 hover class */
1449	jq("#wp-admin-bar ul.main-nav li, #nav li").mouseover( function() {
1450		jq(this).addClass('sfhover');
1451	});
1452
1453	jq("#wp-admin-bar ul.main-nav li, #nav li").mouseout( function() {
1454		jq(this).removeClass('sfhover');
1455	});
1456
1457	/* Clear BP cookies on logout */
1458	jq('a.logout').on( 'click', function() {
1459		jq.cookie('bp-activity-scope', null, {
1460			path: '/'
1461		});
1462		jq.cookie('bp-activity-filter', null, {
1463			path: '/'
1464		});
1465		jq.cookie('bp-activity-oldestpage', null, {
1466			path: '/'
1467		});
1468
1469		var objects = [ 'members', 'groups', 'blogs', 'forums' ];
1470		jq(objects).each( function(i) {
1471			jq.cookie('bp-' + objects[i] + '-scope', null, {
1472				path: '/'
1473			} );
1474			jq.cookie('bp-' + objects[i] + '-filter', null, {
1475				path: '/'
1476			} );
1477			jq.cookie('bp-' + objects[i] + '-extras', null, {
1478				path: '/'
1479			} );
1480		});
1481	});
1482	
1483	/* if js is enabled then replace the no-js class by a js one */
1484	if( jq('body').hasClass('no-js') )
1485		jq('body').attr('class', jq('body').attr('class').replace( /no-js/,'js' ) );
1486		
1487});
1488
1489/* Setup activity scope and filter based on the current cookie settings. */
1490function bp_init_activity() {
1491
1492	if(typeof jq == 'undefined'){
1493		var jq = jQuery;
1494	}
1495
1496	/* Reset the page */
1497	jq.cookie( 'bp-activity-oldestpage', 1, {
1498		path: '/'
1499	} );
1500
1501	if ( null != jq.cookie('bp-activity-filter') && jq('#activity-filter-select').length )
1502		jq('#activity-filter-select select option[value="' + jq.cookie('bp-activity-filter') + '"]').prop( 'selected', true );
1503
1504	/* Activity Tab Set */
1505	if ( null != jq.cookie('bp-activity-scope') && jq('.activity-type-tabs').length ) {
1506		jq('.activity-type-tabs li').each( function() {
1507			jq(this).removeClass('selected');
1508		});
1509		jq('#activity-' + jq.cookie('bp-activity-scope') + ', .item-list-tabs li.current').addClass('selected');
1510	}
1511}
1512
1513/* Setup object scope and filter based on the current cookie settings for the object. */
1514function bp_init_objects(objects) {
1515
1516	if(typeof jq == 'undefined'){
1517		var jq = jQuery;
1518	}
1519	jq(objects).each( function(i) {
1520		if(objects[i] == 'course')
1521			return;
1522		if ( null != jq.cookie('bp-' + objects[i] + '-filter') && jq('#' + objects[i] + '-order-select select').length )
1523			jq('#' + objects[i] + '-order-select select option[value="' + jq.cookie('bp-' + objects[i] + '-filter') + '"]').prop( 'selected', true );
1524
1525		if ( null != jq.cookie('bp-' + objects[i] + '-scope') && jq('div.' + objects[i]).length ) {
1526			jq('.item-list-tabs li').each( function() {
1527				jq(this).removeClass('selected');
1528			});
1529			jq('#' + objects[i] + '-' + jq.cookie('bp-' + objects[i] + '-scope') + ', #object-nav li.current').addClass('selected');
1530			if (typeof jq.cookie('bp-' + objects[i] + '-scope') !== 'undefined'){
1531				//bp_filter_request( objects[i], jq.cookie('bp-' + objects[i] + '-filter'), jq.cookie('bp-' + objects[i] + '-scope') , 'div.' + objects[i],'', 1, jq.cookie('bp-' + objects[i] + '-extras') );
1532			}
1533		}
1534	});
1535}
1536
1537/* Filter the current content list (groups/members/blogs/topics) */
1538function bp_filter_request( object, filter, scope, target, search_terms, page, extras, caller ) {
1539	if ( 'activity' == object )
1540		return false;
1541
1542	if(typeof jq == 'undefined'){
1543		var jq = jQuery;
1544	}
1545	if ( jq.query.get('s') && !search_terms )
1546		search_terms = jq.query.get('s');
1547
1548	if ( null == scope )
1549		scope = 'all';
1550
1551	/* Save the settings we want to remain persistent to a cookie */
1552	jq.cookie( 'bp-' + object + '-scope', scope, {
1553		path: '/'
1554	} );
1555	jq.cookie( 'bp-' + object + '-filter', filter, {
1556		path: '/'
1557	} );
1558	jq.cookie( 'bp-' + object + '-extras', extras, {
1559		path: '/'
1560	} );
1561
1562	/* Set the correct selected nav and filter */
1563	jq('.item-list-tabs li').each( function() {
1564		jq(this).removeClass('selected');
1565	});
1566	jq('#' + object + '-' + scope + ', #object-nav li.current').addClass('selected');
1567	jq('.item-list-tabs li.selected').addClass('loading');
1568	jq('.item-list-tabs select option[value="' + filter + '"]').prop( 'selected', true );
1569
1570	if ( 'friends' == object )
1571		object = 'members';
1572
1573	if ( bp_ajax_request )
1574		bp_ajax_request.abort();
1575
1576	jq('.item-list').addClass('loading');
1577
1578	bp_ajax_request = jq.post( ajaxurl, {
1579		action: object + '_filter',
1580		'cookie': bp_get_cookies(),
1581		'object': object,
1582		'filter': filter,
1583		'search_terms': search_terms,
1584		'scope': scope,
1585		'page': page,
1586		'extras': extras
1587	},
1588	function(response)
1589	{	
1590		jq('.item-list').removeClass('loading');
1591		jq('.dir-search').removeClass('loading');	
1592		/* animate to top if called from bottom pagination */
1593		if ( caller == 'pag-bottom' && jq('#subnav').length ) {
1594			var top = jq('#subnav').parent();
1595			jq('html,body').animate({scrollTop: top.offset().top}, 'slow', function() {
1596				jq(target).fadeOut( 100, function() {
1597					var resp = jq(this).html(response);
1598					jq(this).fadeIn(100);
1599					jq('#buddypress').trigger('bp_filter_request');
1600					if(jq('#grid_view').hasClass('active')){ 
1601						jQuery(resp).find('.item-list').addClass('grid');
1602					}else{
1603						jQuery(resp).find('.item-list').removeClass('grid');
1604					}
1605			 	});
1606			});	
1607
1608		} else {
1609			jq(target).fadeOut( 100, function() {
1610				
1611				var resp = jq(this).html(response);
1612				jq(this).fadeIn(100);
1613				jq('#buddypress').trigger('bp_filter_request');
1614				if(jq('#grid_view').hasClass('active')){ 
1615					jQuery(resp).find('.item-list').addClass('grid');
1616				}else{
1617					jQuery(resp).find('.item-list').removeClass('grid');
1618				}
1619		 	});
1620		}
1621
1622		jq('.item-list-tabs li.selected').removeClass('loading');
1623	});
1624}
1625
1626/* Activity Loop Requesting */
1627function bp_activity_request(scope, filter) {
1628
1629	if(typeof jq == 'undefined'){
1630		var jq = jQuery;
1631	}
1632	/* Save the type and filter to a session cookie */
1633	jq.cookie( 'bp-activity-scope', scope, {
1634		path: '/'
1635	} );
1636	jq.cookie( 'bp-activity-filter', filter, {
1637		path: '/'
1638	} );
1639	jq.cookie( 'bp-activity-oldestpage', 1, {
1640		path: '/'
1641	} );
1642
1643	/* Remove selected and loading classes from tabs */
1644	jq('.item-list-tabs li').each( function() {
1645		jq(this).removeClass('selected loading');
1646	});
1647	/* Set the correct selected nav and filter */
1648	jq('#activity-' + scope + ', .item-list-tabs li.current').addClass('selected');
1649	jq('#object-nav.item-list-tabs li.selected, div.activity-type-tabs li.selected').addClass('loading');
1650	jq('#activity-filter-select select option[value="' + filter + '"]').prop( 'selected', true );
1651
1652	/* Reload the activity stream based on the selection */
1653	jq('.widget_bp_activity_widget h2 span.ajax-loader').show();
1654
1655	if ( bp_ajax_request )
1656		bp_ajax_request.abort();
1657
1658	bp_ajax_request = jq.post( ajaxurl, {
1659		action: 'activity_widget_filter',
1660		'cookie': bp_get_cookies(),
1661		'_wpnonce_activity_filter': jq("#_wpnonce_activity_filter").val(),
1662		'scope': scope,
1663		'filter': filter
1664	},
1665	function(response)
1666	{
1667		jq('.widget_bp_activity_widget h2 span.ajax-loader').hide();
1668
1669		jq('div.activity').fadeOut( 100, function() {
1670			jq(this).html(response.contents);
1671			jq(this).fadeIn(100);
1672
1673			/* Selectively hide comments */
1674			bp_legacy_theme_hide_comments();
1675		});
1676
1677		/* Update the feed link */
1678		if ( null != response.feed_url )
1679			jq('.directory #subnav li.feed a, .home-page #subnav li.feed a').attr('href', response.feed_url);
1680
1681		jq('.item-list-tabs li.selected').removeClass('loading');
1682
1683	}, 'json' );
1684}
1685
1686/* Hide long lists of activity comments, only show the latest five root comments. */
1687function bp_legacy_theme_hide_comments() {
1688
1689	if(typeof jq == 'undefined'){
1690		var jq = jQuery;
1691	}
1692
1693	var comments_divs = jq('div.activity-comments');
1694
1695	if ( !comments_divs.length )
1696		return false;
1697
1698	comments_divs.each( function() {
1699		if ( jq(this).children('ul').children('li').length < 5 ) return;
1700
1701		var comments_div = jq(this);
1702		var parent_li = comments_div.parents('#activity-stream > li');
1703		var comment_lis = jq(this).children('ul').children('li');
1704		var comment_count = ' ';
1705
1706		if ( jq('#' + parent_li.attr('id') + ' a.acomment-reply span').length )
1707			var comment_count = jq('#' + parent_li.attr('id') + ' a.acomment-reply span').html();
1708
1709		comment_lis.each( function(i) {
1710			/* Show the latest 5 root comments */
1711			if ( i < comment_lis.length - 5 ) {
1712				jq(this).addClass('hidden');
1713				jq(this).toggle();
1714
1715				if ( !i ) 
1716					jq(this).before( '<li class="show-all"><a href="#' + parent_li.attr('id') + '/show-all/" title="' + BP_DTheme.show_all_comments + '">' + BP_DTheme.show_x_comments.replace( '%d', comment_count ) + '</a></li>' );
1717			}
1718		});
1719
1720	});
1721}
1722
1723/* Helper Functions */
1724
1725function checkAll() {
1726	var checkboxes = document.getElementsByTagName("input");
1727	for(var i=0; i<checkboxes.length; i++) {
1728		if(checkboxes[i].type == "checkbox") {
1729			if($("check_all").checked == "") {
1730				checkboxes[i].checked = "";
1731			}
1732			else {
1733				checkboxes[i].checked = "checked";
1734			}
1735		}
1736	}
1737}
1738
1739function clear(container) {
1740	if( !document.getElementById(container) ) return;
1741
1742	var container = document.getElementById(container);
1743
1744	if ( radioButtons = container.getElementsByTagName('INPUT') ) {
1745		for(var i=0; i<radioButtons.length; i++) {
1746			radioButtons[i].checked = '';
1747		}
1748	}
1749
1750	if ( options = container.getElementsByTagName('OPTION') ) {
1751		for(var i=0; i<options.length; i++) {
1752			options[i].selected = false;
1753		}
1754	}
1755
1756	return;
1757}
1758
1759/* Returns a querystring of BP cookies (cookies beginning with 'bp-') */
1760function bp_get_cookies() {
1761	// get all cookies and split into an array
1762	var allCookies   = document.cookie.split(";");
1763
1764	var bpCookies    = {};
1765	var cookiePrefix = 'bp-';
1766
1767	if(typeof jq == 'undefined'){
1768		var jq = jQuery;
1769	}
1770
1771	// loop through cookies
1772	for (var i = 0; i < allCookies.length; i++) {
1773		var cookie    = allCookies[i];
1774		var delimiter = cookie.indexOf("=");
1775		var name      = jq.trim( unescape( cookie.slice(0, delimiter) ) );
1776		var value     = unescape( cookie.slice(delimiter + 1) );
1777
1778		// if BP cookie, store it
1779		if ( name.indexOf(cookiePrefix) == 0 ) {
1780			bpCookies[name] = value;
1781		}
1782	}
1783
1784	// returns BP cookies as querystring
1785	return encodeURIComponent( jq.param(bpCookies) );
1786}
1787
1788jQuery(document).ready( function() {
1789	jQuery('.footerwidget div#members-list-options a,.widget div#members-list-options a').on('click',
1790		function() {
1791			var link = this;
1792			jQuery(link).addClass('loading');
1793
1794			jQuery('.footerwidget div#members-list-options a,.widget div#members-list-options a').removeClass('selected');
1795			jQuery(this).addClass('selected');
1796
1797			jQuery.post( ajaxurl, {
1798				action: 'widget_members',
1799				'cookie': encodeURIComponent(document.cookie),
1800				'_wpnonce': jQuery('input#_wpnonce-members').val(),
1801				'max-members': jQuery('input#members_widget_max').val(),
1802				'filter': jQuery(this).attr('id')
1803			},
1804			function(response)
1805			{
1806				jQuery(link).removeClass('loading');
1807				footermember_wiget_response(response);
1808			});
1809
1810			return false;
1811		}
1812	);
1813});
1814
1815function footermember_wiget_response(response) {
1816	response = response.substr(0, response.length-1);
1817	response = response.split('[[SPLIT]]');
1818
1819	if ( response[0] !== '-1' ) {
1820		jQuery('.footerwidget ul#members-list,.widget ul#members-list').fadeOut(200,
1821			function() {
1822				jQuery('.footerwidget ul#members-list,.widget ul#members-list').html(response[1]);
1823				jQuery('.footerwidget ul#members-list,.widget ul#members-list').fadeIn(200);
1824			}
1825		);
1826
1827	} else {
1828		jQuery('.footerwidget ul#members-list').fadeOut(200,
1829			function() {
1830				var message = '<p>' + response[1] + '</p>';
1831				jQuery('.footerwidget ul#members-list,.widget ul#members-list').html(message);
1832				jQuery('.footerwidget ul#members-list,.widget ul#members-list').fadeIn(200);
1833			}
1834		);
1835	}
1836}
1837
1838jQuery(document).ready( function() {
1839	jQuery('.footerwidget div#groups-list-options a,.widget div#groups-list-options a').on('click',
1840		function() {
1841			var link = this;
1842			jQuery(link).addClass('loading');
1843
1844			jQuery('.footerwidget div#groups-list-options a,.widget div#groups-list-options a').removeClass('selected');
1845			jQuery(this).addClass('selected');
1846
1847			jQuery.post( ajaxurl, {
1848				action: 'widget_groups_list',
1849				'cookie': encodeURIComponent(document.cookie),
1850				'_wpnonce': jQuery('input#_wpnonce-groups').val(),
1851				'max_groups': jQuery('input#groups_widget_max').val(),
1852				'filter': jQuery(this).attr('id')
1853			},
1854			function(response)
1855			{
1856				jQuery(link).removeClass('loading');
1857				footergroups_wiget_response(response);
1858			});
1859
1860			return false;
1861		}
1862	);
1863});
1864
1865function footergroups_wiget_response(response) {
1866	response = response.substr(0, response.length-1);
1867	response = response.split('[[SPLIT]]');
1868
1869	if ( response[0] !== '-1' ) {
1870		jQuery('.footerwidget ul#groups-list,.widget ul#groups-list').fadeOut(200,
1871			function() {
1872				jQuery('.footerwidget ul#groups-list,.widget ul#groups-list').html(response[1]);
1873				jQuery('.footerwidget ul#groups-list,.widget ul#groups-list').fadeIn(200);
1874			}
1875		);
1876
1877	} else {
1878		jQuery('.footerwidget ul#groups-list,.widget ul#groups-list').fadeOut(200,
1879			function() {
1880				var message = '<p>' + response[1] + '</p>';
1881				jQuery('.footerwidget ul#groups-list,.widget ul#groups-list').html(message);
1882				jQuery('.footerwidget ul#groups-list,.widget ul#groups-list').fadeIn(200);
1883			}
1884		);
1885	}
1886}
1887
1888/*Woocommerce mini cart fix */
1889jQuery( document.body ).on( 'removed_from_cart',function(e, data){
1890	window.location.reload(true);
1891});
1892//})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.