-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dashboard.js
1 lines (1 loc) · 4.83 KB
/
Dashboard.js
1
!function(){var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},t={},n={},a=e.parcelRequire9ec1;null==a&&((a=function(e){if(e in t)return t[e].exports;if(e in n){var a=n[e];delete n[e];var r={id:e,exports:{}};return t[e]=r,a.call(r.exports,r,r.exports),r.exports}var o=Error("Cannot find module '"+e+"'");throw o.code="MODULE_NOT_FOUND",o}).register=function(e,t){n[e]=t},e.parcelRequire9ec1=a),(0,a.register)("lKEtu",function(e,t){function n(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Object.defineProperty(e.exports,"_",{get:function(){return n},set:void 0,enumerable:!0,configurable:!0})});var r=a("lKEtu");function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},a=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),a.forEach(function(t){(0,r._)(e,t,n[t])})}return e}var i=function(){var e;function t(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,t),this.selectors={panel:"[data-dashboard-panel]",tabs:"[data-dashboard-tabs]",tabLink:"[data-dashboard-tab]"}}return e=[{key:"init",value:function(){var e=this;this.url=document.location.pathname+document.location.search,this.$panels=$(this.selectors.panel),this.$tabs=$(this.selectors.tabs),this.$panels.each(function(t,n){e.setupPanel($(n))}),this.$tabs.each(function(t,n){e.setupTabs($(n))}),this.setupReloadEvents(),this.setupAutoReload(),this.triggerDashboardReadyEvent()}},{key:"getPanelByKey",value:function(e){return this.$panels.filter("[data-key='".concat(e,"']")).first()}},{key:"triggerDashboardReadyEvent",value:function(){$(document).trigger("dashboard:ready")}},{key:"triggerPanelReadyEvent",value:function(e){return this.triggerPanelEvent(e,"panel")}},{key:"triggerPanelEvent",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=parseInt(e.data("key"),10),r=e.data("panel"),i=o({$element:e,key:a,panel:r},n),l=$.Event("dashboard:".concat(t)),s=$.Event("dashboard:".concat(t,"(").concat(r,")"));return $(document).trigger(l,[i]),$(document).trigger(s,[i]),!(l.isDefaultPrevented()||s.isDefaultPrevented())}},{key:"setupTabs",value:function(e){var t=e.find(this.selectors.tabLink),n=function(e,t){var n=$(e).attr("href");$(e).attr("aria-current",t?"true":"false"),$(n).attr("aria-hidden",t?"false":"true")},a=function(e){t.each(function(e,t){return n(t,!1)}),n(e,!0)};a(t.eq(0)),t.on("click",function(e){e.preventDefault(),a(e.target)}),e.attr("data-cloak",null)}},{key:"setupPanel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t&&function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document;"undefined"!=typeof UIkit?function(e){$(".tooltip, .pw-tooltip",e).each(function(){$(this).removeClass("tooltip pw-tooltip"),UIkit.tooltip($(this))})}(e):function(e){$("a.tooltip, .pw-tooltip",e).tooltip({position:{my:"center bottom",at:"center top"}}).hover(function(){var e=$(this);e.is("a")?e.addClass("ui-state-hover"):(e.data("pw-tooltip-cursor",e.css("cursor")),e.css("cursor","pointer")),e.addClass("pw-tooltip-hover"),e.css("cursor","pointer")},function(){var e=$(this);e.removeClass("pw-tooltip-hover ui-state-hover"),e.is("a")||e.css("cursor",e.data("pw-tooltip-cursor"))})}(e)}(e),this.triggerPanelReadyEvent(e)}},{key:"setupReloadEvents",value:function(){var e=this;$(document).on("reload",this.selectors.panel,function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=n.animate,r=n.params;e.reloadPanel($(t.target),{animate:a,params:r})})}},{key:"setupAutoReload",value:function(){this.$panels.each(function(e,t){var n=$(t),a=parseInt(n.data("key"),10),r=parseInt(n.data("interval"),10);a>=0&&r>0&&setInterval(function(){n.trigger("reload")},r=Math.max(2e3,r))})}},{key:"reloadPanel",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=n.animate,r=void 0!==a&&a,i=n.params;if(e.length){var l=o({dashboard:1,key:parseInt(e.data("key"),10),panel:e.data("panel")},(void 0===i?null:i)||{});$.post(this.url,l,null,"text").done(function(n){var a=$(n);if(t.triggerPanelEvent(e,"reload",{$new:a})){var o=function(){e.html(a.html()),e.prop("className",a.prop("className")),a.filter("script").each(function(e,t){$.globalEval(t.text||t.textContent||t.innerHTML||"")}),t.setupPanel(e,!0)};r?e.children().fadeOut(400,function(){o(),e.children().fadeIn(400)}):o()}}).fail(function(){console.error("Error fetching panel contents")})}}}],function(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}(t.prototype,e),t}();$(function(){new i().init()})}();