1
|
const $ = require('yoho-jquery');
|
1
|
const $ = require('yoho-jquery');
|
2
|
const Vue = require('yoho-vue');
|
2
|
const Vue = require('yoho-vue');
|
3
|
|
3
|
|
4
|
-const resources = require('channel/resources.vue');
|
|
|
5
|
-const letterList = require('channel/letter-list.vue');
|
4
|
+var $nav = $('.cate-nav'),
|
|
|
5
|
+ $cateContainer = $('.cate-container'),
|
|
|
6
|
+ $contents = $cateContainer.children('.content'),
|
|
|
7
|
+ $subLevelItem = $cateContainer.find('.sub-level li'),
|
|
|
8
|
+ $primaryItem = $cateContainer.find('.primary-level li');
|
6
|
|
9
|
|
7
|
-require('common/vue-filter');
|
10
|
+var $curContent = $contents.not('.hide');
|
8
|
|
11
|
|
9
|
-new Vue({
|
|
|
10
|
- el: '#cate',
|
|
|
11
|
- components: {
|
|
|
12
|
- resources,
|
|
|
13
|
- letterList
|
12
|
+(function() {
|
|
|
13
|
+ var $header = $('.yoho-header'),
|
|
|
14
|
+ $search = $('#search-input');
|
|
|
15
|
+
|
|
|
16
|
+ var h = $(window).height() - $header.outerHeight() - $search.outerHeight() - $nav.outerHeight();
|
|
|
17
|
+
|
|
|
18
|
+ $cateContainer.css('min-height', h);
|
|
|
19
|
+
|
|
|
20
|
+ $contents.height(h);
|
|
|
21
|
+}());
|
|
|
22
|
+
|
|
|
23
|
+$('#search-input').focus(function() {
|
|
|
24
|
+ $(this).blur();
|
|
|
25
|
+});
|
|
|
26
|
+$nav.bind('contextmenu', function() {
|
|
|
27
|
+ return false;
|
|
|
28
|
+});
|
|
|
29
|
+$('.cate-container').bind('contextmenu', function() {
|
|
|
30
|
+ return false;
|
|
|
31
|
+});
|
|
|
32
|
+
|
|
|
33
|
+$nav.on('touchend touchcancel', function(e) {
|
|
|
34
|
+ var $this = $(e.target).closest('li'),
|
|
|
35
|
+ index = $this.index();
|
|
|
36
|
+
|
|
|
37
|
+ if ($this.hasClass('focus')) {
|
|
|
38
|
+ return;
|
14
|
}
|
39
|
}
|
|
|
40
|
+
|
|
|
41
|
+ $nav.find('li.focus').removeClass('focus');
|
|
|
42
|
+ $this.addClass('focus');
|
|
|
43
|
+
|
|
|
44
|
+ $curContent.addClass('hide');
|
|
|
45
|
+ $curContent = $contents.eq(index).removeClass('hide');
|
15
|
});
|
46
|
});
|
|
|
47
|
+
|
|
|
48
|
+$cateContainer.on('touchend', function(e) {
|
|
|
49
|
+ var $this = $(e.target),
|
|
|
50
|
+ $subLevel,
|
|
|
51
|
+ $cur, index;
|
|
|
52
|
+
|
|
|
53
|
+ $cur = $this.closest('.p-level-item');
|
|
|
54
|
+ if ($cur.length > 0) {
|
|
|
55
|
+ index = $cur.index();
|
|
|
56
|
+ $subLevel = $this.closest('.content').find('.sub-level');
|
|
|
57
|
+
|
|
|
58
|
+ if ($this.hasClass('focus')) {
|
|
|
59
|
+ return;
|
|
|
60
|
+ }
|
|
|
61
|
+
|
|
|
62
|
+ $this.closest('.primary-level').children('.focus').removeClass('focus');
|
|
|
63
|
+ $this.addClass('focus');
|
|
|
64
|
+
|
|
|
65
|
+ $subLevel.not('.hide').addClass('hide');
|
|
|
66
|
+ $subLevel.eq(index).removeClass('hide');
|
|
|
67
|
+
|
|
|
68
|
+ $subLevel.css({
|
|
|
69
|
+ top: $cur.offset().top - 60
|
|
|
70
|
+ });
|
|
|
71
|
+ }
|
|
|
72
|
+});
|
|
|
73
|
+
|
|
|
74
|
+$cateContainer.find('.primary-level').on('touchstart touchend touchcancel', 'li', function() {
|
|
|
75
|
+ $primaryItem.removeClass('highlight');
|
|
|
76
|
+ $(this).addClass('highlight');
|
|
|
77
|
+}).on('touchend touchcancel', 'li', function() {
|
|
|
78
|
+ $(this).removeClass('highlight');
|
|
|
79
|
+});
|
|
|
80
|
+
|
|
|
81
|
+$cateContainer.find('.sub-level').on('touchstart', 'li', function() {
|
|
|
82
|
+ $subLevelItem.removeClass('highlight');
|
|
|
83
|
+ $(this).addClass('highlight');
|
|
|
84
|
+}).on('touchend touchcancel', 'li', function() {
|
|
|
85
|
+ $(this).removeClass('highlight');
|
|
|
86
|
+});
|
|
|
87
|
+
|
|
|
88
|
+$nav.on('touchstart', 'li', function() {
|
|
|
89
|
+ $nav.find('li').removeClass('bytouch');
|
|
|
90
|
+ $(this).addClass('bytouch');
|
|
|
91
|
+}).on('touchend touchcancel', 'li', function() {
|
|
|
92
|
+ $nav.find('li').removeClass('bytouch');
|
|
|
93
|
+});
|
|
|
94
|
+ |