PageSourceSearch

https://co2geonet.com/content/scripts/scripts.js?v=639265198001711096

js co2geonet.com collected 2026-10-02 04:37:27 UTC 61,862 bytes, 1,741 lines download raw bytes

1const glossaryContainers = document.querySelectorAll("[glossary-container]");
2const noGlossaryIdentifier = "nogl_"
3if (glossaryContainers?.length) {
4    //Chiamata ed esecuzione dello script solo in presenza di elementi
5    //che contengono l'attributo "glossary-container"
6    fetch("/umbraco/api/glossary/GetAllGlossaryItems")
7        .then(response => response.json())
8        .then(data => parseGlossaryItems(data));
9}
10
11function parseGlossaryItems(glossaryItems) {
12    if (!glossaryItems?.length) {
13        return;
14    }
15
16    glossaryContainers.forEach(gc => {
17        let newText = gc.innerHTML;
18        glossaryItems.forEach(i => {
19
20            // Match whole words optionally prefixed by noGlossaryIdentifier and optionally suffixed by 's' (for plurals), globally and case-insensitively.
21            // captures the prefix to see if it has an identifier
22            // captures the word + eventual 's' to use in element creation
23            const regex = new RegExp(`\\b(${noGlossaryIdentifier}){0,1}(${i.name}s{0,1})\\b`, "gi");
24
25            const matches = [...gc.innerHTML.matchAll(regex)];
26            let occurrences = [];
27            matches.map(match => {
28                occurrences.push({
29                    value: i,
30                    full_match: match[0], //full match
31                    ignore: match[1], //prefix. if identifier isn't present => unidentified
32                    text: match[2] //matches the word to replace, plural or singular, respecting case
33                })
34            })
35            occurrences = removeDuplicates(occurrences, isSameOccurrence)
36                .sort((a, b) => a.ignore ? b.ignore ? 0 : 1 : -1);
37            //ignored words must be last to be matched otherwise the replace of the not ignored targets them after they have already been replaced
38
39            if (occurrences?.length) {
40                occurrences.forEach(oc => {
41                    const replacement = createReplacement(oc.value, oc.text, oc.ignore);
42                    //regex to avoid matching the term when it's used in the attributes
43                    const replacementRegex = new RegExp(`\\b${oc.full_match}\\b(?![^<]*<\/a>)`, "g");
44                    newText = newText.replaceAll(replacementRegex, oc.ignore ? replacement : replacement.outerHTML);
45                })
46            }
47        })
48
49        gc.innerHTML = newText;
50    });
51
52    $("[tooltip-value]").tooltip({
53        placement: "bottom"
54    })
55
56}
57
58function createReplacement(glossaryItem, text, ignore) {
59    if (ignore) {
60        return text;
61    }
62    const tag = document.createElement("a");
63    tag.setAttribute("href", glossaryItem.hash);
64    tag.setAttribute("target", "_blank");
65    tag.setAttribute("title", glossaryItem.value)
66    tag.setAttribute("tooltip-value", glossaryItem.value)
67    tag.setAttribute("tooltip-name", glossaryItem.name)
68    tag.setAttribute("data-toggle", "tooltip")
69    tag.classList.add("glossary-item")
70    tag.innerHTML = text;
71    return tag;
72}
73
74//deduplication support function
75function isSameOccurrence(a, b) {
76    return a.full_match === b.full_match
77        && a.ignore === b.ignore
78        && a.text === b.text;
79}
80
81function removeDuplicates(arr, comparer) {
82    return arr.filter((item, index, self) =>
83        index === self.findIndex((t) => (
84            comparer(t, item)
85        ))
86    )
87}
88/*!
89 * @file ScrollMagic GSAP Animation Plugin.
90 *
91 * requires: GSAP ~1.14
92 * Powered by the Greensock Animation Platform (GSAP): http://www.greensock.com/js
93 * Greensock License info at http://www.greensock.com/licensing/
94 */
95/**
96 * This plugin is meant to be used in conjunction with the Greensock Animation Plattform.  
97 * It offers an easy API to trigger Tweens or synchronize them to the scrollbar movement.
98 *
99 * Both the `lite` and the `max` versions of the GSAP library are supported.  
100 * The most basic requirement is `TweenLite`.
101 * 
102 * To have access to this extension, please include `plugins/animation.gsap.js`.
103 * @requires {@link http://greensock.com/gsap|GSAP ~1.14.x}
104 * @mixin animation.GSAP
105 */
106(function (root, factory) {
107	if (typeof define === 'function' && define.amd) {
108		// AMD. Register as an anonymous module.
109		define(['ScrollMagic', 'TweenMax', 'TimelineMax'], factory);
110	} else if (typeof exports === 'object') {
111		// CommonJS
112		// Loads whole gsap package onto global scope.
113		require('gsap');
114		factory(require('scrollmagic'), TweenMax, TimelineMax);
115	} else {
116		// Browser globals
117		factory(root.ScrollMagic || (root.jQuery && root.jQuery.ScrollMagic), root.TweenMax || root.TweenLite, root.TimelineMax || root.TimelineLite);
118	}
119}(this, function(ScrollMagic, Tween, Timeline) {
120	"use strict";
121	var NAMESPACE = "animation.gsap";
122
123	// (BUILD) - REMOVE IN MINIFY - START
124	var
125        console = window.console || {},
126        err = Function.prototype.bind.call(console.error || console.log || function() {}, console);
127	if (!ScrollMagic) {
128		err("(" + NAMESPACE + ") -> ERROR: The ScrollMagic main module could not be found. Please make sure it's loaded before this plugin or use an asynchronous loader like requirejs.");
129	}
130	if (!Tween) {
131		err("(" + NAMESPACE + ") -> ERROR: TweenLite or TweenMax could not be found. Please make sure GSAP is loaded before ScrollMagic or use an asynchronous loader like requirejs.");
132	}
133	// (BUILD) - REMOVE IN MINIFY - END
134    
135	/*
136     * ----------------------------------------------------------------
137     * Extensions for Scene
138     * ----------------------------------------------------------------
139     */
140	/**
141     * Every instance of ScrollMagic.Scene now accepts an additional option.  
142     * See {@link ScrollMagic.Scene} for a complete list of the standard options.
143     * @memberof! animation.GSAP#
144     * @method new ScrollMagic.Scene(options)
145     * @example
146     * var scene = new ScrollMagic.Scene({tweenChanges: true});
147     *
148     * @param {object} [options] - Options for the Scene. The options can be updated at any time.
149     * @param {boolean} [options.tweenChanges=false] - Tweens Animation to the progress target instead of setting it.  
150                                                      Does not affect animations where duration is `0`.
151     */
152	/**
153     * **Get** or **Set** the tweenChanges option value.  
154     * This only affects scenes with a duration. If `tweenChanges` is `true`, the progress update when scrolling will not be immediate, but instead the animation will smoothly animate to the target state.  
155     * For a better understanding, try enabling and disabling this option in the [Scene Manipulation Example](../examples/basic/scene_manipulation.html).
156     * @memberof! animation.GSAP#
157     * @method Scene.tweenChanges
158     * 
159     * @example
160     * // get the current tweenChanges option
161     * var tweenChanges = scene.tweenChanges();
162     *
163     * // set new tweenChanges option
164     * scene.tweenChanges(true);
165     *
166     * @fires {@link Scene.change}, when used as setter
167     * @param {boolean} [newTweenChanges] - The new tweenChanges setting of the scene.
168     * @returns {boolean} `get` -  Current tweenChanges option value.
169     * @returns {Scene} `set` -  Parent object for chaining.
170     */
171	// add option (TODO: DOC (private for dev))
172	ScrollMagic.Scene.addOption(
173        "tweenChanges", // name
174        false, // default
175        function (val) { // validation callback
176        	return !!val;
177        }
178    );
179	// extend scene
180	ScrollMagic.Scene.extend(function () {
181		var Scene = this,
182        _tween;
183
184		// (BUILD) - REMOVE IN MINIFY - START
185		var log = function () {
186			if (Scene._log) { // not available, when main source minified
187				Array.prototype.splice.call(arguments, 1, 0, "(" + NAMESPACE + ")", "->");
188				Scene._log.apply(this, arguments);
189			}
190		};
191		// (BUILD) - REMOVE IN MINIFY - END
192
193		// set listeners
194		Scene.on("progress.plugin_gsap", function () {
195			updateTweenProgress();
196		});
197		Scene.on("destroy.plugin_gsap", function (e) {
198			Scene.removeTween(e.reset);
199		});
200
201		/**
202         * Update the tween progress to current position.
203         * @private
204         */
205		var updateTweenProgress = function () {
206			if (_tween) {
207				var
208                    progress = Scene.progress(),
209                    state = Scene.state();
210				if (_tween.repeat && _tween.repeat() === -1) {
211					// infinite loop, so not in relation to progress
212					if (state === 'DURING' && _tween.paused()) {
213						_tween.play();
214					} else if (state !== 'DURING' && !_tween.paused()) {
215						_tween.pause();
216					}
217				} else if (progress != _tween.progress()) { // do we even need to update the progress?
218					// no infinite loop - so should we just play or go to a specific point in t
218ime?
219					if (Scene.duration() === 0) {
220						// play the animation
221						if (progress > 0) { // play from 0 to 1
222							_tween.play();
223						} else { // play from 1 to 0
224							_tween.reverse();
225						}
226					} else {
227						// go to a specific point in time
228						if (Scene.tweenChanges() && _tween.tweenTo) {
229							// go smooth
230							_tween.tweenTo(progress * _tween.duration());
231						} else {
232							// just hard set it
233							_tween.progress(progress).pause();
234						}
235					}
236				}
237			}
238		};
239
240		/**
241         * Add a tween to the scene.  
242         * If you want to add multiple tweens, add them into a GSAP Timeline object and supply it instead (see example below).  
243         * 
244         * If the scene has a duration, the tween's duration will be projected to the scroll distance of the scene, meaning its progress will be synced to scrollbar movement.  
245         * For a scene with a duration of `0`, the tween will be triggered when scrolling forward past the scene's trigger position and reversed, when scrolling back.  
246         * To gain better understanding, check out the [Simple Tweening example](../examples/basic/simple_tweening.html).
247         *
248         * Instead of supplying a tween this method can also be used as a shorthand for `TweenMax.to()` (see example below).
249         * @memberof! animation.GSAP#
250         *
251         * @example
252         * // add a single tween directly
253         * scene.setTween(TweenMax.to("obj"), 1, {x: 100});
254         *
255         * // add a single tween via variable
256         * var tween = TweenMax.to("obj"), 1, {x: 100};
257         * scene.setTween(tween);
258         *
259         * // add multiple tweens, wrapped in a timeline.
260         * var timeline = new TimelineMax();
261         * var tween1 = TweenMax.from("obj1", 1, {x: 100});
262         * var tween2 = TweenMax.to("obj2", 1, {y: 100});
263         * timeline
264         *      .add(tween1)
265         *      .add(tween2);
266         * scene.addTween(timeline);
267         *
268         * // short hand to add a TweenMax.to() tween
269         * scene.setTween("obj3", 0.5, {y: 100});
270         *
271         * // short hand to add a TweenMax.to() tween for 1 second
272         * // this is useful, when the scene has a duration and the tween duration isn't important anyway
273         * scene.setTween("obj3", {y: 100});
274         *
275         * @param {(object|string)} TweenObject - A TweenMax, TweenLite, TimelineMax or TimelineLite object that should be animated in the scene. Can also be a Dom Element or Selector, when using direct tween definition (see examples).
276         * @param {(number|object)} duration - A duration for the tween, or tween parameters. If an object containing parameters are supplied, a default duration of 1 will be used.
277         * @param {object} params - The parameters for the tween
278         * @returns {Scene} Parent object for chaining.
279         */
280		Scene.setTween = function (TweenObject, duration, params) {
281			var newTween;
282			if (arguments.length > 1) {
283				if ( arguments.length < 3) {
284					params = duration;
285					duration = 1;
286				}
287				TweenObject = Tween.to(TweenObject, duration, params);
288			}
289			try {
290				// wrap Tween into a Timeline Object if available to include delay and repeats in the duration and standardize methods.
291				if (Timeline) {
292					newTween = new Timeline({smoothChildTiming: true})
293                        .add(TweenObject);
294				} else {
295					newTween = TweenObject;
296				}
297				newTween.pause();
298			} catch (e) {
299				log(1, "ERROR calling method 'setTween()': Supplied argument is not a valid TweenObject");
300				return Scene;
301			}
302			if (_tween) { // kill old tween?
303				Scene.removeTween();
304			}
305			_tween = newTween;
306
307			// some properties need to be transferred it to the wrapper, otherwise they would get lost.
308			if (TweenObject.repeat && TweenObject.repeat() === -1) {// TweenMax or TimelineMax Object?
309				_tween.repeat(-1);
310				_tween.yoyo(TweenObject.yoyo());
311			}
312			// (BUILD) - REMOVE IN MINIFY - START
313			// Some tween validations and debugging helpers
314
315			if (Scene.tweenChanges() && !_tween.tweenTo) {
316				log(2, "WARNING: tweenChanges will only work if the TimelineMax object is available for ScrollMagic.");
317			}
318
319			// check if there are position tweens defined for the trigger and warn about it :)
320			if (_tween && Scene.controller()  && Scene.triggerElement() && Scene.loglevel() >= 2) {// controller is needed to know scroll direction.
321				var
322                    triggerTweens = Tween.getTweensOf(Scene.triggerElement()),
323                    vertical = Scene.controller().info("vertical");
324				triggerTweens.forEach(function (value, index) {
325					var
326                        tweenvars = value.vars.css || value.vars,
327                        condition = vertical ? (tweenvars.top !== undefined || tweenvars.bottom !== undefined) : (tweenvars.left !== undefined || tweenvars.right !== undefined);
328					if (condition) {
329						log(2, "WARNING: Tweening the position of the trigger element affects the scene timing and should be avoided!");
330						return false;
331					}
332				});
333			}
334
335			// warn about tween overwrites, when an element is tweened multiple times
336			if (parseFloat(TweenLite.version) >= 1.14) { // onOverwrite only present since GSAP v1.14.0
337				var
338                    list = _tween.getChildren ? _tween.getChildren(true, true, false) : [_tween], // get all nested tween objects
339                    newCallback = function () {
340                    	log(2, "WARNING: tween was overwritten by another. To learn how to avoid this issue see here: https://github.com/janpaepke/ScrollMagic/wiki/WARNING:-tween-was-overwritten-by-another");
341                    };
342				for (var i=0, thisTween, oldCallback; i<list.length; i++) {
343					/*jshint loopfunc: true */
344					thisTween = list[i];
345					if (oldCallback !== newCallback) { // if tweens is added more than once
346						oldCallback = thisTween.vars.onOverwrite;
347						thisTween.vars.onOverwrite = function () {
348							if (oldCallback) {
349								oldCallback.apply(this, arguments);
350							}
351							newCallback.apply(this, arguments);
352						};
353					}
354				}
355			}
356			// (BUILD) - REMOVE IN MINIFY - END
357			log(3, "added tween");
358
359			updateTweenProgress();
360			return Scene;
361		};
362
363		/**
364         * Remove the tween from the scene.  
365         * This will terminate the control of the Scene over the tween.
366         *
367         * Using the reset option you can decide if the tween should remain in the current state or be rewound to set the target elements back to the state they were in before the tween was added to the scene.
368         * @memberof! animation.GSAP#
369         *
370         * @example
371         * // remove the tween from the scene without resetting it
372         * scene.removeTween();
373         *
374         * // remove the tween from the scene and reset it to initial position
375         * scene.removeTween(true);
376         *
377         * @param {boolean} [reset=false] - If `true` the tween will be reset to its initial values.
378         * @returns {Scene} Parent object for chaining.
379         */
380		Scene.removeTween = function (reset) {
381			if (_tween) {
382				if (reset) {
383					_tween.progress(0).pause();
384				}
385				_tween.kill();
386				_tween = undefined;
387				log(3, "removed tween (reset: " + (reset ? "true" : "false") + ")");
388			}
389			return Scene;
390		};
391
392	});
393}));
394
395var boxMasonryMinWidth = 500;
396var boxMasonrySelector = '.box-container';
397var boxMasonryOptions = {
398    columnWidth: '.box-placeholder',
399    itemSelector: '.box',
400    fitWidth: true,
401    gutter: 10
402}
403
404$(document).ready(function () {
405
406    $(boxMasonrySelector).masonry(boxMasonryOptions);
407
408    $('.box').click(function (e) {
409        var box = $(this);
410        var isBoxAlreadySelected = box.hasClass('selected');
411        var img = $(this).find("img");
412        if (box.hasClass('is-open')) {
413            $('.box').removeClass('is-open');
414            if(!isBoxAlreadySelected && checkFilter())
415            {
416                $(img).addClass("image-gray");
417            }
418        } else {
419            $('.box').removeClass('is-open');
420            box.addClass('is-open');
421            $(img).removeClass("image-gray");
422        }
423
424        $(boxMasonrySelector).masonry();
425        $(boxMasonrySelector).masonry('layout');
426    });
427
428    $('[data-ps-box-select]').click(function () {
429
430        var currentBoxFilter = $(this);
431
432        isCurrentBoxFilterActive = currentBoxFilter.hasClass('active');
433
434        //ALL BOX FILTER
435        $('[data-ps-box-select]').each(function () {
436            var boxFilter = $(this);
437            boxFilter.removeClass('active');
438        });
439
440        if (isCurrentBoxFilterActive) {
441            currentBoxFilter.removeClass('active');
442        } else {
443            currentBoxFilter.addClass('active');
444        }
445
446        $('[data-ps-box-select-id]').each(function () {
447            var box = $(this);
448            var img = $(this).find("img");
449            isBoxAlreadySelected = box.hasClass('selected');
450            isBoxSelected = box.attr('data-ps-box-select-id') == currentBoxFilter.attr('data-ps-box-select');
451
452            if (!isCurrentBoxFilterActive)
453            {
454                if (isBoxAlreadySelected) {
455                    box.removeClass('selected');
456                    img.addClass('image-gray');
457                } else {
458                    if (isBoxSelected) {
459                        box.addClass('selected');
460                        img.removeClass('image-gray');
461                    } else {
462                        img.addClass('image-gray');
463                        box.removeClass('selected');
464                    }
465                }
466            }
467            else
468            {
469                box.removeClass('selected');
470                img.removeClass('image-gray');
471            }
472           
473        });
474    });
475
476    checkMasonryActivity();
477
478    $(window).resize(function () {
479        checkMasonryActivity()
480    })
481});
482function checkFilter() {
483    var isCurrentBoxFilterActive = false;
484    $('[data-ps-box-select]').each(function () {
485        if($(this).hasClass("active"))
486        {
487            isCurrentBoxFilterActive = true;
488        }
489    })
490    return isCurrentBoxFilterActive;
491}
492function checkMasonryActivity() {
493    if (window.innerWidth < boxMasonryMinWidth) {
494        $(boxMasonrySelector).masonry(boxMasonryOptions);
495        $(boxMasonrySelector).masonry('destroy');
496    } else {
497        $(boxMasonrySelector).masonry(boxMasonryOptions);
498    }
499}
500$(document).ready(function () {
501    setCollapsedNewsHeight();
502
503    $("#expandNews").click(function () {
504        expandCollapseNews(getCollapsedNewsHeight());
505    })
506});
507
508$(window).resize(function () {
509    setCollapsedNewsHeight();
510});
511
512function setCollapsedNewsHeight() {
513    var eventsContainer = $("#events").find(".events-container");
514    var height = getCollapsedNewsHeight();
515    if (height != 0 && height != null) {
516        eventsContainer.height(height);
517        $("#expandNews").html("See all");
518    }
519}
520
521function getCollapsedNewsHeight() {
522    var height = null;
523    var collapsedItems = null;
524
525    var eventsContainer = $("#events");
526    var events = null;
527
528    var linkSearch = window.location.search;
529    var expand = false;
530    if (linkSearch.indexOf("?expand") >= 0) {
531        expand = true;
532    }
533
534    if (typeof eventsContainer != "undefined" && eventsContainer.length > 0 && !expand) {
535
536        events = eventsContainer.find(".event-date-link");
537
538        if (typeof events != "undefined" && events != null && events.length > 1) {
539            collapsedItems = events.slice(0, 2);
540            height = 0;
541            collapsedItems.each(function (index, el) {
542                height += $(el).height();
543            })
544        }
545    }
546    return height;
547}
548
549function expandCollapseNews(height) {
550    var eventsContainer = $("#events").find(".events-container");
551    var eventsContainerClass = eventsContainer.attr("class");
552
553    if (height == null) {
554        eventsContainer.addClass("events-container-expanded");
555        eventsContainer.css("height", "auto");
556        $("#expandNews").html("Show less");
557    }
558    else {
559        console.log(eventsContainerClass.indexOf("events-container-expanded"))
560        if (eventsContainerClass.indexOf("events-container-expanded") != -1) {
561            eventsContainer.removeClass("events-container-expanded");
562            eventsContainer.height(height);
563            $("#expandNews").html("See all");
564        }
565        else {
566            eventsContainer.addClass("events-container-expanded");
567            eventsContainer.css("height", "auto");
568            $("#expandNews").html("Show less");
569        }
570    }
571
572}
573
574
575
576//$(document).ready(function () {
577
578//    $("#expandNews").click(function () {
579//        expandCollapseNews(ItemsCollapsedHeight);
580//    })
581
582//    var bodyClass = $("body").attr("class");
583//    var eventsContainer = $("#events");
584//    var maxItemToShowCollapsed = 3;
585//    var ItemsCollapsed = $(".event-container").slice(0, 2);
586//    var linkSearch = window.location.search;
587//    var expand = false;
588//    if (linkSearch.indexOf("?expand") >= 0) {
589//        expand = true;
590//    }
591
592//    var ItemsCollapsedHeight = 0;
593//    var ItemCollapsedMargin = parseInt($(".event-container").css("margin-bottom"));
594//    ItemsCollapsed.each(function (index, el) {
595//        ItemsCollapsedHeight = ItemsCollapsedHeight + $(el).height();
596//    })
597//    ItemsCollapsedHeight = ItemsCollapsedHeight + ItemCollapsedMargin * 2; //deve fare 295 ma fa 291
598//    $(".events-container").height(ItemsCollapsedHeight);
599//    if (bodyClass == "PressFolder" && expand) {
600//        expandCollapseNews(ItemsCollapsedHeight);
601//    }
602
603//});
604
605//$(window).resize(function () {
606//    var ItemsCollapsed = $(".event-container").slice(0, 2);
607//    var linkSearch = window.location.search;
608//    var expand = false;
609//    if (linkSearch.indexOf("?expand") >= 0) {
610//        expand = true;
611//    }
612
613//    var ItemsCollapsedHeight = 0;
614//    var ItemCollapsedMargin = parseInt($(".event-container").css("margin-bottom"));
615//    ItemsCollapsed.each(function (index, el) {
616//        ItemsCollapsedHeight = ItemsCollapsedHeight + $(el).height();
617//    })
618//    ItemsCollapsedHeight = ItemsCollapsedHeight + ItemCollapsedMargin * 2; //deve fare 295 ma fa 291
619//    $(".events-container").height(ItemsCollapsedHeight);
620//    if (bodyClass == "PressFolder" && expand) {
621//        expandCollapseNews(ItemsCollapsedHeight);
622//    }
623
624//});
625
626
627//function expandCollapseNews(ItemsCollapsedHeight) {
628//    var eventsContainerClass = $(".events-container").attr("class");
629//    if (eventsContainerClass.indexOf("events-container-expanded") >= 0) {
630//        $(".events-container").removeClass("events-container-expanded");
631//        $(".events-container").height(ItemsCollapsedHeight);
632//        $("#expandNews").html("See all");
633//    }
634//    else {
635//        $(".events-container").addClass("events-container-expanded");
636//        $(".events-container").css("height", "auto");
637//        $("#expandNews").html("Show less");
638//    }
639//}
640$(".box-content-section a").click(function (event) {
641    event.stopPropagation();
642})
643$(".contact-us-container").find(".textbox-field").on("input", function () {
644    var $inputField = $(this);
645    if ($inputField.hasClass("invalid-field")) {
646        $inputField.removeClass("invalid-field");
647        $inputField.parent().find(".error-field").addClass("hidden");
648    }
649});
650$(".contact-us-container").find(".checkbox-field").on("change", function () {
651    var $inputField = $(this);
652    if ($inputField.hasClass("invalid-field")) {
653        $inputField.removeClass("invalid-field");
654        $inputField.parent().find(".error-field").addClass("hidden");
655    }
656});
657
658$("#send-button").on("click", function (event) {
659    var $container = $(".contact-us-container");
660    var url = "/umbraco/api/Form/send";
661    var isFormValid = true;
662    var invalidFields = [];
663    var isClickable = true;
664    var $button = $(this);
665    if ($button.hasClass("sending")) {
666        isClickable = false;
667    }
668
669    if (isClickable) {
670        $($container).each(function () {
671            var genericForm = {
672                Groups: []
673            };
674            $("[ps-input-container]").each(function () {
675                var $inputContainer = $(this);
676
677                $inputContainer.find("[ps-input-inner]").each(function () {
678                    var $inputInner = $(this);
679
680                    var group = {
681                        GroupKey: $inputInner.attr("id"),
682                        Values: [],
683                        Type: $inputInner.data("type")
684
685                    };
686                    $inputInner.find("[ps-input]").each(function () {
687                        var $input = $(this);
688                        var inputValue = "";
689                        if ($input.attr("type") === "checkbox") {
690                            inputValue = $input.is(":checked");
691                        } else {
692                            inputValue = $input.val();
693                        }
694                        if ((inputValue === "" || inputValue === false || typeof inputValue === "undefined") && $input.attr("required")) {
695                            isFormValid = false;
696                            invalidFields.push($input);
697                        }
698                        var value = {
699                            Key: $input.attr("id"),
700                            Value: inputValue
701                        };
702                        group.Values.push(value);
703                    });
704                    genericForm.Groups.push(group);
705
706                });
707            });
708
709            var recaptcha = $("#g-recaptcha-response").val();
710
711            if (typeof recaptcha === "undefined" || recaptcha === null || recaptcha === "") {
712                isFormValid = false;
713            } else {
714                var group = {
715                    GroupKey: "recaptcha",
716                    Values: [{
717                        Key: 0,
718                        Value: recaptcha
719                    }],
720                    Type: "recaptcha"
721                };
722                genericForm.Groups.push(group);
723            }
724
725
726            if (!isFormValid) {
727                //console.log("invalid");
728                console.error("Invalid Form");
729                $button.removeClass("sending");
730                $button.addClass("send-error");
731                $button.html("<div class=\"sending-button\">" +
732                    "<span>Error</span>" +
733                    "</div>");
734                setTimeout(function () {
735                    $button.removeClass("send-error");
736                    $button.html("Send");
737                }, 3000);
738                $.each(invalidFields,
739                    function () {
740                        $invalidField = $(this);
741                        $invalidFieldParent = $invalidField.parent();
742                        $invalidFieldParent.find(".error-field").removeClass("hidden");
743                        $invalidField.addClass("invalid-field");
744                    });
745                if (recaptcha == "") {
746                    console.error("Invalid Recaptcha")
747                    $(".recaptcha").find(".error-field").removeClass("hidden");
748                    $(".recaptcha").css("box-shadow", "0 0 3px #F00");
749                }
750            } else {
751                $button = $("#send-button");
752                $button.addClass("sending");
753                $button.html("<div class=\"sending-button\">" +
754                    "<span>Sending</span>" +
755                    "<i class=\"fa fa-circle-o-notch fa-spin fa-fw\"></i>" +
756                    "</div>");
757                $.ajax({
758                    type: "POST",
759                    url: url,
760                    data: JSON.stringify(genericForm),
761                    //success: function () {
762                    //    $button.removeClass("sending");
763                    //    $button.addClass("send-successful");
764                    //    $button.html("<div class=\"sending-button\">" +
765                    //        "<span>Done</span>" +
766                    //        "</div>");
767                    //    clearForm($container);
768                    //    setTimeout(function () {
769                    //        $button.removeClass("sending");
770                    //        $button.removeClass("send-successful");
771                    //        $button.html("Send");
772                    //    }, 10000);
773                    //},
774                    //error: function () {
775                    //    console.log("There was an error contacting the WebApi /Form/send")
776                    //    $button.addClass("send-error");
777                    //    $button.html("<div class=\"sending-button\">" +
778                    //        "<span>Error</span>" +
779                    //        "</div>");
780                    //    setTimeout(function () {
781                    //        $button.removeClass("send-error");
782                    //        $button.html("Send");
783                    //    }, 3000);
784                    //},
785                    headers: {
786                        "Content-Type": "application/json"
787                    }
788                })
789                    .done(function () {
790                        $button.removeClass("sending");
791                        $button.addClass("send-successful");
792                        $button.html("<div class=\"sending-button\">" +
793                            "<span>Done</span>" +
794                            "</div>");
795                        clearForm($container);
796                        setTimeout(function () {
797                            $button.removeClass("sending");
798                            $button.removeClass("send-successful");
799                            $button.html("Send");
800                        }, 10000);
801                    })
802                    .fail(function () {
803                        console.log("There was an error contacting the WebApi /Form/send")
804                        $button.addClass("send-error");
805                        $button.html("<div class=\"sending-button\">" +
806                            "<span>Error</span>" +
807                            "</div>");
808                        setTimeout(function () {
809                            $button.removeClass("send-error");
810                            $button.html("Send");
811                        }, 3000);
812                    });
813            }
814        });
815    }
816});
817
818$('[ps-contact-us]').click(function (e) {
819
820    e.preventDefault();
821
822    var self = $(this);
823    var id = self.attr("ps-contact-us");
824
825    if (id != "") {
826        var form = "#contact-form-" + id;
827
828        var name = $("#contact-form-" + id + "-name").val();
829        var surname = $("#contact-form-" + id + "-surname").val();
830        var email = $("#contact-form-" + id + "-email").val();
831        var company = $("#contact-form-" + id + "-company").val();
832        var text = $("#contact-form-" + id + "-text").val();
833        var authorize = $("#contact-form-" + id + "-authorize").prop("checked");
834        var recaptcha = $("#g-recaptcha-response").val();
835
836        debugger;
837
838        if (recaptcha != "" && name != "" && surname != "" && validateEmail(email) && text != "" && authorize) {
839            $.ajax({
840                type: "POST",
841                url: $(form).attr("action"),
842                data: "name=" + name + "&surname=" + surname + "&company=" + company + "&text=" + text + "&email=" + email + "&recaptcha=" + recaptcha,
843                dataType: "html",
844                success: function (msg) {
845                    toastr.success('Messaggio inviato correttamente. Grazie');
846                    document.getElementById("contact-form-" + id).reset();
847                },
848                error: function (data) {
849                    toastr.error("Problemi nell'invio del messaggio. Riprovare più tardi.");
850                    console.log(data.responseText);
851                }
852            });
853        }
854        else {
855            toastr.error("Compila correttamente tutti i campi obbligatori, autorizza il trattamento dei dati e riprova");
856        }
857
858
859
860    } else {
861        alert("error id null");
862    }
863});
864
865$("#formLogin").on("click", function () {
866    var username = $("#requestUsername").val();
867    var password = $("#requestPassword").val();
868    var url = "/umbraco/surface/Login/loginResult?id=" + username + "&password=" + password;
869    $.ajax({
870        type: "POST",
871        url: url,
872        success: function (data) {
873            if (data.toLowerCase() === "ok") {
874                var redirectUrl = window.location.href;
875                window.location.replace(redirectUrl);
876            } else if (data.toLowerCase() === "badrequest") {
877                outlineField($("#requestPassword"));
878            } else if (data.toLowerCase() === "notfound") {
879                outlineField($("#requestUsername"));
880            }
881        }
882    });
883});
884
885$("#clear-button").on("click", function () {
886    clearForm($(".contact-us-container"));
887});
888$("#formClear").on("click", function () {
889    clearForm(".login-form-container");
890});
891function clearForm(container) {
892    $(container).each(function () {
893        $("[ps-input]").each(function () {
894            var inputType = $(this).attr("type");
895            if (inputType === "checkbox") {
896                $(this).prop("checked", false);
897            } else {
898                $(this).val("");
899            }
900        });
901    });
902}
903function outlineField(field) {
904    field.addClass("invalid-field");
905    field.parent().find(".error-field").removeClass("hidden");
906}
907
908
909//Modale Homepage
910var isOverlayModalOpen = false;
911$(".subscribe-button").click(function () {
912
913    $(".hover-black").addClass("hover-open");
914    $(".modal-container").addClass("modal-open");
915    $("body").css("overflow", "hidden");
916    $("body").css("padding-right",getScrollBarWidth());
917    $(".main-menu-container").css("margin-right", getScrollBarWidth());
918
919})
920$(".modal-close").click(function () {
921    $(".hover-black").removeClass("hover-open");
922    $(".modal-container").removeClass("modal-open");
923    $("body").delay(400).queue(function () {
924        $("body").css("padding-right", "").dequeue();
925        $("body").css("overflow", "").dequeue();
926        $(".main-menu-container").css("margin-right", "").dequeue();
927    });
928
929})
930$(window).resize(function () {
931    var windowSize = window.innerWidth;
932    if(windowSize >= 992)
933    {
934        if (isOverlayModalOpen)
935            closeModal();
936    }
937})
938
939//Modale overlay destro
940$("#overlay-black-background").on("click", function (event) {
941    if (isOverlayModalOpen)
942        closeModal();
943})
944$(".overlay-single-click").on("click", function () {
945    if (isOverlayModalOpen)
946        closeModal();
947})
948
949$("#overlay-right-column-button").click(function () {
950    if (!isOverlayModalOpen)
951        openModal();
952})
953$("#overlay-modal-cross").click(function () {
954    if (isOverlayModalOpen)
955        closeModal();
956})
957
958function closeModal() {
959    isOverlayModalOpen = false;
960    $(".overlay-right-column-modal-container").addClass("hidden-news");
961    $("body").delay(400).queue(function () {
962        $("body").css("padding-right", "").dequeue();
963        $("body").css("overflow", "").dequeue();
964        $(".overlay-right-column-button").css("padding-right", "").dequeue();
965        $(".main-menu-container").css("padding-right", "").dequeue();
966    });
967}
968
969function openModal() {
970    isOverlayModalOpen = true;
971    $(".main-menu-container").css("padding-right", getScrollBarWidth());
972    $(".overlay-right-column-modal-container").removeClass("hidden-news");
973    $("body").css("padding-right", getScrollBarWidth());
974    $(".overlay-right-column-button").css("padding-right", getScrollBarWidth());
975    $("body").css("overflow", "hidden");
976}
977
978function getScrollBarWidth() {
979    var scrollDiv = document.createElement("div");
980    scrollDiv.className = "scrollbar-measure";
981    document.body.appendChild(scrollDiv);
982
983    // Get the scrollbar width
984    var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
985    //console.log(scrollbarWidth); // Mac:  15
986
987    // Delete the DIV 
988    document.body.removeChild(scrollDiv);
989    return scrollbarWidth;
990}
991var publicationFrom, publicationTo, publicationType, publicationText, publicationResults, sendButton, resetButton;
992
993var url = "/umbraco/surface/Publications/getAllPublications" + "?";
994$(document).ready(function () {
995    initPublicationForm($("#publication-form-container"));
996    $("#publication-field-send").on("click", function () {
997        var notValidFields = isFormValidated();
998        if (notValidFields.length == 0)
999        {
1000            setLoadingStateSendButton(true);
1001            sendRequest(0);
1002        }
1003        else {
1004            setSendButtonError();
1005            $.each(notValidFields, function (key, element) {
1006                setStateOfValidationToElement(element, true)
1007            })
1008        }
1009    });
1010    $("#publication-field-reset").on("click", function () {
1011        resetForm();
1012        sendRequest(1);
1013    });
1014    
1015    $("#publication-field-from").change(function () {
1016        setStateOfValidationToElement($(this),false)
1017    })
1018    $("#publication-field-to").change(function () {
1019        setStateOfValidationToElement($(this), false)
1020    })
1021    $("#publication-field-type").change(function () {
1022        setStateOfValidationToElement($(this), false)
1023    })
1024})
1025
1026function initPublicationForm(container) {
1027    sendButton = $("#publication-field-send");
1028    resetButton = $("#publication-field-reset");
1029    if (typeof container !== "undefined" && container.length > 0) {
1030        publicationFrom = $("#publication-field-from");
1031        publicationTo = $("#publication-field-to");
1032        publicationType = $("#publication-field-type");
1033        publicationText = $("#publication-field-text");
1034        publicationResults = $("#publication-results");
1035    } else {
1036        if (isElementDefined(sendButton) && isElementDefined(resetButton))
1037        {
1038            setStateButtonDisabled(sendButton, true);
1039            setStateButtonDisabled(resetButton, true);
1040        }
1041    }
1042}
1043
1044function sendRequest(resetElements) {
1045    var request = "";
1046    if (resetElements == 0)
1047    {
1048        request = "from=" + publicationFrom.val() + "&";
1049        request = request + "to=" + publicationTo.val() + "&";
1050        if (publicationText.val() != "")
1051            request = request + "type=" + publicationType.val() + "&";
1052        if (publicationText.val() != "")
1053            request = request + "text=" + publicationText.val() + "&";
1054
1055    } else {
1056        request = "from=" + defaultPublicationInitialYear + "&";
1057        request = request + "to=" + defaultPublicationLastYear + "&";
1058    }
1059    request = request + "initialize=" + resetElements;
1060
1061    publicationResults.empty()
1062    
1063
1064    $.ajax({
1065        url: url + request,
1066    })
1067    .done(function (response) {
1068        publicationResults.empty().append(response)
1069        setTimeout(function () {
1070            setLoadingStateSendButton(false);
1071        }, 20)
1072    })
1073    .fail(function () {
1074        setSendButtonError()
1075    })
1076}
1077
1078//Visual
1079
1080function resetForm() {
1081    resetSelectField(publicationFrom,0);
1082    resetSelectField(publicationTo,publicationTo.last());
1083    resetSelectField(publicationType,0);
1084    publicationText.val("");
1085}
1086
1087function setStateOfValidationToElement(element,notValidated)
1088{
1089    if(isElementDefined(element))
1090    {
1091        var mandatoryElement = element.parent().find(".publication-field-mandatory");
1092        if (isElementDefined(mandatoryElement))
1093        {
1094            if (notValidated) {
1095                element.addClass("input-not-valid");
1096                mandatoryElement.removeClass("hidden");
1097            } else {
1098                element.removeClass("input-not-valid");
1099                mandatoryElement.addClass("hidden");
1100            }
1101        }
1102    }
1103}
1104
1105function resetSelectField(field, selectedIndex) {
1106    if(isElementDefined(field))
1107    {
1108        field.removeClass("not-valid");
1109        field.prop('selectedIndex', selectedIndex);
1110        setStateOfValidationToElement(field, false);
1111    }
1112}
1113
1114
1115function isFormValidated() {
1116    var notValidFields = [];
1117
1118    if (publicationType.prop('selectedIndex') == "0" && publicationText.val() != "")
1119        notValidFields.push(publicationType);
1120
1121    return notValidFields;
1122}
1123
1124function setSendButtonError() {
1125    sendButton.addClass("send-error");
1126    sendButton.empty().append("Error");
1127    setStateButtonDisabled(sendButton, true);
1128    setTimeout(function () {
1129        sendButton.removeClass("send-error");
1130        sendButton.empty().append("Search");
1131        setStateButtonDisabled(sendButton, false);
1132        sendButton.removeClass("send-loading");
1133    }, 3000)
1134}
1135
1136function setStateButtonDisabled(button, setDisabled) {
1137    if (isElementDefined(button)) {
1138        button.prop("disabled", setDisabled)
1139    }
1140}
1141
1142function setLoadingStateSendButton(setLoading) {
1143    if (isElementDefined(sendButton)) {
1144        if (setLoading) {
1145            sendButton.empty().append("<i class='fa fa-circle-o-notch fa-spin fa-fw'></i>");
1146            sendButton.addClass("send-loading");
1147        } else {
1148            sendButton.empty().append("Search");
1149            sendButton.removeClass("send-loading");
1150        }
1151        setStateButtonDisabled(sendButton, setLoading);
1152    }
1153}
1154
1155function isElementDefined(element) {
1156    var isElementDefined;
1157
1158    if (typeof sendButton !== "undefined" && sendButton.length > 0)
1159        return true;
1160
1161    return isElementDefined;
1162}
1163
1164
1165var bodyClass = $("body").attr("class");
1166if (bodyClass == "ActivitiesFolder" || bodyClass == "Resources" || bodyClass == "PressFolder")
1167{
1168    var offset = 0;
1169    if (bodyClass == "ActivitiesFolder")
1170    {
1171        offset = 120;
1172    }
1173    else
1174    {
1175        offset = 80;
1176    }
1177    var jump = function (e) {
1178        if (e) {
1179            e.preventDefault();
1180            var target = $(this).attr("href");
1181        } else {
1182            var target = location.hash;
1183        }
1184
1185        $('html,body').animate(
1186        {
1187            
1188            scrollTop: $(target).offset().top - offset
1189        }, 0, function () {
1190            location.hash = target;
1191        });
1192    }
1193
1194    $(document).ready(function () {
1195        $('a[href^=#]').bind("click", jump);
1196        if (location.hash) {
1197            setTimeout(function () {
1198                $('html, body').scrollTop();
1199                
1200                jump();
1201            }, 0);
1202        } else {
1203            $('html, body').show();
1204        }
1205    });
1206}
1207//mCustomScrollbar
1208$(window).on("load", function () {
1209    $(".press-scrollbar").mCustomScrollbar({
1210        theme: "dark"
1211    });
1212    $(".press-article-scrollbar").mCustomScrollbar({
1213        theme: "dark"
1214    })
1215});
1216//Paralax Effect
1217var controller1 = new ScrollMagic.Controller({ globalSceneOptions: { triggerHook: "onEnter", duration: "300%" } });
1218
1219if ($("#parallax1") != undefined && $("#parallax1").length > 0) {
1220
1221    new ScrollMagic.Scene({ triggerElement: "#parallax1" })
1222                    .setTween("#parallax1 > .paralaxInner", { y: "50%", ease: Linear.easeNone })
1223                    .addTo(controller1);
1224}
1225if ($("#parallax1") != undefined && $("#parallax2").length > 0) {
1226    new ScrollMagic.Scene({ triggerElement: "#parallax2" })
1227                    .setTween("#parallax2 > .paralaxInner", { y: "50%", ease: Linear.easeNone })
1228                    .addTo(controller1);
1229}
1230if ($("#parallax1") != undefined && $("#parallax3").length > 0) {
1231    new ScrollMagic.Scene({ triggerElement: "#parallax3" })
1232                    .setTween("#parallax3 > .paralaxInner", { y: "50%", ease: Linear.easeNone })
1233                    .addTo(controller1);
1234}
1235if ($("#parallax1") != undefined && $("#parallax4").length > 0) {
1236    new ScrollMagic.Scene({ triggerElement: "#parallax4" })
1237                    .setTween("#parallax4 > .paralaxInner", { y: "50%", ease: Linear.easeNone })
1238                    .addTo(controller1);
1239}
1240if ($("#parallax1") != undefined && $("#parallax5").length > 0) {
1241    new ScrollMagic.Scene({ triggerElement: "#parallax5" })
1242                .setTween("#parallax5 > .paralaxInner", { y: "50%", ease: Linear.easeNone })
1243                .addTo(controller1);
1244}
1245
1246
1247//Blur effects
1248//var controller2 = new ScrollMagic.Controller({ globalSceneOptions: { triggerHook: "onEnter", duration: "200%" } });
1249//var blurElement = { a: 0 };
1250//TweenLite.to(blurElement, 1, { a: 10 });
1251//new ScrollMagic.Scene({ triggerElement: "#parallax1" })
1252//                .setTween("#parallax1 > .paralax-inner", { y: 10%, ease: Linear.easeNone })
1253//                .addIndicators()
1254//                .addTo(controller2);
1255//function applyBlur() {
1256//    TweenLite.set(element, { webkitFilter: "blur(" + element.blur + "px)" });
1257//}
1258
1259$(document).ready(function(){
1260    $('.newsletter-resources-carousel').slick({
1261        infinite: true,
1262        slidesToShow: 4,
1263        slidesToScroll: 4,
1264        dots: true,
1265        arrows: true,
1266        nextArrow: '<div type="button" class="slick-arrow slick-arrow-right"><i class="fa fa-chevron-right" aria-hidden="true"></i></div>',
1267        prevArrow: '<div type="button" class="slick-arrow slick-arrow-left"><i class="fa fa-chevron-left" aria-hidden="true"></i></div>',
1268        responsive: [
1269       {
1270           breakpoint: 700,
1271           settings: {
1272               slidesToShow: 1,
1273               slidesToScroll: 1,
1274               infinite: true,
1275               dots: true
1276           }
1277       },
1278       {
1279           breakpoint: 992,
1280           settings: {
1281               slidesToShow: 2,
1282               slidesToScroll: 2
1283           }
1284       },
1285       {
1286           breakpoint: 1200,
1287           settings: {
1288               slidesToShow: 3,
1289               slidesToScroll: 3
1290           }
1291       },
1292       {
1293           breakpoint: 1400,
1294           settings: {
1295               slidesToShow: 4,
1296               slidesToScroll: 4
1297           }
1298       }]
1299    });
1300    $('.otherReports-slider-container').slick({
1301        autoplay: true,
1302        autoplaySpeed: 1000,
1303        speed:1000,
1304        infinite: true,
1305        slidesToShow: 3,
1306        slidesToScroll: 3,
1307        dots: true,
1308        arrows: true,
1309        responsive: [
1310       {
1311           breakpoint: 700,
1312           settings: {
1313               slidesToShow: 1,
1314               slidesToScroll: 1,
1315               infinite: true,
1316               dots: true
1317           }
1318       },
1319       {
1320           breakpoint: 992,
1321           settings: {
1322               slidesToShow: 2,
1323               slidesToScroll: 2
1324           }
1325       },
1326       {
1327           breakpoint: 1400,
1328           settings: {
1329               slidesToShow: 3,
1330               slidesToScroll: 3
1331           }
1332       }]
1333    });
1334    $('.conferences-slider-container').slick({
1335        infinite: true,
1336        slidesToShow: 3,
1337        slidesToScroll: 3,
1338        dots: true,
1339        arrows: true,
1340        nextArrow: '<div type="button" class="slick-arrow slick-arrow-right"><i class="fa fa-chevron-right" aria-hidden="true"></i></div>',
1341        prevArrow: '<div type="button" class="slick-arrow slick-arrow-left"><i class="fa fa-chevron-left" aria-hidden="true"></i></div>',
1342        responsive: [
1343       {
1344           breakpoint: 700,
1345           settings: {
1346               slidesToShow: 1,
1347               slidesToScroll: 1,
1348               infinite: true,
1349               dots: true
1350           }
1351       },
1352       {
1353           breakpoint: 1200,
1354           settings: {
1355               slidesToShow: 2,
1356               slidesToScroll: 2
1357           }
1358       },
1359       {
1360           breakpoint: 1500,
1361           settings: {
1362               slidesToShow: 3,
1363               slidesToScroll: 3
1364           }
1365       }]
1366    });
1367    
1368    //TODO: Da controllare se gli slider qui sotto servono ancora.........
1369
1370    // consortium slider
1371    $('.consortium-partner-list-carousel').slick({
1372        slidesToShow: 4,
1373        slidesToScroll: 4,
1374        dots: true,
1375        arrows: true,
1376        responsive: [
1377          {
1378              breakpoint: 1400,
1379              settings: {
1380                  slidesToShow: 4,
1381                  slidesToScroll: 4,
1382              }
1383          },
1384          {
1385              breakpoint: 996,
1386              settings: {
1387                  slidesToShow: 3,
1388                  slidesToScroll: 3,
1389              }
1390          },
1391          {
1392              breakpoint: 767,
1393              settings: {
1394                  slidesToShow: 1,
1395                  slidesToScroll: 1,
1396              }
1397          },
1398          {
1399              breakpoint: 465,
1400              settings: {
1401                  slidesToShow: 1,
1402                  slidesToScroll: 1,
1403              }
1404          }
1405        ]
1406    });
1407
1408    // newsletter slider
1409    $('.newsletter-partner-list-carousel').slick({
1410        slidesToShow: 3,
1411        slidesToScroll: 3,
1412        dots: true,
1413        arrows: true,
1414        responsive: [
1415          {
1416              breakpoint: 1400,
1417              settings: {
1418                  slidesToShow: 3,
1419                  slidesToScroll: 3,
1420              }
1421          },
1422          {
1423              breakpoint: 996,
1424              settings: {
1425                  slidesToShow: 3,
1426                  slidesToScroll: 3,
1427              }
1428          },
1429          {
1430              breakpoint: 767,
1431              settings: {
1432                  slidesToShow: 1,
1433                  slidesToScroll: 1,
1434              }
1435          },
1436          {
1437              breakpoint: 465,
1438              settings: {
1439                  slidesToShow: 1,
1440                  slidesToScroll: 1,
1441              }
1442          }
1443        ]
1444    });
1445
1446    // News slider
1447    $('.news-slider').slick({
1448        infinite: true,
1449        slidesToShow: 4,
1450        dots: true,
1451        arrows: false,
1452        focusOnSelect: true,
1453        autoplay: true,
1454        draggable: true,
1455        responsive: [
1456            {
1457                breakpoint: 1400,
1458                settings: {
1459                    slidesToShow: 4,
1460                }
1461            },
1462            {
1463                breakpoint: 996,
1464                settings: {
1465                    slidesToShow: 2,
1466                }
1467            },
1468            {
1469                breakpoint: 767,
1470                settings: {
1471                    slidesToShow: 1,
1472                },
1473            }
1474
1475        ]
1476    });
1477
1478    // Press big slider
1479    $('.press-first-slider').slick({
1480        slidesToShow: 3,
1481        dots: true,
1482        arrows: false,
1483        responsive: [
1484          {
1485              breakpoint: 1400,
1486              settings: {
1487                  slidesToShow: 3,
1488                  centerPadding: '0px',
1489              }
1490          },
1491          {
1492              breakpoint: 996,
1493              settings: {
1494                  slidesToShow: 2,
1495                  centerPadding: '0px',
1496              }
1497          },
1498          {
1499              breakpoint: 767,
1500              settings: {
1501                  slidesToShow: 1,
1502                  centerPadding: '0px',
1503              }
1504          }
1505        ]
1506    });
1507   
1508    //News article image carousel
1509    $('.slider-image').slick({
1510        slidesToShow: 1,
1511        slidesToScroll: 1,
1512        arrows: false,
1513        fade: true,
1514        asNavFor: '.slider-nav'
1515    });
1516    $('.slider-nav').slick({
1517        slidesToShow: 3,
1518        slidesToScroll: 1,
1519        asNavFor: '.slider-image',
1520        dots: false,
1521        centerMode: true,
1522        focusOnSelect: true,
1523        arrows: false
1524    });
1525
1526    //News article image carousel grid
1527    $('.article-images-grid').slickLightbox({
1528        //itemSelector: '> .article-images-grid-item',
1529        useHistoryApi: 'true',
1530        slick: {
1531            prevArrow: '<button type="button" class="slick-prev article-images-prev">Previous</button>',
1532            nextArrow: '<button type="button" class="slick-next article-images-next">Next</button>',
1533        }
1534    });
1535    
1536});
1537//SUBSCRIBE HOMEPAGE
1538$(window).on('load', function () {
1539    $(".subscribe-error-container").addClass("hidden");
1540    $(".subscribe-response-container").addClass("hidden");
1541
1542})
1543function clearField() {
1544    $(".input > input").val("");
1545}
1546$("#homePageSubmitButton").click(function () {
1547    AjaxLoader();
1548
1549    function AjaxLoader() {
1550        var privacyBox = "";
1551        if ($("#privacy").is(":checked")) {
1552            privacyBox = "true";
1553        }
1554        else {
1555            privacyBox = "false";
1556        }
1557        var url = "/umbraco/Surface/HomePageContent/HomePageForm";
1558        console.log("Ajax update");
1559        var formData = {
1560            name: $("#name").val(),
1561            surname: $("#surname").val(),
1562            email: $("#email").val(),
1563            affiliation: $("#affiliation").val(),
1564            privacy: privacyBox
1565        }
1566
1567        $.ajax({
1568            type: "POST",
1569            url: url,
1570            data: JSON.stringify(formData),
1571            contentType: 'application/json;charset=utf-8',
1572            success: function (responseText) {
1573                console.log("OK");
1574                $(".subscribe-error-container").html("");
1575                $(".subscribe-error-container").addClass("hidden");
1576                $(".subscribe-response-container").html("");
1577                $(".subscribe-response-container").addClass("hidden");
1578                if (responseText.toLowerCase().indexOf("required") >= 0) {
1579                    $(".subscribe-error-container").removeClass("hidden").delay(3000).queue(function () {
1580                        $(".subscribe-error-container").addClass("hidden").dequeue();
1581                    });
1582                    $(".subscribe-error-container").html("<i class='fa fa-exclamation-triangle' aria-hidden='true'></i>" + responseText);
1583                }
1584                else {
1585                    $(".subscribe-response-container").removeClass("hidden").delay(3000).queue(function () {
1586                        $(".subscribe-response-container").addClass("hidden").dequeue();
1587                        clearField();
1588                    });
1589                    $(".subscribe-response-container").html("<i class='fa fa-thumbs-o-up' aria-hidden='true'></i>" + responseText);
1590                }
1591            },
1592            error: function (responseText) {
1593                console.error("ERROR");
1594                $(".subscribe-response-container").removeClass("hidden").delay(3000).queue(function () {
1595                    $(".subscribe-response-container").addClass("hidden").dequeue();
1596                });
1597                $(".subscribe-error-container").html(responseText);
1598            }
1599        })
1600    }
1601})
1602$("#homePageCancelButton").click(function () {
1603    clearField();
1604    $(".subscribe-response-container").removeClass("hidden").delay(3000).queue(function () {
1605        $(".subscribe-response-container").addClass("hidden").dequeue();
1606    });
1607    $(".subscribe-response-container").html("<i class='fa fa-thumbs-o-up' aria-hidden='true'></i> All fields cleared");
1608})
1609
1610$(document).ready(function () {
1611
1612    $(".brochures-select").change(function () {
1613        $(".brochures-select option:selected").each(function () {
1614            var _this = $(this);
1615
1616            $('[data-ps-brochure-download-button]').addClass("not-active").removeAttr("href");
1617            $('[data-ps-brochure-browse-button]').addClass("not-active").removeAttr("href");
1618
1619            if (_this.val() != "") {
1620                if (_this.attr('data-ps-brochure-download') != "") {
1621                    $('[data-ps-brochure-download-button]').attr('href', _this.attr('data-ps-brochure-download')).removeClass("not-active");
1622                }
1623                if (_this.attr('data-ps-brochure-online') != "") {
1624                    $('[data-ps-brochure-browse-button]').attr('href', _this.attr('data-ps-brochure-online')).removeClass("not-active");
1625                }
1626                if (_this.attr('data-ps-brochure-title') != "") {
1627                    $('[data-ps-brochure-title-display]').html(_this.attr('data-ps-brochure-title'));
1628                }
1629            }
1630            else {
1631                $('[data-ps-brochure-title-display]').html("");
1632               
1633            }
1634        });
1635
1636
1637    });
1638
1639	var psEventIntro = $("[ps-news-event-intro]")
1640	var psNewsEventContainer = $("[ps-news-event-container]");
1641	if (typeof psNewsEventContainer !== 'undefined' && psNewsEventContainer != null)
1642		psNewsEventContainer.on("click", function (e) {
1643			var attrUrl = $(e.currentTarget).attr("ps-news-event-container");
1644			if (typeof attrUrl !== 'undefined' && attrUrl != null && attrUrl != "")
1645				window.location.href = attrUrl;
1646		})
1647
1648	if (typeof psEventIntro !== 'undefined' && psEventIntro != null) {
1649		console.log(psEventIntro)
1650		psEventIntro.on("click", function (e) {
1651			var links = $(this).find("a");
1652			links.on("click", function (ae) {
1653				ae.stopPropagation();
1654			})
1655		});
1656    }
1657
1658    //Smooth Scrolling (viene da znit.js), necessario per smooth scrolling in pagina activities
1659    $(function () {
1660        $('a[href*=#]:not([href=#])').click(function () {
1661            if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
1662                var target = $(this.hash);
1663                target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
1664                if (target.length) {
1665                    $('html,body').animate({
1666                        scrollTop: (target.offset().top - 50)
1667                    }, 1000);
1668                    return false;
1669                }
1670            }
1671        });
1672    });
1673
1674    //Menu (da znit.js) aggiunge classe on-top nel menu, non chiaro a cosa serva quella classe, ma non interferisce neg
1675    navbarOnScroll();
1676
1677    $(document).on("scroll", function () {
1678        navbarOnScroll();
1679    });
1680
1681    //Fix close menu on click (da znit.js) non sembra fare niente, forse dovrenbbe tenere aperto il menu mob. clickando su una voce ma non sembra funzionare
1682    $('.navbar-collapse').find('li > a').on('click', function (e) {
1683        if ($(e.target).is('a') && $(e.target).attr('class') != 'dropdown-toggle') {
1684            $('.navbar-collapse').collapse('hide');
1685           
1686        }
1687    });
1688
1689    // (da znit.js) l'unico consortium-item trovato è nel template single-page che non sembra venir usato, ma potrebbe in futuro come landing page
1690    $(document).on('click', '.consortium-item', function (e) {
1691        e.preventDefault();
1692        var partnerName = $(this).attr('data-name');
1693        var url = window.location.href.replace('home', 'about-us/partners') + '?partner_name=' + partnerName;
1694        window.location = url;
1695    })
1696
1697});
1698
1699//mansory da znit.js
1700
1701// usato nella pagina newsletter folder, che però non viene mostrata nel menu
1702$('#newsletter-section-page').masonry({ itemSelector: '.newsletter-item-container' });
1703
1704//non sembra esserci un activities-section-page nel progetto
1705$('#activities-section-page').masonry({ itemSelector: '.project-item' });
1706
1707//in press archived folder viene usato, anche se press archived folder sembra ancora in test
1708$('.press-page').masonry({ itemSelector: '.press-item' });
1709
1710$(window).on('resize', function () {
1711    $('#activities-section-page').masonry({ itemSelector: '.project-item' });
1712    $('.press-page').masonry({ itemSelector: '.press-item' });
1713    $('#newsletter-section-page').masonry({ itemSelector: '.newsletter-item-container' });
1714})
1715
1716
1717
1718function navbarOnScroll(){
1719    if ($(document).scrollTop() > 50) { 
1720        $("header").removeClass("on-top");
1721        $(".logo-container").addClass("top");
1722    }
1723    else {
1724        $("header").addClass("on-top");
1725        $(".logo-container").removeClass("top");
1726    }
1727}
1728
1729//(da znit.js) funzione che non sembra usata
1730function gup(name) {
1731    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
1732    var regexS = "[\\?&]" + name + "=([^&#]*)";
1733    var regex = new RegExp(regexS);
1734    var results = regex.exec(window.location.href);
1735    if (results == null)
1736        return "";
1737    else
1738        return results[1];
1739}
1740
1741

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.