芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/cepali/question/type/ddmarker/amd/build/question.min.js
define(["jquery","core/dragdrop","qtype_ddmarker/shapes","core/key_codes"],function(a,b,c,d){"use strict";function e(a,b,c,d){this.containerId=a,this.visibleDropZones=d,c&&this.getRoot().addClass("qtype_ddmarker-readonly"),this.loadImage(b)}e.prototype.loadImage=function(a){var b=this;this.getRoot().find(".dropbackground").one("load",function(){b.visibleDropZones.length>0&&b.drawDropzones(),b.repositionDrags()}).attr("src",a).css({border:"1px solid #000","max-width":"none"})},e.prototype.drawDropzones=function(){var a=this.getRoot().find("img.dropbackground");this.getRoot().find("div.dropzones").html('
');var b=this.getRoot().find("svg.dropzones");b.css("position","absolute");for(var c=0,d=0;d
'+f.markertext+"")}var i=g.makeSvg(a[0]);i.setAttribute("class","dropzone "+d)}},e.prototype.repositionDropZones=function(){var a=this.getRoot().find("svg.dropzones");if(0!==a.length){var b=this.convertToWindowXY(new c.Point((-1),0));a.offset({left:b.x,top:b.y});for(var d=0;d
0,h=[],i=a(b).val();if(""!==i)for(var j=i.split(";"),k=0;k
0&&a.x<=b.width()&&a.y>0&&a.y<=b.height()},e.prototype.dragHomeXY=function(a){var b=this.dragHome(a);return new c.Point(b.offset().left,b.offset().top)},e.prototype.getRoot=function(){return a(document.getElementById(this.containerId))},e.prototype.bgImage=function(){return this.getRoot().find("img.dropbackground")},e.prototype.dragHome=function(a){return this.getRoot().find("div.dragitems span.draghome.choice"+a)},e.prototype.dragItem=function(a,b){return this.getRoot().find("div.dragitems span.dragitem.choice"+a+".item"+b)},e.prototype.cloneNewDragItem=function(a,b){var c=a.clone(!0);return c.removeClass("draghome").addClass("dragitem").addClass("item"+b),a.after(c),c.attr("tabIndex",0),c},e.prototype.handleDragStart=function(c){var d=this,e=a(c.target).closest(".dragitem"),f=b.prepare(c);f.start&&(e.addClass("beingdragged"),b.start(c,e,function(){},function(a,b,c){d.dragEnd(c)}))},e.prototype.dragEnd=function(a){a.removeClass("beingdragged");var b=this.getChoiceNoFromElement(a);this.saveCoordsForChoice(b,a),this.repositionDrags()},e.prototype.saveCoordsForChoice=function(a,b){for(var d,e=[],f=this.getRoot().find("span.dragitem.choice"+a).length,g=!0,h=0;h<=f;h++){var i=this.dragItem(a,h);0!==i.length&&(i.hasClass("beingdragged")||(d=this.convertToBgImgXY(new c.Point(i.offset().left,i.offset().top)),this.coordsInBgImg(d)&&(e[e.length]=d)),b&&0!==b.length&&b[0].innerText===i[0].innerText&&(g=!1))}g&&(d=this.convertToBgImgXY(new c.Point(b.offset().left,b.offset().top)),this.coordsInBgImg(d)&&(e[e.length]=d)),this.getRoot().find("input.choice"+a).val(e.join(";"))},e.prototype.handleKeyPress=function(b){var e=a(b.target).closest(".dragitem"),f=new c.Point(e.offset().left,e.offset().top),g=this.getChoiceNoFromElement(e);switch(b.keyCode){case d.arrowLeft:case 65:f.x-=1;break;case d.arrowRight:case 68:f.x+=1;break;case d.arrowDown:case 83:f.y+=1;break;case d.arrowUp:case 87:f.y-=1;break;case d.space:case d.escape:f=null;break;default:return}b.preventDefault(),f=null!==f?this.constrainToBgImg(f):this.dragHomeXY(g),e.offset({left:f.x,top:f.y}),this.saveCoordsForChoice(g,e),this.repositionDrags()},e.prototype.constrainToBgImg=function(a){var b=this.bgImage(),c=this.convertToBgImgXY(a);return c.x=Math.max(0,c.x),c.y=Math.max(0,c.y),c.x=Math.min(b.width(),c.x),c.y=Math.min(b.height(),c.y),this.convertToWindowXY(c)},e.prototype.getChoiceNoFromElement=function(a){return Number(this.getClassnameNumericSuffix(a,"choice"))},e.prototype.getClassnameNumericSuffix=function(b,c){var d=a(b).attr("class");if(void 0!==d&&""!==d)for(var e=d.split(" "),f=0;f