-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
sms.js
98 lines (82 loc) · 2.97 KB
/
sms.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
/** SmsBundle **/
Mautic.smsOnLoad = function (container, response) {
const smsMessage = mQuery('#sms_message');
if (smsMessage.length) {
Mautic.setSmsCharactersCount(smsMessage);
smsMessage.on('input', () => {
Mautic.setSmsCharactersCount(smsMessage);
});
}
if (mQuery(container + ' #list-search').length) {
Mautic.activateSearchAutocomplete('list-search', 'sms');
}
if (mQuery('table.sms-list').length) {
var ids = [];
mQuery('td.col-stats').each(function () {
var id = mQuery(this).attr('data-stats');
ids.push(id);
});
// Get all stats numbers in batches of 10
while (ids.length > 0) {
let batchIds = ids.splice(0, 10);
Mautic.ajaxActionRequest(
'sms:getSmsCountStats',
{ids: batchIds},
function (response) {
if (response.success && response.stats) {
for (var i = 0; i < response.stats.length; i++) {
var stat = response.stats[i];
if (mQuery('#pending-' + stat.id).length) {
if (stat.pending) {
mQuery('#pending-' + stat.id + ' > a').html(stat.pending);
mQuery('#pending-' + stat.id).removeClass('hide');
}
}
}
}
},
false,
true
);
}
}
};
Mautic.setSmsCharactersCount = function (smsMessage) {
mQuery('#sms_nb_char').text((smsMessage.val().length))
};
Mautic.selectSmsType = function(smsType) {
if (smsType == 'list') {
mQuery('#leadList').removeClass('hide');
mQuery('#publishStatus').addClass('hide');
mQuery('.page-header h3').text(mauticLang.newListSms);
} else {
mQuery('#publishStatus').removeClass('hide');
mQuery('#leadList').addClass('hide');
mQuery('.page-header h3').text(mauticLang.newTemplateSms);
}
mQuery('#sms_smsType').val(smsType);
mQuery('body').removeClass('noscroll');
mQuery('.sms-type-modal').remove();
mQuery('.sms-type-modal-backdrop').remove();
};
Mautic.standardSmsUrl = function(options) {
if (!options) {
return;
}
var url = options.windowUrl;
if (url) {
var editEmailKey = '/sms/edit/smsId';
if (url.indexOf(editEmailKey) > -1) {
options.windowUrl = url.replace('smsId', mQuery('#campaignevent_properties_sms').val());
}
}
return options;
};
Mautic.disabledSmsAction = function(opener) {
if (typeof opener == 'undefined') {
opener = window;
}
var sms = opener.mQuery('#campaignevent_properties_sms').val();
var disabled = sms === '' || sms === null;
opener.mQuery('#campaignevent_properties_editSmsButton').prop('disabled', disabled);
};