-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathcollections.renderers.js
183 lines (158 loc) · 7.55 KB
/
collections.renderers.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
var iconClass = {
"edit": "icon-pencil",
"quickupdate": "icon-edit",
"delete": "icon-trash-o",
"duplicate": "icon-files-o",
"publish": "icon-thumbs-o-up",
"unpublish": "icon-thumbs-down",
"view": "icon-eye",
"open": "icon-folder-open-o",
"remove": "icon-ban",
"undelete": "icon-undo",
"unlink": "icon-chain-broken"
};
var pagetitleWithButtons = new Ext.XTemplate('<tpl for="."><div class="collections-title-column">'
+'<span class="collections-children-icon x-tree-node-collapsed"><i class="{icons}"></i></span><h3 class="main-column buttons"><a href="{[ parent.self.getEditChildUrl(parent) ]}" title=\'' + _('edit') + ' "{pagetitle}"\'>{pagetitle}</a></h3>'
+'<ul class="actions">'
+'<tpl for="actions">'
+'<tpl if="values.urlFunction">'
+'<li><a href="{[ parent.self[values.urlFunction](parent) ]}" class="{className}" {attributes}>{text}</a></li>'
+'</tpl>'
+'<tpl if="!values.urlFunction">'
+'<li><a href="javascript:void(0);" class="controlBtn {className}" {attributes}>{text}</a></li>'
+'</tpl>'
+'</tpl>'
+'</ul>'
+'</div></tpl>',{
compiled: true
});
var pagetitle = new Ext.XTemplate('<tpl for="."><div class="collections-title-column">'
+ '<span class="collections-children-icon x-tree-node-collapsed"><i class="{icons}"></i></span><h3 class="main-column buttons"><a href="{[ parent.self.getEditChildUrl(parent) ]}" title=\'' + _('edit') + ' "{pagetitle}"\'>{pagetitle}</a></h3>'
+ '</div></tpl>', {
compiled: true
});
var pagetitleLink = new Ext.XTemplate('<tpl for="."><div class="collections-title-column">'
+ '<a href="{[ parent.self.getEditChildUrl(parent) ]}" title=\'' + _('edit') + ' "{pagetitle}"\'>{pagetitle}</a>'
+ '</div></tpl>', {
compiled: true
});
var linkNameToRecord = new Ext.XTemplate('<tpl for="."><div class="collections-title-column">'
+ '<a href="{[ parent.self.getEditChildUrl(parent) ]}" title=\'' + _('edit') + ' "{displayName}"\'>{displayName}</a>'
+ '</div></tpl>', {
compiled: true
});
var pagetitleWithIcons = new Ext.XTemplate('<tpl for="."><div class="collections-title-column">'
+'<span class="collections-children-icon x-tree-node-collapsed"><i class="{icons}"></i></span><h3 class="main-column buttons"><a href="{[ parent.self.getEditChildUrl(parent) ]}" title=\'' + _('edit') + ' "{pagetitle}"\'>{pagetitle}</a></h3>'
+'<ul class="actions">'
+'<tpl for="actions">'
+'<tpl if="values.urlFunction">'
+'<li><a href="{[ parent.self[values.urlFunction](parent) ]}" class="{className}" title="{text}">'
+'<i class="icon icon-fw icon {[ iconClass[values.key] ]}"></i>{[ iconClass[values.key] ? "":values.text ]}'
+'</a></li>'
+'</tpl>'
+'<tpl if="!values.urlFunction">'
+'<li><a href="javascript:void(0);" class="controlBtn {className}" title="{text}">'
+'<i class="icon icon-fw icon {[ iconClass[values.key] ]}" data-id="{parent.id}" data-action="{values.key}"></i>{[ iconClass[values.key] ? "":values.text ]}'
+'</a></li>'
+'</tpl>'
+'</tpl>'
+'</ul>'
+'</div></tpl>',{
compiled: true
});
var icons = new Ext.XTemplate('<tpl for=".">'
+'<ul class="actions solo">'
+'<tpl for="actions">'
+'<tpl if="values.urlFunction">'
+'<li><a href="{[ parent.self[values.urlFunction](parent) ]}" class="{className}" title="{text}">'
+'<i class="icon icon-fw icon {[ iconClass[values.key] ]}"></i>{[ iconClass[values.key] ? "":values.text ]}'
+'</a></li>'
+'</tpl>'
+'<tpl if="!values.urlFunction">'
+'<li><a href="javascript:void(0);" class="controlBtn {className}" title="{text}">'
+'<i class="icon icon-fw icon {[ iconClass[values.key] ]}" data-id="{parent.id}" data-action="{values.key}"></i>{[ iconClass[values.key] ? "":values.text ]}'
+'</a></li>'
+'</tpl>'
+'</tpl>'
+'</ul>'
+'</tpl>',{
compiled: true
});
collections.renderer.buttons = function(value, metaData, record, rowIndex, colIndex, store) {
var data = JSON.parse(JSON.stringify(record.data));
data.self = this;
return icons.apply(data);
};
collections.renderer.qtip = function(value, metaData, record, rowIndex, colIndex, store) {
metaData.attr = 'ext:qtip="' + value + '"';
return value;
};
collections.renderer.pagetitleWithButtons = function(value, metaData, record, rowIndex, colIndex, store) {
var data = JSON.parse(JSON.stringify(record.data));
data.self = this;
return pagetitleWithButtons.apply(data);
};
collections.renderer.pagetitleWithIcons = function(value, metaData, record, rowIndex, colIndex, store) {
var data = JSON.parse(JSON.stringify(record.data));
data.self = this;
return pagetitleWithIcons.apply(data);
};
collections.renderer.pagetitle = function(value, metaData, record, rowIndex, colIndex, store) {
var data = JSON.parse(JSON.stringify(record.data));
data.self = this;
return pagetitle.apply(data);
};
collections.renderer.pagetitleLink = function(value, metaData, record, rowIndex, colIndex, store) {
var data = JSON.parse(JSON.stringify(record.data));
data.self = this;
return pagetitleLink.apply(data);
};
collections.renderer.linkNameToRecord = function(value, metaData, record, rowIndex, colIndex, store) {
var data = JSON.parse(JSON.stringify(record.data));
data.self = this;
data.displayName = value;
return linkNameToRecord.apply(data);
};
collections.renderer.datetimeTwoLines = function(value, metaData, record, rowIndex, colIndex, store) {
if (value == 0) return '';
var d = Date.parseDate(value, 'Y-m-d H:i:s');
var date = Ext.util.Format.date(d, MODx.config['collections.mgr_date_format']);
var time = Ext.util.Format.date(d, MODx.config['collections.mgr_time_format']);
return '<div class="collections-grid-date">' + date + '<span class="collections-grid-time">' + time + '</span></div>';
};
collections.renderer.datetime = function(value, metaData, record, rowIndex, colIndex, store) {
if (value == 0) return '';
var d = Date.parseDate(value, 'Y-m-d H:i:s');
return Ext.util.Format.date(d,MODx.config['collections.mgr_datetime_format']);
};
collections.renderer.timestampToDatetime = function(value, metaData, record, rowIndex, colIndex, store) {
if (value == 0 || value == null) return '';
return Ext.util.Format.date(new Date(parseInt(value)),MODx.config['collections.mgr_datetime_format']);
};
collections.renderer.image = function(value, metaData, record, rowIndex, colIndex, store) {
if (value != '' && value != null) {
var imgPath = MODx.config['collections.renderer_image_path'];
return '<img src="' + MODx.config.base_url + imgPath + value + '" width="64">';
}
};
collections.renderer.boolean = function(value, metaData, record, rowIndex, colIndex, store) {
var iconclass = (value) ? 'icon-check' : 'icon-times';
return '<div style="text-align:center;"><i class="icon ' + iconclass + '"></i></div>';
};
collections.renderer.html = function(value, metaData, record, rowIndex, colIndex, store) {
return value;
};
// Backwards compatibility
Collections.renderer = {
buttons: collections.renderer.buttons,
qtip: collections.renderer.qtip,
pagetitleWithButtons: collections.renderer.pagetitleWithButtons,
pagetitleWithIcons: collections.renderer.pagetitleWithIcons,
pagetitle: collections.renderer.pagetitle,
pagetitleLink: collections.renderer.pagetitleLink,
datetimeTwoLines: collections.renderer.datetimeTwoLines,
datetime: collections.renderer.datetime,
timestampToDatetime: collections.renderer.timestampToDatetime,
image: collections.renderer.image,
boolean: collections.renderer.boolean
};