2011-09-24 23:09:48 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-11-05 17:04:10 +00:00
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2011-09-24 23:09:48 +00:00
|
|
|
pandora.ui.usersDialog = function() {
|
2011-10-03 09:31:20 +00:00
|
|
|
|
2012-03-21 13:07:19 +00:00
|
|
|
var browsers = [
|
2012-10-27 19:35:20 +00:00
|
|
|
'Camino', 'Chrome', 'Chrome Frame', 'Chromium', 'Epiphany',
|
|
|
|
'Firefox', 'Internet Explorer', 'Konqueror', 'Nokia Browser',
|
|
|
|
'Opera', 'Safari', 'WebKit'
|
2012-03-21 13:07:19 +00:00
|
|
|
],
|
|
|
|
dialogHeight = Math.round((window.innerHeight - 48) * 0.9),
|
2011-12-18 09:27:15 +00:00
|
|
|
dialogWidth = Math.round(window.innerWidth * 0.9),
|
|
|
|
formWidth = 256,
|
2011-10-03 09:31:20 +00:00
|
|
|
numberOfUsers = 0,
|
2012-03-21 13:07:19 +00:00
|
|
|
systems = [
|
2012-10-27 16:57:28 +00:00
|
|
|
'Android', 'BlackBerry', 'BSD', 'iOS', 'Java', 'Linux', 'Mac OS X',
|
|
|
|
'Nokia', 'PlayStation', 'Unix', 'Windows'
|
2012-03-21 13:07:19 +00:00
|
|
|
],
|
2012-05-24 08:22:56 +00:00
|
|
|
userLevels = pandora.site.userLevels.map(function(userLevel) {
|
|
|
|
return Ox.toTitleCase(userLevel);
|
|
|
|
}).concat(['Robot']),
|
2011-10-03 09:31:20 +00:00
|
|
|
|
2012-03-20 07:19:03 +00:00
|
|
|
$reloadButton = Ox.Button({
|
2013-01-01 13:10:41 +00:00
|
|
|
disabled: true,
|
2012-03-20 07:19:03 +00:00
|
|
|
title: 'redo',
|
|
|
|
tooltip: 'Reload',
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'left', margin: '4px 2px 4px 4px'})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
2013-01-01 13:10:41 +00:00
|
|
|
$reloadButton.options({disabled: true});
|
2012-03-21 06:57:40 +00:00
|
|
|
Ox.Request.clearCache('findUsers');
|
2012-03-20 07:19:03 +00:00
|
|
|
$list.reloadList(true);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
2011-11-12 10:39:50 +00:00
|
|
|
$guestsCheckbox = Ox.Checkbox({
|
2012-04-19 09:52:36 +00:00
|
|
|
title: 'Include Guests',
|
2012-02-05 11:19:40 +00:00
|
|
|
value: false
|
2011-11-12 10:39:50 +00:00
|
|
|
})
|
2012-04-19 09:52:36 +00:00
|
|
|
.css({float: 'left', margin: '4px 2px 4px 2px'})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
data.value
|
|
|
|
? $robotsCheckbox.show()
|
|
|
|
: $robotsCheckbox.hide().options({value: false});
|
|
|
|
updateList();
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
$robotsCheckbox = Ox.Checkbox({
|
|
|
|
title: 'Include Robots',
|
|
|
|
value: false
|
|
|
|
})
|
|
|
|
.css({float: 'left', margin: '4px 2px 4px 2px'})
|
|
|
|
.hide()
|
2011-11-12 11:02:54 +00:00
|
|
|
.bindEvent({
|
|
|
|
change: updateList
|
|
|
|
}),
|
2011-11-12 10:39:50 +00:00
|
|
|
|
2011-10-03 09:31:20 +00:00
|
|
|
$findSelect = Ox.Select({
|
|
|
|
items: [
|
2011-12-22 15:48:48 +00:00
|
|
|
{id: 'all', title: 'Find: All'},
|
2011-10-03 09:31:20 +00:00
|
|
|
{id: 'username', title: 'Find: Username'},
|
|
|
|
{id: 'email', title: 'Find: E-Mail-Address'}
|
|
|
|
],
|
|
|
|
overlap: 'right',
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
2011-11-12 11:02:54 +00:00
|
|
|
$findInput.value() && updateList();
|
2011-10-03 09:31:20 +00:00
|
|
|
$findInput.options({
|
2011-12-21 15:34:28 +00:00
|
|
|
placeholder: data.title
|
2011-10-03 09:31:20 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
$findInput = Ox.Input({
|
|
|
|
changeOnKeypress: true,
|
|
|
|
clear: true,
|
|
|
|
placeholder: 'Find: All',
|
|
|
|
width: 192
|
|
|
|
})
|
|
|
|
.bindEvent({
|
2011-11-12 11:02:54 +00:00
|
|
|
change: updateList
|
2011-10-03 09:31:20 +00:00
|
|
|
}),
|
|
|
|
|
|
|
|
$findElement = Ox.FormElementGroup({
|
|
|
|
elements: [
|
|
|
|
$findSelect,
|
|
|
|
$findInput
|
|
|
|
]
|
|
|
|
})
|
|
|
|
.css({float: 'right', margin: '4px'}),
|
|
|
|
|
2012-06-27 07:41:39 +00:00
|
|
|
$list = Ox.TableList({
|
2011-10-03 09:31:20 +00:00
|
|
|
columns: [
|
|
|
|
{
|
2012-04-16 17:30:25 +00:00
|
|
|
format: function(value, data) {
|
2011-10-03 09:31:20 +00:00
|
|
|
return $('<img>')
|
|
|
|
.attr({
|
|
|
|
src: Ox.UI.getImageURL('symbolCheck')
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '10px',
|
|
|
|
height: '10px',
|
|
|
|
padding: '3px',
|
2012-04-16 17:30:25 +00:00
|
|
|
opacity: value || [
|
|
|
|
'guest', 'robot'
|
2012-04-19 09:18:16 +00:00
|
|
|
].indexOf(data.level) > -1 ? 0 : 1
|
2011-10-03 09:31:20 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
id: 'disabled',
|
|
|
|
operator: '-',
|
2011-12-18 09:27:15 +00:00
|
|
|
title: 'Enabled',
|
|
|
|
titleImage: 'check',
|
2011-10-03 09:31:20 +00:00
|
|
|
visible: true,
|
|
|
|
width: 16
|
|
|
|
},
|
2012-04-19 14:26:52 +00:00
|
|
|
{
|
|
|
|
format: function(value) {
|
|
|
|
return $('<img>')
|
|
|
|
.attr({
|
|
|
|
src: Ox.UI.getImageURL('symbolMail')
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '10px',
|
|
|
|
height: '10px',
|
|
|
|
padding: '3px',
|
|
|
|
opacity: +value
|
|
|
|
});
|
|
|
|
},
|
|
|
|
id: 'newsletter',
|
|
|
|
title: 'Newsletter',
|
|
|
|
titleImage: 'mail',
|
|
|
|
operator: '-',
|
|
|
|
visible: true,
|
|
|
|
width: 16
|
|
|
|
},
|
2012-03-21 13:20:22 +00:00
|
|
|
{
|
|
|
|
format: function(value, data) {
|
|
|
|
return '<span style="opacity: ' + (
|
|
|
|
data.disabled ? 0.5 : 1
|
|
|
|
) + '">' + Ox.encodeHTMLEntities(value) + '</span>';
|
|
|
|
},
|
|
|
|
id: 'username',
|
|
|
|
operator: '+',
|
|
|
|
removable: false,
|
|
|
|
title: 'Username',
|
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 128
|
2012-03-21 13:20:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
format: function(value, data) {
|
|
|
|
return '<span style="opacity: ' + (
|
|
|
|
data.disabled ? 0.5 : 1
|
|
|
|
) + '">' + value + '</span>';
|
|
|
|
},
|
|
|
|
id: 'email',
|
|
|
|
operator: '+',
|
|
|
|
title: 'E-Mail Address',
|
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 192
|
2012-03-21 13:20:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'center',
|
2012-04-19 14:30:09 +00:00
|
|
|
format: function(value) {
|
2012-03-21 13:20:22 +00:00
|
|
|
return Ox.Theme.formatColorLevel(
|
2012-03-26 19:27:20 +00:00
|
|
|
userLevels.indexOf(Ox.toTitleCase(value)),
|
2012-03-21 13:20:22 +00:00
|
|
|
userLevels,
|
|
|
|
[0, 300]
|
|
|
|
);
|
|
|
|
},
|
|
|
|
id: 'level',
|
|
|
|
operator: '-',
|
|
|
|
title: 'Level',
|
|
|
|
type: 'label',
|
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 64
|
2012-03-21 13:20:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
format: function(value) {
|
2012-03-21 14:01:18 +00:00
|
|
|
return Ox.Element({
|
2012-03-21 13:07:19 +00:00
|
|
|
element: '<img>',
|
|
|
|
tooltip: value
|
|
|
|
})
|
|
|
|
.attr({
|
2012-03-27 07:14:59 +00:00
|
|
|
src: Ox.getFlagByGeoname(value, 16)
|
2012-03-21 13:07:19 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '14px',
|
|
|
|
height: '14px',
|
|
|
|
borderRadius: '4px',
|
|
|
|
marginLeft: '-3px',
|
|
|
|
marginTop: 0
|
2012-03-21 14:01:18 +00:00
|
|
|
});
|
2012-03-21 13:07:19 +00:00
|
|
|
},
|
|
|
|
id: 'location',
|
|
|
|
operator: '+',
|
|
|
|
title: 'Location',
|
|
|
|
titleImage: 'flag',
|
|
|
|
visible: true,
|
|
|
|
width: 16
|
|
|
|
},
|
|
|
|
{
|
|
|
|
format: function(value) {
|
2012-03-21 14:01:18 +00:00
|
|
|
var system;
|
|
|
|
Ox.forEach(systems, function(s) {
|
|
|
|
if (new RegExp('^' + s).test(value)) {
|
|
|
|
system = s;
|
2012-07-04 11:40:37 +00:00
|
|
|
return false;
|
2012-03-21 13:07:19 +00:00
|
|
|
}
|
|
|
|
});
|
2012-03-21 14:01:18 +00:00
|
|
|
return system ? Ox.Element({
|
2012-03-21 13:07:19 +00:00
|
|
|
element: '<img>',
|
|
|
|
tooltip: value
|
2012-03-27 10:29:32 +00:00
|
|
|
.replace(/BSD \((.+)\)/, '$1')
|
|
|
|
.replace(/Linux \((.+)\)/, '$1')
|
|
|
|
.replace(/Unix \((.+)\)/, '$1')
|
|
|
|
.replace(/Windows (NT \d+\.\d+) \((.+)\)/, 'Windows $2 ($1)')
|
2012-03-21 13:07:19 +00:00
|
|
|
})
|
|
|
|
.attr({
|
2012-03-21 14:01:18 +00:00
|
|
|
src: Ox.UI.PATH + 'png/system'
|
|
|
|
+ system.replace(/ /g, '') + '128.png'
|
2012-03-21 13:07:19 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '14px',
|
|
|
|
height: '14px',
|
|
|
|
marginLeft: '-3px',
|
|
|
|
marginTop: 0
|
|
|
|
}) : '';
|
|
|
|
},
|
2012-03-21 14:01:18 +00:00
|
|
|
id: 'system',
|
2012-03-21 13:07:19 +00:00
|
|
|
operator: '+',
|
2012-03-21 14:01:18 +00:00
|
|
|
title: 'System',
|
2012-04-16 09:22:56 +00:00
|
|
|
titleImage: 'square',
|
2012-03-21 13:07:19 +00:00
|
|
|
visible: true,
|
2012-03-21 14:01:18 +00:00
|
|
|
width: 16
|
2012-03-21 13:07:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
format: function(value) {
|
2012-03-21 14:01:18 +00:00
|
|
|
var browser;
|
|
|
|
Ox.forEach(browsers, function(b) {
|
|
|
|
if (new RegExp('^' + b).test(value)) {
|
|
|
|
browser = b;
|
2012-07-04 11:40:37 +00:00
|
|
|
return false;
|
2012-03-21 13:07:19 +00:00
|
|
|
}
|
|
|
|
});
|
2012-03-21 14:01:18 +00:00
|
|
|
return browser ? Ox.Element({
|
2012-03-21 13:07:19 +00:00
|
|
|
element: '<img>',
|
|
|
|
tooltip: value
|
|
|
|
})
|
|
|
|
.attr({
|
2012-03-21 14:01:18 +00:00
|
|
|
src: Ox.UI.PATH + 'png/browser'
|
|
|
|
+ browser.replace(/ /g, '') + '128.png'
|
2012-03-21 13:07:19 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: '14px',
|
|
|
|
height: '14px',
|
|
|
|
marginLeft: '-3px',
|
|
|
|
marginTop: 0
|
|
|
|
}) : '';
|
|
|
|
},
|
2012-03-21 14:01:18 +00:00
|
|
|
id: 'browser',
|
2012-03-21 13:07:19 +00:00
|
|
|
operator: '+',
|
2012-03-21 14:01:18 +00:00
|
|
|
title: 'Browser',
|
2012-04-16 09:22:56 +00:00
|
|
|
titleImage: 'circle',
|
2012-03-21 13:07:19 +00:00
|
|
|
visible: true,
|
2012-03-21 14:01:18 +00:00
|
|
|
width: 16
|
2012-03-21 13:07:19 +00:00
|
|
|
},
|
2011-12-18 09:27:15 +00:00
|
|
|
{
|
2012-03-21 13:20:22 +00:00
|
|
|
align: 'right',
|
2011-12-18 09:27:15 +00:00
|
|
|
format: function(value) {
|
2012-03-21 13:20:22 +00:00
|
|
|
return Ox.formatNumber(value);
|
2011-12-18 09:27:15 +00:00
|
|
|
},
|
2011-10-03 09:31:20 +00:00
|
|
|
id: 'timesseen',
|
|
|
|
operator: '-',
|
|
|
|
title: 'Times Seen',
|
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 80
|
2011-10-03 09:31:20 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
2011-10-03 11:37:46 +00:00
|
|
|
format: function(value) {
|
2012-10-31 23:54:09 +00:00
|
|
|
return Ox.formatDate(value, '%F %T');
|
2011-10-03 11:37:46 +00:00
|
|
|
},
|
2011-10-03 09:31:20 +00:00
|
|
|
id: 'firstseen',
|
|
|
|
operator: '-',
|
|
|
|
title: 'First Seen',
|
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 144
|
2011-10-03 09:31:20 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
2011-10-03 11:37:46 +00:00
|
|
|
format: function(value) {
|
2012-10-31 23:54:09 +00:00
|
|
|
return Ox.formatDate(value, '%F %T');
|
2011-10-03 11:37:46 +00:00
|
|
|
},
|
2011-10-03 09:31:20 +00:00
|
|
|
id: 'lastseen',
|
|
|
|
operator: '-',
|
|
|
|
title: 'Last Seen',
|
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 144
|
2011-10-03 09:31:20 +00:00
|
|
|
},
|
2012-03-21 13:20:22 +00:00
|
|
|
{
|
|
|
|
align: 'right',
|
2012-04-19 14:30:09 +00:00
|
|
|
format: function(value, data) {
|
|
|
|
return ['guest', 'robot'].indexOf(data.level) > -1
|
|
|
|
? '' : value;
|
|
|
|
},
|
|
|
|
id: 'numberoflists',
|
2012-03-21 13:20:22 +00:00
|
|
|
operator: '-',
|
|
|
|
title: 'Lists',
|
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 64
|
2012-03-21 13:20:22 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'groups',
|
|
|
|
operator: '+',
|
|
|
|
title: 'Groups',
|
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 64
|
2012-03-21 13:20:22 +00:00
|
|
|
},
|
2011-10-03 09:31:20 +00:00
|
|
|
{
|
|
|
|
id: 'screensize',
|
|
|
|
align: 'right',
|
|
|
|
operator: '-',
|
|
|
|
title: 'Screen Size',
|
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 80
|
2011-10-03 09:31:20 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
align: 'right',
|
|
|
|
id: 'windowsize',
|
|
|
|
operator: '-',
|
|
|
|
title: 'Window Size',
|
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 80
|
2011-10-03 09:31:20 +00:00
|
|
|
},
|
2011-12-03 16:17:07 +00:00
|
|
|
{
|
2012-03-21 13:07:19 +00:00
|
|
|
align: 'right',
|
|
|
|
id: 'ip',
|
2011-12-03 16:17:07 +00:00
|
|
|
operator: '+',
|
2012-03-21 13:07:19 +00:00
|
|
|
title: 'IP Address',
|
2011-12-03 16:17:07 +00:00
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 128
|
2011-12-03 16:17:07 +00:00
|
|
|
},
|
2011-10-03 09:31:20 +00:00
|
|
|
{
|
|
|
|
id: 'useragent',
|
2011-10-03 16:38:07 +00:00
|
|
|
operator: '+',
|
2011-10-03 09:31:20 +00:00
|
|
|
title: 'User Agent',
|
|
|
|
visible: true,
|
2012-09-15 13:47:10 +00:00
|
|
|
width: 768
|
2011-10-03 09:31:20 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
columnsRemovable: true,
|
|
|
|
columnsVisible: true,
|
2012-06-20 10:47:15 +00:00
|
|
|
items: pandora.api.findUsers,
|
|
|
|
query: {
|
|
|
|
conditions: [
|
|
|
|
{key: 'level', value: 'guest', operator: '!='},
|
|
|
|
{key: 'level', value: 'robot', operator: '!='}
|
|
|
|
],
|
|
|
|
operator: '&'
|
2012-02-05 11:19:40 +00:00
|
|
|
},
|
2012-01-13 09:47:18 +00:00
|
|
|
keys: ['notes', 'groups'],
|
2011-12-18 09:27:15 +00:00
|
|
|
max: -1,
|
2011-10-03 09:31:20 +00:00
|
|
|
scrollbarVisible: true,
|
2012-06-27 22:24:02 +00:00
|
|
|
sort: [{key: 'lastseen', operator: '-'}],
|
|
|
|
unique: 'id'
|
2011-10-03 09:31:20 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
init: function(data) {
|
2012-02-17 13:50:06 +00:00
|
|
|
numberOfUsers = data.users;
|
2011-10-11 16:13:21 +00:00
|
|
|
$status.html(
|
2011-11-07 14:46:16 +00:00
|
|
|
Ox.formatNumber(data.items)
|
|
|
|
+ ' user' + (data.items == 1 ? '' : 's')
|
2011-11-12 11:02:54 +00:00
|
|
|
+ (
|
|
|
|
$guestsCheckbox.value()
|
|
|
|
? ' (' + Ox.formatNumber(data.users) + ' registered, '
|
|
|
|
+ Ox.formatNumber(data.guests) + ' guest'
|
2012-03-27 09:41:03 +00:00
|
|
|
+ (data.guests == 1 ? '' : 's') + ', '
|
|
|
|
+ Ox.formatNumber(data.robots) + ' robot'
|
|
|
|
+ (data.robots == 1 ? '' : 's')
|
2011-11-12 11:02:54 +00:00
|
|
|
+ ')'
|
|
|
|
: ''
|
|
|
|
)
|
2011-10-11 16:13:21 +00:00
|
|
|
);
|
2011-10-03 09:31:20 +00:00
|
|
|
},
|
2013-01-01 13:10:41 +00:00
|
|
|
load: function() {
|
|
|
|
$reloadButton.options({disabled: false});
|
|
|
|
},
|
2011-12-18 09:27:15 +00:00
|
|
|
select: selectUsers
|
2011-10-03 09:31:20 +00:00
|
|
|
}),
|
|
|
|
|
2011-12-18 09:27:15 +00:00
|
|
|
$formLabel = Ox.Label({
|
2011-10-03 09:31:20 +00:00
|
|
|
textAlign: 'center',
|
|
|
|
title: 'No user selected',
|
2011-12-18 09:27:15 +00:00
|
|
|
width: 212
|
2011-10-03 09:31:20 +00:00
|
|
|
})
|
2011-12-18 09:27:15 +00:00
|
|
|
.css({float: 'left', margin: '4px 2px 4px 4px'}),
|
2011-10-03 09:31:20 +00:00
|
|
|
|
2011-12-18 09:27:15 +00:00
|
|
|
$formButton = Ox.ButtonGroup({
|
|
|
|
buttons: [
|
2011-10-03 01:46:19 +00:00
|
|
|
{
|
2011-12-18 09:27:15 +00:00
|
|
|
id: 'edit',
|
|
|
|
selected: true,
|
|
|
|
title: 'edit',
|
|
|
|
tooltip: 'Edit'
|
2011-09-24 23:09:48 +00:00
|
|
|
},
|
2011-10-03 01:46:19 +00:00
|
|
|
{
|
2011-12-18 09:27:15 +00:00
|
|
|
id: 'mail',
|
|
|
|
title: 'mail',
|
|
|
|
tooltip: 'Mail'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
selectable: true,
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'left', margin: '4px 4px 4px 2px'})
|
|
|
|
.bindEvent({
|
|
|
|
change: selectForm
|
|
|
|
}),
|
|
|
|
|
|
|
|
$form = Ox.Element({}),
|
|
|
|
|
|
|
|
$editForm,
|
|
|
|
|
2012-03-21 05:16:13 +00:00
|
|
|
$sendButton = Ox.Button({
|
|
|
|
disabled: true,
|
|
|
|
id: 'send',
|
|
|
|
title: 'Send',
|
|
|
|
width: 64
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: sendMail
|
|
|
|
}),
|
|
|
|
|
2011-12-18 09:27:15 +00:00
|
|
|
$mailForm = renderMailForm(),
|
|
|
|
|
|
|
|
$content = Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: Ox.Bar({size: 24})
|
2012-03-20 07:19:03 +00:00
|
|
|
.append($reloadButton)
|
2011-12-18 09:27:15 +00:00
|
|
|
.append($guestsCheckbox)
|
2012-04-19 09:52:36 +00:00
|
|
|
.append($robotsCheckbox)
|
2011-12-18 09:27:15 +00:00
|
|
|
.append($findElement),
|
|
|
|
size: 24
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: $list
|
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
|
|
|
})
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: Ox.SplitPanel({
|
2011-10-03 01:46:19 +00:00
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: Ox.Bar({size: 24})
|
2011-12-18 09:27:15 +00:00
|
|
|
.append($formLabel)
|
|
|
|
.append($formButton),
|
2011-10-03 01:46:19 +00:00
|
|
|
size: 24
|
|
|
|
},
|
|
|
|
{
|
2011-12-18 09:27:15 +00:00
|
|
|
element: $form
|
2011-10-03 01:46:19 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
2011-12-18 09:27:15 +00:00
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
resize: setWidth
|
2011-10-03 01:46:19 +00:00
|
|
|
}),
|
2011-12-18 09:27:15 +00:00
|
|
|
resizable: true,
|
|
|
|
resize: [256, 384, 512],
|
|
|
|
size: 256
|
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'horizontal'
|
|
|
|
}),
|
|
|
|
|
|
|
|
that = Ox.Dialog({
|
|
|
|
buttons: [
|
2012-03-23 08:55:22 +00:00
|
|
|
Ox.Button({
|
|
|
|
id: 'statistics',
|
|
|
|
title: 'Statistics...'
|
|
|
|
}).bindEvent({
|
|
|
|
click: function() {
|
2012-03-23 09:02:55 +00:00
|
|
|
that.close();
|
|
|
|
pandora.$ui.statisticsDialog = pandora.ui.statisticsDialog().open();
|
2012-03-23 08:55:22 +00:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
{},
|
2011-12-18 09:27:15 +00:00
|
|
|
Ox.Button({
|
|
|
|
title: 'Export E-Mail Addresses'
|
|
|
|
})
|
|
|
|
.css({margin: '4px 4px 4px 0'})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
pandora.api.findUsers({
|
|
|
|
query: {conditions: [], operator: '&'},
|
|
|
|
keys: ['email', 'username'],
|
|
|
|
range: [0, numberOfUsers],
|
|
|
|
sort: [{key: 'username', operator: '+'}]
|
|
|
|
}, function(result) {
|
|
|
|
var $dialog = Ox.Dialog({
|
|
|
|
buttons: [
|
|
|
|
Ox.Button({
|
|
|
|
title: 'Close'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
$dialog.close();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
],
|
|
|
|
content: Ox.Element()
|
|
|
|
.addClass('OxSelectable')
|
|
|
|
.css({margin: '16px'})
|
|
|
|
.html(
|
|
|
|
result.data.items.filter(function(item) {
|
|
|
|
return item.email;
|
|
|
|
}).map(function(item) {
|
2012-02-22 10:14:07 +00:00
|
|
|
return Ox.encodeHTMLEntities(item.username)
|
|
|
|
+ ' <' + item.email + '>';
|
2011-12-18 09:27:15 +00:00
|
|
|
}).join(', ')
|
|
|
|
),
|
|
|
|
removeOnClose: true,
|
|
|
|
title: 'E-Mail Addresses'
|
|
|
|
})
|
|
|
|
.open();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Ox.Button({
|
|
|
|
id: 'done',
|
|
|
|
title: 'Done',
|
|
|
|
width: 48
|
|
|
|
}).bindEvent({
|
|
|
|
click: function() {
|
|
|
|
that.close();
|
|
|
|
}
|
|
|
|
})
|
2011-10-03 01:46:19 +00:00
|
|
|
],
|
2011-12-18 09:27:15 +00:00
|
|
|
closeButton: true,
|
|
|
|
content: $content,
|
|
|
|
height: dialogHeight,
|
|
|
|
maximizeButton: true,
|
|
|
|
minHeight: 256,
|
|
|
|
minWidth: 512,
|
|
|
|
padding: 0,
|
|
|
|
removeOnClose: true,
|
|
|
|
title: 'Manage Users',
|
|
|
|
width: dialogWidth
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
resize: setHeight
|
2011-10-03 01:46:19 +00:00
|
|
|
}),
|
2011-10-11 16:13:21 +00:00
|
|
|
|
|
|
|
$status = $('<div>')
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
top: '4px',
|
2012-03-23 08:55:22 +00:00
|
|
|
left: '128px',
|
|
|
|
right: '384px',
|
2011-10-11 16:13:21 +00:00
|
|
|
bottom: '4px',
|
|
|
|
paddingTop: '2px',
|
|
|
|
fontSize: '9px',
|
2012-03-23 08:55:22 +00:00
|
|
|
textAlign: 'center'
|
2011-10-11 16:13:21 +00:00
|
|
|
})
|
2012-05-22 13:15:16 +00:00
|
|
|
.appendTo(that.find('.OxButtonsbar'));
|
2011-10-11 16:13:21 +00:00
|
|
|
|
2012-03-19 15:57:36 +00:00
|
|
|
that.superClose = that.close;
|
|
|
|
that.close = function() {
|
|
|
|
Ox.Request.clearCache('findUsers');
|
|
|
|
that.superClose();
|
|
|
|
};
|
|
|
|
|
2011-12-18 09:27:15 +00:00
|
|
|
function getFormItemById(id) {
|
|
|
|
var ret;
|
|
|
|
Ox.forEach((
|
|
|
|
$formButton.value() == 'edit' ? $editForm : $mailForm
|
|
|
|
).options('items'), function($item) {
|
|
|
|
if ($item.options('id') == id) {
|
|
|
|
ret = $item;
|
2012-07-04 11:40:37 +00:00
|
|
|
return false;
|
2011-12-18 09:27:15 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
|
|
|
|
function getTo() {
|
|
|
|
return $list.options('selected').map(function(id) {
|
|
|
|
return $list.value(id);
|
|
|
|
}).filter(function(user) {
|
2012-03-26 19:27:20 +00:00
|
|
|
return ['guest', 'robot'].indexOf(user.level) == -1 && (
|
2011-12-18 09:27:15 +00:00
|
|
|
$mailForm.values().include == 'users' || user.newsletter
|
|
|
|
);
|
|
|
|
}).map(function(user) {
|
|
|
|
return user.username;
|
|
|
|
});
|
|
|
|
}
|
2011-10-03 09:31:20 +00:00
|
|
|
|
2011-12-18 09:27:15 +00:00
|
|
|
function renderEditForm() {
|
|
|
|
var user = $list.value($list.options('selected')[0]);
|
2011-10-03 09:31:20 +00:00
|
|
|
return Ox.Form({
|
2011-12-18 09:27:15 +00:00
|
|
|
items: [
|
|
|
|
Ox.Checkbox({
|
|
|
|
id: 'status',
|
|
|
|
label: 'Status',
|
|
|
|
labelWidth: 80,
|
|
|
|
title: !user.disabled ? 'Enabled' : 'Disabled',
|
2011-12-22 15:48:48 +00:00
|
|
|
value: !user.disabled,
|
2011-12-18 09:27:15 +00:00
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
this.options({
|
|
|
|
title: this.options('title') == 'Enabled'
|
|
|
|
? 'Disabled' : 'Enabled'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Ox.Input({
|
|
|
|
id: 'username',
|
|
|
|
label: 'Username',
|
|
|
|
labelWidth: 80,
|
|
|
|
value: user.username,
|
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
submit: function(data) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Ox.Input({
|
|
|
|
id: 'email',
|
|
|
|
label: 'E-Mail',
|
|
|
|
labelWidth: 80,
|
|
|
|
value: user.email,
|
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
submit: function(data) {
|
2011-10-03 15:01:47 +00:00
|
|
|
|
2011-12-18 09:27:15 +00:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
Ox.Select({
|
|
|
|
id: 'level',
|
2012-05-22 15:07:34 +00:00
|
|
|
items: pandora.site.userLevels.slice(1).map(function(level) {
|
|
|
|
return {
|
2011-12-18 09:27:15 +00:00
|
|
|
id: level,
|
|
|
|
title: Ox.toTitleCase(level)
|
2012-05-22 15:07:34 +00:00
|
|
|
};
|
2011-12-18 09:27:15 +00:00
|
|
|
}),
|
|
|
|
label: 'Level',
|
|
|
|
labelWidth: 80,
|
2011-12-22 15:48:48 +00:00
|
|
|
value: user.level,
|
2011-12-18 09:27:15 +00:00
|
|
|
width: formWidth - 16
|
|
|
|
}),
|
|
|
|
Ox.Checkbox({
|
|
|
|
id: 'newsletter',
|
|
|
|
label: 'Newsletter',
|
2011-10-03 15:01:47 +00:00
|
|
|
labelWidth: 80,
|
2011-12-18 09:27:15 +00:00
|
|
|
title: user.newsletter ? 'Subscribed' : 'Unsubscribed',
|
2011-12-22 15:48:48 +00:00
|
|
|
value: user.newsletter,
|
2011-12-18 09:27:15 +00:00
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
this.options({
|
|
|
|
title: this.options('title') == 'Subscribed'
|
|
|
|
? 'Unsubscribed' : 'Subscribed'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}),
|
2012-03-21 13:20:22 +00:00
|
|
|
Ox.Input({
|
|
|
|
id: 'groups',
|
|
|
|
label: 'Groups',
|
|
|
|
labelWidth: 80,
|
|
|
|
value: user.groups ? user.groups.join(', ') : '',
|
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
submit: function(data) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}),
|
2011-12-18 09:27:15 +00:00
|
|
|
Ox.Input({
|
2012-01-19 16:35:28 +00:00
|
|
|
height: dialogHeight - 184,
|
2011-12-18 09:27:15 +00:00
|
|
|
id: 'notes',
|
|
|
|
placeholder: 'Notes',
|
|
|
|
type: 'textarea',
|
|
|
|
value: user.notes,
|
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
],
|
|
|
|
width: 240
|
|
|
|
})
|
|
|
|
.css({margin: '8px'})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(event) {
|
|
|
|
var data = {id: user.id}, key, value;
|
|
|
|
if (event.id == 'status') {
|
2011-12-21 15:34:28 +00:00
|
|
|
data.disabled = !event.data.value;
|
2011-12-18 09:27:15 +00:00
|
|
|
} else if (event.id == 'level') {
|
2011-12-21 15:34:28 +00:00
|
|
|
data.level = event.data.value;
|
2011-12-18 09:27:15 +00:00
|
|
|
} else if (event.id == 'newsletter') {
|
2011-12-21 15:34:28 +00:00
|
|
|
data.newsletter = event.data.value;
|
2012-01-13 09:47:18 +00:00
|
|
|
} else if (event.id == 'groups') {
|
|
|
|
data.groups = event.data.value.split(', ');
|
2011-12-18 09:27:15 +00:00
|
|
|
} else {
|
|
|
|
data[event.id] = event.data.value;
|
|
|
|
}
|
2012-04-22 10:33:31 +00:00
|
|
|
if (event.id == 'status') {
|
|
|
|
$list.value(user.id, 'disabled', data.disabled);
|
|
|
|
} else {
|
|
|
|
$list.value(user.id, event.id, data[event.id]);
|
|
|
|
}
|
2011-12-18 09:27:15 +00:00
|
|
|
pandora.api.editUser(data, function(result) {
|
|
|
|
Ox.Request.clearCache('findUsers');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderMailForm() {
|
|
|
|
return Ox.Form({
|
|
|
|
items: [
|
|
|
|
Ox.Input({
|
|
|
|
disabled: true,
|
|
|
|
id: 'from',
|
|
|
|
label: 'From',
|
|
|
|
labelWidth: 80,
|
|
|
|
value: pandora.site.site.name + ' <' + pandora.site.site.email.contact + '>',
|
|
|
|
width: formWidth - 16
|
|
|
|
}),
|
|
|
|
Ox.Input({
|
|
|
|
disabled: true,
|
|
|
|
id: 'to',
|
|
|
|
label: 'To',
|
|
|
|
labelWidth: 80,
|
|
|
|
value: '',
|
|
|
|
width: formWidth - 16
|
|
|
|
}),
|
|
|
|
Ox.Select({
|
|
|
|
id: 'include',
|
|
|
|
items: [
|
|
|
|
{id: 'users', title: 'All users'},
|
|
|
|
{id: 'subscribers', title: 'Subscribers only'},
|
|
|
|
],
|
|
|
|
label: 'Include',
|
|
|
|
labelWidth: 80,
|
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function() {
|
|
|
|
setTo();
|
|
|
|
setSend();
|
|
|
|
}
|
2011-10-03 09:31:20 +00:00
|
|
|
}),
|
2011-12-18 09:27:15 +00:00
|
|
|
Ox.Input({
|
|
|
|
id: 'subject',
|
|
|
|
label: 'Subject',
|
|
|
|
labelWidth: 80,
|
|
|
|
value: pandora.site.site.email.prefix + ' ',
|
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: setSend
|
2011-10-03 09:31:20 +00:00
|
|
|
}),
|
2011-12-18 09:27:15 +00:00
|
|
|
Ox.Input({
|
|
|
|
height: dialogHeight - 208,
|
|
|
|
id: 'message',
|
|
|
|
placeholder: 'Message',
|
2011-10-03 09:31:20 +00:00
|
|
|
type: 'textarea',
|
2011-12-18 09:27:15 +00:00
|
|
|
value: '\n\n' + pandora.site.site.email.footer,
|
|
|
|
width: formWidth - 16
|
2011-10-03 09:31:20 +00:00
|
|
|
})
|
2011-12-18 09:27:15 +00:00
|
|
|
.bindEvent({
|
|
|
|
change: setSend
|
|
|
|
}),
|
2011-12-20 07:20:23 +00:00
|
|
|
Ox.MenuButton({
|
2011-12-18 09:27:15 +00:00
|
|
|
id: 'insert',
|
|
|
|
items: [
|
|
|
|
{id: 'username', title: 'Username'},
|
|
|
|
{id: 'email', title: 'E-Mail address'},
|
|
|
|
],
|
|
|
|
title: 'Insert...',
|
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function(data) {
|
|
|
|
var $input = getFormItemById('message'),
|
|
|
|
textarea = $input.find('textarea')[0],
|
2011-12-21 15:34:28 +00:00
|
|
|
value = $input.value();
|
|
|
|
$input.value(
|
2012-05-24 09:56:52 +00:00
|
|
|
value.slice(0, textarea.selectionStart)
|
2011-12-21 15:34:28 +00:00
|
|
|
+ '{' + data.id + '}'
|
2012-05-24 09:56:52 +00:00
|
|
|
+ value.slice(textarea.selectionEnd)
|
2011-12-21 15:34:28 +00:00
|
|
|
)
|
2011-12-18 09:27:15 +00:00
|
|
|
.focusInput(textarea.selectionStart + data.id.length + 2);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
Ox.Checkbox({
|
|
|
|
id: 'receipt',
|
|
|
|
title: 'Send a receipt to ' + pandora.user.email,
|
2011-12-22 15:48:48 +00:00
|
|
|
value: false,
|
2011-12-18 09:27:15 +00:00
|
|
|
width: formWidth - 16
|
|
|
|
}),
|
2012-03-21 05:16:13 +00:00
|
|
|
$sendButton
|
2011-12-18 09:27:15 +00:00
|
|
|
],
|
|
|
|
width: formWidth - 16
|
|
|
|
})
|
|
|
|
.css({margin: '8px', textAlign: 'right'});
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectForm(data) {
|
|
|
|
var selected;
|
2011-12-21 15:34:28 +00:00
|
|
|
if (data.value == 'edit') {
|
2011-12-18 09:27:15 +00:00
|
|
|
$mailForm.detach();
|
|
|
|
selected = $list.options('selected');
|
2012-03-26 19:27:20 +00:00
|
|
|
if (selected.length == 1 && ['guest', 'robot'].indexOf(selected[0].level) == -1) {
|
2011-12-18 09:27:15 +00:00
|
|
|
$form.append($editForm = renderEditForm());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
setTo();
|
|
|
|
setSend();
|
|
|
|
setWidth();
|
|
|
|
$editForm && $editForm.remove();
|
|
|
|
$form.append($mailForm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectUsers(data) {
|
2012-06-30 14:58:21 +00:00
|
|
|
var users = data.ids.map(function(id) {
|
2011-12-18 09:27:15 +00:00
|
|
|
return $list.value(id);
|
|
|
|
});
|
|
|
|
setLabel();
|
|
|
|
if ($formButton.value() == 'edit') {
|
|
|
|
$form.empty();
|
2012-06-30 14:58:21 +00:00
|
|
|
if (
|
|
|
|
data.ids.length == 1
|
|
|
|
&& ['guest', 'robot'].indexOf(users[0].level) == -1
|
|
|
|
) {
|
|
|
|
$form.append($editForm = renderEditForm());
|
2011-12-18 09:27:15 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
setTo();
|
|
|
|
setSend();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function sendMail() {
|
2012-03-21 05:16:13 +00:00
|
|
|
$sendButton.options({title: 'Sending', disabled: true});
|
2011-12-18 09:27:15 +00:00
|
|
|
pandora.api.mail({
|
|
|
|
to: getTo(),
|
2011-12-21 15:34:28 +00:00
|
|
|
subject: getFormItemById('subject').value(),
|
|
|
|
message: getFormItemById('message').value(),
|
2011-12-18 09:27:15 +00:00
|
|
|
receipt: getFormItemById('receipt').value()
|
|
|
|
}, function(result) {
|
|
|
|
var title = result.status.code == 200
|
|
|
|
? 'Message Sent'
|
|
|
|
: 'Application Error',
|
|
|
|
message = result.status.code == 200
|
|
|
|
? 'Your message has been sent.'
|
|
|
|
: 'Your message could not be sent. Please try again.',
|
|
|
|
$dialog = Ox.Dialog({
|
|
|
|
buttons: [
|
|
|
|
Ox.Button({
|
|
|
|
id: 'close',
|
|
|
|
title: 'Close'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
$dialog.close();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
],
|
|
|
|
// FIXME: we need a template for this type of dialog
|
|
|
|
content: Ox.Element()
|
|
|
|
.append(
|
|
|
|
$('<img>')
|
2012-04-20 10:22:32 +00:00
|
|
|
.attr({src: '/static/png/icon.png'})
|
2011-12-18 09:27:15 +00:00
|
|
|
.css({position: 'absolute', left: '16px', top: '16px', width: '64px', height: '64px'})
|
|
|
|
)
|
|
|
|
.append(
|
|
|
|
$('<div>')
|
|
|
|
.css({position: 'absolute', left: '96px', top: '16px', width: '192px'})
|
|
|
|
.html(message)
|
|
|
|
),
|
|
|
|
height: 128,
|
|
|
|
keys: {enter: 'close', escape: 'close'},
|
|
|
|
removeOnClose: true,
|
|
|
|
title: title,
|
|
|
|
width: 304
|
|
|
|
}).open();
|
2012-03-21 05:16:13 +00:00
|
|
|
$sendButton.options({title: 'Send', disabled: false});
|
2011-12-18 09:27:15 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setHeight(data) {
|
2011-12-21 15:34:28 +00:00
|
|
|
var form = $formButton.value(),
|
2011-12-18 09:27:15 +00:00
|
|
|
$item = getFormItemById(form == 'edit' ? 'notes' : 'message');
|
|
|
|
dialogHeight = data.height;
|
|
|
|
$item && $item.options({
|
|
|
|
height: dialogHeight - (form == 'edit' ? 160 : 208)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setLabel() {
|
|
|
|
var users = $list.options('selected').map(function(id) {
|
|
|
|
return $list.value(id);
|
|
|
|
}),
|
|
|
|
title = users.length == 0 ? 'No user selected'
|
|
|
|
: users.length == 1 ? (
|
2012-03-26 19:27:20 +00:00
|
|
|
['guest', 'robot'].indexOf(users[0].level) > -1
|
|
|
|
? Ox.toTitleCase(users[0].level)
|
2012-02-22 10:14:07 +00:00
|
|
|
: Ox.encodeHTMLEntities(users[0].username)
|
|
|
|
+ ' <' + users[0].email + '>'
|
2011-12-18 09:27:15 +00:00
|
|
|
)
|
|
|
|
: users.length + ' users selected';
|
|
|
|
$formLabel.options({title: title});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setSend() {
|
|
|
|
getFormItemById('send').options({
|
2011-12-21 15:34:28 +00:00
|
|
|
disabled: getFormItemById('to').value() == 'No recipients'
|
|
|
|
|| getFormItemById('subject').value() === ''
|
|
|
|
|| getFormItemById('message').value() === ''
|
2011-12-18 09:27:15 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setTo() {
|
|
|
|
var recipients = getTo().length;
|
|
|
|
$mailForm.values({
|
|
|
|
to: (recipients || 'No') + ' recipient' + (recipients == 1 ? '' : 's')
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setWidth() {
|
2012-03-23 08:55:22 +00:00
|
|
|
var $form = $formButton.value() == 'edit' ? $editForm : $mailForm;
|
2011-12-18 09:27:15 +00:00
|
|
|
formWidth = $content.size(1);
|
|
|
|
$formLabel.options({width: formWidth - 44});
|
2012-03-23 08:55:22 +00:00
|
|
|
$form && $form.options('items').forEach(function($item) {
|
2011-12-18 09:27:15 +00:00
|
|
|
if ($item.options('id') != 'send') {
|
|
|
|
$item.options({width: formWidth - 16});
|
|
|
|
}
|
|
|
|
});
|
2012-03-23 08:55:22 +00:00
|
|
|
$status.css({right: formWidth + 128 + 'px'});
|
2011-10-03 09:31:20 +00:00
|
|
|
}
|
|
|
|
|
2011-11-12 11:02:54 +00:00
|
|
|
function updateList() {
|
|
|
|
var guests = $guestsCheckbox.value(),
|
2012-04-19 09:52:36 +00:00
|
|
|
robots = $robotsCheckbox.value(),
|
2011-11-12 11:02:54 +00:00
|
|
|
key = $findSelect.value(),
|
|
|
|
value = $findInput.value(),
|
|
|
|
query = {
|
|
|
|
conditions: value
|
2012-05-24 08:22:56 +00:00
|
|
|
? [].concat(
|
2011-11-12 11:02:54 +00:00
|
|
|
key != 'email' ? [{key: 'username', value: value, operator: '='}] : [],
|
|
|
|
key != 'username' ? [{key: 'email', value: value, operator: '='}] : []
|
|
|
|
)
|
2012-05-24 08:22:56 +00:00
|
|
|
: [].concat(
|
2012-04-19 09:52:36 +00:00
|
|
|
!guests ? [{key: 'level', value: 'guest', operator: '!='}] : [],
|
|
|
|
!robots ? [{key: 'level', value: 'robot', operator: '!='}] : []
|
|
|
|
),
|
2011-11-12 11:02:54 +00:00
|
|
|
operator: key == 'all' && value ? '|' : '&'
|
2011-10-03 09:31:20 +00:00
|
|
|
};
|
|
|
|
$list.options({
|
2012-06-20 10:47:15 +00:00
|
|
|
query: query
|
2011-10-29 17:46:46 +00:00
|
|
|
});
|
2011-10-03 09:31:20 +00:00
|
|
|
}
|
|
|
|
|
2011-09-24 23:09:48 +00:00
|
|
|
return that;
|
2011-10-03 09:31:20 +00:00
|
|
|
|
2011-09-24 23:09:48 +00:00
|
|
|
};
|
|
|
|
|