Skip to content

Commit 4000e4d

Browse files
committed
Removed jquery dependencies from the code
1 parent 9b904d8 commit 4000e4d

20 files changed

Lines changed: 224 additions & 12718 deletions

File tree

src/LIN3S/AdminBundle/Resources/private/js/app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
import {onDomReady} from 'lin3s-event-bus';
1414
import FastClick from 'fastclick';
1515

16+
import './components/Filter';
1617
import './components/FormCollection';
18+
import './components/MenuToggle';
19+
import './components/Panel';
1720
import './polyfills';
18-
import './filter';
19-
import './menu';
20-
import './panel';
2121

2222
const onReady = () => {
2323
new FastClick(document.body);
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* This file is part of the Admin Bundle.
3+
*
4+
* Copyright (c) 2015-present LIN3S <info@lin3s.com>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* @author Beñat Espiña <benatespina@gmail.com>
10+
*/
11+
12+
import {onDomReady} from 'lin3s-event-bus';
13+
14+
class Filter {
15+
constructor(rootNode) {
16+
this.options = rootNode.querySelector('.filter__options');
17+
this.filterBy = rootNode.querySelector('.filter__filter-by');
18+
19+
this.onFilterByChanged = this.onFilterByChanged.bind(this);
20+
21+
this.filterBy.addEventListener('change', this.onFilterByChanged);
22+
}
23+
24+
onFilterByChanged(event) {
25+
const
26+
optionInputs = this.options.children,
27+
filter = this.options.querySelector(`[data-filter-field="${event.currentTarget.value}"]`),
28+
focusEvent = document.createEvent('HTMLEvents');
29+
30+
Array.from(optionInputs).forEach((optionInput) => {
31+
optionInput.classList.add('filter__option--hidden');
32+
optionInput.setAttribute('name', '');
33+
});
34+
35+
focusEvent.initEvent('focus', true, false);
36+
37+
filter.classList.remove('filter__option--hidden');
38+
filter.setAttribute('name', 'filter');
39+
filter.dispatchEvent(focusEvent);
40+
}
41+
}
42+
43+
const onReady = () => {
44+
const filters = document.querySelectorAll('.filter');
45+
46+
if (filters.length === 0) {
47+
return;
48+
}
49+
50+
Array.from(filters).forEach(filter => new Filter(filter));
51+
};
52+
53+
onDomReady(onReady);
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* This file is part of the Admin Bundle.
3+
*
4+
* Copyright (c) 2015-present LIN3S <info@lin3s.com>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* @author Beñat Espiña <benatespina@gmail.com>
10+
* @author Gorka Laucirica <gorka.lauzirika@gmail.com>
11+
*/
12+
13+
import {onDomReady} from 'lin3s-event-bus';
14+
15+
class MenuToggle {
16+
constructor(rootNode) {
17+
this.menuToggle = rootNode;
18+
this.menu = this.menuToggle.closest('.menu');
19+
20+
this.onClick = this.onClick.bind(this);
21+
22+
this.menuToggle.addEventListener('click', this.onClick);
23+
}
24+
25+
onClick(event) {
26+
event.preventDefault();
27+
28+
this.menuToggle.classList.toggle('menu-toggle--visible');
29+
30+
if (this.menu.classList.contains('menu--open')) {
31+
this.menu.setAttribute('style', '');
32+
} else {
33+
this.menu.style.height = `${this.menu.scrollHeight}px`;
34+
}
35+
36+
this.menu.classList.toggle('menu--open');
37+
}
38+
}
39+
40+
const onReady = () => {
41+
const menuToggles = document.querySelectorAll('.menu-toggle');
42+
43+
if (menuToggles.length === 0) {
44+
return;
45+
}
46+
47+
Array.from(menuToggles).forEach(menuToggle => new MenuToggle(menuToggle));
48+
};
49+
50+
onDomReady(onReady);
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* This file is part of the Admin Bundle.
3+
*
4+
* Copyright (c) 2015-present LIN3S <info@lin3s.com>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* @author Beñat Espiña <benatespina@gmail.com>
10+
* @author Gorka Laucirica <gorka.lauzirika@gmail.com>
11+
*/
12+
13+
import {onDomReady} from 'lin3s-event-bus';
14+
15+
class Panel {
16+
constructor(rootNode) {
17+
this.panel = rootNode;
18+
this.panelHeaders = this.panel.querySelectorAll('.panel__header');
19+
20+
this.onClick = this.onClick.bind(this);
21+
22+
Array.from(this.panelHeaders).forEach(panelHeader => panelHeader.addEventListener('click', this.onClick));
23+
}
24+
25+
onClick(event) {
26+
event.preventDefault();
27+
28+
this.panel.classList.toggle('panel--closed');
29+
}
30+
}
31+
32+
const onReady = () => {
33+
const panels = document.querySelectorAll('.panel');
34+
35+
if (panels.length === 0) {
36+
return;
37+
}
38+
39+
Array.from(panels).forEach(panel => new Panel(panel));
40+
};
41+
42+
onDomReady(onReady);

src/LIN3S/AdminBundle/Resources/private/js/filter.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/LIN3S/AdminBundle/Resources/private/js/menu.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/LIN3S/AdminBundle/Resources/private/js/panel.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/LIN3S/AdminBundle/Resources/private/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
{
22
"name": "lin3s-admin-bundle",
3+
"description": "Admin Bundle in the LIN3S way",
34
"author": "LIN3S",
5+
"license": "MIT",
46
"private": true,
7+
"scripts": {
8+
"build": "node_modules/.bin/webpack --config=./webpack.bundle.config.babel.js",
9+
"build:watch": "node_modules/.bin/webpack --config=./webpack.bundle.config.babel.js --watch",
10+
"build:prod": "node_modules/.bin/webpack --config=./webpack.bundle.config.babel.js -p"
11+
},
512
"babel": {
613
"presets": [
714
"stage-2",
8-
"react",
915
"es2015"
1016
],
1117
"plugins": [
1218
"transform-class-properties"
1319
]
1420
},
15-
"scripts": {
16-
"build": "node_modules/.bin/webpack --config=./webpack.bundle.config.babel.js",
17-
"build:watch": "node_modules/.bin/webpack --config=./webpack.bundle.config.babel.js --watch",
18-
"build:prod": "node_modules/.bin/webpack --config=./webpack.bundle.config.babel.js -p"
19-
},
2021
"dependencies": {
2122
"array-from": "^2.1.1",
2223
"fastclick": "^1.0.6",
2324
"jquery": "^3.2.1",
2425
"lin3s-css-grid": "^0.3.0",
2526
"lin3s-event-bus": "^0.6.0",
26-
"lin3s-front-foundation": "^0.5.0",
27-
"magnific-popup": "^1.1.0"
27+
"lin3s-front-foundation": "^0.5.0"
2828
},
2929
"devDependencies": {
3030
"autoprefixer": "^6.7.2",

src/LIN3S/AdminBundle/Resources/private/scss/components/_filter.scss

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
// This file is part of the Admin Bundle.
22
//
3-
// Copyright (c) 2015-2016 LIN3S <info@lin3s.com>
3+
// Copyright (c) 2015-present LIN3S <info@lin3s.com>
44
//
55
// For the full copyright and license information, please view the LICENSE
66
// file that was distributed with this source code.
77
//
88
// @author Gorka Laucirica <gorka.lauzirika@gmail.com>
9-
10-
@import './../../node_modules/lin3s-css-grid/scss/variables';
9+
// @author Beñat Espiña <benatespina@gmail.com>
1110

1211
@import '../variables/colors';
12+
@import '../variables/grid';
1313

1414
$filter-background-color: $color-white !default;
15+
$filter-element-height: 37px;
1516

1617
.filter {
1718
align-items: center;
@@ -22,21 +23,32 @@ $filter-background-color: $color-white !default;
2223
}
2324

2425
.filter__filter-by {
26+
margin-right: -1px; // Solves 1px border-width sum
2527
order: 0;
2628
}
2729

2830
.filter__filter-by,
2931
.filter__options .form__input {
3032
width: 100%;
33+
34+
&:focus {
35+
z-index: 1;
36+
}
3137
}
3238

3339
.filter__option--hidden {
3440
display: none;
3541
}
3642

3743
.filter__button {
38-
margin-top: 15px;
39-
width: 100%;
44+
height: $filter-element-height;
45+
46+
.button {
47+
border-bottom-left-radius: 0;
48+
border-top-left-radius: 0;
49+
box-shadow: none;
50+
height: 100%;
51+
}
4052
}
4153

4254
@media #{$medium-up} {
@@ -46,9 +58,6 @@ $filter-background-color: $color-white !default;
4658

4759
.filter__button.button {
4860
align-self: stretch;
49-
border-bottom-left-radius: 0;
50-
border-top-left-radius: 0;
51-
box-shadow: none;
5261
margin-top: 0;
5362
width: auto;
5463
}

src/LIN3S/AdminBundle/Resources/private/scss/components/_form-collection.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ $form-collection-item-toggle-icon-color: $color-mercury !default;
6969
.form-collection__footer {
7070
border-top: 1px solid $form-collection-footer-border-color;
7171
order: 3;
72-
padding: 15px;
72+
padding-bottom: 15px;
73+
padding-top: 15px;
7374
text-align: right;
7475
}
7576

0 commit comments

Comments
 (0)