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