Gitlab CSE Unil

Commit 52014ab8 authored by M. Chardon's avatar M. Chardon
Browse files

Merge remote-tracking branch 'origin/master' into dev

parents de1b24d0 c7286d1f
......@@ -17915,6 +17915,7 @@ define('adim/category',["underscore", "paper", "signals"], function (_, paper, S
_categories['default'] = _categories[id];
}
});
_categories['default'] = _categories['cat_2'];
}
 
/**
......@@ -17971,7 +17972,7 @@ define('tools/marker',[
var defaultProperties = {
//comment: "",
labelComment: "",
category: ""
category: "cat_2"
};
 
// Markers management related
......@@ -17999,12 +18000,17 @@ define('tools/marker',[
var curLayer = paper.project.activeLayer;
layer.activate();
 
// Keep copy of current category
var curCat = defaultProperties.category;
var marker = createMarker(itemData.origin, itemData, listening);
if (itemData.prop.category) {
_setCategory.call(marker, itemData.prop.category);
}
 
// Restore states
curLayer.activate();
defaultProperties.category = curCat;
 
return marker;
}
......@@ -18258,6 +18264,7 @@ define('tools/marker',[
var category = Category.getCategory(catId),
color = (category && category.color) || "#000000";
_setColor.call(this, color);
defaultProperties.category = catId;
}
 
 
......@@ -18431,6 +18438,7 @@ define('tools/marker',[
 
var marker = hitOnMarkerTest(event.point);
if (marker) {
debugger;
if (!marker.selected) {
paper.project.deselectAll();
marker.selected = true;
......@@ -18452,6 +18460,7 @@ define('tools/marker',[
itemMouseDown.call(marker, event);
_selectedMarker = marker;
_events.annotationSelected.dispatch(marker);
}
},
 
......@@ -27534,7 +27543,7 @@ function($){
!function(a){function b(b){if("string"==typeof b.data&&(b.data={keys:b.data}),b.data&&b.data.keys&&"string"==typeof b.data.keys){var c=b.handler,d=b.data.keys.toLowerCase().split(" ");b.handler=function(b){if(this===b.target||!(/textarea|select/i.test(b.target.nodeName)||a.hotkeys.options.filterTextInputs&&a.inArray(b.target.type,a.hotkeys.textAcceptingInputTypes)>-1)){var e="keypress"!==b.type&&a.hotkeys.specialKeys[b.which],f=String.fromCharCode(b.which).toLowerCase(),g="",h={};a.each(["alt","ctrl","shift"],function(a,c){b[c+"Key"]&&e!==c&&(g+=c+"+")}),b.metaKey&&!b.ctrlKey&&"meta"!==e&&(g+="meta+"),b.metaKey&&"meta"!==e&&g.indexOf("alt+ctrl+shift+")>-1&&(g=g.replace("alt+ctrl+shift+","hyper+")),e?h[g+e]=!0:(h[g+f]=!0,h[g+a.hotkeys.shiftNums[f]]=!0,"shift+"===g&&(h[a.hotkeys.shiftNums[f]]=!0));for(var i=0,j=d.length;j>i;i++)if(h[d[i]])return c.apply(this,arguments)}}}}a.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",10:"return",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",59:";",61:"=",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},shiftNums:{"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"},textAcceptingInputTypes:["text","password","number","email","url","range","date","month","week","time","datetime","datetime-local","search","color","tel"],options:{filterTextInputs:!0}},a.each(["keydown","keyup","keypress"],function(){a.event.special[this]={add:b}})}(jQuery||this.jQuery||window.jQuery);
define("jquery.hotkeys", ["jquery"], function(){});
 
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('env/shortcuts',["jquery","paper","signals","adim/config","adim/view","adim/tools","adim/ui","jquery.hotkeys"],function(a,b,c,d,e,f){var g,h=function(){return function(){return!1}};return{"backspace del":[{event:"keydown",ctxt:"edit",fn:function(){return e.removeSelectedItems(),!1}},{event:"keydown",ctxt:"review",fn:h()}],space:[{event:"keydown",fn:function(){return g||(g=f.getActiveTool(),f.activateTool("pan")),!1}},{event:"keyup",fn:function(){return g&&(f.activateTool(g),g=null),!1}}],a:[{event:"keydown",ctxt:"edit",fn:function(){return f.activateTool("select"),!1}}],"ctrl+a meta+a":[{event:"keydown",ctxt:"edit",fn:function(){return b.project.activeLayer.children.map(function(a){a.selected=!0}),!1}},{event:"keydown",ctxt:"review",fn:h()}],d:[{event:"keydown",ctxt:"edit",fn:function(){return f.activateTool("drawing"),!1}}],f:[{event:"keydown",ctxt:"edit",fn:function(){return f.activateTool("arrow"),!1}}],l:[{event:"keydown",ctxt:"edit",fn:function(){return f.activateTool("lines"),!1}}],c:[{event:"keydown",ctxt:"edit",fn:function(){return f.activateTool("ellipse"),!1}}],r:[{event:"keydown",ctxt:"edit",fn:function(){return f.activateTool("rectangle"),!1}}],t:[{event:"keydown",ctxt:"edit",fn:function(){return f.activateTool("text"),!1}}]}});
/*! Sortable 1.2.0 - MIT | git://github.com/rubaxa/Sortable.git */
!function(a){"function"==typeof define&&define.amd?define('sortable',a):"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=a():"undefined"!=typeof Package?Sortable=a():window.Sortable=a()}(function(){function a(a,b){this.el=a,this.options=b=q({},b),a[H]=this;var d={group:Math.random(),sort:!0,disabled:!1,store:null,handle:null,scroll:!0,scrollSensitivity:30,scrollSpeed:10,draggable:/[uo]l/i.test(a.nodeName)?"li":">*",ghostClass:"sortable-ghost",ignore:"a, img",filter:null,animation:0,setData:function(a,b){a.setData("Text",b.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0};for(var e in d)!(e in b)&&(b[e]=d[e]);var g=b.group;g&&"object"==typeof g||(g=b.group={name:g}),["pull","put"].forEach(function(a){a in g||(g[a]=!0)}),b.groups=" "+g.name+(g.put.join?" "+g.put.join(" "):"")+" ";for(var h in this)"_"===h.charAt(0)&&(this[h]=c(this,this[h]));f(a,"mousedown",this._onTapStart),f(a,"touchstart",this._onTapStart),f(a,"dragover",this),f(a,"dragenter",this),Q.push(this._onDragOver),b.store&&this.sort(b.store.get(this))}function b(a){t&&t.state!==a&&(i(t,"display",a?"none":""),!a&&t.state&&u.insertBefore(t,r),t.state=a)}function c(a,b){var c=P.call(arguments,2);return b.bind?b.bind.apply(b,[a].concat(c)):function(){return b.apply(a,c.concat(P.call(arguments)))}}function d(a,b,c){if(a){c=c||J,b=b.split(".");var d=b.shift().toUpperCase(),e=new RegExp("\\s("+b.join("|")+")\\s","g");do if(">*"===d&&a.parentNode===c||(""===d||a.nodeName.toUpperCase()==d)&&(!b.length||((" "+a.className+" ").match(e)||[]).length==b.length))return a;while(a!==c&&(a=a.parentNode))}return null}function e(a){a.dataTransfer.dropEffect="move",a.preventDefault()}function f(a,b,c){a.addEventListener(b,c,!1)}function g(a,b,c){a.removeEventListener(b,c,!1)}function h(a,b,c){if(a)if(a.classList)a.classList[c?"add":"remove"](b);else{var d=(" "+a.className+" ").replace(G," ").replace(" "+b+" "," ");a.className=(d+(c?" "+b:"")).replace(G," ")}}function i(a,b,c){var d=a&&a.style;if(d){if(void 0===c)return J.defaultView&&J.defaultView.getComputedStyle?c=J.defaultView.getComputedStyle(a,""):a.currentStyle&&(c=a.currentStyle),void 0===b?c:c[b];b in d||(b="-webkit-"+b),d[b]=c+("string"==typeof c?"":"px")}}function j(a,b,c){if(a){var d=a.getElementsByTagName(b),e=0,f=d.length;if(c)for(;f>e;e++)c(d[e],e);return d}return[]}function k(a){a.draggable=!1}function l(){M=!1}function m(a,b){var c=a.lastElementChild,d=c.getBoundingClientRect();return b.clientY-(d.top+d.height)>5&&c}function n(a){for(var b=a.tagName+a.className+a.src+a.href+a.textContent,c=b.length,d=0;c--;)d+=b.charCodeAt(c);return d.toString(36)}function o(a){for(var b=0;a&&(a=a.previousElementSibling);)"TEMPLATE"!==a.nodeName.toUpperCase()&&b++;return b}function p(a,b){var c,d;return function(){void 0===c&&(c=arguments,d=this,setTimeout(function(){1===c.length?a.call(d,c[0]):a.apply(d,c),c=void 0},b))}}function q(a,b){if(a&&b)for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}var r,s,t,u,v,w,x,y,z,A,B,C,D,E,F={},G=/\s+/g,H="Sortable"+(new Date).getTime(),I=window,J=I.document,K=I.parseInt,L=!!("draggable"in J.createElement("div")),M=!1,N=function(a,b,c,d,e,f,g){var h=J.createEvent("Event"),i=(a||b[H]).options,j="on"+c.charAt(0).toUpperCase()+c.substr(1);h.initEvent(c,!0,!0),h.item=d||b,h.from=e||b,h.clone=t,h.oldIndex=f,h.newIndex=g,i[j]&&i[j].call(a,h),b.dispatchEvent(h)},O=Math.abs,P=[].slice,Q=[],R=p(function(a,b,c){if(c&&b.scroll){var d,e,f,g,h=b.scrollSensitivity,i=b.scrollSpeed,j=a.clientX,k=a.clientY,l=window.innerWidth,m=window.innerHeight;if(x!==c&&(w=b.scroll,x=c,w===!0)){w=c;do if(w.offsetWidth<w.scrollWidth||w.offsetHeight<w.scrollHeight)break;while(w=w.parentNode)}w&&(d=w,e=w.getBoundingClientRect(),f=(O(e.right-j)<=h)-(O(e.left-j)<=h),g=(O(e.bottom-k)<=h)-(O(e.top-k)<=h)),f||g||(f=(h>=l-j)-(h>=j),g=(h>=m-k)-(h>=k),(f||g)&&(d=I)),(F.vx!==f||F.vy!==g||F.el!==d)&&(F.el=d,F.vx=f,F.vy=g,clearInterval(F.pid),d&&(F.pid=setInterval(function(){d===I?I.scrollTo(I.pageXOffset+f*i,I.pageYOffset+g*i):(g&&(d.scrollTop+=g*i),f&&(d.scrollLeft+=f*i))},24)))}},30);return a.prototype={constructor:a,_onTapStart:function(a){var b=this,c=this.el,e=this.options,f=a.type,g=a.touches&&a.touches[0],h=(g||a).target,i=h,j=e.filter;if(!("mousedown"===f&&0!==a.button||e.disabled)&&(h=d(h,e.draggable,c))){if(A=o(h),"function"==typeof j){if(j.call(this,a,h,this))return N(b,i,"filter",h,c,A),void a.preventDefault()}else if(j&&(j=j.split(",").some(function(a){return a=d(i,a.trim(),c),a?(N(b,a,"filter",h,c,A),!0):void 0})))return;(!e.handle||d(i,e.handle,c))&&this._prepareDragStart(a,g,h)}},_prepareDragStart:function(a,b,c){var d,e=this,g=e.el,h=e.options,i=g.ownerDocument;c&&!r&&c.parentNode===g&&(D=a,u=g,r=c,v=r.nextSibling,C=h.group,d=function(){e._disableDelayedDrag(),r.draggable=!0,h.ignore.split(",").forEach(function(a){j(r,a.trim(),k)}),e._triggerDragStart(b)},f(i,"mouseup",e._onDrop),f(i,"touchend",e._onDrop),f(i,"touchcancel",e._onDrop),h.delay?(f(i,"mousemove",e._disableDelayedDrag),f(i,"touchmove",e._disableDelayedDrag),e._dragStartTimer=setTimeout(d,h.delay)):d())},_disableDelayedDrag:function(){var a=this.el.ownerDocument;clearTimeout(this._dragStartTimer),g(a,"mousemove",this._disableDelayedDrag),g(a,"touchmove",this._disableDelayedDrag)},_triggerDragStart:function(a){a?(D={target:r,clientX:a.clientX,clientY:a.clientY},this._onDragStart(D,"touch")):L?(f(r,"dragend",this),f(u,"dragstart",this._onDragStart)):this._onDragStart(D,!0);try{J.selection?J.selection.empty():window.getSelection().removeAllRanges()}catch(b){}},_dragStarted:function(){u&&r&&(h(r,this.options.ghostClass,!0),a.active=this,N(this,u,"start",r,u,A))},_emulateDragOver:function(){if(E){i(s,"display","none");var a=J.elementFromPoint(E.clientX,E.clientY),b=a,c=" "+this.options.group.name,d=Q.length;if(b)do{if(b[H]&&b[H].options.groups.indexOf(c)>-1){for(;d--;)Q[d]({clientX:E.clientX,clientY:E.clientY,target:a,rootEl:b});break}a=b}while(b=b.parentNode);i(s,"display","")}},_onTouchMove:function(a){if(D){var b=a.touches?a.touches[0]:a,c=b.clientX-D.clientX,d=b.clientY-D.clientY,e=a.touches?"translate3d("+c+"px,"+d+"px,0)":"translate("+c+"px,"+d+"px)";E=b,i(s,"webkitTransform",e),i(s,"mozTransform",e),i(s,"msTransform",e),i(s,"transform",e),a.preventDefault()}},_onDragStart:function(a,b){var c=a.dataTransfer,d=this.options;if(this._offUpEvents(),"clone"==C.pull&&(t=r.cloneNode(!0),i(t,"display","none"),u.insertBefore(t,r)),b){var e,g=r.getBoundingClientRect(),h=i(r);s=r.cloneNode(!0),i(s,"top",g.top-K(h.marginTop,10)),i(s,"left",g.left-K(h.marginLeft,10)),i(s,"width",g.width),i(s,"height",g.height),i(s,"opacity","0.8"),i(s,"position","fixed"),i(s,"zIndex","100000"),u.appendChild(s),e=s.getBoundingClientRect(),i(s,"width",2*g.width-e.width),i(s,"height",2*g.height-e.height),"touch"===b?(f(J,"touchmove",this._onTouchMove),f(J,"touchend",this._onDrop),f(J,"touchcancel",this._onDrop)):(f(J,"mousemove",this._onTouchMove),f(J,"mouseup",this._onDrop)),this._loopId=setInterval(this._emulateDragOver,150)}else c&&(c.effectAllowed="move",d.setData&&d.setData.call(this,c,r)),f(J,"drop",this);setTimeout(this._dragStarted,0)},_onDragOver:function(a){var c,e,f,g=this.el,h=this.options,j=h.group,k=j.put,n=C===j,o=h.sort;if(void 0!==a.preventDefault&&(a.preventDefault(),!h.dragoverBubble&&a.stopPropagation()),C&&!h.disabled&&(n?o||(f=!u.contains(r)):C.pull&&k&&(C.name===j.name||k.indexOf&&~k.indexOf(C.name)))&&(void 0===a.rootEl||a.rootEl===this.el)){if(R(a,h,this.el),M)return;if(c=d(a.target,h.draggable,g),e=r.getBoundingClientRect(),f)return b(!0),void(t||v?u.insertBefore(r,t||v):o||u.appendChild(r));if(0===g.children.length||g.children[0]===s||g===a.target&&(c=m(g,a))){if(c){if(c.animated)return;q=c.getBoundingClientRect()}b(n),g.appendChild(r),this._animate(e,r),c&&this._animate(q,c)}else if(c&&!c.animated&&c!==r&&void 0!==c.parentNode[H]){y!==c&&(y=c,z=i(c));var p,q=c.getBoundingClientRect(),w=q.right-q.left,x=q.bottom-q.top,A=/left|right|inline/.test(z.cssFloat+z.display),B=c.offsetWidth>r.offsetWidth,D=c.offsetHeight>r.offsetHeight,E=(A?(a.clientX-q.left)/w:(a.clientY-q.top)/x)>.5,F=c.nextElementSibling;M=!0,setTimeout(l,30),b(n),p=A?c.previousElementSibling===r&&!B||E&&B:F!==r&&!D||E&&D,p&&!F?g.appendChild(r):c.parentNode.insertBefore(r,p?F:c),this._animate(e,r),this._animate(q,c)}}},_animate:function(a,b){var c=this.options.animation;if(c){var d=b.getBoundingClientRect();i(b,"transition","none"),i(b,"transform","translate3d("+(a.left-d.left)+"px,"+(a.top-d.top)+"px,0)"),b.offsetWidth,i(b,"transition","all "+c+"ms"),i(b,"transform","translate3d(0,0,0)"),clearTimeout(b.animated),b.animated=setTimeout(function(){i(b,"transition",""),i(b,"transform",""),b.animated=!1},c)}},_offUpEvents:function(){var a=this.el.ownerDocument;g(J,"touchmove",this._onTouchMove),g(a,"mouseup",this._onDrop),g(a,"touchend",this._onDrop),g(a,"touchcancel",this._onDrop)},_onDrop:function(b){var c=this.el,d=this.options;clearInterval(this._loopId),clearInterval(F.pid),clearTimeout(this.dragStartTimer),g(J,"drop",this),g(J,"mousemove",this._onTouchMove),g(c,"dragstart",this._onDragStart),this._offUpEvents(),b&&(b.preventDefault(),!d.dropBubble&&b.stopPropagation(),s&&s.parentNode.removeChild(s),r&&(g(r,"dragend",this),k(r),h(r,this.options.ghostClass,!1),u!==r.parentNode?(B=o(r),N(null,r.parentNode,"sort",r,u,A,B),N(this,u,"sort",r,u,A,B),N(null,r.parentNode,"add",r,u,A,B),N(this,u,"remove",r,u,A,B)):(t&&t.parentNode.removeChild(t),r.nextSibling!==v&&(B=o(r),N(this,u,"update",r,u,A,B),N(this,u,"sort",r,u,A,B))),a.active&&N(this,u,"end",r,u,A,B)),u=r=s=v=t=w=x=D=E=y=z=C=a.active=null,this.save())},handleEvent:function(a){var b=a.type;"dragover"===b||"dragenter"===b?r&&(this._onDragOver(a),e(a)):("drop"===b||"dragend"===b)&&this._onDrop(a)},toArray:function(){for(var a,b=[],c=this.el.children,e=0,f=c.length,g=this.options;f>e;e++)a=c[e],d(a,g.draggable,this.el)&&b.push(a.getAttribute(g.dataIdAttr)||n(a));return b},sort:function(a){var b={},c=this.el;this.toArray().forEach(function(a,e){var f=c.children[e];d(f,this.options.draggable,c)&&(b[a]=f)},this),a.forEach(function(a){b[a]&&(c.removeChild(b[a]),c.appendChild(b[a]))})},save:function(){var a=this.options.store;a&&a.set(this)},closest:function(a,b){return d(a,b||this.options.draggable,this.el)},option:function(a,b){var c=this.options;return void 0===b?c[a]:void(c[a]=b)},destroy:function(){var a=this.el;a[H]=null,g(a,"mousedown",this._onTapStart),g(a,"touchstart",this._onTapStart),g(a,"dragover",this),g(a,"dragenter",this),Array.prototype.forEach.call(a.querySelectorAll("[draggable]"),function(a){a.removeAttribute("draggable")}),Q.splice(Q.indexOf(this._onDragOver),1),this._onDrop(),this.el=a=null}},a.utils={on:f,off:g,css:i,find:j,bind:c,is:function(a,b){return!!d(a,b,a)},extend:q,throttle:p,closest:d,toggleClass:h,index:o},a.version="1.2.0",a.create=function(b,c){return new a(b,c)},a});
......@@ -27873,7 +27882,7 @@ define('tools/marker-ui',[
}
}
);
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('env/env',["jquery","underscore","paper","signals","adim/config","adim/view","adim/attributes","adim/io","adim/tools","adim/ui","adim/category","env/shortcuts","tools/marker-ui"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){function n(){console.info("_initSignalRouting from env/anodate"),h.events.annotableLoaded.add(function(){f.events.annotationRemoved.add(function(a){"marker"===a.data.type&&i.tools.marker.listeners.updateNumbering()}),f.events.imageLoaded.add(function(){})},100),f.events.annotationsLoaded.add(function(){i.tools.marker.listeners.updateNumbering()},-100),j.events.modeChanged.add(function(b){var c=b.mode;"edit"===c?(a("#annotation-display-panel").hide(),a("#annotation-property-panel").show()):"review"===c&&(a("#annotation-display-panel").show(),a("#annotation-property-panel").hide())})}function o(b){function c(a){e.toggleClass("col-sm-1",!a).toggleClass("col-sm-2",a),l.toggleClass("hidden",!a),i.toggleClass("col-xs-12",!a).toggleClass("col-xs-6",a)}function d(a){c(a&&n.find(".panel-collapse").hasClass("in")),n.toggleClass("hidden",!a)}k.init(),m.init(b),a("#tool-colorselect").find(".color-menu").addClass("no-picker"),a(".adim-display-type-selector").find("button").on("click",function(b){var c=a(this),d=!c.hasClass("active"),e=c.data("category");b.metaKey||(c.toggleClass("active",d),"image"===e?g.setImageOpacity(d?100:0,!0):f.toggleItemsByProp({prop:"category",val:e,undef:!0},d))});var e=a("#side-col"),h=a(".canvas-container"),i=a("#side-col-panel-group"),l=a("#alt-side-col-panel-group"),n=a("#shared-annotation-markers-panel");d("review"===b.mode),j.events.modeChanged.add(function(a){var b=a.mode;d("review"===b),j.updateReservedSpace(),j.adjustCanvasToImage()}),n.find(".panel-collapse").on("hidden.bs.collapse",function(){h.css("transition","width 0.2s cubic-bezier(0.25, 0.1, 0.25, 1) 0s"),n.prependTo(i),c(!1),j.updateReservedSpace(),j.adjustCanvasToImage(),h.css("transition","")}).on("show.bs.collapse",function(){c(!0),n.appendTo(l),j.updateReservedSpace(),j.adjustCanvasToImage()})}function p(){var b,d=a("#tool-colorselect").find(".color-menu .c4").css("backgroundColor");if(0===d.indexOf("rgb")){var e=d.split(/[(),]/).map(function(a){return parseFloat(a.trim())}).filter(function(a){return!isNaN(a)});b=new c.Color(e[0]/255,e[1]/255,e[2]/255)}else b=new c.Color(d);return{strokeColor:b}}var q={name:"anodate",shortcuts:l,initSignalRouting:n,initUI:o};return Object.defineProperty(q,"style",{get:p}),q});
/**
* Copyright (C) 2014 Université de Lausanne, RISET,
......@@ -17915,6 +17915,7 @@ define('adim/category',["underscore", "paper", "signals"], function (_, paper, S
_categories['default'] = _categories[id];
}
});
_categories['default'] = _categories['cat_2'];
}
 
/**
......@@ -17971,7 +17972,7 @@ define('tools/marker',[
var defaultProperties = {
//comment: "",
labelComment: "",
category: ""
category: "cat_2"
};
 
// Markers management related
......@@ -17999,12 +18000,17 @@ define('tools/marker',[
var curLayer = paper.project.activeLayer;
layer.activate();
 
// Keep copy of current category
var curCat = defaultProperties.category;
var marker = createMarker(itemData.origin, itemData, listening);
if (itemData.prop.category) {
_setCategory.call(marker, itemData.prop.category);
}
 
// Restore states
curLayer.activate();
defaultProperties.category = curCat;
 
return marker;
}
......@@ -18258,6 +18264,7 @@ define('tools/marker',[
var category = Category.getCategory(catId),
color = (category && category.color) || "#000000";
_setColor.call(this, color);
defaultProperties.category = catId;
}
 
 
......@@ -18431,6 +18438,7 @@ define('tools/marker',[
 
var marker = hitOnMarkerTest(event.point);
if (marker) {
debugger;
if (!marker.selected) {
paper.project.deselectAll();
marker.selected = true;
......@@ -18452,6 +18460,7 @@ define('tools/marker',[
itemMouseDown.call(marker, event);
_selectedMarker = marker;
_events.annotationSelected.dispatch(marker);
}
},
 
......@@ -19828,7 +19837,7 @@ define("jquery.bootstrap", ["jquery"], function(){});
!function(a){!function(a){function b(){}function c(a){function c(b){b.prototype.option||(b.prototype.option=function(b){a.isPlainObject(b)&&(this.options=a.extend(!0,this.options,b))})}function e(b,c){a.fn[b]=function(e){if("string"==typeof e){for(var g=d.call(arguments,1),h=0,i=this.length;i>h;h++){var j=this[h],k=a.data(j,b);if(k)if(a.isFunction(k[e])&&"_"!==e.charAt(0)){var l=k[e].apply(k,g);if(void 0!==l&&l!==k)return l}else f("no such method '"+e+"' for "+b+" instance");else f("cannot call methods on "+b+" prior to initialization; attempted to call '"+e+"'")}return this}var m=this.map(function(){var d=a.data(this,b);return d?(d.option(e),d._init()):(d=new c(this,e),a.data(this,b,d)),a(this)});return!m||m.length>1?m:m[0]}}if(a){var f="undefined"==typeof console?b:function(a){console.error(a)};return a.bridget=function(a,b){c(b),e(a,b)},a.bridget}}var d=Array.prototype.slice;c(a)}(a),function(a){function b(b,c){function d(a,b){var c="data-slider-"+b,d=a.getAttribute(c);try{return JSON.parse(d)}catch(e){return d}}"string"==typeof b?this.element=document.querySelector(b):b instanceof HTMLElement&&(this.element=b);var e,f,g,h=this.element.style.width,i=!1,j=this.element.parentNode;if(this.sliderElem)i=!0;else{this.sliderElem=document.createElement("div"),this.sliderElem.className="slider";var k=document.createElement("div");k.className="slider-track",e=document.createElement("div"),e.className="slider-selection",f=document.createElement("div"),f.className="slider-handle min-slider-handle",g=document.createElement("div"),g.className="slider-handle max-slider-handle",k.appendChild(e),k.appendChild(f),k.appendChild(g);var l=function(a){var b=document.createElement("div");b.className="tooltip-arrow";var c=document.createElement("div");c.className="tooltip-inner",a.appendChild(b),a.appendChild(c)},m=document.createElement("div");m.className="tooltip tooltip-main",l(m);var n=document.createElement("div");n.className="tooltip tooltip-min",l(n);var o=document.createElement("div");o.className="tooltip tooltip-max",l(o),this.sliderElem.appendChild(k),this.sliderElem.appendChild(m),this.sliderElem.appendChild(n),this.sliderElem.appendChild(o),j.insertBefore(this.sliderElem,this.element),this.element.style.display="none"}a&&(this.$element=a(this.element),this.$sliderElem=a(this.sliderElem)),c=c?c:{};for(var p=Object.keys(this.defaultOptions),q=0;q<p.length;q++){var r=p[q],s=c[r];s="undefined"!=typeof s?s:d(this.element,r),s=null!==s?s:this.defaultOptions[r],this.options||(this.options={}),this.options[r]=s}this.eventToCallbackMap={},this.sliderElem.id=this.options.id,this.touchCapable="ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch,this.tooltip=this.sliderElem.querySelector(".tooltip-main"),this.tooltipInner=this.tooltip.querySelector(".tooltip-inner"),this.tooltip_min=this.sliderElem.querySelector(".tooltip-min"),this.tooltipInner_min=this.tooltip_min.querySelector(".tooltip-inner"),this.tooltip_max=this.sliderElem.querySelector(".tooltip-max"),this.tooltipInner_max=this.tooltip_max.querySelector(".tooltip-inner"),i===!0&&(this._removeClass(this.sliderElem,"slider-horizontal"),this._removeClass(this.sliderElem,"slider-vertical"),this._removeClass(this.tooltip,"hide"),this._removeClass(this.tooltip_min,"hide"),this._removeClass(this.tooltip_max,"hide"),["left","top","width","height"].forEach(function(a){this._removeProperty(this.trackSelection,a)},this),[this.handle1,this.handle2].forEach(function(a){this._removeProperty(a,"left"),this._removeProperty(a,"top")},this),[this.tooltip,this.tooltip_min,this.tooltip_max].forEach(function(a){this._removeProperty(a,"left"),this._removeProperty(a,"top"),this._removeProperty(a,"margin-left"),this._removeProperty(a,"margin-top"),this._removeClass(a,"right"),this._removeClass(a,"top")},this)),"vertical"===this.options.orientation?(this._addClass(this.sliderElem,"slider-vertical"),this.stylePos="top",this.mousePos="pageY",this.sizePos="offsetHeight",this._addClass(this.tooltip,"right"),this.tooltip.style.left="100%",this._addClass(this.tooltip_min,"right"),this.tooltip_min.style.left="100%",this._addClass(this.tooltip_max,"right"),this.tooltip_max.style.left="100%"):(this._addClass(this.sliderElem,"slider-horizontal"),this.sliderElem.style.width=h,this.options.orientation="horizontal",this.stylePos="left",this.mousePos="pageX",this.sizePos="offsetWidth",this._addClass(this.tooltip,"top"),this.tooltip.style.top=-this.tooltip.outerHeight-14+"px",this._addClass(this.tooltip_min,"top"),this.tooltip_min.style.top=-this.tooltip_min.outerHeight-14+"px",this._addClass(this.tooltip_max,"top"),this.tooltip_max.style.top=-this.tooltip_max.outerHeight-14+"px"),this.options.value instanceof Array?this.options.range=!0:this.options.range&&(this.options.value=[this.options.value,this.options.max]),this.trackSelection=e||this.trackSelection,"none"===this.options.selection&&this._addClass(this.trackSelection,"hide"),this.handle1=f||this.handle1,this.handle2=g||this.handle2,i===!0&&(this._removeClass(this.handle1,"round triangle"),this._removeClass(this.handle2,"round triangle hide"));var t=["round","triangle","custom"],u=-1!==t.indexOf(this.options.handle);u&&(this._addClass(this.handle1,this.options.handle),this._addClass(this.handle2,this.options.handle)),this.offset=this._offset(this.sliderElem),this.size=this.sliderElem[this.sizePos],this.setValue(this.options.value),this.handle1Keydown=this._keydown.bind(this,0),this.handle1.addEventListener("keydown",this.handle1Keydown,!1),this.handle2Keydown=this._keydown.bind(this,0),this.handle2.addEventListener("keydown",this.handle2Keydown,!1),this.touchCapable?(this.mousedown=this._mousedown.bind(this),this.sliderElem.addEventListener("touchstart",this.mousedown,!1)):(this.mousedown=this._mousedown.bind(this),this.sliderElem.addEventListener("mousedown",this.mousedown,!1)),"hide"===this.options.tooltip?(this._addClass(this.tooltip,"hide"),this._addClass(this.tooltip_min,"hide"),this._addClass(this.tooltip_max,"hide")):"always"===this.options.tooltip?(this._showTooltip(),this._alwaysShowTooltip=!0):(this.showTooltip=this._showTooltip.bind(this),this.hideTooltip=this._hideTooltip.bind(this),this.sliderElem.addEventListener("mouseenter",this.showTooltip,!1),this.sliderElem.addEventListener("mouseleave",this.hideTooltip,!1),this.handle1.addEventListener("focus",this.showTooltip,!1),this.handle1.addEventListener("blur",this.hideTooltip,!1),this.handle2.addEventListener("focus",this.showTooltip,!1),this.handle2.addEventListener("blur",this.hideTooltip,!1)),this.options.enabled?this.enable():this.disable()}var c={formatInvalidInputErrorMsg:function(a){return"Invalid input value '"+a+"' passed in"},callingContextNotSliderInstance:"Calling context element does not have instance of Slider bound to it. Check your code to make sure the JQuery object returned from the call to the slider() initializer is calling the method"},d=function(a,c){return b.call(this,a,c),this};if(d.prototype={_init:function(){},constructor:d,defaultOptions:{id:"",min:0,max:10,step:1,precision:0,orientation:"horizontal",value:5,range:!1,selection:"before",tooltip:"show",tooltip_split:!1,handle:"round",reversed:!1,enabled:!0,formatter:function(a){return a instanceof Array?a[0]+" : "+a[1]:a},natural_arrow_keys:!1},over:!1,inDrag:!1,getValue:function(){return this.options.range?this.options.value:this.options.value[0]},setValue:function(a,b){a||(a=0),this.options.value=this._validateInputValue(a);var c=this._applyPrecision.bind(this);if(this.options.range?(this.options.value[0]=c(this.options.value[0]),this.options.value[1]=c(this.options.value[1]),this.options.value[0]=Math.max(this.options.min,Math.min(this.options.max,this.options.value[0])),this.options.value[1]=Math.max(this.options.min,Math.min(this.options.max,this.options.value[1]))):(this.options.value=c(this.options.value),this.options.value=[Math.max(this.options.min,Math.min(this.options.max,this.options.value))],this._addClass(this.handle2,"hide"),this.options.value[1]="after"===this.selection?this.options.max:this.options.min),this.diff=this.options.max-this.options.min,this.percentage=this.diff>0?[100*(this.options.value[0]-this.options.min)/this.diff,100*(this.options.value[1]-this.options.min)/this.diff,100*this.options.step/this.diff]:[0,0,100],this._layout(),b===!0){var d=this.options.range?this.options.value:this.options.value[0];this._trigger("slide",d),this._setDataVal(d)}return this},destroy:function(){this._removeSliderEventHandlers(),this.sliderElem.parentNode.removeChild(this.sliderElem),this.element.style.display="",this._cleanUpEventCallbacksMap(),this.element.removeAttribute("data"),a&&(this._unbindJQueryEventHandlers(),this.$element.removeData("slider"))},disable:function(){return this.options.enabled=!1,this.handle1.removeAttribute("tabindex"),this.handle2.removeAttribute("tabindex"),this._addClass(this.sliderElem,"slider-disabled"),this._trigger("slideDisabled"),this},enable:function(){return this.options.enabled=!0,this.handle1.setAttribute("tabindex",0),this.handle2.setAttribute("tabindex",0),this._removeClass(this.sliderElem,"slider-disabled"),this._trigger("slideEnabled"),this},toggle:function(){return this.options.enabled?this.disable():this.enable(),this},isEnabled:function(){return this.options.enabled},on:function(b,c){return a?(this.$element.on(b,c),this.$sliderElem.on(b,c)):this._bindNonQueryEventHandler(b,c),this},getAttribute:function(a){return a?this.options[a]:this.options},setAttribute:function(a,b){return this.options[a]=b,this},refresh:function(){return this._removeSliderEventHandlers(),b.call(this,this.element,this.options),a&&a.data(this.element,"slider",this),this},_removeSliderEventHandlers:function(){this.handle1.removeEventListener("keydown",this.handle1Keydown,!1),this.handle1.removeEventListener("focus",this.showTooltip,!1),this.handle1.removeEventListener("blur",this.hideTooltip,!1),this.handle2.removeEventListener("keydown",this.handle2Keydown,!1),this.handle2.removeEventListener("focus",this.handle2Keydown,!1),this.handle2.removeEventListener("blur",this.handle2Keydown,!1),this.sliderElem.removeEventListener("mouseenter",this.showTooltip,!1),this.sliderElem.removeEventListener("mouseleave",this.hideTooltip,!1),this.sliderElem.removeEventListener("touchstart",this.mousedown,!1),this.sliderElem.removeEventListener("mousedown",this.mousedown,!1)},_bindNonQueryEventHandler:function(a,b){var c=this.eventToCallbackMap[a];c?c.push(b):this.eventToCallbackMap[a]=[]},_cleanUpEventCallbacksMap:function(){for(var a=Object.keys(this.eventToCallbackMap),b=0;b<a.length;b++){var c=a[b];this.eventToCallbackMap[c]=null}},_showTooltip:function(){this.options.tooltip_split===!1?this._addClass(this.tooltip,"in"):(this._addClass(this.tooltip_min,"in"),this._addClass(this.tooltip_max,"in")),this.over=!0},_hideTooltip:function(){this.inDrag===!1&&this.alwaysShowTooltip!==!0&&(this._removeClass(this.tooltip,"in"),this._removeClass(this.tooltip_min,"in"),this._removeClass(this.tooltip_max,"in")),this.over=!1},_layout:function(){var a;if(a=this.options.reversed?[100-this.percentage[0],this.percentage[1]]:[this.percentage[0],this.percentage[1]],this.handle1.style[this.stylePos]=a[0]+"%",this.handle2.style[this.stylePos]=a[1]+"%","vertical"===this.options.orientation)this.trackSelection.style.top=Math.min(a[0],a[1])+"%",this.trackSelection.style.height=Math.abs(a[0]-a[1])+"%";else{this.trackSelection.style.left=Math.min(a[0],a[1])+"%",this.trackSelection.style.width=Math.abs(a[0]-a[1])+"%";var b=this.tooltip_min.getBoundingClientRect(),c=this.tooltip_max.getBoundingClientRect();b.right>c.left?(this._removeClass(this.tooltip_max,"top"),this._addClass(this.tooltip_max,"bottom"),this.tooltip_max.style.top="18px"):(this._removeClass(this.tooltip_max,"bottom"),this._addClass(this.tooltip_max,"top"),this.tooltip_max.style.top="-30px")}var d;if(this.options.range){d=this.options.formatter(this.options.value),this._setText(this.tooltipInner,d),this.tooltip.style[this.stylePos]=(a[1]+a[0])/2+"%","vertical"===this.options.orientation?this._css(this.tooltip,"margin-top",-this.tooltip.offsetHeight/2+"px"):this._css(this.tooltip,"margin-left",-this.tooltip.offsetWidth/2+"px"),"vertical"===this.options.orientation?this._css(this.tooltip,"margin-top",-this.tooltip.offsetHeight/2+"px"):this._css(this.tooltip,"margin-left",-this.tooltip.offsetWidth/2+"px");var e=this.options.formatter(this.options.value[0]);this._setText(this.tooltipInner_min,e);var f=this.options.formatter(this.options.value[1]);this._setText(this.tooltipInner_max,f),this.tooltip_min.style[this.stylePos]=a[0]+"%","vertical"===this.options.orientation?this._css(this.tooltip_min,"margin-top",-this.tooltip_min.offsetHeight/2+"px"):this._css(this.tooltip_min,"margin-left",-this.tooltip_min.offsetWidth/2+"px"),this.tooltip_max.style[this.stylePos]=a[1]+"%","vertical"===this.options.orientation?this._css(this.tooltip_max,"margin-top",-this.tooltip_max.offsetHeight/2+"px"):this._css(this.tooltip_max,"margin-left",-this.tooltip_max.offsetWidth/2+"px")}else d=this.options.formatter(this.options.value[0]),this._setText(this.tooltipInner,d),this.tooltip.style[this.stylePos]=a[0]+"%","vertical"===this.options.orientation?this._css(this.tooltip,"margin-top",-this.tooltip.offsetHeight/2+"px"):this._css(this.tooltip,"margin-left",-this.tooltip.offsetWidth/2+"px")},_removeProperty:function(a,b){a.style.removeProperty?a.style.removeProperty(b):a.style.removeAttribute(b)},_mousedown:function(a){if(!this.options.enabled)return!1;this.touchCapable&&"touchstart"===a.type&&(a=a.originalEvent),this._triggerFocusOnHandle(),this.offset=this._offset(this.sliderElem),this.size=this.sliderElem[this.sizePos];var b=this._getPercentage(a);if(this.options.range){var c=Math.abs(this.percentage[0]-b),d=Math.abs(this.percentage[1]-b);this.dragged=d>c?0:1}else this.dragged=0;this.percentage[this.dragged]=this.options.reversed?100-b:b,this._layout(),this.mousemove=this._mousemove.bind(this),this.mouseup=this._mouseup.bind(this),this.touchCapable?(document.addEventListener("touchmove",this.mousemove,!1),document.addEventListener("touchend",this.mouseup,!1)):(document.addEventListener("mousemove",this.mousemove,!1),document.addEventListener("mouseup",this.mouseup,!1)),this.inDrag=!0;var e=this._calculateValue();return this._trigger("slideStart",e),this._setDataVal(e),this.setValue(e),this._pauseEvent(a),!0},_triggerFocusOnHandle:function(a){0===a&&this.handle1.focus(),1===a&&this.handle2.focus()},_keydown:function(a,b){if(!this.options.enabled)return!1;var c;switch(b.keyCode){case 37:case 40:c=-1;break;case 39:case 38:c=1}if(c){if(this.options.natural_arrow_keys){var d="vertical"===this.options.orientation&&!this.options.reversed,e="horizontal"===this.options.orientation&&this.options.reversed;(d||e)&&(c=-1*c)}var f=c*this.percentage[2],g=this.percentage[a]+f;g>100?g=100:0>g&&(g=0),this.dragged=a,this._adjustPercentageForRangeSliders(g),this.percentage[this.dragged]=g,this._layout();var h=this._calculateValue();return this._trigger("slideStart",h),this._setDataVal(h),this.setValue(h,!0),this._trigger("slideStop",h),this._setDataVal(h),this._pauseEvent(b),!1}},_pauseEvent:function(a){a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault(),a.cancelBubble=!0,a.returnValue=!1},_mousemove:function(a){if(!this.options.enabled)return!1;this.touchCapable&&"touchmove"===a.type&&(a=a.originalEvent);var b=this._getPercentage(a);this._adjustPercentageForRangeSliders(b),this.percentage[this.dragged]=this.options.reversed?100-b:b,this._layout();var c=this._calculateValue();return this.setValue(c,!0),!1},_adjustPercentageForRangeSliders:function(a){this.options.range&&(0===this.dragged&&this.percentage[1]<a?(this.percentage[0]=this.percentage[1],this.dragged=1):1===this.dragged&&this.percentage[0]>a&&(this.percentage[1]=this.percentage[0],this.dragged=0))},_mouseup:function(){if(!this.options.enabled)return!1;this.touchCapable?(document.removeEventListener("touchmove",this.mousemove,!1),document.removeEventListener("touchend",this.mouseup,!1)):(document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1)),this.inDrag=!1,this.over===!1&&this._hideTooltip();var a=this._calculateValue();return this._layout(),this._setDataVal(a),this._trigger("slideStop",a),!1},_calculateValue:function(){var a;return this.options.range?(a=[this.options.min,this.options.max],0!==this.percentage[0]&&(a[0]=Math.max(this.options.min,this.options.min+Math.round(this.diff*this.percentage[0]/100/this.options.step)*this.options.step),a[0]=this._applyPrecision(a[0])),100!==this.percentage[1]&&(a[1]=Math.min(this.options.max,this.options.min+Math.round(this.diff*this.percentage[1]/100/this.options.step)*this.options.step),a[1]=this._applyPrecision(a[1])),this.options.value=a):(a=this.options.min+Math.round(this.diff*this.percentage[0]/100/this.options.step)*this.options.step,a<this.options.min?a=this.options.min:a>this.options.max&&(a=this.options.max),a=parseFloat(a),a=this._applyPrecision(a),this.options.value=[a,this.options.value[1]]),a},_applyPrecision:function(a){var b=this.options.precision||this._getNumDigitsAfterDecimalPlace(this.step);return this._applyToFixedAndParseFloat(a,b)},_getNumDigitsAfterDecimalPlace:function(a){var b=(""+a).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return b?Math.max(0,(b[1]?b[1].length:0)-(b[2]?+b[2]:0)):0},_applyToFixedAndParseFloat:function(a,b){var c=a.toFixed(b);return parseFloat(c)},_getPercentage:function(a){!this.touchCapable||"touchstart"!==a.type&&"touchmove"!==a.type||(a=a.touches[0]);var b=100*(a[this.mousePos]-this.offset[this.stylePos])/this.size;return b=Math.round(b/this.percentage[2])*this.percentage[2],Math.max(0,Math.min(100,b))},_validateInputValue:function(a){if("number"==typeof a)return a;if(a instanceof Array)return this._validateArray(a),a;throw new Error(c.formatInvalidInputErrorMsg(a))},_validateArray:function(a){for(var b=0;b<a.length;b++){var d=a[b];if("number"!=typeof d)throw new Error(c.formatInvalidInputErrorMsg(d))}},_setDataVal:function(a){var b="value: '"+a+"'";this.element.setAttribute("data",b)},_trigger:function(b,c){c=c||void 0;var d=this.eventToCallbackMap[b];if(d&&d.length)for(var e=0;e<d.length;e++){var f=d[e];f(c)}a&&this._triggerJQueryEvent(b,c)},_triggerJQueryEvent:function(a,b){var c={type:a,value:b};this.$element.trigger(c),this.$sliderElem.trigger(c)},_unbindJQueryEventHandlers:function(){this.$element.off(),this.$sliderElem.off()},_setText:function(a,b){"undefined"!=typeof a.innerText?a.innerText=b:"undefined"!=typeof a.textContent&&(a.textContent=b)},_removeClass:function(a,b){for(var c=b.split(" "),d=a.className,e=0;e<c.length;e++){var f=c[e],g=new RegExp("(?:\\s|^)"+f+"(?:\\s|$)");d=d.replace(g," ")}a.className=d.trim()},_addClass:function(a,b){for(var c=b.split(" "),d=a.className,e=0;e<c.length;e++){var f=c[e],g=new RegExp("(?:\\s|^)"+f+"(?:\\s|$)"),h=g.test(d);h||(d+=" "+f)}a.className=d.trim()},_offset:function(a){var b=0,c=0;if(a.offsetParent)do b+=a.offsetLeft,c+=a.offsetTop;while(a=a.offsetParent);return{left:b,top:c}},_css:function(a,b,c){a.style[b]=c}},a){var e=a.fn.slider?"bootstrapSlider":"slider";a.bridget(e,d)}else window.Slider=d}(a)}(window.jQuery);
define("bootstrap.slider", ["jquery.bootstrap"], function(){});
 
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('env/ui-analyse',["jquery","signals","adim/config","adim/view","jquery.bootstrap","jquery.mousewheel","bootstrap.slider"],function(a,b,c,d){function e(){f=a(window),a("#mode-selector button[data-href]").click(function(b){b.preventDefault(),document.location.href=a(this).data("href")});var b=a("#analyse-graph-ctrl"),c=a("#graph-col"),e=0;g=0,h=0,f.on("scroll",function(){b.toggleClass("pinned",window.scrollY>50)}).on("resize",function(){var a=c.width();a!==e&&(e=a,d.resize(a),i.graphParamChanged.dispatch({viewWidthChanged:!0}))}).resize(),a("#page-loader").remove();var j=a("#inputGroupSize");j.keydown(function(a){var b=38===a.which?1:40===a.which?-1:0;if(b){a.preventDefault(),a.stopPropagation();var c=parseInt(j.val(),10)+b;c>0&&(j.val(c),i.graphParamChanged.dispatch({groupSize:c}))}}).change(function(){var a=parseInt(j.val(),10);a>0&&i.graphParamChanged.dispatch({groupSize:a})});var k=a("#checkShowConfidence");k.change(function(){i.graphParamChanged.dispatch({showConfidence:k.is(":checked")})});var l=a("#checkShowDiscordance");l.change(function(){i.graphParamChanged.dispatch({showDiscordance:l.is(":checked")})});var m=a("#checkShowConcordance");m.change(function(){i.graphParamChanged.dispatch({showConcordance:m.is(":checked")})});a("#inputScale").slider({selection:"none",value:100,formater:function(a){return a+"%"}}).on("slide",function(a){var b=(parseFloat(a.value)||100)/100;i.graphParamChanged.dispatch({setScale:b})})}var f=a(window),g=0,h=0,i={graphParamChanged:new b};return{init:e,events:i}});
/**
* Copyright (C) 2014 Université de Lausanne, RISET,
......@@ -24951,9 +24960,9 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export
!function(a){function b(b){if("string"==typeof b.data&&(b.data={keys:b.data}),b.data&&b.data.keys&&"string"==typeof b.data.keys){var c=b.handler,d=b.data.keys.toLowerCase().split(" ");b.handler=function(b){if(this===b.target||!(/textarea|select/i.test(b.target.nodeName)||a.hotkeys.options.filterTextInputs&&a.inArray(b.target.type,a.hotkeys.textAcceptingInputTypes)>-1)){var e="keypress"!==b.type&&a.hotkeys.specialKeys[b.which],f=String.fromCharCode(b.which).toLowerCase(),g="",h={};a.each(["alt","ctrl","shift"],function(a,c){b[c+"Key"]&&e!==c&&(g+=c+"+")}),b.metaKey&&!b.ctrlKey&&"meta"!==e&&(g+="meta+"),b.metaKey&&"meta"!==e&&g.indexOf("alt+ctrl+shift+")>-1&&(g=g.replace("alt+ctrl+shift+","hyper+")),e?h[g+e]=!0:(h[g+f]=!0,h[g+a.hotkeys.shiftNums[f]]=!0,"shift+"===g&&(h[a.hotkeys.shiftNums[f]]=!0));for(var i=0,j=d.length;j>i;i++)if(h[d[i]])return c.apply(this,arguments)}}}}a.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",10:"return",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",59:";",61:"=",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},shiftNums:{"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"},textAcceptingInputTypes:["text","password","number","email","url","range","date","month","week","time","datetime","datetime-local","search","color","tel"],options:{filterTextInputs:!0}},a.each(["keydown","keyup","keypress"],function(){a.event.special[this]={add:b}})}(jQuery||this.jQuery||window.jQuery);
define("jquery.hotkeys", ["jquery"], function(){});
 
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('env/shortcuts',["jquery","paper","signals","adim/config","adim/view","adim/tools","adim/ui","jquery.hotkeys"],function(a,b,c,d,e,f){function g(b){var c=a("#inputGroupSize");return function(){var a=parseInt(c.val(),10)+b;return a>0&&c.val(a).change(),!1}}var h,i=function(){return function(){return!1}},j={"backspace del":[{event:"keydown",ctxt:"edit",fn:function(){return e.removeSelectedItems(),!1}},{event:"keydown",ctxt:"review",fn:i()}],space:[{event:"keydown",ctxt:"edit review",fn:function(){return h||(h=f.getActiveTool(),f.activateTool("pan")),!1}},{event:"keyup",ctxt:"edit review",fn:function(){return h&&(f.activateTool(h),h=null),!1}}],"1 2 3":{ctxt:"edit",fn:function(c){return b.project.selectedItems.length>0&&a("#confidence-input").val([c.key]).change().siblings("[data-value]").trigger("mouseleave"),!1}},a:[{event:"keydown",ctxt:"edit",fn:function(){return f.activateTool("select"),!1}}],"ctrl+a meta+a":[{event:"keydown",ctxt:"edit",fn:function(){return b.project.activeLayer.children.map(function(a){a.selected=!0}),!1}},{event:"keydown",ctxt:"review",fn:i()}],c:[{event:"keydown",ctxt:"edit",fn:function(){return a("#tool-concordantstr").is(":disabled")?!1:(f.activateTool("concordantstr"),!1)}},{event:"keydown",ctxt:"analysis",fn:function(){var b=a("#checkShowConcordance");return b.val([b.is(":checked")?"off":"on"]).change(),!1}}],d:[{event:"keydown",ctxt:"edit",fn:function(){return a("#tool-discordantstr").is(":disabled")?!1:(f.activateTool("discordantstr"),!1)}},{event:"keydown",ctxt:"analysis",fn:function(){var b=a("#checkShowDiscordance");return b.val([b.is(":checked")?"off":"on"]).change(),!1}}],"shift+d shift+c":{ctxt:"edit review",fn:function(){a("#annotation-display-container").find("[data-type-name='concordantstr,discordantstr']").click()}},"e b":[{event:"keydown",ctxt:"edit",fn:function(){return a("#tool-fieldedges").is(":disabled")?!1:(f.activateTool("fieldedges"),!1)}}],"shift+e":{ctxt:"edit review",fn:function(){a("#annotation-display-container").find("[data-type-name='fieldedges']").click()}},f:[{event:"keydown",ctxt:"edit",fn:function(){return f.activateTool("arrow"),!1}}],"shift+i":{ctxt:"edit review",fn:function(){a("#annotation-display-container").find("[data-type-name='image']").click()}},n:[{event:"keydown",ctxt:"analysis",fn:function(){var b=a("#checkShowConfidence");return b.val([b.is(":checked")?"off":"on"]).change(),!1}}],t:[{event:"keydown",ctxt:"edit",fn:function(){return f.activateTool("text"),!1}}],z:[{event:"keydown",ctxt:"edit",fn:function(){return a("#tool-cmsarea").is(":disabled")?!1:(f.activateTool("cmsarea"),!1)}}],"shift+z":{ctxt:"edit review",fn:function(){a("#annotation-display-container").find("[data-type-name='cmsarea']").click()}},up:[{event:"keydown",ctxt:"analysis",fn:g(1)}],down:[{event:"keydown",ctxt:"analysis",fn:g(-1)}]};return j});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('env/env',["jquery","underscore","paper","signals","adim/config","adim/view","adim/attributes","adim/io","adim/tools","adim/ui","env/shortcuts"],function(a,b,c,d,e,f,g,h,i,j,k){function l(){function a(a){if(!(a&&["cmsarea","concordantstr"].indexOf(a.data.type)<0)&&(b||(b=f.getOrCreateUserLayer(e.user.id,e.user.full_name)),b)){var d,g,h,i,k=b.children.filter(function(a){return a.data.type&&"cmsarea"===a.data.type}),l=b.children.filter(function(a){return a.data.type&&"concordantstr"===a.data.type}),m=c.project.getSelectedItems(),n=1===m.length&&"cmsarea"===m[0].data.type?m[0]:null,o=n?n.data.prop.nbConcordances:null,p=l.length;for(h=0;d=k[h];h++){for(g=0,i=0;p>i;i++)g+=Math.round(d.getIntersections(l[i]).length/2);d.data.prop.nbConcordances=g}null!==o&&n.data.prop.nbConcordances!==o&&j.displayProperties(n)}}console.info("_initSignalRouting from env/cimaf");var b;i.events.annotationAdded.add(function(b){a(b)},this,100),i.events.annotationChanged.add(function(b){a(1===b.length?b[0]:void 0)},this,100),h.events.annotableLoaded.add(function(a){var b=i.tools.concordantstr,c=i.tools.discordantstr,d=i.tools.cmsarea,e=a.envparam&&a.envparam.cimaf_cut_pos,g=a.envparam&&a.envparam.cimaf_cut_margin;f.events.imageLoaded.add(function(a){e=e||a.raster.scaling.x*a.raster.width/2,g=g||25,b.listeners.onCutPositionChanged(e),b.listeners.onCutMarginChanged(g),c.listeners.onCutPositionChanged(e),d.listeners.onCutPositionChanged(e),d.listeners.onSetAreaWidth(2*g)})},100)}function m(){a(".adim-display-type-selector").find("button").on("click",function(b){var c=a(this),d=!c.hasClass("active"),e=c.data("typeName");b.metaKey?"image"!==e&&f.selectItemsByType(e):(c.toggleClass("active",d),"image"===e?g.setImageOpacity(d?100:0,!0):(f.toggleItemsByType(c.data("typeName"),d),j.enableTool(e,d)))})}return{name:"cimaf",shortcuts:k,initSignalRouting:l,initUI:m}});
/**
* Created by jfurrer on 02.12.13.
......
......@@ -17915,6 +17915,7 @@ define('adim/category',["underscore", "paper", "signals"], function (_, paper, S
_categories['default'] = _categories[id];
}
});
_categories['default'] = _categories['cat_2'];
}
 
/**
......@@ -17971,7 +17972,7 @@ define('tools/marker',[
var defaultProperties = {
//comment: "",
labelComment: "",
category: ""
category: "cat_2"
};
 
// Markers management related
......@@ -17999,12 +18000,17 @@ define('tools/marker',[
var curLayer = paper.project.activeLayer;
layer.activate();
 
// Keep copy of current category
var curCat = defaultProperties.category;
var marker = createMarker(itemData.origin, itemData, listening);
if (itemData.prop.category) {
_setCategory.call(marker, itemData.prop.category);
}
 
// Restore states
curLayer.activate();
defaultProperties.category = curCat;
 
return marker;
}
......@@ -18258,6 +18264,7 @@ define('tools/marker',[
var category = Category.getCategory(catId),
color = (category && category.color) || "#000000";
_setColor.call(this, color);
defaultProperties.category = catId;
}
 
 
......@@ -18431,6 +18438,7 @@ define('tools/marker',[
 
var marker = hitOnMarkerTest(event.point);
if (marker) {
debugger;
if (!marker.selected) {
paper.project.deselectAll();
marker.selected = true;
......@@ -18452,6 +18460,7 @@ define('tools/marker',[
itemMouseDown.call(marker, event);
_selectedMarker = marker;
_events.annotationSelected.dispatch(marker);
}
},
 
......@@ -27534,9 +27543,9 @@ function($){
!function(a){function b(b){if("string"==typeof b.data&&(b.data={keys:b.data}),b.data&&b.data.keys&&"string"==typeof b.data.keys){var c=b.handler,d=b.data.keys.toLowerCase().split(" ");b.handler=function(b){if(this===b.target||!(/textarea|select/i.test(b.target.nodeName)||a.hotkeys.options.filterTextInputs&&a.inArray(b.target.type,a.hotkeys.textAcceptingInputTypes)>-1)){var e="keypress"!==b.type&&a.hotkeys.specialKeys[b.which],f=String.fromCharCode(b.which).toLowerCase(),g="",h={};a.each(["alt","ctrl","shift"],function(a,c){b[c+"Key"]&&e!==c&&(g+=c+"+")}),b.metaKey&&!b.ctrlKey&&"meta"!==e&&(g+="meta+"),b.metaKey&&"meta"!==e&&g.indexOf("alt+ctrl+shift+")>-1&&(g=g.replace("alt+ctrl+shift+","hyper+")),e?h[g+e]=!0:(h[g+f]=!0,h[g+a.hotkeys.shiftNums[f]]=!0,"shift+"===g&&(h[a.hotkeys.shiftNums[f]]=!0));for(var i=0,j=d.length;j>i;i++)if(h[d[i]])return c.apply(this,arguments)}}}}a.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",10:"return",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",59:";",61:"=",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",144:"numlock",145:"scroll",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},shiftNums:{"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"},textAcceptingInputTypes:["text","password","number","email","url","range","date","month","week","time","datetime","datetime-local","search","color","tel"],options:{filterTextInputs:!0}},a.each(["keydown","keyup","keypress"],function(){a.event.special[this]={add:b}})}(jQuery||this.jQuery||window.jQuery);
define("jquery.hotkeys", ["jquery"], function(){});
 
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('env/shortcuts',["jquery","paper","signals","adim/config","adim/view","adim/tools","adim/ui","jquery.hotkeys"],function(a,b,c,d,e,f){function g(b){var c=a("#inputGroupSize");return function(){var a=parseInt(c.val(),10)+b;return a>0&&c.val(a).change(),!1}}var h,i=function(){return function(){return!1}},j={"backspace del":[{event:"keydown",ctxt:"edit",fn:function(){return e.removeSelectedItems(),!1}},{event:"keydown",ctxt:"review",fn:i()}],space:[{event:"keydown",ctxt:"edit review",fn:function(){return h||(h=f.getActiveTool(),f.activateTool("pan")),!1}},{event:"keyup",ctxt:"edit review",fn:function(){return h&&(f.activateTool(h),h=null),!1}}],"1 2 3":{ctxt:"edit",fn:function(c){return b.project.selectedItems.length>0&&a("#confidence-input").val([c.key]).change().siblings("[data-value]").trigger("mouseleave"),!1}},a:[{event:"keydown",ctxt:"edit",fn:function(){return f.activateTool("select"),!1}}],"ctrl+a meta+a":[{event:"keydown",ctxt:"edit",fn:function(){return b.project.activeLayer.children.map(function(a){a.selected=!0}),!1}},{event:"keydown",ctxt:"review",fn:i()}],c:[{event:"keydown",ctxt:"edit",fn:function(){return a("#tool-concordantstr").is(":disabled")?!1:(f.activateTool("concordantstr"),!1)}},{event:"keydown",ctxt:"analysis",fn:function(){var b=a("#checkShowConcordance");return b.val([b.is(":checked")?"off":"on"]).change(),!1}}],d:[{event:"keydown",ctxt:"edit",fn:function(){return a("#tool-discordantstr").is(":disabled")?!1:(f.activateTool("discordantstr"),!1)}},{event:"keydown",ctxt:"analysis",fn:function(){var b=a("#checkShowDiscordance");return b.val([b.is(":checked")?"off":"on"]).change(),!1}}],"shift+d shift+c":{ctxt:"edit review",fn:function(){a("#annotation-display-container").find("[data-type-name='concordantstr,discordantstr']").click()}},"e b":[{event:"keydown",ctxt:"edit",fn:function(){return a("#tool-fieldedges").is(":disabled")?!1:(f.activateTool("fieldedges"),!1)}}],"shift+e":{ctxt:"edit review",fn:function(){a("#annotation-display-container").find("[data-type-name='fieldedges']").click()}},f:[{event:"keydown",ctxt:"edit",fn:function(){return f.activateTool("arrow"),!1}}],"shift+i":{ctxt:"edit review",fn:function(){a("#annotation-display-container").find("[data-type-name='image']").click()}},n:[{event:"keydown",ctxt:"analysis",fn:function(){var b=a("#checkShowConfidence");return b.val([b.is(":checked")?"off":"on"]).change(),!1}}],t:[{event:"keydown",ctxt:"edit",fn:function(){return f.activateTool("text"),!1}}],z:[{event:"keydown",ctxt:"edit",fn:function(){return a("#tool-cmsarea").is(":disabled")?!1:(f.activateTool("cmsarea"),!1)}}],"shift+z":{ctxt:"edit review",fn:function(){a("#annotation-display-container").find("[data-type-name='cmsarea']").click()}},up:[{event:"keydown",ctxt:"analysis",fn:g(1)}],down:[{event:"keydown",ctxt:"analysis",fn:g(-1)}]};return j});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('env/env',["jquery","underscore","paper","signals","adim/config","adim/view","adim/attributes","adim/io","adim/tools","adim/ui","env/shortcuts"],function(a,b,c,d,e,f,g,h,i,j,k){function l(){function a(a){if(!(a&&["cmsarea","concordantstr"].indexOf(a.data.type)<0)&&(b||(b=f.getOrCreateUserLayer(e.user.id,e.user.full_name)),b)){var d,g,h,i,k=b.children.filter(function(a){return a.data.type&&"cmsarea"===a.data.type}),l=b.children.filter(function(a){return a.data.type&&"concordantstr"===a.data.type}),m=c.project.getSelectedItems(),n=1===m.length&&"cmsarea"===m[0].data.type?m[0]:null,o=n?n.data.prop.nbConcordances:null,p=l.length;for(h=0;d=k[h];h++){for(g=0,i=0;p>i;i++)g+=Math.round(d.getIntersections(l[i]).length/2);d.data.prop.nbConcordances=g}null!==o&&n.data.prop.nbConcordances!==o&&j.displayProperties(n)}}console.info("_initSignalRouting from env/cimaf");var b;i.events.annotationAdded.add(function(b){a(b)},this,100),i.events.annotationChanged.add(function(b){a(1===b.length?b[0]:void 0)},this,100),h.events.annotableLoaded.add(function(a){var b=i.tools.concordantstr,c=i.tools.discordantstr,d=i.tools.cmsarea,e=a.envparam&&a.envparam.cimaf_cut_pos,g=a.envparam&&a.envparam.cimaf_cut_margin;f.events.imageLoaded.add(function(a){e=e||a.raster.scaling.x*a.raster.width/2,g=g||25,b.listeners.onCutPositionChanged(e),b.listeners.onCutMarginChanged(g),c.listeners.onCutPositionChanged(e),d.listeners.onCutPositionChanged(e),d.listeners.onSetAreaWidth(2*g)})},100)}function m(){a(".adim-display-type-selector").find("button").on("click",function(b){var c=a(this),d=!c.hasClass("active"),e=c.data("typeName");b.metaKey?"image"!==e&&f.selectItemsByType(e):(c.toggleClass("active",d),"image"===e?g.setImageOpacity(d?100:0,!0):(f.toggleItemsByType(c.data("typeName"),d),j.enableTool(e,d)))})}return{name:"cimaf",shortcuts:k,initSignalRouting:l,initUI:m}});
/**
* Copyright (C) 2014 Université de Lausanne, RISET,
......@@ -12797,7 +12797,7 @@ _addBinding:function(a){var b=this._bindings.length;do--b;while(this._bindings[b
!0,b,c)},remove:function(a,b){g(a,"remove");var c=this._indexOfListener(a,b);c!==-1&&(this._bindings[c]._destroy(),this._bindings.splice(c,1));return a},removeAll:function(){for(var a=this._bindings.length;a--;)this._bindings[a]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(a){if(this.active){var b=Array.prototype.slice.call(arguments),c=this._bindings.length,d;if(this.memorize)this._prevParams=
b;if(c){d=this._bindings.slice();this._shouldPropagate=!0;do c--;while(d[c]&&this._shouldPropagate&&d[c].execute(b)!==!1)}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll();delete this._bindings;delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};var f=e;f.Signal=e;typeof define==="function"&&define.amd?define('signals',[],function(){return f}):typeof module!=="undefined"&&module.exports?module.exports=f:i.signals=
f})(this);
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('adim/config',["jquery"],function(a){var b="ADIM_CONFIG",c=a.extend(!0,{MODE_EDIT:"edit",MODE_REVIEW:"review",MODE_ANALYSIS:"analysis",adim_global_varname:"ADIM",annotable:{image:"image/",thumbnail:"thumb/"},image_url:"",autoSaveThumbnail:!0,io:{},activeTools:[],userEngine:{limit:7,remoteUrl:"http://path/to/suggestion/url/?q=%QUERY",rateLimitWait:300},aai:{slo:!1,urls:{sp_logout:"https://jabba.unil.ch/Shibboleth.sso/Logout",idp_logout:"https://aai.unil.ch/idp/logout.jsp"}},ui:{show_side_col:!0,show_users_results:!1,show_annot_properties:!0},uploadMaxFileSize:2},window[b]||{},!0);if(!c.activeTools||0==c.activeTools.length)try{c.activeTools=a("#draw-tool-tb [data-tool-name]").map(function(){return a(this).attr("data-tool-name")})}catch(d){c.activeTools=null}return c.csrfToken&&a.ajaxSetup({beforeSend:function(a){a.setRequestHeader("X-CSRFToken",c.csrfToken)}}),c});
// Underscore.js 1.8.3
// http://underscorejs.org
......@@ -13543,47 +13543,47 @@ define("bloodhound", ["jquery"], (function (global) {
};
}(this)));
 
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('adim/users',["jquery","underscore","bloodhound","adim/config"],function(a,b,c,d){function e(){i=new c({datumTokenizer:function(a){return c.tokenizers.nonword(a.username)},queryTokenizer:c.tokenizers.whitespace,limit:d.userEngine.limit,remote:{url:d.userEngine.remoteUrl,rateLimitWait:d.userEngine.rateLimitWait}}),i.initialize()}function f(b){a.isArray(b)&&b.length>=0&&i.add(b)}function g(a){var c=b.find(i.index.datums,function(b){return b.id==a});return c?c.username:""}function h(c){var d=a.Deferred(),e=b.find(i.index.datums,function(a){return a.id==c});return e?d.resolve(e.username):d.reject(),d}var i=null;return e(),{engine:i,addUsers:f,getById:g,searchById:h}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('helper/utils',["paper"],function(a){function b(a,b){b=b===!0,a&&(a.data&&a.data.selectListeners&&a.attach(a.data.selectListeners),b&&"function"==typeof a.setSelected&&a.setSelected(!0))}function c(b,c){c=c?c:a.project.getSelectedItems(),b=b===!0;for(var d,e=0;d=c[e];e++)d.data&&d.data.selectListeners&&d.detach(d.data.selectListeners),b&&(d.fullySelected=d.selected=!1)}function d(){var b=[];return a.project.getSelectedItems().map(function(a){a.parent&&a.parent.data&&a.parent.data.type&&-1===b.indexOf(a.parent)?b.push(a.parent):a.data&&a.data.type&&-1===b.indexOf(a)&&b.push(a)}),b}function e(a){g=a}function f(a){g&&$.each(g,function(b,c){$.isArray(c)||(c=[c]);for(var d=0,e=c.length;e>d;d++){var f=c[d].fn;if("function"!=typeof f)return;var g=c[d].ctxt&&c[d].ctxt.split(" "),h=c[d].event||"keydown";$(document).unbind(h,f),(!g||g.indexOf(a)>-1)&&$(document).bind(h,{keys:b},f)}})}var g=null;return{addSelectListeners:b,removeSelectListeners:c,getSelectedAnnotations:d,initShortcuts:e,setShortcutsContext:f}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/select',["paper","adim/config","helper/utils"],function(a,b,c){function d(a,b){var c=a.hitTest(b.point,p);switch(k=l=m=null,x=y=z=A=null,c.type){case"handle-in":case"handle-out":if(a.selected){var d=c.type.split("-");m=d[1],k=c.segment}break;case"segment":k=c.segment;break;case"fill":case"stroke":b.modifiers.shift||(a.data&&"function"==typeof a.data.setDragMode?a.data.setDragMode("FULL_DRAG",{item:c.item}):l=!0);break;case"bounds":var e=c.name.split("-");if(["shape","ellipse","rectangle","circle"].indexOf(c.item.type)>-1)if("center"===e[0]||"center"===e[1])a.data.setDragMode("FULL_DRAG",{item:a});else{var f="bottom"===e[0]?"top":"bottom";f+="left"===e[1]?"Right":"Left";var g=["right"===e[1]?1:-1,"bottom"===e[0]?1:-1];c.item.data.setDragMode.call(c.item,"DRAG_HANDLE",{nameStr:c.name,nameParts:e,item:c.item,fixedPt:c.item.bounds[f],resizeDir:g})}else if("arrow"===c.item.data.type&&"right"===e[1])try{c.item.data.setDragMode.call(c.item,"DRAG_HANDLE",{nameStr:c.name,nameParts:e})}catch(h){}else if("text"===c.item.data.type)if("center"===e[0]||"center"===e[1])a.data.setDragMode("FULL_DRAG",{item:a});else try{c.item.data.setDragMode.call(c.item,"DRAG_HANDLE",{item:c.item,nameStr:c.name,nameParts:e})}catch(h){}else if("lines"===c.item.data.type){for(var i,j,n,o=c.point,q=0,r=a.segments.length;r>q&&(j=o.getDistance(a.segments[q].point),(!n||i>j)&&(n=a.segments[q],i=j),0!=j);q++);n&&(k=n)}else"function"==typeof s.onMouseDown&&s.onMouseDown(b)}}function e(a){var b=a.point.subtract(k.point),c=a.lastPoint.subtract(k.point),d=b.angle-c.angle,e=!a.modifiers.option;"in"===m?(k.handleIn=b,e&&(k.handleOut.angle+=d)):(k.handleOut=b,e&&(k.handleIn.angle+=d))}function f(b){var c,d,e;c=new a.Rectangle({from:y,to:b.point}).size,b.event.shiftKey&&(e=x.bounds.size.width/x.bounds.size.height,c.height=c.width/e),d=c.subtract(x.bounds.size).multiply(z).divide(2),x.size=c,x.translate(d.width,d.height)}function g(a,b){a.data&&"function"==typeof a.data.itemMouseDrag?a.data.itemMouseDrag.call(a,b):x?f(b):m&&k.path.id===a.id?e(b):k&&k.path.id===a.id?k.point=b.point:l&&a.translate(b.delta),t=!0}function h(){}function i(a){return r=a,q=!a,a}var j,k,l,m,n="select",o={segments:!0,stroke:!0,fill:!0,tolerance:5,bounds:!1,handles:!1},p={segments:!0,stroke:!0,fill:!0,tolerance:5,bounds:!0,handles:!0},q=b.mode===b.MODE_EDIT,r=!q,s=null,t=!1,u={annotationAdded:null,annotationChanged:null,annotationSelected:null},v=null,w=[],x=null,y=null,z=[1,1],A=null,B={tolerance:7,fill:!0,stroke:!0,segments:!0,handles:!0,ends:!0,bounds:!0,selected:!0},C={onMouseDown:function(b){k=l=m=x=y=null;var e=r?a.project.hitTest(b.point,o):a.project.activeLayer.hitTest(b.point,B);if(e||(e=r?a.project.hitTest(b.point,o):a.project.activeLayer.hitTest(b.point,o)),!q)return a.project.deselectAll(),u.annotationSelected.dispatch(null),a.view.draw(),void(e&&"pixel"!==e.type&&(s=e&&e.item,s&&s.parent.data.type&&(s=s.parent),s.data.type&&(s.selected=!0),u.annotationSelected.dispatch(s)));var f=c.getSelectedAnnotations();if(1===f.length&&(!e||"pixel"===e.type||e.item.id!==f[0].id)){var g=a.project.activeLayer.hitTest(b.point,p);g&&g.item===f[0]&&(e=g)}var h=b.modifiers.shift&&q;if(s=e&&e.item,s&&s.parent&&s.parent.data&&s.parent.data.type&&(s=s.parent),s&&(s.selected||h)||(a.project.deselectAll(),u.annotationSelected.dispatch(null)),s){if(s.layer&&"image"===s.layer.name)return;s.selected?(t=!1,h&&"bounds"!==e.type?s.fullySelected=!1:s.responds("mousedown")&&"bounds"!==e.type?s.onMouseDown(b):d(s,b)):("group"===s.type?"function"==typeof s.oSetSelected?!s.selected&&s.oSetSelected(!0):s.children.map(function(a){a.selected=!0}):-1===["handle-in","handle-out"].indexOf(e.type)&&(s.selected=!0,s.responds("mousedown")&&s.onMouseDown(b)),q&&s.selected&&"path"===s.type),u.annotationSelected.dispatch(s)}w=c.getSelectedAnnotations()},onMouseDrag:function(a){if(q){var b=w;if(1===b.length)s.responds("mousedrag")||g(s,a);else{t=!0;for(var c,d=0;c=b[d];d++)c.parent&&c.parent.data&&c.parent.data.type&&(c=c.parent),c.data.type&&(c===s&&c.responds("mousedrag")||c.translate(a.delta)),c=null}}},onMouseUp:function(b){v&&(v.remove(),v=null);var c=[];a.project.getSelectedItems().map(function(a){-1===c.indexOf(a)&&(a.data.type?c.push(a):a.parent.data.type&&-1===c.indexOf(a.parent)&&c.push(a.parent))}),q&&(s&&1===c.length&&(s.responds("mouseup")?s.onMouseUp(b):h(s,b)),t&&(u.annotationChanged.dispatch(c),t=!1))},onKeyDown:function(b){var c=a.project.getSelectedItems();if(q)for(var d,e=0;d=c[e];e++)if(d.data.type&&"function"==typeof d.onKeyDown){d.onKeyDown(b);break}},onKeyUp:function(b){var c=a.project.getSelectedItems();if(q)for(var d,e=0;d=c[e];e++)if(d.data.type&&"function"==typeof d.onKeyUp){d.onKeyUp(b);break}}};return j=new a.Tool(C),{name:n,tool:j,setRo:i,registerEvent:function(a,b){u[a]=b},_tools:null}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/pan',["paper"],function(a){var b={onMouseDrag:function(b){var c=b.point.subtract(b.downPoint).multiply(-1);a.project.view.scrollBy(c),a.project.view.draw()},onMouseDown:function(){jQuery(a.view.element).addClass("cursor-tool-pan-down")},onMouseUp:function(){jQuery(a.view.element).removeClass("cursor-tool-pan-down")}};return{name:"pan",tool:new a.Tool(b)}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/drawing',["paper"],function(a){function b(b){b.data.prop="object"==typeof b.data.prop?b.data.prop:{};for(var d in k)b.data.prop.hasOwnProperty(d)||(b.data.prop[d]=k[d]);b.onPropertyChange=c,b.onDoubleClick=function(){i||(this.selected=!1,this.fullySelected=!0,a.view.draw())}}function c(b,c){"fill"===b&&(this.closed=c,a.view.draw())}function d(a){var b=this.selected,c=this.fullySelected;this.selected=this.fullySelected=!1;var d=this.exportJSON({asString:!1});return delete d[1].fontFamily,delete d[1].font,delete d[1].fontSize,delete d[1].leading,d=a&&a.asString===!1?d:JSON.stringify(d),this.fullySelected=c,this.selected=b,d}function e(a,c){var d=c.importJSON(a);return b(d),d}function f(a){return a!==i&&(i=a),i}var g="drawing",h=null,i=!1,j={annotationAdded:null,annotationSelected:null},k={comment:"",confidence:3,fill:!1},l={onMouseDown:function(b){a.project.deselectAll(),h=new a.Path({fillColor:null,strokeCap:"round"}),h.add(b.point)},minDistance:5,onMouseDrag:function(a){h&&h.add(a.point)},onMouseUp:function(){if(h){h.simplify(20);var c=h.clone();h.remove(),h=null,c.data.type=g,c.data.tId="a"+c._id,b(c),a.view.draw(),c.fullySelected=!0,"function"==typeof j.annotationSelected.dispatch&&j.annotationSelected.dispatch(c),"function"==typeof j.annotationAdded.dispatch&&j.annotationAdded.dispatch(c)}}};return{name:g,tool:new a.Tool(l),setRo:f,registerEvent:function(a,b){j[a]=b},exportJSON:d,importJSON:e}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/lines',["paper"],function(a){function b(a){var b=this.exportJSON({asString:!1});return 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(a,b){var c=b.importJSON(a);return d(c),c}function d(a){a.data.prop="object"==typeof a.data.prop?a.data.prop:{};for(var b in p)a.data.prop.hasOwnProperty(b)||(a.data.prop[b]=p[b]);a.onPropertyChange=e}function e(b,c){"confidence"===b?(this.style=q[c],a.view.draw()):"processus"===b||"fill"===b&&(this.closed=c,a.view.draw())}function f(){if(n=null,k&&k.remove(),i=!1,h.length>l){var b=h.clone();b.style=a.project.currentStyle,b.strokeCap="round",b.strokeJoin="round",b.fillColor=null,b.data.type=g,b.data.tId="a"+b._id,d(b),b.selected=!0,"function"==typeof o.annotationSelected.dispatch&&o.annotationSelected.dispatch(b),"function"==typeof o.annotationAdded.dispatch&&o.annotationAdded.dispatch(b)}h.remove()}var g="lines",h=null,i=!1,j=!1,k=null,l=5,m=!1,n=null,o={annotationAdded:null,annotationChanged:null},p={comment:"",confidence:3,fill:!1},q={1:{dashArray:[10,10]},2:{dashArray:[30,10]},3:{dashArray:null}},r={segments:!0,stroke:!0,tolerance:5},s={onMouseDown:function(b){if(i){if(h){if(b.point.subtract(b.lastPoint).length<l)return void f();k&&k.remove(),h.add(b.point)}}else{var c=a.project.activeLayer.hitTest(b.point,r);if(c&&c.item&&c.item.selected&&c.item.data.type===g)if(h=c.item,"stroke"===c.type){var d=c.location;k=h.insert(d.index+1,b.point),j=!0}else"segment"===c.type&&(b.modifiers.option?(c.segment.remove(),o.annotationChanged.dispatch(c.item)):(k=c.segment,j=!0));else a.project.deselectAll(),h=new a.Path({strokeColor:a.project.currentStyle.strokeColor||a.project.currentStyle.fillColor,fillColor:null,strokeCap:"round",strokeJoin:"round"}),i=!0,h.add(b.point)}},onMouseMove:function(b){i?(n=b.point,k&&k.remove(),k=new a.Path(b.downPoint,b.point),k.strokeColor=a.project.currentStyle.strokeColor||a.project.currentStyle.fillColor):j&&k&&(m=!0,k.point=b.point)},onMouseUp:function(){j&&(j=!1,k&&(m&&(m=!1,o.annotationChanged.dispatch(k.path)),k=null))},onKeyDown:function(a){switch(a.key){case"enter":i&&h&&(n&&h.add(n),f());break;case"escape":i&&h&&f()}}};return{name:g,tool:new a.Tool(s),registerEvent:function(a,b){o[a]=b},exportJSON:b,importJSON:c}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/Shape.class',["paper"],function(){return function(a,b){function c(a){var b=this.exportJSON({asString:!1});return delete b[1].fontFamily,delete b[1].font,delete b[1].fontSize,delete b[1].leading,a&&a.asString?JSON.stringify(b):b}function d(a,b){var c=b.importJSON(a);return h(c),c}function e(a){var b=["ellipse","rectangle"];return!!a&&a.data&&a.data.type&&b.indexOf(a.data.type)>-1}function f(b,c){var d;if(b.modifiers.shift)var e=o.subtract(p).length/1.414213,f=p.subtract(o).quadrant,g=2===f||3===f?-e:e,h=3===f||4===f?-e:e;switch(a){case"circle":d=new paper.Shape.Circle({center:o,radius:o.subtract(p).length});break;case"ellipse":d=new paper.Shape.Ellipse(b.modifiers.shift?{point:o,size:[g,h]}:{from:o,to:p});break;case"rectangle":d=new paper.Shape.Rectangle(b.modifiers.shift?{point:o,size:[g,h]}:{from:o,to:p})}return d.data.type=a,c&&d.set("style",c),d}function g(a){n&&n.remove(),q&&(n=f(a))}function h(a){a.data.prop="object"==typeof a.data.prop?a.data.prop:{};for(var b in v)a.data.prop.hasOwnProperty(b)||(a.data.prop[b]=v[b]);a.onPropertyChange=i,a.data.exportJSON=function(a){return function(b){return c.call(a,b)}}(a),a.data.setDragMode=l,a.data.itemMouseDrag=m}function i(a,b){"confidence"===a&&(this.style=w[b],paper.view.draw())}function j(a){var c,d;if(c=paper.project.activeLayer.hitTest(a,{tolerance:7,fill:!0,stroke:!0,bounds:!0,selected:!0}),c||(c=paper.project.activeLayer.hitTest(a,{fill:!0,stroke:!0})),!c||!e(c.item))return!1;if(d=c.item,d.selected||(paper.project.deselectAll(),d.selected=!0,b.annotationSelected.dispatch(d)),"bounds"===c.type&&"center"!==c.name.split("-")[1]){var f=c.name.split("-"),g="bottom"===f[0]?"top":"bottom";g+="left"===f[1]?"Right":"Left";var h=["right"===f[1]?1:-1,"bottom"===f[0]?1:-1];l("DRAG_HANDLE",{nameStr:c.name,nameParts:f,item:c.item,fixedPt:c.item.bounds[g],resizeDir:h})}else l("FULL_DRAG",{item:d});return!0}function k(a){var b,c,d;b=new paper.Rectangle({from:s.fixedPt,to:a.point}).size,a.event.shiftKey&&(d=s.item.bounds.size.width/s.item.bounds.size.height,b.height=b.width/d),c=b.subtract(s.item.bounds.size).multiply(s.resizeDir).divide(2),s.item.size=b,s.item.translate(c.width,c.height)}function l(a,b){!a in u?(r=null,s={},t=!1):(r=u[a],s=b)}function m(a){switch(t=!0,r){case u.FULL_DRAG:this.translate(a.delta);break;case u.DRAG_HANDLE:k(a)}}var n,o,p,q=!1,r=null,s={},t=!1,u={FULL_DRAG:1,DRAG_HANDLE:4},v={comment:"",confidence:3,fill:!0},w={1:{dashArray:[10,10]},2:{dashArray:[30,10]},3:{dashArray:null}};return{exportJSON:c,importJSON:d,onKeyDown:function(a){n&&g(a)},onKeyUp:function(a){g(a)},onMouseDown:function(a){q=t=!1,j(a.point)||(paper.project.deselectAll(),b.annotationSelected.dispatch(null),paper.project.deselectAll(),q=!0,o=a.point,p=o)},onMouseDrag:function(a){q?(p=a.point,g(a)):r&&s.item&&m.call(s.item,a)},onMouseUp:function(a){if(q){if(p=a.point,g(a),q=!1,n&&n.remove(),n=null,a.delta.length>5){var c=f(a);c.data.tId="a"+c._id,c.selected=!0,h(c),b&&"function"==typeof b.annotationAdded.dispatch&&b.annotationAdded.dispatch(c)}paper.view.draw()}else t&&s.item&&(b.annotationChanged.dispatch(s.item),t=!1)}}}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/ellipse',["paper","tools/Shape.class"],function(a,b){var c="ellipse",d={annotationAdded:null},e=new b(c,d),f=e.exportJSON;delete e.exportJSON;var g=e.importJSON;return delete e.importJSON,{name:c,tool:new a.Tool(e),exportJSON:f,importJSON:g,registerEvent:function(a,b){d[a]=b}}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/rectangle',["paper","tools/Shape.class"],function(a,b){var c="rectangle",d={annotationAdded:null,annotationSelected:null,annotationChanged:null},e=new b(c,d),f=e.exportJSON;delete e.exportJSON;var g=e.importJSON;return delete e.importJSON,{name:c,tool:new a.Tool(e),exportJSON:f,importJSON:g,registerEvent:function(a,b){d[a]=b}}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/text',["paper","jquery"],function(a,b){function c(a,b){!a in w?(x=null,y={},z=!1):(x=w[a],y=b)}function d(a){switch(x){case w.DRAG_HANDLE:if("center"===y.nameParts[1])return;var b=y.item.bounds,c="top"===y.nameParts[0]?b.bottom-a.point.y:a.point.y-b.top,d=c/1.2,e=[0,0];"bottom"===y.nameParts[0]&&(e[1]=c-b.height),d>9&&999>d&&i.call(y.item,d),y.item.translate(e);break;case w.FULL_DRAG:default:this.translate(a.delta)}}function e(a){a.oGetSelected=function(){return this.children[1].selected},a.oSetSelected=function(a){this.children[1].selected=a},a.data.setDragMode=c,a.data.itemMouseDrag=d}function f(c){if(o&&g(!1),!s){o=!0,q||(q=b("<input>",{type:"text","class":"text-tool-input",placeholder:"Votre texte",maxlength:128,size:128,style:"display:none;position:absolute;top:0;left:0;padding:10px;border:0;border-radius:5px;background:rgba(255,255,255,0.75);"}).appendTo(a.project.view.element.parentNode).on("blur",function(){o&&g()}).on("keydown",function(a){(27===a.which||13==a.which)&&g()}).autoGrowInput(),r=r||b("<div>").css({zIndex:999,position:"fixed",display:"none",top:"-10px",left:"-10px",width:"5000px",height:"5000px"}).click(function(){g()}),q.before(r)),c.selected=!1,c.visible=!1;var d=c.children[1].point;d=d.subtract(a.view.bounds.point).multiply(a.view.zoom);var e=c.fontSize*a.view.zoom;q.val(c.data.content).css({fontSize:e+"px",fontFamily:c.font,color:c.data.color,top:d.y-e+1-10,left:d.x-1-10,zIndex:1e3}).show(),r.show();var f=q.nextAll("tester");f.css({fontSize:q.css("fontSize"),fontFamily:q.css("fontFamily"),fontWeight:q.css("fontWeight"),letterSpacing:q.css("letterSpacing")}),f.text(""===c.data.content?q.attr("placeholder"):c.data.content),q.width(f.width()+30),p=c,setTimeout(function(){q.focus()},100)}}function g(b){if(b=!(b===!1),o=!1,p){var c=q.val();if(c&&""!==c){var d=""===p.data.content;p.data.content=c,p.children[0].content=c,p.children[1].content=c,p.visible=!0,b&&t.annotationSelected&&"function"==typeof t.annotationSelected.dispatch&&t.annotationSelected.dispatch(p),d?(e(p),t.annotationAdded&&"function"==typeof t.annotationAdded.dispatch&&t.annotationAdded.dispatch(p)):t.annotationChanged&&"function"==typeof t.annotationChanged.dispatch&&t.annotationChanged.dispatch(p),p.oSetSelected(b),a.project.view.draw()}else p.remove(),p=null}r.hide(),q.val("").blur().hide()}function h(a){var b=this,c=b.children[1].fillColor!==a;return b.children[1].fillColor=a,b.data.color=a,c}function i(a){var b=this,c=a/10;3>c&&(c=3),b.children[0].fontSize=a,b.children[0].strokeWidth=c,b.children[1].fontSize=a}function j(){return this.children[0].fontSize}function k(a,c,d){var g=c.importJSON(a);return b.extend(g.data,{setColor:h,setFill:v,setStrokeWidth:v,setFontSize:i,getFontSize:j}),e(g),d&&g.children[1].on("doubleclick",function(){f(this.parent)}),g}function l(a){var c=this.selected;this.selected=!1;var d=this.exportJSON({asString:!1});return b.each(d[1].children,function(a,b){delete b[1].leading}),d=a&&a.asString===!1?d:JSON.stringify(d),c&&(this.selected=c),d}function m(a){return a!==s&&(s=a),s}var n="text",o=!1,p=null,q=null,r=null,s=!1,t={annotationAdded:null,annotationChanged:null,annotationSelected:null},u={type:"point-text",tolerance:5,fill:!0},v=function(){},w={FULL_DRAG:1,DRAG_HANDLE:4},x=null,y={},z=!1,A={onMouseDown:function(b){if(!s){var c=a.project.activeLayer.hitTest(b.point,u);if(c){var d=c.item.parent;f(d)}else{var e=a.project.currentStyle.fontSize;if(o)g();else{a.project.deselectAll();var k=b.point,l=new a.PointText({point:k,fillColor:"white",strokeColor:"white",strokeWidth:e/6,strokeJoin:"round",content:""}),m=a.project.currentStyle.strokeColor||a.project.currentStyle.fillColor;m=m.toCSS();var q=new a.PointText({point:k,fillColor:m,strokeColor:m,strokeWidth:0,content:""});q.on("doubleclick",function(){f(this.parent)}),p=new a.Group({children:[l,q],data:{type:n,setColor:h,setFill:v,setStrokeWidth:v,setFontSize:i,getFontSize:j,content:"",color:m}}),p.data.tId="a"+p._id,p.data.content="",f(p)}}}}};return{name:n,tool:new a.Tool(A),setRo:m,exportJSON:l,importJSON:k,registerEvent:function(a,b){t[a]=b}}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/arrow',["paper"],function(a){function b(a){var b=(this.data.from,this.data.to,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(c){console.error(c)}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,e=b.globalToLocal(a).x;return(e-c)/(d-c)>.1}function f(a,b){b=b||this,a=a||b.symbol.definition.segments[B].point.x-b.symbol.definition.segments[z].point.x;var c=b.symbol.definition.segments[B].point.x-b.symbol.definition.segments[A].point.x;return C>a-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},c!==!1&&(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=null,K={},L=!1):(J=I[a],K=b)}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(){this.detach("mousedrag",r),h.call(this),J=null,L&&F.annotationChanged.dispatch(this),L=!1}function t(){}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),!d)return!1;if(d.selected=!0,"bounds"===c.type){var e=c.name.split("-");"right"===e[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){if(!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(){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 - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/fieldedges',["paper"],function(a){function b(b,f){b.style="object"==typeof b.style?b.style:{};for(var g in L)b.style.hasOwnProperty(g)||(b.style[g]=L[g]);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 h=new a.Group({children:[b.firstEdge,b.secondEdge],style:b.style});b.prop="object"==typeof b.prop?b.prop:{};for(var g in H)b.prop.hasOwnProperty(g)||(b.prop[g]=H[g]);var i=[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 h.data={tId:"a"+h._id,type:B,prop:b.prop,points:i,itemMouseDrag:d},f||(h.onMouseDown=function(b){this.oGetSelected()?c(b):(a.project.deselectAll(),this.oSetSelected(!0),F.annotationSelected.dispatch(this))},h.oGetSelected=function(){for(var a,b=0;a=this.children[b];b++)if(!a.selected)return!1;return!0},h.oSetSelected=function(a){this.children.map(function(b){b.selected=a})},h.onMouseUp=e),F.annotationAdded.dispatch(h),h}function c(a){(J===I.DONE||J===I.CREATED_BOTH)&&o(a)}function d(a){J===I.EDITING&&k(a)}function e(a){J===I.EDITING&&p(a)}function f(a){var b=this.exportJSON({asString:!1});b[1].data.points=[s,t,u,v].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&&a.asString===!1?b:JSON.stringify(b)}function g(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(i){}var k=a.project.activeLayer;d.activate();var l=b({p1s:g[0],p1e:g[1],p2s:g[2],p2e:g[3],style:h,prop:f.data.prop});return e&&(w=l.children[0],x=l.children[1],j(),J=I.CREATED_BOTH),k.activate(),l}function h(){s=t=u=v=A=null,w&&w.remove(),x&&x.remove(),w=x=null}function i(){switch(J){case I.READY:break;case I.CREATE_FIRST:w&&w.remove(),w=new a.Path.Line({from:s,to:t}),w.style=K;break;case I.CREATE_SECOND:w&&w.remove(),w=new a.Path.Line({from:s,to:t}),w.style=L,x&&x.remove(),x=new a.Path.Line({from:u,to:v}),x.style=K;break;case I.CREATED_BOTH:}}function j(){s=w.segments[0].point,t=w.segments[1].point,u=x.segments[0].point,v=x.segments[1].point,A=u.subtract(s)}function k(a){if(y)if(isNaN(parseInt(z,2)))y.translate(a.delta);else{var b=y===w,c=b?x:w,d=b?a.point.add(A):a.point.subtract(A);y.insert(z,a.point),y.segments[z+1].remove(),c.insert(z,d),c.segments[z+1].remove()}}function l(a){s=t=a.point,J=I.CREATE_FIRST}function m(){u=s,v=t,J=I.CREATE_SECOND}function n(){J=I.CREATED_BOTH,A=u.subtract(s);var a=b({p1s:s,p1e:t,p2s:u,p2e:v});w&&w.remove(),w=a.children[0],x&&x.remove(),x=a.children[1],j()}function o(b){J=I.EDITING,y=z=null;var c=a.project.activeLayer.hitTest(b.point,E);c&&"pixel"!==c.type&&(c.item===w?y=w:c.item===x&&(y=x),a.project.deselectAll(),y.selected=!0,F.annotationSelected.dispatch(y),y&&"segment"===c.type&&(z=y.segments[0]===c.segment?0:1))}function p(){J=I.DONE;var a=y?y.parent:null;y=z=null,j(),a&&F.annotationChanged.dispatch(a)}function q(a){G&&(w.strokeWidth=a,x.strokeWidth=a,D=a)}function r(a){G=a===B}var s,t,u,v,w,x,y,z,A,B="fieldedges",C=new a.Color("#E100FF"),D=3,E={segments:!0,stroke:!0,fill:!1,tolerance:5,bounds:!1,handles:!0},F={annotationAdded:null,annotationSelected:null,annotationChanged:null},G=!1,H={comment:""},I={READY:1,CREATE_FIRST:2,CREATE_SECOND:3,CREATED_BOTH:4,EDITING:5,DONE:6},J=I.READY,K={strokeWidth:D,strokeColor:C,dashArray:[9,4]},L={strokeWidth:D,strokeColor:C},M={onMouseDown:function(a){switch(J){case I.READY:h(),l(a);break;case I.CREATE_FIRST:m(a);break;case I.CREATE_SECOND:n(a);break;case I.CREATED_BOTH:case I.DONE:o(a)}i(a)},onMouseMove:function(a){switch(J){case I.CREATE_FIRST:t=a.point,i(a);break;case I.CREATE_SECOND:v=a.point,u=s.add(v.subtract(t)),i(a);break;case I.EDITING:k(a)}},onMouseUp:function(a){switch(J){case I.EDITING:p(a)}}};return{name:B,tool:new a.Tool(M),registerEvent:function(a,b){F[a]=b},exportJSON:f,importJSON:g,listeners:{onStrokeWidthChanged:q,onToolActivated:r}}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 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){var d=b[1],e=a.project.activeLayer;c.activate();var f=g({from:d.segments[0],to:d.segments[1],strokeWidth:d.strokeWidth,prop:d.data.prop},{not_interactive:!0});return e.activate(),f}function d(a){y=a}function e(a){z=Math.floor(1.5*a)}function f(a){x=a===v}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 N)b.prop.hasOwnProperty(e)||(b.prop[e]=N[e]);return d.style=B[b.prop.confidence],parseInt(b.strokeWidth,10)&&(d.strokeWidth=b.strokeWidth),d.data={tId:"a"+d._id,type:v,prop:b.prop,itemMouseDrag:i,itemMouseUp:j},c&&c.not_interactive||(d.selected=!0,w.annotationSelected.dispatch(d)),d.onMouseDown=h,d.onKeyDown=k,d.onKeyUp=l,d.onPropertyChange=m,d}function h(b){var c=this;H=this;var d=c.hitTest(b.point,C);c.layer.activate(),a.project.deselectAll(),c.selected=!0,w.annotationSelected.dispatch(c),I=K=L=J=null,"segment"===d.type?(I=d.segment.index,J=y+(H.segments[1-I].point.x<y?1:-1)*z):(K=H.getFirstSegment().point.x<y?0:1,L=1-K),M=!1,w.annotationSelected.dispatch(c)}function i(a){a.tool&&(null!==I?s(a):H&&H.segments[K].point.x+a.delta.x<=y-z&&H.segments[L].point.x+a.delta.x>=y+z&&(H.translate(a.delta),M=!0))}function j(a){a.tool&&(H&&M&&(w.annotationChanged.dispatch([H]),M=!1),I=K=L=H=J=null)}function k(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),H=this,this.translate(c),M=!0,a.view.draw())}function l(a){switch(a.key){case"up":case"down":M&&(w.annotationChanged.dispatch([H]),M=!1)}}function m(b,c){"confidence"===b&&(this.style=B[c],a.view.draw())}function n(a,b){return a.x<=y&&b.x>=y+z||a.x>=y&&b.x<=y-z}function o(){F&&F.remove(),E=null,D=!1}function p(){var a=F?F.segments[1].point.clone():null;if(n(E,a)){F&&(F.remove(),F=null);var b=g({from:E,to:a});w.annotationAdded.dispatch(b),E=null,D=!1}}function q(b,c,d){d?u&&(b.segments[c].point.y=u.y,a.view.draw()):(u=b.segments[c].point.clone(),b.segments[c].point.y=b.segments[1-c].point.y)}function r(b){F?(F.segments[1].point=b.point,b.event.shiftKey&&q(F,1)):(F=new a.Path.Line({from:E,to:b.point}),F.style=A,F.dashArray=[10,5]),F.opacity=n(E,b.point)?1:.5,F.dashArray=n(E,b.point)?null:[10,5]}function s(a){var b=a.point.clone();n(H.segments[1-I].point,b)||(b.x=J),H.segments[I].point=b,a.event.shiftKey&&q(H,I),M=!0}var t,u,v="concordantstr",w={annotationAdded:null,annotationSelected:null},x=!1,y=0,z=10,A={strokeWidth:3,strokeColor:"red"},B={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}},C={segments:!0,stroke:!0,fill:!1,tolerance:5,bounds:!1,handles:!0},D=!0,E=null,F=null,G=!1,H=null,I=null,J=null,K=null,L=null,M=!1,N={confidence:3,comment:""},O={onMouseDown:function(b){if(E)F&&!G&&p();else{var c=a.project.activeLayer.hitTest(b.point,C);c?c.item.onMouseDown(b):(a.project.deselectAll(),w.annotationSelected.dispatch(null),E||(I=H=null,D=!0,F&&F.remove(),F=null,E=b.point,G=!1))}},onMouseDrag:function(a){D&&E&&(G=!0,r(a)),H&&H.data.itemMouseDrag(a)},onMouseMove:function(a){D&&E&&r(a)},onMouseUp:function(a){E?F&&G&&(r(a),p()):H&&H.data.itemMouseUp(a),I=H=null},onKeyDown:function(b){switch(b.key){case"enter":D&&p();break;case"escape":D&&o();break;case"shift":F?q(F,1):H&&null!==I&&q(H,I);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":F?q(F,1,!0):H&&I&&q(H,I,!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 t=new a.Tool(O),{name:v,tool:t,registerEvent:function(a,b){w[a]=b},exportJSON:b,importJSON:c,listeners:{onCutPositionChanged:d,onCutMarginChanged:e,onToolActivated:f}}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/discordantstr',["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){var d=b[1],e=a.project.activeLayer;c.activate();var g=f({from:d.segments[0],to:d.segments[1],strokeWidth:d.strokeWidth,prop:d.data.prop},{not_interactive:!0});return e.activate(),g}function d(a){w=a}function e(a){v=a===t}function f(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 I)b.prop.hasOwnProperty(e)||(b.prop[e]=I[e]);return d.style=x[b.prop.confidence],parseInt(b.strokeWidth,10)&&(d.strokeWidth=b.strokeWidth),d.data={tId:"a"+d._id,type:t,prop:b.prop,itemMouseDrag:h,itemMouseUp:i},c&&c.not_interactive||(d.selected=!0,u.annotationSelected.dispatch(d)),d.onMouseDown=g,d.onKeyDown=j,d.onKeyUp=k,d.onPropertyChange=l,d}function g(b){var c=this;D=this;var d=c.hitTest(b.point,y);if(c.layer.activate(),a.project.deselectAll(),c.selected=!0,u.annotationSelected.dispatch(c),E=F=G=null,"segment"===d.type)E=d.segment.index;else{var e=D.getFirstSegment(),f=D.getLastSegment();F=e.point.x-f.point.x<0?1:0,G=e.point.x>w||f.point.x>w,G&&(F=1-F)}H=!1,u.annotationSelected.dispatch(c)}function h(a){if(a.tool)if(null!==E)r(a);else if(D){var b=D.segments[F].point.x+a.delta.x-w;(G?b>=0:0>=b)&&D.translate(a.delta),H=!0}}function i(a){a.tool&&(D&&H&&(u.annotationChanged.dispatch([D]),H=!1),E=D=F=G=null)}function j(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),D=this,this.translate(c),H=!0,a.view.draw())}function k(a){switch(a.key){case"up":case"down":H&&(u.annotationChanged.dispatch([D]),H=!1)}}function l(b,c){"confidence"===b&&(this.style=x[c],a.view.draw())}function m(a,b){return a.x<=w&&b.x<=w||a.x>=w&&b.x>=w}function n(){B&&B.remove(),A=null,z=!1}function o(){var a=B?B.segments[1].point.clone():null;B&&(m(A,a)||(a.x=w),B.remove(),B=null),B&&B.remove();var b=f({from:A,to:a});u.annotationAdded.dispatch(b),A=null,z=!1}function p(b,c,d){d?s&&(b.segments[c].point.y=s.y,a.view.draw()):(s=b.segments[c].point.clone(),b.segments[c].point.y=b.segments[1-c].point.y)}function q(b){var c=b.point.clone();B?(m(A,b.point)||(c.x=w),B.segments[1].point=c,b.event.shiftKey&&p(B,1)):(B=new a.Path.Line({from:A,to:c}),B.style=x[3],b.event.shiftKey&&p(B,1))}function r(a){var b=a.point.clone();m(D.segments[1-E].point,a.point)||(b.x=w),D.segments[E].point=b,a.event.shiftKey&&p(D,E),H=!0}var s,t="discordantstr",u={annotationAdded:null,annotationSelected:null},v=!1,w=0,x={1:{strokeColor:new a.Color("#2057FF"),dashArray:[10,10]},2:{strokeColor:new a.Color("#2057FF"),dashArray:[30,10]},3:{strokeColor:new a.Color("#2057FF"),dashArray:null}},y={segments:!0,stroke:!0,fill:!1,tolerance:5,bounds:!1,handles:!0},z=!0,A=null,B=null,C=!1,D=null,E=null,F=null,G=null,H=!1,I={confidence:3,comment:""},J={onMouseDown:function(b){if(A)B&&!C&&o();else{var c=a.project.activeLayer.hitTest(b.point,y);c?c.item.onMouseDown(b):(a.project.deselectAll(),u.annotationSelected.dispatch(null),A||(z=!0,A=b.point,C=!1))}},onMouseDrag:function(a){z&&A&&(C=!0,q(a)),D&&D.data.itemMouseDrag(a)},onMouseMove:function(a){z&&A&&q(a)},onMouseUp:function(a){A?B&&C&&(q(a),o()):D&&D.data.itemMouseUp(a),E=D=null},onKeyDown:function(b){switch(b.key){case"enter":z&&o();break;case"escape":z&&n();break;case"shift":B?p(B,1):D&&null!==E&&p(D,E);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":B?p(B,1,!0):D&&E&&p(D,E,!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{name:t,tool:new a.Tool(J),registerEvent:function(a,b){u[a]=b},exportJSON:b,importJSON:c,listeners:{onCutPositionChanged:d,onToolActivated:e}}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/cmsarea',["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){var d=b[1],e=a.project.activeLayer;c.activate();var f=g({from:d.segments[0][1],to:d.segments[2][1],prop:d.data.prop});return e.activate(),f}function d(a){u=a}function e(a){v=a,w=v/2}function f(a){t=a===r}function g(b,c){var d=new a.Path({segments:[[u-w,b.from],[u+w,b.from],[u+w,b.to],[u-w,b.to]],closed:!0,style:x});b.prop="object"==typeof b.prop?b.prop:{};for(var e in H)b.prop.hasOwnProperty(e)||(b.prop[e]=H[e]);return d.data={tId:"a"+d._id,type:r,prop:b.prop,setStrokeWidth:z,itemMouseDrag:i,itemMouseUp:j},c!==!0&&(d.onMouseDown=h,d.onKeyDown=k,d.onKeyUp=l),d}function h(b){F=null;var c=this;return c.layer.activate(),a.project.deselectAll(),c.selected=!0,s.annotationSelected.dispatch(c),E=c,F=b.point.y-E.segments[0].point.y<=w?"up":E.segments[2].point.y-b.point.y<=w?"down":null,!1}function i(a){null!==F?p(a):E&&q(a)}function j(){E&&G&&(s.annotationChanged.dispatch([E]),G=!1)}function k(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),E=this,this.translate(c),G=!0,a.view.draw())}function l(a){switch(a.key){case"up":case"down":G&&(s.annotationChanged.dispatch([E]),G=!1)}}function m(){C&&C.remove(),B=null,A=!1,G=!1}function n(){var a=C?C.segments[3].point.clone():null;C&&(C.remove(),C=null);var b=g({from:B.y,to:a.y});s.annotationAdded.dispatch(b),G=!1,B=null,A=!1}function o(b){C?(C.segments[2].point.y=b.point.y,C.segments[3].point.y=b.point.y):C=new a.Path({segments:[[u-w,B.y],[u+w,B.y],[u+w,b.point.y],[u-w,b.point.y]],closed:!0,style:x,dashArray:[10,5]})}function p(a){var b="up"===F?0:2;E.segments[b].point.y+=a.delta.y,E.segments[b+1].point.y+=a.delta.y,G=!0}function q(a){var b=a.delta.clone();b.x=0,E.translate(b),G=!0}var r="cmsarea",s={annotationAdded:null,annotationSelected:null,annotationChanged:null},t=!1,u=0,v=50,w=v/2,x={strokeWidth:2,fillColor:new a.Color(1,.91372549,.501960784,.66),strokeColor:"#FFCF40",opacity:.5},y={segments:!0,stroke:!1,fill:!0,tolerance:20,bounds:!1,handles:!1},z=function(){},A=!0,B=null,C=null,D=!1,E=null,F=null,G=!1,H={comment:""},I={onMouseDown:function(b){if(B)C&&!D&&n();else{if(b.point.x<u-w-5||b.point.x>u+w+5)return a.project.deselectAll(),void s.annotationSelected.dispatch(null);var c=b.point.clone();c.x=u;var d=a.project.activeLayer.hitTest(c,y),e=null;if(d&&d.item.data&&d.item.data.type===r&&(e=d.item),e)return!1;F=E=null,a.project.deselectAll(),s.annotationSelected.dispatch(null),B||(A=!0,C&&C.remove(),C=null,B=c,D=!1)}},onMouseDrag:function(a){if(A&&B)D=!0,o(a);else if(null!==F)p(a);else{if(!E)return!1;q(a)}},onMouseMove:function(a){A&&B&&o(a)},onMouseUp:function(a){B?C&&D&&(o(a),n()):E&&E.data.itemMouseUp(a),F=E=null},onKeyDown:function(b){switch(b.key){case"enter":A&&n();break;case"escape":A&&m();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"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{name:r,tool:new a.Tool(I),registerEvent:function(a,b){s[a]=b},exportJSON:b,importJSON:c,listeners:{onCutPositionChanged:d,onSetAreaWidth:e,onToolActivated:f}}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
define('adim/category',["underscore","paper","signals"],function(a,b){function c(){a.isString(e)&&(e=$(e)),a(e.find("[data-category]")).each(function(a,b){var c=$(a),e=c.data("color")||c.css("backgroundColor"),g=c.data("category");f[g]={id:g,color:d(e)},0==b&&(f["default"]=f[g])})}function d(a,c){var d;if(0===a.indexOf("rgb")){var e=a.split(/[(),]/).map(function(a){return parseFloat(a.trim())}).filter(function(a){return!isNaN(a)});d=new b.Color(e[0]/255,e[1]/255,e[2]/255)}else d=new b.Color(a);return c?d:d.toCSS(!0)}var e="#prop-annot-category",f={};return{init:c,getCategory:function(a){return f[a]}}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/marker',["underscore","paper","signals","adim/category"],function(a,b,c,d){function e(a){var b=this.exportJSON({asString:!1});return b[1].data.origin.splice(0,1),a&&a.asString?JSON.stringify(b):b}function f(a,c,d){var e=a[1].data;e.origin=new b.Point(e.origin);var f=b.project.activeLayer;c.activate();var h=g(e.origin,e,d);return e.prop.category&&l.call(h,e.prop.category),f.activate(),h}function g(c,d,e){e=e!==!1;var f;d&&d.label?(f=parseInt(d.label,10)||d.label,C=!0):f=B.length+1;var g=(d?parseInt(d.radius,10):!1)||D,i=(d?parseFloat(d.rotation):!1)||0,m=d&&"object"==typeof d.prop?d.prop:{};for(var r in A)m.hasOwnProperty(r)||(m[r]=A[r]);var s=new b.Group;return s.data={type:w,tId:"a"+s._id,origin:c,radius:g,rotation:i,label:f,prop:m,setColor:y,getColor:y,setFill:y,setStrokeWidth:j,getStrokeWidth:k,setCategory:l,itemMouseDrag:o,itemMouseDown:n,itemMouseUp:p},s._boundsSelected=!0,s._selectChildren=!1,e&&(s.onPropertyChange=q,s.onMouseDown=n),h(s),e&&(a.some(B,function(a,b){return f<a.data.label?(B.splice(b,0,s),!0):!1})||B.push(s)),s}function h(a,c){c=c||{};var e=c.radius||a.data.radius,f=c.label||a.data.label,g=c.origin||a.data.origin,h=c.rotation||a.data.rotation,i=c.category||a.data.prop.category||"default",j=c.highlight||!1,k=d.getCategory(i),l=k&&k.color||"black";if(!f||!g)return void console.error("label or origin not defined");var m=1.4*e,n=e/3.75,o=2*e/1.25;f.toString().length>1&&(m*=.9);var p=new b.Path.Circle({center:[0,0],radius:e+e/4,fillColor:j?F:E,strokeColor:null}),q=new b.Path.Circle({center:[0,0],radius:e,strokeColor:l||"black",fillColor:"white",strokeWidth:e/4}),r=new b.Path({segments:[[n-e,o-e],[0,10*e/3-e],[2*e-n-e,o-e]],closed:!0,fillColor:l||"black",strokeJoin:"round",strokeColor:j?F:E,strokeWidth:e/8}),s=new b.PointText({point:[0,0],content:f,fillColor:l||"black",strokeColor:null,fontFamily:"Courier",fontWeight:"bold",fontSize:m});s.translate([-s.bounds.width/2,m/4]),a.removeChildren(),a.addChildren([p,r,q,s]),a.translate(g),r.rotate(h,g)}function i(a){this.children[G.circle].strokeColor=a,this.children[G.pointer].fillColor=a,this.children[G.labelText].fillColor=a}function j(a){this.data.radius=a+10,h(this)}function k(){return this.data.radius-10}function l(a){var b=d.getCategory(a),c=b&&b.color||"#000000";i.call(this,c)}function m(a,b){!a in H?(I=null,J={},K=!1):(I=H[a],J=b)}function n(a){if(this.selected&&!x){var b=this.data.origin.subtract(a.point).length;I=b>1.25*this.data.radius?H.DRAG_POINTER:H.FULL_DRAG}}function o(a){if(!x)switch(K=!0,I){case H.FULL_DRAG:this.translate(a.delta),this.data.origin=this.data.origin.add(a.delta);break;case H.DRAG_POINTER:var b=a.point.subtract(this.data.origin).angle-90;this.data.rotation=b,h(this);break;default:K=!1}}function p(){I=null,K&&z.annotationChanged.dispatch(this),K=!1}function q(a,c){"category"===a&&(l.call(this,c),b.view.draw())}function r(a){return a.data&&a.data.type===w?a:a.parent?r(a.parent):null}function s(a){var c,d;return c=b.project.activeLayer.hitTest(a,{tolerance:7,fill:!0,stroke:!0,segments:!0,ends:!0,bounds:!0,selected:!0}),c||(c=b.project.activeLayer.hitTest(a,{tolerance:1,fill:!0,stroke:!0})),c&&c.item&&(d=r(c.item))?d:!1}function t(){var b=[],c=0;a.each(B,function(a){a.parent&&(c++,a.data.label.toString()!==c.toString()&&(a.data.label=c.toString(),h(a),b.push(a),z.markerLabelChanged.dispatch(a)))}),B=a.reject(B,function(a){return!a.parent}),b.length>0&&z.annotationChanged.dispatch(b)}function u(a){var c=B.splice(a.oldIndex,1);B.splice(a.newIndex,0,c[0]),t(),b.view.draw()}function v(a){return x=a}var w="marker",x=!1,y=function(){},z=(new b.Color([0,0,0,0]),{annotationAdded:null,annotationSelected:null,annotationChanged:null,markerLabelChanged:new c}),A={labelComment:"",category:""},B=[],C=!1,D=20,E="white",F="red",G={bgCircle:0,pointer:1,circle:2,labelText:3},H={FULL_DRAG:1,DRAG_POINTER:2},I=null,J={},K=!1,L=null,M={onMouseDown:function(a){if(!x&&(I=null,b.project.hitTest(a.point,{"class":b.Raster}))){var c=s(a.point);c?(c.selected?a.point.x==a.lastPoint.x&&z.annotationSelected.dispatch(c):(b.project.deselectAll(),c.selected=!0,z.annotationSelected.dispatch(c)),n.call(c,a),L=c):(b.project.deselectAll(),z.annotationSelected.dispatch(null),c=g(a.point),z.annotationAdded.dispatch(c),b.project.deselectAll(),c.selected=!0,n.call(c,a),L=c,z.annotationSelected.dispatch(c))}},onMouseDrag:function(a){x||I&&o.call(L,a)},onMouseUp:function(){m(null),L=null}};return{name:w,tool:new b.Tool(M),setRo:v,registerEvent:function(a,b){z[a]=b},exportJSON:e,importJSON:f,listeners:{updateNumbering:t,setNumbering:u},events:z}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('adim/category',["underscore","paper","signals"],function(a,b){function c(){a.isString(e)&&(e=$(e)),a(e.find("[data-category]")).each(function(a,b){var c=$(a),e=c.data("color")||c.css("backgroundColor"),g=c.data("category");f[g]={id:g,color:d(e)},0==b&&(f["default"]=f[g])}),f["default"]=f.cat_2}function d(a,c){var d;if(0===a.indexOf("rgb")){var e=a.split(/[(),]/).map(function(a){return parseFloat(a.trim())}).filter(function(a){return!isNaN(a)});d=new b.Color(e[0]/255,e[1]/255,e[2]/255)}else d=new b.Color(a);return c?d:d.toCSS(!0)}var e="#prop-annot-category",f={};return{init:c,getCategory:function(a){return f[a]}}});
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/marker',["underscore","paper","signals","adim/category"],function(a,b,c,d){function e(a){var b=this.exportJSON({asString:!1});return b[1].data.origin.splice(0,1),a&&a.asString?JSON.stringify(b):b}function f(a,c,d){var e=a[1].data;e.origin=new b.Point(e.origin);var f=b.project.activeLayer;c.activate();var h=A.category,i=g(e.origin,e,d);return e.prop.category&&l.call(i,e.prop.category),f.activate(),A.category=h,i}function g(c,d,e){e=e!==!1;var f;d&&d.label?(f=parseInt(d.label,10)||d.label,C=!0):f=B.length+1;var g=(d?parseInt(d.radius,10):!1)||D,i=(d?parseFloat(d.rotation):!1)||0,m=d&&"object"==typeof d.prop?d.prop:{};for(var r in A)m.hasOwnProperty(r)||(m[r]=A[r]);var s=new b.Group;return s.data={type:w,tId:"a"+s._id,origin:c,radius:g,rotation:i,label:f,prop:m,setColor:y,getColor:y,setFill:y,setStrokeWidth:j,getStrokeWidth:k,setCategory:l,itemMouseDrag:o,itemMouseDown:n,itemMouseUp:p},s._boundsSelected=!0,s._selectChildren=!1,e&&(s.onPropertyChange=q,s.onMouseDown=n),h(s),e&&(a.some(B,function(a,b){return f<a.data.label?(B.splice(b,0,s),!0):!1})||B.push(s)),s}function h(a,c){c=c||{};var e=c.radius||a.data.radius,f=c.label||a.data.label,g=c.origin||a.data.origin,h=c.rotation||a.data.rotation,i=c.category||a.data.prop.category||"default",j=c.highlight||!1,k=d.getCategory(i),l=k&&k.color||"black";if(!f||!g)return void console.error("label or origin not defined");var m=1.4*e,n=e/3.75,o=2*e/1.25;f.toString().length>1&&(m*=.9);var p=new b.Path.Circle({center:[0,0],radius:e+e/4,fillColor:j?F:E,strokeColor:null}),q=new b.Path.Circle({center:[0,0],radius:e,strokeColor:l||"black",fillColor:"white",strokeWidth:e/4}),r=new b.Path({segments:[[n-e,o-e],[0,10*e/3-e],[2*e-n-e,o-e]],closed:!0,fillColor:l||"black",strokeJoin:"round",strokeColor:j?F:E,strokeWidth:e/8}),s=new b.PointText({point:[0,0],content:f,fillColor:l||"black",strokeColor:null,fontFamily:"Courier",fontWeight:"bold",fontSize:m});s.translate([-s.bounds.width/2,m/4]),a.removeChildren(),a.addChildren([p,r,q,s]),a.translate(g),r.rotate(h,g)}function i(a){this.children[G.circle].strokeColor=a,this.children[G.pointer].fillColor=a,this.children[G.labelText].fillColor=a}function j(a){this.data.radius=a+10,h(this)}function k(){return this.data.radius-10}function l(a){var b=d.getCategory(a),c=b&&b.color||"#000000";i.call(this,c),A.category=a}function m(a,b){!a in H?(I=null,J={},K=!1):(I=H[a],J=b)}function n(a){if(this.selected&&!x){var b=this.data.origin.subtract(a.point).length;I=b>1.25*this.data.radius?H.DRAG_POINTER:H.FULL_DRAG}}function o(a){if(!x)switch(K=!0,I){case H.FULL_DRAG:this.translate(a.delta),this.data.origin=this.data.origin.add(a.delta);break;case H.DRAG_POINTER:var b=a.point.subtract(this.data.origin).angle-90;this.data.rotation=b,h(this);break;default:K=!1}}function p(){I=null,K&&z.annotationChanged.dispatch(this),K=!1}function q(a,c){"category"===a&&(l.call(this,c),b.view.draw())}function r(a){return a.data&&a.data.type===w?a:a.parent?r(a.parent):null}function s(a){var c,d;return c=b.project.activeLayer.hitTest(a,{tolerance:7,fill:!0,stroke:!0,segments:!0,ends:!0,bounds:!0,selected:!0}),c||(c=b.project.activeLayer.hitTest(a,{tolerance:1,fill:!0,stroke:!0})),c&&c.item&&(d=r(c.item))?d:!1}function t(){var b=[],c=0;a.each(B,function(a){a.parent&&(c++,a.data.label.toString()!==c.toString()&&(a.data.label=c.toString(),h(a),b.push(a),z.markerLabelChanged.dispatch(a)))}),B=a.reject(B,function(a){return!a.parent}),b.length>0&&z.annotationChanged.dispatch(b)}function u(a){var c=B.splice(a.oldIndex,1);B.splice(a.newIndex,0,c[0]),t(),b.view.draw()}function v(a){return x=a}var w="marker",x=!1,y=function(){},z=(new b.Color([0,0,0,0]),{annotationAdded:null,annotationSelected:null,annotationChanged:null,markerLabelChanged:new c}),A={labelComment:"",category:"cat_2"},B=[],C=!1,D=20,E="white",F="red",G={bgCircle:0,pointer:1,circle:2,labelText:3},H={FULL_DRAG:1,DRAG_POINTER:2},I=null,J={},K=!1,L=null,M={onMouseDown:function(a){if(!x&&(I=null,b.project.hitTest(a.point,{"class":b.Raster}))){var c=s(a.point);c?(c.selected?a.point.x==a.lastPoint.x&&z.annotationSelected.dispatch(c):(b.project.deselectAll(),c.selected=!0,z.annotationSelected.dispatch(c)),n.call(c,a),L=c):(b.project.deselectAll(),z.annotationSelected.dispatch(null),c=g(a.point),z.annotationAdded.dispatch(c),b.project.deselectAll(),c.selected=!0,n.call(c,a),L=c,z.annotationSelected.dispatch(c))}},onMouseDrag:function(a){x||I&&o.call(L,a)},onMouseUp:function(){m(null),L=null}};return{name:w,tool:new b.Tool(M),setRo:v,registerEvent:function(a,b){z[a]=b},exportJSON:e,importJSON:f,listeners:{updateNumbering:t,setNumbering:u},events:z}});
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 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"],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(a);b?(n=a,b.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){var c=i(a.data.type);return c.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},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(){var a=new paper.Tool({onMouseDown:p,onMouseUp:p,onMouseDrag:p,onKeyDown:p,onKeyUp:p});a.activate()}(),{events:q,tools:m,getTool:f,getToolJSONImporter:h,getToolJSONExporter:i,activateTool:g,getActiveTool:e,serializeItem:j,setRo:k}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 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){var c="user_"+a,d=b||f.getById(a)||a;return j(c,{owner:d,ownerId:a})}function l(a,b){var d=h(a);return d?(b="undefined"==typeof 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(j){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 l=k(c.owner),m=g.getToolJSONImporter(i)(f,l,d);return m&&(m.data.id=c.id,m.selected=!1),m}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;f>e;e++)for(var g=b[e].children,h=0,i=g.length;i>h;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?!0:!!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)?!0:!!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&&a.undef===!0: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)?!0: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,d&&(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(){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(a).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,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)},A.source=b.url,A.position=[0,0],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){var b=h("user_"+a);return o(b.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 - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 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(){})}function j(a){function c(a){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){a=a||e.user.id;var b=f.getUserAnnnotationsSerialized(a);return j(b),!0},saveAnnotations:function(a,b){if(!n&&!b)return!1;m.annotationsSavedStatusChanged.dispatch({status:"dirty"});var c=f.getAnnotationsSerialized(a);return j(c),!0},removeAnnotation:k,saveThumbnail:i,setAnnotableName:l}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('adim/attributes',["underscore","paper","signals","adim/view"],function(a,b,c,d){function e(a){a=a||b.project.currentStyle,B.colorChanged.add(function(a,b){j(a,b)}),B.fillChanged.add(function(a,b){m(a,b)}),B.fontSizeChanged.add(function(a,b){p(a,b)}),B.strokeWidthChanged.add(function(a,b){t(a,b)}),B.opacityChanged.add(function(a,b){w(a,b)}),h(a.strokeColor),n(a.fontSize),q(a.strokeWidth),z(1),k(!!a.isFill)}function f(a,c){for(var e,f=d.getSelectedAnnotations(),g=[],h=0;e=f[h];h++)e.data&&e.data.type&&("function"==typeof e.data[a.setCallbackName]?e.data[a.setCallbackName].call(e,a.attrValue):a.setAttrCallback.call(e,a.attrValue),g.push(e));c!==!1&&B.annotationChanged.dispatch(g),b.view.draw()}function g(a){var c=d.getSelectedAnnotations();if(c.length>0){var e=c[0],f=e.index,g=null,h=null,i=[];if("front"===a?e.bringToFront():"frontward"===a?e.nextSibling&&e.insertAbove(e.nextSibling):"back"===a?e.sendToBack():"backward"===a&&e.previousSibling&&e.insertBelow(e.previousSibling),f!==e.index){g=Math.min(f,e.index),h=Math.max(f,e.index);for(var j=g;h>=j;j++)i.push(e.layer.children[j]);B.annotationChanged.dispatch(i),b.view.draw()}}}function h(a,c,d){C=new b.Color(a),b.project.currentStyle.strokeColor=C,b.project.currentStyle.fillColor=E?C:null,d!==!0&&B.colorChanged.dispatch(a,c)}function i(){return C}function j(a,b){f({setCallbackName:"setColor",attrValue:a,setAttrCallback:function(a){this.fillColor&&(this.fillColor=a),this.strokeColor=a}},b)}function k(a,c,d){E=!!a,b.project.currentStyle.fillColor=E?C:null,d!==!0&&B.fillChanged.dispatch(E,c)}function l(){return E}function m(a,b){f({setCallbackName:"setFill",attrValue:a,setAttrCallback:function(a){var b=this.fillColor||this.strokeColor;this.fillColor=a?b:null}},b)}function n(a,c,d){F=a,b.project.currentStyle.fontSize=a,d!==!0&&B.fontSizeChanged.dispatch(a,c)}function o(){return b.project.currentStyle.fontSize}function p(a,b){f({setCallbackName:"setFontSize",attrValue:a},b)}function q(a,c,d){G=a>J?J:K>a?K:a,b.project.currentStyle.strokeWidth=G,d!==!0&&B.strokeWidthChanged.dispatch(a,c)}function r(){return G}function s(a){var b=Math.abs(a),c=b/a,d=(1+Math.floor(b/3))*c;q(r()+d,!1),L(r())}function t(a,b){f({setCallbackName:"setStrokeWidth",attrValue:a,setAttrCallback:function(a){this.strokeWidth=a}},b)}function u(a,b,c){D=Math.max(0,Math.min(100,a)),c!==!0&&B.opacityChanged.dispatch(a,b)}function v(){return D}function w(a,b){f({setCallbackName:"setOpacity",attrValue:a,setAttrCallback:function(a){this.opacity=a/100}},b)}function x(a){a=Math.max(0,Math.min(100,a)),H=a,d._raster().opacity=a/100,b.view.draw()}function y(){return H}function z(a,c){var e,f,g;a=Math.max(N,Math.min(M,a)),b.project.view.zoom!==a&&(c&&("center"===c?(I=I||d.getLayerByName("image"),g=I?I.localToGlobal(I.bounds.center).subtract(b.view.center):[0,0]):(c=b.view.viewToProject(c),e=b.view.zoom/a,f=c.subtract(b.view.center),g=c.subtract(f.multiply(e)).subtract(b.view.center))),b.project.view.zoom=a,g&&b.view.setCenter(b.view.center.add(g)),B.zoomChanged.dispatch(a))}function A(a,c,d){var e=20;if(d=isNaN(d)?5:d,0!==a){var f=Math.abs(a),g=f/a;a=g*(f>e?e:d>f?d:f);var h=b.project.view.zoom;h+=b.project.view.zoom*a/100,z(h,c)}}var B={colorChanged:new c,fillChanged:new c,fontSizeChanged:new c,strokeWidthChanged:new c,opacityChanged:new c,zoomChanged:new c,annotationChanged:new c},C=null,D=1,E=!1,F=48,G=7,H=100,I=null,J=50,K=1,L=a.debounce(q,300),M=10,N=.1;return{init:e,events:B,setColor:h,getColor:i,setFill:k,getFill:l,setFontSize:n,getFontSize:o,setStrokeWidth:q,getStrokeWidth:r,deltaStrokeWidth:s,setOpacity:u,getOpacity:v,setZoom:z,deltaZoom:A,setImageOpacity:x,getImageOpacity:y,bringToFront:function(){g("front")},bringFrontward:function(){g("frontward")},sendToBack:function(){g("back")},sendBacktward:function(){g("backward")}}});
/* FileSaver.js
* A saveAs() FileSaver implementation.
......@@ -13830,7 +13830,7 @@ if (typeof module !== "undefined" && module !== null) {
}
;
!function(a){var b=a.HTMLCanvasElement&&a.HTMLCanvasElement.prototype,c=a.Blob&&function(){try{return Boolean(new Blob)}catch(a){return!1}}(),d=c&&a.Uint8Array&&function(){try{return 100===new Blob([new Uint8Array(100)]).size}catch(a){return!1}}(),e=a.BlobBuilder||a.WebKitBlobBuilder||a.MozBlobBuilder||a.MSBlobBuilder,f=(c||e)&&a.atob&&a.ArrayBuffer&&a.Uint8Array&&function(a){var b,f,g,h,i,j;for(b=a.split(",")[0].indexOf("base64")>=0?atob(a.split(",")[1]):decodeURIComponent(a.split(",")[1]),f=new ArrayBuffer(b.length),g=new Uint8Array(f),h=0;h<b.length;h+=1)g[h]=b.charCodeAt(h);return i=a.split(",")[0].split(":")[1].split(";")[0],c?new Blob([d?g:f],{type:i}):(j=new e,j.append(f),j.getBlob(i))};a.HTMLCanvasElement&&!b.toBlob&&(b.mozGetAsFile?b.toBlob=function(a,c,d){d&&b.toDataURL&&f?a(f(this.toDataURL(c,d))):a(this.mozGetAsFile("blob",c))}:b.toDataURL&&f&&(b.toBlob=function(a,b,c){a(f(this.toDataURL(b,c)))})),"function"==typeof define&&define.amd?define('canvasToBlob',[],function(){return f}):a.dataURLtoBlob=f}(this);
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('helper/exporter',["jquery","paper","FileSaver","adim/view","adim/config","canvasToBlob"],function(a,b,c,d,e){function f(a,e){var f,g,h,i=d.getLayerByName("image").children.filter(function(a){return!!a.image});if(i.length>0&&e.linkImages)require(["zip"],function(d){j||(d.workerScriptsPath=requirejs.toUrl("zip").split("/").slice(0,-1).join("/")+"/",j=!0),g=i[0].toDataURL,h=function(){return this._image&&this._image.src};for(var k,l=0;k=i[l];l++)k.toDataURL=h;f=b.project.exportSVG({asString:!0});for(var k,l=0;k=i[l];l++)k.toDataURL=g;for(var m,n=(i.map(function(a){return a.source}),[]),o=0;m=i[o];o++){var p=m.source,q=p.split("/").pop();f=f.replace(p,q),n.push([q,m])}var r=a+" directory";return d.createWriter(new d.BlobWriter("application/zip"),function(b){function g(){var a=n[i++];a?a[1].canvas.toBlob(function(c){b.add(r+"/"+a[0],new d.BlobReader(c),function(){g()})},"image/jpeg",e.quality||.9):h()}function h(){b.close(function(b){c(b,a+"_svg.zip"),e&&e.callback&&"function"==typeof e.callback&&e.callback()})}var i=0;b.add(r+"/image.svg",new d.TextReader(f),function(){g()})}),null});else{if(0===i.length||"png"===e.imageType)f=b.project.exportSVG({asString:!0});else{g=i[0].toDataURL,h=function(){var a=this._image&&this._image.src;if(/^data:/.test(a))return a;var b=this.getCanvas();return b?b.toDataURL("image/jpeg",e.quality||.9):null};for(var k,l=0;k=i[l];l++)k.toDataURL=h;f=b.project.exportSVG({asString:!0});for(var k,l=0;k=i[l];l++)k.toDataURL=g}var m=new Blob([f],{type:"image/svg+xml;charset=utf-8"});c(m,a+".svg"),e&&e.callback&&"function"==typeof e.callback&&e.callback()}}function g(e,f){var g=a.Deferred(),h=b.view.zoom,i=b.view.viewSize,j=b.view.center,k=d.getLayerByName("image").children[1].size,l=d.getSelectedAnnotations(),m=a.map(l,function(a){return a.fullySelected?a:null});b.project.deselectAll();var n,o,p=[];if(f&&f.thumbnailSize){for(p=b.project.getItems({data:{type:"arrow"}}),o=0,n;n=p[o];o++)n.symbol.definition.strokeScaling=!0;b.view.zoom=f.thumbnailSize/Math.max(k.width,k.height),d.resize(k.width*b.view.zoom,k.height*b.view.zoom)}else b.view.zoom=1,d.resize(k.width,k.height);for(b.view.center=k.multiply(.5),b.view.element.toBlob(function(a){g.resolve({blob:a}),f&&f.thumbnailSize||c(a,e+".png")}),a.each(l,function(a,b){b.selected=!0}),a.each(m,function(a,b){b.fullySelected=!0}),o=0,n;n=p[o];o++)n.symbol.definition.strokeScaling=!1;return b.view.viewSize=i,b.view.zoom=h,b.view.center=j,f&&f.callback&&"function"==typeof f.callback&&f.callback(),g}function h(a){var b=window.devicePixelRatio||1;return a.thumbnailSize=(parseInt(e.thumbnailSize,10)||150)/b,g(null,a)}function i(a,b,c){switch(b){case"png":return g(a,c);case"svg":c=c||{},c.linkImages=!1,c.imageType="jpeg",c.quality=.9,f(a,c)}}var j=!1;return{exportSVG:f,"export":i,getThumbnail:h}});
(function(t,e){if(typeof define==="function"&&define.amd){define('backbone',["underscore","jquery","exports"],function(i,r,s){t.Backbone=e(t,s,i,r)})}else if(typeof exports!=="undefined"){var i=require("underscore");e(t,exports,i)}else{t.Backbone=e(t,{},t._,t.jQuery||t.Zepto||t.ender||t.$)}})(this,function(t,e,i,r){var s=t.Backbone;var n=[];var a=n.push;var o=n.slice;var h=n.splice;e.VERSION="1.1.2";e.$=r;e.noConflict=function(){t.Backbone=s;return this};e.emulateHTTP=false;e.emulateJSON=false;var u=e.Events={on:function(t,e,i){if(!c(this,"on",t,[e,i])||!e)return this;this._events||(this._events={});var r=this._events[t]||(this._events[t]=[]);r.push({callback:e,context:i,ctx:i||this});return this},once:function(t,e,r){if(!c(this,"once",t,[e,r])||!e)return this;var s=this;var n=i.once(function(){s.off(t,n);e.apply(this,arguments)});n._callback=e;return this.on(t,n,r)},off:function(t,e,r){var s,n,a,o,h,u,l,f;if(!this._events||!c(this,"off",t,[e,r]))return this;if(!t&&!e&&!r){this._events=void 0;return this}o=t?[t]:i.keys(this._events);for(h=0,u=o.length;h<u;h++){t=o[h];if(a=this._events[t]){this._events[t]=s=[];if(e||r){for(l=0,f=a.length;l<f;l++){n=a[l];if(e&&e!==n.callback&&e!==n.callback._callback||r&&r!==n.context){s.push(n)}}}if(!s.length)delete this._events[t]}}return this},trigger:function(t){if(!this._events)return this;var e=o.call(arguments,1);if(!c(this,"trigger",t,e))return this;var i=this._events[t];var r=this._events.all;if(i)f(i,e);if(r)f(r,arguments);return this},stopListening:function(t,e,r){var s=this._listeningTo;if(!s)return this;var n=!e&&!r;if(!r&&typeof e==="object")r=this;if(t)(s={})[t._listenId]=t;for(var a in s){t=s[a];t.off(e,r,this);if(n||i.isEmpty(t._events))delete this._listeningTo[a]}return this}};var l=/\s+/;var c=function(t,e,i,r){if(!i)return true;if(typeof i==="object"){for(var s in i){t[e].apply(t,[s,i[s]].concat(r))}return false}if(l.test(i)){var n=i.split(l);for(var a=0,o=n.length;a<o;a++){t[e].apply(t,[n[a]].concat(r))}return false}return true};var f=function(t,e){var i,r=-1,s=t.length,n=e[0],a=e[1],o=e[2];switch(e.length){case 0:while(++r<s)(i=t[r]).callback.call(i.ctx);return;case 1:while(++r<s)(i=t[r]).callback.call(i.ctx,n);return;case 2:while(++r<s)(i=t[r]).callback.call(i.ctx,n,a);return;case 3:while(++r<s)(i=t[r]).callback.call(i.ctx,n,a,o);return;default:while(++r<s)(i=t[r]).callback.apply(i.ctx,e);return}};var d={listenTo:"on",listenToOnce:"once"};i.each(d,function(t,e){u[e]=function(e,r,s){var n=this._listeningTo||(this._listeningTo={});var a=e._listenId||(e._listenId=i.uniqueId("l"));n[a]=e;if(!s&&typeof r==="object")s=this;e[t](r,s,this);return this}});u.bind=u.on;u.unbind=u.off;i.extend(e,u);var p=e.Model=function(t,e){var r=t||{};e||(e={});this.cid=i.uniqueId("c");this.attributes={};if(e.collection)this.collection=e.collection;if(e.parse)r=this.parse(r,e)||{};r=i.defaults({},r,i.result(this,"defaults"));this.set(r,e);this.changed={};this.initialize.apply(this,arguments)};i.extend(p.prototype,u,{changed:null,validationError:null,idAttribute:"id",initialize:function(){},toJSON:function(t){return i.clone(this.attributes)},sync:function(){return e.sync.apply(this,arguments)},get:function(t){return this.attributes[t]},escape:function(t){return i.escape(this.get(t))},has:function(t){return this.get(t)!=null},set:function(t,e,r){var s,n,a,o,h,u,l,c;if(t==null)return this;if(typeof t==="object"){n=t;r=e}else{(n={})[t]=e}r||(r={});if(!this._validate(n,r))return false;a=r.unset;h=r.silent;o=[];u=this._changing;this._changing=true;if(!u){this._previousAttributes=i.clone(this.attributes);this.changed={}}c=this.attributes,l=this._previousAttributes;if(this.idAttribute in n)this.id=n[this.idAttribute];for(s in n){e=n[s];if(!i.isEqual(c[s],e))o.push(s);if(!i.isEqual(l[s],e)){this.changed[s]=e}else{delete this.changed[s]}a?delete c[s]:c[s]=e}if(!h){if(o.length)this._pending=r;for(var f=0,d=o.length;f<d;f++){this.trigger("change:"+o[f],this,c[o[f]],r)}}if(u)return this;if(!h){while(this._pending){r=this._pending;this._pending=false;this.trigger("change",this,r)}}this._pending=false;this._changing=false;return this},unset:function(t,e){return this.set(t,void 0,i.extend({},e,{unset:true}))},clear:function(t){var e={};for(var r in this.attributes)e[r]=void 0;return this.set(e,i.extend({},t,{unset:true}))},hasChanged:function(t){if(t==null)return!i.isEmpty(this.changed);return i.has(this.changed,t)},changedAttributes:function(t){if(!t)return this.hasChanged()?i.clone(this.changed):false;var e,r=false;var s=this._changing?this._previousAttributes:this.attributes;for(var n in t){if(i.isEqual(s[n],e=t[n]))continue;(r||(r={}))[n]=e}return r},previous:function(t){if(t==null||!this._previousAttributes)return null;return this._previousAttributes[t]},previousAttributes:function(){return i.clone(this._previousAttributes)},fetch:function(t){t=t?i.clone(t):{};if(t.parse===void 0)t.parse=true;var e=this;var r=t.success;t.success=function(i){if(!e.set(e.parse(i,t),t))return false;if(r)r(e,i,t);e.trigger("sync",e,i,t)};q(this,t);return this.sync("read",this,t)},save:function(t,e,r){var s,n,a,o=this.attributes;if(t==null||typeof t==="object"){s=t;r=e}else{(s={})[t]=e}r=i.extend({validate:true},r);if(s&&!r.wait){if(!this.set(s,r))return false}else{if(!this._validate(s,r))return false}if(s&&r.wait){this.attributes=i.extend({},o,s)}if(r.parse===void 0)r.parse=true;var h=this;var u=r.success;r.success=function(t){h.attributes=o;var e=h.parse(t,r);if(r.wait)e=i.extend(s||{},e);if(i.isObject(e)&&!h.set(e,r)){return false}if(u)u(h,t,r);h.trigger("sync",h,t,r)};q(this,r);n=this.isNew()?"create":r.patch?"patch":"update";if(n==="patch")r.attrs=s;a=this.sync(n,this,r);if(s&&r.wait)this.attributes=o;return a},destroy:function(t){t=t?i.clone(t):{};var e=this;var r=t.success;var s=function(){e.trigger("destroy",e,e.collection,t)};t.success=function(i){if(t.wait||e.isNew())s();if(r)r(e,i,t);if(!e.isNew())e.trigger("sync",e,i,t)};if(this.isNew()){t.success();return false}q(this,t);var n=this.sync("delete",this,t);if(!t.wait)s();return n},url:function(){var t=i.result(this,"urlRoot")||i.result(this.collection,"url")||M();if(this.isNew())return t;return t.replace(/([^\/])$/,"$1/")+encodeURIComponent(this.id)},parse:function(t,e){return t},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return!this.has(this.idAttribute)},isValid:function(t){return this._validate({},i.extend(t||{},{validate:true}))},_validate:function(t,e){if(!e.validate||!this.validate)return true;t=i.extend({},this.attributes,t);var r=this.validationError=this.validate(t,e)||null;if(!r)return true;this.trigger("invalid",this,r,i.extend(e,{validationError:r}));return false}});var v=["keys","values","pairs","invert","pick","omit"];i.each(v,function(t){p.prototype[t]=function(){var e=o.call(arguments);e.unshift(this.attributes);return i[t].apply(i,e)}});var g=e.Collection=function(t,e){e||(e={});if(e.model)this.model=e.model;if(e.comparator!==void 0)this.comparator=e.comparator;this._reset();this.initialize.apply(this,arguments);if(t)this.reset(t,i.extend({silent:true},e))};var m={add:true,remove:true,merge:true};var y={add:true,remove:false};i.extend(g.prototype,u,{model:p,initialize:function(){},toJSON:function(t){return this.map(function(e){return e.toJSON(t)})},sync:function(){return e.sync.apply(this,arguments)},add:function(t,e){return this.set(t,i.extend({merge:false},e,y))},remove:function(t,e){var r=!i.isArray(t);t=r?[t]:i.clone(t);e||(e={});var s,n,a,o;for(s=0,n=t.length;s<n;s++){o=t[s]=this.get(t[s]);if(!o)continue;delete this._byId[o.id];delete this._byId[o.cid];a=this.indexOf(o);this.models.splice(a,1);this.length--;if(!e.silent){e.index=a;o.trigger("remove",o,this,e)}this._removeReference(o,e)}return r?t[0]:t},set:function(t,e){e=i.defaults({},e,m);if(e.parse)t=this.parse(t,e);var r=!i.isArray(t);t=r?t?[t]:[]:i.clone(t);var s,n,a,o,h,u,l;var c=e.at;var f=this.model;var d=this.comparator&&c==null&&e.sort!==false;var v=i.isString(this.comparator)?this.comparator:null;var g=[],y=[],_={};var b=e.add,w=e.merge,x=e.remove;var E=!d&&b&&x?[]:false;for(s=0,n=t.length;s<n;s++){h=t[s]||{};if(h instanceof p){a=o=h}else{a=h[f.prototype.idAttribute||"id"]}if(u=this.get(a)){if(x)_[u.cid]=true;if(w){h=h===o?o.attributes:h;if(e.parse)h=u.parse(h,e);u.set(h,e);if(d&&!l&&u.hasChanged(v))l=true}t[s]=u}else if(b){o=t[s]=this._prepareModel(h,e);if(!o)continue;g.push(o);this._addReference(o,e)}o=u||o;if(E&&(o.isNew()||!_[o.id]))E.push(o);_[o.id]=true}if(x){for(s=0,n=this.length;s<n;++s){if(!_[(o=this.models[s]).cid])y.push(o)}if(y.length)this.remove(y,e)}if(g.length||E&&E.length){if(d)l=true;this.length+=g.length;if(c!=null){for(s=0,n=g.length;s<n;s++){this.models.splice(c+s,0,g[s])}}else{if(E)this.models.length=0;var k=E||g;for(s=0,n=k.length;s<n;s++){this.models.push(k[s])}}}if(l)this.sort({silent:true});if(!e.silent){for(s=0,n=g.length;s<n;s++){(o=g[s]).trigger("add",o,this,e)}if(l||E&&E.length)this.trigger("sort",this,e)}return r?t[0]:t},reset:function(t,e){e||(e={});for(var r=0,s=this.models.length;r<s;r++){this._removeReference(this.models[r],e)}e.previousModels=this.models;this._reset();t=this.add(t,i.extend({silent:true},e));if(!e.silent)this.trigger("reset",this,e);return t},push:function(t,e){return this.add(t,i.extend({at:this.length},e))},pop:function(t){var e=this.at(this.length-1);this.remove(e,t);return e},unshift:function(t,e){return this.add(t,i.extend({at:0},e))},shift:function(t){var e=this.at(0);this.remove(e,t);return e},slice:function(){return o.apply(this.models,arguments)},get:function(t){if(t==null)return void 0;return this._byId[t]||this._byId[t.id]||this._byId[t.cid]},at:function(t){return this.models[t]},where:function(t,e){if(i.isEmpty(t))return e?void 0:[];return this[e?"find":"filter"](function(e){for(var i in t){if(t[i]!==e.get(i))return false}return true})},findWhere:function(t){return this.where(t,true)},sort:function(t){if(!this.comparator)throw new Error("Cannot sort a set without a comparator");t||(t={});if(i.isString(this.comparator)||this.comparator.length===1){this.models=this.sortBy(this.comparator,this)}else{this.models.sort(i.bind(this.comparator,this))}if(!t.silent)this.trigger("sort",this,t);return this},pluck:function(t){return i.invoke(this.models,"get",t)},fetch:function(t){t=t?i.clone(t):{};if(t.parse===void 0)t.parse=true;var e=t.success;var r=this;t.success=function(i){var s=t.reset?"reset":"set";r[s](i,t);if(e)e(r,i,t);r.trigger("sync",r,i,t)};q(this,t);return this.sync("read",this,t)},create:function(t,e){e=e?i.clone(e):{};if(!(t=this._prepareModel(t,e)))return false;if(!e.wait)this.add(t,e);var r=this;var s=e.success;e.success=function(t,i){if(e.wait)r.add(t,e);if(s)s(t,i,e)};t.save(null,e);return t},parse:function(t,e){return t},clone:function(){return new this.constructor(this.models)},_reset:function(){this.length=0;this.models=[];this._byId={}},_prepareModel:function(t,e){if(t instanceof p)return t;e=e?i.clone(e):{};e.collection=this;var r=new this.model(t,e);if(!r.validationError)return r;this.trigger("invalid",this,r.validationError,e);return false},_addReference:function(t,e){this._byId[t.cid]=t;if(t.id!=null)this._byId[t.id]=t;if(!t.collection)t.collection=this;t.on("all",this._onModelEvent,this)},_removeReference:function(t,e){if(this===t.collection)delete t.collection;t.off("all",this._onModelEvent,this)},_onModelEvent:function(t,e,i,r){if((t==="add"||t==="remove")&&i!==this)return;if(t==="destroy")this.remove(e,r);if(e&&t==="change:"+e.idAttribute){delete this._byId[e.previous(e.idAttribute)];if(e.id!=null)this._byId[e.id]=e}this.trigger.apply(this,arguments)}});var _=["forEach","each","map","collect","reduce","foldl","inject","reduceRight","foldr","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max","min","toArray","size","first","head","take","initial","rest","tail","drop","last","without","difference","indexOf","shuffle","lastIndexOf","isEmpty","chain","sample"];i.each(_,function(t){g.prototype[t]=function(){var e=o.call(arguments);e.unshift(this.models);return i[t].apply(i,e)}});var b=["groupBy","countBy","sortBy","indexBy"];i.each(b,function(t){g.prototype[t]=function(e,r){var s=i.isFunction(e)?e:function(t){return t.get(e)};return i[t](this.models,s,r)}});var w=e.View=function(t){this.cid=i.uniqueId("view");t||(t={});i.extend(this,i.pick(t,E));this._ensureElement();this.initialize.apply(this,arguments);this.delegateEvents()};var x=/^(\S+)\s*(.*)$/;var E=["model","collection","el","id","attributes","className","tagName","events"];i.extend(w.prototype,u,{tagName:"div",$:function(t){return this.$el.find(t)},initialize:function(){},render:function(){return this},remove:function(){this.$el.remove();this.stopListening();return this},setElement:function(t,i){if(this.$el)this.undelegateEvents();this.$el=t instanceof e.$?t:e.$(t);this.el=this.$el[0];if(i!==false)this.delegateEvents();return this},delegateEvents:function(t){if(!(t||(t=i.result(this,"events"))))return this;this.undelegateEvents();for(var e in t){var r=t[e];if(!i.isFunction(r))r=this[t[e]];if(!r)continue;var s=e.match(x);var n=s[1],a=s[2];r=i.bind(r,this);n+=".delegateEvents"+this.cid;if(a===""){this.$el.on(n,r)}else{this.$el.on(n,a,r)}}return this},undelegateEvents:function(){this.$el.off(".delegateEvents"+this.cid);return this},_ensureElement:function(){if(!this.el){var t=i.extend({},i.result(this,"attributes"));if(this.id)t.id=i.result(this,"id");if(this.className)t["class"]=i.result(this,"className");var r=e.$("<"+i.result(this,"tagName")+">").attr(t);this.setElement(r,false)}else{this.setElement(i.result(this,"el"),false)}}});e.sync=function(t,r,s){var n=T[t];i.defaults(s||(s={}),{emulateHTTP:e.emulateHTTP,emulateJSON:e.emulateJSON});var a={type:n,dataType:"json"};if(!s.url){a.url=i.result(r,"url")||M()}if(s.data==null&&r&&(t==="create"||t==="update"||t==="patch")){a.contentType="application/json";a.data=JSON.stringify(s.attrs||r.toJSON(s))}if(s.emulateJSON){a.contentType="application/x-www-form-urlencoded";a.data=a.data?{model:a.data}:{}}if(s.emulateHTTP&&(n==="PUT"||n==="DELETE"||n==="PATCH")){a.type="POST";if(s.emulateJSON)a.data._method=n;var o=s.beforeSend;s.beforeSend=function(t){t.setRequestHeader("X-HTTP-Method-Override",n);if(o)return o.apply(this,arguments)}}if(a.type!=="GET"&&!s.emulateJSON){a.processData=false}if(a.type==="PATCH"&&k){a.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}var h=s.xhr=e.ajax(i.extend(a,s));r.trigger("request",r,h,s);return h};var k=typeof window!=="undefined"&&!!window.ActiveXObject&&!(window.XMLHttpRequest&&(new XMLHttpRequest).dispatchEvent);var T={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};e.ajax=function(){return e.$.ajax.apply(e.$,arguments)};var $=e.Router=function(t){t||(t={});if(t.routes)this.routes=t.routes;this._bindRoutes();this.initialize.apply(this,arguments)};var S=/\((.*?)\)/g;var H=/(\(\?)?:\w+/g;var A=/\*\w+/g;var I=/[\-{}\[\]+?.,\\\^$|#\s]/g;i.extend($.prototype,u,{initialize:function(){},route:function(t,r,s){if(!i.isRegExp(t))t=this._routeToRegExp(t);if(i.isFunction(r)){s=r;r=""}if(!s)s=this[r];var n=this;e.history.route(t,function(i){var a=n._extractParameters(t,i);n.execute(s,a);n.trigger.apply(n,["route:"+r].concat(a));n.trigger("route",r,a);e.history.trigger("route",n,r,a)});return this},execute:function(t,e){if(t)t.apply(this,e)},navigate:function(t,i){e.history.navigate(t,i);return this},_bindRoutes:function(){if(!this.routes)return;this.routes=i.result(this,"routes");var t,e=i.keys(this.routes);while((t=e.pop())!=null){this.route(t,this.routes[t])}},_routeToRegExp:function(t){t=t.replace(I,"\\$&").replace(S,"(?:$1)?").replace(H,function(t,e){return e?t:"([^/?]+)"}).replace(A,"([^?]*?)");return new RegExp("^"+t+"(?:\\?([\\s\\S]*))?$")},_extractParameters:function(t,e){var r=t.exec(e).slice(1);return i.map(r,function(t,e){if(e===r.length-1)return t||null;return t?decodeURIComponent(t):null})}});var N=e.History=function(){this.handlers=[];i.bindAll(this,"checkUrl");if(typeof window!=="undefined"){this.location=window.location;this.history=window.history}};var R=/^[#\/]|\s+$/g;var O=/^\/+|\/+$/g;var P=/msie [\w.]+/;var C=/\/$/;var j=/#.*$/;N.started=false;i.extend(N.prototype,u,{interval:50,atRoot:function(){return this.location.pathname.replace(/[^\/]$/,"$&/")===this.root},getHash:function(t){var e=(t||this).location.href.match(/#(.*)$/);return e?e[1]:""},getFragment:function(t,e){if(t==null){if(this._hasPushState||!this._wantsHashChange||e){t=decodeURI(this.location.pathname+this.location.search);var i=this.root.replace(C,"");if(!t.indexOf(i))t=t.slice(i.length)}else{t=this.getHash()}}return t.replace(R,"")},start:function(t){if(N.started)throw new Error("Backbone.history has already been started");N.started=true;this.options=i.extend({root:"/"},this.options,t);this.root=this.options.root;this._wantsHashChange=this.options.hashChange!==false;this._wantsPushState=!!this.options.pushState;this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var r=this.getFragment();var s=document.documentMode;var n=P.exec(navigator.userAgent.toLowerCase())&&(!s||s<=7);this.root=("/"+this.root+"/").replace(O,"/");if(n&&this._wantsHashChange){var a=e.$('<iframe src="javascript:0" tabindex="-1">');this.iframe=a.hide().appendTo("body")[0].contentWindow;this.navigate(r)}if(this._hasPushState){e.$(window).on("popstate",this.checkUrl)}else if(this._wantsHashChange&&"onhashchange"in window&&!n){e.$(window).on("hashchange",this.checkUrl)}else if(this._wantsHashChange){this._checkUrlInterval=setInterval(this.checkUrl,this.interval)}this.fragment=r;var o=this.location;if(this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot()){this.fragment=this.getFragment(null,true);this.location.replace(this.root+"#"+this.fragment);return true}else if(this._hasPushState&&this.atRoot()&&o.hash){this.fragment=this.getHash().replace(R,"");this.history.replaceState({},document.title,this.root+this.fragment)}}if(!this.options.silent)return this.loadUrl()},stop:function(){e.$(window).off("popstate",this.checkUrl).off("hashchange",this.checkUrl);if(this._checkUrlInterval)clearInterval(this._checkUrlInterval);N.started=false},route:function(t,e){this.handlers.unshift({route:t,callback:e})},checkUrl:function(t){var e=this.getFragment();if(e===this.fragment&&this.iframe){e=this.getFragment(this.getHash(this.iframe))}if(e===this.fragment)return false;if(this.iframe)this.navigate(e);this.loadUrl()},loadUrl:function(t){t=this.fragment=this.getFragment(t);return i.any(this.handlers,function(e){if(e.route.test(t)){e.callback(t);return true}})},navigate:function(t,e){if(!N.started)return false;if(!e||e===true)e={trigger:!!e};var i=this.root+(t=this.getFragment(t||""));t=t.replace(j,"");if(this.fragment===t)return;this.fragment=t;if(t===""&&i!=="/")i=i.slice(0,-1);if(this._hasPushState){this.history[e.replace?"replaceState":"pushState"]({},document.title,i)}else if(this._wantsHashChange){this._updateHash(this.location,t,e.replace);if(this.iframe&&t!==this.getFragment(this.getHash(this.iframe))){if(!e.replace)this.iframe.document.open().close();this._updateHash(this.iframe.location,t,e.replace)}}else{return this.location.assign(i)}if(e.trigger)return this.loadUrl(t)},_updateHash:function(t,e,i){if(i){var r=t.href.replace(/(javascript:|#).*$/,"");t.replace(r+"#"+e)}else{t.hash="#"+e}}});e.history=new N;var U=function(t,e){var r=this;var s;if(t&&i.has(t,"constructor")){s=t.constructor}else{s=function(){return r.apply(this,arguments)}}i.extend(s,r,e);var n=function(){this.constructor=s};n.prototype=r.prototype;s.prototype=new n;if(t)i.extend(s.prototype,t);s.__super__=r.prototype;return s};p.extend=g.extend=$.extend=w.extend=N.extend=U;var M=function(){throw new Error('A "url" property or function must be specified')};var q=function(t,e){var i=e.error;e.error=function(r){if(i)i(t,r,e);t.trigger("error",t,r,e)}};return e});
 
......@@ -15416,9 +15416,9 @@ define("bootstrap.spinedit", ["jquery.bootstrap"], function(){});
 
define("bootstrap.rating", ["jquery.bootstrap"], function(){});
 
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('adim/ui',["jquery","underscore","signals","paper","adim/config","adim/view","adim/io","adim/tools","adim/attributes","adim/users","helper/exporter","anobj-mgr/views/AnObjMgr","jquery.bootstrap","jquery.mousewheel","bootstrap.colorpicker","bootstrap.slider","jquery.autoGrowInput","bootstrap.spinedit","bootstrap.rating","FileSaver"],function($,_,Signal,paper,config,view,io,tools,attributes,Users,exporter,AnObjMgr){function init(a){var b=this,c=$("#main-navbar"),d=$("#page-loader");_$w=$(window),_canvas=$("#my-canvas"),_canvasCtnr=$(".canvas-container"),_canvasToolBar=$("#canvas-bbar"),_sideCol=$("#side-col"),_toolsCol=$("#tools-col"),_annotationListCtnr=$("#annotation-list-container"),_markerLabelListCtnr=$("#annotation-markers-container").find(".list-group"),_sharedMarkerLabelListCtnr=$("#shared-annotation-markers-container").find(".list-group"),_canvasCtnrTop=_canvasCtnr.offset().top+_canvasToolBar.outerHeight(),view.events.imageLoaded.add(function(a){adjustCanvasToImage(a.raster),d.remove(),console.timeEnd("complete app")}),view.events.annotationsLoaded.add(function(){zoomFitContent(),updateUserLayers(),e=!0,io.setAutoSave(e)}),view.events.userLayerVisibilityChanged.add(onUserLayerVisChange),tools.events.annotationSelected.add(function(a){_.each($.isArray(a)?a:[a],function(a){var b=!!a&&1===view.getSelectedAnnotations().length;if(b){displayProperties(a);var c="function"==typeof a.data.getStrokeWidth?a.data.getStrokeWidth.call(a):"undefined"!=typeof a.data.strokeWidth?a.data.strokeWidth:"undefined"!=typeof a.strokeWidth?a.strokeWidth:0;c&&(_widthSlider.slider("setValue",c),attributes.setStrokeWidth(c,!1,!0)),"undefined"!=typeof a.opacity&&(_opacitySlider.slider("setValue",100*a.opacity),attributes.setOpacity(a.opacity,!1,!0));var d="function"==typeof a.data.getColor?a.data.getColor.call(a):a.data.color?a.data.color:a.strokeColor?a.strokeColor:a.fillColor;d&&(updateColorSelector(d),attributes.setColor(d,!1,!0));var e="function"==typeof a.data.getFill?a.data.getFill.call(a):!!a.fillColor;$("#tool-fill-color").toggleClass("active",e),attributes.setFill(e,!1,!0);var f="function"==typeof a.data.getFontSize?a.data.getFontSize.call(a):attributes.getFontSize();$("#attr-font-size").val(f),attributes.setFontSize(f,!1,!0)}else disableProperties(!0),$("*:focus").blur();if(a&&a.layer){var g=a.layer.id,h=$("#annotation-list-container .list-group-item").filter(function(a,b){return $(b).data("layerId")==g});selectLayerListItem(h,!1)}})}),io.events.loadingError.add(function(a){if(d.length)d.html('<div class="text-danger lead">Erreur de chargement</div><div class="text-danger">'+a.msg+"</div>");else{var b=$('<div class="alert alert-danger in"><button data-dismiss="alert" class="close" type="button">×</button><h4>Erreur de chargement</h4><p>'+a.msg+"</p></div>");$("#main").prepend(b.alert())}}),_minWind=a.minWind,_minWind&&c.hide(),config.aai&&config.aai.slo&&config.user&&config.user.shibboleth&&$("#adim-logout-but").click(function(a){a.preventDefault();var b=$(this).attr("href");$("<iframe>",{src:config.aai.urls.sp_logout}).appendTo("body").hide(),$("<iframe>",{src:config.aai.urls.idp_logout}).appendTo("body").hide(),setTimeout(function(){window.document.location.href=b},500)});var e=io.getAutoSave();config.ui.show_side_col?_sideCol.find(".side-col-collapse-but .btn").on("click",function(){toggleSideCol()}):_sideCol.hide(),updateReservedSpace();var f=function(){var a,b=c.find(".navbar-header"),d=c.find(".navbar-right"),e=c.find(".adim-image-name");return a=b.offset().left+b.outerWidth()+d.outerWidth()+(e.outerWidth()-e.width())+25,e.find(".text").css("max-width",_$w.width()-a),a}();!function(){var a=$("body"),b=a.outerWidth(),d=a.outerHeight(),e=_.debounce(function(){a.data("resize-fixed")||(a.css({width:b,maxWidth:b,minWidth:b,height:d,maxHeight:d,minHeight:d}),a.data("resize-fixed",!0))},50,!0),g=_.debounce(function(){a.css({width:"auto",maxWidth:"none",minWidth:0,height:"auto",maxHeight:"none",minHeight:0}),a.data("resize-fixed",!1),b=a.outerWidth(),d=a.outerHeight(),adjustCanvasToImage(),c.find(".adim-image-name .text").css("max-width",_$w.width()-f)},100);_$w.on("resize",function(){e(),g()})}(),$("#side-col-panel-group .panel-collapse").on("hidden.bs.collapse shown.bs.collapse",function(){_adjustCanvasFrame()}),$(".adim-view-mod-tabs li").on("click","a",function(a){var b=$(a.target),c=$(a.delegateTarget),d=b.data("adimMode");return d?(a.preventDefault(),c.hasClass("active")?!1:void updateViewMode(d)):!0}),$(".adim-view-mod-tabs").find("[data-toggle=tooltip]").tooltip({placement:"bottom",delay:{show:1500,hide:50}}),$("#but-zoom-fit").on("click",zoomFitContent),$("#but-zoom-100").on("click",function(a){a.preventDefault(),attributes.setZoom(1,"center")}),config.user.guest||config.annotable.locked||config.annotable.ttpShared?$("a.adim-image-name").on("click",function(a){a.preventDefault()}):(this._anObjNameModal=$("#adim-name-modal").modal({show:!1}),this._anObjNameModal.find("button.btn-primary").on("click",function(a){a.preventDefault(),io.setAnnotableName(config.annotable.id,b._anObjNameModal.find("input[name=imageName]").val()).done(function(){b._anObjNameModal.modal("hide")}).fail(function(a,c){var d=a.responseJSON.name||a.responseJSON.detail||c;b._anObjNameModal.find(".errors").removeClass("hide").find(".error-text").text(d)})}),this._anObjName=$("a.adim-image-name").on("click submit",function(a){a.preventDefault(),b._anObjNameModal.find(".errors").addClass("hide").end().find("input[name=imageName]").val(b._anObjName.find(".text").text()).end().modal("show")}).append($('<span style="font-size: 12px;" class="glyphicon glyphicon-pencil"></span>'))),$(".aom-show-but").on("click",function(a){_showAnObjMgr.call(b,a)}),function(){var a=$("#dlg-publish-mode").modal({show:!1}),b=$("#annotation-sharing-panel");b.find("[data-toggle=tooltip]").tooltip({viewport:"#annotation-sharing-container",container:"#annotation-sharing-container",placement:"bottom",delay:{show:500,hide:100}}).end().find(".adim-sha-publish-mode-but").on("click",function(){var b;try{b=config.user.membership.publish_mode}catch(c){b=0}a.find("form input[name=publish-mode]").val([b]),a.modal("show")}),a.find(".modal-footer .save-publish-mode-but").on("click",function(){var c=b.data("publishState"),d=a.find("form input[name=publish-mode]:checked").val();return c==d?void a.modal("hide"):void $.ajax({url:config.api.annotables+config.annotable.id+"/set_publish_mode/",type:"PATCH",contentType:"application/json; charset=utf-8",dataType:"json",data:JSON.stringify({publish_mode:d})}).done(function(a){config.user.membership.publish_mode=a.publish_mode,b.data("publishState",a.publish_mode).attr("data-publish-state",a.publish_mode)}).fail(function(){}).always(function(){a.modal("hide"),a.find("form input[name=publish-mode]").val([config.user.membership.publish_mode])})})}(),io.events.annotableChanged.add(function(a){if(a.id===config.annotable.id&&b._anObjName.find(".text").text(a.name),b._anObjMgr){var c=b._anObjMgr.anobjs.findWhere({id:a.id});c&&c.set("name",a.name)}}),function(a){var b={placement:"bottom",delay:{show:750,hide:50}},c=a.find(".annot-stat.annot-stat-error"),d=-1,e=5e3,f=!1;a.find(".annot-saved-status").find("[data-toggle=tooltip]").tooltip(b),io.events.annotationsSavedStatusChanged.add(function(g){$(".annot-saved-status").removeClass("stat-saved stat-dirty stat-error").addClass("stat-"+(g.status||"error")),"error"===g.status?Date.now()-d>e?f||c.popover({trigger:"manual"}).on("shown.bs.popover",function(){c.tooltip("destroy"),a.find(".annot-saved-status").find(".popover").on("click",function(){c.popover("destroy")}),f=!0}).on("hidden.bs.popover",function(){c.tooltip(b).off("click"),d=Date.now(),f=!1}).popover("show"):d=Date.now():"saved"===g.status&&(d=-1)})}(c),$("#btn-export-image-png").on("click",function(a){a.preventDefault(),_export("png")}),$("#btn-export-image-svg").on("click",function(a){a.preventDefault(),_export("svg")}),$("#adim-about-but").on("click",function(a){a.preventDefault(),$("#dlg-about-adim").modal()}),initPropertiesPanel();var g=updateViewMode(),h=a.locked||"review"===g;initTools({disabled:a.locked,ro:h}),initAttributes({disabled:a.locked}),tools.activateTool("select")}function updateViewMode(a){var b,c=$(".adim-view-mod-tabs"),d=document.location.hash.split(":")[0],e="";if(0!==c.length)return-1===["edit","review"].indexOf(a)&&(b=c.find("a[href='"+d+"']"),a=1===b.length?b.data("adimMode"):"edit"),b&&b.length||(b=c.find("a[data-adim-mode="+a+"]")),e=b.attr("href"),_minWind&&(e+=":m"),c.find("li.active").removeClass("active"),b.closest("li").addClass("active"),window.history.replaceState(null,"",e),$(".adim-view").removeClass("adim-view-review adim-view-edit").addClass("adim-view-"+a),config.mode=a,updateReservedSpace(),adjustCanvasToImage(),tools.activateTool("select"),tools.setRo(config.annotable.locked||"review"===a),"review"===a?c.data("loaded")?view.toggleMembersLayers(!0):io.loadSharedAnnotations(config.api.annotables+config.annotable.id+"/shared/annotations/").done(function(a){c.data("loaded",!0),$.ajax({url:config.api.annotables+config.annotable.id+"/members/",dataType:"json"}).done(function(a){Users.addUsers(a.users)}).always(function(){view.loadAnnotations(a,null)})}):"edit"===a&&view.toggleMembersLayers(!1),_events.modeChanged.dispatch({mode:a}),a}function toggleSideCol(a){if(_sideCol.is(":visible")){var b,c;"undefined"==typeof a&&(a=_sideCol.is(".collapsed"),b=["width",_sideCol.css("transition-duration"),_sideCol.css("transition-timing-function"),_sideCol.css("transition-delay")].join(" ")),_sideCol.toggleClass("collapsed",!a),updateReservedSpace(),b&&(_canvasCtnr.css("transition",b),_canvasToolBar.css("transition",b),c=_canvas.css("border-color"),_canvas.css("border-right-color","transparent")),adjustCanvasToImage(),b&&setTimeout(function(){_canvasCtnr.css("transition",""),_canvasToolBar.css("transition",""),_canvas.css("border-right-color",c)},300)}}function initTools(a){a=$.extend({},{disabled:!1,ro:!1},a||{}),tools.setRo(a.ro),$("[data-tool-name]").each(function(){var b=$(this),c=b.data("toolName");a.disabled||void 0===tools.getTool(c)?b.attr("disabled","disabled").parent(".btn").addClass("disabled"):b.on("change",function(){var a=$(this).data("toolName");tools.activateTool(a)}),$(this).data("toolName")===config.ui.initial_tool&&$(this).click()})}function enableTool(a,b){b=_.isUndefined(b)?!0:b;var c=tools.getActiveTool();_.each(a.split(","),function(a){var d=$("#draw-tool-tb").find('[data-tool-name="'+a+'"]');0!==d.length&&(b?d.removeAttr("disabled").parent(".btn").removeClass("disabled"):(a===c&&tools.activateTool("select"),d.attr("disabled","disabled").parent(".btn").addClass("disabled")))})}function disableTool(a,b){return enableTool(a,_.isUndefined(b)?!1:b)}function initAttributes(a){a=$.extend({},{disabled:!1},a||{});var b=$("#attr-orderup"),c=$("#attr-orderdown");a.disabled?(b.attr("disabled","disabled"),c.attr("disabled","disabled")):(b.click(function(a){a.shiftKey?attributes.bringFrontward():attributes.bringToFront()}),c.click(function(a){a.shiftKey?attributes.sendBacktward():attributes.sendToBack()})),setupColorSelector(a.disabled),a.disabled?$("#tool-fill-color").attr("disabled","disabled"):$("#tool-fill-color").removeAttr("disabled").click(function(){var a=!$(this).is(".active");attributes.setFill(a)}),a.disabled?$("#attr-font").attr("disabled","disabled"):$("#attr-font").removeAttr("disabled").popover({title:'Propriétés des textes <button type="button" class="close" style="margin:-9px">&times;</button>',html:!0,container:"body",trigger:"click",delay:0,content:'<div style="width:160px"><label style="float:left; line-height: 35px" class="small text-muted">Taille: &nbsp;</label><div class="input-group" style="width: 70px;"><input type="text" size="10" class="form-control" name="fontSize" id="attr-font-size"></div></div>'}).on("shown.bs.popover",function(){var a=this,b=$(a).data("bs.popover").$tip,c=b.find("input[name=fontSize]").focus();c.spinedit({value:attributes.getFontSize(),minimum:9,maximum:999,step:1,numberOfDecimals:0}).on("valueChanged",function(a){attributes.setFontSize(parseInt(a.value,10))});var d=function(c){var d=c.target===a||$(c.target).closest(".popover").get(0)===b.get(0);d||e()},e=function(){$(document).unbind("click",d),$("#attr-font").popover("hide")};b.find(".close").on("click",e),$(document).bind("click",d)}),_widthSlider=$("#attr-size-slider").toggleClass("disabled",a.disabled).find(".slider").slider({min:1,max:50,step:1,orientation:"vertical",value:paper&&paper.projet?paper.project.currentStyle.strokeWidth:5,tooltip:a.disabled?"hide":"show",selection:"none",reversed:!0,enabled:!a.disabled}).on("slide",function(a){attributes.setStrokeWidth(a.value,!1)}).on("slideStop",function(a){attributes.setStrokeWidth(a.value,!0)}),attributes.events.strokeWidthChanged.add(function(a){_widthSlider.slider("setValue",a)}),_opacitySlider=$("#attr-opacity-slider").toggleClass("disabled",a.disabled).find(".slider").slider({min:0,max:100,step:10,orientation:"vertical",value:100,tooltip:a.disabled?"hide":"show",formatter:function(a){return a+" %"},selection:"none",reversed:!0,enabled:!a.disabled}).on("slide",function(a){attributes.setOpacity(a.value,!1)}).on("slideStop",function(a){attributes.setOpacity(a.value,!0)});var d,e=$("#attr-zoom"),f=e.find("input[name=zoomLevel]").val(100).on("blur",function(){var a=$(this);a.val(parseInt(parseFloat($(this).val()))+" %")}).on("focus",function(){var a=$(this);a.val(parseInt(parseFloat($(this).val())))}).on("change",function(){var a=parseInt(parseFloat($(this).val()));isNaN(a)||attributes.setZoom(a/100)}),g=e.find(".slider").slider({selection:"none",value:100,enabled:!a.disabled,tooltip:a.disabled?"hide":"show",formater:function(a){return a+"%"}}).on("slide",function(a){var b=parseInt(a.value,10);attributes.setZoom(b/100)});_canvas.on("mousewheel",function(b){if(b.ctrlKey){if(b.preventDefault(),!a.disabled){var c=_widthSlider.slider("getValue")+Math.min(1,Math.max(-1,b.deltaY));_widthSlider.slider("setValue",c),attributes.setStrokeWidth(c,!1),d&&clearTimeout(d),d=setTimeout(function(){attributes.setStrokeWidth(c,!0)},500)}}else b.metaKey?(b.preventDefault(),attributes.deltaZoom(b.deltaY/20,[b.offsetX,b.offsetY],2)):b.altKey?(b.preventDefault(),attributes.deltaStrokeWidth(b.deltaY/20)):(b.preventDefault(),attributes.deltaZoom(b.deltaY,[b.offsetX,b.offsetY]))}),attributes.events.zoomChanged.add(function(a){var b=Math.floor(100*a);f.val(b+" %"),g.slider("setValue",b)})}function zoomFitContent(){var a=view.getLayerByName("image"),b=a.children[1];if(b){var c=paper.view.viewSize.divide(b.size);attributes.setZoom(Math.min(c.width,c.height),"center"),paper.view.draw()}}function updateUserLayers(){config.ui.show_users_results&&($.each(view.getAllUsersLayers(),function(a,b){0==usersList.find("li[data-layer-id="+b.id+"]").length&&$(layerListItemTpl({id:b.id,visibleClass:visibleClass,name:b.data.owner||b.name})).prependTo(usersList)}),showUserLayerName(!$("#btn-layers-hidenames").hasClass("active")))}function onUserLayerVisChange(a,b){updateUserLayerState(getListItem(a),b)}function showUserLayerName(a){a=_.isUndefined(a)?!0:!!a,usersList.find(".list-group-item .layer-title").each(function(b,c){var d=$(c);d.text(a?d.data("name"):"Utilisateur "+(b+1))})}function selectLayerListItem(a,b){var c=$(a),d=c.data("layerId");if(!c.hasClass("selected")){var e=usersList.find(".list-group-item.selected");b&&(e.each(function(a,b){toggleLayer($(b),!1)}),toggleLayer(c,!0)),e.removeClass("selected"),c.addClass("selected");var f=view.getLayerByName(d);f&&(f.activate(),_events.userLayerActivated.dispatch({layer:f,userId:d}))}}function updateUserLayerState(a,b){a.toggleClass("layer-hidden",!b).find(".layer-status").toggleClass(hiddenClass,!b).toggleClass(visibleClass,b)}function toggleLayer(a,b){view.toggleLayer(a.data("layerId"),b)}function toggleAll(a){var b=a;usersList.find(".list-group-item").each(function(c,d){b=$(d).is(".selected")?!0:a,toggleLayer($(d),b)})}function _adjustCanvasFrame(){var a=_canvas.width(),b=_canvas.height();_canvasToolBar.css("width",a+4),_canvasCtnr.width(a+2).height(b+2),_sideCol.height(b+_canvasToolBar.outerHeight()+5);var c;_annotationListCtnr.length>0&&(c=b+_canvasCtnrTop-_annotationListCtnr.offset().top,_annotationListCtnr.css("maxHeight",Math.max(c,80))),_markerLabelListCtnr.length>0&&(c=b+_canvasCtnrTop-_markerLabelListCtnr.offset().top,_markerLabelListCtnr.css("maxHeight",Math.max(c,180))),_sharedMarkerLabelListCtnr.length>0&&(c=b+_canvasCtnrTop-_sharedMarkerLabelListCtnr.offset().top,_sharedMarkerLabelListCtnr.css("maxHeight",Math.max(c,180)))}function updateColorSelector(a){if("string"!=typeof a){if(!a||"function"!=typeof a.toCSS)return;a=a.toCSS()}_colorSelector.find(" > button").css("color",a),$("#tool-fill-color").css("color",a)}function setupColorSelector(a){if(a)_colorSelector.find(".tinter").attr("disabled","disabled"),updateColorSelector("#999");else{var b=null;_colorSelector.find(".tinter").removeAttr("disabled"),_colorSelector.find(".picker").colorpicker().on("mouseup",function(){var a=$(this).data("colorpicker"),b=a.picker;if(b.hasClass("colorpicker-visible")){var c=a.color.toRGB(),d="rgba("+c.r+", "+c.g+", "+c.b+", "+c.a+")";updateColorSelector(d),attributes.setColor(d),setTimeout(function(){_colorSelector.find(".picker").colorpicker("hide"),_colorSelector.find(".color-menu").dropdown("toggle")},100)}}).on("changeColor",function(a){var c=a.color.toRGB(),d="rgba("+c.r+", "+c.g+", "+c.b+", "+c.a+")";updateColorSelector(d),_colorSelector.find(".color-menu .cx").css("background-color",d),attributes.setColor(d,!1),b&&clearTimeout(b),b=setTimeout(function(a){return function(){attributes.setColor(a,!0)}}(d),1e3)}),_colorSelector.find(".color-menu > li > a").click(function(a){var b=$(this);if(a.preventDefault(),!b.is(".cx")){var c=b.css("background-color");updateColorSelector(c),attributes.setColor(c)}}),attributes.getColor()&&updateColorSelector(attributes.getColor().toCSS())}}function disableProperties(a){for(var b in itemProperties)a&&itemProperties[b].setValue(""),itemProperties[b].enable(!1)}function displayProperties(a){var b=!1;if(a&&a.data&&a.data.prop)for(var c in itemProperties)b=a.data.prop.hasOwnProperty(c)||"fill"===c,b?itemProperties[c].enable().setValue(a.data.prop[c]):itemProperties[c].enable(!1);else disableProperties()}function updateSelectedItemProp(a){if(a&&"string"==typeof a){var b=itemProperties[a].getValue(),c=!1;return null!==b&&void 0!==b&&(c=view.setSelectedItemProperty(a,b,!0)),c}}function onPropertyChange(a){updateSelectedItemProp(a.data.pName)}function onPropertyBlur(){}function initPropertiesPanel(){_.each(itemProperties,function(a,b){if("string"==typeof a.el){var c=$(a.el);1===c.length?(a.el=c,_.isFunction(a.init)&&a.init(),_.isFunction(a.onChange)?c.on("change",a.onChange):c.on("change",null,{pName:b},onPropertyChange),_.isFunction(a.onBlur)?c.on("blur",a.onBlur):c.on("blur",null,{pName:b},onPropertyBlur)):delete itemProperties[b]}}),disableProperties(!0),$(document).on("keydown",function(a){$("*:focus");switch(a.which){case 49:case 50:case 51:}})}function onToolActivated(a){var b=$("[data-tool-name]").filter("[checked=checked]"),c=$("[data-tool-name="+a+"]");$("[data-tool-name]").button(),b.get(0)!==c.get(0)&&(b.removeAttr("checked").parent(".btn").removeClass("active"),c.attr("checked","checked").parent(".btn").addClass("active")),_canvas.removeClass(function(a,b){var c=b.split(" ").filter(function(a){return a.match(/cursor-tool-/)});return c&&c.join(" ")}).addClass("cursor-tool-"+a)}function adjustCanvasToImage(){var a=_$w.width(),b=_$w.height(),c=a-_reservedWidth,d=320,e=b-_reservedHeight,f=240;a=Math.max(Math.min(a,c),d),b=Math.max(Math.min(b,e),f),view.resize(a,b),_adjustCanvasFrame()}function _showAnObjMgr(a){var b=this;a.preventDefault(),b._anObjMgr||(b._anObjMgr=new AnObjMgr({el:"#aom-modal",aomListCtner:$("#aom-user-images-list .aom-list-container"),sharedAomListCtner:$("#aom-shared-images-list .aom-list-container")})),b._anObjMgrModal||(b._anObjMgrModal=$("#aom-modal").data("loaded",!1).modal({show:!1})),b._anObjMgrModal.modal("show"),b._anObjMgrModal.data("loaded")||b._anObjMgr.loadAnObjs({success:function(){b._anObjMgrModal&&(b._anObjMgrModal.find(".aom-loader").remove(),b._anObjMgrModal.data("loaded",!0)),b._anObjMgr.selectCurrent()}})}function updateCurrentThumbnail(thumbnailPath){if(this._anObjMgrModal){var curItemImg=this._anObjMgrModal.find(".aom-list-item.current img");curItemImg&&0!==curItemImg.length&&(thumbnailPath&&""!==thumbnailPath||(thumbnailPath=eval("(function(){function url(u){return u}return "+curItemImg.css("backgroundImage")+"})()").split("?")[0]),curItemImg.css("backgroundImage",'url("'+thumbnailPath+"?nc=_"+(""+Math.random()).substr(3)+'")'))}}function _export(a){var b=config.annotable.slug+"__"+(config.mode===config.MODE_EDIT?config.user.username:"review");switch(a){case"png":exporter.export(b,"png",{callback:function(){adjustCanvasToImage()}}).done(function(){});break;case"svg":exporter.export(b,"svg")}}function setState(a){switch(a){case"thumbNotSaved":break;case"thumbSaved":this.updateCurrentThumbnail()}}var _$w=$(window),_canvas=null,_canvasCtnr=null,_canvasToolBar=null,_sideCol=null,_toolsCol=null,_minWind=!1,_annotationListCtnr=null,_markerLabelListCtnr=null,_sharedMarkerLabelListCtnr=null,_canvasCtnrTop,_colorSelector=$("#tool-colorselect"),_opacitySlider,_widthSlider,_reservedWidth=0,_reservedHeight=0,_events={modeChanged:new Signal,saveButClick:new Signal,autoSaveChanged:new Signal,userLayerActivated:new Signal},updateReservedSpace=function(){var a=$("#canvas-col").offset().top,b=_toolsCol.outerWidth(),c=_canvasToolBar.outerHeight();(updateReservedSpace=function(){_reservedWidth=(_toolsCol.is(":visible")?b:0)+(config.ui.show_side_col?_sideCol.is(".collapsed")?32:_sideCol.outerWidth():50)+24,_reservedHeight=a+c+20})()},usersListPanel=$("#annotation-list-panel"),usersListCtr=$("#annotation-list-container"),usersList=usersListCtr.find(" > ul"),hiddenClass="icon-eye-close",visibleClass="icon-eye-open",layerListItemTpl=_.template(['<li class="list-group-item" data-layer-id="<%= id %>">','<span class="layer-status <%= visibleClass %>"></span>','<span class="layer-title" data-name="<%= name %>"><%= name %></span>',"</li>"].join("")),getListItem=_.memoize(function(a){return usersList.find("li[data-layer-id="+a.id+"]")},function(a){return a.id});usersList.on("click",".layer-status",function(a){a.stopPropagation();var b=$(this),c=b.parent(".list-group-item");toggleLayer(c)}),usersList.on("click",".list-group-item",function(){selectLayerListItem(this,!1),toggleLayer($(this),!0)}),$("#btn-layers-hideall").click(function(){toggleAll(!1)}),$("#btn-layers-showall").click(function(){toggleAll(!0)}),$("#btn-layers-next").click(function(){var a=usersList.find(".list-group-item.selected").next();1===a.length&&selectLayerListItem(a,!0)}),$("#btn-layers-prev").click(function(){var a=usersList.find(".list-group-item.selected").prev();1===a.length&&selectLayerListItem(a,!0)}),$("#btn-layers-hidenames").on("click",function(){var a=$(this);a.toggleClass("active"),showUserLayerName(!a.hasClass("active"))});var transparentColor=new paper.Color(1,1,1,0),itemProperties={confidence:{el:"#confidence-input",enable:function(a){return a=void 0!==a?!!a:!0,this.el.attr("disabled")&&!a?this:(this.el.rating(a?"enable":"disable"),this.el.closest(".property-group").toggleClass("disabled",!a),config.mode!==config.MODE_EDIT&&this.el.rating("disable"),this)},setValue:function(a){return a=parseInt(a,10),isNaN(a)?void 0:(config.mode===config.MODE_EDIT?this.el.val(a).siblings("[data-value]").trigger("mouseleave"):this.el.siblings("[data-value]").each(function(b,c){var d=$(c);d.toggleClass("label-warning rating-on",d.data("value")<=a).toggleClass("rating-off",d.data("value")>a)}),this)},getValue:function(){var a=parseInt(this.el.val(),10);return isNaN(a)?null:a},init:function(){}},fill:{el:"#fill-check",enable:function(a){return a=void 0!==a?!!a:!0,config.mode!==config.MODE_EDIT&&(a=!1),a?this.el.removeAttr("disabled"):this.el.attr("disabled","disabled"),this.el.closest(".property-group").toggleClass("disabled",!a),this},setValue:function(a){return a=!!a,this.el.prop("checked",a),this},getValue:function(){return!!this.el.prop("checked")},onChange:function(){for(var a,b=$(this).is(":checked"),c=!1,d=view.getSelectedAnnotations(),e=0;a=d[e];e++)if("function"!=typeof a.data.setColor){if(a.data&&a.data.prop&&a.data.prop.fill===b)continue;c=!0,a.fillColor=b?paper.project.currentStyle.fillColor:null,paper.view.draw()}var f=updateSelectedItemProp("fill");c&&!f&&tools.events.annotationChanged.dispatch(d)},init:function(){}},comment:{el:"#prop-annot-comment",enable:function(a){return a=void 0!==a?!!a:!0,("review"===config.mode||config.annotable&&config.annotable.locked)&&(a=!1),a?this.el.removeAttr("disabled"):this.el.attr("disabled","disabled"),this.el.closest(".property-group").toggleClass("disabled",!a),this},setValue:function(a){return this.el.val(a),this},getValue:function(){return this.el.val()},init:function(){var a=this,b=null;a.el.on("keyup",function(){b&&clearTimeout(b),b=setTimeout(function(){updateSelectedItemProp("comment"),b=null},500)})}},nbConcordances:{el:"#prop-annot-nbconcordance",enable:function(a){return a=void 0!==a?!!a:!0,a||this.setValue(""),this.el.closest(".property-group").toggleClass("disabled",!a),this},setValue:function(a){return this.el.text(a),this},getValue:function(){return this.el.text()}},category:{el:"#prop-annot-category",enable:function(a){return a=void 0!==a?!!a:!0,this.el.find(".btn-cat").toggleClass("disabled",!a),this.el.closest(".property-group").toggleClass("disabled",!a),a||this.el.find(".btn-cat.active").removeClass("active"),this},init:function(){this.el.find(".btn-cat").addClass("disabled")},setValue:function(a){a=a||"cat_0",this.el.find(".btn-cat.active").removeClass("active"),this.el.find(".btn-cat[data-category='"+a+"']").addClass("active")},getValue:function(){var a=this.el.find(".btn-cat.active");return 1===a.length?a.data("category"):""}}};tools.events.activated.add(onToolActivated);var _raster=null;return{init:init,events:_events,updateUserLayers:updateUserLayers,showUserLayerName:showUserLayerName,displayProperties:displayProperties,updateReservedSpace:updateReservedSpace,adjustCanvasToImage:adjustCanvasToImage,exporter:exporter,updateCurrentThumbnail:updateCurrentThumbnail,setState:setState,enableTool:enableTool}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('helper/theme',["jquery"],function(a){var b={updateTheme:function(b){b=b||localStorage.getItem("adimTheme")||"dark",a("body").toggleClass("theme-light","light"===b).toggleClass("theme-dark","dark"===b),a("#main-navbar").toggleClass("navbar-inverse","dark"===b).toggleClass("navbar-default","light"===b).find(".btn-adim-dark, .btn-default").toggleClass("btn-adim-dark","dark"===b).toggleClass("btn-default","light"===b),a("#side-col").find(".panel").toggleClass("panel-dark","dark"===b).toggleClass("panel-default","light"===b)},setTheme:function(a){return!a||"dark"!==a&&"light"!==a||(localStorage.setItem("adimTheme",a),updateTheme()),!1}};return b});
/*!
* jQuery UI Widget 1.10.4+amd
......@@ -17797,9 +17797,9 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
 
}));
 
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('helper/fileUploader',["jquery","jquery.fileupload","jquery.iframe-transport","jquery.fileupload-proc"],function(a){function b(b){b=a.extend(!0,{elem:"#fileupload",progBar:".progress-bar",alertBox:".adim-fu-error-box",acceptFileTypes:/(\.|\/)(jpe?g|png)$/i,maxFileSize:2*Math.pow(2,20),dropZone:a(document),onStart:null,processstart:null,autoUpload:!0,sequentialUploads:!1,add:null},b),a(function(){function c(a){a.preventDefault()}var d=a(b.elem),e=a(b.progBar),f=a(b.alertBox);d.fileupload({dataType:"json",dropZone:b.dropZone,autoUpload:b.autoUpload,done:function(b,c){1===a(b.target).fileupload("active")&&!c.result.error&&c.result.next&&document.location.assign(c.result.next)},processstart:function(){"function"==typeof b.processstart&&b.processstart(b)},start:function(){f.find("[class^=adim-fu-error-]").addClass("hide").end().addClass("hide"),e.closest(".progress-wrapper").removeClass("hide"),a("#fileupload").fileupload("disable"),a(document).on("drop dragover",c),"function"==typeof b.onStart&&b.onStart(b)},progressall:function(a,b){var c=parseInt(b.loaded/b.total*100,10),d=c+"%";e.text(d).css("width",d)},processQueue:[{action:"validate",always:!0,acceptFileTypes:b.acceptFileTypes,maxFileSize:b.maxFileSize}],processfail:function(b,d){var e=d.files[d.index].error;f.find("[class^=adim-fu-error-]").addClass("hide"),f.removeClass("hide").find(".adim-fu-error-"+e).removeClass("hide"),a(document).off("drop dragover",c),a("#fileupload").fileupload("enable")}}),"function"==typeof b.add&&d.fileupload("option","add",b.add)})}return a.widget("blueimp.fileupload",a.blueimp.fileupload,{processActions:{validate:function(b,c){if(c.disabled)return b;var d=a.Deferred(),e=b.files[b.index];return c.acceptFileTypes.test(e.type)?e.size>c.maxFileSize?(b.files[b.index].error="maxFileSize",d.rejectWith(this,b)):d.resolveWith(this,b):(b.files[b.index].error="acceptFileTypes",d.rejectWith(this,b)),d.promise()}}}),{initialize:b,init:b}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('adim/main-newao',["jquery","paper","signals","adim/config","adim/view","adim/io","adim/attributes","adim/ui","helper/theme","helper/fileUploader"],function(a,b,c,d,e,f,g,h,i,j){a(function(){return i.updateTheme(),e.init("my-canvas")?(h.init({ro:!0,locked:!0}),h.adjustCanvasToImage(1),a("#page-loader").fadeOut(100),j.init({elem:"#fileupload",progBar:".adim-fu-status .progress-bar",alertBox:".adim-fu-status .adim-fu-error-box",acceptFileTypes:/(\.|\/)(jpe?g|png)$/i,maxFileSize:d.uploadMaxFileSize,dropZone:a(document)}),void j.init({elem:"#fileupload-alt",progBar:"#adim-fu-alt-status .progress-bar",alertBox:"#adim-fu-alt-status .adim-fu-error-box",acceptFileTypes:/(\.|\/)(jpe?g|png)$/i,maxFileSize:d.uploadMaxFileSize,dropZone:null,processstart:function(){a("#adim-fu-alt-status").modal("show")}})):void(console&&console.error&&console.error("View not initialized. Abort."))})});
/**
* Copyright (C) 2014 Université de Lausanne, RISET,
......
......@@ -12797,7 +12797,7 @@ _addBinding:function(a){var b=this._bindings.length;do--b;while(this._bindings[b
!0,b,c)},remove:function(a,b){g(a,"remove");var c=this._indexOfListener(a,b);c!==-1&&(this._bindings[c]._destroy(),this._bindings.splice(c,1));return a},removeAll:function(){for(var a=this._bindings.length;a--;)this._bindings[a]._destroy();this._bindings.length=0},getNumListeners:function(){return this._bindings.length},halt:function(){this._shouldPropagate=!1},dispatch:function(a){if(this.active){var b=Array.prototype.slice.call(arguments),c=this._bindings.length,d;if(this.memorize)this._prevParams=
b;if(c){d=this._bindings.slice();this._shouldPropagate=!0;do c--;while(d[c]&&this._shouldPropagate&&d[c].execute(b)!==!1)}}},forget:function(){this._prevParams=null},dispose:function(){this.removeAll();delete this._bindings;delete this._prevParams},toString:function(){return"[Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}};var f=e;f.Signal=e;typeof define==="function"&&define.amd?define('signals',[],function(){return f}):typeof module!=="undefined"&&module.exports?module.exports=f:i.signals=
f})(this);
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('adim/config',["jquery"],function(a){var b="ADIM_CONFIG",c=a.extend(!0,{MODE_EDIT:"edit",MODE_REVIEW:"review",MODE_ANALYSIS:"analysis",adim_global_varname:"ADIM",annotable:{image:"image/",thumbnail:"thumb/"},image_url:"",autoSaveThumbnail:!0,io:{},activeTools:[],userEngine:{limit:7,remoteUrl:"http://path/to/suggestion/url/?q=%QUERY",rateLimitWait:300},aai:{slo:!1,urls:{sp_logout:"https://jabba.unil.ch/Shibboleth.sso/Logout",idp_logout:"https://aai.unil.ch/idp/logout.jsp"}},ui:{show_side_col:!0,show_users_results:!1,show_annot_properties:!0},uploadMaxFileSize:2},window[b]||{},!0);if(!c.activeTools||0==c.activeTools.length)try{c.activeTools=a("#draw-tool-tb [data-tool-name]").map(function(){return a(this).attr("data-tool-name")})}catch(d){c.activeTools=null}return c.csrfToken&&a.ajaxSetup({beforeSend:function(a){a.setRequestHeader("X-CSRFToken",c.csrfToken)}}),c});
// Underscore.js 1.8.3
// http://underscorejs.org
......@@ -13543,47 +13543,47 @@ define("bloodhound", ["jquery"], (function (global) {
};
}(this)));
 
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('adim/users',["jquery","underscore","bloodhound","adim/config"],function(a,b,c,d){function e(){i=new c({datumTokenizer:function(a){return c.tokenizers.nonword(a.username)},queryTokenizer:c.tokenizers.whitespace,limit:d.userEngine.limit,remote:{url:d.userEngine.remoteUrl,rateLimitWait:d.userEngine.rateLimitWait}}),i.initialize()}function f(b){a.isArray(b)&&b.length>=0&&i.add(b)}function g(a){var c=b.find(i.index.datums,function(b){return b.id==a});return c?c.username:""}function h(c){var d=a.Deferred(),e=b.find(i.index.datums,function(a){return a.id==c});return e?d.resolve(e.username):d.reject(),d}var i=null;return e(),{engine:i,addUsers:f,getById:g,searchById:h}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('helper/utils',["paper"],function(a){function b(a,b){b=b===!0,a&&(a.data&&a.data.selectListeners&&a.attach(a.data.selectListeners),b&&"function"==typeof a.setSelected&&a.setSelected(!0))}function c(b,c){c=c?c:a.project.getSelectedItems(),b=b===!0;for(var d,e=0;d=c[e];e++)d.data&&d.data.selectListeners&&d.detach(d.data.selectListeners),b&&(d.fullySelected=d.selected=!1)}function d(){var b=[];return a.project.getSelectedItems().map(function(a){a.parent&&a.parent.data&&a.parent.data.type&&-1===b.indexOf(a.parent)?b.push(a.parent):a.data&&a.data.type&&-1===b.indexOf(a)&&b.push(a)}),b}function e(a){g=a}function f(a){g&&$.each(g,function(b,c){$.isArray(c)||(c=[c]);for(var d=0,e=c.length;e>d;d++){var f=c[d].fn;if("function"!=typeof f)return;var g=c[d].ctxt&&c[d].ctxt.split(" "),h=c[d].event||"keydown";$(document).unbind(h,f),(!g||g.indexOf(a)>-1)&&$(document).bind(h,{keys:b},f)}})}var g=null;return{addSelectListeners:b,removeSelectListeners:c,getSelectedAnnotations:d,initShortcuts:e,setShortcutsContext:f}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/select',["paper","adim/config","helper/utils"],function(a,b,c){function d(a,b){var c=a.hitTest(b.point,p);switch(k=l=m=null,x=y=z=A=null,c.type){case"handle-in":case"handle-out":if(a.selected){var d=c.type.split("-");m=d[1],k=c.segment}break;case"segment":k=c.segment;break;case"fill":case"stroke":b.modifiers.shift||(a.data&&"function"==typeof a.data.setDragMode?a.data.setDragMode("FULL_DRAG",{item:c.item}):l=!0);break;case"bounds":var e=c.name.split("-");if(["shape","ellipse","rectangle","circle"].indexOf(c.item.type)>-1)if("center"===e[0]||"center"===e[1])a.data.setDragMode("FULL_DRAG",{item:a});else{var f="bottom"===e[0]?"top":"bottom";f+="left"===e[1]?"Right":"Left";var g=["right"===e[1]?1:-1,"bottom"===e[0]?1:-1];c.item.data.setDragMode.call(c.item,"DRAG_HANDLE",{nameStr:c.name,nameParts:e,item:c.item,fixedPt:c.item.bounds[f],resizeDir:g})}else if("arrow"===c.item.data.type&&"right"===e[1])try{c.item.data.setDragMode.call(c.item,"DRAG_HANDLE",{nameStr:c.name,nameParts:e})}catch(h){}else if("text"===c.item.data.type)if("center"===e[0]||"center"===e[1])a.data.setDragMode("FULL_DRAG",{item:a});else try{c.item.data.setDragMode.call(c.item,"DRAG_HANDLE",{item:c.item,nameStr:c.name,nameParts:e})}catch(h){}else if("lines"===c.item.data.type){for(var i,j,n,o=c.point,q=0,r=a.segments.length;r>q&&(j=o.getDistance(a.segments[q].point),(!n||i>j)&&(n=a.segments[q],i=j),0!=j);q++);n&&(k=n)}else"function"==typeof s.onMouseDown&&s.onMouseDown(b)}}function e(a){var b=a.point.subtract(k.point),c=a.lastPoint.subtract(k.point),d=b.angle-c.angle,e=!a.modifiers.option;"in"===m?(k.handleIn=b,e&&(k.handleOut.angle+=d)):(k.handleOut=b,e&&(k.handleIn.angle+=d))}function f(b){var c,d,e;c=new a.Rectangle({from:y,to:b.point}).size,b.event.shiftKey&&(e=x.bounds.size.width/x.bounds.size.height,c.height=c.width/e),d=c.subtract(x.bounds.size).multiply(z).divide(2),x.size=c,x.translate(d.width,d.height)}function g(a,b){a.data&&"function"==typeof a.data.itemMouseDrag?a.data.itemMouseDrag.call(a,b):x?f(b):m&&k.path.id===a.id?e(b):k&&k.path.id===a.id?k.point=b.point:l&&a.translate(b.delta),t=!0}function h(){}function i(a){return r=a,q=!a,a}var j,k,l,m,n="select",o={segments:!0,stroke:!0,fill:!0,tolerance:5,bounds:!1,handles:!1},p={segments:!0,stroke:!0,fill:!0,tolerance:5,bounds:!0,handles:!0},q=b.mode===b.MODE_EDIT,r=!q,s=null,t=!1,u={annotationAdded:null,annotationChanged:null,annotationSelected:null},v=null,w=[],x=null,y=null,z=[1,1],A=null,B={tolerance:7,fill:!0,stroke:!0,segments:!0,handles:!0,ends:!0,bounds:!0,selected:!0},C={onMouseDown:function(b){k=l=m=x=y=null;var e=r?a.project.hitTest(b.point,o):a.project.activeLayer.hitTest(b.point,B);if(e||(e=r?a.project.hitTest(b.point,o):a.project.activeLayer.hitTest(b.point,o)),!q)return a.project.deselectAll(),u.annotationSelected.dispatch(null),a.view.draw(),void(e&&"pixel"!==e.type&&(s=e&&e.item,s&&s.parent.data.type&&(s=s.parent),s.data.type&&(s.selected=!0),u.annotationSelected.dispatch(s)));var f=c.getSelectedAnnotations();if(1===f.length&&(!e||"pixel"===e.type||e.item.id!==f[0].id)){var g=a.project.activeLayer.hitTest(b.point,p);g&&g.item===f[0]&&(e=g)}var h=b.modifiers.shift&&q;if(s=e&&e.item,s&&s.parent&&s.parent.data&&s.parent.data.type&&(s=s.parent),s&&(s.selected||h)||(a.project.deselectAll(),u.annotationSelected.dispatch(null)),s){if(s.layer&&"image"===s.layer.name)return;s.selected?(t=!1,h&&"bounds"!==e.type?s.fullySelected=!1:s.responds("mousedown")&&"bounds"!==e.type?s.onMouseDown(b):d(s,b)):("group"===s.type?"function"==typeof s.oSetSelected?!s.selected&&s.oSetSelected(!0):s.children.map(function(a){a.selected=!0}):-1===["handle-in","handle-out"].indexOf(e.type)&&(s.selected=!0,s.responds("mousedown")&&s.onMouseDown(b)),q&&s.selected&&"path"===s.type),u.annotationSelected.dispatch(s)}w=c.getSelectedAnnotations()},onMouseDrag:function(a){if(q){var b=w;if(1===b.length)s.responds("mousedrag")||g(s,a);else{t=!0;for(var c,d=0;c=b[d];d++)c.parent&&c.parent.data&&c.parent.data.type&&(c=c.parent),c.data.type&&(c===s&&c.responds("mousedrag")||c.translate(a.delta)),c=null}}},onMouseUp:function(b){v&&(v.remove(),v=null);var c=[];a.project.getSelectedItems().map(function(a){-1===c.indexOf(a)&&(a.data.type?c.push(a):a.parent.data.type&&-1===c.indexOf(a.parent)&&c.push(a.parent))}),q&&(s&&1===c.length&&(s.responds("mouseup")?s.onMouseUp(b):h(s,b)),t&&(u.annotationChanged.dispatch(c),t=!1))},onKeyDown:function(b){var c=a.project.getSelectedItems();if(q)for(var d,e=0;d=c[e];e++)if(d.data.type&&"function"==typeof d.onKeyDown){d.onKeyDown(b);break}},onKeyUp:function(b){var c=a.project.getSelectedItems();if(q)for(var d,e=0;d=c[e];e++)if(d.data.type&&"function"==typeof d.onKeyUp){d.onKeyUp(b);break}}};return j=new a.Tool(C),{name:n,tool:j,setRo:i,registerEvent:function(a,b){u[a]=b},_tools:null}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/pan',["paper"],function(a){var b={onMouseDrag:function(b){var c=b.point.subtract(b.downPoint).multiply(-1);a.project.view.scrollBy(c),a.project.view.draw()},onMouseDown:function(){jQuery(a.view.element).addClass("cursor-tool-pan-down")},onMouseUp:function(){jQuery(a.view.element).removeClass("cursor-tool-pan-down")}};return{name:"pan",tool:new a.Tool(b)}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/drawing',["paper"],function(a){function b(b){b.data.prop="object"==typeof b.data.prop?b.data.prop:{};for(var d in k)b.data.prop.hasOwnProperty(d)||(b.data.prop[d]=k[d]);b.onPropertyChange=c,b.onDoubleClick=function(){i||(this.selected=!1,this.fullySelected=!0,a.view.draw())}}function c(b,c){"fill"===b&&(this.closed=c,a.view.draw())}function d(a){var b=this.selected,c=this.fullySelected;this.selected=this.fullySelected=!1;var d=this.exportJSON({asString:!1});return delete d[1].fontFamily,delete d[1].font,delete d[1].fontSize,delete d[1].leading,d=a&&a.asString===!1?d:JSON.stringify(d),this.fullySelected=c,this.selected=b,d}function e(a,c){var d=c.importJSON(a);return b(d),d}function f(a){return a!==i&&(i=a),i}var g="drawing",h=null,i=!1,j={annotationAdded:null,annotationSelected:null},k={comment:"",confidence:3,fill:!1},l={onMouseDown:function(b){a.project.deselectAll(),h=new a.Path({fillColor:null,strokeCap:"round"}),h.add(b.point)},minDistance:5,onMouseDrag:function(a){h&&h.add(a.point)},onMouseUp:function(){if(h){h.simplify(20);var c=h.clone();h.remove(),h=null,c.data.type=g,c.data.tId="a"+c._id,b(c),a.view.draw(),c.fullySelected=!0,"function"==typeof j.annotationSelected.dispatch&&j.annotationSelected.dispatch(c),"function"==typeof j.annotationAdded.dispatch&&j.annotationAdded.dispatch(c)}}};return{name:g,tool:new a.Tool(l),setRo:f,registerEvent:function(a,b){j[a]=b},exportJSON:d,importJSON:e}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/lines',["paper"],function(a){function b(a){var b=this.exportJSON({asString:!1});return 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(a,b){var c=b.importJSON(a);return d(c),c}function d(a){a.data.prop="object"==typeof a.data.prop?a.data.prop:{};for(var b in p)a.data.prop.hasOwnProperty(b)||(a.data.prop[b]=p[b]);a.onPropertyChange=e}function e(b,c){"confidence"===b?(this.style=q[c],a.view.draw()):"processus"===b||"fill"===b&&(this.closed=c,a.view.draw())}function f(){if(n=null,k&&k.remove(),i=!1,h.length>l){var b=h.clone();b.style=a.project.currentStyle,b.strokeCap="round",b.strokeJoin="round",b.fillColor=null,b.data.type=g,b.data.tId="a"+b._id,d(b),b.selected=!0,"function"==typeof o.annotationSelected.dispatch&&o.annotationSelected.dispatch(b),"function"==typeof o.annotationAdded.dispatch&&o.annotationAdded.dispatch(b)}h.remove()}var g="lines",h=null,i=!1,j=!1,k=null,l=5,m=!1,n=null,o={annotationAdded:null,annotationChanged:null},p={comment:"",confidence:3,fill:!1},q={1:{dashArray:[10,10]},2:{dashArray:[30,10]},3:{dashArray:null}},r={segments:!0,stroke:!0,tolerance:5},s={onMouseDown:function(b){if(i){if(h){if(b.point.subtract(b.lastPoint).length<l)return void f();k&&k.remove(),h.add(b.point)}}else{var c=a.project.activeLayer.hitTest(b.point,r);if(c&&c.item&&c.item.selected&&c.item.data.type===g)if(h=c.item,"stroke"===c.type){var d=c.location;k=h.insert(d.index+1,b.point),j=!0}else"segment"===c.type&&(b.modifiers.option?(c.segment.remove(),o.annotationChanged.dispatch(c.item)):(k=c.segment,j=!0));else a.project.deselectAll(),h=new a.Path({strokeColor:a.project.currentStyle.strokeColor||a.project.currentStyle.fillColor,fillColor:null,strokeCap:"round",strokeJoin:"round"}),i=!0,h.add(b.point)}},onMouseMove:function(b){i?(n=b.point,k&&k.remove(),k=new a.Path(b.downPoint,b.point),k.strokeColor=a.project.currentStyle.strokeColor||a.project.currentStyle.fillColor):j&&k&&(m=!0,k.point=b.point)},onMouseUp:function(){j&&(j=!1,k&&(m&&(m=!1,o.annotationChanged.dispatch(k.path)),k=null))},onKeyDown:function(a){switch(a.key){case"enter":i&&h&&(n&&h.add(n),f());break;case"escape":i&&h&&f()}}};return{name:g,tool:new a.Tool(s),registerEvent:function(a,b){o[a]=b},exportJSON:b,importJSON:c}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/Shape.class',["paper"],function(){return function(a,b){function c(a){var b=this.exportJSON({asString:!1});return delete b[1].fontFamily,delete b[1].font,delete b[1].fontSize,delete b[1].leading,a&&a.asString?JSON.stringify(b):b}function d(a,b){var c=b.importJSON(a);return h(c),c}function e(a){var b=["ellipse","rectangle"];return!!a&&a.data&&a.data.type&&b.indexOf(a.data.type)>-1}function f(b,c){var d;if(b.modifiers.shift)var e=o.subtract(p).length/1.414213,f=p.subtract(o).quadrant,g=2===f||3===f?-e:e,h=3===f||4===f?-e:e;switch(a){case"circle":d=new paper.Shape.Circle({center:o,radius:o.subtract(p).length});break;case"ellipse":d=new paper.Shape.Ellipse(b.modifiers.shift?{point:o,size:[g,h]}:{from:o,to:p});break;case"rectangle":d=new paper.Shape.Rectangle(b.modifiers.shift?{point:o,size:[g,h]}:{from:o,to:p})}return d.data.type=a,c&&d.set("style",c),d}function g(a){n&&n.remove(),q&&(n=f(a))}function h(a){a.data.prop="object"==typeof a.data.prop?a.data.prop:{};for(var b in v)a.data.prop.hasOwnProperty(b)||(a.data.prop[b]=v[b]);a.onPropertyChange=i,a.data.exportJSON=function(a){return function(b){return c.call(a,b)}}(a),a.data.setDragMode=l,a.data.itemMouseDrag=m}function i(a,b){"confidence"===a&&(this.style=w[b],paper.view.draw())}function j(a){var c,d;if(c=paper.project.activeLayer.hitTest(a,{tolerance:7,fill:!0,stroke:!0,bounds:!0,selected:!0}),c||(c=paper.project.activeLayer.hitTest(a,{fill:!0,stroke:!0})),!c||!e(c.item))return!1;if(d=c.item,d.selected||(paper.project.deselectAll(),d.selected=!0,b.annotationSelected.dispatch(d)),"bounds"===c.type&&"center"!==c.name.split("-")[1]){var f=c.name.split("-"),g="bottom"===f[0]?"top":"bottom";g+="left"===f[1]?"Right":"Left";var h=["right"===f[1]?1:-1,"bottom"===f[0]?1:-1];l("DRAG_HANDLE",{nameStr:c.name,nameParts:f,item:c.item,fixedPt:c.item.bounds[g],resizeDir:h})}else l("FULL_DRAG",{item:d});return!0}function k(a){var b,c,d;b=new paper.Rectangle({from:s.fixedPt,to:a.point}).size,a.event.shiftKey&&(d=s.item.bounds.size.width/s.item.bounds.size.height,b.height=b.width/d),c=b.subtract(s.item.bounds.size).multiply(s.resizeDir).divide(2),s.item.size=b,s.item.translate(c.width,c.height)}function l(a,b){!a in u?(r=null,s={},t=!1):(r=u[a],s=b)}function m(a){switch(t=!0,r){case u.FULL_DRAG:this.translate(a.delta);break;case u.DRAG_HANDLE:k(a)}}var n,o,p,q=!1,r=null,s={},t=!1,u={FULL_DRAG:1,DRAG_HANDLE:4},v={comment:"",confidence:3,fill:!0},w={1:{dashArray:[10,10]},2:{dashArray:[30,10]},3:{dashArray:null}};return{exportJSON:c,importJSON:d,onKeyDown:function(a){n&&g(a)},onKeyUp:function(a){g(a)},onMouseDown:function(a){q=t=!1,j(a.point)||(paper.project.deselectAll(),b.annotationSelected.dispatch(null),paper.project.deselectAll(),q=!0,o=a.point,p=o)},onMouseDrag:function(a){q?(p=a.point,g(a)):r&&s.item&&m.call(s.item,a)},onMouseUp:function(a){if(q){if(p=a.point,g(a),q=!1,n&&n.remove(),n=null,a.delta.length>5){var c=f(a);c.data.tId="a"+c._id,c.selected=!0,h(c),b&&"function"==typeof b.annotationAdded.dispatch&&b.annotationAdded.dispatch(c)}paper.view.draw()}else t&&s.item&&(b.annotationChanged.dispatch(s.item),t=!1)}}}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/ellipse',["paper","tools/Shape.class"],function(a,b){var c="ellipse",d={annotationAdded:null},e=new b(c,d),f=e.exportJSON;delete e.exportJSON;var g=e.importJSON;return delete e.importJSON,{name:c,tool:new a.Tool(e),exportJSON:f,importJSON:g,registerEvent:function(a,b){d[a]=b}}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/rectangle',["paper","tools/Shape.class"],function(a,b){var c="rectangle",d={annotationAdded:null,annotationSelected:null,annotationChanged:null},e=new b(c,d),f=e.exportJSON;delete e.exportJSON;var g=e.importJSON;return delete e.importJSON,{name:c,tool:new a.Tool(e),exportJSON:f,importJSON:g,registerEvent:function(a,b){d[a]=b}}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/text',["paper","jquery"],function(a,b){function c(a,b){!a in w?(x=null,y={},z=!1):(x=w[a],y=b)}function d(a){switch(x){case w.DRAG_HANDLE:if("center"===y.nameParts[1])return;var b=y.item.bounds,c="top"===y.nameParts[0]?b.bottom-a.point.y:a.point.y-b.top,d=c/1.2,e=[0,0];"bottom"===y.nameParts[0]&&(e[1]=c-b.height),d>9&&999>d&&i.call(y.item,d),y.item.translate(e);break;case w.FULL_DRAG:default:this.translate(a.delta)}}function e(a){a.oGetSelected=function(){return this.children[1].selected},a.oSetSelected=function(a){this.children[1].selected=a},a.data.setDragMode=c,a.data.itemMouseDrag=d}function f(c){if(o&&g(!1),!s){o=!0,q||(q=b("<input>",{type:"text","class":"text-tool-input",placeholder:"Votre texte",maxlength:128,size:128,style:"display:none;position:absolute;top:0;left:0;padding:10px;border:0;border-radius:5px;background:rgba(255,255,255,0.75);"}).appendTo(a.project.view.element.parentNode).on("blur",function(){o&&g()}).on("keydown",function(a){(27===a.which||13==a.which)&&g()}).autoGrowInput(),r=r||b("<div>").css({zIndex:999,position:"fixed",display:"none",top:"-10px",left:"-10px",width:"5000px",height:"5000px"}).click(function(){g()}),q.before(r)),c.selected=!1,c.visible=!1;var d=c.children[1].point;d=d.subtract(a.view.bounds.point).multiply(a.view.zoom);var e=c.fontSize*a.view.zoom;q.val(c.data.content).css({fontSize:e+"px",fontFamily:c.font,color:c.data.color,top:d.y-e+1-10,left:d.x-1-10,zIndex:1e3}).show(),r.show();var f=q.nextAll("tester");f.css({fontSize:q.css("fontSize"),fontFamily:q.css("fontFamily"),fontWeight:q.css("fontWeight"),letterSpacing:q.css("letterSpacing")}),f.text(""===c.data.content?q.attr("placeholder"):c.data.content),q.width(f.width()+30),p=c,setTimeout(function(){q.focus()},100)}}function g(b){if(b=!(b===!1),o=!1,p){var c=q.val();if(c&&""!==c){var d=""===p.data.content;p.data.content=c,p.children[0].content=c,p.children[1].content=c,p.visible=!0,b&&t.annotationSelected&&"function"==typeof t.annotationSelected.dispatch&&t.annotationSelected.dispatch(p),d?(e(p),t.annotationAdded&&"function"==typeof t.annotationAdded.dispatch&&t.annotationAdded.dispatch(p)):t.annotationChanged&&"function"==typeof t.annotationChanged.dispatch&&t.annotationChanged.dispatch(p),p.oSetSelected(b),a.project.view.draw()}else p.remove(),p=null}r.hide(),q.val("").blur().hide()}function h(a){var b=this,c=b.children[1].fillColor!==a;return b.children[1].fillColor=a,b.data.color=a,c}function i(a){var b=this,c=a/10;3>c&&(c=3),b.children[0].fontSize=a,b.children[0].strokeWidth=c,b.children[1].fontSize=a}function j(){return this.children[0].fontSize}function k(a,c,d){var g=c.importJSON(a);return b.extend(g.data,{setColor:h,setFill:v,setStrokeWidth:v,setFontSize:i,getFontSize:j}),e(g),d&&g.children[1].on("doubleclick",function(){f(this.parent)}),g}function l(a){var c=this.selected;this.selected=!1;var d=this.exportJSON({asString:!1});return b.each(d[1].children,function(a,b){delete b[1].leading}),d=a&&a.asString===!1?d:JSON.stringify(d),c&&(this.selected=c),d}function m(a){return a!==s&&(s=a),s}var n="text",o=!1,p=null,q=null,r=null,s=!1,t={annotationAdded:null,annotationChanged:null,annotationSelected:null},u={type:"point-text",tolerance:5,fill:!0},v=function(){},w={FULL_DRAG:1,DRAG_HANDLE:4},x=null,y={},z=!1,A={onMouseDown:function(b){if(!s){var c=a.project.activeLayer.hitTest(b.point,u);if(c){var d=c.item.parent;f(d)}else{var e=a.project.currentStyle.fontSize;if(o)g();else{a.project.deselectAll();var k=b.point,l=new a.PointText({point:k,fillColor:"white",strokeColor:"white",strokeWidth:e/6,strokeJoin:"round",content:""}),m=a.project.currentStyle.strokeColor||a.project.currentStyle.fillColor;m=m.toCSS();var q=new a.PointText({point:k,fillColor:m,strokeColor:m,strokeWidth:0,content:""});q.on("doubleclick",function(){f(this.parent)}),p=new a.Group({children:[l,q],data:{type:n,setColor:h,setFill:v,setStrokeWidth:v,setFontSize:i,getFontSize:j,content:"",color:m}}),p.data.tId="a"+p._id,p.data.content="",f(p)}}}}};return{name:n,tool:new a.Tool(A),setRo:m,exportJSON:l,importJSON:k,registerEvent:function(a,b){t[a]=b}}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/arrow',["paper"],function(a){function b(a){var b=(this.data.from,this.data.to,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(c){console.error(c)}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,e=b.globalToLocal(a).x;return(e-c)/(d-c)>.1}function f(a,b){b=b||this,a=a||b.symbol.definition.segments[B].point.x-b.symbol.definition.segments[z].point.x;var c=b.symbol.definition.segments[B].point.x-b.symbol.definition.segments[A].point.x;return C>a-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},c!==!1&&(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=null,K={},L=!1):(J=I[a],K=b)}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(){this.detach("mousedrag",r),h.call(this),J=null,L&&F.annotationChanged.dispatch(this),L=!1}function t(){}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),!d)return!1;if(d.selected=!0,"bounds"===c.type){var e=c.name.split("-");"right"===e[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){if(!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(){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 - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/fieldedges',["paper"],function(a){function b(b,f){b.style="object"==typeof b.style?b.style:{};for(var g in L)b.style.hasOwnProperty(g)||(b.style[g]=L[g]);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 h=new a.Group({children:[b.firstEdge,b.secondEdge],style:b.style});b.prop="object"==typeof b.prop?b.prop:{};for(var g in H)b.prop.hasOwnProperty(g)||(b.prop[g]=H[g]);var i=[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 h.data={tId:"a"+h._id,type:B,prop:b.prop,points:i,itemMouseDrag:d},f||(h.onMouseDown=function(b){this.oGetSelected()?c(b):(a.project.deselectAll(),this.oSetSelected(!0),F.annotationSelected.dispatch(this))},h.oGetSelected=function(){for(var a,b=0;a=this.children[b];b++)if(!a.selected)return!1;return!0},h.oSetSelected=function(a){this.children.map(function(b){b.selected=a})},h.onMouseUp=e),F.annotationAdded.dispatch(h),h}function c(a){(J===I.DONE||J===I.CREATED_BOTH)&&o(a)}function d(a){J===I.EDITING&&k(a)}function e(a){J===I.EDITING&&p(a)}function f(a){var b=this.exportJSON({asString:!1});b[1].data.points=[s,t,u,v].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&&a.asString===!1?b:JSON.stringify(b)}function g(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(i){}var k=a.project.activeLayer;d.activate();var l=b({p1s:g[0],p1e:g[1],p2s:g[2],p2e:g[3],style:h,prop:f.data.prop});return e&&(w=l.children[0],x=l.children[1],j(),J=I.CREATED_BOTH),k.activate(),l}function h(){s=t=u=v=A=null,w&&w.remove(),x&&x.remove(),w=x=null}function i(){switch(J){case I.READY:break;case I.CREATE_FIRST:w&&w.remove(),w=new a.Path.Line({from:s,to:t}),w.style=K;break;case I.CREATE_SECOND:w&&w.remove(),w=new a.Path.Line({from:s,to:t}),w.style=L,x&&x.remove(),x=new a.Path.Line({from:u,to:v}),x.style=K;break;case I.CREATED_BOTH:}}function j(){s=w.segments[0].point,t=w.segments[1].point,u=x.segments[0].point,v=x.segments[1].point,A=u.subtract(s)}function k(a){if(y)if(isNaN(parseInt(z,2)))y.translate(a.delta);else{var b=y===w,c=b?x:w,d=b?a.point.add(A):a.point.subtract(A);y.insert(z,a.point),y.segments[z+1].remove(),c.insert(z,d),c.segments[z+1].remove()}}function l(a){s=t=a.point,J=I.CREATE_FIRST}function m(){u=s,v=t,J=I.CREATE_SECOND}function n(){J=I.CREATED_BOTH,A=u.subtract(s);var a=b({p1s:s,p1e:t,p2s:u,p2e:v});w&&w.remove(),w=a.children[0],x&&x.remove(),x=a.children[1],j()}function o(b){J=I.EDITING,y=z=null;var c=a.project.activeLayer.hitTest(b.point,E);c&&"pixel"!==c.type&&(c.item===w?y=w:c.item===x&&(y=x),a.project.deselectAll(),y.selected=!0,F.annotationSelected.dispatch(y),y&&"segment"===c.type&&(z=y.segments[0]===c.segment?0:1))}function p(){J=I.DONE;var a=y?y.parent:null;y=z=null,j(),a&&F.annotationChanged.dispatch(a)}function q(a){G&&(w.strokeWidth=a,x.strokeWidth=a,D=a)}function r(a){G=a===B}var s,t,u,v,w,x,y,z,A,B="fieldedges",C=new a.Color("#E100FF"),D=3,E={segments:!0,stroke:!0,fill:!1,tolerance:5,bounds:!1,handles:!0},F={annotationAdded:null,annotationSelected:null,annotationChanged:null},G=!1,H={comment:""},I={READY:1,CREATE_FIRST:2,CREATE_SECOND:3,CREATED_BOTH:4,EDITING:5,DONE:6},J=I.READY,K={strokeWidth:D,strokeColor:C,dashArray:[9,4]},L={strokeWidth:D,strokeColor:C},M={onMouseDown:function(a){switch(J){case I.READY:h(),l(a);break;case I.CREATE_FIRST:m(a);break;case I.CREATE_SECOND:n(a);break;case I.CREATED_BOTH:case I.DONE:o(a)}i(a)},onMouseMove:function(a){switch(J){case I.CREATE_FIRST:t=a.point,i(a);break;case I.CREATE_SECOND:v=a.point,u=s.add(v.subtract(t)),i(a);break;case I.EDITING:k(a)}},onMouseUp:function(a){switch(J){case I.EDITING:p(a)}}};return{name:B,tool:new a.Tool(M),registerEvent:function(a,b){F[a]=b},exportJSON:f,importJSON:g,listeners:{onStrokeWidthChanged:q,onToolActivated:r}}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 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){var d=b[1],e=a.project.activeLayer;c.activate();var f=g({from:d.segments[0],to:d.segments[1],strokeWidth:d.strokeWidth,prop:d.data.prop},{not_interactive:!0});return e.activate(),f}function d(a){y=a}function e(a){z=Math.floor(1.5*a)}function f(a){x=a===v}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 N)b.prop.hasOwnProperty(e)||(b.prop[e]=N[e]);return d.style=B[b.prop.confidence],parseInt(b.strokeWidth,10)&&(d.strokeWidth=b.strokeWidth),d.data={tId:"a"+d._id,type:v,prop:b.prop,itemMouseDrag:i,itemMouseUp:j},c&&c.not_interactive||(d.selected=!0,w.annotationSelected.dispatch(d)),d.onMouseDown=h,d.onKeyDown=k,d.onKeyUp=l,d.onPropertyChange=m,d}function h(b){var c=this;H=this;var d=c.hitTest(b.point,C);c.layer.activate(),a.project.deselectAll(),c.selected=!0,w.annotationSelected.dispatch(c),I=K=L=J=null,"segment"===d.type?(I=d.segment.index,J=y+(H.segments[1-I].point.x<y?1:-1)*z):(K=H.getFirstSegment().point.x<y?0:1,L=1-K),M=!1,w.annotationSelected.dispatch(c)}function i(a){a.tool&&(null!==I?s(a):H&&H.segments[K].point.x+a.delta.x<=y-z&&H.segments[L].point.x+a.delta.x>=y+z&&(H.translate(a.delta),M=!0))}function j(a){a.tool&&(H&&M&&(w.annotationChanged.dispatch([H]),M=!1),I=K=L=H=J=null)}function k(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),H=this,this.translate(c),M=!0,a.view.draw())}function l(a){switch(a.key){case"up":case"down":M&&(w.annotationChanged.dispatch([H]),M=!1)}}function m(b,c){"confidence"===b&&(this.style=B[c],a.view.draw())}function n(a,b){return a.x<=y&&b.x>=y+z||a.x>=y&&b.x<=y-z}function o(){F&&F.remove(),E=null,D=!1}function p(){var a=F?F.segments[1].point.clone():null;if(n(E,a)){F&&(F.remove(),F=null);var b=g({from:E,to:a});w.annotationAdded.dispatch(b),E=null,D=!1}}function q(b,c,d){d?u&&(b.segments[c].point.y=u.y,a.view.draw()):(u=b.segments[c].point.clone(),b.segments[c].point.y=b.segments[1-c].point.y)}function r(b){F?(F.segments[1].point=b.point,b.event.shiftKey&&q(F,1)):(F=new a.Path.Line({from:E,to:b.point}),F.style=A,F.dashArray=[10,5]),F.opacity=n(E,b.point)?1:.5,F.dashArray=n(E,b.point)?null:[10,5]}function s(a){var b=a.point.clone();n(H.segments[1-I].point,b)||(b.x=J),H.segments[I].point=b,a.event.shiftKey&&q(H,I),M=!0}var t,u,v="concordantstr",w={annotationAdded:null,annotationSelected:null},x=!1,y=0,z=10,A={strokeWidth:3,strokeColor:"red"},B={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}},C={segments:!0,stroke:!0,fill:!1,tolerance:5,bounds:!1,handles:!0},D=!0,E=null,F=null,G=!1,H=null,I=null,J=null,K=null,L=null,M=!1,N={confidence:3,comment:""},O={onMouseDown:function(b){if(E)F&&!G&&p();else{var c=a.project.activeLayer.hitTest(b.point,C);c?c.item.onMouseDown(b):(a.project.deselectAll(),w.annotationSelected.dispatch(null),E||(I=H=null,D=!0,F&&F.remove(),F=null,E=b.point,G=!1))}},onMouseDrag:function(a){D&&E&&(G=!0,r(a)),H&&H.data.itemMouseDrag(a)},onMouseMove:function(a){D&&E&&r(a)},onMouseUp:function(a){E?F&&G&&(r(a),p()):H&&H.data.itemMouseUp(a),I=H=null},onKeyDown:function(b){switch(b.key){case"enter":D&&p();break;case"escape":D&&o();break;case"shift":F?q(F,1):H&&null!==I&&q(H,I);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":F?q(F,1,!0):H&&I&&q(H,I,!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 t=new a.Tool(O),{name:v,tool:t,registerEvent:function(a,b){w[a]=b},exportJSON:b,importJSON:c,listeners:{onCutPositionChanged:d,onCutMarginChanged:e,onToolActivated:f}}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/discordantstr',["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){var d=b[1],e=a.project.activeLayer;c.activate();var g=f({from:d.segments[0],to:d.segments[1],strokeWidth:d.strokeWidth,prop:d.data.prop},{not_interactive:!0});return e.activate(),g}function d(a){w=a}function e(a){v=a===t}function f(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 I)b.prop.hasOwnProperty(e)||(b.prop[e]=I[e]);return d.style=x[b.prop.confidence],parseInt(b.strokeWidth,10)&&(d.strokeWidth=b.strokeWidth),d.data={tId:"a"+d._id,type:t,prop:b.prop,itemMouseDrag:h,itemMouseUp:i},c&&c.not_interactive||(d.selected=!0,u.annotationSelected.dispatch(d)),d.onMouseDown=g,d.onKeyDown=j,d.onKeyUp=k,d.onPropertyChange=l,d}function g(b){var c=this;D=this;var d=c.hitTest(b.point,y);if(c.layer.activate(),a.project.deselectAll(),c.selected=!0,u.annotationSelected.dispatch(c),E=F=G=null,"segment"===d.type)E=d.segment.index;else{var e=D.getFirstSegment(),f=D.getLastSegment();F=e.point.x-f.point.x<0?1:0,G=e.point.x>w||f.point.x>w,G&&(F=1-F)}H=!1,u.annotationSelected.dispatch(c)}function h(a){if(a.tool)if(null!==E)r(a);else if(D){var b=D.segments[F].point.x+a.delta.x-w;(G?b>=0:0>=b)&&D.translate(a.delta),H=!0}}function i(a){a.tool&&(D&&H&&(u.annotationChanged.dispatch([D]),H=!1),E=D=F=G=null)}function j(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),D=this,this.translate(c),H=!0,a.view.draw())}function k(a){switch(a.key){case"up":case"down":H&&(u.annotationChanged.dispatch([D]),H=!1)}}function l(b,c){"confidence"===b&&(this.style=x[c],a.view.draw())}function m(a,b){return a.x<=w&&b.x<=w||a.x>=w&&b.x>=w}function n(){B&&B.remove(),A=null,z=!1}function o(){var a=B?B.segments[1].point.clone():null;B&&(m(A,a)||(a.x=w),B.remove(),B=null),B&&B.remove();var b=f({from:A,to:a});u.annotationAdded.dispatch(b),A=null,z=!1}function p(b,c,d){d?s&&(b.segments[c].point.y=s.y,a.view.draw()):(s=b.segments[c].point.clone(),b.segments[c].point.y=b.segments[1-c].point.y)}function q(b){var c=b.point.clone();B?(m(A,b.point)||(c.x=w),B.segments[1].point=c,b.event.shiftKey&&p(B,1)):(B=new a.Path.Line({from:A,to:c}),B.style=x[3],b.event.shiftKey&&p(B,1))}function r(a){var b=a.point.clone();m(D.segments[1-E].point,a.point)||(b.x=w),D.segments[E].point=b,a.event.shiftKey&&p(D,E),H=!0}var s,t="discordantstr",u={annotationAdded:null,annotationSelected:null},v=!1,w=0,x={1:{strokeColor:new a.Color("#2057FF"),dashArray:[10,10]},2:{strokeColor:new a.Color("#2057FF"),dashArray:[30,10]},3:{strokeColor:new a.Color("#2057FF"),dashArray:null}},y={segments:!0,stroke:!0,fill:!1,tolerance:5,bounds:!1,handles:!0},z=!0,A=null,B=null,C=!1,D=null,E=null,F=null,G=null,H=!1,I={confidence:3,comment:""},J={onMouseDown:function(b){if(A)B&&!C&&o();else{var c=a.project.activeLayer.hitTest(b.point,y);c?c.item.onMouseDown(b):(a.project.deselectAll(),u.annotationSelected.dispatch(null),A||(z=!0,A=b.point,C=!1))}},onMouseDrag:function(a){z&&A&&(C=!0,q(a)),D&&D.data.itemMouseDrag(a)},onMouseMove:function(a){z&&A&&q(a)},onMouseUp:function(a){A?B&&C&&(q(a),o()):D&&D.data.itemMouseUp(a),E=D=null},onKeyDown:function(b){switch(b.key){case"enter":z&&o();break;case"escape":z&&n();break;case"shift":B?p(B,1):D&&null!==E&&p(D,E);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":B?p(B,1,!0):D&&E&&p(D,E,!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{name:t,tool:new a.Tool(J),registerEvent:function(a,b){u[a]=b},exportJSON:b,importJSON:c,listeners:{onCutPositionChanged:d,onToolActivated:e}}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/cmsarea',["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){var d=b[1],e=a.project.activeLayer;c.activate();var f=g({from:d.segments[0][1],to:d.segments[2][1],prop:d.data.prop});return e.activate(),f}function d(a){u=a}function e(a){v=a,w=v/2}function f(a){t=a===r}function g(b,c){var d=new a.Path({segments:[[u-w,b.from],[u+w,b.from],[u+w,b.to],[u-w,b.to]],closed:!0,style:x});b.prop="object"==typeof b.prop?b.prop:{};for(var e in H)b.prop.hasOwnProperty(e)||(b.prop[e]=H[e]);return d.data={tId:"a"+d._id,type:r,prop:b.prop,setStrokeWidth:z,itemMouseDrag:i,itemMouseUp:j},c!==!0&&(d.onMouseDown=h,d.onKeyDown=k,d.onKeyUp=l),d}function h(b){F=null;var c=this;return c.layer.activate(),a.project.deselectAll(),c.selected=!0,s.annotationSelected.dispatch(c),E=c,F=b.point.y-E.segments[0].point.y<=w?"up":E.segments[2].point.y-b.point.y<=w?"down":null,!1}function i(a){null!==F?p(a):E&&q(a)}function j(){E&&G&&(s.annotationChanged.dispatch([E]),G=!1)}function k(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),E=this,this.translate(c),G=!0,a.view.draw())}function l(a){switch(a.key){case"up":case"down":G&&(s.annotationChanged.dispatch([E]),G=!1)}}function m(){C&&C.remove(),B=null,A=!1,G=!1}function n(){var a=C?C.segments[3].point.clone():null;C&&(C.remove(),C=null);var b=g({from:B.y,to:a.y});s.annotationAdded.dispatch(b),G=!1,B=null,A=!1}function o(b){C?(C.segments[2].point.y=b.point.y,C.segments[3].point.y=b.point.y):C=new a.Path({segments:[[u-w,B.y],[u+w,B.y],[u+w,b.point.y],[u-w,b.point.y]],closed:!0,style:x,dashArray:[10,5]})}function p(a){var b="up"===F?0:2;E.segments[b].point.y+=a.delta.y,E.segments[b+1].point.y+=a.delta.y,G=!0}function q(a){var b=a.delta.clone();b.x=0,E.translate(b),G=!0}var r="cmsarea",s={annotationAdded:null,annotationSelected:null,annotationChanged:null},t=!1,u=0,v=50,w=v/2,x={strokeWidth:2,fillColor:new a.Color(1,.91372549,.501960784,.66),strokeColor:"#FFCF40",opacity:.5},y={segments:!0,stroke:!1,fill:!0,tolerance:20,bounds:!1,handles:!1},z=function(){},A=!0,B=null,C=null,D=!1,E=null,F=null,G=!1,H={comment:""},I={onMouseDown:function(b){if(B)C&&!D&&n();else{if(b.point.x<u-w-5||b.point.x>u+w+5)return a.project.deselectAll(),void s.annotationSelected.dispatch(null);var c=b.point.clone();c.x=u;var d=a.project.activeLayer.hitTest(c,y),e=null;if(d&&d.item.data&&d.item.data.type===r&&(e=d.item),e)return!1;F=E=null,a.project.deselectAll(),s.annotationSelected.dispatch(null),B||(A=!0,C&&C.remove(),C=null,B=c,D=!1)}},onMouseDrag:function(a){if(A&&B)D=!0,o(a);else if(null!==F)p(a);else{if(!E)return!1;q(a)}},onMouseMove:function(a){A&&B&&o(a)},onMouseUp:function(a){B?C&&D&&(o(a),n()):E&&E.data.itemMouseUp(a),F=E=null},onKeyDown:function(b){switch(b.key){case"enter":A&&n();break;case"escape":A&&m();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"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{name:r,tool:new a.Tool(I),registerEvent:function(a,b){s[a]=b},exportJSON:b,importJSON:c,listeners:{onCutPositionChanged:d,onSetAreaWidth:e,onToolActivated:f}}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
define('adim/category',["underscore","paper","signals"],function(a,b){function c(){a.isString(e)&&(e=$(e)),a(e.find("[data-category]")).each(function(a,b){var c=$(a),e=c.data("color")||c.css("backgroundColor"),g=c.data("category");f[g]={id:g,color:d(e)},0==b&&(f["default"]=f[g])})}function d(a,c){var d;if(0===a.indexOf("rgb")){var e=a.split(/[(),]/).map(function(a){return parseFloat(a.trim())}).filter(function(a){return!isNaN(a)});d=new b.Color(e[0]/255,e[1]/255,e[2]/255)}else d=new b.Color(a);return c?d:d.toCSS(!0)}var e="#prop-annot-category",f={};return{init:c,getCategory:function(a){return f[a]}}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/marker',["underscore","paper","signals","adim/category"],function(a,b,c,d){function e(a){var b=this.exportJSON({asString:!1});return b[1].data.origin.splice(0,1),a&&a.asString?JSON.stringify(b):b}function f(a,c,d){var e=a[1].data;e.origin=new b.Point(e.origin);var f=b.project.activeLayer;c.activate();var h=g(e.origin,e,d);return e.prop.category&&l.call(h,e.prop.category),f.activate(),h}function g(c,d,e){e=e!==!1;var f;d&&d.label?(f=parseInt(d.label,10)||d.label,C=!0):f=B.length+1;var g=(d?parseInt(d.radius,10):!1)||D,i=(d?parseFloat(d.rotation):!1)||0,m=d&&"object"==typeof d.prop?d.prop:{};for(var r in A)m.hasOwnProperty(r)||(m[r]=A[r]);var s=new b.Group;return s.data={type:w,tId:"a"+s._id,origin:c,radius:g,rotation:i,label:f,prop:m,setColor:y,getColor:y,setFill:y,setStrokeWidth:j,getStrokeWidth:k,setCategory:l,itemMouseDrag:o,itemMouseDown:n,itemMouseUp:p},s._boundsSelected=!0,s._selectChildren=!1,e&&(s.onPropertyChange=q,s.onMouseDown=n),h(s),e&&(a.some(B,function(a,b){return f<a.data.label?(B.splice(b,0,s),!0):!1})||B.push(s)),s}function h(a,c){c=c||{};var e=c.radius||a.data.radius,f=c.label||a.data.label,g=c.origin||a.data.origin,h=c.rotation||a.data.rotation,i=c.category||a.data.prop.category||"default",j=c.highlight||!1,k=d.getCategory(i),l=k&&k.color||"black";if(!f||!g)return void console.error("label or origin not defined");var m=1.4*e,n=e/3.75,o=2*e/1.25;f.toString().length>1&&(m*=.9);var p=new b.Path.Circle({center:[0,0],radius:e+e/4,fillColor:j?F:E,strokeColor:null}),q=new b.Path.Circle({center:[0,0],radius:e,strokeColor:l||"black",fillColor:"white",strokeWidth:e/4}),r=new b.Path({segments:[[n-e,o-e],[0,10*e/3-e],[2*e-n-e,o-e]],closed:!0,fillColor:l||"black",strokeJoin:"round",strokeColor:j?F:E,strokeWidth:e/8}),s=new b.PointText({point:[0,0],content:f,fillColor:l||"black",strokeColor:null,fontFamily:"Courier",fontWeight:"bold",fontSize:m});s.translate([-s.bounds.width/2,m/4]),a.removeChildren(),a.addChildren([p,r,q,s]),a.translate(g),r.rotate(h,g)}function i(a){this.children[G.circle].strokeColor=a,this.children[G.pointer].fillColor=a,this.children[G.labelText].fillColor=a}function j(a){this.data.radius=a+10,h(this)}function k(){return this.data.radius-10}function l(a){var b=d.getCategory(a),c=b&&b.color||"#000000";i.call(this,c)}function m(a,b){!a in H?(I=null,J={},K=!1):(I=H[a],J=b)}function n(a){if(this.selected&&!x){var b=this.data.origin.subtract(a.point).length;I=b>1.25*this.data.radius?H.DRAG_POINTER:H.FULL_DRAG}}function o(a){if(!x)switch(K=!0,I){case H.FULL_DRAG:this.translate(a.delta),this.data.origin=this.data.origin.add(a.delta);break;case H.DRAG_POINTER:var b=a.point.subtract(this.data.origin).angle-90;this.data.rotation=b,h(this);break;default:K=!1}}function p(){I=null,K&&z.annotationChanged.dispatch(this),K=!1}function q(a,c){"category"===a&&(l.call(this,c),b.view.draw())}function r(a){return a.data&&a.data.type===w?a:a.parent?r(a.parent):null}function s(a){var c,d;return c=b.project.activeLayer.hitTest(a,{tolerance:7,fill:!0,stroke:!0,segments:!0,ends:!0,bounds:!0,selected:!0}),c||(c=b.project.activeLayer.hitTest(a,{tolerance:1,fill:!0,stroke:!0})),c&&c.item&&(d=r(c.item))?d:!1}function t(){var b=[],c=0;a.each(B,function(a){a.parent&&(c++,a.data.label.toString()!==c.toString()&&(a.data.label=c.toString(),h(a),b.push(a),z.markerLabelChanged.dispatch(a)))}),B=a.reject(B,function(a){return!a.parent}),b.length>0&&z.annotationChanged.dispatch(b)}function u(a){var c=B.splice(a.oldIndex,1);B.splice(a.newIndex,0,c[0]),t(),b.view.draw()}function v(a){return x=a}var w="marker",x=!1,y=function(){},z=(new b.Color([0,0,0,0]),{annotationAdded:null,annotationSelected:null,annotationChanged:null,markerLabelChanged:new c}),A={labelComment:"",category:""},B=[],C=!1,D=20,E="white",F="red",G={bgCircle:0,pointer:1,circle:2,labelText:3},H={FULL_DRAG:1,DRAG_POINTER:2},I=null,J={},K=!1,L=null,M={onMouseDown:function(a){if(!x&&(I=null,b.project.hitTest(a.point,{"class":b.Raster}))){var c=s(a.point);c?(c.selected?a.point.x==a.lastPoint.x&&z.annotationSelected.dispatch(c):(b.project.deselectAll(),c.selected=!0,z.annotationSelected.dispatch(c)),n.call(c,a),L=c):(b.project.deselectAll(),z.annotationSelected.dispatch(null),c=g(a.point),z.annotationAdded.dispatch(c),b.project.deselectAll(),c.selected=!0,n.call(c,a),L=c,z.annotationSelected.dispatch(c))}},onMouseDrag:function(a){x||I&&o.call(L,a)},onMouseUp:function(){m(null),L=null}};return{name:w,tool:new b.Tool(M),setRo:v,registerEvent:function(a,b){z[a]=b},exportJSON:e,importJSON:f,listeners:{updateNumbering:t,setNumbering:u},events:z}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('adim/category',["underscore","paper","signals"],function(a,b){function c(){a.isString(e)&&(e=$(e)),a(e.find("[data-category]")).each(function(a,b){var c=$(a),e=c.data("color")||c.css("backgroundColor"),g=c.data("category");f[g]={id:g,color:d(e)},0==b&&(f["default"]=f[g])}),f["default"]=f.cat_2}function d(a,c){var d;if(0===a.indexOf("rgb")){var e=a.split(/[(),]/).map(function(a){return parseFloat(a.trim())}).filter(function(a){return!isNaN(a)});d=new b.Color(e[0]/255,e[1]/255,e[2]/255)}else d=new b.Color(a);return c?d:d.toCSS(!0)}var e="#prop-annot-category",f={};return{init:c,getCategory:function(a){return f[a]}}});
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('tools/marker',["underscore","paper","signals","adim/category"],function(a,b,c,d){function e(a){var b=this.exportJSON({asString:!1});return b[1].data.origin.splice(0,1),a&&a.asString?JSON.stringify(b):b}function f(a,c,d){var e=a[1].data;e.origin=new b.Point(e.origin);var f=b.project.activeLayer;c.activate();var h=A.category,i=g(e.origin,e,d);return e.prop.category&&l.call(i,e.prop.category),f.activate(),A.category=h,i}function g(c,d,e){e=e!==!1;var f;d&&d.label?(f=parseInt(d.label,10)||d.label,C=!0):f=B.length+1;var g=(d?parseInt(d.radius,10):!1)||D,i=(d?parseFloat(d.rotation):!1)||0,m=d&&"object"==typeof d.prop?d.prop:{};for(var r in A)m.hasOwnProperty(r)||(m[r]=A[r]);var s=new b.Group;return s.data={type:w,tId:"a"+s._id,origin:c,radius:g,rotation:i,label:f,prop:m,setColor:y,getColor:y,setFill:y,setStrokeWidth:j,getStrokeWidth:k,setCategory:l,itemMouseDrag:o,itemMouseDown:n,itemMouseUp:p},s._boundsSelected=!0,s._selectChildren=!1,e&&(s.onPropertyChange=q,s.onMouseDown=n),h(s),e&&(a.some(B,function(a,b){return f<a.data.label?(B.splice(b,0,s),!0):!1})||B.push(s)),s}function h(a,c){c=c||{};var e=c.radius||a.data.radius,f=c.label||a.data.label,g=c.origin||a.data.origin,h=c.rotation||a.data.rotation,i=c.category||a.data.prop.category||"default",j=c.highlight||!1,k=d.getCategory(i),l=k&&k.color||"black";if(!f||!g)return void console.error("label or origin not defined");var m=1.4*e,n=e/3.75,o=2*e/1.25;f.toString().length>1&&(m*=.9);var p=new b.Path.Circle({center:[0,0],radius:e+e/4,fillColor:j?F:E,strokeColor:null}),q=new b.Path.Circle({center:[0,0],radius:e,strokeColor:l||"black",fillColor:"white",strokeWidth:e/4}),r=new b.Path({segments:[[n-e,o-e],[0,10*e/3-e],[2*e-n-e,o-e]],closed:!0,fillColor:l||"black",strokeJoin:"round",strokeColor:j?F:E,strokeWidth:e/8}),s=new b.PointText({point:[0,0],content:f,fillColor:l||"black",strokeColor:null,fontFamily:"Courier",fontWeight:"bold",fontSize:m});s.translate([-s.bounds.width/2,m/4]),a.removeChildren(),a.addChildren([p,r,q,s]),a.translate(g),r.rotate(h,g)}function i(a){this.children[G.circle].strokeColor=a,this.children[G.pointer].fillColor=a,this.children[G.labelText].fillColor=a}function j(a){this.data.radius=a+10,h(this)}function k(){return this.data.radius-10}function l(a){var b=d.getCategory(a),c=b&&b.color||"#000000";i.call(this,c),A.category=a}function m(a,b){!a in H?(I=null,J={},K=!1):(I=H[a],J=b)}function n(a){if(this.selected&&!x){var b=this.data.origin.subtract(a.point).length;I=b>1.25*this.data.radius?H.DRAG_POINTER:H.FULL_DRAG}}function o(a){if(!x)switch(K=!0,I){case H.FULL_DRAG:this.translate(a.delta),this.data.origin=this.data.origin.add(a.delta);break;case H.DRAG_POINTER:var b=a.point.subtract(this.data.origin).angle-90;this.data.rotation=b,h(this);break;default:K=!1}}function p(){I=null,K&&z.annotationChanged.dispatch(this),K=!1}function q(a,c){"category"===a&&(l.call(this,c),b.view.draw())}function r(a){return a.data&&a.data.type===w?a:a.parent?r(a.parent):null}function s(a){var c,d;return c=b.project.activeLayer.hitTest(a,{tolerance:7,fill:!0,stroke:!0,segments:!0,ends:!0,bounds:!0,selected:!0}),c||(c=b.project.activeLayer.hitTest(a,{tolerance:1,fill:!0,stroke:!0})),c&&c.item&&(d=r(c.item))?d:!1}function t(){var b=[],c=0;a.each(B,function(a){a.parent&&(c++,a.data.label.toString()!==c.toString()&&(a.data.label=c.toString(),h(a),b.push(a),z.markerLabelChanged.dispatch(a)))}),B=a.reject(B,function(a){return!a.parent}),b.length>0&&z.annotationChanged.dispatch(b)}function u(a){var c=B.splice(a.oldIndex,1);B.splice(a.newIndex,0,c[0]),t(),b.view.draw()}function v(a){return x=a}var w="marker",x=!1,y=function(){},z=(new b.Color([0,0,0,0]),{annotationAdded:null,annotationSelected:null,annotationChanged:null,markerLabelChanged:new c}),A={labelComment:"",category:"cat_2"},B=[],C=!1,D=20,E="white",F="red",G={bgCircle:0,pointer:1,circle:2,labelText:3},H={FULL_DRAG:1,DRAG_POINTER:2},I=null,J={},K=!1,L=null,M={onMouseDown:function(a){if(!x&&(I=null,b.project.hitTest(a.point,{"class":b.Raster}))){var c=s(a.point);c?(c.selected?a.point.x==a.lastPoint.x&&z.annotationSelected.dispatch(c):(b.project.deselectAll(),c.selected=!0,z.annotationSelected.dispatch(c)),n.call(c,a),L=c):(b.project.deselectAll(),z.annotationSelected.dispatch(null),c=g(a.point),z.annotationAdded.dispatch(c),b.project.deselectAll(),c.selected=!0,n.call(c,a),L=c,z.annotationSelected.dispatch(c))}},onMouseDrag:function(a){x||I&&o.call(L,a)},onMouseUp:function(){m(null),L=null}};return{name:w,tool:new b.Tool(M),setRo:v,registerEvent:function(a,b){z[a]=b},exportJSON:e,importJSON:f,listeners:{updateNumbering:t,setNumbering:u},events:z}});
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 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"],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(a);b?(n=a,b.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){var c=i(a.data.type);return c.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},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(){var a=new paper.Tool({onMouseDown:p,onMouseUp:p,onMouseDrag:p,onKeyDown:p,onKeyUp:p});a.activate()}(),{events:q,tools:m,getTool:f,getToolJSONImporter:h,getToolJSONExporter:i,activateTool:g,getActiveTool:e,serializeItem:j,setRo:k}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 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){var c="user_"+a,d=b||f.getById(a)||a;return j(c,{owner:d,ownerId:a})}function l(a,b){var d=h(a);return d?(b="undefined"==typeof 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(j){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 l=k(c.owner),m=g.getToolJSONImporter(i)(f,l,d);return m&&(m.data.id=c.id,m.selected=!1),m}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;f>e;e++)for(var g=b[e].children,h=0,i=g.length;i>h;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?!0:!!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)?!0:!!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&&a.undef===!0: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)?!0: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,d&&(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(){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(a).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,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)},A.source=b.url,A.position=[0,0],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){var b=h("user_"+a);return o(b.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 - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 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(){})}function j(a){function c(a){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){a=a||e.user.id;var b=f.getUserAnnnotationsSerialized(a);return j(b),!0},saveAnnotations:function(a,b){if(!n&&!b)return!1;m.annotationsSavedStatusChanged.dispatch({status:"dirty"});var c=f.getAnnotationsSerialized(a);return j(c),!0},removeAnnotation:k,saveThumbnail:i,setAnnotableName:l}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('adim/attributes',["underscore","paper","signals","adim/view"],function(a,b,c,d){function e(a){a=a||b.project.currentStyle,B.colorChanged.add(function(a,b){j(a,b)}),B.fillChanged.add(function(a,b){m(a,b)}),B.fontSizeChanged.add(function(a,b){p(a,b)}),B.strokeWidthChanged.add(function(a,b){t(a,b)}),B.opacityChanged.add(function(a,b){w(a,b)}),h(a.strokeColor),n(a.fontSize),q(a.strokeWidth),z(1),k(!!a.isFill)}function f(a,c){for(var e,f=d.getSelectedAnnotations(),g=[],h=0;e=f[h];h++)e.data&&e.data.type&&("function"==typeof e.data[a.setCallbackName]?e.data[a.setCallbackName].call(e,a.attrValue):a.setAttrCallback.call(e,a.attrValue),g.push(e));c!==!1&&B.annotationChanged.dispatch(g),b.view.draw()}function g(a){var c=d.getSelectedAnnotations();if(c.length>0){var e=c[0],f=e.index,g=null,h=null,i=[];if("front"===a?e.bringToFront():"frontward"===a?e.nextSibling&&e.insertAbove(e.nextSibling):"back"===a?e.sendToBack():"backward"===a&&e.previousSibling&&e.insertBelow(e.previousSibling),f!==e.index){g=Math.min(f,e.index),h=Math.max(f,e.index);for(var j=g;h>=j;j++)i.push(e.layer.children[j]);B.annotationChanged.dispatch(i),b.view.draw()}}}function h(a,c,d){C=new b.Color(a),b.project.currentStyle.strokeColor=C,b.project.currentStyle.fillColor=E?C:null,d!==!0&&B.colorChanged.dispatch(a,c)}function i(){return C}function j(a,b){f({setCallbackName:"setColor",attrValue:a,setAttrCallback:function(a){this.fillColor&&(this.fillColor=a),this.strokeColor=a}},b)}function k(a,c,d){E=!!a,b.project.currentStyle.fillColor=E?C:null,d!==!0&&B.fillChanged.dispatch(E,c)}function l(){return E}function m(a,b){f({setCallbackName:"setFill",attrValue:a,setAttrCallback:function(a){var b=this.fillColor||this.strokeColor;this.fillColor=a?b:null}},b)}function n(a,c,d){F=a,b.project.currentStyle.fontSize=a,d!==!0&&B.fontSizeChanged.dispatch(a,c)}function o(){return b.project.currentStyle.fontSize}function p(a,b){f({setCallbackName:"setFontSize",attrValue:a},b)}function q(a,c,d){G=a>J?J:K>a?K:a,b.project.currentStyle.strokeWidth=G,d!==!0&&B.strokeWidthChanged.dispatch(a,c)}function r(){return G}function s(a){var b=Math.abs(a),c=b/a,d=(1+Math.floor(b/3))*c;q(r()+d,!1),L(r())}function t(a,b){f({setCallbackName:"setStrokeWidth",attrValue:a,setAttrCallback:function(a){this.strokeWidth=a}},b)}function u(a,b,c){D=Math.max(0,Math.min(100,a)),c!==!0&&B.opacityChanged.dispatch(a,b)}function v(){return D}function w(a,b){f({setCallbackName:"setOpacity",attrValue:a,setAttrCallback:function(a){this.opacity=a/100}},b)}function x(a){a=Math.max(0,Math.min(100,a)),H=a,d._raster().opacity=a/100,b.view.draw()}function y(){return H}function z(a,c){var e,f,g;a=Math.max(N,Math.min(M,a)),b.project.view.zoom!==a&&(c&&("center"===c?(I=I||d.getLayerByName("image"),g=I?I.localToGlobal(I.bounds.center).subtract(b.view.center):[0,0]):(c=b.view.viewToProject(c),e=b.view.zoom/a,f=c.subtract(b.view.center),g=c.subtract(f.multiply(e)).subtract(b.view.center))),b.project.view.zoom=a,g&&b.view.setCenter(b.view.center.add(g)),B.zoomChanged.dispatch(a))}function A(a,c,d){var e=20;if(d=isNaN(d)?5:d,0!==a){var f=Math.abs(a),g=f/a;a=g*(f>e?e:d>f?d:f);var h=b.project.view.zoom;h+=b.project.view.zoom*a/100,z(h,c)}}var B={colorChanged:new c,fillChanged:new c,fontSizeChanged:new c,strokeWidthChanged:new c,opacityChanged:new c,zoomChanged:new c,annotationChanged:new c},C=null,D=1,E=!1,F=48,G=7,H=100,I=null,J=50,K=1,L=a.debounce(q,300),M=10,N=.1;return{init:e,events:B,setColor:h,getColor:i,setFill:k,getFill:l,setFontSize:n,getFontSize:o,setStrokeWidth:q,getStrokeWidth:r,deltaStrokeWidth:s,setOpacity:u,getOpacity:v,setZoom:z,deltaZoom:A,setImageOpacity:x,getImageOpacity:y,bringToFront:function(){g("front")},bringFrontward:function(){g("frontward")},sendToBack:function(){g("back")},sendBacktward:function(){g("backward")}}});
/* FileSaver.js
* A saveAs() FileSaver implementation.
......@@ -13830,7 +13830,7 @@ if (typeof module !== "undefined" && module !== null) {
}
;
!function(a){var b=a.HTMLCanvasElement&&a.HTMLCanvasElement.prototype,c=a.Blob&&function(){try{return Boolean(new Blob)}catch(a){return!1}}(),d=c&&a.Uint8Array&&function(){try{return 100===new Blob([new Uint8Array(100)]).size}catch(a){return!1}}(),e=a.BlobBuilder||a.WebKitBlobBuilder||a.MozBlobBuilder||a.MSBlobBuilder,f=(c||e)&&a.atob&&a.ArrayBuffer&&a.Uint8Array&&function(a){var b,f,g,h,i,j;for(b=a.split(",")[0].indexOf("base64")>=0?atob(a.split(",")[1]):decodeURIComponent(a.split(",")[1]),f=new ArrayBuffer(b.length),g=new Uint8Array(f),h=0;h<b.length;h+=1)g[h]=b.charCodeAt(h);return i=a.split(",")[0].split(":")[1].split(";")[0],c?new Blob([d?g:f],{type:i}):(j=new e,j.append(f),j.getBlob(i))};a.HTMLCanvasElement&&!b.toBlob&&(b.mozGetAsFile?b.toBlob=function(a,c,d){d&&b.toDataURL&&f?a(f(this.toDataURL(c,d))):a(this.mozGetAsFile("blob",c))}:b.toDataURL&&f&&(b.toBlob=function(a,b,c){a(f(this.toDataURL(b,c)))})),"function"==typeof define&&define.amd?define('canvasToBlob',[],function(){return f}):a.dataURLtoBlob=f}(this);
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('helper/exporter',["jquery","paper","FileSaver","adim/view","adim/config","canvasToBlob"],function(a,b,c,d,e){function f(a,e){var f,g,h,i=d.getLayerByName("image").children.filter(function(a){return!!a.image});if(i.length>0&&e.linkImages)require(["zip"],function(d){j||(d.workerScriptsPath=requirejs.toUrl("zip").split("/").slice(0,-1).join("/")+"/",j=!0),g=i[0].toDataURL,h=function(){return this._image&&this._image.src};for(var k,l=0;k=i[l];l++)k.toDataURL=h;f=b.project.exportSVG({asString:!0});for(var k,l=0;k=i[l];l++)k.toDataURL=g;for(var m,n=(i.map(function(a){return a.source}),[]),o=0;m=i[o];o++){var p=m.source,q=p.split("/").pop();f=f.replace(p,q),n.push([q,m])}var r=a+" directory";return d.createWriter(new d.BlobWriter("application/zip"),function(b){function g(){var a=n[i++];a?a[1].canvas.toBlob(function(c){b.add(r+"/"+a[0],new d.BlobReader(c),function(){g()})},"image/jpeg",e.quality||.9):h()}function h(){b.close(function(b){c(b,a+"_svg.zip"),e&&e.callback&&"function"==typeof e.callback&&e.callback()})}var i=0;b.add(r+"/image.svg",new d.TextReader(f),function(){g()})}),null});else{if(0===i.length||"png"===e.imageType)f=b.project.exportSVG({asString:!0});else{g=i[0].toDataURL,h=function(){var a=this._image&&this._image.src;if(/^data:/.test(a))return a;var b=this.getCanvas();return b?b.toDataURL("image/jpeg",e.quality||.9):null};for(var k,l=0;k=i[l];l++)k.toDataURL=h;f=b.project.exportSVG({asString:!0});for(var k,l=0;k=i[l];l++)k.toDataURL=g}var m=new Blob([f],{type:"image/svg+xml;charset=utf-8"});c(m,a+".svg"),e&&e.callback&&"function"==typeof e.callback&&e.callback()}}function g(e,f){var g=a.Deferred(),h=b.view.zoom,i=b.view.viewSize,j=b.view.center,k=d.getLayerByName("image").children[1].size,l=d.getSelectedAnnotations(),m=a.map(l,function(a){return a.fullySelected?a:null});b.project.deselectAll();var n,o,p=[];if(f&&f.thumbnailSize){for(p=b.project.getItems({data:{type:"arrow"}}),o=0,n;n=p[o];o++)n.symbol.definition.strokeScaling=!0;b.view.zoom=f.thumbnailSize/Math.max(k.width,k.height),d.resize(k.width*b.view.zoom,k.height*b.view.zoom)}else b.view.zoom=1,d.resize(k.width,k.height);for(b.view.center=k.multiply(.5),b.view.element.toBlob(function(a){g.resolve({blob:a}),f&&f.thumbnailSize||c(a,e+".png")}),a.each(l,function(a,b){b.selected=!0}),a.each(m,function(a,b){b.fullySelected=!0}),o=0,n;n=p[o];o++)n.symbol.definition.strokeScaling=!1;return b.view.viewSize=i,b.view.zoom=h,b.view.center=j,f&&f.callback&&"function"==typeof f.callback&&f.callback(),g}function h(a){var b=window.devicePixelRatio||1;return a.thumbnailSize=(parseInt(e.thumbnailSize,10)||150)/b,g(null,a)}function i(a,b,c){switch(b){case"png":return g(a,c);case"svg":c=c||{},c.linkImages=!1,c.imageType="jpeg",c.quality=.9,f(a,c)}}var j=!1;return{exportSVG:f,"export":i,getThumbnail:h}});
(function(t,e){if(typeof define==="function"&&define.amd){define('backbone',["underscore","jquery","exports"],function(i,r,s){t.Backbone=e(t,s,i,r)})}else if(typeof exports!=="undefined"){var i=require("underscore");e(t,exports,i)}else{t.Backbone=e(t,{},t._,t.jQuery||t.Zepto||t.ender||t.$)}})(this,function(t,e,i,r){var s=t.Backbone;var n=[];var a=n.push;var o=n.slice;var h=n.splice;e.VERSION="1.1.2";e.$=r;e.noConflict=function(){t.Backbone=s;return this};e.emulateHTTP=false;e.emulateJSON=false;var u=e.Events={on:function(t,e,i){if(!c(this,"on",t,[e,i])||!e)return this;this._events||(this._events={});var r=this._events[t]||(this._events[t]=[]);r.push({callback:e,context:i,ctx:i||this});return this},once:function(t,e,r){if(!c(this,"once",t,[e,r])||!e)return this;var s=this;var n=i.once(function(){s.off(t,n);e.apply(this,arguments)});n._callback=e;return this.on(t,n,r)},off:function(t,e,r){var s,n,a,o,h,u,l,f;if(!this._events||!c(this,"off",t,[e,r]))return this;if(!t&&!e&&!r){this._events=void 0;return this}o=t?[t]:i.keys(this._events);for(h=0,u=o.length;h<u;h++){t=o[h];if(a=this._events[t]){this._events[t]=s=[];if(e||r){for(l=0,f=a.length;l<f;l++){n=a[l];if(e&&e!==n.callback&&e!==n.callback._callback||r&&r!==n.context){s.push(n)}}}if(!s.length)delete this._events[t]}}return this},trigger:function(t){if(!this._events)return this;var e=o.call(arguments,1);if(!c(this,"trigger",t,e))return this;var i=this._events[t];var r=this._events.all;if(i)f(i,e);if(r)f(r,arguments);return this},stopListening:function(t,e,r){var s=this._listeningTo;if(!s)return this;var n=!e&&!r;if(!r&&typeof e==="object")r=this;if(t)(s={})[t._listenId]=t;for(var a in s){t=s[a];t.off(e,r,this);if(n||i.isEmpty(t._events))delete this._listeningTo[a]}return this}};var l=/\s+/;var c=function(t,e,i,r){if(!i)return true;if(typeof i==="object"){for(var s in i){t[e].apply(t,[s,i[s]].concat(r))}return false}if(l.test(i)){var n=i.split(l);for(var a=0,o=n.length;a<o;a++){t[e].apply(t,[n[a]].concat(r))}return false}return true};var f=function(t,e){var i,r=-1,s=t.length,n=e[0],a=e[1],o=e[2];switch(e.length){case 0:while(++r<s)(i=t[r]).callback.call(i.ctx);return;case 1:while(++r<s)(i=t[r]).callback.call(i.ctx,n);return;case 2:while(++r<s)(i=t[r]).callback.call(i.ctx,n,a);return;case 3:while(++r<s)(i=t[r]).callback.call(i.ctx,n,a,o);return;default:while(++r<s)(i=t[r]).callback.apply(i.ctx,e);return}};var d={listenTo:"on",listenToOnce:"once"};i.each(d,function(t,e){u[e]=function(e,r,s){var n=this._listeningTo||(this._listeningTo={});var a=e._listenId||(e._listenId=i.uniqueId("l"));n[a]=e;if(!s&&typeof r==="object")s=this;e[t](r,s,this);return this}});u.bind=u.on;u.unbind=u.off;i.extend(e,u);var p=e.Model=function(t,e){var r=t||{};e||(e={});this.cid=i.uniqueId("c");this.attributes={};if(e.collection)this.collection=e.collection;if(e.parse)r=this.parse(r,e)||{};r=i.defaults({},r,i.result(this,"defaults"));this.set(r,e);this.changed={};this.initialize.apply(this,arguments)};i.extend(p.prototype,u,{changed:null,validationError:null,idAttribute:"id",initialize:function(){},toJSON:function(t){return i.clone(this.attributes)},sync:function(){return e.sync.apply(this,arguments)},get:function(t){return this.attributes[t]},escape:function(t){return i.escape(this.get(t))},has:function(t){return this.get(t)!=null},set:function(t,e,r){var s,n,a,o,h,u,l,c;if(t==null)return this;if(typeof t==="object"){n=t;r=e}else{(n={})[t]=e}r||(r={});if(!this._validate(n,r))return false;a=r.unset;h=r.silent;o=[];u=this._changing;this._changing=true;if(!u){this._previousAttributes=i.clone(this.attributes);this.changed={}}c=this.attributes,l=this._previousAttributes;if(this.idAttribute in n)this.id=n[this.idAttribute];for(s in n){e=n[s];if(!i.isEqual(c[s],e))o.push(s);if(!i.isEqual(l[s],e)){this.changed[s]=e}else{delete this.changed[s]}a?delete c[s]:c[s]=e}if(!h){if(o.length)this._pending=r;for(var f=0,d=o.length;f<d;f++){this.trigger("change:"+o[f],this,c[o[f]],r)}}if(u)return this;if(!h){while(this._pending){r=this._pending;this._pending=false;this.trigger("change",this,r)}}this._pending=false;this._changing=false;return this},unset:function(t,e){return this.set(t,void 0,i.extend({},e,{unset:true}))},clear:function(t){var e={};for(var r in this.attributes)e[r]=void 0;return this.set(e,i.extend({},t,{unset:true}))},hasChanged:function(t){if(t==null)return!i.isEmpty(this.changed);return i.has(this.changed,t)},changedAttributes:function(t){if(!t)return this.hasChanged()?i.clone(this.changed):false;var e,r=false;var s=this._changing?this._previousAttributes:this.attributes;for(var n in t){if(i.isEqual(s[n],e=t[n]))continue;(r||(r={}))[n]=e}return r},previous:function(t){if(t==null||!this._previousAttributes)return null;return this._previousAttributes[t]},previousAttributes:function(){return i.clone(this._previousAttributes)},fetch:function(t){t=t?i.clone(t):{};if(t.parse===void 0)t.parse=true;var e=this;var r=t.success;t.success=function(i){if(!e.set(e.parse(i,t),t))return false;if(r)r(e,i,t);e.trigger("sync",e,i,t)};q(this,t);return this.sync("read",this,t)},save:function(t,e,r){var s,n,a,o=this.attributes;if(t==null||typeof t==="object"){s=t;r=e}else{(s={})[t]=e}r=i.extend({validate:true},r);if(s&&!r.wait){if(!this.set(s,r))return false}else{if(!this._validate(s,r))return false}if(s&&r.wait){this.attributes=i.extend({},o,s)}if(r.parse===void 0)r.parse=true;var h=this;var u=r.success;r.success=function(t){h.attributes=o;var e=h.parse(t,r);if(r.wait)e=i.extend(s||{},e);if(i.isObject(e)&&!h.set(e,r)){return false}if(u)u(h,t,r);h.trigger("sync",h,t,r)};q(this,r);n=this.isNew()?"create":r.patch?"patch":"update";if(n==="patch")r.attrs=s;a=this.sync(n,this,r);if(s&&r.wait)this.attributes=o;return a},destroy:function(t){t=t?i.clone(t):{};var e=this;var r=t.success;var s=function(){e.trigger("destroy",e,e.collection,t)};t.success=function(i){if(t.wait||e.isNew())s();if(r)r(e,i,t);if(!e.isNew())e.trigger("sync",e,i,t)};if(this.isNew()){t.success();return false}q(this,t);var n=this.sync("delete",this,t);if(!t.wait)s();return n},url:function(){var t=i.result(this,"urlRoot")||i.result(this.collection,"url")||M();if(this.isNew())return t;return t.replace(/([^\/])$/,"$1/")+encodeURIComponent(this.id)},parse:function(t,e){return t},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return!this.has(this.idAttribute)},isValid:function(t){return this._validate({},i.extend(t||{},{validate:true}))},_validate:function(t,e){if(!e.validate||!this.validate)return true;t=i.extend({},this.attributes,t);var r=this.validationError=this.validate(t,e)||null;if(!r)return true;this.trigger("invalid",this,r,i.extend(e,{validationError:r}));return false}});var v=["keys","values","pairs","invert","pick","omit"];i.each(v,function(t){p.prototype[t]=function(){var e=o.call(arguments);e.unshift(this.attributes);return i[t].apply(i,e)}});var g=e.Collection=function(t,e){e||(e={});if(e.model)this.model=e.model;if(e.comparator!==void 0)this.comparator=e.comparator;this._reset();this.initialize.apply(this,arguments);if(t)this.reset(t,i.extend({silent:true},e))};var m={add:true,remove:true,merge:true};var y={add:true,remove:false};i.extend(g.prototype,u,{model:p,initialize:function(){},toJSON:function(t){return this.map(function(e){return e.toJSON(t)})},sync:function(){return e.sync.apply(this,arguments)},add:function(t,e){return this.set(t,i.extend({merge:false},e,y))},remove:function(t,e){var r=!i.isArray(t);t=r?[t]:i.clone(t);e||(e={});var s,n,a,o;for(s=0,n=t.length;s<n;s++){o=t[s]=this.get(t[s]);if(!o)continue;delete this._byId[o.id];delete this._byId[o.cid];a=this.indexOf(o);this.models.splice(a,1);this.length--;if(!e.silent){e.index=a;o.trigger("remove",o,this,e)}this._removeReference(o,e)}return r?t[0]:t},set:function(t,e){e=i.defaults({},e,m);if(e.parse)t=this.parse(t,e);var r=!i.isArray(t);t=r?t?[t]:[]:i.clone(t);var s,n,a,o,h,u,l;var c=e.at;var f=this.model;var d=this.comparator&&c==null&&e.sort!==false;var v=i.isString(this.comparator)?this.comparator:null;var g=[],y=[],_={};var b=e.add,w=e.merge,x=e.remove;var E=!d&&b&&x?[]:false;for(s=0,n=t.length;s<n;s++){h=t[s]||{};if(h instanceof p){a=o=h}else{a=h[f.prototype.idAttribute||"id"]}if(u=this.get(a)){if(x)_[u.cid]=true;if(w){h=h===o?o.attributes:h;if(e.parse)h=u.parse(h,e);u.set(h,e);if(d&&!l&&u.hasChanged(v))l=true}t[s]=u}else if(b){o=t[s]=this._prepareModel(h,e);if(!o)continue;g.push(o);this._addReference(o,e)}o=u||o;if(E&&(o.isNew()||!_[o.id]))E.push(o);_[o.id]=true}if(x){for(s=0,n=this.length;s<n;++s){if(!_[(o=this.models[s]).cid])y.push(o)}if(y.length)this.remove(y,e)}if(g.length||E&&E.length){if(d)l=true;this.length+=g.length;if(c!=null){for(s=0,n=g.length;s<n;s++){this.models.splice(c+s,0,g[s])}}else{if(E)this.models.length=0;var k=E||g;for(s=0,n=k.length;s<n;s++){this.models.push(k[s])}}}if(l)this.sort({silent:true});if(!e.silent){for(s=0,n=g.length;s<n;s++){(o=g[s]).trigger("add",o,this,e)}if(l||E&&E.length)this.trigger("sort",this,e)}return r?t[0]:t},reset:function(t,e){e||(e={});for(var r=0,s=this.models.length;r<s;r++){this._removeReference(this.models[r],e)}e.previousModels=this.models;this._reset();t=this.add(t,i.extend({silent:true},e));if(!e.silent)this.trigger("reset",this,e);return t},push:function(t,e){return this.add(t,i.extend({at:this.length},e))},pop:function(t){var e=this.at(this.length-1);this.remove(e,t);return e},unshift:function(t,e){return this.add(t,i.extend({at:0},e))},shift:function(t){var e=this.at(0);this.remove(e,t);return e},slice:function(){return o.apply(this.models,arguments)},get:function(t){if(t==null)return void 0;return this._byId[t]||this._byId[t.id]||this._byId[t.cid]},at:function(t){return this.models[t]},where:function(t,e){if(i.isEmpty(t))return e?void 0:[];return this[e?"find":"filter"](function(e){for(var i in t){if(t[i]!==e.get(i))return false}return true})},findWhere:function(t){return this.where(t,true)},sort:function(t){if(!this.comparator)throw new Error("Cannot sort a set without a comparator");t||(t={});if(i.isString(this.comparator)||this.comparator.length===1){this.models=this.sortBy(this.comparator,this)}else{this.models.sort(i.bind(this.comparator,this))}if(!t.silent)this.trigger("sort",this,t);return this},pluck:function(t){return i.invoke(this.models,"get",t)},fetch:function(t){t=t?i.clone(t):{};if(t.parse===void 0)t.parse=true;var e=t.success;var r=this;t.success=function(i){var s=t.reset?"reset":"set";r[s](i,t);if(e)e(r,i,t);r.trigger("sync",r,i,t)};q(this,t);return this.sync("read",this,t)},create:function(t,e){e=e?i.clone(e):{};if(!(t=this._prepareModel(t,e)))return false;if(!e.wait)this.add(t,e);var r=this;var s=e.success;e.success=function(t,i){if(e.wait)r.add(t,e);if(s)s(t,i,e)};t.save(null,e);return t},parse:function(t,e){return t},clone:function(){return new this.constructor(this.models)},_reset:function(){this.length=0;this.models=[];this._byId={}},_prepareModel:function(t,e){if(t instanceof p)return t;e=e?i.clone(e):{};e.collection=this;var r=new this.model(t,e);if(!r.validationError)return r;this.trigger("invalid",this,r.validationError,e);return false},_addReference:function(t,e){this._byId[t.cid]=t;if(t.id!=null)this._byId[t.id]=t;if(!t.collection)t.collection=this;t.on("all",this._onModelEvent,this)},_removeReference:function(t,e){if(this===t.collection)delete t.collection;t.off("all",this._onModelEvent,this)},_onModelEvent:function(t,e,i,r){if((t==="add"||t==="remove")&&i!==this)return;if(t==="destroy")this.remove(e,r);if(e&&t==="change:"+e.idAttribute){delete this._byId[e.previous(e.idAttribute)];if(e.id!=null)this._byId[e.id]=e}this.trigger.apply(this,arguments)}});var _=["forEach","each","map","collect","reduce","foldl","inject","reduceRight","foldr","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max","min","toArray","size","first","head","take","initial","rest","tail","drop","last","without","difference","indexOf","shuffle","lastIndexOf","isEmpty","chain","sample"];i.each(_,function(t){g.prototype[t]=function(){var e=o.call(arguments);e.unshift(this.models);return i[t].apply(i,e)}});var b=["groupBy","countBy","sortBy","indexBy"];i.each(b,function(t){g.prototype[t]=function(e,r){var s=i.isFunction(e)?e:function(t){return t.get(e)};return i[t](this.models,s,r)}});var w=e.View=function(t){this.cid=i.uniqueId("view");t||(t={});i.extend(this,i.pick(t,E));this._ensureElement();this.initialize.apply(this,arguments);this.delegateEvents()};var x=/^(\S+)\s*(.*)$/;var E=["model","collection","el","id","attributes","className","tagName","events"];i.extend(w.prototype,u,{tagName:"div",$:function(t){return this.$el.find(t)},initialize:function(){},render:function(){return this},remove:function(){this.$el.remove();this.stopListening();return this},setElement:function(t,i){if(this.$el)this.undelegateEvents();this.$el=t instanceof e.$?t:e.$(t);this.el=this.$el[0];if(i!==false)this.delegateEvents();return this},delegateEvents:function(t){if(!(t||(t=i.result(this,"events"))))return this;this.undelegateEvents();for(var e in t){var r=t[e];if(!i.isFunction(r))r=this[t[e]];if(!r)continue;var s=e.match(x);var n=s[1],a=s[2];r=i.bind(r,this);n+=".delegateEvents"+this.cid;if(a===""){this.$el.on(n,r)}else{this.$el.on(n,a,r)}}return this},undelegateEvents:function(){this.$el.off(".delegateEvents"+this.cid);return this},_ensureElement:function(){if(!this.el){var t=i.extend({},i.result(this,"attributes"));if(this.id)t.id=i.result(this,"id");if(this.className)t["class"]=i.result(this,"className");var r=e.$("<"+i.result(this,"tagName")+">").attr(t);this.setElement(r,false)}else{this.setElement(i.result(this,"el"),false)}}});e.sync=function(t,r,s){var n=T[t];i.defaults(s||(s={}),{emulateHTTP:e.emulateHTTP,emulateJSON:e.emulateJSON});var a={type:n,dataType:"json"};if(!s.url){a.url=i.result(r,"url")||M()}if(s.data==null&&r&&(t==="create"||t==="update"||t==="patch")){a.contentType="application/json";a.data=JSON.stringify(s.attrs||r.toJSON(s))}if(s.emulateJSON){a.contentType="application/x-www-form-urlencoded";a.data=a.data?{model:a.data}:{}}if(s.emulateHTTP&&(n==="PUT"||n==="DELETE"||n==="PATCH")){a.type="POST";if(s.emulateJSON)a.data._method=n;var o=s.beforeSend;s.beforeSend=function(t){t.setRequestHeader("X-HTTP-Method-Override",n);if(o)return o.apply(this,arguments)}}if(a.type!=="GET"&&!s.emulateJSON){a.processData=false}if(a.type==="PATCH"&&k){a.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}var h=s.xhr=e.ajax(i.extend(a,s));r.trigger("request",r,h,s);return h};var k=typeof window!=="undefined"&&!!window.ActiveXObject&&!(window.XMLHttpRequest&&(new XMLHttpRequest).dispatchEvent);var T={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};e.ajax=function(){return e.$.ajax.apply(e.$,arguments)};var $=e.Router=function(t){t||(t={});if(t.routes)this.routes=t.routes;this._bindRoutes();this.initialize.apply(this,arguments)};var S=/\((.*?)\)/g;var H=/(\(\?)?:\w+/g;var A=/\*\w+/g;var I=/[\-{}\[\]+?.,\\\^$|#\s]/g;i.extend($.prototype,u,{initialize:function(){},route:function(t,r,s){if(!i.isRegExp(t))t=this._routeToRegExp(t);if(i.isFunction(r)){s=r;r=""}if(!s)s=this[r];var n=this;e.history.route(t,function(i){var a=n._extractParameters(t,i);n.execute(s,a);n.trigger.apply(n,["route:"+r].concat(a));n.trigger("route",r,a);e.history.trigger("route",n,r,a)});return this},execute:function(t,e){if(t)t.apply(this,e)},navigate:function(t,i){e.history.navigate(t,i);return this},_bindRoutes:function(){if(!this.routes)return;this.routes=i.result(this,"routes");var t,e=i.keys(this.routes);while((t=e.pop())!=null){this.route(t,this.routes[t])}},_routeToRegExp:function(t){t=t.replace(I,"\\$&").replace(S,"(?:$1)?").replace(H,function(t,e){return e?t:"([^/?]+)"}).replace(A,"([^?]*?)");return new RegExp("^"+t+"(?:\\?([\\s\\S]*))?$")},_extractParameters:function(t,e){var r=t.exec(e).slice(1);return i.map(r,function(t,e){if(e===r.length-1)return t||null;return t?decodeURIComponent(t):null})}});var N=e.History=function(){this.handlers=[];i.bindAll(this,"checkUrl");if(typeof window!=="undefined"){this.location=window.location;this.history=window.history}};var R=/^[#\/]|\s+$/g;var O=/^\/+|\/+$/g;var P=/msie [\w.]+/;var C=/\/$/;var j=/#.*$/;N.started=false;i.extend(N.prototype,u,{interval:50,atRoot:function(){return this.location.pathname.replace(/[^\/]$/,"$&/")===this.root},getHash:function(t){var e=(t||this).location.href.match(/#(.*)$/);return e?e[1]:""},getFragment:function(t,e){if(t==null){if(this._hasPushState||!this._wantsHashChange||e){t=decodeURI(this.location.pathname+this.location.search);var i=this.root.replace(C,"");if(!t.indexOf(i))t=t.slice(i.length)}else{t=this.getHash()}}return t.replace(R,"")},start:function(t){if(N.started)throw new Error("Backbone.history has already been started");N.started=true;this.options=i.extend({root:"/"},this.options,t);this.root=this.options.root;this._wantsHashChange=this.options.hashChange!==false;this._wantsPushState=!!this.options.pushState;this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var r=this.getFragment();var s=document.documentMode;var n=P.exec(navigator.userAgent.toLowerCase())&&(!s||s<=7);this.root=("/"+this.root+"/").replace(O,"/");if(n&&this._wantsHashChange){var a=e.$('<iframe src="javascript:0" tabindex="-1">');this.iframe=a.hide().appendTo("body")[0].contentWindow;this.navigate(r)}if(this._hasPushState){e.$(window).on("popstate",this.checkUrl)}else if(this._wantsHashChange&&"onhashchange"in window&&!n){e.$(window).on("hashchange",this.checkUrl)}else if(this._wantsHashChange){this._checkUrlInterval=setInterval(this.checkUrl,this.interval)}this.fragment=r;var o=this.location;if(this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!this.atRoot()){this.fragment=this.getFragment(null,true);this.location.replace(this.root+"#"+this.fragment);return true}else if(this._hasPushState&&this.atRoot()&&o.hash){this.fragment=this.getHash().replace(R,"");this.history.replaceState({},document.title,this.root+this.fragment)}}if(!this.options.silent)return this.loadUrl()},stop:function(){e.$(window).off("popstate",this.checkUrl).off("hashchange",this.checkUrl);if(this._checkUrlInterval)clearInterval(this._checkUrlInterval);N.started=false},route:function(t,e){this.handlers.unshift({route:t,callback:e})},checkUrl:function(t){var e=this.getFragment();if(e===this.fragment&&this.iframe){e=this.getFragment(this.getHash(this.iframe))}if(e===this.fragment)return false;if(this.iframe)this.navigate(e);this.loadUrl()},loadUrl:function(t){t=this.fragment=this.getFragment(t);return i.any(this.handlers,function(e){if(e.route.test(t)){e.callback(t);return true}})},navigate:function(t,e){if(!N.started)return false;if(!e||e===true)e={trigger:!!e};var i=this.root+(t=this.getFragment(t||""));t=t.replace(j,"");if(this.fragment===t)return;this.fragment=t;if(t===""&&i!=="/")i=i.slice(0,-1);if(this._hasPushState){this.history[e.replace?"replaceState":"pushState"]({},document.title,i)}else if(this._wantsHashChange){this._updateHash(this.location,t,e.replace);if(this.iframe&&t!==this.getFragment(this.getHash(this.iframe))){if(!e.replace)this.iframe.document.open().close();this._updateHash(this.iframe.location,t,e.replace)}}else{return this.location.assign(i)}if(e.trigger)return this.loadUrl(t)},_updateHash:function(t,e,i){if(i){var r=t.href.replace(/(javascript:|#).*$/,"");t.replace(r+"#"+e)}else{t.hash="#"+e}}});e.history=new N;var U=function(t,e){var r=this;var s;if(t&&i.has(t,"constructor")){s=t.constructor}else{s=function(){return r.apply(this,arguments)}}i.extend(s,r,e);var n=function(){this.constructor=s};n.prototype=r.prototype;s.prototype=new n;if(t)i.extend(s.prototype,t);s.__super__=r.prototype;return s};p.extend=g.extend=$.extend=w.extend=N.extend=U;var M=function(){throw new Error('A "url" property or function must be specified')};var q=function(t,e){var i=e.error;e.error=function(r){if(i)i(t,r,e);t.trigger("error",t,r,e)}};return e});
 
......@@ -15416,9 +15416,9 @@ define("bootstrap.spinedit", ["jquery.bootstrap"], function(){});
 
define("bootstrap.rating", ["jquery.bootstrap"], function(){});
 
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('adim/ui',["jquery","underscore","signals","paper","adim/config","adim/view","adim/io","adim/tools","adim/attributes","adim/users","helper/exporter","anobj-mgr/views/AnObjMgr","jquery.bootstrap","jquery.mousewheel","bootstrap.colorpicker","bootstrap.slider","jquery.autoGrowInput","bootstrap.spinedit","bootstrap.rating","FileSaver"],function($,_,Signal,paper,config,view,io,tools,attributes,Users,exporter,AnObjMgr){function init(a){var b=this,c=$("#main-navbar"),d=$("#page-loader");_$w=$(window),_canvas=$("#my-canvas"),_canvasCtnr=$(".canvas-container"),_canvasToolBar=$("#canvas-bbar"),_sideCol=$("#side-col"),_toolsCol=$("#tools-col"),_annotationListCtnr=$("#annotation-list-container"),_markerLabelListCtnr=$("#annotation-markers-container").find(".list-group"),_sharedMarkerLabelListCtnr=$("#shared-annotation-markers-container").find(".list-group"),_canvasCtnrTop=_canvasCtnr.offset().top+_canvasToolBar.outerHeight(),view.events.imageLoaded.add(function(a){adjustCanvasToImage(a.raster),d.remove(),console.timeEnd("complete app")}),view.events.annotationsLoaded.add(function(){zoomFitContent(),updateUserLayers(),e=!0,io.setAutoSave(e)}),view.events.userLayerVisibilityChanged.add(onUserLayerVisChange),tools.events.annotationSelected.add(function(a){_.each($.isArray(a)?a:[a],function(a){var b=!!a&&1===view.getSelectedAnnotations().length;if(b){displayProperties(a);var c="function"==typeof a.data.getStrokeWidth?a.data.getStrokeWidth.call(a):"undefined"!=typeof a.data.strokeWidth?a.data.strokeWidth:"undefined"!=typeof a.strokeWidth?a.strokeWidth:0;c&&(_widthSlider.slider("setValue",c),attributes.setStrokeWidth(c,!1,!0)),"undefined"!=typeof a.opacity&&(_opacitySlider.slider("setValue",100*a.opacity),attributes.setOpacity(a.opacity,!1,!0));var d="function"==typeof a.data.getColor?a.data.getColor.call(a):a.data.color?a.data.color:a.strokeColor?a.strokeColor:a.fillColor;d&&(updateColorSelector(d),attributes.setColor(d,!1,!0));var e="function"==typeof a.data.getFill?a.data.getFill.call(a):!!a.fillColor;$("#tool-fill-color").toggleClass("active",e),attributes.setFill(e,!1,!0);var f="function"==typeof a.data.getFontSize?a.data.getFontSize.call(a):attributes.getFontSize();$("#attr-font-size").val(f),attributes.setFontSize(f,!1,!0)}else disableProperties(!0),$("*:focus").blur();if(a&&a.layer){var g=a.layer.id,h=$("#annotation-list-container .list-group-item").filter(function(a,b){return $(b).data("layerId")==g});selectLayerListItem(h,!1)}})}),io.events.loadingError.add(function(a){if(d.length)d.html('<div class="text-danger lead">Erreur de chargement</div><div class="text-danger">'+a.msg+"</div>");else{var b=$('<div class="alert alert-danger in"><button data-dismiss="alert" class="close" type="button">×</button><h4>Erreur de chargement</h4><p>'+a.msg+"</p></div>");$("#main").prepend(b.alert())}}),_minWind=a.minWind,_minWind&&c.hide(),config.aai&&config.aai.slo&&config.user&&config.user.shibboleth&&$("#adim-logout-but").click(function(a){a.preventDefault();var b=$(this).attr("href");$("<iframe>",{src:config.aai.urls.sp_logout}).appendTo("body").hide(),$("<iframe>",{src:config.aai.urls.idp_logout}).appendTo("body").hide(),setTimeout(function(){window.document.location.href=b},500)});var e=io.getAutoSave();config.ui.show_side_col?_sideCol.find(".side-col-collapse-but .btn").on("click",function(){toggleSideCol()}):_sideCol.hide(),updateReservedSpace();var f=function(){var a,b=c.find(".navbar-header"),d=c.find(".navbar-right"),e=c.find(".adim-image-name");return a=b.offset().left+b.outerWidth()+d.outerWidth()+(e.outerWidth()-e.width())+25,e.find(".text").css("max-width",_$w.width()-a),a}();!function(){var a=$("body"),b=a.outerWidth(),d=a.outerHeight(),e=_.debounce(function(){a.data("resize-fixed")||(a.css({width:b,maxWidth:b,minWidth:b,height:d,maxHeight:d,minHeight:d}),a.data("resize-fixed",!0))},50,!0),g=_.debounce(function(){a.css({width:"auto",maxWidth:"none",minWidth:0,height:"auto",maxHeight:"none",minHeight:0}),a.data("resize-fixed",!1),b=a.outerWidth(),d=a.outerHeight(),adjustCanvasToImage(),c.find(".adim-image-name .text").css("max-width",_$w.width()-f)},100);_$w.on("resize",function(){e(),g()})}(),$("#side-col-panel-group .panel-collapse").on("hidden.bs.collapse shown.bs.collapse",function(){_adjustCanvasFrame()}),$(".adim-view-mod-tabs li").on("click","a",function(a){var b=$(a.target),c=$(a.delegateTarget),d=b.data("adimMode");return d?(a.preventDefault(),c.hasClass("active")?!1:void updateViewMode(d)):!0}),$(".adim-view-mod-tabs").find("[data-toggle=tooltip]").tooltip({placement:"bottom",delay:{show:1500,hide:50}}),$("#but-zoom-fit").on("click",zoomFitContent),$("#but-zoom-100").on("click",function(a){a.preventDefault(),attributes.setZoom(1,"center")}),config.user.guest||config.annotable.locked||config.annotable.ttpShared?$("a.adim-image-name").on("click",function(a){a.preventDefault()}):(this._anObjNameModal=$("#adim-name-modal").modal({show:!1}),this._anObjNameModal.find("button.btn-primary").on("click",function(a){a.preventDefault(),io.setAnnotableName(config.annotable.id,b._anObjNameModal.find("input[name=imageName]").val()).done(function(){b._anObjNameModal.modal("hide")}).fail(function(a,c){var d=a.responseJSON.name||a.responseJSON.detail||c;b._anObjNameModal.find(".errors").removeClass("hide").find(".error-text").text(d)})}),this._anObjName=$("a.adim-image-name").on("click submit",function(a){a.preventDefault(),b._anObjNameModal.find(".errors").addClass("hide").end().find("input[name=imageName]").val(b._anObjName.find(".text").text()).end().modal("show")}).append($('<span style="font-size: 12px;" class="glyphicon glyphicon-pencil"></span>'))),$(".aom-show-but").on("click",function(a){_showAnObjMgr.call(b,a)}),function(){var a=$("#dlg-publish-mode").modal({show:!1}),b=$("#annotation-sharing-panel");b.find("[data-toggle=tooltip]").tooltip({viewport:"#annotation-sharing-container",container:"#annotation-sharing-container",placement:"bottom",delay:{show:500,hide:100}}).end().find(".adim-sha-publish-mode-but").on("click",function(){var b;try{b=config.user.membership.publish_mode}catch(c){b=0}a.find("form input[name=publish-mode]").val([b]),a.modal("show")}),a.find(".modal-footer .save-publish-mode-but").on("click",function(){var c=b.data("publishState"),d=a.find("form input[name=publish-mode]:checked").val();return c==d?void a.modal("hide"):void $.ajax({url:config.api.annotables+config.annotable.id+"/set_publish_mode/",type:"PATCH",contentType:"application/json; charset=utf-8",dataType:"json",data:JSON.stringify({publish_mode:d})}).done(function(a){config.user.membership.publish_mode=a.publish_mode,b.data("publishState",a.publish_mode).attr("data-publish-state",a.publish_mode)}).fail(function(){}).always(function(){a.modal("hide"),a.find("form input[name=publish-mode]").val([config.user.membership.publish_mode])})})}(),io.events.annotableChanged.add(function(a){if(a.id===config.annotable.id&&b._anObjName.find(".text").text(a.name),b._anObjMgr){var c=b._anObjMgr.anobjs.findWhere({id:a.id});c&&c.set("name",a.name)}}),function(a){var b={placement:"bottom",delay:{show:750,hide:50}},c=a.find(".annot-stat.annot-stat-error"),d=-1,e=5e3,f=!1;a.find(".annot-saved-status").find("[data-toggle=tooltip]").tooltip(b),io.events.annotationsSavedStatusChanged.add(function(g){$(".annot-saved-status").removeClass("stat-saved stat-dirty stat-error").addClass("stat-"+(g.status||"error")),"error"===g.status?Date.now()-d>e?f||c.popover({trigger:"manual"}).on("shown.bs.popover",function(){c.tooltip("destroy"),a.find(".annot-saved-status").find(".popover").on("click",function(){c.popover("destroy")}),f=!0}).on("hidden.bs.popover",function(){c.tooltip(b).off("click"),d=Date.now(),f=!1}).popover("show"):d=Date.now():"saved"===g.status&&(d=-1)})}(c),$("#btn-export-image-png").on("click",function(a){a.preventDefault(),_export("png")}),$("#btn-export-image-svg").on("click",function(a){a.preventDefault(),_export("svg")}),$("#adim-about-but").on("click",function(a){a.preventDefault(),$("#dlg-about-adim").modal()}),initPropertiesPanel();var g=updateViewMode(),h=a.locked||"review"===g;initTools({disabled:a.locked,ro:h}),initAttributes({disabled:a.locked}),tools.activateTool("select")}function updateViewMode(a){var b,c=$(".adim-view-mod-tabs"),d=document.location.hash.split(":")[0],e="";if(0!==c.length)return-1===["edit","review"].indexOf(a)&&(b=c.find("a[href='"+d+"']"),a=1===b.length?b.data("adimMode"):"edit"),b&&b.length||(b=c.find("a[data-adim-mode="+a+"]")),e=b.attr("href"),_minWind&&(e+=":m"),c.find("li.active").removeClass("active"),b.closest("li").addClass("active"),window.history.replaceState(null,"",e),$(".adim-view").removeClass("adim-view-review adim-view-edit").addClass("adim-view-"+a),config.mode=a,updateReservedSpace(),adjustCanvasToImage(),tools.activateTool("select"),tools.setRo(config.annotable.locked||"review"===a),"review"===a?c.data("loaded")?view.toggleMembersLayers(!0):io.loadSharedAnnotations(config.api.annotables+config.annotable.id+"/shared/annotations/").done(function(a){c.data("loaded",!0),$.ajax({url:config.api.annotables+config.annotable.id+"/members/",dataType:"json"}).done(function(a){Users.addUsers(a.users)}).always(function(){view.loadAnnotations(a,null)})}):"edit"===a&&view.toggleMembersLayers(!1),_events.modeChanged.dispatch({mode:a}),a}function toggleSideCol(a){if(_sideCol.is(":visible")){var b,c;"undefined"==typeof a&&(a=_sideCol.is(".collapsed"),b=["width",_sideCol.css("transition-duration"),_sideCol.css("transition-timing-function"),_sideCol.css("transition-delay")].join(" ")),_sideCol.toggleClass("collapsed",!a),updateReservedSpace(),b&&(_canvasCtnr.css("transition",b),_canvasToolBar.css("transition",b),c=_canvas.css("border-color"),_canvas.css("border-right-color","transparent")),adjustCanvasToImage(),b&&setTimeout(function(){_canvasCtnr.css("transition",""),_canvasToolBar.css("transition",""),_canvas.css("border-right-color",c)},300)}}function initTools(a){a=$.extend({},{disabled:!1,ro:!1},a||{}),tools.setRo(a.ro),$("[data-tool-name]").each(function(){var b=$(this),c=b.data("toolName");a.disabled||void 0===tools.getTool(c)?b.attr("disabled","disabled").parent(".btn").addClass("disabled"):b.on("change",function(){var a=$(this).data("toolName");tools.activateTool(a)}),$(this).data("toolName")===config.ui.initial_tool&&$(this).click()})}function enableTool(a,b){b=_.isUndefined(b)?!0:b;var c=tools.getActiveTool();_.each(a.split(","),function(a){var d=$("#draw-tool-tb").find('[data-tool-name="'+a+'"]');0!==d.length&&(b?d.removeAttr("disabled").parent(".btn").removeClass("disabled"):(a===c&&tools.activateTool("select"),d.attr("disabled","disabled").parent(".btn").addClass("disabled")))})}function disableTool(a,b){return enableTool(a,_.isUndefined(b)?!1:b)}function initAttributes(a){a=$.extend({},{disabled:!1},a||{});var b=$("#attr-orderup"),c=$("#attr-orderdown");a.disabled?(b.attr("disabled","disabled"),c.attr("disabled","disabled")):(b.click(function(a){a.shiftKey?attributes.bringFrontward():attributes.bringToFront()}),c.click(function(a){a.shiftKey?attributes.sendBacktward():attributes.sendToBack()})),setupColorSelector(a.disabled),a.disabled?$("#tool-fill-color").attr("disabled","disabled"):$("#tool-fill-color").removeAttr("disabled").click(function(){var a=!$(this).is(".active");attributes.setFill(a)}),a.disabled?$("#attr-font").attr("disabled","disabled"):$("#attr-font").removeAttr("disabled").popover({title:'Propriétés des textes <button type="button" class="close" style="margin:-9px">&times;</button>',html:!0,container:"body",trigger:"click",delay:0,content:'<div style="width:160px"><label style="float:left; line-height: 35px" class="small text-muted">Taille: &nbsp;</label><div class="input-group" style="width: 70px;"><input type="text" size="10" class="form-control" name="fontSize" id="attr-font-size"></div></div>'}).on("shown.bs.popover",function(){var a=this,b=$(a).data("bs.popover").$tip,c=b.find("input[name=fontSize]").focus();c.spinedit({value:attributes.getFontSize(),minimum:9,maximum:999,step:1,numberOfDecimals:0}).on("valueChanged",function(a){attributes.setFontSize(parseInt(a.value,10))});var d=function(c){var d=c.target===a||$(c.target).closest(".popover").get(0)===b.get(0);d||e()},e=function(){$(document).unbind("click",d),$("#attr-font").popover("hide")};b.find(".close").on("click",e),$(document).bind("click",d)}),_widthSlider=$("#attr-size-slider").toggleClass("disabled",a.disabled).find(".slider").slider({min:1,max:50,step:1,orientation:"vertical",value:paper&&paper.projet?paper.project.currentStyle.strokeWidth:5,tooltip:a.disabled?"hide":"show",selection:"none",reversed:!0,enabled:!a.disabled}).on("slide",function(a){attributes.setStrokeWidth(a.value,!1)}).on("slideStop",function(a){attributes.setStrokeWidth(a.value,!0)}),attributes.events.strokeWidthChanged.add(function(a){_widthSlider.slider("setValue",a)}),_opacitySlider=$("#attr-opacity-slider").toggleClass("disabled",a.disabled).find(".slider").slider({min:0,max:100,step:10,orientation:"vertical",value:100,tooltip:a.disabled?"hide":"show",formatter:function(a){return a+" %"},selection:"none",reversed:!0,enabled:!a.disabled}).on("slide",function(a){attributes.setOpacity(a.value,!1)}).on("slideStop",function(a){attributes.setOpacity(a.value,!0)});var d,e=$("#attr-zoom"),f=e.find("input[name=zoomLevel]").val(100).on("blur",function(){var a=$(this);a.val(parseInt(parseFloat($(this).val()))+" %")}).on("focus",function(){var a=$(this);a.val(parseInt(parseFloat($(this).val())))}).on("change",function(){var a=parseInt(parseFloat($(this).val()));isNaN(a)||attributes.setZoom(a/100)}),g=e.find(".slider").slider({selection:"none",value:100,enabled:!a.disabled,tooltip:a.disabled?"hide":"show",formater:function(a){return a+"%"}}).on("slide",function(a){var b=parseInt(a.value,10);attributes.setZoom(b/100)});_canvas.on("mousewheel",function(b){if(b.ctrlKey){if(b.preventDefault(),!a.disabled){var c=_widthSlider.slider("getValue")+Math.min(1,Math.max(-1,b.deltaY));_widthSlider.slider("setValue",c),attributes.setStrokeWidth(c,!1),d&&clearTimeout(d),d=setTimeout(function(){attributes.setStrokeWidth(c,!0)},500)}}else b.metaKey?(b.preventDefault(),attributes.deltaZoom(b.deltaY/20,[b.offsetX,b.offsetY],2)):b.altKey?(b.preventDefault(),attributes.deltaStrokeWidth(b.deltaY/20)):(b.preventDefault(),attributes.deltaZoom(b.deltaY,[b.offsetX,b.offsetY]))}),attributes.events.zoomChanged.add(function(a){var b=Math.floor(100*a);f.val(b+" %"),g.slider("setValue",b)})}function zoomFitContent(){var a=view.getLayerByName("image"),b=a.children[1];if(b){var c=paper.view.viewSize.divide(b.size);attributes.setZoom(Math.min(c.width,c.height),"center"),paper.view.draw()}}function updateUserLayers(){config.ui.show_users_results&&($.each(view.getAllUsersLayers(),function(a,b){0==usersList.find("li[data-layer-id="+b.id+"]").length&&$(layerListItemTpl({id:b.id,visibleClass:visibleClass,name:b.data.owner||b.name})).prependTo(usersList)}),showUserLayerName(!$("#btn-layers-hidenames").hasClass("active")))}function onUserLayerVisChange(a,b){updateUserLayerState(getListItem(a),b)}function showUserLayerName(a){a=_.isUndefined(a)?!0:!!a,usersList.find(".list-group-item .layer-title").each(function(b,c){var d=$(c);d.text(a?d.data("name"):"Utilisateur "+(b+1))})}function selectLayerListItem(a,b){var c=$(a),d=c.data("layerId");if(!c.hasClass("selected")){var e=usersList.find(".list-group-item.selected");b&&(e.each(function(a,b){toggleLayer($(b),!1)}),toggleLayer(c,!0)),e.removeClass("selected"),c.addClass("selected");var f=view.getLayerByName(d);f&&(f.activate(),_events.userLayerActivated.dispatch({layer:f,userId:d}))}}function updateUserLayerState(a,b){a.toggleClass("layer-hidden",!b).find(".layer-status").toggleClass(hiddenClass,!b).toggleClass(visibleClass,b)}function toggleLayer(a,b){view.toggleLayer(a.data("layerId"),b)}function toggleAll(a){var b=a;usersList.find(".list-group-item").each(function(c,d){b=$(d).is(".selected")?!0:a,toggleLayer($(d),b)})}function _adjustCanvasFrame(){var a=_canvas.width(),b=_canvas.height();_canvasToolBar.css("width",a+4),_canvasCtnr.width(a+2).height(b+2),_sideCol.height(b+_canvasToolBar.outerHeight()+5);var c;_annotationListCtnr.length>0&&(c=b+_canvasCtnrTop-_annotationListCtnr.offset().top,_annotationListCtnr.css("maxHeight",Math.max(c,80))),_markerLabelListCtnr.length>0&&(c=b+_canvasCtnrTop-_markerLabelListCtnr.offset().top,_markerLabelListCtnr.css("maxHeight",Math.max(c,180))),_sharedMarkerLabelListCtnr.length>0&&(c=b+_canvasCtnrTop-_sharedMarkerLabelListCtnr.offset().top,_sharedMarkerLabelListCtnr.css("maxHeight",Math.max(c,180)))}function updateColorSelector(a){if("string"!=typeof a){if(!a||"function"!=typeof a.toCSS)return;a=a.toCSS()}_colorSelector.find(" > button").css("color",a),$("#tool-fill-color").css("color",a)}function setupColorSelector(a){if(a)_colorSelector.find(".tinter").attr("disabled","disabled"),updateColorSelector("#999");else{var b=null;_colorSelector.find(".tinter").removeAttr("disabled"),_colorSelector.find(".picker").colorpicker().on("mouseup",function(){var a=$(this).data("colorpicker"),b=a.picker;if(b.hasClass("colorpicker-visible")){var c=a.color.toRGB(),d="rgba("+c.r+", "+c.g+", "+c.b+", "+c.a+")";updateColorSelector(d),attributes.setColor(d),setTimeout(function(){_colorSelector.find(".picker").colorpicker("hide"),_colorSelector.find(".color-menu").dropdown("toggle")},100)}}).on("changeColor",function(a){var c=a.color.toRGB(),d="rgba("+c.r+", "+c.g+", "+c.b+", "+c.a+")";updateColorSelector(d),_colorSelector.find(".color-menu .cx").css("background-color",d),attributes.setColor(d,!1),b&&clearTimeout(b),b=setTimeout(function(a){return function(){attributes.setColor(a,!0)}}(d),1e3)}),_colorSelector.find(".color-menu > li > a").click(function(a){var b=$(this);if(a.preventDefault(),!b.is(".cx")){var c=b.css("background-color");updateColorSelector(c),attributes.setColor(c)}}),attributes.getColor()&&updateColorSelector(attributes.getColor().toCSS())}}function disableProperties(a){for(var b in itemProperties)a&&itemProperties[b].setValue(""),itemProperties[b].enable(!1)}function displayProperties(a){var b=!1;if(a&&a.data&&a.data.prop)for(var c in itemProperties)b=a.data.prop.hasOwnProperty(c)||"fill"===c,b?itemProperties[c].enable().setValue(a.data.prop[c]):itemProperties[c].enable(!1);else disableProperties()}function updateSelectedItemProp(a){if(a&&"string"==typeof a){var b=itemProperties[a].getValue(),c=!1;return null!==b&&void 0!==b&&(c=view.setSelectedItemProperty(a,b,!0)),c}}function onPropertyChange(a){updateSelectedItemProp(a.data.pName)}function onPropertyBlur(){}function initPropertiesPanel(){_.each(itemProperties,function(a,b){if("string"==typeof a.el){var c=$(a.el);1===c.length?(a.el=c,_.isFunction(a.init)&&a.init(),_.isFunction(a.onChange)?c.on("change",a.onChange):c.on("change",null,{pName:b},onPropertyChange),_.isFunction(a.onBlur)?c.on("blur",a.onBlur):c.on("blur",null,{pName:b},onPropertyBlur)):delete itemProperties[b]}}),disableProperties(!0),$(document).on("keydown",function(a){$("*:focus");switch(a.which){case 49:case 50:case 51:}})}function onToolActivated(a){var b=$("[data-tool-name]").filter("[checked=checked]"),c=$("[data-tool-name="+a+"]");$("[data-tool-name]").button(),b.get(0)!==c.get(0)&&(b.removeAttr("checked").parent(".btn").removeClass("active"),c.attr("checked","checked").parent(".btn").addClass("active")),_canvas.removeClass(function(a,b){var c=b.split(" ").filter(function(a){return a.match(/cursor-tool-/)});return c&&c.join(" ")}).addClass("cursor-tool-"+a)}function adjustCanvasToImage(){var a=_$w.width(),b=_$w.height(),c=a-_reservedWidth,d=320,e=b-_reservedHeight,f=240;a=Math.max(Math.min(a,c),d),b=Math.max(Math.min(b,e),f),view.resize(a,b),_adjustCanvasFrame()}function _showAnObjMgr(a){var b=this;a.preventDefault(),b._anObjMgr||(b._anObjMgr=new AnObjMgr({el:"#aom-modal",aomListCtner:$("#aom-user-images-list .aom-list-container"),sharedAomListCtner:$("#aom-shared-images-list .aom-list-container")})),b._anObjMgrModal||(b._anObjMgrModal=$("#aom-modal").data("loaded",!1).modal({show:!1})),b._anObjMgrModal.modal("show"),b._anObjMgrModal.data("loaded")||b._anObjMgr.loadAnObjs({success:function(){b._anObjMgrModal&&(b._anObjMgrModal.find(".aom-loader").remove(),b._anObjMgrModal.data("loaded",!0)),b._anObjMgr.selectCurrent()}})}function updateCurrentThumbnail(thumbnailPath){if(this._anObjMgrModal){var curItemImg=this._anObjMgrModal.find(".aom-list-item.current img");curItemImg&&0!==curItemImg.length&&(thumbnailPath&&""!==thumbnailPath||(thumbnailPath=eval("(function(){function url(u){return u}return "+curItemImg.css("backgroundImage")+"})()").split("?")[0]),curItemImg.css("backgroundImage",'url("'+thumbnailPath+"?nc=_"+(""+Math.random()).substr(3)+'")'))}}function _export(a){var b=config.annotable.slug+"__"+(config.mode===config.MODE_EDIT?config.user.username:"review");switch(a){case"png":exporter.export(b,"png",{callback:function(){adjustCanvasToImage()}}).done(function(){});break;case"svg":exporter.export(b,"svg")}}function setState(a){switch(a){case"thumbNotSaved":break;case"thumbSaved":this.updateCurrentThumbnail()}}var _$w=$(window),_canvas=null,_canvasCtnr=null,_canvasToolBar=null,_sideCol=null,_toolsCol=null,_minWind=!1,_annotationListCtnr=null,_markerLabelListCtnr=null,_sharedMarkerLabelListCtnr=null,_canvasCtnrTop,_colorSelector=$("#tool-colorselect"),_opacitySlider,_widthSlider,_reservedWidth=0,_reservedHeight=0,_events={modeChanged:new Signal,saveButClick:new Signal,autoSaveChanged:new Signal,userLayerActivated:new Signal},updateReservedSpace=function(){var a=$("#canvas-col").offset().top,b=_toolsCol.outerWidth(),c=_canvasToolBar.outerHeight();(updateReservedSpace=function(){_reservedWidth=(_toolsCol.is(":visible")?b:0)+(config.ui.show_side_col?_sideCol.is(".collapsed")?32:_sideCol.outerWidth():50)+24,_reservedHeight=a+c+20})()},usersListPanel=$("#annotation-list-panel"),usersListCtr=$("#annotation-list-container"),usersList=usersListCtr.find(" > ul"),hiddenClass="icon-eye-close",visibleClass="icon-eye-open",layerListItemTpl=_.template(['<li class="list-group-item" data-layer-id="<%= id %>">','<span class="layer-status <%= visibleClass %>"></span>','<span class="layer-title" data-name="<%= name %>"><%= name %></span>',"</li>"].join("")),getListItem=_.memoize(function(a){return usersList.find("li[data-layer-id="+a.id+"]")},function(a){return a.id});usersList.on("click",".layer-status",function(a){a.stopPropagation();var b=$(this),c=b.parent(".list-group-item");toggleLayer(c)}),usersList.on("click",".list-group-item",function(){selectLayerListItem(this,!1),toggleLayer($(this),!0)}),$("#btn-layers-hideall").click(function(){toggleAll(!1)}),$("#btn-layers-showall").click(function(){toggleAll(!0)}),$("#btn-layers-next").click(function(){var a=usersList.find(".list-group-item.selected").next();1===a.length&&selectLayerListItem(a,!0)}),$("#btn-layers-prev").click(function(){var a=usersList.find(".list-group-item.selected").prev();1===a.length&&selectLayerListItem(a,!0)}),$("#btn-layers-hidenames").on("click",function(){var a=$(this);a.toggleClass("active"),showUserLayerName(!a.hasClass("active"))});var transparentColor=new paper.Color(1,1,1,0),itemProperties={confidence:{el:"#confidence-input",enable:function(a){return a=void 0!==a?!!a:!0,this.el.attr("disabled")&&!a?this:(this.el.rating(a?"enable":"disable"),this.el.closest(".property-group").toggleClass("disabled",!a),config.mode!==config.MODE_EDIT&&this.el.rating("disable"),this)},setValue:function(a){return a=parseInt(a,10),isNaN(a)?void 0:(config.mode===config.MODE_EDIT?this.el.val(a).siblings("[data-value]").trigger("mouseleave"):this.el.siblings("[data-value]").each(function(b,c){var d=$(c);d.toggleClass("label-warning rating-on",d.data("value")<=a).toggleClass("rating-off",d.data("value")>a)}),this)},getValue:function(){var a=parseInt(this.el.val(),10);return isNaN(a)?null:a},init:function(){}},fill:{el:"#fill-check",enable:function(a){return a=void 0!==a?!!a:!0,config.mode!==config.MODE_EDIT&&(a=!1),a?this.el.removeAttr("disabled"):this.el.attr("disabled","disabled"),this.el.closest(".property-group").toggleClass("disabled",!a),this},setValue:function(a){return a=!!a,this.el.prop("checked",a),this},getValue:function(){return!!this.el.prop("checked")},onChange:function(){for(var a,b=$(this).is(":checked"),c=!1,d=view.getSelectedAnnotations(),e=0;a=d[e];e++)if("function"!=typeof a.data.setColor){if(a.data&&a.data.prop&&a.data.prop.fill===b)continue;c=!0,a.fillColor=b?paper.project.currentStyle.fillColor:null,paper.view.draw()}var f=updateSelectedItemProp("fill");c&&!f&&tools.events.annotationChanged.dispatch(d)},init:function(){}},comment:{el:"#prop-annot-comment",enable:function(a){return a=void 0!==a?!!a:!0,("review"===config.mode||config.annotable&&config.annotable.locked)&&(a=!1),a?this.el.removeAttr("disabled"):this.el.attr("disabled","disabled"),this.el.closest(".property-group").toggleClass("disabled",!a),this},setValue:function(a){return this.el.val(a),this},getValue:function(){return this.el.val()},init:function(){var a=this,b=null;a.el.on("keyup",function(){b&&clearTimeout(b),b=setTimeout(function(){updateSelectedItemProp("comment"),b=null},500)})}},nbConcordances:{el:"#prop-annot-nbconcordance",enable:function(a){return a=void 0!==a?!!a:!0,a||this.setValue(""),this.el.closest(".property-group").toggleClass("disabled",!a),this},setValue:function(a){return this.el.text(a),this},getValue:function(){return this.el.text()}},category:{el:"#prop-annot-category",enable:function(a){return a=void 0!==a?!!a:!0,this.el.find(".btn-cat").toggleClass("disabled",!a),this.el.closest(".property-group").toggleClass("disabled",!a),a||this.el.find(".btn-cat.active").removeClass("active"),this},init:function(){this.el.find(".btn-cat").addClass("disabled")},setValue:function(a){a=a||"cat_0",this.el.find(".btn-cat.active").removeClass("active"),this.el.find(".btn-cat[data-category='"+a+"']").addClass("active")},getValue:function(){var a=this.el.find(".btn-cat.active");return 1===a.length?a.data("category"):""}}};tools.events.activated.add(onToolActivated);var _raster=null;return{init:init,events:_events,updateUserLayers:updateUserLayers,showUserLayerName:showUserLayerName,displayProperties:displayProperties,updateReservedSpace:updateReservedSpace,adjustCanvasToImage:adjustCanvasToImage,exporter:exporter,updateCurrentThumbnail:updateCurrentThumbnail,setState:setState,enableTool:enableTool}});
/*! AdIm - v0.0.0 - 2016-01-05 - Copyright (C) 2016 Université de Lausanne - see licence */
/*! AdIm - v0.0.0 - 2016-03-14 - Copyright (C) 2016 Université de Lausanne - see licence */
define('helper/theme',["jquery"],function(a){var b={updateTheme:function(b){b=b||localStorage.getItem("adimTheme")||"dark",a("body").toggleClass("theme-light","light"===b).toggleClass("theme-dark","dark"===b),a("#main-navbar").toggleClass("navbar-inverse","dark"===b).toggleClass("navbar-default","light"===b).find(".btn-adim-dark, .btn-default").toggleClass("btn-adim-dark","dark"===b).toggleClass("btn-default","light"===b),a("#side-col").find(".panel").toggleClass("panel-dark","dark"===b).toggleClass("panel-default","light"===b)},setTheme:function(a){return!a||"dark"!==a&&"light"!==a||(localStorage.setItem("adimTheme",a),updateTheme()),!1}};return b});
/*!
* jQuery UI Widget 1.10.4+amd
......@@ -17797,7 +17797,7 @@ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
 
}));