Added NextCloud

Taken from https://github.com/pierre-alain-b/snappymail-nextcloud
This commit is contained in:
djmaze 2021-07-17 08:38:21 +02:00
parent 2dde6c59eb
commit 65200af210
32 changed files with 1713 additions and 1 deletions

View file

@ -0,0 +1,12 @@
/**
* Nextcloud - SnappyMail mail plugin
*
* @author SnappyMail Team, Nextgen-Networks (@nextgen-networks), Tab Fitts (@tabp0le), Pierre-Alain Bandinelli (@pierre-alain-b)
*
* Based initially on https://github.com/SnappyMail/snappymail-webmail/tree/master/build/owncloud
*/
$(function() {
SnappyMailFormHelper('#mail-snappymail-admin-form', 'admin.php');
});

View file

@ -0,0 +1,12 @@
/**
* Nextcloud - SnappyMail mail plugin
*
* @author SnappyMail Team, Nextgen-Networks (@nextgen-networks), Tab Fitts (@tabp0le), Pierre-Alain Bandinelli (@pierre-alain-b)
*
* Based initially on https://github.com/SnappyMail/snappymail-webmail/tree/master/build/owncloud
*/
$(function() {
SnappyMailFormHelper('#mail-snappymail-personal-form', 'personal.php');
});

View file

@ -0,0 +1,114 @@
// Do the following things once the document is fully loaded.
document.onreadystatechange = function () {
if (document.readyState === 'complete') {
watchIFrameTitle();
}
}
// The SnappyMail application is already configured to modify the <title> element
// of its root document with the number of unread messages in the inbox.
// However, its document is the SnappyMail iframe. This function sets up a
// Mutation Observer to watch the <title> element of the iframe for changes in
// the unread message count and propagates that to the parent <title> element,
// allowing the unread message count to be displayed in the NC tab's text when
// the SnappyMail app is selected.
function watchIFrameTitle() {
iframe = document.getElementById('rliframe');
if (!iframe) {
return;
}
target = iframe.contentDocument.getElementsByTagName('title')[0];
config = {
characterData: true,
childList: true,
subtree: true
}
observer = new MutationObserver(function(mutations) {
title = mutations[0].target.innerText;
if (title) {
matches = title.match(/\(([0-9]+)\)/);
if (matches) {
document.title = '('+ matches[1] + ') ' + t('snappymail', 'Email') + ' - Nextcloud';
} else {
document.title = t('snappymail', 'Email') + ' - Nextcloud';
}
}
});
observer.observe(target, config);
}
function SnappyMailFormHelper(sID, sAjaxFile, fCallback)
{
try
{
var
oForm = $(sID),
oSubmit = $('#snappymail-save-button', oForm),
sSubmitValue = oSubmit.val(),
oDesc = oForm.find('.snappymail-result-desc')
;
oSubmit.click(function (oEvent) {
var oDefAjax = null;
oEvent.preventDefault();
oForm
.addClass('snappymail-ajax')
.removeClass('snappymail-error')
.removeClass('snappymail-success')
;
oDesc.text('');
oSubmit.val('...');
oDefAjax = $.ajax({
'type': 'POST',
'async': true,
'url': OC.filePath('snappymail', 'ajax', sAjaxFile),
'data': oForm.serialize(),
'dataType': 'json',
'global': true
});
oDefAjax.always(function (oData) {
var bResult = false;
oForm.removeClass('snappymail-ajax');
oSubmit.val(sSubmitValue);
if (oData)
{
bResult = 'success' === oData['status'];
if (oData['Message'])
{
oDesc.text(t('snappymail', oData['Message']));
}
}
if (bResult)
{
oForm.addClass('snappymail-success');
}
else
{
oForm.addClass('snappymail-error');
if ('' === oDesc.text())
{
oDesc.text(t('snappymail', 'Error'));
}
}
if (fCallback)
{
fCallback(bResult, oData);
}
});
return false;
});
}
catch(e) {}
}

View file

@ -0,0 +1,26 @@
$(function (window, document) {
var
buffer = 0, //was 5 but this was creating a white space of 5px at the bottom of the page
ifr = document.getElementById('rliframe')
;
function pageY(elem) {
return elem.offsetParent ? (elem.offsetTop + pageY(elem.offsetParent)) : elem.offsetTop;
}
function resizeIframe() {
var height = document.documentElement.clientHeight;
height -= pageY(ifr) + buffer;
height = (height < 0) ? 0 : height;
ifr.style.height = height + 'px';
}
if (ifr)
{
ifr.onload = resizeIframe;
window.onresize = resizeIframe;
}
}(window, document));