web-manager 2.1.30 → 2.1.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +97 -41
  2. package/package.json +4 -4
package/index.js CHANGED
@@ -169,7 +169,7 @@ function Manager() {
169
169
  this.properties.page.status.eventHandlersSet = true;
170
170
  var This = this;
171
171
  // document.addEventListener('click', function (event) {
172
- This.dom().select('body').on('click', function (event) {
172
+ document.addEventListener('click', function (event) {
173
173
  // console.log('Clicked.... NEW');
174
174
  // This.log('Clicked', event.target);
175
175
  // auth events
@@ -837,26 +837,45 @@ function Manager() {
837
837
  domLib.select(erel).hide().setInnerHTML('');
838
838
  }
839
839
 
840
- function signinButtonDisabled(status) {
840
+ // function signinButtonDisabled(status) {
841
+ // if (status) {
842
+ // domLib.select('.auth-signin-email-btn').setAttribute('disabled', true);
843
+ // } else {
844
+ // domLib.select('.auth-signin-email-btn').removeAttribute('disabled');
845
+ // }
846
+ // }
847
+ // function signupButtonDisabled(status) {
848
+ // if (status) {
849
+ // domLib.select('.auth-signup-email-btn').setAttribute('disabled', true);
850
+ // } else {
851
+ // domLib.select('.auth-signup-email-btn').removeAttribute('disabled');
852
+ // }
853
+ // }
854
+ // function forgotButtonDisabled(status) {
855
+ // if (status) {
856
+ // domLib.select('.auth-forgot-email-btn').setAttribute('disabled', true);
857
+ // } else {
858
+ // domLib.select('.auth-forgot-email-btn').removeAttribute('disabled');
859
+ // }
860
+ // }
861
+
862
+ function setAuthButtonDisabled(button, status) {
863
+ var el = domLib.select('.auth-' + button + '-email-btn');
864
+ var disabled = 'disabled';
841
865
  if (status) {
842
- domLib.select('.auth-signin-email-btn').setAttribute('disabled', true);
866
+ el.setAttribute(disabled, true);
843
867
  } else {
844
- domLib.select('.auth-signin-email-btn').removeAttribute('disabled');
868
+ el.removeAttribute(disabled);
845
869
  }
846
870
  }
847
- function signupButtonDisabled(status) {
848
- if (status) {
849
- domLib.select('.auth-signup-email-btn').setAttribute('disabled', true);
850
- } else {
851
- domLib.select('.auth-signup-email-btn').removeAttribute('disabled');
852
- }
853
- }
854
- function forgotButtonDisabled(status) {
855
- if (status) {
856
- domLib.select('.auth-forgot-email-btn').setAttribute('disabled', true);
857
- } else {
858
- domLib.select('.auth-forgot-email-btn').removeAttribute('disabled');
859
- }
871
+
872
+ function resolveAuthInput(existing, mode, input) {
873
+ var authSelector = '.auth-';
874
+ var inputSelector = authSelector + input + '-input';
875
+ var formSelector = authSelector + mode + '-form ';
876
+ // var temp
877
+
878
+ return existing || domLib.select(formSelector + inputSelector).getValue() || domLib.select(inputSelector).getValue()
860
879
  }
861
880
 
862
881
  return {
@@ -896,13 +915,20 @@ function Manager() {
896
915
  }
897
916
  },
898
917
  signIn: function (method, email, password) {
918
+ var mode = 'signin';
899
919
  method = method || 'email';
900
920
  _preDisplayError();
901
921
  // This.log('Signin attempt: ', method, email, password);
902
922
  if (method === 'email') {
903
- email = (email || domLib.select('.auth-email-input').getValue()).trim().toLowerCase();
904
- password = password || domLib.select('.auth-password-input').getValue();
905
- signinButtonDisabled(true);
923
+ // email = (email || domLib.select('.auth-email-input').getValue()).trim().toLowerCase();
924
+ email = resolveAuthInput(email, mode, 'email').trim().toLowerCase();
925
+ // password = password || domLib.select('.auth-password-input').getValue();
926
+ password = resolveAuthInput(password, mode, 'password');
927
+ // console.log('Signin attempt: ', method, email, password);
928
+
929
+ // signinButtonDisabled(true);
930
+ setAuthButtonDisabled(mode, true);
931
+
906
932
  firebase.auth().signInWithEmailAndPassword(email, password)
907
933
  .then(function(credential) {
908
934
  // _postAuthSubscriptionCheck(This)
@@ -910,11 +936,13 @@ function Manager() {
910
936
  //
911
937
  // })
912
938
  This.properties.page.status.didSignIn = true;
913
- signinButtonDisabled(false);
939
+ // signinButtonDisabled(false);
940
+ setAuthButtonDisabled(mode, false);
914
941
  // This.log('Good signin');
915
942
  })
916
943
  .catch(function(error) {
917
- signinButtonDisabled(false);
944
+ // signinButtonDisabled(false);
945
+ setAuthButtonDisabled(mode, false);
918
946
  _displayError(error.message);
919
947
  // This.log('Error', error.message);
920
948
  });
@@ -927,22 +955,37 @@ function Manager() {
927
955
  }
928
956
  },
929
957
  signUp: function(method, email, password, passwordConfirm) {
958
+ var mode = 'signup';
930
959
  method = method || 'email';
931
960
 
932
961
  _preDisplayError();
933
962
  // This.log('Signup attempt: ', method, email, password, passwordConfirm);
934
- var termEl = domLib.select('.auth-terms-input');
935
- if (termEl.exists() && !termEl.getValue() === true) {
963
+ // var acceptedTerms
964
+ // var termEl = domLib.select('.auth-terms-input');
965
+ // if (termEl.exists() && !termEl.getValue() === true) {
966
+ // _displayError('Please review and accept our terms.');
967
+ // return;
968
+ // }
969
+ var termsSelector = '.auth-terms-input';
970
+ var termSpecificEl = domLib.select('.auth-signup-form ' + termsSelector)
971
+ var termGenericEl = domLib.select(termsSelector)
972
+ if ((termSpecificEl.exists() && !termSpecificEl.getValue() === true) || (termGenericEl.exists() && !termGenericEl.getValue() === true)) {
936
973
  _displayError('Please review and accept our terms.');
937
974
  return;
938
975
  }
976
+
939
977
  if (method === 'email') {
940
- email = (email || domLib.select('.auth-email-input').getValue()).trim().toLowerCase();
941
- password = password || domLib.select('.auth-password-input').getValue();
942
- passwordConfirm = passwordConfirm || domLib.select('.auth-password-confirm-input').getValue();
978
+ // email = (email || domLib.select('.auth-email-input').getValue()).trim().toLowerCase();
979
+ email = resolveAuthInput(email, mode, 'email').trim().toLowerCase();
980
+ // password = password || domLib.select('.auth-password-input').getValue();
981
+ password = resolveAuthInput(password, mode, 'password');
982
+ // passwordConfirm = passwordConfirm || domLib.select('.auth-password-confirm-input').getValue();
983
+ passwordConfirm = resolveAuthInput(passwordConfirm, mode, 'password-confirm');
984
+ // console.log('Signup attempt: ', method, email, password, passwordConfirm);
943
985
 
944
986
  if (password === passwordConfirm) {
945
- signupButtonDisabled(true);
987
+ // signupButtonDisabled(true);
988
+ setAuthButtonDisabled(mode, true);
946
989
  firebase.auth().createUserWithEmailAndPassword(email, password)
947
990
  .then(function(credential) {
948
991
  This.properties.page.status.didSignUp = true;
@@ -950,7 +993,8 @@ function Manager() {
950
993
  // signupButtonDisabled(false);
951
994
  })
952
995
  .catch(function(error) {
953
- signupButtonDisabled(false);
996
+ // signupButtonDisabled(false);
997
+ setAuthButtonDisabled(mode, false);
954
998
  _displayError(error.message);
955
999
  // This.log('error', error.message);
956
1000
  });
@@ -976,17 +1020,24 @@ function Manager() {
976
1020
  },
977
1021
  forgot: function(email) {
978
1022
  // This.log('forgot()');
979
- email = email || domLib.select('.auth-email-input').getValue();
980
- forgotButtonDisabled(true);
1023
+ var mode = 'forgot';
1024
+ // email = email || domLib.select('.auth-email-input').getValue();
1025
+ email = resolveAuthInput(email, mode, 'email').trim().toLowerCase();
1026
+
1027
+ // forgotButtonDisabled(true);
1028
+ setAuthButtonDisabled(mode, true);
981
1029
  _preDisplayError();
1030
+
982
1031
  firebase.auth().sendPasswordResetEmail(email)
983
1032
  .then(function() {
984
- forgotButtonDisabled(false);
1033
+ // forgotButtonDisabled(false);
1034
+ setAuthButtonDisabled(mode, false);
985
1035
  // This.log('forgot success.');
986
1036
  _displayError('A reset link has been sent to you.');
987
1037
  })
988
1038
  .catch(function(error) {
989
- forgotButtonDisabled(false);
1039
+ // forgotButtonDisabled(false);
1040
+ setAuthButtonDisabled(mode, false);
990
1041
  // This.log('forgot failed: ', error);
991
1042
  _displayError(error.message);
992
1043
  });
@@ -1220,6 +1271,7 @@ function Manager() {
1220
1271
  if (setting.enabled === true) {
1221
1272
  function _post() {
1222
1273
  // This.log('Loaded Firebase.');
1274
+ // console.log('_post.');
1223
1275
  window.app = firebase.initializeApp(setting.config);
1224
1276
 
1225
1277
  Promise.all([
@@ -1231,8 +1283,9 @@ function Manager() {
1231
1283
  .catch(reject);
1232
1284
  }
1233
1285
  if (setting.load) {
1234
- setting.load()
1235
- _post()
1286
+ setting.load(This)
1287
+ .then(_post)
1288
+ .catch(reject);
1236
1289
  } else {
1237
1290
  import('firebase/app')
1238
1291
  .then(function(mod) {
@@ -1256,8 +1309,9 @@ function Manager() {
1256
1309
  var setting = options.libraries.firebase_auth;
1257
1310
  if (setting.enabled === true) {
1258
1311
  if (setting.load) {
1259
- setting.load()
1260
- resolve()
1312
+ setting.load(This)
1313
+ .then(resolve)
1314
+ .catch(reject);
1261
1315
  } else {
1262
1316
  import('firebase/auth')
1263
1317
  .then(resolve)
@@ -1279,8 +1333,9 @@ function Manager() {
1279
1333
  var setting = options.libraries.firebase_firestore;
1280
1334
  if (setting.enabled === true) {
1281
1335
  if (setting.load) {
1282
- setting.load()
1283
- resolve()
1336
+ setting.load(This)
1337
+ .then(resolve)
1338
+ .catch(reject);
1284
1339
  } else {
1285
1340
  import('firebase/firestore')
1286
1341
  .then(resolve)
@@ -1300,8 +1355,9 @@ function Manager() {
1300
1355
  var setting = options.libraries.firebase_messaging;
1301
1356
  if (setting.enabled === true) {
1302
1357
  if (setting.load) {
1303
- setting.load()
1304
- resolve()
1358
+ setting.load(This)
1359
+ .then(resolve)
1360
+ .catch(reject);
1305
1361
  } else {
1306
1362
  import('firebase/messaging')
1307
1363
  .then(resolve)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "2.1.30",
3
+ "version": "2.1.34",
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": {
@@ -23,9 +23,9 @@
23
23
  },
24
24
  "homepage": "https://itwcreativeworks.com",
25
25
  "dependencies": {
26
- "@sentry/browser": "^6.15.0",
26
+ "@sentry/browser": "^6.17.3",
27
27
  "cookieconsent": "^3.1.1",
28
- "firebase": "^8.10.0",
28
+ "firebase": "^8.10.1",
29
29
  "lazysizes": "^5.3.2"
30
30
  }
31
- }
31
+ }