UNPKG

quoslibero

Version:

FusionCharts JavaScript charting framework

1 lines 10.9 kB
import{pluck}from'../../../lib';export default function(b){var a,c=window,d=c.navigator.userAgent,e=/msie/i.test(d)&&!c.opera,f=Math,g=f.min,i=f.round,h=c.parseFloat,j=String,k='rgba(192,192,192,'+(e?.002:1e-6)+')',l={enabled:!1,false:!1,0:!1,disabled:!0,true:!0,1:!0};b.define&&b.define([{name:'button',button:function(c,d,e,f,g,h){var i,j=this,l=d,m=j.group('button',l),n=c.labelFill,o=c.symbolFill,p=c.fill,q=c.button[5],r=c.button[6],s=c.hoverFill,t=c.stroke,u=c['symbol-stroke'],v=c['stroke-width'],w=c['symbol-stroke-width'],z=c.config;for(i in'object'==typeof c&&c.button&&([c,d,e,f,g,l]=c.button),l=l||h,m._.button={bound:j.rect(m),tracker:j.rect(m).attr({fill:k,stroke:k,cursor:'pointer'}).data('compositeButton',m)},b.is(g,'object')||(g={}),b.fn.button.fn)m[i]=b.fn.button.fn[i];for(i in b.fn.button.ca)m.ca[i]=b.fn.button.ca[i];return z&&m.attr({config:z}),m.attr({"button-padding":[g.horizontalPadding,g.verticalPadding],"button-label":e,"button-label-size":q,"button-label-family":r,"button-symbol":f,"button-disabled":g.disabled||'false',"button-symbol-position":g.symbolPosition,"button-symbol-padding":g.symbolPadding}).attr('button-repaint',[c,d,g.width,g.height,g.r]).attr({labelFill:n,symbolFill:o,fill:p,hoverFill:s,stroke:t,"symbol-stroke":u,"stroke-width":v,"stroke-linecap":'round',"symbol-stroke-width":w})},data:{hoverin:function(){var a=this,b=a._.button,c=b.hoverbackIn,d=a._hover||{};d.fill||d['fill-symbol']||d.stroke||d['stroke-width']||d.cursor||d.labelFill||d['symbol-stroke']?(d.fill&&a.bottom.attr('fill',d.fill)&&!d['fill-symbol']&&b.symbol.attr('fill',d.fill),d['fill-symbol']&&b.symbol.attr('fill',d['fill-symbol']),d.stroke&&a.bottom.attr('stroke',d.stroke)&&b.symbol.attr('stroke',d.stroke),d['stroke-width']&&a.bottom.attr('stroke-width',d['stroke-width'])&&b.symbol.attr('stroke-width',d['stroke-width']),d.cursor&&b.tracker.attr('cursor',d.cursor),d.labelFill&&b.label&&b.label.attr('fill',d.labelFill),d['symbol-stroke']&&b.symbol.attr('stroke',d['symbol-stroke']),c&&c()):c&&!1===c(arguments)||a.attr('fill','hover'),a.hovered=!0},hoverout:function(){var a=this,b=a._.button,c=b.hoverbackOut,d=a._normal||{};d.fill||d['fill-symbol']||d.stroke||d['stroke-width']||d.cursor||d.labelFill||d['symbol-stroke']?(d.fill&&a.bottom.attr('fill',d.fill)&&!d['fill-symbol']&&b.symbol.attr('fill',d.fill),d.stroke&&a.bottom.attr('stroke',d.stroke)&&b.symbol.attr('stroke',d.stroke),d['fill-symbol']&&b.symbol.attr('fill',d['fill-symbol']),d['stroke-width']&&a.bottom.attr('stroke-width',d['stroke-width'])&&b.symbol.attr('stroke-width',d['stroke-width']),d['symbol-stroke']&&b.symbol.attr('stroke',d['symbol-stroke']),d.labelFill&&b.label&&b.label.attr('fill',d.labelFill),d.cursor&&b.tracker.attr('cursor',d.cursor),c&&c()):c&&!1===c(arguments)||a.attr('fill',(a.pressed||a.active)&&'active'||'normal'),a.hovered=!1},mousedown:function(){var a=this,b=a._.button,c=a._pressed||{};c.fill||c['fill-symbol']||c.stroke||c['stroke-width']||c.cursor||c.labelFill||c['symbol-stroke']?(c.fill&&a.bottom.attr('fill',c.fill)&&!c['fill-symbol']&&b.symbol.attr('fill',c.fill),c.stroke&&a.bottom.attr('stroke',c.stroke)&&b.symbol.attr('stroke',c.stroke),c['fill-symbol']&&b.symbol.attr('fill',c['fill-symbol']),c['stroke-width']&&a.bottom.attr('stroke-width',c['stroke-width'])&&b.symbol.attr('stroke-width',c['stroke-width']),c.labelFill&&b.label&&b.label.attr('fill',c.labelFill),c['symbol-stroke']&&b.symbol.attr('stroke',c['symbol-stroke']),c.cursor&&b.tracker.attr('cursor',c.cursor)):a.attr('fill','active'),a.pressed=!0},mouseup:function(){var a=this,b=a._.button,c=b.callback,d=a._normal||{};d.fill||d['fill-symbol']||d.stroke||d['stroke-width']||d.cursor||d.labelFill||d['symbol-stroke']?(d.fill&&a.bottom.attr('fill',d.fill)&&!d['fill-symbol']&&b.symbol.attr('fill',d.fill),d.stroke&&a.bottom.attr('stroke',d.stroke)&&b.symbol.attr('stroke',d.stroke),d['fill-symbol']&&b.symbol.attr('fill',d['fill-symbol']),d['stroke-width']&&a.bottom.attr('stroke-width',d['stroke-width'])&&b.symbol.attr('stroke-width',d['stroke-width']),d.labelFill&&b.label&&b.label.attr('fill',d.labelFill),d['symbol-stroke']&&b.symbol.attr('stroke',d['symbol-stroke']),d.cursor&&b.tracker.attr('cursor',d.cursor)):a.attr('fill',a.hovered&&'hover'||a.active&&'active'||'normal'),a.pressed=!1,c&&c(arguments)},mousemove:function(){var a=this,b=a._.button,c=b.mousemove;c&&c(arguments)}},fn:{tooltip:function(){return b.el.tooltip&&b.el.tooltip.apply(this._.button.tracker,arguments),this},buttonclick:function(a,b){var c=this,d=c._.button;return b=b||c,d.callback=function(){return a.apply(b,arguments)},c},labelcss:function(){var a=this._.button,b=a.label;return a.cssArg=arguments,b&&b.css.apply(b,arguments),this.attr('button-repaint',this.attrs['button-repaint'])},buttonhover:function(a,b,c,d,e,f){var g=this,h=g._.button;return c=c||g,d=d||g,f=f||g,e&&(h.mousemove=function(){return e.apply(f,arguments)}),h.hoverbackIn=function(){return a.apply(c,arguments)},h.hoverbackOut=function(){return b.apply(d,arguments)},g},remove:function(){var a,c=this,d=c._.button;for(a in c.attr('button-disabled','true'),d)d[a]&&d[a].remove&&d[a].remove(),d[a]=null;delete c._.button,b.el.remove.apply(c,arguments)}},ca:{"button-active":function(a){var b=this;b.attr('fill',(b.active=!!a)?'active':b.hovered&&'hover'||'normal')},"button-disabled":function(b){var c=this,d=c.paper,e=c._.button,f=e.tracker,g=c.attrs['button-disabled'],h=d.button.data,i=c._disabled||{};(b=l[b],g=l[g],b!==a&&b!==g)&&(!0===b?(i.fill||i.stroke||i['stroke-width']||i.cursor?(i.fill&&c.bottom.attr('fill',i.fill)&&e.symbol.attr('fill',i.fill),i.stroke&&c.bottom.attr('stroke',i.stroke)&&e.symbol.attr('stroke',i.stroke),i['stroke-width']&&c.bottom.attr('stroke-width',i['stroke-width']&&e.symbol.attr('fill',i.fill)),i.cursor&&e.tracker.attr('cursor',i.cursor)):f.attr('fill','rgba(204,204,205,.5)'),f.off('fc-mousedown',h.mousedown).off('fc-unmouseup',h.mouseup).unhover(h.hoverin,h.hoverout).unmousemove(h.mousemove)):!1===b?f.attr('fill',k).on('fc-mousedown',h.mousedown,c).on('fc-mouseup',h.mouseup,c).hover(h.hoverin,h.hoverout,c,c).mousemove(h.mousemove,c):void 0)},"button-label":function(a){var b=this,c=b._.button,d=b.attrs,e=c.label,f=c.cssArg,g=b.attrs['button-repaint'];a=j(a||''),'none'===a?e&&(c.label=e.remove()):a&&(!e&&(e=c.label=b.paper.text(b).insertBefore(c.tracker)),e.attr({text:a,"text-anchor":'middle',"vertical-align":'middle'}),f&&f.length&&e.css.apply(e,f)),g&&d['button-label']!==a&&b.attr('button-repaint',g)},"button-label-size":function(a){var b=this,c=b._.button,d=b.attrs,e=c.label,f=b.attrs['button-label-size'];e&&e.attr({"font-size":a}),f&&d['button-label-size']!==a&&b.attr('button-label-size',f)},"button-label-family":function(b){var c=this,d=c._.button,e=c.attrs,f=d.label,g=c.attrs['button-label-family'];f&&(b===a&&(b='sans-serif'),f.attr({"font-family":b}),g&&e['button-label-family']!==b&&c.attr('button-label-family',g))},"button-symbol":function(a){var b=this,c=b._.button,d=c.symbol,e=b.attrs['button-repaint'];a=j(a||''),'none'===a?(d&&(c.symbol=d.remove()),delete c.symbol):a&&!d&&(d=c.symbol=b.paper.symbol(b).insertAfter(c.bound)),e&&b.attr('button-repaint',e)},"button-symbol-position":function(a){return{"button-symbol-position":{top:'top',right:'right',bottom:'bottom',left:'left',none:'none'}[j(a).toLowerCase()]||'none'}},"button-symbol-padding":function(a){return{"button-symbol-padding":h(a)}},"button-padding":function(b,c){return{"button-padding":[(null===b||b===a)&&(b=5)||h(b),(null===c||c===a)&&b||h(c)]}},"button-repaint":function(c,d,e,f,j){var k,l,m,n,p,q,s,t=this,o=t._.button,u=o.bound,v=o.label,z=o.symbol,A=t.attrs,B=A['button-padding'],C=B[0],D=B[1];if(c===a&&(c=0),d===a&&(d=0),(e===a||f===a)&&(q=v&&v.getBBox()||{width:0,height:0},e===a&&(e=2*C+q.width),f===a&&(f=2*D+q.height)),s=b.crispBound(c,d,e,f,u.attr('stroke-width')),s.r=j=pluck(j,i(.1*g(f,e))),c=s.x,d=s.y,e=s.width,f=s.height,v&&v.attr({x:c+e/2,y:d+f/2}),z){switch(b.is(p=A['button-symbol-padding'],'finite')||(p=.2*f),m=f-D,n=.5*m,A['button-symbol-position']+(v&&'+'||'-')){case'right+':e+=2*n+D,k=c+e-n-C,l=d+.5*f,v.attr('transform',['t',-(m+p),0]);break;case'left+':e+=2*n+D,k=c+C+n,l=d+.5*f,v.attr('transform',['t',m+p,0]);break;case'top+':f+=2*n+p,k=c+.5*e,l=d+B[1]+n,v.attr('transform',['t',0,m+p]);break;case'bottom+':f+=2*n+p,k=c+.5*e,l=d+f-D-n,v.attr('transform',['t',0,-(m+p)]);break;default:k=c+.5*e,l=d+.5*f;}z.attr('symbol',[A['button-symbol'],k,l,n,e,f])}o.bound.attr(s),o.tracker.attr(s)},fill:function(a,c=!0){var d=this,e=d._.button,f=e.bound,g={normal:e.gradient,active:e.gradientActive,hover:e.gradientHover}[a];return g||(!c&&(a=b.getRGB(a),a.error&&(a=b.color('#cccccc')),a='opacity'in a?'rgba('+[a.r,a.g,a.b,a.opacity]+')':'rgb('+[a.r,a.g,a.b]+')'),e.gradient=c?a:[90,b.tintshade(a,-.8).rgba+':0',b.tintshade(a,.8).rgba+':100'].join('-'),e.gradientActive=[270,b.tintshade(a,-.8).rgba+':0',b.tintshade(a,.8).rgba+':100'].join('-'),g=(d.pressed||d.active)&&e.gradientActive||d.hovered&&e.gradienthover||e.gradient),f.attr('fill',g),!1},hoverFill:function(a){var c=this,d=c._.button;return a=b.getRGB(a),a='opacity'in a?'rgba('+[a.r,a.g,a.b,a.opacity]+')':'rgb('+[a.r,a.g,a.b]+')',d.gradientHover=a,!1},labelFill:function(a){var b=this,c=b._.button,d=c.label;return d&&a&&(c.labelFill=a,d.attr('fill',a)),!1},symbolFill:function(a){var b=this,c=b._.button,d=c.symbol;return d&&a&&(c.symbolFill=a,d.attr('fill',a)),!1},stroke:function(a){var c=this._.button;return a=b.color(a),a.error&&(a=b.color('#999999')),c.bound.attr('stroke',a),!1},"symbol-stroke":function(a){var b=this._.button,c=b.symbol;return c&&a&&c.attr('stroke',a),!1},"stroke-width":function(a){var b=this._.button;return b.bound.attr('stroke-width',a),b.tracker.attr('stroke-width',a),!1},"symbol-stroke-width":function(a){var b=this._.button,c=b.symbol;return c&&a&&c.attr('stroke-width',a),!1},config:function(a){var b=this;a.hover&&(b._hover={fill:a.hover.fill,stroke:a.hover.stroke,"stroke-width":a.hover['stroke-width'],cursor:a.hover.cursor,"fill-symbol":a.hover['fill-symbol'],"symbol-stroke":a.hover['symbol-stroke'],labelFill:a.hover.labelFill}),a.disabled&&(b._disabled={fill:a.disabled.fill,stroke:a.disabled.stroke,"stroke-width":a.disabled['stroke-width'],"symbol-stroke":a.disabled['symbol-stroke'],cursor:a.disabled.cursor,labelFill:a.disabled.labelFill}),a.pressed&&(b._pressed={fill:a.pressed.fill,stroke:a.pressed.stroke,"stroke-width":a.pressed['stroke-width'],cursor:a.pressed.cursor,"fill-symbol":a.pressed['fill-symbol'],"symbol-stroke":a.pressed['symbol-stroke'],labelFill:a.pressed.labelFill}),a.normal&&(b._normal={fill:a.normal.fill,stroke:a.normal.stroke,"stroke-width":a.normal['stroke-width'],cursor:a.normal.cursor,"fill-symbol":a.normal['fill-symbol'],"symbol-stroke":a.normal['symbol-stroke'],labelFill:a.normal.labelFill}),a.symbol&&(a.symbol={stroke:a.normal.stroke,"stroke-width":a.normal['stroke-width']})}}}])}