summaryrefslogtreecommitdiff
blob: 4e0a3d10d2c65127707f18455e86c665df353a55 (plain)
1
2
3
/* Do not modify this file directly. It is compiled from other files. */
/* global isRtl, widget_conditions_parent_pages, widget_conditions_data, jQuery */
jQuery(function(i){var t=i("div#widgets-right");function n(t){var n,e;i("body").hasClass("wp-customizer")?t.find(".widget-inside").css("top",0):t.hasClass("expanded")?(t.attr("style")&&t.data("original-style",t.attr("style")),(n=t.width())<400&&(e=400-n,isRtl?t.css("position","relative").css("right","-"+e+"px").css("width","400px"):t.css("position","relative").css("left","-"+e+"px").css("width","400px"))):t.data("original-style")?t.attr("style",t.data("original-style")).data("original-style",null):t.removeAttr("style")}function e(i){var t=i.find("a.display-options").first();t.insertBefore(i.find("input.widget-control-save")),t.parent().removeClass("widget-control-noform").find(".spinner").remove().css("float","left").prependTo(t.parent())}function o(t){var n,e,o,s,a,c,l,r,h,p,g,u,f=t.find(".conditions-rule-minor").html(""),v=t.data("rule-major");if(v&&"post_type"!==v){for(n=t.data("rule-minor"),e=t.data("rule-has-children"),s=0,r=(o=widget_conditions_data[v]).length;s<r;s++)if(c=o[s][0],"object"==typeof(l=o[s][1])){for(u=i("<optgroup/>").attr("label",c),a=0,h=l.length;a<h;a++)p=o[s][1][a][0],g=o[s][1][a][1],u.append(i("<option/>").val(p).text(d(g.replace(/&nbsp;/g," "))));f.append(u)}else f.append(i("<option/>").val(c).text(d(l.replace(/&nbsp;/g," "))));f.removeAttr("disabled"),f.val(n),"page"===v&&n in widget_conditions_parent_pages?(f.siblings("span.conditions-rule-has-children").show(),e&&f.siblings("span.conditions-rule-has-children").find('input[type="checkbox"]').attr("checked","checked")):f.siblings("span.conditions-rule-has-children").hide().find('input[type="checkbox"]').removeAttr("checked")}else f.attr("disabled","disabled")}function s(t){var n=0;t.find("span.conditions-rule-has-children").find('input[type="checkbox"]').each(function(){i(this).attr("name","conditions[page_children]["+n+"]"),n++})}function d(i){var t=document.createElement("textarea");return t.innerHTML=i,t.value}t.length&&i(t).find(".widget-control-actions").length||(t=i("form#customize-controls")),i(".widget").each(function(){e(i(this))}),i(document).on("widget-added",function(i,t){0===t.find("div.widget-control-actions a.display-options").length&&e(t)}),t.on("click.widgetconditions","a.add-condition",function(t){var n=i(this).closest("div.condition"),e=n.clone().data("rule-major","").data("rule-minor","").data("has-children","").insertAfter(n);t.preventDefault(),e.find("select.conditions-rule-major").val(""),e.find("select.conditions-rule-minor").html("").attr("disabled"),e.find("span.conditions-rule-has-children").hide().find('input[type="checkbox"]').removeAttr("checked"),s(e.closest(".conditions"))}),t.on("click.widgetconditions","a.display-options",function(t){var e=i(this).closest("div.widget");t.preventDefault(),e.find("div.widget-conditional").toggleClass("widget-conditional-hide"),i(this).toggleClass("active"),e.toggleClass("expanded"),n(e),i(this).hasClass("active")?(e.find("input[name=widget-conditions-visible]").val("1"),e.find(".condition").each(function(){o(i(this))})):e.find("input[name=widget-conditions-visible]").val("0")}),t.on("click.widgetconditions","a.delete-condition",function(t){var n=i(this).closest("div.condition");t.preventDefault(),n.is(":first-child")&&n.is(":last-child")?(i(this).closest("div.widget").find("a.display-options").click(),n.find("select.conditions-rule-major").val("").change()):(n.find("select.conditions-rule-major").change(),n.detach()),s(n.closest(".conditions"))}),t.on("click.widgetconditions","div.widget-top",function(){var t=i(this).closest("div.widget"),e=t.find("a.display-options");e.hasClass("active")&&e.attr("opened","true"),e.attr("opened")&&(e.removeAttr("opened"),t.toggleClass("expanded"),n(t))}),t.on("change.widgetconditions","input.conditions-match-all",function(){i(this).parents(".widget-conditional").toggleClass("conjunction").toggleClass("intersection")}),i(document).on("change.widgetconditions","select.conditions-rule-major",function(){var t=i(this),n=t.siblings("select.conditions-rule-minor:first"),e=t.siblings("span.conditions-rule-has-children"),s=n.closest(".condition");s.data("rule-minor","").data("rule-major",t.val()),t.val()?o(s):(t.siblings("select.conditions-rule-minor").attr("disabled","disabled").html(""),e.hide().find('input[type="checkbox"]').removeAttr("checked"))}),i(document).on("change.widgetconditions","select.conditions-rule-minor",function(){var t=i(this),n=t.siblings("select.conditions-rule-major"),e=t.siblings("span.conditions-rule-has-children");t.closest(".condition").data("rule-minor",t.val()),"page"===n.val()&&t.val()in widget_conditions_parent_pages?e.show():e.hide().find('input[type="checkbox"]').removeAttr("checked")}),i(document).on("widget-updated widget-synced",function(t,n){n.find(".condition").each(function(){o(i(this))})})});