|
|
const $ = require('jquery');
|
|
|
window.jQuery = $;
|
|
|
|
|
|
require('./index');
|
|
|
|
|
|
var categoryObj = {
|
|
|
domInit: function () {
|
|
|
this.el = {
|
|
|
$tabItem: $('.tab-item'),
|
|
|
$listItem: $('.tab-item').find('.list-item'),
|
|
|
$leftPartItem: $('.left-part').find('.item')
|
|
|
};
|
|
|
},
|
|
|
init: function () {
|
|
|
var _this = this;
|
|
|
|
|
|
this.domInit();
|
|
|
_this.el.$tabItem.on('click', function () {
|
|
|
$(this).toggleClass('active').siblings('.tab-item').removeClass('active');
|
|
|
});
|
|
|
|
|
|
_this.el.$listItem.on('click', function () {
|
|
|
var cityName = $(this).find('.name').text();
|
|
|
|
|
|
$(this).addClass('active').siblings('div').removeClass('active');
|
|
|
$(this).parents('.tab-item').find('.city-name .name').text(cityName);
|
|
|
$(this).parents('.tab-item').toggleClass('active');
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
_this.el.$leftPartItem.on('click', function () {
|
|
|
$(this).addClass('active').siblings('div').removeClass('active');
|
|
|
return false;
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
$(
|
|
|
function () {
|
|
|
categoryObj.init();
|
|
|
}
|
|
|
); |