Source: core.js

  1. (
  2. /**
  3. * Main module / namespace for the MMIR framework.
  4. *
  5. * On initialization, a global module <code>window.mmir</code> is created.
  6. *
  7. * If called multiple times, the existing module instance is returned.
  8. *
  9. * If a function <code>require</code> exists, the module tries to registers itself
  10. * according to the <em>RequireJS</em> interface (using the default as its module name, i.e. "mmirf/core").
  11. *
  12. * @name mmir
  13. * @export initMmir as mmir
  14. * @class
  15. * @namespace
  16. *
  17. * @returns the module instance <code>mmir</code>
  18. *
  19. */
  20. function initMmir(globalCtx) {
  21. var moduleConfigHelper = typeof WEBPACK_BUILD !== 'undefined' && WEBPACK_BUILD? require('build-tool/module-config-helper') : null;
  22. /**
  23. * the name of the global variable which will hold the core-module
  24. * @memberOf mmir.internal
  25. * @private
  26. */
  27. var coreName = typeof MMIR_CORE_NAME === 'string'? MMIR_CORE_NAME : 'mmir';
  28. // temp variable for global mmir instance
  29. var mmirGlobal = globalCtx[coreName];
  30. if(mmirGlobal){
  31. //if globalCtx[coreName] is the core-module: register it and return
  32. //(note: if it is not the core-module, its properties will be merged/copied to the core-module -> see below)
  33. if(typeof mmirGlobal.startModule === 'string' && typeof define === 'function'){
  34. define(function(){ return mmirGlobal; });
  35. return mmirGlobal;
  36. }
  37. }
  38. /**
  39. * the version of mmir-lib
  40. *
  41. * @memberOf mmir.internal
  42. * @private
  43. */
  44. var CORE_VERSION = "6.0.0";
  45. /**
  46. * STATE: state variable for indicating "doc is already loaded" (this needs to be set/reset manually)
  47. * @memberOf mmir.internal
  48. * @private
  49. */
  50. var _isReady = false;
  51. /**
  52. * @memberOf mmir.internal
  53. * @private
  54. */
  55. var _funcList = [];
  56. /**
  57. * @memberOf mmir.internal
  58. * @private
  59. */
  60. function dequeue () { return _funcList.shift(); };
  61. /**
  62. * @memberOf mmir.internal
  63. * @private
  64. */
  65. function isEmpty () { return _funcList.length === 0; };
  66. /**
  67. * @param {Function} [func] OPTIONAL
  68. * if func is present, func will be used instead of dequeueing a callback from the queue
  69. * @memberOf mmir.internal
  70. * @private
  71. */
  72. function deqExec (func) {
  73. if(!func){
  74. func = dequeue();
  75. }
  76. //run function in context of the document (with library reference as argument)
  77. func.call(mmir);
  78. };
  79. /**
  80. * HELPER apply requirejs configuration
  81. *
  82. * @param {PlainObject} [configuration]
  83. * the requirejs configuration value
  84. * @param {requirejs} [reqInstance] OPTIONAL
  85. * the requirejs instance, with attached <code>config</code> function
  86. * @memberOf mmir.internal
  87. * @private
  88. */
  89. function _reqConfig (configuration, reqInstance) {
  90. var req = reqInstance? reqInstance : (mmir && mmir.require? mmir.require : null);
  91. if(configuration){
  92. if(!req || !req.config){
  93. req = typeof requirejs !== 'undefined'? requirejs : (typeof WEBPACK_BUILD === 'undefined' || !typeof WEBPACK_BUILD) && typeof require !== 'undefined'? require : req && req('requirejs');
  94. }
  95. return req.config(configuration) || req;
  96. }
  97. return req;
  98. };
  99. /**
  100. * STATE: state variable for indicating "configs for requirejs are already applied"
  101. * @memberOf mmir.internal
  102. * @private
  103. */
  104. var _isApplied = false;
  105. /**
  106. * @memberOf mmir.internal
  107. * @private
  108. */
  109. var _configList = [];
  110. /**
  111. * Applies all <code>config</code>s (that were added by
  112. * {@link mmir.config}) to the requirejs instance.
  113. *
  114. * @param {PlainObject} mainConfig
  115. * the main configuration for the framework
  116. * (this is used as reference for merging config options if necessary - see also mainConfig.js)
  117. *
  118. * @memberOf mmir.internal
  119. * @private
  120. *
  121. * @see #mergeModuleConfigs
  122. */
  123. function applyConfigs(mainConfig, reqInstance){
  124. if(typeof require === 'undefined' && !moduleConfigHelper){
  125. return;
  126. }
  127. _isApplied = true;
  128. var conf;
  129. var confConfig, p;
  130. while(_configList.length > 0){
  131. conf = mergeModuleConfigs(_configList.shift(), mainConfig);
  132. //copy/remember all conf.config values that were not merged
  133. if(conf.config){
  134. for(p in conf.config){
  135. if(conf.config.hasOwnProperty(p) && typeof conf.config[p] !== 'undefined'){
  136. if(!confConfig){
  137. confConfig = {};
  138. }
  139. confConfig[p] = conf.config[p];
  140. }
  141. }
  142. }
  143. if(!moduleConfigHelper){
  144. for(p in conf){
  145. if(p === 'config'){
  146. continue;
  147. }
  148. if(mainConfig[p] && typeof mainConfig[p] === 'object'){
  149. for(var n in conf[p]){
  150. mainConfig[p][n] = conf[p][n];
  151. }
  152. } else {
  153. mainConfig[p] = conf[p];
  154. }
  155. }
  156. }
  157. }
  158. //if there were non-merged conf.config-values:
  159. // we cannot just apply these, since they would overwrite the mainConfig.config
  160. // -> so we copy all (possibly) merged values from the mainConfig.config over
  161. // and then apply all the conf.config-values at once here
  162. if(confConfig){
  163. for(p in mainConfig.config){
  164. if(mainConfig.config.hasOwnProperty(p) && typeof mainConfig.config[p] !== 'undefined'){
  165. confConfig[p] = mainConfig.config[p];
  166. }
  167. }
  168. if(moduleConfigHelper){
  169. moduleConfigHelper.setConfig({config: confConfig});
  170. return;
  171. }
  172. // replace mainConfig's config with merged & collected config-values:
  173. mainConfig.config = confConfig;
  174. }
  175. if(mainConfig){
  176. if(moduleConfigHelper){
  177. moduleConfigHelper.setConfig(mainConfig);
  178. } else {
  179. mmir.require = _reqConfig(mainConfig, reqInstance);
  180. }
  181. }
  182. return mainConfig;
  183. }
  184. /**
  185. * Helper for merging additional module-configurations with the (requirejs) main-config
  186. * of the framework.
  187. *
  188. * <p>
  189. * This allows to add module configurations outside the main-configuration (otherwise:
  190. * requirejs by default overwrites additional module-config settings).
  191. *
  192. * <p>
  193. * Merge behavior: if values in <code>mainConfig.config</code> exists, the primitive values
  194. * are overwritten with values from <code>conf.config</code> and object-values
  195. * are merged (recursively). Arrays are treated as primitive values (i.e.
  196. * overwritten, not merged/extended).
  197. *
  198. * <p>
  199. * Note: removes <code>conf.config</code> if present and merges the values
  200. * into <code>mainConfig.config</code>.
  201. *
  202. * @param {PlainObject} conf
  203. * the additional configuration options
  204. * @param {PlainObject} mainConfig
  205. * the main configuration for the framework
  206. * (this is used as reference for merging config options if necessary - see mainConfig.js)
  207. *
  208. * @return {PlainObject} the <code>conf</code> setting.
  209. * If necessary (i.e. if <code>conf.config</code> was present), the module-configuration
  210. * was merged with the main-configuration
  211. *
  212. * @memberOf mmir.internal
  213. * @private
  214. */
  215. function mergeModuleConfigs(conf, mainConfig){
  216. if(!mainConfig || !conf || !mainConfig.config || !conf.config || typeof mainConfig.config !== 'object' || typeof conf.config !== 'object'){
  217. return conf;
  218. }
  219. //ASSERT mainConfig.config and conf.config exist
  220. var count = 0, merged = 0;
  221. for(var cname in conf.config){
  222. if(conf.config.hasOwnProperty(cname)){
  223. ++count;
  224. //merge property cname into mainConfig
  225. if(doMergeInto(conf.config, mainConfig.config, cname)){
  226. //remove merge property from conf.config
  227. conf.config[cname] = void(0);
  228. ++merged;
  229. }
  230. }
  231. }
  232. //lastly: remove the conf.config property itself, if
  233. // all of its properties were merged
  234. if(count === merged){
  235. conf.config = void(0);
  236. }
  237. return conf;
  238. }
  239. /**
  240. * Helper for recursively merging config values from <code>conf1</code> into
  241. * <code>conf2</code> (and removing merged values from <code>conf1</code>) IF
  242. * an object-property <code>name</code> already exists in <code>conf2</code>.
  243. *
  244. * @param {PlainObject} conf1
  245. * the configuration object from which to take values (and removing them after merging)
  246. * @param {PlainObject} conf2
  247. * the configuration object to which values are merged
  248. * @param {String} name
  249. * the name of the property in <code>conf1</code> that should be merged into <code>conf2</code>
  250. * @param {Boolean} [isNotRoot] OPTIONAL
  251. * when cursively called, this should be TRUE, otherwise FALSE
  252. * (i.e. this should only be used in the function's internal invocation)
  253. *
  254. * @return {Boolean} <code>true</code> if property <code>name</code> was merged into conf2.
  255. *
  256. * @memberOf mmir.internal
  257. * @private
  258. */
  259. function doMergeInto(conf1, conf2, name, isNotRoot){
  260. var v = conf1[name];
  261. if(typeof conf2[name] === 'undefined' || typeof v !== typeof conf2[name] || typeof v !== 'object'){
  262. //if not set in conf2 OR types differ OR value is primitive:
  263. if( ! isNotRoot){
  264. //... if it is at the root-level of the config-value:
  265. // let requirejs.config() take care of it (-> will overwrite value in conf2 by applying conf1)
  266. // -> signal that it was not merged, and should not be removed
  267. return false; ////////////////////////// EARLY EXIT ////////////
  268. } else {
  269. //... if not at root-level, we must move the property over to conf2,
  270. // otherwise requirejs.config() would overwrite the entire property in conf2 with the one from conf1
  271. // -> move property (copy to conf2, remove from conf1)
  272. // -> signal that we merge the property
  273. conf2[name] = v;
  274. conf1[name] = void(0);
  275. return true; ////////////////////////// EARLY EXIT ////////////
  276. }
  277. }
  278. //ASSERT v has type object AND conf2 has an object value too
  279. //-> recursively merge
  280. for(var cname in conf1[name]){
  281. if(conf1[name].hasOwnProperty(cname)){
  282. //merge cname into conf2
  283. doMergeInto(conf1[name], conf2[name], cname, true);
  284. }
  285. }
  286. return true;
  287. }
  288. /**
  289. * Check if the version number corresponds to the most significant (right-most)
  290. * part of the mmir-lib's version number, i.e. check
  291. *
  292. * "is <code>version</code> <code>comp</code> than the mmir-lib version?"
  293. *
  294. * <br>
  295. * NOTE: changing the {@link mmir.version} field will have no effect on this function
  296. * (i.e. it will use the original value of <code>version</code>)
  297. *
  298. * @param {Number} version
  299. * the version number to check against
  300. * @param {String} [comp] OPTIONAL
  301. * the comparison type, e.g. <code> ">" | "<" | ">=" | "<=" | "==" | "===" | "!=" | "!==" </code>
  302. * <br>Will be used as follows: <code>{mmir-lib version} {comp} {version}</code>
  303. * <br>DEFAULT: "==="
  304. * <br>NOTE: "=" will be interpreted as "=="
  305. *
  306. * @returns {Boolean|Void} returns the result of the comparison to most the significant part
  307. * of the mmir-lib version number,
  308. * or <code>VOID</code> if the mmir-lib version number is not available.
  309. *
  310. * @memberOf mmir.internal
  311. * @private
  312. */
  313. var _isVersion = function(version, comp){
  314. var ver = CORE_VERSION;
  315. if(ver){
  316. var sigNum = /^.*?(\d+)\./.exec(ver);
  317. sigNum = parseInt(sigNum[1], 10);
  318. if(isFinite(sigNum)){
  319. switch(comp){
  320. case '>=':
  321. return sigNum >= version;
  322. case '<=':
  323. return sigNum <= version;
  324. case '>':
  325. return sigNum > version;
  326. case '<':
  327. return sigNum < version;
  328. case '!=':
  329. return sigNum != version;
  330. case '!==':
  331. return sigNum !== version;
  332. case '='://
  333. case '==':
  334. return sigNum == version;
  335. case '===':
  336. default:
  337. return sigNum === version;
  338. }
  339. }
  340. }
  341. return void(0);
  342. };
  343. //DISABLED: un-used for now
  344. // /**
  345. // * Helper for detecting array type.
  346. // *
  347. // * @param {any} obj
  348. // * the object which should be checked
  349. // *
  350. // * @return {Boolean} <code>true</code> if <code>obj</code> is an Array
  351. // *
  352. // * @memberOf mmir.internal
  353. // * @private
  354. // */
  355. // var isArray = (function(){
  356. // if(typeof Array.isArray === 'function'){
  357. // return Array.isArray;
  358. // }
  359. // else {
  360. // return function(arr){
  361. // //workaround if Array.isArray is not available: use specified result for arrays of Object's toString() function
  362. // Object.prototype.toString.call(arr,arr) === '[object Array]';
  363. // };
  364. // }
  365. // })();
  366. var mmir = {
  367. /**
  368. * Set the framework to "initialized" status (i.e. will
  369. * trigger the "ready" event/callbacks)
  370. *
  371. * <p>
  372. * WARNING: use this only, if you know what
  373. * you are doing -- normally this
  374. * functions is only called once
  375. * during initialization by the
  376. * framework to signal that all
  377. * settings, classes, set-up etc
  378. * for the framework are now
  379. * initialized.
  380. * <p>
  381. *
  382. * NOTE: this is a semi-private function that
  383. * should only be used by the initialization
  384. * process.
  385. *
  386. * @memberOf mmir
  387. * @name setInitialized
  388. * @function
  389. * @private
  390. */
  391. setInitialized : function() {
  392. _isReady = true;
  393. //apply configurations to requirejs instance:
  394. applyConfigs();
  395. //execute all callbacks in queue
  396. while(!isEmpty()){
  397. deqExec();
  398. }
  399. },
  400. /**
  401. * Register callbacks for initialization-event of framework.
  402. *
  403. * If used after framework has been initialized, the callback is invoked immediately.
  404. *
  405. * @memberOf mmir
  406. * @name ready
  407. * @function
  408. * @public
  409. *
  410. * @param {Function} func
  411. * callback Function that will be triggered when the framework has been initialized
  412. */
  413. ready: function(func) {
  414. //SPECIAL MODE: if already active, execute the callback
  415. // (if queue is not empty yet: queue function call in order to preserve the execution ordering)
  416. if(_isReady && isEmpty()){
  417. deqExec(func);
  418. }
  419. else {
  420. _funcList.push(func);
  421. }
  422. },
  423. /**
  424. * Set options / settings for overwriting the default
  425. * configuration for RequireJS:
  426. *
  427. * <br>
  428. * Options / configurations that are added by this
  429. * method will overwrite settings specified in
  430. * <code>mainConfig.js</code>.
  431. *
  432. * <p>
  433. * NOTE: the options added here will be applied in the order
  434. * they were added, i.e. if a later option specifies
  435. * settings that were already set by a previous call,
  436. * then these later options will overwrite the earlier
  437. * ones.
  438. *
  439. * @memberOf mmir
  440. * @name config
  441. * @function
  442. * @param {PlainObject} options
  443. * options for RequireJS
  444. * @public
  445. *
  446. * @example
  447. *
  448. * //IMPORTANT these calls need to done, AFTER core.js is loaded, but BEFORE require.js+mainConfig.js is loaded
  449. * //(see example index.html in starter-kit)
  450. *
  451. * //set specific log-level for module "moduleName":
  452. * mmir.config({config: { 'moduleName': {logLevel: 'warn'}}});
  453. *
  454. * //modify default log-levels for dialogManager and inputManager:
  455. * mmir.config({config: { 'mmirf/dialogManager': {logLevel: 'warn'}, 'mmirf/inputManager': {logLevel: 'warn'}}});
  456. *
  457. * //... or using alternative SCXML definition for dialog-engine:
  458. * mmir.config({config: { 'mmirf/dialogManager': {modelUri: 'config/states/example-view_transitions-dialogDescriptionSCXML.xml'});
  459. *
  460. * //overwrite module location (BEWARE: you should know what you are doing, if you use this)
  461. * mmir.config({paths: {'jquery': 'content/libs/zepto'}};
  462. *
  463. *
  464. * //add ID and location for own module (NOTE: need to omit file-extension ".js" in location! see requirejs docs):
  465. * mmir.config({paths: {'customAppRouter': 'content/libs/router'}};
  466. */
  467. config: function(options){
  468. if(_isApplied && typeof require !== 'undefined'){
  469. _reqConfig(options, this.require);
  470. }
  471. else {
  472. _configList.push(options);
  473. }
  474. },
  475. /**
  476. * Applies settings that were added via
  477. * {@link #config}.
  478. *
  479. * <p>
  480. * WARNING: use this only, if you know what
  481. * you are doing -- normally this
  482. * functions is only called once
  483. * during initialization by the
  484. * framework, after the default
  485. * configuration settings for
  486. * RequireJS in <code>mainConfig.js</code>
  487. * were applied.
  488. * <p>
  489. *
  490. * NOTE: this is a semi-private function that
  491. * should only be used by the initialization
  492. * process.
  493. *
  494. * @memberOf mmir
  495. * @name applyConfigs
  496. * @function
  497. * @protected
  498. */
  499. applyConfig: applyConfigs,
  500. /**
  501. * @copydoc mmir.internal._isVersion
  502. * @memberOf mmir
  503. * @name isVersion
  504. * @function
  505. * @public
  506. */
  507. isVersion: _isVersion,
  508. /**
  509. * The name of the (this) the core module:
  510. * this is also the global variable by which the core module (this) can be accessed.
  511. *
  512. *
  513. * NOTE: changing this name here will have no affect on the name of the global variable,
  514. * instead set global variable <code>MMIR_CORE_NAME</code> before loading mmir
  515. *
  516. * @memberOf mmir
  517. * @name mmirName
  518. * @type String
  519. * @default {String} "mmir"
  520. * @readonly
  521. * @public
  522. */
  523. mmirName: coreName,
  524. /**
  525. * The version of mmir-lib.
  526. *
  527. * @memberOf mmir
  528. * @name version
  529. * @type String
  530. * @readonly
  531. * @public
  532. */
  533. version: CORE_VERSION,
  534. /**
  535. * The name / ID of the RequireJS module that will
  536. * be loaded, after the configuration in
  537. * <code>mainConfig.js</code> was applied.
  538. *
  539. * <p>
  540. * This module should first start-up the framework and
  541. * then signal the application (via {@link mmir.setInitialized})
  542. * that it is ready to be used, i.e. fully initialized now.
  543. *
  544. * <p>
  545. * NOTE: If set to <code>undefined</code>, no module will be
  546. * loaded after configuration in <code>mainConfig.js</code>
  547. * was applied.
  548. *
  549. * @memberOf mmir
  550. * @name startModule
  551. * @type String
  552. * @default {String} "mmirf/main" will load the module specified in /main.js
  553. * @public
  554. */
  555. startModule: 'mmirf/main',
  556. /**
  557. * A list of names / RequireJS module IDs, that will be loaded
  558. * immediately before loading/initializing the mmir library.
  559. *
  560. * @memberOf mmir
  561. * @name startModules
  562. * @type Array<String>
  563. * @default {Void}
  564. * @public
  565. */
  566. startModules: void(0),
  567. /**
  568. * Mode for vendor libraries:
  569. * if "min" the minified/optimized variants (if available) for vendor libraries
  570. * are used.
  571. *
  572. * @memberOf mmir
  573. * @name libMode
  574. * @type undefined | "min"
  575. * @default {Void}
  576. * @public
  577. */
  578. libMode: void(0),
  579. /**
  580. * The jQuery instance that will be used by the MMIR library.
  581. *
  582. * Will be automatically set, if jQuery is loaded before the MMIR library initializes
  583. * (or can be manually set, before the MMIR library initializes).
  584. *
  585. * If jQuery is present, the MMIR library will utilize its implementation for some
  586. * utility functions (otherwise alternative, internal utiltiy implemenations will be used).
  587. *
  588. * NOTE: changing this field after the MMIR library has initialized will have no effect.
  589. *
  590. *
  591. * @memberOf mmir
  592. * @name jquery
  593. * @type jQuery
  594. * @default undefined (will be set automatically, if jQuery was loaded)
  595. * @public
  596. */
  597. jquery: void(0),
  598. /**
  599. * Name / ID / load-path (requirejs) for the module
  600. * that handles the views (i.e. "rendering" that is
  601. * change from one view to the next).
  602. *
  603. * @memberOf mmir
  604. * @name viewEngine
  605. * @type String
  606. * @default "mmirf/simpleViewEngine" will load the default view-engine that uses standard HTML document API
  607. * @public
  608. */
  609. viewEngine: 'mmirf/simpleViewEngine',
  610. /**
  611. * Property for enabling / disabling logging:
  612. * if set to <code>true</code> (or omitted), the default Logger implementation <code>tools/logger.js</code>
  613. * will be loaded as "logger" module.
  614. *
  615. * If set to <code>false</code> the "dummy" Logger implementation <code>tools/loggerDisabled.js</code> will
  616. * be loaded as "logger" module which essentially will create no logging output.
  617. *
  618. * @memberOf mmir
  619. * @name debug
  620. * @type Boolean
  621. * @default true
  622. * @public
  623. *
  624. * @see mmir.logLevel
  625. */
  626. debug: true,
  627. /**
  628. * Property for the log-level of the Logger module:
  629. * if set, and property <code>debug</code> is <code>true</code>, then the logger module
  630. * will use the log-level as default log-level.
  631. *
  632. * If omitted, the Logger's implementation defaults will be used.
  633. *
  634. * If set, the property must be either a Number or a String with one of the following values:
  635. * <pre>
  636. * 0: "verbose"
  637. * 1: "debug"
  638. * 2: "info"
  639. * 3: "warn"
  640. * 4: "error"
  641. * 5: "critical"
  642. * 6: "disabled"
  643. * </pre>
  644. *
  645. * or a <code>LogLevelOptions</code> object:
  646. * <pre>
  647. * {
  648. * level: LogLevel // OPTIONAL the default log level as integer or string, DEFAULT: "debug"
  649. * levels: { // OPTIONAL list of modules for per log level (unspecified modules will have default log level)
  650. * [logLevel]: Array<string> // list of modules for the LogLevel
  651. * },
  652. * modules: { // OPTIONAL log level per module (unspecified modules will have default log level)
  653. * [moduleId]: LogLevel // log level for the module
  654. * }
  655. * </pre>
  656. * NOTE: LogLevelOptions.levels and LogLevelOptions.modules will be overriden by module configurations,
  657. * i.e. <pre>core.config({config: {"moduleId": {logLevel: LOGLEVEL}}})</pre>
  658. *
  659. * NOTE: if you want to disable logging completely, use {@link mmir.debug}.
  660. * Setting the logLevel to "disabled" will still allow specific module's to create logging output
  661. * (if their log-level is set appropriately)
  662. *
  663. * @memberOf mmir
  664. * @name logLevel
  665. * @type Integer | String | LogLevelOptions
  666. * @default "debug"
  667. * @public
  668. *
  669. * @see mmir.debug
  670. * @example
  671. * var logLevelOpt = {
  672. * level: "warn",
  673. * levels: {
  674. * 0: ["mmirf/mediaManager"],
  675. * critical: ["mmirf/notificationManager", "mmirf/view"]
  676. * },
  677. * modules: {
  678. * "mmirf/presentationManager": 3,
  679. * "mmirf/commonUtils": "disabled"
  680. * }
  681. * }
  682. */
  683. logLevel: 'debug',
  684. /**
  685. * Property for enabling / disabling trace output in the Logger module:
  686. * if set to <code>true</code>, and property <code>debug</code> is <code>true</code>, then
  687. * the logger module will print a stack-trace for each log-message.
  688. *
  689. * If set to a configuration object:
  690. * <pre>
  691. * {
  692. * "trace": [true | false], //same as the Boolean primitive for logTrace, DEFAULT: true
  693. * "depth": ["full" | any] //OPTIONAL: if "full" then the complete stack trace is printed,
  694. * // otherwise only the first stack-entry (i.e. the calling function)
  695. * // is printed.
  696. * //DEFAULT: any
  697. * }
  698. * </pre>
  699. *
  700. * i.e. <code>{trace: true}</code> would be the same as using <code>true</code> (or omitting this property).
  701. *
  702. *
  703. * The default value (also if omitted!) is <code>true</code>.
  704. *
  705. * @memberOf mmir
  706. * @name logTrace
  707. * @type Boolean | PlainObject
  708. * @default true
  709. * @public
  710. *
  711. * @see mmir.debug
  712. * @see mmir.logLevel
  713. */
  714. logTrace: true, //{trace: true, depth: 'full'},
  715. /**
  716. * Attached require-function that is used by the framework to load dependencies.
  717. *
  718. * @memberOf mmir
  719. * @name require
  720. * @type Function
  721. * @default requirejs
  722. * @public
  723. *
  724. * @see https://requirejs.org/
  725. */
  726. require: null,//is intialized in mainConfig.js
  727. /**
  728. * Attached define-function for "declaring" modules that is used by the framework.
  729. *
  730. * See requirejs documentation on details about the <code>define</code> function.
  731. *
  732. * @memberOf mmir
  733. * @name _define
  734. * @type Function
  735. * @default define
  736. * @protected
  737. *
  738. * @see https://requirejs.org/
  739. */
  740. _define: null,//is intialized in mainConfig.js
  741. /**
  742. * The (relative) path pointing to the mmir-lib, in case the library is located
  743. * somewhere other than <code>mmirf/</code> (relative to the main HTML page).
  744. *
  745. * Normally, it should not be necessary to change this.
  746. *
  747. * NOTE: if specified, the path should end with a slash, otherwise loading
  748. * the library may fail!
  749. *
  750. *
  751. * @memberOf mmir
  752. * @name _mmirLibPath
  753. * @type String
  754. * @default undefined (will use the default configuration for the path)
  755. * @protected
  756. */
  757. _mmirLibPath: void(0)
  758. };
  759. if(typeof define === 'function'){
  760. define('mmirf/core', function(){ return mmir; });
  761. }
  762. //if mmirGlobal, i.e. globalCtx[coreName] already exists:
  763. // copy all its properties to the new core-mmir object
  764. // (i.e. collisions will override the default impl.)
  765. if(mmirGlobal){
  766. for(var p in mmirGlobal){
  767. if(mmirGlobal.hasOwnProperty(p) && typeof mmir[p] === 'undefined'){
  768. mmir[p] = mmirGlobal[p];
  769. }
  770. }
  771. }
  772. //export core-module into global namespace:
  773. globalCtx[coreName] = mmir;
  774. return mmir;
  775. }(typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : typeof global !== 'undefined' ? global : this));