var BASE_URL = WWW,
CP = BASE_URL + 'cp/',
SOURCE_URL = BASE_URL + 'source/',
SOURCE_ORIGIN = BASE_URL + 'source/',
UPLOAD_URL = BASE_URL + 'source/',
UPLOAD_IMG = UPLOAD_URL + 'upload',
UPLOAD_FILE = UPLOAD_URL + 'upload',
WU_SWF = BASE_URL + 'msic/webuploader/Uploader.swf',
BRAND_ID = 0;
var YZ = {version: '1.0', author: 'lynn@elicht.cn', created: '20161118', elements: {}}, SOSO = {};
YZ.U = function (uri) {
uri = uri.replace(/\\/g, '/');
if (new RegExp("^[a-z]+:\/\/", 'gi').test(uri.toLowerCase()) || uri.substr(0, 1) == '/') {
return uri;
}
return BASE_URL + uri;
};
YZ.Mask = {
text: '正在处理,请稍候',
html: '
').addClass('preview-list-container'),
$forward = $previewList.find('.preview-ctrl-forward'),
$backward = $previewList.find('.preview-ctrl-backward'),
$ul = $previewList.find('.preview-list ul'),
divlen = 6,
left = 0,
num = 1,
len = $ul.find('li').length,
pageCount = Math.ceil(len / divlen),
itemWidth = 60,
last = Math.floor(len % divlen),
offset = 0;
c.append($leftCtrl, $rightCtrl, $previewListContainer.append($previewList));
$leftCtrl.on('click', function () {
var li = $activeLi.prev();
if (li.length <= 0) return;
var url = li.find('img').data('url');
h.attr('src', url);
c.removeData('bs.lightbox').lightbox({remove: !0, backdrop: 0});
li.trigger('click');
$activeLi = li;
offset = $activeLi.position().left + parseInt($ul.css('left'));
changePage('left', offset);
});
$rightCtrl.on('click', function () {
var li = $activeLi.next();
if (li.length <= 0) return;
var url = li.find('img').data('url');
h.attr('src', url);
c.removeData('bs.lightbox').lightbox({remove: !0, backdrop: 0});
li.trigger('click');
$activeLi = li;
offset = $activeLi.position().left + parseInt($ul.css('left'));
changePage('right', offset);
});
function changePage(dir, offset) {
switch (dir) {
case 'left':
if (offset < 0) { // 需要翻上一页
$forward.trigger('click');
}
break;
case 'right':
if (offset > (divlen - 1) * itemWidth) { // 需要翻下一页
$backward.trigger('click');
}
break;
}
}
$previewList.on('click', 'li', function () {
var p = $(this), me = p.find('img'), cls = 'active', url = me.data('url');
if (!p.hasClass(cls) && url) {
p.parent().find('li.' + cls).removeClass(cls);
p.addClass(cls);
h.attr('src', url);
c.removeData('bs.lightbox').lightbox({remove: !0, backdrop: 0});
$activeLi = p;
}
});
$forward.on('click', function (e) {
if (num <= 1) return;
left = parseInt($ul.css('left'));
left += divlen * itemWidth;
left = left > 0 ? 0 : left;
$ul.stop().animate({'left': left}, 400);
num--;
e.stopPropagation();
});
$backward.on('click', function (e) {
if (num >= pageCount) return;
left = parseInt($ul.css('left'));
if (num + 1 == pageCount && last < divlen) left += (divlen - last) * itemWidth;
left -= divlen * itemWidth;
$ul.stop().animate({'left': left}, 400);
num++;
e.stopPropagation();
});
}
c.appendTo(document.body);
c.lightbox({remove: !0});
return c;
}
$(function () {
var dt1 = new Date();
var id = $.cookie('YZ_PAGE');
window.onbeforeunload = function () {
var dt2 = new Date();
var ms = dt2.getTime() > dt1.getTime() ? (dt2.getTime() - dt1.getTime()) / 1000 : 1;
var img = new Image();
img.src = WWW + 'feedback/unload?t=' + ms + '&id=' + id;
}
$('img').error(function () {
//$(this).hide();
//var downlight;
});
var so = $('#headerSoForm').on('submit', function (e) {
return false
});
so.find('input').on('focus', function () {
YZ.So()
});
so.find('button').on('click', function () {
YZ.So()
});
$('.product-preview').each(function () {
carousel(this);
});
$('.images-selector').on('mouseover', 'li', function () {
var me = $(this),
img = me.find('img'),
url = img.data('url'),
cls = 'active';
if (!me.hasClass(cls) && url) {
me.siblings('.' + cls).removeClass(cls);
me.addClass(cls);
me.parent().prev().find('img').attr('src', url);
}
});
var lightEffect = $('.light-effect-list-img');
if (lightEffect.length) {
lightEffect.on('click', 'a', function () {
var el = $(this), cls = 'active', p;
if (el.hasClass(cls)) return;
el.addClass(cls).siblings().removeClass(cls);
el.parent().parent().parent().find('.light-effect-img img').removeClass(cls).eq(el.index()).addClass(cls);
p = el.parent().parent().find('.light-effect-info');
p.find('h4').text(el.data('name'));
p.find('p').text(el.data('description'));
});
}
$('body').on('click dblclick', '.lightbox-img', function (e) {
var el = $(this),
img = el.find('img'),
src = img.data('source') || img.attr('src'),
closest = el.parents('.' + el.data('closest')),
list = closest.find('.preview-ctrl');
if (img.length && src) {
if (img.data('lightbox-dblclick')) {
if (e.type == 'dblclick') lightBox(img, {src: src, list: list});
} else if (e.type != 'dblclick') {
lightBox(img, {src: src, list: list});
}
}
});
$('.img-hover').hover(function () {
var el = $(this).find('img'), hover = el.data('hover'), src = el.data('src');
if (!src) {
src = el.attr('src');
el.data('src', src);
}
if (hover) el.attr('src', hover);
}, function () {
var el = $(this).find('img');
el.attr('src', el.data('src'));
});
window.setTimeout(function () {
affixCategory($('.category-affix-nav'));
}, 500);
$('[data-toggle="tooltip"]').tooltip();
$("#back-to-top").on("click", function () {
$(document.body).animate({
"scrollTop": 0
}, 200);
});
$('.popover-btn').each(function () {
var $pElem = $(this);
$pElem.popover({
html: true,
animation: true,
trigger: 'hover',
container: $(this),
content: function () {
return $($($pElem).data('contentElement')).html();
}
});
});
$('.navbar-nav>li>a.dropdown-toggle').on('click tap', function (e) {
if ($(window).width() > 768) e.stopPropagation();
});
if ($(window).width() <= 768) {
$('.navbar-nav>li>a').each(function () {
var $dropdownMenu = $(this).siblings('.dropdown-menu');
if ($dropdownMenu.length > 0 && $dropdownMenu.find('li').length <= 0) {
$(this).removeClass('dropdown-toggle').removeAttr('data-toggle');
}
});
}
;
$('.search-tab').on('click', 'li', function () {
$(this).siblings('li').removeClass('active');
$(this).addClass('active');
$(this).parents('form').find('input[name="cate"]').val($(this).data('id'));
});
$('.yz-button').hover(
function () {
var high = $(this).data('high');
if (high) {
$(this).attr('style', $(this).attr('style') + high);
}
},
function () {
var high = $(this).data('high'),
reg = new RegExp(high, 'g');
if (high && !$(this).hasClass('active')) {
$(this).attr('style', $(this).attr('style').replace(reg, ''));
}
}
);
// YZ.Feedback.init();
// YZ.Subscriber.init();
$('#feed-back').on('click', function () {
// YZ.Feedback.show();
var el = $(this),
me = el.get(0);
if(me.isClick) return false;
me.isClick = true;
if(me.isModal){
me.isModal.modal('show');
me.isClick = false;
}else{
me.isClick = false;
NProgress.start()
$.ajax({
url:YZ.U('feedback/index'),
type:'post',
success:function(rs){
me.isModal = $(rs).appendTo('body').find('.modal')
me.isModal.modal('show');
},
error:function(rs){
NProgress.done(), toast('提交失败,错误信息:' + rs.message);
console.log(rs.responseText);
}
})
}
});
$('#subscriber').on('click', function () {
var el = $(this),
dialogId = 'subscriberDialog',
dialog = $('#' + dialogId);
if (dialog.length) {
return Subscriber.show();
}
if($('#subscriberFrom').length){
toast('已在订阅页面');
}else{
$('
').appendTo(document.body).load(YZ.U('app/subscribe?' + (new Date()).getTime()), function () {
});
}
});
$('.nav-menu-horizontal>li').mouseenter(function () {
var maxW = $('.container').width(),
ul = $('.nav-menu-horizontal>li:hover>.dropdown-menu-nav'),
navLeft = $('.container').offset().left,
liW = 0, ulLeft, clientW, overW;
if ($(window).width() > 769) {
if (ul.length > 0) {
ulLeft = ul.closest('li').offset().left;
ul.find('li').each(function () {
liW += $(this).width();
});
clientW = maxW - (ulLeft - navLeft);
overW = liW - clientW;
if (overW > 0) {
if (liW > maxW) {
ul.css('left', -(ulLeft - navLeft)).width(maxW);
} else {
ul.width(liW + 10).css('left', -overW);
}
} else {
ul.width(liW + 10).css('left', 0);
}
} else {
ul.css('left', 0);
}
}
});
var sideNavBar = $('.side-nav-bar');
if (sideNavBar.data('hoverColor')) {
var color = sideNavBar.data('color'),
fontColor = sideNavBar.data('fontColor'),
theme = sideNavBar.data('theme'),
hoverColor = sideNavBar.data('hoverColor'),
colorStyle = '.bar-menu-bottom > li:hover > a, .bar-menu-top > li:hover > a{background:' + color + ';color: #fff;}#back-to-top:hover {border-color: ' + color + ';}',
fontColorStyle = '.bar-menu-bottom > li > a, .bar-menu-top > li > a{color:' + fontColor + ' !important}.bar-menu-bottom,#back-to-top{border-top:1px solid ' + YZ.colortORgba(fontColor, .25) + ' !important}',
themeStyle = '.side-nav-bar{background:' + theme + '!important}',
hoverColorStyle = '.bar-menu-bottom > li:hover > a, .bar-menu-top > li:hover > a{color:' + hoverColor + ' !important}',
style = colorStyle + fontColorStyle + themeStyle + hoverColorStyle;
YZ.appendStyle(style);
}
//导航条溢出处理(小于1024px)
if ($(window).width() > 768 && $(window).width() <= 1024) {
var $header = $('.header'),
$navbar = $header.find('.navbar-nav'),
$navbarLi = $header.find('.navbar-nav > li'),
sumLiWidth = 0;
$navbar.find('li a').on('click', function (e) {
if ($(this).siblings('.nav').length > 0 && $(this).parent().is('.spill') == false) {
e.preventDefault();
}
});
$navbarLi.each(function (index, element) {
sumLiWidth = sumLiWidth + $navbarLi.eq(index).width();
if (sumLiWidth >= 450) {
$(element).addClass('spill');
}
});
if ($navbar.find('li.spill').length > 0) {
$navbar.find('li.spill').wrapAll('
')
$navbar.find('.spill-con').before('
');
}
}
});
// jq cookie
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory)
} else if (typeof exports === 'object') {
factory(require('jquery'))
} else {
factory(jQuery)
}
}(function ($) {
var pluses = /\+/g;
function encode(s) {
return config.raw ? s : encodeURIComponent(s)
}
function decode(s) {
return config.raw ? s : decodeURIComponent(s)
}
function stringifyCookieValue(value) {
return encode(config.json ? JSON.stringify(value) : String(value))
}
function parseCookieValue(s) {
if (s.indexOf('"') === 0) {
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\')
}
try {
s = decodeURIComponent(s.replace(pluses, ' '));
return config.json ? JSON.parse(s) : s
} catch (e) {
}
}
function read(s, converter) {
var value = config.raw ? s : parseCookieValue(s);
return $.isFunction(converter) ? converter(value) : value
}
var config = $.cookie = function (key, value, options) {
if (value !== undefined && !$.isFunction(value)) {
options = $.extend({}, config.defaults, options);
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setTime(+t + days * 864e+5)
}
return (document.cookie = [encode(key), '=', stringifyCookieValue(value), options.expires ? '; expires=' + options.expires.toUTCString() : '', options.path ? '; path=' + options.path : '', options.domain ? '; domain=' + options.domain : '', options.secure ? '; secure' : ''].join(''))
}
var result = key ? undefined : {};
var cookies = document.cookie ? document.cookie.split('; ') : [];
for (var i = 0, l = cookies.length; i < l; i++) {
var parts = cookies[i].split('=');
var name = decode(parts.shift());
var cookie = parts.join('=');
if (key && key === name) {
result = read(cookie, value);
break
}
if (!key && (cookie = read(cookie)) !== undefined) {
result[name] = cookie
}
}
return result
};
config.defaults = {};
$.removeCookie = function (key, options) {
if ($.cookie(key) === undefined) {
return false
}
$.cookie(key, '', $.extend({}, options, {expires: -1}));
return !$.cookie(key)
}
}));