1
|
|
2
|
// variables
|
3
|
var $body = $('body'),
|
4
|
$html = $('html'),
|
5
|
$window = $(window),
|
6
|
$document = $(document),
|
7
|
$header_main = $('#header_main'),
|
8
|
header_main_height = $header_main.height(),
|
9
|
easing_swiftOut = [ 0.35,0,0.25,1 ];
|
10
|
bez_easing_swiftOut = $.bez(easing_swiftOut);
|
11
|
|
12
|
/* Detect hi-res devices */
|
13
|
function isHighDensity() {
|
14
|
return ((window.matchMedia && (window.matchMedia('only screen and (min-resolution: 124dpi), only screen and (min-resolution: 1.3dppx), only screen and (min-resolution: 48.8dpcm)').matches || window.matchMedia('only screen and (-webkit-min-device-pixel-ratio: 1.3), only screen and (-o-min-device-pixel-ratio: 2.6/2), only screen and (min--moz-device-pixel-ratio: 1.3), only screen and (min-device-pixel-ratio: 1.3)').matches)) || (window.devicePixelRatio && window.devicePixelRatio > 1.3));
|
15
|
}
|
16
|
|
17
|
/*
|
18
|
* Dynamically loading an external JavaScript or CSS file
|
19
|
* http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml
|
20
|
*/
|
21
|
function loadjscssfile(b,c){if("js"==c){var a=document.createElement("script");a.setAttribute("type","text/javascript");a.setAttribute("src",b)}else"css"==c&&(a=document.createElement("link"),a.setAttribute("rel","stylesheet"),a.setAttribute("type","text/css"),a.setAttribute("href",b));"undefined"!=typeof a&&document.getElementsByTagName("head")[0].appendChild(a)};
|
22
|
|
23
|
/* detect touch devices */
|
24
|
function isTouchDevice() {
|
25
|
return 'ontouchstart' in document.documentElement;
|
26
|
}
|
27
|
|
28
|
$(function() {
|
29
|
// header main
|
30
|
altair_header_main.init();
|
31
|
// inputs
|
32
|
altair_md.init();
|
33
|
});
|
34
|
|
35
|
$window.on('load',function () {
|
36
|
if(isHighDensity()) {
|
37
|
loadjscssfile("bower_components/dense/src/dense.js", "js");
|
38
|
// enable hires images
|
39
|
$('img').dense({
|
40
|
glue: "@"
|
41
|
});
|
42
|
}
|
43
|
if (isTouchDevice()) {
|
44
|
// fastClick (touch devices)
|
45
|
FastClick.attach(document.body);
|
46
|
}
|
47
|
|
48
|
});
|
49
|
|
50
|
altair_header_main = {
|
51
|
init: function () {
|
52
|
// sticky header
|
53
|
altair_header_main.sticky_header();
|
54
|
// main navigation
|
55
|
altair_header_main.main_navigation();
|
56
|
},
|
57
|
sticky_header: function () {
|
58
|
$body.addClass('header_sticky');
|
59
|
$(window).on("scroll touchmove", function () {
|
60
|
$body.toggleClass('header_shadow', $(document).scrollTop() > 0);
|
61
|
});
|
62
|
},
|
63
|
main_navigation: function() {
|
64
|
$('#main_navigation').onePageNav({
|
65
|
currentClass: 'current_active',
|
66
|
changeHash: false,
|
67
|
scrollSpeed: 840,
|
68
|
scrollThreshold: 0.4,
|
69
|
filter: '',
|
70
|
scrollOffset: -header_main_height,
|
71
|
easing: bez_easing_swiftOut,
|
72
|
begin: function() {
|
73
|
//Hack so you can click other menu items after the initial click (IOS)
|
74
|
//$('body').append('<div id="device-dummy" style="height: 1px;"></div>');
|
75
|
},
|
76
|
end: function() {
|
77
|
$('#device-dummy').remove();
|
78
|
},
|
79
|
scrollChange: function($currentListItem) {
|
80
|
//I get fired when you enter a section and I pass the list item of the section
|
81
|
}
|
82
|
});
|
83
|
|
84
|
}
|
85
|
};
|
86
|
|
87
|
altair_md = {
|
88
|
init: function () {
|
89
|
altair_md.inputs();
|
90
|
},
|
91
|
inputs: function(parent) {
|
92
|
var $mdInput = (typeof parent === 'undefined') ? $('.md-input') : $(parent).find('.md-input');
|
93
|
$mdInput.each(function() {
|
94
|
if(!$(this).closest('.md-input-wrapper').length) {
|
95
|
var $this = $(this),
|
96
|
extraClass = '';
|
97
|
|
98
|
if($this.is('[class*="uk-form-width-"]')) {
|
99
|
var elClasses = $this.attr('class').split (' ');
|
100
|
for(var i = 0; i < elClasses.length; i++){
|
101
|
var classPart = elClasses[i].substr(0,14);
|
102
|
if(classPart == "uk-form-width-"){
|
103
|
var extraClass = elClasses[i];
|
104
|
}
|
105
|
}
|
106
|
}
|
107
|
|
108
|
if( $this.prev('label').length ) {
|
109
|
$this.prev('label').andSelf().wrapAll('<div class="md-input-wrapper"/>');
|
110
|
} else if($this.siblings('[data-uk-form-password]').length) {
|
111
|
$this.siblings('[data-uk-form-password]').andSelf().wrapAll('<div class="md-input-wrapper"/>');
|
112
|
} else {
|
113
|
$this.wrap('<div class="md-input-wrapper"/>');
|
114
|
}
|
115
|
$this.closest('.md-input-wrapper').append('<span class="md-input-bar '+extraClass+'"/>');
|
116
|
|
117
|
altair_md.update_input($this);
|
118
|
}
|
119
|
$body
|
120
|
.on('focus', '.md-input', function() {
|
121
|
$(this).closest('.md-input-wrapper').addClass('md-input-focus')
|
122
|
})
|
123
|
.on('blur', '.md-input', function() {
|
124
|
$(this).closest('.md-input-wrapper').removeClass('md-input-focus');
|
125
|
if(!$(this).hasClass('label-fixed')) {
|
126
|
if($(this).val() != '') {
|
127
|
$(this).closest('.md-input-wrapper').addClass('md-input-filled')
|
128
|
} else {
|
129
|
$(this).closest('.md-input-wrapper').removeClass('md-input-filled')
|
130
|
}
|
131
|
}
|
132
|
})
|
133
|
.on('change', '.md-input', function() {
|
134
|
altair_md.update_input($(this));
|
135
|
});
|
136
|
})
|
137
|
},
|
138
|
update_input: function(object) {
|
139
|
// clear wrapper classes
|
140
|
object.closest('.uk-input-group').removeClass('uk-input-group-danger uk-input-group-success');
|
141
|
object.closest('.md-input-wrapper').removeClass('md-input-wrapper-danger md-input-wrapper-success md-input-wrapper-disabled');
|
142
|
|
143
|
if(object.hasClass('md-input-danger')) {
|
144
|
if(object.closest('.uk-input-group').length) {
|
145
|
object.closest('.uk-input-group').addClass('uk-input-group-danger')
|
146
|
}
|
147
|
object.closest('.md-input-wrapper').addClass('md-input-wrapper-danger')
|
148
|
}
|
149
|
if(object.hasClass('md-input-success')) {
|
150
|
if(object.closest('.uk-input-group').length) {
|
151
|
object.closest('.uk-input-group').addClass('uk-input-group-success')
|
152
|
}
|
153
|
object.closest('.md-input-wrapper').addClass('md-input-wrapper-success')
|
154
|
}
|
155
|
if(object.prop('disabled')) {
|
156
|
object.closest('.md-input-wrapper').addClass('md-input-wrapper-disabled')
|
157
|
}
|
158
|
if(object.hasClass('label-fixed')) {
|
159
|
object.closest('.md-input-wrapper').addClass('md-input-filled')
|
160
|
}
|
161
|
if(object.val() != '') {
|
162
|
object.closest('.md-input-wrapper').addClass('md-input-filled')
|
163
|
}
|
164
|
}
|
165
|
};
|