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