text: var localContext={PRINT_DIALOG_TIMEOUT:3e3,CONTROL_FRAME:"controlFrame",CONTENT_FRAME:"contentFrame",TEXT_FRAME:"textFrame",CLICKABLE_FRAME:"clickableFrame",CONTAINER_ID_STUB:"Container",DASHBOARD_VIEWER_PARAM:"&dashboardViewer=true",CONTROL_PREFIX:"input_",HIDDEN_PARAM_PREFIX:"hidden_",CONTENT_FRAME_PREFIX:"contentFrame_",timers:[],buttonIdToAction:{},VIEW_DOM_ID:"dashboardViewer",NOTHING_SUBSTITUTE:"~NOTHING~",CONTENT_FRAME_PATTERN:"div.componentContainer.iframe",CONTROL_BUTTON_PATTERN:"div.componentContainer.control.actionButton>button.action",FLOATING_BUTTON_PATTERN:"div.floatingMenu button.button",controlsController:null,CUSTOM_RESOURCE_TYPE:"customResourceType",CUSTOM_URL_IFRAME_TIMEOUT:1e4,customUrlLoadingTimeouts:{},getMode:function(){return designerBase.DASHBOARD_RUNTIME},_isHoverSupported:function(e){try{return!window.frameElement||jQuery(window.frameElement).hasClass("outerDashboardFrame")}catch(t){return!0}},initDashboardViewEvents:function(){$(this.VIEW_DOM_ID).observe("mouseover",function(e){var t=null,a=e.element();isIPad()||(t=matchAny(a,[this.CONTENT_FRAME_PATTERN],!0),t&&this._isHoverSupported()&&t.addClassName("over"))}.bind(this)),$(this.VIEW_DOM_ID).observe("mouseout",function(e){var t=null,a=e.element();t=matchAny(a,[this.CONTENT_FRAME_PATTERN],!0),t&&this._isHoverSupported()&&t.removeClassName("over")}.bind(this)),$(this.VIEW_DOM_ID).observe("click",function(e){var t=null,a=null,n=null,r=e.element();if(t=matchAny(r,[this.CONTROL_BUTTON_PATTERN],!0)){a=/[A-Za-z]+$/;var i=t.identify();n=a.exec(i)[0],n&&this.buttonIdToAction[n]()}if(t=matchAny(r,[this.FLOATING_BUTTON_PATTERN],!0)){a=/[A-Za-z]+_\d+$/;var o=t.identify();if(n=a.exec(o)[0])if(o.startsWith("refresh_")){var s=$("containerOverlay_"+n);if(s){s.getAttribute("data-isCustom");this.refreshIFrame(n)}}else o.startsWith("open_")&&this._getDrillThroughSource(n)}}.bind(this))},initButtonIdToActionFunctions:function(){this.buttonIdToAction={submit:_.bind(this.submitInputControlParams,this),reset:_.bind(this.resetInputControlParams,this),print:_.bind(this.printDashboard,this)}},_initAllFrameSources:function(e){if(e){this._hasSubmitButton()?!0:!1;this._updateIFrameSRCParams(!paramsChanged,!0)}else contentFrames.each(function(e){var t=$(this.CONTENT_FRAME_PREFIX+e.frameName);this.loadIframe(t,e.src,e.resourceType===this.CUSTOM_RESOURCE_TYPE)}.bind(this))},loadDashboard:function(){this.controlsController=new JRS.Controls.DashboardRuntimeController({reportUri:"/dashboard/viewer/"+clientKey,viewModel:new JRS.Controls.DashboardRuntimeViewModel}),this._isPrintableWindow()&&(this._hideControlButtons(),this._updateIFrameSRCParams(!0,!0)),controlFrames.length>0?(this.controlsController.fetchControlsStructure(this.getInitialControlValues(!0)).always(_.bind(this._initAllFrameSources,this,!0)),JRS.Controls.listen({"viewmodel:values:changed":_.bind(function(){!this._hasSubmitButton()&&this.submitInputControlParams()},this)})):this._initAllFrameSources(!0),this.initDashboardViewEvents(),this.initButtonIdToActionFunctions()},getInitialControlValues:function(e){var t={};return _.each(controlFrames,_.bind(function(e){t[e.paramName]=e.paramValue},this)),e?_.extend(t,this.getHiddenParamValuesForControls()):t},getHiddenParamValuesForControls:function(){var e={};return hiddenParams.length>0&&_.each(controlFrames,_.bind(function(t){var a=this.getHiddenParamValue(t.paramName);a&&(e[t.paramName]=a)},this)),e},getHiddenParamValue:function(e){var t=[];return _.each(hiddenParams,function(a){a.paramName===e&&t.push(a.paramValue)}),t.length>0?t:null},setRefreshTimer:function(e,t){var a=this._convertFromMinToMilliSecs(t);this.timers[e]=setInterval("localContext.refreshIFrame('"+e+"')",a)},refreshIFrame:function(e){var t=$(this.CONTENT_FRAME_PREFIX+e);if(t)try{this._showFrameLoadingImage(t);var a=_.find(contentFrames,function(t){return t.frameName===e});this.loadIframe(t,t.src,a.resourceType===this.CUSTOM_RESOURCE_TYPE)}catch(n){}},_convertFromMinToMilliSecs:function(e){return 6e4*parseInt(e)},_getDrillThroughSource:function(e){var t=this._getIFrameByName(e);if(t){var a=t.src;a=a.replace("&viewAsDashboardFrame=true",""),a=a.replace(localContext.DASHBOARD_VIEWER_PARAM,""),launchNewWindow(a)}},_getIFrameByName:function(e){var t=this.CONTENT_FRAME+"_"+e;return $(t)},_getControlFrameObjectByName:function(e){var t=null;return controlFrames.each(function(a){if(a.frameName===e)throw t=a,$break}),t},_getControlFrameObjectByParamName:function(e){var t=null;return controlFrames.each(function(a){if(a.paramName===e)throw t=a,$break}),t},_getFrameContainerByName:function(e,t){var a=e+localContext.CONTAINER_ID_STUB+"_"+t;return $(a)},_getSelectedValuesForControlFrame:function(e){return this.controlsController.getViewModel().get("selection")[e.paramName]},_setSelectedValuesForControlFrame:function(e,t){var a=null,n=e.dataType,r=null,i=null,o=null,s=null,l=document.getElementsByName(this.CONTROL_PREFIX+e.paramName);if(l.length>0?i=l[0].type:(a=document.getElementById(this.CONTROL_PREFIX+e.paramName),i=a.type),1==l.length&&(a=l[0]),i)if("text"===i)if("Date"===n){var m=new Date;m.setTime(getDateFromFormat(t,staticDatePattern,!0)),a.value=formatDate(m,localDateFormat)}else if("Timestamp"===n){var m=new Date;m.setTime(getDateFromFormat(t,staticDatePattern,!0)),a.value=formatDate(m,localDateTimeFormat)}else a.value=t;else if("select-one"===i)for(s=a.options.length,r=0;s>r;r++)o=a.options[r],o.value===t&&(a.selectedIndex=r);else if("select-multiple"===i){s=a.options.length;var u=t.split("@@");for(r=0;s>r;r++)o=a.options[r],u.include(o.value)?o.selected=!0:o.selected=!1}else{if("checkbox"!==i&&"radio"!==i)throw"[_setSelectedValuesForControlFrame]: unknown control type!!";for(var c=t.split("@@"),d=0;d<l.length;d++){for(var h=!1,_=0;_<c.length;_++){var f=String(c[_]),T=String(l[d].value);if(f===T){h=!0;break}}h?l[d].checked="checked":l[d].checked=""}}},_formatParamValue:function(e,t){for(var a="",n=e+"=",r=0;r<t.length;r++)a+=n+encodeURIComponent(t[r]),r<t.length-1&&(a+="&");return a},_updateIFrameSRCParams:function(e,t){var a=null,n=null,r=null;contentFrames.each(function(i){var o=i.frameName,s="";if(e||controlFrames.each(function(e){if(a=i.params?i.params[e.paramName]:void 0){var t=this._getSelectedValuesForControlFrame(e);n=this._formatParamValue(a,t),r=getSymbolToAppendNextParam(i.src+s),s=s+r+n}}.bind(this)),hiddenParams.each(function(t){a=i.params&&"undefined"!=typeof i.params[t.paramName]?i.params[t.paramName]:t.paramName;var r=_.find(controlFrames,function(e){return e.paramName===t.paramName});!a||r&&!e||(n=this._formatParamValue(a,[t.paramValue]),s=s+getSymbolToAppendNextParam(i.src+s)+n)}.bind(this)),t||s){isIPad()||(document.getElementById("contentFrameContainer_"+o).style.backgroundImage="url(themes/default/images/wait_animation_large.gif)");var l=this._getIFrameByName(o);this._showFrameLoadingImage(l),l.className="hidden";var m=i.src.indexOf(localContext.DASHBOARD_VIEWER_PARAM)>-1?"":localContext.DASHBOARD_VIEWER_PARAM,u=i.src+s+(i.src.indexOf("http://")<0?m:"");this.loadIframe(l,u,i.resourceType===this.CUSTOM_RESOURCE_TYPE)}}.bind(this))},loadIframe:function(e,t,a){var n=jQuery(e);if(n.attr("src",t),a){var r=n.attr("id").split(this.CONTENT_FRAME+"_")[1],i=n.parent().parent();i.removeClass("hideLoadingAnimation"),i.find(".externalUrlEmbeddingError").remove(),this.customUrlLoadingTimeouts[r]&&clearTimeout(this.customUrlLoadingTimeouts[r]),this.customUrlLoadingTimeouts[r]=setTimeout(function(){var e=jQuery("<div></div>");e.html(DASHBOARD_CUSTOM_URL_ERROR.replace("\n","<br>")).addClass("externalUrlEmbeddingError"),i.addClass("hideLoadingAnimation").prepend(e)},this.CUSTOM_URL_IFRAME_TIMEOUT)}},_buildHiddenParamsURL:function(){var e="";return controlFrames.each(function(t){var a=this._getSelectedValuesForControlFrame(t);e=e+"&"+this._formatParamValue(this.HIDDEN_PARAM_PREFIX+t.paramName,a)}.bind(this)),hiddenParams.each(function(t){var a=_.find(controlFrames,function(e){return e.paramName===t.paramName});a||(e=e+"&"+this._formatParamValue(this.HIDDEN_PARAM_PREFIX+t.paramName,[t.paramValue]))}.bind(this)),e},submitInputControlParams:function(){this._updateIFrameSRCParams(!1)},resetInputControlParams:function(){var e=this.controlsController.updateControlsValues(this.getInitialControlValues(!1));e.done(function(){this._updateIFrameSRCParams(!1)}.bind(this))},printDashboard:function(){var e=new RegExp("(&)?"+this.HIDDEN_PARAM_PREFIX+"[^=]+=([^&]+)?","g"),t=document.location.toString().replace(e,"");window.open(t+"&JSprint=true&viewAsDashboardFrame=true"+this._buildHiddenParamsURL(),"PrintPreview")},_hideControlButtons:function(){var e=this._hasPrintButton(),t=this._hasResetButton(),a=this._hasSubmitButton();e&&e.addClassName("hidden"),t&&t.addClassName("hidden"),a&&a.addClassName("hidden")},_showPrintButton:function(){this._hasPrintButton()&&$("button_print").removeClassName("hidden")},_updateIFrameLoadingStatus:function(e){var t=null,a=$(e);if(a&&(t=this._getIFrameIDFromOverlay(a),$(t))){$(t).setAttribute("data-iframeLoaded","complete");var n=(Element.up($(e),"DIV"),document.getElementById(t));n&&n.getAttribute("src")&&(0===n.getAttribute("src").indexOf("http")||n.getAttribute("src").indexOf("_flowId=dashboardRuntimeFlow")>0)&&(document.getElementById(t).className=""),Element.show($(t)),this._updateScroll(),$(t).observe("touchstart",cancelEventAndPreventDefault).observe("touchmove",cancelEventAndPreventDefault).observe("touchend",cancelEventAndPreventDefault).observe("orientationchange",cancelEventAndPreventDefault)}},_updateScroll:function(){var e=$("dashboardFrameParent"),t=0,a=0;if(e){var n=$$(".control");if(n.length>0){var r=designerBase.getContentDimensions(n);r.width>0&&(t=r.width),r.height>0&&(a=r.height)}e.setStyle({width:t+"px",height:a+25+"px"})}},_showFrameLoadingImage:function(e,t){var a=$(e).up("DIV");$(a)&&($(a).setStyle({backgroundImage:""}),t?$(e).show():$(e).hide())},_getIFrameIDFromOverlay:function(e){return e?$(e).getAttribute("data-iFrameID"):null},_isPrintableWindow:function(){return document.location.href.indexOf("&JSprint=true")>-1},_isIFrameSrcUpdateable:function(e){return!e||e.indexOf("blank.htm")>-1},_hasSubmitButton:function(){return $("button_submit")},_hasPrintButton:function(){return $("button_print")},_hasResetButton:function(){return $("button_reset")}};