/** * RealWay JavaScript Library * Copyright (c) 2017 RealWay * Email: RealWay@gmail.com */ var $windowHeight, $navHeight, $height, $screen, $dom = {}; /** SmartScroll **/ $.smartScroll=function(a,b){var c,d;b&&!a.data("isBindScroll")&&(d={posY:0,maxscroll:0},a.on({touchstart:function(a){var f,c=a.touches[0]||a,e=$(a.target);e.length&&(e.is(b)?f=e:0==(f=e.parents(b)).length&&(f=null),f&&(d.elScroll=f,d.posY=c.pageY,d.scrollY=f.scrollTop(),d.maxscroll=f[0].scrollHeight-f[0].clientHeight))},touchmove:function(){var a,b,e,f;return(d.maxscroll<=0||c)&&event.preventDefault(),a=d.elScroll,b=a.scrollTop(),e=event.touches[0]||event,f=e.pageY-d.posY,c?(a.scrollTop(d.scrollY-f),a.trigger("scroll"),void 0):f>0&&0==b?(event.preventDefault(),void 0):0>f&&b+1>=d.maxscroll?(event.preventDefault(),void 0):void 0},touchend:function(){d.maxscroll=0}}),a.data("isBindScroll",!0))}; /** MsgBox **/ var msgbox={timer:null,tips:function(a,b,c){var d=this;d.remove(),d.makeMask(),$(".le-msgbox-mask").append($('

'+a+"

")),b=1e3*b||3e3,d.timer=setTimeout(function(){"function"==typeof c&&c(a),d.remove()},b)},makeMask:function(a){a=a||"rgba(255,255,255,.01)",$("body").append($('
'))},remove:function(a){clearTimeout(this.timer),$(".le-msgbox-mask").fadeOut(function(){$(this).remove(),"function"==typeof a&&a()})}}; $(function() { FastClick.attach(document.body); }); /* try { paceOptions = { elements:true }; Pace.on("hide", function() { $(".page-loading").fadeOut(500); }); } catch (e) {} */ $(document).on("foucs click", "a,button", function() { $(this).blur(); }); var scrollToElement = function($element, $addY, callback, $speed) { var $addY = $addY || 0; var $speed = $speed || 300; $("html,body").animate({ scrollTop:$element.offset().top + $addY }, $speed, function() { if (typeof callback == "function") { callback(); } }); }; var MediaPlayer = { path: MODEL + '/Plugins/mediaplayer', player: null, playVideo: function($files, $image, $auto, $obj) { $auto = typeof $auto == 'undefined' ? true : $auto; $obj = typeof $obj == 'undefined' ? 'real_player' : $obj; this.player = jwplayer($obj).setup({ flashplayer: this.path + '/jwplayer.flash.swf', file: $files, image: $image, autostart: $auto, stretching: 'fill', controlbar: 'over', height: '100%', width: '100%' }); } }; /* * Page Action */ var actIt = function($action, $fid, callback) { $.post("/cn/act/", { "post-type":"ajax", action:$action, fid:$fid }, function(data) { if (typeof callback == "function") { callback(data); } }, "json"); }; /* * Tabs('.ui-tabs'); * *
1
2
*/ var Tabs = function(sObject, sEvents, Callback) { sEvents = "click " + sEvents || "click"; $(sObject).on(sEvents, "li", function() { if (!$(this).attr("href")) { var oPanel = $(sObject + "-panel > div"); var $index = $(this).index(); $(this).addClass("active").siblings().removeClass("active"); oPanel.eq($index).css({ height:"auto" }).siblings().css({ height:0, overflow:"hidden" }); /* oPanel.eq($index).siblings().slideUp(300, function() { oPanel.eq($index).slideDown(); }); */ Callback && typeof Callback === "function" && Callback($index); return false; } }); $(sObject + " > li").eq(0).click(); return false; }; var formatStyle = function($the) {}; var removeStyle = function($the) {}; $(function() { if ($sDevice != "phone") { wow = new WOW({ boxClass:"wow", animateClass:"animated", offset:100, mobile:true, live:true }); wow.init(); } $dom.html = $("html"); $dom.body = $("body"); $(window).resize(function() { $screen = $('ins[data-type="screen"]').css("content").replace(/\"/g, ""); $("body").attr({ "data-screen":$screen }); /**/ if (!$dom.html.hasClass("full-screen")) { $dom.body.css("height", ""); $dom.iHtml = $dom.html.height(); $dom.iBody = $("body").outerHeight(); if ($dom.iBody < $dom.iHtml) { $dom.body.css({ height:"100%" }); } } }).resize(); $dom.menu = { icon:$(".ani-menu"), wait:false, timer:0 }; $dom.body = $("body"); var closeTopNav = function() { if ($dom.menu.wait) return false; $("html").removeClass("mobile-menu"); $dom.body.attr({ "data-menu":"closed" }); $dom.menu.icon.attr({ "data-action":"open-top-nav" }); $dom.top_nav.removeClass("opened"); $(".top-nav-menu dl.current").addClass("active").siblings().removeClass("active"); return true; }; $("[data-action]").on("click", function() { var $the = $(this); var $action = $the.attr("data-action"); switch ($action) { case "top-nav-toggle": $("html").toggleClass("mobile-menu"); break; case "open-video": $.fancybox.open({ type:"iframe", href:$the.attr("data-src") }); break; case "open-top-nav": if ($dom.menu.wait) return false; $("html").addClass("mobile-menu"); $dom.body.attr({ "data-menu":"opend" }); $dom.menu.icon.attr({ "data-action":"close-top-nav" }); $.smartScroll($(".top-nav-menu.opened dl.active div"), ".scrollable"); break; case "close-top-nav": closeTopNav(); break; } return false; }); }); var $G = {}; $(function() { $dom.top = $(".top-nav"); $dom.top_nav = $(".top-nav-menu"); if ($sDevice == "desktop") { $dom.nav = $('[data-menu="top-menu-hover"]'); $dom.navSub = $dom.top.find(".top-nav-menu dd"); $iWidthNav = 0; $(".top-nav-menu dl").each(function($k, $v) { $(this).attr({ "data-left":$iWidthNav, "data-width":$(this).width() }); $iWidthNav += $(this).width(); $span = $(this).find('dd>div'); $span.css({ "margin-left":-$span.width() / 2 }).css('opacity',1); }); $dom.nav.on("mouseenter", "dt a", function() { $G.the = $(this).closest("dl"); $G.dd = $G.the.find("dd"); $G.span = $G.dd.find("div"); /* $G.span.css({ "margin-left":-$G.span.width() / 2 }); */ $dom.top.attr({ "data-menu":$G.dd.size() }); $G.the.addClass("active").siblings().removeClass("active"); $dom.top.addClass("active"); }); $dom.top.find('.row-nav').on("mouseleave", function() { $dom.top.removeClass("active"); $dom.nav.find("dl").removeClass("active").parent().find(".current").addClass("active"); }); } else { $('.top-nav-menu dl[data-full="1"] dt a').on("click", function() { $dl = $(this).closest("dl"); $dl.addClass("active").siblings().removeClass("active"); $dom.top_nav.addClass("opened"); return false; }); } $('[data-nav="slides-prev"]').on("click", function() { $($(this).attr("data-slider")).slick("slickPrev"); return false; }); $('[data-nav="slides-next"]').on("click", function() { $($(this).attr("data-slider")).slick("slickNext"); return false; }); $('[data-action="products-menu-hover"]>a').on('mouseover', function(){ var $the = $(this); $the.addClass('active').siblings().removeClass('active'); $the.parent().find('.left-nav-level-3').removeClass('active') $the.parent().find('.left-nav-level-3[data-id='+$the.attr('data-id')+']').addClass('active'); }); }); $(function() { var $iDefaultTop = 0; var $iBar = $('.top-nav-bar').outerHeight()||90; $(window).scroll(function() { var $iCurrentTop = $(document).scrollTop(); if($iCurrentTop>60){ $('body').addClass('fixed-bar'); }else{ $('body').removeClass('fixed-bar'); } }); $(window).on('resize', function(){ $('[data-same-height]').each(function(){ sameHeight($(this).find($(this).attr('data-same-height'))); }); }).resize(); });