{% extends "filemanager/filemanager_base.html" %}

{% load i18n staticfiles %}

{% block content %}
{% include "filemanager/filemanager_breadcrumbs.html" %}

<form id="fileupload" data-url="{% url 'filemanager:upload-file' %}">
  <input type="hidden" name="path" value="{{path}}">
  <input type="file" name="files[]" multiple>
</form>

{% endblock %}

{% block js %}


<script src="{% static 'js/jquery.fileupload.js' %} "></script>
<script>
$(function () {
    $('#fileupload').fileupload({
      dataType: 'json',
      done: function(e, data) {
        $.each(data.result.files, function (index, file) {
        $('<p/>').text(file.name).appendTo(document.body);
      });
    }
  });
});

$("#gallery").on( "click", ".get_img", function(e){
    console.log('click');
    e.preventDefault();
    img = $(this).data('img');
    //top.tinymce.activeEditor.windowManager.close();
    //var selectedImage = img;

    var args = top.tinymce.activeEditor.windowManager.getParams();
    win = (args.window);
    input = (args.input);
    win.document.getElementById(input).value = img;
    console.log(win.document.getElementById(input).value)
    top.tinymce.activeEditor.windowManager.close();
});
</script>
{% endblock %}
