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