Created
August 13, 2015 15:25
-
-
Save djom202/f80b93cf9db39c9abc25 to your computer and use it in GitHub Desktop.
Fixed Codes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var isMobile = navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|Windows Phone)/); | |
| var is_iPad = navigator.userAgent.match(/(iPad)/); | |
| // | |
| var res1440 = false; | |
| var res1080 = false; | |
| var res1050 = false; | |
| var res900 = false; | |
| var res768 = false; | |
| // | |
| var userAgent = window.navigator.userAgent.toLowerCase(); | |
| $.browser.msie9 = $.browser.msie && /msie 9\.0/i.test(userAgent); | |
| $.browser.msie8 = $.browser.msie && /msie 8\.0/i.test(userAgent); | |
| $.browser.msie7 = $.browser.msie && /msie 7\.0/i.test(userAgent); | |
| $.browser.msie6 = !$.browser.msie8 && !$.browser.msie7 && $.browser.msie && /msie 6\.0/i.test(userAgent); | |
| var ie6_8 = false; | |
| var ie6_9 = false; | |
| if ($.browser.msie6 || $.browser.msie7 || $.browser.msie8) { | |
| ie6_8 = true; | |
| }; | |
| if ($.browser.msie6 || $.browser.msie7 || $.browser.msie8 || $.browser.msie9) { | |
| ie6_9 = true; | |
| }; | |
| //$(window).load(function() { | |
| $(document).ready(function() { | |
| // executes when complete page is fully loaded, including all frames, objects and images | |
| // alert("(window).load was called - window is loaded!"); | |
| $('#se_preloader').hide(); | |
| $('#se_fullpage').css('opacity', 1); | |
| // Hide side nav for iPad | |
| if (is_iPad) $('.se_fullPage_side_nav').css('z-index', '-1'); | |
| init(); | |
| homeEvent(); | |
| headNav(); | |
| fullpageNav(); | |
| // | |
| jQuery(document).bind('keydown', function(evt) { | |
| if (evt.keyCode == 40) { | |
| downPage(); | |
| } else if (evt.keyCode == 38) { | |
| upPage(); | |
| } | |
| }); | |
| }); | |
| // -------------------------------------------------------------------------------------------- | |
| // init | |
| // -------------------------------------------------------------------------------------------- | |
| function init() { | |
| // | |
| // $('html, body').stop().animate({scrollTop: 0}, 700); | |
| // | |
| setTimeout(function() { | |
| $('.se_fullPage_side_nav').fadeIn(300); | |
| // show nav text | |
| if (!ie6_8) { | |
| if (localStorage.getItem("idx_page") != undefined) { | |
| showNavText(localStorage.getItem("idx_page")); | |
| idx_page = localStorage.getItem("idx_page"); | |
| reposNav(); | |
| } else { | |
| showNavText(0); | |
| }; | |
| } else { | |
| showNavText(0); | |
| }; | |
| }, 500); | |
| //navigation bar | |
| // | |
| //page links | |
| $('.se_header_nav a').click(function() { | |
| var label = $(this).text().toLowerCase(); | |
| if (label !== "features") { | |
| trackEvent('outbound-link', 'product-nav', label); | |
| // Delay link | |
| var href = $(this).attr('href'); | |
| setTimeout(function() { | |
| top.window.location.href = href; | |
| // top.window.open(href,'_blank'); | |
| }, 200); | |
| return false; | |
| }; | |
| }); | |
| //SNS sharing links | |
| $('.se_header_sns a').click(function() { | |
| var site = $(this).data('sns'); | |
| // Tracking | |
| trackEvent('share', 'product-sns', site); | |
| return false; | |
| }); | |
| }; | |
| // -------------------------------------------------------------------------------------------- | |
| // resize | |
| // -------------------------------------------------------------------------------------------- | |
| $(document).ready(function() { | |
| resizeWin(); | |
| $(window).resize(function() { | |
| resizeWin(); | |
| //scrollPage(idx_page); | |
| }); | |
| }); | |
| // -------------------------------------------------------------------------------------------- | |
| // common | |
| // -------------------------------------------------------------------------------------------- | |
| function resizeWin() { | |
| var ww = $(window).width(); | |
| var wh = $(window).height(); | |
| // | |
| if (!isMobile) { | |
| if (wh > 990) { | |
| res1440 = true; | |
| res1080 = res1050 = res900 = res768 = false; | |
| } else if (wh > 960 && wh <= 990) { | |
| res1080 = true; | |
| res1440 = res1050 = res900 = res768 = false; | |
| } else if (wh > 810 && wh <= 960) { | |
| res1050 = true; | |
| res1440 = res1080 = res900 = res768 = false; | |
| } else if (wh > 680 && wh <= 810) { | |
| res900 = true; | |
| res1440 = res1080 = res1050 = res768 = false; | |
| } else if (wh <= 680) { | |
| res768 = true; | |
| res1440 = res1080 = res1050 = res900 = false; | |
| } | |
| }; | |
| // | |
| if(isMobile && (ww > wh)) { | |
| fit768(); | |
| } | |
| checkVideo(); | |
| function fit768() { | |
| // | |
| $('#se_section0,#se_section1,#se_section01,#se_section2,#se_section3,#se_section4,#se_section5,#se_section6,#se_section7').addClass('tiny').removeClass('tiny9'); | |
| // 1st height hack | |
| $('#se_section0').height(500); | |
| } | |
| if (res768) { | |
| fit768(); | |
| // -------------------------------------- 768 end ------------------------ 768 end ---------------------------- | |
| } else if (res900) { | |
| // | |
| $('#se_section0,#se_section1,#se_section01,#se_section2,#se_section3,#se_section4, #se_section5,#se_section6, #se_section7').addClass('tiny9').removeClass('tiny'); | |
| // 1st height hack | |
| $('#se_section0').height(650); | |
| // -------------------------------------- 900 end ------------------------ 900 end ---------------------------- | |
| } else { | |
| // | |
| $('#se_section0,#se_section1,#se_section01,#se_section2,#se_section3,#se_section4, #se_section5,#se_section6, #se_section7').removeClass('tiny').removeClass('tiny9'); | |
| // 1st height hack | |
| $('#se_section0').height(800); | |
| }; | |
| // | |
| reposNav(); | |
| // | |
| $('.se_dialog-overlay').height(wh + 200); | |
| } | |
| function checkVideo () { | |
| var ww = $(window).width(); | |
| var wh = $(window).height(); | |
| if (is_iPad && $('#se_section1 video').length > 0) { | |
| if (ww > wh && boo_play) { | |
| $('#se_section1').height(parseInt(ww * 9 / 16) - 3); | |
| } else { | |
| $('#se_section1').height($('#se_section01').height()); | |
| } | |
| $('#se_section1 video').removeAttr('style'); | |
| $('#se_section1 video').width(ww); | |
| $('#se_section1 video').height(Math.ceil(ww * 9 / 16)); | |
| }; | |
| } | |
| // | |
| function reposNav() { | |
| if (idx_page == 9) { | |
| $('.se_fullPage_side_nav').stop().animate({'top': -($('.se_fullPage_side_nav').height() + 340 - $(window).height()) + 'px'}, scrollingSpeed); | |
| } else if (idx_page == 0) { | |
| $('.se_fullPage_side_nav').stop().animate({'top': ($(window).height() - 290 - $('.se_fullPage_side_nav').height()) * .5 + 290 + 'px'}, scrollingSpeed); | |
| } else { | |
| $('.se_fullPage_side_nav').stop().animate({'top': ($(window).height() - 150 - $('.se_fullPage_side_nav').height()) * .5 + 150 + 'px'}, scrollingSpeed); | |
| } | |
| } | |
| // -------------------------------------------------------------------------------------------- | |
| // head nav | |
| // -------------------------------------------------------------------------------------------- | |
| function headNav() { | |
| $(window).scroll(function() { | |
| var height = $(document).scrollTop(); | |
| // console.log(height); | |
| var offset = $(document).height() - $(window).height(); | |
| var num_sub = offset - height; | |
| // | |
| if (height <= 4) { | |
| $('.se_header').css('top', ''); | |
| } else if (height > 4 && height < 139) { | |
| $('.se_header').css('top', 139 - height + 'px'); | |
| } else { | |
| $('.se_header').css('top', 0); | |
| } | |
| // | |
| if (height > 1340) { | |
| stopvideo_c(); | |
| }; | |
| }) | |
| }; | |
| // -------------------------------------------------------------------------------------------- | |
| // fullpage nav Home\TVC\Display\Performance\Camera\Battery\Thermal Design\Industry Design\Music | |
| // -------------------------------------------------------------------------------------------- | |
| var scrollingSpeed = 700; | |
| var scrollDelay = 600; | |
| var isMoving = false; | |
| var isResizing = false; | |
| var currentSection = 'Home'; | |
| var scrollingEasing = "easeInQuint"; | |
| var anchor = ['Home', 'TVC', 'Display', 'Performance', 'Camera', 'Battery','Thermal Design','Industry Design','Music']; | |
| var pages = ['#se_section0','#se_section1', '#se_section01', '#se_section2', '#se_section3', '#se_section4', '#se_section5','#se_section6','#se_section7','#footDiv']; | |
| idx_page = 0; | |
| var cnt_row = pages.length; | |
| jQuery(function($) { | |
| $(document).bind('mousewheel', function(event, delta) { | |
| if(delta > 0) { | |
| upPage(); | |
| } else { | |
| downPage(); | |
| } | |
| }); | |
| }); | |
| function fullpageNav() { | |
| // click | |
| $('.se_fullPage_side_nav li').click(function() { | |
| if ($('.se_fullPage_side_nav li').index(this) < 15) { | |
| idx_page = $('.se_fullPage_side_nav li').index(this); | |
| scrollPage(idx_page); | |
| }; | |
| }); | |
| // swipe | |
| $(".se_section_wrapper").on("swipeleft", function() { | |
| idx_page = $('.se_section_wrapper').index(this) + 1; | |
| // alert("swiperight: " + idx_page); | |
| rightPage(); | |
| }); | |
| $(".se_section_wrapper").on("swiperight", function() { | |
| idx_page = $('.se_section_wrapper').index(this) + 1; | |
| // alert("swipeleft: " + idx_page); | |
| leftPage(); | |
| }); | |
| // Hover nav li | |
| $('.se_fullPage_side_nav li').mouseover(function(event) { | |
| $(this).find('i').css('opacity', 1); | |
| }).mouseout(function() { | |
| $('.se_fullPage_side_nav li').find('i').css('opacity', 0); | |
| }) | |
| }; | |
| function scrollPage(idx) { | |
| if(!ie6_8) localStorage.setItem("idx_page", idx); | |
| // alert($(pages[idx]).position().top); | |
| var num_top_offset = 0; | |
| if (idx_page == 0) num_top_offset = 0; | |
| else num_top_offset = 139; | |
| // | |
| // console.log($(pages[idx]).position().top+ num_top_offset) ; | |
| // alert($(pages[idx]).position().top + num_top_offset); | |
| $('html, body').stop().animate({ | |
| scrollTop: $(pages[idx]).position().top + num_top_offset | |
| }, scrollingSpeed); | |
| // | |
| event_1(idx); | |
| reposNav(); | |
| // console.log(idx); | |
| // | |
| animation(idx); | |
| // | |
| if (idx < 9) { | |
| $('.se_fullPage_side_nav li').eq(idx).addClass('se_active').siblings().removeClass('se_active'); | |
| } else { | |
| $('.se_fullPage_side_nav li').removeClass('se_active'); | |
| }; | |
| // show nav text | |
| showNavText(idx); | |
| } | |
| // show nav text | |
| var navTextTimeout; | |
| function showNavText(n) { | |
| $('.se_fullPage_side_nav li').find('i').css('opacity', 0); | |
| $('.se_fullPage_side_nav li').eq(n).find('i').css('opacity', 1); | |
| clearTimeout(navTextTimeout); | |
| navTextTimeout = setTimeout(function() { | |
| $('.se_fullPage_side_nav li').find('i').css('opacity', 0); | |
| }, 1500); | |
| } | |
| function getTransforms(translate3d){ | |
| return { | |
| '-webkit-transform': translate3d, | |
| '-moz-transform': translate3d, | |
| '-ms-transform':translate3d, | |
| '-o-transform':translate3d, | |
| 'transform': translate3d | |
| }; | |
| } | |
| function activeSlideNav(idx, slide) { | |
| $('.se_fullPage_slide_nav').eq(idx).find('a').removeClass('se_active'); | |
| $('.se_fullPage_slide_nav').eq(idx).find('a').eq(slide).addClass('se_active'); | |
| } | |
| function upPage() { | |
| if (idx_page > 0) { | |
| idx_page--; | |
| scrollPage(idx_page); | |
| } | |
| } | |
| function downPage() { | |
| if (idx_page < cnt_row - 1) { | |
| idx_page++; | |
| scrollPage(idx_page); | |
| } | |
| } | |
| // -------------------------------------------------------------------------------------------- | |
| // fullpage events | |
| // -------------------------------------------------------------------------------------------- | |
| function homeEvent() { | |
| // | |
| if(ie6_9) { | |
| window.setTimeout(function() { | |
| $('.se_fullPage_side_nav').addClass('active'); | |
| }, 1400); | |
| } else { | |
| window.setTimeout(function() { | |
| $('.se_fullPage_side_nav').addClass('active'); | |
| }, 1200); | |
| } | |
| // Tracking | |
| trackPageview('/' + anchor[0]); | |
| }; | |
| function event_1(idx){ | |
| if(idx!=1){ | |
| stopvideo_c(); | |
| } | |
| } | |
| var s2_desc_5_during = 1000; | |
| var s5_during = 2800; | |
| var num_fire = 1050; | |
| var s3_1_during_0 = 1200; | |
| var s3_1_during_1 = 2600; | |
| var cooling_timer = null; | |
| var timer = null; | |
| var first_run = true; | |
| var t0,t1,t2,t3,t4 | |
| function animation(side) { | |
| if (isMobile) num_fire = 300; | |
| if (side == 3) { | |
| setTimeout(function () { | |
| $('#s3_cpu_0_0, #se_section_3_0 #se_light').addClass('active'); | |
| }, 800); | |
| }else if(side == 2) { | |
| setTimeout(function () { | |
| $('#s2_0_2, #s2_0_3, #se_section_2_0 #se_light').addClass('active'); | |
| }, 800); | |
| }else if(side ==6) { | |
| }else if(side ==11){ | |
| setTimeout(function () { | |
| $('#se_section_11_0 #se_light').addClass('active'); | |
| }, 800); | |
| } | |
| else{$('#s3_cpu_0_0 ,#s2_0_2,#s2_0_3,#se_light,#s3_cpu_0_00,#s3_cpu_0_01,#s3_cpu_0_02,#s3_cpu_0_03,#s3_cpu_0_04,#s3_cpu_0_05,#s3_cpu_0_06,#s3_cpu_0_07e,#s3_cpu_0_08,#s3_cpu_0_09').removeClass('active');} | |
| } | |
| // -------------------------------------------------------------------------------------------- | |
| // misc | |
| // -------------------------------------------------------------------------------------------- | |
| var PAGEVIEW_PREFIX = '/davinci'; // No trailing slash | |
| //GA trackPageview wrapper | |
| function trackPageview(url) { | |
| /*console.log('trackPageview() url = ' + PAGEVIEW_PREFIX + url);*/ | |
| try { | |
| _gaq.push(['_trackPageview', PAGEVIEW_PREFIX + url]); | |
| // huawei track | |
| trackHaPageview(url); | |
| } catch (err) {} | |
| } | |
| //GA trackEvent wrapper | |
| function trackEvent(category, action, label, value) { | |
| // console.log('trackEvent() category=' + category + ', action=' + action + ', label=' + label + ', value=' + value); | |
| try { | |
| _gaq.push(['_trackEvent', category, action, label, value]); | |
| // huawei track | |
| trackHaEvent(category, action, label, value); | |
| } catch (err) {} | |
| } | |
| // HWA | |
| function trackHaPageview(_url){ | |
| var _indexUrl = window.location.href; | |
| var _pageHierarchy = "c:{"+PAGEVIEW_PREFIX.substring(1)+"}f:{slide["+_url.substring(1)+"]}"; | |
| ha("trackEvent","click",{url:_indexUrl,page_hierarchy:_pageHierarchy}); | |
| //console.log('trackHaPageview successfully'); | |
| } | |
| function trackHaEvent(_category, _action, _label, _value){ | |
| var _indexUrl = window.location.href; | |
| var _path = _category+"/"+_action+"/"+_label; | |
| var _pageHierarchy = "c:{" + PAGEVIEW_PREFIX.substring(1) + "}f:{slide[" + _path + "]}"; | |
| ha("trackEvent", "click",{url: _indexUrl, page_hierarchy: _pageHierarchy }); | |
| //console.log('trackHaEvent successfully'); | |
| } | |
| // detect browser | |
| function ff() { | |
| var browser = navigator.userAgent.toLowerCase(); | |
| if (browser.indexOf('firefox') > -1) | |
| return true; | |
| return false; | |
| } | |
| function iPx() { | |
| if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) | |
| return true; | |
| return false; | |
| } | |
| function isIE() { | |
| if (ie6_9) | |
| return true; | |
| return false; | |
| } | |
| //IE7 HACK | |
| var t=setTimeout("headNav2()",800); | |
| function headNav2() { | |
| if(ie6_8) { | |
| window.scrollTo(0,0); | |
| clearTimeout(t); | |
| } | |
| }; | |
| $(document).ready(function(){ | |
| $('.Slide_secP7 a').click(function(){ | |
| var ix = $('.Slide_secP7 a').index(this); | |
| //alert(ix); | |
| $(this).addClass('on').siblings().removeClass('on'); | |
| $(this).parents('.se_section').find('.se_slide').eq(ix).fadeIn(800).siblings().hide(); | |
| }); | |
| $('.Slide_secP5 a').click(function(){ | |
| var ix02 = $('.Slide_secP5 a').index(this); | |
| $(this).addClass('on').siblings().removeClass('on'); | |
| $(this).parents('.se_section').find('.se_slide').eq(ix02).fadeIn(800).siblings().hide(); | |
| }); | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment