Permalink
Browse files

Merge pull request #1514 from pascalmouret/develop

multi plugin frontend moving
  • Loading branch information...
2 parents c9b232a + c6ad012 commit 41c50e2aba68501a9810533a7d1e2ac9af2f98bf @digi604 digi604 committed Nov 14, 2012
Showing with 18 additions and 14 deletions.
  1. +14 −12 cms/static/cms/js/plugins/cms.placeholders.js
  2. +4 −2 cms/templates/cms/toolbar/placeholder_wrapper.html
@@ -189,7 +189,13 @@ CMS.$(document).ready(function ($) {
// save reference to this class
var that = this;
// get all siblings within the placeholder
- var holders = plugin.siblings('.cms_placeholder').andSelf();
+ var plugin_id = $(plugin).attr('id').split("-")[1];
+ var multi = $('#cms_placeholder_multi-'+plugin_id)
+ if(multi.length > 0) {
+ plugin = multi
+ }
+
+ var holders = plugin.siblings('.cms_moveable').andSelf();
// get selected index and bound
var index = holders.index(plugin);
var bound = holders.length;
@@ -204,6 +210,10 @@ CMS.$(document).ready(function ($) {
var array = [];
holders.each(function (index, item) {
+ if($(item).hasClass('cms_multi')) {
+ var item_id = $(item).attr('id').split("-")[1];
+ var item = $('#cms_placeholder-'+item_id)
+ }
array.push($(item).data('options').plugin_id);
});
// remove current array
@@ -218,6 +228,7 @@ CMS.$(document).ready(function ($) {
// add array to new position
if(dir === 'moveup') array.splice(index-1, 0, values.plugin_id);
if(dir === 'movedown') array.splice(index+1, 0, values.plugin_id);
+
// now lets do the ajax request
$.ajax({
'type': 'POST',
@@ -252,18 +263,9 @@ CMS.$(document).ready(function ($) {
if(before){
plugin.insertBefore(target);
}else{
- var target_content = $("#cms_placeholdercontent-"+target_id);
- if(target_content.length > 0){
- plugin.insertAfter(target_content);
- }else{
- plugin.insertAfter(target);
- }
- }
- var content = $("#cms_placeholdercontent-"+values.plugin_id);
- if(content.length > 0){
- content.insertAfter($("#cms_placeholder-"+values.plugin_id));
+ plugin.insertAfter(target);
}
-
+
// close overlay
that.hideOverlay();
@@ -26,5 +26,7 @@
});
</script>
{% endaddtoblock %}
-<div id="cms_placeholder-{{ instance.pk }}" class="cms_placeholder cms_placeholder_slot::{{ instance.placeholder.slot }}">{% if instance.get_plugin_class.allow_children %}{{ instance.get_plugin_class.name }}{% else %}{{ rendered_content }}{% endif %}</div>
-{% if instance.get_plugin_class.allow_children %}<div id="cms_placeholdercontent-{{ instance.pk }}">{{ rendered_content }}</div>{% endif %}
+{% if instance.get_plugin_class.allow_children %}<div class="cms_moveable cms_multi" id="cms_placeholder_multi-{{ instance.pk }}">{% endif %}
+<div id="cms_placeholder-{{ instance.pk }}" class="{% if not instance.get_plugin_class.allow_children %}cms_moveable{% endif %} cms_placeholder cms_placeholder_slot::{{ instance.placeholder.slot }}">{% if instance.get_plugin_class.allow_children %}{{ instance.get_plugin_class.name }}{% else %}{{ rendered_content }}{% endif %}</div>
+{% if instance.get_plugin_class.allow_children %}{{ rendered_content }}{% endif %}
+{% if instance.get_plugin_class.allow_children %}</div>{% endif %}

0 comments on commit 41c50e2

Please sign in to comment.