Ticket #5148: 5148.2.patch
File 5148.2.patch, 4.2 KB (added by , 11 years ago) |
---|
-
bp-notifications/bp-notifications-template.php
241 241 $this->search_terms = $r['search_terms']; 242 242 $this->page_arg = $r['page_arg']; 243 243 $this->order_by = $r['order_by']; 244 $this->sort_order = $r['sort_order'];244 $this->sort_order = in_array( $_GET['sort_order'], array( 'ASC', 'DESC' ) ) ? $_GET['sort_order'] :$r['sort_order']; 245 245 246 246 // Get the notifications 247 247 $notifications = BP_Notifications_Notification::get_current_notifications_for_user( array( … … 272 272 } else { 273 273 $this->notification_count = count( $this->notifications ); 274 274 } 275 276 //we have notifications, so we enqueue the sort behavior handling JS 277 wp_enqueue_script( 'bp-notifications-behavior', BP_PLUGIN_URL . '/bp-notifications/js/bp-notifications-behavior.js', array('jquery'), '0.1', TRUE ); 275 278 } 276 279 277 280 if ( (int) $this->total_notification_count && (int) $this->pag_num ) { … … 287 290 } 288 291 } 289 292 293 public function enqueue_scripts() { 294 //wp_enqueue_script( 'bp-notifications-behavior', __DIR__ . '/js/bp-notifications-behavior.js', array('jquery'), '0.1', TRUE ); 295 } 296 290 297 /** 291 298 * Whether there are notifications available in the loop. 292 299 * -
bp-notifications/js/bp-notifications-behavior.js
1 (function( $ ) { 2 $.fn.reverse = [].reverse; 3 4 function reverse_sort() { 5 if( is_paginated() ) { 6 var sort_order = new_sort_order( get_query_vars() ); 7 document.location.href = document.location.origin + document.location.pathname + '?sort_order=' + sort_order; 8 } 9 10 var $notification_tbody = $('table.notifications tbody'); 11 $notification_tbody.html($notification_tbody.find('tr').reverse()); 12 } 13 14 function new_sort_order(qv) { 15 return !qv['sort_order'] || 'DESC' == qv['sort_order'] ? 'ASC' : 'DESC'; 16 } 17 18 function get_current_page() { 19 var qv = get_query_vars(); 20 return !qv['npage'] ? 1 : parseInt( qv['npage'] ); 21 } 22 23 function is_paginated() { 24 return !!$('.pagination-links .page-numbers').length; 25 } 26 27 function get_query_vars() { 28 var vars = [], hash; 29 var q = document.URL.split('?')[1]; 30 if(q != undefined){ 31 q = q.split('&'); 32 for(var i = 0; i < q.length; i++){ 33 hash = q[i].split('='); 34 vars.push(hash[1]); 35 vars[hash[0]] = hash[1]; 36 } 37 } 38 return vars; 39 } 40 41 $('#members-friends').on('change', reverse_sort); 42 }(jQuery)); 43 No newline at end of file -
bp-templates/bp-legacy/buddypress/members/single/notifications/notifications-loop.php
Property changes on: bp-notifications/js/bp-notifications-behavior.js ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property
21 21 22 22 <?php endwhile; ?> 23 23 24 < tbody>24 </tbody> 25 25 </table> 26 No newline at end of file -
bp-templates/bp-legacy/buddypress/members/single/notifications.php
18 18 <label for="members-friends"><?php _e( 'Order By:', 'buddypress' ); ?></label> 19 19 <select id="members-friends"> 20 20 <option value="newest"><?php _e( 'Newest First', 'buddypress' ); ?></option> 21 <option value="oldest" ><?php _e( 'Oldest First', 'buddypress' ); ?></option>21 <option value="oldest" <?php selected( $_GET['sort_order'], 'ASC' ); ?>><?php _e( 'Oldest First', 'buddypress' ); ?></option> 22 22 </select> 23 23 </li> 24 24 </ul>