Skip to content

Commit fca2e7e

Browse files
committed
Remove jquery from project
1 parent 0b5695f commit fca2e7e

File tree

9 files changed

+250
-291
lines changed

9 files changed

+250
-291
lines changed

package-lock.json

Lines changed: 186 additions & 210 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"homepage": "https://github.com/npfoss/courseroad2#readme",
2828
"dependencies": {
2929
"axios": "^0.18.0",
30-
"jquery": "^3.3.1",
3130
"material-design-icons-iconfont": "^4.0.5",
3231
"moment": "^2.24.0",
3332
"typeface-roboto": "0.0.54",

src/components/Auth.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export default {
171171
} };
172172
return this.verify()
173173
.then(function (verifyResponse) {
174-
return !!params
174+
return params
175175
? axiosFunc(process.env.FIREROAD_URL + link, params, headerList)
176176
: axiosFunc(process.env.FIREROAD_URL + link, headerList);
177177
});

src/components/ClassInfo.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@
194194
</template>
195195

196196
<script>
197-
import $ from 'jquery';
198197
import SubjectScroll from '../components/SubjectScroll.vue';
199198
import ExpansionReqs from '../components/ExpansionReqs.vue';
200199
import colorMixin from './../mixins/colorMixin.js';
@@ -236,7 +235,7 @@ export default {
236235
},
237236
clickRelatedSubject: function (subject) {
238237
this.$emit('push-stack', subject.id);
239-
$('#cardBody').animate({ scrollTop: 0 });
238+
document.getElementById('cardBody').scrollTop = 0;
240239
},
241240
parseRequirements: function (requirements) {
242241
// TODO: a way to make this more ETU?
@@ -425,4 +424,7 @@ table td:first-child {
425424
padding-right: 1em;
426425
}
427426
427+
#cardBody {
428+
scroll-behavior: smooth;
429+
}
428430
</style>

src/components/ClassSearch.vue

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@
3030
@click="viewClassInfo(props)"
3131
>
3232
<td style="padding: 0px; white-space: nowrap; width: 30%;">
33-
<v-icon style="vertical-align: middle;">drag_indicator</v-icon>
34-
<span style="vertical-align: middle;"> {{props.item.subject_id}}</span>
33+
<v-icon style="vertical-align: middle;">
34+
drag_indicator
35+
</v-icon>
36+
<span style="vertical-align: middle;"> {{ props.item.subject_id }}</span>
37+
</td>
38+
<td style="padding: 2px 4px 2px 0px; width: 60%;">
39+
{{ props.item.title }}
3540
</td>
36-
<td style="padding: 2px 4px 2px 0px; width: 60%;">{{props.item.title}}</td>
3741
</tr>
3842
</v-hover>
3943
</template>
@@ -45,7 +49,6 @@
4549

4650
<script>
4751
import FilterSet from './FilterSet.vue';
48-
import $ from 'jquery';
4952
import Vue from 'vue';
5053
5154
export default {
@@ -244,9 +247,7 @@ export default {
244247
this.updateMenuStyle();
245248
246249
window.cookies = this.$cookies;
247-
$(window).resize(function () {
248-
this.updateMenuStyle();
249-
}.bind(this));
250+
window.addEventListener('resize', this.updateMenuStyle.bind(this));
250251
251252
if (this.$cookies.isKey('paginationRows')) {
252253
this.pagination.rowsPerPage = parseInt(this.$cookies.get('paginationRows'));
@@ -261,19 +262,17 @@ export default {
261262
isNew: true
262263
});
263264
},
265+
// Change search menu size based on existence of class info card
264266
updateMenuStyle: function () {
265267
const searchInputElem = document.getElementById('searchInputTF');
266268
const searchInputRect = searchInputElem.getBoundingClientRect();
267269
const searchMenuTop = searchInputRect.top + searchInputRect.height;
268-
const searchInput = $('#searchInputTF');
269-
const menuWidth = searchInput.outerWidth();
270-
const classInfoCard = $('#classInfoCard');
271-
let menuBottom;
272-
if (classInfoCard.length) {
273-
menuBottom = classInfoCard.position().top;
274-
} else {
275-
menuBottom = $(window).innerHeight();
276-
}
270+
const searchInput = document.getElementById('searchInputTF');
271+
const menuWidth = searchInput.offsetWidth;
272+
const classInfoCard = document.getElementById('classInfoCard');
273+
const menuBottom = classInfoCard
274+
? classInfoCard.getBoundingClientRect().top
275+
: window.innerHeight;
277276
const maxHeight = menuBottom - searchMenuTop - this.menuMargin;
278277
this.searchHeight = 'max-height: ' + maxHeight + 'px;width: ' + menuWidth + 'px;';
279278
},

src/components/ExpansionReqs.vue

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646

4747
<script>
4848
import SubjectScroll from '../components/SubjectScroll.vue';
49-
import $ from 'jquery';
5049
import Vue from 'vue';
5150
5251
export default {
@@ -93,12 +92,12 @@ export default {
9392
this.expansionIndex = subj.index;
9493
this.open = true;
9594
this.nextReqs = nextReqs;
96-
Vue.nextTick(function () {
97-
const scrollPoint = $('#' + $.escapeSelector(scrollPointID));
98-
const topPoint = scrollPoint.offset().top;
99-
const cardBody = $('#cardBody');
100-
cardBody.animate({ scrollTop: topPoint - cardBody.offset().top + cardBody.scrollTop() - 10 }, 200);
101-
});
95+
// Vue.nextTick(function () {
96+
// const scrollPoint = $('#' + $.escapeSelector(scrollPointID));
97+
// const topPoint = scrollPoint.offset().top;
98+
// const cardBody = $('#cardBody');
99+
// cardBody.animate({ scrollTop: topPoint - cardBody.offset().top + cardBody.scrollTop() - 10 }, 200);
100+
// });
102101
} else {
103102
if (subj.id.indexOf('GIR:') >= 0) {
104103
subj.id = subj.id.substring(4);
@@ -111,15 +110,15 @@ export default {
111110
},
112111
closeMyExpansion: function (event) {
113112
this.open = false;
114-
let scrollPoint;
115-
if (!this.doubleScroller) {
116-
scrollPoint = $('#' + $.escapeSelector(this.reqID));
117-
} else {
118-
scrollPoint = $('#ds' + this.whichScroller + $.escapeSelector(this.reqID));
119-
}
120-
const topPoint = scrollPoint.offset().top;
121-
const cardBody = $('#cardBody');
122-
cardBody.animate({ scrollTop: topPoint - cardBody.offset().top + cardBody.scrollTop() - 10 }, 350);
113+
// let scrollPoint;
114+
// if (!this.doubleScroller) {
115+
// scrollPoint = $('#' + $.escapeSelector(this.reqID));
116+
// } else {
117+
// scrollPoint = $('#ds' + this.whichScroller + $.escapeSelector(this.reqID));
118+
// }
119+
// const topPoint = scrollPoint.offset().top;
120+
// const cardBody = $('#cardBody');
121+
// cardBody.animate({ scrollTop: topPoint - cardBody.offset().top + cardBody.scrollTop() - 10 }, 350);
123122
}
124123
}
125124
};

src/components/Requirement.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<span v-if="'title-no-degree' in req && req['title-no-degree'] !=''">
1313
{{ req["title-no-degree"] }}
1414
</span>
15-
<span v-else-if = "'medium-title' in req && req['medium-title'] != ''">{{ req['medium-title']}}</span>
15+
<span v-else-if="'medium-title' in req && req['medium-title'] != ''">{{ req['medium-title'] }}</span>
1616
<span v-else-if="'short-title' in req && req['short-title'] != ''">
1717
{{ req['short-title'] }}
1818
</span>

src/components/Semester.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ export default {
239239
},
240240
semesterYear: function () {
241241
return this.index === 0
242-
? ''
242+
? ''
243243
: Math.floor((this.index - 2) / 3) + this.baseYear;
244244
},
245245
semesterType: function () {
@@ -303,7 +303,7 @@ export default {
303303
const allIDs = subjects.map((s) => s.id);
304304
reqString = reqString.replace(/''/g, '"').replace(/,[\s]+/g, ',');
305305
const splitReq = reqString.split(/(,|\(|\)|\/)/);
306-
const _this = this
306+
const _this = this;
307307
for (let i = 0; i < splitReq.length; i++) {
308308
if (splitReq[i].indexOf('"') >= 0) {
309309
splitReq[i] = 'true';

src/pages/MainPage.vue

Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -68,29 +68,28 @@
6868
@reset-id="resetID(...arguments)"
6969
@allow-cookies="allowCookies"
7070
@set-sem="setSemester"
71-
>
72-
</auth>
71+
/>
7372

7473
<v-layout justify-end>
7574
<v-text-field
76-
id = "searchInputTF"
77-
autocomplete = "false"
78-
class = "expanded-search"
75+
id="searchInputTF"
76+
v-model="searchInput"
77+
autocomplete="false"
78+
class="expanded-search"
7979
prepend-icon="search"
80-
v-model = "searchInput"
81-
placeholder = "Add classes"
80+
placeholder="Add classes"
8281
autofocus
83-
@click.native = "clickSearch"
84-
@input = "typeSearch"
85-
style = "width:100%;"
82+
style="width:100%;"
83+
@click.native="clickSearch"
84+
@input="typeSearch"
8685
/>
8786
</v-layout>
8887

8988
<v-menu
89+
v-model="searchOpen"
9090
:close-on-content-click="false"
91-
v-model = "searchOpen"
92-
:position-x = "searchX"
93-
:position-y = "searchY"
91+
:position-x="searchX"
92+
:position-y="searchY"
9493
>
9594
<class-search
9695
id="searchMenu"
@@ -106,7 +105,6 @@
106105
@drag-start-class="dragStartClass"
107106
/>
108107
</v-menu>
109-
110108
</v-toolbar>
111109

112110
<v-navigation-drawer
@@ -274,7 +272,6 @@ import RoadTabs from './../components/RoadTabs.vue';
274272
import ConflictDialog from './../components/ConflictDialog.vue';
275273
import Auth from './../components/Auth.vue';
276274
import axios from 'axios';
277-
import $ from 'jquery';
278275
import moment from 'moment';
279276
import UAParser from 'ua-parser-js';
280277
import Vue from 'vue';
@@ -393,23 +390,6 @@ export default {
393390
}
394391
},
395392
mounted () {
396-
const borders = $('.v-navigation-drawer__border');
397-
const scrollers = $('.scroller');
398-
const scrollWidth = scrollers.width();
399-
400-
// moves nav drawer border with scroll
401-
// if the effect proves too annoying we can remove the borders instead
402-
// (commented out below)
403-
404-
scrollers.scroll(function () {
405-
const scrollPosition = scrollers.scrollLeft();
406-
borders.css({ top: 0, left: scrollWidth - 1 + scrollPosition });
407-
});
408-
409-
$(window).on('hashchange', function () {
410-
this.setActiveRoad();
411-
}.bind(this));
412-
413393
this.setActiveRoad();
414394
415395
axios.get(process.env.FIREROAD_URL + `/requirements/list_reqs/`)
@@ -423,19 +403,23 @@ export default {
423403
424404
this.updateFulfillment();
425405
426-
this.searchX = $("#searchInputTF").offset().left;
427-
this.searchY = $("#searchInputTF").offset().top + $("#searchInputTF").outerHeight();
406+
const searchInput = document.getElementById('searchInputTF');
407+
const rect = searchInput.getBoundingClientRect();
408+
this.searchX = rect.left + document.body.scrollLeft;
409+
this.searchY = rect.top + document.body.scrollTop + searchInput.offsetHeight;
428410
429-
$(window).on("resize", function() {
430-
this.searchX = $("#searchInputTF").offset().left;
431-
this.searchY = $("#searchInputTF").offset().top + $("#searchInputTF").outerHeight();
411+
window.addEventListener('resize', function () {
412+
const searchInput = document.getElementById('searchInputTF');
413+
const rect = searchInput.getBoundingClientRect();
414+
this.searchX = rect.left + document.body.scrollLeft;
415+
this.searchY = rect.top + document.body.scrollTop + searchInput.offsetHeight;
432416
}.bind(this));
433417
434418
document.body.addEventListener('click', function (e) {
435419
this.showSearch = false;
436420
}.bind(this));
437421
438-
if(this.$cookies.isKey('dismissedOld')) {
422+
if (this.$cookies.isKey('dismissedOld')) {
439423
this.dismissedOld = JSON.parse(this.$cookies.get('dismissedOld'));
440424
this.cookiesAllowed = true;
441425
}
@@ -710,22 +694,22 @@ export default {
710694
Vue.set(this.roads[this.activeRoad].contents.progressOverrides, newProgress.listID, newProgress.progress);
711695
Vue.set(this.roads[this.activeRoad], 'changed', moment().format(DATE_FORMAT));
712696
},
713-
dismissOld: function() {
697+
dismissOld: function () {
714698
this.dismissedOld = true;
715-
if(this.cookiesAllowed) {
699+
if (this.cookiesAllowed) {
716700
this.$cookies.set('dismissedOld', true);
717701
}
718702
},
719703
dismissCookies: function() {
720704
this.dismissedCookies = true;
721-
if(this.cookiesAllowed) {
705+
if (this.cookiesAllowed) {
722706
this.$cookies.set('dismissedCookies', true);
723707
}
724708
},
725709
clickSearch: function(event) {
726710
this.searchOpen = !this.searchOpen;
727711
},
728-
typeSearch: function(searchString) {
712+
typeSearch: function (searchString) {
729713
this.searchOpen = searchString.length > 0;
730714
}
731715
}

0 commit comments

Comments
 (0)