mirror of
https://bitbucket.org/bellord13/kit.git
synced 2026-11-13 19:06:11 +03:00
fix
This commit is contained in:
@@ -848,6 +848,34 @@ kit.config = kit.config || {};
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
/**
|
||||
* @param {(string|string[])} deps
|
||||
* @param {function} callback
|
||||
* @memberOf kit
|
||||
*/
|
||||
|
||||
PluginManager.prototype.loaded = function(deps, callback = undefined) {
|
||||
var self = this;
|
||||
if(typeof deps === 'function') {
|
||||
callback = deps;
|
||||
deps = [];
|
||||
}
|
||||
if(typeof callback !== 'function') {
|
||||
callback = function (){};
|
||||
}
|
||||
self.__loaded(self.exec, [deps, callback], self);
|
||||
};
|
||||
PluginManager.prototype.__loaded = function(fn, args = [], context = window) {
|
||||
var self = this;
|
||||
context = context || this;
|
||||
if (/complete|interactive|loaded/.test(document.readyState)) {
|
||||
fn.apply(context, args);
|
||||
} else {
|
||||
window.addEventListener("load", function () {
|
||||
fn.apply(context, args);
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
PluginManager.prototype.require = function (pluginId, callback) {
|
||||
|
||||
@@ -885,6 +913,7 @@ kit.config = kit.config || {};
|
||||
|
||||
var manager = new PluginManager(global);
|
||||
global.ready = manager.ready.bind(manager);
|
||||
global.loaded = manager.loaded.bind(manager);
|
||||
global.exec = manager.exec.bind(manager);
|
||||
global.require = manager.require.bind(manager);
|
||||
manager.register('pluginManager', {
|
||||
@@ -932,6 +961,9 @@ kit.config = kit.config || {};
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
console.log('%cDOMContentLoaded', 'color:#2053ff');
|
||||
});
|
||||
window.addEventListener("load", (event) => {
|
||||
console.log('%cWindowLoaded', 'color:#2053ff');
|
||||
});
|
||||
}());
|
||||
},
|
||||
onInstall: function(plugin){
|
||||
|
||||
Reference in New Issue
Block a user