if(typeof tc_translate=="undefined")tc_translate={keys:{}};
$.each({"process.button.log-ascent":"Log ascent(s)","process.button.log-ascent.one":"Log ascent","process.button.log-ascent.many":"Log {count} ascents","process.button.edit-item":"Edit item(s)","process.button.edit-item.one":"Edit item","process.button.edit-item.many":"Edit {count} items","process.button.add-route-above":"Add route above","process.button.add-route-below":"Add route below","process.button.add-annotation-above":"Add annotation above","process.button.add-annotation-below":"Add annotation below",
"process.button.archive-item":"Archive item","process.button.unarchive-item":"Unarchive item","process.button.move-item":"Move item(s)","process.button.move-item.one":"Move item","process.button.move-item.many":"Move {count} items","process.button.merge-items":"Merge items","process.button.your-ascent-history":"Your ascent history","process.button.all-ascent-history":"All ascent history","process.button.link-to-this-route":"Link to this route",x:""},function(d,b){if(typeof tc_translate.keys[d]=="undefined")tc_translate.keys[d]=
b});
function addDynamicListViewMenu(d,b){if(b.find(".actionarea").length>0)return false;var c=$("body").data("nid"),u=$("body").data("cctname"),v=$("body").data("uid"),k=$("body").data("can-edit"),l=$("body").data("can-reparent"),h=$("body").data("can-merge"),i=$("body").data("can-archive"),r=$("body").data("is-gym"),q="",m="R="+location.pathname,n=b.hasClass("archived"),w=b.data("collapsed");if(b.data("nid")){q=b.hasClass("route")?"route":b.hasClass("annotation")?"annotation":"area";id=b.data("nid")}var x=b.data("cctid"),
o=b.siblings("[data-nid].selected").add(b);selectIDs=o.map(function(){return $(this).data("nid")}).get();selectRouteIDs=[];selectAnnotationIDs=[];selectAreaIDs=[];var s={};o.each(function(){var j=$(this).data("nid");if($(this).hasClass("route")){selectRouteIDs.push(j);s.route=1}else if($(this).hasClass("area")){selectAreaIDs.push(j);s.area=1}else if($(this).hasClass("annotation")){selectAnnotationIDs.push(j);s.annotation=1}});var t=tc_translate.getText("process.button.log-ascent",{count:selectRouteIDs.length},
{count:selectRouteIDs.length}),e=$('input[name="D:NetworkNodeID"]'),p="";if(e.length){p=e.val();p="/processmap/logascent_multi/"+selectRouteIDs.join("+")+"?parent="+p+"&"+m}e=false;if(Object.keys(s).length>1)e=true;var a=tc_translate.getText("process.button.edit-item",{count:selectRouteIDs.length},{count:selectRouteIDs.length});tc_translate.getText("process.button.edit-item",{count:selectAreaIDs.length},{count:selectAreaIDs.length});var g=tc_translate.getText("process.button.edit-item",{count:selectAnnotationIDs.length},
{count:selectAnnotationIDs.length}),f=tc_translate.getText("process.button.edit-item",{count:selectIDs.length},{count:selectIDs.length});if(!e)if(q=="route")f=a;else if(q=="annotation")f=g;g="/processmap/bulkedit/"+selectIDs.join("+")+"?select=0&"+m;e="pencil";a=f;var y=g;if(q=="route"){e="ok";a=t;y=p}e=$('
');
a=e.find(".dropdown-menu");k?a.append(''+f+""):a.append(''+f+"");f=tc_translate.getText("process.button.add-annotation-above");g=tc_translate.getText("process.button.add-route-above");if(o.length==1&&k&&!w){a.append(''+g+"");a.append(''+f+"")}else{a.append(''+g+"");
a.append(''+f+"")}if(!b.next().length){f=tc_translate.getText("process.button.add-annotation-below");g=tc_translate.getText("process.button.add-route-below");a.append('');if(o.length==1&&k&&!w){a.append(''+g+"");a.append(''+f+"")}else{a.append(''+g+"");a.append(''+f+"")}}if(q=="route"){if(r){a.append('');
k=tc_translate.getText("process.button.archive-item");r=tc_translate.getText("process.button.unarchive-item");if(n)selectRouteIDs.length==1&&i?a.append(''+r+""):a.append(''+r+"");else selectRouteIDs.length==1&&i?a.append(''+k+""):a.append(''+k+"")}a.append('');i=tc_translate.getText("process.button.move-item",{count:selectIDs.length},{count:selectIDs.length});n=
"";if(l&&selectIDs.length>0)if(selectIDs.length==1){l=selectIDs[0];n="/processmap/reparentnode/"+l}else n="/processmap/reparentnode/"+c+"?CHECKBOX:AllChildren=1&D:ID="+selectIDs.join("&D:ID=")+"&D:NetworkNodeID="+c+"&C:HideNavigation=1&State:7126=Next&C:ReturnURL="+location.pathname;n.length>0?a.append(''+i+""):a.append(''+i+"");i=tc_translate.getText("process.button.merge-items");if(selectRouteIDs.length==2&&selectIDs.length==2&&h){l=selectRouteIDs[0];
a.append(''+i+"")}else a.append(''+i+"");a.append('');p.length>0?a.append(''+t+""):a.append(''+t+"");c=tc_translate.getText("process.button.your-ascent-history");h=o.has(".tick > a > span:not(.tick_unticked)").map(function(){return $(this).data("nid")}).get();if(h.length>
0){h="/ascents/at/"+h.join("+")+"/by/"+v;a.append(''+c+"")}else a.append(''+c+"");c=tc_translate.getText("process.button.all-ascent-history");if(selectRouteIDs.length>0){h="/ascents/at/"+selectRouteIDs.join("+");a.append(''+c+"")}else a.append(''+c+"");a.append('');c=tc_translate.getText("process.button.link-to-this-route");a.append(''+c+"")}if(o.length==
1&&x&&u){a.append('');a.append('Add route to active circuit').find(".cctlink").unbind("click").bind("click",function(){b.data("cctid",0);b.removeAttr("data-cctid");addRouteToCircuit(v,x,id,function(){})})}e.prependTo(b);a.find(".fn-archive").unbind("click").bind("click",function(j){return archiveRoute(j,$(this))});a.find(".fn-unarchive").unbind("click").bind("click",function(j){return unarchiveRoute(j,$(this))})}
function removeDynamicListViewMenu(d,b){if(b.find(".actionarea").length<1)return false;b.find(".actionarea").remove();b.removeClass("hover")}function updateDynamicListViewMenu(d,b){b.siblings("[data-nid].selected").each(function(){removeDynamicListViewMenu(d,$(this))});b.hasClass("selected")?addDynamicListViewMenu(d,b):removeDynamicListViewMenu(d,b)}
function updateDynamicListViewMenuForTouchscreen(d,b){if("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)updateDynamicListViewMenu(d,b)}(function(){if($("body").data("uid"))"ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch||$(".routetable, .node-listview").on({mouseenter:function(d){addDynamicListViewMenu(d,$(this))},mouseleave:function(d){removeDynamicListViewMenu(d,$(this))}},".route[data-nid], .annotation[data-nid]")})();