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