-
Notifications
You must be signed in to change notification settings - Fork 139
Expand file tree
/
Copy path_Trashable.js
More file actions
61 lines (48 loc) · 1.12 KB
/
_Trashable.js
File metadata and controls
61 lines (48 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* Trashable model
*
* @type {Object}
* @since 3.16.12
* @version 3.16.12
*/
define( [], function() {
return {
/**
* DOM Events
*
* @type {Object}
* @since 3.16.12
* @version 3.16.12
*/
events: {
'click a[href="#llms-trash-model"]': 'trash_model',
'click button.llms-trash-model': 'trash_model',
},
/**
* Remove a model from it's parent and delete it
*
* @param obj event js event object
* @return void
* @since 3.16.12
* @version 3.16.12
*/
trash_model: function( event ) {
if ( event ) {
event.preventDefault();
event.stopPropagation();
}
var msg = LLMS.l10n.replace( 'Are you sure you want to move this %s to the trash?', {
'%s': this.model.get_l10n_type(),
} );
if ( window.confirm( msg ) ) {
if ( this.model.collection ) {
this.model.collection.remove( this.model );
}
// publish event
Backbone.pubSub.trigger( 'model-trashed', this.model );
// trigger local event so extending views can run other actions where necessary
this.trigger( 'model-trashed', this.model );
}
},
}
} );