(function(){"use strict";u8.Base.Widgets.LiveTileChangeNotificationsProvider=function(i){$.extend(this,u8.Base.Widgets.LiveTileChangeNotificationsProvider.defaults,i);this.bind(i);this._isCreated=false;this._create()};u8.Base.Widgets.LiveTileChangeNotificationsProvider.defaults={items:[],moreRowsExist:false,disabled:false};$.extend(u8.Base.Widgets.LiveTileChangeNotificationsProvider.prototype,{createSlider:function(i,e){this._slider=u8.create("Slider",i,$.extend(e,{keyProperty:"notificationId",textProperty:"fullChangeDescription",items:[],onDblClick:this._onSliderDblClick}));return this._slider},load:function(){this.items=this.items||[];var i=this;if(this.tableCaptionName=="recent"){var e=u8.session.webConfigValues.getInt("Watchlist.RecentNotifications.PeriodInDays",30);u8.request("WatchListChannel.RetrieveAllMyRecentNotifications",{request:{inboxOwner:u8.session.identity.repId,periodInDays:e}},function(e,t){if(t.error){}else{i.items=t.response.allMyRecentNotifications;i.raise("Update",{reason:"load"});var n=i.items;if(n&&n.length&&typeof n[0]!="object"){var o=0;n=n.map(function(i){return{key:o++,text:i.toString()}})}if(i._slider){i._slider.setItems(n)}}})}else if(this.tableCaptionName=="today"){u8.request("WatchListChannel.RetrieveAllMyTodayNotifications",{request:{inboxOwner:u8.session.identity.repId}},function(e,t){if(t.error){}else{i.items=t.response.allMyTodayNotifications;i.raise("Update",{reason:"load"});var n=i.items;if(n&&n.length&&typeof n[0]!="object"){var o=0;n=n.map(function(i){return{key:o++,text:i.toString()}})}if(i._slider){i._slider.setItems(n)}}})}},executeAction:function(i){u8.services.actions.execute(i)},canExecuteAction:function(i){return!this.disabled&&!!i},canCreateSlider:function(){return true},dispose:function(){},set:function(i,e){var t=this.get(i);this[i]=e;if(t!==e){this.raise("Update",{propertyName:propertyName,value:e})}},get:function(i){return this[i]},_create:function(){u8.tools.created(this)},_onSliderDblClick:function(i,e){if(i==null||i.items==null||i.items.length==0){return}var t=i.getValue();if(t<=0){return}var n=i.items.find(function(i){return i.notificationId===t});if(n==null){return}var o=new Array;n.changedFields.forEach(function(i){o.push({FieldChangeId:i.fieldChangeId,FieldDefinitionId:i.fieldDefinitionId,FieldDefinitionName:i.fieldDefinitionName,FieldDefinitionType:i.fieldDefinitionType,UpdatedValue:i.updatedValue,OldValue:i.oldValue})});var a=u8.application.getWorkWindow();u8.using({texts:[],types:["ViewChangeNotificationPopup"]},function(){var i=new u8.Crm.Widgets.ViewChangeNotificationPopup(a,{parent:page});i.open({AuthorFullName:n.authorFullName,AuthorId:n.authorId,AuthorUsername:n.authorUsername,ChangedFields:o,DateOfChange:n.dateOfChange,IsRead:n.isRead,NotificationId:n.notificationId,NotificationSubscription:{CreatedBy:n.notificationSubscription.createdBy,CreatedByEmail:n.notificationSubscription.createdByEmail,CreatedByFullName:n.notificationSubscription.createdByFullName,CreatedByUsername:n.notificationSubscription.createdByUsername,CreatedDate:n.notificationSubscription.createdDate,IsActive:n.notificationSubscription.isActive,IsDashboardNotification:n.notificationSubscription.isDashboardNotification,IsEmailNotification:n.notificationSubscription.isEmailNotification,IsPopupNotification:n.notificationSubscription.isPopupNotification,IsRecordOnlyNotification:n.notificationSubscription.isRecordOnlyNotification,NotifyOnOption:n.notificationSubscription.notifyOnOption,WatchlistSubscriptionId:n.notificationSubscription.watchlistSubscriptionId,WatchedItemIdentifier:n.notificationSubscription.watchedItemIdentifier,WatchedItemType:n.notificationSubscription.watchedItemType}})})}});u8.Base.Widgets.LiveTileChangeNotificationsProvider.makeClass({name:"LiveTileChangeNotificationsProvider",events:["Update","Create"]})})();