/*! Custom Sidebars - v2.1.08
* http://premium.wpmudev.org/project/the-pop-over-plugin/
* Copyright (c) 2016; * Licensed GPLv2+ */
function trim(e){e=e.replace(/^\s\s*/,"");for(var i=e.length-1;i>=0;i--)if(/\S/.test(e.charAt(i))){e=e.substring(0,i+1);break}return e}function CsSidebar(e,i){var t;this.id=e.split("%").join("\\%"),this.type=i,this.sb=jQuery("#"+this.id),this.widgets="",this.name=trim(this.sb.find(".sidebar-name h3").text()),this.description=trim(this.sb.find(".sidebar-description").text()),t="custom"===i?window.csSidebars.extras.find(".cs-custom-sidebar").clone():window.csSidebars.extras.find(".cs-theme-sidebar").clone(),this.sb.parent().append(t),t.find("label").each(function(){var i=jQuery(this);window.csSidebars.addIdToLabel(i,e)})}CsSidebar.prototype.getID=function(){return this.id.split("\\").join("")},window.csSidebars=null,function(){window.csSidebars={sidebars:[],sidebar_prefix:"cs-",edit_form:null,delete_form:null,export_form:null,location_form:null,right:null,extras:null,action_handlers:{},init:function(){"undefined"!=typeof csSidebarsData&&csSidebars.initControls().initTopTools().initSidebars().initToolbars().initColumns()},initControls:function(){return csSidebars.right=jQuery("#widgets-right"),csSidebars.extras=jQuery("#cs-widgets-extra"),null===csSidebars.edit_form&&(csSidebars.edit_form=csSidebars.extras.find(".cs-editor").clone(),csSidebars.extras.find(".cs-editor").remove()),null===csSidebars.delete_form&&(csSidebars.delete_form=csSidebars.extras.find(".cs-delete").clone(),csSidebars.extras.find(".cs-delete").remove()),null===csSidebars.export_form&&(csSidebars.export_form=csSidebars.extras.find(".cs-export").clone(),csSidebars.extras.find(".cs-export").remove()),null===csSidebars.location_form&&(csSidebars.location_form=csSidebars.extras.find(".cs-location").clone(),csSidebars.extras.find(".cs-location").remove()),jQuery("#cs-title-options").detach().prependTo(csSidebars.right),csSidebars},initColumns:function(){function e(){var e=jQuery(this),i=e.closest(".sidebars-column-1, .sidebars-column-2"),t=i.data("sort-dir");t="asc"===t?"desc":"asc",csSidebars.sort_sidebars(i,t)}var i=csSidebars.right.find(".sidebars-column-1"),t=csSidebars.right.find(".sidebars-column-2"),s=jQuery('
'),a=csSidebars.right.find(".widgets-holder-wrap");t.length||(t=jQuery(''),t.appendTo(csSidebars.right)),s.find("h3").append('').css({cursor:"pointer"}),s.clone().prependTo(i).click(e).find(".cs-title-val").text(csSidebarsData.custom_sidebars),s.clone().prependTo(t).click(e).find(".cs-title-val").text(csSidebarsData.theme_sidebars),i=jQuery('').appendTo(i),t=jQuery('').appendTo(t),a.each(function(){var e=jQuery(this),s=e.find(".widgets-sortables");csSidebars.isCustomSidebar(s)?e.appendTo(i):e.appendTo(t)})},initSidebars:function(){return csSidebars.right.find(".widgets-sortables").each(function(){var e,i,t=!1,s=jQuery(this),a=s.attr("id");if(s.data("cs-init")!==!0)if(s.data("cs-init",!0),csSidebars.isCustomSidebar(this))i=csSidebars.add(a,"custom");else{i=csSidebars.add(a,"theme");for(e in csSidebarsData.replaceable)if(csSidebarsData.replaceable.hasOwnProperty(e)&&csSidebarsData.replaceable[e]===a){t=!0;break}csSidebars.setReplaceable(i,t,!1)}}),csSidebars},initTopTools:function(){var e=jQuery(".btn-create-sidebar"),i=jQuery(".btn-export"),t=jQuery(".cs-options"),s=jQuery(''),a={};return e.click(function(){a.id="",a.title=csSidebarsData.title_new,a.button=csSidebarsData.btn_new,a.description="",a.name="",csSidebars.showEditor(a)}),i.click(csSidebars.showExport),s.appendTo(t).attr("placeholder",csSidebarsData.filter).keyup(csSidebars.filter_sidebars).on("search",csSidebars.filter_sidebars),csSidebars},initToolbars:function(){function e(e){var i=jQuery(e.target).closest(".cs-tool"),t=i.data("action"),s=csSidebars.getIdFromEditbar(i),a=csSidebars.find(s);return!csSidebars.handleAction(t,a)}return csSidebars.registerAction("edit",csSidebars.showEditor),csSidebars.registerAction("location",csSidebars.showLocations),csSidebars.registerAction("delete",csSidebars.showRemove),csSidebars.registerAction("replaceable",csSidebars.setReplaceable),csSidebars.right.on("click",".cs-tool",e),csSidebars},handleAction:function(e,i){return"function"==typeof csSidebars.action_handlers[e]?!!csSidebars.action_handlers[e](i):!1},registerAction:function(e,i){csSidebars.action_handlers[e]=i},showAjaxError:function(e){var i={};i.message=csSidebarsData.ajax_error,i.details=e,i.parent="#widgets-right",i.insert_after="#cs-title-options",i.id="editor",i.type="err",wpmUi.message(i)},sort_sidebars:function(e,i){var t=e.find(".widgets-holder-wrap"),s=e.find(".cs-title .cs-icon");t.sortElements(function(e,t){var s=jQuery(e).find(".sidebar-name h3").text(),a=jQuery(t).find(".sidebar-name h3").text();return"asc"===i?s>a?1:-1:a>s?1:-1}),e.data("sort-dir",i),"asc"===i?s.removeClass("dashicons-arrow-down dashicons-sort").addClass("dashicons-arrow-up"):s.removeClass("dashicons-arrow-up dashicons-sort").addClass("dashicons-arrow-down")},filter_sidebars:function(){var e=jQuery("input.cs-filter").val().toLowerCase(),i=csSidebars.right.find(".widgets-holder-wrap");i.each(function(){var i=jQuery(this),t=i.find(".sidebar-name h3").text();-1!==t.toLowerCase().indexOf(e)?i.show():i.hide()}),jQuery(window).trigger("cs-resize")},showEditor:function(e){function i(){o.$().removeClass("csb-has-more"),o.size(782,215)}function t(){o.$().addClass("csb-has-more"),o.size(782,545)}function s(){jQuery(this).prop("checked")?t():i()}function a(e,i){return o.loading(!1),e?i?(e.sidebar&&(e=e.sidebar),e.id&&o.$().find("#csb-id").val(e.id),e.name&&o.$().find("#csb-name").val(e.name),e.description&&o.$().find("#csb-description").val(e.description),e.before_title&&o.$().find("#csb-before-title").val(e.before_title),e.after_title&&o.$().find("#csb-after-title").val(e.after_title),e.before_widget&&o.$().find("#csb-before-widget").val(e.before_widget),e.after_widget&&o.$().find("#csb-after-widget").val(e.after_widget),e.button&&o.$().find(".btn-save").text(e.button),void 0):(o.destroy(),csSidebars.showAjaxError(e),!1):!1}function r(e,i){var t,s={};o.loading(!1),o.destroy(),s.message=e.message,s.parent="#widgets-right",s.insert_after="#cs-title-options",s.id="editor",i?"update"===e.action?(t=csSidebars.find(e.data.id),csSidebars.updateSidebar(t,e.data)):"insert"===e.action&&csSidebars.insertSidebar(e.data):s.type="err",wpmUi.message(s)}function n(){var e=o.$().find("form");return o.loading(!0),d.reset().data(e).ondone(r).load_json(),!1}var o=null,d=null;return e instanceof CsSidebar&&(e={id:e.getID(),title:csSidebarsData.title_edit.replace("[Sidebar]",e.name),button:csSidebarsData.btn_edit}),o=wpmUi.popup().modal(!0).title(e.title).onshow(i).content(csSidebars.edit_form),i(),a(e,!0,null),d=wpmUi.ajax(null,"cs-ajax"),e.id&&(o.loading(!0),d.reset().data({"do":"get",sb:e.id}).ondone(a).load_json()),o.show(),o.$().find("#csb-name").focus(),o.$().on("click","#csb-more",s),o.$().on("click",".btn-save",n),o.$().on("click",".btn-cancel",o.destroy),!0},updateSidebar:function(e,i){return e.sb.find(".sidebar-name h3").text(i.name),e.sb.find(".sidebar-description").html('').find(".description").text(i.description),csSidebars},insertSidebar:function(e){var i=jQuery(''),t=jQuery(''),s=jQuery(''),a=jQuery(''),r=csSidebars.right.find(".sidebars-column-1 > .inner:first");return t.attr("id",e.id),s.find("h3").text(e.name),a.html('').find(".description").text(e.description),s.appendTo(t),a.appendTo(t),t.appendTo(i),i.prependTo(r),jQuery("#widgets-right .sidebar-name").unbind("click"),jQuery("#widgets-left .sidebar-name").unbind("click"),jQuery(document.body).unbind("click.widgets-toggle"),jQuery(".widgets-chooser").off("click.widgets-chooser").off("keyup.widgets-chooser"),jQuery("#available-widgets .widget .widget-title").off("click.widgets-chooser"),jQuery(".widgets-chooser-sidebars").empty(),window.wpWidgets.init(),csSidebars.initSidebars(),csSidebars},showExport:function(){function e(e){var i=jQuery(this).closest("form");return o.reset().data(i).load_http(),n.destroy(),e.preventDefault(),!1}function i(e,i){var t={};n.loading(!1),i?n.size(900,600).content(e.html):(t.message=e.message,t.parent=n.$().find(".wpmui-wnd-content"),t.insert_after=!1,t.id="export",t["class"]="wpmui-wnd-err",t.type="err",wpmUi.message(t))}function t(e){var t=jQuery(this).closest("form");return n.loading(!0),o.reset().data(t).ondone(i).load_json("cs-ajax"),e.preventDefault(),!1}function s(){var e=jQuery(this),i=e.prop("checked"),t=n.$().find(".column-widgets, .import-widgets");i?t.show():t.hide()}function a(){n.size(782,480),n.content(csSidebars.export_form)}function r(){var e=n.$().find(".frm-import");n.loading(!0),o.reset().data(e).load_http("_self")}var n=null,o=null;return n=wpmUi.popup().modal(!0).size(782,480).title(csSidebarsData.title_export).content(csSidebars.export_form).show(),o=wpmUi.ajax(null,"cs-ajax"),n.$().on("submit",".frm-export",e),n.$().on("submit",".frm-preview-import",t),n.$().on("change","#import-widgets",s),n.$().on("click",".btn-cancel",a),n.$().on("click",".btn-import",r),!0},showRemove:function(e){function i(e){e.find(".name").text(d)}function t(){r.loading(!1),r.destroy()}function s(e,i){var t={};r.loading(!1),r.destroy(),t.message=e.message,t.parent="#widgets-right",t.insert_after="#cs-title-options",t.id="editor",i?(csSidebars.right.find("#"+o).closest(".widgets-holder-wrap").remove(),csSidebars.remove(o)):t.type="err",wpmUi.message(t)}function a(){r.loading(!0),n.reset().data({"do":"delete",sb:o}).ondone(s).load_json()}var r=null,n=null,o=e.getID(),d=e.name;return r=wpmUi.popup().modal(!0).size(560,160).title(csSidebarsData.title_delete).content(csSidebars.delete_form).onshow(i).show(),n=wpmUi.ajax(null,"cs-ajax"),r.$().on("click",".btn-cancel",t),r.$().on("click",".btn-delete",a),!0},showLocations:function(e){function i(e,i){function t(e,i,t){var s=jQuery("");s.attr("value",t).text(e.name),i.append(s)}function s(e,i,t,s){var a=s.closest(".cs-replaceable").filter("."+i),r=a.find('option[value="'+t+'"]'),n=a.find("optgroup.used"),o=a.find(".detail-toggle");e===d?(r.prop("selected",!0),!0!==o.prop("checked")&&(o.prop("checked",!0),a.addClass("open"),wpmUi.upgrade_multiselect(a))):(n.length||(n=jQuery('