Gitlab CSE Unil

Commit 4e2987a6 authored by M. Chardon's avatar M. Chardon
Browse files

résolution bug marqueur : erreur ordre listener

parent f13d7103
......@@ -1587,6 +1587,7 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export
* @param event
*/
function onPropertyChange(event) {
$(this).addClass("focus");
updateSelectedItemProp(event.data.pName);
}
......@@ -1621,7 +1622,12 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export
if (_.isFunction(pDef.onChange)) {
elem.on('change', pDef.onChange);
} else {
elem.on('change', null, {pName: pName}, onPropertyChange);
var elemBtn = elem.find(".btn-cat");
if (elemBtn) {
elem.find(".btn-cat").on('change', null, {pName: pName}, onPropertyChange);
}else{
elem.on('change', null, {pName: pName}, onPropertyChange);
}
}
if (_.isFunction(pDef['onBlur'])) {
......
......@@ -31060,6 +31060,7 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export
* @param event
*/
function onPropertyChange(event) {
$(this).addClass("focus");
updateSelectedItemProp(event.data.pName);
}
 
......@@ -31094,7 +31095,12 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export
if (_.isFunction(pDef.onChange)) {
elem.on('change', pDef.onChange);
} else {
elem.on('change', null, {pName: pName}, onPropertyChange);
var elemBtn = elem.find(".btn-cat");
if (elemBtn) {
elem.find(".btn-cat").on('change', null, {pName: pName}, onPropertyChange);
}else{
elem.on('change', null, {pName: pName}, onPropertyChange);
}
}
 
if (_.isFunction(pDef['onBlur'])) {
......@@ -31062,6 +31062,7 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export
* @param event
*/
function onPropertyChange(event) {
$(this).addClass("focus");
updateSelectedItemProp(event.data.pName);
}
 
......@@ -31096,7 +31097,12 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export
if (_.isFunction(pDef.onChange)) {
elem.on('change', pDef.onChange);
} else {
elem.on('change', null, {pName: pName}, onPropertyChange);
var elemBtn = elem.find(".btn-cat");
if (elemBtn) {
elem.find(".btn-cat").on('change', null, {pName: pName}, onPropertyChange);
}else{
elem.on('change', null, {pName: pName}, onPropertyChange);
}
}
 
if (_.isFunction(pDef['onBlur'])) {
......@@ -31060,6 +31060,7 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export
* @param event
*/
function onPropertyChange(event) {
$(this).addClass("focus");
updateSelectedItemProp(event.data.pName);
}
 
......@@ -31094,7 +31095,12 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export
if (_.isFunction(pDef.onChange)) {
elem.on('change', pDef.onChange);
} else {
elem.on('change', null, {pName: pName}, onPropertyChange);
var elemBtn = elem.find(".btn-cat");
if (elemBtn) {
elem.find(".btn-cat").on('change', null, {pName: pName}, onPropertyChange);
}else{
elem.on('change', null, {pName: pName}, onPropertyChange);
}
}
 
if (_.isFunction(pDef['onBlur'])) {
......@@ -31060,6 +31060,7 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export
* @param event
*/
function onPropertyChange(event) {
$(this).addClass("focus");
updateSelectedItemProp(event.data.pName);
}
 
......@@ -31094,7 +31095,12 @@ function($, _, Signal, paper, config, view, io, tools, attributes, Users, export
if (_.isFunction(pDef.onChange)) {
elem.on('change', pDef.onChange);
} else {
elem.on('change', null, {pName: pName}, onPropertyChange);
var elemBtn = elem.find(".btn-cat");
if (elemBtn) {
elem.find(".btn-cat").on('change', null, {pName: pName}, onPropertyChange);
}else{
elem.on('change', null, {pName: pName}, onPropertyChange);
}
}
 
if (_.isFunction(pDef['onBlur'])) {
......@@ -19504,7 +19504,7 @@ define('fontawesome', ['fontawesome/fontawesome-all.min'], function (main) { ret
define("fontawesome/fontawesome-all.min", function(){});
 
/*! AdIm - v0.0.0 - 2018-03-07 - Copyright (C) 2018 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.rating","fontawesome"],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"),_canvasCol=$("#canvas-col"),_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(".ml-auto"),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(a){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")&&void updateViewMode(d))}),$(".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(a){b._anObjNameModal.modal("hide")}).fail(function(a,c,d){var e=a.responseJSON.name||a.responseJSON.detail||c;b._anObjNameModal.find(".errors").show().find(".error-text").text(e)})}),this._anObjName=$("a.adim-image-name").on("click submit",function(a){a.preventDefault(),b._anObjNameModal.find(".errors").hide().end().find("input[name=imageName]").val(b._anObjName.find(".text").text()).end().modal("show")}).append($('<span class="gly"><i class="fa fa-pencil-alt"></i></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(a){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(a,b,c){}).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["edit","review"].indexOf(a)===-1&&(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.has("#side-col-panel-group.w-50").length&&(_sideCol.toggleClass("default",!a),_sideCol.toggleClass("w-25",a),_canvasCol.toggleClass("w-100",!a)),_sideCol.toggleClass("collapsed",!a),_sideCol.toggleClass(""),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)||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.prop("disabled",!1).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)&&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").prop("disabled",!1).click(function(){var a=!$(this).is(".active");$(this).toggleClass("active"),attributes.setFill(a)}),a.disabled?$("#attr-font").attr("disabled","disabled"):$("#attr-font").prop("disabled",!1).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" id="attr-font-div"><label style="float:left; line-height: 35px" class="small text-muted">Taille: &nbsp;</label><div class="input-group" style="width: 70px;"><input type="number" size="10" class="form-control" name="fontSize" id="attr-font-size" min="9" max="999" step="1" value="32"></div></div>'}).on("shown.bs.popover",function(){var a=$("#attr-font-div").parent().parent(),b=$("#attr-font-size").focus();b.val(attributes.getFontSize()),b.on("change",function(){attributes.setFontSize(parseInt(b.val(),10))});var c=function(b){var c=$.contains(a.get(0),b.target);c||d()},d=function(){$(document).off("click",c),$("#attr-font").popover("hide"),$("#attr-font").toggleClass("active")};a.find(".close").on("click",d),$(document).on("click",c)}),_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){var c=usersList.find("li[data-layer-id="+a.id+"]");updateUserLayerState(c,b)}function showUserLayerName(a){a=!!_.isUndefined(a)||!!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=a,toggleLayer($(d),b)})}function _adjustCanvasFrame(){var a=(_canvas.width(),_canvas.height());_canvasCtnr.height(a+2),_sideCol.height(a+_canvasToolBar.outerHeight()+5);var b;_annotationListCtnr.length>0&&(b=a+_canvasCtnrTop-_annotationListCtnr.offset().top,_annotationListCtnr.css("maxHeight",Math.max(b,80))),_markerLabelListCtnr.length>0&&(b=a+_canvasCtnrTop-_markerLabelListCtnr.offset().top,_markerLabelListCtnr.css("maxHeight",Math.max(b,180))),_sharedMarkerLabelListCtnr.length>0&&(b=a+_canvasCtnrTop-_sharedMarkerLabelListCtnr.offset().top,_sharedMarkerLabelListCtnr.css("maxHeight",Math.max(b,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").prop("disabled",!1),_colorSelector.find(".picker").colorpicker().on("mouseup",function(a){var b=$(this).data("colorpicker"),c=b.picker;if(c.hasClass("colorpicker-visible")){var d=b.color.toRGB(),e="rgba("+d.r+", "+d.g+", "+d.b+", "+d.a+")";updateColorSelector(e),attributes.setColor(e),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 > 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(a){}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){_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(a){var b=_$w.width(),c=_$w.height(),d=_canvasCtnr.outerWidth(),e=320,f=c-_reservedHeight,g=240;b=Math.max(Math.min(b,d),e),c=Math.max(Math.min(c,f),g),view.resize(b,c),_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(a){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(""));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(){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,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){if(a=parseInt(a,10),!isNaN(a))return 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("badge-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,config.mode!==config.MODE_EDIT&&(a=!1),a?this.el.prop("disabled",!1):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;if(c=!0,b){var f=paper.project.currentStyle.fillColor;if(a.data)try{f=a.data.getColorBgD()}finally{}a.fillColor=f}else a.fillColor=null;paper.view.draw()}var g=updateSelectedItemProp("fill");c&&!g&&tools.events.annotationChanged.dispatch(d)},init:function(){}},comment:{el:"#prop-annot-comment",enable:function(a){return a=void 0===a||!!a,("review"===config.mode||config.annotable&&config.annotable.locked)&&(a=!1),a?this.el.prop("disabled",!1):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(a){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,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,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 a.length<1&&(a=this.el.find(".btn-cat.focus")),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}});
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.rating","fontawesome"],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"),_canvasCol=$("#canvas-col"),_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(".ml-auto"),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(a){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")&&void updateViewMode(d))}),$(".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(a){b._anObjNameModal.modal("hide")}).fail(function(a,c,d){var e=a.responseJSON.name||a.responseJSON.detail||c;b._anObjNameModal.find(".errors").show().find(".error-text").text(e)})}),this._anObjName=$("a.adim-image-name").on("click submit",function(a){a.preventDefault(),b._anObjNameModal.find(".errors").hide().end().find("input[name=imageName]").val(b._anObjName.find(".text").text()).end().modal("show")}).append($('<span class="gly"><i class="fa fa-pencil-alt"></i></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(a){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(a,b,c){}).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["edit","review"].indexOf(a)===-1&&(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.has("#side-col-panel-group.w-50").length&&(_sideCol.toggleClass("default",!a),_sideCol.toggleClass("w-25",a),_canvasCol.toggleClass("w-100",!a)),_sideCol.toggleClass("collapsed",!a),_sideCol.toggleClass(""),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)||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.prop("disabled",!1).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)&&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").prop("disabled",!1).click(function(){var a=!$(this).is(".active");$(this).toggleClass("active"),attributes.setFill(a)}),a.disabled?$("#attr-font").attr("disabled","disabled"):$("#attr-font").prop("disabled",!1).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" id="attr-font-div"><label style="float:left; line-height: 35px" class="small text-muted">Taille: &nbsp;</label><div class="input-group" style="width: 70px;"><input type="number" size="10" class="form-control" name="fontSize" id="attr-font-size" min="9" max="999" step="1" value="32"></div></div>'}).on("shown.bs.popover",function(){var a=$("#attr-font-div").parent().parent(),b=$("#attr-font-size").focus();b.val(attributes.getFontSize()),b.on("change",function(){attributes.setFontSize(parseInt(b.val(),10))});var c=function(b){var c=$.contains(a.get(0),b.target);c||d()},d=function(){$(document).off("click",c),$("#attr-font").popover("hide"),$("#attr-font").toggleClass("active")};a.find(".close").on("click",d),$(document).on("click",c)}),_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){var c=usersList.find("li[data-layer-id="+a.id+"]");updateUserLayerState(c,b)}function showUserLayerName(a){a=!!_.isUndefined(a)||!!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=a,toggleLayer($(d),b)})}function _adjustCanvasFrame(){var a=(_canvas.width(),_canvas.height());_canvasCtnr.height(a+2),_sideCol.height(a+_canvasToolBar.outerHeight()+5);var b;_annotationListCtnr.length>0&&(b=a+_canvasCtnrTop-_annotationListCtnr.offset().top,_annotationListCtnr.css("maxHeight",Math.max(b,80))),_markerLabelListCtnr.length>0&&(b=a+_canvasCtnrTop-_markerLabelListCtnr.offset().top,_markerLabelListCtnr.css("maxHeight",Math.max(b,180))),_sharedMarkerLabelListCtnr.length>0&&(b=a+_canvasCtnrTop-_sharedMarkerLabelListCtnr.offset().top,_sharedMarkerLabelListCtnr.css("maxHeight",Math.max(b,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").prop("disabled",!1),_colorSelector.find(".picker").colorpicker().on("mouseup",function(a){var b=$(this).data("colorpicker"),c=b.picker;if(c.hasClass("colorpicker-visible")){var d=b.color.toRGB(),e="rgba("+d.r+", "+d.g+", "+d.b+", "+d.a+")";updateColorSelector(e),attributes.setColor(e),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 > 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){$(this).addClass("focus"),updateSelectedItemProp(a.data.pName)}function onPropertyBlur(a){}function initPropertiesPanel(){_.each(itemProperties,function(a,b){if("string"==typeof a.el){var c=$(a.el);if(1===c.length){if(a.el=c,_.isFunction(a.init)&&a.init(),_.isFunction(a.onChange))c.on("change",a.onChange);else{var d=c.find(".btn-cat");d?c.find(".btn-cat").on("change",null,{pName:b},onPropertyChange):c.on("change",null,{pName:b},onPropertyChange)}_.isFunction(a.onBlur)?c.on("blur",a.onBlur):c.on("blur",null,{pName:b},onPropertyBlur)}else delete itemProperties[b]}}),disableProperties(!0),$(document).on("keydown",function(a){$("*:focus");switch(a.which){case 49:case 50:case 51:}})}function onToolActivated(a){_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(a){var b=_$w.width(),c=_$w.height(),d=_canvasCtnr.outerWidth(),e=320,f=c-_reservedHeight,g=240;b=Math.max(Math.min(b,d),e),c=Math.max(Math.min(c,f),g),view.resize(b,c),_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(a){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(""));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(){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,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){if(a=parseInt(a,10),!isNaN(a))return 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("badge-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,config.mode!==config.MODE_EDIT&&(a=!1),a?this.el.prop("disabled",!1):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;if(c=!0,b){var f=paper.project.currentStyle.fillColor;if(a.data)try{f=a.data.getColorBgD()}finally{}a.fillColor=f}else a.fillColor=null;paper.view.draw()}var g=updateSelectedItemProp("fill");c&&!g&&tools.events.annotationChanged.dispatch(d)},init:function(){}},comment:{el:"#prop-annot-comment",enable:function(a){return a=void 0===a||!!a,("review"===config.mode||config.annotable&&config.annotable.locked)&&(a=!1),a?this.el.prop("disabled",!1):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(a){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,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,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 a.length<1&&(a=this.el.find(".btn-cat.focus")),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 - 2018-03-07 - Copyright (C) 2018 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-secondary").toggleClass("btn-adim-dark","dark"===b).toggleClass("btn-secondary","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 - v1.12.1 - 2018-02-10
......@@ -19504,7 +19504,7 @@ define('fontawesome', ['fontawesome/fontawesome-all.min'], function (main) { ret
define("fontawesome/fontawesome-all.min", function(){});
 
/*! AdIm - v0.0.0 - 2018-03-07 - Copyright (C) 2018 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.rating","fontawesome"],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"),_canvasCol=$("#canvas-col"),_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(".ml-auto"),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(a){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")&&void updateViewMode(d))}),$(".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(a){b._anObjNameModal.modal("hide")}).fail(function(a,c,d){var e=a.responseJSON.name||a.responseJSON.detail||c;b._anObjNameModal.find(".errors").show().find(".error-text").text(e)})}),this._anObjName=$("a.adim-image-name").on("click submit",function(a){a.preventDefault(),b._anObjNameModal.find(".errors").hide().end().find("input[name=imageName]").val(b._anObjName.find(".text").text()).end().modal("show")}).append($('<span class="gly"><i class="fa fa-pencil-alt"></i></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(a){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(a,b,c){}).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["edit","review"].indexOf(a)===-1&&(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.has("#side-col-panel-group.w-50").length&&(_sideCol.toggleClass("default",!a),_sideCol.toggleClass("w-25",a),_canvasCol.toggleClass("w-100",!a)),_sideCol.toggleClass("collapsed",!a),_sideCol.toggleClass(""),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)||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.prop("disabled",!1).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)&&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").prop("disabled",!1).click(function(){var a=!$(this).is(".active");$(this).toggleClass("active"),attributes.setFill(a)}),a.disabled?$("#attr-font").attr("disabled","disabled"):$("#attr-font").prop("disabled",!1).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" id="attr-font-div"><label style="float:left; line-height: 35px" class="small text-muted">Taille: &nbsp;</label><div class="input-group" style="width: 70px;"><input type="number" size="10" class="form-control" name="fontSize" id="attr-font-size" min="9" max="999" step="1" value="32"></div></div>'}).on("shown.bs.popover",function(){var a=$("#attr-font-div").parent().parent(),b=$("#attr-font-size").focus();b.val(attributes.getFontSize()),b.on("change",function(){attributes.setFontSize(parseInt(b.val(),10))});var c=function(b){var c=$.contains(a.get(0),b.target);c||d()},d=function(){$(document).off("click",c),$("#attr-font").popover("hide"),$("#attr-font").toggleClass("active")};a.find(".close").on("click",d),$(document).on("click",c)}),_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){var c=usersList.find("li[data-layer-id="+a.id+"]");updateUserLayerState(c,b)}function showUserLayerName(a){a=!!_.isUndefined(a)||!!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=a,toggleLayer($(d),b)})}function _adjustCanvasFrame(){var a=(_canvas.width(),_canvas.height());_canvasCtnr.height(a+2),_sideCol.height(a+_canvasToolBar.outerHeight()+5);var b;_annotationListCtnr.length>0&&(b=a+_canvasCtnrTop-_annotationListCtnr.offset().top,_annotationListCtnr.css("maxHeight",Math.max(b,80))),_markerLabelListCtnr.length>0&&(b=a+_canvasCtnrTop-_markerLabelListCtnr.offset().top,_markerLabelListCtnr.css("maxHeight",Math.max(b,180))),_sharedMarkerLabelListCtnr.length>0&&(b=a+_canvasCtnrTop-_sharedMarkerLabelListCtnr.offset().top,_sharedMarkerLabelListCtnr.css("maxHeight",Math.max(b,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").prop("disabled",!1),_colorSelector.find(".picker").colorpicker().on("mouseup",function(a){var b=$(this).data("colorpicker"),c=b.picker;if(c.hasClass("colorpicker-visible")){var d=b.color.toRGB(),e="rgba("+d.r+", "+d.g+", "+d.b+", "+d.a+")";updateColorSelector(e),attributes.setColor(e),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 > 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(a){}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){_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(a){var b=_$w.width(),c=_$w.height(),d=_canvasCtnr.outerWidth(),e=320,f=c-_reservedHeight,g=240;b=Math.max(Math.min(b,d),e),c=Math.max(Math.min(c,f),g),view.resize(b,c),_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(a){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(""));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(){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,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){if(a=parseInt(a,10),!isNaN(a))return 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("badge-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,config.mode!==config.MODE_EDIT&&(a=!1),a?this.el.prop("disabled",!1):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;if(c=!0,b){var f=paper.project.currentStyle.fillColor;if(a.data)try{f=a.data.getColorBgD()}finally{}a.fillColor=f}else a.fillColor=null;paper.view.draw()}var g=updateSelectedItemProp("fill");c&&!g&&tools.events.annotationChanged.dispatch(d)},init:function(){}},comment:{el:"#prop-annot-comment",enable:function(a){return a=void 0===a||!!a,("review"===config.mode||config.annotable&&config.annotable.locked)&&(a=!1),a?this.el.prop("disabled",!1):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(a){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,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,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 a.length<1&&(a=this.el.find(".btn-cat.focus")),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}});
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.rating","fontawesome"],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"),_canvasCol=$("#canvas-col"),_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(".ml-auto"),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(a){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")&&void updateViewMode(d))}),$(".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(a){b._anObjNameModal.modal("hide")}).fail(function(a,c,d){var e=a.responseJSON.name||a.responseJSON.detail||c;b._anObjNameModal.find(".errors").show().find(".error-text").text(e)})}),this._anObjName=$("a.adim-image-name").on("click submit",function(a){a.preventDefault(),b._anObjNameModal.find(".errors").hide().end().find("input[name=imageName]").val(b._anObjName.find(".text").text()).end().modal("show")}).append($('<span class="gly"><i class="fa fa-pencil-alt"></i></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(a){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(a,b,c){}).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["edit","review"].indexOf(a)===-1&&(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.has("#side-col-panel-group.w-50").length&&(_sideCol.toggleClass("default",!a),_sideCol.toggleClass("w-25",a),_canvasCol.toggleClass("w-100",!a)),_sideCol.toggleClass("collapsed",!a),_sideCol.toggleClass(""),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)||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.prop("disabled",!1).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)&&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").prop("disabled",!1).click(function(){var a=!$(this).is(".active");$(this).toggleClass("active"),attributes.setFill(a)}),a.disabled?$("#attr-font").attr("disabled","disabled"):$("#attr-font").prop("disabled",!1).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" id="attr-font-div"><label style="float:left; line-height: 35px" class="small text-muted">Taille: &nbsp;</label><div class="input-group" style="width: 70px;"><input type="number" size="10" class="form-control" name="fontSize" id="attr-font-size" min="9" max="999" step="1" value="32"></div></div>'}).on("shown.bs.popover",function(){var a=$("#attr-font-div").parent().parent(),b=$("#attr-font-size").focus();b.val(attributes.getFontSize()),b.on("change",function(){attributes.setFontSize(parseInt(b.val(),10))});var c=function(b){var c=$.contains(a.get(0),b.target);c||d()},d=function(){$(document).off("click",c),$("#attr-font").popover("hide"),$("#attr-font").toggleClass("active")};a.find(".close").on("click",d),$(document).on("click",c)}),_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){var c=usersList.find("li[data-layer-id="+a.id+"]");updateUserLayerState(c,b)}function showUserLayerName(a){a=!!_.isUndefined(a)||!!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=a,toggleLayer($(d),b)})}function _adjustCanvasFrame(){var a=(_canvas.width(),_canvas.height());_canvasCtnr.height(a+2),_sideCol.height(a+_canvasToolBar.outerHeight()+5);var b;_annotationListCtnr.length>0&&(b=a+_canvasCtnrTop-_annotationListCtnr.offset().top,_annotationListCtnr.css("maxHeight",Math.max(b,80))),_markerLabelListCtnr.length>0&&(b=a+_canvasCtnrTop-_markerLabelListCtnr.offset().top,_markerLabelListCtnr.css("maxHeight",Math.max(b,180))),_sharedMarkerLabelListCtnr.length>0&&(b=a+_canvasCtnrTop-_sharedMarkerLabelListCtnr.offset().top,_sharedMarkerLabelListCtnr.css("maxHeight",Math.max(b,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").prop("disabled",!1),_colorSelector.find(".picker").colorpicker().on("mouseup",function(a){var b=$(this).data("colorpicker"),c=b.picker;if(c.hasClass("colorpicker-visible")){var d=b.color.toRGB(),e="rgba("+d.r+", "+d.g+", "+d.b+", "+d.a+")";updateColorSelector(e),attributes.setColor(e),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 > 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){$(this).addClass("focus"),updateSelectedItemProp(a.data.pName)}function onPropertyBlur(a){}function initPropertiesPanel(){_.each(itemProperties,function(a,b){if("string"==typeof a.el){var c=$(a.el);if(1===c.length){if(a.el=c,_.isFunction(a.init)&&a.init(),_.isFunction(a.onChange))c.on("change",a.onChange);else{var d=c.find(".btn-cat");d?c.find(".btn-cat").on("change",null,{pName:b},onPropertyChange):c.on("change",null,{pName:b},onPropertyChange)}_.isFunction(a.onBlur)?c.on("blur",a.onBlur):c.on("blur",null,{pName:b},onPropertyBlur)}else delete itemProperties[b]}}),disableProperties(!0),$(document).on("keydown",function(a){$("*:focus");switch(a.which){case 49:case 50:case 51:}})}function onToolActivated(a){_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(a){var b=_$w.width(),c=_$w.height(),d=_canvasCtnr.outerWidth(),e=320,f=c-_reservedHeight,g=240;b=Math.max(Math.min(b,d),e),c=Math.max(Math.min(c,f),g),view.resize(b,c),_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(a){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(""));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(){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,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){if(a=parseInt(a,10),!isNaN(a))return 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("badge-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,config.mode!==config.MODE_EDIT&&(a=!1),a?this.el.prop("disabled",!1):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;if(c=!0,b){var f=paper.project.currentStyle.fillColor;if(a.data)try{f=a.data.getColorBgD()}finally{}a.fillColor=f}else a.fillColor=null;paper.view.draw()}var g=updateSelectedItemProp("fill");c&&!g&&tools.events.annotationChanged.dispatch(d)},init:function(){}},comment:{el:"#prop-annot-comment",enable:function(a){return a=void 0===a||!!a,("review"===config.mode||config.annotable&&config.annotable.locked)&&(a=!1),a?this.el.prop("disabled",!1):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(a){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,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,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 a.length<1&&(a=this.el.find(".btn-cat.focus")),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 - 2018-03-07 - Copyright (C) 2018 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-secondary").toggleClass("btn-adim-dark","dark"===b).toggleClass("btn-secondary","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 - v1.12.1 - 2018-02-10
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment