6392 lines
349 KiB
JavaScript
6392 lines
349 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',
|
||
'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;
|
||
}
|
||
}
|
||
|
||
// 执行实际的 REST 请求 — local insert instead of full-page re-fetch
|
||
function performSubmit(captchaPayload) {
|
||
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; });
|
||
Object.assign(restBody, captchaPayload || {});
|
||
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';
|
||
|
||
// 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');
|
||
if (json.wait_time) startCountdown(json.wait_time);
|
||
else setLoading(false);
|
||
return;
|
||
}
|
||
|
||
notyf('评论已提交', 'success');
|
||
setLoading(false);
|
||
setTimeout(function () { reloadCommentList(); }, 500);
|
||
})
|
||
.catch(function (error) {
|
||
console.error('[AKSRT Comment] 提交失败:', error);
|
||
notyf((error && error.message) || '网络连接失败,请检查网络后重试', 'danger');
|
||
setLoading(false);
|
||
})
|
||
.finally(function () {
|
||
if (window.AKSRTCaptcha) window.AKSRTCaptcha.reset('comment', form);
|
||
if (!countdownTimer && isSubmitting) setLoading(false);
|
||
});
|
||
}
|
||
|
||
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();
|
||
}
|
||
}
|
||
// 核心表单提交事件处理器
|
||
function handleSubmit(e) {
|
||
// 如果已经在提交中或倒计时中,防止重复提交
|
||
if (isSubmitting || countdownTimer) {
|
||
e.preventDefault();
|
||
e.stopImmediatePropagation();
|
||
return false;
|
||
}
|
||
|
||
// 阻止默认表单提交
|
||
e.preventDefault();
|
||
e.stopImmediatePropagation();
|
||
var captcha = window.AKSRTCaptcha;
|
||
setLoading(true);
|
||
(captcha ? captcha.run('comment', form) : Promise.resolve({})).then(function (captchaPayload) {
|
||
if (captchaPayload === null) {
|
||
notyf('人机验证未通过,请重试', 'warning');
|
||
setLoading(false);
|
||
return;
|
||
}
|
||
performSubmit(captchaPayload);
|
||
}).catch(function () {
|
||
notyf('人机验证未通过,请重试', 'warning');
|
||
setLoading(false);
|
||
if (captcha) captcha.reset('comment', form);
|
||
});
|
||
|
||
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';
|
||
|
||
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 lastTrigger = null;
|
||
var previousBodyOverflow = '';
|
||
var EXCLUDE_SEL = '.no-imgbox,.no-lightbox,.avatar,.img-icon,.avatar-badge,.aksrt-avatar,[data-no-lightbox],[data-aksrt-lightbox="0"]';
|
||
var TRIGGER_SEL = '[data-aksrt-lightbox="1"] img,.aksrt-lightbox-trigger img,.imgbox-container img,.comment-content .box-img';
|
||
var ANCHOR_TRIGGER_SEL = 'a[data-aksrt-lightbox-trigger]';
|
||
var GROUP_SEL = '[data-aksrt-lightbox-group],.content-gallery[data-aksrt-lightbox="1"],.aksrt-carousel-block[data-aksrt-lightbox="1"],.imgbox-container,.comment-content,.post_front_content[data-aksrt-lightbox="1"],.wp-posts-content[data-aksrt-lightbox="1"],.entry-thumb[data-aksrt-lightbox="1"],.entry-content[data-aksrt-lightbox="1"],.aksrt-lightbox-trigger,[data-aksrt-lightbox="1"]';
|
||
var IMAGE_URL_RE = /\.(?:avif|bmp|gif|ico|jpe?g|png|svg|tiff?|webp)(?:[?#].*)?$/i;
|
||
var MAX_ZOOM_DESKTOP = 2;
|
||
var MAX_ZOOM_MOBILE = 3;
|
||
|
||
function lightboxFlag(key, fallback) {
|
||
var config = window._win || {};
|
||
if (config[key] === undefined || config[key] === null || config[key] === '') return fallback;
|
||
return config[key] === true || config[key] === 1 || config[key] === '1';
|
||
}
|
||
|
||
function lightboxEnabled() {
|
||
return lightboxFlag('imgbox', false);
|
||
}
|
||
|
||
function normalizeFullUrl(url) {
|
||
if (!url || url.indexOf('data:') === 0) return url || '';
|
||
return url
|
||
.replace(/-\d+x\d+(\.[a-z0-9]+)(?=([?#]|$))/i, '$1')
|
||
.replace(/([?&])x-oss-process=[^#&]*&?/i, '$1')
|
||
.replace(/[?&]$/, '');
|
||
}
|
||
|
||
function resolveFullUrl(img) {
|
||
var explicitFull = img.getAttribute('data-full-url') || '';
|
||
if (explicitFull) return normalizeFullUrl(explicitFull);
|
||
|
||
var anchor = img.closest('a[href]');
|
||
var href = anchor ? anchor.getAttribute('href') || '' : '';
|
||
if (IMAGE_URL_RE.test(href)) return normalizeFullUrl(href);
|
||
|
||
return normalizeFullUrl(
|
||
img.getAttribute('data-src')
|
||
|| img.getAttribute('data-lazy-src')
|
||
|| img.currentSrc
|
||
|| img.getAttribute('src')
|
||
|| ''
|
||
);
|
||
}
|
||
|
||
function resolveThumbUrl(img) {
|
||
return img.currentSrc
|
||
|| img.getAttribute('src')
|
||
|| img.getAttribute('data-src')
|
||
|| img.getAttribute('data-lazy-src')
|
||
|| img.getAttribute('data-full-url')
|
||
|| '';
|
||
}
|
||
|
||
function resolveCaption(img) {
|
||
var anchor = img.closest('a');
|
||
var explicit = anchor ? anchor.getAttribute('data-caption') || '' : '';
|
||
if (explicit.trim()) return explicit.trim();
|
||
|
||
var figure = img.closest('figure');
|
||
var figcaption = figure ? figure.querySelector('figcaption') : null;
|
||
if (figcaption && figcaption.textContent.trim()) return figcaption.textContent.trim();
|
||
|
||
return (img.getAttribute('alt') || '').trim();
|
||
}
|
||
|
||
function isNoLightbox(img) {
|
||
if (!img || img.closest(EXCLUDE_SEL)) return true;
|
||
|
||
var parentA = img.closest('a[href]');
|
||
if (parentA) {
|
||
var href = parentA.getAttribute('href') || '';
|
||
if (href && !IMAGE_URL_RE.test(href) && !parentA.hasAttribute('data-aksrt-lightbox-trigger')) {
|
||
return true;
|
||
}
|
||
}
|
||
|
||
return resolveFullUrl(img) === '';
|
||
}
|
||
|
||
function createLightbox() {
|
||
if (!lightboxEnabled()) return null;
|
||
if (lightboxEl) return lightboxEl;
|
||
|
||
lightboxEl = document.createElement('div');
|
||
lightboxEl.className = 'aksrt-lightbox';
|
||
lightboxEl.setAttribute('role', 'dialog');
|
||
lightboxEl.setAttribute('aria-modal', 'true');
|
||
lightboxEl.setAttribute('aria-hidden', 'true');
|
||
lightboxEl.setAttribute('aria-label', '图片预览');
|
||
lightboxEl.setAttribute('tabindex', '-1');
|
||
lightboxEl.innerHTML =
|
||
'<div class="aksrt-lightbox__toolbar">' +
|
||
'<span class="aksrt-lightbox__counter" aria-live="polite"></span>' +
|
||
'<button type="button" class="aksrt-lightbox__tool toggle-zoom" title="缩放" aria-label="缩放"><i class="fa fas fa-search-plus" aria-hidden="true"></i></button>' +
|
||
'<button type="button" class="aksrt-lightbox__tool toggle-thumbs" title="缩略图" aria-label="显示或隐藏缩略图"><i class="fa fas fa-th" aria-hidden="true"></i></button>' +
|
||
'<button type="button" class="aksrt-lightbox__tool toggle-play" title="幻灯片" aria-label="播放幻灯片"><i class="fa fas fa-play" aria-hidden="true"></i></button>' +
|
||
'<button type="button" class="aksrt-lightbox__tool toggle-full" title="全屏" aria-label="切换全屏"><i class="fa fas fa-expand" aria-hidden="true"></i></button>' +
|
||
'<a class="aksrt-lightbox__tool aksrt-lightbox__download" title="下载" aria-label="下载图片" download><i class="fa fas fa-download" aria-hidden="true"></i></a>' +
|
||
'<button type="button" class="aksrt-lightbox__tool aksrt-lightbox__close" title="关闭" aria-label="关闭"><i class="fa fas fa-times" aria-hidden="true"></i></button>' +
|
||
'</div>' +
|
||
'<button type="button" class="aksrt-lightbox__nav aksrt-lightbox__nav--prev" aria-label="上一张"><i class="fa fas fa-chevron-left" aria-hidden="true"></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" aria-hidden="true"></i></button>' +
|
||
'<div class="aksrt-lightbox__caption" aria-live="polite"></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');
|
||
|
||
lightboxEl.querySelector('.aksrt-lightbox__close').addEventListener('click', function (event) {
|
||
event.stopPropagation();
|
||
closeLightbox();
|
||
});
|
||
lightboxEl.addEventListener('click', function (event) {
|
||
if (event.target === lightboxEl || event.target.classList.contains('aksrt-lightbox__stage')) closeLightbox();
|
||
});
|
||
lightboxEl.querySelector('.aksrt-lightbox__nav--prev').addEventListener('click', function (event) {
|
||
event.stopPropagation();
|
||
navigateLightbox(-1);
|
||
});
|
||
lightboxEl.querySelector('.aksrt-lightbox__nav--next').addEventListener('click', function (event) {
|
||
event.stopPropagation();
|
||
navigateLightbox(1);
|
||
});
|
||
|
||
document.addEventListener('keydown', function (event) {
|
||
if (!lightboxEl || !lightboxEl.classList.contains('is-open')) return;
|
||
if (event.key === 'Escape') closeLightbox();
|
||
if (event.key === 'ArrowLeft') navigateLightbox(-1);
|
||
if (event.key === 'ArrowRight') navigateLightbox(1);
|
||
if (event.key === 'Tab') trapFocus(event);
|
||
});
|
||
|
||
lightboxEl.addEventListener('wheel', function (event) {
|
||
if (!lightboxEl.classList.contains('is-open') || currentZoom > 1 || currentGallery.length < 2) return;
|
||
event.preventDefault();
|
||
navigateLightbox(event.deltaY > 0 ? 1 : -1);
|
||
}, { passive: false });
|
||
|
||
lightboxImg.addEventListener('click', function (event) {
|
||
event.stopPropagation();
|
||
if (lightboxFlag('imgbox_zoom', true)) toggleZoom();
|
||
});
|
||
lightboxImg.addEventListener('dblclick', function (event) {
|
||
if (!lightboxFlag('imgbox_zoom', true)) return;
|
||
event.stopPropagation();
|
||
var maxZoom = window.innerWidth < 768 ? MAX_ZOOM_MOBILE : MAX_ZOOM_DESKTOP;
|
||
setZoom(currentZoom < maxZoom ? maxZoom : 1);
|
||
});
|
||
|
||
bindTouchGestures();
|
||
|
||
lightboxEl.querySelector('.toggle-zoom').addEventListener('click', function (event) {
|
||
event.stopPropagation();
|
||
toggleZoom();
|
||
});
|
||
lightboxEl.querySelector('.toggle-thumbs').addEventListener('click', function (event) {
|
||
event.stopPropagation();
|
||
lightboxThumbsWrap.hidden = !lightboxThumbsWrap.hidden;
|
||
});
|
||
lightboxEl.querySelector('.toggle-play').addEventListener('click', function (event) {
|
||
event.stopPropagation();
|
||
toggleAutoplay();
|
||
});
|
||
lightboxEl.querySelector('.toggle-full').addEventListener('click', function (event) {
|
||
event.stopPropagation();
|
||
toggleFullscreen();
|
||
});
|
||
|
||
document.addEventListener('fullscreenchange', syncFullscreenState);
|
||
document.addEventListener('webkitfullscreenchange', syncFullscreenState);
|
||
|
||
return lightboxEl;
|
||
}
|
||
|
||
function bindTouchGestures() {
|
||
var pinchStart = 0;
|
||
var touchStartY = 0;
|
||
var touchStartX = 0;
|
||
var pullDistance = 0;
|
||
|
||
lightboxEl.addEventListener('touchstart', function (event) {
|
||
if (event.touches.length === 2 && lightboxFlag('imgbox_zoom', true)) {
|
||
pinchStart = Math.hypot(
|
||
event.touches[1].clientX - event.touches[0].clientX,
|
||
event.touches[1].clientY - event.touches[0].clientY
|
||
);
|
||
return;
|
||
}
|
||
if (event.touches.length === 1 && currentZoom <= 1.05) {
|
||
touchStartY = event.touches[0].clientY;
|
||
touchStartX = event.touches[0].clientX;
|
||
pullDistance = 0;
|
||
}
|
||
}, { passive: true });
|
||
|
||
lightboxEl.addEventListener('touchmove', function (event) {
|
||
if (event.touches.length === 2 && pinchStart > 0 && lightboxFlag('imgbox_zoom', true)) {
|
||
var distance = Math.hypot(
|
||
event.touches[1].clientX - event.touches[0].clientX,
|
||
event.touches[1].clientY - event.touches[0].clientY
|
||
);
|
||
var maxZoom = window.innerWidth < 768 ? MAX_ZOOM_MOBILE : MAX_ZOOM_DESKTOP;
|
||
setZoom(Math.min(maxZoom, Math.max(1, currentZoom * (distance / pinchStart))));
|
||
pinchStart = distance;
|
||
return;
|
||
}
|
||
if (event.touches.length !== 1 || currentZoom > 1.05) return;
|
||
|
||
var dy = event.touches[0].clientY - touchStartY;
|
||
var dx = event.touches[0].clientX - touchStartX;
|
||
if (Math.abs(dy) > Math.abs(dx) && dy > 30) {
|
||
pullDistance = dy;
|
||
lightboxImg.style.transform = 'translate3d(0, ' + dy + 'px, 0) scale(' + currentZoom + ')';
|
||
lightboxImg.style.opacity = String(Math.max(0.2, Math.min(1, (150 - dy) / 80)));
|
||
}
|
||
}, { passive: true });
|
||
|
||
lightboxEl.addEventListener('touchend', function () {
|
||
pinchStart = 0;
|
||
if (pullDistance > 100) {
|
||
closeLightbox();
|
||
} else if (pullDistance > 0) {
|
||
setZoom(1);
|
||
}
|
||
lightboxImg.style.opacity = '';
|
||
pullDistance = 0;
|
||
}, { passive: true });
|
||
}
|
||
|
||
function trapFocus(event) {
|
||
var focusable = Array.prototype.filter.call(
|
||
lightboxEl.querySelectorAll('a[href],button:not([hidden]):not([disabled]),[tabindex]:not([tabindex="-1"])'),
|
||
function (element) { return element.offsetParent !== null; }
|
||
);
|
||
if (!focusable.length) {
|
||
event.preventDefault();
|
||
lightboxEl.focus();
|
||
return;
|
||
}
|
||
|
||
var first = focusable[0];
|
||
var last = focusable[focusable.length - 1];
|
||
if (event.shiftKey && document.activeElement === first) {
|
||
event.preventDefault();
|
||
last.focus();
|
||
} else if (!event.shiftKey && document.activeElement === last) {
|
||
event.preventDefault();
|
||
first.focus();
|
||
}
|
||
}
|
||
|
||
function setZoom(zoom) {
|
||
if (!lightboxImg || !lightboxEl) return;
|
||
currentZoom = zoom;
|
||
lightboxImg.style.transform = 'scale(' + zoom + ')';
|
||
lightboxEl.classList.toggle('is-zoomed', zoom > 1);
|
||
}
|
||
|
||
function toggleZoom() {
|
||
if (!lightboxFlag('imgbox_zoom', true)) return;
|
||
var maxZoom = window.innerWidth < 768 ? MAX_ZOOM_MOBILE : MAX_ZOOM_DESKTOP;
|
||
setZoom(currentZoom > 1 ? 1 : maxZoom);
|
||
}
|
||
|
||
function toggleAutoplay() {
|
||
if (!lightboxEl) return;
|
||
var icon = lightboxEl.querySelector('.toggle-play i');
|
||
if (isAutoplay) {
|
||
clearInterval(autoplayTimer);
|
||
autoplayTimer = null;
|
||
isAutoplay = false;
|
||
icon.className = 'fa fas fa-play';
|
||
return;
|
||
}
|
||
if (currentGallery.length < 2) return;
|
||
|
||
isAutoplay = true;
|
||
icon.className = 'fa fas fa-pause';
|
||
autoplayTimer = setInterval(function () { navigateLightbox(1); }, 3000);
|
||
}
|
||
|
||
function toggleFullscreen() {
|
||
if (!lightboxEl || !lightboxFlag('imgbox_full', true)) return;
|
||
var fullscreenElement = document.fullscreenElement || document.webkitFullscreenElement;
|
||
if (fullscreenElement) {
|
||
var exit = document.exitFullscreen || document.webkitExitFullscreen;
|
||
if (exit) exit.call(document);
|
||
return;
|
||
}
|
||
|
||
var request = lightboxEl.requestFullscreen || lightboxEl.webkitRequestFullscreen;
|
||
if (request) request.call(lightboxEl);
|
||
}
|
||
|
||
function syncFullscreenState() {
|
||
if (!lightboxEl) return;
|
||
var active = Boolean(document.fullscreenElement || document.webkitFullscreenElement);
|
||
var icon = lightboxEl.querySelector('.toggle-full i');
|
||
lightboxEl.classList.toggle('full-screen', active);
|
||
icon.className = active ? 'fa fas fa-compress' : 'fa fas fa-expand';
|
||
}
|
||
|
||
function buildThumbnails() {
|
||
if (!lightboxThumbsWrap) return;
|
||
lightboxThumbsWrap.innerHTML = '';
|
||
currentGallery.forEach(function (item, index) {
|
||
var button = document.createElement('button');
|
||
var thumb = document.createElement('img');
|
||
button.type = 'button';
|
||
button.className = 'aksrt-lightbox__thumb' + (index === currentIndex ? ' is-active' : '');
|
||
button.setAttribute('aria-label', '查看第 ' + (index + 1) + ' 张图片');
|
||
thumb.src = item.thumbSrc || item.src;
|
||
thumb.alt = '';
|
||
button.appendChild(thumb);
|
||
button.addEventListener('click', function (event) {
|
||
event.stopPropagation();
|
||
showLightboxImage(index);
|
||
});
|
||
lightboxThumbsWrap.appendChild(button);
|
||
});
|
||
}
|
||
|
||
function syncThumbActive() {
|
||
if (!lightboxThumbsWrap) return;
|
||
var thumbs = lightboxThumbsWrap.querySelectorAll('.aksrt-lightbox__thumb');
|
||
thumbs.forEach(function (thumb, index) {
|
||
thumb.classList.toggle('is-active', index === currentIndex);
|
||
});
|
||
var active = thumbs[currentIndex];
|
||
if (active) active.scrollIntoView({ inline: 'center', block: 'nearest' });
|
||
}
|
||
|
||
function syncControls() {
|
||
if (!lightboxEl) return;
|
||
var multiple = currentGallery.length > 1;
|
||
var fullscreenAvailable = Boolean(
|
||
lightboxEl.requestFullscreen
|
||
|| lightboxEl.webkitRequestFullscreen
|
||
|| document.fullscreenEnabled
|
||
|| document.webkitFullscreenEnabled
|
||
);
|
||
var thumbsEnabled = multiple && lightboxFlag('imgbox_thumbs', true);
|
||
|
||
lightboxEl.querySelector('.toggle-zoom').hidden = !lightboxFlag('imgbox_zoom', true);
|
||
lightboxEl.querySelector('.toggle-thumbs').hidden = !thumbsEnabled;
|
||
lightboxEl.querySelector('.toggle-play').hidden = !multiple || !lightboxFlag('imgbox_play', false);
|
||
lightboxEl.querySelector('.toggle-full').hidden = !lightboxFlag('imgbox_full', true) || !fullscreenAvailable;
|
||
lightboxEl.querySelector('.aksrt-lightbox__download').hidden = !lightboxFlag('imgbox_down', false);
|
||
lightboxEl.querySelector('.aksrt-lightbox__nav--prev').hidden = !multiple;
|
||
lightboxEl.querySelector('.aksrt-lightbox__nav--next').hidden = !multiple;
|
||
lightboxThumbsWrap.hidden = !thumbsEnabled;
|
||
}
|
||
|
||
function openLightbox(src, caption, gallery, index, originEl) {
|
||
if (!lightboxEnabled() || !createLightbox()) return false;
|
||
|
||
currentGallery = gallery && gallery.length ? gallery : [{ src: src, fullSrc: src, thumbSrc: src, caption: caption || '' }];
|
||
currentIndex = Number.isInteger(index) ? index : 0;
|
||
currentZoom = 1;
|
||
lastTrigger = originEl || document.activeElement;
|
||
|
||
if (originEl && typeof originEl.getBoundingClientRect === 'function') {
|
||
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');
|
||
}
|
||
|
||
buildThumbnails();
|
||
syncControls();
|
||
showLightboxImage(currentIndex);
|
||
|
||
lightboxEl.classList.add('is-open');
|
||
lightboxEl.setAttribute('aria-hidden', 'false');
|
||
previousBodyOverflow = document.body.style.overflow;
|
||
document.body.style.overflow = 'hidden';
|
||
document.body.classList.add('aksrt-lightbox-open');
|
||
lightboxEl.querySelector('.aksrt-lightbox__close').focus();
|
||
lightboxEl.dispatchEvent(new CustomEvent('aksrt:lightbox-open', { bubbles: true }));
|
||
return true;
|
||
}
|
||
|
||
function showLightboxImage(index) {
|
||
if (!currentGallery.length || !lightboxImg) return;
|
||
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.hidden = !item.caption;
|
||
|
||
if (currentGallery.length > 1) {
|
||
lightboxCounter.textContent = (currentIndex + 1) + ' / ' + currentGallery.length;
|
||
lightboxCounter.hidden = false;
|
||
} else {
|
||
lightboxCounter.textContent = '';
|
||
lightboxCounter.hidden = true;
|
||
}
|
||
|
||
var download = lightboxEl.querySelector('.aksrt-lightbox__download');
|
||
var fullSrc = item.fullSrc || item.src;
|
||
download.href = fullSrc;
|
||
download.download = fullSrc.substring(fullSrc.lastIndexOf('/') + 1).split(/[?#]/)[0] || 'image';
|
||
syncThumbActive();
|
||
}
|
||
|
||
function navigateLightbox(direction) {
|
||
if (currentGallery.length < 2) return;
|
||
showLightboxImage(currentIndex + direction);
|
||
}
|
||
|
||
function closeLightbox() {
|
||
if (!lightboxEl || !lightboxEl.classList.contains('is-open')) return;
|
||
if (isAutoplay) toggleAutoplay();
|
||
lightboxEl.classList.remove('is-open', 'is-zoomed', 'from-origin');
|
||
lightboxEl.setAttribute('aria-hidden', 'true');
|
||
document.body.style.overflow = previousBodyOverflow;
|
||
document.body.classList.remove('aksrt-lightbox-open');
|
||
lightboxThumbsWrap.hidden = true;
|
||
lightboxImg.src = '';
|
||
lightboxImg.alt = '';
|
||
|
||
var fullscreenElement = document.fullscreenElement || document.webkitFullscreenElement;
|
||
var exit = document.exitFullscreen || document.webkitExitFullscreen;
|
||
if (fullscreenElement && exit) exit.call(document);
|
||
|
||
if (lastTrigger && typeof lastTrigger.focus === 'function' && document.contains(lastTrigger)) {
|
||
lastTrigger.focus({ preventScroll: true });
|
||
}
|
||
lastTrigger = null;
|
||
}
|
||
|
||
function buildGallery(img) {
|
||
var container = img.closest(GROUP_SEL);
|
||
if (!container || container.closest('[data-no-lightbox],[data-aksrt-lightbox="0"]')) return null;
|
||
|
||
var gallery = [];
|
||
var foundIndex = -1;
|
||
container.querySelectorAll('img').forEach(function (candidate) {
|
||
if (!candidate.matches(TRIGGER_SEL) || isNoLightbox(candidate)) return;
|
||
var fullSrc = resolveFullUrl(candidate);
|
||
var thumbSrc = resolveThumbUrl(candidate) || fullSrc;
|
||
if (!fullSrc) return;
|
||
|
||
if (candidate === img) foundIndex = gallery.length;
|
||
gallery.push({
|
||
src: thumbSrc,
|
||
thumbSrc: thumbSrc,
|
||
fullSrc: fullSrc,
|
||
caption: resolveCaption(candidate),
|
||
});
|
||
});
|
||
|
||
if (foundIndex < 0 || !gallery.length) return null;
|
||
return { items: gallery, index: foundIndex };
|
||
}
|
||
|
||
function openImage(img) {
|
||
if (isNoLightbox(img)) return false;
|
||
var gallery = buildGallery(img);
|
||
if (!gallery) return false;
|
||
var item = gallery.items[gallery.index];
|
||
return openLightbox(item.fullSrc, item.caption, gallery.items, gallery.index, img);
|
||
}
|
||
|
||
function initLightbox() {
|
||
document.addEventListener('click', function (event) {
|
||
if (!lightboxEnabled() || !(event.target instanceof Element)) return;
|
||
|
||
var anchor = event.target.closest(ANCHOR_TRIGGER_SEL);
|
||
if (anchor && !anchor.closest(EXCLUDE_SEL)) {
|
||
var anchorImage = anchor.querySelector('img');
|
||
if (anchorImage && openImage(anchorImage)) {
|
||
event.preventDefault();
|
||
return;
|
||
}
|
||
|
||
var href = anchor.getAttribute('href') || '';
|
||
if (IMAGE_URL_RE.test(href) && openLightbox(href, anchor.getAttribute('data-caption') || '', null, 0, anchor)) {
|
||
event.preventDefault();
|
||
}
|
||
return;
|
||
}
|
||
|
||
var img = event.target.closest(TRIGGER_SEL);
|
||
if (img && openImage(img)) event.preventDefault();
|
||
});
|
||
}
|
||
|
||
window.AksrtLightbox = {
|
||
open: openLightbox,
|
||
close: closeLightbox,
|
||
};
|
||
|
||
// Scroll direction is handled by aksrt-runtime.js. Keep the prefixed
|
||
// classes in sync for the remaining CSS consumers.
|
||
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);
|
||
}
|
||
|
||
window.addEventListener('scroll', function () {
|
||
requestAnimationFrame(sync);
|
||
}, { passive: true });
|
||
}
|
||
|
||
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,a,t){if(a===void 0){var r=null;if(document.cookie&&document.cookie!="")for(var n=document.cookie.split(";"),i=0;i<n.length;i++){var s=jQuery.trim(n[i]);if(s.substring(0,e.length+1)==e+"="){r=decodeURIComponent(s.substring(e.length+1));break}}return r}t=t||{},a===null&&(a="",t.expires=-1);var o="";if(t.expires&&(typeof t.expires=="number"||t.expires.toUTCString)){var d;typeof t.expires=="number"?(d=new Date,d.setTime(d.getTime()+24*t.expires*60*60*1e3)):d=t.expires,o="; expires="+d.toUTCString()}var u=t.path?"; path="+t.path:"",c=t.domain?"; domain="+t.domain:"",l=t.secure?"; secure":"";document.cookie=[e,"=",encodeURIComponent(a),o,u,c,l].join("")};var lcs={get:function(e){return window.localStorage?localStorage.getItem(e):jQuery.cookie(e)},set:function(e,a){window.localStorage?localStorage[e]=a:jQuery.cookie(e,a)},remove:function(e){window.localStorage?localStorage.removeItem(e):jQuery.cookie(e,"")}};function aksrt__(e){var a=window._win&&window._win.i18n;return a&&Object.prototype.hasOwnProperty.call(a,e)?a[e]:e}function aksrt_is_fatal_error_response(e){return e&&(e.indexOf("Fatal error")>-1||e.indexOf("致命错误")>-1)}function aksrt_sprintf(e){var a=Array.prototype.slice.call(arguments,1),t=aksrt__(e),r=0;return t.replace(/%(\d+\$)?s/g,function(n,i){var s=i?parseInt(i,10)-1:r++;return a[s]!==void 0&&a[s]!==null?a[s]:n})}(function(e,a){var t=a(e,e.document,Date);e.lazySizes=t,typeof module=="object"&&module.exports&&(module.exports=t)})(typeof window<"u"?window:{},function(a,t,r){"use strict";var n,i;if((function(){var w,y={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};i=a.lazySizesConfig||a.lazysizesConfig||{};for(w in y)w in i||(i[w]=y[w])})(),!t||!t.getElementsByClassName)return{init:function(){},cfg:i,noSupport:!0};var s=t.documentElement,o=a.HTMLPictureElement,d="addEventListener",u="getAttribute",c=a[d].bind(a),l=a.setTimeout,h=a.requestAnimationFrame||l,f=a.requestIdleCallback,p=/^picture$/i,g=["load","error","lazyincluded","_lazyloaded"],v={},b=Array.prototype.forEach,_=function(w,y){return v[y]||(v[y]=new RegExp("(\\s|^)"+y+"(\\s|$)")),v[y].test(w[u]("class")||"")&&v[y]},Q=function(w,y){_(w,y)||w.setAttribute("class",(w[u]("class")||"").trim()+" "+y)},j=function(w,y){var k;(k=_(w,y))&&w.setAttribute("class",(w[u]("class")||"").replace(k," "))},C=function(w,y,k){var L=k?d:"removeEventListener";k&&C(w,y),g.forEach(function(q){w[L](q,y)})},T=function(w,y,k,L,q){var z=t.createEvent("Event");return k||(k={}),k.instance=n,z.initEvent(y,!L,!q),z.detail=k,w.dispatchEvent(z),z},F=function(w,y){var k;!o&&(k=a.picturefill||i.pf)?(y&&y.src&&!w[u]("srcset")&&w.setAttribute("srcset",y.src),k({reevaluate:!0,elements:[w]})):y&&y.src&&(w.src=y.src)},X=function(w,y){return(getComputedStyle(w,null)||{})[y]},Z=function(w,y,k){for(k=k||w.offsetWidth;k<i.minSize&&y&&!w._lazysizesWidth;)k=y.offsetWidth,y=y.parentNode;return k},Y=(function(){var w,y,k=[],L=[],q=k,z=function(){var E=q;for(q=k.length?L:k,w=!0,y=!1;E.length;)E.shift()();w=!1},O=function(E,A){w&&!A?E.apply(this,arguments):(q.push(E),y||(y=!0,(t.hidden?l:h)(z)))};return O._lsFlush=z,O})(),G=function(w,y){return y?function(){Y(w)}:function(){var k=this,L=arguments;Y(function(){w.apply(k,L)})}},pe=function(w){var y,k=0,L=i.throttleDelay,q=i.ricTimeout,z=function(){y=!1,k=r.now(),w()},O=f&&q>49?function(){f(z,{timeout:q}),q!==i.ricTimeout&&(q=i.ricTimeout)}:G(function(){l(z)},!0);return function(E){var A;(E=E===!0)&&(q=33),!y&&(y=!0,A=L-(r.now()-k),A<0&&(A=0),E||A<9?O():l(O,A))}},oe=function(w){var y,k,L=99,q=function(){y=null,w()},z=function(){var O=r.now()-k;O<L?l(z,L-O):(f||q)(q)};return function(){k=r.now(),y||(y=l(z,L))}},le=(function(){var w,y,k,L,q,z,O,E,A,W,$,J,me=/^img$/i,ye=/^iframe$/i,ge="onscroll"in a&&!/(gle|ing)bot/.test(navigator.userAgent),_e=0,ae=0,R=0,ee=-1,de=function(m){R--,(!m||R<0||!m.target)&&(R=0)},ue=function(m){return J==null&&(J=X(t.body,"visibility")=="hidden"),J||!(X(m.parentNode,"visibility")=="hidden"&&X(m,"visibility")=="hidden")},we=function(m,x){var S,M=m,H=ue(m);for(E-=x,$+=x,A-=x,W+=x;H&&(M=M.offsetParent)&&M!=t.body&&M!=s;)H=(X(M,"opacity")||1)>0,H&&X(M,"overflow")!="visible"&&(S=M.getBoundingClientRect(),H=W>S.left&&A<S.right&&$>S.top-1&&E<S.bottom+1);return H},ce=function(){var m,x,S,M,H,I,B,D,V,U,K,te,N=n.elements;if((L=i.loadMode)&&R<8&&(m=N.length)){for(x=0,ee++;x<m;x++)if(!(!N[x]||N[x]._lazyRace)){if(!ge||n.prematureUnveil&&n.prematureUnveil(N[x])){re(N[x]);continue}if((!(D=N[x][u]("data-expand"))||!(I=D*1))&&(I=ae),U||(U=!i.expand||i.expand<1?s.clientHeight>500&&s.clientWidth>500?500:370:i.expand,n._defEx=U,K=U*i.expFactor,te=i.hFac,J=null,ae<K&&R<1&&ee>2&&L>2&&!t.hidden?(ae=K,ee=0):L>1&&ee>1&&R<6?ae=U:ae=_e),V!==I&&(z=innerWidth+I*te,O=innerHeight+I,B=I*-1,V=I),S=N[x].getBoundingClientRect(),($=S.bottom)>=B&&(E=S.top)<=O&&(W=S.right)>=B*te&&(A=S.left)<=z&&($||W||A||E)&&(i.loadHidden||ue(N[x]))&&(y&&R<3&&!D&&(L<3||ee<4)||we(N[x],I))){if(re(N[x]),H=!0,R>9)break}else!H&&y&&!M&&R<4&&ee<4&&L>2&&(w[0]||i.preloadAfterLoad)&&(w[0]||!D&&($||W||A||E||N[x][u](i.sizesAttr)!="auto"))&&(M=w[0]||N[x])}M&&!H&&re(M)}},P=pe(ce),fe=function(m){var x=m.target;if(x._lazyCache){delete x._lazyCache;return}de(m),Q(x,i.loadedClass),j(x,i.loadingClass),C(x,he),T(x,"lazyloaded"),l(function(){Q(x,i.loadafterClass)},700)},be=G(fe),he=function(m){be({target:m.target})},je=function(m,x){try{m.contentWindow.location.replace(x)}catch{m.src=x}},xe=function(m){var x,S=m[u](i.srcsetAttr);(x=i.customMedia[m[u]("data-media")||m[u]("media")])&&m.setAttribute("media",x),S&&m.setAttribute("srcset",S)},Qe=G(function(m,x,S,M,H){var I,B,D,V,U,K;(U=T(m,"lazybeforeunveil",x)).defaultPrevented||(M&&(S?Q(m,i.autosizesClass):m.setAttribute("sizes",M)),B=m[u](i.srcsetAttr),I=m[u](i.srcAttr),H&&(D=m.parentNode,V=D&&p.test(D.nodeName||"")),K=x.firesLoad||"src"in m&&(B||I||V),U={target:m},Q(m,i.loadingClass),K&&(clearTimeout(k),k=l(de,2500),C(m,he,!0)),V&&b.call(D.getElementsByTagName("source"),xe),B?m.setAttribute("srcset",B):I&&!V&&(ye.test(m.nodeName)?je(m,I):m.src=I),H&&(B||V)&&F(m,{src:I})),m._lazyRace&&delete m._lazyRace,j(m,i.lazyClass),Y(function(){var te=m.complete&&m.naturalWidth>1;(!K||te)&&(te&&Q(m,"ls-is-cached"),fe(U),m._lazyCache=!0,l(function(){"_lazyCache"in m&&delete m._lazyCache},9)),m.loading=="lazy"&&R--},!0)}),re=function(m){if(!m._lazyRace){var x,S=me.test(m.nodeName),M=S&&(m[u](i.sizesAttr)||m[u]("sizes")),H=M=="auto";(H||!y)&&S&&(m[u]("src")||m.srcset)&&!m.complete&&!_(m,i.errorClass)&&_(m,i.lazyClass)||(x=T(m,"lazyunveilread").detail,H&&se.updateElem(m,!0,m.offsetWidth),m._lazyRace=!0,R++,Qe(m,x,H,M,S))}},ke=oe(function(){i.loadMode=3,P()}),ve=function(){i.loadMode==3&&(i.loadMode=2),ke()},ne=function(){if(!y){if(r.now()-q<999){l(ne,999);return}y=!0,i.loadMode=3,P(),c("scroll",ve,!0)}};return{_:function(){q=r.now(),n.elements=t.getElementsByClassName(i.lazyClass),w=t.getElementsByClassName(i.lazyClass+" "+i.preloadClass),c("scroll",P,!0),c("resize",P,!0),c("pageshow",function(m){if(m.persisted){var x=t.querySelectorAll("."+i.loadingClass);x.length&&x.forEach&&h(function(){x.forEach(function(S){S.complete&&re(S)})})}}),a.MutationObserver?new MutationObserver(P).observe(s,{childList:!0,subtree:!0,attributes:!0}):(s[d]("DOMNodeInserted",P,!0),s[d]("DOMAttrModified",P,!0),setInterval(P,999)),c("hashchange",P,!0),["focus","mouseover","click","load","transitionend","animationend"].forEach(function(m){t[d](m,P,!0)}),/d$|^c/.test(t.readyState)?ne():(c("load",ne),t[d]("DOMContentLoaded",P),l(ne,2e4)),n.elements.length?(ce(),Y._lsFlush()):P()},checkElems:P,unveil:re,_aLSL:ve}})(),se=(function(){var w,y=G(function(z,O,E,A){var W,$,J;if(z._lazysizesWidth=A,A+="px",z.setAttribute("sizes",A),p.test(O.nodeName||""))for(W=O.getElementsByTagName("source"),$=0,J=W.length;$<J;$++)W[$].setAttribute("sizes",A);E.detail.dataAttr||F(z,E.detail)}),k=function(z,O,E){var A,W=z.parentNode;W&&(E=Z(z,W,E),A=T(z,"lazybeforesizes",{width:E,dataAttr:!!O}),A.defaultPrevented||(E=A.detail.width,E&&E!==z._lazysizesWidth&&y(z,W,A,E)))},L=function(){var z,O=w.length;if(O)for(z=0;z<O;z++)k(w[z])},q=oe(L);return{_:function(){w=t.getElementsByClassName(i.autosizesClass),c("resize",q)},checkElems:q,updateElem:k}})(),ie=function(){!ie.i&&t.getElementsByClassName&&(ie.i=!0,se._(),le._())};return l(function(){i.init&&ie()}),n={cfg:i,autoSizer:se,loader:le,init:ie,uP:F,aC:Q,rC:j,hC:_,fire:T,gW:Z,rAF:Y},n}),jQuery.fn.minitouch=function(e){var a="minitouch-isload",t=jQuery(this);if(!t.data(a)){e=jQuery.extend({direction:"bottom",selector:"",start_selector:"",depreciation:50,stop:!1,onStart:!1,onIng:!1,onEnd:!1,inEnd:!1},e);var r=!1,n=e.depreciation,i=0,s=0,o=0,d=0,u=0,c=0,l=0,h=!1,f=function(v,b,_,Q,j){var C,T,F;Q&&(b+="px",_+="px",C="translate3D("+b+","+_+" , 0)",T={},F=p(),T[F+"transform"]=C,T[F+"transition"]=F+"transform 0s linear",T.cursor=j,Q=="null"&&(T[F+"transform"]="",T[F+"transition"]=""),v.css(T))},p=function(){var v=document.body||document.documentElement;return v=v.style,v.WebkitTransition==""?"-webkit-":v.MozTransition==""?"-moz-":v.OTransition==""?"-o-":v.transition==""?"":void 0},g=e.start_selector||e.selector;t.on("touchstart pointerdown MSPointerDown",g,function(v){i=s=o=d=u=c=l=0,i=v.originalEvent.pageX||v.originalEvent.touches[0].pageX,s=v.originalEvent.pageY||v.originalEvent.touches[0].pageY,h=!0,jQuery(v.target).parentsUntil(g,".swiper-container,.scroll-x").length&&(h=!1)}).on("touchmove pointermove MSPointerMove",g,function(v){var b=e.start_selector?e.selector?t.find(e.selector):t.find(e.start_selector):jQuery(this);jQuery.isFunction(e.stop)&&(r=e.stop(t,b,i,s)),h&&!r&&(o=v.originalEvent.pageX||v.originalEvent.touches[0].pageX,d=v.originalEvent.pageY||v.originalEvent.touches[0].pageY,c=o-i,l=d-s,u=180*Math.atan2(l,c)/Math.PI,e.direction=="right"&&(l=0,c=u>-40&&u<40&&c>0?c:0),e.direction=="left"&&(l=0,c=(u>150||u<-150)&&0>c?c:0),e.direction=="top"&&(c=0,l=u>-130&&u<-50&&0>l?l:0),e.direction=="bottom"&&(c=0,l=u>50&&u<130&&l>0?l:0),(c!==0||l!==0)&&(v.preventDefault?v.preventDefault():v.returnValue=!1,f(b,c,l,h,"grab"),jQuery.isFunction(e.onIng)&&e.onIng(t,b,c,l)))}).on("touchend touchcancel pointerup MSPointerUp",g,function(){var v=e.start_selector?e.selector?t.find(e.selector):t.find(e.start_selector):jQuery(this);h&&!r&&(f(v,0,0,"null",""),jQuery.isFunction(e.inEnd)&&e.inEnd(t,v,c,l),(Math.abs(c)>n||Math.abs(l)>n)&&jQuery.isFunction(e.onEnd)&&e.onEnd(t,v,c,l),i=s=o=d=u=c=l=0,h=!1)}).data(a,!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 e=jQuery(this).attr("data-toggle-class")||"show",a=jQuery(this).attr("data-target")||this;return jQuery(a).toggleClass(e).trigger("toggleClass"),!1}),_win.bd.on("click",only_drop),_win.bd.on("toggleClass",".dropup,.dropdown",only_drop);function only_drop(e){var a=jQuery(e.target).closest(".dropup,.dropdown");jQuery(".dropup.open,.dropdown.open").not(a).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(e,a,t,r){var n=/\S+/g,i=!1;e=e.match(n)[0];var s=jQuery._data(this[0],"events");s&&typeof s.type<"u"&&jQuery.each(s[e],function(o,d){if(d.selector==a&&d.data==t)return i=!0,!1}),i?console.log("事件重复绑定{type:"+e+",selector:"+a+",data:"+t+"}"):this.on(e,a,t,r)},jQuery.fn.aksrt_ajax=function(e,a,t,r){return aksrt_ajax(jQuery(this),e,a,t,r)},jQuery.fn.countdown=function(){function e(a,t){var r=new Date,n=r.getTime(),i=new Date(a),s=i.getTime(),o=s-n,d=o/1e3%60;d=d.toFixed(2);var u=~~(o%1e3),c=~~(o/1e3/60%60),l=~~(o/(1e3*60*60)%24),h=~~(o/(1e3*60*60*24));return t==="minute"&&c>0&&(l=0,h=0,c=~~(o/1e3/60)),t==="hour"&&l>0&&(h=0,l=~~(o/(1e3*60*60))),d=d<10?"0"+d:d,c=c<10?"0"+c:c,{total:o,days:h,hours:l,minutes:c,seconds:d,mseconds:u}}jQuery(this).each(function(){var a=jQuery(this),t=a.attr("data-countdown");if(!t)return;var r=a.attr("int-second"),n=a.attr("max-unit");if(a.attr("title",aksrt__("countdown_end_time")+t),r==="auto"){var i=e(t,n);r=i.days>0}function s(){var d=e(t,n);if(r&&(d.seconds=d.seconds.toString().replace(/\.\d+$/,"")),a.find(".day").length&&a.find(".day").html(d.days),a.find(".hour").length&&a.find(".hour").html(d.hours),a.find(".minute").length&&a.find(".minute").html(d.minutes),a.find(".second").length)a.find(".second").html(d.seconds);else{var u="";d.days>0&&(u+='<span class="day">'+d.days+'</span><span class="day-unit">'+aksrt__("countdown_day")+"</span>"),(d.hours>0||d.days>0)&&(u+='<span class="hour">'+d.hours+'</span><span class="hour-unit">'+aksrt__("countdown_hour")+"</span>"),(d.minutes>0||d.hours>0||d.days>0)&&(u+='<span class="minute">'+d.minutes+'</span><span class="minute-unit">'+aksrt__("countdown_minute")+"</span>"),u+='<span class="second">'+d.seconds+'</span><span class="second-unit">'+aksrt__("countdown_second")+"</span>",a.html(u)}if(d.total<=0){clearInterval(o);var c=a.attr("data-over-text")||aksrt__("countdown_ended");a.html(c).trigger("countdown-over")}}s();var o=setInterval(s,r?1e3:20);a.removeAttr("data-countdown").addClass("countdown-box")})},_win.dplayer={tbquire:["dplayer"],obj:{}};function new_dplayer(){var e=".new-dplayer:not(.dplayer-initialized),[data-dplayer]:not(.dplayer-initialized)";jQuery(e).length&&jQuery(e).each(function(){var a=jQuery(this);get_new_dplayer(a,function(t){a.addClass("dplayer-initialized").siblings(".dplayer-featured").find(".switch-video").each(function(){var r=jQuery(this),n=r.attr("video-url"),i=r.attr("video-pic");r.data({"video-url":n,"video-pic":i}),r.attr({"dplayer-id":t.container.id}),setTimeout(function(){r.removeAttr("video-url").removeAttr("video-pic")},50)})})})}function get_new_dplayer(e,a){var t={},r=e.attr("video-url")||e.data("video-url"),n=e.attr("data-volume"),i=parseInt((Math.random()+1)*Math.pow(10,4));if(!(e.find(".dplayer-video-wrap").length||!r)){e.attr("id","dplayer-"+i),t.container=document.getElementById("dplayer-"+i),t.theme="#f04494",t.video={url:r,pic:e.attr("video-pic")||"",type:e.attr("video-type")||"auto"},e.attr("data-loop")&&(t.loop=!0),e.attr("data-autoplay")&&(t.autoplay=!0),n&&n<1&&(t.volume=n),n==="none"&&(t.volume=0);var s=e.attr("video-option");if(s){try{s=JSON.parse(s)}catch(d){console.log(d)}jQuery.extend(t,s)}var o=r.toLowerCase();return o.indexOf(".m3u")!=-1&&_win.dplayer.tbquire.push("hls"),o.indexOf(".mpd")!=-1&&_win.dplayer.tbquire.push("dash"),o.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 d=new DPlayer(t);d.on("play",function(){_win.dplayer.play=d}),e.data("dplayer",d),_win.dplayer.obj[i]=d,e.attr({"video-url":"","video-pic":""}),jQuery.isFunction(a)&&a(d)}catch(u){console.error(u)}}),i}}_win.bd.on("click",".swiper-slide.slide-dplayer:not(.slide-dplayer-played) > *",function(){var e=jQuery(this),a=e.find(".new-dplayer").data("dplayer");a&&(a.play(),e.parent().addClass("slide-dplayer-played"))});function thumb_dplayer(e,a){var t=jQuery("body"),r="thumb_dplayer_data",n=t.data(r)||{};if(n[e+a])return;var i="thumb-dplayer-playing",s="dplayer-thumb-hide";function o(h,f,p){f.find(".dplayer-thumb").removeClass(s),_win.dplayer.thumb_play=p,f.find(".progress").show(),h.addClass(i)}function d(h,f,p){p.pause(),f.find(".dplayer-thumb").addClass(s),_win.dplayer.thumb_play=!1,f.find(".progress").hide(),h.removeClass(i)}function u(){if(_win.dplayer.thumb_play){var h=jQuery(_win.dplayer.thumb_play.container).closest(a),f=h.closest(e);d(f,h,_win.dplayer.thumb_play)}}function c(){var h=jQuery(this),f=h.find(a);if(!f.length)return;var p=f.find(".dplayer-thumb").data("dplayer");if(p)return o(h,f,p),p.play();function g(T){T.on("loadeddata",function(){setTimeout(function(){f.find(".progress-bar").css({width:"100%",opacity:"0",transition:"width .2s, opacity .3s .3s"})},100),setTimeout(function(){f.find(".progress").remove()},800)}),setTimeout(function(){o(h,f,T),T.play()},200)}if(!f.find(".dplayer-thumb").length){var v=f.attr("video-url"),b=f.attr("data-volume")||"none",_="",Q=~~f.attr("scale-height"),j='<div class="progress progress-striped active progress-abs-bottom"><div class="progress-bar progress-bar-success"></div></div>',C=jQuery('<div class="dplayer-thumb-hide new-dplayer dplayer-thumb controller-hide'+(Q?" dplayer-scale-height":"")+'"'+(Q?' style="--scale-height:'+Q+'%;"':"")+' data-loop="true" data-volume="'+b+'" data-hide="true" video-url="'+v+'" video-pic="'+_+'" video-type="auto"></div>');f.find(".video-thumb").html(C).after(j),setTimeout(function(){f.find(".progress-bar").css({transition:"width 6s",width:"80%"})},50),f.attr("video-url",""),get_new_dplayer(C,g)}}t.on("mouseenter touchstart",e,c),t.on("mouseleave",e,u);var l="thumb_dplayer_init";t.data(l)||t.on("touchstart",function(h){var f=jQuery(h.target);!f.parents("."+i).length&&_win.dplayer.thumb_play&&u()}).data(l,!0),n[e+a]=!0,t.data(r,n)}_win.bd.on("click",".switch-video",function(){var e=jQuery(this),a=jQuery("#"+e.attr("dplayer-id")).data("dplayer"),t=e.data("video-url"),r=e.data("video-pic");if(!(!t||!a||e.hasClass("active"))){e.addClass("active").siblings().removeClass("active");var n=t.toLowerCase();n.indexOf(".m3u")!=-1&&_win.dplayer.tbquire.push("hls"),n.indexOf(".mpd")!=-1&&_win.dplayer.tbquire.push("dash"),n.indexOf(".flv")!=-1&&_win.dplayer.tbquire.push("flv"),tbquire(_win.dplayer.tbquire,function(){try{var i={url:t,type:"auto"};r&&(i.pic=r),a.switchVideo(i),setTimeout(function(){a.play()},100)}catch(s){console.log(s)}})}}),_win.bd.on("click",".switch-iframe",function(){var e=jQuery(this),a=e.attr("iframe-url"),t=e.closest(".iframe-series").find("iframe");if(!(!a||e.hasClass("active"))){try{t[0].contentWindow.location.replace(a)}catch{t.attr("src",a)}e.addClass("active").siblings().removeClass("active")}}),_win.bd.on("click",".file-download-btn",function(){var e=jQuery(this),a=e.attr("data-download-file"),t=e.attr("download-nonce");if(e.attr("target","_blank"),!!a){var r=_win.ajax_url+"?action=download_file&file="+a+"&nonce="+t;e.attr("target","_blank").removeAttr("data-download-file").attr("href",r)}}),_win.bd.on("click",".post-tab-toggle",function(){var e=jQuery(this),a=e.attr("tab-id");if(!e.parent().hasClass("active")){var t=e.parent().addClass("active").siblings().removeClass("active").parent().next().find('[tab-id="'+a+'"]');t.siblings().removeClass("in"),setTimeout(function(){t.addClass("active").siblings().removeClass("active")},150),setTimeout(function(){t.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 a={},t=jQuery(this),r="swiper-scroll-eq-"+e,n=t.attr("data-slideClass")||!1;if(n&&(a.slideClass=n),!t.attr("scroll-nogroup")){var i=t.width(),s=t.find(".swiper-wrapper>*:eq(0)").outerWidth(),o=~~(i/s);a.slidesPerGroup=o||1}a.autoplay=t.attr("data-autoplay")?{delay:~~t.attr("data-interval")||4e3,disableOnInteraction:!1}:!1,a.loop=t.attr("data-loop"),a.slidesPerView="auto",a.mousewheel={forceToAxis:!0},a.freeMode=!0,a.freeModeSticky=!0,a.navigation={nextEl:".swiper-scroll."+r+" .swiper-button-next",prevEl:".swiper-scroll."+r+" .swiper-button-prev"},t.addClass(r).attr("swiper-scroll-index",e),_win.swiper.scroll[e]=new Swiper(".swiper-scroll."+r,a)}}),jQuery(".swiper-tab").each(function(e){if(!jQuery(this).hasClass("swiper-container-initialized")){var a="swiper-eq-"+e,t=jQuery(this),r=~~t.attr("data-speed")||~~((t.width()+1200)/170)*50,n=~~t.attr("active-index");r=r<300?300:r;var i={loop:!1,initialSlide:n,autoHeight:!0,spaceBetween:20,autoplay:!1,speed:r,pagination:{el:".swiper-tab."+a+" .swiper-pagination",clickable:!0},on:{init:function(){auto_maxHeight()},slideChangeTransitionEnd:function(u){var c=jQuery(".swiper-tab."+a+" .swiper-slide-active .post_ajax_trigger .ajax-open");c.length&&(scrollTopTo(jQuery(".swiper-tab."+a),-40),c.attr("no-scroll",!0).click());var l=u.onStart&&jQuery('[swiper-scroll-index="'+e+'"] .swiper-slide-thumb-active [data-route]');l&&l.length&&history.replaceState(null,document.title,l.attr("data-route")),u.onStart=!0}}},s=t.attr("swiper-tab"),o=jQuery('[swiper-tab-nav="'+s+'"]');if(o.length){var d=o.attr("swiper-scroll-index");i.thumbs={swiper:_win.swiper.scroll[d],autoScrollOffset:2},o.on("click","a[data-route]",function(u){u.preventDefault()})}t.addClass(a).attr("swiper-tab-index",e),_win.swiper.tab[e]=new Swiper(".swiper-tab."+a,i)}}),jQuery(".new-swiper").each(function(e){if(!jQuery(this).hasClass("swiper-container-initialized")){var a="swiper-eq-"+e,t=jQuery(this),r=~~t.attr("data-interval")||6e3,n=t.attr("data-autoplay")?{delay:r,disableOnInteraction:!1}:!1,i=!!t.attr("auto-height"),s=~~t.attr("data-speed")||~~((t.width()+1e3)/22)*10;s=s<400?400:s,s=n===!1?s/1.6:s;var o=!!t.attr("data-loop"),d=!!t.find("[data-swiper-parallax],[data-swiper-parallax-scale]").length,u=t.attr("data-effect")||"slide",c=t.attr("data-direction")||"horizontal",l=~~t.attr("data-spaceBetween")||0,h=t.attr("data-pagination-type")||"bullets";t.addClass(a).attr("swiper-new-index",e);var f={loop:o,autoHeight:i,direction:c,spaceBetween:l,parallax:d,effect:u,lazy:{loadPrevNext:!0},autoplay:n,speed:s,pagination:{el:".new-swiper."+a+" .swiper-pagination",type:h,clickable:!0},navigation:{nextEl:".new-swiper."+a+" .swiper-button-next",prevEl:".new-swiper."+a+" .swiper-button-prev"},on:{lazyImageReady:function(p,g){jQuery(g).addClass("lazyloaded")},slideChange:function(){t.find(".new-dplayer").each(function(p,g){var v=jQuery(g).data("dplayer");v&&v.pause()})},init:function(){o&&t.find(".swiper-slide-duplicate img").addClass("no-imgbox")}}};h==="thumbnail"&&(f.pagination.type="bullets",f.pagination.bulletClass="pagination-thumbnail-item",f.pagination.bulletActiveClass="pagination-thumbnail-item-active",f.pagination.renderBullet=function(p,g){var v,b,_=jQuery(this.slides[p]).find("img");return _.length&&(_=jQuery(_[0]),v=_.attr("data-src")||_.attr("src")),v?(b='<div class="'+g+'"><image class="obj-fit no-imgbox" src="'+v+'"></div>',b):""}),_win.swiper.new[e]=new Swiper(".new-swiper."+a,f)}})}))}window.swiper_tab_AutoHeight=debounce(function(e){var a=e.closest("[swiper-tab-index]");if(a.length){var t=a.attr("swiper-tab-index");_win.swiper.tab[t].updateAutoHeight(500)}},100),jQuery.fn.scrollX=function(){return this.each(function(){var e=jQuery(this),a="is-on";if(!e.data(a)){e.data(a,!0);var t="scroll-x-",r=t+"prev",n=t+"next",i=jQuery('<div class="'+r+'" style="display: none;"></div>'),s=jQuery('<div class="'+n+'" style="display: none;"></div>');d()}function o(l){var h=c();e.animate({scrollLeft:l==="prev"?h[0]:h[1]},300,"linear",u)}function d(){e.after(i).after(s),i.on("click",function(){o("prev")}),s.on("click",o),e.parent().hover(u,function(){i.hide(),s.hide()})}function u(){var l=c();l[3]?i.show():i.hide(),l[3]<l[2]?s.show():s.hide()}function c(){var l=e.innerWidth(),h=e.scrollLeft(),f=~~(e.prop("scrollWidth")-l),p=~~(h-l);p=p>0?p:0;var g=~~(h+l);return g=g>f?f:g,[p,g,f,h]}})},jQuery.fn.Tabcenter=function(){return this.each(function(){var e=jQuery(this),a=e.find(".active");if(a.length){var t=e.innerWidth(),r=a.innerWidth(),n=e.scrollLeft(),i=a.position().left,s=~~(e.prop("scrollWidth")-t),o=~~(n+i-t/2+r/2);o=o>0?o:0,o=o>s?s:o,o!=n&&e.animate({scrollLeft:o},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(e,a,t,r,n,i,s,o,d,u,c,l){var h=e.closest(a);if(h.attr("ing"))return!1;var f=v(r),p=e.attr("ajax-href")||e.attr("href")||e.find("a").attr("ajax-href")||e.find("a").attr("href");t=t||a,l=l||(_win.ajax_trigger?_win.ajax_trigger:'<i class="fa fas fa-arrow-right"></i>'+aksrt__("load_more")),d=e.attr("ajax-replace")||d,u=u||_win.ajax_nomore;var g=v(".post_ajax_loader");g.length||(n=n||'<div class="theme-box box-body ajax-loading text-center"><h2 class="loading zts"></h2></div>',g=jQuery('<div class="post_ajax_loader">'+n+"</div>"));function v(b,_,Q){_=_&&_.length?_:h,Q=Q||a;var j=_.find(">"+b);return j.length||(j=_.find(">*:not("+Q+")>"+b),j.length)||(j=_.find(">*:not("+Q+")>*:not("+Q+")>"+b),j.length)||(j=_.find(">*:not("+Q+")>*:not("+Q+")>*:not("+Q+")>"+b),j.length)?j:jQuery("null#null")}return p&&jQuery.ajax({type:"POST",url:p,dataType:"html",beforeSend:function(){d&&f.length&&f.remove(),h.attr("ing",!0),v(".post_ajax_trigger").remove(),v(".no-more").remove(),v(".post_ajax_loader").remove(),v(".noajax-pag").remove(),v(i).remove(),f=v(r),f.length?c?f.first().before(g):f.last().after(g):h.append(g),g.fadeIn(),swiper_tab_AutoHeight(h)},success:function(b){b=jQuery.parseHTML("<div>"+b+"</div>");var _=jQuery(b);_.find("[win-ajax-replace]").each(function(){var Y=jQuery(this).attr("win-ajax-replace"),G=jQuery('[win-ajax-replace="'+Y+'"]');G.length&&(G.html(jQuery(this).html()),jQuery(this).remove())});var Q=_.find(t),j=v(r,Q,t),C=v(i,Q,t),T=C.find(s).attr("href")||C.find(s).find("a").attr("href");C=C.length?C:'<div class="text-center mb20 padding-h10 muted-2-color no-more separator">'+u+"</div>",C=Q.find(".noajax-pag").length?Q.find(".noajax-pag"):C,o&&(C=typeof T<"u"?'<span class="post_ajax_trigger"><a class="'+o+'" href="'+T+'">'+l+"</a></span>":C);var F=v(".ajax-item-header",Q,t);if(F.length&&(v(".ajax-item-header").remove(),h.prepend(F)),f=v(r),f.length?c?f.first().before(C).before(j):f.last().after(C).after(j):c?h.append(C).append(j):h.append(j).append(C),h.removeAttr("ing").trigger("post_ajax.ed",jQuery(b)),v(".post_ajax_loader",h).hide(),e.attr("no-scroll"))_win.auto_scroll=!0,setTimeout(function(){_win.window.trigger("scroll"),_win.auto_scroll=!1},20);else{var X=d?h:jQuery(j[0]);setTimeout(function(){scrollTopTo(X,-40)},100)}if(e.attr("route")){var Z=e.attr("route-title")||_.find("title").text();history.replaceState(null,Z,p),Z&&jQuery("head title").text(Z)}swiper_tab_AutoHeight(h),auto_fun()}}),!1}if(_win.bd.on("click","[remote-box]",function(){var e=jQuery(this),a=e.attr("remote-box");a&&jQuery.post(a,null,function(t){e.html(t).removeAttr("remote-box"),auto_fun(),e.trigger("aksrt:remote-loaded")})}),_win.bd.on("show.bs.tab","a[data-ajax]",function(){var e=jQuery(this),a=e.data("target")||e.attr("href"),t=a+" .post_ajax_trigger .ajax-next",r=jQuery(t).attr("ajax-replace",!0);if(r.length)r.click();else{var n=e.attr("data-ajax");if(n){var i='<span class="post_ajax_trigger hide"><a ajax-href="'+n+'" class="ajax_load ajax-next ajax-open" ajax-replace="true"></a></span>';jQuery(a).append(i),jQuery(t).click()}}e.attr("only-one")&&e.removeAttr("data-ajax")}),_win.bd.on("click","[ajax-tab],[ajax-target]",function(){var e=jQuery(this),a=e.attr("ajax-replace")?' ajax-replace="true"':"",t=e.attr("ajax-tab")||e.attr("ajax-target"),r=e.attr("data-ajax"),n='<span class="post_ajax_trigger hide"><a ajax-href="'+r+'" class="ajax_load ajax-next ajax-open"'+a+"></a></span>";console.log(t),jQuery(t).find(".post_ajax_trigger").remove(),jQuery(t).append(n),jQuery(t+" .post_ajax_trigger .ajax-next").click(),jQuery('a[href="'+t+'"]').click()}),_win.bd.on("click",".ajax-next",function(e){e.preventDefault();var a=jQuery(this);if(a.hasClass("pag-jump"))return!1;var t='<div class="text-center muted-2-color mt20"><i class="loading mr10"></i>'+aksrt__("loading")+"</div>";a.attr("ajax-replace")&&(t='<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>',t+=t,t+=t),t='<div class="mb20">'+t+"</div>";var r=a.attr("ajaxpager-target")||".ajaxpager",n=a.attr("ajaxitem-target")||".ajax-item",i=a.parents(r+":eq(0)").find(n+":first"),s=i.attr("class");if(s&&s.indexOf("posts-item")>-1)if(s.indexOf("card")>-1){var o=s.replace("ajax-item","");t='<div class="'+o+'"><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>',t=t.repeat(_wid>766?_wid>992&&!jQuery(".sidebar").length?8:6:4)}else s.indexOf("list")>-1&&(t='<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>',t=t.repeat(_wid>766?4:3));return post_ajax(a,r,r,n,t,".ajax-pag")}),_wid<769&&jQuery(".drawer-sm").length){_win.bd.on("click","[data-drawer]",function(){var e=jQuery(this),a=e.attr("drawer-title")||"",t=e.attr("drawer-selector")||".drawer-sm",r=e.attr("data-drawer"),n=e.attr("route"),i=e.attr("route-back");jQuery(t).Drawer(r,a,n,i)});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 e=jQuery(this);if(!history.state){var a=e.attr("route")||e.attr("data-route"),t=e.attr("data-target");a&&history.replaceState({tab_id:t},null,a)}}function tabOnRoute(){var e=jQuery(this);if(e.attr("onpopstate"))e.attr("onpopstate",!1);else{var a=e.attr("route")||e.attr("data-route"),t=e.attr("data-target");a&&routeGo(a,{tab_id:t})}}window.onpopstate=function(e){var a=e.state&&jQuery('[data-toggle="tab"][data-target="'+e.state.tab_id+'"]');a&&a.length&&a.attr("onpopstate",!0).click()};function routeGo(e,a,t){t=t||document.title,e&&history.pushState(a,t,e)}if(jQuery.fn.loading=function(e){var a=jQuery(this);e=e=="show"||e=="hide"?e:a.hasClass("loading-show")?"hide":"show";var t="loading-backdrop",r='<div class="'+t+'" style="display:none;"><svg class="loading-circle" viewBox="0 0 50 50"><circle cx="25" cy="25" r="20"></circle></svg></div>';return e=="show"?a.addClass("loading-show").append(r).find("."+t).fadeIn(200):a.removeClass("loading-show").find("."+t).fadeOut(200,function(){jQuery(this).remove()}),a},jQuery.fn.Drawer=function(e,a,t,r){a=a||"";var n=jQuery(this);if(!n.length)return;e=e=="show"||e=="hide"?e:n.hasClass("show")?"hide":"show";var i=jQuery("body");n.attr("on-start")||n.attr("on-start",!0).minitouch({direction:"right",onEnd:function(){n.Drawer("hide")}});function s(d){history.replaceState(null,document.title,d)}switch(e){case"show":var o=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">'+a+"</div></div>").on("click",".drawer-close",function(){n.Drawer("hide")});return i.append(o),setTimeout(function(){i.addClass("drawer-show")},10),r&&n.data("route_back",r),t&&s(t),n.addClass("show");case"hide":return i.removeClass("drawer-show"),setTimeout(function(){jQuery(".drawer-header").remove()},400),s(n.data("route_back")),n.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(e){var a=jQuery(this),t="swiper-post-"+e;a.find(".wp-block-gallery>.blocks-gallery-grid").length&&a.find(".wp-block-gallery").html(a.find(".wp-block-gallery>.blocks-gallery-grid").html()),a.find(".wp-block-gallery").removeClass().addClass("swiper-wrapper").find(".blocks-gallery-item,>.wp-block-image").addClass("swiper-slide"),a.find(".carousel-control.left").replaceWith('<div class="swiper-button-next"></div>'),a.find(".carousel-control.right").replaceWith('<div class="swiper-button-prev"></div><div class="swiper-pagination"></div>');var r=a.find(".carousel"),n=r.attr("proportion")||.6,i=r.attr("style");r.addClass(t+" new-swiper scale-height").attr("style","--scale-height:"+n*100+"%;"),a.attr("style",i);var s=~~r.attr("data-interval")||6e3,o=r.attr("data-jyloop")||!1,d=r.attr("data-effect")||"slide",u=~~((r.width()+1200)/250)*100;Sw["swiper_wz_"+e]=new Swiper(".wp-block-carousel ."+t,{spaceBetween:10,speed:u,loop:o,effect:d,autoplay:{delay:s,disableOnInteraction:!1},pagination:{el:"."+t+" .swiper-pagination",clickable:!0},navigation:{nextEl:"."+t+" .swiper-button-next",prevEl:"."+t+" .swiper-button-prev"}})})})}_win.bd.on("show.bs.modal loaded.bs.modal",".modal:not(.flex)",function(){var e=jQuery(this),a=e.find(".modal-dialog");e.css("display","block"),a.css({"margin-top":Math.max(0,(_hei-a.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 e=jQuery(this),a={action:"user_oauth_untying",user_id:e.attr("user-id"),type:e.attr("untying-type"),_wpnonce:e.attr("_wpnonce")};return aksrt_ajax(e,a),!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 a=jQuery(this).attr("tab-id");if(a){var t=jQuery('a[data-target="#'+a+'"]');t.length||(t=jQuery('a[href="#'+a+'"]')),t.length&&(e.preventDefault(),t.tab("show"))}}),_win.bd.on("click",'[data-toggle="RefreshModal"]',function(e){e.preventDefault();var a=jQuery(this),t=a.attr("data-remote");if(!t){var r=a.attr("data-action");r&&(t=_win.ajax_url+"?action="+r)}return refresh_modal({class:a.attr("data-class")||"",height:a.attr("data-height")||300,mobile_from_bottom:!!a.attr("mobile-bottom"),new:a.attr("new"),touch_close:!a.attr("no-touch"),remote:t}),!1}),_win.bd.on("click",".show-order-modal",function(e){e.preventDefault();var a=jQuery(this),t=a.attr("data-order-id"),r=a.attr("new-modal");refresh_modal({class:"full-sm body-bg",height:420,mobile_from_bottom:!0,touch_close:!0,new:r,remote:_win.ajax_url+"?action=order_details_modal&order_id="+t})});function refresh_modal(e){e.mobile_from_bottom=typeof e.mobile_from_bottom>"u"?!0:e.mobile_from_bottom;var a="refresh_modal",t=e.new,r=e.class||"",n=e.height||200,i=e.mobile_from_bottom&&_wid<769?" bottom":"",s=typeof e.touch_close>"u"?!0:e.touch_close,o="modal flex jc fade"+i,d=e.remote||"",u=e.content||"";r+=" modal-dialog",a+=t?parseInt((Math.random()+1)*Math.pow(10,4)):"";var c="#"+a,l=jQuery(c);if(l.length){var h=l.hasClass("in");h&&(o+=" in");var f=l.find(".modal-content");l.removeClass().addClass(o),l.find(".modal-dialog").removeClass().addClass(r),l.find(".loading-mask").fadeIn(200),l.find(".modal-body").fadeOut(200),f.css({overflow:"hidden",height:h?f.height():100}).animate({height:n})}else{var p='<div class="'+o+'" id="'+a+'" tabindex="-1" role="dialog" aria-hidden="false"> <div class="'+r+'" role="document"> <div class="modal-content"> </div> </div> </div>',g='<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(p),l=jQuery(c),l.on("hidden.bs.modal",function(){t?jQuery(this).remove():jQuery(this).find(".modal-content").html(g)}),l.find(".modal-content").html(g).css({height:n,overflow:"hidden"}),_wid<769&&l.minitouch({direction:"bottom",selector:".modal-dialog",start_selector:".modal-colorful-header,.touch-close,.touch",onEnd:function(){l.modal("hide")},stop:function(){return!l.hasClass("bottom")}})}l.find(".touch-close").remove(),i&&s&&l.find(".modal-dialog").append('<div class="touch-close"></div>'),l.modal("show"),u?(l.find(".modal-body").html(u),v()):d&&jQuery.post(d,null,function(b){l.find(".modal-body").html(b),setTimeout(function(){l.trigger("loaded.bs.modal")},20),v()});function v(){l.find(".modal-body").fadeIn(50,function(){var b=jQuery(this).outerHeight(!0);l.find(".loading-mask").fadeOut(300),l.find(".modal-content").animate({height:b},300,"swing",function(){l.find(".modal-content").css({height:"",overflow:"",transition:""})})})}return l}window.auto_maxHeight=debounce(z_auto,100);function z_auto(){if(_win.do_hh=document.documentElement.clientHeight,_win.do_hh>document.body.clientHeight){var e=_win.do_hh-jQuery(".footer").outerHeight()-jQuery(".header").outerHeight()-20;jQuery("main").animate({"min-height":e})}}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 e=_win.highlight_kg?"pre code:not(.enlighter-origin)":"pre code.gl:not(.enlighter-origin),pre code.special:not(.enlighter-origin)";jQuery(e).length&&tbquire(["enlighterjs"],function(){var a=!!_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(e).enlight({linenumbers:a,indent:2,textOverflow:"scroll",rawcodeDbclick:!0,rawButton:!1,infoButton:!1,windowButton:!1,theme:_win.highlight_zt})})}(function(){var e=throttle(function(){var s=document.documentElement.scrollTop+document.body.scrollTop,o=jQuery(".ontop");s>100?_win.bd.addClass("body-scroll"):_win.bd.removeClass("body-scroll"),s>400?o.addClass("show"):o.removeClass("show")},100);_win.window.scroll(e);var a=debounce(function(){jQuery("[data-toggle='tooltip']").tooltip("hide")},500,!0);_win.window.scroll(a);var t=debounce(function(){_win.bd.addClass("scroll-ing")},500,!0),r=debounce(function(){_win.bd.removeClass("scroll-ing")},500);jQuery(".scrolling-hide").length&&_win.window.scroll(t).scroll(r);var n=0,i=debounce(function(){var s=document.documentElement.scrollTop+document.body.scrollTop;n>100&&s>n?_win.auto_scroll||_win.bd.removeClass("scroll-up").addClass("scroll-down"):(!_win.auto_scroll||n<=100)&&_win.bd.removeClass("scroll-down").addClass("scroll-up"),n=s},10,!0);jQuery(".scroll-down-hide").length&&_win.window.scroll(i)})();function scrollTopTo(e,a){var t=0,r=jQuery("body,html"),n=n||300;if(a=a||0,e){var i=e instanceof jQuery?e:jQuery(e);t=i.length?i.offset().top+a-(r.hasClass("nav-fixed")?jQuery(".header").innerHeight()+20:0):0}Math.abs(t-r.scrollTop())<80||(_win.auto_scroll=!0,r.animate({scrollTop:t},n,"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 a=jQuery(this);if(!a.hasClass("nowave")&&!a.hasClass("is-disabled")){a.css({overflow:"hidden",position:"relative"});var t,r=~~a.outerWidth(),n=~~a.outerHeight();r<n?t=n:t=r;var i=a.css("color")||"rgba(200, 200, 200)",s=jQuery("<div></div>").css({display:"block",background:i,"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"});a.append(s),s.css({width:t*2+"px",height:t*2+"px",top:e.pageY-a.offset().top-t+"px",left:e.pageX-a.offset().left-t+"px",transform:"scale(1)","-webkit-transform":"scale(1)",opacity:0}),setTimeout(function(){s.remove()},2e3)}}),jQuery.fn.sidebarAffix=function(){var e=jQuery(this),a=e.find("[data-affix]"),t="sidebar-affix";if(!a.length||e.children("."+t).length)return e;var r=jQuery("body"),n=a.innerWidth(),i=jQuery(".header");function s(){return r.hasClass("nav-fixed")&&(!i.hasClass("scroll-down-hide")||!r.hasClass("scroll-down"))?i.outerHeight(!0):20}var o=jQuery('<div class="'+t+' affix-top" style="width:'+n+'px;"></div>');e.prepend(o);function d(){o.css({top:s()})}var u=0;return o.affix({offset:{top:function(){var c=e.outerHeight(!0)+e.offset().top-s();return c!==u&&o.hasClass("affix")&&d(),u=c,c},bottom:function(){var c=e.parent();return document.body.clientHeight-c.outerHeight()-c.offset().top}}}).on("affix-top.bs.affix",function(){o.html("")}).on("affix.bs.affix",function(){o.find("[data-affix]").length||o.append(e.find("[data-affix]").clone()),d()}).find("[lazyload-action]:not(.lazyload)").addClass("lazyload"),o.hasClass("affix")&&o.trigger("affix.bs.affix"),o.hasClass("affix-bottom")&&o.trigger("affix-bottom.bs.affix"),e},jQuery.fn.autoAffix=function(e,a){e=~~e,a=~~a;var t=jQuery(this);if(t.data("bs.affix"))return t;var r=jQuery("body"),n=~~t.attr("offset-top"),i=~~t.attr("offset-bottom"),s=t.attr("data-wrap"),o=s?jQuery(s):t.parent(),d=jQuery(".header");function u(){return(r.hasClass("nav-fixed")&&(!d.hasClass("scroll-down-hide")||!r.hasClass("scroll-down"))?d.outerHeight():0)+e}function c(){t.next(".affix-clone").remove()}function l(){t.css({top:u()})}function h(){t.next(".affix-clone").length||t.after(t.clone().removeClass("affix-top affix affix-bottom").addClass("affix-clone").css("opacity","0"))}o.css("min-height",t.outerHeight()+a);var f=0;return t.affix({offset:{top:function(){var p=t.parent().offset().top-u()+n;return p!==f&&t.hasClass("affix")&&l(),f=p,p},bottom:function(){return document.body.clientHeight-o.outerHeight()-o.offset().top+a+i}}}).on("affix-top.bs.affix",function(){t.css({top:"",width:""}),c()}).on("affix.bs.affix",function(){h(),l()}).on("affix-bottom.bs.affix",function(){h()}),t.hasClass("affix")&&t.trigger("affix.bs.affix"),t.hasClass("affix-bottom")&&t.trigger("affix-bottom.bs.affix"),t.hasClass("affix-top")&&t.trigger("affix-top.bs.affix"),t},_win.bd.on("click",".toggle-theme",function(e){var a=jQuery("body").hasClass("dark-theme");if(!document.startViewTransition){o();return}const t=document.startViewTransition(()=>{o()}),{clientX:r,clientY:n}=e,i=Math.hypot(Math.max(r,innerWidth-r),Math.max(n,innerHeight-n)),s=[`circle(0px at ${r}px ${n}px)`,`circle(${i}px at ${r}px ${n}px)`];t.ready.then(()=>{document.documentElement.animate({clipPath:a?[...s].reverse():s},{duration:500,easing:a?"ease-out":"ease-in",fill:"both",pseudoElement:a?"::view-transition-old(root)":"::view-transition-new(root)"})});function o(){var d="enlighter-t-"+_win.highlight_white_zt,u="enlighter-t-"+_win.highlight_dark_zt;jQuery("img[switch-src]").each(function(){var f=jQuery(this),p=f.attr("data-src")||f.attr("src"),g=f.attr("switch-src");f.attr("src",g).attr("switch-src",p).attr("data-src","")}),jQuery("img[white-src],img[dark-src]").each(function(){var f=jQuery(this),p=a?f.attr("white-src"):f.attr("dark-src");p&&f.attr("src",p)});var c=jQuery(".enlighter-default"),l=jQuery("body"),h=jQuery("#post_content_ifr").contents().find("body");a?(jQuery('meta[name="theme-color"]').attr("content","#FDFCFE"),document.documentElement.classList.remove("dark"),h.removeClass("dark-theme"),c.removeClass(u).addClass(d),l.removeClass("dark-theme"),jQuery.cookie("theme_mode","white-theme",{path:"/"})):(jQuery('meta[name="theme-color"]').attr("content","#2F3135"),document.documentElement.classList.add("dark"),h.addClass("dark-theme"),c.removeClass(d).addClass(u),l.addClass("dark-theme"),jQuery.cookie("theme_mode","dark-theme",{path:"/"}))}}),_win.bd.on("click","[data-action]",function(){var e=jQuery(this),a=e.attr("data-pid"),t=e.attr("data-action"),r=t,n="aksrt"+r,i={type:r,key:t,pid:a};if(!_win.is_signin){var s=lcs.get(n)||"";if(s.indexOf(","+a+",")!==-1)return notyf(aksrt__(r=="like"?"like_already_post":"like_already_comment"),"warning");s?s.length>=160?(s=s.substring(0,s.length-1),s=s.substr(1).split(","),s.splice(0,1),s.push(a),s=s.join(","),lcs.set(n,","+s+",")):lcs.set(n,s+a+","):lcs.set(n,","+a+",")}action_ajax(e,i,a,r,aksrt__("like_thanks"))});function action_ajax(e,a,t,r,n){if(e.attr("disabled"))return!1;a._wpnonce=_win.post_action_nonce;var i=n||aksrt__("done");jQuery.ajax({type:"POST",url:_win.uri+"/action/action.php",dataType:"json",data:a,beforeSend:function(){e.attr("disabled",!0).find("count").html('<i class="loading zts"></i>')},success:function(s){var o=s.error?"danger":"";s.action&&s.action=="remove"&&(e.removeClass("actived action-animation"),o="warning"),s.action&&s.action=="add"&&e.addClass("actived action-animation"),notyf(s.msg||i,o),e.attr("disabled",!1).find("count").html(s.cuont||"0"),r=="follow_user"&&jQuery('[data-action="follow_user"][data-pid="'+t+'"]').each(function(){jQuery(this).find("count").html(s.cuont)})}})}_win.bd.on("click","[ajax-action]",function(){var e=jQuery(this);if(e.attr("disabled"))return!1;var a=e.attr("data-id"),t=e.attr("ajax-action"),r=e.find("text");r=r.length?r:e.siblings("text");var n=r.html();e.attr("disabled",!0),r.html('<i class="loading-spot"><i></i></i>'),jQuery.ajax({type:"POST",url:_win.ajax_url,dataType:"json",data:{id:a,action:t,_wpnonce:e.attr("data-nonce")},error:function(i){var s=aksrt_sprintf("ajax_error",i.status,i.statusText);aksrt_is_fatal_error_response(i.responseText)&&(s=aksrt__("ajax_fatal_error")),notyf(s,"danger"),e.attr("disabled",!1),r.html(n)},success:function(i){if(e.attr("disabled",!1),!i.data||!i.success)r.html(n),i.data&&i.data.msg&¬yf(i.data.msg,i.data.ys||"danger");else{if(i=i.data,i.show_modal&&i.modal){var s={class:"modal-mini full-sm",height:330,mobile_from_bottom:!0,touch_close:!0,content:i.modal};i.modal_config&&(s=jQuery.extend(s,i.modal_config)),s.content=i.modal,refresh_modal(s),r.html(n);return}jQuery('[ajax-action="'+t+'"][data-id="'+a+'"]').each(function(){var o=jQuery(this),d=o.find("text");d=d.length?d:o.siblings("text"),d.html(i.text||n).addClass("ajaxed"),i.active?o.addClass("active").siblings(".active").removeClass("active"):o.removeClass("active")})}}})});function throttle(e,a){let t=!0;return function(...r){if(!t)return!1;t=!1,setTimeout(function(){e.apply(this,r),t=!0},a)}}function debounce(e,a,t){var r;return function(){var n=this,i=arguments,s=function(){r=null,t||e.apply(n,i)},o=t&&!r;clearTimeout(r),r=setTimeout(s,a),o&&e.apply(n,i)}}if(_win.bd.on("input focus","textarea[autoHeight]",function(){var e=this,a=~~getComputedStyle(e).getPropertyValue("border-top-width").replace("px","")+~~getComputedStyle(e).getPropertyValue("border-bottom-width").replace("px",""),t=~~jQuery(e).attr("maxHeight");e.style.height="auto",t>e.scrollHeight?(e.style.height=e.scrollHeight+a+"px",e.style.overflow="hidden"):(e.style.height=t+"px",e.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 e=jQuery(this);e.text().search(reg)!=-1&&e.html(e.html().replace(reg,function(a){return'<b class="focus-color">'+a+"</b>"}))})}catch(e){}}_win.bd.on("click",".pag-jump .jump-icon",function(){var e=jQuery(this).siblings(".jump-input");pag_jump_go(e)}),_win.bd.on("input",".pag-jump .jump-input",debounce(function(){pag_jump(jQuery(this))},200)),_win.bd.on("keydown",".pag-jump .jump-input",function(e){e.keyCode==13&&pag_jump_go(jQuery(this))});function pag_jump(e){var a=e.attr("max"),t=e.attr("current"),r=~~e.val();return(!r||r<1||r>a)&&(r=r>a?a:"",e.val(r)),r==t?0:r}function pag_jump_go(e){var a=pag_jump(e);if(a){var t=e.attr("base"),r=t.replace("%#%",a),n=e.parent();if(n.hasClass("ajax-next")){e.val("");var i=n.clone().removeClass("pag-jump").addClass("hide").attr("href",r);n.append(i),i.click(),i.remove()}else location.href=r,location.reload}else e.focus()}jQuery.fn.cloneable=function(){var e="cloneable",a="."+e+"-add",t="."+e+"-remove",r="."+e+"-item";function n(i,s,o){var d=i.children(r).length;s&&s<=d?i.nextAll(a).hide():i.nextAll(a).show(),o&&o>=d?i.find(t).hide():i.find(t).show()}return this.each(function(){var i=jQuery(this),s=i.children(r),o="is-on",d="click",u=i.data("max")||0,c=i.data("min")||0;if(n(i,u,c),!(!s.length||i.attr(o))){var l=jQuery(s[0]).clone(!1);l.find("input,textarea").val(""),i.attr(o,!0).on(d,t,function(){jQuery(jQuery(this).parents(r)[0]).remove(),n(i,u,c)}).nextAll(a).on(d,function(){var h=l.clone(!1),f=i.children(r).length;h.find("[name]").each(function(){var p=jQuery(this),g=p.attr("name");g=="_pseudo"||!g.includes("[0]")||p.attr("name",p.attr("name").replace("[0]","["+f+"]"))}),i.append(h),n(i,u,c)})}})},jQuery.fn.dependency=function(){function e(r){return Number(r)}function a(r){switch(r){case!0:case"true":case 1:case"1":return!0;case null:case!1:case"false":case 0:case"0":return!1;default:return r}}function t(r,n,i){switch(r){case"==":return a(n)==a(i);case"!=":return a(n)!=a(i);case">=":return e(i)>=e(n);case"<=":return e(i)<=e(n);case">":return e(i)>e(n);case"<":return e(i)<e(n);case"any":if(jQuery.isArray(i)){for(let s=i.length-1;s>=0;s--)if(jQuery.inArray(i[s],n.split(","))!==-1)return!0}else if(jQuery.inArray(i,n.split(","))!==-1)return!0;return!1;case"not-any":if(jQuery.isArray(i)){for(let s=i.length-1;s>=0;s--)if(jQuery.inArray(i[s],n.split(","))==-1)return!0}else if(jQuery.inArray(i,n.split(","))==-1)return!0;return!1;default:return!1}}return this.each(function(){var r=jQuery(this),n=r.find("[data-controller]");if(n.length){var i="is-on";n.each(function(){var s=jQuery(this);if(!s.attr(i)){var o=s.attr(i,!0).data("controller").split("|"),d=s.data("condition").split("|"),u=s.data("value").toString().split("|");jQuery.each(o,function(c,l){var h=u[c]||"",f=d[c]||d[0]||"==";r.on("change","[name='"+l+"']",function(){var p=jQuery(this),g=p.attr("type"),v=g=="checkbox"?p.is(":checked"):p.val(),b=t(f,h,v);s.trigger("controller.change",b),b?s.show():s.hide()})})}})}})},_win.bd.on("click","[data-for]",function(){var e=jQuery(this),a=e.html(),t=e.attr("data-for"),r=e.parents("form"),n=e.attr("data-value"),i=~~e.attr("data-multiple"),s=e.closest("[for-group]"),o=e.prop("outerHTML");if(s.length||(s=e.parent()),i>1){a="",o="";var d=[],u="",c=e.hasClass("active");if(c)s.find('[data-for="'+t+'"][data-value="'+n+'"]').removeClass("active");else{var l={};if(s.find('[data-for="'+t+'"].active').each(function(){l[jQuery(this).attr("data-value")]=1}),Object.keys(l).length>=i)return notyf(aksrt_sprintf("select_max",i),"danger");s.find('[data-for="'+t+'"][data-value="'+n+'"]').addClass("active")}s.find('[data-for="'+t+'"].active').each(function(){var h=jQuery(this).attr("data-value");d.indexOf(h)==-1&&(a+=jQuery(this).html(),u+='<input type="hidden" name="'+t+'[]" value="'+h+'">',d.push(h),o+=jQuery(this).clone().addClass("outerhtml-copy").prop("outerHTML"))}),jQuery.each(d,function(h,f){s.find('[data-for="'+t+'"][data-value="'+f+'"]').addClass("active")}),r.find("input[name='"+t+"[]']").remove(),r.append(u)}else s.find('[data-for="'+t+'"]').removeClass("active"),s.find('[data-for="'+t+'"][data-value="'+n+'"]').addClass("active"),r.find("input[name='"+t+"']").val(n).trigger("change");r.find("span[name='"+t+"']").html(a),r.find("input[name=s]").focus(),r.find(".active-outerhtml[name='"+t+"']").html(o)}),_win.bd.on("input","input[limit-min],input[limit-max]",debounce(function(){var e=jQuery(this),a=Number(e.attr("limit-min")),t=Number(e.attr("limit-max")),r=Number(e.val()),n,i="limit-warning";e.next("."+i).length||e.after('<div class="limit-warning" style="display: none;"></div>');var s=e.next("."+i);e.val().length<1?s.html("").hide():r>t?(n=e.attr("warning-max")||aksrt__("input_max"),s.html(n.replace("1$",t)).fadeIn(150)):r<a?(n=e.attr("warning-min")||aksrt__("input_min"),s.html(n.replace("1$",a)).fadeIn(150)):s.fadeOut(150)},500)),jQuery.fn.AutoSearch=function(){return this.each(function(){var e=jQuery(this),a=e.attr("ajax-url")||_win.ajax_url,t=2,r="search-",n="."+r,i=r+"loading",s=n+"input",o=r+"centent",d=e.find(n+"container"),u=e.find(n+"remind"),c=e.find(n+"icon"),l=c.html(),h=aksrt_sprintf("search_min_chars",t),f='<i class="loading em12"></i>',p=f+'<span class="ml6">'+aksrt__("search_loading")+"</span>",g="is-on";if(e.data(g))return;function v(){var _={},Q=e.serializeObject();jQuery.each(Q,function(j,C){_[j]=C}),e.find("input[name]").each(function(){var j=jQuery(this),C=j.val()||"";_[j.attr("name")]=C}),e.addClass(i),u.html(p),c.html(f),d.css({height:d.outerHeight(),overflow:"hidden"}),jQuery.post(a,_,function(j){var C=j.data;C&&d.html('<div class="'+o+'">'+C+"</div>").animate({height:d.children("."+o).outerHeight()},200,"swing",function(){d.css({height:"",overflow:"",transition:""})}),e.removeClass(i),u.html(j.remind||""),c.html(l),auto_fun()},"json")}function b(_){_.val().length>=t?v():u.html(h)}e.data(g,!0).find(s).on("input",debounce(function(){b(jQuery(this))},500)).on("keydown",function(_){_.keyCode==13&&(_.preventDefault(),b(jQuery(this)))})})},_win.bd.on("click",".main-search [data-for]",function(){var e=jQuery(".main-search").find(".scale-placeholder");e.length&&e.text(e.attr("default"))}),_win.bd.on("submit",".main-search form",function(){var e=jQuery(this),a=e.serializeObject();jQuery.each(a,function(t,r){(!r||r=="null")&&t!="s"&&e.find('input[name="'+t+'"]').remove()})}),_win.bd.on("click",".main-search-btn",function(){var e=jQuery(this);jQuery(".main-search").addClass("show");var a=jQuery(".main-search [remote-box]").first();if(a.length){a.one("aksrt:remote-loaded",function(){e.trigger("click")}),a.trigger("click");return}var t=jQuery(".main-search form");if(t.length){var r="search-",n={type:e.attr(r+"type"),user:e.attr(r+"user"),trem:e.attr(r+"trem")};jQuery.each(n,function(s,o){if(o){var d=t.find('input[name="'+s+'"]').val(o),u=t.find('[data-for="'+s+'"][data-value="'+o+'"]').click();if(!u.length&&s=="trem"){var c=e.attr("trem-name"),l=t.find(".cat-drop");c&&l.length&&(l.append('<li data-for="trem" data-value="'+o+'"><a href="javascript:;">'+c+"</a></li>"),l.find('[data-value="'+o+'"]').click())}d.length||t.append('<input type="hidden" name="'+s+'" value="'+o+'">')}});var i=e.attr(r+"placeholder")||t.find(".scale-placeholder").attr("default");t.find(".scale-placeholder").text(i),setTimeout(function(){t.find('[name="s"]').focus()},100)}}),jQuery(".search-page-ajaxpager").length&&(_win.bd.on("click",".page-search-box a.search_keywords",function(){var e=jQuery(this).clone();return e.addClass("ajax-next").attr("ajax-replace","true").attr("route","true"),jQuery(".search-page-ajaxpager").append(e),e.click().remove(),!1}),_win.bd.on("submit",".page-search-box .search-form",function(){var e=jQuery(this),a=e.serializeObject(),t=new URL(e.attr("action"));t.search=new URLSearchParams(a).toString();var r=jQuery('<a class="ajax-next" ajax-replace="1" route="1" href="'+t.href+'"></a>');return jQuery(".search-page-ajaxpager").append(r),r.click().remove(),!1}));function nav_folding(){var e=".navbar-nav",a="sub-menu",t=jQuery(".navbar-collapse"),r=t.width();t.find(">:not("+e+")").each(function(){r-=jQuery(this).outerWidth()}),r-=jQuery(".navbar-header").outerWidth()+40;var n=66,i=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="'+a+'"></ul></li>');jQuery(e+">li").each(function(){n+=jQuery(this).outerWidth(),n>r&&i.find(">."+a).append(jQuery(this))}),i.find(">."+a+" li").length&&jQuery(e).append(i)}window.debounce_notyf=debounce(notyf,100,!0);function notyf(e,a,t,r){jQuery(".notyn").length||_win.bd.append('<div class="notyn"></div>'),a=a||"success",a=="error"&&(a="danger"),t=t||5e3,t=t<100?t*1e3:t;var n=r?' id="'+r+'"':"",i=jQuery('<div class="noty1"'+n+'><div class="notyf '+a+'">'+e+"</div></div>"),s=!r;r&&jQuery("#"+r).length?(jQuery("#"+r).find(".notyf").removeClass().addClass("notyf "+a).html(e),i=jQuery("#"+r),s=!0):jQuery(".notyn").append(i),s&&setTimeout(function(){notyf_close(i)},t)}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 e=jQuery(this);_win.passw==1?(e.find(".fa").addClass("fa-eye-slash"),e.siblings("input").attr("type","text"),_win.passw=2):(e.find(".fa").removeClass("fa-eye-slash"),e.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(e){var a=e.val(),t=e.siblings(".scale-placeholder");a.length>0?t.addClass("is-focus"):t.removeClass("is-focus")}function aksrt_is_url(e){try{return new URL(e),!0}catch{return!1}}function is_mail(e){return/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/.test(e)}jQuery.fn.serializeObject=function(){var e={},a=this.serializeArray();return jQuery.each(a,function(){e[this.name]!==void 0?(e[this.name].push||(e[this.name]=[e[this.name]]),e[this.name].push(this.value||"")):e[this.name]=this.value||""}),e},_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(e){e.details_link&&jQuery(".initiate-checkin").each(function(){var a=jQuery(e.details_link),t=jQuery(this),r=t.attr("class"),n=t.attr("ed-text");a.addClass(r).removeClass("initiate-checkin").html(n),t.prop("outerHTML",a.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 e=jQuery(this),a=e.attr("ajax-submit")||'.wp-ajax-submit,[zibajax="submit"]';return e.find(a).click(),!1}),_win.bd.on("click",'.wp-ajax-submit,[zibajax="submit"]',function(){var e=jQuery(this),a=e.attr("data-confirm");return a&&!confirm(a)||aksrt_ajax(jQuery(this)),!1});function aksrt_ajax(e,a,t,r,n){if(e.attr("disabled"))return!1;if(!a){var i=e.attr("form-data");if(i)try{a=jQuery.parseJSON(i)}catch{}if(!a){var s=e.parents("form");a=s.serializeObject()}}var o=e.attr("form-action");o&&(a.action=o);var d=e.html(),u=n?d:'<i class="loading mr6"></i><text>'+aksrt__("please_wait")+"</text>";r!="stop"&¬yf(r||aksrt__("processing"),"load","","wp_ajax"),e.attr("disabled",!0).html(u);var c=e.attr("ajax-href")||_win.ajax_url;jQuery.ajax({type:"POST",url:c,data:a,dataType:"json",error:function(l){var h=aksrt_sprintf("ajax_error",l.status,l.statusText);aksrt_is_fatal_error_response(l.responseText)&&(h=aksrt__("ajax_fatal_error")),console.error("ajax请求错误,错误信息如下:",l),notyf(h,"danger","",r!="stop"?"wp_ajax":""),e.attr("disabled",!1).html(d)},success:function(l){var h=l.ys?l.ys:l.error?"danger":"";r!="stop"?notyf(l.msg||aksrt__("done"),h,"","wp_ajax"):l.msg&¬yf(l.msg,h),e.attr("disabled",!1).html(d).trigger("aksrt_ajax.success",l),jQuery.isFunction(t)&&t(l,e,a),l.hide_modal&&e.closest(".modal").modal("hide"),l.reload&&(l.goto?(window.location.href=l.goto,window.location.reload):window.location.reload())}})}_win.bd.on("aksrt_ajax.success","[next-tab]",function(e,a){var t=jQuery(this).attr("next-tab");t&&a&&!a.error&&jQuery('a[href="#'+t+'"]').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 e=jQuery(".limit-height");if(e.data("posts-limit-ison"))return;var a=e.height(),t=e.attr("data-maxheight");if(~~a>=~~t+79){var r='<div class="read-more"><a href="javascript:;" class="read-more-open">'+aksrt__("read_more")+'<i class="fa ml10 fa-angle-down"></i></a></div>';e.append(r).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 a=jQuery(e.target),t=a.attr("lazyload-action");setTimeout(function(){if(t==="ias")if(a.attr("remote-box"))a.click();else{var n=a.is(".ajax-next,.ias-btn")?a:a.find(".ajax-next,.ias-btn");n.attr("no-scroll",!0).click()}if(t=="animated"){var i=a.attr("data-animated");i&&a.addClass("animated "+i).css("visibility","unset")}},200);var r=a.attr("data-bg");r&&a.css("background-image","url("+r+")")});function fps_yh(){var e=0,a=0,t=0,r=0,n,i=0;function s(){n=performance.now(),a++,n-e>=300&&(t=Math.round(a*1e3/(n-e)),a=0,e=n,t>5&&e>1600&&(r=r||t,r=(r+t)/2,r<20&&i++,i>5&&jQuery("body").addClass("fps-accelerat"))),i<=5&&e<15e3?requestAnimationFrame(s):o()}function o(){jQuery.cookie("fps_accelerat",~~r,{path:"/",expires:604800})}requestAnimationFrame(s)}!jQuery.cookie("fps_accelerat")&&!jQuery("body").hasClass("fps-accelerat")&&fps_yh();function partners_scroll_init(){function e(t){if(!(!t||t.dataset.zpsReady==="1")){var r=parseFloat(t.style.getPropertyValue("--zps-speed"))||3,n=t.querySelectorAll("[data-zps-row]");n.forEach(function(i){var s=i.querySelector("[data-zps-track]");if(s){var o=s.querySelector(".zps-group");if(o){var d=function(){var h=s.querySelectorAll(".zps-group.zps-clone");h.forEach(function(j){j.remove()});var f=o.scrollWidth;if(!(f<10)){var p=i.clientWidth||t.clientWidth||window.innerWidth,g=Math.max(f*2,p+f),v=Math.ceil(g/f);v<2&&(v=2);for(var b=1;b<v;b++){var _=o.cloneNode(!0);_.classList.add("zps-clone"),_.setAttribute("aria-hidden","true"),s.appendChild(_)}s.style.setProperty("--zps-shift","-"+f+"px");var Q=f/100*r;Q<4&&(Q=4),s.style.setProperty("--zps-duration",Q.toFixed(2)+"s"),s.setAttribute("data-zps-ready","1")}};d();var u=o.querySelectorAll("img"),c=0;u.forEach(function(h){if(!(h.complete&&h.naturalWidth>0)){c++;var f=function(){c--,c<=0&&d()};h.addEventListener("load",f,{once:!0}),h.addEventListener("error",f,{once:!0})}});var l;window.addEventListener("resize",function(){clearTimeout(l),l=setTimeout(d,200)})}}}),t.dataset.zpsReady="1"}}function a(){document.querySelectorAll(".aksrt-partners-scroll").forEach(e)}a()}function translate_init(){var e=_win.translate_config;e.s&&tbquire(["translate"],function(){translate.selectLanguageTag.show=!1,translate.language.setLocal(e.local||"chinese_simplified"),e.service_url&&translate.request.setHost(e.service_url),e.ignore_text&&(translate.ignore.text=e.ignore_text),e.nomenclature&&e.nomenclature.length>0&&jQuery.each(e.nomenclature,function(n,i){var s=i.from,o=i.to,d=i.value;s=="auto"&&(s=""),d&&o&&translate.nomenclature.append(s,o,d)}),e.auto_discriminate_local&&translate.setAutoDiscriminateLocalLanguage(),e.range&&e.range.length>0&&(translate.language.translateLanguagesRange=e.range),e.loading&&translate.progress.api.startUITip();var a=jQuery(".language-dropdown .dropdown-menu"),t=debounce(function(){jQuery("[data-language]").removeClass("active"),a.loading("show")},400,!0);translate.lifecycle.changeLanguage.trigger.push(t);var r=debounce(function(n){a.loading("hide"),jQuery("[data-language='"+n.to+"']").addClass("active")},400);translate.lifecycle.execute.finally.push(r),_wid>996&&jQuery(".navbar-top .nav>li>a>.menu-item-title").each(function(){var n=jQuery(this);n.css({"max-width":~~n.outerWidth(!0)+5+"px"})}),translate.ignore.class.push("translate-ignore"),translate.ignore.tag.push("svg"),translate.service.use(e.service_use||"client.edge"),translate.listener.start(),translate.execute()})}_win.bd.on("click",".translate-button",function(){var e=jQuery(this),a=e.attr("data-language");translate&&translate.changeLanguage(a)}),(function(){var e="obs-animate",a="."+e,t="in-view",r="__zaniObserved",n="obs-animate-repeat",i=!("IntersectionObserver"in window)||window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(i){l(a);return}var s="100px 0px 0px 0px",o=0;function d(p){o=0;for(var g=0,v=0;v<p.length;v++)p[v].isIntersecting&&g++;for(var b=0;b<p.length;b++){var _=p[b],Q=_.target,j=jQuery(Q);j.css("transition-delay","");var C=Q.hasAttribute("data-animation-repeat")||Q.classList.contains(n);if(_.isIntersecting){var T=o*.11;g>8&&(T=T/(g/8)),j.css("transition-delay",T+"s"),j.addClass(t),o++,C||c(Q)}else C&&j.removeClass(t)}}var u=new IntersectionObserver(d,{root:null,rootMargin:s,threshold:.01});function c(p){!p||p.nodeType!==1||!p[r]||(p[r]=!1,u.unobserve(p),setTimeout(function(){l(p)},50))}function l(p){var g=jQuery(p).attr("data-animation"),v="ani-"+g;jQuery(p).removeClass(t+" "+e+" "+v+" "+n).removeAttr("data-animation").removeAttr("data-animation-repeat").css("transition-delay","")}function h(p){!p||p.nodeType!==1||p[r]||(p[r]=!0,u.observe(p))}function f(){jQuery(a).each(function(){h(this)})}f()})();function number_stats_init(){function e(r,n){var i=parseFloat(r.getAttribute("data-target"))||0;if(i===0){r.textContent="0";return}var s=r.getAttribute("data-target")||"0",o=(s.split(".")[1]||"").length,d=~~r.getAttribute("data-duration");n=d>10?d:n;var u=0,c=null;n=n||1500;function l(h){c||(c=h);var f=Math.min((h-c)/n,1),p=1-Math.pow(1-f,1.5),g=u+(i-u)*p;r.textContent=o>0?g.toFixed(o):Math.floor(g).toString(),f<1?requestAnimationFrame(l):r.textContent=o>0?i.toFixed(o):i.toString()}requestAnimationFrame(l)}var a=document.querySelectorAll(".stat-number-wrap");if(a.length){if(!("IntersectionObserver"in window)){a.forEach(function(r){r.querySelectorAll(".stat-number").forEach(function(n){n.textContent=n.getAttribute("data-target")||""})});return}var t=new IntersectionObserver(function(r){r.forEach(function(n){if(n.isIntersecting){var i=n.target;i.dataset.counted!=="1"&&(i.dataset.counted="1",i.querySelectorAll(".stat-number").forEach(function(s){e(s,1500)}),t.unobserve(i))}})},{threshold:.3});a.forEach(function(r){t.observe(r)})}}_win.bd.on("click",".produck-wid-feature-intro .fi-tab",function(){var e=jQuery(this);if(!e.hasClass("is-active")){e.addClass("is-active"),e.siblings().removeClass("is-active");var a=e.closest(".produck-wid-feature-intro").find(".fi-panel");a.removeClass("is-active"),a.eq(e.index()).addClass("is-active")}});function tilt_cases_init(){function e(){var r="ontouchstart"in window||navigator.maxTouchPoints&&navigator.maxTouchPoints>0,n=window.matchMedia&&window.matchMedia("(max-width: 768px)").matches;return r||n}if(e())return;var a=jQuery(".vanilla-tilt:not(.is-initialized)");if(!a.length)return;function t(r,n){var i=r[0].style.transform;i.includes("translate3d")&&(i=i.replace(/translate3d\(.*?\)/g,"").trim()),i=i+" "+n,r.css("transform",i)}tbquire(["tilt"],function(){a.each(function(){var r=jQuery(this),n=r.find("img"),i=parseFloat(r.attr("data-tilt-max"))||10,s=n.length,o=1.22,d=r.closest(".tilt-cases-container")||r,u=r.data("tilt-mouse-event-element");if(u){r.removeAttr("data-tilt-mouse-event-element");var c=r.closest(u);d=c.length?c:d}var l={};d.length&&(l["mouse-event-element"]=d[0]),r.addClass("is-initialized"),VanillaTilt.init(this,l),!(s<=1)&&(this.addEventListener("tiltChange",function(h){var f=h.detail||{},p=parseFloat(f.tiltX)||0,g=parseFloat(f.tiltY)||0;n.each(function(v){var b=jQuery(this),_=parseFloat(b.attr("data-tilt-depth"));if(isNaN(_)&&(_=20),_===0){t(b,"translate3d(0,0,0)");return}var Q=1;s>1&&(Q=.48+v/(s-1)*1.14);var j=_*o*Q,C=p/i*j*-1,T=g/i*j;t(b,"translate3d("+C+"px, "+T+"px, 0)")})}),d&&d.on("mouseleave",function(){n.each(function(){t(jQuery(this),"translate3d(0,0,0)")})}))})})}_win.bd.on("click",".customize-preview-widget-edit",function(e){if(!(!wp||!wp.customize||!wp.customize.widgetsPreview)){var a=jQuery(this),t=a.closest(".customize-preview-widget-box");e.preventDefault(),wp.customize.widgetsPreview.preview.send("focus-widget-control",t.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 e=0,a=0;jQuery(".feature").each(function(){var r=jQuery(this);(e=r.find(".feature-icon").innerHeight()+r.find(".feature-title").innerHeight()+r.find(".feature-note").innerHeight())>a&&(a=e)}),jQuery(".feature").css("height",a)}jQuery(".qrcode").length&&tbquire(["qrcode"],function(){jQuery(".qrcode").each(function(){var r=jQuery(this),n=r.attr("data-qrcode"),i=r.attr("data-size")||160;r.qrcode({width:i,height:i,correctLevel:0,text:n||document.URL,background:"#fff",foreground:"#333"})})}),jQuery(document).on("lazyloaded",function(r){var n=jQuery(r.target);swiper_tab_AutoHeight(n)}),jQuery(document).on("lazyloaded",".gradient-bg img",function(r){var n=jQuery(r.target),i=n.closest(".gradient-bg"),s=i.attr("data-opacity"),o=s?"a":"",d=s?","+s:"";tbquire(["grade"],function(){Grade(i[0],null,function(u){u=u[0];var c=u.gradientData,l="rgb"+o+"("+c[0].rgba.slice(0,3).join(",")+d+") 10%",h="rgb"+o+"("+c[1].rgba.slice(0,3).join(",")+d+") 80%";jQuery(u.element).addClass("gradient-bg-loaded").css("background-image","linear-gradient(135deg, "+l+", "+h+")")})})}),_win.qj_loading&&jQuery(".qj_loading").fadeOut(500).delay(1e3,function(){jQuery(this).remove(),jQuery("#qj_dh_css").remove()});function t(r){var n=_win.uri+"/yiyan/qv-yiyan.php",i;jQuery.ajax({type:"POST",url:n}).done(function(s){var o=s.replace(/\r\n|\r/g,"/&/").trim().split("/&/");if(o){var d=r.attr("type");d?i=d==="en"?o[0]:o[1]:i='<div class="cn">'+o[0]+'</div><div class="en">'+o[1]+"</div>",r.html(i)}})}jQuery(".yiyan").each(function(){t(jQuery(this))}),setInterval(function(){jQuery(".yiyan").each(function(){t(jQuery(this))})},3e4),jQuery(".yiyan").on("click",function(){t(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 r=jQuery(this),n=r.attr("touch-direction");r.minitouch({direction:n,onEnd:function(i){r.attr("mini-touch")==="mobile-nav"?jQuery("body").removeClass("mobile-navbar-show"):i.removeClass("show")}})})});
|
||
;
|
||
|
||
/* source: assets/js/captcha-front.js */
|
||
/**
|
||
* AKSRT Captcha front-end runtime — cloud providers only.
|
||
*
|
||
* Mounts are registered internally by uid and resolved by scene plus DOM scope.
|
||
* The only public surface is window.AKSRTCaptcha.
|
||
*/
|
||
(function () {
|
||
'use strict';
|
||
|
||
var TOKEN_FIELDS = Object.freeze([
|
||
'captcha_verified',
|
||
'aksrt_captcha_challenge',
|
||
'aksrt_captcha_proof',
|
||
'cf_turnstile_response',
|
||
'tencent_ticket', 'tencent_randstr',
|
||
'geetest_lot_number', 'geetest_captcha_output', 'geetest_pass_token', 'geetest_gen_time',
|
||
'aliyun_captcha_verify_param'
|
||
]);
|
||
var loaders = {};
|
||
var instances = {};
|
||
var scenes = {};
|
||
|
||
function asElement(scope) {
|
||
if (!scope) return null;
|
||
if (scope.nodeType === 1 || scope.nodeType === 9) return scope;
|
||
if (typeof scope !== 'string') return null;
|
||
if (instances[scope]) return instances[scope].box;
|
||
try { return document.querySelector(scope); } catch (_) { return null; }
|
||
}
|
||
|
||
function scopeBoundary(box, config) {
|
||
if (config.scope) {
|
||
try {
|
||
var configured = document.querySelector(config.scope);
|
||
if (configured) return configured;
|
||
} catch (_) {}
|
||
}
|
||
return box.closest('[data-aksrt-captcha-scope], form, [data-aksrt-download-box], [data-aksrt-auth], .aksrt-modal, [data-signin-captcha], #comments') || box.parentElement;
|
||
}
|
||
|
||
function register(instance) {
|
||
instances[instance.uid] = instance;
|
||
scenes[instance.scene] = scenes[instance.scene] || [];
|
||
if (scenes[instance.scene].indexOf(instance) === -1) scenes[instance.scene].push(instance);
|
||
}
|
||
|
||
function resolve(scene, scope) {
|
||
scan();
|
||
if (typeof scope === 'string' && instances[scope] && instances[scope].scene === scene) {
|
||
return instances[scope];
|
||
}
|
||
var candidates = scenes[scene] || [];
|
||
var element = asElement(scope);
|
||
if (element && element.getAttribute) {
|
||
var uid = element.getAttribute('data-aksrt-captcha-uid') || element.getAttribute('data-captcha-uid');
|
||
if (uid && instances[uid] && instances[uid].scene === scene) return instances[uid];
|
||
}
|
||
if (!element) return scope ? null : (candidates.length === 1 ? candidates[0] : null);
|
||
var matches = candidates.filter(function (instance) {
|
||
var boundary = instance.scope;
|
||
return element === instance.box || element === instance.mount || element === boundary ||
|
||
instance.box.contains(element) || instance.mount.contains(element) ||
|
||
(boundary && boundary.contains(element)) ||
|
||
(element.contains && (element.contains(instance.box) || (boundary && element.contains(boundary))));
|
||
});
|
||
if (matches.length === 1) return matches[0];
|
||
if (!matches.length) return null;
|
||
matches.sort(function (a, b) {
|
||
if (a.scope === b.scope) return 0;
|
||
if (a.scope && b.scope && a.scope.contains(b.scope)) return 1;
|
||
if (a.scope && b.scope && b.scope.contains(a.scope)) return -1;
|
||
return 0;
|
||
});
|
||
return matches[0];
|
||
}
|
||
|
||
function verify(scene, scope) {
|
||
var instance = resolve(scene, scope);
|
||
if (!instance) return Promise.resolve(true);
|
||
return instance.verify();
|
||
}
|
||
|
||
function collect(scene, scope) {
|
||
var instance = resolve(scene, scope);
|
||
return instance ? instance.collect() : {};
|
||
}
|
||
|
||
function reset(scene, scope) {
|
||
var instance = resolve(scene, scope);
|
||
if (instance) instance.reset();
|
||
}
|
||
|
||
function releaseRunLock(instance) {
|
||
instance.runLocked = false;
|
||
var waiters = instance.lockWaiters.slice();
|
||
instance.lockWaiters = [];
|
||
waiters.forEach(function (resolveWaiter) { resolveWaiter(null); });
|
||
}
|
||
|
||
function run(scene, scope) {
|
||
var instance = resolve(scene, scope);
|
||
if (!instance) return Promise.resolve({});
|
||
if (instance.runLocked) {
|
||
return new Promise(function (resolveWaiter) { instance.lockWaiters.push(resolveWaiter); });
|
||
}
|
||
instance.runLocked = true;
|
||
return instance.verify().then(function (passed) {
|
||
if (!passed) releaseRunLock(instance);
|
||
return passed ? instance.collect() : null;
|
||
}).catch(function (error) {
|
||
releaseRunLock(instance);
|
||
throw error;
|
||
});
|
||
}
|
||
|
||
window.AKSRTCaptcha = Object.freeze({
|
||
verify: verify,
|
||
collect: collect,
|
||
reset: reset,
|
||
run: run,
|
||
TOKEN_FIELDS: TOKEN_FIELDS
|
||
});
|
||
|
||
function scan() {
|
||
var mounts = document.querySelectorAll('[data-aksrt-captcha-config]');
|
||
Array.prototype.forEach.call(mounts, function (mount) {
|
||
if (mount.dataset.aksrtCaptchaBound) return;
|
||
var config;
|
||
try {
|
||
config = JSON.parse(mount.getAttribute('data-aksrt-captcha-config'));
|
||
} catch (_) {
|
||
return;
|
||
}
|
||
if (!config || !config.scene || !config.uid || !config.vid) return;
|
||
mount.dataset.aksrtCaptchaBound = '1';
|
||
initMount(config, mount);
|
||
});
|
||
}
|
||
|
||
function initMount(C, mount) {
|
||
var box = document.getElementById(C.uid);
|
||
var hField = document.getElementById(C.vid);
|
||
if (!box || !hField) return;
|
||
|
||
var container = box.closest('form') || mount;
|
||
mount.setAttribute('data-aksrt-captcha-uid', C.uid);
|
||
var verified = false;
|
||
var pending = [];
|
||
var refreshingChallenge = null;
|
||
var providerReset = function () {};
|
||
var triggerCaptcha = function () {
|
||
showTip('验证码加载中,请稍候', '#e67e22');
|
||
finishPending(false);
|
||
};
|
||
|
||
function loadScriptOnce(key, src, readyCheck) {
|
||
if (typeof readyCheck === 'function' && readyCheck()) return Promise.resolve();
|
||
if (loaders[key]) return loaders[key];
|
||
loaders[key] = new Promise(function (resolveLoad, rejectLoad) {
|
||
var existing = document.querySelector('script[data-aksrt-sdk="' + key + '"]');
|
||
if (existing) {
|
||
if (typeof readyCheck === 'function' && readyCheck()) { resolveLoad(); return; }
|
||
existing.addEventListener('load', resolveLoad, { once: true });
|
||
existing.addEventListener('error', function () { rejectLoad(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 = resolveLoad;
|
||
script.onerror = function () { rejectLoad(new Error(key + ' load failed')); };
|
||
document.head.appendChild(script);
|
||
});
|
||
return loaders[key];
|
||
}
|
||
|
||
function setField(name, value) {
|
||
var field = container.querySelector('input[name="' + name + '"]');
|
||
if (!field) {
|
||
field = document.createElement('input');
|
||
field.type = 'hidden';
|
||
field.name = name;
|
||
container.appendChild(field);
|
||
}
|
||
field.value = value == null ? '' : value;
|
||
}
|
||
|
||
function collectFields() {
|
||
var payload = {};
|
||
TOKEN_FIELDS.forEach(function (name) {
|
||
var field = container.querySelector('input[name="' + name + '"]');
|
||
if (field && field.value !== '') payload[name] = field.value;
|
||
});
|
||
return payload;
|
||
}
|
||
|
||
function refreshChallenge() {
|
||
if (!C.challenge_url || typeof window.fetch !== 'function') return Promise.resolve();
|
||
if (refreshingChallenge) return refreshingChallenge;
|
||
refreshingChallenge = window.fetch(C.challenge_url, {
|
||
method: 'POST',
|
||
credentials: 'same-origin',
|
||
headers: { 'Content-Type': 'application/json' },
|
||
body: JSON.stringify({ scene: C.scene })
|
||
}).then(function (response) {
|
||
return response.json().catch(function () { return {}; }).then(function (body) {
|
||
if (!response.ok || !body || body.success === false) throw new Error(body.message || 'challenge refresh failed');
|
||
var data = body.data || body;
|
||
if (!data.challenge) throw new Error('challenge missing');
|
||
setField('aksrt_captcha_challenge', data.challenge);
|
||
});
|
||
}).catch(function () {
|
||
showTip('无法刷新人机验证会话,请刷新页面重试', '#e74c3c');
|
||
}).finally(function () {
|
||
refreshingChallenge = null;
|
||
});
|
||
return refreshingChallenge;
|
||
}
|
||
|
||
function clearProviderTokens() {
|
||
TOKEN_FIELDS.forEach(function (name) {
|
||
if (name === 'captcha_verified' || name === 'aksrt_captcha_challenge' || name === 'aksrt_captcha_proof') return;
|
||
Array.prototype.forEach.call(container.querySelectorAll('input[name="' + name + '"]'), function (field) {
|
||
field.remove();
|
||
});
|
||
});
|
||
}
|
||
|
||
function resetVerificationState() {
|
||
verified = false;
|
||
releaseRunLock(instance);
|
||
hField.value = '0';
|
||
setField('aksrt_captcha_proof', '');
|
||
clearProviderTokens();
|
||
try { providerReset(); } catch (_) {}
|
||
refreshChallenge();
|
||
}
|
||
|
||
function finishPending(ok) {
|
||
var callbacks = pending.slice();
|
||
pending = [];
|
||
callbacks.forEach(function (callback) { callback(!!ok); });
|
||
}
|
||
|
||
function cancelPending(message) {
|
||
if (message) showTip(message, '#e67e22');
|
||
finishPending(false);
|
||
}
|
||
|
||
function providerPayload() {
|
||
var payload = collectFields();
|
||
payload.scene = C.scene;
|
||
return payload;
|
||
}
|
||
|
||
function exchangeVerification() {
|
||
if (!C.exchange_url || typeof window.fetch !== 'function') {
|
||
cancelPending('人机验证服务不可用,请刷新页面重试');
|
||
return;
|
||
}
|
||
window.fetch(C.exchange_url, {
|
||
method: 'POST',
|
||
credentials: 'same-origin',
|
||
headers: { 'Content-Type': 'application/json' },
|
||
body: JSON.stringify(providerPayload())
|
||
}).then(function (response) {
|
||
return response.json().catch(function () { return {}; }).then(function (body) {
|
||
if (!response.ok || !body || body.success === false) throw new Error(body.message || '人机验证失败');
|
||
var data = body.data || body;
|
||
if (!data.proof) throw new Error('人机验证凭证缺失');
|
||
setField('aksrt_captcha_proof', data.proof);
|
||
clearProviderTokens();
|
||
completeVerification();
|
||
});
|
||
}).catch(function (error) {
|
||
cancelPending(error.message || '人机验证失败,请重试');
|
||
resetVerificationState();
|
||
});
|
||
}
|
||
|
||
function completeProviderVerification() {
|
||
hField.value = '1';
|
||
exchangeVerification();
|
||
}
|
||
|
||
function completeVerification() {
|
||
verified = true;
|
||
hField.value = '1';
|
||
finishPending(true);
|
||
}
|
||
|
||
function showTip(message, color) {
|
||
var tip = box.querySelector('.captcha-tip');
|
||
if (!tip) {
|
||
tip = document.createElement('div');
|
||
tip.className = 'captcha-tip';
|
||
tip.style.cssText = 'font-size:12px;margin-top:4px;text-align:left;';
|
||
box.appendChild(tip);
|
||
}
|
||
tip.style.color = color || '#e74c3c';
|
||
tip.textContent = message;
|
||
setTimeout(function () { if (tip.parentNode) tip.remove(); }, 4000);
|
||
}
|
||
|
||
function showLoading() {
|
||
box.innerHTML = '<div style="text-align:center;padding:20px;color:#9ca3af;">验证码加载中...</div>';
|
||
}
|
||
|
||
function clearLoading() {
|
||
box.innerHTML = '';
|
||
}
|
||
|
||
var instance = {
|
||
uid: C.uid,
|
||
scene: C.scene,
|
||
box: box,
|
||
mount: mount,
|
||
scope: scopeBoundary(box, C),
|
||
runLocked: false,
|
||
lockWaiters: [],
|
||
collect: collectFields,
|
||
reset: resetVerificationState,
|
||
verify: function () {
|
||
var challengeField = container.querySelector('input[name="aksrt_captcha_challenge"]');
|
||
var preparation = challengeField && challengeField.value ? Promise.resolve() : refreshChallenge();
|
||
return preparation.then(function () {
|
||
challengeField = container.querySelector('input[name="aksrt_captcha_challenge"]');
|
||
if (!challengeField || !challengeField.value) {
|
||
showTip('人机验证会话未就绪,请稍后重试', '#e74c3c');
|
||
return false;
|
||
}
|
||
if (verified || hField.value === '1') return true;
|
||
return new Promise(function (resolveVerify) {
|
||
pending.push(resolveVerify);
|
||
if (pending.length === 1) triggerCaptcha();
|
||
});
|
||
});
|
||
}
|
||
};
|
||
register(instance);
|
||
refreshingChallenge = refreshChallenge();
|
||
|
||
function loadTencent() {
|
||
showLoading();
|
||
loadScriptOnce('tencent', 'https://turing.captcha.qcloud.com/TJCaptcha.js', function () {
|
||
return typeof window.TencentCaptcha !== 'undefined';
|
||
}).then(function () {
|
||
clearLoading();
|
||
var captchaInstance = null;
|
||
triggerCaptcha = function () {
|
||
if (!captchaInstance) {
|
||
captchaInstance = new window.TencentCaptcha(C.tc.app_id, function (result) {
|
||
if (result.ret === 2) { cancelPending('已取消验证'); return; }
|
||
if (result.ret === 0 && result.ticket) {
|
||
if (result.ticket.indexOf('trerror_') === 0) {
|
||
cancelPending('验证码服务异常,请刷新页面重试');
|
||
return;
|
||
}
|
||
setField('tencent_ticket', result.ticket);
|
||
setField('tencent_randstr', result.randstr);
|
||
completeProviderVerification();
|
||
return;
|
||
}
|
||
var errorMap = { 1001: '验证码组件加载失败', 1002: '验证码超时', 1006: '验证码配置拉取失败', 1008: '验证码页面加载异常', 1012: '验证码刷新次数过多', 1013: '验证码网络异常' };
|
||
cancelPending(errorMap[result.errorCode] || '验证码异常,请重试');
|
||
}, { userLanguage: 'zh-cn' });
|
||
}
|
||
captchaInstance.show();
|
||
};
|
||
}).catch(function () {
|
||
clearLoading();
|
||
cancelPending('验证码组件加载失败,请刷新重试');
|
||
});
|
||
}
|
||
|
||
function loadCloudflare() {
|
||
var widgetId = null;
|
||
var verifying = false;
|
||
var modal = null;
|
||
|
||
function closeModal() {
|
||
if (widgetId !== null && typeof window.turnstile !== 'undefined') {
|
||
try { window.turnstile.remove(widgetId); } catch (_) {}
|
||
}
|
||
widgetId = null;
|
||
if (modal && modal.parentNode) modal.parentNode.removeChild(modal);
|
||
modal = null;
|
||
}
|
||
|
||
function renderWidget() {
|
||
if (typeof window.turnstile === 'undefined') { setTimeout(renderWidget, 200); return; }
|
||
widgetId = window.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 (!verifying) return;
|
||
verifying = false;
|
||
setField('cf_turnstile_response', token);
|
||
closeModal();
|
||
completeProviderVerification();
|
||
},
|
||
'error-callback': function () {
|
||
verifying = false;
|
||
closeModal();
|
||
cancelPending('验证码失败,请重试');
|
||
},
|
||
'expired-callback': function () {
|
||
verifying = false;
|
||
closeModal();
|
||
cancelPending('验证码已过期,请重新验证');
|
||
}
|
||
});
|
||
}
|
||
|
||
function createModal() {
|
||
modal = document.createElement('div');
|
||
modal.className = 'aksrt-captcha-modal-overlay';
|
||
modal.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(modal);
|
||
var cancel = function () {
|
||
verifying = false;
|
||
closeModal();
|
||
cancelPending('已取消验证');
|
||
};
|
||
modal.querySelector('.aksrt-captcha-modal-backdrop').addEventListener('click', cancel);
|
||
modal.querySelector('.aksrt-captcha-modal-close').addEventListener('click', cancel);
|
||
renderWidget();
|
||
}
|
||
|
||
window['onTurnstileLoad_' + C.uid] = function () {};
|
||
if (typeof window.turnstile === 'undefined') {
|
||
loadScriptOnce('cloudflare', 'https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onTurnstileLoad_' + C.uid + '&render=explicit', function () {
|
||
return typeof window.turnstile !== 'undefined';
|
||
}).catch(function () { cancelPending('验证码组件加载失败,请刷新重试'); });
|
||
}
|
||
triggerCaptcha = function () {
|
||
if (verifying) return;
|
||
verifying = true;
|
||
createModal();
|
||
};
|
||
providerReset = closeModal;
|
||
}
|
||
|
||
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();
|
||
cancelPending('极验 Captcha ID 未配置');
|
||
return;
|
||
}
|
||
|
||
function render() {
|
||
clearLoading();
|
||
window.initGeetest4({ captchaId: captchaId, product: product, hideSuccess: true }, function (captchaInstance) {
|
||
function onSuccess() {
|
||
var result = captchaInstance.getValidate();
|
||
if (!result) { cancelPending('验证码失败,请重试'); 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);
|
||
completeProviderVerification();
|
||
}
|
||
captchaInstance.onReady(function () {}).onSuccess(onSuccess).onClose(function () { cancelPending('已取消验证'); });
|
||
if (product !== 'bind' && product !== 'popup') captchaInstance.appendTo('#' + C.uid);
|
||
triggerCaptcha = function () {
|
||
if (product === 'bind' || product === 'popup') captchaInstance.showCaptcha();
|
||
else showTip('请先完成人机验证', '#e67e22');
|
||
};
|
||
providerReset = function () {
|
||
if (typeof captchaInstance.reset === 'function') captchaInstance.reset();
|
||
};
|
||
});
|
||
}
|
||
|
||
if (typeof window.initGeetest4 === 'undefined') {
|
||
loadScriptOnce('geetest', 'https://static.geetest.com/v4/gt4.js', function () {
|
||
return typeof window.initGeetest4 !== 'undefined';
|
||
}).then(render).catch(function () {
|
||
clearLoading();
|
||
cancelPending('极验组件加载失败');
|
||
});
|
||
} else {
|
||
render();
|
||
}
|
||
}
|
||
|
||
function loadAliyun() {
|
||
showLoading();
|
||
window.AliyunCaptchaConfig = { region: C.al.region || 'cn', prefix: C.al.prefix };
|
||
|
||
function render() {
|
||
clearLoading();
|
||
var captchaInstance = null;
|
||
window.initAliyunCaptcha({
|
||
SceneId: C.al.scene_id,
|
||
mode: 'popup',
|
||
element: '#' + C.uid,
|
||
success: function (verifyParam) {
|
||
setField('aliyun_captcha_verify_param', verifyParam);
|
||
completeProviderVerification();
|
||
},
|
||
fail: function () { cancelPending('验证码失败,请重试'); },
|
||
getInstance: function (value) { captchaInstance = value; },
|
||
slideStyle: { width: 360, height: 40 },
|
||
language: 'cn'
|
||
});
|
||
triggerCaptcha = function () {
|
||
if (captchaInstance && captchaInstance.show) captchaInstance.show();
|
||
else cancelPending('验证码组件加载中,请稍候再试');
|
||
};
|
||
providerReset = function () {
|
||
if (captchaInstance && typeof captchaInstance.reset === 'function') captchaInstance.reset();
|
||
};
|
||
}
|
||
|
||
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();
|
||
cancelPending('验证码组件加载失败,请刷新重试');
|
||
});
|
||
} else {
|
||
render();
|
||
}
|
||
}
|
||
|
||
switch (C.provider) {
|
||
case 'tencent': loadTencent(); break;
|
||
case 'cloudflare': loadCloudflare(); break;
|
||
case 'geetest': loadGeetest(); break;
|
||
case 'aliyun': loadAliyun(); break;
|
||
}
|
||
}
|
||
|
||
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', scan);
|
||
else setTimeout(scan, 0);
|
||
|
||
if (window.MutationObserver) {
|
||
new MutationObserver(function (mutations) {
|
||
var shouldScan = mutations.some(function (mutation) { return mutation.addedNodes && mutation.addedNodes.length; });
|
||
if (shouldScan) scan();
|
||
}).observe(document.documentElement, { childList: true, subtree: true });
|
||
}
|
||
})();
|
||
;
|
||
|
||
/* 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;
|
||
});
|
||
})();
|
||
;
|