| Current Path : /var/www/iplanru/data/old/www/i-plan.ru/media/zoo/elements/repeatable/ |
| Current File : /var/www/iplanru/data/old/www/i-plan.ru/media/zoo/elements/repeatable/repeatable.js |
/* Copyright (C) YOOtheme GmbH, http://www.gnu.org/licenses/gpl.html GNU/GPL */
(function(b){var a=function(){};b.extend(a.prototype,{name:"ElementRepeatable",options:{msgDeleteElement:null,msgSortElement:null},initialize:function(e,a){this.options=b.extend({},this.options,a);var d=this,c=e.find("ul.repeatable-list"),g=c.find("li.hidden").remove(),h=c.find("li.repeatable-element").length;c.find("li.repeatable-element").each(function(){d.attachButtons(b(this))});c.delegate("span.sort","mousedown",function(){c.find(".more-options.show-advanced").removeClass("show-advanced")}).delegate("span.delete",
"click",function(){b(this).closest("li.repeatable-element").fadeOut(200,function(){b(this).remove()})}).sortable({handle:"span.sort",placeholder:"repeatable-element dragging",axis:"y",opacity:1,delay:100,cursorAt:{top:16},tolerance:"pointer",containment:"parent",scroll:false,start:function(b,a){a.item.addClass("ghost");a.placeholder.height(a.item.height()-2);a.placeholder.width(a.item.find("div.repeatable-content").width()-2)},stop:function(a,b){b.item.removeClass("ghost")}});e.find("p.add a").bind("click",
function(){var a=b("<li>").addClass("repeatable-element").html(g.html().replace(/(elements\[\S+])\[(-?\d+)\]/g,"$1["+h++ +"]"));d.attachButtons(a);a.appendTo(c);a.find("input").each(function(){b(this).val()&&b(this).val("")});a.children("div.repeatable-content").effect("highlight",{},1E3)})},attachButtons:function(a){a.children().wrapAll(b("<div>").addClass("repeatable-content"));b("<span>").addClass("sort").attr("title",this.options.msgSortElement).appendTo(a);b("<span>").addClass("delete").attr("title",
this.options.msgDeleteElement).appendTo(a)}});b.fn[a.prototype.name]=function(){var e=arguments,f=e[0]?e[0]:null;return this.each(function(){var d=b(this);if(a.prototype[f]&&d.data(a.prototype.name)&&f!="initialize")d.data(a.prototype.name)[f].apply(d.data(a.prototype.name),Array.prototype.slice.call(e,1));else if(!f||b.isPlainObject(f)){var c=new a;a.prototype.initialize&&c.initialize.apply(c,b.merge([d],e));d.data(a.prototype.name,c)}else b.error("Method "+f+" does not exist on jQuery."+a.name)})}})(jQuery);