Forráskód Böngészése

definitly fix the history bug due to aggregation by loading history in head

Bachir Soussi Chiadmi 6 éve
szülő
commit
cf1ea6aea7

+ 1 - 14
sites/all/themes/custom/edlptheme/assets/dist/scripts/history.min.js

@@ -1,24 +1,11 @@
-console.log('history');
-// https://plainjs.com/javascript/utilities/set-cookie-get-cookie-and-delete-cookie-5/
-// function setCookie(name, value, days) {
-//   var d = new Date;
-//   d.setTime(d.getTime() + 24*60*60*1000*days);
-//   document.cookie = name + "=" + value + ";path=/;expires=" + d.toGMTString();
-// }
-
+console.log('EDLP THEME HISTORY.js');
 // var edlp is provided by edlp_ajax.module file
 if(edlp.redirect){
   console.log('history redirect');
-  document.body.style.visibility = 'hidden';
-  // record current (will be origin) sys_path in cookie
-  // var cookiename = "edlp_origin_path";
-  // var cookie_value = edlp.sys_path.replace(/^\//, '') + '~~' + window.location.pathname;
-  // setCookie(cookiename, cookie_value, 1);
   window.localStorage.setItem('edlp_origin_path', edlp.sys_path.replace(/^\//, ''));
   window.localStorage.setItem('edlp_origin_url', window.location.pathname);
   // redirect to home
   window.location.replace(window.location.origin);
 }else{
   console.log('history do not redirect');
-  document.body.style.visibility = 'visible';
 }

+ 1 - 0
sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js

@@ -1,3 +1,4 @@
+console.log('EDLP THEME MAIN.js');
 (function($, Drupal, drupalSettings) {
 
   EdlpTheme = function(){

+ 1 - 14
sites/all/themes/custom/edlptheme/assets/scripts/history.js

@@ -1,24 +1,11 @@
-console.log('history');
-// https://plainjs.com/javascript/utilities/set-cookie-get-cookie-and-delete-cookie-5/
-// function setCookie(name, value, days) {
-//   var d = new Date;
-//   d.setTime(d.getTime() + 24*60*60*1000*days);
-//   document.cookie = name + "=" + value + ";path=/;expires=" + d.toGMTString();
-// }
-
+console.log('EDLP THEME HISTORY.js');
 // var edlp is provided by edlp_ajax.module file
 if(edlp.redirect){
   console.log('history redirect');
-  document.body.style.visibility = 'hidden';
-  // record current (will be origin) sys_path in cookie
-  // var cookiename = "edlp_origin_path";
-  // var cookie_value = edlp.sys_path.replace(/^\//, '') + '~~' + window.location.pathname;
-  // setCookie(cookiename, cookie_value, 1);
   window.localStorage.setItem('edlp_origin_path', edlp.sys_path.replace(/^\//, ''));
   window.localStorage.setItem('edlp_origin_url', window.location.pathname);
   // redirect to home
   window.location.replace(window.location.origin);
 }else{
   console.log('history do not redirect');
-  document.body.style.visibility = 'visible';
 }

+ 1 - 0
sites/all/themes/custom/edlptheme/assets/scripts/main.js

@@ -1,3 +1,4 @@
+console.log('EDLP THEME MAIN.js');
 (function($, Drupal, drupalSettings) {
 
   EdlpTheme = function(){

+ 1 - 1
sites/all/themes/custom/edlptheme/edlptheme.info.yml

@@ -5,8 +5,8 @@ base theme: classy
 core: 8.x
 libraries:
   - core/normalize
-  - edlptheme/global-css
   - edlptheme/history-js
+  - edlptheme/global-css
   - edlptheme/global-js
 
 # stylesheets-remove:

+ 6 - 5
sites/all/themes/custom/edlptheme/edlptheme.libraries.yml

@@ -1,21 +1,22 @@
 global-css:
   version: VERSION
   css:
-    base:
+    theme:
       assets/dist/styles/app.min.css: {}
 
 history-js:
   version: VERSION
+  header: true
   js:
-    assets/dist/scripts/history.min.js: { weight:-998, scope: header }
+    assets/dist/scripts/history.min.js: { weight:-998, preprocess: false, minified: true }
 
 global-js:
   version: VERSION
   js:
     # assets/dist/bower/jquery.hotkeys.js: { scope: footer }
-    assets/dist/bower/imagesloaded.pkgd.min.js: { scope: footer }
-    assets/dist/bower/masonry.pkgd.min.js: { scope: footer }
-    assets/dist/scripts/main.min.js: { scope: footer }
+    assets/dist/bower/imagesloaded.pkgd.min.js: { minified: true }
+    assets/dist/bower/masonry.pkgd.min.js: { minified: true }
+    assets/dist/scripts/main.min.js: { minified: true }
   dependencies:
     - core/drupal
     # - core/drupal.ajax