-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscripts.min.js
1 lines (1 loc) · 3.84 KB
/
scripts.min.js
1
var help_post_id=8612;var a=document.createElementNS("http://www.w3.org/2000/svg","a");var namespaceURI="http://www.w3.org/1999/xlink";var svgs=$("[data-id]");svgs.each(function(b,c){var d=$(c).data("id");$.each(config,function(e,f){if(d==f.id){a.setAttributeNS(namespaceURI,"href","/?p="+f.post);$(c).wrapInner(a);$(c).attr("data-postid",f.post);$(c).attr("data-level",getLevel(d));$(c).attr("data-segment",getSegment(d));return false}})});var loaded=[];var svg_el=$("svg","#svg").eq(0);var svg_w=svg_el.width();var svg_h=svg_el.height();var edit=$(".edit-post");svg_el.draggable();var r=$("#result");var part="#main article";var navigator={segment:null,level:null};$("body").on("click","#svg svg a",function(f){f.preventDefault();var b=$(this);var d=b.parents().eq(0);var h=d.data("postid");navigator.segment=d.data("segment");navigator.level=d.data("level");reloadNavigator();if(h){var c;if("undefined"==typeof(loaded[h])){$.ajax({url:b.attr("href"),dataType:"html",success:function(e){c=$(e).find(part).html();r.html(c);loaded[h]=c;b.addClass("loaded");setActive(b);edit.attr("href","/wp-admin/post.php?post="+h+"&action=edit");scrollToResult(r);if($(e).find("#wp-admin-bar-edit").length>0){edit.removeClass("hidden")}}})}else{c=loaded[h];r.html(c);setActive(b);edit.attr("href","/wp-admin/post.php?post="+h+"&action=edit");scrollToResult(r)}}else{r.html("")}}).on("click","#svg .zoom > *",function(f){f.preventDefault();var c=$(this);var b=svg_el.width();var d=svg_el.height();if(c.is(".in")){svg_el.width(b*1.2);svg_el.height(b*1.2)}else{if(c.is(".out")){svg_el.width(b/1.2);svg_el.height(d/1.2)}else{if(c.is(".orig")){svg_el.animate({top:"0px",left:"0px",width:svg_w,height:svg_h})}}}}).on("click","#svg .go-cell a",function(c){c.preventDefault();var b=$(this);if(b.data("segment")){navigator.segment=b.data("segment");$("#bavigatorSegment").html(b.data("segment"));navigate()}else{if(b.data("level")){navigator.level=b.data("level");$("#bavigatorLevel").html(b.data("level"));navigate()}}});function navigate(){if(navigator.segment&&navigator.level){$('[data-segment="'+navigator.segment+'"][data-level="'+navigator.level+'"] a').click()}reloadNavigator()}function reloadNavigator(){$("#bavigatorSegment").html(navigator.segment);$("#bavigatorLevel").html(navigator.level);var b=$(".dropdown-item",".go-cell");b.removeClass("active");b.filter('[data-segment="'+navigator.segment+'"]').addClass("active");b.filter('[data-level="'+navigator.level+'"]').addClass("active")}function setActive(b){if($("a","#svg svg").removeClass("active")){b.addClass("active");setNeighbours(b);setOposite(b)}}function setNeighbours(b){var d=b.parent();var f=d.data("id");var e=d.data("level");var c=d.data("segment");if($("[data-level]","#svg svg").removeClass("neighbour")){$('[data-level="'+(e-1)+'"], [data-level="'+e+'"], [data-level="'+(e+1)+'"]').filter($('[data-segment="'+((c-1)<1?24:c-1)+'"], [data-segment="'+c+'"], [data-segment="'+((c+1>24?1:c+1))+'"]')).not('[data-id="'+f+'"]').addClass("neighbour")}}function setOposite(c){var e=c.parent();var f=e.data("level");var d=e.data("segment");var b;if(d<=12){b=d+12}else{b=d-12}if($("[data-level]","#svg svg").removeClass("oposite")){$('[data-level="'+f+'"][data-segment="'+b+'"]').addClass("oposite")}}function getLevel(b){return Math.ceil(parseInt(b)/24)}function getSegment(c){var b=parseInt(c)%24;if(b===0){return 24}return b}function scrollToResult(b){$("html, body").animate({scrollTop:b.offset().top})}function loadPost(b){if("undefined"==typeof(loaded[b])){$.ajax({url:"/?p="+help_post_id,dataType:"html",success:function(c){html=$(c).find(part).html();r.html(html);edit.attr("href","/wp-admin/post.php?post="+b+"&action=edit");loaded[b]=html}})}else{html=loaded[b];r.html(html);edit.attr("href","/wp-admin/post.php?post="+b+"&action=edit")}}loadPost(help_post_id);$(".help","#svg").attr("href","/?p="+help_post_id).on("click",function(b){b.preventDefault();loadPost(help_post_id)});