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