woocommerce/assets/js/admin/marketplace-suggestions.min.js

1 line
6.4 KiB
JavaScript
Raw Normal View History

!function(h,v,d){h(function(){if(void 0!==v){window.wcTracks=window.wcTracks||{},window.wcTracks.recordEvent=window.wcTracks.recordEvent||function(){};var l=!1;v.suggestions_data&&(!function t(d){var u=[];h(".marketplace-suggestions-container").each(function(){var s=this.dataset.marketplaceSuggestionsContext,t=function c(t,e){var s=_.filter(t,function(t){return _.isArray(t.context)?_.contains(t.context,e):e===t.context});return s=_.filter(s,function(t){return!_.contains(v.dismissed_suggestions,t.slug)}),s=_.filter(s,function(t){return!_.contains(v.active_plugins,t.product)}),s=_.filter(s,function(t){return!t["show-if-active"]||0<_.intersection(v.active_plugins,t["show-if-active"]).length})}(d,s),n=_.sample(t,5);for(var e in n){var a=n[e]["link-text"],o=!0;n[e]["link-text"]&&(a=n[e]["link-text"],o=!1);var i=!0;!1===n[e]["allow-dismiss"]&&(i=!1);var r=g(s,n[e].product,n[e].promoted,n[e].slug,n[e].icon,n[e].title,n[e].copy,n[e].url,a,o,i);h(this).append(r),h(this).addClass("showing-suggestion"),u.push(s),m(s)||window.wcTracks.recordEvent("marketplace_suggestion_displayed",{suggestion_slug:n[e].slug,context:s,product:n[e].product||"",promoted:n[e].promoted||"",target:n[e].url||""})}h("ul.product_data_tabs li.marketplace-suggestions_options a").click(function(t){if(t.preventDefault(),"#marketplace_suggestions"!==l&&m(s))for(var e in n)window.wcTracks.recordEvent("marketplace_suggestion_displayed",{suggestion_slug:n[e].slug,context:s,product:n[e].product||"",promoted:n[e].promoted||"",target:n[e].url||""})})}),function s(t){var e=0<_.intersection(t,["products-list-empty-body","orders-list-empty-body"]).length;e&&(h("#screen-meta-links").hide(),h("#wpfooter").hide()),e||(h('.marketplace-suggestions-container[data-marketplace-suggestions-context="products-list-empty-header"]').hide(),h('.marketplace-suggestions-container[data-marketplace-suggestions-context="products-list-empty-footer"]').hide(),h('.marketplace-suggestions-container[data-marketplace-suggestions-context="orders-list-empty-header"]').hide(),h('.marketplace-suggestions-container[data-marketplace-suggestions-context="orders-list-empty-footer"]').hide())}(u),p()}(v.suggestions_data),h("ul.product_data_tabs").on("click","li a",function(t){t.preventDefault(),l=h(this).attr("href")})),function e(){h("a.marketplace-suggestion-manage-link").on("click",function(){window.wcTracks.recordEvent("marketplace_suggestions_manage_clicked")})}()}function k(e,s,n,a,o){var t=document.createElement("a");return t.classList.add("suggestion-dismiss"),t.setAttribute("title",v.i18n_marketplace_suggestions_dismiss_tooltip),t.setAttribute("href","#"),t.onclick=function(t){t.preventDefault(),function c(t,e,s,n,a){if(h("[data-suggestion-slug="+a+"]").fadeOut(function(){h(this).remove(),p()}),jQuery.post(d,{action:"woocommerce_add_dismissed_marketplace_suggestion",_wpnonce:v.dismiss_suggestion_nonce,slug:a}),_.contains(["products-list-inline"],t)){var o="woocommerce_snooze_suggestions__"+t;Cookies.set(o,"true",{expires:2});var i="woocommerce_dismissed_suggestions__"+t,r=parseInt(Cookies.get(i),10)||0;Cookies.set(i,r+1,{expires:31})}window.wcTracks.recordEvent("marketplace_suggestion_dismissed",{suggestion_slug:a,context:t,product:e||"",promoted:s||"",target:n||""})}(e,s,n,a,o)},t}function f(t,e,s,n,a,o,i){var r=document.createElement("a"),c=function u(e,t){var s={utm_source:"unknown",utm_campaign:"marketplacesuggestions",utm_medium:"product"},n=_.findKey({productstable:["products-list-inline"],productsempty:["products-list-empty-header","products-list-empty-footer","products-list-empty-body"],ordersempty:["orders-list-empty-header","orders-list-empty-footer","orders-list-empty-body"],editproduct:["product-edit-meta-tab-header","product-edit-meta-tab-footer","product-edit-meta-tab-body"]},function(t){return _.contains(t,e)});return n&&(s.utm_source=n),t+"?"+jQuery.param(s)}(t,a);if(r.setAttribute("href",c),r.setAttribute("target","blank"),r.textContent=o,r.onclick=function(){window.wcTracks.recordEvent("marketplace_suggestion_clicked",{suggestion_slug:n,context:t,product:e||"",promoted:s||"",ta