$.widget("ui.videoNode",$.ui.sceneResource,{options:{data:null,parent:null,zoom:$.noop,onupdate:$.noop,ondelete:$.noop,addHistory:$.noop},bgSize:{width:800,height:450},category:"videos",defaultValues:{type:"",id:"",rotation:0,opacity:1,zIndex:0,position:{x:0,y:0},size:{width:800,height:450},src:"",autoplay:!1,isFullScreen:!1,controls:!1,loop:1,videoSkipBtn:{isUse:!1,data:{size:{width:50,height:50},position:{x:0,y:0},picture:"/public/qiyun/resources/UI/skipButton.png"}},hiddenAtStart:!1},sourceProp:["src","autoplay","isFullScreen","size","controls","loop","videoSkipBtn"],needToUpdateJson:!0,initElement:function(){var t=this.element,e=this;$.ui.sceneResource.prototype.initElement.apply(this,arguments);this.$inner.addClass("video-element");$("<div class = 'controls'></div>").appendTo(t).hide();$("<a class = 'videoSkipBtn' style = 'position: absolute; width: 50px; height: 50px; z-index: 100;'></a>").appendTo(t).draggable({stop:function(){var t=e.videoSkipBtn();t||(t={});t.data||(t={});var i=t.data.position,o=$(this).position();o={x:parseInt(o.left/e.zoomValue),y:parseInt(o.top/e.zoomValue)};if(i.x!==o.x||i.y!==o.y){t=JSON.parse(JSON.stringify(t));t.data.position=o;e.onchange("videoSkipBtn",{videoSkipBtn:t})}}}).dblclick(function(t){$.utils.selectImage({fileType:"image",multiple:!1,callback:function(t){$.utils.getImageSize(t,function(i){var o=e.videoSkipBtn();o||(o={});o.data||(o={});var s=o.data.size,n=o.data.picture;if(t!==n||i.width!==s.width||i.height!==s.height){o=JSON.parse(JSON.stringify(o));o.data.size=i;o.data.picture=t;e.onchange("videoSkipBtn",{videoSkipBtn:o})}});return!0}});t.stopPropagation()}).hide()},initData:function(){$.ui.sceneResource.prototype.initData.apply(this,arguments);this.updateControls();this.updateVideoSkipButton()},dragStart:function(t){if(!this.draggable)return!1;$.ui.sceneResource.prototype.dragStart.call(this,t);return void 0},getRate:function(){var t=this.bgSize;return t.width/t.height},resize:function(t,e,i,o){var s=this.element;s.css({top:e.y+o.y+"px",left:e.x+o.x+"px",width:t.width+i.width+"px",height:t.height+i.height+"px"});this.elementData("size",this.getRealSize());this.elementData("position",this.getRealPosition());this.updatePreview();this.isSelected()&&this.onselect()},getCurrentData:function(){var t=this,e={};this.jsonProperties.forEach(function(i){t[i]&&(e[i]=t[i]())});e.hiddenAtStart||delete e.hiddenAtStart;e.zIndex||delete e.zIndex;e.src||delete e.src;e.autoplay||delete e.autoplay;e.isFullScreen||delete e.isFullScreen;e.controls||delete e.controls;e.loop-0===1&&delete e.loop;var i=this.isUseVideoSkipBtn();i&&(e.videoSkipBtn={isUse:!0,data:{size:this.skipBtnSize(),position:this.skipBtnPosition(),picture:this.skipBtnPicture()}});return e},isFullScreen:function(t){var e=this.elementData("isFullScreen",t);if(void 0!==t){if(t){this.resizable=!1;this.draggable=!1;this.rotatable=!1}else{this.resizable=!0;this.draggable=!0;this.rotatable=!0}this.initOperateObjectData();this.isSelected()&&this.onselect()}return e},controls:function(t){var e=this.elementData("controls",t);if(void 0===t)return e;this.updateControls();return void 0},videoSkipBtn:function(t){var e=this.elementData("videoSkipBtn",t);if(void 0===t)return e;this.updateVideoSkipButton();return void 0},getDomSize:function(){return{width:this.element.width(),height:this.element.height()}},updatePreview:function(t){var e=this.element;t||(t=this.zoomValue);var i=(this.position(),this.size());e.css({width:i.width*t,height:i.height*t});var o=Math.min(i.width/this.bgSize.width,i.height/this.bgSize.height);this.$inner.css({width:this.bgSize.width*o*t,height:this.bgSize.height*o*t,position:"absolute",left:(i.width-this.bgSize.width*o)*t/2+"px",top:(i.height-this.bgSize.height*o)*t/2+"px"});this.updateVideoSkipButton()},updateVideoSkipButton:function(){var t=this.element.find(".videoSkipBtn"),e=this.videoSkipBtn();if(e&&e.isUse){t.show();e.data||(e.data={});var i=this.defaultValues.videoSkipBtn,o=e.data.size||i.data.size,s=e.data.position||i.data.position,n=e.data.picture||i.data.picture,a=this.zoomValue;t.css({width:o.width*a+"px",height:o.height*a+"px",top:s.y*a+"px",left:s.x*a+"px",background:"url("+$.utils.getImageData($.user.userid+"/"+$.currentProj+"/"+n)+")",backgroundRepeat:"no-repeat",backgroundSize:"100% 100%"})}else t.hide()},updateControls:function(){this.element.find(".controls")[this.controls()?"show":"hide"]()}});