-
Notifications
You must be signed in to change notification settings - Fork 3
/
models.js
executable file
·100 lines (84 loc) · 2.15 KB
/
models.js
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//noinspection ThisExpressionReferencesGlobalObjectJS,JSUnresolvedVariable
( function( window, $, Backbone, plugin ) {
'use strict';
var models = {};
models.Logo = Backbone.Model.extend( {
urlRoot : ajaxurl,
defaults : {
container : {},
templates : {},
l10n : {},
att_id : 0,
width : 0,
height : 0,
thumb : '',
name : '',
link : ''
},
initialize : function() {
// this.queue = $.Deferred();
// this.queue.resolve();
},
fetch : function() {
var self = this;
$.when(
$.post( this.urlRoot, {
action : plugin.action,
_ajax_nonce : plugin._ajax_nonce,
att_id : self.get('att_id'),
task : 'fetch'
} )
)
.done( function( response ) {
self.set( {
thumb : response.data.thumb,
name : response.data.name,
width : response.data.width,
height : response.data.height,
link : response.data.link
} );
} )
.fail( function( reason ) {
//console.log( 'Model:fetch Error',reason );
} );
/*wp.ajax.post( plugin.action, {
_ajax_nonce : plugin._ajax_nonce,
att_id : self.get('att_id'),
task : 'fetch'
} )
.done( function( response ) {
self.set( {
att_id : self.get('att_id'),
width : response.data.width,
height : response.data.height,
thumb : response.data.thumb,
name : response.data.name,
link : response.data.link
} );
} );*/
},
save : function( att_id ) {},
// Triggered by: views.Delete
destroy : function( att_id ) {
var self = this;
$.when(
$.post( this.urlRoot, {
action : plugin.action,
_ajax_nonce : plugin._ajax_nonce,
att_id : self.get('att_id'),
task : 'destroy'
} )
)
.done( function( response ) {
// console.log( 'Model:destroy Success', response );
} )
.fail( function( reason ) {
// console.log( 'Model:destroy Error', reason );
} );
return {};
}
} );
window.wcm = window.wcm || {};
window.wcm.logo = window.wcm.logo || {};
window.wcm.logo.models = models;
} )( this, jQuery, Backbone, logoUploader );