so it is reachable general from the whole website, and the dropzone-factory can use
it also to create dropzones from modal.js
'$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),
]);
}
}
'$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),
]);
}
'$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),
]);
}
}
'$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'];
}
'$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),
-
]);
'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),
]);
}
}
'$compose_link_title' => $this->t('Open Compose page'),
- // Dropzone
- '$max_imagesize' => round(Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')) / 1000000,1),
]);
return $output;
}
'$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),
]);
}
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();
})
};
- 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);
})
</div>
</div>
<script>
- dzFactory.setupDropzone('#dropzone-{{$id}}', 'comment-edit-text-{{$id}}', {{$max_imagesize}});
+ dzFactory.setupDropzone('#dropzone-{{$id}}', 'comment-edit-text-{{$id}}');
</script>
+++ /dev/null
-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;
-}
// 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();
<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')
});
<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 *}}
</script>
<script>
- dzFactory.setupDropzone('#jot-text-wrap', 'profile-jot-text', {{$max_imagesize}});
+ dzFactory.setupDropzone('#jot-text-wrap', 'profile-jot-text');
</script>