var NEOS = NEOS || {};
NEOS.ProjectOffsetForm = (function () {
function _formatSummaryTab(){
// Move the public name into the quick view iframe
$('div.tab[data-name="summaryTab"] #QuickViewProjectDetails').on("load", function(){
var rowHtml = $("#mara_publicdisplayname").parents("tr").first();
var contentDocument = $($(this)[0].contentWindow.document);
$(rowHtml).insertBefore($(contentDocument.find("#ticketnumber").parents("tr").first()));
var iframeHeight = $(this).css("height");
iframeHeight = parseFloat(iframeHeight) + 200;
$(this).css("height",iframeHeight+"px");
});
}
function _formatConditionsSubgrid(){
// Removes html from rich text condition description
$('div.tab[data-name="conditionsTab"] div.entity-grid.subgrid').on("loaded", function(){
$('div.tab[data-name="conditionsTab"] td[data-attribute="mara_fullconditiontext"]').each(function(){
let html = $(this).html();
$(this).html($('
').html(html).text());
});
});
}
function _formatSiteSubgrid(){
// Remove the hyperlink in the first column (Assumption: First column = mara_name)
$('div.tab[data-name="sitesTab"] div.entity-grid.subgrid').on("loaded", function(){
$('div.tab[data-name="sitesTab"] td[data-attribute="mara_name"]').each(function(){
$(this).children('a').contents().unwrap();
});
});
}
function _formatDecisionNoticesSubgrid(){
// Update the anchor tags to open the decision notice in a new tab
$('div.tab[data-name="noticesTab"] div.entity-grid.subgrid').on("loaded", function(){
$('div.tab[data-name="noticesTab"] div.entity-grid.subgrid tbody tr').each(function(){
$(this).find('td[data-attribute="mara_noticewebdisplayname"] a').attr('target','_blank');
$(this).find('td[aria-label="action menu"] a.details-link').attr('target','_blank');
});
});
}
return {
initialise: function () {
_formatSummaryTab();
_formatSiteSubgrid();
_formatConditionsSubgrid();
_formatDecisionNoticesSubgrid();
}
}
})();