forked from lafranceinsoumise/mosaico-standalone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mosaico.html
137 lines (127 loc) · 4.98 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
130
131
132
133
134
135
136
137
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=1024, initial-scale=1">
<script src="/mosaico/vendor/jquery.min.js"></script>
<script src="/mosaico/vendor/knockout.js"></script>
<script src="/mosaico/vendor/jquery-ui.min.js"></script>
<script src="/mosaico/vendor/jquery.ui.touch-punch.min.js"></script>
<script src="/mosaico/vendor/load-image.all.min.js"></script>
<script src="/mosaico/vendor/canvas-to-blob.min.js"></script>
<script src="/mosaico/vendor/jquery.iframe-transport.js"></script>
<script src="/mosaico/vendor/jquery.fileupload.js"></script>
<script src="/mosaico/vendor/jquery.fileupload-process.js"></script>
<script src="/mosaico/vendor/jquery.fileupload-image.js"></script>
<script src="/mosaico/vendor/jquery.fileupload-validate.js"></script>
<script src="/mosaico/vendor/knockout-jqueryui.min.js"></script>
<script src="/mosaico/vendor/tinymce.min.js"></script>
<script src="/mosaico/mosaico.min.js?v=0.15"></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 = JSON.stringify(data);
Mosaico.init(options, plugins);
}, 'json');
} else {
Mosaico.init(options, plugins);
}
});
</script>
<link rel="stylesheet" href="/mosaico/mosaico-material.min.css?v=0.10" />
<link rel="stylesheet" href="/mosaico/vendor/notoregular/stylesheet.css" />
</head>
<body class="mo-standalone"></body>
</html>