jQuery(document).ready(function(){jQuery("body").on("click",".modal-columns-visibility .settings-column",function(e){e.preventDefault();var o=jQuery(this).parent().find(".column-settings");o.toggleClass("settings-opened"),vgseColumnsVisibilityEqualizeHeight(),vgseInitLazySelects(),o.find(".field-type select").trigger("change")}),jQuery("body").on("change",".modal-columns-visibility .field-type select",function(){if(jQuery(this).is(":visible")){var e=jQuery(this).val(),o=jQuery(this).parents(".column-settings");o.find(".settings-for-type").hide(),e&&o.find(".settings-for-"+e).show(),vgseColumnsVisibilityEqualizeHeight()}}),jQuery(".modal-columns-visibility .field-type select").trigger("change"),jQuery("body").on("change",'.modal-columns-visibility .column-settings select, .modal-columns-visibility .column-settings input, .modal-columns-visibility .column-settings textarea, .modal-columns-visibility input[name="wpse_group_name"]',function(){jQuery(".modal-columns-visibility .save_post_type_settings").prop("checked",!0),vgse_editor_settings.is_editor_page&&jQuery('.modal-columns-visibility input[name="wpse_auto_reload_after_saving"]').val(1)})}),jQuery(document).ready(function(){if("undefined"==typeof hot)return!0;var e=hot.getSettings().contextMenu;function s(){var e;if("object"==typeof vgse_editor_settings.columnsBackgroundColors){for(var o in vgse_editor_settings.columnsBackgroundColors)if(Object.hasOwnProperty.call(vgse_editor_settings.columnsBackgroundColors,o)){var t=vgseStripHtml(vgse_editor_settings.columnsBackgroundColors[o]),s="bg-"+t.replace("#","");jQuery("head style."+s).length||(e=void 0,e=t.replace("#",""),170<(299*parseInt(e.substr(0,2),16)+587*parseInt(e.substr(2,2),16)+114*parseInt(e.substr(4,2),16))/1e3?jQuery("head").append('<style class="wpse-column-backgrounds className">#vgse-wrapper.highlightCurrentRow .currentRow.className, #vgse-wrapper .className { background-color: colorCode !important; color: #444 !important;}#vgse-wrapper .className a {color: #222 !important;}</style>'.replace(/className/g,s).replace(/colorCode/g,t)):jQuery("head").append('<style class="wpse-column-backgrounds className">#vgse-wrapper.highlightCurrentRow .currentRow.className, #vgse-wrapper .className { background-color: colorCode !important; color: white !important;}</style>'.replace(/className/g,s).replace(/colorCode/g,t)))}jQuery.isEmptyObject(vgse_editor_settings.columnsBackgroundColors)&&jQuery("head style.wpse-column-backgrounds").remove(),hot.render()}}void 0===e.items&&(e.items={}),e.items.wpse_column_background={name:vgse_editor_settings.texts.change_background_color,callback:function(e,o,t){var r=[],c=[];o.forEach(function(e){for(var o=e.start.col>e.end.col?e.end.col:e.start.col,t=e.start.col>e.end.col?e.start.col:e.end.col,s=[],n=o;n<=t;n++)s.push(n);s.forEach(function(e){var o=hot.colToProp(e);o&&(r.push(o),c.push(e))})}),$colorInput=jQuery(".wpse-column-background-selector-wrapper input"),$colorInput.data("columnKeys",jQuery.unique(r)).data("columnIndexes",jQuery.unique(c)),$colorInput.val("#ffffff"),$colorInput.data("backgroundsBeforeOpening",jQuery.extend(!0,{},vgse_editor_settings.columnsBackgroundColors||{})),jQuery(".wpse-column-background-selector-wrapper").show()}},hot.updateSettings({contextMenu:e}),jQuery("body").on("change input",".wpse-column-background-selector-wrapper input",_throttle(function(e){e.preventDefault();var o=jQuery(this),t=o.val().toLowerCase();"object"!=typeof vgse_editor_settings.columnsBackgroundColors&&(vgse_editor_settings.columnsBackgroundColors={}),o.data("columnKeys")&&(o.data("columnKeys").forEach(function(e){"#ffffff"===t&&"string"==typeof vgse_editor_settings.columnsBackgroundColors[e]?delete vgse_editor_settings.columnsBackgroundColors[e]:"#ffffff"!==t&&(vgse_editor_settings.columnsBackgroundColors[e]=t)}),s())},500,{leading:!1,trailing:!0})),jQuery("body").on("click",".wpse-column-background-selector-wrapper .cancel-background-change",function(e){e.preventDefault();var o=jQuery(this).parent().find("input");jQuery(".wpse-column-background-selector-wrapper").hide(),vgse_editor_settings.columnsBackgroundColors=o.data("backgroundsBeforeOpening"),s()}),jQuery("body").on("click",".wpse-column-background-selector-wrapper .clear-background-color",function(e){e.preventDefault();var o=jQuery(this).parent().find("input");o.val("#ffffff"),o.trigger("change")}),jQuery("body").on("click",".wpse-column-background-selector-wrapper .save-background-color",function(e){e.preventDefault(),jQuery.post(vgse_global_data.ajax_url,{action:"vgse_save_column_backgrounds",post_type:vgse_editor_settings.post_type,backgrounds:vgse_editor_settings.columnsBackgroundColors,nonce:vgse_editor_settings.nonce}),jQuery(".wpse-column-background-selector-wrapper").hide()}),s()});