Gitlab CSE Unil

Commit 9c82cf4d authored by M. Chardon's avatar M. Chardon
Browse files

correction bug cimaf fieldedge

parent 9e0d918e
Pipeline #43 failed with stages
...@@ -180,9 +180,10 @@ define(["paper"], function (paper) { ...@@ -180,9 +180,10 @@ define(["paper"], function (paper) {
// Update data.points // Update data.points
if (p1s) { if (p1s) {
json[1].data.points = [p1s, p1e, p2s, p2e].map(function (p) { json[1].data.points = [p1s, p1e, p2s, p2e].map(function (p) {
console.log(p);
return [p.x, p.y] return [p.x, p.y]
}); });
} else {
return null;
} }
// Cleanup useless properties // Cleanup useless properties
......
...@@ -249,7 +249,10 @@ function ($, _, paper, Signal, config, Users, tools) { ...@@ -249,7 +249,10 @@ function ($, _, paper, Signal, config, Users, tools) {
if (annot.data.prop) { if (annot.data.prop) {
obj.prop = annot.data.prop; obj.prop = annot.data.prop;
} }
serializedAnnotations.push(obj); //si l'objet n'a pas de contenu on ne le synchronise pas
if (obj.itemStr) {
serializedAnnotations.push(obj);
}
} }
return serializedAnnotations; return serializedAnnotations;
} }
......
...@@ -18763,9 +18763,10 @@ define('tools/fieldedges',["paper"], function (paper) { ...@@ -18763,9 +18763,10 @@ define('tools/fieldedges',["paper"], function (paper) {
// Update data.points // Update data.points
if (p1s) { if (p1s) {
json[1].data.points = [p1s, p1e, p2s, p2e].map(function (p) { json[1].data.points = [p1s, p1e, p2s, p2e].map(function (p) {
console.log(p);
return [p.x, p.y] return [p.x, p.y]
}); });
} else {
return null;
} }
   
// Cleanup useless properties // Cleanup useless properties
...@@ -24038,7 +24039,10 @@ function ($, _, paper, Signal, config, Users, tools) { ...@@ -24038,7 +24039,10 @@ function ($, _, paper, Signal, config, Users, tools) {
if (annot.data.prop) { if (annot.data.prop) {
obj.prop = annot.data.prop; obj.prop = annot.data.prop;
} }
serializedAnnotations.push(obj); //si l'objet n'a pas de contenu on ne le synchronise pas
if (obj.itemStr) {
serializedAnnotations.push(obj);
}
} }
return serializedAnnotations; return serializedAnnotations;
} }
...@@ -18763,9 +18763,10 @@ define('tools/fieldedges',["paper"], function (paper) { ...@@ -18763,9 +18763,10 @@ define('tools/fieldedges',["paper"], function (paper) {
// Update data.points // Update data.points
if (p1s) { if (p1s) {
json[1].data.points = [p1s, p1e, p2s, p2e].map(function (p) { json[1].data.points = [p1s, p1e, p2s, p2e].map(function (p) {
console.log(p);
return [p.x, p.y] return [p.x, p.y]
}); });
} else {
return null;
} }
   
// Cleanup useless properties // Cleanup useless properties
...@@ -24038,7 +24039,10 @@ function ($, _, paper, Signal, config, Users, tools) { ...@@ -24038,7 +24039,10 @@ function ($, _, paper, Signal, config, Users, tools) {
if (annot.data.prop) { if (annot.data.prop) {
obj.prop = annot.data.prop; obj.prop = annot.data.prop;
} }
serializedAnnotations.push(obj); //si l'objet n'a pas de contenu on ne le synchronise pas
if (obj.itemStr) {
serializedAnnotations.push(obj);
}
} }
return serializedAnnotations; return serializedAnnotations;
} }
...@@ -18763,9 +18763,10 @@ define('tools/fieldedges',["paper"], function (paper) { ...@@ -18763,9 +18763,10 @@ define('tools/fieldedges',["paper"], function (paper) {
// Update data.points // Update data.points
if (p1s) { if (p1s) {
json[1].data.points = [p1s, p1e, p2s, p2e].map(function (p) { json[1].data.points = [p1s, p1e, p2s, p2e].map(function (p) {
console.log(p);
return [p.x, p.y] return [p.x, p.y]
}); });
} else {
return null;
} }
   
// Cleanup useless properties // Cleanup useless properties
...@@ -24038,7 +24039,10 @@ function ($, _, paper, Signal, config, Users, tools) { ...@@ -24038,7 +24039,10 @@ function ($, _, paper, Signal, config, Users, tools) {
if (annot.data.prop) { if (annot.data.prop) {
obj.prop = annot.data.prop; obj.prop = annot.data.prop;
} }
serializedAnnotations.push(obj); //si l'objet n'a pas de contenu on ne le synchronise pas
if (obj.itemStr) {
serializedAnnotations.push(obj);
}
} }
return serializedAnnotations; return serializedAnnotations;
} }
...@@ -18763,9 +18763,10 @@ define('tools/fieldedges',["paper"], function (paper) { ...@@ -18763,9 +18763,10 @@ define('tools/fieldedges',["paper"], function (paper) {
// Update data.points // Update data.points
if (p1s) { if (p1s) {
json[1].data.points = [p1s, p1e, p2s, p2e].map(function (p) { json[1].data.points = [p1s, p1e, p2s, p2e].map(function (p) {
console.log(p);
return [p.x, p.y] return [p.x, p.y]
}); });
} else {
return null;
} }
   
// Cleanup useless properties // Cleanup useless properties
...@@ -24038,7 +24039,10 @@ function ($, _, paper, Signal, config, Users, tools) { ...@@ -24038,7 +24039,10 @@ function ($, _, paper, Signal, config, Users, tools) {
if (annot.data.prop) { if (annot.data.prop) {
obj.prop = annot.data.prop; obj.prop = annot.data.prop;
} }
serializedAnnotations.push(obj); //si l'objet n'a pas de contenu on ne le synchronise pas
if (obj.itemStr) {
serializedAnnotations.push(obj);
}
} }
return serializedAnnotations; return serializedAnnotations;
} }
...@@ -15876,7 +15876,7 @@ define('tools/text',["paper","jquery"],function(a,b){function c(a,b){a in w?(x=w ...@@ -15876,7 +15876,7 @@ define('tools/text',["paper","jquery"],function(a,b){function c(a,b){a in w?(x=w
/*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */ /*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */
define('tools/arrow',["paper"],function(a){function b(a){var b=this.exportJSON({asString:!1});try{b[1][1].data.from=[this.data.from.x,this.data.from.y],b[1][1].data.to=[this.data.to.x,this.data.to.y]}catch(a){console.error(a)}return a&&a.asString?JSON.stringify(b):b}function c(b,c,d){var e=b[1][1],f=b[0][1][e.symbol][1][1],h=f.fillColor&&(f.fillColor.length<3||0!==f.fillColor[3]),i=parseFloat(e.opacity)||1,k=a.project.activeLayer;c.activate(),e.data.from.length>2&&(e.data.from=e.data.from.splice(1)),e.data.to.length>2&&(e.data.to=e.data.to.splice(1));var m=g({from:new a.Point(e.data.from),prop:e.data.prop,scale:e.data.scale||{h:1,v:1}},d);return m.opacity=i,j.call(m,f.strokeColor),l.call(m,h),n.call(m,f.strokeWidth),u(m,{from:m.data.from,to:new a.Point(e.data.to)}),k.activate(),m}function d(){if(!y){var b=new a.Path({segments:[[0,-5],[0,5],new a.Segment([20,5]),[10,30],new a.Segment([50,0]),[10,-30],new a.Segment([20,-5])],strokeJoin:"round",strokeScaling:!1,closed:!0});z=1,A=3,B=4,C=b.segments[A].point.x-b.segments[z].point.x,y=new a.Symbol(b),b.remove()}}function e(a,b){b=b||this;var c=b.symbol.definition.segments[2].point.x,d=b.symbol.definition.segments[B].point.x;return(b.globalToLocal(a).x-c)/(d-c)>.1}function f(a,b){return b=b||this,(a=a||b.symbol.definition.segments[B].point.x-b.symbol.definition.segments[z].point.x)-(b.symbol.definition.segments[B].point.x-b.symbol.definition.segments[A].point.x)<C}function g(b,c){var e,f,g,h,v;d(),e=new a.PlacedSymbol(y.clone()),f=e.symbol.definition.bounds.width,g=new a.Point(b.from),h=new a.Point([g.x+f,g.y]),v=b.scale||{h:1,v:1},e.pivot=[-f/2,0],u(e,{from:g,to:h}),i.call(e,v),l.call(e,a.project.currentStyle.fillColor),j.call(e,a.project.currentStyle.strokeColor),n.call(e,a.project.currentStyle.strokeWidth),b.prop="object"==typeof b.prop?b.prop:{};for(var w in G)b.prop.hasOwnProperty(w)||(b.prop[w]=G[w]);return e.data={tId:"a"+e._id,type:D,prop:b.prop,from:g,to:h,scale:v,setColor:j,getColor:k,setFill:l,getFill:m,setStrokeWidth:n,getStrokeWidth:o,setDragMode:p,itemMouseDrag:r},!1!==c&&(e.onMouseDown=q,e.onMouseUp=s,e.onPropertyChange=t),e}function h(){this.data.from=this.position,this.data.to=this.data.from.add(new a.Point({length:this.symbol.definition.bounds.width,angle:this.rotation}))}function i(a){var b=y.definition.bounds.width;this.symbol.definition.scale(a.h,a.v,[-b/2,0]),this.data.scale||(this.data.scale={h:1,v:1}),this.data.scale.h*=a.h,this.data.scale.v*=a.v,h.call(this)}function j(a){this.symbol.definition.strokeColor=a,this.symbol.definition.fillColor.alpha>0&&(this.symbol.definition.fillColor=a)}function k(){return this.symbol.definition.strokeColor}function l(a){this.symbol.definition.fillColor=a?this.symbol.definition.strokeColor:H}function m(){return this.symbol.definition.fillColor.alpha>0}function n(a){this.symbol.definition.strokeWidth=a}function o(){return this.symbol.definition.strokeWidth}function p(a,b){a in I?(J=I[a],K=b):(J=null,K={},L=!1)}function q(a){if(this.selected&&!E){J=I.FULL_DRAG;var b=this.data.to,c=this.data.from;e.call(this,a.point)?p("DRAG_TO",{delta:b.subtract(a.point)}):c.getDistance(a.point)<30&&p("DRAG_FROM",{delta:c.subtract(a.point)}),this.attach("mousedrag",r)}}function r(a){if(!E){L=!0;var b={from:this.data.from,to:this.data.to};switch(J){case I.FULL_DRAG:this.translate(a.delta),h.call(this);break;case I.DRAG_TO:b.to=K.delta?a.point.add(K.delta):a.point,delete b.from,u(this,b);break;case I.DRAG_FROM:b.from=K.delta?a.point.add(K.delta):a.point,delete b.to,u(this,b);break;case I.DRAG_HANDLE:if("right"!==K.nameParts[1])L=!1;else{var c=a.point.subtract(b.from).project(b.to.subtract(b.from)),d=c.length/this.symbol.definition.bounds.width,e=a.event.shiftKey?d:a.point.subtract(c.add(b.from)).length/this.symbol.definition.bounds.height*2;i.call(this,{h:d,v:e})}break;default:L=!1}}}function s(a){this.detach("mousedrag",r),h.call(this),J=null,L&&F.annotationChanged.dispatch(this),L=!1}function t(a,b){}function u(b,c){var d,e,g,h,i="";if(c.from||(c.from=b.data.from,i="to"),c.to||(c.to=b.data.to,i="from"),d=c.to.subtract(c.from),e=d.angle,g=b.symbol.definition.bounds.width,h=d.length-g,f.call(b,g+h)&&(h=0,"from"===i&&(c.from=c.to.subtract(new a.Point({length:g,angle:e})))),b.rotation=e,b.position=c.from,0!==h)for(var j,k=2;j=b.symbol.definition.segments[k];k++)j.point.x+=h;b.data.from=c.from,b.data.to=c.to}function v(a){return a.data&&a.data.type===D?a:a.parent?v(a.parent):null}function w(b){var c,d;if(c=a.project.activeLayer.hitTest(b,{tolerance:7,fill:!0,stroke:!0,segments:!0,handles:!0,ends:!0,bounds:!0,selected:!0}),c||(c=a.project.activeLayer.hitTest(b,{fill:!0,stroke:!0})),!c||!c.item)return!1;if(!(d=v(c.item)))return!1;if(d.selected=!0,"bounds"===c.type){"right"===c.name.split("-")[1]&&p("DRAG_HANDLE",{nameStr:c.name,nameParts:c.name.split("-"),item:d})}return!0}function x(a){return a!==E&&(E=a),E}var y,z,A,B,C,D="arrow",E=!1,F={annotationAdded:null,annotationSelected:null,annotationChanged:null},G={comment:"",fill:!0},H=new a.Color([0,0,0,0]),I={FULL_DRAG:1,DRAG_TO:2,DRAG_FROM:3,DRAG_HANDLE:4},J=null,K={},L=!1,M=!1,N=null,O=null,P={onMouseDown:function(b){E||(M=!1,O=null,w(b.point)||(a.project.deselectAll(),F.annotationSelected.dispatch(null),M=!0,N=b.point,O=g({from:N},!0),O.visible=!1))},onMouseDrag:function(a){E||(M&&O?(u(O,{from:N,to:a.point}),O.visible=!0):J===I.DRAG_HANDLE&&K.item&&r.call(K.item,a))},onMouseUp:function(a){p(null),M&&O&&(F.annotationAdded.dispatch(O),M=!1,O.selected=!0,O.visible=!0,O=null)}};return{name:D,tool:new a.Tool(P),setRo:x,registerEvent:function(a,b){F[a]=b},exportJSON:b,importJSON:c,listeners:{}}}); define('tools/arrow',["paper"],function(a){function b(a){var b=this.exportJSON({asString:!1});try{b[1][1].data.from=[this.data.from.x,this.data.from.y],b[1][1].data.to=[this.data.to.x,this.data.to.y]}catch(a){console.error(a)}return a&&a.asString?JSON.stringify(b):b}function c(b,c,d){var e=b[1][1],f=b[0][1][e.symbol][1][1],h=f.fillColor&&(f.fillColor.length<3||0!==f.fillColor[3]),i=parseFloat(e.opacity)||1,k=a.project.activeLayer;c.activate(),e.data.from.length>2&&(e.data.from=e.data.from.splice(1)),e.data.to.length>2&&(e.data.to=e.data.to.splice(1));var m=g({from:new a.Point(e.data.from),prop:e.data.prop,scale:e.data.scale||{h:1,v:1}},d);return m.opacity=i,j.call(m,f.strokeColor),l.call(m,h),n.call(m,f.strokeWidth),u(m,{from:m.data.from,to:new a.Point(e.data.to)}),k.activate(),m}function d(){if(!y){var b=new a.Path({segments:[[0,-5],[0,5],new a.Segment([20,5]),[10,30],new a.Segment([50,0]),[10,-30],new a.Segment([20,-5])],strokeJoin:"round",strokeScaling:!1,closed:!0});z=1,A=3,B=4,C=b.segments[A].point.x-b.segments[z].point.x,y=new a.Symbol(b),b.remove()}}function e(a,b){b=b||this;var c=b.symbol.definition.segments[2].point.x,d=b.symbol.definition.segments[B].point.x;return(b.globalToLocal(a).x-c)/(d-c)>.1}function f(a,b){return b=b||this,(a=a||b.symbol.definition.segments[B].point.x-b.symbol.definition.segments[z].point.x)-(b.symbol.definition.segments[B].point.x-b.symbol.definition.segments[A].point.x)<C}function g(b,c){var e,f,g,h,v;d(),e=new a.PlacedSymbol(y.clone()),f=e.symbol.definition.bounds.width,g=new a.Point(b.from),h=new a.Point([g.x+f,g.y]),v=b.scale||{h:1,v:1},e.pivot=[-f/2,0],u(e,{from:g,to:h}),i.call(e,v),l.call(e,a.project.currentStyle.fillColor),j.call(e,a.project.currentStyle.strokeColor),n.call(e,a.project.currentStyle.strokeWidth),b.prop="object"==typeof b.prop?b.prop:{};for(var w in G)b.prop.hasOwnProperty(w)||(b.prop[w]=G[w]);return e.data={tId:"a"+e._id,type:D,prop:b.prop,from:g,to:h,scale:v,setColor:j,getColor:k,setFill:l,getFill:m,setStrokeWidth:n,getStrokeWidth:o,setDragMode:p,itemMouseDrag:r},!1!==c&&(e.onMouseDown=q,e.onMouseUp=s,e.onPropertyChange=t),e}function h(){this.data.from=this.position,this.data.to=this.data.from.add(new a.Point({length:this.symbol.definition.bounds.width,angle:this.rotation}))}function i(a){var b=y.definition.bounds.width;this.symbol.definition.scale(a.h,a.v,[-b/2,0]),this.data.scale||(this.data.scale={h:1,v:1}),this.data.scale.h*=a.h,this.data.scale.v*=a.v,h.call(this)}function j(a){this.symbol.definition.strokeColor=a,this.symbol.definition.fillColor.alpha>0&&(this.symbol.definition.fillColor=a)}function k(){return this.symbol.definition.strokeColor}function l(a){this.symbol.definition.fillColor=a?this.symbol.definition.strokeColor:H}function m(){return this.symbol.definition.fillColor.alpha>0}function n(a){this.symbol.definition.strokeWidth=a}function o(){return this.symbol.definition.strokeWidth}function p(a,b){a in I?(J=I[a],K=b):(J=null,K={},L=!1)}function q(a){if(this.selected&&!E){J=I.FULL_DRAG;var b=this.data.to,c=this.data.from;e.call(this,a.point)?p("DRAG_TO",{delta:b.subtract(a.point)}):c.getDistance(a.point)<30&&p("DRAG_FROM",{delta:c.subtract(a.point)}),this.attach("mousedrag",r)}}function r(a){if(!E){L=!0;var b={from:this.data.from,to:this.data.to};switch(J){case I.FULL_DRAG:this.translate(a.delta),h.call(this);break;case I.DRAG_TO:b.to=K.delta?a.point.add(K.delta):a.point,delete b.from,u(this,b);break;case I.DRAG_FROM:b.from=K.delta?a.point.add(K.delta):a.point,delete b.to,u(this,b);break;case I.DRAG_HANDLE:if("right"!==K.nameParts[1])L=!1;else{var c=a.point.subtract(b.from).project(b.to.subtract(b.from)),d=c.length/this.symbol.definition.bounds.width,e=a.event.shiftKey?d:a.point.subtract(c.add(b.from)).length/this.symbol.definition.bounds.height*2;i.call(this,{h:d,v:e})}break;default:L=!1}}}function s(a){this.detach("mousedrag",r),h.call(this),J=null,L&&F.annotationChanged.dispatch(this),L=!1}function t(a,b){}function u(b,c){var d,e,g,h,i="";if(c.from||(c.from=b.data.from,i="to"),c.to||(c.to=b.data.to,i="from"),d=c.to.subtract(c.from),e=d.angle,g=b.symbol.definition.bounds.width,h=d.length-g,f.call(b,g+h)&&(h=0,"from"===i&&(c.from=c.to.subtract(new a.Point({length:g,angle:e})))),b.rotation=e,b.position=c.from,0!==h)for(var j,k=2;j=b.symbol.definition.segments[k];k++)j.point.x+=h;b.data.from=c.from,b.data.to=c.to}function v(a){return a.data&&a.data.type===D?a:a.parent?v(a.parent):null}function w(b){var c,d;if(c=a.project.activeLayer.hitTest(b,{tolerance:7,fill:!0,stroke:!0,segments:!0,handles:!0,ends:!0,bounds:!0,selected:!0}),c||(c=a.project.activeLayer.hitTest(b,{fill:!0,stroke:!0})),!c||!c.item)return!1;if(!(d=v(c.item)))return!1;if(d.selected=!0,"bounds"===c.type){"right"===c.name.split("-")[1]&&p("DRAG_HANDLE",{nameStr:c.name,nameParts:c.name.split("-"),item:d})}return!0}function x(a){return a!==E&&(E=a),E}var y,z,A,B,C,D="arrow",E=!1,F={annotationAdded:null,annotationSelected:null,annotationChanged:null},G={comment:"",fill:!0},H=new a.Color([0,0,0,0]),I={FULL_DRAG:1,DRAG_TO:2,DRAG_FROM:3,DRAG_HANDLE:4},J=null,K={},L=!1,M=!1,N=null,O=null,P={onMouseDown:function(b){E||(M=!1,O=null,w(b.point)||(a.project.deselectAll(),F.annotationSelected.dispatch(null),M=!0,N=b.point,O=g({from:N},!0),O.visible=!1))},onMouseDrag:function(a){E||(M&&O?(u(O,{from:N,to:a.point}),O.visible=!0):J===I.DRAG_HANDLE&&K.item&&r.call(K.item,a))},onMouseUp:function(a){p(null),M&&O&&(F.annotationAdded.dispatch(O),M=!1,O.selected=!0,O.visible=!0,O=null)}};return{name:D,tool:new a.Tool(P),setRo:x,registerEvent:function(a,b){F[a]=b},exportJSON:b,importJSON:c,listeners:{}}});
/*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */ /*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */
define('tools/fieldedges',["paper"],function(a){function b(b,g){b.style="object"==typeof b.style?b.style:{};for(var h in M)b.style.hasOwnProperty(h)||(b.style[h]=M[h]);b.firstEdge=new a.Path.Line({from:b.p1s,to:b.p1e}),b.secondEdge=new a.Path.Line({from:b.p2s,to:b.p2e});var i=new a.Group({children:[b.firstEdge,b.secondEdge],style:b.style});b.prop="object"==typeof b.prop?b.prop:{};for(var h in I)b.prop.hasOwnProperty(h)||(b.prop[h]=I[h]);var j=[b.firstEdge.segments[0].point,b.firstEdge.segments[1].point,b.secondEdge.segments[0].point,b.secondEdge.segments[1].point].map(function(a){return[a.x,a.y]});return i.data={tId:"a"+i._id,type:C,prop:b.prop,points:j,itemMouseDrag:e,setColor:c},g||(i.onMouseDown=function(b){this.oGetSelected()?d(b):(a.project.deselectAll(),this.oSetSelected(!0),G.annotationSelected.dispatch(this))},i.oGetSelected=function(){for(var a,b=0;a=this.children[b];b++)if(!a.selected)return!1;return!0},i.oSetSelected=function(a){this.children.map(function(b){b.selected=a})},i.onMouseUp=f),G.annotationAdded.dispatch(i),i}function c(){this.style.strokeColor=D}function d(a){K!==J.DONE&&K!==J.CREATED_BOTH||p(a)}function e(a){K===J.EDITING&&l(a)}function f(a){K===J.EDITING&&q(a)}function g(a){var b=this.exportJSON({asString:!1});t&&(b[1].data.points=[t,u,v,w].map(function(a){return console.log(a),[a.x,a.y]}));var c=["fontFamily","font","fontSize","fontLeading","leading","selected"];return[b[1],b[1].children[0][1],b[1].children[1][1]].forEach(function(a){c.forEach(function(b){a.hasOwnProperty(b)&&delete a[b]})}),b=a&&!1===a.asString?b:JSON.stringify(b)}function h(c,d,e){var f=c[1],g=f.data&&f.data.points;if(!g)return null;var h={};try{h.strokeWidth=f.children[0][1].strokeWidth}catch(a){}var i=a.project.activeLayer;d.activate();var j=b({p1s:g[0],p1e:g[1],p2s:g[2],p2e:g[3],style:h,prop:f.data.prop});return e&&(x=j.children[0],y=j.children[1],k(),K=J.CREATED_BOTH),i.activate(),j}function i(){t=u=v=w=B=null,x&&x.remove(),y&&y.remove(),x=y=null}function j(b){switch(K){case J.READY:break;case J.CREATE_FIRST:x&&x.remove(),x=new a.Path.Line({from:t,to:u}),x.style=L;break;case J.CREATE_SECOND:x&&x.remove(),x=new a.Path.Line({from:t,to:u}),x.style=M,y&&y.remove(),y=new a.Path.Line({from:v,to:w}),y.style=L;break;case J.CREATED_BOTH:}}function k(){t=x.segments[0].point,u=x.segments[1].point,v=y.segments[0].point,w=y.segments[1].point,B=v.subtract(t)}function l(a){if(z)if(isNaN(parseInt(A,2)))z.translate(a.delta);else{var b=z===x,c=b?y:x,d=b?a.point.add(B):a.point.subtract(B);z.insert(A,a.point),z.segments[A+1].remove(),c.insert(A,d),c.segments[A+1].remove()}}function m(a){t=u=a.point,K=J.CREATE_FIRST}function n(a){v=t,w=u,K=J.CREATE_SECOND}function o(a){K=J.CREATED_BOTH,B=v.subtract(t);var c=b({p1s:t,p1e:u,p2s:v,p2e:w});x&&x.remove(),x=c.children[0],y&&y.remove(),y=c.children[1],k()}function p(b){K=J.EDITING,z=A=null;var c=a.project.activeLayer.hitTest(b.point,F);c&&"pixel"!==c.type&&(c.item===x?z=x:c.item===y&&(z=y),a.project.deselectAll(),z.selected=!0,G.annotationSelected.dispatch(z),z&&"segment"===c.type&&(A=z.segments[0]===c.segment?0:1))}function q(a){K=J.DONE;var b=z?z.parent:null;z=A=null,k(),b&&G.annotationChanged.dispatch(b)}function r(a){H&&(x.strokeWidth=a,y.strokeWidth=a,E=a)}function s(a){H=a===C,H?$("#tool-colorselect").hide():$("#tool-colorselect .c7").hide()}var t,u,v,w,x,y,z,A,B,C="fieldedges",D=new a.Color("#E100FF"),E=3,F={segments:!0,stroke:!0,fill:!1,tolerance:5,bounds:!1,handles:!0},G={annotationAdded:null,annotationSelected:null,annotationChanged:null},H=!1,I={comment:""},J={READY:1,CREATE_FIRST:2,CREATE_SECOND:3,CREATED_BOTH:4,EDITING:5,DONE:6},K=J.READY,L={strokeWidth:E,strokeColor:D,dashArray:[9,4]},M={strokeWidth:E,strokeColor:D},N={onMouseDown:function(a){switch(K){case J.READY:i(),m(a);break;case J.CREATE_FIRST:n(a);break;case J.CREATE_SECOND:o(a);break;case J.CREATED_BOTH:case J.DONE:p(a)}j(a)},onMouseMove:function(a){switch(K){case J.CREATE_FIRST:u=a.point,j(a);break;case J.CREATE_SECOND:w=a.point,v=t.add(w.subtract(u)),j(a);break;case J.EDITING:l(a)}},onMouseUp:function(a){switch(K){case J.EDITING:q(a)}}};return{name:C,tool:new a.Tool(N),registerEvent:function(a,b){G[a]=b},exportJSON:g,importJSON:h,listeners:{onStrokeWidthChanged:r,onToolActivated:s}}}); define('tools/fieldedges',["paper"],function(a){function b(b,g){b.style="object"==typeof b.style?b.style:{};for(var h in M)b.style.hasOwnProperty(h)||(b.style[h]=M[h]);b.firstEdge=new a.Path.Line({from:b.p1s,to:b.p1e}),b.secondEdge=new a.Path.Line({from:b.p2s,to:b.p2e});var i=new a.Group({children:[b.firstEdge,b.secondEdge],style:b.style});b.prop="object"==typeof b.prop?b.prop:{};for(var h in I)b.prop.hasOwnProperty(h)||(b.prop[h]=I[h]);var j=[b.firstEdge.segments[0].point,b.firstEdge.segments[1].point,b.secondEdge.segments[0].point,b.secondEdge.segments[1].point].map(function(a){return[a.x,a.y]});return i.data={tId:"a"+i._id,type:C,prop:b.prop,points:j,itemMouseDrag:e,setColor:c},g||(i.onMouseDown=function(b){this.oGetSelected()?d(b):(a.project.deselectAll(),this.oSetSelected(!0),G.annotationSelected.dispatch(this))},i.oGetSelected=function(){for(var a,b=0;a=this.children[b];b++)if(!a.selected)return!1;return!0},i.oSetSelected=function(a){this.children.map(function(b){b.selected=a})},i.onMouseUp=f),G.annotationAdded.dispatch(i),i}function c(){this.style.strokeColor=D}function d(a){K!==J.DONE&&K!==J.CREATED_BOTH||p(a)}function e(a){K===J.EDITING&&l(a)}function f(a){K===J.EDITING&&q(a)}function g(a){var b=this.exportJSON({asString:!1});if(!t)return null;b[1].data.points=[t,u,v,w].map(function(a){return[a.x,a.y]});var c=["fontFamily","font","fontSize","fontLeading","leading","selected"];return[b[1],b[1].children[0][1],b[1].children[1][1]].forEach(function(a){c.forEach(function(b){a.hasOwnProperty(b)&&delete a[b]})}),b=a&&!1===a.asString?b:JSON.stringify(b)}function h(c,d,e){var f=c[1],g=f.data&&f.data.points;if(!g)return null;var h={};try{h.strokeWidth=f.children[0][1].strokeWidth}catch(a){}var i=a.project.activeLayer;d.activate();var j=b({p1s:g[0],p1e:g[1],p2s:g[2],p2e:g[3],style:h,prop:f.data.prop});return e&&(x=j.children[0],y=j.children[1],k(),K=J.CREATED_BOTH),i.activate(),j}function i(){t=u=v=w=B=null,x&&x.remove(),y&&y.remove(),x=y=null}function j(b){switch(K){case J.READY:break;case J.CREATE_FIRST:x&&x.remove(),x=new a.Path.Line({from:t,to:u}),x.style=L;break;case J.CREATE_SECOND:x&&x.remove(),x=new a.Path.Line({from:t,to:u}),x.style=M,y&&y.remove(),y=new a.Path.Line({from:v,to:w}),y.style=L;break;case J.CREATED_BOTH:}}function k(){t=x.segments[0].point,u=x.segments[1].point,v=y.segments[0].point,w=y.segments[1].point,B=v.subtract(t)}function l(a){if(z)if(isNaN(parseInt(A,2)))z.translate(a.delta);else{var b=z===x,c=b?y:x,d=b?a.point.add(B):a.point.subtract(B);z.insert(A,a.point),z.segments[A+1].remove(),c.insert(A,d),c.segments[A+1].remove()}}function m(a){t=u=a.point,K=J.CREATE_FIRST}function n(a){v=t,w=u,K=J.CREATE_SECOND}function o(a){K=J.CREATED_BOTH,B=v.subtract(t);var c=b({p1s:t,p1e:u,p2s:v,p2e:w});x&&x.remove(),x=c.children[0],y&&y.remove(),y=c.children[1],k()}function p(b){K=J.EDITING,z=A=null;var c=a.project.activeLayer.hitTest(b.point,F);c&&"pixel"!==c.type&&(c.item===x?z=x:c.item===y&&(z=y),a.project.deselectAll(),z.selected=!0,G.annotationSelected.dispatch(z),z&&"segment"===c.type&&(A=z.segments[0]===c.segment?0:1))}function q(a){K=J.DONE;var b=z?z.parent:null;z=A=null,k(),b&&G.annotationChanged.dispatch(b)}function r(a){H&&(x.strokeWidth=a,y.strokeWidth=a,E=a)}function s(a){H=a===C,H?$("#tool-colorselect").hide():$("#tool-colorselect .c7").hide()}var t,u,v,w,x,y,z,A,B,C="fieldedges",D=new a.Color("#E100FF"),E=3,F={segments:!0,stroke:!0,fill:!1,tolerance:5,bounds:!1,handles:!0},G={annotationAdded:null,annotationSelected:null,annotationChanged:null},H=!1,I={comment:""},J={READY:1,CREATE_FIRST:2,CREATE_SECOND:3,CREATED_BOTH:4,EDITING:5,DONE:6},K=J.READY,L={strokeWidth:E,strokeColor:D,dashArray:[9,4]},M={strokeWidth:E,strokeColor:D},N={onMouseDown:function(a){switch(K){case J.READY:i(),m(a);break;case J.CREATE_FIRST:n(a);break;case J.CREATE_SECOND:o(a);break;case J.CREATED_BOTH:case J.DONE:p(a)}j(a)},onMouseMove:function(a){switch(K){case J.CREATE_FIRST:u=a.point,j(a);break;case J.CREATE_SECOND:w=a.point,v=t.add(w.subtract(u)),j(a);break;case J.EDITING:l(a)}},onMouseUp:function(a){switch(K){case J.EDITING:q(a)}}};return{name:C,tool:new a.Tool(N),registerEvent:function(a,b){G[a]=b},exportJSON:g,importJSON:h,listeners:{onStrokeWidthChanged:r,onToolActivated:s}}});
/*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */ /*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */
define('tools/concordantstr',["paper"],function(a){function b(a){var b=this.exportJSON({asString:!1});return b[1].strokeColor||(b[1].strokeWidth=0),delete b[1].fontFamily,delete b[1].font,delete b[1].fontSize,delete b[1].leading,a&&a.asString?JSON.stringify(b):b}function c(b,c,d){var e=b[1],f=a.project.activeLayer;c.activate();var h=g({from:e.segments[0],to:e.segments[1],strokeWidth:e.strokeWidth,prop:e.data.prop},{not_interactive:!0});return f.activate(),h}function d(a){z=a}function e(a){A=Math.floor(1.5*a)}function f(a){(y=a===w)&&$("#tool-colorselect").hide()}function g(b,c){var d=new a.Path.Line({from:b.from,to:b.to});b.prop="object"==typeof b.prop?b.prop:{};for(var e in O)b.prop.hasOwnProperty(e)||(b.prop[e]=O[e]);return d.style=C[b.prop.confidence],parseInt(b.strokeWidth,10)&&(d.strokeWidth=b.strokeWidth),d.data={tId:"a"+d._id,type:w,prop:b.prop,itemMouseDrag:j,itemMouseUp:k,setColor:h},c&&c.not_interactive||(d.selected=!0,x.annotationSelected.dispatch(d)),d.onMouseDown=i,d.onKeyDown=l,d.onKeyUp=m,d.onPropertyChange=n,d}function h(){this.style.strokeColor=B.strokeColor}function i(b){var c=this;I=this;var d=c.hitTest(b.point,D);c.layer.activate(),a.project.deselectAll(),c.selected=!0,x.annotationSelected.dispatch(c),J=L=M=K=null,"segment"===d.type?(J=d.segment.index,K=z+(I.segments[1-J].point.x<z?1:-1)*A):(L=I.getFirstSegment().point.x<z?0:1,M=1-L),N=!1,x.annotationSelected.dispatch(c)}function j(a){a.tool&&(null!==J?t(a):I&&I.segments[L].point.x+a.delta.x<=z-A&&I.segments[M].point.x+a.delta.x>=z+A&&(I.translate(a.delta),N=!0))}function k(a){a.tool&&(I&&N&&(x.annotationChanged.dispatch([I]),N=!1),J=L=M=I=K=null)}function l(b){var c;switch(b.key){case"up":c=[0,-1];break;case"down":c=[0,1]}c&&(c=new a.Point(c).multiply(a.view.zoom<4.5?1:.5),I=this,this.translate(c),N=!0,a.view.draw())}function m(a){switch(a.key){case"up":case"down":N&&(x.annotationChanged.dispatch([I]),N=!1)}}function n(b,c){"confidence"===b&&(this.style=C[c],a.view.draw())}function o(a,b){return a.x<=z&&b.x>=z+A||a.x>=z&&b.x<=z-A}function p(){G&&G.remove(),F=null,E=!1}function q(){var a=G?G.segments[1].point.clone():null;if(o(F,a)){G&&(G.remove(),G=null);var b=g({from:F,to:a});x.annotationAdded.dispatch(b),F=null,E=!1}}function r(b,c,d){d?v&&(b.segments[c].point.y=v.y,a.view.draw()):(v=b.segments[c].point.clone(),b.segments[c].point.y=b.segments[1-c].point.y)}function s(b){G?(G.segments[1].point=b.point,b.event.shiftKey&&r(G,1)):(G=new a.Path.Line({from:F,to:b.point}),G.style=B,G.dashArray=[10,5]),G.opacity=o(F,b.point)?1:.5,G.dashArray=o(F,b.point)?null:[10,5]}function t(a){var b=a.point.clone();o(I.segments[1-J].point,b)||(b.x=K),I.segments[J].point=b,a.event.shiftKey&&r(I,J),N=!0}var u,v,w="concordantstr",x={annotationAdded:null,annotationSelected:null},y=!1,z=0,A=10,B={strokeWidth:3,strokeColor:"red"},C={1:{strokeColor:new a.Color("#FF3737"),dashArray:[10,10]},2:{strokeColor:new a.Color("#FF3737"),dashArray:[30,10]},3:{strokeColor:new a.Color("#FF0000"),dashArray:null}},D={segments:!0,stroke:!0,fill:!1,tolerance:5,bounds:!1,handles:!0},E=!0,F=null,G=null,H=!1,I=null,J=null,K=null,L=null,M=null,N=!1,O={confidence:3,comment:""},P={onMouseDown:function(b){if(F)G&&!H&&q();else{var c=a.project.activeLayer.hitTest(b.point,D);c?c.item.onMouseDown(b):(a.project.deselectAll(),x.annotationSelected.dispatch(null),F||(J=I=null,E=!0,G&&G.remove(),G=null,F=b.point,H=!1))}},onMouseDrag:function(a){E&&F&&(H=!0,s(a)),I&&I.data.itemMouseDrag(a)},onMouseMove:function(a){E&&F&&s(a)},onMouseUp:function(a){F?G&&H&&(s(a),q()):I&&I.data.itemMouseUp(a),J=I=null},onKeyDown:function(b){switch(b.key){case"enter":E&&q();break;case"escape":E&&p();break;case"shift":G?r(G,1):I&&null!==J&&r(I,J);break;case"up":case"down":for(var c,d=a.project.getSelectedItems(),e=0;c=d[e];e++)if(c.data.type&&"function"==typeof c.onKeyDown){c.onKeyDown(b);break}}},onKeyUp:function(b){switch(b.key){case"shift":G?r(G,1,!0):I&&J&&r(I,J,!0);break;case"up":case"down":for(var c,d=a.project.getSelectedItems(),e=0;c=d[e];e++)if(c.data.type&&"function"==typeof c.onKeyUp){c.onKeyUp(b);break}}}};return u=new a.Tool(P),{name:w,tool:u,registerEvent:function(a,b){x[a]=b},exportJSON:b,importJSON:c,listeners:{onCutPositionChanged:d,onCutMarginChanged:e,onToolActivated:f}}}); define('tools/concordantstr',["paper"],function(a){function b(a){var b=this.exportJSON({asString:!1});return b[1].strokeColor||(b[1].strokeWidth=0),delete b[1].fontFamily,delete b[1].font,delete b[1].fontSize,delete b[1].leading,a&&a.asString?JSON.stringify(b):b}function c(b,c,d){var e=b[1],f=a.project.activeLayer;c.activate();var h=g({from:e.segments[0],to:e.segments[1],strokeWidth:e.strokeWidth,prop:e.data.prop},{not_interactive:!0});return f.activate(),h}function d(a){z=a}function e(a){A=Math.floor(1.5*a)}function f(a){(y=a===w)&&$("#tool-colorselect").hide()}function g(b,c){var d=new a.Path.Line({from:b.from,to:b.to});b.prop="object"==typeof b.prop?b.prop:{};for(var e in O)b.prop.hasOwnProperty(e)||(b.prop[e]=O[e]);return d.style=C[b.prop.confidence],parseInt(b.strokeWidth,10)&&(d.strokeWidth=b.strokeWidth),d.data={tId:"a"+d._id,type:w,prop:b.prop,itemMouseDrag:j,itemMouseUp:k,setColor:h},c&&c.not_interactive||(d.selected=!0,x.annotationSelected.dispatch(d)),d.onMouseDown=i,d.onKeyDown=l,d.onKeyUp=m,d.onPropertyChange=n,d}function h(){this.style.strokeColor=B.strokeColor}function i(b){var c=this;I=this;var d=c.hitTest(b.point,D);c.layer.activate(),a.project.deselectAll(),c.selected=!0,x.annotationSelected.dispatch(c),J=L=M=K=null,"segment"===d.type?(J=d.segment.index,K=z+(I.segments[1-J].point.x<z?1:-1)*A):(L=I.getFirstSegment().point.x<z?0:1,M=1-L),N=!1,x.annotationSelected.dispatch(c)}function j(a){a.tool&&(null!==J?t(a):I&&I.segments[L].point.x+a.delta.x<=z-A&&I.segments[M].point.x+a.delta.x>=z+A&&(I.translate(a.delta),N=!0))}function k(a){a.tool&&(I&&N&&(x.annotationChanged.dispatch([I]),N=!1),J=L=M=I=K=null)}function l(b){var c;switch(b.key){case"up":c=[0,-1];break;case"down":c=[0,1]}c&&(c=new a.Point(c).multiply(a.view.zoom<4.5?1:.5),I=this,this.translate(c),N=!0,a.view.draw())}function m(a){switch(a.key){case"up":case"down":N&&(x.annotationChanged.dispatch([I]),N=!1)}}function n(b,c){"confidence"===b&&(this.style=C[c],a.view.draw())}function o(a,b){return a.x<=z&&b.x>=z+A||a.x>=z&&b.x<=z-A}function p(){G&&G.remove(),F=null,E=!1}function q(){var a=G?G.segments[1].point.clone():null;if(o(F,a)){G&&(G.remove(),G=null);var b=g({from:F,to:a});x.annotationAdded.dispatch(b),F=null,E=!1}}function r(b,c,d){d?v&&(b.segments[c].point.y=v.y,a.view.draw()):(v=b.segments[c].point.clone(),b.segments[c].point.y=b.segments[1-c].point.y)}function s(b){G?(G.segments[1].point=b.point,b.event.shiftKey&&r(G,1)):(G=new a.Path.Line({from:F,to:b.point}),G.style=B,G.dashArray=[10,5]),G.opacity=o(F,b.point)?1:.5,G.dashArray=o(F,b.point)?null:[10,5]}function t(a){var b=a.point.clone();o(I.segments[1-J].point,b)||(b.x=K),I.segments[J].point=b,a.event.shiftKey&&r(I,J),N=!0}var u,v,w="concordantstr",x={annotationAdded:null,annotationSelected:null},y=!1,z=0,A=10,B={strokeWidth:3,strokeColor:"red"},C={1:{strokeColor:new a.Color("#FF3737"),dashArray:[10,10]},2:{strokeColor:new a.Color("#FF3737"),dashArray:[30,10]},3:{strokeColor:new a.Color("#FF0000"),dashArray:null}},D={segments:!0,stroke:!0,fill:!1,tolerance:5,bounds:!1,handles:!0},E=!0,F=null,G=null,H=!1,I=null,J=null,K=null,L=null,M=null,N=!1,O={confidence:3,comment:""},P={onMouseDown:function(b){if(F)G&&!H&&q();else{var c=a.project.activeLayer.hitTest(b.point,D);c?c.item.onMouseDown(b):(a.project.deselectAll(),x.annotationSelected.dispatch(null),F||(J=I=null,E=!0,G&&G.remove(),G=null,F=b.point,H=!1))}},onMouseDrag:function(a){E&&F&&(H=!0,s(a)),I&&I.data.itemMouseDrag(a)},onMouseMove:function(a){E&&F&&s(a)},onMouseUp:function(a){F?G&&H&&(s(a),q()):I&&I.data.itemMouseUp(a),J=I=null},onKeyDown:function(b){switch(b.key){case"enter":E&&q();break;case"escape":E&&p();break;case"shift":G?r(G,1):I&&null!==J&&r(I,J);break;case"up":case"down":for(var c,d=a.project.getSelectedItems(),e=0;c=d[e];e++)if(c.data.type&&"function"==typeof c.onKeyDown){c.onKeyDown(b);break}}},onKeyUp:function(b){switch(b.key){case"shift":G?r(G,1,!0):I&&J&&r(I,J,!0);break;case"up":case"down":for(var c,d=a.project.getSelectedItems(),e=0;c=d[e];e++)if(c.data.type&&"function"==typeof c.onKeyUp){c.onKeyUp(b);break}}}};return u=new a.Tool(P),{name:w,tool:u,registerEvent:function(a,b){x[a]=b},exportJSON:b,importJSON:c,listeners:{onCutPositionChanged:d,onCutMarginChanged:e,onToolActivated:f}}});
/*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */ /*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */
...@@ -15902,7 +15902,7 @@ define('tools/textgeo',["paper","jquery","adim/category"],function(a,b,c){functi ...@@ -15902,7 +15902,7 @@ define('tools/textgeo',["paper","jquery","adim/category"],function(a,b,c){functi
/*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */ /*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */
define('adim/tools',["underscore","signals","tools/select","tools/pan","tools/drawing","tools/lines","tools/ellipse","tools/rectangle","tools/text","tools/arrow","tools/fieldedges","tools/concordantstr","tools/discordantstr","tools/cmsarea","tools/marker","tools/drawinggeo","tools/linesgeo","tools/ellipsegeo","tools/rectanglegeo","tools/arrowgeo","tools/textgeo"],function(a,b){function c(a,b){return b.importJSON(a)}function d(a){return this.exportJSON(a)}function e(){return n}function f(a){return m[a]?m[a].tool:null}function g(a){if(a&&m[a]){var b=f(n);b&&q.annotationCheckCancel.dispatch(b);var c=f(a);c?(n=a,c.activate(),q.activated.dispatch(a)):console&&console.warn&&console.warn("Tool «"+a+"» not activated")}}function h(a){return m[a]&&"function"==typeof m[a].importJSON?m[a].importJSON:p}function i(a){return m[a]&&"function"==typeof m[a].exportJSON?m[a].exportJSON:p}function j(a,b){return i(a.data.type).call(a,$.extend({asString:!0},b))}function k(b){b!==o&&(o=b,a.invoke(m,"setRo",b))}for(var l,m={},n=null,o=null,p=function(){},q={activated:new b,annotationAdded:new b,annotationChanged:new b,annotationSelected:new b,annotationCheckCancel:new b},r=1;l=arguments[r];r++)m[l.name]={tool:l.tool,importJSON:l.importJSON||c,exportJSON:l.exportJSON||d,setRo:l.setRo||p,listeners:l.listeners||{},events:l.events||{}},"function"==typeof l.registerEvent&&(l.registerEvent("annotationAdded",q.annotationAdded),l.registerEvent("annotationChanged",q.annotationChanged),l.registerEvent("annotationSelected",q.annotationSelected)),l.listeners&&"function"==typeof l.listeners.onToolActivated&&q.activated.add(l.listeners.onToolActivated);return function(){new paper.Tool({onMouseDown:p,onMouseUp:p,onMouseDrag:p,onKeyDown:p,onKeyUp:p}).activate()}(),{events:q,tools:m,getTool:f,getToolJSONImporter:h,getToolJSONExporter:i,activateTool:g,getActiveTool:e,serializeItem:j,setRo:k}}); define('adim/tools',["underscore","signals","tools/select","tools/pan","tools/drawing","tools/lines","tools/ellipse","tools/rectangle","tools/text","tools/arrow","tools/fieldedges","tools/concordantstr","tools/discordantstr","tools/cmsarea","tools/marker","tools/drawinggeo","tools/linesgeo","tools/ellipsegeo","tools/rectanglegeo","tools/arrowgeo","tools/textgeo"],function(a,b){function c(a,b){return b.importJSON(a)}function d(a){return this.exportJSON(a)}function e(){return n}function f(a){return m[a]?m[a].tool:null}function g(a){if(a&&m[a]){var b=f(n);b&&q.annotationCheckCancel.dispatch(b);var c=f(a);c?(n=a,c.activate(),q.activated.dispatch(a)):console&&console.warn&&console.warn("Tool «"+a+"» not activated")}}function h(a){return m[a]&&"function"==typeof m[a].importJSON?m[a].importJSON:p}function i(a){return m[a]&&"function"==typeof m[a].exportJSON?m[a].exportJSON:p}function j(a,b){return i(a.data.type).call(a,$.extend({asString:!0},b))}function k(b){b!==o&&(o=b,a.invoke(m,"setRo",b))}for(var l,m={},n=null,o=null,p=function(){},q={activated:new b,annotationAdded:new b,annotationChanged:new b,annotationSelected:new b,annotationCheckCancel:new b},r=1;l=arguments[r];r++)m[l.name]={tool:l.tool,importJSON:l.importJSON||c,exportJSON:l.exportJSON||d,setRo:l.setRo||p,listeners:l.listeners||{},events:l.events||{}},"function"==typeof l.registerEvent&&(l.registerEvent("annotationAdded",q.annotationAdded),l.registerEvent("annotationChanged",q.annotationChanged),l.registerEvent("annotationSelected",q.annotationSelected)),l.listeners&&"function"==typeof l.listeners.onToolActivated&&q.activated.add(l.listeners.onToolActivated);return function(){new paper.Tool({onMouseDown:p,onMouseUp:p,onMouseDrag:p,onKeyDown:p,onKeyUp:p}).activate()}(),{events:q,tools:m,getTool:f,getToolJSONImporter:h,getToolJSONExporter:i,activateTool:g,getActiveTool:e,serializeItem:j,setRo:k}});
/*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */ /*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */
define('adim/view',["jquery","underscore","paper","signals","adim/config","adim/users","adim/tools"],function(a,b,c,d,e,f,g){function h(a){if(!a)return!1;if(!isNaN(parseInt(a,10)))return i(a);var b=F[a]||null;if(!b)for(var d,e=2===a.indexOf(":")?a.substr(3):null,f=c.project.layers,g=0;d=f[g];g++){var h=e?d.id.toString()===e:d.name===a;if(h){b=d,F[a]=d;break}}return b}function i(a){return a=parseInt(a,10),b(c.project.layers).findWhere({id:a})}function j(b,d){var e=h(b);if(d=d||{},!e){var f=c.project.activeLayer;e=new c.Layer({name:b}),a.extend(e.data,d),F[b]=e,f&&f.activate()}return e}function k(a,b){return j("user_"+a,{owner:b||f.getById(a)||a,ownerId:a})}function l(a,b){var d=h(a);return d?(b=void 0===b?!d.visible:"function"==typeof b?!!b():!!b,d.visible=b,c.view.draw(),C.userLayerVisibilityChanged.dispatch(d,d.visible),d.visible):null}function m(){var a=[];return c.project.getSelectedItems().map(function(b){b.parent&&b.parent.data&&b.parent.data.type&&-1===a.indexOf(b.parent)?a.push(b.parent):b.data&&b.data.type&&-1===a.indexOf(b)&&a.push(b)}),a}function n(c,d){var f,h,i;try{f="string"==typeof c.item?JSON.parse(c.item):c.item}catch(a){throw"Unable to parse annotation's item"}if(!a.isArray(f)||f.length<2)return null;if("string"==typeof f[0]?h=f[1].data:a.isArray(f[0])&&(h=f[1][1].data),!h)return null;if(i=h.type,!b.isEmpty(e.activeTools)&&!b.contains(e.activeTools,i))return null;var j=k(c.owner),l=g.getToolJSONImporter(i)(f,j,d);return l&&(l.data.id=c.id,l.selected=!1),l}function o(a){for(var b,c=[],d=0;b=a[d];d++)if(b.data&&b.data.type){var e={id:b.data.id,itemStr:g.serializeItem(b),index:b.index};b.data.prop&&(e.prop=b.data.prop),c.push(e)}return c}function p(a){for(var b=c.project.layers,d=null,e=0,f=b.length;e<f;e++)for(var g=b[e].children,h=0,i=g.length;h<i;h++)if(g[h].data.tId===a){d=g[h];break}return d}function q(){for(var a,b=m(),d=0;a=b[d];d++)a.remove(),C.annotationRemoved.dispatch(a);c.view.draw()}function r(a){c.project.view.scrollBy(a),c.project.view.draw()}function s(a,b){if(b=void 0===b||!!b,"string"==typeof a){for(var d,e=a.split(","),f=0,h=c.project.layers;d=h[f];f++)for(var i,j=0,k=d.children;i=k[j];j++)i.data&&i.data.type&&e.indexOf(i.data.type)>-1&&(i.selected&&(i.selected=!1,g.events.annotationSelected.dispatch(null)),i.visible=b);c.view.draw()}}function t(a,d){d=!!b.isUndefined(d)||!!d;for(var e,f=a.val.split(","),h=0,i=c.project.layers;e=i[h];h++)for(var j,k=0,l=e.children;j=l[k];k++)if(j.data&&j.data.prop){var m=b.isUndefined(j.data.prop[a.prop])?f.indexOf("")>-1&&!0===a.undef:f.indexOf(j.data.prop[a.prop])>-1;m&&(j.selected&&(j.selected=!1,g.events.annotationSelected.dispatch(null)),j.visible=d)}c.view.draw()}function u(a,d){d=!!b.isUndefined(d)||d;for(var e,f=a.split(","),h=[],i=0,j=c.project.layers;e=j[i];i++)for(var k,l=0,m=e.children;k=m[l];l++)k.data&&k.data.type&&f.indexOf(k.data.type)>-1&&k.visible&&(k.selected=d,h.push(k));g.events.annotationSelected.dispatch(h),c.view.draw()}function v(a,b,c){var d=!1;return a.data&&a.data.prop&&(d=a.data.prop[b]!==c)&&(a.data.prop[b]=c,"function"==typeof a.onPropertyChange&&a.onPropertyChange(b,c),C.annotationPropertyChanged.dispatch(a,b,c)),d}function w(a,b,c){var d=m();c||(d=d.length?d[0]:[]);for(var e,f=!0,g=0;e=d[g];g++)f=v(e,a,b)&&f;return f}function x(a,b){return a.data&&a.data.prop&&a.data.prop.hasOwnProperty(b)?a.data.prop[b]:null}function y(a){var b=c.project.getSelectedItems();return 1===b.length?x(b[0],a):null}var z=null,A=null,B=null,C={imageLoaded:new d,annotationsLoaded:new d,annotationRemoved:new d,annotationPropertyChanged:new d,userLayerVisibilityChanged:new d},D=e.users,E={strokeWidth:7,strokeColor:"red",font:"Helvetica,Arial,sans-serif",fontSize:32},F={};return{init:function(b){return"string"==typeof b&&"#"!==b.substr(0,1)&&(b="#"+b),z=a(b),0===z.length?(console&&console.warn&&console.warn("Unable to find canvas element: "+b),!1):(c.setup(z.get(0)),c.project.activeLayer.name="image",a.extend(c.project.currentStyle,E),B=k(e.user.id,e.user.username),B.opacity=1,!0)},events:C,loadUserDict:function(a){D=e.users},updateUserDict:function(b){a.extend(D,b)},resize:function(a,b){z&&(a=parseInt(a,10)||z.width(),b=parseInt(b,10)||z.height(),z.width("100%").height(b),c.view.viewSize=[a,b],A&&(A.position=[A.bounds.width/2,A.bounds.height/2]))},scrollBy:r,loadImage:function(b,d,e){b="string"==typeof b?{url:b}:a.extend({url:""},b);var f=c.project.activeLayer,g=j("image");g.activate(),A=new c.Raster({source:b.url,position:[0,0]}),A.onLoad=function(){var a=c.project.activeLayer;g.activate();var f;b.bgUrl?(f=new c.Raster(b.bgUrl),f.translate(A.width/2,A.height/2)):f=new c.Path.Rectangle({from:[0,0],to:[A.width,A.height],fillColor:"white",strokeColor:null}),f.sendToBack(),a.activate(),C.imageLoaded.dispatch({raster:A}),"function"==typeof d&&d.call(e,A)},f.activate()},loadAnnotation:n,loadAnnotations:function(b,d){for(var f,i=[],j=b.length-1;f=b[j];j--){var k=f.owner===d;(e.ui.show_users_results||k)&&i.push(n(f,k))}if(d){var l=h("user_"+d);if(l){var m=c.project.layers,o=m.splice(l._index,1);m.push(o[0]),a.each(m,function(a,b){b._index=a}),l=h("user_"+d),l.activate(),c.view.draw()}}console.log(">> before dispatch annotationsLoaded"),C.annotationsLoaded.dispatch(i,d),c.project.deselectAll(),g.events.annotationSelected.dispatch(null),c.view.draw()},removeSelectedItems:q,getUserAnnnotationsSerialized:function(a){return o(h("user_"+a).children)},getSelectedAnnotations:m,getSelectedAnnnotationsSerialized:function(){for(var a,b=c.project.getSelectedItems(),d=[],e=0;a=b[e];e++)a.data.type&&d.push(a);return o(d)},getAnnotationsSerialized:function(b){return a.isArray(b)||(b=[b]),o(b)},getItemByTempId:p,setItemProperty:v,setSelectedItemProperty:w,getSelectedItemProperty:y,showItemsByType:function(a){s(a,!0)},hideItemsByType:function(a){s(a,!1)},toggleItemsByType:s,toggleItemsByProp:t,selectItemsByType:u,getLayerByName:h,getOrCreateLayerByName:j,getOrCreateUserLayer:k,getUserLayer:function(a){return h("user_"+a)},getAllUsersLayers:function(){for(var a=[],b=0,d=c.project.layers;b<d.length;b++)"user_"===d[b].name.substr(0,5)&&a.push(d[b]);return a},showLayer:function(a){l(a,!0)},hideLayer:function(a){l(a,!1)},toggleLayer:function(a,b){return l(a,b)},toggleMembersLayers:function(){function a(a,b){return b?e[a.id]:b}var d,e={};return function(f,h){c.project.deselectAll(),g.events.annotationSelected.dispatch(null);var i=this.getAllUsersLayers();f||(d=c.project.activeLayer,b.reduce(i,function(a,b){return a[b.id]=b.visible,a},e)),b.each(i,function(b){l(b.name,h?f:a(b,f))}),f?d&&d.activate():(l(B.id,!0),B.activate())}}(),_raster:function(){return A}}}); define('adim/view',["jquery","underscore","paper","signals","adim/config","adim/users","adim/tools"],function(a,b,c,d,e,f,g){function h(a){if(!a)return!1;if(!isNaN(parseInt(a,10)))return i(a);var b=F[a]||null;if(!b)for(var d,e=2===a.indexOf(":")?a.substr(3):null,f=c.project.layers,g=0;d=f[g];g++){var h=e?d.id.toString()===e:d.name===a;if(h){b=d,F[a]=d;break}}return b}function i(a){return a=parseInt(a,10),b(c.project.layers).findWhere({id:a})}function j(b,d){var e=h(b);if(d=d||{},!e){var f=c.project.activeLayer;e=new c.Layer({name:b}),a.extend(e.data,d),F[b]=e,f&&f.activate()}return e}function k(a,b){return j("user_"+a,{owner:b||f.getById(a)||a,ownerId:a})}function l(a,b){var d=h(a);return d?(b=void 0===b?!d.visible:"function"==typeof b?!!b():!!b,d.visible=b,c.view.draw(),C.userLayerVisibilityChanged.dispatch(d,d.visible),d.visible):null}function m(){var a=[];return c.project.getSelectedItems().map(function(b){b.parent&&b.parent.data&&b.parent.data.type&&-1===a.indexOf(b.parent)?a.push(b.parent):b.data&&b.data.type&&-1===a.indexOf(b)&&a.push(b)}),a}function n(c,d){var f,h,i;try{f="string"==typeof c.item?JSON.parse(c.item):c.item}catch(a){throw"Unable to parse annotation's item"}if(!a.isArray(f)||f.length<2)return null;if("string"==typeof f[0]?h=f[1].data:a.isArray(f[0])&&(h=f[1][1].data),!h)return null;if(i=h.type,!b.isEmpty(e.activeTools)&&!b.contains(e.activeTools,i))return null;var j=k(c.owner),l=g.getToolJSONImporter(i)(f,j,d);return l&&(l.data.id=c.id,l.selected=!1),l}function o(a){for(var b,c=[],d=0;b=a[d];d++)if(b.data&&b.data.type){var e={id:b.data.id,itemStr:g.serializeItem(b),index:b.index};b.data.prop&&(e.prop=b.data.prop),e.itemStr&&c.push(e)}return c}function p(a){for(var b=c.project.layers,d=null,e=0,f=b.length;e<f;e++)for(var g=b[e].children,h=0,i=g.length;h<i;h++)if(g[h].data.tId===a){d=g[h];break}return d}function q(){for(var a,b=m(),d=0;a=b[d];d++)a.remove(),C.annotationRemoved.dispatch(a);c.view.draw()}function r(a){c.project.view.scrollBy(a),c.project.view.draw()}function s(a,b){if(b=void 0===b||!!b,"string"==typeof a){for(var d,e=a.split(","),f=0,h=c.project.layers;d=h[f];f++)for(var i,j=0,k=d.children;i=k[j];j++)i.data&&i.data.type&&e.indexOf(i.data.type)>-1&&(i.selected&&(i.selected=!1,g.events.annotationSelected.dispatch(null)),i.visible=b);c.view.draw()}}function t(a,d){d=!!b.isUndefined(d)||!!d;for(var e,f=a.val.split(","),h=0,i=c.project.layers;e=i[h];h++)for(var j,k=0,l=e.children;j=l[k];k++)if(j.data&&j.data.prop){var m=b.isUndefined(j.data.prop[a.prop])?f.indexOf("")>-1&&!0===a.undef:f.indexOf(j.data.prop[a.prop])>-1;m&&(j.selected&&(j.selected=!1,g.events.annotationSelected.dispatch(null)),j.visible=d)}c.view.draw()}function u(a,d){d=!!b.isUndefined(d)||d;for(var e,f=a.split(","),h=[],i=0,j=c.project.layers;e=j[i];i++)for(var k,l=0,m=e.children;k=m[l];l++)k.data&&k.data.type&&f.indexOf(k.data.type)>-1&&k.visible&&(k.selected=d,h.push(k));g.events.annotationSelected.dispatch(h),c.view.draw()}function v(a,b,c){var d=!1;return a.data&&a.data.prop&&(d=a.data.prop[b]!==c)&&(a.data.prop[b]=c,"function"==typeof a.onPropertyChange&&a.onPropertyChange(b,c),C.annotationPropertyChanged.dispatch(a,b,c)),d}function w(a,b,c){var d=m();c||(d=d.length?d[0]:[]);for(var e,f=!0,g=0;e=d[g];g++)f=v(e,a,b)&&f;return f}function x(a,b){return a.data&&a.data.prop&&a.data.prop.hasOwnProperty(b)?a.data.prop[b]:null}function y(a){var b=c.project.getSelectedItems();return 1===b.length?x(b[0],a):null}var z=null,A=null,B=null,C={imageLoaded:new d,annotationsLoaded:new d,annotationRemoved:new d,annotationPropertyChanged:new d,userLayerVisibilityChanged:new d},D=e.users,E={strokeWidth:7,strokeColor:"red",font:"Helvetica,Arial,sans-serif",fontSize:32},F={};return{init:function(b){return"string"==typeof b&&"#"!==b.substr(0,1)&&(b="#"+b),z=a(b),0===z.length?(console&&console.warn&&console.warn("Unable to find canvas element: "+b),!1):(c.setup(z.get(0)),c.project.activeLayer.name="image",a.extend(c.project.currentStyle,E),B=k(e.user.id,e.user.username),B.opacity=1,!0)},events:C,loadUserDict:function(a){D=e.users},updateUserDict:function(b){a.extend(D,b)},resize:function(a,b){z&&(a=parseInt(a,10)||z.width(),b=parseInt(b,10)||z.height(),z.width("100%").height(b),c.view.viewSize=[a,b],A&&(A.position=[A.bounds.width/2,A.bounds.height/2]))},scrollBy:r,loadImage:function(b,d,e){b="string"==typeof b?{url:b}:a.extend({url:""},b);var f=c.project.activeLayer,g=j("image");g.activate(),A=new c.Raster({source:b.url,position:[0,0]}),A.onLoad=function(){var a=c.project.activeLayer;g.activate();var f;b.bgUrl?(f=new c.Raster(b.bgUrl),f.translate(A.width/2,A.height/2)):f=new c.Path.Rectangle({from:[0,0],to:[A.width,A.height],fillColor:"white",strokeColor:null}),f.sendToBack(),a.activate(),C.imageLoaded.dispatch({raster:A}),"function"==typeof d&&d.call(e,A)},f.activate()},loadAnnotation:n,loadAnnotations:function(b,d){for(var f,i=[],j=b.length-1;f=b[j];j--){var k=f.owner===d;(e.ui.show_users_results||k)&&i.push(n(f,k))}if(d){var l=h("user_"+d);if(l){var m=c.project.layers,o=m.splice(l._index,1);m.push(o[0]),a.each(m,function(a,b){b._index=a}),l=h("user_"+d),l.activate(),c.view.draw()}}console.log(">> before dispatch annotationsLoaded"),C.annotationsLoaded.dispatch(i,d),c.project.deselectAll(),g.events.annotationSelected.dispatch(null),c.view.draw()},removeSelectedItems:q,getUserAnnnotationsSerialized:function(a){return o(h("user_"+a).children)},getSelectedAnnotations:m,getSelectedAnnnotationsSerialized:function(){for(var a,b=c.project.getSelectedItems(),d=[],e=0;a=b[e];e++)a.data.type&&d.push(a);return o(d)},getAnnotationsSerialized:function(b){return a.isArray(b)||(b=[b]),o(b)},getItemByTempId:p,setItemProperty:v,setSelectedItemProperty:w,getSelectedItemProperty:y,showItemsByType:function(a){s(a,!0)},hideItemsByType:function(a){s(a,!1)},toggleItemsByType:s,toggleItemsByProp:t,selectItemsByType:u,getLayerByName:h,getOrCreateLayerByName:j,getOrCreateUserLayer:k,getUserLayer:function(a){return h("user_"+a)},getAllUsersLayers:function(){for(var a=[],b=0,d=c.project.layers;b<d.length;b++)"user_"===d[b].name.substr(0,5)&&a.push(d[b]);return a},showLayer:function(a){l(a,!0)},hideLayer:function(a){l(a,!1)},toggleLayer:function(a,b){return l(a,b)},toggleMembersLayers:function(){function a(a,b){return b?e[a.id]:b}var d,e={};return function(f,h){c.project.deselectAll(),g.events.annotationSelected.dispatch(null);var i=this.getAllUsersLayers();f||(d=c.project.activeLayer,b.reduce(i,function(a,b){return a[b.id]=b.visible,a},e)),b.each(i,function(b){l(b.name,h?f:a(b,f))}),f?d&&d.activate():(l(B.id,!0),B.activate())}}(),_raster:function(){return A}}});
/*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */ /*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */
define('adim/io',["jquery","underscore","paper","signals","adim/config","adim/view"],function(a,b,c,d,e,f){function g(){}function h(b,c,d,f){b=parseInt(b,10);var g=!b;f=parseInt(f,10)||0;var h={item:c,order:f};if(d)for(var i in d)h[i]=d[i];var j,k=e.api.annotations;return g?(j="POST",a.extend(h,{annotable:e.annotable.id,owner:e.user.id,owner_id:e.user.id})):(j="PATCH",k+=b+"/"),a.ajax({url:k,type:j,dataType:"json",data:h}).done(function(a,b,c){201===c.status?m.annotationAdded.dispatch(a):200===c.status&&m.annotationSaved.dispatch(a)}).fail(function(a){m.loadingError.dispatch({msg:"Erreur lors de l'enregistrement d'une annotation",jqXHR:a})})}function i(b,c){var d=new FormData;return d.append("aid",b),d.append("file",c),a.ajax({type:"POST",url:e.annotable.thumbnail,data:d,processData:!1,contentType:!1}).done(function(a){})}function j(a){function c(a,c){e.push(a),e.length===f&&m.annotationsSavedStatusChanged.dispatch({status:b.every(e)?"saved":"error"})}for(var d,e=[],f=a.length,g=0;d=a[g];g++)h(d.id,d.itemStr,d.prop,d.index).done(function(a){return function(){c(!0,a)}}(d.id)).fail(function(a){return function(){c(!1,a)}}(d.id))}function k(b){a.ajax({url:e.api.annotations+parseInt(b,10)+"/",type:"DELETE",success:function(a,c,d){204===d.status&&m.annotationRemoved.dispatch(b)},error:function(a){404!==a.status&&m.loadingError.dispatch({msg:"Erreur lors de la suppression d'une annotation"})}})}function l(b,c){return a.ajax({url:e.api.annotables+parseInt(b,10)+"/",type:"PATCH",dataType:"json",data:{name:c},success:function(a){m.annotableChanged.dispatch(a)}})}var m={annotableLoaded:new d,annotableChanged:new d,annotationsLoaded:new d,loadingError:new d,annotationAdded:new d,annotationSaved:new d,annotationRemoved:new d,annotationsSavedStatusChanged:new d},n=!1;return{init:g,events:m,setAutoSave:function(a){return n=!!a},getAutoSave:function(){return n},loadData:function(b){console.time("loadData"),a.ajax({url:b,dataType:"json",success:function(a){console.timeEnd("loadData"),m.annotableLoaded.dispatch(a)},error:function(){m.loadingError.dispatch({msg:"Une erreur est survenue lors du chargement des données."})}})},loadSharedAnnotations:function(b){console.log("loadSharedAnnotations");var c=a.Deferred();return a.ajax({url:b,dataType:"json",success:function(a){c.resolve(a)},error:function(){var a={msg:"Une erreur est survenue lors du chargement des données."};m.loadingError.dispatch(a),c.reject(a)}}),c},saveUserAnnotations:function(a){return a=a||e.user.id,j(f.getUserAnnnotationsSerialized(a)),!0},saveAnnotations:function(a,b){return!(!n&&!b)&&(m.annotationsSavedStatusChanged.dispatch({status:"dirty"}),j(f.getAnnotationsSerialized(a)),!0)},removeAnnotation:k,saveThumbnail:i,setAnnotableName:l}}); define('adim/io',["jquery","underscore","paper","signals","adim/config","adim/view"],function(a,b,c,d,e,f){function g(){}function h(b,c,d,f){b=parseInt(b,10);var g=!b;f=parseInt(f,10)||0;var h={item:c,order:f};if(d)for(var i in d)h[i]=d[i];var j,k=e.api.annotations;return g?(j="POST",a.extend(h,{annotable:e.annotable.id,owner:e.user.id,owner_id:e.user.id})):(j="PATCH",k+=b+"/"),a.ajax({url:k,type:j,dataType:"json",data:h}).done(function(a,b,c){201===c.status?m.annotationAdded.dispatch(a):200===c.status&&m.annotationSaved.dispatch(a)}).fail(function(a){m.loadingError.dispatch({msg:"Erreur lors de l'enregistrement d'une annotation",jqXHR:a})})}function i(b,c){var d=new FormData;return d.append("aid",b),d.append("file",c),a.ajax({type:"POST",url:e.annotable.thumbnail,data:d,processData:!1,contentType:!1}).done(function(a){})}function j(a){function c(a,c){e.push(a),e.length===f&&m.annotationsSavedStatusChanged.dispatch({status:b.every(e)?"saved":"error"})}for(var d,e=[],f=a.length,g=0;d=a[g];g++)h(d.id,d.itemStr,d.prop,d.index).done(function(a){return function(){c(!0,a)}}(d.id)).fail(function(a){return function(){c(!1,a)}}(d.id))}function k(b){a.ajax({url:e.api.annotations+parseInt(b,10)+"/",type:"DELETE",success:function(a,c,d){204===d.status&&m.annotationRemoved.dispatch(b)},error:function(a){404!==a.status&&m.loadingError.dispatch({msg:"Erreur lors de la suppression d'une annotation"})}})}function l(b,c){return a.ajax({url:e.api.annotables+parseInt(b,10)+"/",type:"PATCH",dataType:"json",data:{name:c},success:function(a){m.annotableChanged.dispatch(a)}})}var m={annotableLoaded:new d,annotableChanged:new d,annotationsLoaded:new d,loadingError:new d,annotationAdded:new d,annotationSaved:new d,annotationRemoved:new d,annotationsSavedStatusChanged:new d},n=!1;return{init:g,events:m,setAutoSave:function(a){return n=!!a},getAutoSave:function(){return n},loadData:function(b){console.time("loadData"),a.ajax({url:b,dataType:"json",success:function(a){console.timeEnd("loadData"),m.annotableLoaded.dispatch(a)},error:function(){m.loadingError.dispatch({msg:"Une erreur est survenue lors du chargement des données."})}})},loadSharedAnnotations:function(b){console.log("loadSharedAnnotations");var c=a.Deferred();return a.ajax({url:b,dataType:"json",success:function(a){c.resolve(a)},error:function(){var a={msg:"Une erreur est survenue lors du chargement des données."};m.loadingError.dispatch(a),c.reject(a)}}),c},saveUserAnnotations:function(a){return a=a||e.user.id,j(f.getUserAnnnotationsSerialized(a)),!0},saveAnnotations:function(a,b){return!(!n&&!b)&&(m.annotationsSavedStatusChanged.dispatch({status:"dirty"}),j(f.getAnnotationsSerialized(a)),!0)},removeAnnotation:k,saveThumbnail:i,setAnnotableName:l}});
/*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */ /*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */
...@@ -15876,7 +15876,7 @@ define('tools/text',["paper","jquery"],function(a,b){function c(a,b){a in w?(x=w ...@@ -15876,7 +15876,7 @@ define('tools/text',["paper","jquery"],function(a,b){function c(a,b){a in w?(x=w
/*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */ /*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */
define('tools/arrow',["paper"],function(a){function b(a){var b=this.exportJSON({asString:!1});try{b[1][1].data.from=[this.data.from.x,this.data.from.y],b[1][1].data.to=[this.data.to.x,this.data.to.y]}catch(a){console.error(a)}return a&&a.asString?JSON.stringify(b):b}function c(b,c,d){var e=b[1][1],f=b[0][1][e.symbol][1][1],h=f.fillColor&&(f.fillColor.length<3||0!==f.fillColor[3]),i=parseFloat(e.opacity)||1,k=a.project.activeLayer;c.activate(),e.data.from.length>2&&(e.data.from=e.data.from.splice(1)),e.data.to.length>2&&(e.data.to=e.data.to.splice(1));var m=g({from:new a.Point(e.data.from),prop:e.data.prop,scale:e.data.scale||{h:1,v:1}},d);return m.opacity=i,j.call(m,f.strokeColor),l.call(m,h),n.call(m,f.strokeWidth),u(m,{from:m.data.from,to:new a.Point(e.data.to)}),k.activate(),m}function d(){if(!y){var b=new a.Path({segments:[[0,-5],[0,5],new a.Segment([20,5]),[10,30],new a.Segment([50,0]),[10,-30],new a.Segment([20,-5])],strokeJoin:"round",strokeScaling:!1,closed:!0});z=1,A=3,B=4,C=b.segments[A].point.x-b.segments[z].point.x,y=new a.Symbol(b),b.remove()}}function e(a,b){b=b||this;var c=b.symbol.definition.segments[2].point.x,d=b.symbol.definition.segments[B].point.x;return(b.globalToLocal(a).x-c)/(d-c)>.1}function f(a,b){return b=b||this,(a=a||b.symbol.definition.segments[B].point.x-b.symbol.definition.segments[z].point.x)-(b.symbol.definition.segments[B].point.x-b.symbol.definition.segments[A].point.x)<C}function g(b,c){var e,f,g,h,v;d(),e=new a.PlacedSymbol(y.clone()),f=e.symbol.definition.bounds.width,g=new a.Point(b.from),h=new a.Point([g.x+f,g.y]),v=b.scale||{h:1,v:1},e.pivot=[-f/2,0],u(e,{from:g,to:h}),i.call(e,v),l.call(e,a.project.currentStyle.fillColor),j.call(e,a.project.currentStyle.strokeColor),n.call(e,a.project.currentStyle.strokeWidth),b.prop="object"==typeof b.prop?b.prop:{};for(var w in G)b.prop.hasOwnProperty(w)||(b.prop[w]=G[w]);return e.data={tId:"a"+e._id,type:D,prop:b.prop,from:g,to:h,scale:v,setColor:j,getColor:k,setFill:l,getFill:m,setStrokeWidth:n,getStrokeWidth:o,setDragMode:p,itemMouseDrag:r},!1!==c&&(e.onMouseDown=q,e.onMouseUp=s,e.onPropertyChange=t),e}function h(){this.data.from=this.position,this.data.to=this.data.from.add(new a.Point({length:this.symbol.definition.bounds.width,angle:this.rotation}))}function i(a){var b=y.definition.bounds.width;this.symbol.definition.scale(a.h,a.v,[-b/2,0]),this.data.scale||(this.data.scale={h:1,v:1}),this.data.scale.h*=a.h,this.data.scale.v*=a.v,h.call(this)}function j(a){this.symbol.definition.strokeColor=a,this.symbol.definition.fillColor.alpha>0&&(this.symbol.definition.fillColor=a)}function k(){return this.symbol.definition.strokeColor}function l(a){this.symbol.definition.fillColor=a?this.symbol.definition.strokeColor:H}function m(){return this.symbol.definition.fillColor.alpha>0}function n(a){this.symbol.definition.strokeWidth=a}function o(){return this.symbol.definition.strokeWidth}function p(a,b){a in I?(J=I[a],K=b):(J=null,K={},L=!1)}function q(a){if(this.selected&&!E){J=I.FULL_DRAG;var b=this.data.to,c=this.data.from;e.call(this,a.point)?p("DRAG_TO",{delta:b.subtract(a.point)}):c.getDistance(a.point)<30&&p("DRAG_FROM",{delta:c.subtract(a.point)}),this.attach("mousedrag",r)}}function r(a){if(!E){L=!0;var b={from:this.data.from,to:this.data.to};switch(J){case I.FULL_DRAG:this.translate(a.delta),h.call(this);break;case I.DRAG_TO:b.to=K.delta?a.point.add(K.delta):a.point,delete b.from,u(this,b);break;case I.DRAG_FROM:b.from=K.delta?a.point.add(K.delta):a.point,delete b.to,u(this,b);break;case I.DRAG_HANDLE:if("right"!==K.nameParts[1])L=!1;else{var c=a.point.subtract(b.from).project(b.to.subtract(b.from)),d=c.length/this.symbol.definition.bounds.width,e=a.event.shiftKey?d:a.point.subtract(c.add(b.from)).length/this.symbol.definition.bounds.height*2;i.call(this,{h:d,v:e})}break;default:L=!1}}}function s(a){this.detach("mousedrag",r),h.call(this),J=null,L&&F.annotationChanged.dispatch(this),L=!1}function t(a,b){}function u(b,c){var d,e,g,h,i="";if(c.from||(c.from=b.data.from,i="to"),c.to||(c.to=b.data.to,i="from"),d=c.to.subtract(c.from),e=d.angle,g=b.symbol.definition.bounds.width,h=d.length-g,f.call(b,g+h)&&(h=0,"from"===i&&(c.from=c.to.subtract(new a.Point({length:g,angle:e})))),b.rotation=e,b.position=c.from,0!==h)for(var j,k=2;j=b.symbol.definition.segments[k];k++)j.point.x+=h;b.data.from=c.from,b.data.to=c.to}function v(a){return a.data&&a.data.type===D?a:a.parent?v(a.parent):null}function w(b){var c,d;if(c=a.project.activeLayer.hitTest(b,{tolerance:7,fill:!0,stroke:!0,segments:!0,handles:!0,ends:!0,bounds:!0,selected:!0}),c||(c=a.project.activeLayer.hitTest(b,{fill:!0,stroke:!0})),!c||!c.item)return!1;if(!(d=v(c.item)))return!1;if(d.selected=!0,"bounds"===c.type){"right"===c.name.split("-")[1]&&p("DRAG_HANDLE",{nameStr:c.name,nameParts:c.name.split("-"),item:d})}return!0}function x(a){return a!==E&&(E=a),E}var y,z,A,B,C,D="arrow",E=!1,F={annotationAdded:null,annotationSelected:null,annotationChanged:null},G={comment:"",fill:!0},H=new a.Color([0,0,0,0]),I={FULL_DRAG:1,DRAG_TO:2,DRAG_FROM:3,DRAG_HANDLE:4},J=null,K={},L=!1,M=!1,N=null,O=null,P={onMouseDown:function(b){E||(M=!1,O=null,w(b.point)||(a.project.deselectAll(),F.annotationSelected.dispatch(null),M=!0,N=b.point,O=g({from:N},!0),O.visible=!1))},onMouseDrag:function(a){E||(M&&O?(u(O,{from:N,to:a.point}),O.visible=!0):J===I.DRAG_HANDLE&&K.item&&r.call(K.item,a))},onMouseUp:function(a){p(null),M&&O&&(F.annotationAdded.dispatch(O),M=!1,O.selected=!0,O.visible=!0,O=null)}};return{name:D,tool:new a.Tool(P),setRo:x,registerEvent:function(a,b){F[a]=b},exportJSON:b,importJSON:c,listeners:{}}}); define('tools/arrow',["paper"],function(a){function b(a){var b=this.exportJSON({asString:!1});try{b[1][1].data.from=[this.data.from.x,this.data.from.y],b[1][1].data.to=[this.data.to.x,this.data.to.y]}catch(a){console.error(a)}return a&&a.asString?JSON.stringify(b):b}function c(b,c,d){var e=b[1][1],f=b[0][1][e.symbol][1][1],h=f.fillColor&&(f.fillColor.length<3||0!==f.fillColor[3]),i=parseFloat(e.opacity)||1,k=a.project.activeLayer;c.activate(),e.data.from.length>2&&(e.data.from=e.data.from.splice(1)),e.data.to.length>2&&(e.data.to=e.data.to.splice(1));var m=g({from:new a.Point(e.data.from),prop:e.data.prop,scale:e.data.scale||{h:1,v:1}},d);return m.opacity=i,j.call(m,f.strokeColor),l.call(m,h),n.call(m,f.strokeWidth),u(m,{from:m.data.from,to:new a.Point(e.data.to)}),k.activate(),m}function d(){if(!y){var b=new a.Path({segments:[[0,-5],[0,5],new a.Segment([20,5]),[10,30],new a.Segment([50,0]),[10,-30],new a.Segment([20,-5])],strokeJoin:"round",strokeScaling:!1,closed:!0});z=1,A=3,B=4,C=b.segments[A].point.x-b.segments[z].point.x,y=new a.Symbol(b),b.remove()}}function e(a,b){b=b||this;var c=b.symbol.definition.segments[2].point.x,d=b.symbol.definition.segments[B].point.x;return(b.globalToLocal(a).x-c)/(d-c)>.1}function f(a,b){return b=b||this,(a=a||b.symbol.definition.segments[B].point.x-b.symbol.definition.segments[z].point.x)-(b.symbol.definition.segments[B].point.x-b.symbol.definition.segments[A].point.x)<C}function g(b,c){var e,f,g,h,v;d(),e=new a.PlacedSymbol(y.clone()),f=e.symbol.definition.bounds.width,g=new a.Point(b.from),h=new a.Point([g.x+f,g.y]),v=b.scale||{h:1,v:1},e.pivot=[-f/2,0],u(e,{from:g,to:h}),i.call(e,v),l.call(e,a.project.currentStyle.fillColor),j.call(e,a.project.currentStyle.strokeColor),n.call(e,a.project.currentStyle.strokeWidth),b.prop="object"==typeof b.prop?b.prop:{};for(var w in G)b.prop.hasOwnProperty(w)||(b.prop[w]=G[w]);return e.data={tId:"a"+e._id,type:D,prop:b.prop,from:g,to:h,scale:v,setColor:j,getColor:k,setFill:l,getFill:m,setStrokeWidth:n,getStrokeWidth:o,setDragMode:p,itemMouseDrag:r},!1!==c&&(e.onMouseDown=q,e.onMouseUp=s,e.onPropertyChange=t),e}function h(){this.data.from=this.position,this.data.to=this.data.from.add(new a.Point({length:this.symbol.definition.bounds.width,angle:this.rotation}))}function i(a){var b=y.definition.bounds.width;this.symbol.definition.scale(a.h,a.v,[-b/2,0]),this.data.scale||(this.data.scale={h:1,v:1}),this.data.scale.h*=a.h,this.data.scale.v*=a.v,h.call(this)}function j(a){this.symbol.definition.strokeColor=a,this.symbol.definition.fillColor.alpha>0&&(this.symbol.definition.fillColor=a)}function k(){return this.symbol.definition.strokeColor}function l(a){this.symbol.definition.fillColor=a?this.symbol.definition.strokeColor:H}function m(){return this.symbol.definition.fillColor.alpha>0}function n(a){this.symbol.definition.strokeWidth=a}function o(){return this.symbol.definition.strokeWidth}function p(a,b){a in I?(J=I[a],K=b):(J=null,K={},L=!1)}function q(a){if(this.selected&&!E){J=I.FULL_DRAG;var b=this.data.to,c=this.data.from;e.call(this,a.point)?p("DRAG_TO",{delta:b.subtract(a.point)}):c.getDistance(a.point)<30&&p("DRAG_FROM",{delta:c.subtract(a.point)}),this.attach("mousedrag",r)}}function r(a){if(!E){L=!0;var b={from:this.data.from,to:this.data.to};switch(J){case I.FULL_DRAG:this.translate(a.delta),h.call(this);break;case I.DRAG_TO:b.to=K.delta?a.point.add(K.delta):a.point,delete b.from,u(this,b);break;case I.DRAG_FROM:b.from=K.delta?a.point.add(K.delta):a.point,delete b.to,u(this,b);break;case I.DRAG_HANDLE:if("right"!==K.nameParts[1])L=!1;else{var c=a.point.subtract(b.from).project(b.to.subtract(b.from)),d=c.length/this.symbol.definition.bounds.width,e=a.event.shiftKey?d:a.point.subtract(c.add(b.from)).length/this.symbol.definition.bounds.height*2;i.call(this,{h:d,v:e})}break;default:L=!1}}}function s(a){this.detach("mousedrag",r),h.call(this),J=null,L&&F.annotationChanged.dispatch(this),L=!1}function t(a,b){}function u(b,c){var d,e,g,h,i="";if(c.from||(c.from=b.data.from,i="to"),c.to||(c.to=b.data.to,i="from"),d=c.to.subtract(c.from),e=d.angle,g=b.symbol.definition.bounds.width,h=d.length-g,f.call(b,g+h)&&(h=0,"from"===i&&(c.from=c.to.subtract(new a.Point({length:g,angle:e})))),b.rotation=e,b.position=c.from,0!==h)for(var j,k=2;j=b.symbol.definition.segments[k];k++)j.point.x+=h;b.data.from=c.from,b.data.to=c.to}function v(a){return a.data&&a.data.type===D?a:a.parent?v(a.parent):null}function w(b){var c,d;if(c=a.project.activeLayer.hitTest(b,{tolerance:7,fill:!0,stroke:!0,segments:!0,handles:!0,ends:!0,bounds:!0,selected:!0}),c||(c=a.project.activeLayer.hitTest(b,{fill:!0,stroke:!0})),!c||!c.item)return!1;if(!(d=v(c.item)))return!1;if(d.selected=!0,"bounds"===c.type){"right"===c.name.split("-")[1]&&p("DRAG_HANDLE",{nameStr:c.name,nameParts:c.name.split("-"),item:d})}return!0}function x(a){return a!==E&&(E=a),E}var y,z,A,B,C,D="arrow",E=!1,F={annotationAdded:null,annotationSelected:null,annotationChanged:null},G={comment:"",fill:!0},H=new a.Color([0,0,0,0]),I={FULL_DRAG:1,DRAG_TO:2,DRAG_FROM:3,DRAG_HANDLE:4},J=null,K={},L=!1,M=!1,N=null,O=null,P={onMouseDown:function(b){E||(M=!1,O=null,w(b.point)||(a.project.deselectAll(),F.annotationSelected.dispatch(null),M=!0,N=b.point,O=g({from:N},!0),O.visible=!1))},onMouseDrag:function(a){E||(M&&O?(u(O,{from:N,to:a.point}),O.visible=!0):J===I.DRAG_HANDLE&&K.item&&r.call(K.item,a))},onMouseUp:function(a){p(null),M&&O&&(F.annotationAdded.dispatch(O),M=!1,O.selected=!0,O.visible=!0,O=null)}};return{name:D,tool:new a.Tool(P),setRo:x,registerEvent:function(a,b){F[a]=b},exportJSON:b,importJSON:c,listeners:{}}});
/*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */ /*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */
define('tools/fieldedges',["paper"],function(a){function b(b,g){b.style="object"==typeof b.style?b.style:{};for(var h in M)b.style.hasOwnProperty(h)||(b.style[h]=M[h]);b.firstEdge=new a.Path.Line({from:b.p1s,to:b.p1e}),b.secondEdge=new a.Path.Line({from:b.p2s,to:b.p2e});var i=new a.Group({children:[b.firstEdge,b.secondEdge],style:b.style});b.prop="object"==typeof b.prop?b.prop:{};for(var h in I)b.prop.hasOwnProperty(h)||(b.prop[h]=I[h]);var j=[b.firstEdge.segments[0].point,b.firstEdge.segments[1].point,b.secondEdge.segments[0].point,b.secondEdge.segments[1].point].map(function(a){return[a.x,a.y]});return i.data={tId:"a"+i._id,type:C,prop:b.prop,points:j,itemMouseDrag:e,setColor:c},g||(i.onMouseDown=function(b){this.oGetSelected()?d(b):(a.project.deselectAll(),this.oSetSelected(!0),G.annotationSelected.dispatch(this))},i.oGetSelected=function(){for(var a,b=0;a=this.children[b];b++)if(!a.selected)return!1;return!0},i.oSetSelected=function(a){this.children.map(function(b){b.selected=a})},i.onMouseUp=f),G.annotationAdded.dispatch(i),i}function c(){this.style.strokeColor=D}function d(a){K!==J.DONE&&K!==J.CREATED_BOTH||p(a)}function e(a){K===J.EDITING&&l(a)}function f(a){K===J.EDITING&&q(a)}function g(a){var b=this.exportJSON({asString:!1});t&&(b[1].data.points=[t,u,v,w].map(function(a){return console.log(a),[a.x,a.y]}));var c=["fontFamily","font","fontSize","fontLeading","leading","selected"];return[b[1],b[1].children[0][1],b[1].children[1][1]].forEach(function(a){c.forEach(function(b){a.hasOwnProperty(b)&&delete a[b]})}),b=a&&!1===a.asString?b:JSON.stringify(b)}function h(c,d,e){var f=c[1],g=f.data&&f.data.points;if(!g)return null;var h={};try{h.strokeWidth=f.children[0][1].strokeWidth}catch(a){}var i=a.project.activeLayer;d.activate();var j=b({p1s:g[0],p1e:g[1],p2s:g[2],p2e:g[3],style:h,prop:f.data.prop});return e&&(x=j.children[0],y=j.children[1],k(),K=J.CREATED_BOTH),i.activate(),j}function i(){t=u=v=w=B=null,x&&x.remove(),y&&y.remove(),x=y=null}function j(b){switch(K){case J.READY:break;case J.CREATE_FIRST:x&&x.remove(),x=new a.Path.Line({from:t,to:u}),x.style=L;break;case J.CREATE_SECOND:x&&x.remove(),x=new a.Path.Line({from:t,to:u}),x.style=M,y&&y.remove(),y=new a.Path.Line({from:v,to:w}),y.style=L;break;case J.CREATED_BOTH:}}function k(){t=x.segments[0].point,u=x.segments[1].point,v=y.segments[0].point,w=y.segments[1].point,B=v.subtract(t)}function l(a){if(z)if(isNaN(parseInt(A,2)))z.translate(a.delta);else{var b=z===x,c=b?y:x,d=b?a.point.add(B):a.point.subtract(B);z.insert(A,a.point),z.segments[A+1].remove(),c.insert(A,d),c.segments[A+1].remove()}}function m(a){t=u=a.point,K=J.CREATE_FIRST}function n(a){v=t,w=u,K=J.CREATE_SECOND}function o(a){K=J.CREATED_BOTH,B=v.subtract(t);var c=b({p1s:t,p1e:u,p2s:v,p2e:w});x&&x.remove(),x=c.children[0],y&&y.remove(),y=c.children[1],k()}function p(b){K=J.EDITING,z=A=null;var c=a.project.activeLayer.hitTest(b.point,F);c&&"pixel"!==c.type&&(c.item===x?z=x:c.item===y&&(z=y),a.project.deselectAll(),z.selected=!0,G.annotationSelected.dispatch(z),z&&"segment"===c.type&&(A=z.segments[0]===c.segment?0:1))}function q(a){K=J.DONE;var b=z?z.parent:null;z=A=null,k(),b&&G.annotationChanged.dispatch(b)}function r(a){H&&(x.strokeWidth=a,y.strokeWidth=a,E=a)}function s(a){H=a===C,H?$("#tool-colorselect").hide():$("#tool-colorselect .c7").hide()}var t,u,v,w,x,y,z,A,B,C="fieldedges",D=new a.Color("#E100FF"),E=3,F={segments:!0,stroke:!0,fill:!1,tolerance:5,bounds:!1,handles:!0},G={annotationAdded:null,annotationSelected:null,annotationChanged:null},H=!1,I={comment:""},J={READY:1,CREATE_FIRST:2,CREATE_SECOND:3,CREATED_BOTH:4,EDITING:5,DONE:6},K=J.READY,L={strokeWidth:E,strokeColor:D,dashArray:[9,4]},M={strokeWidth:E,strokeColor:D},N={onMouseDown:function(a){switch(K){case J.READY:i(),m(a);break;case J.CREATE_FIRST:n(a);break;case J.CREATE_SECOND:o(a);break;case J.CREATED_BOTH:case J.DONE:p(a)}j(a)},onMouseMove:function(a){switch(K){case J.CREATE_FIRST:u=a.point,j(a);break;case J.CREATE_SECOND:w=a.point,v=t.add(w.subtract(u)),j(a);break;case J.EDITING:l(a)}},onMouseUp:function(a){switch(K){case J.EDITING:q(a)}}};return{name:C,tool:new a.Tool(N),registerEvent:function(a,b){G[a]=b},exportJSON:g,importJSON:h,listeners:{onStrokeWidthChanged:r,onToolActivated:s}}}); define('tools/fieldedges',["paper"],function(a){function b(b,g){b.style="object"==typeof b.style?b.style:{};for(var h in M)b.style.hasOwnProperty(h)||(b.style[h]=M[h]);b.firstEdge=new a.Path.Line({from:b.p1s,to:b.p1e}),b.secondEdge=new a.Path.Line({from:b.p2s,to:b.p2e});var i=new a.Group({children:[b.firstEdge,b.secondEdge],style:b.style});b.prop="object"==typeof b.prop?b.prop:{};for(var h in I)b.prop.hasOwnProperty(h)||(b.prop[h]=I[h]);var j=[b.firstEdge.segments[0].point,b.firstEdge.segments[1].point,b.secondEdge.segments[0].point,b.secondEdge.segments[1].point].map(function(a){return[a.x,a.y]});return i.data={tId:"a"+i._id,type:C,prop:b.prop,points:j,itemMouseDrag:e,setColor:c},g||(i.onMouseDown=function(b){this.oGetSelected()?d(b):(a.project.deselectAll(),this.oSetSelected(!0),G.annotationSelected.dispatch(this))},i.oGetSelected=function(){for(var a,b=0;a=this.children[b];b++)if(!a.selected)return!1;return!0},i.oSetSelected=function(a){this.children.map(function(b){b.selected=a})},i.onMouseUp=f),G.annotationAdded.dispatch(i),i}function c(){this.style.strokeColor=D}function d(a){K!==J.DONE&&K!==J.CREATED_BOTH||p(a)}function e(a){K===J.EDITING&&l(a)}function f(a){K===J.EDITING&&q(a)}function g(a){var b=this.exportJSON({asString:!1});if(!t)return null;b[1].data.points=[t,u,v,w].map(function(a){return[a.x,a.y]});var c=["fontFamily","font","fontSize","fontLeading","leading","selected"];return[b[1],b[1].children[0][1],b[1].children[1][1]].forEach(function(a){c.forEach(function(b){a.hasOwnProperty(b)&&delete a[b]})}),b=a&&!1===a.asString?b:JSON.stringify(b)}function h(c,d,e){var f=c[1],g=f.data&&f.data.points;if(!g)return null;var h={};try{h.strokeWidth=f.children[0][1].strokeWidth}catch(a){}var i=a.project.activeLayer;d.activate();var j=b({p1s:g[0],p1e:g[1],p2s:g[2],p2e:g[3],style:h,prop:f.data.prop});return e&&(x=j.children[0],y=j.children[1],k(),K=J.CREATED_BOTH),i.activate(),j}function i(){t=u=v=w=B=null,x&&x.remove(),y&&y.remove(),x=y=null}function j(b){switch(K){case J.READY:break;case J.CREATE_FIRST:x&&x.remove(),x=new a.Path.Line({from:t,to:u}),x.style=L;break;case J.CREATE_SECOND:x&&x.remove(),x=new a.Path.Line({from:t,to:u}),x.style=M,y&&y.remove(),y=new a.Path.Line({from:v,to:w}),y.style=L;break;case J.CREATED_BOTH:}}function k(){t=x.segments[0].point,u=x.segments[1].point,v=y.segments[0].point,w=y.segments[1].point,B=v.subtract(t)}function l(a){if(z)if(isNaN(parseInt(A,2)))z.translate(a.delta);else{var b=z===x,c=b?y:x,d=b?a.point.add(B):a.point.subtract(B);z.insert(A,a.point),z.segments[A+1].remove(),c.insert(A,d),c.segments[A+1].remove()}}function m(a){t=u=a.point,K=J.CREATE_FIRST}function n(a){v=t,w=u,K=J.CREATE_SECOND}function o(a){K=J.CREATED_BOTH,B=v.subtract(t);var c=b({p1s:t,p1e:u,p2s:v,p2e:w});x&&x.remove(),x=c.children[0],y&&y.remove(),y=c.children[1],k()}function p(b){K=J.EDITING,z=A=null;var c=a.project.activeLayer.hitTest(b.point,F);c&&"pixel"!==c.type&&(c.item===x?z=x:c.item===y&&(z=y),a.project.deselectAll(),z.selected=!0,G.annotationSelected.dispatch(z),z&&"segment"===c.type&&(A=z.segments[0]===c.segment?0:1))}function q(a){K=J.DONE;var b=z?z.parent:null;z=A=null,k(),b&&G.annotationChanged.dispatch(b)}function r(a){H&&(x.strokeWidth=a,y.strokeWidth=a,E=a)}function s(a){H=a===C,H?$("#tool-colorselect").hide():$("#tool-colorselect .c7").hide()}var t,u,v,w,x,y,z,A,B,C="fieldedges",D=new a.Color("#E100FF"),E=3,F={segments:!0,stroke:!0,fill:!1,tolerance:5,bounds:!1,handles:!0},G={annotationAdded:null,annotationSelected:null,annotationChanged:null},H=!1,I={comment:""},J={READY:1,CREATE_FIRST:2,CREATE_SECOND:3,CREATED_BOTH:4,EDITING:5,DONE:6},K=J.READY,L={strokeWidth:E,strokeColor:D,dashArray:[9,4]},M={strokeWidth:E,strokeColor:D},N={onMouseDown:function(a){switch(K){case J.READY:i(),m(a);break;case J.CREATE_FIRST:n(a);break;case J.CREATE_SECOND:o(a);break;case J.CREATED_BOTH:case J.DONE:p(a)}j(a)},onMouseMove:function(a){switch(K){case J.CREATE_FIRST:u=a.point,j(a);break;case J.CREATE_SECOND:w=a.point,v=t.add(w.subtract(u)),j(a);break;case J.EDITING:l(a)}},onMouseUp:function(a){switch(K){case J.EDITING:q(a)}}};return{name:C,tool:new a.Tool(N),registerEvent:function(a,b){G[a]=b},exportJSON:g,importJSON:h,listeners:{onStrokeWidthChanged:r,onToolActivated:s}}});
/*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */ /*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */
define('tools/concordantstr',["paper"],function(a){function b(a){var b=this.exportJSON({asString:!1});return b[1].strokeColor||(b[1].strokeWidth=0),delete b[1].fontFamily,delete b[1].font,delete b[1].fontSize,delete b[1].leading,a&&a.asString?JSON.stringify(b):b}function c(b,c,d){var e=b[1],f=a.project.activeLayer;c.activate();var h=g({from:e.segments[0],to:e.segments[1],strokeWidth:e.strokeWidth,prop:e.data.prop},{not_interactive:!0});return f.activate(),h}function d(a){z=a}function e(a){A=Math.floor(1.5*a)}function f(a){(y=a===w)&&$("#tool-colorselect").hide()}function g(b,c){var d=new a.Path.Line({from:b.from,to:b.to});b.prop="object"==typeof b.prop?b.prop:{};for(var e in O)b.prop.hasOwnProperty(e)||(b.prop[e]=O[e]);return d.style=C[b.prop.confidence],parseInt(b.strokeWidth,10)&&(d.strokeWidth=b.strokeWidth),d.data={tId:"a"+d._id,type:w,prop:b.prop,itemMouseDrag:j,itemMouseUp:k,setColor:h},c&&c.not_interactive||(d.selected=!0,x.annotationSelected.dispatch(d)),d.onMouseDown=i,d.onKeyDown=l,d.onKeyUp=m,d.onPropertyChange=n,d}function h(){this.style.strokeColor=B.strokeColor}function i(b){var c=this;I=this;var d=c.hitTest(b.point,D);c.layer.activate(),a.project.deselectAll(),c.selected=!0,x.annotationSelected.dispatch(c),J=L=M=K=null,"segment"===d.type?(J=d.segment.index,K=z+(I.segments[1-J].point.x<z?1:-1)*A):(L=I.getFirstSegment().point.x<z?0:1,M=1-L),N=!1,x.annotationSelected.dispatch(c)}function j(a){a.tool&&(null!==J?t(a):I&&I.segments[L].point.x+a.delta.x<=z-A&&I.segments[M].point.x+a.delta.x>=z+A&&(I.translate(a.delta),N=!0))}function k(a){a.tool&&(I&&N&&(x.annotationChanged.dispatch([I]),N=!1),J=L=M=I=K=null)}function l(b){var c;switch(b.key){case"up":c=[0,-1];break;case"down":c=[0,1]}c&&(c=new a.Point(c).multiply(a.view.zoom<4.5?1:.5),I=this,this.translate(c),N=!0,a.view.draw())}function m(a){switch(a.key){case"up":case"down":N&&(x.annotationChanged.dispatch([I]),N=!1)}}function n(b,c){"confidence"===b&&(this.style=C[c],a.view.draw())}function o(a,b){return a.x<=z&&b.x>=z+A||a.x>=z&&b.x<=z-A}function p(){G&&G.remove(),F=null,E=!1}function q(){var a=G?G.segments[1].point.clone():null;if(o(F,a)){G&&(G.remove(),G=null);var b=g({from:F,to:a});x.annotationAdded.dispatch(b),F=null,E=!1}}function r(b,c,d){d?v&&(b.segments[c].point.y=v.y,a.view.draw()):(v=b.segments[c].point.clone(),b.segments[c].point.y=b.segments[1-c].point.y)}function s(b){G?(G.segments[1].point=b.point,b.event.shiftKey&&r(G,1)):(G=new a.Path.Line({from:F,to:b.point}),G.style=B,G.dashArray=[10,5]),G.opacity=o(F,b.point)?1:.5,G.dashArray=o(F,b.point)?null:[10,5]}function t(a){var b=a.point.clone();o(I.segments[1-J].point,b)||(b.x=K),I.segments[J].point=b,a.event.shiftKey&&r(I,J),N=!0}var u,v,w="concordantstr",x={annotationAdded:null,annotationSelected:null},y=!1,z=0,A=10,B={strokeWidth:3,strokeColor:"red"},C={1:{strokeColor:new a.Color("#FF3737"),dashArray:[10,10]},2:{strokeColor:new a.Color("#FF3737"),dashArray:[30,10]},3:{strokeColor:new a.Color("#FF0000"),dashArray:null}},D={segments:!0,stroke:!0,fill:!1,tolerance:5,bounds:!1,handles:!0},E=!0,F=null,G=null,H=!1,I=null,J=null,K=null,L=null,M=null,N=!1,O={confidence:3,comment:""},P={onMouseDown:function(b){if(F)G&&!H&&q();else{var c=a.project.activeLayer.hitTest(b.point,D);c?c.item.onMouseDown(b):(a.project.deselectAll(),x.annotationSelected.dispatch(null),F||(J=I=null,E=!0,G&&G.remove(),G=null,F=b.point,H=!1))}},onMouseDrag:function(a){E&&F&&(H=!0,s(a)),I&&I.data.itemMouseDrag(a)},onMouseMove:function(a){E&&F&&s(a)},onMouseUp:function(a){F?G&&H&&(s(a),q()):I&&I.data.itemMouseUp(a),J=I=null},onKeyDown:function(b){switch(b.key){case"enter":E&&q();break;case"escape":E&&p();break;case"shift":G?r(G,1):I&&null!==J&&r(I,J);break;case"up":case"down":for(var c,d=a.project.getSelectedItems(),e=0;c=d[e];e++)if(c.data.type&&"function"==typeof c.onKeyDown){c.onKeyDown(b);break}}},onKeyUp:function(b){switch(b.key){case"shift":G?r(G,1,!0):I&&J&&r(I,J,!0);break;case"up":case"down":for(var c,d=a.project.getSelectedItems(),e=0;c=d[e];e++)if(c.data.type&&"function"==typeof c.onKeyUp){c.onKeyUp(b);break}}}};return u=new a.Tool(P),{name:w,tool:u,registerEvent:function(a,b){x[a]=b},exportJSON:b,importJSON:c,listeners:{onCutPositionChanged:d,onCutMarginChanged:e,onToolActivated:f}}}); define('tools/concordantstr',["paper"],function(a){function b(a){var b=this.exportJSON({asString:!1});return b[1].strokeColor||(b[1].strokeWidth=0),delete b[1].fontFamily,delete b[1].font,delete b[1].fontSize,delete b[1].leading,a&&a.asString?JSON.stringify(b):b}function c(b,c,d){var e=b[1],f=a.project.activeLayer;c.activate();var h=g({from:e.segments[0],to:e.segments[1],strokeWidth:e.strokeWidth,prop:e.data.prop},{not_interactive:!0});return f.activate(),h}function d(a){z=a}function e(a){A=Math.floor(1.5*a)}function f(a){(y=a===w)&&$("#tool-colorselect").hide()}function g(b,c){var d=new a.Path.Line({from:b.from,to:b.to});b.prop="object"==typeof b.prop?b.prop:{};for(var e in O)b.prop.hasOwnProperty(e)||(b.prop[e]=O[e]);return d.style=C[b.prop.confidence],parseInt(b.strokeWidth,10)&&(d.strokeWidth=b.strokeWidth),d.data={tId:"a"+d._id,type:w,prop:b.prop,itemMouseDrag:j,itemMouseUp:k,setColor:h},c&&c.not_interactive||(d.selected=!0,x.annotationSelected.dispatch(d)),d.onMouseDown=i,d.onKeyDown=l,d.onKeyUp=m,d.onPropertyChange=n,d}function h(){this.style.strokeColor=B.strokeColor}function i(b){var c=this;I=this;var d=c.hitTest(b.point,D);c.layer.activate(),a.project.deselectAll(),c.selected=!0,x.annotationSelected.dispatch(c),J=L=M=K=null,"segment"===d.type?(J=d.segment.index,K=z+(I.segments[1-J].point.x<z?1:-1)*A):(L=I.getFirstSegment().point.x<z?0:1,M=1-L),N=!1,x.annotationSelected.dispatch(c)}function j(a){a.tool&&(null!==J?t(a):I&&I.segments[L].point.x+a.delta.x<=z-A&&I.segments[M].point.x+a.delta.x>=z+A&&(I.translate(a.delta),N=!0))}function k(a){a.tool&&(I&&N&&(x.annotationChanged.dispatch([I]),N=!1),J=L=M=I=K=null)}function l(b){var c;switch(b.key){case"up":c=[0,-1];break;case"down":c=[0,1]}c&&(c=new a.Point(c).multiply(a.view.zoom<4.5?1:.5),I=this,this.translate(c),N=!0,a.view.draw())}function m(a){switch(a.key){case"up":case"down":N&&(x.annotationChanged.dispatch([I]),N=!1)}}function n(b,c){"confidence"===b&&(this.style=C[c],a.view.draw())}function o(a,b){return a.x<=z&&b.x>=z+A||a.x>=z&&b.x<=z-A}function p(){G&&G.remove(),F=null,E=!1}function q(){var a=G?G.segments[1].point.clone():null;if(o(F,a)){G&&(G.remove(),G=null);var b=g({from:F,to:a});x.annotationAdded.dispatch(b),F=null,E=!1}}function r(b,c,d){d?v&&(b.segments[c].point.y=v.y,a.view.draw()):(v=b.segments[c].point.clone(),b.segments[c].point.y=b.segments[1-c].point.y)}function s(b){G?(G.segments[1].point=b.point,b.event.shiftKey&&r(G,1)):(G=new a.Path.Line({from:F,to:b.point}),G.style=B,G.dashArray=[10,5]),G.opacity=o(F,b.point)?1:.5,G.dashArray=o(F,b.point)?null:[10,5]}function t(a){var b=a.point.clone();o(I.segments[1-J].point,b)||(b.x=K),I.segments[J].point=b,a.event.shiftKey&&r(I,J),N=!0}var u,v,w="concordantstr",x={annotationAdded:null,annotationSelected:null},y=!1,z=0,A=10,B={strokeWidth:3,strokeColor:"red"},C={1:{strokeColor:new a.Color("#FF3737"),dashArray:[10,10]},2:{strokeColor:new a.Color("#FF3737"),dashArray:[30,10]},3:{strokeColor:new a.Color("#FF0000"),dashArray:null}},D={segments:!0,stroke:!0,fill:!1,tolerance:5,bounds:!1,handles:!0},E=!0,F=null,G=null,H=!1,I=null,J=null,K=null,L=null,M=null,N=!1,O={confidence:3,comment:""},P={onMouseDown:function(b){if(F)G&&!H&&q();else{var c=a.project.activeLayer.hitTest(b.point,D);c?c.item.onMouseDown(b):(a.project.deselectAll(),x.annotationSelected.dispatch(null),F||(J=I=null,E=!0,G&&G.remove(),G=null,F=b.point,H=!1))}},onMouseDrag:function(a){E&&F&&(H=!0,s(a)),I&&I.data.itemMouseDrag(a)},onMouseMove:function(a){E&&F&&s(a)},onMouseUp:function(a){F?G&&H&&(s(a),q()):I&&I.data.itemMouseUp(a),J=I=null},onKeyDown:function(b){switch(b.key){case"enter":E&&q();break;case"escape":E&&p();break;case"shift":G?r(G,1):I&&null!==J&&r(I,J);break;case"up":case"down":for(var c,d=a.project.getSelectedItems(),e=0;c=d[e];e++)if(c.data.type&&"function"==typeof c.onKeyDown){c.onKeyDown(b);break}}},onKeyUp:function(b){switch(b.key){case"shift":G?r(G,1,!0):I&&J&&r(I,J,!0);break;case"up":case"down":for(var c,d=a.project.getSelectedItems(),e=0;c=d[e];e++)if(c.data.type&&"function"==typeof c.onKeyUp){c.onKeyUp(b);break}}}};return u=new a.Tool(P),{name:w,tool:u,registerEvent:function(a,b){x[a]=b},exportJSON:b,importJSON:c,listeners:{onCutPositionChanged:d,onCutMarginChanged:e,onToolActivated:f}}});
/*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */ /*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */
...@@ -15902,7 +15902,7 @@ define('tools/textgeo',["paper","jquery","adim/category"],function(a,b,c){functi ...@@ -15902,7 +15902,7 @@ define('tools/textgeo',["paper","jquery","adim/category"],function(a,b,c){functi
/*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */ /*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */
define('adim/tools',["underscore","signals","tools/select","tools/pan","tools/drawing","tools/lines","tools/ellipse","tools/rectangle","tools/text","tools/arrow","tools/fieldedges","tools/concordantstr","tools/discordantstr","tools/cmsarea","tools/marker","tools/drawinggeo","tools/linesgeo","tools/ellipsegeo","tools/rectanglegeo","tools/arrowgeo","tools/textgeo"],function(a,b){function c(a,b){return b.importJSON(a)}function d(a){return this.exportJSON(a)}function e(){return n}function f(a){return m[a]?m[a].tool:null}function g(a){if(a&&m[a]){var b=f(n);b&&q.annotationCheckCancel.dispatch(b);var c=f(a);c?(n=a,c.activate(),q.activated.dispatch(a)):console&&console.warn&&console.warn("Tool «"+a+"» not activated")}}function h(a){return m[a]&&"function"==typeof m[a].importJSON?m[a].importJSON:p}function i(a){return m[a]&&"function"==typeof m[a].exportJSON?m[a].exportJSON:p}function j(a,b){return i(a.data.type).call(a,$.extend({asString:!0},b))}function k(b){b!==o&&(o=b,a.invoke(m,"setRo",b))}for(var l,m={},n=null,o=null,p=function(){},q={activated:new b,annotationAdded:new b,annotationChanged:new b,annotationSelected:new b,annotationCheckCancel:new b},r=1;l=arguments[r];r++)m[l.name]={tool:l.tool,importJSON:l.importJSON||c,exportJSON:l.exportJSON||d,setRo:l.setRo||p,listeners:l.listeners||{},events:l.events||{}},"function"==typeof l.registerEvent&&(l.registerEvent("annotationAdded",q.annotationAdded),l.registerEvent("annotationChanged",q.annotationChanged),l.registerEvent("annotationSelected",q.annotationSelected)),l.listeners&&"function"==typeof l.listeners.onToolActivated&&q.activated.add(l.listeners.onToolActivated);return function(){new paper.Tool({onMouseDown:p,onMouseUp:p,onMouseDrag:p,onKeyDown:p,onKeyUp:p}).activate()}(),{events:q,tools:m,getTool:f,getToolJSONImporter:h,getToolJSONExporter:i,activateTool:g,getActiveTool:e,serializeItem:j,setRo:k}}); define('adim/tools',["underscore","signals","tools/select","tools/pan","tools/drawing","tools/lines","tools/ellipse","tools/rectangle","tools/text","tools/arrow","tools/fieldedges","tools/concordantstr","tools/discordantstr","tools/cmsarea","tools/marker","tools/drawinggeo","tools/linesgeo","tools/ellipsegeo","tools/rectanglegeo","tools/arrowgeo","tools/textgeo"],function(a,b){function c(a,b){return b.importJSON(a)}function d(a){return this.exportJSON(a)}function e(){return n}function f(a){return m[a]?m[a].tool:null}function g(a){if(a&&m[a]){var b=f(n);b&&q.annotationCheckCancel.dispatch(b);var c=f(a);c?(n=a,c.activate(),q.activated.dispatch(a)):console&&console.warn&&console.warn("Tool «"+a+"» not activated")}}function h(a){return m[a]&&"function"==typeof m[a].importJSON?m[a].importJSON:p}function i(a){return m[a]&&"function"==typeof m[a].exportJSON?m[a].exportJSON:p}function j(a,b){return i(a.data.type).call(a,$.extend({asString:!0},b))}function k(b){b!==o&&(o=b,a.invoke(m,"setRo",b))}for(var l,m={},n=null,o=null,p=function(){},q={activated:new b,annotationAdded:new b,annotationChanged:new b,annotationSelected:new b,annotationCheckCancel:new b},r=1;l=arguments[r];r++)m[l.name]={tool:l.tool,importJSON:l.importJSON||c,exportJSON:l.exportJSON||d,setRo:l.setRo||p,listeners:l.listeners||{},events:l.events||{}},"function"==typeof l.registerEvent&&(l.registerEvent("annotationAdded",q.annotationAdded),l.registerEvent("annotationChanged",q.annotationChanged),l.registerEvent("annotationSelected",q.annotationSelected)),l.listeners&&"function"==typeof l.listeners.onToolActivated&&q.activated.add(l.listeners.onToolActivated);return function(){new paper.Tool({onMouseDown:p,onMouseUp:p,onMouseDrag:p,onKeyDown:p,onKeyUp:p}).activate()}(),{events:q,tools:m,getTool:f,getToolJSONImporter:h,getToolJSONExporter:i,activateTool:g,getActiveTool:e,serializeItem:j,setRo:k}});
/*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */ /*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */
define('adim/view',["jquery","underscore","paper","signals","adim/config","adim/users","adim/tools"],function(a,b,c,d,e,f,g){function h(a){if(!a)return!1;if(!isNaN(parseInt(a,10)))return i(a);var b=F[a]||null;if(!b)for(var d,e=2===a.indexOf(":")?a.substr(3):null,f=c.project.layers,g=0;d=f[g];g++){var h=e?d.id.toString()===e:d.name===a;if(h){b=d,F[a]=d;break}}return b}function i(a){return a=parseInt(a,10),b(c.project.layers).findWhere({id:a})}function j(b,d){var e=h(b);if(d=d||{},!e){var f=c.project.activeLayer;e=new c.Layer({name:b}),a.extend(e.data,d),F[b]=e,f&&f.activate()}return e}function k(a,b){return j("user_"+a,{owner:b||f.getById(a)||a,ownerId:a})}function l(a,b){var d=h(a);return d?(b=void 0===b?!d.visible:"function"==typeof b?!!b():!!b,d.visible=b,c.view.draw(),C.userLayerVisibilityChanged.dispatch(d,d.visible),d.visible):null}function m(){var a=[];return c.project.getSelectedItems().map(function(b){b.parent&&b.parent.data&&b.parent.data.type&&-1===a.indexOf(b.parent)?a.push(b.parent):b.data&&b.data.type&&-1===a.indexOf(b)&&a.push(b)}),a}function n(c,d){var f,h,i;try{f="string"==typeof c.item?JSON.parse(c.item):c.item}catch(a){throw"Unable to parse annotation's item"}if(!a.isArray(f)||f.length<2)return null;if("string"==typeof f[0]?h=f[1].data:a.isArray(f[0])&&(h=f[1][1].data),!h)return null;if(i=h.type,!b.isEmpty(e.activeTools)&&!b.contains(e.activeTools,i))return null;var j=k(c.owner),l=g.getToolJSONImporter(i)(f,j,d);return l&&(l.data.id=c.id,l.selected=!1),l}function o(a){for(var b,c=[],d=0;b=a[d];d++)if(b.data&&b.data.type){var e={id:b.data.id,itemStr:g.serializeItem(b),index:b.index};b.data.prop&&(e.prop=b.data.prop),c.push(e)}return c}function p(a){for(var b=c.project.layers,d=null,e=0,f=b.length;e<f;e++)for(var g=b[e].children,h=0,i=g.length;h<i;h++)if(g[h].data.tId===a){d=g[h];break}return d}function q(){for(var a,b=m(),d=0;a=b[d];d++)a.remove(),C.annotationRemoved.dispatch(a);c.view.draw()}function r(a){c.project.view.scrollBy(a),c.project.view.draw()}function s(a,b){if(b=void 0===b||!!b,"string"==typeof a){for(var d,e=a.split(","),f=0,h=c.project.layers;d=h[f];f++)for(var i,j=0,k=d.children;i=k[j];j++)i.data&&i.data.type&&e.indexOf(i.data.type)>-1&&(i.selected&&(i.selected=!1,g.events.annotationSelected.dispatch(null)),i.visible=b);c.view.draw()}}function t(a,d){d=!!b.isUndefined(d)||!!d;for(var e,f=a.val.split(","),h=0,i=c.project.layers;e=i[h];h++)for(var j,k=0,l=e.children;j=l[k];k++)if(j.data&&j.data.prop){var m=b.isUndefined(j.data.prop[a.prop])?f.indexOf("")>-1&&!0===a.undef:f.indexOf(j.data.prop[a.prop])>-1;m&&(j.selected&&(j.selected=!1,g.events.annotationSelected.dispatch(null)),j.visible=d)}c.view.draw()}function u(a,d){d=!!b.isUndefined(d)||d;for(var e,f=a.split(","),h=[],i=0,j=c.project.layers;e=j[i];i++)for(var k,l=0,m=e.children;k=m[l];l++)k.data&&k.data.type&&f.indexOf(k.data.type)>-1&&k.visible&&(k.selected=d,h.push(k));g.events.annotationSelected.dispatch(h),c.view.draw()}function v(a,b,c){var d=!1;return a.data&&a.data.prop&&(d=a.data.prop[b]!==c)&&(a.data.prop[b]=c,"function"==typeof a.onPropertyChange&&a.onPropertyChange(b,c),C.annotationPropertyChanged.dispatch(a,b,c)),d}function w(a,b,c){var d=m();c||(d=d.length?d[0]:[]);for(var e,f=!0,g=0;e=d[g];g++)f=v(e,a,b)&&f;return f}function x(a,b){return a.data&&a.data.prop&&a.data.prop.hasOwnProperty(b)?a.data.prop[b]:null}function y(a){var b=c.project.getSelectedItems();return 1===b.length?x(b[0],a):null}var z=null,A=null,B=null,C={imageLoaded:new d,annotationsLoaded:new d,annotationRemoved:new d,annotationPropertyChanged:new d,userLayerVisibilityChanged:new d},D=e.users,E={strokeWidth:7,strokeColor:"red",font:"Helvetica,Arial,sans-serif",fontSize:32},F={};return{init:function(b){return"string"==typeof b&&"#"!==b.substr(0,1)&&(b="#"+b),z=a(b),0===z.length?(console&&console.warn&&console.warn("Unable to find canvas element: "+b),!1):(c.setup(z.get(0)),c.project.activeLayer.name="image",a.extend(c.project.currentStyle,E),B=k(e.user.id,e.user.username),B.opacity=1,!0)},events:C,loadUserDict:function(a){D=e.users},updateUserDict:function(b){a.extend(D,b)},resize:function(a,b){z&&(a=parseInt(a,10)||z.width(),b=parseInt(b,10)||z.height(),z.width("100%").height(b),c.view.viewSize=[a,b],A&&(A.position=[A.bounds.width/2,A.bounds.height/2]))},scrollBy:r,loadImage:function(b,d,e){b="string"==typeof b?{url:b}:a.extend({url:""},b);var f=c.project.activeLayer,g=j("image");g.activate(),A=new c.Raster({source:b.url,position:[0,0]}),A.onLoad=function(){var a=c.project.activeLayer;g.activate();var f;b.bgUrl?(f=new c.Raster(b.bgUrl),f.translate(A.width/2,A.height/2)):f=new c.Path.Rectangle({from:[0,0],to:[A.width,A.height],fillColor:"white",strokeColor:null}),f.sendToBack(),a.activate(),C.imageLoaded.dispatch({raster:A}),"function"==typeof d&&d.call(e,A)},f.activate()},loadAnnotation:n,loadAnnotations:function(b,d){for(var f,i=[],j=b.length-1;f=b[j];j--){var k=f.owner===d;(e.ui.show_users_results||k)&&i.push(n(f,k))}if(d){var l=h("user_"+d);if(l){var m=c.project.layers,o=m.splice(l._index,1);m.push(o[0]),a.each(m,function(a,b){b._index=a}),l=h("user_"+d),l.activate(),c.view.draw()}}console.log(">> before dispatch annotationsLoaded"),C.annotationsLoaded.dispatch(i,d),c.project.deselectAll(),g.events.annotationSelected.dispatch(null),c.view.draw()},removeSelectedItems:q,getUserAnnnotationsSerialized:function(a){return o(h("user_"+a).children)},getSelectedAnnotations:m,getSelectedAnnnotationsSerialized:function(){for(var a,b=c.project.getSelectedItems(),d=[],e=0;a=b[e];e++)a.data.type&&d.push(a);return o(d)},getAnnotationsSerialized:function(b){return a.isArray(b)||(b=[b]),o(b)},getItemByTempId:p,setItemProperty:v,setSelectedItemProperty:w,getSelectedItemProperty:y,showItemsByType:function(a){s(a,!0)},hideItemsByType:function(a){s(a,!1)},toggleItemsByType:s,toggleItemsByProp:t,selectItemsByType:u,getLayerByName:h,getOrCreateLayerByName:j,getOrCreateUserLayer:k,getUserLayer:function(a){return h("user_"+a)},getAllUsersLayers:function(){for(var a=[],b=0,d=c.project.layers;b<d.length;b++)"user_"===d[b].name.substr(0,5)&&a.push(d[b]);return a},showLayer:function(a){l(a,!0)},hideLayer:function(a){l(a,!1)},toggleLayer:function(a,b){return l(a,b)},toggleMembersLayers:function(){function a(a,b){return b?e[a.id]:b}var d,e={};return function(f,h){c.project.deselectAll(),g.events.annotationSelected.dispatch(null);var i=this.getAllUsersLayers();f||(d=c.project.activeLayer,b.reduce(i,function(a,b){return a[b.id]=b.visible,a},e)),b.each(i,function(b){l(b.name,h?f:a(b,f))}),f?d&&d.activate():(l(B.id,!0),B.activate())}}(),_raster:function(){return A}}}); define('adim/view',["jquery","underscore","paper","signals","adim/config","adim/users","adim/tools"],function(a,b,c,d,e,f,g){function h(a){if(!a)return!1;if(!isNaN(parseInt(a,10)))return i(a);var b=F[a]||null;if(!b)for(var d,e=2===a.indexOf(":")?a.substr(3):null,f=c.project.layers,g=0;d=f[g];g++){var h=e?d.id.toString()===e:d.name===a;if(h){b=d,F[a]=d;break}}return b}function i(a){return a=parseInt(a,10),b(c.project.layers).findWhere({id:a})}function j(b,d){var e=h(b);if(d=d||{},!e){var f=c.project.activeLayer;e=new c.Layer({name:b}),a.extend(e.data,d),F[b]=e,f&&f.activate()}return e}function k(a,b){return j("user_"+a,{owner:b||f.getById(a)||a,ownerId:a})}function l(a,b){var d=h(a);return d?(b=void 0===b?!d.visible:"function"==typeof b?!!b():!!b,d.visible=b,c.view.draw(),C.userLayerVisibilityChanged.dispatch(d,d.visible),d.visible):null}function m(){var a=[];return c.project.getSelectedItems().map(function(b){b.parent&&b.parent.data&&b.parent.data.type&&-1===a.indexOf(b.parent)?a.push(b.parent):b.data&&b.data.type&&-1===a.indexOf(b)&&a.push(b)}),a}function n(c,d){var f,h,i;try{f="string"==typeof c.item?JSON.parse(c.item):c.item}catch(a){throw"Unable to parse annotation's item"}if(!a.isArray(f)||f.length<2)return null;if("string"==typeof f[0]?h=f[1].data:a.isArray(f[0])&&(h=f[1][1].data),!h)return null;if(i=h.type,!b.isEmpty(e.activeTools)&&!b.contains(e.activeTools,i))return null;var j=k(c.owner),l=g.getToolJSONImporter(i)(f,j,d);return l&&(l.data.id=c.id,l.selected=!1),l}function o(a){for(var b,c=[],d=0;b=a[d];d++)if(b.data&&b.data.type){var e={id:b.data.id,itemStr:g.serializeItem(b),index:b.index};b.data.prop&&(e.prop=b.data.prop),e.itemStr&&c.push(e)}return c}function p(a){for(var b=c.project.layers,d=null,e=0,f=b.length;e<f;e++)for(var g=b[e].children,h=0,i=g.length;h<i;h++)if(g[h].data.tId===a){d=g[h];break}return d}function q(){for(var a,b=m(),d=0;a=b[d];d++)a.remove(),C.annotationRemoved.dispatch(a);c.view.draw()}function r(a){c.project.view.scrollBy(a),c.project.view.draw()}function s(a,b){if(b=void 0===b||!!b,"string"==typeof a){for(var d,e=a.split(","),f=0,h=c.project.layers;d=h[f];f++)for(var i,j=0,k=d.children;i=k[j];j++)i.data&&i.data.type&&e.indexOf(i.data.type)>-1&&(i.selected&&(i.selected=!1,g.events.annotationSelected.dispatch(null)),i.visible=b);c.view.draw()}}function t(a,d){d=!!b.isUndefined(d)||!!d;for(var e,f=a.val.split(","),h=0,i=c.project.layers;e=i[h];h++)for(var j,k=0,l=e.children;j=l[k];k++)if(j.data&&j.data.prop){var m=b.isUndefined(j.data.prop[a.prop])?f.indexOf("")>-1&&!0===a.undef:f.indexOf(j.data.prop[a.prop])>-1;m&&(j.selected&&(j.selected=!1,g.events.annotationSelected.dispatch(null)),j.visible=d)}c.view.draw()}function u(a,d){d=!!b.isUndefined(d)||d;for(var e,f=a.split(","),h=[],i=0,j=c.project.layers;e=j[i];i++)for(var k,l=0,m=e.children;k=m[l];l++)k.data&&k.data.type&&f.indexOf(k.data.type)>-1&&k.visible&&(k.selected=d,h.push(k));g.events.annotationSelected.dispatch(h),c.view.draw()}function v(a,b,c){var d=!1;return a.data&&a.data.prop&&(d=a.data.prop[b]!==c)&&(a.data.prop[b]=c,"function"==typeof a.onPropertyChange&&a.onPropertyChange(b,c),C.annotationPropertyChanged.dispatch(a,b,c)),d}function w(a,b,c){var d=m();c||(d=d.length?d[0]:[]);for(var e,f=!0,g=0;e=d[g];g++)f=v(e,a,b)&&f;return f}function x(a,b){return a.data&&a.data.prop&&a.data.prop.hasOwnProperty(b)?a.data.prop[b]:null}function y(a){var b=c.project.getSelectedItems();return 1===b.length?x(b[0],a):null}var z=null,A=null,B=null,C={imageLoaded:new d,annotationsLoaded:new d,annotationRemoved:new d,annotationPropertyChanged:new d,userLayerVisibilityChanged:new d},D=e.users,E={strokeWidth:7,strokeColor:"red",font:"Helvetica,Arial,sans-serif",fontSize:32},F={};return{init:function(b){return"string"==typeof b&&"#"!==b.substr(0,1)&&(b="#"+b),z=a(b),0===z.length?(console&&console.warn&&console.warn("Unable to find canvas element: "+b),!1):(c.setup(z.get(0)),c.project.activeLayer.name="image",a.extend(c.project.currentStyle,E),B=k(e.user.id,e.user.username),B.opacity=1,!0)},events:C,loadUserDict:function(a){D=e.users},updateUserDict:function(b){a.extend(D,b)},resize:function(a,b){z&&(a=parseInt(a,10)||z.width(),b=parseInt(b,10)||z.height(),z.width("100%").height(b),c.view.viewSize=[a,b],A&&(A.position=[A.bounds.width/2,A.bounds.height/2]))},scrollBy:r,loadImage:function(b,d,e){b="string"==typeof b?{url:b}:a.extend({url:""},b);var f=c.project.activeLayer,g=j("image");g.activate(),A=new c.Raster({source:b.url,position:[0,0]}),A.onLoad=function(){var a=c.project.activeLayer;g.activate();var f;b.bgUrl?(f=new c.Raster(b.bgUrl),f.translate(A.width/2,A.height/2)):f=new c.Path.Rectangle({from:[0,0],to:[A.width,A.height],fillColor:"white",strokeColor:null}),f.sendToBack(),a.activate(),C.imageLoaded.dispatch({raster:A}),"function"==typeof d&&d.call(e,A)},f.activate()},loadAnnotation:n,loadAnnotations:function(b,d){for(var f,i=[],j=b.length-1;f=b[j];j--){var k=f.owner===d;(e.ui.show_users_results||k)&&i.push(n(f,k))}if(d){var l=h("user_"+d);if(l){var m=c.project.layers,o=m.splice(l._index,1);m.push(o[0]),a.each(m,function(a,b){b._index=a}),l=h("user_"+d),l.activate(),c.view.draw()}}console.log(">> before dispatch annotationsLoaded"),C.annotationsLoaded.dispatch(i,d),c.project.deselectAll(),g.events.annotationSelected.dispatch(null),c.view.draw()},removeSelectedItems:q,getUserAnnnotationsSerialized:function(a){return o(h("user_"+a).children)},getSelectedAnnotations:m,getSelectedAnnnotationsSerialized:function(){for(var a,b=c.project.getSelectedItems(),d=[],e=0;a=b[e];e++)a.data.type&&d.push(a);return o(d)},getAnnotationsSerialized:function(b){return a.isArray(b)||(b=[b]),o(b)},getItemByTempId:p,setItemProperty:v,setSelectedItemProperty:w,getSelectedItemProperty:y,showItemsByType:function(a){s(a,!0)},hideItemsByType:function(a){s(a,!1)},toggleItemsByType:s,toggleItemsByProp:t,selectItemsByType:u,getLayerByName:h,getOrCreateLayerByName:j,getOrCreateUserLayer:k,getUserLayer:function(a){return h("user_"+a)},getAllUsersLayers:function(){for(var a=[],b=0,d=c.project.layers;b<d.length;b++)"user_"===d[b].name.substr(0,5)&&a.push(d[b]);return a},showLayer:function(a){l(a,!0)},hideLayer:function(a){l(a,!1)},toggleLayer:function(a,b){return l(a,b)},toggleMembersLayers:function(){function a(a,b){return b?e[a.id]:b}var d,e={};return function(f,h){c.project.deselectAll(),g.events.annotationSelected.dispatch(null);var i=this.getAllUsersLayers();f||(d=c.project.activeLayer,b.reduce(i,function(a,b){return a[b.id]=b.visible,a},e)),b.each(i,function(b){l(b.name,h?f:a(b,f))}),f?d&&d.activate():(l(B.id,!0),B.activate())}}(),_raster:function(){return A}}});
/*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */ /*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */
define('adim/io',["jquery","underscore","paper","signals","adim/config","adim/view"],function(a,b,c,d,e,f){function g(){}function h(b,c,d,f){b=parseInt(b,10);var g=!b;f=parseInt(f,10)||0;var h={item:c,order:f};if(d)for(var i in d)h[i]=d[i];var j,k=e.api.annotations;return g?(j="POST",a.extend(h,{annotable:e.annotable.id,owner:e.user.id,owner_id:e.user.id})):(j="PATCH",k+=b+"/"),a.ajax({url:k,type:j,dataType:"json",data:h}).done(function(a,b,c){201===c.status?m.annotationAdded.dispatch(a):200===c.status&&m.annotationSaved.dispatch(a)}).fail(function(a){m.loadingError.dispatch({msg:"Erreur lors de l'enregistrement d'une annotation",jqXHR:a})})}function i(b,c){var d=new FormData;return d.append("aid",b),d.append("file",c),a.ajax({type:"POST",url:e.annotable.thumbnail,data:d,processData:!1,contentType:!1}).done(function(a){})}function j(a){function c(a,c){e.push(a),e.length===f&&m.annotationsSavedStatusChanged.dispatch({status:b.every(e)?"saved":"error"})}for(var d,e=[],f=a.length,g=0;d=a[g];g++)h(d.id,d.itemStr,d.prop,d.index).done(function(a){return function(){c(!0,a)}}(d.id)).fail(function(a){return function(){c(!1,a)}}(d.id))}function k(b){a.ajax({url:e.api.annotations+parseInt(b,10)+"/",type:"DELETE",success:function(a,c,d){204===d.status&&m.annotationRemoved.dispatch(b)},error:function(a){404!==a.status&&m.loadingError.dispatch({msg:"Erreur lors de la suppression d'une annotation"})}})}function l(b,c){return a.ajax({url:e.api.annotables+parseInt(b,10)+"/",type:"PATCH",dataType:"json",data:{name:c},success:function(a){m.annotableChanged.dispatch(a)}})}var m={annotableLoaded:new d,annotableChanged:new d,annotationsLoaded:new d,loadingError:new d,annotationAdded:new d,annotationSaved:new d,annotationRemoved:new d,annotationsSavedStatusChanged:new d},n=!1;return{init:g,events:m,setAutoSave:function(a){return n=!!a},getAutoSave:function(){return n},loadData:function(b){console.time("loadData"),a.ajax({url:b,dataType:"json",success:function(a){console.timeEnd("loadData"),m.annotableLoaded.dispatch(a)},error:function(){m.loadingError.dispatch({msg:"Une erreur est survenue lors du chargement des données."})}})},loadSharedAnnotations:function(b){console.log("loadSharedAnnotations");var c=a.Deferred();return a.ajax({url:b,dataType:"json",success:function(a){c.resolve(a)},error:function(){var a={msg:"Une erreur est survenue lors du chargement des données."};m.loadingError.dispatch(a),c.reject(a)}}),c},saveUserAnnotations:function(a){return a=a||e.user.id,j(f.getUserAnnnotationsSerialized(a)),!0},saveAnnotations:function(a,b){return!(!n&&!b)&&(m.annotationsSavedStatusChanged.dispatch({status:"dirty"}),j(f.getAnnotationsSerialized(a)),!0)},removeAnnotation:k,saveThumbnail:i,setAnnotableName:l}}); define('adim/io',["jquery","underscore","paper","signals","adim/config","adim/view"],function(a,b,c,d,e,f){function g(){}function h(b,c,d,f){b=parseInt(b,10);var g=!b;f=parseInt(f,10)||0;var h={item:c,order:f};if(d)for(var i in d)h[i]=d[i];var j,k=e.api.annotations;return g?(j="POST",a.extend(h,{annotable:e.annotable.id,owner:e.user.id,owner_id:e.user.id})):(j="PATCH",k+=b+"/"),a.ajax({url:k,type:j,dataType:"json",data:h}).done(function(a,b,c){201===c.status?m.annotationAdded.dispatch(a):200===c.status&&m.annotationSaved.dispatch(a)}).fail(function(a){m.loadingError.dispatch({msg:"Erreur lors de l'enregistrement d'une annotation",jqXHR:a})})}function i(b,c){var d=new FormData;return d.append("aid",b),d.append("file",c),a.ajax({type:"POST",url:e.annotable.thumbnail,data:d,processData:!1,contentType:!1}).done(function(a){})}function j(a){function c(a,c){e.push(a),e.length===f&&m.annotationsSavedStatusChanged.dispatch({status:b.every(e)?"saved":"error"})}for(var d,e=[],f=a.length,g=0;d=a[g];g++)h(d.id,d.itemStr,d.prop,d.index).done(function(a){return function(){c(!0,a)}}(d.id)).fail(function(a){return function(){c(!1,a)}}(d.id))}function k(b){a.ajax({url:e.api.annotations+parseInt(b,10)+"/",type:"DELETE",success:function(a,c,d){204===d.status&&m.annotationRemoved.dispatch(b)},error:function(a){404!==a.status&&m.loadingError.dispatch({msg:"Erreur lors de la suppression d'une annotation"})}})}function l(b,c){return a.ajax({url:e.api.annotables+parseInt(b,10)+"/",type:"PATCH",dataType:"json",data:{name:c},success:function(a){m.annotableChanged.dispatch(a)}})}var m={annotableLoaded:new d,annotableChanged:new d,annotationsLoaded:new d,loadingError:new d,annotationAdded:new d,annotationSaved:new d,annotationRemoved:new d,annotationsSavedStatusChanged:new d},n=!1;return{init:g,events:m,setAutoSave:function(a){return n=!!a},getAutoSave:function(){return n},loadData:function(b){console.time("loadData"),a.ajax({url:b,dataType:"json",success:function(a){console.timeEnd("loadData"),m.annotableLoaded.dispatch(a)},error:function(){m.loadingError.dispatch({msg:"Une erreur est survenue lors du chargement des données."})}})},loadSharedAnnotations:function(b){console.log("loadSharedAnnotations");var c=a.Deferred();return a.ajax({url:b,dataType:"json",success:function(a){c.resolve(a)},error:function(){var a={msg:"Une erreur est survenue lors du chargement des données."};m.loadingError.dispatch(a),c.reject(a)}}),c},saveUserAnnotations:function(a){return a=a||e.user.id,j(f.getUserAnnnotationsSerialized(a)),!0},saveAnnotations:function(a,b){return!(!n&&!b)&&(m.annotationsSavedStatusChanged.dispatch({status:"dirty"}),j(f.getAnnotationsSerialized(a)),!0)},removeAnnotation:k,saveThumbnail:i,setAnnotableName:l}});
/*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */ /*! AdIm - v3.0.0 - 2019-03-25 - Copyright (C) 2019 Université de Lausanne - see licence */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment