-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomscript.js
374 lines (344 loc) · 11.6 KB
/
customscript.js
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
// menu dropdown link clickable
jQuery( document ).ready( function ( $ ) {
$( '.navbar .dropdown > a, .dropdown-menu > li > a' ).click( function () {
location.href = this.href;
} );
} );
// scroll to top button
jQuery( document ).ready( function ( $ ) {
$( "#back-top" ).hide();
$( function () {
$( window ).scroll( function () {
if ( $( this ).scrollTop() > 100 ) {
$( '#back-top' ).fadeIn();
} else {
$( '#back-top' ).fadeOut();
}
} );
// scroll body to 0px on click
$( '#back-top a' ).click( function () {
$( 'body,html' ).animate( {
scrollTop: 0
}, 800 );
return false;
} );
} );
} );
// Smart sidebar
jQuery( document ).ready( function ( $ ) {
if ( $( "aside" ).hasClass( "td-sticky" ) ) {
$( 'aside.td-sticky' ).hcSticky( {
top: 80,
offResolutions: -975,
} );
}
} );
// Ad banner in single post
jQuery( document ).ready( function ( $ ) {
if ( $( ".entry-content .sticky-ad" ).hasClass( "td-sticky" ) ) {
$( '.entry-content .td-sticky' ).hcSticky( {
top: 20,
offResolutions: -975,
} );
}
} );
// Content slider in single post
jQuery( document ).ready( function ( $ ) {
var myDiv = document.getElementById( 'custom-box' );
if ( myDiv ) {
$( window ).scroll( function () {
var distanceTop = $( '#custom-box' ).offset().top - $( window ).height();
if ( $( window ).scrollTop() > distanceTop )
$( '#slidebox' ).animate( { 'right': '0px' }, 300 );
else
$( '#slidebox' ).stop( true ).animate( { 'right': '-430px' }, 100 );
} );
$( '#slidebox .close-me' ).bind( 'click', function () {
$( this ).parent().remove();
} );
}
;
} );
//smoothscroll
jQuery( document ).ready( function ( $ ) {
var sections = $( 'section' )
, nav = $( '#main-navigation-inner .nav' )
, nav_height = nav.outerHeight();
$( window ).on( 'scroll', function () {
var cur_pos = $( this ).scrollTop();
sections.each( function () {
var top = $( this ).offset().top - nav_height,
bottom = top + $( this ).outerHeight();
if ( cur_pos >= top && cur_pos <= bottom ) {
nav.find( 'a' ).removeClass( 'active' );
sections.removeClass( 'active' );
$( this ).addClass( 'active' );
nav.find( 'a[href="#' + $( this ).attr( 'id' ) + '"]' ).addClass( 'active' );
}
} );
} );
nav.find( 'a' ).on( 'click', function () {
var $el = $( this )
, id = $el.attr( 'href' );
$( 'html, body' ).animate( {
scrollTop: $( id ).offset().top - nav_height + 50
}, 500 );
return false;
} );
} );
// FlexSlider
jQuery( document ).ready( function ( $ ) {
$( window ).load( function () {
var animation = $( '.homepage-slider' ).data( 'animation' );
var interval = $( '.homepage-slider' ).data( 'interval' );
$( '.homepage-slider' ).flexslider( {
animation: animation,
slideshow: true,
slideshowSpeed: interval,
touch: true,
keyboard: true,
pauseOnHover: true,
prevText: '',
nextText: '',
} );
} );
} );
// FlexSlider Carousel
jQuery( document ).ready( function ( $ ) {
var $window = $( window ),
flexslider;
// tiny helper function to add breakpoints
var columns = $( '#carousel-home' ).data( 'columns' );
function getGridSize() {
return ( window.innerWidth < 520 ) ? 1 :
( window.innerWidth < 768 ) ? 2 :
( window.innerWidth < 1028 ) ? 3 : columns;
}
$( window ).load( function () {
var interval = $( '#carousel-home' ).data( 'interval' );
var start = $( '#carousel-home' ).data( 'start' );
var loop = $( '#carousel-home' ).data( 'loop' );
$( '#carousel-home' ).flexslider( {
animation: "slide",
controlNav: false,
slideshowSpeed: interval,
animationLoop: loop,
slideshow: start,
itemWidth: 330,
itemMargin: 30,
prevText: '',
nextText: '',
minItems: getGridSize(),
maxItems: getGridSize(),
start: function ( slider ) {
flexslider = slider;
slider.removeClass( 'carousel-loading' );
}
} );
$window.resize( function () {
var gridSize = getGridSize();
if ( flexslider ) {
flexslider.vars.minItems = gridSize;
flexslider.vars.maxItems = gridSize;
}
} );
} );
// set the timeout for the slider resize
$( function () {
var resizeEnd;
$( window ).on( 'resize', function () {
clearTimeout( resizeEnd );
resizeEnd = setTimeout( function () {
flexsliderResize();
}, 100 );
} );
} );
function flexsliderResize() {
if ( $( '#carousel-home' ).length > 0 ) {
$( '#carousel-home' ).data( 'flexslider' ).resize();
}
}
} );
// Brand logos Carousel
jQuery( document ).ready( function ( $ ) {
var $window = $( window ),
flexslider;
// tiny helper function to add breakpoints
var columns = $( '#logo-home' ).data( 'columns' );
function getGridSize() {
return ( window.innerWidth < 320 ) ? 1 :
( window.innerWidth < 668 ) ? 2 :
( window.innerWidth < 1028 ) ? 3 : columns;
}
$( window ).load( function () {
var interval = $( '#logo-home' ).data( 'interval' );
var start = $( '#logo-home' ).data( 'start' );
var loop = $( '#logo-home' ).data( 'loop' );
var loop = $( '#logo-home' ).data( 'columns' );
$( '#logo-home' ).flexslider( {
animation: "slide",
controlNav: false,
slideshowSpeed: interval,
animationLoop: loop,
slideshow: start,
itemWidth: 128,
itemMargin: 50,
prevText: '',
nextText: '',
minItems: getGridSize(),
maxItems: getGridSize(),
start: function ( slider ) {
flexslider = slider;
slider.removeClass( 'carousel-loading' );
}
} );
$window.resize( function () {
var gridSize = getGridSize();
if ( flexslider ) {
flexslider.vars.minItems = gridSize;
flexslider.vars.maxItems = gridSize;
}
} );
} );
// set the timeout for the slider resize
$( function () {
var resizeEnd;
$( window ).on( 'resize', function () {
clearTimeout( resizeEnd );
resizeEnd = setTimeout( function () {
flexsliderResize();
}, 100 );
} );
} );
function flexsliderResize() {
if ( $( '#logo-home' ).length > 0 ) {
$( '#logo-home' ).data( 'flexslider' ).resize();
}
}
} );
// Border effects
jQuery( document ).ready( function ( $ ) {
$( window ).on( 'resize', function ( ) {
$( ".border-top" ).css( { "border-left-width": window.innerWidth } );
$( ".border-bottom" ).css( { "border-right-width": window.innerWidth } );
} ).trigger( 'resize' );
} );
// Intro parallax effect
jQuery( document ).ready( function ( $ ) {
var ua = navigator.userAgent,
isMobileWebkit = /WebKit/.test( ua ) && /Mobile/.test( ua );
if ( isMobileWebkit && $( 'body' ).hasClass( 'parallax-mobile-off' ) ) {
$( '.img-holder' ).imageScroll( {
coverRatio: 1,
parallax: false,
} );
} else {
$( '.img-holder' ).imageScroll( {
coverRatio: 1,
speed: 0.4,
extraHeight: 120,
} );
}
var counter = 15;
$( '.imageHolder' ).each( function ( ) {
$( this ).css( 'z-index', counter );
counter--;
} );
} );
// Smooth scroll effect
jQuery( document ).ready( function ( $ ) {
if ( $( 'body' ).hasClass( 'smooth-scroll-on' ) ) {
if ( window.addEventListener )
window.addEventListener( 'DOMMouseScroll', wheel, false );
window.onmousewheel = document.onmousewheel = wheel;
function wheel( event ) {
var delta = 0;
if ( event.wheelDelta )
delta = event.wheelDelta / 80;
else if ( event.detail )
delta = -event.detail / 3;
handle( delta );
if ( event.preventDefault )
event.preventDefault();
event.returnValue = false;
}
var goUp = true;
var end = null;
var interval = null;
function handle( delta ) {
var animationInterval = 7; //lower is faster
var scrollSpeed = 7; //lower is faster
if ( end == null ) {
end = $( window ).scrollTop();
}
end -= 20 * delta;
goUp = delta > 0;
if ( interval == null ) {
interval = setInterval( function () {
var scrollTop = $( window ).scrollTop();
var step = Math.round( ( end - scrollTop ) / scrollSpeed );
if ( scrollTop <= 0 ||
scrollTop >= $( window ).prop( "scrollHeight" ) - $( window ).height() ||
goUp && step > -1 ||
!goUp && step < 1 ) {
clearInterval( interval );
interval = null;
end = null;
}
$( window ).scrollTop( scrollTop + step );
}, animationInterval );
}
}
}
} );
// Portfolio isotope
jQuery( document ).ready( function ( $ ) {
var $container = $( '#portfolio' );
if ( $container.length ) {
// init Isotope
var $grid = $( '#portfolio' ).imagesLoaded( function () {
$grid.isotope();
} );
// filter items when filter link is clicked
$( '#filter a' ).click( function () {
var selector = $( this ).attr( 'data-filter' );
$container.isotope( { filter: selector } );
return false;
} );
}
} );
// Tooltip
jQuery( document ).ready( function ( $ ) {
$( '[data-toggle="tooltip"]' ).tooltip();
} );
// Sections animations
jQuery( document ).ready( function ( $ ) {
$( '.homepage-section' ).each( function ( ind ) {
var animation = jQuery( this ).attr( 'data-animation' );
var id = jQuery( this ).attr( 'data-id' );
jQuery( '#' + id + ' .container' ).addClass( "bt_hidden" ).viewportChecker( {
classToAdd: animation,
offset: 10,
repeat: false,
callbackFunction: function ( elem, action ) {},
scrollHorizontal: false
} );
} );
} );
// Youtube Player
jQuery( window ).ready( function ( $ ) {
$( '.homepage-section.video-bg' ).each( function ( ) {
if ( $( this ).attr( 'data-video' ) ) {
var id = $( this ).attr( 'data-id' );
var videoID = $( this ).attr( 'data-video' );
var sections = $( '#' + id + '.video-bg' );
if ( sections.length ) {
$( '#' + id + ' .prlx' ).YTPlayer( {
fitToBackground: true,
videoId: videoID,
pauseOnScroll: false,
} );
}
}
} );
} );