Error executing template "Designs/Rapido/_parsed/ContentPage.parsed.cshtml"
System.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - An existing connection was forcibly closed by the remote host.) ---> System.ComponentModel.Win32Exception (0x80004005): An existing connection was forcibly closed by the remote host
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at Dynamicweb.Data.DatabaseConnectionProvider.CreateConnection(Boolean open)
at Dynamicweb.Data.Database.CreateConnection()
at Dynamicweb.Data.Database.CreateDataReader(CommandBuilder commandBuilder, IDbConnection connection, IDbTransaction transaction, Int32 commandTimeout)
at Dynamicweb.Ecommerce.Products.ProductRepository.GetProductsCountByGroups(IEnumerable`1 groupIds, Boolean countOnlyActive, String searchValue, String productLanguageId, Boolean includeVariants, Boolean doRefactoring, Boolean searchInAllFields)
at Dynamicweb.Ecommerce.Products.Group.<GetProductsCountByGroups>d__191.MoveNext()
at Dynamicweb.Ecommerce.Frontend.NavigationProviders.GroupNavigationProvider.SetProductCountOnGroups(Dictionary`2 groupNavigationItemMap)
at Dynamicweb.Frontend.XmlNavigation.MakeXml(Int32 parentId, Int32 levelStart, Int32 levelStop, Expand expand, Int32 selectedAreaId)
at Dynamicweb.Frontend.XmlNavigation.GetNavigationHtml(Int32 parentId, Int32 levelStart, Int32 levelStop, Expand expand, String name, String xsltPath, Int32 selectedAreaId, Boolean sitemapMode, NameValueCollection settings, NameValueCollection attributes, IncludeMode mode)
at Dynamicweb.Frontend.XmlNavigation.GetNavigationHtml(NameValueCollection settings, NameValueCollection attributes)
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<RenderDesktopMenu>b__114_0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 4787
at RazorEngine.Templating.TemplateWriter.ToString()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<>c__DisplayClass3_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 254
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<>c__DisplayClass2_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 192
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<RenderDesktopNavigation>b__139_0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 5876
at RazorEngine.Templating.TemplateWriter.ToString()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<>c__DisplayClass3_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 254
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<>c__DisplayClass2_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 164
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<RenderMasterHeader>b__204_0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 8462
at RazorEngine.Templating.TemplateWriter.ToString()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<>c__DisplayClass3_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 254
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<>c__DisplayClass2_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 164
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<RenderMain>b__205_0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 8471
at RazorEngine.Templating.TemplateWriter.ToString()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<>c__DisplayClass3_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 254
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<>c__DisplayClass2_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 164
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<>c__DisplayClass3_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 287
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<>c__DisplayClass2_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 164
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<RenderMasterBody>b__203_0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 8451
at RazorEngine.Templating.TemplateWriter.ToString()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<>c__DisplayClass3_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 254
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<>c__DisplayClass2_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 164
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<>c__DisplayClass3_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 287
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.<>c__DisplayClass2_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 164
at CompiledRazorTemplates.Dynamic.RazorEngine_be474f6a2ee744188e2c3e5c6c36642a.Execute() in D:\dynamicweb.net\Solutions\Buchs\gobo2021.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\ContentPage.parsed.cshtml:line 8064
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
ClientConnectionId:9bb7166c-af2c-4601-9d0d-a35a978b7eb9
Error Number:10054,State:0,Class:20
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
2
3 @using System.Web;
4 @using Dynamicweb
5 @using Dynamicweb.Frontend
6 @using Dynamicweb.Frontend.Devices
7 @using Dynamicweb.Extensibility
8 @using Dynamicweb.Content
9 @using Dynamicweb.Security
10 @using Dynamicweb.Core
11 @using System
12 @using System.Web
13 @using System.IO
14 @using Dynamicweb.Rapido.Blocks
15 @using System.Net
16
17
18 @functions {
19 BlocksPage masterPage = BlocksPage.GetBlockPage("Master");
20
21 string getFontFamily(params string[] items)
22 {
23 var itemParent = Pageview.AreaSettings;
24 foreach (var item in items)
25 {
26 itemParent = itemParent.GetItem(item);
27 if (itemParent == null)
28 {
29 return null;
30 }
31 }
32
33 var googleFont = itemParent.GetGoogleFont("FontFamily");
34 if (googleFont == null)
35 {
36 return null;
37 }
38 return googleFont.Family.Replace(" ", "+");
39 }
40 }
41
42 @{
43 Block root = new Block
44 {
45 Id = "Root",
46 SortId = 10,
47 BlocksList = new List<Block>
48 {
49 new Block {
50 Id = "Head",
51 SortId = 10,
52 SkipRenderBlocksList = true,
53 Template = RenderMasterHead(),
54 BlocksList = new List<Block>
55 {
56 new Block {
57 Id = "HeadMetadata",
58 SortId = 10,
59 Template = RenderMasterMetadata(),
60 },
61 new Block {
62 Id = "HeadCss",
63 SortId = 20,
64 Template = RenderMasterCss(),
65 },
66 new Block {
67 Id = "HeadManifest",
68 SortId = 30,
69 Template = RenderMasterManifest(),
70 }
71 }
72 },
73 new Block {
74 Id = "Body",
75 SortId = 20,
76 SkipRenderBlocksList = true,
77 Template = RenderMasterBody(),
78 BlocksList = new List<Block>
79 {
80 new Block()
81 {
82 Id = "Master",
83 SortId = 10,
84 BlocksList = new List<Block> {
85 new Block {
86 Id = "MasterTopSnippets",
87 SortId = 10
88 },
89 new Block {
90 Id = "MasterMain",
91 SortId = 20,
92 Template = RenderMain(),
93 SkipRenderBlocksList = true,
94 BlocksList = new List<Block> {
95 new Block {
96 Id = "MasterHeader",
97 SortId = 10,
98 Template = RenderMasterHeader(),
99 SkipRenderBlocksList = true
100 },
101 new Block {
102 Id = "MasterPageContent",
103 SortId = 20,
104 Template = RenderPageContent()
105 }
106 }
107 },
108 new Block {
109 Id = "MasterFooter",
110 SortId = 30
111 },
112 new Block {
113 Id = "MasterReferences",
114 SortId = 40
115 },
116 new Block {
117 Id = "MasterBottomSnippets",
118 SortId = 50,
119 BlocksList = new List<Block> {
120 new Block {
121 Id = "iOsTabletFix",
122 SortId = 10,
123 Template = RenderIosTabletFix()
124 }
125 }
126 }
127 }
128 }
129 }
130 }
131 }
132 };
133
134 masterPage.Add(root);
135 }
136
137 @* Include the required Grid builder (Contains the methods @RenderBlockList and @RenderBlock) *@
138 @using System.Text.RegularExpressions
139 @using System.Collections.Generic
140 @using System.Reflection
141 @using System.Web
142 @using System.Web.UI.HtmlControls
143 @using Dynamicweb.Rapido.Blocks.Components
144 @using Dynamicweb.Rapido.Blocks.Components.Articles
145 @using Dynamicweb.Rapido.Blocks.Components.Documentation
146 @using Dynamicweb.Rapido.Blocks
147
148
149 @*--- START: Base block renderers ---*@
150
151 @helper RenderBlockList(List<Block> blocks)
152 {
153 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false;
154 blocks = blocks.OrderBy(item => item.SortId).ToList();
155
156 foreach (Block item in blocks)
157 {
158 if (debug) {
159 <!-- Block START: @item.Id -->
160 }
161
162 if (item.Design == null)
163 {
164 @RenderBlock(item)
165 }
166 else if (item.Design.RenderType == RenderType.None) {
167 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : "";
168
169 <div class="@cssClass dw-mod">
170 @RenderBlock(item)
171 </div>
172 }
173 else if (item.Design.RenderType != RenderType.Hide)
174 {
175 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : "";
176
177 if (!item.SkipRenderBlocksList) {
178 if (item.Design.RenderType == RenderType.Row)
179 {
180 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id">
181 @RenderBlock(item)
182 </div>
183 }
184
185 if (item.Design.RenderType == RenderType.Column)
186 {
187 string hidePadding = item.Design.HidePadding ? "u-no-padding" : "";
188 string size = item.Design.Size ?? "12";
189 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size;
190
191 <div class="grid__col-lg-@item.Design.Size grid__col-md-@item.Design.Size grid__col-sm-12 grid__col-xs-12 @hidePadding @cssClass dw-mod" id="Block__@item.Id">
192 @RenderBlock(item)
193 </div>
194 }
195
196 if (item.Design.RenderType == RenderType.Table)
197 {
198 <table class="table @cssClass dw-mod" id="Block__@item.Id">
199 @RenderBlock(item)
200 </table>
201 }
202
203 if (item.Design.RenderType == RenderType.TableRow)
204 {
205 <tr class="@cssClass dw-mod" id="Block__@item.Id">
206 @RenderBlock(item)
207 </tr>
208 }
209
210 if (item.Design.RenderType == RenderType.TableColumn)
211 {
212 <td class="@cssClass dw-mod" id="Block__@item.Id">
213 @RenderBlock(item)
214 </td>
215 }
216
217 if (item.Design.RenderType == RenderType.CardHeader)
218 {
219 <div class="card-header @cssClass dw-mod">
220 @RenderBlock(item)
221 </div>
222 }
223
224 if (item.Design.RenderType == RenderType.CardBody)
225 {
226 <div class="card @cssClass dw-mod">
227 @RenderBlock(item)
228 </div>
229 }
230
231 if (item.Design.RenderType == RenderType.CardFooter)
232 {
233 <div class="card-footer @cssClass dw-mod">
234 @RenderBlock(item)
235 </div>
236 }
237 }
238 else
239 {
240 @RenderBlock(item)
241 }
242 }
243
244 if (debug) {
245 <!-- Block END: @item.Id -->
246 }
247 }
248 }
249
250 @helper RenderBlock(Block item)
251 {
252 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false;
253
254 if (item.Template != null)
255 {
256 @BlocksPage.RenderTemplate(item.Template)
257 }
258
259 if (item.Component != null)
260 {
261 string customSufix = "Custom";
262 string methodName = item.Component.HelperName;
263
264 ComponentBase[] methodParameters = new ComponentBase[1];
265 methodParameters[0] = item.Component;
266 Type methodType = this.GetType();
267
268 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix);
269 MethodInfo generalMethod = methodType.GetMethod(methodName);
270
271 try {
272 if (debug) {
273 <!-- Component: @methodName.Replace("Render", "") -->
274 }
275 @customMethod.Invoke(this, methodParameters).ToString();
276 } catch {
277 try {
278 @generalMethod.Invoke(this, methodParameters).ToString();
279 } catch(Exception ex) {
280 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex);
281 }
282 }
283 }
284
285 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList)
286 {
287 @RenderBlockList(item.BlocksList)
288 }
289 }
290
291 @*--- END: Base block renderers ---*@
292
293
294 @* Include the components *@
295 @using Dynamicweb.Rapido.Blocks.Components
296 @using Dynamicweb.Rapido.Blocks.Components.General
297 @using Dynamicweb.Rapido.Blocks
298 @using System.IO
299
300 @* Required *@
301 @using Dynamicweb.Rapido.Blocks.Components
302 @using Dynamicweb.Rapido.Blocks.Components.General
303 @using Dynamicweb.Rapido.Blocks
304
305
306 @helper Render(ComponentBase component)
307 {
308 if (component != null)
309 {
310 @component.Render(this)
311 }
312 }
313
314 @* Components *@
315 @using System.Reflection
316 @using Dynamicweb.Rapido.Blocks.Components.General
317
318
319 @* Component *@
320
321 @helper RenderIcon(Icon settings)
322 {
323 if (settings != null)
324 {
325 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : "";
326
327 if (settings.Name != null)
328 {
329 if (string.IsNullOrEmpty(settings.Label))
330 {
331 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i>
332 }
333 else
334 {
335 if (settings.LabelPosition == IconLabelPosition.Before)
336 {
337 <div class="u-flex u-flex--align-items-center @settings.CssClass">@settings.Label <i class="@settings.Prefix @settings.Name u-margin-left" @color></i></div>
338 }
339 else
340 {
341 <div class="u-flex u-flex--align-items-center @settings.CssClass"><i class="@settings.Prefix @settings.Name u-margin-right--lg u-w20px" @color></i>@settings.Label</div>
342 }
343 }
344 }
345 else if (!string.IsNullOrEmpty(settings.Label))
346 {
347 @settings.Label
348 }
349 }
350 }
351 @using System.Reflection
352 @using Dynamicweb.Rapido.Blocks.Components.General
353 @using Dynamicweb.Rapido.Blocks.Components
354 @using Dynamicweb.Core
355
356 @* Component *@
357
358 @helper RenderButton(Button settings)
359 {
360 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null))
361 {
362 Dictionary<string, string> attributes = new Dictionary<string, string>();
363 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>();
364 if (settings.Disabled) {
365 attributes.Add("disabled", "true");
366 classList.Add("disabled");
367 }
368
369 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle))
370 {
371 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N");
372 @RenderConfirmDialog(settings);
373 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true";
374 }
375
376 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); }
377 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); }
378 if (!string.IsNullOrEmpty(settings.AltText))
379 {
380 attributes.Add("title", settings.AltText);
381 }
382 else if (!string.IsNullOrEmpty(settings.Title))
383 {
384 string cleanTitle = Regex.Replace(settings.Title, "<.*?>", String.Empty);
385 cleanTitle = cleanTitle.Replace(" ", " ");
386 attributes.Add("title", cleanTitle);
387 }
388
389 var onClickEvents = new List<string>();
390 if (!string.IsNullOrEmpty(settings.OnClick))
391 {
392 onClickEvents.Add(settings.OnClick);
393 }
394 if (!string.IsNullOrEmpty(settings.Href))
395 {
396 onClickEvents.Add("location.href='" + settings.Href + "'");
397 }
398 if (onClickEvents.Count > 0)
399 {
400 attributes.Add("onClick", string.Join(";", onClickEvents));
401 }
402
403 if (settings.ButtonLayout != ButtonLayout.None)
404 {
405 classList.Add("btn");
406 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower();
407 if (btnLayout == "linkclean")
408 {
409 btnLayout = "link-clean"; //fix
410 }
411 classList.Add("btn--" + btnLayout);
412 }
413
414 if (settings.Icon == null)
415 {
416 settings.Icon = new Icon();
417 }
418
419 settings.Icon.CssClass += Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower() != "linkclean" ? " u-flex--align-center" : "";
420 settings.Icon.Label = settings.Title;
421
422 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower());
423
424 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button>
425 }
426 }
427
428 @helper RenderConfirmDialog(Button settings)
429 {
430 Modal confirmDialog = new Modal {
431 Id = settings.Id,
432 Width = ModalWidth.Sm,
433 Heading = new Heading
434 {
435 Level = 2,
436 Title = settings.ConfirmTitle
437 },
438 BodyText = settings.ConfirmText
439 };
440
441 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"});
442 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick });
443
444 @Render(confirmDialog)
445 }
446 @using Dynamicweb.Rapido.Blocks.Components.General
447 @using Dynamicweb.Rapido.Blocks.Components
448 @using Dynamicweb.Core
449
450 @helper RenderDashboard(Dashboard settings)
451 {
452 var widgets = settings.GetWidgets();
453
454 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor))
455 {
456 //set bg color for them
457
458 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor);
459 int r = Convert.ToInt16(color.R);
460 int g = Convert.ToInt16(color.G);
461 int b = Convert.ToInt16(color.B);
462
463 var count = widgets.Length;
464 var max = Math.Max(r, Math.Max(g, b));
465 double step = 255.0 / (max * count);
466 var i = 0;
467 foreach (var widget in widgets)
468 {
469 i++;
470
471 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")";
472 widget.BackgroundColor = shade;
473 }
474 }
475
476 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)>
477 @foreach (var widget in widgets)
478 {
479 <div class="dashboard__widget">
480 @Render(widget)
481 </div>
482 }
483 </div>
484 }
485 @using Dynamicweb.Rapido.Blocks.Components.General
486 @using Dynamicweb.Rapido.Blocks.Components
487
488 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings)
489 {
490 if (!string.IsNullOrEmpty(settings.Link))
491 {
492 var backgroundStyles = "";
493 if (!string.IsNullOrEmpty(settings.BackgroundColor))
494 {
495 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\"";
496 }
497
498 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)>
499 <div class="u-center-middle u-color-light">
500 @if (settings.Icon != null)
501 {
502 settings.Icon.CssClass += "widget__icon";
503 @Render(settings.Icon)
504 }
505 <div class="widget__title">@settings.Title</div>
506 </div>
507 </a>
508 }
509 }
510 @using Dynamicweb.Rapido.Blocks.Components.General
511 @using Dynamicweb.Rapido.Blocks.Components
512
513 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings)
514 {
515 var backgroundStyles = "";
516 if (!string.IsNullOrEmpty(settings.BackgroundColor))
517 {
518 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'";
519 }
520
521 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)>
522 <div class="u-center-middle u-color-light">
523 @if (settings.Icon != null)
524 {
525 settings.Icon.CssClass += "widget__icon";
526 @Render(settings.Icon)
527 }
528 <div class="widget__counter">@settings.Count</div>
529 <div class="widget__title">@settings.Title</div>
530 </div>
531 </div>
532 }
533 @using System.Reflection
534 @using Dynamicweb.Rapido.Blocks.Components.General
535 @using Dynamicweb.Rapido.Blocks.Components
536 @using Dynamicweb.Core
537
538 @* Component *@
539
540 @helper RenderLink(Link settings)
541 {
542 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null))
543 {
544 Dictionary<string, string> attributes = new Dictionary<string, string>();
545 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>();
546 if (settings.Disabled)
547 {
548 attributes.Add("disabled", "true");
549 classList.Add("disabled");
550 }
551
552 if (!string.IsNullOrEmpty(settings.AltText))
553 {
554 attributes.Add("title", settings.AltText);
555 }
556 else if (!string.IsNullOrEmpty(settings.Title))
557 {
558 attributes.Add("title", settings.Title);
559 }
560
561 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); }
562 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); }
563 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); }
564 attributes.Add("href", settings.Href);
565
566 if (settings.ButtonLayout != ButtonLayout.None)
567 {
568 classList.Add("btn");
569 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower();
570 if (btnLayout == "linkclean")
571 {
572 btnLayout = "link-clean"; //fix
573 }
574 classList.Add("btn--" + btnLayout);
575 }
576
577 if (settings.Icon == null)
578 {
579 settings.Icon = new Icon();
580 }
581 settings.Icon.Label = settings.Title;
582
583 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None)
584 {
585 settings.Rel = LinkRelType.Noopener;
586 }
587 if (settings.Target != LinkTargetType.None)
588 {
589 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower());
590 }
591 if (settings.Download)
592 {
593 attributes.Add("download", "true");
594 }
595 if (settings.Rel != LinkRelType.None)
596 {
597 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower());
598 }
599
600 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a>
601 }
602 }
603 @using System.Reflection
604 @using Dynamicweb.Rapido.Blocks.Components
605 @using Dynamicweb.Rapido.Blocks.Components.General
606 @using Dynamicweb.Rapido.Blocks
607
608
609 @* Component *@
610
611 @helper RenderRating(Rating settings)
612 {
613 if (settings.Score > 0)
614 {
615 int rating = settings.Score;
616 string iconType = "fa-star";
617
618 switch (settings.Type.ToString()) {
619 case "Stars":
620 iconType = "fa-star";
621 break;
622 case "Hearts":
623 iconType = "fa-heart";
624 break;
625 case "Lemons":
626 iconType = "fa-lemon";
627 break;
628 case "Bombs":
629 iconType = "fa-bomb";
630 break;
631 }
632
633 <div class="u-ta-right">
634 @for (int i = 0; i < settings.OutOf; i++)
635 {
636 <i class="@(rating > i ? "fas" : "far") @iconType"></i>
637 }
638 </div>
639 }
640 }
641 @using System.Reflection
642 @using Dynamicweb.Rapido.Blocks.Components.General
643 @using Dynamicweb.Rapido.Blocks.Components
644
645
646 @* Component *@
647
648 @helper RenderSelectFieldOption(SelectFieldOption settings)
649 {
650 Dictionary<string, string> attributes = new Dictionary<string, string>();
651 if (settings.Checked) { attributes.Add("selected", "true"); }
652 if (settings.Disabled) { attributes.Add("disabled", "true"); }
653 if (settings.Value != null) { attributes.Add("value", settings.Value); }
654 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); }
655
656 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option>
657 }
658 @using System.Reflection
659 @using Dynamicweb.Rapido.Blocks.Components.General
660 @using Dynamicweb.Rapido.Blocks.Components
661
662
663 @* Component *@
664
665 @helper RenderNavigation(Navigation settings) {
666 @RenderNavigation(new
667 {
668 id = settings.Id,
669 cssclass = settings.CssClass,
670 startLevel = settings.StartLevel,
671 endlevel = settings.EndLevel,
672 expandmode = settings.Expandmode,
673 sitemapmode = settings.SitemapMode,
674 template = settings.Template
675 })
676 }
677 @using Dynamicweb.Rapido.Blocks.Components.General
678 @using Dynamicweb.Rapido.Blocks.Components
679
680
681 @* Component *@
682
683 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) {
684 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id;
685 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template;
686 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel;
687 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel;
688 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode;
689 settings.SitemapMode = false;
690
691 @RenderNavigation(settings)
692 }
693 @using Dynamicweb.Rapido.Blocks.Components.General
694 @using Dynamicweb.Rapido.Blocks.Components
695
696
697 @* Component *@
698
699 @helper RenderLeftNavigation(LeftNavigation settings) {
700 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id;
701 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template;
702 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel;
703 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel;
704 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode;
705
706 <div class="grid__cell">
707 @RenderNavigation(settings)
708 </div>
709 }
710 @using System.Reflection
711 @using Dynamicweb.Rapido.Blocks.Components.General
712 @using Dynamicweb.Core
713
714 @* Component *@
715
716 @helper RenderHeading(Heading settings)
717 {
718 if (settings != null && !string.IsNullOrEmpty(settings.Title))
719 {
720 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : "";
721 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div";
722
723 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">")
724 if (!string.IsNullOrEmpty(settings.Link))
725 {
726 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None })
727 }
728 else
729 {
730 if (settings.Icon == null)
731 {
732 settings.Icon = new Icon();
733 }
734 settings.Icon.Label = settings.Title;
735 @Render(settings.Icon)
736 }
737 @("</" + tagName + ">");
738 }
739 }
740 @using Dynamicweb.Rapido.Blocks.Components
741 @using Dynamicweb.Rapido.Blocks.Components.General
742 @using Dynamicweb.Rapido.Blocks
743
744
745 @* Component *@
746
747 @helper RenderImage(Image settings)
748 {
749 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None)
750 {
751 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>();
752 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); }
753
754 if (settings.Caption != null)
755 {
756 @:<div>
757 }
758
759 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower();
760 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower();
761
762 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)>
763 <div class="image-filter image-filter--@secondaryFilterClass dw-mod">
764 @if (settings.Link != null)
765 {
766 var linkTarget = settings.ExtraAttributes?.ContainsKey("LinkTarget") == true ? settings.ExtraAttributes["LinkTarget"] : string.Empty;
767
768 if (!string.IsNullOrWhiteSpace(linkTarget)) {
769 settings.ExtraAttributes.Remove("LinkTarget");
770 }
771
772 <a href="@settings.Link" target="@(linkTarget)">
773 @RenderTheImage(settings)
774 </a>
775 }
776 else
777 {
778 @RenderTheImage(settings)
779 }
780 </div>
781 </div>
782
783 if (settings.Caption != null)
784 {
785 <span class="image-caption dw-mod">@settings.Caption</span>
786 @:</div>
787 }
788 }
789 else
790 {
791 if (settings.Caption != null)
792 {
793 @:<div>
794 }
795 if (!string.IsNullOrEmpty(settings.Link))
796 {
797 var linkTarget = settings.ExtraAttributes?.ContainsKey("LinkTarget") == true ? settings.ExtraAttributes["LinkTarget"] : string.Empty;
798
799 if (!string.IsNullOrWhiteSpace(linkTarget)) {
800 settings.ExtraAttributes.Remove("LinkTarget");
801 }
802
803 <a href="@settings.Link" target="@(linkTarget)">
804 @RenderTheImage(settings)
805 </a>
806 }
807 else
808 {
809 @RenderTheImage(settings)
810 }
811
812 if (settings.Caption != null)
813 {
814 <span class="image-caption dw-mod">@settings.Caption</span>
815 @:</div>
816 }
817 }
818 }
819
820 @helper RenderTheImage(Image settings)
821 {
822 if (settings != null)
823 {
824 string alternativeImage = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("AlternativeImage")) ? Pageview.AreaSettings.GetItem("Settings").GetFile("AlternativeImage").PathUrlEncoded : "/Images/missing_image.jpg";
825 string placeholderImage = "/Files/Images/placeholder.gif";
826 string imageEngine = "/Admin/Public/GetImage.ashx?";
827
828 string imageStyle = "";
829
830 switch (settings.Style)
831 {
832 case ImageStyle.Ball:
833 imageStyle = "grid__cell-img--ball";
834 break;
835
836 case ImageStyle.Triangle:
837 imageStyle = "grid__cell-img--triangle";
838 break;
839 }
840
841 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle || settings.Style == ImageStyle.Triangle)
842 {
843 settings.ImageDefault.Crop = settings.ImageDefault.Crop == 5 ? settings.ImageDefault.Crop = 0 : settings.ImageDefault.Crop;
844
845 if (settings.ImageDefault != null)
846 {
847 settings.ImageDefault.Height = settings.ImageDefault.Width;
848 }
849 if (settings.ImageMedium != null)
850 {
851 settings.ImageMedium.Height = settings.ImageMedium.Width;
852 }
853 if (settings.ImageSmall != null)
854 {
855 settings.ImageSmall.Height = settings.ImageSmall.Width;
856 }
857 }
858
859 string defaultImage = imageEngine;
860 string imageSmall = "";
861 string imageMedium = "";
862
863 if (settings.DisableImageEngine)
864 {
865 defaultImage = settings.Path;
866 }
867 else
868 {
869 if (settings.ImageDefault != null)
870 {
871 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault);
872
873 if (settings.Path.GetType() != typeof(string))
874 {
875 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : "";
876 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : "";
877 }
878 else
879 {
880 defaultImage += settings.Path != null ? "Image=" + settings.Path : "";
881 }
882
883 defaultImage += "&AlternativeImage=" + alternativeImage;
884 }
885
886 if (settings.ImageSmall != null)
887 {
888 imageSmall = "data-src-small=\"" + imageEngine;
889 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall);
890
891 if (settings.Path.GetType() != typeof(string))
892 {
893 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : "";
894 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : "";
895 }
896 else
897 {
898 imageSmall += settings.Path != null ? "Image=" + settings.Path : "";
899 }
900
901 imageSmall += "&alternativeImage=" + alternativeImage;
902
903 imageSmall += "\"";
904 }
905
906 if (settings.ImageMedium != null)
907 {
908 imageMedium = "data-src-medium=\"" + imageEngine;
909 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium);
910
911 if (settings.Path.GetType() != typeof(string))
912 {
913 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : "";
914 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : "";
915 }
916 else
917 {
918 imageMedium += settings.Path != null ? "Image=" + settings.Path : "";
919 }
920
921 imageMedium += "&alternativeImage=" + alternativeImage;
922
923 imageMedium += "\"";
924 }
925 }
926
927 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>();
928 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); }
929 if (!string.IsNullOrEmpty(settings.Title))
930 {
931 optionalAttributes.Add("alt", settings.Title);
932 optionalAttributes.Add("title", settings.Title);
933 }
934
935 if (settings.DisableLazyLoad)
936 {
937 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) />
938 }
939 else
940 {
941 <img id="@settings.Id" class="b-lazy @imageStyle @settings.CssClass dw-mod" src="@placeholderImage" data-src="@defaultImage" @imageSmall @imageMedium @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) />
942 }
943 }
944 }
945 @using System.Reflection
946 @using Dynamicweb.Rapido.Blocks.Components.General
947 @using Dynamicweb.Rapido.Blocks.Components
948
949 @* Component *@
950
951 @helper RenderFileField(FileField settings)
952 {
953 var attributes = new Dictionary<string, string>();
954 if (string.IsNullOrEmpty(settings.Id))
955 {
956 settings.Id = Guid.NewGuid().ToString("N");
957 }
958
959 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); }
960 if (settings.Disabled) { attributes.Add("disabled", "true"); }
961 if (settings.Required) { attributes.Add("required", "true"); }
962 if (settings.Multiple) { attributes.Add("multiple", "true"); }
963 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); }
964 if (string.IsNullOrEmpty(settings.ChooseFileText))
965 {
966 settings.ChooseFileText = Translate("Choose file");
967 }
968 if (string.IsNullOrEmpty(settings.NoFilesChosenText))
969 {
970 settings.NoFilesChosenText = Translate("No files chosen...");
971 }
972 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); }
973
974 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; }
975
976 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)";
977 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : ""));
978
979 attributes.Add("type", "file");
980 if (settings.Value != null) { attributes.Add("value", settings.Value); }
981 settings.CssClass = "u-full-width " + settings.CssClass;
982
983 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value);
984
985 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod">
986 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null )
987 {
988 <div class="u-full-width">
989 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> }
990 @if (settings.Link != null) {
991 <div class="u-pull--right">
992 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; }
993 @Render(settings.Link)
994 </div>
995 }
996 </div>
997
998 }
999
1000 @if (!string.IsNullOrEmpty(settings.HelpText))
1001 {
1002 <small class="form__help-text">@settings.HelpText</small>
1003 }
1004
1005 <div class="form__field-combi file-input u-no-margin dw-mod">
1006 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" />
1007 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label>
1008 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label>
1009 @if (settings.UploadButton != null)
1010 {
1011 settings.UploadButton.CssClass += " btn--condensed u-no-margin";
1012 @Render(settings.UploadButton)
1013 }
1014 </div>
1015 @Render(new NotificationMessage { Message = settings.ErrorMessage })
1016 </div>
1017 }
1018 @using System.Reflection
1019 @using Dynamicweb.Rapido.Blocks.Components.General
1020 @using Dynamicweb.Rapido.Blocks.Components
1021 @using Dynamicweb.Core
1022 @using System.Linq
1023
1024 @* Component *@
1025
1026 @helper RenderDateTimeField(DateTimeField settings)
1027 {
1028 if (string.IsNullOrEmpty(settings.Id))
1029 {
1030 settings.Id = Guid.NewGuid().ToString("N");
1031 }
1032
1033 var textField = new TextField {
1034 Name = settings.Name,
1035 Id = settings.Id,
1036 Label = settings.Label,
1037 HelpText = settings.HelpText,
1038 Value = settings.Value,
1039 Disabled = settings.Disabled,
1040 Required = settings.Required,
1041 ErrorMessage = settings.ErrorMessage,
1042 CssClass = settings.CssClass,
1043 WrapperCssClass = settings.WrapperCssClass,
1044 OnChange = settings.OnChange,
1045 OnClick = settings.OnClick,
1046 Link = settings.Link,
1047 ExtraAttributes = settings.ExtraAttributes,
1048 //
1049 Placeholder = settings.Placeholder
1050 };
1051
1052 @Render(textField)
1053
1054 List<string> jsAttributes = new List<string>();
1055
1056 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'");
1057
1058 if (!string.IsNullOrEmpty(settings.DateFormat))
1059 {
1060 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'");
1061 }
1062 if (!string.IsNullOrEmpty(settings.MinDate))
1063 {
1064 jsAttributes.Add("minDate: '" + settings.MinDate + "'");
1065 }
1066 if (!string.IsNullOrEmpty(settings.MaxDate))
1067 {
1068 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'");
1069 }
1070 if (settings.IsInline)
1071 {
1072 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower());
1073 }
1074 if (settings.EnableTime)
1075 {
1076 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower());
1077 }
1078 if (settings.EnableWeekNumbers)
1079 {
1080 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower());
1081 }
1082
1083 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value));
1084
1085 <script>
1086 document.addEventListener("DOMContentLoaded", function () {
1087 flatpickr("#@textField.Id", {
1088 @string.Join(",", jsAttributes)
1089 });
1090 });
1091 </script>
1092 }
1093 @using System.Reflection
1094 @using Dynamicweb.Rapido.Blocks.Components.General
1095 @using Dynamicweb.Rapido.Blocks.Components
1096
1097 @* Component *@
1098
1099 @helper RenderTextField(TextField settings)
1100 {
1101 var attributes = new Dictionary<string, string>();
1102 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id))
1103 {
1104 settings.Id = Guid.NewGuid().ToString("N");
1105 }
1106
1107 /*base settings*/
1108 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); }
1109 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); }
1110 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); }
1111 if (settings.Disabled) { attributes.Add("disabled", "true"); }
1112 if (settings.Required) { attributes.Add("required", "true"); }
1113 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); }
1114 /*end*/
1115
1116 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); }
1117 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); }
1118 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); }
1119 if (settings.ReadOnly) { attributes.Add("readonly", "true"); }
1120 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); }
1121 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); }
1122 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower());
1123 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); };
1124 if (settings.Value != null) { attributes.Add("value", settings.Value); }
1125
1126 settings.CssClass = "u-full-width " + settings.CssClass;
1127
1128 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; }
1129
1130 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value);
1131
1132 string noMargin = "u-no-margin";
1133 if (!settings.ReadOnly) {
1134 noMargin = "";
1135 }
1136
1137 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod">
1138 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null )
1139 {
1140 <div class="u-full-width">
1141 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> }
1142 @if (settings.Link != null) {
1143 settings.Link.ButtonLayout = ButtonLayout.LinkClean;
1144
1145 <div class="u-pull--right">
1146 @Render(settings.Link)
1147 </div>
1148 }
1149 </div>
1150
1151 }
1152
1153 @if (!string.IsNullOrEmpty(settings.HelpText))
1154 {
1155 <small class="form__help-text">@settings.HelpText</small>
1156 }
1157
1158 @if (settings.ActionButton != null)
1159 {
1160 settings.ActionButton.CssClass += " btn--condensed u-no-margin";
1161 <div class="form__field-combi u-no-margin dw-mod">
1162 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" />
1163 @Render(settings.ActionButton)
1164 </div>
1165 }
1166 else
1167 {
1168 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" />
1169 }
1170
1171 @Render(new NotificationMessage { Message = settings.ErrorMessage })
1172 </div>
1173 }
1174 @using System.Reflection
1175 @using Dynamicweb.Rapido.Blocks.Components.General
1176 @using Dynamicweb.Rapido.Blocks.Components
1177
1178 @* Component *@
1179
1180 @helper RenderNumberField(NumberField settings)
1181 {
1182 var attributes = new Dictionary<string, string>();
1183 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id))
1184 {
1185 settings.Id = Guid.NewGuid().ToString("N");
1186 }
1187
1188 /*base settings*/
1189 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); }
1190 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); }
1191 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); }
1192 if (settings.Disabled) { attributes.Add("disabled", "true"); }
1193 if (settings.Required) { attributes.Add("required", "true"); }
1194 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); }
1195 /*end*/
1196
1197 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); }
1198 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); }
1199 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); }
1200 if (settings.ReadOnly) { attributes.Add("readonly", "true"); }
1201 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); }
1202 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); }
1203 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); }
1204 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); }
1205 attributes.Add("type", "number");
1206
1207 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value);
1208
1209 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod">
1210 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null )
1211 {
1212 <div class="u-full-width">
1213 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> }
1214 @if (settings.Link != null) {
1215 <div class="u-pull--right">
1216 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; }
1217 @Render(settings.Link)
1218 </div>
1219 }
1220 </div>
1221
1222 }
1223
1224 @if (!string.IsNullOrEmpty(settings.HelpText))
1225 {
1226 <small class="form__help-text">@settings.HelpText</small>
1227 }
1228
1229 @if (settings.ActionButton != null)
1230 {
1231 settings.ActionButton.CssClass += " btn--condensed u-no-margin";
1232 <div class="form__field-combi u-no-margin dw-mod">
1233 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" />
1234 @Render(settings.ActionButton)
1235 </div>
1236 }
1237 else
1238 {
1239 <div class="form__field-combi u-no-margin dw-mod">
1240 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" />
1241 </div>
1242 }
1243
1244 @Render(new NotificationMessage { Message = settings.ErrorMessage })
1245 </div>
1246 }
1247 @using System.Reflection
1248 @using Dynamicweb.Rapido.Blocks.Components.General
1249 @using Dynamicweb.Rapido.Blocks.Components
1250
1251
1252 @* Component *@
1253
1254 @helper RenderTextareaField(TextareaField settings)
1255 {
1256 Dictionary<string, string> attributes = new Dictionary<string, string>();
1257 string id = settings.Id;
1258 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id))
1259 {
1260 id = Guid.NewGuid().ToString("N");
1261 }
1262
1263 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); }
1264 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); }
1265 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); }
1266 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); }
1267 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); }
1268 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); }
1269 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); }
1270 if (settings.Disabled) { attributes.Add("disabled", "true"); }
1271 if (settings.Required) { attributes.Add("required", "true"); }
1272 if (settings.ReadOnly) { attributes.Add("readonly", "true"); }
1273 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); }
1274 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); }
1275 attributes.Add("name", settings.Name);
1276
1277 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; }
1278
1279 <div class="form__field-group @settings.WrapperCssClass dw-mod">
1280 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null )
1281 {
1282 <div class="u-full-width">
1283 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> }
1284 @if (settings.Link != null) {
1285 <div class="u-pull--right">
1286 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; }
1287 @Render(settings.Link)
1288 </div>
1289 }
1290 </div>
1291 }
1292
1293 @if (!string.IsNullOrEmpty(settings.HelpText))
1294 {
1295 <small class="form__help-text">@settings.HelpText</small>
1296 }
1297
1298 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea>
1299
1300 @Render(new NotificationMessage { Message = settings.ErrorMessage })
1301 </div>
1302 }
1303 @using System.Reflection
1304 @using Dynamicweb.Rapido.Blocks.Components.General
1305 @using Dynamicweb.Rapido.Blocks.Components
1306
1307
1308 @* Component *@
1309
1310 @helper RenderHiddenField(HiddenField settings) {
1311 var attributes = new Dictionary<string, string>();
1312 attributes.Add("type", "hidden");
1313 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); }
1314 if (settings.Value != null) { attributes.Add("value", settings.Value); }
1315 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); }
1316
1317 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/>
1318 }
1319 @using System.Reflection
1320 @using Dynamicweb.Rapido.Blocks.Components.General
1321 @using Dynamicweb.Rapido.Blocks.Components
1322
1323 @* Component *@
1324
1325 @helper RenderCheckboxField(CheckboxField settings)
1326 {
1327 var attributes = new Dictionary<string, string>();
1328 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id))
1329 {
1330 settings.Id = Guid.NewGuid().ToString("N");
1331 }
1332
1333 /*base settings*/
1334 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); }
1335 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); }
1336 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); }
1337 if (settings.Disabled) { attributes.Add("disabled", "true"); }
1338 if (settings.Required) { attributes.Add("required", "true"); }
1339 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); }
1340 /*end*/
1341
1342 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; }
1343
1344 attributes.Add("type", "checkbox");
1345 if (settings.Checked) { attributes.Add("checked", "true"); }
1346 settings.CssClass = "form__control " + settings.CssClass;
1347 if (settings.Value != null) { attributes.Add("value", settings.Value); }
1348
1349 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value);
1350
1351 <div class="form__field-group @settings.WrapperCssClass dw-mod">
1352 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" />
1353 @if (!string.IsNullOrEmpty(settings.Label))
1354 {
1355 <label for="@settings.Id" class="dw-mod">@settings.Label</label>
1356 }
1357
1358 @if (settings.Link != null) {
1359 <span>
1360 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; }
1361 @Render(settings.Link)
1362 </span>
1363 }
1364
1365 @if (!string.IsNullOrEmpty(settings.HelpText))
1366 {
1367 <small class="form__help-text checkbox-help dw-mod">@settings.HelpText</small>
1368 }
1369 @Render(new NotificationMessage { Message = settings.ErrorMessage })
1370 </div>
1371 }
1372 @using System.Reflection
1373 @using Dynamicweb.Rapido.Blocks.Components.General
1374 @using Dynamicweb.Rapido.Blocks.Components
1375
1376
1377 @* Component *@
1378
1379 @helper RenderCheckboxListField(CheckboxListField settings)
1380 {
1381 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)>
1382 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null )
1383 {
1384 <div class="u-full-width">
1385 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> }
1386 @if (settings.Link != null) {
1387 <div class="u-pull--right">
1388 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; }
1389 @Render(settings.Link)
1390 </div>
1391 }
1392 </div>
1393
1394 }
1395
1396 <div class="u-pull--left">
1397 @if (!string.IsNullOrEmpty(settings.HelpText))
1398 {
1399 <small class="form__help-text">@settings.HelpText</small>
1400 }
1401
1402 @foreach (var item in settings.Options)
1403 {
1404 if (settings.Required)
1405 {
1406 item.Required = true;
1407 }
1408 if (settings.Disabled)
1409 {
1410 item.Disabled = true;
1411 }
1412 if (!string.IsNullOrEmpty(settings.Name))
1413 {
1414 item.Name = settings.Name;
1415 }
1416 if (!string.IsNullOrEmpty(settings.CssClass))
1417 {
1418 item.CssClass += settings.CssClass;
1419 }
1420
1421 /* value is not supported */
1422
1423 if (!string.IsNullOrEmpty(settings.OnClick))
1424 {
1425 item.OnClick += settings.OnClick;
1426 }
1427 if (!string.IsNullOrEmpty(settings.OnChange))
1428 {
1429 item.OnChange += settings.OnChange;
1430 }
1431 @Render(item)
1432 }
1433
1434 @Render(new NotificationMessage { Message = settings.ErrorMessage })
1435 </div>
1436
1437 </div>
1438 }
1439 @using Dynamicweb.Rapido.Blocks.Components.General
1440
1441 @* Component *@
1442
1443 @helper RenderSearch(Search settings)
1444 {
1445 var searchValue = HttpContext.Current.Request.QueryString.Get(settings.SearchParameter) ?? "";
1446 var groupValue = HttpContext.Current.Request.QueryString.Get(settings.GroupsParameter) ?? "";
1447
1448 if (string.IsNullOrEmpty(settings.Id))
1449 {
1450 settings.Id = Guid.NewGuid().ToString("N");
1451 }
1452
1453 var resultAttributes = new Dictionary<string, string>();
1454
1455 if (settings.PageSize != 0)
1456 {
1457 resultAttributes.Add("data-page-size", settings.PageSize.ToString());
1458 }
1459 if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl))
1460 {
1461 resultAttributes.Add("data-groups-feed-url", settings.GroupItemsFeedUrl);
1462 if (!string.IsNullOrEmpty(groupValue))
1463 {
1464 resultAttributes.Add("data-selected-group", groupValue);
1465 }
1466 if (!string.IsNullOrEmpty(settings.GroupsParameter))
1467 {
1468 resultAttributes.Add("data-groups-parameter", settings.GroupsParameter);
1469 }
1470 }
1471 resultAttributes.Add("data-force-init", "true");
1472 if (settings.GoToFirstSearchResultOnEnter)
1473 {
1474 resultAttributes.Add("data-go-to-first-search-result-on-enter", settings.GoToFirstSearchResultOnEnter.ToString().ToLower());
1475 }
1476 if (!string.IsNullOrEmpty(settings.SearchParameter))
1477 {
1478 resultAttributes.Add("data-search-parameter", settings.SearchParameter);
1479 }
1480 resultAttributes.Add("data-search-feed-url", settings.SearchData.SearchFeedUrl);
1481 resultAttributes.Add("data-results-template-id", settings.SearchData.ResultsTemplateId);
1482
1483 if (settings.SecondSearchData != null)
1484 {
1485 resultAttributes.Add("data-second-search-feed-url", settings.SecondSearchData.SearchFeedUrl);
1486 resultAttributes.Add("data-second-results-template-id", settings.SecondSearchData.ResultsTemplateId);
1487 }
1488 if (!string.IsNullOrEmpty(settings.ResultsPageUrl))
1489 {
1490 resultAttributes.Add("data-results-page-url", settings.ResultsPageUrl);
1491 }
1492
1493 resultAttributes = resultAttributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value);
1494
1495 string searchFieldCss = (settings.SearchButton == null) ? "search--with-icon" : "";
1496
1497 <div class="search @settings.CssClass @searchFieldCss js-search-data-source dw-mod" id="@settings.Id" @ComponentMethods.AddAttributes(resultAttributes)>
1498 @if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl))
1499 {
1500 <button type="button" class="search__groups-btn dw-mod js-search-groups-btn">@Translate("All")</button>
1501 <ul class="dropdown dropdown--absolute-position dw-mod search__groups-results js-search-groups-list"></ul>
1502 }
1503
1504 <input type="text" class="search__field dw-mod js-search-field" placeholder="@settings.Placeholder" value="@searchValue">
1505
1506 <div class="dropdown dropdown--absolute-position search__results dw-mod js-search-results @(settings.SecondSearchData != null ? "search__results--combined" : "")">
1507 @if (settings.SecondSearchData != null)
1508 {
1509 <div class="search__column search__column--products dw-mod">
1510 <div class="search__column-header dw-mod">@Translate("Products")</div>
1511 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul>
1512 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl))
1513 {
1514 @Render(new Link {
1515 Title = Translate("View all"),
1516 CssClass = "js-view-all-button u-margin",
1517 Href = settings.SearchData.ResultsPageUrl
1518 });
1519 }
1520 </div>
1521 <div class="search__column search__column--pages dw-mod">
1522 <div class="search__column-header">@Translate("Pages")</div>
1523 <ul class="search__results-list dw-mod js-search-results-second-list" id="@(settings.Id)_SecondResultsList"></ul>
1524 @if (!string.IsNullOrEmpty(settings.SecondSearchData.ResultsPageUrl))
1525 {
1526 @Render(new Link
1527 {
1528 Title = Translate("View all"),
1529 CssClass = "js-view-all-button u-margin",
1530 Href = settings.SecondSearchData.ResultsPageUrl
1531 });
1532 }
1533 </div>
1534 }
1535 else
1536 {
1537 <div class="search__column search__column--only dw-mod">
1538 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul>
1539 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl))
1540 {
1541 @Render(new Link {
1542 Title = Translate("View all"),
1543 CssClass = "js-view-all-button u-margin",
1544 Href = settings.SearchData.ResultsPageUrl
1545 });
1546 }
1547 </div>
1548 }
1549 </div>
1550
1551 @if (settings.SearchButton != null)
1552 {
1553 settings.SearchButton.CssClass += " search__btn js-search-btn";
1554 if (settings.RenderDefaultSearchIcon)
1555 {
1556 settings.SearchButton.Icon = new Icon { Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue };
1557 }
1558 @Render(settings.SearchButton);
1559 }
1560 </div>
1561 }
1562 @using System.Reflection
1563 @using Dynamicweb.Rapido.Blocks.Components.General
1564 @using Dynamicweb.Rapido.Blocks.Components
1565
1566
1567 @* Component *@
1568
1569 @helper RenderSelectField(SelectField settings)
1570 {
1571 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id))
1572 {
1573 settings.Id = Guid.NewGuid().ToString("N");
1574 }
1575
1576 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod">
1577 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null )
1578 {
1579 <div class="u-full-width">
1580 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> }
1581 @if (settings.Link != null) {
1582 <div class="u-pull--right">
1583 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; }
1584 @Render(settings.Link)
1585 </div>
1586 }
1587 </div>
1588 }
1589
1590 @if (!string.IsNullOrEmpty(settings.HelpText))
1591 {
1592 <small class="form__help-text">@settings.HelpText</small>
1593 }
1594
1595 @if (settings.ActionButton != null)
1596 {
1597 settings.ActionButton.CssClass += " btn--condensed u-no-margin";
1598 <div class="form__field-combi u-no-margin dw-mod">
1599 @RenderSelectBase(settings)
1600 @Render(settings.ActionButton)
1601 </div>
1602 }
1603 else
1604 {
1605 @RenderSelectBase(settings)
1606 }
1607
1608 @Render(new NotificationMessage { Message = settings.ErrorMessage })
1609 </div>
1610 }
1611
1612 @helper RenderSelectBase(SelectField settings)
1613 {
1614 var attributes = new Dictionary<string, string>();
1615
1616 /*base settings*/
1617 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); }
1618 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); }
1619 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); }
1620 if (settings.Disabled) { attributes.Add("disabled", "true"); }
1621 if (settings.Required) { attributes.Add("required", "true"); }
1622 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); }
1623 /*end*/
1624
1625 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value);
1626
1627 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod">
1628 @if (settings.Default != null)
1629 {
1630 @Render(settings.Default)
1631 }
1632
1633 @foreach (var item in settings.Options)
1634 {
1635 if (settings.Value != null) {
1636 item.Checked = item.Value == settings.Value;
1637 }
1638 @Render(item)
1639 }
1640 </select>
1641 }
1642 @using System.Reflection
1643 @using Dynamicweb.Rapido.Blocks.Components.General
1644 @using Dynamicweb.Rapido.Blocks.Components
1645
1646 @* Component *@
1647
1648 @helper RenderRadioButtonField(RadioButtonField settings)
1649 {
1650 var attributes = new Dictionary<string, string>();
1651 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id))
1652 {
1653 settings.Id = Guid.NewGuid().ToString("N");
1654 }
1655
1656 /*base settings*/
1657 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); }
1658 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); }
1659 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); }
1660 if (settings.Disabled) { attributes.Add("disabled", "true"); }
1661 if (settings.Required) { attributes.Add("required", "true"); }
1662 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); }
1663 /*end*/
1664
1665 attributes.Add("type", "radio");
1666 if (settings.Checked) { attributes.Add("checked", "true"); }
1667 settings.CssClass = "form__control " + settings.CssClass;
1668 if (settings.Value != null) { attributes.Add("value", settings.Value); }
1669
1670 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value);
1671
1672 <div class="form__field-group @settings.WrapperCssClass dw-mod">
1673 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" />
1674 @if (!string.IsNullOrEmpty(settings.Label))
1675 {
1676 <label for="@settings.Id" class="dw-mod">@settings.Label</label>
1677 }
1678 @if (!string.IsNullOrEmpty(settings.HelpText))
1679 {
1680 <small class="form__help-text">@settings.HelpText</small>
1681 }
1682 @Render(new NotificationMessage { Message = settings.ErrorMessage })
1683 </div>
1684 }
1685 @using System.Reflection
1686 @using Dynamicweb.Rapido.Blocks.Components.General
1687 @using Dynamicweb.Rapido.Blocks.Components
1688
1689
1690 @* Component *@
1691
1692 @helper RenderRadioButtonListField(RadioButtonListField settings)
1693 {
1694 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; }
1695
1696 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)>
1697 @if (!string.IsNullOrEmpty(settings.Label))
1698 {
1699 <label>@settings.Label</label>
1700 }
1701 @if (!string.IsNullOrEmpty(settings.HelpText))
1702 {
1703 <small class="form__help-text">@settings.HelpText</small>
1704 }
1705
1706 @foreach (var item in settings.Options)
1707 {
1708 if (settings.Required)
1709 {
1710 item.Required = true;
1711 }
1712 if (settings.Disabled)
1713 {
1714 item.Disabled = true;
1715 }
1716 if (!string.IsNullOrEmpty(settings.Name))
1717 {
1718 item.Name = settings.Name;
1719 }
1720 if (settings.Value != null && settings.Value == item.Value)
1721 {
1722 item.Checked = true;
1723 }
1724 if (!string.IsNullOrEmpty(settings.OnClick))
1725 {
1726 item.OnClick += settings.OnClick;
1727 }
1728 if (!string.IsNullOrEmpty(settings.OnChange))
1729 {
1730 item.OnChange += settings.OnChange;
1731 }
1732 if (!string.IsNullOrEmpty(settings.CssClass))
1733 {
1734 item.CssClass += settings.CssClass;
1735 }
1736 @Render(item)
1737 }
1738
1739 @Render(new NotificationMessage { Message = settings.ErrorMessage })
1740 </div>
1741 }
1742 @using System.Reflection
1743 @using Dynamicweb.Rapido.Blocks.Components.General
1744 @using Dynamicweb.Rapido.Blocks.Components
1745
1746
1747 @* Component *@
1748
1749 @helper RenderNotificationMessage(NotificationMessage settings)
1750 {
1751 if (!string.IsNullOrEmpty(settings.Message))
1752 {
1753 var attributes = new Dictionary<string, string>();
1754 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); }
1755
1756 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower();
1757 string messageLayoutClass = Enum.GetName(typeof(NotificationMessageLayout), settings.MessageLayout).ToLower();
1758 string minHeightClass = settings.Icon != null ? "u-min-h70px" : "";
1759
1760 <div class="notification-message-@messageTypeClass notification-message-@messageLayoutClass @messageLayoutClass @minHeightClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)>
1761 @if (settings.Icon != null) {
1762 settings.Icon.Label = !string.IsNullOrEmpty(settings.Icon.Label) ? settings.Message + settings.Icon.Label : settings.Message;
1763 @Render(settings.Icon)
1764 } else {
1765 @settings.Message
1766 }
1767 </div>
1768 }
1769 }
1770 @using Dynamicweb.Rapido.Blocks.Components.General
1771
1772
1773 @* Component *@
1774
1775 @helper RenderHandlebarsRoot(HandlebarsRoot settings) {
1776 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : "";
1777
1778 <div class="@settings.CssClass dw-mod js-handlebars-root" id="@settings.Id" data-template="@settings.ScriptTemplate" data-json-feed="@settings.FeedUrl" data-init-onload="@settings.InitOnLoad.ToString()" data-preloader="@settings.Preloader" @preRender>
1779 @if (settings.SubBlocks != null) {
1780 @RenderBlockList(settings.SubBlocks)
1781 }
1782 </div>
1783 }
1784 @using System.Reflection
1785 @using Dynamicweb.Rapido.Blocks.Components.General
1786 @using Dynamicweb.Rapido.Blocks.Components
1787 @using System.Text.RegularExpressions
1788
1789
1790 @* Component *@
1791
1792 @helper RenderSticker(Sticker settings) {
1793 if (!String.IsNullOrEmpty(settings.Title)) {
1794 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : "";
1795 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : "";
1796
1797 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>();
1798 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) {
1799 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : "";
1800 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : "";
1801 optionalAttributes.Add("style", styleTag);
1802 }
1803
1804 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div>
1805 }
1806 }
1807
1808 @using System.Reflection
1809 @using Dynamicweb.Rapido.Blocks.Components.General
1810 @using Dynamicweb.Rapido.Blocks.Components
1811
1812
1813 @* Component *@
1814
1815 @helper RenderStickersCollection(StickersCollection settings)
1816 {
1817 if (settings.Stickers.Count > 0)
1818 {
1819 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower();
1820
1821 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)>
1822 @foreach (Sticker sticker in settings.Stickers)
1823 {
1824 @Render(sticker)
1825 }
1826 </div>
1827 }
1828 }
1829
1830 @using Dynamicweb.Rapido.Blocks.Components.General
1831
1832
1833 @* Component *@
1834
1835 @helper RenderForm(Form settings) {
1836 if (settings != null)
1837 {
1838 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>();
1839 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); };
1840 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); };
1841 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); };
1842 var enctypes = new Dictionary<string, string>
1843 {
1844 { "multipart", "multipart/form-data" },
1845 { "text", "text/plain" },
1846 { "application", "application/x-www-form-urlencoded" }
1847 };
1848 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); };
1849 optionalAttributes.Add("method", settings.Method.ToString());
1850
1851 if (!string.IsNullOrEmpty(settings.FormStartMarkup))
1852 {
1853 @settings.FormStartMarkup
1854 }
1855 else
1856 {
1857 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>
1858 }
1859
1860 foreach (var field in settings.GetFields())
1861 {
1862 @Render(field)
1863 }
1864
1865 @:</form>
1866 }
1867 }
1868 @using System.Reflection
1869 @using Dynamicweb.Rapido.Blocks.Components.General
1870 @using Dynamicweb.Rapido.Blocks.Components
1871
1872
1873 @* Component *@
1874
1875 @helper RenderText(Text settings)
1876 {
1877 @settings.Content
1878 }
1879 @using System.Reflection
1880 @using Dynamicweb.Rapido.Blocks.Components.General
1881 @using Dynamicweb.Rapido.Blocks.Components
1882
1883
1884 @* Component *@
1885
1886 @helper RenderContentModule(ContentModule settings) {
1887 if (!string.IsNullOrEmpty(settings.Content))
1888 {
1889 @settings.Content
1890 }
1891 }
1892 @using System.Reflection
1893 @using Dynamicweb.Rapido.Blocks.Components.General
1894 @using Dynamicweb.Rapido.Blocks.Components
1895
1896
1897 @* Component *@
1898
1899 @helper RenderModal(Modal settings) {
1900 if (settings != null)
1901 {
1902 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N");
1903
1904 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : "";
1905
1906 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange />
1907
1908 <div class="modal-container">
1909 @if (!settings.DisableDarkOverlay)
1910 {
1911 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label>
1912 }
1913 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal">
1914 @if (settings.Heading != null)
1915 {
1916 if (!string.IsNullOrEmpty(settings.Heading.Title))
1917 {
1918 <div class="modal__header">
1919 @Render(settings.Heading)
1920 </div>
1921 }
1922 }
1923 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")">
1924 @if (!string.IsNullOrEmpty(settings.BodyText))
1925 {
1926 @settings.BodyText
1927 }
1928 @if (settings.BodyTemplate != null)
1929 {
1930 @settings.BodyTemplate
1931 }
1932 @{
1933 var actions = settings.GetActions();
1934 }
1935 </div>
1936 @if (actions.Length > 0)
1937 {
1938 <div class="modal__footer">
1939 @foreach (var action in actions)
1940 {
1941 if (Pageview.Device.ToString() != "Mobile") {
1942 action.CssClass += " u-no-margin";
1943 } else {
1944 action.CssClass += " u-full-width u-margin-bottom";
1945 }
1946
1947 @Render(action)
1948 }
1949 </div>
1950 }
1951 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label>
1952 </div>
1953 </div>
1954 }
1955 }
1956 @using Dynamicweb.Rapido.Blocks.Components.General
1957
1958 @* Component *@
1959
1960 @helper RenderMediaListItem(MediaListItem settings)
1961 {
1962 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")>
1963 @if (!string.IsNullOrEmpty(settings.Label))
1964 {
1965 if (!string.IsNullOrEmpty(settings.Link))
1966 {
1967 @Render(new Link
1968 {
1969 Href = settings.Link,
1970 CssClass = "media-list-item__sticker dw-mod",
1971 ButtonLayout = ButtonLayout.None,
1972 Title = settings.Label,
1973 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : ""
1974 })
1975 }
1976 else if (!string.IsNullOrEmpty(settings.OnClick))
1977 {
1978 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)">
1979 <span class="u-uppercase">@settings.Label</span>
1980 </span>
1981 }
1982 else
1983 {
1984 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod">
1985 <span class="u-uppercase">@settings.Label</span>
1986 </span>
1987 }
1988 }
1989 <div class="media-list-item__wrap">
1990 <div class="media-list-item__info dw-mod">
1991 <div class="media-list-item__header dw-mod">
1992 @if (!string.IsNullOrEmpty(settings.Title))
1993 {
1994 if (!string.IsNullOrEmpty(settings.Link))
1995 {
1996 @Render(new Link
1997 {
1998 Href = settings.Link,
1999 CssClass = "media-list-item__name dw-mod",
2000 ButtonLayout = ButtonLayout.None,
2001 Title = settings.Title,
2002 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : ""
2003 })
2004 }
2005 else if (!string.IsNullOrEmpty(settings.OnClick))
2006 {
2007 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span>
2008 }
2009 else
2010 {
2011 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span>
2012 }
2013 }
2014
2015 @if (!string.IsNullOrEmpty(settings.Status))
2016 {
2017 <div class="media-list-item__state dw-mod">@settings.Status</div>
2018 }
2019 </div>
2020 @{
2021 settings.InfoTable.CssClass += " media-list-item__parameters-table";
2022 }
2023
2024 @Render(settings.InfoTable)
2025 </div>
2026 <div class="media-list-item__actions dw-mod">
2027 <div class="media-list-item__actions-list dw-mod">
2028 @{
2029 var actions = settings.GetActions();
2030
2031 foreach (ButtonBase action in actions)
2032 {
2033 action.ButtonLayout = ButtonLayout.None;
2034 action.CssClass += " media-list-item__action link";
2035
2036 @Render(action)
2037 }
2038 }
2039 </div>
2040
2041 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title))
2042 {
2043 settings.SelectButton.CssClass += " u-no-margin";
2044
2045 <div class="media-list-item__action-button">
2046 @Render(settings.SelectButton)
2047 </div>
2048 }
2049 </div>
2050 </div>
2051 </div>
2052 }
2053 @using Dynamicweb.Rapido.Blocks.Components.General
2054 @using Dynamicweb.Rapido.Blocks.Components
2055
2056 @helper RenderTable(Table settings)
2057 {
2058 Dictionary<string, string> attributes = new Dictionary<string, string>();
2059 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); }
2060
2061 var enumToClasses = new Dictionary<TableDesign, string>
2062 {
2063 { TableDesign.Clean, "table--clean" },
2064 { TableDesign.Bordered, "table--bordered" },
2065 { TableDesign.Striped, "table--striped" },
2066 { TableDesign.Hover, "table--hover" },
2067 { TableDesign.Compact, "table--compact" },
2068 { TableDesign.Condensed, "table--condensed" },
2069 { TableDesign.NoTopBorder, "table--no-top-border" }
2070 };
2071 string tableDesignClass = "";
2072 if (settings.Design != TableDesign.None)
2073 {
2074 tableDesignClass = enumToClasses[settings.Design];
2075 }
2076
2077 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); }
2078
2079 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value);
2080
2081 <table @ComponentMethods.AddAttributes(resultAttributes)>
2082 @if (settings.Header != null)
2083 {
2084 <thead>
2085 @Render(settings.Header)
2086 </thead>
2087 }
2088 <tbody>
2089 @foreach (var row in settings.Rows)
2090 {
2091 @Render(row)
2092 }
2093 </tbody>
2094 @if (settings.Footer != null)
2095 {
2096 <tfoot>
2097 @Render(settings.Footer)
2098 </tfoot>
2099 }
2100 </table>
2101 }
2102 @using Dynamicweb.Rapido.Blocks.Components.General
2103 @using Dynamicweb.Rapido.Blocks.Components
2104
2105 @helper RenderTableRow(TableRow settings)
2106 {
2107 Dictionary<string, string> attributes = new Dictionary<string, string>();
2108 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); }
2109
2110 var enumToClasses = new Dictionary<TableRowDesign, string>
2111 {
2112 { TableRowDesign.NoBorder, "table__row--no-border" },
2113 { TableRowDesign.Border, "table__row--border" },
2114 { TableRowDesign.TopBorder, "table__row--top-line" },
2115 { TableRowDesign.BottomBorder, "table__row--bottom-line" },
2116 { TableRowDesign.Solid, "table__row--solid" }
2117 };
2118
2119 string tableRowDesignClass = "";
2120 if (settings.Design != TableRowDesign.None)
2121 {
2122 tableRowDesignClass = enumToClasses[settings.Design];
2123 }
2124
2125 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); }
2126
2127 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value);
2128
2129 <tr @ComponentMethods.AddAttributes(resultAttributes)>
2130 @foreach (var cell in settings.Cells)
2131 {
2132 if (settings.IsHeaderRow)
2133 {
2134 cell.IsHeader = true;
2135 }
2136 @Render(cell)
2137 }
2138 </tr>
2139 }
2140 @using Dynamicweb.Rapido.Blocks.Components.General
2141 @using Dynamicweb.Rapido.Blocks.Components
2142 @using Dynamicweb.Core
2143
2144 @helper RenderTableCell(TableCell settings)
2145 {
2146 Dictionary<string, string> attributes = new Dictionary<string, string>();
2147 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); }
2148 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); }
2149 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); }
2150 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); }
2151
2152 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value);
2153
2154 string tagName = settings.IsHeader ? "th" : "td";
2155
2156 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">")
2157 @settings.Content
2158 @("</" + tagName + ">");
2159 }
2160 @using System.Linq
2161 @using Dynamicweb.Rapido.Blocks.Components.General
2162
2163 @* Component *@
2164
2165 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings)
2166 {
2167 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter
2168 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring
2169
2170 if (settings.NumberOfPages > 1)
2171 {
2172 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx";
2173 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation");
2174 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings);
2175
2176 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel">
2177 @if (settings.ShowPagingInfo)
2178 {
2179 <div class="pager__info dw-mod">
2180 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages
2181 </div>
2182 }
2183 <ul class="pager__list dw-mod">
2184 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls)
2185 {
2186 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon })
2187 }
2188 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls)
2189 {
2190 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon })
2191 }
2192 @if (settings.GetPages().Any())
2193 {
2194 foreach (var page in settings.GetPages())
2195 {
2196 @Render(page)
2197 }
2198 }
2199 else
2200 {
2201 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++)
2202 {
2203 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString());
2204 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) });
2205 }
2206 }
2207 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls)
2208 {
2209 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon })
2210 }
2211 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls)
2212 {
2213 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon })
2214 }
2215 </ul>
2216 </div>
2217 }
2218 }
2219
2220 @helper RenderPaginationItem(PaginationItem settings)
2221 {
2222 if (settings.Icon == null)
2223 {
2224 settings.Icon = new Icon();
2225 }
2226
2227 settings.Icon.Label = settings.Label;
2228 <li class="pager__btn dw-mod">
2229 @if (settings.IsActive)
2230 {
2231 <span class="pager__num pager__num--current dw-mod">
2232 @Render(settings.Icon)
2233 </span>
2234 }
2235 else
2236 {
2237 <a href="@settings.Link" class="pager__num dw-mod">
2238 @Render(settings.Icon)
2239 </a>
2240 }
2241 </li>
2242 }
2243
2244
2245 @using Dynamicweb.Rapido.Blocks.Components.General
2246 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce
2247
2248
2249 @using Dynamicweb.Frontend
2250 @using System.Reflection
2251 @using Dynamicweb.Content.Items
2252 @using System.Web.UI.HtmlControls
2253 @using Dynamicweb.Rapido.Blocks.Components
2254 @using Dynamicweb.Rapido.Blocks
2255 @using Dynamicweb.Rapido.Blocks.Components.Articles
2256
2257 @* Components for the articles *@
2258 @using System.Reflection
2259 @using Dynamicweb.Rapido.Blocks.Components.Articles
2260
2261
2262 @* Component for the articles *@
2263
2264 @helper RenderArticleBanner(dynamic settings) {
2265 string filterClasses = "image-filter image-filter--darken";
2266 settings.Layout = ArticleHeaderLayout.Banner;
2267
2268 if (settings.Image != null)
2269 {
2270 if (settings.Image.Path != null)
2271 {
2272 <section class="multiple-paragraphs-container u-color-light paragraph-container--full-width">
2273 <div class="background-image @filterClasses dw-mod">
2274 <div class="background-image__wrapper @filterClasses dw-mod">
2275 @{
2276 settings.Image.CssClass += "background-image__cover dw-mod";
2277 }
2278 @Render(settings.Image)
2279 </div>
2280 </div>
2281 <div class="center-container dw-mod">
2282 <div class="grid">
2283 <div class="grid__col-md-8 grid__col-xs-12 paragraph-container paragraph-container--height-lg">
2284 <div class="u-left-middle">
2285 <div>
2286 @if (!String.IsNullOrEmpty(settings.Heading))
2287 {
2288 <h1 class="article__header article__header--giant dw-mod" style="color: @settings.TextColor">@settings.Heading</h1>
2289 }
2290 @if (!String.IsNullOrEmpty(settings.Subheading))
2291 {
2292 <div class="article__leadtext dw-mod" style="color: @settings.TextColor">@settings.Subheading</div>
2293 }
2294 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date))
2295 {
2296 <small class="article__post-info u-margin-bottom--lg dw-mod" style="color: @settings.TextColor">@settings.Author @settings.Date</small>
2297 }
2298 @if (!String.IsNullOrEmpty(settings.Link)) {
2299 <div class="grid__cell">
2300 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout })
2301 </div>
2302 }
2303 </div>
2304 </div>
2305 </div>
2306 @if (settings.ExternalParagraphId != 0)
2307 {
2308 <div class="grid__col-md-4 grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-auto dw-mod">
2309 <div class="u-color-light-gray--bg u-color-dark dw-mod">
2310 @RenderParagraphContent(settings.ExternalParagraphId)
2311 </div>
2312 </div>
2313 }
2314
2315 </div>
2316 </div>
2317 </section>
2318 if (!String.IsNullOrEmpty(settings.Image.Caption)) {
2319 <div class="image-caption dw-mod">@settings.Image.Caption</div>
2320 }
2321 }
2322 else
2323 {
2324 settings.Layout = ArticleHeaderLayout.Clean;
2325 @RenderArticleCleanHeader(settings);
2326 }
2327 }
2328 else
2329 {
2330 settings.Layout = ArticleHeaderLayout.Clean;
2331 @RenderArticleCleanHeader(settings);
2332 }
2333 }
2334 @using System.Reflection
2335 @using Dynamicweb.Rapido.Blocks.Components
2336 @using Dynamicweb.Rapido.Blocks.Components.General
2337 @using Dynamicweb.Rapido.Blocks.Components.Articles
2338 @using Dynamicweb.Rapido.Blocks
2339
2340
2341 @* Component for the articles *@
2342
2343 @helper RenderArticleHeader(ArticleHeader settings) {
2344 dynamic[] methodParameters = new dynamic[1];
2345 methodParameters[0] = settings;
2346 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleHeaderCustom");
2347
2348 if (customMethod != null)
2349 {
2350 @customMethod.Invoke(this, methodParameters).ToString();
2351 } else {
2352 switch (settings.Layout)
2353 {
2354 case ArticleHeaderLayout.Clean:
2355 @RenderArticleCleanHeader(settings);
2356 break;
2357 case ArticleHeaderLayout.Split:
2358 @RenderArticleSplitHeader(settings);
2359 break;
2360 case ArticleHeaderLayout.Banner:
2361 @RenderArticleBannerHeader(settings);
2362 break;
2363 case ArticleHeaderLayout.Overlay:
2364 @RenderArticleOverlayHeader(settings);
2365 break;
2366 default:
2367 @RenderArticleCleanHeader(settings);
2368 break;
2369 }
2370 }
2371 }
2372
2373 @helper RenderArticleCleanHeader(ArticleHeader settings) {
2374 dynamic[] methodParameters = new dynamic[1];
2375 methodParameters[0] = settings;
2376 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleCleanHeaderCustom");
2377
2378 if (customMethod != null)
2379 {
2380 @customMethod.Invoke(this, methodParameters).ToString();
2381 }
2382 else
2383 {
2384 string contentColumns = settings.TextLayout != ArticleHeaderTextLayout.Full ? "8" : "12";
2385
2386 <div class="grid grid--align-content-start grid--justify-start">
2387 <div class="grid__col-md-@contentColumns grid__col-sm-12 u-padding--lg dw-mod">
2388 @if (!String.IsNullOrEmpty(settings.Category) || !String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date) || settings.RatingOutOf != 0)
2389 {
2390 <div class="u-border-bottom u-padding-bottom">
2391 @if (!String.IsNullOrEmpty(settings.Category))
2392 {
2393 <div class="u-pull--left">
2394 <div class="article__category dw-mod" style="color: @settings.CategoryColor">@settings.Category</div>
2395 </div>
2396 }
2397 <div class="u-pull--right">
2398 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date))
2399 {
2400 <small class="article__post-info dw-mod">@settings.Author @settings.Date</small>
2401 }
2402 @if (settings.RatingOutOf != 0)
2403 {
2404 @Render(new Rating { Score = settings.RatingScore, OutOf = settings.RatingOutOf })
2405 }
2406 </div>
2407 </div>
2408 }
2409
2410 <div class="grid__cell">
2411 @if (!String.IsNullOrEmpty(settings.Heading))
2412 {
2413 <h1 class="article__header article__header--giant dw-mod">@settings.Heading</h1>
2414 }
2415 @if (settings.Image != null)
2416 {
2417 if (settings.Image.Path != null)
2418 {
2419 <div class="u-padding-bottom--lg">
2420 @Render(settings.Image)
2421 </div>
2422 }
2423 }
2424 @if (!String.IsNullOrEmpty(settings.Subheading))
2425 {
2426 <div class="article__leadtext dw-mod">@settings.Subheading</div>
2427 }
2428 @if (!String.IsNullOrEmpty(settings.Link))
2429 {
2430 <div class="grid__cell">
2431 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout })
2432 </div>
2433 }
2434 </div>
2435 </div>
2436 @if (settings.ExternalParagraphId != 0)
2437 {
2438 <div class="grid__col-md-4 grid__col-sm-12 u-padding--lg u-color-light-gray--bg dw-mod">
2439 @RenderParagraphContent(settings.ExternalParagraphId)
2440 </div>
2441 }
2442 </div>
2443 }
2444 }
2445
2446 @helper RenderArticleSplitHeader(ArticleHeader settings) {
2447 dynamic[] methodParameters = new dynamic[1];
2448 methodParameters[0] = settings;
2449 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleSplitHeaderCustom");
2450
2451 if (customMethod != null)
2452 {
2453 @customMethod.Invoke(this, methodParameters).ToString();
2454 }
2455 else
2456 {
2457 string headerColumnWidth = settings.ExternalParagraphId != 0 ? "4" : "6";
2458
2459 if (settings.Image != null)
2460 {
2461 if (settings.Image.Path != null)
2462 {
2463 <section class="multiple-paragraphs-container paragraph-container--full-width">
2464 <div class="grid">
2465 <div class="grid__col-md-@headerColumnWidth grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-xl dw-mod">
2466 <div class="u-left-middle u-padding--lg">
2467 <div>
2468 @if (!String.IsNullOrEmpty(settings.Category))
2469 {
2470 <div class="article__category dw-mod" style="color: @settings.CategoryColor">@settings.Category</div>
2471 }
2472 @if (!String.IsNullOrEmpty(settings.Heading))
2473 {
2474 <h1 class="article__header article__header--giant dw-mod">@settings.Heading</h1>
2475 }
2476 @if (!String.IsNullOrEmpty(settings.Subheading))
2477 {
2478 <div class="article__leadtext dw-mod">@settings.Subheading</div>
2479 }
2480 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date))
2481 {
2482 <small class="article__post-info u-pull--left dw-mod">@settings.Author @settings.Date</small>
2483 }
2484 @if (settings.RatingOutOf != 0)
2485 {
2486 <div class="u-pull--right">
2487 @Render(new Rating { Score = settings.RatingScore, OutOf = settings.RatingOutOf })
2488 </div>
2489 }
2490 @if (!String.IsNullOrEmpty(settings.Link)) {
2491 <div class="u-full-width u-pull--left u-margin-top">
2492 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout })
2493 </div>
2494 }
2495 </div>
2496 </div>
2497 </div>
2498 <div class="grid__col-md-@headerColumnWidth grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-auto dw-mod" style="background-image:url(/Admin/Public/GetImage.ashx?width=1800&height=1100&crop=0&Compression=85&DoNotUpscale=true&image=@settings.Image.Path); background-position: center center; background-size: cover;"></div>
2499 @if (settings.ExternalParagraphId != 0)
2500 {
2501 <div class="grid__col-md-4 grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-auto u-color-light-gray--bg dw-mod">
2502 @RenderParagraphContent(settings.ExternalParagraphId)
2503 </div>
2504 }
2505 </div>
2506 </section>
2507 }
2508 }
2509 else
2510 {
2511 @RenderArticleCleanHeader(settings);
2512 }
2513 }
2514 }
2515
2516 @helper RenderArticleOverlayHeader(ArticleHeader settings) {
2517 dynamic[] methodParameters = new dynamic[1];
2518 methodParameters[0] = settings;
2519 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleOverlayHeaderCustom");
2520
2521 if (customMethod != null)
2522 {
2523 @customMethod.Invoke(this, methodParameters).ToString();
2524 }
2525 else
2526 {
2527 string contentColumns = settings.TextLayout != ArticleHeaderTextLayout.Full ? "8" : "12";
2528 string contentAlignment = settings.TextLayout == ArticleHeaderTextLayout.Center ? "grid--justify-center" : "";
2529
2530 if (settings.Image != null)
2531 {
2532 if (settings.Image.Path != null)
2533 {
2534 if (settings.ExternalParagraphId == 0)
2535 {
2536 <section class="multiple-paragraphs-container u-color-light paragraph-container--full-width">
2537 <div class="background-image image-filter image-filter--darken dw-mod">
2538 <div class="background-image__wrapper image-filter image-filter--darken dw-mod">
2539 @{
2540 settings.Image.CssClass += "background-image__cover dw-mod";
2541 }
2542 @Render(settings.Image)
2543 </div>
2544 </div>
2545 <div class="center-container dw-mod">
2546 <div class="grid @contentAlignment">
2547 <div class="grid__col-md-@contentColumns grid__col-xs-12 paragraph-container paragraph-container--height-xl dw-mod">
2548 @if (!string.IsNullOrEmpty(settings.Heading))
2549 {
2550 <h1 class="article__header article__header--giant u-padding-top--lg dw-mod" style="color: @settings.TextColor">@settings.Heading</h1>
2551 }
2552 @if (!String.IsNullOrEmpty(settings.Subheading))
2553 {
2554 <div class="article__leadtext dw-mod" style="color: @settings.TextColor">@settings.Subheading</div>
2555 }
2556 <div class="u-margin-top">
2557 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date))
2558 {
2559 <small class="article__post-info u-pull--left dw-mod" style="color: @settings.TextColor">@settings.Author @settings.Date</small>
2560 }
2561 @if (settings.RatingOutOf != 0)
2562 {
2563 <div class="u-pull--right">
2564 @Render(new Rating { Score = settings.RatingScore, OutOf = settings.RatingOutOf })
2565 </div>
2566 }
2567 </div>
2568 @if (!String.IsNullOrEmpty(settings.Link))
2569 {
2570 <div class="grid__cell">
2571 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout })
2572 </div>
2573 }
2574 </div>
2575 </div>
2576 </div>
2577 </section>
2578 }
2579 else
2580 {
2581 @RenderArticleBanner(settings);
2582 }
2583 }
2584 }
2585 else
2586 {
2587 @RenderArticleCleanHeader(settings);
2588 }
2589 }
2590 }
2591
2592 @helper RenderArticleBannerHeader(dynamic settings) {
2593 dynamic[] methodParameters = new dynamic[1];
2594 methodParameters[0] = settings;
2595 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleBannerHeaderCustom");
2596
2597 if (customMethod != null)
2598 {
2599 @customMethod.Invoke(this, methodParameters).ToString();
2600 }
2601 else
2602 {
2603 @RenderArticleBanner(settings);
2604 }
2605 }
2606 @using System.Reflection
2607 @using System.Text.RegularExpressions;
2608 @using Dynamicweb.Frontend
2609 @using Dynamicweb.Content.Items
2610 @using Dynamicweb.Rapido.Blocks.Components
2611 @using Dynamicweb.Rapido.Blocks.Components.Articles
2612 @using Dynamicweb.Rapido.Blocks
2613
2614 @* Component for the articles *@
2615
2616 @helper RenderArticleBodyRow(ArticleBodyRow settings)
2617 {
2618 string position = settings.TopLayout == "overlay" ? "article__overlay-offset" : "";
2619 string contentAlignment = settings.TextLayout == "center" ? "grid--justify-center" : "";
2620
2621 <div class="grid grid--align-content-start @contentAlignment @position dw-mod">
2622 @RenderBlockList(settings.SubBlocks)
2623 </div>
2624 }
2625 @using System.Reflection
2626 @using Dynamicweb.Rapido.Blocks.Components
2627 @using Dynamicweb.Rapido.Blocks.Components.General
2628 @using Dynamicweb.Rapido.Blocks.Components.Articles
2629 @using Dynamicweb.Rapido.Blocks
2630
2631 @* Component for the articles *@
2632
2633 @helper RenderArticleImage(ArticleImage settings)
2634 {
2635 if (settings.Image != null)
2636 {
2637 if (settings.Image.Path != null)
2638 {
2639 <div class="u-margin-bottom--lg">
2640 @Render(settings.Image)
2641 </div>
2642 }
2643 }
2644 }
2645 @using System.Reflection
2646 @using Dynamicweb.Rapido.Blocks.Components
2647 @using Dynamicweb.Rapido.Blocks.Components.Articles
2648
2649
2650 @* Component for the articles *@
2651
2652 @helper RenderArticleSubHeader(ArticleSubHeader settings)
2653 {
2654 if (!String.IsNullOrEmpty(settings.Title))
2655 {
2656 <h2 class="article__header">@settings.Title</h2>
2657 }
2658 }
2659 @using System.Reflection
2660 @using Dynamicweb.Rapido.Blocks.Components
2661 @using Dynamicweb.Rapido.Blocks.Components.Articles
2662 @using Dynamicweb.Rapido.Blocks
2663
2664
2665 @* Component for the articles *@
2666
2667 @helper RenderArticleText(ArticleText settings)
2668 {
2669 if (!String.IsNullOrEmpty(settings.Text))
2670 {
2671 string greatTextClass = settings.EnableLargeText == true ? "article__paragraph--great-text" : "";
2672
2673 <div class="article__paragraph @greatTextClass dw-mod">
2674 @settings.Text
2675 </div>
2676 }
2677 }
2678 @using System.Reflection
2679 @using Dynamicweb.Rapido.Blocks.Components
2680 @using Dynamicweb.Rapido.Blocks.Components.Articles
2681 @using Dynamicweb.Rapido.Blocks
2682
2683
2684 @* Component for the articles *@
2685
2686 @helper RenderArticleQuote(ArticleQuote settings)
2687 {
2688 string text = Regex.Replace(settings.Text, "<.*?>", String.Empty);
2689
2690 <div class="grid u-padding-bottom--lg">
2691 @if (settings.Image != null)
2692 {
2693 if (settings.Image.Path != null) {
2694 <div class="grid__col-3">
2695 <div class="grid__cell-img">
2696 @{
2697 settings.Image.Title = !String.IsNullOrEmpty(settings.Image.Title) ? settings.Image.Title : settings.Author;
2698 settings.Image.CssClass += " article__image article__image--ball";
2699 settings.Image.ImageDefault.Width = 200;
2700 settings.Image.ImageDefault.Height = 200;
2701 }
2702 @Render(settings.Image)
2703 </div>
2704 </div>
2705 }
2706 }
2707 <div class="grid__col-auto">
2708 @if (!String.IsNullOrEmpty(settings.Text))
2709 {
2710 <div class="article__quote dw-mod">
2711 <i class="fas fa-quote-right u-margin-bottom--lg"></i>
2712 @settings.Text
2713 <i class="fas fa-quote-right"></i>
2714 </div>
2715 }
2716 @if (!String.IsNullOrEmpty(settings.Author))
2717 {
2718 <div class="article__quote-author dw-mod">
2719 - @settings.Author
2720 </div>
2721 }
2722 </div>
2723 </div>
2724 }
2725 @using System.Reflection
2726 @using Dynamicweb.Rapido.Blocks.Components
2727 @using Dynamicweb.Rapido.Blocks.Components.Articles
2728 @using Dynamicweb.Rapido.Blocks
2729
2730 @* Component for the articles *@
2731
2732 @helper RenderArticleInfoTable(ArticleInfoTable settings)
2733 {
2734 <table class="table table--clean">
2735 @foreach (var row in settings.Rows)
2736 {
2737 string iconColor = row.IconColor != null ? row.IconColor : "u-brand-color-two";
2738
2739 <tr>
2740 @if (!String.IsNullOrEmpty(row.Icon))
2741 {
2742 <td class="u-w32px"><i class="@row.Icon fa-2x @row.IconColor"></i></td>
2743 }
2744 <td class="u-no-margin-on-p-elements">
2745 <div class="u-bold">@row.Title</div>
2746 @if (!String.IsNullOrEmpty(row.SubTitle))
2747 {
2748 if (row.Link == null)
2749 {
2750 <div>@row.SubTitle</div>
2751 }
2752 else
2753 {
2754 <a href="@row.Link" class="u-color-inherit">@row.SubTitle</a>
2755 }
2756 }
2757 </td>
2758 </tr>
2759 }
2760 </table>
2761 }
2762 @using System.Reflection
2763 @using Dynamicweb.Rapido.Blocks.Components
2764 @using Dynamicweb.Rapido.Blocks.Components.General
2765 @using Dynamicweb.Rapido.Blocks.Components.Articles
2766 @using Dynamicweb.Rapido.Blocks
2767
2768 @* Component for the articles *@
2769
2770 @helper RenderArticleGalleryModal(ArticleGalleryModal settings)
2771 {
2772 Modal galleryModal = new Modal
2773 {
2774 Id = "ParagraphGallery",
2775 Width = ModalWidth.Full,
2776 BodyTemplate = RenderArticleGalleryModalContent()
2777 };
2778
2779 @Render(galleryModal)
2780 }
2781
2782 @helper RenderArticleGalleryModalContent() {
2783 <div class="modal__image-min-size-wrapper">
2784 @Render(new Image {
2785 Id = "ParagraphGallery",
2786 Path = "#",
2787 CssClass = "modal--full__img",
2788 DisableLazyLoad = true,
2789 DisableImageEngine = true
2790 })
2791 </div>
2792
2793 <div class="modal__images-counter" id="ParagraphGallery_counter"></div>
2794
2795 @Render(new Button {
2796 Id = "ParagraphGallery_prev",
2797 ButtonType = ButtonType.Button,
2798 ButtonLayout = ButtonLayout.None,
2799 CssClass = "modal__prev-btn",
2800 Icon = new Icon { Prefix = "far", Name = "fa-angle-left", LabelPosition = IconLabelPosition.After },
2801 OnClick = "Gallery.prevImage('ParagraphGallery')"
2802 })
2803
2804 @Render(new Button {
2805 Id = "ParagraphGallery_next",
2806 ButtonType = ButtonType.Button,
2807 ButtonLayout = ButtonLayout.None,
2808 CssClass = "modal__next-btn",
2809 Icon = new Icon { Prefix = "far", Name = "fa-angle-right", LabelPosition = IconLabelPosition.After },
2810 OnClick = "Gallery.nextImage('ParagraphGallery')"
2811 })
2812 }
2813 @using System.Reflection
2814 @using Dynamicweb.Rapido.Blocks.Components
2815 @using Dynamicweb.Rapido.Blocks.Components.Articles
2816 @using Dynamicweb.Rapido.Blocks
2817
2818
2819 @* Component for the articles *@
2820
2821 @helper RenderArticleRelated(ArticleRelated settings)
2822 {
2823 string cardClass = Pageview.Device.ToString() != "Tablet" ? "card u-color-light--bg u-full-height" : "";
2824 string cardFooterClass = Pageview.Device.ToString() != "Tablet" ? "card-footer u-color-light--bg" : "";
2825
2826 <section class="multiple-paragraphs-container u-color-light-gray--bg paragraph-container--full-width">
2827 <div class="center-container dw-mod">
2828 <div class="grid u-padding">
2829 <div class="grid__col-md-12 grid__col-xs-12">
2830 <h2 class="article__header u-no-margin u-margin-top">@settings.Title</h2>
2831 </div>
2832 </div>
2833
2834 <div class="js-handlebars-root u-padding" id="@settings.Title.Replace(" ", String.Empty)" data-template="RelatedSimpleTemplate" data-json-feed="/Default.aspx?ID=@settings.FeedPageId&@settings.Query&ExcludeItemID=@settings.CurrentPageId&PageSize=@settings.PageSize"></div>
2835
2836 <script id="RelatedSimpleTemplate" type="text/x-template">
2837 {{#.}}
2838 <div class="grid u-padding-bottom--lg">
2839 {{#Cases}}
2840 <div class="grid__col-lg-3 grid__col-sm-6 image-hover--zoom dw-mod">
2841 <a href="{{link}}" class="u-full-height u-color-light--bg u-flex u-flex--column">
2842 {{#if image}}
2843 <div class="u-color-light--bg u-no-padding dw-mod">
2844 <div class="flex-img image-hover__wrapper">
2845 <img class="b-lazy" src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=680&height=314&crop=1&DoNotUpscale=True&Compression=75&image={{image}}" alt="{{title}}" />
2846 </div>
2847 </div>
2848 {{/if}}
2849
2850 <div class="card u-color-light--bg u-full-height dw-mod">
2851 <h3 class="article-list__item-header u-truncate-text dw-mod">{{title}}</h3>
2852 <p class="article__short-summary dw-mod">{{summary}}</p>
2853 </div>
2854 </a>
2855 </div>
2856 {{/Cases}}
2857 </div>
2858 {{/.}}
2859 </script>
2860 </div>
2861 </section>
2862 }
2863 @using System.Reflection
2864 @using Dynamicweb.Rapido.Blocks.Components
2865 @using Dynamicweb.Rapido.Blocks.Components.Articles
2866 @using Dynamicweb.Rapido.Blocks
2867
2868
2869 @* Component for the articles *@
2870
2871 @helper RenderArticleMenu(ArticleMenu settings)
2872 {
2873 if (!String.IsNullOrEmpty(settings.Title)) {
2874 <div class="u-margin u-border-bottom">
2875 <h3 class="u-no-margin">@settings.Title</h3>
2876 </div>
2877 }
2878
2879 <ul class="menu-left u-margin-bottom dw-mod">
2880 @foreach (var item in settings.Items)
2881 {
2882 @Render(item)
2883 }
2884 </ul>
2885 }
2886
2887 @helper RenderArticleMenuItem(ArticleMenuItem settings)
2888 {
2889 string link = !String.IsNullOrEmpty(settings.Link) ? settings.Link : "#";
2890
2891 if (!String.IsNullOrEmpty(settings.Title)) {
2892 <li class="menu-left__item dw-mod">
2893 <a href="@link" onclick="@settings.OnClick" class="menu-left__link dw-mod">@settings.Title</a>
2894 </li>
2895 }
2896 }
2897 @using System.Reflection
2898 @using Dynamicweb.Rapido.Blocks.Components
2899 @using Dynamicweb.Rapido.Blocks.Components.Articles
2900 @using Dynamicweb.Rapido.Blocks
2901
2902 @* Component for the articles *@
2903
2904 @helper RenderArticleList(ArticleList settings)
2905 {
2906 if (Pageview != null)
2907 {
2908 bool isParagraph = Pageview.CurrentParagraph != null ? true : false;
2909 string[] sortArticlesListBy = new string[2];
2910
2911 if (isParagraph) {
2912 sortArticlesListBy = Pageview.CurrentParagraph.Item["SortArticlesListBy"] != null && !string.IsNullOrEmpty(Pageview.CurrentParagraph.Item["SortArticlesListBy"].ToString()) ? Pageview.CurrentParagraph.Item["SortArticlesListBy"].ToString().Split('+') : new string[] { "Date", "ASC" };
2913 }
2914 else {
2915 sortArticlesListBy = Pageview.Item["SortArticlesListBy"] != null && !string.IsNullOrEmpty(Pageview.Item["SortArticlesListBy"].ToString()) ? Pageview.Item["SortArticlesListBy"].ToString().Split('+') : new string[] { "Date", "ASC" };
2916 }
2917
2918 string sourcePage = settings.SourcePage != null ? settings.SourcePage : Pageview.ID.ToString();
2919
2920 if (!settings.DisablePagination) {
2921 @RenderItemList(new
2922 {
2923 ItemType = !String.IsNullOrEmpty(settings.ItemType) ? settings.ItemType : "DynamicArticle",
2924 ListSourceType = settings.SourceType,
2925 ListSourcePage = sourcePage,
2926 ItemFieldsList = "*",
2927 Filter = settings.Filter,
2928 ListOrderBy = sortArticlesListBy[0],
2929 ListOrderByDirection = sortArticlesListBy[1],
2930 ListSecondOrderBy = sortArticlesListBy[0] == "Date" ? "InFocusSortId" : "Date",
2931 ListSecondOrderByDirection = "ASC",
2932 IncludeAllChildItems = true,
2933 ListTemplate = settings.Template,
2934 ListPageSize = settings.PageSize.ToString()
2935 });
2936 } else {
2937 @RenderItemList(new
2938 {
2939 ItemType = !String.IsNullOrEmpty(settings.ItemType) ? settings.ItemType : "DynamicArticle",
2940 ListSourceType = settings.SourceType,
2941 ListSourcePage = sourcePage,
2942 ItemFieldsList = "*",
2943 Filter = settings.Filter,
2944 ListOrderBy = sortArticlesListBy[0],
2945 ListOrderByDirection = sortArticlesListBy[1],
2946 ListSecondOrderBy = sortArticlesListBy[0] == "Date" ? "InFocusSortId" : "Date",
2947 ListSecondOrderByDirection = "ASC",
2948 IncludeAllChildItems = true,
2949 ListTemplate = settings.Template,
2950 ListPageSize = settings.PageSize.ToString(),
2951 ListViewMode = "Partial",
2952 ListShowTo = settings.PageSize + 1
2953 });
2954 }
2955 }
2956 }
2957 @using System.Reflection
2958 @using Dynamicweb.Rapido.Blocks.Components.Articles
2959
2960
2961 @* Component for the articles *@
2962
2963 @helper RenderArticleSummary(ArticleSummary settings)
2964 {
2965 if (!String.IsNullOrEmpty(settings.Text))
2966 {
2967 <div class="article__summary dw-mod">@settings.Text</div>
2968 }
2969 }
2970 @using System.Reflection
2971 @using Dynamicweb.Rapido.Blocks.Components
2972 @using Dynamicweb.Rapido.Blocks.Components.Articles
2973 @using Dynamicweb.Rapido.Blocks
2974
2975 @* Component for the articles *@
2976
2977 @helper RenderArticleListCategoryFilter(ArticleListCategoryFilter settings)
2978 {
2979 string pageId = Pageview.ID.ToString();
2980 string selectedFilter = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("sourcePage")) ? HttpContext.Current.Request.QueryString.Get("sourcePage") : Translate("All");
2981 var query = HttpUtility.ParseQueryString(HttpContext.Current.Request.QueryString.ToString());
2982
2983 foreach (var option in settings.Categories)
2984 {
2985 selectedFilter = selectedFilter == option.Value ? option.Key : selectedFilter;
2986 }
2987
2988 if (selectedFilter == pageId)
2989 {
2990 selectedFilter = Translate("All");
2991 }
2992
2993 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet")
2994 {
2995 <div class="u-pull--right u-margin-left">
2996 <div class="collection u-no-margin">
2997 <h5>@Translate("Category")</h5>
2998 <input type="checkbox" id="CategorySelector" class="dropdown-trigger" />
2999 <div class="dropdown u-w180px dw-mod">
3000 <label class="dropdown__header dropdown__btn dw-mod" for="CategorySelector">@Translate(selectedFilter)</label>
3001 <div class="dropdown__content dw-mod">
3002 @foreach (var option in settings.Categories)
3003 {
3004 <div class="dropdown__item" onclick="QueryArray.setParametersInCurrentURL({ sourceType: 'Page', sourcePage: '@(option.Key.ToLower() == "all" ? pageId : option.Value)' })">@Translate(option.Key)</div>
3005 }
3006 </div>
3007 <label class="dropdown-trigger-off" for="CategorySelector"></label>
3008 </div>
3009 </div>
3010 </div>
3011 }
3012 else
3013 {
3014 <div class="u-full-width u-margin-bottom">
3015 <h5 class="u-no-margin">@Translate("Category")</h5>
3016 <input type="checkbox" id="CategorySelector" class="dropdown-trigger" />
3017 <div class="dropdown u-full-width dw-mod">
3018 <label class="dropdown__header dropdown__btn dw-mod" for="CategorySelector">@Translate(selectedFilter)</label>
3019 <div class="dropdown__content dw-mod">
3020 @foreach (var option in settings.Categories)
3021 {
3022 <div class="dropdown__item" onclick="QueryArray.setParametersInCurrentURL({ sourceType: 'Page', sourcePage: '@(option.Key.ToLower() == "all" ? pageId : option.Value)' })">@Translate(option.Key)</div>
3023 }
3024 </div>
3025 <label class="dropdown-trigger-off" for="CategorySelector"></label>
3026 </div>
3027 </div>
3028 }
3029 }
3030 @using System.Reflection
3031 @using Dynamicweb.Rapido.Blocks.Components
3032 @using Dynamicweb.Rapido.Blocks.Components.Articles
3033 @using Dynamicweb.Rapido.Blocks
3034 @using System.Collections.Generic
3035
3036 @* Component for the articles *@
3037
3038 @helper RenderArticleListFilter(ArticleListFilter settings)
3039 {
3040 string selectedFilter = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get(settings.SystemName)) ? HttpContext.Current.Request.QueryString.Get(settings.SystemName) : Translate("All");
3041 var query = HttpUtility.ParseQueryString(HttpContext.Current.Request.QueryString.ToString());
3042
3043 if (settings.Options != null)
3044 {
3045 if (settings.Options is IEnumerable<dynamic>)
3046 {
3047 var options = (IEnumerable<dynamic>) settings.Options;
3048 settings.Options = options.OrderBy(item => item.Name);
3049 }
3050
3051 foreach (var option in settings.Options)
3052 {
3053 selectedFilter = selectedFilter == option.Value ? option.Name : selectedFilter;
3054 }
3055
3056 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet")
3057 {
3058 <div class="u-pull--right u-margin-left">
3059 <div class="collection u-no-margin">
3060 <h5>@settings.Label</h5>
3061 <input type="checkbox" id="@(settings.SystemName)Selector" class="dropdown-trigger" />
3062 <div class="dropdown u-w180px dw-mod">
3063 <label class="dropdown__header dropdown__btn dw-mod" for="@(settings.SystemName)Selector">@Translate(selectedFilter)</label>
3064 <div class="dropdown__content dw-mod">
3065 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '')">@Translate("All")</div>
3066 @foreach (var option in settings.Options)
3067 {
3068 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '@option.Value')">@Translate(option.Name)</div>
3069 }
3070 </div>
3071 <label class="dropdown-trigger-off" for="@(settings.SystemName)Selector"></label>
3072 </div>
3073 </div>
3074 </div>
3075 }
3076 else
3077 {
3078 <div class="u-full-width u-margin-bottom">
3079 <h5 class="u-no-margin">@settings.Label</h5>
3080 <input type="checkbox" id="@(settings.SystemName)Selector" class="dropdown-trigger" />
3081 <div class="dropdown u-full-width w-mod">
3082 <label class="dropdown__header dropdown__btn dw-mod" for="@(settings.SystemName)Selector">@Translate(selectedFilter)</label>
3083 <div class="dropdown__content dw-mod">
3084 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '')">@Translate("All")</div>
3085 @foreach (var option in settings.Options)
3086 {
3087 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '@option.Value')">@Translate(option.Name)</div>
3088 }
3089 </div>
3090 <label class="dropdown-trigger-off" for="@(settings.SystemName)Selector"></label>
3091 </div>
3092 </div>
3093 }
3094 }
3095 }
3096 @using System.Reflection
3097 @using Dynamicweb.Rapido.Blocks.Components
3098 @using Dynamicweb.Rapido.Blocks.Components.Articles
3099 @using Dynamicweb.Rapido.Blocks
3100
3101 @* Component for the articles *@
3102
3103 @helper RenderArticleListSearch(ArticleListSearch settings)
3104 {
3105 string searchParameter = !string.IsNullOrEmpty(settings.SearchParameter) ? settings.SearchParameter : "Title";
3106 string searchWord = HttpContext.Current.Request.QueryString.Get(searchParameter);
3107 string searchString = !string.IsNullOrEmpty(searchWord) ? searchWord.Trim('*') : "";
3108 string className = "u-w340px u-pull--right u-margin-left";
3109
3110 if (Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet")
3111 {
3112 className = "u-full-width";
3113 }
3114
3115 <div class="typeahead u-color-inherit u-margin-bottom dw-mod @className">
3116 <input type="text" class="typeahead-search-field u-no-margin dw-mod" placeholder="@Translate("Search in list")" value="@searchString" id="ArticleListSearchInput" onchange="QueryArray.setParameterInCurrentURL('@searchParameter', '*' + document.getElementById('ArticleListSearchInput').value + '*')">
3117 <button type="button" class="btn btn--condensed btn--primary u-no-margin dw-mod"><i class="fas fa-search"></i></button>
3118 </div>
3119 }
3120 @using System.Reflection
3121 @using Dynamicweb.Rapido.Blocks.Components
3122 @using Dynamicweb.Rapido.Blocks.Components.Articles
3123 @using Dynamicweb.Rapido.Blocks
3124
3125 @* Component for the articles *@
3126
3127 @helper RenderArticleListNoResultsInfo(ArticleListNoResultsInfo settings)
3128 {
3129 <div class="u-margin-top--lg u-bold u-ta-center u-bold">@Translate(settings.Message)</div>
3130 }
3131 @using System.Reflection
3132 @using Dynamicweb.Rapido.Blocks.Components
3133 @using Dynamicweb.Rapido.Blocks.Components.General
3134 @using Dynamicweb.Rapido.Blocks.Components.Articles
3135 @using Dynamicweb.Rapido.Blocks
3136 @using System.Text.RegularExpressions
3137
3138 @* Component for the articles *@
3139
3140 @helper RenderArticleListItem(ArticleListItem settings)
3141 {
3142 switch (settings.Type) {
3143 case ArticleListItemType.Card:
3144 @RenderArticleListItemCard(settings);
3145 break;
3146 case ArticleListItemType.List:
3147 @RenderArticleListItemList(settings);
3148 break;
3149 case ArticleListItemType.Simple:
3150 @RenderArticleListItemSimple(settings);
3151 break;
3152 default:
3153 @RenderArticleListItemCard(settings);
3154 break;
3155 }
3156 }
3157
3158 @helper RenderArticleListItemCard(ArticleListItem settings) {
3159 <a href="@settings.Link" class="u-full-height u-color-light--bg u-flex u-flex--column">
3160 <div class="u-color-light--bg u-no-padding dw-mod">
3161 @if (settings.Logo != null)
3162 {
3163 string backgroundImage = settings.Image != null ? "background-image:url(/Admin/Public/GetImage.ashx?width=992&height=760&crop=0&Compression=75&DoNotUpscale=True&image=" + settings.Image.Path + "); background-size: cover;" : "";
3164 settings.Logo.ImageDefault.Crop = 5;
3165 settings.Logo.ImageDefault.Width = settings.Logo.ImageDefault.Width == 1920 ? 240 : settings.Logo.ImageDefault.Width;
3166 settings.Logo.ImageDefault.Height = settings.Logo.ImageDefault.Height == 1080 ? 200 : settings.Logo.ImageDefault.Height;
3167 <div class="image-hover__wrapper layered-image layered-image--tinted dw-mod" style="@backgroundImage">
3168 @if (settings.Stickers != null)
3169 {
3170 if (settings.Stickers.Position != StickersListPosition.Custom && settings.Stickers.Position != StickersListPosition.None)
3171 {
3172 @Render(settings.Stickers);
3173 }
3174 }
3175 @RenderImage(settings.Logo)
3176 </div>
3177 } else if (settings.Image != null)
3178 {
3179 <div class="flex-img image-hover__wrapper u-position-relative dw-mod">
3180 @if (settings.Stickers != null)
3181 {
3182 if (settings.Stickers.Position != StickersListPosition.Custom && settings.Stickers.Position != StickersListPosition.None)
3183 {
3184 @Render(settings.Stickers);
3185 }
3186 }
3187 @Render(settings.Image)
3188 </div>
3189 }
3190 </div>
3191
3192 @if (!String.IsNullOrEmpty(settings.Title) || !String.IsNullOrEmpty(settings.Summary))
3193 {
3194 <div class="card u-color-light--bg u-full-height dw-mod">
3195 @if (settings.Stickers != null)
3196 {
3197 if (settings.Stickers.Position == StickersListPosition.Custom)
3198 {
3199 @Render(settings.Stickers);
3200 }
3201 }
3202 @if (!String.IsNullOrEmpty(settings.Title))
3203 {
3204 <h3 class="article-list__item-header u-truncate-text dw-mod">@settings.Title</h3>
3205 }
3206 @if (!String.IsNullOrEmpty(settings.SubTitle))
3207 {
3208 <div class="article-list__item-micro-info u-truncate-text dw-mod">@settings.SubTitle</div>
3209 }
3210 @if (!String.IsNullOrEmpty(settings.Summary))
3211 {
3212 <p class="article__short-summary dw-mod">@settings.Summary</p>
3213 }
3214 </div>
3215 }
3216 </a>
3217 }
3218
3219 @helper RenderArticleListItemList(ArticleListItem settings) {
3220 <a href="@settings.Link">
3221 <div class="grid u-color-light--bg u-no-padding dw-mod">
3222 <div class="grid__col-md-3">
3223 <div class="u-color-light--bg u-no-padding dw-mod">
3224 @if (settings.Logo != null)
3225 {
3226 string backgroundImage = settings.Image != null ? "background-image:url(/Admin/Public/GetImage.ashx?width=992&height=760&crop=0&Compression=75&DoNotUpscale=True&image=" + settings.Image.Path + "); background-size: cover;" : "";
3227 settings.Logo.ImageDefault.Crop = 5;
3228 settings.Logo.ImageDefault.Width = settings.Logo.ImageDefault.Width == 1920 ? 240 : settings.Logo.ImageDefault.Width;
3229 settings.Logo.ImageDefault.Height = settings.Logo.ImageDefault.Height == 1080 ? 200 : settings.Logo.ImageDefault.Height;
3230 <div class="image-hover__wrapper layered-image layered-image--tinted dw-mod" style="@backgroundImage">
3231 @if (settings.Stickers != null)
3232 {
3233 if (settings.Stickers.Position != StickersListPosition.Custom)
3234 {
3235 @Render(settings.Stickers);
3236 }
3237 }
3238 @RenderImage(settings.Logo)
3239 </div>
3240 } else if (settings.Image != null)
3241 {
3242 <div class="flex-img image-hover__wrapper dw-mod">
3243 @if (settings.Stickers != null)
3244 {
3245 if (settings.Stickers.Position != StickersListPosition.Custom)
3246 {
3247 @Render(settings.Stickers);
3248 }
3249 }
3250 @Render(settings.Image)
3251 </div>
3252 }
3253 </div>
3254 </div>
3255
3256 @if (!String.IsNullOrEmpty(settings.Title) || !String.IsNullOrEmpty(settings.Summary))
3257 {
3258 <div class="grid__col-md-9">
3259 @if (!String.IsNullOrEmpty(settings.Title))
3260 {
3261 <h3 class="article-list__item-header u-truncate-text dw-mod">@settings.Title</h3>
3262 }
3263 @if (settings.Stickers != null)
3264 {
3265 if (settings.Stickers.Position == StickersListPosition.Custom)
3266 {
3267 @Render(settings.Stickers);
3268 }
3269 }
3270 @if (!String.IsNullOrEmpty(settings.SubTitle))
3271 {
3272 <div class="article-list__item-micro-info u-truncate-text dw-mod">@settings.SubTitle</div>
3273 }
3274 @if (!String.IsNullOrEmpty(settings.Summary))
3275 {
3276 <p class="article__short-summary dw-mod">@settings.Summary</p>
3277 }
3278 </div>
3279 }
3280 </div>
3281 </a>
3282 }
3283
3284 @helper RenderArticleListItemSimple(ArticleListItem settings) {
3285 <a href="@settings.Link" class="u-color-inherit">
3286 <div class="grid u-color-light--bg u-no-padding dw-mod">
3287 <div class="grid__col-md-12">
3288 @if (!String.IsNullOrEmpty(settings.Title))
3289 {
3290 <div class="article-list-item__header u-truncate-text u-no-margin dw-mod">@settings.Title</div>
3291 }
3292 @if (!String.IsNullOrEmpty(settings.SubTitle))
3293 {
3294 <div class="article-list__item-micro-info u-truncate-text dw-mod">@settings.SubTitle</div>
3295 }
3296 </div>
3297 </div>
3298 </a>
3299 }
3300 @using System.Reflection
3301 @using Dynamicweb.Rapido.Blocks.Components.Articles
3302
3303
3304 @* Component for the articles *@
3305
3306 @helper RenderArticleAuthorAndDate(ArticleAuthorAndDate settings)
3307 {
3308 <small class="article__subscription">
3309 @if (!(string.IsNullOrWhiteSpace(settings.Author) && string.IsNullOrWhiteSpace(settings.Date)))
3310 {
3311 <text>@Translate("Written")</text>
3312 }
3313 @if (!string.IsNullOrWhiteSpace(settings.Author))
3314 {
3315 <text>@Translate("by") @settings.Author</text>
3316 }
3317 @if (!string.IsNullOrWhiteSpace(settings.Date))
3318 {
3319 <text>@Translate("on") @settings.Date</text>
3320 }
3321 </small>
3322 }
3323 @using System.Reflection
3324 @using Dynamicweb.Rapido.Blocks.Components.Articles
3325 @using Dynamicweb.Rapido.Blocks.Components.General
3326
3327
3328 @* Component for the articles *@
3329
3330 @helper RenderArticleLink(ArticleLink settings)
3331 {
3332 if (!string.IsNullOrEmpty(settings.Title))
3333 {
3334 Button link = new Button {
3335 ConfirmText = settings.ConfirmText,
3336 ConfirmTitle = settings.ConfirmTitle,
3337 ButtonType = settings.ButtonType,
3338 Id = settings.Id,
3339 Title = settings.Title,
3340 AltText = settings.AltText,
3341 OnClick = settings.OnClick,
3342 CssClass = settings.CssClass,
3343 Disabled = settings.Disabled,
3344 Icon = settings.Icon,
3345 Name = settings.Name,
3346 Href = settings.Href,
3347 ButtonLayout = settings.ButtonLayout,
3348 ExtraAttributes = settings.ExtraAttributes
3349 };
3350 <div class="grid__cell">
3351 @Render(link)
3352 </div>
3353 }
3354 }
3355 @using System.Reflection
3356 @using Dynamicweb.Rapido.Blocks
3357 @using Dynamicweb.Rapido.Blocks.Components.Articles
3358 @using Dynamicweb.Rapido.Blocks.Components.General
3359
3360
3361 @* Component for the articles *@
3362
3363 @helper RenderArticleCarousel(ArticleCarousel settings)
3364 {
3365 <div class="grid">
3366 <div class="grid__col-12 u-no-padding u-margin-bottom">
3367 <div class="carousel" id="carousel_@settings.Id">
3368 <div class="carousel__container js-carousel-slides dw-mod">
3369 @RenderBlockList(settings.SubBlocks)
3370 </div>
3371 </div>
3372 </div>
3373 </div>
3374
3375 <script>
3376 document.addEventListener("DOMContentLoaded", function () {
3377 new CarouselModule("#carousel_@settings.Id", {
3378 slideTime: 0,
3379 dots: true
3380 });
3381 });
3382 </script>
3383 }
3384
3385 @helper RenderArticleCarouselSlide(ArticleCarouselSlide settings)
3386 {
3387 string imageEngine = "/Admin/Public/GetImage.ashx?";
3388
3389 string defaultImage = settings.ImageSettings != null ? imageEngine : settings.Image;
3390 if (settings.ImageSettings != null)
3391 {
3392 defaultImage += settings.ImageSettings.Width != 0 ? "Width=" + settings.ImageSettings.Width + "&" : "";
3393 defaultImage += settings.ImageSettings.Height != 0 ? "Height=" + settings.ImageSettings.Height + "&" : "";
3394 defaultImage += "Crop=" + settings.ImageSettings.Crop + "&";
3395 defaultImage += "Compression=" + settings.ImageSettings.Compression + "&";
3396 defaultImage += "DoNotUpscale=" + settings.ImageSettings.DoNotUpscale.ToString() + "&";
3397 defaultImage += "FillCanvas=" + settings.ImageSettings.FillCanvas.ToString() + "&";
3398 }
3399 defaultImage += "&Image=" + settings.Image;
3400
3401 <div class="carousel__slide u-min-h300px u-flex dw-mod" style="background-size:cover; background-image:url('@defaultImage')">
3402 <a class="article-carousel-item__wrap" href="@settings.Link" title="@settings.Title">
3403 <h2 class="article-list__item-header u-truncate-text u-color-light dw-mod">@settings.Title</h2>
3404 <div class="article-list__item-info">
3405 @if (settings.Stickers != null)
3406 {
3407 settings.Stickers.Position = StickersListPosition.Custom;
3408 @Render(settings.Stickers);
3409 }
3410
3411 <small class="u-margin-top--lg u-color-light">
3412 @if (!(string.IsNullOrWhiteSpace(settings.Author) && string.IsNullOrWhiteSpace(settings.Date)))
3413 {
3414 <text>@Translate("Written")</text>
3415 }
3416 @if (!string.IsNullOrWhiteSpace(settings.Author))
3417 {
3418 <text>@Translate("by") @settings.Author</text>
3419 }
3420 @if (!string.IsNullOrWhiteSpace(settings.Date))
3421 {
3422 <text>@Translate("on") @settings.Date</text>
3423 }
3424 </small>
3425 </div>
3426
3427 <h3 class="article__short-summary u-color-light">@settings.Summary</h3>
3428 </a>
3429 @if (settings.UseFilters == true)
3430 {
3431 <div class="background-image image-filter image-filter--darken dw-mod"></div>
3432 }
3433 </div>
3434 }
3435 @using System.Text.RegularExpressions
3436 @using Dynamicweb.Rapido.Blocks.Components
3437 @using Dynamicweb.Rapido.Blocks.Components.General
3438 @using Dynamicweb.Rapido.Blocks.Components.Articles
3439 @using Dynamicweb.Rapido.Blocks
3440
3441 @* Component for the articles *@
3442
3443 @helper RenderArticleVideo(ArticleVideo settings)
3444 {
3445 if (settings.Url != null)
3446 {
3447 //getting video ID from youtube URL
3448 string videoCode = settings.Url;
3449 Regex regex = new Regex(@".be\/(.[^?]*)");
3450 Match match = regex.Match(videoCode);
3451 string videoId = "";
3452 if (match.Success)
3453 {
3454 videoId = match.Groups[1].Value;
3455 }
3456 else
3457 {
3458 regex = new Regex(@"v=([^&]+)");
3459 match = regex.Match(videoCode);
3460 if (match.Success)
3461 {
3462 videoId = match.Groups[1].Value;
3463 }
3464 }
3465
3466 int autoPlay = settings.AutoPlay == "true" ? 1 : 0;
3467
3468 <div class="video-wrapper">
3469 <div class="js-youtube-video" data-video="@videoId" id="ytPlayer@(Guid.NewGuid().ToString("N"))" data-auto-play="@autoPlay" data-enable-controls="1"></div>
3470 </div>
3471 }
3472 }
3473
3474
3475
3476 @* Simple helpers *@
3477
3478 @*Requires the Gallery ItemType that comes with Rapido*@
3479 @helper RenderArticleItemGallery(IList<ItemViewModel> gallery) {
3480 if (gallery != null && gallery.Count > 0)
3481 {
3482 int count = 1;
3483
3484 foreach (var item in gallery)
3485 {
3486 if (item.GetFile("ImagePath") != null)
3487 {
3488 string image = item.GetFile("ImagePath").PathUrlEncoded;
3489 string imagePrefix = "/Admin/Public/GetImage.ashx?width=1200&height=820&crop=5&Compression=75&DoNotUpscale=1&image=";
3490 int imagesCount = gallery.Count;
3491
3492 if (count == 1)
3493 {
3494 <label class="gallery" for="ParagraphGalleryModalTrigger" onclick="Gallery.openImage(this.querySelector('.js-gallery'))">
3495 <span class="gallery__main-image">
3496 <img src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=992&height=760&crop=0&Compression=75&DoNotUpscale=1&image=@image" class="b-lazy flex-img js-gallery" alt="" data-for="ParagraphGallery" data-image="@imagePrefix@image" />
3497 </span>
3498 <span class="gallery__image-counter">
3499 <i class="fas fa-camera fa-2x"></i> <span class="gallery__image-counter__number">@imagesCount</span>
3500 <span class="gallery__image-counter__text">@Translate("See all") <i class="fas fa-angle-right"></i></span>
3501 </span>
3502 </label>
3503 }
3504 else
3505 {
3506 <div class="u-hidden js-gallery" data-for="ParagraphGallery" data-image="@imagePrefix@image"></div>
3507 }
3508
3509 count++;
3510 }
3511 }
3512
3513 @Render(new ArticleGalleryModal())
3514 }
3515 }
3516
3517 @helper RenderMobileFilters(List<Block> subBlocks)
3518 {
3519 if (subBlocks.Count > 0)
3520 {
3521 <div class="grid__col-12">
3522 <input type="checkbox" id="CheckFilters" class="js-remember-state u-hidden" data-expand="CheckFilters" />
3523 <div class="grid u-margin-bottom dw-mod" data-trigger="CheckFilters">
3524 @RenderBlockList(subBlocks)
3525 </div>
3526 <label for="CheckFilters" class="btn btn--secondary btn--full dw-mod js-expand-hide" data-trigger="CheckFilters">@Translate("Select filters")</label>
3527 <label for="CheckFilters" class="btn btn--secondary btn--full dw-mod expandable--collapsed" data-trigger="CheckFilters">@Translate("Close filters")</label>
3528 </div>
3529 }
3530 }
3531
3532
3533 @* Include the Blocks for the page *@
3534 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
3535
3536 @using System
3537 @using System.Web
3538 @using System.Collections.Generic
3539 @using Dynamicweb.Rapido.Blocks.Extensibility
3540 @using Dynamicweb.Rapido.Blocks
3541 @using Dynamicweb.Environment
3542
3543 @functions {
3544 string GoogleTagManagerID = "";
3545 string GoogleAnalyticsID = "";
3546 }
3547
3548 @{
3549 GoogleTagManagerID = Model.Area.Item.GetItem("Settings").GetString("GoogleTagManagerID");
3550 GoogleAnalyticsID = Model.Area.Item.GetItem("Settings").GetString("GoogleAnalyticsTrackingID");
3551
3552 BlocksPage topSnippetsBlocksPage = BlocksPage.GetBlockPage("Master");
3553
3554 if (!string.IsNullOrWhiteSpace(GoogleAnalyticsID))
3555 {
3556 Block tagManager = new Block()
3557 {
3558 Id = "GoogleAnalytics",
3559 SortId = 0,
3560 Template = RenderGoogleAnalyticsSnippet()
3561 };
3562 topSnippetsBlocksPage.Add("Head", tagManager);
3563 }
3564
3565 if (!string.IsNullOrWhiteSpace(GoogleTagManagerID))
3566 {
3567 Block tagManager = new Block()
3568 {
3569 Id = "TagManager",
3570 SortId = 1,
3571 Template = RenderGoogleTagManager()
3572 };
3573 topSnippetsBlocksPage.Add("Head", tagManager);
3574
3575 Block tagManagerBodySnippet = new Block()
3576 {
3577 Id = "TagManagerBodySnippet",
3578 SortId = 1,
3579 Template = RenderGoogleTagManagerBodySnippet()
3580 };
3581 topSnippetsBlocksPage.Add(MasterBlockId.MasterTopSnippets, tagManagerBodySnippet);
3582 }
3583
3584 Block facebookPixel = new Block()
3585 {
3586 Id = "FacebookPixel",
3587 SortId = 2,
3588 Template = RenderFacebookPixel()
3589 };
3590
3591 topSnippetsBlocksPage.Add(MasterBlockId.MasterTopSnippets, facebookPixel);
3592 }
3593
3594 @helper RenderGoogleAnalyticsSnippet()
3595 {
3596 @*List<string> AllowedCookieCategories = new List<string>() { "Essential" };
3597 foreach (string s in CookieManager.GetCategories())
3598 {
3599 if (s == "Essential")
3600 {
3601 continue;
3602 }
3603 else if (CookieManager.CookieOptInLevelExists && (CookieManager.GetCookieOptInLevel() == CookieOptInLevel.All || (CookieManager.CookieOptInLevelExists && System.Web.HttpContext.Current.Request.Cookies.Get("Dynamicweb.CookieOptInLevel").Value.IndexOf(s) > -1)))
3604 {
3605 AllowedCookieCategories.Add(s);
3606 }
3607 }
3608
3609 if (AllowedCookieCategories.Contains("Statistical"))
3610 {*@
3611 <!-- Global site tag (gtag.js) - Google Analytics -->
3612 <script async src="https://www.googletagmanager.com/gtag/js?id=@GoogleAnalyticsID"></script>
3613 <script>
3614 window.dataLayer = window.dataLayer || [];
3615 function gtag(){dataLayer.push(arguments);}
3616 gtag('js', new Date());
3617
3618 gtag('config', '@GoogleAnalyticsID');
3619 </script>
3620 @*}*@
3621
3622 }
3623
3624 @helper RenderGoogleTagManager()
3625 {
3626 @*IList<string> AllowedCookieCategories = new List<string>() { "Essential" };
3627 foreach (string s in CookieManager.GetCategories())
3628 {
3629 if (s == "Essential")
3630 {
3631 continue;
3632 }
3633 else if (CookieManager.CookieOptInLevelExists && (CookieManager.GetCookieOptInLevel() == CookieOptInLevel.All || (CookieManager.CookieOptInLevelExists && System.Web.HttpContext.Current.Request.Cookies.Get("Dynamicweb.CookieOptInLevel").Value.IndexOf(s) > -1)))
3634 {
3635 AllowedCookieCategories.Add(s);
3636 }
3637 }
3638
3639 if (AllowedCookieCategories.Contains("Statistical"))
3640 {*@
3641 <script>
3642 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
3643 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
3644 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
3645 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
3646 })(window,document,'script','dataLayer','@GoogleTagManagerID');
3647 </script>
3648 @*}*@
3649 }
3650
3651 @helper RenderGoogleTagManagerBodySnippet()
3652 {
3653 @*IList<string> AllowedCookieCategories = new List<string>() { "Essential" };
3654 foreach (string s in CookieManager.GetCategories())
3655 {
3656 if (s == "Essential")
3657 {
3658 continue;
3659 }
3660 else if (CookieManager.CookieOptInLevelExists && (CookieManager.GetCookieOptInLevel() == CookieOptInLevel.All || (CookieManager.CookieOptInLevelExists && System.Web.HttpContext.Current.Request.Cookies.Get("Dynamicweb.CookieOptInLevel").Value.IndexOf(s) > -1)))
3661 {
3662 AllowedCookieCategories.Add(s);
3663 }
3664 }
3665
3666 if (AllowedCookieCategories.Contains("Statistical"))
3667 {*@
3668 <!-- Google Tag Manager (noscript) -->
3669 <noscript>
3670 <iframe src="https://www.googletagmanager.com/ns.html?id=@GoogleTagManagerID"
3671 height="0" width="0" style="display:none;visibility:hidden"></iframe>
3672 </noscript>
3673 <!-- End Google Tag Manager (noscript) -->
3674 @*}*@
3675 }
3676
3677 @helper RenderFacebookPixel()
3678 {
3679 string FacebookPixelID = Model.Area.Item.GetItem("Settings").GetString("FacebookPixelID");
3680
3681 @*IList<string> AllowedCookieCategories = new List<string>() { "Essential" };
3682 foreach (string s in CookieManager.GetCategories())
3683 {
3684 if (s == "Essential")
3685 {
3686 continue;
3687 }
3688 else if (CookieManager.CookieOptInLevelExists && (CookieManager.GetCookieOptInLevel() == CookieOptInLevel.All || (CookieManager.CookieOptInLevelExists && System.Web.HttpContext.Current.Request.Cookies.Get("Dynamicweb.CookieOptInLevel").Value.IndexOf(s) > -1)))
3689 {
3690 AllowedCookieCategories.Add(s);
3691 }
3692 }
3693
3694 if (AllowedCookieCategories.Contains("Marketing"))
3695 {*@
3696 if (!string.IsNullOrWhiteSpace(FacebookPixelID))
3697 {
3698 <!-- Facebook Pixel Code -->
3699 <script>
3700 !function(f,b,e,v,n,t,s)
3701 {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
3702 n.callMethod.apply(n,arguments):n.queue.push(arguments)};
3703 if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
3704 n.queue=[];t=b.createElement(e);t.async=!0;
3705 t.src=v;s=b.getElementsByTagName(e)[0];
3706 s.parentNode.insertBefore(t,s)}(window, document,'script',
3707 'https://connect.facebook.net/en_US/fbevents.js');
3708 fbq('init', '@FacebookPixelID');
3709 fbq('track', 'PageView');
3710 </script>
3711 <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=@FacebookPixelID&ev=PageView&noscript=1" alt="" /></noscript>
3712 <!-- End Facebook Pixel Code -->
3713 }
3714 @*}*@
3715
3716 }
3717 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
3718
3719 @using System
3720 @using System.Web
3721 @using System.Collections.Generic
3722 @using Dynamicweb.Rapido.Blocks
3723 @using Dynamicweb.Rapido.Blocks.Extensibility
3724 @using Dynamicweb.Security.UserManagement
3725 @using Dynamicweb.Security.UserManagement.ExternalAuthentication
3726 @using Dynamicweb.Rapido.Blocks.Components.General
3727
3728 @{
3729 BlocksPage loginBlocksPage = BlocksPage.GetBlockPage("Master");
3730
3731 Block loginModal = new Block()
3732 {
3733 Id = "LoginModal",
3734 SortId = 10,
3735 Component = new Modal
3736 {
3737 Id = "SignIn",
3738 Heading = new Heading
3739 {
3740 Level = 0,
3741 Title = Translate("Sign in")
3742 },
3743 Width = ModalWidth.Sm,
3744 BodyTemplate = RenderLoginForm()
3745 }
3746 };
3747
3748 loginBlocksPage.Add(MasterBlockId.MasterTopSnippets, loginModal);
3749 }
3750
3751 @helper RenderLoginForm()
3752 {
3753 int pageId = Model.TopPage.ID;
3754 string userSignedInErrorText = "";
3755 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
3756 string forgotPasswordPageLink = "/Default.aspx?ID=" + signInProfilePageId + "&LoginAction=Recovery";
3757 int createAccountPageId = GetPageIdByNavigationTag("CreateAccount");
3758 bool showModalOnStart = pageId != GetPageIdByNavigationTag("CustomerCenter") && Model.LogOnFailed;
3759 bool hideCreateAccountLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideCreateAccount");
3760 bool hideForgotPasswordLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideForgotPasswordLink");
3761
3762 ProviderCollection providers = Provider.GetActiveProviders();
3763
3764 if (Model.LogOnFailed)
3765 {
3766 switch (Model.LogOnFailedReason)
3767 {
3768 case LogOnFailedReason.PasswordLengthInvalid:
3769 userSignedInErrorText = Translate("Password length is invalid");
3770 break;
3771 case LogOnFailedReason.IncorrectLogin:
3772 userSignedInErrorText = Translate("Invalid email or password");
3773 break;
3774 case LogOnFailedReason.ExceededFailedLogOnLimit:
3775 userSignedInErrorText = Translate("You have exceeded the limit of allowed login attempts. The user account is temporarily locked");
3776 break;
3777 case LogOnFailedReason.LoginLocked:
3778 userSignedInErrorText = Translate("The user account is temporarily locked");
3779 break;
3780 case LogOnFailedReason.PasswordExpired:
3781 userSignedInErrorText = Translate("The password has expired and needs to be renewed");
3782 break;
3783 default:
3784 userSignedInErrorText = Translate("An unknown error occured");
3785 break;
3786 }
3787 }
3788
3789 Form form = new Form { Method = FormMethod.Post, Name = "LoginModalForm", ExtraAttributes = new Dictionary<string, string>{ { "id", "login-modal-form-" + pageId } } };
3790
3791 TextField passwordField = new TextField { Id = "login-password", Type = TextFieldType.Password, Name = "password", Label = Translate("Password"), Required = true };
3792
3793 if (!hideForgotPasswordLink) {
3794 passwordField.Link = new Link { Title = Translate("Forgot password?"), Href = "/Default.aspx?id=" + signInProfilePageId + "&LoginAction=Recovery" };
3795 }
3796
3797 form.Add(new HiddenField { Name = "ID", Value = Converter.ToString(pageId) });
3798 form.Add(new HiddenField { Name = "DWExtranetUsernameRemember", Value = "True" });
3799 form.Add(new HiddenField { Name = "DWExtranetPasswordRemember", Value = "True" });
3800 form.Add(new HiddenField { Name = "LoginAction", Value = "Login" });
3801 form.Add(new TextField { Id = "LoginUsername", Name = "username", Label = Translate("Email"), CssClass = "u-full-width", Required = true });
3802 form.Add(passwordField);
3803 form.Add(new NotificationMessage { Message = userSignedInErrorText, MessageType = NotificationMessageType.Error });
3804 form.Add(new CheckboxField { Id = "LoginRememberMe", Value = "True", Name = "Autologin", Label = Translate("Remember me") });
3805 form.Add(new Button { ButtonType = ButtonType.Submit, Title = Translate("Sign in"), CssClass = "btn--full", OnClick = "Buttons.LockButton(event)" });
3806
3807 form.Add(new Text { Content = "<div class=\"login-error-wrapper\"></div>" });
3808
3809 foreach (Provider LoginProvider in providers)
3810 {
3811 var ProviderName = LoginProvider.Name.ToLower();
3812 form.Add(new Link {
3813 Href = "/Admin/Public/Social/ExternalLogin.aspx?action=login&providerID=" + LoginProvider.ID,
3814 Icon = new Icon { Prefix = "fab", Name = "fa-" + ProviderName, CssClass = "fa-1_5x", LabelPosition = IconLabelPosition.After },
3815 ButtonLayout = ButtonLayout.LinkClean,
3816 CssClass = "btn--condensed u-margin-bottom u-margin-right u-inline-block u-color-" + ProviderName,
3817 AltText = ProviderName
3818 });
3819 }
3820
3821 if (!hideCreateAccountLink) {
3822 form.Add(new Text { Content = "<div class=\"u-border-top u-full-width u-margin-bottom--lg\"></div>" });
3823 form.Add(new Link
3824 {
3825 Href = "/Default.aspx?id=" + createAccountPageId,
3826 ButtonLayout = ButtonLayout.LinkClean,
3827 Title = Translate("Create account"),
3828 CssClass = "u-full-width u-ta-center"
3829 });
3830 }
3831
3832 @Render(form)
3833
3834 <script>
3835 window.addEventListener('load', function() {
3836 var $form = document.getElementById('login-modal-form-@(pageId)');
3837 var $errorWrapper = $form.querySelector('.login-error-wrapper');
3838 var $btnSubmit = $form.querySelector('button[type="submit"]');
3839
3840 var errors = @(Gobo.Common.ToJson(new {
3841 UserNotFound = Translate("CheckLogin:UserNotFound", "User not found"),
3842 NoAccess = Translate("CheckLogin:NoAccess", "No access"),
3843 AreaNotFound = Translate("CheckLogin:AreaNotFound", "Area not found"),
3844 NoAccessToTheArea = Translate("CheckLogin:NoAccessToTheArea", "No access to the area")
3845 }));
3846
3847 $form.addEventListener('submit', function(evt) {
3848 evt.preventDefault();
3849
3850 $errorWrapper.innerHTML = '';
3851
3852 var username = $form.querySelector('input[name="username"]').value;
3853
3854 Request.Fetch().post('/Files/Handlers/MiscHandler.ashx?methodName=CheckLogin', { username: username }, function(data) {
3855 if (data === true) {
3856 setTimeout(function() {
3857 evt.target.submit();
3858 }, 400);
3859 return;
3860 }
3861
3862 if (data.Error) {
3863 var error = '<div class="u-full-width u-margin-bottom--lg u-color-warning--bg u-padding u-bold">';
3864
3865 error += (data.Error in errors) ? errors[data.Error] : data.Error;
3866 if (data.LoginUrl)
3867 error += ' <a href="' + data.LoginUrl + '">' + data.LoginUrl + '</a>';
3868 error += '</div>';
3869
3870 $errorWrapper.innerHTML = error;
3871
3872 setTimeout(function () {
3873 $btnSubmit.classList.remove('disabled');
3874 $btnSubmit.disabled = false;
3875 $btnSubmit.innerHTML = '@(Translate("Sign in"))';
3876 $btnSubmit.style.removeProperty('width');
3877 }, 400);
3878 }
3879 });
3880 });
3881 });
3882 </script>
3883
3884 if (showModalOnStart)
3885 {
3886 <script>
3887 document.getElementById("SignInModalTrigger").checked = true;
3888 </script>
3889 }
3890 }
3891
3892 @if (Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet")
3893 {
3894 <text>@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
3895
3896 @using System
3897 @using System.Web
3898 @using System.Collections.Generic
3899 @using Dynamicweb.Rapido.Blocks.Extensibility
3900 @using Dynamicweb.Rapido.Blocks
3901 @using Dynamicweb.Rapido.Services
3902
3903
3904 @functions {
3905 BlocksPage mobileHeaderBlocksPage = BlocksPage.GetBlockPage("Master");
3906 }
3907
3908 @{
3909 var mobileTopLayout = !String.IsNullOrEmpty(Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetString("Design")) ? Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetList("Design").SelectedValue : "nav-left";
3910 bool mobileHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch");
3911 bool mobileHideCart = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart") || !Dynamicweb.Rapido.Services.User.IsBuyingAllowed();
3912
3913 if (!mobileHideCart) {
3914 mobileHideCart = Gobo.UserService.IsInGroup_GuestAccounts(Dynamicweb.Security.UserManagement.User.GetCurrentExtranetUser());
3915 }
3916
3917 Block mobileHeader = new Block()
3918 {
3919 Id = "MobileTop",
3920 SortId = 10,
3921 Template = RenderMobileTop(),
3922 SkipRenderBlocksList = true
3923 };
3924 mobileHeaderBlocksPage.Add(MasterBlockId.MasterHeader, mobileHeader);
3925
3926 Block mobileHeaderNavigation = new Block()
3927 {
3928 Id = "MobileHeaderNavigation",
3929 SortId = 10,
3930 Template = RenderMobileHeaderNavigation(),
3931 SkipRenderBlocksList = true,
3932 BlocksList = new List<Block> {
3933 new Block {
3934 Id = "MobileHeaderNavigationTrigger",
3935 SortId = 10,
3936 Template = RenderMobileHeaderNavigationTrigger()
3937 }
3938 }
3939 };
3940 mobileHeaderBlocksPage.Add("MobileTop", mobileHeaderNavigation);
3941
3942 Block mobileHeaderLogo = new Block()
3943 {
3944 Id = "MobileHeaderLogo",
3945 SortId = 20,
3946 Template = RenderMobileHeaderLogo(),
3947 SkipRenderBlocksList = true
3948 };
3949 mobileHeaderBlocksPage.Add("MobileTop", mobileHeaderLogo);
3950
3951 Block mobileHeaderActions = new Block()
3952 {
3953 Id = "MobileHeaderActions",
3954 SortId = 30,
3955 Template = RenderMobileTopActions(),
3956 SkipRenderBlocksList = true
3957 };
3958 mobileHeaderBlocksPage.Add("MobileTop", mobileHeaderActions);
3959
3960 if (!mobileHideSearch)
3961 {
3962 Block mobileHeaderSearch = new Block
3963 {
3964 Id = "MobileHeaderSearch",
3965 SortId = 10,
3966 Template = RenderMobileTopSearch()
3967 };
3968 mobileHeaderBlocksPage.Add("MobileHeaderActions", mobileHeaderSearch);
3969 }
3970
3971 Block mobileHeaderMiniCart;
3972
3973 if (!mobileHideCart)
3974 {
3975 mobileHeaderMiniCart = new Block
3976 {
3977 Id = "MobileHeaderMiniCart",
3978 SortId = 20,
3979 Template = RenderMobileTopMiniCart()
3980 };
3981
3982 Block miniCartCounterScriptTemplate = new Block
3983 {
3984 Id = "MiniCartCounterScriptTemplate",
3985 Template = RenderMobileMiniCartCounterContent()
3986 };
3987 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", miniCartCounterScriptTemplate);
3988 }
3989 else
3990 {
3991 mobileHeaderMiniCart = new Block
3992 {
3993 Id = "MobileHeaderMiniCart",
3994 SortId = 20
3995 };
3996 }
3997
3998 if (!mobileHideSearch)
3999 {
4000 Block mobileHeaderSearchBar = new Block()
4001 {
4002 Id = "MobileHeaderSearchBar",
4003 SortId = 30,
4004 Template = RenderMobileTopSearchBar()
4005 };
4006 mobileHeaderBlocksPage.Add(MasterBlockId.MasterHeader, mobileHeaderSearchBar);
4007 }
4008
4009 switch (mobileTopLayout)
4010 {
4011 case "nav-left":
4012 mobileHeaderNavigation.SortId = 10;
4013 mobileHeaderLogo.SortId = 20;
4014 mobileHeaderActions.SortId = 30;
4015 mobileHeaderBlocksPage.Add("MobileHeaderActions", mobileHeaderMiniCart);
4016 break;
4017 case "nav-right":
4018 mobileHeaderLogo.SortId = 10;
4019 mobileHeaderActions.SortId = 20;
4020 mobileHeaderNavigation.SortId = 30;
4021 mobileHeaderBlocksPage.Add("MobileHeaderActions", mobileHeaderMiniCart);
4022 break;
4023 case "nav-search-left":
4024 mobileHeaderNavigation.SortId = 10;
4025 mobileHeaderLogo.SortId = 20;
4026 mobileHeaderActions.SortId = 30;
4027 mobileHeaderBlocksPage.Add("MobileHeaderNavigation", mobileHeaderMiniCart);
4028 break;
4029 case "search-left":
4030 mobileHeaderActions.SortId = 10;
4031 mobileHeaderLogo.SortId = 20;
4032 mobileHeaderNavigation.SortId = 30;
4033 mobileHeaderMiniCart.SortId = 0;
4034 mobileHeaderBlocksPage.Add("MobileHeaderNavigation", mobileHeaderMiniCart);
4035 break;
4036 }
4037 }
4038
4039
4040 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4041
4042 @using System
4043 @using System.Web
4044 @using Dynamicweb.Rapido.Blocks.Extensibility
4045 @using Dynamicweb.Rapido.Blocks
4046
4047 @{
4048 BlocksPage customMobileHeaderBlocksPage = BlocksPage.GetBlockPage("Master");
4049 }
4050
4051
4052
4053
4054 @helper RenderMobileTop() {
4055 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileTop").OrderBy(item => item.SortId).ToList();
4056
4057 <nav class="main-navigation-mobile dw-mod">
4058 <div class="center-container top-container__center-container dw-mod">
4059 <div class="grid grid--align-center">
4060 @RenderBlockList(subBlocks)
4061 </div>
4062 </div>
4063 </nav>
4064 }
4065
4066 @helper RenderMobileHeaderNavigation() {
4067 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileHeaderNavigation").OrderBy(item => item.SortId).ToList();
4068
4069 <div class="grid__col-auto-width">
4070 <ul class="menu dw-mod">
4071 @RenderBlockList(subBlocks)
4072 </ul>
4073 </div>
4074 }
4075
4076 @helper RenderMobileHeaderNavigationTrigger() {
4077 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod">
4078 <label for="MobileNavTrigger" class="mobile-nav-trigger-button menu__link menu__link--icon menu__link--mobile dw-mod"></label>
4079 </li>
4080 }
4081
4082 @helper RenderMobileHeaderLogo() {
4083 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileHeaderLogo").OrderBy(item => item.SortId).ToList();
4084
4085 var mobileTopLayout = !String.IsNullOrEmpty(Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetString("Design")) ? Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetList("Design").SelectedValue : "nav-left";
4086 string centeredLogo = mobileTopLayout != "nav-right" ? "u-ta-center" : "";
4087 string firstPageId = Model.Area.FirstActivePage.ID.ToString();
4088 string businessName = Model.Area.Item.GetItem("Settings").GetString("BusinessName");
4089
4090 string mobileLogo = "/Files/Images/logo-dynamicweb.png";
4091 if (Model.Area.Item.GetItem("Layout").GetItem("MobileTop") != null && Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetFile("Logo") != null)
4092 {
4093 mobileLogo = Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetFile("Logo").PathUrlEncoded;
4094 }
4095
4096 if (Path.GetExtension(mobileLogo).ToLower() != ".svg")
4097 {
4098 mobileLogo = "/Admin/Public/GetImage.ashx?height=40&width=100&crop=5&Compression=75&image=" + mobileLogo;
4099 }
4100 else
4101 {
4102 mobileLogo = HttpUtility.UrlDecode(mobileLogo);
4103 }
4104
4105 <div class="grid__col-auto grid__col--bleed">
4106 <div class="grid__cell @centeredLogo">
4107 <a href="/Default.aspx?ID=@firstPageId" class="logo logo--mobile u-inline-block dw-mod">
4108 <img class="grid__cell-img logo__img logo__img--mobile dw-mod" src="@mobileLogo" alt="@businessName" />
4109 </a>
4110 </div>
4111
4112 @RenderBlockList(subBlocks)
4113 </div>
4114 }
4115
4116 @helper RenderMobileTopActions() {
4117 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileHeaderActions").OrderBy(item => item.SortId).ToList();
4118
4119 <div class="grid__col-auto-width">
4120 <ul class="menu dw-mod">
4121 @RenderBlockList(subBlocks)
4122 </ul>
4123 </div>
4124 }
4125
4126 @helper RenderMobileTopSearch() {
4127 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod">
4128 <label for="MobileSearchTrigger" class="menu__link menu__link--icon menu__link--mobile dw-mod">
4129 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue fa-1_5x"></i>
4130 </label>
4131 </li>
4132 }
4133
4134 @helper RenderMobileTopMiniCart() {
4135 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
4136 int cartPageId = GetPageIdByNavigationTag("CartPage");
4137 double cartProductsCount = Model.Cart.TotalProductsCount;
4138
4139 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod" id="miniCartWrapper">
4140 <div class="mini-cart dw-mod">
4141 <a href="/Default.aspx?ID=@cartPageId&Purge=True" id="miniCartCounterWrap" class="menu__link menu__link--icon menu__link--mobile dw-mod js-mini-cart-button">
4142 <div class="u-inline u-position-relative">
4143 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue fa-1_5x"></i>
4144 <div class="mini-cart__counter dw-mod">
4145 <div class="js-handlebars-root js-mini-cart-counter" id="cartCounter" data-template="MiniCartCounterContent" data-json-feed="/Default.aspx?ID=@miniCartFeedPageId&feedType=Counter" data-init-onload="false" data-preloader="false">
4146 <div class="js-mini-cart-counter-content" data-count="@cartProductsCount">
4147 @cartProductsCount
4148 </div>
4149 </div>
4150 </div>
4151 </div>
4152 </a>
4153 </div>
4154 </li>
4155 }
4156
4157 @helper RenderMobileTopSearchBar()
4158 {
4159 string searchFeedId = "";
4160 string searchSecondFeedId = "";
4161 int groupsFeedId;
4162 int productsPageId = GetPageIdByNavigationTag("ProductsPage");
4163 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID;
4164 string resultPageLink;
4165 string searchPlaceholder;
4166 string searchType = "product-search";
4167 string searchTemplate;
4168 string searchContentTemplate = "";
4169 string searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? "";
4170 bool showGroups = true;
4171
4172 if (Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue == "contentSearch")
4173 {
4174 searchFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true";
4175 resultPageLink = contentSearchPageLink;
4176 searchPlaceholder = Translate("Search page");
4177 groupsFeedId = 0;
4178 searchType = "content-search";
4179 searchTemplate = "SearchPagesTemplate";
4180 showGroups = false;
4181 }
4182 else if (Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue == "combinedSearch")
4183 {
4184 searchFeedId = productsPageId + "&feed=true";
4185 searchSecondFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true";
4186 resultPageLink = Converter.ToString(productsPageId);
4187 searchPlaceholder = Translate("Search products or pages");
4188 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed");
4189 searchType = "combined-search";
4190 searchTemplate = "SearchProductsTemplateWrap";
4191 searchContentTemplate = "SearchPagesTemplateWrap";
4192 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector");
4193 }
4194 else
4195 {
4196 resultPageLink = Converter.ToString(productsPageId);
4197 searchFeedId = productsPageId + "&feed=true";
4198 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed");
4199 searchPlaceholder = Translate("Search products");
4200 searchTemplate = "SearchProductsTemplate";
4201 searchType = "product-search";
4202 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector");
4203 }
4204
4205 <input type="checkbox" id="MobileSearchTrigger" class="mobile-search-trigger" />
4206
4207 <div class="main-navigation-mobile typeahead-mobile dw-mod">
4208 <div class="center-container top-container__center-container dw-mod">
4209 <div class="grid">
4210 <div class="grid__col-auto">
4211 <div class="typeahead-mobile__search-field dw-mod js-typeahead" data-page-size="@(searchType == "combined-search" ? 4 : 8)" id="MobileProductSearch" data-search-feed-id="@searchFeedId" data-search-second-feed-id="@searchSecondFeedId" data-result-page-id="@resultPageLink" data-search-type="@searchType">
4212 <input type="text" class="js-typeahead-search-field u-w160px u-no-margin" placeholder="@searchPlaceholder" value="@searchValue">
4213 @if (string.IsNullOrEmpty(searchSecondFeedId))
4214 {
4215 <ul class="dropdown dropdown--absolute-position u-min-w220px u-full-width js-handlebars-root js-typeahead-search-content dw-mod" id="MobileProductSearchBarContent" data-template="@searchTemplate" data-json-feed="/Default.aspx?ID=@searchFeedId&feedType=productsOnly" data-init-onload="false"></ul>
4216 }
4217 else
4218 {
4219 <div class="dropdown dropdown--absolute-position dropdown--combined grid dropdown--combined-mobile grid">
4220 <div class="js-handlebars-root js-typeahead-search-content grid__col-sm-7 grid__col--bleed-y" id="MobileProductSearchBarContent" data-template="@searchTemplate" data-json-feed="/Default.aspx?ID=@searchFeedId&feedType=productsOnly" data-init-onload="false"></div>
4221 <div class="js-handlebars-root js-typeahead-additional-search-content grid__col-sm-5 grid__col--bleed-y" id="MobileContentSearchBarContent" data-template="@searchContentTemplate" data-json-feed="/Default.aspx?ID=@searchSecondFeedId" data-init-onload="false"></div>
4222 </div>
4223 }
4224 <button type="button" class="btn btn--condensed btn--primary u-no-margin dw-mod js-typeahead-enter-btn"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue"></i></button>
4225 </div>
4226 </div>
4227 <div class="grid__col-auto-width">
4228 <ul class="menu dw-mod">
4229 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod">
4230 <label for="MobileSearchTrigger" class="menu__link menu__link--icon menu__link--mobile dw-mod">
4231 <i class="fas fa-times fa-1_5x"></i>
4232 </label>
4233 </li>
4234 </ul>
4235 </div>
4236 </div>
4237 </div>
4238 </div>
4239 }
4240
4241 @helper RenderMobileMiniCartCounterContent()
4242 {
4243 <script id="MiniCartCounterContent" type="text/x-template">
4244 {{#.}}
4245 <div class="js-mini-cart-counter-content dw-mod" data-count="{{numberofproducts}}">
4246 {{numberofproducts}}
4247 </div>
4248 {{/.}}
4249 </script>
4250 }
4251 </text>
4252 <text>@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4253
4254 @using System
4255 @using System.Web
4256 @using System.Collections.Generic
4257 @using Dynamicweb.Rapido.Blocks.Extensibility
4258 @using Dynamicweb.Rapido.Blocks
4259
4260 @functions {
4261 BlocksPage mobileNavigationBlocksPage = BlocksPage.GetBlockPage("Master");
4262 }
4263
4264 @{
4265 bool mobileNavigationItemsHideSignIn = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSignIn");
4266 bool mobileHideCreateAccountLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideCreateAccount");
4267 bool mobileHideMyProfileLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideProfile");
4268 bool mobileHideMyOrdersLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideOrders");
4269 bool mobileHideMySavedCardsLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideSavedCards");
4270 bool mobileHideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideFavorites");
4271
4272 if (!mobileHideMyOrdersLink) {
4273 mobileHideMyOrdersLink = Gobo.UserService.IsInGroup_GuestAccounts(Dynamicweb.Security.UserManagement.User.GetCurrentExtranetUser());
4274 }
4275
4276 Block mobileNavigation = new Block()
4277 {
4278 Id = "MobileNavigation",
4279 SortId = 10,
4280 Template = MobileNavigation(),
4281 SkipRenderBlocksList = true
4282 };
4283 mobileNavigationBlocksPage.Add(MasterBlockId.MasterTopSnippets, mobileNavigation);
4284
4285 if (Model.CurrentUser.ID > 0 && !mobileHideMyProfileLink)
4286 {
4287 Block mobileNavigationSignIn = new Block
4288 {
4289 Id = "MobileNavigationSignIn",
4290 SortId = 10,
4291 Template = RenderMobileNavigationSignIn()
4292 };
4293 mobileNavigationBlocksPage.Add("MobileNavigation", mobileNavigationSignIn);
4294 }
4295
4296 Block mobileNavigationMenu = new Block
4297 {
4298 Id = "MobileNavigationMenu",
4299 SortId = 20,
4300 Template = RenderMobileNavigationMenu()
4301 };
4302 mobileNavigationBlocksPage.Add("MobileNavigation", mobileNavigationMenu);
4303
4304 Block mobileNavigationActions = new Block
4305 {
4306 Id = "MobileNavigationActions",
4307 SortId = 30,
4308 Template = RenderMobileNavigationActions(),
4309 SkipRenderBlocksList = true
4310 };
4311 mobileNavigationBlocksPage.Add("MobileNavigation", mobileNavigationActions);
4312
4313 if (!mobileNavigationItemsHideSignIn)
4314 {
4315 if (Model.CurrentUser.ID <= 0)
4316 {
4317 Block mobileNavigationSignInAction = new Block
4318 {
4319 Id = "MobileNavigationSignInAction",
4320 SortId = 10,
4321 Template = RenderMobileNavigationSignInAction()
4322 };
4323 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationSignInAction);
4324
4325 if (!mobileHideCreateAccountLink)
4326 {
4327 Block mobileNavigationCreateAccountAction = new Block
4328 {
4329 Id = "MobileNavigationCreateAccountAction",
4330 SortId = 20,
4331 Template = RenderMobileNavigationCreateAccountAction()
4332 };
4333 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationCreateAccountAction);
4334 }
4335 }
4336 else
4337 {
4338 if (!mobileHideMyOrdersLink)
4339 {
4340 Block mobileNavigationOrdersAction = new Block
4341 {
4342 Id = "MobileNavigationOrdersAction",
4343 SortId = 20,
4344 Template = RenderMobileNavigationOrdersAction()
4345 };
4346 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationOrdersAction);
4347 }
4348 if (!mobileHideMyFavoritesLink)
4349 {
4350 Block mobileNavigationFavoritesAction = new Block
4351 {
4352 Id = "MobileNavigationFavoritesAction",
4353 SortId = 30,
4354 Template = RenderMobileNavigationFavoritesAction()
4355 };
4356 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationFavoritesAction);
4357 }
4358 if (!mobileHideMySavedCardsLink)
4359 {
4360 Block mobileNavigationSavedCardsAction = new Block
4361 {
4362 Id = "MobileNavigationFavoritesAction",
4363 SortId = 30,
4364 Template = RenderMobileNavigationSavedCardsAction()
4365 };
4366 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationSavedCardsAction);
4367 }
4368
4369 Block mobileNavigationSignOutAction = new Block
4370 {
4371 Id = "MobileNavigationSignOutAction",
4372 SortId = 40,
4373 Template = RenderMobileNavigationSignOutAction()
4374 };
4375 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationSignOutAction);
4376 }
4377 }
4378
4379 if (Model.Languages.Count > 1)
4380 {
4381 Block mobileNavigationLanguagesAction = new Block
4382 {
4383 Id = "MobileNavigationLanguagesAction",
4384 SortId = 50,
4385 Template = RenderMobileNavigationLanguagesAction()
4386 };
4387 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationLanguagesAction);
4388 }
4389 }
4390
4391
4392 @helper MobileNavigation()
4393 {
4394 List<Block> subBlocks = this.mobileNavigationBlocksPage.GetBlockListById("MobileNavigation").OrderBy(item => item.SortId).ToList();
4395 string mobileTopDesign = Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetList("Design") != null ? Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetList("Design").SelectedValue : "nav-left";
4396 string position = mobileTopDesign == "nav-left" || mobileTopDesign == "nav-search-left" ? "left" : "right";
4397
4398 <!-- Trigger for mobile navigation -->
4399 <input type="checkbox" id="MobileNavTrigger" class="mobile-nav-trigger mobile-nav-trigger--@position" autocomplete="off" />
4400
4401 <!-- Mobile navigation -->
4402 <nav class="mobile-navigation mobile-navigation--@position dw-mod">
4403 <div class="mobile-navigation__wrapper" id="mobileNavigationWrapper">
4404 @RenderBlockList(subBlocks)
4405 </div>
4406 </nav>
4407
4408 <label class="mobile-nav-trigger-off" for="MobileNavTrigger"></label>
4409 }
4410
4411 @helper RenderMobileNavigationSignIn()
4412 {
4413 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
4414 int myProfilePageId = GetPageIdByNavigationTag("CustomerProfile");
4415 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID=";
4416 string myProfilePageLink = linkStart + myProfilePageId;
4417 string userName = Model.CurrentUser.FirstName;
4418 if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(Model.CurrentUser.LastName))
4419 {
4420 userName += " " + Model.CurrentUser.LastName;
4421 }
4422 if (string.IsNullOrEmpty(userName))
4423 {
4424 userName = Model.CurrentUser.Name;
4425 }
4426 if (string.IsNullOrEmpty(userName))
4427 {
4428 userName = Model.CurrentUser.UserName;
4429 }
4430 if (string.IsNullOrEmpty(userName))
4431 {
4432 userName = Model.CurrentUser.Email;
4433 }
4434
4435 <ul class="menu menu-mobile">
4436 <li class="menu-mobile__item">
4437 <a href="@myProfilePageLink" class="menu-mobile__link dw-mod"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue menu-mobile__link-icon"></i> @userName</a>
4438 </li>
4439 </ul>
4440 }
4441
4442 @helper RenderMobileNavigationMenu()
4443 {
4444 bool isSlidesDesign = Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetList("Design").SelectedValue == "Slides";
4445 string menuTemplate = isSlidesDesign ? "BaseMenuForMobileSlides.xslt" : "BaseMenuForMobileExpandable.xslt";
4446 string levels = !String.IsNullOrEmpty(Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetString("Levels")) ? Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetString("Levels") : "3";
4447 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar");
4448 int startLevel = 0;
4449
4450 @RenderNavigation(new
4451 {
4452 id = "mobilenavigation",
4453 cssclass = "menu menu-mobile dwnavigation",
4454 startLevel = @startLevel,
4455 ecomStartLevel = @startLevel + 1,
4456 endlevel = @levels,
4457 expandmode = "all",
4458 template = @menuTemplate
4459 })
4460
4461 if (isSlidesDesign)
4462 {
4463 <script>
4464 function goToLevel(level) {
4465 document.getElementById('mobileNavigationWrapper').style.left = -(level * 100) + "%";
4466 }
4467
4468 document.addEventListener('DOMContentLoaded', function () {
4469 goToLevel(document.getElementById('mobileNavigationWrapper').querySelectorAll('input[type=radio]:checked').length);
4470 });
4471 </script>
4472 }
4473
4474 if (renderPagesInToolBar)
4475 {
4476 @RenderNavigation(new
4477 {
4478 id = "topToolsMobileNavigation",
4479 cssclass = "menu menu-mobile dwnavigation",
4480 template = "ToolsMenuForMobile.xslt"
4481 })
4482 }
4483 }
4484
4485 @helper RenderMobileNavigationActions()
4486 {
4487 List<Block> subBlocks = this.mobileNavigationBlocksPage.GetBlockListById("MobileNavigationActions").OrderBy(item => item.SortId).ToList(); ;
4488
4489 <ul class="menu menu-mobile">
4490 @RenderBlockList(subBlocks)
4491 </ul>
4492 }
4493
4494 @helper RenderMobileNavigationSignInAction()
4495 {
4496 <li class="menu-mobile__item">
4497 <label for="SignInModalTrigger" onclick="document.getElementById('MobileNavTrigger').checked = false;" class="menu-mobile__link dw-mod menu-mobile__link--highlighted"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue menu-mobile__link-icon"></i> @Translate("Sign in")</label>
4498 </li>
4499 }
4500
4501 @helper RenderMobileNavigationCreateAccountAction()
4502 {
4503 int createAccountPageId = GetPageIdByNavigationTag("CreateAccount");
4504
4505 <li class="menu-mobile__item">
4506 <a class="menu-mobile__link menu-mobile__link--highlighted dw-mod" href="/Default.aspx?ID=@createAccountPageId"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue menu-mobile__link-icon"></i> @Translate("Create account")</a>
4507 </li>
4508 }
4509
4510 @helper RenderMobileNavigationProfileAction()
4511 {
4512 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
4513 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID=";
4514 int myProfilePageId = GetPageIdByNavigationTag("CustomerProfile");
4515 string myProfilePageLink = linkStart + myProfilePageId;
4516
4517 <li class="menu-mobile__item">
4518 <a href="@myProfilePageLink" class="menu-mobile__link menu-mobile__link--highlighted dw-mod"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue menu-mobile__link-icon"></i> @Translate("My Profile")</a>
4519 </li>
4520 }
4521
4522 @helper RenderMobileNavigationOrdersAction()
4523 {
4524 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
4525 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID=";
4526 int myOrdersPageId = GetPageIdByNavigationTag("CustomerOrders");
4527 string myOrdersPageLink = linkStart + myOrdersPageId;
4528 string ordersIcon = "fas fa-list";
4529
4530 <li class="menu-mobile__item">
4531 <a href="@myOrdersPageLink" class="menu-mobile__link menu-mobile__link--highlighted dw-mod"><i class="@ordersIcon menu-mobile__link-icon"></i> @Translate("My Orders")</a>
4532 </li>
4533 }
4534
4535 @helper RenderMobileNavigationFavoritesAction()
4536 {
4537 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
4538 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID=";
4539 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites");
4540 string myFavoritesPageLink = linkStart + myFavoritesPageId;
4541 string favoritesIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon") != null ? "fas fa-" + Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon").SelectedValue : "fa fa-star";
4542
4543
4544 <li class="menu-mobile__item">
4545 <a href="@myFavoritesPageLink" class="menu-mobile__link menu-mobile__link--highlighted dw-mod"><i class="@favoritesIcon menu-mobile__link-icon"></i> @Translate("My Favorites")</a>
4546 </li>
4547 }
4548
4549 @helper RenderMobileNavigationSavedCardsAction()
4550 {
4551 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
4552 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID=";
4553 int mySavedCardsPageId = GetPageIdByNavigationTag("SavedCards");
4554 string mySavedCardsPageLink = linkStart + mySavedCardsPageId;
4555 string savedCardsIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SavedCards") != null ? "fas fa-" + Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SavedCards").SelectedValue : "fas fa-credit-card";
4556
4557 <li class="menu-mobile__item">
4558 <a href="@mySavedCardsPageLink" class="menu-mobile__link menu-mobile__link--highlighted dw-mod"><i class="@savedCardsIcon menu-mobile__link-icon"></i> @Translate("My Saved Cards")</a>
4559 </li>
4560 }
4561
4562 @helper RenderMobileNavigationSignOutAction()
4563 {
4564 int pageId = Model.TopPage.ID;
4565 string signOutIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignOutIcon") != null ? "fas fa-" + Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignOutIcon").SelectedValue : "far fa-sign-out-alt";
4566
4567 <li class="menu-mobile__item">
4568 <a class="menu-mobile__link menu-mobile__link--highlighted dw-mod" href="/Admin/Public/ExtranetLogoff.aspx?ID=@Model.Area.FirstActivePage.ID" onclick="RememberState.SetCookie('useAnotherAddress', false)"><i class="@signOutIcon menu-mobile__link-icon"></i> @Translate("Sign out")</a>
4569 </li>
4570 }
4571
4572 @helper RenderMobileNavigationLanguagesAction()
4573 {
4574 bool isSlidesDesign = Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetList("Design").SelectedValue == "Slides";
4575
4576 string selectedLanguage = "";
4577 foreach (var lang in Model.Languages)
4578 {
4579 if (lang.IsCurrent)
4580 {
4581 selectedLanguage = lang.Name;
4582 }
4583 }
4584
4585 <li class="menu-mobile__item dw-mod">
4586 @if (isSlidesDesign)
4587 {
4588 <input id="MobileMenuCheck_Language" type="radio" class="expand-trigger" name="mobile-menu-level-1" onclick="goToLevel(1);">
4589 }
4590 else
4591 {
4592 <input id="MobileMenuCheck_Language" type="checkbox" class="expand-trigger">
4593 }
4594 <div class="menu-mobile__link__wrap">
4595 <label for="MobileMenuCheck_Language" class="menu-mobile__link menu-mobile__link--highlighted dw-mod"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("LanguageIcon").SelectedValue menu-mobile__link-icon"></i> @selectedLanguage</label>
4596 <label for="MobileMenuCheck_Language" class="menu-mobile__trigger"></label>
4597 </div>
4598 <ul class="menu-mobile menu-mobile__submenu expand-menu">
4599 @if (isSlidesDesign)
4600 {
4601 <li class="menu-mobile__item dw-mod">
4602 <div class="menu-mobile__link__wrap">
4603 <input id="MobileMenuCheck_Language_back" type="radio" class="expand-trigger" name="mobile-menu-level-1" onclick="goToLevel(0);" />
4604 <label for="MobileMenuCheck_Language_back" class="menu-mobile__trigger menu-mobile__trigger--back"></label>
4605 <label for="MobileMenuCheck_Language_back" class="menu-mobile__link dw-mod ">@Translate("Back")</label>
4606 </div>
4607 </li>
4608 }
4609 @foreach (var lang in Model.Languages)
4610 {
4611 <li class="menu-mobile__item dw-mod">
4612 <a class="menu-mobile__link menu-mobile__link--highlighted dw-mod menu-mobile__link--level-1" href="/Default.aspx?ID=@lang.Page.ID">@lang.Name</a>
4613 </li>
4614 }
4615 </ul>
4616 </li>
4617 }</text>
4618 }
4619 else
4620 {
4621 <text>@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4622
4623 @using System
4624 @using System.Web
4625 @using System.Collections.Generic
4626 @using Dynamicweb.Rapido.Blocks.Extensibility
4627 @using Dynamicweb.Rapido.Blocks
4628
4629 @functions {
4630 BlocksPage headerBlocksPage = BlocksPage.GetBlockPage("Master");
4631 }
4632
4633 @{
4634 Block masterTools = new Block()
4635 {
4636 Id = "MasterDesktopTools",
4637 SortId = 10,
4638 Template = RenderDesktopTools(),
4639 SkipRenderBlocksList = true,
4640 BlocksList = new List<Block>
4641 {
4642 new Block {
4643 Id = "MasterDesktopToolsText",
4644 SortId = 10,
4645 Template = RenderDesktopToolsText(),
4646 Design = new Design
4647 {
4648 Size = "auto",
4649 HidePadding = true,
4650 RenderType = RenderType.Column
4651 }
4652 },
4653 new Block {
4654 Id = "MasterDesktopToolsNavigation",
4655 SortId = 20,
4656 Template = RenderDesktopToolsNavigation(),
4657 Design = new Design
4658 {
4659 Size = "auto-width",
4660 HidePadding = true,
4661 RenderType = RenderType.Column
4662 }
4663 }
4664 }
4665 };
4666 headerBlocksPage.Add("MasterHeader", masterTools);
4667
4668 Block masterDesktopExtra = new Block()
4669 {
4670 Id = "MasterDesktopExtra",
4671 SortId = 10,
4672 Template = RenderDesktopExtra(),
4673 SkipRenderBlocksList = true
4674 };
4675 headerBlocksPage.Add("MasterHeader", masterDesktopExtra);
4676
4677 Block masterDesktopNavigation = new Block()
4678 {
4679 Id = "MasterDesktopNavigation",
4680 SortId = 20,
4681 Template = RenderDesktopNavigation(),
4682 SkipRenderBlocksList = true
4683 };
4684 headerBlocksPage.Add("MasterHeader", masterDesktopNavigation);
4685 }
4686
4687 @* Include the Blocks for the page *@
4688 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4689
4690 @using System
4691 @using System.Web
4692 @using Dynamicweb.Rapido.Blocks.Extensibility
4693 @using Dynamicweb.Rapido.Blocks
4694
4695 @{
4696 Block masterDesktopLogo = new Block
4697 {
4698 Id = "MasterDesktopLogo",
4699 SortId = 10,
4700 Template = RenderDesktopLogo(),
4701 Design = new Design
4702 {
4703 Size = "auto-width",
4704 HidePadding = true,
4705 RenderType = RenderType.Column,
4706 CssClass = "grid--align-self-center"
4707 }
4708 };
4709
4710 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopLogo);
4711 }
4712
4713
4714 @helper RenderDesktopLogo()
4715 {
4716 string firstPageId = Model.Area.FirstActivePage.ID.ToString();
4717 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
4718 string alignClass = topLayout == "two-lines-centered" || topLayout == "two-lines" ? "grid--align-self-center" : "";
4719 alignClass = topLayout == "splitted-center" ? "u-middle" : alignClass;
4720 string logo = Model.Area.Item.GetItem("Layout").GetFile("LogoImage") != null ? Model.Area.Item.GetItem("Layout").GetFile("LogoImage").PathUrlEncoded : "/Files/Images/logo-dynamicweb.png";
4721 if (Path.GetExtension(logo).ToLower() != ".svg")
4722 {
4723 int logoHeight = Model.Area.Item.GetItem("Layout").GetInt32("LogoHeight");
4724 logoHeight = logoHeight > 0 && Pageview.Device.ToString() != "Mobile" ? logoHeight : 40;
4725 logo = "/Admin/Public/GetImage.ashx?height=" + Converter.ToString(logoHeight) + "&crop=5&Compression=75&image=" + logo;
4726 }
4727 else
4728 {
4729 logo = HttpUtility.UrlDecode(logo);
4730 }
4731
4732 <div class="logo @alignClass dw-mod">
4733 <a href="/Default.aspx?ID=@firstPageId" class="logo__img dw-mod u-block">
4734 <img class="grid__cell-img logo__img dw-mod" src="@logo" alt="@Translate("Logo")" />
4735 </a>
4736 </div>
4737 }
4738 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4739
4740 @using System
4741 @using System.Web
4742 @using Dynamicweb.Rapido.Blocks.Extensibility
4743 @using Dynamicweb.Rapido.Blocks
4744
4745 @functions {
4746 bool isMegaMenu;
4747 }
4748
4749 @{
4750 isMegaMenu = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("NavigationMegaMenu") != null ? Converter.ToBoolean(Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("NavigationMegaMenu").SelectedValue) : false;
4751 Block masterDesktopMenu = new Block
4752 {
4753 Id = "MasterDesktopMenu",
4754 SortId = 10,
4755 Template = RenderDesktopMenu(),
4756 Design = new Design
4757 {
4758 Size = "auto",
4759 HidePadding = true,
4760 RenderType = RenderType.Column
4761 }
4762 };
4763
4764 if (isMegaMenu)
4765 {
4766 masterDesktopMenu.Design.CssClass = "u-reset-position";
4767 }
4768
4769 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopMenu);
4770 }
4771
4772 @helper RenderDesktopMenu()
4773 {
4774 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
4775 string menuAlignment = topLayout == "minimal-right" ? "grid--align-self-end" : "";
4776 menuAlignment = topLayout == "minimal-center" ? "grid--align-self-center" : topLayout;
4777 string megamenuPromotionImage = Model.Area.Item.GetItem("Layout").GetItem("Header").GetFile("MegamenuPromotionImage") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetFile("MegamenuPromotionImage").PathUrlEncoded : "";
4778 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar");
4779 bool showOnlyHeaders = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowOnlyHeaders");
4780 int startLevel = renderPagesInToolBar ? 1 : 0;
4781
4782 string promotionLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("MegamenuPromotionLink");
4783
4784 <div class="grid__cell u-flex @(isMegaMenu ? "u-reset-position" : "") @menuAlignment">
4785 @if (!isMegaMenu)
4786 {
4787 @RenderNavigation(new
4788 {
4789 id = "topnavigation",
4790 cssclass = "menu dw-mod dwnavigation u-full-max-width u-flex grid--wrap",
4791 startLevel = startLevel,
4792 ecomStartLevel = startLevel + 1,
4793 ecomEndLevel = 2,
4794 endlevel = 5,
4795 expandmode = "all",
4796 template = "BaseMenuWithDropdown.xslt"
4797 });
4798 }
4799 else
4800 {
4801 @RenderNavigation(new
4802 {
4803 id = "topnavigation",
4804 cssclass = "menu dw-mod dwnavigation u-full-max-width u-flex grid--wrap",
4805 startLevel = startLevel,
4806 ecomStartLevel = startLevel + 1,
4807 endlevel = 5,
4808 promotionImage = megamenuPromotionImage,
4809 promotionLink = promotionLink,
4810 expandmode = "all",
4811 showOnlyHeaders = showOnlyHeaders.ToString().ToLower(),
4812 template = "BaseMegaMenu.xslt"
4813 });
4814 }
4815 </div>
4816 }
4817 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4818
4819 @using System
4820 @using System.Web
4821 @using Dynamicweb.Rapido.Blocks.Extensibility
4822 @using Dynamicweb.Rapido.Blocks
4823
4824 @{
4825 Block masterDesktopActionsMenu = new Block
4826 {
4827 Id = "MasterDesktopActionsMenu",
4828 SortId = 10,
4829 Template = RenderDesktopActionsMenu(),
4830 Design = new Design
4831 {
4832 CssClass = "u-flex"
4833 },
4834 SkipRenderBlocksList = true
4835
4836 };
4837 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopActionsMenu);
4838
4839 if (!string.IsNullOrWhiteSpace(Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonLink")))
4840 {
4841 Block masterDesktopActionsHeaderButton = new Block
4842 {
4843 Id = "MasterDesktopActionsHeaderButton",
4844 SortId = 60,
4845 Template = RenderHeaderButton()
4846 };
4847 masterDesktopActionsMenu.Add(masterDesktopActionsHeaderButton);
4848 }
4849 }
4850
4851 @helper RenderDesktopActionsMenu()
4852 {
4853 List<Block> subBlocks = this.headerBlocksPage.GetBlockListById("MasterDesktopActionsMenu").OrderBy(item => item.SortId).ToList();
4854
4855 <ul class="menu u-flex dw-mod">
4856 @RenderBlockList(subBlocks)
4857 </ul>
4858 }
4859
4860 @helper RenderHeaderButton()
4861 {
4862 string headerButtonText = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonText");
4863 string headerButtonLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonLink");
4864 string headerButtonType = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("HeaderButtonType") != null ? "btn--" + Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("HeaderButtonType").SelectedName.ToLower() : "";
4865
4866 <li class="menu__item menu__item--horizontal menu--clean dw-mod">
4867 <a class="btn @headerButtonType dw-mod u-no-margin u-margin-left" href="@headerButtonLink">@headerButtonText</a>
4868 </li>
4869 }
4870 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4871
4872 @using System
4873 @using System.Web
4874 @using Dynamicweb.Core;
4875 @using System.Text.RegularExpressions
4876 @using Dynamicweb.Rapido.Blocks.Extensibility
4877 @using Dynamicweb.Rapido.Blocks
4878
4879 @{
4880 Block masterDesktopActionsMenuLanguageSelector = new Block
4881 {
4882 Id = "MasterDesktopActionsMenuLanguageSelector",
4883 SortId = 40,
4884 Template = RenderLanguageSelector()
4885 };
4886
4887 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuLanguageSelector);
4888 }
4889
4890 @helper RenderLanguageSelector()
4891 {
4892 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
4893 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean";
4894 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
4895 string languageViewType = !string.IsNullOrEmpty(Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("LanguageSelector").SelectedValue) ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("LanguageSelector").SelectedValue.ToLower() : "";
4896
4897 if (Model.Languages.Count > 1)
4898 {
4899 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon is-dropdown is-dropdown--no-icon dw-mod">
4900 <div class="@menuLinkClass dw-mod" title="@Translate("Language")">
4901 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("LanguageIcon").SelectedValue fa-1_5x"></i>
4902 </div>
4903 <div class="menu menu--dropdown menu--dropdown-right languages-dropdown dw-mod grid__cell">
4904 @foreach (var lang in Model.Languages)
4905 {
4906 string widthClass = "menu__item--fixed-width";
4907 string langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " u-margin-right\"></span>" + lang.Name;
4908 string cultureName = Regex.Replace(Dynamicweb.Services.Areas.GetArea(lang.ID).CultureInfo.NativeName, @" ?\(.*?\)", string.Empty);
4909 cultureName = char.ToUpper(cultureName[0]) + cultureName.Substring(1);
4910
4911 if (languageViewType == "flag-culture")
4912 {
4913 langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " \"></span> " + cultureName;
4914 }
4915
4916 if (languageViewType == "flag")
4917 {
4918 langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " \"></span>";
4919 widthClass = "";
4920 }
4921
4922 if (languageViewType == "name")
4923 {
4924 langInfo = lang.Name;
4925 }
4926
4927 if (languageViewType == "culture")
4928 {
4929 langInfo = cultureName;
4930 widthClass = "";
4931 }
4932
4933 <div class="menu__item dw-mod @widthClass">
4934 <a href="/Default.aspx?AreaID=@Dynamicweb.Services.Pages.GetPage(lang.Page.ID).Area.ID" class="menu-dropdown__link dw-mod">@langInfo</a>
4935 </div>
4936 }
4937 </div>
4938 </li>
4939 }
4940 }
4941 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4942
4943 @using System
4944 @using System.Web
4945 @using Dynamicweb.Rapido.Blocks.Extensibility
4946 @using Dynamicweb.Rapido.Blocks
4947
4948 @{
4949 Block masterDesktopActionsMenuSignIn = new Block
4950 {
4951 Id = "MasterDesktopActionsMenuSignIn",
4952 SortId = 20,
4953 Template = RenderSignIn()
4954 };
4955
4956 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuSignIn);
4957 }
4958
4959 @helper RenderSignIn()
4960 {
4961 bool navigationItemsHideSignIn = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSignIn");
4962 string userInitials = "";
4963 int pageId = Model.TopPage.ID;
4964 int createAccountPageId = GetPageIdByNavigationTag("CreateAccount");
4965 int myDashboardPageId = GetPageIdByNavigationTag("CustomerDashboard");
4966 int myProfilePageId = GetPageIdByNavigationTag("CustomerProfile");
4967 int myOrdersPageId = GetPageIdByNavigationTag("CustomerOrders");
4968 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites");
4969 int mySavedCardsPageId = GetPageIdByNavigationTag("SavedCards");
4970 int myOrderDraftsPageId = GetPageIdByNavigationTag("OrderDraft");
4971 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
4972 bool hideCreateAccountLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideCreateAccount");
4973 bool hideMyProfileLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideProfile");
4974 bool hideMyOrdersLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideOrders");
4975 bool hideMySavedCardsLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideSavedCards");
4976 bool hideMyOrderDraftsLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideOrderDrafts");
4977 bool hideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideFavorites");
4978 bool hideForgotPasswordLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideForgotPasswordLink");
4979
4980 if (!hideMyOrdersLink) {
4981 hideMyOrdersLink = Gobo.UserService.IsInGroup_GuestAccounts(Dynamicweb.Security.UserManagement.User.GetCurrentExtranetUser());
4982 }
4983
4984 string linkStart = "/Default.aspx?ID=";
4985 if (Model.CurrentUser.ID <= 0)
4986 {
4987 linkStart += signInProfilePageId + "&RedirectPageId=";
4988 }
4989
4990 string forgotPasswordPageLink = "/Default.aspx?ID=" + signInProfilePageId + "&LoginAction=Recovery";
4991 string myProfilePageLink = linkStart + myProfilePageId;
4992 string myOrdersPageLink = linkStart + myOrdersPageId;
4993 string myFavoritesPageLink = linkStart + myFavoritesPageId;
4994 string mySavedCardsPageLink = linkStart + mySavedCardsPageId;
4995 string myOrderDraftsLink = linkStart + myOrderDraftsPageId;
4996
4997 string profileIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue : "fa fa-user";
4998 string favoritesIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon") != null ? "fas fa-" + Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon").SelectedValue : "fa fa-star";
4999 string orderDraftsIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon").SelectedValue : "fa fa-clipboard";
5000
5001 if (Model.CurrentUser.ID != 0)
5002 {
5003 userInitials = Dynamicweb.Rapido.Services.User.GetInitials(Model.CurrentUser.Name, Model.CurrentUser.FirstName, Model.CurrentUser.LastName, Model.CurrentUser.Email, Model.CurrentUser.UserName);
5004 }
5005
5006 if (!navigationItemsHideSignIn)
5007 {
5008 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5009 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu__item--clean";
5010 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5011
5012 <li class="menu__item menu__item--horizontal menu__item menu__item--icon @liClasses is-dropdown is-dropdown--no-icon dw-mod">
5013 <div class="@menuLinkClass dw-mod">
5014 @if (Model.CurrentUser.ID <= 0)
5015 {
5016 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue fa-1_5x" title="@Translate("Sign in")"></i>
5017 }
5018 else
5019 {
5020 <a href="/default.aspx?ID=@myDashboardPageId" class="u-color-inherit" title="@Translate("Customer center")"><div class="circle-icon-btn">@userInitials.ToUpper()</div></a>
5021 }
5022 </div>
5023 <div class="menu menu--dropdown menu--dropdown-right menu--sign-in grid__cell dw-mod">
5024 <ul class="list list--clean dw-mod">
5025 @if (Model.CurrentUser.ID <= 0)
5026 {
5027 <li>
5028 <label for="SignInModalTrigger" class="btn btn--primary btn--full u-no-margin sign-in-modal-trigger-button dw-mod" onclick="setTimeout(function () { document.getElementById('LoginUsername').focus() }, 10)">@Translate("Sign in")</label>
5029 </li>
5030
5031 if (!hideCreateAccountLink)
5032 {
5033 @RenderListItem("/default.aspx?ID=" + createAccountPageId, Translate("Create account"));
5034 }
5035 if (!hideForgotPasswordLink)
5036 {
5037 @RenderListItem(forgotPasswordPageLink, Translate("Forgot your password?"))
5038 }
5039 if (!hideMyProfileLink || !hideMyOrdersLink || !hideMyFavoritesLink || !hideMySavedCardsLink)
5040 {
5041 @RenderSeparator()
5042 }
5043 }
5044 @if (!hideMyProfileLink)
5045 {
5046 @RenderListItem(myProfilePageLink, Translate("My Profile"), profileIcon)
5047 }
5048 @if (!hideMyOrdersLink)
5049 {
5050 @RenderListItem(myOrdersPageLink, Translate("My Orders"), "fas fa-list")
5051 }
5052 @if (!hideMyFavoritesLink)
5053 {
5054 @RenderListItem(myFavoritesPageLink, Translate("My Favorites"), favoritesIcon)
5055 }
5056 @if (!hideMySavedCardsLink)
5057 {
5058 @RenderListItem(mySavedCardsPageLink, Translate("My Saved cards"), "fas fa-credit-card")
5059 }
5060 @if (!hideMyOrderDraftsLink)
5061 {
5062 @RenderListItem(myOrderDraftsLink, Translate("My Order drafts"), orderDraftsIcon)
5063 }
5064 @if (Model.CurrentUser.ID > 0)
5065 {
5066 if (!hideMyProfileLink || !hideMyOrdersLink || !hideMyFavoritesLink || !hideMySavedCardsLink)
5067 {
5068 @RenderSeparator()
5069 }
5070
5071 //Check if impersonation is on
5072 if (Model.CurrentSecondaryUser != null && Model.CurrentSecondaryUser.ID > 0)
5073 {
5074 <li>
5075 <div class="list__link dw-mod" onclick="document.getElementById('StopImpersonationModalTrigger').checked = true;">
5076 @Translate("Sign out")
5077 </div>
5078 </li>
5079 } else {
5080 @RenderListItem("/Admin/Public/ExtranetLogoff.aspx?ID=" + Model.Area.FirstActivePage.ID, Translate("Sign out"))
5081 }
5082 }
5083 </ul>
5084 </div>
5085 </li>
5086 }
5087 }
5088
5089 @helper RenderListItem(string link, string text, string icon = null) {
5090 <li>
5091 <a href="@link" class="list__link dw-mod" onclick="RememberState.SetCookie('useAnotherAddress', false)">
5092 @if (!string.IsNullOrEmpty(icon)){<i class="@icon u-margin-right"></i>}@text
5093 </a>
5094 </li>
5095 }
5096
5097 @helper RenderSeparator()
5098 {
5099 <li class="list__seperator dw-mod"></li>
5100 }
5101 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5102
5103 @using System
5104 @using System.Web
5105 @using Dynamicweb.Rapido.Blocks.Extensibility
5106 @using Dynamicweb.Rapido.Blocks
5107
5108 @{
5109 bool hideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideFavorites");
5110
5111 Block masterDesktopActionsMenuFavorites = new Block
5112 {
5113 Id = "MasterDesktopActionsMenuFavorites",
5114 SortId = 30,
5115 Template = RenderFavorites()
5116 };
5117
5118 if (!hideMyFavoritesLink && Model.CurrentUser.ID > 0)
5119 {
5120 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuFavorites);
5121 }
5122 }
5123
5124 @helper RenderFavorites()
5125 {
5126 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites");
5127 string myFavoritesPageLink = "/Default.aspx?ID=" + myFavoritesPageId;
5128
5129 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5130 string liClasses = topLayout != "normal" && topLayout != "splitted-center" ? "menu__item--top-level u-hidden-xxs" : "menu--clean";
5131 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5132
5133 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod">
5134 <a href="@myFavoritesPageLink" class="@menuLinkClass dw-mod" title="@Translate("Favorites")">
5135 <i class="fas fa-@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon").SelectedValue fa-1_5x"></i>
5136 </a>
5137 </li>
5138 }
5139 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5140
5141 @using System
5142 @using System.Web
5143 @using Dynamicweb.Rapido.Blocks.Extensibility
5144 @using Dynamicweb.Rapido.Blocks
5145 @using Dynamicweb.Rapido.Services
5146
5147 @{
5148 bool hideCart = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart");
5149 string miniCartLayout = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout").SelectedValue : "dropdown";
5150
5151 if (!hideCart) {
5152 hideCart = Gobo.UserService.IsInGroup_GuestAccounts(Dynamicweb.Security.UserManagement.User.GetCurrentExtranetUser());
5153 }
5154
5155 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed() && !hideCart)
5156 {
5157 Block masterDesktopActionsMenuMiniCart = new Block
5158 {
5159 Id = "MasterDesktopActionsMenuMiniCart",
5160 SortId = 60,
5161 Template = RenderMiniCart(miniCartLayout == "dropdown"),
5162 SkipRenderBlocksList = true,
5163 BlocksList = new List<Block>()
5164 };
5165
5166 Block miniCartCounterScriptTemplate = new Block
5167 {
5168 Id = "MiniCartCounterScriptTemplate",
5169 Template = RenderMiniCartCounterContent()
5170 };
5171
5172 //dropdown layout is default
5173 RazorEngine.Templating.TemplateWriter layoutTemplate;
5174 RazorEngine.Templating.TemplateWriter miniCartTriggerTemplate;
5175
5176 switch (miniCartLayout)
5177 {
5178 case "dropdown":
5179 layoutTemplate = RenderMiniCartDropdownLayout();
5180 miniCartTriggerTemplate = RenderMiniCartTriggerLink();
5181 break;
5182 case "panel":
5183 layoutTemplate = RenderMiniCartPanelLayout();
5184 miniCartTriggerTemplate = RenderMiniCartTriggerLabel();
5185 break;
5186 case "modal":
5187 layoutTemplate = RenderMiniCartModalLayout();
5188 miniCartTriggerTemplate = RenderMiniCartTriggerLabel();
5189 break;
5190 case "none":
5191 default:
5192 layoutTemplate = RenderMiniCartDropdownLayout();
5193 miniCartTriggerTemplate = RenderMiniCartTriggerLink();
5194 break;
5195 }
5196
5197 masterDesktopActionsMenuMiniCart.BlocksList.Add(new Block
5198 {
5199 Id = "MiniCartTrigger",
5200 Template = miniCartTriggerTemplate
5201 });
5202
5203 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet")
5204 {
5205 masterDesktopActionsMenuMiniCart.BlocksList.Add(new Block
5206 {
5207 Id = "MiniCartLayout",
5208 Template = layoutTemplate
5209 });
5210 }
5211
5212 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuMiniCart);
5213 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", miniCartCounterScriptTemplate);
5214 }
5215
5216 if (hideCart && Dynamicweb.Rapido.Services.User.IsBuyingAllowed())
5217 {
5218 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", new Block {
5219 Id = "CartInitialization"
5220 });
5221 }
5222 }
5223
5224 @helper RenderMiniCart(bool hasMouseEnterEvent)
5225 {
5226 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterDesktopActionsMenuMiniCart").OrderBy(item => item.SortId).ToList();
5227 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5228 string liClasses = topLayout != "normal" ? "menu__item--top-level" : "menu--clean";
5229 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5230 string mouseEvent = "";
5231 string id = "MiniCart";
5232 if (hasMouseEnterEvent)
5233 {
5234 mouseEvent = "onmouseenter=\"Cart.UpdateMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '/Default.aspx?ID=" + miniCartFeedPageId + "&feedType=MiniCart')\"";
5235 id = "miniCartTrigger";
5236 }
5237 <li class="menu__item menu__item--horizontal menu__item--icon @liClasses dw-mod" id="@id" @mouseEvent>
5238 @RenderBlockList(subBlocks)
5239 </li>
5240 }
5241
5242 @helper RenderMiniCartTriggerLabel()
5243 {
5244 int cartPageId = GetPageIdByNavigationTag("CartPage");
5245 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fa fa-cart";
5246 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5247 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5248 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5249
5250 <div class="@menuLinkClass dw-mod js-mini-cart-button" onclick="Cart.UpdateMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '/Default.aspx?ID=@miniCartFeedPageId&feedType=MiniCart')" title="@Translate("Cart")">
5251 <div class="u-inline u-position-relative">
5252 <i class="@cartIcon fa-1_5x"></i>
5253 @RenderMiniCartCounter()
5254 </div>
5255 </div>
5256 }
5257
5258 @helper RenderMiniCartTriggerLink()
5259 {
5260 int cartPageId = GetPageIdByNavigationTag("CartPage");
5261 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fa fa-cart";
5262 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5263 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5264
5265 <a href="/Default.aspx?ID=@cartPageId&Purge=True" class="@menuLinkClass menu__item--icon dw-mod js-mini-cart-button" title="@Translate("Cart")">
5266 <span class="u-inline u-position-relative">
5267 <i class="@cartIcon fa-1_5x"></i>
5268 @RenderMiniCartCounter()
5269 </span>
5270 </a>
5271 }
5272
5273 @helper RenderMiniCartCounter()
5274 {
5275 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5276 string cartProductsCount = Model.Cart.TotalProductsCount.ToString();
5277 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right";
5278 bool showPrice = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetBoolean("ShowPrice");
5279 string cartProductsTotalPrice = showPrice && Model.Cart.TotalPrice != null ? Model.Cart.TotalPrice.Price.Formatted : "";
5280 cartProductsTotalPrice = counterPosition == "right" ? cartProductsTotalPrice : "";
5281
5282 if (showPrice && counterPosition == "right")
5283 {
5284 cartProductsCount = Translate("Cart") + " (" + cartProductsCount + ")";
5285 }
5286
5287 <span class="mini-cart__counter @(counterPosition == "right" ? "mini-cart__counter--inline" : "") dw-mod">
5288 <span class="js-handlebars-root js-mini-cart-counter" id="cartCounter" data-template="MiniCartCounterContent" data-json-feed="/Default.aspx?ID=@miniCartFeedPageId&feedType=Counter" data-init-onload="false" data-preloader="false">
5289 <span class="js-mini-cart-counter-content" data-count="@Model.Cart.TotalProductsCount.ToString()">
5290 @cartProductsCount @cartProductsTotalPrice
5291 </span>
5292 </span>
5293 </span>
5294 }
5295
5296 @helper RenderMiniCartCounterContent()
5297 {
5298 bool showPrice = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetBoolean("ShowPrice");
5299 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right";
5300 bool showPriceInMiniCartCounter = Pageview.Device.ToString() != "Mobile" && counterPosition == "right" && showPrice;
5301
5302 <script id="MiniCartCounterContent" type="text/x-template">
5303 {{#.}}
5304 <span class="js-mini-cart-counter-content dw-mod" data-count="{{numberofproducts}}">
5305 @if (showPriceInMiniCartCounter)
5306 {
5307 @Translate("Cart")<text>({{numberofproducts}}) {{totalprice}}</text>
5308 }
5309 else
5310 {
5311 <text>{{numberofproducts}}</text>
5312 }
5313 </span>
5314 {{/.}}
5315 </script>
5316 }
5317
5318 @helper RenderMiniCartDropdownLayout()
5319 {
5320 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5321 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage");
5322
5323 <div class="mini-cart mini-cart-dropdown js-mini-cart grid__cell dw-mod" id="miniCart" data-cart-id="@miniCartFeedPageId" data-show-type="dropdown" data-cart-page-link="@cartPageLink">
5324 <div class="mini-cart-dropdown__inner dw-mod">
5325 <h3 class="u-ta-center dw-mod">@Translate("Shopping cart")</h3>
5326 <div class="mini-cart-dropdown__body u-flex dw-mod">
5327 <div class="js-handlebars-root u-flex grid--direction-column u-full-width dw-mod" id="miniCartContent" data-template="MiniCartContent" data-json-feed="/Default.aspx?ID=@miniCartFeedPageId&feedType=MiniCart" data-init-onload="false"></div>
5328 </div>
5329 </div>
5330 </div>
5331 }
5332
5333 @helper RenderMiniCartPanelLayout()
5334 {
5335 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5336 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage");
5337
5338 <div class="mini-cart grid__cell dw-mod">
5339 <input type="checkbox" id="miniCartTrigger" class="panel-trigger" />
5340 <div class="panel panel--right panel--with-close-btn dw-mod js-mini-cart" id="miniCart" data-cart-id="@miniCartFeedPageId" data-show-type="block" data-cart-page-link="@cartPageLink">
5341 <label for="miniCartTrigger" class="panel__close-btn" title="@Translate("Close panel")"><i class="fas fa-times"></i></label>
5342 <div class="panel__content u-full-width dw-mod">
5343 <h3 class="panel__header dw-mod u-margin-bottom u-ta-center">@Translate("Shopping cart")</h3>
5344 <div class="panel__content-body panel__content-body--cart dw-mod">
5345 <div class="js-handlebars-root u-flex grid--direction-column u-full-height dw-mod" id="miniCartContent" data-template="MiniCartContent" data-json-feed="/Default.aspx?ID=@miniCartFeedPageId&feedType=MiniCart" data-init-onload="false"></div>
5346 </div>
5347 </div>
5348 </div>
5349 </div>
5350 }
5351
5352 @helper RenderMiniCartModalLayout()
5353 {
5354 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5355 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage");
5356
5357 <div class="mini-cart grid__cell dw-mod">
5358 <input type="checkbox" id="miniCartTrigger" class="modal-trigger" autocomplete="off" />
5359 <div class="modal-container dw-mod js-mini-cart" id="miniCart" data-cart-id="@miniCartFeedPageId" data-show-type="block" data-cart-page-link="@cartPageLink">
5360 <label for="miniCartTrigger" class="modal-overlay"></label>
5361 <div class="modal modal--md modal--top-right dw-mod">
5362 <div class="modal__body u-flex grid--direction-column dw-mod">
5363 <h3 class="dw-mod u-ta-center">@Translate("Shopping cart")</h3>
5364 <div class="js-handlebars-root u-flex grid--direction-column dw-mod" id="miniCartContent" data-template="MiniCartContent" data-json-feed="/Default.aspx?ID=@miniCartFeedPageId&feedType=MiniCart" data-init-onload="false"></div>
5365 </div>
5366 <label class="modal__close-btn modal__close-btn--clean dw-mod" for="miniCartTrigger" title="@Translate("Close modal")"></label>
5367 </div>
5368 </div>
5369 </div>
5370 }
5371 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5372
5373 @using System
5374 @using System.Web
5375 @using Dynamicweb.Rapido.Blocks.Extensibility
5376 @using Dynamicweb.Rapido.Blocks
5377
5378 @{
5379 bool showOrderDraftLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowOrderDraftIcon");
5380
5381 Block masterDesktopActionsMenuOrderDraft = new Block
5382 {
5383 Id = "MasterDesktopActionsMenuOrderDraft",
5384 SortId = 40,
5385 Template = RenderOrderDraft()
5386 };
5387
5388 if (showOrderDraftLink && Model.CurrentUser.ID > 0)
5389 {
5390 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuOrderDraft);
5391 }
5392 }
5393
5394 @helper RenderOrderDraft()
5395 {
5396 int OrderDraftPageId = GetPageIdByNavigationTag("OrderDraft");
5397 string OrderDraftPageLink = "/Default.aspx?ID=" + OrderDraftPageId;
5398 string draftIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon").SelectedValue : "fa fa-clipboard";
5399
5400
5401 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5402 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean";
5403 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5404
5405 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod">
5406 <a href="@OrderDraftPageLink" class="@menuLinkClass dw-mod" title="@Translate("My order drafts")">
5407 <span class="u-inline u-position-relative">
5408 <i class="@draftIcon fa-1_5x"></i>
5409 </span>
5410 </a>
5411 </li>
5412 }
5413 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5414
5415 @using System
5416 @using System.Web
5417 @using Dynamicweb.Rapido.Blocks.Extensibility
5418 @using Dynamicweb.Rapido.Blocks
5419
5420 @{
5421 bool showDownloadCartLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowDownloadCart");
5422
5423 Block masterDesktopActionsMenuDownloadCart = new Block
5424 {
5425 Id = "MasterDesktopActionsMenuDownloadCart",
5426 SortId = 50,
5427 Template = RenderDownloadCart()
5428 };
5429
5430 if (showDownloadCartLink && Model.CurrentUser.ID > 0)
5431 {
5432 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuDownloadCart);
5433 }
5434 }
5435
5436 @helper RenderDownloadCart()
5437 {
5438 int downloadCartPageId = GetPageIdByNavigationTag("DownloadCart");
5439 string downloadCartPageLink = "/Default.aspx?ID=" + downloadCartPageId;
5440
5441 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5442 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean";
5443 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5444 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right";
5445
5446 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod">
5447 <a href="@downloadCartPageLink" class="@menuLinkClass dw-mod" title="@Translate("Download cart")">
5448 <span class="u-inline u-position-relative">
5449 <i class="fas fa-cart-arrow-down fa-1_5x"></i>
5450 <span class="mini-cart__counter u-hidden @(counterPosition == "right" ? "mini-cart__counter--inline" : "") dw-mod js-download-cart-counter"></span>
5451 </span>
5452 </a>
5453 </li>
5454 }
5455 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5456
5457 @using System
5458 @using System.Web
5459 @using Dynamicweb.Rapido.Blocks.Extensibility
5460 @using Dynamicweb.Rapido.Blocks
5461
5462 @functions {
5463 public class SearchConfiguration
5464 {
5465 public string searchFeedId { get; set; }
5466 public string searchSecondFeedId { get; set; }
5467 public int groupsFeedId { get; set; }
5468 public string resultPageLink { get; set; }
5469 public string searchPlaceholder { get; set; }
5470 public string searchType { get; set; }
5471 public string searchTemplate { get; set; }
5472 public string searchContentTemplate { get; set; }
5473 public string searchValue { get; set; }
5474 public bool showGroups { get; set; }
5475
5476 public SearchConfiguration()
5477 {
5478 searchFeedId = "";
5479 searchSecondFeedId = "";
5480 searchType = "product-search";
5481 searchContentTemplate = "";
5482 showGroups = true;
5483 }
5484 }
5485 }
5486 @{
5487 Block masterSearchBar = new Block
5488 {
5489 Id = "MasterSearchBar",
5490 SortId = 40,
5491 Template = RenderSearch("bar"),
5492 Design = new Design
5493 {
5494 Size = "auto",
5495 HidePadding = true,
5496 RenderType = RenderType.Column
5497 }
5498 };
5499
5500 Block masterSearchAction = new Block
5501 {
5502 Id = "MasterDesktopActionsMenuSearch",
5503 SortId = 10,
5504 Template = RenderSearch()
5505 };
5506
5507 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterSearchBar);
5508 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterSearchAction);
5509 }
5510
5511 @helper RenderSearch(string type = "mini-search")
5512 {
5513 string productsPageId = Converter.ToString(GetPageIdByNavigationTag("ProductsPage"));
5514 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID;
5515 string searchType = Model.Area.Item.GetItem("Layout").GetList("TopSearch") != null ? Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue : "productSearch";
5516
5517 SearchConfiguration searchConfiguration = null;
5518
5519 switch (searchType) {
5520 case "contentSearch":
5521 searchConfiguration = new SearchConfiguration() {
5522 searchFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true",
5523 resultPageLink = contentSearchPageLink,
5524 searchPlaceholder = Translate("Search page"),
5525 groupsFeedId = 0,
5526 searchType = "content-search",
5527 searchTemplate = "SearchPagesTemplate",
5528 showGroups = false
5529 };
5530 break;
5531 case "combinedSearch":
5532 searchConfiguration = new SearchConfiguration() {
5533 searchFeedId = productsPageId + "&feed=true",
5534 searchSecondFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true",
5535 resultPageLink = Converter.ToString(productsPageId),
5536 searchPlaceholder = Translate("Search products or pages"),
5537 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"),
5538 searchType = "combined-search",
5539 searchTemplate = "SearchProductsTemplateWrap",
5540 searchContentTemplate = "SearchPagesTemplateWrap",
5541 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector")
5542 };
5543 break;
5544 default: //productSearch
5545 searchConfiguration = new SearchConfiguration() {
5546 resultPageLink = Converter.ToString(productsPageId),
5547 searchFeedId = productsPageId + "&feed=true",
5548 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"),
5549 searchPlaceholder = Translate("Search products"),
5550 searchTemplate = "SearchProductsTemplate",
5551 searchType = "product-search",
5552 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector")
5553 };
5554 break;
5555 }
5556 searchConfiguration.searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? "";
5557
5558 if (type == "mini-search") {
5559 @RenderMiniSearch(searchConfiguration)
5560 } else {
5561 @RenderSearchBar(searchConfiguration)
5562 }
5563 }
5564
5565 @helper RenderSearchBar(SearchConfiguration options)
5566 {
5567 <div class="typeahead typeahead--centered u-color-inherit js-typeahead dw-mod" id="ProductSearchBar"
5568 data-page-size="7"
5569 data-search-feed-id="@options.searchFeedId"
5570 data-search-second-feed-id="@options.searchSecondFeedId"
5571 data-result-page-id="@options.resultPageLink"
5572 data-groups-page-id="@options.groupsFeedId"
5573 data-search-type="@options.searchType">
5574 @if (options.showGroups)
5575 {
5576 <button type="button" class="btn btn--condensed u-color-light-gray--bg typeahead-group-btn dw-mod js-typeahead-groups-btn" data-group-id="all">@Translate("All")</button>
5577 <ul class="dropdown dropdown--absolute-position u-min-w220px js-handlebars-root js-typeahead-groups-content dw-mod" id="ProductSearchBarGroupsContent" data-template="SearchGroupsTemplate" data-json-feed="/Default.aspx?ID=@options.groupsFeedId&feedType=productGroups" data-init-onload="false" data-preloader="minimal"></ul>
5578 }
5579 <div class="typeahead-search-field">
5580 <input type="text" class="u-no-margin u-full-width u-full-height js-typeahead-search-field" placeholder="@options.searchPlaceholder" value="@options.searchValue">
5581 @if (string.IsNullOrEmpty(options.searchSecondFeedId))
5582 {
5583 <ul class="dropdown dropdown--absolute-position u-min-w220px u-full-width js-handlebars-root js-typeahead-search-content dw-mod" id="ProductSearchBarContent" data-template="@options.searchTemplate" data-json-feed="/Default.aspx?ID=@options.searchFeedId&feedType=productsOnly" data-init-onload="false"></ul>
5584 }
5585 else
5586 {
5587 <div class="dropdown dropdown--absolute-position dropdown--combined grid">
5588 <div class="js-typeahead-search-content grid__col-sm-7 grid__col--bleed-y" id="ProductSearchBarContent" data-template="@options.searchTemplate" data-init-onload="false"></div>
5589 <div class="js-typeahead-additional-search-content grid__col-sm-5 grid__col--bleed-y" id="ContentSearchBarContent" data-template="@options.searchContentTemplate" data-init-onload="false"></div>
5590 </div>
5591 }
5592 </div>
5593 <button type="button" class="btn btn--condensed btn--primary u-no-margin dw-mod js-typeahead-enter-btn" title="@Translate("Search")"><i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue"></i></button>
5594 </div>
5595 }
5596
5597 @helper RenderMiniSearch(SearchConfiguration options)
5598 {
5599 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5600 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5601 <style>
5602 .is-dropdown:hover > #headerSearchWrapper{
5603 display: block;
5604 -webkit-animation-name:unset;
5605 animation-name:unset;
5606 -webkit-animation-duration: unset;
5607 animation-duration: unset;
5608 }
5609 </style>
5610 <li class="menu__item menu__item--horizontal menu__item--top-level menu__item--icon u-hidden-xxs is-dropdown is-dropdown--no-icon dw-mod" id="miniSearchIcon" onclick="toggleTopSearch()">
5611 <div class="@menuLinkClass dw-mod" title="@Translate("Search")">
5612 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue fa-1_5x"></i>
5613 </div>
5614 <div class="menu menu--dropdown menu--dropdown-right u-no-padding u-w380px grid__cell dw-mod" id="headerSearchWrapper" style="display:none;">
5615 <div class="typeahead js-typeahead" id="ProductSearchBar"
5616 data-page-size="7"
5617 data-search-feed-id="@(options.searchFeedId)&DoNotShowVariantsAsSingleProducts=True"
5618 data-search-second-feed-id="@(options.searchSecondFeedId)&DoNotShowVariantsAsSingleProducts=True"
5619 data-result-page-id="@options.resultPageLink"
5620 data-search-type="@options.searchType">
5621 <div class="typeahead-search-field">
5622 <input type="text" class="u-no-margin u-full-width js-typeahead-search-field" id="headerSearch" placeholder="@options.searchPlaceholder" value="@options.searchValue" onclick="event.stopPropagation();">
5623 @if (string.IsNullOrEmpty(options.searchSecondFeedId))
5624 {
5625 <ul class="dropdown dropdown--absolute-position u-min-w220px u-full-width js-handlebars-root js-typeahead-search-content dw-mod" id="ProductSearchBarContent" data-template="@options.searchTemplate" data-json-feed="/Default.aspx?ID=@options.searchFeedId&feedType=productsOnly&DoNotShowVariantsAsSingleProducts=True" data-init-onload="false"></ul>
5626 }
5627 else
5628 {
5629 <div class="dropdown dropdown--absolute-position dropdown--combined grid dropdown--right-aligned">
5630 <div class="js-handlebars-root js-typeahead-search-content grid__col-sm-7 grid__col--bleed-y" id="ProductSearchBarContent" data-template="@options.searchTemplate" data-json-feed="/Default.aspx?ID=@options.searchFeedId&feedType=productsOnly&DoNotShowVariantsAsSingleProducts=True" data-init-onload="false"></div>
5631 <div class="js-handlebars-root js-typeahead-additional-search-content grid__col-sm-5 grid__col--bleed-y" id="ContentSearchBarContent" data-template="@options.searchContentTemplate" data-json-feed="/Default.aspx?ID=@options.searchSecondFeedId" data-init-onload="false"></div>
5632 </div>
5633 }
5634 </div>
5635 </div>
5636 </div>
5637 </li>
5638 }
5639 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5640
5641 @using System
5642 @using System.Web
5643 @using Dynamicweb.Rapido.Blocks.Extensibility
5644 @using Dynamicweb.Rapido.Blocks
5645
5646 @{
5647 string headerConfigurationTopLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5648 bool headerConfigurationHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch");
5649
5650 BlocksPage headerConfigurationPage = BlocksPage.GetBlockPage("Master");
5651
5652 Block configDesktopLogo = headerConfigurationPage.GetBlockById("MasterDesktopLogo");
5653 headerConfigurationPage.RemoveBlock(configDesktopLogo);
5654
5655 Block configDesktopMenu = headerConfigurationPage.GetBlockById("MasterDesktopMenu");
5656 headerConfigurationPage.RemoveBlock(configDesktopMenu);
5657
5658 Block configSearchBar = headerConfigurationPage.GetBlockById("MasterSearchBar");
5659 headerConfigurationPage.RemoveBlock(configSearchBar);
5660
5661 Block configSearchAction = headerConfigurationPage.GetBlockById("MasterDesktopActionsMenuSearch");
5662 headerConfigurationPage.RemoveBlock(configSearchAction);
5663
5664 Block configDesktopActionsMenu = headerConfigurationPage.GetBlockById("MasterDesktopActionsMenu");
5665 headerConfigurationPage.RemoveBlock(configDesktopActionsMenu);
5666
5667 Block configDesktopExtra = headerConfigurationPage.GetBlockById("MasterDesktopExtra");
5668
5669 switch (headerConfigurationTopLayout)
5670 {
5671 case "condensed": //2
5672 configDesktopLogo.Design.Size = "auto-width";
5673 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo);
5674
5675 configDesktopMenu.SortId = 20;
5676 configDesktopMenu.Design.Size = "auto";
5677 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5678
5679 configDesktopActionsMenu.SortId = 30;
5680 configDesktopActionsMenu.Design.Size = "auto-width";
5681 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5682
5683 if (!headerConfigurationHideSearch)
5684 {
5685 configSearchBar.SortId = 40;
5686 configSearchBar.Design.Size = "12";
5687 configDesktopExtra.SortId = 50;
5688 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar);
5689 }
5690 break;
5691 case "splitted": //3
5692 configDesktopLogo.Design.Size = "auto";
5693 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5694
5695 if (!headerConfigurationHideSearch)
5696 {
5697 configSearchBar.SortId = 20;
5698 configSearchBar.Design.Size = "auto";
5699 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar);
5700 }
5701
5702 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5703
5704 configDesktopActionsMenu.SortId = 20;
5705 configDesktopActionsMenu.Design.Size = "auto-width";
5706 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5707 break;
5708 case "splitted-center": //4
5709 configDesktopLogo.Design.Size = "auto";
5710 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5711 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5712
5713 configDesktopActionsMenu.SortId = 30;
5714 configDesktopActionsMenu.Design.Size = "auto-width";
5715 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopActionsMenu);
5716
5717 if (!headerConfigurationHideSearch)
5718 {
5719 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5720 }
5721 break;
5722 case "minimal": //5
5723 configDesktopLogo.Design.Size = "auto-width";
5724 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo);
5725
5726 configDesktopMenu.Design.Size = "auto";
5727 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5728
5729 configDesktopActionsMenu.SortId = 20;
5730 configDesktopActionsMenu.Design.Size = "auto-width";
5731 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5732
5733 if (!headerConfigurationHideSearch)
5734 {
5735 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5736 }
5737 break;
5738 case "minimal-center": //6
5739 configDesktopLogo.Design.Size = "auto-width";
5740 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo);
5741
5742 configDesktopMenu.Design.Size = "auto";
5743 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5744
5745 configDesktopActionsMenu.SortId = 20;
5746 configDesktopActionsMenu.Design.Size = "auto-width";
5747 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5748
5749 if (!headerConfigurationHideSearch)
5750 {
5751 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5752 }
5753 break;
5754 case "minimal-right": //7
5755 configDesktopLogo.Design.Size = "auto-width";
5756 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo);
5757
5758 configDesktopMenu.Design.Size = "auto";
5759 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5760
5761 configDesktopActionsMenu.SortId = 20;
5762 configDesktopActionsMenu.Design.Size = "auto-width";
5763 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5764
5765 if (!headerConfigurationHideSearch)
5766 {
5767 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5768 }
5769 break;
5770 case "two-lines": //8
5771 configDesktopLogo.Design.Size = "auto";
5772 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5773
5774 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5775
5776 configDesktopActionsMenu.SortId = 20;
5777 configDesktopActionsMenu.Design.Size = "auto-width";
5778 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5779
5780 if (!headerConfigurationHideSearch)
5781 {
5782 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5783 }
5784 break;
5785 case "two-lines-centered": //9
5786 configDesktopLogo.Design.Size = "auto";
5787 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5788
5789 configDesktopMenu.Design.Size = "auto-width";
5790 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5791
5792 configDesktopActionsMenu.SortId = 20;
5793 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5794
5795 if (!headerConfigurationHideSearch)
5796 {
5797 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5798 }
5799 break;
5800 case "normal": //1
5801 default:
5802 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5803
5804 if (!headerConfigurationHideSearch)
5805 {
5806 configSearchBar.SortId = 20;
5807 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar);
5808 }
5809
5810 configDesktopActionsMenu.SortId = 30;
5811 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopActionsMenu);
5812
5813 configDesktopActionsMenu.Design.Size = "auto-width";
5814 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5815 break;
5816 }
5817 }
5818 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5819
5820 @using System
5821 @using System.Web
5822 @using Dynamicweb.Rapido.Blocks.Extensibility
5823 @using Dynamicweb.Rapido.Blocks
5824
5825 @{
5826
5827 }
5828
5829 @* Insert Simple Banner Widget *@
5830 @*<div data-key="Simple Banner" class="ft" id="ft3hmmu3v">
5831 </div>
5832 <script src="https://wdg.fouita.com/widgets/0x25d57e.js"></script>*@
5833
5834 @helper RenderDesktopTools()
5835 {
5836 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopTools").OrderBy(item => item.SortId).ToList();
5837
5838 <div class="tools-navigation dw-mod">
5839 <div class="center-container grid top-container__center-container dw-mod">
5840 @RenderBlockList(subBlocks)
5841 </div>
5842 </div>
5843 }
5844
5845 @helper RenderDesktopToolsText()
5846 {
5847 string toolsText = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("ToolsText");
5848 if (!string.IsNullOrEmpty(toolsText))
5849 {
5850 <div class="u-margin-top u-margin-bottom">@toolsText</div>
5851 }
5852 }
5853
5854 @helper RenderDesktopToolsNavigation()
5855 {
5856 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar");
5857
5858 if (renderPagesInToolBar)
5859 {
5860 @RenderNavigation(new
5861 {
5862 id = "topToolsNavigation",
5863 cssclass = "menu menu-tools dw-mod dwnavigation",
5864 template = "TopMenu.xslt"
5865 })
5866 }
5867 }
5868
5869 @helper RenderDesktopNavigation()
5870 {
5871 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopNavigation").OrderBy(item => item.SortId).ToList();
5872 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5873 string alignClass = topLayout == "two-lines-centered" ? "grid--justify-center" : "";
5874 <nav class="main-navigation dw-mod">
5875 <div class="center-container top-container__center-container grid @alignClass dw-mod">
5876 @RenderBlockList(subBlocks)
5877 </div>
5878 </nav>
5879 }
5880
5881 @helper RenderDesktopExtra()
5882 {
5883 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopExtra").OrderBy(item => item.SortId).ToList();
5884
5885 if (subBlocks.Count > 0)
5886 {
5887 <div class="header header-top dw-mod">
5888 <div class="center-container top-container__center-container grid--justify-space-between grid grid--align-center dw-mod">
5889 @RenderBlockList(subBlocks)
5890 </div>
5891 </div>
5892 }
5893 }
5894 </text>
5895 }
5896
5897 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5898
5899 @using System
5900 @using System.Web
5901 @using Dynamicweb.Rapido.Blocks.Extensibility
5902 @using Dynamicweb.Rapido.Blocks
5903 @using Dynamicweb.Rapido.Blocks.Components.General
5904 @using Dynamicweb.Frontend
5905
5906 @functions {
5907 int impersonationPageId;
5908 string impersonationLayout;
5909 int impersonationFeed;
5910 Block impersonationBar;
5911
5912 string getUserNameFromParams(string firstName, string middleName, string lastName, string name, string email, string userName)
5913 {
5914 string username = "";
5915
5916 if (!string.IsNullOrEmpty(firstName) && !string.IsNullOrEmpty(lastName))
5917 {
5918 username = firstName + " " + (!string.IsNullOrEmpty(middleName) ? middleName + " " : "") + lastName;
5919 }
5920 else if (!string.IsNullOrEmpty(name))
5921 {
5922 username = name;
5923 }
5924 else if (!string.IsNullOrEmpty(email))
5925 {
5926 username = email;
5927 }
5928 else
5929 {
5930 username = userName;
5931 }
5932 return username;
5933 }
5934
5935 string getUserName(UserViewModel user)
5936 {
5937 return getUserNameFromParams(user.FirstName, user.MiddleName, user.LastName, user.Name, user.Email, user.UserName);
5938 }
5939
5940 string getUserName(Dynamicweb.Security.UserManagement.User user)
5941 {
5942 return getUserNameFromParams(user.FirstName, user.MiddleName, user.LastName, user.Name, user.Email, user.UserName);
5943 }
5944 }
5945
5946 @{
5947 impersonationPageId = GetPageIdByNavigationTag("Impersonation");
5948 impersonationLayout = Model.Area.Item.GetItem("Ecommerce").GetList("ImpersonationLayout") != null ? Model.Area.Item.GetItem("Ecommerce").GetList("ImpersonationLayout").SelectedValue : "bar";
5949 impersonationFeed = GetPageIdByNavigationTag("UsersFeed");
5950
5951 if (Model.CurrentUser.ID > 0 && Model.SecondaryUsers.Count > 0)
5952 {
5953 impersonationBar = new Block
5954 {
5955 Id = "ImpersonationBar",
5956 SortId = 50,
5957 Template = RenderImpersonation(),
5958 SkipRenderBlocksList = true,
5959 Design = new Design
5960 {
5961 Size = "auto-width",
5962 HidePadding = true,
5963 RenderType = RenderType.Column
5964 }
5965 };
5966
5967 if (impersonationLayout == "top-bar") {
5968 impersonationBar.SortId = 9;
5969 }
5970
5971 Block impersonationContent = new Block
5972 {
5973 Id = "ImpersonationContent",
5974 SortId = 20
5975 };
5976
5977 if (Model.CurrentSecondaryUser != null && Model.CurrentSecondaryUser.ID > 0)
5978 {
5979 //Render stop impersonation view
5980 impersonationContent.Template = RenderStopImpersonationView();
5981
5982
5983 Modal stopImpersonation = new Modal
5984 {
5985 Id = "StopImpersonation",
5986 Heading = new Heading {
5987 Level = 2,
5988 Title = Translate("Sign out"),
5989 Icon = new Icon {
5990 Name = "fa-sign-out",
5991 Prefix = "fas",
5992 LabelPosition = IconLabelPosition.After
5993 }
5994 },
5995 Width = ModalWidth.Sm,
5996 BodyTemplate = RenderStopImpersonationForm()
5997 };
5998
5999 Block stopImpersonationBlock = new Block
6000 {
6001 Id = "StopImpersonationBlock",
6002 SortId = 10,
6003 Component = stopImpersonation
6004 };
6005 impersonationBar.BlocksList.Add(stopImpersonationBlock);
6006 }
6007 else
6008 {
6009 //Render main view
6010 switch (impersonationLayout)
6011 {
6012 case "right-lower-box":
6013 impersonationContent.BlocksList.Add(
6014 new Block {
6015 Id = "RightLowerBoxHeader",
6016 SortId = 10,
6017 Component = new Heading {
6018 Level = 5,
6019 Title = Translate("View the list of users you can sign in as"),
6020 CssClass = "impersonation-text"
6021 }
6022 }
6023 );
6024 impersonationContent.BlocksList.Add(
6025 new Block {
6026 Id = "RightLowerBoxContent",
6027 SortId = 20,
6028 Template = RenderImpersonationControls()
6029 }
6030 );
6031 break;
6032 case "right-lower-bar":
6033 impersonationContent.BlocksList.Add(
6034 new Block {
6035 Id = "RightLowerBarContent",
6036 SortId = 10,
6037 Template = RenderImpersonationControls()
6038 }
6039 );
6040 break;
6041 case "bar":
6042 default:
6043 impersonationContent.BlocksList.Add(
6044 new Block {
6045 Id = "ViewListLink",
6046 SortId = 20,
6047 Template = RenderViewListLink()
6048 }
6049 );
6050 impersonationContent.BlocksList.Add(
6051 new Block {
6052 Id = "BarTypeaheadSearch",
6053 SortId = 30,
6054 Template = RenderTypeaheadSearch()
6055 }
6056 );
6057 break;
6058 }
6059 }
6060 impersonationBar.BlocksList.Add(impersonationContent);
6061
6062 impersonationBar.BlocksList.Add(
6063 new Block
6064 {
6065 Id = "ImpersonationSearchTemplates",
6066 SortId = 30,
6067 Template = RenderSearchResultTemplate()
6068 }
6069 );
6070 if (impersonationLayout != "bar" && impersonationLayout != "top-bar")
6071 {
6072 impersonationBar.BlocksList.Add(
6073 new Block
6074 {
6075 Id = "ImpersonationSearchScripts",
6076 SortId = 40,
6077 Template = RenderSearchScripts()
6078 }
6079 );
6080 }
6081 BlocksPage.GetBlockPage("Master").Add("MasterHeader", impersonationBar);
6082 }
6083 }
6084
6085 @helper RenderImpersonation()
6086 {
6087 List<Block> subBlocks = impersonationBar.BlocksList.OrderBy(item => item.SortId).ToList();
6088 <input type="checkbox" class="impersonation-trigger js-remember-state" id="ImpersonationMinimizeTrigger" />
6089 <div class="impersonation impersonation--@(impersonationLayout)-layout dw-mod" id="Impersonation">
6090 @if (impersonationLayout == "right-lower-box")
6091 {
6092 @RenderRightLowerBoxHeader()
6093 }
6094 <div class="center-container top-container__center-container impersonation__container @(impersonationLayout != "bar" && impersonationLayout != "top-bar" ? "impersonation__container--box" : "") dw-mod">
6095 @*Impersonation*@
6096 @RenderBlockList(subBlocks)
6097 </div>
6098 </div>
6099 }
6100
6101 @helper RenderRightLowerBoxHeader()
6102 {
6103 <div class="impersonation__header dw-mod">
6104 <div class="impersonation__title">@Translate("Impersonation")</div>
6105 <label for="ImpersonationMinimizeTrigger" class="btn btn--impersonation impersonation__minimize-btn dw-mod" onclick="this.blur();">
6106 @Render(new Icon
6107 {
6108 Prefix = "fas",
6109 Name = "fa-window-minimize"
6110 })
6111 </label>
6112 </div>
6113 }
6114
6115 @helper RenderStopImpersonationView()
6116 {
6117 string secondaryUserName = getUserName(Model.CurrentSecondaryUser);
6118 string userName = getUserName(Pageview.User);
6119 string impersonationText = "<span class=\"impersonation-light-text dw-mod\">" + Translate("Logged in as") + "</span> <b>" + secondaryUserName + "</b> <span class=\"impersonation-light-text dw-mod\">" + Translate("by") + "</span> <b>" + userName + "</b> ";
6120 impersonationText = Dynamicweb.Security.UserManagement.User.ImpersonationMode == Dynamicweb.Security.UserManagement.UserImpersonation.Full ? "<span class=\"impersonation-light-text dw-mod\">" + Translate("Logged in as") + "</span> <b>" + userName + "</b> <span class=\"impersonation-light-text dw-mod\">" + Translate("by") + "</span> <b>" + secondaryUserName + "</b> " : impersonationText;
6121
6122 if (impersonationLayout == "right-lower-box")
6123 {
6124 <div class="u-margin-bottom--lg u-ta-center">
6125 @impersonationText
6126 </div>
6127 <div class="u-margin-bottom--lg u-ta-center">
6128 @RenderSwitchAccountButton()
6129 </div>
6130 @RenderStopImpersonationButton()
6131 }
6132 else
6133 {
6134 <div class="grid grid--align-center impersonation__stop-wrap">
6135 <div class="impersonation-bar-item dw-mod">
6136 @impersonationText
6137 </div>
6138 <div class="impersonation-bar-item dw-mod">
6139 @RenderSwitchAccountButton()
6140 </div>
6141 <div class="impersonation-bar-item dw-mod">
6142 @RenderStopImpersonationButton()
6143 </div>
6144 </div>
6145 }
6146 }
6147
6148 @helper RenderSwitchAccountButton() {
6149 @Render(new Button
6150 {
6151 Href = "/Default.aspx?ID=" + impersonationPageId,
6152 ButtonType = ButtonType.Button,
6153 ButtonLayout = ButtonLayout.Clean,
6154 Title = Translate("Switch account"),
6155 Icon = new Icon {
6156 Name = "fa-users",
6157 Prefix = "fal",
6158 LabelPosition = IconLabelPosition.After
6159 },
6160 CssClass = "u-no-margin u-color-inherit"
6161 })
6162 }
6163
6164 @helper RenderStopImpersonationForm()
6165 {
6166 string secondaryUserName = getUserName(Model.CurrentSecondaryUser);
6167 string userName = getUserName(Pageview.User);
6168 int pageId = Model.TopPage.ID;
6169
6170 <form method="post" class="u-no-margin">
6171 @Render(new Button
6172 {
6173 ButtonType = ButtonType.Submit,
6174 ButtonLayout = ButtonLayout.Secondary,
6175 Title = Translate("Sign out as") + " " + userName,
6176 Href = "/Default.aspx?ID=" + impersonationPageId,
6177 CssClass = "btn--full",
6178 Name = "DwExtranetRemoveSecondaryUser"
6179 })
6180
6181 @Render(new Button
6182 {
6183 ButtonType = ButtonType.Submit,
6184 ButtonLayout = ButtonLayout.Secondary,
6185 Title = Translate("Sign out as") + " " + secondaryUserName,
6186 Href = "/Admin/Public/ExtranetLogoff.aspx?ID=" + Model.Area.FirstActivePage.ID,
6187 CssClass = "btn--full",
6188 Name = "DwExtranetRemoveSecondaryUser"
6189 })
6190 </form>
6191 }
6192
6193 @helper RenderStopImpersonationButton() {
6194 @Render(new Button
6195 {
6196 ButtonType = ButtonType.Button,
6197 ButtonLayout = ButtonLayout.Clean,
6198 Title = Translate("Sign out"),
6199 Icon = new Icon {
6200 Name = "fa-sign-out",
6201 Prefix = "fal",
6202 LabelPosition = IconLabelPosition.After
6203 },
6204 OnClick = "document.getElementById('StopImpersonationModalTrigger').checked = true",
6205 CssClass = "u-no-margin"
6206 })
6207 }
6208
6209 @helper RenderImpersonationControls()
6210 {
6211 <div class="impersonation__controls">
6212 @RenderViewListLink()
6213 @RenderSearchBox()
6214 </div>
6215 @RenderResultsList()
6216 }
6217
6218 @helper RenderViewListLink()
6219 {
6220 string title = impersonationLayout == "right-lower-box" ? Translate("View the list") : Translate("View the list of users you can sign in as");
6221 string buttonClasses = impersonationLayout == "right-lower-box" ? "impersonation__button btn btn--impersonation" : "impersonation__link impersonation__link";
6222
6223 @Render(new Link {
6224 ButtonLayout = ButtonLayout.None,
6225 Title = title,
6226 Href = "/Default.aspx?ID=" + impersonationPageId,
6227 CssClass = buttonClasses
6228 })
6229 }
6230
6231 @helper RenderSearchBox()
6232 {
6233 <div class="impersonation__search-wrap">
6234 <input placeholder="@Translate("Search users")" type="text" class="impersonation__search-field dw-mod" onkeyup="searchKeyUpHandler(event)" id="ImpersonationBoxSearchField">
6235 <div id="ImpersonationBoxSearchFind" class="impersonation__search-icon dw-mod" onclick="updateResults(document.getElementById('ImpersonationBoxSearchField').value)">
6236 <i class="fal fa-search"></i>
6237 </div>
6238 <div id="ImpersonationBoxSearchClear" class="impersonation__search-icon u-hidden dw-mod" onclick="clearResults();">
6239 <i class="fal fa-times"></i>
6240 </div>
6241 </div>
6242 }
6243
6244 @helper RenderTypeaheadSearch()
6245 {
6246 <div class="typeahead u-ta-right impersonation__typeahead js-typeahead dw-mod" id="ImpersonationSearchBar"
6247 data-page-size="5"
6248 data-search-feed-id="@impersonationFeed"
6249 data-result-page-id="@impersonationPageId"
6250 data-search-type="user-search"
6251 data-search-parameter-name="q">
6252
6253 <div class="typeahead-search-field">
6254 <input type="text" class="u-no-margin u-full-width js-typeahead-search-field" placeholder="@Translate("Search users")">
6255 <ul class="dropdown dropdown--absolute-position u-min-w220px u-full-width js-handlebars-root js-typeahead-search-content dw-mod" id="ImpersonationSearchBarContent" data-template="ImpersonationSearchResult" data-json-feed="/Default.aspx?ID=@impersonationFeed" data-init-onload="false"></ul>
6256 </div>
6257 </div>
6258 }
6259
6260 @helper RenderResultsList()
6261 {
6262 <ul id="ImpersonationBoxSearchResults" class="impersonation__search-results js-handlebars-root dw-mod" data-template="ImpersonationSearchResult" data-json-feed="/Default.aspx?ID=@impersonationFeed" data-init-onload="false" data-preloader="minimal"></ul>
6263 }
6264
6265 @helper RenderSearchResultTemplate()
6266 {
6267 <script id="ImpersonationSearchResult" type="text/x-template">
6268 {{#.}}
6269 {{#Users}}
6270 <li class="impersonation__search-results-item impersonation-user">
6271 <form method="post" class="impersonation-user__form" name="account{{id}}">
6272 <input type="hidden" id="DWExtranetSecondaryUserSelector" name="DWExtranetSecondaryUserSelector" value="{{id}}">
6273 <div class="impersonation-user__info">
6274 <div class="impersonation-user__name">{{userName}}</div>
6275 <div class="impersonation-user__number">{{customerNumber}}</div>
6276 </div>
6277 @Render(new Button
6278 {
6279 ButtonType = ButtonType.Submit,
6280 ButtonLayout = ButtonLayout.Secondary,
6281 Title = Translate("Sign in as"),
6282 CssClass = "impersonation-user__sign-in-btn" + (impersonationLayout != "bar" ? " btn--impersonation" : "")
6283 })
6284 </form>
6285 </li>
6286 {{/Users}}
6287 {{#unless Users}}
6288 <li class="impersonation__search-results-item impersonation__search-results-item--not-found">
6289 @Translate("Your search gave 0 results")
6290 </li>
6291 {{/unless}}
6292 {{/.}}
6293 </script>
6294 }
6295
6296 @helper RenderSearchScripts()
6297 {
6298 <script>
6299 let inputDelayTimer;
6300 function searchKeyUpHandler(e) {
6301 clearTimeout(inputDelayTimer);
6302 let value = e.target.value;
6303 if (value != "") {
6304 inputDelayTimer = setTimeout(function () {
6305 updateResults(value);
6306 }, 500);
6307 } else {
6308 clearResults();
6309 }
6310 };
6311
6312 function updateResults(value) {
6313 if (value == "") {
6314 return null;
6315 }
6316 HandlebarsBolt.UpdateContent("ImpersonationBoxSearchResults", "/Default.aspx?ID=@impersonationFeed&q=" + value);
6317 document.getElementById("ImpersonationBoxSearchFind").classList.add("u-hidden");
6318 document.getElementById("ImpersonationBoxSearchClear").classList.remove("u-hidden");
6319 }
6320
6321 function clearResults() {
6322 document.getElementById("ImpersonationBoxSearchField").value = "";
6323 HandlebarsBolt.CleanContainer("ImpersonationBoxSearchResults");
6324 document.getElementById("ImpersonationBoxSearchFind").classList.remove("u-hidden");
6325 document.getElementById("ImpersonationBoxSearchClear").classList.add("u-hidden");
6326 }
6327 </script>
6328 }
6329 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
6330
6331 @using System
6332 @using System.Web
6333 @using System.Collections.Generic
6334 @using Dynamicweb.Rapido.Blocks.Extensibility
6335 @using Dynamicweb.Rapido.Blocks
6336
6337 @{
6338 BlocksPage miniCartBlocksPage = BlocksPage.GetBlockPage("Master");
6339 string orderlinesView = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("OrderlinesView") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("OrderlinesView").SelectedValue : "table";
6340
6341 Block orderLines = new Block
6342 {
6343 Id = "MiniCartOrderLines",
6344 SkipRenderBlocksList = true,
6345 BlocksList = new List<Block>
6346 {
6347 new Block {
6348 Id = "MiniCartOrderLinesList",
6349 SortId = 20,
6350 Template = RenderMiniCartOrderLinesList()
6351 }
6352 }
6353 };
6354
6355 Block orderlinesScriptTemplates = new Block
6356 {
6357 Id = "OrderlinesScriptTemplates"
6358 };
6359
6360 if (orderlinesView == "table")
6361 {
6362 orderLines.Template = RenderMiniCartOrderLinesTable();
6363 orderLines.BlocksList.Add(
6364 new Block
6365 {
6366 Id = "MiniCartOrderlinesTableHeader",
6367 SortId = 10,
6368 Template = RenderMiniCartOrderLinesHeader()
6369 }
6370 );
6371
6372 orderlinesScriptTemplates.Template = RenderMiniCartScriptsTableTemplates();
6373 }
6374 else
6375 {
6376 orderLines.Template = RenderMiniCartOrderLinesBlocks();
6377 orderlinesScriptTemplates.Template = RenderMiniCartScriptsListTemplates();
6378 }
6379
6380 miniCartBlocksPage.Add("MasterBottomSnippets", orderlinesScriptTemplates);
6381
6382 Block miniCartScriptTemplates = new Block()
6383 {
6384 Id = "MasterMiniCartTemplates",
6385 SortId = 1,
6386 Template = RenderMiniCartScriptTemplates(),
6387 SkipRenderBlocksList = true,
6388 BlocksList = new List<Block>
6389 {
6390 orderLines,
6391 new Block {
6392 Id = "MiniCartFooter",
6393 Template = RenderMiniCartFooter(),
6394 SortId = 50,
6395 SkipRenderBlocksList = true,
6396 BlocksList = new List<Block>
6397 {
6398 new Block {
6399 Id = "MiniCartSubTotal",
6400 Template = RenderMiniCartSubTotal(),
6401 SortId = 30
6402 },
6403 new Block {
6404 Id = "MiniCartFees",
6405 Template = RenderMiniCartFees(),
6406 SortId = 40
6407 },
6408 new Block {
6409 Id = "MiniCartPoints",
6410 Template = RenderMiniCartPoints(),
6411 SortId = 50
6412 },
6413 new Block {
6414 Id = "MiniCartTotal",
6415 Template = RenderMiniCartTotal(),
6416 SortId = 60
6417 },
6418 new Block {
6419 Id = "MiniCartDisclaimer",
6420 Template = RenderMiniCartDisclaimer(),
6421 SortId = 70
6422 },
6423 new Block {
6424 Id = "MiniCartActions",
6425 Template = RenderMiniCartActions(),
6426 SortId = 80
6427 }
6428 }
6429 }
6430 }
6431 };
6432
6433 miniCartBlocksPage.Add("MasterBottomSnippets", miniCartScriptTemplates);
6434 }
6435
6436 @helper RenderMiniCartScriptsTableTemplates()
6437 {
6438 <script id="MiniCartOrderline" type="text/x-template">
6439 {{#unless isEmpty}}
6440 <tr>
6441 <td class="u-w60px"><a href="{{link}}" class="{{hideimage}}"><img class="b-lazy" src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=50&height=50&crop=5&Compression=75&image={{image}}" alt="{{name}}" title="{{name}}"></a></td>
6442 <td class="u-va-middle">
6443 <a href="{{link}}" class="mini-cart-orderline__name" title="{{name}}">{{name}}</a>
6444 {{#if variantname}}
6445 <a href="{{link}}" class="mini-cart-orderline__name mini-cart-orderline__name--sm">{{variantname}}</a>
6446 {{/if}}
6447 {{#if unitname}}
6448 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm">{{unitname}}</div>
6449 {{/if}}
6450 </td>
6451 <td class="u-ta-right u-va-middle">{{quantity}}</td>
6452 <td class="u-ta-right u-va-middle">
6453 {{#if pointsTotal}}
6454 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points")
6455 {{else}}
6456 {{totalprice}}
6457 {{/if}}
6458 </td>
6459 </tr>
6460 {{/unless}}
6461 </script>
6462
6463 <script id="MiniCartOrderlineDiscount" type="text/x-template">
6464 {{#unless isEmpty}}
6465 <tr class="table__row--no-border">
6466 <td class="u-w60px"> </td>
6467 <td><div class="mini-cart-orderline__name dw-mod">{{name}}</div></td>
6468 <td class="u-ta-right"> </td>
6469 <td class="u-ta-right">{{totalprice}}</td>
6470 </tr>
6471 {{/unless}}
6472 </script>
6473 }
6474
6475 @helper RenderMiniCartScriptsListTemplates()
6476 {
6477 int cartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
6478
6479 <script id="MiniCartOrderline" type="text/x-template">
6480 {{#unless isEmpty}}
6481 <div class="mini-cart-orderline grid dw-mod">
6482 <div class="grid__col-4">
6483 <a href="{{link}}" class="{{hideimage}}">
6484 <img class="b-lazy" src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=100&height=100&crop=5&Compression=75&image={{image}}" alt="{{name}}" title="{{name}}">
6485 </a>
6486 </div>
6487 <div class="grid__col-8">
6488 <a href="{{link}}" class="mini-cart-orderline__name mini-cart-orderline__name--truncate mini-cart-orderline__name--md u-padding-right--lg" title="{{name}}">{{name}}</a>
6489 {{#if variantname}}
6490 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Variant"): {{variantname}}</div>
6491 {{/if}}
6492 {{#if unitname}}
6493 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Unit"): {{unitname}}</div>
6494 {{/if}}
6495 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Qty"): {{quantity}}</div>
6496
6497 <div class="grid__cell-footer">
6498 <div class="grid__cell">
6499 <div class="u-pull--left mini-cart-orderline__price dw-mod">
6500 {{#if pointsTotal}}
6501 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points")
6502 {{else}}
6503 {{totalprice}}
6504 {{/if}}
6505 </div>
6506 <button type="button"
6507 title="@Translate("Remove orderline")"
6508 class="btn btn--clean btn--condensed u-pull--right mini-cart-orderline__remove-btn dw-mod"
6509 onclick="{{#if googleImpression}}googleImpressionRemoveFromCart({{googleImpression}});{{/if}}Cart.UpdateCart('miniCartContent', '/Default.aspx?ID=@cartFeedPageId', 'CartCmd=DelOrderLine&key={{orderLineId}}&redirect=false', true);">@Translate("Remove")</button>
6510 </div>
6511 </div>
6512 </div>
6513 </div>
6514 {{/unless}}
6515 </script>
6516
6517 <script id="MiniCartOrderlineDiscount" type="text/x-template">
6518 {{#unless isEmpty}}
6519 <div class="mini-cart-orderline mini-cart-orderline--discount grid dw-mod">
6520 <div class="grid__col-4">
6521 <div class="mini-cart-orderline__name mini-cart-orderline__name dw-mod">{{name}}</div>
6522 </div>
6523 <div class="grid__col-8">{{totalprice}}</div>
6524 </div>
6525 {{/unless}}
6526 </script>
6527 }
6528
6529 @helper RenderMiniCartScriptTemplates()
6530 {
6531 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterMiniCartTemplates").OrderBy(item => item.SortId).ToList();
6532 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID"));
6533 string cartPageLink = string.Concat("/Default.aspx?ID=", GetPageIdByNavigationTag("CartPage"));
6534 bool miniCartUseGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID"));
6535
6536 <script id="MiniCartContent" type="text/x-template">
6537 {{#.}}
6538 {{#unless isEmpty}}
6539 @if (miniCartUseGoogleTagManager)
6540 {
6541 <text>{{{googleEnchantImpressionEmptyCart OrderLines}}}</text>
6542 }
6543 @RenderBlockList(subBlocks)
6544 {{/unless}}
6545 {{/.}}
6546 </script>
6547 }
6548
6549 @helper RenderMiniCartOrderLinesTable()
6550 {
6551 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartOrderLines").OrderBy(item => item.SortId).ToList();
6552
6553 <div class="u-overflow-auto">
6554 <table class="table mini-cart-table dw-mod">
6555 @RenderBlockList(subBlocks)
6556 </table>
6557 </div>
6558 }
6559
6560 @helper RenderMiniCartOrderLinesBlocks()
6561 {
6562 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartOrderLines").OrderBy(item => item.SortId).ToList();
6563
6564 <div class="u-overflow-auto">
6565 @RenderBlockList(subBlocks)
6566 </div>
6567 }
6568
6569 @helper RenderMiniCartOrderLinesHeader()
6570 {
6571 <thead>
6572 <tr>
6573 <td> </td>
6574 <td>@Translate("Product")</td>
6575 <td class="u-ta-right">@Translate("Qty")</td>
6576 <td class="u-ta-right" width="120">@Translate("Price")</td>
6577 </tr>
6578 </thead>
6579 }
6580
6581 @helper RenderMiniCartOrderLinesList()
6582 {
6583 <text>
6584 {{#OrderLines}}
6585 {{#ifCond template "===" "CartOrderline"}}
6586 {{>MiniCartOrderline}}
6587 {{/ifCond}}
6588 {{#ifCond template "===" "CartOrderlineMobile"}}
6589 {{>MiniCartOrderline}}
6590 {{/ifCond}}
6591 {{#ifCond template "===" "CartOrderlineDiscount"}}
6592 {{>MiniCartOrderlineDiscount}}
6593 {{/ifCond}}
6594 {{/OrderLines}}
6595 </text>
6596 }
6597
6598 @helper RenderMiniCartFees()
6599 {
6600 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly");
6601 if (!pointShop)
6602 {
6603 <text>
6604 {{#unless hidePaymentfee}}
6605 <div class="grid">
6606 <div class="grid__col-6 grid__col--bleed-y">
6607 {{paymentmethod}}
6608 </div>
6609 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{paymentfee}}</div>
6610 </div>
6611 {{/unless}}
6612 </text>
6613 }
6614 <text>
6615 {{#unless hideShippingfee}}
6616 <div class="grid">
6617 <div class="grid__col-6 grid__col--bleed-y">
6618 {{shippingmethod}}
6619 </div>
6620 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{shippingfee}}</div>
6621 </div>
6622 {{/unless}}
6623 </text>
6624 <text>
6625 {{#if hasTaxSettings}}
6626 <div class="grid">
6627 <div class="grid__col-6 grid__col--bleed-y">@Translate("Sales Tax")</div>
6628 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{totaltaxes}}</div>
6629 </div>
6630 {{/if}}
6631 </text>
6632 }
6633
6634 @helper RenderMiniCartFooter()
6635 {
6636 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartFooter").OrderBy(item => item.SortId).ToList();
6637
6638 <div class="mini-cart__footer u-border-top u-padding-top dw-mod">
6639 @RenderBlockList(subBlocks)
6640 </div>
6641 }
6642
6643 @helper RenderMiniCartActions()
6644 {
6645 int cartPageId = GetPageIdByNavigationTag("CartPage");
6646
6647 <button type="button" title="@Translate("Empty cart")" class="btn btn--secondary u-full-width dw-mod u-no-margin u-margin-bottom" onclick="googleEnchantImpressionEmptyCart(); Cart.EmptyCart(event);">@Translate("Empty cart")</button>
6648 <a href="/Default.aspx?ID=@cartPageId" title="@Translate("Go to cart")" class="btn btn--primary u-full-width u-no-margin dw-mod">@Translate("Go to cart")</a>
6649 }
6650
6651 @helper RenderMiniCartPoints()
6652 {
6653 <text>
6654 {{#if earnings}}
6655 <div class="grid">
6656 <div class="grid__col-6 grid__col--bleed-y">@Translate("Earnings")</div>
6657 <div class="grid__col-6 grid__col--bleed-y grid--align-end">
6658 <div>
6659 <span class="u-color--loyalty-points">{{earnings}}</span> @Translate("points")
6660 </div>
6661 </div>
6662 </div>
6663 {{/if}}
6664 </text>
6665 }
6666
6667 @helper RenderMiniCartSubTotal()
6668 {
6669 bool hasTaxSettings = Dynamicweb.Rapido.Services.Countries.HasTaxSettings(Model.Cart.ID);
6670 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly");
6671 if (!pointShop)
6672 {
6673 <text>
6674 {{#unless hideSubTotal}}
6675 <div class="grid dw-mod u-bold">
6676 <div class="grid__col-6 grid__col--bleed-y">@Translate("Subtotal")</div>
6677 <div class="grid__col-6 grid__col--bleed-y grid--align-end">
6678 @if (hasTaxSettings)
6679 {
6680 <text>{{subtotalpricewithouttaxes}}</text>
6681 }
6682 else
6683 {
6684 <text>{{subtotalprice}}</text>
6685 }
6686 </div>
6687 </div>
6688 {{/unless}}
6689 </text>
6690 }
6691 }
6692
6693 @helper RenderMiniCartTotal()
6694 {
6695 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly");
6696
6697 <div class="mini-cart-totals grid u-border-top u-margin-top dw-mod">
6698 <div class="grid__col-6">@Translate("Total")</div>
6699 <div class="grid__col-6 grid--align-end">
6700 <div>
6701 @if (pointShop)
6702 {
6703 <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points")
6704 }
6705 else
6706 {
6707 <text>{{totalprice}}</text>
6708 }
6709 </div>
6710 </div>
6711 </div>
6712 }
6713
6714 @helper RenderMiniCartDisclaimer()
6715 {
6716 <text>
6717 {{#if showCheckoutDisclaimer}}
6718 <div class="grid u-margin-bottom u-ta-right">
6719 <small class="grid__col-12">{{checkoutDisclaimer}}</small>
6720 </div>
6721 {{/if}}
6722 </text>
6723 }
6724 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
6725
6726 @using Dynamicweb.Rapido.Blocks.Extensibility
6727 @using Dynamicweb.Rapido.Blocks
6728 @using Dynamicweb.Rapido.Blocks.Components.General
6729 @using Dynamicweb.Rapido.Blocks.Components
6730 @using Dynamicweb.Rapido.Services
6731
6732 @{
6733 string addToCartNotificationType = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("AddToCartNotificationType") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("AddToCartNotificationType").SelectedValue : "";
6734 string addToCartNotificationMiniCartLayout = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout").SelectedValue : "dropdown";
6735 bool addToCartHideCartIcon = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart");
6736
6737 if (!addToCartHideCartIcon) {
6738 addToCartHideCartIcon = Gobo.UserService.IsInGroup_GuestAccounts(Dynamicweb.Security.UserManagement.User.GetCurrentExtranetUser());
6739 }
6740
6741 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed() && !string.IsNullOrEmpty(addToCartNotificationType))
6742 {
6743 if (addToCartNotificationType == "modal")
6744 {
6745 Block addToCartNotificationModal = new Block
6746 {
6747 Id = "AddToCartNotificationModal",
6748 Template = RenderAddToCartNotificationModal()
6749 };
6750
6751 Block addToCartNotificationScript = new Block
6752 {
6753 Id = "AddToCartNotificationScript",
6754 Template = RenderAddToCartNotificationModalScript()
6755 };
6756 BlocksPage.GetBlockPage("Master").Add("MasterTopSnippets", addToCartNotificationModal);
6757 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", addToCartNotificationScript);
6758 }
6759 else if (addToCartNotificationType == "toggle" && addToCartNotificationMiniCartLayout != "none" && !addToCartHideCartIcon && Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet")
6760 {
6761 Block addToCartNotificationScript = new Block
6762 {
6763 Id = "AddToCartNotificationScript",
6764 Template = RenderAddToCartNotificationToggleScript()
6765 };
6766 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", addToCartNotificationScript);
6767 }
6768 }
6769 }
6770
6771 @helper RenderAddToCartNotificationModal()
6772 {
6773 <div id="LastAddedProductModal" data-template="LastAddedProductTemplate"></div>
6774 }
6775
6776 @helper RenderAddToCartNotificationModalScript()
6777 {
6778 int cartPageId = GetPageIdByNavigationTag("CartPage");
6779
6780 <script id="LastAddedProductTemplate" type="text/x-template">
6781 @{
6782
6783 Modal lastAddedProduct = new Modal
6784 {
6785 Id = "LastAddedProduct",
6786 Heading = new Heading
6787 {
6788 Level = 2,
6789 Title = Translate("Product is added to the cart")
6790 },
6791 Width = ModalWidth.Md,
6792 BodyTemplate = RenderModalContent()
6793 };
6794
6795 lastAddedProduct.AddActions(
6796 new Button
6797 {
6798 ButtonType = ButtonType.Button,
6799 ButtonLayout = ButtonLayout.Secondary,
6800 Title = Translate("Continue shopping"),
6801 CssClass = "u-pull--left u-no-margin btn--sm",
6802 OnClick = "document.getElementById('LastAddedProductModalTrigger').checked = false"
6803 },
6804 new Link
6805 {
6806 Href = "/Default.aspx?ID=" + cartPageId,
6807 ButtonLayout = ButtonLayout.Secondary,
6808 CssClass = "u-pull--right u-no-margin btn--sm",
6809 Title = Translate("Proceed to checkout"),
6810 OnClick = "document.getElementById('LastAddedProductModalTrigger').checked = false"
6811 }
6812 );
6813
6814 @Render(lastAddedProduct)
6815 }
6816 </script>
6817 <script>
6818 document.addEventListener('addToCart', function (event) {
6819 Cart.ShowLastAddedProductModal(event.detail);
6820 });
6821 </script>
6822 }
6823
6824 @helper RenderModalContent()
6825 {
6826 <div class="grid">
6827 <div class="grid__col-2">
6828 @Render(new Image { Path = "{{ productInfo.image }}", Link = "{{ productInfo.link }}", Title = "{{ productInfo.name }}", DisableImageEngine = true })
6829 </div>
6830 <div class="u-padding grid--align-self-center">
6831 <span>{{quantity}}</span> x
6832 </div>
6833 <div class="grid__col-auto grid--align-self-center">
6834 <div>{{productInfo.name}}</div>
6835 {{#if productInfo.variantName}}
6836 <small class="u-margin-bottom-5px">{{productInfo.variantName}}</small>
6837 {{/if}}
6838 {{#if productInfo.unitName}}
6839 <small class="u-margin-bottom-5px">{{productInfo.unitName}}</small>
6840 {{/if}}
6841 </div>
6842 </div>
6843 }
6844
6845 @helper RenderAddToCartNotificationToggleScript()
6846 {
6847 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
6848
6849 <script>
6850 document.addEventListener('addToCart', function () {
6851 Cart.ToggleMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '@miniCartFeedPageId');
6852 });
6853 </script>
6854 }
6855 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
6856
6857 @using System
6858 @using System.Web
6859 @using System.Collections.Generic
6860 @using Dynamicweb.Rapido.Blocks.Extensibility
6861 @using Dynamicweb.Rapido.Blocks
6862 @using Dynamicweb.Rapido.Blocks.Components.General
6863
6864 @functions {
6865 BlocksPage footerBlocksPage = BlocksPage.GetBlockPage("Master");
6866 }
6867
6868 @{
6869 string footerColumnOneContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnOne").GetString("Content");
6870 string footerColumnTwoContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnTwo").GetString("Content");
6871 string footerColumnThreeContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnThree").GetString("Content");
6872 string footerColumnFourContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnFour").GetString("Content");
6873 string footerColumnOneHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnOne").GetString("Header");
6874 string footerColumnTwoHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnTwo").GetString("Header");
6875 string footerColumnThreeHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnThree").GetString("Header");
6876 string footerColumnFourHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnFour").GetString("Header");
6877
6878 Block masterFooterContent = new Block()
6879 {
6880 Id = "MasterFooterContent",
6881 SortId = 10,
6882 Template = RenderFooter(),
6883 SkipRenderBlocksList = true
6884 };
6885 footerBlocksPage.Add(MasterBlockId.MasterFooter, masterFooterContent);
6886
6887 if (!string.IsNullOrEmpty(footerColumnOneContent) || !string.IsNullOrEmpty(footerColumnOneHeader))
6888 {
6889 Block masterFooterColumnOne = new Block
6890 {
6891 Id = "MasterFooterColumnOne",
6892 SortId = 10,
6893 Template = RenderFooterColumn(footerColumnOneHeader, footerColumnOneContent),
6894 Design = new Design
6895 {
6896 Size = "auto",
6897 RenderType = RenderType.Column
6898 }
6899 };
6900 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnOne);
6901 }
6902
6903
6904 if (!string.IsNullOrEmpty(footerColumnTwoContent) || !string.IsNullOrEmpty(footerColumnTwoHeader))
6905 {
6906 Block masterFooterColumnTwo = new Block
6907 {
6908 Id = "MasterFooterColumnTwo",
6909 SortId = 20,
6910 Template = RenderFooterColumn(footerColumnTwoHeader, footerColumnTwoContent),
6911 Design = new Design
6912 {
6913 Size = "auto",
6914 RenderType = RenderType.Column
6915 }
6916 };
6917 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnTwo);
6918 }
6919
6920 if (!string.IsNullOrEmpty(footerColumnThreeContent) || !string.IsNullOrEmpty(footerColumnThreeHeader))
6921 {
6922 Block masterFooterColumnThree = new Block
6923 {
6924 Id = "MasterFooterColumnThree",
6925 SortId = 30,
6926 Template = RenderFooterColumn(footerColumnThreeHeader, footerColumnThreeContent),
6927 Design = new Design
6928 {
6929 Size = "auto",
6930 RenderType = RenderType.Column
6931 }
6932 };
6933 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnThree);
6934 }
6935
6936 if (!string.IsNullOrEmpty(footerColumnFourContent) || !string.IsNullOrEmpty(footerColumnFourHeader))
6937 {
6938 Block masterFooterColumnFour = new Block
6939 {
6940 Id = "MasterFooterColumnFour",
6941 SortId = 30,
6942 Template = RenderFooterColumn(footerColumnFourHeader, footerColumnFourContent),
6943 Design = new Design
6944 {
6945 Size = "auto",
6946 RenderType = RenderType.Column
6947 }
6948 };
6949 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnFour);
6950 }
6951
6952
6953 if (Model.Area.Item.GetItem("Layout").GetBoolean("FooterNewsletterSignUp"))
6954 {
6955 Block masterFooterNewsletterSignUp = new Block
6956 {
6957 Id = "MasterFooterNewsletterSignUp",
6958 SortId = 40,
6959 Template = RenderFooterNewsletterSignUp(),
6960 Design = new Design
6961 {
6962 Size = "auto",
6963 RenderType = RenderType.Column
6964 }
6965 };
6966 footerBlocksPage.Add("MasterFooterContent", masterFooterNewsletterSignUp);
6967 }
6968
6969 if (Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks") != null && Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks").Count > 0)
6970 {
6971 Block masterFooterSocialLinks = new Block
6972 {
6973 Id = "MasterFooterSocialLinks",
6974 SortId = 50,
6975 Template = RenderFooterSocialLinks(),
6976 Design = new Design
6977 {
6978 Size = "auto",
6979 RenderType = RenderType.Column
6980 }
6981 };
6982 footerBlocksPage.Add("MasterFooterContent", masterFooterSocialLinks);
6983 }
6984
6985 if (Model.Area.Item.GetItem("Layout").GetItems("FooterPayments") != null && Model.Area.Item.GetItem("Layout").GetItems("FooterPayments").Count > 0)
6986 {
6987 Block masterFooterPayments = new Block
6988 {
6989 Id = "MasterFooterPayments",
6990 SortId = 60,
6991 Template = RenderFooterPayments(),
6992 Design = new Design
6993 {
6994 Size = "12",
6995 RenderType = RenderType.Column
6996 }
6997 };
6998 footerBlocksPage.Add("MasterFooterContent", masterFooterPayments);
6999 }
7000
7001 Block masterFooterCopyright = new Block
7002 {
7003 Id = "MasterFooterCopyright",
7004 SortId = 70,
7005 Template = RenderFooterCopyright(),
7006 Design = new Design
7007 {
7008 Size = "12",
7009 RenderType = RenderType.Column
7010 }
7011 };
7012 footerBlocksPage.Add("MasterFooterContent", masterFooterCopyright);
7013 }
7014
7015 @helper RenderFooter()
7016 {
7017 List<Block> subBlocks = this.footerBlocksPage.GetBlockListById("MasterFooterContent").OrderBy(item => item.SortId).ToList();
7018
7019 <footer class="footer no-print dw-mod">
7020 <div class="center-container top-container__center-container dw-mod">
7021 <div class="grid grid--external-bleed-x">
7022 @RenderBlockList(subBlocks)
7023 </div>
7024 </div>
7025 </footer>
7026 }
7027
7028 @helper RenderFooterColumn(string header, string content)
7029 {
7030 <h3 class="footer__heading dw-mod">@header</h3>
7031 <div class="footer__content dw-mod">
7032 @content
7033 </div>
7034 }
7035
7036 @helper RenderFooterNewsletterSignUp()
7037 {
7038 string newsletterSignUpPageId = GetPageIdByNavigationTag("NewsletterSignUp").ToString();
7039 Form form = new Form { Action = "/Default.aspx", Method = FormMethod.Get, Enctype = FormEnctype.multipart };
7040
7041 form.Add(new HiddenField { Name = "ID", Value = newsletterSignUpPageId });
7042 form.Add(new Text { Content = "<p>" + Translate("Sign up if you would like to receive occasional treats from us") + "</p>" });
7043 form.Add(new TextField {
7044 Id = "NewsletterEmail", Name = "NewsletterEmail", Placeholder = Translate("Your email address"),
7045 Type = TextFieldType.Email,
7046 ActionButton = new Button {
7047 ButtonType = ButtonType.Submit, Id="Submitter", Title = Translate("Go"), OnClick = "Buttons.LockButton(event)", CssClass = "btn--condensed"
7048 }
7049 });
7050
7051 <h3 class="footer__heading dw-mod">@Translate("Mailing list")</h3>
7052 <div class="footer__content dw-mod">
7053 @Render(form)
7054 </div>
7055 }
7056
7057 @helper RenderFooterSocialLinks()
7058 {
7059 <h3 class="footer__heading dw-mod">@Translate("Social links")</h3>
7060 <div class="footer__content dw-mod">
7061 <div class="collection dw-mod">
7062 @foreach (var socialitem in Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks"))
7063 {
7064 var socialIcon = socialitem.GetValue("Icon") as Dynamicweb.Frontend.ListViewModel;
7065 string socialIconClass = socialIcon.SelectedValue;
7066 string socialIconTitle = socialIcon.SelectedName;
7067 string socialLink = socialitem.GetString("Link");
7068
7069 <a href="@socialLink" target="_blank" title="@socialIconTitle" class="u-margin-bottom-5px" rel="noopener"><i class="@socialIconClass fa-2x"></i></a>
7070 }
7071 </div>
7072 </div>
7073 }
7074
7075 @helper RenderFooterPayments()
7076 {
7077 <div class="footer__content dw-mod">
7078 <div class="collection dw-mod">
7079 @foreach (var payment in Model.Area.Item.GetItem("Layout").GetItems("FooterPayments"))
7080 {
7081 var paymentItem = payment.GetValue("CardTypeOrVerifiedPayment") as Dynamicweb.Frontend.ListViewModel;
7082 string paymentImage = null;
7083 string paymentTitle = paymentItem.SelectedName;
7084 ListOptionViewModel selected = paymentItem.SelectedOptions.FirstOrDefault();
7085 if (selected != null)
7086 {
7087 paymentImage = selected.Icon;
7088 }
7089
7090 <div class="footer__card-type">
7091 <img class="b-lazy" src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=60&Compression=75&image=@paymentImage" alt="@paymentTitle" title="@paymentTitle" />
7092 </div>
7093 }
7094 </div>
7095 </div>
7096 }
7097
7098 @helper RenderFooterCopyright()
7099 {
7100 <div class="grid__col-12 footer__copyright dw-mod">
7101 <p>@Model.Area.Item.GetItem("Layout").GetString("FooterCopyrightText")</p>
7102 </div>
7103 }
7104 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
7105
7106 @using System
7107 @using System.Web
7108 @using System.Collections.Generic
7109 @using Dynamicweb.Rapido.Blocks.Extensibility
7110 @using Dynamicweb.Rapido.Blocks
7111 @using Dynamicweb.Ecommerce.Common
7112
7113 @{
7114 BlocksPage referencesBlocksPage = BlocksPage.GetBlockPage("Master");
7115
7116 Block masterScriptReferences = new Block()
7117 {
7118 Id = "MasterScriptReferences",
7119 SortId = 1,
7120 Template = RenderMasterScriptReferences()
7121 };
7122 referencesBlocksPage.Add(MasterBlockId.MasterReferences, masterScriptReferences);
7123 }
7124
7125 @helper RenderMasterScriptReferences() {
7126 <script src="/Files/Templates/Designs/Rapido/js/handlebars-v4.0.12.min.js"></script>
7127 <script src="/Files/Templates/Designs/Rapido/js/master.min.js?ticks=@(Pageview.Area.Audit.LastModifiedAt.Ticks)"></script>
7128
7129 if (Model.Area.Item.GetItem("Custom").GetBoolean("UseCustomJavascript"))
7130 {
7131 <script src="/Files/Templates/Designs/Rapido/js/custom.min.js?ticks=@(Pageview.Area.Audit.LastModifiedAt.Ticks)"></script>
7132 PushPromise("/Files/Templates/Designs/Rapido/js/custom.min.js");
7133 }
7134
7135 PushPromise("/Files/Templates/Designs/Rapido/js/handlebars-v4.0.12.min.js");
7136 PushPromise("/Files/Templates/Designs/Rapido/js/master.min.js");
7137 }
7138 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
7139
7140 @using System
7141 @using System.Web
7142 @using System.Collections.Generic
7143 @using Dynamicweb.Rapido.Blocks.Extensibility
7144 @using Dynamicweb.Rapido.Blocks
7145 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce
7146 @using Dynamicweb.Rapido.Services
7147
7148 @{
7149 BlocksPage searchBlocksPage = BlocksPage.GetBlockPage("Master");
7150 bool navigationItemsHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch");
7151 bool isFavoriteList = !string.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("ListID"));
7152
7153 if (!navigationItemsHideSearch || isFavoriteList)
7154 {
7155 Block masterSearchScriptTemplates = new Block()
7156 {
7157 Id = "MasterSearchScriptTemplates",
7158 SortId = 1,
7159 Template = RenderSearchScriptTemplates()
7160 };
7161
7162 searchBlocksPage.Add(MasterBlockId.MasterBottomSnippets, masterSearchScriptTemplates);
7163 }
7164 }
7165
7166 @helper RenderSearchScriptTemplates()
7167 {
7168 int productsPageId = GetPageIdByNavigationTag("ProductsPage");
7169 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID;
7170 bool useFacebookPixel = !string.IsNullOrWhiteSpace(Pageview.AreaSettings.GetItem("Settings").GetString("FacebookPixelID"));
7171 bool useGoogleTagManager = !string.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("GoogleTagManagerID"));
7172 bool showPrice = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HidePriceInSearchResults");
7173 bool showAddToCartButton = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HideAddToCartButton");
7174 bool showViewButton = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HideViewButton");
7175 bool showAddToDownloadButton = Pageview.AreaSettings.GetItem("Layout").GetBoolean("ShowAddToDownloadButton");
7176 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly");
7177
7178 <script id="SearchGroupsTemplate" type="text/x-template">
7179 {{#.}}
7180 <li class="dropdown__item dw-mod" onclick="Search.UpdateGroupSelection(this)" data-group-id="{{id}}">{{name}}</li>
7181 {{/.}}
7182 </script>
7183
7184 <script id="SearchProductsTemplate" type="text/x-template">
7185 {{#each .}}
7186 {{#Product}}
7187 {{#ifCond template "!==" "SearchMore"}}
7188 <li class="dropdown__item dropdown__item--seperator dw-mod">
7189 @if (useFacebookPixel)
7190 {
7191 <text>{{{facebookPixelSearch name number priceDouble currency searchParameter}}}</text>
7192 }
7193 @if (useGoogleTagManager)
7194 {
7195 <text>{{{googleEnchantImpression googleImpression}}}</text>
7196 }
7197 <div>
7198 <a href="{{link}}"
7199 class="js-typeahead-link u-color-inherit u-pull--left"
7200 onclick="{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}"
7201 title="{{name}}">
7202 <div class="u-margin-right u-pull--left {{noimage}} u-hidden-xs u-hidden-xxs"><img class="b-lazy" src="/Files/Images/placeholder.gif" data-src="/Admin/Public/GetImage.ashx?width=45&height=36&crop=5&FillCanvas=True&Compression=75&image={{image}}" alt="{{name}}"></div>
7203 <div class="u-pull--left">
7204 <div class="u-bold u-max-w220px u-truncate-text js-typeahead-name">{{name}}</div>
7205 @if (showPrice && Dynamicweb.Rapido.Services.User.IsPricesAllowed())
7206 {
7207 if (pointShopOnly)
7208 {
7209 <text>
7210 {{#if havePointPrice}}
7211 <div>
7212 <span class="u-color--loyalty-points">{{points}}</span> @Translate("points")
7213 </div>
7214 {{else}}
7215 <small class="help-text u-no-margin">@Translate("Not available")</small>
7216 {{/if}}
7217 {{#unless canBePurchasedWithPoints}}
7218 {{#if havePointPrice}}
7219 <small class="help-text u-no-margin">@Translate("Not enough points to buy this")</small>
7220 {{/if}}
7221 {{/unless}}
7222 </text>
7223 }
7224 else
7225 {
7226 <div>{{price}}</div>
7227 }
7228 }
7229 </div>
7230 </a>
7231 <div class="u-margin-left u-pull--right">
7232 @{
7233 var viewBtn = new Link
7234 {
7235 Href = "{{link}}",
7236 OnClick = "{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}",
7237 ButtonLayout = ButtonLayout.Secondary,
7238 CssClass = "btn--condensed u-no-margin u-w80px js-ignore-click-outside",
7239 Title = Translate("View")
7240 };
7241 }
7242 @if (showAddToCartButton && Dynamicweb.Rapido.Services.User.IsBuyingAllowed())
7243 {
7244 <text>{{#if hideAddToCartButton}}</text>
7245 @Render(viewBtn)
7246 <text>{{else}}</text>
7247 <text>{{#if price}}</text>
7248 @Render(new AddToCartButton
7249 {
7250 HideTitle = true,
7251 ProductId = "{{productId}}",
7252 ProductInfo = "{{productInfo}}",
7253 BuyForPoints = pointShopOnly,
7254 OnClick = "{{facebookPixelAction}}",
7255 CssClass = "u-w80px u-no-margin js-ignore-click-outside",
7256 Icon = new Icon {
7257 CssClass = "js-ignore-click-outside"
7258 },
7259 ExtraAttributes = new Dictionary<string, string>
7260 {
7261 { "{{disabledBuyButton}}", "" }
7262 }
7263 })
7264 <text>{{/if}}</text>
7265 <text>{{/if}}</text>
7266 }
7267 else if (showViewButton)
7268 {
7269 @Render(viewBtn)
7270 }
7271 @if (showAddToDownloadButton)
7272 {
7273 <button type="button" class="btn btn--primary u-no-margin btn--condensed dw-mod js-add-to-downloads" title="@Translate("Add")" data-product-id="{{productId}}">
7274 <i class="fas fa-plus js-button-icon"></i>
7275 </button>
7276 }
7277 </div>
7278 </div>
7279 </li>
7280 {{/ifCond}}
7281 {{#ifCond template "===" "SearchMore"}}
7282 {{>SearchMoreProducts}}
7283 {{/ifCond}}
7284 {{/Product}}
7285 {{else}}
7286 <li class="dropdown__item dropdown__item--seperator dropdown__item--not-selectable js-no-result dw-mod">
7287 @Translate("Your search gave 0 results")
7288 </li>
7289 {{/each}}
7290 </script>
7291
7292 <script id="SearchMoreProducts" type="text/x-template">
7293 <li class="dropdown__item dropdown__item--not-selectable {{stickToBottom}} dw-mod">
7294 <!-- <a href="/Default.aspx?ID=@productsPageId&Search={{searchParameter}}&GroupID={{groupId}}&DoNotShowVariantsAsSingleProducts=True&OnlyShowVariants=False" class="btn btn--primary btn--full u-no-margin dw-mod js-typeahead-link"> -->
7295 <a href="/Default.aspx?ID=@productsPageId&Search={{searchParameter}}&GroupID={{groupId}}&DoNotShowVariantsAsSingleProducts=True" class="btn btn--primary btn--full u-no-margin dw-mod js-typeahead-link">
7296 @Translate("View all")
7297 </a>
7298 </li>
7299 </script>
7300
7301 <script id="SearchMorePages" type="text/x-template">
7302 <li class="dropdown__item dropdown__item--not-selectable {{stickToBottom}} dw-mod">
7303 <!-- <a href="/Default.aspx?ID=@contentSearchPageLink&Search={{searchParameter}}&DoNotShowVariantsAsSingleProducts=True&OnlyShowVariants=False" class="btn btn--primary btn--full u-no-margin dw-mod js-typeahead-link"> -->
7304 <a href="/Default.aspx?ID=@contentSearchPageLink&Search={{searchParameter}}&DoNotShowVariantsAsSingleProducts=True" class="btn btn--primary btn--full u-no-margin dw-mod js-typeahead-link">
7305 @Translate("View all")
7306 </a>
7307 </li>
7308 </script>
7309
7310 <script id="SearchPagesTemplate" type="text/x-template">
7311 {{#each .}}
7312 {{#ifCond template "!==" "SearchMore"}}
7313 <li class="dropdown__item dropdown__item--seperator dropdown__item--no-padding dw-mod">
7314 <a href="/Default.aspx?ID={{id}}" class="js-typeahead-link dropdown__link u-color-inherit">
7315 <div class="u-margin-right u-inline"><i class="fa {{icon}} u-w20px u-ta-center"></i></div>
7316 <div class="u-inline u-va-middle"><div class="u-bold u-truncate-text u-max-w210px u-inline-block js-typeahead-name">{{name}}</div></div>
7317 </a>
7318 </li>
7319 {{/ifCond}}
7320 {{#ifCond template "===" "SearchMore"}}
7321 {{>SearchMorePages}}
7322 {{/ifCond}}
7323 {{else}}
7324 <li class="dropdown__item dropdown__item--seperator dropdown__item--not-selectable js-no-result dw-mod">
7325 @Translate("Your search gave 0 results")
7326 </li>
7327 {{/each}}
7328 </script>
7329
7330 <script id="SearchPagesTemplateWrap" type="text/x-template">
7331 <div class="dropdown__column-header">@Translate("Pages")</div>
7332 <ul class="dropdown__list u-min-w220px u-full-width u-margin-bottom u-height--auto u-flex-grow--1 dw-mod">
7333 {{>SearchPagesTemplate}}
7334 </ul>
7335 </script>
7336
7337 <script id="SearchProductsTemplateWrap" type="text/x-template">
7338 <div class="dropdown__column-header">@Translate("Products")</div>
7339 <ul class="dropdown__list u-min-w220px u-full-width u-margin-bottom u-height--auto u-flex-grow--1 dw-mod">
7340 {{>SearchProductsTemplate}}
7341 </ul>
7342 </script>
7343 }
7344
7345 @using Dynamicweb.Rapido.Blocks.Components
7346 @using Dynamicweb.Rapido.Blocks.Components.General
7347 @using Dynamicweb.Rapido.Blocks
7348 @using System.IO
7349
7350
7351 @using Dynamicweb.Rapido.Blocks.Components.General
7352 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce
7353
7354
7355 @* Component *@
7356
7357 @helper RenderVariantMatrix(VariantMatrix settings) {
7358 if (settings != null)
7359 {
7360 int productLoopCounter = 0;
7361 int groupCount = 0;
7362 List<VariantOption> firstDimension = new List<VariantOption>();
7363 List<VariantOption> secondDimension = new List<VariantOption>();
7364 List<VariantOption> thirdDimension = new List<VariantOption>();
7365
7366 foreach (VariantGroup variantGroup in settings.GetVariantGroups())
7367 {
7368 foreach (VariantOption variantOptions in variantGroup.GetVariantOptions())
7369 {
7370 if (groupCount == 0) {
7371 firstDimension.Add(variantOptions);
7372 }
7373 if (groupCount == 1)
7374 {
7375 secondDimension.Add(variantOptions);
7376 }
7377 if (groupCount == 2)
7378 {
7379 thirdDimension.Add(variantOptions);
7380 }
7381 }
7382 groupCount++;
7383 }
7384
7385 int rowCount = 0;
7386 int columnCount = 0;
7387
7388 <script>
7389 var variantsCollection = [];
7390 </script>
7391
7392 <table class="table table--compact js-variants-matrix dw-mod" id="VariantMatrixTable_@settings.ProductId">
7393 @if (groupCount == 1)
7394 {
7395 <tbody>
7396 @foreach (VariantOption firstVariantOption in firstDimension)
7397 {
7398 var variantId = firstVariantOption.Id;
7399 <tr>
7400 <td class="u-bold">
7401 @firstVariantOption.Name
7402 </td>
7403 <td>
7404 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount)
7405 </td>
7406 </tr>
7407 productLoopCounter++;
7408 }
7409
7410 <tr>
7411 <td> </td>
7412 <td>
7413 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div>
7414 </td>
7415 </tr>
7416 </tbody>
7417 }
7418 @if (groupCount == 2)
7419 {
7420 <thead>
7421 <tr>
7422 <td> </td>
7423 @foreach (VariantOption variant in secondDimension)
7424 {
7425 <td>@variant.Name</td>
7426 }
7427 </tr>
7428 </thead>
7429 <tbody>
7430 @foreach (VariantOption firstVariantOption in firstDimension)
7431 {
7432 string variantId = "";
7433 columnCount = 0;
7434
7435 <tr>
7436 <td class="u-min-w120px">@firstVariantOption.Name</td>
7437
7438 @foreach (VariantOption secondVariantOption in secondDimension)
7439 {
7440 variantId = firstVariantOption.Id + "." + secondVariantOption.Id;
7441 <td>
7442 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount)
7443 </td>
7444
7445 columnCount++;
7446
7447 productLoopCounter++;
7448 }
7449
7450 <td>
7451 <div class="qty-field js-total-qty-row-@rowCount dw-mod">0</div>
7452 </td>
7453 </tr>
7454
7455 rowCount++;
7456 }
7457
7458 @{
7459 columnCount = 0;
7460 }
7461
7462 <tr>
7463 <td> </td>
7464 @foreach (VariantOption secondVariantOption in secondDimension)
7465 {
7466 <td>
7467 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div>
7468 </td>
7469
7470 columnCount++;
7471 }
7472 <td> </td>
7473 </tr>
7474 </tbody>
7475 }
7476 @if (groupCount == 3)
7477 {
7478 <thead>
7479 <tr>
7480 <td> </td>
7481 @foreach (VariantOption thirdVariantOption in thirdDimension)
7482 {
7483 <td>@thirdVariantOption.Name</td>
7484 }
7485 </tr>
7486 </thead>
7487 <tbody>
7488 @foreach (VariantOption firstVariantOption in firstDimension)
7489 {
7490 int colspan = (thirdDimension.Count + 1);
7491
7492 <tr>
7493 <td colspan="@colspan" class="u-color-light-gray--bg u-bold">@firstVariantOption.Name</td>
7494 </tr>
7495
7496 foreach (VariantOption secondVariantOption in secondDimension)
7497 {
7498 string variantId = "";
7499 columnCount = 0;
7500
7501 <tr>
7502 <td class="u-min-w120px">@secondVariantOption.Name</td>
7503
7504 @foreach (VariantOption thirdVariantOption in thirdDimension)
7505 {
7506 variantId = firstVariantOption.Id + "." + secondVariantOption.Id + "." + thirdVariantOption.Id;
7507
7508 <td>
7509 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount)
7510 </td>
7511
7512 columnCount++;
7513 productLoopCounter++;
7514 }
7515
7516 <td>
7517 <div class="qty-field js-total-qty-row-@rowCount dw-mod">0</div>
7518 </td>
7519 </tr>
7520 rowCount++;
7521 }
7522 }
7523
7524 @{
7525 columnCount = 0;
7526 }
7527
7528 <tr>
7529 <td> </td>
7530 @foreach (VariantOption thirdVariantOption in thirdDimension)
7531 {
7532 <td>
7533 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div>
7534 </td>
7535
7536 columnCount++;
7537 }
7538 <td> </td>
7539 </tr>
7540 </tbody>
7541 }
7542 </table>
7543
7544 <script>
7545 document.addEventListener("DOMContentLoaded", function (event) {
7546 MatrixUpdateQuantity("@settings.ProductId");
7547 });
7548
7549 MatrixUpdateQuantity = function (productId) {
7550 var currentMatrix = document.getElementById("VariantMatrixTable_" + productId);
7551 var allQtyFields = currentMatrix.getElementsByClassName("js-qty");
7552
7553 var qtyRowArr = [];
7554 var qtyColumnArr = [];
7555
7556 var totalQty = 0;
7557
7558 for (var i = 0; i < allQtyFields.length; i++) {
7559 qtyRowArr[allQtyFields[i].getAttribute("data-qty-row-group")] = 0;
7560 qtyColumnArr[allQtyFields[i].getAttribute("data-qty-column-group")] = 0;
7561 }
7562
7563 for (var i = 0; i < allQtyFields.length; i++) {
7564 qtyRowArr[allQtyFields[i].getAttribute("data-qty-row-group")] += parseFloat(allQtyFields[i].value);
7565 qtyColumnArr[allQtyFields[i].getAttribute("data-qty-column-group")] += parseFloat(allQtyFields[i].value);
7566 totalQty += parseFloat(allQtyFields[i].value);
7567 }
7568
7569 //Update row counters
7570 for (var i = 0; i < qtyRowArr.length; i++) {
7571 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-row-" + i)[0];
7572
7573 if (qtyRowArr[i] != undefined && qtyCounter != null) {
7574 var currentCount = qtyCounter.innerHTML;
7575 qtyCounter.innerHTML = qtyRowArr[i];
7576
7577 if (currentCount != qtyCounter.innerHTML) {
7578 qtyCounter.classList.add("qty-field--active");
7579 }
7580 }
7581
7582 }
7583
7584 //Update column counters
7585 for (var i = 0; i < qtyColumnArr.length; i++) {
7586 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-column-" + i)[0];
7587
7588 if (qtyColumnArr[i] != undefined && qtyCounter != null) {
7589 var currentCount = qtyCounter.innerHTML;
7590 qtyCounter.innerHTML = qtyColumnArr[i];
7591
7592 if (currentCount != qtyCounter.innerHTML) {
7593 qtyCounter.classList.add("qty-field--active");
7594 }
7595 }
7596 }
7597
7598 if (document.getElementById("TotalQtyCount_" + productId)) {
7599 document.getElementById("TotalQtyCount_" + productId).innerHTML = totalQty;
7600 }
7601
7602 //Clean up animations
7603 setTimeout(function () {
7604 for (var i = 0; i < qtyRowArr.length; i++) {
7605 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-row-" + i)[0];
7606 if (qtyCounter != null) {
7607 qtyCounter.classList.remove("qty-field--active");
7608 }
7609 }
7610 for (var i = 0; i < qtyColumnArr.length; i++) {
7611 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-column-" + i)[0];
7612 if (qtyCounter != null) {
7613 qtyCounter.classList.remove("qty-field--active");
7614 }
7615 }
7616 }, 1000);
7617 }
7618 </script>
7619 }
7620 }
7621
7622 @helper RenderVariantMatrixQuantityField(string variantId, VariantMatrix settings, int productLoopCounter, int rowCount, int columnCount)
7623 {
7624 string loopCount = productLoopCounter.ToString();
7625
7626 bool combinationFound = false;
7627 double stock = 0;
7628 double quantityValue = 0;
7629 string note = "";
7630
7631 VariantProduct variantProduct = null;
7632
7633 if (settings.GetVariantProducts().TryGetValue(variantId, out variantProduct))
7634 {
7635 stock = variantProduct.Stock;
7636 quantityValue = variantProduct.Quantity;
7637 combinationFound = true;
7638 }
7639
7640 if (combinationFound)
7641 {
7642 <input type="hidden" name="ProductLoopCounter@(loopCount)" value="@loopCount" />
7643 <input type="hidden" name="ProductID@(loopCount)" value="@settings.ProductId" />
7644 <input type="hidden" name="VariantID@(loopCount)" value="@variantId" />
7645 <input type="hidden" name="CurrentNote@(loopCount)" id="CurrentNote_@(settings.ProductId)_@variantId" value="@note" />
7646 <input type="number" name="Quantity@(loopCount)" id="Quantity_@(settings.ProductId)_@variantId" value="@quantityValue" min="0" class="js-qty u-no-margin u-full-max-width" style="width: 100%; max-width: 100%" onkeyup="MatrixUpdateQuantity('@settings.ProductId')" onmouseup="MatrixUpdateQuantity('@settings.ProductId')" data-qty-row-group="@rowCount" data-qty-column-group="@columnCount">
7647
7648 if (stock != 0)
7649 {
7650 <small>@Translate("Stock") @stock</small>
7651 }
7652
7653 <script>
7654 var variants = '{ "ProductId" :' + '"@settings.ProductId"' + ', "VariantId": ' + '"@variantId"' +'}';
7655 variantsCollection.push(variants);
7656 document.getElementById("Quantity_@(settings.ProductId)_@variantId").closest(".js-variants-matrix").setAttribute("data-variants-collection", "[" + variantsCollection + "]" );
7657 </script>
7658 }
7659 else
7660 {
7661 <div class="use-btn-height" style="background-color: #a8a8a8"></div>
7662 }
7663 }
7664 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce
7665
7666 @* Component *@
7667
7668 @helper RenderAddToCart(AddToCart settings)
7669 {
7670 //set Id for quantity selector to get it's value from button
7671 if (settings.QuantitySelector != null)
7672 {
7673 if (string.IsNullOrEmpty(settings.QuantitySelector.Id))
7674 {
7675 settings.QuantitySelector.Id = Guid.NewGuid().ToString("N");
7676 }
7677
7678 settings.AddButton.QuantitySelectorId = settings.QuantitySelector.Id;
7679
7680 if (settings.Disabled)
7681 {
7682 settings.QuantitySelector.Disabled = true;
7683 }
7684
7685 if (string.IsNullOrEmpty(settings.QuantitySelector.Name))
7686 {
7687 settings.QuantitySelector.Name = settings.QuantitySelector.Id;
7688 }
7689 }
7690
7691 if (settings.Disabled)
7692 {
7693 settings.AddButton.Disabled = true;
7694 }
7695
7696 settings.AddButton.CssClass += " btn--condensed";
7697
7698 //unitsSelector
7699 if (settings.UnitSelector != null)
7700 {
7701 if (settings.Disabled)
7702 {
7703 settings.QuantitySelector.Disabled = true;
7704 }
7705 }
7706
7707 <div class="buttons-collection @settings.WrapperCssClass" @ComponentMethods.AddAttributes(settings.ExtraAttributes)>
7708 @if (settings.UnitSelector != null)
7709 {
7710 @Render(settings.UnitSelector)
7711 }
7712 @if (settings.QuantitySelector != null)
7713 {
7714 @Render(settings.QuantitySelector)
7715 }
7716 @Render(settings.AddButton)
7717 </div>
7718 }
7719 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce
7720
7721 @* Component *@
7722
7723 @helper RenderAddToCartButton(AddToCartButton settings)
7724 {
7725 if (!settings.HideTitle)
7726 {
7727 if (string.IsNullOrEmpty(settings.Title))
7728 {
7729 if (settings.BuyForPoints)
7730 {
7731 settings.Title = Translate("Buy with points");
7732 }
7733 else
7734 {
7735 settings.Title = Translate("Add to cart");
7736 }
7737 }
7738 }
7739 else
7740 {
7741 settings.Title = "";
7742 }
7743
7744 if (settings.Icon == null)
7745 {
7746 settings.Icon = new Icon();
7747 settings.Icon.LabelPosition = Dynamicweb.Rapido.Blocks.Components.General.IconLabelPosition.After;
7748 }
7749
7750 if (string.IsNullOrEmpty(settings.Icon.Name))
7751 {
7752 settings.Icon.Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue;
7753 }
7754
7755 settings.OnClick = "Cart.AddToCart(event, { " +
7756 "id: '" + settings.ProductId + "'," +
7757 (!string.IsNullOrEmpty(settings.VariantId) ? "variantId: '" + settings.VariantId + "'," : "") +
7758 (!string.IsNullOrEmpty(settings.UnitId) ? "unitId: '" + settings.UnitId + "'," : "") +
7759 (settings.BuyForPoints ? "buyForPoints: true," : "") +
7760 (!string.IsNullOrEmpty(settings.ProductInfo) ? "productInfo: " + settings.ProductInfo + "," : "") +
7761 "quantity: " + (string.IsNullOrEmpty(settings.QuantitySelectorId) ? "1" : "parseFloat(document.getElementById('" + settings.QuantitySelectorId + "').value)") +
7762 "});" + settings.OnClick;
7763
7764 @RenderButton(settings)
7765 }
7766 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce
7767
7768 @* Component *@
7769
7770 @helper RenderUnitSelector(UnitSelector settings)
7771 {
7772 if (string.IsNullOrEmpty(settings.Id))
7773 {
7774 settings.Id = Guid.NewGuid().ToString("N");
7775 }
7776 var disabledClass = settings.Disabled ? "disabled" : "";
7777
7778 <input type="checkbox" id="@settings.Id" class="dropdown-trigger" />
7779 <div class="dropdown unit-selector @settings.CssClass @disabledClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)>
7780 <label class="dropdown__header dropdown__btn dropdown__btn--unit-selector dw-mod" for="@settings.Id">@settings.SelectedOption</label>
7781 <div class="dropdown__content dw-mod">
7782 @settings.OptionsContent
7783 </div>
7784 <label class="dropdown-trigger-off" for="@settings.Id"></label>
7785 </div>
7786 }
7787 @using System.Reflection
7788 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce
7789
7790 @* Component *@
7791
7792 @helper RenderQuantitySelector(QuantitySelector settings)
7793 {
7794 var attributes = new Dictionary<string, string>();
7795
7796 /*base settings*/
7797 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); }
7798 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); }
7799 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); }
7800 if (settings.Disabled) { attributes.Add("disabled", "true"); }
7801 if (settings.Required) { attributes.Add("required", "true"); }
7802 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); }
7803 /*end*/
7804
7805 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); }
7806 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); }
7807 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); }
7808 if (settings.ReadOnly) { attributes.Add("readonly", "true"); }
7809 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); }
7810 if (settings.Min == null) { settings.Min = 1; }
7811 attributes.Add("min", settings.Min.ToString());
7812 if (settings.Step != null && !string.IsNullOrEmpty(settings.Step.ToString())) { attributes.Add("step", settings.Step.ToString()); }
7813 if (settings.Value == null) { settings.Value = 1; }
7814 attributes.Add("value", settings.Value.ToString());
7815 attributes.Add("type", "number");
7816
7817 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value);
7818
7819 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" />
7820 }
7821 @using Dynamicweb.Rapido.Blocks.Components
7822
7823 @using Dynamicweb.Frontend
7824 @using Dynamicweb.Frontend.Devices
7825 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce
7826 @using Dynamicweb.Rapido.Blocks.Components.General
7827 @using System.Collections.Generic;
7828
7829 @* Component *@
7830
7831 @helper RenderCustomerCenterList(CustomerCenterList settings)
7832 {
7833 bool isTouchDevice = Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet" ? true : false;
7834 string hideActions = isTouchDevice ? "u-block" : "";
7835
7836 <table class="table data-list dw-mod">
7837 @if (settings.GetHeaders().Length > 0) {
7838 <thead>
7839 <tr class="u-bold">
7840 @foreach (CustomerCenterListHeaderItem header in settings.GetHeaders())
7841 {
7842 var attributes = new Dictionary<string, string>();
7843 if (!string.IsNullOrEmpty(header.Id)) { attributes.Add("id", header.Id); }
7844 if (!string.IsNullOrEmpty(header.CssClass)) { attributes.Add("class", header.CssClass); }
7845 attributes.Add("align", header.Align.ToString());
7846 attributes = attributes.Concat(header.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value);
7847
7848 <td @ComponentMethods.AddAttributes(attributes)>@header.Title</td>
7849 }
7850 </tr>
7851 </thead>
7852 }
7853 @foreach (CustomerCenterListItem listItem in settings.GetItems())
7854 {
7855 int columnCount = 0;
7856 int totalColumns = listItem.GetInfoItems().Length;
7857 string rowHasActions = listItem.GetActions().Length > 0 ? "data-list__item--has-actions" : "";
7858 listItem.Id = !string.IsNullOrEmpty(listItem.Id) ? listItem.Id : Guid.NewGuid().ToString("N");
7859
7860 var attributes = new Dictionary<string, string>();
7861 if (!string.IsNullOrEmpty(listItem.Title)) { attributes.Add("title", listItem.Title); };
7862
7863 attributes = attributes.Concat(listItem.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value);
7864 <tbody class="data-list__item @rowHasActions @listItem.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes)>
7865 <tr>
7866 @if (!string.IsNullOrEmpty(listItem.Title) || !string.IsNullOrEmpty(listItem.Description)) {
7867 string onClick = !string.IsNullOrEmpty(listItem.OnClick) ? "onclick=\"" + listItem.OnClick + "\"" : "";
7868
7869 <td rowspan="2" @onClick class="data-list__main-item dw-mod">
7870 @if (!string.IsNullOrEmpty(listItem.Title)) {
7871 <div class="u-bold">@listItem.Title</div>
7872 }
7873 @if (!string.IsNullOrEmpty(listItem.Description)) {
7874 <div>@listItem.Description</div>
7875 }
7876 </td>
7877 }
7878
7879 @foreach (CustomerCenterListInfoItem infoItem in listItem.GetInfoItems())
7880 {
7881 var infoAttributes = new Dictionary<string, string>();
7882 if (!string.IsNullOrEmpty(infoItem.Id)) { infoAttributes.Add("id", infoItem.Id); };
7883 if (!string.IsNullOrEmpty(infoItem.OnClick)) { infoAttributes.Add("onclick", infoItem.OnClick); };
7884 infoAttributes.Add("align", infoItem.Align.ToString());
7885
7886 infoAttributes = infoAttributes.Concat(infoItem.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value);
7887 string columnClick = columnCount < (totalColumns-1) && !string.IsNullOrEmpty(listItem.OnClick) ? "onclick=\"" + listItem.OnClick + "\"" : "";
7888
7889 <td @ComponentMethods.AddAttributes(infoAttributes) @columnClick class="data-list__info-item dw-mod">
7890 @if (!string.IsNullOrEmpty(infoItem.Title)) {
7891 <div>@infoItem.Title</div>
7892 }
7893 @if (!string.IsNullOrEmpty(infoItem.Subtitle)) {
7894 <div><small>@infoItem.Subtitle</small></div>
7895 }
7896 </td>
7897
7898 columnCount++;
7899 }
7900 </tr>
7901 <tr>
7902 <td colspan="7" align="right" class="u-va-bottom u-no-border">
7903 <div class="data-list__actions @hideActions dw-mod" id="ActionsMenu_@listItem.Id">
7904 @foreach (ButtonBase action in listItem.GetActions())
7905 {
7906 action.ButtonLayout = ButtonLayout.LinkClean;
7907 action.Icon.CssClass += " u-full-height";
7908 action.CssClass += " data-list__action-button link";
7909
7910 @Render(action)
7911 }
7912 </div>
7913 </td>
7914 </tr>
7915 </tbody>
7916 }
7917 </table>
7918 }
7919 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
7920
7921 @using System
7922 @using System.Web
7923 @using System.Collections.Generic
7924 @using Dynamicweb.Rapido.Blocks.Extensibility
7925 @using Dynamicweb.Rapido.Blocks
7926
7927 @{
7928 BlocksPage bottomSnippetsBlocksPage = BlocksPage.GetBlockPage("Master");
7929
7930 Block primaryBottomSnippets = new Block()
7931 {
7932 Id = "MasterJavascriptInitializers",
7933 SortId = 100,
7934 Template = RenderPrimaryBottomSnippets()
7935 };
7936 bottomSnippetsBlocksPage.Add(MasterBlockId.MasterReferences, primaryBottomSnippets);
7937
7938 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed())
7939 {
7940 Block miniCartPageId = new Block
7941 {
7942 Id = "MiniCartPageId",
7943 Template = RenderMiniCartPageId()
7944 };
7945 bottomSnippetsBlocksPage.Add(MasterBlockId.MasterReferences, miniCartPageId);
7946 }
7947 }
7948
7949 @helper RenderPrimaryBottomSnippets()
7950 {
7951 bool isWireframeMode = Model.Area.Item.GetItem("Settings").GetBoolean("WireframeMode");
7952 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID"));
7953
7954 if (isWireframeMode)
7955 {
7956 <script>
7957 Wireframe.Init(true);
7958 </script>
7959 }
7960
7961
7962 if (useGoogleTagManager)
7963 {
7964 <script>
7965 document.addEventListener('addToCart', function(event) {
7966 var googleImpression = JSON.parse(event.detail.productInfo.googleImpression);
7967 if (typeof googleImpression == "string") {
7968 googleImpression = JSON.parse(event.detail.productInfo.googleImpression);
7969 }
7970 dataLayer.push({
7971 'event': 'addToCart',
7972 'ecommerce': {
7973 'currencyCode': googleImpression.currency,
7974 'add': {
7975 'products': [{
7976 'name': googleImpression.name,
7977 'id': googleImpression.id,
7978 'price': googleImpression.price,
7979 'brand': googleImpression.brand,
7980 'category': googleImpression.category,
7981 'variant': googleImpression.variant,
7982 'quantity': event.detail.quantity
7983 }]
7984 }
7985 }
7986 });
7987 });
7988 </script>
7989 }
7990
7991 //if digitalwarehouse
7992 if (Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowDownloadCart"))
7993 {
7994 string cartContextId = Converter.ToString(HttpContext.Current.Application["DownloadCartContext"]);
7995
7996 if (string.IsNullOrEmpty(cartContextId))
7997 {
7998 var moduleProps = Dynamicweb.Modules.Properties.GetParagraphModuleSettings(GetPageIdByNavigationTag("DownloadCart"), "eCom_CartV2");
7999 var cartSettings = new Dynamicweb.Ecommerce.Cart.ModuleSettings(moduleProps);
8000 cartContextId = cartSettings.OrderContextID;
8001 HttpContext.Current.Application["DownloadCartContext"] = cartContextId;
8002 }
8003
8004 <script>
8005 let downloadCart = new DownloadCart({
8006 cartPageId: @GetPageIdByNavigationTag("MiniCartFeed"),
8007 contextId: "@cartContextId",
8008 addButtonText: "@Translate("Add")",
8009 removeButtonText: "@Translate("Remove")"
8010 });
8011 </script>
8012 }
8013
8014 <!--$$Javascripts-->
8015 }
8016
8017 @helper RenderMiniCartPageId()
8018 {
8019 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
8020 <script>
8021 window.cartId = "@miniCartFeedPageId";
8022 </script>
8023 }
8024 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
8025
8026 @using System
8027 @using System.Web
8028 @using System.Collections.Generic
8029 @using Dynamicweb.Rapido.Blocks
8030
8031 @{
8032 BlocksPage masterCustomBlocksPage = BlocksPage.GetBlockPage("Master");
8033
8034 }
8035
8036
8037 @functions {
8038 public class ManifestIcon
8039 {
8040 public string src { get; set; }
8041 public string type { get; set; }
8042 public string sizes { get; set; }
8043 }
8044
8045 public class Manifest
8046 {
8047 public string name { get; set; }
8048 public string short_name { get; set; }
8049 public string start_url { get; set; }
8050 public string display { get; set; }
8051 public string background_color { get; set; }
8052 public string theme_color { get; set; }
8053 public List<ManifestIcon> icons { get; set; }
8054 }
8055 }
8056
8057 <!DOCTYPE html>
8058
8059 <html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName">
8060
8061
8062
8063 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@
8064 @RenderBlockList(masterPage.BlocksRoot.BlocksList)
8065
8066
8067
8068 @helper RenderMasterHead() {
8069 List<Block> subBlocks = this.masterPage.GetBlockListById("Head").OrderBy(item => item.SortId).ToList();
8070
8071 <head>
8072 <!-- Rapido version 3.4.2 TEST -->
8073
8074 @RenderBlockList(subBlocks)
8075
8076
8077 <style>
8078 @@media only screen and (max-width: 480px) {
8079 .content-row--height-auto .image-paragraph { min-height: 200px; }
8080 }
8081
8082 .buttons-collection>*:not(:last-child) { margin-bottom: 1em; }
8083
8084 /* -- -- -- ARKITEKT SITE -- -- -- 28 */
8085 body[data-areaid="28"] .stickers-container__tag--control{ color: #4e79ab !important; border: solid 1px #4e79ab !important; background: transparent !important; }
8086
8087 </style>
8088
8089 </head>
8090 }
8091
8092 @helper RenderMasterMetadata() {
8093 var swatches = new Dynamicweb.Content.Items.ColorSwatchService();
8094 var brandColors = swatches.GetColorSwatch(1);
8095 string brandColorOne = brandColors.Palette["BrandColor1"];
8096
8097 if (!String.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("AppName")) && Model.Area.Item.GetItem("Settings").GetFile("AppIcon") != null) {
8098 Manifest manifest = new Manifest
8099 {
8100 name = Model.Area.Item.GetItem("Settings").GetString("AppName"),
8101 short_name = !String.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("AppShortName")) ? Model.Area.Item.GetItem("Settings").GetString("AppShortName") : Model.Area.Item.GetItem("Settings").GetString("AppName"),
8102 start_url = "/",
8103 display = "standalone",
8104 background_color = Model.Area.Item.GetItem("Settings").GetString("AppBackgroundColor"),
8105 theme_color = Model.Area.Item.GetItem("Settings").GetString("AppThemeColor")
8106 };
8107
8108 manifest.icons = new List<ManifestIcon> {
8109 new ManifestIcon {
8110 src = "/Admin/Public/GetImage.ashx?width=192&height=192&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded,
8111 sizes = "192x192",
8112 type = "image/png"
8113 },
8114 new ManifestIcon {
8115 src = "/Admin/Public/GetImage.ashx?width=512&height=512&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded,
8116 sizes = "512x512",
8117 type = "image/png"
8118 },
8119 new ManifestIcon {
8120 src = "/Admin/Public/GetImage.ashx?width=1024&height=1024&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded,
8121 sizes = "1024x1024",
8122 type = "image/png"
8123 }
8124 };
8125
8126 string manifestFilePath = HttpContext.Current.Request.MapPath("/Files/Templates/Designs/Rapido/manifest.json");
8127 string manifestJSON = Newtonsoft.Json.JsonConvert.SerializeObject(manifest);
8128 string currentManifest = File.ReadAllText(manifestFilePath);
8129
8130 if (manifestJSON != currentManifest)
8131 {
8132 File.WriteAllText(manifestFilePath, manifestJSON);
8133 }
8134 }
8135
8136 <meta charset="utf-8" />
8137 <title>@Model.Title</title>
8138 <meta name="viewport" content="width=device-width, initial-scale=1.0">
8139 <meta name="robots" content="index, follow">
8140 <meta name="theme-color" content="@brandColorOne" />
8141
8142 if (Model.MetaTags != null && !Model.MetaTags.Contains("og:image") && Model.PropertyItem != null && Model.PropertyItem.GetFile("OpenGraphImage") != null)
8143 {
8144 Pageview.Meta.AddTag("og:image", string.Format("{0}://{1}{2}", Dynamicweb.Context.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, Model.PropertyItem.GetFile("OpenGraphImage")));
8145 }
8146
8147 if (!Model.MetaTags.Contains("og:description") && !string.IsNullOrEmpty(Model.Description))
8148 {
8149 Pageview.Meta.AddTag("og:description", Model.Description);
8150 }
8151
8152 Pageview.Meta.AddTag("og:title", Model.Title);
8153 Pageview.Meta.AddTag("og:site_name", Model.Name);
8154 Pageview.Meta.AddTag("og:url", HttpContext.Current.Request.Url.ToString());
8155 Pageview.Meta.AddTag("og:type", "Website");
8156
8157 if (!string.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("FacebookAppID"))) {
8158 Pageview.Meta.AddTag("fb:app_id", Model.Area.Item.GetItem("Settings").GetString("FacebookAppID"));
8159 }
8160
8161 @Model.MetaTags
8162 }
8163
8164 @helper RenderMasterCss() {
8165 var fonts = new string[] {
8166 getFontFamily("Layout", "HeaderFont"),
8167 getFontFamily("Layout", "SubheaderFont"),
8168 getFontFamily("Layout", "TertiaryHeaderFont"),
8169 getFontFamily("Layout", "BodyText"),
8170 getFontFamily("Layout", "Header", "ToolsFont"),
8171 getFontFamily("Layout", "Header", "NavigationFont"),
8172 getFontFamily("Layout", "MobileNavigation", "Font"),
8173 getFontFamily("ProductList", "Facets", "HeaderFont"),
8174 getFontFamily("ProductPage", "PriceFontDesign"),
8175 getFontFamily("Ecommerce", "SaleSticker", "Font"),
8176 getFontFamily("Ecommerce", "NewSticker", "Font"),
8177 getFontFamily("Ecommerce", "CustomSticker", "Font")
8178 };
8179
8180 string autoCssLink = "/Files/Templates/Designs/Rapido/css/rapido/rapido_" + Model.Area.ID.ToString() + ".min.css?ticks=" + Model.Area.UpdatedDate.Ticks;
8181 string favicon = Model.Area.Item.GetItem("Layout").GetFile("LogoFavicon") != null ? Model.Area.Item.GetItem("Layout").GetFile("LogoFavicon").Path : "/Files/Images/favicon.png";
8182 bool useFontAwesomePro = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetBoolean("UseFontAwesomePro");
8183 string fontAwesomeCssLink = "/Files/Templates/Designs/Rapido/css/fonts/FontAwesomeFree/css/fontawesome-all.min.css";
8184 if (useFontAwesomePro)
8185 {
8186 fontAwesomeCssLink = "/Files/Templates/Designs/Rapido/css/fonts/FontAwesomePro/css/fontawesome-all.min.css";
8187 }
8188
8189 //Favicon
8190 <link href="@favicon" rel="icon" type="image/png">
8191
8192 //Base (Default, wireframe) styles
8193 <link rel="stylesheet" href="/Files/Templates/Designs/Rapido/css/base/base.min.css" type="text/css">
8194
8195 //Rapido Css from Website Settings
8196 <link rel="stylesheet" id="rapidoCss" href="@autoCssLink" type="text/css">
8197
8198 //Ignite Css (Custom site specific styles)
8199 <link rel="stylesheet" id="igniteCss" type="text/css" href="/Files/Templates/Designs/Rapido/css/ignite/ignite.min.css?ticks=@(Model.Area.UpdatedDate.Ticks)">
8200
8201 //Font awesome
8202 <link rel="stylesheet" href="@fontAwesomeCssLink" type="text/css">
8203
8204 //Flag icon
8205 <link rel="stylesheet" href="/Files/Templates/Designs/Rapido/css/fonts/flag-icon.min.css" type="text/css">
8206
8207 //Google fonts
8208 var family = string.Join("%7C", fonts.Where(x => !string.IsNullOrEmpty(x)).Distinct().Select(x => string.Format("{0}:100,200,300,400,500,600,700,800,900", x)));
8209
8210 <link href="https://fonts.googleapis.com/css?family=@family" rel="stylesheet">
8211
8212 PushPromise(favicon);
8213 PushPromise(fontAwesomeCssLink);
8214 PushPromise("/Files/Templates/Designs/Rapido/css/base/base.min.css");
8215 PushPromise(autoCssLink);
8216 PushPromise("/Files/Templates/Designs/Rapido/css/ignite/ignite.min.css");
8217 PushPromise("/Files/Images/placeholder.gif");
8218 PushPromise("/Files/Templates/Designs/Rapido/css/fonts/flag-icon.min.css");
8219 }
8220
8221 @helper RenderMasterManifest() {
8222 if (!String.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("AppName")))
8223 {
8224 <link rel="manifest" href="/Files/Templates/Designs/Rapido/manifest.json">
8225 PushPromise("/Files/Templates/Designs/Rapido/manifest.json");
8226 }
8227 }
8228
8229 @helper RenderMasterBody() {
8230 List<Block> subBlocks = this.masterPage.GetBlockListById("Body").OrderBy(item => item.SortId).ToList();
8231 string designLayout = Model.PropertyItem.GetItem("CustomSettings") != null ? Model.PropertyItem.GetItem("CustomSettings").GetString("DesignLayout") != null ? Model.PropertyItem.GetItem("CustomSettings").GetList("DesignLayout").SelectedValue : "" : "";
8232 if (!String.IsNullOrEmpty(designLayout)) {
8233 designLayout = "class=\"" + designLayout + "\"";
8234 }
8235
8236 // COOKIE ---------------------------
8237 @*IList<string> AllowedCookieCategories = new List<string>() { "Essential" };
8238 foreach (string s in CookieManager.GetCategories())
8239 {
8240 if (s == "Essential")
8241 {
8242 continue;
8243 }
8244 else if (CookieManager.CookieOptInLevelExists && (CookieManager.GetCookieOptInLevel() == CookieOptInLevel.All || (CookieManager.CookieOptInLevelExists && System.Web.HttpContext.Current.Request.Cookies.Get("Dynamicweb.CookieOptInLevel").Value.IndexOf(s) > -1)))
8245 {
8246 AllowedCookieCategories.Add(s);
8247 }
8248 }
8249
8250 //var categories = Dynamicweb.Environment.CookieManager.GetCategories();
8251 string cookieChoiceId = "cookie-choice-renew";
8252 string cookieWarningClass = "custom-cookie";
8253 if (Dynamicweb.Environment.CookieManager.CookieOptInLevelExists)
8254 {
8255 cookieWarningClass += " \" style=\"display:none\" tab-index=\"-1\" aria-hidden=\"true\"";
8256 }
8257 else
8258 {
8259 cookieChoiceId += "\" style=\"display:none;";
8260 }
8261 var cookieSettingsPage = Dynamicweb.Services.Pages.GetPageByNavigationTag(Pageview.AreaID, "cookiesettings");
8262
8263 bool cookieActivated = cookieSettingsPage != null && cookieSettingsPage.Item["CookieActivated"] != null ? (bool)cookieSettingsPage.Item["CookieActivated"] : false;
8264 // /COOKIE ---------------------------
8265 *@
8266 <body @designLayout>
8267 @* ---------------------------------------------------------------------------------------------------------------------- *@
8268 @* -- -- -- -- -- COOKIE -- -- -- -- -- *@
8269
8270 @*@if ( cookieSettingsPage != null && cookieSettingsPage.Item["Cookies"] != null)
8271 {
8272 var cookieCategoryItems = Dynamicweb.Content.Items.ItemList.GetItemListById((int)cookieSettingsPage.Item["Cookies"]).Relations;
8273
8274 if (cookieCategoryItems.Any())
8275 {
8276 <div id="@cookieChoiceId" title="Cookie valg" aria-label="renew-consent">
8277 <svg class="svg-inline--fa fa-cookie-bite fa-w-16" aria-hidden="true" focusable="false" data-prefix="fal" data-icon="cookie-bite" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""><path fill="currentColor" d="M352 328c-13.25 0-24 10.74-24 24 0 13.25 10.75 24 24 24s24-10.75 24-24c0-13.26-10.75-24-24-24zM184 192c0-13.26-10.75-24-24-24s-24 10.74-24 24c0 13.25 10.75 24 24 24s24-10.75 24-24zm8 136c-13.25 0-24 10.74-24 24 0 13.25 10.75 24 24 24s24-10.75 24-24c0-13.26-10.75-24-24-24zm96-96c-13.25 0-24 10.74-24 24 0 13.25 10.75 24 24 24s24-10.75 24-24c0-13.26-10.75-24-24-24zm222.52 23.82c-69.97-.85-126.47-57.69-126.47-127.86-70.17 0-127-56.49-127.86-126.45C249.57.5 242.9 0 236.26 0c-20.68 0-41.18 4.85-59.79 14.33l-69.13 35.22a132.221 132.221 0 0 0-57.79 57.81l-35.1 68.88a132.645 132.645 0 0 0-12.82 80.95l12.08 76.28a132.555 132.555 0 0 0 37.16 72.96l54.77 54.76a132.036 132.036 0 0 0 72.71 37.06l76.71 12.14c6.86 1.09 13.76 1.62 20.64 1.62 20.72 0 41.25-4.88 59.89-14.38l69.13-35.22a132.221 132.221 0 0 0 57.79-57.81l35.1-68.88c12.56-24.63 17.01-52.57 12.91-79.9zm-41.42 65.36L434 390.07c-9.68 19-24.83 34.15-43.81 43.82l-69.13 35.22C307.08 476.23 291.39 480 275.7 480c-5.21 0-10.47-.41-15.63-1.23l-76.7-12.14c-21-3.33-40.05-13.04-55.09-28.08l-54.77-54.76c-15.1-15.09-24.84-34.23-28.18-55.33l-12.08-76.27c-3.35-21.12.02-42.36 9.72-61.41l35.1-68.88c9.68-19 24.83-34.15 43.81-43.82L191 42.85c11.33-5.77 23.8-9.33 36.51-10.46 13.15 63.15 63.84 112.95 127.25 124.86 11.91 63.42 61.71 114.11 124.87 127.25-1.1 12.73-4.64 25.14-10.53 36.68z"></path></svg>
8278 </div>
8279
8280 <div id="cookieWarningContainer" class="@cookieWarningClass">
8281 <form id="cookieWarningForm" method="post" action="/Admin/Public/CookieOptInLevelConfig.aspx">
8282 <input type="hidden" name="cmd" value="SetCookieOptInLevel" />
8283 <input type="hidden" name="OptInLevel" id="OptInLevel" value="1" />
8284
8285 <fieldset>
8286 <div class="p-4">
8287 <div class="row">
8288 <div class="col-12">
8289 <h2>@cookieSettingsPage.Item["CookieHeader"]</h2>
8290 @cookieSettingsPage.Item["CookieIntro"]
8291 <hr class="mt-4 mb-2 w-100" />
8292 <p class="text-center">
8293 <button type="button" class="btn btn--primary dw-mod ml-3" onclick="setOptInCookie(1);" tapindex="1">@Translate("Tillad valgte")</button>
8294 <button type="button" class="btn btn--primary dw-mod ml-3" onclick="setOptInCookie(2);">@Translate("Tillad alle")</button>
8295 </p>
8296 </div>
8297 </div>
8298 </div>
8299 @{
8300 string showDetails = Translate("Vis detaljer");
8301 string hideDetails = Translate("Skjul detaljer");
8302 <div class="p-4">
8303 <div class="grid">
8304 @foreach (Dynamicweb.Content.Items.Item category in cookieCategoryItems)
8305 {
8306 string categoryName = "" + category["Name"];
8307 string categorySysName = "" + category["SysName"];
8308 string categoryID = "cookecategory-" + category.Id;
8309 string categoryDescription = "" + category["Description"];
8310 var cookies = Dynamicweb.Content.Items.ItemList.GetItemListById((int)category["Cookies"]).Relations;
8311 string translateLabel = Translate("Accepter") + " " + categoryName + " " + Translate("cookies");
8312
8313 if (cookies.Any())
8314 {
8315 <div class="dw-mod grid__col-4">
8316 <div class="custom-control custom-checkbox text-center" data-nogutter="1">
8317 <span class="d-block">@categoryName</span>
8318 @if (categorySysName == "Essential")
8319 {
8320 <input type="checkbox" class="custom-control-input" id="chk-cookie-@categorySysName" value="@categorySysName" checked="checked" disabled='disabled' />
8321 }
8322 else
8323 {
8324 if (AllowedCookieCategories.Contains(categorySysName))
8325 {
8326 <input type="checkbox" class="custom-control-input" checked="checked" id="chk-cookie-@categorySysName" name="OptInCategory" value="@categorySysName" />
8327 }
8328 else
8329 {
8330 <input type="checkbox" class="custom-control-input" id="chk-cookie-@categorySysName" name="OptInCategory" value="@categorySysName" />
8331 }
8332 }
8333 <label class="custom-control-label" for="chk-cookie-@categorySysName"><span class="sr-only">@translateLabel</span></label>
8334 </div>
8335 </div>
8336 }
8337 }
8338
8339 </div>
8340 <div class="row">
8341 <div class="col-12">
8342 <hr class="mt-4 mb-4" />
8343 <p class="text-center">
8344 <a class="btn btn--secondary dw-mod mr-3 collapsed" id="cookie-details-button" data-toggle="collapse" role="button" aria-expanded="false" data-open-text="Vis detaljer" data-close-text="Skjul detaljer" aria-controls="collapse-cookie-info-container">Vis detaljer</a>
8345 </p>
8346 </div>
8347
8348 </div>
8349 </div>
8350 <div class="collapse" id="collapse-cookie-info-container">
8351 <div class="cookie-info-container">
8352 <div class="mb-4">
8353 @foreach (Dynamicweb.Content.Items.Item category in cookieCategoryItems)
8354 {
8355 string categoryName = "" + category["Name"];
8356 string categorySysName = "" + category["SysName"];
8357 string categoryID = "cookecategory-" + category.Id;
8358 string categoryDescription = "" + category["Description"];
8359 var cookies = Dynamicweb.Content.Items.ItemList.GetItemListById((int)category["Cookies"]).Relations;
8360 if (cookies.Any())
8361 {
8362 <div class="d-block toogle-f-content" data-toggle="collapse" role="button" aria-expanded="false" aria-controls="collapse-cookie-info-@categoryID" tabindex="0">
8363 <div class="grid">
8364 <div class="dw-mod grid__col-3 d-inline-block">
8365 <span class="arrow-animate-down">
8366 <span class="icon-bar"></span>
8367 <span class="icon-bar"></span>
8368 </span>
8369 <strong>@categoryName</strong>
8370 </div>
8371 <div class="dw-mod grid__col-9">
8372 @categoryDescription
8373 </div>
8374 </div>
8375 </div>
8376 <div class="collapse" id="collapse-cookie-info-@categoryID">
8377 @foreach (Dynamicweb.Content.Items.Item cookie in cookies)
8378 {
8379 string titleClass = "dw-mod grid__col-3";
8380 string contentClass = "dw-mod grid__col-9";
8381
8382 <div class="grid p-1">
8383 <div class="@titleClass">
8384 <strong>
8385 @Translate("Databehandler")
8386 </strong>
8387 </div>
8388 <div class="@contentClass">
8389 <p>@cookie["DataProcessor"]</p>
8390 </div>
8391 <div class="@titleClass">
8392 <strong>
8393 @Translate("Formål")
8394 </strong>
8395 </div>
8396 <div class="@contentClass">
8397 @cookie["Purpose"]
8398 </div>
8399 <div class="@titleClass">
8400 <strong>
8401 @Translate("Privatlivspolitik:")
8402 </strong>
8403 </div>
8404 <div class="@contentClass">
8405 <a target="_blank" href="@cookie["PrivacyPolicy"]">@cookie["PrivacyPolicy"]</a>
8406 </div>
8407 <div class="@titleClass">
8408 <strong>
8409 @Translate("Udløb")
8410 </strong>
8411 </div>
8412 <div class="@contentClass">
8413 <p>@cookie["Expires"]</p>
8414 </div>
8415 <div class="@titleClass">
8416 <strong>
8417 @Translate("Navn")
8418 </strong>
8419 </div>
8420 <div class="@contentClass">
8421 <p>@cookie["Name"]</p>
8422 </div>
8423 <div class="@titleClass">
8424 <strong>
8425 @Translate("Udbyder")
8426 </strong>
8427 </div>
8428 <div class="@contentClass">
8429 <p>@cookie["Provider"]</p>
8430 </div>
8431 </div>
8432 }
8433 </div>
8434
8435 }
8436 }
8437 </div>
8438 </div>
8439 </div>
8440 }
8441 </fieldset>
8442 </form>
8443
8444 </div>
8445 }
8446 }*@
8447
8448 @* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- *@
8449 @* ----------------------------------------------------------------------------------------------------------------------- *@
8450
8451 @RenderBlockList(subBlocks)
8452 </body>
8453 }
8454
8455 @helper RenderMasterHeader()
8456 {
8457 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterHeader").OrderBy(item => item.SortId).ToList();
8458 bool isNavigationStickyMenu = Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet" && Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("StickyTop");
8459 string stickyTop = isNavigationStickyMenu ? "top-container--sticky" : "";
8460
8461 <header class="top-container @stickyTop no-print dw-mod" id="Top">
8462 @RenderBlockList(subBlocks)
8463 </header>
8464 }
8465
8466 @helper RenderMain()
8467 {
8468 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterMain").OrderBy(item => item.SortId).ToList();
8469
8470 <main class="site dw-mod">
8471 @RenderBlockList(subBlocks)
8472 </main>
8473 }
8474
8475 @helper RenderPageContent()
8476 {
8477 bool isNavigationStickyMenu = Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet" && Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("StickyTop");
8478 string pagePos = isNavigationStickyMenu ? "js-page-pos" : "";
8479
8480 <div id="Page" class="page @pagePos">
8481 <div id="content">
8482 @RenderSnippet("Content")
8483 </div>
8484 </div>
8485 }
8486
8487 @* Hack to support nested helpers *@
8488 @SnippetStart("Content")
8489 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
8490 @{
8491 @*if(Pageview.AreaID == 28 && Pageview.Page.NavigationTag == "ProductsPage" && Dynamicweb.Context.Current.Request.RawUrl == "/produkter") {
8492 Dynamicweb.Context.Current.Response.Redirect("/Default.aspx?ID=7535");
8493
8494 Dynamicweb.Context.Current.Response.End();
8495 }*@
8496 }
8497
8498
8499 @* Render the grid *@
8500 @Model.Grid("Grid", "Grid", "default:true;sort:1", "Pages")
8501
8502 @SnippetEnd("Content")
8503
8504 @helper RenderIosTabletFix() {
8505 if (Pageview.Device != Dynamicweb.Frontend.Devices.DeviceType.Tablet && Pageview.Platform != Dynamicweb.Frontend.Devices.PlatformType.Ios)
8506 {
8507 <script>
8508 let isIpadIOS = (/iPad/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) && !window.MSStream;
8509 if (isIpadIOS) {
8510 var separator = (window.location.href.indexOf("?") === -1) ? "?" : "&";
8511 window.location.href = window.location.href + separator + "DeviceType=Tablet&PlatformType=Ios";
8512 }
8513 </script>
8514 }
8515 }
8516
8517 </html>
8518
8519