Your IP : 216.73.216.147


Current Path : /home/lejardintz/www/media/foundry/3.1/scripts/
Upload File :
Current File : /home/lejardintz/www/media/foundry/3.1/scripts/selection.min.js

!function(){var moduleFactory=function($){var module=this,exports=function(){$.template("selection/box","<div data-selection-box></div>"),$.Controller("Selection",{pluginName:"selection",hostname:"selection",defaultOptions:{view:{box:"selection/box"},movable:!0,selectable:!0,spotlight:!0,autodraw:!0,autoWidth:50,autoHeight:50,tolerance:15,minWidth:0,minHeight:0,aspectRatio:null,"{selection}":"[data-selection-box]"}},function(self){return{init:function(){},disabled:!1,drawing:!1,createSelection:function(){self.removeSelection();
var selection=self.view.box().appendTo(self.element);self.trigger("selectionCreate",[selection,self])},removeSelection:function(){var selection=self.selection();selection.length<1||(self.selection().remove(),self.trigger("selectionRemove",[self]))},coords:function(event){var coords=[event.pageX,event.pageY];return coords.x=event.pageX,coords.y=event.pageY,coords},offset:function(){var selection=self.selection(),offset=selection.offset();return offset.top=offset.top+parseInt(selection.css("borderTopWidth")),offset.left=offset.left+parseInt(selection.css("borderLeftWidth")),offset.bottom=offset.top+selection.height(),offset.right=offset.left+selection.width(),offset
},calculateArea:function(collision,offset){collision||(collision="clip"),offset||(offset={x:0,y:0});var options=self.options,autoWidth=options.autoWidth,autoHeight=options.autoHeight,minWidth=options.minWidth,minHeight=options.minHeight,aspectRatio=options.aspectRatio,viewportEl=self.element,viewport=viewportEl.offset();viewport.width=viewportEl.width(),viewport.height=viewportEl.height(),viewport.right=viewport.width+viewport.left,viewport.bottom=viewport.height+viewport.top;var area=self.area;area.width=Math.abs(area.endX-area.startX),area.height=Math.abs(area.endY-area.startY);
var tolerance=options.tolerance,autodraw=options.autodraw&&area.width<tolerance&&area.height<tolerance;return area.width=Math.max(area.width,minWidth,autodraw?autoWidth:0),area.height=Math.max(area.height,minHeight,autodraw?autoHeight:0),aspectRatio&&(area.width=area.height*aspectRatio),autodraw&&(area.endX=area.startX+area.width,area.endY=area.startY+area.height,collision="flip",offset={x:area.width/-2,y:area.height/-2}),area.top=(area.startY<=area.endY?area.startY:area.endY)+offset.y,area.left=(area.startX<=area.endX?area.startX:area.endX)+offset.x,area.right=area.width+area.left,area.bottom=area.height+area.top,"clip"==collision&&(area.top<=viewport.top&&(area.top=viewport.top),area.bottom>=viewport.bottom&&(area.bottom=viewport.bottom),area.left<=viewport.left&&(area.left=viewport.left),area.right>=viewport.right&&(area.right=viewport.right),area.width=area.right-area.left,area.height=area.bottom-area.top,aspectRatio&&(area.left+area.height*aspectRatio>viewport.right?area.height=area.width/aspectRatio:area.width=area.height*aspectRatio,area.bottom=area.height+area.top,area.right=area.width+area.left)),"flip"==collision&&(area.top<=viewport.top&&(area.top=viewport.top,area.bottom=area.height+area.top),area.left<=viewport.left&&(area.left=viewport.left,area.right=area.width+area.left),area.right>=viewport.right&&(area.right=viewport.right,area.left=area.right-area.width),area.bottom>=viewport.bottom&&(area.bottom=viewport.bottom,area.top=area.bottom-area.height)),area.offset={top:area.startY,left:area.startX,bottom:area.startY+area.height,right:area.startX+area.width},area.pixel={top:area.top-viewport.top,left:area.left-viewport.left,width:area.width,height:area.height},area.decimal={top:area.pixel.top/viewport.height,left:area.pixel.left/viewport.width,width:area.width/viewport.width,height:area.height/viewport.height},area.percentage={top:100*area.decimal.top+"%",left:100*area.decimal.left+"%",width:100*area.decimal.width+"%",height:100*area.decimal.height+"%"},area.viewport=viewport,area
},set:function(type,prop,coords){var type=self[type]||(self[type]={});type[prop+"X"]=coords.x,type[prop+"Y"]=coords.y},drawSelection:function(){var area=self.calculateArea(),selection=self.selection().css(area.percentage);return self.trigger("selectionChange",[area,selection,self]),area},"{self} mousedown":function(viewport,event){var options=self.options;!self.disabled&&options.selectable&&(options.movable&&event.target==self.selection()[0]&&$.intersects(self.offset(),self.coords(event))||(event.preventDefault(),self.selection().length<1&&self.createSelection(),self.drawing=!0,self.set("area","start",self.coords(event)),$(document).on("mousemove.selection.selecting",function(event){self.drawing&&(self.set("area","end",self.coords(event)),self.drawSelection())
}).on("mouseup.selection.selecting",function(event){self.set("area","end",self.coords(event)),self.drawSelection(),$(document).off("mousemove.selection.selecting mouseup.selection.selecting")})))},moveSelection:function(){var anchor=self.anchor,dx=anchor.startX-anchor.endX,dy=anchor.startY-anchor.endY,area=self.calculateArea("flip",{x:-1*dx,y:-1*dy}),selection=self.selection().css(area.percentage);return self.trigger("selectionChange",[area,selection,self]),area},"{selection} mousedown":function(selection,event){var options=self.options;
if(!self.disabled&&options.movable&&$.intersects(self.offset(),self.coords(event))&&event.target===selection[0]){event.preventDefault();var autodraw=options.autodraw;options.autodraw=!1,self.drawing=!0,self.set("anchor","start",self.coords(event)),$(document).on("mousemove.selection.moving",function(event){self.drawing&&(self.set("anchor","end",self.coords(event)),self.moveSelection())}).on("mouseup.selection.moving",function(event){self.set("anchor","end",self.coords(event));var area=self.moveSelection();self.set("area","start",{x:area.left,y:area.top}),self.set("area","end",{x:area.right,y:area.bottom}),$(document).off("mousemove.selection.moving mouseup.selection.moving"),options.autodraw=autodraw
})}},"{self} selectionChange":function(el,event,area,selection){if(self.options.spotlight){var viewport=area.viewport,pixel=area.pixel;selection.css({marginTop:-1*pixel.top,marginLeft:-1*pixel.left,borderTopWidth:pixel.top,borderLeftWidth:pixel.left,borderBottomWidth:viewport.bottom-area.bottom,borderRightWidth:viewport.right-area.right})}},"{window} mousemove":function(el,event){var selection=self.selection();selection.length<1||self.options.spotlight&&self.selection().css("cursor",$.intersects(self.offset(),self.coords(event))?"move":"crosshair")
},"{window} keydown":function(el,event){27==event.keyCode&&self.removeSelection()}}})};exports(),module.resolveWith(exports)};FD31.module("selection",moduleFactory)}();