mirror of
https://github.com/docsifyjs/docsify.git
synced 2025-12-08 19:55:52 +00:00
* UPDATE .eslintrc * UPDATE lint task * FIX lint errors * CLEANUP * FIX no-eq-null warning * FIX many jsdoc warnings * FIX jsdoc issues * FIX jsdoc warnings * FIX jsdoc * FIX eqeq and no-eq-null * ADD lint to travis * UPDATE test env for eslint
45 lines
1.0 KiB
JavaScript
45 lines
1.0 KiB
JavaScript
import { initMixin } from './init'
|
|
import { routerMixin } from './router'
|
|
import { renderMixin } from './render'
|
|
import { fetchMixin } from './fetch'
|
|
import { eventMixin } from './event'
|
|
import initGlobalAPI from './global-api'
|
|
|
|
/**
|
|
* Fork https://github.com/bendrucker/document-ready/blob/master/index.js
|
|
* @param {Function} callback The callbacack to be called when the page is loaded
|
|
* @returns {Number|void} If the page is already laoded returns the result of the setTimeout callback,
|
|
* otherwise it only attaches the callback to the DOMContentLoaded event
|
|
*/
|
|
function ready(callback) {
|
|
const state = document.readyState
|
|
|
|
if (state === 'complete' || state === 'interactive') {
|
|
return setTimeout(callback, 0)
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', callback)
|
|
}
|
|
|
|
function Docsify() {
|
|
this._init()
|
|
}
|
|
|
|
const proto = Docsify.prototype
|
|
|
|
initMixin(proto)
|
|
routerMixin(proto)
|
|
renderMixin(proto)
|
|
fetchMixin(proto)
|
|
eventMixin(proto)
|
|
|
|
/**
|
|
* Global API
|
|
*/
|
|
initGlobalAPI()
|
|
|
|
/**
|
|
* Run Docsify
|
|
*/
|
|
ready(_ => new Docsify())
|