-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbundle.js
1259 lines (1061 loc) · 39 KB
/
bundle.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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*!
* Lazy Load - jQuery plugin for lazy loading images
*
* Copyright (c) 2007-2015 Mika Tuupola
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Project home:
* http://www.appelsiini.net/projects/lazyload
*
* Version: 1.9.7
*
*/
(function($, window, document, undefined) {
var $window = $(window);
$.fn.lazyload = function(options) {
var elements = this;
var $container;
var settings = {
threshold : 0,
failure_limit : 0,
event : "scroll",
effect : "show",
container : window,
data_attribute : "original",
skip_invisible : false,
appear : null,
load : null,
placeholder : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC"
};
function update() {
var counter = 0;
elements.each(function() {
var $this = $(this);
if (settings.skip_invisible && !$this.is(":visible")) {
return;
}
if ($.abovethetop(this, settings) ||
$.leftofbegin(this, settings)) {
/* Nothing. */
} else if (!$.belowthefold(this, settings) &&
!$.rightoffold(this, settings)) {
$this.trigger("appear");
/* if we found an image we'll load, reset the counter */
counter = 0;
} else {
if (++counter > settings.failure_limit) {
return false;
}
}
});
}
if(options) {
/* Maintain BC for a couple of versions. */
if (undefined !== options.failurelimit) {
options.failure_limit = options.failurelimit;
delete options.failurelimit;
}
if (undefined !== options.effectspeed) {
options.effect_speed = options.effectspeed;
delete options.effectspeed;
}
$.extend(settings, options);
}
/* Cache container as jQuery as object. */
$container = (settings.container === undefined ||
settings.container === window) ? $window : $(settings.container);
/* Fire one scroll event per scroll. Not one scroll event per image. */
if (0 === settings.event.indexOf("scroll")) {
$container.bind(settings.event, function() {
return update();
});
}
this.each(function() {
var self = this;
var $self = $(self);
self.loaded = false;
/* If no src attribute given use data:uri. */
if ($self.attr("src") === undefined || $self.attr("src") === false) {
if ($self.is("img")) {
$self.attr("src", settings.placeholder);
}
}
/* When appear is triggered load original image. */
$self.one("appear", function() {
if (!this.loaded) {
if (settings.appear) {
var elements_left = elements.length;
settings.appear.call(self, elements_left, settings);
}
$("<img />")
.bind("load", function() {
var original = $self.attr("data-" + settings.data_attribute);
$self.hide();
if ($self.is("img")) {
$self.attr("src", original);
} else {
$self.css("background-image", "url('" + original + "')");
}
$self[settings.effect](settings.effect_speed);
self.loaded = true;
/* Remove image from array so it is not looped next time. */
var temp = $.grep(elements, function(element) {
return !element.loaded;
});
elements = $(temp);
if (settings.load) {
var elements_left = elements.length;
settings.load.call(self, elements_left, settings);
}
})
.attr("src", $self.attr("data-" + settings.data_attribute));
}
});
/* When wanted event is triggered load original image */
/* by triggering appear. */
if (0 !== settings.event.indexOf("scroll")) {
$self.bind(settings.event, function() {
if (!self.loaded) {
$self.trigger("appear");
}
});
}
});
/* Check if something appears when window is resized. */
$window.bind("resize", function() {
update();
});
/* With IOS5 force loading images when navigating with back button. */
/* Non optimal workaround. */
if ((/(?:iphone|ipod|ipad).*os 5/gi).test(navigator.appVersion)) {
$window.bind("pageshow", function(event) {
if (event.originalEvent && event.originalEvent.persisted) {
elements.each(function() {
$(this).trigger("appear");
});
}
});
}
/* Force initial check if images should appear. */
$(document).ready(function() {
update();
});
return this;
};
/* Convenience methods in jQuery namespace. */
/* Use as $.belowthefold(element, {threshold : 100, container : window}) */
$.belowthefold = function(element, settings) {
var fold;
if (settings.container === undefined || settings.container === window) {
fold = (window.innerHeight ? window.innerHeight : $window.height()) + $window.scrollTop();
} else {
fold = $(settings.container).offset().top + $(settings.container).height();
}
return fold <= $(element).offset().top - settings.threshold;
};
$.rightoffold = function(element, settings) {
var fold;
if (settings.container === undefined || settings.container === window) {
fold = $window.width() + $window.scrollLeft();
} else {
fold = $(settings.container).offset().left + $(settings.container).width();
}
return fold <= $(element).offset().left - settings.threshold;
};
$.abovethetop = function(element, settings) {
var fold;
if (settings.container === undefined || settings.container === window) {
fold = $window.scrollTop();
} else {
fold = $(settings.container).offset().top;
}
return fold >= $(element).offset().top + settings.threshold + $(element).height();
};
$.leftofbegin = function(element, settings) {
var fold;
if (settings.container === undefined || settings.container === window) {
fold = $window.scrollLeft();
} else {
fold = $(settings.container).offset().left;
}
return fold >= $(element).offset().left + settings.threshold + $(element).width();
};
$.inviewport = function(element, settings) {
return !$.rightoffold(element, settings) && !$.leftofbegin(element, settings) &&
!$.belowthefold(element, settings) && !$.abovethetop(element, settings);
};
/* Custom selectors for your convenience. */
/* Use as $("img:below-the-fold").something() or */
/* $("img").filter(":below-the-fold").something() which is faster */
$.extend($.expr[":"], {
"below-the-fold" : function(a) { return $.belowthefold(a, {threshold : 0}); },
"above-the-top" : function(a) { return !$.belowthefold(a, {threshold : 0}); },
"right-of-screen": function(a) { return $.rightoffold(a, {threshold : 0}); },
"left-of-screen" : function(a) { return !$.rightoffold(a, {threshold : 0}); },
"in-viewport" : function(a) { return $.inviewport(a, {threshold : 0}); },
/* Maintain BC for couple of versions. */
"above-the-fold" : function(a) { return !$.belowthefold(a, {threshold : 0}); },
"right-of-fold" : function(a) { return $.rightoffold(a, {threshold : 0}); },
"left-of-fold" : function(a) { return !$.rightoffold(a, {threshold : 0}); }
});
})(jQuery, window, document);
;
/* global NexT, CONFIG */
NexT.utils = NexT.$u = {
/**
* Wrap images with fancybox support.
*/
wrapImageWithFancyBox: function() {
$('.content img')
.not('[hidden]')
.not('.group-picture img, .post-gallery img')
.each(function() {
var $image = $(this);
var imageTitle = $image.attr('title');
var $imageWrapLink = $image.parent('a');
if ($imageWrapLink.length < 1) {
var imageLink = $image.attr('data-original') ? this.getAttribute('data-original') : this.getAttribute('src');
$imageWrapLink = $image.wrap('<a data-fancybox="group" href="' + imageLink + '"></a>').parent('a');
}
$imageWrapLink.addClass('fancybox fancybox.image');
$imageWrapLink.attr('rel', 'group');
if (imageTitle) {
$imageWrapLink.append('<p class="image-caption">' + imageTitle + '</p>');
//make sure img title tag will show correctly in fancybox
$imageWrapLink.attr('title', imageTitle);
}
});
$('.fancybox').fancybox({
helpers: {
overlay: {
locked: false
}
}
});
},
lazyLoadPostsImages: function() {
$('#posts').find('img').lazyload({
//placeholder: '/images/loading.gif',
effect : 'fadeIn',
threshold: 0
});
},
/**
* Tabs tag listener (without twitter bootstrap).
*/
registerTabsTag: function() {
var tNav = '.tabs ul.nav-tabs ';
// Binding `nav-tabs` & `tab-content` by real time permalink changing.
$(function() {
$(window).bind('hashchange', function() {
var tHash = location.hash;
if (tHash !== '') {
$(tNav + 'li:has(a[href="' + tHash + '"])').addClass('active').siblings().removeClass('active');
$(tHash).addClass('active').siblings().removeClass('active');
}
}).trigger('hashchange');
});
$(tNav + '.tab').on('click', function(href) {
href.preventDefault();
// Prevent selected tab to select again.
if (!$(this).hasClass('active')) {
// Add & Remove active class on `nav-tabs` & `tab-content`.
$(this).addClass('active').siblings().removeClass('active');
var tActive = $(this).find('a').attr('href');
$(tActive).addClass('active').siblings().removeClass('active');
// Clear location hash in browser if #permalink exists.
if (location.hash !== '') {
history.pushState('', document.title, window.location.pathname + window.location.search);
}
}
});
},
registerESCKeyEvent: function() {
$(document).on('keyup', function(event) {
var shouldDismissSearchPopup = event.which === 27
&& $('.search-popup').is(':visible');
if (shouldDismissSearchPopup) {
$('.search-popup').hide();
$('.search-popup-overlay').remove();
$('body').css('overflow', '');
}
});
},
registerBackToTop: function() {
var THRESHOLD = 50;
var $top = $('.back-to-top');
$(window).on('scroll', function() {
$top.toggleClass('back-to-top-on', window.pageYOffset > THRESHOLD);
var scrollTop = $(window).scrollTop();
var contentVisibilityHeight = NexT.utils.getContentVisibilityHeight();
var scrollPercent = scrollTop / contentVisibilityHeight;
var scrollPercentRounded = Math.round(scrollPercent * 100);
var scrollPercentMaxed = scrollPercentRounded > 100 ? 100 : scrollPercentRounded;
$('#scrollpercent>span').html(scrollPercentMaxed);
});
$top.on('click', function() {
$('body').velocity('scroll');
});
},
/**
* Transform embedded video to support responsive layout.
* @see http://toddmotto.com/fluid-and-responsive-youtube-and-vimeo-videos-with-fluidvids-js/
*/
embeddedVideoTransformer: function() {
var $iframes = $('iframe');
// Supported Players. Extend this if you need more players.
var SUPPORTED_PLAYERS = [
'www.youtube.com',
'player.vimeo.com',
'player.youku.com',
'music.163.com',
'www.tudou.com'
];
var pattern = new RegExp(SUPPORTED_PLAYERS.join('|'));
function getDimension($element) {
return {
width : $element.width(),
height: $element.height()
};
}
function getAspectRadio(width, height) {
return height / width * 100;
}
$iframes.each(function() {
var iframe = this;
var $iframe = $(this);
var oldDimension = getDimension($iframe);
var newDimension;
if (this.src.search(pattern) > 0) {
// Calculate the video ratio based on the iframe's w/h dimensions
var videoRatio = getAspectRadio(oldDimension.width, oldDimension.height);
// Replace the iframe's dimensions and position the iframe absolute
// This is the trick to emulate the video ratio
$iframe.width('100%').height('100%')
.css({
position: 'absolute',
top : '0',
left : '0'
});
// Wrap the iframe in a new <div> which uses a dynamically fetched padding-top property
// based on the video's w/h dimensions
var wrap = document.createElement('div');
wrap.className = 'fluid-vids';
wrap.style.position = 'relative';
wrap.style.marginBottom = '20px';
wrap.style.width = '100%';
wrap.style.paddingTop = videoRatio + '%';
// Fix for appear inside tabs tag.
(wrap.style.paddingTop === '') && (wrap.style.paddingTop = '50%');
// Add the iframe inside our newly created <div>
var iframeParent = iframe.parentNode;
iframeParent.insertBefore(wrap, iframe);
wrap.appendChild(iframe);
// Additional adjustments for 163 Music
if (this.src.search('music.163.com') > 0) {
newDimension = getDimension($iframe);
var shouldRecalculateAspect = newDimension.width > oldDimension.width
|| newDimension.height < oldDimension.height;
// 163 Music Player has a fixed height, so we need to reset the aspect radio
if (shouldRecalculateAspect) {
wrap.style.paddingTop = getAspectRadio(newDimension.width, oldDimension.height) + '%';
}
}
}
});
},
hasMobileUA: function() {
var nav = window.navigator;
var ua = nav.userAgent;
var pa = /iPad|iPhone|Android|Opera Mini|BlackBerry|webOS|UCWEB|Blazer|PSP|IEMobile|Symbian/g;
return pa.test(ua);
},
isTablet: function() {
return window.screen.width < 992 && window.screen.width > 767 && this.hasMobileUA();
},
isMobile: function() {
return window.screen.width < 767 && this.hasMobileUA();
},
isDesktop: function() {
return !this.isTablet() && !this.isMobile();
},
/**
* Escape meta symbols in jQuery selectors.
*
* @param selector
* @returns {string|void|XML|*}
*/
escapeSelector: function(selector) {
return selector.replace(/[!"$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g, '\\$&');
},
displaySidebar: function() {
if (!this.isDesktop() || this.isPisces() || this.isGemini()) {
return;
}
$('.sidebar-toggle').trigger('click');
},
isMist: function() {
return CONFIG.scheme === 'Mist';
},
isPisces: function() {
return CONFIG.scheme === 'Pisces';
},
isGemini: function() {
return CONFIG.scheme === 'Gemini';
},
getScrollbarWidth: function() {
var $div = $('<div />').addClass('scrollbar-measure').prependTo('body');
var div = $div[0];
var scrollbarWidth = div.offsetWidth - div.clientWidth;
$div.remove();
return scrollbarWidth;
},
getContentVisibilityHeight: function() {
var docHeight = $('#content').height();
var winHeight = $(window).height();
var contentVisibilityHeight = docHeight > winHeight ? docHeight - winHeight : $(document).height() - winHeight;
return contentVisibilityHeight;
},
getSidebarb2tHeight: function() {
//var sidebarb2tHeight = (CONFIG.sidebar.b2t) ? document.getElementsByClassName('back-to-top')[0].clientHeight : 0;
var sidebarb2tHeight = CONFIG.sidebar.b2t ? $('.back-to-top').height() : 0;
return sidebarb2tHeight;
},
getSidebarSchemePadding: function() {
var sidebarNavHeight = $('.sidebar-nav').css('display') === 'block' ? $('.sidebar-nav').outerHeight(true) : 0;
var sidebarInner = $('.sidebar-inner');
var sidebarPadding = sidebarInner.innerWidth() - sidebarInner.width();
var sidebarSchemePadding = this.isPisces() || this.isGemini()
? (sidebarPadding * 2) + sidebarNavHeight + (CONFIG.sidebar.offset * 2) + this.getSidebarb2tHeight()
: (sidebarPadding * 2) + (sidebarNavHeight / 2);
return sidebarSchemePadding;
}
};
$(document).ready(function() {
/**
* Init Sidebar & TOC inner dimensions on all pages and for all schemes.
* Need for Sidebar/TOC inner scrolling if content taller then viewport.
*/
function updateSidebarHeight(height) {
height = height || 'auto';
$('.site-overview, .post-toc').css('max-height', height);
}
function initSidebarDimension() {
var updateSidebarHeightTimer;
$(window).on('resize', function() {
updateSidebarHeightTimer && clearTimeout(updateSidebarHeightTimer);
updateSidebarHeightTimer = setTimeout(function() {
var sidebarWrapperHeight = document.body.clientHeight - NexT.utils.getSidebarSchemePadding();
updateSidebarHeight(sidebarWrapperHeight);
}, 0);
});
// Initialize Sidebar & TOC Width.
var scrollbarWidth = NexT.utils.getScrollbarWidth();
if ($('.site-overview-wrap').height() > (document.body.clientHeight - NexT.utils.getSidebarSchemePadding())) {
$('.site-overview').css('width', 'calc(100% + ' + scrollbarWidth + 'px)');
}
if ($('.post-toc-wrap').height() > (document.body.clientHeight - NexT.utils.getSidebarSchemePadding())) {
$('.post-toc').css('width', 'calc(100% + ' + scrollbarWidth + 'px)');
}
// Initialize Sidebar & TOC Height.
updateSidebarHeight(document.body.clientHeight - NexT.utils.getSidebarSchemePadding());
}
initSidebarDimension();
});
;
/* global NexT, CONFIG */
$(document).ready(function() {
NexT.motion = {};
var sidebarToggleLines = {
lines: [],
push : function(line) {
this.lines.push(line);
},
init: function() {
this.lines.forEach(function(line) {
line.init();
});
},
arrow: function() {
this.lines.forEach(function(line) {
line.arrow();
});
},
close: function() {
this.lines.forEach(function(line) {
line.close();
});
}
};
function SidebarToggleLine(settings) {
this.el = $(settings.el);
this.status = $.extend({}, {
init: {
width : '100%',
opacity: 1,
left : 0,
rotateZ: 0,
top : 0
}
}, settings.status);
}
SidebarToggleLine.prototype.init = function() {
this.transform('init');
};
SidebarToggleLine.prototype.arrow = function() {
this.transform('arrow');
};
SidebarToggleLine.prototype.close = function() {
this.transform('close');
};
SidebarToggleLine.prototype.transform = function(status) {
this.el.velocity('stop').velocity(this.status[status]);
};
var sidebarToggleLine1st = new SidebarToggleLine({
el : '.sidebar-toggle-line-first',
status: {
arrow: {width: '50%', rotateZ: '-45deg', top: '2px'},
close: {width: '100%', rotateZ: '-45deg', top: '5px'}
}
});
var sidebarToggleLine2nd = new SidebarToggleLine({
el : '.sidebar-toggle-line-middle',
status: {
arrow: {width: '90%'},
close: {opacity: 0}
}
});
var sidebarToggleLine3rd = new SidebarToggleLine({
el : '.sidebar-toggle-line-last',
status: {
arrow: {width: '50%', rotateZ: '45deg', top: '-2px'},
close: {width: '100%', rotateZ: '45deg', top: '-5px'}
}
});
sidebarToggleLines.push(sidebarToggleLine1st);
sidebarToggleLines.push(sidebarToggleLine2nd);
sidebarToggleLines.push(sidebarToggleLine3rd);
var SIDEBAR_WIDTH = CONFIG.sidebar.width ? CONFIG.sidebar.width : '320px';
var SIDEBAR_DISPLAY_DURATION = 200;
var xPos, yPos;
var sidebarToggleMotion = {
toggleEl : $('.sidebar-toggle'),
dimmerEl : $('#sidebar-dimmer'),
sidebarEl : $('.sidebar'),
isSidebarVisible: false,
init : function() {
this.toggleEl.on('click', this.clickHandler.bind(this));
this.dimmerEl.on('click', this.clickHandler.bind(this));
this.toggleEl.on('mouseenter', this.mouseEnterHandler.bind(this));
this.toggleEl.on('mouseleave', this.mouseLeaveHandler.bind(this));
this.sidebarEl.on('touchstart', this.touchstartHandler.bind(this));
this.sidebarEl.on('touchend', this.touchendHandler.bind(this));
this.sidebarEl.on('touchmove', function(e) { e.preventDefault(); });
$(document)
.on('sidebar.isShowing', function() {
NexT.utils.isDesktop() && $('body').velocity('stop').velocity(
{paddingRight: SIDEBAR_WIDTH},
SIDEBAR_DISPLAY_DURATION
);
})
.on('sidebar.isHiding', function() {
});
},
clickHandler: function() {
this.isSidebarVisible ? this.hideSidebar() : this.showSidebar();
this.isSidebarVisible = !this.isSidebarVisible;
},
mouseEnterHandler: function() {
if (this.isSidebarVisible) {
return;
}
sidebarToggleLines.arrow();
},
mouseLeaveHandler: function() {
if (this.isSidebarVisible) {
return;
}
sidebarToggleLines.init();
},
touchstartHandler: function(e) {
xPos = e.originalEvent.touches[0].clientX;
yPos = e.originalEvent.touches[0].clientY;
},
touchendHandler: function(e) {
var _xPos = e.originalEvent.changedTouches[0].clientX;
var _yPos = e.originalEvent.changedTouches[0].clientY;
if (_xPos - xPos > 30 && Math.abs(_yPos - yPos) < 20) {
this.clickHandler();
}
},
showSidebar: function() {
var self = this;
sidebarToggleLines.close();
this.sidebarEl.velocity('stop').velocity({
width: SIDEBAR_WIDTH
}, {
display : 'block',
duration: SIDEBAR_DISPLAY_DURATION,
begin : function() {
$('.sidebar .motion-element').velocity(
'transition.slideRightIn',
{
stagger : 50,
drag : true,
complete: function() {
self.sidebarEl.trigger('sidebar.motion.complete');
}
}
);
},
complete: function() {
self.sidebarEl.addClass('sidebar-active');
self.sidebarEl.trigger('sidebar.didShow');
}
}
);
this.sidebarEl.trigger('sidebar.isShowing');
},
hideSidebar: function() {
NexT.utils.isDesktop() && $('body').velocity('stop').velocity({paddingRight: 0});
this.sidebarEl.find('.motion-element').velocity('stop').css('display', 'none');
this.sidebarEl.velocity('stop').velocity({width: 0}, {display: 'none'});
sidebarToggleLines.init();
this.sidebarEl.removeClass('sidebar-active');
this.sidebarEl.trigger('sidebar.isHiding');
// Prevent adding TOC to Overview if Overview was selected when close & open sidebar.
if (!$('.post-toc-wrap')) {
if ($('.site-overview-wrap').css('display') === 'block') {
$('.post-toc-wrap').removeClass('motion-element');
} else {
$('.post-toc-wrap').addClass('motion-element');
}
}
}
};
sidebarToggleMotion.init();
NexT.motion.integrator = {
queue : [],
cursor: -1,
add : function(fn) {
this.queue.push(fn);
return this;
},
next: function() {
this.cursor++;
var fn = this.queue[this.cursor];
$.isFunction(fn) && fn(NexT.motion.integrator);
},
bootstrap: function() {
this.next();
}
};
NexT.motion.middleWares = {
logo: function(integrator) {
var sequence = [];
var $brand = $('.brand');
var $title = $('.site-title');
var $subtitle = $('.site-subtitle');
var $logoLineTop = $('.logo-line-before i');
var $logoLineBottom = $('.logo-line-after i');
$brand.length > 0 && sequence.push({
e: $brand,
p: {opacity: 1},
o: {duration: 200}
});
/**
* Check if $elements exist.
* @param {jQuery|Array} $elements
* @returns {boolean}
*/
function hasElement($elements) {
$elements = Array.isArray($elements) ? $elements : [$elements];
return $elements.every(function($element) {
return $element.length > 0;
});
}
function getMistLineSettings(element, translateX) {
return {
e: $(element),
p: {translateX: translateX},
o: {
duration : 500,
sequenceQueue: false
}
};
}
NexT.utils.isMist() && hasElement([$logoLineTop, $logoLineBottom])
&& sequence.push(
getMistLineSettings($logoLineTop, '100%'),
getMistLineSettings($logoLineBottom, '-100%')
);
hasElement($title) && sequence.push({
e: $title,
p: {opacity: 1, top: 0},
o: { duration: 200 }
});
hasElement($subtitle) && sequence.push({
e: $subtitle,
p: {opacity: 1, top: 0},
o: {duration: 200}
});
if (CONFIG.motion.async) {
integrator.next();
}
if (sequence.length > 0) {
sequence[sequence.length - 1].o.complete = function() {
integrator.next();
};
/* eslint-disable */
$.Velocity.RunSequence(sequence);
/* eslint-enable */
} else {
integrator.next();
}
},
menu: function(integrator) {
if (CONFIG.motion.async) {
integrator.next();
}
$('.menu-item').velocity('transition.slideDownIn', {
display : null,
duration: 200,
complete: function() {
integrator.next();
}
});
},
postList: function(integrator) {
//var $post = $('.post');
var $postBlock = $('.post-block, .pagination, .comments');
var $postBlockTransition = CONFIG.motion.transition.post_block;
var $postHeader = $('.post-header');
var $postHeaderTransition = CONFIG.motion.transition.post_header;
var $postBody = $('.post-body');
var $postBodyTransition = CONFIG.motion.transition.post_body;
var $collHeader = $('.collection-title, .archive-year');
var $collHeaderTransition = CONFIG.motion.transition.coll_header;
var $sidebarAffix = $('.sidebar-inner');
var $sidebarAffixTransition = CONFIG.motion.transition.sidebar;
var hasPost = $postBlock.length > 0;
function postMotion() {
var postMotionOptions = window.postMotionOptions || {
stagger: 100,
drag : true
};
postMotionOptions.complete = function() {
// After motion complete need to remove transform from sidebar to let affix work on Pisces | Gemini.
if (CONFIG.motion.transition.sidebar && (NexT.utils.isPisces() || NexT.utils.isGemini())) {
$sidebarAffix.css({ 'transform': 'initial' });
}
integrator.next();
};
//$post.velocity('transition.slideDownIn', postMotionOptions);
if (CONFIG.motion.transition.post_block) {
$postBlock.velocity('transition.' + $postBlockTransition, postMotionOptions);
}
if (CONFIG.motion.transition.post_header) {
$postHeader.velocity('transition.' + $postHeaderTransition, postMotionOptions);
}
if (CONFIG.motion.transition.post_body) {
$postBody.velocity('transition.' + $postBodyTransition, postMotionOptions);
}
if (CONFIG.motion.transition.coll_header) {
$collHeader.velocity('transition.' + $collHeaderTransition, postMotionOptions);
}
// Only for Pisces | Gemini.
if (CONFIG.motion.transition.sidebar && (NexT.utils.isPisces() || NexT.utils.isGemini())) {
$sidebarAffix.velocity('transition.' + $sidebarAffixTransition, postMotionOptions);
}
}
hasPost ? postMotion() : integrator.next();
if (CONFIG.motion.async) {
integrator.next();
}
},
sidebar: function(integrator) {
if (CONFIG.sidebar.display === 'always') {
NexT.utils.displaySidebar();
}
integrator.next();
}
};
});
;
/* ========================================================================
* Bootstrap: scrollspy.js v3.3.2
* http://getbootstrap.com/javascript/#scrollspy
* ========================================================================
* Copyright 2011-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
/**
* Customized by iissnan & Ivan.Nginx
*
* - Add a `clear.bs.scrollspy` event.
* - Esacpe targets selector.
* - Refactored with eslint-config-theme-next style.
*/
/* global NexT */
(function($) {
'use strict';
// SCROLLSPY CLASS DEFINITION
// ==========================
function ScrollSpy(element, options) {
this.$body = $(document.body);
this.$scrollElement = $(element).is(document.body) ? $(window) : $(element);
this.options = $.extend({}, ScrollSpy.DEFAULTS, options);
this.selector = (this.options.target || '') + ' .nav li > a';
this.offsets = [];
this.targets = [];
this.activeTarget = null;
this.scrollHeight = 0;
this.$scrollElement.on('scroll.bs.scrollspy', $.proxy(this.process, this));
this.refresh();
this.process();
}
ScrollSpy.VERSION = '3.3.2';
ScrollSpy.DEFAULTS = {
offset: 10
};
ScrollSpy.prototype.getScrollHeight = function() {
return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight);
};
ScrollSpy.prototype.refresh = function() {
var that = this;
var offsetMethod = 'offset';
var offsetBase = 0;
this.offsets = [];
this.targets = [];
this.scrollHeight = this.getScrollHeight();
if (!$.isWindow(this.$scrollElement[0])) {
offsetMethod = 'position';
offsetBase = this.$scrollElement.scrollTop();
}
this.$body
.find(this.selector)
.map(function() {
var $el = $(this);
var href = $el.data('target') || $el.attr('href');
var $href = /^#./.test(href) && $(NexT.utils.escapeSelector(href)); // Need to escape selector.
return ($href
&& $href.length
&& $href.is(':visible')
&& [[$href[offsetMethod]().top + offsetBase, href]]) || null;
})
.sort(function(a, b) {
return a[0] - b[0];
})
.each(function() {
that.offsets.push(this[0]);