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