Changeset 3443281
- Timestamp:
- 01/20/2026 01:26:34 PM (2 months ago)
- Location:
- post-views-counter/trunk
- Files:
-
- 1 added
- 12 edited
-
js/admin-dashboard.js (modified) (1 diff)
-
js/admin-post.js (modified) (1 diff)
-
js/admin-quick-edit.js (modified) (1 diff)
-
js/admin-settings.js (modified) (1 diff)
-
js/admin-theme.js (added)
-
js/admin-widgets.js (modified) (1 diff)
-
js/block-editor.js (modified) (1 diff)
-
js/column-modal.js (modified) (1 diff)
-
js/counter.js (modified) (1 diff)
-
js/frontend.js (modified) (1 diff)
-
js/integration-gutenberg.js (modified) (1 diff)
-
post-views-counter.php (modified) (3 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
post-views-counter/trunk/js/admin-dashboard.js
r3442638 r3443281 1 !function($,e,t){!function($){e.addEventListener("load",function(){e.pvcUpdatePostViewsWidget(),e.pvcUpdatePostMostViewedWidget()}),$(function(){$(".pvc-accordion-header").on("click",function(t){$(t.currentTarget).closest(".pvc-accordion-item").toggleClass("pvc-collapsed");var n=$("#pvc-dashboard-accordion").find(".pvc-accordion-item"),a={};n.length>0&&$(n).each(function(e,t){var n=$(t).attr("id");n=n.replace("pvc-",""),a[n]=$(t).hasClass("pvc-collapsed")}),e.pvcUpdateUserOptions({menu_items:a})})});var n=$({});$.pvcAjaxQueue=function(e){var t,a=$.Deferred(),o=a.promise(),i=function(n){(t=$.ajax(e)).done(a.resolve).fail(a.reject).then(n,n)};return n.queue(i),o.abort=function(s){if(t)return t.abort(s);var d=n.queue(),r=$.inArray(i,d);return r>-1&&d.splice(r,1),a.rejectWith(e.context||e,[o,s,""]),o},o},e.pvcUpdateUserOptions=function(e){$.pvcAjaxQueue({url:pvcArgs.ajaxURL,type:"POST",dataType:"json",data:{action:"pvc_dashboard_user_options",nonce:pvcArgs.nonceUser,options:e},success:function(){}})},e.pvcUpdateConfig=function(e,t){return e.data=t.data,e.options.plugins.tooltip={callbacks:{title:function(e){return t.data.dates[e[0].dataIndex]}}},$.each(e.data.datasets,function(e,n){n.fill=t.design.fill,n.tension=.4,n.borderColor=t.design.borderColor,n.backgroundColor=t.design.backgroundColor,n.borderWidth=t.design.borderWidth,n.borderDash=t.design.borderDash,n.pointBorderColor=t.design.pointBorderColor,n.pointBackgroundColor=t.design.pointBackgroundColor,n.pointBorderWidth=t.design.pointBorderWidth}),e};var a=function(e,t,n){$(n).addClass("loading").find(".spinner").addClass("is-active"),$.ajax({url:pvcArgs.ajaxURL,type:"POST",dataType:"json",data:{action:"pvc_dashboard_post_most_viewed",nonce:pvcArgs.nonce,period:t,lang:pvcArgs.lang?pvcArgs.lang:""},success:function(t){$(n).removeClass("loading"),$(n).find(".spinner").removeClass("is-active"),e||i(t.dates,n),$(n).find("#pvc-post-most-viewed-content").html(t.html),r("pvc-dashboard-widget-loaded",t)}})},o=function(n,a,o){$(o).addClass("loading").find(".spinner").addClass("is-active"),$.ajax({url:pvcArgs.ajaxURL,type:"POST",dataType:"json",data:{action:"pvc_dashboard_post_views_chart",nonce:pvcArgs.nonce,period:a,lang:pvcArgs.lang?pvcArgs.lang:""},success:function(a){if($(o).removeClass("loading"),$(o).find(".spinner").removeClass("is-active"),n){var s={type:"line",options:{maintainAspectRatio:!1,responsive:!0,plugins:{legend:{display:!0,position:"bottom",align:"center",fullSize:!0,onHover:function(e){e.native.target.style.cursor="pointer"},onLeave:function(e){e.native.target.style.cursor="default"},onClick:function(t,n,a){var o=n.datasetIndex,i=a.chart,s=i.getDatasetMeta(o);s.hidden=!!i.isDatasetVisible(o),i.update(),e.pvcUpdateUserOptions({post_type:i.data.datasets[o].post_type,hidden:s.hidden})},labels:{boxWidth:8,boxHeight:8,font:{size:13,weight:"normal",family:"'-apple-system', 'BlinkMacSystemFont', 'Segoe UI', 'Roboto', 'Oxygen-Sans', 'Ubuntu', 'Cantarell', 'Helvetica Neue', 'sans-serif'"},padding:10,usePointStyle:!1,textAlign:"center"}}},scales:{x:{display:!0,title:{display:!1}},y:{display:!0,grace:0,beginAtZero:!0,title:{display:!1},ticks:{precision:0,maxTicksLimit:12}}},hover:{mode:"label"}}};s=e.pvcUpdateConfig(s,a),e.postViewsChart=new Chart(t.getElementById("pvc-post-views-chart").getContext("2d"),s)}else i(a.dates,o),e.postViewsChart.config=e.pvcUpdateConfig(e.postViewsChart.config,a),e.postViewsChart.update();r("pvc-dashboard-widget-loaded",a)}})};e.pvcUpdatePostViewsWidget=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=$("#pvc-post-views").find(".pvc-dashboard-container");$(t).length>0&&(i(!1,t),o(!0,e,t))},e.pvcUpdatePostMostViewedWidget=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=$("#pvc-post-most-viewed").find(".pvc-dashboard-container");$(t).length>0&&(i(!1,t),a(!0,e,t))};var i=function(e,t){var n=$(t).find(".pvc-date-nav")[0];if(n){!1!==e&&(n.innerHTML=e);var a=n.getElementsByClassName("prev")[0],o=n.getElementsByClassName("next")[0],i=$(t).closest(".pvc-accordion-item").attr("id");"pvc-post-most-viewed"===i?a.addEventListener("click",function(e){e.preventDefault(),d(e.target.dataset.date)}):"pvc-post-views"===i&&a.addEventListener("click",function(e){e.preventDefault(),s(e.target.dataset.date)}),"A"===o.tagName&&("pvc-post-most-viewed"===i?o.addEventListener("click",function(e){e.preventDefault(),d(e.target.dataset.date)}):"pvc-post-views"===i&&o.addEventListener("click",function(e){e.preventDefault(),s(e.target.dataset.date)}))}},s=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=$("#pvc-post-views").find(".pvc-dashboard-container");o(!1,e,t)},d=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=$("#pvc-post-most-viewed").find(".pvc-dashboard-container");a(!1,e,t)},r=function(t,n){["dates","html","design"].forEach(function(e){delete n[e]});var a=new CustomEvent(t,{detail:n});e.dispatchEvent(a)}}(jQuery)}(jQuery,window,document); 1 ;(function($, window, document){ 2 !function($){window.addEventListener("load",function(){window.pvcUpdatePostViewsWidget(),window.pvcUpdatePostMostViewedWidget()}),$(function(){$(".pvc-accordion-header").on("click",function(e){$(e.currentTarget).closest(".pvc-accordion-item").toggleClass("pvc-collapsed");var t=$("#pvc-dashboard-accordion").find(".pvc-accordion-item"),n={};t.length>0&&$(t).each(function(e,t){var a=$(t).attr("id");a=a.replace("pvc-",""),n[a]=$(t).hasClass("pvc-collapsed")}),window.pvcUpdateUserOptions({menu_items:n})})});var e=$({});$.pvcAjaxQueue=function(t){var n,a=$.Deferred(),o=a.promise(),i=function(e){(n=$.ajax(t)).done(a.resolve).fail(a.reject).then(e,e)};return e.queue(i),o.abort=function(s){if(n)return n.abort(s);var d=e.queue(),r=$.inArray(i,d);return r>-1&&d.splice(r,1),a.rejectWith(t.context||t,[o,s,""]),o},o},window.pvcUpdateUserOptions=function(e){$.pvcAjaxQueue({url:pvcArgs.ajaxURL,type:"POST",dataType:"json",data:{action:"pvc_dashboard_user_options",nonce:pvcArgs.nonceUser,options:e},success:function(){}})},window.pvcUpdateConfig=function(e,t){return e.data=t.data,e.options.plugins.tooltip={callbacks:{title:function(e){return t.data.dates[e[0].dataIndex]}}},$.each(e.data.datasets,function(e,n){n.fill=t.design.fill,n.tension=.4,n.borderColor=t.design.borderColor,n.backgroundColor=t.design.backgroundColor,n.borderWidth=t.design.borderWidth,n.borderDash=t.design.borderDash,n.pointBorderColor=t.design.pointBorderColor,n.pointBackgroundColor=t.design.pointBackgroundColor,n.pointBorderWidth=t.design.pointBorderWidth}),e};var t=function(e,t,n){$(n).addClass("loading").find(".spinner").addClass("is-active"),$.ajax({url:pvcArgs.ajaxURL,type:"POST",dataType:"json",data:{action:"pvc_dashboard_post_most_viewed",nonce:pvcArgs.nonce,period:t,lang:pvcArgs.lang?pvcArgs.lang:""},success:function(t){$(n).removeClass("loading"),$(n).find(".spinner").removeClass("is-active"),e||a(t.dates,n),$(n).find("#pvc-post-most-viewed-content").html(t.html),s("pvc-dashboard-widget-loaded",t)}})},n=function(e,t,n){$(n).addClass("loading").find(".spinner").addClass("is-active"),$.ajax({url:pvcArgs.ajaxURL,type:"POST",dataType:"json",data:{action:"pvc_dashboard_post_views_chart",nonce:pvcArgs.nonce,period:t,lang:pvcArgs.lang?pvcArgs.lang:""},success:function(t){if($(n).removeClass("loading"),$(n).find(".spinner").removeClass("is-active"),e){var o={type:"line",options:{maintainAspectRatio:!1,responsive:!0,plugins:{legend:{display:!0,position:"bottom",align:"center",fullSize:!0,onHover:function(e){e.native.target.style.cursor="pointer"},onLeave:function(e){e.native.target.style.cursor="default"},onClick:function(e,t,n){var a=t.datasetIndex,o=n.chart,i=o.getDatasetMeta(a);i.hidden=!!o.isDatasetVisible(a),o.update(),window.pvcUpdateUserOptions({post_type:o.data.datasets[a].post_type,hidden:i.hidden})},labels:{boxWidth:8,boxHeight:8,font:{size:13,weight:"normal",family:"'-apple-system', 'BlinkMacSystemFont', 'Segoe UI', 'Roboto', 'Oxygen-Sans', 'Ubuntu', 'Cantarell', 'Helvetica Neue', 'sans-serif'"},padding:10,usePointStyle:!1,textAlign:"center"}}},scales:{x:{display:!0,title:{display:!1}},y:{display:!0,grace:0,beginAtZero:!0,title:{display:!1},ticks:{precision:0,maxTicksLimit:12}}},hover:{mode:"label"}}};o=window.pvcUpdateConfig(o,t),window.postViewsChart=new Chart(document.getElementById("pvc-post-views-chart").getContext("2d"),o)}else a(t.dates,n),window.postViewsChart.config=window.pvcUpdateConfig(window.postViewsChart.config,t),window.postViewsChart.update();s("pvc-dashboard-widget-loaded",t)}})};window.pvcUpdatePostViewsWidget=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=$("#pvc-post-views").find(".pvc-dashboard-container");$(t).length>0&&(a(!1,t),n(!0,e,t))},window.pvcUpdatePostMostViewedWidget=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=$("#pvc-post-most-viewed").find(".pvc-dashboard-container");$(n).length>0&&(a(!1,n),t(!0,e,n))};var a=function(e,t){var n=$(t).find(".pvc-date-nav")[0];if(n){!1!==e&&(n.innerHTML=e);var a=n.getElementsByClassName("prev")[0],s=n.getElementsByClassName("next")[0],d=$(t).closest(".pvc-accordion-item").attr("id");"pvc-post-most-viewed"===d?a.addEventListener("click",function(e){e.preventDefault(),i(e.target.dataset.date)}):"pvc-post-views"===d&&a.addEventListener("click",function(e){e.preventDefault(),o(e.target.dataset.date)}),"A"===s.tagName&&("pvc-post-most-viewed"===d?s.addEventListener("click",function(e){e.preventDefault(),i(e.target.dataset.date)}):"pvc-post-views"===d&&s.addEventListener("click",function(e){e.preventDefault(),o(e.target.dataset.date)}))}},o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=$("#pvc-post-views").find(".pvc-dashboard-container");n(!1,e,t)},i=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=$("#pvc-post-most-viewed").find(".pvc-dashboard-container");t(!1,e,n)},s=function(e,t){["dates","html","design"].forEach(function(e){delete t[e]});var n=new CustomEvent(e,{detail:t});window.dispatchEvent(n)}}(jQuery); 3 4 })(jQuery, window, document); -
post-views-counter/trunk/js/admin-post.js
r3442638 r3443281 1 var $;jQuery,window,document,($=jQuery)(function(){var t=$("#post-views-input-container"),e=$("#post-views-display b"),s=$("#post-views-input"),i=$("#post-views .edit-post-views");i.on("click",function(e){return t.is(":hidden")&&(t.slideDown("fast"),$(e.currentTarget).hide()),!1}),$("#post-views .save-post-views").on("click",function(){var n=e.text().trim();return t.slideUp("fast"),i.show(),n=parseInt(s.val(),10),s.val(n),e.text(n),!1}),$("#post-views .cancel-post-views").on("click",function(){var n=e.text().trim();return t.slideUp("fast"),i.show(),n=parseInt($("#post-views-current").val(),10),e.text(n),s.val(n),!1})}); 1 ;(function($, window, document){ 2 var $;($=jQuery)(function(){var t=$("#post-views-input-container"),s=$("#post-views-display b"),e=$("#post-views-input"),i=$("#post-views .edit-post-views");i.on("click",function(s){return t.is(":hidden")&&(t.slideDown("fast"),$(s.currentTarget).hide()),!1}),$("#post-views .save-post-views").on("click",function(){var n=s.text().trim();return t.slideUp("fast"),i.show(),n=parseInt(e.val(),10),e.val(n),s.text(n),!1}),$("#post-views .cancel-post-views").on("click",function(){var n=s.text().trim();return t.slideUp("fast"),i.show(),n=parseInt($("#post-views-current").val(),10),s.text(n),e.val(n),!1})}); 3 4 })(jQuery, window, document); -
post-views-counter/trunk/js/admin-quick-edit.js
r3442638 r3443281 1 !function($,t,n){function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}!function($){$(function(){var t=inlineEditPost.edit;inlineEditPost.edit=function(n){t.apply(this,arguments);var e=0;if("object"===i(n)&&(e=parseInt(this.getId(n),10)),e>0){var o=$("#edit-".concat(e)),c=$("#post-".concat(e)),s=$(".column-post_views",c).text();$(':input[name="post_views"]',o).val(s),$(':input[name="current_post_views"]',o).val(s)}return!1},$(n).on("click","#bulk_edit",function(){var t=$("#bulk-edit"),n=[];pvcArgsQuickEdit.wpVersion59?t.find("#bulk-titles-list").children(".ntdelitem").each(function(){n.push($(this).find("button").attr("id").replace(/[^0-9]/i,""))}):t.find("#bulk-titles").children().each(function(){n.push($(this).attr("id").replace(/^(ttle)/i,""))});var i=t.find('input[name="post_views"]').val();$.ajax({url:ajaxurl,type:"post",async:!1,cache:!1,data:{action:"save_bulk_post_views",post_ids:n,post_views:i,current_post_views:i,nonce:pvcArgsQuickEdit.nonce}})})})}(jQuery)}(jQuery,window,document); 1 ;(function($, window, document){ 2 function t(i){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(i)}var $;($=jQuery)(function(){var i=inlineEditPost.edit;inlineEditPost.edit=function(n){i.apply(this,arguments);var e=0;if("object"===t(n)&&(e=parseInt(this.getId(n),10)),e>0){var o=$("#edit-".concat(e)),c=$("#post-".concat(e)),s=$(".column-post_views",c).text();$(':input[name="post_views"]',o).val(s),$(':input[name="current_post_views"]',o).val(s)}return!1},$(document).on("click","#bulk_edit",function(){var t=$("#bulk-edit"),i=[];pvcArgsQuickEdit.wpVersion59?t.find("#bulk-titles-list").children(".ntdelitem").each(function(){i.push($(this).find("button").attr("id").replace(/[^0-9]/i,""))}):t.find("#bulk-titles").children().each(function(){i.push($(this).attr("id").replace(/^(ttle)/i,""))});var n=t.find('input[name="post_views"]').val();$.ajax({url:ajaxurl,type:"post",async:!1,cache:!1,data:{action:"save_bulk_post_views",post_ids:i,post_views:n,current_post_views:n,nonce:pvcArgsQuickEdit.nonce}})})}); 3 4 })(jQuery, window, document); -
post-views-counter/trunk/js/admin-settings.js
r3442638 r3443281 1 !function($,e,t){const n=(e,t=0,n=1)=>e>n?n:e<t?t:e,r=(e,t=0,n=Math.pow(10,t))=>Math.round(n*e)/n,o=e=>("#"===e[0]&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:4===e.length?r(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:8===e.length?r(parseInt(e.substring(6,8),16)/255,2):1}),i=e=>{const{h:t,s:n,l:o}=(({h:e,s:t,v:n,a:o})=>{const i=(200-t)*n/100;return{h:r(e),s:r(i>0&&i<200?t*n/100/(i<=100?i:200-i)*100:0),l:r(i/2),a:r(o,2)}})(e);return`hsl(${t}, ${n}%, ${o}%)`},a=({h:e,s:t,v:n,a:o})=>{e=e/360*6,t/=100,n/=100;const i=Math.floor(e),a=n*(1-t),s=n*(1-(e-i)*t),c=n*(1-(1-e+i)*t),l=i%6;return{r:r(255*[n,s,a,a,c,n][l]),g:r(255*[c,n,n,s,a,a][l]),b:r(255*[a,a,c,n,n,s][l]),a:r(o,2)}},s=e=>{const t=e.toString(16);return t.length<2?"0"+t:t},c=({r:e,g:t,b:n,a:o})=>{const i=o<1?s(r(255*o)):"";return"#"+s(e)+s(t)+s(n)+i},l=({r:e,g:t,b:n,a:o})=>{const i=Math.max(e,t,n),a=i-Math.min(e,t,n),s=a?i===e?(t-n)/a:i===t?2+(n-e)/a:4+(e-t)/a:0;return{h:r(60*(s<0?s+6:s)),s:r(i?a/i*100:0),v:r(i/255*100),a:o}},u=(e,t)=>{if(e===t)return!0;for(const n in e)if(e[n]!==t[n])return!1;return!0},d={},f=e=>{let n=d[e];return n||(n=t.createElement("template"),n.innerHTML=e,d[e]=n),n},v=(e,t,n)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))};let p=!1;const h=e=>"touches"in e,m=(t,r)=>{const o=h(r)?r.touches[0]:r,i=t.el.getBoundingClientRect();v(t.el,"move",t.getMove({x:n((o.pageX-(i.left+e.pageXOffset))/i.width),y:n((o.pageY-(i.top+e.pageYOffset))/i.height)}))};class g{constructor(e,t,n,r){const o=f(`<div role="slider" tabindex="0" part="${t}" ${n}><div part="${t}-pointer"></div></div>`);e.appendChild(o.content.cloneNode(!0));const i=e.querySelector(`[part=${t}]`);i.addEventListener("mousedown",this),i.addEventListener("touchstart",this),i.addEventListener("keydown",this),this.el=i,this.xy=r,this.nodes=[i.firstChild,i]}set dragging(e){const n=e?t.addEventListener:t.removeEventListener;n(p?"touchmove":"mousemove",this),n(p?"touchend":"mouseup",this)}handleEvent(e){switch(e.type){case"mousedown":case"touchstart":if(e.preventDefault(),!(e=>!(p&&!h(e)||(p||(p=h(e)),0)))(e)||!p&&0!=e.button)return;this.el.focus(),m(this,e),this.dragging=!0;break;case"mousemove":case"touchmove":e.preventDefault(),m(this,e);break;case"mouseup":case"touchend":this.dragging=!1;break;case"keydown":((e,t)=>{const n=t.keyCode;n>40||e.xy&&n<37||n<33||(t.preventDefault(),v(e.el,"move",e.getMove({x:39===n?.01:37===n?-.01:34===n?.05:33===n?-.05:35===n?1:36===n?-1:0,y:40===n?.01:38===n?-.01:0},!0)))})(this,e)}}style(e){e.forEach((e,t)=>{for(const n in e)this.nodes[t].style.setProperty(n,e[n])})}}class b extends g{constructor(e){super(e,"hue",'aria-label="Hue" aria-valuemin="0" aria-valuemax="360"',!1)}update({h:e}){this.h=e,this.style([{left:e/360*100+"%",color:i({h:e,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuenow",`${r(e)}`)}getMove(e,t){return{h:t?n(this.h+360*e.x,0,360):360*e.x}}}class y extends g{constructor(e){super(e,"saturation",'aria-label="Color"',!0)}update(e){this.hsva=e,this.style([{top:100-e.v+"%",left:`${e.s}%`,color:i(e)},{"background-color":i({h:e.h,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuetext",`Saturation ${r(e.s)}%, Brightness ${r(e.v)}%`)}getMove(e,t){return{s:t?n(this.hsva.s+100*e.x,0,100):100*e.x,v:t?n(this.hsva.v-100*e.y,0,100):Math.round(100-100*e.y)}}}const x=Symbol("same"),E=Symbol("color"),L=Symbol("hsva"),w=Symbol("update"),A=Symbol("parts"),S=Symbol("css"),k=Symbol("sliders");class q extends HTMLElement{static get observedAttributes(){return["color"]}get[S](){return[':host{display:flex;flex-direction:column;position:relative;width:200px;height:200px;user-select:none;-webkit-user-select:none;cursor:default}:host([hidden]){display:none!important}[role=slider]{position:relative;touch-action:none;user-select:none;-webkit-user-select:none;outline:0}[role=slider]:last-child{border-radius:0 0 8px 8px}[part$=pointer]{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;display:flex;place-content:center center;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}[part$=pointer]::after{content:"";width:100%;height:100%;border-radius:inherit;background-color:currentColor}[role=slider]:focus [part$=pointer]{transform:translate(-50%,-50%) scale(1.1)}',"[part=hue]{flex:0 0 24px;background:linear-gradient(to right,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%)}[part=hue-pointer]{top:50%;z-index:2}","[part=saturation]{flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,rgba(255,255,255,0));box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}[part=saturation-pointer]{z-index:3}"]}get[k](){return[y,b]}get color(){return this[E]}set color(e){if(!this[x](e)){const t=this.colorModel.toHsva(e);this[w](t),this[E]=e}}constructor(){super();const e=f(`<style>${this[S].join("")}</style>`),t=this.attachShadow({mode:"open"});t.appendChild(e.content.cloneNode(!0)),t.addEventListener("move",this),this[A]=this[k].map(e=>new e(t))}connectedCallback(){if(this.hasOwnProperty("color")){const e=this.color;delete this.color,this.color=e}else this.color||(this.color=this.colorModel.defaultColor)}attributeChangedCallback(e,t,n){const r=this.colorModel.fromAttr(n);this[x](r)||(this.color=r)}handleEvent(e){const t=this[L],n={...t,...e.detail};let r;this[w](n),u(n,t)||this[x](r=this.colorModel.fromHsva(n))||(this[E]=r,v(this,"color-changed",{value:r}))}[x](e){return this.color&&this.colorModel.equal(e,this.color)}[w](e){this[L]=e,this[A].forEach(t=>t.update(e))}}const _={defaultColor:"#000",toHsva:e=>l(o(e)),fromHsva:({h:e,s:t,v:n})=>c(a({h:e,s:t,v:n,a:1})),equal:(e,t)=>e.toLowerCase()===t.toLowerCase()||u(o(e),o(t)),fromAttr:e=>e};class C extends q{get colorModel(){return _}}function M(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return I(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?I(e,t):void 0}}(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function P(e){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},P(e)}customElements.define("hex-color-picker",class extends C{});var O=/^[0-9a-f]{3}([0-9a-f]{3})?$/i,H=function(e){if(!e)return"";var t=e.trim();if(!t)return"";var n=t.startsWith("#")?t.slice(1):t;return O.test(n)?"#".concat(n.toLowerCase()):""};function D(){var e=t.querySelector("[data-settings-prefix]"),n=e?e.dataset.settingsPrefix:"";if(n){var r=".".concat(n,"-hex-color-picker"),o=".".concat(n,"-field-type-color"),i=".".concat(n,"-color-input"),a=".".concat(n,"-color-swatch"),s=".".concat(n,"-color-popover"),c=".".concat(n,"-color-control"),l="".concat(n,"ColorInitialized");t.querySelectorAll(o).forEach(function(e){if("true"!==e.dataset[l]){var n=e.querySelector(i),o=e.querySelector(a),u=e.querySelector(s),d=e.querySelector(r),f=e.querySelector(c);if(n&&o&&u&&d&&f){d.addEventListener("mousedown",function(e){return e.stopPropagation()}),e.dataset[l]="true";var v=H(n.value)||"#000000",p=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.setInput,i=void 0===r||r,a=t.dispatch,s=void 0===a||a,c=t.setPicker,l=void 0===c||c,u=H(e);return!!u&&(v=u,i&&(n.value=u),o.style.backgroundColor=u,l&&d.color!==u&&(d.color=u),s&&n.dispatchEvent(new Event("input",{bubbles:!0})),!0)},h=function(){e.classList.contains("is-open")||(e.classList.add("is-open"),u.removeAttribute("aria-hidden"),o.setAttribute("aria-expanded","true"),t.addEventListener("mousedown",g,!0),t.addEventListener("keydown",b))},m=function(){e.classList.contains("is-open")&&(e.classList.remove("is-open"),u.setAttribute("aria-hidden","true"),o.setAttribute("aria-expanded","false"),t.removeEventListener("mousedown",g,!0),t.removeEventListener("keydown",b))},g=function(e){var t="function"==typeof e.composedPath?e.composedPath():[];f.contains(e.target)||t.includes(f)||t.includes(u)||t.includes(d)||m()},b=function(e){"Escape"===e.key&&m()};p(v,{setInput:!0,dispatch:!1}),o.addEventListener("click",function(t){t.preventDefault(),e.classList.contains("is-open")?m():h()}),n.addEventListener("click",h),n.addEventListener("input",function(){var e=H(n.value);e&&(n.value!==e&&(n.value=e),v=e,o.style.backgroundColor=e,d.color!==e&&(d.color=e))}),n.addEventListener("blur",function(){p(n.value,{setInput:!0,dispatch:!1})||p(v,{setInput:!0,dispatch:!1})}),d.addEventListener("color-changed",function(e){p(e.detail.value,{setPicker:!1})})}}})}}function j(){t.querySelectorAll('input[type="range"][data-range-output]').forEach(function(e){var n=e.getAttribute("data-range-output"),r=t.getElementById(n);r&&e.addEventListener("input",function(){r.textContent=e.value})})}function B(){var e=t.querySelector("[data-settings-prefix]"),n=e?e.dataset.settingsPrefix:"";if(n){var r="data-".concat(n,"-logic"),o="data-".concat(n,"-fallback-option"),i="".concat(n,"-hidden"),a="".concat(n,"CondDisabled"),s="_".concat(n,"AnimHandler"),c=[],l=new Map;t.querySelectorAll("[".concat(r,"]")).forEach(function(e){var i,a,s=function(e){var t=e.getAttribute(r);if(!t)return[];try{var n=JSON.parse(t);if(Array.isArray(n))return n;if(n&&"object"===P(n))return[n]}catch(o){return[]}return[]}(e);if(s.length){var u=s.map(function(e){return{field:e.field,operator:e.operator,value:e.value,scope:e.scope||"field",action:e.action||"",target:e.target||"",container:e.container||""}}),d=(null===(i=u.find(function(e){return e.container}))||void 0===i?void 0:i.container)||"",f=null;"self"===d?f=e:d&&(f=e.querySelector(d)||t.querySelector(d)),f||(f=e.closest("tr")||e);var v=e.getAttribute("data-".concat(n,"-animation")),p=(null===(a=u.find(function(e){return e.action}))||void 0===a?void 0:a.action)||"show",h=e.getAttribute(o)||"",m={el:e,row:f,logic:u,animation:v,defaultAction:p,fallbackOption:h};c.push(m),u.forEach(function(e){l.has(e.field)||l.set(e.field,[]);var t=l.get(e.field);t.includes(m)||t.push(m)})}});var u=function(e){var n=function(e){var n=t.getElementById(e);if(n)return"checkbox"===n.type||"radio"===n.type?n.checked?n.value:"":n.value;var r=t.querySelectorAll('input[type="radio"][id^="'.concat(e,'-"]'));if(r.length>0){var o,i=M(r);try{for(i.s();!(o=i.n()).done;){var a=o.value;if(a.checked)return a.value}}catch(l){i.e(l)}finally{i.f()}return null}var s=t.querySelectorAll('input[type="checkbox"][id^="'.concat(e,'-"]'));if(s.length>0){var c=[];return s.forEach(function(e){e.checked&&c.push(e.value)}),c}return null}(e.field);if(null===n)return!1;switch(e.operator){case"is":return n===e.value;case"isnot":return n!==e.value;case"contains":return("string"==typeof n||Array.isArray(n))&&n.includes(e.value);case"containsnot":return("string"==typeof n||Array.isArray(n))&&!n.includes(e.value);default:return!1}},d=function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=e.row,a=e.animation,c=o.classList.contains(i);if(t===!c)return Promise.resolve();if(!r||!a||!["fade","slide"].includes(a))return o.classList.toggle(i,!t),Promise.resolve();var l="".concat(n,"-anim-in"),u="".concat(n,"-anim-out"),d="".concat(n,"-anim-").concat(a);return new Promise(function(e){o[s]&&(o.removeEventListener("animationend",o[s]),o[s]=null);var n=function(){o.classList.remove(l,u,d),t?o.classList.remove(i):o.classList.add(i),o.removeEventListener("animationend",n),o[s]=null,e()};o.classList.remove(l,u,d),t?(o.classList.remove(i),o.classList.add(l,d)):o.classList.add(u,d),o[s]=n,o.addEventListener("animationend",n,{once:!0})})},f=function(e,t){e.el.querySelectorAll("input, select, textarea, button").forEach(function(e){t?e.disabled||(e.dataset[a]="true",e.disabled=!0):"true"===e.dataset[a]&&(e.disabled=!1,delete e.dataset[a])})},v=function(e,n,r,o){var s=e.action||o;if(s){var c=function(e,n){if(e.target)return Array.from(t.querySelectorAll(e.target));var r=n.el.querySelectorAll('input[type="radio"]');if(r.length)return Array.from(r).filter(function(t){return t.value===e.value});var o=n.el.querySelectorAll('input[type="checkbox"]');if(o.length)return Array.from(o).filter(function(t){return t.value===e.value});var i=n.el.querySelector("select");return i?Array.from(i.options).filter(function(t){return t.value===e.value}):[]}(e,n);c.length&&c.forEach(function(e){if("disable"===s||"enable"===s)!function(e,t){t?e.disabled||(e.dataset[a]="true",e.disabled=!0):"true"===e.dataset[a]&&(e.disabled=!1,delete e.dataset[a])}(e,"disable"===s?r:!r);else if("show"===s||"hide"===s){var t="show"===s?r:!r;e.classList.toggle(i,!t)}})}},p=function(e){if(e.fallbackOption){var t=e.el.querySelectorAll('input[type="radio"]');if(t.length){var n=Array.from(t).find(function(e){return e.checked});if(!n||n.disabled){var r=Array.from(t).find(function(t){return t.value===e.fallbackOption&&!t.disabled});r||(r=Array.from(t).find(function(e){return!e.disabled})||null),r&&!r.checked&&(r.checked=!0,r.dispatchEvent(new Event("change",{bubbles:!0})))}}else{var o=e.el.querySelector("select");if(o){var i=o.options[o.selectedIndex];if(i&&!i.disabled)return;var a=Array.from(o.options).find(function(t){return t.value===e.fallbackOption&&!t.disabled});a||(a=Array.from(o.options).find(function(e){return!e.disabled})),a&&(o.value=a.value,o.dispatchEvent(new Event("change",{bubbles:!0})))}}}},h=new Set,m=new Map;l.forEach(function(e,n){if(!h.has(n)){m.has(n)||m.set(n,{seq:0});!function(e,n){var r=t.getElementById(e);if(r)return r.addEventListener("change",n),void r.addEventListener("input",n);t.querySelectorAll('input[type="radio"][id^="'.concat(e,'-"]')).forEach(function(e){e.addEventListener("change",n)}),t.querySelectorAll('input[type="checkbox"][id^="'.concat(e,'-"]')).forEach(function(e){e.addEventListener("change",n)})}(n,function(){var t=m.get(n),r=++t.seq,o=[],a=[];if(e.forEach(function(e){var t,n=e.logic.filter(function(e){return"option"===e.scope}),r=e.logic.filter(function(e){return"option"!==e.scope});if(n.forEach(function(t){var n=u(t);v(t,e,n,e.defaultAction)}),p(e),r.length){var s=(null===(t=r.find(function(e){return e.action}))||void 0===t?void 0:t.action)||e.defaultAction,c=r.every(function(e){return u(e)});if("enable"!==s&&"disable"!==s){var l=e.row.classList.contains(i),d="show"===s?c:!c;d&&l?a.push(e):d||l||o.push(e)}else{f(e,"disable"===s?c:!c)}}}),o.length>0){var s=o.map(function(e){return d(e,!1,!0)});Promise.all(s).then(function(){t.seq===r&&a.forEach(function(e){return d(e,!0,!0)})})}else a.forEach(function(e){return d(e,!0,!0)})}),h.add(n)}}),c.forEach(function(e){var t,n=e.logic.filter(function(e){return"option"===e.scope}),r=e.logic.filter(function(e){return"option"!==e.scope});if(n.forEach(function(t){var n=u(t);v(t,e,n,e.defaultAction)}),p(e),r.length){var o=(null===(t=r.find(function(e){return e.action}))||void 0===t?void 0:t.action)||e.defaultAction,i=r.every(function(e){return u(e)});if("enable"!==o&&"disable"!==o)d(e,"show"===o?i:!i,!1);else f(e,"disable"===o?i:!i)}})}}function z(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"slide",o=t.querySelector("[data-settings-prefix]"),i=o?o.dataset.settingsPrefix:"";if(!i)return e.style.display=n?"":"none",Promise.resolve();var a="".concat(i,"-hidden"),s="".concat(i,"-anim-in"),c="".concat(i,"-anim-out"),l="".concat(i,"-anim-").concat(r),u="_".concat(i,"AnimHandler");return new Promise(function(t){e[u]&&(e.removeEventListener("animationend",e[u]),e[u]=null);var r=function(){e.classList.remove(s,c,l),n?e.classList.remove(a):e.classList.add(a),e.removeEventListener("animationend",r),e[u]=null,t()};e.classList.remove(s,c,l),n?(e.classList.remove(a),e.classList.add(s,l)):e.classList.add(c,l),e[u]=r,e.addEventListener("animationend",r,{once:!0})})}t.addEventListener("DOMContentLoaded",function(){D(),j(),B()}),t.addEventListener("wpAjaxContentLoaded",function(){D(),j(),B()}),function($){$(function(){var e=$("#pvc-general-exclude-ips-setting"),n=e.find(".pvc-ip-box").length,r=function(){e.find(".pvc-remove-exclude-ip").each(function(e,t){0===e?t.classList.add("pvc-hidden"):n>1?t.classList.remove("pvc-hidden"):t.classList.add("pvc-hidden")})};r(),$(t).on("click",".reset_pvc_settings",function(){var e=confirm(pvcArgsSettings.resetToDefaults);return e&&$(this).hasClass("reset_post_views_counter_settings_other")&&$('input[data-pvc-menu="submenu"]').after($('input[data-pvc-menu="topmenu"]')),e}),$(t).on("click",'input[name="post_views_counter_reset_views"]',function(){return confirm(pvcArgsSettings.resetViews)}),$(t).on("click",'input[name="post_views_counter_import_views"]',function(){return confirm(pvcArgsSettings.importViews)}),$(t).on("click",".pvc-remove-exclude-ip",function(e){e.preventDefault();var t=$(this).closest(".pvc-ip-box")[0];z(t,!1).then(function(){t.remove(),n--,r()})});$(t).on("click",".pvc-add-exclude-ip",function(){var e=$(this).parents("#pvc-general-exclude-ips-setting"),t=e.find('.pvc-ip-box:last input[type="text"]');if(function(e){if(!e)return!1;var t=-1!==e.indexOf("*")?e.replace(/\*/g,"0"):e;return Boolean(t.match(/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/))}(t.val().trim())){n++;var o=e.find(".pvc-ip-box:last").clone();o.find("input").val(""),o[0].classList.add("pvc-hidden"),e.find(".pvc-ip-box:last").after(o),z(o[0],!0),r()}else t.focus()}),$(t).on("click",".pvc-add-current-ip",function(){$(this).parents("#pvc-general-exclude-ips-setting").find(".pvc-ip-box").last().find("input").val($(this).attr("data-rel"))}),$('input[name="post_views_counter_settings_display[menu_position]"], input[name="post_views_counter_settings_other[menu_position]"]').on("change",function(){"top"===$(this).val()?$('input[data-pvc-menu="submenu"]').after($('input[data-pvc-menu="topmenu"]')):$('input[data-pvc-menu="submenu"]').before($('input[data-pvc-menu="topmenu"]'))})})}(jQuery)}(jQuery,window,document); 1 ;(function($, window, document){ 2 const e=(e,t=0,n=1)=>e>n?n:e<t?t:e,t=(e,t=0,n=Math.pow(10,t))=>Math.round(n*e)/n,n=e=>("#"===e[0]&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:4===e.length?t(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:8===e.length?t(parseInt(e.substring(6,8),16)/255,2):1}),r=e=>{const{h:n,s:r,l:o}=(({h:e,s:n,v:r,a:o})=>{const i=(200-n)*r/100;return{h:t(e),s:t(i>0&&i<200?n*r/100/(i<=100?i:200-i)*100:0),l:t(i/2),a:t(o,2)}})(e);return`hsl(${n}, ${r}%, ${o}%)`},o=({h:e,s:n,v:r,a:o})=>{e=e/360*6,n/=100,r/=100;const i=Math.floor(e),a=r*(1-n),s=r*(1-(e-i)*n),c=r*(1-(1-e+i)*n),u=i%6;return{r:t(255*[r,s,a,a,c,r][u]),g:t(255*[c,r,r,s,a,a][u]),b:t(255*[a,a,c,r,r,s][u]),a:t(o,2)}},i=e=>{const t=e.toString(16);return t.length<2?"0"+t:t},a=({r:e,g:n,b:r,a:o})=>{const a=o<1?i(t(255*o)):"";return"#"+i(e)+i(n)+i(r)+a},s=({r:e,g:n,b:r,a:o})=>{const i=Math.max(e,n,r),a=i-Math.min(e,n,r),s=a?i===e?(n-r)/a:i===n?2+(r-e)/a:4+(e-n)/a:0;return{h:t(60*(s<0?s+6:s)),s:t(i?a/i*100:0),v:t(i/255*100),a:o}},c=(e,t)=>{if(e===t)return!0;for(const n in e)if(e[n]!==t[n])return!1;return!0},u={},l=e=>{let t=u[e];return t||(t=document.createElement("template"),t.innerHTML=e,u[e]=t),t},d=(e,t,n)=>{e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n}))};let f=!1;const v=e=>"touches"in e,p=(t,n)=>{const r=v(n)?n.touches[0]:n,o=t.el.getBoundingClientRect();d(t.el,"move",t.getMove({x:e((r.pageX-(o.left+window.pageXOffset))/o.width),y:e((r.pageY-(o.top+window.pageYOffset))/o.height)}))};class h{constructor(e,t,n,r){const o=l(`<div role="slider" tabindex="0" part="${t}" ${n}><div part="${t}-pointer"></div></div>`);e.appendChild(o.content.cloneNode(!0));const i=e.querySelector(`[part=${t}]`);i.addEventListener("mousedown",this),i.addEventListener("touchstart",this),i.addEventListener("keydown",this),this.el=i,this.xy=r,this.nodes=[i.firstChild,i]}set dragging(e){const t=e?document.addEventListener:document.removeEventListener;t(f?"touchmove":"mousemove",this),t(f?"touchend":"mouseup",this)}handleEvent(e){switch(e.type){case"mousedown":case"touchstart":if(e.preventDefault(),!(e=>!(f&&!v(e)||(f||(f=v(e)),0)))(e)||!f&&0!=e.button)return;this.el.focus(),p(this,e),this.dragging=!0;break;case"mousemove":case"touchmove":e.preventDefault(),p(this,e);break;case"mouseup":case"touchend":this.dragging=!1;break;case"keydown":((e,t)=>{const n=t.keyCode;n>40||e.xy&&n<37||n<33||(t.preventDefault(),d(e.el,"move",e.getMove({x:39===n?.01:37===n?-.01:34===n?.05:33===n?-.05:35===n?1:36===n?-1:0,y:40===n?.01:38===n?-.01:0},!0)))})(this,e)}}style(e){e.forEach((e,t)=>{for(const n in e)this.nodes[t].style.setProperty(n,e[n])})}}class m extends h{constructor(e){super(e,"hue",'aria-label="Hue" aria-valuemin="0" aria-valuemax="360"',!1)}update({h:e}){this.h=e,this.style([{left:e/360*100+"%",color:r({h:e,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuenow",`${t(e)}`)}getMove(t,n){return{h:n?e(this.h+360*t.x,0,360):360*t.x}}}class g extends h{constructor(e){super(e,"saturation",'aria-label="Color"',!0)}update(e){this.hsva=e,this.style([{top:100-e.v+"%",left:`${e.s}%`,color:r(e)},{"background-color":r({h:e.h,s:100,v:100,a:1})}]),this.el.setAttribute("aria-valuetext",`Saturation ${t(e.s)}%, Brightness ${t(e.v)}%`)}getMove(t,n){return{s:n?e(this.hsva.s+100*t.x,0,100):100*t.x,v:n?e(this.hsva.v-100*t.y,0,100):Math.round(100-100*t.y)}}}const b=Symbol("same"),y=Symbol("color"),x=Symbol("hsva"),E=Symbol("update"),w=Symbol("parts"),L=Symbol("css"),A=Symbol("sliders");class S extends HTMLElement{static get observedAttributes(){return["color"]}get[L](){return[':host{display:flex;flex-direction:column;position:relative;width:200px;height:200px;user-select:none;-webkit-user-select:none;cursor:default}:host([hidden]){display:none!important}[role=slider]{position:relative;touch-action:none;user-select:none;-webkit-user-select:none;outline:0}[role=slider]:last-child{border-radius:0 0 8px 8px}[part$=pointer]{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;display:flex;place-content:center center;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}[part$=pointer]::after{content:"";width:100%;height:100%;border-radius:inherit;background-color:currentColor}[role=slider]:focus [part$=pointer]{transform:translate(-50%,-50%) scale(1.1)}',"[part=hue]{flex:0 0 24px;background:linear-gradient(to right,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%)}[part=hue-pointer]{top:50%;z-index:2}","[part=saturation]{flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,rgba(255,255,255,0));box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}[part=saturation-pointer]{z-index:3}"]}get[A](){return[g,m]}get color(){return this[y]}set color(e){if(!this[b](e)){const t=this.colorModel.toHsva(e);this[E](t),this[y]=e}}constructor(){super();const e=l(`<style>${this[L].join("")}</style>`),t=this.attachShadow({mode:"open"});t.appendChild(e.content.cloneNode(!0)),t.addEventListener("move",this),this[w]=this[A].map(e=>new e(t))}connectedCallback(){if(this.hasOwnProperty("color")){const e=this.color;delete this.color,this.color=e}else this.color||(this.color=this.colorModel.defaultColor)}attributeChangedCallback(e,t,n){const r=this.colorModel.fromAttr(n);this[b](r)||(this.color=r)}handleEvent(e){const t=this[x],n={...t,...e.detail};let r;this[E](n),c(n,t)||this[b](r=this.colorModel.fromHsva(n))||(this[y]=r,d(this,"color-changed",{value:r}))}[b](e){return this.color&&this.colorModel.equal(e,this.color)}[E](e){this[x]=e,this[w].forEach(t=>t.update(e))}}const k={defaultColor:"#000",toHsva:e=>s(n(e)),fromHsva:({h:e,s:t,v:n})=>a(o({h:e,s:t,v:n,a:1})),equal:(e,t)=>e.toLowerCase()===t.toLowerCase()||c(n(e),n(t)),fromAttr:e=>e};class q extends S{get colorModel(){return k}}function _(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return C(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?C(e,t):void 0}}(e))||t){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw i}}}}function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function M(e){return M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},M(e)}customElements.define("hex-color-picker",class extends q{});var $,I=/^[0-9a-f]{3}([0-9a-f]{3})?$/i,P=function(e){if(!e)return"";var t=e.trim();if(!t)return"";var n=t.startsWith("#")?t.slice(1):t;return I.test(n)?"#".concat(n.toLowerCase()):""};function O(){var e=document.querySelector("[data-settings-prefix]"),t=e?e.dataset.settingsPrefix:"";if(t){var n=".".concat(t,"-hex-color-picker"),r=".".concat(t,"-field-type-color"),o=".".concat(t,"-color-input"),i=".".concat(t,"-color-swatch"),a=".".concat(t,"-color-popover"),s=".".concat(t,"-color-control"),c="".concat(t,"ColorInitialized");document.querySelectorAll(r).forEach(function(e){if("true"!==e.dataset[c]){var t=e.querySelector(o),r=e.querySelector(i),u=e.querySelector(a),l=e.querySelector(n),d=e.querySelector(s);if(t&&r&&u&&l&&d){l.addEventListener("mousedown",function(e){return e.stopPropagation()}),e.dataset[c]="true";var f=P(t.value)||"#000000",v=function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.setInput,i=void 0===o||o,a=n.dispatch,s=void 0===a||a,c=n.setPicker,u=void 0===c||c,d=P(e);return!!d&&(f=d,i&&(t.value=d),r.style.backgroundColor=d,u&&l.color!==d&&(l.color=d),s&&t.dispatchEvent(new Event("input",{bubbles:!0})),!0)},p=function(){e.classList.contains("is-open")||(e.classList.add("is-open"),u.removeAttribute("aria-hidden"),r.setAttribute("aria-expanded","true"),document.addEventListener("mousedown",m,!0),document.addEventListener("keydown",g))},h=function(){e.classList.contains("is-open")&&(e.classList.remove("is-open"),u.setAttribute("aria-hidden","true"),r.setAttribute("aria-expanded","false"),document.removeEventListener("mousedown",m,!0),document.removeEventListener("keydown",g))},m=function(e){var t="function"==typeof e.composedPath?e.composedPath():[];d.contains(e.target)||t.includes(d)||t.includes(u)||t.includes(l)||h()},g=function(e){"Escape"===e.key&&h()};v(f,{setInput:!0,dispatch:!1}),r.addEventListener("click",function(t){t.preventDefault(),e.classList.contains("is-open")?h():p()}),t.addEventListener("click",p),t.addEventListener("input",function(){var e=P(t.value);e&&(t.value!==e&&(t.value=e),f=e,r.style.backgroundColor=e,l.color!==e&&(l.color=e))}),t.addEventListener("blur",function(){v(t.value,{setInput:!0,dispatch:!1})||v(f,{setInput:!0,dispatch:!1})}),l.addEventListener("color-changed",function(e){v(e.detail.value,{setPicker:!1})})}}})}}function H(){document.querySelectorAll('input[type="range"][data-range-output]').forEach(function(e){var t=e.getAttribute("data-range-output"),n=document.getElementById(t);n&&e.addEventListener("input",function(){n.textContent=e.value})})}function D(){var e=document.querySelector("[data-settings-prefix]"),t=e?e.dataset.settingsPrefix:"";if(t){var n="data-".concat(t,"-logic"),r="data-".concat(t,"-fallback-option"),o="".concat(t,"-hidden"),i="".concat(t,"CondDisabled"),a="_".concat(t,"AnimHandler"),s=[],c=new Map;document.querySelectorAll("[".concat(n,"]")).forEach(function(e){var o,i,a=function(e){var t=e.getAttribute(n);if(!t)return[];try{var r=JSON.parse(t);if(Array.isArray(r))return r;if(r&&"object"===M(r))return[r]}catch(o){return[]}return[]}(e);if(a.length){var u=a.map(function(e){return{field:e.field,operator:e.operator,value:e.value,scope:e.scope||"field",action:e.action||"",target:e.target||"",container:e.container||""}}),l=(null===(o=u.find(function(e){return e.container}))||void 0===o?void 0:o.container)||"",d=null;"self"===l?d=e:l&&(d=e.querySelector(l)||document.querySelector(l)),d||(d=e.closest("tr")||e);var f=e.getAttribute("data-".concat(t,"-animation")),v=(null===(i=u.find(function(e){return e.action}))||void 0===i?void 0:i.action)||"show",p=e.getAttribute(r)||"",h={el:e,row:d,logic:u,animation:f,defaultAction:v,fallbackOption:p};s.push(h),u.forEach(function(e){c.has(e.field)||c.set(e.field,[]);var t=c.get(e.field);t.includes(h)||t.push(h)})}});var u=function(e){var t=function(e){var t=document.getElementById(e);if(t)return"checkbox"===t.type||"radio"===t.type?t.checked?t.value:"":t.value;var n=document.querySelectorAll('input[type="radio"][id^="'.concat(e,'-"]'));if(n.length>0){var r,o=_(n);try{for(o.s();!(r=o.n()).done;){var i=r.value;if(i.checked)return i.value}}catch(c){o.e(c)}finally{o.f()}return null}var a=document.querySelectorAll('input[type="checkbox"][id^="'.concat(e,'-"]'));if(a.length>0){var s=[];return a.forEach(function(e){e.checked&&s.push(e.value)}),s}return null}(e.field);if(null===t)return!1;switch(e.operator){case"is":return t===e.value;case"isnot":return t!==e.value;case"contains":return("string"==typeof t||Array.isArray(t))&&t.includes(e.value);case"containsnot":return("string"==typeof t||Array.isArray(t))&&!t.includes(e.value);default:return!1}},l=function(e,n){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=e.row,s=e.animation,c=i.classList.contains(o);if(n===!c)return Promise.resolve();if(!r||!s||!["fade","slide"].includes(s))return i.classList.toggle(o,!n),Promise.resolve();var u="".concat(t,"-anim-in"),l="".concat(t,"-anim-out"),d="".concat(t,"-anim-").concat(s);return new Promise(function(e){i[a]&&(i.removeEventListener("animationend",i[a]),i[a]=null);var t=function(){i.classList.remove(u,l,d),n?i.classList.remove(o):i.classList.add(o),i.removeEventListener("animationend",t),i[a]=null,e()};i.classList.remove(u,l,d),n?(i.classList.remove(o),i.classList.add(u,d)):i.classList.add(l,d),i[a]=t,i.addEventListener("animationend",t,{once:!0})})},d=function(e,t){e.el.querySelectorAll("input, select, textarea, button").forEach(function(e){t?e.disabled||(e.dataset[i]="true",e.disabled=!0):"true"===e.dataset[i]&&(e.disabled=!1,delete e.dataset[i])})},f=function(e,t,n,r){var a=e.action||r;if(a){var s=function(e,t){if(e.target)return Array.from(document.querySelectorAll(e.target));var n=t.el.querySelectorAll('input[type="radio"]');if(n.length)return Array.from(n).filter(function(t){return t.value===e.value});var r=t.el.querySelectorAll('input[type="checkbox"]');if(r.length)return Array.from(r).filter(function(t){return t.value===e.value});var o=t.el.querySelector("select");return o?Array.from(o.options).filter(function(t){return t.value===e.value}):[]}(e,t);s.length&&s.forEach(function(e){if("disable"===a||"enable"===a)!function(e,t){t?e.disabled||(e.dataset[i]="true",e.disabled=!0):"true"===e.dataset[i]&&(e.disabled=!1,delete e.dataset[i])}(e,"disable"===a?n:!n);else if("show"===a||"hide"===a){var t="show"===a?n:!n;e.classList.toggle(o,!t)}})}},v=function(e){if(e.fallbackOption){var t=e.el.querySelectorAll('input[type="radio"]');if(t.length){var n=Array.from(t).find(function(e){return e.checked});if(!n||n.disabled){var r=Array.from(t).find(function(t){return t.value===e.fallbackOption&&!t.disabled});r||(r=Array.from(t).find(function(e){return!e.disabled})||null),r&&!r.checked&&(r.checked=!0,r.dispatchEvent(new Event("change",{bubbles:!0})))}}else{var o=e.el.querySelector("select");if(o){var i=o.options[o.selectedIndex];if(i&&!i.disabled)return;var a=Array.from(o.options).find(function(t){return t.value===e.fallbackOption&&!t.disabled});a||(a=Array.from(o.options).find(function(e){return!e.disabled})),a&&(o.value=a.value,o.dispatchEvent(new Event("change",{bubbles:!0})))}}}},p=new Set,h=new Map;c.forEach(function(e,t){if(!p.has(t)){h.has(t)||h.set(t,{seq:0});!function(e,t){var n=document.getElementById(e);if(n)return n.addEventListener("change",t),void n.addEventListener("input",t);document.querySelectorAll('input[type="radio"][id^="'.concat(e,'-"]')).forEach(function(e){e.addEventListener("change",t)}),document.querySelectorAll('input[type="checkbox"][id^="'.concat(e,'-"]')).forEach(function(e){e.addEventListener("change",t)})}(t,function(){var n=h.get(t),r=++n.seq,i=[],a=[];if(e.forEach(function(e){var t,n=e.logic.filter(function(e){return"option"===e.scope}),r=e.logic.filter(function(e){return"option"!==e.scope});if(n.forEach(function(t){var n=u(t);f(t,e,n,e.defaultAction)}),v(e),r.length){var s=(null===(t=r.find(function(e){return e.action}))||void 0===t?void 0:t.action)||e.defaultAction,c=r.every(function(e){return u(e)});if("enable"!==s&&"disable"!==s){var l=e.row.classList.contains(o),p="show"===s?c:!c;p&&l?a.push(e):p||l||i.push(e)}else{d(e,"disable"===s?c:!c)}}}),i.length>0){var s=i.map(function(e){return l(e,!1,!0)});Promise.all(s).then(function(){n.seq===r&&a.forEach(function(e){return l(e,!0,!0)})})}else a.forEach(function(e){return l(e,!0,!0)})}),p.add(t)}}),s.forEach(function(e){var t,n=e.logic.filter(function(e){return"option"===e.scope}),r=e.logic.filter(function(e){return"option"!==e.scope});if(n.forEach(function(t){var n=u(t);f(t,e,n,e.defaultAction)}),v(e),r.length){var o=(null===(t=r.find(function(e){return e.action}))||void 0===t?void 0:t.action)||e.defaultAction,i=r.every(function(e){return u(e)});if("enable"!==o&&"disable"!==o)l(e,"show"===o?i:!i,!1);else d(e,"disable"===o?i:!i)}})}}function j(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"slide",r=document.querySelector("[data-settings-prefix]"),o=r?r.dataset.settingsPrefix:"";if(!o)return e.style.display=t?"":"none",Promise.resolve();var i="".concat(o,"-hidden"),a="".concat(o,"-anim-in"),s="".concat(o,"-anim-out"),c="".concat(o,"-anim-").concat(n),u="_".concat(o,"AnimHandler");return new Promise(function(n){e[u]&&(e.removeEventListener("animationend",e[u]),e[u]=null);var r=function(){e.classList.remove(a,s,c),t?e.classList.remove(i):e.classList.add(i),e.removeEventListener("animationend",r),e[u]=null,n()};e.classList.remove(a,s,c),t?(e.classList.remove(i),e.classList.add(a,c)):e.classList.add(s,c),e[u]=r,e.addEventListener("animationend",r,{once:!0})})}document.addEventListener("DOMContentLoaded",function(){O(),H(),D()}),document.addEventListener("wpAjaxContentLoaded",function(){O(),H(),D()}),($=jQuery)(function(){var e=$("#pvc-general-exclude-ips-setting"),t=e.find(".pvc-ip-box").length,n=function(){e.find(".pvc-remove-exclude-ip").each(function(e,n){0===e?n.classList.add("pvc-hidden"):t>1?n.classList.remove("pvc-hidden"):n.classList.add("pvc-hidden")})};n(),$(document).on("click",".reset_pvc_settings",function(){var e=confirm(pvcArgsSettings.resetToDefaults);return e&&$(this).hasClass("reset_post_views_counter_settings_other")&&$('input[data-pvc-menu="submenu"]').after($('input[data-pvc-menu="topmenu"]')),e}),$(document).on("click",'input[name="post_views_counter_reset_views"]',function(){return confirm(pvcArgsSettings.resetViews)}),$(document).on("click",'input[name="post_views_counter_import_views"]',function(){return confirm(pvcArgsSettings.importViews)}),$(document).on("click",".pvc-remove-exclude-ip",function(e){e.preventDefault();var r=$(this).closest(".pvc-ip-box")[0];j(r,!1).then(function(){r.remove(),t--,n()})}),$(document).on("click",".pvc-add-exclude-ip",function(){var e=$(this).parents("#pvc-general-exclude-ips-setting"),r=e.find('.pvc-ip-box:last input[type="text"]');if(function(e){if(!e)return!1;var t=-1!==e.indexOf("*")?e.replace(/\*/g,"0"):e;return Boolean(t.match(/^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/))}(r.val().trim())){t++;var o=e.find(".pvc-ip-box:last").clone();o.find("input").val(""),o[0].classList.add("pvc-hidden"),e.find(".pvc-ip-box:last").after(o),j(o[0],!0),n()}else r.focus()}),$(document).on("click",".pvc-add-current-ip",function(){$(this).parents("#pvc-general-exclude-ips-setting").find(".pvc-ip-box").last().find("input").val($(this).attr("data-rel"))}),$('input[name="post_views_counter_settings_display[menu_position]"], input[name="post_views_counter_settings_other[menu_position]"]').on("change",function(){"top"===$(this).val()?$('input[data-pvc-menu="submenu"]').after($('input[data-pvc-menu="topmenu"]')):$('input[data-pvc-menu="submenu"]').before($('input[data-pvc-menu="topmenu"]'))})}); 3 4 })(jQuery, window, document); -
post-views-counter/trunk/js/admin-widgets.js
r3442638 r3443281 1 !function($,n,t){!function($){$(function(){$(t).on("change",".pvc-show-post-thumbnail",function(n){$(n.currentTarget).closest(".widget-content").find(".pvc-post-thumbnail-size").fadeToggle(300)})})}(jQuery)}(jQuery,window,document); 1 ;(function($, window, document){ 2 var $;($=jQuery)(function(){$(document).on("change",".pvc-show-post-thumbnail",function(n){$(n.currentTarget).closest(".widget-content").find(".pvc-post-thumbnail-size").fadeToggle(300)})}); 3 4 })(jQuery, window, document); -
post-views-counter/trunk/js/block-editor.js
r3442638 r3443281 1 1 (function(){ 2 !function(){function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){for(var i=0;i<t.length;i++){var o=t[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,n(o.key),o)}}function n(t){var n=function(t,n){if("object"!=e(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var o=i.call(t,n);if("object"!=e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==e(n)?n:n+""}function i(t,n,i){return n=s(n),function(t,n){if(n&&("object"==e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(t,o()?Reflect.construct(n,i||[],s(t).constructor):n.apply(t,i))}function o(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(o=function(){return!!e})()}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function r(e,t){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},r(e,t)}var l=wp.element,a=l.Fragment,c=l.Component,p=wp.data.withSelect,u=wp.plugins.registerPlugin,d=wp.components,w=d.TextControl,m=d.Button,v=d.Popover,f=wp.editPost.PluginPostStatusInfo,h=function(e){function n(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),(e=i(this,n,arguments)).state={postViews:pvcEditorArgs.postViews,isVisible:!1},e.handleClick=e.handleClick.bind(e),e.handleClickOutside=e.handleClickOutside.bind(e),e.handleCancel=e.handleCancel.bind(e),e.handleSetViews=e.handleSetViews.bind(e),e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t)}(n,e),o=n,s=[{key:"handleClick",value:function(e){e.target.classList.contains("edit-post-post-views-toggle-link")&&this.setState(function(e){return{isVisible:!e.isVisible}})}},{key:"handleClickOutside",value:function(e){e.target.classList.contains("edit-post-post-views-toggle-link")||this.setState(function(e){return{isVisible:!e.isVisible}})}},{key:"handleCancel",value:function(e){this.setState(function(e){return{postViews:pvcEditorArgs.postViews,isVisible:!e.isVisible}})}},{key:"handleSetViews",value:function(e){wp.data.dispatch("core/editor").editPost({meta:{_pvc_post_views:e}}),this.setState(function(){return{postViews:e}})}},{key:"render",value:function(){return wp.element.createElement(b,{postViews:this.state.postViews,isVisible:this.state.isVisible,handleClick:this.handleClick,handleClickOutside:this.handleClickOutside,handleCancel:this.handleCancel,handleSetViews:this.handleSetViews})}}],l=[{key:"getDerivedStateFromProps",value:function(e,t){!e.isPublishing&&!e.isSaving||e.isAutoSaving||wp.apiRequest({path:"/post-views-counter/update-post-views/?id=".concat(e.postId),method:"POST",data:{post_views:t.postViews}}).then(function(e){return e},function(e){return e})}}],s&&t(o.prototype,s),l&&t(o,l),Object.defineProperty(o,"prototype",{writable:!1}),o;var o,s,l}(c),b=function(e){return wp.element.createElement(a,null,wp.element.createElement(f,{className:"edit-post-post-views"},wp.element.createElement("div",{className:"editor-post-panel__row-label"},wp.element.createElement("span",null,pvcEditorArgs.textPostViews)),!pvcEditorArgs.canEdit&&wp.element.createElement("div",{className:"editor-post-panel__row-control"},wp.element.createElement("div",{className:"components-dropdown edit-post-post-views-popover-wrapper"},wp.element.createElement(m,{size:"compact",variant:"tertiary",disabled:!0,className:"components-button edit-post-post-views-toggle-link"},e.postViews))),pvcEditorArgs.canEdit&&wp.element.createElement("div",{className:"editor-post-panel__row-control"},wp.element.createElement("div",{className:"components-dropdown edit-post-post-views-popover-wrapper"},wp.element.createElement(m,{size:"compact",variant:"tertiary",className:"components-button edit-post-post-views-toggle-link",onClick:e.handleClick},e.postViews,e.isVisible&&(pvcEditorArgs.wpGreater53?wp.element.createElement(v,{position:"bottom right",className:"edit-post-post-views-popover",onFocusOutside:e.handleClickOutside},wp.element.createElement("legend",null,pvcEditorArgs.textPostViews),wp.element.createElement(w,{className:"edit-post-post-views-input",type:"number",key:"post_views",value:e.postViews,onChange:e.handleSetViews}),wp.element.createElement("p",{className:"description"},pvcEditorArgs.textHelp),wp.element.createElement(m,{isLink:!0,className:"edit-post-post-views-cancel-link",onClick:e.handleCancel},pvcEditorArgs.textCancel)):wp.element.createElement(v,{position:"bottom right",className:"edit-post-post-views-popover",onClickOutside:e.handleClickOutside},wp.element.createElement("legend",null,pvcEditorArgs.textPostViews),wp.element.createElement(w,{className:"edit-post-post-views-input",type:"number",key:"post_views",value:e.postViews,onChange:e.handleSetViews}),wp.element.createElement("p",{className:"description"},pvcEditorArgs.textHelp),wp.element.createElement(m,{isLink:!0,className:"edit-post-post-views-cancel-link",onClick:e.handleCancel},pvcEditorArgs.textCancel))))))))};u("post-views-counter",{icon:"",render:p(function(e,t){var n=t.forceIsSaving,i=e("core/editor"),o=i.getCurrentPostId,s=i.isSavingPost,r=i.isPublishingPost,l=i.isAutosavingPost;return{postId:o(),isSaving:n||s(),isAutoSaving:l(),isPublishing:r()}})(h)})}(jQuery,window,document);2 function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){for(var i=0;i<t.length;i++){var o=t[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,n(o.key),o)}}function n(t){var n=function(t,n){if("object"!=e(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var o=i.call(t,n);if("object"!=e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==e(n)?n:n+""}function i(t,n,i){return n=s(n),function(t,n){if(n&&("object"==e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(t,o()?Reflect.construct(n,i||[],s(t).constructor):n.apply(t,i))}function o(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(o=function(){return!!e})()}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function r(e,t){return r=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},r(e,t)}var l=wp.element,a=l.Fragment,c=l.Component,p=wp.data.withSelect,u=wp.plugins.registerPlugin,d=wp.components,w=d.TextControl,m=d.Button,v=d.Popover,f=wp.editPost.PluginPostStatusInfo,h=function(){function e(){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),(t=i(this,e,arguments)).state={postViews:pvcEditorArgs.postViews,isVisible:!1},t.handleClick=t.handleClick.bind(t),t.handleClickOutside=t.handleClickOutside.bind(t),t.handleCancel=t.handleCancel.bind(t),t.handleSetViews=t.handleSetViews.bind(t),t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t)}(e,c),n=e,o=[{key:"handleClick",value:function(e){e.target.classList.contains("edit-post-post-views-toggle-link")&&this.setState(function(e){return{isVisible:!e.isVisible}})}},{key:"handleClickOutside",value:function(e){e.target.classList.contains("edit-post-post-views-toggle-link")||this.setState(function(e){return{isVisible:!e.isVisible}})}},{key:"handleCancel",value:function(e){this.setState(function(e){return{postViews:pvcEditorArgs.postViews,isVisible:!e.isVisible}})}},{key:"handleSetViews",value:function(e){wp.data.dispatch("core/editor").editPost({meta:{_pvc_post_views:e}}),this.setState(function(){return{postViews:e}})}},{key:"render",value:function(){return wp.element.createElement(b,{postViews:this.state.postViews,isVisible:this.state.isVisible,handleClick:this.handleClick,handleClickOutside:this.handleClickOutside,handleCancel:this.handleCancel,handleSetViews:this.handleSetViews})}}],s=[{key:"getDerivedStateFromProps",value:function(e,t){!e.isPublishing&&!e.isSaving||e.isAutoSaving||wp.apiRequest({path:"/post-views-counter/update-post-views/?id=".concat(e.postId),method:"POST",data:{post_views:t.postViews}}).then(function(e){return e},function(e){return e})}}],o&&t(n.prototype,o),s&&t(n,s),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,o,s}(),b=function(e){return wp.element.createElement(a,null,wp.element.createElement(f,{className:"edit-post-post-views"},wp.element.createElement("div",{className:"editor-post-panel__row-label"},wp.element.createElement("span",null,pvcEditorArgs.textPostViews)),!pvcEditorArgs.canEdit&&wp.element.createElement("div",{className:"editor-post-panel__row-control"},wp.element.createElement("div",{className:"components-dropdown edit-post-post-views-popover-wrapper"},wp.element.createElement(m,{size:"compact",variant:"tertiary",disabled:!0,className:"components-button edit-post-post-views-toggle-link"},e.postViews))),pvcEditorArgs.canEdit&&wp.element.createElement("div",{className:"editor-post-panel__row-control"},wp.element.createElement("div",{className:"components-dropdown edit-post-post-views-popover-wrapper"},wp.element.createElement(m,{size:"compact",variant:"tertiary",className:"components-button edit-post-post-views-toggle-link",onClick:e.handleClick},e.postViews,e.isVisible&&(pvcEditorArgs.wpGreater53?wp.element.createElement(v,{position:"bottom right",className:"edit-post-post-views-popover",onFocusOutside:e.handleClickOutside},wp.element.createElement("legend",null,pvcEditorArgs.textPostViews),wp.element.createElement(w,{className:"edit-post-post-views-input",type:"number",key:"post_views",value:e.postViews,onChange:e.handleSetViews}),wp.element.createElement("p",{className:"description"},pvcEditorArgs.textHelp),wp.element.createElement(m,{isLink:!0,className:"edit-post-post-views-cancel-link",onClick:e.handleCancel},pvcEditorArgs.textCancel)):wp.element.createElement(v,{position:"bottom right",className:"edit-post-post-views-popover",onClickOutside:e.handleClickOutside},wp.element.createElement("legend",null,pvcEditorArgs.textPostViews),wp.element.createElement(w,{className:"edit-post-post-views-input",type:"number",key:"post_views",value:e.postViews,onChange:e.handleSetViews}),wp.element.createElement("p",{className:"description"},pvcEditorArgs.textHelp),wp.element.createElement(m,{isLink:!0,className:"edit-post-post-views-cancel-link",onClick:e.handleCancel},pvcEditorArgs.textCancel))))))))};u("post-views-counter",{icon:"",render:p(function(e,t){var n=t.forceIsSaving,i=e("core/editor"),o=i.getCurrentPostId,s=i.isSavingPost,r=i.isPublishingPost,l=i.isAutosavingPost;return{postId:o(),isSaving:n||s(),isAutoSaving:l(),isPublishing:r()}})(h)}); 3 3 4 4 })(); -
post-views-counter/trunk/js/column-modal.js
r3442638 r3443281 1 !function($,a,o){!function($){if(void 0!==$){var a=null,e=null;if("undefined"!=typeof pvcColumnModal){var t=function(a,o){var e=$(".pvc-modal-chart-container");e.addClass("loading"),e.find(".spinner").addClass("is-active"),$.ajax({url:pvcColumnModal.ajaxURL,type:"POST",dataType:"json",data:{action:"pvc_column_chart",nonce:pvcColumnModal.nonce,post_id:a,period:o},success:function(a){a.success?n(a.data):l(a.data.message||pvcColumnModal.i18n.error)},error:function(){l(pvcColumnModal.i18n.error)},complete:function(){e.removeClass("loading"),e.find(".spinner").removeClass("is-active")}})},n=function(e){var t=o.getElementById("pvc-modal-chart");if(t){a&&(a.destroy(),a=null),$(".pvc-modal-error").remove(),$(t).show(),$(".pvc-modal-views-label").text(pvcColumnModal.i18n.summary),$(".pvc-modal-count").text(e.total_views.toLocaleString()),$(".pvc-modal-dates").html(e.dates_html);var n={type:"line",data:e.data,options:{maintainAspectRatio:!1,responsive:!0,plugins:{legend:{display:!1},tooltip:{callbacks:{title:function(a){return e.data.dates[a[0].dataIndex]},label:function(a){var o=a.parsed.y,e=1===o?pvcColumnModal.i18n.view:pvcColumnModal.i18n.views;return"".concat(o.toLocaleString()," ").concat(e)}}}},scales:{x:{display:!0,grid:{display:!1}},y:{display:!0,beginAtZero:!0,ticks:{precision:0},grid:{color:"rgba(0, 0, 0, 0.05)"}}}}};e.design&&n.data.datasets.forEach(function(a){Object.assign(a,e.design),a.tension=.4}),a=new Chart(t.getContext("2d"),n)}},l=function(o){a&&(a.destroy(),a=null),$(".pvc-modal-summary").text(""),$(".pvc-modal-dates").html("");var e=$(".pvc-modal-chart-container");e.removeClass("loading"),e.find(".spinner").removeClass("is-active"),$(".pvc-modal-error").remove(),e.before('<p class="pvc-modal-error">'.concat(o,"</p>")),e.find("canvas").hide()};$(function(){0!==$("#pvc-chart-modal").length&&"undefined"!=typeof MicroModal&&(MicroModal.init({disableScroll:!0,awaitCloseAnimation:!0}),1)&&($(o).on("click",".pvc-view-chart",function(o){o.preventDefault();var n=$(o.currentTarget),l=n.data("post-id"),i=n.data("post-title");l&&function(a,o){if(!a)return!1;e=a,$("#pvc-modal-title").text(o);var t=$(".pvc-modal-chart-container");return t.addClass("loading"),t.find(".spinner").addClass("is-active"),$(".pvc-modal-views-label").text(""),$(".pvc-modal-count").text(""),$(".pvc-modal-dates").html(""),!0}(l,i)&&"undefined"!=typeof MicroModal&&MicroModal.show("pvc-chart-modal",{onShow:function(){e&&t(e,"")},onClose:function(){a&&(a.destroy(),a=null),e=null,function(){$("#pvc-modal-title").text(""),$(".pvc-modal-views-label").text(""),$(".pvc-modal-count").text(""),$(".pvc-modal-dates").html("");var a=$(".pvc-modal-chart-container");a.removeClass("loading"),a.find(".spinner").removeClass("is-active"),$(".pvc-modal-error").remove()}()},disableScroll:!0,awaitCloseAnimation:!0})}),$(o).on("click",".pvc-modal-nav-prev, .pvc-modal-nav-next",function(a){a.preventDefault();var o=$(a.currentTarget);if(!o.hasClass("pvc-disabled")){var n=o.data("period");n&&e&&t(e,n)}}))})}}}(jQuery)}(jQuery,window,document); 1 ;(function($, window, document){ 2 !function($){if(void 0!==$){var a=null,o=null;if("undefined"!=typeof pvcColumnModal){var e=function(a,o){var e=$(".pvc-modal-chart-container");e.addClass("loading"),e.find(".spinner").addClass("is-active"),$.ajax({url:pvcColumnModal.ajaxURL,type:"POST",dataType:"json",data:{action:"pvc_column_chart",nonce:pvcColumnModal.nonce,post_id:a,period:o},success:function(a){a.success?t(a.data):n(a.data.message||pvcColumnModal.i18n.error)},error:function(){n(pvcColumnModal.i18n.error)},complete:function(){e.removeClass("loading"),e.find(".spinner").removeClass("is-active")}})},t=function(o){var e=document.getElementById("pvc-modal-chart");if(e){a&&(a.destroy(),a=null),$(".pvc-modal-error").remove(),$(e).show(),$(".pvc-modal-views-label").text(pvcColumnModal.i18n.summary),$(".pvc-modal-count").text(o.total_views.toLocaleString()),$(".pvc-modal-dates").html(o.dates_html);var t={type:"line",data:o.data,options:{maintainAspectRatio:!1,responsive:!0,plugins:{legend:{display:!1},tooltip:{callbacks:{title:function(a){return o.data.dates[a[0].dataIndex]},label:function(a){var o=a.parsed.y,e=1===o?pvcColumnModal.i18n.view:pvcColumnModal.i18n.views;return"".concat(o.toLocaleString()," ").concat(e)}}}},scales:{x:{display:!0,grid:{display:!1}},y:{display:!0,beginAtZero:!0,ticks:{precision:0},grid:{color:"rgba(0, 0, 0, 0.05)"}}}}};o.design&&t.data.datasets.forEach(function(a){Object.assign(a,o.design),a.tension=.4}),a=new Chart(e.getContext("2d"),t)}},n=function(o){a&&(a.destroy(),a=null),$(".pvc-modal-summary").text(""),$(".pvc-modal-dates").html("");var e=$(".pvc-modal-chart-container");e.removeClass("loading"),e.find(".spinner").removeClass("is-active"),$(".pvc-modal-error").remove(),e.before('<p class="pvc-modal-error">'.concat(o,"</p>")),e.find("canvas").hide()};$(function(){0!==$("#pvc-chart-modal").length&&"undefined"!=typeof MicroModal&&(MicroModal.init({disableScroll:!0,awaitCloseAnimation:!0}),1)&&($(document).on("click",".pvc-view-chart",function(t){t.preventDefault();var n=$(t.currentTarget),l=n.data("post-id"),i=n.data("post-title");l&&function(a,e){if(!a)return!1;o=a,$("#pvc-modal-title").text(e);var t=$(".pvc-modal-chart-container");return t.addClass("loading"),t.find(".spinner").addClass("is-active"),$(".pvc-modal-views-label").text(""),$(".pvc-modal-count").text(""),$(".pvc-modal-dates").html(""),!0}(l,i)&&"undefined"!=typeof MicroModal&&MicroModal.show("pvc-chart-modal",{onShow:function(){o&&e(o,"")},onClose:function(){a&&(a.destroy(),a=null),o=null,function(){$("#pvc-modal-title").text(""),$(".pvc-modal-views-label").text(""),$(".pvc-modal-count").text(""),$(".pvc-modal-dates").html("");var a=$(".pvc-modal-chart-container");a.removeClass("loading"),a.find(".spinner").removeClass("is-active"),$(".pvc-modal-error").remove()}()},disableScroll:!0,awaitCloseAnimation:!0})}),$(document).on("click",".pvc-modal-nav-prev, .pvc-modal-nav-next",function(a){a.preventDefault();var t=$(a.currentTarget);if(!t.hasClass("pvc-disabled")){var n=t.data("period");n&&o&&e(o,n)}}))})}}}(jQuery); 3 4 })(jQuery, window, document); -
post-views-counter/trunk/js/counter.js
r3442638 r3443281 1 !function($,o,n){function t(o){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},t(o)}o.PostViewsCounterManual={init:function(o){var n=this,e={action:"pvc-view-posts",pvc_nonce:o.nonce,ids:o.ids},c=Object.keys(e).map(function(o){return"".concat(encodeURIComponent(o),"=").concat(encodeURIComponent(e[o]))}).join("&").replace(/%20/g,"+");return fetch(o.url,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:c}).then(function(o){if(!o.ok)throw Error(o.statusText);return o.json()}).then(function(o){try{"object"===t(o)&&null!==o&&n.triggerEvent("pvcCheckPost",o)}catch(e){console.log("Invalid JSON data"),console.log(e)}}).catch(function(o){console.log("Invalid response"),console.log(o)})},triggerEvent:function(o,t){var e=new CustomEvent(o,{bubbles:!0,detail:t});n.dispatchEvent(e)}}}(jQuery,window,document);1 function o(n){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},o(n)}window.PostViewsCounterManual={init:function(n){var t=this,e={action:"pvc-view-posts",pvc_nonce:n.nonce,ids:n.ids},c=Object.keys(e).map(function(o){return"".concat(encodeURIComponent(o),"=").concat(encodeURIComponent(e[o]))}).join("&").replace(/%20/g,"+");return fetch(n.url,{method:"POST",mode:"cors",cache:"no-cache",credentials:"same-origin",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},body:c}).then(function(o){if(!o.ok)throw Error(o.statusText);return o.json()}).then(function(n){try{"object"===o(n)&&null!==n&&t.triggerEvent("pvcCheckPost",n)}catch(e){console.log("Invalid JSON data"),console.log(e)}}).catch(function(o){console.log("Invalid response"),console.log(o)})},triggerEvent:function(o,n){var t=new CustomEvent(o,{bubbles:!0,detail:n});document.dispatchEvent(t)}}; -
post-views-counter/trunk/js/frontend.js
r3442638 r3443281 1 !function($,t,e){function o(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var o=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=o){var n,r,a,c,i=[],s=!0,u=!1;try{if(a=(o=o.call(t)).next,0===e);else for(;!(s=(n=a.call(o)).done)&&(i.push(n.value),i.length!==e);s=!0);}catch(t){u=!0,r=t}finally{try{if(!s&&null!=o.return&&(c=o.return(),Object(c)!==c))return}finally{if(u)throw r}}return i}}(t,e)||function(t,e){if(t){if("string"==typeof t)return n(t,e);var o={}.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?n(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,n=Array(e);o<e;o++)n[o]=t[o];return n}function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}t.PostViewsCounter={promise:null,args:{},init:function(t){this.args=t;var e={storage_type:"cookies",storage_data:this.readCookieData("pvc_visits".concat(!1!==t.multisite?"_".concat(parseInt(t.multisite,10)):""))};"rest_api"===t.mode?this.promise=this.request(t.requestURL,e,"POST",{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8","X-WP-Nonce":t.nonce}):(e.action="pvc-check-post",e.pvc_nonce=t.nonce,e.id=t.postID,this.promise=this.request(t.requestURL,e,"POST",{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"}))},request:function(t,e,o,n){var a=this,c={method:o,mode:"cors",cache:"no-cache",credentials:"same-origin",headers:n,body:this.prepareRequestData(e)};return fetch(t,c).then(function(t){if(!t.ok)throw Error(t.statusText);return t.json()}).then(function(t){try{"object"===r(t)&&null!==t?"success"in t&&!1===t.success?(console.log("PVC: Request error."),console.log(t.data)):(a.saveCookieData(t.storage),a.triggerEvent("pvcCheckPost",t)):(console.log("PVC: Invalid object."),console.log(t))}catch(e){console.log("PVC: Invalid JSON data."),console.log(e)}}).catch(function(t){console.log("PVC: Invalid response."),console.log(t)})},prepareRequestData:function(t){return Object.keys(t).map(function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t[e]))}).join("&").replace(/%20/g,"+")},triggerEvent:function(t,o){var n=new CustomEvent(t,{bubbles:!0,detail:o});e.dispatchEvent(n)},saveCookieData:function(t){if(t&&Object.prototype.hasOwnProperty.call(t,"name")){var o="";"https:"===e.location.protocol&&(o=";secure");for(var n=0;n<t.name.length;n++){var r=new Date,a=parseInt(t.expiry[n],10);a?a*=1e3:a=r.getTime()+864e5,r.setTime(a),e.cookie="".concat(t.name[n],"=").concat(t.value[n],";expires=").concat(r.toUTCString(),";path=/").concat("/"===this.args.path?"":this.args.path,";domain=").concat(this.args.domain).concat(o,";SameSite=Lax")}}},readCookieData:function(t){var n=[];return e.cookie.split(";").forEach(function(e){var r=o(e.split("="),2),a=r[0],c=r[1],i=a.trim();new RegExp("".concat(t,"\\[\\d+\\]")).test(i)&&n.push(c)}),n.join("a")}};var a=function(){return t.PostViewsCounter.init(pvcArgsFrontend)};"loading"===e.readyState?e.addEventListener("DOMContentLoaded",a):a()}(jQuery,window,document);1 function t(t,o){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var o=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=o){var n,r,a,c,i=[],s=!0,u=!1;try{if(a=(o=o.call(t)).next,0===e);else for(;!(s=(n=a.call(o)).done)&&(i.push(n.value),i.length!==e);s=!0);}catch(t){u=!0,r=t}finally{try{if(!s&&null!=o.return&&(c=o.return(),Object(c)!==c))return}finally{if(u)throw r}}return i}}(t,o)||function(t,o){if(t){if("string"==typeof t)return e(t,o);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,o):void 0}}(t,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,n=Array(e);o<e;o++)n[o]=t[o];return n}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}window.PostViewsCounter={promise:null,args:{},init:function(t){this.args=t;var e={storage_type:"cookies",storage_data:this.readCookieData("pvc_visits".concat(!1!==t.multisite?"_".concat(parseInt(t.multisite,10)):""))};"rest_api"===t.mode?this.promise=this.request(t.requestURL,e,"POST",{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8","X-WP-Nonce":t.nonce}):(e.action="pvc-check-post",e.pvc_nonce=t.nonce,e.id=t.postID,this.promise=this.request(t.requestURL,e,"POST",{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"}))},request:function(t,e,n,r){var a=this,c={method:n,mode:"cors",cache:"no-cache",credentials:"same-origin",headers:r,body:this.prepareRequestData(e)};return fetch(t,c).then(function(t){if(!t.ok)throw Error(t.statusText);return t.json()}).then(function(t){try{"object"===o(t)&&null!==t?"success"in t&&!1===t.success?(console.log("PVC: Request error."),console.log(t.data)):(a.saveCookieData(t.storage),a.triggerEvent("pvcCheckPost",t)):(console.log("PVC: Invalid object."),console.log(t))}catch(e){console.log("PVC: Invalid JSON data."),console.log(e)}}).catch(function(t){console.log("PVC: Invalid response."),console.log(t)})},prepareRequestData:function(t){return Object.keys(t).map(function(e){return"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t[e]))}).join("&").replace(/%20/g,"+")},triggerEvent:function(t,e){var o=new CustomEvent(t,{bubbles:!0,detail:e});document.dispatchEvent(o)},saveCookieData:function(t){if(t&&Object.prototype.hasOwnProperty.call(t,"name")){var e="";"https:"===document.location.protocol&&(e=";secure");for(var o=0;o<t.name.length;o++){var n=new Date,r=parseInt(t.expiry[o],10);r?r*=1e3:r=n.getTime()+864e5,n.setTime(r),document.cookie="".concat(t.name[o],"=").concat(t.value[o],";expires=").concat(n.toUTCString(),";path=/").concat("/"===this.args.path?"":this.args.path,";domain=").concat(this.args.domain).concat(e,";SameSite=Lax")}}},readCookieData:function(e){var o=[];return document.cookie.split(";").forEach(function(n){var r=t(n.split("="),2),a=r[0],c=r[1],i=a.trim();new RegExp("".concat(e,"\\[\\d+\\]")).test(i)&&o.push(c)}),o.join("a")}};var n=function(){return window.PostViewsCounter.init(pvcArgsFrontend)};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",n):n(); -
post-views-counter/trunk/js/integration-gutenberg.js
r3442638 r3443281 1 1 (function(){ 2 !function( $,e,t){!function(e,o){var r=o.hooks.addFilter,n=o.compose.createHigherOrderComponent,s=o.element,i=s.Fragment,c=s.useEffect,l=o.blockEditor.InspectorControls,u=o.components,a=u.PanelBody,d=u.ToggleControl,v=o.i18n.__,p=e.pvcGutenbergIntegration||{enabled:!0,defaultIncludeZeroViews:!0};if(p.enabled){var f=new Map,m=!1;r("blocks.registerBlockType","pvc/latest-posts-add-post-views-orderby",function(e,t){return"core/latest-posts"!==t||(e.attributes||(e.attributes={}),e.attributes.pvcIncludeZeroViews={type:"boolean",default:p.defaultIncludeZeroViews}),e});var w=function(e,o,r){if(e){var n=Array.from(e.options).some(function(e){return e.value===o});if(!n){var s=t.createElement("option");s.value=o,s.text=r,e.appendChild(s)}}},y=function(){return t.querySelector(".block-editor-block-inspector")||t.querySelector(".interface-interface-skeleton__sidebar")||t.body},b=function(){var t=y().querySelectorAll("select");e.pvcDebug&&(console.log("[PVC] findLatestPostsOrderBySelect - Found selects:",t.length),t.forEach(function(e,t){var o=Array.from(e.options).map(function(e){return e.value});console.log("[PVC] Select",t,"options:",o)}));for(var o=0;o<t.length;o++){var r=t[o],n=r.querySelector('option[value="date/desc"]'),s=r.querySelector('option[value="date/asc"]'),i=r.querySelector('option[value="title/asc"]'),c=r.querySelector('option[value="title/desc"]'),l=r.querySelector('option[value="menu_order/asc"]')||r.querySelector('option[value="menu_order/desc"]');if(n&&s&&i&&c&&!l)return e.pvcDebug&&console.log("[PVC] Found Latest Posts orderBy select (QueryControls format) at index",o),r}return e.pvcDebug&&console.log("[PVC] Latest Posts orderBy select NOT found"),null},g=function(e){if(e){var t=y(),o=t.querySelector(".pvc-post-views-settings--latest-posts");if(o){var r=e.closest(".components-tools-panel");if(r){for(var n=r;n.parentNode&&n.parentNode!==t;){var s=n.parentNode;if(s.querySelector(":scope > .components-panel__body"))break;n=s}var i=n.parentNode;if(i){for(var c=o;c.parentNode&&c.parentNode!==i&&c.parentNode!==t;)c=c.parentNode;c.previousElementSibling!==n&&(c.parentNode===i?i.insertBefore(c,n.nextSibling):i.insertBefore(o,n.nextSibling))}}}}},S=n(function(e){return function(t){var r=t.name,n=t.attributes,s=t.setAttributes;if("core/query"!==r)return o.element.createElement(e,t);c(function(){if(t.isSelected){var e=function(){var e=function(){for(var e=y().querySelectorAll("select"),t=0;t<e.length;t++){var o=e[t],r=o.querySelector('option[value="date/desc"]'),n=o.querySelector('option[value="date/asc"]'),s=o.querySelector('option[value="title/asc"]');if(r&&n&&s)return o}return null}();e&&(w(e,"post_views/desc",v("Most viewed","post-views-counter")),w(e,"post_views/asc",v("Least viewed","post-views-counter")))},o=y(),r=new MutationObserver(e);return e(),r.observe(o,{childList:!0,subtree:!0}),function(){r.disconnect()}}},[t.clientId,t.isSelected]);var u=n.query&&"post_views"===n.query.orderBy,f=n.query&&void 0!==n.query.pvcIncludeZeroViews?n.query.pvcIncludeZeroViews:p.defaultIncludeZeroViews;return o.element.createElement(i,null,o.element.createElement(e,t),u&&o.element.createElement(l,null,o.element.createElement(a,{title:v("Post Views Settings","post-views-counter"),initialOpen:!0,className:"pvc-post-views-settings pvc-post-views-settings--query"},o.element.createElement(d,{label:v("Include posts with zero views","post-views-counter"),checked:f,onChange:function(e){var t=Object.assign({},n.query||{});t.pvcIncludeZeroViews=e,s({query:t})},help:v("When enabled, posts with no views will be included in the results.","post-views-counter")}))))}},"withQueryLoopControls"),q=n(function(e){return function(r){var n=r.name,s=r.attributes,u=r.setAttributes;if("core/latest-posts"!==n)return o.element.createElement(e,r);var S=r.clientId;c(function(){var e;"post_views"===s.orderBy&&(e="post_views",f.set(S,e))},[s.orderBy,S]),c(function(){if("post_views"===f.get(S)&&"date"===s.orderBy&&!m){var e=requestAnimationFrame(function(){u({orderBy:"post_views"})});return function(){cancelAnimationFrame(e)}}},[s.orderBy,S,u]),c(function(){m&&"post_views"!==s.orderBy&&f.delete(S)},[s.orderBy,S]),c(function(){return function(){var e=setTimeout(function(){f.get(S)&&null===t.querySelector('[data-block="'+S+'"]')&&f.delete(S)},5e3);return function(){clearTimeout(e)}}},[S]),c(function(){if(r.isSelected){var e=function(){var e=b();if(e){if(w(e,"post_views/desc",v("Most viewed","post-views-counter")),w(e,"post_views/asc",v("Least viewed","post-views-counter")),e.dataset.pvcListenerAdded||(e.dataset.pvcListenerAdded="true",e.addEventListener("change",function(){m=!0,setTimeout(function(){m=!1},100)})),"post_views"===s.orderBy){var t="post_views/"+(s.order||"desc");e.value!==t&&(e.value=t)}g(e)}},t=y(),o=new MutationObserver(e);e();var n=setTimeout(e,100),i=setTimeout(e,300);return o.observe(t,{childList:!0,subtree:!0}),function(){o.disconnect(),clearTimeout(n),clearTimeout(i)}}},[r.clientId,r.isSelected,s.orderBy,s.order]);var q="post_views"===s.orderBy;c(function(){if(q&&r.isSelected){var e=function(){var e=b();e&&g(e)},t=setTimeout(e,50),o=setTimeout(e,150),n=setTimeout(e,300),s=setTimeout(e,500),i=setTimeout(e,1e3),c=y(),l=new MutationObserver(function(){c.querySelector(".pvc-post-views-settings--latest-posts")&&e()});return l.observe(c,{childList:!0,subtree:!0}),function(){clearTimeout(t),clearTimeout(o),clearTimeout(n),clearTimeout(s),clearTimeout(i),l.disconnect()}}},[q,r.isSelected]);var h=void 0!==s.pvcIncludeZeroViews?s.pvcIncludeZeroViews:p.defaultIncludeZeroViews;return o.element.createElement(i,null,o.element.createElement(e,r),q&&o.element.createElement(l,null,o.element.createElement(a,{title:v("Post Views Settings","post-views-counter"),initialOpen:!0,className:"pvc-post-views-settings pvc-post-views-settings--latest-posts"},o.element.createElement(d,{label:v("Include posts with zero views","post-views-counter"),checked:h,onChange:function(e){u({pvcIncludeZeroViews:e})},help:v("When enabled, posts with no views will be included in the results.","post-views-counter")}))))}},"withLatestPostsControls");r("editor.BlockEdit","pvc/query-loop-controls",S),r("editor.BlockEdit","pvc/latest-posts-controls",q)}}(e,e.wp)}(jQuery,window,document);2 !function(e,t){var o=t.hooks.addFilter,n=t.compose.createHigherOrderComponent,r=t.element,s=r.Fragment,i=r.useEffect,c=t.blockEditor.InspectorControls,l=t.components,u=l.PanelBody,a=l.ToggleControl,d=t.i18n.__,v=e.pvcGutenbergIntegration||{enabled:!0,defaultIncludeZeroViews:!0};if(v.enabled){var p=new Map,f=!1;o("blocks.registerBlockType","pvc/latest-posts-add-post-views-orderby",function(e,t){return"core/latest-posts"!==t||(e.attributes||(e.attributes={}),e.attributes.pvcIncludeZeroViews={type:"boolean",default:v.defaultIncludeZeroViews}),e});var m=function(e,t,o){if(e){var n=Array.from(e.options).some(function(e){return e.value===t});if(!n){var r=document.createElement("option");r.value=t,r.text=o,e.appendChild(r)}}},w=function(){return document.querySelector(".block-editor-block-inspector")||document.querySelector(".interface-interface-skeleton__sidebar")||document.body},y=function(){var t=w().querySelectorAll("select");e.pvcDebug&&(console.log("[PVC] findLatestPostsOrderBySelect - Found selects:",t.length),t.forEach(function(e,t){var o=Array.from(e.options).map(function(e){return e.value});console.log("[PVC] Select",t,"options:",o)}));for(var o=0;o<t.length;o++){var n=t[o],r=n.querySelector('option[value="date/desc"]'),s=n.querySelector('option[value="date/asc"]'),i=n.querySelector('option[value="title/asc"]'),c=n.querySelector('option[value="title/desc"]'),l=n.querySelector('option[value="menu_order/asc"]')||n.querySelector('option[value="menu_order/desc"]');if(r&&s&&i&&c&&!l)return e.pvcDebug&&console.log("[PVC] Found Latest Posts orderBy select (QueryControls format) at index",o),n}return e.pvcDebug&&console.log("[PVC] Latest Posts orderBy select NOT found"),null},b=function(e){if(e){var t=w(),o=t.querySelector(".pvc-post-views-settings--latest-posts");if(o){var n=e.closest(".components-tools-panel");if(n){for(var r=n;r.parentNode&&r.parentNode!==t;){var s=r.parentNode;if(s.querySelector(":scope > .components-panel__body"))break;r=s}var i=r.parentNode;if(i){for(var c=o;c.parentNode&&c.parentNode!==i&&c.parentNode!==t;)c=c.parentNode;c.previousElementSibling!==r&&(c.parentNode===i?i.insertBefore(c,r.nextSibling):i.insertBefore(o,r.nextSibling))}}}}},g=n(function(e){return function(o){var n=o.name,r=o.attributes,l=o.setAttributes;if("core/query"!==n)return t.element.createElement(e,o);i(function(){if(o.isSelected){var e=function(){var e=function(){for(var e=w().querySelectorAll("select"),t=0;t<e.length;t++){var o=e[t],n=o.querySelector('option[value="date/desc"]'),r=o.querySelector('option[value="date/asc"]'),s=o.querySelector('option[value="title/asc"]');if(n&&r&&s)return o}return null}();e&&(m(e,"post_views/desc",d("Most viewed","post-views-counter")),m(e,"post_views/asc",d("Least viewed","post-views-counter")))},t=w(),n=new MutationObserver(e);return e(),n.observe(t,{childList:!0,subtree:!0}),function(){n.disconnect()}}},[o.clientId,o.isSelected]);var p=r.query&&"post_views"===r.query.orderBy,f=r.query&&void 0!==r.query.pvcIncludeZeroViews?r.query.pvcIncludeZeroViews:v.defaultIncludeZeroViews;return t.element.createElement(s,null,t.element.createElement(e,o),p&&t.element.createElement(c,null,t.element.createElement(u,{title:d("Post Views Settings","post-views-counter"),initialOpen:!0,className:"pvc-post-views-settings pvc-post-views-settings--query"},t.element.createElement(a,{label:d("Include posts with zero views","post-views-counter"),checked:f,onChange:function(e){var t=Object.assign({},r.query||{});t.pvcIncludeZeroViews=e,l({query:t})},help:d("When enabled, posts with no views will be included in the results.","post-views-counter")}))))}},"withQueryLoopControls"),S=n(function(e){return function(o){var n=o.name,r=o.attributes,l=o.setAttributes;if("core/latest-posts"!==n)return t.element.createElement(e,o);var g=o.clientId;i(function(){var e;"post_views"===r.orderBy&&(e="post_views",p.set(g,e))},[r.orderBy,g]),i(function(){if("post_views"===p.get(g)&&"date"===r.orderBy&&!f){var e=requestAnimationFrame(function(){l({orderBy:"post_views"})});return function(){cancelAnimationFrame(e)}}},[r.orderBy,g,l]),i(function(){f&&"post_views"!==r.orderBy&&p.delete(g)},[r.orderBy,g]),i(function(){return function(){var e=setTimeout(function(){p.get(g)&&null===document.querySelector('[data-block="'+g+'"]')&&p.delete(g)},5e3);return function(){clearTimeout(e)}}},[g]),i(function(){if(o.isSelected){var e=function(){var e=y();if(e){if(m(e,"post_views/desc",d("Most viewed","post-views-counter")),m(e,"post_views/asc",d("Least viewed","post-views-counter")),e.dataset.pvcListenerAdded||(e.dataset.pvcListenerAdded="true",e.addEventListener("change",function(){f=!0,setTimeout(function(){f=!1},100)})),"post_views"===r.orderBy){var t="post_views/"+(r.order||"desc");e.value!==t&&(e.value=t)}b(e)}},t=w(),n=new MutationObserver(e);e();var s=setTimeout(e,100),i=setTimeout(e,300);return n.observe(t,{childList:!0,subtree:!0}),function(){n.disconnect(),clearTimeout(s),clearTimeout(i)}}},[o.clientId,o.isSelected,r.orderBy,r.order]);var S="post_views"===r.orderBy;i(function(){if(S&&o.isSelected){var e=function(){var e=y();e&&b(e)},t=setTimeout(e,50),n=setTimeout(e,150),r=setTimeout(e,300),s=setTimeout(e,500),i=setTimeout(e,1e3),c=w(),l=new MutationObserver(function(){c.querySelector(".pvc-post-views-settings--latest-posts")&&e()});return l.observe(c,{childList:!0,subtree:!0}),function(){clearTimeout(t),clearTimeout(n),clearTimeout(r),clearTimeout(s),clearTimeout(i),l.disconnect()}}},[S,o.isSelected]);var q=void 0!==r.pvcIncludeZeroViews?r.pvcIncludeZeroViews:v.defaultIncludeZeroViews;return t.element.createElement(s,null,t.element.createElement(e,o),S&&t.element.createElement(c,null,t.element.createElement(u,{title:d("Post Views Settings","post-views-counter"),initialOpen:!0,className:"pvc-post-views-settings pvc-post-views-settings--latest-posts"},t.element.createElement(a,{label:d("Include posts with zero views","post-views-counter"),checked:q,onChange:function(e){l({pvcIncludeZeroViews:e})},help:d("When enabled, posts with no views will be included in the results.","post-views-counter")}))))}},"withLatestPostsControls");o("editor.BlockEdit","pvc/query-loop-controls",g),o("editor.BlockEdit","pvc/latest-posts-controls",S)}}(window,window.wp); 3 3 4 4 })(); -
post-views-counter/trunk/post-views-counter.php
r3442638 r3443281 3 3 Plugin Name: Post Views Counter 4 4 Description: Post Views Counter allows you to collect and display how many times a post, page, or other content has been viewed in a simple, fast and reliable way. 5 Version: 1.7. 15 Version: 1.7.2 6 6 Author: dFactory 7 7 Author URI: https://dfactory.co/ … … 31 31 * 32 32 * @class Post_Views_Counter 33 * @version 1.7. 133 * @version 1.7.2 34 34 */ 35 35 final class Post_Views_Counter { … … 110 110 'integrations' => [] 111 111 ], 112 'version' => '1.7. 1'112 'version' => '1.7.2' 113 113 ]; 114 114 -
post-views-counter/trunk/readme.txt
r3442638 r3443281 3 3 Tags: counter, postviews, statistics, analytics, pageviews 4 4 Requires at least: 6.3.0 5 Requires PHP: 7. 4.05 Requires PHP: 7.0 6 6 Tested up to: 6.9 7 Stable tag: 1.7. 17 Stable tag: 1.7.2 8 8 License: MIT License 9 9 License URI: http://opensource.org/licenses/MIT … … 93 93 == Changelog == 94 94 95 = 1.7.2 = 96 * Fix: jQuery wrapper applied to vanilla JS files in build output. 97 95 98 = 1.7.1 = 96 99 * New: Enhanced settings UI with modern theme and improved visual design. … … 432 435 == Upgrade Notice == 433 436 434 = 1.7. 1=435 Enhanced settings UI with modern design.437 = 1.7.2 = 438 Fixed jQuery wrapper applied to vanilla JS files in build output.
Note: See TracChangeset
for help on using the changeset viewer.