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