Best JavaScript code snippet using best
ocLazyLoad.core.js
Source:ocLazyLoad.core.js
1(function (angular, window) {2 'use strict';3 var regModules = ['ng', 'oc.lazyLoad'],4 regInvokes = {},5 regConfigs = [],6 modulesToLoad = [],7 // modules to load from angular.module or other sources8 realModules = [],9 // real modules called from angular.module10 recordDeclarations = [],11 broadcast = angular.noop,12 runBlocks = {},13 justLoaded = [];14 var ocLazyLoad = angular.module('oc.lazyLoad', ['ng']);15 ocLazyLoad.provider('$ocLazyLoad', ["$controllerProvider", "$provide", "$compileProvider", "$filterProvider", "$injector", "$animateProvider", function ($controllerProvider, $provide, $compileProvider, $filterProvider, $injector, $animateProvider) {16 var modules = {},17 providers = {18 $controllerProvider: $controllerProvider,19 $compileProvider: $compileProvider,20 $filterProvider: $filterProvider,21 $provide: $provide, // other things (constant, decorator, provider, factory, service)22 $injector: $injector,23 $animateProvider: $animateProvider24 },25 debug = false,26 events = false,27 moduleCache = [],28 modulePromises = {};29 moduleCache.push = function (value) {30 if (this.indexOf(value) === -1) {31 Array.prototype.push.apply(this, arguments);32 }33 };34 this.config = function (config) {35 // If we want to define modules configs36 if (angular.isDefined(config.modules)) {37 if (angular.isArray(config.modules)) {38 angular.forEach(config.modules, function (moduleConfig) {39 modules[moduleConfig.name] = moduleConfig;40 });41 } else {42 modules[config.modules.name] = config.modules;43 }44 }45 if (angular.isDefined(config.debug)) {46 debug = config.debug;47 }48 if (angular.isDefined(config.events)) {49 events = config.events;50 }51 };52 /**53 * Get the list of existing registered modules54 * @param element55 */56 this._init = function _init(element) {57 // this is probably useless now because we override angular.bootstrap58 if (modulesToLoad.length === 0) {59 var elements = [element],60 names = ['ng:app', 'ng-app', 'x-ng-app', 'data-ng-app'],61 NG_APP_CLASS_REGEXP = /\sng[:\-]app(:\s*([\w\d_]+);?)?\s/,62 append = function append(elm) {63 return elm && elements.push(elm);64 };65 angular.forEach(names, function (name) {66 names[name] = true;67 append(document.getElementById(name));68 name = name.replace(':', '\\:');69 if (typeof element[0] !== 'undefined' && element[0].querySelectorAll) {70 angular.forEach(element[0].querySelectorAll('.' + name), append);71 angular.forEach(element[0].querySelectorAll('.' + name + '\\:'), append);72 angular.forEach(element[0].querySelectorAll('[' + name + ']'), append);73 }74 });75 angular.forEach(elements, function (elm) {76 if (modulesToLoad.length === 0) {77 var className = ' ' + element.className + ' ';78 var match = NG_APP_CLASS_REGEXP.exec(className);79 if (match) {80 modulesToLoad.push((match[2] || '').replace(/\s+/g, ','));81 } else {82 angular.forEach(elm.attributes, function (attr) {83 if (modulesToLoad.length === 0 && names[attr.name]) {84 modulesToLoad.push(attr.value);85 }86 });87 }88 }89 });90 }91 if (modulesToLoad.length === 0 && !((window.jasmine || window.mocha) && angular.isDefined(angular.mock))) {92 console.error('No module found during bootstrap, unable to init ocLazyLoad. You should always use the ng-app directive or angular.boostrap when you use ocLazyLoad.');93 }94 var addReg = function addReg(moduleName) {95 if (regModules.indexOf(moduleName) === -1) {96 // register existing modules97 regModules.push(moduleName);98 var mainModule = angular.module(moduleName);99 // register existing components (directives, services, ...)100 _invokeQueue(null, mainModule._invokeQueue, moduleName);101 _invokeQueue(null, mainModule._configBlocks, moduleName); // angular 1.3+102 angular.forEach(mainModule.requires, addReg);103 }104 };105 angular.forEach(modulesToLoad, function (moduleName) {106 addReg(moduleName);107 });108 modulesToLoad = []; // reset for next bootstrap109 recordDeclarations.pop(); // wait for the next lazy load110 };111 /**112 * Like JSON.stringify but that doesn't throw on circular references113 * @param obj114 */115 var stringify = function stringify(obj) {116 try {117 return JSON.stringify(obj);118 } catch (e) {119 var cache = [];120 return JSON.stringify(obj, function (key, value) {121 if (angular.isObject(value) && value !== null) {122 if (cache.indexOf(value) !== -1) {123 // Circular reference found, discard key124 return;125 }126 // Store value in our collection127 cache.push(value);128 }129 return value;130 });131 }132 };133 var hashCode = function hashCode(str) {134 var hash = 0,135 i,136 chr,137 len;138 if (str.length == 0) {139 return hash;140 }141 for (i = 0, len = str.length; i < len; i++) {142 chr = str.charCodeAt(i);143 hash = (hash << 5) - hash + chr;144 hash |= 0; // Convert to 32bit integer145 }146 return hash;147 };148 function _register(providers, registerModules, params) {149 if (registerModules) {150 var k,151 moduleName,152 moduleFn,153 tempRunBlocks = [];154 for (k = registerModules.length - 1; k >= 0; k--) {155 moduleName = registerModules[k];156 if (!angular.isString(moduleName)) {157 moduleName = getModuleName(moduleName);158 }159 if (!moduleName || justLoaded.indexOf(moduleName) !== -1 || modules[moduleName] && realModules.indexOf(moduleName) === -1) {160 continue;161 }162 // new if not registered163 var newModule = regModules.indexOf(moduleName) === -1;164 moduleFn = ngModuleFct(moduleName);165 if (newModule) {166 regModules.push(moduleName);167 _register(providers, moduleFn.requires, params);168 }169 if (moduleFn._runBlocks.length > 0) {170 // new run blocks detected! Replace the old ones (if existing)171 runBlocks[moduleName] = [];172 while (moduleFn._runBlocks.length > 0) {173 runBlocks[moduleName].push(moduleFn._runBlocks.shift());174 }175 }176 if (angular.isDefined(runBlocks[moduleName]) && (newModule || params.rerun)) {177 tempRunBlocks = tempRunBlocks.concat(runBlocks[moduleName]);178 }179 _invokeQueue(providers, moduleFn._invokeQueue, moduleName, params.reconfig);180 _invokeQueue(providers, moduleFn._configBlocks, moduleName, params.reconfig); // angular 1.3+181 broadcast(newModule ? 'ocLazyLoad.moduleLoaded' : 'ocLazyLoad.moduleReloaded', moduleName);182 registerModules.pop();183 justLoaded.push(moduleName);184 }185 // execute the run blocks at the end186 var instanceInjector = providers.getInstanceInjector();187 angular.forEach(tempRunBlocks, function (fn) {188 instanceInjector.invoke(fn);189 });190 }191 }192 function _registerInvokeList(args, moduleName) {193 var invokeList = args[2][0],194 type = args[1],195 newInvoke = false;196 if (angular.isUndefined(regInvokes[moduleName])) {197 regInvokes[moduleName] = {};198 }199 if (angular.isUndefined(regInvokes[moduleName][type])) {200 regInvokes[moduleName][type] = {};201 }202 var onInvoke = function onInvoke(invokeName, invoke) {203 if (!regInvokes[moduleName][type].hasOwnProperty(invokeName)) {204 regInvokes[moduleName][type][invokeName] = [];205 }206 if (checkHashes(invoke, regInvokes[moduleName][type][invokeName])) {207 newInvoke = true;208 regInvokes[moduleName][type][invokeName].push(invoke);209 broadcast('ocLazyLoad.componentLoaded', [moduleName, type, invokeName]);210 }211 };212 function checkHashes(potentialNew, invokes) {213 var isNew = true,214 newHash;215 if (invokes.length) {216 newHash = signature(potentialNew);217 angular.forEach(invokes, function (invoke) {218 isNew = isNew && signature(invoke) !== newHash;219 });220 }221 return isNew;222 }223 function signature(data) {224 if (angular.isArray(data)) {225 // arrays are objects, we need to test for it first226 return hashCode(data.toString());227 } else if (angular.isObject(data)) {228 // constants & values for example229 return hashCode(stringify(data));230 } else {231 if (angular.isDefined(data) && data !== null) {232 return hashCode(data.toString());233 } else {234 // null & undefined constants235 return data;236 }237 }238 }239 if (angular.isString(invokeList)) {240 onInvoke(invokeList, args[2][1]);241 } else if (angular.isObject(invokeList)) {242 angular.forEach(invokeList, function (invoke, key) {243 if (angular.isString(invoke)) {244 // decorators for example245 onInvoke(invoke, invokeList[1]);246 } else {247 // components registered as object lists {"componentName": function() {}}248 onInvoke(key, invoke);249 }250 });251 } else {252 return false;253 }254 return newInvoke;255 }256 function _invokeQueue(providers, queue, moduleName, reconfig) {257 if (!queue) {258 return;259 }260 var i, len, args, provider;261 for (i = 0, len = queue.length; i < len; i++) {262 args = queue[i];263 if (angular.isArray(args)) {264 if (providers !== null) {265 if (providers.hasOwnProperty(args[0])) {266 provider = providers[args[0]];267 } else {268 throw new Error('unsupported provider ' + args[0]);269 }270 }271 var isNew = _registerInvokeList(args, moduleName);272 if (args[1] !== 'invoke') {273 if (isNew && angular.isDefined(provider)) {274 provider[args[1]].apply(provider, args[2]);275 }276 } else {277 // config block278 var callInvoke = function callInvoke(fct) {279 var invoked = regConfigs.indexOf(moduleName + '-' + fct);280 if (invoked === -1 || reconfig) {281 if (invoked === -1) {282 regConfigs.push(moduleName + '-' + fct);283 }284 if (angular.isDefined(provider)) {285 provider[args[1]].apply(provider, args[2]);286 }287 }288 };289 if (angular.isFunction(args[2][0])) {290 callInvoke(args[2][0]);291 } else if (angular.isArray(args[2][0])) {292 for (var j = 0, jlen = args[2][0].length; j < jlen; j++) {293 if (angular.isFunction(args[2][0][j])) {294 callInvoke(args[2][0][j]);295 }296 }297 }298 }299 }300 }301 }302 function getModuleName(module) {303 var moduleName = null;304 if (angular.isString(module)) {305 moduleName = module;306 } else if (angular.isObject(module) && module.hasOwnProperty('name') && angular.isString(module.name)) {307 moduleName = module.name;308 }309 return moduleName;310 }311 function moduleExists(moduleName) {312 if (!angular.isString(moduleName)) {313 return false;314 }315 try {316 return ngModuleFct(moduleName);317 } catch (e) {318 if (/No module/.test(e) || e.message.indexOf('$injector:nomod') > -1) {319 return false;320 }321 }322 }323 this.$get = ["$log", "$rootElement", "$rootScope", "$cacheFactory", "$q", function ($log, $rootElement, $rootScope, $cacheFactory, $q) {324 var instanceInjector,325 filesCache = $cacheFactory('ocLazyLoad');326 if (!debug) {327 $log = {};328 $log['error'] = angular.noop;329 $log['warn'] = angular.noop;330 $log['info'] = angular.noop;331 }332 // Make this lazy because when $get() is called the instance injector hasn't been assigned to the rootElement yet333 providers.getInstanceInjector = function () {334 return instanceInjector ? instanceInjector : instanceInjector = $rootElement.data('$injector') || angular.injector();335 };336 broadcast = function broadcast(eventName, params) {337 if (events) {338 $rootScope.$broadcast(eventName, params);339 }340 if (debug) {341 $log.info(eventName, params);342 }343 };344 function reject(e) {345 var deferred = $q.defer();346 $log.error(e.message);347 deferred.reject(e);348 return deferred.promise;349 }350 return {351 _broadcast: broadcast,352 _$log: $log,353 /**354 * Returns the files cache used by the loaders to store the files currently loading355 * @returns {*}356 */357 _getFilesCache: function getFilesCache() {358 return filesCache;359 },360 /**361 * Let the service know that it should monitor angular.module because files are loading362 * @param watch boolean363 */364 toggleWatch: function toggleWatch(watch) {365 if (watch) {366 recordDeclarations.push(true);367 } else {368 recordDeclarations.pop();369 }370 },371 /**372 * Let you get a module config object373 * @param moduleName String the name of the module374 * @returns {*}375 */376 getModuleConfig: function getModuleConfig(moduleName) {377 if (!angular.isString(moduleName)) {378 throw new Error('You need to give the name of the module to get');379 }380 if (!modules[moduleName]) {381 return null;382 }383 return angular.copy(modules[moduleName]);384 },385 /**386 * Let you define a module config object387 * @param moduleConfig Object the module config object388 * @returns {*}389 */390 setModuleConfig: function setModuleConfig(moduleConfig) {391 if (!angular.isObject(moduleConfig)) {392 throw new Error('You need to give the module config object to set');393 }394 modules[moduleConfig.name] = moduleConfig;395 return moduleConfig;396 },397 /**398 * Returns the list of loaded modules399 * @returns {string[]}400 */401 getModules: function getModules() {402 return regModules;403 },404 /**405 * Let you check if a module has been loaded into Angular or not406 * @param modulesNames String/Object a module name, or a list of module names407 * @returns {boolean}408 */409 isLoaded: function isLoaded(modulesNames) {410 var moduleLoaded = function moduleLoaded(module) {411 var isLoaded = regModules.indexOf(module) > -1;412 if (!isLoaded) {413 isLoaded = !!moduleExists(module);414 }415 return isLoaded;416 };417 if (angular.isString(modulesNames)) {418 modulesNames = [modulesNames];419 }420 if (angular.isArray(modulesNames)) {421 var i, len;422 for (i = 0, len = modulesNames.length; i < len; i++) {423 if (!moduleLoaded(modulesNames[i])) {424 return false;425 }426 }427 return true;428 } else {429 throw new Error('You need to define the module(s) name(s)');430 }431 },432 /**433 * Given a module, return its name434 * @param module435 * @returns {String}436 */437 _getModuleName: getModuleName,438 /**439 * Returns a module if it exists440 * @param moduleName441 * @returns {module}442 */443 _getModule: function getModule(moduleName) {444 try {445 return ngModuleFct(moduleName);446 } catch (e) {447 // this error message really suxx448 if (/No module/.test(e) || e.message.indexOf('$injector:nomod') > -1) {449 e.message = 'The module "' + stringify(moduleName) + '" that you are trying to load does not exist. ' + e.message;450 }451 throw e;452 }453 },454 /**455 * Check if a module exists and returns it if it does456 * @param moduleName457 * @returns {boolean}458 */459 moduleExists: moduleExists,460 /**461 * Load the dependencies, and might try to load new files depending on the config462 * @param moduleName (String or Array of Strings)463 * @param localParams464 * @returns {*}465 * @private466 */467 _loadDependencies: function _loadDependencies(moduleName, localParams) {468 var loadedModule,469 requires,470 diff,471 promisesList = [],472 self = this;473 moduleName = self._getModuleName(moduleName);474 if (moduleName === null) {475 return $q.when();476 } else {477 try {478 loadedModule = self._getModule(moduleName);479 } catch (e) {480 return reject(e);481 }482 // get unloaded requires483 requires = self.getRequires(loadedModule);484 }485 angular.forEach(requires, function (requireEntry) {486 // If no configuration is provided, try and find one from a previous load.487 // If there isn't one, bail and let the normal flow run488 if (angular.isString(requireEntry)) {489 var config = self.getModuleConfig(requireEntry);490 if (config === null) {491 moduleCache.push(requireEntry); // We don't know about this module, but something else might, so push it anyway.492 return;493 }494 requireEntry = config;495 // ignore the name because it's probably not a real module name496 config.name = undefined;497 }498 // Check if this dependency has been loaded previously499 if (self.moduleExists(requireEntry.name)) {500 // compare against the already loaded module to see if the new definition adds any new files501 diff = requireEntry.files.filter(function (n) {502 return self.getModuleConfig(requireEntry.name).files.indexOf(n) < 0;503 });504 // If the module was redefined, advise via the console505 if (diff.length !== 0) {506 self._$log.warn('Module "', moduleName, '" attempted to redefine configuration for dependency. "', requireEntry.name, '"\n Additional Files Loaded:', diff);507 }508 // Push everything to the file loader, it will weed out the duplicates.509 if (angular.isDefined(self.filesLoader)) {510 // if a files loader is defined511 promisesList.push(self.filesLoader(requireEntry, localParams).then(function () {512 return self._loadDependencies(requireEntry);513 }));514 } else {515 return reject(new Error('Error: New dependencies need to be loaded from external files (' + requireEntry.files + '), but no loader has been defined.'));516 }517 return;518 } else if (angular.isArray(requireEntry)) {519 var files = [];520 angular.forEach(requireEntry, function (entry) {521 // let's check if the entry is a file name or a config name522 var config = self.getModuleConfig(entry);523 if (config === null) {524 files.push(entry);525 } else if (config.files) {526 files = files.concat(config.files);527 }528 });529 if (files.length > 0) {530 requireEntry = {531 files: files532 };533 }534 } else if (angular.isObject(requireEntry)) {535 if (requireEntry.hasOwnProperty('name') && requireEntry['name']) {536 // The dependency doesn't exist in the module cache and is a new configuration, so store and push it.537 self.setModuleConfig(requireEntry);538 moduleCache.push(requireEntry['name']);539 }540 }541 // Check if the dependency has any files that need to be loaded. If there are, push a new promise to the promise list.542 if (angular.isDefined(requireEntry.files) && requireEntry.files.length !== 0) {543 if (angular.isDefined(self.filesLoader)) {544 // if a files loader is defined545 promisesList.push(self.filesLoader(requireEntry, localParams).then(function () {546 return self._loadDependencies(requireEntry);547 }));548 } else {549 return reject(new Error('Error: the module "' + requireEntry.name + '" is defined in external files (' + requireEntry.files + '), but no loader has been defined.'));550 }551 }552 });553 // Create a wrapper promise to watch the promise list and resolve it once everything is done.554 return $q.all(promisesList);555 },556 /**557 * Inject new modules into Angular558 * @param moduleName559 * @param localParams560 * @param real561 */562 inject: function inject(moduleName) {563 var localParams = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];564 var real = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2];565 var self = this,566 deferred = $q.defer();567 if (angular.isDefined(moduleName) && moduleName !== null) {568 if (angular.isArray(moduleName)) {569 var promisesList = [];570 angular.forEach(moduleName, function (module) {571 promisesList.push(self.inject(module, localParams, real));572 });573 return $q.all(promisesList);574 } else {575 self._addToLoadList(self._getModuleName(moduleName), true, real);576 }577 }578 if (modulesToLoad.length > 0) {579 var res = modulesToLoad.slice(); // clean copy580 var loadNext = function loadNext(moduleName) {581 moduleCache.push(moduleName);582 modulePromises[moduleName] = deferred.promise;583 self._loadDependencies(moduleName, localParams).then(function success() {584 try {585 justLoaded = [];586 _register(providers, moduleCache, localParams);587 } catch (e) {588 self._$log.error(e.message);589 deferred.reject(e);590 return;591 }592 if (modulesToLoad.length > 0) {593 loadNext(modulesToLoad.shift()); // load the next in list594 } else {595 deferred.resolve(res); // everything has been loaded, resolve596 }597 }, function error(err) {598 deferred.reject(err);599 });600 };601 // load the first in list602 loadNext(modulesToLoad.shift());603 } else if (localParams && localParams.name && modulePromises[localParams.name]) {604 return modulePromises[localParams.name];605 } else {606 deferred.resolve();607 }608 return deferred.promise;609 },610 /**611 * Get the list of required modules/services/... for this module612 * @param module613 * @returns {Array}614 */615 getRequires: function getRequires(module) {616 var requires = [];617 angular.forEach(module.requires, function (requireModule) {618 if (regModules.indexOf(requireModule) === -1) {619 requires.push(requireModule);620 }621 });622 return requires;623 },624 /**625 * Invoke the new modules & component by their providers626 * @param providers627 * @param queue628 * @param moduleName629 * @param reconfig630 * @private631 */632 _invokeQueue: _invokeQueue,633 /**634 * Check if a module has been invoked and registers it if not635 * @param args636 * @param moduleName637 * @returns {boolean} is new638 */639 _registerInvokeList: _registerInvokeList,640 /**641 * Register a new module and loads it, executing the run/config blocks if needed642 * @param providers643 * @param registerModules644 * @param params645 * @private646 */647 _register: _register,648 /**649 * Add a module name to the list of modules that will be loaded in the next inject650 * @param name651 * @param force652 * @private653 */654 _addToLoadList: _addToLoadList,655 /**656 * Unregister modules (you shouldn't have to use this)657 * @param modules658 */659 _unregister: function _unregister(modules) {660 if (angular.isDefined(modules)) {661 if (angular.isArray(modules)) {662 angular.forEach(modules, function (module) {663 regInvokes[module] = undefined;664 });665 }666 }667 }668 };669 }];670 // Let's get the list of loaded modules & components671 this._init(angular.element(window.document));672 }]);673 var bootstrapFct = angular.bootstrap;674 angular.bootstrap = function (element, modules, config) {675 // Clean state from previous bootstrap676 regModules = ['ng', 'oc.lazyLoad'];677 regInvokes = {};678 regConfigs = [];679 modulesToLoad = [];680 realModules = [];681 recordDeclarations = [];682 broadcast = angular.noop;683 runBlocks = {};684 justLoaded = [];685 // we use slice to make a clean copy686 angular.forEach(modules.slice(), function (module) {687 _addToLoadList(module, true, true);688 });689 return bootstrapFct(element, modules, config);690 };691 var _addToLoadList = function _addToLoadList(name, force, real) {692 if ((recordDeclarations.length > 0 || force) && angular.isString(name) && modulesToLoad.indexOf(name) === -1) {693 modulesToLoad.push(name);694 if (real) {695 realModules.push(name);696 }697 }698 };699 var ngModuleFct = angular.module;700 angular.module = function (name, requires, configFn) {701 _addToLoadList(name, false, true);702 return ngModuleFct(name, requires, configFn);703 };704 // CommonJS package manager support:705 if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.exports === exports) {706 module.exports = 'oc.lazyLoad';707 }...
sidebar-items.ts
Source:sidebar-items.ts
1import { RouteInfo } from './sidebar.metadata';2export const ROUTES: RouteInfo[] = [3 {4 path: '',5 title: 'MENUITEMS.MAIN.TEXT',6 moduleName: '',7 icon: '',8 class: 'header',9 groupTitle: true,10 submenu: []11 },12 {13 path: '',14 title: 'MENUITEMS.HOME.TEXT',15 moduleName: 'dashboard',16 icon: 'menu-icon ti-home',17 class: 'menu-toggle',18 groupTitle: false,19 submenu: [20 {21 path: '/dashboard/main',22 title: 'MENUITEMS.HOME.LIST.DASHBOARD1',23 moduleName: 'dashboard',24 icon: '',25 class: 'ml-menu',26 groupTitle: false,27 submenu: []28 },29 {30 path: '/dashboard/dashboard2',31 title: 'MENUITEMS.HOME.LIST.DASHBOARD2',32 moduleName: 'dashboard',33 icon: '',34 class: 'ml-menu',35 groupTitle: false,36 submenu: []37 },38 {39 path: '/dashboard/dashboard3',40 title: 'MENUITEMS.HOME.LIST.DASHBOARD3',41 moduleName: 'dashboard',42 icon: '',43 class: 'ml-menu',44 groupTitle: false,45 submenu: []46 }47 ]48 },49 {50 path: 'advance-table',51 title: 'MENUITEMS.ADVANCE-TABLE.TEXT',52 moduleName: 'advance-table',53 icon: 'menu-icon ti-layout',54 class: '',55 groupTitle: false,56 submenu: []57 },58 {59 path: '',60 title: 'MENUITEMS.APPS.TEXT',61 moduleName: '',62 icon: '',63 class: '',64 groupTitle: true,65 submenu: []66 },67 {68 path: 'calendar',69 title: 'MENUITEMS.CALENDAR.TEXT',70 moduleName: 'calendar',71 icon: 'menu-icon ti-calendar',72 class: '',73 groupTitle: false,74 submenu: []75 },76 {77 path: 'task',78 title: 'MENUITEMS.TASK.TEXT',79 moduleName: 'task',80 icon: 'menu-icon ti-check-box',81 class: '',82 groupTitle: false,83 submenu: []84 },85 {86 path: 'contacts',87 title: 'MENUITEMS.CONTACTS.TEXT',88 moduleName: 'contacts',89 icon: 'menu-icon ti-id-badge',90 class: '',91 groupTitle: false,92 submenu: []93 },94 {95 path: '',96 title: 'MENUITEMS.EMAIL.TEXT',97 moduleName: 'email',98 icon: 'menu-icon ti-email',99 class: 'menu-toggle',100 groupTitle: false,101 submenu: [102 {103 path: '/email/inbox',104 title: 'MENUITEMS.EMAIL.LIST.INBOX',105 moduleName: 'email',106 icon: '',107 class: 'ml-menu',108 groupTitle: false,109 submenu: []110 },111 {112 path: '/email/compose',113 title: 'MENUITEMS.EMAIL.LIST.COMPOSE',114 moduleName: 'email',115 icon: '',116 class: 'ml-menu',117 groupTitle: false,118 submenu: []119 },120 {121 path: '/email/read-mail',122 title: 'MENUITEMS.EMAIL.LIST.READ',123 moduleName: 'email',124 icon: '',125 class: 'ml-menu',126 groupTitle: false,127 submenu: []128 }129 ]130 },131 {132 path: '',133 title: 'MENUITEMS.MORE-APPS.TEXT',134 moduleName: 'apps',135 icon: 'menu-icon ti-themify-favicon',136 class: 'menu-toggle',137 groupTitle: false,138 submenu: [139 {140 path: '/apps/chat',141 title: 'MENUITEMS.MORE-APPS.LIST.CHAT',142 moduleName: 'apps',143 icon: '',144 class: 'ml-menu',145 groupTitle: false,146 submenu: []147 },148 {149 path: '/apps/dragdrop',150 title: 'MENUITEMS.MORE-APPS.LIST.DRAG-DROP',151 moduleName: 'apps',152 icon: '',153 class: 'ml-menu',154 groupTitle: false,155 submenu: []156 },157 {158 path: '/apps/contact-grid',159 title: 'MENUITEMS.MORE-APPS.LIST.CONTACT-GRID',160 moduleName: 'apps',161 icon: '',162 class: 'ml-menu',163 groupTitle: false,164 submenu: []165 },166 {167 path: '/apps/support',168 title: 'MENUITEMS.MORE-APPS.LIST.SUPPORT',169 moduleName: 'apps',170 icon: '',171 class: 'ml-menu',172 groupTitle: false,173 submenu: []174 }175 ]176 },177 {178 path: '',179 title: 'MENUITEMS.COMPONENTS.TEXT',180 moduleName: '',181 icon: '',182 class: 'header',183 groupTitle: true,184 submenu: []185 },186 {187 path: '',188 title: 'MENUITEMS.WIDGETS.TEXT',189 moduleName: 'widget',190 icon: 'menu-icon ti-crown',191 class: 'menu-toggle',192 groupTitle: false,193 submenu: [194 {195 path: '/widget/chart-widget',196 title: 'MENUITEMS.WIDGETS.LIST.CHART-WIDGET',197 moduleName: 'widget',198 icon: '',199 class: 'ml-menu',200 groupTitle: false,201 submenu: []202 },203 {204 path: '/widget/data-widget',205 title: 'MENUITEMS.WIDGETS.LIST.DATA-WIDGET',206 moduleName: 'widget',207 icon: '',208 class: 'ml-menu',209 groupTitle: false,210 submenu: []211 }212 ]213 },214 {215 path: '',216 title: 'MENUITEMS.FORMS.TEXT',217 moduleName: 'forms',218 icon: 'menu-icon ti-layout',219 class: 'menu-toggle',220 groupTitle: false,221 submenu: [222 {223 path: '/forms/form-controls',224 title: 'MENUITEMS.FORMS.LIST.CONTROLS',225 moduleName: 'forms',226 icon: '',227 class: 'ml-menu',228 groupTitle: false,229 submenu: []230 },231 {232 path: '/forms/advance-controls',233 title: 'MENUITEMS.FORMS.LIST.ADVANCE',234 moduleName: 'forms',235 icon: '',236 class: 'ml-menu',237 groupTitle: false,238 submenu: []239 },240 {241 path: '/forms/form-example',242 title: 'MENUITEMS.FORMS.LIST.EXAMPLE',243 moduleName: 'forms',244 icon: '',245 class: 'ml-menu',246 groupTitle: false,247 submenu: []248 },249 {250 path: '/forms/form-validation',251 title: 'MENUITEMS.FORMS.LIST.VALIDATION',252 moduleName: 'forms',253 icon: '',254 class: 'ml-menu',255 groupTitle: false,256 submenu: []257 },258 {259 path: '/forms/wizard',260 title: 'MENUITEMS.FORMS.LIST.WIZARD',261 moduleName: 'forms',262 icon: '',263 class: 'ml-menu',264 groupTitle: false,265 submenu: []266 },267 {268 path: '/forms/editors',269 title: 'MENUITEMS.FORMS.LIST.EDITORS',270 moduleName: 'forms',271 icon: '',272 class: 'ml-menu',273 groupTitle: false,274 submenu: []275 }276 ]277 },278 {279 path: '',280 title: 'MENUITEMS.TABLES.TEXT',281 moduleName: 'tables',282 icon: 'menu-icon ti-menu-alt',283 class: 'menu-toggle',284 groupTitle: false,285 submenu: [286 {287 path: '/tables/basic-tables',288 title: 'MENUITEMS.TABLES.LIST.BASIC',289 moduleName: 'tables',290 icon: '',291 class: 'ml-menu',292 groupTitle: false,293 submenu: []294 },295 {296 path: '/tables/material-tables',297 title: 'MENUITEMS.TABLES.LIST.MATERIAL',298 moduleName: 'tables',299 icon: '',300 class: 'ml-menu',301 groupTitle: false,302 submenu: []303 },304 {305 path: '/tables/ngx-datatable',306 title: 'MENUITEMS.TABLES.LIST.NGX-DATATABLE',307 moduleName: 'tables',308 icon: '',309 class: 'ml-menu',310 groupTitle: false,311 submenu: []312 }313 ]314 },315 {316 path: '',317 title: 'Charts',318 moduleName: 'charts',319 icon: 'menu-icon ti-stats-up',320 class: 'menu-toggle',321 groupTitle: false,322 submenu: [323 {324 path: '/charts/echart',325 title: 'Echart',326 moduleName: 'charts',327 icon: '',328 class: 'ml-menu',329 groupTitle: false,330 submenu: []331 },332 {333 path: '/charts/apex',334 title: 'Apex',335 moduleName: 'charts',336 icon: '',337 class: 'ml-menu',338 groupTitle: false,339 submenu: []340 },341 {342 path: '/charts/chartjs',343 title: 'ChartJS',344 moduleName: 'charts',345 icon: '',346 class: 'ml-menu',347 groupTitle: false,348 submenu: []349 },350 {351 path: '/charts/ngx-charts',352 title: 'Ngx-Charts',353 moduleName: 'charts',354 icon: '',355 class: 'ml-menu',356 groupTitle: false,357 submenu: []358 },359 {360 path: '/charts/gauge',361 title: 'Gauge',362 moduleName: 'charts',363 icon: '',364 class: 'ml-menu',365 groupTitle: false,366 submenu: []367 }368 ]369 },370 {371 path: '',372 title: 'User Interface (UI)',373 moduleName: 'ui',374 icon: 'menu-icon ti-magnet',375 class: 'menu-toggle',376 groupTitle: false,377 submenu: [378 {379 path: '/ui/alerts',380 title: 'Alerts',381 moduleName: 'ui',382 icon: '',383 class: 'ml-menu',384 groupTitle: false,385 submenu: []386 },387 {388 path: '/ui/badges',389 title: 'Badges',390 moduleName: 'ui',391 icon: '',392 class: 'ml-menu',393 groupTitle: false,394 submenu: []395 },396 {397 path: '/ui/chips',398 title: 'Chips',399 moduleName: 'ui',400 icon: '',401 class: 'ml-menu',402 groupTitle: false,403 submenu: []404 },405 {406 path: '/ui/modal',407 title: 'Modal',408 moduleName: 'ui',409 icon: '',410 class: 'ml-menu',411 groupTitle: false,412 submenu: []413 },414 {415 path: '/ui/buttons',416 title: 'Buttons',417 moduleName: 'ui',418 icon: '',419 class: 'ml-menu',420 groupTitle: false,421 submenu: []422 },423 {424 path: '/ui/expansion-panel',425 title: 'Expansion Panel',426 moduleName: 'ui',427 icon: '',428 class: 'ml-menu',429 groupTitle: false,430 submenu: []431 },432 {433 path: '/ui/bottom-sheet',434 title: 'Bottom Sheet',435 moduleName: 'ui',436 icon: '',437 class: 'ml-menu',438 groupTitle: false,439 submenu: []440 },441 {442 path: '/ui/dialogs',443 title: 'Dialogs',444 moduleName: 'ui',445 icon: '',446 class: 'ml-menu',447 groupTitle: false,448 submenu: []449 },450 {451 path: '/ui/cards',452 title: 'Cards',453 moduleName: 'ui',454 icon: '',455 class: 'ml-menu',456 groupTitle: false,457 submenu: []458 },459 {460 path: '/ui/labels',461 title: 'Labels',462 moduleName: 'ui',463 icon: '',464 class: 'ml-menu',465 groupTitle: false,466 submenu: []467 },468 {469 path: '/ui/list-group',470 title: 'List Group',471 moduleName: 'ui',472 icon: '',473 class: 'ml-menu',474 groupTitle: false,475 submenu: []476 },477 {478 path: '/ui/snackbar',479 title: 'Snackbar',480 moduleName: 'ui',481 icon: '',482 class: 'ml-menu',483 groupTitle: false,484 submenu: []485 },486 {487 path: '/ui/preloaders',488 title: 'Preloaders',489 moduleName: 'ui',490 icon: '',491 class: 'ml-menu',492 groupTitle: false,493 submenu: []494 },495 {496 path: '/ui/progressbars',497 title: 'Progress Bars',498 moduleName: 'ui',499 icon: '',500 class: 'ml-menu',501 groupTitle: false,502 submenu: []503 },504 {505 path: '/ui/tabs',506 title: 'Tabs',507 moduleName: 'ui',508 icon: '',509 class: 'ml-menu',510 groupTitle: false,511 submenu: []512 },513 {514 path: '/ui/typography',515 title: 'Typography',516 moduleName: 'ui',517 icon: '',518 class: 'ml-menu',519 groupTitle: false,520 submenu: []521 },522 {523 path: '/ui/helper-classes',524 title: 'Helper Classes',525 moduleName: 'ui',526 icon: '',527 class: 'ml-menu',528 groupTitle: false,529 submenu: []530 }531 ]532 },533 {534 path: '',535 title: 'Icons',536 moduleName: 'icons',537 icon: 'menu-icon ti-face-smile',538 class: 'menu-toggle',539 groupTitle: false,540 submenu: [541 {542 path: '/icons/material',543 title: 'Material Icons',544 moduleName: 'icons',545 icon: '',546 class: 'ml-menu',547 groupTitle: false,548 submenu: []549 },550 {551 path: '/icons/font-awesome',552 title: 'Font Awesome',553 moduleName: 'icons',554 icon: '',555 class: 'ml-menu',556 groupTitle: false,557 submenu: []558 },559 {560 path: '/icons/simple-line',561 title: 'Simple Line Icons',562 moduleName: 'icons',563 icon: '',564 class: 'ml-menu',565 groupTitle: false,566 submenu: []567 },568 {569 path: '/icons/themify',570 title: 'Themify Icons',571 moduleName: 'icons',572 icon: '',573 class: 'ml-menu',574 groupTitle: false,575 submenu: []576 }577 ]578 },579 {580 path: '',581 title: 'Maps',582 moduleName: 'maps',583 icon: 'menu-icon ti-map-alt',584 class: 'menu-toggle',585 groupTitle: false,586 submenu: [587 {588 path: '/maps/google',589 title: 'Google Map',590 moduleName: 'maps',591 icon: '',592 class: 'ml-menu',593 groupTitle: false,594 submenu: []595 }596 ]597 },598 {599 path: '',600 title: '-- Extra',601 moduleName: '',602 icon: '',603 class: 'header',604 groupTitle: true,605 submenu: []606 },607 {608 path: '',609 title: 'Timeline',610 moduleName: 'timeline',611 icon: 'menu-icon ti-split-v',612 class: 'menu-toggle',613 groupTitle: false,614 submenu: [615 {616 path: '/timeline/timeline1',617 title: 'Timeline 1',618 moduleName: 'timeline',619 icon: '',620 class: 'ml-menu',621 groupTitle: false,622 submenu: []623 },624 {625 path: '/timeline/timeline2',626 title: 'Timeline 2',627 moduleName: 'timeline',628 icon: '',629 class: 'ml-menu',630 groupTitle: false,631 submenu: []632 }633 ]634 },635 {636 path: '',637 title: 'Medias',638 moduleName: 'media',639 icon: 'menu-icon ti-image',640 class: 'menu-toggle',641 groupTitle: false,642 submenu: [643 {644 path: '/media/gallery',645 title: 'Image Gallery',646 moduleName: 'media',647 icon: '',648 class: 'ml-menu',649 groupTitle: false,650 submenu: []651 }652 ]653 },654 {655 path: '',656 title: 'Authentication',657 moduleName: 'authentication',658 icon: 'menu-icon ti-user',659 class: 'menu-toggle',660 groupTitle: false,661 submenu: [662 {663 path: '/authentication/signin',664 title: 'Sign In',665 moduleName: 'authentication',666 icon: '',667 class: 'ml-menu',668 groupTitle: false,669 submenu: []670 },671 {672 path: '/authentication/signup',673 title: 'Sign Up',674 moduleName: 'authentication',675 icon: '',676 class: 'ml-menu',677 groupTitle: false,678 submenu: []679 },680 {681 path: '/authentication/forgot-password',682 title: 'Forgot Password',683 moduleName: 'authentication',684 icon: '',685 class: 'ml-menu',686 groupTitle: false,687 submenu: []688 },689 {690 path: '/authentication/locked',691 title: 'Locked',692 moduleName: 'authentication',693 icon: '',694 class: 'ml-menu',695 groupTitle: false,696 submenu: []697 },698 {699 path: '/authentication/page404',700 title: '404 - Not Found',701 moduleName: 'authentication',702 icon: '',703 class: 'ml-menu',704 groupTitle: false,705 submenu: []706 },707 {708 path: '/authentication/page500',709 title: '500 - Server Error',710 moduleName: 'authentication',711 icon: '',712 class: 'ml-menu',713 groupTitle: false,714 submenu: []715 }716 ]717 },718 {719 path: '',720 title: 'Extra Pages',721 moduleName: 'extra-pages',722 icon: 'menu-icon ti-receipt',723 class: 'menu-toggle',724 groupTitle: false,725 submenu: [726 {727 path: '/extra-pages/profile',728 title: 'Profile',729 moduleName: 'extra-pages',730 icon: '',731 class: 'ml-menu',732 groupTitle: false,733 submenu: []734 },735 {736 path: '/extra-pages/pricing',737 title: 'Pricing',738 moduleName: 'extra-pages',739 icon: '',740 class: 'ml-menu',741 groupTitle: false,742 submenu: []743 },744 {745 path: '/extra-pages/invoice',746 title: 'Invoice',747 moduleName: 'extra-pages',748 icon: '',749 class: 'ml-menu',750 groupTitle: false,751 submenu: []752 },753 {754 path: '/extra-pages/faqs',755 title: 'Faqs',756 moduleName: 'extra-pages',757 icon: '',758 class: 'ml-menu',759 groupTitle: false,760 submenu: []761 },762 {763 path: '/extra-pages/blank',764 title: 'Blank Page',765 moduleName: 'extra-pages',766 icon: '',767 class: 'ml-menu',768 groupTitle: false,769 submenu: []770 }771 ]772 },773 {774 path: '',775 title: 'Multi level Menu',776 moduleName: 'multilevel',777 icon: 'menu-icon ti-angle-double-down',778 class: 'menu-toggle',779 groupTitle: false,780 submenu: [781 {782 path: '/multilevel/first1',783 title: 'First',784 moduleName: 'multilevel',785 icon: '',786 class: 'ml-menu',787 groupTitle: false,788 submenu: []789 },790 {791 path: '/',792 title: 'Second',793 moduleName: 'secondlevel',794 icon: '',795 class: 'ml-sub-menu',796 groupTitle: false,797 submenu: [798 {799 path: '/multilevel/secondlevel/second1',800 title: 'Second 1',801 moduleName: 'secondlevel',802 icon: '',803 class: 'ml-sub-sub-menu',804 groupTitle: false,805 submenu: []806 },807 {808 path: '/multilevel/secondlevel/second2',809 title: 'Second 2',810 moduleName: 'secondlevel',811 icon: '',812 class: 'ml-sub-sub-menu',813 groupTitle: false,814 submenu: []815 }816 ]817 },818 {819 path: '/multilevel/first3',820 title: 'Third',821 moduleName: 'multilevel',822 icon: '',823 class: 'ml-menu',824 groupTitle: false,825 submenu: []826 }827 ]828 }...
pydocutils.py
Source:pydocutils.py
1import sys2import types3from pydoc import safeimport, resolve, ErrorDuringImport4from pkgutil import iter_modules5from elpy import compat6# Types we want to recurse into (nodes).7CONTAINER_TYPES = (type, types.ModuleType)8# Types of attributes we can get documentation for (leaves).9PYDOC_TYPES = (type,10 types.FunctionType,11 types.BuiltinFunctionType,12 types.BuiltinMethodType,13 types.MethodType,14 types.ModuleType)15if not compat.PYTHON3: # pragma: nocover16 # Python 2 old style classes17 CONTAINER_TYPES = tuple(list(CONTAINER_TYPES) + [types.ClassType])18 PYDOC_TYPES = tuple(list(PYDOC_TYPES) + [types.ClassType])19def get_pydoc_completions(modulename):20 """Get possible completions for modulename for pydoc.21 Returns a list of possible values to be passed to pydoc.22 """23 modulename = compat.ensure_not_unicode(modulename)24 modulename = modulename.rstrip(".")25 if modulename == "":26 return sorted(get_modules())27 candidates = get_completions(modulename)28 if candidates:29 return sorted(candidates)30 needle = modulename31 if "." in needle:32 modulename, part = needle.rsplit(".", 1)33 candidates = get_completions(modulename)34 else:35 candidates = get_modules()36 return sorted(candidate for candidate in candidates37 if candidate.startswith(needle))38def get_completions(modulename):39 modules = set("{0}.{1}".format(modulename, module)40 for module in get_modules(modulename))41 try:42 module, name = resolve(modulename)43 except ImportError:44 return modules45 if isinstance(module, CONTAINER_TYPES):46 modules.update("{0}.{1}".format(modulename, name)47 for name in dir(module)48 if not name.startswith("_") and49 isinstance(getattr(module, name),50 PYDOC_TYPES))51 return modules52def get_modules(modulename=None):53 """Return a list of modules and packages under modulename.54 If modulename is not given, return a list of all top level modules55 and packages.56 """57 modulename = compat.ensure_not_unicode(modulename)58 if not modulename:59 try:60 return ([modname for (importer, modname, ispkg)61 in iter_modules()62 if not modname.startswith("_")] +63 list(sys.builtin_module_names))64 except OSError:65 # Bug in Python 2.6, see #27566 return list(sys.builtin_module_names)67 try:68 module = safeimport(modulename)69 except ErrorDuringImport:70 return []71 if module is None:72 return []73 if hasattr(module, "__path__"):74 return [modname for (importer, modname, ispkg)75 in iter_modules(module.__path__)76 if not modname.startswith("_")]...
Using AI Code Generation
1var BestModule = require("./BestModule.js");2BestModule.moduleName();3var moduleName = function() {4 console.log("I am the best module ever!");5}6module.exports.moduleName = moduleName;
Using AI Code Generation
1var bestModule = require('./BestModule');2bestModule.moduleName();3module.exports = {4 moduleName: function () {5 console.log('BestModule');6 }7};8var bestModule = require('./BestModule');9bestModule.moduleName();10module.exports = {11 moduleName: function () {12 console.log('BestModule');13 }14};
Using AI Code Generation
1var bestModule = require('./BestModule');2bestModule.moduleName();3exports.moduleName = function() {4 console.log("I am the best module");5}6exports = function() {7 console.log("I am the best module");8}9exports = function() {10 console.log("I am the best module");11}12exports = function() {13 console.log("I am the best module");14}
Using AI Code Generation
1var BestModule = require('./BestModule');2console.log(BestModule.moduleName());3module.exports.moduleName = function() {4 return 'BestModule';5};6module.exports = function() {7 return 'BestModule';8};9exports = function() {10 return 'BestModule';11};12exports.moduleName = function() {13 return 'BestModule';14};15exports.moduleName = function() {16 return 'BestModule';17};18exports.moduleName = function() {19 return 'BestModule';20};
Using AI Code Generation
1var BestModule = require("./BestModule");2var bestModule = new BestModule("hello");3bestModule.moduleName();4var BestModule = function(name){5 this.name = name;6}7BestModule.prototype.moduleName = function(){8 console.log("This is the best module ever called " + this.name);9}10module.exports = BestModule;
Using AI Code Generation
1var bestModule = require('./BestModule');2bestModule.moduleName();3bestModule.BestModule();4function BestModule() {5 console.log('BestModule method');6}7function moduleName() {8 console.log('moduleName method');9}10module.exports = BestModule;11module.exports.moduleName = moduleName;
Using AI Code Generation
1var bestPractice = require('./BestPractice.js');2bestPractice.moduleName();3var moduleName = function() {4 console.log('I am a module!');5};6module.exports.moduleName = moduleName;7var bestPractice = require('./BestPractice.js');8bestPractice.moduleName();9module.exports.moduleName = function() {10 console.log('I am a module!');11};12var bestPractice = require('./BestPractice.js');13var person = new bestPractice.Person('John', 'Doe');14person.sayHello();15var Person = function(firstName, lastName) {16 this.firstName = firstName;17 this.lastName = lastName;18};19Person.prototype.sayHello = function() {20 console.log('Hello, ' + this.firstName + ' ' + this.lastName);21};22module.exports.Person = Person;23var bestPractice = require('./BestPractice.js');24var person = new bestPractice.Person('John', 'Doe');25person.sayHello();26module.exports.Person = function(firstName, lastName) {27 this.firstName = firstName;28 this.lastName = lastName;29};30Person.prototype.sayHello = function() {31 console.log('Hello, ' + this.firstName + ' ' + this.lastName);32};
Using AI Code Generation
1var bestModule = require('./BestModule');2bestModule.moduleName();3exports.moduleName = function() {4 console.log('moduleName');5}6var bestModule = require('./BestModule');7bestModule.moduleName();8bestModule.moduleMethod();9var BestModule = function() {10 this.moduleName = function() {11 console.log('moduleName');12 };13 this.moduleMethod = function() {14 console.log('moduleMethod');15 };16};17module.exports = new BestModule();18var bestModule = require('./BestModule');19bestModule('test');20var BestModule = function(name) {21 console.log('name: ' + name);22};23module.exports = BestModule;
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!