芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/cepali/question/type/ddimageortext/amd/build/question.min.js
define(["jquery","core/dragdrop","core/key_codes"],function(a,b,c){"use strict";function d(a,b,c){this.containerId=a,M.util.js_pending("qtype_ddimageortext-init-"+this.containerId),this.places=c,this.allImagesLoaded=!1,this.imageLoadingTimeoutId=null,b&&this.getRoot().addClass("qtype_ddimageortext-readonly");var d=this;this.getNotYetLoadedImages().one("load",function(){d.waitForAllImagesToBeLoaded()}),this.waitForAllImagesToBeLoaded()}d.prototype.waitForAllImagesToBeLoaded=function(){var a=this;if(!this.allImagesLoaded){if(null!==this.imageLoadingTimeoutId&&clearTimeout(this.imageLoadingTimeoutId),this.getNotYetLoadedImages().length>0)return void(this.imageLoadingTimeoutId=setTimeout(function(){a.waitForAllImagesToBeLoaded()},100));this.allImagesLoaded=!0,a.setupQuestion()}},d.prototype.getNotYetLoadedImages=function(){var a=this;return this.getRoot().find(".ddarea img").not(function(b,c){return a.imageIsLoaded(c)})},d.prototype.imageIsLoaded=function(a){return a.complete&&0!==a.naturalHeight},d.prototype.setupQuestion=function(){this.resizeAllDragsAndDrops(),this.cloneDrags(),this.positionDragsAndDrops(),M.util.js_complete("qtype_ddimageortext-init-"+this.containerId)},d.prototype.resizeAllDragsAndDrops=function(){var b=this;this.getRoot().find(".draghomes > div").each(function(c,d){b.resizeAllDragsAndDropsInGroup(b.getClassnameNumericSuffix(a(d),"dragitemgroup"))})},d.prototype.resizeAllDragsAndDropsInGroup=function(b){var c=this.getRoot(),d=c.find(".dragitemgroup"+b+" .draghome"),e=0,f=0;d.each(function(a,b){e=Math.max(e,Math.ceil(b.offsetWidth)),f=Math.max(f,Math.ceil(b.offsetHeight))}),e+=10,f+=10,d.each(function(b,c){var d=Math.round((e-c.offsetWidth)/2),g=Math.floor((f-c.offsetHeight)/2);a(c).css({"padding-left":d+"px","padding-right":e-c.offsetWidth-d+"px","padding-top":g+"px","padding-bottom":f-c.offsetHeight-g+"px"})});for(var g in this.places)if(this.places.hasOwnProperty(g)){var h=this.places[g],i=h.text;parseInt(h.group)===b&&(""===i&&(i=M.util.get_string("blank","qtype_ddimageortext")),c.find(".dropzones").append('
'+i+"
"),c.find(".dropzone.place"+g).width(e-2).height(f-2))}},d.prototype.cloneDrags=function(){var b=this;this.getRoot().find(".ddarea .draghome").each(function(c,d){b.cloneDragsForOneChoice(a(d))})},d.prototype.cloneDragsForOneChoice=function(a){if(a.hasClass("infinite"))for(var b=this.noOfDropsInGroup(this.getGroup(a)),c=0;c
1;)c--,d=this.getUnplacedChoice(a,c);return d},d.prototype.animateTo=function(a,b){var c=a.offset(),d=b.offset();a.addClass("beingdragged"),a.animate({left:parseInt(a.css("left"))+d.left-c.left,top:parseInt(a.css("top"))+d.top-c.top},{duration:"fast",done:function(){a.removeClass("beingdragged"),a.offset(d)}})},d.prototype.isPointInDrop=function(a,b,c){var d=c.offset();return a>=d.left&&a
=d.top&&b