render max_imagesize in header.tpl
authorJakobus Schürz <jakobus.schuerz@schuerz.at>
Wed, 15 Mar 2023 20:48:17 +0000 (21:48 +0100)
committerJakobus Schürz <jakobus.schuerz@schuerz.at>
Sun, 19 Mar 2023 17:52:46 +0000 (18:52 +0100)
so it is reachable general from the whole website, and the dropzone-factory can use
it also to create dropzones from modal.js

13 files changed:
mod/photos.php
src/App/Page.php
src/Content/Conversation.php
src/Module/Item/Compose.php
src/Module/Post/Edit.php
src/Object/Post.php
view/js/dropzone-factory.js
view/templates/item/compose.tpl
view/theme/frio/js/dropzone-frio.js [deleted file]
view/theme/frio/js/modal.js
view/theme/frio/templates/comment_item.tpl
view/theme/frio/templates/head.tpl
view/theme/frio/templates/jot.tpl

index 5b22548..a08b569 100644 (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),
                                                ]);
                                        }
                                }
index 965c049..45ec6be 100644 (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'];
        }
 
index 1d7430e..f233339 100644 (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),
-
                ]);
 
 
index 19726eb..f53158b 100644 (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),
                ]);
        }
 }
index 403908c..5ddc250 100644 (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;
        }
index c6ef5e3..3f4d061 100644 (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),
                        ]);
                }
 
index 5aaab50..bbf9262 100644 (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);
                })
index 499dfaf..09e42c9 100644 (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>
diff --git a/view/theme/frio/js/dropzone-frio.js b/view/theme/frio/js/dropzone-frio.js
deleted file mode 100644 (file)
index c165633..0000000
+++ /dev/null
@@ -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;
-}
index 85c258c..905e787 100644 (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();
index 3d9860a..81664cf 100644 (file)
 
 <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')
        });
index 436e362..8c5e0a9 100644 (file)
        <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 *}}
index 325c8d5..5c18afa 100644 (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>