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