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