<?php
    /**
    *
    * copyright (c) 2013-2019 Heliac Technologies
    * license http://opensource.org/licenses/gpl-license.php GNU GPL v3 
    *
    * linee guida per l'utilizzo del logo http://www.geecom.org/articolo.php?id=34&alias=linee-guida-per-l%27uso-del-logo-geecom
    */

    /*
            include il js comune a tutte le pagine, più la favicon
    */
?>
    <script src="../js/util.js" type="text/javascript"></script>
    <script src="../plugins/jQuery/jquery-3.4.1.min.js" type="text/javascript"></script>
    <script src="../plugins/popper/popper.min.js" type="text/javascript"></script>
    <script src="../plugins/bootstrap/bootstrap.min.js" type="text/javascript"></script>
    
    <!-- Tooltips e Popover -->
    <script>
        $(function () {
          $('[data-toggle="tooltip"]').tooltip()
        }) 
    </script>
    
    <script type="text/javascript"> 		
		$(function(){

			$("[data-toggle=popover]").popover({
				html : true,
				content: function() {
					var content = $(this).attr("data-popover-content");
					return $(content).children(".popover-body").html();
				},
				title: function() {
					var title = $(this).attr("data-popover-content");
					return $(title).children(".popover-heading").html();
				}
			});

		});
		
		 $('body').on('click', function (e) {
			$('[data-toggle="popover"]').each(function () {
				//the 'is' for buttons that trigger popups
				//the 'has' for icons within a button that triggers a popup
				if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
					$(this).popover('hide');
				}
			});
		});
    </script> 

    <!-- Mostra div con radio button -->
    <script type="text/javascript">
            $(document).ready(function(){
                    $('input[type="radio"]').click(function(){
                            var inputValue = $(this).attr("value");
                            var targetBox = $("." + inputValue);
                            $(".none").not(targetBox).hide();
                            $(targetBox).show();
                    });
            });
    </script>

     <!-- Mostra div con select -->
    <script type="text/javascript">
    $(document).ready(function(){
            $("select").change(function(){
                    $(this).find("option:selected").each(function(){
                            var optionValue = $(this).attr("value");
                            if(optionValue){
                                    $(".none").not("." + optionValue).hide();
                                    $("." + optionValue).show();
                            } else{
                                    $(".none").hide();
                            }
                    });
            }).change();
    });
    </script>

    <!-- Nestable2 -->
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/nestable2/1.6.0/jquery.nestable.min.js"></script>
    <script>
          $('.dd').nestable({ 
                  'depth': 1,
                  'parent_id': 'contenitore-sezioni-pagina'
          });
    </script>
    
    <!-- TinyMCE --> 
    <script src="../plugins/tinymce/tinymce.min.js"></script>
    <script>
        tinymce.init({
            selector:'.tiny',
            plugins: [
                'advlist autolink pagebreak lists link image charmap print preview anchor textcolor',
                'searchreplace visualblocks code fullscreen',
                'insertdatetime media table contextmenu paste code wordcount'
            ],
            pagebreak_separator: "<!-- leggi tutto -->",
            toolbar: 'insert | undo redo  pagebreak |  formatselect | bold italic link unlink forecolor backcolor  | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | code',
            height:'400',
            language : 'it',
            valid_elements : '*[*]',
            branding:false
        });
    </script>   
    
    <!-- Codice per evitare il problema delle modal in modal con Tinymce --> 
    <script>
        $(document).on('focusin', function(e) {
            if ($(e.target).closest(".mce-window").length) {
              e.stopImmediatePropagation();
            }
          });
    </script>
    
    <!-- Switchery -->
    <script type="text/javascript" src="../plugins/switchery/switchery.min.js"></script>
    <script type="text/javascript">
        var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch'));

        elems.forEach(function(html) {
          var switchery = new Switchery(html, { size: 'small', color: 'var(--primary)', jackColor: '#FFF' });

        });
    </script>
    
    <!-- Color Picker -->
    <script src="../plugins/bootstrap-colorpicker/colorpicker.js" type="text/javascript"></script>
    <script>
        $(function () {
            $('.selettore-colore').colorpicker({
                format: 'hex'
            });
        });
    </script>
    
    <!-- Data Table -->
    <script src="../plugins/datatable/datatables.min.js" type="text/javascript"></script>
    
    <!-- Bootstrap select -->
    <script src="../plugins/bootstrap-select/bootstrap-select.min.js" type="text/javascript"></script>
    <script src="../plugins/bootstrap-select/defaults-it_IT.min.js" type="text/javascript"></script>

    	 <script type="text/javascript"> 		
		
		$(function(){

			$("[data-toggle=popover]").popover({
				html : true,
				content: function() {
					var content = $(this).attr("data-popover-content");
					return $(content).children(".popover-body").html();
				},
				title: function() {
					var title = $(this).attr("data-popover-content");
					return $(title).children(".popover-heading").html();
				}
			});

		});
		
		 $('body').on('click', function (e) {
			$('[data-toggle="popover"]').each(function () {
				//the 'is' for buttons that trigger popups
				//the 'has' for icons within a button that triggers a popup
				if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
					$(this).popover('hide');
				}
			});
		});
		
	</script> 
    <script>
        /*
        * Replace all SVG images with inline SVG
        */
       jQuery('img.svg').each(function(){
               var $img = jQuery(this);
               var imgID = $img.attr('id');
               var imgClass = $img.attr('class');
               var imgURL = $img.attr('src');

               jQuery.get(imgURL, function(data) {
                       // Get the SVG tag, ignore the rest
                       var $svg = jQuery(data).find('svg');

                       // Add replaced image's ID to the new SVG
                       if(typeof imgID !== 'undefined') {
                               $svg = $svg.attr('id', imgID);
                       }
                       // Add replaced image's classes to the new SVG
                       if(typeof imgClass !== 'undefined') {
                               $svg = $svg.attr('class', imgClass+' replaced-svg');
                       }

                       // Remove any invalid XML tags as per http://validator.w3.org
                       $svg = $svg.removeAttr('xmlns:a');

                       // Check if the viewport is set, if the viewport is not set the SVG wont't scale.
                       if(!$svg.attr('viewBox') && $svg.attr('height') && $svg.attr('width')) {
                               $svg.attr('viewBox', '0 0 ' + $svg.attr('height') + ' ' + $svg.attr('width'))
                       }

                       // Replace image with new SVG
                       $img.replaceWith($svg);

               }, 'xml');

       });
	  
    </script>
    
    <!-- Password strength meter -->
    <script type="text/javascript" src="../plugins/password-strength-meter-1.1.0/dist/password.min.js"></script>
    <script type="text/javascript">
        jQuery(document).ready(function($) {
            $('#nuovaPassword').password({
              shortPass: '<span class="pwd-corta">La password è troppo corta, usa una password <strong>FORTE</strong> per scongiurare attacchi al tuo sito</span>',
              badPass: '<span class="pwd-insufficiente">Insufficiente. Prova a combinare lettere e numeri</span>',
              goodPass: '<span class="pwd-media">Media, aggiungi un carattere speciale per renderla più sicura</span>',
              strongPass: '<span class="pwd-forte">Password forte</span>',
              containsUsername: '<span class="pwd-corta">La tua password contiene lo username! Per motivi di sicurezza è bene sia diversa</span>',
              enterPass: '',
              showPercent: false,
              animate: false,
              minimumLength: 6,
            });
        });
    </script>