/*!***********************************************
 Copyright (c) 2019, Neusoft Inc.
 All rights reserved
 图表秀 Version 1.0.0 2019.9.3
 ************************************************/
"use strict";player.directive("playWidget",["$sce","$rootScope","$timeout",function(i,e,t){return{restrict:"AE",replace:!0,scope:{widget:"=",sectionStyle:"=",pageOptions:"=",useMobileLayout:"=",curTheme:"=",largeTextRatio:"=",mode:"@"},template:'<div class="free-layout-box"><div class="free-layout-box-content" ng-style="{color : curTheme.define.text}"><div class="h-full w-full" ng-switch="widget.type"><div class="h-full w-full" ng-switch-when="chart"><div class="h-full w-full" dataviz-chart chart-obj="widget.resource" theme-id="curTheme.id" widget="widget" mode="mode" large-text-ratio="largeTextRatio"></div></div><div class="h-full w-full" ng-switch-when="text" class="widget-box-text" ng-bind-html="trustAsHtml(widget.resource.content)" style="font-family: \'微软雅黑\', \'Microsoft Yahei\', sans-serif, Arial, Verdana, \'Trebuchet MS\';  font-size:{{16 * largeTextRatio + \'px\'}}"></div><img ng-switch-when="image" style="max-width: 100%;max-height: 100%" ng-src="{{widget.resource.imageStore}}" /><div class="h-full w-full" ng-switch-when="icon"><span style="color: {{widget.resource.setIconContent}} "><span ng-class="widget.resource.iconContent" style="font-size: {{widget.resource.iconFontSize + \'px\'}}"></span></span></div></div></div></div>',link:function(g,h,e){function t(e){if(!g.useMobileLayout&&void 0===g.widget.define.zIndex||g.useMobileLayout&&void 0===g.widget.defineMobile.zIndex)var t=24,i=(u=g.useMobileLayout?g.widget.defineMobile:g.widget.define).col,o=u.row,n=u.sizeX,r=u.sizeY,d=n/t*e-5*n/t-5,l=r/t*e-5*r/t-5,a=i/t*e+5,s=o/t*e+5,c=g.widgetIndex;else{var u;d=(u=g.useMobileLayout?g.widget.defineMobile:g.widget.define).width*e,l=u.height*e,a=u.left*e,s=u.top*e,c=-1==u.zIndex?g.widgetIndex:u.zIndex}!function(e,t,i,o){h[0].style.width=Math.round(e)+"px",h[0].style.height=Math.round(t)+"px",h[0].style.top=Math.round(i)+"px",h[0].style.left=Math.round(o)+"px"}(d,l,s,a),function(e){h[0].style.zIndex=e,g.widget.define.zIndex=e}(c),function(e){h[0].style.border=e}(function(){var e,t="0.5px solid ";g.pageOptions&&g.pageOptions.showBorder?e=t+"#000":g.widget.type?e=t+"transparent":g.widget.type||(e=t+"#ccc");return e}())}g.trustAsHtml=i.trustAsHtml,g.chartReadyToRender=!1,g.mode=e.mode,t(g.sectionStyle.width),"chart"===g.widget.type?(h.attr("id","chart"+g.widget.resource.id),h.attr("name",g.widget.resource.simpleJson.option.name),g.$on("chartReadyToRender",function(e){e.stopPropagation&&e.stopPropagation(),g.chartReadyToRender=!0,g.$emit("render-widget-done")}),g.$on("render-play-widget",function(e){g.chartReadyToRender&&g.$broadcast("drawChart",{isOpenAnimation:"exportChart"!==g.mode})})):("image"===g.widget.type&&(g.widget.resource.imageStore=g.widget.resource.imageStore.split("@")[0]),g.$emit("render-widget-done")),g.$on("init-widget-style",function(){t(g.sectionStyle.width)})}}}]),player.directive("playChart",["$rootScope",function(e){return{restrict:"AE",replace:!0,scope:{widget:"=",curTheme:"=",largeTextRatio:"=",mode:"@"},template:'<div class="pos rlt h-full w-full"><div class="h-full w-full" dataviz-chart chart-obj="widget.resource" theme-id="curTheme.id" mode="mode" large-text-ratio="largeTextRatio"></div></div>',link:function(e,t,i){e.mode=i.mode,e.$on("render-play-widget",function(){e.$broadcast("drawChart")}),e.$emit("render-widget-done")}}}]),player.directive("playerScroll",["$window","$timeout",function(e,n){return{restrict:"AE",link:function(o,e){if(o.isMobile)o.$on("render-widget-done",_.once(function(){betterScroll=new BScroll(e[0],{momentum:!1,scrollY:!0,startY:0,pullUpLoad:{threshold:30}}),betterScroll.on("touchEnd",function(){for(var e=document.querySelectorAll("section"),t=0,i=0;i<=o.pageIndex;i++)t+=o.sectionStyle[i].height;0<this.movingDirectionY?t-Math.abs(this.y)<screen.height&&o.pageIndex<o.pages.length-1&&e&&this.scrollToElement(e[++o.pageIndex]):this.movingDirectionY<0&&t-o.sectionStyle[o.pageIndex].height-Math.abs(this.y)<screen.height&&o.pageIndex&&e&&this.scrollToElement(e[--o.pageIndex])}),betterScroll.on("pullingUp",function(){o.pageIndex<o.pages.length-1&&o.$emit("set-page-info")}),o.$on("set-page-info-done",function(){betterScroll.finishPullUp(),n(function(){betterScroll.refresh()})})}));else{var t=function(){e.perfectScrollbar("update")};e.perfectScrollbar();var i=_.debounce(t,200);setTimeout(function(){t(),$(window).on("resize",i)}),o.$on("scroll-to-top",function(){e.scrollTop(0)}),o.$on("$destroy",function(){$(window).off("resize",i),e.perfectScrollbar("destroy")})}}}}]);