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