| 1 |
!function($){"use strict";$((function(){function toggleMenuItems(layoutValue){var isCarouselSliderThumbnail="carousel_layout"===layoutValue||"slider_layout"===layoutValue;$(".spf-tabbed-nav .pcp_ajax_pagination").toggle(!isCarouselSliderThumbnail),$(".menu-item_sp_pcp_view_options_3").toggle(isCarouselSliderThumbnail),$(".pcp-display-tabs .spf-tabbed-nav a:nth-child(1)").trigger("click")}$("#sp_pcp_view_options .spf-metabox").css("visibility","hidden"),$(".post_content_sorter .spf--sortable .spf--sortable-item:nth-child(1)").find(".spf-accordion-title").trigger("click");var layoutValue=$(".pcp-layout-preset .spf--sibling.spf--active").find("input").val();toggleMenuItems(layoutValue),$(".pcp-layout-preset .spf--sibling").on("change","input",(function(event){toggleMenuItems(layoutValue=$(this).val())}));var lastSelectedOption=$('input[name="sp_pcp_layouts[pcp_layout_preset]"]:checked').val();$('input[name="sp_pcp_layouts[pcp_layout_preset]"]').on("change",(function(){$(this).is(":disabled")||(lastSelectedOption=$(this).val())}));var lastSelectedContentOrientation="default",valuesToDisable;function pcp_copyToClipboard(element){var $temp=$("<input>");$("body").append($temp),$temp.val($(element).text()).select(),document.execCommand("copy"),$temp.remove()}function pcp_SelectText(element){var r=document.createRange(),w=element.get(0);r.selectNodeContents(w);var sel=window.getSelection();sel.removeAllRanges(),sel.addRange(r)}function addVisualBlockEditorButton(){if("undefined"==typeof ajaxurl)return!1;if(document.body.classList.contains("post-type-sp_post_carousel")&&document.body.classList.contains("edit-php")){var pageTitleAction=document.querySelector(".page-title-action");if(pageTitleAction&&!document.querySelector(".sp-pcp-visual-block-editor-btn")){var button=document.createElement("a");return button.href=ajaxurl.replace("admin-ajax.php","post-new.php?post_type=page&spblock_inserter=true"),button.className="sp-pcp-visual-block-editor-btn",button.textContent="Start with Smart Post Blocks",pageTitleAction.parentNode.insertBefore(button,pageTitleAction.nextSibling),!0}}return!1}function tryAddButton(){addVisualBlockEditorButton()||setTimeout(tryAddButton,100)}$('input[name="sp_pcp_view_options[post_content_orientation]"]').on("change",(function(){$(this).is(":disabled")||(lastSelectedContentOrientation=$(this).val())})),$("#publishing-action").on("click","#publish",(function(e){$('input[name="sp_pcp_layouts[pcp_layout_preset]"]:checked').is(":disabled")&&$('input[name="sp_pcp_layouts[pcp_layout_preset]"][value="'+lastSelectedOption+'"]').prop("checked",!0),$('input[name="sp_pcp_view_options[post_content_orientation]"]:checked').is(":disabled")&&$('input[name="sp_pcp_view_options[post_content_orientation]"][value="'+lastSelectedContentOrientation+'"]').prop("checked",!0)})),["1","2","3","4","5"].forEach((function(value){$(".pro-overlay-options-select").find('select option[value="'+value+'"]').attr("disabled","disabled").addClass("pcp_pro_only")})),$(".sps-live-demo-icon").on("click",(function(event){event.stopPropagation()})),$("#sp_pcp_view_options .spf-metabox").css({backgroundImage:"none",visibility:"visible",minHeight:"auto"}),$("#sp_pcp_view_options .spf-nav-metabox li").css("opacity",1),$(".pcp-shortcode-selectable").on("click",(function(e){e.preventDefault(),pcp_copyToClipboard($(this)),pcp_SelectText($(this)),$(this).focus().select(),$(".pcp-after-copy-text").animate({opacity:1,bottom:25},300),setTimeout((function(){jQuery(".pcp-after-copy-text").animate({opacity:0},200),jQuery(".pcp-after-copy-text").animate({bottom:0},0)}),2e3)})),$(".sp_pcp_input").on("click",(function(e){var copyText;e.preventDefault(),$(this).select(),document.execCommand("copy"),$(".pcp-after-copy-text").animate({opacity:1,bottom:25},300),setTimeout((function(){jQuery(".pcp-after-copy-text").animate({opacity:0},200),jQuery(".pcp-after-copy-text").animate({bottom:0},0)}),2e3)})),tryAddButton()}))}(jQuery); |