(function(a){if(location.href.includes("edit_article.jsp")){var e="Title;Alternative title;Text and media;Rights;Publisher ID;Section title;Section text;Subsection title;Subsection text;Appendix title;Appendix text;Caption;Caption text;Address;Description;Group assets;Group name;Group lead;Small Image;Approver;Level title;Level text;Level detail title;Level detail text;Report settings;Question number;Question text".split(";"),f="Cluster section;Related resources;Resource image;Download forms;Digital forms;Competency".split(";"),
w="Content;Contact;Section;Subsection;Appendix;Competency;Cluster section;Group;Question;Answer".split(";");a.fn.DynamicScrollspyCustomised=function(g){function l(b){return a("\x3cdiv\x3e\x3c/div\x3e").text(b).html()}function k(){for(var b=[],d=c.options.tH;d<=c.options.bH;d++)b.push("[data-nav-level\x3d"+d+"]");return a(b.join(","))}function m(){k().filter(function(){return""===a(this).prop("id")}).prop("id",function(){var b=a(this).prop("tagName"),d;for(d=Math.floor(900*Math.random())+100;0<=c.rands.indexOf(d);)d=
Math.floor(900*Math.random())+100;c.rands.push(d);return b+d})}function n(){var b=0;k().each(function(){if(""===a(this).prop("id"))b++;else if(1<a('[id\x3d"'+a(this).prop("id")+'"]').length)throw Error("DynamicScrollspy: Error! Duplicate id "+a(this).prop("id"));});if(0<b)throw Error("DynamicScrollspy: Not all headers have ids and genIDs: false.");return b}function x(){k().append(function(){return" ("+a(this).prop("tagName")+", "+a(this).prop("id")+")"})}function p(){var b=c.tree;a("[data-nav-level\x3d"+
c.options.tH+"]").each(function(){b[a(this).prop("id")]={dstext:l(a(this).attr("data-nav-label")),parentId:"navroot",jqel:a(this)}});c.options.tH+1<=c.options.bH&&q(b);return b}function q(b){for(var d in b)if("dstext"!=d&&"jqel"!=d&&"parentId"!=d){var h="",e="",h=Number(a("#"+d).attr("data-nav-level")),e=a("#"+d).attr("data-nav-label");if(h>=c.options.bH||f.includes(e))return!1;a("#"+d).find("[data-nav-level\x3d"+(h+1)+"]").each(function(){b[d][a(this).prop("id")]={dstext:l(a(this).attr("data-nav-label")),
parentId:d,jqel:a(this)}});h<c.options.bH&&q(b[d])}}function r(){var b=a('\x3cnav id\x3d"navroot" class\x3d"navbar navbar-light bg-light"\x3e\x3c/nav\x3e');c.append(b);var d=a('\x3cnav class\x3d"nav nav-pills flex-column"\x3e\x3c/nav\x3e');b.append(d);a.each(c.tree,function(b){var h=a('\x3ca class\x3d"nav-link" href\x3d"#'+b+'"\x3e'+c.tree[b].dstext+"\x3c/a\x3e");d.append(h);t(c.tree[b],d)});return c}function t(b,d){if(3>Object.keys(b).length)return!1;var c=b.jqel.prop("id"),e=void 0,f;for(f in b)if("dstext"!=
f&&"jqel"!=f&&"parentId"!=f){var g=b[f];e||(e=a('\x3cnav id\x3d"nav'+c+'" class\x3d"nav nav-pills flex-column"\x3e\x3c/nav\x3e'),d.append(e));g=a('\x3ca class\x3d"nav-link ml-3" href\x3d"#'+f+'"\x3e'+g.dstext+"\x3c/a\x3e");e.append(g);t(b[f],e)}}function u(){a(".article-content-content [data-nav-level]").each(function(){a(this).removeAttr("data-nav-level");a(this).removeAttr("data-nav-label")});a(".article-content-content .control-label").each(function(){var b=1+a(this).parents("[data-nav-level]").length,
d="?",c=a(this).contents().filter(function(){return 3===this.nodeType}).first();c&&c.text().trim().length&&(d=c.text().trim());w.includes(d)&&(d=(c=a(this).parent().find("input").first().val())&&c.trim().length?d+": "+c:d+": (empty)");a(this).parent().attr("data-nav-level",b);a(this).parent().attr("data-nav-label",d)});a("[data-nav-label]").filter(function(){return e.includes(a(this).attr("data-nav-label"))}).each(function(){a(this).removeAttr("data-nav-level");a(this).removeAttr("data-nav-label")})}
function v(){!1===c.isinit?(0<a("#webcms-content-navigation").length&&(u(),c.options.genIDs?m():n(),c.options.testing&&x(),p(),r()),0<a("#webcms-content-navigation").length&&(a("body").attr("data-spy","scroll").attr("data-target","#scrollspy").css("overflow-y","scroll").scrollspy({target:"#"+c.prop("id"),offset:c.options.offset}),a("body").removeClass("dialog-iframe-popup")),setTimeout(function(){var b=document.getElementById("content");(new MutationObserver(function(b,c){for(i=0;i<b.length;i++)c=
b[i],"childList"===c.type&&(c.target.classList.contains("cke_path")||c.target.classList.contains("lfr-ddm-field-group"))&&(a("#navroot").remove().promise().done(function(){v()}),updateAllContentSelectors())})).observe(b,{attributes:!1,childList:!0,subtree:!0})},1E3),c.isinit=!0):(u(),c.options.genIDs?m():n(),p(),r(),a('[data-spy\x3d"scroll"]').each(function(){a(this).scrollspy("refresh")}));return c}g="undefined"==typeof g?{}:g;this.isinit="undefined"==typeof this.isinit?!1:c.isinit;if("destroy"==
g)return this.isinit=!1,this.empty(),this.off("activate.bs.scrollspy"),a(body).removeAttr("data-spy"),this;this.options=a.extend({},{tH:1,bH:6,genIDs:!1,offset:100,ulClassNames:"hidden-print",activeClass:"",testing:!1},this.options,g);var c=this;this.tree={};this.rands=[];return v()}}a(".select-button").click(function(){alert("The paragraph was clicked.")})})(jQuery);$(function(){location.href.includes("edit_article.jsp")&&$("#scrollspy").DynamicScrollspyCustomised({genIDs:!0,testing:!1,offset:200})});
location.href.includes("edit_article.jsp")&&location.hostname.includes("ikon")&&window.addEventListener("load",function(){updateAllContentSelectors()});Function.prototype.override=function(a){var e=this;return function(){this.superFunction=e;return a.apply(this,arguments)}};function updateAllContentSelectors(){var a=Liferay.component("_com_liferay_journal_web_portlet_JournalPortlet_ddmForm").get("fields");updateContentSelectors(a)}
function updateContentSelectors(a){a&&a.forEach(function(a){var e=a.getRuleInputName();e.includes("contactSelector")?updateContentSelector(a,contactsItemSelectorURL,"Contacts"):e.includes("_com_liferay_journal_web_portlet_JournalPortlet_contact_INSTANCE")?updateContentSelector(a,contactsItemSelectorURL,"Contacts"):e.startsWith("_com_liferay_journal_web_portlet_JournalPortlet_formLink_INSTANCE")&&updateContentSelector(a,formLinksItemSelectorURL,"Form links");updateContentSelectors(a.get("fields"))})}
function updateContentSelector(a,e,f){a._handleSelectButtonClick=a._handleSelectButtonClick.override(function(){var a=this;""==e&&(e=a._getWebContentSelectorURL());var g=a.get("portletNamespace");Liferay.Util.openSelectionModal({onSelect:function(e){e&&(a.setValue({className:e.assetclassname,classPK:e.assetclasspk,title:e.assettitle||""}),a._hideMessage())},selectEventName:g+"selectWebContent",title:f,url:e})})};
