Changeset 2281
- Timestamp:
- 01/09/2010 11:13:31 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 5 edited
-
bp-activity/bp-activity-widgets.php (deleted)
-
bp-activity/js (deleted)
-
bp-core/bp-core-cssjs.php (modified) (1 diff)
-
bp-core/js/admin-bar.js (modified) (1 diff)
-
bp-themes/bp-default/_inc/global.js (modified) (1 diff)
-
bp-themes/bp-sn-parent/_inc/js/ajax.js (modified) (1 diff)
-
bp-themes/bp-sn-parent/functions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-cssjs.php
r2227 r2281 24 24 } 25 25 add_action( 'init', 'bp_core_add_admin_bar_css' ); 26 27 /**28 * bp_core_add_admin_bar_js()29 *30 * Add the minor JS needed for the admin bar.31 *32 * @package BuddyPress Core33 * @uses get_option() Selects a site setting from the DB.34 */35 function bp_core_add_admin_bar_js() {36 wp_enqueue_script( 'bp-admin-bar-js', BP_PLUGIN_URL . '/bp-core/js/admin-bar.js', array( 'jquery' ) );37 }38 add_action( 'init', 'bp_core_add_admin_bar_js' );39 26 40 27 /** -
trunk/bp-core/js/admin-bar.js
r2128 r2281 1 jQuery(document).ready( function() {2 jQuery("#wp-admin-bar ul.main-nav li").mouseover( function() {3 jQuery(this).addClass('sfhover');4 });5 6 jQuery("#wp-admin-bar ul.main-nav li").mouseout( function() {7 jQuery(this).removeClass('sfhover');8 });9 }); -
trunk/bp-themes/bp-default/_inc/global.js
r2276 r2281 942 942 ); 943 943 944 /* Admin Bar Javascript */ 945 j("#wp-admin-bar ul.main-nav li").mouseover( function() { 946 j(this).addClass('sfhover'); 947 }); 948 949 j("#wp-admin-bar ul.main-nav li").mouseout( function() { 950 j(this).removeClass('sfhover'); 951 }); 944 952 }); 945 953 -
trunk/bp-themes/bp-sn-parent/_inc/js/ajax.js
r2150 r2281 1308 1308 ); 1309 1309 1310 if ( j('div.widget_bp_activity_widget').length ) 1311 bp_activity_widget_post( j.cookie('bp_atype'), j.cookie('bp_afilter') ); 1312 1313 /* New posts */ 1314 j("input#aw-whats-new-submit").click( function() { 1315 var button = j(this); 1316 var form = button.parent().parent().parent().parent(); 1317 1318 form.children().each( function() { 1319 if ( j.nodeName(this, "textarea") || j.nodeName(this, "input") ) 1320 j(this).attr( 'disabled', 'disabled' ); 1321 }); 1322 1323 j( 'form#' + form.attr('id') + ' span.ajax-loader' ).show(); 1324 1325 /* Remove any errors */ 1326 j('div.error').remove(); 1327 button.attr('disabled','disabled'); 1328 1329 j.post( ajaxurl, { 1330 action: 'post_update', 1331 'cookie': encodeURIComponent(document.cookie), 1332 '_wpnonce_post_update': j("input#_wpnonce_post_update").val(), 1333 'content': j("textarea#whats-new").val(), 1334 'group': j("#whats-new-post-in").val() 1335 }, 1336 function(response) 1337 { 1338 j( 'form#' + form.attr('id') + ' span.ajax-loader' ).hide(); 1339 1340 form.children().each( function() { 1341 if ( j.nodeName(this, "textarea") || j.nodeName(this, "input") ) 1342 j(this).attr( 'disabled', '' ); 1343 }); 1344 1345 /* Check for errors and append if found. */ 1346 if ( response[0] + response[1] == '-1' ) { 1347 form.prepend( response.substr( 2, response.length ) ); 1348 j( 'form#' + form.attr('id') + ' div.error').hide().fadeIn( 200 ); 1349 button.attr("disabled", ''); 1350 } else { 1351 if ( 0 == j("ul.activity-list").length ) { 1352 j("div.error").slideUp(100).remove(); 1353 j("div.activity").append( '<ul id="site-wide-stream" class="activity-list item-list">' ); 1354 } 1355 1356 j("ul.activity-list").prepend(response); 1357 j("li.new-update").hide().slideDown( 300 ); 1358 j("li.new-update").removeClass( 'new-update' ); 1359 j("textarea#whats-new").val(''); 1360 1361 /* Re-enable the submit button after 8 seconds. */ 1362 setTimeout( function() { button.attr("disabled", ''); }, 8000 ); 1363 } 1364 }); 1365 1366 return false; 1367 }); 1368 1369 /* List tabs event delegation */ 1370 j('div.item-list-tabs').click( function(event) { 1371 var target = j(event.target).parent(); 1372 1373 /* Activity Stream Tabs */ 1374 if ( target.attr('id') == 'activity-all' || 1375 target.attr('id') == 'activity-friends' || 1376 target.attr('id') == 'activity-groups' ) { 1377 1378 var type = target.attr('id').substr( 9, target.attr('id').length ); 1379 var filter = j("#activity-filter-select select").val(); 1380 1381 bp_activity_widget_post(type, filter); 1382 1383 return false; 1384 } 1385 }); 1386 1387 j('#activity-filter-select select').change( function() { 1388 var selected_tab = j( '.' + j(this).parent().parent().parent().attr('class') + ' li.selected'); 1389 var type = selected_tab.attr('id').substr( 9, selected_tab.attr('id').length ); 1390 var filter = j(this).val(); 1391 1392 bp_activity_widget_post(type, filter); 1393 1394 return false; 1395 }); 1396 1397 /* Stream event delegation */ 1398 j('div.widget_bp_activity_widget').click( function(event) { 1399 var target = j(event.target).parent(); 1400 1401 /* Load more updates at the end of the page */ 1402 if ( target.attr('class') == 'load-more' ) { 1403 j("li.load-more span.ajax-loader").show(); 1404 1405 var oldest_page = ( j("input#aw-oldestpage").val() * 1 ) + 1; 1406 1407 j.post( ajaxurl, { 1408 action: 'aw_get_older_updates', 1409 'cookie': encodeURIComponent(document.cookie), 1410 'query_string': j("input#aw-querystring").val(), 1411 'acpage': oldest_page 1412 }, 1413 function(response) 1414 { 1415 j("li.load-more span.ajax-loader").hide(); 1416 1417 /* Check for errors and append if found. */ 1418 if ( response[0] + response[1] != '-1' ) { 1419 var response = response.split('||'); 1420 j("input#aw-querystring").val(response[0]); 1421 1422 j("ul.activity-list").append(response[1]); 1423 j("input#aw-oldestpage").val( oldest_page ); 1424 } 1425 1426 target.hide(); 1427 }); 1428 1429 return false; 1430 } 1431 }); 1432 1433 function bp_activity_widget_post(type, filter) { 1434 if ( null == type ) 1435 var type = 'all'; 1436 1437 if ( null == filter ) 1438 var filter = '-1'; 1439 1440 /* Save the type and filter to a session cookie */ 1441 j.cookie( 'bp_atype', type, null ); 1442 j.cookie( 'bp_afilter', filter, null ); 1443 1444 /* Set the correct selected nav and filter */ 1445 j('.widget_bp_activity_widget div.item-list-tabs li').each( function() { 1446 j(this).removeClass('selected'); 1447 }); 1448 j('li#activity-' + type).addClass('selected'); 1449 j('#activity-filter-select select option[value=' + filter + ']').attr( 'selected', 'selected' ); 1450 1451 /* Reload the activity stream based on the selection */ 1452 j('.widget_bp_activity_widget h2 span.ajax-loader').show(); 1453 1454 j.post( ajaxurl, { 1455 action: 'activity_widget_filter', 1456 'cookie': encodeURIComponent(document.cookie), 1457 '_wpnonce_activity_filter': j("input#_wpnonce_activity_filter").val(), 1458 'type': type, 1459 'filter': filter 1460 }, 1461 function(response) 1462 { 1463 j('.widget_bp_activity_widget h2 span.ajax-loader').hide(); 1464 1465 /* Check for errors and append if found. */ 1466 if ( response[0] + response[1] == '-1' ) { 1467 j('div.activity').fadeOut( 100, function() { 1468 j(this).html( response.substr( 2, response.length ) ).hide().fadeIn( 200 ); 1469 j(this).fadeIn(100); 1470 }); 1471 } else { 1472 var response = response.split('||'); 1473 j("input#aw-querystring").val(response[0]); 1474 1475 j('div.activity').fadeOut( 100, function() { 1476 j(this).html(response[1]); 1477 j(this).fadeIn(100); 1478 }); 1479 } 1480 }); 1481 } 1482 1483 /* Admin Bar Javascript */ 1484 j("#wp-admin-bar ul.main-nav li").mouseover( function() { 1485 j(this).addClass('sfhover'); 1486 }); 1487 1488 j("#wp-admin-bar ul.main-nav li").mouseout( function() { 1489 j(this).removeClass('sfhover'); 1490 }); 1491 1492 /* jQuery Cookie plugin */ 1493 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}('o.5=B(9,b,2){6(h b!=\'E\'){2=2||{};6(b===n){b=\'\';2.3=-1}4 3=\'\';6(2.3&&(h 2.3==\'j\'||2.3.k)){4 7;6(h 2.3==\'j\'){7=w u();7.t(7.q()+(2.3*r*l*l*x))}m{7=2.3}3=\'; 3=\'+7.k()}4 8=2.8?\'; 8=\'+(2.8):\'\';4 a=2.a?\'; a=\'+(2.a):\'\';4 c=2.c?\'; c\':\'\';d.5=[9,\'=\',C(b),3,8,a,c].y(\'\')}m{4 e=n;6(d.5&&d.5!=\'\'){4 g=d.5.A(\';\');s(4 i=0;i<g.f;i++){4 5=o.z(g[i]);6(5.p(0,9.f+1)==(9+\'=\')){e=D(5.p(9.f+1));v}}}F e}};',42,42,'||options|expires|var|cookie|if|date|path|name|domain|value|secure|document|cookieValue|length|cookies|typeof||number|toUTCString|60|else|null|jQuery|substring|getTime|24|for|setTime|Date|break|new|1000|join|trim|split|function|encodeURIComponent|decodeURIComponent|undefined|return'.split('|'),0,{})) 1494 1310 1495 /* ScrollTo plugin - just inline and minified */ 1311 1496 ;(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); -
trunk/bp-themes/bp-sn-parent/functions.php
r2126 r2281 82 82 } 83 83 84 /* Activity Widget */ 85 86 class BP_Activity_Widget extends WP_Widget { 87 function bp_activity_widget() { 88 parent::WP_Widget( false, $name = __( 'Site Wide Activity', 'buddypress' ) ); 89 90 if ( is_active_widget( false, false, $this->id_base ) ) 91 wp_enqueue_script( 'activity_widget_js', BP_PLUGIN_URL . '/bp-activity/js/widget-activity.js' ); 92 } 93 94 function widget($args, $instance) { 95 global $bp; 96 97 extract( $args ); 98 99 echo $before_widget; 100 echo $before_title 101 . $widget_name . 102 ' <span class="ajax-loader"></span> 103 <a class="rss-image" href="' . bp_get_sitewide_activity_feed_link() . '" title="' . __( 'Site Wide Activity RSS Feed', 'buddypress' ) . '">' . __( '[RSS]', 'buddypress' ) . '</a>' 104 . $after_title; ?> 105 106 <?php if ( is_user_logged_in() ) : ?> 107 <form action="" method="post" id="whats-new-form" name="whats-new-form"> 108 <div id="whats-new-avatar"> 109 <?php bp_loggedin_user_avatar('width=40&height=40') ?> 110 <span class="loading"></span> 111 </div> 112 113 <h5> 114 <?php 115 $fullname = (array)explode( ' ', $bp->loggedin_user->fullname ); 116 printf( __( "What's new %s?", 'buddypress' ), $fullname[0] ) 117 ?> 118 </h5> 119 120 <div id="whats-new-content"> 121 <div id="whats-new-textarea"> 122 <textarea name="whats-new" id="whats-new" value="" /></textarea> 123 </div> 124 125 <div id="whats-new-options"> 126 <div id="whats-new-submit"> 127 <span class="ajax-loader"></span> 128 <input type="submit" name="aw-whats-new-submit" id="aw-whats-new-submit" value="<?php _e( 'Post Update', 'callisto' ) ?>" /> 129 </div> 130 131 <div id="whats-new-post-in-box"> 132 <?php _e( 'Post in', 'callisto' ) ?>: 133 134 <select id="whats-new-post-in" name="whats-new-post-in"> 135 <option selected="selected" value="0"><?php _e( 'My Profile', 'buddypress' ) ?></option> 136 <?php if ( bp_has_groups( 'user_id=' . bp_loggedin_user_id() . '&type=alphabetical&max=100&per_page=100' ) ) : while ( bp_groups() ) : bp_the_group(); ?> 137 <option value="<?php bp_group_id() ?>"><?php bp_group_name() ?></option> 138 <?php endwhile; endif; ?> 139 </select> 140 </div> 141 </div> 142 143 <div class="clear"></div> 144 145 </div> 146 147 <?php wp_nonce_field( 'post_update', '_wpnonce_post_update' ); ?> 148 </form> 149 <?php endif; ?> 150 151 <div class="item-list-tabs"> 152 <ul> 153 <li class="selected" id="activity-all"><a href="<?php bp_root_domain() ?>"><?php _e( 'All Members', 'buddypress' ) ?></a></li> 154 155 <?php if ( is_user_logged_in() ) : ?> 156 <li id="activity-friends"><a href="<?php echo bp_loggedin_user_domain() . BP_ACTIVITY_SLUG . '/my-friends/' ?>"><?php _e( 'My Friends', 'buddypress') ?></a></li> 157 <li id="activity-groups"><a href="<?php echo bp_loggedin_user_domain() . BP_ACTIVITY_SLUG . '/my-groups/' ?>"><?php _e( 'My Groups', 'buddypress') ?></a></li> 158 <?php endif; ?> 159 160 <?php do_action( 'bp_activity_types' ) ?> 161 162 <li id="activity-filter-select"> 163 <select> 164 <option value="-1"><?php _e( 'No Filter', 'buddypress' ) ?></option> 165 <option value="new_wire_post"><?php _e( 'Updates Only', 'buddypress' ) ?></option> 166 <option value="new_forum_post,new_forum_topic"><?php _e( 'Group Forum Activity Only', 'buddypress' ) ?></option> 167 <option value="new_blog_post,new_blog_comment"><?php _e( 'Blog Activity Only', 'buddypress' ) ?></option> 168 169 <?php do_action( 'bp_activity_filter_options' ) ?> 170 </select> 171 </li> 172 </ul> 173 </div> 174 175 <div class="activity"> 176 <?php // The loop will be loaded here via AJAX on page load to retain settings. ?> 177 </div> 178 179 <form action="" name="activity-widget-form" id="activity-widget-form" method="post"> 180 <?php wp_nonce_field( 'activity_filter', '_wpnonce_activity_filter' ) ?> 181 <input type="hidden" id="aw-querystring" name="aw-querystring" value="" /> 182 <input type="hidden" id="aw-oldestpage" name="aw-oldestpage" value="1" /> 183 </div> 184 185 <?php echo $after_widget; ?> 186 <?php 187 } 188 189 function update( $new_instance, $old_instance ) { 190 $instance = $old_instance; 191 $instance['max_items'] = strip_tags( $new_instance['max_items'] ); 192 $instance['per_page'] = strip_tags( $new_instance['per_page'] ); 193 194 return $instance; 195 } 196 197 function form( $instance ) { 198 $instance = wp_parse_args( (array) $instance, array( 'max_items' => 200, 'per_page' => 25 ) ); 199 $per_page = strip_tags( $instance['per_page'] ); 200 $max_items = strip_tags( $instance['max_items'] ); 201 ?> 202 203 <p><label for="bp-activity-widget-sitewide-per-page"><?php _e('Number of Items Per Page:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'per_page' ); ?>" name="<?php echo $this->get_field_name( 'per_page' ); ?>" type="text" value="<?php echo attribute_escape( $per_page ); ?>" style="width: 30%" /></label></p> 204 <p><label for="bp-core-widget-members-max"><?php _e('Max items to show:', 'buddypress'); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'max_items' ); ?>" name="<?php echo $this->get_field_name( 'max_items' ); ?>" type="text" value="<?php echo attribute_escape( $max_items ); ?>" style="width: 30%" /></label></p> 205 <?php 206 } 207 } 208 register_widget( "BP_Activity_Widget" ); 209 210 function bp_activity_widget_loop( $type = 'all', $filter = false, $query_string = false, $per_page = 20 ) { 211 global $bp; 212 213 if ( !$query_string ) { 214 /* Set a valid type */ 215 if ( !$type || ( 'all' != $type && 'friends' != $type && 'groups' != $type ) ) 216 $type = 'all'; 217 218 if ( ( 'friends' == $type || 'groups' == $type ) && !is_user_logged_in() ) 219 $type = 'all'; 220 221 switch( $type ) { 222 case 'friends': 223 $friend_ids = implode( ',', friends_get_friend_user_ids( $bp->loggedin_user->id ) ); 224 $query_string = 'user_id=' . $friend_ids; 225 break; 226 case 'groups': 227 $groups = groups_get_user_groups( $bp->loggedin_user->id ); 228 $group_ids = implode( ',', $groups['groups'] ); 229 $query_string = 'object=groups&primary_id=' . $group_ids; 230 break; 231 } 232 233 /* Build the filter */ 234 if ( $filter && $filter != '-1' ) 235 $query_string .= '&action=' . $filter; 236 237 /* Add the per_page param */ 238 $query_string .= '&per_page=' . $per_page; 239 } 240 241 if ( bp_has_activities( $query_string . '&display_comments=threaded' ) ) : ?> 242 <?php echo $query_string . '&display_comments=threaded||'; // Pass the qs back to the JS. ?> 243 244 <?php if ( !$_POST['acpage'] || 1 == $_POST['acpage'] ) : ?> 245 <ul id="site-wide-stream" class="activity-list item-list"> 246 <?php endif; ?> 247 248 <?php while ( bp_activities() ) : bp_the_activity(); ?> 249 <li class="<?php bp_activity_css_class() ?>" id="activity-<?php bp_activity_id() ?>"> 250 <div class="activity-avatar"> 251 <?php bp_activity_avatar('type=full&width=40&height=40') ?> 252 </div> 253 254 <div class="activity-content"> 255 <?php bp_activity_content() ?> 256 257 <?php if ( is_user_logged_in() ) : ?> 258 <div class="activity-meta"> 259 <a href="#acomment-<?php bp_activity_id() ?>" class="acomment-reply" id="acomment-comment-<?php bp_activity_id() ?>"><?php _e( 'Comment', 'buddypress' ) ?> (<?php bp_activity_comment_count() ?>)</a> 260 </div> 261 <?php endif; ?> 262 </div> 263 264 <div class="activity-comments"> 265 <?php bp_activity_comments() ?> 266 267 <?php if ( is_user_logged_in() ) : ?> 268 <form action="" method="post" name="activity-comment-form" id="ac-form-<?php bp_activity_id() ?>" class="ac-form"> 269 <div class="ac-reply-avatar"><?php bp_loggedin_user_avatar( 'width=25&height=25' ) ?></div> 270 <div class="ac-reply-content"> 271 <div class="ac-textarea"> 272 <textarea id="ac-input-<?php bp_activity_id() ?>" class="ac-input" name="ac-input-<?php bp_activity_id() ?>"></textarea> 273 </div> 274 <input type="submit" name="ac-form-submit" value="<?php _e( 'Post', 'buddypress' ) ?> →" /> 275 </div> 276 <?php wp_nonce_field( 'new_activity_comment', '_wpnonce_new_activity_comment' ) ?> 277 </form> 278 <?php endif; ?> 279 </div> 280 281 </li> 282 <?php endwhile; ?> 283 <li class="load-more"> 284 <a href="#more"><?php _e( 'Load More', 'buddypress' ) ?></a> <span class="ajax-loader"></span> 285 </li> 286 287 <?php if ( !$_POST['acpage'] || 1 == $_POST['acpage'] ) : ?> 288 </ul> 289 <?php endif; ?> 290 291 <?php else: ?> 292 <?php echo "-1<div id='message' class='info'><p>" . __( 'No activity found', 'buddypress' ) . '</p></div>'; ?> 293 <?php endif; 294 } 295 296 /* The ajax function to reload the activity widget. In here because this is a self contained widget. */ 297 function bp_activity_ajax_widget_filter() { 298 bp_activity_widget_loop( $_POST['type'], $_POST['filter'] ); 299 } 300 add_action( 'wp_ajax_activity_widget_filter', 'bp_activity_ajax_widget_filter' ); 301 302 /* The ajax function to load older updates at the end of the list */ 303 function bp_activity_ajax_load_older_updates() { 304 bp_activity_widget_loop( false, false, $_POST['query_string'] ); 305 } 306 add_action( 'wp_ajax_aw_get_older_updates', 'bp_activity_ajax_load_older_updates' ); 307 84 308 ?>
Note: See TracChangeset
for help on using the changeset viewer.