6200 lines
365 KiB
JavaScript
6200 lines
365 KiB
JavaScript
/* source: assets/js/runtime/libs/bootstrap.min.js */
|
||
if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");!function(t){"use strict";var e=t.fn.jquery.split(" ")[0].split(".");if(e[0]<2&&e[1]<9||1==e[0]&&9==e[1]&&e[2]<1||e[0]>3)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4")}(jQuery),function(t){"use strict";function e(){var t=document.createElement("bootstrap"),e={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var i in e)if(void 0!==t.style[i])return{end:e[i]};return!1}t.fn.emulateTransitionEnd=function(e){var i=!1,o=this;t(this).one("bsTransitionEnd",function(){i=!0});var n=function(){i||t(o).trigger(t.support.transition.end)};return setTimeout(n,e),this},t(function(){t.support.transition=e(),t.support.transition&&(t.event.special.bsTransitionEnd={bindType:t.support.transition.end,delegateType:t.support.transition.end,handle:function(e){if(t(e.target).is(this))return e.handleObj.handler.apply(this,arguments)}})})}(jQuery),function(t){"use strict";function e(e){return this.each(function(){var i=t(this),n=i.data("bs.alert");n||i.data("bs.alert",n=new o(this)),"string"==typeof e&&n[e].call(i)})}var i='[data-dismiss="alert"]',o=function(e){t(e).on("click",i,this.close)};o.VERSION="3.4.1",o.TRANSITION_DURATION=150,o.prototype.close=function(e){function i(){a.detach().trigger("closed.bs.alert").remove()}var n=t(this),s=n.attr("data-target");s||(s=n.attr("href"),s=s&&s.replace(/.*(?=#[^\s]*$)/,"")),s="#"===s?[]:s;var a=t(document).find(s);e&&e.preventDefault(),a.length||(a=n.closest(".alert")),a.trigger(e=t.Event("close.bs.alert")),e.isDefaultPrevented()||(a.removeClass("in"),t.support.transition&&a.hasClass("fade")?a.one("bsTransitionEnd",i).emulateTransitionEnd(o.TRANSITION_DURATION):i())};var n=t.fn.alert;t.fn.alert=e,t.fn.alert.Constructor=o,t.fn.alert.noConflict=function(){return t.fn.alert=n,this},t(document).on("click.bs.alert.data-api",i,o.prototype.close)}(jQuery),function(t){"use strict";function e(e){return this.each(function(){var o=t(this),n=o.data("bs.button"),s="object"==typeof e&&e;n||o.data("bs.button",n=new i(this,s)),"toggle"==e?n.toggle():e&&n.setState(e)})}var i=function(e,o){this.$element=t(e),this.options=t.extend({},i.DEFAULTS,o),this.isLoading=!1};i.VERSION="3.4.1",i.DEFAULTS={loadingText:"loading..."},i.prototype.setState=function(e){var i="disabled",o=this.$element,n=o.is("input")?"val":"html",s=o.data();e+="Text",null==s.resetText&&o.data("resetText",o[n]()),setTimeout(t.proxy(function(){o[n](null==s[e]?this.options[e]:s[e]),"loadingText"==e?(this.isLoading=!0,o.addClass(i).attr(i,i).prop(i,!0)):this.isLoading&&(this.isLoading=!1,o.removeClass(i).removeAttr(i).prop(i,!1))},this),0)},i.prototype.toggle=function(){var t=!0,e=this.$element.closest('[data-toggle="buttons"]');if(e.length){var i=this.$element.find("input");"radio"==i.prop("type")?(i.prop("checked")&&(t=!1),e.find(".active").removeClass("active"),this.$element.addClass("active")):"checkbox"==i.prop("type")&&(i.prop("checked")!==this.$element.hasClass("active")&&(t=!1),this.$element.toggleClass("active")),i.prop("checked",this.$element.hasClass("active")),t&&i.trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active")),this.$element.toggleClass("active")};var o=t.fn.button;t.fn.button=e,t.fn.button.Constructor=i,t.fn.button.noConflict=function(){return t.fn.button=o,this},t(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(i){var o=t(i.target).closest(".btn");e.call(o,"toggle"),t(i.target).is('input[type="radio"], input[type="checkbox"]')||(i.preventDefault(),o.is("input,button")?o.trigger("focus"):o.find("input:visible,button:visible").first().trigger("focus"))}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(e){t(e.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(e.type))})}(jQuery),function(t){"use strict";function e(e){return this.each(function(){var o=t(this),n=o.data("bs.carousel"),s=t.extend({},i.DEFAULTS,o.data(),"object"==typeof e&&e),a="string"==typeof e?e:s.slide;n||o.data("bs.carousel",n=new i(this,s)),"number"==typeof e?n.to(e):a?n[a]():s.interval&&n.pause().cycle()})}var i=function(e,i){this.$element=t(e),this.$indicators=this.$element.find(".carousel-indicators"),this.options=i,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",t.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",t.proxy(this.pause,this)).on("mouseleave.bs.carousel",t.proxy(this.cycle,this))};i.VERSION="3.4.1",i.TRANSITION_DURATION=600,i.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},i.prototype.keydown=function(t){if(!/input|textarea/i.test(t.target.tagName)){switch(t.which){case 37:this.prev();break;case 39:this.next();break;default:return}t.preventDefault()}},i.prototype.cycle=function(e){return e||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(t.proxy(this.next,this),this.options.interval)),this},i.prototype.getItemIndex=function(t){return this.$items=t.parent().children(".item"),this.$items.index(t||this.$active)},i.prototype.getItemForDirection=function(t,e){var i=this.getItemIndex(e),o="prev"==t&&0===i||"next"==t&&i==this.$items.length-1;if(o&&!this.options.wrap)return e;var n="prev"==t?-1:1,s=(i+n)%this.$items.length;return this.$items.eq(s)},i.prototype.to=function(t){var e=this,i=this.getItemIndex(this.$active=this.$element.find(".item.active"));if(!(t>this.$items.length-1||t<0))return this.sliding?this.$element.one("slid.bs.carousel",function(){e.to(t)}):i==t?this.pause().cycle():this.slide(t>i?"next":"prev",this.$items.eq(t))},i.prototype.pause=function(e){return e||(this.paused=!0),this.$element.find(".next, .prev").length&&t.support.transition&&(this.$element.trigger(t.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},i.prototype.next=function(){if(!this.sliding)return this.slide("next")},i.prototype.prev=function(){if(!this.sliding)return this.slide("prev")},i.prototype.slide=function(e,o){var n=this.$element.find(".item.active"),s=o||this.getItemForDirection(e,n),a=this.interval,r="next"==e?"left":"right",l=this;if(s.hasClass("active"))return this.sliding=!1;var h=s[0],d=t.Event("slide.bs.carousel",{relatedTarget:h,direction:r});if(this.$element.trigger(d),!d.isDefaultPrevented()){if(this.sliding=!0,a&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var p=t(this.$indicators.children()[this.getItemIndex(s)]);p&&p.addClass("active")}var c=t.Event("slid.bs.carousel",{relatedTarget:h,direction:r});return t.support.transition&&this.$element.hasClass("slide")?(s.addClass(e),"object"==typeof s&&s.length&&s[0].offsetWidth,n.addClass(r),s.addClass(r),n.one("bsTransitionEnd",function(){s.removeClass([e,r].join(" ")).addClass("active"),n.removeClass(["active",r].join(" ")),l.sliding=!1,setTimeout(function(){l.$element.trigger(c)},0)}).emulateTransitionEnd(i.TRANSITION_DURATION)):(n.removeClass("active"),s.addClass("active"),this.sliding=!1,this.$element.trigger(c)),a&&this.cycle(),this}};var o=t.fn.carousel;t.fn.carousel=e,t.fn.carousel.Constructor=i,t.fn.carousel.noConflict=function(){return t.fn.carousel=o,this};var n=function(i){var o=t(this),n=o.attr("href");n&&(n=n.replace(/.*(?=#[^\s]+$)/,""));var s=o.attr("data-target")||n,a=t(document).find(s);if(a.hasClass("carousel")){var r=t.extend({},a.data(),o.data()),l=o.attr("data-slide-to");l&&(r.interval=!1),e.call(a,r),l&&a.data("bs.carousel").to(l),i.preventDefault()}};t(document).on("click.bs.carousel.data-api","[data-slide]",n).on("click.bs.carousel.data-api","[data-slide-to]",n),t(window).on("load",function(){t('[data-ride="carousel"]').each(function(){var i=t(this);e.call(i,i.data())})})}(jQuery),function(t){"use strict";function e(e){var i,o=e.attr("data-target")||(i=e.attr("href"))&&i.replace(/.*(?=#[^\s]+$)/,"");return t(document).find(o)}function i(e){return this.each(function(){var i=t(this),n=i.data("bs.collapse"),s=t.extend({},o.DEFAULTS,i.data(),"object"==typeof e&&e);!n&&s.toggle&&/show|hide/.test(e)&&(s.toggle=!1),n||i.data("bs.collapse",n=new o(this,s)),"string"==typeof e&&n[e]()})}var o=function(e,i){this.$element=t(e),this.options=t.extend({},o.DEFAULTS,i),this.$trigger=t('[data-toggle="collapse"][href="#'+e.id+'"],[data-toggle="collapse"][data-target="#'+e.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};o.VERSION="3.4.1",o.TRANSITION_DURATION=350,o.DEFAULTS={toggle:!0},o.prototype.dimension=function(){var t=this.$element.hasClass("width");return t?"width":"height"},o.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var e,n=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(n&&n.length&&(e=n.data("bs.collapse"),e&&e.transitioning))){var s=t.Event("show.bs.collapse");if(this.$element.trigger(s),!s.isDefaultPrevented()){n&&n.length&&(i.call(n,"hide"),e||n.data("bs.collapse",null));var a=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[a](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var r=function(){this.$element.removeClass("collapsing").addClass("collapse in")[a](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!t.support.transition)return r.call(this);var l=t.camelCase(["scroll",a].join("-"));this.$element.one("bsTransitionEnd",t.proxy(r,this)).emulateTransitionEnd(o.TRANSITION_DURATION)[a](this.$element[0][l])}}}},o.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var e=t.Event("hide.bs.collapse");if(this.$element.trigger(e),!e.isDefaultPrevented()){var i=this.dimension();this.$element[i](this.$element[i]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var n=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};if(!t.support.transition)return n.call(this);this.$element[i](0).one("bsTransitionEnd",t.proxy(n,this)).emulateTransitionEnd(o.TRANSITION_DURATION)}}},o.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},o.prototype.getParent=function(){return t(document).find(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(t.proxy(function(i,o){var n=t(o);this.addAriaAndCollapsedClass(e(n),n)},this)).end()},o.prototype.addAriaAndCollapsedClass=function(t,e){var i=t.hasClass("in");t.attr("aria-expanded",i),e.toggleClass("collapsed",!i).attr("aria-expanded",i)};var n=t.fn.collapse;t.fn.collapse=i,t.fn.collapse.Constructor=o,t.fn.collapse.noConflict=function(){return t.fn.collapse=n,this},t(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(o){var n=t(this);n.attr("data-target")||o.preventDefault();var s=e(n),a=s.data("bs.collapse"),r=a?"toggle":n.data();i.call(s,r)})}(jQuery),function(t){"use strict";function e(e){var i=e.attr("data-target");i||(i=e.attr("href"),i=i&&/#[A-Za-z]/.test(i)&&i.replace(/.*(?=#[^\s]*$)/,""));var o="#"!==i?t(document).find(i):null;return o&&o.length?o:e.parent()}function i(i){i&&3===i.which||(t(n).remove(),t(s).each(function(){var o=t(this),n=e(o),s={relatedTarget:this};n.hasClass("open")&&(i&&"click"==i.type&&/input|textarea/i.test(i.target.tagName)&&t.contains(n[0],i.target)||(n.trigger(i=t.Event("hide.bs.dropdown",s)),i.isDefaultPrevented()||(o.attr("aria-expanded","false"),n.removeClass("open").trigger(t.Event("hidden.bs.dropdown",s)))))}))}function o(e){return this.each(function(){var i=t(this),o=i.data("bs.dropdown");o||i.data("bs.dropdown",o=new a(this)),"string"==typeof e&&o[e].call(i)})}var n=".dropdown-backdrop",s='[data-toggle="dropdown"]',a=function(e){t(e).on("click.bs.dropdown",this.toggle)};a.VERSION="3.4.1",a.prototype.toggle=function(o){var n=t(this);if(!n.is(".disabled, :disabled")){var s=e(n),a=s.hasClass("open");if(i(),!a){"ontouchstart"in document.documentElement&&!s.closest(".navbar-nav").length&&t(document.createElement("div")).addClass("dropdown-backdrop").insertAfter(t(this)).on("click",i);var r={relatedTarget:this};if(s.trigger(o=t.Event("show.bs.dropdown",r)),o.isDefaultPrevented())return;n.trigger("focus").attr("aria-expanded","true"),s.toggleClass("open").trigger(t.Event("shown.bs.dropdown",r))}return!1}},a.prototype.keydown=function(i){if(/(38|40|27|32)/.test(i.which)&&!/input|textarea/i.test(i.target.tagName)){var o=t(this);if(i.preventDefault(),i.stopPropagation(),!o.is(".disabled, :disabled")){var n=e(o),a=n.hasClass("open");if(!a&&27!=i.which||a&&27==i.which)return 27==i.which&&n.find(s).trigger("focus"),o.trigger("click");var r=" li:not(.disabled):visible a",l=n.find(".dropdown-menu"+r);if(l.length){var h=l.index(i.target);38==i.which&&h>0&&h--,40==i.which&&h<l.length-1&&h++,~h||(h=0),l.eq(h).trigger("focus")}}}};var r=t.fn.dropdown;t.fn.dropdown=o,t.fn.dropdown.Constructor=a,t.fn.dropdown.noConflict=function(){return t.fn.dropdown=r,this},t(document).on("click.bs.dropdown.data-api",i).on("click.bs.dropdown.data-api",".dropdown form",function(t){t.stopPropagation()}).on("click.bs.dropdown.data-api",s,a.prototype.toggle).on("keydown.bs.dropdown.data-api",s,a.prototype.keydown).on("keydown.bs.dropdown.data-api",".dropdown-menu",a.prototype.keydown)}(jQuery),function(t){"use strict";function e(e,o){return this.each(function(){var n=t(this),s=n.data("bs.modal"),a=t.extend({},i.DEFAULTS,n.data(),"object"==typeof e&&e);s||n.data("bs.modal",s=new i(this,a)),"string"==typeof e?s[e](o):a.show&&s.show(o)})}var i=function(e,i){this.options=i,this.$body=t(document.body),this.$element=t(e),this.$dialog=this.$element.find(".modal-dialog"),this.$backdrop=null,this.isShown=null,this.isIng=null,this.originalBodyPad=null,this.scrollbarWidth=0,this.ignoreBackdropClick=!1,this.fixedContent=".navbar-fixed-top, .navbar-fixed-bottom",this.options.remote&&this.$element.find(".modal-content").load(this.options.remote,t.proxy(function(){this.$element.trigger("loaded.bs.modal")},this))};i.VERSION="3.4.1",i.TRANSITION_DURATION=300,i.BACKDROP_TRANSITION_DURATION=150,i.DEFAULTS={backdrop:!0,keyboard:!0,show:!0},i.prototype.toggle=function(t){return this.isShown?this.hide():this.show(t)},i.prototype.show=function(e){if(!this.isIng){var o=this,n=t.Event("show.bs.modal",{relatedTarget:e});this.$element.trigger(n),this.isShown||n.isDefaultPrevented()||(this.isIng=!0,this.isShown=!0,this.checkScrollbar(),this.setScrollbar(),this.$body.addClass("modal-open"),this.escape(),this.resize(),this.$element.on("click.dismiss.bs.modal",'[data-dismiss="modal"]',t.proxy(this.hide,this)),this.$dialog.on("mousedown.dismiss.bs.modal",function(){o.$element.one("mouseup.dismiss.bs.modal",function(e){t(e.target).is(o.$element)&&(o.ignoreBackdropClick=!0)})}),this.backdrop(function(){var n=t.support.transition&&o.$element.hasClass("fade");o.$element.parent().length||o.$element.appendTo(o.$body),o.$element.show().scrollTop(0),o.adjustDialog(),n&&o.$element[0].offsetWidth,o.$element.addClass("in"),o.enforceFocus();var s=t.Event("shown.bs.modal",{relatedTarget:e});n?o.$dialog.one("bsTransitionEnd",function(){o.$element.trigger("focus").trigger(s),o.isIng=!1}).emulateTransitionEnd(i.TRANSITION_DURATION):o.$element.trigger("focus").trigger(s),o.isIng=!1}))}},i.prototype.hide=function(e){this.isIng||(e&&e.preventDefault(),e=t.Event("hide.bs.modal"),this.$element.trigger(e),this.isShown&&!e.isDefaultPrevented()&&(this.isIng=!0,this.isShown=!1,this.escape(),this.resize(),t(document).off("focusin.bs.modal"),this.$element.removeClass("in").off("click.dismiss.bs.modal").off("mouseup.dismiss.bs.modal"),this.$dialog.off("mousedown.dismiss.bs.modal"),t.support.transition&&this.$element.hasClass("fade")?this.$element.one("bsTransitionEnd",t.proxy(this.hideModal,this)).emulateTransitionEnd(i.TRANSITION_DURATION):this.hideModal()))},i.prototype.enforceFocus=function(){t(document).off("focusin.bs.modal").on("focusin.bs.modal",t.proxy(function(t){document===t.target||this.$element[0]===t.target||this.$element.has(t.target).length||this.$element.trigger("focus")},this))},i.prototype.escape=function(){this.isShown&&this.options.keyboard?this.$element.on("keydown.dismiss.bs.modal",t.proxy(function(t){27==t.which&&this.hide()},this)):this.isShown||this.$element.off("keydown.dismiss.bs.modal")},i.prototype.resize=function(){this.isShown?t(window).on("resize.bs.modal",t.proxy(this.handleUpdate,this)):t(window).off("resize.bs.modal")},i.prototype.hideModal=function(){var t=this;this.$element.hide(),this.backdrop(function(){t.isIng=!1,t.$body.find(".modal.in").length||t.$body.removeClass("modal-open"),t.resetScrollbar(),t.resetAdjustments(),t.$element.trigger("hidden.bs.modal")})},i.prototype.removeBackdrop=function(){this.$backdrop&&this.$backdrop.remove(),this.$backdrop=null},i.prototype.backdrop=function(e){var o=this,n=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var s=t.support.transition&&n;if(this.$backdrop=t(document.createElement("div")).addClass("modal-backdrop "+n).appendTo(this.$body),this.$element.on("click.dismiss.bs.modal",t.proxy(function(t){this.ignoreBackdropClick?this.ignoreBackdropClick=!1:t.target===t.currentTarget&&("static"==this.options.backdrop?this.$element[0].focus():this.hide())},this)),s&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),!e)return;s?this.$backdrop.one("bsTransitionEnd",e).emulateTransitionEnd(i.BACKDROP_TRANSITION_DURATION):e()}else if(!this.isShown&&this.$backdrop){this.$backdrop.removeClass("in");var a=function(){o.removeBackdrop(),e&&e()};t.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one("bsTransitionEnd",a).emulateTransitionEnd(i.BACKDROP_TRANSITION_DURATION):a()}else e&&e()},i.prototype.handleUpdate=function(){this.adjustDialog()},i.prototype.adjustDialog=function(){var t=this.$element[0].scrollHeight>document.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&t?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!t?this.scrollbarWidth:""})},i.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})},i.prototype.checkScrollbar=function(){var t=window.innerWidth;if(!t){var e=document.documentElement.getBoundingClientRect();t=e.right-Math.abs(e.left)}this.bodyIsOverflowing=document.body.clientWidth<t,this.scrollbarWidth=this.measureScrollbar()},i.prototype.setScrollbar=function(){var e=parseInt(this.$body.css("padding-right")||0,10);this.originalBodyPad=document.body.style.paddingRight||"";var i=this.scrollbarWidth;this.bodyIsOverflowing&&(this.$body.css("padding-right",e+i),t(this.fixedContent).each(function(e,o){var n=o.style.paddingRight,s=t(o).css("padding-right");t(o).data("padding-right",n).css("padding-right",parseFloat(s)+i+"px")}))},i.prototype.resetScrollbar=function(){this.$body.css("padding-right",this.originalBodyPad),t(this.fixedContent).each(function(e,i){var o=t(i).data("padding-right");t(i).removeData("padding-right"),i.style.paddingRight=o||""})},i.prototype.measureScrollbar=function(){var t=document.createElement("div");t.className="modal-scrollbar-measure",this.$body.append(t);var e=t.offsetWidth-t.clientWidth;return this.$body[0].removeChild(t),e};var o=t.fn.modal;t.fn.modal=e,t.fn.modal.Constructor=i,t.fn.modal.noConflict=function(){return t.fn.modal=o,this},t(document).on("click.bs.modal.data-api",'[data-toggle="modal"]',function(i){var o=t(this),n=o.attr("href"),s=o.attr("data-target")||n&&n.replace(/.*(?=#[^\s]+$)/,""),a=t(document).find(s),r=a.data("bs.modal")?"toggle":t.extend({remote:!/#|javascript/.test(n)&&n},a.data(),o.data());o.is("a")&&i.preventDefault(),a.one("show.bs.modal",function(t){t.isDefaultPrevented()||a.one("hidden.bs.modal",function(){o.is(":visible")&&o.trigger("focus")})}),e.call(a,r,this)})}(jQuery),function(t){"use strict";function e(e,i){var o=e.nodeName.toLowerCase();if(-1!==t.inArray(o,i))return-1===t.inArray(o,s)||Boolean(e.nodeValue.match(l)||e.nodeValue.match(h));for(var n=t(i).filter(function(t,e){return e instanceof RegExp}),a=0,r=n.length;a<r;a++)if(o.match(n[a]))return!0;return!1}function i(i,o,n){if(0===i.length)return i;if(n&&"function"==typeof n)return n(i);if(!document.implementation||!document.implementation.createHTMLDocument)return i;var s=document.implementation.createHTMLDocument("sanitization");s.body.innerHTML=i;for(var a=t.map(o,function(t,e){return e}),r=t(s.body).find("*"),l=0,h=r.length;l<h;l++){var d=r[l],p=d.nodeName.toLowerCase();if(-1!==t.inArray(p,a))for(var c=t.map(d.attributes,function(t){return t}),f=[].concat(o["*"]||[],o[p]||[]),u=0,g=c.length;u<g;u++)e(c[u],f)||d.removeAttribute(c[u].nodeName);else d.parentNode.removeChild(d)}return s.body.innerHTML}function o(e){return this.each(function(){var i=t(this),o=i.data("bs.tooltip"),n="object"==typeof e&&e;!o&&/destroy|hide/.test(e)||(o||i.data("bs.tooltip",o=new d(this,n)),"string"==typeof e&&o[e]())})}var n=["sanitize","whiteList","sanitizeFn"],s=["background","cite","href","itemtype","longdesc","poster","src","xlink:href"],a=/^aria-[\w-]*$/i,r={"*":["class","dir","id","lang","role",a],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],div:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]},l=/^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi,h=/^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i,d=function(t,e){this.type=null,this.options=null,this.enabled=null,this.timeout=null,this.hoverState=null,this.$element=null,this.inState=null,this.init("tooltip",t,e)};d.VERSION="3.4.1",d.TRANSITION_DURATION=150,d.DEFAULTS={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0},sanitize:!0,sanitizeFn:null,whiteList:r},d.prototype.init=function(e,i,o){if(this.enabled=!0,this.type=e,this.$element=t(i),this.options=this.getOptions(o),this.$viewport=this.options.viewport&&t(document).find(t.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):this.options.viewport.selector||this.options.viewport),this.inState={click:!1,hover:!1,focus:!1},this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var n=this.options.trigger.split(" "),s=n.length;s--;){var a=n[s];if("click"==a)this.$element.on("click."+this.type,this.options.selector,t.proxy(this.toggle,this));else if("manual"!=a){var r="hover"==a?"mouseenter":"focusin",l="hover"==a?"mouseleave":"focusout";this.$element.on(r+"."+this.type,this.options.selector,t.proxy(this.enter,this)),this.$element.on(l+"."+this.type,this.options.selector,t.proxy(this.leave,this))}}this.options.selector?this._options=t.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},d.prototype.getDefaults=function(){return d.DEFAULTS},d.prototype.getOptions=function(e){var o=this.$element.data();for(var s in o)o.hasOwnProperty(s)&&-1!==t.inArray(s,n)&&delete o[s];return e=t.extend({},this.getDefaults(),o,e),e.delay&&"number"==typeof e.delay&&(e.delay={show:e.delay,hide:e.delay}),e.sanitize&&(e.template=i(e.template,e.whiteList,e.sanitizeFn)),e},d.prototype.getDelegateOptions=function(){var e={},i=this.getDefaults();return this._options&&t.each(this._options,function(t,o){i[t]!=o&&(e[t]=o)}),e},d.prototype.enter=function(e){var i=e instanceof this.constructor?e:t(e.currentTarget).data("bs."+this.type);if(i||(i=new this.constructor(e.currentTarget,this.getDelegateOptions()),t(e.currentTarget).data("bs."+this.type,i)),e instanceof t.Event&&(i.inState["focusin"==e.type?"focus":"hover"]=!0),i.tip().hasClass("in")||"in"==i.hoverState)i.hoverState="in";else{if(clearTimeout(i.timeout),i.hoverState="in",!i.options.delay||!i.options.delay.show)return i.show();i.timeout=setTimeout(function(){"in"==i.hoverState&&i.show()},i.options.delay.show)}},d.prototype.isInStateTrue=function(){for(var t in this.inState)if(this.inState[t])return!0;return!1},d.prototype.leave=function(e){var i=e instanceof this.constructor?e:t(e.currentTarget).data("bs."+this.type);if(i||(i=new this.constructor(e.currentTarget,this.getDelegateOptions()),t(e.currentTarget).data("bs."+this.type,i)),e instanceof t.Event&&(i.inState["focusout"==e.type?"focus":"hover"]=!1),!i.isInStateTrue()){if(clearTimeout(i.timeout),i.hoverState="out",!i.options.delay||!i.options.delay.hide)return i.hide();i.timeout=setTimeout(function(){"out"==i.hoverState&&i.hide()},i.options.delay.hide)}},d.prototype.show=function(){var e=t.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(e);var i=t.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(e.isDefaultPrevented()||!i)return;var o=this,n=this.tip(),s=this.getUID(this.type);this.setContent(),n.attr("id",s),this.$element.attr("aria-describedby",s),this.options.animation&&n.addClass("fade");var a="function"==typeof this.options.placement?this.options.placement.call(this,n[0],this.$element[0]):this.options.placement,r=/\s?auto?\s?/i,l=r.test(a);l&&(a=a.replace(r,"")||"top"),n.detach().css({top:0,left:0,display:"block"}).addClass(a).data("bs."+this.type,this),this.options.container?n.appendTo(t(document).find(this.options.container)):n.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var h=this.getPosition(),p=n[0].offsetWidth,c=n[0].offsetHeight;if(l){var f=a,u=this.getPosition(this.$viewport);a="bottom"==a&&h.bottom+c>u.bottom?"top":"top"==a&&h.top-c<u.top?"bottom":"right"==a&&h.right+p>u.width?"left":"left"==a&&h.left-p<u.left?"right":a,n.removeClass(f).addClass(a)}var g=this.getCalculatedOffset(a,h,p,c);this.applyPlacement(g,a);var m=function(){var t=o.hoverState;o.$element.trigger("shown.bs."+o.type),o.hoverState=null,"out"==t&&o.leave(o)};t.support.transition&&this.$tip.hasClass("fade")?n.one("bsTransitionEnd",m).emulateTransitionEnd(d.TRANSITION_DURATION):m()}},d.prototype.applyPlacement=function(e,i){var o=this.tip(),n=o[0].offsetWidth,s=o[0].offsetHeight,a=parseInt(o.css("margin-top"),10),r=parseInt(o.css("margin-left"),10);isNaN(a)&&(a=0),isNaN(r)&&(r=0),e.top+=a,e.left+=r,t.offset.setOffset(o[0],t.extend({using:function(t){o.css({top:Math.round(t.top),left:Math.round(t.left)})}},e),0),o.addClass("in");var l=o[0].offsetWidth,h=o[0].offsetHeight;"top"==i&&h!=s&&(e.top=e.top+s-h);var d=this.getViewportAdjustedDelta(i,e,l,h);d.left?e.left+=d.left:e.top+=d.top;var p=/top|bottom/.test(i),c=p?2*d.left-n+l:2*d.top-s+h,f=p?"offsetWidth":"offsetHeight";o.offset(e),this.replaceArrow(c,o[0][f],p)},d.prototype.replaceArrow=function(t,e,i){this.arrow().css(i?"left":"top",50*(1-t/e)+"%").css(i?"top":"left","")},d.prototype.setContent=function(){var t=this.tip(),e=this.getTitle();this.options.html?(this.options.sanitize&&(e=i(e,this.options.whiteList,this.options.sanitizeFn)),t.find(".tooltip-inner").html(e)):t.find(".tooltip-inner").text(e),t.removeClass("fade in top bottom left right")},d.prototype.hide=function(e){function i(){"in"!=o.hoverState&&n.detach(),o.$element&&o.$element.removeAttr("aria-describedby").trigger("hidden.bs."+o.type),e&&e()}var o=this,n=t(this.$tip),s=t.Event("hide.bs."+this.type);if(this.$element.trigger(s),!s.isDefaultPrevented())return n.removeClass("in"),t.support.transition&&n.hasClass("fade")?n.one("bsTransitionEnd",i).emulateTransitionEnd(d.TRANSITION_DURATION):i(),this.hoverState=null,this},d.prototype.fixTitle=function(){var t=this.$element;(t.attr("title")||"string"!=typeof t.attr("data-original-title"))&&t.attr("data-original-title",t.attr("title")||"").attr("title","")},d.prototype.hasContent=function(){return this.getTitle()},d.prototype.getPosition=function(e){e=e||this.$element;var i=e[0],o="BODY"==i.tagName,n=i.getBoundingClientRect();null==n.width&&(n=t.extend({},n,{width:n.right-n.left,height:n.bottom-n.top}));var s=window.SVGElement&&i instanceof window.SVGElement,a=o?{top:0,left:0}:s?null:e.offset(),r={scroll:o?document.documentElement.scrollTop||document.body.scrollTop:e.scrollTop()},l=o?{width:t(window).width(),height:t(window).height()}:null;return t.extend({},n,r,l,a)},d.prototype.getCalculatedOffset=function(t,e,i,o){return"bottom"==t?{top:e.top+e.height,left:e.left+e.width/2-i/2}:"top"==t?{top:e.top-o,left:e.left+e.width/2-i/2}:"left"==t?{top:e.top+e.height/2-o/2,left:e.left-i}:{top:e.top+e.height/2-o/2,left:e.left+e.width}},d.prototype.getViewportAdjustedDelta=function(t,e,i,o){var n={top:0,left:0};if(!this.$viewport)return n;var s=this.options.viewport&&this.options.viewport.padding||0,a=this.getPosition(this.$viewport);if(/right|left/.test(t)){var r=e.top-s-a.scroll,l=e.top+s-a.scroll+o;r<a.top?n.top=a.top-r:l>a.top+a.height&&(n.top=a.top+a.height-l)}else{var h=e.left-s,d=e.left+s+i;h<a.left?n.left=a.left-h:d>a.right&&(n.left=a.left+a.width-d)}return n},d.prototype.getTitle=function(){var t,e=this.$element,i=this.options;return t=e.attr("data-original-title")||("function"==typeof i.title?i.title.call(e[0]):i.title),t},d.prototype.getUID=function(t){do{t+=~~(1e6*Math.random())}while(document.getElementById(t));return t},d.prototype.tip=function(){if(!this.$tip&&(this.$tip=t(this.options.template),1!=this.$tip.length))throw new Error(this.type+" `template` option must consist of exactly 1 top-level element!");return this.$tip},d.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},d.prototype.enable=function(){this.enabled=!0},d.prototype.disable=function(){this.enabled=!1},d.prototype.toggleEnabled=function(){this.enabled=!this.enabled},d.prototype.toggle=function(e){var i=this;e&&(i=t(e.currentTarget).data("bs."+this.type),i||(i=new this.constructor(e.currentTarget,this.getDelegateOptions()),t(e.currentTarget).data("bs."+this.type,i))),e?(i.inState.click=!i.inState.click,i.isInStateTrue()?i.enter(i):i.leave(i)):i.tip().hasClass("in")?i.leave(i):i.enter(i)},d.prototype.destroy=function(){var t=this;clearTimeout(this.timeout),this.hide(function(){t.$element.off("."+t.type).removeData("bs."+t.type),t.$tip&&t.$tip.detach(),t.$tip=null,t.$arrow=null,t.$viewport=null,t.$element=null})},d.prototype.sanitizeHtml=function(t){return i(t,this.options.whiteList,this.options.sanitizeFn)};var p=t.fn.tooltip;t.fn.tooltip=o,t.fn.tooltip.Constructor=d,t.fn.tooltip.noConflict=function(){return t.fn.tooltip=p,this}}(jQuery),function(t){"use strict";function e(e){return this.each(function(){var o=t(this),n=o.data("bs.popover"),s="object"==typeof e&&e;!n&&/destroy|hide/.test(e)||(n||o.data("bs.popover",n=new i(this,s)),"string"==typeof e&&n[e]())})}var i=function(t,e){this.init("popover",t,e)};if(!t.fn.tooltip)throw new Error("Popover requires tooltip.js");i.VERSION="3.4.1",i.DEFAULTS=t.extend({},t.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:'<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'}),i.prototype=t.extend({},t.fn.tooltip.Constructor.prototype),i.prototype.constructor=i,i.prototype.getDefaults=function(){
|
||
return i.DEFAULTS},i.prototype.setContent=function(){var t=this.tip(),e=this.getTitle(),i=this.getContent();if(this.options.html){var o=typeof i;this.options.sanitize&&(e=this.sanitizeHtml(e),"string"===o&&(i=this.sanitizeHtml(i))),t.find(".popover-title").html(e),t.find(".popover-content").children().detach().end()["string"===o?"html":"append"](i)}else t.find(".popover-title").text(e),t.find(".popover-content").children().detach().end().text(i);t.removeClass("fade top bottom left right in"),t.find(".popover-title").html()||t.find(".popover-title").hide()},i.prototype.hasContent=function(){return this.getTitle()||this.getContent()},i.prototype.getContent=function(){var t=this.$element,e=this.options;return t.attr("data-content")||("function"==typeof e.content?e.content.call(t[0]):e.content)},i.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var o=t.fn.popover;t.fn.popover=e,t.fn.popover.Constructor=i,t.fn.popover.noConflict=function(){return t.fn.popover=o,this}}(jQuery),function(t){"use strict";function e(i,o){this.$body=t(document.body),this.$scrollElement=t(i).is(document.body)?t(window):t(i),this.options=t.extend({},e.DEFAULTS,o),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",t.proxy(this.process,this)),this.refresh(),this.process()}function i(i){return this.each(function(){var o=t(this),n=o.data("bs.scrollspy"),s="object"==typeof i&&i;n||o.data("bs.scrollspy",n=new e(this,s)),"string"==typeof i&&n[i]()})}e.VERSION="3.4.1",e.DEFAULTS={offset:10},e.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},e.prototype.refresh=function(){var e=this,i="offset",o=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),t.isWindow(this.$scrollElement[0])||(i="position",o=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var e=t(this),n=e.data("target")||e.attr("href"),s=/^#./.test(n)&&t(n);return s&&s.length&&s.is(":visible")&&[[s[i]().top+o,n]]||null}).sort(function(t,e){return t[0]-e[0]}).each(function(){e.offsets.push(this[0]),e.targets.push(this[1])})},e.prototype.process=function(){var t,e=this.$scrollElement.scrollTop()+this.options.offset,i=this.getScrollHeight(),o=this.options.offset+i-this.$scrollElement.height(),n=this.offsets,s=this.targets,a=this.activeTarget;if(this.scrollHeight!=i&&this.refresh(),e>=o)return a!=(t=s[s.length-1])&&this.activate(t);if(a&&e<n[0])return this.activeTarget=null,this.clear();for(t=n.length;t--;)a!=s[t]&&e>=n[t]&&(void 0===n[t+1]||e<n[t+1])&&this.activate(s[t])},e.prototype.activate=function(e){this.activeTarget=e,this.clear();var i=this.selector+'[data-target="'+e+'"],'+this.selector+'[href="'+e+'"]',o=t(i).parents("li").addClass("active");o.parent(".dropdown-menu").length&&(o=o.closest("li.dropdown").addClass("active")),o.trigger("activate.bs.scrollspy")},e.prototype.clear=function(){t(this.selector).parentsUntil(this.options.target,".active").removeClass("active")};var o=t.fn.scrollspy;t.fn.scrollspy=i,t.fn.scrollspy.Constructor=e,t.fn.scrollspy.noConflict=function(){return t.fn.scrollspy=o,this},t(window).on("load.bs.scrollspy.data-api",function(){t('[data-spy="scroll"]').each(function(){var e=t(this);i.call(e,e.data())})})}(jQuery),function(t){"use strict";function e(e){return this.each(function(){var o=t(this),n=o.data("bs.tab");n||o.data("bs.tab",n=new i(this)),"string"==typeof e&&n[e]()})}var i=function(e){this.element=t(e)};i.VERSION="3.4.1",i.TRANSITION_DURATION=150,i.prototype.show=function(){var e=this.element,i=e.closest("ul:not(.dropdown-menu)"),o=e.data("target");if(o||(o=e.attr("href"),o=o&&o.replace(/.*(?=#[^\s]*$)/,"")),!e.parent("li").hasClass("active")){var n=i.find(".active:last a"),s=t.Event("hide.bs.tab",{relatedTarget:e[0]}),a=t.Event("show.bs.tab",{relatedTarget:n[0]});if(n.trigger(s),e.trigger(a),!a.isDefaultPrevented()&&!s.isDefaultPrevented()){var r=t(document).find(o);this.activate(e.closest("li"),i),this.activate(r,r.parent(),function(){n.trigger({type:"hidden.bs.tab",relatedTarget:e[0]}),e.trigger({type:"shown.bs.tab",relatedTarget:n[0]})})}}},i.prototype.activate=function(e,o,n){function s(){a.removeClass("active").find("> .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),e.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),r?(e[0].offsetWidth,e.addClass("in")):e.removeClass("fade"),e.parent(".dropdown-menu").length&&e.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),n&&n()}var a=o.find("> .active"),r=n&&t.support.transition&&(a.length&&a.hasClass("fade")||!!o.find("> .fade").length);a.length&&r?a.one("bsTransitionEnd",s).emulateTransitionEnd(i.TRANSITION_DURATION):s(),a.removeClass("in")};var o=t.fn.tab;t.fn.tab=e,t.fn.tab.Constructor=i,t.fn.tab.noConflict=function(){return t.fn.tab=o,this};var n=function(i){i.preventDefault(),e.call(t(this),"show")};t(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',n).on("click.bs.tab.data-api",'[data-toggle="pill"]',n)}(jQuery),function(t){"use strict";function e(e){return this.each(function(){var o=t(this),n=o.data("bs.affix"),s="object"==typeof e&&e;n||o.data("bs.affix",n=new i(this,s)),"string"==typeof e&&n[e]()})}var i=function(e,o){this.options=t.extend({},i.DEFAULTS,o);var n=this.options.target===i.DEFAULTS.target?t(this.options.target):t(document).find(this.options.target);this.$target=n.on("scroll.bs.affix.data-api",t.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",t.proxy(this.checkPositionWithEventLoop,this)),this.$element=t(e),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};i.VERSION="3.4.1",i.RESET="affix affix-top affix-bottom",i.DEFAULTS={offset:0,target:window},i.prototype.getState=function(t,e,i,o){var n=this.$target.scrollTop(),s=this.$element.offset(),a=this.$target.height();if(null!=i&&"top"==this.affixed)return n<i&&"top";if("bottom"==this.affixed)return null!=i?!(n+this.unpin<=s.top)&&"bottom":!(n+a<=t-o)&&"bottom";var r=null==this.affixed,l=r?n:s.top,h=r?a:e;return null!=i&&n<=i?"top":null!=o&&l+h>=t-o&&"bottom"},i.prototype.getPinnedOffset=function(){this.$element.removeClass(i.RESET).addClass("affix");var t=this.$target.scrollTop(),e=this.$element.offset();return this.pinnedOffset=e.top-t},i.prototype.checkPositionWithEventLoop=function(){setTimeout(t.proxy(this.checkPosition,this),1)},i.prototype.checkPosition=function(){if(this.$element.is(":visible")){var e=this.$element.height(),o=this.options.offset,n=o.top,s=o.bottom,a=Math.max(t(document).height(),t(document.body).height());"object"!=typeof o&&(s=n=o),"function"==typeof n&&(n=o.top(this.$element)),"function"==typeof s&&(s=o.bottom(this.$element));var r=this.getState(a,e,n,s);if(this.affixed!=r){null!=this.unpin&&this.$element.css("top","");var l="affix"+(r?"-"+r:""),h=t.Event(l+".bs.affix");if(this.$element.trigger(h),h.isDefaultPrevented())return;this.affixed=r,this.unpin="bottom"==r?this.getPinnedOffset():null,this.$element.removeClass(i.RESET).addClass(l).trigger(l.replace("affix","affixed")+".bs.affix")}"bottom"==r&&this.$element.offset({top:a-e-s})}};var o=t.fn.affix;t.fn.affix=e,t.fn.affix.Constructor=i,t.fn.affix.noConflict=function(){return t.fn.affix=o,this},t(window).on("load",function(){t('[data-spy="affix"]').each(function(){var i=t(this),o=i.data();o.offset=o.offset||{},null!=o.offsetBottom&&(o.offset.bottom=o.offsetBottom),null!=o.offsetTop&&(o.offset.top=o.offsetTop),e.call(i,o)})})}(jQuery);
|
||
;
|
||
|
||
/* source: assets/js/runtime/loader.js */
|
||
/**
|
||
* Legacy module loader (RequireJS 2.1.14 derivative, tbquire/tbfine).
|
||
*
|
||
* @package AKSRT
|
||
*/
|
||
/*
|
||
RequireJS 2.1.14 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
|
||
Available via the MIT or new BSD license.
|
||
see: http://github.com/jrburke/tbquirejs for details
|
||
*/
|
||
var tbquirejs,tbquire,tbfine;
|
||
(function(ba){function G(b){return"[object Function]"===K.call(b)}function H(b){return"[object Array]"===K.call(b)}function v(b,c){if(b){var d;for(d=0;d<b.length&&(!b[d]||!c(b[d],d,b));d+=1);}}function T(b,c){if(b){var d;for(d=b.length-1;-1<d&&(!b[d]||!c(b[d],d,b));d-=1);}}function t(b,c){return fa.call(b,c)}function m(b,c){return t(b,c)&&b[c]}function B(b,c){for(var d in b)if(t(b,d)&&c(b[d],d))break}function U(b,c,d,e){c&&B(c,function(c,g){if(d||!t(b,g))e&&"object"===typeof c&&c&&!H(c)&&!G(c)&&!(c instanceof
|
||
RegExp)?(b[g]||(b[g]={}),U(b[g],c,d,e)):b[g]=c});return b}function u(b,c){return function(){return c.apply(b,arguments)}}function ca(b){throw b;}function da(b){if(!b)return b;var c=ba;v(b.split("."),function(b){c=c[b]});return c}function C(b,c,d,e){c=Error(c+"\ntbquire动态加载提醒#"+b);c.tbquireType=b;c.tbquireModules=e;d&&(c.originalError=d);return c}function ga(b){function c(a,k,b){var f,l,c,d,e,g,i,p,k=k&&k.split("/"),h=j.map,n=h&&h["*"];if(a){a=a.split("/");l=a.length-1;j.nodeIdCompat&&
|
||
Q.test(a[l])&&(a[l]=a[l].replace(Q,""));"."===a[0].charAt(0)&&k&&(l=k.slice(0,k.length-1),a=l.concat(a));l=a;for(c=0;c<l.length;c++)if(d=l[c],"."===d)l.splice(c,1),c-=1;else if(".."===d&&!(0===c||1==c&&".."===l[2]||".."===l[c-1])&&0<c)l.splice(c-1,2),c-=2;a=a.join("/")}if(b&&h&&(k||n)){l=a.split("/");c=l.length;a:for(;0<c;c-=1){e=l.slice(0,c).join("/");if(k)for(d=k.length;0<d;d-=1)if(b=m(h,k.slice(0,d).join("/")))if(b=m(b,e)){f=b;g=c;break a}!i&&(n&&m(n,e))&&(i=m(n,e),p=c)}!f&&i&&(f=i,g=p);f&&(l.splice(0,
|
||
g,f),a=l.join("/"))}return(f=m(j.pkgs,a))?f:a}function d(a){z&&v(document.getElementsByTagName("script"),function(k){if(k.getAttribute("data-tbquiremodule")===a&&k.getAttribute("data-tbquirecontext")===i.contextName)return k.parentNode.removeChild(k),!0})}function e(a){var k=m(j.paths,a);if(k&&H(k)&&1<k.length)return k.shift(),i.tbquire.undef(a),i.makeRequire(null,{skipMap:!0})([a]),!0}function n(a){var k,c=a?a.indexOf("!"):-1;-1<c&&(k=a.substring(0,c),a=a.substring(c+1,a.length));return[k,a]}function p(a,
|
||
k,b,f){var l,d,e=null,g=k?k.name:null,j=a,p=!0,h="";a||(p=!1,a="_@r"+(K+=1));a=n(a);e=a[0];a=a[1];e&&(e=c(e,g,f),d=m(r,e));a&&(e?h=d&&d.normalize?d.normalize(a,function(a){return c(a,g,f)}):-1===a.indexOf("!")?c(a,g,f):a:(h=c(a,g,f),a=n(h),e=a[0],h=a[1],b=!0,l=i.nameToUrl(h)));b=e&&!d&&!b?"_unnormalized"+(O+=1):"";return{prefix:e,name:h,parentMap:k,unnormalized:!!b,url:l,originalName:j,isDefine:p,id:(e?e+"!"+h:h)+b}}function s(a){var k=a.id,b=m(h,k);b||(b=h[k]=new i.Module(a));return b}function q(a,
|
||
k,b){var f=a.id,c=m(h,f);if(t(r,f)&&(!c||c.defineEmitComplete))"defined"===k&&b(r[f]);else if(c=s(a),c.error&&"error"===k)b(c.error);else c.on(k,b)}function w(a,b){var c=a.tbquireModules,f=!1;if(b)b(a);else if(v(c,function(b){if(b=m(h,b))b.error=a,b.events.error&&(f=!0,b.emit("error",a))}),!f)g.onError(a)}function x(){R.length&&(ha.apply(A,[A.length,0].concat(R)),R=[])}function y(a){delete h[a];delete V[a]}function F(a,b,c){var f=a.map.id;a.error?a.emit("error",a.error):(b[f]=!0,v(a.depMaps,function(f,
|
||
d){var e=f.id,g=m(h,e);g&&(!a.depMatched[d]&&!c[e])&&(m(b,e)?(a.defineDep(d,r[e]),a.check()):F(g,b,c))}),c[f]=!0)}function D(){var a,b,c=(a=1E3*j.waitSeconds)&&i.startTime+a<(new Date).getTime(),f=[],l=[],g=!1,h=!0;if(!W){W=!0;B(V,function(a){var i=a.map,j=i.id;if(a.enabled&&(i.isDefine||l.push(a),!a.error))if(!a.inited&&c)e(j)?g=b=!0:(f.push(j),d(j));else if(!a.inited&&(a.fetched&&i.isDefine)&&(g=!0,!i.prefix))return h=!1});if(c&&f.length)return a=C("超时","动态加载超时: "+f,null,
|
||
f),a.contextName=i.contextName,w(a);h&&v(l,function(a){F(a,{},{})});if((!c||b)&&g)if((z||ea)&&!X)X=setTimeout(function(){X=0;D()},50);W=!1}}function E(a){t(r,a[0])||s(p(a[0],null,!0)).init(a[1],a[2])}function I(a){var a=a.currentTarget||a.srcElement,b=i.onScriptLoad;a.detachEvent&&!Y?a.detachEvent("onreadystatechange",b):a.removeEventListener("load",b,!1);b=i.onScriptError;(!a.detachEvent||Y)&&a.removeEventListener("error",b,!1);return{node:a,id:a&&a.getAttribute("data-tbquiremodule")}}function J(){var a;
|
||
for(x();A.length;){a=A.shift();if(null===a[0])return w(C("mismatch","Mismatched anonymous define() module: "+a[a.length-1]));E(a)}}var W,Z,i,L,X,j={waitSeconds:7,baseUrl:"./",paths:{},bundles:{},pkgs:{},shim:{},config:{}},h={},V={},$={},A=[],r={},S={},aa={},K=1,O=1;L={tbquire:function(a){return a.tbquire?a.tbquire:a.tbquire=i.makeRequire(a.map)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports?r[a.map.id]=a.exports:a.exports=r[a.map.id]={}},module:function(a){return a.module?
|
||
a.module:a.module={id:a.map.id,uri:a.map.url,config:function(){return m(j.config,a.map.id)||{}},exports:a.exports||(a.exports={})}}};Z=function(a){this.events=m($,a.id)||{};this.map=a;this.shim=m(j.shim,a.id);this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};Z.prototype={init:function(a,b,c,f){f=f||{};if(!this.inited){this.factory=b;if(c)this.on("error",c);else this.events.error&&(c=u(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.errback=
|
||
c;this.inited=!0;this.ignore=f.ignore;f.enabled||this.enabled?this.enable():this.check()}},defineDep:function(a,b){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=b)},fetch:function(){if(!this.fetched){this.fetched=!0;i.startTime=(new Date).getTime();var a=this.map;if(this.shim)i.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],u(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=
|
||
this.map.url;S[a]||(S[a]=!0,i.load(this.map.id,a))},check:function(){if(this.enabled&&!this.enabling){var a,b,c=this.map.id;b=this.depExports;var f=this.exports,l=this.factory;if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(1>this.depCount&&!this.defined){if(G(l)){if(this.events.error&&this.map.isDefine||g.onError!==ca)try{f=i.execCb(c,l,b,f)}catch(d){a=d}else f=i.execCb(c,l,b,f);this.map.isDefine&&void 0===f&&((b=this.module)?f=b.exports:this.usingExports&&
|
||
(f=this.exports));if(a)return a.tbquireMap=this.map,a.tbquireModules=this.map.isDefine?[this.map.id]:null,a.tbquireType=this.map.isDefine?"tbfine":"tbquire",w(this.error=a)}else f=l;this.exports=f;if(this.map.isDefine&&!this.ignore&&(r[c]=f,g.onResourceLoad))g.onResourceLoad(i,this.map,this.depMaps);y(c);this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else this.fetch()}},callPlugin:function(){var a=
|
||
this.map,b=a.id,d=p(a.prefix);this.depMaps.push(d);q(d,"defined",u(this,function(f){var l,d;d=m(aa,this.map.id);var e=this.map.name,P=this.map.parentMap?this.map.parentMap.name:null,n=i.makeRequire(a.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){if(f.normalize&&(e=f.normalize(e,function(a){return c(a,P,!0)})||""),f=p(a.prefix+"!"+e,this.map.parentMap),q(f,"defined",u(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),d=m(h,f.id)){this.depMaps.push(f);
|
||
if(this.events.error)d.on("error",u(this,function(a){this.emit("error",a)}));d.enable()}}else d?(this.map.url=i.nameToUrl(d),this.load()):(l=u(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),l.error=u(this,function(a){this.inited=!0;this.error=a;a.tbquireModules=[b];B(h,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&y(a.map.id)});w(a)}),l.fromText=u(this,function(f,c){var d=a.name,e=p(d),P=M;c&&(f=c);P&&(M=!1);s(e);t(j.config,b)&&(j.config[d]=j.config[b]);try{g.exec(f)}catch(h){return w(C("fromtexteval",
|
||
"fromText eval for "+b+" failed: "+h,h,[b]))}P&&(M=!0);this.depMaps.push(e);i.completeLoad(d);n([d],l)}),f.load(a.name,n,l,j))}));i.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){V[this.map.id]=this;this.enabling=this.enabled=!0;v(this.depMaps,u(this,function(a,b){var c,f;if("string"===typeof a){a=p(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=m(L,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;q(a,"defined",u(this,function(a){this.defineDep(b,
|
||
a);this.check()}));this.errback&&q(a,"error",u(this,this.errback))}c=a.id;f=h[c];!t(L,c)&&(f&&!f.enabled)&&i.enable(a,this)}));B(this.pluginMaps,u(this,function(a){var b=m(h,a.id);b&&!b.enabled&&i.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){v(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};i={config:j,contextName:b,registry:h,defined:r,urlFetched:S,defQueue:A,Module:Z,makeModuleMap:p,
|
||
nextTick:g.nextTick,onError:w,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=j.shim,c={paths:!0,bundles:!0,config:!0,map:!0};B(a,function(a,b){c[b]?(j[b]||(j[b]={}),U(j[b],a,!0,!0)):j[b]=a});a.bundles&&B(a.bundles,function(a,b){v(a,function(a){a!==b&&(aa[a]=b)})});a.shim&&(B(a.shim,function(a,c){H(a)&&(a={deps:a});if((a.exports||a.init)&&!a.exportsFn)a.exportsFn=i.makeShimExports(a);b[c]=a}),j.shim=b);a.packages&&v(a.packages,function(a){var b,
|
||
a="string"===typeof a?{name:a}:a;b=a.name;a.location&&(j.paths[b]=a.location);j.pkgs[b]=a.name+"/"+(a.main||"main").replace(ia,"").replace(Q,"")});B(h,function(a,b){!a.inited&&!a.map.unnormalized&&(a.map=p(b))});if(a.deps||a.callback)i.tbquire(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(ba,arguments));return b||a.exports&&da(a.exports)}},makeRequire:function(a,e){function j(c,d,m){var n,q;e.enableBuildCallback&&(d&&G(d))&&(d.__tbquireJsBuild=
|
||
!0);if("string"===typeof c){if(G(d))return w(C("tbquireargs","Invalid tbquire call"),m);if(a&&t(L,c))return L[c](h[a.id]);if(g.get)return g.get(i,c,a,j);n=p(c,a,!1,!0);n=n.id;return!t(r,n)?w(C("notloaded",'Module name "'+n+'" has not been loaded yet for context: '+b+(a?"":". Use tbquire([])"))):r[n]}J();i.nextTick(function(){J();q=s(p(null,a));q.skipMap=e.skipMap;q.init(c,d,m,{enabled:!0});D()});return j}e=e||{};U(j,{isBrowser:z,toUrl:function(b){var d,e=b.lastIndexOf("."),k=b.split("/")[0];if(-1!==
|
||
e&&(!("."===k||".."===k)||1<e))d=b.substring(e,b.length),b=b.substring(0,e);return i.nameToUrl(c(b,a&&a.id,!0),d,!0)},defined:function(b){return t(r,p(b,a,!1,!0).id)},specified:function(b){b=p(b,a,!1,!0).id;return t(r,b)||t(h,b)}});a||(j.undef=function(b){x();var c=p(b,a,!0),e=m(h,b);d(b);delete r[b];delete S[c.url];delete $[b];T(A,function(a,c){a[0]===b&&A.splice(c,1)});e&&(e.events.defined&&($[b]=e.events),y(b))});return j},enable:function(a){m(h,a.id)&&s(a).enable()},completeLoad:function(a){var b,
|
||
c,d=m(j.shim,a)||{},g=d.exports;for(x();A.length;){c=A.shift();if(null===c[0]){c[0]=a;if(b)break;b=!0}else c[0]===a&&(b=!0);E(c)}c=m(h,a);if(!b&&!t(r,a)&&c&&!c.inited){if(j.enforceDefine&&(!g||!da(g)))return e(a)?void 0:w(C("nodefine","No define call for "+a,null,[a]));E([a,d.deps||[],d.exportsFn])}D()},nameToUrl:function(a,b,c){var d,e,h;(d=m(j.pkgs,a))&&(a=d);if(d=m(aa,a))return i.nameToUrl(d,b,c);if(g.jsExtRegExp.test(a))d=a+(b||"");else{d=j.paths;a=a.split("/");for(e=a.length;0<e;e-=1)if(h=a.slice(0,
|
||
e).join("/"),h=m(d,h)){H(h)&&(h=h[0]);a.splice(0,e,h);break}d=a.join("/");d+=b||(/^data\:|\?/.test(d)||c?"":".js");d=("/"===d.charAt(0)||d.match(/^[\w\+\.\-]+:/)?"":j.baseUrl)+d}return j.urlArgs?d+((-1===d.indexOf("?")?"?":"&")+j.urlArgs):d},load:function(a,b){g.load(i,a,b)},execCb:function(a,b,c,d){return b.apply(d,c)},onScriptLoad:function(a){if("load"===a.type||ja.test((a.currentTarget||a.srcElement).readyState))N=null,a=I(a),i.completeLoad(a.id)},onScriptError:function(a){var b=I(a);if(!e(b.id))return w(C("js 加载失败",
|
||
"加载失败: "+b.id,a,[b.id]))}};i.tbquire=i.makeRequire();return i}var g,x,y,D,I,E,N,J,s,O,ka=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,la=/[^.]\s*tbquire\s*\(\s*["']([^'"\s]+)["']\s*\)/g,Q=/\.js$/,ia=/^\.\//;x=Object.prototype;var K=x.toString,fa=x.hasOwnProperty,ha=Array.prototype.splice,z=!!("undefined"!==typeof window&&"undefined"!==typeof navigator&&window.document),ea=!z&&"undefined"!==typeof importScripts,ja=z&&"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,
|
||
Y="undefined"!==typeof opera&&"[object Opera]"===opera.toString(),F={},q={},R=[],M=!1;if("undefined"===typeof define){if("undefined"!==typeof tbquirejs){if(G(tbquirejs))return;q=tbquirejs;tbquirejs=void 0}"undefined"!==typeof tbquire&&!G(tbquire)&&(q=tbquire,tbquire=void 0);g=tbquirejs=function(b,c,d,e){var n,p="_";!H(b)&&"string"!==typeof b&&(n=b,H(c)?(b=c,c=d,d=e):b=[]);n&&n.context&&(p=n.context);(e=m(F,p))||(e=F[p]=g.s.newContext(p));n&&e.configure(n);return e.tbquire(b,c,d)};g.config=function(b){return g(b)};
|
||
g.nextTick="undefined"!==typeof setTimeout?function(b){setTimeout(b,4)}:function(b){b()};tbquire||(tbquire=g);g.version="2.1.14";g.jsExtRegExp=/^\/|:|\?|\.js$/;g.isBrowser=z;x=g.s={contexts:F,newContext:ga};g({});v(["toUrl","undef","defined","specified"],function(b){g[b]=function(){var c=F._;return c.tbquire[b].apply(c,arguments)}});if(z&&(y=x.head=document.getElementsByTagName("head")[0],D=document.getElementsByTagName("base")[0]))y=x.head=D.parentNode;g.onError=ca;g.createNode=function(b){var c=
|
||
b.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script");/*c.type=b.scriptType||"text/javascript";c.charset="utf-8";*/c.async=!0;return c};g.load=function(b,c,d){var e=b&&b.config||{};if(z)return e=g.createNode(e,c,d),e.setAttribute("data-tbquirecontext",b.contextName),e.setAttribute("data-tbquiremodule",c),e.attachEvent&&!(e.attachEvent.toString&&0>e.attachEvent.toString().indexOf("[native code"))&&!Y?(M=!0,e.attachEvent("onreadystatechange",b.onScriptLoad)):
|
||
(e.addEventListener("load",b.onScriptLoad,!1),e.addEventListener("error",b.onScriptError,!1)),e.src=d,J=e,D?y.insertBefore(e,D):y.appendChild(e),J=null,e;if(ea)try{importScripts(d),b.completeLoad(c)}catch(m){b.onError(C("importscripts","importScripts failed for "+c+" at "+d,m,[c]))}};z&&!q.skipDataMain&&T(document.getElementsByTagName("script"),function(b){y||(y=b.parentNode);if(I=b.getAttribute("data-main"))return s=I,q.baseUrl||(E=s.split("/"),s=E.pop(),O=E.length?E.join("/")+"/":"./",q.baseUrl=
|
||
O),s=s.replace(Q,""),g.jsExtRegExp.test(s)&&(s=I),q.deps=q.deps?q.deps.concat(s):[s],!0});tbfine=function(b,c,d){var e,g;"string"!==typeof b&&(d=c,c=b,b=null);H(c)||(d=c,c=null);!c&&G(d)&&(c=[],d.length&&(d.toString().replace(ka,"").replace(la,function(b,d){c.push(d)}),c=(1===d.length?["tbquire"]:["tbquire","exports","module"]).concat(c)));if(M){if(!(e=J))N&&"interactive"===N.readyState||T(document.getElementsByTagName("script"),function(b){if("interactive"===b.readyState)return N=b}),e=N;e&&(b||
|
||
(b=e.getAttribute("data-tbquiremodule")),g=F[e.getAttribute("data-tbquirecontext")])}(g?g.defQueue:R).push([b,c,d])};tbfine.amd={jQuery:!0};g.exec=function(b){return eval(b)};g(q)}})(this);
|
||
|
||
tbquire.config({
|
||
baseUrl: _win.uri + '/js/runtime',
|
||
urlArgs: 'ver=' + _win.ver,
|
||
paths: {
|
||
'jquery.cookie' : 'libs/jquery.cookie.min',
|
||
'lazysizes' : 'libs/lazysizes.min',
|
||
'clipboard' : 'libs/clipboard.min',
|
||
'swiper' : 'libs/swiper.min',
|
||
'dplayer' : '../../widgets/third-party/DPlayer.min',
|
||
'dash' : '../../widgets/third-party/dash.all.min',
|
||
'hls' : '../../widgets/third-party/hls.min',
|
||
'flv' : '../../widgets/third-party/flv.min',
|
||
'grade' : 'libs/grade.min',
|
||
'qrcode' : 'libs/jquery.qrcode.min',
|
||
'sortablejs' : 'libs/Sortable.min',
|
||
'spark-md5' : 'libs/spark-md5.min',
|
||
'translate' : 'libs/translate.min',
|
||
'waterfall' : 'waterfall.min',
|
||
'enlighterjs' : 'enlighter/enlighterjs.min',
|
||
'imgbox' : 'imgbox.min',
|
||
'section-navs' : 'section-navs.min',
|
||
'poster-share' : 'poster-share.min',
|
||
'comment' : 'comment.min',
|
||
'page-template' : 'page-template.min',
|
||
'page-edit' : 'page-edit.min',
|
||
'author' : 'author.min',
|
||
'page-navs' : 'page-navs.min',
|
||
'input-expand' : 'input-expand.min',
|
||
'mini-touch' : 'mini-touch.min',
|
||
'mini-upload' : 'mini-upload.min',
|
||
'editextend' : 'editextend.min',
|
||
'petite-vue' : 'libs/petite-vue.iife',
|
||
'svg-icon' : 'svg-icon',
|
||
'tilt' : '../../widgets/third-party/vanilla-tilt.min',
|
||
'weixin-share' : 'weixin-share.min',
|
||
'weixin-sdk' : ['//res.wx.qq.com/open/js/jweixin-1.6.0','//res2.wx.qq.com/open/js/jweixin-1.6.0'],
|
||
'shop—main' : _win.uri+'/inc/functions/shop/assets/js/main.min',
|
||
}
|
||
})
|
||
;
|
||
|
||
/* source: assets/js/lazy-image-attr.js */
|
||
/**
|
||
* Build lazy-image attributes for dynamically rendered AKSRT markup.
|
||
* legacy owns the lazySizes runtime; this file only provides the shared bridge.
|
||
*/
|
||
(function (window) {
|
||
'use strict';
|
||
|
||
function escapeAttribute(value) {
|
||
return String(value == null ? '' : value)
|
||
.replace(/&/g, '&')
|
||
.replace(/"/g, '"')
|
||
.replace(/</g, '<')
|
||
.replace(/>/g, '>');
|
||
}
|
||
|
||
window.aksrtGetLazyImageAttr = function (key, src, className, size) {
|
||
var config = window.aksrtData || {};
|
||
var scopes = config.lazyScopes || {};
|
||
var classes = String(className || '').trim();
|
||
var realSrc = escapeAttribute(src);
|
||
|
||
if (!src || scopes[key] === false) {
|
||
return ' class="' + escapeAttribute(classes) + '" src="' + realSrc + '"';
|
||
}
|
||
|
||
var thumbs = config.lazyThumbs || {};
|
||
var placeholder = key === 'lazy_avatar'
|
||
? (config.lazyAvatar || thumbs.sm || '')
|
||
: (thumbs[size || 'default'] || thumbs.default || '');
|
||
|
||
return ' class="lazyload ' + escapeAttribute(classes) + '" src="' +
|
||
escapeAttribute(placeholder) + '" data-src="' + realSrc + '"';
|
||
};
|
||
})(window);
|
||
;
|
||
|
||
/* source: assets/js/rehydrate.js */
|
||
/**
|
||
* AKSRT Rehydrate System
|
||
*
|
||
* Centralized component initialization and re-initialization system.
|
||
* Components register their init functions, and rehydrate() is called
|
||
* to initialize or re-initialize them on a given root element.
|
||
*
|
||
* Usage:
|
||
* AksrtFrontend.register('name', initFn); // Register a component
|
||
* AksrtFrontend.rehydrate(root, 'init'); // Initialize all components
|
||
*
|
||
* @package AKSRT
|
||
* @since 5.0.0
|
||
*/
|
||
(function () {
|
||
'use strict';
|
||
|
||
var _registry = [];
|
||
var _initialized = [];
|
||
|
||
window.AksrtFrontend = {
|
||
|
||
/**
|
||
* Register a component's init function.
|
||
*
|
||
* @param {string} name Unique component name
|
||
* @param {Function} initFn Function(root, reason) - root defaults to document
|
||
*/
|
||
register: function (name, initFn) {
|
||
if (typeof name !== 'string' || typeof initFn !== 'function') return;
|
||
// Prevent duplicate registrations
|
||
for (var i = 0; i < _registry.length; i++) {
|
||
if (_registry[i].name === name) {
|
||
_registry[i].initFn = initFn;
|
||
return;
|
||
}
|
||
}
|
||
_registry.push({ name: name, initFn: initFn });
|
||
},
|
||
|
||
/**
|
||
* Initialize or re-initialize all registered components on a root element.
|
||
*
|
||
* @param {Element|Document} root The root DOM element to search within
|
||
* @param {string} reason Why rehydrate is called:
|
||
* 'init' = initial page load
|
||
* 'ajax' = after AJAX content injection
|
||
* 'modal' = after modal content loads
|
||
* Custom string for other triggers
|
||
*/
|
||
rehydrate: function (root, reason) {
|
||
root = root || document;
|
||
reason = reason || 'init';
|
||
|
||
for (var i = 0; i < _registry.length; i++) {
|
||
var entry = _registry[i];
|
||
try {
|
||
entry.initFn(root, reason);
|
||
} catch (err) {
|
||
console.error('[AKSRT Rehydrate] Error initializing "' + entry.name + '":', err);
|
||
}
|
||
}
|
||
|
||
// Dispatch event so external scripts can hook in
|
||
try {
|
||
root.dispatchEvent(new CustomEvent('aksrt:rehydrated', {
|
||
bubbles: true,
|
||
detail: { reason: reason }
|
||
}));
|
||
} catch (e) { /* IE fallback */ }
|
||
},
|
||
|
||
/**
|
||
* Get the list of registered component names (for debugging).
|
||
*/
|
||
getRegistered: function () {
|
||
return _registry.map(function (r) { return r.name; });
|
||
}
|
||
};
|
||
|
||
})();
|
||
;
|
||
|
||
/* source: assets/js/notyf.js */
|
||
/**
|
||
* legacy-compatible frontend notifications.
|
||
*
|
||
* @package AKSRT
|
||
*/
|
||
|
||
(function ($, window, document) {
|
||
'use strict';
|
||
|
||
function closeNotyf($element) {
|
||
$element.addClass('notyn-out');
|
||
window.setTimeout(function () {
|
||
$element.remove();
|
||
}, 1000);
|
||
}
|
||
|
||
function notyf(message, type, time, id) {
|
||
var $body = $(document.body);
|
||
|
||
if (!$('.notyn').length) {
|
||
$body.append('<div class="notyn"></div>');
|
||
}
|
||
|
||
type = type || 'success';
|
||
if (type === 'error') {
|
||
type = 'danger';
|
||
}
|
||
|
||
time = time || 5000;
|
||
time = time < 100 ? time * 1000 : time;
|
||
|
||
var idAttribute = id ? ' id="' + id + '"' : '';
|
||
var $notification = $('<div class="noty1"' + idAttribute + '><div class="notyf ' + type + '">' + message + '</div></div>');
|
||
var shouldClose = !id;
|
||
|
||
if (id && $('#' + id).length) {
|
||
$('#' + id)
|
||
.find('.notyf')
|
||
.removeClass()
|
||
.addClass('notyf ' + type)
|
||
.html(message);
|
||
$notification = $('#' + id);
|
||
shouldClose = true;
|
||
} else {
|
||
$('.notyn').append($notification);
|
||
}
|
||
|
||
if (shouldClose) {
|
||
window.setTimeout(function () {
|
||
closeNotyf($notification);
|
||
}, time);
|
||
}
|
||
}
|
||
|
||
$(document.body).on('click', '.noty1', function () {
|
||
closeNotyf($(this));
|
||
});
|
||
|
||
window.notyf = notyf;
|
||
})(jQuery, window, document);
|
||
;
|
||
|
||
/* source: assets/js/aksrt-runtime.js */
|
||
/**
|
||
* AKSRT Runtime Infrastructure
|
||
*
|
||
* Unified core primitives for the entire frontend:
|
||
* aksrt.tbquire(deps, cb) — lazy script/CSS loader
|
||
* aksrt.confirm(msg, opts) — i18n confirm dialog
|
||
* aksrt.scrollTopTo(target, off) — smart scroll with header offset
|
||
* aksrt.loading(el, show) — element-level loading overlay
|
||
* aksrt.route(url, title) — push/replace URL + title
|
||
*
|
||
* Declarative interactions (event delegation on body):
|
||
* [data-close] — close target element
|
||
* [data-onclick] — trigger click on another element
|
||
* [data-confirm] — confirm before action
|
||
* [data-action] — universal AJAX action button (like/follow/checkin)
|
||
* [ajax-action] — general AJAX button with modal response
|
||
*
|
||
* @package AKSRT
|
||
* @since 5.0.0
|
||
*/
|
||
(function () {
|
||
'use strict';
|
||
|
||
var aksrt = window.aksrt || {};
|
||
window.aksrt = aksrt;
|
||
|
||
// ══════════════════════════════════════════════════════════════
|
||
// §10.11 — tbquire: lazy script/CSS loader
|
||
// ══════════════════════════════════════════════════════════════
|
||
|
||
var _loadedScripts = {};
|
||
var _loadingPromises = {};
|
||
|
||
function loadSingleScript(src) {
|
||
if (_loadedScripts[src]) return Promise.resolve();
|
||
if (_loadingPromises[src]) return _loadingPromises[src];
|
||
|
||
_loadingPromises[src] = new Promise(function (resolve, reject) {
|
||
var isCSS = /\.css(\?|$)/i.test(src);
|
||
var el;
|
||
|
||
if (isCSS) {
|
||
el = document.createElement('link');
|
||
el.rel = 'stylesheet';
|
||
el.href = src;
|
||
} else {
|
||
el = document.createElement('script');
|
||
el.src = src;
|
||
el.async = true;
|
||
}
|
||
|
||
el.onload = function () {
|
||
_loadedScripts[src] = true;
|
||
delete _loadingPromises[src];
|
||
resolve();
|
||
};
|
||
el.onerror = function () {
|
||
delete _loadingPromises[src];
|
||
reject(new Error('Failed to load: ' + src));
|
||
};
|
||
|
||
(document.head || document.documentElement).appendChild(el);
|
||
});
|
||
|
||
return _loadingPromises[src];
|
||
}
|
||
|
||
aksrt.tbquire = function (deps, callback) {
|
||
if (typeof deps === 'string') deps = [deps];
|
||
if (!Array.isArray(deps) || !deps.length) {
|
||
if (typeof callback === 'function') callback();
|
||
return Promise.resolve();
|
||
}
|
||
|
||
var resolvedDeps = deps.map(function (dep) {
|
||
if (/^https?:\/\/|^\//.test(dep)) return dep;
|
||
var map = (window.aksrtData && aksrtData.tbquireMap) || {};
|
||
return map[dep] || dep;
|
||
});
|
||
|
||
var p = Promise.all(resolvedDeps.map(loadSingleScript));
|
||
if (typeof callback === 'function') {
|
||
p.then(callback).catch(function (err) {
|
||
console.error('[AKSRT tbquire]', err);
|
||
});
|
||
}
|
||
return p;
|
||
};
|
||
|
||
// ══════════════════════════════════════════════════════════════
|
||
// §10.10 — confirm: i18n confirm dialog + [data-confirm]
|
||
// ══════════════════════════════════════════════════════════════
|
||
|
||
var _i18n = (window.aksrtData && aksrtData.i18n) || {};
|
||
|
||
function __(key, fallback) {
|
||
return _i18n[key] || fallback || key;
|
||
}
|
||
|
||
aksrt.__ = __;
|
||
|
||
aksrt.confirm = function (msg, opts) {
|
||
opts = opts || {};
|
||
return new Promise(function (resolve) {
|
||
var overlay = document.createElement('div');
|
||
overlay.className = 'aksrt-confirm-overlay';
|
||
|
||
var dialog = document.createElement('div');
|
||
dialog.className = 'aksrt-confirm-dialog';
|
||
dialog.setAttribute('role', 'alertdialog');
|
||
dialog.setAttribute('aria-modal', 'true');
|
||
|
||
dialog.innerHTML =
|
||
'<div class="aksrt-confirm__body">' + escapeHtml(msg) + '</div>' +
|
||
'<div class="aksrt-confirm__actions">' +
|
||
'<button type="button" class="aksrt-confirm__cancel btn-ghost">' +
|
||
escapeHtml(opts.cancelText || __('cancel', '取消')) +
|
||
'</button>' +
|
||
'<button type="button" class="aksrt-confirm__ok btn-primary">' +
|
||
escapeHtml(opts.okText || __('confirm', '确定')) +
|
||
'</button>' +
|
||
'</div>';
|
||
|
||
overlay.appendChild(dialog);
|
||
document.body.appendChild(overlay);
|
||
|
||
requestAnimationFrame(function () { overlay.classList.add('is-open'); });
|
||
|
||
function close(result) {
|
||
overlay.classList.remove('is-open');
|
||
setTimeout(function () { overlay.remove(); }, 200);
|
||
resolve(result);
|
||
}
|
||
|
||
dialog.querySelector('.aksrt-confirm__cancel').addEventListener('click', function () { close(false); });
|
||
dialog.querySelector('.aksrt-confirm__ok').addEventListener('click', function () { close(true); });
|
||
overlay.addEventListener('click', function (e) { if (e.target === overlay) close(false); });
|
||
|
||
dialog.querySelector('.aksrt-confirm__ok').focus();
|
||
});
|
||
};
|
||
|
||
// ══════════════════════════════════════════════════════════════
|
||
// §10.10 — scrollTopTo: smart scroll with header offset
|
||
// ══════════════════════════════════════════════════════════════
|
||
|
||
aksrt.scrollTopTo = function (target, extraOffset) {
|
||
var top = 0;
|
||
if (typeof target === 'number') {
|
||
top = target;
|
||
} else if (target && target.getBoundingClientRect) {
|
||
top = target.getBoundingClientRect().top + window.pageYOffset;
|
||
}
|
||
|
||
var navFixed = document.querySelector('body.nav-fixed .header, .navbar.navbar-top');
|
||
var headerOffset = navFixed ? (navFixed.offsetHeight + 20) : 0;
|
||
top = Math.max(0, top - headerOffset - (extraOffset || 0));
|
||
|
||
var current = window.pageYOffset;
|
||
if (Math.abs(top - current) < 80) return;
|
||
|
||
window.scrollTo({ top: top, behavior: 'smooth' });
|
||
};
|
||
|
||
// ══════════════════════════════════════════════════════════════
|
||
// §10.10 — loading: element-level loading overlay
|
||
// ══════════════════════════════════════════════════════════════
|
||
|
||
aksrt.loading = function (el, show) {
|
||
if (!el) return;
|
||
if (show === false) {
|
||
var mask = el.querySelector('.aksrt-loading-mask');
|
||
if (mask) {
|
||
mask.classList.add('aksrt-loading-mask--out');
|
||
setTimeout(function () { mask.remove(); }, 300);
|
||
}
|
||
return;
|
||
}
|
||
if (el.querySelector('.aksrt-loading-mask')) return;
|
||
var pos = getComputedStyle(el).position;
|
||
if (pos === 'static') el.style.position = 'relative';
|
||
|
||
var mask = document.createElement('div');
|
||
mask.className = 'aksrt-loading-mask';
|
||
mask.innerHTML = '<svg class="aksrt-loading-mask__spinner" width="36" height="36" viewBox="0 0 36 36">' +
|
||
'<circle cx="18" cy="18" r="15" fill="none" stroke="currentColor" stroke-width="3" stroke-dasharray="80 40" stroke-linecap="round">' +
|
||
'<animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="0.8s" repeatCount="indefinite"/>' +
|
||
'</circle></svg>';
|
||
el.appendChild(mask);
|
||
};
|
||
|
||
// ══════════════════════════════════════════════════════════════
|
||
// §10.11 — route: tab route + popstate
|
||
// ══════════════════════════════════════════════════════════════
|
||
|
||
aksrt.route = function (url, title) {
|
||
if (!window.history || !history.pushState) return;
|
||
history.pushState({ aksrt: true }, title || '', url);
|
||
if (title) document.title = title;
|
||
};
|
||
|
||
aksrt.routeReplace = function (url, title) {
|
||
if (!window.history || !history.replaceState) return;
|
||
history.replaceState({ aksrt: true }, title || '', url);
|
||
if (title) document.title = title;
|
||
};
|
||
|
||
// Tab route: elements with [data-route] push URL on activation
|
||
window.addEventListener('popstate', function (e) {
|
||
var routeTabs = document.querySelectorAll('[data-route]');
|
||
if (!routeTabs.length) return;
|
||
|
||
var path = window.location.pathname + window.location.search;
|
||
routeTabs.forEach(function (tab) {
|
||
var tabRoute = tab.getAttribute('data-route');
|
||
var isMatch = path === tabRoute || path.indexOf(tabRoute) === 0;
|
||
tab.classList.toggle('is-active', isMatch);
|
||
var target = tab.getAttribute('data-route-target');
|
||
if (target) {
|
||
var panel = document.querySelector(target);
|
||
if (panel) panel.classList.toggle('is-active', isMatch);
|
||
}
|
||
});
|
||
});
|
||
|
||
// ══════════════════════════════════════════════════════════════
|
||
// §10.11 — Declarative interactions (event delegation)
|
||
// ══════════════════════════════════════════════════════════════
|
||
|
||
document.addEventListener('click', function (e) {
|
||
var target = e.target.closest('[data-close]');
|
||
if (target) {
|
||
e.preventDefault();
|
||
var sel2 = target.getAttribute('data-close');
|
||
var el2 = sel2 ? document.querySelector(sel2) : target.parentElement;
|
||
if (el2) {
|
||
el2.classList.remove('is-open', 'is-active', 'is-visible');
|
||
el2.hidden = true;
|
||
}
|
||
return;
|
||
}
|
||
|
||
target = e.target.closest('[data-onclick]');
|
||
if (target) {
|
||
e.preventDefault();
|
||
var sel3 = target.getAttribute('data-onclick');
|
||
var el3 = document.querySelector(sel3);
|
||
if (el3) el3.click();
|
||
return;
|
||
}
|
||
});
|
||
|
||
// [data-confirm] — intercept submission
|
||
document.addEventListener('click', function (e) {
|
||
var target = e.target.closest('[data-confirm]');
|
||
if (!target) return;
|
||
|
||
var msg = target.getAttribute('data-confirm');
|
||
if (!msg) return;
|
||
|
||
e.preventDefault();
|
||
e.stopPropagation();
|
||
|
||
aksrt.confirm(msg).then(function (ok) {
|
||
if (!ok) return;
|
||
target.removeAttribute('data-confirm');
|
||
target.click();
|
||
target.setAttribute('data-confirm', msg);
|
||
});
|
||
}, true);
|
||
|
||
// ══════════════════════════════════════════════════════════════
|
||
// §10.10a — 拦截 vendor 评论脚本 & 解绑 vendor ajax 委托
|
||
// ══════════════════════════════════════════════════════════════
|
||
// vendor 链路:loader.js(tbquire,改造版 RequireJS)→ main.min.js 检测到
|
||
// #commentform/#postcomments 即 tbquire(["comment"]) 懒加载 comment.min.js;
|
||
// 检测到 .dropdown-code/.dropdown-image 即 tbquire(["input-expand"])。
|
||
// AKSRT 自有评论脚本(comments/comment-tools/comment-fixed-input/
|
||
// comment-move-form/comment-ajax)已承担全部行为,vendor comment.min.js 的
|
||
// 7 条 body 委托会双路触发(提交 legacy action=submit_comment 无处理器,
|
||
// 即控制台「ajax请求错误」400 "0" 的来源;回复/排序/分页同理);
|
||
// vendor input-expand.min.js(表情/快捷回复旧链路,源文件已删除)同理不再下载。
|
||
//
|
||
// 双层防御:
|
||
// 1) tbfine 预注册空 'comment'/'input-expand' 模块 → tbquire 不再下载;
|
||
// 2) 若模块抢在注册前加载,退化为对 7 条委托做幂等 .off。
|
||
function stubVendorCommentModule() {
|
||
if (!(window.tbfine && window.tbquire && window.tbquire.defined)) return false;
|
||
try {
|
||
['comment', 'input-expand'].forEach(function (name) {
|
||
if (!window.tbquire.defined(name)) {
|
||
window.tbfine(name, [], function () { return {}; });
|
||
}
|
||
});
|
||
return true;
|
||
} catch (e) {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
// main.min.js 的 body 级 legacy 委托同理摘除(vendor 只保留 UI 行为)。
|
||
function unbindVendorAjaxDelegates() {
|
||
stubVendorCommentModule();
|
||
if (!window.jQuery) return;
|
||
try {
|
||
var $body = jQuery('body');
|
||
$body.off('click', '[data-action]');
|
||
$body.off('click', '[ajax-action]');
|
||
$body.off('click', '.wp-ajax-submit,[zibajax="submit"]');
|
||
$body.off('click', '.initiate-checkin');
|
||
$body.off('click', '.oauth-untying');
|
||
// comment.min.js 的 7 条委托(legacy/js/comment.js 原始选择器)
|
||
$body.off('click', '[fixed-input]');
|
||
$body.off('click', '.commentlist .pagenav a,.comment-orderby');
|
||
$body.off('click', '.comment-edit-link,.comment-reply-link');
|
||
$body.off('keydown', '#comment');
|
||
$body.off('click', '.comment-trash-link');
|
||
$body.off('click', '.comment-approve-link');
|
||
$body.off('click', '#commentform #submit');
|
||
} catch (e) { /* vendor 运行时未就绪时忽略 */ }
|
||
}
|
||
var unbindVendorAjaxLoop = function () {
|
||
unbindVendorAjaxDelegates();
|
||
if (++unbindVendorAjaxLoop.tries >= 50) return; // ~10s @200ms 覆盖异步加载窗口
|
||
setTimeout(unbindVendorAjaxLoop, 200);
|
||
};
|
||
unbindVendorAjaxLoop.tries = 0;
|
||
unbindVendorAjaxLoop();
|
||
|
||
// ══════════════════════════════════════════════════════════════
|
||
// §10.11 — [data-action] / [ajax-action] universal buttons
|
||
// ══════════════════════════════════════════════════════════════
|
||
|
||
// Only these data-action values are network AJAX. UI-only actions
|
||
// (toggle-theme, editor toolbar, download, etc.) must not hit admin-ajax.
|
||
var DATA_ACTION_AJAX = {
|
||
like: true,
|
||
favorite: true,
|
||
follow: true,
|
||
checkin: true
|
||
};
|
||
|
||
document.addEventListener('click', function (e) {
|
||
// [data-action] — like/follow/checkin with localStorage de-dup
|
||
var btn = e.target.closest('[data-action]');
|
||
if (btn) {
|
||
var dataAction = btn.getAttribute('data-action') || '';
|
||
if (!DATA_ACTION_AJAX[dataAction]) {
|
||
// Leave non-AJAX data-action handlers (theme toggle, toolbar, download) alone.
|
||
return;
|
||
}
|
||
e.preventDefault();
|
||
handleDataAction(btn);
|
||
return;
|
||
}
|
||
|
||
// [ajax-action] — general AJAX button
|
||
btn = e.target.closest('[ajax-action]');
|
||
if (btn) {
|
||
e.preventDefault();
|
||
handleAjaxAction(btn);
|
||
return;
|
||
}
|
||
});
|
||
|
||
function handleDataAction(btn) {
|
||
if (btn.classList.contains('is-loading')) return;
|
||
|
||
var action = btn.getAttribute('data-action');
|
||
if (!action || !DATA_ACTION_AJAX[action]) return;
|
||
|
||
var id = btn.getAttribute('data-id') || '';
|
||
var storageKey = 'aksrt_action_' + action + '_' + id;
|
||
|
||
if (action === 'like' || action === 'favorite') {
|
||
try {
|
||
if (localStorage.getItem(storageKey) && !btn.classList.contains('is-active')) {
|
||
notyf(__('already_done', '已操作'), 'warning');
|
||
return;
|
||
}
|
||
} catch (ex) { /* storage unavailable */ }
|
||
}
|
||
|
||
btn.classList.add('is-loading');
|
||
|
||
var ajaxUrl = (window.aksrtData && aksrtData.ajaxUrl) || '/wp-admin/admin-ajax.php';
|
||
if (!(window.aksrtData && aksrtData.nonce)) {
|
||
btn.classList.remove('is-loading');
|
||
notyf(__('action_failed', '操作失败'), 'danger');
|
||
return;
|
||
}
|
||
var params = new URLSearchParams();
|
||
params.set('action', 'aksrt_' + action);
|
||
params.set('nonce', aksrtData.nonce);
|
||
params.set('id', id);
|
||
|
||
var extraData = btn.getAttribute('data-action-data');
|
||
if (extraData) {
|
||
try {
|
||
var ed = JSON.parse(extraData);
|
||
Object.keys(ed).forEach(function (k) { params.set(k, ed[k]); });
|
||
} catch (ex) { /* ignore */ }
|
||
}
|
||
|
||
fetch(ajaxUrl, {
|
||
method: 'POST',
|
||
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
|
||
credentials: 'same-origin',
|
||
body: params.toString()
|
||
})
|
||
.then(function (r) { return r.json(); })
|
||
.then(function (json) {
|
||
btn.classList.remove('is-loading');
|
||
if (json && json.success) {
|
||
var isActive = !!json.data && !!json.data.active;
|
||
btn.classList.toggle('is-active', isActive);
|
||
|
||
var countEl = btn.querySelector('[data-count]') || btn.querySelector('.action-count');
|
||
if (countEl && json.data && json.data.count !== undefined) {
|
||
countEl.textContent = String(json.data.count);
|
||
}
|
||
|
||
try {
|
||
if (isActive) localStorage.setItem(storageKey, '1');
|
||
else localStorage.removeItem(storageKey);
|
||
} catch (ex) { /* */ }
|
||
|
||
if (json.data && json.data.message) {
|
||
notyf(json.data.message, 'success');
|
||
}
|
||
|
||
if (json.data && json.data.goto) {
|
||
window.location.href = json.data.goto;
|
||
}
|
||
} else {
|
||
notyf((json.data && json.data.message) || __('action_failed', '操作失败'), 'danger');
|
||
}
|
||
})
|
||
.catch(function (err) {
|
||
btn.classList.remove('is-loading');
|
||
notyf(err.message || __('network_error', '网络错误'), 'danger');
|
||
});
|
||
}
|
||
|
||
function handleAjaxAction(btn) {
|
||
if (btn.classList.contains('is-loading')) return;
|
||
btn.classList.add('is-loading');
|
||
|
||
var action = btn.getAttribute('ajax-action');
|
||
var ajaxUrl = (window.aksrtData && aksrtData.ajaxUrl) || '/wp-admin/admin-ajax.php';
|
||
var params = new URLSearchParams();
|
||
params.set('action', action);
|
||
if (window.aksrtData && aksrtData.nonce) params.set('nonce', aksrtData.nonce);
|
||
|
||
var form = btn.closest('form');
|
||
if (form) {
|
||
new FormData(form).forEach(function (v, k) { params.set(k, v); });
|
||
}
|
||
|
||
fetch(ajaxUrl, {
|
||
method: 'POST',
|
||
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
|
||
credentials: 'same-origin',
|
||
body: params.toString()
|
||
})
|
||
.then(function (r) { return r.json(); })
|
||
.then(function (json) {
|
||
btn.classList.remove('is-loading');
|
||
if (json && json.success) {
|
||
if (json.data && json.data.show_modal) {
|
||
window.AksrtModalRuntime.open({
|
||
html: json.data.show_modal,
|
||
bottom: true,
|
||
mobileBottom: true,
|
||
kind: 'generic',
|
||
});
|
||
} else if (json.data && json.data.message) {
|
||
notyf(json.data.message, 'success');
|
||
}
|
||
if (json.data && json.data.goto) {
|
||
window.location.href = json.data.goto;
|
||
}
|
||
if (json.data && json.data.reload) {
|
||
window.location.reload();
|
||
}
|
||
} else {
|
||
notyf((json.data && json.data.message) || __('action_failed', '操作失败'), 'danger');
|
||
}
|
||
})
|
||
.catch(function (err) {
|
||
btn.classList.remove('is-loading');
|
||
notyf(err.message || __('network_error', '网络错误'), 'danger');
|
||
});
|
||
}
|
||
|
||
// ══════════════════════════════════════════════════════════════
|
||
// §10.11 — Ripple (broad coverage)
|
||
// ══════════════════════════════════════════════════════════════
|
||
|
||
var RIPPLE_SELECTORS = '.toggle-radius,.but-ripple,.but,.btn,.btn-primary,.btn-ghost,.btn-outline,.item-thumbnail,.menu-item>a,.aksrt-ripple,.yiyan-box,.aksrt-card';
|
||
|
||
document.addEventListener('click', function (e) {
|
||
var target = e.target.closest(RIPPLE_SELECTORS);
|
||
if (!target) return;
|
||
// Markup opt-out (header publish uses class="nowave") + nav CTA chips
|
||
if (target.classList.contains('nowave') || target.closest('.nowave')) return;
|
||
if (target.classList.contains('navbar-cta') || target.closest('.navbar-cta')) return;
|
||
if (target.closest('.navbar-top .navbar-but, .navbar-top .navbar-vip, .navbar-but-cluster')) return;
|
||
if (target.querySelector('.aksrt-wave')) return;
|
||
|
||
var rect = target.getBoundingClientRect();
|
||
var size = Math.max(rect.width, rect.height) * 2;
|
||
var x = e.clientX - rect.left - size / 2;
|
||
var y = e.clientY - rect.top - size / 2;
|
||
|
||
var wave = document.createElement('span');
|
||
wave.className = 'aksrt-wave';
|
||
// Must be absolute — without it the huge span expands the button box ("变长").
|
||
wave.style.cssText = 'position:absolute;pointer-events:none;border-radius:50%;background:rgba(255,255,255,0.35);width:'
|
||
+ size + 'px;height:' + size + 'px;left:' + x + 'px;top:' + y + 'px;transform:scale(0);animation:aksrtWaveRipple .6s ease-out forwards;';
|
||
|
||
var cs = getComputedStyle(target);
|
||
if (cs.position === 'static') target.style.position = 'relative';
|
||
if (cs.overflow === 'visible') target.style.overflow = 'hidden';
|
||
|
||
target.appendChild(wave);
|
||
setTimeout(function () {
|
||
if (wave.parentNode) wave.parentNode.removeChild(wave);
|
||
}, 600);
|
||
});
|
||
|
||
// ══════════════════════════════════════════════════════════════
|
||
// §10.11 — auto_fun: extended rehydration coverage
|
||
// ══════════════════════════════════════════════════════════════
|
||
|
||
aksrt.autoFun = function (root) {
|
||
root = root || document;
|
||
if (window.AksrtFrontend) {
|
||
AksrtFrontend.rehydrate(root, 'ajax');
|
||
}
|
||
|
||
// Tooltips
|
||
root.querySelectorAll('[data-tooltip]').forEach(function (el) {
|
||
if (el.dataset.tooltipBound) return;
|
||
el.dataset.tooltipBound = '1';
|
||
el.addEventListener('mouseenter', function () {
|
||
var tip = document.createElement('div');
|
||
tip.className = 'aksrt-tooltip';
|
||
tip.textContent = el.getAttribute('data-tooltip');
|
||
document.body.appendChild(tip);
|
||
var rect = el.getBoundingClientRect();
|
||
tip.style.left = (rect.left + rect.width / 2 - tip.offsetWidth / 2) + 'px';
|
||
tip.style.top = (rect.top - tip.offsetHeight - 8 + window.pageYOffset) + 'px';
|
||
el._aksrtTooltip = tip;
|
||
});
|
||
el.addEventListener('mouseleave', function () {
|
||
if (el._aksrtTooltip) { el._aksrtTooltip.remove(); el._aksrtTooltip = null; }
|
||
});
|
||
});
|
||
|
||
// Countdowns
|
||
root.querySelectorAll('[data-countdown]').forEach(function (el) {
|
||
if (el.dataset.countdownBound) return;
|
||
el.dataset.countdownBound = '1';
|
||
var end = parseInt(el.getAttribute('data-countdown'), 10);
|
||
if (!end) return;
|
||
var iv = setInterval(function () {
|
||
var left = Math.max(0, end - Math.floor(Date.now() / 1000));
|
||
if (left <= 0) { clearInterval(iv); el.textContent = '00:00'; return; }
|
||
var m = Math.floor(left / 60);
|
||
var s = left % 60;
|
||
el.textContent = (m < 10 ? '0' : '') + m + ':' + (s < 10 ? '0' : '') + s;
|
||
}, 1000);
|
||
});
|
||
};
|
||
|
||
// ══════════════════════════════════════════════════════════════
|
||
// Helpers
|
||
// ══════════════════════════════════════════════════════════════
|
||
|
||
function escapeHtml(str) {
|
||
if (!str) return '';
|
||
return String(str)
|
||
.replace(/&/g, '&')
|
||
.replace(/</g, '<')
|
||
.replace(/>/g, '>')
|
||
.replace(/"/g, '"');
|
||
}
|
||
|
||
// ── DOMContentLoaded ──
|
||
|
||
function initRuntime() {
|
||
aksrt.autoFun(document);
|
||
}
|
||
|
||
if (document.readyState === 'loading') {
|
||
document.addEventListener('DOMContentLoaded', initRuntime);
|
||
} else {
|
||
initRuntime();
|
||
}
|
||
|
||
})();
|
||
;
|
||
|
||
/* source: assets/js/grade.min.js */
|
||
(function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Grade=e()}})(function(){return function e(t,n,r){function i(o,s){if(!n[o]){if(!t[o]){var u="function"==typeof require&&require;if(!s&&u)return u(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var g=n[o]={exports:{}};t[o][0].call(g.exports,function(e){var n=t[o][1][e];return i(n||e)},g,g.exports,e,t,n,r)}return n[o].exports}for(var a="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}({1:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=["webkit"],o=function(){function e(t,n,i){r(this,e),this.callback=i||null,this.container=t;var a=this.container.querySelector(n||"img");if(this.gradientData=[],a&&this.container){this.canvas=document.createElement("canvas"),this.ctx=this.canvas.getContext("2d"),this.imageData=[];var o=this;o.image=new Image,o.image.crossOrigin="Anonymous",o.image.src=a.getAttribute("data-src")||a.getAttribute("src"),o.image.onload=function(){o.readImage()}}}return i(e,[{key:"readImage",value:function(){this.imageDimensions={width:100,height:100},this.render()}},{key:"getImageData",value:function(){var e=this.ctx.getImageData(0,0,this.imageDimensions.width,this.imageDimensions.height).data;this.imageData=Array.from(e)}},{key:"getChunkedImageData",value:function(){var e=4,t=this.imageData.reduce(function(t,n,r){var i=Math.floor(r/e);return t[i]||(t[i]=[]),t[i].push(n),t},[]),n=t.filter(function(e){var t=e[0],n=e[1],r=e[2],i=Math.max(Math.abs(t-n),Math.abs(t-r),Math.abs(n-r));return i>20});return(!n||n.length<2)&&(n=t.filter(function(e){return e.slice(0,2).every(function(e){return e<245})&&e.slice(0,2).every(function(e){return e>10})})),n}},{key:"getRGBAGradientValues",value:function(e){return e.map(function(e,t){return"rgb("+e.rgba.slice(0,3).join(",")+") "+(0==t?"0%":"75%")}).join(",")}},{key:"getCSSGradientProperty",value:function(e){var t=this.getRGBAGradientValues(e);return a.map(function(e){return"background-image: -"+e+"-linear-gradient(\n 135deg,\n "+t+"\n )"}).concat(["background-image: linear-gradient(\n 135deg,\n "+t+"\n )"]).join(";")}},{key:"getMiddleRGB",value:function(e,t){var n=0,r=(n+1)/2,i=1-r,a=[parseInt(e[0]*r+t[0]*i),parseInt(e[1]*r+t[1]*i),parseInt(e[2]*r+t[2]*i)];return a}},{key:"getSortedValues",value:function(e){var t=Object.keys(e).map(function(t){var n=t,r=t.split("|"),i=(299*r[0]+587*r[1]+114*r[2])/1e3;return{rgba:n.split("|"),occurs:e[t],brightness:i}}).sort(function(e,t){return e.occurs-t.occurs}).reverse().slice(0,10);return t.sort(function(e,t){return e.brightness-t.brightness}).reverse()}},{key:"getTextProperty",value:function(e){var t=this.getMiddleRGB(e[0].rgba.slice(0,3),e[1].rgba.slice(0,3)),n=Math.round((299*parseInt(t[0])+587*parseInt(t[1])+114*parseInt(t[2]))/1e3);return n>125?"color: #000":"color: #fff"}},{key:"getTopValues",value:function(e){var t=this.getSortedValues(e);return[t[0],t[t.length-1]]}},{key:"getUniqValues",value:function(e){return e.reduce(function(e,t){var n=t.join("|");return e[n]?(e[n]=++e[n],e):(e[n]=1,e)},{})}},{key:"renderGradient",value:function(){var e=window.localStorage,t="grade-"+this.image.getAttribute("src"),n=null;if(e&&e.getItem(t)&&(n=JSON.parse(e.getItem(t))),!n||!n[0]){var r=this.getChunkedImageData();n=this.getTopValues(this.getUniqValues(r)),e&&e.setItem(t,JSON.stringify(n))}if(this.callback)return this.gradientData=n,void this.callback([{element:this.container,gradientData:n}]);var i=this.getCSSGradientProperty(n),a=this.getTextProperty(n),o=(this.container.getAttribute("style")||"")+"; "+i+"; "+a;this.container.setAttribute("style",o)}},{key:"render",value:function(){this.canvas.width=this.imageDimensions.width,this.canvas.height=this.imageDimensions.height,this.ctx.drawImage(this.image,0,0,this.imageDimensions.width,this.imageDimensions.height),this.getImageData(),this.renderGradient()}}]),e}();t.exports=function(e,t,n){var r=function(e,t,n){var r=new o(e,t,n),i=r.gradientData;return i.length?{element:e,gradientData:i}:null},i=(NodeList.prototype.isPrototypeOf(e)?Array.from(e).map(function(e){return r(e,t,n)}):[r(e,t,n)]).filter(Boolean);if(i.length)return n(i)}},{}]},{},[1])(1)});
|
||
;
|
||
|
||
/* source: assets/js/core/modal-telemetry.js */
|
||
/**
|
||
* Frontend modal performance marks.
|
||
*
|
||
* Records only bounded domain/event names and timing data. Never include
|
||
* payment credentials, order contents, identity evidence, or user payloads.
|
||
*
|
||
* @package AKSRT
|
||
*/
|
||
(function (window) {
|
||
'use strict';
|
||
|
||
var allowedKinds = {
|
||
identity: true,
|
||
badges: true,
|
||
orders: true,
|
||
vip: true,
|
||
};
|
||
var allowedEvents = {
|
||
click: true,
|
||
shell: true,
|
||
'first-content': true,
|
||
ready: true,
|
||
'action-start': true,
|
||
'action-end': true,
|
||
unauthorized: true,
|
||
error: true,
|
||
};
|
||
var sessions = Object.create(null);
|
||
var sequence = 0;
|
||
var maxSessions = 100;
|
||
|
||
function normalize(value, fallback) {
|
||
var normalized = String(value || fallback || '').toLowerCase().replace(/[^a-z0-9-]/g, '');
|
||
return normalized || fallback;
|
||
}
|
||
|
||
function now() {
|
||
return window.performance && typeof window.performance.now === 'function'
|
||
? window.performance.now()
|
||
: 0;
|
||
}
|
||
|
||
function markName(session, event) {
|
||
return 'aksrt-modal-' + session.kind + '-' + session.id + '-' + event;
|
||
}
|
||
|
||
function emit(session, event) {
|
||
if (!window.performance || typeof window.performance.mark !== 'function') return;
|
||
|
||
var name = markName(session, event);
|
||
window.performance.mark(name);
|
||
session.marks[event] = name;
|
||
|
||
if (typeof window.performance.measure === 'function' && session.marks.click && event !== 'click') {
|
||
try {
|
||
window.performance.measure(
|
||
'aksrt-modal-' + session.kind + '-' + session.id + '-click-to-' + event,
|
||
session.marks.click,
|
||
name
|
||
);
|
||
} catch (error) {
|
||
// A missing mark must never affect the modal interaction.
|
||
}
|
||
}
|
||
}
|
||
|
||
function start(kind) {
|
||
var safeKind = normalize(kind, 'unknown');
|
||
if (!allowedKinds[safeKind]) safeKind = 'unknown';
|
||
|
||
sequence += 1;
|
||
var id = String(sequence);
|
||
var session = {
|
||
id: id,
|
||
kind: safeKind,
|
||
startedAt: now(),
|
||
marks: Object.create(null),
|
||
};
|
||
|
||
sessions[id] = session;
|
||
emit(session, 'click');
|
||
|
||
var ids = Object.keys(sessions);
|
||
while (ids.length > maxSessions) {
|
||
delete sessions[ids.shift()];
|
||
}
|
||
|
||
return id;
|
||
}
|
||
|
||
function mark(id, event) {
|
||
var session = sessions[String(id || '')];
|
||
var safeEvent = normalize(event, 'error');
|
||
if (!session || !allowedEvents[safeEvent]) return;
|
||
emit(session, safeEvent);
|
||
}
|
||
|
||
function finish(id) {
|
||
mark(id, 'ready');
|
||
}
|
||
|
||
function fail(id) {
|
||
mark(id, 'error');
|
||
}
|
||
|
||
window.AksrtModalTelemetry = {
|
||
start: start,
|
||
mark: mark,
|
||
finish: finish,
|
||
error: fail,
|
||
};
|
||
})(window);
|
||
;
|
||
|
||
/* source: assets/js/core/request.js */
|
||
/**
|
||
* AKSRT frontend request adapter.
|
||
*
|
||
* Owns the injected REST root, nonce headers, response envelopes, and
|
||
* abort-aware error normalization used by modal loaders.
|
||
*
|
||
* @package AKSRT
|
||
*/
|
||
(function (window) {
|
||
"use strict";
|
||
|
||
function data() {
|
||
return window.aksrtData || window.aksrt || {};
|
||
}
|
||
|
||
function createIdempotencyKey() {
|
||
if (window.crypto && typeof window.crypto.randomUUID === "function") {
|
||
return window.crypto.randomUUID();
|
||
}
|
||
if (!window.crypto || typeof window.crypto.getRandomValues !== "function") {
|
||
throw new Error("当前浏览器无法生成安全的操作标识");
|
||
}
|
||
var bytes = new Uint8Array(16);
|
||
window.crypto.getRandomValues(bytes);
|
||
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
||
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
||
var hex = Array.prototype.map.call(bytes, function (value) {
|
||
return value.toString(16).padStart(2, "0");
|
||
}).join("");
|
||
return hex.slice(0, 8) + "-" + hex.slice(8, 12) + "-" + hex.slice(12, 16) + "-" + hex.slice(16, 20) + "-" + hex.slice(20);
|
||
}
|
||
|
||
function restBase() {
|
||
var config = data();
|
||
var raw = config.restUrl || config.apiUrl || config.rest_url || "";
|
||
var siteUrl = config.siteUrl || config.homeUrl || (window.location.origin + "/");
|
||
|
||
if (window.location.protocol === "https:" && siteUrl.substring(0, 5) === "http:") {
|
||
siteUrl = "https:" + siteUrl.substring(5);
|
||
}
|
||
|
||
if (raw) return String(raw).replace(/\/$/, "");
|
||
return String(siteUrl).replace(/\/$/, "") + "/index.php?rest_route=/aksrt/v1";
|
||
}
|
||
|
||
function appendQuery(url, query) {
|
||
if (!query) return url;
|
||
var parts = [];
|
||
|
||
if (typeof query === "string") {
|
||
parts = query.replace(/^\?/, "").split("&").filter(Boolean);
|
||
} else if (typeof query === "object") {
|
||
Object.keys(query).forEach(function (key) {
|
||
if (query[key] === undefined || query[key] === null) return;
|
||
parts.push(encodeURIComponent(key) + "=" + encodeURIComponent(String(query[key])));
|
||
});
|
||
}
|
||
|
||
if (!parts.length) return url;
|
||
return url + (url.indexOf("?") >= 0 ? "&" : "?") + parts.join("&");
|
||
}
|
||
|
||
function url(path, query) {
|
||
path = String(path || "");
|
||
var inlineQuery = "";
|
||
var queryIndex = path.indexOf("?");
|
||
|
||
if (queryIndex >= 0) {
|
||
inlineQuery = path.slice(queryIndex + 1);
|
||
path = path.slice(0, queryIndex);
|
||
}
|
||
|
||
if (/^https?:\/\//i.test(path)) {
|
||
return appendQuery(path, query || inlineQuery);
|
||
}
|
||
|
||
if (path.charAt(0) !== "/") path = "/" + path;
|
||
var base = restBase();
|
||
var result = base.indexOf("rest_route=") >= 0 ? base + path : base + path;
|
||
return appendQuery(result, query || inlineQuery);
|
||
}
|
||
|
||
function headers(options) {
|
||
var config = data();
|
||
var source = (options && options.headers) || {};
|
||
var result = {};
|
||
var nonce = config.restNonce || config.nonce || "";
|
||
|
||
Object.keys(source).forEach(function (key) {
|
||
result[key] = source[key];
|
||
});
|
||
|
||
if (!result.Accept) result.Accept = "application/json, text/html;q=0.9, */*;q=0.8";
|
||
if (nonce && !result["X-WP-Nonce"]) result["X-WP-Nonce"] = nonce;
|
||
|
||
if (options && options.body !== undefined && options.body !== null &&
|
||
!(window.FormData && options.body instanceof window.FormData) &&
|
||
!result["Content-Type"]) {
|
||
result["Content-Type"] = "application/json";
|
||
}
|
||
|
||
return result;
|
||
}
|
||
|
||
function responseError(result) {
|
||
var json = result.json;
|
||
var message = json && (json.message || (json.data && json.data.message));
|
||
var error = new Error(message || (result.status ? "请求失败(HTTP " + result.status + ")" : "请求失败"));
|
||
error.status = result.status;
|
||
error.code = result.status === 401 ? "unauthorized" : "http_error";
|
||
error.response = result;
|
||
error.json = json;
|
||
return error;
|
||
}
|
||
|
||
function parseResponse(response) {
|
||
return response.text().then(function (text) {
|
||
var type = (response.headers.get("content-type") || "").toLowerCase();
|
||
var json = null;
|
||
var trimmed = String(text || "").trim();
|
||
|
||
if (type.indexOf("application/json") >= 0 || trimmed.charAt(0) === "{" || trimmed.charAt(0) === "[") {
|
||
try {
|
||
json = trimmed ? JSON.parse(trimmed) : {};
|
||
} catch (error) {
|
||
json = null;
|
||
}
|
||
}
|
||
|
||
return {
|
||
ok: response.ok,
|
||
status: response.status,
|
||
headers: response.headers,
|
||
text: text,
|
||
json: json,
|
||
data: json && json.data !== undefined ? json.data : json,
|
||
};
|
||
});
|
||
}
|
||
|
||
function request(path, options) {
|
||
options = Object.assign({}, options || {});
|
||
var requestUrl = url(path, options.query);
|
||
delete options.query;
|
||
|
||
var fetchOptions = Object.assign({}, options, {
|
||
credentials: options.credentials || "same-origin",
|
||
headers: headers(options),
|
||
});
|
||
|
||
return window.fetch(requestUrl, fetchOptions).then(function (response) {
|
||
return parseResponse(response);
|
||
}).then(function (result) {
|
||
if (!result.ok || (result.json && result.json.success === false)) {
|
||
throw responseError(result);
|
||
}
|
||
return result;
|
||
});
|
||
}
|
||
|
||
window.AksrtRequest = {
|
||
url: url,
|
||
request: request,
|
||
createIdempotencyKey: createIdempotencyKey,
|
||
get: function (path, options) {
|
||
return request(path, Object.assign({}, options || {}, { method: "GET" }));
|
||
},
|
||
post: function (path, body, options) {
|
||
return request(path, Object.assign({}, options || {}, {
|
||
method: "POST",
|
||
body: body,
|
||
}));
|
||
},
|
||
};
|
||
})(window);
|
||
;
|
||
|
||
/* source: assets/js/core/modal-cache.js */
|
||
/**
|
||
* User-scoped in-memory modal cache with short TTLs and request deduplication.
|
||
* Private modal payloads are never persisted to browser storage.
|
||
*
|
||
* @package AKSRT
|
||
*/
|
||
(function (window, document) {
|
||
"use strict";
|
||
|
||
var DEFAULT_TTL = 15000;
|
||
var entries = Object.create(null);
|
||
var flights = Object.create(null);
|
||
var lastScope = "";
|
||
|
||
function scope() {
|
||
var config = window.aksrtData || window.aksrt || {};
|
||
var userId = parseInt(config.userId || 0, 10) || 0;
|
||
var current = (config.isLoggedIn && userId > 0 ? "user:" + userId : "guest") + ":v1";
|
||
if (lastScope && lastScope !== current) clear();
|
||
lastScope = current;
|
||
return current;
|
||
}
|
||
|
||
function token(key) {
|
||
return scope() + "::" + String(key || "");
|
||
}
|
||
|
||
function read(key) {
|
||
var id = token(key);
|
||
var entry = entries[id];
|
||
if (!entry) return { hit: false, value: undefined };
|
||
if (entry.expiresAt <= Date.now()) {
|
||
delete entries[id];
|
||
return { hit: false, value: undefined };
|
||
}
|
||
return { hit: true, value: entry.value };
|
||
}
|
||
|
||
function tagsOf(value) {
|
||
return Array.isArray(value) ? value.slice() : (value ? [value] : []);
|
||
}
|
||
|
||
function set(key, value, options) {
|
||
options = options || {};
|
||
var ttl = Number(options.ttl || DEFAULT_TTL);
|
||
entries[token(key)] = {
|
||
value: value,
|
||
expiresAt: Date.now() + Math.max(0, ttl),
|
||
tags: tagsOf(options.tags),
|
||
};
|
||
return value;
|
||
}
|
||
|
||
function matchesTags(entry, wanted) {
|
||
if (!wanted.length) return true;
|
||
return wanted.some(function (tag) { return entry.tags.indexOf(tag) >= 0; });
|
||
}
|
||
|
||
function invalidate(tags) {
|
||
var wanted = Array.isArray(tags) ? tags : (tags ? [tags] : []);
|
||
var removed = 0;
|
||
Object.keys(entries).forEach(function (id) {
|
||
if (!wanted.length || matchesTags(entries[id], wanted)) {
|
||
delete entries[id];
|
||
removed += 1;
|
||
}
|
||
});
|
||
Object.keys(flights).forEach(function (id) {
|
||
var flight = flights[id];
|
||
if (!wanted.length || matchesTags(flight, wanted)) {
|
||
flight.cancelled = true;
|
||
delete flights[id];
|
||
if (typeof flight.cancel === "function") flight.cancel();
|
||
}
|
||
});
|
||
return removed;
|
||
}
|
||
|
||
function clear() {
|
||
entries = Object.create(null);
|
||
Object.keys(flights).forEach(function (id) {
|
||
var flight = flights[id];
|
||
flight.cancelled = true;
|
||
if (typeof flight.cancel === "function") flight.cancel();
|
||
});
|
||
flights = Object.create(null);
|
||
}
|
||
|
||
function acquire(key, loader, options) {
|
||
options = options || {};
|
||
var id = token(key);
|
||
var cached = options.skipCache ? { hit: false } : read(key);
|
||
|
||
if (cached.hit) {
|
||
return {
|
||
cached: true,
|
||
promise: Promise.resolve(cached.value),
|
||
release: function () {},
|
||
};
|
||
}
|
||
|
||
var flight = flights[id];
|
||
if (!flight) {
|
||
flight = {
|
||
refs: 0,
|
||
settled: false,
|
||
cancelled: false,
|
||
tags: tagsOf(options.tags),
|
||
cancel: options.cancel,
|
||
};
|
||
flight.promise = Promise.resolve().then(loader).then(function (value) {
|
||
flight.settled = true;
|
||
if (!flight.cancelled && options.store !== false) set(key, value, options);
|
||
if (flights[id] === flight) delete flights[id];
|
||
return value;
|
||
}, function (error) {
|
||
flight.settled = true;
|
||
if (flights[id] === flight) delete flights[id];
|
||
throw error;
|
||
});
|
||
flights[id] = flight;
|
||
}
|
||
|
||
flight.refs += 1;
|
||
var released = false;
|
||
return {
|
||
cached: false,
|
||
promise: flight.promise,
|
||
release: function () {
|
||
if (released) return;
|
||
released = true;
|
||
flight.refs = Math.max(0, flight.refs - 1);
|
||
if (flight.refs === 0 && !flight.settled) {
|
||
flight.cancelled = true;
|
||
if (flights[id] === flight) delete flights[id];
|
||
if (typeof flight.cancel === "function") flight.cancel();
|
||
}
|
||
},
|
||
};
|
||
}
|
||
|
||
["aksrt:auth:logout", "aksrt:account-switch", "aksrt:logout", "aksrt:user:logout", "aksrt:auth:changed", "wp_logout"].forEach(function (eventName) {
|
||
document.addEventListener(eventName, clear);
|
||
});
|
||
|
||
window.AksrtModalCache = {
|
||
get: function (key) { return read(key); },
|
||
set: set,
|
||
acquire: acquire,
|
||
invalidate: invalidate,
|
||
clear: clear,
|
||
scope: scope,
|
||
};
|
||
})(window, document);
|
||
;
|
||
|
||
/* source: assets/js/core/modal-state.js */
|
||
/**
|
||
* Shared modal state vocabulary.
|
||
*
|
||
* @package AKSRT
|
||
*/
|
||
(function (window) {
|
||
"use strict";
|
||
|
||
var statuses = {
|
||
idle: "idle",
|
||
loading: "loading",
|
||
ready: "ready",
|
||
empty: "empty",
|
||
submitting: "submitting",
|
||
success: "success",
|
||
error: "error",
|
||
unauthorized: "unauthorized",
|
||
stale: "stale",
|
||
};
|
||
|
||
function create(kind) {
|
||
return {
|
||
kind: String(kind || "generic"),
|
||
status: statuses.idle,
|
||
updatedAt: 0,
|
||
error: null,
|
||
};
|
||
}
|
||
|
||
window.AksrtModalState = {
|
||
statuses: statuses,
|
||
create: create,
|
||
};
|
||
})(window);
|
||
;
|
||
|
||
/* source: assets/js/core/modal-runtime.js */
|
||
/**
|
||
* Canonical frontend modal runtime.
|
||
*
|
||
* Owns the modal shell while adding cancellable loaders,
|
||
* short in-memory caching, request deduplication, retryable errors, focus
|
||
* restoration, and modal-scoped rehydration.
|
||
*
|
||
* @package AKSRT
|
||
*/
|
||
(function (window, document) {
|
||
"use strict";
|
||
|
||
var ROOT_ID = "aksrt-modal-runtime-root";
|
||
var active = null;
|
||
var sequence = 0;
|
||
var loaders = Object.create(null);
|
||
|
||
function isMobile() {
|
||
return window.matchMedia && window.matchMedia("(max-width: 768px)").matches;
|
||
}
|
||
|
||
function ensureRoot() {
|
||
var root = document.getElementById(ROOT_ID);
|
||
if (root) return root;
|
||
root = document.createElement("div");
|
||
root.id = ROOT_ID;
|
||
root.className = "aksrt-modal-runtime-host";
|
||
document.body.appendChild(root);
|
||
return root;
|
||
}
|
||
|
||
function escapeHtml(value) {
|
||
return String(value == null ? "" : value)
|
||
.replace(/&/g, "&")
|
||
.replace(/</g, "<")
|
||
.replace(/>/g, ">")
|
||
.replace(/\"/g, """)
|
||
.replace(/'/g, "'");
|
||
}
|
||
|
||
function lockScroll(lock) {
|
||
document.documentElement.classList.toggle("aksrt-modal-runtime-open", !!lock);
|
||
document.body.classList.toggle("aksrt-modal-runtime-open", !!lock);
|
||
}
|
||
|
||
function skeleton(options) {
|
||
return (options && options.skeleton) ||
|
||
'<div class="aksrt-modal-runtime__skeleton" aria-live="polite" aria-busy="true">' +
|
||
'<span class="aksrt-modal-runtime__skeleton-line is-wide"></span>' +
|
||
'<span class="aksrt-modal-runtime__skeleton-line"></span>' +
|
||
'<span class="aksrt-modal-runtime__skeleton-line is-short"></span>' +
|
||
'<span class="aksrt-modal-runtime__skeleton-block"></span>' +
|
||
'</div>';
|
||
}
|
||
|
||
function telemetryStart(kind) {
|
||
if (kind === false) return "";
|
||
return window.AksrtModalTelemetry.start(kind || "generic");
|
||
}
|
||
|
||
function telemetryMark(session, event) {
|
||
if (!session || !session.telemetryId) return;
|
||
window.AksrtModalTelemetry.mark(session.telemetryId, event);
|
||
}
|
||
|
||
function setState(session, status, error) {
|
||
session.state.status = status;
|
||
session.state.error = error || null;
|
||
session.state.updatedAt = Date.now();
|
||
if (session.shell) session.shell.setAttribute("data-aksrt-modal-state", status);
|
||
if (typeof session.options.onState === "function") {
|
||
session.options.onState(status, session);
|
||
}
|
||
}
|
||
|
||
function focusable(shell) {
|
||
return shell.querySelectorAll("button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex='-1'])");
|
||
}
|
||
|
||
function closeSelector() {
|
||
return "[data-aksrt-modal-close], .aksrt-modal-runtime__close";
|
||
}
|
||
|
||
function bindChrome(session) {
|
||
var shell = session.shell;
|
||
shell.addEventListener("click", function (event) {
|
||
var closeButton = event.target.closest(closeSelector());
|
||
if (closeButton) {
|
||
event.preventDefault();
|
||
close("control");
|
||
return;
|
||
}
|
||
if (event.target === shell || event.target.classList.contains("aksrt-modal-runtime__overlay")) {
|
||
close("overlay");
|
||
return;
|
||
}
|
||
var retry = event.target.closest("[data-aksrt-modal-retry]");
|
||
if (retry) {
|
||
event.preventDefault();
|
||
refresh();
|
||
}
|
||
});
|
||
|
||
shell.addEventListener("keydown", function (event) {
|
||
if (event.key === "Escape") {
|
||
event.preventDefault();
|
||
close("escape");
|
||
return;
|
||
}
|
||
if (event.key !== "Tab") return;
|
||
var nodes = focusable(shell);
|
||
if (!nodes.length) {
|
||
event.preventDefault();
|
||
shell.focus();
|
||
return;
|
||
}
|
||
var first = nodes[0];
|
||
var last = nodes[nodes.length - 1];
|
||
if (event.shiftKey && document.activeElement === first) {
|
||
event.preventDefault();
|
||
last.focus();
|
||
} else if (!event.shiftKey && document.activeElement === last) {
|
||
event.preventDefault();
|
||
first.focus();
|
||
}
|
||
});
|
||
}
|
||
|
||
function createSession(options) {
|
||
options = options || {};
|
||
var root = ensureRoot();
|
||
var shell = document.createElement("div");
|
||
var bottom = options.bottom === true || (options.mobileBottom !== false && isMobile());
|
||
var heightStyle = options.height ? "min-height:" + parseInt(options.height, 10) + "px;" : "";
|
||
var initialHtml = options.html !== undefined ? options.html : skeleton(options);
|
||
var titleId = "aksrt-modal-title-" + String(sequence + 1);
|
||
var titleHtml = options.title
|
||
? '<header class="aksrt-modal-runtime__header"><h3 class="aksrt-modal-runtime__title" id="' + titleId + '">' + escapeHtml(options.title) + '</h3><button type="button" class="aksrt-modal-runtime__close" data-aksrt-modal-close aria-label="关闭">×</button></header>'
|
||
: "";
|
||
|
||
shell.className =
|
||
"aksrt-modal-runtime" +
|
||
(bottom ? " aksrt-modal-runtime--bottom" : "") +
|
||
(options.className ? " " + options.className : "");
|
||
shell.setAttribute("role", "dialog");
|
||
shell.setAttribute("aria-modal", "true");
|
||
if (options.title) shell.setAttribute("aria-labelledby", titleId);
|
||
shell.setAttribute("tabindex", "-1");
|
||
shell.innerHTML =
|
||
'<div class="aksrt-modal-runtime__overlay" data-aksrt-modal-close></div>' +
|
||
'<div class="aksrt-modal-runtime__dialog" style="' + heightStyle + '">' +
|
||
titleHtml +
|
||
'<div class="aksrt-modal-runtime__content">' + initialHtml + "</div></div>";
|
||
|
||
var session = {
|
||
id: String(++sequence),
|
||
shell: shell,
|
||
content: shell.querySelector(".aksrt-modal-runtime__content"),
|
||
options: options,
|
||
state: window.AksrtModalState.create(options.kind || "generic"),
|
||
focusReturn: document.activeElement,
|
||
controller: null,
|
||
flight: null,
|
||
closed: false,
|
||
telemetryId: telemetryStart(options.telemetry === false ? false : options.kind),
|
||
};
|
||
|
||
root.appendChild(shell);
|
||
bindChrome(session);
|
||
active = session;
|
||
lockScroll(true);
|
||
void shell.offsetWidth;
|
||
shell.classList.add("is-open");
|
||
setState(session, options.html !== undefined ? "ready" : "loading");
|
||
telemetryMark(session, "shell");
|
||
|
||
var nodes = focusable(shell);
|
||
try {
|
||
(nodes.length ? nodes[0] : shell).focus();
|
||
} catch (error) {}
|
||
|
||
document.dispatchEvent(new CustomEvent("aksrt:modal:open", {
|
||
detail: { shell: shell, options: options, session: session },
|
||
}));
|
||
|
||
if (options.html !== undefined) {
|
||
rehydrate(session);
|
||
telemetryMark(session, "first-content");
|
||
telemetryMark(session, "ready");
|
||
if (typeof options.onContent === "function") options.onContent(options.html, session);
|
||
}
|
||
|
||
return session;
|
||
}
|
||
|
||
function rehydrate(session) {
|
||
if (!session || !session.content) return;
|
||
window.AksrtFrontend.rehydrate(session.content, "modal");
|
||
}
|
||
|
||
function abortSessionRequest(session) {
|
||
if (!session) return;
|
||
if (session.flight && typeof session.flight.release === "function") session.flight.release();
|
||
session.flight = null;
|
||
if (session.controller) {
|
||
try { session.controller.abort(); } catch (error) {}
|
||
}
|
||
session.controller = null;
|
||
}
|
||
|
||
function close(reason, preserveRequest) {
|
||
if (!active) return;
|
||
var session = active;
|
||
active = null;
|
||
session.closed = true;
|
||
if (!preserveRequest) abortSessionRequest(session);
|
||
session.shell.classList.remove("is-open");
|
||
if (!preserveRequest) lockScroll(false);
|
||
document.dispatchEvent(new CustomEvent("aksrt:modal:close", {
|
||
detail: { shell: session.shell, reason: reason || "close", session: session },
|
||
}));
|
||
|
||
var node = session.shell;
|
||
window.setTimeout(function () {
|
||
if (node && node.parentNode) node.parentNode.removeChild(node);
|
||
var target = session.focusReturn;
|
||
if (!preserveRequest && !active && target && target !== node && document.contains(target) && typeof target.focus === "function") {
|
||
try { target.focus(); } catch (error) {}
|
||
}
|
||
}, 220);
|
||
}
|
||
|
||
function responseData(result) {
|
||
if (!result) return null;
|
||
if (result.data !== undefined && result.data !== null) return result.data;
|
||
if (result.json && result.json.data !== undefined) return result.json.data;
|
||
return result.json;
|
||
}
|
||
|
||
function responseHtml(result) {
|
||
var data = responseData(result);
|
||
if (data && typeof data.html === "string") return data.html;
|
||
if (result && result.json && typeof result.json.html === "string") return result.json.html;
|
||
return result && typeof result.text === "string" ? result.text : "";
|
||
}
|
||
|
||
function errorMessage(error) {
|
||
if (error && error.code === "unauthorized") return "请先登录";
|
||
return error && error.message ? String(error.message) : "加载失败,请重试";
|
||
}
|
||
|
||
function renderError(session, error) {
|
||
if (!session || session.closed || active !== session) return;
|
||
var unauthorized = error && error.code === "unauthorized";
|
||
setState(session, unauthorized ? "unauthorized" : "error", error);
|
||
telemetryMark(session, unauthorized ? "unauthorized" : "error");
|
||
session.content.innerHTML =
|
||
'<div class="aksrt-modal-runtime__error touch border-title"><b>提示</b></div>' +
|
||
'<div class="aksrt-modal-runtime__error-body">' + escapeHtml(errorMessage(error)) +
|
||
'</div><div class="but-average modal-buts">' +
|
||
'<button type="button" class="but" data-aksrt-modal-retry>重试</button>' +
|
||
'<button type="button" class="but" data-aksrt-modal-close>关闭</button></div>';
|
||
rehydrate(session);
|
||
if (typeof session.options.onError === "function") session.options.onError(error, session);
|
||
}
|
||
|
||
function renderResult(session, result) {
|
||
if (!session || session.closed || active !== session) return;
|
||
|
||
if (session.options.responseType === "json" || typeof session.options.renderData === "function") {
|
||
var data = responseData(result);
|
||
if (data === null || data === undefined) {
|
||
setState(session, "empty");
|
||
telemetryMark(session, "first-content");
|
||
telemetryMark(session, "ready");
|
||
session.content.innerHTML = '<div class="aksrt-modal-runtime__error-body">暂无内容</div>';
|
||
return;
|
||
}
|
||
if (typeof session.options.renderData === "function") {
|
||
session.options.renderData(data, session, result);
|
||
}
|
||
setState(session, "ready");
|
||
telemetryMark(session, "first-content");
|
||
rehydrate(session);
|
||
telemetryMark(session, "ready");
|
||
if (typeof session.options.onData === "function") session.options.onData(data, session, result);
|
||
return;
|
||
}
|
||
|
||
var html = responseHtml(result);
|
||
if (!html) {
|
||
setState(session, "empty");
|
||
telemetryMark(session, "first-content");
|
||
telemetryMark(session, "ready");
|
||
session.content.innerHTML = '<div class="aksrt-modal-runtime__error-body">暂无内容</div>';
|
||
return;
|
||
}
|
||
session.content.innerHTML = html;
|
||
setState(session, "ready");
|
||
telemetryMark(session, "first-content");
|
||
rehydrate(session);
|
||
telemetryMark(session, "ready");
|
||
if (typeof session.options.onContent === "function") session.options.onContent(html, session);
|
||
}
|
||
|
||
function load(session, loadOptions) {
|
||
loadOptions = loadOptions || {};
|
||
if (!session || session.closed || !session.options.url) return Promise.resolve(session && session.shell);
|
||
abortSessionRequest(session);
|
||
setState(session, "loading");
|
||
session.content.innerHTML = skeleton(session.options);
|
||
session.controller = window.AbortController ? new window.AbortController() : null;
|
||
|
||
var requestOptions = {
|
||
method: session.options.method || "GET",
|
||
headers: session.options.headers || {},
|
||
body: session.options.body,
|
||
query: session.options.query,
|
||
signal: session.controller ? session.controller.signal : undefined,
|
||
};
|
||
if (requestOptions.body === undefined) delete requestOptions.body;
|
||
if (!requestOptions.signal) delete requestOptions.signal;
|
||
|
||
var request = function () {
|
||
return window.AksrtRequest.request(session.options.url, requestOptions);
|
||
};
|
||
|
||
var method = String(session.options.method || "GET").toUpperCase();
|
||
var cacheable = method === "GET" && session.options.cache !== false;
|
||
var cacheKey = session.options.cacheKey ||
|
||
method + ":" + window.AksrtRequest.url(session.options.url, session.options.query);
|
||
var cache = window.AksrtModalCache;
|
||
var acquireOptions = {
|
||
ttl: Number(session.options.cacheTtl || 15000),
|
||
tags: session.options.cacheTags || session.options.tags || [],
|
||
skipCache: !!loadOptions.force || !cacheable,
|
||
store: cacheable,
|
||
cancel: function () {
|
||
if (session.controller) {
|
||
try { session.controller.abort(); } catch (error) {}
|
||
}
|
||
},
|
||
};
|
||
|
||
var flight = cacheable
|
||
? cache.acquire(cacheKey, request, acquireOptions)
|
||
: { promise: request(), release: function () {} };
|
||
session.flight = flight;
|
||
|
||
return flight.promise.then(function (result) {
|
||
if (!session.closed && active === session) renderResult(session, result);
|
||
return session.shell;
|
||
}).catch(function (error) {
|
||
var aborted = error && (error.name === "AbortError" || error.code === "ABORT_ERR");
|
||
if (!aborted && !session.closed && active === session) renderError(session, error);
|
||
return session.shell;
|
||
}).then(function (shell) {
|
||
// A refresh/replacement may have installed a newer flight on this session.
|
||
// Only the owner of this promise may release and clear the slot.
|
||
if (session.flight === flight) {
|
||
if (flight && typeof flight.release === "function") flight.release();
|
||
session.flight = null;
|
||
}
|
||
return shell;
|
||
});
|
||
}
|
||
|
||
function open(options) {
|
||
options = options || {};
|
||
close("replace");
|
||
var session = createSession(options);
|
||
return session.shell;
|
||
}
|
||
|
||
function sessionKey(options) {
|
||
if (!options || !options.url) return "";
|
||
var method = String(options.method || "GET").toUpperCase();
|
||
var requestUrl = window.AksrtRequest.url(options.url, options.query);
|
||
return method + ":" + requestUrl;
|
||
}
|
||
|
||
function openRemote(options) {
|
||
options = Object.assign({}, options || {});
|
||
if (!options.url) return Promise.reject(new Error("missing url"));
|
||
var sameRequest = active && active.flight && sessionKey(active.options) === sessionKey(options);
|
||
close("replace", !!sameRequest);
|
||
var session = createSession(options);
|
||
return load(session).then(function () { return session.shell; });
|
||
}
|
||
|
||
function refresh(options) {
|
||
if (!active || !active.options.url) return Promise.resolve(null);
|
||
if (options && typeof options === "object") active.options = Object.assign({}, active.options, options);
|
||
return load(active, { force: true });
|
||
}
|
||
|
||
function registerLoader(kind, loader) {
|
||
if (!kind || typeof loader !== "function") return;
|
||
loaders[String(kind)] = loader;
|
||
}
|
||
|
||
function openLoader(kind, context) {
|
||
var loader = loaders[String(kind)];
|
||
if (!loader) return Promise.reject(new Error("missing modal loader: " + kind));
|
||
return openRemote(loader(context || {}));
|
||
}
|
||
|
||
function invalidate(tags) {
|
||
return window.AksrtModalCache.invalidate(tags);
|
||
}
|
||
|
||
window.AksrtModalRuntime = {
|
||
open: open,
|
||
openRemote: openRemote,
|
||
close: close,
|
||
refresh: refresh,
|
||
registerLoader: registerLoader,
|
||
openLoader: openLoader,
|
||
invalidate: invalidate,
|
||
getActive: function () { return active ? active.shell : null; },
|
||
getState: function () { return active ? active.state : null; },
|
||
};
|
||
|
||
document.dispatchEvent(new CustomEvent("aksrt:modal-runtime:ready"));
|
||
})(window, document);
|
||
;
|
||
|
||
/* source: assets/js/core/modal-triggers.js */
|
||
/**
|
||
* Declarative modal triggers.
|
||
*
|
||
* The only modal entry point is AksrtModalRuntime. Triggers carry an
|
||
* explicit URL and never create a second modal implementation.
|
||
*
|
||
* @package AKSRT
|
||
*/
|
||
(function (window, document) {
|
||
"use strict";
|
||
|
||
function openFromTrigger(element) {
|
||
var runtime = window.AksrtModalRuntime;
|
||
var url = element.getAttribute("data-aksrt-modal-url") || "";
|
||
if (!url || url === "#") return;
|
||
|
||
var ttl = parseInt(element.getAttribute("data-aksrt-modal-cache-ttl") || "15000", 10);
|
||
var cache = element.getAttribute("data-aksrt-modal-cache") !== "false";
|
||
var tags = (element.getAttribute("data-aksrt-modal-cache-tags") || "").split(",").map(function (tag) {
|
||
return tag.trim();
|
||
}).filter(Boolean);
|
||
|
||
runtime.openRemote({
|
||
url: url,
|
||
method: element.getAttribute("data-aksrt-modal-method") || "GET",
|
||
className: element.getAttribute("data-aksrt-modal-class") || "modal-mini full-sm",
|
||
height: parseInt(element.getAttribute("data-aksrt-modal-height") || "0", 10) || 0,
|
||
mobileBottom: element.getAttribute("data-aksrt-modal-mobile-bottom") === "true",
|
||
bottom: element.getAttribute("data-aksrt-modal-bottom") === "true",
|
||
kind: element.getAttribute("data-aksrt-modal-kind") || "generic",
|
||
cacheKey: element.getAttribute("data-aksrt-modal-cache-key") || "",
|
||
cache: cache,
|
||
cacheTtl: ttl > 0 ? ttl : 15000,
|
||
cacheTags: tags,
|
||
});
|
||
}
|
||
|
||
document.addEventListener("click", function (event) {
|
||
var trigger = event.target.closest('[data-aksrt-modal="remote"]');
|
||
if (!trigger) return;
|
||
event.preventDefault();
|
||
openFromTrigger(trigger);
|
||
});
|
||
})(window, document);
|
||
;
|
||
|
||
/* source: assets/js/core/article.js */
|
||
/**
|
||
* AKSRT Article Tools — password toggles, search clear, article actions, interaction bar
|
||
*/
|
||
(function () {
|
||
"use strict";
|
||
|
||
function initPasswordToggles(root) {
|
||
(root || document).querySelectorAll(".toggle-pwd").forEach(function (btn) {
|
||
if (btn.dataset.pwdToggleBound) return;
|
||
btn.dataset.pwdToggleBound = "1";
|
||
btn.addEventListener("click", function () {
|
||
var id = btn.getAttribute("data-target");
|
||
var input = id ? document.getElementById(id) : null;
|
||
if (!input) return;
|
||
var show = input.getAttribute("type") === "password";
|
||
input.setAttribute("type", show ? "text" : "password");
|
||
btn.setAttribute("aria-label", show ? "隐藏密码" : "显示密码");
|
||
});
|
||
});
|
||
}
|
||
|
||
function initSearchClear() {
|
||
var btn = document.getElementById("search-clear-btn");
|
||
var input = document.getElementById("search-page-input");
|
||
|
||
if (btn && input) {
|
||
var syncClearButton = function () {
|
||
var hasValue = input.value.trim().length > 0;
|
||
btn.classList.toggle("is-visible", hasValue);
|
||
btn.hidden = !hasValue;
|
||
};
|
||
|
||
btn.addEventListener("click", function () {
|
||
input.value = "";
|
||
input.focus();
|
||
syncClearButton();
|
||
});
|
||
|
||
input.addEventListener("input", syncClearButton);
|
||
syncClearButton();
|
||
}
|
||
|
||
var categorySelect = document.getElementById("search-category-filter");
|
||
if (categorySelect) {
|
||
categorySelect.addEventListener("change", function () {
|
||
var url = new URL(window.location.href);
|
||
if (this.value) {
|
||
url.searchParams.set("aksrt_category", this.value);
|
||
} else {
|
||
url.searchParams.delete("aksrt_category");
|
||
}
|
||
if (url.searchParams.get("aksrt_search_type") && url.searchParams.get("aksrt_search_type") !== "post") {
|
||
url.searchParams.delete("aksrt_category");
|
||
}
|
||
url.searchParams.delete("paged");
|
||
window.location.href = url.toString();
|
||
});
|
||
}
|
||
}
|
||
|
||
function initArticleTools() {
|
||
var buttons = document.querySelectorAll("[data-article-tool]");
|
||
if (!buttons.length) return;
|
||
|
||
buttons.forEach(function (button) {
|
||
button.addEventListener("click", function () {
|
||
var tool = button.getAttribute("data-article-tool");
|
||
if (tool === "print") {
|
||
window.print();
|
||
return;
|
||
}
|
||
|
||
if (tool === "pdf") {
|
||
window.print();
|
||
notyf("请在打印对话框中选择“另存为 PDF”", "info");
|
||
}
|
||
});
|
||
});
|
||
}
|
||
|
||
var postMetaDocumentEventsBound = false;
|
||
|
||
function setPostMetaMenuState(menuRoot, open) {
|
||
var toggle = menuRoot.querySelector(".post-drop-meta__toggle");
|
||
var menu = menuRoot.querySelector(".post-drop-meta__menu");
|
||
if (!toggle || !menu) return;
|
||
|
||
menuRoot.classList.toggle("is-open", open);
|
||
toggle.setAttribute("aria-expanded", open ? "true" : "false");
|
||
menu.setAttribute("aria-hidden", open ? "false" : "true");
|
||
}
|
||
|
||
function closePostMetaMenus(except, restoreFocus) {
|
||
document.querySelectorAll(".post-drop-meta.is-open").forEach(function (menuRoot) {
|
||
if (menuRoot === except) return;
|
||
var toggle = menuRoot.querySelector(".post-drop-meta__toggle");
|
||
setPostMetaMenuState(menuRoot, false);
|
||
if (restoreFocus && toggle) toggle.focus();
|
||
});
|
||
}
|
||
|
||
function initPostMetaMenus(root) {
|
||
var scope = root || document;
|
||
var menuRoots = [];
|
||
|
||
if (scope.nodeType === 1 && scope.matches(".post-drop-meta")) {
|
||
menuRoots.push(scope);
|
||
}
|
||
scope.querySelectorAll(".post-drop-meta").forEach(function (menuRoot) {
|
||
menuRoots.push(menuRoot);
|
||
});
|
||
|
||
menuRoots.forEach(function (menuRoot) {
|
||
var toggle = menuRoot.querySelector(".post-drop-meta__toggle");
|
||
var menu = menuRoot.querySelector(".post-drop-meta__menu");
|
||
if (!toggle || !menu || toggle.dataset.postMetaMenuBound) return;
|
||
|
||
toggle.dataset.postMetaMenuBound = "1";
|
||
setPostMetaMenuState(menuRoot, false);
|
||
|
||
toggle.addEventListener("click", function () {
|
||
var open = !menuRoot.classList.contains("is-open");
|
||
closePostMetaMenus(menuRoot, false);
|
||
setPostMetaMenuState(menuRoot, open);
|
||
});
|
||
|
||
menu.addEventListener("click", function (event) {
|
||
if (event.target.closest(".post-drop-meta__item")) {
|
||
setPostMetaMenuState(menuRoot, false);
|
||
}
|
||
});
|
||
});
|
||
|
||
if (menuRoots.length && !postMetaDocumentEventsBound) {
|
||
postMetaDocumentEventsBound = true;
|
||
document.addEventListener("click", function (event) {
|
||
if (!event.target.closest(".post-drop-meta")) {
|
||
closePostMetaMenus(null, false);
|
||
}
|
||
});
|
||
document.addEventListener("keydown", function (event) {
|
||
if (event.key === "Escape") {
|
||
closePostMetaMenus(null, true);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
function getBaseStatCount(statName) {
|
||
var statEl = document.querySelector('[data-stat-count="' + statName + '"][data-base-count]');
|
||
return statEl ? (parseInt(statEl.dataset.baseCount, 10) || 0) : 0;
|
||
}
|
||
|
||
function updateStatCounts(statName, count) {
|
||
var safeCount = Math.max(0, count);
|
||
document.querySelectorAll('[data-stat-count="' + statName + '"]').forEach(function (statEl) {
|
||
statEl.textContent = String(safeCount);
|
||
});
|
||
}
|
||
|
||
function setBaseStatCount(statName, count) {
|
||
var safeCount = Math.max(0, count);
|
||
document.querySelectorAll('[data-stat-count="' + statName + '"][data-base-count]').forEach(function (statEl) {
|
||
statEl.dataset.baseCount = String(safeCount);
|
||
});
|
||
updateStatCounts(statName, safeCount);
|
||
}
|
||
|
||
function requestInteraction(actionName, postId, active) {
|
||
if (!window.aksrtData || !aksrtData.ajaxUrl || !aksrtData.nonce) {
|
||
return Promise.reject(new Error("互动服务未配置"));
|
||
}
|
||
|
||
var body = new URLSearchParams();
|
||
body.set("action", actionName);
|
||
body.set("nonce", aksrtData.nonce);
|
||
body.set("postId", String(postId));
|
||
body.set("active", active ? "1" : "0");
|
||
|
||
return fetch(aksrtData.ajaxUrl, {
|
||
method: "POST",
|
||
headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" },
|
||
credentials: "same-origin",
|
||
body: body.toString()
|
||
}).then(function (response) {
|
||
return response.json().catch(function () {
|
||
throw new Error("服务器返回无效响应");
|
||
});
|
||
}).then(function (payload) {
|
||
if (!payload || !payload.success) {
|
||
var message = payload && payload.data && payload.data.message ? payload.data.message : "请求失败";
|
||
throw new Error(message);
|
||
}
|
||
return payload.data || {};
|
||
});
|
||
}
|
||
|
||
function setButtonBusy(button, busy) {
|
||
button.disabled = !!busy;
|
||
button.classList.toggle("is-loading", !!busy);
|
||
}
|
||
|
||
function findInScope(scope, id) {
|
||
scope = scope || document;
|
||
if (!scope) return null;
|
||
if (scope.nodeType === 9) {
|
||
return scope.getElementById(id);
|
||
}
|
||
if (scope.nodeType === 1) {
|
||
if (scope.id === id) return scope;
|
||
return typeof scope.querySelector === "function"
|
||
? scope.querySelector("#" + id)
|
||
: null;
|
||
}
|
||
return null;
|
||
}
|
||
|
||
function collectActionButtons(scope, selector) {
|
||
scope = scope || document;
|
||
var list = [];
|
||
if (!scope) return list;
|
||
if (scope.nodeType === 1 && scope.matches && scope.matches(selector)) {
|
||
list.push(scope);
|
||
}
|
||
if (typeof scope.querySelectorAll === "function") {
|
||
var found = scope.querySelectorAll(selector);
|
||
for (var i = 0; i < found.length; i++) list.push(found[i]);
|
||
} else if (scope.nodeType === 9) {
|
||
var all = document.querySelectorAll(selector);
|
||
for (var j = 0; j < all.length; j++) list.push(all[j]);
|
||
}
|
||
// also keep legacy id hooks
|
||
var legacyId = selector.indexOf("action-like") >= 0 ? "action-like" : (selector.indexOf("action-favorite") >= 0 ? "action-favorite" : "");
|
||
if (legacyId) {
|
||
var legacy = findInScope(scope, legacyId);
|
||
if (legacy && list.indexOf(legacy) === -1) list.push(legacy);
|
||
}
|
||
return list;
|
||
}
|
||
|
||
function initInteractionBar(root) {
|
||
var scope = root || document;
|
||
// Bind all like/favorite controls (in-content + footer tabbar extend).
|
||
var likeBtns = collectActionButtons(scope, ".action-like[data-post-id]");
|
||
var favBtns = collectActionButtons(scope, ".action-favorite[data-post-id]");
|
||
|
||
function paintLike(btn, isActive) {
|
||
btn.dataset.initialActive = isActive ? "1" : "0";
|
||
btn.classList.toggle("is-active", isActive);
|
||
var icon = btn.querySelector("i");
|
||
if (icon) icon.className = isActive ? "fa fas fa-heart" : "fa fas fa-heart";
|
||
}
|
||
|
||
function paintFavorite(btn, isActive) {
|
||
btn.dataset.initialActive = isActive ? "1" : "0";
|
||
btn.classList.toggle("is-active", isActive);
|
||
var icon = btn.querySelector("i");
|
||
if (icon) icon.className = isActive ? "fa fas fa-star" : "fa fas fa-star";
|
||
}
|
||
|
||
function applyLikeState(isActive, count) {
|
||
for (var i = 0; i < likeBtns.length; i++) paintLike(likeBtns[i], isActive);
|
||
if ("number" === typeof count && !isNaN(count)) {
|
||
setBaseStatCount("likes", count);
|
||
} else {
|
||
updateStatCounts("likes", getBaseStatCount("likes"));
|
||
}
|
||
}
|
||
|
||
function applyFavoriteState(isActive, count) {
|
||
for (var i = 0; i < favBtns.length; i++) paintFavorite(favBtns[i], isActive);
|
||
if ("number" === typeof count && !isNaN(count)) {
|
||
setBaseStatCount("favorites", count);
|
||
} else {
|
||
updateStatCounts("favorites", getBaseStatCount("favorites"));
|
||
}
|
||
}
|
||
|
||
if (likeBtns.length) {
|
||
var seedLike = likeBtns[0];
|
||
if (!seedLike.dataset.aksrtInteractionBound) {
|
||
applyLikeState(seedLike.dataset.initialActive === "1", getBaseStatCount("likes"));
|
||
likeBtns.forEach(function (likeBtn) {
|
||
if (likeBtn.dataset.aksrtInteractionBound) return;
|
||
likeBtn.dataset.aksrtInteractionBound = "1";
|
||
likeBtn.addEventListener("click", function () {
|
||
var postId = likeBtn.dataset.postId ? String(likeBtn.dataset.postId) : "";
|
||
if (!postId || likeBtn.disabled) return;
|
||
var nextState = likeBtn.dataset.initialActive !== "1";
|
||
setButtonBusy(likeBtn, true);
|
||
requestInteraction("aksrt_toggle_like", postId, nextState).then(function (data) {
|
||
applyLikeState(!!data.active, parseInt(data.count, 10) || 0);
|
||
notyf(data.active ? "感谢你的点赞" : "已取消点赞", "success");
|
||
}).catch(function (error) {
|
||
notyf(error && error.message ? error.message : "点赞失败", "danger");
|
||
}).finally(function () {
|
||
setButtonBusy(likeBtn, false);
|
||
});
|
||
});
|
||
});
|
||
}
|
||
}
|
||
|
||
if (favBtns.length) {
|
||
var seedFav = favBtns[0];
|
||
if (!seedFav.dataset.aksrtInteractionBound) {
|
||
applyFavoriteState(seedFav.dataset.initialActive === "1", getBaseStatCount("favorites"));
|
||
favBtns.forEach(function (favBtn) {
|
||
if (favBtn.dataset.aksrtInteractionBound) return;
|
||
favBtn.dataset.aksrtInteractionBound = "1";
|
||
favBtn.addEventListener("click", function () {
|
||
var postId = favBtn.dataset.postId ? String(favBtn.dataset.postId) : "";
|
||
if (!postId || favBtn.disabled) return;
|
||
var nextState = favBtn.dataset.initialActive !== "1";
|
||
setButtonBusy(favBtn, true);
|
||
requestInteraction("aksrt_toggle_favorite", postId, nextState).then(function (data) {
|
||
applyFavoriteState(!!data.active, parseInt(data.count, 10) || 0);
|
||
notyf(data.active ? "收藏成功" : "已取消收藏", "success");
|
||
}).catch(function (error) {
|
||
notyf(error && error.message ? error.message : "收藏失败", "danger");
|
||
}).finally(function () {
|
||
setButtonBusy(favBtn, false);
|
||
});
|
||
});
|
||
});
|
||
}
|
||
}
|
||
}
|
||
|
||
window.AksrtFrontend.register("aksrt-search-clear", function () { initSearchClear(); });
|
||
window.AksrtFrontend.register("aksrt-article-tools", function () { initArticleTools(); });
|
||
window.AksrtFrontend.register("aksrt-post-meta-menus", function (root) { initPostMetaMenus(root); });
|
||
window.AksrtFrontend.register("aksrt-password-toggles", function (root) { initPasswordToggles(root); });
|
||
window.AksrtFrontend.register("aksrt-interaction-bar", function (root) { initInteractionBar(root); });
|
||
})();
|
||
;
|
||
|
||
/* source: assets/js/core/comments.js */
|
||
/**
|
||
* AKSRT Comment System — AJAX submit, captcha, ordering, author filter
|
||
*/
|
||
(function () {
|
||
"use strict";
|
||
|
||
function initCommentSystem() {
|
||
var form = document.querySelector("#commentform");
|
||
if (!form) return;
|
||
|
||
// 修复:同时匹配 button 和 input 元素
|
||
var submitBtn = form.querySelector('[type="submit"]');
|
||
if (!submitBtn) return;
|
||
var isInputSubmit = submitBtn.tagName === 'INPUT';
|
||
|
||
// 保存原始按钮内容(用于恢复)
|
||
var originalBtnHTML = isInputSubmit ? submitBtn.value : submitBtn.innerHTML;
|
||
|
||
function setSubmitBtnContent(html, textFallback) {
|
||
if (isInputSubmit) {
|
||
submitBtn.value = textFallback;
|
||
} else {
|
||
submitBtn.innerHTML = html;
|
||
}
|
||
}
|
||
|
||
// 状态管理
|
||
var isSubmitting = false;
|
||
var countdownTimer = null;
|
||
|
||
// 显示/隐藏加载状态
|
||
function setLoading(loading) {
|
||
if (loading) {
|
||
isSubmitting = true;
|
||
submitBtn.classList.add("is-loading");
|
||
submitBtn.disabled = true;
|
||
var loadingText = (window.aksrtData && aksrtData.commentSubmittingText) || '发送中...';
|
||
setSubmitBtnContent('<i class="fa fas fa-spinner fa-spin"></i> ' + loadingText, loadingText);
|
||
} else {
|
||
isSubmitting = false;
|
||
submitBtn.classList.remove("is-loading");
|
||
submitBtn.classList.remove('countdown-active');
|
||
submitBtn.disabled = false;
|
||
setSubmitBtnContent(originalBtnHTML, originalBtnHTML);
|
||
}
|
||
}
|
||
|
||
// 收集表单数据(包含验证码字段)
|
||
function collectFormData() {
|
||
var formData = new FormData(form);
|
||
|
||
// 确保包含必要的隐藏字段
|
||
var postId = document.querySelector('input[name="comment_post_ID"]');
|
||
if (postId && !formData.get('comment_post_ID')) {
|
||
formData.append('comment_post_ID', postId.value);
|
||
}
|
||
|
||
return formData;
|
||
}
|
||
|
||
// 从 wp_die() HTML 中提取错误信息
|
||
function extractErrorMessage(html) {
|
||
// WordPress wp_die() 输出格式: <p>错误信息</p>
|
||
var match = html.match(/<p[^>]*>([^<]+)<\/p>/i);
|
||
return match ? match[1].trim() : '未知错误';
|
||
}
|
||
|
||
// 从错误消息中提取等待时间(秒)
|
||
function extractWaitTime(msg) {
|
||
var match = msg.match(/(\d+)\s*秒/);
|
||
return match ? parseInt(match[1]) : 0;
|
||
}
|
||
|
||
// 启动倒计时(用于频率限制)
|
||
function startCountdown(seconds) {
|
||
if (countdownTimer) clearInterval(countdownTimer);
|
||
|
||
submitBtn.classList.add('countdown-active');
|
||
submitBtn.disabled = true;
|
||
var remaining = seconds;
|
||
|
||
countdownTimer = setInterval(function () {
|
||
setSubmitBtnContent(
|
||
'<i class="fa fas fa-clock"></i> 请等待 ' + remaining + 's',
|
||
'请等待 ' + remaining + 's'
|
||
);
|
||
|
||
if (--remaining <= 0) {
|
||
clearInterval(countdownTimer);
|
||
countdownTimer = null;
|
||
submitBtn.classList.remove('countdown-active', 'is-loading');
|
||
submitBtn.disabled = false;
|
||
setSubmitBtnContent(originalBtnHTML, originalBtnHTML);
|
||
isSubmitting = false;
|
||
}
|
||
}, 1000);
|
||
}
|
||
|
||
function updateCommentCount(delta) {
|
||
var countEl = document.querySelector('#comments .title-theme small');
|
||
if (!countEl) return;
|
||
var text = countEl.textContent || '';
|
||
var match = text.match(/(\d+)/);
|
||
if (!match) return;
|
||
var nextCount = Math.max(0, parseInt(match[1], 10) + delta);
|
||
countEl.textContent = text.replace(match[1], String(nextCount));
|
||
}
|
||
function handleResponse(responseText, statusCode) {
|
||
try {
|
||
// 情况1: 成功提交 - 包含评论ID或成功标记
|
||
if (statusCode === 200 || statusCode === 201) {
|
||
if (responseText.includes('comment-submitted') ||
|
||
responseText.indexOf('id="comment-') !== -1 ||
|
||
responseText.indexOf('awaiting-moderation') !== -1) {
|
||
|
||
// 区分是否需要审核
|
||
if (responseText.indexOf('审核') !== -1 ||
|
||
responseText.indexOf('moderation') !== -1 ||
|
||
responseText.includes('awaiting-moderation')) {
|
||
notyf('评论已提交,等待管理员审核', 'info');
|
||
} else {
|
||
notyf('评论发布成功', 'success');
|
||
}
|
||
|
||
// 清空文本框
|
||
var textarea = form.querySelector('#comment');
|
||
if (textarea) textarea.value = '';
|
||
|
||
// 重置回复状态
|
||
var replyInfo = document.getElementById('comment-reply-info');
|
||
if (replyInfo) replyInfo.style.display = 'none';
|
||
|
||
// 刷新评论列表(延迟执行,确保后端处理完成)
|
||
setTimeout(function () {
|
||
reloadCommentList();
|
||
}, 500);
|
||
setLoading(false);
|
||
|
||
return true;
|
||
}
|
||
}
|
||
|
||
// 情况2: HTTP 429 频率限制
|
||
if (statusCode === 429) {
|
||
var errorMsg = extractErrorMessage(responseText);
|
||
var waitSeconds = extractWaitTime(errorMsg);
|
||
|
||
notyf(errorMsg, 'warning');
|
||
|
||
if (waitSeconds > 0) {
|
||
startCountdown(waitSeconds);
|
||
} else {
|
||
setLoading(false); // 无具体等待时间时恢复按钮
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
// 情况3: HTTP 403 权限不足(地区/IP/关键词等)
|
||
if (statusCode === 403) {
|
||
var forbiddenMsg = extractErrorMessage(responseText);
|
||
notyf(forbiddenMsg, 'danger');
|
||
setLoading(false);
|
||
return false;
|
||
}
|
||
|
||
// 情况4: 包含WordPress错误信息
|
||
var errorMatch = responseText.match(/<p[^>]*>([^<]*(?:错误|失败|error|Error)[^<]*)<\/p>/i);
|
||
if (errorMatch) {
|
||
notyf(errorMatch[1].trim(), 'danger');
|
||
setLoading(false);
|
||
return false;
|
||
}
|
||
// 默认情况:可能是成功或其他
|
||
notyf('评论已提交', 'success');
|
||
var textarea2 = form.querySelector('#comment');
|
||
if (textarea2) textarea2.value = '';
|
||
|
||
// 局部刷新评论列表(不再整页 reload)
|
||
setTimeout(function () {
|
||
reloadCommentList();
|
||
}, 500);
|
||
setLoading(false);
|
||
|
||
return true;
|
||
|
||
} catch (e) {
|
||
console.error('[AKSRT Comment] 解析响应失败:', e);
|
||
notyf('响应解析异常,请重试', 'danger');
|
||
setLoading(false);
|
||
return false;
|
||
}
|
||
}
|
||
|
||
// 执行实际的 AJAX 请求 — local insert instead of full-page re-fetch
|
||
function performSubmit() {
|
||
setLoading(true);
|
||
|
||
var formData = collectFormData();
|
||
var restRoot = (window.aksrtData && aksrtData.siteUrl) ? String(aksrtData.siteUrl).replace(/\/$/, '') : '';
|
||
var editId = form.querySelector('[name="edit_comment_ID"]');
|
||
var isEdit = editId && parseInt(editId.value, 10) > 0;
|
||
var restBase = (restRoot || '') + '/wp-json/aksrt/v1/comment/' + (isEdit ? 'edit' : 'submit');
|
||
|
||
// Try REST endpoint for local-insert HTML response
|
||
var restBody = {};
|
||
formData.forEach(function (v, k) { restBody[k] = v; });
|
||
if (isEdit) {
|
||
restBody.comment_id = parseInt(editId.value, 10);
|
||
restBody.content = restBody.comment || restBody.content || '';
|
||
}
|
||
|
||
fetch(restBase, {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/json',
|
||
'X-WP-Nonce': (window.aksrtData && aksrtData.restNonce) || ''
|
||
},
|
||
credentials: 'same-origin',
|
||
body: JSON.stringify(restBody)
|
||
})
|
||
.then(function (r) { return r.json(); })
|
||
.then(function (json) {
|
||
if (isEdit && json && json.success) {
|
||
var cid = restBody.comment_id;
|
||
var contentEl = document.querySelector('#comment-content-' + cid + ', [data-comment-id="' + cid + '"] .comment-content');
|
||
var rendered = (json.data && json.data.content) || json.content || '';
|
||
if (contentEl && rendered) contentEl.innerHTML = rendered;
|
||
var textarea = form.querySelector('#comment');
|
||
if (textarea) textarea.value = '';
|
||
if (editId) editId.remove();
|
||
restoreRespondPosition();
|
||
setLoading(false);
|
||
notyf(json.message || '评论已更新', 'success');
|
||
var respondEl = document.getElementById('respond');
|
||
if (respondEl && window.AksrtFixedInput) window.AksrtFixedInput(respondEl, 'hide');
|
||
return;
|
||
}
|
||
if (json && json.success && json.html) {
|
||
// Local insert: prepend new comment HTML
|
||
localInsertComment(json.html, json.is_reply, json.parent_id, json.needs_moderation);
|
||
|
||
var textarea = form.querySelector('#comment');
|
||
if (textarea) textarea.value = '';
|
||
|
||
var replyInfo = document.getElementById('comment-reply-info');
|
||
if (replyInfo) replyInfo.style.display = 'none';
|
||
// Reset captcha after successful submit
|
||
try {
|
||
var captchaScene = window.AKSRTCaptchaState &&
|
||
window.AKSRTCaptchaState.scenes &&
|
||
window.AKSRTCaptchaState.scenes.comment;
|
||
if (captchaScene && typeof captchaScene.reset === 'function') {
|
||
captchaScene.reset();
|
||
}
|
||
} catch (e) { /* ignore */ }
|
||
|
||
// Wait time countdown
|
||
if (json.wait_time && json.wait_time > 0) {
|
||
startCountdown(json.wait_time);
|
||
} else {
|
||
setLoading(false);
|
||
}
|
||
|
||
// Move respond back to original position
|
||
restoreRespondPosition();
|
||
|
||
// Hide mobile FixedInput after successful submit.
|
||
var respondEl = document.getElementById('respond');
|
||
if (respondEl && window.AksrtFixedInput) {
|
||
window.AksrtFixedInput(respondEl, 'hide');
|
||
} else if (respondEl) {
|
||
respondEl.classList.remove('show');
|
||
}
|
||
|
||
// If editing via moveForm, clear edit field.
|
||
var editField = form.querySelector('[name="edit_comment_ID"]');
|
||
if (editField) editField.remove();
|
||
|
||
return;
|
||
}
|
||
|
||
if (json && json.code) {
|
||
notyf(json.message || '评论提交失败', 'danger');
|
||
try {
|
||
var failScene = window.AKSRTCaptchaState &&
|
||
window.AKSRTCaptchaState.scenes &&
|
||
window.AKSRTCaptchaState.scenes.comment;
|
||
if (failScene && typeof failScene.reset === 'function') {
|
||
failScene.reset();
|
||
}
|
||
} catch (e) { /* ignore */ }
|
||
if (json.wait_time) startCountdown(json.wait_time);
|
||
else setLoading(false);
|
||
return;
|
||
}
|
||
|
||
notyf('评论已提交', 'success');
|
||
setLoading(false);
|
||
setTimeout(function () { reloadCommentList(); }, 500);
|
||
})
|
||
.catch(function () {
|
||
// Fallback: submit to wp-comments-post.php directly
|
||
performLegacySubmit();
|
||
});
|
||
}
|
||
|
||
function localInsertComment(html, isReply, parentId, needsModeration) {
|
||
var temp = document.createElement('div');
|
||
temp.innerHTML = html;
|
||
var newComment = temp.firstElementChild;
|
||
if (!newComment) { reloadCommentList(); return; }
|
||
|
||
newComment.style.overflow = 'hidden';
|
||
newComment.style.maxHeight = '0';
|
||
newComment.style.opacity = '0';
|
||
newComment.style.transition = 'max-height 0.4s ease, opacity 0.3s ease';
|
||
if (isReply && parentId) {
|
||
var parentComment = document.querySelector('#comment-' + parentId);
|
||
if (parentComment) {
|
||
var children = parentComment.querySelector(':scope > .children');
|
||
if (!children) {
|
||
children = document.createElement('ol');
|
||
children.className = 'children';
|
||
parentComment.appendChild(children);
|
||
}
|
||
children.insertBefore(newComment, children.firstChild);
|
||
} else {
|
||
prependToCommentList(newComment);
|
||
}
|
||
} else {
|
||
prependToCommentList(newComment);
|
||
}
|
||
|
||
// slideDown animation
|
||
requestAnimationFrame(function () {
|
||
newComment.style.maxHeight = newComment.scrollHeight + 100 + 'px';
|
||
newComment.style.opacity = '1';
|
||
setTimeout(function () {
|
||
newComment.style.maxHeight = '';
|
||
newComment.style.overflow = '';
|
||
newComment.style.transition = '';
|
||
}, 500);
|
||
});
|
||
|
||
if (needsModeration) {
|
||
notyf('评论已提交,等待管理员审核', 'info');
|
||
} else {
|
||
notyf('评论发布成功', 'success');
|
||
}
|
||
|
||
if (window.AksrtFrontend) AksrtFrontend.rehydrate(newComment, 'ajax');
|
||
updateCommentCount(1);
|
||
}
|
||
|
||
function prependToCommentList(el) {
|
||
var list = document.querySelector('#comments .commentlist');
|
||
if (!list) return;
|
||
// 插到筛选栏之后、最新评论之前
|
||
var filter = list.querySelector('.comment-filter');
|
||
if (filter && filter.nextSibling) {
|
||
list.insertBefore(el, filter.nextSibling);
|
||
} else {
|
||
list.insertBefore(el, list.firstChild);
|
||
}
|
||
}
|
||
|
||
function restoreRespondPosition() {
|
||
var respond = document.getElementById('respond');
|
||
var placeholder = document.getElementById('wp-temp-form-div');
|
||
if (respond && placeholder && placeholder.parentNode) {
|
||
placeholder.parentNode.insertBefore(respond, placeholder);
|
||
placeholder.remove();
|
||
}
|
||
}
|
||
// Legacy fallback: POST to wp-comments-post.php
|
||
function performLegacySubmit() {
|
||
var formData = collectFormData();
|
||
var actionUrl = form.getAttribute('action') || '/wp-comments-post.php';
|
||
|
||
fetch(actionUrl, {
|
||
method: 'POST',
|
||
body: formData,
|
||
credentials: 'same-origin',
|
||
headers: { 'X-Requested-With': 'XMLHttpRequest' }
|
||
})
|
||
.then(function (response) {
|
||
return response.text().then(function (text) {
|
||
return { status: response.status, text: text, ok: response.ok };
|
||
});
|
||
})
|
||
.then(function (result) {
|
||
handleResponse(result.text, result.status);
|
||
})
|
||
.catch(function (error) {
|
||
console.error('[AKSRT Comment] 提交失败:', error);
|
||
|
||
if (error.message === 'Failed to fetch' || error.name === 'TypeError') {
|
||
notyf('网络连接失败,请检查网络后重试', 'danger');
|
||
} else {
|
||
notyf(error.message || '评论提交失败,请重试', 'danger');
|
||
}
|
||
|
||
setLoading(false);
|
||
})
|
||
.finally(function () {
|
||
// 兜底:避免异常分支漏掉状态恢复导致按钮卡在"发送中"
|
||
if (!countdownTimer && isSubmitting) {
|
||
setLoading(false);
|
||
}
|
||
});
|
||
}
|
||
|
||
// 核心表单提交事件处理器
|
||
function handleSubmit(e) {
|
||
// 如果已经在提交中或倒计时中,防止重复提交
|
||
if (isSubmitting || countdownTimer) {
|
||
e.preventDefault();
|
||
e.stopImmediatePropagation();
|
||
return false;
|
||
}
|
||
|
||
// 阻止默认表单提交
|
||
e.preventDefault();
|
||
e.stopImmediatePropagation();
|
||
// 检查验证码状态(如果有验证码组件)
|
||
var captchaScene = window.AKSRTCaptchaState &&
|
||
window.AKSRTCaptchaState.scenes &&
|
||
window.AKSRTCaptchaState.scenes.comment;
|
||
|
||
if (captchaScene && typeof captchaScene.verify === 'function') {
|
||
// 有验证码:先触发验证流程
|
||
setLoading(true);
|
||
|
||
captchaScene.verify(function (verified) {
|
||
if (verified !== false) {
|
||
// 验证通过,执行 AJAX 提交
|
||
performSubmit();
|
||
} else {
|
||
// 验证失败
|
||
notyf('人机验证未通过,请重试', 'warning');
|
||
setLoading(false);
|
||
}
|
||
});
|
||
} else {
|
||
// 无验证码或已经验证过:直接提交
|
||
performSubmit();
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
// 绑定表单提交事件(使用捕获阶段,高优先级)
|
||
form.addEventListener('submit', handleSubmit, true);
|
||
}
|
||
|
||
|
||
function getCommentsRestBase() {
|
||
var root = (window.aksrtData && aksrtData.siteUrl) ? String(aksrtData.siteUrl).replace(/\/$/, "") : "";
|
||
return root + "/wp-json/aksrt/v1";
|
||
}
|
||
|
||
function getCurrentCommentPostId() {
|
||
var input = document.querySelector('input[name="comment_post_ID"]');
|
||
if (input && input.value) return parseInt(input.value, 10) || 0;
|
||
var comments = document.getElementById("comments");
|
||
if (comments && comments.dataset.postId) return parseInt(comments.dataset.postId, 10) || 0;
|
||
return 0;
|
||
}
|
||
|
||
function getCurrentCommentOrder() {
|
||
var active = document.querySelector("#comments .comment-order-box li.active .comment-orderby");
|
||
if (active && active.dataset && active.dataset.order) return active.dataset.order;
|
||
var url = new URL(window.location.href);
|
||
return url.searchParams.get("aksrt_comment_order") || "newest";
|
||
}
|
||
|
||
function getCurrentAuthorOnly() {
|
||
var btn = document.querySelector("#comments .btn-only-author");
|
||
return !!(btn && btn.classList.contains("active") && btn.dataset.authorOnly === "0");
|
||
}
|
||
|
||
/* ====== 全局无参数加载:评论状态仅保存在客户端,地址栏不携带 ? 参数 ====== */
|
||
var COMMENT_URL_PARAMS = ["cpage", "aksrt_comment_order", "aksrt_author_only"];
|
||
var commentUrlStateCleaned = false;
|
||
|
||
function stripCommentUrlParams() {
|
||
if (commentUrlStateCleaned || !window.history || typeof window.history.replaceState !== "function") return;
|
||
commentUrlStateCleaned = true;
|
||
var url = new URL(window.location.href);
|
||
var changed = false;
|
||
COMMENT_URL_PARAMS.forEach(function (key) {
|
||
if (url.searchParams.has(key)) {
|
||
url.searchParams.delete(key);
|
||
changed = true;
|
||
}
|
||
});
|
||
if (changed) {
|
||
// 服务端首屏已按参数渲染完毕,落地后地址栏回到无参干净链接。
|
||
window.history.replaceState(null, "", url.toString());
|
||
}
|
||
}
|
||
|
||
function getMaxCommentPages() {
|
||
var pagenav = document.querySelector("#comments .pagenav[data-max-pages]");
|
||
if (pagenav) {
|
||
var max = parseInt(pagenav.dataset.maxPages, 10);
|
||
if (max > 0) return max;
|
||
}
|
||
var jumpInput = document.querySelector("#comments .jump-input[max]");
|
||
if (jumpInput) {
|
||
var maxAttr = parseInt(jumpInput.getAttribute("max"), 10);
|
||
if (maxAttr > 0) return maxAttr;
|
||
}
|
||
return 1;
|
||
}
|
||
|
||
function parseCommentPageFromHref(href) {
|
||
if (!href || href === "#" || href.indexOf("javascript:") === 0) return 0;
|
||
try {
|
||
var url = new URL(href, window.location.href);
|
||
var cpage = parseInt(url.searchParams.get("cpage"), 10);
|
||
if (cpage > 0) return cpage;
|
||
var match = url.pathname.match(/\/comment-page-([0-9]{1,})\/?$/);
|
||
return match ? parseInt(match[1], 10) : 0;
|
||
} catch (e) {
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
function scrollCommentsIntoView() {
|
||
var commentsArea = document.getElementById("comments");
|
||
if (!commentsArea || typeof commentsArea.scrollIntoView !== "function") return;
|
||
var rect = commentsArea.getBoundingClientRect();
|
||
if (rect.top >= 0 && rect.top < window.innerHeight * 0.6) return;
|
||
commentsArea.scrollIntoView({ behavior: "smooth", block: "start" });
|
||
}
|
||
|
||
function loadCommentPage(page, opts) {
|
||
opts = opts || {};
|
||
var commentsArea = document.getElementById("comments");
|
||
if (!commentsArea) {
|
||
return Promise.reject(new Error("comments area missing"));
|
||
}
|
||
var maxPages = getMaxCommentPages();
|
||
page = parseInt(page, 10) || 1;
|
||
page = Math.max(1, page);
|
||
if (maxPages > 1) page = Math.min(page, maxPages);
|
||
|
||
showListLoading(commentsArea);
|
||
return fetchCommentFragment({
|
||
order: getCurrentCommentOrder(),
|
||
authorOnly: getCurrentAuthorOnly(),
|
||
page: page
|
||
}).then(function (json) {
|
||
if (json && json.success && json.data) {
|
||
applyFragmentPayload(commentsArea, json.data);
|
||
if (!opts.noScroll) scrollCommentsIntoView();
|
||
return true;
|
||
}
|
||
throw new Error("comment fragment failed");
|
||
});
|
||
}
|
||
|
||
function applyFragmentPayload(commentsArea, data) {
|
||
if (!commentsArea || !data || !data.html) return;
|
||
|
||
// data.html 是完整的 <div id="postcomments">(含筛选、列表、分页)
|
||
var tempList = document.createElement("div");
|
||
tempList.innerHTML = data.html;
|
||
var newListWrap = tempList.querySelector("#postcomments");
|
||
if (!newListWrap) return;
|
||
|
||
var currentListWrap = commentsArea.querySelector("#postcomments");
|
||
if (currentListWrap) {
|
||
currentListWrap.replaceWith(newListWrap);
|
||
} else {
|
||
commentsArea.appendChild(newListWrap);
|
||
}
|
||
|
||
var currentCount = commentsArea.querySelector(".title-theme small");
|
||
if (currentCount && data.count_text) currentCount.textContent = data.count_text;
|
||
|
||
if (window.AksrtFrontend) AksrtFrontend.rehydrate(commentsArea, "ajax");
|
||
}
|
||
|
||
function fetchCommentFragment(opts) {
|
||
opts = opts || {};
|
||
var postId = opts.postId || getCurrentCommentPostId();
|
||
if (!postId) return Promise.reject(new Error("missing post id"));
|
||
var order = opts.order || getCurrentCommentOrder() || "newest";
|
||
var authorOnly = !!opts.authorOnly;
|
||
var page = opts.page || 1;
|
||
var qs = new URLSearchParams();
|
||
qs.set("post_id", String(postId));
|
||
qs.set("order", order);
|
||
qs.set("page", String(page));
|
||
if (authorOnly) qs.set("author_only", "1");
|
||
var url = getCommentsRestBase() + "/comment/list?" + qs.toString();
|
||
return fetch(url, {
|
||
method: "GET",
|
||
credentials: "same-origin",
|
||
headers: {
|
||
"X-WP-Nonce": (window.aksrtData && aksrtData.restNonce) || ""
|
||
}
|
||
}).then(function (r) { return r.json(); });
|
||
}
|
||
|
||
/* ====== 评论列表动态刷新 ====== */
|
||
function showListLoading(commentsArea) {
|
||
var list = commentsArea.querySelector(".commentlist");
|
||
if (!list) return;
|
||
// 保留筛选栏,清空条目并显示 legacy 骨架
|
||
var filter = list.querySelector(".comment-filter");
|
||
var loader = list.querySelector(".post_ajax_loader");
|
||
var skeleton = loader ? loader.cloneNode(true) : null;
|
||
Array.prototype.slice.call(list.children).forEach(function (child) {
|
||
if (child !== filter && child !== loader) child.remove();
|
||
});
|
||
if (skeleton) {
|
||
skeleton.style.display = "block";
|
||
skeleton.removeAttribute("hidden");
|
||
list.appendChild(skeleton);
|
||
}
|
||
}
|
||
|
||
function reloadCommentList() {
|
||
loadCommentPage(1, { noScroll: true }).catch(function (error) {
|
||
console.error('[AKSRT Comment] 刷新评论列表失败:', error);
|
||
window.location.reload();
|
||
});
|
||
}
|
||
|
||
/* ====== 评论排序(最新 / 最早) ====== */
|
||
/**
|
||
* Locate #id within a rehydrate root.
|
||
* Document has getElementById; Element roots (AJAX panels) only have querySelector.
|
||
*/
|
||
function findInScope(scope, id) {
|
||
scope = scope || document;
|
||
if (!scope) return null;
|
||
if (scope.nodeType === 9) {
|
||
return scope.getElementById(id);
|
||
}
|
||
if (scope.nodeType === 1) {
|
||
if (scope.id === id) return scope;
|
||
return typeof scope.querySelector === "function"
|
||
? scope.querySelector("#" + id)
|
||
: null;
|
||
}
|
||
return null;
|
||
}
|
||
|
||
function initCommentOrder(root) {
|
||
var scope = root || document;
|
||
var commentsArea = findInScope(scope, "comments");
|
||
if (!commentsArea) return;
|
||
// Event delegation survives filter HTML replacement after AJAX rehydrate.
|
||
if (commentsArea.dataset.orderInit === "1") return;
|
||
commentsArea.dataset.orderInit = "1";
|
||
|
||
function renderLoadingState() {
|
||
showListLoading(commentsArea);
|
||
}
|
||
function applyCommentOrder(order) {
|
||
if (order !== "newest" && order !== "oldest" && order !== "hottest") {
|
||
order = "newest";
|
||
}
|
||
renderLoadingState();
|
||
var authorOnly = getCurrentAuthorOnly();
|
||
|
||
fetchCommentFragment({ order: order, authorOnly: authorOnly, page: 1 })
|
||
.then(function (json) {
|
||
if (json && json.success && json.data) {
|
||
applyFragmentPayload(commentsArea, json.data);
|
||
return;
|
||
}
|
||
throw new Error("order fragment failed");
|
||
})
|
||
.catch(function (error) {
|
||
console.error("[AKSRT Comment] 排序刷新失败:", error);
|
||
// 兜底整页刷新,地址栏保持无参。
|
||
window.location.reload();
|
||
});
|
||
}
|
||
|
||
function applyAuthorFilter(authorOnlyFlag) {
|
||
renderLoadingState();
|
||
var authorOnly = authorOnlyFlag === "1" || authorOnlyFlag === 1 || authorOnlyFlag === true;
|
||
var order = getCurrentCommentOrder();
|
||
|
||
fetchCommentFragment({ order: order, authorOnly: authorOnly, page: 1 })
|
||
.then(function (json) {
|
||
if (json && json.success && json.data) {
|
||
applyFragmentPayload(commentsArea, json.data);
|
||
return;
|
||
}
|
||
throw new Error("author fragment failed");
|
||
})
|
||
.catch(function (error) {
|
||
console.error("[AKSRT Comment] Author filter failed:", error);
|
||
// 兜底整页刷新,地址栏保持无参。
|
||
window.location.reload();
|
||
});
|
||
}
|
||
|
||
commentsArea.addEventListener("click", function (e) {
|
||
var target = e.target;
|
||
if (!target || typeof target.closest !== "function") return;
|
||
|
||
// 「只看作者」同时带 comment-orderby,需优先于排序按钮判断
|
||
var authorBtn = target.closest(".btn-only-author");
|
||
if (authorBtn && commentsArea.contains(authorBtn)) {
|
||
e.preventDefault();
|
||
applyAuthorFilter(authorBtn.getAttribute("data-author-only") || "0");
|
||
return;
|
||
}
|
||
|
||
var orderBtn = target.closest(".comment-orderby[data-order]");
|
||
if (orderBtn && commentsArea.contains(orderBtn)) {
|
||
e.preventDefault();
|
||
applyCommentOrder(orderBtn.getAttribute("data-order") || "newest");
|
||
return;
|
||
}
|
||
|
||
// 数字分页:本地 DOM 刷新,地址栏不携带参数(href 仅作无 JS 兜底)。
|
||
var pageLink = target.closest(".pagenav a.page-numbers");
|
||
if (pageLink && commentsArea.contains(pageLink) && !pageLink.classList.contains("pag-jump")) {
|
||
var page = parseCommentPageFromHref(pageLink.getAttribute("href"));
|
||
if (page > 0) {
|
||
e.preventDefault();
|
||
loadCommentPage(page).catch(function (error) {
|
||
console.error("[AKSRT Comment] 分页刷新失败:", error);
|
||
// AJAX 不可用时退回原始链接(pretty 链接本身无 ? 参数)。
|
||
window.location.href = pageLink.href;
|
||
});
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
/* ====== 数字分页跳页(legacy pag-jump) ====== */
|
||
function jumpToCommentPage(page) {
|
||
loadCommentPage(page).catch(function (error) {
|
||
console.error("[AKSRT Comment] 跳页失败:", error);
|
||
window.location.reload();
|
||
});
|
||
}
|
||
|
||
function initCommentPageJump() {
|
||
document.addEventListener("click", function (e) {
|
||
var jump = e.target.closest ? e.target.closest("#comments .pag-jump") : null;
|
||
if (!jump) return;
|
||
e.preventDefault();
|
||
var input = jump.querySelector(".jump-input");
|
||
if (input) jumpToCommentPage(input.value);
|
||
});
|
||
document.addEventListener("keydown", function (e) {
|
||
if (e.key !== "Enter") return;
|
||
var input = e.target;
|
||
if (!input || !input.classList || !input.classList.contains("jump-input")) return;
|
||
if (!input.closest("#comments .pagenav")) return;
|
||
e.preventDefault();
|
||
jumpToCommentPage(input.value);
|
||
});
|
||
}
|
||
|
||
window.AksrtFrontend.register("aksrt-comment-system", function () {
|
||
stripCommentUrlParams();
|
||
initCommentSystem();
|
||
initCommentPageJump();
|
||
});
|
||
window.AksrtFrontend.register("aksrt-comment-order", function (root) { initCommentOrder(root); });
|
||
|
||
// 供 pagination.js 等模块复用:评论页码加载 / 列表刷新(局部 DOM,无 ? 参数)。
|
||
window.AksrtComments = {
|
||
loadPage: function (page, opts) { return loadCommentPage(page, opts); },
|
||
reload: function () { reloadCommentList(); }
|
||
};
|
||
})();
|
||
;
|
||
|
||
/* source: assets/js/core/comment-fixed-input.js */
|
||
/**
|
||
* Mobile FixedInput + autoheight for comment respond (legacy parity).
|
||
*/
|
||
(function () {
|
||
'use strict';
|
||
|
||
function $(sel, root) {
|
||
return (root || document).querySelector(sel);
|
||
}
|
||
|
||
function FixedInput(el, action) {
|
||
if (!el) return;
|
||
if (!el.dataset.fixedBound) {
|
||
el.addEventListener('click', function (e) {
|
||
if (e.target && e.target.closest && e.target.closest('.fixed-body')) {
|
||
FixedInput(el, 'hide');
|
||
}
|
||
});
|
||
el.dataset.fixedBound = '1';
|
||
}
|
||
if (action === 'show') {
|
||
el.classList.add('show');
|
||
window.setTimeout(function () {
|
||
var field = el.querySelector('textarea, input');
|
||
if (field) field.focus();
|
||
}, 100);
|
||
return;
|
||
}
|
||
if (action === 'hide') {
|
||
var cancel = el.querySelector('#cancel-comment-reply-link');
|
||
if (cancel) cancel.click();
|
||
el.querySelectorAll('input,textarea').forEach(function (n) {
|
||
try { n.blur(); } catch (e) {}
|
||
});
|
||
el.querySelectorAll('.dropup.open, .open').forEach(function (n) {
|
||
n.classList.remove('open');
|
||
});
|
||
el.classList.remove('show');
|
||
}
|
||
}
|
||
|
||
document.addEventListener('click', function (e) {
|
||
var trigger = e.target && e.target.closest ? e.target.closest('[fixed-input]') : null;
|
||
if (!trigger) return;
|
||
e.preventDefault();
|
||
var targetSel = trigger.getAttribute('fixed-input') || '#respond';
|
||
var panel = document.querySelector(targetSel);
|
||
var comments = document.getElementById('comments');
|
||
if (comments && comments.scrollIntoView) {
|
||
comments.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||
}
|
||
FixedInput(panel, 'show');
|
||
});
|
||
|
||
// Autoheight textareas.
|
||
function bindAutoheight(ta) {
|
||
if (!ta || ta.dataset.autoheightBound) return;
|
||
ta.dataset.autoheightBound = '1';
|
||
var max = parseInt(ta.getAttribute('maxheight') || '188', 10) || 188;
|
||
var resize = function () {
|
||
ta.style.height = 'auto';
|
||
var h = Math.min(ta.scrollHeight, max);
|
||
ta.style.height = h + 'px';
|
||
ta.style.overflowY = ta.scrollHeight > max ? 'auto' : 'hidden';
|
||
};
|
||
ta.addEventListener('input', resize);
|
||
resize();
|
||
}
|
||
|
||
function scan() {
|
||
document.querySelectorAll('textarea[autoheight], textarea.grin').forEach(bindAutoheight);
|
||
}
|
||
|
||
document.addEventListener('DOMContentLoaded', scan);
|
||
if (window.AksrtFrontend && typeof window.AksrtFrontend.register === 'function') {
|
||
window.AksrtFrontend.register('aksrt-comment-fixed-input', function (root) {
|
||
scan();
|
||
// Expose for submit hide.
|
||
root = root || document;
|
||
var respond = root.querySelector ? root.querySelector('#respond') : document.getElementById('respond');
|
||
if (respond) {
|
||
respond.aksrtFixedInput = function (action) {
|
||
FixedInput(respond, action);
|
||
};
|
||
}
|
||
});
|
||
}
|
||
|
||
window.AksrtFixedInput = FixedInput;
|
||
})();
|
||
;
|
||
|
||
/* source: assets/js/core/comment-move-form.js */
|
||
/**
|
||
* Comment moveForm for reply/edit (legacy parity) — REST-backed edit fetch.
|
||
*/
|
||
(function () {
|
||
'use strict';
|
||
|
||
var respondId = 'respond';
|
||
var tempId = 'aksrt-wp-temp-form-div';
|
||
var editingId = 0;
|
||
|
||
function getRespond() {
|
||
return document.getElementById(respondId);
|
||
}
|
||
|
||
function restRoot() {
|
||
var d = window.aksrtData || {};
|
||
return (d.restUrl || d.rest_url || '/wp-json/aksrt/v1').replace(/\/$/, '');
|
||
}
|
||
|
||
function nonce() {
|
||
var d = window.aksrtData || {};
|
||
return d.restNonce || d.nonce || '';
|
||
}
|
||
|
||
function setActionText(text) {
|
||
var el = document.querySelector('#' + respondId + ' .action-text');
|
||
if (!el) return;
|
||
if (text) {
|
||
el.style.display = '';
|
||
el.textContent = text;
|
||
} else {
|
||
el.style.display = 'none';
|
||
el.textContent = '';
|
||
}
|
||
}
|
||
|
||
function ensureParentField(respond) {
|
||
var form = respond.querySelector('#commentform') || respond;
|
||
var parent = form.querySelector('[name="comment_parent"]');
|
||
if (!parent) {
|
||
parent = document.createElement('input');
|
||
parent.type = 'hidden';
|
||
parent.name = 'comment_parent';
|
||
parent.id = 'comment_parent';
|
||
parent.value = '0';
|
||
form.appendChild(parent);
|
||
}
|
||
return parent;
|
||
}
|
||
|
||
function ensureEditField(respond, commentId) {
|
||
var form = respond.querySelector('#commentform') || respond;
|
||
var existing = form.querySelector('[name="edit_comment_ID"]');
|
||
if (commentId) {
|
||
if (!existing) {
|
||
existing = document.createElement('input');
|
||
existing.type = 'hidden';
|
||
existing.name = 'edit_comment_ID';
|
||
existing.id = 'edit_comment_ID';
|
||
form.appendChild(existing);
|
||
}
|
||
existing.value = String(commentId);
|
||
// Hide parent while editing.
|
||
var parent = form.querySelector('[name="comment_parent"]');
|
||
if (parent) parent.name = 'comment_parent_bak';
|
||
} else if (existing) {
|
||
existing.remove();
|
||
var bak = form.querySelector('[name="comment_parent_bak"]');
|
||
if (bak) bak.name = 'comment_parent';
|
||
}
|
||
}
|
||
|
||
function moveForm(commId, parentId, isEdit) {
|
||
var respond = getRespond();
|
||
if (!respond) return false;
|
||
var comm = document.getElementById(commId);
|
||
var parent = ensureParentField(respond);
|
||
var cancel = document.getElementById('cancel-comment-reply-link');
|
||
var submit = respond.querySelector('#submit');
|
||
var textarea = respond.querySelector('#comment');
|
||
|
||
if (!document.getElementById(tempId)) {
|
||
var temp = document.createElement('div');
|
||
temp.id = tempId;
|
||
temp.style.display = 'none';
|
||
respond.parentNode.insertBefore(temp, respond);
|
||
}
|
||
|
||
if (comm && comm.parentNode) {
|
||
comm.parentNode.insertBefore(respond, comm.nextSibling);
|
||
}
|
||
|
||
parent.value = isEdit ? '0' : String(parentId || '0');
|
||
editingId = isEdit ? parseInt(parentId, 10) || 0 : 0;
|
||
|
||
if (cancel) {
|
||
cancel.style.display = '';
|
||
cancel.onclick = function () {
|
||
var t = document.getElementById(tempId);
|
||
var r = getRespond();
|
||
if (t && r && t.parentNode) {
|
||
t.parentNode.insertBefore(r, t);
|
||
t.parentNode.removeChild(t);
|
||
}
|
||
ensureEditField(r, 0);
|
||
if (parent) parent.value = '0';
|
||
setActionText('');
|
||
if (textarea) textarea.value = '';
|
||
editingId = 0;
|
||
cancel.style.display = 'none';
|
||
if (window.AksrtFixedInput) window.AksrtFixedInput(r, 'hide');
|
||
else if (r) r.classList.remove('show');
|
||
return false;
|
||
};
|
||
}
|
||
|
||
if (isEdit && editingId) {
|
||
setActionText('编辑评论');
|
||
ensureEditField(respond, editingId);
|
||
if (textarea) {
|
||
textarea.disabled = true;
|
||
textarea.value = '加载中…';
|
||
}
|
||
if (submit) submit.disabled = true;
|
||
fetch(restRoot() + '/comment/get?comment_id=' + encodeURIComponent(String(editingId)), {
|
||
headers: { 'X-WP-Nonce': nonce() },
|
||
credentials: 'same-origin',
|
||
})
|
||
.then(function (r) { return r.json(); })
|
||
.then(function (json) {
|
||
var content = (json && (json.content || (json.data && json.data.content))) || '';
|
||
if (textarea) {
|
||
textarea.disabled = false;
|
||
textarea.value = content;
|
||
textarea.dispatchEvent(new Event('input'));
|
||
}
|
||
if (submit) submit.disabled = false;
|
||
})
|
||
.catch(function () {
|
||
notyf('加载评论失败', 'danger');
|
||
if (textarea) {
|
||
textarea.disabled = false;
|
||
textarea.value = '';
|
||
}
|
||
if (submit) submit.disabled = false;
|
||
});
|
||
} else {
|
||
var nameEl = comm ? comm.querySelector('.comment-header name') : null;
|
||
var author = nameEl ? (nameEl.textContent || '').trim() : '';
|
||
setActionText(author ? ('回复 @' + author) : '回复评论');
|
||
ensureEditField(respond, 0);
|
||
if (textarea) {
|
||
textarea.focus();
|
||
}
|
||
}
|
||
|
||
if (window.AksrtFixedInput) {
|
||
window.AksrtFixedInput(respond, 'show');
|
||
} else {
|
||
respond.classList.add('show');
|
||
}
|
||
|
||
if (comm && comm.scrollIntoView) {
|
||
comm.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||
}
|
||
return false;
|
||
}
|
||
|
||
document.addEventListener('click', function (e) {
|
||
var reply = e.target && e.target.closest ? e.target.closest('.comment-reply-link') : null;
|
||
var edit = e.target && e.target.closest ? e.target.closest('.comment-edit-link, [data-comment-action="edit"]') : null;
|
||
if (reply) {
|
||
e.preventDefault();
|
||
var cid = reply.getAttribute('data-commentid') || reply.getAttribute('data-comment-id') || '';
|
||
var postid = reply.getAttribute('data-postid') || '';
|
||
if (!cid) {
|
||
var li = reply.closest('[data-comment-id], #comment-' + (cid || ''));
|
||
if (li && li.getAttribute('data-comment-id')) cid = li.getAttribute('data-comment-id');
|
||
}
|
||
if (!cid) {
|
||
var m = (reply.closest('li[id^="comment-"]') || {}).id || '';
|
||
var mm = /comment-(\d+)/.exec(m);
|
||
if (mm) cid = mm[1];
|
||
}
|
||
moveForm('div-comment-' + cid, cid, false);
|
||
return;
|
||
}
|
||
if (edit) {
|
||
e.preventDefault();
|
||
var eid = edit.getAttribute('data-commentid') || edit.getAttribute('data-comment-id') || '';
|
||
if (!eid) {
|
||
var row = edit.closest('[data-comment-id]');
|
||
if (row) eid = row.getAttribute('data-comment-id');
|
||
}
|
||
if (!eid) return;
|
||
moveForm('div-comment-' + eid, eid, true);
|
||
}
|
||
});
|
||
|
||
// Dropup / dropdown toggles (guest info, expand toolbar, action menu).
|
||
document.addEventListener('click', function (e) {
|
||
var t = e.target && e.target.closest ? e.target.closest('[data-toggle-class="open"], span.dropup > a.but, [data-toggle="dropdown"]') : null;
|
||
if (!t) return;
|
||
var wrap = t.closest('span.dropup, span.dropdown');
|
||
if (!wrap) return;
|
||
// 点击已在打开的下拉内部(表情/快捷项等)不切换
|
||
if (wrap.classList.contains('open') && t.parentElement !== wrap) return;
|
||
e.preventDefault();
|
||
wrap.classList.toggle('open');
|
||
});
|
||
|
||
// Close dropups on outside click.
|
||
document.addEventListener('click', function (e) {
|
||
if (e.target.closest && e.target.closest('span.dropup.open, span.dropdown.open')) return;
|
||
document.querySelectorAll('span.dropup.open, span.dropdown.open').forEach(function (n) {
|
||
n.classList.remove('open');
|
||
});
|
||
});
|
||
|
||
// Scroll helper for @parent.
|
||
document.addEventListener('click', function (e) {
|
||
var a = e.target && e.target.closest ? e.target.closest('[data-scroll-to]') : null;
|
||
if (!a) return;
|
||
e.preventDefault();
|
||
var sel = a.getAttribute('data-scroll-to');
|
||
var el = sel ? document.querySelector(sel) : null;
|
||
if (el) el.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||
});
|
||
|
||
window.aksrtCommentMoveForm = moveForm;
|
||
window.aksrtGetEditingCommentId = function () { return editingId; };
|
||
})();
|
||
;
|
||
|
||
/* source: assets/js/core/ajax-list.js */
|
||
/**
|
||
* AKSRT Ajax List Engine — legacy .ajax-next / ajax-replace / route parity.
|
||
*
|
||
* DOM contract:
|
||
* .ajaxpager list container
|
||
* .ajax-item replace/append unit
|
||
* .ajax-pag .next-page.ajax-next paginate control
|
||
* ajax-replace="true" replace mode
|
||
* route / route-title history + document.title
|
||
* [win-ajax-replace] partial header sync from response HTML
|
||
*
|
||
* Transport:
|
||
* - Prefer data-aksrt-ajax-url JSON { html, header_html, paginate_html, title }
|
||
* - Else fetch href as HTML fragment and parse .ajaxpager / .ajax-item
|
||
*
|
||
* Events: post_ajax.before / post_ajax.ed on container (bubbles).
|
||
*
|
||
* @package AKSRT
|
||
*/
|
||
(function (window, document) {
|
||
"use strict";
|
||
|
||
var loadingMap = new WeakMap();
|
||
|
||
function restHeaders() {
|
||
var h = { Accept: "application/json, text/html", "X-AKSRT-Ajax": "list" };
|
||
if (window.aksrtData && aksrtData.restNonce) {
|
||
h["X-WP-Nonce"] = aksrtData.restNonce;
|
||
}
|
||
return h;
|
||
}
|
||
|
||
function closestPager(el) {
|
||
if (!el) return null;
|
||
return (
|
||
el.closest(".ajaxpager") ||
|
||
el.closest("[data-aksrt-ajaxpager]") ||
|
||
el.closest(".aksrt-ajaxpager")
|
||
);
|
||
}
|
||
|
||
function dispatch(container, name, detail) {
|
||
if (!container) return;
|
||
try {
|
||
container.dispatchEvent(
|
||
new CustomEvent(name, { bubbles: true, detail: detail || {} })
|
||
);
|
||
} catch (err) {}
|
||
}
|
||
|
||
function showLoader(container) {
|
||
if (!container) return;
|
||
var loader = container.querySelector(".post_ajax_loader, .post-ajax-loader, [data-aksrt-ajax-loader]");
|
||
if (loader) {
|
||
loader.classList.add("is-loading");
|
||
loader.hidden = false;
|
||
loader.style.display = "";
|
||
return;
|
||
}
|
||
container.classList.add("is-ajax-loading");
|
||
}
|
||
|
||
function hideLoader(container) {
|
||
if (!container) return;
|
||
var loader = container.querySelector(".post_ajax_loader, .post-ajax-loader, [data-aksrt-ajax-loader]");
|
||
if (loader) {
|
||
loader.classList.remove("is-loading");
|
||
if (loader.hasAttribute("data-aksrt-ajax-loader-hide")) {
|
||
loader.hidden = true;
|
||
loader.style.display = "none";
|
||
}
|
||
}
|
||
container.classList.remove("is-ajax-loading");
|
||
}
|
||
|
||
function parseHtml(html) {
|
||
var wrap = document.createElement("div");
|
||
wrap.innerHTML = html || "";
|
||
return wrap;
|
||
}
|
||
|
||
function extractFromHtml(html, container) {
|
||
var doc = parseHtml(html);
|
||
var pager =
|
||
doc.querySelector(".ajaxpager") ||
|
||
doc.querySelector("[data-aksrt-ajaxpager]") ||
|
||
doc.querySelector(".aksrt-ajaxpager");
|
||
var items = [];
|
||
var scope = pager || doc;
|
||
scope.querySelectorAll(".ajax-item").forEach(function (n) {
|
||
items.push(n.outerHTML);
|
||
});
|
||
if (!items.length && pager) {
|
||
items.push(pager.innerHTML);
|
||
}
|
||
var pag = scope.querySelector(".ajax-pag");
|
||
var headerBits = {};
|
||
doc.querySelectorAll("[win-ajax-replace]").forEach(function (n) {
|
||
var key = n.getAttribute("win-ajax-replace");
|
||
if (key) headerBits[key] = n.outerHTML;
|
||
});
|
||
var titleEl = doc.querySelector("title");
|
||
return {
|
||
itemsHtml: items.join(""),
|
||
paginateHtml: pag ? pag.outerHTML : "",
|
||
headerBits: headerBits,
|
||
title: titleEl ? titleEl.textContent : "",
|
||
fullHtml: pager ? pager.innerHTML : html,
|
||
};
|
||
}
|
||
|
||
function syncWinReplace(bits) {
|
||
if (!bits) return;
|
||
Object.keys(bits).forEach(function (key) {
|
||
var live = document.querySelector('[win-ajax-replace="' + key + '"]');
|
||
if (!live) return;
|
||
var tmp = document.createElement("div");
|
||
tmp.innerHTML = bits[key];
|
||
var next = tmp.firstElementChild;
|
||
if (next) live.replaceWith(next);
|
||
});
|
||
}
|
||
|
||
function applyRoute(link, title) {
|
||
if (!link) return;
|
||
var route = link.getAttribute("route") || link.getAttribute("data-route");
|
||
if (!(route === "1" || route === "true" || link.hasAttribute("route"))) return;
|
||
var href = link.getAttribute("href") || link.getAttribute("ajax-href") || "";
|
||
if (!href) return;
|
||
try {
|
||
window.history.replaceState({}, "", href);
|
||
} catch (err) {}
|
||
var rt =
|
||
title ||
|
||
link.getAttribute("route-title") ||
|
||
link.getAttribute("data-route-title") ||
|
||
"";
|
||
if (rt) {
|
||
try {
|
||
document.title = rt;
|
||
} catch (e2) {}
|
||
}
|
||
}
|
||
|
||
function replacePaginate(container, paginateHtml) {
|
||
if (!container || !paginateHtml) return;
|
||
var old = container.querySelector(".ajax-pag");
|
||
if (!old) {
|
||
container.insertAdjacentHTML("beforeend", paginateHtml);
|
||
return;
|
||
}
|
||
var tmp = document.createElement("div");
|
||
tmp.innerHTML = paginateHtml;
|
||
var next = tmp.firstElementChild;
|
||
if (next) old.replaceWith(next);
|
||
}
|
||
|
||
// Some widgets keep the rendered post grid inside an outer ajaxpager that
|
||
// also owns pagination/loading controls. Preserve that grid when replacing
|
||
// or appending AJAX items instead of flattening cards into the outer panel.
|
||
function findItemHost(container) {
|
||
if (!container || !container.children) return container;
|
||
for (var i = 0; i < container.children.length; i++) {
|
||
var child = container.children[i];
|
||
if (
|
||
child.matches &&
|
||
child.matches(".posts-row.post-grid, .aksrt-home-widget__post-grid")
|
||
) {
|
||
return child;
|
||
}
|
||
}
|
||
return container;
|
||
}
|
||
|
||
function inject(container, payload, options) {
|
||
options = options || {};
|
||
var replace = options.replace !== false;
|
||
if (!container) return;
|
||
|
||
var itemsHtml = payload.itemsHtml || payload.html || "";
|
||
var itemHost = findItemHost(container);
|
||
if (replace) {
|
||
itemHost.querySelectorAll(".ajax-item").forEach(function (n) {
|
||
n.remove();
|
||
});
|
||
// If container itself holds only items, clear non-loader children.
|
||
if (container.getAttribute("data-aksrt-ajax-clear") === "1") {
|
||
Array.prototype.slice.call(container.children).forEach(function (child) {
|
||
if (
|
||
child.classList.contains("post_ajax_loader") ||
|
||
child.classList.contains("post-ajax-loader") ||
|
||
child.hasAttribute("data-aksrt-ajax-loader") ||
|
||
child.classList.contains("ajax-pag")
|
||
) {
|
||
return;
|
||
}
|
||
child.remove();
|
||
});
|
||
}
|
||
if (itemsHtml) {
|
||
var pag = itemHost.querySelector(".ajax-pag");
|
||
if (pag) {
|
||
pag.insertAdjacentHTML("beforebegin", itemsHtml);
|
||
} else {
|
||
itemHost.insertAdjacentHTML("beforeend", itemsHtml);
|
||
}
|
||
}
|
||
} else if (itemsHtml) {
|
||
var pag2 = itemHost.querySelector(".ajax-pag");
|
||
if (pag2) {
|
||
pag2.insertAdjacentHTML("beforebegin", itemsHtml);
|
||
} else {
|
||
itemHost.insertAdjacentHTML("beforeend", itemsHtml);
|
||
}
|
||
}
|
||
|
||
if (payload.paginateHtml) {
|
||
replacePaginate(container, payload.paginateHtml);
|
||
}
|
||
if (payload.headerBits) {
|
||
syncWinReplace(payload.headerBits);
|
||
}
|
||
if (payload.headerHtml) {
|
||
var headerHost = document.querySelector(
|
||
options.headerSelector || "[data-aksrt-ajax-header]"
|
||
);
|
||
if (headerHost) headerHost.innerHTML = payload.headerHtml;
|
||
}
|
||
}
|
||
|
||
function normalizeJson(json) {
|
||
var data = json && json.data ? json.data : json;
|
||
if (!data) return null;
|
||
var html = data.html || data.list_html || "";
|
||
var itemsHtml = data.items_html || "";
|
||
if (!itemsHtml && html) {
|
||
// If html is only item nodes, use as-is; else extract.
|
||
if (html.indexOf("ajax-item") !== -1) {
|
||
var parsed = extractFromHtml("<div class='ajaxpager'>" + html + "</div>");
|
||
itemsHtml = parsed.itemsHtml || html;
|
||
} else {
|
||
itemsHtml = html;
|
||
}
|
||
}
|
||
return {
|
||
itemsHtml: itemsHtml,
|
||
html: html,
|
||
paginateHtml: data.paginate_html || data.paginateHtml || "",
|
||
headerHtml: data.header_html || data.headerHtml || "",
|
||
headerBits: data.header_bits || null,
|
||
title: data.title || "",
|
||
emptyHtml: data.empty_html || "",
|
||
hasMore: typeof data.has_more !== "undefined" ? !!data.has_more : null,
|
||
};
|
||
}
|
||
|
||
function loadFromLink(link, override) {
|
||
override = override || {};
|
||
if (!link) return Promise.resolve();
|
||
|
||
var container =
|
||
override.container ||
|
||
(link.getAttribute("ajaxpager-target")
|
||
? document.querySelector(link.getAttribute("ajaxpager-target"))
|
||
: null) ||
|
||
closestPager(link);
|
||
if (!container) {
|
||
// Fall back: parent stream list.
|
||
container = link.closest("[data-aksrt-ajax-list]");
|
||
}
|
||
if (!container) return Promise.resolve();
|
||
|
||
if (loadingMap.get(container)) return Promise.resolve();
|
||
loadingMap.set(container, true);
|
||
|
||
var replaceAttr = link.getAttribute("ajax-replace");
|
||
var replace =
|
||
typeof override.replace === "boolean"
|
||
? override.replace
|
||
: replaceAttr === "true" || replaceAttr === "1" || replaceAttr === "replace";
|
||
|
||
var href =
|
||
override.url ||
|
||
link.getAttribute("data-aksrt-ajax-url") ||
|
||
link.getAttribute("ajax-href") ||
|
||
link.getAttribute("href") ||
|
||
"";
|
||
|
||
dispatch(container, "post_ajax.before", { link: link, replace: replace, url: href });
|
||
showLoader(container);
|
||
if (replace) {
|
||
// Soft clear items while loading (keep skeleton if present).
|
||
container.querySelectorAll(".ajax-item").forEach(function (n) {
|
||
n.classList.add("is-fading");
|
||
});
|
||
}
|
||
|
||
return fetch(href, {
|
||
method: override.method || "GET",
|
||
credentials: "same-origin",
|
||
headers: restHeaders(),
|
||
})
|
||
.then(function (res) {
|
||
var type = (res.headers.get("content-type") || "").toLowerCase();
|
||
if (type.indexOf("application/json") !== -1) {
|
||
return res.json().then(function (json) {
|
||
if (!res.ok || (json && json.success === false)) {
|
||
throw new Error(
|
||
(json && (json.message || (json.data && json.data.message))) || "加载失败"
|
||
);
|
||
}
|
||
return normalizeJson(json);
|
||
});
|
||
}
|
||
return res.text().then(function (text) {
|
||
if (!res.ok) throw new Error("加载失败");
|
||
return extractFromHtml(text, container);
|
||
});
|
||
})
|
||
.then(function (payload) {
|
||
if (!payload) throw new Error("空响应");
|
||
if (replace && !payload.itemsHtml && payload.emptyHtml) {
|
||
inject(container, { itemsHtml: payload.emptyHtml, paginateHtml: payload.paginateHtml }, { replace: true });
|
||
} else {
|
||
inject(container, payload, { replace: replace });
|
||
}
|
||
applyRoute(link, payload.title);
|
||
hideLoader(container);
|
||
loadingMap.set(container, false);
|
||
dispatch(container, "post_ajax.ed", {
|
||
link: link,
|
||
replace: replace,
|
||
url: href,
|
||
payload: payload,
|
||
});
|
||
document.dispatchEvent(
|
||
new CustomEvent("aksrt:posts:rendered", {
|
||
bubbles: true,
|
||
detail: { container: container, replace: replace },
|
||
})
|
||
);
|
||
return payload;
|
||
})
|
||
.catch(function (err) {
|
||
hideLoader(container);
|
||
loadingMap.set(container, false);
|
||
container.querySelectorAll(".ajax-item.is-fading").forEach(function (n) {
|
||
n.classList.remove("is-fading");
|
||
});
|
||
notyf((err && err.message) || "加载失败", "danger");
|
||
dispatch(container, "post_ajax.error", { link: link, error: err });
|
||
throw err;
|
||
});
|
||
}
|
||
|
||
document.addEventListener("click", function (e) {
|
||
var link = e.target.closest("a.ajax-next, .ajax-next a, button.ajax-next, [data-aksrt-ajax-next]");
|
||
if (!link) return;
|
||
// Ignore if inside a component that opts out.
|
||
if (link.closest("[data-aksrt-ajax-list='off']")) return;
|
||
// The canonical pagination engine exclusively owns these controls.
|
||
if (link.closest("[data-aksrt-pagination], .aksrt-comment-pagination")) return;
|
||
|
||
var href = link.getAttribute("href") || link.getAttribute("ajax-href") || link.getAttribute("data-aksrt-ajax-url");
|
||
if (!href && !link.getAttribute("data-aksrt-ajax-url")) return;
|
||
|
||
e.preventDefault();
|
||
loadFromLink(link.tagName === "A" || link.classList.contains("ajax-next") ? link : link.closest(".ajax-next") || link);
|
||
});
|
||
|
||
window.AksrtAjaxList = {
|
||
load: loadFromLink,
|
||
inject: inject,
|
||
extractFromHtml: extractFromHtml,
|
||
closestPager: closestPager,
|
||
};
|
||
})(window, document);
|
||
;
|
||
|
||
/* source: assets/js/core/pagination.js */
|
||
/**
|
||
* AKSRT AJAX Pagination & Lazy Load
|
||
*/
|
||
(function () {
|
||
"use strict";
|
||
|
||
function hasAjaxConfig() {
|
||
return !!(window.aksrtData && aksrtData.ajaxUrl && aksrtData.nonce);
|
||
}
|
||
|
||
function initAjaxPagination(root) {
|
||
var containers = (root || document).querySelectorAll("[data-aksrt-pagination], .aksrt-comment-pagination");
|
||
if (!containers.length) return;
|
||
|
||
var triggerText = (window.aksrtData && aksrtData.ajaxTrigger) || "加载更多";
|
||
var nomoreText = (window.aksrtData && aksrtData.ajaxNomore) || "没有更多了";
|
||
var loadingText = (window.aksrtData && aksrtData.ajaxLoading) || "正在加载...";
|
||
var errorText = (window.aksrtData && aksrtData.ajaxLoadError) || "加载失败,请重试";
|
||
|
||
containers.forEach(function (container) {
|
||
if (container.dataset.aksrtPaginationBound === "1") return;
|
||
container.dataset.aksrtPaginationBound = "1";
|
||
|
||
var mode = container.dataset.mode || "load_more";
|
||
var nextPage = parseInt(container.dataset.nextPage, 10) || 2;
|
||
var maxPages = parseInt(container.dataset.maxPages, 10) || 1;
|
||
var isComment = container.classList.contains("aksrt-comment-pagination");
|
||
var postId = container.dataset.postId || "";
|
||
var commentOrder = container.dataset.commentOrder || "newest";
|
||
var loading = false;
|
||
var failed = false;
|
||
var clickTarget = container.querySelector(".next-page.ajax-next, .ias-btn") || container;
|
||
var loadMoreBtn = container.querySelector("[data-aksrt-load-more]") || clickTarget;
|
||
var indicator = container.querySelector(".post_ajax_loader");
|
||
var successfulAutoLoads = 0;
|
||
var iasMax = isComment
|
||
? ((window.aksrtData && typeof aksrtData.commentIasMax !== "undefined") ? parseInt(aksrtData.commentIasMax, 10) : 0)
|
||
: ((window.aksrtData && typeof aksrtData.iasMax !== "undefined") ? parseInt(aksrtData.iasMax, 10) : 0);
|
||
var homepagePanel = container.closest("[data-home-tab-panel]");
|
||
var target = homepagePanel || container.previousElementSibling;
|
||
if (!homepagePanel && target && target.classList && target.classList.contains("content-stream__footer")) {
|
||
target = target.previousElementSibling;
|
||
}
|
||
if (isComment) {
|
||
var commentList = container.closest("#comment-list, .commentlist, ol.commentlist") ||
|
||
document.getElementById("comment-list");
|
||
if (commentList) target = commentList;
|
||
}
|
||
if (!target && container.parentElement) {
|
||
target = container.parentElement.querySelector(".post-grid, .comment-list, .commentlist, .content-stream__list");
|
||
}
|
||
|
||
function showSkeleton() {
|
||
if (!target) return;
|
||
var loader = target.querySelector(".post-ajax-loader");
|
||
if (loader) {
|
||
loader.classList.add("is-loading");
|
||
}
|
||
}
|
||
|
||
function hideSkeleton() {
|
||
if (!target) return;
|
||
var loader = target.querySelector(".post-ajax-loader");
|
||
if (loader) {
|
||
loader.classList.remove("is-loading");
|
||
}
|
||
}
|
||
|
||
function stopInfinite(markNomore) {
|
||
container.classList.remove("ias-pending");
|
||
if (markNomore && loadMoreBtn) {
|
||
loadMoreBtn.innerHTML = nomoreText;
|
||
loadMoreBtn.classList.remove("is-loading");
|
||
loadMoreBtn.classList.add("ajax-nomore");
|
||
var nextWrap = loadMoreBtn.closest(".next-page");
|
||
if (nextWrap) nextWrap.classList.add("no-more");
|
||
loadMoreBtn.style.pointerEvents = "none";
|
||
} else if (loadMoreBtn && !loadMoreBtn.classList.contains("ajax-nomore")) {
|
||
loadMoreBtn.classList.remove("is-loading");
|
||
if (failed) {
|
||
loadMoreBtn.textContent = errorText;
|
||
} else {
|
||
loadMoreBtn.innerHTML = triggerText;
|
||
}
|
||
loadMoreBtn.style.pointerEvents = "";
|
||
}
|
||
}
|
||
|
||
function markFailed(message) {
|
||
failed = true;
|
||
stopInfinite(false);
|
||
if (loadMoreBtn) {
|
||
loadMoreBtn.textContent = message || errorText;
|
||
loadMoreBtn.classList.remove("is-loading");
|
||
loadMoreBtn.classList.remove("ajax-nomore");
|
||
loadMoreBtn.style.pointerEvents = "";
|
||
}
|
||
}
|
||
|
||
function loadNextPage(fromAuto) {
|
||
if (loading || failed || nextPage > maxPages || !target) return Promise.resolve(false);
|
||
if (!hasAjaxConfig()) {
|
||
markFailed(errorText);
|
||
return Promise.resolve(false);
|
||
}
|
||
|
||
loading = true;
|
||
if (indicator) indicator.style.display = "flex";
|
||
if (loadMoreBtn) {
|
||
loadMoreBtn.classList.add("is-loading");
|
||
loadMoreBtn.textContent = loadingText;
|
||
}
|
||
showSkeleton();
|
||
|
||
var action = isComment ? "aksrt_load_more_comments" : "aksrt_load_more_posts";
|
||
var queryContext = container.dataset.queryContext || "";
|
||
var queryVars = container.dataset.queryVars || "";
|
||
var renderConfig = container.dataset.renderConfig || "";
|
||
var body = new URLSearchParams();
|
||
body.set("action", action);
|
||
body.set("nonce", aksrtData.nonce);
|
||
body.set("page", String(nextPage));
|
||
if (queryContext) {
|
||
body.set("query_context", queryContext);
|
||
}
|
||
if (!isComment && queryVars) {
|
||
body.set("query_vars", queryVars);
|
||
}
|
||
if (!isComment && renderConfig) {
|
||
body.set("render_config", renderConfig);
|
||
}
|
||
if (isComment && postId) {
|
||
body.set("post_id", postId);
|
||
body.set("comment_order", commentOrder);
|
||
var authorOnly = container.dataset.authorOnly || "0";
|
||
if (authorOnly === "1") body.set("author_only", "1");
|
||
}
|
||
|
||
return fetch(aksrtData.ajaxUrl, {
|
||
method: "POST",
|
||
headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8" },
|
||
credentials: "same-origin",
|
||
body: body.toString(),
|
||
})
|
||
.then(function (r) {
|
||
if (!r.ok) {
|
||
throw new Error("HTTP " + r.status);
|
||
}
|
||
return r.text().then(function (text) {
|
||
try {
|
||
return JSON.parse(text);
|
||
} catch (err) {
|
||
throw new Error("Invalid JSON");
|
||
}
|
||
});
|
||
})
|
||
.then(function (res) {
|
||
if (!(res && res.success && res.data && typeof res.data.html === "string")) {
|
||
var msg = res && res.data && res.data.message ? res.data.message : errorText;
|
||
markFailed(msg);
|
||
return false;
|
||
}
|
||
|
||
var temp = document.createElement("div");
|
||
temp.innerHTML = res.data.html;
|
||
var newItems = temp.children;
|
||
while (newItems.length > 0) {
|
||
if (homepagePanel && container.parentNode === target) {
|
||
target.insertBefore(newItems[0], container);
|
||
} else if (container.parentNode === target) {
|
||
target.insertBefore(newItems[0], container);
|
||
} else {
|
||
target.appendChild(newItems[0]);
|
||
}
|
||
}
|
||
if (window.AksrtFrontend) {
|
||
AksrtFrontend.rehydrate(target, "ajax");
|
||
}
|
||
nextPage++;
|
||
container.dataset.nextPage = String(nextPage);
|
||
if (fromAuto) {
|
||
successfulAutoLoads++;
|
||
}
|
||
|
||
if (nextPage > maxPages || !res.data.has_more) {
|
||
stopInfinite(true);
|
||
if (!loadMoreBtn) {
|
||
container.innerHTML = '<span class="ajax-nomore">' + nomoreText + '</span>';
|
||
}
|
||
}
|
||
return true;
|
||
})
|
||
.catch(function () {
|
||
markFailed(errorText);
|
||
return false;
|
||
})
|
||
.finally(function () {
|
||
loading = false;
|
||
hideSkeleton();
|
||
if (indicator) indicator.style.display = "none";
|
||
if (loadMoreBtn && !loadMoreBtn.classList.contains("ajax-nomore") && !failed) {
|
||
loadMoreBtn.classList.remove("is-loading");
|
||
loadMoreBtn.innerHTML = triggerText;
|
||
if (mode === "infinite") {
|
||
var lazyTrigger = clickTarget.closest(".next-page") || clickTarget;
|
||
if (iasMax > 0 && successfulAutoLoads >= iasMax) {
|
||
container.classList.remove("ias-pending");
|
||
lazyTrigger.classList.remove("lazyload", "lazyloaded", "lazyloading");
|
||
lazyTrigger.removeAttribute("lazyload-action");
|
||
} else {
|
||
lazyTrigger.classList.remove("lazyloaded", "lazyloading");
|
||
lazyTrigger.classList.add("lazyload");
|
||
if (window.lazySizes && lazySizes.loader) {
|
||
lazySizes.loader.checkElems();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
if (loadMoreBtn) {
|
||
clickTarget.addEventListener("click", function(e) {
|
||
e.preventDefault();
|
||
if (loadMoreBtn.dataset.jumpComments === "1") {
|
||
var jumpInput = container.querySelector(".jump-input");
|
||
if (!jumpInput) return;
|
||
var targetPage = parseInt(jumpInput.value, 10) || 1;
|
||
var max = parseInt(jumpInput.dataset.maxPages || String(maxPages), 10) || maxPages;
|
||
targetPage = Math.max(1, Math.min(max, targetPage));
|
||
// 评论跳页:本地 DOM 刷新,地址栏不携带 ? 参数。
|
||
if (window.AksrtComments && typeof window.AksrtComments.loadPage === "function") {
|
||
e.preventDefault();
|
||
window.AksrtComments.loadPage(targetPage);
|
||
return;
|
||
}
|
||
window.location.hash = "comments";
|
||
window.location.reload();
|
||
return;
|
||
}
|
||
if (loadMoreBtn.dataset.jumpArchive === "1") {
|
||
var archiveJumpInput = container.querySelector(".jump-input");
|
||
if (!archiveJumpInput) return;
|
||
var archiveTargetPage = parseInt(archiveJumpInput.value, 10) || 1;
|
||
var archiveMax = parseInt(archiveJumpInput.dataset.maxPages || String(maxPages), 10) || maxPages;
|
||
archiveTargetPage = Math.max(1, Math.min(archiveMax, archiveTargetPage));
|
||
var archiveUrl = new URL(window.location.href);
|
||
archiveUrl.searchParams.set(loadMoreBtn.dataset.pageVar || "paged", String(archiveTargetPage));
|
||
window.location.href = archiveUrl.toString();
|
||
return;
|
||
}
|
||
var fromAuto = clickTarget.dataset.lazyAuto === "1";
|
||
delete clickTarget.dataset.lazyAuto;
|
||
if (fromAuto && iasMax > 0 && successfulAutoLoads >= iasMax) {
|
||
container.classList.remove("ias-pending");
|
||
return;
|
||
}
|
||
// Manual click can recover from a previous auto-load failure.
|
||
failed = false;
|
||
loadNextPage(fromAuto);
|
||
});
|
||
}
|
||
|
||
// The runtime lazySizes dispatches lazybeforeunveil natively but follows up
|
||
// with a jQuery-simulated click, which native listeners never receive.
|
||
// Route the unveil trigger through the same click pipeline.
|
||
if (container.classList.contains("lazyload") || clickTarget.classList.contains("lazyload")) {
|
||
container.addEventListener("lazybeforeunveil", function (e) {
|
||
if (e.target !== container && e.target !== clickTarget) return;
|
||
clickTarget.dataset.lazyAuto = "1";
|
||
clickTarget.click();
|
||
});
|
||
}
|
||
|
||
if (mode === "infinite") {
|
||
if ((isComment && window.aksrtData && aksrtData.commentIasAuto === false) || !hasAjaxConfig()) {
|
||
var autoTrigger = clickTarget.closest(".next-page") || clickTarget;
|
||
autoTrigger.classList.remove("lazyload");
|
||
autoTrigger.removeAttribute("lazyload-action");
|
||
return;
|
||
}
|
||
container.classList.add("ias-pending");
|
||
}
|
||
});
|
||
}
|
||
|
||
window.AksrtFrontend.register("aksrt-ajax-pagination", function (root) { initAjaxPagination(root); });
|
||
})();
|
||
;
|
||
|
||
/* source: assets/js/core/archive.js */
|
||
/**
|
||
* AKSRT Archive AJAX Filter
|
||
*/
|
||
(function () {
|
||
"use strict";
|
||
|
||
function initArchiveFilter(root) {
|
||
var scope = root || document;
|
||
var bar = scope.querySelector(".archive-filter-bar--ajax[data-ajax-archive]");
|
||
if (!bar) return;
|
||
|
||
var archiveType = bar.dataset.ajaxArchive || "category";
|
||
var termId = parseInt(bar.dataset.termId, 10) || 0;
|
||
var wrap = scope.querySelector("[data-ajax-wrap]");
|
||
if (!wrap) return;
|
||
|
||
var loading = wrap.querySelector(".archive__ajax-loading");
|
||
var REST_BASE = "/wp-json/aksrt/v1/archive/posts";
|
||
var emptyText = archiveType === "tag" ? "该标签下暂无文章" : "该分类下暂无文章";
|
||
|
||
var state = {
|
||
filter_cat: "",
|
||
filter_tag: "",
|
||
sort: "date",
|
||
page: 1
|
||
};
|
||
|
||
var activeCat = bar.querySelector("[data-filter-cat].is-active");
|
||
if (activeCat) state.filter_cat = activeCat.dataset.filterCat || "";
|
||
var activeTag = bar.querySelector("[data-filter-tag].is-active");
|
||
if (activeTag) state.filter_tag = activeTag.dataset.filterTag || "";
|
||
var activeSort = bar.querySelector("[data-filter-sort].is-active");
|
||
if (activeSort) state.sort = activeSort.dataset.filterSort || "date";
|
||
|
||
function buildUrl() {
|
||
var params = new URLSearchParams();
|
||
params.set("archive_type", archiveType);
|
||
params.set("term_id", String(termId));
|
||
if (state.filter_cat) params.set("filter_cat", state.filter_cat);
|
||
if (state.filter_tag) params.set("filter_tag", state.filter_tag);
|
||
|
||
params.set("sort", state.sort || "date");
|
||
params.set("page", String(state.page));
|
||
return REST_BASE + "?" + params.toString();
|
||
}
|
||
|
||
function updateActiveChips() {
|
||
bar.querySelectorAll("[data-filter-cat]").forEach(function (el) {
|
||
el.classList.toggle("is-active", (el.dataset.filterCat || "") === state.filter_cat);
|
||
});
|
||
bar.querySelectorAll("[data-filter-tag]").forEach(function (el) {
|
||
el.classList.toggle("is-active", (el.dataset.filterTag || "") === state.filter_tag);
|
||
});
|
||
bar.querySelectorAll("[data-filter-sort]").forEach(function (el) {
|
||
el.classList.toggle("is-active", (el.dataset.filterSort || "date") === state.sort);
|
||
});
|
||
}
|
||
|
||
function showLoading() {
|
||
if (loading) loading.classList.add("is-loading");
|
||
wrap.classList.add("is-loading");
|
||
}
|
||
|
||
function hideLoading() {
|
||
if (loading) loading.classList.remove("is-loading");
|
||
wrap.classList.remove("is-loading");
|
||
}
|
||
|
||
function rebuildEmptyState() {
|
||
var noResults = document.createElement("div");
|
||
noResults.className = "no-results content-stream__empty";
|
||
noResults.innerHTML = "<p>" + emptyText + "</p>";
|
||
wrap.appendChild(noResults);
|
||
}
|
||
|
||
function fetchPosts(pushState) {
|
||
showLoading();
|
||
fetch(buildUrl(), {
|
||
method: "GET",
|
||
headers: { Accept: "application/json" },
|
||
credentials: "same-origin"
|
||
})
|
||
.then(function (r) {
|
||
if (!r.ok) throw new Error("HTTP " + r.status);
|
||
return r.json();
|
||
})
|
||
.then(function (data) {
|
||
hideLoading();
|
||
if (data.html !== undefined) {
|
||
var children = Array.from(wrap.children);
|
||
children.forEach(function (child) {
|
||
if (child !== loading) wrap.removeChild(child);
|
||
});
|
||
if (data.html) {
|
||
var temp = document.createElement("div");
|
||
temp.innerHTML = data.html;
|
||
while (temp.firstChild) wrap.appendChild(temp.firstChild);
|
||
} else {
|
||
rebuildEmptyState();
|
||
}
|
||
if (window.AksrtFrontend) AksrtFrontend.rehydrate(wrap, "ajax");
|
||
}
|
||
if (pushState !== false) {
|
||
var url = new URL(window.location.href);
|
||
url.searchParams.delete("orderby");
|
||
url.searchParams.delete("order");
|
||
url.searchParams.delete("paged");
|
||
url.searchParams.delete("aksrt_filter_cat");
|
||
url.searchParams.delete("aksrt_filter_tag");
|
||
if (state.filter_cat) url.searchParams.set("aksrt_filter_cat", state.filter_cat);
|
||
if (state.filter_tag) url.searchParams.set("aksrt_filter_tag", state.filter_tag);
|
||
if (state.sort) url.searchParams.set("orderby", state.sort);
|
||
if (state.page > 1) url.searchParams.set("paged", String(state.page));
|
||
history.pushState({ aksrtArchive: true, state: Object.assign({}, state) }, "", url.toString());
|
||
}
|
||
})
|
||
.catch(function () {
|
||
hideLoading();
|
||
});
|
||
}
|
||
|
||
bar.addEventListener("click", function (e) {
|
||
var chip = e.target.closest("[data-filter-cat], [data-filter-tag], [data-filter-sort]");
|
||
if (!chip) return;
|
||
e.preventDefault();
|
||
|
||
var changed = false;
|
||
if (chip.dataset.filterCat !== undefined) {
|
||
var newCat = chip.dataset.filterCat;
|
||
if (newCat !== state.filter_cat) {
|
||
state.filter_cat = newCat;
|
||
changed = true;
|
||
}
|
||
}
|
||
if (chip.dataset.filterTag !== undefined) {
|
||
var newTag = chip.dataset.filterTag;
|
||
if (newTag !== state.filter_tag) {
|
||
state.filter_tag = newTag;
|
||
changed = true;
|
||
}
|
||
}
|
||
if (chip.dataset.filterSort !== undefined) {
|
||
var newSort = chip.dataset.filterSort || "date";
|
||
if (newSort !== state.sort) {
|
||
state.sort = newSort;
|
||
changed = true;
|
||
}
|
||
}
|
||
|
||
if (changed) {
|
||
state.page = 1;
|
||
updateActiveChips();
|
||
fetchPosts(true);
|
||
}
|
||
});
|
||
|
||
wrap.addEventListener("click", function (e) {
|
||
var pageLink = e.target.closest(".pagination a, .nav-links a, a.page-numbers");
|
||
if (!pageLink || !wrap.contains(pageLink)) return;
|
||
var href = pageLink.getAttribute("href");
|
||
if (!href) return;
|
||
|
||
var match = href.match(/[?&]paged=(\d+)/);
|
||
if (match) {
|
||
e.preventDefault();
|
||
state.page = parseInt(match[1], 10) || 1;
|
||
fetchPosts(true);
|
||
}
|
||
});
|
||
|
||
window.addEventListener("popstate", function (e) {
|
||
if (e.state && e.state.aksrtArchive) {
|
||
state = Object.assign(state, e.state.state);
|
||
updateActiveChips();
|
||
fetchPosts(false);
|
||
}
|
||
});
|
||
}
|
||
|
||
window.AksrtFrontend.register("aksrt-archive-filter", function (root) {
|
||
initArchiveFilter(root);
|
||
});
|
||
})();
|
||
;
|
||
|
||
/* source: assets/js/core/footer-tabbar.js */
|
||
/**
|
||
* AKSRT Footer Tabbar
|
||
*/
|
||
(function () {
|
||
"use strict";
|
||
|
||
function initFooterTabbar() {
|
||
var tabbar = document.getElementById("footer-tabbar");
|
||
if (!tabbar) return;
|
||
var addBackdrop = document.getElementById("tabbar-add-backdrop");
|
||
|
||
var ticking = false;
|
||
var scrollThreshold = 100;
|
||
var isHidden = false;
|
||
|
||
// Use body scroll bus classes from aksrt-runtime.js
|
||
function handleScrollDownHide() {
|
||
var body = document.body;
|
||
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
||
|
||
if (scrollTop > scrollThreshold) {
|
||
if (body.classList.contains("scroll-down") && !isHidden) {
|
||
// 向下滚动 - 隐藏
|
||
tabbar.classList.add("is-hidden");
|
||
isHidden = true;
|
||
} else if (body.classList.contains("scroll-up") && isHidden) {
|
||
tabbar.classList.remove("is-hidden");
|
||
isHidden = false;
|
||
}
|
||
} else {
|
||
tabbar.classList.remove("is-hidden");
|
||
isHidden = false;
|
||
}
|
||
}
|
||
|
||
// 返回顶部按钮切换
|
||
function handleOntopWrap() {
|
||
var ontopWraps = tabbar.querySelectorAll(".tabbar-ontop-wrap");
|
||
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
||
|
||
ontopWraps.forEach(function (wrap) {
|
||
if (scrollTop > scrollThreshold) {
|
||
wrap.classList.add("is-scrolled");
|
||
} else {
|
||
wrap.classList.remove("is-scrolled");
|
||
}
|
||
});
|
||
}
|
||
|
||
// 滚动事件处理
|
||
function onScroll() {
|
||
if (!ticking) {
|
||
requestAnimationFrame(function () {
|
||
if (tabbar.classList.contains("scroll-down-hide")) {
|
||
handleScrollDownHide();
|
||
}
|
||
handleOntopWrap();
|
||
ticking = false;
|
||
});
|
||
ticking = true;
|
||
}
|
||
}
|
||
|
||
window.addEventListener("scroll", onScroll, { passive: true });
|
||
|
||
function closeAddPanels() {
|
||
document.querySelectorAll(".tabbar-add-panel").forEach(function (panel) {
|
||
panel.setAttribute("hidden", "");
|
||
});
|
||
if (addBackdrop) addBackdrop.setAttribute("hidden", "");
|
||
document.body.classList.remove("tabbar-add-open");
|
||
}
|
||
|
||
function openAddPanel(panelId) {
|
||
closeAddPanels();
|
||
var panel = document.getElementById(panelId);
|
||
if (!panel) return;
|
||
panel.removeAttribute("hidden");
|
||
if (addBackdrop) addBackdrop.removeAttribute("hidden");
|
||
document.body.classList.add("tabbar-add-open");
|
||
}
|
||
|
||
if (addBackdrop) {
|
||
addBackdrop.addEventListener("click", closeAddPanels);
|
||
}
|
||
|
||
document.addEventListener("keydown", function (e) {
|
||
if (e.key === "Escape") closeAddPanels();
|
||
});
|
||
|
||
// 返回顶部点击事件 + 双击首页刷新
|
||
var homeClickTimer = null;
|
||
tabbar.addEventListener("click", function (e) {
|
||
var addBtn = e.target.closest('.tabbar-item[data-type="add"]');
|
||
if (addBtn) {
|
||
e.preventDefault();
|
||
openAddPanel(addBtn.getAttribute("data-panel-id"));
|
||
return;
|
||
}
|
||
|
||
var searchBtn = e.target.closest('.tabbar-item[data-type="search"]');
|
||
if (searchBtn) {
|
||
e.preventDefault();
|
||
if (typeof window.__aksrtOpenSearchPanel === "function") {
|
||
window.__aksrtOpenSearchPanel();
|
||
}
|
||
return;
|
||
}
|
||
|
||
var ontopBtn = e.target.closest(".tabbar-ontop-btn");
|
||
if (ontopBtn) {
|
||
e.preventDefault();
|
||
window.scrollTo({ top: 0, behavior: "smooth" });
|
||
return;
|
||
}
|
||
|
||
// 双击首页Tab刷新页面
|
||
var homeBtn = e.target.closest('.tabbar-item[data-type="home"]');
|
||
if (homeBtn && tabbar.classList.contains("has-animation")) {
|
||
if (homeClickTimer) {
|
||
clearTimeout(homeClickTimer);
|
||
homeClickTimer = null;
|
||
window.location.reload();
|
||
return;
|
||
}
|
||
homeClickTimer = setTimeout(function () {
|
||
homeClickTimer = null;
|
||
}, 350);
|
||
}
|
||
});
|
||
|
||
document.addEventListener("click", function (e) {
|
||
if (e.target.closest("[data-close-tabbar-add-panel]")) {
|
||
closeAddPanels();
|
||
}
|
||
});
|
||
}
|
||
|
||
window.AksrtFrontend.register("aksrt-footer-tabbar", function () { initFooterTabbar(); });
|
||
})();
|
||
;
|
||
|
||
/* source: assets/js/core/misc.js */
|
||
/**
|
||
* AKSRT Misc — related swiper, slide covers, hidden content
|
||
*/
|
||
(function () {
|
||
"use strict";
|
||
|
||
function renderGradientBackground(container) {
|
||
if (!container || container.dataset.aksrtGradientState || typeof window.Grade !== "function") return;
|
||
|
||
var source = container.querySelector("img");
|
||
if (!source || (!source.classList.contains("lazyloaded") && !(source.complete && source.naturalWidth > 0))) return;
|
||
|
||
container.dataset.aksrtGradientState = "loading";
|
||
window.Grade(container, null, function (result) {
|
||
var gradientData = result && result[0];
|
||
var colors = gradientData && gradientData.gradientData;
|
||
if (!gradientData || !colors || !colors[0] || !colors[1]) {
|
||
delete container.dataset.aksrtGradientState;
|
||
return;
|
||
}
|
||
|
||
var opacity = container.getAttribute("data-opacity");
|
||
var colorName = opacity ? "rgba" : "rgb";
|
||
var alpha = opacity ? "," + opacity : "";
|
||
var color1 = colorName + "(" + colors[0].rgba.slice(0, 3).join(",") + alpha + ") 10%";
|
||
var color2 = colorName + "(" + colors[1].rgba.slice(0, 3).join(",") + alpha + ") 80%";
|
||
|
||
gradientData.element.classList.add("gradient-bg-loaded");
|
||
gradientData.element.style.backgroundImage = "linear-gradient(135deg, " + color1 + ", " + color2 + ")";
|
||
container.dataset.aksrtGradientState = "loaded";
|
||
});
|
||
}
|
||
|
||
function initGradientBackgrounds(root) {
|
||
var scope = root || document;
|
||
if (scope.nodeType === 1 && scope.matches(".gradient-bg")) {
|
||
renderGradientBackground(scope);
|
||
}
|
||
scope.querySelectorAll(".gradient-bg").forEach(renderGradientBackground);
|
||
}
|
||
|
||
document.addEventListener("lazyloaded", function (event) {
|
||
if (!(event.target instanceof Element) || !event.target.matches(".gradient-bg img")) return;
|
||
renderGradientBackground(event.target.closest(".gradient-bg"));
|
||
}, true);
|
||
|
||
function initPostThumbMedia(root) {
|
||
var scope = root || document;
|
||
|
||
scope.querySelectorAll("[data-post-thumb-video]").forEach(function (box) {
|
||
if (box.dataset.aksrtThumbVideoBound === "1") return;
|
||
box.dataset.aksrtThumbVideoBound = "1";
|
||
var video = box.querySelector("video");
|
||
if (!video) return;
|
||
|
||
function loadVideo() {
|
||
if (!video.getAttribute("src") && video.dataset.src) {
|
||
video.setAttribute("src", video.dataset.src);
|
||
video.load();
|
||
}
|
||
}
|
||
|
||
function playVideo() {
|
||
loadVideo();
|
||
var result = video.play();
|
||
var postItem = box.closest(".posts-item");
|
||
if (postItem) postItem.classList.add("thumb-dplayer-playing");
|
||
if (result && typeof result.catch === "function") result.catch(function () {});
|
||
}
|
||
|
||
function pauseVideo() {
|
||
video.pause();
|
||
var postItem = box.closest(".posts-item");
|
||
if (postItem) postItem.classList.remove("thumb-dplayer-playing");
|
||
}
|
||
|
||
var item = box.closest(".item-thumbnail") || box;
|
||
item.addEventListener("mouseenter", playVideo);
|
||
item.addEventListener("mouseleave", pauseVideo);
|
||
item.addEventListener("focusin", playVideo);
|
||
item.addEventListener("focusout", pauseVideo);
|
||
});
|
||
}
|
||
|
||
window.AksrtFrontend.register("aksrt-post-thumb-media", function (root) {
|
||
initPostThumbMedia(root);
|
||
initGradientBackgrounds(root);
|
||
});
|
||
|
||
})();
|
||
|
||
(function () {
|
||
"use strict";
|
||
|
||
function initSlideCovers() {
|
||
var covers = document.querySelectorAll(".single-cover--slide");
|
||
covers.forEach(function (cover) {
|
||
var slides = cover.querySelectorAll(".single-cover__slide");
|
||
var dots = cover.querySelectorAll(".single-cover__dot");
|
||
if (slides.length < 2) return;
|
||
|
||
var current = 0;
|
||
var interval = 5000;
|
||
|
||
function goTo(idx) {
|
||
slides[current].classList.remove("is-active");
|
||
if (dots[current]) dots[current].classList.remove("is-active");
|
||
current = idx;
|
||
slides[current].classList.add("is-active");
|
||
if (dots[current]) dots[current].classList.add("is-active");
|
||
}
|
||
|
||
var timer = setInterval(function () {
|
||
goTo((current + 1) % slides.length);
|
||
}, interval);
|
||
|
||
dots.forEach(function (dot, i) {
|
||
dot.addEventListener("click", function () {
|
||
clearInterval(timer);
|
||
goTo(i);
|
||
timer = setInterval(function () {
|
||
goTo((current + 1) % slides.length);
|
||
}, interval);
|
||
});
|
||
});
|
||
});
|
||
}
|
||
|
||
if (document.readyState === "loading") {
|
||
document.addEventListener("DOMContentLoaded", initSlideCovers);
|
||
} else {
|
||
initSlideCovers();
|
||
}
|
||
})();
|
||
|
||
(function () {
|
||
"use strict";
|
||
|
||
function initHiddenContent() {
|
||
document.addEventListener("click", function (e) {
|
||
var btn = e.target.closest(".aksrt-hidden-content__submit-btn");
|
||
if (!btn) return;
|
||
|
||
e.preventDefault();
|
||
var wrapper = btn.closest(".aksrt-hidden-content--locked");
|
||
if (!wrapper) return;
|
||
|
||
var mode = wrapper.getAttribute("data-aksrt-visibility-mode");
|
||
var pid = wrapper.getAttribute("data-aksrt-visibility-pid");
|
||
var input = wrapper.querySelector(".aksrt-hidden-content__password-input");
|
||
var password = input ? input.value.trim() : "";
|
||
|
||
if (mode === "password" && !password) {
|
||
if (input) input.focus();
|
||
return;
|
||
}
|
||
|
||
var formData = new FormData();
|
||
formData.append("action", "aksrt_check_visibility");
|
||
formData.append("_nonce", (window.aksrtData && aksrtData.visibilityNonce) || "");
|
||
formData.append("mode", mode);
|
||
formData.append("pid", pid);
|
||
if (password) formData.append("password", password);
|
||
|
||
btn.disabled = true;
|
||
btn.textContent = "...";
|
||
|
||
fetch((window.aksrtData && aksrtData.ajaxUrl) || "/wp-admin/admin-ajax.php", {
|
||
method: "POST",
|
||
body: formData,
|
||
credentials: "same-origin",
|
||
})
|
||
.then(function (res) { return res.json(); })
|
||
.then(function (data) {
|
||
if (data.success) {
|
||
window.location.reload();
|
||
} else {
|
||
var msg = (data.data && data.data.message) ? data.data.message : "验证失败";
|
||
alert(msg);
|
||
btn.disabled = false;
|
||
btn.textContent = "验证";
|
||
}
|
||
})
|
||
.catch(function () {
|
||
alert("网络错误,请重试");
|
||
btn.disabled = false;
|
||
btn.textContent = "验证";
|
||
});
|
||
});
|
||
|
||
// Handle Enter key on password input
|
||
document.addEventListener("keydown", function (e) {
|
||
if (e.key === "Enter" && e.target.classList.contains("aksrt-hidden-content__password-input")) {
|
||
e.preventDefault();
|
||
var wrapper = e.target.closest(".aksrt-hidden-content--locked");
|
||
if (wrapper) {
|
||
var btn = wrapper.querySelector(".aksrt-hidden-content__submit-btn");
|
||
if (btn) btn.click();
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
if (document.readyState === "loading") {
|
||
document.addEventListener("DOMContentLoaded", initHiddenContent);
|
||
} else {
|
||
initHiddenContent();
|
||
}
|
||
})();
|
||
;
|
||
|
||
/* source: assets/js/follow.js */
|
||
/**
|
||
* AKSRT Follow — 前台关注交互
|
||
*
|
||
* @package AKSRT
|
||
*/
|
||
(function () {
|
||
'use strict';
|
||
|
||
var API_ROOT = (function () {
|
||
var data = window.aksrtData || {};
|
||
var raw = data.apiUrl || data.restUrl || data.rest_url || '/index.php?rest_route=/aksrt/v1';
|
||
return String(raw).replace(/\/$/, '');
|
||
})();
|
||
var NONCE = (window.aksrtData && window.aksrtData.restNonce) || '';
|
||
|
||
function buttonsFor(userId) {
|
||
return Array.prototype.slice.call(document.querySelectorAll('[data-aksrt-follow="' + userId + '"]'));
|
||
}
|
||
|
||
function setLoading(buttons, loading) {
|
||
buttons.forEach(function (button) {
|
||
button.disabled = loading;
|
||
button.classList.toggle('is-loading', loading);
|
||
});
|
||
}
|
||
|
||
function updateButton(button, isFollowing) {
|
||
var icon = button.querySelector('i');
|
||
var label = button.querySelector('[data-aksrt-follow-label]');
|
||
if (!label) return;
|
||
|
||
button.classList.toggle('is-following', isFollowing);
|
||
if (icon) {
|
||
icon.className = isFollowing ? 'fa fas fa-heart em09' : 'fa far fa-heart em09';
|
||
}
|
||
label.textContent = isFollowing ? '已关注' : '关注';
|
||
button.title = isFollowing ? '点击取消关注' : '关注该用户';
|
||
}
|
||
|
||
function updateFollowerCount(count) {
|
||
var countEl = document.querySelector('.aksrt-user-home__stat-value[data-followers]');
|
||
if (countEl && count !== undefined) {
|
||
countEl.textContent = count;
|
||
}
|
||
}
|
||
|
||
function initFollowButtons() {
|
||
document.addEventListener('click', function (event) {
|
||
var button = event.target.closest('[data-aksrt-follow]');
|
||
if (!button) return;
|
||
event.preventDefault();
|
||
|
||
var targetUserId = parseInt(button.getAttribute('data-aksrt-follow'), 10);
|
||
if (!targetUserId || button.disabled) return;
|
||
|
||
var matchingButtons = buttonsFor(targetUserId);
|
||
setLoading(matchingButtons, true);
|
||
|
||
fetch(API_ROOT + '/follow/toggle', {
|
||
method: 'POST',
|
||
headers: {
|
||
'Content-Type': 'application/json',
|
||
'X-WP-Nonce': NONCE,
|
||
},
|
||
body: JSON.stringify({ target_user_id: targetUserId }),
|
||
})
|
||
.then(function (response) { return response.json(); })
|
||
.then(function (result) {
|
||
if (!result.success || !result.data) {
|
||
notyf(result.message || '操作失败', 'danger');
|
||
return;
|
||
}
|
||
|
||
var isFollowing = Boolean(result.data.is_following);
|
||
matchingButtons.forEach(function (matchingButton) {
|
||
updateButton(matchingButton, isFollowing);
|
||
});
|
||
updateFollowerCount(result.data.follower_count);
|
||
|
||
if (!isFollowing) {
|
||
var managementItem = button.closest('.uc-follow-management__item');
|
||
if (managementItem) managementItem.remove();
|
||
}
|
||
notyf(isFollowing ? '关注成功' : '已取消关注', 'success');
|
||
})
|
||
.catch(function () {
|
||
notyf('网络错误,请重试', 'danger');
|
||
})
|
||
.finally(function () {
|
||
setLoading(matchingButtons, false);
|
||
});
|
||
});
|
||
}
|
||
|
||
if (document.readyState === 'loading') {
|
||
document.addEventListener('DOMContentLoaded', initFollowButtons);
|
||
} else {
|
||
initFollowButtons();
|
||
}
|
||
})();
|
||
;
|
||
|
||
/* source: assets/js/enhancements.js */
|
||
/**
|
||
* AKSRT Enhancements — 全局 UI 增强
|
||
*
|
||
* 包含:图片灯箱、滚动方向感知
|
||
*
|
||
* @package AKSRT
|
||
*/
|
||
|
||
(function () {
|
||
'use strict';
|
||
|
||
/* ============================================================
|
||
* 1. 图片灯箱 — zoom / thumbnails / slideshow / fullscreen /
|
||
* mousewheel / origin animation / smart download
|
||
* ============================================================ */
|
||
var lightboxEl = null;
|
||
var lightboxImg = null;
|
||
var lightboxCaption = null;
|
||
var lightboxCounter = null;
|
||
var lightboxThumbsWrap = null;
|
||
var currentGallery = [];
|
||
var currentIndex = 0;
|
||
var currentZoom = 1;
|
||
var autoplayTimer = null;
|
||
var isAutoplay = false;
|
||
var EXCLUDE_SEL = '.no-imgbox,.no-lightbox,.avatar,.img-icon,.avatar-badge,.aksrt-avatar';
|
||
var TRIGGER_SEL = '.entry-content img, .wp-posts-content img, .aksrt-lightbox-trigger img, [data-aksrt-lightbox] img, .imgbox-container img, .comment-content .box-img img, a[data-imgbox] img';
|
||
var CONTAINER_SEL = '.entry-content, .wp-posts-content, .aksrt-lightbox-trigger, [data-aksrt-lightbox], .imgbox-container, .comment-content';
|
||
var MAX_ZOOM_DESKTOP = 2;
|
||
var MAX_ZOOM_MOBILE = 3;
|
||
|
||
function lightboxFlag(key, fallback) {
|
||
var w = window._win || (window.aksrtData && window.aksrtData.imgbox) || {};
|
||
if (w[key] === undefined || w[key] === null || w[key] === '') return fallback;
|
||
return w[key] === true || w[key] === 1 || w[key] === '1';
|
||
}
|
||
function lightboxEnabled() {
|
||
return lightboxFlag('imgbox', true);
|
||
}
|
||
|
||
|
||
function resolveFullUrl(img) {
|
||
var full = img.getAttribute('data-full-url') || img.getAttribute('data-src') || '';
|
||
if (full) return full;
|
||
var src = img.src || '';
|
||
// thumbnail → original: strip -NNNxNNN suffix
|
||
return src.replace(/-\d+x\d+(\.[a-z]+)$/i, '$1');
|
||
}
|
||
|
||
function isNoLightbox(img) {
|
||
if (img.closest(EXCLUDE_SEL)) return true;
|
||
// parent anchor that does NOT point to an image
|
||
var parentA = img.closest('a');
|
||
if (parentA) {
|
||
var href = parentA.getAttribute('href') || '';
|
||
if (href && !/\.(jpe?g|png|gif|webp|avif|svg|bmp)(\?|$)/i.test(href) && !parentA.hasAttribute('data-imgbox')) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
function createLightbox() {
|
||
if (!lightboxEnabled()) return;
|
||
if (lightboxEl) return;
|
||
|
||
lightboxEl = document.createElement('div');
|
||
lightboxEl.className = 'aksrt-lightbox';
|
||
lightboxEl.innerHTML =
|
||
'<div class="aksrt-lightbox__toolbar">' +
|
||
'<span class="aksrt-lightbox__counter"></span>' +
|
||
'<button type="button" class="aksrt-lightbox__tool toggle-zoom" title="缩放"><i class="fa fas fa-search-plus"></i></button>' +
|
||
'<button type="button" class="aksrt-lightbox__tool toggle-thumbs" title="缩略图"><i class="fa fas fa-th"></i></button>' +
|
||
'<button type="button" class="aksrt-lightbox__tool toggle-play" title="幻灯片"><i class="fa fas fa-play"></i></button>' +
|
||
'<button type="button" class="aksrt-lightbox__tool toggle-full" title="全屏"><i class="fa fas fa-expand"></i></button>' +
|
||
'<button type="button" class="aksrt-lightbox__tool aksrt-lightbox__download" title="下载"><i class="fa fas fa-download"></i></button>' +
|
||
'<button type="button" class="aksrt-lightbox__tool aksrt-lightbox__close" title="关闭"><i class="fa fas fa-times"></i></button>' +
|
||
'</div>' +
|
||
'<button type="button" class="aksrt-lightbox__nav aksrt-lightbox__nav--prev" aria-label="上一张"><i class="fa fas fa-chevron-left"></i></button>' +
|
||
'<div class="aksrt-lightbox__stage"><img class="aksrt-lightbox__img" src="" alt=""></div>' +
|
||
'<button type="button" class="aksrt-lightbox__nav aksrt-lightbox__nav--next" aria-label="下一张"><i class="fa fas fa-chevron-right"></i></button>' +
|
||
'<div class="aksrt-lightbox__caption"></div>' +
|
||
'<div class="aksrt-lightbox__thumbs" hidden></div>';
|
||
|
||
document.body.appendChild(lightboxEl);
|
||
|
||
lightboxImg = lightboxEl.querySelector('.aksrt-lightbox__img');
|
||
lightboxCaption = lightboxEl.querySelector('.aksrt-lightbox__caption');
|
||
lightboxCounter = lightboxEl.querySelector('.aksrt-lightbox__counter');
|
||
lightboxThumbsWrap = lightboxEl.querySelector('.aksrt-lightbox__thumbs');
|
||
|
||
// Apply window._win imgbox feature flags
|
||
var zoomBtn = lightboxEl.querySelector('.toggle-zoom');
|
||
var thumbsBtn = lightboxEl.querySelector('.toggle-thumbs');
|
||
var playBtn = lightboxEl.querySelector('.toggle-play');
|
||
var fullBtn = lightboxEl.querySelector('.toggle-full');
|
||
var downBtn = lightboxEl.querySelector('.aksrt-lightbox__download');
|
||
if (zoomBtn) zoomBtn.hidden = !lightboxFlag('imgbox_zoom', true);
|
||
if (thumbsBtn) thumbsBtn.hidden = !lightboxFlag('imgbox_thumbs', true);
|
||
if (playBtn) playBtn.hidden = !lightboxFlag('imgbox_play', false);
|
||
if (fullBtn) fullBtn.hidden = !lightboxFlag('imgbox_full', true);
|
||
if (downBtn) downBtn.hidden = !lightboxFlag('imgbox_down', false);
|
||
|
||
// Close
|
||
lightboxEl.querySelector('.aksrt-lightbox__close').addEventListener('click', function (e) { e.stopPropagation(); closeLightbox(); });
|
||
lightboxEl.addEventListener('click', function (e) { if (e.target === lightboxEl || e.target.classList.contains('aksrt-lightbox__stage')) closeLightbox(); });
|
||
|
||
// Nav
|
||
lightboxEl.querySelector('.aksrt-lightbox__nav--prev').addEventListener('click', function (e) { e.stopPropagation(); navigateLightbox(-1); });
|
||
lightboxEl.querySelector('.aksrt-lightbox__nav--next').addEventListener('click', function (e) { e.stopPropagation(); navigateLightbox(1); });
|
||
|
||
// Keyboard
|
||
document.addEventListener('keydown', function (e) {
|
||
if (!lightboxEl.classList.contains('is-open')) return;
|
||
if (e.key === 'Escape') closeLightbox();
|
||
if (e.key === 'ArrowLeft') navigateLightbox(-1);
|
||
if (e.key === 'ArrowRight') navigateLightbox(1);
|
||
});
|
||
|
||
// Mousewheel nav
|
||
lightboxEl.addEventListener('wheel', function (e) {
|
||
if (!lightboxEl.classList.contains('is-open')) return;
|
||
if (currentZoom > 1) return; // don't nav when zoomed
|
||
e.preventDefault();
|
||
if (e.deltaY > 0) navigateLightbox(1);
|
||
else navigateLightbox(-1);
|
||
}, { passive: false });
|
||
|
||
// Image click → toggle zoom
|
||
lightboxImg.addEventListener('click', function (e) { e.stopPropagation(); toggleZoom(); });
|
||
|
||
// Double-click → zoom in
|
||
lightboxImg.addEventListener('dblclick', function (e) {
|
||
e.stopPropagation();
|
||
var maxZoom = window.innerWidth < 768 ? MAX_ZOOM_MOBILE : MAX_ZOOM_DESKTOP;
|
||
if (currentZoom < maxZoom) setZoom(maxZoom);
|
||
else setZoom(1);
|
||
});
|
||
|
||
// Pinch zoom (mobile)
|
||
var pinchStart = 0;
|
||
lightboxEl.addEventListener('touchstart', function (e) {
|
||
if (e.touches.length === 2) {
|
||
pinchStart = Math.hypot(
|
||
e.touches[1].clientX - e.touches[0].clientX,
|
||
e.touches[1].clientY - e.touches[0].clientY
|
||
);
|
||
}
|
||
}, { passive: true });
|
||
|
||
lightboxEl.addEventListener('touchmove', function (e) {
|
||
if (e.touches.length === 2 && pinchStart > 0) {
|
||
var dist = Math.hypot(
|
||
e.touches[1].clientX - e.touches[0].clientX,
|
||
e.touches[1].clientY - e.touches[0].clientY
|
||
);
|
||
var maxZoom = window.innerWidth < 768 ? MAX_ZOOM_MOBILE : MAX_ZOOM_DESKTOP;
|
||
var newZoom = Math.min(maxZoom, Math.max(1, currentZoom * (dist / pinchStart)));
|
||
setZoom(newZoom);
|
||
pinchStart = dist;
|
||
}
|
||
}, { passive: true });
|
||
|
||
lightboxEl.addEventListener('touchend', function () { pinchStart = 0; }, { passive: true });
|
||
|
||
// Touch swipe/pull-dismiss (skip when zoomed)
|
||
var touchStartY = 0, touchStartX = 0, isSwiping = false;
|
||
lightboxEl.addEventListener('touchstart', function (e) {
|
||
if (e.touches.length !== 1 || currentZoom > 1.05) return;
|
||
touchStartY = e.touches[0].clientY;
|
||
touchStartX = e.touches[0].clientX;
|
||
isSwiping = false;
|
||
}, { passive: true });
|
||
|
||
lightboxEl.addEventListener('touchmove', function (e) {
|
||
if (e.touches.length !== 1 || currentZoom > 1.05) return;
|
||
var dy = e.touches[0].clientY - touchStartY;
|
||
var dx = e.touches[0].clientX - touchStartX;
|
||
if (Math.abs(dy) > Math.abs(dx) && dy > 30) {
|
||
isSwiping = true;
|
||
var opacity = Math.max(0.2, (150 - dy) / 80);
|
||
lightboxImg.style.transform = 'translate3d(0, ' + dy + 'px, 0) scale(' + currentZoom + ')';
|
||
lightboxImg.style.opacity = String(Math.min(1, opacity));
|
||
}
|
||
}, { passive: true });
|
||
|
||
lightboxEl.addEventListener('touchend', function () {
|
||
if (isSwiping) {
|
||
closeLightbox();
|
||
lightboxImg.style.transform = '';
|
||
lightboxImg.style.opacity = '';
|
||
}
|
||
isSwiping = false;
|
||
}, { passive: true });
|
||
|
||
// Download
|
||
lightboxEl.querySelector('.aksrt-lightbox__download').addEventListener('click', function (e) {
|
||
e.stopPropagation();
|
||
var item = currentGallery[currentIndex];
|
||
if (!item || !item.src) return;
|
||
var a = document.createElement('a');
|
||
var fullSrc = item.fullSrc || item.src;
|
||
a.href = fullSrc;
|
||
a.download = fullSrc.substring(fullSrc.lastIndexOf('/') + 1) || 'image';
|
||
document.body.appendChild(a);
|
||
a.click();
|
||
a.remove();
|
||
});
|
||
|
||
// Zoom button
|
||
lightboxEl.querySelector('.toggle-zoom').addEventListener('click', function (e) { e.stopPropagation(); toggleZoom(); });
|
||
|
||
// Thumbnails toggle
|
||
lightboxEl.querySelector('.toggle-thumbs').addEventListener('click', function (e) {
|
||
e.stopPropagation();
|
||
lightboxThumbsWrap.hidden = !lightboxThumbsWrap.hidden;
|
||
});
|
||
|
||
// Slideshow toggle
|
||
lightboxEl.querySelector('.toggle-play').addEventListener('click', function (e) {
|
||
e.stopPropagation();
|
||
toggleAutoplay();
|
||
});
|
||
|
||
// Fullscreen
|
||
lightboxEl.querySelector('.toggle-full').addEventListener('click', function (e) {
|
||
e.stopPropagation();
|
||
toggleFullscreen();
|
||
});
|
||
|
||
document.addEventListener('fullscreenchange', function () {
|
||
var icon = lightboxEl.querySelector('.toggle-full i');
|
||
if (document.fullscreenElement) {
|
||
lightboxEl.classList.add('full-screen');
|
||
icon.className = 'fa fas fa-compress';
|
||
} else {
|
||
lightboxEl.classList.remove('full-screen');
|
||
icon.className = 'fa fas fa-expand';
|
||
}
|
||
});
|
||
}
|
||
|
||
function setZoom(z) {
|
||
currentZoom = z;
|
||
lightboxImg.style.transform = 'scale(' + z + ')';
|
||
lightboxEl.classList.toggle('is-zoomed', z > 1);
|
||
}
|
||
|
||
function toggleZoom() {
|
||
var maxZoom = window.innerWidth < 768 ? MAX_ZOOM_MOBILE : MAX_ZOOM_DESKTOP;
|
||
setZoom(currentZoom > 1 ? 1 : maxZoom);
|
||
}
|
||
|
||
function toggleAutoplay() {
|
||
var icon = lightboxEl.querySelector('.toggle-play i');
|
||
if (isAutoplay) {
|
||
clearInterval(autoplayTimer);
|
||
isAutoplay = false;
|
||
icon.className = 'fa fas fa-play';
|
||
} else {
|
||
if (currentGallery.length < 2) return;
|
||
isAutoplay = true;
|
||
icon.className = 'fa fas fa-pause';
|
||
autoplayTimer = setInterval(function () { navigateLightbox(1); }, 3000);
|
||
}
|
||
}
|
||
|
||
function toggleFullscreen() {
|
||
var rfs = lightboxEl.requestFullscreen || lightboxEl.webkitRequestFullscreen || lightboxEl.msRequestFullscreen;
|
||
if (document.fullscreenElement || document.webkitFullscreenElement) {
|
||
(document.exitFullscreen || document.webkitExitFullscreen || document.msExitFullscreen).call(document);
|
||
} else if (rfs) {
|
||
rfs.call(lightboxEl);
|
||
}
|
||
}
|
||
|
||
function buildThumbnails() {
|
||
if (!lightboxThumbsWrap) return;
|
||
lightboxThumbsWrap.innerHTML = '';
|
||
currentGallery.forEach(function (item, i) {
|
||
var thumb = document.createElement('img');
|
||
thumb.src = item.src;
|
||
thumb.className = 'aksrt-lightbox__thumb' + (i === currentIndex ? ' is-active' : '');
|
||
thumb.addEventListener('click', function (e) {
|
||
e.stopPropagation();
|
||
showLightboxImage(i);
|
||
});
|
||
lightboxThumbsWrap.appendChild(thumb);
|
||
});
|
||
}
|
||
|
||
function syncThumbActive() {
|
||
if (!lightboxThumbsWrap) return;
|
||
var thumbs = lightboxThumbsWrap.querySelectorAll('.aksrt-lightbox__thumb');
|
||
thumbs.forEach(function (t, i) { t.classList.toggle('is-active', i === currentIndex); });
|
||
var active = thumbs[currentIndex];
|
||
if (active) active.scrollIntoView({ inline: 'center', block: 'nearest', behavior: 'smooth' });
|
||
}
|
||
|
||
function openLightbox(src, caption, gallery, index, originEl) {
|
||
createLightbox();
|
||
|
||
currentGallery = gallery || [{ src: src, caption: caption || '' }];
|
||
currentIndex = index || 0;
|
||
currentZoom = 1;
|
||
|
||
// Origin animation
|
||
if (originEl) {
|
||
var rect = originEl.getBoundingClientRect();
|
||
lightboxEl.style.setProperty('--imgbox-origin-top', (rect.top + rect.height / 2) + 'px');
|
||
lightboxEl.style.setProperty('--imgbox-origin-left', (rect.left + rect.width / 2) + 'px');
|
||
lightboxEl.classList.add('from-origin');
|
||
} else {
|
||
lightboxEl.classList.remove('from-origin');
|
||
}
|
||
|
||
showLightboxImage(currentIndex);
|
||
buildThumbnails();
|
||
|
||
lightboxEl.classList.add('is-open');
|
||
document.body.style.overflow = 'hidden';
|
||
|
||
lightboxEl.dispatchEvent(new CustomEvent('aksrt:lightbox-open', { bubbles: true }));
|
||
}
|
||
|
||
function showLightboxImage(index) {
|
||
if (index < 0) index = currentGallery.length - 1;
|
||
if (index >= currentGallery.length) index = 0;
|
||
currentIndex = index;
|
||
setZoom(1);
|
||
|
||
var item = currentGallery[currentIndex];
|
||
lightboxImg.src = item.fullSrc || item.src;
|
||
lightboxImg.alt = item.caption || '';
|
||
lightboxCaption.textContent = item.caption || '';
|
||
lightboxCaption.style.display = item.caption ? '' : 'none';
|
||
|
||
if (currentGallery.length > 1) {
|
||
lightboxCounter.textContent = (currentIndex + 1) + ' / ' + currentGallery.length;
|
||
lightboxCounter.style.display = '';
|
||
} else {
|
||
lightboxCounter.style.display = 'none';
|
||
}
|
||
|
||
syncThumbActive();
|
||
}
|
||
|
||
function navigateLightbox(dir) {
|
||
showLightboxImage(currentIndex + dir);
|
||
}
|
||
|
||
function closeLightbox() {
|
||
if (!lightboxEl) return;
|
||
if (isAutoplay) toggleAutoplay();
|
||
lightboxEl.classList.remove('is-open', 'is-zoomed', 'from-origin');
|
||
document.body.style.overflow = '';
|
||
lightboxThumbsWrap.hidden = true;
|
||
if (document.fullscreenElement) {
|
||
(document.exitFullscreen || document.webkitExitFullscreen || document.msExitFullscreen).call(document);
|
||
}
|
||
}
|
||
|
||
// Auto-bind: expanded trigger scope + exclusion rules
|
||
function initLightbox() {
|
||
document.addEventListener('click', function (e) {
|
||
// Also support a[data-imgbox]
|
||
var anchor = e.target.closest('a[data-imgbox]');
|
||
if (anchor) {
|
||
e.preventDefault();
|
||
var href = anchor.getAttribute('href') || anchor.getAttribute('data-imgbox');
|
||
openLightbox(href, '', [{ src: href, fullSrc: href, caption: '' }], 0, anchor);
|
||
return;
|
||
}
|
||
|
||
var img = e.target.closest(TRIGGER_SEL);
|
||
if (!img) return;
|
||
if (img.width < 100 || img.height < 100) return;
|
||
if (!lightboxEnabled() || isNoLightbox(img)) return;
|
||
|
||
e.preventDefault();
|
||
|
||
var container = img.closest(CONTAINER_SEL);
|
||
if (!container) return;
|
||
|
||
var allImages = container.querySelectorAll('img');
|
||
var gallery = [];
|
||
var foundIndex = 0;
|
||
|
||
allImages.forEach(function (el) {
|
||
if (el.width < 100 || el.height < 100) return;
|
||
if (isNoLightbox(el)) return;
|
||
var full = resolveFullUrl(el);
|
||
var caption = el.alt || '';
|
||
var figcaption = el.closest('figure') ? el.closest('figure').querySelector('figcaption') : null;
|
||
if (figcaption) caption = figcaption.textContent;
|
||
gallery.push({ src: el.dataset.src || el.src, fullSrc: full, caption: caption });
|
||
if (el === img) foundIndex = gallery.length - 1;
|
||
});
|
||
|
||
if (gallery.length > 0) {
|
||
openLightbox(img.dataset.src || img.src, img.alt, gallery, foundIndex, img);
|
||
}
|
||
});
|
||
}
|
||
|
||
// 暴露到全局
|
||
window.AksrtLightbox = {
|
||
open: openLightbox,
|
||
close: closeLightbox,
|
||
};
|
||
|
||
/* ============================================================
|
||
* 2. 滚动方向感知
|
||
* ============================================================ */
|
||
// Scroll direction is now handled by aksrt-runtime.js body scroll bus
|
||
// (body.scroll-down / body.scroll-up / body.body-scroll).
|
||
// This stub syncs the legacy aksrt-* prefixed classes for backward compat.
|
||
function initScrollDirection() {
|
||
var body = document.body;
|
||
|
||
function sync() {
|
||
body.classList.toggle('aksrt-body-scroll', body.classList.contains('body-scroll'));
|
||
body.classList.toggle('aksrt-scroll-down', body.classList.contains('scroll-down'));
|
||
body.classList.toggle('aksrt-scroll-up', body.classList.contains('scroll-up'));
|
||
|
||
body.classList.add('aksrt-scrolling');
|
||
clearTimeout(body._aksrtScrollTimer);
|
||
body._aksrtScrollTimer = setTimeout(function () {
|
||
body.classList.remove('aksrt-scrolling');
|
||
}, 300);
|
||
}
|
||
|
||
function onScroll() {
|
||
requestAnimationFrame(sync);
|
||
}
|
||
|
||
window.addEventListener('scroll', onScroll, { passive: true });
|
||
}
|
||
|
||
/* ============================================================
|
||
* 3. 导航溢出折叠
|
||
* 由 legacy main.js 的 navFolding 负责。
|
||
* 此处不再重复实现,避免两套逻辑争抢 .aksrt-nav-more 节点
|
||
* 触发 NotFoundError: insertBefore (moreLi 已被对方 remove)。
|
||
* ============================================================ */
|
||
|
||
/* ============================================================
|
||
* 初始化入口
|
||
* ============================================================ */
|
||
document.addEventListener('DOMContentLoaded', function () {
|
||
initLightbox();
|
||
initScrollDirection();
|
||
});
|
||
|
||
})();
|
||
;
|
||
|
||
/* source: assets/js/enhancements2.js */
|
||
/**
|
||
* AKSRT Enhancements Part 2 — 高级交互组件
|
||
*
|
||
* 包含:3D 悬停倾斜、滚动触发动画、封面轮播、打赏按钮
|
||
*
|
||
* @package AKSRT
|
||
*/
|
||
|
||
(function () {
|
||
'use strict';
|
||
|
||
/* ============================================================
|
||
* 1. 3D 悬停倾斜效果 (vanilla-tilt 轻量版)
|
||
* ============================================================ */
|
||
function initTilt() {
|
||
document.querySelectorAll('[data-aksrt-tilt]').forEach(function (el) {
|
||
if (el.dataset.tiltInit) return;
|
||
el.dataset.tiltInit = '1';
|
||
|
||
var maxTilt = parseInt(el.dataset.aksrtTiltMax || '15', 10);
|
||
var perspective = parseInt(el.dataset.aksrtTiltPerspective || '1000', 10);
|
||
var scale = parseFloat(el.dataset.aksrtTiltScale || '1.03');
|
||
var speed = parseInt(el.dataset.aksrtTiltSpeed || '400', 10);
|
||
var glare = el.dataset.aksrtTiltGlare === '1';
|
||
|
||
el.style.transformStyle = 'preserve-3d';
|
||
el.style.transition = 'transform ' + speed + 'ms ease';
|
||
|
||
var glareEl = null;
|
||
if (glare) {
|
||
glareEl = document.createElement('div');
|
||
glareEl.style.cssText = 'position:absolute;inset:0;border-radius:inherit;pointer-events:none;opacity:0;transition:opacity ' + speed + 'ms;';
|
||
el.style.position = el.style.position || 'relative';
|
||
el.style.overflow = 'hidden';
|
||
el.appendChild(glareEl);
|
||
}
|
||
|
||
el.addEventListener('mousemove', function (e) {
|
||
var rect = el.getBoundingClientRect();
|
||
var x = (e.clientX - rect.left) / rect.width;
|
||
var y = (e.clientY - rect.top) / rect.height;
|
||
var tiltX = (0.5 - y) * maxTilt;
|
||
var tiltY = (x - 0.5) * maxTilt;
|
||
|
||
el.style.transform = 'perspective(' + perspective + 'px) rotateX(' + tiltX + 'deg) rotateY(' + tiltY + 'deg) scale3d(' + scale + ',' + scale + ',' + scale + ')';
|
||
|
||
if (glareEl) {
|
||
glareEl.style.opacity = '1';
|
||
glareEl.style.background = 'linear-gradient(135deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.2) 50%, rgba(255,255,255,0) 100%)';
|
||
glareEl.style.transform = 'translate(' + ((x - 0.5) * 100) + '%, ' + ((y - 0.5) * 100) + '%)';
|
||
}
|
||
});
|
||
|
||
el.addEventListener('mouseleave', function () {
|
||
el.style.transform = 'perspective(' + perspective + 'px) rotateX(0deg) rotateY(0deg) scale3d(1,1,1)';
|
||
if (glareEl) glareEl.style.opacity = '0';
|
||
});
|
||
});
|
||
}
|
||
|
||
/* ============================================================
|
||
* 2. 滚动触发动画 (IntersectionObserver)
|
||
* ============================================================ */
|
||
function initScrollAnimations() {
|
||
if (!('IntersectionObserver' in window)) {
|
||
// 不支持时直接显示所有元素
|
||
document.querySelectorAll('[data-aksrt-animate]').forEach(function (el) {
|
||
el.style.opacity = '1';
|
||
el.style.transform = 'none';
|
||
});
|
||
return;
|
||
}
|
||
|
||
var observer = new IntersectionObserver(function (entries) {
|
||
entries.forEach(function (entry) {
|
||
if (!entry.isIntersecting) return;
|
||
|
||
var el = entry.target;
|
||
var animation = el.dataset.aksrtAnimate || 'fadeInUp';
|
||
var delay = parseInt(el.dataset.aksrtAnimateDelay || '0', 10);
|
||
var duration = parseInt(el.dataset.aksrtAnimateDuration || '600', 10);
|
||
|
||
setTimeout(function () {
|
||
el.style.transition = 'opacity ' + duration + 'ms ease, transform ' + duration + 'ms ease';
|
||
el.style.opacity = '1';
|
||
el.style.transform = 'translateY(0) translateX(0) scale(1)';
|
||
el.classList.add('aksrt-animated');
|
||
}, delay);
|
||
|
||
observer.unobserve(el);
|
||
});
|
||
}, {
|
||
threshold: 0.1,
|
||
rootMargin: '0px 0px -50px 0px',
|
||
});
|
||
|
||
document.querySelectorAll('[data-aksrt-animate]').forEach(function (el) {
|
||
var animation = el.dataset.aksrtAnimate || 'fadeInUp';
|
||
|
||
// 设置初始状态
|
||
el.style.opacity = '0';
|
||
switch (animation) {
|
||
case 'fadeIn':
|
||
el.style.transform = 'none';
|
||
break;
|
||
case 'fadeInUp':
|
||
el.style.transform = 'translateY(30px)';
|
||
break;
|
||
case 'fadeInDown':
|
||
el.style.transform = 'translateY(-30px)';
|
||
break;
|
||
case 'fadeInLeft':
|
||
el.style.transform = 'translateX(-30px)';
|
||
break;
|
||
case 'fadeInRight':
|
||
el.style.transform = 'translateX(30px)';
|
||
break;
|
||
case 'zoomIn':
|
||
el.style.transform = 'scale(0.9)';
|
||
break;
|
||
default:
|
||
el.style.transform = 'translateY(30px)';
|
||
}
|
||
|
||
observer.observe(el);
|
||
});
|
||
}
|
||
|
||
/* ============================================================
|
||
* 5. 粘性元素 (Sticky)
|
||
* ============================================================ */
|
||
function initSticky() {
|
||
document.querySelectorAll('[data-aksrt-sticky]').forEach(function (el) {
|
||
var top = parseInt(el.dataset.aksrtStickyTop || '80', 10);
|
||
var offset = parseInt(el.dataset.aksrtStickyOffset || '0', 10);
|
||
|
||
function update() {
|
||
var rect = el.getBoundingClientRect();
|
||
var parentRect = el.parentElement.getBoundingClientRect();
|
||
|
||
if (parentRect.top < top && parentRect.bottom > el.offsetHeight + top) {
|
||
el.style.position = 'sticky';
|
||
el.style.top = top + 'px';
|
||
}
|
||
}
|
||
|
||
window.addEventListener('scroll', update, { passive: true });
|
||
});
|
||
}
|
||
|
||
/* ============================================================
|
||
* 6. 视差滚动
|
||
* ============================================================ */
|
||
function initParallax() {
|
||
var elements = document.querySelectorAll('[data-aksrt-parallax]');
|
||
if (elements.length === 0) return;
|
||
|
||
var ticking = false;
|
||
|
||
function update() {
|
||
var scrollTop = window.pageYOffset;
|
||
elements.forEach(function (el) {
|
||
var speed = parseFloat(el.dataset.aksrtParallax || '0.3');
|
||
var rect = el.getBoundingClientRect();
|
||
var center = rect.top + rect.height / 2;
|
||
var windowCenter = window.innerHeight / 2;
|
||
var offset = (center - windowCenter) * speed;
|
||
|
||
el.style.transform = 'translateY(' + offset + 'px)';
|
||
});
|
||
ticking = false;
|
||
}
|
||
|
||
window.addEventListener('scroll', function () {
|
||
if (!ticking) {
|
||
requestAnimationFrame(update);
|
||
ticking = true;
|
||
}
|
||
}, { passive: true });
|
||
}
|
||
|
||
/* ============================================================
|
||
* 7. 涟漪点击效果
|
||
* ============================================================ */
|
||
function initRipple() {
|
||
document.addEventListener('click', function (e) {
|
||
var el = e.target.closest('.aksrt-ripple');
|
||
if (!el) return;
|
||
|
||
var rect = el.getBoundingClientRect();
|
||
var x = e.clientX - rect.left;
|
||
var y = e.clientY - rect.top;
|
||
var size = Math.max(rect.width, rect.height) * 2;
|
||
|
||
var wave = document.createElement('span');
|
||
wave.className = 'aksrt-ripple__wave';
|
||
wave.style.width = wave.style.height = size + 'px';
|
||
wave.style.left = (x - size / 2) + 'px';
|
||
wave.style.top = (y - size / 2) + 'px';
|
||
|
||
el.appendChild(wave);
|
||
|
||
wave.addEventListener('animationend', function () {
|
||
wave.remove();
|
||
});
|
||
});
|
||
}
|
||
|
||
/* ============================================================
|
||
* 8. 表单浮动标签自动初始化
|
||
* ============================================================ */
|
||
function initFloatLabels() {
|
||
document.querySelectorAll('.aksrt-float-label__input').forEach(function (input) {
|
||
// 检查初始值
|
||
if (input.value) {
|
||
input.setAttribute('data-has-value', '1');
|
||
}
|
||
input.addEventListener('input', function () {
|
||
if (this.value) {
|
||
this.setAttribute('data-has-value', '1');
|
||
} else {
|
||
this.removeAttribute('data-has-value');
|
||
}
|
||
});
|
||
});
|
||
}
|
||
|
||
/* ============================================================
|
||
* 8. 签到日历可视化
|
||
* ============================================================ */
|
||
function initSigninCalendar() {
|
||
var calendar = document.querySelector('[data-aksrt-signin-calendar]');
|
||
if (!calendar) return;
|
||
|
||
var data = [];
|
||
try {
|
||
data = JSON.parse(calendar.dataset.aksrtSigninCalendar || '[]');
|
||
} catch (e) {}
|
||
|
||
// 生成最近 30 天的格子
|
||
var today = new Date();
|
||
var html = '<div class="aksrt-signin-calendar__grid">';
|
||
|
||
for (var i = 29; i >= 0; i--) {
|
||
var d = new Date(today);
|
||
d.setDate(d.getDate() - i);
|
||
var dateStr = d.toISOString().split('T')[0];
|
||
var isSigned = data.indexOf(dateStr) !== -1;
|
||
var isToday = i === 0;
|
||
|
||
html += '<div class="aksrt-signin-calendar__day' +
|
||
(isSigned ? ' is-signed' : '') +
|
||
(isToday ? ' is-today' : '') +
|
||
'" title="' + dateStr + (isSigned ? ' ✓' : '') + '">' +
|
||
'<span>' + d.getDate() + '</span>' +
|
||
'</div>';
|
||
}
|
||
|
||
html += '</div>';
|
||
calendar.innerHTML = html;
|
||
}
|
||
|
||
/* ============================================================
|
||
* 初始化入口
|
||
* ============================================================ */
|
||
document.addEventListener('DOMContentLoaded', function () {
|
||
initTilt();
|
||
initScrollAnimations();
|
||
initRipple();
|
||
initSticky();
|
||
initParallax();
|
||
initFloatLabels();
|
||
initSigninCalendar();
|
||
document.addEventListener('aksrt:modal:open', function () {
|
||
// Remote modal may inject calendar markup after open.
|
||
window.setTimeout(initSigninCalendar, 30);
|
||
});
|
||
});
|
||
|
||
// 暴露到全局供动态内容使用
|
||
window.AksrtEnhancements = {
|
||
initTilt: initTilt,
|
||
initScrollAnimations: initScrollAnimations,
|
||
initRipple: initRipple,
|
||
};
|
||
|
||
})();
|
||
;
|
||
|
||
/* source: assets/js/color-extract.js */
|
||
/**
|
||
* AKSRT Color Extract
|
||
*
|
||
* Extracts dominant colors from images and applies them as dynamic accents.
|
||
* Uses canvas-based color sampling — no external dependencies.
|
||
*
|
||
* Usage:
|
||
* <img data-aksrt-color-extract data-aksrt-color-target=".card">
|
||
* <!-- Will set --aksrt-dynamic-color on .card based on image colors -->
|
||
*
|
||
* @package AKSRT
|
||
*/
|
||
|
||
(function () {
|
||
'use strict';
|
||
|
||
var canvas = null;
|
||
var ctx = null;
|
||
|
||
function getCanvas() {
|
||
if (!canvas) {
|
||
canvas = document.createElement('canvas');
|
||
canvas.width = 40;
|
||
canvas.height = 40;
|
||
ctx = canvas.getContext('2d', { willReadFrequently: true });
|
||
}
|
||
return { canvas: canvas, ctx: ctx };
|
||
}
|
||
|
||
function extractColor(img) {
|
||
try {
|
||
var c = getCanvas();
|
||
c.ctx.drawImage(img, 0, 0, 40, 40);
|
||
var data = c.ctx.getImageData(0, 0, 40, 40).data;
|
||
|
||
var r = 0, g = 0, b = 0, count = 0;
|
||
var step = 4; // sample every 4th pixel for speed
|
||
|
||
for (var i = 0; i < data.length; i += 4 * step) {
|
||
var pr = data[i], pg = data[i + 1], pb = data[i + 2];
|
||
// Skip very dark or very light pixels
|
||
var brightness = (pr + pg + pb) / 3;
|
||
if (brightness < 20 || brightness > 240) continue;
|
||
// Skip near-transparent
|
||
if (data[i + 3] < 128) continue;
|
||
|
||
r += pr;
|
||
g += pg;
|
||
b += pb;
|
||
count++;
|
||
}
|
||
|
||
if (count === 0) return null;
|
||
|
||
r = Math.round(r / count);
|
||
g = Math.round(g / count);
|
||
b = Math.round(b / count);
|
||
|
||
return { r: r, g: g, b: b, hex: rgbToHex(r, g, b) };
|
||
} catch (e) {
|
||
// CORS or tainted canvas — silently fail
|
||
return null;
|
||
}
|
||
}
|
||
|
||
function rgbToHex(r, g, b) {
|
||
return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
||
}
|
||
|
||
function lighten(r, g, b, amount) {
|
||
return rgbToHex(
|
||
Math.min(255, r + amount),
|
||
Math.min(255, g + amount),
|
||
Math.min(255, b + amount)
|
||
);
|
||
}
|
||
|
||
function darken(r, g, b, amount) {
|
||
return rgbToHex(
|
||
Math.max(0, r - amount),
|
||
Math.max(0, g - amount),
|
||
Math.max(0, b - amount)
|
||
);
|
||
}
|
||
|
||
function applyColor(target, color) {
|
||
if (!target || !color) return;
|
||
|
||
var r = color.r, g = color.g, b = color.b;
|
||
target.style.setProperty('--aksrt-dynamic-color', color.hex);
|
||
target.style.setProperty('--aksrt-dynamic-color-rgb', r + ',' + g + ',' + b);
|
||
target.style.setProperty('--aksrt-dynamic-color-light', lighten(r, g, b, 60));
|
||
target.style.setProperty('--aksrt-dynamic-color-dark', darken(r, g, b, 40));
|
||
|
||
// Add a subtle tinted background if target doesn't already have one
|
||
if (!target.style.background && !target.style.backgroundColor) {
|
||
target.style.setProperty('--aksrt-dynamic-bg', 'rgba(' + r + ',' + g + ',' + b + ',0.05)');
|
||
}
|
||
}
|
||
|
||
function processImage(img) {
|
||
if (img.dataset.aksrtColorDone) return;
|
||
|
||
// Need crossOrigin for canvas access
|
||
if (!img.crossOrigin && img.src.indexOf(window.location.origin) !== 0) {
|
||
img.crossOrigin = 'anonymous';
|
||
}
|
||
|
||
function extract() {
|
||
var color = extractColor(img);
|
||
if (!color) return;
|
||
|
||
img.dataset.aksrtColorDone = '1';
|
||
|
||
var targetSelector = img.dataset.aksrtColorTarget;
|
||
var target = targetSelector
|
||
? img.closest(targetSelector) || document.querySelector(targetSelector)
|
||
: img.parentElement;
|
||
|
||
applyColor(target, color);
|
||
}
|
||
|
||
if (img.complete && img.naturalWidth > 0) {
|
||
extract();
|
||
} else {
|
||
img.addEventListener('load', extract, { once: true });
|
||
}
|
||
}
|
||
|
||
function init() {
|
||
document.querySelectorAll('[data-aksrt-color-extract]').forEach(processImage);
|
||
}
|
||
|
||
// Public API
|
||
window.AksrtColorExtract = {
|
||
extract: extractColor,
|
||
apply: applyColor,
|
||
process: processImage,
|
||
init: init
|
||
};
|
||
|
||
if (document.readyState === 'loading') {
|
||
document.addEventListener('DOMContentLoaded', init);
|
||
} else {
|
||
init();
|
||
}
|
||
})();
|
||
;
|
||
|
||
/* source: assets/js/effects.js */
|
||
/**
|
||
* AKSRT Effects — count-up / countdown / marquee / 3D tilt / FPS detection
|
||
*
|
||
* 全部渐进增强,尊重 prefers-reduced-motion。
|
||
*
|
||
* @package AKSRT
|
||
*/
|
||
|
||
(function () {
|
||
'use strict';
|
||
|
||
var reducedMotion = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||
|
||
/* ============================================================
|
||
* 1. 数字递增 (count-up) — IntersectionObserver 触发
|
||
* 用法:<span data-aksrt-countup data-target="1234" data-duration="2000">0</span>
|
||
* ============================================================ */
|
||
function initCountUp() {
|
||
if (reducedMotion) return;
|
||
if (!('IntersectionObserver' in window)) return;
|
||
|
||
var els = document.querySelectorAll('[data-aksrt-countup]');
|
||
if (!els.length) return;
|
||
|
||
var observer = new IntersectionObserver(function (entries) {
|
||
entries.forEach(function (entry) {
|
||
if (!entry.isIntersecting) return;
|
||
var el = entry.target;
|
||
observer.unobserve(el);
|
||
|
||
var target = parseFloat(el.dataset.target || '0');
|
||
var duration = parseInt(el.dataset.duration || '2000', 10);
|
||
var decimals = (el.dataset.decimals || '0|').split('|');
|
||
var prefix = decimals[1] || '';
|
||
var dec = parseInt(decimals[0], 10) || 0;
|
||
var start = 0;
|
||
var startTime = null;
|
||
|
||
function step(timestamp) {
|
||
if (!startTime) startTime = timestamp;
|
||
var progress = Math.min((timestamp - startTime) / duration, 1);
|
||
// ease-out cubic
|
||
var eased = 1 - Math.pow(1 - progress, 3);
|
||
var current = start + (target - start) * eased;
|
||
el.textContent = prefix + current.toFixed(dec).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||
if (progress < 1) {
|
||
requestAnimationFrame(step);
|
||
} else {
|
||
el.textContent = prefix + target.toFixed(dec).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||
}
|
||
}
|
||
|
||
requestAnimationFrame(step);
|
||
});
|
||
}, { threshold: 0.3 });
|
||
|
||
els.forEach(function (el) { observer.observe(el); });
|
||
}
|
||
|
||
/* ============================================================
|
||
* 2. 倒计时组件
|
||
* 用法:<span data-aksrt-countdown data-end="2026-12-31T23:59:59">--:--:--</span>
|
||
* ============================================================ */
|
||
function initCountdown() {
|
||
var els = document.querySelectorAll('[data-aksrt-countdown]');
|
||
if (!els.length) return;
|
||
|
||
function pad(n) { return n < 10 ? '0' + n : '' + n; }
|
||
|
||
function update() {
|
||
var now = Date.now();
|
||
els.forEach(function (el) {
|
||
var end = new Date(el.dataset.end).getTime();
|
||
var diff = end - now;
|
||
if (diff <= 0) {
|
||
el.textContent = el.dataset.expired || '已结束';
|
||
return;
|
||
}
|
||
var d = Math.floor(diff / 86400000);
|
||
var h = Math.floor((diff % 86400000) / 3600000);
|
||
var m = Math.floor((diff % 3600000) / 60000);
|
||
var s = Math.floor((diff % 60000) / 1000);
|
||
var format = el.dataset.format || 'dhms';
|
||
if (format === 'dhms') {
|
||
el.textContent = (d > 0 ? d + '天 ' : '') + pad(h) + ':' + pad(m) + ':' + pad(s);
|
||
} else if (format === 'hms') {
|
||
el.textContent = pad(h + d * 24) + ':' + pad(m) + ':' + pad(s);
|
||
} else {
|
||
el.textContent = (d > 0 ? d + '天 ' : '') + pad(h) + '时' + pad(m) + '分' + pad(s) + '秒';
|
||
}
|
||
});
|
||
}
|
||
|
||
update();
|
||
setInterval(update, 1000);
|
||
}
|
||
|
||
/* ============================================================
|
||
* 4. 3D 悬停倾斜 (vanilla tilt)
|
||
* 用法:<div data-aksrt-tilt data-tilt-max="15">...</div>
|
||
* ============================================================ */
|
||
function initTilt() {
|
||
if (reducedMotion) return;
|
||
|
||
document.querySelectorAll('[data-aksrt-tilt]').forEach(function (el) {
|
||
if (el.dataset.tiltBound) return;
|
||
el.dataset.tiltBound = '1';
|
||
|
||
var maxDeg = parseFloat(el.dataset.tiltMax || '10');
|
||
var perspective = parseFloat(el.dataset.tiltPerspective || '800');
|
||
var scale = parseFloat(el.dataset.tiltScale || '1.03');
|
||
var glare = el.dataset.tiltGlare === '1';
|
||
var glareEl = null;
|
||
|
||
if (glare) {
|
||
glareEl = document.createElement('div');
|
||
glareEl.style.cssText = 'position:absolute;inset:0;border-radius:inherit;pointer-events:none;background:linear-gradient(135deg,rgba(255,255,255,0) 0%,rgba(255,255,255,0.25) 100%);opacity:0;transition:opacity 0.2s;';
|
||
el.style.position = el.style.position || 'relative';
|
||
el.style.overflow = 'hidden';
|
||
el.appendChild(glareEl);
|
||
}
|
||
|
||
el.addEventListener('mousemove', function (e) {
|
||
var rect = el.getBoundingClientRect();
|
||
var x = (e.clientX - rect.left) / rect.width;
|
||
var y = (e.clientY - rect.top) / rect.height;
|
||
var rotateX = (0.5 - y) * maxDeg;
|
||
var rotateY = (x - 0.5) * maxDeg;
|
||
el.style.transform = 'perspective(' + perspective + 'px) rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg) scale3d(' + scale + ',' + scale + ',' + scale + ')';
|
||
if (glareEl) glareEl.style.opacity = '1';
|
||
});
|
||
|
||
el.addEventListener('mouseleave', function () {
|
||
el.style.transform = 'perspective(' + perspective + 'px) rotateX(0deg) rotateY(0deg) scale3d(1,1,1)';
|
||
if (glareEl) glareEl.style.opacity = '0';
|
||
});
|
||
});
|
||
}
|
||
|
||
/* ============================================================
|
||
* 5. FPS 检测 + 低端设备降级
|
||
* ============================================================ */
|
||
function initFpsDetection() {
|
||
if (!('requestAnimationFrame' in window)) return;
|
||
|
||
var frames = 0;
|
||
var startTime = performance.now();
|
||
|
||
function countFrames() {
|
||
frames++;
|
||
var elapsed = performance.now() - startTime;
|
||
if (elapsed >= 1000) {
|
||
var fps = Math.round(frames * 1000 / elapsed);
|
||
if (fps < 24) {
|
||
document.body.classList.add('fps-accelerat');
|
||
}
|
||
return; // 只检测一次
|
||
}
|
||
requestAnimationFrame(countFrames);
|
||
}
|
||
|
||
requestAnimationFrame(countFrames);
|
||
}
|
||
|
||
/* ============================================================
|
||
* 初始化入口
|
||
* ============================================================ */
|
||
document.addEventListener('DOMContentLoaded', function () {
|
||
initCountUp();
|
||
initCountdown();
|
||
if (typeof initMarquee === 'function') {
|
||
initMarquee();
|
||
}
|
||
initTilt();
|
||
initFpsDetection();
|
||
});
|
||
|
||
})();
|
||
;
|
||
|
||
/* source: assets/js/runtime/main.min.js */
|
||
jQuery.cookie=function(e,o,t){if(o===void 0){var i=null;if(document.cookie&&document.cookie!="")for(var r=document.cookie.split(";"),n=0;n<r.length;n++){var c=jQuery.trim(r[n]);if(c.substring(0,e.length+1)==e+"="){i=decodeURIComponent(c.substring(e.length+1));break}}return i}t=t||{},o===null&&(o="",t.expires=-1);var a="";if(t.expires&&(typeof t.expires=="number"||t.expires.toUTCString)){var l2;typeof t.expires=="number"?(l2=new Date,l2.setTime(l2.getTime()+24*t.expires*60*60*1e3)):l2=t.expires,a="; expires="+l2.toUTCString()}var u=t.path?"; path="+t.path:"",s=t.domain?"; domain="+t.domain:"",m=t.secure?"; secure":"";document.cookie=[e,"=",encodeURIComponent(o),a,u,s,m].join("")};var lcs={get:function(e){return window.localStorage?localStorage.getItem(e):jQuery.cookie(e)},set:function(e,o){window.localStorage?localStorage[e]=o:jQuery.cookie(e,o)},remove:function(e){window.localStorage?localStorage.removeItem(e):jQuery.cookie(e,"")}};function aksrt__(key){var map=window._win&&window._win.i18n;return map&&Object.prototype.hasOwnProperty.call(map,key)?map[key]:key}function aksrt_is_fatal_error_response(text){return text&&(text.indexOf("Fatal error")>-1||text.indexOf("致命错误")>-1)}function aksrt_sprintf(key){var args=Array.prototype.slice.call(arguments,1),str=aksrt__(key),autoIndex=0;return str.replace(/%(\d+\$)?s/g,function(match,num){var idx=num?parseInt(num,10)-1:autoIndex++;return args[idx]!==void 0&&args[idx]!==null?args[idx]:match})}(function(window2,factory){var lazySizes=factory(window2,window2.document,Date);window2.lazySizes=lazySizes,typeof module=="object"&&module.exports&&(module.exports=lazySizes)})(typeof window<"u"?window:{},function(window2,document2,Date2){"use strict";var lazysizes,lazySizesCfg;if((function(){var prop,lazySizesDefaults={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",loadafterClass:"lazyloadafter",errorClass:"lazyerror",autosizesClass:"lazyautosizes",srcAttr:"data-src",srcsetAttr:"data-srcset",sizesAttr:"data-sizes",minSize:40,customMedia:{},init:!0,expFactor:1.5,hFac:.8,loadMode:2,loadHidden:!0,ricTimeout:0,throttleDelay:125};lazySizesCfg=window2.lazySizesConfig||window2.lazysizesConfig||{};for(prop in lazySizesDefaults)prop in lazySizesCfg||(lazySizesCfg[prop]=lazySizesDefaults[prop])})(),!document2||!document2.getElementsByClassName)return{init:function(){},cfg:lazySizesCfg,noSupport:!0};var docElem=document2.documentElement,supportPicture=window2.HTMLPictureElement,_addEventListener="addEventListener",_getAttribute="getAttribute",addEventListener=window2[_addEventListener].bind(window2),setTimeout2=window2.setTimeout,requestAnimationFrame2=window2.requestAnimationFrame||setTimeout2,requestIdleCallback=window2.requestIdleCallback,regPicture=/^picture$/i,loadEvents=["load","error","lazyincluded","_lazyloaded"],regClassCache={},forEach=Array.prototype.forEach,hasClass=function(ele,cls){return regClassCache[cls]||(regClassCache[cls]=new RegExp("(\\s|^)"+cls+"(\\s|$)")),regClassCache[cls].test(ele[_getAttribute]("class")||"")&®ClassCache[cls]},addClass=function(ele,cls){hasClass(ele,cls)||ele.setAttribute("class",(ele[_getAttribute]("class")||"").trim()+" "+cls)},removeClass=function(ele,cls){var reg2;(reg2=hasClass(ele,cls))&&ele.setAttribute("class",(ele[_getAttribute]("class")||"").replace(reg2," "))},addRemoveLoadEvents=function(dom,fn,add){var action=add?_addEventListener:"removeEventListener";add&&addRemoveLoadEvents(dom,fn),loadEvents.forEach(function(evt){dom[action](evt,fn)})},triggerEvent=function(elem,name,detail,noBubbles,noCancelable){var event=document2.createEvent("Event");return detail||(detail={}),detail.instance=lazysizes,event.initEvent(name,!noBubbles,!noCancelable),event.detail=detail,elem.dispatchEvent(event),event},updatePolyfill=function(el,full){var polyfill;!supportPicture&&(polyfill=window2.picturefill||lazySizesCfg.pf)?(full&&full.src&&!el[_getAttribute]("srcset")&&el.setAttribute("srcset",full.src),polyfill({reevaluate:!0,elements:[el]})):full&&full.src&&(el.src=full.src)},getCSS=function(elem,style){return(getComputedStyle(elem,null)||{})[style]},getWidth=function(elem,parent,width){for(width=width||elem.offsetWidth;width<lazySizesCfg.minSize&&parent&&!elem._lazysizesWidth;)width=parent.offsetWidth,parent=parent.parentNode;return width},rAF=(function(){var running,waiting,firstFns=[],secondFns=[],fns=firstFns,run=function(){var runFns=fns;for(fns=firstFns.length?secondFns:firstFns,running=!0,waiting=!1;runFns.length;)runFns.shift()();running=!1},rafBatch=function(fn,queue){running&&!queue?fn.apply(this,arguments):(fns.push(fn),waiting||(waiting=!0,(document2.hidden?setTimeout2:requestAnimationFrame2)(run)))};return rafBatch._lsFlush=run,rafBatch})(),rAFIt=function(fn,simple){return simple?function(){rAF(fn)}:function(){var that=this,args=arguments;rAF(function(){fn.apply(that,args)})}},throttle2=function(fn){var running,lastTime=0,gDelay=lazySizesCfg.throttleDelay,rICTimeout=lazySizesCfg.ricTimeout,run=function(){running=!1,lastTime=Date2.now(),fn()},idleCallback=requestIdleCallback&&rICTimeout>49?function(){requestIdleCallback(run,{timeout:rICTimeout}),rICTimeout!==lazySizesCfg.ricTimeout&&(rICTimeout=lazySizesCfg.ricTimeout)}:rAFIt(function(){setTimeout2(run)},!0);return function(isPriority){var delay;(isPriority=isPriority===!0)&&(rICTimeout=33),!running&&(running=!0,delay=gDelay-(Date2.now()-lastTime),delay<0&&(delay=0),isPriority||delay<9?idleCallback():setTimeout2(idleCallback,delay))}},debounce2=function(func){var timeout,timestamp,wait=99,run=function(){timeout=null,func()},later=function(){var last=Date2.now()-timestamp;last<wait?setTimeout2(later,wait-last):(requestIdleCallback||run)(run)};return function(){timestamp=Date2.now(),timeout||(timeout=setTimeout2(later,wait))}},loader=(function(){var preloadElems,isCompleted,resetPreloadingTimer,loadMode,started,eLvW,elvH,eLtop,eLleft,eLright,eLbottom,isBodyHidden,regImg=/^img$/i,regIframe=/^iframe$/i,supportScroll="onscroll"in window2&&!/(gle|ing)bot/.test(navigator.userAgent),shrinkExpand=0,currentExpand=0,isLoading=0,lowRuns=-1,resetPreloading=function(e){isLoading--,(!e||isLoading<0||!e.target)&&(isLoading=0)},isVisible=function(elem){return isBodyHidden==null&&(isBodyHidden=getCSS(document2.body,"visibility")=="hidden"),isBodyHidden||!(getCSS(elem.parentNode,"visibility")=="hidden"&&getCSS(elem,"visibility")=="hidden")},isNestedVisible=function(elem,elemExpand){var outerRect,parent=elem,visible=isVisible(elem);for(eLtop-=elemExpand,eLbottom+=elemExpand,eLleft-=elemExpand,eLright+=elemExpand;visible&&(parent=parent.offsetParent)&&parent!=document2.body&&parent!=docElem;)visible=(getCSS(parent,"opacity")||1)>0,visible&&getCSS(parent,"overflow")!="visible"&&(outerRect=parent.getBoundingClientRect(),visible=eLright>outerRect.left&&eLleft<outerRect.right&&eLbottom>outerRect.top-1&&eLtop<outerRect.bottom+1);return visible},checkElements=function(){var eLlen,i,rect,autoLoadElem,loadedSomething,elemExpand,elemNegativeExpand,elemExpandVal,beforeExpandVal,defaultExpand,preloadExpand,hFac,lazyloadElems=lazysizes.elements;if((loadMode=lazySizesCfg.loadMode)&&isLoading<8&&(eLlen=lazyloadElems.length)){for(i=0,lowRuns++;i<eLlen;i++)if(!(!lazyloadElems[i]||lazyloadElems[i]._lazyRace)){if(!supportScroll||lazysizes.prematureUnveil&&lazysizes.prematureUnveil(lazyloadElems[i])){unveilElement(lazyloadElems[i]);continue}if((!(elemExpandVal=lazyloadElems[i][_getAttribute]("data-expand"))||!(elemExpand=elemExpandVal*1))&&(elemExpand=currentExpand),defaultExpand||(defaultExpand=!lazySizesCfg.expand||lazySizesCfg.expand<1?docElem.clientHeight>500&&docElem.clientWidth>500?500:370:lazySizesCfg.expand,lazysizes._defEx=defaultExpand,preloadExpand=defaultExpand*lazySizesCfg.expFactor,hFac=lazySizesCfg.hFac,isBodyHidden=null,currentExpand<preloadExpand&&isLoading<1&&lowRuns>2&&loadMode>2&&!document2.hidden?(currentExpand=preloadExpand,lowRuns=0):loadMode>1&&lowRuns>1&&isLoading<6?currentExpand=defaultExpand:currentExpand=shrinkExpand),beforeExpandVal!==elemExpand&&(eLvW=innerWidth+elemExpand*hFac,elvH=innerHeight+elemExpand,elemNegativeExpand=elemExpand*-1,beforeExpandVal=elemExpand),rect=lazyloadElems[i].getBoundingClientRect(),(eLbottom=rect.bottom)>=elemNegativeExpand&&(eLtop=rect.top)<=elvH&&(eLright=rect.right)>=elemNegativeExpand*hFac&&(eLleft=rect.left)<=eLvW&&(eLbottom||eLright||eLleft||eLtop)&&(lazySizesCfg.loadHidden||isVisible(lazyloadElems[i]))&&(isCompleted&&isLoading<3&&!elemExpandVal&&(loadMode<3||lowRuns<4)||isNestedVisible(lazyloadElems[i],elemExpand))){if(unveilElement(lazyloadElems[i]),loadedSomething=!0,isLoading>9)break}else!loadedSomething&&isCompleted&&!autoLoadElem&&isLoading<4&&lowRuns<4&&loadMode>2&&(preloadElems[0]||lazySizesCfg.preloadAfterLoad)&&(preloadElems[0]||!elemExpandVal&&(eLbottom||eLright||eLleft||eLtop||lazyloadElems[i][_getAttribute](lazySizesCfg.sizesAttr)!="auto"))&&(autoLoadElem=preloadElems[0]||lazyloadElems[i])}autoLoadElem&&!loadedSomething&&unveilElement(autoLoadElem)}},throttledCheckElements=throttle2(checkElements),switchLoadingClass=function(e){var elem=e.target;if(elem._lazyCache){delete elem._lazyCache;return}resetPreloading(e),addClass(elem,lazySizesCfg.loadedClass),removeClass(elem,lazySizesCfg.loadingClass),addRemoveLoadEvents(elem,rafSwitchLoadingClass),triggerEvent(elem,"lazyloaded"),setTimeout2(function(){addClass(elem,lazySizesCfg.loadafterClass)},700)},rafedSwitchLoadingClass=rAFIt(switchLoadingClass),rafSwitchLoadingClass=function(e){rafedSwitchLoadingClass({target:e.target})},changeIframeSrc=function(elem,src){try{elem.contentWindow.location.replace(src)}catch{elem.src=src}},handleSources=function(source){var customMedia,sourceSrcset=source[_getAttribute](lazySizesCfg.srcsetAttr);(customMedia=lazySizesCfg.customMedia[source[_getAttribute]("data-media")||source[_getAttribute]("media")])&&source.setAttribute("media",customMedia),sourceSrcset&&source.setAttribute("srcset",sourceSrcset)},lazyUnveil=rAFIt(function(elem,detail,isAuto,sizes,isImg){var src,srcset,parent,isPicture,event,firesLoad;(event=triggerEvent(elem,"lazybeforeunveil",detail)).defaultPrevented||(sizes&&(isAuto?addClass(elem,lazySizesCfg.autosizesClass):elem.setAttribute("sizes",sizes)),srcset=elem[_getAttribute](lazySizesCfg.srcsetAttr),src=elem[_getAttribute](lazySizesCfg.srcAttr),isImg&&(parent=elem.parentNode,isPicture=parent&®Picture.test(parent.nodeName||"")),firesLoad=detail.firesLoad||"src"in elem&&(srcset||src||isPicture),event={target:elem},addClass(elem,lazySizesCfg.loadingClass),firesLoad&&(clearTimeout(resetPreloadingTimer),resetPreloadingTimer=setTimeout2(resetPreloading,2500),addRemoveLoadEvents(elem,rafSwitchLoadingClass,!0)),isPicture&&forEach.call(parent.getElementsByTagName("source"),handleSources),srcset?elem.setAttribute("srcset",srcset):src&&!isPicture&&(regIframe.test(elem.nodeName)?changeIframeSrc(elem,src):elem.src=src),isImg&&(srcset||isPicture)&&updatePolyfill(elem,{src})),elem._lazyRace&&delete elem._lazyRace,removeClass(elem,lazySizesCfg.lazyClass),rAF(function(){var isLoaded=elem.complete&&elem.naturalWidth>1;(!firesLoad||isLoaded)&&(isLoaded&&addClass(elem,"ls-is-cached"),switchLoadingClass(event),elem._lazyCache=!0,setTimeout2(function(){"_lazyCache"in elem&&delete elem._lazyCache},9)),elem.loading=="lazy"&&isLoading--},!0)}),unveilElement=function(elem){if(!elem._lazyRace){var detail,isImg=regImg.test(elem.nodeName),sizes=isImg&&(elem[_getAttribute](lazySizesCfg.sizesAttr)||elem[_getAttribute]("sizes")),isAuto=sizes=="auto";(isAuto||!isCompleted)&&isImg&&(elem[_getAttribute]("src")||elem.srcset)&&!elem.complete&&!hasClass(elem,lazySizesCfg.errorClass)&&hasClass(elem,lazySizesCfg.lazyClass)||(detail=triggerEvent(elem,"lazyunveilread").detail,isAuto&&autoSizer.updateElem(elem,!0,elem.offsetWidth),elem._lazyRace=!0,isLoading++,lazyUnveil(elem,detail,isAuto,sizes,isImg))}},afterScroll=debounce2(function(){lazySizesCfg.loadMode=3,throttledCheckElements()}),altLoadmodeScrollListner=function(){lazySizesCfg.loadMode==3&&(lazySizesCfg.loadMode=2),afterScroll()},onload=function(){if(!isCompleted){if(Date2.now()-started<999){setTimeout2(onload,999);return}isCompleted=!0,lazySizesCfg.loadMode=3,throttledCheckElements(),addEventListener("scroll",altLoadmodeScrollListner,!0)}};return{_:function(){started=Date2.now(),lazysizes.elements=document2.getElementsByClassName(lazySizesCfg.lazyClass),preloadElems=document2.getElementsByClassName(lazySizesCfg.lazyClass+" "+lazySizesCfg.preloadClass),addEventListener("scroll",throttledCheckElements,!0),addEventListener("resize",throttledCheckElements,!0),addEventListener("pageshow",function(e){if(e.persisted){var loadingElements=document2.querySelectorAll("."+lazySizesCfg.loadingClass);loadingElements.length&&loadingElements.forEach&&requestAnimationFrame2(function(){loadingElements.forEach(function(img){img.complete&&unveilElement(img)})})}}),window2.MutationObserver?new MutationObserver(throttledCheckElements).observe(docElem,{childList:!0,subtree:!0,attributes:!0}):(docElem[_addEventListener]("DOMNodeInserted",throttledCheckElements,!0),docElem[_addEventListener]("DOMAttrModified",throttledCheckElements,!0),setInterval(throttledCheckElements,999)),addEventListener("hashchange",throttledCheckElements,!0),["focus","mouseover","click","load","transitionend","animationend"].forEach(function(name){document2[_addEventListener](name,throttledCheckElements,!0)}),/d$|^c/.test(document2.readyState)?onload():(addEventListener("load",onload),document2[_addEventListener]("DOMContentLoaded",throttledCheckElements),setTimeout2(onload,2e4)),lazysizes.elements.length?(checkElements(),rAF._lsFlush()):throttledCheckElements()},checkElems:throttledCheckElements,unveil:unveilElement,_aLSL:altLoadmodeScrollListner}})(),autoSizer=(function(){var autosizesElems,sizeElement=rAFIt(function(elem,parent,event,width){var sources,i,len;if(elem._lazysizesWidth=width,width+="px",elem.setAttribute("sizes",width),regPicture.test(parent.nodeName||""))for(sources=parent.getElementsByTagName("source"),i=0,len=sources.length;i<len;i++)sources[i].setAttribute("sizes",width);event.detail.dataAttr||updatePolyfill(elem,event.detail)}),getSizeElement=function(elem,dataAttr,width){var event,parent=elem.parentNode;parent&&(width=getWidth(elem,parent,width),event=triggerEvent(elem,"lazybeforesizes",{width,dataAttr:!!dataAttr}),event.defaultPrevented||(width=event.detail.width,width&&width!==elem._lazysizesWidth&&sizeElement(elem,parent,event,width)))},updateElementsSizes=function(){var i,len=autosizesElems.length;if(len)for(i=0;i<len;i++)getSizeElement(autosizesElems[i])},debouncedUpdateElementsSizes=debounce2(updateElementsSizes);return{_:function(){autosizesElems=document2.getElementsByClassName(lazySizesCfg.autosizesClass),addEventListener("resize",debouncedUpdateElementsSizes)},checkElems:debouncedUpdateElementsSizes,updateElem:getSizeElement}})(),init=function(){!init.i&&document2.getElementsByClassName&&(init.i=!0,autoSizer._(),loader._())};return setTimeout2(function(){lazySizesCfg.init&&init()}),lazysizes={cfg:lazySizesCfg,autoSizer,loader,init,uP:updatePolyfill,aC:addClass,rC:removeClass,hC:hasClass,fire:triggerEvent,gW:getWidth,rAF},lazysizes}),jQuery.fn.minitouch=function(options){var is_on="minitouch-isload",_e=jQuery(this);if(!_e.data(is_on)){options=jQuery.extend({direction:"bottom",selector:"",start_selector:"",depreciation:50,stop:!1,onStart:!1,onIng:!1,onEnd:!1,inEnd:!1},options);var is_stop=!1,dep=options.depreciation,startX=0,startY=0,endX=0,endY=0,angle=0,distanceX=0,distanceY=0,dragging=!1,cssTransition=function(a,b,c,d,s){var e,f,g;d&&(b+="px",c+="px",e="translate3D("+b+","+c+" , 0)",f={},g=cssT_Support(),f[g+"transform"]=e,f[g+"transition"]=g+"transform 0s linear",f.cursor=s,d=="null"&&(f[g+"transform"]="",f[g+"transition"]=""),a.css(f))},cssT_Support=function(){var a=document.body||document.documentElement;return a=a.style,a.WebkitTransition==""?"-webkit-":a.MozTransition==""?"-moz-":a.OTransition==""?"-o-":a.transition==""?"":void 0},touch_selector=options.start_selector||options.selector;_e.on("touchstart pointerdown MSPointerDown",touch_selector,function(e){startX=startY=endX=endY=angle=distanceX=distanceY=0,startX=e.originalEvent.pageX||e.originalEvent.touches[0].pageX,startY=e.originalEvent.pageY||e.originalEvent.touches[0].pageY,dragging=!0,jQuery(e.target).parentsUntil(touch_selector,".swiper-container,.scroll-x").length&&(dragging=!1)}).on("touchmove pointermove MSPointerMove",touch_selector,function(a){var _move=options.start_selector?options.selector?_e.find(options.selector):_e.find(options.start_selector):jQuery(this);jQuery.isFunction(options.stop)&&(is_stop=options.stop(_e,_move,startX,startY)),dragging&&!is_stop&&(endX=a.originalEvent.pageX||a.originalEvent.touches[0].pageX,endY=a.originalEvent.pageY||a.originalEvent.touches[0].pageY,distanceX=endX-startX,distanceY=endY-startY,angle=180*Math.atan2(distanceY,distanceX)/Math.PI,options.direction=="right"&&(distanceY=0,distanceX=angle>-40&&angle<40&&distanceX>0?distanceX:0),options.direction=="left"&&(distanceY=0,distanceX=(angle>150||angle<-150)&&0>distanceX?distanceX:0),options.direction=="top"&&(distanceX=0,distanceY=angle>-130&&angle<-50&&0>distanceY?distanceY:0),options.direction=="bottom"&&(distanceX=0,distanceY=angle>50&&angle<130&&distanceY>0?distanceY:0),(distanceX!==0||distanceY!==0)&&(a.preventDefault?a.preventDefault():a.returnValue=!1,cssTransition(_move,distanceX,distanceY,dragging,"grab"),jQuery.isFunction(options.onIng)&&options.onIng(_e,_move,distanceX,distanceY)))}).on("touchend touchcancel pointerup MSPointerUp",touch_selector,function(){var _move=options.start_selector?options.selector?_e.find(options.selector):_e.find(options.start_selector):jQuery(this);dragging&&!is_stop&&(cssTransition(_move,0,0,"null",""),jQuery.isFunction(options.inEnd)&&options.inEnd(_e,_move,distanceX,distanceY),(Math.abs(distanceX)>dep||Math.abs(distanceY)>dep)&&jQuery.isFunction(options.onEnd)&&options.onEnd(_e,_move,distanceX,distanceY),startX=startY=endX=endY=angle=distanceX=distanceY=0,dragging=!1)}).data(is_on,!0)}},_win.bd=jQuery("body"),_win.window=jQuery(window),_win.is_signin=!!_win.bd.hasClass("logged-in");var _wid=_win.window.width(),_hei=_win.window.height();_win.bd.on("click","[data-close]",function(){var e=jQuery(this).attr("data-close");return jQuery(e).removeClass("show in"),!1}),_win.bd.on("click","[data-toggle-class]",function(){var c=jQuery(this).attr("data-toggle-class")||"show",e=jQuery(this).attr("data-target")||this;return jQuery(e).toggleClass(c).trigger("toggleClass"),!1}),_win.bd.on("click",only_drop),_win.bd.on("toggleClass",".dropup,.dropdown",only_drop);function only_drop(e){var drop=jQuery(e.target).closest(".dropup,.dropdown");jQuery(".dropup.open,.dropdown.open").not(drop).removeClass("open")}_win.bd.on("click",".alert-dismissible > .close",function(){jQuery(this).parent().slideUp()}),_win.bd.on("click","[data-onclick]",function(){var e=jQuery(this).attr("data-onclick");return jQuery(e).click()}),jQuery.fn.OnlyOn=function(type,selector,data,fun){var rnotwhite=/\S+/g,is_oned=!1;type=type.match(rnotwhite)[0];var events=jQuery._data(this[0],"events");events&&typeof events.type<"u"&&jQuery.each(events[type],function(i,item){if(item.selector==selector&&item.data==data)return is_oned=!0,!1}),is_oned?console.log("事件重复绑定{type:"+type+",selector:"+selector+",data:"+data+"}"):this.on(type,selector,data,fun)},jQuery.fn.aksrt_ajax=function(data,success,noty,no_loading){return aksrt_ajax(jQuery(this),data,success,noty,no_loading)},jQuery.fn.countdown=function(){function getTimeRemaining(endtime,max_unit){var date=new Date,now=date.getTime(),endDate=new Date(endtime),end=endDate.getTime(),total=end-now,seconds=total/1e3%60;seconds=seconds.toFixed(2);var mseconds=~~(total%1e3),minutes=~~(total/1e3/60%60),hours=~~(total/(1e3*60*60)%24),days=~~(total/(1e3*60*60*24));return max_unit==="minute"&&minutes>0&&(hours=0,days=0,minutes=~~(total/1e3/60)),max_unit==="hour"&&hours>0&&(days=0,hours=~~(total/(1e3*60*60))),seconds=seconds<10?"0"+seconds:seconds,minutes=minutes<10?"0"+minutes:minutes,{total,days,hours,minutes,seconds,mseconds}}jQuery(this).each(function(){var _this=jQuery(this),endtime=_this.attr("data-countdown");if(!endtime)return;var int_second=_this.attr("int-second"),max_unit=_this.attr("max-unit");if(_this.attr("title",aksrt__("countdown_end_time")+endtime),int_second==="auto"){var t=getTimeRemaining(endtime,max_unit);int_second=t.days>0}function updateClock(){var t2=getTimeRemaining(endtime,max_unit);if(int_second&&(t2.seconds=t2.seconds.toString().replace(/\.\d+$/,"")),_this.find(".day").length&&_this.find(".day").html(t2.days),_this.find(".hour").length&&_this.find(".hour").html(t2.hours),_this.find(".minute").length&&_this.find(".minute").html(t2.minutes),_this.find(".second").length)_this.find(".second").html(t2.seconds);else{var html="";t2.days>0&&(html+='<span class="day">'+t2.days+'</span><span class="day-unit">'+aksrt__("countdown_day")+"</span>"),(t2.hours>0||t2.days>0)&&(html+='<span class="hour">'+t2.hours+'</span><span class="hour-unit">'+aksrt__("countdown_hour")+"</span>"),(t2.minutes>0||t2.hours>0||t2.days>0)&&(html+='<span class="minute">'+t2.minutes+'</span><span class="minute-unit">'+aksrt__("countdown_minute")+"</span>"),html+='<span class="second">'+t2.seconds+'</span><span class="second-unit">'+aksrt__("countdown_second")+"</span>",_this.html(html)}if(t2.total<=0){clearInterval(timeinterval);var over_text=_this.attr("data-over-text")||aksrt__("countdown_ended");_this.html(over_text).trigger("countdown-over")}}updateClock();var timeinterval=setInterval(updateClock,int_second?1e3:20);_this.removeAttr("data-countdown").addClass("countdown-box")})},_win.dplayer={tbquire:["dplayer"],obj:{}};function new_dplayer(){var selector=".new-dplayer:not(.dplayer-initialized),[data-dplayer]:not(.dplayer-initialized)";jQuery(selector).length&&jQuery(selector).each(function(){var _this=jQuery(this);get_new_dplayer(_this,function(dplayer){_this.addClass("dplayer-initialized").siblings(".dplayer-featured").find(".switch-video").each(function(){var _this2=jQuery(this),video_url=_this2.attr("video-url"),video_pic=_this2.attr("video-pic");_this2.data({"video-url":video_url,"video-pic":video_pic}),_this2.attr({"dplayer-id":dplayer.container.id}),setTimeout(function(){_this2.removeAttr("video-url").removeAttr("video-pic")},50)})})})}function get_new_dplayer(_this,func){var option={},video_url=_this.attr("video-url")||_this.data("video-url"),data_volume=_this.attr("data-volume"),i=parseInt((Math.random()+1)*Math.pow(10,4));if(!(_this.find(".dplayer-video-wrap").length||!video_url)){_this.attr("id","dplayer-"+i),option.container=document.getElementById("dplayer-"+i),option.theme="#f04494",option.video={url:video_url,pic:_this.attr("video-pic")||"",type:_this.attr("video-type")||"auto"},_this.attr("data-loop")&&(option.loop=!0),_this.attr("data-autoplay")&&(option.autoplay=!0),data_volume&&data_volume<1&&(option.volume=data_volume),data_volume==="none"&&(option.volume=0);var option_attr=_this.attr("video-option");if(option_attr){try{option_attr=JSON.parse(option_attr)}catch(e){console.log(e)}jQuery.extend(option,option_attr)}var v_u=video_url.toLowerCase();return v_u.indexOf(".m3u")!=-1&&_win.dplayer.tbquire.push("hls"),v_u.indexOf(".mpd")!=-1&&_win.dplayer.tbquire.push("dash"),v_u.indexOf(".flv")!=-1&&_win.dplayer.tbquire.push("flv"),jQuery("link#dplayer").length||jQuery("dplayer").append('<link type="text/css" id="dplayer" rel="stylesheet" href="'+_win.uri+"/css/dplayer.min.css?ver="+_win.ver+'">'),_win.dplayer.tbquire.push("dplayer"),tbquire(_win.dplayer.tbquire,function(){try{var newDPlayer=new DPlayer(option);newDPlayer.on("play",function(){_win.dplayer.play=newDPlayer}),_this.data("dplayer",newDPlayer),_win.dplayer.obj[i]=newDPlayer,_this.attr({"video-url":"","video-pic":""}),jQuery.isFunction(func)&&func(newDPlayer)}catch(e){console.error(e)}}),i}}_win.bd.on("click",".swiper-slide.slide-dplayer:not(.slide-dplayer-played) > *",function(){var _this=jQuery(this),dplayer=_this.find(".new-dplayer").data("dplayer");dplayer&&(dplayer.play(),_this.parent().addClass("slide-dplayer-played"))});function thumb_dplayer(mouseenter_e,box_e){var $body=jQuery("body"),thumb_dplayer_data_text="thumb_dplayer_data",thumb_dplayer_data=$body.data(thumb_dplayer_data_text)||{};if(thumb_dplayer_data[mouseenter_e+box_e])return;var ing_class="thumb-dplayer-playing",thumb_hide_class="dplayer-thumb-hide";function to_play(_this_m,_this,dplayer){_this.find(".dplayer-thumb").removeClass(thumb_hide_class),_win.dplayer.thumb_play=dplayer,_this.find(".progress").show(),_this_m.addClass(ing_class)}function to_pause(_this_m,_this,dplayer){dplayer.pause(),_this.find(".dplayer-thumb").addClass(thumb_hide_class),_win.dplayer.thumb_play=!1,_this.find(".progress").hide(),_this_m.removeClass(ing_class)}function video_thumb_stop(){if(_win.dplayer.thumb_play){var _this=jQuery(_win.dplayer.thumb_play.container).closest(box_e),_this_m=_this.closest(mouseenter_e);to_pause(_this_m,_this,_win.dplayer.thumb_play)}}function video_thumb_play(){var _this_m=jQuery(this),_this=_this_m.find(box_e);if(!_this.length)return;var dplayer=_this.find(".dplayer-thumb").data("dplayer");if(dplayer)return to_play(_this_m,_this,dplayer),dplayer.play();function dplayer_init(dplayer2){dplayer2.on("loadeddata",function(){setTimeout(function(){_this.find(".progress-bar").css({width:"100%",opacity:"0",transition:"width .2s, opacity .3s .3s"})},100),setTimeout(function(){_this.find(".progress").remove()},800)}),setTimeout(function(){to_play(_this_m,_this,dplayer2),dplayer2.play()},200)}if(!_this.find(".dplayer-thumb").length){var video_url=_this.attr("video-url"),video_volume=_this.attr("data-volume")||"none",video_pic="",scale_height=~~_this.attr("scale-height"),progress='<div class="progress progress-striped active progress-abs-bottom"><div class="progress-bar progress-bar-success"></div></div>',_dplayer=jQuery('<div class="dplayer-thumb-hide new-dplayer dplayer-thumb controller-hide'+(scale_height?" dplayer-scale-height":"")+'"'+(scale_height?' style="--scale-height:'+scale_height+'%;"':"")+' data-loop="true" data-volume="'+video_volume+'" data-hide="true" video-url="'+video_url+'" video-pic="'+video_pic+'" video-type="auto"></div>');_this.find(".video-thumb").html(_dplayer).after(progress),setTimeout(function(){_this.find(".progress-bar").css({transition:"width 6s",width:"80%"})},50),_this.attr("video-url",""),get_new_dplayer(_dplayer,dplayer_init)}}$body.on("mouseenter touchstart",mouseenter_e,video_thumb_play),$body.on("mouseleave",mouseenter_e,video_thumb_stop);var thumb_dplayer_init="thumb_dplayer_init";$body.data(thumb_dplayer_init)||$body.on("touchstart",function(e){var _target=jQuery(e.target);!_target.parents("."+ing_class).length&&_win.dplayer.thumb_play&&video_thumb_stop()}).data(thumb_dplayer_init,!0),thumb_dplayer_data[mouseenter_e+box_e]=!0,$body.data(thumb_dplayer_data_text,thumb_dplayer_data)}_win.bd.on("click",".switch-video",function(){var _this=jQuery(this),dplayer=jQuery("#"+_this.attr("dplayer-id")).data("dplayer"),video_url=_this.data("video-url"),video_pic=_this.data("video-pic");if(!(!video_url||!dplayer||_this.hasClass("active"))){_this.addClass("active").siblings().removeClass("active");var v_u=video_url.toLowerCase();v_u.indexOf(".m3u")!=-1&&_win.dplayer.tbquire.push("hls"),v_u.indexOf(".mpd")!=-1&&_win.dplayer.tbquire.push("dash"),v_u.indexOf(".flv")!=-1&&_win.dplayer.tbquire.push("flv"),tbquire(_win.dplayer.tbquire,function(){try{var op={url:video_url,type:"auto"};video_pic&&(op.pic=video_pic),dplayer.switchVideo(op),setTimeout(function(){dplayer.play()},100)}catch(e){console.log(e)}})}}),_win.bd.on("click",".switch-iframe",function(){var _this=jQuery(this),video_url=_this.attr("iframe-url"),$iframe=_this.closest(".iframe-series").find("iframe");if(!(!video_url||_this.hasClass("active"))){try{$iframe[0].contentWindow.location.replace(video_url)}catch{$iframe.attr("src",video_url)}_this.addClass("active").siblings().removeClass("active")}}),_win.bd.on("click",".file-download-btn",function(){var _this=jQuery(this),id=_this.attr("data-download-file"),nonce=_this.attr("download-nonce");if(_this.attr("target","_blank"),!!id){var href=_win.ajax_url+"?action=download_file&file="+id+"&nonce="+nonce;_this.attr("target","_blank").removeAttr("data-download-file").attr("href",href)}}),_win.bd.on("click",".post-tab-toggle",function(){var _this=jQuery(this),tab_id=_this.attr("tab-id");if(!_this.parent().hasClass("active")){var _con=_this.parent().addClass("active").siblings().removeClass("active").parent().next().find('[tab-id="'+tab_id+'"]');_con.siblings().removeClass("in"),setTimeout(function(){_con.addClass("active").siblings().removeClass("active")},150),setTimeout(function(){_con.addClass("in")},160)}}),_win.swiper=[],_win.swiper.tab={},_win.swiper.scroll={},_win.swiper.new={};function new_swiper(){jQuery(".swiper-scroll:not(.swiper-container-initialized),.new-swiper:not(.swiper-container-initialized),.swiper-tab:not(.swiper-container-initialized)").length&&(jQuery("link#swiper").length||jQuery("head").append('<link type="text/css" id="swiper" rel="stylesheet" href="'+_win.uri+"/css/swiper.min.css?ver="+_win.ver+'">'),tbquire(["swiper"],function(){jQuery(".swiper-scroll").each(function(e){if(!jQuery(this).hasClass("swiper-container-initialized")){var option={},_this=jQuery(this),_eq="swiper-scroll-eq-"+e,slideClass=_this.attr("data-slideClass")||!1;if(slideClass&&(option.slideClass=slideClass),!_this.attr("scroll-nogroup")){var c_w=_this.width(),i_w=_this.find(".swiper-wrapper>*:eq(0)").outerWidth(),slidesPerGroup=~~(c_w/i_w);option.slidesPerGroup=slidesPerGroup||1}option.autoplay=_this.attr("data-autoplay")?{delay:~~_this.attr("data-interval")||4e3,disableOnInteraction:!1}:!1,option.loop=_this.attr("data-loop"),option.slidesPerView="auto",option.mousewheel={forceToAxis:!0},option.freeMode=!0,option.freeModeSticky=!0,option.navigation={nextEl:".swiper-scroll."+_eq+" .swiper-button-next",prevEl:".swiper-scroll."+_eq+" .swiper-button-prev"},_this.addClass(_eq).attr("swiper-scroll-index",e),_win.swiper.scroll[e]=new Swiper(".swiper-scroll."+_eq,option)}}),jQuery(".swiper-tab").each(function(e){if(!jQuery(this).hasClass("swiper-container-initialized")){var _eq="swiper-eq-"+e,_this=jQuery(this),speed=~~_this.attr("data-speed")||~~((_this.width()+1200)/170)*50,initialSlide=~~_this.attr("active-index");speed=speed<300?300:speed;var option={loop:!1,initialSlide,autoHeight:!0,spaceBetween:20,autoplay:!1,speed,pagination:{el:".swiper-tab."+_eq+" .swiper-pagination",clickable:!0},on:{init:function(){auto_maxHeight()},slideChangeTransitionEnd:function(bvv){var b=jQuery(".swiper-tab."+_eq+" .swiper-slide-active .post_ajax_trigger .ajax-open");b.length&&(scrollTopTo(jQuery(".swiper-tab."+_eq),-40),b.attr("no-scroll",!0).click());var r=bvv.onStart&&jQuery('[swiper-scroll-index="'+e+'"] .swiper-slide-thumb-active [data-route]');r&&r.length&&history.replaceState(null,document.title,r.attr("data-route")),bvv.onStart=!0}}},tab_id=_this.attr("swiper-tab"),tab_nav=jQuery('[swiper-tab-nav="'+tab_id+'"]');if(tab_nav.length){var tab_nav_index=tab_nav.attr("swiper-scroll-index");option.thumbs={swiper:_win.swiper.scroll[tab_nav_index],autoScrollOffset:2},tab_nav.on("click","a[data-route]",function(e2){e2.preventDefault()})}_this.addClass(_eq).attr("swiper-tab-index",e),_win.swiper.tab[e]=new Swiper(".swiper-tab."+_eq,option)}}),jQuery(".new-swiper").each(function(e){if(!jQuery(this).hasClass("swiper-container-initialized")){var _eq="swiper-eq-"+e,_this=jQuery(this),delay=~~_this.attr("data-interval")||6e3,autoplay=_this.attr("data-autoplay")?{delay,disableOnInteraction:!1}:!1,auto_h=!!_this.attr("auto-height"),speed=~~_this.attr("data-speed")||~~((_this.width()+1e3)/22)*10;speed=speed<400?400:speed,speed=autoplay===!1?speed/1.6:speed;var loop=!!_this.attr("data-loop"),parallax=!!_this.find("[data-swiper-parallax],[data-swiper-parallax-scale]").length,effect=_this.attr("data-effect")||"slide",direction=_this.attr("data-direction")||"horizontal",spaceBetween=~~_this.attr("data-spaceBetween")||0,pagination_type=_this.attr("data-pagination-type")||"bullets";_this.addClass(_eq).attr("swiper-new-index",e);var swiper_args={loop,autoHeight:auto_h,direction,spaceBetween,parallax,effect,lazy:{loadPrevNext:!0},autoplay,speed,pagination:{el:".new-swiper."+_eq+" .swiper-pagination",type:pagination_type,clickable:!0},navigation:{nextEl:".new-swiper."+_eq+" .swiper-button-next",prevEl:".new-swiper."+_eq+" .swiper-button-prev"},on:{lazyImageReady:function(slideEl,imageEl){jQuery(imageEl).addClass("lazyloaded")},slideChange:function(){_this.find(".new-dplayer").each(function(index,item){var dplayer=jQuery(item).data("dplayer");dplayer&&dplayer.pause()})},init:function(){loop&&_this.find(".swiper-slide-duplicate img").addClass("no-imgbox")}}};pagination_type==="thumbnail"&&(swiper_args.pagination.type="bullets",swiper_args.pagination.bulletClass="pagination-thumbnail-item",swiper_args.pagination.bulletActiveClass="pagination-thumbnail-item-active",swiper_args.pagination.renderBullet=function(index,className){var imgsrc,thumbnail,_img=jQuery(this.slides[index]).find("img");return _img.length&&(_img=jQuery(_img[0]),imgsrc=_img.attr("data-src")||_img.attr("src")),imgsrc?(thumbnail='<div class="'+className+'"><image class="obj-fit no-imgbox" src="'+imgsrc+'"></div>',thumbnail):""}),_win.swiper.new[e]=new Swiper(".new-swiper."+_eq,swiper_args)}})}))}window.swiper_tab_AutoHeight=debounce(function($con){var tab=$con.closest("[swiper-tab-index]");if(tab.length){var tab_index=tab.attr("swiper-tab-index");_win.swiper.tab[tab_index].updateAutoHeight(500)}},100),jQuery.fn.scrollX=function(){return this.each(function(){var _this=jQuery(this),is_on="is-on";if(!_this.data(is_on)){_this.data(is_on,!0);var btn_class="scroll-x-",prev_btn_class=btn_class+"prev",next_btn_class=btn_class+"next",prev=jQuery('<div class="'+prev_btn_class+'" style="display: none;"></div>'),next=jQuery('<div class="'+next_btn_class+'" style="display: none;"></div>');init()}function scroll(type){var data=get_data();_this.animate({scrollLeft:type==="prev"?data[0]:data[1]},300,"linear",hover_show)}function init(){_this.after(prev).after(next),prev.on("click",function(){scroll("prev")}),next.on("click",scroll),_this.parent().hover(hover_show,function(){prev.hide(),next.hide()})}function hover_show(){var data=get_data();data[3]?prev.show():prev.hide(),data[3]<data[2]?next.show():next.hide()}function get_data(){var _this_w=_this.innerWidth(),_this_scrollLeft=_this.scrollLeft(),max=~~(_this.prop("scrollWidth")-_this_w),prev_scroll=~~(_this_scrollLeft-_this_w);prev_scroll=prev_scroll>0?prev_scroll:0;var next_scroll=~~(_this_scrollLeft+_this_w);return next_scroll=next_scroll>max?max:next_scroll,[prev_scroll,next_scroll,max,_this_scrollLeft]}})},jQuery.fn.Tabcenter=function(){return this.each(function(){var _this=jQuery(this),_active=_this.find(".active");if(_active.length){var _this_w=_this.innerWidth(),_active_w=_active.innerWidth(),_this_scrollLeft=_this.scrollLeft(),_active_left=_active.position().left,max=~~(_this.prop("scrollWidth")-_this_w),_yd=~~(_this_scrollLeft+_active_left-_this_w/2+_active_w/2);_yd=_yd>0?_yd:0,_yd=_yd>max?max:_yd,_yd!=_this_scrollLeft&&_this.animate({scrollLeft:_yd},300)}})},_win.bd.on("shown.bs.tab","a[data-ajax]",function(){jQuery(this).closest("ul.list-inline").Tabcenter()}),jQuery(".tab-nav-theme,.tab-nav-but,.index-tab ul.list-inline").Tabcenter();function post_ajax(_this,con,jcon,item,loader,pag,next,trigger,replace,nomore,top,ajax_trigger){var $con=_this.closest(con);if($con.attr("ing"))return!1;var $item=find(item),href=_this.attr("ajax-href")||_this.attr("href")||_this.find("a").attr("ajax-href")||_this.find("a").attr("href");jcon=jcon||con,ajax_trigger=ajax_trigger||(_win.ajax_trigger?_win.ajax_trigger:'<i class="fa fas fa-arrow-right"></i>'+aksrt__("load_more")),replace=_this.attr("ajax-replace")||replace,nomore=nomore||_win.ajax_nomore;var $loader=find(".post_ajax_loader");$loader.length||(loader=loader||'<div class="theme-box box-body ajax-loading text-center"><h2 class="loading zts"></h2></div>',$loader=jQuery('<div class="post_ajax_loader">'+loader+"</div>"));function find(selector,$parent,con_selector){$parent=$parent&&$parent.length?$parent:$con,con_selector=con_selector||con;var $element=$parent.find(">"+selector);return $element.length||($element=$parent.find(">*:not("+con_selector+")>"+selector),$element.length)||($element=$parent.find(">*:not("+con_selector+")>*:not("+con_selector+")>"+selector),$element.length)||($element=$parent.find(">*:not("+con_selector+")>*:not("+con_selector+")>*:not("+con_selector+")>"+selector),$element.length)?$element:jQuery("null#null")}return href&&jQuery.ajax({type:"POST",url:href,dataType:"html",beforeSend:function(){replace&&$item.length&&$item.remove(),$con.attr("ing",!0),find(".post_ajax_trigger").remove(),find(".no-more").remove(),find(".post_ajax_loader").remove(),find(".noajax-pag").remove(),find(pag).remove(),$item=find(item),$item.length?top?$item.first().before($loader):$item.last().after($loader):$con.append($loader),$loader.fadeIn(),swiper_tab_AutoHeight($con)},success:function(a){a=jQuery.parseHTML("<div>"+a+"</div>");var $a=jQuery(a);$a.find("[win-ajax-replace]").each(function(){var replace_key=jQuery(this).attr("win-ajax-replace"),replace_e=jQuery('[win-ajax-replace="'+replace_key+'"]');replace_e.length&&(replace_e.html(jQuery(this).html()),jQuery(this).remove())});var $jcon=$a.find(jcon),c_c=find(item,$jcon,jcon),c_p=find(pag,$jcon,jcon),n_h=c_p.find(next).attr("href")||c_p.find(next).find("a").attr("href");c_p=c_p.length?c_p:'<div class="text-center mb20 padding-h10 muted-2-color no-more separator">'+nomore+"</div>",c_p=$jcon.find(".noajax-pag").length?$jcon.find(".noajax-pag"):c_p,trigger&&(c_p=typeof n_h<"u"?'<span class="post_ajax_trigger"><a class="'+trigger+'" href="'+n_h+'">'+ajax_trigger+"</a></span>":c_p);var $item_header=find(".ajax-item-header",$jcon,jcon);if($item_header.length&&(find(".ajax-item-header").remove(),$con.prepend($item_header)),$item=find(item),$item.length?top?$item.first().before(c_p).before(c_c):$item.last().after(c_p).after(c_c):top?$con.append(c_p).append(c_c):$con.append(c_c).append(c_p),$con.removeAttr("ing").trigger("post_ajax.ed",jQuery(a)),find(".post_ajax_loader",$con).hide(),_this.attr("no-scroll"))_win.auto_scroll=!0,setTimeout(function(){_win.window.trigger("scroll"),_win.auto_scroll=!1},20);else{var _scroll_To=replace?$con:jQuery(c_c[0]);setTimeout(function(){scrollTopTo(_scroll_To,-40)},100)}if(_this.attr("route")){var route_title=_this.attr("route-title")||$a.find("title").text();history.replaceState(null,route_title,href),route_title&&jQuery("head title").text(route_title)}swiper_tab_AutoHeight($con),auto_fun()}}),!1}if(_win.bd.on("click","[remote-box]",function(){var _this=jQuery(this),remote=_this.attr("remote-box");remote&&jQuery.post(remote,null,function(data){_this.html(data).removeAttr("remote-box"),auto_fun(),_this.trigger("aksrt:remote-loaded")})}),_win.bd.on("show.bs.tab","a[data-ajax]",function(){var _this=jQuery(this),a=_this.data("target")||_this.attr("href"),selector=a+" .post_ajax_trigger .ajax-next",b=jQuery(selector).attr("ajax-replace",!0);if(b.length)b.click();else{var href=_this.attr("data-ajax");if(href){var trigger='<span class="post_ajax_trigger hide"><a ajax-href="'+href+'" class="ajax_load ajax-next ajax-open" ajax-replace="true"></a></span>';jQuery(a).append(trigger),jQuery(selector).click()}}_this.attr("only-one")&&_this.removeAttr("data-ajax")}),_win.bd.on("click","[ajax-tab],[ajax-target]",function(){var _this=jQuery(this),replace=_this.attr("ajax-replace")?' ajax-replace="true"':"",target=_this.attr("ajax-tab")||_this.attr("ajax-target"),href=_this.attr("data-ajax"),trigger='<span class="post_ajax_trigger hide"><a ajax-href="'+href+'" class="ajax_load ajax-next ajax-open"'+replace+"></a></span>";console.log(target),jQuery(target).find(".post_ajax_trigger").remove(),jQuery(target).append(trigger),jQuery(target+" .post_ajax_trigger .ajax-next").click(),jQuery('a[href="'+target+'"]').click()}),_win.bd.on("click",".ajax-next",function(e){e.preventDefault();var _this=jQuery(this);if(_this.hasClass("pag-jump"))return!1;var _loader='<div class="text-center muted-2-color mt20"><i class="loading mr10"></i>'+aksrt__("loading")+"</div>";_this.attr("ajax-replace")&&(_loader='<div class="posts-item flex"><div class="post-graphic"><div class="radius8 item-thumbnail placeholder"></div> </div><div class="item-body flex xx flex1 jsb"> <p class="placeholder t1"></p> <h4 class="item-excerpt placeholder k1"></h4><p class="placeholder k2"></p><i><i class="placeholder s1"></i><i class="placeholder s1 ml10"></i></i></div></div>',_loader+=_loader,_loader+=_loader),_loader='<div class="mb20">'+_loader+"</div>";var t_con=_this.attr("ajaxpager-target")||".ajaxpager",t_item=_this.attr("ajaxitem-target")||".ajax-item",$item1=_this.parents(t_con+":eq(0)").find(t_item+":first"),$item1_class=$item1.attr("class");if($item1_class&&$item1_class.indexOf("posts-item")>-1)if($item1_class.indexOf("card")>-1){var loader_class=$item1_class.replace("ajax-item","");_loader='<div class="'+loader_class+'"><div class="item-thumbnail"><div class="radius8 item-thumbnail placeholder"></div> </div><div class="item-body "> <h2 class="item-excerpt placeholder t1 item-heading"></h2> <p class="mt10 placeholder k2"></p><i class="flex jsb"><i class="placeholder s1"></i><i class="placeholder s1 ml10"></i></i></div></div>',_loader=_loader.repeat(_wid>766?_wid>992&&!jQuery(".sidebar").length?8:6:4)}else $item1_class.indexOf("list")>-1&&(_loader='<div class="posts-item list flex"><div class="post-graphic"><div class="radius8 item-thumbnail placeholder"></div> </div><div class="item-body flex xx flex1 jsb"> <p class="placeholder t1"></p> <h4 class="item-excerpt placeholder k1"></h4><p class="placeholder k2"></p><i><i class="placeholder s1"></i><i class="placeholder s1 ml10"></i></i></div></div>',_loader=_loader.repeat(_wid>766?4:3));return post_ajax(_this,t_con,t_con,t_item,_loader,".ajax-pag")}),_wid<769&&jQuery(".drawer-sm").length){_win.bd.on("click","[data-drawer]",function(){var _this=jQuery(this),title=_this.attr("drawer-title")||"",drawer_selector=_this.attr("drawer-selector")||".drawer-sm",action=_this.attr("data-drawer"),route=_this.attr("route"),route_back=_this.attr("route-back");jQuery(drawer_selector).Drawer(action,title,route,route_back)});var this_url=(window.parent.location.origin+window.parent.location.pathname).replace(/(\/*$)/g,"");_win.url_request=window.parent.location.search,setTimeout(function(){jQuery('[data-drawer][route="'+this_url+'"]').click()},20)}else _win.bd.on("shown.bs.tab","[data-drawer][route]",tabOnRoute),_win.bd.on("hide.bs.tab","[data-drawer][route]",tabOnRoute_hidden);_win.bd.on("shown.bs.tab","[data-route]",tabOnRoute),_win.bd.on("hide.bs.tab","[data-route]",tabOnRoute_hidden);function tabOnRoute_hidden(){var _this=jQuery(this);if(!history.state){var route=_this.attr("route")||_this.attr("data-route"),tab_id=_this.attr("data-target");route&&history.replaceState({tab_id},null,route)}}function tabOnRoute(){var _this=jQuery(this);if(_this.attr("onpopstate"))_this.attr("onpopstate",!1);else{var route=_this.attr("route")||_this.attr("data-route"),tab_id=_this.attr("data-target");route&&routeGo(route,{tab_id})}}window.onpopstate=function(event){var tab=event.state&&jQuery('[data-toggle="tab"][data-target="'+event.state.tab_id+'"]');tab&&tab.length&&tab.attr("onpopstate",!0).click()};function routeGo(url,data,title){title=title||document.title,url&&history.pushState(data,title,url)}if(jQuery.fn.loading=function(action){var _this=jQuery(this);action=action=="show"||action=="hide"?action:_this.hasClass("loading-show")?"hide":"show";var loading_class="loading-backdrop",loading_html='<div class="'+loading_class+'" style="display:none;"><svg class="loading-circle" viewBox="0 0 50 50"><circle cx="25" cy="25" r="20"></circle></svg></div>';return action=="show"?_this.addClass("loading-show").append(loading_html).find("."+loading_class).fadeIn(200):_this.removeClass("loading-show").find("."+loading_class).fadeOut(200,function(){jQuery(this).remove()}),_this},jQuery.fn.Drawer=function(action,title,route,route_back){title=title||"";var _this=jQuery(this);if(!_this.length)return;action=action=="show"||action=="hide"?action:_this.hasClass("show")?"hide":"show";var _body=jQuery("body");_this.attr("on-start")||_this.attr("on-start",!0).minitouch({direction:"right",onEnd:function(){_this.Drawer("hide")}});function urlTo(url){history.replaceState(null,document.title,url)}switch(action){case"show":var header=jQuery('<div class="drawer-header flex ac"><div class="drawer-close"><i class="fa fas fa-angle-left em12"></i></div><div class="drawer-title">'+title+"</div></div>").on("click",".drawer-close",function(){_this.Drawer("hide")});return _body.append(header),setTimeout(function(){_body.addClass("drawer-show")},10),route_back&&_this.data("route_back",route_back),route&&urlTo(route),_this.addClass("show");case"hide":return _body.removeClass("drawer-show"),setTimeout(function(){jQuery(".drawer-header").remove()},400),urlTo(_this.data("route_back")),_this.removeClass("show");default:}},jQuery(".wp-block-carousel").length){jQuery("link#swiper").length||jQuery("head").append('<link type="text/css" id="swiper" rel="stylesheet" href="'+_win.uri+"/css/swiper.min.css?ver="+_win.ver+'">');var _sc=jQuery(".wp-block-carousel"),Sw=[];tbquire(["swiper"],function(){_sc.each(function(si){var _this=jQuery(this),_eq="swiper-post-"+si;_this.find(".wp-block-gallery>.blocks-gallery-grid").length&&_this.find(".wp-block-gallery").html(_this.find(".wp-block-gallery>.blocks-gallery-grid").html()),_this.find(".wp-block-gallery").removeClass().addClass("swiper-wrapper").find(".blocks-gallery-item,>.wp-block-image").addClass("swiper-slide"),_this.find(".carousel-control.left").replaceWith('<div class="swiper-button-next"></div>'),_this.find(".carousel-control.right").replaceWith('<div class="swiper-button-prev"></div><div class="swiper-pagination"></div>');var _ss=_this.find(".carousel"),proportion=_ss.attr("proportion")||.6,style=_ss.attr("style");_ss.addClass(_eq+" new-swiper scale-height").attr("style","--scale-height:"+proportion*100+"%;"),_this.attr("style",style);var delay=~~_ss.attr("data-interval")||6e3,loop=_ss.attr("data-jyloop")||!1,effect=_ss.attr("data-effect")||"slide",speed=~~((_ss.width()+1200)/250)*100;Sw["swiper_wz_"+si]=new Swiper(".wp-block-carousel ."+_eq,{spaceBetween:10,speed,loop,effect,autoplay:{delay,disableOnInteraction:!1},pagination:{el:"."+_eq+" .swiper-pagination",clickable:!0},navigation:{nextEl:"."+_eq+" .swiper-button-next",prevEl:"."+_eq+" .swiper-button-prev"}})})})}_win.bd.on("show.bs.modal loaded.bs.modal",".modal:not(.flex)",function(){var o=jQuery(this),i=o.find(".modal-dialog");o.css("display","block"),i.css({"margin-top":Math.max(0,(_hei-i.height())/2)})}),_win.bd.on("show.bs.modal loaded.bs.modal",".modal",function(){auto_fun()}),_win.modal_z_index=1050,_win.bd.on("show.bs.modal",".modal",function(){_win.modal_z_index++,jQuery(".modal.in").addClass("modal-parent"),jQuery(this).css("z-index",_win.modal_z_index).removeClass("modal-parent")}),_win.bd.on("hide.bs.modal",".modal",function(){jQuery(".modal.modal-parent").removeClass("modal-parent")}),_win.bd.on("click",".oauth-untying",function(){if(confirm(aksrt__("confirm_unbind"))==!0){var _this=jQuery(this),data={action:"user_oauth_untying",user_id:_this.attr("user-id"),type:_this.attr("untying-type"),_wpnonce:_this.attr("_wpnonce")};return aksrt_ajax(_this,data),!1}}),_win.bd.on("click",".medal-add-link",function(){if(confirm(aksrt__("confirm_grant_badge"))==!0)return aksrt_ajax(jQuery(this)),!1}),_win.bd.on("click",".medal-remove-link",function(){if(window.confirm(aksrt__("confirm_revoke_badge")))return aksrt_ajax(jQuery(this)),!1}),_win.bd.on("click","[tab-id]",function(e){var tab=jQuery(this).attr("tab-id");if(tab){var _tab=jQuery('a[data-target="#'+tab+'"]');_tab.length||(_tab=jQuery('a[href="#'+tab+'"]')),_tab.length&&(e.preventDefault(),_tab.tab("show"))}}),_win.bd.on("click",'[data-toggle="RefreshModal"]',function(e){e.preventDefault();var _this=jQuery(this),remote=_this.attr("data-remote");if(!remote){var action=_this.attr("data-action");action&&(remote=_win.ajax_url+"?action="+action)}return refresh_modal({class:_this.attr("data-class")||"",height:_this.attr("data-height")||300,mobile_from_bottom:!!_this.attr("mobile-bottom"),new:_this.attr("new"),touch_close:!_this.attr("no-touch"),remote}),!1}),_win.bd.on("click",".show-order-modal",function(e){e.preventDefault();var _this=jQuery(this),order_id=_this.attr("data-order-id"),is_new=_this.attr("new-modal");refresh_modal({class:"full-sm body-bg",height:420,mobile_from_bottom:!0,touch_close:!0,new:is_new,remote:_win.ajax_url+"?action=order_details_modal&order_id="+order_id})});function refresh_modal(_config){_config.mobile_from_bottom=typeof _config.mobile_from_bottom>"u"?!0:_config.mobile_from_bottom;var id="refresh_modal",is_new=_config.new,dataclass=_config.class||"",height=_config.height||200,mobile_bottom=_config.mobile_from_bottom&&_wid<769?" bottom":"",touch_close=typeof _config.touch_close>"u"?!0:_config.touch_close,modal_class="modal flex jc fade"+mobile_bottom,remote=_config.remote||"",content=_config.content||"";dataclass+=" modal-dialog",id+=is_new?parseInt((Math.random()+1)*Math.pow(10,4)):"";var _id="#"+id,_modal=jQuery(_id);if(_modal.length){var is_in=_modal.hasClass("in");is_in&&(modal_class+=" in");var $modal_content=_modal.find(".modal-content");_modal.removeClass().addClass(modal_class),_modal.find(".modal-dialog").removeClass().addClass(dataclass),_modal.find(".loading-mask").fadeIn(200),_modal.find(".modal-body").fadeOut(200),$modal_content.css({overflow:"hidden",height:is_in?$modal_content.height():100}).animate({height})}else{var modal_html='<div class="'+modal_class+'" id="'+id+'" tabindex="-1" role="dialog" aria-hidden="false"> <div class="'+dataclass+'" role="document"> <div class="modal-content"> </div> </div> </div>',loading='<div class="modal-body" style=""></div><div class="flex jc loading-mask absolute main-bg radius8"><div class="em2x opacity5"><svg class="loading-circle" viewBox="0 0 50 50"><circle cx="25" cy="25" r="20"></circle></svg></div></div>';_win.bd.append(modal_html),_modal=jQuery(_id),_modal.on("hidden.bs.modal",function(){is_new?jQuery(this).remove():jQuery(this).find(".modal-content").html(loading)}),_modal.find(".modal-content").html(loading).css({height,overflow:"hidden"}),_wid<769&&_modal.minitouch({direction:"bottom",selector:".modal-dialog",start_selector:".modal-colorful-header,.touch-close,.touch",onEnd:function(){_modal.modal("hide")},stop:function(){return!_modal.hasClass("bottom")}})}_modal.find(".touch-close").remove(),mobile_bottom&&touch_close&&_modal.find(".modal-dialog").append('<div class="touch-close"></div>'),_modal.modal("show"),content?(_modal.find(".modal-body").html(content),_modal_content_open()):remote&&jQuery.post(remote,null,function(data){_modal.find(".modal-body").html(data),setTimeout(function(){_modal.trigger("loaded.bs.modal")},20),_modal_content_open()});function _modal_content_open(){_modal.find(".modal-body").fadeIn(50,function(){var b_height=jQuery(this).outerHeight(!0);_modal.find(".loading-mask").fadeOut(300),_modal.find(".modal-content").animate({height:b_height},300,"swing",function(){_modal.find(".modal-content").css({height:"",overflow:"",transition:""})})})}return _modal}window.auto_maxHeight=debounce(z_auto,100);function z_auto(){if(_win.do_hh=document.documentElement.clientHeight,_win.do_hh>document.body.clientHeight){var min_h=_win.do_hh-jQuery(".footer").outerHeight()-jQuery(".header").outerHeight()-20;jQuery("main").animate({"min-height":min_h})}}window.auto_fun=debounce(z_auto_fun,100);function z_auto_fun(){jQuery(document).trigger("auto_fun"),jQuery(".auto-search").AutoSearch(),jQuery(".dependency-box").dependency(),jQuery(".cloneable").cloneable(),jQuery("[data-countdown]").countdown(),auto_maxHeight(),jQuery("img[data-src]:not(.lazyload,.lazyloaded,.lazyloading,.swiper-lazy)").addClass("lazyload"),jQuery(".dropdown-code,.dropdown-image,.dropdown-quick-often").length&&tbquire(["input-expand"]),jQuery("[aksrtupload]").length&&tbquire(["mini-upload"]),jQuery("[poster-share]").length&&tbquire(["poster-share"]),jQuery("[data-toggle='tooltip']").tooltip({container:"body"}),jQuery("[data-clipboard-text]").length&&tbquire(["clipboard"]),jQuery("[data-toggle='popover']").popover({sanitize:!1}),_wid>768?(jQuery(".fixed-wrap-nav").autoAffix(20,38),jQuery(".relative>.scroll-x.no-scrollbar").scrollX()):jQuery(".affix-header-sm").autoAffix(0,20),_wid>900&&jQuery(".sidebar").sidebarAffix(),new_swiper(),new_dplayer(),tbquire(["svg-icon"],()=>{show_svg()});var _h_e=_win.highlight_kg?"pre code:not(.enlighter-origin)":"pre code.gl:not(.enlighter-origin),pre code.special:not(.enlighter-origin)";jQuery(_h_e).length&&tbquire(["enlighterjs"],function(){var lin=!!_win.highlight_hh;jQuery("link#enlighterjs").length||jQuery("head").append('<link type="text/css" rel="stylesheet" href="'+_win.uri+"/js/runtime/enlighter/enlighterjs.min.css?ver="+_win.ver+'" id="enlighterjs">'),jQuery(_h_e).enlight({linenumbers:lin,indent:2,textOverflow:"scroll",rawcodeDbclick:!0,rawButton:!1,infoButton:!1,windowButton:!1,theme:_win.highlight_zt})}),_win.imgbox&&jQuery(".alone-imgbox-img,a[data-imgbox],.comment-content .box-img,.wp-posts-content img,.imgbox-container").length&&tbquire(["imgbox"])}(function(){var scroll_throttle=throttle(function(){var h=document.documentElement.scrollTop+document.body.scrollTop,ontop=jQuery(".ontop");h>100?_win.bd.addClass("body-scroll"):_win.bd.removeClass("body-scroll"),h>400?ontop.addClass("show"):ontop.removeClass("show")},100);_win.window.scroll(scroll_throttle);var debounce_scroll_end=debounce(function(){jQuery("[data-toggle='tooltip']").tooltip("hide")},500,!0);_win.window.scroll(debounce_scroll_end);var debounce_scrolling_hide=debounce(function(){_win.bd.addClass("scroll-ing")},500,!0),debounce_scrolling_hide_end=debounce(function(){_win.bd.removeClass("scroll-ing")},500);jQuery(".scrolling-hide").length&&_win.window.scroll(debounce_scrolling_hide).scroll(debounce_scrolling_hide_end);var _last_scroll_top=0,debounce_scroll_down=debounce(function(){var _scroll_top=document.documentElement.scrollTop+document.body.scrollTop;_last_scroll_top>100&&_scroll_top>_last_scroll_top?_win.auto_scroll||_win.bd.removeClass("scroll-up").addClass("scroll-down"):(!_win.auto_scroll||_last_scroll_top<=100)&&_win.bd.removeClass("scroll-down").addClass("scroll-up"),_last_scroll_top=_scroll_top},10,!0);jQuery(".scroll-down-hide").length&&_win.window.scroll(debounce_scroll_down)})();function scrollTopTo(element,offset){var scrollTop=0,body=jQuery("body,html"),duration=duration||300;if(offset=offset||0,element){var target=element instanceof jQuery?element:jQuery(element);scrollTop=target.length?target.offset().top+offset-(body.hasClass("nav-fixed")?jQuery(".header").innerHeight()+20:0):0}Math.abs(scrollTop-body.scrollTop())<80||(_win.auto_scroll=!0,body.animate({scrollTop},duration,"swing",function(){setTimeout(function(){_win.auto_scroll=!1},20)}))}_win.bd.on("click",".toggle-radius,.float-right a,.but-ripple,.but,.item-thumbnail,.menu-item >a,.yiyan-box,.relates-thumb li a",function(e){var _th=jQuery(this);if(!_th.hasClass("nowave")&&!_th.hasClass("is-disabled")){_th.css({overflow:"hidden",position:"relative"});var R,waveWidth=~~_th.outerWidth(),waveHeight=~~_th.outerHeight();waveWidth<waveHeight?R=waveHeight:R=waveWidth;var cllor=_th.css("color")||"rgba(200, 200, 200)",wave=jQuery("<div></div>").css({display:"block",background:cllor,"border-radius":"50%",position:" absolute","-webkit-transform":"scale(0)",transform:"scale(0)",opacity:".3","-webkit-transition":"all 1.5s cubic-bezier(0.22, 0.61, 0.36, 1)",transition:"all 1.5s cubic-bezier(0.22, 0.61, 0.36, 1)","z-index":"1",overflow:"hidden","pointer-events":"none"});_th.append(wave),wave.css({width:R*2+"px",height:R*2+"px",top:e.pageY-_th.offset().top-R+"px",left:e.pageX-_th.offset().left-R+"px",transform:"scale(1)","-webkit-transform":"scale(1)",opacity:0}),setTimeout(function(){wave.remove()},2e3)}}),jQuery.fn.sidebarAffix=function(){var _this=jQuery(this),_affix=_this.find("[data-affix]"),sidebar_class="sidebar-affix";if(!_affix.length||_this.children("."+sidebar_class).length)return _this;var _body=jQuery("body"),affix_width=_affix.innerWidth(),_header=jQuery(".header");function nav_Height(){return _body.hasClass("nav-fixed")&&(!_header.hasClass("scroll-down-hide")||!_body.hasClass("scroll-down"))?_header.outerHeight(!0):20}var sidebarAffix_con=jQuery('<div class="'+sidebar_class+' affix-top" style="width:'+affix_width+'px;"></div>');_this.prepend(sidebarAffix_con);function top_css(){sidebarAffix_con.css({top:nav_Height()})}var last_top=0;return sidebarAffix_con.affix({offset:{top:function(){var new_top=_this.outerHeight(!0)+_this.offset().top-nav_Height();return new_top!==last_top&&sidebarAffix_con.hasClass("affix")&&top_css(),last_top=new_top,new_top},bottom:function(){var _wrap=_this.parent();return document.body.clientHeight-_wrap.outerHeight()-_wrap.offset().top}}}).on("affix-top.bs.affix",function(){sidebarAffix_con.html("")}).on("affix.bs.affix",function(){sidebarAffix_con.find("[data-affix]").length||sidebarAffix_con.append(_this.find("[data-affix]").clone()),top_css()}).find("[lazyload-action]:not(.lazyload)").addClass("lazyload"),sidebarAffix_con.hasClass("affix")&&sidebarAffix_con.trigger("affix.bs.affix"),sidebarAffix_con.hasClass("affix-bottom")&&sidebarAffix_con.trigger("affix-bottom.bs.affix"),_this},jQuery.fn.autoAffix=function(top,bottom){top=~~top,bottom=~~bottom;var _this=jQuery(this);if(_this.data("bs.affix"))return _this;var _body=jQuery("body"),offset_top=~~_this.attr("offset-top"),offset_bottom=~~_this.attr("offset-bottom"),_wrap_attr=_this.attr("data-wrap"),_wrap=_wrap_attr?jQuery(_wrap_attr):_this.parent(),_header=jQuery(".header");function get_nav_Height(){return(_body.hasClass("nav-fixed")&&(!_header.hasClass("scroll-down-hide")||!_body.hasClass("scroll-down"))?_header.outerHeight():0)+top}function remove_clone(){_this.next(".affix-clone").remove()}function top_css(){_this.css({top:get_nav_Height()})}function this_clone(){_this.next(".affix-clone").length||_this.after(_this.clone().removeClass("affix-top affix affix-bottom").addClass("affix-clone").css("opacity","0"))}_wrap.css("min-height",_this.outerHeight()+bottom);var last_top=0;return _this.affix({offset:{top:function(){var new_top=_this.parent().offset().top-get_nav_Height()+offset_top;return new_top!==last_top&&_this.hasClass("affix")&&top_css(),last_top=new_top,new_top},bottom:function(){return document.body.clientHeight-_wrap.outerHeight()-_wrap.offset().top+bottom+offset_bottom}}}).on("affix-top.bs.affix",function(){_this.css({top:"",width:""}),remove_clone()}).on("affix.bs.affix",function(){this_clone(),top_css()}).on("affix-bottom.bs.affix",function(){this_clone()}),_this.hasClass("affix")&&_this.trigger("affix.bs.affix"),_this.hasClass("affix-bottom")&&_this.trigger("affix-bottom.bs.affix"),_this.hasClass("affix-top")&&_this.trigger("affix-top.bs.affix"),_this},_win.bd.on("click",".toggle-theme",function(event){var isDark=jQuery("body").hasClass("dark-theme");if(!document.startViewTransition){toggle();return}const transition=document.startViewTransition(()=>{toggle()}),{clientX,clientY}=event,endRadius=Math.hypot(Math.max(clientX,innerWidth-clientX),Math.max(clientY,innerHeight-clientY)),clipPath=[`circle(0px at ${clientX}px ${clientY}px)`,`circle(${endRadius}px at ${clientX}px ${clientY}px)`];transition.ready.then(()=>{document.documentElement.animate({clipPath:isDark?[...clipPath].reverse():clipPath},{duration:500,easing:isDark?"ease-out":"ease-in",fill:"both",pseudoElement:isDark?"::view-transition-old(root)":"::view-transition-new(root)"})});function toggle(){var highlight_white_zt="enlighter-t-"+_win.highlight_white_zt,highlight_dark_zt="enlighter-t-"+_win.highlight_dark_zt;jQuery("img[switch-src]").each(function(){var _this=jQuery(this),_src=_this.attr("data-src")||_this.attr("src"),_s_src=_this.attr("switch-src");_this.attr("src",_s_src).attr("switch-src",_src).attr("data-src","")}),jQuery("img[white-src],img[dark-src]").each(function(){var _this=jQuery(this),_s_src=isDark?_this.attr("white-src"):_this.attr("dark-src");_s_src&&_this.attr("src",_s_src)});var _enlighter=jQuery(".enlighter-default"),_body=jQuery("body"),_tinymce_body=jQuery("#post_content_ifr").contents().find("body");isDark?(jQuery('meta[name="theme-color"]').attr("content","#FDFCFE"),document.documentElement.classList.remove("dark"),_tinymce_body.removeClass("dark-theme"),_enlighter.removeClass(highlight_dark_zt).addClass(highlight_white_zt),_body.removeClass("dark-theme"),jQuery.cookie("theme_mode","white-theme",{path:"/"})):(jQuery('meta[name="theme-color"]').attr("content","#2F3135"),document.documentElement.classList.add("dark"),_tinymce_body.addClass("dark-theme"),_enlighter.removeClass(highlight_white_zt).addClass(highlight_dark_zt),_body.addClass("dark-theme"),jQuery.cookie("theme_mode","dark-theme",{path:"/"}))}}),_win.bd.on("click","[data-action]",function(){var _this=jQuery(this),s=_this.attr("data-pid"),key=_this.attr("data-action"),type=key,_type="aksrt"+type,data={type,key,pid:s};if(!_win.is_signin){var t=lcs.get(_type)||"";if(t.indexOf(","+s+",")!==-1)return notyf(aksrt__(type=="like"?"like_already_post":"like_already_comment"),"warning");t?t.length>=160?(t=t.substring(0,t.length-1),t=t.substr(1).split(","),t.splice(0,1),t.push(s),t=t.join(","),lcs.set(_type,","+t+",")):lcs.set(_type,t+s+","):lcs.set(_type,","+s+",")}action_ajax(_this,data,s,type,aksrt__("like_thanks"))});function action_ajax(_this,data,pid,type,text){if(_this.attr("disabled"))return!1;data._wpnonce=_win.post_action_nonce;var c=text||aksrt__("done");jQuery.ajax({type:"POST",url:_win.uri+"/action/action.php",dataType:"json",data,beforeSend:function(){_this.attr("disabled",!0).find("count").html('<i class="loading zts"></i>')},success:function(n){var ys=n.error?"danger":"";n.action&&n.action=="remove"&&(_this.removeClass("actived action-animation"),ys="warning"),n.action&&n.action=="add"&&_this.addClass("actived action-animation"),notyf(n.msg||c,ys),_this.attr("disabled",!1).find("count").html(n.cuont||"0"),type=="follow_user"&&jQuery('[data-action="follow_user"][data-pid="'+pid+'"]').each(function(){jQuery(this).find("count").html(n.cuont)})}})}_win.bd.on("click","[ajax-action]",function(){var _this=jQuery(this);if(_this.attr("disabled"))return!1;var id=_this.attr("data-id"),action=_this.attr("ajax-action"),_text=_this.find("text");_text=_text.length?_text:_this.siblings("text");var _this_html=_text.html();_this.attr("disabled",!0),_text.html('<i class="loading-spot"><i></i></i>'),jQuery.ajax({type:"POST",url:_win.ajax_url,dataType:"json",data:{id,action,_wpnonce:_this.attr("data-nonce")},error:function(n){var _msg=aksrt_sprintf("ajax_error",n.status,n.statusText);aksrt_is_fatal_error_response(n.responseText)&&(_msg=aksrt__("ajax_fatal_error")),notyf(_msg,"danger"),_this.attr("disabled",!1),_text.html(_this_html)},success:function(n){if(_this.attr("disabled",!1),!n.data||!n.success)_text.html(_this_html),n.data&&n.data.msg&¬yf(n.data.msg,n.data.ys||"danger");else{if(n=n.data,n.show_modal&&n.modal){var modal_config={class:"modal-mini full-sm",height:330,mobile_from_bottom:!0,touch_close:!0,content:n.modal};n.modal_config&&(modal_config=jQuery.extend(modal_config,n.modal_config)),modal_config.content=n.modal,refresh_modal(modal_config),_text.html(_this_html);return}jQuery('[ajax-action="'+action+'"][data-id="'+id+'"]').each(function(){var _this2=jQuery(this),_text2=_this2.find("text");_text2=_text2.length?_text2:_this2.siblings("text"),_text2.html(n.text||_this_html).addClass("ajaxed"),n.active?_this2.addClass("active").siblings(".active").removeClass("active"):_this2.removeClass("active")})}}})});function throttle(fn,delay){let valid=!0;return function(...args){if(!valid)return!1;valid=!1,setTimeout(function(){fn.apply(this,args),valid=!0},delay)}}function debounce(callback,delay,immediate){var timeout;return function(){var context=this,args=arguments,later=function(){timeout=null,immediate||callback.apply(context,args)},callNow=immediate&&!timeout;clearTimeout(timeout),timeout=setTimeout(later,delay),callNow&&callback.apply(context,args)}}if(_win.bd.on("input focus","textarea[autoHeight]",function(){var elem=this,border=~~getComputedStyle(elem).getPropertyValue("border-top-width").replace("px","")+~~getComputedStyle(elem).getPropertyValue("border-bottom-width").replace("px",""),max=~~jQuery(elem).attr("maxHeight");elem.style.height="auto",max>elem.scrollHeight?(elem.style.height=elem.scrollHeight+border+"px",elem.style.overflow="hidden"):(elem.style.height=max+"px",elem.style.overflow="auto")}),_win.bd.on("click",".rewards",function(){jQuery("#rewards-popover").modal("show")}),_win.bd.hasClass("author")&&tbquire(["author"]),_win.bd.hasClass("page-template-postsnavs")&&_win.bd.hasClass("logged-admin")&&tbquire(["page-navs"]),jQuery("#modal_admin_set").length&&tbquire(["page-edit"]),jQuery("#commentform,#postcomments").length&&tbquire(["comment"]),_win.bd.hasClass("page-template")&&tbquire(["page-template"]),window.WeChatShareDate&&tbquire(["weixin-share"]),_win.bd.hasClass("search")){var val=jQuery(".search-desc-text .search-key").text();try{var reg=eval("/"+val+"/i");jQuery(".search-tab .item-heading a,.search-tab .item-excerpt,.search-tab .forum-title a,.search-tab .excerpt,#search-tab-user .display-name").each(function(){var $this=jQuery(this);$this.text().search(reg)!=-1&&$this.html($this.html().replace(reg,function(w){return'<b class="focus-color">'+w+"</b>"}))})}catch(e){}}_win.bd.on("click",".pag-jump .jump-icon",function(){var _input=jQuery(this).siblings(".jump-input");pag_jump_go(_input)}),_win.bd.on("input",".pag-jump .jump-input",debounce(function(){pag_jump(jQuery(this))},200)),_win.bd.on("keydown",".pag-jump .jump-input",function(event){event.keyCode==13&&pag_jump_go(jQuery(this))});function pag_jump(_input){var max=_input.attr("max"),current=_input.attr("current"),val2=~~_input.val();return(!val2||val2<1||val2>max)&&(val2=val2>max?max:"",_input.val(val2)),val2==current?0:val2}function pag_jump_go(_input){var val2=pag_jump(_input);if(val2){var base=_input.attr("base"),url=base.replace("%#%",val2),parent=_input.parent();if(parent.hasClass("ajax-next")){_input.val("");var _ajax_link=parent.clone().removeClass("pag-jump").addClass("hide").attr("href",url);parent.append(_ajax_link),_ajax_link.click(),_ajax_link.remove()}else location.href=url,location.reload}else _input.focus()}jQuery.fn.cloneable=function(){var cloneable_text="cloneable",cloneable_add_e="."+cloneable_text+"-add",cloneable_remove_e="."+cloneable_text+"-remove",cloneable_item_e="."+cloneable_text+"-item";function max_min(_this,max,min){var count=_this.children(cloneable_item_e).length;max&&max<=count?_this.nextAll(cloneable_add_e).hide():_this.nextAll(cloneable_add_e).show(),min&&min>=count?_this.find(cloneable_remove_e).hide():_this.find(cloneable_remove_e).show()}return this.each(function(){var _this=jQuery(this),_item=_this.children(cloneable_item_e),is_on="is-on",click="click",max=_this.data("max")||0,min=_this.data("min")||0;if(max_min(_this,max,min),!(!_item.length||_this.attr(is_on))){var add_item=jQuery(_item[0]).clone(!1);add_item.find("input,textarea").val(""),_this.attr(is_on,!0).on(click,cloneable_remove_e,function(){jQuery(jQuery(this).parents(cloneable_item_e)[0]).remove(),max_min(_this,max,min)}).nextAll(cloneable_add_e).on(click,function(){var _add_item=add_item.clone(!1),count=_this.children(cloneable_item_e).length;_add_item.find("[name]").each(function(){var $this=jQuery(this),name=$this.attr("name");name=="_pseudo"||!name.includes("[0]")||$this.attr("name",$this.attr("name").replace("[0]","["+count+"]"))}),_this.append(_add_item),max_min(_this,max,min)})}})},jQuery.fn.dependency=function(){function _number(val2){return Number(val2)}function checkBoolean(v){switch(v){case!0:case"true":case 1:case"1":return!0;case null:case!1:case"false":case 0:case"0":return!1;default:return v}}function evalCondition(condition,val1,val2){switch(condition){case"==":return checkBoolean(val1)==checkBoolean(val2);case"!=":return checkBoolean(val1)!=checkBoolean(val2);case">=":return _number(val2)>=_number(val1);case"<=":return _number(val2)<=_number(val1);case">":return _number(val2)>_number(val1);case"<":return _number(val2)<_number(val1);case"any":if(jQuery.isArray(val2)){for(let i=val2.length-1;i>=0;i--)if(jQuery.inArray(val2[i],val1.split(","))!==-1)return!0}else if(jQuery.inArray(val2,val1.split(","))!==-1)return!0;return!1;case"not-any":if(jQuery.isArray(val2)){for(let i=val2.length-1;i>=0;i--)if(jQuery.inArray(val2[i],val1.split(","))==-1)return!0}else if(jQuery.inArray(val2,val1.split(","))==-1)return!0;return!1;default:return!1}}return this.each(function(){var $this=jQuery(this),$fields=$this.find("[data-controller]");if($fields.length){var is_on="is-on";$fields.each(function(){var $field=jQuery(this);if(!$field.attr(is_on)){var controllers=$field.attr(is_on,!0).data("controller").split("|"),conditions=$field.data("condition").split("|"),values=$field.data("value").toString().split("|");jQuery.each(controllers,function(index,depend_id){var value=values[index]||"",condition=conditions[index]||conditions[0]||"==";$this.on("change","[name='"+depend_id+"']",function(){var $elem=jQuery(this),_type=$elem.attr("type"),val2=_type=="checkbox"?$elem.is(":checked"):$elem.val(),is_show=evalCondition(condition,value,val2);$field.trigger("controller.change",is_show),is_show?$field.show():$field.hide()})})}})}})},_win.bd.on("click","[data-for]",function(){var _this=jQuery(this),_tt=_this.html(),_for=_this.attr("data-for"),_form=_this.parents("form"),_v=_this.attr("data-value"),multiple=~~_this.attr("data-multiple"),_group=_this.closest("[for-group]"),active_outerHTML=_this.prop("outerHTML");if(_group.length||(_group=_this.parent()),multiple>1){_tt="",active_outerHTML="";var active_array=[],_input="",is_active=_this.hasClass("active");if(is_active)_group.find('[data-for="'+_for+'"][data-value="'+_v+'"]').removeClass("active");else{var ii={};if(_group.find('[data-for="'+_for+'"].active').each(function(){ii[jQuery(this).attr("data-value")]=1}),Object.keys(ii).length>=multiple)return notyf(aksrt_sprintf("select_max",multiple),"danger");_group.find('[data-for="'+_for+'"][data-value="'+_v+'"]').addClass("active")}_group.find('[data-for="'+_for+'"].active').each(function(){var _this_value=jQuery(this).attr("data-value");active_array.indexOf(_this_value)==-1&&(_tt+=jQuery(this).html(),_input+='<input type="hidden" name="'+_for+'[]" value="'+_this_value+'">',active_array.push(_this_value),active_outerHTML+=jQuery(this).clone().addClass("outerhtml-copy").prop("outerHTML"))}),jQuery.each(active_array,function(index,value){_group.find('[data-for="'+_for+'"][data-value="'+value+'"]').addClass("active")}),_form.find("input[name='"+_for+"[]']").remove(),_form.append(_input)}else _group.find('[data-for="'+_for+'"]').removeClass("active"),_group.find('[data-for="'+_for+'"][data-value="'+_v+'"]').addClass("active"),_form.find("input[name='"+_for+"']").val(_v).trigger("change");_form.find("span[name='"+_for+"']").html(_tt),_form.find("input[name=s]").focus(),_form.find(".active-outerhtml[name='"+_for+"']").html(active_outerHTML)}),_win.bd.on("input","input[limit-min],input[limit-max]",debounce(function(){var _this=jQuery(this),min=Number(_this.attr("limit-min")),max=Number(_this.attr("limit-max")),val2=Number(_this.val()),text,warning_class="limit-warning";_this.next("."+warning_class).length||_this.after('<div class="limit-warning" style="display: none;"></div>');var _warning=_this.next("."+warning_class);_this.val().length<1?_warning.html("").hide():val2>max?(text=_this.attr("warning-max")||aksrt__("input_max"),_warning.html(text.replace("1$",max)).fadeIn(150)):val2<min?(text=_this.attr("warning-min")||aksrt__("input_min"),_warning.html(text.replace("1$",min)).fadeIn(150)):_warning.fadeOut(150)},500)),jQuery.fn.AutoSearch=function(){return this.each(function(){var _this=jQuery(this),ajax_url=_this.attr("ajax-url")||_win.ajax_url,min_length=2,search="search-",d_search="."+search,loading=search+"loading",input=d_search+"input",centent=search+"centent",_container=_this.find(d_search+"container"),_remind=_this.find(d_search+"remind"),_icon=_this.find(d_search+"icon"),_icon_html=_icon.html(),min_length_remind=aksrt_sprintf("search_min_chars",min_length),loading_icon='<i class="loading em12"></i>',loading_remind=loading_icon+'<span class="ml6">'+aksrt__("search_loading")+"</span>",is_on="is-on";if(_this.data(is_on))return;function ajax(){var data={},serializeObject=_this.serializeObject();jQuery.each(serializeObject,function(key,val2){data[key]=val2}),_this.find("input[name]").each(function(){var _th=jQuery(this),v=_th.val()||"";data[_th.attr("name")]=v}),_this.addClass(loading),_remind.html(loading_remind),_icon.html(loading_icon),_container.css({height:_container.outerHeight(),overflow:"hidden"}),jQuery.post(ajax_url,data,function(result){var data_html=result.data;data_html&&_container.html('<div class="'+centent+'">'+data_html+"</div>").animate({height:_container.children("."+centent).outerHeight()},200,"swing",function(){_container.css({height:"",overflow:"",transition:""})}),_this.removeClass(loading),_remind.html(result.remind||""),_icon.html(_icon_html),auto_fun()},"json")}function submitted(_input){_input.val().length>=min_length?ajax():_remind.html(min_length_remind)}_this.data(is_on,!0).find(input).on("input",debounce(function(){submitted(jQuery(this))},500)).on("keydown",function(event){event.keyCode==13&&(event.preventDefault(),submitted(jQuery(this)))})})},_win.bd.on("click",".main-search [data-for]",function(){var _placeholder=jQuery(".main-search").find(".scale-placeholder");_placeholder.length&&_placeholder.text(_placeholder.attr("default"))}),_win.bd.on("submit",".main-search form",function(){var _this=jQuery(this),inputs=_this.serializeObject();jQuery.each(inputs,function(k,v){(!v||v=="null")&&k!="s"&&_this.find('input[name="'+k+'"]').remove()})}),_win.bd.on("click",".main-search-btn",function(){var _this=jQuery(this);jQuery(".main-search").addClass("show");var _remote_search=jQuery(".main-search [remote-box]").first();if(_remote_search.length){_remote_search.one("aksrt:remote-loaded",function(){_this.trigger("click")}),_remote_search.trigger("click");return}var _search_form=jQuery(".main-search form");if(_search_form.length){var attr_="search-",obj={type:_this.attr(attr_+"type"),user:_this.attr(attr_+"user"),trem:_this.attr(attr_+"trem")};jQuery.each(obj,function(k,v){if(v){var _k=_search_form.find('input[name="'+k+'"]').val(v),_data_for=_search_form.find('[data-for="'+k+'"][data-value="'+v+'"]').click();if(!_data_for.length&&k=="trem"){var cat_name=_this.attr("trem-name"),_cat_drop=_search_form.find(".cat-drop");cat_name&&_cat_drop.length&&(_cat_drop.append('<li data-for="trem" data-value="'+v+'"><a href="javascript:;">'+cat_name+"</a></li>"),_cat_drop.find('[data-value="'+v+'"]').click())}_k.length||_search_form.append('<input type="hidden" name="'+k+'" value="'+v+'">')}});var placeholder=_this.attr(attr_+"placeholder")||_search_form.find(".scale-placeholder").attr("default");_search_form.find(".scale-placeholder").text(placeholder),setTimeout(function(){_search_form.find('[name="s"]').focus()},100)}}),jQuery(".search-page-ajaxpager").length&&(_win.bd.on("click",".page-search-box a.search_keywords",function(){var $this=jQuery(this).clone();return $this.addClass("ajax-next").attr("ajax-replace","true").attr("route","true"),jQuery(".search-page-ajaxpager").append($this),$this.click().remove(),!1}),_win.bd.on("submit",".page-search-box .search-form",function(){var $this=jQuery(this),data=$this.serializeObject(),url=new URL($this.attr("action"));url.search=new URLSearchParams(data).toString();var $link=jQuery('<a class="ajax-next" ajax-replace="1" route="1" href="'+url.href+'"></a>');return jQuery(".search-page-ajaxpager").append($link),$link.click().remove(),!1}));function nav_folding(){var navbar_nav_t=".navbar-nav",sub_menu_t="sub-menu",_collapse=jQuery(".navbar-collapse"),surplus_width=_collapse.width();_collapse.find(">:not("+navbar_nav_t+")").each(function(){surplus_width-=jQuery(this).outerWidth()}),surplus_width-=jQuery(".navbar-header").outerWidth()+40;var navs_width=66,_folding=jQuery('<li class="menu-item"><a href="javascript:void(0);"><svg class="em12" aria-hidden="true" data-viewbox="0 0 1024 1024" viewBox="0 0 1024 1024"><use xlink:href="#icon-menu_2"></use></svg></a><ul class="'+sub_menu_t+'"></ul></li>');jQuery(navbar_nav_t+">li").each(function(){navs_width+=jQuery(this).outerWidth(),navs_width>surplus_width&&_folding.find(">."+sub_menu_t).append(jQuery(this))}),_folding.find(">."+sub_menu_t+" li").length&&jQuery(navbar_nav_t).append(_folding)}window.debounce_notyf=debounce(notyf,100,!0);function notyf(str,ys,time,id){jQuery(".notyn").length||_win.bd.append('<div class="notyn"></div>'),ys=ys||"success",ys=="error"&&(ys="danger"),time=time||5e3,time=time<100?time*1e3:time;var id_attr=id?' id="'+id+'"':"",_html=jQuery('<div class="noty1"'+id_attr+'><div class="notyf '+ys+'">'+str+"</div></div>"),is_close=!id;id&&jQuery("#"+id).length?(jQuery("#"+id).find(".notyf").removeClass().addClass("notyf "+ys).html(str),_html=jQuery("#"+id),is_close=!0):jQuery(".notyn").append(_html),is_close&&setTimeout(function(){notyf_close(_html)},time)}function notyf_close(_e){_e.addClass("notyn-out"),setTimeout(function(){_e.remove()},1e3)}_win.bd.on("click",".noty1",function(){notyf_close(jQuery(this))}),_win.passw=1,_win.bd.on("click",".passw",function(){var _this=jQuery(this);_win.passw==1?(_this.find(".fa").addClass("fa-eye-slash"),_this.siblings("input").attr("type","text"),_win.passw=2):(_this.find(".fa").removeClass("fa-eye-slash"),_this.siblings("input").attr("type","password"),_win.passw=1)}),_win.bd.on("input change focus",".line-form-input",debounce(function(){placeholder_scale(jQuery(this))},100));function placeholder_scale(_this){var val2=_this.val(),placeholder=_this.siblings(".scale-placeholder");val2.length>0?placeholder.addClass("is-focus"):placeholder.removeClass("is-focus")}function aksrt_is_url(str){try{return new URL(str),!0}catch{return!1}}function is_mail(str){return/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/.test(str)}jQuery.fn.serializeObject=function(){var o={},a=this.serializeArray();return jQuery.each(a,function(){o[this.name]!==void 0?(o[this.name].push||(o[this.name]=[o[this.name]]),o[this.name].push(this.value||"")):o[this.name]=this.value||""}),o},_win.bd.on("click",".trash-history-search",function(){confirm(aksrt__("confirm_clear_search"))==!0&&(jQuery(".history-search").slideUp().delay(1e3,function(){jQuery(this).remove()}),jQuery.cookie("history_search",""))}),_win.bd.on("click",".initiate-checkin",function(){aksrt_ajax(jQuery(this),0,function(data){data.details_link&&jQuery(".initiate-checkin").each(function(){var $link=jQuery(data.details_link),_this=jQuery(this),_class=_this.attr("class"),_text=_this.attr("ed-text");$link.addClass(_class).removeClass("initiate-checkin").html(_text),_this.prop("outerHTML",$link.prop("outerHTML"))})},aksrt__("checkin_loading"))}),_win.bd.on("click",".single-pay-tabbar",function(){scrollTo("#posts-pay",-50),jQuery("#posts-pay .cashier-link").click()}),_win.bd.on("submit","[ajax-submit]",function(){var _this=jQuery(this),but=_this.attr("ajax-submit")||'.wp-ajax-submit,[zibajax="submit"]';return _this.find(but).click(),!1}),_win.bd.on("click",'.wp-ajax-submit,[zibajax="submit"]',function(){var _this=jQuery(this),confirm_text=_this.attr("data-confirm");return confirm_text&&!confirm(confirm_text)||aksrt_ajax(jQuery(this)),!1});function aksrt_ajax(_this,data,success,noty,no_loading){if(_this.attr("disabled"))return!1;if(!data){var _data=_this.attr("form-data");if(_data)try{data=jQuery.parseJSON(_data)}catch{}if(!data){var form=_this.parents("form");data=form.serializeObject()}}var _action=_this.attr("form-action");_action&&(data.action=_action);var _text=_this.html(),_loading=no_loading?_text:'<i class="loading mr6"></i><text>'+aksrt__("please_wait")+"</text>";noty!="stop"&¬yf(noty||aksrt__("processing"),"load","","wp_ajax"),_this.attr("disabled",!0).html(_loading);var _url=_this.attr("ajax-href")||_win.ajax_url;jQuery.ajax({type:"POST",url:_url,data,dataType:"json",error:function(n){var _msg=aksrt_sprintf("ajax_error",n.status,n.statusText);aksrt_is_fatal_error_response(n.responseText)&&(_msg=aksrt__("ajax_fatal_error")),console.error("ajax请求错误,错误信息如下:",n),notyf(_msg,"danger","",noty!="stop"?"wp_ajax":""),_this.attr("disabled",!1).html(_text)},success:function(n){var ys=n.ys?n.ys:n.error?"danger":"";noty!="stop"?notyf(n.msg||aksrt__("done"),ys,"","wp_ajax"):n.msg&¬yf(n.msg,ys),_this.attr("disabled",!1).html(_text).trigger("aksrt_ajax.success",n),jQuery.isFunction(success)&&success(n,_this,data),n.hide_modal&&_this.closest(".modal").modal("hide"),n.reload&&(n.goto?(window.location.href=n.goto,window.location.reload):window.location.reload())}})}_win.bd.on("aksrt_ajax.success","[next-tab]",function(e,n){var _next=jQuery(this).attr("next-tab");_next&&n&&!n.error&&jQuery('a[href="#'+_next+'"]').tab("show")}),jQuery(".erphp-login-must").each(function(){jQuery(this).addClass("signin-loader")}),_win.window.resize(debounce(function(){_wid=_win.window.width(),auto_fun()},500)),jQuery(".collapse").on("shown.bs.collapse",function(){auto_fun()}),_win.bd.on("click",".read-more-open",function(){jQuery(this).parents(".limit-height").css({height:"","max-height":""}).find(".read-more").remove()});function posts_limit_height(){if(jQuery(".limit-height").length){var r=jQuery(".limit-height");if(r.data("posts-limit-ison"))return;var r_h=r.height(),r_m=r.attr("data-maxheight");if(~~r_h>=~~r_m+79){var nn='<div class="read-more"><a href="javascript:;" class="read-more-open">'+aksrt__("read_more")+'<i class="fa ml10 fa-angle-down"></i></a></div>';r.append(nn).data("posts-limit-ison",!0)}}}auto_fun(),thumb_dplayer(_wid>640?".posts-item .item-thumbnail,.forum-lists-cover":".posts-item,.forum-posts",".video-thumb-box[video-url]"),jQuery("[load-click]").attr("no-scroll",!0).click(),jQuery(document).on("lazybeforeunveil",function(e){var _this=jQuery(e.target),lazyload_action=_this.attr("lazyload-action");setTimeout(function(){if(lazyload_action==="ias")if(_this.attr("remote-box"))_this.click();else{var _a=_this.is(".ajax-next,.ias-btn")?_this:_this.find(".ajax-next,.ias-btn");_a.attr("no-scroll",!0).click()}if(lazyload_action=="animated"){var animated=_this.attr("data-animated");animated&&_this.addClass("animated "+animated).css("visibility","unset")}},200);var bg=_this.attr("data-bg");bg&&_this.css("background-image","url("+bg+")")});function fps_yh(){var lastTime=0,frames=0,fps=0,fps_average=0,currentTime,stop=0;function updateFPS(){currentTime=performance.now(),frames++,currentTime-lastTime>=300&&(fps=Math.round(frames*1e3/(currentTime-lastTime)),frames=0,lastTime=currentTime,fps>5&&lastTime>1600&&(fps_average=fps_average||fps,fps_average=(fps_average+fps)/2,fps_average<20&&stop++,stop>5&&jQuery("body").addClass("fps-accelerat"))),stop<=5&&lastTime<15e3?requestAnimationFrame(updateFPS):setCookie()}function setCookie(){jQuery.cookie("fps_accelerat",~~fps_average,{path:"/",expires:604800})}requestAnimationFrame(updateFPS)}!jQuery.cookie("fps_accelerat")&&!jQuery("body").hasClass("fps-accelerat")&&fps_yh();function partners_scroll_init(){function init(widget){if(!(!widget||widget.dataset.zpsReady==="1")){var speed=parseFloat(widget.style.getPropertyValue("--zps-speed"))||3,rows=widget.querySelectorAll("[data-zps-row]");rows.forEach(function(row){var track=row.querySelector("[data-zps-track]");if(track){var seed=track.querySelector(".zps-group");if(seed){var setup=function(){var extras=track.querySelectorAll(".zps-group.zps-clone");extras.forEach(function(el){el.remove()});var groupWidth=seed.scrollWidth;if(!(groupWidth<10)){var rowWidth=row.clientWidth||widget.clientWidth||window.innerWidth,needTotal=Math.max(groupWidth*2,rowWidth+groupWidth),copies=Math.ceil(needTotal/groupWidth);copies<2&&(copies=2);for(var i=1;i<copies;i++){var clone=seed.cloneNode(!0);clone.classList.add("zps-clone"),clone.setAttribute("aria-hidden","true"),track.appendChild(clone)}track.style.setProperty("--zps-shift","-"+groupWidth+"px");var duration=groupWidth/100*speed;duration<4&&(duration=4),track.style.setProperty("--zps-duration",duration.toFixed(2)+"s"),track.setAttribute("data-zps-ready","1")}};setup();var imgs=seed.querySelectorAll("img"),pending=0;imgs.forEach(function(img){if(!(img.complete&&img.naturalWidth>0)){pending++;var done=function(){pending--,pending<=0&&setup()};img.addEventListener("load",done,{once:!0}),img.addEventListener("error",done,{once:!0})}});var resizeTimer;window.addEventListener("resize",function(){clearTimeout(resizeTimer),resizeTimer=setTimeout(setup,200)})}}}),widget.dataset.zpsReady="1"}}function initAll(){document.querySelectorAll(".aksrt-partners-scroll").forEach(init)}initAll()}function translate_init(){var translate_config=_win.translate_config;translate_config.s&&tbquire(["translate"],function(){translate.selectLanguageTag.show=!1,translate.language.setLocal(translate_config.local||"chinese_simplified"),translate_config.service_url&&translate.request.setHost(translate_config.service_url),translate_config.ignore_text&&(translate.ignore.text=translate_config.ignore_text),translate_config.nomenclature&&translate_config.nomenclature.length>0&&jQuery.each(translate_config.nomenclature,function(index,item){var from=item.from,to=item.to,value=item.value;from=="auto"&&(from=""),value&&to&&translate.nomenclature.append(from,to,value)}),translate_config.auto_discriminate_local&&translate.setAutoDiscriminateLocalLanguage(),translate_config.range&&translate_config.range.length>0&&(translate.language.translateLanguagesRange=translate_config.range),translate_config.loading&&translate.progress.api.startUITip();var $language_dropdown=jQuery(".language-dropdown .dropdown-menu"),translateStart=debounce(function(){jQuery("[data-language]").removeClass("active"),$language_dropdown.loading("show")},400,!0);translate.lifecycle.changeLanguage.trigger.push(translateStart);var renderFinish=debounce(function(uuid){$language_dropdown.loading("hide"),jQuery("[data-language='"+uuid.to+"']").addClass("active")},400);translate.lifecycle.execute.finally.push(renderFinish),_wid>996&&jQuery(".navbar-top .nav>li>a>.menu-item-title").each(function(){var _this=jQuery(this);_this.css({"max-width":~~_this.outerWidth(!0)+5+"px"})}),translate.ignore.class.push("translate-ignore"),translate.ignore.tag.push("svg"),translate.service.use(translate_config.service_use||"client.edge"),translate.listener.start(),translate.execute()})}_win.bd.on("click",".translate-button",function(){var _this=jQuery(this),language=_this.attr("data-language");translate&&translate.changeLanguage(language)}),(function(){var SELECTOR_class="obs-animate",SELECTOR="."+SELECTOR_class,BASE_CLS="in-view",OBS_FLAG="__zaniObserved",REPEAT_CLS="obs-animate-repeat",noAnim=!("IntersectionObserver"in window)||window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(noAnim){removeAnimation(SELECTOR);return}var rootMargin="100px 0px 0px 0px",c_i=0;function execute(entries){c_i=0;for(var isIntersecting_count=0,j=0;j<entries.length;j++)entries[j].isIntersecting&&isIntersecting_count++;for(var i=0;i<entries.length;i++){var entry=entries[i],el=entry.target,$el=jQuery(el);$el.css("transition-delay","");var is_repeat=el.hasAttribute("data-animation-repeat")||el.classList.contains(REPEAT_CLS);if(entry.isIntersecting){var delay=c_i*.11;isIntersecting_count>8&&(delay=delay/(isIntersecting_count/8)),$el.css("transition-delay",delay+"s"),$el.addClass(BASE_CLS),c_i++,is_repeat||stop(el)}else is_repeat&&$el.removeClass(BASE_CLS)}}var io=new IntersectionObserver(execute,{root:null,rootMargin,threshold:.01});function stop(el){!el||el.nodeType!==1||!el[OBS_FLAG]||(el[OBS_FLAG]=!1,io.unobserve(el),setTimeout(function(){removeAnimation(el)},50))}function removeAnimation(el){var animation=jQuery(el).attr("data-animation"),animation_class="ani-"+animation;jQuery(el).removeClass(BASE_CLS+" "+SELECTOR_class+" "+animation_class+" "+REPEAT_CLS).removeAttr("data-animation").removeAttr("data-animation-repeat").css("transition-delay","")}function register(el){!el||el.nodeType!==1||el[OBS_FLAG]||(el[OBS_FLAG]=!0,io.observe(el))}function scan(){jQuery(SELECTOR).each(function(){register(this)})}scan()})();function number_stats_init(){function animateCount(el,duration){var target=parseFloat(el.getAttribute("data-target"))||0;if(target===0){el.textContent="0";return}var raw=el.getAttribute("data-target")||"0",decimals=(raw.split(".")[1]||"").length,_duration=~~el.getAttribute("data-duration");duration=_duration>10?_duration:duration;var start=0,startTs=null;duration=duration||1500;function step(ts){startTs||(startTs=ts);var progress=Math.min((ts-startTs)/duration,1),eased=1-Math.pow(1-progress,1.5),value=start+(target-start)*eased;el.textContent=decimals>0?value.toFixed(decimals):Math.floor(value).toString(),progress<1?requestAnimationFrame(step):el.textContent=decimals>0?target.toFixed(decimals):target.toString()}requestAnimationFrame(step)}var wraps=document.querySelectorAll(".stat-number-wrap");if(wraps.length){if(!("IntersectionObserver"in window)){wraps.forEach(function(wrap){wrap.querySelectorAll(".stat-number").forEach(function(el){el.textContent=el.getAttribute("data-target")||""})});return}var io=new IntersectionObserver(function(entries){entries.forEach(function(entry){if(entry.isIntersecting){var wrap=entry.target;wrap.dataset.counted!=="1"&&(wrap.dataset.counted="1",wrap.querySelectorAll(".stat-number").forEach(function(el){animateCount(el,1500)}),io.unobserve(wrap))}})},{threshold:.3});wraps.forEach(function(wrap){io.observe(wrap)})}}_win.bd.on("click",".produck-wid-feature-intro .fi-tab",function(){var _this=jQuery(this);if(!_this.hasClass("is-active")){_this.addClass("is-active"),_this.siblings().removeClass("is-active");var panels=_this.closest(".produck-wid-feature-intro").find(".fi-panel");panels.removeClass("is-active"),panels.eq(_this.index()).addClass("is-active")}});function tilt_cases_init(){function isTouchOrMobile(){var isTouch="ontouchstart"in window||navigator.maxTouchPoints&&navigator.maxTouchPoints>0,isSmall=window.matchMedia&&window.matchMedia("(max-width: 768px)").matches;return isTouch||isSmall}if(isTouchOrMobile())return;var cases=jQuery(".vanilla-tilt:not(.is-initialized)");if(!cases.length)return;function setTranslate3d(imgs,translate3d){var transform=imgs[0].style.transform;transform.includes("translate3d")&&(transform=transform.replace(/translate3d\(.*?\)/g,"").trim()),transform=transform+" "+translate3d,imgs.css("transform",transform)}tbquire(["tilt"],function(){cases.each(function(){var _this=jQuery(this),imgs=_this.find("img"),maxTilt=parseFloat(_this.attr("data-tilt-max"))||10,n=imgs.length,gain=1.22,hoverZone=_this.closest(".tilt-cases-container")||_this,mes=_this.data("tilt-mouse-event-element");if(mes){_this.removeAttr("data-tilt-mouse-event-element");var elZone=_this.closest(mes);hoverZone=elZone.length?elZone:hoverZone}var opt={};hoverZone.length&&(opt["mouse-event-element"]=hoverZone[0]),_this.addClass("is-initialized"),VanillaTilt.init(this,opt),!(n<=1)&&(this.addEventListener("tiltChange",function(e){var detail=e.detail||{},tx=parseFloat(detail.tiltX)||0,ty=parseFloat(detail.tiltY)||0;imgs.each(function(i){var $img=jQuery(this),base=parseFloat($img.attr("data-tilt-depth"));if(isNaN(base)&&(base=20),base===0){setTranslate3d($img,"translate3d(0,0,0)");return}var layerMul=1;n>1&&(layerMul=.48+i/(n-1)*1.14);var effective=base*gain*layerMul,dx=tx/maxTilt*effective*-1,dy=ty/maxTilt*effective;setTranslate3d($img,"translate3d("+dx+"px, "+dy+"px, 0)")})}),hoverZone&&hoverZone.on("mouseleave",function(){imgs.each(function(){setTranslate3d(jQuery(this),"translate3d(0,0,0)")})}))})})}_win.bd.on("click",".customize-preview-widget-edit",function(e){if(!(!wp||!wp.customize||!wp.customize.widgetsPreview)){var _this=jQuery(this),box=_this.closest(".customize-preview-widget-box");e.preventDefault(),wp.customize.widgetsPreview.preview.send("focus-widget-control",box.prop("id"))}}),jQuery(document).ready(function(){if(setTimeout(function(){jQuery(".line-form-input").each(function(){placeholder_scale(jQuery(this))}),_win.views&&jQuery.post(_win.ajax_url,{action:"views_record",id:_win.views}),posts_limit_height(),_win.window.trigger("scroll")},1e3),number_stats_init(),translate_init(),partners_scroll_init(),tilt_cases_init(),jQuery(".navbar-top li.menu-item-has-children>a").each(function(){jQuery(this).append('<i class="fa fas fa-angle-down ml6"></i>')}),_wid>996&&jQuery(".header").height()>81&&nav_folding(),posts_limit_height(),auto_maxHeight(),jQuery(".feature").length){var _feh=0,_fehm=0;jQuery(".feature").each(function(){var _th=jQuery(this);(_feh=_th.find(".feature-icon").innerHeight()+_th.find(".feature-title").innerHeight()+_th.find(".feature-note").innerHeight())>_fehm&&(_fehm=_feh)}),jQuery(".feature").css("height",_fehm)}jQuery(".qrcode").length&&tbquire(["qrcode"],function(){jQuery(".qrcode").each(function(){var _this=jQuery(this),text=_this.attr("data-qrcode"),size=_this.attr("data-size")||160;_this.qrcode({width:size,height:size,correctLevel:0,text:text||document.URL,background:"#fff",foreground:"#333"})})}),jQuery(document).on("lazyloaded",function(e){var _this=jQuery(e.target);swiper_tab_AutoHeight(_this)}),jQuery(document).on("lazyloaded",".gradient-bg img",function(e){var _this=jQuery(e.target),_parent=_this.closest(".gradient-bg"),opacity=_parent.attr("data-opacity"),c_11=opacity?"a":"",c_12=opacity?","+opacity:"";tbquire(["grade"],function(){Grade(_parent[0],null,function(gradientData){gradientData=gradientData[0];var rgba=gradientData.gradientData,c_1="rgb"+c_11+"("+rgba[0].rgba.slice(0,3).join(",")+c_12+") 10%",c_2="rgb"+c_11+"("+rgba[1].rgba.slice(0,3).join(",")+c_12+") 80%";jQuery(gradientData.element).addClass("gradient-bg-loaded").css("background-image","linear-gradient(135deg, "+c_1+", "+c_2+")")})})}),_win.qj_loading&&jQuery(".qj_loading").fadeOut(500).delay(1e3,function(){jQuery(this).remove(),jQuery("#qj_dh_css").remove()});function yiyan_nr(n){var yylink=_win.uri+"/yiyan/qv-yiyan.php",y_nr;jQuery.ajax({type:"POST",url:yylink}).done(function(i){var lines=i.replace(/\r\n|\r/g,"/&/").trim().split("/&/");if(lines){var type=n.attr("type");type?y_nr=type==="en"?lines[0]:lines[1]:y_nr='<div class="cn">'+lines[0]+'</div><div class="en">'+lines[1]+"</div>",n.html(y_nr)}})}jQuery(".yiyan").each(function(){yiyan_nr(jQuery(this))}),setInterval(function(){jQuery(".yiyan").each(function(){yiyan_nr(jQuery(this))})},3e4),jQuery(".yiyan").on("click",function(){yiyan_nr(jQuery(this))}),jQuery("[data-nav] h1,[data-nav] h2,[data-nav] h3,[data-nav] h4").length>2&&tbquire(["section-navs"]),jQuery("[mini-touch]").each(function(){var _this=jQuery(this),fx=_this.attr("touch-direction");_this.minitouch({direction:fx,onEnd:function(e){_this.attr("mini-touch")==="mobile-nav"?jQuery("body").removeClass("mobile-navbar-show"):e.removeClass("show")}})})});
|
||
;
|
||
|
||
/* source: assets/js/captcha-front.js */
|
||
/**
|
||
* AKSRT Captcha front-end runtime — cloud providers only (tencent / aliyun / cloudflare / geetest).
|
||
*
|
||
* PHP renders passive mounts via [data-aksrt-captcha-config] (JSON config attribute);
|
||
* this script scans them, registers AKSRTCaptchaState.scenes[scene], loads the provider
|
||
* SDK once per page, and writes verified tokens back into the surrounding form.
|
||
* Bundled into assets/js/build/public.js by tools/build-public-assets.mjs.
|
||
*/
|
||
(function () {
|
||
'use strict';
|
||
|
||
var TOKEN_FIELDS = [
|
||
'cf_turnstile_response',
|
||
'tencent_ticket', 'tencent_randstr', 'tencent_sid',
|
||
'geetest_lot_number', 'geetest_captcha_output', 'geetest_pass_token', 'geetest_gen_time',
|
||
'aliyun_captcha_verify_param'
|
||
];
|
||
|
||
var root = (window.AKSRTCaptchaState = window.AKSRTCaptchaState || { loaders: {}, scenes: {} });
|
||
root.rescan = scan;
|
||
|
||
function scan() {
|
||
var mounts = document.querySelectorAll('[data-aksrt-captcha-config]');
|
||
Array.prototype.forEach.call(mounts, function (el) {
|
||
if (el.dataset.aksrtCaptchaBound) {
|
||
return;
|
||
}
|
||
el.dataset.aksrtCaptchaBound = '1';
|
||
var config;
|
||
try {
|
||
config = JSON.parse(el.getAttribute('data-aksrt-captcha-config'));
|
||
} catch (e) {
|
||
return;
|
||
}
|
||
if (config && config.scene && config.uid && config.vid) {
|
||
initMount(config);
|
||
}
|
||
});
|
||
}
|
||
|
||
/**
|
||
* One mount = one scene instance. Mirrors the scene semantics of the previous
|
||
* per-render inline script: the last initialized mount wins scenes[scene].
|
||
*/
|
||
function initMount(C) {
|
||
var root = window.AKSRTCaptchaState;
|
||
var box, hField, form = null;
|
||
var verified = false;
|
||
var pendingAction = null;
|
||
var triggerCaptcha = function () { showTip('验证码加载中,请稍候', '#e67e22'); };
|
||
|
||
function loadScriptOnce(key, src, readyCheck) {
|
||
if (typeof readyCheck === 'function' && readyCheck()) { return Promise.resolve(); }
|
||
if (root.loaders[key]) { return root.loaders[key]; }
|
||
root.loaders[key] = new Promise(function (resolve, reject) {
|
||
var existing = document.querySelector('script[data-aksrt-sdk="' + key + '"]');
|
||
if (existing) {
|
||
if (typeof readyCheck === 'function' && readyCheck()) { resolve(); return; }
|
||
existing.addEventListener('load', function () { resolve(); }, { once: true });
|
||
existing.addEventListener('error', function () { reject(new Error(key + ' load failed')); }, { once: true });
|
||
return;
|
||
}
|
||
var script = document.createElement('script');
|
||
script.src = src;
|
||
script.async = true;
|
||
script.setAttribute('data-aksrt-sdk', key);
|
||
script.onload = function () { resolve(); };
|
||
script.onerror = function () { reject(new Error(key + ' load failed')); };
|
||
document.head.appendChild(script);
|
||
});
|
||
return root.loaders[key];
|
||
}
|
||
|
||
function findForm() {
|
||
form = box.closest('form');
|
||
if (!form && C.scene === 'comment') form = document.getElementById('commentform');
|
||
if (!form && (C.scene === 'login' || C.scene === 'register')) {
|
||
form = box.closest('[data-auth-form]') || document.querySelector('[data-auth-form]');
|
||
}
|
||
if (!form && C.scene === 'bind_phone') {
|
||
form = document.getElementById('aksrt-bind-phone-form')
|
||
|| document.querySelector('[data-aksrt-bind-phone-form]')
|
||
|| document.querySelector('.auth-form');
|
||
}
|
||
return form;
|
||
}
|
||
|
||
function bindSubmit() {
|
||
if (!form) return;
|
||
form.addEventListener('submit', function (e) {
|
||
if (verified || hField.value === '1') return;
|
||
e.preventDefault(); e.stopImmediatePropagation();
|
||
pendingAction = null; triggerCaptcha();
|
||
}, true);
|
||
}
|
||
|
||
function setField(name, value) {
|
||
var container = form || box;
|
||
var el = container.querySelector('input[name="' + name + '"]');
|
||
if (!el) {
|
||
el = document.createElement('input');
|
||
el.type = 'hidden';
|
||
el.name = name;
|
||
container.appendChild(el);
|
||
}
|
||
el.value = value;
|
||
}
|
||
|
||
function resetVerificationState() {
|
||
verified = false;
|
||
hField.value = '0';
|
||
var container = form || box;
|
||
TOKEN_FIELDS.forEach(function (n) {
|
||
var f = container.querySelector('input[name="' + n + '"]');
|
||
if (f) f.remove();
|
||
});
|
||
if (C.scene === 'download') {
|
||
syncDownloadSiblings(false);
|
||
}
|
||
}
|
||
|
||
function syncDownloadSiblings(passed) {
|
||
var myContainer = box.closest('[data-aksrt-download-captcha]');
|
||
if (!myContainer) return;
|
||
document.querySelectorAll('[data-aksrt-download-captcha]').forEach(function (target) {
|
||
if (target === myContainer) return;
|
||
var tgtH = target.querySelector('input[name="captcha_verified"]');
|
||
if (tgtH) tgtH.value = passed ? '1' : '0';
|
||
TOKEN_FIELDS.forEach(function (name) {
|
||
var f = target.querySelector('input[name="' + name + '"]');
|
||
if (f) f.remove();
|
||
if (passed) {
|
||
var srcEl = myContainer.querySelector('input[name="' + name + '"]');
|
||
if (srcEl && srcEl.value !== '') {
|
||
var tgtEl = document.createElement('input');
|
||
tgtEl.type = 'hidden';
|
||
tgtEl.name = name;
|
||
target.appendChild(tgtEl);
|
||
tgtEl.value = srcEl.value;
|
||
}
|
||
}
|
||
});
|
||
});
|
||
}
|
||
|
||
function submitNativeForm() {
|
||
if (!form) return;
|
||
if (form.requestSubmit) { form.requestSubmit(); }
|
||
else { HTMLFormElement.prototype.submit.call(form); }
|
||
}
|
||
|
||
function submitForm() {
|
||
verified = true; hField.value = '1';
|
||
if (C.scene === 'download') syncDownloadSiblings(true);
|
||
if (typeof pendingAction === 'function') {
|
||
finishPending(true);
|
||
return;
|
||
}
|
||
setTimeout(resetVerificationState, 3000);
|
||
submitNativeForm();
|
||
}
|
||
|
||
function showTip(msg, color) {
|
||
var t = box.querySelector('.captcha-tip');
|
||
if (!t) {
|
||
t = document.createElement('div');
|
||
t.className = 'captcha-tip';
|
||
t.style.cssText = 'font-size:12px;margin-top:4px;text-align:left;';
|
||
box.appendChild(t);
|
||
}
|
||
t.style.color = color || '#e74c3c';
|
||
t.textContent = msg;
|
||
setTimeout(function () { if (t.parentNode) t.remove(); }, 4000);
|
||
}
|
||
|
||
function showLoading() { box.innerHTML = '<div style="text-align:center;padding:20px;color:#9ca3af;">验证码加载中...</div>'; }
|
||
function clearLoading() { box.innerHTML = ''; }
|
||
|
||
function finishPending(ok) {
|
||
var action = pendingAction;
|
||
pendingAction = null;
|
||
if (typeof action === 'function') { action(!!ok); }
|
||
}
|
||
|
||
function cancelPending(msg) {
|
||
if (msg) showTip(msg, '#e67e22');
|
||
finishPending(false);
|
||
}
|
||
|
||
root.scenes[C.scene] = {
|
||
verify: function (callback) {
|
||
if (verified || hField.value === '1') {
|
||
if (typeof callback === 'function') callback(true);
|
||
return;
|
||
}
|
||
pendingAction = (typeof callback === 'function') ? function (ok) { callback(ok !== false); } : null;
|
||
triggerCaptcha();
|
||
},
|
||
reset: resetVerificationState
|
||
};
|
||
|
||
// ============ 腾讯云 Captcha 2.0 ============
|
||
function loadTencent() {
|
||
showLoading();
|
||
loadScriptOnce('tencent', 'https://turing.captcha.qcloud.com/TJCaptcha.js', function () {
|
||
return typeof TencentCaptcha !== 'undefined';
|
||
}).then(function () {
|
||
clearLoading();
|
||
var capIns = null;
|
||
triggerCaptcha = function () {
|
||
if (!capIns) {
|
||
capIns = new TencentCaptcha(C.tc.app_id, function (res) {
|
||
if (res.ret === 2) { cancelPending('已取消验证'); return; }
|
||
if (res.ret === 0 && res.ticket) {
|
||
if (res.ticket.indexOf('trerror_') === 0) {
|
||
showTip('验证码服务异常,请刷新页面重试', '#e67e22');
|
||
return;
|
||
}
|
||
setField('tencent_ticket', res.ticket);
|
||
setField('tencent_randstr', res.randstr);
|
||
setField('tencent_sid', res.sid || '');
|
||
submitForm();
|
||
return;
|
||
}
|
||
if (res.errorCode) {
|
||
var errorMap = { 1001: '验证码组件加载失败', 1002: '验证码超时', 1006: '验证码配置拉取失败', 1008: '验证码页面加载异常', 1012: '验证码刷新次数过多', 1013: '验证码网络异常' };
|
||
showTip(errorMap[res.errorCode] || ('验证码异常(errorCode:' + res.errorCode + ')'), '#e74c3c');
|
||
}
|
||
}, { userLanguage: 'zh-cn' });
|
||
}
|
||
capIns.show();
|
||
};
|
||
}).catch(function () { clearLoading(); showTip('验证码组件加载失败,请刷新重试', '#e74c3c'); });
|
||
}
|
||
|
||
// ============ Cloudflare Turnstile(弹窗) ============
|
||
function loadCloudflare() {
|
||
var cfWidgetId = null, cfVerifying = false, cfModal = null;
|
||
|
||
if (typeof turnstile === 'undefined') {
|
||
window['onTurnstileLoad_' + C.uid] = function () {};
|
||
loadScriptOnce('cloudflare', 'https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onTurnstileLoad_' + C.uid + '&render=explicit', function () {
|
||
return typeof turnstile !== 'undefined';
|
||
});
|
||
}
|
||
|
||
function renderWidget() {
|
||
if (cfWidgetId) { try { turnstile.remove(cfWidgetId); } catch (e) {} cfWidgetId = null; }
|
||
if (typeof turnstile === 'undefined') { setTimeout(renderWidget, 200); return; }
|
||
cfWidgetId = turnstile.render('#modalWidget_' + C.uid, {
|
||
sitekey: C.cf.site_key, theme: C.cf.theme, size: C.cf.size, action: 'aksrt-verify', cdata: C.scene,
|
||
callback: function (token) {
|
||
if (!cfVerifying) return;
|
||
cfVerifying = false;
|
||
setField('cf_turnstile_response', token);
|
||
closeModal();
|
||
submitForm();
|
||
},
|
||
'error-callback': function () { showTip('验证码失败,请重试', '#e74c3c'); cfWidgetId = null; setTimeout(renderWidget, 500); },
|
||
'expired-callback': function () { showTip('验证码已过期,请重新验证', '#e67e22'); cfWidgetId = null; setTimeout(renderWidget, 500); }
|
||
});
|
||
}
|
||
|
||
function createModal() {
|
||
cfModal = document.createElement('div');
|
||
cfModal.className = 'aksrt-captcha-modal-overlay';
|
||
cfModal.innerHTML = '<div class="aksrt-captcha-modal-backdrop"></div>' +
|
||
'<div class="aksrt-captcha-modal-box"><div class="aksrt-captcha-modal-header">' +
|
||
'<span class="aksrt-captcha-modal-title">人机验证</span>' +
|
||
'<button type="button" class="aksrt-captcha-modal-close">×</button></div>' +
|
||
'<div class="aksrt-captcha-modal-body"><p class="aksrt-captcha-modal-hint">请完成验证后继续操作</p>' +
|
||
'<div id="modalWidget_' + C.uid + '" class="aksrt-captcha-modal-widget"></div></div></div></div>';
|
||
document.body.appendChild(cfModal);
|
||
var cancelFn = function () { cfVerifying = false; closeModal(); cancelPending('已取消验证'); };
|
||
cfModal.querySelector('.aksrt-captcha-modal-backdrop').addEventListener('click', cancelFn);
|
||
cfModal.querySelector('.aksrt-captcha-modal-close').addEventListener('click', cancelFn);
|
||
renderWidget();
|
||
}
|
||
|
||
function closeModal() {
|
||
if (cfWidgetId) { try { turnstile.remove(cfWidgetId); } catch (e) {} cfWidgetId = null; }
|
||
if (cfModal && cfModal.parentNode) { cfModal.parentNode.removeChild(cfModal); }
|
||
cfModal = null;
|
||
}
|
||
|
||
triggerCaptcha = function () {
|
||
if (cfVerifying) { showTip('验证码进行中,请稍候', '#e67e22'); return; }
|
||
cfVerifying = true;
|
||
createModal();
|
||
};
|
||
}
|
||
|
||
// ============ 极验 GeeTest v4 ============
|
||
function loadGeetest() {
|
||
showLoading();
|
||
var captchaId = (C.gt && C.gt.captcha_id) ? String(C.gt.captcha_id).trim() : '';
|
||
var product = (C.gt && C.gt.product) ? String(C.gt.product) : 'bind';
|
||
if (!captchaId) {
|
||
clearLoading();
|
||
showTip('极验 Captcha ID 未配置,请到后台「功能&权限 → 人机验证」填写并保存', '#e74c3c');
|
||
return;
|
||
}
|
||
function render() {
|
||
clearLoading();
|
||
initGeetest4({ captchaId: captchaId, product: product, hideSuccess: true }, function (capIns) {
|
||
window['__gt_' + C.uid] = capIns;
|
||
function onSuccess() {
|
||
var result = capIns.getValidate();
|
||
if (!result) return;
|
||
setField('geetest_lot_number', result.lot_number);
|
||
setField('geetest_captcha_output', result.captcha_output);
|
||
setField('geetest_pass_token', result.pass_token);
|
||
setField('geetest_gen_time', result.gen_time);
|
||
submitForm();
|
||
}
|
||
if (product === 'bind' || product === 'popup') {
|
||
capIns.onReady(function () {}).onSuccess(onSuccess).onClose(function () { cancelPending('已取消验证'); });
|
||
} else {
|
||
capIns.appendTo('#' + C.uid).onSuccess(onSuccess).onClose(function () { cancelPending('已取消验证'); });
|
||
}
|
||
});
|
||
triggerCaptcha = function () {
|
||
var instance = window['__gt_' + C.uid];
|
||
if (!instance) { showTip('验证码加载中,请稍候再试', '#e67e22'); return; }
|
||
if (product === 'bind' || product === 'popup') { instance.showCaptcha(); return; }
|
||
showTip('请先完成人机验证', '#e67e22');
|
||
};
|
||
}
|
||
if (typeof initGeetest4 === 'undefined') {
|
||
loadScriptOnce('geetest', 'https://static.geetest.com/v4/gt4.js', function () {
|
||
return typeof initGeetest4 !== 'undefined';
|
||
}).then(render).catch(function () { clearLoading(); showTip('极验组件加载失败', '#e74c3c'); });
|
||
return;
|
||
}
|
||
render();
|
||
}
|
||
|
||
// ============ 阿里云 CAPTCHA 2.0 V3 ============
|
||
function loadAliyun() {
|
||
showLoading();
|
||
window.AliyunCaptchaConfig = { region: C.al.region || 'cn', prefix: C.al.prefix };
|
||
|
||
function render() {
|
||
clearLoading();
|
||
var captchaIns = null;
|
||
var btn = box.closest('form') ? box.closest('form').querySelector('button[type="submit"], input[type="submit"]') : null;
|
||
window.initAliyunCaptcha({
|
||
SceneId: C.al.scene_id, mode: 'popup', element: '#' + C.uid,
|
||
button: btn ? '#' + (btn.id || (function () { btn.id = 'aksrt-captcha-btn-' + C.scene; return btn.id; })()) : null,
|
||
success: function (captchaVerifyParam) {
|
||
setField('aliyun_captcha_verify_param', captchaVerifyParam);
|
||
submitForm();
|
||
},
|
||
fail: function (result) { showTip('验证码失败: ' + (result || '请重试'), '#e74c3c'); captchaIns = null; },
|
||
getInstance: function (instance) { captchaIns = instance; },
|
||
slideStyle: { width: 360, height: 40 }, language: 'cn'
|
||
});
|
||
triggerCaptcha = function () {
|
||
if (captchaIns && captchaIns.show) { captchaIns.show(); return; }
|
||
showTip('验证码组件加载中,请稍候再试', '#e67e22');
|
||
};
|
||
}
|
||
|
||
if (typeof window.initAliyunCaptcha === 'undefined') {
|
||
loadScriptOnce('aliyun', 'https://o.alicdn.com/captcha-frontend/aliyunCaptcha/AliyunCaptcha.js', function () {
|
||
return typeof window.initAliyunCaptcha !== 'undefined';
|
||
}).then(render).catch(function () { clearLoading(); showTip('验证码组件加载失败,请刷新重试', '#e74c3c'); });
|
||
return;
|
||
}
|
||
render();
|
||
}
|
||
|
||
function loadProvider() {
|
||
switch (C.provider) {
|
||
case 'tencent': loadTencent(); break;
|
||
case 'cloudflare': loadCloudflare(); break;
|
||
case 'geetest': loadGeetest(); break;
|
||
case 'aliyun': loadAliyun(); break;
|
||
}
|
||
}
|
||
|
||
function init() {
|
||
box = document.getElementById(C.uid);
|
||
hField = document.getElementById(C.vid);
|
||
if (!box || !hField) return;
|
||
|
||
var tries = 0;
|
||
(function retryFind() {
|
||
findForm();
|
||
if (!form && ++tries < 10) { setTimeout(retryFind, 150); }
|
||
else {
|
||
if (form) bindSubmit();
|
||
setTimeout(loadProvider, 0);
|
||
}
|
||
})();
|
||
}
|
||
|
||
init();
|
||
}
|
||
|
||
if (document.readyState === 'loading') {
|
||
document.addEventListener('DOMContentLoaded', scan);
|
||
} else {
|
||
setTimeout(scan, 50);
|
||
}
|
||
})();
|
||
;
|
||
|
||
/* source: assets/js/instant-page.js */
|
||
/**
|
||
* AKSRT Instant Page
|
||
*
|
||
* Lightweight page prefetch on hover/focus.
|
||
* Preloads pages when the user hovers over a link, so navigation feels instant.
|
||
* No external dependencies — pure vanilla JS.
|
||
*
|
||
* Based on the instant.page concept (MIT license).
|
||
*
|
||
* @package AKSRT
|
||
*/
|
||
|
||
(function () {
|
||
'use strict';
|
||
|
||
// Only prefetch on desktop (no touch-only devices) with good connection
|
||
if ('connection' in navigator) {
|
||
var conn = navigator.connection;
|
||
if (conn.saveData || (conn.effectiveType && conn.effectiveType.indexOf('2g') !== -1)) return;
|
||
}
|
||
|
||
// Don't run on touch-only devices (they don't benefit from hover prefetch)
|
||
var hasHoverSupport = window.matchMedia('(hover: hover) and (pointer: fine)').matches;
|
||
if (!hasHoverSupport) return;
|
||
|
||
var prefetcher = document.createElement('link');
|
||
var isPrefetched = {};
|
||
var timer = null;
|
||
var DELAY = 65; // ms to wait before prefetching
|
||
var MAX_PREFETCH = 3; // max concurrent prefetches
|
||
var prefetchedCount = 0;
|
||
|
||
if (!prefetcher.relList || !prefetcher.relList.supports || !prefetcher.relList.supports('prefetch')) return;
|
||
|
||
function prefetch(url) {
|
||
if (isPrefetched[url] || prefetchedCount >= MAX_PREFETCH) return;
|
||
|
||
// Don't prefetch URLs with hash (same page navigation)
|
||
if (url.indexOf('#') !== -1) return;
|
||
|
||
// Only prefetch same-origin URLs
|
||
try {
|
||
var link = new URL(url, window.location.origin);
|
||
if (link.origin !== window.location.origin) return;
|
||
// Don't prefetch the current page
|
||
if (link.pathname === window.location.pathname && link.search === window.location.search) return;
|
||
} catch (e) { return; }
|
||
|
||
// Don't prefetch files/downloads
|
||
if (/\.(pdf|zip|rar|7z|tar|gz|exe|dmg|apk|mp[34]|avi|mov|wmv|flv|webm|ogg|wav|bmp|gif|ico|svg|woff2?|ttf|eot)(\?|$)/i.test(url)) return;
|
||
|
||
isPrefetched[url] = true;
|
||
prefetchedCount++;
|
||
|
||
var linkEl = document.createElement('link');
|
||
linkEl.rel = 'prefetch';
|
||
linkEl.href = url;
|
||
linkEl.as = 'document';
|
||
document.head.appendChild(linkEl);
|
||
}
|
||
|
||
function onHoverStart(e) {
|
||
var link = e.target.closest('a');
|
||
if (!link || !link.href) return;
|
||
if (link.target === '_blank') return;
|
||
if (link.hasAttribute('download')) return;
|
||
if (link.getAttribute('rel') === 'nofollow') return;
|
||
if (link.closest('.no-prefetch,[data-no-prefetch]')) return;
|
||
|
||
clearTimeout(timer);
|
||
timer = setTimeout(function () {
|
||
prefetch(link.href);
|
||
}, DELAY);
|
||
}
|
||
|
||
function onHoverEnd() {
|
||
clearTimeout(timer);
|
||
}
|
||
|
||
document.addEventListener('mouseover', onHoverStart, { passive: true, capture: true });
|
||
document.addEventListener('mouseout', onHoverEnd, { passive: true, capture: true });
|
||
|
||
// Also prefetch on focus for keyboard navigation
|
||
document.addEventListener('focusin', function (e) {
|
||
var link = e.target.closest('a');
|
||
if (link && link.href) {
|
||
prefetch(link.href);
|
||
}
|
||
}, { passive: true, capture: true });
|
||
|
||
// Cleanup after page hides (bfcache)
|
||
window.addEventListener('pagehide', function () {
|
||
isPrefetched = {};
|
||
prefetchedCount = 0;
|
||
});
|
||
})();
|
||
;
|