forked from codeislifes/svas-maximum-slider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SwiperSliderPluginProcessor.cs
127 lines (115 loc) · 4.74 KB
/
SwiperSliderPluginProcessor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Routing;
using Nop.Core;
using Nop.Services.Cms;
using Nop.Services.Configuration;
using Nop.Services.Localization;
using Nop.Services.Plugins;
using Nop.Web.Framework;
using Nop.Web.Framework.Infrastructure;
using Nop.Web.Framework.Menu;
namespace Nop.Plugin.Widgets.SwiperSlider
{
// Hello
public class SwiperSliderPluginProcessor : BasePlugin, IWidgetPlugin, IAdminMenuPlugin
{
#region Fields
private readonly IWebHelper _webHelper;
private readonly ISettingService _settingService;
private readonly ILocalizationService _localizationService;
#endregion
#region Ctor
public SwiperSliderPluginProcessor(
IWebHelper webHelper,
ISettingService settingService,
ILocalizationService localizationService)
{
_webHelper = webHelper;
_settingService = settingService;
_localizationService = localizationService;
}
#endregion
#region BasePlugin Overrides
public override async Task InstallAsync()
{
var settings = new SwiperSliderSettings
{
ContainerCssSelector = ".swiper-container",
PaginationCssSelector = ".swiper-pagination",
NavigationNextCssSelector = ".swiper-button-next",
NavigationPrevCssSelector = ".swiper-button-prev",
ScrollBarCssSelector = ".swiper-scrollbar",
Direction = Direction.Horizontal,
InitialSlide = 0,
Speed = 300,
Loop = true,
NavigationEnabled = true,
PaginationEnabled = true,
ScrollBarEnabled = false
};
await _settingService.SaveSettingAsync(settings);
}
public override async Task UninstallAsync()
{
await _settingService.DeleteSettingAsync<SwiperSliderSettings>();
await _localizationService.DeleteLocaleResourcesAsync("Nop.Plugin.Widgets.SwiperSlider");
}
public override string GetConfigurationPageUrl()
{
return $"{_webHelper.GetStoreLocation()}Admin/SwiperSlider/Configure";
}
#endregion
#region IWidgetPlugin
public async Task<IList<string>> GetWidgetZonesAsync()
{
return await Task.FromResult(new List<string> { PublicWidgetZones.HomepageTop, PublicWidgetZones.ProductDetailsTop });
}
public string GetWidgetViewComponent(string widgetZone)
{
return typeof(SwiperSliderViewComponent);
}
public Task ManageSiteMapAsync(SiteMapNode rootNode)
{
var menuItem = new SiteMapNode()
{
SystemName = "Nop.Plugin.Widgets.SwiperSlider.Root",
Title = _localizationService.GetResourceAsync("Nop.Plugin.Widgets.SwiperSlider.Admin.Menu.Root").Result,
IconClass = "far fa-dot-circle",
Visible = true,
ChildNodes = new List<SiteMapNode>()
{
new SiteMapNode()
{
SystemName = "Nop.Plugin.Widgets.SwiperSlider.Configuration",
Title = _localizationService.GetResourceAsync("Nop.Plugin.Widgets.SwiperSlider.Admin.Menu.Root.Configuration").Result,
ControllerName = "SwiperSlider",
ActionName = "Configure",
IconClass = "far fa-dot-circle",
Visible = true,
RouteValues = new RouteValueDictionary() { { "area", AreaNames.Admin } },
},
new SiteMapNode()
{
SystemName = "Nop.Plugin.Widgets.SwiperSlider.List",
Title = _localizationService.GetResourceAsync("Nop.Plugin.Widgets.SwiperSlider.Admin.Menu.Root.List").Result,
ControllerName = "SwiperSlider",
ActionName = "List",
IconClass = "far fa-dot-circle",
Visible = true,
RouteValues = new RouteValueDictionary() { { "area", AreaNames.Admin } },
}
}
};
var pluginNode = rootNode.ChildNodes.FirstOrDefault(x => x.SystemName == "Third party plugins");
if (pluginNode != null)
pluginNode.ChildNodes.Add(menuItem);
else
rootNode.ChildNodes.Add(menuItem);
return Task.CompletedTask;
}
public bool HideInWidgetList => false;
#endregion
}
}