Attribute changed material-kit
[bootswatch] / material-kit / js / material-kit.js
1 /*!
2     
3  =========================================================
4  * Material Kit - v1.1.1.0
5  =========================================================
6  
7  * Product Page: http://www.creative-tim.com/product/material-kit
8  * Copyright 2017 Creative Tim (http://www.creative-tim.com)
9  * Licensed under MIT (https://github.com/timcreative/material-kit/blob/master/LICENSE.md)
10  
11  =========================================================
12  
13  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14  
15  */
16
17 var transparent = true;
18
19 var transparentDemo = true;
20 var fixedTop = false;
21
22 var navbar_initialized = false;
23
24 $(document).ready(function(){
25
26     // Init Material scripts for buttons ripples, inputs animations etc, more info on the next link https://github.com/FezVrasta/bootstrap-material-design#materialjs
27     $.material.init();
28
29     //  Activate the Tooltips
30     $('[data-toggle="tooltip"], [rel="tooltip"]').tooltip();
31
32     // Activate Datepicker
33     if($('.datepicker').length != 0){
34         $('.datepicker').datepicker({
35              weekStart:1
36         });
37     }
38
39     // Check if we have the class "navbar-color-on-scroll" then add the function to remove the class "navbar-transparent" so it will transform to a plain color.
40     if($('.navbar-color-on-scroll').length != 0){
41         $(window).on('scroll', materialKit.checkScrollForTransparentNavbar)
42     }
43
44     // Activate Popovers
45     $('[data-toggle="popover"]').popover();
46
47     // Active Carousel
48         $('.carousel').carousel({
49       interval: 400000
50     });
51
52 });
53
54 materialKit = {
55     misc:{
56         navbar_menu_visible: 0
57     },
58
59     checkScrollForTransparentNavbar: debounce(function() {
60             if($(document).scrollTop() > 260 ) {
61                 if(transparent) {
62                     transparent = false;
63                     $('.navbar-color-on-scroll').removeClass('navbar-transparent');
64                 }
65             } else {
66                 if( !transparent ) {
67                     transparent = true;
68                     $('.navbar-color-on-scroll').addClass('navbar-transparent');
69                 }
70             }
71     }, 17),
72
73     initSliders: function(){
74         // Sliders for demo purpose
75         $('#sliderRegular').noUiSlider({
76             start: 40,
77             connect: "lower",
78             range: {
79                 min: 0,
80                 max: 100
81             }
82         });
83
84         $('#sliderDouble').noUiSlider({
85             start: [20, 60] ,
86             connect: true,
87             range: {
88                 min: 0,
89                 max: 100
90             }
91         });
92     }
93 }
94
95
96 var big_image;
97
98 materialKitDemo = {
99     checkScrollForParallax: debounce(function(){
100         var current_scroll = $(this).scrollTop();
101
102         oVal = ($(window).scrollTop() / 3);
103         big_image.css({
104             'transform':'translate3d(0,' + oVal +'px,0)',
105             '-webkit-transform':'translate3d(0,' + oVal +'px,0)',
106             '-ms-transform':'translate3d(0,' + oVal +'px,0)',
107             '-o-transform':'translate3d(0,' + oVal +'px,0)'
108         });
109
110     }, 6)
111
112 }
113 // Returns a function, that, as long as it continues to be invoked, will not
114 // be triggered. The function will be called after it stops being called for
115 // N milliseconds. If `immediate` is passed, trigger the function on the
116 // leading edge, instead of the trailing.
117
118 function debounce(func, wait, immediate) {
119         var timeout;
120         return function() {
121                 var context = this, args = arguments;
122                 clearTimeout(timeout);
123                 timeout = setTimeout(function() {
124                         timeout = null;
125                         if (!immediate) func.apply(context, args);
126                 }, wait);
127                 if (immediate && !timeout) func.apply(context, args);
128         };
129 };