tao-test/app/taoQtiItem/views/js/qtiCreator/model/pciCreatorContext.js

38 lines
1002 B
JavaScript
Raw Normal View History

2022-08-29 20:14:13 +02:00
define(['lodash'], function(_){
"use strict";
var _pciModels = {};
/**
* Global object accessible by all PCIs
*
* @type Object
*/
var pciCreatorContext = {
/**
* register a custom interaction (its runtime model) in global registery
* register a renderer
*
* @param {Object} pciModel
* @returns {undefined}
*/
register : function(pciModel){
//@todo check pciModel validity
_pciModels[pciModel.getTypeIdentifier()] = pciModel;
},
/**
* Get a cloned object representing the PCI model
*
* @param {string} pciTypeIdentifier
* @returns {Object} clonedPciModel
*/
createPciInstance : function(pciTypeIdentifier){
if(_pciModels[pciTypeIdentifier]){
return _.cloneDeep(_pciModels[pciTypeIdentifier]);
}
}
};
return pciCreatorContext;
});