From 5760d72bcd0e1f628c927eec3339d16d118a4ff1 Mon Sep 17 00:00:00 2001 From: James Hillyerd Date: Sun, 23 Aug 2015 19:15:13 -0700 Subject: [PATCH] Extract mailbox javascript --- themes/bootstrap/public/mailbox.js | 59 +++++++++++++++ themes/bootstrap/templates/mailbox/index.html | 73 ++----------------- 2 files changed, 66 insertions(+), 66 deletions(-) create mode 100644 themes/bootstrap/public/mailbox.js diff --git a/themes/bootstrap/public/mailbox.js b/themes/bootstrap/public/mailbox.js new file mode 100644 index 0000000..900aff2 --- /dev/null +++ b/themes/bootstrap/public/mailbox.js @@ -0,0 +1,59 @@ +function messageLoaded(responseText, textStatus, XMLHttpRequest) { + if (textStatus == "error") { + alert("Failed to load message, server said:\n" + responseText); + } else { + window.scrollTo(0,0); + } +} + +function listLoaded() { + $('.listEntry').click( + function() { + $('.listEntry').removeClass("disabled"); + $(this).addClass("disabled"); + $('#emailContent').load('/mailbox/' + mailbox + '/' + this.id, messageLoaded); + selected = this.id; + } + ) + $("#messageList").slideDown(); + if (selected != "") { + $("#" + selected).click(); + selected = ""; + } +} + +function loadList() { + $('#messageList').load('/mailbox/' + mailbox, listLoaded); +} + +function reloadList() { + $('#messageList').hide(); + loadList(); +} + +function listInit() { + $("#messageList").hide(); + loadList(); +} + +function deleteMessage(id) { + $('#emailContent').empty(); + $.ajax({ + type: 'DELETE', + url: '/mailbox/' + mailbox + '/' + id, + success: reloadList + }) +} + +function htmlView(id) { + window.open('/mailbox/' + mailbox + '/' + id + "/html", '_blank', + 'width=800,height=600,' + + 'menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes'); +} + +function messageSource(id) { + window.open('/mailbox/' + mailbox + '/' + id + "/source", '_blank', + 'width=800,height=600,' + + 'menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no'); +} + diff --git a/themes/bootstrap/templates/mailbox/index.html b/themes/bootstrap/templates/mailbox/index.html index b5ec23f..5989f37 100644 --- a/themes/bootstrap/templates/mailbox/index.html +++ b/themes/bootstrap/templates/mailbox/index.html @@ -1,75 +1,16 @@ {{define "title"}}{{printf "Inbucket for %v" .name}}{{end}} -{{define "navMail"}}true{{end}} {{$name := .name}} {{define "script"}} + {{end}}