diff --git src/bp-core/js/avatar.js src/bp-core/js/avatar.js
index 1226d2b..b410204 100644
|
|
window.bp = window.bp || {}; |
34 | 34 | // Avatars are uploaded files |
35 | 35 | this.avatars = bp.Uploader.filesUploaded; |
36 | 36 | |
| 37 | // The Avatar Attachment object. |
| 38 | this.Attachment = new Backbone.Model(); |
| 39 | |
37 | 40 | // Wait till the queue is reset |
38 | 41 | bp.Uploader.filesQueue.on( 'reset', this.cropView, this ); |
39 | 42 | |
… |
… |
window.bp = window.bp || {}; |
256 | 259 | // Inject the Delete nav |
257 | 260 | bp.Avatar.navItems.get( 'delete' ).set( { hide: 0 } ); |
258 | 261 | |
| 262 | /** |
| 263 | * Set the Attachment object |
| 264 | * |
| 265 | * You can run extra actions once the avatar is set using: |
| 266 | * bp.Avatar.Attachment.on( 'change:url', function( data ) { your code } ); |
| 267 | * |
| 268 | * In this case data.attributes will include the url to the newly |
| 269 | * uploaded avatar, the object and the item_id concerned. |
| 270 | */ |
| 271 | self.Attachment.set( _.extend( |
| 272 | _.pick( avatar.attributes, ['object', 'item_id'] ), |
| 273 | { url: response.avatar, action: 'uploaded' } |
| 274 | ) ); |
| 275 | |
259 | 276 | } ).fail( function( response ) { |
260 | 277 | var feedback = BP_Uploader.strings.default_error; |
261 | 278 | if ( ! _.isUndefined( response ) ) { |
… |
… |
window.bp = window.bp || {}; |
329 | 346 | $( this ).prop( 'src', response.avatar ); |
330 | 347 | } ); |
331 | 348 | |
332 | | // Remove the Delete nav |
333 | | bp.Avatar.navItems.get( 'delete' ).set( { active: 0, hide: 1 } ); |
| 349 | // Remove the Delete nav |
| 350 | bp.Avatar.navItems.get( 'delete' ).set( { active: 0, hide: 1 } ); |
| 351 | |
| 352 | /** |
| 353 | * Reset the Attachment object |
| 354 | * |
| 355 | * You can run extra actions once the avatar is set using: |
| 356 | * bp.Avatar.Attachment.on( 'change:url', function( data ) { your code } ); |
| 357 | * |
| 358 | * In this case data.attributes will include the url to the gravatar, |
| 359 | * the object and the item_id concerned. |
| 360 | */ |
| 361 | self.Attachment.set( _.extend( |
| 362 | _.pick( model.attributes, ['object', 'item_id'] ), |
| 363 | { url: response.avatar, action: 'deleted' } |
| 364 | ) ); |
334 | 365 | |
335 | 366 | } ).fail( function( response ) { |
336 | 367 | var feedback = BP_Uploader.strings.default_error; |
diff --git src/bp-core/js/cover-image.js src/bp-core/js/cover-image.js
index bd51777..07b2259 100644
|
|
window.bp = window.bp || {}; |
20 | 20 | this.views = new Backbone.Collection(); |
21 | 21 | this.warning = null; |
22 | 22 | |
| 23 | // The Cover Image Attachment object. |
| 24 | this.Attachment = new Backbone.Model(); |
| 25 | |
23 | 26 | // Set up views |
24 | 27 | this.uploaderView(); |
25 | 28 | |
… |
… |
window.bp = window.bp || {}; |
125 | 128 | // Reset the has_cover_image bp_param |
126 | 129 | BP_Uploader.settings.defaults.multipart_params.bp_params.has_cover_image = false; |
127 | 130 | |
| 131 | /** |
| 132 | * Reset the Attachment object |
| 133 | * |
| 134 | * You can run extra actions once the cover image is set using: |
| 135 | * bp.CoverImage.Attachment.on( 'change:url', function( data ) { your code } ); |
| 136 | * |
| 137 | * In this case data.attributes will include the default url for the |
| 138 | * cover image (most of the time: ''), the object and the item_id concerned. |
| 139 | */ |
| 140 | self.Attachment.set( _.extend( |
| 141 | _.pick( model.attributes, ['object', 'item_id'] ), |
| 142 | { url: response.reset_url, action: 'deleted' } |
| 143 | ) ); |
| 144 | |
128 | 145 | } ).fail( function( response ) { |
129 | 146 | var feedback = BP_Uploader.strings.default_error; |
130 | 147 | if ( ! _.isUndefined( response ) ) { |
… |
… |
window.bp = window.bp || {}; |
203 | 220 | |
204 | 221 | // Add the delete view |
205 | 222 | bp.CoverImage.deleteView(); |
| 223 | |
| 224 | /** |
| 225 | * Set the Attachment object |
| 226 | * |
| 227 | * You can run extra actions once the cover image is set using: |
| 228 | * bp.CoverImage.Attachment.on( 'change:url', function( data ) { your code } ); |
| 229 | * |
| 230 | * In this case data.attributes will include the url to the newly |
| 231 | * uploaded cover image, the object and the item_id concerned. |
| 232 | */ |
| 233 | bp.CoverImage.Attachment.set( _.extend( |
| 234 | _.pick( BP_Uploader.settings.defaults.multipart_params.bp_params, ['object', 'item_id'] ), |
| 235 | { url: model.get( 'url' ), action: 'uploaded' } |
| 236 | ) ); |
206 | 237 | } |
207 | 238 | } |
208 | 239 | } ); |