2013-08-07 07:49:02 +02:00
|
|
|
var wpWidgets;!function(a){wpWidgets={init:function(){var b,c,d=a("div.widgets-sortables"),e=isRtl?"marginRight":"marginLeft";a("#widgets-right").children(".widgets-holder-wrap").children(".sidebar-name").click(function(){var b=a(this).siblings(".widgets-sortables"),c=a(this).parent();c.hasClass("closed")?(c.removeClass("closed"),b.sortable("enable").sortable("refresh")):(b.sortable("disable"),c.addClass("closed"))}),a("#widgets-left").children(".widgets-holder-wrap").children(".sidebar-name").click(function(){a(this).parent().toggleClass("closed")}),d.each(function(){if(a(this).parent().hasClass("inactive"))return!0;var b=50,c=a(this).children(".widget").length;b+=parseInt(48*c,10),a(this).css("minHeight",b+"px")}),a(document.body).bind("click.widgets-toggle",function(b){var c,d,f,g=a(b.target),h={};g.parents(".widget-top").length&&!g.parents("#available-widgets").length?(c=g.closest("div.widget"),d=c.children(".widget-inside"),f=parseInt(c.find("input.widget-width").val(),10),d.is(":hidden")?(f>250&&d.closest("div.widgets-sortables").length&&(h.width=f+30+"px",d.closest("div.widget-liquid-right").length&&(h[e]=235-f+"px"),c.css(h)),wpWidgets.fixLabels(c),d.slideDown("fast")):d.slideUp("fast",function(){c.css({width:"",margin:""})}),b.preventDefault()):g.hasClass("widget-control-save")?(wpWidgets.save(g.closest("div.widget"),0,1,0),b.preventDefault()):g.hasClass("widget-control-remove")?(wpWidgets.save(g.closest("div.widget"),1,1,0),b.preventDefault()):g.hasClass("widget-control-close")&&(wpWidgets.close(g.closest("div.widget")),b.preventDefault())}),d.children(".widget").each(function(){wpWidgets.appendTitle(this),a("p.widget-error",this).length&&a("a.widget-action",this).click()}),a("#widget-list").children(".widget").draggable({connectToSortable:"div.widgets-sortables",handle:"> .widget-top > .widget-title",distance:2,helper:"clone",zIndex:100,containment:"document",start:function(a,b){b.helper.find("div.widget-description").hide(),c=this.id},stop:function(){b&&a(b).hide(),b=""}}),d.sortable({placeholder:"widget-placeholder",items:"> .widget",handle:"> .widget-top > .widget-title",cursor:"move",distance:2,containment:"document",start:function(a,b){b.item.children(".widget-inside").hide(),b.item.css({margin:"",width:""})},stop:function(d,e){if(e.item.hasClass("ui-draggable")&&e.item.data("draggable")&&e.item.draggable("destroy"),e.item.hasClass("deleting"))return wpWidgets.save(e.item,1,0,1),e.item.remove(),void 0;var f=e.item.find("input.add_new").val(),g=e.item.find("input.multi_number").val(),h=c,i=a(this).attr("id");return e.item.css({margin:"",width:""}),c="",f?("multi"==f?(e.item.html(e.item.html().replace(/<[^<>]+>/g,function(a){return a.replace(/__i__|%i%/g,g)})),e.item.attr("id",h.replace("__i__",g)),g++,a("div#"+h).find("input.multi_number").val(g)):"single"==f&&(e.item.attr("id","new-"+h),b="div#"+h),wpWidgets.save(e.item,0,0,1),e.item.find("input.add_new").val(""),e.item.find("a.widget-action").click(),void 0):(wpWidgets.saveOrder(i),void 0)},receive:function(b,c){var d=a(c.sender);a(this).is(":visible")&&-1==this.id.indexOf("orphaned_widgets")||d.sortable("cancel"),-1==d.attr("id").indexOf("orphaned_widgets")||d.children(".widget").length||d.parents(".orphan-sidebar").slideUp(400,function(){a(this).remove()})}}).sortable("option","connectWith","div.widgets-sortables").parent().filter(".closed").children(".widgets-sortables").sortable("disable"),a("#available-widgets").droppable({tolerance:"pointer",accept:function(b){return"widget-list"!=a(b).parent().attr("id")},drop:function(b,c){c.draggable.addClass("deleting"),a("#removing-widget").hide().children("span").html("")},over:function(b,c){c.draggable.addClass("deleting"),a("div.widget-placeholder").hide(),c.draggable.hasClass("ui-sortable-helper")&&a("#removing-widget").show().children("span").html(c.draggable.find("div.widget-title").children("h4").html())},out:function(b,c){c.draggable.removeClass("deleting"),a("div.widget-placeholder").show(),a("#removing-widget").hide().children("span").html("")}})},saveOrder:function(b){b&&a("#"+b).closest("div.widge
|