PageSourceSearch

https://www.nordpoolgroup.com/Scripts/CustomEpiserverForms.js

js nordpoolgroup.com collected 2026-10-02 02:39:28 UTC 9,760 bytes, 248 lines download raw bytes

1$(document).ready(function () {
2
3    if (typeof $$epiforms !== 'undefined') {
4        $(".active-group").removeClass("hide");
5        $(".remove-group-button").css("display", "none");
6    }
7
8    $('body').click(function (element) {
9        var elementTarget = $(element.target);
10        if (!elementTarget.hasClass('group-multi-select-show-button') && elementTarget.parents('.group-multi-select-show-button').length < 1 && elementTarget.parents('.group-multi-select').length < 1) {
11            $('.group-multi-select:visible').each(function () {
12                $(this).hide();
13            });
14
15            $('.group-multi-select-triangle.group-rotate-triangle').each(function () {
16                $(this).removeClass("group-rotate-triangle");
17            });
18        }
19    });
20
21    $(".group .group-content .FormSelection select.group-select").change(function () {
22        validateDropdownSelections();
23    });
24
25    //set LinkColumnBlock max-width if max 3 items and not too long texts
26    $(".link-column-block-selection-container").each(function (index) {
27        var linkItems = $(this).find(".link-container > .link-item");
28        if (linkItems.length < 4) {
29            var linkItemsWidth = 0;
30            var containerWidth = $(this).width();
31
32            $(linkItems).each(function (index) {
33                linkItemsWidth += $(this).textWidth();
34            })
35
36            var widthPercentage = (100 * (linkItemsWidth / containerWidth));
37
38            if (widthPercentage <= 10) {
39                $(this).find(".link-container").addClass("link-column-block-20");
40            }
41            else if (widthPercentage <= 20) {
42                $(this).find(".link-container").addClass("link-column-block-30");
43            }
44            else if (widthPercentage <= 30) {
45                $(this).find(".link-container").addClass("link-column-block-40");
46            }
47            else if (widthPercentage <= 40) {
48                $(this).find(".link-container").addClass("link-column-block-50");
49            }
50            else if (widthPercentage <= 50) {
51                $(this).find(".link-container").addClass("link-column-block-60");
52            }
53            else if (widthPercentage <= 70) {
54                $(this).find(".link-container").addClass("link-column-block-70");
55            }
56        }
57    });
58});
59
60//jQuery extension (plug-in) to get text element true width
61$.fn.textWidth = function () {
62    var htmlOrg = $(this).html();
63    var htmlCalc = '<span>' + htmlOrg + '</span>';
64    $(this).html(htmlCalc);
65    var width = $(this).find('span:first').width();
66    $(this).html(htmlOrg);
67    return width;
68};
69
70function show(element) {
71    $("#" + element).toggle();
72    $("#" + element + "-triangle").hasClass("group-rotate-triangle") ? $("#" + element + "-triangle").removeClass("group-rotate-triangle") : $("#" + element + "-triangle").addClass("group-rotate-triangle");
73}
74
75function selectOption(event, element, activeOption) {
76    event.preventDefault();
77    event.stopPropagation();
78    var oldValues = [];
79    if ($("#" + element).val()) {
80        oldValues = $("#" + element).val();
81    }
82    var index = oldValues.indexOf(activeOption);
83    var newValues = [];
84    if (index < 0) {
85        newValues = oldValues.concat(activeOption);
86        $("#" + element + "-group-multi-select-selected-values").append("<div id=\"" + element + activeOption.replace(/\s/g, "").replace(/[&\/\\#,+()$~%.'":*?<>{}]/g, '_') + "-selected\" class=\"group-multi-select-selected-value\" ><span>" + activeOption + "</span><button onclick=\"selectOption(event, '" + element + "', '" + activeOption + "')\" class=\"group-multi-select-remove-button\" ><span class=\"group-multi-select-remove-button-image\" ></span></button></div>");
87    } else {
88        newValues = oldValues.filter(value => value !== activeOption);
89        $("#" + element + activeOption.replace(/\s/g, "").replace(/[&\/\\#,+()$~%.'":*?<>{}]/g, '_') + "-selected").remove();
90    }
91
92    $("#" + element).val(newValues);
93
94    validateDropdownSelections();
95}
96
97function addGroup(form, group) {
98    $("#" + group).removeClass("active-group");
99    $("#" + group + "+.group").addClass("active-group");
100    $(".active-group .group-footer").addClass("hide");
101    $("#" + group + "+.group").removeClass("hide");
102
103    $(".active-group .group-content .FormSelection select.group-select").each((index, item) => {
104        item.style.backgroundImage = 'url(/Static/caret_down.png)';
105    });
106
107    $("#" + group + " .group-footer").addClass("hide");
108    $("#" + group + "-remove-group-button").css("display", "inline-flex");
109
110    $("#" + group + " .group-content input").each((index, item) => {
111        item.disabled = true;
112    });
113
114    $("#" + group + " .group-content select").each((index, item) => {
115        item.disabled = true;
116    });
117
118    $("#" + group + " .group-content .FormSelection select.group-select").each((index, item) => {
119        item.style.backgroundImage = 'url(/Static/caret_down_disabled.png)';
120    });
121
122    $("#" + group + " .group-content button").each((index, item) => {
123        item.disabled = true;
124    });
125
126    // Disable dropdown values that the user has already selected
127    var previouslySelectedValues = [];
128
129    $('.group:not(:has(.active-group)) .group-content .FormSelection select.group-select').each(function () {
130        var selectedValue = $(this).val();
131        if (selectedValue !== null && selectedValue !== undefined) {
132            previouslySelectedValues.push(selectedValue);
133        }
134    });
135
136    if (previouslySelectedValues.length > 0) {
137        $('.active-group .group-content .FormSelection select.group-select option').each(function () {
138            var selectableValue = $(this).val();
139            if ($.inArray(selectableValue, previouslySelectedValues) > -1) {
140                $(this).prop("disabled", true);
141            }
142        });
143    }
144}
145
146function removeGroup(form, group, headerText) {
147    // Enable other groups' dropdown values that the user had selected for the removed group
148    var previouslySelectedValues = [];
149
150    $('#' + group + ' .group-content .FormSelection select.group-select').each(function () {
151        var selectedValue = $(this).val();
152        if (selectedValue !== null && selectedValue !== undefined) {
153            previouslySelectedValues.push(selectedValue);
154        }
155    });
156
157    if (previouslySelectedValues.length > 0) {
158        $('div:not(#' + group + ') .group-content .FormSelection select.group-select option').each(function () {
159            var selectableValue = $(this).val();
160            if ($.inArray(selectableValue, previouslySelectedValues) > -1) {
161                $(this).prop("disabled", false);
162            }
163        });
164    }
165
166    $("#" + group + "-add-group-button").removeClass("hide");
167    $("#" + group + "-remove-group-button").css("display", "none");
168
169    // Empty values
170    if ($("#" + group + " input:text") > 0) {
171        $("#" + group + " input.text").val('');
172    }
173
174    if ($("#" + group + " select.group-multi-select").length > 0) {
175        $("#" + group + "  .group-content .group-multi-select-selected-values .group-multi-select-selected-value").each((index, item) => {
176            item.remove();
177        });
178    }
179
180    if ($("#" + group + " select").length > 0) {
181        $("#" + group + " select").val('');
182    }
183
184    if ($("#" + group + " input:radio").length > 0) {
185        $("#" + group + " input:radio").removeAttr("checked");
186    }
187
188    if ($("#" + group + " input:checkbox").length > 0) {
189        $("#" + group + " input:checkbox").removeAttr("checked");
190    }
191
192    var element = $("#" + group);
193    element.remove();
194
195    if ($(".active-group").length === 0) {
196        $("#" + form + "-group-element").append(element);
197        $("#" + group).addClass("active-group");
198        $(".active-group .group-footer").removeClass("hide");
199    } else {
200        $(element).insertAfter($("#" + form + " .active-group"));
201        element.addClass("hide");
202    }
203
204    if ($(".group.hide").length > 0) {
205        $(".active-group .group-footer").removeClass("hide");
206    } else {
207        $(".active-group .group-footer").addClass("hide");
208    }
209
210    var i = 1;
211    $(".group-header-text").each((index, item) => {
212        item.innerText = headerText + " " + i;
213        i++;
214    });
215    $("#" + group + " .group-content input").each((index, item) => {
216        item.disabled = false;
217    });
218    $("#" + group + "  .group-content select").each((index, item) => {
219        item.disabled = false;
220    });
221    $("#" + group + "  .group-content button").each((index, item) => {
222        item.disabled = false;
223    });
224}
225
226function validateDropdownSelections() {
227    var dropdownValueSelected = true;
228    $(".active-group .group-content .FormSelection.ValidationRequired select.group-select").each(function () {
229        var selectedValue = $(this).val();
230        if (selectedValue === null || selectedValue === undefined) {
231            dropdownValueSelected = false;
232        }
233    });
234
235    var dropdownMultiValueSelected = true;
236    $(".active-group .group-content .FormSelection.ValidationRequired select.group-multi-select").each(function () {
237        var selectedValue = $(this).val();
238        if (selectedValue === null || selectedValue === undefined) {
239            dropdownMultiValueSelected = false;
240        }
241    });
242
243    if (dropdownValueSelected && dropdownMultiValueSelected && $(".group.hide").length > 0) {
244        $(".active-group .group-footer").removeClass("hide");
245    } else {
246        $(".active-group .group-footer").addClass("hide");
247    }
248}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.