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_1864cb7a6fc649919236f93fbbcc330c.<RenderMasterMetadata>b__192_0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 7350
at RazorEngine.Templating.TemplateWriter.ToString()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at CompiledRazorTemplates.Dynamic.RazorEngine_1864cb7a6fc649919236f93fbbcc330c.<>c__DisplayClass3_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 246
at CompiledRazorTemplates.Dynamic.RazorEngine_1864cb7a6fc649919236f93fbbcc330c.<>c__DisplayClass2_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 156
at CompiledRazorTemplates.Dynamic.RazorEngine_1864cb7a6fc649919236f93fbbcc330c.<RenderMasterHead>b__191_0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 7295
at RazorEngine.Templating.TemplateWriter.ToString()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at CompiledRazorTemplates.Dynamic.RazorEngine_1864cb7a6fc649919236f93fbbcc330c.<>c__DisplayClass3_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 246
at CompiledRazorTemplates.Dynamic.RazorEngine_1864cb7a6fc649919236f93fbbcc330c.<>c__DisplayClass2_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 156
at CompiledRazorTemplates.Dynamic.RazorEngine_1864cb7a6fc649919236f93fbbcc330c.<>c__DisplayClass3_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 279
at CompiledRazorTemplates.Dynamic.RazorEngine_1864cb7a6fc649919236f93fbbcc330c.<>c__DisplayClass2_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 156
at CompiledRazorTemplates.Dynamic.RazorEngine_1864cb7a6fc649919236f93fbbcc330c.Execute() in D:\dynamicweb.net\Solutions\Dynamicweb\dignet.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\_parsed\Page.parsed.cshtml:line 7285
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
2
3 @using System.Web;
4 @using Dynamicweb.Frontend
5 @using Dynamicweb.Frontend.Devices
6 @using Dynamicweb.Extensibility
7 @using Dynamicweb.Content
8 @using Dynamicweb.Security
9 @using Dynamicweb.Core
10 @using System
11 @using System.Web
12 @using System.IO
13 @using Dynamicweb.Rapido.Blocks
14 @using System.Net
15
16
17 @functions {
18 BlocksPage masterPage = BlocksPage.GetBlockPage("Master");
19
20 string getFontFamily(params string[] items)
21 {
22 var itemParent = Pageview.AreaSettings;
23 foreach (var item in items)
24 {
25 itemParent = itemParent.GetItem(item);
26 if (itemParent == null)
27 {
28 return null;
29 }
30 }
31
32 var googleFont = itemParent.GetGoogleFont("FontFamily");
33 if (googleFont == null)
34 {
35 return null;
36 }
37 return googleFont.Family.Replace(" ", "+");
38 }
39 }
40
41 @{
42 Block root = new Block
43 {
44 Id = "Root",
45 SortId = 10,
46 BlocksList = new List<Block>
47 {
48 new Block {
49 Id = "Head",
50 SortId = 10,
51 SkipRenderBlocksList = true,
52 Template = RenderMasterHead(),
53 BlocksList = new List<Block>
54 {
55 new Block {
56 Id = "HeadMetadata",
57 SortId = 10,
58 Template = RenderMasterMetadata(),
59 },
60 new Block {
61 Id = "HeadCss",
62 SortId = 20,
63 Template = RenderMasterCss(),
64 },
65 new Block {
66 Id = "HeadManifest",
67 SortId = 30,
68 Template = RenderMasterManifest(),
69 }
70 }
71 },
72 new Block {
73 Id = "Body",
74 SortId = 20,
75 SkipRenderBlocksList = true,
76 Template = RenderMasterBody(),
77 BlocksList = new List<Block>
78 {
79 new Block()
80 {
81 Id = "Master",
82 SortId = 10,
83 BlocksList = new List<Block> {
84 new Block {
85 Id = "MasterTopSnippets",
86 SortId = 10
87 },
88 new Block {
89 Id = "MasterMain",
90 SortId = 20,
91 Template = RenderMain(),
92 SkipRenderBlocksList = true,
93 BlocksList = new List<Block> {
94 new Block {
95 Id = "MasterHeader",
96 SortId = 10,
97 Template = RenderMasterHeader(),
98 SkipRenderBlocksList = true
99 },
100 new Block {
101 Id = "MasterPageContent",
102 SortId = 20,
103 Template = RenderPageContent()
104 }
105 }
106 },
107 new Block {
108 Id = "MasterFooter",
109 SortId = 30
110 },
111 new Block {
112 Id = "MasterReferences",
113 SortId = 40
114 },
115 new Block {
116 Id = "MasterBottomSnippets",
117 SortId = 50
118 }
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-3 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 @{
3285 BlocksPage topSnippetsBlocksPage = BlocksPage.GetBlockPage("Master");
3286
3287 Block tagManager = new Block()
3288 {
3289 Id = "TagManager",
3290 SortId = 1,
3291 Template = RenderGoogleTagManager()
3292 };
3293
3294 Block facebookPixel = new Block()
3295 {
3296 Id = "FacebookPixel",
3297 SortId = 2,
3298 Template = RenderFacebookPixel()
3299 };
3300
3301 topSnippetsBlocksPage.Add(MasterBlockId.MasterTopSnippets, tagManager);
3302 topSnippetsBlocksPage.Add(MasterBlockId.MasterTopSnippets, facebookPixel);
3303 }
3304
3305 @helper RenderGoogleTagManager() {
3306 string GoogleTagManagerID = Model.Area.Item.GetItem("Settings").GetString("GoogleTagManagerID");
3307
3308 if (!string.IsNullOrWhiteSpace(GoogleTagManagerID))
3309 {
3310 <script>
3311 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
3312 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
3313 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
3314 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
3315 })(window,document,'script','dataLayer','@GoogleTagManagerID');
3316 </script>
3317 <!-- Google Tag Manager (noscript) -->
3318 <noscript>
3319 <iframe src="https://www.googletagmanager.com/ns.html?id=@GoogleTagManagerID"
3320 height="0" width="0" style="display:none;visibility:hidden"></iframe>
3321 </noscript>
3322 <!-- End Google Tag Manager (noscript) -->
3323 }
3324 }
3325
3326 @helper RenderFacebookPixel() {
3327 string FacebookPixelID = Model.Area.Item.GetItem("Settings").GetString("FacebookPixelID");
3328
3329 if (!string.IsNullOrWhiteSpace(FacebookPixelID))
3330 {
3331 <!-- Facebook Pixel Code -->
3332 <script>
3333 !function(f,b,e,v,n,t,s)
3334 {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
3335 n.callMethod.apply(n,arguments):n.queue.push(arguments)};
3336 if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
3337 n.queue=[];t=b.createElement(e);t.async=!0;
3338 t.src=v;s=b.getElementsByTagName(e)[0];
3339 s.parentNode.insertBefore(t,s)}(window, document,'script',
3340 'https://connect.facebook.net/en_US/fbevents.js');
3341 fbq('init', '@FacebookPixelID');
3342 fbq('track', 'PageView');
3343 </script>
3344 <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=@FacebookPixelID&ev=PageView&noscript=1" alt="" /></noscript>
3345 }
3346 }
3347 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
3348
3349 @using System
3350 @using System.Web
3351 @using System.Collections.Generic
3352 @using Dynamicweb.Rapido.Blocks
3353 @using Dynamicweb.Rapido.Blocks.Extensibility
3354 @using Dynamicweb.Security.UserManagement
3355 @using Dynamicweb.Security.UserManagement.ExternalAuthentication
3356 @using Dynamicweb.Rapido.Blocks.Components.General
3357
3358 @{
3359 BlocksPage loginBlocksPage = BlocksPage.GetBlockPage("Master");
3360
3361 Block loginModal = new Block()
3362 {
3363 Id = "LoginModal",
3364 SortId = 10,
3365 Component = new Modal
3366 {
3367 Id = "SignIn",
3368 Heading = new Heading
3369 {
3370 Level = 0,
3371 Title = Translate("Sign in")
3372 },
3373 Width = ModalWidth.Xs,
3374 BodyTemplate = RenderLoginForm()
3375 }
3376 };
3377
3378 loginBlocksPage.Add(MasterBlockId.MasterTopSnippets, loginModal);
3379 }
3380
3381 @helper RenderLoginForm()
3382 {
3383 int pageId = Model.TopPage.ID;
3384 string userSignedInErrorText = "";
3385 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
3386 string forgotPasswordPageLink = "/Default.aspx?ID=" + signInProfilePageId + "&LoginAction=Recovery";
3387 int createAccountPageId = GetPageIdByNavigationTag("CreateAccount");
3388 bool showModalOnStart = pageId != GetPageIdByNavigationTag("CustomerCenter") && Model.LogOnFailed;
3389 bool hideCreateAccountLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideCreateAccount");
3390 bool hideForgotPasswordLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideForgotPasswordLink");
3391
3392 ProviderCollection providers = Provider.GetActiveProviders();
3393
3394 if (Model.LogOnFailed)
3395 {
3396 switch (Model.LogOnFailedReason)
3397 {
3398 case LogOnFailedReason.PasswordLengthInvalid:
3399 userSignedInErrorText = Translate("Password length is invalid");
3400 break;
3401 case LogOnFailedReason.IncorrectLogin:
3402 userSignedInErrorText = Translate("Invalid email or password");
3403 break;
3404 case LogOnFailedReason.ExceededFailedLogOnLimit:
3405 userSignedInErrorText = Translate("You have exceeded the limit of allowed login attempts. The user account is temporarily locked");
3406 break;
3407 case LogOnFailedReason.LoginLocked:
3408 userSignedInErrorText = Translate("The user account is temporarily locked");
3409 break;
3410 case LogOnFailedReason.PasswordExpired:
3411 userSignedInErrorText = Translate("The password has expired and needs to be renewed");
3412 break;
3413 default:
3414 userSignedInErrorText = Translate("An unknown error occured");
3415 break;
3416 }
3417 }
3418
3419 Form form = new Form { Method = FormMethod.Post, Name = "LoginModalForm" };
3420
3421 form.Add(new HiddenField { Name = "ID", Value = Converter.ToString(pageId) });
3422 form.Add(new HiddenField { Name = "DWExtranetUsernameRemember", Value = "True" });
3423 form.Add(new HiddenField { Name = "DWExtranetPasswordRemember", Value = "True" });
3424 form.Add(new HiddenField { Name = "LoginAction", Value = "Login" });
3425 form.Add(new TextField { Id = "LoginUsername", Name = "username", Label = Translate("Email"), CssClass = "u-full-width", Required = true });
3426 form.Add(new TextField { Id = "LoginPassword", Name = "password", Type = TextFieldType.Password, Label = Translate("Password"), CssClass = "u-full-width", Required = true });
3427 form.Add(new NotificationMessage { Message = userSignedInErrorText, MessageType = NotificationMessageType.Error });
3428 form.Add(new CheckboxField { Id = "LoginRememberMe", Value = "True", Name = "Autologin", Label = Translate("Remember me") });
3429 form.Add(new Button { ButtonType = ButtonType.Submit, Title = Translate("Sign in"), CssClass = "btn--full", OnClick = "Buttons.LockButton(event)" });
3430
3431 foreach (Provider LoginProvider in providers)
3432 {
3433 var ProviderName = LoginProvider.Name.ToLower();
3434 form.Add(new Link {
3435 Href = "/Admin/Public/Social/ExternalLogin.aspx?action=login&providerID=" + LoginProvider.ID,
3436 Icon = new Icon { Prefix = "fab", Name = "fa-" + ProviderName, CssClass = "fa-1_5x", LabelPosition = IconLabelPosition.After },
3437 ButtonLayout = ButtonLayout.LinkClean,
3438 CssClass = "btn--condensed u-margin-bottom u-margin-right u-inline-block u-color-" + ProviderName,
3439 AltText = ProviderName
3440 });
3441 }
3442
3443 if (!hideCreateAccountLink) {
3444 form.Add(new Link { Href = "/default.aspx?ID=" + createAccountPageId, Title = Translate("Create account?"), ButtonLayout = ButtonLayout.None, CssClass = "u-block u-padding-bottom" });
3445 }
3446
3447 if (!hideForgotPasswordLink) {
3448 form.Add(new Link { Href = forgotPasswordPageLink, Title = Translate("Forgot your password?"), ButtonLayout = ButtonLayout.None, CssClass = "u-block u-padding-bottom" });
3449 }
3450
3451 @Render(form)
3452
3453 if (showModalOnStart)
3454 {
3455 <script>
3456 document.getElementById("SignInModalTrigger").checked = true;
3457 </script>
3458 }
3459 }
3460
3461 @if (Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet")
3462 {
3463 <text>@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
3464
3465 @using System
3466 @using System.Web
3467 @using System.Collections.Generic
3468 @using Dynamicweb.Rapido.Blocks.Extensibility
3469 @using Dynamicweb.Rapido.Blocks
3470 @using Dynamicweb.Rapido.Services
3471
3472
3473 @functions {
3474 BlocksPage mobileHeaderBlocksPage = BlocksPage.GetBlockPage("Master");
3475 }
3476
3477 @{
3478 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";
3479 bool mobileHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch");
3480 bool mobileHideCart = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart") || !Dynamicweb.Rapido.Services.User.IsBuyingAllowed();
3481
3482 Block mobileHeader = new Block()
3483 {
3484 Id = "MobileTop",
3485 SortId = 10,
3486 Template = RenderMobileTop(),
3487 SkipRenderBlocksList = true
3488 };
3489 mobileHeaderBlocksPage.Add(MasterBlockId.MasterHeader, mobileHeader);
3490
3491 Block mobileHeaderNavigation = new Block()
3492 {
3493 Id = "MobileHeaderNavigation",
3494 SortId = 10,
3495 Template = RenderMobileHeaderNavigation(),
3496 SkipRenderBlocksList = true,
3497 BlocksList = new List<Block> {
3498 new Block {
3499 Id = "MobileHeaderNavigationTrigger",
3500 SortId = 10,
3501 Template = RenderMobileHeaderNavigationTrigger()
3502 }
3503 }
3504 };
3505 mobileHeaderBlocksPage.Add("MobileTop", mobileHeaderNavigation);
3506
3507 Block mobileHeaderLogo = new Block()
3508 {
3509 Id = "MobileHeaderLogo",
3510 SortId = 20,
3511 Template = RenderMobileHeaderLogo(),
3512 SkipRenderBlocksList = true
3513 };
3514 mobileHeaderBlocksPage.Add("MobileTop", mobileHeaderLogo);
3515
3516 Block mobileHeaderActions = new Block()
3517 {
3518 Id = "MobileHeaderActions",
3519 SortId = 30,
3520 Template = RenderMobileTopActions(),
3521 SkipRenderBlocksList = true
3522 };
3523 mobileHeaderBlocksPage.Add("MobileTop", mobileHeaderActions);
3524
3525 if (!mobileHideSearch)
3526 {
3527 Block mobileHeaderSearch = new Block
3528 {
3529 Id = "MobileHeaderSearch",
3530 SortId = 10,
3531 Template = RenderMobileTopSearch()
3532 };
3533 mobileHeaderBlocksPage.Add("MobileHeaderActions", mobileHeaderSearch);
3534 }
3535
3536 Block mobileHeaderMiniCart;
3537
3538 if (!mobileHideCart)
3539 {
3540 mobileHeaderMiniCart = new Block
3541 {
3542 Id = "MobileHeaderMiniCart",
3543 SortId = 20,
3544 Template = RenderMobileTopMiniCart()
3545 };
3546
3547 Block miniCartCounterScriptTemplate = new Block
3548 {
3549 Id = "MiniCartCounterScriptTemplate",
3550 Template = RenderMobileMiniCartCounterContent()
3551 };
3552 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", miniCartCounterScriptTemplate);
3553 }
3554 else
3555 {
3556 mobileHeaderMiniCart = new Block
3557 {
3558 Id = "MobileHeaderMiniCart",
3559 SortId = 20
3560 };
3561 }
3562
3563 if (!mobileHideSearch)
3564 {
3565 Block mobileHeaderSearchBar = new Block()
3566 {
3567 Id = "MobileHeaderSearchBar",
3568 SortId = 30,
3569 Template = RenderMobileTopSearchBar()
3570 };
3571 mobileHeaderBlocksPage.Add(MasterBlockId.MasterHeader, mobileHeaderSearchBar);
3572 }
3573
3574 switch (mobileTopLayout)
3575 {
3576 case "nav-left":
3577 mobileHeaderNavigation.SortId = 10;
3578 mobileHeaderLogo.SortId = 20;
3579 mobileHeaderActions.SortId = 30;
3580 mobileHeaderBlocksPage.Add("MobileHeaderActions", mobileHeaderMiniCart);
3581 break;
3582 case "nav-right":
3583 mobileHeaderLogo.SortId = 10;
3584 mobileHeaderActions.SortId = 20;
3585 mobileHeaderNavigation.SortId = 30;
3586 mobileHeaderBlocksPage.Add("MobileHeaderActions", mobileHeaderMiniCart);
3587 break;
3588 case "nav-search-left":
3589 mobileHeaderNavigation.SortId = 10;
3590 mobileHeaderLogo.SortId = 20;
3591 mobileHeaderActions.SortId = 30;
3592 mobileHeaderBlocksPage.Add("MobileHeaderNavigation", mobileHeaderMiniCart);
3593 break;
3594 case "search-left":
3595 mobileHeaderActions.SortId = 10;
3596 mobileHeaderLogo.SortId = 20;
3597 mobileHeaderNavigation.SortId = 30;
3598 mobileHeaderMiniCart.SortId = 0;
3599 mobileHeaderBlocksPage.Add("MobileHeaderNavigation", mobileHeaderMiniCart);
3600 break;
3601 }
3602 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed())
3603 {
3604 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", new Block {
3605 Id = "CartInitialization",
3606 Template = RenderMobileCartInitialization()
3607 });
3608 }
3609 }
3610
3611
3612 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
3613
3614 @using System
3615 @using System.Web
3616 @using Dynamicweb.Rapido.Blocks.Extensibility
3617 @using Dynamicweb.Rapido.Blocks
3618
3619 @{
3620 BlocksPage customMobileHeaderBlocksPage = BlocksPage.GetBlockPage("Master");
3621 }
3622
3623
3624
3625 @helper RenderMobileCartInitialization()
3626 {
3627 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
3628 <script>
3629 window.cartId = "@miniCartFeedPageId";
3630 </script>
3631 }
3632
3633 @helper RenderMobileTop() {
3634 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileTop").OrderBy(item => item.SortId).ToList();
3635
3636 <nav class="main-navigation-mobile dw-mod">
3637 <div class="center-container top-container__center-container dw-mod">
3638 <div class="grid grid--align-center">
3639 @RenderBlockList(subBlocks)
3640 </div>
3641 </div>
3642 </nav>
3643 }
3644
3645 @helper RenderMobileHeaderNavigation() {
3646 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileHeaderNavigation").OrderBy(item => item.SortId).ToList();
3647
3648 <div class="grid__col-auto-width">
3649 <ul class="menu dw-mod">
3650 @RenderBlockList(subBlocks)
3651 </ul>
3652 </div>
3653 }
3654
3655 @helper RenderMobileHeaderNavigationTrigger() {
3656 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod">
3657 <label for="MobileNavTrigger" class="mobile-nav-trigger-button menu__link menu__link--icon menu__link--mobile dw-mod"></label>
3658 </li>
3659 }
3660
3661 @helper RenderMobileHeaderLogo() {
3662 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileHeaderLogo").OrderBy(item => item.SortId).ToList();
3663
3664 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";
3665 string centeredLogo = mobileTopLayout != "nav-right" ? "u-ta-center" : "";
3666 string firstPageId = Model.Area.FirstActivePage.ID.ToString();
3667 string businessName = Model.Area.Item.GetItem("Settings").GetString("BusinessName");
3668
3669 string mobileLogo = "/Files/Images/logo-dynamicweb.png";
3670 if (Model.Area.Item.GetItem("Layout").GetItem("MobileTop") != null && Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetFile("Logo") != null)
3671 {
3672 mobileLogo = Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetFile("Logo").PathUrlEncoded;
3673 }
3674
3675 if (Path.GetExtension(mobileLogo).ToLower() != ".svg")
3676 {
3677 mobileLogo = "/Admin/Public/GetImage.ashx?height=40&width=100&crop=5&Compression=75&image=" + mobileLogo;
3678 }
3679 else
3680 {
3681 mobileLogo = HttpUtility.UrlDecode(mobileLogo);
3682 }
3683
3684 <div class="grid__col-auto grid__col--bleed">
3685 <div class="grid__cell @centeredLogo">
3686 <a href="/Default.aspx?ID=@firstPageId" class="logo logo--mobile u-inline-block dw-mod">
3687 <img class="grid__cell-img logo__img logo__img--mobile dw-mod" src="@mobileLogo" alt="@businessName" />
3688 </a>
3689 </div>
3690
3691 @RenderBlockList(subBlocks)
3692 </div>
3693 }
3694
3695 @helper RenderMobileTopActions() {
3696 List<Block> subBlocks = this.mobileHeaderBlocksPage.GetBlockListById("MobileHeaderActions").OrderBy(item => item.SortId).ToList();
3697
3698 <div class="grid__col-auto-width">
3699 <ul class="menu dw-mod">
3700 @RenderBlockList(subBlocks)
3701 </ul>
3702 </div>
3703 }
3704
3705 @helper RenderMobileTopSearch() {
3706 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod">
3707 <label for="MobileSearchTrigger" class="menu__link menu__link--icon menu__link--mobile dw-mod">
3708 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue fa-1_5x"></i>
3709 </label>
3710 </li>
3711 }
3712
3713 @helper RenderMobileTopMiniCart() {
3714 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
3715 int cartPageId = GetPageIdByNavigationTag("CartPage");
3716 double cartProductsCount = Model.Cart.TotalProductsCount;
3717
3718 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod" id="miniCartWrapper">
3719 <div class="mini-cart dw-mod">
3720 <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">
3721 <div class="u-inline u-position-relative">
3722 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue fa-1_5x"></i>
3723 <div class="mini-cart__counter dw-mod">
3724 <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">
3725 <div class="js-mini-cart-counter-content" data-count="@cartProductsCount">
3726 @cartProductsCount
3727 </div>
3728 </div>
3729 </div>
3730 </div>
3731 </a>
3732 </div>
3733 </li>
3734 }
3735
3736 @helper RenderMobileTopSearchBar()
3737 {
3738 string searchFeedId = "";
3739 string searchSecondFeedId = "";
3740 int groupsFeedId;
3741 int productsPageId = GetPageIdByNavigationTag("ProductsPage");
3742 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID;
3743 string resultPageLink;
3744 string searchPlaceholder;
3745 string searchType = "product-search";
3746 string searchTemplate;
3747 string searchContentTemplate = "";
3748 string searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? "";
3749 bool showGroups = true;
3750
3751 if (Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue == "contentSearch")
3752 {
3753 searchFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true";
3754 resultPageLink = contentSearchPageLink;
3755 searchPlaceholder = Translate("Search page");
3756 groupsFeedId = 0;
3757 searchType = "content-search";
3758 searchTemplate = "SearchPagesTemplate";
3759 showGroups = false;
3760 }
3761 else if (Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue == "combinedSearch")
3762 {
3763 searchFeedId = productsPageId + "&feed=true";
3764 searchSecondFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true";
3765 resultPageLink = Converter.ToString(productsPageId);
3766 searchPlaceholder = Translate("Search products or pages");
3767 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed");
3768 searchType = "combined-search";
3769 searchTemplate = "SearchProductsTemplateWrap";
3770 searchContentTemplate = "SearchPagesTemplateWrap";
3771 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector");
3772 }
3773 else
3774 {
3775 resultPageLink = Converter.ToString(productsPageId);
3776 searchFeedId = productsPageId + "&feed=true";
3777 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed");
3778 searchPlaceholder = Translate("Search products");
3779 searchTemplate = "SearchProductsTemplate";
3780 searchType = "product-search";
3781 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector");
3782 }
3783
3784 <input type="checkbox" id="MobileSearchTrigger" class="mobile-search-trigger" />
3785
3786 <div class="main-navigation-mobile typeahead-mobile dw-mod">
3787 <div class="center-container top-container__center-container dw-mod">
3788 <div class="grid">
3789 <div class="grid__col-auto">
3790 <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">
3791 <input type="text" class="js-typeahead-search-field u-w160px u-no-margin" placeholder="@searchPlaceholder" value="@searchValue">
3792 @if (string.IsNullOrEmpty(searchSecondFeedId))
3793 {
3794 <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>
3795 }
3796 else
3797 {
3798 <div class="dropdown dropdown--absolute-position dropdown--combined grid dropdown--combined-mobile grid">
3799 <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>
3800 <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>
3801 </div>
3802 }
3803 <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>
3804 </div>
3805 </div>
3806 <div class="grid__col-auto-width">
3807 <ul class="menu dw-mod">
3808 <li class="menu__item menu__item--horizontal menu__item--top-level dw-mod">
3809 <label for="MobileSearchTrigger" class="menu__link menu__link--icon menu__link--mobile dw-mod">
3810 <i class="fas fa-times fa-1_5x"></i>
3811 </label>
3812 </li>
3813 </ul>
3814 </div>
3815 </div>
3816 </div>
3817 </div>
3818 }
3819
3820 @helper RenderMobileMiniCartCounterContent()
3821 {
3822 <script id="MiniCartCounterContent" type="text/x-template">
3823 {{#.}}
3824 <div class="js-mini-cart-counter-content dw-mod" data-count="{{numberofproducts}}">
3825 {{numberofproducts}}
3826 </div>
3827 {{/.}}
3828 </script>
3829 }
3830 </text>
3831 <text>@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
3832
3833 @using System
3834 @using System.Web
3835 @using System.Collections.Generic
3836 @using Dynamicweb.Rapido.Blocks.Extensibility
3837 @using Dynamicweb.Rapido.Blocks
3838
3839 @functions {
3840 BlocksPage mobileNavigationBlocksPage = BlocksPage.GetBlockPage("Master");
3841 }
3842
3843 @{
3844 bool mobileNavigationItemsHideSignIn = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSignIn");
3845 bool mobileHideCreateAccountLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideCreateAccount");
3846 bool mobileHideMyProfileLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideProfile");
3847 bool mobileHideMyOrdersLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideOrders");
3848 bool mobileHideMySavedCardsLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideSavedCards");
3849 bool mobileHideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideFavorites");
3850
3851 Block mobileNavigation = new Block()
3852 {
3853 Id = "MobileNavigation",
3854 SortId = 10,
3855 Template = MobileNavigation(),
3856 SkipRenderBlocksList = true
3857 };
3858 mobileNavigationBlocksPage.Add(MasterBlockId.MasterTopSnippets, mobileNavigation);
3859
3860 if (Model.CurrentUser.ID > 0 && !mobileHideMyProfileLink)
3861 {
3862 Block mobileNavigationSignIn = new Block
3863 {
3864 Id = "MobileNavigationSignIn",
3865 SortId = 10,
3866 Template = RenderMobileNavigationSignIn()
3867 };
3868 mobileNavigationBlocksPage.Add("MobileNavigation", mobileNavigationSignIn);
3869 }
3870
3871 Block mobileNavigationMenu = new Block
3872 {
3873 Id = "MobileNavigationMenu",
3874 SortId = 20,
3875 Template = RenderMobileNavigationMenu()
3876 };
3877 mobileNavigationBlocksPage.Add("MobileNavigation", mobileNavigationMenu);
3878
3879 Block mobileNavigationActions = new Block
3880 {
3881 Id = "MobileNavigationActions",
3882 SortId = 30,
3883 Template = RenderMobileNavigationActions(),
3884 SkipRenderBlocksList = true
3885 };
3886 mobileNavigationBlocksPage.Add("MobileNavigation", mobileNavigationActions);
3887
3888 if (!mobileNavigationItemsHideSignIn)
3889 {
3890 if (Model.CurrentUser.ID <= 0)
3891 {
3892 Block mobileNavigationSignInAction = new Block
3893 {
3894 Id = "MobileNavigationSignInAction",
3895 SortId = 10,
3896 Template = RenderMobileNavigationSignInAction()
3897 };
3898 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationSignInAction);
3899
3900 if (!mobileHideCreateAccountLink)
3901 {
3902 Block mobileNavigationCreateAccountAction = new Block
3903 {
3904 Id = "MobileNavigationCreateAccountAction",
3905 SortId = 20,
3906 Template = RenderMobileNavigationCreateAccountAction()
3907 };
3908 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationCreateAccountAction);
3909 }
3910 }
3911 else
3912 {
3913 if (!mobileHideMyOrdersLink)
3914 {
3915 Block mobileNavigationOrdersAction = new Block
3916 {
3917 Id = "MobileNavigationOrdersAction",
3918 SortId = 20,
3919 Template = RenderMobileNavigationOrdersAction()
3920 };
3921 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationOrdersAction);
3922 }
3923 if (!mobileHideMyFavoritesLink)
3924 {
3925 Block mobileNavigationFavoritesAction = new Block
3926 {
3927 Id = "MobileNavigationFavoritesAction",
3928 SortId = 30,
3929 Template = RenderMobileNavigationFavoritesAction()
3930 };
3931 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationFavoritesAction);
3932 }
3933 if (!mobileHideMySavedCardsLink)
3934 {
3935 Block mobileNavigationSavedCardsAction = new Block
3936 {
3937 Id = "MobileNavigationFavoritesAction",
3938 SortId = 30,
3939 Template = RenderMobileNavigationSavedCardsAction()
3940 };
3941 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationSavedCardsAction);
3942 }
3943
3944 Block mobileNavigationSignOutAction = new Block
3945 {
3946 Id = "MobileNavigationSignOutAction",
3947 SortId = 40,
3948 Template = RenderMobileNavigationSignOutAction()
3949 };
3950 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationSignOutAction);
3951 }
3952 }
3953
3954 if (Model.Languages.Count > 1)
3955 {
3956 Block mobileNavigationLanguagesAction = new Block
3957 {
3958 Id = "MobileNavigationLanguagesAction",
3959 SortId = 50,
3960 Template = RenderMobileNavigationLanguagesAction()
3961 };
3962 mobileNavigationBlocksPage.Add("MobileNavigationActions", mobileNavigationLanguagesAction);
3963 }
3964 }
3965
3966
3967 @helper MobileNavigation()
3968 {
3969 List<Block> subBlocks = this.mobileNavigationBlocksPage.GetBlockListById("MobileNavigation").OrderBy(item => item.SortId).ToList();
3970 string mobileTopDesign = Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetList("Design") != null ? Model.Area.Item.GetItem("Layout").GetItem("MobileTop").GetList("Design").SelectedValue : "nav-left";
3971 string position = mobileTopDesign == "nav-left" || mobileTopDesign == "nav-search-left" ? "left" : "right";
3972
3973 <!-- Trigger for mobile navigation -->
3974 <input type="checkbox" id="MobileNavTrigger" class="mobile-nav-trigger mobile-nav-trigger--@position" autocomplete="off" />
3975
3976 <!-- Mobile navigation -->
3977 <nav class="mobile-navigation mobile-navigation--@position dw-mod">
3978 <div class="mobile-navigation__wrapper" id="mobileNavigationWrapper">
3979 @RenderBlockList(subBlocks)
3980 </div>
3981 </nav>
3982
3983 <label class="mobile-nav-trigger-off" for="MobileNavTrigger"></label>
3984 }
3985
3986 @helper RenderMobileNavigationSignIn()
3987 {
3988 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
3989 int myProfilePageId = GetPageIdByNavigationTag("CustomerProfile");
3990 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID=";
3991 string myProfilePageLink = linkStart + myProfilePageId;
3992 string userName = Model.CurrentUser.FirstName ?? "";
3993 userName += " " + (Model.CurrentUser.LastName ?? "");
3994 userName += userName == "" && Model.CurrentUser.UserName != null ? Model.CurrentUser.UserName : "";
3995
3996 <ul class="menu menu-mobile">
3997 <li class="menu-mobile__item">
3998 <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>
3999 </li>
4000 </ul>
4001 }
4002
4003 @helper RenderMobileNavigationMenu()
4004 {
4005 bool isSlidesDesign = Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetList("Design").SelectedValue == "Slides";
4006 string menuTemplate = isSlidesDesign ? "BaseMenuForMobileSlides.xslt" : "BaseMenuForMobileExpandable.xslt";
4007 string levels = !String.IsNullOrEmpty(Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetString("Levels")) ? Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetString("Levels") : "3";
4008 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar");
4009 int startLevel = renderPagesInToolBar ? 1 : 0;
4010
4011 @RenderNavigation(new
4012 {
4013 id = "mobilenavigation",
4014 cssclass = "menu menu-mobile dwnavigation",
4015 startLevel = @startLevel,
4016 ecomStartLevel = @startLevel + 1,
4017 endlevel = @levels,
4018 expandmode = "all",
4019 template = @menuTemplate
4020 })
4021
4022 if (isSlidesDesign)
4023 {
4024 <script>
4025 function goToLevel(level) {
4026 document.getElementById('mobileNavigationWrapper').style.left = -(level * 100) + "%";
4027 }
4028
4029 document.addEventListener('DOMContentLoaded', function () {
4030 goToLevel(document.getElementById('mobileNavigationWrapper').querySelectorAll('input[type=radio]:checked').length);
4031 });
4032 </script>
4033 }
4034
4035 if (renderPagesInToolBar)
4036 {
4037 @RenderNavigation(new
4038 {
4039 id = "topToolsMobileNavigation",
4040 cssclass = "menu menu-mobile dwnavigation",
4041 template = "ToolsMenuForMobile.xslt"
4042 })
4043 }
4044 }
4045
4046 @helper RenderMobileNavigationActions()
4047 {
4048 List<Block> subBlocks = this.mobileNavigationBlocksPage.GetBlockListById("MobileNavigationActions").OrderBy(item => item.SortId).ToList(); ;
4049
4050 <ul class="menu menu-mobile">
4051 @RenderBlockList(subBlocks)
4052 </ul>
4053 }
4054
4055 @helper RenderMobileNavigationSignInAction()
4056 {
4057 <li class="menu-mobile__item">
4058 <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>
4059 </li>
4060 }
4061
4062 @helper RenderMobileNavigationCreateAccountAction()
4063 {
4064 int createAccountPageId = GetPageIdByNavigationTag("CreateAccount");
4065
4066 <li class="menu-mobile__item">
4067 <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>
4068 </li>
4069 }
4070
4071 @helper RenderMobileNavigationProfileAction()
4072 {
4073 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
4074 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID=";
4075 int myProfilePageId = GetPageIdByNavigationTag("CustomerProfile");
4076 string myProfilePageLink = linkStart + myProfilePageId;
4077
4078 <li class="menu-mobile__item">
4079 <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>
4080 </li>
4081 }
4082
4083 @helper RenderMobileNavigationOrdersAction()
4084 {
4085 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
4086 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID=";
4087 int myOrdersPageId = GetPageIdByNavigationTag("CustomerOrders");
4088 string myOrdersPageLink = linkStart + myOrdersPageId;
4089 string ordersIcon = "fas fa-list";
4090
4091 <li class="menu-mobile__item">
4092 <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>
4093 </li>
4094 }
4095
4096 @helper RenderMobileNavigationFavoritesAction()
4097 {
4098 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
4099 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID=";
4100 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites");
4101 string myFavoritesPageLink = linkStart + myFavoritesPageId;
4102 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";
4103
4104
4105 <li class="menu-mobile__item">
4106 <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>
4107 </li>
4108 }
4109
4110 @helper RenderMobileNavigationSavedCardsAction()
4111 {
4112 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
4113 string linkStart = Model.CurrentUser.ID <= 0 ? "/Default.aspx?ID=" + signInProfilePageId + "&RedirectPageId=" : "/Default.aspx?ID=";
4114 int mySavedCardsPageId = GetPageIdByNavigationTag("SavedCards");
4115 string mySavedCardsPageLink = linkStart + mySavedCardsPageId;
4116 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";
4117
4118 <li class="menu-mobile__item">
4119 <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>
4120 </li>
4121 }
4122
4123 @helper RenderMobileNavigationSignOutAction()
4124 {
4125 int pageId = Model.TopPage.ID;
4126 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";
4127
4128 <li class="menu-mobile__item">
4129 <a class="menu-mobile__link menu-mobile__link--highlighted dw-mod" href="/Admin/Public/ExtranetLogoff.aspx?ID=@pageId"><i class="@signOutIcon menu-mobile__link-icon"></i> @Translate("Sign out")</a>
4130 </li>
4131 }
4132
4133 @helper RenderMobileNavigationLanguagesAction()
4134 {
4135 bool isSlidesDesign = Model.Area.Item.GetItem("Layout").GetItem("MobileNavigation").GetList("Design").SelectedValue == "Slides";
4136
4137 string selectedLanguage = "";
4138 foreach (var lang in Model.Languages)
4139 {
4140 if (lang.IsCurrent)
4141 {
4142 selectedLanguage = lang.Name;
4143 }
4144 }
4145
4146 <li class="menu-mobile__item dw-mod">
4147 @if (isSlidesDesign)
4148 {
4149 <input id="MobileMenuCheck_Language" type="radio" class="expand-trigger" name="mobile-menu-level-1" onclick="goToLevel(1);">
4150 }
4151 else
4152 {
4153 <input id="MobileMenuCheck_Language" type="checkbox" class="expand-trigger">
4154 }
4155 <div class="menu-mobile__link__wrap">
4156 <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>
4157 <label for="MobileMenuCheck_Language" class="menu-mobile__trigger"></label>
4158 </div>
4159 <ul class="menu-mobile menu-mobile__submenu expand-menu">
4160 @if (isSlidesDesign)
4161 {
4162 <li class="menu-mobile__item dw-mod">
4163 <div class="menu-mobile__link__wrap">
4164 <input id="MobileMenuCheck_Language_back" type="radio" class="expand-trigger" name="mobile-menu-level-1" onclick="goToLevel(0);" />
4165 <label for="MobileMenuCheck_Language_back" class="menu-mobile__trigger menu-mobile__trigger--back"></label>
4166 <label for="MobileMenuCheck_Language_back" class="menu-mobile__link dw-mod ">@Translate("Back")</label>
4167 </div>
4168 </li>
4169 }
4170 @foreach (var lang in Model.Languages)
4171 {
4172 <li class="menu-mobile__item dw-mod">
4173 <a class="menu-mobile__link menu-mobile__link--highlighted dw-mod menu-mobile__link--level-1" href="https://dignet.hr/Default.aspx?ID=@lang.Page.ID">@lang.Name</a>
4174 </li>
4175 }
4176 </ul>
4177 </li>
4178 }</text>
4179 }
4180 else
4181 {
4182 <text>@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4183
4184 @using System
4185 @using System.Web
4186 @using System.Collections.Generic
4187 @using Dynamicweb.Rapido.Blocks.Extensibility
4188 @using Dynamicweb.Rapido.Blocks
4189
4190 @functions {
4191 BlocksPage headerBlocksPage = BlocksPage.GetBlockPage("Master");
4192 }
4193
4194 @{
4195 Block masterTools = new Block()
4196 {
4197 Id = "MasterDesktopTools",
4198 SortId = 10,
4199 Template = RenderDesktopTools(),
4200 SkipRenderBlocksList = true,
4201 BlocksList = new List<Block>
4202 {
4203 new Block {
4204 Id = "MasterDesktopToolsText",
4205 SortId = 10,
4206 Template = RenderDesktopToolsText(),
4207 Design = new Design
4208 {
4209 Size = "auto",
4210 HidePadding = true,
4211 RenderType = RenderType.Column
4212 }
4213 },
4214 new Block {
4215 Id = "MasterDesktopToolsNavigation",
4216 SortId = 20,
4217 Template = RenderDesktopToolsNavigation(),
4218 Design = new Design
4219 {
4220 Size = "auto-width",
4221 HidePadding = true,
4222 RenderType = RenderType.Column
4223 }
4224 }
4225 }
4226 };
4227 headerBlocksPage.Add("MasterHeader", masterTools);
4228
4229 Block masterDesktopExtra = new Block()
4230 {
4231 Id = "MasterDesktopExtra",
4232 SortId = 10,
4233 Template = RenderDesktopExtra(),
4234 SkipRenderBlocksList = true
4235 };
4236 headerBlocksPage.Add("MasterHeader", masterDesktopExtra);
4237
4238 Block masterDesktopNavigation = new Block()
4239 {
4240 Id = "MasterDesktopNavigation",
4241 SortId = 20,
4242 Template = RenderDesktopNavigation(),
4243 SkipRenderBlocksList = true
4244 };
4245 headerBlocksPage.Add("MasterHeader", masterDesktopNavigation);
4246 }
4247
4248 @* Include the Blocks for the page *@
4249 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4250
4251 @using System
4252 @using System.Web
4253 @using Dynamicweb.Rapido.Blocks.Extensibility
4254 @using Dynamicweb.Rapido.Blocks
4255
4256 @{
4257 Block masterDesktopLogo = new Block
4258 {
4259 Id = "MasterDesktopLogo",
4260 SortId = 10,
4261 Template = RenderDesktopLogo(),
4262 Design = new Design
4263 {
4264 Size = "auto-width",
4265 HidePadding = true,
4266 RenderType = RenderType.Column,
4267 CssClass = "grid--align-self-center"
4268 }
4269 };
4270
4271 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopLogo);
4272 }
4273
4274
4275 @helper RenderDesktopLogo()
4276 {
4277 string firstPageId = Model.Area.FirstActivePage.ID.ToString();
4278 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
4279 string alignClass = topLayout == "two-lines-centered" || topLayout == "two-lines" ? "grid--align-self-center" : "";
4280 string logo = Model.Area.Item.GetItem("Layout").GetFile("LogoImage") != null ? Model.Area.Item.GetItem("Layout").GetFile("LogoImage").PathUrlEncoded : "/Files/Images/logo-dynamicweb.png";
4281 if (Path.GetExtension(logo).ToLower() != ".svg")
4282 {
4283 int logoHeight = Model.Area.Item.GetItem("Layout").GetInt32("LogoHeight");
4284 logoHeight = logoHeight > 0 && Pageview.Device.ToString() != "Mobile" ? logoHeight : 40;
4285 logo = "/Admin/Public/GetImage.ashx?height=" + Converter.ToString(logoHeight) + "&crop=5&Compression=75&image=" + logo;
4286 }
4287 else
4288 {
4289 logo = HttpUtility.UrlDecode(logo);
4290 }
4291
4292 <div class="logo @alignClass dw-mod">
4293 <a href="/Default.aspx?ID=@firstPageId" class="logo__img dw-mod u-block">
4294 <img class="grid__cell-img logo__img dw-mod" src="@logo" alt="@Translate("Logo")" />
4295 </a>
4296 </div>
4297 }
4298 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4299
4300 @using System
4301 @using System.Web
4302 @using Dynamicweb.Rapido.Blocks.Extensibility
4303 @using Dynamicweb.Rapido.Blocks
4304
4305 @functions {
4306 bool isMegaMenu;
4307 }
4308
4309
4310 @{
4311
4312 isMegaMenu = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("NavigationMegaMenu") != null ? Converter.ToBoolean(Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("NavigationMegaMenu").SelectedValue) : false;
4313
4314 Block masterDesktopMenu = new Block
4315 {
4316 Id = "MasterDesktopMenu",
4317 SortId = 10,
4318 Template = RenderDesktopMenu(),
4319 Design = new Design
4320 {
4321 Size = "auto",
4322 HidePadding = true,
4323 RenderType = RenderType.Column
4324 }
4325 };
4326
4327 if (isMegaMenu)
4328 {
4329 masterDesktopMenu.Design.CssClass = "u-reset-position";
4330 }
4331
4332 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopMenu);
4333 }
4334
4335
4336
4337 @helper RenderDesktopMenu()
4338
4339 {
4340 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
4341 string menuAlignment = topLayout == "minimal-right" ? "grid--align-self-end" : "";
4342 string megamenuPromotionImage = Model.Area.Item.GetItem("Layout").GetItem("Header").GetFile("MegamenuPromotionImage") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetFile("MegamenuPromotionImage").PathUrlEncoded : "";
4343 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar");
4344 bool showOnlyHeaders = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowOnlyHeaders");
4345 int startLevel = renderPagesInToolBar ? 1 : 0;
4346
4347 string promotionLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("MegamenuPromotionLink");
4348
4349 <div class="grid__cell u-flex @(isMegaMenu ? "u-reset-position" : "") @menuAlignment">
4350 @if (!isMegaMenu)
4351 {
4352 @RenderNavigation(new
4353 {
4354 id = "topnavigation",
4355 cssclass = "menu dw-mod dwnavigation u-full-max-width u-flex grid--wrap",
4356 startLevel = startLevel,
4357 ecomStartLevel = startLevel + 1,
4358 endlevel = 5,
4359 expandmode = "all",
4360 template = "BaseMenuWithDropdown.xslt"
4361 });
4362 }
4363 else
4364 {
4365 @RenderNavigation(new
4366 {
4367 id = "topnavigation",
4368 cssclass = "menu dw-mod dwnavigation u-full-max-width u-flex grid--wrap",
4369 startLevel = startLevel,
4370 ecomStartLevel = startLevel + 1,
4371 endlevel = 5,
4372 promotionImage = megamenuPromotionImage,
4373 promotionLink = promotionLink,
4374 expandmode = "all",
4375 showOnlyHeaders = showOnlyHeaders.ToString().ToLower(),
4376 template = "BaseMegaMenu.xslt"
4377 });
4378 }
4379 </div>
4380 }
4381 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4382
4383 @using System
4384 @using System.Web
4385 @using Dynamicweb.Rapido.Blocks.Extensibility
4386 @using Dynamicweb.Rapido.Blocks
4387
4388 @{
4389 Block masterDesktopActionsMenu = new Block
4390 {
4391 Id = "MasterDesktopActionsMenu",
4392 SortId = 10,
4393 Template = RenderDesktopActionsMenu(),
4394 Design = new Design
4395 {
4396 CssClass = "u-flex"
4397 },
4398 SkipRenderBlocksList = true
4399
4400 };
4401 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterDesktopActionsMenu);
4402
4403 if (!string.IsNullOrWhiteSpace(Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonLink")))
4404 {
4405 Block masterDesktopActionsHeaderButton = new Block
4406 {
4407 Id = "MasterDesktopActionsHeaderButton",
4408 SortId = 60,
4409 Template = RenderHeaderButton()
4410 };
4411 masterDesktopActionsMenu.Add(masterDesktopActionsHeaderButton);
4412 }
4413 }
4414
4415 @helper RenderDesktopActionsMenu()
4416 {
4417 List<Block> subBlocks = this.headerBlocksPage.GetBlockListById("MasterDesktopActionsMenu").OrderBy(item => item.SortId).ToList();
4418
4419 <ul class="menu u-flex dw-mod">
4420 @RenderBlockList(subBlocks)
4421 </ul>
4422 }
4423
4424 @helper RenderHeaderButton()
4425 {
4426 string headerButtonText = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonText");
4427 string headerButtonLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("HeaderButtonLink");
4428 string headerButtonType = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("HeaderButtonType") != null ? "btn--" + Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("HeaderButtonType").SelectedName.ToLower() : "";
4429
4430 <li class="menu__item menu__item--horizontal menu--clean dw-mod">
4431 <a class="btn @headerButtonType dw-mod u-no-margin u-margin-top u-margin-left" href="@headerButtonLink">@headerButtonText</a>
4432 </li>
4433 }
4434 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4435
4436 @using System
4437 @using System.Web
4438 @using Dynamicweb.Core;
4439 @using System.Text.RegularExpressions
4440 @using Dynamicweb.Rapido.Blocks.Extensibility
4441 @using Dynamicweb.Rapido.Blocks
4442
4443 @{
4444 Block masterDesktopActionsMenuLanguageSelector = new Block
4445 {
4446 Id = "MasterDesktopActionsMenuLanguageSelector",
4447 SortId = 40,
4448 Template = RenderLanguageSelector()
4449 };
4450
4451 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuLanguageSelector);
4452 }
4453
4454 @helper RenderLanguageSelector()
4455 {
4456 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
4457 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean";
4458 string menuLinkClass = topLayout != "normal" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
4459 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() : "";
4460
4461 if (Model.Languages.Count > 1)
4462 {
4463 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon is-dropdown is-dropdown--no-icon dw-mod">
4464 <div class="@menuLinkClass dw-mod" title="@Translate("Language")">
4465 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("LanguageIcon").SelectedValue fa-1_5x"></i>
4466 </div>
4467 <div class="menu menu--dropdown menu--dropdown-right languages-dropdown dw-mod grid__cell">
4468 @foreach (var lang in Model.Languages)
4469 {
4470 string widthClass = "menu__item--fixed-width";
4471 string langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " u-margin-right\"></span>" + lang.Name;
4472 string cultureName = Regex.Replace(Dynamicweb.Services.Areas.GetArea(lang.ID).CultureInfo.NativeName, @" ?\(.*?\)", string.Empty);
4473 cultureName = char.ToUpper(cultureName[0]) + cultureName.Substring(1);
4474
4475 if (languageViewType == "flag-culture")
4476 {
4477 langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " \"></span> " + cultureName;
4478 }
4479
4480 if (languageViewType == "flag")
4481 {
4482 langInfo = "<span class=\"flag-icon flag-icon-" + Dynamicweb.Services.Areas.GetArea(lang.ID).EcomCountryCode.ToLower() + " \"></span>";
4483 widthClass = "";
4484 }
4485
4486 if (languageViewType == "name")
4487 {
4488 langInfo = lang.Name;
4489 }
4490
4491 if (languageViewType == "culture")
4492 {
4493 langInfo = cultureName;
4494 widthClass = "";
4495 }
4496
4497 <div class="menu__item dw-mod @widthClass">
4498 <a href="https://dignet.hr/Default.aspx?AreaID=@Dynamicweb.Services.Pages.GetPage(lang.Page.ID).Area.ID" class="menu-dropdown__link dw-mod">@langInfo</a>
4499 </div>
4500 }
4501 </div>
4502 </li>
4503 <div class="menu_gumb" id="menu_hide"><label class="show-menu" for="show-menu"><i class="fa fa-bars"></i></label></div>
4504 }
4505 }
4506 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4507
4508 @using System
4509 @using System.Web
4510 @using Dynamicweb.Rapido.Blocks.Extensibility
4511 @using Dynamicweb.Rapido.Blocks
4512
4513 @{
4514 Block masterDesktopActionsMenuSignIn = new Block
4515 {
4516 Id = "MasterDesktopActionsMenuSignIn",
4517 SortId = 20,
4518 Template = RenderSignIn()
4519 };
4520
4521 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuSignIn);
4522 }
4523
4524 @helper RenderSignIn()
4525 {
4526 bool navigationItemsHideSignIn = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSignIn");
4527 string userInitials = "";
4528 int pageId = Model.TopPage.ID;
4529 int createAccountPageId = GetPageIdByNavigationTag("CreateAccount");
4530 int myDashboardPageId = GetPageIdByNavigationTag("CustomerDashboard");
4531 int myProfilePageId = GetPageIdByNavigationTag("CustomerProfile");
4532 int myOrdersPageId = GetPageIdByNavigationTag("CustomerOrders");
4533 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites");
4534 int mySavedCardsPageId = GetPageIdByNavigationTag("SavedCards");
4535 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage");
4536 bool hideCreateAccountLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideCreateAccount");
4537 bool hideMyProfileLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideProfile");
4538 bool hideMyOrdersLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideOrders");
4539 bool hideMySavedCardsLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideSavedCards");
4540 bool hideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideFavorites");
4541 bool hideForgotPasswordLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("SignInHideForgotPasswordLink");
4542
4543 string linkStart = "/Default.aspx?ID=";
4544 if (Model.CurrentUser.ID <= 0)
4545 {
4546 linkStart += signInProfilePageId + "&RedirectPageId=";
4547 }
4548
4549 string forgotPasswordPageLink = "/Default.aspx?ID=" + signInProfilePageId + "&LoginAction=Recovery";
4550 string myProfilePageLink = linkStart + myProfilePageId;
4551 string myOrdersPageLink = linkStart + myOrdersPageId;
4552 string myFavoritesPageLink = linkStart + myFavoritesPageId;
4553 string mySavedCardsPageLink = linkStart + mySavedCardsPageId;
4554
4555 string profileIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue : "fa fa-user";
4556 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";
4557
4558 if (Model.CurrentUser.ID != 0)
4559 {
4560 userInitials = Dynamicweb.Rapido.Services.User.GetInitials(Model.CurrentUser.Name, Model.CurrentUser.FirstName, Model.CurrentUser.LastName, Model.CurrentUser.Email, Model.CurrentUser.UserName);
4561 }
4562
4563 if (!navigationItemsHideSignIn)
4564 {
4565 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
4566 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu__item--clean";
4567 string menuLinkClass = topLayout != "normal" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
4568
4569 <li class="menu__item menu__item--horizontal menu__item menu__item--icon @liClasses is-dropdown is-dropdown--no-icon dw-mod">
4570 <div class="@menuLinkClass dw-mod">
4571 @if (Model.CurrentUser.ID <= 0)
4572 {
4573 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SignInProfileIcon").SelectedValue fa-1_5x" title="@Translate("Sign in")"></i>
4574 }
4575 else
4576 {
4577 <a href="/default.aspx?ID=@myDashboardPageId" class="u-color-inherit" title="@Translate("Customer center")"><div class="circle-icon-btn">@userInitials.ToUpper()</div></a>
4578 }
4579 </div>
4580 <div class="menu menu--dropdown menu--dropdown-right menu--sign-in grid__cell dw-mod">
4581 <ul class="list list--clean dw-mod">
4582 @if (Model.CurrentUser.ID <= 0)
4583 {
4584 <li>
4585 <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>
4586 </li>
4587
4588 if (!hideCreateAccountLink)
4589 {
4590 @RenderListItem("/default.aspx?ID=" + createAccountPageId, Translate("Create account"));
4591 }
4592 if (!hideForgotPasswordLink)
4593 {
4594 @RenderListItem(forgotPasswordPageLink, Translate("Forgot your password?"))
4595 }
4596 if (!hideMyProfileLink || !hideMyOrdersLink || !hideMyFavoritesLink || !hideMySavedCardsLink)
4597 {
4598 @RenderSeparator()
4599 }
4600 }
4601 @if (!hideMyProfileLink)
4602 {
4603 @RenderListItem(myProfilePageLink, Translate("My Profile"), profileIcon)
4604 }
4605 @if (!hideMyOrdersLink)
4606 {
4607 @RenderListItem(myOrdersPageLink, Translate("My Orders"), "fas fa-list")
4608 }
4609 @if (!hideMyFavoritesLink)
4610 {
4611 @RenderListItem(myFavoritesPageLink, Translate("My Favorites"), favoritesIcon)
4612 }
4613 @if (!hideMySavedCardsLink)
4614 {
4615 @RenderListItem(mySavedCardsPageLink, Translate("My Saved cards"), "fas fa-credit-card")
4616 }
4617 @if (Model.CurrentUser.ID > 0)
4618 {
4619 if (!hideMyProfileLink || !hideMyOrdersLink || !hideMyFavoritesLink || !hideMySavedCardsLink)
4620 {
4621 @RenderSeparator()
4622 }
4623
4624 @RenderListItem("/Admin/Public/ExtranetLogoff.aspx?ID=" + pageId, Translate("Sign out"))
4625 }
4626 </ul>
4627 </div>
4628 </li>
4629 }
4630 }
4631
4632 @helper RenderListItem(string link, string text, string icon = null) {
4633 <li>
4634 <a href="@link" class="list__link dw-mod">
4635 @if (!string.IsNullOrEmpty(icon)){<i class="@icon u-margin-right"></i>}@text
4636 </a>
4637 </li>
4638 }
4639
4640 @helper RenderSeparator()
4641 {
4642 <li class="list__seperator dw-mod"></li>
4643 }
4644 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4645
4646 @using System
4647 @using System.Web
4648 @using Dynamicweb.Rapido.Blocks.Extensibility
4649 @using Dynamicweb.Rapido.Blocks
4650
4651 @{
4652 bool hideMyFavoritesLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideFavorites");
4653
4654 Block masterDesktopActionsMenuFavorites = new Block
4655 {
4656 Id = "MasterDesktopActionsMenuFavorites",
4657 SortId = 30,
4658 Template = RenderFavorites()
4659 };
4660
4661 if (!hideMyFavoritesLink && Model.CurrentUser.ID > 0)
4662 {
4663 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuFavorites);
4664 }
4665 }
4666
4667 @helper RenderFavorites()
4668 {
4669 int myFavoritesPageId = GetPageIdByNavigationTag("CustomerFavorites");
4670 string myFavoritesPageLink = "/Default.aspx?ID=" + myFavoritesPageId;
4671
4672 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
4673 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean";
4674 string menuLinkClass = topLayout != "normal" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
4675
4676 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod">
4677 <a href="@myFavoritesPageLink" class="@menuLinkClass dw-mod" title="@Translate("Favorites")">
4678 <i class="fas fa-@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon").SelectedValue fa-1_5x"></i>
4679 </a>
4680 </li>
4681 }
4682 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4683
4684 @using System
4685 @using System.Web
4686 @using Dynamicweb.Rapido.Blocks.Extensibility
4687 @using Dynamicweb.Rapido.Blocks
4688 @using Dynamicweb.Rapido.Services
4689
4690 @{
4691 bool hideCart = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart");
4692 string miniCartLayout = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout").SelectedValue : "dropdown";
4693
4694 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed() && !hideCart)
4695 {
4696 Block masterDesktopActionsMenuMiniCart = new Block
4697 {
4698 Id = "MasterDesktopActionsMenuMiniCart",
4699 SortId = 50,
4700 Template = RenderMiniCart(miniCartLayout == "dropdown"),
4701 SkipRenderBlocksList = true,
4702 BlocksList = new List<Block>()
4703 };
4704
4705 Block miniCartCounterScriptTemplate = new Block
4706 {
4707 Id = "MiniCartCounterScriptTemplate",
4708 Template = RenderMiniCartCounterContent()
4709 };
4710
4711 //dropdown layout is default
4712 RazorEngine.Templating.TemplateWriter layoutTemplate;
4713 RazorEngine.Templating.TemplateWriter miniCartTriggerTemplate;
4714
4715 switch (miniCartLayout)
4716 {
4717 case "dropdown":
4718 layoutTemplate = RenderMiniCartDropdownLayout();
4719 miniCartTriggerTemplate = RenderMiniCartTriggerLink();
4720 break;
4721 case "panel":
4722 layoutTemplate = RenderMiniCartPanelLayout();
4723 miniCartTriggerTemplate = RenderMiniCartTriggerLabel();
4724 break;
4725 case "modal":
4726 layoutTemplate = RenderMiniCartModalLayout();
4727 miniCartTriggerTemplate = RenderMiniCartTriggerLabel();
4728 break;
4729 case "none":
4730 default:
4731 layoutTemplate = RenderNoLayoutMiniCart();
4732 miniCartTriggerTemplate = RenderMiniCartTriggerLink();
4733 break;
4734 }
4735
4736 masterDesktopActionsMenuMiniCart.BlocksList.Add(new Block
4737 {
4738 Id = "MiniCartTrigger",
4739 Template = miniCartTriggerTemplate
4740 });
4741
4742 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet")
4743 {
4744 masterDesktopActionsMenuMiniCart.BlocksList.Add(new Block
4745 {
4746 Id = "MiniCartLayout",
4747 Template = layoutTemplate
4748 });
4749 }
4750
4751 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuMiniCart);
4752 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", miniCartCounterScriptTemplate);
4753 }
4754
4755 if (hideCart && Dynamicweb.Rapido.Services.User.IsBuyingAllowed())
4756 {
4757 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", new Block {
4758 Id = "CartInitialization",
4759 Template = RenderNoLayoutMiniCart()
4760 });
4761 }
4762 }
4763
4764 @helper RenderMiniCart(bool hasMouseEnterEvent)
4765 {
4766 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterDesktopActionsMenuMiniCart").OrderBy(item => item.SortId).ToList();
4767 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
4768 string liClasses = topLayout != "normal" ? "menu__item--top-level" : "menu--clean";
4769 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
4770 string mouseEvent = "";
4771 string id = "MiniCart";
4772 if (hasMouseEnterEvent)
4773 {
4774 mouseEvent = "onmouseenter=\"Cart.UpdateMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '/Default.aspx?ID=" + miniCartFeedPageId + "&feedType=MiniCart')\"";
4775 id = "miniCartTrigger";
4776 }
4777 <li class="menu__item menu__item--horizontal menu__item--icon @liClasses dw-mod" id="@id" @mouseEvent>
4778 @RenderBlockList(subBlocks)
4779 </li>
4780 }
4781
4782 @helper RenderNoLayoutMiniCart()
4783 {
4784 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
4785 <script>
4786 window.cartId = "@miniCartFeedPageId";
4787 </script>
4788 }
4789
4790 @helper RenderMiniCartTriggerLabel()
4791 {
4792 int cartPageId = GetPageIdByNavigationTag("CartPage");
4793 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fa fa-cart";
4794 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
4795 string menuLinkClass = topLayout != "normal" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
4796 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
4797
4798 <div class="@menuLinkClass dw-mod js-mini-cart-button" onclick="Cart.UpdateMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '/Default.aspx?ID=@miniCartFeedPageId&feedType=MiniCart')">
4799 <div class="u-inline u-position-relative" title="@Translate("Cart")">
4800 <i class="@cartIcon fa-1_5x"></i>
4801 @RenderMiniCartCounter()
4802 </div>
4803 </div>
4804 }
4805
4806 @helper RenderMiniCartTriggerLink()
4807 {
4808 int cartPageId = GetPageIdByNavigationTag("CartPage");
4809 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fa fa-cart";
4810 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
4811 string menuLinkClass = topLayout != "normal" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
4812
4813 <a href="/Default.aspx?ID=@cartPageId&Purge=True" class="@menuLinkClass menu__item--icon dw-mod js-mini-cart-button">
4814 <div class="u-inline u-position-relative" title="@Translate("Cart")">
4815 <i class="@cartIcon fa-1_5x"></i>
4816 @RenderMiniCartCounter()
4817 </div>
4818 </a>
4819 }
4820
4821 @helper RenderMiniCartCounter()
4822 {
4823 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
4824 string cartProductsCount = Model.Cart.TotalProductsCount.ToString();
4825 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right";
4826 bool showPrice = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetBoolean("ShowPrice");
4827 string cartProductsTotalPrice = showPrice && Model.Cart.TotalPrice != null ? Model.Cart.TotalPrice.Price.Formatted : "";
4828 cartProductsTotalPrice = counterPosition == "right" ? cartProductsTotalPrice : "";
4829
4830 if (showPrice && counterPosition == "right")
4831 {
4832 cartProductsCount = Translate("Cart") + "(" + cartProductsCount + ")";
4833 }
4834
4835 <div class="mini-cart__counter @(counterPosition == "right" ? "mini-cart__counter--inline" : "") dw-mod">
4836 <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">
4837 <div class="js-mini-cart-counter-content" data-count="@Model.Cart.TotalProductsCount.ToString()">
4838 @cartProductsCount
4839 @cartProductsTotalPrice
4840 </div>
4841 </div>
4842 </div>
4843 }
4844
4845 @helper RenderMiniCartCounterContent()
4846 {
4847 bool showPrice = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetBoolean("ShowPrice");
4848 string counterPosition = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("CounterPosition").SelectedValue : "right";
4849 bool showPriceInMiniCartCounter = Pageview.Device.ToString() != "Mobile" && counterPosition == "right" && showPrice;
4850
4851 <script id="MiniCartCounterContent" type="text/x-template">
4852 {{#.}}
4853 <div class="js-mini-cart-counter-content dw-mod" data-count="{{numberofproducts}}">
4854 @if (showPriceInMiniCartCounter)
4855 {
4856 @Translate("Cart")<text>({{numberofproducts}}) {{totalprice}}</text>
4857 }
4858 else
4859 {
4860 <text>{{numberofproducts}}</text>
4861 }
4862 </div>
4863 {{/.}}
4864 </script>
4865 }
4866
4867 @helper RenderMiniCartDropdownLayout()
4868 {
4869 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
4870 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage");
4871
4872 <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">
4873 <div class="mini-cart-dropdown__inner dw-mod">
4874 <h3 class="u-ta-center dw-mod">@Translate("Shopping cart")</h3>
4875 <div class="mini-cart-dropdown__body u-flex dw-mod">
4876 <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>
4877 </div>
4878 </div>
4879 </div>
4880 }
4881
4882 @helper RenderMiniCartPanelLayout()
4883 {
4884 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
4885 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage");
4886
4887 <div class="mini-cart grid__cell dw-mod">
4888 <input type="checkbox" id="miniCartTrigger" class="panel-trigger" />
4889 <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">
4890 <label for="miniCartTrigger" class="panel__close-btn" title="@Translate("Close panel")"><i class="fas fa-times"></i></label>
4891 <div class="panel__content u-full-width dw-mod">
4892 <h3 class="panel__header dw-mod u-margin-bottom u-ta-center">@Translate("Shopping cart")</h3>
4893 <div class="panel__content-body panel__content-body--cart dw-mod">
4894 <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>
4895 </div>
4896 </div>
4897 </div>
4898 </div>
4899 }
4900
4901 @helper RenderMiniCartModalLayout()
4902 {
4903 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
4904 string cartPageLink = "Default.aspx?ID=" + GetPageIdByNavigationTag("CartPage");
4905
4906 <div class="mini-cart grid__cell dw-mod">
4907 <input type="checkbox" id="miniCartTrigger" class="modal-trigger" autocomplete="off" />
4908 <div class="modal-container dw-mod js-mini-cart" id="miniCart" data-cart-id="@miniCartFeedPageId" data-show-type="block" data-cart-page-link="@cartPageLink">
4909 <label for="miniCartTrigger" class="modal-overlay"></label>
4910 <div class="modal modal--md modal--top-right dw-mod">
4911 <div class="modal__body u-flex grid--direction-column dw-mod">
4912 <h3 class="dw-mod u-ta-center">@Translate("Shopping cart")</h3>
4913 <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>
4914 </div>
4915 <label class="modal__close-btn modal__close-btn--clean dw-mod" for="miniCartTrigger" title="@Translate("Close modal")"></label>
4916 </div>
4917 </div>
4918 </div>
4919 }
4920 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4921
4922 @using System
4923 @using System.Web
4924 @using Dynamicweb.Rapido.Blocks.Extensibility
4925 @using Dynamicweb.Rapido.Blocks
4926
4927 @{
4928 bool showDownloadCartLink = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowDownloadCart");
4929
4930 Block masterDesktopActionsMenuDownloadCart = new Block
4931 {
4932 Id = "MasterDesktopActionsMenuDownloadCart",
4933 SortId = 35,
4934 Template = RenderDownloadCart()
4935 };
4936
4937 if (showDownloadCartLink && Model.CurrentUser.ID > 0)
4938 {
4939 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterDesktopActionsMenuDownloadCart);
4940 }
4941 }
4942
4943 @helper RenderDownloadCart()
4944 {
4945 int downloadCartPageId = GetPageIdByNavigationTag("DownloadCart");
4946 string downloadCartPageLink = "/Default.aspx?ID=" + downloadCartPageId;
4947
4948 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
4949 string liClasses = topLayout != "normal" ? "menu__item--top-level u-hidden-xxs" : "menu--clean";
4950 string menuLinkClass = topLayout != "normal" ? "menu__link menu__link--icon" : "header-menu__link header-menu__link--icon";
4951
4952 <li class="menu__item menu__item--horizontal @liClasses menu__item--icon dw-mod">
4953 <a href="@downloadCartPageLink" class="@menuLinkClass dw-mod" title="@Translate("Download cart")">
4954 <i class="fas fa-cart-arrow-down fa-1_5x"></i>
4955 </a>
4956 </li>
4957 }
4958 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
4959
4960 @using System
4961 @using System.Web
4962 @using Dynamicweb.Rapido.Blocks.Extensibility
4963 @using Dynamicweb.Rapido.Blocks
4964
4965 @functions {
4966 public class SearchConfiguration
4967 {
4968 public string searchFeedId { get; set; }
4969 public string searchSecondFeedId { get; set; }
4970 public int groupsFeedId { get; set; }
4971 public string resultPageLink { get; set; }
4972 public string searchPlaceholder { get; set; }
4973 public string searchType { get; set; }
4974 public string searchTemplate { get; set; }
4975 public string searchContentTemplate { get; set; }
4976 public string searchValue { get; set; }
4977 public bool showGroups { get; set; }
4978
4979 public SearchConfiguration()
4980 {
4981 searchFeedId = "";
4982 searchSecondFeedId = "";
4983 searchType = "product-search";
4984 searchContentTemplate = "";
4985 showGroups = true;
4986 }
4987 }
4988 }
4989 @{
4990 Block masterSearchBar = new Block
4991 {
4992 Id = "MasterSearchBar",
4993 SortId = 40,
4994 Template = RenderSearch("bar"),
4995 Design = new Design
4996 {
4997 Size = "auto",
4998 HidePadding = true,
4999 RenderType = RenderType.Column
5000 }
5001 };
5002
5003 Block masterSearchAction = new Block
5004 {
5005 Id = "MasterDesktopActionsMenuSearch",
5006 SortId = 10,
5007 Template = RenderSearch()
5008 };
5009
5010 BlocksPage.GetBlockPage("Master").Add("MasterHeader", masterSearchBar);
5011 BlocksPage.GetBlockPage("Master").Add("MasterDesktopActionsMenu", masterSearchAction);
5012 }
5013
5014 @helper RenderSearch(string type = "mini-search")
5015 {
5016 string productsPageId = Converter.ToString(GetPageIdByNavigationTag("ProductsPage"));
5017 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID;
5018 string searchType = Model.Area.Item.GetItem("Layout").GetList("TopSearch") != null ? Model.Area.Item.GetItem("Layout").GetList("TopSearch").SelectedValue : "productSearch";
5019
5020 SearchConfiguration searchConfiguration = null;
5021
5022 switch (searchType) {
5023 case "contentSearch":
5024 searchConfiguration = new SearchConfiguration() {
5025 searchFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true",
5026 resultPageLink = contentSearchPageLink,
5027 searchPlaceholder = Translate("Search page"),
5028 groupsFeedId = 0,
5029 searchType = "content-search",
5030 searchTemplate = "SearchPagesTemplate",
5031 showGroups = false
5032 };
5033 break;
5034 case "combinedSearch":
5035 searchConfiguration = new SearchConfiguration() {
5036 searchFeedId = productsPageId + "&feed=true",
5037 searchSecondFeedId = GetPageIdByNavigationTag("ContentSearchFeed") + "&Areaid=" + Model.Area.ID + "&pagesOnly=true",
5038 resultPageLink = Converter.ToString(productsPageId),
5039 searchPlaceholder = Translate("Search products or pages"),
5040 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"),
5041 searchType = "combined-search",
5042 searchTemplate = "SearchProductsTemplateWrap",
5043 searchContentTemplate = "SearchPagesTemplateWrap",
5044 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector")
5045 };
5046 break;
5047 default: //productSearch
5048 searchConfiguration = new SearchConfiguration() {
5049 resultPageLink = Converter.ToString(productsPageId),
5050 searchFeedId = productsPageId + "&feed=true",
5051 groupsFeedId = GetPageIdByNavigationTag("ProductGroupsFeed"),
5052 searchPlaceholder = Translate("Search products"),
5053 searchTemplate = "SearchProductsTemplate",
5054 searchType = "product-search",
5055 showGroups = Model.Area.Item.GetItem("Layout").GetBoolean("ShowGroupsSelector")
5056 };
5057 break;
5058 }
5059 searchConfiguration.searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? "";
5060
5061 if (type == "mini-search") {
5062 @RenderMiniSearch(searchConfiguration)
5063 } else {
5064 @RenderSearchBar(searchConfiguration)
5065 }
5066 }
5067
5068 @helper RenderSearchBar(SearchConfiguration options)
5069 {
5070 <div class="typeahead typeahead--centered u-color-inherit js-typeahead dw-mod" id="ProductSearchBar"
5071 data-page-size="7"
5072 data-search-feed-id="@options.searchFeedId"
5073 data-search-second-feed-id="@options.searchSecondFeedId"
5074 data-result-page-id="@options.resultPageLink"
5075 data-groups-page-id="@options.groupsFeedId"
5076 data-search-type="@options.searchType">
5077 @if (options.showGroups)
5078 {
5079 <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>
5080 <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>
5081 }
5082 <div class="typeahead-search-field">
5083 <input type="text" class="u-no-margin u-full-width u-full-height js-typeahead-search-field" placeholder="@options.searchPlaceholder" value="@options.searchValue">
5084 @if (string.IsNullOrEmpty(options.searchSecondFeedId))
5085 {
5086 <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>
5087 }
5088 else
5089 {
5090 <div class="dropdown dropdown--absolute-position dropdown--combined grid">
5091 <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>
5092 <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>
5093 </div>
5094 }
5095 </div>
5096 <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>
5097 </div>
5098 }
5099
5100 @helper RenderMiniSearch(SearchConfiguration options)
5101 {
5102 <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">
5103 <div class="menu__link menu__link--icon dw-mod" title="@Translate("Search")">
5104 <i class="@Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue fa-1_5x"></i>
5105 </div>
5106 <div class="menu menu--dropdown menu--dropdown-right u-no-padding u-w380px grid__cell dw-mod">
5107 <div class="typeahead js-typeahead" id="ProductSearchBar"
5108 data-page-size="7"
5109 data-search-feed-id="@options.searchFeedId"
5110 data-search-second-feed-id="@options.searchSecondFeedId"
5111 data-result-page-id="@options.resultPageLink"
5112 data-search-type="@options.searchType">
5113 <div class="typeahead-search-field">
5114 <input type="text" class="u-no-margin u-full-width js-typeahead-search-field" id="headerSearch" placeholder="@options.searchPlaceholder" value="@options.searchValue">
5115 @if (string.IsNullOrEmpty(options.searchSecondFeedId))
5116 {
5117 <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>
5118 }
5119 else
5120 {
5121 <div class="dropdown dropdown--absolute-position dropdown--combined grid dropdown--right-aligned">
5122 <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>
5123 <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>
5124 </div>
5125 }
5126 </div>
5127 </div>
5128 </div>
5129 </li>
5130 }
5131 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5132
5133 @using System
5134 @using System.Web
5135 @using Dynamicweb.Rapido.Blocks.Extensibility
5136 @using Dynamicweb.Rapido.Blocks
5137
5138 @{
5139 string headerConfigurationTopLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5140 bool headerConfigurationHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch");
5141
5142 BlocksPage headerConfigurationPage = BlocksPage.GetBlockPage("Master");
5143
5144 Block configDesktopLogo = headerConfigurationPage.GetBlockById("MasterDesktopLogo");
5145 headerConfigurationPage.RemoveBlock(configDesktopLogo);
5146
5147 Block configDesktopMenu = headerConfigurationPage.GetBlockById("MasterDesktopMenu");
5148 headerConfigurationPage.RemoveBlock(configDesktopMenu);
5149
5150 Block configSearchBar = headerConfigurationPage.GetBlockById("MasterSearchBar");
5151 headerConfigurationPage.RemoveBlock(configSearchBar);
5152
5153 Block configSearchAction = headerConfigurationPage.GetBlockById("MasterDesktopActionsMenuSearch");
5154 headerConfigurationPage.RemoveBlock(configSearchAction);
5155
5156 Block configDesktopActionsMenu = headerConfigurationPage.GetBlockById("MasterDesktopActionsMenu");
5157 headerConfigurationPage.RemoveBlock(configDesktopActionsMenu);
5158
5159 Block configDesktopExtra = headerConfigurationPage.GetBlockById("MasterDesktopExtra");
5160
5161 switch (headerConfigurationTopLayout)
5162 {
5163 case "condensed": //2
5164 configDesktopLogo.Design.Size = "auto-width";
5165 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo);
5166
5167 configDesktopMenu.SortId = 20;
5168 configDesktopMenu.Design.Size = "auto";
5169 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5170
5171 configDesktopActionsMenu.SortId = 30;
5172 configDesktopActionsMenu.Design.Size = "auto-width";
5173 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5174
5175 if (!headerConfigurationHideSearch)
5176 {
5177 configSearchBar.SortId = 40;
5178 configSearchBar.Design.Size = "12";
5179 configDesktopExtra.SortId = 50;
5180 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar);
5181 }
5182 break;
5183 case "splitted": //3
5184 configDesktopLogo.Design.Size = "auto";
5185 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5186
5187 if (!headerConfigurationHideSearch)
5188 {
5189 configSearchBar.SortId = 20;
5190 configSearchBar.Design.Size = "auto";
5191 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar);
5192 }
5193
5194 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5195
5196 configDesktopActionsMenu.SortId = 20;
5197 configDesktopActionsMenu.Design.Size = "auto-width";
5198 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5199 break;
5200 case "minimal": //4
5201 configDesktopLogo.Design.Size = "auto-width";
5202 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo);
5203
5204 configDesktopMenu.Design.Size = "auto";
5205 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5206
5207 configDesktopActionsMenu.SortId = 20;
5208 configDesktopActionsMenu.Design.Size = "auto-width";
5209 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5210
5211 if (!headerConfigurationHideSearch)
5212 {
5213 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5214 }
5215 break;
5216 case "minimal-right": //5
5217 configDesktopLogo.Design.Size = "auto-width";
5218 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopLogo);
5219
5220 configDesktopMenu.Design.Size = "auto";
5221 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5222
5223 configDesktopActionsMenu.SortId = 20;
5224 configDesktopActionsMenu.Design.Size = "auto-width";
5225 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5226
5227 if (!headerConfigurationHideSearch)
5228 {
5229 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5230 }
5231 break;
5232 case "two-lines": //6
5233 configDesktopLogo.Design.Size = "auto";
5234 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5235
5236 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5237
5238 configDesktopActionsMenu.SortId = 20;
5239 configDesktopActionsMenu.Design.Size = "auto-width";
5240 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5241
5242 if (!headerConfigurationHideSearch)
5243 {
5244 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5245 }
5246 break;
5247 case "two-lines-centered": //7
5248 configDesktopLogo.Design.Size = "auto";
5249 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5250
5251 configDesktopMenu.Design.Size = "auto-width";
5252 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5253
5254 configDesktopActionsMenu.SortId = 20;
5255 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopActionsMenu);
5256
5257 if (!headerConfigurationHideSearch)
5258 {
5259 headerConfigurationPage.Add("MasterDesktopActionsMenu", configSearchAction);
5260 }
5261 break;
5262 case "normal": //1
5263 default:
5264 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopLogo);
5265
5266 if (!headerConfigurationHideSearch)
5267 {
5268 configSearchBar.SortId = 20;
5269 headerConfigurationPage.Add("MasterDesktopExtra", configSearchBar);
5270 }
5271
5272 configDesktopActionsMenu.SortId = 30;
5273 headerConfigurationPage.Add("MasterDesktopExtra", configDesktopActionsMenu);
5274
5275 configDesktopActionsMenu.Design.Size = "auto-width";
5276 headerConfigurationPage.Add("MasterDesktopNavigation", configDesktopMenu);
5277 break;
5278 }
5279 }
5280 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5281
5282 @using System
5283 @using System.Web
5284 @using Dynamicweb.Rapido.Blocks.Extensibility
5285 @using Dynamicweb.Rapido.Blocks
5286
5287 @{
5288
5289 }
5290
5291
5292 @helper RenderDesktopTools()
5293 {
5294 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopTools").OrderBy(item => item.SortId).ToList();
5295
5296 <div class="tools-navigation dw-mod">
5297 <div class="center-container grid top-container__center-container dw-mod">
5298 @RenderBlockList(subBlocks)
5299 </div>
5300 </div>
5301 }
5302
5303 @helper RenderDesktopToolsText()
5304 {
5305 string toolsText = Model.Area.Item.GetItem("Layout").GetItem("Header").GetString("ToolsText");
5306 if (!string.IsNullOrEmpty(toolsText))
5307 {
5308 <div class="u-margin-top u-margin-bottom">@toolsText</div>
5309 }
5310 }
5311
5312 @helper RenderDesktopToolsNavigation()
5313 {
5314 bool renderPagesInToolBar = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("RenderPagesInToolBar");
5315
5316 if (renderPagesInToolBar)
5317 {
5318 @RenderNavigation(new
5319 {
5320 id = "topToolsNavigation",
5321 cssclass = "menu menu-tools dw-mod dwnavigation",
5322 template = "TopMenu.xslt"
5323 })
5324 }
5325 }
5326
5327 @helper RenderDesktopNavigation()
5328 {
5329 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopNavigation").OrderBy(item => item.SortId).ToList();
5330 string topLayout = Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout") != null ? Model.Area.Item.GetItem("Layout").GetItem("Header").GetList("TopLayout").SelectedValue : "normal";
5331 string alignClass = topLayout == "two-lines-centered" ? "grid--justify-center" : "";
5332 <nav class="main-navigation dw-mod">
5333 <input id="show-menu" type="checkbox" />
5334 <div class="center-container top-container__center-container grid @alignClass dw-mod">
5335 @RenderBlockList(subBlocks)
5336 </div>
5337 </nav>
5338 }
5339
5340 @helper RenderDesktopExtra()
5341 {
5342 List<Block> subBlocks = headerBlocksPage.GetBlockListById("MasterDesktopExtra").OrderBy(item => item.SortId).ToList();
5343
5344 if (subBlocks.Count > 0)
5345 {
5346 <div class="header header-top dw-mod">
5347 <div class="center-container top-container__center-container grid--justify-space-between grid grid--align-center dw-mod">
5348 @RenderBlockList(subBlocks)
5349 </div>
5350 </div>
5351 }
5352 }</text>
5353 }
5354
5355 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5356
5357 @using System
5358 @using System.Web
5359 @using Dynamicweb.Rapido.Blocks.Extensibility
5360 @using Dynamicweb.Rapido.Blocks
5361 @using Dynamicweb.Rapido.Blocks.Components.General
5362 @using Dynamicweb.Frontend
5363
5364 @functions {
5365 int impersonationPageId;
5366 string impersonationLayout;
5367 int impersonationFeed;
5368 Block impersonationBar;
5369
5370 string getUserNameFromParams(string firstName, string middleName, string lastName, string name, string email, string userName)
5371 {
5372 string username = "";
5373
5374 if (!string.IsNullOrEmpty(firstName) && !string.IsNullOrEmpty(lastName))
5375 {
5376 username = firstName + " " + (!string.IsNullOrEmpty(middleName) ? middleName + " " : "") + lastName;
5377 }
5378 else if (!string.IsNullOrEmpty(name))
5379 {
5380 username = name;
5381 }
5382 else if (!string.IsNullOrEmpty(email))
5383 {
5384 username = email;
5385 }
5386 else
5387 {
5388 username = userName;
5389 }
5390 return username;
5391 }
5392
5393 string getUserName(UserViewModel user)
5394 {
5395 return getUserNameFromParams(user.FirstName, user.MiddleName, user.LastName, user.Name, user.Email, user.UserName);
5396 }
5397
5398 string getUserName(Dynamicweb.Security.UserManagement.User user)
5399 {
5400 return getUserNameFromParams(user.FirstName, user.MiddleName, user.LastName, user.Name, user.Email, user.UserName);
5401 }
5402 }
5403
5404 @{
5405 impersonationPageId = GetPageIdByNavigationTag("Impersonation");
5406 impersonationLayout = Model.Area.Item.GetItem("Ecommerce").GetList("ImpersonationLayout") != null ? Model.Area.Item.GetItem("Ecommerce").GetList("ImpersonationLayout").SelectedValue : "bar";
5407 impersonationFeed = GetPageIdByNavigationTag("UsersFeed");
5408
5409 if (Model.CurrentUser.ID > 0 && Model.SecondaryUsers.Count > 0)
5410 {
5411 impersonationBar = new Block
5412 {
5413 Id = "ImpersonationBar",
5414 SortId = 50,
5415 Template = RenderImpersonation(),
5416 SkipRenderBlocksList = true,
5417 Design = new Design
5418 {
5419 Size = "auto-width",
5420 HidePadding = true,
5421 RenderType = RenderType.Column
5422 }
5423 };
5424
5425 Block impersonationContent = new Block
5426 {
5427 Id = "ImpersonationContent",
5428 SortId = 10
5429 };
5430
5431 if (Model.CurrentSecondaryUser != null && Model.CurrentSecondaryUser.ID > 0)
5432 {
5433 //Render stop impersonation view
5434 impersonationContent.Template = RenderStopImpersonationView();
5435 }
5436 else
5437 {
5438 //Render main view
5439 switch (impersonationLayout)
5440 {
5441 case "right-lower-box":
5442 impersonationContent.BlocksList.Add(
5443 new Block {
5444 Id = "RightLowerBoxHeader",
5445 SortId = 10,
5446 Component = new Heading {
5447 Level = 5,
5448 Title = Translate("View the list of users you can impersonate"),
5449 CssClass = "impersonation-text"
5450 }
5451 }
5452 );
5453 impersonationContent.BlocksList.Add(
5454 new Block {
5455 Id = "RightLowerBoxContent",
5456 SortId = 20,
5457 Template = RenderImpersonationControls()
5458 }
5459 );
5460 break;
5461 case "right-lower-bar":
5462 impersonationContent.BlocksList.Add(
5463 new Block {
5464 Id = "RightLowerBarContent",
5465 SortId = 10,
5466 Template = RenderImpersonationControls()
5467 }
5468 );
5469 break;
5470 case "bar":
5471 default:
5472 impersonationContent.BlocksList.Add(
5473 new Block {
5474 Id = "ViewListLink",
5475 SortId = 20,
5476 Template = RenderViewListLink()
5477 }
5478 );
5479 impersonationContent.BlocksList.Add(
5480 new Block {
5481 Id = "BarTypeaheadSearch",
5482 SortId = 30,
5483 Template = RenderTypeaheadSearch()
5484 }
5485 );
5486 break;
5487 }
5488 }
5489 impersonationBar.BlocksList.Add(impersonationContent);
5490
5491 impersonationBar.BlocksList.Add(
5492 new Block
5493 {
5494 Id = "ImpersonationSearchTemplates",
5495 SortId = 20,
5496 Template = RenderSearchResultTemplate()
5497 }
5498 );
5499 if (impersonationLayout != "bar")
5500 {
5501 impersonationBar.BlocksList.Add(
5502 new Block
5503 {
5504 Id = "ImpersonationSearchScripts",
5505 SortId = 30,
5506 Template = RenderSearchScripts()
5507 }
5508 );
5509 }
5510 BlocksPage.GetBlockPage("Master").Add("MasterHeader", impersonationBar);
5511 }
5512 }
5513
5514 @helper RenderImpersonation()
5515 {
5516 List<Block> subBlocks = impersonationBar.BlocksList.OrderBy(item => item.SortId).ToList();
5517 <input type="checkbox" class="impersonation-trigger js-remember-state" id="ImpersonationMinimizeTrigger" />
5518 <div class="impersonation impersonation--@(impersonationLayout)-layout dw-mod" id="Impersonation">
5519 @if (impersonationLayout == "right-lower-box")
5520 {
5521 @RenderRightLowerBoxHeader()
5522 }
5523 <div class="center-container top-container__center-container u-padding--lg impersonation__container @(impersonationLayout != "bar" ? "impersonation__container--box" : "") dw-mod">
5524 @*Impersonation*@
5525 @RenderBlockList(subBlocks)
5526 </div>
5527 </div>
5528 }
5529
5530 @helper RenderRightLowerBoxHeader()
5531 {
5532 <div class="impersonation__header dw-mod">
5533 <div class="impersonation__title">@Translate("Impersonation")</div>
5534 <label for="ImpersonationMinimizeTrigger" class="btn btn--impersonation impersonation__minimize-btn dw-mod" onclick="this.blur();">
5535 @Render(new Icon
5536 {
5537 Prefix = "fas",
5538 Name = "fa-window-minimize"
5539 })
5540 </label>
5541 </div>
5542 }
5543
5544 @helper RenderStopImpersonationView()
5545 {
5546 string secondaryUserName = getUserName(Model.CurrentSecondaryUser);
5547 string userName = getUserName(Pageview.User);
5548 string impersonationText = "<b>" + userName + "</b> " + Translate("is impersonating") + " <b>" + secondaryUserName + "</b>";
5549 impersonationText = Dynamicweb.Security.UserManagement.User.ImpersonationMode == Dynamicweb.Security.UserManagement.UserImpersonation.Full ? "<b>" + secondaryUserName + "</b> " + Translate("is impersonating") + " <b>" + userName + "</b>" : impersonationText;
5550
5551 if (impersonationLayout == "right-lower-box")
5552 {
5553 <div class="u-margin-bottom--lg u-ta-center">
5554 @impersonationText
5555 </div>
5556 @RenderStopImpersonationForm()
5557 }
5558 else
5559 {
5560 <div class="grid grid--align-center grid--justify-space-between impersonation__stop-wrap">
5561 <div class="u-margin-right--lg impersonation__stop-text">
5562 <i class="fas fa-user-secret"></i>
5563 @impersonationText
5564 </div>
5565 @RenderStopImpersonationForm()
5566 </div>
5567 }
5568 }
5569
5570 @helper RenderStopImpersonationForm()
5571 {
5572 <form method="post" class="u-no-margin">
5573 @Render(new Button
5574 {
5575 ButtonType = ButtonType.Submit,
5576 ButtonLayout = ButtonLayout.None,
5577 Title = Translate("Stop impersonation"),
5578 Href = "/Default.aspx?ID=" + impersonationPageId,
5579 CssClass = "impersonation__button btn btn--impersonation",
5580 Name = "DwExtranetRemoveSecondaryUser"
5581 })
5582 </form>
5583 }
5584
5585 @helper RenderImpersonationControls()
5586 {
5587 <div class="impersonation__controls">
5588 @RenderViewListLink()
5589 @RenderSearchBox()
5590 </div>
5591 @RenderResultsList()
5592 }
5593
5594 @helper RenderViewListLink()
5595 {
5596 string title = impersonationLayout == "right-lower-box" ? Translate("View the list") : Translate("View the list of users you can impersonate");
5597 string buttonClasses = impersonationLayout == "right-lower-box" ? "impersonation__button btn btn--impersonation" : "impersonation__link impersonation__link";
5598
5599 @Render(new Link {
5600 ButtonLayout = ButtonLayout.None,
5601 Title = title,
5602 Href = "/Default.aspx?ID=" + impersonationPageId,
5603 CssClass = buttonClasses
5604 })
5605 }
5606
5607 @helper RenderSearchBox()
5608 {
5609 <div class="impersonation__search-wrap">
5610 <input placeholder="@Translate("Search users")" type="text" class="impersonation__search-field dw-mod" onkeyup="searchKeyUpHandler(event)" id="ImpersonationBoxSearchField">
5611 <div id="ImpersonationBoxSearchFind" class="impersonation__search-icon dw-mod" onclick="updateResults(document.getElementById('ImpersonationBoxSearchField').value)">
5612 <i class="fal fa-search"></i>
5613 </div>
5614 <div id="ImpersonationBoxSearchClear" class="impersonation__search-icon u-hidden dw-mod" onclick="clearResults();">
5615 <i class="fal fa-times"></i>
5616 </div>
5617 </div>
5618 }
5619
5620 @helper RenderTypeaheadSearch()
5621 {
5622 <div class="typeahead u-ta-right impersonation__typeahead js-typeahead dw-mod" id="ImpersonationSearchBar"
5623 data-page-size="5"
5624 data-search-feed-id="@impersonationFeed"
5625 data-result-page-id="@impersonationPageId"
5626 data-search-type="user-search"
5627 data-search-parameter-name="q">
5628
5629 <div class="typeahead-search-field">
5630 <input type="text" class="u-no-margin js-typeahead-search-field" placeholder="@Translate("Search users")">
5631 <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>
5632 </div>
5633 </div>
5634 }
5635
5636 @helper RenderResultsList()
5637 {
5638 <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>
5639 }
5640
5641 @helper RenderSearchResultTemplate()
5642 {
5643 <script id="ImpersonationSearchResult" type="text/x-template">
5644 {{#.}}
5645 {{#Users}}
5646 <li class="impersonation__search-results-item impersonation-user">
5647 <form method="post" class="impersonation-user__form" name="account{{id}}">
5648 <input type="hidden" id="DWExtranetSecondaryUserSelector" name="DWExtranetSecondaryUserSelector" value="{{id}}">
5649 <div class="impersonation-user__info">
5650 <div class="impersonation-user__name">{{userName}}</div>
5651 <div class="impersonation-user__number">{{customerNumber}}</div>
5652 </div>
5653 @Render(new Button
5654 {
5655 ButtonType = ButtonType.Submit,
5656 ButtonLayout = ButtonLayout.Secondary,
5657 Title = Translate("Sign in as"),
5658 CssClass = "impersonation-user__sign-in-btn" + (impersonationLayout != "bar" ? " btn--impersonation" : "")
5659 })
5660 </form>
5661 </li>
5662 {{/Users}}
5663 {{#unless Users}}
5664 <li class="impersonation__search-results-item impersonation__search-results-item--not-found">
5665 @Translate("Your search gave 0 results")
5666 </li>
5667 {{/unless}}
5668 {{/.}}
5669 </script>
5670 }
5671
5672 @helper RenderSearchScripts()
5673 {
5674 <script>
5675 let inputDelayTimer;
5676 function searchKeyUpHandler(e) {
5677 clearTimeout(inputDelayTimer);
5678 let value = e.target.value;
5679 if (value != "") {
5680 inputDelayTimer = setTimeout(function () {
5681 updateResults(value);
5682 }, 500);
5683 } else {
5684 clearResults();
5685 }
5686 };
5687
5688 function updateResults(value) {
5689 if (value == "") {
5690 return null;
5691 }
5692 HandlebarsBolt.UpdateContent("ImpersonationBoxSearchResults", "/Default.aspx?ID=@impersonationFeed&q=" + value);
5693 document.getElementById("ImpersonationBoxSearchFind").classList.add("u-hidden");
5694 document.getElementById("ImpersonationBoxSearchClear").classList.remove("u-hidden");
5695 }
5696
5697 function clearResults() {
5698 document.getElementById("ImpersonationBoxSearchField").value = "";
5699 HandlebarsBolt.CleanContainer("ImpersonationBoxSearchResults");
5700 document.getElementById("ImpersonationBoxSearchFind").classList.remove("u-hidden");
5701 document.getElementById("ImpersonationBoxSearchClear").classList.add("u-hidden");
5702 }
5703 </script>
5704 }
5705 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
5706
5707 @using System
5708 @using System.Web
5709 @using System.Collections.Generic
5710 @using Dynamicweb.Rapido.Blocks.Extensibility
5711 @using Dynamicweb.Rapido.Blocks
5712
5713 @{
5714 BlocksPage miniCartBlocksPage = BlocksPage.GetBlockPage("Master");
5715 string orderlinesView = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("OrderlinesView") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("OrderlinesView").SelectedValue : "table";
5716
5717 Block orderLines = new Block
5718 {
5719 Id = "MiniCartOrderLines",
5720 SkipRenderBlocksList = true,
5721 BlocksList = new List<Block>
5722 {
5723 new Block {
5724 Id = "MiniCartOrderLinesList",
5725 SortId = 20,
5726 Template = RenderMiniCartOrderLinesList()
5727 }
5728 }
5729 };
5730
5731 Block orderlinesScriptTemplates = new Block
5732 {
5733 Id = "OrderlinesScriptTemplates"
5734 };
5735
5736 if (orderlinesView == "table")
5737 {
5738 orderLines.Template = RenderMiniCartOrderLinesTable();
5739 orderLines.BlocksList.Add(
5740 new Block
5741 {
5742 Id = "MiniCartOrderlinesTableHeader",
5743 SortId = 10,
5744 Template = RenderMiniCartOrderLinesHeader()
5745 }
5746 );
5747
5748 orderlinesScriptTemplates.Template = RenderMiniCartScriptsTableTemplates();
5749 }
5750 else
5751 {
5752 orderLines.Template = RenderMiniCartOrderLinesBlocks();
5753 orderlinesScriptTemplates.Template = RenderMiniCartScriptsListTemplates();
5754 }
5755
5756 miniCartBlocksPage.Add("MasterBottomSnippets", orderlinesScriptTemplates);
5757
5758 Block miniCartScriptTemplates = new Block()
5759 {
5760 Id = "MasterMiniCartTemplates",
5761 SortId = 1,
5762 Template = RenderMiniCartScriptTemplates(),
5763 SkipRenderBlocksList = true,
5764 BlocksList = new List<Block>
5765 {
5766 orderLines,
5767 new Block {
5768 Id = "MiniCartFooter",
5769 Template = RenderMiniCartFooter(),
5770 SortId = 50,
5771 SkipRenderBlocksList = true,
5772 BlocksList = new List<Block>
5773 {
5774 new Block {
5775 Id = "MiniCartSubTotal",
5776 Template = RenderMiniCartSubTotal(),
5777 SortId = 30
5778 },
5779 new Block {
5780 Id = "MiniCartFees",
5781 Template = RenderMiniCartFees(),
5782 SortId = 40
5783 },
5784 new Block {
5785 Id = "MiniCartPoints",
5786 Template = RenderMiniCartPoints(),
5787 SortId = 50
5788 },
5789 new Block {
5790 Id = "MiniCartTotal",
5791 Template = RenderMiniCartTotal(),
5792 SortId = 60
5793 },
5794 new Block {
5795 Id = "MiniCartDisclaimer",
5796 Template = RenderMiniCartDisclaimer(),
5797 SortId = 70
5798 },
5799 new Block {
5800 Id = "MiniCartActions",
5801 Template = RenderMiniCartActions(),
5802 SortId = 80
5803 }
5804 }
5805 }
5806 }
5807 };
5808
5809 miniCartBlocksPage.Add("MasterBottomSnippets", miniCartScriptTemplates);
5810 }
5811
5812 @helper RenderMiniCartScriptsTableTemplates()
5813 {
5814 <script id="MiniCartOrderline" type="text/x-template">
5815 {{#unless isEmpty}}
5816 <tr>
5817 <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>
5818 <td class="u-va-middle">
5819 <a href="{{link}}" class="mini-cart-orderline__name" title="{{name}}">{{name}}</a>
5820 {{#if variantname}}
5821 <a href="{{link}}" class="mini-cart-orderline__name mini-cart-orderline__name--sm">{{variantname}}</a>
5822 {{/if}}
5823 {{#if unitname}}
5824 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm">{{unitname}}</div>
5825 {{/if}}
5826 </td>
5827 <td class="u-ta-right u-va-middle">{{quantity}}</td>
5828 <td class="u-ta-right u-va-middle">
5829 {{#if pointsTotal}}
5830 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points")
5831 {{else}}
5832 {{totalprice}}
5833 {{/if}}
5834 </td>
5835 </tr>
5836 {{/unless}}
5837 </script>
5838
5839 <script id="MiniCartOrderlineDiscount" type="text/x-template">
5840 {{#unless isEmpty}}
5841 <tr class="table__row--no-border">
5842 <td class="u-w60px"> </td>
5843 <td><div class="mini-cart-orderline__name dw-mod">{{name}}</div></td>
5844 <td class="u-ta-right"> </td>
5845 <td class="u-ta-right">{{totalprice}}</td>
5846 </tr>
5847 {{/unless}}
5848 </script>
5849 }
5850
5851 @helper RenderMiniCartScriptsListTemplates()
5852 {
5853 int cartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
5854
5855 <script id="MiniCartOrderline" type="text/x-template">
5856 {{#unless isEmpty}}
5857 <div class="mini-cart-orderline grid dw-mod">
5858 <div class="grid__col-4">
5859 <a href="{{link}}" class="{{hideimage}}">
5860 <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}}">
5861 </a>
5862 </div>
5863 <div class="grid__col-8">
5864 <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>
5865 {{#if variantname}}
5866 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Variant"): {{variantname}}</div>
5867 {{/if}}
5868 {{#if unitname}}
5869 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Unit"): {{unitname}}</div>
5870 {{/if}}
5871 <div class="mini-cart-orderline__name mini-cart-orderline__name--sm dw-mod">@Translate("Qty"): {{quantity}}</div>
5872
5873 <div class="grid__cell-footer">
5874 <div class="grid__cell">
5875 <div class="u-pull--left mini-cart-orderline__price dw-mod">
5876 {{#if pointsTotal}}
5877 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points")
5878 {{else}}
5879 {{totalprice}}
5880 {{/if}}
5881 </div>
5882 <button type="button" title="@Translate("Remove orderline")" class="btn btn--clean btn--condensed u-pull--right mini-cart-orderline__remove-btn dw-mod" onclick="{{removeFromCartGoogleImpression}}; Cart.UpdateCart('miniCartContent', '/Default.aspx?ID=@cartFeedPageId', 'CartCmd=DelOrderLine&key={{orderLineId}}&redirect=false', true);">@Translate("Remove")</button>
5883 </div>
5884 </div>
5885 </div>
5886 </div>
5887 {{/unless}}
5888 </script>
5889
5890 <script id="MiniCartOrderlineDiscount" type="text/x-template">
5891 {{#unless isEmpty}}
5892 <div class="mini-cart-orderline mini-cart-orderline--discount grid dw-mod">
5893 <div class="grid__col-4">
5894 <div class="mini-cart-orderline__name mini-cart-orderline__name dw-mod">{{name}}</div>
5895 </div>
5896 <div class="grid__col-8">{{totalprice}}</div>
5897 </div>
5898 {{/unless}}
5899 </script>
5900 }
5901
5902 @helper RenderMiniCartScriptTemplates()
5903 {
5904 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterMiniCartTemplates").OrderBy(item => item.SortId).ToList();
5905 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID"));
5906 string cartPageLink = string.Concat("/Default.aspx?ID=", GetPageIdByNavigationTag("CartPage"));
5907
5908 <script id="MiniCartContent" type="text/x-template">
5909 {{#.}}
5910 {{#unless isEmpty}}
5911 @RenderBlockList(subBlocks)
5912 {{/unless}}
5913 {{/.}}
5914 </script>
5915 }
5916
5917 @helper RenderMiniCartOrderLinesTable()
5918 {
5919 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartOrderLines").OrderBy(item => item.SortId).ToList();
5920
5921 <div class="u-overflow-auto">
5922 <table class="table mini-cart-table dw-mod">
5923 @RenderBlockList(subBlocks)
5924 </table>
5925 </div>
5926 }
5927
5928 @helper RenderMiniCartOrderLinesBlocks()
5929 {
5930 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartOrderLines").OrderBy(item => item.SortId).ToList();
5931
5932 <div class="u-overflow-auto">
5933 @RenderBlockList(subBlocks)
5934 </div>
5935 }
5936
5937 @helper RenderMiniCartOrderLinesHeader()
5938 {
5939 <thead>
5940 <tr>
5941 <td> </td>
5942 <td>@Translate("Product")</td>
5943 <td class="u-ta-right">@Translate("Qty")</td>
5944 <td class="u-ta-right" width="120">@Translate("Price")</td>
5945 </tr>
5946 </thead>
5947 }
5948
5949 @helper RenderMiniCartOrderLinesList()
5950 {
5951 <text>
5952 {{#OrderLines}}
5953 {{#ifCond template "===" "CartOrderline"}}
5954 {{>MiniCartOrderline}}
5955 {{/ifCond}}
5956 {{#ifCond template "===" "CartOrderlineMobile"}}
5957 {{>MiniCartOrderline}}
5958 {{/ifCond}}
5959 {{#ifCond template "===" "CartOrderlineDiscount"}}
5960 {{>MiniCartOrderlineDiscount}}
5961 {{/ifCond}}
5962 {{/OrderLines}}
5963 </text>
5964 }
5965
5966 @helper RenderMiniCartFees()
5967 {
5968 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly");
5969 if (!pointShop)
5970 {
5971 <text>
5972 {{#unless hidePaymentfee}}
5973 <div class="grid">
5974 <div class="grid__col-6 grid__col--bleed-y">
5975 {{paymentmethod}}
5976 </div>
5977 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{paymentfee}}</div>
5978 </div>
5979 {{/unless}}
5980 </text>
5981 }
5982 <text>
5983 {{#unless hideShippingfee}}
5984 <div class="grid">
5985 <div class="grid__col-6 grid__col--bleed-y">
5986 {{shippingmethod}}
5987 </div>
5988 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{shippingfee}}</div>
5989 </div>
5990 {{/unless}}
5991 </text>
5992 <text>
5993 {{#if hasTaxSettings}}
5994 <div class="grid">
5995 <div class="grid__col-6 grid__col--bleed-y">@Translate("Sales Tax")</div>
5996 <div class="grid__col-6 grid__col--bleed-y grid--align-end">{{totaltaxes}}</div>
5997 </div>
5998 {{/if}}
5999 </text>
6000 }
6001
6002 @helper RenderMiniCartFooter()
6003 {
6004 List<Block> subBlocks = this.masterPage.GetBlockListById("MiniCartFooter").OrderBy(item => item.SortId).ToList();
6005
6006 <div class="mini-cart__footer u-border-top u-padding-top dw-mod">
6007 @RenderBlockList(subBlocks)
6008 </div>
6009 }
6010
6011 @helper RenderMiniCartActions()
6012 {
6013 int cartPageId = GetPageIdByNavigationTag("CartPage");
6014
6015 <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>
6016 <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>
6017 }
6018
6019 @helper RenderMiniCartPoints()
6020 {
6021 <text>
6022 {{#if earnings}}
6023 <div class="grid">
6024 <div class="grid__col-6 grid__col--bleed-y">@Translate("Earnings")</div>
6025 <div class="grid__col-6 grid__col--bleed-y grid--align-end">
6026 <div>
6027 <span class="u-color--loyalty-points">{{earnings}}</span> @Translate("points")
6028 </div>
6029 </div>
6030 </div>
6031 {{/if}}
6032 </text>
6033 }
6034
6035 @helper RenderMiniCartSubTotal()
6036 {
6037 bool hasTaxSettings = Dynamicweb.Rapido.Services.Countries.HasTaxSettings(Model.Cart.ID);
6038 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly");
6039 if (!pointShop)
6040 {
6041 <text>
6042 {{#unless hideSubTotal}}
6043 <div class="grid dw-mod u-bold">
6044 <div class="grid__col-6 grid__col--bleed-y">@Translate("Subtotal")</div>
6045 <div class="grid__col-6 grid__col--bleed-y grid--align-end">
6046 @if (hasTaxSettings)
6047 {
6048 <text>{{subtotalpricewithouttaxes}}</text>
6049 }
6050 else
6051 {
6052 <text>{{subtotalprice}}</text>
6053 }
6054 </div>
6055 </div>
6056 {{/unless}}
6057 </text>
6058 }
6059 }
6060
6061 @helper RenderMiniCartTotal()
6062 {
6063 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly");
6064
6065 <div class="mini-cart-totals grid u-border-top u-margin-top dw-mod">
6066 <div class="grid__col-6">@Translate("Total")</div>
6067 <div class="grid__col-6 grid--align-end">
6068 <div>
6069 @if (pointShop)
6070 {
6071 <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points")
6072 }
6073 else
6074 {
6075 <text>{{totalprice}}</text>
6076 }
6077 </div>
6078 </div>
6079 </div>
6080 }
6081
6082 @helper RenderMiniCartDisclaimer()
6083 {
6084 <text>
6085 {{#if showCheckoutDisclaimer}}
6086 <div class="grid u-margin-bottom u-ta-right">
6087 <small class="grid__col-12">{{checkoutDisclaimer}}</small>
6088 </div>
6089 {{/if}}
6090 </text>
6091 }
6092 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
6093
6094 @using Dynamicweb.Rapido.Blocks.Extensibility
6095 @using Dynamicweb.Rapido.Blocks
6096 @using Dynamicweb.Rapido.Blocks.Components.General
6097 @using Dynamicweb.Rapido.Blocks.Components
6098 @using Dynamicweb.Rapido.Services
6099
6100 @{
6101 string addToCartNotificationType = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("AddToCartNotificationType") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("AddToCartNotificationType").SelectedValue : "";
6102 string addToCartNotificationMiniCartLayout = Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout") != null ? Model.Area.Item.GetItem("Ecommerce").GetItem("MiniCart").GetList("Layout").SelectedValue : "dropdown";
6103 bool addToCartHideCartIcon = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideCart");
6104
6105 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed() && !string.IsNullOrEmpty(addToCartNotificationType))
6106 {
6107 if (addToCartNotificationType == "modal")
6108 {
6109 Block addToCartNotificationModal = new Block
6110 {
6111 Id = "AddToCartNotificationModal",
6112 Template = RenderAddToCartNotificationModal()
6113 };
6114
6115 Block addToCartNotificationScript = new Block
6116 {
6117 Id = "AddToCartNotificationScript",
6118 Template = RenderAddToCartNotificationModalScript()
6119 };
6120 BlocksPage.GetBlockPage("Master").Add("MasterTopSnippets", addToCartNotificationModal);
6121 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", addToCartNotificationScript);
6122 }
6123 else if (addToCartNotificationType == "toggle" && addToCartNotificationMiniCartLayout != "none" && !addToCartHideCartIcon && Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet")
6124 {
6125 Block addToCartNotificationScript = new Block
6126 {
6127 Id = "AddToCartNotificationScript",
6128 Template = RenderAddToCartNotificationToggleScript()
6129 };
6130 BlocksPage.GetBlockPage("Master").Add("MasterBottomSnippets", addToCartNotificationScript);
6131 }
6132 }
6133 }
6134
6135 @helper RenderAddToCartNotificationModal()
6136 {
6137 <div id="LastAddedProductModal" data-template="LastAddedProductTemplate"></div>
6138 }
6139
6140 @helper RenderAddToCartNotificationModalScript()
6141 {
6142 int cartPageId = GetPageIdByNavigationTag("CartPage");
6143
6144 <script id="LastAddedProductTemplate" type="text/x-template">
6145 @{
6146
6147 Modal lastAddedProduct = new Modal
6148 {
6149 Id = "LastAddedProduct",
6150 Heading = new Heading
6151 {
6152 Level = 2,
6153 Title = Translate("Product is added to the cart")
6154 },
6155 Width = ModalWidth.Md,
6156 BodyTemplate = RenderModalContent()
6157 };
6158
6159 lastAddedProduct.AddActions(
6160 new Button
6161 {
6162 ButtonType = ButtonType.Button,
6163 ButtonLayout = ButtonLayout.Secondary,
6164 Title = Translate("Continue shopping"),
6165 CssClass = "u-pull--left u-no-margin btn--sm",
6166 OnClick = "document.getElementById('LastAddedProductModalTrigger').checked = false"
6167 },
6168 new Link
6169 {
6170 Href = "/Default.aspx?ID=" + cartPageId,
6171 ButtonLayout = ButtonLayout.Secondary,
6172 CssClass = "u-pull--right u-no-margin btn--sm",
6173 Title = Translate("Proceed to checkout")
6174 }
6175 );
6176
6177 @Render(lastAddedProduct)
6178 }
6179 </script>
6180 <script>
6181 document.addEventListener('addToCart', function (event) {
6182 Cart.ShowLastAddedProductModal(event.detail);
6183 });
6184 </script>
6185 }
6186
6187 @helper RenderModalContent()
6188 {
6189 <div class="grid">
6190 <div class="grid__col-2">
6191 @Render(new Image { Path = "{{ productInfo.image }}", Link = "{{ productInfo.link }}", Title = "{{ productInfo.name }}", DisableImageEngine = true })
6192 </div>
6193 <div class="u-padding grid--align-self-center">
6194 <span>{{quantity}}</span> x
6195 </div>
6196 <div class="grid__col-auto grid--align-self-center">
6197 <div>{{productInfo.name}}</div>
6198 {{#if productInfo.variantName}}
6199 <small class="u-margin-bottom-5px">{{productInfo.variantName}}</small>
6200 {{/if}}
6201 {{#if productInfo.unitName}}
6202 <small class="u-margin-bottom-5px">{{productInfo.unitName}}</small>
6203 {{/if}}
6204 </div>
6205 </div>
6206 }
6207
6208 @helper RenderAddToCartNotificationToggleScript()
6209 {
6210 int miniCartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed");
6211
6212 <script>
6213 document.addEventListener('addToCart', function () {
6214 Cart.ToggleMiniCart('miniCartTrigger', 'miniCart', 'cartCounter', '@miniCartFeedPageId');
6215 });
6216 </script>
6217 }
6218 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
6219
6220 @using System
6221 @using System.Web
6222 @using System.Collections.Generic
6223 @using Dynamicweb.Rapido.Blocks.Extensibility
6224 @using Dynamicweb.Rapido.Blocks
6225 @using Dynamicweb.Rapido.Blocks.Components.General
6226
6227 @functions {
6228 BlocksPage footerBlocksPage = BlocksPage.GetBlockPage("Master");
6229 }
6230
6231 @{
6232 string footerColumnOneContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnOne").GetString("Content");
6233 string footerColumnTwoContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnTwo").GetString("Content");
6234 string footerColumnThreeContent = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnThree").GetString("Content");
6235 string footerColumnOneHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnOne").GetString("Header");
6236 string footerColumnTwoHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnTwo").GetString("Header");
6237 string footerColumnThreeHeader = Model.Area.Item.GetItem("Layout").GetItem("FooterColumnThree").GetString("Header");
6238
6239 Block masterFooterContent = new Block()
6240 {
6241 Id = "MasterFooterContent",
6242 SortId = 10,
6243 Template = RenderFooter(),
6244 SkipRenderBlocksList = true
6245 };
6246 footerBlocksPage.Add(MasterBlockId.MasterFooter, masterFooterContent);
6247
6248 if (!string.IsNullOrEmpty(footerColumnOneContent) || !string.IsNullOrEmpty(footerColumnOneHeader))
6249 {
6250 Block masterFooterColumnOne = new Block
6251 {
6252 Id = "MasterFooterColumnOne",
6253 SortId = 10,
6254 Template = RenderFooterColumn(footerColumnOneHeader, footerColumnOneContent),
6255 Design = new Design
6256 {
6257 Size = "auto",
6258 RenderType = RenderType.Column
6259 }
6260 };
6261 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnOne);
6262 }
6263
6264 if (!string.IsNullOrEmpty(footerColumnTwoContent) || !string.IsNullOrEmpty(footerColumnTwoHeader))
6265 {
6266 Block masterFooterColumnTwo = new Block
6267 {
6268 Id = "MasterFooterColumnTwo",
6269 SortId = 20,
6270 Template = RenderFooterColumn(footerColumnTwoHeader, footerColumnTwoContent),
6271 Design = new Design
6272 {
6273 Size = "auto",
6274 RenderType = RenderType.Column
6275 }
6276 };
6277 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnTwo);
6278 }
6279
6280 if (!string.IsNullOrEmpty(footerColumnThreeContent) || !string.IsNullOrEmpty(footerColumnThreeHeader))
6281 {
6282 Block masterFooterColumnThree = new Block
6283 {
6284 Id = "MasterFooterColumnThree",
6285 SortId = 30,
6286 Template = RenderFooterColumn(footerColumnThreeHeader, footerColumnThreeContent),
6287 Design = new Design
6288 {
6289 Size = "auto",
6290 RenderType = RenderType.Column
6291 }
6292 };
6293 footerBlocksPage.Add("MasterFooterContent", masterFooterColumnThree);
6294 }
6295
6296 if (Model.Area.Item.GetItem("Layout").GetBoolean("FooterNewsletterSignUp"))
6297 {
6298 Block masterFooterNewsletterSignUp = new Block
6299 {
6300 Id = "MasterFooterNewsletterSignUp",
6301 SortId = 40,
6302 Template = RenderFooterNewsletterSignUp(),
6303 Design = new Design
6304 {
6305 Size = "auto",
6306 RenderType = RenderType.Column
6307 }
6308 };
6309 footerBlocksPage.Add("MasterFooterContent", masterFooterNewsletterSignUp);
6310 }
6311
6312 if (Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks") != null && Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks").Count > 0)
6313 {
6314 Block masterFooterSocialLinks = new Block
6315 {
6316 Id = "MasterFooterSocialLinks",
6317 SortId = 50,
6318 Template = RenderFooterSocialLinks(),
6319 Design = new Design
6320 {
6321 Size = "auto",
6322 RenderType = RenderType.Column
6323 }
6324 };
6325 footerBlocksPage.Add("MasterFooterContent", masterFooterSocialLinks);
6326 }
6327
6328 if (Model.Area.Item.GetItem("Layout").GetItems("FooterPayments") != null && Model.Area.Item.GetItem("Layout").GetItems("FooterPayments").Count > 0)
6329 {
6330 Block masterFooterPayments = new Block
6331 {
6332 Id = "MasterFooterPayments",
6333 SortId = 60,
6334 Template = RenderFooterPayments(),
6335 Design = new Design
6336 {
6337 Size = "12",
6338 RenderType = RenderType.Column
6339 }
6340 };
6341 footerBlocksPage.Add("MasterFooterContent", masterFooterPayments);
6342 }
6343
6344 Block masterFooterCopyright = new Block
6345 {
6346 Id = "MasterFooterCopyright",
6347 SortId = 70,
6348 Template = RenderFooterCopyright(),
6349 Design = new Design
6350 {
6351 Size = "12",
6352 RenderType = RenderType.Column
6353 }
6354 };
6355 footerBlocksPage.Add("MasterFooterContent", masterFooterCopyright);
6356 }
6357
6358 @helper RenderFooter()
6359 {
6360 List<Block> subBlocks = this.footerBlocksPage.GetBlockListById("MasterFooterContent").OrderBy(item => item.SortId).ToList();
6361
6362 <footer class="footer dw-mod">
6363 <div class="center-container top-container__center-container dw-mod">
6364 <div class="grid grid--external-bleed-x">
6365 @RenderBlockList(subBlocks)
6366 </div>
6367 </div>
6368 </footer>
6369 }
6370
6371 @helper RenderFooterColumn(string header, string content)
6372 {
6373 <h3 class="footer__heading dw-mod">@header</h3>
6374 <div class="footer__content dw-mod">
6375 @content
6376 </div>
6377 }
6378
6379 @helper RenderFooterNewsletterSignUp()
6380 {
6381 string newsletterSignUpPageId = GetPageIdByNavigationTag("NewsletterSignUp").ToString();
6382 Form form = new Form { Action = "/Default.aspx", Method = FormMethod.Get, Enctype = FormEnctype.multipart };
6383
6384 form.Add(new HiddenField { Name = "ID", Value = newsletterSignUpPageId });
6385 form.Add(new Text { Content = "<p>" + Translate("Sign up if you would like to receive occasional treats from us") + "</p>" });
6386 form.Add(new TextField {
6387 Id = "NewsletterEmail", Name = "NewsletterEmail", Placeholder = Translate("Your email address"),
6388 Type = TextFieldType.Email,
6389 ActionButton = new Button {
6390 ButtonType = ButtonType.Submit, Id="Submitter", Title = Translate("Go"), OnClick = "Buttons.LockButton(event)", CssClass = "btn--condensed"
6391 }
6392 });
6393
6394 <h3 class="footer__heading dw-mod">@Translate("Mailing list")</h3>
6395 <div class="footer__content dw-mod" style="max-width: 330px;">
6396 @Render(form)
6397 </div>
6398 }
6399
6400 @helper RenderFooterSocialLinks()
6401 {
6402 <h3 class="footer__heading dw-mod">@Translate("Social links")</h3>
6403 <div class="footer__content dw-mod">
6404 <div class="collection dw-mod">
6405 @foreach (var socialitem in Model.Area.Item.GetItem("Layout").GetItems("FooterSocialLinks"))
6406 {
6407 var socialIcon = socialitem.GetValue("Icon") as Dynamicweb.Frontend.ListViewModel;
6408 string socialIconClass = socialIcon.SelectedValue;
6409 string socialIconTitle = socialIcon.SelectedName;
6410 string socialLink = socialitem.GetString("Link");
6411
6412 <a href="@socialLink" target="_blank" title="@socialIconTitle" class="u-margin-bottom-5px" rel="noopener"><i class="@socialIconClass fa-2x"></i></a>
6413 }
6414 <a target="_blank" href="https://hr.jooble.org/posao-software-developer" title="Jooble" class="u-margin-bottom-5px" style="background-color: white;padding: 3px 2px 4px 2px;border-radius: 3px;
6415 margin-top: -2px;">
6416 <img src="https://hr.jooble.org/css/images/logos/jooble_80x60.png" style="max-width: 29px;" alt="Poslovi u Hrvatskoj">
6417 </a>
6418 </div>
6419 </div>
6420 }
6421
6422 @helper RenderFooterPayments()
6423 {
6424 <div class="footer__content dw-mod">
6425 <div class="collection dw-mod">
6426 @foreach (var payment in Model.Area.Item.GetItem("Layout").GetItems("FooterPayments"))
6427 {
6428 var paymentItem = payment.GetValue("CardTypeOrVerifiedPayment") as Dynamicweb.Frontend.ListViewModel;
6429 string paymentImage = null;
6430 string paymentTitle = paymentItem.SelectedName;
6431 ListOptionViewModel selected = paymentItem.SelectedOptions.FirstOrDefault();
6432 if (selected != null)
6433 {
6434 paymentImage = selected.Icon;
6435 }
6436
6437 <div class="footer__card-type">
6438 <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" />
6439 </div>
6440 }
6441 </div>
6442 </div>
6443 }
6444
6445
6446 @helper RenderFooterCopyright()
6447 {
6448 <div class="grid__col-12 footer__copyright dw-mod">
6449 <p>@Model.Area.Item.GetItem("Layout").GetString("FooterCopyrightText")</p>
6450 </div>
6451 }
6452 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
6453
6454 @using System
6455 @using System.Web
6456 @using System.Collections.Generic
6457 @using Dynamicweb.Rapido.Blocks.Extensibility
6458 @using Dynamicweb.Rapido.Blocks
6459 @using Dynamicweb.Ecommerce.Common
6460
6461 @{
6462 BlocksPage referencesBlocksPage = BlocksPage.GetBlockPage("Master");
6463
6464 Block masterScriptReferences = new Block()
6465 {
6466 Id = "MasterScriptReferences",
6467 SortId = 1,
6468 Template = RenderMasterScriptReferences()
6469 };
6470 referencesBlocksPage.Add(MasterBlockId.MasterReferences, masterScriptReferences);
6471 }
6472
6473 @helper RenderMasterScriptReferences() {
6474 <script src="/Files/Templates/Designs/Rapido/js/handlebars-v4.0.12.min.js"></script>
6475 <script src="/Files/Templates/Designs/Rapido/js/master.min.js"></script>
6476
6477 if (Model.Area.Item.GetItem("Custom").GetBoolean("UseCustomJavascript"))
6478 {
6479 <script src="/Files/Templates/Designs/Rapido/js/custom.min.js"></script>
6480 PushPromise("/Files/Templates/Designs/Rapido/js/custom.min.js");
6481 }
6482
6483 PushPromise("/Files/Templates/Designs/Rapido/js/handlebars-v4.0.12.min.js");
6484 PushPromise("/Files/Templates/Designs/Rapido/js/master.min.js");
6485 }
6486 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
6487
6488 @using System
6489 @using System.Web
6490 @using System.Collections.Generic
6491 @using Dynamicweb.Rapido.Blocks.Extensibility
6492 @using Dynamicweb.Rapido.Blocks
6493 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce
6494 @using Dynamicweb.Rapido.Services
6495
6496 @{
6497 BlocksPage searchBlocksPage = BlocksPage.GetBlockPage("Master");
6498 bool navigationItemsHideSearch = Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("HideSearch");
6499 bool isFavoriteList = !string.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("ListID"));
6500
6501 if (!navigationItemsHideSearch || isFavoriteList)
6502 {
6503 Block masterSearchScriptTemplates = new Block()
6504 {
6505 Id = "MasterSearchScriptTemplates",
6506 SortId = 1,
6507 Template = RenderSearchScriptTemplates()
6508 };
6509
6510 searchBlocksPage.Add(MasterBlockId.MasterBottomSnippets, masterSearchScriptTemplates);
6511 }
6512 }
6513
6514 @helper RenderSearchScriptTemplates()
6515 {
6516 int productsPageId = GetPageIdByNavigationTag("ProductsPage");
6517 string contentSearchPageLink = GetPageIdByNavigationTag("ContentSearchResults") + "&Areaid=" + Model.Area.ID;
6518 bool useFacebookPixel = !string.IsNullOrWhiteSpace(Pageview.AreaSettings.GetItem("Settings").GetString("FacebookPixelID"));
6519 bool useGoogleTagManager = !string.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("GoogleTagManagerID"));
6520 bool showPrice = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HidePriceInSearchResults");
6521 bool showAddToCartButton = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HideAddToCartButton");
6522 bool showViewButton = !Pageview.AreaSettings.GetItem("Layout").GetBoolean("HideViewButton");
6523 bool showAddToDownloadButton = Pageview.AreaSettings.GetItem("Layout").GetBoolean("ShowAddToDownloadButton");
6524 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly");
6525
6526 <script id="SearchGroupsTemplate" type="text/x-template">
6527 {{#.}}
6528 <li class="dropdown__item dw-mod" onclick="Search.UpdateGroupSelection(this)" data-group-id="{{id}}">{{name}}</li>
6529 {{/.}}
6530 </script>
6531
6532 <script id="SearchProductsTemplate" type="text/x-template">
6533 {{#each .}}
6534 {{#Product}}
6535 {{#ifCond template "!==" "SearchMore"}}
6536 <li class="dropdown__item dropdown__item--seperator dw-mod">
6537 @if (useFacebookPixel)
6538 {
6539 <text>{{{facebookPixelSearch name number priceDouble currency searchParameter}}}</text>
6540 }
6541 @if (useGoogleTagManager)
6542 {
6543 <text>{{{googleEnchantImpression 'Search results' currency googleImpression}}}</text>
6544 }
6545 <div>
6546 <a href="{{link}}" class="js-typeahead-link u-color-inherit u-pull--left" onclick="{{googleImpressionClick}}" title="{{name}}{{#if variantName}}, {{variantName}}{{/if}}">
6547 <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>
6548 <div class="u-pull--left">
6549 <div class="u-bold u-max-w220px u-truncate-text js-typeahead-name">{{name}}{{#if variantName}}, {{variantName}}{{/if}}</div>
6550 @if (showPrice && Dynamicweb.Rapido.Services.User.IsPricesAllowed())
6551 {
6552 if (pointShopOnly)
6553 {
6554 <text>
6555 {{#if havePointPrice}}
6556 <div>
6557 <span class="u-color--loyalty-points">{{points}}</span> @Translate("points")
6558 </div>
6559 {{else}}
6560 <small class="help-text u-no-margin">@Translate("Not available")</small>
6561 {{/if}}
6562 {{#unless canBePurchasedWithPoints}}
6563 {{#if havePointPrice}}
6564 <small class="help-text u-no-margin">@Translate("Not enough points to buy this")</small>
6565 {{/if}}
6566 {{/unless}}
6567 </text>
6568 }
6569 else
6570 {
6571 <div>{{price}}</div>
6572 }
6573 }
6574 </div>
6575 </a>
6576 <div class="u-margin-left u-pull--right">
6577 @{
6578 var viewBtn = new Link
6579 {
6580 Href = "{{link}}",
6581 OnClick = "{{googleImpressionClick}}",
6582 ButtonLayout = ButtonLayout.Secondary,
6583 CssClass = "btn--condensed u-no-margin u-w80px js-ignore-click-outside",
6584 Title = Translate("View")
6585 };
6586 }
6587 @if (showAddToCartButton && Dynamicweb.Rapido.Services.User.IsBuyingAllowed())
6588 {
6589 <text>{{#if hideAddToCartButton}}</text>
6590 @Render(viewBtn)
6591 <text>{{else}}</text>
6592 @Render(new AddToCartButton
6593 {
6594 HideTitle = true,
6595 ProductId = "{{productId}}",
6596 ProductInfo = "{{productInfo}}",
6597 BuyForPoints = pointShopOnly,
6598 OnClick = "{{facebookPixelAction}}",
6599 CssClass = "u-w80px js-ignore-click-outside",
6600 Icon = new Icon {
6601 CssClass = "js-ignore-click-outside"
6602 },
6603 ExtraAttributes = new Dictionary<string, string>
6604 {
6605 { "{{disabledBuyButton}}", "" }
6606 }
6607 })
6608 <text>{{/if}}</text>
6609 }
6610 else if (showViewButton)
6611 {
6612 @Render(viewBtn)
6613 }
6614 @if (showAddToDownloadButton)
6615 {
6616 <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}}">
6617 <i class="fas fa-plus js-button-icon"></i>
6618 </button>
6619 }
6620 </div>
6621 </div>
6622 </li>
6623 {{/ifCond}}
6624 {{#ifCond template "===" "SearchMore"}}
6625 {{>SearchMoreProducts}}
6626 {{/ifCond}}
6627 {{/Product}}
6628 {{else}}
6629 <li class="dropdown__item dropdown__item--seperator dropdown__item--not-selectable js-no-result dw-mod">
6630 @Translate("Your search gave 0 results")
6631 </li>
6632 {{/each}}
6633 </script>
6634
6635 <script id="SearchMoreProducts" type="text/x-template">
6636 <li class="dropdown__item dropdown__item--not-selectable {{stickToBottom}} dw-mod">
6637 <a href="/Default.aspx?ID=@productsPageId&Search={{searchParameter}}&GroupID={{groupId}}" class="btn btn--primary btn--full u-no-margin dw-mod js-typeahead-link">
6638 @Translate("View all")
6639 </a>
6640 </li>
6641 </script>
6642
6643 <script id="SearchMorePages" type="text/x-template">
6644 <li class="dropdown__item dropdown__item--not-selectable {{stickToBottom}} dw-mod">
6645 <a href="/Default.aspx?ID=@contentSearchPageLink&Search={{searchParameter}}" class="btn btn--primary btn--full u-no-margin dw-mod js-typeahead-link">
6646 @Translate("View all")
6647 </a>
6648 </li>
6649 </script>
6650
6651 <script id="SearchPagesTemplate" type="text/x-template">
6652 {{#each .}}
6653 {{#ifCond template "!==" "SearchMore"}}
6654 <li class="dropdown__item dropdown__item--seperator dw-mod">
6655 <div>
6656 <a href="/Default.aspx?ID={{id}}" class="js-typeahead-link u-pull--left u-color-inherit">
6657 <div class="u-margin-right u-pull--left"><i class="fa {{icon}} u-w20px u-ta-center"></i></div>
6658 <div class="u-pull--left">
6659 <div class="u-bold u-truncate-text u-max-w220px js-typeahead-name">{{name}}</div>
6660 </div>
6661 </a>
6662 </div>
6663 </li>
6664 {{/ifCond}}
6665 {{#ifCond template "===" "SearchMore"}}
6666 {{>SearchMorePages}}
6667 {{/ifCond}}
6668 {{else}}
6669 <li class="dropdown__item dropdown__item--seperator dropdown__item--not-selectable js-no-result dw-mod">
6670 @Translate("Your search gave 0 results")
6671 </li>
6672 {{/each}}
6673 </script>
6674
6675 <script id="SearchPagesTemplateWrap" type="text/x-template">
6676 <div class="dropdown__column-header">@Translate("Pages")</div>
6677 <ul class="dropdown__list u-min-w220px u-full-width u-margin-bottom u-height--auto u-flex-grow--1 dw-mod">
6678 {{>SearchPagesTemplate}}
6679 </ul>
6680 </script>
6681
6682 <script id="SearchProductsTemplateWrap" type="text/x-template">
6683 <div class="dropdown__column-header">@Translate("Products")</div>
6684 <ul class="dropdown__list u-min-w220px u-full-width u-margin-bottom u-height--auto u-flex-grow--1 dw-mod">
6685 {{>SearchProductsTemplate}}
6686 </ul>
6687 </script>
6688 }
6689
6690 @using Dynamicweb.Rapido.Blocks.Components
6691 @using Dynamicweb.Rapido.Blocks.Components.General
6692 @using Dynamicweb.Rapido.Blocks
6693 @using System.IO
6694
6695
6696 @using Dynamicweb.Rapido.Blocks.Components.General
6697 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce
6698
6699
6700 @* Component *@
6701
6702 @helper RenderVariantMatrix(VariantMatrix settings) {
6703 if (settings != null)
6704 {
6705 int productLoopCounter = 0;
6706 int groupCount = 0;
6707 List<VariantOption> firstDimension = new List<VariantOption>();
6708 List<VariantOption> secondDimension = new List<VariantOption>();
6709 List<VariantOption> thirdDimension = new List<VariantOption>();
6710
6711 foreach (VariantGroup variantGroup in settings.GetVariantGroups())
6712 {
6713 foreach (VariantOption variantOptions in variantGroup.GetVariantOptions())
6714 {
6715 if (groupCount == 0) {
6716 firstDimension.Add(variantOptions);
6717 }
6718 if (groupCount == 1)
6719 {
6720 secondDimension.Add(variantOptions);
6721 }
6722 if (groupCount == 2)
6723 {
6724 thirdDimension.Add(variantOptions);
6725 }
6726 }
6727 groupCount++;
6728 }
6729
6730 int rowCount = 0;
6731 int columnCount = 0;
6732
6733 <script>
6734 var variantsCollection = [];
6735 </script>
6736
6737 <table class="table table--compact js-variants-matrix dw-mod" id="VariantMatrixTable_@settings.ProductId">
6738 @if (groupCount == 1)
6739 {
6740 <tbody>
6741 @foreach (VariantOption firstVariantOption in firstDimension)
6742 {
6743 var variantId = firstVariantOption.Id;
6744 <tr>
6745 <td class="u-bold">
6746 @firstVariantOption.Name
6747 </td>
6748 <td>
6749 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount)
6750 </td>
6751 </tr>
6752 productLoopCounter++;
6753 }
6754
6755 <tr>
6756 <td> </td>
6757 <td>
6758 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div>
6759 </td>
6760 </tr>
6761 </tbody>
6762 }
6763 @if (groupCount == 2)
6764 {
6765 <thead>
6766 <tr>
6767 <td> </td>
6768 @foreach (VariantOption variant in secondDimension)
6769 {
6770 <td>@variant.Name</td>
6771 }
6772 </tr>
6773 </thead>
6774 <tbody>
6775 @foreach (VariantOption firstVariantOption in firstDimension)
6776 {
6777 string variantId = "";
6778 columnCount = 0;
6779
6780 <tr>
6781 <td class="u-min-w120px">@firstVariantOption.Name</td>
6782
6783 @foreach (VariantOption secondVariantOption in secondDimension)
6784 {
6785 variantId = firstVariantOption.Id + "." + secondVariantOption.Id;
6786 <td>
6787 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount)
6788 </td>
6789
6790 columnCount++;
6791
6792 productLoopCounter++;
6793 }
6794
6795 <td>
6796 <div class="qty-field js-total-qty-row-@rowCount dw-mod">0</div>
6797 </td>
6798 </tr>
6799
6800 rowCount++;
6801 }
6802
6803 @{
6804 columnCount = 0;
6805 }
6806
6807 <tr>
6808 <td> </td>
6809 @foreach (VariantOption secondVariantOption in secondDimension)
6810 {
6811 <td>
6812 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div>
6813 </td>
6814
6815 columnCount++;
6816 }
6817 <td> </td>
6818 </tr>
6819 </tbody>
6820 }
6821 @if (groupCount == 3)
6822 {
6823 <thead>
6824 <tr>
6825 <td> </td>
6826 @foreach (VariantOption thirdVariantOption in thirdDimension)
6827 {
6828 <td>@thirdVariantOption.Name</td>
6829 }
6830 </tr>
6831 </thead>
6832 <tbody>
6833 @foreach (VariantOption firstVariantOption in firstDimension)
6834 {
6835 int colspan = (thirdDimension.Count + 1);
6836
6837 <tr>
6838 <td colspan="@colspan" class="u-color-light-gray--bg u-bold">@firstVariantOption.Name</td>
6839 </tr>
6840
6841 foreach (VariantOption secondVariantOption in secondDimension)
6842 {
6843 string variantId = "";
6844 columnCount = 0;
6845
6846 <tr>
6847 <td class="u-min-w120px">@secondVariantOption.Name</td>
6848
6849 @foreach (VariantOption thirdVariantOption in thirdDimension)
6850 {
6851 variantId = firstVariantOption.Id + "." + secondVariantOption.Id + "." + thirdVariantOption.Id;
6852
6853 <td>
6854 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount)
6855 </td>
6856
6857 columnCount++;
6858 productLoopCounter++;
6859 }
6860
6861 <td>
6862 <div class="qty-field js-total-qty-row-@rowCount dw-mod">0</div>
6863 </td>
6864 </tr>
6865 rowCount++;
6866 }
6867 }
6868
6869 @{
6870 columnCount = 0;
6871 }
6872
6873 <tr>
6874 <td> </td>
6875 @foreach (VariantOption thirdVariantOption in thirdDimension)
6876 {
6877 <td>
6878 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div>
6879 </td>
6880
6881 columnCount++;
6882 }
6883 <td> </td>
6884 </tr>
6885 </tbody>
6886 }
6887 </table>
6888
6889 <script>
6890 document.addEventListener("DOMContentLoaded", function (event) {
6891 MatrixUpdateQuantity("@settings.ProductId");
6892 });
6893
6894 MatrixUpdateQuantity = function (productId) {
6895 var currentMatrix = document.getElementById("VariantMatrixTable_" + productId);
6896 var allQtyFields = currentMatrix.getElementsByClassName("js-qty");
6897
6898 var qtyRowArr = [];
6899 var qtyColumnArr = [];
6900
6901 var totalQty = 0;
6902
6903 for (var i = 0; i < allQtyFields.length; i++) {
6904 qtyRowArr[allQtyFields[i].getAttribute("data-qty-row-group")] = 0;
6905 qtyColumnArr[allQtyFields[i].getAttribute("data-qty-column-group")] = 0;
6906 }
6907
6908 for (var i = 0; i < allQtyFields.length; i++) {
6909 qtyRowArr[allQtyFields[i].getAttribute("data-qty-row-group")] += parseFloat(allQtyFields[i].value);
6910 qtyColumnArr[allQtyFields[i].getAttribute("data-qty-column-group")] += parseFloat(allQtyFields[i].value);
6911 totalQty += parseFloat(allQtyFields[i].value);
6912 }
6913
6914 //Update row counters
6915 for (var i = 0; i < qtyRowArr.length; i++) {
6916 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-row-" + i)[0];
6917
6918 if (qtyRowArr[i] != undefined && qtyCounter != null) {
6919 var currentCount = qtyCounter.innerHTML;
6920 qtyCounter.innerHTML = qtyRowArr[i];
6921
6922 if (currentCount != qtyCounter.innerHTML) {
6923 qtyCounter.classList.add("qty-field--active");
6924 }
6925 }
6926
6927 }
6928
6929 //Update column counters
6930 for (var i = 0; i < qtyColumnArr.length; i++) {
6931 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-column-" + i)[0];
6932
6933 if (qtyColumnArr[i] != undefined && qtyCounter != null) {
6934 var currentCount = qtyCounter.innerHTML;
6935 qtyCounter.innerHTML = qtyColumnArr[i];
6936
6937 if (currentCount != qtyCounter.innerHTML) {
6938 qtyCounter.classList.add("qty-field--active");
6939 }
6940 }
6941 }
6942
6943 if (document.getElementById("TotalQtyCount_" + productId)) {
6944 document.getElementById("TotalQtyCount_" + productId).innerHTML = totalQty;
6945 }
6946
6947 //Clean up animations
6948 setTimeout(function () {
6949 for (var i = 0; i < qtyRowArr.length; i++) {
6950 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-row-" + i)[0];
6951 if (qtyCounter != null) {
6952 qtyCounter.classList.remove("qty-field--active");
6953 }
6954 }
6955 for (var i = 0; i < qtyColumnArr.length; i++) {
6956 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-column-" + i)[0];
6957 if (qtyCounter != null) {
6958 qtyCounter.classList.remove("qty-field--active");
6959 }
6960 }
6961 }, 1000);
6962 }
6963 </script>
6964 }
6965 }
6966
6967 @helper RenderVariantMatrixQuantityField(string variantId, VariantMatrix settings, int productLoopCounter, int rowCount, int columnCount)
6968 {
6969 string loopCount = productLoopCounter.ToString();
6970
6971 bool combinationFound = false;
6972 double stock = 0;
6973 double quantityValue = 0;
6974 string note = "";
6975
6976 VariantProduct variantProduct = null;
6977
6978 if (settings.GetVariantProducts().TryGetValue(variantId, out variantProduct))
6979 {
6980 stock = variantProduct.Stock;
6981 quantityValue = variantProduct.Quantity;
6982 combinationFound = true;
6983 }
6984
6985 if (combinationFound)
6986 {
6987 <input type="hidden" name="ProductLoopCounter@(loopCount)" value="@loopCount" />
6988 <input type="hidden" name="ProductID@(loopCount)" value="@settings.ProductId" />
6989 <input type="hidden" name="VariantID@(loopCount)" value="@variantId" />
6990 <input type="hidden" name="CurrentNote@(loopCount)" id="CurrentNote_@(settings.ProductId)_@variantId" value="@note" />
6991 <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">
6992
6993 if (stock != 0)
6994 {
6995 <small>@Translate("Stock") @stock</small>
6996 }
6997
6998 <script>
6999 var variants = '{ "ProductId" :' + '"@settings.ProductId"' + ', "VariantId": ' + '"@variantId"' +'}';
7000 variantsCollection.push(variants);
7001 document.getElementById("Quantity_@(settings.ProductId)_@variantId").closest(".js-variants-matrix").setAttribute("data-variants-collection", "[" + variantsCollection + "]" );
7002 </script>
7003 }
7004 else
7005 {
7006 <div class="use-btn-height" style="background-color: #a8a8a8"></div>
7007 }
7008 }
7009 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce
7010
7011 @* Component *@
7012
7013 @helper RenderAddToCart(AddToCart settings)
7014 {
7015 //set Id for quantity selector to get it's value from button
7016 if (settings.QuantitySelector != null)
7017 {
7018 if (string.IsNullOrEmpty(settings.QuantitySelector.Id))
7019 {
7020 settings.QuantitySelector.Id = Guid.NewGuid().ToString("N");
7021 }
7022
7023 settings.AddButton.QuantitySelectorId = settings.QuantitySelector.Id;
7024
7025 if (settings.Disabled)
7026 {
7027 settings.QuantitySelector.Disabled = true;
7028 }
7029
7030 if (string.IsNullOrEmpty(settings.QuantitySelector.Name))
7031 {
7032 settings.QuantitySelector.Name = settings.QuantitySelector.Id;
7033 }
7034 }
7035
7036 if (settings.Disabled)
7037 {
7038 settings.AddButton.Disabled = true;
7039 }
7040
7041 settings.AddButton.CssClass += " btn--condensed";
7042
7043 //unitsSelector
7044 if (settings.UnitSelector != null)
7045 {
7046 if (settings.Disabled)
7047 {
7048 settings.QuantitySelector.Disabled = true;
7049 }
7050 }
7051
7052 <div class="buttons-collection @settings.WrapperCssClass" @ComponentMethods.AddAttributes(settings.ExtraAttributes)>
7053 @if (settings.UnitSelector != null)
7054 {
7055 @Render(settings.UnitSelector)
7056 }
7057 @if (settings.QuantitySelector != null)
7058 {
7059 @Render(settings.QuantitySelector)
7060 }
7061 @Render(settings.AddButton)
7062 </div>
7063 }
7064 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce
7065
7066 @* Component *@
7067
7068 @helper RenderAddToCartButton(AddToCartButton settings)
7069 {
7070 if (!settings.HideTitle)
7071 {
7072 if (string.IsNullOrEmpty(settings.Title))
7073 {
7074 if (settings.BuyForPoints)
7075 {
7076 settings.Title = Translate("Buy with points");
7077 }
7078 else
7079 {
7080 settings.Title = Translate("Add to cart");
7081 }
7082 }
7083 }
7084 else
7085 {
7086 settings.Title = "";
7087 }
7088
7089 if (settings.Icon == null)
7090 {
7091 settings.Icon = new Icon();
7092 settings.Icon.LabelPosition = Dynamicweb.Rapido.Blocks.Components.General.IconLabelPosition.After;
7093 }
7094
7095 if (string.IsNullOrEmpty(settings.Icon.Name))
7096 {
7097 settings.Icon.Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue;
7098 }
7099
7100 settings.OnClick = "Cart.AddToCart(event, { " +
7101 "id: '" + settings.ProductId + "'," +
7102 (!string.IsNullOrEmpty(settings.VariantId) ? "variantId: '" + settings.VariantId + "'," : "") +
7103 (!string.IsNullOrEmpty(settings.UnitId) ? "unitId: '" + settings.UnitId + "'," : "") +
7104 (settings.BuyForPoints ? "buyForPoints: true," : "") +
7105 (!string.IsNullOrEmpty(settings.ProductInfo) ? "productInfo: " + settings.ProductInfo + "," : "") +
7106 "quantity: " + (string.IsNullOrEmpty(settings.QuantitySelectorId) ? "1" : "parseFloat(document.getElementById('" + settings.QuantitySelectorId + "').value)") +
7107 "});" + settings.OnClick;
7108
7109 @RenderButton(settings)
7110 }
7111 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce
7112
7113 @* Component *@
7114
7115 @helper RenderUnitSelector(UnitSelector settings)
7116 {
7117 var id = settings.Id;
7118 var disabledClass = settings.Disabled ? "disabled" : "";
7119
7120 <input type="checkbox" id="@id" class="dropdown-trigger" />
7121 <div class="dropdown unit-selector @settings.CssClass @disabledClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)>
7122 <label class="dropdown__header dropdown__btn dropdown__btn--unit-selector dw-mod" for="@id">@settings.SelectedOption</label>
7123 <div class="dropdown__content dw-mod">
7124 @settings.OptionsContent
7125 </div>
7126 <label class="dropdown-trigger-off" for="@id"></label>
7127 </div>
7128 }
7129 @using System.Reflection
7130 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce
7131
7132 @* Component *@
7133
7134 @helper RenderQuantitySelector(QuantitySelector settings)
7135 {
7136 var attributes = new Dictionary<string, string>();
7137
7138 /*base settings*/
7139 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); }
7140 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); }
7141 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); }
7142 if (settings.Disabled) { attributes.Add("disabled", "true"); }
7143 if (settings.Required) { attributes.Add("required", "true"); }
7144 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); }
7145 /*end*/
7146
7147 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); }
7148 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); }
7149 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); }
7150 if (settings.ReadOnly) { attributes.Add("readonly", "true"); }
7151 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); }
7152 if (settings.Min == null) { settings.Min = 1; }
7153 attributes.Add("min", settings.Min.ToString());
7154 if (settings.Step != null && !string.IsNullOrEmpty(settings.Step.ToString())) { attributes.Add("step", settings.Step.ToString()); }
7155 if (settings.Value == null) { settings.Value = 1; }
7156 attributes.Add("value", settings.Value.ToString());
7157 attributes.Add("type", "number");
7158
7159 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value);
7160
7161 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" />
7162 }
7163 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
7164
7165 @using System
7166 @using System.Web
7167 @using System.Collections.Generic
7168 @using Dynamicweb.Rapido.Blocks.Extensibility
7169 @using Dynamicweb.Rapido.Blocks
7170
7171 @{
7172 BlocksPage bottomSnippetsBlocksPage = BlocksPage.GetBlockPage("Master");
7173
7174 Block primaryBottomSnippets = new Block()
7175 {
7176 Id = "MasterJavascriptInitializers",
7177 SortId = 100,
7178 Template = RenderPrimaryBottomSnippets()
7179 };
7180 bottomSnippetsBlocksPage.Add(MasterBlockId.MasterReferences, primaryBottomSnippets);
7181 }
7182
7183 @helper RenderPrimaryBottomSnippets() {
7184 bool isWireframeMode = Model.Area.Item.GetItem("Settings").GetBoolean("WireframeMode");
7185 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID"));
7186
7187 if (isWireframeMode)
7188 {
7189 <script>
7190 Wireframe.Init(true);
7191 </script>
7192 }
7193
7194
7195 if (useGoogleTagManager)
7196 {
7197 <script>
7198 document.addEventListener('addToCart', function(event) {
7199 var googleImpression = event.detail.productInfo.googleImpression;
7200 dataLayer.push({
7201 'event': 'addToCart',
7202 'ecommerce': {
7203 'currencyCode': '@Dynamicweb.Ecommerce.Services.Currencies.GetDefaultCurrency().Code',
7204 'add': {
7205 'products': [{
7206 'name': googleImpression.name,
7207 'id': googleImpression.id,
7208 'price': googleImpression.price,
7209 'brand': googleImpression.brand,
7210 'category': googleImpression.category,
7211 'variant': googleImpression.variant,
7212 'quantity': event.detail.quantity
7213 }]
7214 }
7215 }
7216 });
7217 });
7218 </script>
7219 }
7220
7221 //if digitalwarehouse
7222 if (Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("ShowDownloadCart"))
7223 {
7224 string cartContextId = Converter.ToString(HttpContext.Current.Application["DownloadCartContext"]);
7225
7226 if (string.IsNullOrEmpty(cartContextId)) {
7227 var moduleProps = Dynamicweb.Modules.Properties.GetParagraphModuleSettings(GetPageIdByNavigationTag("DownloadCart"), "eCom_CartV2");
7228 var cartSettings = new Dynamicweb.Ecommerce.Cart.ModuleSettings(moduleProps);
7229 cartContextId = cartSettings.OrderContextID;
7230 HttpContext.Current.Application["DownloadCartContext"] = cartContextId;
7231 }
7232
7233 <script>
7234 let downloadCart = new DownloadCart({
7235 cartPageId: @GetPageIdByNavigationTag("MiniCartFeed"),
7236 contextId: "@cartContextId",
7237 addButtonText: "@Translate("Add")",
7238 removeButtonText: "@Translate("Remove")"
7239 });
7240 </script>
7241 }
7242
7243 <!--$$Javascripts-->
7244 }
7245 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
7246
7247 @using System
7248 @using System.Web
7249 @using System.Collections.Generic
7250 @using Dynamicweb.Rapido.Blocks
7251
7252 @{
7253 BlocksPage masterCustomBlocksPage = BlocksPage.GetBlockPage("Master");
7254
7255 }
7256
7257
7258 @functions {
7259 public class ManifestIcon
7260 {
7261 public string src { get; set; }
7262 public string type { get; set; }
7263 public string sizes { get; set; }
7264 }
7265
7266 public class Manifest
7267 {
7268 public string name { get; set; }
7269 public string short_name { get; set; }
7270 public string start_url { get; set; }
7271 public string display { get; set; }
7272 public string background_color { get; set; }
7273 public string theme_color { get; set; }
7274 public List<ManifestIcon> icons { get; set; }
7275 }
7276 }
7277
7278 <!DOCTYPE html>
7279
7280 <html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName">
7281
7282
7283
7284 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@
7285 @RenderBlockList(masterPage.BlocksRoot.BlocksList)
7286
7287
7288
7289 @helper RenderMasterHead() {
7290 List<Block> subBlocks = this.masterPage.GetBlockListById("Head").OrderBy(item => item.SortId).ToList();
7291
7292 <head>
7293 <!-- Rapido version 3.2 -->
7294
7295 @RenderBlockList(subBlocks)
7296 </head>
7297 }
7298
7299 @helper RenderMasterMetadata() {
7300 var swatches = new Dynamicweb.Content.Items.ColorSwatchService();
7301 var brandColors = swatches.GetColorSwatch(1);
7302 string brandColorOne = brandColors.Palette["BrandColor1"];
7303
7304 if (!String.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("AppName")) && Model.Area.Item.GetItem("Settings").GetFile("AppIcon") != null) {
7305 Manifest manifest = new Manifest
7306 {
7307 name = Model.Area.Item.GetItem("Settings").GetString("AppName"),
7308 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"),
7309 start_url = "/",
7310 display = "standalone",
7311 background_color = Model.Area.Item.GetItem("Settings").GetString("AppBackgroundColor"),
7312 theme_color = Model.Area.Item.GetItem("Settings").GetString("AppThemeColor")
7313 };
7314
7315 manifest.icons = new List<ManifestIcon> {
7316 new ManifestIcon {
7317 src = "/Admin/Public/GetImage.ashx?width=192&height=192&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded,
7318 sizes = "192x192",
7319 type = "image/png"
7320 },
7321 new ManifestIcon {
7322 src = "/Admin/Public/GetImage.ashx?width=512&height=512&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded,
7323 sizes = "512x512",
7324 type = "image/png"
7325 },
7326 new ManifestIcon {
7327 src = "/Admin/Public/GetImage.ashx?width=1024&height=1024&crop=5&image=" + Model.Area.Item.GetItem("Settings").GetFile("AppIcon").PathUrlEncoded,
7328 sizes = "1024x1024",
7329 type = "image/png"
7330 }
7331 };
7332
7333 string manifestFilePath = HttpContext.Current.Request.MapPath("/Files/Templates/Designs/Rapido/manifest.json");
7334 string manifestJSON = Newtonsoft.Json.JsonConvert.SerializeObject(manifest);
7335 string currentManifest = File.ReadAllText(manifestFilePath);
7336
7337 if (manifestJSON != currentManifest)
7338 {
7339 File.WriteAllText(manifestFilePath, manifestJSON);
7340 }
7341 }
7342
7343 <meta charset="utf-8" />
7344 <title>@Model.Title</title>
7345 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7346 <meta name="robots" content="index, follow">
7347 <meta name="theme-color" content="@brandColorOne" />
7348
7349 if (!Model.MetaTags.Contains("og:image")) {
7350 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")));
7351 }
7352
7353 if (!Model.MetaTags.Contains("og:description")) {
7354 Pageview.Meta.AddTag("og:description", Model.Description);
7355 }
7356
7357 Pageview.Meta.AddTag("og:title", Model.Title);
7358 Pageview.Meta.AddTag("og:site_name", Model.Name);
7359 Pageview.Meta.AddTag("og:url", HttpContext.Current.Request.Url.ToString());
7360 Pageview.Meta.AddTag("og:type", "Website");
7361 Pageview.Meta.AddTag("fb:page_id", Model.ID.ToString());
7362
7363 @Model.MetaTags
7364 }
7365
7366 @helper RenderMasterCss() {
7367 var fonts = new string[] {
7368 getFontFamily("Layout", "HeaderFont"),
7369 getFontFamily("Layout", "SubheaderFont"),
7370 getFontFamily("Layout", "TertiaryHeaderFont"),
7371 getFontFamily("Layout", "BodyText"),
7372 getFontFamily("Layout", "Header", "ToolsFont"),
7373 getFontFamily("Layout", "Header", "NavigationFont"),
7374 getFontFamily("Layout", "MobileNavigation", "Font"),
7375 getFontFamily("ProductList", "Facets", "HeaderFont"),
7376 getFontFamily("ProductPage", "PriceFontDesign"),
7377 getFontFamily("Ecommerce", "SaleSticker", "Font"),
7378 getFontFamily("Ecommerce", "NewSticker", "Font"),
7379 getFontFamily("Ecommerce", "CustomSticker", "Font")
7380 };
7381
7382 string autoCssLink = "/Files/Templates/Designs/Rapido/css/rapido/rapido_" + Model.Area.ID.ToString() + ".min.css?ticks=" + Model.Area.UpdatedDate.Ticks;
7383 string favicon = Model.Area.Item.GetItem("Layout").GetFile("LogoFavicon") != null ? Model.Area.Item.GetItem("Layout").GetFile("LogoFavicon").Path : "/Files/Images/favicon.png";
7384 bool useFontAwesomePro = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetBoolean("UseFontAwesomePro");
7385 string fontAwesomeCssLink = "/Files/Templates/Designs/Rapido/css/fonts/FontAwesomeFree/css/fontawesome-all.min.css";
7386 if (useFontAwesomePro)
7387 {
7388 fontAwesomeCssLink = "/Files/Templates/Designs/Rapido/css/fonts/FontAwesomePro/css/fontawesome-all.min.css";
7389 }
7390
7391 //Favicon
7392 <link href="@favicon" rel="icon" type="image/png">
7393
7394 //Base (Default, wireframe) styles
7395 <link rel="stylesheet" href="/Files/Templates/Designs/Rapido/css/base/base.min.css" type="text/css">
7396
7397 //Rapido Css from Website Settings
7398 <link rel="stylesheet" id="rapidoCss" href="@autoCssLink" type="text/css">
7399
7400 //Ignite Css (Custom site specific styles)
7401 <link rel="stylesheet" id="igniteCss" type="text/css" href="/Files/Templates/Designs/Rapido/css/ignite/ignite.min.css">
7402
7403 //Font awesome
7404 <link rel="stylesheet" href="@fontAwesomeCssLink" type="text/css">
7405
7406 //Flag icon
7407 <link rel="stylesheet" href="/Files/Templates/Designs/Rapido/css/fonts/flag-icon.min.css" type="text/css">
7408
7409 //Google fonts
7410 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)));
7411
7412 <link href="https://fonts.googleapis.com/css?family=@family" rel="stylesheet">
7413
7414 PushPromise(favicon);
7415 PushPromise(fontAwesomeCssLink);
7416 PushPromise("/Files/Templates/Designs/Rapido/css/base/base.min.css");
7417 PushPromise(autoCssLink);
7418 PushPromise("/Files/Templates/Designs/Rapido/css/ignite/ignite.min.css");
7419 PushPromise("/Files/Images/placeholder.gif");
7420 PushPromise("/Files/Templates/Designs/Rapido/css/fonts/flag-icon.min.css");
7421 }
7422
7423 @helper RenderMasterManifest() {
7424 if (!String.IsNullOrEmpty(Model.Area.Item.GetItem("Settings").GetString("AppName")))
7425 {
7426 <link rel="manifest" href="/Files/Templates/Designs/Rapido/manifest.json">
7427 PushPromise("/Files/Templates/Designs/Rapido/manifest.json");
7428 }
7429 }
7430
7431 @helper RenderMasterBody() {
7432 List<Block> subBlocks = this.masterPage.GetBlockListById("Body").OrderBy(item => item.SortId).ToList();
7433 string designLayout = Model.PropertyItem.GetItem("CustomSettings") != null ? Model.PropertyItem.GetItem("CustomSettings").GetString("DesignLayout") != null ? Model.PropertyItem.GetItem("CustomSettings").GetList("DesignLayout").SelectedValue : "" : "";
7434 if (!String.IsNullOrEmpty(designLayout)) {
7435 designLayout = "class=\"" + designLayout + "\"";
7436 }
7437
7438 <body @designLayout>
7439 @RenderBlockList(subBlocks)
7440 </body>
7441 }
7442
7443 @helper RenderMasterHeader()
7444 {
7445 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterHeader").OrderBy(item => item.SortId).ToList();
7446 bool isNavigationStickyMenu = Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet" && Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("StickyTop");
7447 string stickyTop = isNavigationStickyMenu ? "top-container--sticky" : "";
7448
7449 <header class="top-container @stickyTop dw-mod" id="Top">
7450 @RenderBlockList(subBlocks)
7451 </header>
7452 }
7453
7454 @helper RenderMain()
7455 {
7456 List<Block> subBlocks = this.masterPage.GetBlockListById("MasterMain").OrderBy(item => item.SortId).ToList();
7457
7458 <main class="site dw-mod">
7459 @RenderBlockList(subBlocks)
7460 </main>
7461 }
7462
7463 @helper RenderPageContent()
7464 {
7465 bool isNavigationStickyMenu = Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet" && Model.Area.Item.GetItem("Layout").GetItem("Header").GetBoolean("StickyTop");
7466 string pagePos = isNavigationStickyMenu ? "js-page-pos" : "";
7467
7468 <div id="Page" class="page @pagePos">
7469 <section class="center-container content-container dw-mod" id="content">
7470
7471 @RenderSnippet("Content")
7472 </section>
7473 </div>
7474 }
7475
7476 @* Hack to support nested helpers *@
7477 @SnippetStart("Content")
7478 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
7479
7480
7481
7482 @using Dynamicweb.Rapido.Blocks.Components.General
7483 @using Dynamicweb.Rapido.Blocks
7484
7485 @functions {
7486 BlocksPage page = BlocksPage.GetBlockPage("Page");
7487 }
7488
7489 @{
7490 bool isProductPage = HttpContext.Current.Request.QueryString.Get("ProductID") != null;
7491 string backgroundColorClass = Model.PropertyItem.GetList("BackgroundColor") != null && !isProductPage ? "u-" + Model.PropertyItem.GetList("BackgroundColor").SelectedValue + "--bg" : "";
7492 string navigationMarkup = "";
7493
7494 Block pageContainer = new Block
7495 {
7496 Id = "PageContainer",
7497 SortId = 10,
7498 BlocksList = new List<Block> {
7499 new Block {
7500 Id = "PageRow",
7501 SortId = 20,
7502 Design = new Design {
7503 RenderType = RenderType.Row
7504 }
7505 }
7506 }
7507 };
7508 page.Add(pageContainer);
7509
7510 if (Model.PropertyItem.GetList("ShowBreadcrumb") != null && Model.PropertyItem.GetList("ShowBreadcrumb").SelectedValue == "True")
7511 {
7512 Block breadcrumbNavigation = new Block
7513 {
7514 Id = "PageBreadcrumbNavigation",
7515 SortId = 10,
7516 Component = new BreadcrumbNavigation { Id = "breadcrumb", Template = "Breadcrumb.xslt", SitemapMode = true }
7517 };
7518 page.Add("PageContainer", breadcrumbNavigation);
7519 }
7520
7521 if (Model.PropertyItem.GetList("LeftMenu") != null && Model.PropertyItem.GetList("LeftMenu").SelectedValue == "True" && (Pageview.Page.NavigationSettings == null || !Pageview.Page.NavigationSettings.UseEcomGroups))
7522 {
7523 navigationMarkup = RenderNavigation(new
7524 {
7525 id = "leftnav",
7526 cssclass = "dwnavigation",
7527 startLevel = 2,
7528 expandmode = "all",
7529 endlevel = 5,
7530 template = "LeftNavigation.xslt"
7531 });
7532
7533 if (!string.IsNullOrEmpty(navigationMarkup))
7534 {
7535 Block leftNavigation = new Block
7536 {
7537 Id = "PageLeftNavigation",
7538 SortId = 10,
7539 Component = new LeftNavigation { Id = "leftnav", CssClass = "dwnavigation", StartLevel = 2, EndLevel = 5, Expandmode = "all", Template = "LeftNavigation.xslt" },
7540 Design = new Design
7541 {
7542 RenderType = RenderType.Column,
7543 Size = "3"
7544 }
7545 };
7546 page.Add("PageRow", leftNavigation);
7547 }
7548 }
7549
7550 string contentColumnSize = !string.IsNullOrEmpty(navigationMarkup) ? "9" : "12";
7551
7552 Block pageContent = new Block
7553 {
7554 Id = "PageContent",
7555 SortId = 20,
7556 Design = new Design
7557 {
7558 RenderType = RenderType.Column,
7559 Size = contentColumnSize,
7560 CssClass = "grid__col--bleed"
7561 },
7562 BlocksList = new List<Block> {
7563 new Block {
7564 Id = "PageContentRow",
7565 SortId = 10,
7566 Component = new Text { Content = @Model.Placeholder("dwcontent", "content", "default:true;sort:1") },
7567 Design = new Design {
7568 RenderType = RenderType.Row
7569 }
7570 }
7571 }
7572 };
7573 page.Add("PageRow", pageContent);
7574 }
7575
7576 @using System
7577 @using System.Web
7578 @using System.Collections.Generic
7579 @using Dynamicweb.Rapido.Blocks
7580
7581 @{
7582 BlocksPage pageCustomBlocksPage = BlocksPage.GetBlockPage("Page");
7583
7584 }
7585
7586 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@
7587 @RenderBlockList(page.BlocksRoot.BlocksList)
7588
7589
7590 @* Very small hack to make it cleanly, and easily possible to change the background color on a single page *@
7591 @if (backgroundColorClass != "")
7592 {
7593 <script>
7594 document.getElementById("Page").classList.add("@backgroundColorClass");
7595 </script>
7596 }
7597 @SnippetEnd("Content")
7598 <!-- Global site tag (gtag.js) - Google Analytics -->
7599 <script async src="https://www.googletagmanager.com/gtag/js?id=UA-127410146-1"></script>
7600 <script>
7601 window.dataLayer = window.dataLayer || [];
7602 function gtag(){dataLayer.push(arguments);}
7603 gtag('js', new Date());
7604
7605 gtag('config', 'UA-127410146-1');
7606 </script>
7607 </html>
7608
7609