(function(d){var e={setHandlersDisplay:function(a){return d(".dolly-handler").css({display:a})}};d.widget("llp.dolly",{options:{rowSelector:"tr",cellSelector:"td",allowDiagonalSelection:!1,boxStyle:{border:"2px dotted black"},handleStyle:{width:"8px",height:"8px","background-color":"black",cursor:"crosshair"}},_boxStyle:{position:"absolute",width:"100%",height:"100%","z-index":"1000",visibility:"hidden"},_handleStyle:{position:"absolute",visibility:"hidden"},_wrapperStyle:{position:"relative",height:"100%", width:"100%",display:"inline-block"},_create:function(){this._createElements();this._boxBorder=this._getCssAsNumber("border-width",this.elements.box);this._bindEvents()},_createElements:function(){this.elements={};this.elements.box=d("
",{"class":"dolly-box"});this.elements.handle=d("
",{"class":"dolly-handler"});this.elements.wrapper=d("
",{"class":"dolly-wrapper"});this.elements.box.css(this._processBoxStyle());this.elements.handle.css(this._processHandleStyle());this.elements.wrapper.css(this._wrapperStyle); this.element.wrapInner(this.elements.wrapper);this.elements.wrapper=this.element.find(".dolly-wrapper");this.elements.wrapper.append(this.elements.box);this.elements.wrapper.append(this.elements.handle)},_processHandleStyle:function(){return d.extend(this.options.handleStyle,this._handleStyle,{right:-1*this._getCssAsNumber("padding-right")+"px",bottom:-1*this._getCssAsNumber("padding-bottom")+"px"})},_processBoxStyle:function(){return d.extend(this.options.boxStyle,this._boxStyle)},_bindEvents:function(){var a= this;this.element.hover(function(){a.elements.handle.css({visibility:"visible"})},function(){a.elements.handle.css({visibility:"hidden"})});this.elements.handle.on("mousedown",function(b){a._initialX=b.pageX;a._initialY=b.pageY;a._cloneX=0;a._cloneY=0;a.elements.box.css({visibility:"visible"});e.setHandlersDisplay("none");a._resetBoxSize();a._setTopLeftBoxPosition();d(window).disableSelection();var c=function(b){a._handleDrag(b)},f=function(){a.elements.box.css({visibility:"hidden"});e.setHandlersDisplay(""); d(window).enableSelection();d(window).off("mousemove",c);d(window).off("mouseup",f);a._trigger("cloned",null,{cloneX:a._cloneX,cloneY:a._cloneY,originX:a._getOriginX(),originY:a._getOriginY()})};d(window).on("mousemove",c);d(window).on("mouseup",f)})},_handleDrag:function(a){this._resetBoxSize();var b=this._cloneX,c=this._cloneY;this._cloneY=this._cloneX=0;this.options.allowDiagonalSelection?this._getCells(a.pageX,a.pageY):Math.abs(a.pageX-this._initialX)>Math.abs(a.pageY-this._initialY)?this._getCellsHorizontally(a.pageX): this._getCellsVertically(a.pageY);b===this._cloneX&&c===this._cloneY||this._trigger("selected",null,{cloneX:this._cloneX,cloneY:this._cloneY,originX:this._getOriginX(),originY:this._getOriginY()})},_getCells:function(a,b){athis._initialX&&b this._initialX&&b>this._initialY?(this._setTopLeftBoxPosition(),this._getCellsRight(this.element,a),this._getCellsDown(this.element,b)):athis._initialY&&(this._setTopRightBoxPosition(),this._getCellsLeft(this.element,a),this._getCellsDown(this.element,b))},_getCellsHorizontally:function(a){athis._getCellEdges(c).bottom-10||(this._cloneY-=1,this.elements.box.height(this.elements.box.offset().top+ this.elements.box.height()-this._getCellEdges(c).top+this._boxBorder),this._getCellsUp(c,b))},_getCellsLeft:function(a,b){var c=a.prev(this.options.cellSelector);0===c.length||b>this._getCellEdges(c).right-10||(this._cloneX-=1,this.elements.box.width(this.elements.box.offset().left+this.elements.box.width()-this._getCellEdges(c).left+this._boxBorder),this._getCellsLeft(c,b))},_getCellsRight:function(a,b){var c=a.next(this.options.cellSelector);0===c.length||b