var Knoema,gaTracker;$(function(){$("body").on("click","div#atlas-tab-content div#letters a",function(){var i=$(this).closest("div#atlas-tab-content"),n=i.find("div.container"),t=n.find("li"+this.hash);return $("div#atlas").hasClass("new")?$(window).stop(!0).scrollTo(t,{duration:1,interrupt:!0}):n.stop(!0).scrollTo(t,{duration:300,interrupt:!0}),!1});var n="";$("body").on("keyup","div#atlas-tab-content div.filter-textarea input",function(){var i=$(this),r=i.val().toLowerCase(),t;n!=r&&(n=r,t=i.closest("div#atlas-tab-content").find("li.letter"),t.hide(),t.find("ul li").each(function(t,i){var r=$(i),u=r.find("a").text().toLowerCase();n==""||u.indexOf(n)!=-1?(r.show(),r.parents("li.letter").show()):r.hide()}))});$.defaultText({context:"div#atlas div.filter-textarea"})}),gaTracker=gaTracker||{},$(function(){function y(){var r=$("div#menu-holder ul").height()!=null,i=$("div#menu-holder ul").height()||$("div#atlas-header ul").height()+3+15,n,u,t;r&&(i-=1),n=$("div.atlas-tab-content","div#atlas-tab-content"),n.height()500&&n.find("div.container").css("min-height",t).css("max-height",t))}function t(n,t,i){var f;if(n){f=(n.href+"").replace(window.location.protocol,"").replace(window.location.host,"").replace("//",""),i||(a?history.pushState({href:n.href,topicTab:t},n.innerHTML,n.href):window.location.hash=n.attributes["data-fragment"].value),$("div.atlas-tab-content").height(800);var r=[],u=[],e=n.href.split("/");e[e.length-1]=="datasets"&&$("a#login").length==0&&u.push(Knoema.Utils.apiGet("/api/1.0/me/pinned/",function(n){for(var t=0;t0){for(f=0;f0?void 0:($(this).closest("ul.topic-tabs").length>0?t(this,!0,!1):t(this,!1,!1),!1):!0});e=null;$("body").on("click","div.dsbrowser2 a.dataset-result-title",function(){var n=$(this);return n.hasClass("active")?(n.removeClass("active").parent().removeClass("active").next().slideUp(500,"easeOutQuad"),e=null):(e!=null&&e.removeClass("active").parent().removeClass("active").next().slideUp(500,"easeOutQuad"),n.addClass("active").parent().addClass("active").next().slideDown(500,"easeOutQuad"),e=n),!1});$("body").on("click","div.dsbrowser2 span.dataset-result-arrow",function(){$(this).next().click()});$("body").on("click","div#atlas div.container.dsbrowser2 a.dataset-pin",function(){var n=$(this),t=this.id,i=n.data("datasetname");return $.ajax({url:this.href+"?rnd="+Math.random(),data:{},complete:function(r){r.getResponseHeader("Content-Length")!="0"?window.location.href="/sys/login/?returnUrl="+encodeURI(window.location.pathname):n.hasClass("pinned")?(gaTracker.Unpin(i,t),n.removeClass("pinned").addClass("unpinned")):(gaTracker.Pin(i,t),n.removeClass("unpinned").addClass("pinned"))}}),!1});$("body").on("click","div#atlas div.container.topics-list a.ajax-handle",function(){if(!Modernizr.history)return!0;var n=o.filter("."+this.attributes["data-fragment"].value);return t(n.get(0)||this),!1});$(window).on("popstate.atlas",function(n){var i=n.originalEvent.state?n.originalEvent.state.topicTab:!1,r=$("a.atlas-nav").each(function(n,r){if(r.href==window.location.href&&!c)return i?t(r,i,!0):t(r,$(r).closest("ul").hasClass("topic-tabs"),!0),!1})})}),$(function(){function f(){return Math.floor((document.documentElement.clientWidth-u)*.5)-4}function t(){return document.documentElement.clientHeight*.5-21}function e(r){$(r).scrollTop()>i?n.hasClass("visible")||n.addClass("visible").animate({opacity:.7},500):n.removeClass("visible").css("opacity",0),n.css("bottom",t())}var o=document.documentElement.scrollHeight,i=document.documentElement.clientHeight*2/3,r=document.getElementById("site-main"),u,n;if(r){u=r.clientWidth,n=$("span#back-to-top"),n.css("right",f()).css("bottom",t()),e(window),$(window).resize(function(){o=document.documentElement.scrollHeight,i=document.documentElement.clientHeight*2/3,n.css("right",f()).css("bottom",t())}),$(window).scroll(function(){e(this)});$("div#site-main").on("click","span#back-to-top",function(){window.scrollTo(0,0)})}}),$(document).ready(function(){navigator.vendor!=null&&navigator.vendor.indexOf("Google")!=-1&&navigator.userAgent.indexOf("Android")==-1&&(chrome&&chrome.app&&chrome.app.isInstalled||Globalize.culture().language=="en"&&($("#atlas-chrome-app-install").click(function(n){window.location.host.indexOf("knoema.com")!==-1&&(n.preventDefault(),chrome.webstore.install("https://chrome.google.com/webstore/detail/knlgfedckdhkgjinnhogmhkbcjpmmhko",function(){$("#atlas-chrome-app-install").hide()},function(){}))}),$("#atlas-chrome-app-install").show()))}),$(function(){$("tbody","table.compare").each(function(n,t){$tbody=$(t),$tbody.children().length===0&&$tbody.closest("table").hide()}),$("div:last","div#country-values").css("margin-right",0);$("body").on("click","a.dialog.button",function(){var n={selected:$("input#selected-regions").length>0?$("input#selected-regions").val().split(","):null,level:$(this).attr("data-level")||2,parent:$(this).attr("data-region-id")||null,countries:$("#countries-ids").val()?$("#countries-ids").val().split(","):[],groupName:$("#countries-group-name").val()?$("#countries-group-name").val():""};return Knoema.Widget.AtlasCompare(this.href,n)});$("body").on("click","ul#atlas-tabs.matrix a",function(){var t,n;return $("a","ul#atlas-tabs.matrix").removeClass("active"),t=$(this),t.addClass("active"),t.hasClass("growth")?($("h3.h3-growth").addClass("active"),$("h3.h3-scale").removeClass("active"),$("tr.no-scale","table.compare").show()):($("tr.no-scale","table.compare").hide(),$("h3.h3-scale").addClass("active"),$("h3.h3-growth").removeClass("active")),n=$("span.value"),n.hasClass("small")?n.removeClass("small"):n.addClass("small"),$("span.growth-change").toggle(),$("span.scale-change").toggle(),!1});$("body").on("click","div#atlas div#divider a.export.button",function(){var i=$("div#tables-holder","div#atlas"),t,n;return i.length&&(t=i.clone().wrap("
").parent(),t.find("h3.active").show(),n=$("form#export-form"),n.attr("action",$(this).attr("href")),n.find("input#export-form-content").val(t.html()),mixpanelTracker.track("Export",{Format:"pdf"},function(){n.submit()}),mixpanelTracker.increment("Number Of Exports")),!1})}),$(function(){var r=$("div.embed-footer"),t,n,i;r.length>0&&(c12n.get($("input#userKey").val(),function(n){$.tmpl("embed-action",{canExport:!1,canShare:!1,isEmbed:!0,background:"#"+n.background,text:n.text,logo:n.logo,title:n.title}).insertAfter($("div.embed-footer"))}),$("").appendTo("head"),t=81,$("div#atlas div#indicator, div#atlas h3, div#atlas>p, div#atlas div#country-values, div#atlas>div.footer.footnote-added").each(function(n,i){t+=$(i).outerHeight(!0)}),n=$("body").height()-t,$("div#site-holder div.gadget-host").height(n),parseInt($("div#site-holder div.gadget-host").css("min-height"))>n&&$("div#site-holder div.gadget-host").css("min-height",n),i=n-$("div#atlas div#top-bottom h5").outerHeight(!0),$("div#top5, div#bot5").height(i/2-10))}),Knoema=Knoema||{},Knoema.AtlasEditor=function(n){this._atlasOptions=n,this._container=null,this._atlasMetadata=null,this._factsDataset=null,this.indicatorEditorContext=null,this._dimfilter=null,this._factsDatasetChanged=!1,this._saveMetadataUrl="saveatlas",this._metadataUrl="download?CountryId="+this._atlasOptions.CountryId,this._atlasChanged=!1,this.structuredFacts=[],this.structuredTopics=[],this._closedSubtopics=[]},Knoema.AtlasEditor.prototype._evalEntityByPath=function(n){for(var e,o,r,u=n.split("."),f,s,i,t=0;t$(t).next(":has(td[colspan])").index()){u=$(t).attr("data-group");return}}),$.each($("#facts .knoema-table tbody tr[data-fact-index]"),function(n,t){$(t).attr("data-fact-index",n)}),r.attr("data-fact-group",u),i.structuredFacts[u-1]=[],$.each($("#facts .knoema-table tbody tr[data-fact-group="+u+"]"),function(n,t){var r=$(t).find("td[data-column]"),f={Column:r.attr("data-column"),Title:r.attr("data-title"),TitleColumn:r.attr("data-title-column"),DateColumn:r.attr("data-date-column"),Precision:parseInt(r.attr("data-precision")),IsSubstring:r.attr("data-is-substring")=="true",Group:r.parent().attr("data-fact-group")};i.structuredFacts[u-1].push(f)}),f!=u&&i.structuredFacts[f-1].splice(s,1),i._atlasChanged=!0,i._container.trigger("factsChanged")}}).disableSelection(),$(".ui-button").button()}),n.busy(Knoema.Utils.apiGet(i._metadataUrl,function(t){t==null?t={Dataset:null,Facts:[],Topics:[]}:t.Facts||(t.Facts=[]),i._factsDatasetChanged||(i._atlasMetadata=t),i.structureData(i._atlasMetadata.Facts,"Group",i.structuredFacts),i.structureData(i._atlasMetadata.Topics,"Column",i.structuredTopics),i._atlasMetadata.Facts=[],i._atlasMetadata.Topics=[],n.empty();var r=$.tmpl("atlas-metadata-editor",i._atlasOptions);n.append(r),n.delegate("a.delete-fact","click",function(n){var t=$(n.target).closest("tr[data-fact-index]"),r=t.attr("data-fact-group"),u=t.attr("data-fact-index");i.structuredFacts[r-1].splice(u,1),i._container.trigger("factsChanged")}),n.delegate("#create-fact","click",function(){var t={};t.factsDataset=i._factsDataset,t.factIndex="",t.fact={Group:null},i.initFactForm(t,$.R("~/Js/Atlas/Knoema.AtlasEditor.js","Create new fact"))}),n.delegate("a.edit-fact","click",function(n){var t=$(n.target).parent(),u=t.parent(),f=u.attr("data-fact-index"),e=u.attr("data-fact-group"),r={};r.factIndex=f,r.factsDataset=i._factsDataset,r.fact={Group:e,Column:t.attr("data-column"),TitleColumn:t.attr("data-title-column"),Title:t.attr("data-title"),DateColumn:t.attr("data-date-column"),Precision:t.attr("data-precision"),IsSubstring:t.attr("data-is-substring")=="true"},i.initFactForm(r,$.R("~/Js/Atlas/Knoema.AtlasEditor.js","Edit fact"))}),n.delegate("#create-group","click",function(){var t=$("#facts table.knoema-table tbody tr[data-group]").last().attr("data-group"),u=$("#facts table.knoema-table tbody tr[data-fact-group="+t+"]").length,r;(u>0||typeof t=="undefined")&&(typeof t=="undefined"?t=1:t++,r=$(Knoema.Utils.buildHTML("tr",'Group '+t+"<\/td><\/tr>",{"data-group":t})),$(i._container).find("#facts table.knoema-table tbody").append(r),i.structuredFacts.push([]),$("#create-fact").show())}),$("#tabs").tabs({select:function(n,t){var u=$(t.panel),f,e,r;switch(u.attr("id")){case"facts":i._atlasMetadata.Dataset==null?(f=$.tmpl("atlas-metadata-facts",{metadata:i._atlasMetadata,factsDatasetDetails:{},isCommunity:i._atlasOptions.Community}),u.html(f),$("#facts-list").hide(),$("#facts").find(".infomessage").show()):Knoema.Utils.apiGet("/api/1.0/meta/dataset/"+i._atlasMetadata.Dataset,function(n){i._factsDataset=n;var t=$.tmpl("atlas-metadata-facts",{metadata:i._atlasMetadata,factsDatasetDetails:n});u.html(t),i._container.trigger("factsChanged"),$("#facts").find(".infomessage").hide()});break;case"topics":i._selectTopic(),e=!i._atlasOptions.Community&&(i._atlasOptions.CountryId?!1:!0),$("#topics").html($.tmpl("atlas-metadata-topics",{structuredTopics:i.structuredTopics,isWDA:e})),$("#topic-select").trigger("change"),i.structuredTopics.length==0&&$("#topic-indicators").hide();break;case"lang":for(r=0;r-1;$("#lang").html($.tmpl("atlas-metadata-culture",{Languages:i._atlasOptions.Languages,Metadata:i._atlasMetadata}))}}}),$("#tabs").tabs("select",1)}));n.on("click","a#country-selector",function(){var n=$(this),t={},r,u;n.hasClass("not-set")||(t.id=n.text()),r={level:2,multiSelect:!1,selectedRegion:t},u=new Knoema.RegionSelector(r),u.show();$("body").on("regionSelected",function(t,r){var f=$("div#country-profile"),u=typeof r=="undefined"?null:r.id;u?(n.attr("href","#"+u),n.removeClass("not-set"),n.text(u)):(n.addClass("not-set"),n.text(n.data("text")),n.attr("href","#"),u=null),f.toggle(u!=null),i._atlasMetadata.ShowCountryProfile=u!=null,$("input#country-profile-check").prop("checked",i._atlasMetadata.ShowCountryProfile),i._atlasMetadata.RegionId=u,i._atlasChanged=!0,$("body").off("regionSelected")});return!1});n.on("change","input#country-profile-check",function(){i._atlasMetadata.ShowCountryProfile=this.checked,i._atlasChanged=!0});n.delegate("#change-atlas-facts-dataset","click",function(){var t=$("#dialog").append($("
<\/div>")),r;t.bind("datasetChange",$.proxy(function(n,t){Knoema.Utils.apiGet("/api/1.0/meta/dataset/"+t,function(n){if(n.hasGeoDimension)i._atlasMetadata.Dataset=t,i._atlasMetadata.Facts=[],i._factsDatasetChanged=!0,i._factsDataset=n,i._container.trigger("factsChanged"),$("#tabs").tabs("select",1),$("#dialog").dialog("close");else return Knoema.Utils.showWarningMessage($.R("~/Js/Atlas/Knoema.AtlasEditor.js","This dataset has no GeoDimension. Please select another dataset.")),!1})},this)),t.knDialog({position:"center",title:$.R("~/Js/Atlas/Knoema.AtlasEditor.js","Facts dataset selection"),width:800,height:600,modal:!0,closeOnEscape:!0,draggable:!1,autoOpen:!0,resizable:!1,close:function(){t.unbind("datasetChange")}}),r=new Knoema.DatasetBrowser2({filter:"map"}),r.load(t,function(){i.indicatorEditorContext="datasetBrowser"})}),n.delegate("#topic-select","change",function(){var t=$("option:selected","select#topic-select"),r=parseInt(t.attr("data-column")),f=parseInt(t.attr("data-index")),u,e;i._closedSubtopics[t.val()]||(i._closedSubtopics[t.val()]=[]),u=null,isNaN(r)||(u=i.structuredTopics[r][f]),e={topic:u,topicIndex:f,columnIndex:r},setTimeout(function(){var n=$("#topic-indicators");u.CollectionProjectId?n.html($.tmpl("atlas-metadata-project-indicators",e)):n.html($.tmpl("atlas-metadata-topic-indicators",e)),setTimeout(function(){var e,u;i.sortableIndicators(r,f),e=$("table.knoema-table tbody.subtopic",n),$("tr[data-index]",e).each(function(n,r){var u=$(r);i._closedSubtopics[t.val()][u.attr("data-index")]||u.next().show()}),u=0,e.sortable({cursor:"move",cancel:"tr.not-topic",start:function(n,t){u=$(t.item).attr("data-index")},update:function(n,t){var f=$(t.item),o=f.prevAll("tr[data-index]").length,r,e;newIndex=o,r=i._evalEntityByPath(f.attr("data-path")),e=r.SubTopics[u],r.SubTopics.splice(u,1),r.SubTopics.splice(newIndex,0,e),i.renderChanges($("#topic-select").val())}}).disableSelection()},50)},10)}),n.delegate("#create-topic","click",function(){var t={topic:{Name:"",index:null,Column:$("#topic-select").data("column")},columns:i.structuredTopics};i.initTopicForm(t,!0,$.R("~/Js/Atlas/Knoema.AtlasEditor.js","Create new topic"))}),n.delegate("#create-topic-from-collection","click",function(){var n={topic:{Name:"",index:null,Column:$("#topic-select").data("column")},columns:i.structuredTopics};return $.getJSON("/sys/admin/collectionprojects",function(t){i.initProjectForm(n,!0,"Add collection project",t)}),!1}),n.delegate("#create-column","click",function(){if(i.structuredTopics.length===3)return!1;i.structuredTopics.push([]);var t=$("
");i._atlasChanged=!0,t.knDialog({position:"center",title:$.R("~/Js/Atlas/Knoema.AtlasEditor.js","New column added"),width:250,height:150,modal:!0,closeOnEscape:!0,draggable:!1,autoOpen:!0,resizable:!1,buttons:[{text:$.R("~/Js/Atlas/Knoema.AtlasEditor.js","Ok"),click:function(){$("#tabs").tabs("select",1),$("#tabs").tabs("select",2),$("#topic-select").trigger("change"),t.remove()}}],close:function(){t.remove()}})}),n.delegate("#reorder-topics","click",function(){var r,u,t=$("
"),f,e;t.append($.tmpl("atlas-metadata-topics-sorter",{columns:i.structuredTopics})),t.find("select.column-switcher").change(function(n){var f=parseInt($(n.target).val()),e=[];t.find("div.topics-holder").html($.tmpl("atlas-metadata-column-topics",{topics:i.structuredTopics[f]})),t.find("ul.topics").sortable({cursor:"move",start:function(n,t){r=$(t.item).index()},update:function(n,t){u=$(t.item).index();var e=i.structuredTopics[f][r];i.structuredTopics[f].splice(r,1),i.structuredTopics[f].splice(u,0,e)}})}),f=$("#topic-select option:selected").attr("data-column"),t.find("select.column-switcher").val(f),t.find("select.column-switcher").trigger("change"),e=t.knDialog({position:"center",title:$.R("~/Js/Atlas/Knoema.AtlasEditor.js","Topic reordering"),width:500,height:400,modal:!0,closeOnEscape:!0,draggable:!1,autoOpen:!0,resizable:!1,buttons:[{text:$.R("~/Js/Atlas/Knoema.AtlasEditor.js","OK"),click:function(){$("#tabs").tabs("select",1),$("#tabs").tabs("select",2),$("#topic-select").val(f.toString()+u.toString()),$("#topic-select").trigger("change"),t.remove()}},{text:$.R("~/Js/Atlas/Knoema.AtlasEditor.js","Cancel"),click:function(){t.remove()}}],close:function(){t.remove()}})});n.on("click","tbody.subtopic tr[data-index]",function(){var t=$(this),n=t.next();n.hasClass("not-topic")&&(n.toggle(),i._closedSubtopics[$("option:selected","select#topic-select").val()][t.attr("data-index")]=!n.is(":visible"))});n.delegate("#edit-topic","click",function(){var u=$("#topic-select option:selected"),t=u.attr("data-index"),r=u.attr("data-column"),e=i.structuredTopics[r][t].Name,f={topic:{Name:e,index:t,Column:r,Description:i.structuredTopics[r][t].Description},columns:i.structuredTopics};i.structuredTopics[r][t].CollectionProjectId?i.initProjectForm(f,!1,"Edit topic"):i.initTopicForm(f,!1,$.R("~/Js/Atlas/Knoema.AtlasEditor.js","Edit topic"))}),n.delegate("tbody.subtopic a.edit","click",function(){var u=$(this),f={},t,r=u.attr("data-index"),e=u.attr("data-path");return t=i._evalEntityByPath(e),f={topic:{Name:t.SubTopics[r].Name,index:r,Column:t.SubTopics[r].Column-1},columns:[1,2]},i.initTopicForm(f,!1,$.R("~/Js/Atlas/Knoema.AtlasEditor.js","Edit topic"),t),!1}),n.delegate("#delete-topic, tbody.subtopic a.delete","click",function(){var t=$(this),n=$("
");n.html("

"+$.R("~/Js/Atlas/Knoema.AtlasEditor.js","Are you sure you want to delete topic?")+"<\/p>");var r=$("#topic-select option:selected"),e=r.attr("data-index"),u=r.attr("data-column"),f=t.hasClass("delete");return n.knDialog({position:"center",title:$.R("~/Js/Atlas/Knoema.AtlasEditor.js","Warning"),width:400,height:200,modal:!0,closeOnEscape:!0,draggable:!1,autoOpen:!0,resizable:!1,buttons:[{text:$.R("~/Js/Atlas/Knoema.AtlasEditor.js","Delete"),click:function(){var r=$("#topic-select option:selected").attr("data-index"),o;f&&(r=t.attr("data-index"),o=t.attr("data-path")),i.removeTopic(r,u,o),i.renderChanges(u+(f?e.toString():"0")),n.remove()}},{text:$.R("~/Js/Atlas/Knoema.AtlasEditor.js","Cancel"),click:function(){n.remove()}}],close:function(){n.remove()}}),!1});n.on("click","a#add-subtopic",function(){var n={topic:{Name:$.R("~/Js/Atlas/Knoema.AtlasEditor.js","New subtopic"),index:0,Column:0},columns:[1,2]},t=$("#topic-select option:selected").attr("data-index"),r=$("#topic-select option:selected").attr("data-column");return i.initTopicForm(n,!0,$.R("~/Js/Atlas/Knoema.AtlasEditor.js","Add subtopic"),i.structuredTopics[r][t]),!1});n.delegate(".delete-indicator","click",function(){var r=i.getSelectedTopic(),t=$(this),u=t.attr("data-index")*1,f=i._evalEntityByPath(t.attr("data-path"));return f.Indicators.splice(u,1),i.renderChanges(r.rootIndex),!1}),n.delegate(".edit-indicator","click",function(){var t=$(this),r=t.attr("data-index")*1,u=i._evalEntityByPath(t.attr("data-path")),e=u.Indicators[r],f=$("#topic-select option:selected"),o=f.attr("data-index"),s=f.attr("data-column"),h=i.structuredTopics[s][o];return i.initIndicatorEditor(e,u,r,!1,t.attr("data-path").indexOf("SubTopics")>-1,h.CollectionProjectId),!1}),n.delegate("#add-indicator, tbody.subtopic a.add-indicator","click",function(){var t=$(this),r,o=null,f=parseInt($("#topic-select option:selected").attr("data-column")),e=parseInt($("#topic-select option:selected").attr("data-index")),u;return r=t.hasClass("add-indicator")?i._evalEntityByPath(t.attr("data-path")+".SubTopics["+t.attr("data-index")+"]"):i.structuredTopics[f][e],u={Name:"",ShortName:"",Unit:"",Precision:"",Year:"",Description:"",DatasetId:null,RegionDimensionId:null,SmallerIsBetter:!1,Keywords:"",Filter:[{Parameter:"",Value:""}]},i.initIndicatorEditor(u,r,null,!0,t.hasClass("add-indicator")),!1});n.on("click","div#lang",function(){i.clicked=!0});n.delegate(".save-metadata","click",function(){var t=$(this),n,r;return(t.spinbutton("start","Saving"),!i._factsDataset)?(Knoema.Utils.showWarningMessage($.R("~/Js/Atlas/Knoema.AtlasEditor.js","Please select facts dataset.")),!1):i._factsDataset==null?(Knoema.Utils.showWarningMessage($.R("~/Js/Atlas/Knoema.AtlasEditor.js","Dataset for facts not defined! Please select dataset on Facts tab.")),!1):(i._atlasMetadata.RegionDimensionId=i._factsDataset.regionDimensionId,i.fillUpFacts(),i.fillUpTopics(),$("div#lang").length&&i.clicked&&(i._atlasMetadata.Locales=$("div#lang input:checkbox:checked").map(function(){return $(this).val()}).get()),n=function(){var n=JSON.stringify(i._atlasMetadata);$.post(i._saveMetadataUrl,{Country:i._atlasOptions.Country,CountryId:i._atlasOptions.CountryId,atlasMetadataStr:n},function(n){var r=null,u=null;$("#tabs").find(".infomessage").remove(),n.errors.length>0?(r=$.R("~/Js/Atlas/Knoema.AtlasEditor.js","Error"),u=$.R("~/Js/Atlas/Knoema.AtlasEditor.js","Errors while saving atlas metadata")):(r=$.R("~/Js/Atlas/Knoema.AtlasEditor.js","Success"),u=$.R("~/Js/Atlas/Knoema.AtlasEditor.js","Atlas metadata successfully saved!"),i._atlasChanged=!1),$("#dialog").html(u),$("#dialog").knDialog({position:"center",title:r,width:400,height:200,modal:!0,closeOnEscape:!0,draggable:!1,autoOpen:!0,resizable:!1,buttons:[{text:$.R("~/Js/Atlas/Knoema.AtlasEditor.js","OK"),click:function(){$(this).dialog("close")}}]}),t.spinbutton("stop")},"json")},typeof i._atlasMetadata.Subregions=="undefined"&&typeof i._atlasOptions.CountryTitle!="undefined"?(i._atlasMetadata.Subregions=[],r=$.getJSON("/page/map",function(n){for(var u=i._atlasOptions.CountryTitle,e=1,r,f,t=0;t0?($("button#apply-delete").removeAttr("disabled"),$("button#apply-move").removeAttr("disabled"),$("select#select-subtopic").removeAttr("disabled")):($("button#apply-delete").attr("disabled","disabled"),$("button#apply-move").attr("disabled","disabled"),$("select#select-subtopic").attr("disabled","disabled"))});n.on("click","button#apply-delete",function(){var n,r,u;if(!this.disabled){var t=$("input:checked","div#topic-indicators tbody.subtopic"),e=[],f=t.length;for(n=f-1;n>=0;n--)r=$(t.get(n)).closest("tr").attr("data-index"),u=i._evalEntityByPath(t.get(n).value),u.Indicators.splice(r,1);i.renderChanges($("#topic-select").val())}});n.on("click","button#apply-move",function(){var t,o,n;if(!this.disabled){t=i._evalEntityByPath($("select#select-subtopic").val()),t.Indicators||(t.Indicators=[]);var r=[],u=$("input:checked","div#topic-indicators tbody.subtopic"),s=[],c=u.length;for(n=c-1;n>=0;n--){var h=$(u.get(n)).closest("tr").attr("data-index"),f=i._evalEntityByPath(u.get(n).value),e=f.Indicators[h];i._indicatorExists(e.ShortName,"",t)?r.push({indicator:e.ShortName,topic:f.Name}):(s.push(e),f.Indicators.splice(h,1))}if(t.Indicators=t.Indicators.concat(s.reverse()),i.renderChanges($("#topic-select").val()),r.length>0){for(o="