|
@@ -2,6 +2,8 @@
|
|
|
|
|
|
var scrollFlag = false;
|
|
|
var navbarIndex = 0;
|
|
|
+var isPC = true;
|
|
|
+
|
|
|
/**
|
|
|
* 防抖
|
|
|
* @param {*} func 执行数
|
|
@@ -11,32 +13,33 @@ var navbarIndex = 0;
|
|
|
*/
|
|
|
|
|
|
function debounce(func, wait, immediate) {
|
|
|
- var timeout, result;
|
|
|
- return function () {
|
|
|
- var context = this;
|
|
|
- var args = arguments;
|
|
|
- if (timeout) clearTimeout(timeout);
|
|
|
-
|
|
|
- if (immediate) {
|
|
|
- var callNow = !timeout;
|
|
|
- timeout = setTimeout(function () {
|
|
|
- timeout = null;
|
|
|
- }, wait);
|
|
|
- if (callNow) result = func.apply(context, args);
|
|
|
- } else {
|
|
|
- timeout = setTimeout(function () {
|
|
|
- func.apply(context, args);
|
|
|
- }, wait);
|
|
|
- }
|
|
|
-
|
|
|
- return result;
|
|
|
- };
|
|
|
+ var timeout, result;
|
|
|
+ return function () {
|
|
|
+ var context = this;
|
|
|
+ var args = arguments;
|
|
|
+ if (timeout) clearTimeout(timeout);
|
|
|
+
|
|
|
+ if (immediate) {
|
|
|
+ var callNow = !timeout;
|
|
|
+ timeout = setTimeout(function () {
|
|
|
+ timeout = null;
|
|
|
+ }, wait);
|
|
|
+ if (callNow) result = func.apply(context, args);
|
|
|
+ } else {
|
|
|
+ timeout = setTimeout(function () {
|
|
|
+ func.apply(context, args);
|
|
|
+ }, wait);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ };
|
|
|
} // 还原滚动状态
|
|
|
|
|
|
|
|
|
var resetScrollFlag = debounce(function () {
|
|
|
- scrollFlag = false;
|
|
|
+ scrollFlag = false;
|
|
|
}, 200);
|
|
|
+
|
|
|
/**
|
|
|
* 监听视窗大小
|
|
|
* @param {*} size 视窗断点大小
|
|
@@ -44,18 +47,19 @@ var resetScrollFlag = debounce(function () {
|
|
|
*/
|
|
|
|
|
|
function responseScreen(size, callback) {
|
|
|
- var isPc = $(window).width() > size; // callback(isPc)
|
|
|
-
|
|
|
- $(window).resize(function () {
|
|
|
- if (!isPc && $(this).width() > size) {
|
|
|
- isPc = true;
|
|
|
- callback(isPc);
|
|
|
- } else if (isPc && $(this).width() < size) {
|
|
|
- isPc = false;
|
|
|
- callback(isPc);
|
|
|
- }
|
|
|
- });
|
|
|
+ var isPc = isPC = $(window).width() > size; // callback(isPc)
|
|
|
+
|
|
|
+ $(window).resize(function () {
|
|
|
+ if (!isPc && $(this).width() > size) {
|
|
|
+ isPc = true;
|
|
|
+ callback(isPc);
|
|
|
+ } else if (isPc && $(this).width() < size) {
|
|
|
+ isPc = false;
|
|
|
+ callback(isPc);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 菜单栏折叠展开 父子容器
|
|
|
* @param {*} bindEl 触发事件的元素
|
|
@@ -67,32 +71,33 @@ function responseScreen(size, callback) {
|
|
|
|
|
|
|
|
|
function collapseToggle(bindEl, eventName, callback) {
|
|
|
- var isCollapse = false; // 获取元素
|
|
|
-
|
|
|
- bindEl = $(bindEl);
|
|
|
- var parent = $(bindEl.attr('data-collapse-parent-target'));
|
|
|
- var children = $(bindEl.attr('data-collapse-children-target'));
|
|
|
- parent.css('transition', 'height 0.4s'); // 获取父子容器高度
|
|
|
-
|
|
|
- var parentHeight = parent.height();
|
|
|
- var childrenHeight = children.height();
|
|
|
- if (parentHeight >= childrenHeight) return bindEl.hide(); // 绑定点击事件
|
|
|
-
|
|
|
- bindEl.on(eventName, function () {
|
|
|
- var height = isCollapse ? parentHeight : childrenHeight;
|
|
|
- parent.height(height); //为父元素重新设置高度
|
|
|
-
|
|
|
- isCollapse = !isCollapse; // 执行回调
|
|
|
-
|
|
|
- callback({
|
|
|
- bindEl: bindEl,
|
|
|
- parent: parent,
|
|
|
- children: children,
|
|
|
- height: height,
|
|
|
- isCollapse: isCollapse
|
|
|
+ var isCollapse = false; // 获取元素
|
|
|
+
|
|
|
+ bindEl = $(bindEl);
|
|
|
+ var parent = $(bindEl.attr('data-collapse-parent-target'));
|
|
|
+ var children = $(bindEl.attr('data-collapse-children-target'));
|
|
|
+ parent.css('transition', 'height 0.4s'); // 获取父子容器高度
|
|
|
+
|
|
|
+ var parentHeight = parent.height();
|
|
|
+ var childrenHeight = children.height();
|
|
|
+ if (parentHeight >= childrenHeight) return bindEl.hide(); // 绑定点击事件
|
|
|
+
|
|
|
+ bindEl.on(eventName, function () {
|
|
|
+ var height = isCollapse ? parentHeight : childrenHeight;
|
|
|
+ parent.height(height); //为父元素重新设置高度
|
|
|
+
|
|
|
+ isCollapse = !isCollapse; // 执行回调
|
|
|
+
|
|
|
+ callback({
|
|
|
+ bindEl: bindEl,
|
|
|
+ parent: parent,
|
|
|
+ children: children,
|
|
|
+ height: height,
|
|
|
+ isCollapse: isCollapse
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 设置高亮
|
|
|
* @param {*} selector 节点选择器
|
|
@@ -101,17 +106,18 @@ function collapseToggle(bindEl, eventName, callback) {
|
|
|
|
|
|
|
|
|
var activeCategory = debounce(function (selector, index) {
|
|
|
- if (!selector || typeof index !== 'number') return;
|
|
|
- var activeWidth = 0;
|
|
|
- var selectorList = selector.split(',');
|
|
|
- $('.navigate li, .category-list li').removeClass('active');
|
|
|
- selectorList.forEach(function (el) {
|
|
|
- $(el.trim()).eq(index).addClass('active');
|
|
|
- activeWidth = $(el.trim()).eq(index).width();
|
|
|
- });
|
|
|
- var offset = ($(window).width() - activeWidth) / 2;
|
|
|
- categoryScrollTo('#category ul', 0, offset);
|
|
|
+ if (!selector || typeof index !== 'number') return;
|
|
|
+ var activeWidth = 0;
|
|
|
+ var selectorList = selector.split(',');
|
|
|
+ $('.navigate li, .category-list li').removeClass('active');
|
|
|
+ selectorList.forEach(function (el) {
|
|
|
+ $(el.trim()).eq(index).addClass('active');
|
|
|
+ activeWidth = $(el.trim()).eq(index).width();
|
|
|
+ });
|
|
|
+ var offset = ($(window).width() - activeWidth) / 2;
|
|
|
+ categoryScrollTo('#category ul', 0, offset);
|
|
|
}, 200);
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* @param {*} el 监听的元素
|
|
@@ -119,24 +125,25 @@ var activeCategory = debounce(function (selector, index) {
|
|
|
*/
|
|
|
|
|
|
function stickyResponse(el) {
|
|
|
- var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
|
- var callback = arguments.length > 2 ? arguments[2] : undefined;
|
|
|
- $(window).scroll(function () {
|
|
|
- var scrollTop = $(this).scrollTop();
|
|
|
-
|
|
|
- if (scrollTop >= offset) {
|
|
|
- callback({
|
|
|
- sticky: true,
|
|
|
- scrollTop: scrollTop
|
|
|
- });
|
|
|
- } else {
|
|
|
- callback({
|
|
|
- sticky: false,
|
|
|
- scrollTop: scrollTop
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
+ var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
|
+ var callback = arguments.length > 2 ? arguments[2] : undefined;
|
|
|
+ $(window).scroll(function () {
|
|
|
+ var scrollTop = $(this).scrollTop();
|
|
|
+
|
|
|
+ if (scrollTop >= offset) {
|
|
|
+ callback({
|
|
|
+ sticky: true,
|
|
|
+ scrollTop: scrollTop
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ callback({
|
|
|
+ sticky: false,
|
|
|
+ scrollTop: scrollTop
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* @param {*} offsetEls 需要获取的元素列表
|
|
@@ -144,16 +151,17 @@ function stickyResponse(el) {
|
|
|
|
|
|
|
|
|
function getScrollOffset(offsetEl) {
|
|
|
- if (typeof offsetEl === 'string') {
|
|
|
- return $(offsetEl).height();
|
|
|
- }
|
|
|
-
|
|
|
- var height = 0;
|
|
|
- offsetEl.forEach(function (el) {
|
|
|
- height += $(el).height();
|
|
|
- });
|
|
|
- return height;
|
|
|
+ if (typeof offsetEl === 'string') {
|
|
|
+ return $(offsetEl).height();
|
|
|
+ }
|
|
|
+
|
|
|
+ var height = 0;
|
|
|
+ offsetEl.forEach(function (el) {
|
|
|
+ height += $(el).height();
|
|
|
+ });
|
|
|
+ return height;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 侧边栏点击跳转
|
|
|
* @param {*} selector 侧边栏节点选择器
|
|
@@ -164,22 +172,23 @@ function getScrollOffset(offsetEl) {
|
|
|
|
|
|
|
|
|
function bindCategory(selector, floorEl) {
|
|
|
- var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
|
- var callback = arguments.length > 3 ? arguments[3] : undefined;
|
|
|
- $(selector).on('click', function () {
|
|
|
- scrollFlag = true;
|
|
|
- resetScrollFlag();
|
|
|
- var index = $(this).index();
|
|
|
- var floor = $(floorEl).eq(index);
|
|
|
- if (!floor.length) return;
|
|
|
- var floorTop = floor.offset().top - offset;
|
|
|
- $('html ,body').animate({
|
|
|
- scrollTop: floorTop
|
|
|
- }, 400, 'linear', function () {
|
|
|
- callback(index);
|
|
|
+ var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
|
+ var callback = arguments.length > 3 ? arguments[3] : undefined;
|
|
|
+ $(selector).on('click', function () {
|
|
|
+ scrollFlag = true;
|
|
|
+ resetScrollFlag();
|
|
|
+ var index = $(this).index();
|
|
|
+ var floor = $(floorEl).eq(index);
|
|
|
+ if (!floor.length) return;
|
|
|
+ var floorTop = floor.offset().top - offset;
|
|
|
+ $('html ,body').animate({
|
|
|
+ scrollTop: floorTop
|
|
|
+ }, 400, 'linear', function () {
|
|
|
+ callback(index);
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 监听页面滚动并观察元素是否在滚动区间
|
|
|
* @param {*} selector 被观察的元素节点选择器
|
|
@@ -189,26 +198,27 @@ function bindCategory(selector, floorEl) {
|
|
|
|
|
|
|
|
|
function pageScrollObserve(selector) {
|
|
|
- var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
|
- var callback = arguments.length > 2 ? arguments[2] : undefined;
|
|
|
- $(window).scroll(function () {
|
|
|
- if (scrollFlag) return;
|
|
|
- var scrollTop = $(this).scrollTop();
|
|
|
-
|
|
|
- if (scrollTop < $(selector).eq(0).offset().top - offset) {
|
|
|
- callback(null, -1);
|
|
|
- }
|
|
|
-
|
|
|
- $(selector).each(function (index, el) {
|
|
|
- var offsetTop = $(el).offset().top - offset;
|
|
|
- var height = $(el).height();
|
|
|
-
|
|
|
- if (scrollTop >= offsetTop && scrollTop < offsetTop + height) {
|
|
|
- callback(el, index);
|
|
|
- }
|
|
|
+ var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
|
+ var callback = arguments.length > 2 ? arguments[2] : undefined;
|
|
|
+ $(window).scroll(function () {
|
|
|
+ if (scrollFlag) return;
|
|
|
+ var scrollTop = $(this).scrollTop();
|
|
|
+
|
|
|
+ if (scrollTop < $(selector).eq(0).offset().top - offset) {
|
|
|
+ callback(null, -1);
|
|
|
+ }
|
|
|
+
|
|
|
+ $(selector).each(function (index, el) {
|
|
|
+ var offsetTop = $(el).offset().top - offset;
|
|
|
+ var height = $(el).height();
|
|
|
+
|
|
|
+ if (scrollTop >= offsetTop && scrollTop < offsetTop + height) {
|
|
|
+ callback(el, index);
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 动态生成侧边导航
|
|
|
* @param {*} selector 从该节点元素中获取文本
|
|
@@ -217,18 +227,19 @@ function pageScrollObserve(selector) {
|
|
|
|
|
|
|
|
|
function makeNavigate(selector, bindEl) {
|
|
|
- var ul = document.createElement('ul');
|
|
|
- $(selector).each(function (index, el) {
|
|
|
- var li = document.createElement('li');
|
|
|
- var a = document.createElement('a');
|
|
|
- a.innerText = $(el).text();
|
|
|
- a.setAttribute('href', '#' + $(el).text());
|
|
|
- li.appendChild(a);
|
|
|
- if (index === 0) li.classList.add('active');
|
|
|
- ul.appendChild(li);
|
|
|
- });
|
|
|
- $(bindEl).append(ul);
|
|
|
+ var ul = document.createElement('ul');
|
|
|
+ $(selector).each(function (index, el) {
|
|
|
+ var li = document.createElement('li');
|
|
|
+ var a = document.createElement('a');
|
|
|
+ a.innerText = $(el).text();
|
|
|
+ a.setAttribute('href', '#' + $(el).text());
|
|
|
+ li.appendChild(a);
|
|
|
+ if (index === 0) li.classList.add('active');
|
|
|
+ ul.appendChild(li);
|
|
|
+ });
|
|
|
+ $(bindEl).append(ul);
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 可折叠楼层
|
|
|
* @param {*} options
|
|
@@ -245,77 +256,89 @@ function makeNavigate(selector, bindEl) {
|
|
|
|
|
|
|
|
|
function makeFloorList(options) {
|
|
|
- var row = options.size / options.col; //每列显示的个数
|
|
|
-
|
|
|
- var floorMap = [];
|
|
|
- var minHeight = options.minHeight; // 最小高度
|
|
|
-
|
|
|
- $(options.root).each(function (index, el) {
|
|
|
- var floorInfo = floorMap[index] = Object.create(null);
|
|
|
- var selector = floorInfo.$floor = $(el); // 当前楼层对象
|
|
|
- floorInfo.count = selector.find(options.item).length; // 总数
|
|
|
- floorInfo.step = Math.ceil(floorInfo.count / options.size); // 可展开步数
|
|
|
- floorInfo.current = 1; // 当前步数
|
|
|
- floorInfo.hasMore = floorInfo.count > options.size; // 是否还有更多
|
|
|
- // 初始化高度,只有在可展开时设置初始高度
|
|
|
- if (floorInfo.hasMore) {
|
|
|
- floorInfo.height = minHeight * row * floorInfo.current;
|
|
|
- selector.find(options.collapse).height(floorInfo.height);
|
|
|
- selector.find(options.collapse).css({
|
|
|
- overflow: 'hidden',
|
|
|
- transition: 'height .4s'
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- // 为按钮绑定事件
|
|
|
- floorMap.forEach(function (floor) {
|
|
|
- if (!floor.hasMore) return floor.$floor.find(options.touch).parent().hide();
|
|
|
- floor.$floor.find(options.touch).on('click', function () {
|
|
|
- moreClick(floor);
|
|
|
- });
|
|
|
- });
|
|
|
- // 查看更多
|
|
|
- function moreClick(floor) {
|
|
|
- if (floor.current === floor.step) return closeMore(floor); // 剩下的个数
|
|
|
- var lastCount = floor.count - options.size * floor.current;
|
|
|
- floor.current++;
|
|
|
- floor.hasMore = floor.current < floor.step; // 如果还有更多
|
|
|
- if (floor.hasMore || lastCount > 3) {
|
|
|
- floor.$floor.find(options.collapse).height(minHeight * row * floor.current);
|
|
|
- } else {
|
|
|
- floor.$floor.find(options.collapse).height(minHeight * row * (floor.current - 1) + minHeight);
|
|
|
+ var row = options.size / options.col; //每列显示的个数
|
|
|
+
|
|
|
+ var floorMap = [];
|
|
|
+ var minHeight = options.minHeight; // 最小高度
|
|
|
+
|
|
|
+ $(options.root).each(function (index, el) {
|
|
|
+ var floorInfo = floorMap[index] = Object.create(null);
|
|
|
+ var selector = floorInfo.$floor = $(el); // 当前楼层对象
|
|
|
+
|
|
|
+ floorInfo.count = selector.find(options.item).length; // 总数
|
|
|
+
|
|
|
+ floorInfo.step = Math.ceil(floorInfo.count / options.size); // 可展开步数
|
|
|
+
|
|
|
+ floorInfo.current = 1; // 当前步数
|
|
|
+
|
|
|
+ floorInfo.hasMore = floorInfo.count > options.size; // 是否还有更多
|
|
|
+ // 初始化高度,只有在可展开时设置初始高度
|
|
|
+
|
|
|
+ if (floorInfo.hasMore) {
|
|
|
+ floorInfo.height = minHeight * row * floorInfo.current;
|
|
|
+ selector.find(options.collapse).height(floorInfo.height);
|
|
|
+ selector.find(options.collapse).css({
|
|
|
+ overflow: 'hidden',
|
|
|
+ transition: 'height .4s'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }); // 为按钮绑定事件
|
|
|
+
|
|
|
+ floorMap.forEach(function (floor) {
|
|
|
+ if (!floor.hasMore) return floor.$floor.find(options.touch).parent().hide();
|
|
|
+ floor.$floor.find(options.touch).on('click', function () {
|
|
|
+ moreClick(floor);
|
|
|
+ });
|
|
|
+ }); // 查看更多
|
|
|
+
|
|
|
+ function moreClick(floor) {
|
|
|
+ if (floor.current === floor.step) return closeMore(floor); // 剩下的个数
|
|
|
+
|
|
|
+ var lastCount = floor.count - options.size * floor.current;
|
|
|
+ floor.current++;
|
|
|
+ floor.hasMore = floor.current < floor.step; // 如果还有更多
|
|
|
+
|
|
|
+ if (floor.hasMore || lastCount > 3) {
|
|
|
+ floor.$floor.find(options.collapse).height(minHeight * row * floor.current);
|
|
|
+ } else {
|
|
|
+ floor.$floor.find(options.collapse).height(minHeight * row * (floor.current - 1) + minHeight);
|
|
|
+ } // 展开回调
|
|
|
+
|
|
|
+
|
|
|
+ options.open(floor);
|
|
|
+ } // 全部收起
|
|
|
+
|
|
|
+
|
|
|
+ function closeMore(floor) {
|
|
|
+ floor.current = 1;
|
|
|
+ floor.hasMore = true;
|
|
|
+ floor.$floor.find(options.collapse).height(floor.height); // 收起回调
|
|
|
+
|
|
|
+ options.close(floor);
|
|
|
}
|
|
|
- // 展开回调
|
|
|
- options.open(floor);
|
|
|
- }
|
|
|
-
|
|
|
- // 全部收起
|
|
|
- function closeMore(floor) {
|
|
|
- floor.current = 1;
|
|
|
- floor.hasMore = true;
|
|
|
- floor.$floor.find(options.collapse).height(floor.height); // 收起回调
|
|
|
- options.close(floor);
|
|
|
- }
|
|
|
} // 激活导航栏
|
|
|
|
|
|
|
|
|
function activeNavbar(selector) {
|
|
|
- var baseHref = window.location.href;
|
|
|
- navbarIndex = localStorage.getItem('navbarIndex') || 0;
|
|
|
- selector = $(selector);
|
|
|
- selector.each(function (index, el) {
|
|
|
- $(el).removeClass('active');
|
|
|
- if ($(el).find('a').length > 0) {
|
|
|
- var href = $(el).find('a').attr('href');
|
|
|
- href = href.split('?')[0].split('#')[0];
|
|
|
- if (baseHref.indexOf(href) > -1) {
|
|
|
- navbarIndex = index;
|
|
|
- localStorage.setItem('navbarIndex', navbarIndex)
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- selector.eq(navbarIndex).addClass('active');
|
|
|
+ var baseHref = window.location.href;
|
|
|
+ navbarIndex = localStorage.getItem('navbarIndex') || 0;
|
|
|
+ selector = $(selector);
|
|
|
+ selector.each(function (index, el) {
|
|
|
+ $(el).removeClass('active');
|
|
|
+
|
|
|
+ if ($(el).find('a').length > 0) {
|
|
|
+ var href = $(el).find('a').attr('href');
|
|
|
+ href = href.split('?')[0].split('#')[0];
|
|
|
+
|
|
|
+ if (baseHref.indexOf(href) > -1) {
|
|
|
+ navbarIndex = index;
|
|
|
+ localStorage.setItem('navbarIndex', navbarIndex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ selector.eq(navbarIndex).addClass('active');
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 将导航滚动到激活位置
|
|
|
* @param {*} selector 导航元素
|
|
@@ -326,36 +349,44 @@ function activeNavbar(selector) {
|
|
|
|
|
|
|
|
|
function categoryScrollTo(selector, scrollLeft) {
|
|
|
- var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
|
- if ($(window).width <= 768) return;
|
|
|
- selector = $(selector);
|
|
|
- var sub = selector.children().eq(0).offset().left + offset;
|
|
|
- scrollLeft = Math.ceil(selector.find('.active').offset().left - sub);
|
|
|
- $(selector).animate({
|
|
|
- scrollLeft: scrollLeft
|
|
|
- }, 200, 'linear');
|
|
|
+ var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
|
+ if ($(window).width <= 768) return;
|
|
|
+ selector = $(selector);
|
|
|
+ var sub = selector.children().eq(0).offset().left + offset;
|
|
|
+ scrollLeft = Math.ceil(selector.find('.active').offset().left - sub);
|
|
|
+ $(selector).animate({
|
|
|
+ scrollLeft: scrollLeft
|
|
|
+ }, 200, 'linear');
|
|
|
} // 移动端绑定滑动事件
|
|
|
|
|
|
|
|
|
function slideBarHandle(selector) {
|
|
|
- var display = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'block';
|
|
|
- if ($(window).width() > 768) return;
|
|
|
- selector = $(selector);
|
|
|
- var target = $(selector.attr('data-target'));
|
|
|
- selector.on('click', function () {
|
|
|
- target.slideDown();
|
|
|
- target.css('display', display);
|
|
|
- });
|
|
|
- target.on('click', function () {
|
|
|
- target.slideUp();
|
|
|
- });
|
|
|
+ var display = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'block';
|
|
|
+ if ($(window).width() > 768) return;
|
|
|
+ selector = $(selector);
|
|
|
+ var target = $(selector.attr('data-target'));
|
|
|
+ selector.on('click', function () {
|
|
|
+ target.slideDown();
|
|
|
+ target.css('display', display);
|
|
|
+ });
|
|
|
+ target.on('click', function () {
|
|
|
+ target.slideUp();
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
+* 跳转到搜索页面
|
|
|
+* */
|
|
|
+function toSearchPage(){
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
$(function () {
|
|
|
- activeNavbar('.navbar .nav li');
|
|
|
- slideBarHandle('#menuBtn', 'flex');
|
|
|
- slideBarHandle('#hotKeyword');
|
|
|
- responseScreen(768, function () {
|
|
|
- window.location.reload();
|
|
|
- });
|
|
|
+ activeNavbar('.navbar .nav li');
|
|
|
+ slideBarHandle('#menuBtn', 'flex');
|
|
|
+ slideBarHandle('#hotKeyword');
|
|
|
+ responseScreen(768, function () {
|
|
|
+ window.location.reload();
|
|
|
+ });
|
|
|
});
|