summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/WfextStyle/wikifab-style.js
blob: 809ddaf16f97b4d54d7d8d482d2c04d0e6787b4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

/*
$( document ).ready(function() {
    $(window).scroll(function(){
		// en haut : 
	    //$("#saving-menu").css("top",Math.max(0,250-$(this).scrollTop()));

		$originalPosition = Math.floor($('.footer-main').position().top - $(this).scrollTop());

		$movedPosition = $(this).height() - $('.saving-menu').outerHeight(true)  ;

	    // en bas :position:fixed
	    if($originalPosition < $movedPosition) {
		    $(".saving-menu").css("position",'relative');
		    $(".saving-menu").css("top","");
		    $(".saving-menu").css("margin-left",0);
		} else {
		    $(".saving-menu").css("position",'fixed');
		    $(".saving-menu").css("top",$movedPosition);
		    $(".saving-menu").css("margin-left",$("body").css("margin-left"));
		}
	});
});*/

$( document ).ready(function() {
	$('.file-3D').wrap("<div class='file-3D'></div>");
	$('<span>').addClass('stl-file').prependTo('div.file-3D');

	$('.videofile').wrap("<div class='videofile'></div>");
	$('<span>').addClass('mp4-file').prependTo('div.videofile');
});

// BACK TO TOP

// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function() {scrollFunction()};

function scrollFunction() {
    if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
        document.getElementById("backToTop").style.display = "block";
    } else {
        document.getElementById("backToTop").style.display = "none";
    }
}

// When the user clicks on the button, scroll to the top of the document
function topFunction() {
	$('body, html').stop().animate({scrollTop:0}, 500, 'swing', function() { 
	});
} 

// BACK TO TOP - END


// SMOOTH SCROLLING PAGE ANCHOR

$(function() {
    /**
    * Smooth scrolling to page anchor on click
    **/
    $(".smooth-scroll a[href*='#']:not([href='#'])").click(function() {
        if (
            location.hostname == this.hostname
            && this.pathname.replace(/^\//,"") == location.pathname.replace(/^\//,"")
        ) {
            var anchor = $(this.hash);
            anchor = anchor.length ? anchor : $("[name=" + this.hash.slice(1) +"]");
            if ( anchor.length ) {
                $("html, body").animate( { scrollTop: anchor.offset().top }, 800);
            }
        }
    });
});

// SMOOTH SCROLLING PAGE ANCHOR - END

// LOGIN POPUP ON CLICK ON EDIT BUTTON (Not logged in)

(function() {
	$( document ).ready(function() {
		$('#ca-edit a, #ca-formedit a').click(function(e){
			if (! mw.config.get('wgUserId')) {
				e.preventDefault();
				displayModal();
				return;
			}
		});
	});

	function displayModal() {
		$( "#connectionRequiredModal" ).modal();
	}
})();
	
// LOGIN POPUP ON CLICK ON EDIT BUTTON - END


$('body').on('click.collapse-next.data-api', '[data-toggle=collapse-next]', function (e) {
  var $target = $(this).next(".collapse");
  $target.data('bs.collapse') ? $target.collapse('toggle') : $target.collapse();
})