提交 279d0ae8 编写于 作者: J James Kerr

Update the URL when changing mailer preview formats

Added javascript to update the URL on mailer previews with the
currently selected email format. Reloading the page now keeps you on
your selected format rather than going back to the default html version.
上级 71317e64
* Added javascript to update the URL on mailer previews with the currently
selected email format. Reloading the page now keeps you on your selected
format rather than going back to the default html version.
*James Kerr*
* Add fail fast to `bin/rails test`
Adding `--fail-fast` or `-f` when running tests will interrupt the run on
......
......@@ -94,7 +94,7 @@
<% if @email.multipart? %>
<dd>
<select onchange="document.getElementsByName('messageBody')[0].src=this.options[this.selectedIndex].value;">
<select onchange="formatChanged(this);">
<option <%= request.format == Mime[:html] ? 'selected' : '' %> value="?part=text%2Fhtml">View as HTML email</option>
<option <%= request.format == Mime[:text] ? 'selected' : '' %> value="?part=text%2Fplain">View as plain-text email</option>
</select>
......@@ -112,5 +112,19 @@
</p>
<% end %>
<script>
function formatChanged(form) {
var part_name = form.options[form.selectedIndex].value
var iframe =document.getElementsByName('messageBody')[0];
iframe.contentWindow.location.replace(part_name);
if (history.replaceState) {
var url = location.pathname.replace(/\.(txt|html)$/, '');
var format = /html/.test(part_name) ? '.html' : '.txt';
window.history.replaceState({}, '', url + format);
}
}
</script>
</body>
</html>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册