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