Skip to content

Commit

Permalink
Merge pull request #307 from Oksydan/modules-jquery-removed
Browse files Browse the repository at this point in the history
Removing jQuery from prestashop native modules
  • Loading branch information
Oksydan authored Nov 3, 2023
2 parents 240c54e + 4463432 commit 048d836
Show file tree
Hide file tree
Showing 29 changed files with 953 additions and 661 deletions.
15 changes: 0 additions & 15 deletions _dev/css/theme/components/product/_comments-pagination.scss

This file was deleted.

1 change: 0 additions & 1 deletion _dev/css/theme/components/product/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
@import "stars";
@import "products-list";
@import "product-slider";
@import "comments-pagination";
29 changes: 18 additions & 11 deletions _dev/css/theme/components/product/_stars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,31 @@
top: 0;
left: 0;
display: flex;
flex-wrap: nowrap;
overflow: hidden;

&.star-content-empty {
position: static;
}

.star,
.star-on,
.star-hover {
flex: 0 0 auto;
display: block;
flex: auto;
width: 20px;
height: 20px;
margin-left: 3px;
background: url("../img/icons/star_gray.svg") no-repeat 0 0 transparent;
background-size: 20px;
}

.star-on,
.star-hover {
background-image: url("../img/icons/star_active.svg");
}
&:first-child {
margin-left: 0;
}

.star-hover {
cursor: pointer;
&.star-on {
background-image: url("../img/icons/star_active.svg");
}
}

.small-stars & {
Expand All @@ -35,18 +40,20 @@
height: 16px;
margin-left: 2px;
background-size: 16px;

&:first-child {
margin-left: 0;
}
}
}
}

.grade-stars {
position: relative;
display: inline-block;
min-width: 120px;
height: 20px;

&.small-stars {
min-width: 70px;
height: 16px;
}
}
Expand All @@ -61,6 +68,6 @@
background: rgba($white, 0.4);

.grade-stars {
display: block;
display: inline-block;
}
}
1 change: 1 addition & 0 deletions _dev/js/jquery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'jquery'; // ONLY FOR CHUNK
2 changes: 0 additions & 2 deletions _dev/js/theme.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import 'jquery'; // ONLY FOR CHUNK

import './theme/index';
2 changes: 1 addition & 1 deletion _dev/js/theme/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import EventEmitter from 'events';

import './windowExpose';
import './core/index';
import './vendors/bootstrap/bootstrap-imports';
import './vendors/index';
import './components/dynamic-bootstrap-components';
import bsCustomFileInput from 'bs-custom-file-input';
import './components/header/index';
Expand Down
1 change: 1 addition & 0 deletions _dev/js/theme/vendors/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './bootstrap/bootstrap-imports';
5 changes: 5 additions & 0 deletions _dev/js/theme/windowExpose.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { getAllSiblingsBeforeElement, getAllSiblingsAfterElement } from '../util
import { fromSerializeObject, fromSerialize, formSerializeArray } from '../utils/form/formSerialize';
import useToggleDisplay from '../utils/display/useToggleDisplay';

const { hide, show, toggle } = useToggleDisplay();

exposeToWindow('eventHandlerOn', on);
exposeToWindow('eventHandlerOne', one);
exposeToWindow('eventHandlerOff', off);
Expand All @@ -31,3 +33,6 @@ exposeToWindow('fromSerializeObject', fromSerializeObject);
exposeToWindow('fromSerialize', fromSerialize);
exposeToWindow('formSerializeArray', formSerializeArray);
exposeToWindow('useToggleDisplay', useToggleDisplay);
exposeToWindow('hide', hide);
exposeToWindow('show', show);
exposeToWindow('toggle', toggle);
5 changes: 5 additions & 0 deletions _dev/js/utils/http/useHttpRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ const useHttpRequest = (url, options = {}, addons = []) => {
options.headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
}

// Set default accept header
if (!(options.headers?.accept)) {
options.headers.accept = 'application/json, text/javascript, */*;';
}

// Set default X-Requested-With header
if (!(options.headers?.['X-Requested-With'])) {
options.headers['X-Requested-With'] = 'XMLHttpRequest';
Expand Down
6 changes: 0 additions & 6 deletions _dev/webpack/webpack.parts.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,6 @@ exports.extractVendorsChunks = () => ({
filename: 'js/swipervendor.js',
chunks: 'initial',
},
jquery: {
test: /[\\/]node_modules[\\/](jquery)[\\/]/,
name: 'jquery',
filename: 'js/jquery.js',
chunks: 'initial',
},
shared: {
name: 'shared',
chunks: 'initial',
Expand Down
1 change: 1 addition & 0 deletions _dev/webpack/webpack.production.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const plugins = (purge, analyze) => ([
new EsbuildPlugin({
target: 'es2016',
format: 'iife',
minify: true,
}),
analyze ? new BundleAnalyzerPlugin() : false,
purge ? new PurgeCSSPlugin({
Expand Down
2 changes: 2 additions & 0 deletions _dev/webpack/webpack.vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ exports.webpackVars = {
]
}

resultEntries.jquery = path.resolve(themeDev, `./js/jquery.js`);

return resultEntries;
},
getOutput: ({ mode, publicPath, siteURL, port, devServer }) => ({
Expand Down
6 changes: 3 additions & 3 deletions config/assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ js:
runtime: # This file is only used to handle HMR for multiple entry points
fileName: runtime.js
priority: 1
jquery:
fileName: jquery.js
priority: 1
# jquery: # Uncomment this if you want to use jQuery
# fileName: jquery.js
# priority: 1
shared: # Shared code between all pages autogenerated by Webpack
fileName: shared.js
priority: 1
Expand Down
Loading

0 comments on commit 048d836

Please sign in to comment.