$.widget("ui.scrollerNode",$.ui.sceneResource,{options:{data:null,parent:null,zoom:$.noop,onupdate:$.noop,ondelete:$.noop,addHistory:$.noop},category:"scrollers",isContainer:!0,defaultValues:{type:"",id:"",rotation:0,opacity:1,zIndex:0,position:{x:0,y:0},direction:"vertical",columns:1,rows:1,width:100,height:100,cellWidth:100,cellHeight:100,margin:0,hiddenAtStart:!1},sourceProp:["direction","rows","columns","width","height","cellWidth","cellHeight","margin"],needToUpdateJson:!0,getRate:function(){return 1},resizeStart:function(){$.ui.sceneResource.prototype.resizeStart.call(this);this.originalSize={width:this.width(),height:this.height()};this.originalCellWidth=this.cellWidth();this.originalCellHeight=this.cellHeight();this.originalColumns=this.columns();this.originalRows=this.rows()},resize:function(t,i,e,h){var n=this.element;if(h.x||h.y){n.css({top:i.y+h.y+"px",left:i.x+h.x+"px"});this.position(this.getRealPosition())}var o=this.direction(),s=this.zoomValue;if("vertical"===o){this.$inner.css("height",t.height+e.height);this.height(Math.round(this.originalSize.height+e.height/s));var r=this.cellWidth();this.columns(Math.max(this.originalColumns+Math.round(e.width/s/r),1))}else{this.$inner.css("width",t.width+e.width);this.width(Math.round(this.originalSize.width+e.width/s));var l=this.cellHeight();this.rows(Math.max(this.originalRows+Math.round(e.height/s/l),1))}this.isSelected()&&this.onselect()},direction:function(t){var i=this.elementData("direction",t);void 0!==t&&this.updatePreview();return i},cellWidth:function(t){var i=this.elementData("cellWidth",t);void 0!==t&&this.updatePreview();return i},cellHeight:function(t){var i=this.elementData("cellHeight",t);void 0!==t&&this.updatePreview();return i},columns:function(t){var i=this.elementData("columns",t);void 0!==t&&this.updatePreview();return i},rows:function(t){var i=this.elementData("rows",t);void 0!==t&&this.updatePreview();return i},width:function(t){var i=this.elementData("width",t);void 0!==t&&this.updatePreview();return i},height:function(t){var i=this.elementData("height",t);void 0!==t&&this.updatePreview();return i},margin:function(t){var i=this.elementData("margin",t);void 0!==t&&this.updatePreview();return i},updatePreview:function(t){t||(t=this.zoomValue);var i=this.direction(),e=(this.position(),this.cellWidth()),h=this.cellHeight(),n=this.margin()||0,o=this.element.addClass(i),s=this.$inner;if("vertical"===i){o.removeClass("horizontal");var r=this.height(),l=this.columns(),a=Math.ceil(r/h);s.css({width:l*(e+2*n)*t,height:r*t})}else{o.removeClass("vertical");var d=this.width(),a=this.rows(),l=Math.ceil(d/e);s.css({width:d*t,height:a*(h+2*n)*t})}o.css({width:s.width()+2,height:s.height()+2});s.css({outline:"none",position:"absolute"});for(var c=0;a>c;c++)for(var u=0;l>u;u++){var g=s.children("[row = '"+c+"'][column = '"+u+"']").show();g.length||(g=this.addCell(c,u,t));g.css({width:e*t,height:h*t,overflow:"visible",position:"absolute",left:u*(e+2*n)*t+n*t,top:c*(h+2*n)*t+n*t})}s.children().each(function(t,i){var e=$(i).attr("row"),h=$(i).attr("column");(0>e||e>=a||0>h||h>=l)&&$(i).hide()})},addCell:function(t,i,e){e||(e=this.zoomValue);var h=(this.cellWidth(),this.cellHeight(),this.margin()||0,this),n=$("<div class = 'cell'></div>").attr("row",t).attr("column",i).appendTo(this.$inner);this.options.get("initDroppable",n,null,function(){return h.id()},function(e){e.row=t;e.column=i;return e});return n},getObjectsParent:function(t){var i=t.row||0,e=t.column||0,h=this.element.find("[row = '"+i+"'][column = '"+e+"']");h.length||(h=this.addCell(i,e));return h}});