(function(a){if(location.href.includes("edit_article.jsp")){var f="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(";"),h="Cluster section;Related resources;Resource image;Download forms;Digital forms;Competency".split(";"),
n="Content;Contact;Section;Subsection;Appendix;Competency;Cluster section;Group;Question;Answer".split(";");a.fn.DynamicScrollspyCustomised=function(k){function l(c){return a("\x3cdiv\x3e\x3c/div\x3e").text(c).html()}function p(){for(var c=[],b=d.options.tH;b<=d.options.bH;b++)c.push("[data-nav-level\x3d"+b+"]");return a(c.join(","))}function r(){p().filter(function(){return""===a(this).prop("id")}).prop("id",function(){var c=a(this).prop("tagName"),b;for(b=Math.floor(900*Math.random())+100;0<=d.rands.indexOf(b);)b=
Math.floor(900*Math.random())+100;d.rands.push(b);return c+b})}function t(){var c=0;p().each(function(){if(""===a(this).prop("id"))c++;else if(1<a('[id\x3d"'+a(this).prop("id")+'"]').length)throw Error("DynamicScrollspy: Error! Duplicate id "+a(this).prop("id"));});if(0<c)throw Error("DynamicScrollspy: Not all headers have ids and genIDs: false.");return c}function A(){p().append(function(){return" ("+a(this).prop("tagName")+", "+a(this).prop("id")+")"})}function u(){var c=d.tree;a("[data-nav-level\x3d"+
d.options.tH+"]").each(function(){c[a(this).prop("id")]={dstext:l(a(this).attr("data-nav-label")),parentId:"navroot",jqel:a(this)}});d.options.tH+1<=d.options.bH&&v(c);return c}function v(c){for(var b in c)if("dstext"!=b&&"jqel"!=b&&"parentId"!=b){var e="",g="";e=Number(a("#"+b).attr("data-nav-level"));g=a("#"+b).attr("data-nav-label");if(e>=d.options.bH||h.includes(g))return!1;a("#"+b).find("[data-nav-level\x3d"+(e+1)+"]").each(function(){c[b][a(this).prop("id")]={dstext:l(a(this).attr("data-nav-label")),
parentId:b,jqel:a(this)}});e<d.options.bH&&v(c[b])}}function w(){var c=a('\x3cnav id\x3d"navroot" class\x3d"navbar navbar-light bg-light"\x3e\x3c/nav\x3e');d.append(c);var b=a('\x3cnav class\x3d"nav nav-pills flex-column"\x3e\x3c/nav\x3e');c.append(b);a.each(d.tree,function(e){var g=a('\x3ca class\x3d"nav-link" href\x3d"#'+e+'"\x3e'+d.tree[e].dstext+"\x3c/a\x3e");b.append(g);x(d.tree[e],b)});return d}function x(c,b){if(3>Object.keys(c).length)return!1;var e=c.jqel.prop("id"),g=void 0,m;for(m in c)if("dstext"!=
m&&"jqel"!=m&&"parentId"!=m){var q=c[m];g||(g=a('\x3cnav id\x3d"nav'+e+'" class\x3d"nav nav-pills flex-column"\x3e\x3c/nav\x3e'),b.append(g));q=a('\x3ca class\x3d"nav-link ml-3" href\x3d"#'+m+'"\x3e'+q.dstext+"\x3c/a\x3e");g.append(q);x(c[m],g)}}function y(){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 c=1+a(this).parents("[data-nav-level]").length,
b="?",e=a(this).contents().filter(function(){return 3===this.nodeType}).first();e&&e.text().trim().length&&(b=e.text().trim());n.includes(b)&&(b=(e=a(this).parent().find("input").first().val())&&e.trim().length?b+": "+e:b+": (empty)");a(this).parent().attr("data-nav-level",c);a(this).parent().attr("data-nav-label",b)});a("[data-nav-label]").filter(function(){return f.includes(a(this).attr("data-nav-label"))}).each(function(){a(this).removeAttr("data-nav-level");a(this).removeAttr("data-nav-label")})}
function z(){!1===d.isinit?(0<a("#webcms-content-navigation").length&&(y(),d.options.genIDs?r():t(),d.options.testing&&A(),u(),w()),0<a("#webcms-content-navigation").length&&(a("body").attr("data-spy","scroll").attr("data-target","#scrollspy").css("overflow-y","scroll").scrollspy({target:"#"+d.prop("id"),offset:d.options.offset}),a("body").removeClass("dialog-iframe-popup")),setTimeout(function(){var c=document.getElementById("content");(new MutationObserver(function(b,e){for(i=0;i<b.length;i++)e=
b[i],"childList"===e.type&&(e.target.classList.contains("cke_path")||e.target.classList.contains("lfr-ddm-field-group"))&&(a("#navroot").remove().promise().done(function(){z()}),updateAllContentSelectors())})).observe(c,{attributes:!1,childList:!0,subtree:!0})},1E3),d.isinit=!0):(y(),d.options.genIDs?r():t(),u(),w(),a('[data-spy\x3d"scroll"]').each(function(){a(this).scrollspy("refresh")}));return d}k="undefined"==typeof k?{}:k;this.isinit="undefined"==typeof this.isinit?!1:d.isinit;if("destroy"==
k)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,k);var d=this;this.tree={};this.rands=[];return z()}}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 f=this;return function(){this.superFunction=f;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(f){var h=f.getRuleInputName();h.includes("contactSelector")?updateContentSelector(f,contactsItemSelectorURL,"Contacts"):h.includes("_com_liferay_journal_web_portlet_JournalPortlet_contact_INSTANCE")?updateContentSelector(f,contactsItemSelectorURL,"Contacts"):h.startsWith("_com_liferay_journal_web_portlet_JournalPortlet_formLink_INSTANCE")&&updateContentSelector(f,formLinksItemSelectorURL,"Form links");updateContentSelectors(f.get("fields"))})}
function updateContentSelector(a,f,h){a._handleSelectButtonClick=a._handleSelectButtonClick.override(function(){var n=this;""==f&&(f=n._getWebContentSelectorURL());var k=n.get("portletNamespace");Liferay.Util.openSelectionModal({onSelect:function(l){l&&(n.setValue({className:l.assetclassname,classPK:l.assetclasspk,title:l.assettitle||""}),n._hideMessage())},selectEventName:k+"selectWebContent",title:h,url:f})})};
