Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
neoteric-editor / app / assets / javascripts / neoteric-editor / redactor.files.js
Size: Mime:
var RedactorPlugins = RedactorPlugins || {};

RedactorPlugins.files = {

  init: function() {
    this.opts.modal_file = this.createHtml();
    this.opts.toolbar.file.func = 'showFileModal';
  },

  createHtml: function() {
    return '' +
      '<div id="redactor_modal_content">' +
        '<div id="redactor_tabs">' +
          '<a href="javascript:void(null);" class="redactor_tabs_act">' + RLANG.upload + '</a>' +
          '<a href="javascript:void(null);">' + RLANG.choose + '</a>' +
        '</div>' +

        '<div id="redactor_tab1" class="redactor_tab">' +
          $(this.opts.modal_file).find('form').html() +
        '</div>' +

        '<div id="redactor_tab2" class="redactor_tab" style="display: none;">' +
          "<ul id='redactor_files_list'></ul>" +
        '</div>' +
      '</div>';
  },

  showFileModal: function() {
    this.addFileList();
    this.showFile();
  },

  addFileList: function() {
    if (!this.opts.fileGetJson) return;

    var that = this;

    $.getJSON(this.opts.fileGetJson, $.proxy(function(data) {
      $.each(data, function(k, v) {
        var file = data[k],
            item = $('' +
              "<li>" +
                "<a href='" + file.data.url + "'>" + file.data_file_name + "</a>" +
              "</li>");
        $('#redactor_files_list').append(item);

        $(item).find('a').click(function(e) {
          e.preventDefault();
          $.proxy(that.fileUploadCallback({
            filename: file.data_file_name,
            filelink: file.data.url
          }), that);
        });
      });

    }));
  }
};