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