;(function($) {
window.GALAXY = {
isMobile: $.browser.mobile,
isPoorBrowser: $.browser.ie && 9 > $.browser.ie,
swipeAble: !!(!!$.browser.mobile || window.PointerEvent || window.MSPointerEvent),
parallaxAble: !($.browser.ie && 9 > $.browser.ie) && !$.browser.mobile && $.support.transition,
areaWidth: 0,
areaHeight: 0,
prevSizeMode: -1,
sizeMode: 0,
scrollBarWidth: 0,
scrollTop: 0,
mediaBaseURL: window.MEDIA_BASE_URL || '',
isTestURL: location.href.indexOf('samsung.com') < 0,
isGalaxy: location.pathname.indexOf('/global/galaxy') === 0,
isGPSI: navigator.userAgent.toLowerCase().replace(/ /g, '').indexOf('googlepagespeedinsights') != -1,
scrollFunctions: [],
resizeFunctions: [],
path: {
root: '/global/galaxy/'
},
initialized: false,
dom: {
header: $('#header').get(0) || $('header').get(0)
},
header: function() {
if (!$(GALAXY.isGalaxy?'#header':GALAXY.dom.header).length) {
return;
}
var
$header = $(GALAXY.isGalaxy?'#header':GALAXY.dom.header),
$menuButton = $header.find('p.menu a'),
isMobile = $.browser.mobile,
isPoorBrowser = GALAXY.isPoorBrowser,
transitionName = $.support.transition,
gnb, subNav;
gnb = (function() {
if (!$('#gnb').length) {
return {scroll: $.noop, resize: $.noop};
}
var $wrap = $('#wrap'),
$box = $('#gnb'),
$boxElementsA = $box.find('a'),
$bod = $box.find('a.bod'),
$eod = $box.find('a.eod'),
$logo = $box.find('.logo a'),
$h2 = $box.find('> .g-heading'),
$dotcom = $box.find('p.g-country-site a'),
$inner = $box.find('div.g-inner'),
$buttonParent = $menuButton.parent(),
$tabBox = $box.find('.g-tabs'),
$tabs = $tabBox.find('ul a'),
$tabContents = [],
$contentBox = $box.find('.g-contents'),
$listBoxs = $contentBox.find('.g-content ul'),
$listItems = $listBoxs.find('> li'),
$tabBar = $('
').appendTo($tabBox),
$latestGroup = null,
$closeButton = $box.find('p.g-close a'),
$opener = null,
iScrolls = [],
iScrollOptions = {mouseWheel: true, scrollbars: true, interactiveScrollbars: true, preventDefaultException: {tagName: /(a|img|span)/i}},
i = 0, numTabs = $tabs.length,
tabIndex = 0,
currentIndex = -1,
tabBarIndex = 0,
opened = true,
tabResetTimer = null,
clickAble = true,
enteredList = null,
listLeaveTimer = null,
keyDowned = false,
onOpen,
onClose;
$box
.bind('mousewheel', function(e) {
e.stopPropagation();
})
.bind('touchmove', function(e) {
e.preventDefault();
})
.click(function(e) {
var target = e.target;
if (target == this || target == $inner[0]) {
close();
}
});
$menuButton.keydown(function() {
keyDowned = true;
})
.bind({
focus: function() {
$buttonParent.addClass('focus');
},
blur: function() {
$buttonParent.removeClass('focus');
},
click: function() {
open($menuButton, function() {
$buttonParent.removeClass('on');
});
$menuButton.addClass('hide');
$buttonParent.addClass('on');
return false;
}
});
$bod.attr('tabindex', ++tabIndex);
$logo.attr('tabindex', ++tabIndex);
$h2.attr('tabindex', ++tabIndex);
for (; i < numTabs; i++) {
$tabs[i] = $($tabs[i]);
if ($tabs[i].attr('href').indexOf('#g-') != -1) {
if (!isMobile) {
$tabs[i].parent().attr('data-index', i)
.mouseenter(changeTabBar).mouseleave(readyToResetTabBar).click(tabClick);
}
$tabs[i].attr('data-index', i).attr('tabindex', ++tabIndex)
.focus(changeTabBar).blur(readyToResetTabBar).click(changeTab);
$tabContents[i] = $($tabs[i].attr('href'));
$tabContents[i].find('li').mouseenter(listEnter).mouseleave(listLeave)
.find('a').focus(listEnter).blur(listLeave)
.each(function() {
this.setAttribute('tabindex', ++tabIndex);
});
iScrolls[i] = new IScroll($tabContents[i][0], iScrollOptions);
}
}
function listEnter(e) {
clearTimeout(listLeaveTimer);
enteredList = e.type == 'focus' ? this.parentNode.parentNode : this.parentNode;
enteredList.className = 'hover';
}
function listLeave() {
listLeaveTimer = setTimeout(listLeaveAction, 50);
}
function listLeaveAction() {
enteredList.className = '';
}
$contentBox.xlider({
swipe: isMobile,
onChange: function(page) {
changeTab.call($tabs[page][0]);
},
onChangeEnd: function() {
currentIndex > -1 && iScrolls[currentIndex].refresh();
}
});
/* GNB default select max 1 */
$tabs[Math.min(parseInt($wrap.attr('data-depth1') || 1)-1, 1)].click();
$dotcom.attr('tabindex', ++tabIndex);
$closeButton.attr('tabindex', ++tabIndex);
$eod.attr('tabindex', ++tabIndex);
if (!isMobile) {
$tabBar.mouseenter(cancelResetTabBar).mouseleave(readyToResetTabBar).click(tabClick);
}
$closeButton.mousedown(function() {
this.style.outline = 'none';
}).keydown(function() {
keyDowned = true;
}).click(close);
$bod.on('focus', function() {
$boxElementsA.eq(-2).focus();
}).on('click', function(e) {
e.preventDefault();
});
$eod.on('focus', function() {
$boxElementsA.eq(1).focus();
}).on('click', function(e) {
e.preventDefault();
});
function open(_$opener, _onClose) {
if (_$opener) {
$opener = _$opener;
}
$boxElementsA = $box.find('a');
$wrap.addClass('gnb-open');
$closeButton.removeClass('hide');
$box.addClass('show');
GALAXY.noScroll.on();
resize();
$.each(iScrolls, function() {
this.refresh();
});
if (!isMobile) {
setTimeout(function() {
if (keyDowned) {
$logo.focus();
} else {
$h2.focus();
}
}, 100);
}
onClose = _onClose;
opened = true;
return false;
}
function close(e) {
$wrap.removeClass('gnb-open');
$closeButton.addClass('hide');
$box.removeClass('show');
if (keyDowned && $opener) {
$opener.focus();
}
keyDowned = false;
$opener = null;
onClose && onClose();
GALAXY.setTransitionEndEvent($box, function() {
GALAXY.noScroll.off();
resize();
$box.hide();
$closeButton.css('outline', '');
setTimeout(function() {
$box.show();
}, 0);
});
onClose = null;
opened = false;
return false;
}
function changeTab() {
var i = 0, index = parseInt(this.getAttribute('data-index')),
$targets, numTargets;
if (!clickAble) {
return false;
}
for (; i < numTabs; i++) {
if ($tabContents[i]) {
$tabs[i].parent().decideClass('on', i == index);
if (!isMobile) {
$tabContents[i].decideClass('ready', i == index);
}
}
}
$contentBox.xlider('jump', index, !opened);
setTimeout(function() {
$tabContents[index].removeClass('ready');
}, 0);
currentIndex = index;
setTabBar(currentIndex);
return false;
}
function tabClick() {
$tabs[tabBarIndex].click();
}
function changeTabBar() {
cancelResetTabBar();
setTabBar(parseInt(this.getAttribute('data-index')));
}
function readyToResetTabBar() {
tabResetTimer = setTimeout(resetTabBar, 250);
}
function cancelResetTabBar() {
clearTimeout(tabResetTimer);
}
function resetTabBar() {
setTabBar(currentIndex);
}
function setTabBar(index, withoutAnimation) {
$tabBar['__'+ (isPoorBrowser || withoutAnimation === true || !opened ? 'css' : 'animate')](
{x: $tabs[index][0].offsetLeft, width: $tabs[index][0].offsetWidth},
{duration: 550, easing: 'easeOutCubic', force3D: true}
);
tabBarIndex = index;
}
function focusing(isReset) {
var $group = this.parentNode.children;
i = 0, numGroup = $group.length;
for (var i = 0; i < numGroup; i++) {
$group[i].className = $group[i].className.replace(/ *off */g, '') + (isReset === true || $group[i] == this ? '' : ' off');
}
}
function reset() {
focusing.call(this, true);
}
function scroll(v) {
var base = GALAXY.sizeMode == 1 ? 40 : 100;
$header.decideClass('clear', v > base);
}
function resize() {
var cols = GALAXY.sizeMode == 1 ? 2 : 3,
itemWidth = Math.ceil($wrap[0].offsetWidth/cols);
$listBoxs.css('width', itemWidth*cols);
$listItems.css('width', itemWidth);
setTabBar(currentIndex, true);
}
return {
open: open,
scroll: scroll,
resize: resize
}
})();
subNav = (function() {
var
$wrap = $('#wrap'),
$contents = $('#contents'),
$firstBox = $('#contents > [class^="m_"]:first'),
$subNav = $('#subnav'),
$scroller = $('div.inside'),
$links = $subNav.find('ul a'),
$menuButton = $subNav.find('p.gnb a'),
$preButtonClone = $subNav.find('p.pre-button').clone(),
$line = $subNav.find('div.line'),
$bar = $subNav.find('div.bar'),
single = $subNav.hasClass('single'),
firstBoxTop = 0,
firstBoxHeight = 0,
subNavHeight = 0,
swapBase = 75,
maxTop = 0,
fixed = false,
current = 0,
resetTimer = null,
iScroll = $.browser.android,
i = 0, numLinks = $links.length;
if (!GALAXY.isGalaxy) {
$('#subnav p.gnb').remove();
}
if (!$subNav.length) {
return {display: $.noop, scroll: $.noop, resize: $.noop};
}
if (iScroll) {
iScroll = new IScroll($scroller[0], {scrollX: true, scrollY: false, scrollbars: false, interactiveScrollbars: false, preventDefaultException: {tagName: /(a|img|span)/i}});
$bar.appendTo($scroller.find('ul'));
}
$wrap.addClass('has-subnav');
if (!isMobile) {
$links.mouseenter(linkHover).mouseleave(linkLeave).mousedown(linkDown).focus(linkHover).blur(linkLeave);
}
$links.click(function() {
clearResetTimer();
});
for (; i < numLinks; i++) {
$links[i] = $($links[i]);
if ($links[i].parent().hasClass('on')) {
current = i;
}
}
$menuButton.click(function() {
gnb.open($menuButton, function() {
$subNav.removeClass('hide');
});
$subNav.addClass('hide');
return false;
});
$preButtonClone.appendTo($header);
function clearResetTimer() {
clearTimeout(resetTimer);
}
function linkHover() {
clearResetTimer();
setBar(this.parentNode);
}
function linkLeave() {
clearResetTimer();
resetTimer = setTimeout(reset, 250);
}
function linkDown() {
setBar(this.parentNode, true);
}
function reset() {
if (single) {
current = $subNav.find('.on').index();
}
setBar($links[current][0]);
}
function setBar(target, noAni) {
var lPoint = target.offsetLeft;
if ($('html').hasClass('rtl')) {
var ulwidth = $scroller.children('ul').width();
var awidth = target.offsetWidth;
lPoint = -(ulwidth - lPoint) + awidth;
}
if (!$subNav.hasClass('hold')) {
$bar.stop()['_'+ (noAni ? 'css' : 'animate')]({translate3dX: lPoint, width: target.offsetWidth},
{duration: 550, easing: 'easeOutCubic', force3D: true});
}
}
function setScroll(noRefresh) {
var scrollLeft = $links[current][0].offsetLeft-$scroller[0].offsetWidth/2+$links[current][0].offsetWidth/2;
if (iScroll) {
iScroll.scrollTo(-scrollLeft, 0);
iScroll.refresh();
} else {
if (noRefresh!==true) {
$scroller.__css({scrollLeft: scrollLeft}, {duration: 550, easing: 'easeOutCubic', force3D: true});
} else {
$scroller.stop().__animate({scrollLeft: scrollLeft}, {duration: 550, easing: 'easeOutCubic', force3D: true});
}
}
}
function display() {
$subNav.addClass('show');
setScroll();
resize();
}
function reposition() {
if (!GALAXY.isGalaxy) {
firstBoxTop = $firstBox.offset().top;
}
var top = Math.min(GALAXY.areaHeight, firstBoxTop+firstBoxHeight-GALAXY.scrollTop)-subNavHeight,
needSwap = swapBase > top,
needFixed = GALAXY.scrollTop >= firstBoxTop+firstBoxHeight-subNavHeight;
if (needSwap != fixed) {
fixed = needSwap;
$wrap.decideClass('subnav-fixed', fixed);
if (isMobile) {
if (fixed) {
$preButtonClone._stop().css('opacity', 0);
} else {
$preButtonClone.css({opacity: 1});
}
}
}
$subNav.css({position: needFixed ? 'fixed' : '', left: needFixed ? $contents.offset().left : 0, top: needFixed ? Math.max(top, maxTop) : firstBoxHeight-subNavHeight});
if ($contents.hasClass('new_') && needFixed) {
$subNav.addClass('newNav');
} else if (!needFixed){
$subNav.removeClass('newNav');
}
}
function scroll(v) {
reposition();
$wrap.decideClass('subnav-passed', GALAXY.sizeMode == 1 && v > 80);
}
function resize() {
var sizeMode = GALAXY.sizeMode;
firstBoxTop = $firstBox.offset().top;
firstBoxHeight = $firstBox[0].offsetHeight;
subNavHeight = $subNav[0].offsetHeight;
swapBase = sizeMode > 2 ? 75 : 0;
maxTop = sizeMode > 2 ? 0 : sizeMode > 1 ? -29 : -19;
$line.css('width', '').css('width', $scroller[0].scrollWidth);
setBar($links[current][0], true);
reposition();
if (iScroll) {
iScroll.refresh();
setScroll();
}
}
return {
display: display,
scroll: scroll,
resize: resize,
reset: reset,
setScroll: setScroll
}
})();
function resize() {
GALAXY.noScroll.resize();
gnb.resize();
subNav.resize();
}
return {
scroll: function(v) {
gnb.scroll(v);
subNav.scroll(v);
},
resize: resize,
onKeyVisualShow: function() {
subNav.display();
},
resetSubNav: function() {
subNav.setScroll(true);
subNav.reset();
}
}
},
sections: function() {
var
$wrap = $('#wrap'),
$contents = $('#contents'),
$sections = $contents.children('[class^="m_"]'),
$subNav = $wrap.find('#subnav'),
$blocks = [],
$children = null,
keyvisual = null,
keyvisualType2 = null,
controls = [],
isMobile = GALAXY.isMobile,
isPoorBrowser = GALAXY.isPoorBrowser,
transformName = $.support.transform,
supportTransition = $.support.transition,
supportTransform = $.support.transform,
parallaxAble = GALAXY.parallaxAble,
parallaxAbleTypes = /^(x|y|s|a|c)$/,
parallaxFloatTypes = /^(s|a)$/,
i = 0, j = 0, numSections = $sections.length,
k, kmax,
numBlocks;
if ($.browser.ie && $.support.canvas) {
!$(document.documentElement).hasClass('s1') && $sections.not('#kv, .m_spec_list').find('span[class*="ico_obj-"]').each(function() {
GALAXY.imageResizeViaCanvas(this.children[0], this.children[0].offsetWidth, this.children[0].offsetHeight);
});
!$(document.documentElement).hasClass('s1') && !$(document.documentElement).hasClass('s2') && $sections.filter('.m_spec_list').find('span[class*="ico_obj-"]').each(function() {
GALAXY.imageResizeViaCanvas(this.children[0], 200, 200);
});
}
for (; i < numSections; i++, j++) {
$blocks[j] = $($sections[i]);
controls[j] = createControls($blocks[j]);
if (!controls[j]) {
for ($children = $blocks[j].children('[class^="m_"]'), k = 0, kmax = $children.length; k < kmax; j++, k++) {
$blocks[j] = $($children[k]);
controls[j] = createControls($blocks[j]);
}
if (kmax) {
j--;
} else {
controls[j] = getArticleControl($blocks[j]);
}
}
}
numBlocks = $blocks.length;
$contents.find('a[data-layer-toggle]').each(GALAXY.setLayerToggler);
$.browser.ie && $('[class*="logo_galaxy-"] img').each(function() {
var ieFix = this.getAttribute('data-ie-fix');
if (ieFix != 'no') {
this.src = this.src.replace('.png', (ieFix || '_ie') +'.png');
}
});
keyvisual = (function() {
var $visual = $sections.filter('#kv, #kv-type2'),
$article = $visual.find('article'),
$title = $article.find('[class*="f_header-"] .kv-title'),
$text = $article.find('[class*="f_header-"] .kv-text'),
$figure = $article.find('figure'),
$image = $figure.find('img'),
$video = $figure.find('video'),
$preButton = $article.find('div.f_btn_pre'),
imageDisplayed = false,
tryToVideoPlay = false,
minWidthBound = 0.75,
sizeMode, areaWidth, areaHeight,
show = false,
type, setImage;
if (!$visual.length) {
GALAXY.header.onKeyVisualShow();
return {resize: $.noop};
}
type = $visual.attr('id').match('kv-type([0-9])');
type = type ? parseInt(type[1]) : 1;
if (!isPoorBrowser) {
$title.css({opacity: 0});
$text.css({opacity: 0});
$figure.css({opacity: 0});
$preButton.css({opacity: 0});
$article.bind({'video-play-kv': videoPlay, 'video-pause-kv': videoPause});
}
$title.show();
$text.show();
$preButton.show();
function videoPlay() {
tryToVideoPlay = true;
if (imageDisplayed) {
$article.trigger('video-play');
}
}
function videoPause() {
tryToVideoPlay = false;
$article.trigger('video-pause');
}
function onImageShow() {
imageDisplayed = true;
tryToVideoPlay && videoPlay();
}
function getMobileImageHeight() {
for (var i = 0; i < $image.length; i++) {
if ($image[i].offsetHeight) {
return $image[i].offsetHeight;
}
}
}
setImage = {
1: function() {
var imageWidth = areaHeight/9*16,
visualTop = '',
visualWidth = Math.min(areaWidth, 1920),
visualHeight = areaHeight;
if (sizeMode > 2) {
if (visualWidth > imageWidth) {
imageWidth = visualWidth;
}
if (imageWidth*minWidthBound > visualWidth) {
imageWidth = visualWidth/(minWidthBound*10)*10;
visualHeight = Math.round(imageWidth/16*9);
}
if (imageWidth/16*9 > visualHeight) {
visualTop = (visualHeight-imageWidth/16*9)/2;
}
} else {
imageWidth = visualWidth = areaWidth;
$figure.css('width', areaWidth);
visualTop = (areaHeight-getMobileImageHeight())/2;
visualHeight = areaHeight;
}
$visual.css({height: visualHeight});
$figure.css({top: visualTop, width: imageWidth, marginLeft: Math.min(0, (visualWidth-imageWidth)/2)});
$video.css('height', imageWidth*0.5625);
setImage.after(500, 1500, $text.length ? 3000 : 2000, 1500);
},
2: function() {
setImage.after(1000, 500, 2000);
},
after: function(delayForTitle, delayForText, delayForPreButton) {
if (!show) {
if ($title.get(0)) {
$title.parent().show();
} else {
$text.parent().show();
}
if ($article.hasClass('invisible')) {
if (!isPoorBrowser) {
$title.css({opacity: 1});
$text.css({opacity: 1});
$preButton.css({opacity: 1});
$figure.css({opacity: 1});
}
onImageShow();
} else {
if (!isPoorBrowser) {
if (GALAXY.sizeMode>1) {
setTimeout(function() {
$title._animate({opacity: 1}, {queue: false, duration: 1500, delay: delayForTitle, easing: 'easeInOutQuad'});
$text._animate({opacity: 1}, {queue: false, duration: 1250, delay: delayForText, easing: 'easeInOutQuad', complete: onImageShow});
$preButton._animate({opacity: 1}, {queue: false, duration: 750, delay: delayForPreButton, easing: 'easeInOutQuad'});
$figure._animate({opacity: 1}, {queue: false, duration: 1300, easing: 'easeInOutQuad'});
}, 500);
} else {
$title.css({opacity: 1});
$text.css({opacity: 1});
$preButton.css({opacity: 1});
$figure.css({opacity: 1});
onImageShow();
}
}
}
show = true;
}
GALAXY.header.onKeyVisualShow();
}
}
return {
scroll: function(v) {
},
resize: function resize(_sizeMode) {
sizeMode = _sizeMode;
areaWidth = Math.min(GALAXY.areaWidth, 1920);
areaHeight = GALAXY.areaHeight;
GALAXY.loadImage($image, setImage[type]);
}
};
})();
function createControls($section) {
var className = $section.attr('class') || '',
$children = $section.children().not('nav'),
i = 0, numChildren = $children.length;
if ((/^m_feature/).test(className) && (/article/i).test($section[0].nodeName)) {
return getArticleControl($section);
} else if (numChildren == 1) {
if (className.indexOf('m_product_gallery') != -1) {
return getProductGalleryControl($section);
} else if (className.indexOf('m_content-colorset') != -1) {
return getProductColorsetControl($children);
} else if (className.indexOf('m_content-video') != -1) {
return getVideoControl($children);
} else {
return getArticleControl($children);
}
} else if (className) {
if (className.indexOf('m_spec_list') != -1) {
return getSpecListControl($section);
} else if (className.indexOf('m_content-slider') != -1) {
return getSliderControl($section);
} else if (className.indexOf('m_content-tab') != -1) {
return getTabControl($section);
}
}
}
function getVideoControl($article) {
var $figureContainer = $article.find('.f_container'),
$playButton = $figureContainer.find('a'),
control = getArticleControl($article),
added = false,
videoId = '';
control.name = 'video';
$playButton.click(function() {
if (!added) {
videoId = $playButton.attr('href').split('?v=')[1];
if (supportTransition) {
GALAXY.setTransitionEndEvent($playButton.find('img.play'), addVideo);
$article.parent().addClass('video-added');
} else {
addVideo();
}
added = true;
}
return false;
});
function addVideo() {
$('')
.appendTo($article).focus();
}
return control;
}
function getProductColorsetControl($article) {
var $buttons = $article.find('nav a'),
$images = $article.find('.f_container figure'),
$fakeSlider = null,
$fakeSliderItems = null,
control = getArticleControl($article),
prevColor = 0,
nowColor = 0,
i = 0, numColors = $buttons.length;
if (!$images.get(0)||$images.length<2) {
return getArticleControl($article);
}
control.name = 'colorset';
if (GALAXY.swipeAble) {
$fakeSlider = $('');
$fakeSliderItems = [];
}
for (; i < numColors; i++) {
$buttons[i] = $($buttons[i]).attr('data-index', i)
.bind('click touchend', changeColor);
$images[i] = $($images[i]).show();
if (i && !isPoorBrowser) {
$($images[i]).css('opacity', 0);
}
if ($fakeSlider) {
$fakeSliderItems[i] = $('').appendTo($fakeSlider);
}
}
$images[0].css('zIndex', 1);
if ($fakeSlider) {
$fakeSlider.appendTo($article);
$fakeSlider.xlider({
endless: true,
swipe: true,
onMove: function(v) {
var percent = Math.abs(v)/$fakeSlider[0].offsetWidth;
$images[nowColor]._css({opacity: 1-percent});
$images[0 > v ? nowColor == numColors-1 ? 0 : nowColor+1 : !nowColor ? numColors-1 : nowColor-1]
.css('opacity', percent);
},
onChange: function(page) {
setButtons(page);
},
onChangeEnd: function(page) {
$images[nowColor]._css('translate3dX', 0);
changed(page);
onColorChanged();
}
});
}
function changeColor() {
var index = parseInt(this.getAttribute('data-index'));
if (nowColor != index) {
if (!isPoorBrowser) {
$images[index].stop().css({zIndex: 1, opacity: 0}).show()
._animate({opacity: 1}, {queue: false, duration: 500, easing: 'easeInOutSine', step: onChanging, complete: onColorChanged});
} else {
$images[index].show();
$images[nowColor].hide();
}
setButtons(index);
changed(index);
}
return false;
}
function setButtons(index) {
$buttons[nowColor].removeClass('on');
$buttons[index].addClass('on');
}
function changed(index) {
prevColor = nowColor;
nowColor = index;
}
function onChanging(v) {
$images[prevColor].css('opacity', 1-v.opacity);
}
function onColorChanged() {
$images[prevColor].css('zIndex', 0);
}
return control;
}
function getSpecListControl($section) {
var
$mask = $section.find('div.m_inner'),
$list = $mask.find('> ul'),
$moreButton = $section.find('div.m_more a'),
$moreButtonText = $moreButton.find('em'),
control = getArticleControl($section),
opened = false;
control.name = 'spec';
$moreButton.click(more);
$moreButtonText.html('Learn more');
if (GALAXY.hashMenu == 'spec') {
setTimeout(more, 1000);
}
function more() {
if (!opened) {
GALAXY.setHash('spec');
GALAXY.setSmoothScrollTop($section[0].offsetTop + ($subNav.length ? -$subNav[0].offsetHeight : 0), 750);
$mask._animate({height: $list[0].offsetHeight}, {queue: false, duration: 750, easing: 'easeInOutQuint', complete: onMore});
opened = true;
} else {
less();
}
return false;
}
function onMore() {
$mask.addClass('on').css('height', '');
$moreButtonText.html('Close');
}
function less() {
var $checker, lessHeight;
if (opened) {
GALAXY.setHash('');
$checker = $mask.clone().removeClass('on').appendTo($mask.parent());
lessHeight = $checker[0].offsetHeight;
$checker.remove();
$mask.__animate({height: lessHeight}, {queue: false, duration: 750, easing: 'easeInOutQuart', complete: onLess});
opened = false;
}
}
function onLess() {
$mask.removeClass('on').css('height', '');
$moreButtonText.html('Learn more');
}
return control;
}
function getProductGalleryControl($section) {
var
$body = $(document.body),
$sliders = $section.find('div.m_list'),
$sliderItems = [],
$nav = $section.find('nav'),
$prev = $nav.find('a[class$=prev]'),
$next = $nav.find('a[class$=next]'),
$colors = $nav.find('div.c_paging-type2 a'),
$items = [],
$opener = null,
hashname = $section.attr('data-hash-name'),
layerId = $section.attr('data-layer-id'),
$layer = $((layerId===undefined||layerId==='') ? '#layer-gallery' : '#'+layerId),
$layerColorName = $layer.find('.c_txt_ly-type1 em'),
$layerList = $layer.find('ul.ly_gallery_list'),
$layerPrev = $layer.find('button[class$=prev]'),
$layerNext = $layer.find('button[class$=next]'),
$layerPagingBox = $layer.find('div.m_paging_type1'),
$layerClose = $layer.find('button.c_btn_close-type1'),
$baseContentsArea = $('#wrap'),
$baseContentsClickable = null,
$perspectiveImagesForRubbishIE,
lastSettedPerspectiveImageName = 'ie...',
layerAdded = false,
layerSetted = false,
layerPagingClick = false,
hasListImage = $section.attr('data-has-list-image'),
lastSizeMode = -1,
regSizeModeImageName = /(_s[1-4])?\.png/,
colorNames = [],
nowPage = 0,
nowLayerPage = 0,
prevLayerPage = null,
nowColor = 0,
clickAble = true,
isSincing = false,
numSliderItems = $sliders.length,
numPages = $sliders.first().find('> ul').length,
numItems = $sliders.first().find('li').length,
control = getArticleControl($section),
i = 0, j;
if ((hashname === undefined) || (hashname === '')) {
hashname = 'gallay';
}
if (hasListImage) {
hasListImage += ',';
}
$colors.bind('click touchend', changeColor);
for (; i < numSliderItems; i++) {
$sliderItems[i] = $($sliders[i]);
$colors[i] = $($colors[i]).attr('data-index', i);
$items[i] = $sliderItems[i].find('li');
for (j = 0; j < numItems; j++) {
$items[i][j] = $($items[i][j]);
$items[i][j].find('a').attr('data-index', j).click(showLayer);
if (!isMobile && !isPoorBrowser) {
$items[i][j].find('a').bind({mouseenter: itemHover, mouseleave: itemLeave, focus: itemHover, blur: itemLeave});
}
$items[i][j].find('img').attr('src', GALAXY.setMediaBaseURL($items[i][j].find('img').attr('data-image')));
}
colorNames[i] = $colors[i].text();
}
$sliders.xlider({
swipe: GALAXY.swipeAble,
onChange: function(page) {
isSliding = true;
if (!isSincing) {
setButtons(page);
}
},
onChangeEnd: function() {
if (!isSincing) {
isSliding = false;
}
}
});
$prev.click(function() {
for (var i = 0; i < numSliderItems; i++) {
isSincing = i != nowColor;
$sliderItems[i].xlider('prev', i != nowColor);
}
isSincing = false;
return false;
});
$next.click(function() {
for (var i = 0; i < numSliderItems; i++) {
isSincing = i != nowColor;
$sliderItems[i].xlider('next', i != nowColor);
}
isSincing = false;
return false;
});
control.setSizeMode = function(sizeMode) {
if (lastSizeMode != sizeMode) {
hasListImage && setSizeModeImages(sizeMode);
lastSizeMode = sizeMode;
}
resizeLayer();
}
control.name = 'product-gallery';
setButtons(0);
colorChanged();
if (GALAXY.hashMenu == hashname) {
$sliderItems[nowColor].find('a').eq(0).click();
}
function setSizeModeImages(sizeMode) {
var imageSizeMode = (hasListImage.indexOf(sizeMode+',') != -1) ? sizeMode : hasListImage.split(',')[0];
$section.find('div.m_list img').each(function() {
this.src = this.src.replace(regSizeModeImageName, '_s'+ imageSizeMode +'.png');
});
}
function itemHover() {
!isSliding && itemFocusing(parseInt(this.getAttribute('data-index')));
}
function itemLeave() {
!isSliding && itemFocusing(-1);
}
function itemFocusing(index) {
var sizeMode = GALAXY.sizeMode;
for (i = 0, $currentItems = $items[nowColor]; i < numItems; i++) {
$currentItems[i]._stop()._animate({opacity: (index == -1 || i == index) ? 1 : 0.5}, {queue: false, duration: 350, easing: 'easeOutQuad'});
}
}
function showLayer() {
var index = parseInt(this.getAttribute('data-index'));
if (!layerAdded) {
$baseContentsClickable = $baseContentsArea.find('a,input,select,textarea,button,video');
$baseContentsClickable.each(function() {
var tabindex = $(this).attr('tabindex');
if (tabindex!==undefined&&tabindex!==null) {
$(this).data('prev-tabindex', tabindex);
}
$(this).attr('tabindex','-1');
});
$opener = $(this);
setLayerContent();
$layerColorName.html(colorNames[nowColor]);
$layerList.xlider('change', index, true);
if (!isPoorBrowser) {
$layerList[0].children[index].style.opacity = 1;
}
$layer.addClass('show');
GALAXY.setHash(hashname);
GALAXY.noScroll.on();
layerAdded = true;
resizeLayer();
}
return false;
}
function setLayerContent() {
var $images = $sliderItems[nowColor].find('img'),
$imageButtons = $sliderItems[nowColor].find('a'),
$layerImages, i;
if (!layerSetted) {
for (i = 0; i < numItems; i++) {
$('
').appendTo($layerList);
$(''+ $images[i].alt +'').appendTo($layerPagingBox);
}
for ($layerImages = $layerList.find('img'), i = 0; i < numItems; i++) {
$layerImages[i].alt = $images[i].alt;
}
$layerClose.bind('click touchend', hideLayer);
$layerPagingBox.find('a').click(function() {
layerPagingClick = true;
}).each(function(i) {
var omni = $imageButtons.eq(i).attr('data-omni');
if (omni&&omni.length>0) {
$(this).attr({'data-omni':omni}).click(GALAXY.tracking);
}
});
$layerList.xlider({
endless: true,
swipe: GALAXY.swipeAble,
onMove: !isPoorBrowser ? onLayerSliderMove : null,
arrows: [$layerPrev, $layerNext],
paging: $layerPagingBox,
onChange: function(page) {
prevLayerPage = nowLayerPage;
nowLayerPage = page;
},
onChangeEnd: function(page) {
prevLayerPage = null;
layerPagingClick = false;
}
});
$layer.bind('touchmove', GALAXY.preventDefault);
layerSetted = true;
}
for ($layerImages = $layerList.find('img'), i = 0; i < numItems; i++) {
$layerImages[i].src = $images[i].src.replace(regSizeModeImageName, '.png');
}
if (hasListImage && $.browser.ie) {
$perspectiveImagesForRubbishIE = $layerList.find('img[src*="-perspective"]');
}
}
function checkPerspectiveImageSize() {
var imageName;
if ($perspectiveImagesForRubbishIE) {
imageName = $layerList[0].offsetHeight > 650 ? '' : '_m';
if (imageName != lastSettedPerspectiveImageName) {
$perspectiveImagesForRubbishIE.each(function() {
this.src = this.src.replace(/(_m)?\.png/i, imageName +'.png');
});
lastSettedPerspectiveImageName = imageName;
}
}
}
function onLayerSliderMove(now) {
if (layerPagingClick) {
return;
}
return;
var children = $layerList[0].children,
minWidth = $layerList[0].offsetWidth/3,
maxWidth = minWidth*2,
currentIndex = prevLayerPage !== null ? prevLayerPage : nowLayerPage,
percent, i = 0;
for (; i < numItems; i++) {
if (i == currentIndex) {
percent = 1-Math.min(1, Math.abs(now)/minWidth);
children[i].style.opacity = percent;
} else if ((now > 0 && (i == currentIndex-1 || i == numItems-1)) ||
(0 > now && (i == currentIndex+1 || i == 0))) {
percent = Math.max(0, Math.min(1, (Math.abs(now)-maxWidth)/minWidth));
children[i].style.opacity = percent;
}
}
}
function resizeLayer() {
if (layerAdded) {
$layerList.css('marginTop', ($layerList[0].parentNode.offsetHeight-$layerList[0].offsetHeight)/2);
checkPerspectiveImageSize();
}
}
function hideLayer() {
$layer.removeClass('show');
$baseContentsClickable.each(function() {
var tabindex = $(this).data('prev-tabindex');
if (tabindex!==undefined&&tabindex!==null) {
$(this).attr('tabindex',tabindex);
} else {
$(this).removeAttr('tabindex');
}
});
$opener && $opener.focus();
$opener = null;
GALAXY.setHash('');
GALAXY.setTransitionEndEvent($layer, function() {
GALAXY.noScroll.off();
});
layerAdded = false;
lastSettedPerspectiveImageName = '...';
return false;
}
function changeColor() {
var index;
if (clickAble) {
index = parseInt(this.getAttribute('data-index'));
if (index != nowColor) {
clickAble = false;
if (!isPoorBrowser) {
$sliderItems[nowColor]._animate({opacity: 0}, {queue: false, duration: 500, easing: 'easeInOutQuad'});
$sliderItems[index].addClass('over')
.css({zIndex: 1, opacity: 0}).show()
._animate({opacity: 1}, {queue: false, duration: 500, easing: 'easeInOutQuad', complete: colorChanged});
}
nowColor = index;
for (i = 0; i < numSliderItems; i++) {
$($colors[i]).decideClass('on', i == nowColor);
}
if (isPoorBrowser) {
$sliderItems[index].css({zIndex: 1}).show();
colorChanged();
}
}
}
return false;
}
function colorChanged() {
clickAble = true;
for (i = 0; i < numSliderItems; i++) {
$sliderItems[i].removeClass('over').css({zIndex: 0});
if (i != nowColor) {
$sliderItems[i].hide();
}
}
}
function setButtons(_nowPage) {
var i;
nowPage = _nowPage;
$prev.decideClass('hide', !nowPage);
$next.decideClass('hide', nowPage == numPages-1);
isSincing = true;
for (i = 0; i < numSliderItems; i++) {
i != nowColor && $sliderItems[i].xlider('change', nowPage, true);
}
isSincing = false;
}
return control;
}
function getSliderControl($section) {
var $nav = $section.find('> nav'),
$items = $section.children().not('nav, .fixedCont'),
$slider = $items.wrapAll('').parent(),
$prev = $nav.find('a[class*=-prev]'),
$next = $nav.find('a[class*=-next]'),
$pagingBox = $nav.find('[class^="m_paging_type"]'),
$paging = [],
controls = [],
pagingOmnitureBase = $pagingBox.attr('data-omni'),
pagingNameBase = $pagingBox.attr('data-alt'),
pagingIsNumbering = $pagingBox.hasClass('numbering'),
lastVisiblePercent = 0,
lastVisibility = false,
lastInvisibility = true,
regThemeArrow = /m_btn_type([0-9]+)/,
regThemePage = /m_paging_type([0-9]+)/,
themeArrowDefault = 1,
themePageDefault = 1,
nowPage = -1,
i = 0, numItems = $items.length;
if (regThemeArrow.test($prev.attr('class'))) {
themeArrowDefault = parseInt($prev.attr('class').match(regThemeArrow)[1]);
}
if (regThemePage.test($pagingBox.attr('class'))) {
themePageDefault = parseInt($pagingBox.attr('class').match(regThemePage)[1]);
}
if (pagingNameBase == undefined) {
pagingNameBase = $section[0].parentNode.className.indexOf('m_content_sub') != -1 ? 'Sub Feature' : 'Feature';
}
pagingNameBase = pagingNameBase ? pagingNameBase +' ' : '';
for (; i < numItems; i++) {
$items[i] = $($items[i]).bind('tab-changed', setTheme);
if (!pagingIsNumbering) {
$paging[i] = $(''+ pagingNameBase + (i+1) +'')
.click(changePage)
.appendTo($pagingBox);
}
controls[i] = createControls($($items[i]));
}
if (pagingIsNumbering) {
$paging = $('').appendTo($pagingBox);
}
$slider.xlider({
swipe: GALAXY.swipeAble,
onChange: setButtons,
onChangeEnd: setVisibles
});
$prev.click(function() {
$slider.xlider('prev');
return false;
});
$next.click(function() {
$slider.xlider('next');
return false;
});
setButtons(0);
function changePage() {
var page = parseInt(this.getAttribute('data-page'));
$slider.xlider('jump', page);
return false;
}
function setButtons(_nowPage) {
nowPage = _nowPage;
if (pagingIsNumbering) {
$paging.html((nowPage+1) +'/'+ numItems);
} else{
for (i = 0; i < numItems; i++) {
$paging[i].decideClass('on', i == nowPage);
}
}
$prev.decideClass('hide', !nowPage);
$next.decideClass('hide', nowPage == numItems-1);
setTheme();
$section.trigger('xlider-changed', {page: nowPage});
}
function setTheme() {
if (0 > nowPage) {
return;
}
var $currentItem = controls[nowPage].name == 'tab' ? controls[nowPage].getCurrentItem() : $items[nowPage],
themeArrow = $currentItem.attr('data-theme-arrow') || themeArrowDefault,
themePage = $currentItem.attr('data-theme-page') || themePageDefault;
$prev.attr('class', $prev.attr('class').replace(regThemeArrow, 'm_btn_type'+ themeArrow));
$next.attr('class', $next.attr('class').replace(regThemeArrow, 'm_btn_type'+ themeArrow));
$pagingBox.attr('class', $pagingBox.attr('class').replace(regThemePage, 'm_paging_type'+ themePage));
}
function setVisibles() {
setParallax(lastVisiblePercent);
setVisible(lastVisibility);
setInvisible(lastInvisibility);
for (i = 0; i < numItems; i++) {
i != nowPage && controls[i].resetVideo();
}
}
function setParallax(visiblePercent) {
lastVisiblePercent = visiblePercent;
for (var i = 0; i < numItems; i++) {
controls[i].setParallax(visiblePercent);
}
}
function setVisible(visible) {
lastVisibility = visible;
for (var i = 0; i < numItems; i++) {
controls[i].setVisible(i == nowPage ? visible : false);
}
}
function setInvisible(invisible) {
lastInvisibility = invisible;
for (var i = 0; i < numItems; i++) {
controls[i].setInvisible(2 >Math.abs(nowPage-i) ? invisible : true);
}
}
return {
name: 'slider',
resetVideo: function() {
for (var i = 0; i < numItems; i++) {
controls[i].resetVideo();
}
},
setSizeMode: function(sizeMode) {
for (var i = 0; i < numItems; i++) {
controls[i].setSizeMode(sizeMode);
}
},
setParallax: setParallax,
setVisible: setVisible,
setInvisible: setInvisible
}
}
function getTabControl($section) {
var $nav = $section.find('> nav'),
$items = $section.children().not($nav),
$tabs = $nav.find('a'),
$itemHeaders = [],
controls = [],
lastVisibility = false,
lastInvisibility = true,
lastZIndex = 0,
nowIndex = -1,
isNewTabModule = $nav[0].className.indexOf('c_tab2-') != -1,
isFirst = true,
i = 0, numItems = $items.length;
for (; i < numItems; i++) {
$items[i] = $($items[i]);
if (isNewTabModule) {
$itemHeaders[i] = $items[i].find('[class*="f_header-"]');
}
controls[i] = createControls($items[i]);
}
$tabs.click(tabChange).eq(0).click();
function tabChange() {
var index = $tabs.index(this),
i = 0;
if (index != nowIndex) {
nowIndex = index;
$items[index].css({left: 0, zIndex: ++lastZIndex});
if (!isPoorBrowser) {
$items[index].css({opacity: 0})
.animate({opacity: 1}, {queue: false, duration: 500, easing: 'easeInOutQuad', complete: setVisibles});
if (!isFirst&&$.browser.firefox) {
setVisibles();
}
}
$nav.css('zIndex', lastZIndex+1);
$tabs.removeClass('on').eq(index).addClass('on');
$section.trigger('tab-changed');
resize(GALAXY.sizeMode, !isFirst);
if (isFirst) {
$nav.show();
isFirst = false;
}
}
return false;
}
function setVisibles() {
setVisible(lastVisibility);
setInvisible(lastInvisibility);
}
function setVisible(visible) {
lastVisibility = visible;
for (var i = 0; i < numItems; i++) {
controls[i].setVisible(i == nowIndex ? visible : false);
}
}
function setInvisible(invisible) {
lastInvisibility = invisible;
for (var i = 0; i < numItems; i++) {
controls[i].setInvisible(i == nowIndex ? invisible : true);
}
}
function resize(sizeMode, animate) {
for (var i = 0; i < numItems; i++) {
controls[i].setSizeMode(sizeMode);
}
if (isNewTabModule) {
$nav['_'+ (isPoorBrowser || animate !== true ? 'css' : 'animate')]({top: $itemHeaders[nowIndex][0].offsetTop+$itemHeaders[nowIndex][0].offsetHeight},
{duration: 500, easing: 'easeInOutCubic'});
}
}
return {
name: 'tab',
getCurrentItem: function() {
return $items[nowIndex];
},
resetVideo: function() {
for (var i = 0; i < numItems; i++) {
controls[i].resetVideo();
}
},
setSizeMode: resize,
setParallax: function(visiblePercent) {
for (var i = 0; i < numItems; i++) {
controls[i].setParallax(visiblePercent);
}
},
setVisible: setVisible,
setInvisible: setInvisible
}
}
function getArticleControl($article) {
var $figures = $article.find('figure'),
$images = $article.find('figure img'),
$parallaxs = null,
imageSources = [],
parallaxs = [],
videos = [],
hasVideo = false,
videoPlaying = false,
videoHided = false,
show = false,
visible = false,
invisible = false,
isKeyvisual = $article.parent().attr('id') == 'kv',
isParallaxVideo = false,
$parallaxer = $({p: 0}),
parallaxAnimateOption = {queue: false, duration: 850, bystep: false, rounding: false, easing: 'easeOutQuint', step: onParallaxAnimate},
i, j, max;
for (i = 0, max = $figures.length; i < max; i++) {
$figures[i] = $($figures[i]);
$images[i] = $($images[i]);
imageSources[i] = GALAXY.getImageSources($images[i]);
videos[i] = GALAXY.setVideoControl($figures[i], $article);
hasVideo = hasVideo || videos[i];
isParallaxVideo = isParallaxVideo || $figures[i].attr('data-parallax-video');
}
$parallaxs = $article.find('[data-parallax]');
for (i = 0, max = $parallaxs.length; i < max; i++) {
$parallaxs[i] = $($parallaxs[i]);
parallaxs[i] = $parallaxs[i].attr('data-parallax');
if (parallaxs[i]) {
parallaxs[i] = parallaxs[i].split('|');
for (j = 0; j < parallaxs[i].length; j++) {
parallaxs[i][j] = parallaxs[i][j].split(',');
if (parallaxAbleTypes.test(parallaxs[i][j][0])) {
parallaxs[i][j][10] = parallaxs[i][j][0].toLowerCase();
parallaxs[i][j].shift();
} else {
parallaxs[i][j][9] = 'y';
}
if (parallaxs[i][j][9] != 'c') {
parallaxs[i][j][0] = parseFloat(parallaxs[i][j][0]);
parallaxs[i][j][1] = parallaxs[i][j][0]-parseFloat(parallaxs[i][j][1]);
if (parallaxs[i][j][2] !== undefined) {
parallaxs[i][j][5] = parseFloat(parallaxs[i][j][2]);
}
if (parallaxs[i][j][3] !== undefined) {
parallaxs[i][j][6] = parseFloat(parallaxs[i][j][3]);
}
parallaxs[i][j][2] = 0;
parallaxs[i][j][3] = 0;
parallaxs[i][j][4] = 0;
if (parallaxs[i][j][9] == 's') {
parallaxs[i][j][2] = parallaxs[i][j][0];
}
}
}
}
}
function onParallaxAnimate(v) {
for (var properties, value, transform,
i = 0, j, max = $parallaxs.length; i < max; i++) {
for (j = 0, properties = {}, transform = '';
j < parallaxs[i].length; j++) {
if (parallaxs[i][j][9] == 'c') {
continue;
}
value = parallaxs[i][j][3]+(parallaxs[i][j][4]-parallaxs[i][j][3])*v.p;
properties[parallaxs[i][j][9]] = parallaxs[i][j][2] = value;
}
$parallaxs[i][0].style[transformName] = [
'scale(', properties.s !== undefined ? properties.s : 1, ', ', properties.s !== undefined ? properties.s : 1, ')', ' ',
'translate3d(', properties.x || 0, 'px, ', properties.y || 0, 'px, 0)'
].join('');
if (properties.a !== undefined) {
$parallaxs[i][0].style.opacity = properties.a;
}
}
}
function resetVideo() {
hasVideo && $article.trigger('video-reset');
}
return {
name: 'article',
resetVideo: resetVideo,
setSizeMode: function(sizeMode) {
for (var newSrc, i = 0, max = $figures.length; i < max; i++) {
newSrc = imageSources[i][sizeMode];
if ($images[i][0] && $images[i][0].src && $images[i][0].src.indexOf(newSrc) == -1) {
$images[i][0].src = GALAXY.setMediaBaseURL(newSrc);
}
if (hasVideo) {
if (3 > sizeMode && !videoHided) {
$article.trigger('video-hide');
videoHided = true;
} else if (sizeMode > 2) {
if (videoHided) {
$article.trigger('video-show');
videoHided = false;
} else {
if (GALAXY.prevSizeMode!==sizeMode) {
$article.trigger(isKeyvisual ? 'video-play-kv' : 'video-play');
}
}
}
}
}
},
setParallax: function(visiblePercent) {
var i, j, max, valueTo, sizeMode;
if (parallaxAble) {
visiblePercent = Math.max(0, visiblePercent, Math.min(1, visiblePercent));
sizeMode = GALAXY.sizeMode;
$parallaxer._stop();
if (3 > sizeMode) {
for (i = 0, max = $parallaxs.length; i < max; i++) {
for (j = 0; j < parallaxs[i].length; j++) {
parallaxs[i][j][2] = 0;
}
$parallaxs[i][0].style[transformName] = $parallaxs[i][0].style.opacity = '';
}
} else {
for (i = 0, max = $parallaxs.length; i < max; i++) {
for (j = 0; j < parallaxs[i].length; j++) {
if (parallaxs[i][j][9] == 'c') {
window[parallaxs[i][j][0]] && window[parallaxs[i][j][0]](visiblePercent);
} else {
parallaxs[i][j][3] = parallaxs[i][j][2];
valueTo = parallaxs[i][j][0]-parallaxs[i][j][1]*visiblePercent;
if (parallaxs[i][j][5] !== undefined) {
valueTo = Math.max(parallaxs[i][j][5], valueTo);
}
if (parallaxs[i][j][6] !== undefined) {
valueTo = Math.min(parallaxs[i][j][6], valueTo);
}
if (sizeMode == 3 && parallaxs[i][j][9] != 's' && parallaxs[i][j][9] != 'a') {
valueTo *= 0.75;
}
if (!parallaxFloatTypes.test(parallaxs[i][j][9])) {
valueTo = Math.round(valueTo);
}
parallaxs[i][j][4] = valueTo;
}
}
}
$parallaxer[0].p = 0;
$parallaxer._animate({p: 1}, parallaxAnimateOption);
}
if (hasVideo && !videoHided && isParallaxVideo && visiblePercent && 1 > visiblePercent) {
$article.trigger('video-parallax', visiblePercent);
}
}
},
setVisible: function(_visible) {
if (_visible) {
if (!show) {
$article.addClass('show');
show = true;
}
if (!visible) {
$article.addClass('visible').trigger('visible');
visible = true;
}
if (hasVideo && !videoPlaying && !isParallaxVideo) {
$article.trigger(isKeyvisual ? 'video-play-kv' : 'video-play');
videoPlaying = true;
}
} else {
if (visible) {
$article.removeClass('visible');
visible = false;
}
if (hasVideo && videoPlaying && !isParallaxVideo) {
$article.trigger(isKeyvisual ? 'video-pause-kv' : 'video-pause');
videoPlaying = false;
}
}
},
setInvisible: function(_invisible) {
if (_invisible) {
if (!invisible) {
$article.addClass('invisible').trigger('invisible');
resetVideo();
invisible = true;
}
} else {
if (invisible) {
$article.removeClass('invisible');
invisible = false;
}
}
}
}
}
function scroll(scrollTop, maxScrollTop) {
var sizeMode = GALAXY.sizeMode,
areaHeight = GALAXY.areaHeight,
blockTop, blockHeight,
visibleSize, visibleHeight, visiblePercent, visibleBase,
i = 0, j, jmax;
for (; i < numBlocks; i++) {
blockTop = !i ? $blocks[i][0].offsetTop-scrollTop : $blocks[i][0].getBoundingClientRect().top;
blockHeight = $blocks[i][0].offsetHeight;
if (!i) {
visibleSize = 1-((blockHeight+blockTop)/blockHeight);
} else {
visibleSize = -(blockTop-areaHeight)/(areaHeight+blockHeight);
}
if (parallaxAble) {
visiblePercent = visibleSize;
if (visiblePercent >= -0.15 && 1.15 >= visiblePercent) {
controls[i].setParallax(visiblePercent);
}
}
visibleBase = Math.min(blockHeight*0.66, GALAXY.areaHeight*0.66);
visibleHeight = Math.min(areaHeight, 0 >= blockTop ? blockHeight+blockTop : Math.min(blockHeight, areaHeight-blockTop));
controls[i].setVisible(visibleHeight >= visibleBase);
controls[i].setInvisible(0 > visibleSize || visibleSize > 1);
}
keyvisual.scroll && keyvisual.scroll(scrollTop);
}
function resize() {
var i = 0, sizeMode = GALAXY.sizeMode;
for (; i < numBlocks; i++) {
controls[i].setSizeMode(sizeMode);
}
keyvisual.resize(sizeMode);
}
return {
scroll: scroll,
resize: resize
}
},
footer: function() {
if (!$('#footer').length) {
return;
}
var $document = $(document.documentElement),
$footer = $('#footer')
$moreButton = $footer.find('a.c_btn_type3-more'),
$moreContents = $footer.find('div.f_more_content'),
$colors = $footer.find('div.f_colors a');
supporOpacity = $.support.opacity,
topButton = null,
toTopDuration = $.browser.mobile ? 350 : 750,
moreOpened = false,
$baseContentsArea = $('#wrap'),
$baseContentsClickable = null;
$moreButton.keydown(function(e) {
if (e.keyCode==13) {
$(this).data('keydown', 'Y');
}
}).click(toggleMore);
$colors.click(function() {
var highContrastMode = this.title.toLowerCase().indexOf('high contrast') != -1;
$document.decideClass('color_yb', highContrastMode);
$._cookie.set('highContrastMode', highContrastMode ? 1 : 0, 1, '/');
return false;
});
$footer.find('a.c_btn_type3-top').click(toTop);
$footer.find('.f_social_share a').click(GALAXY.sharing);
topButton = (function() {
var $button = $footer.find('div.f_backtotop a'),
$keyvisual = $('#kv'),
hasKeyVisual = !!$keyvisual.length,
rotateBaseTop = 250,
rotated = false,
hidden = false;
if ($('#wrap').attr('data-no-topbutton')) {
$footer.find('div.f_backtotop').remove();
return null;
}
if (!hasKeyVisual) {
$button.addClass('rotate').html('Back to top of page');
$button.addClass('hide');
rotated = true;
}
$button.keydown(function(e) {
if (e.keyCode==13) {
$(this).data('keydown', 'Y');
}
}).click(function() {
if ($(this).data('keydown')!='Y') {
if (!hidden) {
if (rotated) {
toTop();
} else {
GALAXY.setSmoothScrollTop($keyvisual[0].offsetHeight, toTopDuration);
}
$(this).blur();
}
return false;
}
$(this).data('keydown', 'N');
});
return {
scroll: function(v, maxv) {
var footerHeight = $footer[0].offsetHeight + (moreOpened ? 0 : 30);
if (v > rotateBaseTop && !rotated) {
hasKeyVisual ? $button.addClass('rotate').html('Back to top of page') : $button.removeClass('hide');
rotated = true;
} else if (rotateBaseTop >= v && rotated) {
hasKeyVisual ? $button.removeClass('rotate').html('Down') : $button.addClass('hide');
rotated = false;
}
if (maxv-footerHeight > v && hidden) {
$button.removeClass('hide');
hidden = false;
} else if (v >= maxv-footerHeight && !hidden) {
$button.addClass('hide');
hidden = true;
}
}
}
})();
function toTop() {
GALAXY.setSmoothScrollTop(0, toTopDuration);
return false;
}
function toggleMore() {
if (!moreOpened) {
$moreButton.removeClass('on').text('Close');
$moreContents.show();
if (supporOpacity) {
$moreContents.stop().hide().slideDown({queue: false, duration: 500, easing: 'easeOutCubic', step: function(v, a) {
$moreContents.css('opacity', a.now/a.end);
GALAXY.setScrollTop(100000);
}});
} else {
$moreContents.show();
GALAXY.setScrollTop(100000);
}
if ($(this).data('keydown')=='Y') {
$baseContentsClickable = $baseContentsArea.find('a,input,select,textarea,button,video').not('.c_btn_type3-more').not('#terms-and-conditions a');
$baseContentsClickable.each(function() {
var tabindex = $(this).attr('tabindex');
if (tabindex!==undefined&&tabindex!==null) {
$(this).data('prev-tabindex', tabindex);
}
$(this).attr('tabindex','-1');
});
}
moreOpened = true;
try {
location.hash = $moreButton.attr('href').split('#')[1];
} catch(e){}
} else {
$moreButton.addClass('on').text('More');
if (supporOpacity) {
$moreContents.slideUp({queue: false, duration: 250, easing: 'easeOutCubic', step: function(v, a) {
$moreContents.css('opacity', a.now/a.start);
}});
} else {
$moreContents.hide();
}
if ($(this).data('keydown')=='Y'&&$baseContentsClickable&&$baseContentsClickable.length) {
$baseContentsClickable.each(function() {
var tabindex = $(this).data('prev-tabindex');
if (tabindex!==undefined&&tabindex!==null) {
$(this).attr('tabindex',tabindex);
} else {
$(this).removeAttr('tabindex');
}
});
}
moreOpened = false;
GALAXY.setHash('');
}
$(this).data('keydown', 'N');
return false;
}
function scroll(v, maxv) {
topButton && topButton.scroll(v, maxv);
}
function resize(v, maxv) {
}
return {
scroll: scroll,
resize: resize
}
},
setVideoControl: function($figure, $article, $cover) {
var $video = null,
source = '',
setVideoimg = $figure.find('.setting-img'),
isKeyvisual = ($article.attr('class') || '').indexOf('-kv') != -1,
ready = false,
tryToPlay = false,
coverHided = false,
videoHided = false,
preferWebm = false,
tweener = null,
invisible = true,
duration = 0,
noneplay = $figure.attr('data-none-play'),
autoplayText = '';
if (GALAXY.isPoorBrowser || GALAXY.isMobile) {
if ($cover == undefined) {
removeReady();
return false;
}
}
if ($cover == undefined) {
$cover = $figure.find('img:not(".setting-img")');
}
source = $figure.attr('data-media-video');
if (!source) {
return false;
}
if (noneplay === undefined) {
autoplayText = ' autoplay'
}
source = GALAXY.setMediaBaseURL(source);
source = {
mp4: '',
webm: '',
ogv: ''
}
preferWebm = $figure.attr('data-video-prefer-webm');
$video = $([
''].join(''))
.bind({
play: function() {
if (invisible) {
$video[0].pause();
}
},
canplay: function() {
if (!ready) {
ready = true;
duration = this.duration;
!isKeyvisual && GALAXY.sizeMode > 2 && hideCover();
tryToPlay && play();
}
removeReady();
},
ended: function() {
},
error: function() {
removeReady();
}
})
.insertBefore($cover);
setTimeout(function() {
$video[0].load();
}, 0);
$article.bind({
visible: function() {
invisible = false;
}, invisible: function() {
invisible = true;
},
'video-play': play, 'video-pause': pause, 'video-reset': reset, 'video-show': show, 'video-hide': hide, 'video-parallax': parallax});
function removeReady() {
if(setVideoimg) {
setVideoimg.remove();
}
}
function play() {
tryToPlay = true;
if (ready && !videoHided && (noneplay != 'none')) {
hideCover();
videoPlay();
}
}
function videoPlay() {
$video.css('opacity', '')[0].play();
}
function hideCover() {
if (ready && !coverHided) {
$cover.css('visibility', 'hidden');
$video.css('visibility', '');
coverHided = true;
}
}
function pause() {
tryToPlay = false;
ready && $video[0].pause();
}
function reset() {
if (ready) {
$video[0].pause();
$video[0].currentTime = 0;
}
}
function show() {
hideCover();
videoHided = false;
ready && tryToPlay && videoPlay();
}
function hide() {
if (coverHided) {
$video[0].pause();
$cover.css('visibility', '');
$video.css('visibility', 'hidden');
coverHided = false;
}
videoHided = true;
}
var parallaxer = {currentTime: 0},
prevVideoTime = 0;
function parallax(e, visiblePercent) {
if (ready) {
visiblePercent = Math.max(0, Math.min(1, (visiblePercent*1.25)-0.125));
tweener && tweener.kill();
tweener = TweenMax.to(parallaxer, 0.5, {
startAt: {currentTime: $video[0].currentTime},
currentTime: Math.min(duration-0.05/* ie11 bug */, duration*visiblePercent),
ease: 'easeOutQuad',
lazy: true,
onUpdate: function() {
$video[0].currentTime = parallaxer.currentTime;
return;
var current = Math.round(parallaxer.currentTime*10000)/10000;
if (prevVideoTime != current) {
$video[0].currentTime = current;
prevVideoTime = current;
}
}
});
}
}
return true;
},
setLayerToggler: function() {
var $button = $(this),
$layer = $($button.attr('href')),
$layerTitle = $layer.find('.layer-title'),
$opener = null,
opened = false;
if (!$layer.length) {
return;
}
$button.click(function() {
$opener = $button;
show();
return false;
});
$layer.find('button[class*="c_btn_close"]').click(hide);
function show() {
if (!opened) {
$layer.addClass('show');
GALAXY.noScroll.on();
$layerTitle.focus();
opened = true;
}
}
function hide() {
if (opened) {
$layer.removeClass('show');
$opener && $opener.focus();
$opener = null;
GALAXY.setTransitionEndEvent($layer, function() {
GALAXY.noScroll.off();
});
opened = false;
}
}
},
vodPlayer: (function() {
var $layer, $layerTitle, $iframeBox, $iframe, $closeButton,
$opener = null,
opened = false,
$baseContentsArea = null,
$baseContentsClickable = null,
isKeydown = false;
function show(url, opener, autoplay) {
var id = url.split('?v=')[1];
if (!$layer) {
$layer = $([
'',
'
Movie player Layer',
'',
'
',
'
',
'
'
].join(''));
$layerTitle = $layer.find('span.layer-title');
$iframe = $layer.find('iframe');
$iframeBox = $iframe.parent();
$closeButton = $layer.find('button[class*="_btn_close"]');
$closeButton.one('keydown', function() {
isKeydown = true;
});
$closeButton.bind('click touchend', hide);
$layer.bind('touchmove', GALAXY.preventDefault)
.appendTo(document.body);
}
$baseContentsArea = $('#wrap');
$baseContentsClickable = $baseContentsArea.find('a,input,select,textarea,button,video');
$baseContentsClickable.each(function() {
var tabindex = $(this).attr('tabindex');
if (tabindex!==undefined&&tabindex!==null) {
$(this).data('prev-tabindex', tabindex);
}
$(this).attr('tabindex','-1');
});
if (!opened) {
if (opener) {
$opener = $(opener);
}
$iframe.attr('src', GALAXY.getYoutubePlayerLink(id, autoplay)).appendTo($iframeBox);
$layer.addClass('show');
$layerTitle.focus();
GALAXY.noScroll.on();
opened = true;
}
}
function hide() {
if (opened) {
$layer.removeClass('show');
$baseContentsClickable.each(function() {
var tabindex = $(this).data('prev-tabindex');
if (tabindex!==undefined&&tabindex!==null) {
$(this).attr('tabindex',tabindex);
} else {
$(this).removeAttr('tabindex');
}
});
isKeydown && $opener && $opener.focus();
$opener = null;
GALAXY.setTransitionEndEvent($layer, function() {
$iframe.attr('src', 'about:blank').detach();
GALAXY.noScroll.off();
});
opened = false;
}
isKeydown = false;
}
return {
show: show,
hide: hide
}
})(),
getYoutubePlayerLink: function(id, autoplay) {
return 'https://www.youtube.com/embed/'+ id +'?enablejsapi=1&version=3&autoplay='+ (autoplay ? 1 : 0) +'&wmode=opaque';
},
imageResizeViaCanvas: (function() {
function canvasResizer(_image, width, height, widthTo, heightTo, callback) {
var canvas = document.createElement('canvas'),
context = canvas.getContext('2d'),
image = new Image();
image.onload = function() {
canvas.width = widthTo;
canvas.height = heightTo;
context.drawImage(image, 0, 0, widthTo, heightTo);
this.onload = null;
this.src = canvas.toDataURL();
callback(this);
}
image.src = _image.src;
}
return function(image, widthTo, heightTo) {
var resizedImage = new Image(),
nowWidth, nowHeight;
resizedImage.onload = function() {
nowWidth = this.width;
nowHeight = this.height;
this.onload = null;
check(this);
}
resizedImage.src = image.src;
function check(_image) {
resizedImage = _image;
if (nowWidth/2 > widthTo && nowHeight/2 > heightTo) {
canvasResizer(resizedImage, nowWidth, nowHeight, nowWidth/2, nowHeight/2, check);
nowWidth = nowWidth/2;
nowHeight = nowHeight/2;
} else if (nowWidth) {
canvasResizer(resizedImage, nowWidth, nowHeight, widthTo, heightTo, check);
nowWidth = nowHeight = 0;
} else {
image.src = resizedImage.src;
}
}
}
})(),
noScroll: (function() {
var $documentElement,
$wrap,
$header,
$headerButtonBox,
$gnbBox,
$gnbCloseButton,
$subNavGnbBox,
$topButtonBox,
scrollBarWidth;
function assign() {
$documentElement = $(document.documentElement);
$wrap = $('#wrap');
$header = $(GALAXY.isGalaxy?'#header':GALAXY.dom.header);
$headerButtonBox = $header.find('p.link');
$gnbBox = $('#gnb');
$gnbContentsBox = $gnbBox.find('.g-contents');
$gnbCloseButton = $gnbBox.find('p.g-close a');
$subNavGnbBox = $('#subnav p.gnb');
$subNavPreButton = $('#subnav p.pre-button');
$topButtonBox = $('div.f_backtotop');
scrollBarWidth = GALAXY.scrollBarWidth;
}
return {
activated: false,
on: function() {
var paddingRight = 0;
!$documentElement && assign();
GALAXY.scrollFixSkip = true;
$documentElement.addClass('no-scroll').css('paddingRight', scrollBarWidth);
if (GALAXY.areaWidth > 1920+scrollBarWidth) {
paddingRight = scrollBarWidth;
$gnbBox.css('paddingRight', paddingRight);
$gnbBox.addClass('wide');
} else {
$gnbBox.removeClass('wide');
}
$gnbContentsBox.css('right', scrollBarWidth-paddingRight);
$gnbCloseButton.css('marginRight', scrollBarWidth-paddingRight);
$topButtonBox.css('paddingRight', scrollBarWidth);
if ($wrap.hasClass('subnav-fixed')) {
$subNavGnbBox.css('marginRight', scrollBarWidth-paddingRight);
$subNavPreButton.css('marginRight', scrollBarWidth-paddingRight);
}
GALAXY.noScroll.activated = true;
GALAXY.noScroll.resize();
},
off: function() {
GALAXY.noScroll.activated = false;
GALAXY.scrollFixSkip = false;
$documentElement.removeClass('no-scroll').css('paddingRight', '');
$gnbBox.css('paddingRight', '');
$gnbContentsBox.css('right', '');
$gnbCloseButton.css('marginRight', '');
$topButtonBox.css('paddingRight', '');
$subNavGnbBox.css('marginRight', '');
$subNavPreButton.css('marginRight', '');
GALAXY.noScroll.resize();
},
resize: function() {
!$documentElement && assign();
if (GALAXY.isPoorBrowser) {
return;
}
var marginRight = Math.round((GALAXY.areaWidth-$header[0].offsetWidth)/2); //$header[0].offsetWidth
if (GALAXY.noScroll.activated) {
marginRight += GALAXY.scrollBarWidth;
}
$headerButtonBox.css('marginRight', marginRight);
}
}
})(),
setOverflowYEdges: function($target) {
var pointYAtStart, getPoint = $._event.getpoint;
$target.bind('touchstart', function(e) {
pointYAtStart = GALAXY.getEventPoint(e)[1];
});
$target.bind('touchmove', function(e) {
var pointY = GALAXY.getEventPoint(e)[1];
if (
( this.scrollTop === 0 && pointY > pointYAtStart ) ||
( this.scrollTop >= this.scrollHeight-this.offsetHeight && pointYAtStart > pointY )
) {
e.preventDefault();
return false;
}
e.stopPropagation();
return true;
});
},
getImageSources: function($image) {
var s4 = $image.attr('data-media-s4') || $image.attr('src'),
s3 = $image.attr('data-media-s3') || s4,
s2 = $image.attr('data-media-s2') || s3,
s1 = $image.attr('data-media-s1') || s2;
return [null, s1, s2, s3, s4];
},
setTabFocusTrap: function($box, $toFocus, tabIndex) {
$('')
.focus(function() {
$toFocus.focus();
})
.appendTo($box);
},
getEventType: $._event.gettype,
getEventPoint: $._event.getpoint,
setTransitionEndEvent: (function() {
var supportTransition = $.support.transition,
transitionEndName = 'transitionend webkitTransitionEnd mozTransitionEnd oTransitionEnd msTransitionEnd';
return function($target, callback) {
if (supportTransition) {
$target.bind(transitionEndName, function(e) {
if (e.target == this) {
callback.call(this);
$target.unbind(transitionEndName);
}
});
} else {
callback.call($target[0]);
}
}
})(),
loadImage: function($image, callback) {
if ($image[0].complete) {
$image.unbind({load: callback});
callback.call($image);
} else {
$image.bind({load: callback});
$image[0].src = $image[0].src;
}
},
setMediaBaseURL: function(mediaBaseURL) {
return function(src) {
return (/^(http|\/global\/)/).test(src)||(''+src).indexOf('.')==0 ? src : mediaBaseURL+src;
}
},
sharing: function() {
var
$body = $(document.body),
provider = GALAXY.stripTags(this.innerHTML).replace(/ /g, '').toLowerCase(),
bodyDataURL = $body.attr('data-url'),
url = encodeURIComponent(this.getAttribute('data-share-url') || (!bodyDataURL || bodyDataURL == '-' ? location.href : bodyDataURL)),
message = encodeURIComponent(this.getAttribute('data-share-msg') || $body.attr('data-msg') || 'The Galaxy S6 is here.'),
tags = encodeURIComponent(this.getAttribute('data-share-tags') || $body.attr('data-tags') || 'SamsungGalaxyS6,NextIsNow,SamsungMobile'),
popupSize, popupURL, popup;
if (provider == 'facebook') {
popupSize = [560, 525];
popupURL = 'https://www.facebook.com/sharer/sharer.php?u='+ url;
} else if (provider == 'twitter') {
if ($body.attr('data-url') == '-') {
url = null;
}
popupSize = [680, 400];
popupURL = 'https://twitter.com/intent/tweet?text='+ message +'&hashtags='+ tags + (url ? '&url='+ url : '');
} else if (provider == 'googleplus' || provider == 'google+') {
popupSize = [510, 510];
popupURL = 'https://plus.google.com/share?url='+ url;
} else if (provider == 'linkedin') {
popupSize = [550, 500];
popupURL = 'https://www.linkedin.com/shareArticle?url='+ url;
}
popup = GALAXY.popup(popupURL, popupSize[0], popupSize[1], 'shareWindow');
popup && popup.focus();
return false;
},
setHash: function(hash) {
var href = location.href.split('#')[0];
location.replace(href +'#!/'+ (hash || ''));
},
scrollTracking: function() {
var omniCode = $(this).data('omni-scroll-code');
var prevOmniCode = GALAXY.___scroll_omniCode;
GALAXY.___scroll_omniCode = omniCode;
if (omniCode!=null&&omniCode!=''&&omniCode!=prevOmniCode) {
GALAXY.omniture('scroll:'+omniCode);
}
},
tracking: function() {
var omniCode = this.getAttribute('data-omni');
var omniType = this.getAttribute('data-omni-type');
if (omniCode!=null&&omniCode!='') {
GALAXY.omniture(omniCode, omniType);
}
},
omniture: function(name, type) {
var omniTag,
isMicrositeAction = (type&&type!='') ? false : true;
if (GALAXY.isGalaxy) {
omniTag = [
'global:', (window.OMNI_CAMPAIGN_NAME || ''),
name.indexOf(':') !== 0 ? ':'+ (window.OMNI_PAGE_NAME || '') +':'+ name : name
].join('');
if (GALAXY.isTestURL) {
console.log('omniture: "'+ omniTag +'"');
} else {
window.omniture_click && omniture_click(omniTag);
}
} else {
type = (isMicrositeAction) ? 'microsite_action' : type;
if (isMicrositeAction) {
omniTag = [
(window.OMNI_CAMPAIGN_NAME || 'galaxy2016'),
name.indexOf(':') !== 0 ? ':'+ (window.OMNI_PAGE_NAME || '') +':'+ name : name
].join('');
} else {
omniTag = name;
}
if (GALAXY.isTestURL) {
console.log('omniture : "'+ type +'", "'+ omniTag +'"');
} else {
window.sendClickCode && sendClickCode(type, omniTag);
}
}
},
svgFillTween: (function() {
if (!$.browser.ie) {
return function(element, color) {
element.setAttribute('fill', color);
}
} else {
return function(element, color) {
$('span').css('color', element.getAttribute('fill'))
._animate({color: color}, {queue: false, duration: 250, easing: 'easeInOutQuad', step: function(v) {
element.setAttribute('fill', v.color);
}});
}
}
})(),
popup: function(url, width, height, name) {
return window.open(url, name || '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width='+ (width+GALAXY.scrollBarWidth) +',height='+ height);
},
stripTags: function(text) {
return text.replace(/<[^>]+>/g, '');
},
addZero: function(value) {
return 10 > value ? '0'+ value : value;
},
preventDefault: function(e) {
e.preventDefault();
},
returnFalse: function() {
return false;
},
getScrollTop: function() {
return document.documentElement.scrollTop || document.body.scrollTop || 0;
},
getScrollHeight: function() {
return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
},
getMaxScrollTop: function() {
return GALAXY.getScrollHeight()-GALAXY.areaHeight;
},
setScrollTop: function(v) {
$(window).scrollTop(v);
},
setSmoothScrollTop: function(v, time, callback) {
$('html, body')._animate({scrollTop: v}, {queue: false, duration: time || 1000, easing: 'easeInOutQuart', complete: callback});
},
getScrollBarWidth: function() {
var div = document.createElement('div'), scrollBarWidth;
div.style.cssText = 'position: absolute; left: -999em; width: 100px; height: 100px; overflow: scroll;';
document.body.appendChild(div);
scrollBarWidth = 100-div.clientWidth;
document.body.removeChild(div);
div = null;
return scrollBarWidth;
},
scroll: (function(e) {
var
ie = navigator.userAgent.match(/(?:msie ([0-9]+)|rv:([0-9\.]+)\) like gecko)/i),
webkit = (/applewebkit/i).test(navigator.userAgent),
documentElement = document.documentElement,
scrollCaptured = false,
lastScrollTop = 0,
maxScrollTop = 0;
if ((/win/i).test(navigator.appVersion) && ie) {
$(documentElement)
.bind('mousewheel', function(e) {
if (GALAXY.scrollFixSkip === true) {
return true;
}
scrollFix(e.originalEvent.wheelDelta*-1);
e.preventDefault();
})
.bind('keydown', function(e) {
if (GALAXY.scrollFixSkip) {
return true;
}
var keyCode = e.keyCode, documentHeight = documentElement.clientHeight, newScrollTop;
if ((/^(32|33|34|38|40)$/).test(keyCode)) {
scrollFix(keyCode == 32 || keyCode == 34 ? documentHeight : keyCode == 33 ? -documentHeight : keyCode == 38 ? -75 : 75);
e.preventDefault();
}
});
}
function scrollFix(scrollBy) {
var newScrollTop = Math.min(getMaxScrollTop(), Math.max(0, getScrollTop()+scrollBy));
if (newScrollTop != lastScrollTop) {
scroll(newScrollTop);
scrollCaptured = true;
document[webkit ? 'body' : 'documentElement'].scrollTop = newScrollTop;
}
}
function getScrollTop() {
return documentElement.scrollTop || (document.body ? document.body.scrollTop : 0) || 0;
}
function getMaxScrollTop() {
return Math.max(document.body ? document.body.scrollHeight : 0, documentElement.scrollHeight)-Math.min(documentElement.offsetHeight, documentElement.clientHeight);
}
function scroll(_scrollTop) {
var scrollTop = typeof(_scrollTop) == 'number' ? _scrollTop : getScrollTop();
lastScrollTop = scrollTop;
if (scrollCaptured) {
scrollCaptured = false;
return false;
}
GALAXY.scrollTop = scrollTop;
maxScrollTop = getMaxScrollTop();
GALAXY.scrollTop = scrollTop;
GALAXY.header && GALAXY.header.scroll && GALAXY.header.scroll(scrollTop, maxScrollTop);
GALAXY.sections && GALAXY.sections.scroll && GALAXY.sections.scroll(scrollTop, maxScrollTop);
GALAXY.footer && GALAXY.footer.scroll && GALAXY.footer.scroll(scrollTop, maxScrollTop);
if (GALAXY.scrollFunctions.length) {
$.each(GALAXY.scrollFunctions, function() {
this(scrollTop, maxScrollTop);
});
}
}
return scroll;
})(),
resize: function(ignore) {
var documentElement = document.documentElement,
width, height, sizeMode;
width = documentElement.clientWidth;
if (GALAXY.isPoorBrowser) {
width = Math.max(document.getElementById('wrap').offsetWidth, width);
}
height = $(window).height();
if (ignore !== true) {
if (!$.browser.mobile && width == GALAXY.areaWidth && height == GALAXY.areaHeight) {
return;
} else if ($.browser.mobile && width == GALAXY.areaWidth) {
return;
}
}
sizeMode = width > 1440 ? 4 : width > 1023 ? 3 : width > 767 ? 2 : 1;
GALAXY.prevSizeMode = GALAXY.sizeMode;
if (sizeMode != GALAXY.sizeMode) {
GALAXY.sizeMode = sizeMode;
documentElement.className = documentElement.className.replace(/ *s[1-4][1-4]?/g, '') +' s'+ sizeMode +' s'+ (sizeMode > 2 ? 34 : 12);
}
documentElement.className = documentElement.className.replace(/ *s0/, '') + (360 > width ? ' s0' : '');
GALAXY.areaWidth = width;
GALAXY.areaHeight = height;
GALAXY.header && GALAXY.header.resize && GALAXY.header.resize();
GALAXY.sections && GALAXY.sections.resize && GALAXY.sections.resize();
GALAXY.footer && GALAXY.footer.resize && GALAXY.footer.resize();
GALAXY.noScroll.resize();
if (GALAXY.resizeFunctions.length) {
$.each(GALAXY.resizeFunctions, function() {
this();
});
}
GALAXY.scroll();
},
initialize: function() {
if (this.initialized) {
return;
}
this.initialized = true;
if (!this.isGalaxy) {
this.path.root = '..';
this.mediaBaseURL = '.';
}
$(document.documentElement)
.addClass($.browser.mobile ? 'mobile' : 'desktop')
.decideClass('oldandroid', $.browser.android && 430 > $.browser.android)
.decideClass('color_yb', $._cookie.get('highContrastMode') == '1');
this.hashMenu = location.href.split('#!/')[1];
this.hashMenu && this.isTestURL && console.log('hash menu: "'+ this.hashMenu + '"');
this.mediaBaseURL = this.mediaBaseURL.replace(/\/$/, '');
this.setMediaBaseURL = this.setMediaBaseURL(this.mediaBaseURL);
this.scrollBarWidth = this.getScrollBarWidth();
if (!$(document.body).attr('data-url') || (/bit\.ly\/?$/i).test($(document.body).attr('data-url'))) {
$(document.body).attr('data-url', '-');
}
$('body style').each(function() {
this.removeAttribute('scoped');
});
if (GALAXY.isGPSI) {
this.resize(true);
$('body img')
.not('#kv [class*="f_header-"] img')
.not('div.gift_header .heading img')
.not('div.theme-steps div.img img')
.each(function(i) {
var $image = $(this),
source = GALAXY.setMediaBaseURL(GALAXY.getImageSources($image)[GALAXY.sizeMode].replace(/^\./, ''));
$image.attr('src', GALAXY.path.root+'/common/images/blank.gif');
$image.css({
backgroundImage: 'url('+ source +')',
backgroundRepeat: 'no-repeat',
backgroundSize: GALAXY.sizeMode > 2 ? 'cover' : '100% auto',
backgroundPosition: '50% 50%'
});
});
$('#kv').find('[class*="f_header-"]').find('.kv-title, .kv-text, div').show();
$('#kv').css({width: '100%', height: $(window).height()})
.find('div.f_container figure')
.css({left: 'auto', width: '100%', marginLeft: 'auto'})
.css($.support.transform, 'none')
.find('img').css({width: '100%', height: '100%'});
$('#kv').find('div.f_container figure').each(function() {
this.style.marginLeft = Math.min(0, (this.parentNode.offsetWidth-this.offsetWidth)/2) +'px';
});
if ($('#kv').hasClass('m_content-slider')) {
$('#kv').children().not('nav').not(':first').hide();
}
return;
}
this.header = this.header();
this.sections = this.sections();
this.footer = this.footer();
if (GALAXY.isGalaxy) {
$('a[data-omni], button[data-omni]')
.unbind('click', GALAXY.tracking)
.bind('click', GALAXY.tracking);
} else {
$('#contents a[data-omni], #contents button[data-omni], .m_dotcom_footer a[data-omni]')
.unbind('click', GALAXY.tracking)
.bind('click', GALAXY.tracking);
}
$(window).resize(this.resize)
.scroll(this.scroll);
if (!GALAXY.isGalaxy&&$('html').attr('lang')=='ja') {
$('body').on('scroll', function() {
if (GALAXY.sizeMode<3) {
GALAXY.scroll();
}
});
}
this.resize(true);
setTimeout(function() {
$(document.documentElement).addClass('load');
window.onAfterLoad&&window.onAfterLoad();
}, 100);
(function() {
var url = 'http://campaign.samsung.com.cn/marvel';
var countryCode = $._cookie.get('country_codes');
countryCode = (countryCode) ? $.trim(countryCode).toUpperCase() : '';
if (countryCode=='CN') {
$(".link-avengers").each(function(i) {
$(this).attr({
title: 'Go to Avengers in a new window',
target: '_blank',
href: url
});
});
}
})();
}
};
$(window).load(function() {
setTimeout(function() {
GALAXY.initialize();
}, 0);
});
})(window.jQuery);