-
Notifications
You must be signed in to change notification settings - Fork 6
/
mosaico.html
129 lines (118 loc) · 4.38 KB
/
mosaico.html
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=1024, initial-scale=1">
<link rel="canonical" href="http://mosaico.io" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<script src="/mosaico/mosaico-libs.min.js?v=0.17.3"></script>
<script src="/mosaico/mosaico.min.js?v=0.17.3"></script>
<script>
$(function() {
if (!Mosaico.isCompatible()) {
alert('Update your browser!');
return;
}
var base = window.location.protocol + '//' + window.location.host;
var uuid = (location.hash && location.hash.indexOf('#edit') === 0) ? location.hash.split('/')[1] : undefined;
var plugins = [function(vm) {
// Logo path
vm.logoPath = '/mosaico/img/mosaico32.png';
// Download command
var downloadCmd = {
name: 'Download', // l10n happens in the template
enabled: ko.observable(true)
};
downloadCmd.execute = function() {
downloadCmd.enabled(false);
vm.notifier.info(vm.t('Downloading...'));
vm.exportHTMLtoTextarea('#downloadHtmlTextarea');
document.getElementById('downloadForm').setAttribute('action', '/dl/');
document.getElementById('downloadForm').submit();
downloadCmd.enabled(true);
};
vm.download = downloadCmd;
// Save command
var saveCmd = {
name: 'Save', // l10n happens in the template
enabled: ko.observable(true),
uuid: uuid
};
saveCmd.execute = function() {
saveCmd.enabled(false);
var metadata = JSON.parse(vm.exportMetadata());
metadata.name = prompt('Nom du template', metadata.name);
var post = $.post(base + '/storage/save', {
uuid: saveCmd.uuid,
html: vm.exportHTML(),
metadata: JSON.stringify(metadata),
content: vm.exportJSON()
});
post.fail(function() {
vm.notifier.error(vm.t('Unexpected error talking to server.'));
});
post.success(function(res) {
vm.notifier.success(vm.t('Saved!'));
saveCmd.uuid = res.uuid;
});
post.always(function() {
saveCmd.enabled(true);
});
};
vm.save = saveCmd;
// Test command
var testCmd = {
name: 'Test', // l10n happens in the template
enabled: ko.observable(true)
};
testCmd.execute = function() {
testCmd.enabled(false);
var email = vm.t('Insert here the recipient email address');
email = prompt(vm.t('Test email address'), email);
if (!email || !email.match(/@/)) {
alert(vm.t('Invalid email address'));
testCmd.enabled(true);
return
}
var post = $.post(base + '/dl/', {
action: 'email',
rcpt: email,
subject: "[test]",
html: vm.exportHTML()
});
post.fail(function() {
vm.notifier.error(vm.t('Unexpected error talking to server.'));
});
post.success(function() {
vm.notifier.success(vm.t("Test email sent..."));
});
post.always(function() {
testCmd.enabled(true);
});
};
vm.test = testCmd;
}];
var options = {
imgProcessorBackend: base + '/img/',
emailProcessorBackend: base +'/dl/',
titleToken: "MOSAICO Responsive Email Designer",
fileuploadConfig: {
url: base + '/upload/',
},
};
if (uuid) {
$.get('/emails/' + uuid + '.json', null, function(data) {
options.data = data;
Mosaico.init(options, plugins);
}, 'json');
} else {
Mosaico.init(options, plugins);
}
});
</script>
<link rel="stylesheet" href="/mosaico/mosaico-libs.min.css?v=0.17.3" />
<link rel="stylesheet" href="/mosaico/mosaico-material.min.css?v=0.17.3" />
</head>
<body class="mo-standalone"></body>
</html>