Source

cmsplugin-markup / cmsplugin_markup / templates / cmsplugin_markup / markup_plugin_change_form.html

{% extends "admin/cms/page/plugin_change_form.html" %}

{% load i18n %}

{% block top %}
{% if preview %}
<div id="plugin-preview">
{{ block.super }}
</div>
{% endif %}
{% endblock %}

{% block fieldsets %}
<div class="iftextplugins">
<select name="plugins">
<option value="" selected="selected">{% filter escapejs %}{% trans "Available Plugins" %}{% endfilter %}</option>{% for p in text_plugins %}
<option value="{{ p.value }}">{{ p.name }}</option>{% endfor %}
</select>
<span class="insert-object addlink">{% filter escapejs %}{% trans "Insert plugin" %}{% endfilter %}</span>
</div>
{{ block.super }}
{% endblock %}

{% block after_field_sets %}{{ block.super }}
<div class="iftextplugins">
<p class="help">{% trans "Note: Unused inserted plugins will be automatically removed when saving." %}</p>
<div id="plugins_list">
<ul></ul>
</div>
</div>
{% endblock %}

{% block extrahead %}{{ block.super }}
<script type="text/javascript" src="{{ CMS_MEDIA_URL }}js/csrf.js"></script>
<script type="text/javascript">
/* <![CDATA[ */
var plugin_id = '{{ plugin.id|escapejs }}';
var page_id = '{{ request.current_page.id|escapejs }}';
var auto_preview_timeout = 2.0;{% url cmsplugin_markup_preview as auto_preview_url %}
var auto_preview_url = '{{ auto_preview_url|escapejs }}';
/* ]]> */
</script>
<script type="text/javascript" src="{{ STATIC_URL|default:MEDIA_URL }}cmsplugin_markup/markup.js"></script>
<script type="text/javascript" src="{{ CMS_MEDIA_URL }}js/lib/ui.core.js"></script>
<script type="text/javascript" src="{{ CMS_MEDIA_URL }}js/placeholder_editor_registry.js"></script>
<script type="text/javascript">
/* <![CDATA[ */

var editPluginPopupCallbacks = {};
var markupPlugins = {};

{% include "cms/plugins/widgets/widget_lib.js" %}

function edit_plugin_click() {
  var obj = this;
  (function ($) {
    var texteditor = get_editor('{{ name|escapejs }}');
    if (texteditor == null || texteditor.selectedObject == null) {
      alert("{% filter escapejs %}{% trans "Text editor does not support editing objects." %}{% endfilter %}");
      return;
    }
    var objid = $(obj).closest('li').get(0);
    if (objid.id == null || objid.id.indexOf("plugin_obj_") != 0) {
      alert("{% filter escapejs %}{% trans "Not a plugin object" %}{% endfilter %}");
      return;
    }
    var plugin_id = objid.id.substr("plugin_obj_".length);
    edit_plugin_for_markup(plugin_id, '{{ name|escapejs }}');
  })(jQuery);
}

jQuery(document).ready(function($) {
  var c = new MarkupEditorPlaceholderBridge($('#id_body'));
  PlaceholderEditorRegistry.registerEditor('{{ name|escapejs }}', c);

  $('span.insert-object').click(function() {
    var select = $(this).parent().children("select");
    var pluginvalue = select.attr('value');
    var splits = window.location.href.split("?")[0].split("/");
    var parent_id = Number(splits[splits.length - 2]);
    var language = $('#id_language').attr('value');
    
    if (pluginvalue == "") {
      alert("{% filter escapejs %}{% trans "Please select a plugin type." %}{% endfilter %}");
      return;
    }
    
    var texteditor = get_editor('{{ name|escapejs }}');
    if (texteditor == null || texteditor.insertText == null) {
      alert("{% filter escapejs %}{% trans "Markup does not support inserting objects." %}{% endfilter %}");
      return;
    }
    
    add_plugin_for_markup(pluginvalue, parent_id, language, '{{ name|escapejs }}')
  }).css("cursor", "pointer").css("margin", "5px");

{% for p in used_plugins %}
  add_plugin_to_list('{{ p.pk|escapejs }}', '{{ p.get_instance_icon_src|escapejs }}', '{{ p.get_instance_icon_alt|escapejs }}');
{% endfor %}
});

{% for p in markup_plugins %}
markupPlugins['{{ p.identifier|escapejs }}'] = {
  'textenabled': {{ p.text_enabled_plugins|yesno:"true,false" }},
  'markup': {{ p.plugin_markup|default:"null" }},
  'regex': {{ p.plugin_regexp|default:"null" }}
};
{% endfor %}
/* ]]> */
</script>
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL|default:MEDIA_URL }}cmsplugin_markup/markup.css" />
<link rel="stylesheet" type="text/css" href="{{ CMS_MEDIA_URL }}css/jquery/cupertino/jquery-ui.css" />
{% endblock %}