Title / Description
Code // Avoid `console` errors in browsers that lack a console. ;(function(){for(var a,e=function(){},b="assert clear count debug dir dirxml error exception group groupCollapsed groupEnd info log markTimeline profile profileEnd table time timeEnd timeStamp trace warn".split(" "),c=b.length,d=window.console=window.console||{};c--;)a=b[c],d[a]||(d[a]=e)})(); (function(n, w, d, $, undefined) { var Initializer, init, base, SmoothScroll, App; Initializer = (function() { function Initializer() { this.init(); } Initializer.prototype = { isDev: function() { var host = location.hostname, regex = /panasonic\.jp$/i; return !regex.test(host); }, isSp: function() { var mq = 'only screen and (max-width:640px) and (max-device-width:1280px)'; return (w.matchMedia && w.matchMedia(mq).matches); }, isLegacy: function() { return ((w.Modernizr !== undefined) && !w.Modernizr.opacity); }, readWebFont: function() { var src = '//typesquare.com/accessor/script/typesquare.js?F3oktzPCZQs%3D', script = '<script' + ' src="$1" charset="UTF-8"></' + 'script>'; if (!this.isLegacy()) { script = script.replace('$1', src); d.write(script); } return this; }, init: function() { if (this.isDev()) { this.readWebFont(); } /*if (w.WOW !== undefined) { new WOW().init(); }*/ return this; } }; return Initializer; })(); init = new Initializer(); SmoothScroll = (function() { function SmoothScroll() { this.obj = { anchor: base.find('a[href^=#]:not(".no-scroll")') }; this.browsebarHeight = this._browsebarHeight(); this.init(); } SmoothScroll.prototype = { _browsebarHeight: function() { return init.isSp() ? 0 : $('#browsebar').height(); }, enterPage: function() { var target, position = $(w).scrollTop(); if (location.hash) { target = $(location.hash); if (target.length === 0) { return this; } position = target.offset().top - this.browsebarHeight; } if (position > 0) { this._scrollTo(position, 1); } return this; }, anchor: function() { var self =this, duration = 450, browsebarHeight = self.browsebarHeight; self.obj.anchor.on('click.SmoothScroll', function(e) { var obj = $(this), target = $(obj.attr('href')), position = 0; if (target.length && target.is(':visible')) { e.preventDefault(); position = target.offset().top - browsebarHeight; self._scrollTo(position, duration); } }); return this; }, _scrollTo: function(position, duration) { $('html, body').animate({scrollTop: position}, duration); return this; }, init: function() { if (!init.isSp()) { this.enterPage(); } this.anchor(); return this; } }; return SmoothScroll; })(); App = (function() { function App() { this.init(); } App.prototype = { bgVideo: function() { var obj; if (base.hasClass('index')) { obj = d.getElementById('hero-video'); if (obj) { obj.playbackRate = 0.6; } } return this; }, navEvent: function() { var win = $(w), gnavBar = base.find('#gnav-bar'), button = gnavBar.find('.nav-button'), nav = gnavBar.find('#gnav'), openClass = 'open'; button.on('click', function(e) { var obj = $(this); e.preventDefault(); if (obj.hasClass(openClass)) { nav .stop() .slideUp(250, function() { obj.removeClass(openClass); }); } else { nav .stop() .slideDown(300, function() { obj.addClass(openClass); }); } }); win.on('resize orientationchange', function() { if (!init.isSp()) { nav.show(); } else { if (button.hasClass(openClass)) { nav.show(); } else { nav.hide(); } } }); return this; }, twitterIntent: function() { var obj = base.find('a.twitter-win'); obj.on('click', function(e) { if (!init.isLegacy()) { e.preventDefault(); } }); return this; }, init: function() { this.bgVideo() .navEvent() .twitterIntent(); return this; } }; return App; })(); $(function() { var html = $('html'); base = $('#evolta2015'); new SmoothScroll(); new App(); html.addClass('loaded'); }); })(navigator, window, document, jQuery);
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code