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_f1925c21f9b0412d964d590449cf0184.Execute() in D:\dynamicweb.net\Solutions\Production\Files\Templates\Designs\Rapido\_parsed\DynamicArticle.parsed.cshtml:line 7891
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 (languageViewType == "flag-culture")
4929 {
4930 langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " \"></span> " + cultureName;
4931 }
4932
4933 if (languageViewType == "flag")
4934 {
4935 langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " \"></span>";
4936 widthClass = "";
4937 }
4938
4939 if (languageViewType == "name")
4940 {
4941 langInfo = lang.Name;
4942 }
4943
4944 if (languageViewType == "culture")
4945 {
4946 langInfo = cultureName;
4947 widthClass = "";
4948 }
4949
4950 <div class="menu__item dw-mod @widthClass">
4951 <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>
4952 </div>
4953 }
4954 </div>
4955 </li>
4956 }
4957 }
4958 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4959
4960 @using System
4961 @using System.Web
4962 @using Dynamicweb.Rapido.Blocks.Extensibility
4963 @using Dynamicweb.Rapido.Blocks
4964
4965 @{
4966 Block masterDesktopActionsMenuSignIn = new Block
4967 {
4968 Id = "MasterDesktopActionsMenuSignIn",
4969 SortId = 20,
4970 Template = RenderSignIn()
4971 };
4972
4973 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuSignIn);
4974 }
4975
4976 @helper RenderSignIn()
4977 {
4978 bool navigationItemsHideSignIn = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSignIn");
4979 string userInitials = "";
4980 int pageId = Model.TopPage.ID;
4981 int createAccountPageId = GetPageIdByNavigationTag("CreateAccount");
4982 int myDashboardPageId = GetPageIdByNavigationTag("CustomerDashboard");
4983 int myProfilePageId = GetPageIdByNavigationTag("CustomerProfile");
4984 int myOrdersPageId = GetPageIdByNavigationTag("CustomerOrders");
4985 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites");
4986 int mySavedCardsPageId = GetPageIdByNavigationTag("SavedCards");
4987 int myOrderDraftsPageId = GetPageIdByNavigationTag("OrderDraft");
4988 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
4989 bool hideCreateAccountLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideCreateAccount");
4990 bool hideMyProfileLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideProfile");
4991 bool hideMyOrdersLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideOrders");
4992 bool hideMySavedCardsLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideSavedCards");
4993 bool hideMyOrderDraftsLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideOrderDrafts");
4994 bool hideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideFavorites");
4995 bool hideForgotPasswordLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideForgotPasswordLink");
4996
4997 string linkStart = "/Default.aspx?ID=";
4998 if (Model.CurrentUser.ID <= 0)
4999 {
5000 linkStart += signInProfilePageId + "&RedirectPageId=";
5001 }
5002
5003 string forgotPasswordPageLink = "/Default.aspx?ID=" + signInProfilePageId + "&LoginAction=Recovery";
5004 string myProfilePageLink = linkStart + myProfilePageId;
5005 string myOrdersPageLink = linkStart + myOrdersPageId;
5006 string myFavoritesPageLink = linkStart + myFavoritesPageId;
5007 string mySavedCardsPageLink = linkStart + mySavedCardsPageId;
5008 string myOrderDraftsLink = linkStart + myOrderDraftsPageId;
5009
5010 string profileIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue : "fa fa-user";
5011 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";
5012 string orderDraftsIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon").SelectedValue : "fa fa-clipboard";
5013
5014 if (Model.CurrentUser.ID != 0)
5015 {
5016 userInitials = Dynamicweb.Rapido.Services.User.GetInitials(Model.CurrentUser.Name, Model.CurrentUser.FirstName, Model.CurrentUser.LastName, Model.CurrentUser.Email, Model.CurrentUser.UserName);
5017 }
5018
5019 if (!navigationItemsHideSignIn)
5020 {
5021 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5022 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu__item--clean";
5023 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5024
5025 <li class="menu__item menu__item--horizontal menu__item menu__item--icon @liClasses is-dropdown is-dropdown--no-icon dw-mod">
5026 <div class="@menuLinkClass dw-mod">
5027 @if (Model.CurrentUser.ID <= 0)
5028 {
5029 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue fa-1_5x" title="@Translate("Sign in")"></i>
5030 <span class="headericonlabel signinicontext">@Translate("SignInIcontext", "Sign In")</span>
5031 }
5032 else
5033 {
5034 <a href="/default.aspx?ID=@myDashboardPageId" class="u-color-inherit" title="@Translate("Customer center")"><div class="circle-icon-btn">@userInitials.ToUpper()</div></a>
5035 <span class="headericonlabel profileicontext">@Translate("ProfileIcontext", "Profile")</span>
5036 }
5037 </div>
5038 <div class="menu menu--dropdown menu--dropdown-right menu--sign-in grid__cell dw-mod">
5039 <ul class="list list--clean dw-mod">
5040 @if (Model.CurrentUser.ID <= 0)
5041 {
5042 <li>
5043 <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>
5044 </li>
5045
5046 if (!hideCreateAccountLink)
5047 {
5048 @RenderListItem("/default.aspx?ID=" + createAccountPageId, Translate("Create account"));
5049 }
5050 if (!hideForgotPasswordLink)
5051 {
5052 @RenderListItem(forgotPasswordPageLink, Translate("Forgot your password?"))
5053 }
5054 if (!hideMyProfileLink || !hideMyOrdersLink || !hideMyFavoritesLink || !hideMySavedCardsLink)
5055 {
5056 @RenderSeparator()
5057 }
5058 }
5059 @if (!hideMyProfileLink)
5060 {
5061 @RenderListItem(myProfilePageLink, Translate("My Profile"), profileIcon)
5062 }
5063 @if (!hideMyOrdersLink)
5064 {
5065 @RenderListItem(myOrdersPageLink, Translate("My Orders"), "fas fa-list")
5066 }
5067 @if (!hideMyFavoritesLink)
5068 {
5069 @RenderListItem(myFavoritesPageLink, Translate("My Favorites"), favoritesIcon)
5070 }
5071 @if (!hideMySavedCardsLink)
5072 {
5073 @RenderListItem(mySavedCardsPageLink, Translate("My Saved cards"), "fas fa-credit-card")
5074 }
5075 @if (!hideMyOrderDraftsLink)
5076 {
5077 @RenderListItem(myOrderDraftsLink, Translate("My Order drafts"), orderDraftsIcon)
5078 }
5079 @if (Model.CurrentUser.ID > 0)
5080 {
5081 if (!hideMyProfileLink || !hideMyOrdersLink || !hideMyFavoritesLink || !hideMySavedCardsLink)
5082 {
5083 @RenderSeparator()
5084 }
5085
5086 //Check if impersonation is on
5087 if (Model.CurrentSecondaryUser != null && Model.CurrentSecondaryUser.ID > 0)
5088 {
5089 <li>
5090 <div class="list__link dw-mod" onclick="document.getElementById('StopImpersonationModalTrigger').checked = true;">
5091 @Translate("Sign out")
5092 </div>
5093 </li>
5094 } else {
5095 @RenderListItem("/Admin/Public/ExtranetLogoff.aspx?ID=" + pageId, Translate("Sign out"))
5096 }
5097 }
5098 </ul>
5099 </div>
5100 </li>
5101 }
5102 }
5103
5104 @helper RenderListItem(string link, string text, string icon = null) {
5105 <li>
5106 <a href="@link" class="list__link dw-mod" onclick="RememberState.SetCookie('useAnotherAddress', false)">
5107 @if (!string.IsNullOrEmpty(icon)){<i class="@icon u-margin-right"></i>}@text
5108 </a>
5109 </li>
5110 }
5111
5112 @helper RenderSeparator()
5113 {
5114 <li class="list__seperator dw-mod"></li>
5115 }
5116 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5117
5118 @using System
5119 @using System.Web
5120 @using Dynamicweb.Rapido.Blocks.Extensibility
5121 @using Dynamicweb.Rapido.Blocks
5122
5123 @{
5124 bool hideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideFavorites");
5125
5126 Block masterDesktopActionsMenuFavorites = new Block
5127 {
5128 Id = "MasterDesktopActionsMenuFavorites",
5129 SortId = 30,
5130 Template = RenderFavorites()
5131 };
5132
5133 if (!hideMyFavoritesLink && Model.CurrentUser.ID > 0)
5134 {
5135 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuFavorites);
5136 }
5137 }
5138
5139 @helper RenderFavorites()
5140 {
5141 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites");
5142 string myFavoritesPageLink = "/Default.aspx?ID=" + myFavoritesPageId;
5143
5144 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5145 string liClasses = topLayout != "normal" && topLayout != "splitted-center" ? "menu__item--top-level u-hidden-xxs" : "menu--clean";
5146 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5147
5148 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod">
5149 <a href="@myFavoritesPageLink" class="@menuLinkClass dw-mod" title="@Translate("Favorites")">
5150 <i class="fas fa-@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon").SelectedValue fa-1_5x"></i>
5151 </a>
5152 </li>
5153 }
5154 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5155
5156 @using System
5157 @using System.Web
5158 @using Dynamicweb.Rapido.Blocks.Extensibility
5159 @using Dynamicweb.Rapido.Blocks
5160 @using Dynamicweb.Rapido.Services
5161
5162 @{
5163 bool hideCart = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart");
5164 string miniCartLayout = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout").SelectedValue : "dropdown";
5165
5166 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed() && !hideCart)
5167 {
5168 Block masterDesktopActionsMenuMiniCart = new Block
5169 {
5170 Id = "MasterDesktopActionsMenuMiniCart",
5171 SortId = 60,
5172 Template = RenderMiniCart(miniCartLayout == "dropdown"),
5173 SkipRenderBlocksList = true,
5174 BlocksList = new List<Block>()
5175 };
5176
5177 Block miniCartCounterScriptTemplate = new Block
5178 {
5179 Id = "MiniCartCounterScriptTemplate",
5180 Template = RenderMiniCartCounterContent()
5181 };
5182
5183 //dropdown layout is default
5184 RazorEngine.Templating.TemplateWriter layoutTemplate;
5185 RazorEngine.Templating.TemplateWriter miniCartTriggerTemplate;
5186
5187 switch (miniCartLayout)
5188 {
5189 case "dropdown":
5190 layoutTemplate = RenderMiniCartDropdownLayout();
5191 miniCartTriggerTemplate = RenderMiniCartTriggerLink();
5192 break;
5193 case "panel":
5194 layoutTemplate = RenderMiniCartPanelLayout();
5195 miniCartTriggerTemplate = RenderMiniCartTriggerLabel();
5196 break;
5197 case "modal":
5198 layoutTemplate = RenderMiniCartModalLayout();
5199 miniCartTriggerTemplate = RenderMiniCartTriggerLabel();
5200 break;
5201 case "none":
5202 default:
5203 layoutTemplate = RenderMiniCartDropdownLayout();
5204 miniCartTriggerTemplate = RenderMiniCartTriggerLink();
5205 break;
5206 }
5207
5208 masterDesktopActionsMenuMiniCart.BlocksList.Add(new Block
5209 {
5210 Id = "MiniCartTrigger",
5211 Template = miniCartTriggerTemplate
5212 });
5213
5214 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet")
5215 {
5216 masterDesktopActionsMenuMiniCart.BlocksList.Add(new Block
5217 {
5218 Id = "MiniCartLayout",
5219 Template = layoutTemplate
5220 });
5221 }
5222
5223 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuMiniCart);
5224 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", miniCartCounterScriptTemplate);
5225 }
5226
5227 if (hideCart && Dynamicweb.Rapido.Services.User.IsBuyingAllowed())
5228 {
5229 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", new Block {
5230 Id = "CartInitialization"
5231 });
5232 }
5233 }
5234
5235 @helper RenderMiniCart(bool hasMouseEnterEvent)
5236 {
5237 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterDesktopActionsMenuMiniCart").OrderBy(item => item.SortId).ToList();
5238 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5239 string liClasses = topLayout != "normal" ? "menu__item--top-level" : "menu--clean";
5240 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5241 string mouseEvent = "";
5242 string id = "MiniCart";
5243 if (hasMouseEnterEvent)
5244 {
5245 mouseEvent = "onmouseenter=\"Cart.UpdateMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '/Default.aspx?ID=" + miniCartFeedPageId + "&feedType=MiniCart')\"";
5246 id = "miniCartTrigger";
5247 }
5248 <li class="menu__item menu__item--horizontal menu__item--icon @liClasses dw-mod" id="@id" @mouseEvent>
5249 @RenderBlockList(subBlocks)
5250 </li>
5251 }
5252
5253 @helper RenderMiniCartTriggerLabel()
5254 {
5255 int cartPageId = GetPageIdByNavigationTag("CartPage");
5256 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fa fa-cart";
5257 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5258 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5259 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5260
5261 <div class="@menuLinkClass dw-mod js-mini-cart-button" onclick="Cart.UpdateMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '/Default.aspx?ID=@miniCartFeedPageId&feedType=MiniCart')" title="@Translate("Cart")">
5262 <div class="u-inline u-position-relative">
5263 <i class="@cartIcon fa-1_5x"></i>
5264 @RenderMiniCartCounter()
5265 </div>
5266 </div>
5267 }
5268
5269 @helper RenderMiniCartTriggerLink()
5270 {
5271 int cartPageId = GetPageIdByNavigationTag("CartPage");
5272 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fa fa-cart";
5273 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5274 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5275
5276 <a href="/Default.aspx?ID=@cartPageId&Purge=True" class="@menuLinkClass menu__item--icon dw-mod js-mini-cart-button" title="@Translate("Cart")">
5277 <span class="u-inline u-position-relative">
5278 <i class="@cartIcon fa-1_5x"></i>
5279 @RenderMiniCartCounter()
5280 </span>
5281 </a>
5282 }
5283
5284 @helper RenderMiniCartCounter()
5285 {
5286 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5287 string cartProductsCount = Model.Cart.TotalProductsCount.ToString();
5288 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right";
5289 bool showPrice = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetBoolean("ShowPrice");
5290 string cartProductsTotalPrice = showPrice && Model.Cart.TotalPrice != null ? Model.Cart.TotalPrice.Price.Formatted : "";
5291 cartProductsTotalPrice = counterPosition == "right" ? cartProductsTotalPrice : "";
5292
5293 if (showPrice && counterPosition == "right")
5294 {
5295 cartProductsCount = Translate("Cart") + " (" + cartProductsCount + ")";
5296 }
5297
5298 <span class="mini-cart__counter @(counterPosition == "right" ? "mini-cart__counter--inline" : "") dw-mod">
5299 <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">
5300 <span class="js-mini-cart-counter-content" data-count="@Model.Cart.TotalProductsCount.ToString()">
5301 @cartProductsCount @cartProductsTotalPrice
5302 </span>
5303 </span>
5304 </span>
5305 }
5306
5307 @helper RenderMiniCartCounterContent()
5308 {
5309 bool showPrice = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetBoolean("ShowPrice");
5310 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right";
5311 bool showPriceInMiniCartCounter = Pageview.Device.ToString() != "Mobile" && counterPosition == "right" && showPrice;
5312
5313 <script id="MiniCartCounterContent" type="text/x-template">
5314 {{#.}}
5315 <span class="js-mini-cart-counter-content dw-mod" data-count="{{numberofproducts}}">
5316 @if (showPriceInMiniCartCounter)
5317 {
5318 @Translate("Cart")<text>({{numberofproducts}}) {{totalprice}}</text>
5319 }
5320 else
5321 {
5322 <text>{{numberofproducts}}</text>
5323 }
5324 </span>
5325 {{/.}}
5326 </script>
5327 }
5328
5329 @helper RenderMiniCartDropdownLayout()
5330 {
5331 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5332 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage");
5333
5334 <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">
5335 <div class="mini-cart-dropdown__inner dw-mod">
5336 <h3 class="u-ta-center dw-mod">@Translate("Shopping cart")</h3>
5337 <div class="mini-cart-dropdown__body u-flex dw-mod">
5338 <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>
5339 </div>
5340 </div>
5341 </div>
5342 }
5343
5344 @helper RenderMiniCartPanelLayout()
5345 {
5346 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5347 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage");
5348
5349 <div class="mini-cart grid__cell dw-mod">
5350 <input type="checkbox" id="miniCartTrigger" class="panel-trigger" />
5351 <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">
5352 <label for="miniCartTrigger" class="panel__close-btn" title="@Translate("Close panel")"><i class="fas fa-times"></i></label>
5353 <div class="panel__content u-full-width dw-mod">
5354 <h3 class="panel__header dw-mod u-margin-bottom u-ta-center">@Translate("Shopping cart")</h3>
5355 <div class="panel__content-body panel__content-body--cart dw-mod">
5356 <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>
5357 </div>
5358 </div>
5359 </div>
5360 </div>
5361 }
5362
5363 @helper RenderMiniCartModalLayout()
5364 {
5365 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5366 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage");
5367
5368 <div class="mini-cart grid__cell dw-mod">
5369 <input type="checkbox" id="miniCartTrigger" class="modal-trigger" autocomplete="off" />
5370 <div class="modal-container dw-mod js-mini-cart" id="miniCart" data-cart-id="@miniCartFeedPageId" data-show-type="block" data-cart-page-link="@cartPageLink">
5371 <label for="miniCartTrigger" class="modal-overlay"></label>
5372 <div class="modal modal--md modal--top-right dw-mod">
5373 <div class="modal__body u-flex grid--direction-column dw-mod">
5374 <h3 class="dw-mod u-ta-center">@Translate("Shopping cart")</h3>
5375 <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>
5376 </div>
5377 <label class="modal__close-btn modal__close-btn--clean dw-mod" for="miniCartTrigger" title="@Translate("Close modal")"></label>
5378 </div>
5379 </div>
5380 </div>
5381 }
5382 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5383
5384 @using System
5385 @using System.Web
5386 @using Dynamicweb.Rapido.Blocks.Extensibility
5387 @using Dynamicweb.Rapido.Blocks
5388
5389 @{
5390 bool showOrderDraftLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowOrderDraftIcon");
5391
5392 Block masterDesktopActionsMenuOrderDraft = new Block
5393 {
5394 Id = "MasterDesktopActionsMenuOrderDraft",
5395 SortId = 40,
5396 Template = RenderOrderDraft()
5397 };
5398
5399 if (showOrderDraftLink && Model.CurrentUser.ID > 0)
5400 {
5401 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuOrderDraft);
5402 }
5403 }
5404
5405 @helper RenderOrderDraft()
5406 {
5407 int OrderDraftPageId = GetPageIdByNavigationTag("OrderDraft");
5408 string OrderDraftPageLink = "/Default.aspx?ID=" + OrderDraftPageId;
5409 string draftIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("DraftIcon").SelectedValue : "fa fa-clipboard";
5410
5411
5412 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5413 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean";
5414 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5415
5416 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod">
5417 <a href="@OrderDraftPageLink" class="@menuLinkClass dw-mod" title="@Translate("My order drafts")">
5418 <span class="u-inline u-position-relative">
5419 <i class="@draftIcon fa-1_5x"></i>
5420 </span>
5421 </a>
5422 </li>
5423 }
5424 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5425
5426 @using System
5427 @using System.Web
5428 @using Dynamicweb.Rapido.Blocks.Extensibility
5429 @using Dynamicweb.Rapido.Blocks
5430
5431 @{
5432 bool showDownloadCartLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowDownloadCart");
5433
5434 Block masterDesktopActionsMenuDownloadCart = new Block
5435 {
5436 Id = "MasterDesktopActionsMenuDownloadCart",
5437 SortId = 50,
5438 Template = RenderDownloadCart()
5439 };
5440
5441 if (showDownloadCartLink && Model.CurrentUser.ID > 0)
5442 {
5443 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuDownloadCart);
5444 }
5445 }
5446
5447 @helper RenderDownloadCart()
5448 {
5449 int downloadCartPageId = GetPageIdByNavigationTag("DownloadCart");
5450 string downloadCartPageLink = "/Default.aspx?ID=" + downloadCartPageId;
5451
5452 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5453 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean";
5454 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5455 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right";
5456
5457 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod">
5458 <a href="@downloadCartPageLink" class="@menuLinkClass dw-mod" title="@Translate("Download cart")">
5459 <span class="u-inline u-position-relative">
5460 <i class="fas fa-cart-arrow-down fa-1_5x"></i>
5461 <span class="mini-cart__counter u-hidden @(counterPosition == "right" ? "mini-cart__counter--inline" : "") dw-mod js-download-cart-counter"></span>
5462 </span>
5463 </a>
5464 </li>
5465 }
5466 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5467
5468 @using System
5469 @using System.Web
5470 @using Dynamicweb.Rapido.Blocks.Extensibility
5471 @using Dynamicweb.Rapido.Blocks
5472
5473 @functions {
5474 public class SearchConfiguration
5475 {
5476 public string searchFeedId { get; set; }
5477 public string searchSecondFeedId { get; set; }
5478 public int groupsFeedId { get; set; }
5479 public string resultPageLink { get; set; }
5480 public string searchPlaceholder { get; set; }
5481 public string searchType { get; set; }
5482 public string searchTemplate { get; set; }
5483 public string searchContentTemplate { get; set; }
5484 public string searchValue { get; set; }
5485 public bool showGroups { get; set; }
5486
5487 public SearchConfiguration()
5488 {
5489 searchFeedId = "";
5490 searchSecondFeedId = "";
5491 searchType = "product-search";
5492 searchContentTemplate = "";
5493 showGroups = true;
5494 }
5495 }
5496 }
5497 @{
5498 Block masterSearchBar = new Block
5499 {
5500 Id = "MasterSearchBar",
5501 SortId = 40,
5502 Template = RenderSearch("bar"),
5503 Design = new Design
5504 {
5505 Size = "auto",
5506 HidePadding = true,
5507 RenderType = RenderType.Column
5508 }
5509 };
5510
5511 Block masterSearchAction = new Block
5512 {
5513 Id = "MasterDesktopActionsMenuSearch",
5514 SortId = 10,
5515 Template = RenderSearch()
5516 };
5517
5518 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterSearchBar);
5519 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterSearchAction);
5520 }
5521
5522 @helper RenderSearch(string type = "mini-search")
5523 {
5524 string productsPageId = Converter.ToString(GetPageIdByNavigationTag("ProductsPage"));
5525 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID;
5526 string searchType = Model.Area.Item.GetItem("Layout").GetList("TopSearch") != null ? Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue : "productSearch";
5527
5528 SearchConfiguration searchConfiguration = null;
5529
5530 switch (searchType) {
5531 case "contentSearch":
5532 searchConfiguration = new SearchConfiguration() {
5533 searchFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true",
5534 resultPageLink = contentSearchPageLink,
5535 searchPlaceholder = Translate("Search page"),
5536 groupsFeedId = 0,
5537 searchType = "content-search",
5538 searchTemplate = "SearchPagesTemplate",
5539 showGroups = false
5540 };
5541 break;
5542 case "combinedSearch":
5543 searchConfiguration = new SearchConfiguration() {
5544 searchFeedId = productsPageId + "&feed=true",
5545 searchSecondFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true",
5546 resultPageLink = Converter.ToString(productsPageId),
5547 searchPlaceholder = Translate("Search products or pages"),
5548 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"),
5549 searchType = "combined-search",
5550 searchTemplate = "SearchProductsTemplateWrap",
5551 searchContentTemplate = "SearchPagesTemplateWrap",
5552 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector")
5553 };
5554 break;
5555 default: //productSearch
5556 searchConfiguration = new SearchConfiguration() {
5557 resultPageLink = Converter.ToString(productsPageId),
5558 searchFeedId = productsPageId + "&feed=true",
5559 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"),
5560 searchPlaceholder = Translate("Search products"),
5561 searchTemplate = "SearchProductsTemplate",
5562 searchType = "product-search",
5563 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector")
5564 };
5565 break;
5566 }
5567 searchConfiguration.searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? "";
5568
5569 if (type == "mini-search") {
5570 @RenderMiniSearch(searchConfiguration)
5571 } else {
5572 @RenderSearchBar(searchConfiguration)
5573 }
5574 }
5575
5576 @helper RenderSearchBar(SearchConfiguration options)
5577 {
5578 <div class="typeahead typeahead--centered u-color-inherit js-typeahead dw-mod" id="ProductSearchBar"
5579 data-page-size="7"
5580 data-search-feed-id="@options.searchFeedId"
5581 data-search-second-feed-id="@options.searchSecondFeedId"
5582 data-result-page-id="@options.resultPageLink"
5583 data-groups-page-id="@options.groupsFeedId"
5584 data-search-type="@options.searchType">
5585 @if (options.showGroups)
5586 {
5587 <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>
5588 <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>
5589 }
5590 <div class="typeahead-search-field">
5591 <input type="text" class="u-no-margin u-full-width u-full-height js-typeahead-search-field" placeholder="@options.searchPlaceholder" value="@options.searchValue">
5592 @if (string.IsNullOrEmpty(options.searchSecondFeedId))
5593 {
5594 <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>
5595 }
5596 else
5597 {
5598 <div class="dropdown dropdown--absolute-position dropdown--combined grid">
5599 <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>
5600 <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>
5601 </div>
5602 }
5603 </div>
5604 <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>
5605 </div>
5606 }
5607
5608 @helper RenderMiniSearch(SearchConfiguration options)
5609 {
5610 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5611 string menuLinkClass = topLayout != "normal" && topLayout != "splitted-center" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
5612
5613 <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">
5614 <div class="@menuLinkClass dw-mod" title="@Translate("Search")">
5615 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue fa-1_5x"></i>
5616 <span class="headericonlabel searchtext">@Translate("Searchicontext", "Search")</span>
5617 </div>
5618 <div class="menu menu--dropdown menu--dropdown-right u-no-padding u-w380px grid__cell dw-mod">
5619 <div class="typeahead js-typeahead" id="ProductSearchBar"
5620 data-page-size="7"
5621 data-search-feed-id="@options.searchFeedId"
5622 data-search-second-feed-id="@options.searchSecondFeedId"
5623 data-result-page-id="@options.resultPageLink"
5624 data-search-type="@options.searchType">
5625 <div class="typeahead-search-field">
5626 <input type="text" class="u-no-margin u-full-width js-typeahead-search-field" id="headerSearch" placeholder="@options.searchPlaceholder" value="@options.searchValue">
5627 @if (string.IsNullOrEmpty(options.searchSecondFeedId))
5628 {
5629 <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>
5630 }
5631 else
5632 {
5633 <div class="dropdown dropdown--absolute-position dropdown--combined grid dropdown--right-aligned">
5634 <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>
5635 <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>
5636 </div>
5637 }
5638 </div>
5639 </div>
5640 </div>
5641 </li>
5642 }
5643 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5644
5645 @using System
5646 @using System.Web
5647 @using Dynamicweb.Rapido.Blocks.Extensibility
5648 @using Dynamicweb.Rapido.Blocks
5649
5650 @{
5651 string headerConfigurationTopLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5652 bool headerConfigurationHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch");
5653
5654 BlocksPage headerConfigurationPage = BlocksPage.GetBlockPage("Master");
5655
5656 Block configDesktopLogo = headerConfigurationPage.GetBlockById("MasterDesktopLogo");
5657 headerConfigurationPage.RemoveBlock(configDesktopLogo);
5658
5659 Block configDesktopMenu = headerConfigurationPage.GetBlockById("MasterDesktopMenu");
5660 headerConfigurationPage.RemoveBlock(configDesktopMenu);
5661
5662 Block configSearchBar = headerConfigurationPage.GetBlockById("MasterSearchBar");
5663 headerConfigurationPage.RemoveBlock(configSearchBar);
5664
5665 Block configSearchAction = headerConfigurationPage.GetBlockById("MasterDesktopActionsMenuSearch");
5666 headerConfigurationPage.RemoveBlock(configSearchAction);
5667
5668 Block configDesktopActionsMenu = headerConfigurationPage.GetBlockById("MasterDesktopActionsMenu");
5669 headerConfigurationPage.RemoveBlock(configDesktopActionsMenu);
5670
5671 Block configDesktopExtra = headerConfigurationPage.GetBlockById("MasterDesktopExtra");
5672
5673 switch (headerConfigurationTopLayout)
5674 {
5675 case "condensed": //2
5676 configDesktopLogo.Design.Size = "auto-width";
5677 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo);
5678
5679 configDesktopMenu.SortId = 20;
5680 configDesktopMenu.Design.Size = "auto";
5681 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5682
5683 configDesktopActionsMenu.SortId = 30;
5684 configDesktopActionsMenu.Design.Size = "auto-width";
5685 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5686
5687 if (!headerConfigurationHideSearch)
5688 {
5689 configSearchBar.SortId = 40;
5690 configSearchBar.Design.Size = "12";
5691 configDesktopExtra.SortId = 50;
5692 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar);
5693 }
5694 break;
5695 case "splitted": //3
5696 configDesktopLogo.Design.Size = "auto";
5697 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5698
5699 if (!headerConfigurationHideSearch)
5700 {
5701 configSearchBar.SortId = 20;
5702 configSearchBar.Design.Size = "auto";
5703 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar);
5704 }
5705
5706 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5707
5708 configDesktopActionsMenu.SortId = 20;
5709 configDesktopActionsMenu.Design.Size = "auto-width";
5710 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5711 break;
5712 case "splitted-center": //4
5713 configDesktopLogo.Design.Size = "auto";
5714 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5715 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5716
5717 configDesktopActionsMenu.SortId = 30;
5718 configDesktopActionsMenu.Design.Size = "auto-width";
5719 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopActionsMenu);
5720
5721 if (!headerConfigurationHideSearch)
5722 {
5723 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5724 }
5725 break;
5726 case "minimal": //5
5727 configDesktopLogo.Design.Size = "auto-width";
5728 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo);
5729
5730 configDesktopMenu.Design.Size = "auto";
5731 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5732
5733 configDesktopActionsMenu.SortId = 20;
5734 configDesktopActionsMenu.Design.Size = "auto-width";
5735 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5736
5737 if (!headerConfigurationHideSearch)
5738 {
5739 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5740 }
5741 break;
5742 case "minimal-center": //6
5743 configDesktopLogo.Design.Size = "auto-width";
5744 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo);
5745
5746 configDesktopMenu.Design.Size = "auto";
5747 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5748
5749 configDesktopActionsMenu.SortId = 20;
5750 configDesktopActionsMenu.Design.Size = "auto-width";
5751 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5752
5753 if (!headerConfigurationHideSearch)
5754 {
5755 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5756 }
5757 break;
5758 case "minimal-right": //7
5759 configDesktopLogo.Design.Size = "auto-width";
5760 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo);
5761
5762 configDesktopMenu.Design.Size = "auto";
5763 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5764
5765 configDesktopActionsMenu.SortId = 20;
5766 configDesktopActionsMenu.Design.Size = "auto-width";
5767 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5768
5769 if (!headerConfigurationHideSearch)
5770 {
5771 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5772 }
5773 break;
5774 case "two-lines": //8
5775 configDesktopLogo.Design.Size = "auto";
5776 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5777
5778 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5779
5780 configDesktopActionsMenu.SortId = 20;
5781 configDesktopActionsMenu.Design.Size = "auto-width";
5782 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5783
5784 if (!headerConfigurationHideSearch)
5785 {
5786 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5787 }
5788 break;
5789 case "two-lines-centered": //9
5790 configDesktopLogo.Design.Size = "auto";
5791 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5792
5793 configDesktopMenu.Design.Size = "auto-width";
5794 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5795
5796 configDesktopActionsMenu.SortId = 20;
5797 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5798
5799 if (!headerConfigurationHideSearch)
5800 {
5801 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5802 }
5803 break;
5804 case "normal": //1
5805 default:
5806 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5807
5808 if (!headerConfigurationHideSearch)
5809 {
5810 configSearchBar.SortId = 20;
5811 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar);
5812 }
5813
5814 configDesktopActionsMenu.SortId = 30;
5815 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopActionsMenu);
5816
5817 configDesktopActionsMenu.Design.Size = "auto-width";
5818 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5819 break;
5820 }
5821 }
5822 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5823
5824 @using System
5825 @using System.Web
5826 @using Dynamicweb.Rapido.Blocks.Extensibility
5827 @using Dynamicweb.Rapido.Blocks
5828
5829 @{
5830
5831 }
5832
5833
5834 @helper RenderDesktopTools()
5835 {
5836 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopTools").OrderBy(item => item.SortId).ToList();
5837
5838 <div class="tools-navigation dw-mod">
5839 <div class="center-container grid top-container__center-container dw-mod">
5840 @RenderBlockList(subBlocks)
5841 </div>
5842 </div>
5843 }
5844
5845 @helper RenderDesktopToolsText()
5846 {
5847 string toolsText = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("ToolsText");
5848 if (!string.IsNullOrEmpty(toolsText))
5849 {
5850 <div class="u-margin-top u-margin-bottom">@toolsText</div>
5851 }
5852 }
5853
5854 @helper RenderDesktopToolsNavigation()
5855 {
5856 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar");
5857
5858 if (renderPagesInToolBar)
5859 {
5860 @RenderNavigation(new
5861 {
5862 id = "topToolsNavigation",
5863 cssclass = "menu menu-tools dw-mod dwnavigation",
5864 template = "TopMenu.xslt"
5865 })
5866 }
5867 }
5868
5869 @helper RenderDesktopNavigation()
5870 {
5871 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopNavigation").OrderBy(item => item.SortId).ToList();
5872 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5873 string alignClass = topLayout == "two-lines-centered" ? "grid--justify-center" : "";
5874 <nav class="main-navigation dw-mod">
5875 <div class="center-container top-container__center-container grid @alignClass dw-mod">
5876 @RenderBlockList(subBlocks)
5877 </div>
5878 </nav>
5879 }
5880
5881 @helper RenderDesktopExtra()
5882 {
5883 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopExtra").OrderBy(item => item.SortId).ToList();
5884
5885 if (subBlocks.Count > 0)
5886 {
5887 <div class="header header-top dw-mod">
5888 <div class="center-container top-container__center-container grid--justify-space-between grid grid--align-center dw-mod">
5889 @RenderBlockList(subBlocks)
5890 </div>
5891 </div>
5892 }
5893 }</text>
5894 }
5895
5896 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5897
5898 @using System
5899 @using System.Web
5900 @using Dynamicweb.Rapido.Blocks.Extensibility
5901 @using Dynamicweb.Rapido.Blocks
5902 @using Dynamicweb.Rapido.Blocks.Components.General
5903 @using Dynamicweb.Frontend
5904
5905 @functions {
5906 int impersonationPageId;
5907 string impersonationLayout;
5908 int impersonationFeed;
5909 Block impersonationBar;
5910
5911 string getUserNameFromParams(string firstName, string middleName, string lastName, string name, string email, string userName)
5912 {
5913 string username = "";
5914
5915 if (!string.IsNullOrEmpty(firstName) && !string.IsNullOrEmpty(lastName))
5916 {
5917 username = firstName + " " + (!string.IsNullOrEmpty(middleName) ? middleName + " " : "") + lastName;
5918 }
5919 else if (!string.IsNullOrEmpty(name))
5920 {
5921 username = name;
5922 }
5923 else if (!string.IsNullOrEmpty(email))
5924 {
5925 username = email;
5926 }
5927 else
5928 {
5929 username = userName;
5930 }
5931 return username;
5932 }
5933
5934 string getUserName(UserViewModel user)
5935 {
5936 return getUserNameFromParams(user.FirstName, user.MiddleName, user.LastName, user.Name, user.Email, user.UserName);
5937 }
5938
5939 string getUserName(Dynamicweb.Security.UserManagement.User user)
5940 {
5941 return getUserNameFromParams(user.FirstName, user.MiddleName, user.LastName, user.Name, user.Email, user.UserName);
5942 }
5943 }
5944
5945 @{
5946 impersonationPageId = GetPageIdByNavigationTag("Impersonation");
5947 impersonationLayout = Model.Area.Item.GetItem("Ecommerce").GetList("ImpersonationLayout") != null ? Model.Area.Item.GetItem("Ecommerce").GetList("ImpersonationLayout").SelectedValue : "bar";
5948 impersonationFeed = GetPageIdByNavigationTag("UsersFeed");
5949
5950 if (Model.CurrentUser.ID > 0 && Model.SecondaryUsers.Count > 0)
5951 {
5952 impersonationBar = new Block
5953 {
5954 Id = "ImpersonationBar",
5955 SortId = 50,
5956 Template = RenderImpersonation(),
5957 SkipRenderBlocksList = true,
5958 Design = new Design
5959 {
5960 Size = "auto-width",
5961 HidePadding = true,
5962 RenderType = RenderType.Column
5963 }
5964 };
5965
5966 if (impersonationLayout == "top-bar") {
5967 impersonationBar.SortId = 9;
5968 }
5969
5970 Block impersonationContent = new Block
5971 {
5972 Id = "ImpersonationContent",
5973 SortId = 20
5974 };
5975
5976 if (Model.CurrentSecondaryUser != null && Model.CurrentSecondaryUser.ID > 0)
5977 {
5978 //Render stop impersonation view
5979 impersonationContent.Template = RenderStopImpersonationView();
5980
5981
5982 Modal stopImpersonation = new Modal
5983 {
5984 Id = "StopImpersonation",
5985 Heading = new Heading {
5986 Level = 2,
5987 Title = Translate("Sign out"),
5988 Icon = new Icon {
5989 Name = "fa-sign-out",
5990 Prefix = "fas",
5991 LabelPosition = IconLabelPosition.After
5992 }
5993 },
5994 Width = ModalWidth.Sm,
5995 BodyTemplate = RenderStopImpersonationForm()
5996 };
5997
5998 Block stopImpersonationBlock = new Block
5999 {
6000 Id = "StopImpersonationBlock",
6001 SortId = 10,
6002 Component = stopImpersonation
6003 };
6004 impersonationBar.BlocksList.Add(stopImpersonationBlock);
6005 }
6006 else
6007 {
6008 //Render main view
6009 switch (impersonationLayout)
6010 {
6011 case "right-lower-box":
6012 impersonationContent.BlocksList.Add(
6013 new Block {
6014 Id = "RightLowerBoxHeader",
6015 SortId = 10,
6016 Component = new Heading {
6017 Level = 5,
6018 Title = Translate("View the list of users you can sign in as"),
6019 CssClass = "impersonation-text"
6020 }
6021 }
6022 );
6023 impersonationContent.BlocksList.Add(
6024 new Block {
6025 Id = "RightLowerBoxContent",
6026 SortId = 20,
6027 Template = RenderImpersonationControls()
6028 }
6029 );
6030 break;
6031 case "right-lower-bar":
6032 impersonationContent.BlocksList.Add(
6033 new Block {
6034 Id = "RightLowerBarContent",
6035 SortId = 10,
6036 Template = RenderImpersonationControls()
6037 }
6038 );
6039 break;
6040 case "bar":
6041 default:
6042 impersonationContent.BlocksList.Add(
6043 new Block {
6044 Id = "ViewListLink",
6045 SortId = 20,
6046 Template = RenderViewListLink()
6047 }
6048 );
6049 impersonationContent.BlocksList.Add(
6050 new Block {
6051 Id = "BarTypeaheadSearch",
6052 SortId = 30,
6053 Template = RenderTypeaheadSearch()
6054 }
6055 );
6056 break;
6057 }
6058 }
6059 impersonationBar.BlocksList.Add(impersonationContent);
6060
6061 impersonationBar.BlocksList.Add(
6062 new Block
6063 {
6064 Id = "ImpersonationSearchTemplates",
6065 SortId = 30,
6066 Template = RenderSearchResultTemplate()
6067 }
6068 );
6069 if (impersonationLayout != "bar" && impersonationLayout != "top-bar")
6070 {
6071 impersonationBar.BlocksList.Add(
6072 new Block
6073 {
6074 Id = "ImpersonationSearchScripts",
6075 SortId = 40,
6076 Template = RenderSearchScripts()
6077 }
6078 );
6079 }
6080 BlocksPage.GetBlockPage("Master").Add("MasterHeader", impersonationBar);
6081 }
6082 }
6083
6084 @helper RenderImpersonation()
6085 {
6086 List<Block> subBlocks = impersonationBar.BlocksList.OrderBy(item => item.SortId).ToList();
6087 <input type="checkbox" class="impersonation-trigger js-remember-state" id="ImpersonationMinimizeTrigger" />
6088 <div class="impersonation impersonation--@(impersonationLayout)-layout dw-mod" id="Impersonation">
6089 @if (impersonationLayout == "right-lower-box")
6090 {
6091 @RenderRightLowerBoxHeader()
6092 }
6093 <div class="center-container top-container__center-container impersonation__container @(impersonationLayout != "bar" && impersonationLayout != "top-bar" ? "impersonation__container--box" : "") dw-mod">
6094 @*Impersonation*@
6095 @RenderBlockList(subBlocks)
6096 </div>
6097 </div>
6098 }
6099
6100 @helper RenderRightLowerBoxHeader()
6101 {
6102 <div class="impersonation__header dw-mod">
6103 <div class="impersonation__title">@Translate("Impersonation")</div>
6104 <label for="ImpersonationMinimizeTrigger" class="btn btn--impersonation impersonation__minimize-btn dw-mod" onclick="this.blur();">
6105 @Render(new Icon
6106 {
6107 Prefix = "fas",
6108 Name = "fa-window-minimize"
6109 })
6110 </label>
6111 </div>
6112 }
6113
6114 @helper RenderStopImpersonationView()
6115 {
6116 string secondaryUserName = getUserName(Model.CurrentSecondaryUser);
6117 string userName = getUserName(Pageview.User);
6118 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> ";
6119 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;
6120
6121 if (impersonationLayout == "right-lower-box")
6122 {
6123 <div class="u-margin-bottom--lg u-ta-center">
6124 @impersonationText
6125 </div>
6126 <div class="u-margin-bottom--lg u-ta-center">
6127 @RenderSwitchAccountButton()
6128 </div>
6129 @RenderStopImpersonationButton()
6130 }
6131 else
6132 {
6133 <div class="grid grid--align-center impersonation__stop-wrap">
6134 <div class="impersonation-bar-item dw-mod">
6135 @impersonationText
6136 </div>
6137 <div class="impersonation-bar-item dw-mod">
6138 @RenderSwitchAccountButton()
6139 </div>
6140 <div class="impersonation-bar-item dw-mod">
6141 @RenderStopImpersonationButton()
6142 </div>
6143 </div>
6144 }
6145 }
6146
6147 @helper RenderSwitchAccountButton() {
6148 @Render(new Button
6149 {
6150 Href = "/Default.aspx?ID=" + impersonationPageId,
6151 ButtonType = ButtonType.Button,
6152 ButtonLayout = ButtonLayout.Clean,
6153 Title = Translate("Switch account"),
6154 Icon = new Icon {
6155 Name = "fa-users",
6156 Prefix = "fal",
6157 LabelPosition = IconLabelPosition.After
6158 },
6159 CssClass = "u-no-margin u-color-inherit"
6160 })
6161 }
6162
6163 @helper RenderStopImpersonationForm()
6164 {
6165 string secondaryUserName = getUserName(Model.CurrentSecondaryUser);
6166 string userName = getUserName(Pageview.User);
6167 int pageId = Model.TopPage.ID;
6168
6169 <form method="post" class="u-no-margin">
6170 @Render(new Button
6171 {
6172 ButtonType = ButtonType.Submit,
6173 ButtonLayout = ButtonLayout.Secondary,
6174 Title = Translate("Sign out as") + " " + userName,
6175 Href = "/Default.aspx?ID=" + impersonationPageId,
6176 CssClass = "btn--full",
6177 Name = "DwExtranetRemoveSecondaryUser"
6178 })
6179
6180 @Render(new Button
6181 {
6182 ButtonType = ButtonType.Submit,
6183 ButtonLayout = ButtonLayout.Secondary,
6184 Title = Translate("Sign out as") + " " + secondaryUserName,
6185 Href = "/Admin/Public/ExtranetLogoff.aspx?ID=" + pageId,
6186 CssClass = "btn--full",
6187 Name = "DwExtranetRemoveSecondaryUser"
6188 })
6189 </form>
6190 }
6191
6192 @helper RenderStopImpersonationButton() {
6193 @Render(new Button
6194 {
6195 ButtonType = ButtonType.Button,
6196 ButtonLayout = ButtonLayout.Clean,
6197 Title = Translate("Sign out"),
6198 Icon = new Icon {
6199 Name = "fa-sign-out",
6200 Prefix = "fal",
6201 LabelPosition = IconLabelPosition.After
6202 },
6203 OnClick = "document.getElementById('StopImpersonationModalTrigger').checked = true",
6204 CssClass = "u-no-margin"
6205 })
6206 }
6207
6208 @helper RenderImpersonationControls()
6209 {
6210 <div class="impersonation__controls">
6211 @RenderViewListLink()
6212 @RenderSearchBox()
6213 </div>
6214 @RenderResultsList()
6215 }
6216
6217 @helper RenderViewListLink()
6218 {
6219 string title = impersonationLayout == "right-lower-box" ? Translate("View the list") : Translate("View the list of users you can sign in as");
6220 string buttonClasses = impersonationLayout == "right-lower-box" ? "impersonation__button btn btn--impersonation" : "impersonation__link impersonation__link";
6221
6222 @Render(new Link {
6223 ButtonLayout = ButtonLayout.None,
6224 Title = title,
6225 Href = "/Default.aspx?ID=" + impersonationPageId,
6226 CssClass = buttonClasses
6227 })
6228 }
6229
6230 @helper RenderSearchBox()
6231 {
6232 <div class="impersonation__search-wrap">
6233 <input placeholder="@Translate("Search users")" type="text" class="impersonation__search-field dw-mod" onkeyup="searchKeyUpHandler(event)" id="ImpersonationBoxSearchField">
6234 <div id="ImpersonationBoxSearchFind" class="impersonation__search-icon dw-mod" onclick="updateResults(document.getElementById('ImpersonationBoxSearchField').value)">
6235 <i class="fal fa-search"></i>
6236 </div>
6237 <div id="ImpersonationBoxSearchClear" class="impersonation__search-icon u-hidden dw-mod" onclick="clearResults();">
6238 <i class="fal fa-times"></i>
6239 </div>
6240 </div>
6241 }
6242
6243 @helper RenderTypeaheadSearch()
6244 {
6245 <div class="typeahead u-ta-right impersonation__typeahead js-typeahead dw-mod" id="ImpersonationSearchBar"
6246 data-page-size="5"
6247 data-search-feed-id="@impersonationFeed"
6248 data-result-page-id="@impersonationPageId"
6249 data-search-type="user-search"
6250 data-search-parameter-name="q">
6251
6252 <div class="typeahead-search-field">
6253 <input type="text" class="u-no-margin u-full-width js-typeahead-search-field" placeholder="@Translate("Search users")">
6254 <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>
6255 </div>
6256 </div>
6257 }
6258
6259 @helper RenderResultsList()
6260 {
6261 <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>
6262 }
6263
6264 @helper RenderSearchResultTemplate()
6265 {
6266 <script id="ImpersonationSearchResult" type="text/x-template">
6267 {{#.}}
6268 {{#Users}}
6269 <li class="impersonation__search-results-item impersonation-user">
6270 <form method="post" class="impersonation-user__form" name="account{{id}}">
6271 <input type="hidden" id="DWExtranetSecondaryUserSelector" name="DWExtranetSecondaryUserSelector" value="{{id}}">
6272 <div class="impersonation-user__info">
6273 <div class="impersonation-user__name">{{userName}}</div>
6274 <div class="impersonation-user__number">{{customerNumber}}</div>
6275 </div>
6276 @Render(new Button
6277 {
6278 ButtonType = ButtonType.Submit,
6279 ButtonLayout = ButtonLayout.Secondary,
6280 Title = Translate("Sign in as"),
6281 CssClass = "impersonation-user__sign-in-btn" + (impersonationLayout != "bar" ? " btn--impersonation" : "")
6282 })
6283 </form>
6284 </li>
6285 {{/Users}}
6286 {{#unless Users}}
6287 <li class="impersonation__search-results-item impersonation__search-results-item--not-found">
6288 @Translate("Your search gave 0 results")
6289 </li>
6290 {{/unless}}
6291 {{/.}}
6292 </script>
6293 }
6294
6295 @helper RenderSearchScripts()
6296 {
6297 <script>
6298 let inputDelayTimer;
6299 function searchKeyUpHandler(e) {
6300 clearTimeout(inputDelayTimer);
6301 let value = e.target.value;
6302 if (value != "") {
6303 inputDelayTimer = setTimeout(function () {
6304 updateResults(value);
6305 }, 500);
6306 } else {
6307 clearResults();
6308 }
6309 };
6310
6311 function updateResults(value) {
6312 if (value == "") {
6313 return null;
6314 }
6315 HandlebarsBolt.UpdateContent("ImpersonationBoxSearchResults", "/Default.aspx?ID=@impersonationFeed&q=" + value);
6316 document.getElementById("ImpersonationBoxSearchFind").classList.add("u-hidden");
6317 document.getElementById("ImpersonationBoxSearchClear").classList.remove("u-hidden");
6318 }
6319
6320 function clearResults() {
6321 document.getElementById("ImpersonationBoxSearchField").value = "";
6322 HandlebarsBolt.CleanContainer("ImpersonationBoxSearchResults");
6323 document.getElementById("ImpersonationBoxSearchFind").classList.remove("u-hidden");
6324 document.getElementById("ImpersonationBoxSearchClear").classList.add("u-hidden");
6325 }
6326 </script>
6327 }
6328 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
6329
6330 @using System
6331 @using System.Web
6332 @using System.Collections.Generic
6333 @using Dynamicweb.Rapido.Blocks.Extensibility
6334 @using Dynamicweb.Rapido.Blocks
6335
6336 @{
6337 BlocksPage miniCartBlocksPage = BlocksPage.GetBlockPage("Master");
6338 string orderlinesView = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("OrderlinesView") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("OrderlinesView").SelectedValue : "table";
6339
6340 Block orderLines = new Block
6341 {
6342 Id = "MiniCartOrderLines",
6343 SkipRenderBlocksList = true,
6344 BlocksList = new List<Block>
6345 {
6346 new Block {
6347 Id = "MiniCartOrderLinesList",
6348 SortId = 20,
6349 Template = RenderMiniCartOrderLinesList()
6350 }
6351 }
6352 };
6353
6354 Block orderlinesScriptTemplates = new Block
6355 {
6356 Id = "OrderlinesScriptTemplates"
6357 };
6358
6359 if (orderlinesView == "table")
6360 {
6361 orderLines.Template = RenderMiniCartOrderLinesTable();
6362 orderLines.BlocksList.Add(
6363 new Block
6364 {
6365 Id = "MiniCartOrderlinesTableHeader",
6366 SortId = 10,
6367 Template = RenderMiniCartOrderLinesHeader()
6368 }
6369 );
6370
6371 orderlinesScriptTemplates.Template = RenderMiniCartScriptsTableTemplates();
6372 }
6373 else
6374 {
6375 orderLines.Template = RenderMiniCartOrderLinesBlocks();
6376 orderlinesScriptTemplates.Template = RenderMiniCartScriptsListTemplates();
6377 }
6378
6379 miniCartBlocksPage.Add("MasterBottomSnippets", orderlinesScriptTemplates);
6380
6381 Block miniCartScriptTemplates = new Block()
6382 {
6383 Id = "MasterMiniCartTemplates",
6384 SortId = 1,
6385 Template = RenderMiniCartScriptTemplates(),
6386 SkipRenderBlocksList = true,
6387 BlocksList = new List<Block>
6388 {
6389 orderLines,
6390 new Block {
6391 Id = "MiniCartFooter",
6392 Template = RenderMiniCartFooter(),
6393 SortId = 50,
6394 SkipRenderBlocksList = true,
6395 BlocksList = new List<Block>
6396 {
6397 new Block {
6398 Id = "MiniCartSubTotal",
6399 Template = RenderMiniCartSubTotal(),
6400 SortId = 30
6401 },
6402 new Block {
6403 Id = "MiniCartFees",
6404 Template = RenderMiniCartFees(),
6405 SortId = 40
6406 },
6407 new Block {
6408 Id = "MiniCartPoints",
6409 Template = RenderMiniCartPoints(),
6410 SortId = 50
6411 },
6412 new Block {
6413 Id = "MiniCartTotal",
6414 Template = RenderMiniCartTotal(),
6415 SortId = 60
6416 },
6417 new Block {
6418 Id = "MiniCartDisclaimer",
6419 Template = RenderMiniCartDisclaimer(),
6420 SortId = 70
6421 },
6422 new Block {
6423 Id = "MiniCartActions",
6424 Template = RenderMiniCartActions(),
6425 SortId = 80
6426 }
6427 }
6428 }
6429 }
6430 };
6431
6432 miniCartBlocksPage.Add("MasterBottomSnippets", miniCartScriptTemplates);
6433 }
6434
6435 @helper RenderMiniCartScriptsTableTemplates()
6436 {
6437 <script id="MiniCartOrderline" type="text/x-template">
6438 {{#unless isEmpty}}
6439 <tr>
6440 <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>
6441 <td class="u-va-middle">
6442 <a href="{{link}}" class="mini-cart-orderline__name" title="{{name}}">{{name}}</a>
6443 {{#if variantname}}
6444 <a href="{{link}}" class="mini-cart-orderline__name mini-cart-orderline__name--sm">{{variantname}}</a>
6445 {{/if}}
6446 {{#if unitname}}
6447 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm">{{unitname}}</div>
6448 {{/if}}
6449 </td>
6450 <td class="u-ta-right u-va-middle">{{quantity}}</td>
6451 <td class="u-ta-right u-va-middle">
6452 {{#if pointsTotal}}
6453 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points")
6454 {{else}}
6455 {{totalprice}}
6456 {{/if}}
6457 </td>
6458 </tr>
6459 {{/unless}}
6460 </script>
6461
6462 <script id="MiniCartOrderlineDiscount" type="text/x-template">
6463 {{#unless isEmpty}}
6464 <tr class="table__row--no-border">
6465 <td class="u-w60px"> </td>
6466 <td><div class="mini-cart-orderline__name dw-mod">{{name}}</div></td>
6467 <td class="u-ta-right"> </td>
6468 <td class="u-ta-right">{{totalprice}}</td>
6469 </tr>
6470 {{/unless}}
6471 </script>
6472 }
6473
6474 @helper RenderMiniCartScriptsListTemplates()
6475 {
6476 int cartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
6477
6478 <script id="MiniCartOrderline" type="text/x-template">
6479 {{#unless isEmpty}}
6480 <div class="mini-cart-orderline grid dw-mod">
6481 <div class="grid__col-4">
6482 <a href="{{link}}" class="{{hideimage}}">
6483 <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}}">
6484 </a>
6485 </div>
6486 <div class="grid__col-8">
6487 <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>
6488 {{#if variantname}}
6489 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Variant"): {{variantname}}</div>
6490 {{/if}}
6491 {{#if unitname}}
6492 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Unit"): {{unitname}}</div>
6493 {{/if}}
6494 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Qty"): {{quantity}}</div>
6495
6496 <div class="grid__cell-footer">
6497 <div class="grid__cell">
6498 <div class="u-pull--left mini-cart-orderline__price dw-mod">
6499 {{#if pointsTotal}}
6500 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points")
6501 {{else}}
6502 {{totalprice}}
6503 {{/if}}
6504 </div>
6505 <button type="button"
6506 title="@Translate("Remove orderline")"
6507 class="btn btn--clean btn--condensed u-pull--right mini-cart-orderline__remove-btn dw-mod"
6508 onclick="{{#if googleImpression}}googleImpressionRemoveFromCart({{googleImpression}});{{/if}}Cart.UpdateCart('miniCartContent', '/Default.aspx?ID=@cartFeedPageId', 'CartCmd=DelOrderLine&key={{orderLineId}}&redirect=false', true);">@Translate("Remove")</button>
6509 </div>
6510 </div>
6511 </div>
6512 </div>
6513 {{/unless}}
6514 </script>
6515
6516 <script id="MiniCartOrderlineDiscount" type="text/x-template">
6517 {{#unless isEmpty}}
6518 <div class="mini-cart-orderline mini-cart-orderline--discount grid dw-mod">
6519 <div class="grid__col-4">
6520 <div class="mini-cart-orderline__name mini-cart-orderline__name dw-mod">{{name}}</div>
6521 </div>
6522 <div class="grid__col-8">{{totalprice}}</div>
6523 </div>
6524 {{/unless}}
6525 </script>
6526 }
6527
6528 @helper RenderMiniCartScriptTemplates()
6529 {
6530 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterMiniCartTemplates").OrderBy(item => item.SortId).ToList();
6531 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID"));
6532 string cartPageLink = string.Concat("/Default.aspx?ID=", GetPageIdByNavigationTag("CartPage"));
6533 bool miniCartUseGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID"));
6534
6535 <script id="MiniCartContent" type="text/x-template">
6536 {{#.}}
6537 {{#unless isEmpty}}
6538 @if (miniCartUseGoogleTagManager)
6539 {
6540 <text>{{{googleEnchantImpressionEmptyCart OrderLines}}}</text>
6541 }
6542 @RenderBlockList(subBlocks)
6543 {{/unless}}
6544 {{/.}}
6545 </script>
6546 }
6547
6548 @helper RenderMiniCartOrderLinesTable()
6549 {
6550 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartOrderLines").OrderBy(item => item.SortId).ToList();
6551
6552 <div class="u-overflow-auto">
6553 <table class="table mini-cart-table dw-mod">
6554 @RenderBlockList(subBlocks)
6555 </table>
6556 </div>
6557 }
6558
6559 @helper RenderMiniCartOrderLinesBlocks()
6560 {
6561 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartOrderLines").OrderBy(item => item.SortId).ToList();
6562
6563 <div class="u-overflow-auto">
6564 @RenderBlockList(subBlocks)
6565 </div>
6566 }
6567
6568 @helper RenderMiniCartOrderLinesHeader()
6569 {
6570 <thead>
6571 <tr>
6572 <td> </td>
6573 <td>@Translate("Product")</td>
6574 <td class="u-ta-right">@Translate("Qty")</td>
6575 <td class="u-ta-right" width="120">@Translate("Price")</td>
6576 </tr>
6577 </thead>
6578 }
6579
6580 @helper RenderMiniCartOrderLinesList()
6581 {
6582 <text>
6583 {{#OrderLines}}
6584 {{#ifCond template "===" "CartOrderline"}}
6585 {{>MiniCartOrderline}}
6586 {{/ifCond}}
6587 {{#ifCond template "===" "CartOrderlineMobile"}}
6588 {{>MiniCartOrderline}}
6589 {{/ifCond}}
6590 {{#ifCond template "===" "CartOrderlineDiscount"}}
6591 {{>MiniCartOrderlineDiscount}}
6592 {{/ifCond}}
6593 {{/OrderLines}}
6594 </text>
6595 }
6596
6597 @helper RenderMiniCartFees()
6598 {
6599 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly");
6600 if (!pointShop)
6601 {
6602 <text>
6603 {{#unless hidePaymentfee}}
6604 <div class="grid">
6605 <div class="grid__col-6 grid__col--bleed-y">
6606 {{paymentmethod}}
6607 </div>
6608 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{paymentfee}}</div>
6609 </div>
6610 {{/unless}}
6611 </text>
6612 }
6613 <text>
6614 {{#unless hideShippingfee}}
6615 <div class="grid">
6616 <div class="grid__col-6 grid__col--bleed-y">
6617 {{shippingmethod}}
6618 </div>
6619 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{shippingfee}}</div>
6620 </div>
6621 {{/unless}}
6622 </text>
6623 <text>
6624 {{#if hasTaxSettings}}
6625 <div class="grid">
6626 <div class="grid__col-6 grid__col--bleed-y">@Translate("Sales Tax")</div>
6627 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{totaltaxes}}</div>
6628 </div>
6629 {{/if}}
6630 </text>
6631 }
6632
6633 @helper RenderMiniCartFooter()
6634 {
6635 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartFooter").OrderBy(item => item.SortId).ToList();
6636
6637 <div class="mini-cart__footer u-border-top u-padding-top dw-mod">
6638 @RenderBlockList(subBlocks)
6639 </div>
6640 }
6641
6642 @helper RenderMiniCartActions()
6643 {
6644 int cartPageId = GetPageIdByNavigationTag("CartPage");
6645
6646 <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>
6647 <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>
6648 }
6649
6650 @helper RenderMiniCartPoints()
6651 {
6652 <text>
6653 {{#if earnings}}
6654 <div class="grid">
6655 <div class="grid__col-6 grid__col--bleed-y">@Translate("Earnings")</div>
6656 <div class="grid__col-6 grid__col--bleed-y grid--align-end">
6657 <div>
6658 <span class="u-color--loyalty-points">{{earnings}}</span> @Translate("points")
6659 </div>
6660 </div>
6661 </div>
6662 {{/if}}
6663 </text>
6664 }
6665
6666 @helper RenderMiniCartSubTotal()
6667 {
6668 bool hasTaxSettings = Dynamicweb.Rapido.Services.Countries.HasTaxSettings(Model.Cart.ID);
6669 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly");
6670 if (!pointShop)
6671 {
6672 <text>
6673 {{#unless hideSubTotal}}
6674 <div class="grid dw-mod u-bold">
6675 <div class="grid__col-6 grid__col--bleed-y">@Translate("Subtotal")</div>
6676 <div class="grid__col-6 grid__col--bleed-y grid--align-end">
6677 @if (hasTaxSettings)
6678 {
6679 <text>{{subtotalpricewithouttaxes}}</text>
6680 }
6681 else
6682 {
6683 <text>{{subtotalprice}}</text>
6684 }
6685 </div>
6686 </div>
6687 {{/unless}}
6688 </text>
6689 }
6690 }
6691
6692 @helper RenderMiniCartTotal()
6693 {
6694 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly");
6695
6696 <div class="mini-cart-totals grid u-border-top u-margin-top dw-mod">
6697 <div class="grid__col-6">@Translate("Total")</div>
6698 <div class="grid__col-6 grid--align-end">
6699 <div>
6700 @if (pointShop)
6701 {
6702 <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points")
6703 }
6704 else
6705 {
6706 <text>{{totalprice}}</text>
6707 }
6708 </div>
6709 </div>
6710 </div>
6711 }
6712
6713 @helper RenderMiniCartDisclaimer()
6714 {
6715 <text>
6716 {{#if showCheckoutDisclaimer}}
6717 <div class="grid u-margin-bottom u-ta-right">
6718 <small class="grid__col-12">{{checkoutDisclaimer}}</small>
6719 </div>
6720 {{/if}}
6721 </text>
6722 }
6723 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
6724
6725 @using Dynamicweb.Rapido.Blocks.Extensibility
6726 @using Dynamicweb.Rapido.Blocks
6727 @using Dynamicweb.Rapido.Blocks.Components.General
6728 @using Dynamicweb.Rapido.Blocks.Components
6729 @using Dynamicweb.Rapido.Services
6730
6731 @{
6732 string addToCartNotificationType = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("AddToCartNotificationType") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("AddToCartNotificationType").SelectedValue : "";
6733 string addToCartNotificationMiniCartLayout = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout").SelectedValue : "dropdown";
6734 bool addToCartHideCartIcon = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart");
6735
6736 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed() && !string.IsNullOrEmpty(addToCartNotificationType))
6737 {
6738 if (addToCartNotificationType == "modal")
6739 {
6740 Block addToCartNotificationModal = new Block
6741 {
6742 Id = "AddToCartNotificationModal",
6743 Template = RenderAddToCartNotificationModal()
6744 };
6745
6746 Block addToCartNotificationScript = new Block
6747 {
6748 Id = "AddToCartNotificationScript",
6749 Template = RenderAddToCartNotificationModalScript()
6750 };
6751 BlocksPage.GetBlockPage("Master").Add("MasterTopSnippets", addToCartNotificationModal);
6752 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", addToCartNotificationScript);
6753 }
6754 else if (addToCartNotificationType == "toggle" && addToCartNotificationMiniCartLayout != "none" && !addToCartHideCartIcon && Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet")
6755 {
6756 Block addToCartNotificationScript = new Block
6757 {
6758 Id = "AddToCartNotificationScript",
6759 Template = RenderAddToCartNotificationToggleScript()
6760 };
6761 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", addToCartNotificationScript);
6762 }
6763 }
6764 }
6765
6766 @helper RenderAddToCartNotificationModal()
6767 {
6768 <div id="LastAddedProductModal" data-template="LastAddedProductTemplate"></div>
6769 }
6770
6771 @helper RenderAddToCartNotificationModalScript()
6772 {
6773 int cartPageId = GetPageIdByNavigationTag("CartPage");
6774
6775 <script id="LastAddedProductTemplate" type="text/x-template">
6776 @{
6777
6778 Modal lastAddedProduct = new Modal
6779 {
6780 Id = "LastAddedProduct",
6781 Heading = new Heading
6782 {
6783 Level = 2,
6784 Title = Translate("Product is added to the cart")
6785 },
6786 Width = ModalWidth.Md,
6787 BodyTemplate = RenderModalContent()
6788 };
6789
6790 lastAddedProduct.AddActions(
6791 new Button
6792 {
6793 ButtonType = ButtonType.Button,
6794 ButtonLayout = ButtonLayout.Secondary,
6795 Title = Translate("Continue shopping"),
6796 CssClass = "u-pull--left u-no-margin btn--sm",
6797 OnClick = "document.getElementById('LastAddedProductModalTrigger').checked = false"
6798 },
6799 new Link
6800 {
6801 Href = "/Default.aspx?ID=" + cartPageId,
6802 ButtonLayout = ButtonLayout.Secondary,
6803 CssClass = "u-pull--right u-no-margin btn--sm",
6804 Title = Translate("Proceed to checkout"),
6805 OnClick = "document.getElementById('LastAddedProductModalTrigger').checked = false"
6806 }
6807 );
6808
6809 @Render(lastAddedProduct)
6810 }
6811 </script>
6812 <script>
6813 document.addEventListener('addToCart', function (event) {
6814 Cart.ShowLastAddedProductModal(event.detail);
6815 });
6816 </script>
6817 }
6818
6819 @helper RenderModalContent()
6820 {
6821 <div class="grid">
6822 <div class="grid__col-2">
6823 @Render(new Image { Path = "{{ productInfo.image }}", Link = "{{ productInfo.link }}", Title = "{{ productInfo.name }}", DisableImageEngine = true })
6824 </div>
6825 <div class="u-padding grid--align-self-center">
6826 <span>{{quantity}}</span> x
6827 </div>
6828 <div class="grid__col-auto grid--align-self-center">
6829 <div>{{productInfo.name}}</div>
6830 {{#if productInfo.variantName}}
6831 <small class="u-margin-bottom-5px">{{productInfo.variantName}}</small>
6832 {{/if}}
6833 {{#if productInfo.unitName}}
6834 <small class="u-margin-bottom-5px">{{productInfo.unitName}}</small>
6835 {{/if}}
6836 </div>
6837 </div>
6838 }
6839
6840 @helper RenderAddToCartNotificationToggleScript()
6841 {
6842 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
6843
6844 <script>
6845 document.addEventListener('addToCart', function () {
6846 Cart.ToggleMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '@miniCartFeedPageId');
6847 });
6848 </script>
6849 }
6850 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
6851
6852 @using System
6853 @using System.Web
6854 @using System.Collections.Generic
6855 @using Dynamicweb.Rapido.Blocks.Extensibility
6856 @using Dynamicweb.Rapido.Blocks
6857 @using Dynamicweb.Rapido.Blocks.Components.General
6858
6859 @functions {
6860 BlocksPage footerBlocksPage = BlocksPage.GetBlockPage("Master");
6861 }
6862
6863 @{
6864 string footerColumnOneContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnOne").GetString("Content");
6865 string footerColumnTwoContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnTwo").GetString("Content");
6866 string footerColumnThreeContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnThree").GetString("Content");
6867 string footerColumnOneHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnOne").GetString("Header");
6868 string footerColumnTwoHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnTwo").GetString("Header");
6869 string footerColumnThreeHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnThree").GetString("Header");
6870
6871 Block masterFooterContent = new Block()
6872 {
6873 Id = "MasterFooterContent",
6874 SortId = 10,
6875 Template = RenderFooter(),
6876 SkipRenderBlocksList = true
6877 };
6878 footerBlocksPage.Add(MasterBlockId.MasterFooter, masterFooterContent);
6879
6880 if (!string.IsNullOrEmpty(footerColumnOneContent) || !string.IsNullOrEmpty(footerColumnOneHeader))
6881 {
6882 Block masterFooterColumnOne = new Block
6883 {
6884 Id = "MasterFooterColumnOne",
6885 SortId = 10,
6886 Template = RenderFooterColumn(footerColumnOneHeader, footerColumnOneContent),
6887 Design = new Design
6888 {
6889 Size = "auto",
6890 RenderType = RenderType.Column
6891 }
6892 };
6893 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnOne);
6894 }
6895
6896 if (!string.IsNullOrEmpty(footerColumnTwoContent) || !string.IsNullOrEmpty(footerColumnTwoHeader))
6897 {
6898 Block masterFooterColumnTwo = new Block
6899 {
6900 Id = "MasterFooterColumnTwo",
6901 SortId = 20,
6902 Template = RenderFooterColumn(footerColumnTwoHeader, footerColumnTwoContent),
6903 Design = new Design
6904 {
6905 Size = "auto",
6906 RenderType = RenderType.Column
6907 }
6908 };
6909 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnTwo);
6910 }
6911
6912 if (!string.IsNullOrEmpty(footerColumnThreeContent) || !string.IsNullOrEmpty(footerColumnThreeHeader))
6913 {
6914 Block masterFooterColumnThree = new Block
6915 {
6916 Id = "MasterFooterColumnThree",
6917 SortId = 30,
6918 Template = RenderFooterColumn(footerColumnThreeHeader, footerColumnThreeContent),
6919 Design = new Design
6920 {
6921 Size = "auto",
6922 RenderType = RenderType.Column
6923 }
6924 };
6925 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnThree);
6926 }
6927
6928 if (Model.Area.Item.GetItem("Layout").GetBoolean("FooterNewsletterSignUp"))
6929 {
6930 Block masterFooterNewsletterSignUp = new Block
6931 {
6932 Id = "MasterFooterNewsletterSignUp",
6933 SortId = 40,
6934 Template = RenderFooterNewsletterSignUp(),
6935 Design = new Design
6936 {
6937 Size = "auto",
6938 RenderType = RenderType.Column
6939 }
6940 };
6941 footerBlocksPage.Add("MasterFooterContent", masterFooterNewsletterSignUp);
6942 }
6943
6944 if (Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks") != null && Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks").Count > 0)
6945 {
6946 Block masterFooterSocialLinks = new Block
6947 {
6948 Id = "MasterFooterSocialLinks",
6949 SortId = 50,
6950 Template = RenderFooterSocialLinks(),
6951 Design = new Design
6952 {
6953 Size = "auto",
6954 RenderType = RenderType.Column
6955 }
6956 };
6957 footerBlocksPage.Add("MasterFooterContent", masterFooterSocialLinks);
6958 }
6959
6960 if (Model.Area.Item.GetItem("Layout").GetItems("FooterPayments") != null && Model.Area.Item.GetItem("Layout").GetItems("FooterPayments").Count > 0)
6961 {
6962 Block masterFooterPayments = new Block
6963 {
6964 Id = "MasterFooterPayments",
6965 SortId = 60,
6966 Template = RenderFooterPayments(),
6967 Design = new Design
6968 {
6969 Size = "12",
6970 RenderType = RenderType.Column
6971 }
6972 };
6973 footerBlocksPage.Add("MasterFooterContent", masterFooterPayments);
6974 }
6975
6976 Block masterFooterCopyright = new Block
6977 {
6978 Id = "MasterFooterCopyright",
6979 SortId = 70,
6980 Template = RenderFooterCopyright(),
6981 Design = new Design
6982 {
6983 Size = "12",
6984 RenderType = RenderType.Column
6985 }
6986 };
6987 footerBlocksPage.Add("MasterFooterContent", masterFooterCopyright);
6988 }
6989
6990 @helper RenderFooter()
6991 {
6992 List<Block> subBlocks = this.footerBlocksPage.GetBlockListById("MasterFooterContent").OrderBy(item => item.SortId).ToList();
6993
6994 <footer class="footer no-print dw-mod">
6995 <div class="center-container top-container__center-container dw-mod">
6996 <div class="grid grid--external-bleed-x">
6997 @RenderBlockList(subBlocks)
6998 </div>
6999 </div>
7000 </footer>
7001 }
7002
7003 @helper RenderFooterColumn(string header, string content)
7004 {
7005 <h3 class="footer__heading dw-mod">@header</h3>
7006 <div class="footer__content dw-mod">
7007 @content
7008 </div>
7009 }
7010
7011 @helper RenderFooterNewsletterSignUp()
7012 {
7013 string newsletterSignUpPageId = GetPageIdByNavigationTag("NewsletterSignUp").ToString();
7014 Form form = new Form { Action = "/Default.aspx", Method = FormMethod.Get, Enctype = FormEnctype.multipart };
7015
7016 form.Add(new HiddenField { Name = "ID", Value = newsletterSignUpPageId });
7017 form.Add(new Text { Content = "<p>" + Translate("Sign up if you would like to receive occasional treats from us") + "</p>" });
7018 form.Add(new TextField {
7019 Id = "NewsletterEmail", Name = "NewsletterEmail", Placeholder = Translate("Your email address"),
7020 Type = TextFieldType.Email,
7021 ActionButton = new Button {
7022 ButtonType = ButtonType.Submit, Id="Submitter", Title = Translate("Go"), OnClick = "Buttons.LockButton(event)", CssClass = "btn--condensed"
7023 }
7024 });
7025
7026 <h3 class="footer__heading dw-mod">@Translate("Mailing list")</h3>
7027 <div class="footer__content dw-mod">
7028 @Render(form)
7029 </div>
7030 }
7031
7032 @helper RenderFooterSocialLinks()
7033 {
7034 <h3 class="footer__heading dw-mod">@Translate("Social links")</h3>
7035 <div class="footer__content dw-mod">
7036 <div class="collection dw-mod">
7037 @foreach (var socialitem in Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks"))
7038 {
7039 var socialIcon = socialitem.GetValue("Icon") as Dynamicweb.Frontend.ListViewModel;
7040 string socialIconClass = socialIcon.SelectedValue;
7041 string socialIconTitle = socialIcon.SelectedName;
7042 string socialLink = socialitem.GetString("Link");
7043
7044 <a href="@socialLink" target="_blank" title="@socialIconTitle" class="u-margin-bottom-5px" rel="noopener"><i class="@socialIconClass fa-2x"></i></a>
7045 }
7046 </div>
7047 </div>
7048 }
7049
7050 @helper RenderFooterPayments()
7051 {
7052 <div class="footer__content dw-mod">
7053 <div class="collection dw-mod">
7054 @foreach (var payment in Model.Area.Item.GetItem("Layout").GetItems("FooterPayments"))
7055 {
7056 var paymentItem = payment.GetValue("CardTypeOrVerifiedPayment") as Dynamicweb.Frontend.ListViewModel;
7057 string paymentImage = null;
7058 string paymentTitle = paymentItem.SelectedName;
7059 ListOptionViewModel selected = paymentItem.SelectedOptions.FirstOrDefault();
7060 if (selected != null)
7061 {
7062 paymentImage = selected.Icon;
7063 }
7064
7065 <div class="footer__card-type">
7066 <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" />
7067 </div>
7068 }
7069 </div>
7070 </div>
7071 }
7072
7073 @helper RenderFooterCopyright()
7074 {
7075 <div class="grid__col-12 footer__copyright dw-mod">
7076 <p>@Model.Area.Item.GetItem("Layout").GetString("FooterCopyrightText")</p>
7077 </div>
7078 }
7079 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
7080
7081 @using System
7082 @using System.Web
7083 @using System.Collections.Generic
7084 @using Dynamicweb.Rapido.Blocks.Extensibility
7085 @using Dynamicweb.Rapido.Blocks
7086
7087 @{
7088 BlocksPage searchBlocksPage = BlocksPage.GetBlockPage("Master");
7089 bool navigationItemsHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch");
7090 bool isFavoriteList = !string.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("ListID"));
7091
7092 if (!navigationItemsHideSearch || isFavoriteList)
7093 {
7094 Block masterSearchScriptTemplates = new Block()
7095 {
7096 Id = "MasterSearchScriptTemplates",
7097 SortId = 1,
7098 Template = RenderSearchScriptTemplates()
7099 };
7100
7101 searchBlocksPage.Add(MasterBlockId.MasterBottomSnippets, masterSearchScriptTemplates);
7102 }
7103 }
7104
7105 @helper RenderSearchScriptTemplates()
7106 {
7107 int productsPageId = GetPageIdByNavigationTag("ProductsPage");
7108 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID;
7109 bool useFacebookPixel = !string.IsNullOrWhiteSpace(Pageview.AreaSettings.GetItem("Settings").GetString("FacebookPixelID"));
7110 bool onlyPreview = Model.Area.Item.GetItem("Ecommerce").GetBoolean("OnlyPreviewForAnonymous") && Model.CurrentUser.ID == 0;
7111 bool useGoogleTagManager = !string.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("GoogleTagManagerID"));
7112 bool showPrice = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HidePriceInSearchResults");
7113 bool showAddToCartButton = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HideAddToCartButton");
7114 bool showViewButton = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HideViewButton");
7115 bool showAddToDownloadButton = Pageview.AreaSettings.GetItem("Layout").GetBoolean("ShowAddToDownloadButton");
7116 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly");
7117
7118 <script id="SearchGroupsTemplate" type="text/x-template">
7119 {{#.}}
7120 <li class="dropdown__item dw-mod" onclick="Search.UpdateGroupSelection(this)" data-group-id="{{id}}">{{name}}</li>
7121 {{/.}}
7122 </script>
7123
7124 <script id="SearchProductsTemplate" type="text/x-template">
7125 {{#each .}}
7126 {{#Product}}
7127 {{#ifCond template "!==" "SearchMore"}}
7128 <li class="dropdown__item dropdown__item--seperator dw-mod">
7129 @if (useFacebookPixel)
7130 {
7131 <text>{{{facebookPixelSearch name number priceDouble currency searchParameter}}}</text>
7132 }
7133 @if (useGoogleTagManager)
7134 {
7135 <text>{{{googleEnchantImpression 'Search results' currency googleImpression}}}</text>
7136 }
7137 <div>
7138 <a href="{{link}}" class="js-typeahead-link u-color-inherit u-pull--left" onclick="{{googleImpressionClick}}" title="{{name}}">
7139 <div class="u-margin-right u-pull--left {{noimage}} u-hidden-xs u-hidden-xxs"><img src="{{PerfionImageSrc imageGuid 50 50}}" alt="{{name}}"></div>
7140
7141 <div class="u-pull--left">
7142 <div class="u-bold u-max-w220px u-truncate-text js-typeahead-name">{{name}}</div>
7143 @if (showPrice && !onlyPreview)
7144 {
7145 if (pointShopOnly)
7146 {
7147 <text>
7148 {{#if havePointPrice}}
7149 <div>
7150 <span class="u-color--loyalty-points">{{points}}</span> @Translate("points")
7151 </div>
7152 {{else}}
7153 <small class="help-text u-no-margin">@Translate("Not available")</small>
7154 {{/if}}
7155 {{#unless canBePurchasedWithPoints}}
7156 {{#if havePointPrice}}
7157 <small class="help-text u-no-margin">@Translate("Not enough points to buy this")</small>
7158 {{/if}}
7159 {{/unless}}
7160 </text>
7161 }
7162 else
7163 {
7164 <div>{{price}}</div>
7165 }
7166 }
7167 </div>
7168 </a>
7169 <div class="u-margin-left u-pull--right">
7170 @if (showAddToCartButton && !onlyPreview) {
7171 if (pointShopOnly)
7172 {
7173 <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"
7174 onclick="Cart.AddToCart(event, {id: '{{productId}}',quantity: 1,buyForPoints: true,productInfo: {{productInfo}}}); {{facebookPixelAction}}"
7175 {{disabledBuyButton}}>
7176 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue js-ignore-click-outside"></i>
7177 </button>
7178 } else {
7179 <button type="button" class="btn btn--primary btn--condensed btn--full u-no-margin dw-mod {{hideBuyOptions}} js-ignore-click-outside"
7180 onclick="Cart.AddToCart(event, {id: '{{productId}}', quantity: 1,productInfo: {{productInfo}}}); {{facebookPixelAction}}">
7181 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue js-ignore-click-outside"></i>
7182 </button>
7183 }
7184 <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>
7185 }
7186 else if (showViewButton)
7187 {
7188 <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>
7189 }
7190 @if (showAddToDownloadButton)
7191 {
7192 <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}}">
7193 <i class="fas fa-plus js-button-icon"></i>
7194 </button>
7195 }
7196 </div>
7197 </div>
7198 </li>
7199 {{/ifCond}}
7200 {{#ifCond template "===" "SearchMore"}}
7201 {{>SearchMoreProducts}}
7202 {{/ifCond}}
7203 {{/Product}}
7204 {{else}}
7205 <li class="dropdown__item dropdown__item--seperator dw-mod">
7206 @Translate("Your search gave 0 results")
7207 </li>
7208 {{/each}}
7209 </script>
7210
7211 <script id="SearchMoreProducts" type="text/x-template">
7212 <li class="dropdown__item dropdown__item--not-selectable {{stickToBottom}} dw-mod">
7213 <a href="/Default.aspx?ID=@productsPageId&Search={{searchParameter}}&GroupID={{groupId}}" class="btn btn--primary btn--full u-no-margin dw-mod js-typeahead-link">
7214 @Translate("View all")
7215 </a>
7216 </li>
7217 </script>
7218
7219 <script id="SearchMorePages" type="text/x-template">
7220 <li class="dropdown__item dropdown__item--not-selectable {{stickToBottom}} dw-mod">
7221 <a href="/Default.aspx?ID=@contentSearchPageLink&Search={{searchParameter}}" class="btn btn--primary btn--full u-no-margin dw-mod js-typeahead-link">
7222 @Translate("View all")
7223 </a>
7224 </li>
7225 </script>
7226
7227 <script id="SearchPagesTemplate" type="text/x-template">
7228 {{#each .}}
7229 {{#ifCond template "!==" "SearchMore"}}
7230 <li class="dropdown__item dropdown__item--seperator dw-mod">
7231 <div>
7232 <a href="/Default.aspx?ID={{id}}" class="js-typeahead-link u-pull--left u-color-inherit">
7233 <div class="u-margin-right u-pull--left"><i class="fa {{icon}} u-w20px u-ta-center"></i></div>
7234 <div class="u-pull--left">
7235 <div class="u-bold u-truncate-text u-max-w220px js-typeahead-name">{{name}}</div>
7236 </div>
7237 </a>
7238 </div>
7239 </li>
7240 {{/ifCond}}
7241 {{#ifCond template "===" "SearchMore"}}
7242 {{>SearchMorePages}}
7243 {{/ifCond}}
7244 {{else}}
7245 <li class="dropdown__item dropdown__item--seperator dropdown__item--not-selectable dw-mod">
7246 @Translate("Your search gave 0 results")
7247 </li>
7248 {{/each}}
7249 </script>
7250
7251 <script id="SearchPagesTemplateWrap" type="text/x-template">
7252 <div class="dropdown__column-header">@Translate("Pages")</div>
7253 <ul class="dropdown__list u-min-w220px u-full-width u-margin-bottom dw-mod">
7254 {{>SearchPagesTemplate}}
7255 </ul>
7256 </script>
7257
7258 <script id="SearchProductsTemplateWrap" type="text/x-template">
7259 <div class="dropdown__column-header">@Translate("Products")</div>
7260 <ul class="dropdown__list u-min-w220px u-full-width u-margin-bottom dw-mod">
7261 {{>SearchProductsTemplate}}
7262 </ul>
7263 </script>
7264 }
7265
7266
7267 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
7268
7269 @using System
7270 @using System.Web
7271 @using System.Collections.Generic
7272 @using Dynamicweb.Rapido.Blocks.Extensibility
7273 @using Dynamicweb.Rapido.Blocks
7274 @using Dynamicweb.Ecommerce.Common
7275
7276 @{
7277 BlocksPage referencesBlocksPage = BlocksPage.GetBlockPage("Master");
7278
7279 Block masterScriptReferences = new Block()
7280 {
7281 Id = "MasterScriptReferences",
7282 SortId = 1,
7283 Template = RenderMasterScriptReferences()
7284 };
7285 referencesBlocksPage.Add(MasterBlockId.MasterReferences, masterScriptReferences);
7286 }
7287
7288 @helper RenderMasterScriptReferences() {
7289
7290 @* Custom: only load script if on newsletter page *@
7291 if (Pageview.ID == GetPageIdByNavigationTag("NewsletterSignUp"))
7292 {
7293 @* JQuery for mailchimp script *@
7294 <script type='text/javascript' src='//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js'></script>
7295 <script type='text/javascript'>
7296 (function ($) {
7297 window.fnames = new Array();
7298 window.ftypes = new Array();
7299 fnames[0] = 'EMAIL';
7300 ftypes[0] = 'email';
7301 fnames[1] = 'FNAME';
7302 ftypes[1] = 'text';
7303 fnames[2] = 'LNAME';
7304 ftypes[2] = 'text';
7305 fnames[3] = 'MMERGE3';
7306 ftypes[3] = 'text';
7307 fnames[4] = 'MMERGE4';
7308 ftypes[4] = 'text';
7309 fnames[5] = 'MMERGE5';
7310 ftypes[5] = 'text';
7311 fnames[6] = 'MMERGE6';
7312 ftypes[6] = 'text';
7313 fnames[7] = 'MMERGE7';
7314 ftypes[7] = 'text';
7315 }
7316 (jQuery));
7317 var $mcj = jQuery.noConflict(true);
7318 </script>
7319 }
7320
7321 <script src="/Files/Templates/Designs/Rapido/js/handlebars-v4.0.12.min.js" data-cookieconsent="ignore"></script>
7322 <script src="/Files/Templates/Designs/Rapido/js/master.min.js?v1.0" data-cookieconsent="ignore"></script>
7323
7324 if (Model.Area.Item.GetItem("Custom").GetBoolean("UseCustomJavascript"))
7325 {
7326 <script src="/Files/Templates/Designs/Rapido/js/custom.min.js?v1.2" data-cookieconsent="ignore"></script>
7327 PushPromise("/Files/Templates/Designs/Rapido/js/custom.min.js?v1.2");
7328 }
7329
7330 PushPromise("/Files/Templates/Designs/Rapido/js/handlebars-v4.0.12.min.js?v1.0");
7331 PushPromise("/Files/Templates/Designs/Rapido/js/master.min.js?v1.0");
7332 }
7333 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
7334
7335 @using System
7336 @using System.Web
7337 @using System.Collections.Generic
7338 @using Dynamicweb.Rapido.Blocks.Extensibility
7339 @using Dynamicweb.Rapido.Blocks
7340
7341 @{
7342 BlocksPage bottomSnippetsBlocksPage = BlocksPage.GetBlockPage("Master");
7343
7344 Block primaryBottomSnippets = new Block()
7345 {
7346 Id = "MasterJavascriptInitializers",
7347 SortId = 100,
7348 Template = RenderPrimaryBottomSnippets()
7349 };
7350 bottomSnippetsBlocksPage.Add(MasterBlockId.MasterReferences, primaryBottomSnippets);
7351
7352 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed())
7353 {
7354 Block miniCartPageId = new Block
7355 {
7356 Id = "MiniCartPageId",
7357 Template = RenderMiniCartPageId()
7358 };
7359 bottomSnippetsBlocksPage.Add(MasterBlockId.MasterReferences, miniCartPageId);
7360 }
7361 }
7362
7363 @helper RenderPrimaryBottomSnippets()
7364 {
7365 bool isWireframeMode = Model.Area.Item.GetItem("Settings").GetBoolean("WireframeMode");
7366 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID"));
7367
7368 if (isWireframeMode)
7369 {
7370 <script>
7371 Wireframe.Init(true);
7372 </script>
7373 }
7374
7375
7376 if (useGoogleTagManager)
7377 {
7378 <script>
7379 document.addEventListener('addToCart', function(event) {
7380 var googleImpression = JSON.parse(event.detail.productInfo.googleImpression);
7381 if (typeof googleImpression == "string") {
7382 googleImpression = JSON.parse(event.detail.productInfo.googleImpression);
7383 }
7384 dataLayer.push({
7385 'event': 'addToCart',
7386 'ecommerce': {
7387 'currencyCode': googleImpression.currency,
7388 'add': {
7389 'products': [{
7390 'name': googleImpression.name,
7391 'id': googleImpression.id,
7392 'price': googleImpression.price,
7393 'brand': googleImpression.brand,
7394 'category': googleImpression.category,
7395 'variant': googleImpression.variant,
7396 'quantity': event.detail.quantity
7397 }]
7398 }
7399 }
7400 });
7401 });
7402 </script>
7403 }
7404
7405 //if digitalwarehouse
7406 if (Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowDownloadCart"))
7407 {
7408 string cartContextId = Converter.ToString(HttpContext.Current.Application["DownloadCartContext"]);
7409
7410 if (string.IsNullOrEmpty(cartContextId))
7411 {
7412 var moduleProps = Dynamicweb.Modules.Properties.GetParagraphModuleSettings(GetPageIdByNavigationTag("DownloadCart"), "eCom_CartV2");
7413 var cartSettings = new Dynamicweb.Ecommerce.Cart.ModuleSettings(moduleProps);
7414 cartContextId = cartSettings.OrderContextID;
7415 HttpContext.Current.Application["DownloadCartContext"] = cartContextId;
7416 }
7417
7418 <script>
7419 let downloadCart = new DownloadCart({
7420 cartPageId: @GetPageIdByNavigationTag("MiniCartFeed"),
7421 contextId: "@cartContextId",
7422 addButtonText: "@Translate("Add")",
7423 removeButtonText: "@Translate("Remove")"
7424 });
7425 </script>
7426 }
7427
7428 @* Custom *@
7429 <script data-cookieconsent="ignore">
7430 let GlobalSettings = {
7431 PerfionApiUrl: '@GlobalSettingsHelper.GetValue(PicoGlobalSettingsNames.PerfionWebApiUrl)'
7432 }
7433 </script>
7434
7435 <!--$$Javascripts-->
7436 }
7437
7438 @helper RenderMiniCartPageId()
7439 {
7440 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
7441 <script>
7442 window.cartId = "@miniCartFeedPageId";
7443 </script>
7444 }
7445
7446
7447 @functions {
7448 public class ManifestIcon
7449 {
7450 public string src { get; set; }
7451 public string type { get; set; }
7452 public string sizes { get; set; }
7453 }
7454
7455 public class Manifest
7456 {
7457 public string name { get; set; }
7458 public string short_name { get; set; }
7459 public string start_url { get; set; }
7460 public string display { get; set; }
7461 public string background_color { get; set; }
7462 public string theme_color { get; set; }
7463 public List<ManifestIcon> icons { get; set; }
7464 }
7465 }
7466
7467 <!DOCTYPE html>
7468
7469 <html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName">
7470
7471
7472
7473 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@
7474 @RenderBlockList(masterPage.BlocksRoot.BlocksList)
7475
7476
7477
7478 @helper RenderMasterHead()
7479 {
7480 List<Block> subBlocks = this.masterPage.GetBlockListById("Head").OrderBy(item => item.SortId).ToList();
7481
7482 <head>
7483 <!-- Rapido version 3.4.3 -->
7484
7485 @RenderBlockList(subBlocks)
7486 </head>
7487
7488 }
7489
7490 @helper RenderMasterMetadata()
7491 {
7492 var swatches = new Dynamicweb.Content.Items.ColorSwatchService();
7493 var brandColors = swatches.GetColorSwatch(1);
7494 string brandColorOne = brandColors.Palette["BrandColor1"];
7495
7496 if (!String.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("AppName")) && Model.Area.Item.GetItem("Settings").GetFile("AppIcon") != null)
7497 {
7498 Manifest manifest = new Manifest
7499 {
7500 name = Model.Area.Item.GetItem("Settings").GetString("AppName"),
7501 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"),
7502 start_url = "/",
7503 display = "standalone",
7504 background_color = Model.Area.Item.GetItem("Settings").GetString("AppBackgroundColor"),
7505 theme_color = Model.Area.Item.GetItem("Settings").GetString("AppThemeColor")
7506 };
7507
7508 manifest.icons = new List<ManifestIcon> {
7509 new ManifestIcon {
7510 src = "/Admin/Public/GetImage.ashx?width=192&height=192&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded,
7511 sizes = "192x192",
7512 type = "image/png"
7513 },
7514 new ManifestIcon {
7515 src = "/Admin/Public/GetImage.ashx?width=512&height=512&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded,
7516 sizes = "512x512",
7517 type = "image/png"
7518 },
7519 new ManifestIcon {
7520 src = "/Admin/Public/GetImage.ashx?width=1024&height=1024&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded,
7521 sizes = "1024x1024",
7522 type = "image/png"
7523 }
7524 };
7525
7526 string manifestFilePath = HttpContext.Current.Request.MapPath("/Files/Templates/Designs/Rapido/manifest.json");
7527 string manifestJSON = Newtonsoft.Json.JsonConvert.SerializeObject(manifest);
7528 string currentManifest = File.ReadAllText(manifestFilePath);
7529
7530 if (manifestJSON != currentManifest)
7531 {
7532 File.WriteAllText(manifestFilePath, manifestJSON);
7533 }
7534 }
7535
7536 <meta charset="utf-8" />
7537 <title>@Model.Title</title>
7538 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7539 <meta name="robots" content="index, follow">
7540 <meta name="theme-color" content="@brandColorOne" />
7541
7542 if (!Model.MetaTags.Contains("og:image"))
7543 {
7544 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")));
7545 }
7546
7547 if (!Model.MetaTags.Contains("og:description"))
7548 {
7549 Pageview.Meta.AddTag("og:description", Model.Description);
7550 }
7551
7552 Pageview.Meta.AddTag("og:title", Model.Title);
7553 Pageview.Meta.AddTag("og:site_name", Model.Name);
7554 Pageview.Meta.AddTag("og:url", HttpContext.Current.Request.Url.ToString());
7555 Pageview.Meta.AddTag("og:type", "Website");
7556
7557 if (!string.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("FacebookAppID")))
7558 {
7559 Pageview.Meta.AddTag("fb:app_id", Model.Area.Item.GetItem("Settings").GetString("FacebookAppID"));
7560 }
7561
7562 @Model.MetaTags
7563 }
7564
7565 @helper RenderMasterCss()
7566 {
7567 @*
7568 var fonts = new string[] {
7569 getFontFamily("Layout", "HeaderFont"),
7570 getFontFamily("Layout", "SubheaderFont"),
7571 getFontFamily("Layout", "TertiaryHeaderFont"),
7572 getFontFamily("Layout", "BodyText"),
7573 getFontFamily("Layout", "Header", "ToolsFont"),
7574 getFontFamily("Layout", "Header", "NavigationFont"),
7575 getFontFamily("Layout", "MobileNavigation", "Font"),
7576 getFontFamily("ProductList", "Facets", "HeaderFont"),
7577 getFontFamily("ProductPage", "PriceFontDesign"),
7578 getFontFamily("Ecommerce", "SaleSticker", "Font"),
7579 getFontFamily("Ecommerce", "NewSticker", "Font"),
7580 getFontFamily("Ecommerce", "CustomSticker", "Font")
7581 };
7582 *@
7583
7584 string autoCssLink = "/Files/Templates/Designs/Rapido/css/rapido/rapido_" + Model.Area.ID.ToString() + ".min.css?ticks=" + Model.Area.UpdatedDate.Ticks;
7585 string favicon = Model.Area.Item.GetItem("Layout").GetFile("LogoFavicon") != null ? Model.Area.Item.GetItem("Layout").GetFile("LogoFavicon").Path : "/Files/Images/favicon.png";
7586 bool useFontAwesomePro = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetBoolean("UseFontAwesomePro");
7587 string fontAwesomeCssLink = "/Files/Templates/Designs/Rapido/css/fonts/FontAwesomeFree/css/fontawesome-all.min.css";
7588 if (useFontAwesomePro)
7589 {
7590 fontAwesomeCssLink = "/Files/Templates/Designs/Rapido/css/fonts/FontAwesomePro/css/fontawesome-all.min.css";
7591 }
7592
7593 //Favicon
7594 <link href="@favicon" rel="icon" type="image/png">
7595
7596 //Base (Default, wireframe) styles
7597 <link rel="stylesheet" href="/Files/Templates/Designs/Rapido/css/base/base.min.css" type="text/css">
7598
7599 //Rapido Css from Website Settings
7600 <link rel="stylesheet" id="rapidoCss" href="@autoCssLink" type="text/css">
7601
7602 //Ignite Css (Custom site specific styles)
7603 <link rel="stylesheet" id="igniteCss" type="text/css" href="/Files/Templates/Designs/Rapido/css/ignite/ignite.min.css">
7604
7605 //Font awesome
7606 <link rel="stylesheet" href="@fontAwesomeCssLink" type="text/css">
7607
7608 //Flag icon
7609 <link rel="stylesheet" href="/Files/Templates/Designs/Rapido/css/fonts/flag-icon.min.css" type="text/css">
7610
7611 //Google fonts
7612 // Google fonts are now loaded from local repository
7613 @*
7614 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)));
7615
7616 <link href="https://fonts.googleapis.com/css?family=@family&display=swap" rel="stylesheet">*@
7617
7618 PushPromise(favicon);
7619 PushPromise(fontAwesomeCssLink);
7620 PushPromise("/Files/Templates/Designs/Rapido/css/base/base.min.css");
7621 PushPromise(autoCssLink);
7622 PushPromise("/Files/Templates/Designs/Rapido/css/ignite/ignite.min.css");
7623 PushPromise("/Files/Images/placeholder.gif");
7624 PushPromise("/Files/Templates/Designs/Rapido/css/fonts/flag-icon.min.css");
7625 }
7626
7627 @helper RenderMasterManifest()
7628 {
7629 if (!String.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("AppName")))
7630 {
7631 <link rel="manifest" href="/Files/Templates/Designs/Rapido/manifest.json">
7632 PushPromise("/Files/Templates/Designs/Rapido/manifest.json");
7633 }
7634 }
7635
7636 @helper RenderMasterBody()
7637 {
7638 List<Block> subBlocks = this.masterPage.GetBlockListById("Body").OrderBy(item => item.SortId).ToList();
7639 string designLayout = Model.PropertyItem.GetItem("CustomSettings") != null ? Model.PropertyItem.GetItem("CustomSettings").GetString("DesignLayout") != null ? Model.PropertyItem.GetItem("CustomSettings").GetList("DesignLayout").SelectedValue : "" : "";
7640 if (!String.IsNullOrEmpty(designLayout))
7641 {
7642 designLayout = "class=\"" + designLayout + "\"";
7643 }
7644 else
7645 {
7646 designLayout = "id=\"sitecontent\"";
7647 }
7648
7649 <body @designLayout>
7650 @RenderBlockList(subBlocks)
7651 </body>
7652
7653 }
7654
7655 @helper RenderMasterHeader()
7656 {
7657 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterHeader").OrderBy(item => item.SortId).ToList();
7658 bool isNavigationStickyMenu = Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet" && Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("StickyTop");
7659 string stickyTop = isNavigationStickyMenu ? "top-container--sticky" : "";
7660
7661 <header class="top-container @stickyTop dw-mod" id="Top">
7662 @RenderBlockList(subBlocks)
7663 </header>
7664 }
7665
7666 @helper RenderMain()
7667 {
7668 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterMain").OrderBy(item => item.SortId).ToList();
7669
7670 <main class="site dw-mod">
7671 @RenderBlockList(subBlocks)
7672 </main>
7673 }
7674
7675 @helper RenderPageContent()
7676 {
7677 bool isNavigationStickyMenu = Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet" && Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("StickyTop");
7678 string pagePos = isNavigationStickyMenu ? "js-page-pos" : "";
7679
7680 <div id="Page" class="page @pagePos">
7681 <section class="center-container content-container dw-mod" id="content">
7682
7683 @RenderSnippet("Content")
7684 </section>
7685 </div>
7686 }
7687
7688 @* Hack to support nested helpers *@
7689 @SnippetStart("Content")
7690 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
7691
7692
7693 @using Dynamicweb.Extensibility
7694 @using Dynamicweb.Core
7695 @using Dynamicweb.Rapido.Blocks.Components
7696 @using Dynamicweb.Rapido.Blocks.Components.Articles
7697 @using Dynamicweb.Rapido.Blocks.Components.General
7698 @using Dynamicweb.Rapido.Blocks
7699 @using Dynamicweb.Content.Items
7700
7701 @functions {
7702 BlocksPage articlePage = BlocksPage.GetBlockPage("DynamicArticle");
7703
7704 public string GetParentSettingsItem(string systemName) {
7705 string item = null;
7706
7707 Dynamicweb.Content.Page current = Dynamicweb.Services.Pages.GetPage(Model.ID);
7708 while (current != null && current.Parent != current) {
7709 var temp = current.Item != null ? current.Item[systemName] : "";
7710
7711 if (temp != null) {
7712 item = temp.ToString();
7713
7714 if (!String.IsNullOrEmpty(item) && !String.Equals("default", item, StringComparison.OrdinalIgnoreCase)) {
7715 break;
7716 }
7717 }
7718
7719 current = current.Parent;
7720 }
7721
7722 return item;
7723 }
7724
7725 public string GetArticleCategory(int pageId)
7726 {
7727 string categoryName = null;
7728
7729 //Secure that the article is not in the root folder = Actual has a category
7730 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent != null) {
7731 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent != null) {
7732 if (!String.IsNullOrEmpty(Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent.ItemType))
7733 {
7734 categoryName = Dynamicweb.Services.Pages.GetPage(pageId).Parent.GetDisplayName();
7735 }
7736 }
7737 }
7738
7739 return categoryName;
7740 }
7741
7742 public string GetArticleCategoryColor(int pageId)
7743 {
7744 string categoryColor = "";
7745
7746 //Secure that the article is not in the root folder = Actual has a category
7747 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent != null) {
7748 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent != null) {
7749 if (!String.IsNullOrEmpty(Dynamicweb.Services.Pages.GetPage(pageId).Parent.Parent.ItemType))
7750 {
7751 if (Dynamicweb.Services.Pages.GetPage(pageId).Parent.Item["CategoryColor"] != null)
7752 {
7753 var service = new ColorSwatchService();
7754 categoryColor = Dynamicweb.Services.Pages.GetPage(pageId).Parent.Item["CategoryColor"].ToString();
7755
7756 if (!categoryColor.Contains("#")) {
7757 categoryColor = service.GetHexColor(Converter.ToInt32(Model.Area.ID), categoryColor);
7758 }
7759 }
7760 }
7761 }
7762 }
7763
7764 return categoryColor;
7765 }
7766 }
7767
7768 @{
7769 string listPageId = Converter.ToString(GetPageIdByNavigationTag("DynamicListFeed"));
7770 string parentPageId = Dynamicweb.Services.Pages.GetPage(Model.ID).Parent.ID.ToString();
7771 string topLayout = Model.Item.GetList("TopLayout") != null ? Model.Item.GetList("TopLayout").SelectedValue : "default";
7772 topLayout = topLayout == "default" && GetParentSettingsItem("ArticleTopLayout") != null ? GetParentSettingsItem("ArticleTopLayout").ToString().ToLower() : topLayout;
7773 string textLayout = Model.Item.GetList("TextLayout") != null ? Model.Item.GetList("TextLayout").SelectedValue : "default";
7774 textLayout = textLayout == "default" && GetParentSettingsItem("ArticleTextLayout") != null ? GetParentSettingsItem("ArticleTextLayout").ToString().ToLower() : textLayout;
7775 string imageLayout = Model.Item.GetList("ImageLayout") != null ? Model.Item.GetList("ImageLayout").SelectedValue : "default";
7776 imageLayout = imageLayout == "default" && GetParentSettingsItem("ArticleImageLayout") != null ? GetParentSettingsItem("ArticleImageLayout").ToString().ToLower() : imageLayout;
7777
7778 string imageColumns = imageLayout == "straight" && textLayout != "full" ? "8" : "12";
7779 string contentColumns = textLayout != "full" ? "8" : "12";
7780
7781 int externalParagraphId = Model.Item.GetItem("CTAParagraphLink") != null ? Model.Item.GetItem("CTAParagraphLink").ParagraphID : 0;
7782
7783 ArticleHeaderLayout headerLayout;
7784
7785 switch (topLayout)
7786 {
7787 case "default":
7788 headerLayout = ArticleHeaderLayout.Clean;
7789 break;
7790 case "split":
7791 headerLayout = ArticleHeaderLayout.Split;
7792 break;
7793 case "banner":
7794 headerLayout = ArticleHeaderLayout.Banner;
7795 break;
7796 case "overlay":
7797 headerLayout = ArticleHeaderLayout.Overlay;
7798 break;
7799 default:
7800 headerLayout = ArticleHeaderLayout.Clean;
7801 break;
7802 }
7803
7804
7805 Block articleContainer = new Block
7806 {
7807 Id = "ArticleContainer",
7808 SortId = 10,
7809 Design = new Design
7810 {
7811 RenderType = RenderType.Row
7812 },
7813 BlocksList = new List<Block> {
7814 new Block {
7815 Id = "ArticleBody",
7816 SortId = 30,
7817 Design = new Design {
7818 RenderType = RenderType.Column,
7819 Size = "12",
7820 HidePadding = true
7821 }
7822 }
7823 }
7824 };
7825 articlePage.Add(articleContainer);
7826
7827 ButtonLayout topBannerButtonLayout = ButtonLayout.Primary;
7828
7829 switch (Model.Item.GetString("ButtonDesign")) {
7830 case "primary":
7831 topBannerButtonLayout = ButtonLayout.Primary;
7832 break;
7833 case "secondary":
7834 topBannerButtonLayout = ButtonLayout.Secondary;
7835 break;
7836 case "teritary":
7837 topBannerButtonLayout = ButtonLayout.Tertiary;
7838 break;
7839 case "link":
7840 topBannerButtonLayout = ButtonLayout.Link;
7841 break;
7842 }
7843
7844 ArticleHeader topBanner = new ArticleHeader
7845 {
7846 Layout = headerLayout,
7847 Image = new Image { Path = Model.Item.GetFile("Image"), ImageDefault = new ImageSettings { Width = 1920, Height = 640 } },
7848 Heading = Model.Item.GetString("Title"),
7849 Subheading = Model.Item.GetString("Summary"),
7850 TextColor = "#fff",
7851 Author = Model.Item.GetString("Author"),
7852 Date = Model.Item.GetString("Date"),
7853 Category = GetArticleCategory(Model.ID),
7854 CategoryColor = GetArticleCategoryColor(Model.ID),
7855 Link = Model.Item.GetString("Link"),
7856 LinkText = Model.Item.GetString("LinkText"),
7857 ButtonLayout = topBannerButtonLayout,
7858 RatingScore = Model.Item.GetString("Rating") != null ? Converter.ToInt32(Model.Item.GetList("Rating").SelectedValue) : 0,
7859 RatingOutOf = Model.Item.GetString("Rating") != null ? Model.Item.GetList("Rating").Options.Count : 0,
7860 ExternalParagraphId = externalParagraphId
7861 };
7862
7863 Block articleTop = new Block
7864 {
7865 Id = "ArticleHead",
7866 SortId = 20,
7867 Component = topBanner,
7868 Design = new Design
7869 {
7870 RenderType = RenderType.Column,
7871 Size = "12",
7872 HidePadding = true,
7873 CssClass = "article-head"
7874 }
7875 };
7876 articlePage.Add("ArticleContainer", articleTop);
7877
7878
7879 Block articleBodyRow = new Block
7880 {
7881 Id = "ArticleBodyRow",
7882 SortId = 10,
7883 SkipRenderBlocksList = true
7884 };
7885 articlePage.Add("ArticleBody", articleBodyRow);
7886
7887
7888 if (Model.Item.GetString("Paragraphs") != null)
7889 {
7890 int count = 0;
7891 foreach (var paragraph in Model.Item.GetItems("Paragraphs"))
7892 {
7893 if (!paragraph.GetBoolean("RenderAsQuote"))
7894 {
7895 string enableDropCap = Model.Item.GetString("EnableDropCap") != null ? Model.Item.GetList("EnableDropCap").SelectedValue.ToLower() : "default";
7896 enableDropCap = enableDropCap == "default" && GetParentSettingsItem("EnableDropCap") != null ? GetParentSettingsItem("EnableDropCap").ToString().ToLower() : enableDropCap;
7897 string text = paragraph.GetString("Text") != null ? paragraph.GetString("Text") : "";
7898
7899 if (!String.IsNullOrEmpty(text) && enableDropCap == "true" && count == 0 && paragraph.GetString("Text").Substring(0, 3) == "<p>")
7900 {
7901 string firstLetter = paragraph.GetString("Text").Substring(3, 1);
7902 text = paragraph.GetString("Text").Remove(3, 1);
7903 text = text.Insert(3, "<span class=\"article__drop-cap\">" + firstLetter + "</span>");
7904 }
7905
7906 if (paragraph.GetFile("Image") != null)
7907 {
7908 string imageTitle = !string.IsNullOrEmpty(paragraph.GetString("Heading")) ? paragraph.GetString("Heading") : "";
7909
7910 Block articleParagraphImage = new Block
7911 {
7912 Id = "ArticleParagraph" + count + "Image",
7913 SortId = (count * 10),
7914 Design = new Design
7915 {
7916 RenderType = RenderType.Column,
7917 Size = imageColumns,
7918 CssClass = "u-color-light--bg u-padding--lg"
7919 }
7920 };
7921
7922 if (imageLayout == "banner")
7923 {
7924 ArticleBanner banner = new ArticleBanner
7925 {
7926 Image = new Image { Path = paragraph.GetFile("Image"), ImageDefault = new ImageSettings { Height = 650, Width = 1300 }, Caption = paragraph.GetString("ImageCaption") },
7927 Heading = imageTitle,
7928 UseFilters = false
7929 };
7930 articleParagraphImage.Component = banner;
7931 }
7932 else
7933 {
7934 ArticleImage image = new ArticleImage
7935 {
7936 Image = new Image
7937 {
7938 Path = paragraph.GetFile("Image"),
7939 Title = imageTitle,
7940 ImageDefault = new ImageSettings { Height = 650, Width = 1300 },
7941 Caption = paragraph.GetString("ImageCaption")
7942 }
7943 };
7944 articleParagraphImage.Component = image;
7945 }
7946
7947 articlePage.Add("ArticleBodyRow", articleParagraphImage);
7948 }
7949
7950 if (!String.IsNullOrEmpty(paragraph.GetString("VideoURL")))
7951 {
7952 Block articleParagraphVideo = new Block
7953 {
7954 Id = "ArticleParagraph" + count + "Video",
7955 SortId = (count * 10) + 1,
7956 Component = new ArticleVideo { Url = paragraph.GetString("VideoURL"), AutoPlay = "false" },
7957 Design = new Design
7958 {
7959 RenderType = RenderType.Column,
7960 Size = imageColumns,
7961 CssClass = "u-color-light--bg u-padding--lg"
7962 }
7963 };
7964 articlePage.Add("ArticleBodyRow", articleParagraphVideo);
7965 }
7966
7967 if (!String.IsNullOrEmpty(paragraph.GetString("Heading")))
7968 {
7969 Block articleParagraphHeader = new Block
7970 {
7971 Id = "ArticleParagraph" + count + "Heading",
7972 SortId = (count * 10) + 2,
7973 Component = new ArticleSubHeader { Title = paragraph.GetString("Heading") },
7974 Design = new Design
7975 {
7976 RenderType = RenderType.Column,
7977 Size = contentColumns,
7978 CssClass = "u-color-light--bg u-padding--lg"
7979 }
7980 };
7981 articlePage.Add("ArticleBodyRow", articleParagraphHeader);
7982 }
7983
7984 if (!String.IsNullOrEmpty(text))
7985 {
7986 Block articleParagraphText = new Block
7987 {
7988 Id = "ArticleParagraph" + count + "Text",
7989 SortId = (count * 10) + 3,
7990 Component = new ArticleText { Text = text },
7991 Design = new Design
7992 {
7993 RenderType = RenderType.Column,
7994 Size = contentColumns,
7995 CssClass = "u-color-light--bg u-padding--lg"
7996 }
7997 };
7998
7999 articlePage.Add("ArticleBodyRow", articleParagraphText);
8000 }
8001 }
8002 else
8003 {
8004 if (!String.IsNullOrEmpty(paragraph.GetString("Text")))
8005 {
8006 string quoteText = paragraph.GetString("Text") != null ? paragraph.GetString("Text") : "";
8007 string quoteAuthor = paragraph.GetString("Heading") != null ? paragraph.GetString("Heading") : "";
8008
8009 Block articleParagraphQuote = new Block
8010 {
8011 Id = "ArticleParagraph" + count + "Quote",
8012 SortId = (count * 10) + 3,
8013 Component = new ArticleQuote { Image = new Image { Path = paragraph.GetFile("Image") }, Text = quoteText, Author = quoteAuthor },
8014 Design = new Design
8015 {
8016 RenderType = RenderType.Column,
8017 Size = contentColumns,
8018 CssClass = "u-color-light--bg u-padding--lg"
8019 }
8020 };
8021 articlePage.Add("ArticleBodyRow", articleParagraphQuote);
8022 }
8023 }
8024
8025 count++;
8026 }
8027 }
8028
8029 articleBodyRow.Component = new ArticleBodyRow { SubBlocks = articleBodyRow.BlocksList, TopLayout = topLayout, TextLayout = textLayout };
8030
8031
8032 //Related
8033 string showRelatedArtices = Model.Item.GetString("ShowRelatedArticles") != null ? Model.Item.GetList("ShowRelatedArticles").SelectedValue.ToLower() : "default";
8034 showRelatedArtices = showRelatedArtices == "default" && GetParentSettingsItem("ShowRelatedArticles") != null ? GetParentSettingsItem("ShowRelatedArticles").ToString().ToLower() : showRelatedArtices;
8035
8036 if (showRelatedArtices == "true")
8037 {
8038 Block articleRelated = new Block
8039 {
8040 Id = "ArticleRelated",
8041 SortId = 30,
8042 Component = new ArticleRelated { Title = Translate("Related articles"), FeedPageId = listPageId, Query = "sourceType=Page&sourcePage=" + parentPageId, PageSize = 4, CurrentPageId = Model.ID.ToString() },
8043 Design = new Design
8044 {
8045 RenderType = RenderType.Column,
8046 Size = "12"
8047 }
8048 };
8049 articlePage.Add("ArticleContainer", articleRelated);
8050 }
8051 }
8052
8053
8054 @using System
8055 @using System.Web
8056 @using System.Collections.Generic
8057 @using Dynamicweb.Rapido.Blocks
8058
8059 @{
8060 BlocksPage dynamicArticleCustomBlocksPage = BlocksPage.GetBlockPage("DynamicArticle");
8061
8062 }
8063
8064
8065 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@
8066 @RenderBlockList(articlePage.BlocksRoot.BlocksList)
8067 @SnippetEnd("Content")
8068
8069 @helper RenderIosTabletFix()
8070 {
8071 if (Pageview.Device != Dynamicweb.Frontend.Devices.DeviceType.Tablet && Pageview.Platform != Dynamicweb.Frontend.Devices.PlatformType.Ios)
8072 {
8073 <script>
8074 let isIpadIOS = (/iPad/.test(navigator.platform) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)) && !window.MSStream;
8075 if (isIpadIOS) {
8076 var separator = (window.location.href.indexOf("?") === -1) ? "?" : "&";
8077 window.location.href = window.location.href + separator + "DeviceType=Tablet&PlatformType=Ios";
8078 }
8079 </script>
8080 }
8081 }
8082
8083 </html>
8084
8085