@subiz/widget-v4 4.1.4 → 4.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled_src/notif/notif.js +17 -11
- package/compiled_src/store/store.js +6 -5
- package/dist/{185588facf6.132.js → 18575b13d4f.132.js} +0 -0
- package/dist/{185588facf6.178.js → 18575b13d4f.178.js} +0 -0
- package/dist/{185588facf6.213.js → 18575b13d4f.213.js} +0 -0
- package/dist/{185588facf6.335.js → 18575b13d4f.335.js} +0 -0
- package/dist/{185588facf6.362.js → 18575b13d4f.362.js} +0 -0
- package/dist/{185588facf6.441.js → 18575b13d4f.441.js} +0 -0
- package/dist/{185588facf6.605.js → 18575b13d4f.605.js} +1 -1
- package/dist/{185588facf6.678.js → 18575b13d4f.678.js} +0 -0
- package/dist/{185588facf6.782.js → 18575b13d4f.782.js} +0 -0
- package/dist/{185588facf6.app.js → 18575b13d4f.app.js} +1 -1
- package/dist/{185588facf6.index.html → 18575b13d4f.index.html} +1 -1
- package/dist/{185588facf6.library.html → 18575b13d4f.library.html} +1 -1
- package/dist/{185588facf6.library.js → 18575b13d4f.library.js} +1 -1
- package/dist/{185588facf6.preview.html → 18575b13d4f.preview.html} +1 -1
- package/dist/{185588facf6.preview.js → 18575b13d4f.preview.js} +1 -1
- package/dist/{185588facf6.screenshoot.js → 18575b13d4f.screenshoot.js} +1 -1
- package/dist/{185588facf6.webview.js → 18575b13d4f.webview.js} +1 -1
- package/dist/605.js +17 -11
- package/dist/HASH +1 -1
- package/dist/screenshoot.html +1 -1
- package/package.json +1 -1
- package/src/notif/notif.js +40 -30
|
@@ -211,7 +211,7 @@ class Notif extends _common.Com {
|
|
|
211
211
|
if (_index.default.get(op, 'attributes.bold')) out = (0, _preact.h)("b", null, out);
|
|
212
212
|
if (_index.default.get(op, 'attributes.italic')) out = (0, _preact.h)("b", null, out);
|
|
213
213
|
return out;
|
|
214
|
-
});
|
|
214
|
+
}).filter(a => a);
|
|
215
215
|
}
|
|
216
216
|
render() {
|
|
217
217
|
if (!this.props.t) return null;
|
|
@@ -236,6 +236,19 @@ class Notif extends _common.Com {
|
|
|
236
236
|
let st = 'position: fixed !important; z-index: 1000000000 !important';
|
|
237
237
|
if (this.props.plugin._preview) st = 'position: absolute !important;';
|
|
238
238
|
if (this.state.closeAnimation) animation = 'fadeOut';
|
|
239
|
+
let $avatar = null;
|
|
240
|
+
if (user.avatar_url) $avatar = (0, _preact.h)("img", {
|
|
241
|
+
alt: "notification avatar",
|
|
242
|
+
class: "notif_avatar__img",
|
|
243
|
+
src: user.avatar_url
|
|
244
|
+
});
|
|
245
|
+
let $time = (0, _preact.h)("div", {
|
|
246
|
+
class: "notif_time",
|
|
247
|
+
style: _index.default.js2css(notif.subtext_style)
|
|
248
|
+
}, this.state.timestamp);
|
|
249
|
+
let $title = this.renderTextFromQuillDelta(this.state.title, user);
|
|
250
|
+
let $message = this.renderTextFromQuillDelta(this.state.message, user);
|
|
251
|
+
if (!lo.size($title) && !lo.size($message)) $time = null;
|
|
239
252
|
return (0, _preact.h)("div", {
|
|
240
253
|
class: animation + ' notif' + ' notif__' + pos,
|
|
241
254
|
onClick: e => this.onClick(e),
|
|
@@ -252,22 +265,15 @@ class Notif extends _common.Com {
|
|
|
252
265
|
}), this.renderCloseButton(), (0, _preact.h)("div", {
|
|
253
266
|
class: "notif_avatar",
|
|
254
267
|
style: _index.default.js2css(notif.avatar_style)
|
|
255
|
-
}, (0, _preact.h)("
|
|
256
|
-
alt: "notification avatar",
|
|
257
|
-
class: "notif_avatar__img",
|
|
258
|
-
src: user.avatar_url
|
|
259
|
-
})), (0, _preact.h)("div", {
|
|
268
|
+
}, $avatar), (0, _preact.h)("div", {
|
|
260
269
|
class: "notif_body"
|
|
261
270
|
}, (0, _preact.h)("div", {
|
|
262
271
|
class: "notif_title",
|
|
263
272
|
style: _index.default.js2css(notif.title_style)
|
|
264
|
-
},
|
|
273
|
+
}, $title), (0, _preact.h)("div", {
|
|
265
274
|
class: "notif_message",
|
|
266
275
|
style: _index.default.js2css(notif.message_style)
|
|
267
|
-
},
|
|
268
|
-
class: "notif_time",
|
|
269
|
-
style: _index.default.js2css(notif.subtext_style)
|
|
270
|
-
}, this.state.timestamp))));
|
|
276
|
+
}, $message), $time)));
|
|
271
277
|
}
|
|
272
278
|
}
|
|
273
279
|
exports.default = Notif;
|
|
@@ -163,17 +163,18 @@ class Store {
|
|
|
163
163
|
this.fake = fakeapi;
|
|
164
164
|
this.FileURL = FileURL;
|
|
165
165
|
if (this.fake) this.api = new _api_fake.default(ApiURL, FileURL);else this.api = new _api.default(ApiURL, FileURL);
|
|
166
|
-
if (inmem) {
|
|
167
|
-
this.inmem = inmem;
|
|
168
|
-
this.cookie = inmemCookie;
|
|
169
|
-
}
|
|
170
166
|
if (!inmem) {
|
|
171
167
|
try {
|
|
172
|
-
|
|
168
|
+
document.cookie;
|
|
169
|
+
localStorage;
|
|
173
170
|
} catch (e) {
|
|
174
171
|
inmem = true;
|
|
175
172
|
}
|
|
176
173
|
}
|
|
174
|
+
if (inmem) {
|
|
175
|
+
this.inmem = inmem;
|
|
176
|
+
this.cookie = inmemCookie;
|
|
177
|
+
}
|
|
177
178
|
this.pubsub = new _index.default.Pubsub();
|
|
178
179
|
this.kv = new _storage.default.kv(new _storage.default.lsdb('sbz2020', this.inmem), 'kv');
|
|
179
180
|
this.cache = new _storage.default.kv(new _storage.default.lsdb('sbz2020', true), 'kv');
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_subiz_widget_v4=self.webpackChunk_subiz_widget_v4||[]).push([[605],{9605:(t,e,s)=>{s.r(e),s.d(e,{default:()=>
|
|
1
|
+
"use strict";(self.webpackChunk_subiz_widget_v4=self.webpackChunk_subiz_widget_v4||[]).push([[605],{9605:(t,e,s)=>{s.r(e),s.d(e,{default:()=>l});var i=s(4494),o=s(6400),n=s(2493);let a=s.e(362).then(s.bind(s,362));class l extends n.up{constructor(t){var e,s,o;super(t),e=this,o={close:!0,cssready:!1,closeAnimation:!0,imageReady:!1,user:{},timestamp:"",message:"",title:"",last_show:0},(s=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var i=s.call(t,e);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(s="state"))in e?Object.defineProperty(e,s,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[s]=o,setTimeout((async()=>{let{body:t}=await this.props.store.sendImpression(this.props.plugin.id);this.impressionToken=i.Z.get(t,"impression_token")||"";let e=i.Z.get(this.props,"plugin.notification.background_url");i.Z.preloadImg(e,(()=>this.setState({imageReady:!0})))}))}setOver(t){this.mouse_leave=t?0:i.Z.Date.now()}randomTimestampt(){let t=Math.floor(5*Math.random());return 0==t?this.props.t("just_now"):1==t?"1 "+this.props.t("minute_ago"):2==t?"2 "+this.props.t("minutes_ago"):3==t?"3 "+this.props.t("minutes_ago"):"4 "+this.props.t("minutes_ago")}onClick(t){if(t.stopPropagation(),this.props.plugin._dont_follow)return;this.props.store.sendConversion(this.props.plugin.id,null,this.impressionToken);let e=i.Z.get(this.props,"plugin.notification.url");return e?(e.startsWith("http://")||e.startsWith("https://")||(e="//"+e),i.Z.get(this.props,"plugin.notification.new_tab",!1)?window.open(e):void(window.location.href=e)):void 0}onCloseButtonClick(t){t.preventDefault(),t.stopPropagation(),this.setClose(!0)}renderCloseButton(){return(0,o.h)("div",{class:"btn_close",onClick:t=>this.onCloseButtonClick(t)},(0,o.h)("svg",{class:"btn_close__icon",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24","stroke-linecap":"round","stroke-linejoin":"round"},(0,o.h)("line",{x1:"18",y1:"6",x2:"6",y2:"18",style:"stroke-width: 3 !important;"}),(0,o.h)("line",{x1:"6",y1:"6",x2:"18",y2:"18",style:"stroke-width: 3 !important;"})))}async waitForT(){if(!this.props.t)return await i.Z.sleep(100),this.waitForT()}async setClose(t){if(await this.waitForT(),this.props.t){if(!t){clearTimeout(this.lastCloseTimeout),this.setState({closeAnimation:!1});let t=this.randomTimestampt(),e=i.Z.get(this.props,"plugin.notification.profiles",[]),s=e[Math.floor(Math.random()*i.Z.size(e))]||{};s.avatar_url&&s.avatar_url.startsWith("http")&&await i.Z.preloadImg(s.avatar_url),i.Z.map(i.Z.get(this.props.plugin,"notification.custom_avatar_urls"),(t=>{e.push({type:"person",fullname:r(),avatar_url:t,email:r().split(" ").join(".").toLowerCase()+"@gmail.com",address:h(),phone:"+84"+Math.floor(10*Math.random())+Math.floor(10*Math.random())+Math.floor(10*Math.random())+Math.floor(10*Math.random())+Math.floor(10*Math.random())+Math.floor(10*Math.random())+"xxxx",age:15+Math.floor(20*Math.random())})}));let o=i.Z.get(this.props,"plugin.notification.i18n_message_quill_deltas",[]),n=o[Math.floor(Math.random()*i.Z.size(o))],a=i.Z.get(this.props,"plugin.notification.message_quill_deltas",[]),l=a[Math.floor(Math.random()*i.Z.size(a))],p=i.Z.get(this.props,"plugin.notification.i18n_title_quill_delta");return this.setState({close:!1,last_show:i.Z.Date.now(),timestamp:t,user:s,title:this.props.t.i18n(p)||i.Z.get(this.props,"plugin.notification.title_quill_delta"),message:this.props.t.i18n(n)||l})}this.setState({closeAnimation:!0}),this.mouse_leave=i.Z.Date.now(),this.lastCloseTimeout=setTimeout((()=>this.setState({close:!0,closeAnimation:!1})),150),this.props.plugin._dont_close&&setTimeout((()=>this.setState({closeAnimation:!1,close:!1})),1e3)}}async refreshCSS(){let t=this.props.store.matchPlugin();if(!i.Z.find(t,(t=>t.id===this.props.plugin.id)))return;let e=(await a).default.default.toString();i.Z.setCss(this.props.plugin.id,this.$cssStyleDiv,e),this.setClose(this.state.close)}componentWillUnmount(){clearInterval(this.interval),i.Z.setCss(this.props.plugin.id,this.$cssStyleDiv,"")}async componentDidMount(){this.setState({last_show:i.Z.Date.now()}),this.$cssStyleDiv=document.getElementById("subiz-style-for-"+this.props.plugin.id),this.$cssStyleDiv||(this.$cssStyleDiv=document.createElement("style"),document.head.appendChild(this.$cssStyleDiv),this.$cssStyleDiv.type="text/css",this.$cssStyleDiv.id="subiz-style-for-"+this.props.plugin.id),this.props.store.onResetCSS(this,(()=>this.refreshCSS())),await this.refreshCSS(),this.interval=setInterval((()=>{if(this.props._destroy)return this.componentWillUnmount();let t=this.mouse_leave;return 0===t&&(t=i.Z.Date.now()),i.Z.Date.now()-t<1e3?void 0:this.state.close||this.props.plugin._dont_close?i.Z.Date.now()-this.state.last_show>this.props.plugin.notification.interval_sec?this.setClose(!1):void 0:i.Z.Date.now()-this.state.last_show>8e3?this.setClose(!0):void 0}),1e3),setTimeout((()=>{this.setState({cssready:!0}),this.setClose(!1)}),50)}renderTextFromQuillDelta(t,e){let s=i.Z.parseJSON(t);return s&&s.ops?i.Z.map(s.ops,(t=>{let s=null;if(!t.insert)return null;if("string"==typeof t.insert&&(s=t.insert),i.Z.get(t,"insert.dynamicField")){let o=i.Z.get(t,"insert.dynamicField.key");"user.fullname"===o&&(s=e.fullname),"user.email"===o&&(s=e.email),"user.address"===o&&(s=e.address),"user.phone"===o&&(s=e.phone)}return i.Z.get(t,"attributes.bold")&&(s=(0,o.h)("b",null,s)),i.Z.get(t,"attributes.italic")&&(s=(0,o.h)("b",null,s)),s})).filter((t=>t)):null}render(){if(!this.props.t)return null;if(!this.state.cssready)return null;if(!this.state.imageReady)return null;if(this.state.close)return null;if(!this.state.message)return null;let t=i.Z.get(this.props.plugin,"notification",{});if(!t)return null;let e="",s=i.Z.get(t,"position","bottom-left");this.props.mobile&&(s=i.Z.get(t,"mobile_position",s)),"top-left"===s||"top-right"===s?e="fadeInDown":"top-center"===s?e="fadeInDownCenter":"bottom-center"===s?e="fadeInUpCenter":("bottom-right"===s||(s="bottom-left"),e="fadeInUpBig");let n=this.state.user||{},a=t.subtext_style||{};void 0===a.color&&(a.color=i.Z.get(t,"message_style.color","black"));let l="position: fixed !important; z-index: 1000000000 !important";this.props.plugin._preview&&(l="position: absolute !important;"),this.state.closeAnimation&&(e="fadeOut");let r=null;n.avatar_url&&(r=(0,o.h)("img",{alt:"notification avatar",class:"notif_avatar__img",src:n.avatar_url}));let h=(0,o.h)("div",{class:"notif_time",style:i.Z.js2css(t.subtext_style)},this.state.timestamp),p=this.renderTextFromQuillDelta(this.state.title,n),u=this.renderTextFromQuillDelta(this.state.message,n);return lo.size(p)||lo.size(u)||(h=null),(0,o.h)("div",{class:e+" notif notif__"+s,onClick:t=>this.onClick(t),onmouseover:t=>this.setOver(!0),style:l,onmouseleave:t=>this.setOver(!1)},(0,o.h)("div",{style:"position: relative !important; display: flex !important; align-items: center !important;"},(0,o.h)("img",{alt:"notification background",class:"notif_bg",src:t.background_url,style:i.Z.js2css(t.background_style)}),this.renderCloseButton(),(0,o.h)("div",{class:"notif_avatar",style:i.Z.js2css(t.avatar_style)},r),(0,o.h)("div",{class:"notif_body"},(0,o.h)("div",{class:"notif_title",style:i.Z.js2css(t.title_style)},p),(0,o.h)("div",{class:"notif_message",style:i.Z.js2css(t.message_style)},u),h)))}}function r(){let t=["Kiều Thanh","Phương Anh","Lê Thùy Linh","Trang Nguyễn","Thanh Hoa","Hoài Đức","Huơng Giang"];return t[Math.floor(Math.random()*t.length)]}function h(){let t=["Dịch Vọng Hậu, Cầu Giấy","Quận 1, TP Hồ Chí Minh","Ngõ 34 Tôn Thất Thuyết","87 Phạm Hùng","Đống Đa, Hà Nội"];return t[Math.floor(Math.random()*t.length)]}}}]);
|
|
File without changes
|
|
File without changes
|