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