/** * pgwmenu - version 2.0 * * copyright 2014, jonathan m. piat * http://pgwjs.com - http://pagawa.com * * released under the gnu gplv3 license - http://opensource.org/licenses/gpl-3.0 */ (function (a) { a.fn.pgwmenu = function (d) { var e = { mainclassname: "pgwmenu", dropdownlabel: '', viewmoreenabled: true, viewmorelabel: 'view more ', viewmoremaxwidth: 480 }; if (this.length == 0) { return this } else { if (this.length > 1) { this.each(function () { a(this).pgwmenu(d) }); return this } } var c = this; c.plugin = this; c.config = {}; c.resizeevent = null; c.window = a(window); var f = function () { c.config = a.extend({}, e, d); b(); c.checkmenu(); c.window.resize(function () { c.plugin.css("overflow", "hidden"); cleartimeout(c.resizeevent); c.resizeevent = settimeout(function () { c.checkmenu() }, 100) }); c.plugin.find(".pm-dropdown").click(function (g) { c.enablemobiledropdown(); g.stoppropagation() }); c.plugin.find(".pm-viewmore").click(function (g) { c.enableviewmoredropdown(); g.stoppropagation() }); a(document).click(function () { c.disablemobiledropdown(); c.disableviewmoredropdown() }) }; var b = function () { var h = c.config.mainclassname; var g = c.plugin.attr("class"); if (g && g.indexof("light") > -1) { h += " light" } c.plugin.removeclass().addclass("pm-links"); c.plugin.wrap('
'); c.plugin = c.plugin.parent(); c.plugin.prepend('"); if (c.config.viewmoreenabled) { c.plugin.append('") } }; c.checkmenu = function () { var j = c.plugin.width(); if (c.config.viewmoreenabled) { var h = c.plugin.find(".pm-viewmore").width() } function g() { var k = 0; c.plugin.find(".pm-links").removeclass("mobile").show(); c.plugin.find(".pm-links > li").each(function () { k += a(this).width() }); return k } function i(l) { if (l == "viewmore") { var k = h; c.plugin.find(".pm-links").removeclass("mobile").show(); c.plugin.find(".pm-viewmore > ul > li").remove(); c.plugin.find(".pm-links > li").show().each(function () { if (k + a(this).width() < j) { k += a(this).width() } else { c.plugin.find(".pm-viewmore > ul").append(a(this).clone().show()); a(this).hide() } }); c.plugin.find(".pm-dropdown, .pm-viewmore > ul").hide(); c.plugin.find(".pm-viewmore").show() } else { if (l == "dropdown") { c.plugin.find(".pm-links > li").show(); c.plugin.find(".pm-links").addclass("mobile").hide(); c.plugin.find(".pm-viewmore, .pm-viewmore > ul").hide(); c.plugin.find(".pm-viewmore > ul > li").remove(); c.plugin.find(".pm-dropdown").show() } else { c.plugin.find(".pm-links > li").show(); c.plugin.find(".pm-links").removeclass("mobile").show(); c.plugin.find(".pm-dropdown, .pm-viewmore, .pm-viewmore > ul").hide(); c.plugin.find(".pm-viewmore > ul > li").remove() } } c.plugin.find(".pm-dropdown > a, .pm-viewmore > a").removeclass("active") } if (g() > j) { if (c.config.viewmoreenabled && (j > c.config.viewmoremaxwidth)) { i("viewmore") } else { i("dropdown") } } else { i("normal") } c.plugin.css("overflow", "") }; c.enableviewmoredropdown = function () { if (c.plugin.find(".pm-viewmore > a").hasclass("active")) { c.disableviewmoredropdown(); return false } c.plugin.find(".pm-viewmore > a").addclass("active"); c.plugin.find(".pm-viewmore > ul").show() }; c.disableviewmoredropdown = function () { if (c.plugin.find(".pm-viewmore > a").hasclass("active")) { c.plugin.find(".pm-viewmore > a").removeclass("active"); c.plugin.find(".pm-viewmore > ul").hide() } }; c.enablemobiledropdown = function () { if (c.plugin.find(".pm-dropdown > a").hasclass("active")) { c.disablemobiledropdown(); return false } c.plugin.find(".pm-dropdown > a").addclass("active"); c.plugin.find(".pm-links").show() }; c.disablemobiledropdown = function () { if (c.plugin.find(".pm-dropdown > a").hasclass("active")) { c.plugin.find(".pm-dropdown > a").removeclass("active"); c.plugin.find(".pm-links").hide() } }; f(); return this } })(window.zepto || window.jquery); $(function () { $(".pgwmenu").pgwmenu({ dropdownlabel: "菜单", viewmorelabel: '更多', }); $(".pgwmenucustom").pgwmenu({ mainclassname: "pgwmenucustom", dropdownlabel: "菜单", viewmorelabel: '更多', }); }); $(document).ready(function () { $(".pgwmenucustom li").hover( function () { $(this).find("ul").stop(false, false).slidedown("slow"); }, function () { $(this).find("ul").stop(false, false).slideup("fast"); } ); }); $(window).load(function () { $(".mobile-inner-header-icon").click(function () { $(this).toggleclass( "mobile-inner-header-icon-click mobile-inner-header-icon-out" ); $(".mobile-inner-nav").slidetoggle(250); }); $(".m_van_2_cont li").each(function (index) { $(this).css({ "animation-delay": index / 10 + "s", }); }); }); $(".m_van_1").click(function () { console.log(1); if ($(this).hasclass("m_arr")) { $(this).removeclass("m_arr"); } else { $(".m_van_1").removeclass("m_arr"); $(this).addclass("m_arr"); } }); scrolltopfun(); function scrolltopfun() { var topp = $(document).scrolltop(); // console.log(topp); if (topp != 0) { $(".pgwmenucustom").addclass("top_nav"); // $("header .head_logo img").attr('src', "./images/index/logo.png") } else { $(".pgwmenucustom").removeclass("top_nav"); // $("header .head_logo img").attr('src', "./images/index/logo2.png") } } $(function () { $(window).scroll(function () { scrolltopfun(); }); });