"use strict";!function(t){var e={mode:"manual",url:void 0,params:{},topic:void 0,section:void 0,skin:"text",caching:!0,select:void 0,hideEffect:"fadeOut",showEffect:"fadeIn",reloadAfter:0,delay:0,onload:function(){},finished:function(){},beforeload:function(){}};function o(o,n){var i=this;i.elem=t(o),i.opts=t.extend({},e,n),i.elem.is("pre")?i.setContent(""):i.container=i.elem.contents().wrapAll("<div class='jqLoaderContainer'></div>").parent(),i.init(),"auto"===i.opts.mode?i.loadAfter():i.opts.reloadAfter&&i.loadAfter(i.opts.reloadAfter)}o.prototype.setContent=function(e){var o=this;void 0!==o.container&&o.container.remove(),o.elem.empty(),o.container=t("<div class='jqLoaderContainer'></div>"),o.container.append(e),o.elem.is("pre")?o.container.insertAfter(o.elem):o.container.appendTo(o.elem)},o.prototype.init=function(){var e=this;e.elem.on("refresh.jqloader",(function(o,n){e.opts.params=t.extend({},e.opts.params,n),e.loadAfter(0),o.stopPropagation()})),"function"==typeof e.opts.onload&&e.elem.on("onload.jqloader",(function(t){e.opts.onload.call(e),t.stopPropagation()})),"function"==typeof e.opts.beforeload&&e.elem.on("beforeload.jqloader",(function(t){e.opts.beforeload.call(e),t.stopPropagation()})),"function"==typeof e.opts.finished&&e.elem.on("finished.jqloader",(function(t){e.opts.finished.call(e),t.stopPropagation()})),e.opts.reloadAfter&&e.elem.on("finished.jqloader",(function(t){e.loadAfter(e.opts.reloadAfter),t.stopPropagation()}))},o.prototype.loadAfter=function(t){var e=this;t=t||e.opts.delay,void 0!==e.timer&&(window.clearTimeout(e.timer),e.timer=void 0),t?e.timer=window.setTimeout((function(){e.load()}),t):e.load()},o.prototype.load=function(){var e=this,o=e.opts.web||foswiki.getPreference("WEB"),n=e.opts.topic||foswiki.getPreference("TOPIC"),i=t.extend({},e.opts.params),a=e.opts.url;void 0===a&&(a=foswiki.getScriptUrl("view",o,n)),void 0!==e.opts.section&&(i.section=e.opts.section),void 0!==e.opts.skin&&e.opts.skin&&(i.skin=e.opts.skin),e.opts.caching||(i.t=Date.now()),e.opts.hideEffect&&e.container.animateCSS({effect:e.opts.hideEffect}).one("stop.animate",(function(){e.container.hide()})),e.elem.trigger("beforeload.jqloader",e,i),t.get(a,i,"html").done((function(o){void 0!==e.opts.select&&(o=t(o).find(e.opts.select)),e.setContent(o),e.elem.trigger("onload.jqloader",e);var n=e.opts.effect||e.opts.showEffect;n&&"show"!==n&&"hide"!==n?e.container.animateCSS({effect:n}).on("stop.animate",(function(){e.elem.trigger("finished.jqloader",e)})):e.elem.trigger("finished.jqloader",e)}))},t.fn.jqLoader=function(e){return this.each((function(){t.data(this,"jqLoader")||t.data(this,"jqLoader",new o(this,e))}))},t(".jqLoader").livequery((function(){var e=t(this),o=t.extend({},e.data());e.jqLoader(o)})),t("head").append("<style>pre.jqLoader { display:none; }</style>")}(jQuery),function(t){var e={target:null,iconClass:"fa",spinClass:"fa-spin"};function o(o,n){var i=this;i.elem=t(o),i.opts=t.extend({},e,i.elem.data()),i.init()}o.prototype.init=function(){var e=this;e.icon=e.elem.find("."+e.opts.iconClass),"string"==typeof e.opts.target?e.target=t(e.opts.target):e.opts.target&&"object"==typeof e.opts.target?e.target=e.opts.target:e.target=e.elem.next(),e.target.on("beforeload.jqloader",(function(){e.icon.addClass(e.opts.spinClass)})).on("onload.jqloader",(function(){e.icon.removeClass(e.opts.spinClass)})),e.elem.on("click",(function(){return e.target.trigger("refresh"),!1}))},t.fn.jqLoaderButton=function(e){return this.each((function(){t.data(this,"jqLoaderButton")||t.data(this,"jqLoaderButton",new o(this,e))}))},t(".jqLoaderButton").livequery((function(){t(this).jqLoaderButton()}))}(jQuery);
