[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 /* global BP_Nouveau */ 2 /* @since 3.0.0 */ 3 /* @version 8.0.0 */ 4 window.bp = window.bp || {}; 5 6 ( function( bp, $ ) { 7 8 // Bail if not set. 9 if ( typeof BP_Nouveau === 'undefined' ) { 10 return; 11 } 12 13 bp.Nouveau = bp.Nouveau || {}; 14 15 /** 16 * [Activity description] 17 * @type {Object} 18 */ 19 bp.Nouveau.Notifications = { 20 21 /** 22 * [start description] 23 * @return {[type]} [description] 24 */ 25 start: function() { 26 this.setupGlobals(); 27 28 // Listen to events ("Add hooks!"). 29 this.addListeners(); 30 }, 31 32 /** 33 * [setupGlobals description] 34 * @return {[type]} [description] 35 */ 36 setupGlobals: function() { 37 // Always reset sort to Newest notifications 38 bp.Nouveau.setStorage( 'bp-notifications', 'extras', 'DESC' ); 39 }, 40 41 /** 42 * [addListeners description] 43 */ 44 addListeners: function() { 45 // Change the Order actions visibility once the ajax request is done. 46 $( '#buddypress [data-bp-list="notifications"]' ).on( 'bp_ajax_request', this.prepareDocument ); 47 48 // Trigger Notifications order request. 49 $( '#buddypress [data-bp-list="notifications"]' ).on( 'click', '[data-bp-notifications-order]', bp.Nouveau, this.sortNotifications ); 50 51 // Enable the Apply Button once the bulk action is selected. 52 $( '#buddypress [data-bp-list="notifications"]' ).on( 'change', '#notification-select', this.enableBulkSubmit ); 53 54 // Select all displayed notifications. 55 $( '#buddypress [data-bp-list="notifications"]' ).on( 'click', '#select-all-notifications', this.selectAll ); 56 57 // Reset The filter before unload. 58 $( window ).on( 'unload', this.resetFilter ); 59 }, 60 61 /** 62 * [prepareDocument description] 63 * @return {[type]} [description] 64 */ 65 prepareDocument: function() { 66 var store = bp.Nouveau.getStorage( 'bp-notifications' ); 67 68 if ( 'ASC' === store.extras ) { 69 $( '[data-bp-notifications-order="DESC"]' ).show(); 70 $( '[data-bp-notifications-order="ASC"]' ).hide(); 71 } else { 72 $( '[data-bp-notifications-order="ASC"]' ).show(); 73 $( '[data-bp-notifications-order="DESC"]' ).hide(); 74 } 75 76 // Make sure a 'Bulk Action' is selected before submitting the form. 77 $( '#notification-bulk-manage' ).prop( 'disabled', 'disabled' ); 78 }, 79 80 /** 81 * [sortNotifications description] 82 * @param {[type]} event [description] 83 * @return {[type]} [description] 84 */ 85 sortNotifications: function( event ) { 86 var store = event.data.getStorage( 'bp-notifications' ), 87 scope = store.scope || null, filter = store.filter || null, 88 sort = store.extra || null, search_terms = ''; 89 90 event.preventDefault(); 91 92 sort = $( event.currentTarget ).data( 'bp-notifications-order' ); 93 bp.Nouveau.setStorage( 'bp-notifications', 'extras', sort ); 94 95 if ( $( '#buddypress [data-bp-search="notifications"] input[type=search]' ).length ) { 96 search_terms = $( '#buddypress [data-bp-search="notifications"] input[type=search]' ).val(); 97 } 98 99 bp.Nouveau.objectRequest( { 100 object : 'notifications', 101 scope : scope, 102 filter : filter, 103 search_terms : search_terms, 104 extras : sort, 105 page : 1 106 } ); 107 }, 108 109 /** 110 * [enableBulkSubmit description] 111 * @param {[type]} event [description] 112 * @return {[type]} [description] 113 */ 114 enableBulkSubmit: function( event ) { 115 $( '#notification-bulk-manage' ).prop( 'disabled', $( event.currentTarget ).val().length <= 0 ); 116 }, 117 118 /** 119 * [selectAll description] 120 * @param {[type]} event [description] 121 * @return {[type]} [description] 122 */ 123 selectAll: function( event ) { 124 $.each( $( '.notification-check' ), function( cb, checkbox ) { 125 $( checkbox ).prop( 'checked', $( event.currentTarget ).prop( 'checked' ) ); 126 } ); 127 }, 128 129 /** 130 * [resetFilter description] 131 * @return {[type]} [description] 132 */ 133 resetFilter: function() { 134 bp.Nouveau.setStorage( 'bp-notifications', 'filter', 0 ); 135 } 136 }; 137 138 // Launch BP Nouveau Notifications. 139 bp.Nouveau.Notifications.start(); 140 141 } )( window.bp, jQuery );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 22 01:00:56 2024 | Cross-referenced by PHPXref 0.7.1 |