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_f024d06f80ef4365ab8cba3eaca1c10c.Execute() in D:\dynamicweb.net\Solutions\Production\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 7895
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 = settings.WidgetsBaseBackgroundColor;
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
2239 @using Ppdw.Common;
2240
2241 @functions {
2242 public string PerfionImagePrefix(int width, int height)
2243 {
2244 return string.Format("{0}/Perfion/Image.aspx?size={1}x{2}&format=png&id=", GlobalSettingsHelper.GetValue(PicoGlobalSettingsNames.PerfionWebApiUrl), width, height);
2245 }
2246 }
2247 @using System.Xml.Linq;
2248 @using Ppdw.Common;
2249 @using System.Diagnostics;
2250 @using System.Text;
2251 @using Dynamicweb.Configuration;
2252
2253 @functions {
2254
2255 }
2256
2257 @helper RenderCraneArmIllustrationCollection(IEnumerable<int> perfionIds)
2258 {
2259 if (0 < perfionIds.Count())
2260 {
2261
2262
2263 //var variantString = Convert.ToBase64String(Encoding.UTF8.GetBytes("[" + string.Join(",", variantJsObjects) + "]"));
2264 <canvas id="illustration-canvas"
2265 data-variants='@string.Join(",", perfionIds)'
2266 style="opacity: 0;width: 50%; height: 50%"
2267 @*data-scaling="@scaling"
2268 width="@(widestBase + widestJointSum + (mostJoints * (5 /* joint gap */ * scaling)) + (40 /* fly-jib indentation */ * scaling) + 10 /* image margin*/)"
2269 height="@(variantJsObjects.Count() * (120 * scaling))"*@
2270 ></canvas>
2271
2272 <img id="illustration-img" style="width:50%;height:50%;" />
2273 }
2274 }
2275 @using Ppdw.Common;
2276
2277 @functions {
2278 public string PerfionFilePrefix(Guid id)
2279 {
2280 return string.Format("{0}/Perfion/File.aspx?id={1}", GlobalSettingsHelper.GetValue(PicoGlobalSettingsNames.PerfionWebApiUrl), id);
2281 }
2282 }
2283 @using Dynamicweb.Rapido.Blocks.Components
2284 @using Dynamicweb.Rapido.Blocks.Components.General
2285 @using Dynamicweb.Rapido.Blocks
2286
2287
2288 @* Custom Component
2289
2290 * Added u-reset-position to secondary filter *
2291 *@
2292
2293 @helper RenderImageCustom(Image settings)
2294 {
2295 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None)
2296 {
2297 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>();
2298 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); }
2299
2300 if (settings.Caption != null)
2301 {
2302 @:<div>
2303 }
2304
2305 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower();
2306 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower();
2307
2308 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)>
2309 <div class="image-filter image-filter--@secondaryFilterClass u-reset-position dw-mod">
2310 @if (settings.Link != null)
2311 {
2312 <a href="@settings.Link">
2313 @RenderTheImage(settings)
2314 </a>
2315 }
2316 else
2317 {
2318 @RenderTheImage(settings)
2319 }
2320 </div>
2321 </div>
2322
2323 if (settings.Caption != null)
2324 {
2325 <span class="image-caption dw-mod">@settings.Caption</span>
2326 @:</div>
2327 }
2328 }
2329 else
2330 {
2331 if (settings.Caption != null)
2332 {
2333 @:<div>
2334 }
2335 if (!string.IsNullOrEmpty(settings.Link))
2336 {
2337 <a href="@settings.Link">
2338 @RenderTheImage(settings)
2339 </a>
2340 }
2341 else
2342 {
2343 @RenderTheImage(settings)
2344 }
2345
2346 if (settings.Caption != null)
2347 {
2348 <span class="image-caption dw-mod">@settings.Caption</span>
2349 @:</div>
2350 }
2351 }
2352 }
2353
2354 @using Dynamicweb.Frontend
2355 @using System.Reflection
2356 @using Dynamicweb.Content.Items
2357 @using System.Web.UI.HtmlControls
2358 @using Dynamicweb.Rapido.Blocks.Components
2359 @using Dynamicweb.Rapido.Blocks
2360 @using Dynamicweb.Rapido.Blocks.Components.Articles
2361
2362 @* Components for the articles *@
2363 @using System.Reflection
2364 @using Dynamicweb.Rapido.Blocks.Components.Articles
2365
2366
2367 @* Component for the articles *@
2368
2369 @helper RenderArticleBanner(dynamic settings) {
2370 string filterClasses = "image-filter image-filter--darken";
2371 settings.Layout = ArticleHeaderLayout.Banner;
2372
2373 if (settings.Image != null)
2374 {
2375 if (settings.Image.Path != null)
2376 {
2377 <section class="multiple-paragraphs-container u-color-light paragraph-container--full-width">
2378 <div class="background-image @filterClasses dw-mod">
2379 <div class="background-image__wrapper @filterClasses dw-mod">
2380 @{
2381 settings.Image.CssClass += "background-image__cover dw-mod";
2382 }
2383 @Render(settings.Image)
2384 </div>
2385 </div>
2386 <div class="center-container dw-mod">
2387 <div class="grid">
2388 <div class="grid__col-md-8 grid__col-xs-12 paragraph-container paragraph-container--height-lg">
2389 <div class="u-left-middle">
2390 <div>
2391 @if (!String.IsNullOrEmpty(settings.Heading))
2392 {
2393 <h1 class="article__header article__header--giant dw-mod" style="color: @settings.TextColor">@settings.Heading</h1>
2394 }
2395 @if (!String.IsNullOrEmpty(settings.Subheading))
2396 {
2397 <div class="article__leadtext dw-mod" style="color: @settings.TextColor">@settings.Subheading</div>
2398 }
2399 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date))
2400 {
2401 <small class="article__post-info u-margin-bottom--lg dw-mod" style="color: @settings.TextColor">@settings.Author @settings.Date</small>
2402 }
2403 @if (!String.IsNullOrEmpty(settings.Link)) {
2404 <div class="grid__cell">
2405 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout })
2406 </div>
2407 }
2408 </div>
2409 </div>
2410 </div>
2411 @if (settings.ExternalParagraphId != 0)
2412 {
2413 <div class="grid__col-md-4 grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-auto dw-mod">
2414 <div class="u-color-light-gray--bg u-color-dark dw-mod">
2415 @RenderParagraphContent(settings.ExternalParagraphId)
2416 </div>
2417 </div>
2418 }
2419
2420 </div>
2421 </div>
2422 </section>
2423 if (!String.IsNullOrEmpty(settings.Image.Caption)) {
2424 <div class="image-caption dw-mod">@settings.Image.Caption</div>
2425 }
2426 }
2427 else
2428 {
2429 settings.Layout = ArticleHeaderLayout.Clean;
2430 @RenderArticleCleanHeader(settings);
2431 }
2432 }
2433 else
2434 {
2435 settings.Layout = ArticleHeaderLayout.Clean;
2436 @RenderArticleCleanHeader(settings);
2437 }
2438 }
2439 @using System.Reflection
2440 @using Dynamicweb.Rapido.Blocks.Components
2441 @using Dynamicweb.Rapido.Blocks.Components.General
2442 @using Dynamicweb.Rapido.Blocks.Components.Articles
2443 @using Dynamicweb.Rapido.Blocks
2444
2445
2446 @* Component for the articles *@
2447
2448 @helper RenderArticleHeader(ArticleHeader settings) {
2449 dynamic[] methodParameters = new dynamic[1];
2450 methodParameters[0] = settings;
2451 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleHeaderCustom");
2452
2453 if (customMethod != null)
2454 {
2455 @customMethod.Invoke(this, methodParameters).ToString();
2456 } else {
2457 switch (settings.Layout)
2458 {
2459 case ArticleHeaderLayout.Clean:
2460 @RenderArticleCleanHeader(settings);
2461 break;
2462 case ArticleHeaderLayout.Split:
2463 @RenderArticleSplitHeader(settings);
2464 break;
2465 case ArticleHeaderLayout.Banner:
2466 @RenderArticleBannerHeader(settings);
2467 break;
2468 case ArticleHeaderLayout.Overlay:
2469 @RenderArticleOverlayHeader(settings);
2470 break;
2471 default:
2472 @RenderArticleCleanHeader(settings);
2473 break;
2474 }
2475 }
2476 }
2477
2478 @helper RenderArticleCleanHeader(ArticleHeader settings) {
2479 dynamic[] methodParameters = new dynamic[1];
2480 methodParameters[0] = settings;
2481 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleCleanHeaderCustom");
2482
2483 if (customMethod != null)
2484 {
2485 @customMethod.Invoke(this, methodParameters).ToString();
2486 }
2487 else
2488 {
2489 string contentColumns = settings.TextLayout != ArticleHeaderTextLayout.Full ? "8" : "12";
2490
2491 <div class="grid grid--align-content-start grid--justify-start">
2492 <div class="grid__col-md-@contentColumns grid__col-sm-12 u-padding--lg dw-mod">
2493 @if (!String.IsNullOrEmpty(settings.Category) || !String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date) || settings.RatingOutOf != 0)
2494 {
2495 <div class="u-border-bottom u-padding-bottom">
2496 @if (!String.IsNullOrEmpty(settings.Category))
2497 {
2498 <div class="u-pull--left">
2499 <div class="article__category dw-mod" style="color: @settings.CategoryColor">@settings.Category</div>
2500 </div>
2501 }
2502 <div class="u-pull--right">
2503 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date))
2504 {
2505 <small class="article__post-info dw-mod">@settings.Author @settings.Date</small>
2506 }
2507 @if (settings.RatingOutOf != 0)
2508 {
2509 @Render(new Rating { Score = settings.RatingScore, OutOf = settings.RatingOutOf })
2510 }
2511 </div>
2512 </div>
2513 }
2514
2515 <div class="grid__cell">
2516 @if (!String.IsNullOrEmpty(settings.Heading))
2517 {
2518 <h1 class="article__header article__header--giant dw-mod">@settings.Heading</h1>
2519 }
2520 @if (settings.Image != null)
2521 {
2522 if (settings.Image.Path != null)
2523 {
2524 <div class="u-padding-bottom--lg">
2525 @Render(settings.Image)
2526 </div>
2527 }
2528 }
2529 @if (!String.IsNullOrEmpty(settings.Subheading))
2530 {
2531 <div class="article__leadtext dw-mod">@settings.Subheading</div>
2532 }
2533 @if (!String.IsNullOrEmpty(settings.Link))
2534 {
2535 <div class="grid__cell">
2536 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout })
2537 </div>
2538 }
2539 </div>
2540 </div>
2541 @if (settings.ExternalParagraphId != 0)
2542 {
2543 <div class="grid__col-md-4 grid__col-sm-12 u-padding--lg u-color-light-gray--bg dw-mod">
2544 @RenderParagraphContent(settings.ExternalParagraphId)
2545 </div>
2546 }
2547 </div>
2548 }
2549 }
2550
2551 @helper RenderArticleSplitHeader(ArticleHeader settings) {
2552 dynamic[] methodParameters = new dynamic[1];
2553 methodParameters[0] = settings;
2554 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleSplitHeaderCustom");
2555
2556 if (customMethod != null)
2557 {
2558 @customMethod.Invoke(this, methodParameters).ToString();
2559 }
2560 else
2561 {
2562 string headerColumnWidth = settings.ExternalParagraphId != 0 ? "4" : "6";
2563
2564 if (settings.Image != null)
2565 {
2566 if (settings.Image.Path != null)
2567 {
2568 <section class="multiple-paragraphs-container paragraph-container--full-width">
2569 <div class="grid">
2570 <div class="grid__col-md-@headerColumnWidth grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-xl dw-mod">
2571 <div class="u-left-middle u-padding--lg">
2572 <div>
2573 @if (!String.IsNullOrEmpty(settings.Category))
2574 {
2575 <div class="article__category dw-mod" style="color: @settings.CategoryColor">@settings.Category</div>
2576 }
2577 @if (!String.IsNullOrEmpty(settings.Heading))
2578 {
2579 <h1 class="article__header article__header--giant dw-mod">@settings.Heading</h1>
2580 }
2581 @if (!String.IsNullOrEmpty(settings.Subheading))
2582 {
2583 <div class="article__leadtext dw-mod">@settings.Subheading</div>
2584 }
2585 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date))
2586 {
2587 <small class="article__post-info u-pull--left dw-mod">@settings.Author @settings.Date</small>
2588 }
2589 @if (settings.RatingOutOf != 0)
2590 {
2591 <div class="u-pull--right">
2592 @Render(new Rating { Score = settings.RatingScore, OutOf = settings.RatingOutOf })
2593 </div>
2594 }
2595 @if (!String.IsNullOrEmpty(settings.Link)) {
2596 <div class="u-full-width u-pull--left u-margin-top">
2597 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout })
2598 </div>
2599 }
2600 </div>
2601 </div>
2602 </div>
2603 <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>
2604 @if (settings.ExternalParagraphId != 0)
2605 {
2606 <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">
2607 @RenderParagraphContent(settings.ExternalParagraphId)
2608 </div>
2609 }
2610 </div>
2611 </section>
2612 }
2613 }
2614 else
2615 {
2616 @RenderArticleCleanHeader(settings);
2617 }
2618 }
2619 }
2620
2621 @helper RenderArticleOverlayHeader(ArticleHeader settings) {
2622 dynamic[] methodParameters = new dynamic[1];
2623 methodParameters[0] = settings;
2624 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleOverlayHeaderCustom");
2625
2626 if (customMethod != null)
2627 {
2628 @customMethod.Invoke(this, methodParameters).ToString();
2629 }
2630 else
2631 {
2632 string contentColumns = settings.TextLayout != ArticleHeaderTextLayout.Full ? "8" : "12";
2633 string contentAlignment = settings.TextLayout == ArticleHeaderTextLayout.Center ? "grid--justify-center" : "";
2634
2635 if (settings.Image != null)
2636 {
2637 if (settings.Image.Path != null)
2638 {
2639 if (settings.ExternalParagraphId == 0)
2640 {
2641 <section class="multiple-paragraphs-container u-color-light paragraph-container--full-width">
2642 <div class="background-image image-filter image-filter--darken dw-mod">
2643 <div class="background-image__wrapper image-filter image-filter--darken dw-mod">
2644 @{
2645 settings.Image.CssClass += "background-image__cover dw-mod";
2646 }
2647 @Render(settings.Image)
2648 </div>
2649 </div>
2650 <div class="center-container dw-mod">
2651 <div class="grid @contentAlignment">
2652 <div class="grid__col-md-@contentColumns grid__col-xs-12 paragraph-container paragraph-container--height-xl dw-mod">
2653 @if (!string.IsNullOrEmpty(settings.Heading))
2654 {
2655 <h1 class="article__header article__header--giant u-padding-top--lg dw-mod" style="color: @settings.TextColor">@settings.Heading</h1>
2656 }
2657 @if (!String.IsNullOrEmpty(settings.Subheading))
2658 {
2659 <div class="article__leadtext dw-mod" style="color: @settings.TextColor">@settings.Subheading</div>
2660 }
2661 <div class="u-margin-top">
2662 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date))
2663 {
2664 <small class="article__post-info u-pull--left dw-mod" style="color: @settings.TextColor">@settings.Author @settings.Date</small>
2665 }
2666 @if (settings.RatingOutOf != 0)
2667 {
2668 <div class="u-pull--right">
2669 @Render(new Rating { Score = settings.RatingScore, OutOf = settings.RatingOutOf })
2670 </div>
2671 }
2672 </div>
2673 @if (!String.IsNullOrEmpty(settings.Link))
2674 {
2675 <div class="grid__cell">
2676 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout })
2677 </div>
2678 }
2679 </div>
2680 </div>
2681 </div>
2682 </section>
2683 }
2684 else
2685 {
2686 @RenderArticleBanner(settings);
2687 }
2688 }
2689 }
2690 else
2691 {
2692 @RenderArticleCleanHeader(settings);
2693 }
2694 }
2695 }
2696
2697 @helper RenderArticleBannerHeader(dynamic settings) {
2698 dynamic[] methodParameters = new dynamic[1];
2699 methodParameters[0] = settings;
2700 MethodInfo customMethod = this.GetType().GetMethod("RenderArticleBannerHeaderCustom");
2701
2702 if (customMethod != null)
2703 {
2704 @customMethod.Invoke(this, methodParameters).ToString();
2705 }
2706 else
2707 {
2708 @RenderArticleBanner(settings);
2709 }
2710 }
2711 @using System.Reflection
2712 @using System.Text.RegularExpressions;
2713 @using Dynamicweb.Frontend
2714 @using Dynamicweb.Content.Items
2715 @using Dynamicweb.Rapido.Blocks.Components
2716 @using Dynamicweb.Rapido.Blocks.Components.Articles
2717 @using Dynamicweb.Rapido.Blocks
2718
2719 @* Component for the articles *@
2720
2721 @helper RenderArticleBodyRow(ArticleBodyRow settings)
2722 {
2723 string position = settings.TopLayout == "overlay" ? "article__overlay-offset" : "";
2724 string contentAlignment = settings.TextLayout == "center" ? "grid--justify-center" : "";
2725
2726 <div class="grid grid--align-content-start @contentAlignment @position dw-mod">
2727 @RenderBlockList(settings.SubBlocks)
2728 </div>
2729 }
2730 @using System.Reflection
2731 @using Dynamicweb.Rapido.Blocks.Components
2732 @using Dynamicweb.Rapido.Blocks.Components.General
2733 @using Dynamicweb.Rapido.Blocks.Components.Articles
2734 @using Dynamicweb.Rapido.Blocks
2735
2736 @* Component for the articles *@
2737
2738 @helper RenderArticleImage(ArticleImage settings)
2739 {
2740 if (settings.Image != null)
2741 {
2742 if (settings.Image.Path != null)
2743 {
2744 <div class="u-margin-bottom--lg">
2745 @Render(settings.Image)
2746 </div>
2747 }
2748 }
2749 }
2750 @using System.Reflection
2751 @using Dynamicweb.Rapido.Blocks.Components
2752 @using Dynamicweb.Rapido.Blocks.Components.Articles
2753
2754
2755 @* Component for the articles *@
2756
2757 @helper RenderArticleSubHeader(ArticleSubHeader settings)
2758 {
2759 if (!String.IsNullOrEmpty(settings.Title))
2760 {
2761 <h2 class="article__header">@settings.Title</h2>
2762 }
2763 }
2764 @using System.Reflection
2765 @using Dynamicweb.Rapido.Blocks.Components
2766 @using Dynamicweb.Rapido.Blocks.Components.Articles
2767 @using Dynamicweb.Rapido.Blocks
2768
2769
2770 @* Component for the articles *@
2771
2772 @helper RenderArticleText(ArticleText settings)
2773 {
2774 if (!String.IsNullOrEmpty(settings.Text))
2775 {
2776 string greatTextClass = settings.EnableLargeText == true ? "article__paragraph--great-text" : "";
2777
2778 <div class="article__paragraph @greatTextClass dw-mod">
2779 @settings.Text
2780 </div>
2781 }
2782 }
2783 @using System.Reflection
2784 @using Dynamicweb.Rapido.Blocks.Components
2785 @using Dynamicweb.Rapido.Blocks.Components.Articles
2786 @using Dynamicweb.Rapido.Blocks
2787
2788
2789 @* Component for the articles *@
2790
2791 @helper RenderArticleQuote(ArticleQuote settings)
2792 {
2793 string text = Regex.Replace(settings.Text, "<.*?>", String.Empty);
2794
2795 <div class="grid u-padding-bottom--lg">
2796 @if (settings.Image != null)
2797 {
2798 if (settings.Image.Path != null) {
2799 <div class="grid__col-3">
2800 <div class="grid__cell-img">
2801 @{
2802 settings.Image.Title = !String.IsNullOrEmpty(settings.Image.Title) ? settings.Image.Title : settings.Author;
2803 settings.Image.CssClass += " article__image article__image--ball";
2804 settings.Image.ImageDefault.Width = 200;
2805 settings.Image.ImageDefault.Height = 200;
2806 }
2807 @Render(settings.Image)
2808 </div>
2809 </div>
2810 }
2811 }
2812 <div class="grid__col-auto">
2813 @if (!String.IsNullOrEmpty(settings.Text))
2814 {
2815 <div class="article__quote dw-mod">
2816 <i class="fas fa-quote-right u-margin-bottom--lg"></i>
2817 @settings.Text
2818 <i class="fas fa-quote-right"></i>
2819 </div>
2820 }
2821 @if (!String.IsNullOrEmpty(settings.Author))
2822 {
2823 <div class="article__quote-author dw-mod">
2824 - @settings.Author
2825 </div>
2826 }
2827 </div>
2828 </div>
2829 }
2830 @using System.Reflection
2831 @using Dynamicweb.Rapido.Blocks.Components
2832 @using Dynamicweb.Rapido.Blocks.Components.Articles
2833 @using Dynamicweb.Rapido.Blocks
2834
2835 @* Component for the articles *@
2836
2837 @helper RenderArticleInfoTable(ArticleInfoTable settings)
2838 {
2839 <table class="table table--clean">
2840 @foreach (var row in settings.Rows)
2841 {
2842 string iconColor = row.IconColor != null ? row.IconColor : "u-brand-color-two";
2843
2844 <tr>
2845 @if (!String.IsNullOrEmpty(row.Icon))
2846 {
2847 <td class="u-w32px"><i class="@row.Icon fa-2x @row.IconColor"></i></td>
2848 }
2849 <td class="u-no-margin-on-p-elements">
2850 <div class="u-bold">@row.Title</div>
2851 @if (!String.IsNullOrEmpty(row.SubTitle))
2852 {
2853 if (row.Link == null)
2854 {
2855 <div>@row.SubTitle</div>
2856 }
2857 else
2858 {
2859 <a href="@row.Link" class="u-color-inherit">@row.SubTitle</a>
2860 }
2861 }
2862 </td>
2863 </tr>
2864 }
2865 </table>
2866 }
2867 @using System.Reflection
2868 @using Dynamicweb.Rapido.Blocks.Components
2869 @using Dynamicweb.Rapido.Blocks.Components.General
2870 @using Dynamicweb.Rapido.Blocks.Components.Articles
2871 @using Dynamicweb.Rapido.Blocks
2872
2873 @* Component for the articles *@
2874
2875 @helper RenderArticleGalleryModal(ArticleGalleryModal settings)
2876 {
2877 Modal galleryModal = new Modal
2878 {
2879 Id = "ParagraphGallery",
2880 Width = ModalWidth.Full,
2881 BodyTemplate = RenderArticleGalleryModalContent()
2882 };
2883
2884 @Render(galleryModal)
2885 }
2886
2887 @helper RenderArticleGalleryModalContent() {
2888 <div class="modal__image-min-size-wrapper">
2889 @Render(new Image {
2890 Id = "ParagraphGallery",
2891 Path = "#",
2892 CssClass = "modal--full__img",
2893 DisableLazyLoad = true,
2894 DisableImageEngine = true
2895 })
2896 </div>
2897
2898 <div class="modal__images-counter" id="ParagraphGallery_counter"></div>
2899
2900 @Render(new Button {
2901 Id = "ParagraphGallery_prev",
2902 ButtonType = ButtonType.Button,
2903 ButtonLayout = ButtonLayout.None,
2904 CssClass = "modal__prev-btn",
2905 Icon = new Icon { Prefix = "far", Name = "fa-angle-left", LabelPosition = IconLabelPosition.After },
2906 OnClick = "Gallery.prevImage('ParagraphGallery')"
2907 })
2908
2909 @Render(new Button {
2910 Id = "ParagraphGallery_next",
2911 ButtonType = ButtonType.Button,
2912 ButtonLayout = ButtonLayout.None,
2913 CssClass = "modal__next-btn",
2914 Icon = new Icon { Prefix = "far", Name = "fa-angle-right", LabelPosition = IconLabelPosition.After },
2915 OnClick = "Gallery.nextImage('ParagraphGallery')"
2916 })
2917 }
2918 @using System.Reflection
2919 @using Dynamicweb.Rapido.Blocks.Components
2920 @using Dynamicweb.Rapido.Blocks.Components.Articles
2921 @using Dynamicweb.Rapido.Blocks
2922
2923
2924 @* Component for the articles *@
2925
2926 @helper RenderArticleRelated(ArticleRelated settings)
2927 {
2928 string cardClass = Pageview.Device.ToString() != "Tablet" ? "card u-color-light--bg u-full-height" : "";
2929 string cardFooterClass = Pageview.Device.ToString() != "Tablet" ? "card-footer u-color-light--bg" : "";
2930
2931 <section class="multiple-paragraphs-container u-color-light-gray--bg paragraph-container--full-width">
2932 <div class="center-container dw-mod">
2933 <div class="grid u-padding">
2934 <div class="grid__col-md-12 grid__col-xs-12">
2935 <h2 class="article__header u-no-margin u-margin-top">@settings.Title</h2>
2936 </div>
2937 </div>
2938
2939 <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>
2940
2941 <script id="RelatedSimpleTemplate" type="text/x-template">
2942 {{#.}}
2943 <div class="grid u-padding-bottom--lg">
2944 {{#Cases}}
2945 <div class="grid__col-lg-3 grid__col-sm-6 image-hover--zoom dw-mod">
2946 <a href="{{link}}" class="u-full-height u-color-light--bg u-flex u-flex--column">
2947 {{#if image}}
2948 <div class="u-color-light--bg u-no-padding dw-mod">
2949 <div class="flex-img image-hover__wrapper">
2950 <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}}" />
2951 </div>
2952 </div>
2953 {{/if}}
2954
2955 <div class="card u-color-light--bg u-full-height dw-mod">
2956 <h3 class="article-list__item-header u-truncate-text dw-mod">{{title}}</h3>
2957 <p class="article__short-summary dw-mod">{{summary}}</p>
2958 </div>
2959 </a>
2960 </div>
2961 {{/Cases}}
2962 </div>
2963 {{/.}}
2964 </script>
2965 </div>
2966 </section>
2967 }
2968 @using System.Reflection
2969 @using Dynamicweb.Rapido.Blocks.Components
2970 @using Dynamicweb.Rapido.Blocks.Components.Articles
2971 @using Dynamicweb.Rapido.Blocks
2972
2973
2974 @* Component for the articles *@
2975
2976 @helper RenderArticleMenu(ArticleMenu settings)
2977 {
2978 if (!String.IsNullOrEmpty(settings.Title)) {
2979 <div class="u-margin u-border-bottom">
2980 <h3 class="u-no-margin">@settings.Title</h3>
2981 </div>
2982 }
2983
2984 <ul class="menu-left u-margin-bottom dw-mod">
2985 @foreach (var item in settings.Items)
2986 {
2987 @Render(item)
2988 }
2989 </ul>
2990 }
2991
2992 @helper RenderArticleMenuItem(ArticleMenuItem settings)
2993 {
2994 string link = !String.IsNullOrEmpty(settings.Link) ? settings.Link : "#";
2995
2996 if (!String.IsNullOrEmpty(settings.Title)) {
2997 <li class="menu-left__item dw-mod">
2998 <a href="@link" onclick="@settings.OnClick" class="menu-left__link dw-mod">@settings.Title</a>
2999 </li>
3000 }
3001 }
3002 @using System.Reflection
3003 @using Dynamicweb.Rapido.Blocks.Components
3004 @using Dynamicweb.Rapido.Blocks.Components.Articles
3005 @using Dynamicweb.Rapido.Blocks
3006
3007 @* Component for the articles *@
3008
3009 @helper RenderArticleList(ArticleList settings)
3010 {
3011 if (Pageview != null)
3012 {
3013 bool isParagraph = Pageview.CurrentParagraph != null ? true : false;
3014 string[] sortArticlesListBy = new string[2];
3015
3016 if (isParagraph) {
3017 sortArticlesListBy = Pageview.CurrentParagraph.Item["SortArticlesListBy"] != null && !string.IsNullOrEmpty(Pageview.CurrentParagraph.Item["SortArticlesListBy"].ToString()) ? Pageview.CurrentParagraph.Item["SortArticlesListBy"].ToString().Split('+') : new string[] { "Date", "ASC" };
3018 }
3019 else {
3020 sortArticlesListBy = Pageview.Item["SortArticlesListBy"] != null && !string.IsNullOrEmpty(Pageview.Item["SortArticlesListBy"].ToString()) ? Pageview.Item["SortArticlesListBy"].ToString().Split('+') : new string[] { "Date", "ASC" };
3021 }
3022
3023 string sourcePage = settings.SourcePage != null ? settings.SourcePage : Pageview.ID.ToString();
3024
3025 if (!settings.DisablePagination) {
3026 @RenderItemList(new
3027 {
3028 ItemType = !String.IsNullOrEmpty(settings.ItemType) ? settings.ItemType : "DynamicArticle",
3029 ListSourceType = settings.SourceType,
3030 ListSourcePage = sourcePage,
3031 ItemFieldsList = "*",
3032 Filter = settings.Filter,
3033 ListOrderBy = sortArticlesListBy[0],
3034 ListOrderByDirection = sortArticlesListBy[1],
3035 ListSecondOrderBy = sortArticlesListBy[0] == "Date" ? "InFocusSortId" : "Date",
3036 ListSecondOrderByDirection = "ASC",
3037 IncludeAllChildItems = true,
3038 ListTemplate = settings.Template,
3039 ListPageSize = settings.PageSize.ToString()
3040 });
3041 } else {
3042 @RenderItemList(new
3043 {
3044 ItemType = !String.IsNullOrEmpty(settings.ItemType) ? settings.ItemType : "DynamicArticle",
3045 ListSourceType = settings.SourceType,
3046 ListSourcePage = sourcePage,
3047 ItemFieldsList = "*",
3048 Filter = settings.Filter,
3049 ListOrderBy = sortArticlesListBy[0],
3050 ListOrderByDirection = sortArticlesListBy[1],
3051 ListSecondOrderBy = sortArticlesListBy[0] == "Date" ? "InFocusSortId" : "Date",
3052 ListSecondOrderByDirection = "ASC",
3053 IncludeAllChildItems = true,
3054 ListTemplate = settings.Template,
3055 ListPageSize = settings.PageSize.ToString(),
3056 ListViewMode = "Partial",
3057 ListShowTo = settings.PageSize + 1
3058 });
3059 }
3060 }
3061 }
3062 @using System.Reflection
3063 @using Dynamicweb.Rapido.Blocks.Components.Articles
3064
3065
3066 @* Component for the articles *@
3067
3068 @helper RenderArticleSummary(ArticleSummary settings)
3069 {
3070 if (!String.IsNullOrEmpty(settings.Text))
3071 {
3072 <div class="article__summary dw-mod">@settings.Text</div>
3073 }
3074 }
3075 @using System.Reflection
3076 @using Dynamicweb.Rapido.Blocks.Components
3077 @using Dynamicweb.Rapido.Blocks.Components.Articles
3078 @using Dynamicweb.Rapido.Blocks
3079
3080 @* Component for the articles *@
3081
3082 @helper RenderArticleListCategoryFilter(ArticleListCategoryFilter settings)
3083 {
3084 string pageId = Pageview.ID.ToString();
3085 string selectedFilter = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("sourcePage")) ? HttpContext.Current.Request.QueryString.Get("sourcePage") : Translate("All");
3086 var query = HttpUtility.ParseQueryString(HttpContext.Current.Request.QueryString.ToString());
3087
3088 foreach (var option in settings.Categories)
3089 {
3090 selectedFilter = selectedFilter == option.Value ? option.Key : selectedFilter;
3091 }
3092
3093 if (selectedFilter == pageId)
3094 {
3095 selectedFilter = Translate("All");
3096 }
3097
3098 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet")
3099 {
3100 <div class="u-pull--right u-margin-left">
3101 <div class="collection u-no-margin">
3102 <h5>@Translate("Category")</h5>
3103 <input type="checkbox" id="CategorySelector" class="dropdown-trigger" />
3104 <div class="dropdown u-w180px dw-mod">
3105 <label class="dropdown__header dropdown__btn dw-mod" for="CategorySelector">@Translate(selectedFilter)</label>
3106 <div class="dropdown__content dw-mod">
3107 @foreach (var option in settings.Categories)
3108 {
3109 <div class="dropdown__item" onclick="QueryArray.setParametersInCurrentURL({ sourceType: 'Page', sourcePage: '@(option.Key.ToLower() == "all" ? pageId : option.Value)' })">@Translate(option.Key)</div>
3110 }
3111 </div>
3112 <label class="dropdown-trigger-off" for="CategorySelector"></label>
3113 </div>
3114 </div>
3115 </div>
3116 }
3117 else
3118 {
3119 <div class="u-full-width u-margin-bottom">
3120 <h5 class="u-no-margin">@Translate("Category")</h5>
3121 <input type="checkbox" id="CategorySelector" class="dropdown-trigger" />
3122 <div class="dropdown u-full-width dw-mod">
3123 <label class="dropdown__header dropdown__btn dw-mod" for="CategorySelector">@Translate(selectedFilter)</label>
3124 <div class="dropdown__content dw-mod">
3125 @foreach (var option in settings.Categories)
3126 {
3127 <div class="dropdown__item" onclick="QueryArray.setParametersInCurrentURL({ sourceType: 'Page', sourcePage: '@(option.Key.ToLower() == "all" ? pageId : option.Value)' })">@Translate(option.Key)</div>
3128 }
3129 </div>
3130 <label class="dropdown-trigger-off" for="CategorySelector"></label>
3131 </div>
3132 </div>
3133 }
3134 }
3135 @using System.Reflection
3136 @using Dynamicweb.Rapido.Blocks.Components
3137 @using Dynamicweb.Rapido.Blocks.Components.Articles
3138 @using Dynamicweb.Rapido.Blocks
3139 @using System.Collections.Generic
3140
3141 @* Component for the articles *@
3142
3143 @helper RenderArticleListFilter(ArticleListFilter settings)
3144 {
3145 string selectedFilter = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get(settings.SystemName)) ? HttpContext.Current.Request.QueryString.Get(settings.SystemName) : Translate("All");
3146 var query = HttpUtility.ParseQueryString(HttpContext.Current.Request.QueryString.ToString());
3147
3148 if (settings.Options != null)
3149 {
3150 if (settings.Options is IEnumerable<dynamic>)
3151 {
3152 var options = (IEnumerable<dynamic>) settings.Options;
3153 settings.Options = options.OrderBy(item => item.Name);
3154 }
3155
3156 foreach (var option in settings.Options)
3157 {
3158 selectedFilter = selectedFilter == option.Value ? option.Name : selectedFilter;
3159 }
3160
3161 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet")
3162 {
3163 <div class="u-pull--right u-margin-left">
3164 <div class="collection u-no-margin">
3165 <h5>@settings.Label</h5>
3166 <input type="checkbox" id="@(settings.SystemName)Selector" class="dropdown-trigger" />
3167 <div class="dropdown u-w180px dw-mod">
3168 <label class="dropdown__header dropdown__btn dw-mod" for="@(settings.SystemName)Selector">@Translate(selectedFilter)</label>
3169 <div class="dropdown__content dw-mod">
3170 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '')">@Translate("All")</div>
3171 @foreach (var option in settings.Options)
3172 {
3173 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '@option.Value')">@Translate(option.Name)</div>
3174 }
3175 </div>
3176 <label class="dropdown-trigger-off" for="@(settings.SystemName)Selector"></label>
3177 </div>
3178 </div>
3179 </div>
3180 }
3181 else
3182 {
3183 <div class="u-full-width u-margin-bottom">
3184 <h5 class="u-no-margin">@settings.Label</h5>
3185 <input type="checkbox" id="@(settings.SystemName)Selector" class="dropdown-trigger" />
3186 <div class="dropdown u-full-width w-mod">
3187 <label class="dropdown__header dropdown__btn dw-mod" for="@(settings.SystemName)Selector">@Translate(selectedFilter)</label>
3188 <div class="dropdown__content dw-mod">
3189 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '')">@Translate("All")</div>
3190 @foreach (var option in settings.Options)
3191 {
3192 <div class="dropdown__item" onclick="QueryArray.setParameterInCurrentURL('@settings.SystemName', '@option.Value')">@Translate(option.Name)</div>
3193 }
3194 </div>
3195 <label class="dropdown-trigger-off" for="@(settings.SystemName)Selector"></label>
3196 </div>
3197 </div>
3198 }
3199 }
3200 }
3201 @using System.Reflection
3202 @using Dynamicweb.Rapido.Blocks.Components
3203 @using Dynamicweb.Rapido.Blocks.Components.Articles
3204 @using Dynamicweb.Rapido.Blocks
3205
3206 @* Component for the articles *@
3207
3208 @helper RenderArticleListSearch(ArticleListSearch settings)
3209 {
3210 string searchParameter = !string.IsNullOrEmpty(settings.SearchParameter) ? settings.SearchParameter : "Title";
3211 string searchWord = HttpContext.Current.Request.QueryString.Get(searchParameter);
3212 string searchString = !string.IsNullOrEmpty(searchWord) ? searchWord.Trim('*') : "";
3213 string className = "u-w340px u-pull--right u-margin-left";
3214
3215 if (Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet")
3216 {
3217 className = "u-full-width";
3218 }
3219
3220 <div class="typeahead u-color-inherit u-margin-bottom dw-mod @className">
3221 <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 + '*')">
3222 <button type="button" class="btn btn--condensed btn--primary u-no-margin dw-mod"><i class="fas fa-search"></i></button>
3223 </div>
3224 }
3225 @using System.Reflection
3226 @using Dynamicweb.Rapido.Blocks.Components
3227 @using Dynamicweb.Rapido.Blocks.Components.Articles
3228 @using Dynamicweb.Rapido.Blocks
3229
3230 @* Component for the articles *@
3231
3232 @helper RenderArticleListNoResultsInfo(ArticleListNoResultsInfo settings)
3233 {
3234 <div class="u-margin-top--lg u-bold u-ta-center u-bold">@Translate(settings.Message)</div>
3235 }
3236 @using System.Reflection
3237 @using Dynamicweb.Rapido.Blocks.Components
3238 @using Dynamicweb.Rapido.Blocks.Components.General
3239 @using Dynamicweb.Rapido.Blocks.Components.Articles
3240 @using Dynamicweb.Rapido.Blocks
3241 @using System.Text.RegularExpressions
3242
3243 @* Component for the articles *@
3244
3245 @helper RenderArticleListItem(ArticleListItem settings)
3246 {
3247 switch (settings.Type) {
3248 case ArticleListItemType.Card:
3249 @RenderArticleListItemCard(settings);
3250 break;
3251 case ArticleListItemType.List:
3252 @RenderArticleListItemList(settings);
3253 break;
3254 case ArticleListItemType.Simple:
3255 @RenderArticleListItemSimple(settings);
3256 break;
3257 default:
3258 @RenderArticleListItemCard(settings);
3259 break;
3260 }
3261 }
3262
3263 @helper RenderArticleListItemCard(ArticleListItem settings) {
3264 <a href="@settings.Link" class="u-full-height u-color-light--bg u-flex u-flex--column">
3265 <div class="u-color-light--bg u-no-padding dw-mod">
3266 @if (settings.Logo != null)
3267 {
3268 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;" : "";
3269 settings.Logo.ImageDefault.Crop = 5;
3270 settings.Logo.ImageDefault.Width = settings.Logo.ImageDefault.Width == 1920 ? 240 : settings.Logo.ImageDefault.Width;
3271 settings.Logo.ImageDefault.Height = settings.Logo.ImageDefault.Height == 1080 ? 200 : settings.Logo.ImageDefault.Height;
3272 <div class="image-hover__wrapper layered-image layered-image--tinted dw-mod" style="@backgroundImage">
3273 @if (settings.Stickers != null)
3274 {
3275 if (settings.Stickers.Position != StickersListPosition.Custom && settings.Stickers.Position != StickersListPosition.None)
3276 {
3277 @Render(settings.Stickers);
3278 }
3279 }
3280 @RenderImage(settings.Logo)
3281 </div>
3282 } else if (settings.Image != null)
3283 {
3284 <div class="flex-img image-hover__wrapper u-position-relative dw-mod">
3285 @if (settings.Stickers != null)
3286 {
3287 if (settings.Stickers.Position != StickersListPosition.Custom && settings.Stickers.Position != StickersListPosition.None)
3288 {
3289 @Render(settings.Stickers);
3290 }
3291 }
3292 @Render(settings.Image)
3293 </div>
3294 }
3295 </div>
3296
3297 @if (!String.IsNullOrEmpty(settings.Title) || !String.IsNullOrEmpty(settings.Summary))
3298 {
3299 <div class="card u-color-light--bg u-full-height dw-mod">
3300 @if (settings.Stickers != null)
3301 {
3302 if (settings.Stickers.Position == StickersListPosition.Custom)
3303 {
3304 @Render(settings.Stickers);
3305 }
3306 }
3307 @if (!String.IsNullOrEmpty(settings.Title))
3308 {
3309 <h3 class="article-list__item-header u-truncate-text dw-mod">@settings.Title</h3>
3310 }
3311 @if (!String.IsNullOrEmpty(settings.SubTitle))
3312 {
3313 <div class="article-list__item-micro-info u-truncate-text dw-mod">@settings.SubTitle</div>
3314 }
3315 @if (!String.IsNullOrEmpty(settings.Summary))
3316 {
3317 <p class="article__short-summary dw-mod">@settings.Summary</p>
3318 }
3319 </div>
3320 }
3321 </a>
3322 }
3323
3324 @helper RenderArticleListItemList(ArticleListItem settings) {
3325 <a href="@settings.Link">
3326 <div class="grid u-color-light--bg u-no-padding dw-mod">
3327 <div class="grid__col-md-3">
3328 <div class="u-color-light--bg u-no-padding dw-mod">
3329 @if (settings.Logo != null)
3330 {
3331 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;" : "";
3332 settings.Logo.ImageDefault.Crop = 5;
3333 settings.Logo.ImageDefault.Width = settings.Logo.ImageDefault.Width == 1920 ? 240 : settings.Logo.ImageDefault.Width;
3334 settings.Logo.ImageDefault.Height = settings.Logo.ImageDefault.Height == 1080 ? 200 : settings.Logo.ImageDefault.Height;
3335 <div class="image-hover__wrapper layered-image layered-image--tinted dw-mod" style="@backgroundImage">
3336 @if (settings.Stickers != null)
3337 {
3338 if (settings.Stickers.Position != StickersListPosition.Custom)
3339 {
3340 @Render(settings.Stickers);
3341 }
3342 }
3343 @RenderImage(settings.Logo)
3344 </div>
3345 } else if (settings.Image != null)
3346 {
3347 <div class="flex-img image-hover__wrapper dw-mod">
3348 @if (settings.Stickers != null)
3349 {
3350 if (settings.Stickers.Position != StickersListPosition.Custom)
3351 {
3352 @Render(settings.Stickers);
3353 }
3354 }
3355 @Render(settings.Image)
3356 </div>
3357 }
3358 </div>
3359 </div>
3360
3361 @if (!String.IsNullOrEmpty(settings.Title) || !String.IsNullOrEmpty(settings.Summary))
3362 {
3363 <div class="grid__col-md-9">
3364 @if (!String.IsNullOrEmpty(settings.Title))
3365 {
3366 <h3 class="article-list__item-header u-truncate-text dw-mod">@settings.Title</h3>
3367 }
3368 @if (settings.Stickers != null)
3369 {
3370 if (settings.Stickers.Position == StickersListPosition.Custom)
3371 {
3372 @Render(settings.Stickers);
3373 }
3374 }
3375 @if (!String.IsNullOrEmpty(settings.SubTitle))
3376 {
3377 <div class="article-list__item-micro-info u-truncate-text dw-mod">@settings.SubTitle</div>
3378 }
3379 @if (!String.IsNullOrEmpty(settings.Summary))
3380 {
3381 <p class="article__short-summary dw-mod">@settings.Summary</p>
3382 }
3383 </div>
3384 }
3385 </div>
3386 </a>
3387 }
3388
3389 @helper RenderArticleListItemSimple(ArticleListItem settings) {
3390 <a href="@settings.Link" class="u-color-inherit">
3391 <div class="grid u-color-light--bg u-no-padding dw-mod">
3392 <div class="grid__col-md-12">
3393 @if (!String.IsNullOrEmpty(settings.Title))
3394 {
3395 <div class="article-list-item__header u-truncate-text u-no-margin dw-mod">@settings.Title</div>
3396 }
3397 @if (!String.IsNullOrEmpty(settings.SubTitle))
3398 {
3399 <div class="article-list__item-micro-info u-truncate-text dw-mod">@settings.SubTitle</div>
3400 }
3401 </div>
3402 </div>
3403 </a>
3404 }
3405 @using System.Reflection
3406 @using Dynamicweb.Rapido.Blocks.Components.Articles
3407
3408
3409 @* Component for the articles *@
3410
3411 @helper RenderArticleAuthorAndDate(ArticleAuthorAndDate settings)
3412 {
3413 <small class="article__subscription">
3414 @if (!(string.IsNullOrWhiteSpace(settings.Author) && string.IsNullOrWhiteSpace(settings.Date)))
3415 {
3416 <text>@Translate("Written")</text>
3417 }
3418 @if (!string.IsNullOrWhiteSpace(settings.Author))
3419 {
3420 <text>@Translate("by") @settings.Author</text>
3421 }
3422 @if (!string.IsNullOrWhiteSpace(settings.Date))
3423 {
3424 <text>@Translate("on") @settings.Date</text>
3425 }
3426 </small>
3427 }
3428 @using System.Reflection
3429 @using Dynamicweb.Rapido.Blocks.Components.Articles
3430 @using Dynamicweb.Rapido.Blocks.Components.General
3431
3432
3433 @* Component for the articles *@
3434
3435 @helper RenderArticleLink(ArticleLink settings)
3436 {
3437 if (!string.IsNullOrEmpty(settings.Title))
3438 {
3439 Button link = new Button {
3440 ConfirmText = settings.ConfirmText,
3441 ConfirmTitle = settings.ConfirmTitle,
3442 ButtonType = settings.ButtonType,
3443 Id = settings.Id,
3444 Title = settings.Title,
3445 AltText = settings.AltText,
3446 OnClick = settings.OnClick,
3447 CssClass = settings.CssClass,
3448 Disabled = settings.Disabled,
3449 Icon = settings.Icon,
3450 Name = settings.Name,
3451 Href = settings.Href,
3452 ButtonLayout = settings.ButtonLayout,
3453 ExtraAttributes = settings.ExtraAttributes
3454 };
3455 <div class="grid__cell">
3456 @Render(link)
3457 </div>
3458 }
3459 }
3460 @using System.Reflection
3461 @using Dynamicweb.Rapido.Blocks
3462 @using Dynamicweb.Rapido.Blocks.Components.Articles
3463 @using Dynamicweb.Rapido.Blocks.Components.General
3464
3465
3466 @* Component for the articles *@
3467
3468 @helper RenderArticleCarousel(ArticleCarousel settings)
3469 {
3470 <div class="grid">
3471 <div class="grid__col-12 u-no-padding u-margin-bottom">
3472 <div class="carousel" id="carousel_@settings.Id">
3473 <div class="carousel__container js-carousel-slides dw-mod">
3474 @RenderBlockList(settings.SubBlocks)
3475 </div>
3476 </div>
3477 </div>
3478 </div>
3479
3480 <script>
3481 document.addEventListener("DOMContentLoaded", function () {
3482 new CarouselModule("#carousel_@settings.Id", {
3483 slideTime: 0,
3484 dots: true
3485 });
3486 });
3487 </script>
3488 }
3489
3490 @helper RenderArticleCarouselSlide(ArticleCarouselSlide settings)
3491 {
3492 string imageEngine = "/Admin/Public/GetImage.ashx?";
3493
3494 string defaultImage = settings.ImageSettings != null ? imageEngine : settings.Image;
3495 if (settings.ImageSettings != null)
3496 {
3497 defaultImage += settings.ImageSettings.Width != 0 ? "Width=" + settings.ImageSettings.Width + "&" : "";
3498 defaultImage += settings.ImageSettings.Height != 0 ? "Height=" + settings.ImageSettings.Height + "&" : "";
3499 defaultImage += "Crop=" + settings.ImageSettings.Crop + "&";
3500 defaultImage += "Compression=" + settings.ImageSettings.Compression + "&";
3501 defaultImage += "DoNotUpscale=" + settings.ImageSettings.DoNotUpscale.ToString() + "&";
3502 defaultImage += "FillCanvas=" + settings.ImageSettings.FillCanvas.ToString() + "&";
3503 }
3504 defaultImage += "&Image=" + settings.Image;
3505
3506 <div class="carousel__slide u-min-h300px u-flex dw-mod" style="background-size:cover; background-image:url('@defaultImage')">
3507 <a class="article-carousel-item__wrap" href="@settings.Link" title="@settings.Title">
3508 <h2 class="article-list__item-header u-truncate-text u-color-light dw-mod">@settings.Title</h2>
3509 <div class="article-list__item-info">
3510 @if (settings.Stickers != null)
3511 {
3512 settings.Stickers.Position = StickersListPosition.Custom;
3513 @Render(settings.Stickers);
3514 }
3515
3516 <small class="u-margin-top--lg u-color-light">
3517 @if (!(string.IsNullOrWhiteSpace(settings.Author) && string.IsNullOrWhiteSpace(settings.Date)))
3518 {
3519 <text>@Translate("Written")</text>
3520 }
3521 @if (!string.IsNullOrWhiteSpace(settings.Author))
3522 {
3523 <text>@Translate("by") @settings.Author</text>
3524 }
3525 @if (!string.IsNullOrWhiteSpace(settings.Date))
3526 {
3527 <text>@Translate("on") @settings.Date</text>
3528 }
3529 </small>
3530 </div>
3531
3532 <h3 class="article__short-summary u-color-light">@settings.Summary</h3>
3533 </a>
3534 @if (settings.UseFilters == true)
3535 {
3536 <div class="background-image image-filter image-filter--darken dw-mod"></div>
3537 }
3538 </div>
3539 }
3540 @using System.Text.RegularExpressions
3541 @using Dynamicweb.Rapido.Blocks.Components
3542 @using Dynamicweb.Rapido.Blocks.Components.General
3543 @using Dynamicweb.Rapido.Blocks.Components.Articles
3544 @using Dynamicweb.Rapido.Blocks
3545
3546 @* Component for the articles *@
3547
3548 @helper RenderArticleVideo(ArticleVideo settings)
3549 {
3550 if (settings.Url != null)
3551 {
3552 //getting video ID from youtube URL
3553 string videoCode = settings.Url;
3554 Regex regex = new Regex(@".be\/(.[^?]*)");
3555 Match match = regex.Match(videoCode);
3556 string videoId = "";
3557 if (match.Success)
3558 {
3559 videoId = match.Groups[1].Value;
3560 }
3561 else
3562 {
3563 regex = new Regex(@"v=([^&]+)");
3564 match = regex.Match(videoCode);
3565 if (match.Success)
3566 {
3567 videoId = match.Groups[1].Value;
3568 }
3569 }
3570
3571 int autoPlay = settings.AutoPlay == "true" ? 1 : 0;
3572
3573 <div class="video-wrapper">
3574 <div class="js-youtube-video" data-video="@videoId" id="ytPlayer@(Guid.NewGuid().ToString("N"))" data-auto-play="@autoPlay" data-enable-controls="1"></div>
3575 </div>
3576 }
3577 }
3578
3579
3580
3581 @* Simple helpers *@
3582
3583 @*Requires the Gallery ItemType that comes with Rapido*@
3584 @helper RenderArticleItemGallery(IList<ItemViewModel> gallery) {
3585 if (gallery != null && gallery.Count > 0)
3586 {
3587 int count = 1;
3588
3589 foreach (var item in gallery)
3590 {
3591 if (item.GetFile("ImagePath") != null)
3592 {
3593 string image = item.GetFile("ImagePath").PathUrlEncoded;
3594 string imagePrefix = "/Admin/Public/GetImage.ashx?width=1200&height=820&crop=5&Compression=75&DoNotUpscale=1&image=";
3595 int imagesCount = gallery.Count;
3596
3597 if (count == 1)
3598 {
3599 <label class="gallery" for="ParagraphGalleryModalTrigger" onclick="Gallery.openImage(this.querySelector('.js-gallery'))">
3600 <span class="gallery__main-image">
3601 <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" />
3602 </span>
3603 <span class="gallery__image-counter">
3604 <i class="fas fa-camera fa-2x"></i> <span class="gallery__image-counter__number">@imagesCount</span>
3605 <span class="gallery__image-counter__text">@Translate("See all") <i class="fas fa-angle-right"></i></span>
3606 </span>
3607 </label>
3608 }
3609 else
3610 {
3611 <div class="u-hidden js-gallery" data-for="ParagraphGallery" data-image="@imagePrefix@image"></div>
3612 }
3613
3614 count++;
3615 }
3616 }
3617
3618 @Render(new ArticleGalleryModal())
3619 }
3620 }
3621
3622 @helper RenderMobileFilters(List<Block> subBlocks)
3623 {
3624 if (subBlocks.Count > 0)
3625 {
3626 <div class="grid__col-12">
3627 <input type="checkbox" id="CheckFilters" class="js-remember-state u-hidden" data-expand="CheckFilters" />
3628 <div class="grid u-margin-bottom dw-mod" data-trigger="CheckFilters">
3629 @RenderBlockList(subBlocks)
3630 </div>
3631 <label for="CheckFilters" class="btn btn--secondary btn--full dw-mod js-expand-hide" data-trigger="CheckFilters">@Translate("Select filters")</label>
3632 <label for="CheckFilters" class="btn btn--secondary btn--full dw-mod expandable--collapsed" data-trigger="CheckFilters">@Translate("Close filters")</label>
3633 </div>
3634 }
3635 }
3636
3637
3638 @* Include the Blocks for the page *@
3639 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
3640
3641 @using System
3642 @using System.Web
3643 @using System.Collections.Generic
3644 @using Dynamicweb.Rapido.Blocks.Extensibility
3645 @using Dynamicweb.Rapido.Blocks
3646
3647 @functions {
3648 string GoogleTagManagerID = "";
3649 string GoogleAnalyticsID = "";
3650 }
3651
3652 @{
3653 GoogleTagManagerID = Model.Area.Item.GetItem("Settings").GetString("GoogleTagManagerID");
3654 GoogleAnalyticsID = Model.Area.Item.GetItem("Settings").GetString("GoogleAnalyticsTrackingID");
3655
3656 BlocksPage topSnippetsBlocksPage = BlocksPage.GetBlockPage("Master");
3657
3658 if (!string.IsNullOrWhiteSpace(GoogleAnalyticsID))
3659 {
3660 Block tagManager = new Block()
3661 {
3662 Id = "GoogleAnalytics",
3663 SortId = 0,
3664 Template = RenderGoogleAnalyticsSnippet()
3665 };
3666 topSnippetsBlocksPage.Add("Head", tagManager);
3667 }
3668
3669 if (!string.IsNullOrWhiteSpace(GoogleTagManagerID))
3670 {
3671 Block tagManager = new Block()
3672 {
3673 Id = "TagManager",
3674 SortId = 1,
3675 Template = RenderGoogleTagManager()
3676 };
3677 topSnippetsBlocksPage.Add("Head", tagManager);
3678
3679 Block tagManagerBodySnippet = new Block()
3680 {
3681 Id = "TagManagerBodySnippet",
3682 SortId = 1,
3683 Template = RenderGoogleTagManagerBodySnippet()
3684 };
3685 topSnippetsBlocksPage.Add(MasterBlockId.MasterTopSnippets, tagManagerBodySnippet);
3686 }
3687
3688 Block cookieBot = new Block()
3689 {
3690 Id = "Cookiebot",
3691 SortId = 2,
3692 Template = RenderCookiebot()
3693 };
3694 // Disabled manual Cookiebot-script, in order to inject via Google Tag Manager instead
3695 //topSnippetsBlocksPage.Add("Head", cookieBot);
3696
3697
3698 Block facebookPixel = new Block()
3699 {
3700 Id = "FacebookPixel",
3701 SortId = 2,
3702 Template = RenderFacebookPixel()
3703 };
3704
3705 topSnippetsBlocksPage.Add(MasterBlockId.MasterTopSnippets, facebookPixel);
3706 }
3707
3708
3709 @helper RenderCookiebot()
3710 {
3711 <script id="Cookiebot" src="https://consent.cookiebot.com/uc.js" data-cbid="0632c387-a46f-4658-9a7e-1e5ace6538a8" data-blockingmode="auto" type="text/javascript"></script>
3712 }
3713
3714 @helper RenderGoogleAnalyticsSnippet()
3715 {
3716 <!-- Global site tag (gtag.js) - Google Analytics -->
3717 <script async src="https://www.googletagmanager.com/gtag/js?id=@GoogleAnalyticsID"></script>
3718 <script>
3719 window.dataLayer = window.dataLayer || [];
3720 function gtag(){dataLayer.push(arguments);}
3721 gtag('js', new Date());
3722
3723 gtag('config', '@GoogleAnalyticsID');
3724 </script>
3725
3726 }
3727
3728 @helper RenderGoogleTagManager()
3729 {
3730 <script data-cookieconsent="ignore">
3731 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
3732 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
3733 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
3734 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
3735 })(window,document,'script','dataLayer','@GoogleTagManagerID');
3736 </script>
3737 }
3738
3739 @helper RenderGoogleTagManagerBodySnippet()
3740 {
3741 <!-- Google Tag Manager (noscript) -->
3742 <noscript>
3743 <iframe src="https://www.googletagmanager.com/ns.html?id=@GoogleTagManagerID"
3744 height="0" width="0" style="display:none;visibility:hidden"></iframe>
3745 </noscript>
3746 <!-- End Google Tag Manager (noscript) -->
3747 }
3748
3749 @helper RenderFacebookPixel()
3750 {
3751 string FacebookPixelID = Model.Area.Item.GetItem("Settings").GetString("FacebookPixelID");
3752
3753 if (!string.IsNullOrWhiteSpace(FacebookPixelID))
3754 {
3755 <!-- Facebook Pixel Code -->
3756 <script>
3757 window.addEventListener('CookiebotOnAccept', function(e) {
3758 if (Cookiebot.consent.marketing) {
3759 !function(f, b, e, v, n, t, s) {
3760 if (f.fbq) return;
3761 n = f.fbq = function() { n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments) };
3762 if (!f._fbq) f._fbq = n;
3763 n.push = n;
3764 n.loaded = !0;
3765 n.version = '2.0';
3766 n.queue = [];
3767 t = b.createElement(e);
3768 t.async = !0;
3769 t.src = v;
3770 s = b.getElementsByTagName(e)[0];
3771 s.parentNode.insertBefore(t, s)
3772 }(window,
3773 document,
3774 'script',
3775 'https://connect.facebook.net/en_US/fbevents.js');
3776 fbq('init', '@FacebookPixelID');
3777 fbq('track', 'PageView');
3778 }
3779 })
3780 </script>
3781 <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=@FacebookPixelID&ev=PageView&noscript=1" alt="" /></noscript>
3782 }
3783 }
3784 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
3785
3786 @using System
3787 @using System.Web
3788 @using System.Collections.Generic
3789 @using Dynamicweb.Rapido.Blocks
3790 @using Dynamicweb.Rapido.Blocks.Extensibility
3791 @using Dynamicweb.Security.UserManagement
3792 @using Dynamicweb.Security.UserManagement.ExternalAuthentication
3793 @using Dynamicweb.Rapido.Blocks.Components.General
3794
3795 @{
3796 BlocksPage loginBlocksPage = BlocksPage.GetBlockPage("Master");
3797
3798 Block loginModal = new Block()
3799 {
3800 Id = "LoginModal",
3801 SortId = 10,
3802 Component = new Modal
3803 {
3804 Id = "SignIn",
3805 Heading = new Heading
3806 {
3807 Level = 0,
3808 Title = Translate("Sign in")
3809 },
3810 Width = ModalWidth.Sm,
3811 BodyTemplate = RenderLoginForm()
3812 }
3813 };
3814
3815 loginBlocksPage.Add(MasterBlockId.MasterTopSnippets, loginModal);
3816 }
3817
3818 @helper RenderLoginForm()
3819 {
3820 int pageId = Model.TopPage.ID;
3821 string userSignedInErrorText = "";
3822 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
3823 string forgotPasswordPageLink = "/Default.aspx?ID=" + signInProfilePageId + "&LoginAction=Recovery";
3824 int createAccountPageId = GetPageIdByNavigationTag("CreateAccount");
3825 bool showModalOnStart = pageId != GetPageIdByNavigationTag("CustomerCenter") && Pageview.Page.ID != GetPageIdByNavigationTag("SignInPage") && Model.LogOnFailed;
3826 bool hideCreateAccountLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideCreateAccount");
3827 bool hideForgotPasswordLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideForgotPasswordLink");
3828
3829 ProviderCollection providers = Provider.GetActiveProviders();
3830
3831 if (Model.LogOnFailed)
3832 {
3833 switch (Model.LogOnFailedReason)
3834 {
3835 case LogOnFailedReason.PasswordLengthInvalid:
3836 userSignedInErrorText = Translate("Password length is invalid");
3837 break;
3838 case LogOnFailedReason.IncorrectLogin:
3839 userSignedInErrorText = Translate("Invalid email or password");
3840 break;
3841 case LogOnFailedReason.ExceededFailedLogOnLimit:
3842 userSignedInErrorText = Translate("You have exceeded the limit of allowed login attempts. The user account is temporarily locked");
3843 break;
3844 case LogOnFailedReason.LoginLocked:
3845 userSignedInErrorText = Translate("The user account is temporarily locked");
3846 break;
3847 case LogOnFailedReason.PasswordExpired:
3848 userSignedInErrorText = Translate("The password has expired and needs to be renewed");
3849 break;
3850 default:
3851 userSignedInErrorText = Translate("An unknown error occured");
3852 break;
3853 }
3854 }
3855
3856 Form form = new Form { Method = FormMethod.Post, Name = "LoginModalForm" };
3857
3858 TextField passwordField = new TextField { Id = "login-password", Type = TextFieldType.Password, Name = "password", Label = Translate("Password"), Required = true };
3859
3860 if (!hideForgotPasswordLink) {
3861 passwordField.Link = new Link { Title = Translate("Forgot password?"), Href = "/Default.aspx?id=" + signInProfilePageId + "&LoginAction=Recovery" };
3862 }
3863
3864 form.Add(new HiddenField { Name = "ID", Value = Converter.ToString(pageId) });
3865 form.Add(new HiddenField { Name = "DWExtranetUsernameRemember", Value = "True" });
3866 form.Add(new HiddenField { Name = "DWExtranetPasswordRemember", Value = "True" });
3867 form.Add(new HiddenField { Name = "LoginAction", Value = "Login" });
3868 form.Add(new TextField { Id = "LoginUsername", Name = "username", Label = Translate("Email"), CssClass = "u-full-width", Required = true });
3869 form.Add(passwordField);
3870 form.Add(new NotificationMessage { Message = userSignedInErrorText, MessageType = NotificationMessageType.Error });
3871 form.Add(new CheckboxField { Id = "LoginRememberMe", Value = "True", Name = "Autologin", Label = Translate("Remember me") });
3872 form.Add(new Button { ButtonType = ButtonType.Submit, Title = Translate("Sign in"), CssClass = "btn--full", OnClick = "Buttons.LockButton(event)" });
3873
3874 foreach (Provider LoginProvider in providers)
3875 {
3876 var ProviderName = LoginProvider.Name.ToLower();
3877 form.Add(new Link {
3878 Href = "/Admin/Public/Social/ExternalLogin.aspx?action=login&providerID=" + LoginProvider.ID,
3879 Icon = new Icon { Prefix = "fab", Name = "fa-" + ProviderName, CssClass = "fa-1_5x", LabelPosition = IconLabelPosition.After },
3880 ButtonLayout = ButtonLayout.LinkClean,
3881 CssClass = "btn--condensed u-margin-bottom u-margin-right u-inline-block u-color-" + ProviderName,
3882 AltText = ProviderName
3883 });
3884 }
3885
3886 if (!hideCreateAccountLink) {
3887 form.Add(new Text { Content = "<div class=\"u-border-top u-full-width u-margin-bottom--lg\"></div>" });
3888 form.Add(new Link
3889 {
3890 Href = "/Default.aspx?id=" + createAccountPageId,
3891 ButtonLayout = ButtonLayout.LinkClean,
3892 Title = Translate("Create account"),
3893 CssClass = "u-full-width u-ta-center"
3894 });
3895 }
3896
3897 @Render(form)
3898
3899 if (showModalOnStart)
3900 {
3901 <script>
3902 document.getElementById("SignInModalTrigger").checked = true;
3903 </script>
3904 }
3905 }
3906
3907
3908
3909
3910
3911 @if (Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet")
3912 {
3913 <text>@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
3914
3915 @using System
3916 @using System.Web
3917 @using System.Collections.Generic
3918 @using Dynamicweb.Rapido.Blocks.Extensibility
3919 @using Dynamicweb.Rapido.Blocks
3920 @using Dynamicweb.Rapido.Services
3921
3922
3923 @functions {
3924 BlocksPage mobileHeaderBlocksPage = BlocksPage.GetBlockPage("Master");
3925 }
3926
3927 @{
3928 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";
3929 bool mobileHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch");
3930 bool mobileHideCart = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart") || !Dynamicweb.Rapido.Services.User.IsBuyingAllowed();
3931
3932 Block mobileHeader = new Block()
3933 {
3934 Id = "MobileTop",
3935 SortId = 10,
3936 Template = RenderMobileTop(),
3937 SkipRenderBlocksList = true
3938 };
3939 mobileHeaderBlocksPage.Add(MasterBlockId.MasterHeader, mobileHeader);
3940
3941 Block mobileHeaderNavigation = new Block()
3942 {
3943 Id = "MobileHeaderNavigation",
3944 SortId = 10,
3945 Template = RenderMobileHeaderNavigation(),
3946 SkipRenderBlocksList = true,
3947 BlocksList = new List<Block> {
3948 new Block {
3949 Id = "MobileHeaderNavigationTrigger",
3950 SortId = 10,
3951 Template = RenderMobileHeaderNavigationTrigger()
3952 }
3953 }
3954 };
3955 mobileHeaderBlocksPage.Add("MobileTop", mobileHeaderNavigation);
3956
3957 Block mobileHeaderLogo = new Block()
3958 {
3959 Id = "MobileHeaderLogo",
3960 SortId = 20,
3961 Template = RenderMobileHeaderLogo(),
3962 SkipRenderBlocksList = true
3963 };
3964 mobileHeaderBlocksPage.Add("MobileTop", mobileHeaderLogo);
3965
3966 Block mobileHeaderActions = new Block()
3967 {
3968 Id = "MobileHeaderActions",
3969 SortId = 30,
3970 Template = RenderMobileTopActions(),
3971 SkipRenderBlocksList = true
3972 };
3973 mobileHeaderBlocksPage.Add("MobileTop", mobileHeaderActions);
3974
3975 if (!mobileHideSearch)
3976 {
3977 Block mobileHeaderSearch = new Block
3978 {
3979 Id = "MobileHeaderSearch",
3980 SortId = 10,
3981 Template = RenderMobileTopSearch()
3982 };
3983 mobileHeaderBlocksPage.Add("MobileHeaderActions", mobileHeaderSearch);
3984 }
3985
3986 Block mobileHeaderMiniCart;
3987
3988 if (!mobileHideCart)
3989 {
3990 mobileHeaderMiniCart = new Block
3991 {
3992 Id = "MobileHeaderMiniCart",
3993 SortId = 20,
3994 Template = RenderMobileTopMiniCart()
3995 };
3996
3997 Block miniCartCounterScriptTemplate = new Block
3998 {
3999 Id = "MiniCartCounterScriptTemplate",
4000 Template = RenderMobileMiniCartCounterContent()
4001 };
4002 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", miniCartCounterScriptTemplate);
4003 }
4004 else
4005 {
4006 mobileHeaderMiniCart = new Block
4007 {
4008 Id = "MobileHeaderMiniCart",
4009 SortId = 20
4010 };
4011 }
4012
4013 if (!mobileHideSearch)
4014 {
4015 Block mobileHeaderSearchBar = new Block()
4016 {
4017 Id = "MobileHeaderSearchBar",
4018 SortId = 30,
4019 Template = RenderMobileTopSearchBar()
4020 };
4021 mobileHeaderBlocksPage.Add(MasterBlockId.MasterHeader, mobileHeaderSearchBar);
4022 }
4023
4024 switch (mobileTopLayout)
4025 {
4026 case "nav-left":
4027 mobileHeaderNavigation.SortId = 10;
4028 mobileHeaderLogo.SortId = 20;
4029 mobileHeaderActions.SortId = 30;
4030 mobileHeaderBlocksPage.Add("MobileHeaderActions", mobileHeaderMiniCart);
4031 break;
4032 case "nav-right":
4033 mobileHeaderLogo.SortId = 10;
4034 mobileHeaderActions.SortId = 20;
4035 mobileHeaderNavigation.SortId = 30;
4036 mobileHeaderBlocksPage.Add("MobileHeaderActions", mobileHeaderMiniCart);
4037 break;
4038 case "nav-search-left":
4039 mobileHeaderNavigation.SortId = 10;
4040 mobileHeaderLogo.SortId = 20;
4041 mobileHeaderActions.SortId = 30;
4042 mobileHeaderBlocksPage.Add("MobileHeaderNavigation", mobileHeaderMiniCart);
4043 break;
4044 case "search-left":
4045 mobileHeaderActions.SortId = 10;
4046 mobileHeaderLogo.SortId = 20;
4047 mobileHeaderNavigation.SortId = 30;
4048 mobileHeaderMiniCart.SortId = 0;
4049 mobileHeaderBlocksPage.Add("MobileHeaderNavigation", mobileHeaderMiniCart);
4050 break;
4051 }
4052 }
4053
4054
4055 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4056
4057 @using System
4058 @using System.Web
4059 @using Dynamicweb.Rapido.Blocks.Extensibility
4060 @using Dynamicweb.Rapido.Blocks
4061
4062 @{
4063 BlocksPage customMobileHeaderBlocksPage = BlocksPage.GetBlockPage("Master");
4064 }
4065
4066
4067 @helper RenderMobileTop()
4068 {
4069 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileTop").OrderBy(item => item.SortId).ToList();
4070
4071 <nav class="main-navigation-mobile dw-mod">
4072 <div class="center-container top-container__center-container dw-mod">
4073 <div class="grid grid--align-center">
4074 @RenderBlockList(subBlocks)
4075 </div>
4076 </div>
4077 </nav>
4078 }
4079
4080 @helper RenderMobileHeaderNavigation()
4081 {
4082 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileHeaderNavigation").OrderBy(item => item.SortId).ToList();
4083
4084 <div class="grid__col-auto-width">
4085 <ul class="menu dw-mod">
4086 @RenderBlockList(subBlocks)
4087 </ul>
4088 </div>
4089 }
4090
4091 @helper RenderMobileHeaderNavigationTrigger()
4092 {
4093 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod">
4094 <label for="MobileNavTrigger" class="mobile-nav-trigger-button menu__link menu__link--icon menu__link--mobile dw-mod"></label>
4095 </li>
4096 }
4097
4098 @helper RenderMobileHeaderLogo()
4099 {
4100 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileHeaderLogo").OrderBy(item => item.SortId).ToList();
4101
4102 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";
4103 string centeredLogo = mobileTopLayout != "nav-right" ? "u-ta-center" : "";
4104 string firstPageId = Model.Area.FirstActivePage.ID.ToString();
4105 string businessName = Model.Area.Item.GetItem("Settings").GetString("BusinessName");
4106
4107 string mobileLogo = "/Files/Images/logo-dynamicweb.png";
4108 if (Model.Area.Item.GetItem("Layout").GetItem("MobileTop") != null && Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetFile("Logo") != null)
4109 {
4110 mobileLogo = Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetFile("Logo").PathUrlEncoded;
4111 }
4112
4113 if (Path.GetExtension(mobileLogo).ToLower() != ".svg")
4114 {
4115 mobileLogo = "/Admin/Public/GetImage.ashx?height=40&width=100&crop=5&Compression=75&image=" + mobileLogo;
4116 }
4117 else
4118 {
4119 mobileLogo = HttpUtility.UrlDecode(mobileLogo);
4120 }
4121
4122 <div class="grid__col-auto grid__col--bleed">
4123 <div class="grid__cell @centeredLogo">
4124 <a href="/Default.aspx?ID=@firstPageId" class="logo logo--mobile u-inline-block dw-mod">
4125 <img class="grid__cell-img logo__img logo__img--mobile dw-mod" src="@mobileLogo" alt="@businessName" />
4126 </a>
4127 </div>
4128
4129 @RenderBlockList(subBlocks)
4130 </div>
4131 }
4132
4133 @helper RenderMobileTopActions()
4134 {
4135 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileHeaderActions").OrderBy(item => item.SortId).ToList();
4136
4137 <div class="grid__col-auto-width">
4138 <ul class="menu dw-mod">
4139 @RenderBlockList(subBlocks)
4140 </ul>
4141 </div>
4142 }
4143
4144 @helper RenderMobileTopSearch()
4145 {
4146 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod">
4147 <label for="MobileSearchTrigger" class="menu__link menu__link--icon menu__link--mobile dw-mod">
4148 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue fa-1_5x"></i>
4149 </label>
4150 </li>
4151 }
4152
4153 @helper RenderMobileTopMiniCart()
4154 {
4155 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
4156 int cartPageId = GetPageIdByNavigationTag("CartPage");
4157 double cartProductsCount = Model.Cart.TotalProductsCount;
4158
4159 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod" id="miniCartWrapper">
4160 <div class="mini-cart dw-mod">
4161 <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">
4162 <div class="u-inline u-position-relative">
4163 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue fa-1_5x"></i>
4164 <div class="mini-cart__counter dw-mod">
4165 <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">
4166 <div class="js-mini-cart-counter-content" data-count="@cartProductsCount">
4167 @cartProductsCount
4168 </div>
4169 </div>
4170 </div>
4171 </div>
4172 </a>
4173 </div>
4174 </li>
4175 }
4176
4177 @helper RenderMobileTopSearchBar()
4178 {
4179 string searchFeedId = "";
4180 string searchSecondFeedId = "";
4181 int groupsFeedId;
4182 int productsPageId = GetPageIdByNavigationTag("ProductsPage");
4183 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID;
4184 string resultPageLink;
4185 string searchPlaceholder;
4186 string searchType = "product-search";
4187 string searchTemplate;
4188 string searchContentTemplate = "";
4189 string searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? "";
4190 bool showGroups = true;
4191
4192 if (Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue == "contentSearch")
4193 {
4194 searchFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true";
4195 resultPageLink = contentSearchPageLink;
4196 searchPlaceholder = Translate("Search page");
4197 groupsFeedId = 0;
4198 searchType = "content-search";
4199 searchTemplate = "SearchPagesTemplate";
4200 showGroups = false;
4201 }
4202 else if (Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue == "combinedSearch")
4203 {
4204 searchFeedId = productsPageId + "&feed=true";
4205 searchSecondFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true";
4206 resultPageLink = Converter.ToString(productsPageId);
4207 searchPlaceholder = Translate("Search products or pages");
4208 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed");
4209 searchType = "combined-search";
4210 searchTemplate = "SearchProductsTemplateWrap";
4211 searchContentTemplate = "SearchPagesTemplateWrap";
4212 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector");
4213 }
4214 else
4215 {
4216 resultPageLink = Converter.ToString(productsPageId);
4217 searchFeedId = productsPageId + "&feed=true";
4218 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed");
4219 searchPlaceholder = Translate("Search products");
4220 searchTemplate = "SearchProductsTemplate";
4221 searchType = "product-search";
4222 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector");
4223 }
4224
4225 <input type="checkbox" id="MobileSearchTrigger" class="mobile-search-trigger" />
4226
4227 <div class="main-navigation-mobile typeahead-mobile dw-mod">
4228 <div class="center-container top-container__center-container dw-mod">
4229 <div class="grid">
4230 <div class="grid__col-auto">
4231 <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">
4232 <input type="text" class="js-typeahead-search-field u-w160px u-no-margin" placeholder="@searchPlaceholder" value="@searchValue">
4233 @if (string.IsNullOrEmpty(searchSecondFeedId))
4234 {
4235 <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>
4236 }
4237 else
4238 {
4239 <div class="dropdown dropdown--absolute-position dropdown--combined grid dropdown--combined-mobile grid">
4240 <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>
4241 <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>
4242 </div>
4243 }
4244 <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>
4245 </div>
4246 </div>
4247 <div class="grid__col-auto-width">
4248 <ul class="menu dw-mod">
4249 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod">
4250 <label for="MobileSearchTrigger" class="menu__link menu__link--icon menu__link--mobile dw-mod">
4251 <i class="fas fa-times fa-1_5x"></i>
4252 </label>
4253 </li>
4254 </ul>
4255 </div>
4256 </div>
4257 </div>
4258 </div>
4259 }
4260
4261 @helper RenderMobileMiniCartCounterContent()
4262 {
4263 <script id="MiniCartCounterContent" type="text/x-template">
4264 {{#.}}
4265 <div class="js-mini-cart-counter-content dw-mod" data-count="{{numberofproducts}}">
4266 {{numberofproducts}}
4267 </div>
4268 {{/.}}
4269 </script>
4270 }
4271 </text>
4272 <text>@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4273
4274 @using System
4275 @using System.Web
4276 @using System.Collections.Generic
4277 @using Dynamicweb.Rapido.Blocks.Extensibility
4278 @using Dynamicweb.Rapido.Blocks
4279
4280 @functions {
4281 BlocksPage mobileNavigationBlocksPage = BlocksPage.GetBlockPage("Master");
4282 }
4283
4284 @{
4285 bool mobileNavigationItemsHideSignIn = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSignIn");
4286 bool mobileHideCreateAccountLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideCreateAccount");
4287 bool mobileHideMyProfileLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideProfile");
4288 bool mobileHideMyOrdersLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideOrders");
4289 bool mobileHideMySavedCardsLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideSavedCards");
4290 bool mobileHideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideFavorites");
4291
4292 Block mobileNavigation = new Block()
4293 {
4294 Id = "MobileNavigation",
4295 SortId = 10,
4296 Template = MobileNavigation(),
4297 SkipRenderBlocksList = true
4298 };
4299 mobileNavigationBlocksPage.Add(MasterBlockId.MasterTopSnippets, mobileNavigation);
4300
4301 if (Model.CurrentUser.ID > 0 && !mobileHideMyProfileLink)
4302 {
4303 Block mobileNavigationSignIn = new Block
4304 {
4305 Id = "MobileNavigationSignIn",
4306 SortId = 10,
4307 Template = RenderMobileNavigationSignIn()
4308 };
4309 mobileNavigationBlocksPage.Add("MobileNavigation", mobileNavigationSignIn);
4310 }
4311
4312 Block mobileNavigationMenu = new Block
4313 {
4314 Id = "MobileNavigationMenu",
4315 SortId = 20,
4316 Template = RenderMobileNavigationMenu()
4317 };
4318 mobileNavigationBlocksPage.Add("MobileNavigation", mobileNavigationMenu);
4319
4320 Block mobileNavigationActions = new Block
4321 {
4322 Id = "MobileNavigationActions",
4323 SortId = 30,
4324 Template = RenderMobileNavigationActions(),
4325 SkipRenderBlocksList = true
4326 };
4327 mobileNavigationBlocksPage.Add("MobileNavigation", mobileNavigationActions);
4328
4329 if (!mobileNavigationItemsHideSignIn)
4330 {
4331 if (Model.CurrentUser.ID <= 0)
4332 {
4333 Block mobileNavigationSignInAction = new Block
4334 {
4335 Id = "MobileNavigationSignInAction",
4336 SortId = 10,
4337 Template = RenderMobileNavigationSignInAction()
4338 };
4339 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationSignInAction);
4340
4341 if (!mobileHideCreateAccountLink)
4342 {
4343 Block mobileNavigationCreateAccountAction = new Block
4344 {
4345 Id = "MobileNavigationCreateAccountAction",
4346 SortId = 20,
4347 Template = RenderMobileNavigationCreateAccountAction()
4348 };
4349 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationCreateAccountAction);
4350 }
4351 }
4352 else
4353 {
4354 if (!mobileHideMyOrdersLink)
4355 {
4356 Block mobileNavigationOrdersAction = new Block
4357 {
4358 Id = "MobileNavigationOrdersAction",
4359 SortId = 20,
4360 Template = RenderMobileNavigationOrdersAction()
4361 };
4362 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationOrdersAction);
4363 }
4364 if (!mobileHideMyFavoritesLink)
4365 {
4366 Block mobileNavigationFavoritesAction = new Block
4367 {
4368 Id = "MobileNavigationFavoritesAction",
4369 SortId = 30,
4370 Template = RenderMobileNavigationFavoritesAction()
4371 };
4372 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationFavoritesAction);
4373 }
4374 if (!mobileHideMySavedCardsLink)
4375 {
4376 Block mobileNavigationSavedCardsAction = new Block
4377 {
4378 Id = "MobileNavigationFavoritesAction",
4379 SortId = 30,
4380 Template = RenderMobileNavigationSavedCardsAction()
4381 };
4382 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationSavedCardsAction);
4383 }
4384
4385 Block mobileNavigationSignOutAction = new Block
4386 {
4387 Id = "MobileNavigationSignOutAction",
4388 SortId = 40,
4389 Template = RenderMobileNavigationSignOutAction()
4390 };
4391 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationSignOutAction);
4392 }
4393 }
4394
4395 if (Model.Languages.Count > 1)
4396 {
4397 Block mobileNavigationLanguagesAction = new Block
4398 {
4399 Id = "MobileNavigationLanguagesAction",
4400 SortId = 50,
4401 Template = RenderMobileNavigationLanguagesAction()
4402 };
4403 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationLanguagesAction);
4404 }
4405 }
4406
4407
4408 @helper MobileNavigation()
4409 {
4410 List<Block> subBlocks = this.mobileNavigationBlocksPage.GetBlockListById("MobileNavigation").OrderBy(item => item.SortId).ToList();
4411 string mobileTopDesign = Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetList("Design") != null ? Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetList("Design").SelectedValue : "nav-left";
4412 string position = mobileTopDesign == "nav-left" || mobileTopDesign == "nav-search-left" ? "left" : "right";
4413
4414 <!-- Trigger for mobile navigation -->
4415 <input type="checkbox" id="MobileNavTrigger" class="mobile-nav-trigger mobile-nav-trigger--@position" autocomplete="off" />
4416
4417 <!-- Mobile navigation -->
4418 <nav class="mobile-navigation mobile-navigation--@position dw-mod">
4419 <div class="mobile-navigation__wrapper" id="mobileNavigationWrapper">
4420 @RenderBlockList(subBlocks)
4421 </div>
4422 </nav>
4423
4424 <label class="mobile-nav-trigger-off" for="MobileNavTrigger"></label>
4425 }
4426
4427 @helper RenderMobileNavigationSignIn()
4428 {
4429 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
4430 int myProfilePageId = GetPageIdByNavigationTag("CustomerProfile");
4431 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID=";
4432 string myProfilePageLink = linkStart + myProfilePageId;
4433 string userName = Model.CurrentUser.FirstName;
4434 if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(Model.CurrentUser.LastName))
4435 {
4436 userName += " " + Model.CurrentUser.LastName;
4437 }
4438 if (string.IsNullOrEmpty(userName))
4439 {
4440 userName = Model.CurrentUser.Name;
4441 }
4442 if (string.IsNullOrEmpty(userName))
4443 {
4444 userName = Model.CurrentUser.UserName;
4445 }
4446 if (string.IsNullOrEmpty(userName))
4447 {
4448 userName = Model.CurrentUser.Email;
4449 }
4450
4451 <ul class="menu menu-mobile">
4452 <li class="menu-mobile__item">
4453 <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>
4454 </li>
4455 </ul>
4456 }
4457
4458 @helper RenderMobileNavigationMenu()
4459 {
4460 bool isSlidesDesign = Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetList("Design").SelectedValue == "Slides";
4461 string menuTemplate = isSlidesDesign ? "BaseMenuForMobileSlides.xslt" : "BaseMenuForMobileExpandable.xslt";
4462 string levels = !String.IsNullOrEmpty(Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetString("Levels")) ? Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetString("Levels") : "3";
4463 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar");
4464 /* Custom */
4465 int startLevel = renderPagesInToolBar ? 1 : 0;
4466
4467 @RenderNavigation(new
4468 {
4469 id = "mobilenavigation",
4470 cssclass = "menu menu-mobile dwnavigation",
4471 startLevel = @startLevel,
4472 ecomStartLevel = @startLevel + 1,
4473 endlevel = @levels,
4474 expandmode = "all",
4475 template = @menuTemplate
4476 })
4477
4478 if (isSlidesDesign)
4479 {
4480 <script>
4481 function goToLevel(level) {
4482 document.getElementById('mobileNavigationWrapper').style.left = -(level * 100) + "%";
4483 }
4484
4485 document.addEventListener('DOMContentLoaded', function () {
4486 goToLevel(document.getElementById('mobileNavigationWrapper').querySelectorAll('input[type=radio]:checked').length);
4487 });
4488 </script>
4489 }
4490
4491 if (renderPagesInToolBar)
4492 {
4493 @RenderNavigation(new
4494 {
4495 id = "topToolsMobileNavigation",
4496 cssclass = "menu menu-mobile dwnavigation",
4497 template = "ToolsMenuForMobile.xslt"
4498 })
4499 }
4500 }
4501
4502 @helper RenderMobileNavigationActions()
4503 {
4504 List<Block> subBlocks = this.mobileNavigationBlocksPage.GetBlockListById("MobileNavigationActions").OrderBy(item => item.SortId).ToList(); ;
4505
4506 <ul class="menu menu-mobile">
4507 @RenderBlockList(subBlocks)
4508 </ul>
4509 }
4510
4511 @helper RenderMobileNavigationSignInAction()
4512 {
4513 <li class="menu-mobile__item">
4514 <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>
4515 </li>
4516 }
4517
4518 @helper RenderMobileNavigationCreateAccountAction()
4519 {
4520 int createAccountPageId = GetPageIdByNavigationTag("CreateAccount");
4521
4522 <li class="menu-mobile__item">
4523 <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>
4524 </li>
4525 }
4526
4527 @helper RenderMobileNavigationProfileAction()
4528 {
4529 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
4530 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID=";
4531 int myProfilePageId = GetPageIdByNavigationTag("CustomerProfile");
4532 string myProfilePageLink = linkStart + myProfilePageId;
4533
4534 <li class="menu-mobile__item">
4535 <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>
4536 </li>
4537 }
4538
4539 @helper RenderMobileNavigationOrdersAction()
4540 {
4541 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
4542 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID=";
4543 int myOrdersPageId = GetPageIdByNavigationTag("CustomerOrders");
4544 string myOrdersPageLink = linkStart + myOrdersPageId;
4545 string ordersIcon = "fas fa-list";
4546
4547 <li class="menu-mobile__item">
4548 <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>
4549 </li>
4550 }
4551
4552 @helper RenderMobileNavigationFavoritesAction()
4553 {
4554 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
4555 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID=";
4556 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites");
4557 string myFavoritesPageLink = linkStart + myFavoritesPageId;
4558 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";
4559
4560
4561 <li class="menu-mobile__item">
4562 <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>
4563 </li>
4564 }
4565
4566 @helper RenderMobileNavigationSavedCardsAction()
4567 {
4568 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
4569 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID=";
4570 int mySavedCardsPageId = GetPageIdByNavigationTag("SavedCards");
4571 string mySavedCardsPageLink = linkStart + mySavedCardsPageId;
4572 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";
4573
4574 <li class="menu-mobile__item">
4575 <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>
4576 </li>
4577 }
4578
4579 @helper RenderMobileNavigationSignOutAction()
4580 {
4581 int pageId = Model.TopPage.ID;
4582 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";
4583
4584 <li class="menu-mobile__item">
4585 <a class="menu-mobile__link menu-mobile__link--highlighted dw-mod" href="/Admin/Public/ExtranetLogoff.aspx?ID=@pageId" onclick="RememberState.SetCookie('useAnotherAddress', false)"><i class="@signOutIcon menu-mobile__link-icon"></i> @Translate("Sign out")</a>
4586 </li>
4587 }
4588
4589 @helper RenderMobileNavigationLanguagesAction()
4590 {
4591 bool isSlidesDesign = Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetList("Design").SelectedValue == "Slides";
4592
4593 string selectedLanguage = "";
4594 foreach (var lang in Model.Languages)
4595 {
4596 if (lang.IsCurrent)
4597 {
4598 selectedLanguage = lang.Name;
4599 }
4600 }
4601
4602 <li class="menu-mobile__item dw-mod">
4603 @if (isSlidesDesign)
4604 {
4605 <input id="MobileMenuCheck_Language" type="radio" class="expand-trigger" name="mobile-menu-level-1" onclick="goToLevel(1);">
4606 }
4607 else
4608 {
4609 <input id="MobileMenuCheck_Language" type="checkbox" class="expand-trigger">
4610 }
4611 <div class="menu-mobile__link__wrap">
4612 <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>
4613 <label for="MobileMenuCheck_Language" class="menu-mobile__trigger"></label>
4614 </div>
4615 <ul class="menu-mobile menu-mobile__submenu expand-menu">
4616 @if (isSlidesDesign)
4617 {
4618 <li class="menu-mobile__item dw-mod">
4619 <div class="menu-mobile__link__wrap">
4620 <input id="MobileMenuCheck_Language_back" type="radio" class="expand-trigger" name="mobile-menu-level-1" onclick="goToLevel(0);" />
4621 <label for="MobileMenuCheck_Language_back" class="menu-mobile__trigger menu-mobile__trigger--back"></label>
4622 <label for="MobileMenuCheck_Language_back" class="menu-mobile__link dw-mod ">@Translate("Back")</label>
4623 </div>
4624 </li>
4625 }
4626 @foreach (var lang in Model.Languages)
4627 {
4628 <li class="menu-mobile__item dw-mod">
4629 <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>
4630 </li>
4631 }
4632 </ul>
4633 </li>
4634 }</text>
4635 }
4636 else
4637 {
4638 <text>@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4639
4640 @using System
4641 @using System.Web
4642 @using System.Collections.Generic
4643 @using Dynamicweb.Rapido.Blocks.Extensibility
4644 @using Dynamicweb.Rapido.Blocks
4645
4646 @functions {
4647 BlocksPage headerBlocksPage = BlocksPage.GetBlockPage("Master");
4648 }
4649
4650 @{
4651 Block masterTools = new Block()
4652 {
4653 Id = "MasterDesktopTools",
4654 SortId = 10,
4655 Template = RenderDesktopTools(),
4656 SkipRenderBlocksList = true,
4657 BlocksList = new List<Block>
4658 {
4659 new Block {
4660 Id = "MasterDesktopToolsText",
4661 SortId = 10,
4662 Template = RenderDesktopToolsText(),
4663 Design = new Design
4664 {
4665 Size = "auto",
4666 HidePadding = true,
4667 RenderType = RenderType.Column
4668 }
4669 },
4670 new Block {
4671 Id = "MasterDesktopToolsNavigation",
4672 SortId = 20,
4673 Template = RenderDesktopToolsNavigation(),
4674 Design = new Design
4675 {
4676 Size = "auto-width",
4677 HidePadding = true,
4678 RenderType = RenderType.Column
4679 }
4680 }
4681 }
4682 };
4683 headerBlocksPage.Add("MasterHeader", masterTools);
4684
4685 Block masterDesktopExtra = new Block()
4686 {
4687 Id = "MasterDesktopExtra",
4688 SortId = 10,
4689 Template = RenderDesktopExtra(),
4690 SkipRenderBlocksList = true
4691 };
4692 headerBlocksPage.Add("MasterHeader", masterDesktopExtra);
4693
4694 Block masterDesktopNavigation = new Block()
4695 {
4696 Id = "MasterDesktopNavigation",
4697 SortId = 20,
4698 Template = RenderDesktopNavigation(),
4699 SkipRenderBlocksList = true
4700 };
4701 headerBlocksPage.Add("MasterHeader", masterDesktopNavigation);
4702 }
4703
4704 @* Include the Blocks for the page *@
4705 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4706
4707 @using System
4708 @using System.Web
4709 @using Dynamicweb.Rapido.Blocks.Extensibility
4710 @using Dynamicweb.Rapido.Blocks
4711
4712 @{
4713 Block masterDesktopLogo = new Block
4714 {
4715 Id = "MasterDesktopLogo",
4716 SortId = 10,
4717 Template = RenderDesktopLogo(),
4718 Design = new Design
4719 {
4720 Size = "auto-width",
4721 HidePadding = true,
4722 RenderType = RenderType.Column,
4723 CssClass = "grid--align-self-center"
4724 }
4725 };
4726
4727 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopLogo);
4728 }
4729
4730
4731 @helper RenderDesktopLogo()
4732 {
4733 string firstPageId = Model.Area.FirstActivePage.ID.ToString();
4734 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
4735 string alignClass = topLayout == "two-lines-centered" || topLayout == "two-lines" ? "grid--align-self-center" : "";
4736 alignClass = topLayout == "splitted-center" ? "u-middle" : alignClass;
4737 string logo = Model.Area.Item.GetItem("Layout").GetFile("LogoImage") != null ? Model.Area.Item.GetItem("Layout").GetFile("LogoImage").PathUrlEncoded : "/Files/Images/logo-dynamicweb.png";
4738 if (Path.GetExtension(logo).ToLower() != ".svg")
4739 {
4740 int logoHeight = Model.Area.Item.GetItem("Layout").GetInt32("LogoHeight");
4741 logoHeight = logoHeight > 0 && Pageview.Device.ToString() != "Mobile" ? logoHeight : 40;
4742 logo = "/Admin/Public/GetImage.ashx?height=" + Converter.ToString(logoHeight) + "&crop=5&Compression=75&image=" + logo;
4743 }
4744 else
4745 {
4746 logo = HttpUtility.UrlDecode(logo);
4747 }
4748
4749 <div class="logo @alignClass dw-mod">
4750 <a href="/Default.aspx?ID=@firstPageId" class="logo__img dw-mod u-block">
4751 <img class="grid__cell-img logo__img dw-mod" src="@logo" alt="@Translate("Logo")" />
4752 </a>
4753 </div>
4754 }
4755 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4756
4757 @using System
4758 @using System.Web
4759 @using Dynamicweb.Rapido.Blocks.Extensibility
4760 @using Dynamicweb.Rapido.Blocks
4761
4762 @functions {
4763 bool isMegaMenu;
4764 }
4765
4766 @{
4767 isMegaMenu = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("NavigationMegaMenu") != null ? Converter.ToBoolean(Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("NavigationMegaMenu").SelectedValue) : false;
4768 Block masterDesktopMenu = new Block
4769 {
4770 Id = "MasterDesktopMenu",
4771 SortId = 10,
4772 Template = RenderDesktopMenu(),
4773 Design = new Design
4774 {
4775 Size = "auto",
4776 HidePadding = true,
4777 RenderType = RenderType.Column
4778 }
4779 };
4780
4781 if (isMegaMenu)
4782 {
4783 masterDesktopMenu.Design.CssClass = "u-reset-position";
4784 }
4785
4786 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopMenu);
4787 }
4788
4789 @helper RenderDesktopMenu()
4790 {
4791 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
4792 string menuAlignment = topLayout == "minimal-right" ? "grid--align-self-end" : "";
4793 menuAlignment = topLayout == "minimal-center" ? "grid--align-self-center" : topLayout;
4794 string megamenuPromotionImage = Model.Area.Item.GetItem("Layout").GetItem("Header").GetFile("MegamenuPromotionImage") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetFile("MegamenuPromotionImage").PathUrlEncoded : "";
4795 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar");
4796 bool showOnlyHeaders = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowOnlyHeaders");
4797 int startLevel = renderPagesInToolBar ? 1 : 0;
4798
4799 string promotionLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("MegamenuPromotionLink");
4800
4801 <div class="grid__cell u-flex @(isMegaMenu ? "u-reset-position" : "") @menuAlignment">
4802 @if (!isMegaMenu)
4803 {
4804 @RenderNavigation(new
4805 {
4806 id = "topnavigation",
4807 cssclass = "menu dw-mod dwnavigation u-full-max-width u-flex grid--wrap",
4808 startLevel = startLevel,
4809 ecomStartLevel = startLevel + 1,
4810 endlevel = 5,
4811 expandmode = "all",
4812 template = "BaseMenuWithDropdown.xslt"
4813 });
4814 }
4815 else
4816 {
4817 @RenderNavigation(new
4818 {
4819 id = "topnavigation",
4820 cssclass = "menu dw-mod dwnavigation u-full-max-width u-flex grid--wrap",
4821 startLevel = startLevel,
4822 ecomStartLevel = startLevel + 1,
4823 endlevel = 5,
4824 promotionImage = megamenuPromotionImage,
4825 promotionLink = promotionLink,
4826 expandmode = "all",
4827 showOnlyHeaders = showOnlyHeaders.ToString().ToLower(),
4828 template = "BaseMegaMenu.xslt"
4829 });
4830 }
4831 </div>
4832 }
4833 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4834
4835 @using System
4836 @using System.Web
4837 @using Dynamicweb.Rapido.Blocks.Extensibility
4838 @using Dynamicweb.Rapido.Blocks
4839
4840 @{
4841 Block masterDesktopActionsMenu = new Block
4842 {
4843 Id = "MasterDesktopActionsMenu",
4844 SortId = 10,
4845 Template = RenderDesktopActionsMenu(),
4846 Design = new Design
4847 {
4848 CssClass = "u-flex"
4849 },
4850 SkipRenderBlocksList = true
4851
4852 };
4853 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopActionsMenu);
4854
4855 if (!string.IsNullOrWhiteSpace(Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonLink")))
4856 {
4857 Block masterDesktopActionsHeaderButton = new Block
4858 {
4859 Id = "MasterDesktopActionsHeaderButton",
4860 SortId = 60,
4861 Template = RenderHeaderButton()
4862 };
4863 masterDesktopActionsMenu.Add(masterDesktopActionsHeaderButton);
4864 }
4865 }
4866
4867 @helper RenderDesktopActionsMenu()
4868 {
4869 List<Block> subBlocks = this.headerBlocksPage.GetBlockListById("MasterDesktopActionsMenu").OrderBy(item => item.SortId).ToList();
4870
4871 <ul class="menu u-flex dw-mod">
4872 @RenderBlockList(subBlocks)
4873 </ul>
4874 }
4875
4876 @helper RenderHeaderButton()
4877 {
4878 string headerButtonText = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonText");
4879 string headerButtonLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonLink");
4880 string headerButtonType = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("HeaderButtonType") != null ? "btn--" + Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("HeaderButtonType").SelectedName.ToLower() : "";
4881
4882 <li class="menu__item menu__item--horizontal menu--clean dw-mod">
4883 <a class="btn @headerButtonType dw-mod u-no-margin u-margin-left" href="@headerButtonLink">@headerButtonText</a>
4884 </li>
4885 }
4886 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4887
4888 @using System
4889 @using System.Web
4890 @using Dynamicweb.Core;
4891 @using System.Text.RegularExpressions
4892 @using Dynamicweb.Rapido.Blocks.Extensibility
4893 @using Dynamicweb.Rapido.Blocks
4894
4895 @{
4896 Block masterDesktopActionsMenuLanguageSelector = new Block
4897 {
4898 Id = "MasterDesktopActionsMenuLanguageSelector",
4899 SortId = 40,
4900 Template = RenderLanguageSelector()
4901 };
4902
4903 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuLanguageSelector);
4904 }
4905
4906 @helper RenderLanguageSelector()
4907 {
4908 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
4909 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean";
4910 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
4911 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() : "";
4912
4913 if (Model.Languages.Count > 1)
4914 {
4915 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon is-dropdown is-dropdown--no-icon dw-mod">
4916 <div class="@menuLinkClass dw-mod" title="@Translate("Language")">
4917 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("LanguageIcon").SelectedValue fa-1_5x"></i>
4918 <span class="headericonlabel languageicontext">@Translate("Languageicontext", "Language")</span>
4919 </div>
4920 <div class="menu menu--dropdown menu--dropdown-right languages-dropdown dw-mod grid__cell">
4921 @foreach (var lang in Model.Languages)
4922 {
4923 string widthClass = "menu__item--fixed-width";
4924 string langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " u-margin-right\"></span>" + lang.Name;
4925 string cultureName = Regex.Replace(Dynamicweb.Services.Areas.GetArea(lang.ID).CultureInfo.NativeName, @" ?\(.*?\)", string.Empty);
4926 cultureName = char.ToUpper(cultureName[0]) + cultureName.Substring(1);
4927
4928 if (cultureName == "Español") {
4929 continue;
4930 }
4931
4932 if (languageViewType == "flag-culture")
4933 {
4934 langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " \"></span> " + cultureName;
4935 }
4936
4937 if (languageViewType == "flag")
4938 {
4939 langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " \"></span>";
4940 widthClass = "";
4941 }
4942
4943 if (languageViewType == "name")
4944 {
4945 langInfo = lang.Name;
4946 }
4947
4948 if (languageViewType == "culture")
4949 {
4950 langInfo = cultureName;
4951 widthClass = "";
4952 }
4953
4954 <div class="menu__item dw-mod @widthClass">
4955 <a href="/Default.aspx?AreaID=@Dynamicweb.Services.Pages.GetPage(lang.Page.ID).Area.ID&LanguageID=@Dynamicweb.Services.Pages.GetPage(lang.Page.ID).Area.EcomLanguageId" class="menu-dropdown__link dw-mod">@langInfo</a>
4956 </div>
4957 }
4958 </div>
4959 </li>
4960 }
4961 }
4962 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4963
4964 @using System
4965 @using System.Web
4966 @using Dynamicweb.Rapido.Blocks.Extensibility
4967 @using Dynamicweb.Rapido.Blocks
4968
4969 @{
4970 Block masterDesktopActionsMenuSignIn = new Block
4971 {
4972 Id = "MasterDesktopActionsMenuSignIn",
4973 SortId = 20,
4974 Template = RenderSignIn()
4975 };
4976
4977 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuSignIn);
4978 }
4979
4980 @helper RenderSignIn()
4981 {
4982 bool navigationItemsHideSignIn = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSignIn");
4983 string userInitials = "";
4984 int pageId = Model.TopPage.ID;
4985 int createAccountPageId = GetPageIdByNavigationTag("CreateAccount");
4986 int myDashboardPageId = GetPageIdByNavigationTag("CustomerDashboard");
4987 int myProfilePageId = GetPageIdByNavigationTag("CustomerProfile");
4988 int myOrdersPageId = GetPageIdByNavigationTag("CustomerOrders");
4989 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites");
4990 int mySavedCardsPageId = GetPageIdByNavigationTag("SavedCards");
4991 int myOrderDraftsPageId = GetPageIdByNavigationTag("OrderDraft");
4992 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
4993 bool hideCreateAccountLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideCreateAccount");
4994 bool hideMyProfileLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideProfile");
4995 bool hideMyOrdersLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideOrders");
4996 bool hideMySavedCardsLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideSavedCards");
4997 bool hideMyOrderDraftsLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideOrderDrafts");
4998 bool hideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideFavorites");
4999 bool hideForgotPasswordLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideForgotPasswordLink");
5000
5001 string linkStart = "/Default.aspx?ID=";
5002 if (Model.CurrentUser.ID <= 0)
5003 {
5004 linkStart += signInProfilePageId + "&RedirectPageId=";
5005 }
5006
5007 string forgotPasswordPageLink = "/Default.aspx?ID=" + signInProfilePageId + "&LoginAction=Recovery";
5008 string myProfilePageLink = linkStart + myProfilePageId;
5009 string myOrdersPageLink = linkStart + myOrdersPageId;
5010 string myFavoritesPageLink = linkStart + myFavoritesPageId;
5011 string mySavedCardsPageLink = linkStart + mySavedCardsPageId;
5012 string myOrderDraftsLink = linkStart + myOrderDraftsPageId;
5013
5014 string profileIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue : "fa fa-user";
5015 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";
5016 string orderDraftsIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon").SelectedValue : "fa fa-clipboard";
5017
5018 if (Model.CurrentUser.ID != 0)
5019 {
5020 userInitials = Dynamicweb.Rapido.Services.User.GetInitials(Model.CurrentUser.Name, Model.CurrentUser.FirstName, Model.CurrentUser.LastName, Model.CurrentUser.Email, Model.CurrentUser.UserName);
5021 }
5022
5023 if (!navigationItemsHideSignIn)
5024 {
5025 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5026 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu__item--clean";
5027 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5028
5029 <li class="menu__item menu__item--horizontal menu__item menu__item--icon @liClasses is-dropdown is-dropdown--no-icon dw-mod">
5030 <div class="@menuLinkClass dw-mod">
5031 @if (Model.CurrentUser.ID <= 0)
5032 {
5033 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue fa-1_5x" title="@Translate("Sign in")"></i>
5034 <span class="headericonlabel signinicontext">@Translate("SignInIcontext", "Sign In")</span>
5035 }
5036 else
5037 {
5038 <a href="/default.aspx?ID=@myDashboardPageId" class="u-color-inherit" title="@Translate("Customer center")"><div class="circle-icon-btn">@userInitials.ToUpper()</div></a>
5039 <span class="headericonlabel profileicontext">@Translate("ProfileIcontext", "Profile")</span>
5040 }
5041 </div>
5042 <div class="menu menu--dropdown menu--dropdown-right menu--sign-in grid__cell dw-mod">
5043 <ul class="list list--clean dw-mod">
5044 @if (Model.CurrentUser.ID <= 0)
5045 {
5046 <li>
5047 <label for="SignInModalTrigger" class="btn btn--primary btn--full u-no-margin sign-in-modal-trigger-button dw-mod" onclick="setTimeout(function () { document.getElementById('LoginUsername').focus() }, 10)">@Translate("Sign in")</label>
5048 </li>
5049
5050 if (!hideCreateAccountLink)
5051 {
5052 @RenderListItem("/default.aspx?ID=" + createAccountPageId, Translate("Create account"));
5053 }
5054 if (!hideForgotPasswordLink)
5055 {
5056 @RenderListItem(forgotPasswordPageLink, Translate("Forgot your password?"))
5057 }
5058 if (!hideMyProfileLink || !hideMyOrdersLink || !hideMyFavoritesLink || !hideMySavedCardsLink)
5059 {
5060 @RenderSeparator()
5061 }
5062 }
5063 @if (!hideMyProfileLink)
5064 {
5065 @RenderListItem(myProfilePageLink, Translate("My Profile"), profileIcon)
5066 }
5067 @if (!hideMyOrdersLink)
5068 {
5069 @RenderListItem(myOrdersPageLink, Translate("My Orders"), "fas fa-list")
5070 }
5071 @if (!hideMyFavoritesLink)
5072 {
5073 @RenderListItem(myFavoritesPageLink, Translate("My Favorites"), favoritesIcon)
5074 }
5075 @if (!hideMySavedCardsLink)
5076 {
5077 @RenderListItem(mySavedCardsPageLink, Translate("My Saved cards"), "fas fa-credit-card")
5078 }
5079 @if (!hideMyOrderDraftsLink)
5080 {
5081 @RenderListItem(myOrderDraftsLink, Translate("My Order drafts"), orderDraftsIcon)
5082 }
5083 @if (Model.CurrentUser.ID > 0)
5084 {
5085 if (!hideMyProfileLink || !hideMyOrdersLink || !hideMyFavoritesLink || !hideMySavedCardsLink)
5086 {
5087 @RenderSeparator()
5088 }
5089
5090 //Check if impersonation is on
5091 if (Model.CurrentSecondaryUser != null && Model.CurrentSecondaryUser.ID > 0)
5092 {
5093 <li>
5094 <div class="list__link dw-mod" onclick="document.getElementById('StopImpersonationModalTrigger').checked = true;">
5095 @Translate("Sign out")
5096 </div>
5097 </li>
5098 } else {
5099 @RenderListItem("/Admin/Public/ExtranetLogoff.aspx?ID=" + pageId, Translate("Sign out"))
5100 }
5101 }
5102 </ul>
5103 </div>
5104 </li>
5105 }
5106 }
5107
5108 @helper RenderListItem(string link, string text, string icon = null) {
5109 <li>
5110 <a href="@link" class="list__link dw-mod" onclick="RememberState.SetCookie('useAnotherAddress', false)">
5111 @if (!string.IsNullOrEmpty(icon)){<i class="@icon u-margin-right"></i>}@text
5112 </a>
5113 </li>
5114 }
5115
5116 @helper RenderSeparator()
5117 {
5118 <li class="list__seperator dw-mod"></li>
5119 }
5120 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5121
5122 @using System
5123 @using System.Web
5124 @using Dynamicweb.Rapido.Blocks.Extensibility
5125 @using Dynamicweb.Rapido.Blocks
5126
5127 @{
5128 bool hideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideFavorites");
5129
5130 Block masterDesktopActionsMenuFavorites = new Block
5131 {
5132 Id = "MasterDesktopActionsMenuFavorites",
5133 SortId = 30,
5134 Template = RenderFavorites()
5135 };
5136
5137 if (!hideMyFavoritesLink && Model.CurrentUser.ID > 0)
5138 {
5139 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuFavorites);
5140 }
5141 }
5142
5143 @helper RenderFavorites()
5144 {
5145 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites");
5146 string myFavoritesPageLink = "/Default.aspx?ID=" + myFavoritesPageId;
5147
5148 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5149 string liClasses = topLayout != "normal" && topLayout != "splitted-center" ? "menu__item--top-level u-hidden-xxs" : "menu--clean";
5150 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5151
5152 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod">
5153 <a href="@myFavoritesPageLink" class="@menuLinkClass dw-mod" title="@Translate("Favorites")">
5154 <i class="fas fa-@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon").SelectedValue fa-1_5x"></i>
5155 </a>
5156 </li>
5157 }
5158 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5159
5160 @using System
5161 @using System.Web
5162 @using Dynamicweb.Rapido.Blocks.Extensibility
5163 @using Dynamicweb.Rapido.Blocks
5164 @using Dynamicweb.Rapido.Services
5165
5166 @{
5167 bool hideCart = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart");
5168 string miniCartLayout = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout").SelectedValue : "dropdown";
5169
5170 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed() && !hideCart)
5171 {
5172 Block masterDesktopActionsMenuMiniCart = new Block
5173 {
5174 Id = "MasterDesktopActionsMenuMiniCart",
5175 SortId = 60,
5176 Template = RenderMiniCart(miniCartLayout == "dropdown"),
5177 SkipRenderBlocksList = true,
5178 BlocksList = new List<Block>()
5179 };
5180
5181 Block miniCartCounterScriptTemplate = new Block
5182 {
5183 Id = "MiniCartCounterScriptTemplate",
5184 Template = RenderMiniCartCounterContent()
5185 };
5186
5187 //dropdown layout is default
5188 RazorEngine.Templating.TemplateWriter layoutTemplate;
5189 RazorEngine.Templating.TemplateWriter miniCartTriggerTemplate;
5190
5191 switch (miniCartLayout)
5192 {
5193 case "dropdown":
5194 layoutTemplate = RenderMiniCartDropdownLayout();
5195 miniCartTriggerTemplate = RenderMiniCartTriggerLink();
5196 break;
5197 case "panel":
5198 layoutTemplate = RenderMiniCartPanelLayout();
5199 miniCartTriggerTemplate = RenderMiniCartTriggerLabel();
5200 break;
5201 case "modal":
5202 layoutTemplate = RenderMiniCartModalLayout();
5203 miniCartTriggerTemplate = RenderMiniCartTriggerLabel();
5204 break;
5205 case "none":
5206 default:
5207 layoutTemplate = RenderMiniCartDropdownLayout();
5208 miniCartTriggerTemplate = RenderMiniCartTriggerLink();
5209 break;
5210 }
5211
5212 masterDesktopActionsMenuMiniCart.BlocksList.Add(new Block
5213 {
5214 Id = "MiniCartTrigger",
5215 Template = miniCartTriggerTemplate
5216 });
5217
5218 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet")
5219 {
5220 masterDesktopActionsMenuMiniCart.BlocksList.Add(new Block
5221 {
5222 Id = "MiniCartLayout",
5223 Template = layoutTemplate
5224 });
5225 }
5226
5227 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuMiniCart);
5228 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", miniCartCounterScriptTemplate);
5229 }
5230
5231 if (hideCart && Dynamicweb.Rapido.Services.User.IsBuyingAllowed())
5232 {
5233 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", new Block {
5234 Id = "CartInitialization"
5235 });
5236 }
5237 }
5238
5239 @helper RenderMiniCart(bool hasMouseEnterEvent)
5240 {
5241 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterDesktopActionsMenuMiniCart").OrderBy(item => item.SortId).ToList();
5242 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5243 string liClasses = topLayout != "normal" ? "menu__item--top-level" : "menu--clean";
5244 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5245 string mouseEvent = "";
5246 string id = "MiniCart";
5247 if (hasMouseEnterEvent)
5248 {
5249 mouseEvent = "onmouseenter=\"Cart.UpdateMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '/Default.aspx?ID=" + miniCartFeedPageId + "&feedType=MiniCart')\"";
5250 id = "miniCartTrigger";
5251 }
5252 <li class="menu__item menu__item--horizontal menu__item--icon @liClasses dw-mod" id="@id" @mouseEvent>
5253 @RenderBlockList(subBlocks)
5254 </li>
5255 }
5256
5257 @helper RenderMiniCartTriggerLabel()
5258 {
5259 int cartPageId = GetPageIdByNavigationTag("CartPage");
5260 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fa fa-cart";
5261 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5262 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5263 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5264
5265 <div class="@menuLinkClass dw-mod js-mini-cart-button" onclick="Cart.UpdateMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '/Default.aspx?ID=@miniCartFeedPageId&feedType=MiniCart')" title="@Translate("Cart")">
5266 <div class="u-inline u-position-relative">
5267 <i class="@cartIcon fa-1_5x"></i>
5268 @RenderMiniCartCounter()
5269 </div>
5270 </div>
5271 }
5272
5273 @helper RenderMiniCartTriggerLink()
5274 {
5275 int cartPageId = GetPageIdByNavigationTag("CartPage");
5276 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fa fa-cart";
5277 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5278 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5279
5280 <a href="/Default.aspx?ID=@cartPageId&Purge=True" class="@menuLinkClass menu__item--icon dw-mod js-mini-cart-button" title="@Translate("Cart")">
5281 <span class="u-inline u-position-relative">
5282 <i class="@cartIcon fa-1_5x"></i>
5283 @RenderMiniCartCounter()
5284 </span>
5285 </a>
5286 }
5287
5288 @helper RenderMiniCartCounter()
5289 {
5290 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5291 string cartProductsCount = Model.Cart.TotalProductsCount.ToString();
5292 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right";
5293 bool showPrice = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetBoolean("ShowPrice");
5294 string cartProductsTotalPrice = showPrice && Model.Cart.TotalPrice != null ? Model.Cart.TotalPrice.Price.Formatted : "";
5295 cartProductsTotalPrice = counterPosition == "right" ? cartProductsTotalPrice : "";
5296
5297 if (showPrice && counterPosition == "right")
5298 {
5299 cartProductsCount = Translate("Cart") + " (" + cartProductsCount + ")";
5300 }
5301
5302 <span class="mini-cart__counter @(counterPosition == "right" ? "mini-cart__counter--inline" : "") dw-mod">
5303 <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">
5304 <span class="js-mini-cart-counter-content" data-count="@Model.Cart.TotalProductsCount.ToString()">
5305 @cartProductsCount @cartProductsTotalPrice
5306 </span>
5307 </span>
5308 </span>
5309 }
5310
5311 @helper RenderMiniCartCounterContent()
5312 {
5313 bool showPrice = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetBoolean("ShowPrice");
5314 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right";
5315 bool showPriceInMiniCartCounter = Pageview.Device.ToString() != "Mobile" && counterPosition == "right" && showPrice;
5316
5317 <script id="MiniCartCounterContent" type="text/x-template">
5318 {{#.}}
5319 <span class="js-mini-cart-counter-content dw-mod" data-count="{{numberofproducts}}">
5320 @if (showPriceInMiniCartCounter)
5321 {
5322 @Translate("Cart")<text>({{numberofproducts}}) {{totalprice}}</text>
5323 }
5324 else
5325 {
5326 <text>{{numberofproducts}}</text>
5327 }
5328 </span>
5329 {{/.}}
5330 </script>
5331 }
5332
5333 @helper RenderMiniCartDropdownLayout()
5334 {
5335 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5336 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage");
5337
5338 <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">
5339 <div class="mini-cart-dropdown__inner dw-mod">
5340 <h3 class="u-ta-center dw-mod">@Translate("Shopping cart")</h3>
5341 <div class="mini-cart-dropdown__body u-flex dw-mod">
5342 <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>
5343 </div>
5344 </div>
5345 </div>
5346 }
5347
5348 @helper RenderMiniCartPanelLayout()
5349 {
5350 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5351 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage");
5352
5353 <div class="mini-cart grid__cell dw-mod">
5354 <input type="checkbox" id="miniCartTrigger" class="panel-trigger" />
5355 <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">
5356 <label for="miniCartTrigger" class="panel__close-btn" title="@Translate("Close panel")"><i class="fas fa-times"></i></label>
5357 <div class="panel__content u-full-width dw-mod">
5358 <h3 class="panel__header dw-mod u-margin-bottom u-ta-center">@Translate("Shopping cart")</h3>
5359 <div class="panel__content-body panel__content-body--cart dw-mod">
5360 <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>
5361 </div>
5362 </div>
5363 </div>
5364 </div>
5365 }
5366
5367 @helper RenderMiniCartModalLayout()
5368 {
5369 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5370 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage");
5371
5372 <div class="mini-cart grid__cell dw-mod">
5373 <input type="checkbox" id="miniCartTrigger" class="modal-trigger" autocomplete="off" />
5374 <div class="modal-container dw-mod js-mini-cart" id="miniCart" data-cart-id="@miniCartFeedPageId" data-show-type="block" data-cart-page-link="@cartPageLink">
5375 <label for="miniCartTrigger" class="modal-overlay"></label>
5376 <div class="modal modal--md modal--top-right dw-mod">
5377 <div class="modal__body u-flex grid--direction-column dw-mod">
5378 <h3 class="dw-mod u-ta-center">@Translate("Shopping cart")</h3>
5379 <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>
5380 </div>
5381 <label class="modal__close-btn modal__close-btn--clean dw-mod" for="miniCartTrigger" title="@Translate("Close modal")"></label>
5382 </div>
5383 </div>
5384 </div>
5385 }
5386 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5387
5388 @using System
5389 @using System.Web
5390 @using Dynamicweb.Rapido.Blocks.Extensibility
5391 @using Dynamicweb.Rapido.Blocks
5392
5393 @{
5394 bool showOrderDraftLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowOrderDraftIcon");
5395
5396 Block masterDesktopActionsMenuOrderDraft = new Block
5397 {
5398 Id = "MasterDesktopActionsMenuOrderDraft",
5399 SortId = 40,
5400 Template = RenderOrderDraft()
5401 };
5402
5403 if (showOrderDraftLink && Model.CurrentUser.ID > 0)
5404 {
5405 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuOrderDraft);
5406 }
5407 }
5408
5409 @helper RenderOrderDraft()
5410 {
5411 int OrderDraftPageId = GetPageIdByNavigationTag("OrderDraft");
5412 string OrderDraftPageLink = "/Default.aspx?ID=" + OrderDraftPageId;
5413 string draftIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon").SelectedValue : "fa fa-clipboard";
5414
5415
5416 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5417 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean";
5418 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5419
5420 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod">
5421 <a href="@OrderDraftPageLink" class="@menuLinkClass dw-mod" title="@Translate("My order drafts")">
5422 <span class="u-inline u-position-relative">
5423 <i class="@draftIcon fa-1_5x"></i>
5424 </span>
5425 </a>
5426 </li>
5427 }
5428 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5429
5430 @using System
5431 @using System.Web
5432 @using Dynamicweb.Rapido.Blocks.Extensibility
5433 @using Dynamicweb.Rapido.Blocks
5434
5435 @{
5436 bool showDownloadCartLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowDownloadCart");
5437
5438 Block masterDesktopActionsMenuDownloadCart = new Block
5439 {
5440 Id = "MasterDesktopActionsMenuDownloadCart",
5441 SortId = 50,
5442 Template = RenderDownloadCart()
5443 };
5444
5445 if (showDownloadCartLink && Model.CurrentUser.ID > 0)
5446 {
5447 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuDownloadCart);
5448 }
5449 }
5450
5451 @helper RenderDownloadCart()
5452 {
5453 int downloadCartPageId = GetPageIdByNavigationTag("DownloadCart");
5454 string downloadCartPageLink = "/Default.aspx?ID=" + downloadCartPageId;
5455
5456 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5457 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean";
5458 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5459 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right";
5460
5461 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod">
5462 <a href="@downloadCartPageLink" class="@menuLinkClass dw-mod" title="@Translate("Download cart")">
5463 <span class="u-inline u-position-relative">
5464 <i class="fas fa-cart-arrow-down fa-1_5x"></i>
5465 <span class="mini-cart__counter u-hidden @(counterPosition == "right" ? "mini-cart__counter--inline" : "") dw-mod js-download-cart-counter"></span>
5466 </span>
5467 </a>
5468 </li>
5469 }
5470 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5471
5472 @using System
5473 @using System.Web
5474 @using Dynamicweb.Rapido.Blocks.Extensibility
5475 @using Dynamicweb.Rapido.Blocks
5476
5477 @functions {
5478 public class SearchConfiguration
5479 {
5480 public string searchFeedId { get; set; }
5481 public string searchSecondFeedId { get; set; }
5482 public int groupsFeedId { get; set; }
5483 public string resultPageLink { get; set; }
5484 public string searchPlaceholder { get; set; }
5485 public string searchType { get; set; }
5486 public string searchTemplate { get; set; }
5487 public string searchContentTemplate { get; set; }
5488 public string searchValue { get; set; }
5489 public bool showGroups { get; set; }
5490
5491 public SearchConfiguration()
5492 {
5493 searchFeedId = "";
5494 searchSecondFeedId = "";
5495 searchType = "product-search";
5496 searchContentTemplate = "";
5497 showGroups = true;
5498 }
5499 }
5500 }
5501 @{
5502 Block masterSearchBar = new Block
5503 {
5504 Id = "MasterSearchBar",
5505 SortId = 40,
5506 Template = RenderSearch("bar"),
5507 Design = new Design
5508 {
5509 Size = "auto",
5510 HidePadding = true,
5511 RenderType = RenderType.Column
5512 }
5513 };
5514
5515 Block masterSearchAction = new Block
5516 {
5517 Id = "MasterDesktopActionsMenuSearch",
5518 SortId = 10,
5519 Template = RenderSearch()
5520 };
5521
5522 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterSearchBar);
5523 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterSearchAction);
5524 }
5525
5526 @helper RenderSearch(string type = "mini-search")
5527 {
5528 string productsPageId = Converter.ToString(GetPageIdByNavigationTag("ProductsPage"));
5529 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID;
5530 string searchType = Model.Area.Item.GetItem("Layout").GetList("TopSearch") != null ? Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue : "productSearch";
5531
5532 SearchConfiguration searchConfiguration = null;
5533
5534 switch (searchType) {
5535 case "contentSearch":
5536 searchConfiguration = new SearchConfiguration() {
5537 searchFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true",
5538 resultPageLink = contentSearchPageLink,
5539 searchPlaceholder = Translate("Search page"),
5540 groupsFeedId = 0,
5541 searchType = "content-search",
5542 searchTemplate = "SearchPagesTemplate",
5543 showGroups = false
5544 };
5545 break;
5546 case "combinedSearch":
5547 searchConfiguration = new SearchConfiguration() {
5548 searchFeedId = productsPageId + "&feed=true",
5549 searchSecondFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true",
5550 resultPageLink = Converter.ToString(productsPageId),
5551 searchPlaceholder = Translate("Search products or pages"),
5552 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"),
5553 searchType = "combined-search",
5554 searchTemplate = "SearchProductsTemplateWrap",
5555 searchContentTemplate = "SearchPagesTemplateWrap",
5556 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector")
5557 };
5558 break;
5559 default: //productSearch
5560 searchConfiguration = new SearchConfiguration() {
5561 resultPageLink = Converter.ToString(productsPageId),
5562 searchFeedId = productsPageId + "&feed=true",
5563 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"),
5564 searchPlaceholder = Translate("Search products"),
5565 searchTemplate = "SearchProductsTemplate",
5566 searchType = "product-search",
5567 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector")
5568 };
5569 break;
5570 }
5571 searchConfiguration.searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? "";
5572
5573 if (type == "mini-search") {
5574 @RenderMiniSearch(searchConfiguration)
5575 } else {
5576 @RenderSearchBar(searchConfiguration)
5577 }
5578 }
5579
5580 @helper RenderSearchBar(SearchConfiguration options)
5581 {
5582 <div class="typeahead typeahead--centered u-color-inherit js-typeahead dw-mod" id="ProductSearchBar"
5583 data-page-size="7"
5584 data-search-feed-id="@options.searchFeedId"
5585 data-search-second-feed-id="@options.searchSecondFeedId"
5586 data-result-page-id="@options.resultPageLink"
5587 data-groups-page-id="@options.groupsFeedId"
5588 data-search-type="@options.searchType">
5589 @if (options.showGroups)
5590 {
5591 <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>
5592 <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>
5593 }
5594 <div class="typeahead-search-field">
5595 <input type="text" class="u-no-margin u-full-width u-full-height js-typeahead-search-field" placeholder="@options.searchPlaceholder" value="@options.searchValue">
5596 @if (string.IsNullOrEmpty(options.searchSecondFeedId))
5597 {
5598 <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>
5599 }
5600 else
5601 {
5602 <div class="dropdown dropdown--absolute-position dropdown--combined grid">
5603 <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>
5604 <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>
5605 </div>
5606 }
5607 </div>
5608 <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>
5609 </div>
5610 }
5611
5612 @helper RenderMiniSearch(SearchConfiguration options)
5613 {
5614 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5615 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5616
5617 <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">
5618 <div class="@menuLinkClass dw-mod" title="@Translate("Search")">
5619 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue fa-1_5x"></i>
5620 <span class="headericonlabel searchtext">@Translate("Searchicontext", "Search")</span>
5621 </div>
5622 <div class="menu menu--dropdown menu--dropdown-right u-no-padding u-w380px grid__cell dw-mod">
5623 <div class="typeahead js-typeahead" id="ProductSearchBar"
5624 data-page-size="7"
5625 data-search-feed-id="@options.searchFeedId"
5626 data-search-second-feed-id="@options.searchSecondFeedId"
5627 data-result-page-id="@options.resultPageLink"
5628 data-search-type="@options.searchType">
5629 <div class="typeahead-search-field">
5630 <input type="text" class="u-no-margin u-full-width js-typeahead-search-field" id="headerSearch" placeholder="@options.searchPlaceholder" value="@options.searchValue">
5631 @if (string.IsNullOrEmpty(options.searchSecondFeedId))
5632 {
5633 <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>
5634 }
5635 else
5636 {
5637 <div class="dropdown dropdown--absolute-position dropdown--combined grid dropdown--right-aligned">
5638 <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>
5639 <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>
5640 </div>
5641 }
5642 </div>
5643 </div>
5644 </div>
5645 </li>
5646 }
5647 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5648
5649 @using System
5650 @using System.Web
5651 @using Dynamicweb.Rapido.Blocks.Extensibility
5652 @using Dynamicweb.Rapido.Blocks
5653
5654 @{
5655 string headerConfigurationTopLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5656 bool headerConfigurationHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch");
5657
5658 BlocksPage headerConfigurationPage = BlocksPage.GetBlockPage("Master");
5659
5660 Block configDesktopLogo = headerConfigurationPage.GetBlockById("MasterDesktopLogo");
5661 headerConfigurationPage.RemoveBlock(configDesktopLogo);
5662
5663 Block configDesktopMenu = headerConfigurationPage.GetBlockById("MasterDesktopMenu");
5664 headerConfigurationPage.RemoveBlock(configDesktopMenu);
5665
5666 Block configSearchBar = headerConfigurationPage.GetBlockById("MasterSearchBar");
5667 headerConfigurationPage.RemoveBlock(configSearchBar);
5668
5669 Block configSearchAction = headerConfigurationPage.GetBlockById("MasterDesktopActionsMenuSearch");
5670 headerConfigurationPage.RemoveBlock(configSearchAction);
5671
5672 Block configDesktopActionsMenu = headerConfigurationPage.GetBlockById("MasterDesktopActionsMenu");
5673 headerConfigurationPage.RemoveBlock(configDesktopActionsMenu);
5674
5675 Block configDesktopExtra = headerConfigurationPage.GetBlockById("MasterDesktopExtra");
5676
5677 switch (headerConfigurationTopLayout)
5678 {
5679 case "condensed": //2
5680 configDesktopLogo.Design.Size = "auto-width";
5681 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo);
5682
5683 configDesktopMenu.SortId = 20;
5684 configDesktopMenu.Design.Size = "auto";
5685 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5686
5687 configDesktopActionsMenu.SortId = 30;
5688 configDesktopActionsMenu.Design.Size = "auto-width";
5689 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5690
5691 if (!headerConfigurationHideSearch)
5692 {
5693 configSearchBar.SortId = 40;
5694 configSearchBar.Design.Size = "12";
5695 configDesktopExtra.SortId = 50;
5696 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar);
5697 }
5698 break;
5699 case "splitted": //3
5700 configDesktopLogo.Design.Size = "auto";
5701 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5702
5703 if (!headerConfigurationHideSearch)
5704 {
5705 configSearchBar.SortId = 20;
5706 configSearchBar.Design.Size = "auto";
5707 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar);
5708 }
5709
5710 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5711
5712 configDesktopActionsMenu.SortId = 20;
5713 configDesktopActionsMenu.Design.Size = "auto-width";
5714 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5715 break;
5716 case "splitted-center": //4
5717 configDesktopLogo.Design.Size = "auto";
5718 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5719 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5720
5721 configDesktopActionsMenu.SortId = 30;
5722 configDesktopActionsMenu.Design.Size = "auto-width";
5723 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopActionsMenu);
5724
5725 if (!headerConfigurationHideSearch)
5726 {
5727 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5728 }
5729 break;
5730 case "minimal": //5
5731 configDesktopLogo.Design.Size = "auto-width";
5732 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo);
5733
5734 configDesktopMenu.Design.Size = "auto";
5735 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5736
5737 configDesktopActionsMenu.SortId = 20;
5738 configDesktopActionsMenu.Design.Size = "auto-width";
5739 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5740
5741 if (!headerConfigurationHideSearch)
5742 {
5743 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5744 }
5745 break;
5746 case "minimal-center": //6
5747 configDesktopLogo.Design.Size = "auto-width";
5748 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo);
5749
5750 configDesktopMenu.Design.Size = "auto";
5751 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5752
5753 configDesktopActionsMenu.SortId = 20;
5754 configDesktopActionsMenu.Design.Size = "auto-width";
5755 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5756
5757 if (!headerConfigurationHideSearch)
5758 {
5759 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5760 }
5761 break;
5762 case "minimal-right": //7
5763 configDesktopLogo.Design.Size = "auto-width";
5764 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo);
5765
5766 configDesktopMenu.Design.Size = "auto";
5767 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5768
5769 configDesktopActionsMenu.SortId = 20;
5770 configDesktopActionsMenu.Design.Size = "auto-width";
5771 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5772
5773 if (!headerConfigurationHideSearch)
5774 {
5775 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5776 }
5777 break;
5778 case "two-lines": //8
5779 configDesktopLogo.Design.Size = "auto";
5780 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5781
5782 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5783
5784 configDesktopActionsMenu.SortId = 20;
5785 configDesktopActionsMenu.Design.Size = "auto-width";
5786 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5787
5788 if (!headerConfigurationHideSearch)
5789 {
5790 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5791 }
5792 break;
5793 case "two-lines-centered": //9
5794 configDesktopLogo.Design.Size = "auto";
5795 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5796
5797 configDesktopMenu.Design.Size = "auto-width";
5798 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5799
5800 configDesktopActionsMenu.SortId = 20;
5801 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5802
5803 if (!headerConfigurationHideSearch)
5804 {
5805 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5806 }
5807 break;
5808 case "normal": //1
5809 default:
5810 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5811
5812 if (!headerConfigurationHideSearch)
5813 {
5814 configSearchBar.SortId = 20;
5815 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar);
5816 }
5817
5818 configDesktopActionsMenu.SortId = 30;
5819 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopActionsMenu);
5820
5821 configDesktopActionsMenu.Design.Size = "auto-width";
5822 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5823 break;
5824 }
5825 }
5826 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5827
5828 @using System
5829 @using System.Web
5830 @using Dynamicweb.Rapido.Blocks.Extensibility
5831 @using Dynamicweb.Rapido.Blocks
5832
5833 @{
5834
5835 }
5836
5837
5838 @helper RenderDesktopTools()
5839 {
5840 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopTools").OrderBy(item => item.SortId).ToList();
5841
5842 <div class="tools-navigation dw-mod">
5843 <div class="center-container grid top-container__center-container dw-mod">
5844 @RenderBlockList(subBlocks)
5845 </div>
5846 </div>
5847 }
5848
5849 @helper RenderDesktopToolsText()
5850 {
5851 string toolsText = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("ToolsText");
5852 if (!string.IsNullOrEmpty(toolsText))
5853 {
5854 <div class="u-margin-top u-margin-bottom">@toolsText</div>
5855 }
5856 }
5857
5858 @helper RenderDesktopToolsNavigation()
5859 {
5860 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar");
5861
5862 if (renderPagesInToolBar)
5863 {
5864 @RenderNavigation(new
5865 {
5866 id = "topToolsNavigation",
5867 cssclass = "menu menu-tools dw-mod dwnavigation",
5868 template = "TopMenu.xslt"
5869 })
5870 }
5871 }
5872
5873 @helper RenderDesktopNavigation()
5874 {
5875 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopNavigation").OrderBy(item => item.SortId).ToList();
5876 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5877 string alignClass = topLayout == "two-lines-centered" ? "grid--justify-center" : "";
5878 <nav class="main-navigation dw-mod">
5879 <div class="center-container top-container__center-container grid @alignClass dw-mod">
5880 @RenderBlockList(subBlocks)
5881 </div>
5882 </nav>
5883 }
5884
5885 @helper RenderDesktopExtra()
5886 {
5887 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopExtra").OrderBy(item => item.SortId).ToList();
5888
5889 if (subBlocks.Count > 0)
5890 {
5891 <div class="header header-top dw-mod">
5892 <div class="center-container top-container__center-container grid--justify-space-between grid grid--align-center dw-mod">
5893 @RenderBlockList(subBlocks)
5894 </div>
5895 </div>
5896 }
5897 }</text>
5898 }
5899
5900 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5901
5902 @using System
5903 @using System.Web
5904 @using Dynamicweb.Rapido.Blocks.Extensibility
5905 @using Dynamicweb.Rapido.Blocks
5906 @using Dynamicweb.Rapido.Blocks.Components.General
5907 @using Dynamicweb.Frontend
5908
5909 @functions {
5910 int impersonationPageId;
5911 string impersonationLayout;
5912 int impersonationFeed;
5913 Block impersonationBar;
5914
5915 string getUserNameFromParams(string firstName, string middleName, string lastName, string name, string email, string userName)
5916 {
5917 string username = "";
5918
5919 if (!string.IsNullOrEmpty(firstName) && !string.IsNullOrEmpty(lastName))
5920 {
5921 username = firstName + " " + (!string.IsNullOrEmpty(middleName) ? middleName + " " : "") + lastName;
5922 }
5923 else if (!string.IsNullOrEmpty(name))
5924 {
5925 username = name;
5926 }
5927 else if (!string.IsNullOrEmpty(email))
5928 {
5929 username = email;
5930 }
5931 else
5932 {
5933 username = userName;
5934 }
5935 return username;
5936 }
5937
5938 string getUserName(UserViewModel user)
5939 {
5940 return getUserNameFromParams(user.FirstName, user.MiddleName, user.LastName, user.Name, user.Email, user.UserName);
5941 }
5942
5943 string getUserName(Dynamicweb.Security.UserManagement.User user)
5944 {
5945 return getUserNameFromParams(user.FirstName, user.MiddleName, user.LastName, user.Name, user.Email, user.UserName);
5946 }
5947 }
5948
5949 @{
5950 impersonationPageId = GetPageIdByNavigationTag("Impersonation");
5951 impersonationLayout = Model.Area.Item.GetItem("Ecommerce").GetList("ImpersonationLayout") != null ? Model.Area.Item.GetItem("Ecommerce").GetList("ImpersonationLayout").SelectedValue : "bar";
5952 impersonationFeed = GetPageIdByNavigationTag("UsersFeed");
5953
5954 if (Model.CurrentUser.ID > 0 && Model.SecondaryUsers.Count > 0)
5955 {
5956 impersonationBar = new Block
5957 {
5958 Id = "ImpersonationBar",
5959 SortId = 50,
5960 Template = RenderImpersonation(),
5961 SkipRenderBlocksList = true,
5962 Design = new Design
5963 {
5964 Size = "auto-width",
5965 HidePadding = true,
5966 RenderType = RenderType.Column
5967 }
5968 };
5969
5970 if (impersonationLayout == "top-bar") {
5971 impersonationBar.SortId = 9;
5972 }
5973
5974 Block impersonationContent = new Block
5975 {
5976 Id = "ImpersonationContent",
5977 SortId = 20
5978 };
5979
5980 if (Model.CurrentSecondaryUser != null && Model.CurrentSecondaryUser.ID > 0)
5981 {
5982 //Render stop impersonation view
5983 impersonationContent.Template = RenderStopImpersonationView();
5984
5985
5986 Modal stopImpersonation = new Modal
5987 {
5988 Id = "StopImpersonation",
5989 Heading = new Heading {
5990 Level = 2,
5991 Title = Translate("Sign out"),
5992 Icon = new Icon {
5993 Name = "fa-sign-out",
5994 Prefix = "fas",
5995 LabelPosition = IconLabelPosition.After
5996 }
5997 },
5998 Width = ModalWidth.Sm,
5999 BodyTemplate = RenderStopImpersonationForm()
6000 };
6001
6002 Block stopImpersonationBlock = new Block
6003 {
6004 Id = "StopImpersonationBlock",
6005 SortId = 10,
6006 Component = stopImpersonation
6007 };
6008 impersonationBar.BlocksList.Add(stopImpersonationBlock);
6009 }
6010 else
6011 {
6012 //Render main view
6013 switch (impersonationLayout)
6014 {
6015 case "right-lower-box":
6016 impersonationContent.BlocksList.Add(
6017 new Block {
6018 Id = "RightLowerBoxHeader",
6019 SortId = 10,
6020 Component = new Heading {
6021 Level = 5,
6022 Title = Translate("View the list of users you can sign in as"),
6023 CssClass = "impersonation-text"
6024 }
6025 }
6026 );
6027 impersonationContent.BlocksList.Add(
6028 new Block {
6029 Id = "RightLowerBoxContent",
6030 SortId = 20,
6031 Template = RenderImpersonationControls()
6032 }
6033 );
6034 break;
6035 case "right-lower-bar":
6036 impersonationContent.BlocksList.Add(
6037 new Block {
6038 Id = "RightLowerBarContent",
6039 SortId = 10,
6040 Template = RenderImpersonationControls()
6041 }
6042 );
6043 break;
6044 case "bar":
6045 default:
6046 impersonationContent.BlocksList.Add(
6047 new Block {
6048 Id = "ViewListLink",
6049 SortId = 20,
6050 Template = RenderViewListLink()
6051 }
6052 );
6053 impersonationContent.BlocksList.Add(
6054 new Block {
6055 Id = "BarTypeaheadSearch",
6056 SortId = 30,
6057 Template = RenderTypeaheadSearch()
6058 }
6059 );
6060 break;
6061 }
6062 }
6063 impersonationBar.BlocksList.Add(impersonationContent);
6064
6065 impersonationBar.BlocksList.Add(
6066 new Block
6067 {
6068 Id = "ImpersonationSearchTemplates",
6069 SortId = 30,
6070 Template = RenderSearchResultTemplate()
6071 }
6072 );
6073 if (impersonationLayout != "bar" && impersonationLayout != "top-bar")
6074 {
6075 impersonationBar.BlocksList.Add(
6076 new Block
6077 {
6078 Id = "ImpersonationSearchScripts",
6079 SortId = 40,
6080 Template = RenderSearchScripts()
6081 }
6082 );
6083 }
6084 BlocksPage.GetBlockPage("Master").Add("MasterHeader", impersonationBar);
6085 }
6086 }
6087
6088 @helper RenderImpersonation()
6089 {
6090 List<Block> subBlocks = impersonationBar.BlocksList.OrderBy(item => item.SortId).ToList();
6091 <input type="checkbox" class="impersonation-trigger js-remember-state" id="ImpersonationMinimizeTrigger" />
6092 <div class="impersonation impersonation--@(impersonationLayout)-layout dw-mod" id="Impersonation">
6093 @if (impersonationLayout == "right-lower-box")
6094 {
6095 @RenderRightLowerBoxHeader()
6096 }
6097 <div class="center-container top-container__center-container impersonation__container @(impersonationLayout != "bar" && impersonationLayout != "top-bar" ? "impersonation__container--box" : "") dw-mod">
6098 @*Impersonation*@
6099 @RenderBlockList(subBlocks)
6100 </div>
6101 </div>
6102 }
6103
6104 @helper RenderRightLowerBoxHeader()
6105 {
6106 <div class="impersonation__header dw-mod">
6107 <div class="impersonation__title">@Translate("Impersonation")</div>
6108 <label for="ImpersonationMinimizeTrigger" class="btn btn--impersonation impersonation__minimize-btn dw-mod" onclick="this.blur();">
6109 @Render(new Icon
6110 {
6111 Prefix = "fas",
6112 Name = "fa-window-minimize"
6113 })
6114 </label>
6115 </div>
6116 }
6117
6118 @helper RenderStopImpersonationView()
6119 {
6120 string secondaryUserName = getUserName(Model.CurrentSecondaryUser);
6121 string userName = getUserName(Pageview.User);
6122 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> ";
6123 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;
6124
6125 if (impersonationLayout == "right-lower-box")
6126 {
6127 <div class="u-margin-bottom--lg u-ta-center">
6128 @impersonationText
6129 </div>
6130 <div class="u-margin-bottom--lg u-ta-center">
6131 @RenderSwitchAccountButton()
6132 </div>
6133 @RenderStopImpersonationButton()
6134 }
6135 else
6136 {
6137 <div class="grid grid--align-center impersonation__stop-wrap">
6138 <div class="impersonation-bar-item dw-mod">
6139 @impersonationText
6140 </div>
6141 <div class="impersonation-bar-item dw-mod">
6142 @RenderSwitchAccountButton()
6143 </div>
6144 <div class="impersonation-bar-item dw-mod">
6145 @RenderStopImpersonationButton()
6146 </div>
6147 </div>
6148 }
6149 }
6150
6151 @helper RenderSwitchAccountButton() {
6152 @Render(new Button
6153 {
6154 Href = "/Default.aspx?ID=" + impersonationPageId,
6155 ButtonType = ButtonType.Button,
6156 ButtonLayout = ButtonLayout.Clean,
6157 Title = Translate("Switch account"),
6158 Icon = new Icon {
6159 Name = "fa-users",
6160 Prefix = "fal",
6161 LabelPosition = IconLabelPosition.After
6162 },
6163 CssClass = "u-no-margin u-color-inherit"
6164 })
6165 }
6166
6167 @helper RenderStopImpersonationForm()
6168 {
6169 string secondaryUserName = getUserName(Model.CurrentSecondaryUser);
6170 string userName = getUserName(Pageview.User);
6171 int pageId = Model.TopPage.ID;
6172
6173 <form method="post" class="u-no-margin">
6174 @Render(new Button
6175 {
6176 ButtonType = ButtonType.Submit,
6177 ButtonLayout = ButtonLayout.Secondary,
6178 Title = Translate("Sign out as") + " " + userName,
6179 Href = "/Default.aspx?ID=" + impersonationPageId,
6180 CssClass = "btn--full",
6181 Name = "DwExtranetRemoveSecondaryUser"
6182 })
6183
6184 @Render(new Button
6185 {
6186 ButtonType = ButtonType.Submit,
6187 ButtonLayout = ButtonLayout.Secondary,
6188 Title = Translate("Sign out as") + " " + secondaryUserName,
6189 Href = "/Admin/Public/ExtranetLogoff.aspx?ID=" + pageId,
6190 CssClass = "btn--full",
6191 Name = "DwExtranetRemoveSecondaryUser"
6192 })
6193 </form>
6194 }
6195
6196 @helper RenderStopImpersonationButton() {
6197 @Render(new Button
6198 {
6199 ButtonType = ButtonType.Button,
6200 ButtonLayout = ButtonLayout.Clean,
6201 Title = Translate("Sign out"),
6202 Icon = new Icon {
6203 Name = "fa-sign-out",
6204 Prefix = "fal",
6205 LabelPosition = IconLabelPosition.After
6206 },
6207 OnClick = "document.getElementById('StopImpersonationModalTrigger').checked = true",
6208 CssClass = "u-no-margin"
6209 })
6210 }
6211
6212 @helper RenderImpersonationControls()
6213 {
6214 <div class="impersonation__controls">
6215 @RenderViewListLink()
6216 @RenderSearchBox()
6217 </div>
6218 @RenderResultsList()
6219 }
6220
6221 @helper RenderViewListLink()
6222 {
6223 string title = impersonationLayout == "right-lower-box" ? Translate("View the list") : Translate("View the list of users you can sign in as");
6224 string buttonClasses = impersonationLayout == "right-lower-box" ? "impersonation__button btn btn--impersonation" : "impersonation__link impersonation__link";
6225
6226 @Render(new Link {
6227 ButtonLayout = ButtonLayout.None,
6228 Title = title,
6229 Href = "/Default.aspx?ID=" + impersonationPageId,
6230 CssClass = buttonClasses
6231 })
6232 }
6233
6234 @helper RenderSearchBox()
6235 {
6236 <div class="impersonation__search-wrap">
6237 <input placeholder="@Translate("Search users")" type="text" class="impersonation__search-field dw-mod" onkeyup="searchKeyUpHandler(event)" id="ImpersonationBoxSearchField">
6238 <div id="ImpersonationBoxSearchFind" class="impersonation__search-icon dw-mod" onclick="updateResults(document.getElementById('ImpersonationBoxSearchField').value)">
6239 <i class="fal fa-search"></i>
6240 </div>
6241 <div id="ImpersonationBoxSearchClear" class="impersonation__search-icon u-hidden dw-mod" onclick="clearResults();">
6242 <i class="fal fa-times"></i>
6243 </div>
6244 </div>
6245 }
6246
6247 @helper RenderTypeaheadSearch()
6248 {
6249 <div class="typeahead u-ta-right impersonation__typeahead js-typeahead dw-mod" id="ImpersonationSearchBar"
6250 data-page-size="5"
6251 data-search-feed-id="@impersonationFeed"
6252 data-result-page-id="@impersonationPageId"
6253 data-search-type="user-search"
6254 data-search-parameter-name="q">
6255
6256 <div class="typeahead-search-field">
6257 <input type="text" class="u-no-margin u-full-width js-typeahead-search-field" placeholder="@Translate("Search users")">
6258 <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>
6259 </div>
6260 </div>
6261 }
6262
6263 @helper RenderResultsList()
6264 {
6265 <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>
6266 }
6267
6268 @helper RenderSearchResultTemplate()
6269 {
6270 <script id="ImpersonationSearchResult" type="text/x-template">
6271 {{#.}}
6272 {{#Users}}
6273 <li class="impersonation__search-results-item impersonation-user">
6274 <form method="post" class="impersonation-user__form" name="account{{id}}">
6275 <input type="hidden" id="DWExtranetSecondaryUserSelector" name="DWExtranetSecondaryUserSelector" value="{{id}}">
6276 <div class="impersonation-user__info">
6277 <div class="impersonation-user__name">{{userName}}</div>
6278 <div class="impersonation-user__number">{{customerNumber}}</div>
6279 </div>
6280 @Render(new Button
6281 {
6282 ButtonType = ButtonType.Submit,
6283 ButtonLayout = ButtonLayout.Secondary,
6284 Title = Translate("Sign in as"),
6285 CssClass = "impersonation-user__sign-in-btn" + (impersonationLayout != "bar" ? " btn--impersonation" : "")
6286 })
6287 </form>
6288 </li>
6289 {{/Users}}
6290 {{#unless Users}}
6291 <li class="impersonation__search-results-item impersonation__search-results-item--not-found">
6292 @Translate("Your search gave 0 results")
6293 </li>
6294 {{/unless}}
6295 {{/.}}
6296 </script>
6297 }
6298
6299 @helper RenderSearchScripts()
6300 {
6301 <script>
6302 let inputDelayTimer;
6303 function searchKeyUpHandler(e) {
6304 clearTimeout(inputDelayTimer);
6305 let value = e.target.value;
6306 if (value != "") {
6307 inputDelayTimer = setTimeout(function () {
6308 updateResults(value);
6309 }, 500);
6310 } else {
6311 clearResults();
6312 }
6313 };
6314
6315 function updateResults(value) {
6316 if (value == "") {
6317 return null;
6318 }
6319 HandlebarsBolt.UpdateContent("ImpersonationBoxSearchResults", "/Default.aspx?ID=@impersonationFeed&q=" + value);
6320 document.getElementById("ImpersonationBoxSearchFind").classList.add("u-hidden");
6321 document.getElementById("ImpersonationBoxSearchClear").classList.remove("u-hidden");
6322 }
6323
6324 function clearResults() {
6325 document.getElementById("ImpersonationBoxSearchField").value = "";
6326 HandlebarsBolt.CleanContainer("ImpersonationBoxSearchResults");
6327 document.getElementById("ImpersonationBoxSearchFind").classList.remove("u-hidden");
6328 document.getElementById("ImpersonationBoxSearchClear").classList.add("u-hidden");
6329 }
6330 </script>
6331 }
6332 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
6333
6334 @using System
6335 @using System.Web
6336 @using System.Collections.Generic
6337 @using Dynamicweb.Rapido.Blocks.Extensibility
6338 @using Dynamicweb.Rapido.Blocks
6339
6340 @{
6341 BlocksPage miniCartBlocksPage = BlocksPage.GetBlockPage("Master");
6342 string orderlinesView = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("OrderlinesView") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("OrderlinesView").SelectedValue : "table";
6343
6344 Block orderLines = new Block
6345 {
6346 Id = "MiniCartOrderLines",
6347 SkipRenderBlocksList = true,
6348 BlocksList = new List<Block>
6349 {
6350 new Block {
6351 Id = "MiniCartOrderLinesList",
6352 SortId = 20,
6353 Template = RenderMiniCartOrderLinesList()
6354 }
6355 }
6356 };
6357
6358 Block orderlinesScriptTemplates = new Block
6359 {
6360 Id = "OrderlinesScriptTemplates"
6361 };
6362
6363 if (orderlinesView == "table")
6364 {
6365 orderLines.Template = RenderMiniCartOrderLinesTable();
6366 orderLines.BlocksList.Add(
6367 new Block
6368 {
6369 Id = "MiniCartOrderlinesTableHeader",
6370 SortId = 10,
6371 Template = RenderMiniCartOrderLinesHeader()
6372 }
6373 );
6374
6375 orderlinesScriptTemplates.Template = RenderMiniCartScriptsTableTemplates();
6376 }
6377 else
6378 {
6379 orderLines.Template = RenderMiniCartOrderLinesBlocks();
6380 orderlinesScriptTemplates.Template = RenderMiniCartScriptsListTemplates();
6381 }
6382
6383 miniCartBlocksPage.Add("MasterBottomSnippets", orderlinesScriptTemplates);
6384
6385 Block miniCartScriptTemplates = new Block()
6386 {
6387 Id = "MasterMiniCartTemplates",
6388 SortId = 1,
6389 Template = RenderMiniCartScriptTemplates(),
6390 SkipRenderBlocksList = true,
6391 BlocksList = new List<Block>
6392 {
6393 orderLines,
6394 new Block {
6395 Id = "MiniCartFooter",
6396 Template = RenderMiniCartFooter(),
6397 SortId = 50,
6398 SkipRenderBlocksList = true,
6399 BlocksList = new List<Block>
6400 {
6401 new Block {
6402 Id = "MiniCartSubTotal",
6403 Template = RenderMiniCartSubTotal(),
6404 SortId = 30
6405 },
6406 new Block {
6407 Id = "MiniCartFees",
6408 Template = RenderMiniCartFees(),
6409 SortId = 40
6410 },
6411 new Block {
6412 Id = "MiniCartPoints",
6413 Template = RenderMiniCartPoints(),
6414 SortId = 50
6415 },
6416 new Block {
6417 Id = "MiniCartTotal",
6418 Template = RenderMiniCartTotal(),
6419 SortId = 60
6420 },
6421 new Block {
6422 Id = "MiniCartDisclaimer",
6423 Template = RenderMiniCartDisclaimer(),
6424 SortId = 70
6425 },
6426 new Block {
6427 Id = "MiniCartActions",
6428 Template = RenderMiniCartActions(),
6429 SortId = 80
6430 }
6431 }
6432 }
6433 }
6434 };
6435
6436 miniCartBlocksPage.Add("MasterBottomSnippets", miniCartScriptTemplates);
6437 }
6438
6439 @helper RenderMiniCartScriptsTableTemplates()
6440 {
6441 <script id="MiniCartOrderline" type="text/x-template">
6442 {{#unless isEmpty}}
6443 <tr>
6444 <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>
6445 <td class="u-va-middle">
6446 <a href="{{link}}" class="mini-cart-orderline__name" title="{{name}}">{{name}}</a>
6447 {{#if variantname}}
6448 <a href="{{link}}" class="mini-cart-orderline__name mini-cart-orderline__name--sm">{{variantname}}</a>
6449 {{/if}}
6450 {{#if unitname}}
6451 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm">{{unitname}}</div>
6452 {{/if}}
6453 </td>
6454 <td class="u-ta-right u-va-middle">{{quantity}}</td>
6455 <td class="u-ta-right u-va-middle">
6456 {{#if pointsTotal}}
6457 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points")
6458 {{else}}
6459 {{totalprice}}
6460 {{/if}}
6461 </td>
6462 </tr>
6463 {{/unless}}
6464 </script>
6465
6466 <script id="MiniCartOrderlineDiscount" type="text/x-template">
6467 {{#unless isEmpty}}
6468 <tr class="table__row--no-border">
6469 <td class="u-w60px"> </td>
6470 <td><div class="mini-cart-orderline__name dw-mod">{{name}}</div></td>
6471 <td class="u-ta-right"> </td>
6472 <td class="u-ta-right">{{totalprice}}</td>
6473 </tr>
6474 {{/unless}}
6475 </script>
6476 }
6477
6478 @helper RenderMiniCartScriptsListTemplates()
6479 {
6480 int cartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
6481
6482 <script id="MiniCartOrderline" type="text/x-template">
6483 {{#unless isEmpty}}
6484 <div class="mini-cart-orderline grid dw-mod">
6485 <div class="grid__col-4">
6486 <a href="{{link}}" class="{{hideimage}}">
6487 <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}}">
6488 </a>
6489 </div>
6490 <div class="grid__col-8">
6491 <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>
6492 {{#if variantname}}
6493 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Variant"): {{variantname}}</div>
6494 {{/if}}
6495 {{#if unitname}}
6496 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Unit"): {{unitname}}</div>
6497 {{/if}}
6498 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Qty"): {{quantity}}</div>
6499
6500 <div class="grid__cell-footer">
6501 <div class="grid__cell">
6502 <div class="u-pull--left mini-cart-orderline__price dw-mod">
6503 {{#if pointsTotal}}
6504 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points")
6505 {{else}}
6506 {{totalprice}}
6507 {{/if}}
6508 </div>
6509 <button type="button"
6510 title="@Translate("Remove orderline")"
6511 class="btn btn--clean btn--condensed u-pull--right mini-cart-orderline__remove-btn dw-mod"
6512 onclick="{{#if googleImpression}}googleImpressionRemoveFromCart({{googleImpression}});{{/if}}Cart.UpdateCart('miniCartContent', '/Default.aspx?ID=@cartFeedPageId', 'CartCmd=DelOrderLine&key={{orderLineId}}&redirect=false', true);">@Translate("Remove")</button>
6513 </div>
6514 </div>
6515 </div>
6516 </div>
6517 {{/unless}}
6518 </script>
6519
6520 <script id="MiniCartOrderlineDiscount" type="text/x-template">
6521 {{#unless isEmpty}}
6522 <div class="mini-cart-orderline mini-cart-orderline--discount grid dw-mod">
6523 <div class="grid__col-4">
6524 <div class="mini-cart-orderline__name mini-cart-orderline__name dw-mod">{{name}}</div>
6525 </div>
6526 <div class="grid__col-8">{{totalprice}}</div>
6527 </div>
6528 {{/unless}}
6529 </script>
6530 }
6531
6532 @helper RenderMiniCartScriptTemplates()
6533 {
6534 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterMiniCartTemplates").OrderBy(item => item.SortId).ToList();
6535 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID"));
6536 string cartPageLink = string.Concat("/Default.aspx?ID=", GetPageIdByNavigationTag("CartPage"));
6537 bool miniCartUseGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID"));
6538
6539 <script id="MiniCartContent" type="text/x-template">
6540 {{#.}}
6541 {{#unless isEmpty}}
6542 @if (miniCartUseGoogleTagManager)
6543 {
6544 <text>{{{googleEnchantImpressionEmptyCart OrderLines}}}</text>
6545 }
6546 @RenderBlockList(subBlocks)
6547 {{/unless}}
6548 {{/.}}
6549 </script>
6550 }
6551
6552 @helper RenderMiniCartOrderLinesTable()
6553 {
6554 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartOrderLines").OrderBy(item => item.SortId).ToList();
6555
6556 <div class="u-overflow-auto">
6557 <table class="table mini-cart-table dw-mod">
6558 @RenderBlockList(subBlocks)
6559 </table>
6560 </div>
6561 }
6562
6563 @helper RenderMiniCartOrderLinesBlocks()
6564 {
6565 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartOrderLines").OrderBy(item => item.SortId).ToList();
6566
6567 <div class="u-overflow-auto">
6568 @RenderBlockList(subBlocks)
6569 </div>
6570 }
6571
6572 @helper RenderMiniCartOrderLinesHeader()
6573 {
6574 <thead>
6575 <tr>
6576 <td> </td>
6577 <td>@Translate("Product")</td>
6578 <td class="u-ta-right">@Translate("Qty")</td>
6579 <td class="u-ta-right" width="120">@Translate("Price")</td>
6580 </tr>
6581 </thead>
6582 }
6583
6584 @helper RenderMiniCartOrderLinesList()
6585 {
6586 <text>
6587 {{#OrderLines}}
6588 {{#ifCond template "===" "CartOrderline"}}
6589 {{>MiniCartOrderline}}
6590 {{/ifCond}}
6591 {{#ifCond template "===" "CartOrderlineMobile"}}
6592 {{>MiniCartOrderline}}
6593 {{/ifCond}}
6594 {{#ifCond template "===" "CartOrderlineDiscount"}}
6595 {{>MiniCartOrderlineDiscount}}
6596 {{/ifCond}}
6597 {{/OrderLines}}
6598 </text>
6599 }
6600
6601 @helper RenderMiniCartFees()
6602 {
6603 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly");
6604 if (!pointShop)
6605 {
6606 <text>
6607 {{#unless hidePaymentfee}}
6608 <div class="grid">
6609 <div class="grid__col-6 grid__col--bleed-y">
6610 {{paymentmethod}}
6611 </div>
6612 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{paymentfee}}</div>
6613 </div>
6614 {{/unless}}
6615 </text>
6616 }
6617 <text>
6618 {{#unless hideShippingfee}}
6619 <div class="grid">
6620 <div class="grid__col-6 grid__col--bleed-y">
6621 {{shippingmethod}}
6622 </div>
6623 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{shippingfee}}</div>
6624 </div>
6625 {{/unless}}
6626 </text>
6627 <text>
6628 {{#if hasTaxSettings}}
6629 <div class="grid">
6630 <div class="grid__col-6 grid__col--bleed-y">@Translate("Sales Tax")</div>
6631 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{totaltaxes}}</div>
6632 </div>
6633 {{/if}}
6634 </text>
6635 }
6636
6637 @helper RenderMiniCartFooter()
6638 {
6639 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartFooter").OrderBy(item => item.SortId).ToList();
6640
6641 <div class="mini-cart__footer u-border-top u-padding-top dw-mod">
6642 @RenderBlockList(subBlocks)
6643 </div>
6644 }
6645
6646 @helper RenderMiniCartActions()
6647 {
6648 int cartPageId = GetPageIdByNavigationTag("CartPage");
6649
6650 <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>
6651 <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>
6652 }
6653
6654 @helper RenderMiniCartPoints()
6655 {
6656 <text>
6657 {{#if earnings}}
6658 <div class="grid">
6659 <div class="grid__col-6 grid__col--bleed-y">@Translate("Earnings")</div>
6660 <div class="grid__col-6 grid__col--bleed-y grid--align-end">
6661 <div>
6662 <span class="u-color--loyalty-points">{{earnings}}</span> @Translate("points")
6663 </div>
6664 </div>
6665 </div>
6666 {{/if}}
6667 </text>
6668 }
6669
6670 @helper RenderMiniCartSubTotal()
6671 {
6672 bool hasTaxSettings = Dynamicweb.Rapido.Services.Countries.HasTaxSettings(Model.Cart.ID);
6673 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly");
6674 if (!pointShop)
6675 {
6676 <text>
6677 {{#unless hideSubTotal}}
6678 <div class="grid dw-mod u-bold">
6679 <div class="grid__col-6 grid__col--bleed-y">@Translate("Subtotal")</div>
6680 <div class="grid__col-6 grid__col--bleed-y grid--align-end">
6681 @if (hasTaxSettings)
6682 {
6683 <text>{{subtotalpricewithouttaxes}}</text>
6684 }
6685 else
6686 {
6687 <text>{{subtotalprice}}</text>
6688 }
6689 </div>
6690 </div>
6691 {{/unless}}
6692 </text>
6693 }
6694 }
6695
6696 @helper RenderMiniCartTotal()
6697 {
6698 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly");
6699
6700 <div class="mini-cart-totals grid u-border-top u-margin-top dw-mod">
6701 <div class="grid__col-6">@Translate("Total")</div>
6702 <div class="grid__col-6 grid--align-end">
6703 <div>
6704 @if (pointShop)
6705 {
6706 <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points")
6707 }
6708 else
6709 {
6710 <text>{{totalprice}}</text>
6711 }
6712 </div>
6713 </div>
6714 </div>
6715 }
6716
6717 @helper RenderMiniCartDisclaimer()
6718 {
6719 <text>
6720 {{#if showCheckoutDisclaimer}}
6721 <div class="grid u-margin-bottom u-ta-right">
6722 <small class="grid__col-12">{{checkoutDisclaimer}}</small>
6723 </div>
6724 {{/if}}
6725 </text>
6726 }
6727 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
6728
6729 @using Dynamicweb.Rapido.Blocks.Extensibility
6730 @using Dynamicweb.Rapido.Blocks
6731 @using Dynamicweb.Rapido.Blocks.Components.General
6732 @using Dynamicweb.Rapido.Blocks.Components
6733 @using Dynamicweb.Rapido.Services
6734
6735 @{
6736 string addToCartNotificationType = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("AddToCartNotificationType") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("AddToCartNotificationType").SelectedValue : "";
6737 string addToCartNotificationMiniCartLayout = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout").SelectedValue : "dropdown";
6738 bool addToCartHideCartIcon = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart");
6739
6740 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed() && !string.IsNullOrEmpty(addToCartNotificationType))
6741 {
6742 if (addToCartNotificationType == "modal")
6743 {
6744 Block addToCartNotificationModal = new Block
6745 {
6746 Id = "AddToCartNotificationModal",
6747 Template = RenderAddToCartNotificationModal()
6748 };
6749
6750 Block addToCartNotificationScript = new Block
6751 {
6752 Id = "AddToCartNotificationScript",
6753 Template = RenderAddToCartNotificationModalScript()
6754 };
6755 BlocksPage.GetBlockPage("Master").Add("MasterTopSnippets", addToCartNotificationModal);
6756 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", addToCartNotificationScript);
6757 }
6758 else if (addToCartNotificationType == "toggle" && addToCartNotificationMiniCartLayout != "none" && !addToCartHideCartIcon && Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet")
6759 {
6760 Block addToCartNotificationScript = new Block
6761 {
6762 Id = "AddToCartNotificationScript",
6763 Template = RenderAddToCartNotificationToggleScript()
6764 };
6765 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", addToCartNotificationScript);
6766 }
6767 }
6768 }
6769
6770 @helper RenderAddToCartNotificationModal()
6771 {
6772 <div id="LastAddedProductModal" data-template="LastAddedProductTemplate"></div>
6773 }
6774
6775 @helper RenderAddToCartNotificationModalScript()
6776 {
6777 int cartPageId = GetPageIdByNavigationTag("CartPage");
6778
6779 <script id="LastAddedProductTemplate" type="text/x-template">
6780 @{
6781
6782 Modal lastAddedProduct = new Modal
6783 {
6784 Id = "LastAddedProduct",
6785 Heading = new Heading
6786 {
6787 Level = 2,
6788 Title = Translate("Product is added to the cart")
6789 },
6790 Width = ModalWidth.Md,
6791 BodyTemplate = RenderModalContent()
6792 };
6793
6794 lastAddedProduct.AddActions(
6795 new Button
6796 {
6797 ButtonType = ButtonType.Button,
6798 ButtonLayout = ButtonLayout.Secondary,
6799 Title = Translate("Continue shopping"),
6800 CssClass = "u-pull--left u-no-margin btn--sm",
6801 OnClick = "document.getElementById('LastAddedProductModalTrigger').checked = false"
6802 },
6803 new Link
6804 {
6805 Href = "/Default.aspx?ID=" + cartPageId,
6806 ButtonLayout = ButtonLayout.Secondary,
6807 CssClass = "u-pull--right u-no-margin btn--sm",
6808 Title = Translate("Proceed to checkout"),
6809 OnClick = "document.getElementById('LastAddedProductModalTrigger').checked = false"
6810 }
6811 );
6812
6813 @Render(lastAddedProduct)
6814 }
6815 </script>
6816 <script>
6817 document.addEventListener('addToCart', function (event) {
6818 Cart.ShowLastAddedProductModal(event.detail);
6819 });
6820 </script>
6821 }
6822
6823 @helper RenderModalContent()
6824 {
6825 <div class="grid">
6826 <div class="grid__col-2">
6827 @Render(new Image { Path = "{{ productInfo.image }}", Link = "{{ productInfo.link }}", Title = "{{ productInfo.name }}", DisableImageEngine = true })
6828 </div>
6829 <div class="u-padding grid--align-self-center">
6830 <span>{{quantity}}</span> x
6831 </div>
6832 <div class="grid__col-auto grid--align-self-center">
6833 <div>{{productInfo.name}}</div>
6834 {{#if productInfo.variantName}}
6835 <small class="u-margin-bottom-5px">{{productInfo.variantName}}</small>
6836 {{/if}}
6837 {{#if productInfo.unitName}}
6838 <small class="u-margin-bottom-5px">{{productInfo.unitName}}</small>
6839 {{/if}}
6840 </div>
6841 </div>
6842 }
6843
6844 @helper RenderAddToCartNotificationToggleScript()
6845 {
6846 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
6847
6848 <script>
6849 document.addEventListener('addToCart', function () {
6850 Cart.ToggleMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '@miniCartFeedPageId');
6851 });
6852 </script>
6853 }
6854 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
6855
6856 @using System
6857 @using System.Web
6858 @using System.Collections.Generic
6859 @using Dynamicweb.Rapido.Blocks.Extensibility
6860 @using Dynamicweb.Rapido.Blocks
6861 @using Dynamicweb.Rapido.Blocks.Components.General
6862
6863 @functions {
6864 BlocksPage footerBlocksPage = BlocksPage.GetBlockPage("Master");
6865 }
6866
6867 @{
6868 string footerColumnOneContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnOne").GetString("Content");
6869 string footerColumnTwoContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnTwo").GetString("Content");
6870 string footerColumnThreeContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnThree").GetString("Content");
6871 string footerColumnOneHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnOne").GetString("Header");
6872 string footerColumnTwoHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnTwo").GetString("Header");
6873 string footerColumnThreeHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnThree").GetString("Header");
6874
6875 Block masterFooterContent = new Block()
6876 {
6877 Id = "MasterFooterContent",
6878 SortId = 10,
6879 Template = RenderFooter(),
6880 SkipRenderBlocksList = true
6881 };
6882 footerBlocksPage.Add(MasterBlockId.MasterFooter, masterFooterContent);
6883
6884 if (!string.IsNullOrEmpty(footerColumnOneContent) || !string.IsNullOrEmpty(footerColumnOneHeader))
6885 {
6886 Block masterFooterColumnOne = new Block
6887 {
6888 Id = "MasterFooterColumnOne",
6889 SortId = 10,
6890 Template = RenderFooterColumn(footerColumnOneHeader, footerColumnOneContent),
6891 Design = new Design
6892 {
6893 Size = "auto",
6894 RenderType = RenderType.Column
6895 }
6896 };
6897 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnOne);
6898 }
6899
6900 if (!string.IsNullOrEmpty(footerColumnTwoContent) || !string.IsNullOrEmpty(footerColumnTwoHeader))
6901 {
6902 Block masterFooterColumnTwo = new Block
6903 {
6904 Id = "MasterFooterColumnTwo",
6905 SortId = 20,
6906 Template = RenderFooterColumn(footerColumnTwoHeader, footerColumnTwoContent),
6907 Design = new Design
6908 {
6909 Size = "auto",
6910 RenderType = RenderType.Column
6911 }
6912 };
6913 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnTwo);
6914 }
6915
6916 if (!string.IsNullOrEmpty(footerColumnThreeContent) || !string.IsNullOrEmpty(footerColumnThreeHeader))
6917 {
6918 Block masterFooterColumnThree = new Block
6919 {
6920 Id = "MasterFooterColumnThree",
6921 SortId = 30,
6922 Template = RenderFooterColumn(footerColumnThreeHeader, footerColumnThreeContent),
6923 Design = new Design
6924 {
6925 Size = "auto",
6926 RenderType = RenderType.Column
6927 }
6928 };
6929 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnThree);
6930 }
6931
6932 if (Model.Area.Item.GetItem("Layout").GetBoolean("FooterNewsletterSignUp"))
6933 {
6934 Block masterFooterNewsletterSignUp = new Block
6935 {
6936 Id = "MasterFooterNewsletterSignUp",
6937 SortId = 40,
6938 Template = RenderFooterNewsletterSignUp(),
6939 Design = new Design
6940 {
6941 Size = "auto",
6942 RenderType = RenderType.Column
6943 }
6944 };
6945 footerBlocksPage.Add("MasterFooterContent", masterFooterNewsletterSignUp);
6946 }
6947
6948 if (Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks") != null && Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks").Count > 0)
6949 {
6950 Block masterFooterSocialLinks = new Block
6951 {
6952 Id = "MasterFooterSocialLinks",
6953 SortId = 50,
6954 Template = RenderFooterSocialLinks(),
6955 Design = new Design
6956 {
6957 Size = "auto",
6958 RenderType = RenderType.Column
6959 }
6960 };
6961 footerBlocksPage.Add("MasterFooterContent", masterFooterSocialLinks);
6962 }
6963
6964 if (Model.Area.Item.GetItem("Layout").GetItems("FooterPayments") != null && Model.Area.Item.GetItem("Layout").GetItems("FooterPayments").Count > 0)
6965 {
6966 Block masterFooterPayments = new Block
6967 {
6968 Id = "MasterFooterPayments",
6969 SortId = 60,
6970 Template = RenderFooterPayments(),
6971 Design = new Design
6972 {
6973 Size = "12",
6974 RenderType = RenderType.Column
6975 }
6976 };
6977 footerBlocksPage.Add("MasterFooterContent", masterFooterPayments);
6978 }
6979
6980 Block masterFooterCopyright = new Block
6981 {
6982 Id = "MasterFooterCopyright",
6983 SortId = 70,
6984 Template = RenderFooterCopyright(),
6985 Design = new Design
6986 {
6987 Size = "12",
6988 RenderType = RenderType.Column
6989 }
6990 };
6991 footerBlocksPage.Add("MasterFooterContent", masterFooterCopyright);
6992 }
6993
6994 @helper RenderFooter()
6995 {
6996 List<Block> subBlocks = this.footerBlocksPage.GetBlockListById("MasterFooterContent").OrderBy(item => item.SortId).ToList();
6997
6998 <footer class="footer no-print dw-mod">
6999 <div class="center-container top-container__center-container dw-mod">
7000 <div class="grid grid--external-bleed-x">
7001 @RenderBlockList(subBlocks)
7002 </div>
7003 </div>
7004 </footer>
7005 }
7006
7007 @helper RenderFooterColumn(string header, string content)
7008 {
7009 <h3 class="footer__heading dw-mod">@header</h3>
7010 <div class="footer__content dw-mod">
7011 @content
7012 </div>
7013 }
7014
7015 @helper RenderFooterNewsletterSignUp()
7016 {
7017 string newsletterSignUpPageId = GetPageIdByNavigationTag("NewsletterSignUp").ToString();
7018 Form form = new Form { Action = "/Default.aspx", Method = FormMethod.Get, Enctype = FormEnctype.multipart };
7019
7020 form.Add(new HiddenField { Name = "ID", Value = newsletterSignUpPageId });
7021 form.Add(new Text { Content = "<p>" + Translate("Sign up if you would like to receive occasional treats from us") + "</p>" });
7022 form.Add(new TextField {
7023 Id = "NewsletterEmail", Name = "NewsletterEmail", Placeholder = Translate("Your email address"),
7024 Type = TextFieldType.Email,
7025 ActionButton = new Button {
7026 ButtonType = ButtonType.Submit, Id="Submitter", Title = Translate("Go"), OnClick = "Buttons.LockButton(event)", CssClass = "btn--condensed"
7027 }
7028 });
7029
7030 <h3 class="footer__heading dw-mod">@Translate("Mailing list")</h3>
7031 <div class="footer__content dw-mod">
7032 @Render(form)
7033 </div>
7034 }
7035
7036 @helper RenderFooterSocialLinks()
7037 {
7038 <h3 class="footer__heading dw-mod">@Translate("Social links")</h3>
7039 <div class="footer__content dw-mod">
7040 <div class="collection dw-mod">
7041 @foreach (var socialitem in Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks"))
7042 {
7043 var socialIcon = socialitem.GetValue("Icon") as Dynamicweb.Frontend.ListViewModel;
7044 string socialIconClass = socialIcon.SelectedValue;
7045 string socialIconTitle = socialIcon.SelectedName;
7046 string socialLink = socialitem.GetString("Link");
7047
7048 <a href="@socialLink" target="_blank" title="@socialIconTitle" class="u-margin-bottom-5px" rel="noopener"><i class="@socialIconClass fa-2x"></i></a>
7049 }
7050 </div>
7051 </div>
7052 }
7053
7054 @helper RenderFooterPayments()
7055 {
7056 <div class="footer__content dw-mod">
7057 <div class="collection dw-mod">
7058 @foreach (var payment in Model.Area.Item.GetItem("Layout").GetItems("FooterPayments"))
7059 {
7060 var paymentItem = payment.GetValue("CardTypeOrVerifiedPayment") as Dynamicweb.Frontend.ListViewModel;
7061 string paymentImage = null;
7062 string paymentTitle = paymentItem.SelectedName;
7063 ListOptionViewModel selected = paymentItem.SelectedOptions.FirstOrDefault();
7064 if (selected != null)
7065 {
7066 paymentImage = selected.Icon;
7067 }
7068
7069 <div class="footer__card-type">
7070 <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" />
7071 </div>
7072 }
7073 </div>
7074 </div>
7075 }
7076
7077 @helper RenderFooterCopyright()
7078 {
7079 <div class="grid__col-12 footer__copyright dw-mod">
7080 <p>@Model.Area.Item.GetItem("Layout").GetString("FooterCopyrightText")</p>
7081 </div>
7082 }
7083 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
7084
7085 @using System
7086 @using System.Web
7087 @using System.Collections.Generic
7088 @using Dynamicweb.Rapido.Blocks.Extensibility
7089 @using Dynamicweb.Rapido.Blocks
7090
7091 @{
7092 BlocksPage searchBlocksPage = BlocksPage.GetBlockPage("Master");
7093 bool navigationItemsHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch");
7094 bool isFavoriteList = !string.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("ListID"));
7095
7096 if (!navigationItemsHideSearch || isFavoriteList)
7097 {
7098 Block masterSearchScriptTemplates = new Block()
7099 {
7100 Id = "MasterSearchScriptTemplates",
7101 SortId = 1,
7102 Template = RenderSearchScriptTemplates()
7103 };
7104
7105 searchBlocksPage.Add(MasterBlockId.MasterBottomSnippets, masterSearchScriptTemplates);
7106 }
7107 }
7108
7109 @helper RenderSearchScriptTemplates()
7110 {
7111 int productsPageId = GetPageIdByNavigationTag("ProductsPage");
7112 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID;
7113 bool useFacebookPixel = !string.IsNullOrWhiteSpace(Pageview.AreaSettings.GetItem("Settings").GetString("FacebookPixelID"));
7114 bool onlyPreview = Model.Area.Item.GetItem("Ecommerce").GetBoolean("OnlyPreviewForAnonymous") && Model.CurrentUser.ID == 0;
7115 bool useGoogleTagManager = !string.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("GoogleTagManagerID"));
7116 bool showPrice = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HidePriceInSearchResults");
7117 bool showAddToCartButton = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HideAddToCartButton");
7118 bool showViewButton = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HideViewButton");
7119 bool showAddToDownloadButton = Pageview.AreaSettings.GetItem("Layout").GetBoolean("ShowAddToDownloadButton");
7120 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly");
7121
7122 <script id="SearchGroupsTemplate" type="text/x-template">
7123 {{#.}}
7124 <li class="dropdown__item dw-mod" onclick="Search.UpdateGroupSelection(this)" data-group-id="{{id}}">{{name}}</li>
7125 {{/.}}
7126 </script>
7127
7128 <script id="SearchProductsTemplate" type="text/x-template">
7129 {{#each .}}
7130 {{#Product}}
7131 {{#ifCond template "!==" "SearchMore"}}
7132 <li class="dropdown__item dropdown__item--seperator dw-mod">
7133 @if (useFacebookPixel)
7134 {
7135 <text>{{{facebookPixelSearch name number priceDouble currency searchParameter}}}</text>
7136 }
7137 @if (useGoogleTagManager)
7138 {
7139 <text>{{{googleEnchantImpression 'Search results' currency googleImpression}}}</text>
7140 }
7141 <div>
7142 <a href="{{link}}" class="js-typeahead-link u-color-inherit u-pull--left" onclick="{{googleImpressionClick}}" title="{{name}}">
7143 <div class="u-margin-right u-pull--left {{noimage}} u-hidden-xs u-hidden-xxs"><img src="{{PerfionImageSrc imageGuid 50 50}}" alt="{{name}}"></div>
7144
7145 <div class="u-pull--left">
7146 <div class="u-bold u-max-w220px u-truncate-text js-typeahead-name">{{name}}</div>
7147 @if (showPrice && !onlyPreview)
7148 {
7149 if (pointShopOnly)
7150 {
7151 <text>
7152 {{#if havePointPrice}}
7153 <div>
7154 <span class="u-color--loyalty-points">{{points}}</span> @Translate("points")
7155 </div>
7156 {{else}}
7157 <small class="help-text u-no-margin">@Translate("Not available")</small>
7158 {{/if}}
7159 {{#unless canBePurchasedWithPoints}}
7160 {{#if havePointPrice}}
7161 <small class="help-text u-no-margin">@Translate("Not enough points to buy this")</small>
7162 {{/if}}
7163 {{/unless}}
7164 </text>
7165 }
7166 else
7167 {
7168 <div>{{price}}</div>
7169 }
7170 }
7171 </div>
7172 </a>
7173 <div class="u-margin-left u-pull--right">
7174 @if (showAddToCartButton && !onlyPreview) {
7175 if (pointShopOnly)
7176 {
7177 <button type="button" class="btn btn--primary btn--condensed btn--full u-no-margin dw-mod {{hideBuyOptions}} js-ignore-click-outside {{#unless canBePurchasedWithPoints}}js-stay-disabled{{/unless}}" name="CartCmd" value="addWithPoints"
7178 onclick="Cart.AddToCart(event, {id: '{{productId}}',quantity: 1,buyForPoints: true,productInfo: {{productInfo}}}); {{facebookPixelAction}}"
7179 {{disabledBuyButton}}>
7180 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue js-ignore-click-outside"></i>
7181 </button>
7182 } else {
7183 <button type="button" class="btn btn--primary btn--condensed btn--full u-no-margin dw-mod {{hideBuyOptions}} js-ignore-click-outside"
7184 onclick="Cart.AddToCart(event, {id: '{{productId}}', quantity: 1,productInfo: {{productInfo}}}); {{facebookPixelAction}}">
7185 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue js-ignore-click-outside"></i>
7186 </button>
7187 }
7188 <a href="{{link}}" onclick="{{googleImpressionClick}}" class="btn btn--secondary btn--condensed btn--full u-no-margin dw-mod {{hideViewMore}} js-ignore-click-outside" title="@Translate("View")">@Translate("View")</a>
7189 }
7190 else if (showViewButton)
7191 {
7192 <a href="{{link}}" onclick="{{googleImpressionClick}}" class="btn btn--secondary btn--condensed btn--full u-no-margin dw-mod js-ignore-click-outside" title="@Translate("View")">@Translate("View")</a>
7193 }
7194 @if (showAddToDownloadButton)
7195 {
7196 <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}}">
7197 <i class="fas fa-plus js-button-icon"></i>
7198 </button>
7199 }
7200 </div>
7201 </div>
7202 </li>
7203 {{/ifCond}}
7204 {{#ifCond template "===" "SearchMore"}}
7205 {{>SearchMoreProducts}}
7206 {{/ifCond}}
7207 {{/Product}}
7208 {{else}}
7209 <li class="dropdown__item dropdown__item--seperator dw-mod">
7210 @Translate("Your search gave 0 results")
7211 </li>
7212 {{/each}}
7213 </script>
7214
7215 <script id="SearchMoreProducts" type="text/x-template">
7216 <li class="dropdown__item dropdown__item--not-selectable {{stickToBottom}} dw-mod">
7217 <a href="/Default.aspx?ID=@productsPageId&Search={{searchParameter}}&GroupID={{groupId}}" class="btn btn--primary btn--full u-no-margin dw-mod js-typeahead-link">
7218 @Translate("View all")
7219 </a>
7220 </li>
7221 </script>
7222
7223 <script id="SearchMorePages" type="text/x-template">
7224 <li class="dropdown__item dropdown__item--not-selectable {{stickToBottom}} dw-mod">
7225 <a href="/Default.aspx?ID=@contentSearchPageLink&Search={{searchParameter}}" class="btn btn--primary btn--full u-no-margin dw-mod js-typeahead-link">
7226 @Translate("View all")
7227 </a>
7228 </li>
7229 </script>
7230
7231 <script id="SearchPagesTemplate" type="text/x-template">
7232 {{#each .}}
7233 {{#ifCond template "!==" "SearchMore"}}
7234 <li class="dropdown__item dropdown__item--seperator dw-mod">
7235 <div>
7236 <a href="/Default.aspx?ID={{id}}" class="js-typeahead-link u-pull--left u-color-inherit">
7237 <div class="u-margin-right u-pull--left"><i class="fa {{icon}} u-w20px u-ta-center"></i></div>
7238 <div class="u-pull--left">
7239 <div class="u-bold u-truncate-text u-max-w220px js-typeahead-name">{{name}}</div>
7240 </div>
7241 </a>
7242 </div>
7243 </li>
7244 {{/ifCond}}
7245 {{#ifCond template "===" "SearchMore"}}
7246 {{>SearchMorePages}}
7247 {{/ifCond}}
7248 {{else}}
7249 <li class="dropdown__item dropdown__item--seperator dropdown__item--not-selectable dw-mod">
7250 @Translate("Your search gave 0 results")
7251 </li>
7252 {{/each}}
7253 </script>
7254
7255 <script id="SearchPagesTemplateWrap" type="text/x-template">
7256 <div class="dropdown__column-header">@Translate("Pages")</div>
7257 <ul class="dropdown__list u-min-w220px u-full-width u-margin-bottom dw-mod">
7258 {{>SearchPagesTemplate}}
7259 </ul>
7260 </script>
7261
7262 <script id="SearchProductsTemplateWrap" type="text/x-template">
7263 <div class="dropdown__column-header">@Translate("Products")</div>
7264 <ul class="dropdown__list u-min-w220px u-full-width u-margin-bottom dw-mod">
7265 {{>SearchProductsTemplate}}
7266 </ul>
7267 </script>
7268 }
7269
7270
7271 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
7272
7273 @using System
7274 @using System.Web
7275 @using System.Collections.Generic
7276 @using Dynamicweb.Rapido.Blocks.Extensibility
7277 @using Dynamicweb.Rapido.Blocks
7278 @using Dynamicweb.Ecommerce.Common
7279
7280 @{
7281 BlocksPage referencesBlocksPage = BlocksPage.GetBlockPage("Master");
7282
7283 Block masterScriptReferences = new Block()
7284 {
7285 Id = "MasterScriptReferences",
7286 SortId = 1,
7287 Template = RenderMasterScriptReferences()
7288 };
7289 referencesBlocksPage.Add(MasterBlockId.MasterReferences, masterScriptReferences);
7290 }
7291
7292 @helper RenderMasterScriptReferences() {
7293
7294 @* Custom: only load script if on newsletter page *@
7295 if (Pageview.ID == GetPageIdByNavigationTag("NewsletterSignUp"))
7296 {
7297 @* JQuery for mailchimp script *@
7298 <script type='text/javascript' src='//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js'></script>
7299 <script type='text/javascript'>
7300 (function ($) {
7301 window.fnames = new Array();
7302 window.ftypes = new Array();
7303 fnames[0] = 'EMAIL';
7304 ftypes[0] = 'email';
7305 fnames[1] = 'FNAME';
7306 ftypes[1] = 'text';
7307 fnames[2] = 'LNAME';
7308 ftypes[2] = 'text';
7309 fnames[3] = 'MMERGE3';
7310 ftypes[3] = 'text';
7311 fnames[4] = 'MMERGE4';
7312 ftypes[4] = 'text';
7313 fnames[5] = 'MMERGE5';
7314 ftypes[5] = 'text';
7315 fnames[6] = 'MMERGE6';
7316 ftypes[6] = 'text';
7317 fnames[7] = 'MMERGE7';
7318 ftypes[7] = 'text';
7319 }
7320 (jQuery));
7321 var $mcj = jQuery.noConflict(true);
7322 </script>
7323 }
7324
7325 <script src="/Files/Templates/Designs/Rapido/js/handlebars-v4.0.12.min.js" data-cookieconsent="ignore"></script>
7326 <script src="/Files/Templates/Designs/Rapido/js/master.min.js?v1.0" data-cookieconsent="ignore"></script>
7327
7328 if (Model.Area.Item.GetItem("Custom").GetBoolean("UseCustomJavascript"))
7329 {
7330 <script src="/Files/Templates/Designs/Rapido/js/custom.min.js?v1.2" data-cookieconsent="ignore"></script>
7331 PushPromise("/Files/Templates/Designs/Rapido/js/custom.min.js?v1.2");
7332 }
7333
7334 PushPromise("/Files/Templates/Designs/Rapido/js/handlebars-v4.0.12.min.js?v1.0");
7335 PushPromise("/Files/Templates/Designs/Rapido/js/master.min.js?v1.0");
7336 }
7337 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
7338
7339 @using System
7340 @using System.Web
7341 @using System.Collections.Generic
7342 @using Dynamicweb.Rapido.Blocks.Extensibility
7343 @using Dynamicweb.Rapido.Blocks
7344
7345 @{
7346 BlocksPage bottomSnippetsBlocksPage = BlocksPage.GetBlockPage("Master");
7347
7348 Block primaryBottomSnippets = new Block()
7349 {
7350 Id = "MasterJavascriptInitializers",
7351 SortId = 100,
7352 Template = RenderPrimaryBottomSnippets()
7353 };
7354 bottomSnippetsBlocksPage.Add(MasterBlockId.MasterReferences, primaryBottomSnippets);
7355
7356 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed())
7357 {
7358 Block miniCartPageId = new Block
7359 {
7360 Id = "MiniCartPageId",
7361 Template = RenderMiniCartPageId()
7362 };
7363 bottomSnippetsBlocksPage.Add(MasterBlockId.MasterReferences, miniCartPageId);
7364 }
7365 }
7366
7367 @helper RenderPrimaryBottomSnippets()
7368 {
7369 bool isWireframeMode = Model.Area.Item.GetItem("Settings").GetBoolean("WireframeMode");
7370 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID"));
7371
7372 if (isWireframeMode)
7373 {
7374 <script>
7375 Wireframe.Init(true);
7376 </script>
7377 }
7378
7379
7380 if (useGoogleTagManager)
7381 {
7382 <script>
7383 document.addEventListener('addToCart', function(event) {
7384 var googleImpression = JSON.parse(event.detail.productInfo.googleImpression);
7385 if (typeof googleImpression == "string") {
7386 googleImpression = JSON.parse(event.detail.productInfo.googleImpression);
7387 }
7388 dataLayer.push({
7389 'event': 'addToCart',
7390 'ecommerce': {
7391 'currencyCode': googleImpression.currency,
7392 'add': {
7393 'products': [{
7394 'name': googleImpression.name,
7395 'id': googleImpression.id,
7396 'price': googleImpression.price,
7397 'brand': googleImpression.brand,
7398 'category': googleImpression.category,
7399 'variant': googleImpression.variant,
7400 'quantity': event.detail.quantity
7401 }]
7402 }
7403 }
7404 });
7405 });
7406 </script>
7407 }
7408
7409 //if digitalwarehouse
7410 if (Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowDownloadCart"))
7411 {
7412 string cartContextId = Converter.ToString(HttpContext.Current.Application["DownloadCartContext"]);
7413
7414 if (string.IsNullOrEmpty(cartContextId))
7415 {
7416 var moduleProps = Dynamicweb.Modules.Properties.GetParagraphModuleSettings(GetPageIdByNavigationTag("DownloadCart"), "eCom_CartV2");
7417 var cartSettings = new Dynamicweb.Ecommerce.Cart.ModuleSettings(moduleProps);
7418 cartContextId = cartSettings.OrderContextID;
7419 HttpContext.Current.Application["DownloadCartContext"] = cartContextId;
7420 }
7421
7422 <script>
7423 let downloadCart = new DownloadCart({
7424 cartPageId: @GetPageIdByNavigationTag("MiniCartFeed"),
7425 contextId: "@cartContextId",
7426 addButtonText: "@Translate("Add")",
7427 removeButtonText: "@Translate("Remove")"
7428 });
7429 </script>
7430 }
7431
7432 @* Custom *@
7433 <script data-cookieconsent="ignore">
7434 let GlobalSettings = {
7435 PerfionApiUrl: '@GlobalSettingsHelper.GetValue(PicoGlobalSettingsNames.PerfionWebApiUrl)'
7436 }
7437 </script>
7438
7439 <!--$$Javascripts-->
7440 }
7441
7442 @helper RenderMiniCartPageId()
7443 {
7444 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
7445 <script>
7446 window.cartId = "@miniCartFeedPageId";
7447 </script>
7448 }
7449
7450
7451 @functions {
7452 public class ManifestIcon
7453 {
7454 public string src { get; set; }
7455 public string type { get; set; }
7456 public string sizes { get; set; }
7457 }
7458
7459 public class Manifest
7460 {
7461 public string name { get; set; }
7462 public string short_name { get; set; }
7463 public string start_url { get; set; }
7464 public string display { get; set; }
7465 public string background_color { get; set; }
7466 public string theme_color { get; set; }
7467 public List<ManifestIcon> icons { get; set; }
7468 }
7469 }
7470
7471 <!DOCTYPE html>
7472
7473 <html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName">
7474
7475
7476
7477 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@
7478 @RenderBlockList(masterPage.BlocksRoot.BlocksList)
7479
7480
7481
7482 @helper RenderMasterHead()
7483 {
7484 List<Block> subBlocks = this.masterPage.GetBlockListById("Head").OrderBy(item => item.SortId).ToList();
7485
7486 <head>
7487 <!-- Rapido version 3.4.3 -->
7488
7489 @RenderBlockList(subBlocks)
7490 </head>
7491
7492 }
7493
7494 @helper RenderMasterMetadata()
7495 {
7496 var swatches = new Dynamicweb.Content.Items.ColorSwatchService();
7497 var brandColors = swatches.GetColorSwatch(1);
7498 string brandColorOne = brandColors.Palette["BrandColor1"];
7499
7500 if (!String.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("AppName")) && Model.Area.Item.GetItem("Settings").GetFile("AppIcon") != null)
7501 {
7502 Manifest manifest = new Manifest
7503 {
7504 name = Model.Area.Item.GetItem("Settings").GetString("AppName"),
7505 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"),
7506 start_url = "/",
7507 display = "standalone",
7508 background_color = Model.Area.Item.GetItem("Settings").GetString("AppBackgroundColor"),
7509 theme_color = Model.Area.Item.GetItem("Settings").GetString("AppThemeColor")
7510 };
7511
7512 manifest.icons = new List<ManifestIcon> {
7513 new ManifestIcon {
7514 src = "/Admin/Public/GetImage.ashx?width=192&height=192&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded,
7515 sizes = "192x192",
7516 type = "image/png"
7517 },
7518 new ManifestIcon {
7519 src = "/Admin/Public/GetImage.ashx?width=512&height=512&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded,
7520 sizes = "512x512",
7521 type = "image/png"
7522 },
7523 new ManifestIcon {
7524 src = "/Admin/Public/GetImage.ashx?width=1024&height=1024&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded,
7525 sizes = "1024x1024",
7526 type = "image/png"
7527 }
7528 };
7529
7530 string manifestFilePath = HttpContext.Current.Request.MapPath("/Files/Templates/Designs/Rapido/manifest.json");
7531 string manifestJSON = Newtonsoft.Json.JsonConvert.SerializeObject(manifest);
7532 string currentManifest = File.ReadAllText(manifestFilePath);
7533
7534 if (manifestJSON != currentManifest)
7535 {
7536 File.WriteAllText(manifestFilePath, manifestJSON);
7537 }
7538 }
7539
7540 <meta charset="utf-8" />
7541 <title>@Model.Title</title>
7542 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7543 <meta name="robots" content="index, follow">
7544 <meta name="theme-color" content="@brandColorOne" />
7545
7546 if (!Model.MetaTags.Contains("og:image"))
7547 {
7548 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")));
7549 }
7550
7551 if (!Model.MetaTags.Contains("og:description"))
7552 {
7553 Pageview.Meta.AddTag("og:description", Model.Description);
7554 }
7555
7556 Pageview.Meta.AddTag("og:title", Model.Title);
7557 Pageview.Meta.AddTag("og:site_name", Model.Name);
7558 Pageview.Meta.AddTag("og:url", HttpContext.Current.Request.Url.ToString());
7559 Pageview.Meta.AddTag("og:type", "Website");
7560
7561 if (!string.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("FacebookAppID")))
7562 {
7563 Pageview.Meta.AddTag("fb:app_id", Model.Area.Item.GetItem("Settings").GetString("FacebookAppID"));
7564 }
7565
7566 @Model.MetaTags
7567 }
7568
7569 @helper RenderMasterCss()
7570 {
7571 @*
7572 var fonts = new string[] {
7573 getFontFamily("Layout", "HeaderFont"),
7574 getFontFamily("Layout", "SubheaderFont"),
7575 getFontFamily("Layout", "TertiaryHeaderFont"),
7576 getFontFamily("Layout", "BodyText"),
7577 getFontFamily("Layout", "Header", "ToolsFont"),
7578 getFontFamily("Layout", "Header", "NavigationFont"),
7579 getFontFamily("Layout", "MobileNavigation", "Font"),
7580 getFontFamily("ProductList", "Facets", "HeaderFont"),
7581 getFontFamily("ProductPage", "PriceFontDesign"),
7582 getFontFamily("Ecommerce", "SaleSticker", "Font"),
7583 getFontFamily("Ecommerce", "NewSticker", "Font"),
7584 getFontFamily("Ecommerce", "CustomSticker", "Font")
7585 };
7586 *@
7587
7588 string autoCssLink = "/Files/Templates/Designs/Rapido/css/rapido/rapido_" + Model.Area.ID.ToString() + ".min.css?ticks=" + Model.Area.UpdatedDate.Ticks;
7589 string favicon = Model.Area.Item.GetItem("Layout").GetFile("LogoFavicon") != null ? Model.Area.Item.GetItem("Layout").GetFile("LogoFavicon").Path : "/Files/Images/favicon.png";
7590 bool useFontAwesomePro = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetBoolean("UseFontAwesomePro");
7591 string fontAwesomeCssLink = "/Files/Templates/Designs/Rapido/css/fonts/FontAwesomeFree/css/fontawesome-all.min.css";
7592 if (useFontAwesomePro)
7593 {
7594 fontAwesomeCssLink = "/Files/Templates/Designs/Rapido/css/fonts/FontAwesomePro/css/fontawesome-all.min.css";
7595 }
7596
7597 //Favicon
7598 <link href="@favicon" rel="icon" type="image/png">
7599
7600 //Base (Default, wireframe) styles
7601 <link rel="stylesheet" href="/Files/Templates/Designs/Rapido/css/base/base.min.css" type="text/css">
7602
7603 //Rapido Css from Website Settings
7604 <link rel="stylesheet" id="rapidoCss" href="@autoCssLink" type="text/css">
7605
7606 //Ignite Css (Custom site specific styles)
7607 <link rel="stylesheet" id="igniteCss" type="text/css" href="/Files/Templates/Designs/Rapido/css/ignite/ignite.min.css">
7608
7609 //Font awesome
7610 <link rel="stylesheet" href="@fontAwesomeCssLink" type="text/css">
7611
7612 //Flag icon
7613 <link rel="stylesheet" href="/Files/Templates/Designs/Rapido/css/fonts/flag-icon.min.css" type="text/css">
7614
7615 //Google fonts
7616 // Google fonts are now loaded from local repository
7617 @*
7618 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)));
7619
7620 <link href="https://fonts.googleapis.com/css?family=@family&display=swap" rel="stylesheet">*@
7621
7622 PushPromise(favicon);
7623 PushPromise(fontAwesomeCssLink);
7624 PushPromise("/Files/Templates/Designs/Rapido/css/base/base.min.css");
7625 PushPromise(autoCssLink);
7626 PushPromise("/Files/Templates/Designs/Rapido/css/ignite/ignite.min.css");
7627 PushPromise("/Files/Images/placeholder.gif");
7628 PushPromise("/Files/Templates/Designs/Rapido/css/fonts/flag-icon.min.css");
7629 }
7630
7631 @helper RenderMasterManifest()
7632 {
7633 if (!String.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("AppName")))
7634 {
7635 <link rel="manifest" href="/Files/Templates/Designs/Rapido/manifest.json">
7636 PushPromise("/Files/Templates/Designs/Rapido/manifest.json");
7637 }
7638 }
7639
7640 @helper RenderMasterBody()
7641 {
7642 List<Block> subBlocks = this.masterPage.GetBlockListById("Body").OrderBy(item => item.SortId).ToList();
7643 string designLayout = Model.PropertyItem.GetItem("CustomSettings") != null ? Model.PropertyItem.GetItem("CustomSettings").GetString("DesignLayout") != null ? Model.PropertyItem.GetItem("CustomSettings").GetList("DesignLayout").SelectedValue : "" : "";
7644 if (!String.IsNullOrEmpty(designLayout))
7645 {
7646 designLayout = "class=\"" + designLayout + "\"";
7647 }
7648 else
7649 {
7650 designLayout = "id=\"sitecontent\"";
7651 }
7652
7653 <body @designLayout>
7654 @RenderBlockList(subBlocks)
7655 </body>
7656
7657 }
7658
7659 @helper RenderMasterHeader()
7660 {
7661 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterHeader").OrderBy(item => item.SortId).ToList();
7662 bool isNavigationStickyMenu = Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet" && Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("StickyTop");
7663 string stickyTop = isNavigationStickyMenu ? "top-container--sticky" : "";
7664
7665 <header class="top-container @stickyTop dw-mod" id="Top">
7666 @RenderBlockList(subBlocks)
7667 </header>
7668 }
7669
7670 @helper RenderMain()
7671 {
7672 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterMain").OrderBy(item => item.SortId).ToList();
7673
7674 <main class="site dw-mod">
7675 @RenderBlockList(subBlocks)
7676 </main>
7677 }
7678
7679 @helper RenderPageContent()
7680 {
7681 bool isNavigationStickyMenu = Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet" && Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("StickyTop");
7682 string pagePos = isNavigationStickyMenu ? "js-page-pos" : "";
7683
7684 <div id="Page" class="page @pagePos">
7685 <section class="center-container content-container dw-mod" id="content">
7686
7687 @RenderSnippet("Content")
7688 </section>
7689 </div>
7690 }
7691
7692 @* Hack to support nested helpers *@
7693 @SnippetStart("Content")
7694 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
7695
7696
7697 @using Dynamicweb.Extensibility
7698 @using Dynamicweb.Core
7699 @using Dynamicweb.Rapido.Blocks.Components
7700 @using Dynamicweb.Rapido.Blocks.Components.Articles
7701 @using Dynamicweb.Rapido.Blocks.Components.General
7702 @using Dynamicweb.Rapido.Blocks
7703 @using Dynamicweb.Content.Items
7704
7705 @functions {
7706 BlocksPage articlePage = BlocksPage.GetBlockPage("DynamicArticle");
7707
7708 public string GetParentSettingsItem(string systemName) {
7709 string item = null;
7710
7711 Dynamicweb.Content.Page current = Dynamicweb.Services.Pages.GetPage(Model.ID);
7712 while (current != null && current.Parent != current) {
7713 var temp = current.Item != null ? current.Item[systemName] : "";
7714
7715 if (temp != null) {
7716 item = temp.ToString();
7717
7718 if (!String.IsNullOrEmpty(item) && !String.Equals("default", item, StringComparison.OrdinalIgnoreCase)) {
7719 break;
7720 }
7721 }
7722
7723 current = current.Parent;
7724 }
7725
7726 return item;
7727 }
7728
7729 public string GetArticleCategory(int pageId)
7730 {
7731 string categoryName = null;
7732
7733 //Secure that the article is not in the root folder = Actual has a category
7734 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent != null) {
7735 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent != null) {
7736 if (!String.IsNullOrEmpty(Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent.ItemType))
7737 {
7738 categoryName = Dynamicweb.Services.Pages.GetPage(pageId).Parent.GetDisplayName();
7739 }
7740 }
7741 }
7742
7743 return categoryName;
7744 }
7745
7746 public string GetArticleCategoryColor(int pageId)
7747 {
7748 string categoryColor = "";
7749
7750 //Secure that the article is not in the root folder = Actual has a category
7751 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent != null) {
7752 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent != null) {
7753 if (!String.IsNullOrEmpty(Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent.ItemType))
7754 {
7755 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent.Item["CategoryColor"] != null)
7756 {
7757 var service = new ColorSwatchService();
7758 categoryColor = Dynamicweb.Services.Pages.GetPage(pageId).Parent.Item["CategoryColor"].ToString();
7759
7760 if (!categoryColor.Contains("#")) {
7761 categoryColor = service.GetHexColor(Converter.ToInt32(Model.Area.ID), categoryColor);
7762 }
7763 }
7764 }
7765 }
7766 }
7767
7768 return categoryColor;
7769 }
7770 }
7771
7772 @{
7773 string listPageId = Converter.ToString(GetPageIdByNavigationTag("DynamicListFeed"));
7774 string parentPageId = Dynamicweb.Services.Pages.GetPage(Model.ID).Parent.ID.ToString();
7775 string topLayout = Model.Item.GetList("TopLayout") != null ? Model.Item.GetList("TopLayout").SelectedValue : "default";
7776 topLayout = topLayout == "default" && GetParentSettingsItem("ArticleTopLayout") != null ? GetParentSettingsItem("ArticleTopLayout").ToString().ToLower() : topLayout;
7777 string textLayout = Model.Item.GetList("TextLayout") != null ? Model.Item.GetList("TextLayout").SelectedValue : "default";
7778 textLayout = textLayout == "default" && GetParentSettingsItem("ArticleTextLayout") != null ? GetParentSettingsItem("ArticleTextLayout").ToString().ToLower() : textLayout;
7779 string imageLayout = Model.Item.GetList("ImageLayout") != null ? Model.Item.GetList("ImageLayout").SelectedValue : "default";
7780 imageLayout = imageLayout == "default" && GetParentSettingsItem("ArticleImageLayout") != null ? GetParentSettingsItem("ArticleImageLayout").ToString().ToLower() : imageLayout;
7781
7782 string imageColumns = imageLayout == "straight" && textLayout != "full" ? "8" : "12";
7783 string contentColumns = textLayout != "full" ? "8" : "12";
7784
7785 int externalParagraphId = Model.Item.GetItem("CTAParagraphLink") != null ? Model.Item.GetItem("CTAParagraphLink").ParagraphID : 0;
7786
7787 ArticleHeaderLayout headerLayout;
7788
7789 switch (topLayout)
7790 {
7791 case "default":
7792 headerLayout = ArticleHeaderLayout.Clean;
7793 break;
7794 case "split":
7795 headerLayout = ArticleHeaderLayout.Split;
7796 break;
7797 case "banner":
7798 headerLayout = ArticleHeaderLayout.Banner;
7799 break;
7800 case "overlay":
7801 headerLayout = ArticleHeaderLayout.Overlay;
7802 break;
7803 default:
7804 headerLayout = ArticleHeaderLayout.Clean;
7805 break;
7806 }
7807
7808
7809 Block articleContainer = new Block
7810 {
7811 Id = "ArticleContainer",
7812 SortId = 10,
7813 Design = new Design
7814 {
7815 RenderType = RenderType.Row
7816 },
7817 BlocksList = new List<Block> {
7818 new Block {
7819 Id = "ArticleBody",
7820 SortId = 30,
7821 Design = new Design {
7822 RenderType = RenderType.Column,
7823 Size = "12",
7824 HidePadding = true
7825 }
7826 }
7827 }
7828 };
7829 articlePage.Add(articleContainer);
7830
7831 ButtonLayout topBannerButtonLayout = ButtonLayout.Primary;
7832
7833 switch (Model.Item.GetString("ButtonDesign")) {
7834 case "primary":
7835 topBannerButtonLayout = ButtonLayout.Primary;
7836 break;
7837 case "secondary":
7838 topBannerButtonLayout = ButtonLayout.Secondary;
7839 break;
7840 case "teritary":
7841 topBannerButtonLayout = ButtonLayout.Tertiary;
7842 break;
7843 case "link":
7844 topBannerButtonLayout = ButtonLayout.Link;
7845 break;
7846 }
7847
7848 ArticleHeader topBanner = new ArticleHeader
7849 {
7850 Layout = headerLayout,
7851 Image = new Image { Path = Model.Item.GetFile("Image"), ImageDefault = new ImageSettings { Width = 1920, Height = 640 } },
7852 Heading = Model.Item.GetString("Title"),
7853 Subheading = Model.Item.GetString("Summary"),
7854 TextColor = "#fff",
7855 Author = Model.Item.GetString("Author"),
7856 Date = Model.Item.GetString("Date"),
7857 Category = GetArticleCategory(Model.ID),
7858 CategoryColor = GetArticleCategoryColor(Model.ID),
7859 Link = Model.Item.GetString("Link"),
7860 LinkText = Model.Item.GetString("LinkText"),
7861 ButtonLayout = topBannerButtonLayout,
7862 RatingScore = Model.Item.GetString("Rating") != null ? Converter.ToInt32(Model.Item.GetList("Rating").SelectedValue) : 0,
7863 RatingOutOf = Model.Item.GetString("Rating") != null ? Model.Item.GetList("Rating").Options.Count : 0,
7864 ExternalParagraphId = externalParagraphId
7865 };
7866
7867 Block articleTop = new Block
7868 {
7869 Id = "ArticleHead",
7870 SortId = 20,
7871 Component = topBanner,
7872 Design = new Design
7873 {
7874 RenderType = RenderType.Column,
7875 Size = "12",
7876 HidePadding = true,
7877 CssClass = "article-head"
7878 }
7879 };
7880 articlePage.Add("ArticleContainer", articleTop);
7881
7882
7883 Block articleBodyRow = new Block
7884 {
7885 Id = "ArticleBodyRow",
7886 SortId = 10,
7887 SkipRenderBlocksList = true
7888 };
7889 articlePage.Add("ArticleBody", articleBodyRow);
7890
7891
7892 if (Model.Item.GetString("Paragraphs") != null)
7893 {
7894 int count = 0;
7895 foreach (var paragraph in Model.Item.GetItems("Paragraphs"))
7896 {
7897 if (!paragraph.GetBoolean("RenderAsQuote"))
7898 {
7899 string enableDropCap = Model.Item.GetString("EnableDropCap") != null ? Model.Item.GetList("EnableDropCap").SelectedValue.ToLower() : "default";
7900 enableDropCap = enableDropCap == "default" && GetParentSettingsItem("EnableDropCap") != null ? GetParentSettingsItem("EnableDropCap").ToString().ToLower() : enableDropCap;
7901 string text = paragraph.GetString("Text") != null ? paragraph.GetString("Text") : "";
7902
7903 if (!String.IsNullOrEmpty(text) && enableDropCap == "true" && count == 0 && paragraph.GetString("Text").Substring(0, 3) == "<p>")
7904 {
7905 string firstLetter = paragraph.GetString("Text").Substring(3, 1);
7906 text = paragraph.GetString("Text").Remove(3, 1);
7907 text = text.Insert(3, "<span class=\"article__drop-cap\">" + firstLetter + "</span>");
7908 }
7909
7910 if (paragraph.GetFile("Image") != null)
7911 {
7912 string imageTitle = !string.IsNullOrEmpty(paragraph.GetString("Heading")) ? paragraph.GetString("Heading") : "";
7913
7914 Block articleParagraphImage = new Block
7915 {
7916 Id = "ArticleParagraph" + count + "Image",
7917 SortId = (count * 10),
7918 Design = new Design
7919 {
7920 RenderType = RenderType.Column,
7921 Size = imageColumns,
7922 CssClass = "u-color-light--bg u-padding--lg"
7923 }
7924 };
7925
7926 if (imageLayout == "banner")
7927 {
7928 ArticleBanner banner = new ArticleBanner
7929 {
7930 Image = new Image { Path = paragraph.GetFile("Image"), ImageDefault = new ImageSettings { Height = 650, Width = 1300 }, Caption = paragraph.GetString("ImageCaption") },
7931 Heading = imageTitle,
7932 UseFilters = false
7933 };
7934 articleParagraphImage.Component = banner;
7935 }
7936 else
7937 {
7938 ArticleImage image = new ArticleImage
7939 {
7940 Image = new Image
7941 {
7942 Path = paragraph.GetFile("Image"),
7943 Title = imageTitle,
7944 ImageDefault = new ImageSettings { Height = 650, Width = 1300 },
7945 Caption = paragraph.GetString("ImageCaption")
7946 }
7947 };
7948 articleParagraphImage.Component = image;
7949 }
7950
7951 articlePage.Add("ArticleBodyRow", articleParagraphImage);
7952 }
7953
7954 if (!String.IsNullOrEmpty(paragraph.GetString("VideoURL")))
7955 {
7956 Block articleParagraphVideo = new Block
7957 {
7958 Id = "ArticleParagraph" + count + "Video",
7959 SortId = (count * 10) + 1,
7960 Component = new ArticleVideo { Url = paragraph.GetString("VideoURL"), AutoPlay = "false" },
7961 Design = new Design
7962 {
7963 RenderType = RenderType.Column,
7964 Size = imageColumns,
7965 CssClass = "u-color-light--bg u-padding--lg"
7966 }
7967 };
7968 articlePage.Add("ArticleBodyRow", articleParagraphVideo);
7969 }
7970
7971 if (!String.IsNullOrEmpty(paragraph.GetString("Heading")))
7972 {
7973 Block articleParagraphHeader = new Block
7974 {
7975 Id = "ArticleParagraph" + count + "Heading",
7976 SortId = (count * 10) + 2,
7977 Component = new ArticleSubHeader { Title = paragraph.GetString("Heading") },
7978 Design = new Design
7979 {
7980 RenderType = RenderType.Column,
7981 Size = contentColumns,
7982 CssClass = "u-color-light--bg u-padding--lg"
7983 }
7984 };
7985 articlePage.Add("ArticleBodyRow", articleParagraphHeader);
7986 }
7987
7988 if (!String.IsNullOrEmpty(text))
7989 {
7990 Block articleParagraphText = new Block
7991 {
7992 Id = "ArticleParagraph" + count + "Text",
7993 SortId = (count * 10) + 3,
7994 Component = new ArticleText { Text = text },
7995 Design = new Design
7996 {
7997 RenderType = RenderType.Column,
7998 Size = contentColumns,
7999 CssClass = "u-color-light--bg u-padding--lg"
8000 }
8001 };
8002
8003 articlePage.Add("ArticleBodyRow", articleParagraphText);
8004 }
8005 }
8006 else
8007 {
8008 if (!String.IsNullOrEmpty(paragraph.GetString("Text")))
8009 {
8010 string quoteText = paragraph.GetString("Text") != null ? paragraph.GetString("Text") : "";
8011 string quoteAuthor = paragraph.GetString("Heading") != null ? paragraph.GetString("Heading") : "";
8012
8013 Block articleParagraphQuote = new Block
8014 {
8015 Id = "ArticleParagraph" + count + "Quote",
8016 SortId = (count * 10) + 3,
8017 Component = new ArticleQuote { Image = new Image { Path = paragraph.GetFile("Image") }, Text = quoteText, Author = quoteAuthor },
8018 Design = new Design
8019 {
8020 RenderType = RenderType.Column,
8021 Size = contentColumns,
8022 CssClass = "u-color-light--bg u-padding--lg"
8023 }
8024 };
8025 articlePage.Add("ArticleBodyRow", articleParagraphQuote);
8026 }
8027 }
8028
8029 count++;
8030 }
8031 }
8032
8033 articleBodyRow.Component = new ArticleBodyRow { SubBlocks = articleBodyRow.BlocksList, TopLayout = topLayout, TextLayout = textLayout };
8034
8035
8036 //Related
8037 string showRelatedArtices = Model.Item.GetString("ShowRelatedArticles") != null ? Model.Item.GetList("ShowRelatedArticles").SelectedValue.ToLower() : "default";
8038 showRelatedArtices = showRelatedArtices == "default" && GetParentSettingsItem("ShowRelatedArticles") != null ? GetParentSettingsItem("ShowRelatedArticles").ToString().ToLower() : showRelatedArtices;
8039
8040 if (showRelatedArtices == "true")
8041 {
8042 Block articleRelated = new Block
8043 {
8044 Id = "ArticleRelated",
8045 SortId = 30,
8046 Component = new ArticleRelated { Title = Translate("Related articles"), FeedPageId = listPageId, Query = "sourceType=Page&sourcePage=" + parentPageId, PageSize = 4, CurrentPageId = Model.ID.ToString() },
8047 Design = new Design
8048 {
8049 RenderType = RenderType.Column,
8050 Size = "12"
8051 }
8052 };
8053 articlePage.Add("ArticleContainer", articleRelated);
8054 }
8055 }
8056
8057
8058 @using System
8059 @using System.Web
8060 @using System.Collections.Generic
8061 @using Dynamicweb.Rapido.Blocks
8062
8063 @{
8064 BlocksPage dynamicArticleCustomBlocksPage = BlocksPage.GetBlockPage("DynamicArticle");
8065
8066 }
8067
8068
8069 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@
8070 @RenderBlockList(articlePage.BlocksRoot.BlocksList)
8071 @SnippetEnd("Content")
8072
8073 @helper RenderIosTabletFix()
8074 {
8075 if (Pageview.Device != Dynamicweb.Frontend.Devices.DeviceType.Tablet && Pageview.Platform != Dynamicweb.Frontend.Devices.PlatformType.Ios)
8076 {
8077 <script>
8078 let isIpadIOS = (/iPad/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) && !window.MSStream;
8079 if (isIpadIOS) {
8080 var separator = (window.location.href.indexOf("?") === -1) ? "?" : "&";
8081 window.location.href = window.location.href + separator + "DeviceType=Tablet&PlatformType=Ios";
8082 }
8083 </script>
8084 }
8085 }
8086
8087 </html>
8088
8089