From 660cbcad7a5559c55b90d2e4232e6e495f3b0cbb Mon Sep 17 00:00:00 2001
From: Torsten Oppermann <torsten@sgalinski.de>
Date: Tue, 21 Feb 2017 18:43:33 +0100
Subject: [PATCH] [TASK] adding language labels in js. streamlined js

---
 Resources/Private/Language/de.locallang.xlf  |  8 +++++
 Resources/Private/Language/locallang.xlf     |  6 ++++
 Resources/Private/Layouts/Default.html       |  3 +-
 Resources/Private/Templates/Queue/Index.html |  4 +--
 Resources/Public/Scripts/Backend.js          | 35 ++++++++++++++++++++
 Resources/Public/Scripts/Template.js         | 15 ---------
 6 files changed, 52 insertions(+), 19 deletions(-)
 delete mode 100644 Resources/Public/Scripts/Template.js

diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf
index d01e54ff..7f10dd56 100644
--- a/Resources/Private/Language/de.locallang.xlf
+++ b/Resources/Private/Language/de.locallang.xlf
@@ -89,6 +89,14 @@
 			<source>Language (Reloads the page):</source>
 			<target>Sprache (lädt die Seite neu):</target>
 		</trans-unit>
+		<trans-unit id="backend.send_mail_again" approved="yes">
+			<source>Send this E-Mail again ?</source>
+			<target>Diese E-Mail nochmals versenden ?</target>
+		</trans-unit>
+		<trans-unit id="backend.send_mail_manually" approved="yes">
+			<source>Send this E-Mail now ?</source>
+			<target>Diese E-Mail jetzt versenden ?</target>
+		</trans-unit>
 		<trans-unit id="backend.send_test" approved="yes">
 			<source>Send Preview Mail</source>
 			<target>Sende Vorschau-Mail</target>
diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf
index 438b638a..15f1d1ac 100644
--- a/Resources/Private/Language/locallang.xlf
+++ b/Resources/Private/Language/locallang.xlf
@@ -69,6 +69,12 @@
 		<trans-unit id="backend.select_language">
 			<source>Language (Reloads the page):</source>
 		</trans-unit>
+		<trans-unit id="backend.send_mail_again">
+			<source>Send this E-Mail again ?</source>
+		</trans-unit>
+		<trans-unit id="backend.send_mail_manually">
+			<source>Send this E-Mail now ?</source>
+		</trans-unit>
 		<trans-unit id="backend.send_test">
 			<source>Send Preview Mail</source>
 		</trans-unit>
diff --git a/Resources/Private/Layouts/Default.html b/Resources/Private/Layouts/Default.html
index 756283a5..fc2dbc9b 100644
--- a/Resources/Private/Layouts/Default.html
+++ b/Resources/Private/Layouts/Default.html
@@ -1,8 +1,7 @@
 {namespace sgm=SGalinski\SgMail\ViewHelpers}
 <f:be.container enableClickMenu="FALSE" loadExtJs="FALSE" includeCssFiles="{0: '{f:uri.resource(path: \'StyleSheets/backend.css\')}'}">
-	<sgm:addJavaScriptFile javaScriptFile="{f:uri.resource(path: 'Scripts/Template.js')}" />
 	<sgm:addJavaScriptFile javaScriptFile="{f:uri.resource(path: 'Scripts/Backend.js')}" />
-	<sgm:inlineLanguageLabels labels="backend.delete_template" />
+	<sgm:inlineLanguageLabels labels="backend.delete_template, backend.send_mail_manually, backend.send_mail_again" />
 	<div class="module" data-module-id="" data-module-name="">
 		<div class="module-docheader t3js-module-docheader">
 			<div class="module-docheader-bar module-docheader-bar-navigation t3js-module-docheader-bar t3js-module-docheader-bar-navigation">
diff --git a/Resources/Private/Templates/Queue/Index.html b/Resources/Private/Templates/Queue/Index.html
index e6a6bb3a..f022b727 100644
--- a/Resources/Private/Templates/Queue/Index.html
+++ b/Resources/Private/Templates/Queue/Index.html
@@ -47,10 +47,10 @@
 					<td>
 						<f:if condition="{mail.sent} == '0'">
 							<f:then>
-								<f:link.action class="btn btn-primary" controller="Queue" action="sendMail" arguments="{uid: mail.uid}">Send Now</f:link.action>
+								<f:link.action class="btn-send-now btn btn-primary" controller="Queue" action="sendMail" arguments="{uid: mail.uid}">Send Now</f:link.action>
 							</f:then>
 							<f:else>
-								<f:link.action class="btn btn-warning" controller="Queue" action="sendMail" arguments="{uid: mail.uid}">Send Again</f:link.action>
+								<f:link.action class="btn-resend btn btn-warning" controller="Queue" action="sendMail" arguments="{uid: mail.uid}">Send Again</f:link.action>
 							</f:else>
 						</f:if>
 					</td>
diff --git a/Resources/Public/Scripts/Backend.js b/Resources/Public/Scripts/Backend.js
index e69de29b..268a5778 100644
--- a/Resources/Public/Scripts/Backend.js
+++ b/Resources/Public/Scripts/Backend.js
@@ -0,0 +1,35 @@
+(function($) {
+	function resetTemplateListener(_event) {
+		_event.preventDefault();
+
+		var confirm = SG.lang.SgMail['backend.delete_template'];
+		if (window.confirm(confirm)) {
+			window.location = $(_event.currentTarget).attr('href');
+		}
+	}
+
+	function sendMailListener(_event) {
+		_event.preventDefault();
+
+		var confirm = SG.lang.SgMail['backend.send_mail_manually'];
+		if (window.confirm(confirm)) {
+			window.location = $(_event.currentTarget).attr('href');
+		}
+	}
+
+	function resendMailListener(_event) {
+		_event.preventDefault();
+
+		var confirm = SG.lang.SgMail['backend.send_mail_again'];
+		if (window.confirm(confirm)) {
+			window.location = $(_event.currentTarget).attr('href');
+		}
+	}
+
+	$(document).ready(function() {
+		$('.reset-btn').on('click', resetTemplateListener);
+		$('.btn-send-now').on('click', sendMailListener);
+		$('.btn-resend').on('click', resendMailListener);
+	});
+})
+(TYPO3.jQuery);
diff --git a/Resources/Public/Scripts/Template.js b/Resources/Public/Scripts/Template.js
deleted file mode 100644
index 7e1e5a36..00000000
--- a/Resources/Public/Scripts/Template.js
+++ /dev/null
@@ -1,15 +0,0 @@
-(function($) {
-	function resetTemplateListener(_event) {
-		_event.preventDefault();
-
-		var confirm = SG.lang.SgMail['backend.delete_template'];
-		if (window.confirm(confirm)) {
-			window.location = $(_event.currentTarget).attr('href');
-		}
-	}
-
-	$(document).ready(function() {
-		$('.reset-btn').on('click', resetTemplateListener);
-	});
-})
-(TYPO3.jQuery);
-- 
GitLab