initialize file selector soon as it's loaded
Conflicts: templates/post_form.html
This commit is contained in:
parent
3bd7f94861
commit
0005f11098
@ -5,12 +5,11 @@
|
|||||||
* $config['additional_javascript'][] = 'js/jquery.min.js';
|
* $config['additional_javascript'][] = 'js/jquery.min.js';
|
||||||
* $config['additional_javascript'][] = 'js/file-selector.js';
|
* $config['additional_javascript'][] = 'js/file-selector.js';
|
||||||
*/
|
*/
|
||||||
|
function init_file_selector() {
|
||||||
|
|
||||||
if (active_page == 'index' || active_page == 'thread') {
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
// add options panel item
|
||||||
// add options panel item
|
if (window.Options && Options.get_tab('general')) {
|
||||||
if (window.Options && Options.get_tab('general')) {
|
|
||||||
Options.extend_tab('general', '<label id="file-drag-drop"><input type="checkbox">' + _('Drag and drop file selection') + '</label>');
|
Options.extend_tab('general', '<label id="file-drag-drop"><input type="checkbox">' + _('Drag and drop file selection') + '</label>');
|
||||||
|
|
||||||
$('#file-drag-drop>input').on('click', function() {
|
$('#file-drag-drop>input').on('click', function() {
|
||||||
@ -23,16 +22,12 @@ if (window.Options && Options.get_tab('general')) {
|
|||||||
|
|
||||||
if (localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true';
|
if (localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true';
|
||||||
if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true);
|
if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// disabled by user, or incompatible browser.
|
// disabled by user, or incompatible browser.
|
||||||
// fallback to old
|
if (localStorage.file_dragdrop == 'false' || !(window.FileReader && window.File))
|
||||||
if (localStorage.file_dragdrop == 'false' || !(window.FileReader && window.File)) {
|
|
||||||
$('.dropzone-wrap').remove();
|
|
||||||
$('#upload_file').show();
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// multipost not enabled
|
// multipost not enabled
|
||||||
if (typeof max_images == 'undefined') {
|
if (typeof max_images == 'undefined') {
|
||||||
@ -40,6 +35,8 @@ if (typeof max_images == 'undefined') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var files = [];
|
var files = [];
|
||||||
|
$('#upload_file').hide(); // hide the original file selector
|
||||||
|
$('.dropzone-wrap').css('user-select', 'none').show(); // let jquery add browser specific prefix
|
||||||
|
|
||||||
function addFile(file) {
|
function addFile(file) {
|
||||||
if (files.length == max_images)
|
if (files.length == max_images)
|
||||||
@ -140,8 +137,6 @@ var dropHandlers = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$('#upload input[type=file]').hide(); // hide the original file selector
|
|
||||||
$('.dropzone-wrap').css('user-select', 'none').show(); // let jquery add browser specific prefix
|
|
||||||
|
|
||||||
// attach handlers
|
// attach handlers
|
||||||
$(document).on(dropHandlers, '.dropzone');
|
$(document).on(dropHandlers, '.dropzone');
|
||||||
@ -184,5 +179,4 @@ $(document).on('paste', function (e) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">if (typeof init_file_selector !== 'undefined') init_file_selector();</script>
|
||||||
|
|
||||||
{% if config.allow_upload_by_url %}
|
{% if config.allow_upload_by_url %}
|
||||||
<div style="float:none;text-align:left" id="upload_url">
|
<div style="float:none;text-align:left" id="upload_url">
|
||||||
<label for="file_url">{% trans %}Or URL{% endtrans %}</label>:
|
<label for="file_url">{% trans %}Or URL{% endtrans %}</label>:
|
||||||
|
Loading…
Reference in New Issue
Block a user