Skip to content

Commit

Permalink
feat: LoadingBar as a Quasar plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoenescu committed Jul 12, 2018
1 parent 94f9889 commit a8f4526
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import AppFullscreen from './plugins/app-fullscreen.js'
import AppVisibility from './plugins/app-visibility.js'
import Cookies from './plugins/cookies.js'
import Dialog from './plugins/dialog.js'
import LoadingBar from './plugins/loading-bar.js'
import Loading from './plugins/loading.js'
import Notify from './plugins/notify.js'
import Platform from './plugins/platform.js'
Expand All @@ -18,6 +19,7 @@ export {
AppVisibility,
Cookies,
Dialog,
LoadingBar,
Loading,
Notify,
Platform,
Expand Down
30 changes: 30 additions & 0 deletions src/plugins/loading-bar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { isSSR } from './platform.js'
import QAjaxBar from '../components/ajax-bar/QAjaxBar.js'

export default {
start () {},
stop () {},
increment () {},

install ({ $q, Vue, cfg }) {
if (isSSR) {
$q.loadingBar = this
return
}

const bar = $q.loadingBar = new Vue({
render: h => h(QAjaxBar, {
ref: 'bar',
props: cfg.loadingBar
})
}).$mount().$refs.bar

Object.assign(this, {
start: bar.start,
stop: bar.stop,
increment: bar.increment
})

document.body.appendChild($q.loadingBar.$parent.$el)
}
}

0 comments on commit a8f4526

Please sign in to comment.