|
| 1 | +var postboxes; (function(a) { |
| 2 | + postboxes = { |
| 3 | + add_postbox_toggles: function(c, b) { |
| 4 | + this.init(c, b); |
| 5 | + a(".postbox h3, .postbox .handlediv").click(function() { |
| 6 | + var e = a(this).parent(".postbox"), |
| 7 | + f = e.attr("id"); |
| 8 | + if ("dashboard_browser_nag" == f) { |
| 9 | + return |
| 10 | + } |
| 11 | + e.toggleClass("closed"); |
| 12 | + postboxes.save_state(c); |
| 13 | + if (f) { |
| 14 | + if (!e.hasClass("closed") && a.isFunction(postboxes.pbshow)) { |
| 15 | + postboxes.pbshow(f) |
| 16 | + } else { |
| 17 | + if (e.hasClass("closed") && a.isFunction(postboxes.pbhide)) { |
| 18 | + postboxes.pbhide(f) |
| 19 | + } |
| 20 | + } |
| 21 | + } |
| 22 | + }); |
| 23 | + a(".postbox h3 a").click(function(f) { |
| 24 | + f.stopPropagation() |
| 25 | + }); |
| 26 | + a(".postbox a.dismiss").click(function(g) { |
| 27 | + var f = a(this).parents(".postbox").attr("id") + "-hide"; |
| 28 | + a("#" + f).prop("checked", false).triggerHandler("click"); |
| 29 | + return false |
| 30 | + }); |
| 31 | + a(".hide-postbox-tog").click(function() { |
| 32 | + var e = a(this).val(); |
| 33 | + if (a(this).prop("checked")) { |
| 34 | + a("#" + e).show(); |
| 35 | + if (a.isFunction(postboxes.pbshow)) { |
| 36 | + postboxes.pbshow(e) |
| 37 | + } |
| 38 | + } else { |
| 39 | + a("#" + e).hide(); |
| 40 | + if (a.isFunction(postboxes.pbhide)) { |
| 41 | + postboxes.pbhide(e) |
| 42 | + } |
| 43 | + } |
| 44 | + postboxes.save_state(c) |
| 45 | + }); |
| 46 | + a('.columns-prefs input[type="radio"]').click(function() { |
| 47 | + var e = a(this).val(), |
| 48 | + f, |
| 49 | + g, |
| 50 | + h = a("#poststuff"); |
| 51 | + if (h.length) { |
| 52 | + if (e == 2) { |
| 53 | + h.addClass("has-right-sidebar"); |
| 54 | + a("#side-sortables").addClass("temp-border") |
| 55 | + } else { |
| 56 | + if (e == 1) { |
| 57 | + h.removeClass("has-right-sidebar"); |
| 58 | + a("#normal-sortables").append(a("#side-sortables").children(".postbox")) |
| 59 | + } |
| 60 | + } |
| 61 | + } else { |
| 62 | + for (f = 4; (f > e && f > 1); f--) { |
| 63 | + g = a("#" + d(f) + "-sortables"); |
| 64 | + a("#" + d(f - 1) + "-sortables").append(g.children(".postbox")); |
| 65 | + g.parent().hide() |
| 66 | + } |
| 67 | + for (f = 1; f <= e; f++) { |
| 68 | + g = a("#" + d(f) + "-sortables"); |
| 69 | + if (g.parent().is(":hidden")) { |
| 70 | + g.addClass("temp-border").parent().show() |
| 71 | + } |
| 72 | + } |
| 73 | + a(".postbox-container:visible").css("width", 98 / e + "%") |
| 74 | + } |
| 75 | + postboxes.save_order(c) |
| 76 | + }); |
| 77 | + function d(e) { |
| 78 | + switch (e) { |
| 79 | + case 1: |
| 80 | + return "normal"; |
| 81 | + break; |
| 82 | + case 2: |
| 83 | + return "side"; |
| 84 | + break; |
| 85 | + case 3: |
| 86 | + return "column3"; |
| 87 | + break; |
| 88 | + case 4: |
| 89 | + return "column4"; |
| 90 | + break; |
| 91 | + default: |
| 92 | + return "" |
| 93 | + } |
| 94 | + } |
| 95 | + }, |
| 96 | + init: function(c, b) { |
| 97 | + a.extend(this, b || {}); |
| 98 | + a("#wpbody-content").css("overflow", "hidden"); |
| 99 | + a(".meta-box-sortables").sortable({ |
| 100 | + placeholder: "sortable-placeholder", |
| 101 | + connectWith: ".meta-box-sortables", |
| 102 | + items: ".postbox", |
| 103 | + handle: ".hndle", |
| 104 | + cursor: "move", |
| 105 | + distance: 2, |
| 106 | + tolerance: "pointer", |
| 107 | + forcePlaceholderSize: true, |
| 108 | + helper: "clone", |
| 109 | + opacity: 0.65, |
| 110 | + stop: function(f, d) { |
| 111 | + if (a(this).find("#dashboard_browser_nag").is(":visible") && "dashboard_browser_nag" != this.firstChild.id) { |
| 112 | + a(this).sortable("cancel"); |
| 113 | + return |
| 114 | + } |
| 115 | + postboxes.save_order(c); |
| 116 | + d.item.parent().removeClass("temp-border") |
| 117 | + }, |
| 118 | + receive: function(f, d) { |
| 119 | + if ("dashboard_browser_nag" == d.item[0].id) { |
| 120 | + a(d.sender).sortable("cancel") |
| 121 | + } |
| 122 | + } |
| 123 | + }) |
| 124 | + }, |
| 125 | + save_state: function(d) { |
| 126 | + var b = a(".postbox").filter(".closed").map(function() { |
| 127 | + return this.id |
| 128 | + }).get().join(","), |
| 129 | + c = a(".postbox").filter(":hidden").map(function() { |
| 130 | + return this.id |
| 131 | + }).get().join(","); |
| 132 | + a.post(ajaxurl, { |
| 133 | + action: "closed-postboxes", |
| 134 | + closed: b, |
| 135 | + hidden: c, |
| 136 | + closedpostboxesnonce: jQuery("#closedpostboxesnonce").val(), |
| 137 | + page: d |
| 138 | + }) |
| 139 | + }, |
| 140 | + save_order: function(c) { |
| 141 | + var b, |
| 142 | + d = a(".columns-prefs input:checked").val() || 0; |
| 143 | + b = { |
| 144 | + action: "meta-box-order", |
| 145 | + _ajax_nonce: a("#meta-box-order-nonce").val(), |
| 146 | + page_columns: d, |
| 147 | + page: c |
| 148 | + }; |
| 149 | + a(".meta-box-sortables").each(function() { |
| 150 | + b["order[" + this.id.split("-")[0] + "]"] = a(this).sortable("toArray").join(",") |
| 151 | + }); |
| 152 | + a.post(ajaxurl, b) |
| 153 | + }, |
| 154 | + pbshow: false, |
| 155 | + pbhide: false |
| 156 | + } |
| 157 | +} (jQuery)); |
| 158 | +var ajaxWidgets, |
| 159 | +ajaxPopulateWidgets, |
| 160 | +quickPressLoad; |
| 161 | +jQuery(document).ready(function(a) { |
| 162 | + ajaxWidgets = ["dashboard_incoming_links", "dashboard_primary", "dashboard_secondary", "dashboard_plugins"]; |
| 163 | + ajaxPopulateWidgets = function(c) { |
| 164 | + function b(d, h) { |
| 165 | + var g, |
| 166 | + f = a("#" + h + " div.inside:visible").find(".widget-loading"); |
| 167 | + if (f.length) { |
| 168 | + g = f.parent(); |
| 169 | + setTimeout(function() { |
| 170 | + g.load(ajaxurl.replace("/admin-ajax.php", "") + "/index-extra.php?jax=" + h, "", |
| 171 | + function() { |
| 172 | + g.hide().slideDown("normal", |
| 173 | + function() { |
| 174 | + a(this).css("display", "") |
| 175 | + }) |
| 176 | + }) |
| 177 | + }, |
| 178 | + d * 500) |
| 179 | + } |
| 180 | + } |
| 181 | + if (c) { |
| 182 | + c = c.toString(); |
| 183 | + if (a.inArray(c, ajaxWidgets) != -1) { |
| 184 | + b(0, c) |
| 185 | + } |
| 186 | + } else { |
| 187 | + a.each(ajaxWidgets, b) |
| 188 | + } |
| 189 | + }; |
| 190 | + ajaxPopulateWidgets(); |
| 191 | + postboxes.add_postbox_toggles(pagenow, { |
| 192 | + pbshow: ajaxPopulateWidgets |
| 193 | + }); |
| 194 | + quickPressLoad = function() { |
| 195 | + var b = a("#quickpost-action"), |
| 196 | + c; |
| 197 | + c = a("#quick-press").submit(function() { |
| 198 | + a("#dashboard_quick_press #publishing-action img.waiting").css("visibility", "visible"); |
| 199 | + a('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop("disabled", true); |
| 200 | + if ("post" == b.val()) { |
| 201 | + b.val("post-quickpress-publish") |
| 202 | + } |
| 203 | + a("#dashboard_quick_press div.inside").load(c.attr("action"), c.serializeArray(), |
| 204 | + function() { |
| 205 | + a("#dashboard_quick_press #publishing-action img.waiting").css("visibility", "hidden"); |
| 206 | + a('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop("disabled", false); |
| 207 | + a("#dashboard_quick_press ul").next("p").remove(); |
| 208 | + a("#dashboard_quick_press ul").find("li").each(function() { |
| 209 | + a("#dashboard_recent_drafts ul").prepend(this) |
| 210 | + }).end().remove(); |
| 211 | + quickPressLoad() |
| 212 | + }); |
| 213 | + return false |
| 214 | + }); |
| 215 | + a("#publish").click(function() { |
| 216 | + b.val("post-quickpress-publish") |
| 217 | + }) |
| 218 | + }; |
| 219 | + quickPressLoad() |
| 220 | +}); |
| 221 | + |
0 commit comments