<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[BuddyPress] [2473] trunk/bp-themes/bp-default/_inc/global.js:
  Moving request functions into the global scope.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>2473</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2010-01-29 10:43:01 +0000 (Fri, 29 Jan 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Moving request functions into the global scope. Fixes #1628</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpthemesbpdefault_incglobaljs">trunk/bp-themes/bp-default/_inc/global.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpthemesbpdefault_incglobaljs"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/_inc/global.js (2472 => 2473)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/_inc/global.js        2010-01-28 21:58:01 UTC (rev 2472)
+++ trunk/bp-themes/bp-default/_inc/global.js        2010-01-29 10:43:01 UTC (rev 2473)
</span><span class="lines">@@ -1,8 +1,7 @@
</span><span class="cx"> // AJAX Functions
</span><ins>+var j = jQuery;
</ins><span class="cx"> 
</span><del>-jQuery(document).ready( function() {
-        var j = jQuery;
-
</del><ins>+j(document).ready( function() {
</ins><span class="cx">         /**** Page Load Actions *******************************************************/
</span><span class="cx"> 
</span><span class="cx">         /* Activity */
</span><span class="lines">@@ -250,59 +249,6 @@
</span><span class="cx">                 }
</span><span class="cx">         });
</span><span class="cx"> 
</span><del>-        /* Activity Loop Requesting */
-        function bp_activity_request(scope, filter) {
-                if ( null == scope )
-                        var scope = 'all';
-
-                if ( null == filter )
-                        var filter = '-1';
-
-                /* Save the type and filter to a session cookie */
-                j.cookie( 'bp-activity-scope', scope, null );
-                j.cookie( 'bp-activity-filter', filter, null );
-                j.cookie( 'bp-activity-oldestpage', 1 );
-
-                /* Set the correct selected nav and filter */
-                j('div.item-list-tabs li').each( function() {
-                        j(this).removeClass('selected');
-                });
-                j('li#activity-' + scope + ', div.item-list-tabs li.current').addClass('selected');
-                j('div.item-list-tabs li.selected').addClass('loading');
-                j('#activity-filter-select select option[value=' + filter + ']').attr( 'selected', 'selected' );
-
-                /* Reload the activity stream based on the selection */
-                j('.widget_bp_activity_widget h2 span.ajax-loader').show();
-
-                j.post( ajaxurl, {
-                        action: 'activity_widget_filter',
-                        'cookie': encodeURIComponent(document.cookie),
-                        '_wpnonce_activity_filter': j(&quot;input#_wpnonce_activity_filter&quot;).val(),
-                        'scope': scope,
-                        'filter': filter
-                },
-                function(response)
-                {
-                        j('.widget_bp_activity_widget h2 span.ajax-loader').hide();
-                        j.cookie( 'bp-activity-querystring', response.query_string );
-
-                        j('div.activity').fadeOut( 100, function() {
-                                j(this).html(response.contents);
-                                j(this).fadeIn(100);
-                        });
-
-                        /* Update the feed link */
-                        if ( null != response.feed_url )
-                                j('.directory div#subnav li.feed a, .home-page div#subnav li.feed a').attr('href', response.feed_url);
-
-                        j('div.item-list-tabs li.selected').removeClass('loading');
-
-                        /* Selectively hide comments */
-                        bp_dtheme_hide_comments();
-
-                }, 'json' );
-        }
-
</del><span class="cx">         /**** Activity Comments *******************************************************/
</span><span class="cx"> 
</span><span class="cx">         /* Hide all activity comment forms */
</span><span class="lines">@@ -499,38 +445,6 @@
</span><span class="cx">                 }
</span><span class="cx">         });
</span><span class="cx"> 
</span><del>-        /* Hide long lists of activity comments, only show the latest five root comments. */
-        function bp_dtheme_hide_comments() {
-                var comments_divs = j('div.activity-comments');
-
-                if ( !comments_divs.length )
-                        return false;
-
-                comments_divs.each( function() {
-                        if ( j(this).children('ul').children('li').length &lt; 5 ) return;
-
-                        var comments_div = j(this);
-                        var parent_li = comments_div.parents('ul#activity-stream &gt; li');
-                        var comment_lis = j(this).children('ul').children('li');
-                        var comment_count = ' ';
-
-                        if ( j('li#' + parent_li.attr('id') + ' a.acomment-reply span').length )
-                                var comment_count = j('li#' + parent_li.attr('id') + ' a.acomment-reply span').html();
-
-                        comment_lis.each( function(i) {
-                                /* Show the latest 5 root comments */
-                                if ( i &lt; comment_lis.length - 5 ) {
-                                        j(this).addClass('hidden');
-                                        j(this).toggle();
-
-                                        if ( !i )
-                                                j(this).before( '&lt;li class=&quot;show-all&quot;&gt;&lt;a href=&quot;#' + parent_li.attr('id') + '/show-all/&quot; title=&quot;' + bp_terms_show_all_comments + '&quot;&gt;' + bp_terms_show_all + ' ' + comment_count + ' ' + bp_terms_comments + '&lt;/a&gt;&lt;/li&gt;' );
-                                }
-                        });
-
-                });
-        }
-
</del><span class="cx">         /**** Directory Search ****************************************************/
</span><span class="cx"> 
</span><span class="cx">         /* The search form on all directory pages */
</span><span class="lines">@@ -597,66 +511,6 @@
</span><span class="cx">                 return false;
</span><span class="cx">         });
</span><span class="cx"> 
</span><del>-        /* Filter the current content list (groups/members/blogs/topics) */
-        function bp_filter_request( object, filter, scope, target, search_terms, page, extras ) {
-                if ( 'activity' == object )
-                        return false;
-
-                if ( null == scope )
-                        var scope = 'all';
-
-                if ( null == filter )
-                        var filter = 'active';
-
-                if ( null == page )
-                        var page = 1;
-
-                if ( null == search_terms )
-                        var search_terms = false;
-
-                if ( null == extras )
-                        var extras = false;
-
-                if ( j.query.get('s') )
-                        search_terms = j.query.get('s');
-
-                /* Save the type and filter to a session cookie */
-                j.cookie( 'bp-' + object + '-scope', scope, null );
-                j.cookie( 'bp-' + object + '-filter', filter, null );
-                j.cookie( 'bp-' + object + '-page', page, null );
-                j.cookie( 'bp-' + object + '-search-terms', search_terms, null );
-
-                /* Set the correct selected nav and filter */
-                j('div.item-list-tabs li').each( function() {
-                        j(this).removeClass('selected');
-                });
-                j('div.item-list-tabs li#' + object + '-' + scope + ', div.item-list-tabs#object-nav li.current').addClass('selected');
-                j('div.item-list-tabs li.selected').addClass('loading');
-                j('div.item-list-tabs select option[value=' + filter + ']').attr( 'selected', 'selected' );
-
-                if ( 'friends' == object )
-                        object = 'members';
-
-                j.post( ajaxurl, {
-                        action: object + '_filter',
-                        'cookie': encodeURIComponent(document.cookie),
-                        'object': object,
-                        'filter': filter,
-                        'search_terms': search_terms,
-                        'scope': scope,
-                        'page': page,
-                        'extras': extras
-                },
-                function(response)
-                {
-                        j(target).fadeOut( 100, function() {
-                                j(this).html(response);
-                                j(this).fadeIn(100);
-                         });
-                        j('div.item-list-tabs li.selected').removeClass('loading');
-                });
-        }
-
</del><span class="cx">         /* All pagination links run through this function */
</span><span class="cx">         j('div#content').click( function(event) {
</span><span class="cx">                 var target = j(event.target);
</span><span class="lines">@@ -1100,8 +954,153 @@
</span><span class="cx">         });
</span><span class="cx"> });
</span><span class="cx"> 
</span><del>-// Helper JS Functions
</del><ins>+/* Filter the current content list (groups/members/blogs/topics) */
+function bp_filter_request( object, filter, scope, target, search_terms, page, extras ) {
+        if ( 'activity' == object )
+                return false;
</ins><span class="cx"> 
</span><ins>+        if ( null == scope )
+                var scope = 'all';
+
+        if ( null == filter )
+                var filter = 'active';
+
+        if ( null == page )
+                var page = 1;
+
+        if ( null == search_terms )
+                var search_terms = false;
+
+        if ( null == extras )
+                var extras = false;
+
+        if ( j.query.get('s') )
+                search_terms = j.query.get('s');
+
+        /* Save the type and filter to a session cookie */
+        j.cookie( 'bp-' + object + '-scope', scope, null );
+        j.cookie( 'bp-' + object + '-filter', filter, null );
+        j.cookie( 'bp-' + object + '-page', page, null );
+        j.cookie( 'bp-' + object + '-search-terms', search_terms, null );
+
+        /* Set the correct selected nav and filter */
+        j('div.item-list-tabs li').each( function() {
+                j(this).removeClass('selected');
+        });
+        j('div.item-list-tabs li#' + object + '-' + scope + ', div.item-list-tabs#object-nav li.current').addClass('selected');
+        j('div.item-list-tabs li.selected').addClass('loading');
+        j('div.item-list-tabs select option[value=' + filter + ']').attr( 'selected', 'selected' );
+
+        if ( 'friends' == object )
+                object = 'members';
+
+        j.post( ajaxurl, {
+                action: object + '_filter',
+                'cookie': encodeURIComponent(document.cookie),
+                'object': object,
+                'filter': filter,
+                'search_terms': search_terms,
+                'scope': scope,
+                'page': page,
+                'extras': extras
+        },
+        function(response)
+        {
+                j(target).fadeOut( 100, function() {
+                        j(this).html(response);
+                        j(this).fadeIn(100);
+                 });
+                j('div.item-list-tabs li.selected').removeClass('loading');
+        });
+}
+
+/* Activity Loop Requesting */
+function bp_activity_request(scope, filter) {
+        if ( null == scope )
+                var scope = 'all';
+
+        if ( null == filter )
+                var filter = '-1';
+
+        /* Save the type and filter to a session cookie */
+        j.cookie( 'bp-activity-scope', scope, null );
+        j.cookie( 'bp-activity-filter', filter, null );
+        j.cookie( 'bp-activity-oldestpage', 1 );
+
+        /* Set the correct selected nav and filter */
+        j('div.item-list-tabs li').each( function() {
+                j(this).removeClass('selected');
+        });
+        j('li#activity-' + scope + ', div.item-list-tabs li.current').addClass('selected');
+        j('div.item-list-tabs li.selected').addClass('loading');
+        j('#activity-filter-select select option[value=' + filter + ']').attr( 'selected', 'selected' );
+
+        /* Reload the activity stream based on the selection */
+        j('.widget_bp_activity_widget h2 span.ajax-loader').show();
+
+        j.post( ajaxurl, {
+                action: 'activity_widget_filter',
+                'cookie': encodeURIComponent(document.cookie),
+                '_wpnonce_activity_filter': j(&quot;input#_wpnonce_activity_filter&quot;).val(),
+                'scope': scope,
+                'filter': filter
+        },
+        function(response)
+        {
+                j('.widget_bp_activity_widget h2 span.ajax-loader').hide();
+                j.cookie( 'bp-activity-querystring', response.query_string );
+
+                j('div.activity').fadeOut( 100, function() {
+                        j(this).html(response.contents);
+                        j(this).fadeIn(100);
+                });
+
+                /* Update the feed link */
+                if ( null != response.feed_url )
+                        j('.directory div#subnav li.feed a, .home-page div#subnav li.feed a').attr('href', response.feed_url);
+
+                j('div.item-list-tabs li.selected').removeClass('loading');
+
+                /* Selectively hide comments */
+                bp_dtheme_hide_comments();
+
+        }, 'json' );
+}
+
+/* Hide long lists of activity comments, only show the latest five root comments. */
+function bp_dtheme_hide_comments() {
+        var comments_divs = j('div.activity-comments');
+
+        if ( !comments_divs.length )
+                return false;
+
+        comments_divs.each( function() {
+                if ( j(this).children('ul').children('li').length &lt; 5 ) return;
+
+                var comments_div = j(this);
+                var parent_li = comments_div.parents('ul#activity-stream &gt; li');
+                var comment_lis = j(this).children('ul').children('li');
+                var comment_count = ' ';
+
+                if ( j('li#' + parent_li.attr('id') + ' a.acomment-reply span').length )
+                        var comment_count = j('li#' + parent_li.attr('id') + ' a.acomment-reply span').html();
+
+                comment_lis.each( function(i) {
+                        /* Show the latest 5 root comments */
+                        if ( i &lt; comment_lis.length - 5 ) {
+                                j(this).addClass('hidden');
+                                j(this).toggle();
+
+                                if ( !i )
+                                        j(this).before( '&lt;li class=&quot;show-all&quot;&gt;&lt;a href=&quot;#' + parent_li.attr('id') + '/show-all/&quot; title=&quot;' + bp_terms_show_all_comments + '&quot;&gt;' + bp_terms_show_all + ' ' + comment_count + ' ' + bp_terms_comments + '&lt;/a&gt;&lt;/li&gt;' );
+                        }
+                });
+
+        });
+}
+
+/* Helper Functions */
+
</ins><span class="cx"> function checkAll() {
</span><span class="cx">         var checkboxes = document.getElementsByTagName(&quot;input&quot;);
</span><span class="cx">         for(var i=0; i&lt;checkboxes.length; i++) {
</span></span></pre>
</div>
</div>

</body>
</html>