web-manager 3.1.21 → 3.1.23

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.
Files changed (2) hide show
  1. package/index.js +44 -34
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -28,6 +28,9 @@ var debug;
28
28
  // var utilities;
29
29
  // var storage;
30
30
 
31
+ // Shortcuts
32
+ var select;
33
+
31
34
 
32
35
  /**
33
36
  * MODULE
@@ -150,6 +153,8 @@ function Manager() {
150
153
 
151
154
  }
152
155
 
156
+ select = this.dom().select;
157
+
153
158
  }
154
159
 
155
160
  /**
@@ -235,8 +240,6 @@ function Manager() {
235
240
  function _authHandle_in(This, user) {
236
241
  // This.log('_authHandle_in', user);
237
242
  if (This.properties.page.status.didSignUp) {
238
- var domLib = This.dom();
239
-
240
243
  user.getIdToken(false)
241
244
  .then(function(token) {
242
245
  var done;
@@ -246,7 +249,7 @@ function Manager() {
246
249
  authenticationToken: token,
247
250
  command: 'user:sign-up',
248
251
  payload: {
249
- newsletterSignUp: domLib.select('.auth-newsletter-input').getValue(),
252
+ newsletterSignUp: select('.auth-newsletter-input').getValue(),
250
253
  affiliateCode: This.storage().get('auth.affiliateCode', ''),
251
254
  }
252
255
  }),
@@ -290,7 +293,6 @@ function Manager() {
290
293
 
291
294
 
292
295
  function _authHandle_in_normal(This, user) {
293
- var domLib = This.dom();
294
296
  var returnUrl = This.properties.page.queryString.get('auth_redirect');
295
297
  if (returnUrl && This.isValidRedirectUrl(returnUrl)) {
296
298
  window.location.href = decodeURIComponent(returnUrl);
@@ -300,20 +302,20 @@ function Manager() {
300
302
  window.location.href = This.properties.options.auth.sends.prohibited;
301
303
  return;
302
304
  }
303
- domLib.select('.auth-signedin-true-element').show();
304
- domLib.select('.auth-signedin-false-element').hide();
305
- domLib.select('.auth-email-element').each(function(e, i) {
305
+ select('.auth-signedin-true-element').show();
306
+ select('.auth-signedin-false-element').hide();
307
+ select('.auth-email-element').each(function(e, i) {
306
308
  if (e.tagName === 'INPUT') {
307
- domLib.select(e).setValue(user.email)
309
+ select(e).setValue(user.email)
308
310
  } else {
309
- domLib.select(e).setInnerHTML(user.email)
311
+ select(e).setInnerHTML(user.email)
310
312
  }
311
313
  });
312
- domLib.select('.auth-uid-element').each(function(e, i) {
314
+ select('.auth-uid-element').each(function(e, i) {
313
315
  if (e.tagName === 'INPUT') {
314
- domLib.select(e).setValue(user.uid)
316
+ select(e).setValue(user.uid)
315
317
  } else {
316
- domLib.select(e).setInnerHTML(user.uid)
318
+ select(e).setInnerHTML(user.uid)
317
319
  }
318
320
  });
319
321
  }
@@ -686,10 +688,17 @@ function Manager() {
686
688
 
687
689
  var chatsyOps = options_user.libraries.chatsy;
688
690
  if (chatsyOps.enabled) {
689
- This.dom().select('#prechat-btn').css({
691
+ var preChatBtn = select('#prechat-btn');
692
+
693
+ preChatBtn.css({
690
694
  background: chatsyOps.config.settings.openChatButton.background,
691
695
  })
692
696
  .show();
697
+
698
+ window.chatsy = {};
699
+ window.chatsy.open = function() {
700
+ preChatBtn.get(0).click();
701
+ }
693
702
  }
694
703
 
695
704
  // load non-critical libraries
@@ -822,40 +831,39 @@ function Manager() {
822
831
  var This = this;
823
832
  var firebaseActive = typeof firebase !== 'undefined';
824
833
  var erel = '.auth-error-message-element';
825
- var domLib = This.dom();
826
834
 
827
835
  function _displayError(msg) {
828
836
  console.error(msg);
829
- domLib.select(erel).show().setInnerHTML(msg);
837
+ select(erel).show().setInnerHTML(msg);
830
838
  }
831
839
  function _preDisplayError() {
832
- domLib.select(erel).hide().setInnerHTML('');
840
+ select(erel).hide().setInnerHTML('');
833
841
  }
834
842
 
835
843
  // function signinButtonDisabled(status) {
836
844
  // if (status) {
837
- // domLib.select('.auth-signin-email-btn').setAttribute('disabled', true);
845
+ // select('.auth-signin-email-btn').setAttribute('disabled', true);
838
846
  // } else {
839
- // domLib.select('.auth-signin-email-btn').removeAttribute('disabled');
847
+ // select('.auth-signin-email-btn').removeAttribute('disabled');
840
848
  // }
841
849
  // }
842
850
  // function signupButtonDisabled(status) {
843
851
  // if (status) {
844
- // domLib.select('.auth-signup-email-btn').setAttribute('disabled', true);
852
+ // select('.auth-signup-email-btn').setAttribute('disabled', true);
845
853
  // } else {
846
- // domLib.select('.auth-signup-email-btn').removeAttribute('disabled');
854
+ // select('.auth-signup-email-btn').removeAttribute('disabled');
847
855
  // }
848
856
  // }
849
857
  // function forgotButtonDisabled(status) {
850
858
  // if (status) {
851
- // domLib.select('.auth-forgot-email-btn').setAttribute('disabled', true);
859
+ // select('.auth-forgot-email-btn').setAttribute('disabled', true);
852
860
  // } else {
853
- // domLib.select('.auth-forgot-email-btn').removeAttribute('disabled');
861
+ // select('.auth-forgot-email-btn').removeAttribute('disabled');
854
862
  // }
855
863
  // }
856
864
 
857
865
  function setAuthButtonDisabled(button, status) {
858
- var el = domLib.select('.auth-' + button + '-email-btn');
866
+ var el = select('.auth-' + button + '-email-btn');
859
867
  var disabled = 'disabled';
860
868
  if (status) {
861
869
  el.setAttribute(disabled, true);
@@ -868,7 +876,7 @@ function Manager() {
868
876
  var authSelector = '.auth-';
869
877
  var inputSelector = authSelector + input + '-input';
870
878
  var formSelector = authSelector + mode + '-form ';
871
- var result = existing || domLib.select(formSelector + inputSelector).getValue() || domLib.select(inputSelector).getValue();
879
+ var result = existing || select(formSelector + inputSelector).getValue() || select(inputSelector).getValue();
872
880
 
873
881
  return input === 'email' ? result.trim().toLowerCase() : result;
874
882
  }
@@ -914,9 +922,9 @@ function Manager() {
914
922
  _preDisplayError();
915
923
  // This.log('Signin attempt: ', method, email, password);
916
924
  if (method === 'email') {
917
- // email = (email || domLib.select('.auth-email-input').getValue()).trim().toLowerCase();
925
+ // email = (email || select('.auth-email-input').getValue()).trim().toLowerCase();
918
926
  email = resolveAuthInput(email, mode, 'email');
919
- // password = password || domLib.select('.auth-password-input').getValue();
927
+ // password = password || select('.auth-password-input').getValue();
920
928
  password = resolveAuthInput(password, mode, 'password');
921
929
  // console.log('Signin attempt: ', method, email, password);
922
930
 
@@ -954,25 +962,25 @@ function Manager() {
954
962
  _preDisplayError();
955
963
  // This.log('Signup attempt: ', method, email, password, passwordConfirm);
956
964
  // var acceptedTerms
957
- // var termEl = domLib.select('.auth-terms-input');
965
+ // var termEl = select('.auth-terms-input');
958
966
  // if (termEl.exists() && !termEl.getValue() === true) {
959
967
  // _displayError('Please review and accept our terms.');
960
968
  // return;
961
969
  // }
962
970
  var termsSelector = '.auth-terms-input';
963
- var termSpecificEl = domLib.select('.auth-signup-form ' + termsSelector)
964
- var termGenericEl = domLib.select(termsSelector)
971
+ var termSpecificEl = select('.auth-signup-form ' + termsSelector)
972
+ var termGenericEl = select(termsSelector)
965
973
  if ((termSpecificEl.exists() && !termSpecificEl.getValue() === true) || (termGenericEl.exists() && !termGenericEl.getValue() === true)) {
966
974
  _displayError('Please review and accept our terms.');
967
975
  return;
968
976
  }
969
977
 
970
978
  if (method === 'email') {
971
- // email = (email || domLib.select('.auth-email-input').getValue()).trim().toLowerCase();
979
+ // email = (email || select('.auth-email-input').getValue()).trim().toLowerCase();
972
980
  email = resolveAuthInput(email, mode, 'email');
973
- // password = password || domLib.select('.auth-password-input').getValue();
981
+ // password = password || select('.auth-password-input').getValue();
974
982
  password = resolveAuthInput(password, mode, 'password');
975
- // passwordConfirm = passwordConfirm || domLib.select('.auth-password-confirm-input').getValue();
983
+ // passwordConfirm = passwordConfirm || select('.auth-password-confirm-input').getValue();
976
984
  passwordConfirm = resolveAuthInput(passwordConfirm, mode, 'password-confirm');
977
985
  // console.log('Signup attempt: ', method, email, password, passwordConfirm);
978
986
 
@@ -1019,7 +1027,7 @@ function Manager() {
1019
1027
  forgot: function(email) {
1020
1028
  // This.log('forgot()');
1021
1029
  var mode = 'forgot';
1022
- // email = email || domLib.select('.auth-email-input').getValue();
1030
+ // email = email || select('.auth-email-input').getValue();
1023
1031
  email = resolveAuthInput(email, mode, 'email')
1024
1032
 
1025
1033
  // forgotButtonDisabled(true);
@@ -1417,6 +1425,7 @@ function Manager() {
1417
1425
 
1418
1426
  var load_chatsy = function(This, options) {
1419
1427
  var dom = This.dom();
1428
+
1420
1429
  return new Promise(function(resolve, reject) {
1421
1430
  if (options.libraries.chatsy.enabled === true) {
1422
1431
  var chatsyPath = 'libraries.chatsy.config';
@@ -1428,6 +1437,7 @@ function Manager() {
1428
1437
  attributes: [
1429
1438
  {name: 'data-account-id', value: utilities.get(options, chatsyPath + '.accountId', '')},
1430
1439
  {name: 'data-chat-id', value: utilities.get(options, chatsyPath + '.chatId', '')},
1440
+ {name: 'data-settings', value: JSON.stringify(utilities.get(options, chatsyPath + '.settings', ''))},
1431
1441
  ],
1432
1442
  crossorigin: true,
1433
1443
  }, function(e) {
@@ -1436,7 +1446,7 @@ function Manager() {
1436
1446
  }
1437
1447
 
1438
1448
  chatsy.open();
1439
- dom.select('#prechat-btn').hide();
1449
+ select('#prechat-btn').hide();
1440
1450
 
1441
1451
  resolve();
1442
1452
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "3.1.21",
3
+ "version": "3.1.23",
4
4
  "description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
5
5
  "main": "index.js",
6
6
  "scripts": {