7 lines
35 KiB
JavaScript
7 lines
35 KiB
JavaScript
|
this.wc=this.wc||{},this.wc.blocks=this.wc.blocks||{},this.wc.blocks["all-reviews"]=function(e){function t(t){for(var n,a,i=t[0],s=t[1],l=t[2],b=0,d=[];b<i.length;b++)a=i[b],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&d.push(o[a][0]),o[a]=0;for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n]);for(u&&u(t);d.length;)d.shift()();return c.push.apply(c,l||[]),r()}function r(){for(var e,t=0;t<c.length;t++){for(var r=c[t],n=!0,i=1;i<r.length;i++){var s=r[i];0!==o[s]&&(n=!1)}n&&(c.splice(t--,1),e=a(a.s=r[0]))}return e}var n={},o={7:0},c=[];function a(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,a),r.l=!0,r.exports}a.m=e,a.c=n,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)a.d(r,n,function(t){return e[t]}.bind(null,n));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="";var i=window.webpackWcBlocksJsonp=window.webpackWcBlocksJsonp||[],s=i.push.bind(i);i.push=t,i=i.slice();for(var l=0;l<i.length;l++)t(i[l]);var u=s;return c.push([774,0]),r()}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},106:function(e,t,r){"use strict";var n=r(0),o=r(1),c=(r(2),r(66)),a=r(150),i=r(6),s=r.n(i),l=r(4),u=r(52);r(153),t.a=function(e){var t=e.className,r=e.error,i=e.isLoading,b=e.onRetry;return Object(n.createElement)(l.Placeholder,{icon:Object(n.createElement)(c.a,{srcElement:a.a}),label:Object(o.__)("Sorry, an error occurred",'woocommerce'),className:s()("wc-block-api-error",t)},Object(n.createElement)(u.a,{error:r}),b&&Object(n.createElement)(n.Fragment,null,i?Object(n.createElement)(l.Spinner,null):Object(n.createElement)(l.Button,{isSecondary:!0,onClick:b},Object(o.__)("Retry",'woocommerce'))))}},11:function(e,t){e.exports=window.React},12:function(e,t){e.exports=window.wp.blockEditor},123:function(e,t){},144:function(e,t,r){"use strict";r.d(t,"a",(function(){return l})),r.d(t,"b",(function(){return u})),r.d(t,"c",(function(){return b}));var n=r(0),o=r(1),c=r(4),a=r(12),i=r(3),s=r(88),l=function(e,t){return Object(n.createElement)(a.BlockControls,null,Object(n.createElement)(c.ToolbarGroup,{controls:[{icon:"edit",title:Object(o.__)("Edit",'woocommerce'),onClick:function(){return t({editMode:!e})},isActive:e}]}))},u=function(e,t){var r=Object(i.getSetting)("showAvatars",!0),a=Object(i.getSetting)("reviewRatingsEnabled",!0);return Object(n.createElement)(n.Fragment,null,Object(n.createElement)(c.ToggleControl,{label:Object(o.__)("Product rating",'woocommerce'),checked:e.showReviewRating,onChange:function(){return t({showReviewRating:!e.showReviewRating})}}),e.showReviewRating&&!a&&Object(n.createElement)(c.Notice,{className:"wc-block-base-control-notice",isDismissible:!1},Object(n.createInterpolateElement)(Object(o.__)("Product rating is disabled in your <a>store settings</a>.",'woocommerce'),{a:Object(n.createElement)("a",{href:Object(i.getAdminLink)("admin.php?page=wc-settings&tab=products"),target:"_blank",rel:"noopener noreferrer"})})),Object(n.createElement)(c.ToggleControl,{label:Object(o.__)("Reviewer name",'woocommerce'),checked:e.showReviewerName,onChange:function(){return t({showReviewerName:!e.showReviewerName})}}),Object(n.createElement)(c.ToggleControl,{label:Object(o.__)("Image",'woocommerce'),checked:e.showReviewImage,onChange:function(){return t({showReviewImage:!e.showReviewImage})}}),Object(n.createElement)(c.ToggleControl,{label:Object(o.__)("Review date",'woocommerce'),checked:e.showReviewDate,onChange:function(){return t({showReviewDat
|
||
|
/* translators: An example person name used for the block previews. */
|
||
|
reviewer:Object(n.__)("Alice",'woocommerce'),review:"<p>".concat(Object(n.__)("I bought this product last week and I'm very happy with it.",'woocommerce'),"</p>\n"),reviewer_avatar_urls:{48:o.o.defaultAvatar,96:o.o.defaultAvatar},rating:5,verified:!0},{id:2,date_created:"2019-07-12T12:39:39",formatted_date_created:Object(n.__)("July 12, 2019",'woocommerce'),date_created_gmt:"2019-07-12T10:39:39",product_id:0,product_name:Object(n.__)("WordPress Pennant",'woocommerce'),product_permalink:"#",
|
||
|
/* translators: An example person name used for the block previews. */
|
||
|
reviewer:Object(n.__)("Bob",'woocommerce'),review:"<p>".concat(Object(n.__)("This product is awesome, I love it!",'woocommerce'),"</p>\n"),reviewer_avatar_urls:{48:o.o.defaultAvatar,96:o.o.defaultAvatar},rating:null,verified:!1}]}}},192:function(e,t,r){"use strict";t.a={editMode:{type:"boolean",default:!0},imageType:{type:"string",default:"reviewer"},orderby:{type:"string",default:"most-recent"},reviewsOnLoadMore:{type:"number",default:10},reviewsOnPageLoad:{type:"number",default:10},showLoadMore:{type:"boolean",default:!0},showOrderby:{type:"boolean",default:!0},showReviewDate:{type:"boolean",default:!0},showReviewerName:{type:"boolean",default:!0},showReviewImage:{type:"boolean",default:!0},showReviewRating:{type:"boolean",default:!0},showReviewContent:{type:"boolean",default:!0},previewReviews:{type:"array",default:null}}},193:function(e,t,r){"use strict";var n=r(9),o=r.n(n),c=r(0),a=r(12),i=(r(215),r(85));t.a=function(e){var t=e.attributes;return Object(c.createElement)("div",o()({},a.useBlockProps.save({className:Object(i.a)(t)}),Object(i.b)(t)))}},199:function(e,t,r){"use strict";var n=r(0),o=r(1),c=(r(2),r(7)),a=r(4),i=r(12),s=r(17),l=r.n(s),u=r(18),b=r.n(u),d=r(19),p=r.n(d),w=r(20),m=r.n(w),v=r(10),g=r.n(v),f=r(11),h=r(3),O=r(106),y=r(41),j=(r(256),function(e){var t=e.onClick,r=e.label,o=e.screenReaderLabel;return Object(n.createElement)("div",{className:"wp-block-button wc-block-load-more wc-block-components-load-more"},Object(n.createElement)("button",{className:"wp-block-button__link",onClick:t},Object(n.createElement)(y.a,{label:r,screenReaderLabel:o})))});j.defaultProps={label:Object(o.__)("Load more",'woocommerce')};var _=j,k=r(156),R=(r(253),function(e){var t=e.onChange,r=e.readOnly,c=e.value;return Object(n.createElement)(k.a,{className:"wc-block-review-sort-select wc-block-components-review-sort-select",label:Object(o.__)("Order by",'woocommerce'),onChange:t,options:[{key:"most-recent",label:Object(o.__)("Most recent",'woocommerce')},{key:"highest-rating",label:Object(o.__)("Highest rating",'woocommerce')},{key:"lowest-rating",label:Object(o.__)("Lowest rating",'woocommerce')}],readOnly:r,screenReaderLabel:Object(o.__)("Order reviews by",'woocommerce'),value:c})}),E=r(5),P=r.n(E),S=r(6),C=r.n(S),N=r(13),T=r.n(N),x=r(236),L=r.n(x),A=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"...",n=L()(e,{suffix:r,limit:t});return n.html},M=function(e,t,r,n){var o=I(e,t,r);return A(e,o-n.length,n)},I=function(e,t,r){for(var n={start:0,middle:0,end:e.length};n.start<=n.end;)n.middle=Math.floor((n.start+n.end)/2),t.innerHTML=A(e,n.middle),n=D(n,t.clientHeight,r);return n.middle},D=function(e,t,r){return t<=r?e.start=e.middle+1:e.end=e.middle-1,e};var B=function(e){p()(c,e);var t,r,o=(t=c,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,n=g()(t);if(r){var o=g()(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return m()(this,e)});function c(e){var t;return l()(this,c),(t=o.apply(this,arguments)).state={isExpanded:!1,clampEnabled:null,content:e.children,summary:"."},t.reviewSummary=Object(f.createRef)(),t.reviewContent=Object(f.createRef)(),t.getButton=t.getButton.bind(T()(t)),t.onClick=t.onClick.bind(T()(t)),t}return b()(c,[{key:"componentDidMount",value:function(){if(this.props.children){var e=this.props,t=e.maxLines,r=e.ellipsis,n=(this.reviewSummary.current.clientHeight+1)*t+1,o=this.reviewContent.current.clientHeight+1>n;this.setState({clampEnabled:o}),o&&this.setState({summary:M(this.reviewContent.current.innerHTML,this.reviewSummary.current,n,r)})}}},{key:"getButton",value:function(){var e=this.state.isExpanded,t=this.props,r=t.className,o=t.lessText,c=t.moreText,a=e?o:c;if(a)return Object(n.createElement)("a",{href:"#more",className:r+"__read_more",onClick:this.onClick,"aria-expanded":!e,role:"button"},a)}},{key:"onClick",value:
|
||
|
/* translators: %f is referring to the average rating value */
|
||
|
Object(o.__)("Rated %f out of 5",'woocommerce'),t);return Object(n.createElement)("div",{className:"wc-block-review-list-item__rating wc-block-components-review-list-item__rating"},Object(n.createElement)("div",{className:"wc-block-review-list-item__rating__stars wc-block-components-review-list-item__rating__stars",role:"img","aria-label":c},Object(n.createElement)("span",{style:r},c)))}(c),d&&function(e){return Object(n.createElement)("div",{className:"wc-block-review-list-item__product wc-block-components-review-list-item__product"},Object(n.createElement)("a",{href:e.product_permalink,dangerouslySetInnerHTML:{__html:e.product_name}}))}(c),s&&function(e){var t=e.reviewer,r=void 0===t?"":t;return Object(n.createElement)("div",{className:"wc-block-review-list-item__author wc-block-components-review-list-item__author"},r)}(c),i&&function(e){var t=e.date_created,r=e.formatted_date_created;return Object(n.createElement)("time",{className:"wc-block-review-list-item__published-date wc-block-components-review-list-item__published-date",dateTime:t},r)}(c))),b&&function(e){return Object(n.createElement)(H,{maxLines:10,moreText:Object(o.__)("Read full review",'woocommerce'),lessText:Object(o.__)("Hide full review",'woocommerce'),className:"wc-block-review-list-item__text wc-block-components-review-list-item__text"},Object(n.createElement)("div",{dangerouslySetInnerHTML:{__html:e.review||""}}))}(c))};function F(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function V(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?F(Object(r),!0).forEach((function(t){P()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):F(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}r(254);var z=function(e){var t=e.attributes,r=e.reviews,o=Object(h.getSetting)("showAvatars",!0),c=Object(h.getSetting)("reviewRatingsEnabled",!0),a=(o||"product"===t.imageType)&&t.showReviewImage,i=c&&t.showReviewRating,s=V(V({},t),{},{showReviewImage:a,showReviewRating:i});return Object(n.createElement)("ul",{className:"wc-block-review-list wc-block-components-review-list"},0===r.length?Object(n.createElement)(G,{attributes:s}):r.map((function(e,t){return Object(n.createElement)(G,{key:e.id||t,attributes:s,review:e})})))},W=r(9),U=r.n(W),J=r(29),q=r.n(J),Y=r(22),K=r.n(Y),Q=r(34),X=r.n(Q),Z=r(85),$=r(42);var ee=function(e){var t=function(t){p()(a,t);var r,o,c=(r=a,o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=g()(r);if(o){var n=g()(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return m()(this,e)});function a(){var e;l()(this,a);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return e=c.call.apply(c,[this].concat(r)),P()(T()(e),"isPreview",!!e.props.attributes.previewReviews),P()(T()(e),"delayedAppendReviews",e.props.delayFunction(e.appendReviews)),P()(T()(e),"isMounted",!1),P()(T()(e),"state",{error:null,loading:!0,reviews:e.isPreview?e.props.attributes.previewReviews:[],totalReviews:e.isPreview?e.props.attributes.previewReviews.length:0}),P()(T()(e),"setError",function(){var t=q()(K.a.mark((function t(r){var n,o;return K.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.isMounted){t.next=2;break}return t.abrupt("return");case 2:return n=e.props.onReviewsLoadError,t.next=5,Object($.a)(r);case 5:o=t.sent,e.setState({reviews:[],loading:!1,error:o}),n(o);case 8:case"end":return t.stop()}}),t)})));return function(_x){return t.apply(this,arguments)}}()),e}return b()(a,[{key:"componentDidMount",value:function(){this.isMounted=!0,this.replaceReviews()}},{key:"componentDidUpda
|