nav tabs on admin dashboard

This commit is contained in:
2019-03-07 00:20:34 -06:00
parent f73d6ae228
commit e4f473f376
11661 changed files with 216240 additions and 1544253 deletions
+33 -34
View File
@@ -2,17 +2,17 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var createInnerCallback = require("./createInnerCallback");
"use strict";
function startsWith(string, searchString) {
var stringLength = string.length;
var searchLength = searchString.length;
const stringLength = string.length;
const searchLength = searchString.length;
// early out if the search length is greater than the search string
if(searchLength > stringLength) {
return false;
}
var index = -1;
let index = -1;
while(++index < searchLength) {
if(string.charCodeAt(index) !== searchString.charCodeAt(index)) {
return false;
@@ -21,37 +21,36 @@ function startsWith(string, searchString) {
return true;
}
function AliasPlugin(source, options, target) {
this.source = source;
this.name = options.name;
this.alias = options.alias;
this.onlyModule = options.onlyModule;
this.target = target;
}
module.exports = AliasPlugin;
module.exports = class AliasPlugin {
constructor(source, options, target) {
this.source = source;
this.options = Array.isArray(options) ? options : [options];
this.target = target;
}
AliasPlugin.prototype.apply = function(resolver) {
var target = this.target;
var name = this.name;
var alias = this.alias;
var onlyModule = this.onlyModule;
resolver.plugin(this.source, function(request, callback) {
var innerRequest = request.request;
if(!innerRequest) return callback();
if(innerRequest === name || (!onlyModule && startsWith(innerRequest, name + "/"))) {
if(innerRequest !== alias && !startsWith(innerRequest, alias + "/")) {
var newRequestStr = alias + innerRequest.substr(name.length);
var obj = Object.assign({}, request, {
request: newRequestStr
});
return resolver.doResolve(target, obj, "aliased with mapping '" + name + "': '" + alias + "' to '" + newRequestStr + "'", createInnerCallback(function(err, result) {
if(arguments.length > 0) return callback(err, result);
apply(resolver) {
const target = resolver.ensureHook(this.target);
resolver.getHook(this.source).tapAsync("AliasPlugin", (request, resolveContext, callback) => {
const innerRequest = request.request || request.path;
if(!innerRequest) return callback();
for(const item of this.options) {
if(innerRequest === item.name || (!item.onlyModule && startsWith(innerRequest, item.name + "/"))) {
if(innerRequest !== item.alias && !startsWith(innerRequest, item.alias + "/")) {
const newRequestStr = item.alias + innerRequest.substr(item.name.length);
const obj = Object.assign({}, request, {
request: newRequestStr
});
return resolver.doResolve(target, obj, "aliased with mapping '" + item.name + "': '" + item.alias + "' to '" + newRequestStr + "'", resolveContext, (err, result) => {
if(err) return callback(err);
// don't allow other aliasing or raw request
callback(null, null);
}, callback));
// Don't allow other aliasing or raw request
if(result === undefined) return callback(null, null);
callback(null, result);
});
}
}
}
}
return callback();
});
return callback();
});
}
};