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