render max_imagesize in header.tpl

so it is reachable general from the whole website, and the dropzone-factory can use
it also to create dropzones from modal.js
This commit is contained in:
Jakobus Schürz 2023-03-15 21:48:17 +01:00
parent 16f065e260
commit 920dcca263
13 changed files with 19 additions and 56 deletions

View File

@ -1139,8 +1139,6 @@ function photos_content(App $a)
'$loading' => DI::l10n()->t('Loading...'),
'$qcomment' => $qcomment,
'$rand_num' => Crypto::randomDigits(12),
// Dropzone
'$max_imagesize' => round(\Friendica\Util\Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000, 1),
]);
}
}
@ -1196,8 +1194,6 @@ function photos_content(App $a)
'$preview' => DI::l10n()->t('Preview'),
'$qcomment' => $qcomment,
'$rand_num' => Crypto::randomDigits(12),
// Dropzone
'$max_imagesize' => round(Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000, 1),
]);
}
@ -1272,8 +1268,6 @@ function photos_content(App $a)
'$preview' => DI::l10n()->t('Preview'),
'$qcomment' => $qcomment,
'$rand_num' => Crypto::randomDigits(12),
// Dropzone
'$max_imagesize' => round(Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000, 1),
]);
}
}

View File

@ -253,11 +253,15 @@ class Page implements ArrayAccess
'$touch_icon' => $touch_icon,
'$block_public' => intval($config->get('system', 'block_public')),
'$stylesheets' => $this->stylesheets,
'$likeError' => $l10n->t('Like not successfull'),
'$dislikeError' => $l10n->t('Dislike not successfull'),
'$announceError' => $l10n->t('Sharing not successfull'),
'$srvError' => $l10n->t('Backend error'),
'$netError' => $l10n->t('Network error'),
'$likeError' => $l10n->t('Like not successfull'),
'$dislikeError' => $l10n->t('Dislike not successfull'),
'$announceError' => $l10n->t('Sharing not successfull'),
'$srvError' => $l10n->t('Backend error'),
'$netError' => $l10n->t('Network error'),
// Dropzone
'$max_imagesize' => round(\Friendica\Util\Strings::getBytesFromShorthand($config->get('system', 'maximagesize')) / 1000000, 1),
]) . $this->page['htmlhead'];
}

View File

@ -409,9 +409,6 @@ class Conversation
'$compose_link_title' => $this->l10n->t('Open Compose page'),
'$always_open_compose' => $this->pConfig->get($this->session->getLocalUserId(), 'frio', 'always_open_compose', false),
// Dropzone
'$max_imagesize' => round(\Friendica\Util\Strings::getBytesFromShorthand($this->config->get('system', 'maximagesize')) / 1000000, 1),
]);

View File

@ -240,9 +240,6 @@ class Compose extends BaseModule
'deny_cid' => $contact_deny_list,
'deny_gid' => $group_deny_list,
]),
// Dropzone
'$max_imagesize' => round(\Friendica\Util\Strings::getBytesFromShorthand($this->config->get('system', 'maximagesize')) / 1000000, 1),
]);
}
}

View File

@ -185,8 +185,6 @@ class Edit extends BaseModule
'$compose_link_title' => $this->t('Open Compose page'),
// Dropzone
'$max_imagesize' => round(Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000,1),
]);
return $output;
}

View File

@ -1069,8 +1069,6 @@ class Post
'$preview' => DI::l10n()->t('Preview'),
'$indent' => $indent,
'$rand_num' => Crypto::randomDigits(12),
// Dropzone
'$max_imagesize' => round(\Friendica\Util\Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000,1),
]);
}

View File

@ -1,8 +1,8 @@
var DzFactory = function () {
this.createDropzone = function(dropSelector, textareaSelector, maxImagesize) {
this.createDropzone = function(dropSelector, textareaSelector) {
return new Dropzone( dropSelector, {
paramName: 'userfile', // The name that will be used to transfer the file
maxFilesize: maxImagesize, // MB
maxFilesize: max_imagesize, // MB
url: '/media/photo/upload?response=url&album=',
accept: function(file, done) {
done();
@ -52,8 +52,8 @@ var DzFactory = function () {
})
};
this.setupDropzone = function(dropSelector, textareaSelector, maxImagesize) {
var dropzone = this.createDropzone(dropSelector, textareaSelector, maxImagesize);
this.setupDropzone = function(dropSelector, textareaSelector) {
var dropzone = this.createDropzone(dropSelector, textareaSelector);
$(dropSelector).on('paste', function(event) {
dzFactory.copyPaste(event, dropzone);
})

View File

@ -96,5 +96,5 @@
</div>
</div>
<script>
dzFactory.setupDropzone('#dropzone-{{$id}}', 'comment-edit-text-{{$id}}', {{$max_imagesize}});
dzFactory.setupDropzone('#dropzone-{{$id}}', 'comment-edit-text-{{$id}}');
</script>

View File

@ -1,24 +0,0 @@
function isInteger(value) {
return /^\d+$/.test(value);
}
function getMBytes(value) {
var res;
if (isInteger(value)) {
res = value;
} else {
eh = value.slice(-1);
am = Number(value.slice(0, -1));
switch (eh) {
case 'k':
res = am * 1024;
break;
case 'm':
res = am * 1024 * 1024;
break;
case 'g':
res = am * 1024 * 1024 * 1024;
}
}
return res / 1000000;
}

View File

@ -293,8 +293,7 @@ function editpost(url) {
// To make dropzone fileupload work on editing a comment, we need to
// attach a new dropzone to modal
console.log("modal.js max_imagesize",'{{$max_imagesize}}');
dzFactory.setupDropzone('#jot-text-wrap', 'profile-jot-text', '{{$max_imagesize}}');
dzFactory.setupDropzone('#jot-text-wrap', 'profile-jot-text');
modal.show();
$("#jot-popup").show();

View File

@ -67,12 +67,12 @@
<script>
$('[id=comment-fake-text-{{$id}}]').on('focus', function() {
dzFactory.setupDropzone('#dropzone-{{$id}}', 'comment-edit-text-{{$id}}', {{$max_imagesize}});
dzFactory.setupDropzone('#dropzone-{{$id}}', 'comment-edit-text-{{$id}}');
$('[id=comment-fake-text-{{$id}}]').prop('focus', null).off('focus')
$('[id=comment-{{$id}}]').prop('click', null).off('click')
});
$('[id=comment-{{$id}}]').on('click', function() {
dzFactory.setupDropzone('#dropzone-{{$id}}', 'comment-edit-text-{{$id}}', {{$max_imagesize}});
dzFactory.setupDropzone('#dropzone-{{$id}}', 'comment-edit-text-{{$id}}');
$('[id=comment-fake-text-{{$id}}]').prop('focus', null).off('focus')
$('[id=comment-{{$id}}]').prop('click', null).off('click')
});

View File

@ -141,7 +141,7 @@
<script type="text/javascript" src="view/theme/frio/js/textedit.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
<script type="text/javascript" src="vendor/enyo/dropzone/dist/min/dropzone.min.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
<script type="text/javascript" src="view/js/dropzone-factory.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
<script type="text/javascript"> var dzFactory = new DzFactory(); Dropzone.autoDiscover = false;</script>
<script type="text/javascript"> max_imagesize = {{$max_imagesize}}; var dzFactory = new DzFactory(); Dropzone.autoDiscover = false; </script>
{{* Include the strings which are needed for some js functions (e.g. translation)
They are loaded into the html <head> so that js functions can use them *}}

View File

@ -180,5 +180,5 @@ can load different content into the jot modal (e.g. the item edit jot)
</script>
<script>
dzFactory.setupDropzone('#jot-text-wrap', 'profile-jot-text', {{$max_imagesize}});
dzFactory.setupDropzone('#jot-text-wrap', 'profile-jot-text');
</script>