You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
16 KiB
1 lines
16 KiB
(window["webpackJsonp_TIS_PLATFORM"]=window["webpackJsonp_TIS_PLATFORM"]||[]).push([["WidgetDR"],{"0512":function(t,i,e){},"4ec9":function(t,i,e){"use strict";var n=e("6d61"),o=e("6566");t.exports=n("Map",(function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}}),o)},"6a79":function(t,i,e){"use strict";e("c7df")},"88bf":function(t,i,e){"use strict";e("0512")},b6ee:function(t,i,e){"use strict";e.r(i);var n=function(){var t=this,i=t.$createElement,e=t._self._c||i;return e("VueDragResize",{directives:[{name:"show",rawName:"v-show",value:t.widget.opened,expression:"widget.opened"}],staticClass:"drag-container",attrs:{isDraggable:t.isDraggable,parentLimitation:"",isResizable:t.isResizable,parentW:t.parentW,parentH:t.parentH,minh:t.minh,minw:t.minw,x:t.left,y:t.top,w:t.width,h:t.height},on:{resizing:t.resize,dragging:t.resize}},[e("tis-card",{staticClass:"card"},[e("div",{directives:[{name:"show",rawName:"v-show",value:t.isTitle,expression:"isTitle"}],staticClass:"header",attrs:{slot:"header"},slot:"header"},[e("div",{staticClass:"name"},[t._v(t._s(t.widget.name))]),e("div",[e("span",[e("tis-button",{attrs:{type:"text",size:"small"},on:{click:t.toggle}},[t._v("浮窗大小")])],1),t._v(" "),e("span",[e("tis-button",{attrs:{type:"text",size:"small"},on:{click:t.onClose}},[t._v("关闭")])],1)]),e("tis-card",{directives:[{name:"show",rawName:"v-show",value:t.showSizeChoice,expression:"showSizeChoice"}],staticClass:"size-choice"},[e("div",[e("tis-radio",{attrs:{label:"small"},model:{value:t.quickSize,callback:function(i){t.quickSize=i},expression:"quickSize"}},[t._v("小")])],1),e("tis-radio",{attrs:{label:"medium"},model:{value:t.quickSize,callback:function(i){t.quickSize=i},expression:"quickSize"}},[t._v("中")]),e("br"),e("tis-radio",{attrs:{label:"large"},model:{value:t.quickSize,callback:function(i){t.quickSize=i},expression:"quickSize"}},[t._v("大")]),e("br")],1)],1),e("div",{staticClass:"content"},[e("div",{attrs:{id:t.widget.containerId}})])])],1)},o=[],s=e("5530"),a=function(){var t=this,i=t.$createElement,e=t._self._c||i;return e("div",{staticClass:"vdr",class:(t.active||t.isActive?"active":"inactive")+" "+(t.contentClass?t.contentClass:""),style:t.positionStyle,on:{mousedown:function(i){return t.bodyDown(i)},touchstart:function(i){return t.bodyDown(i)},touchend:function(i){return t.up(i)}}},[e("div",{ref:"container",staticClass:"content-container",style:t.sizeStyle},[t._t("default")],2),t._l(t.sticks,(function(i){return e("div",{staticClass:"vdr-stick",class:["vdr-stick-"+i,t.isResizable?"":"not-resizable"],style:t.vdrStick(i),on:{mousedown:function(e){return e.stopPropagation(),e.preventDefault(),t.stickDown(i,e)},touchstart:function(e){return e.stopPropagation(),e.preventDefault(),t.stickDown(i,e)}}})}))],2)},r=[],h=(e("4160"),e("c975"),e("4ec9"),e("a9e3"),e("d3b7"),e("25f0"),e("3ca3"),e("159b"),e("ddb0"),e("2909")),l={y:{t:"top",m:"marginTop",b:"bottom"},x:{l:"left",m:"marginLeft",r:"right"}};function c(t){t.forEach((function(t,i){document.documentElement.addEventListener(i,t)}))}function u(t){t.forEach((function(t,i){document.documentElement.removeEventListener(i,t)}))}var d={name:"vue-drag-resize",emits:["clicked","dragging","dragstop","resizing","resizestop","activated","deactivated"],props:{stickSize:{type:Number,default:8},parentScaleX:{type:Number,default:1},parentScaleY:{type:Number,default:1},isActive:{type:Boolean,default:!1},preventActiveBehavior:{type:Boolean,default:!1},isDraggable:{type:Boolean,default:!0},isResizable:{type:Boolean,default:!0},aspectRatio:{type:Boolean,default:!1},parentLimitation:{type:Boolean,default:!1},snapToGrid:{type:Boolean,default:!1},gridX:{type:Number,default:50,validator:function(t){return t>=0}},gridY:{type:Number,default:50,validator:function(t){return t>=0}},parentW:{type:Number,default:0,validator:function(t){return t>=0}},parentH:{type:Number,default:0,validator:function(t){return t>=0}},w:{type:[String,Number],default:200,validator:function(t){return"string"===typeof t?"auto"===t:t>=0}},h:{type:[String,Number],default:200,validator:function(t){return"string"===typeof t?"auto"===t:t>=0}},minw:{type:Number,default:50,validator:function(t){return t>=0}},minh:{type:Number,default:50,validator:function(t){return t>=0}},x:{type:Number,default:0,validator:function(t){return"number"===typeof t}},y:{type:Number,default:0,validator:function(t){return"number"===typeof t}},z:{type:[String,Number],default:"auto",validator:function(t){return"string"===typeof t?"auto"===t:t>=0}},dragHandle:{type:String,default:null},dragCancel:{type:String,default:null},sticks:{type:Array,default:function(){return["tl","tm","tr","mr","br","bm","bl","ml"]}},axis:{type:String,default:"both",validator:function(t){return-1!==["x","y","both","none"].indexOf(t)}},contentClass:{type:String,required:!1,default:""}},data:function(){return{fixAspectRatio:null,active:null,zIndex:null,parentWidth:null,parentHeight:null,left:null,top:null,right:null,bottom:null,minHeight:null,whiteDOM:null}},beforeCreate:function(){this.stickDrag=!1,this.bodyDrag=!1,this.dimensionsBeforeMove={pointerX:0,pointerY:0,x:0,y:0,w:0,h:0},this.limits={left:{min:null,max:null},right:{min:null,max:null},top:{min:null,max:null},bottom:{min:null,max:null}},this.currentStick=null},mounted:function(){var t=this;this.parentElement=this.$el.parentNode,this.parentWidth=this.parentW?this.parentW:this.parentElement.clientWidth,this.parentHeight=this.parentH?this.parentH:this.parentElement.clientHeight,this.left=this.x,this.top=this.y,this.right=this.parentWidth-("auto"===this.w?this.$refs.container.scrollWidth:this.w)-this.left,this.bottom=this.parentHeight-("auto"===this.h?this.$refs.container.scrollHeight:this.h)-this.top,this.domEvents=new Map([["mousemove",this.move],["mouseup",this.up],["mouseleave",this.up],["mousedown",this.deselect],["touchmove",this.move],["touchend",this.up],["touchcancel",this.up],["touchstart",this.up]]),c(this.domEvents),this.dragHandle&&Object(h["a"])(this.$el.querySelectorAll(this.dragHandle)).forEach((function(i){i.setAttribute("data-drag-handle",t._uid)})),this.dragCancel&&Object(h["a"])(this.$el.querySelectorAll(this.dragCancel)).forEach((function(i){i.setAttribute("data-drag-cancel",t._uid)}))},beforeDestroy:function(){this.whiteDOM=null,u(this.domEvents)},methods:{deselect:function(){this.preventActiveBehavior||(this.active=!1)},move:function(t){if(this.stickDrag||this.bodyDrag){t.stopPropagation();var i="undefined"!==typeof t.pageX?t.pageX:t.touches[0].pageX,e="undefined"!==typeof t.pageY?t.pageY:t.touches[0].pageY,n=this.dimensionsBeforeMove,o={x:(n.pointerX-i)/this.parentScaleX,y:(n.pointerY-e)/this.parentScaleY};if(this.stickDrag&&this.stickMove(o),this.bodyDrag){if("x"===this.axis)o.y=0;else if("y"===this.axis)o.x=0;else if("none"===this.axis)return;this.bodyMove(o)}}},up:function(t){this.stickDrag?this.stickUp(t):this.bodyDrag&&this.bodyUp(t)},bodyDown:function(t){var i=t.target,e=t.button,n=i.nodeName.toLowerCase(),o=["button","input","textarea","select","option"];this.preventActiveBehavior||(this.active=!0);for(var s=0,a=o;s<a.length;s++){var r=a[s];if(n===r)return void(this.whiteDOM=i);this.whiteDOM&&this.whiteDOM.blur()}if(e&&0!==e)console.log("sb");else if(this.$emit("clicked",t),this.active&&(!this.dragHandle||i.getAttribute("data-drag-handle")===this._uid.toString())&&(!this.dragCancel||i.getAttribute("data-drag-cancel")!==this._uid.toString())){"undefined"!==typeof t.stopPropagation&&t.stopPropagation(),"undefined"!==typeof t.preventDefault&&t.preventDefault(),this.isDraggable&&(this.bodyDrag=!0);var h="undefined"!==typeof t.pageX?t.pageX:t.touches[0].pageX,l="undefined"!==typeof t.pageY?t.pageY:t.touches[0].pageY;this.saveDimensionsBeforeMove({pointerX:h,pointerY:l}),this.parentLimitation&&(this.limits=this.calcDragLimitation())}},bodyMove:function(t){var i=this.dimensionsBeforeMove,e=this.parentWidth,n=this.parentHeight,o=this.gridX,s=this.gridY,a=this.width,r=this.height,h=i.top-t.y,l=i.bottom+t.y,c=i.left-t.x,u=i.right+t.x;if(this.snapToGrid){var d=!0,m=!0,p=h-Math.floor(h/s)*s,f=n-l-Math.floor((n-l)/s)*s,g=c-Math.floor(c/o)*o,v=e-u-Math.floor((e-u)/o)*o;p>s/2&&(p-=s),f>s/2&&(f-=s),g>o/2&&(g-=o),v>o/2&&(v-=o),Math.abs(f)<Math.abs(p)&&(d=!1),Math.abs(v)<Math.abs(g)&&(m=!1),h-=d?p:f,l=n-r-h,c-=m?g:v,u=e-a-c}var w=this.rectCorrectionByLimit({newLeft:c,newRight:u,newTop:h,newBottom:l});this.left=w.newLeft,this.right=w.newRight,this.top=w.newTop,this.bottom=w.newBottom,this.$emit("dragging",this.rect)},bodyUp:function(){this.bodyDrag=!1,this.$emit("dragging",this.rect),this.$emit("dragstop",this.rect),this.dimensionsBeforeMove={pointerX:0,pointerY:0,x:0,y:0,w:0,h:0},this.limits={left:{min:null,max:null},right:{min:null,max:null},top:{min:null,max:null},bottom:{min:null,max:null}}},stickDown:function(t,i){var e=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.isResizable&&this.active||e){this.stickDrag=!0;var n="undefined"!==typeof i.pageX?i.pageX:i.touches[0].pageX,o="undefined"!==typeof i.pageY?i.pageY:i.touches[0].pageY;this.saveDimensionsBeforeMove({pointerX:n,pointerY:o}),this.currentStick=t,this.limits=this.calcResizeLimits()}},saveDimensionsBeforeMove:function(t){var i=t.pointerX,e=t.pointerY;this.dimensionsBeforeMove.pointerX=i,this.dimensionsBeforeMove.pointerY=e,this.dimensionsBeforeMove.left=this.left,this.dimensionsBeforeMove.right=this.right,this.dimensionsBeforeMove.top=this.top,this.dimensionsBeforeMove.bottom=this.bottom,this.dimensionsBeforeMove.width=this.width,this.dimensionsBeforeMove.height=this.height,this.aspectFactor=this.width/this.height},stickMove:function(t){var i=this.currentStick,e=this.dimensionsBeforeMove,n=this.gridY,o=this.gridX,s=this.snapToGrid,a=this.parentHeight,r=this.parentWidth,h=e.top,l=e.bottom,c=e.left,u=e.right;switch(i[0]){case"b":l=e.bottom+t.y,s&&(l=a-Math.round((a-l)/n)*n);break;case"t":h=e.top-t.y,s&&(h=Math.round(h/n)*n);break;default:break}switch(i[1]){case"r":u=e.right+t.x,s&&(u=r-Math.round((r-u)/o)*o);break;case"l":c=e.left-t.x,s&&(c=Math.round(c/o)*o);break;default:break}var d=this.rectCorrectionByLimit({newLeft:c,newRight:u,newTop:h,newBottom:l});if(c=d.newLeft,u=d.newRight,h=d.newTop,l=d.newBottom,this.aspectRatio){var m=this.rectCorrectionByAspectRatio({newLeft:c,newRight:u,newTop:h,newBottom:l});c=m.newLeft,u=m.newRight,h=m.newTop,l=m.newBottom}this.left=c,this.right=u,this.top=h,this.bottom=l,this.$emit("resizing",this.rect)},stickUp:function(){this.stickDrag=!1,this.dimensionsBeforeMove={pointerX:0,pointerY:0,x:0,y:0,w:0,h:0},this.limits={left:{min:null,max:null},right:{min:null,max:null},top:{min:null,max:null},bottom:{min:null,max:null}},this.$emit("resizing",this.rect),this.$emit("resizestop",this.rect)},calcDragLimitation:function(){var t=this.parentWidth,i=this.parentHeight;return{left:{min:0,max:t-this.width},right:{min:0,max:t-this.width},top:{min:0,max:i-this.height},bottom:{min:0,max:i-this.height}}},calcResizeLimits:function(){var t=this.aspectFactor,i=this.width,e=this.height,n=this.bottom,o=this.top,s=this.left,a=this.right,r=this.minh,h=this.minw,l=this.parentLimitation?0:null;this.aspectRatio&&(h/r>t?r=h/t:h=t*r);var c={left:{min:l,max:s+(i-h)},right:{min:l,max:a+(i-h)},top:{min:l,max:o+(e-r)},bottom:{min:l,max:n+(e-r)}};if(this.aspectRatio){var u={left:{min:s-Math.min(o,n)*t*2,max:s+(e-r)/2*t*2},right:{min:a-Math.min(o,n)*t*2,max:a+(e-r)/2*t*2},top:{min:o-Math.min(s,a)/t*2,max:o+(i-h)/2/t*2},bottom:{min:n-Math.min(s,a)/t*2,max:n+(i-h)/2/t*2}};"m"===this.currentStick[0]?(c.left={min:Math.max(c.left.min,u.left.min),max:Math.min(c.left.max,u.left.max)},c.right={min:Math.max(c.right.min,u.right.min),max:Math.min(c.right.max,u.right.max)}):"m"===this.currentStick[1]&&(c.top={min:Math.max(c.top.min,u.top.min),max:Math.min(c.top.max,u.top.max)},c.bottom={min:Math.max(c.bottom.min,u.bottom.min),max:Math.min(c.bottom.max,u.bottom.max)})}return c},sideCorrectionByLimit:function(t,i){var e=i;return null!==t.min&&i<t.min?e=t.min:null!==t.max&&t.max<i&&(e=t.max),e},rectCorrectionByLimit:function(t){var i=this.limits,e=t.newRight,n=t.newLeft,o=t.newBottom,s=t.newTop;return n=this.sideCorrectionByLimit(i.left,n),e=this.sideCorrectionByLimit(i.right,e),s=this.sideCorrectionByLimit(i.top,s),o=this.sideCorrectionByLimit(i.bottom,o),{newLeft:n,newRight:e,newTop:s,newBottom:o}},rectCorrectionByAspectRatio:function(t){var i=t.newLeft,e=t.newRight,n=t.newTop,o=t.newBottom,s=this.parentWidth,a=this.parentHeight,r=this.currentStick,h=this.aspectFactor,l=this.dimensionsBeforeMove,c=s-i-e,u=a-n-o;if("m"===r[1]){var d=u-l.height;i-=d*h/2,e-=d*h/2}else if("m"===r[0]){var m=c-l.width;n-=m/h/2,o-=m/h/2}else c/u>h?(c=h*u,"l"===r[1]?i=s-e-c:e=s-i-c):(u=c/h,"t"===r[0]?n=a-o-u:o=a-n-u);return{newLeft:i,newRight:e,newTop:n,newBottom:o}}},computed:{positionStyle:function(){return{top:this.top+"px",left:this.left+"px",zIndex:this.zIndex}},sizeStyle:function(){return{width:"auto"==this.w?"auto":this.width+"px",height:"auto"==this.h?"auto":this.height+"px"}},vdrStick:function(){var t=this;return function(i){var e={width:"".concat(t.stickSize/t.parentScaleX,"px"),height:"".concat(t.stickSize/t.parentScaleY,"px")};return e[l.y[i[0]]]="".concat(t.stickSize/t.parentScaleX/-2,"px"),e[l.x[i[1]]]="".concat(t.stickSize/t.parentScaleX/-2,"px"),e}},width:function(){return this.parentWidth-this.left-this.right},height:function(){return this.parentHeight-this.top-this.bottom},rect:function(){return{left:Math.round(this.left),top:Math.round(this.top),width:Math.round(this.width),height:Math.round(this.height)}}},watch:{active:function(t){t?this.$emit("activated"):this.$emit("deactivated")},isActive:{immediate:!0,handler:function(t){this.active=t}},z:{immediate:!0,handler:function(t){(t>=0||"auto"===t)&&(this.zIndex=t)}},x:{handler:function(t,i){var e=this;if(!this.stickDrag&&!this.bodyDrag&&t!==this.left){var n=i-t;this.bodyDown({pageX:this.left,pageY:this.top}),this.bodyMove({x:n,y:0}),this.$nextTick((function(){e.bodyUp()}))}}},y:{handler:function(t,i){var e=this;if(!this.stickDrag&&!this.bodyDrag&&t!==this.top){var n=i-t;this.bodyDown({pageX:this.left,pageY:this.top}),this.bodyMove({x:0,y:n}),this.$nextTick((function(){e.bodyUp()}))}}},w:{handler:function(t,i){var e=this;if(!this.stickDrag&&!this.bodyDrag&&t!==this.width){var n="mr",o=i-t;this.stickDown(n,{pageX:this.right,pageY:this.top+this.height/2},!0),this.stickMove({x:o,y:0}),this.$nextTick((function(){e.stickUp()}))}}},h:{handler:function(t,i){var e=this;if(!this.stickDrag&&!this.bodyDrag&&t!==this.height){var n="bm",o=i-t;this.stickDown(n,{pageX:this.left+this.width/2,pageY:this.bottom},!0),this.stickMove({x:0,y:o}),this.$nextTick((function(){e.stickUp()}))}}},parentW:function(t){this.right=t-this.width-this.left,this.parentWidth=t},parentH:function(t){this.bottom=t-this.height-this.top,this.parentHeight=t}}},m=d,p=(e("88bf"),e("2877")),f=Object(p["a"])(m,a,r,!1,null,null,null),g=f.exports,v={small:{width:280,height:230},medium:{width:280,height:300},large:{width:280,height:400}},w={props:{widget:Object},components:{VueDragResize:g},computed:{parentW:function(){return window.outerWidth},parentH:function(){return window.outerHeight},isDraggable:function(){return"boolean"!==typeof this.widget.isDraggable||this.widget.isDraggable},isResizable:function(){return"boolean"!==typeof this.widget.isResizable||this.widget.isResizable},isTitle:function(){return"boolean"!==typeof this.widget.isTitle||this.widget.isTitle},minh:function(){return"number"===typeof this.widget.minh?this.widget.minh:40},minw:function(){return"number"===typeof this.widget.minw?this.widget.minw:280},remember:function(){return"boolean"!==typeof this.widget.remember||this.widget.remember},quickSize:{set:function(t){this.showSizeChoice=!1,this.onChangeSize(t)},get:function(){for(var t in v){var i=v[t],e=i.width,n=i.height;if(e===this.width&&this.height===n)return t}return""}}},data:function(){var t=this.widget,i=t.width,e=t.height,n=t.top,o=t.left;if(i="number"===typeof i?i:280,e="number"===typeof e?e:272,n="number"===typeof n?n:80,o="number"===typeof o?o:window.outerWidth/2-i/2,!1!==this.remember)try{var s=localStorage.getItem(this.widget.id);s&&(s=JSON.parse(s),i=s.width,e=s.height,n=s.top,o=s.left)}catch(a){console.error(a)}return{showSizeChoice:!1,width:i,height:e,top:n,left:o}},methods:{resize:function(t){this.width=t.width,this.height=t.height,this.top=t.top,this.left=t.left,!1!==this.remember&&localStorage.setItem(this.widget.id,JSON.stringify(Object(s["a"])({},t)))},onClose:function(){this.$tis.closeWidget(this.widget.id)},toggle:function(){this.showSizeChoice=!this.showSizeChoice},onChangeSize:function(t){var i=v[t];this.resize(Object(s["a"])({width:this.width,height:this.height,top:this.top,left:this.left},i))}}},b=w,y=(e("6a79"),Object(p["a"])(b,n,o,!1,null,"101d9724",null));i["default"]=y.exports},c7df:function(t,i,e){}}]);
|