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