Authored by 郝肖肖

全部品类事件

const $ = require('yoho-jquery');
const Vue = require('yoho-vue');
const resources = require('channel/resources.vue');
const letterList = require('channel/letter-list.vue');
var $nav = $('.cate-nav'),
$cateContainer = $('.cate-container'),
$contents = $cateContainer.children('.content'),
$subLevelItem = $cateContainer.find('.sub-level li'),
$primaryItem = $cateContainer.find('.primary-level li');
require('common/vue-filter');
var $curContent = $contents.not('.hide');
new Vue({
el: '#cate',
components: {
resources,
letterList
(function() {
var $header = $('.yoho-header'),
$search = $('#search-input');
var h = $(window).height() - $header.outerHeight() - $search.outerHeight() - $nav.outerHeight();
$cateContainer.css('min-height', h);
$contents.height(h);
}());
$('#search-input').focus(function() {
$(this).blur();
});
$nav.bind('contextmenu', function() {
return false;
});
$('.cate-container').bind('contextmenu', function() {
return false;
});
$nav.on('touchend touchcancel', function(e) {
var $this = $(e.target).closest('li'),
index = $this.index();
if ($this.hasClass('focus')) {
return;
}
$nav.find('li.focus').removeClass('focus');
$this.addClass('focus');
$curContent.addClass('hide');
$curContent = $contents.eq(index).removeClass('hide');
});
$cateContainer.on('touchend', function(e) {
var $this = $(e.target),
$subLevel,
$cur, index;
$cur = $this.closest('.p-level-item');
if ($cur.length > 0) {
index = $cur.index();
$subLevel = $this.closest('.content').find('.sub-level');
if ($this.hasClass('focus')) {
return;
}
$this.closest('.primary-level').children('.focus').removeClass('focus');
$this.addClass('focus');
$subLevel.not('.hide').addClass('hide');
$subLevel.eq(index).removeClass('hide');
}
});
$cateContainer.find('.primary-level').on('touchstart touchend touchcancel', 'li', function() {
$primaryItem.removeClass('highlight');
$(this).addClass('highlight');
}).on('touchend touchcancel', 'li', function() {
$(this).removeClass('highlight');
});
$cateContainer.find('.sub-level').on('touchstart', 'li', function() {
$subLevelItem.removeClass('highlight');
$(this).addClass('highlight');
}).on('touchend touchcancel', 'li', function() {
$(this).removeClass('highlight');
});
$nav.on('touchstart', 'li', function() {
$nav.find('li').removeClass('bytouch');
$(this).addClass('bytouch');
}).on('touchend touchcancel', 'li', function() {
$nav.find('li').removeClass('bytouch');
});
... ...
... ... @@ -50,10 +50,13 @@
box-sizing: border-box;
float: left;
height: 100%;
padding: 20px 0;
padding: 20px 10px;
width: 25%;
text-align: center;
color: #999;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
&:last-child {
border-right: none;
... ... @@ -125,18 +128,6 @@
width: 100%;
background-color: #f6f6f6;
&:before {
content: "";
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-right: 20px solid #efefef;
position: absolute;
margin-top: 32px;
margin-left: -16px;
}
&.hide {
display: none;
}
... ... @@ -155,6 +146,22 @@
&:last-child {
border-bottom: none;
}
&:hover {
background-color: #efefef;
}
&:first-child:before {
content: "";
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-right: 20px solid #efefef;
position: absolute;
margin-top: 32px;
margin-left: -40px;
}
}
a {
... ...