2 lines
102 KiB
JavaScript
2 lines
102 KiB
JavaScript
function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(o){if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,minLen):void 0}}function _iterableToArray(iter){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(iter))return Array.from(iter)}function _arrayWithoutHoles(arr){if(Array.isArray(arr))return _arrayLikeToArray(arr)}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_typeof(obj)}define("tpl!taoMediaManager/qtiCreator/tpl/relatedItemsPopup",["handlebars"],function(hb){return hb.template(function(Handlebars,depth0,helpers,partials,data){function program1(depth0){var stack1,buffer="";return buffer+="<li>"+escapeExpression((stack1=depth0&&depth0.label,"function"===_typeof(stack1)?stack1.apply(depth0):stack1))+"</li>",buffer}this.compilerInfo=[4,">= 1.0.0"],helpers=this.merge(helpers,Handlebars.helpers),data=data||{};var stack1,helper,options,buffer="",escapeExpression=this.escapeExpression,helperMissing=helpers.helperMissing,self=this;return buffer+=escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"This",options):helperMissing.call(depth0,"__","This",options)))+" <b>",(helper=helpers.name)?stack1=helper.call(depth0,{hash:{},data:data}):(helper=depth0&&depth0.name,stack1="function"===_typeof(helper)?helper.call(depth0,{hash:{},data:data}):helper),buffer+=escapeExpression(stack1)+"</b> "+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"is currently used in",options):helperMissing.call(depth0,"__","is currently used in",options)))+" ",(helper=helpers.number)?stack1=helper.call(depth0,{hash:{},data:data}):(helper=depth0&&depth0.number,stack1="function"===_typeof(helper)?helper.call(depth0,{hash:{},data:data}):helper),buffer+=escapeExpression(stack1)+" "+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"item(s)",options):helperMissing.call(depth0,"__","item(s)",options)))+":\n<ul>\n",stack1=helpers.each.call(depth0,depth0&&depth0.items,{hash:{},inverse:self.noop,fn:self.program(1,program1,data),data:data}),(stack1||0===stack1)&&(buffer+=stack1),buffer+="\n</ul>\n"+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"Are you sure you want to delete this",options):helperMissing.call(depth0,"__","Are you sure you want to delete this",options)))+" <b>",(helper=helpers.name)?stack1=helper.call(depth0,{hash:{},data:data}):(helper=depth0&&depth0.name,stack1="function"===_typeof(helper)?helper.call(depth0,{hash:{},data:data}):helper),buffer+=escapeExpression(stack1)+"</b>?",buffer})}),define("tpl!taoMediaManager/qtiCreator/tpl/relatedItemsClassPopup",["handlebars"],function(hb){return hb.template(function(Handlebars,depth0,helpers,partials,data){this.compilerInfo=[4,">= 1.0.0"],helpers=this.merge(helpers,Handlebars.helpers),data=data||{};var stack1,helper,options,buffer="",helperMissing=helpers.helperMissing,escapeExpression=this.escapeExpression;return buffer+="<b>"+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"Warning",options):helperMissing.call(depth0,"__","Warning",options)))+"</b><br><br>\n"+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"You are about to delete the class",options):helperMissing.call(depth0,"__","You are about to delete the class",options)))+" <b>",(helper=helpers.name)?stack1=helper.call(depth0,{hash:{},data:data}):(helper=depth0&&depth0.name,stack1="function"===_typeof(helper)?helper.call(depth0,{hash:{},data:data}):helper),buffer+=escapeExpression(stack1)+"</b>, "+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"which contains assets that are in use elsewhere.",options):helperMissing.call(depth0,"__","which contains assets that are in use elsewhere.",options)))+"\n"+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"Deleting this class will break the items and the tests that are currently using them.",options):helperMissing.call(depth0,"__","Deleting this class will break the items and the tests that are currently using them.",options)))+"<br><br>\n"+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"Are you sure you want to delete this class and all of its content?",options):helperMissing.call(depth0,"__","Are you sure you want to delete this class and all of its content?",options))),buffer})}),define("tpl!taoMediaManager/qtiCreator/tpl/forbiddenClassAction",["handlebars"],function(hb){return hb.template(function(Handlebars,depth0,helpers,partials,data){this.compilerInfo=[4,">= 1.0.0"],helpers=this.merge(helpers,Handlebars.helpers),data=data||{};var stack1,helper,options,buffer="",helperMissing=helpers.helperMissing,escapeExpression=this.escapeExpression;return buffer+="<b>"+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"Forbidden action",options):helperMissing.call(depth0,"__","Forbidden action",options)))+"</b><br><br>\n"+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"The class",options):helperMissing.call(depth0,"__","The class",options)))+" <b>",(helper=helpers.name)?stack1=helper.call(depth0,{hash:{},data:data}):(helper=depth0&&depth0.name,stack1="function"===_typeof(helper)?helper.call(depth0,{hash:{},data:data}):helper),buffer+=escapeExpression(stack1)+"</b> "+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"you are trying to delete is too large and contains too many subclasses.",options):helperMissing.call(depth0,"__","you are trying to delete is too large and contains too many subclasses.",options)))+"<br>\n"+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"Please delete the subclasses before.",options):helperMissing.call(depth0,"__","Please delete the subclasses before.",options))),buffer})}),define("css!taoMediaManagerCss/media",[],function(){}),define("taoMediaManager/controller/actions",["lodash","jquery","i18n","layout/actions/binder","uri","layout/section","core/request","core/router","core/logger","ui/feedback","ui/dialog/confirm","ui/dialog/alert","util/url","tpl!taoMediaManager/qtiCreator/tpl/relatedItemsPopup","tpl!taoMediaManager/qtiCreator/tpl/relatedItemsClassPopup","tpl!taoMediaManager/qtiCreator/tpl/forbiddenClassAction","css!taoMediaManagerCss/media.css"],function(_,$,__,binder,uri,section,request,router,loggerFactory,feedback,confirmDialog,alertDialog,urlUtil,relatedItemsPopupTpl,relatedItemsClassPopupTpl,forbiddenClassActionTpl){'use strict';function callConfirmModal(actionContext,message,url,data,resolve,reject){confirmDialog(message,function(){return accept(actionContext,url,data,resolve,reject)},function(){return cancel(reject)})}function callAlertModal(actionContext,message,reject){alertDialog(message,function(){return cancel(reject)})}function accept(actionContext,url,data,resolve,reject){return request({url:url,method:"POST",data:data,dataType:"json"}).then(function(response){return response.success&&response.deleted?(feedback().success(response.message||__("Resource deleted")),actionContext.tree&&$(actionContext.tree).trigger("removenode.taotree",[{id:actionContext.uri||actionContext.classUri}]),resolve({uri:actionContext.uri||actionContext.classUri})):void reject(response.msg||__("Unable to delete the selected resource"))})}function cancel(reject){reject({cancel:!0})}var logger=loggerFactory("taoMediaManager/manageMedia");binder.register("newSharedStimulus",function(actionContext){var self=this,classUri=uri.decode(actionContext.classUri);return request({url:self.url,data:JSON.stringify({classUri:classUri}),method:"POST"}).then(function(response){return actionContext.tree&&$(actionContext.tree).trigger("addnode.taotree",[{uri:uri.decode(response.data.id),label:response.data.name,parent:uri.decode(actionContext.classUri),cssClass:"node-instance"}]),{uri:uri.decode(response.data.id),label:response.data.name,classUri:uri.decode(actionContext.classUri),type:"instance"}}).catch(function(err){_.isUndefined(err.message)||feedback().error(err.message),logger.error(err)})}),binder.register("sharedStimulusAuthoring",function(actionContext){section.updateContentBlock("").create({id:"authoring",name:__("Authoring"),url:this.url,content:" ",visible:!1}).show();var $panel=$("#panel-authoring");$panel.attr("data-id",actionContext.id),$panel.attr("data-uri",actionContext.uri),router.dispatch("".concat(this.url,"?id=").concat(actionContext.id))}),binder.register("deleteSharedStimulus",function(actionContext){var self=this,data={},mediaRelationsData={type:"media"};return"instance"===actionContext.context[0]?mediaRelationsData.sourceId=actionContext.id:mediaRelationsData.classId=actionContext.id,data.uri=uri.decode(actionContext.uri),data.classUri=uri.decode(actionContext.classUri),data.id=actionContext.id,data.signature=actionContext.signature,new Promise(function(resolve,reject){request({url:urlUtil.route("index","ResourceRelations","tao"),data:mediaRelationsData,method:"GET",noToken:!0}).then(function(responseRelated){var message,haveItemReferences=responseRelated.data.relations,name=$("a.clicked",actionContext.tree).text().trim();"instance"===actionContext.context[0]?0===haveItemReferences.length?message="".concat(__("Are you sure you want to delete this")," <b>").concat(name,"</b>?"):message=relatedItemsPopupTpl({name:name,number:haveItemReferences.length,items:haveItemReferences}):"instance"!==actionContext.context[0]&&(0===haveItemReferences.length?message="".concat(__("Are you sure you want to delete this class and all of its content?")):0!==haveItemReferences.length&&(message=relatedItemsClassPopupTpl({name:name,number:haveItemReferences.length,items:haveItemReferences}))),callConfirmModal(actionContext,message,self.url,data,resolve,reject)}).catch(function(errorObject){var message;"class"===actionContext.context[0]&&999===errorObject.response.code&&(message=forbiddenClassActionTpl()),callAlertModal(actionContext,message,reject)})})})}),define("taoMediaManager/qtiCreator/helper/createDummyItemData",["taoQtiItem/qtiCreator/model/Item"],function(Item){'use strict';var _generateIdentifier=function(uri){var pos=uri.lastIndexOf("#");return uri.substr(pos+1)};return function creatorDummyItemData(sharedStimulusData){var newItem=new Item().id(_generateIdentifier(sharedStimulusData.id)).attr("title",sharedStimulusData.name);newItem.data("new",!0),newItem.data("dummy",!0);var itemData=Object.assign({},newItem);return delete itemData.bdy,delete itemData.rootElement,itemData.body=sharedStimulusData.body.body,itemData.qtiClass="assessmentItem",itemData.responseProcessing={attributes:{},qtiClass:"responseProcessing",responseRules:[],serial:"response_".concat(sharedStimulusData.body.serial)},itemData.response={},sharedStimulusData.body.attributes["xml:lang"]&&(itemData.attributes["xml:lang"]=sharedStimulusData.body.attributes["xml:lang"]),itemData}}),define("taoMediaManager/qtiCreator/helper/sharedStimulusLoader",["jquery","taoQtiItem/qtiItem/core/Loader","taoQtiItem/qtiCreator/model/qtiClasses","taoMediaManager/qtiCreator/helper/createDummyItemData","core/dataProvider/request","util/url"],function($,Loader,qtiClasses,creatorDummyItemData,request,urlUtil){'use strict';var qtiSchemaLocation={"http://www.imsglobal.org/xsd/imsqti_v2p2":"http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2.xsd"},languagesUrl=urlUtil.route("index","Languages","tao");return{loadSharedStimulus:function loadSharedStimulus(config,callback){if(config.id){var languagesList=request(languagesUrl),assetData=request(config.assetDataUrl,{id:config.id});Promise.all([languagesList,assetData]).then(function(values){var loader,itemData;itemData=creatorDummyItemData(values[1]),loader=new Loader().setClassesLocation(qtiClasses),loader.loadItemData(itemData,function(loadedItem){var namespaces;namespaces=loadedItem.getNamespaces(),namespaces[""]="http://www.imsglobal.org/xsd/imsqti_v2p2",loadedItem.setNamespaces(namespaces),loadedItem.setSchemaLocations(qtiSchemaLocation),languagesList&&loadedItem.data("languagesList",values[0]),callback(loadedItem,this.getLoadedClasses())})})}}}}),define("taoMediaManager/qtiCreator/renderers/config",["lodash","taoQtiItem/qtiCommonRenderer/renderers/config","taoItems/assets/manager","taoItems/assets/strategies"],function(_,commonRenderConfig,assetManagerFactory,assetStrategies){'use strict';var assetManager=assetManagerFactory([assetStrategies.taomedia,assetStrategies.external,assetStrategies.base64,assetStrategies.baseUrl],{baseUrl:""}),locations=_.defaults({_container:"taoQtiItem/qtiCreator/renderers/Container",_tooltip:"taoQtiItem/qtiCreator/renderers/Tooltip",assessmentItem:"taoMediaManager/qtiCreator/renderers/Item",img:"taoMediaManager/qtiCreator/renderers/Img",math:"taoQtiItem/qtiCreator/renderers/Math",object:"taoMediaManager/qtiCreator/renderers/Object",table:"taoMediaManager/qtiCreator/renderers/Table"},commonRenderConfig.locations);return{name:"creatorRenderer",locations:locations,options:{assetManager:assetManager}}}),define("taoMediaManager/qtiCreator/renderers/Renderer",["taoQtiItem/qtiRunner/core/Renderer","taoMediaManager/qtiCreator/renderers/config"],function(Renderer,config){'use strict';return Renderer.build(config.locations,config.name,config.options)}),define("taoMediaManager/qtiCreator/helper/creatorRenderer",["jquery","lodash","taoMediaManager/qtiCreator/renderers/Renderer","taoItems/assets/manager","taoItems/assets/strategies","util/dom"],function($,_,Renderer,assetManagerFactory,assetStrategies,dom){'use strict';var creatorRenderer=null,get=function(reset,config,areaBroker){var $bodyEltForm;return config=config||{},config.properties=config.properties||{},(!creatorRenderer||reset)&&($bodyEltForm=creatorRenderer?creatorRenderer.getOption("bodyElementOptionForm"):null,(reset||!$bodyEltForm||!$bodyEltForm.length||!dom.contains($bodyEltForm))&&(creatorRenderer=new Renderer({lang:"",uri:"",shuffleChoices:!1,itemOptionForm:$("#item-editor-item-property-bar .panel"),bodyElementOptionForm:areaBroker.getElementPropertyPanelArea(),textOptionForm:$("#item-editor-text-property-bar .panel"),mediaManager:{appendContainer:"#mediaManager",browseUrl:config.properties.getFilesUrl,uploadUrl:config.properties.fileUploadUrl,deleteUrl:config.properties.fileDeleteUrl,downloadUrl:config.properties.fileDownloadUrl,fileExistsUrl:config.properties.fileExistsUrl,path:config.properties.path,root:config.properties.root},qtiCreatorContext:config.qtiCreatorContext,locations:config.properties.locations}),creatorRenderer.getAssetManager().setData({baseUrl:config.properties.baseUrl||""}),creatorRenderer.setAreaBroker(areaBroker),_.assign(creatorRenderer,{getCreatorContext:function(){return this.getOption("qtiCreatorContext")}}))),creatorRenderer};return{get:get,setOption:function setOption(name,value){return get().setOption(name,value)},setOptions:function setOptions(options){return get().setOptions(options)},load:function load(qtiClasses,done){return get().load(function(){if(_.isFunction(done)){for(var _len=arguments.length,rest=Array(_len),_key=0;_key<_len;_key++)rest[_key]=arguments[_key];done.apply(this,rest)}},qtiClasses)}}}),define("taoMediaManager/qtiCreator/editor/propertiesPanel",["taoQtiItem/qtiCreator/helper/panel"],function(panel){'use strict';return function($container){panel.initSidebarAccordion($container),panel.initFormVisibilityListener()}}),define("taoMediaManager/qtiXmlRenderer/renderers/config",["taoItems/assets/manager"],function(assetManagerFactory){'use strict';var assetManager=assetManagerFactory([{name:"nomalize",handle:function(url){if(url)return url.toString().replace(/^\.?\//,"")}}]);return{name:"xmlRenderer",locations:{_container:"taoQtiItem/qtiXmlRenderer/renderers/Container",assessmentItem:"taoMediaManager/qtiXmlRenderer/renderers/Item",_tooltip:"taoQtiItem/qtiXmlRenderer/renderers/Tooltip",math:"taoQtiItem/qtiXmlRenderer/renderers/Math",img:"taoQtiItem/qtiXmlRenderer/renderers/Img",object:"taoQtiItem/qtiXmlRenderer/renderers/Object",table:"taoQtiItem/qtiXmlRenderer/renderers/Table"},options:{assetManager:assetManager}}}),define("taoMediaManager/qtiXmlRenderer/renderers/Renderer",["taoQtiItem/qtiRunner/core/Renderer","taoMediaManager/qtiXmlRenderer/renderers/config"],function(Renderer,config){'use strict';return Renderer.build(config.locations,config.name,config.options)}),define("taoMediaManager/qtiCreator/helper/xmlRenderer",["core/logger","taoMediaManager/qtiXmlRenderer/renderers/Renderer","taoQtiItem/qtiItem/core/Element"],function(loggerFactory,XmlRenderer,Element){'use strict';var logger=loggerFactory("taoMediaManager/qtiCreator/helper/xmlRenderer"),_xmlRenderer=new XmlRenderer().load();return{render:function _render(element){var xml="";try{element instanceof Element&&(xml=element.render(_xmlRenderer))}catch(e){logger.error(e)}return xml},get:function get(){return _xmlRenderer}}}),define("taoMediaManager/qtiCreator/editor/interactionsPanel",["lodash","i18n","taoQtiItem/qtiCreator/editor/interactionsToolbar","taoQtiItem/qtiCreator/helper/panel"],function(_,__,interactionsToolbar,panel){'use strict';return function($container){var tagTitles={inlineInteractions:__("Inline Interactions")},interactions={_container:{label:__("Text Block"),icon:"icon-font",description:__("Block contains the content (stimulus) of the item such as text or image. It is also required for Inline Interactions."),short:__("Block"),qtiClass:"_container",tags:[tagTitles.inlineInteractions,"text"],group:__("inline-interactions")}};interactionsToolbar.create($container,interactions),panel.initSidebarAccordion($container),panel.toggleInlineInteractionGroup()}}),define("taoMediaManager/qtiCreator/sharedStimulusCreator",["jquery","lodash","i18n","core/eventifier","taoQtiItem/qtiCreator/context/qtiCreatorContext","taoMediaManager/qtiCreator/helper/sharedStimulusLoader","taoMediaManager/qtiCreator/helper/creatorRenderer","taoQtiItem/qtiCreator/helper/commonRenderer","taoQtiItem/qtiCreator/helper/xincludeRenderer","taoMediaManager/qtiCreator/editor/propertiesPanel","taoQtiItem/qtiCreator/model/helper/event","taoMediaManager/qtiCreator/helper/xmlRenderer","taoQtiItem/qtiItem/helper/xmlNsHandler","core/request","util/url","taoMediaManager/qtiCreator/editor/interactionsPanel"],function($,_,__,eventifier,qtiCreatorContextFactory,sharedStimulusLoader,creatorRenderer,commonRenderer,xincludeRenderer,propertiesPanel,eventHelper,xmlRenderer,xmlNsHandler,request,urlUtil,interactionPanel){'use strict';var loadSharedStimulus=function(id,uri,assetDataUrl){return new Promise(function(resolve,reject){sharedStimulusLoader.loadSharedStimulus({id:id,uri:uri,assetDataUrl:assetDataUrl},function(item){item||reject(new Error("Unable to load the Shared Stimulus")),item.data("uri",uri),resolve(item)})})};return function(config,areaBroker,pluginFactories){var itemCreator,qtiCreatorContext=qtiCreatorContextFactory(),plugins={},pluginRun=function(method){var execStack=[];return _.forEach(plugins,function(plugin){_.isFunction(plugin[method])&&execStack.push(plugin[method]())}),Promise.all(execStack)};if(!_.isPlainObject(config))throw new TypeError("The item creator configuration is required");if(!config.properties||_.isEmpty(config.properties.uri)||_.isEmpty(config.properties.baseUrl))throw new TypeError("The creator configuration must contains the required properties triples: uri, label and baseUrl");if(!areaBroker)throw new TypeError("Without an areaBroker there are no chance to see something you know");return itemCreator=eventifier({init:function init(){var _this=this;return _.forEach(pluginFactories,function(pluginFactory){var plugin=pluginFactory(_this,areaBroker);plugins[plugin.getName()]=plugin}),$(document).off(".qti-widget"),this.on("save",function(silent){var item=_this.getItem(),xml=xmlNsHandler.restoreNs(xmlRenderer.render(item),item.getNamespaces());request({url:urlUtil.route("patch","SharedStimulus","taoMediaManager",{id:config.properties.id}),type:"POST",contentType:"application/json",dataType:"json",data:JSON.stringify({body:xml}),method:"PATCH",noToken:!0}).then(function(){silent||_this.trigger("success"),_this.trigger("saved")}).catch(function(err){_this.trigger("error",err)})}),this.on("exit",function(){$(".item-editor-item",areaBroker.getItemPanelArea()).empty(),this.destroy()}),loadSharedStimulus(config.properties.id,config.properties.uri,config.properties.assetDataUrl).then(function(item){return _.isObject(item)?(_this.item=item,!0):void _this.trigger("error",new Error("Unable to load the item ".concat(config.properties.label)))}).then(function(){return pluginRun("init")}).then(function(){_this.trigger("init",_this.item)}).then(function(){return qtiCreatorContext.on("error",function(err){_this.trigger("error",err)}),qtiCreatorContext.init()}).catch(function(err){_this.trigger("error",err)}),this},render:function render(){var _this2=this,self=this,item=this.getItem();return item&&_.isFunction(item.getUsedClasses)?(commonRenderer.setContext(areaBroker.getItemPanelArea()),commonRenderer.get(!0,config).setOption("baseUrl",config.properties.baseUrl),interactionPanel(areaBroker.getInteractionPanelArea()),$(document).on("ready.qti-widget",function(e,elt){"assessmentItem"===elt.element.qtiClass&&_this2.trigger("ready")}),config.qtiCreatorContext=qtiCreatorContext,creatorRenderer.get(!0,config,areaBroker).setOptions(config.properties).load(function(){var widget;item.setRenderer(this),areaBroker.getItemPanelArea().append(item.render()),Promise.all(item.postRender(_.clone(config.properties))).then(function(){return areaBroker.getContainer().data("widget",item),widget=item.data("widget"),_.each(item.getComposingElements(),function(element){"include"===element.qtiClass&&xincludeRenderer.render(element.data("widget"),config.properties.baseUrl)}),propertiesPanel(areaBroker.getPropertyPanelArea(),widget,config.properties),eventHelper.initElementToWidgetListeners(),pluginRun("render").then(function(){self.trigger("render")})}).catch(function(err){self.trigger("error",err)})},item.getUsedClasses()),this):this.trigger("error",new Error("We need an item to render."))},destroy:function destroy(){var _this3=this;return $(document).off(".qti-widget"),pluginRun("destroy").then(function(){return qtiCreatorContext.destroy()}).then(function(){_this3.trigger("destroy")}).catch(function(err){_this3.trigger("error",err)}),this},getItem:function getItem(){return this.item},getSharedStimulusId:function getSharedStimulusId(){return config.properties.id},getConfig:function getConfig(){return config}}),itemCreator}}),define("tpl!taoMediaManager/qtiCreator/component/tpl/sharedStimulusAuthoring",["handlebars"],function(hb){return hb.template(function(Handlebars,depth0,helpers,partials,data){this.compilerInfo=[4,">= 1.0.0"],helpers=this.merge(helpers,Handlebars.helpers),data=data||{};var helper,options,buffer="",helperMissing=helpers.helperMissing,escapeExpression=this.escapeExpression;return buffer+="<div id=\"item-editor-scope\" data-content-target=\"wide\">\n\n <nav class=\"action-bar plain content-action-bar horizontal-action-bar\">\n <ul class=\"menu-left action-group plain item-editor-menu\"></ul>\n\n <ul class=\"menu action-group plain item-editor-menu\"></ul>\n\n <ul class=\"menu-right action-group plain item-editor-menu\"></ul>\n </nav>\n <div class=\"wrapper clearfix content sidebar-popup-parent\" id=\"item-editor-wrapper\">\n\n <!-- interaction panel -->\n <div class=\"item-editor-sidebar-wrapper left-bar\">\n <form class=\"item-editor-sidebar\" id=\"item-editor-interaction-bar\" autocomplete=\"off\"></form>\n </div>\n\n <!-- item panel -->\n <main id=\"item-editor-panel\" class=\"clearfix\">\n\n <div class=\"item-editor-bar\">\n <h1 class=\"truncate\"></h1>\n <div id=\"toolbar-top\"></div>\n </div>\n\n <div id=\"item-editor-scoll-container\">\n <div id=\"item-editor-scroll-outer\">\n <div id=\"item-editor-scroll-inner\">\n <!-- item goes here -->\n </div>\n </div>\n </div>\n\n </main>\n\n <!-- properties panel -->\n <div class=\"item-editor-sidebar-wrapper right-bar sidebar-popup-parent\">\n <div class=\"item-editor-sidebar\" id=\"item-editor-item-widget-bar\">\n <div class=\"item-editor-item-related sidebar-right-section-box\" id=\"item-editor-item-property-bar\">\n <section class=\"tool-group clearfix\" id=\"sidebar-right-item-properties\">\n <h2>"+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"Passage Properties",options):helperMissing.call(depth0,"__","Passage Properties",options)))+"</h2>\n <div class=\"panel\"></div>\n </section>\n </div>\n <div class=\"item-editor-item-related sidebar-right-section-box\" id=\"item-editor-text-property-bar\">\n <section class=\"tool-group clearfix\" id=\"sidebar-right-text-block-properties\">\n <h2>"+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"Passage Properties",options):helperMissing.call(depth0,"__","Passage Properties",options)))+"</h2>\n <div class=\"panel\"></div>\n </section>\n </div>\n <div class=\"item-editor-body-element-related sidebar-right-section-box\" id=\"item-editor-body-element-property-bar\">\n <section class=\"tool-group clearfix\" id=\"sidebar-right-body-element-properties\">\n <h2><?= __('Element Properties') ?></h2>\n\n <div class=\"panel\"></div>\n </section>\n </div>\n </div>\n </div>\n <!-- /properties panel -->\n\n\n </div>\n\n <div id=\"mediaManager\"></div>\n <div id=\"modal-container\"></div>\n</div>",buffer})}),define("taoMediaManager/qtiCreator/component/sharedStimulusAuthoring",["lodash","ui/component","core/pluginLoader","taoMediaManager/qtiCreator/sharedStimulusCreator","taoQtiItem/qtiCreator/editor/areaBroker","tpl!taoMediaManager/qtiCreator/component/tpl/sharedStimulusAuthoring","context","css!taoQtiItemCss/qti-runner.css","css!taoQtiItemCss/themes/default.css","css!taoQtiItemCss/item-creator.css"],function(_,componentFactory,pluginLoaderFactory,sharedStimulusCreatorFactory,areaBrokerFactory,componentTpl,context){'use strict';var defaultPlugins=[{module:"taoQtiItem/qtiCreator/plugins/content/title",bundle:"taoQtiItem/loader/taoQtiItem.min",category:"content"},{module:"taoMediaManager/qtiCreator/plugins/navigation/back",bundle:"taoMediaManager/loader/taoMediaManager.min",category:"menu"},{module:"taoMediaManager/qtiCreator/plugins/menu/save",bundle:"taoMediaManager/loader/taoMediaManager.min",category:"menu"},{module:"taoMediaManager/qtiCreator/plugins/menu/preview",bundle:"taoMediaManager/loader/taoMediaManager.min",category:"menu"},{module:"taoQtiItem/qtiCreator/plugins/content/changeTracker",bundle:"taoQtiItem/loader/taoQtiItem.min",category:"content"},{module:"taoMediaManager/qtiCreator/plugins/content/blockAdder",bundle:"taoMediaManager/loader/taoMediaManager.min",category:"content"}];return function(container){var areaBroker,sharedStimulusCreator,config=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},plugins=Array.isArray(config.plugins)?config.plugins:[];config.plugins=[].concat(defaultPlugins,_toConsumableArray(plugins));var pluginLoader=pluginLoaderFactory(),sharedStimulusAuthoring=componentFactory({getAreaBroker:function getAreaBroker(){return areaBroker}}).setTemplate(componentTpl).on("init",function(){var _this4=this;_.forEach(this.getConfig().plugins,function(plugin){plugin&&plugin.module&&(plugin.exclude?pluginLoader.remove(plugin.module):pluginLoader.add(plugin))}),pluginLoader.load(!!context.bundle).then(function(){return _this4.render(container)}).catch(function(err){return _this4.trigger("error",err)})}).on("render",function(){var $container=this.getElement();areaBroker=areaBrokerFactory($container,{menu:$container.find(".menu"),menuLeft:$container.find(".menu-left"),menuRight:$container.find(".menu-right"),contentCreatorPanel:$container.find("#item-editor-panel"),editorBar:$container.find("#item-editor-panel .item-editor-bar"),title:$container.find("#item-editor-panel .item-editor-bar h1"),toolbar:$container.find("#item-editor-panel .item-editor-bar #toolbar-top"),interactionPanel:$container.find("#item-editor-interaction-bar"),propertyPanel:$container.find("#item-editor-item-widget-bar"),itemPanel:$container.find("#item-editor-scroll-inner"),itemPropertyPanel:$container.find("#sidebar-right-item-properties"),itemStylePanel:$container.find("#item-style-editor-bar"),modalContainer:$container.find("#modal-container"),elementPropertyPanel:$container.find("#item-editor-body-element-property-bar .panel")}),sharedStimulusCreator=sharedStimulusCreatorFactory(this.getConfig(),areaBroker,pluginLoader.getPlugins()).spread(this,"error success ready").on("init",function(){this.render()}).on("destroy",function(){sharedStimulusCreator=null,sharedStimulusAuthoring.destroy()}).init()}).on("destroy",function(){sharedStimulusCreator&&sharedStimulusCreator.destroy(),sharedStimulusCreator=null,areaBroker=null});return _.defer(function(){return sharedStimulusAuthoring.init(config)}),sharedStimulusAuthoring}}),define("taoMediaManager/controller/authoring",["i18n","lodash","jquery","uri","taoMediaManager/qtiCreator/component/sharedStimulusAuthoring","ui/feedback","util/url","core/dataProvider/request","core/logger"],function(__,_,$,uri,sharedStimulusAuthoringFactory,feedback,urlUtil,request,loggerFactory){'use strict';var logger=loggerFactory("taoMediaManager/authoring");return{start:function start(){var $panel=$("#panel-authoring"),assetDataUrl=urlUtil.route("get","SharedStimulus","taoMediaManager"),assetId=uri.decode($panel.attr("data-id")),previewEnabled=!1;request(assetDataUrl,{id:assetId}).then(function(response){"READ"==response.permissions&&(previewEnabled=!0)}).then(function(){sharedStimulusAuthoringFactory($panel,{properties:{uri:$panel.attr("data-uri"),id:assetId,assetDataUrl:assetDataUrl,fileUploadUrl:urlUtil.route("upload","ItemContent","taoItems"),fileDeleteUrl:urlUtil.route("delete","ItemContent","taoItems"),fileDownloadUrl:urlUtil.route("download","ItemContent","taoItems"),fileExistsUrl:urlUtil.route("fileExists","ItemContent","taoItems"),getFilesUrl:urlUtil.route("files","ItemContent","taoItems"),baseUrl:urlUtil.route("getFile","MediaManager","taoMediaManager",{uri:""}),path:"taomedia://mediamanager/",root:"mediamanager",lang:"en-US",previewEnabled:previewEnabled}}).on("success",function(){feedback().success(__("Your passage is saved"))}).on("error",function(err){_.isUndefined(err.message)||feedback().error(err.message),logger.error(err)})})}}}),define("taoMediaManager/previewer/component/qtiSharedStimulusItem",["context","taoQtiTestPreviewer/previewer/runner","css!taoQtiTestPreviewer/previewer/provider/item/css/item"],function(context,previewerFactory){'use strict';return function(container){var config=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},template=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,testRunnerConfig={testDefinition:"test-container",serviceCallId:"previewer",providers:{runner:{id:"qtiItemPreviewer",module:"taoQtiTestPreviewer/previewer/provider/item/item",bundle:"taoQtiTestPreviewer/loader/qtiPreviewer.min",category:"runner"},proxy:{id:"qtiSharedStimulusItemProxy",module:"taoMediaManager/previewer/proxy/qtiSharedStimulusItem",bundle:"taoMediaManager/loader/taoMediaManager.min",category:"proxy"},communicator:{id:"request",module:"core/communicator/request",bundle:"loader/vendor.min",category:"communicator"},plugins:config.plugins||[]},options:{view:config.view,readOnly:config.readOnly,fullPage:config.fullPage,plugins:config.pluginsOptions,hideActionBars:config.hideActionBars},proxyProvider:"qtiSharedStimulusItemProxy"};return testRunnerConfig.loadFromBundle=!!context.bundle,previewerFactory(container,testRunnerConfig,template).on("ready",function(runner){if(config.itemState&&runner.on("renderitem",function(){return runner.itemRunner.setState(config.itemState)}),config.itemUri)return runner.loadItem(config.itemUri)})}}),define("taoMediaManager/controller/editInstance",["jquery","lodash","layout/actions/binder","ui/previewer","util/url","taoMediaManager/previewer/component/qtiSharedStimulusItem","core/logger","ui/feedback"],function($,_,binder,previewer,urlUtil,qtiItemPreviewerFactory,loggerFactory,feedback){'use strict';var logger=loggerFactory("taoMediaManager/editInstance");return{start:function start(){var $previewer=$(".previewer"),file={};file.url=$previewer.data("url"),file.mime=$previewer.data("type");var isPreviewEnabled=$previewer.data("enabled"),isPassage="application/qti+xml"===file.mime;isPreviewEnabled&&(isPassage?qtiItemPreviewerFactory($previewer,{itemUri:$("#edit-media").data("uri")}).on("error",function(err){_.isUndefined(err.message)||feedback().error(err.message),logger.error(err)}):(file.containerClass="no-background",$previewer.previewer(file))),isPassage?$("#media-authoring").show():$("#media-authoring").hide(),$("#edit-media").off().on("click",function(){var action={binding:"load",url:urlUtil.route("editMedia","MediaImport","taoMediaManager")};binder.exec(action,{classUri:this.dataset.classuri,id:this.dataset.uri}||this._resourceContext)})}}}),define("taoMediaManager/controller/routes",[],function(){'use strict';return{MediaManager:{deps:"controller/actions",actions:{editInstance:"controller/editInstance",authoring:"controller/authoring"}}}}),define("taoMediaManager/previewer/adapter/item/qtiSharedStimulusItem",["lodash","core/logger","taoMediaManager/previewer/component/qtiSharedStimulusItem","ui/feedback"],function(_,loggerFactory,qtiItemPreviewerFactory,feedback){'use strict';var logger=loggerFactory("taoMediaManager/previewer"),defaultPlugins=[{module:"taoQtiTestPreviewer/previewer/plugins/controls/close",bundle:"taoQtiTestPreviewer/loader/qtiPreviewer.min",category:"controls"},{module:"taoQtiTestPreviewer/previewer/plugins/tools/scale/scale",bundle:"taoQtiTestPreviewer/loader/qtiPreviewer.min",category:"tools"},{module:"taoQtiTest/runner/plugins/tools/itemThemeSwitcher/itemThemeSwitcher",bundle:"taoQtiTest/loader/testPlugins.min",category:"tools"}];return{name:"qtiSharedStimulusItem",init:function init(sharedStimulusId){var config=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return config.itemUri=sharedStimulusId,config.plugins=Array.isArray(config.plugins)?[].concat(defaultPlugins,_toConsumableArray(config.plugins)):defaultPlugins,qtiItemPreviewerFactory(window.document.body,config).on("error",function(err){_.isUndefined(err.message)||feedback().error(err.message),logger.error(err)})}}}),define("taoMediaManager/previewer/proxy/qtiSharedStimulusItem",["jquery","lodash","i18n","core/promiseQueue","core/dataProvider/request","util/url","taoMediaManager/qtiCreator/helper/createDummyItemData"],function($,_,__,promiseQueue,request,urlUtil,creatorDummyItemData){'use strict';return{name:"qtiSharedStimulusItemProxy",install:function(){this.queue=promiseQueue()},init:function(){return Promise.resolve({})},destroy:function(){return this.queue=null,Promise.resolve()},getItem:function(identifier){return request(urlUtil.route("get","SharedStimulus","taoMediaManager"),{id:identifier},"GET").then(function(data){var itemData=creatorDummyItemData(data);return data.baseUrl=urlUtil.route("getFile","MediaManager","taoMediaManager",{uri:""}),data.content={type:"qti",data:itemData},data})}}}),define("taoMediaManager/qtiCreator/widgets/helpers/content",["jquery","lodash","taoMediaManager/qtiCreator/helper/creatorRenderer","taoQtiItem/qtiCreator/model/helper/container","taoQtiItem/qtiCreator/editor/gridEditor/content"],function($,_,creatorRenderer,containerHelper,gridContentHelper){'use strict';return{createElements:function(container,$container,data,callback){var $dummy=$("<div>").html(data);containerHelper.createElements(container,gridContentHelper.getContent($dummy),function(newElts){creatorRenderer.get().load(function(){_.each(newElts,function(serial){var $placeholder,$widget,widget;$placeholder=$container.find(".widget-box[data-new][data-qti-class=".concat(serial.qtiClass,"]")),serial.setRenderer(this),serial.render($placeholder),serial.postRender(),widget=serial.data("widget"),$widget=widget.$original,$widget.trigger("contentChange.gridEdit"),_.isFunction(callback)&&callback(widget)}.bind(this))},this.getUsedClasses())})},changeInnerWidgetState:function(outerWidget,state){var selector=[];_.forEach(["img","math","object","include"],function(qtiClass){selector.push("[data-html-editable] .widget-".concat(qtiClass))}),outerWidget.$container.find(selector.join(",")).each(function(){var innerWidget=$(this).data("widget");innerWidget&&innerWidget.changeState(state)})}}}),define("taoMediaManager/qtiCreator/widgets/states/Active",["jquery","taoQtiItem/qtiCreator/widgets/states/factory","taoMediaManager/qtiCreator/widgets/helpers/content"],function($,stateFactory,contentHelper){'use strict';return stateFactory.create("active",function(){function checkIfWidgetShouldSleep(e){return container!==e.target&&!$.contains(container,e.target)&&$.contains(outerContainer,e.target)&&(!areaBroker||!areaBroker.getEditorBarArea||!$.contains(areaBroker.getEditorBarArea().get(0),e.target))&&(!$modalFeedbacksArea.length||!$.contains($modalFeedbacksArea[0],e.target))&&"restore"!==$(e.target).data("role")&&!$(e.target).closest(".widget-popup").length}var _widget=this.widget,container=_widget.$container[0],item=_widget.element.getRootElement(),areaBroker=_widget.getAreaBroker(),$modalFeedbacksArea=$("#modalFeedbacks"),outerContainer=document.querySelector("#item-editor-scroll-outer");areaBroker.getContentCreatorPanelArea().on("mousedown.active.".concat(_widget.serial),function(e){checkIfWidgetShouldSleep(e)&&_widget.changeState("sleep")}).on("beforesave.qti-creator.active",function(){_widget.changeState("sleep")}).on("styleedit.active",function(){_widget.changeState("sleep")}),$(document).on("open-preview.qti-item",function(){_widget.changeState("sleep")}),item&&item.data("widget")&&item.data("widget").$container.on("resizestart.gridEdit.active beforedragoverstart.gridEdit.active",function(){_widget.changeState("sleep")})},function(){var areaBroker=this.widget.getAreaBroker();contentHelper.changeInnerWidgetState(this.widget,"sleep"),this.widget.$container.off(".active"),areaBroker.getContentCreatorPanelArea().off(".active.".concat(this.widget.serial));var item=this.widget.element.getRootElement();item&&item.data("widget")&&item.data("widget").$container.off(".active")})}),define("taoMediaManager/qtiCreator/widgets/static/states/Active",["jquery","taoQtiItem/qtiCreator/widgets/states/factory","taoMediaManager/qtiCreator/widgets/states/Active"],function($,stateFactory,Active){'use strict';return stateFactory.extend(Active,function(){var _widget=this.widget,$container=_widget.$container;_widget.beforeStateInit(function(e,element,state){var composingElts,serial=element.getSerial();("active"===state.name&&serial!==_widget.serial||"choice"===state.name)&&("rubricBlock"===_widget.element.qtiClass?(composingElts=_widget.element.getComposingElements(),!composingElts[element.serial]&&_widget.changeState("sleep")):_widget.changeState("sleep"))},"otherActive"),$container.on("mouseenter.active",function(e){e.stopPropagation(),$container.parent().trigger("mouseleave.sleep")}).on("mouseleave.active",function(e){e.stopPropagation(),$container.parent().trigger("mouseenter.sleep")}).on("click.active",function(e){e.stopPropagation()})},function(){var _widget=this.widget,areaBroker=_widget.getAreaBroker();_widget.$container.off(".active"),areaBroker.getContentCreatorPanelArea().off(".active.".concat(_widget.serial)),_widget.offEvents("otherActive")})}),define("taoMediaManager/qtiCreator/helper/ckConfigurator",["lodash","ui/ckeditor/ckConfigurator","mathJax"],function(_,ckConfigurator,mathJax){'use strict';var _defaults={qtiImage:!0,qtiMedia:!0,qtiInclude:!1,underline:!0,mathJax:!!mathJax,removePlugins:"taoqtiinclude"};return{getConfig:function getConfig(editor){var toolbarType=1<arguments.length&&arguments[1]!==void 0?arguments[1]:"qtiInline",options=2<arguments.length?arguments[2]:void 0;return ckConfigurator.getConfig(editor,toolbarType,_.defaults(options||{},_defaults))}}}),define("taoMediaManager/qtiCreator/editor/ckEditor/htmlEditor",["lodash","i18n","jquery","ckeditor","core/promise","taoMediaManager/qtiCreator/helper/ckConfigurator","taoQtiItem/qtiItem/core/Element","taoMediaManager/qtiCreator/widgets/helpers/content","taoQtiItem/qtiCreator/widgets/helpers/deletingState"],function(_,__,$,CKEditor,Promise,ckConfigurator,Element,contentHelper,deletingHelper){'use strict';function _buildEditor($editable,$editableContainer,options){var ckConfig,widget=(options.data||{}).widget,areaBroker=widget&&widget.getAreaBroker&&widget.getAreaBroker(),$toolbarArea=areaBroker&&areaBroker.getToolbarArea&&areaBroker.getToolbarArea();if(options=_.defaults(options,_defaults),!($editable instanceof $)||!$editable.length)throw new Error("invalid jquery element for $editable");if(!($editableContainer instanceof $)||!$editableContainer.length)throw new Error("invalid jquery element for $editableContainer");return options.placeholder&&""!==options.placeholder&&($editable.is("input")?$editable.attr("placeholder",options.placeholder):$editable.attr("data-placeholder",options.placeholder)),ckConfig={dtdMode:"qti",autoParagraph:!1,removePlugins:options.removePlugins||"",enterMode:options.enterMode||CKEditor.ENTER_P,floatSpaceDockedOffsetY:10,sharedSpaces:{top:$toolbarArea&&$toolbarArea.attr("id")||"toolbar-top"},taoQtiItem:{insert:function insert(tempWidget){var $newContent=$(tempWidget).clone();options.data&&options.data.container&&options.data.widget&&contentHelper.createElements(options.data.container,$editable,_htmlEncode(this.getData()),function(createdWidget){var createdElement=createdWidget.element;_.isFunction(createdElement.initContainer)&&(createdElement.body($newContent.html()),createdWidget.rebuild(),createdWidget=createdElement.data("widget")),_activateInnerWidget(options.data.widget,createdWidget)})}},on:{instanceReady:function instanceReady(e){var widgets={},editor=e.editor;$editable.data("editor",editor),$editable.data("editor-options",options),editor.on("change",_.debounce(function(){_detectWidgetDeletion($editable,widgets,editor),_.isFunction(options.change)&&options.change.call(editor,_htmlEncode(editor.getData()))},100,{leading:!0})),managePlaceholder($editable,editor),options.data&&options.data.container&&($editable.data("qti-container",options.data.container),widgets=_rebuildWidgets(options.data.container,$editable,{restoreState:!0}),options.shieldInnerContent&&_shieldInnerContent($editable,options.data.widget)),options.autofocus&&_focus(editor),$editable.trigger("editorready",[editor]),$(".qti-item").trigger("toolbarchange")},blur:function blur(){$toolbarArea&&$toolbarArea.hide()},focus:function focus(){$toolbarArea&&$toolbarArea.show(),_.isFunction(options.focus)&&options.focus.call(this,_htmlEncode(this.getData())),$editable.trigger("editorfocus"),$(".qti-item").trigger("toolbarchange")},configLoaded:function configLoaded(e){var toolbarType="";options.toolbar&&_.isArray(options.toolbar)?ckConfig.toolbar=options.toolbar:toolbarType=getTooltypeFromContainer($editableContainer),"undefined"!=typeof options.qtiMedia&&(ckConfig.qtiMedia=options.qtiMedia),"undefined"!=typeof options.qtiImage&&(ckConfig.qtiImage=options.qtiImage),"undefined"!=typeof options.qtiInclude&&(ckConfig.qtiInclude=options.qtiInclude),"undefined"!=typeof options.highlight&&(ckConfig.highlight=options.highlight),e.editor.config=ckConfigurator.getConfig(e.editor,toolbarType,ckConfig)},afterPaste:function afterPaste(){}}},CKEditor.inline($editable[0],ckConfig)}function managePlaceholder($editable,editor){$editable.is("input")||(togglePlaceholder($editable),editor.on("change",function(){togglePlaceholder($editable)}))}function togglePlaceholder($editable){""!==$editable.text().trim()||$editable.find(["img","table","math","object","printedVariable",".tooltip-target"].join(",")).length?removePlaceholder($editable):$editable.addClass("cke-placeholder")}function removePlaceholder($editable){$editable.removeClass("cke-placeholder")}function getTooltypeFromContainer($editableContainer){var toolbarType="qtiFlow";return $editableContainer.hasClass("widget-blockInteraction")||$editableContainer.hasClass("widget-textBlock")||$editableContainer.hasClass("widget-rubricBlock")?toolbarType="qtiBlock":($editableContainer.hasClass("qti-prompt-container")||$editableContainer.hasClass("widget-hottext"))&&(toolbarType="qtiInline"),toolbarType}function _find($container,dataAttribute){var $collection;return $collection=$container.data(dataAttribute)?$container:$container.find("[data-".concat(dataAttribute,"=true]")),$collection}function _rebuildWidgets(container,$container,options){var widgets={};return options=options||{},_.each(_.values(container.elements),function(elt){var widget=elt.data("widget"),currentState=widget.getCurrentState().name;widgets[elt.serial]=widget.rebuild({context:$container,ready:function ready(elWidget){options.restoreState&&elWidget.changeState(currentState)}})}),$container.trigger("widgetCreated",[widgets,container]),widgets}function _findWidgetContainer($container,serial){return $container.find(".widget-box[data-serial='".concat(serial,"']"))}function _detectWidgetDeletion($container,widgets,editor){var $widget,deleted=[],container=$container.data("qti-container");if(_.each(widgets,function(w){w.element.data("removed")||($widget=_findWidgetContainer($container,w.serial),!$widget.length&&deleted.push(w))}),deleted.length){var undoCmd=editor.getCommand("undo"),$messageBox=deletingHelper.createInfoBox(deleted);$messageBox.on("confirm.deleting",function(){_.each(deleted,function(w){w.element.remove(),w.destroy()}),editor.resetUndo()}).on("undo.deleting",function(){editor.undoManager.undo(),_rebuildWidgets(container,$container,{restoreState:!0}),_shieldInnerContent($container,container.data("widget"))}),undoCmd&&undoCmd.on("afterUndo",function(){$messageBox.find("a.undo").click()})}}function addShield($widget){var $shield=$("<button>",{class:"html-editable-shield"});return $widget.attr("contenteditable",!1),$widget.append($shield),$shield}function _shieldInnerContent($container,containerWidget){$container.find(".widget-box").each(function(){var $widget=$(this);addShield($widget).on("click",function(e){var innerWidget;e.stopPropagation(),innerWidget=$widget.data("widget"),_activateInnerWidget(containerWidget,innerWidget)})})}function _activateInnerWidget(containerWidget,innerWidget){var listenToWidgetCreation,event="widgetCreated.".concat(innerWidget.serial);containerWidget&&containerWidget.element&&containerWidget.element.qtiClass?(listenToWidgetCreation=function(){containerWidget.$container.on(event,function(e,widgets){var targetWidget=widgets[innerWidget.serial];targetWidget&&(containerWidget.$container.off(event),_.delay(function(){Element.isA(targetWidget.element,"interaction")?targetWidget.changeState("question"):targetWidget.changeState("active")},100))})},Element.isA(containerWidget.element,"_container")&&!containerWidget.element.data("stateless")?(listenToWidgetCreation(),containerWidget.changeState("sleep")):Element.isA(containerWidget.element,"interaction")?(listenToWidgetCreation(),containerWidget.changeState("sleep")):Element.isA(containerWidget.element,"choice")?(listenToWidgetCreation(),containerWidget.changeState("question")):Element.isA(containerWidget.element,"table")?(listenToWidgetCreation(),containerWidget.changeState("sleep")):Element.isA(innerWidget.element,"choice")?innerWidget.changeState("choice"):innerWidget.changeState("active")):innerWidget.changeState("active")}function _htmlEncode(encodedStr){return encodedStr}function _focus(editor){if(editor.editable()&&editor.editable().$.parentNode){editor.focus();var range=editor.createRange();range.moveToElementEditablePosition(editor.editable(),!0),editor.getSelection().selectRanges([range])}}var editorFactory,_defaults={placeholder:__("some text ..."),shieldInnerContent:!0,passthroughInnerContent:!1,autofocus:!0};return CKEditor.disableAutoInline=!0,editorFactory={hasEditor:function($container){var hasEditor=!1;return _find($container,"html-editable").each(function(){return hasEditor=!!$(this).data("editor"),hasEditor}),hasEditor},buildEditor:function buildEditor($container,editorOptions){var buildTasks=[];return _find($container,"html-editable-container").each(function(){var $editableContainer=$(this),$editable=$editableContainer.find("[data-html-editable]");buildTasks.push(new Promise(function(resolve){$editable.attr("contenteditable",!0),_buildEditor($editable,$editableContainer,editorOptions),$editable.on("editorready",resolve)}))}),Promise.all(buildTasks)},destroyEditor:function destroyEditor($container){var destructTasks=[];return _find($container,"html-editable-container").each(function(){var editor,options,$editableContainer=$(this),$editable=$editableContainer.find("[data-html-editable]");$editable.removeAttr("contenteditable"),$editable.data("editor")&&destructTasks.push(new Promise(function(resolve){editor=$editable.data("editor"),options=$editable.data("editor-options"),_.isFunction(options.change)&&options.change.call(editor,_htmlEncode(editor.getData())),removePlaceholder($editable),editor.on("destroy",function(){$editable.removeData("editor").removeData("editor-options"),$editable.data("qti-container")&&_rebuildWidgets($editable.data("qti-container"),$editable),$editable.trigger("editordestroyed"),resolve()}),editor.focusManager.blur(!0),editor.destroy()}))}),Promise.all(destructTasks)},getData:function getData($editable){var editor=$editable.data("editor");if(editor)return _htmlEncode(editor.getData());throw new Error("no editor attached to the DOM element")},setData:function setData($editable,data){var editor=$editable.data("editor");if(editor)_.isString(data)&&editor.setData(_.escape(data));else throw new Error("no editor attached to the DOM element")},focus:function focus($editable){_find($editable,"html-editable").each(function(){var editor=$(this).data("editor");editor&&_focus(editor)})}},editorFactory}),define("tpl!taoMediaManager/qtiCreator/tpl/forms/static/text",["handlebars"],function(hb){return hb.template(function(Handlebars,depth0,helpers,partials,data){this.compilerInfo=[4,">= 1.0.0"],helpers=this.merge(helpers,Handlebars.helpers),data=data||{};var stack1,helper,options,buffer="",helperMissing=helpers.helperMissing,escapeExpression=this.escapeExpression;return buffer+="<div class=\"panel\">\n <label for=\"textBlockCssClass\">"+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"Text Block CSS Class",options):helperMissing.call(depth0,"__","Text Block CSS Class",options)))+"</label>\n <span class=\"icon-help tooltipstered\" data-tooltip=\"~ .tooltip-content:first\" data-tooltip-theme=\"info\"></span>\n <div class=\"tooltip-content\">"+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"Set a CSS class name in order to customize the display style.",options):helperMissing.call(depth0,"__","Set a CSS class name in order to customize the display style.",options)))+"</div>\n <input type=\"text\" name=\"textBlockCssClass\" value=\"",(helper=helpers.textBlockCssClass)?stack1=helper.call(depth0,{hash:{},data:data}):(helper=depth0&&depth0.textBlockCssClass,stack1="function"===_typeof(helper)?helper.call(depth0,{hash:{},data:data}):helper),buffer+=escapeExpression(stack1)+"\" />\n</div>",buffer})}),define("taoMediaManager/qtiCreator/widgets/static/text/states/Active",["taoQtiItem/qtiCreator/widgets/states/factory","taoMediaManager/qtiCreator/widgets/static/states/Active","taoMediaManager/qtiCreator/editor/ckEditor/htmlEditor","taoQtiItem/qtiCreator/editor/gridEditor/content","taoQtiItem/qtiCreator/widgets/helpers/formElement","tpl!taoMediaManager/qtiCreator/tpl/forms/static/text"],function(stateFactory,Active,htmlEditor,content,formElement,formTpl){'use strict';var TextActive=stateFactory.extend(Active,function(){this.buildEditor(),this.initForm()},function(){this.destroyEditor(),this.widget.$form.empty()});return TextActive.prototype.buildEditor=function(){var widget=this.widget,$editableContainer=widget.$container,container=widget.element,changeCallback=content.getChangeCallback(container);$editableContainer.attr("data-html-editable-container",!0),htmlEditor.hasEditor($editableContainer)||htmlEditor.buildEditor($editableContainer,{change:function change(data){changeCallback.call(this,data),data||widget.$form.find("[name=\"textBlockCssClass\"]").val("")},blur:function blur(){widget.changeState("sleep")},data:{widget:widget,container:container}})},TextActive.prototype.destroyEditor=function(){htmlEditor.destroyEditor(this.widget.$container)},TextActive.prototype.initForm=function(){var widget=this.widget,$form=widget.$form,blockCls=widget.$container.find(".".concat("custom-text-box")).attr("class");$form.html(formTpl({textBlockCssClass:(blockCls||"").replace("custom-text-box","").trim()})),formElement.initWidget($form),formElement.setChangeCallbacks($form,widget.element,{textBlockCssClass:function textBlockCssClass(element,value){var $block=widget.$container.find(".".concat("custom-text-box"));value=value.trim(),"custom-text-box"===value&&(value=""),value?(!$block.length&&($block=widget.$container.find("[data-html-editable=\"true\"]").wrapInner("<div />").children()),$block.attr("class","".concat("custom-text-box"," ").concat(value))):$block.children().unwrap()}})},TextActive}),define("taoMediaManager/qtiCreator/widgets/static/text/states/states",["taoQtiItem/qtiCreator/widgets/states/factory","taoQtiItem/qtiCreator/widgets/static/states/states","taoQtiItem/qtiCreator/widgets/static/text/states/Sleep","taoMediaManager/qtiCreator/widgets/static/text/states/Active"],function(factory,states){'use strict';return factory.createBundle(states,arguments)}),define("taoMediaManager/qtiCreator/widgets/static/text/Widget",["jquery","taoQtiItem/qtiCreator/widgets/static/Widget","taoMediaManager/qtiCreator/widgets/static/text/states/states","tpl!taoQtiItem/qtiCreator/tpl/toolbars/textBlock"],function($,Widget,states,toolbarTpl){'use strict';var TextWidget=Widget.clone();return TextWidget.initCreator=function(){Widget.initCreator.call(this),this.registerStates(states)},TextWidget.buildContainer=function(){var $wrap=$("<div>",{"data-serial":this.element.serial,"data-qti-class":"_container",class:"widget-box widget-block widget-textBlock"}).append($("<div>",{"data-html-editable":!0}));this.$original.wrapInner($wrap),this.$container=this.$original.children(".widget-box")},TextWidget.createToolbar=function(){var _this5=this,$tlb=$(toolbarTpl({serial:this.serial,state:"active"}));return this.$container.append($tlb),$tlb.find("[data-role=\"delete\"]").on("click.widget-box",function(e){e.stopPropagation(),_this5.changeState("deleting")}),this},TextWidget}),define("taoMediaManager/qtiCreator/editor/blockAdder/blockAdder",["jquery","lodash","tpl!taoQtiItem/qtiCreator/editor/blockAdder/tpl/addColumnRow","taoQtiItem/qtiItem/core/Element","taoMediaManager/qtiCreator/helper/creatorRenderer","taoQtiItem/qtiCreator/model/helper/container","taoQtiItem/qtiCreator/editor/gridEditor/content","taoMediaManager/qtiCreator/widgets/static/text/Widget"],function($,_,adderTpl,Element,creatorRenderer,containerHelper,contentHelper,TextWidget){'use strict';function _insertElement(qtiClass,$placeholder){$placeholder.removeAttr("id"),$placeholder.addClass("widget-box"),$placeholder.attr({"data-new":!0,"data-qti-class":qtiClass});var $widget=$placeholder.parent().closest(".widget-box, .qti-item"),$editable=$placeholder.closest("[data-html-editable], .qti-itemBody"),widget=$widget.data("widget"),element=widget.element,container=Element.isA(element,"_container")?element:element.getBody();if(!element||!$editable.length)throw new Error("cannot create new element");containerHelper.createElements(container,contentHelper.getContent($editable),function(newElts){var creator=creatorRenderer.get();creator.load(function(){for(var serial in newElts){var elt=newElts[serial],$widgetElem=void 0,widgetElem=void 0,$colParent=$placeholder.parent();elt.setRenderer(this),$placeholder.replaceWith("<div class=\"text-block\"></div>");var $textBlock=$colParent.find(".text-block");$textBlock.html(elt.render()),widgetElem=TextWidget.build(elt,$textBlock,creator.getOption("textOptionForm"),{ready:function ready(){this.$container.parent(".text-block").length&&this.$container.unwrap(),this.changeState("active")}}),$widgetElem=widgetElem.$container,$widgetElem.trigger("contentChange.gridEdit"),$widgetElem.trigger("resize.gridEdit")}},this.getUsedClasses())})}return{create:function(item,$editorPanel){function _getItemBody(){return $editorPanel.find(".qti-itemBody")}function _initInsertion($widget){var $wrap=$("<div class=\"colrow\"></div>"),$colRow=$widget.parent(".colrow");$editorPanel.trigger("beforesave.qti-creator.active"),$colRow.length||($widget.wrap("<div class=\"colrow\"></div>"),$colRow=$widget.parent(".colrow")),$colRow.after($wrap);var $placeholder=$("<div class=\"placeholder\">");$wrap.addClass("tmp").prepend($placeholder),_insertElement("_container",$placeholder)}function _endInsertion(){item.body(contentHelper.getContent(_getItemBody()))}function _done($wrap){$wrap.removeClass("tmp"),_endInsertion()}function _appendButton($widget){if(!$widget.children(".add-block-element").length&&!$widget.parent(".colrow.tmp").length){var $adder=$(adderTpl());$widget.append($adder),$adder.on("click",function(e){e.preventDefault(),e.stopPropagation();var $widgetParent=$(this).parents(".widget-box");_initInsertion($widgetParent)})}}$editorPanel.find(".widget-textBlock").each(function(){_appendButton($(this))}),$editorPanel.on("ready.qti-widget",function(e,_widget){var qtiElement=_widget.element;if(qtiElement.is("_container")){var $colRow=_widget.$container.parent(".colrow");$colRow.hasClass("tmp")&&_done($colRow),$colRow.length||_widget.$container.wrap("<div class=\"colrow\"></div>"),_appendButton(_widget.$container)}})}}}),define("taoMediaManager/qtiCreator/editor/containerEditor",["lodash","jquery","core/promise","taoQtiItem/qtiItem/core/Loader","taoQtiItem/qtiCreator/model/Container","taoQtiItem/qtiCreator/model/Item","taoQtiItem/qtiCreator/model/helper/event","taoQtiItem/qtiCreator/model/qtiClasses","taoQtiItem/qtiCreator/helper/commonRenderer","taoQtiItem/qtiCreator/helper/xmlRenderer","taoQtiItem/qtiItem/helper/simpleParser","taoMediaManager/qtiCreator/helper/creatorRenderer","taoQtiItem/qtiCreator/helper/xincludeRenderer","taoQtiItem/qtiCreator/editor/gridEditor/content","taoQtiItem/qtiCreator/editor/ckEditor/htmlEditor"],function(_,$,Promise,Loader,Container,Item,event,allQtiClasses,commonRenderer,xmlRenderer,simpleParser,creatorRenderer,xincludeRenderer,content,htmlEditor){'use strict';function parser($container){var data=simpleParser.parse($container.clone(),{ns:{math:"m"}});if(data.body)return data.body;throw new Error("invalid content for qti container")}function buildContainer($container){$container.wrapInner($("<div>",{class:"container-editor","data-html-editable":!0}))}function cleanup($container){var container=$container.data("container");return new Promise(function(resolve){container?($(document).off(".".concat(container.serial)),commonRenderer.load(["img","object","math","include","_container","printedVariable","_tooltip"],function(){$container.html(container.render(this)),resolve()}),$container.removeData("container")):resolve()})}function createFakeWidget($editableContainer,container,options){var widget={$container:$editableContainer,element:container,changeState:_.noop,getAreaBroker:function(){return options.areaBroker}};return container.data("widget",widget),widget}function buildEditor($editableContainer,container,options){$editableContainer.attr("data-html-editable-container",!0),htmlEditor.hasEditor($editableContainer)||htmlEditor.buildEditor($editableContainer,_.defaults(options||{},{shieldInnerContent:!1,passthroughInnerContent:!1,change:content.getChangeCallback(container),data:{widget:createFakeWidget($editableContainer,container,options),container:container}}))}function extractHtmlFromMarkup(markupStr,selector){var $found=$("<div>").html(markupStr).find(selector),ret=[];return $found.each(function(){ret.push($(this).html())}),ret}var _defaults={change:_.noop,markup:"",markupSelector:"",qtiMedia:!1};return event.initElementToWidgetListeners(),{create:function($container,options){var html,htmls,data,loader;options=_.defaults(options||{},_defaults),options.markup&&(html=options.markup,options.markupSelector&&(htmls=extractHtmlFromMarkup(html,options.markupSelector),html=htmls[0]||""),$container.html(html)),data=parser($container),loader=new Loader().setClassesLocation(allQtiClasses),loader.loadRequiredClasses(data,function(){var item,containerEditors,renderer,container=new Container;container.data("stateless",!0),$container.data("container",container),item=new Item().setElement(container),container.setRootElement(item),options.metadata&&_.each(options.metadata,function(value,name){item.data(name,value)}),options.related&&(containerEditors=options.related.data("container-editors")||[],containerEditors.push(container),options.related.data("container-editors",containerEditors)),this.loadContainer(container,data),renderer=creatorRenderer.get(options.resetRenderer,{},options.areaBroker),renderer.load(function(){var baseUrl=this.getOption("baseUrl");container.setRenderer(this),$container.html(container.render()),container.postRender(),_.each(container.getComposingElements(),function(element){"include"===element.qtiClass&&xincludeRenderer.render(element.data("widget"),baseUrl)}),buildContainer($container),buildEditor($container,container,{placeholder:options.placeholder||"",toolbar:options.toolbar||"",qtiMedia:options.qtiMedia,highlight:options.highlight,removePlugins:options.removePlugins||"",areaBroker:options.areaBroker,autofocus:options.autofocus||!1}),$container.off(".".concat("containereditor")).on(event.getList("containereditor"+event.getNs()+event.getNsModel()).join(" "),_.throttle(function(){var editorContent=container.render(xmlRenderer.get());$container.trigger("containerchange.".concat("containereditor"),[editorContent]),_.isFunction(options.change)&&options.change(editorContent)},600)),$container.trigger("editorready.containereditor")},["img","object","math","include","printedVariable","_container","_tooltip"])})},destroy:function($editableContainer){return htmlEditor.destroyEditor($editableContainer).then(function(){return $editableContainer.removeAttr("data-html-editable-container"),cleanup($editableContainer)})}}}),define("taoMediaManager/qtiCreator/plugins/content/blockAdder",["i18n","core/plugin","taoMediaManager/qtiCreator/editor/blockAdder/blockAdder"],function(__,pluginFactory,blockAdder){'use strict';return pluginFactory({name:"blockAdder",init:function(){},render:function(){blockAdder.create(this.getHost().getItem(),this.getAreaBroker().getItemPanelArea())}})}),define("taoMediaManager/qtiCreator/plugins/menu/preview",["jquery","i18n","core/plugin","ui/hider","taoMediaManager/previewer/adapter/item/qtiSharedStimulusItem","tpl!taoQtiItem/qtiCreator/plugins/button"],function($,__,pluginFactory,hider,previewerFactory,buttonTpl){'use strict';return pluginFactory({name:"preview",init:function init(){var _this6=this,SharedStimulusCreator=this.getHost();SharedStimulusCreator.on("preview",function(id){previewerFactory.init(id,{readOnly:!1,fullPage:!0})});var sharedStimulusConfig=SharedStimulusCreator.getConfig();sharedStimulusConfig.properties.previewEnabled&&(this.$element=$(buttonTpl({icon:"preview",title:__("Preview the item"),text:__("Preview"),cssClass:"preview-trigger",testId:"preview-the-asset"})).on("click",function(e){$(document).trigger("open-preview.qti-item"),e.preventDefault(),_this6.disable(),SharedStimulusCreator.trigger("preview",SharedStimulusCreator.getSharedStimulusId()),_this6.enable()}))},render:function render(){var $container=this.getAreaBroker().getMenuArea();$container.append(this.$element)},destroy:function destroy(){this.$element.remove()},enable:function enable(){this.$element.removeProp("disabled").removeClass("disabled")},disable:function disable(){this.$element.prop("disabled",!0).addClass("disabled")},show:function show(){hider.show(this.$element)},hide:function hide(){hider.hide(this.$element)}})}),define("taoMediaManager/qtiCreator/plugins/menu/save",["jquery","i18n","core/plugin","ui/hider","tpl!taoQtiItem/qtiCreator/plugins/button"],function($,__,pluginFactory,hider,buttonTpl){'use strict';return pluginFactory({name:"save",init:function init(){var self=this,sharedStimulusCreator=this.getHost();this.$element=$(buttonTpl({icon:"save",title:__("Save the asset"),text:__("Save"),cssClass:"save-trigger",testId:"save-the-asset"})).on("click",function(e){e.preventDefault(),self.disable(),sharedStimulusCreator.trigger("save")}),this.hide(),this.disable(),sharedStimulusCreator.on("ready saved error",function(){self.enable()})},render:function render(){var $container=this.getAreaBroker().getMenuArea();$container.append(this.$element),this.show()},destroy:function destroy(){this.$element.remove()},enable:function enable(){this.$element.removeProp("disabled").removeClass("disabled")},disable:function disable(){this.$element.prop("disabled",!0).addClass("disabled")},show:function show(){hider.show(this.$element)},hide:function hide(){hider.hide(this.$element)}})}),define("taoMediaManager/qtiCreator/plugins/navigation/back",["jquery","i18n","core/plugin","ui/hider","tpl!taoQtiItem/qtiCreator/plugins/button"],function($,__,pluginFactory,hider,buttonTpl){'use strict';return pluginFactory({name:"back",init:function init(){var sharedStimulusCreator=this.getHost();sharedStimulusCreator.on("exit",function(){window.history.back()}),this.$element=$(buttonTpl({icon:"left",title:__("Back to Manage Assets"),text:__("Manage Assets"),cssClass:"back-action",testId:"manage-assets"})).on("click",function(e){e.preventDefault(),sharedStimulusCreator.trigger("exit")}),this.hide()},render:function render(){var $container=this.getAreaBroker().getMenuLeftArea();$container.append(this.$element),this.show()},destroy:function destroy(){this.$element.remove()},enable:function enable(){this.$element.removeProp("disabled").removeClass("disabled")},disable:function disable(){this.$element.prop("disabled",!0).addClass("disabled")},show:function show(){hider.show(this.$element)},hide:function hide(){hider.hide(this.$element)}})}),define("taoMediaManager/qtiCreator/widgets/static/img/states/Active",["taoQtiItem/qtiCreator/widgets/states/factory","taoQtiItem/qtiCreator/widgets/static/states/Active","tpl!taoQtiItem/qtiCreator/tpl/forms/static/img","taoQtiItem/qtiCreator/widgets/helpers/formElement","taoQtiItem/qtiCreator/widgets/static/helpers/inline","ui/image/ImgStateActive"],function(stateFactory,ActiveState,formTpl,formElement,inlineHelper,ImgStateActive){'use strict';return ImgStateActive(stateFactory,ActiveState,formTpl,formElement,inlineHelper)}),define("taoMediaManager/qtiCreator/widgets/static/img/states/states",["taoQtiItem/qtiCreator/widgets/states/factory","taoQtiItem/qtiCreator/widgets/static/states/states","taoQtiItem/qtiCreator/widgets/static/img/states/Sleep","taoMediaManager/qtiCreator/widgets/static/img/states/Active"],function(factory,states){'use strict';return factory.createBundle(states,arguments)}),define("taoMediaManager/qtiCreator/widgets/static/img/Widget",["jquery","taoQtiItem/qtiCreator/widgets/static/Widget","taoMediaManager/qtiCreator/widgets/static/img/states/states","taoQtiItem/qtiCreator/widgets/static/helpers/widget","tpl!taoQtiItem/qtiCreator/tpl/toolbars/media","taoQtiItem/qtiCreator/widgets/static/helpers/inline","ui/mediaEditor/plugins/mediaAlignment/helper"],function($,Widget,states,helper,toolbarTpl,inlineHelper,alignmentHelper){'use strict';var ImgWidget=Widget.clone();return ImgWidget.initCreator=function(options){var _this7=this,img=this.element;this.registerStates(states),Widget.initCreator.call(this),inlineHelper.togglePlaceholder(this),alignmentHelper.initAlignment(this),inlineHelper.checkFileExists(this,"src",options.baseUrl),$("#item-editor-scope").on("filedelete.resourcemgr.".concat(this.element.serial),function(e,src){_this7.getAssetManager().resolve(img.attr("src"))===_this7.getAssetManager().resolve(src)&&(img.attr("src",""),inlineHelper.togglePlaceholder(self))})},ImgWidget.destroy=function(){$("#item-editor-scope").off(".".concat(this.element.serial))},ImgWidget.getRequiredOptions=function(){return["baseUrl","uri","lang","mediaManager","assetManager"]},ImgWidget.buildContainer=function(){return helper.buildInlineContainer(this),this.$container.css({width:this.element.attr("width"),height:this.element.attr("height")}),this.$original[0]&&(this.$original[0].setAttribute("width","100%"),this.$original[0].removeAttribute("height")),this},ImgWidget.createToolbar=function(){return helper.createToolbar(this,toolbarTpl),this},ImgWidget}),define("taoMediaManager/qtiCreator/renderers/Img",["lodash","taoQtiItem/qtiCommonRenderer/renderers/Img","taoMediaManager/qtiCreator/widgets/static/img/Widget"],function(_,Renderer,Widget){'use strict';var CreatorImg=_.clone(Renderer);return CreatorImg.render=function(img,options){options=options||{},options.baseUrl=this.getOption("baseUrl"),options.uri=this.getOption("uri"),options.lang=this.getOption("lang"),options.mediaManager=this.getOption("mediaManager"),options.assetManager=this.getAssetManager(),Widget.build(img,Renderer.getContainer(img),this.getOption("bodyElementOptionForm"),options)},CreatorImg}),define("tpl!taoMediaManager/qtiCreator/tpl/forms/item",["handlebars"],function(hb){return hb.template(function(Handlebars,depth0,helpers,partials,data){function program1(depth0,data){var stack1,helper,options,buffer="";return buffer+="\n <div class=\"panel\">\n <label for=\"xml:lang\">\n "+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"Language",options):helperMissing.call(depth0,"__","Language",options)))+"\n </label>\n <span class=\"icon-help tooltipstered\" data-tooltip=\"~ .tooltip-content:first\" data-tooltip-theme=\"info\"></span>\n <span class=\"tooltip-content\">\n "+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"Define item language.",options):helperMissing.call(depth0,"__","Define item language.",options)))+"\n </span>\n <select name=\"xml:lang\" class=\"select2\" data-has-search=\"false\">\n ",stack1=helpers.each.call(depth0,depth0&&depth0.languagesList,{hash:{},inverse:self.noop,fn:self.programWithDepth(2,program2,data,depth0),data:data}),(stack1||0===stack1)&&(buffer+=stack1),buffer+="\n </select>\n </div>\n",buffer}function program2(depth0,data,depth1){var stack1,helper,options,buffer="";return buffer+="\n <option value=\""+escapeExpression((stack1=null==data||!1===data?data:data.key,"function"===_typeof(stack1)?stack1.apply(depth0):stack1))+"\"",stack1=(helper=helpers.equal||depth1&&depth1.equal,options={hash:{},inverse:self.noop,fn:self.program(3,program3,data),data:data},helper?helper.call(depth0,null==data||!1===data?data:data.key,depth1&&depth1["xml:lang"],options):helperMissing.call(depth0,"equal",null==data||!1===data?data:data.key,depth1&&depth1["xml:lang"],options)),(stack1||0===stack1)&&(buffer+=stack1),buffer+=">"+escapeExpression("function"===_typeof(depth0)?depth0.apply(depth0):depth0)+"</option>\n ",buffer}function program3(){return" selected=\"selected\""}this.compilerInfo=[4,">= 1.0.0"],helpers=this.merge(helpers,Handlebars.helpers),data=data||{};var stack1,escapeExpression=this.escapeExpression,self=this,helperMissing=helpers.helperMissing;return stack1=helpers["if"].call(depth0,depth0&&depth0.languagesList,{hash:{},inverse:self.noop,fn:self.program(1,program1,data),data:data}),stack1||0===stack1?stack1:""})}),define("taoMediaManager/qtiCreator/widgets/item/states/Active",["lodash","taoQtiItem/qtiCreator/widgets/states/factory","taoMediaManager/qtiCreator/widgets/states/Active","tpl!taoMediaManager/qtiCreator/tpl/forms/item","taoQtiItem/qtiCreator/widgets/helpers/formElement"],function(_,stateFactory,Active,formTpl,formElement){'use strict';var ItemStateActive=stateFactory.create(Active,function(){var _widget=this.widget,item=_widget.element,$form=_widget.$form;$form.html(formTpl({"xml:lang":item.attr("xml:lang"),languagesList:item.data("languagesList")})),formElement.initWidget($form),formElement.setChangeCallbacks($form,item,{"xml:lang":formElement.getAttributeChangeCallback()})},_.noop);return ItemStateActive}),define("taoMediaManager/qtiCreator/widgets/item/states/states",["taoQtiItem/qtiCreator/widgets/states/factory","taoMediaManager/qtiCreator/widgets/item/states/Active"],function(factory){'use strict';return factory.createBundle(arguments)}),define("taoMediaManager/qtiCreator/widgets/item/Widget",["lodash","i18n","jquery","core/promise","util/url","taoQtiItem/qtiCreator/widgets/Widget","taoMediaManager/qtiCreator/widgets/item/states/states","taoQtiItem/qtiItem/core/Element","taoMediaManager/qtiCreator/helper/creatorRenderer","taoQtiItem/qtiCreator/model/helper/container","taoQtiItem/qtiCreator/editor/gridEditor/content","taoQtiItem/qtiCreator/helper/xmlRenderer","taoQtiItem/qtiCreator/helper/devTools","taoMediaManager/qtiCreator/widgets/static/text/Widget","taoQtiItem/qtiItem/helper/xmlNsHandler","taoQtiItem/qtiCreator/editor/jquery.gridEditor"],function(_,__,$,Promise,urlUtil,Widget,states,Element,creatorRenderer,containerHelper,contentHelper,xmlRenderer,devTools,TextWidget){'use strict';var ItemWidget=Widget.clone();ItemWidget.initCreator=function(config){var self=this;if(this.registerStates(states),Widget.initCreator.call(this),!config||!config.uri)throw new Error("missing required config parameter uri in item widget initialization");return this.saveItemUrl=config.saveItemUrl,this.renderer=config.renderer,this.itemUri=config.uri,new Promise(function(resolve){self.initTextWidgets(function(){this.initGridEditor(),this.debug({state:!1,xml:!1}),resolve()})})},ItemWidget.buildContainer=function(){this.$container=this.$original},ItemWidget.initUiComponents=function(){var element=this.element,$saveBtn=$("#save-trigger");this.on("metaChange",function(data){if(data.element.getSerial()===element.getSerial()&&"invalid"===data.key){var invalid=element.data("invalid");_.size(invalid)?$saveBtn.addClass("disabled"):$saveBtn.removeClass("disabled")}},!0)},ItemWidget.initGridEditor=function(){var self=this,item=this.element,$itemBody=this.$container.find(".qti-itemBody"),$itemEditorPanel=$("#item-editor-panel");$itemBody.gridEditor(),$itemBody.gridEditor("resizable"),$itemBody.gridEditor("addInsertables",$(".tool-list > [data-qti-class]:not(.disabled)"),{helper:function helper(){return $(this).find(".icon").clone().addClass("dragging")}}),$itemBody.on("beforedragoverstart.gridEdit",function(){$itemEditorPanel.addClass("dragging"),$itemBody.removeClass("hoverable").addClass("inserting")}).on("dragoverstop.gridEdit",function(){$itemEditorPanel.removeClass("dragging"),$itemBody.addClass("hoverable").removeClass("inserting")}).on("dropped.gridEdit.insertable",function(e,qtiClass,$placeholder){$placeholder.removeAttr("id"),"rubricBlock"===qtiClass&&($placeholder=$placeholder.parent(".col-12").parent(".grid-row")),$placeholder.addClass("widget-box"),$placeholder.attr({"data-new":!0,"data-qti-class":qtiClass});var $widget=$placeholder.parent().closest(".widget-box, .qti-item"),$editable=$placeholder.closest("[data-html-editable], .qti-itemBody"),widget=$widget.data("widget"),element=widget.element,container=Element.isA(element,"_container")?element:element.getBody();if(!element||!$editable.length)throw new Error("cannot create new element");containerHelper.createElements(container,contentHelper.getContent($editable),function(newElts){creatorRenderer.get().load(function(){var _this8=this;_.forEach(newElts,function(elt){var $eltWidget,eltwWdget,$colParent=$placeholder.parent();elt.setRenderer(_this8),Element.isA(elt,"_container")?($colParent.empty(),$colParent.html(elt.render()),eltwWdget=self.initTextWidget(elt,$colParent),$eltWidget=eltwWdget.$container):(elt.render($placeholder),elt.postRender(),eltwWdget=elt.data("widget"),$eltWidget=Element.isA(elt,"blockInteraction")?eltwWdget.$container:eltwWdget.$original),$eltWidget.trigger("contentChange.gridEdit"),$eltWidget.trigger("resize.gridEdit"),Element.isA(elt,"interaction")?eltwWdget.changeState("question"):eltwWdget.changeState("active")})},this.getUsedClasses())})}).on("resizestop.gridEdit",function(){item.body($itemBody.gridEditor("getContent"))})};var _detachElements=function(container,elements){var containerElements={};return _.each(elements,function(elementSerial){containerElements[elementSerial]=container.elements[elementSerial],delete container.elements[elementSerial]}),containerElements};return ItemWidget.initTextWidgets=function(callback){var self=this,item=this.element,$originalContainer=this.$container,i=1,subContainers=[];callback=callback||_.noop,$originalContainer.find(".qti-itemBody > .grid-row").each(function(){var $row=$(this);$row.hasClass("widget-box")||$row.children().each(function(){var $col=$(this),isTextBlock=!1;$col.contents().each(function(){if(3===this.nodeType&&this.nodeValue&&this.nodeValue.trim())return isTextBlock=!0,!1});var $widget=$col.children();(1<$widget.length||!$widget.hasClass("widget-blockInteraction"))&&($widget.hasClass("colrow")?$widget.each(function(){var $subElement=$(this),$subWidget=$subElement.children();(1<$subWidget.length||!$subWidget.hasClass("widget-blockInteraction"))&&($subElement.attr("data-text-block-id","text-block-".concat(i)),i++)}):isTextBlock=!0),isTextBlock&&($col.attr("data-text-block-id","text-block-".concat(i)),i++)})});var $clonedContainer=$originalContainer.clone();$clonedContainer.find(".qti-itemBody > .grid-row [data-text-block-id]").each(function(){var $originalTextBlock=$(this),textBlockId=$originalTextBlock.data("text-block-id"),$subContainer=$originalTextBlock.clone(),subContainerElements=contentHelper.serializeElements($subContainer),subContainerBody=$subContainer.html();$originalTextBlock.removeAttr("data-text-block-id").html("{{_container:new}}"),subContainers.push({body:subContainerBody,elements:subContainerElements,$original:$originalContainer.find("[data-text-block-id=\"".concat(textBlockId,"\"]")).removeAttr("data-text-block-id")})}),contentHelper.serializeElements($clonedContainer);var serializedItemBody=$clonedContainer.find(".qti-itemBody").html(),itemBody=item.getBody();subContainers.length?containerHelper.createElements(itemBody,serializedItemBody,function(newElts){if(_.size(newElts)!==subContainers.length)throw new Error("number of sub-containers mismatch");else _.each(newElts,function(container){var containerData=subContainers.shift(),containerElements=_detachElements(itemBody,containerData.elements);container.setElements(containerElements,containerData.body),self.initTextWidget(container,containerData.$original)}),_.defer(function(){callback.call(self)})}):callback.call(self)},ItemWidget.initTextWidget=function(container,$col){return TextWidget.build(container,$col,this.renderer.getOption("textOptionForm"),{})},ItemWidget.debug=function(options){if(options=options||{},options.state&&devTools.listenStateChange(),options.xml){var $code=$("<code>",{class:"language-markup"}),$pre=$("<pre>",{class:"line-numbers"}).append($code);$("#item-editor-wrapper").append($pre),devTools.liveXmlPreview(this.element,$code)}},ItemWidget}),define("tpl!taoMediaManager/qtiCreator/renderers/tpl/wrap",["handlebars"],function(hb){return hb.template(function(Handlebars,depth0,helpers,partials,data){return this.compilerInfo=[4,">= 1.0.0"],helpers=this.merge(helpers,Handlebars.helpers),data=data||{},"<div class=\"grid-row\"><div class=\"col-12\"></div></div>"})}),define("taoMediaManager/qtiCreator/renderers/Item",["jquery","lodash","taoQtiItem/qtiCommonRenderer/renderers/Item","taoMediaManager/qtiCreator/widgets/item/Widget","tpl!taoQtiItem/qtiCreator/tpl/item","tpl!taoMediaManager/qtiCreator/renderers/tpl/wrap"],function($,_,CommonRenderer,Widget,tpl,wrapTpl){'use strict';var CreatorItem=_.clone(CommonRenderer),_normalizeItemBody=function($itemBody){return $itemBody.children().each(function(){var $child=$(this);$child.hasClass("grid-row")||$child.hasClass("qti-infoControl")||$child.wrap(wrapTpl())}),$itemBody};return CreatorItem.template=tpl,CreatorItem.render=function(item,options){var $itemContainer=CommonRenderer.getContainer(item);return _normalizeItemBody($itemContainer.find(".qti-itemBody")),options=options||{},options.state="active",options.renderer=this,Widget.build(item,$itemContainer,this.getOption("itemOptionForm"),options)},CreatorItem}),define("taoMediaManager/qtiCreator/widgets/static/object/states/Active",["lodash","jquery","i18n","taoQtiItem/qtiCreator/widgets/states/factory","taoQtiItem/qtiCreator/widgets/static/states/Active","tpl!taoQtiItem/qtiCreator/tpl/forms/static/object","taoQtiItem/qtiCreator/widgets/helpers/formElement","taoQtiItem/qtiCreator/widgets/static/helpers/inline","ui/mediaEditor/mediaEditorComponent","ui/previewer","ui/resourcemgr","ui/tooltip"],function(_,$,__,stateFactory,Active,formTpl,formElement,inlineHelper,mediaEditorComponent){'use strict';var mediaEditor=null,$panelObjectSize=null,$panelMediaSize=null,_config={renderingThrottle:1e3,fileFilters:"image/jpeg,image/png,image/gif,image/svg+xml,video/mp4,video/avi,video/ogv,video/mpeg,video/ogg,video/quicktime,video/webm,video/x-ms-wmv,video/x-flv,audio/mp3,audio/vnd.wav,audio/ogg,audio/vorbis,audio/webm,audio/mpeg,application/ogg,audio/aac,application/pdf"},ObjectStateActive=stateFactory.extend(Active,function(){this.initForm()},function(){mediaEditor&&mediaEditor.destroy(),mediaEditor=null,$panelObjectSize=null,$panelMediaSize=null,this.widget.$original.off("playerready"),this.widget.$form.empty()}),refreshRendering=_.throttle(function(widget){var obj=widget.element,$container=widget.$original,previewOptions={url:obj.renderer.resolveUrl(obj.attr("data")),mime:obj.attr("type")};obj.attr("height")&&(previewOptions.height=obj.attr("height")),obj.attr("width")&&(previewOptions.width=obj.attr("width")),previewOptions.url&&previewOptions.mime&&$container.previewer(previewOptions)},_config.renderingThrottle),setMediaSizeEditor=function(widget){var _Mathmin=Math.min,_Mathmax=Math.max,_Mathround=Math.round,qtiObject=widget.element,type=qtiObject.attr("type");if(/video/.test(type)){var $container=widget.$original,mediaplayer=$container.data("player"),width=qtiObject.attr("width"),height=qtiObject.attr("height");if(!/%/.test(width)){var originalSize=mediaplayer.getMediaOriginalSize();if(!originalSize.width)return;var containerWidth=$container.closest(".widget-textBlock").width();if(!width)width=_Mathround(100/(containerWidth/originalSize.width)),height=0;else if(height){var scaleHeight=(_Mathmax(height||0,200)-$container.find(".mediaplayer .controls").height())/originalSize.height,scaleWidth=_Mathmax(width||0,200)/originalSize.width,scale=_Mathmin(scaleHeight,scaleWidth);width=_Mathround(100/(containerWidth/(scale*originalSize.width))),qtiObject.removeAttr("height"),height=0}}var onChange=_.debounce(function(nMedia){if(qtiObject.attr("width")!=="".concat(nMedia.width,"%")){var newWidth="".concat(_Mathround(nMedia.width),"%");qtiObject.attr("width",newWidth),mediaplayer.resize(newWidth,"auto")}},200);mediaEditor&&mediaEditor.destroy(),mediaEditor=mediaEditorComponent($panelMediaSize,{$node:$container.find(".mediaplayer .media"),$container:$container,type:qtiObject.attr("type"),width:width,height:height,responsive:!0},{mediaDimension:{active:!0,showResponsiveToggle:!1}}).on("change",onChange)}},hideShowPanels=function(type){/video/.test(type)?($panelObjectSize.hide(),$panelMediaSize.show()):(mediaEditor&&mediaEditor.destroy(),$panelObjectSize.show(),$panelMediaSize.hide())},_initUpload=function(widget){var $form=widget.$form,options=widget.options,qtiObject=widget.element,$uploadTrigger=$form.find("[data-role=\"upload-trigger\"]"),$src=$form.find("input[name=src]"),_openResourceMgr=function(){$uploadTrigger.resourcemgr({title:__("Please select a media file from the resource manager. You can add files from your computer with the button \"Add file(s)\"."),appendContainer:options.mediaManager.appendContainer,mediaSourcesUrl:options.mediaManager.mediaSourcesUrl,browseUrl:options.mediaManager.browseUrl,uploadUrl:options.mediaManager.uploadUrl,deleteUrl:options.mediaManager.deleteUrl,downloadUrl:options.mediaManager.downloadUrl,fileExistsUrl:options.mediaManager.fileExistsUrl,params:{uri:options.uri,lang:options.lang,filters:_config.fileFilters},pathParam:"path",path:options.mediaManager.path,root:options.mediaManager.root,select:function select(e,files){var file,type;files&&files.length&&(file=files[0].file,type=files[0].mime,qtiObject.attr("type",type),$src.val(file).trigger("change"))},open:function open(){$src.data("$tooltip")&&$src.blur().data("$tooltip").hide()},close:function close(){$src.blur()}})};$uploadTrigger.on("click",_openResourceMgr),$src.val()||_openResourceMgr()};return ObjectStateActive.prototype.initForm=function(){var _widget=this.widget,$form=_widget.$form,qtiObject=_widget.element,baseUrl=_widget.options.baseUrl,$container=_widget.$original;$form.html(formTpl({baseUrl:baseUrl||"",src:qtiObject.attr("data"),alt:qtiObject.attr("alt"),height:qtiObject.attr("height"),width:qtiObject.attr("width")})),_initUpload(_widget),formElement.initWidget($form),$panelObjectSize=$(".size-panel",$form),$panelMediaSize=$(".media-size-panel",$form),hideShowPanels(qtiObject.attr("type")),$container.off("playerready").on("playerready",function(){setMediaSizeEditor(_widget)}),formElement.setChangeCallbacks($form,qtiObject,{src:function src(object,value){value!==qtiObject.attr("data")&&(qtiObject.attr("data",value),qtiObject.removeAttr("width"),qtiObject.removeAttr("height"),$form.find("input[name=width]").val(""),$form.find("input[name=height]").val(""),$container.removeData("ui.previewer"),hideShowPanels(qtiObject.attr("type")),inlineHelper.togglePlaceholder(_widget),refreshRendering(_widget))},width:function width(object,value){var val=parseInt(value,10);_.isNaN(val)?qtiObject.removeAttr("width"):qtiObject.attr("width",val),refreshRendering(_widget)},height:function height(object,value){var val=parseInt(value,10);_.isNaN(val)?qtiObject.removeAttr("height"):qtiObject.attr("height",val),refreshRendering(_widget)},alt:function alt(qtiObjectAlt,value){qtiObjectAlt.attr("alt",value)},align:function align(qtiObjectAlign,value){inlineHelper.positionFloat(_widget,value)}})},ObjectStateActive}),define("taoMediaManager/qtiCreator/widgets/static/object/states/states",["taoQtiItem/qtiCreator/widgets/states/factory","taoQtiItem/qtiCreator/widgets/static/states/states","taoQtiItem/qtiCreator/widgets/static/object/states/Sleep","taoMediaManager/qtiCreator/widgets/static/object/states/Active"],function(factory,states){'use strict';return factory.createBundle(states,arguments)}),define("taoMediaManager/qtiCreator/widgets/static/object/Widget",["taoQtiItem/qtiCreator/widgets/static/Widget","taoMediaManager/qtiCreator/widgets/static/object/states/states","taoQtiItem/qtiCreator/widgets/static/helpers/widget","tpl!taoQtiItem/qtiCreator/tpl/toolbars/media","taoQtiItem/qtiCreator/widgets/static/helpers/inline"],function(Widget,states,helper,toolbarTpl,inlineHelper){'use strict';var ObjectWidget=Widget.clone();return ObjectWidget.initCreator=function(){this.registerStates(states),Widget.initCreator.call(this),inlineHelper.togglePlaceholder(this)},ObjectWidget.getRequiredOptions=function(){return["baseUrl","uri","lang","mediaManager"]},ObjectWidget.buildContainer=function(){return helper.buildBlockContainer(this),this},ObjectWidget.createToolbar=function(){return helper.createToolbar(this,toolbarTpl),this},ObjectWidget}),define("taoMediaManager/qtiCreator/renderers/Object",["lodash","taoQtiItem/qtiCommonRenderer/renderers/Object","taoMediaManager/qtiCreator/widgets/static/object/Widget"],function(_,Renderer,Widget){'use strict';var CreatorObject=_.clone(Renderer);return CreatorObject.render=function(object,options){Renderer.render(object),options=options||{},options.baseUrl=this.getOption("baseUrl"),options.uri=this.getOption("uri"),options.lang=this.getOption("lang"),options.mediaManager=this.getOption("mediaManager"),options.assetManager=this.getAssetManager(),Widget.build(object,Renderer.getContainer(object),this.getOption("bodyElementOptionForm"),options)},CreatorObject}),define("taoMediaManager/qtiCreator/widgets/static/table/states/Active",["lodash","jquery","i18n","ckeditor","ui/tableModel","taoQtiItem/qtiCreator/widgets/states/factory","taoMediaManager/qtiCreator/widgets/static/states/Active","taoQtiItem/qtiCreator/widgets/static/table/components/tableActions","taoMediaManager/qtiCreator/editor/ckEditor/htmlEditor","taoQtiItem/qtiCreator/editor/gridEditor/content","taoQtiItem/qtiCreator/widgets/helpers/formElement","tpl!taoQtiItem/qtiCreator/tpl/forms/static/table"],function(_,$,__,ckEditor,tableModelFactory,stateFactory,Active,tableActionsFactory,htmlEditor,contentHelper,formElement,formTpl){'use strict';function getChangeCallback(container){return _.throttle(function(data){var $tableTagContent=$(data).children(),$pseudoContainer=$("<div>").html($tableTagContent),newBody=contentHelper.getContent($pseudoContainer);container.body(newBody)},400)}function addClassOnCurrentRow(editor,className){var $currentCol,currentCellPos=getCurrentCellPos(editor);currentCellPos&&($currentCol=tableModel.getRowCells(currentCellPos.y),$currentCol.addClass(className))}function addClassOnCurrentCol(editor,className){var $currentCol,currentCellPos=getCurrentCellPos(editor);currentCellPos&&($currentCol=tableModel.getColCells(currentCellPos.x),$currentCol.addClass(className))}function clearCellClasses($editable,className){$editable.find("th, td").removeClass(className)}function updateTable(editor,$editableContainer){tableModel.update(),1===tableModel.getRowCount()?rowActions.hideDelete():rowActions.showDelete(),1===tableModel.getColCount()?colActions.hideDelete():colActions.showDelete(),displayTableActions(editor,$editableContainer)}function hideTableActions(){colActions&&colActions.hide(),rowActions&&rowActions.hide()}function displayTableActions(editor,$tableContainer){var $currentCell,selectedCells=getSelection(editor);selectedCells&&1!==selectedCells.length?hideTableActions():($currentCell=$(selectedCells[0].$),colActions.show().hAlignWith($currentCell,"center").vAlignWith($tableContainer,"top"),rowActions.show().hAlignWith($tableContainer,"left").vAlignWith($currentCell,"center"))}function getCurrentCellPos(editor){var currentCell,selectedCells=getSelection(editor);if(selectedCells&&1===selectedCells.length)return currentCell=selectedCells[0].$,{x:currentCell.cellIndex,y:currentCell.parentNode.rowIndex}}function getSelection(editor){var selection=editor.getSelection(),tabletools=window.CKEDITOR.plugins.tabletools;if(selection&&tabletools)return tabletools.getSelectedCells(selection)}var tableModel,colActions,rowActions,css={deleteColRow:"hoverDelete",insertRowAfter:"insertRowAfter",insertColAfter:"insertColAfter",hAlignCenter:"table-center",hAlignRight:"table-right"},TableStateActive=stateFactory.extend(Active,function(){this.initForm(),this.buildEditor()},function(){this.widget.$form.empty(),this.destroyEditor()});return TableStateActive.prototype.initForm=function(){var hAlignOptions,_widget=this.widget,$form=_widget.$form,table=_widget.element,$container=_widget.$container;hAlignOptions=[{name:__("Left"),value:"left"},{name:__("Center"),value:"center",selected:table.hasClass(css.hAlignCenter)},{name:__("Right"),value:"right",selected:table.hasClass(css.hAlignRight)}],$form.html(formTpl({hAlignOptions:hAlignOptions})),formElement.initWidget($form),formElement.setChangeCallbacks($form,table,{hAlign:function hAlign(t,value){switch(hideTableActions(),t.removeClass(css.hAlignRight),t.removeClass(css.hAlignCenter),$container.removeClass("".concat(css.hAlignRight," ").concat(css.hAlignCenter)),value){case"center":{t.addClass(css.hAlignCenter),$container.addClass(css.hAlignCenter);break}case"right":{t.addClass(css.hAlignRight),$container.addClass(css.hAlignRight);break}}}})},TableStateActive.prototype.buildEditor=function(){var _widget=this.widget,container=_widget.element.getBody(),$itemPanel=_widget.getAreaBroker().getItemPanelArea(),$editableContainer=_widget.$container,$editable=$editableContainer.find(".qti-table-container"),$tablePropTrigger=$editableContainer.find("[data-role=\"cke-table-properties\"]");$editableContainer.attr("data-html-editable-container",!0),$editable.attr("data-html-editable",!0),htmlEditor.hasEditor($editableContainer)||htmlEditor.buildEditor($editableContainer,{placeholder:"",change:getChangeCallback(container),removePlugins:"magicline",data:{container:container,widget:_widget},blur:function blur(){_widget.changeState("sleep")}}),$editable.on("editorready.tableActive",function(event,editor){tableModel=tableModelFactory($editable.find("table")),$tablePropTrigger.on("click.tableActive",function(e){e.stopPropagation(),hideTableActions(),editor.execCommand("taoqtitableProperties")}),colActions=tableActionsFactory({insertCol:!0,deleteTitle:"Delete column"}).on("delete",function(){editor.execCommand("columnDelete"),updateTable(editor,$editableContainer),hideTableActions()}).on("deleteMouseEnter",function(){addClassOnCurrentCol(editor,css.deleteColRow)}).on("deleteMouseLeave",function(){clearCellClasses($editable,css.deleteColRow)}).on("insertCol",function(){editor.execCommand("columnInsertAfter"),clearCellClasses($editable,css.insertColAfter),this.trigger("insertColMouseEnter"),updateTable(editor,$editableContainer)}).on("insertColMouseEnter",function(){addClassOnCurrentCol(editor,css.insertColAfter)}).on("insertColMouseLeave",function(){clearCellClasses($editable,css.insertColAfter)}).render($itemPanel).hide(),rowActions=tableActionsFactory({insertRow:!0,deleteTitle:"Delete row"}).on("delete",function(){editor.execCommand("rowDelete"),updateTable(editor,$editableContainer),hideTableActions()}).on("deleteMouseEnter",function(){addClassOnCurrentRow(editor,css.deleteColRow)}).on("deleteMouseLeave",function(){clearCellClasses($editable,css.deleteColRow)}).on("insertRow",function(){editor.execCommand("rowInsertAfter"),clearCellClasses($editable,css.insertRowAfter),this.trigger("insertRowMouseEnter"),updateTable(editor,$editableContainer)}).on("insertRowMouseEnter",function(){addClassOnCurrentRow(editor,css.insertRowAfter)}).on("insertRowMouseLeave",function(){clearCellClasses($editable,css.insertRowAfter)}).render($itemPanel).hide(),$editableContainer.on("keyup.tableActive mouseup.tableActive",function(){displayTableActions(editor,$editableContainer)})}).on("editordestroyed.tableActive",function(){$tablePropTrigger.length&&$tablePropTrigger.off(".tableActive")})},TableStateActive.prototype.destroyEditor=function(){var _widget=this.widget,$editableContainer=_widget.$container,$editable=$editableContainer.find("[data-html-editable=\"true\"]");clearCellClasses($editable,css.insertColAfter),clearCellClasses($editable,css.insertRowAfter),clearCellClasses($editable,css.deleteColRow),htmlEditor.destroyEditor($editableContainer),$editableContainer.off(".tableActive"),$editable.off(".tableActive"),$editable.attr("data-html-editable",!1),$editableContainer.attr("data-html-editable-container",!1),tableModel=null,colActions&&(colActions.destroy(),colActions=null),rowActions&&(rowActions.destroy(),rowActions=null)},TableStateActive}),define("taoMediaManager/qtiCreator/widgets/static/table/states/states",["taoQtiItem/qtiCreator/widgets/states/factory","taoQtiItem/qtiCreator/widgets/static/states/states","taoQtiItem/qtiCreator/widgets/static/table/states/Sleep","taoMediaManager/qtiCreator/widgets/static/table/states/Active"],function(factory,states){'use strict';return factory.createBundle(states,arguments)}),define("taoMediaManager/qtiCreator/widgets/static/table/Widget",["jquery","taoQtiItem/qtiCreator/widgets/static/Widget","taoMediaManager/qtiCreator/widgets/static/table/states/states","taoQtiItem/qtiCreator/widgets/static/helpers/widget","tpl!taoQtiItem/qtiCreator/tpl/toolbars/table"],function($,Widget,states,helper,toolbarTpl){'use strict';var TableWidget=Widget.clone();return TableWidget.initCreator=function(){this.registerStates(states),Widget.initCreator.call(this)},TableWidget.buildContainer=function(){var table=this.element;return helper.buildBlockContainer(this),table.attr("class")&&this.$container.addClass(table.attr("class")),this},TableWidget.createToolbar=function(){var self=this,$tlb=$(toolbarTpl({serial:this.serial,state:"active"}));return this.$container.append($tlb),$tlb.find("[data-role=\"delete\"]").on("click.widget-box",function(e){e.stopPropagation(),self.changeState("deleting")}),this},TableWidget}),define("taoMediaManager/qtiCreator/renderers/Table",["lodash","taoQtiItem/qtiCommonRenderer/renderers/Table","taoMediaManager/qtiCreator/widgets/static/table/Widget","tpl!taoQtiItem/qtiCreator/tpl/table"],function(_,Renderer,Widget,tpl){'use strict';var CreatorTable=_.clone(Renderer);return CreatorTable.template=tpl,CreatorTable.render=function(table,options){Widget.build(table,Renderer.getContainer(table),this.getOption("bodyElementOptionForm"),options||{})},CreatorTable}),define("tpl!taoMediaManager/qtiXmlRenderer/tpl/item",["handlebars"],function(hb){return hb.template(function(Handlebars,depth0,helpers,partials,data){function program1(depth0,data){var stack1,helper,buffer="";return buffer+=" class=\"",(helper=helpers["class"])?stack1=helper.call(depth0,{hash:{},data:data}):(helper=depth0&&depth0["class"],stack1="function"===_typeof(helper)?helper.call(depth0,{hash:{},data:data}):helper),buffer+=escapeExpression(stack1)+"\"",buffer}function program3(depth0,data){var stack1,buffer="";return stack1=helpers["if"].call(depth0,null==data||!1===data?data:data.key,{hash:{},inverse:self.program(6,program6,data),fn:self.program(4,program4,data),data:data}),(stack1||0===stack1)&&(buffer+=stack1),buffer+=" ",buffer}function program4(depth0,data){var stack1,buffer="";return buffer+="xmlns:"+escapeExpression((stack1=null==data||!1===data?data:data.key,"function"===_typeof(stack1)?stack1.apply(depth0):stack1))+"=\""+escapeExpression("function"===_typeof(depth0)?depth0.apply(depth0):depth0)+"\"",buffer}function program6(depth0){var buffer="";return buffer+="xmlns=\""+escapeExpression("function"===_typeof(depth0)?depth0.apply(depth0):depth0)+"\"",buffer}function program8(depth0,data){var stack1,helper,options;return stack1=(helper=helpers.join||depth0&&depth0.join,options={hash:{},data:data},helper?helper.call(depth0,depth0&&depth0.attributes,"="," ","\"",options):helperMissing.call(depth0,"join",depth0&&depth0.attributes,"="," ","\"",options)),stack1||0===stack1?stack1:""}function program12(depth0,data){var stack1,helper,buffer="";return buffer+="\n ",(helper=helpers.body)?stack1=helper.call(depth0,{hash:{},data:data}):(helper=depth0&&depth0.body,stack1="function"===_typeof(helper)?helper.call(depth0,{hash:{},data:data}):helper),(stack1||0===stack1)&&(buffer+=stack1),buffer+="\n ",buffer}this.compilerInfo=[4,">= 1.0.0"],helpers=this.merge(helpers,Handlebars.helpers),data=data||{};var stack1,buffer="",escapeExpression=this.escapeExpression,self=this,helperMissing=helpers.helperMissing;return buffer+="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<div",stack1=helpers["if"].call(depth0,depth0&&depth0["class"],{hash:{},inverse:self.noop,fn:self.program(1,program1,data),data:data}),(stack1||0===stack1)&&(buffer+=stack1),buffer+="\n ",stack1=helpers.each.call(depth0,depth0&&depth0.namespaces,{hash:{},inverse:self.noop,fn:self.program(3,program3,data),data:data}),(stack1||0===stack1)&&(buffer+=stack1),buffer+="\n ",stack1=helpers["if"].call(depth0,depth0&&depth0.attributes,{hash:{},inverse:self.noop,fn:self.program(8,program8,data),data:data}),(stack1||0===stack1)&&(buffer+=stack1),buffer+=">\n ",stack1=helpers["if"].call(depth0,depth0&&depth0.empty,{hash:{},inverse:self.program(12,program12,data),fn:self.program(10,function(){return"\n <div class=\"empty\"></div>\n "},data),data:data}),(stack1||0===stack1)&&(buffer+=stack1),buffer+="\n</div>",buffer})}),define("taoMediaManager/qtiXmlRenderer/renderers/Item",["lodash","tpl!taoMediaManager/qtiXmlRenderer/tpl/item"],function(_,tpl){'use strict';return{qtiClass:"assessmentItem",template:tpl,getData:function(item,data){var defaultData={class:data.attributes.class||"",namespaces:item.getNamespaces(),schemaLocations:"",xsi:"xsi:",empty:item.isEmpty()};return _.forIn(item.getSchemaLocations(),function(url,uri){defaultData.schemaLocations+="".concat(uri," ").concat(url," ")}),defaultData.schemaLocations=defaultData.schemaLocations.trim(),data=_.merge({},data,defaultData),delete data.attributes.class,delete data.attributes.title,delete data.attributes.adaptive,delete data.attributes.timeDependent,delete data.attributes.identifier,data.attributes=_.mapValues(data.attributes,function(val){return _.isString(val)?_.escape(val):val}),data}}}),function(c){var d=document,s=d.createElement("style");s.type="text/css",d.getElementsByTagName("head")[0].appendChild(s),s.styleSheet?s.styleSheet.cssText=c:s.appendChild(d.createTextNode(c))}(".previewer{position:relative}.previewer iframe{min-height:400px;width:100%}.previewer .previewer-component{background-color:white;text-align:initial}.previewer .previewer-component .item-previewer-scope{height:calc(100vh - 250px)}.previewer .previewer-component .item-previewer-scope .action-bar,.previewer .previewer-component .item-previewer-scope .test-sidebar{display:none}.previewer.no-background{background:none}#item-editor-scope .tool-group ._accordion{display:none}\n\n/*# sourceMappingURL=../../../taoMediaManager/views/css/media.css.map */"),define("taoMediaManager/loader/taoMediaManager.bundle",function(){}),define("taoMediaManager/loader/taoMediaManager.min",["taoItems/loader/taoItemsRunner.min","taoTests/loader/taoTestsRunner.min","taoQtiItem/loader/taoQtiItemRunner.min","taoQtiItem/loader/taoQtiItem.min","taoQtiTestPreviewer/loader/qtiPreviewer.min"],function(){});
|
|
//# sourceMappingURL=taoMediaManager.min.js.map
|