var errContents = '
詳細情報はありません
';
var timerQuickView = null;
jQuery(document).ready(function() {
jQuery('img[data-ref-goods]').parents('.js-goods-quickview-hover').hover(function() {
var target = this;
timerQuickView = setTimeout(function() {
addQuickView(target);
}, 200);
}, function() {
clearTimeout(timerQuickView);
timerQuickView = null;
removeQuickView(this);
});
});
function addQuickView(elm) {
jQuery.ajax({
type: 'GET',
url: EC_WWW_ROOT + '/shop/goods/quickviewajax.aspx',
data: {
'goods': jQuery(elm).find('img[data-ref-goods]').attr('data-ref-goods')
},
cache: false,
success: function(data) {
doAddQuickView(elm, data);
},
error: function() {
doAddQuickView(elm, errContents);
}
});
}
function doAddQuickView(elm, data) {
if (timerQuickView == null) {
return;
}
jQuery(elm).append(data);
var topQuickView = jQuery(elm).offset().top - 10;
var leftQuickView = jQuery(elm).offset().left - jQuery(elm).find('.js-goods-quickview').width();
jQuery(elm).find('.js-goods-quickview').css({
'top': topQuickView,
'left': leftQuickView
});
jQuery(elm).find('.js-goods-quickview').queue([]).fadeIn('fast');
if (1 < jQuery(document).find('.js-goods-quickview').length) {
jQuery(document).find('.js-goods-quickview').each(function(key, value) {
if (jQuery(value).position().top == topQuickView && jQuery(value).position().left == leftQuickView) {
jQuery(elm).find('.js-goods-quickview').nextAll().remove('div.js-goods-quickview');
return false;
} else {
jQuery(value).remove();
}
});
}
}
function removeQuickView(elm) {
var quickView = jQuery(elm).find('.js-goods-quickview');
if (quickView) {
quickView.queue([]).fadeOut('fast', function() {
quickView.remove();
});
}
}