@subiz/widget-v4 4.1.206 → 4.1.207

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.
@@ -37,6 +37,7 @@
37
37
  //@mobile-chat-button-background-mask-url : '@mobile_button.background_mask_url'; // @default-chat-button-background-image-url;
38
38
  @mobile-chat-button-margin-x: '@mobile_button.margin_x'; // 20px;
39
39
  @mobile-chat-button-margin-y: '@mobile_button.margin_y'; //20px;
40
+ @mobile-widget-height: '@mobile_height'; // 100%;
40
41
 
41
42
  @widget-position: '@widget_position';
42
43
 
@@ -154,11 +154,11 @@
154
154
  border-radius: 0px;
155
155
  max-height: 100%;
156
156
  margin-bottom: 0;
157
- top: 0;
157
+ top: auto;
158
158
  left: 0;
159
159
  right: 0;
160
160
  width: 100%;
161
- height: 100%;
161
+ height: @mobile-widget-height;
162
162
 
163
163
  opacity: 1;
164
164
  transition: opacity 0.15s cubic-bezier(1, 0.5, 0.8, 1);
@@ -62,7 +62,7 @@ class Main extends _common.Com {
62
62
  });
63
63
  this.refreshCSS();
64
64
  let lastview = this.props.store.matchLastview() || {};
65
- let cid = _index.default.get(lastview, 'opts.cid');
65
+ let cid = _index.default.get(lastview, 'screen') === 'widget' ? _index.default.get(lastview, 'opts.cid') : '';
66
66
  if (cid) {
67
67
  this._last_cid = cid;
68
68
  this.setState({
@@ -172,7 +172,7 @@ class Main extends _common.Com {
172
172
  });
173
173
  }
174
174
  onNewMessageShowWidget(cid) {
175
- if (this.props.store.isMobile()) modifyViewport();
175
+ if (this.props.store.isMobile()) modifyViewport(this.shouldLockPageScroll());
176
176
  this.props.store.updateLastview({
177
177
  screen: 'widget',
178
178
  previewEvent: {},
@@ -183,6 +183,9 @@ class Main extends _common.Com {
183
183
  });
184
184
  this.forceUpdate();
185
185
  }
186
+ shouldLockPageScroll() {
187
+ return _index.default.get(this.props.plugin, 'chatbox.mobile_height') === undefined;
188
+ }
186
189
  async showWidget(p) {
187
190
  let cid = p.cid;
188
191
  let newView = {
@@ -203,7 +206,7 @@ class Main extends _common.Com {
203
206
  cid
204
207
  };
205
208
  }
206
- if (this.props.store.isMobile()) modifyViewport();
209
+ if (this.props.store.isMobile()) modifyViewport(this.shouldLockPageScroll());
207
210
  this.props.store.updateLastview(newView);
208
211
  this.forceUpdate();
209
212
  }
@@ -248,9 +251,11 @@ function restoreViewport() {
248
251
  let metatag = document.getElementById('subiz-meta-viewport');
249
252
  if (metatag) metatag.remove();
250
253
  }
251
- function modifyViewport() {
252
- if (document.body && document.body.classList) document.body.classList.add('sbz_no_scroll');
253
- if (document.documentElement && document.documentElement.classList) document.documentElement.classList.add('sbz_no_scroll');
254
+ function modifyViewport(lockPageScroll) {
255
+ if (lockPageScroll) {
256
+ if (document.body && document.body.classList) document.body.classList.add('sbz_no_scroll');
257
+ if (document.documentElement && document.documentElement.classList) document.documentElement.classList.add('sbz_no_scroll');
258
+ }
254
259
  let currentMetas = document.querySelectorAll('meta[name="viewport"]');
255
260
  let shouldAddMetaTag = true;
256
261
  for (let i = 0; i < currentMetas.length; i++) {
@@ -640,6 +640,7 @@ function replaceCssVariable(css, setting) {
640
640
  tokens = tokenize(tokens, "'@mobile_button.border_radius'");
641
641
  tokens = tokenize(tokens, "'@mobile_button.margin_x'");
642
642
  tokens = tokenize(tokens, "'@mobile_button.margin_y'");
643
+ tokens = tokenize(tokens, "'@mobile_height'");
643
644
  tokens = tokenize(tokens, "'@widget_position'");
644
645
  tokens = tokenize(tokens, "'@z_index'");
645
646
  tokens = tokenize(tokens, "'@z_index_2'");
@@ -763,6 +764,7 @@ const DEFVAL = exports.DEFVAL = {
763
764
  margin_x: 0.3,
764
765
  margin_y: 0.3
765
766
  },
767
+ mobile_height: '100%',
766
768
  widget_position: 'fixed',
767
769
  z_index: 2000000000
768
770
  };
@@ -51,6 +51,14 @@ test('util.randomString', t => {
51
51
  t.equal(12, util.randomString(12).length);
52
52
  t.end();
53
53
  });
54
+ test('replaceCssVariable mobile height', t => {
55
+ let css = "height: '@mobile_height';";
56
+ t.equal(util.replaceCssVariable(css, {}), 'height: 100%;', 'defaults to full mobile height');
57
+ t.equal(util.replaceCssVariable(css, {
58
+ mobile_height: '50%'
59
+ }), 'height: 50%;', 'uses configured mobile height');
60
+ t.end();
61
+ });
54
62
  test('convert message event first msg send', t => {
55
63
  var events = [{
56
64
  by: {