123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- /*
- *构建SDAPP
- */
- SDAPP = (function () {
- function App(options) {
- this.O = options;
- this.J = jQuery;
- this.init();
- }
- return App;
- })();
- SDAPP.prototype.init = function () {
- this.client();
- this.plugin();
- this.renew();
- }
- /**
- * getClient
- */
- SDAPP.prototype.client = function () {
- return {
- "width": this.J(window).width(),
- "height": this.J(window).height()
- };
- }
- /**
- * resize
- */
- SDAPP.prototype.renew = function () {
- var _this = this;
- _this.J(window).resize(function (event) {
- _this.client();
- // window.console && console.log(_this.client().width, _this.client().height);
- });
- }
- /**
- * plugin
- */
- SDAPP.prototype.plugin = function () {
- var _this = this;
- // focus
- // this.O['focus'] && this.J("[data-focus]").sudyfocus(this.O['focus']);
- // menu
- if (this.client().width > 1280) {
- /*增加*/
- this.J(".wp-navi").find(".menu-item").on("mouseenter", function () {
- _this.J(this).addClass("hover");
- _this.J(this).children('.sub-menu').show();
- }).on("mouseleave", function () {
- _this.J(this).removeClass("hover");
- _this.J(this).children('.sub-menu').hide();
- });
- }
- this.J(".column_title_box").on("click", function (event) {
- event.preventDefault();
- _this.J(".column_title_box .arrow").toggleClass("up")
- _this.J(".page_tab_list").slideToggle(200);
- });
- this.J(".page_tab_list .page_list_item.selected").find(".sub_item_link ").eq(0).addClass("selected")
- var $aside = this.J("#wp-navi-aside");
- var sideWrap = $aside.find(".navi-aside-wrap");
- var menuDom = this.J(".header_menu .wp-menu").clone()
- sideWrap.append(menuDom)
- this.J(".menu-switch-arrow", ".wp-navi-aside").on("click", function () {
- _this.J(this).toggleClass('open').siblings(".sub-menu").slideToggle(250);
- });
- this.J(".mobile_menu_taggle").on("click", function () {
- _this.J(".wp-navi-aside").show()
- _this.J(".wp-navi-aside .aside-inner").stop().animate({ right: 0 }, 250);
- });
- this.J(".navi-aside-mask").on("click", function (event) {
- event.preventDefault();
- _this.J(".wp-navi-aside .aside-inner").stop().animate({ right: "-200px" }, 250, function () {
- _this.J(".wp-navi-aside").hide();
- });
- });
- this.J(window).scroll(function (event) {
- var scrolltop = _this.J(window).scrollTop();
- if (scrolltop > 500) {
- _this.J("#gotop").show();
- } else {
- _this.J("#gotop").hide();
- }
- });
- this.J("#gotop").on("click", function () {
- _this.J("body,html").stop().animate({ scrollTop: 0 }, 500);
- });
- $(".search-submit").click(function (event) {
- $(this).removeAttr("name");
- event.preventDefault();
- var val = $.trim($(".search-input input").val());
- if (val !== "") {
- $(".wp-search").find("form").submit();
- } else {
- alert("请输入关键词");
- }
- return false;
- });
- $(".search_icon").click(function () {
- $(".search_box .wp-search").stop().animate({ top: "0", opacity: 1 }, 200)
- })
- $(".close_icon").click(function () {
- $(".search_box .wp-search").stop().animate({ top: "-100%", opacity: 0 }, 200)
- })
- }
|