/* global redux_change */(function(e){"use strict";e.redux.group=e.group||{};e(document).ready(function(){e.redux.group()});e.redux.group=function(){e("#redux-groups-accordion").accordion({header:"> div > h3",collapsible:!0,active:!1,heightStyle:"content",icons:{header:"ui-icon-plus",activeHeader:"ui-icon-minus"}}).sortable({axis:"y",handle:"h3",stop:function(t,n){n.item.children("h3").triggerHandler("focusout");var r=e("input.slide-sort");r.each(function(t){e(this).val(t)})}});e(".redux-groups-accordion-group input[type=text]").on("keyup",function(t){e(this).parents(".redux-groups-accordion-group:first").find(".redux-groups-header").text(t.target.value);e(this).parents(".redux-groups-accordion-group:first").find(".slide-title").val(t.target.value)});e(".redux-groups-remove").live("click",function(){redux_change(e(this));e(this).parent().find('input[type="text"]').val("");e(this).parent().find('input[type="hidden"]').val("");e(this).parent().parent().slideUp("medium",function(){e(this).remove()})});e(".redux-groups-add").click(function(){var t=e(this).prev().find(".redux-groups-accordion-group:last").clone(!0),n=e(t).find('input[type="text"]').attr("name").match(/\d+(?!.*\d+)/),r=n*1+1;e(t).find("h3").text("").append('');e(this).prev().append(t);e(t).find('input[type="text"], input[type="hidden"], textarea , select').each(function(){var n=e(this).attr("name"),i=e(this).attr("id");typeof i!="undefined"&&i!==!1&&e(this).attr("id",e(this).attr("id").replace(/\d+(?!.*\d+)/,r));typeof n!="undefined"&&n!==!1&&e(this).attr("name",e(this).attr("name").replace(/\d+(?!.*\d+)/,r));if(e(this).prop("tagName")=="SELECT"){e(t).find(".select2-container").remove();e(t).find("select").removeClass("select2-offscreen")}e(this).val("");e(this).hasClass("slide-sort")&&e(this).val(r)})})}})(jQuery);