Seditio Source
Root |
./othercms/xenForo 2.2.8/js/xf/notice.min.js
'use strict';!function(f,k,l,m){XF.Notices=XF.Element.newHandler({options:{type:"block",target:".js-notice",scrollInterval:5},$notices:null,slider:null,dismissing:!1,init:function(){this.updateNoticeList();this.filter();this.handleNoticeListChange()&&(this.$target.on("click",".js-noticeDismiss",XF.proxy(this,"dismiss")),this.start())},updateNoticeList:function(){f(l).trigger("xf:notice-change");return this.$notices=this.$target.find(this.options.target).not(".clone")},handleNoticeListChange:function(){var a=
this.$notices.length;a?1==a&&this.$target.removeClass("notices--isMulti"):(this.slider&&(this.slider.destroy(),this.slider=null),this.$target.remove());return a},filter:function(){var a=this.getCookies(),b=!1;this.$notices.each(function(){var c=f(this),d=parseInt(c.data("notice-id"),10),e=c.data("visibility");a&&d&&-1!=f.inArray(d,a)&&(c.remove(),b=!0);e&&("hidden"==c.css("visibility")?(c.remove(),b=!0):c.addClass("is-vis-processed"))});b&&this.updateNoticeList()},start:function(){var a=this,b=this.$notices,
c=this.options.type;"floating"==c?b.each(function(){var d=f(this),e=d.data("display-duration"),g=d.data("delay-duration"),h=d.data("auto-dismiss");g?setTimeout(function(){a.displayFloating(d,XF.config.speed.normal,e,h)},g):a.displayFloating(d,XF.config.speed.fast,e,h)}):"scrolling"==c&&1<this.$notices.length&&(f.fn.lightSlider?(this.slider=this.$target.lightSlider({item:1,addClass:"noticeScrollContainer",slideMargin:0,galleryMargin:0,controls:!1,auto:!0,pause:1E3*this.options.scrollInterval,speed:400,
pauseOnHover:!0,loop:!0,rtl:XF.isRtl(),enableDrag:!1}),f(k).on("resize",XF.proxy(this,"refreshSlider"))):console.error("Lightslider must be loaded first."))},displayFloating:function(a,b,c,d){a.xfFadeDown(b,function(){c&&setTimeout(function(){a.xfFadeUp(XF.config.speed.normal);d&&a.find("a.js-noticeDismiss").trigger("click")},c)})},getCookies:function(){if(!XF.config.userId){var a=XF.Cookie.get("notice_dismiss");a=a?a.split(","):[];for(var b=[],c,d=0;d<a.length;d++)(c=parseInt(a[d],10))&&b.push(c);
return b}},dismiss:function(a){a.preventDefault();if(!this.dismissing){this.dismissing=!0;var b=f(a.target);a=b.parents(".js-notice");var c=parseInt(a.data("notice-id"),10),d=XF.config.userId,e=this.getCookies();d?XF.ajax("post",b.attr("href"),{},function(){},{skipDefault:!0}):c&&-1==f.inArray(c,e)&&(e.push(c),e.sort(function(g,h){return g-h}),b=new Date,b.setUTCMonth(b.getUTCMonth()+1),XF.Cookie.set("notice_dismiss",e.join(","),b));this.removeNotice(a);this.dismissing=!1}},removeNotice:function(a){var b=
this;if(this.slider){var c=this.$notices.length,d=this.slider.getCurrentSlideCount(),e=function(){a.remove();b.updateNoticeList();b.handleNoticeListChange()&&(b.refreshSlider(),b.slider.goToSlide(d))};1<c?(d>=b.slider.getTotalSlideCount()&&(d=1),this.slider.goToNextSlide(),setTimeout(e,500)):e()}else a.xfFadeUp(XF.config.speed.fast,function(){a.remove();b.updateNoticeList();b.handleNoticeListChange()})},refreshSlider:function(){this.$target.css("height","");this.slider.refresh()}});XF.Element.register("notices",
"XF.Notices")}(jQuery,window,document);