(function(){"use strict";u8.Crm.Widgets.RecordSlider=function(e,t){this.Slider(e,$.extend(u8.Crm.Widgets.RecordSlider.defaults,t));this.bind("DblClick",this._onSliderDblClick.bind(this));if(!u8.tools.isClass(this.dataProvider)){this.dataProvider=u8.services.tableCaptions.createDataProvider($.extend(this.dataProvider,{autoRefresh:this.autoRefresh,__owner:this}))}this.dataProvider.bind("Update",this._onDataProviderUpdate.bind(this),"RecordSlider")};u8.Crm.Widgets.RecordSlider.defaults={keyProperty:"uid",showImage:true,showActions:true,reloadOnUpdate:false,createItemView:e,imageDecorator:"s",styles:[]};u8.Crm.Widgets.RecordSlider.makeClass({name:"RecordSlider",deriveFrom:u8.Base.Widgets.Slider});$.extend(u8.Crm.Widgets.RecordSlider.prototype,{dispose:function(){this.dataProvider.unbind("Update","RecordSlider");if(this.dataProvider.__owner==this){this.dataProvider.dispose()}delete this.dataProvider;this.Slider_dispose(this)},_createModel:function(e){this._loadRecords.bind(this,e).defer(0)},_loadRecords:function(e){if(this._isDisposed){return}if(this.dataProvider&&this.dataProvider.__owner==this){this.dataProvider.load()}if(e){e()}},_compareItems:function(e,t){if(e&&!t||!e&&t){return false}if(e==t){return true}if(e.length!=t.length){return false}var i=true;e.each(function(e){i=t.find(function(t){return u8.equalsRecordUid(e.uid,t.uid)});return i});return i},_updateItemsView:function(){var e=this;this.items.each(function(t){if(t.__widget){t.__widget.update({args:{reload:e.reloadOnUpdate}})}})},_onDataProviderUpdate:function(e,t){if(this._isDisposed){return}if(t.reason=="load"){this._isLoaded=true;if(!this._compareItems(this.items,e.data)){this.setItems(e.data||[])}else{this._updateItemsView()}return}this._loadRecords()},_onSliderDblClick:function(e,t){if(t.cancel){return}var i=e.getValue();if(!i){return}if(this.action){u8.services.actions.execute(this.action,{arguments:{uid:i}})}else{u8.services.actions.executeDefault(i)}}});function e(e,t){var i={model:e,value:e.uid,tableCaptionName:e.name,showImage:this.showImage,showActions:this.showActions,imageDecorator:this.imageDecorator,actions:[{command:"BusinessObjects/Menu"}],parent:this,styles:this.styles};var s=u8.widget("TableCaption",t,i);e.__widget=s}})();