Skip to content

Commit 53ba5b7

Browse files
committed
Removed jQuery and replaced axios with fetch
1 parent b532ed0 commit 53ba5b7

13 files changed

Lines changed: 192 additions & 167 deletions

File tree

package-lock.json

Lines changed: 2 additions & 40 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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@
2121
"webpack-cli": "^3.3.2"
2222
},
2323
"dependencies": {
24-
"axios": "^0.19.0",
2524
"clipboard": "^2.0.4",
2625
"codemirror": "^5.47.0",
2726
"dropzone": "^5.5.1",
28-
"jquery": "^3.4.1",
2927
"markdown-it": "^8.4.2",
3028
"markdown-it-task-lists": "^2.1.1",
3129
"sortablejs": "^1.9.0",

readme.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,9 @@ The great people that have worked to build and improve BookStack can [be seen he
137137
These are the great open-source projects used to help build BookStack:
138138

139139
* [Laravel](http://laravel.com/)
140-
* [jQuery](https://jquery.com/)
141140
* [TinyMCE](https://www.tinymce.com/)
142141
* [CodeMirror](https://codemirror.net)
143142
* [Vue.js](http://vuejs.org/)
144-
* [Axios](https://github.com/mzabriskie/axios)
145143
* [Sortable](https://github.com/SortableJS/Sortable) & [Vue.Draggable](https://github.com/SortableJS/Vue.Draggable)
146144
* [Google Material Icons](https://material.io/icons/)
147145
* [Dropzone.js](http://www.dropzonejs.com/)

resources/assets/js/components/breadcrumb-listing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class BreadcrumbListing {
6060
'entity_type': this.entityType,
6161
};
6262

63-
window.$http.get('/search/entity/siblings', {params}).then(resp => {
63+
window.$http.get('/search/entity/siblings', params).then(resp => {
6464
this.entityListElem.innerHTML = resp.data;
6565
}).catch(err => {
6666
console.error(err);

resources/assets/js/components/page-comments.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import MarkdownIt from "markdown-it";
2+
import {scrollAndHighlightElement} from "../services/util";
3+
24
const md = new MarkdownIt({ html: false });
35

46
class PageComments {
@@ -25,8 +27,8 @@ class PageComments {
2527
handleAction(event) {
2628
let actionElem = event.target.closest('[action]');
2729
if (event.target.matches('a[href^="#"]')) {
28-
let id = event.target.href.split('#')[1];
29-
window.scrollAndHighlight(document.querySelector('#' + id));
30+
const id = event.target.href.split('#')[1];
31+
scrollAndHighlightElement(document.querySelector('#' + id));
3032
}
3133
if (actionElem === null) return;
3234
event.preventDefault();
@@ -132,7 +134,7 @@ class PageComments {
132134
this.formContainer.parentNode.style.display = 'block';
133135
this.elem.querySelector('[comment-add-button-container]').style.display = 'none';
134136
this.formInput.focus();
135-
window.scrollToElement(this.formInput);
137+
this.formInput.scrollIntoView({behavior: "smooth"});
136138
}
137139

138140
hideForm() {

resources/assets/js/components/page-display.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Clipboard from "clipboard/dist/clipboard.min";
22
import Code from "../services/code";
33
import * as DOM from "../services/dom";
4+
import {scrollAndHighlightElement} from "../services/util";
45

56
class PageDisplay {
67

@@ -20,10 +21,12 @@ class PageDisplay {
2021

2122
// Sidebar page nav click event
2223
const sidebarPageNav = document.querySelector('.sidebar-page-nav');
23-
DOM.onChildEvent(sidebarPageNav, 'a', 'click', (event, child) => {
24-
window.components['tri-layout'][0].showContent();
25-
this.goToText(child.getAttribute('href').substr(1));
26-
});
24+
if (sidebarPageNav) {
25+
DOM.onChildEvent(sidebarPageNav, 'a', 'click', (event, child) => {
26+
window.components['tri-layout'][0].showContent();
27+
this.goToText(child.getAttribute('href').substr(1));
28+
});
29+
}
2730
}
2831

2932
goToText(text) {
@@ -35,11 +38,11 @@ class PageDisplay {
3538
});
3639

3740
if (idElem !== null) {
38-
window.scrollAndHighlight(idElem);
41+
scrollAndHighlightElement(idElem);
3942
} else {
4043
const textElem = DOM.findText('.page-content > div > *', text);
4144
if (textElem) {
42-
window.scrollAndHighlight(textElem);
45+
scrollAndHighlightElement(textElem);
4346
}
4447
}
4548
}

resources/assets/js/index.js

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Global Polyfills
2-
import "./services/dom-polyfills"
3-
41
// Url retrieval function
52
window.baseUrl = function(path) {
63
let basePath = document.querySelector('meta[name="base-url"]').getAttribute('content');
@@ -11,27 +8,24 @@ window.baseUrl = function(path) {
118

129
// Set events and http services on window
1310
import Events from "./services/events"
14-
import Http from "./services/http"
15-
let httpInstance = Http();
11+
import httpInstance from "./services/http"
12+
const eventManager = new Events();
1613
window.$http = httpInstance;
17-
window.$events = new Events();
14+
window.$events = eventManager;
1815

1916
// Translation setup
2017
// Creates a global function with name 'trans' to be used in the same way as Laravel's translation system
2118
import Translations from "./services/translations"
22-
let translator = new Translations(window.translations);
19+
const translator = new Translations(window.translations);
2320
window.trans = translator.get.bind(translator);
2421
window.trans_choice = translator.getPlural.bind(translator);
2522

26-
// Load in global UI helpers and libraries including jQuery
27-
import "./services/global-ui"
28-
29-
// Set services on Vue
23+
// Make services available to Vue instances
3024
import Vue from "vue"
3125
Vue.prototype.$http = httpInstance;
32-
Vue.prototype.$events = window.$events;
26+
Vue.prototype.$events = eventManager;
3327

34-
// Load vues and components
28+
// Load Vues and components
3529
import vues from "./vues/vues"
3630
import components from "./components"
3731
vues();

resources/assets/js/services/dom-polyfills.js

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

resources/assets/js/services/global-ui.js

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

0 commit comments

Comments
 (0)