]> git.mxchange.org Git - friendica.git/commitdiff
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 5b225489ec3043edee0769145631c3654a9c5c01..a08b569ced6f70de8009dba728fb5e80b39fb0bf 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 965c04915cccead20ef31d04c9f149b355378b2e..45ec6be0fbf4c53e41ad427ba99cf3d13f435dc2 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 1d7430e1933a0b97dd0225296b20bfeb5a5ff219..f23333911b7ddc60edcc4d50f95412bf1e65969f 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 19726eb71799e85c2cd97f193b834a484747c807..f53158b1f7f40da9ec1edea89903e4cc1d273fb4 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 403908cc020bce9e8d8f45f3909f564a8db43b0c..5ddc250d8c4c6d7be7cd8ef44a420b012a10a5f4 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 c6ef5e3ba1b1e15d199538aedd4fc5a358dc261e..3f4d061a17eedecedeead127e4b9a6fd059cc052 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 5aaab503622be770c3ad8494972e479107d7a08e..bbf92625d819cb2a0c2c9291364a3febe4b31e53 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 499dfaffb2120a12d11de02bd66d08bb411d9139..09e42c90e5975203d06885265eed2d34ee75fef5 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 85c258c92f5cca98ee4322ca05f23617a0591377..905e78743437702f2f6baa726aa16f6541d5fe33 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 3d9860a10497d8ed099f700aaa0a074cd116b14b..81664cf0fee681919292dcab2c3c531b59d79ce6 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 436e3626b364132e8ee033bd962dc8306e62e4ac..8c5e0a999da53e3eec174b0e0400b6192e2c5085 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 325c8d5b3b5138a93c617cfb176e059158519811..5c18afa86f5ab968a4787ba28bd234163241bb14 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>