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