Vegghengt vifter

Kjøkken hetten – uunnværlig i det moderne kjøkkenet

Hvis du vil unngå lukt fra mados på kjøkkenet ditt og i andre rom i hjemmet -

Kan du med stor fordel velge at installere en kjøkkenvifte. Kjøkkenvifte gjør det lett for deg å koke, steke og brassere maten din uten at hele huset kommer til at lukte av mat. 
Selv om du kan åpne vinduet og lufte ut, vil det ikke være en holdbar løsning. For det første vil det betyde et stort varmetap i de kalde vinter måneder. For det andet vil du ikke kunne få alle partikler fra matlagningen ut med bare utluftning.
Til dette formål har du bruk for en effektiv kjøkkenvifte, som kan fange fett og sot som ellers ville avleire sig på alle flater i kjøkkenet. En kjøkkenvifte med den rette kapasitet vil kunne holde boligen luktfri, uansett hvor flittig du end måtte kokkerere.

 

 

Hvilken type hette bør jeg velge?

Tidligere var en avtrekkshette en stor og klønete enhet som ble plassert rett over ovnen i hele dens dybde. Denne plasseringen er spesielt upraktisk i forhold til både matlaging og rengjøring, og kan være til sjenanse for personer over en viss høyde.

De gammeldagse hettene var ikke lenger effektive, og bråket samtidig utrolig mye. Det har imidlertid skjedd mye på denne fronten siden den gang. En moderne avtrekkshette av høy kvalitet vil kunne fange opp mat- og sotpartikler fra matlagingen på en mye mer effektiv måte, samtidig som den er tilnærmet lydløs.

Avtrekkshette med avtrekk eller kullfilter 

En nyere hette trenger ikke kobles til avtrekk, men kan fungere med et effektivt kullfilter som samler opp fett og mat og er lett å skifte. Faktisk vil en vegghengt hette med filter kunne rense luften like effektivt som en hette koblet til en avtrekkskanal, så lenge filteret skiftes en til to ganger i året.

Du bør bestemme deg for om du ønsker en hette med filter, eller om du ønsker å kunne koble din hette til hjemmets avtrekkssystem. Det vil fremgå av modellens produktblad om hetten fjerner mat ved hjelp av filter eller avtrekk, eller eventuelt har mulighet for begge deler.

Error executing template "Designs/Rapido/ContentPage/Paragraph/CardParagraph.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_776095055ad24d97af02f9a60cb157b4.<RenderTheContent>b__46_0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\S_DW_Thermex\Files\Templates\Designs\Rapido\ContentPage\Paragraph\CardParagraph.cshtml:line 2215
   at CompiledRazorTemplates.Dynamic.RazorEngine_776095055ad24d97af02f9a60cb157b4.Execute() in D:\Dynamicweb.net\Solutions\S_DW_Thermex\Files\Templates\Designs\Rapido\ContentPage\Paragraph\CardParagraph.cshtml:line 2152
   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.ParagraphViewModel> 2 @using Dynamicweb.Frontend 3 @using Dynamicweb.Content.Items 4 @using Dynamicweb 5 @using Dynamicweb.Rapido.Blocks.Components 6 @using Dynamicweb.Rapido.Blocks.Components.General 7 8 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 9 @using Dynamicweb.Frontend 10 11 @* Include the components *@ 12 @using System.Text.RegularExpressions 13 @using System.Collections.Generic 14 @using System.Reflection 15 @using System.Web 16 @using System.Web.UI.HtmlControls 17 @using Dynamicweb.Rapido.Blocks.Components 18 @using Dynamicweb.Rapido.Blocks.Components.Articles 19 @using Dynamicweb.Rapido.Blocks.Components.Documentation 20 @using Dynamicweb.Rapido.Blocks 21 22 23 @*--- START: Base block renderers ---*@ 24 25 @helper RenderBlockList(List<Block> blocks) 26 { 27 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 28 blocks = blocks.OrderBy(item => item.SortId).ToList(); 29 30 foreach (Block item in blocks) 31 { 32 if (debug) { 33 <!-- Block START: @item.Id --> 34 } 35 36 if (item.Design == null) 37 { 38 @RenderBlock(item) 39 } 40 else if (item.Design.RenderType == RenderType.None) { 41 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 42 43 <div class="@cssClass dw-mod"> 44 @RenderBlock(item) 45 </div> 46 } 47 else if (item.Design.RenderType != RenderType.Hide) 48 { 49 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 50 51 if (!item.SkipRenderBlocksList) { 52 if (item.Design.RenderType == RenderType.Row) 53 { 54 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 55 @RenderBlock(item) 56 </div> 57 } 58 59 if (item.Design.RenderType == RenderType.Column) 60 { 61 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 62 string size = item.Design.Size ?? "12"; 63 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 64 65 <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"> 66 @RenderBlock(item) 67 </div> 68 } 69 70 if (item.Design.RenderType == RenderType.Table) 71 { 72 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 73 @RenderBlock(item) 74 </table> 75 } 76 77 if (item.Design.RenderType == RenderType.TableRow) 78 { 79 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 80 @RenderBlock(item) 81 </tr> 82 } 83 84 if (item.Design.RenderType == RenderType.TableColumn) 85 { 86 <td class="@cssClass dw-mod" id="Block__@item.Id"> 87 @RenderBlock(item) 88 </td> 89 } 90 91 if (item.Design.RenderType == RenderType.CardHeader) 92 { 93 <div class="card-header @cssClass dw-mod"> 94 @RenderBlock(item) 95 </div> 96 } 97 98 if (item.Design.RenderType == RenderType.CardBody) 99 { 100 <div class="card @cssClass dw-mod"> 101 @RenderBlock(item) 102 </div> 103 } 104 105 if (item.Design.RenderType == RenderType.CardFooter) 106 { 107 <div class="card-footer @cssClass dw-mod"> 108 @RenderBlock(item) 109 </div> 110 } 111 } 112 else 113 { 114 @RenderBlock(item) 115 } 116 } 117 118 if (debug) { 119 <!-- Block END: @item.Id --> 120 } 121 } 122 } 123 124 @helper RenderBlock(Block item) 125 { 126 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 127 128 if (item.Template != null) 129 { 130 @BlocksPage.RenderTemplate(item.Template) 131 } 132 133 if (item.Component != null) 134 { 135 string customSufix = "Custom"; 136 string methodName = item.Component.HelperName; 137 138 ComponentBase[] methodParameters = new ComponentBase[1]; 139 methodParameters[0] = item.Component; 140 Type methodType = this.GetType(); 141 142 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 143 144 try { 145 if (debug) { 146 <!-- Component: @methodName.Replace("Render", "") --> 147 } 148 if(customMethod != null) { 149 @customMethod.Invoke(this, methodParameters).ToString(); 150 } else { 151 MethodInfo generalMethod = methodType.GetMethod(methodName); 152 @generalMethod.Invoke(this, methodParameters).ToString(); 153 } 154 } catch { 155 try { 156 MethodInfo generalMethod = methodType.GetMethod(methodName); 157 @generalMethod.Invoke(this, methodParameters).ToString(); 158 } catch(Exception ex) { 159 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 160 } 161 } 162 } 163 164 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 165 { 166 @RenderBlockList(item.BlocksList) 167 } 168 } 169 170 @*--- END: Base block renderers ---*@ 171 172 @using Dynamicweb.Rapido.Blocks.Components 173 @using Dynamicweb.Rapido.Blocks.Components.General 174 @using Dynamicweb.Rapido.Blocks 175 @using System.IO 176 177 @* Required *@ 178 @using Dynamicweb.Rapido.Blocks.Components 179 @using Dynamicweb.Rapido.Blocks.Components.General 180 @using Dynamicweb.Rapido.Blocks 181 182 183 @helper Render(ComponentBase component) 184 { 185 if (component != null) 186 { 187 @component.Render(this) 188 } 189 } 190 191 @* Components *@ 192 @using System.Reflection 193 @using Dynamicweb.Rapido.Blocks.Components.General 194 195 196 @* Component *@ 197 198 @helper RenderIcon(Icon settings) 199 { 200 if (settings != null) 201 { 202 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 203 204 if (settings.Name != null) 205 { 206 if (string.IsNullOrEmpty(settings.Label)) 207 { 208 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 209 } 210 else 211 { 212 if (settings.LabelPosition == IconLabelPosition.Before) 213 { 214 <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> 215 } 216 else 217 { 218 <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> 219 } 220 } 221 } 222 else if (!string.IsNullOrEmpty(settings.Label)) 223 { 224 @settings.Label 225 } 226 } 227 } 228 @using System.Reflection 229 @using Dynamicweb.Rapido.Blocks.Components.General 230 @using Dynamicweb.Rapido.Blocks.Components 231 @using Dynamicweb.Core 232 233 @* Component *@ 234 235 @helper RenderButton(Button settings) 236 { 237 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 238 { 239 Dictionary<string, string> attributes = new Dictionary<string, string>(); 240 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 241 if (settings.Disabled) { 242 attributes.Add("disabled", "true"); 243 classList.Add("disabled"); 244 } 245 246 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 247 { 248 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 249 @RenderConfirmDialog(settings); 250 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 251 } 252 253 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 254 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 255 if (!string.IsNullOrEmpty(settings.AltText)) 256 { 257 attributes.Add("title", settings.AltText); 258 } 259 else if (!string.IsNullOrEmpty(settings.Title)) 260 { 261 string cleanTitle = Regex.Replace(settings.Title, "<.*?>", String.Empty); 262 cleanTitle = cleanTitle.Replace("&nbsp;", " "); 263 attributes.Add("title", cleanTitle); 264 } 265 266 var onClickEvents = new List<string>(); 267 if (!string.IsNullOrEmpty(settings.OnClick)) 268 { 269 onClickEvents.Add(settings.OnClick); 270 } 271 if (!string.IsNullOrEmpty(settings.Href)) 272 { 273 onClickEvents.Add("location.href='" + settings.Href + "'"); 274 } 275 if (onClickEvents.Count > 0) 276 { 277 attributes.Add("onClick", string.Join(";", onClickEvents)); 278 } 279 280 if (settings.ButtonLayout != ButtonLayout.None) 281 { 282 classList.Add("btn"); 283 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 284 if (btnLayout == "linkclean") 285 { 286 btnLayout = "link-clean"; //fix 287 } 288 classList.Add("btn--" + btnLayout); 289 } 290 291 if (settings.Icon == null) 292 { 293 settings.Icon = new Icon(); 294 } 295 296 settings.Icon.CssClass += Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower() != "linkclean" ? " u-flex--align-center" : ""; 297 settings.Icon.Label = settings.Title; 298 299 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 300 301 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 302 } 303 } 304 305 @helper RenderConfirmDialog(Button settings) 306 { 307 Modal confirmDialog = new Modal { 308 Id = settings.Id, 309 Width = ModalWidth.Sm, 310 Heading = new Heading 311 { 312 Level = 2, 313 Title = settings.ConfirmTitle 314 }, 315 BodyText = settings.ConfirmText 316 }; 317 318 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 319 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 320 321 @Render(confirmDialog) 322 } 323 @using Dynamicweb.Rapido.Blocks.Components.General 324 @using Dynamicweb.Rapido.Blocks.Components 325 @using Dynamicweb.Core 326 327 @helper RenderDashboard(Dashboard settings) 328 { 329 var widgets = settings.GetWidgets(); 330 331 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 332 { 333 //set bg color for them 334 335 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 336 int r = Convert.ToInt16(color.R); 337 int g = Convert.ToInt16(color.G); 338 int b = Convert.ToInt16(color.B); 339 340 var count = widgets.Length; 341 var max = Math.Max(r, Math.Max(g, b)); 342 double step = 255.0 / (max * count); 343 var i = 0; 344 foreach (var widget in widgets) 345 { 346 i++; 347 348 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 349 widget.BackgroundColor = shade; 350 } 351 } 352 353 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 354 @foreach (var widget in widgets) 355 { 356 <div class="dashboard__widget"> 357 @Render(widget) 358 </div> 359 } 360 </div> 361 } 362 @using Dynamicweb.Rapido.Blocks.Components.General 363 @using Dynamicweb.Rapido.Blocks.Components 364 365 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 366 { 367 if (!string.IsNullOrEmpty(settings.Link)) 368 { 369 var backgroundStyles = ""; 370 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 371 { 372 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 373 } 374 375 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 376 <div class="u-center-middle u-color-light"> 377 @if (settings.Icon != null) 378 { 379 settings.Icon.CssClass += "widget__icon"; 380 @Render(settings.Icon) 381 } 382 <div class="widget__title">@settings.Title</div> 383 </div> 384 </a> 385 } 386 } 387 @using Dynamicweb.Rapido.Blocks.Components.General 388 @using Dynamicweb.Rapido.Blocks.Components 389 390 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 391 { 392 var backgroundStyles = ""; 393 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 394 { 395 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 396 } 397 398 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 399 <div class="u-center-middle u-color-light"> 400 @if (settings.Icon != null) 401 { 402 settings.Icon.CssClass += "widget__icon"; 403 @Render(settings.Icon) 404 } 405 <div class="widget__counter">@settings.Count</div> 406 <div class="widget__title">@settings.Title</div> 407 </div> 408 </div> 409 } 410 @using System.Reflection 411 @using Dynamicweb.Rapido.Blocks.Components.General 412 @using Dynamicweb.Rapido.Blocks.Components 413 @using Dynamicweb.Core 414 415 @* Component *@ 416 417 @helper RenderLink(Link settings) 418 { 419 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 420 { 421 Dictionary<string, string> attributes = new Dictionary<string, string>(); 422 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 423 if (settings.Disabled) 424 { 425 attributes.Add("disabled", "true"); 426 classList.Add("disabled"); 427 } 428 429 if (!string.IsNullOrEmpty(settings.AltText)) 430 { 431 attributes.Add("title", settings.AltText); 432 } 433 else if (!string.IsNullOrEmpty(settings.Title)) 434 { 435 attributes.Add("title", settings.Title); 436 } 437 438 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 439 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 440 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 441 attributes.Add("href", settings.Href); 442 443 if (settings.ButtonLayout != ButtonLayout.None) 444 { 445 classList.Add("btn"); 446 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 447 if (btnLayout == "linkclean") 448 { 449 btnLayout = "link-clean"; //fix 450 } 451 classList.Add("btn--" + btnLayout); 452 } 453 454 if (settings.Icon == null) 455 { 456 settings.Icon = new Icon(); 457 } 458 settings.Icon.Label = settings.Title; 459 460 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 461 { 462 settings.Rel = LinkRelType.Noopener; 463 } 464 if (settings.Target != LinkTargetType.None) 465 { 466 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 467 } 468 if (settings.Download) 469 { 470 attributes.Add("download", "true"); 471 } 472 if (settings.Rel != LinkRelType.None) 473 { 474 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 475 } 476 477 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 478 } 479 } 480 @using System.Reflection 481 @using Dynamicweb.Rapido.Blocks.Components 482 @using Dynamicweb.Rapido.Blocks.Components.General 483 @using Dynamicweb.Rapido.Blocks 484 485 486 @* Component *@ 487 488 @helper RenderRating(Rating settings) 489 { 490 if (settings.Score > 0) 491 { 492 int rating = settings.Score; 493 string iconType = "fa-star"; 494 495 switch (settings.Type.ToString()) { 496 case "Stars": 497 iconType = "fa-star"; 498 break; 499 case "Hearts": 500 iconType = "fa-heart"; 501 break; 502 case "Lemons": 503 iconType = "fa-lemon"; 504 break; 505 case "Bombs": 506 iconType = "fa-bomb"; 507 break; 508 } 509 510 <div class="u-ta-right"> 511 @for (int i = 0; i < settings.OutOf; i++) 512 { 513 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 514 } 515 </div> 516 } 517 } 518 @using System.Reflection 519 @using Dynamicweb.Rapido.Blocks.Components.General 520 @using Dynamicweb.Rapido.Blocks.Components 521 522 523 @* Component *@ 524 525 @helper RenderSelectFieldOption(SelectFieldOption settings) 526 { 527 Dictionary<string, string> attributes = new Dictionary<string, string>(); 528 if (settings.Checked) { attributes.Add("selected", "true"); } 529 if (settings.Disabled) { attributes.Add("disabled", "true"); } 530 if (settings.Value != null) { attributes.Add("value", settings.Value); } 531 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 532 533 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 534 } 535 @using System.Reflection 536 @using Dynamicweb.Rapido.Blocks.Components.General 537 @using Dynamicweb.Rapido.Blocks.Components 538 539 540 @* Component *@ 541 542 @helper RenderNavigation(Navigation settings) { 543 @RenderNavigation(new 544 { 545 id = settings.Id, 546 cssclass = settings.CssClass, 547 startLevel = settings.StartLevel, 548 endlevel = settings.EndLevel, 549 expandmode = settings.Expandmode, 550 sitemapmode = settings.SitemapMode, 551 template = settings.Template 552 }) 553 } 554 @using Dynamicweb.Rapido.Blocks.Components.General 555 @using Dynamicweb.Rapido.Blocks.Components 556 557 558 @* Component *@ 559 560 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 561 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 562 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 563 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 564 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 565 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 566 settings.SitemapMode = false; 567 568 @RenderNavigation(settings) 569 } 570 @using Dynamicweb.Rapido.Blocks.Components.General 571 @using Dynamicweb.Rapido.Blocks.Components 572 573 574 @* Component *@ 575 576 @helper RenderLeftNavigation(LeftNavigation settings) { 577 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 578 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 579 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 580 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 581 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 582 583 <div class="grid__cell"> 584 @RenderNavigation(settings) 585 </div> 586 } 587 @using System.Reflection 588 @using Dynamicweb.Rapido.Blocks.Components.General 589 @using Dynamicweb.Core 590 591 @* Component *@ 592 593 @helper RenderHeading(Heading settings) 594 { 595 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 596 { 597 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 598 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 599 600 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 601 if (!string.IsNullOrEmpty(settings.Link)) 602 { 603 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 604 } 605 else 606 { 607 if (settings.Icon == null) 608 { 609 settings.Icon = new Icon(); 610 } 611 settings.Icon.Label = settings.Title; 612 @Render(settings.Icon) 613 } 614 @("</" + tagName + ">"); 615 } 616 } 617 @using Dynamicweb.Rapido.Blocks.Components 618 @using Dynamicweb.Rapido.Blocks.Components.General 619 @using Dynamicweb.Rapido.Blocks 620 621 622 @* Component *@ 623 624 @helper RenderImage(Image settings) 625 { 626 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 627 { 628 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 629 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 630 631 if (settings.Caption != null) 632 { 633 @:<div> 634 } 635 636 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 637 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 638 639 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 640 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 641 @if (settings.Link != null) 642 { 643 <a href="@settings.Link"> 644 @RenderTheImage(settings) 645 </a> 646 } 647 else 648 { 649 @RenderTheImage(settings) 650 } 651 </div> 652 </div> 653 654 if (settings.Caption != null) 655 { 656 <span class="image-caption dw-mod">@settings.Caption</span> 657 @:</div> 658 } 659 } 660 else 661 { 662 if (settings.Caption != null) 663 { 664 @:<div> 665 } 666 if (!string.IsNullOrEmpty(settings.Link)) 667 { 668 <a href="@settings.Link"> 669 @RenderTheImage(settings) 670 </a> 671 } 672 else 673 { 674 @RenderTheImage(settings) 675 } 676 677 if (settings.Caption != null) 678 { 679 <span class="image-caption dw-mod">@settings.Caption</span> 680 @:</div> 681 } 682 } 683 } 684 685 @helper RenderTheImage(Image settings) 686 { 687 if (settings != null) 688 { 689 string alternativeImage = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("AlternativeImage")) ? Pageview.AreaSettings.GetItem("Settings").GetFile("AlternativeImage").PathUrlEncoded : "/Images/missing_image.jpg"; 690 string placeholderImage = "/Files/Images/placeholder.gif"; 691 string imageEngine = "/Admin/Public/GetImage.ashx?"; 692 693 string imageStyle = ""; 694 695 switch (settings.Style) 696 { 697 case ImageStyle.Ball: 698 imageStyle = "grid__cell-img--ball"; 699 break; 700 701 case ImageStyle.Triangle: 702 imageStyle = "grid__cell-img--triangle"; 703 break; 704 } 705 706 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle || settings.Style == ImageStyle.Triangle) 707 { 708 settings.ImageDefault.Crop = settings.ImageDefault.Crop == 5 ? settings.ImageDefault.Crop = 0 : settings.ImageDefault.Crop; 709 710 if (settings.ImageDefault != null) 711 { 712 settings.ImageDefault.Height = settings.ImageDefault.Width; 713 } 714 if (settings.ImageMedium != null) 715 { 716 settings.ImageMedium.Height = settings.ImageMedium.Width; 717 } 718 if (settings.ImageSmall != null) 719 { 720 settings.ImageSmall.Height = settings.ImageSmall.Width; 721 } 722 } 723 724 string defaultImage = imageEngine; 725 string imageSmall = ""; 726 string imageMedium = ""; 727 728 if (settings.DisableImageEngine) 729 { 730 defaultImage = settings.Path; 731 } 732 else 733 { 734 if (settings.ImageDefault != null) 735 { 736 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 737 738 if (settings.Path.GetType() != typeof(string)) 739 { 740 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 741 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 742 } 743 else 744 { 745 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 746 } 747 748 defaultImage += "&AlternativeImage=" + alternativeImage; 749 } 750 751 if (settings.ImageSmall != null) 752 { 753 imageSmall = "data-src-small=\"" + imageEngine; 754 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 755 756 if (settings.Path.GetType() != typeof(string)) 757 { 758 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 759 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 760 } 761 else 762 { 763 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 764 } 765 766 imageSmall += "&alternativeImage=" + alternativeImage; 767 768 imageSmall += "\""; 769 } 770 771 if (settings.ImageMedium != null) 772 { 773 imageMedium = "data-src-medium=\"" + imageEngine; 774 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 775 776 if (settings.Path.GetType() != typeof(string)) 777 { 778 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 779 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 780 } 781 else 782 { 783 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 784 } 785 786 imageMedium += "&alternativeImage=" + alternativeImage; 787 788 imageMedium += "\""; 789 } 790 } 791 792 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 793 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 794 if (!string.IsNullOrEmpty(settings.Title)) 795 { 796 optionalAttributes.Add("alt", settings.Title); 797 optionalAttributes.Add("title", settings.Title); 798 } 799 800 if (settings.DisableLazyLoad) 801 { 802 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 803 } 804 else 805 { 806 <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) /> 807 } 808 } 809 } 810 @using System.Reflection 811 @using Dynamicweb.Rapido.Blocks.Components.General 812 @using Dynamicweb.Rapido.Blocks.Components 813 814 @* Component *@ 815 816 @helper RenderFileField(FileField settings) 817 { 818 var attributes = new Dictionary<string, string>(); 819 if (string.IsNullOrEmpty(settings.Id)) 820 { 821 settings.Id = Guid.NewGuid().ToString("N"); 822 } 823 824 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 825 if (settings.Disabled) { attributes.Add("disabled", "true"); } 826 if (settings.Required) { attributes.Add("required", "true"); } 827 if (settings.Multiple) { attributes.Add("multiple", "true"); } 828 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 829 if (string.IsNullOrEmpty(settings.ChooseFileText)) 830 { 831 settings.ChooseFileText = Translate("Choose file"); 832 } 833 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 834 { 835 settings.NoFilesChosenText = Translate("No files chosen..."); 836 } 837 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 838 839 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 840 841 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 842 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 843 844 attributes.Add("type", "file"); 845 if (settings.Value != null) { attributes.Add("value", settings.Value); } 846 settings.CssClass = "u-full-width " + settings.CssClass; 847 848 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 849 850 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 851 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 852 { 853 <div class="u-full-width"> 854 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 855 @if (settings.Link != null) { 856 <div class="u-pull--right"> 857 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 858 @Render(settings.Link) 859 </div> 860 } 861 </div> 862 863 } 864 865 @if (!string.IsNullOrEmpty(settings.HelpText)) 866 { 867 <small class="form__help-text">@settings.HelpText</small> 868 } 869 870 <div class="form__field-combi file-input u-no-margin dw-mod"> 871 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 872 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 873 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 874 @if (settings.UploadButton != null) 875 { 876 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 877 @Render(settings.UploadButton) 878 } 879 </div> 880 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 881 </div> 882 } 883 @using System.Reflection 884 @using Dynamicweb.Rapido.Blocks.Components.General 885 @using Dynamicweb.Rapido.Blocks.Components 886 @using Dynamicweb.Core 887 @using System.Linq 888 889 @* Component *@ 890 891 @helper RenderDateTimeField(DateTimeField settings) 892 { 893 if (string.IsNullOrEmpty(settings.Id)) 894 { 895 settings.Id = Guid.NewGuid().ToString("N"); 896 } 897 if (settings.ExtraAttributes == null) 898 { 899 settings.ExtraAttributes = new Dictionary<string, string>(); 900 } 901 settings.ExtraAttributes.Add("autocomplete","off"); 902 var textField = new TextField { 903 Name = settings.Name, 904 Id = settings.Id, 905 Label = settings.Label, 906 HelpText = settings.HelpText, 907 Value = settings.Value, 908 Disabled = settings.Disabled, 909 Required = settings.Required, 910 ErrorMessage = settings.ErrorMessage, 911 CssClass = settings.CssClass, 912 WrapperCssClass = settings.WrapperCssClass, 913 OnChange = settings.OnChange, 914 OnClick = settings.OnClick, 915 Link = settings.Link, 916 ExtraAttributes = settings.ExtraAttributes, 917 // 918 Placeholder = settings.Placeholder 919 }; 920 921 @Render(textField) 922 923 List<string> jsAttributes = new List<string>(); 924 925 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 926 927 if (!string.IsNullOrEmpty(settings.DateFormat)) 928 { 929 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 930 } 931 if (!string.IsNullOrEmpty(settings.MinDate)) 932 { 933 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 934 } 935 if (!string.IsNullOrEmpty(settings.MaxDate)) 936 { 937 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 938 } 939 if (settings.IsInline) 940 { 941 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 942 } 943 if (settings.EnableTime) 944 { 945 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 946 } 947 if (settings.EnableWeekNumbers) 948 { 949 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 950 } 951 952 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 953 954 <script> 955 document.addEventListener( "DOMContentLoaded", function () { 956 flatpickr("#@textField.Id", { 957 onReady: function(selectedDates, dateStr, instance) { 958 instance.input.readOnly = false; 959 }, 960 onOpen: function(selectedDates, dateStr, instance) { 961 instance.input.readOnly = true; 962 }, 963 onClose: function(selectedDates, dateStr, instance) { 964 instance.input.readOnly = false; 965 //instance.input.blur(); 966 }, 967 @string.Join(",", jsAttributes) 968 } ) 969 } ); 970 </script> 971 } 972 @using System.Reflection 973 @using Dynamicweb.Rapido.Blocks.Components.General 974 @using Dynamicweb.Rapido.Blocks.Components 975 976 @* Component *@ 977 978 @helper RenderTextField(TextField settings) 979 { 980 var attributes = new Dictionary<string, string>(); 981 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 982 { 983 settings.Id = Guid.NewGuid().ToString("N"); 984 } 985 986 /*base settings*/ 987 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 988 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 989 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 990 if (settings.Disabled) { attributes.Add("disabled", "true"); } 991 if (settings.Required) { attributes.Add("required", "true"); } 992 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 993 /*end*/ 994 995 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 996 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 997 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 998 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 999 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1000 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1001 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1002 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1003 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1004 1005 settings.CssClass = "u-full-width " + settings.CssClass; 1006 1007 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1008 1009 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1010 1011 string noMargin = "u-no-margin"; 1012 if (!settings.ReadOnly) { 1013 noMargin = ""; 1014 } 1015 1016 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1017 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1018 { 1019 <div class="u-full-width"> 1020 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1021 @if (settings.Link != null) { 1022 settings.Link.ButtonLayout = ButtonLayout.LinkClean; 1023 1024 <div class="u-pull--right"> 1025 @Render(settings.Link) 1026 </div> 1027 } 1028 </div> 1029 1030 } 1031 1032 @if (!string.IsNullOrEmpty(settings.HelpText)) 1033 { 1034 <small class="form__help-text">@settings.HelpText</small> 1035 } 1036 1037 @if (settings.ActionButton != null) 1038 { 1039 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1040 <div class="form__field-combi u-no-margin dw-mod"> 1041 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1042 @Render(settings.ActionButton) 1043 </div> 1044 } 1045 else 1046 { 1047 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1048 } 1049 1050 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1051 </div> 1052 } 1053 @using System.Reflection 1054 @using Dynamicweb.Rapido.Blocks.Components.General 1055 @using Dynamicweb.Rapido.Blocks.Components 1056 1057 @* Component *@ 1058 1059 @helper RenderNumberField(NumberField settings) 1060 { 1061 var attributes = new Dictionary<string, string>(); 1062 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1063 { 1064 settings.Id = Guid.NewGuid().ToString("N"); 1065 } 1066 1067 /*base settings*/ 1068 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1069 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1070 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1071 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1072 if (settings.Required) { attributes.Add("required", "true"); } 1073 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1074 /*end*/ 1075 1076 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1077 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1078 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1079 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1080 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1081 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1082 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1083 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1084 attributes.Add("type", "number"); 1085 1086 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1087 1088 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1089 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1090 { 1091 <div class="u-full-width"> 1092 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1093 @if (settings.Link != null) { 1094 <div class="u-pull--right"> 1095 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1096 @Render(settings.Link) 1097 </div> 1098 } 1099 </div> 1100 1101 } 1102 1103 @if (!string.IsNullOrEmpty(settings.HelpText)) 1104 { 1105 <small class="form__help-text">@settings.HelpText</small> 1106 } 1107 1108 @if (settings.ActionButton != null) 1109 { 1110 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1111 <div class="form__field-combi u-no-margin dw-mod"> 1112 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1113 @Render(settings.ActionButton) 1114 </div> 1115 } 1116 else 1117 { 1118 <div class="form__field-combi u-no-margin dw-mod"> 1119 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1120 </div> 1121 } 1122 1123 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1124 </div> 1125 } 1126 @using System.Reflection 1127 @using Dynamicweb.Rapido.Blocks.Components.General 1128 @using Dynamicweb.Rapido.Blocks.Components 1129 1130 1131 @* Component *@ 1132 1133 @helper RenderTextareaField(TextareaField settings) 1134 { 1135 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1136 string id = settings.Id; 1137 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1138 { 1139 id = Guid.NewGuid().ToString("N"); 1140 } 1141 1142 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1143 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1144 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1145 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1146 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1147 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1148 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1149 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1150 if (settings.Required) { attributes.Add("required", "true"); } 1151 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1152 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1153 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1154 attributes.Add("name", settings.Name); 1155 1156 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1157 1158 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1159 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1160 { 1161 <div class="u-full-width"> 1162 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1163 @if (settings.Link != null) { 1164 <div class="u-pull--right"> 1165 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1166 @Render(settings.Link) 1167 </div> 1168 } 1169 </div> 1170 } 1171 1172 @if (!string.IsNullOrEmpty(settings.HelpText)) 1173 { 1174 <small class="form__help-text">@settings.HelpText</small> 1175 } 1176 1177 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1178 1179 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1180 </div> 1181 } 1182 @using System.Reflection 1183 @using Dynamicweb.Rapido.Blocks.Components.General 1184 @using Dynamicweb.Rapido.Blocks.Components 1185 1186 1187 @* Component *@ 1188 1189 @helper RenderHiddenField(HiddenField settings) { 1190 var attributes = new Dictionary<string, string>(); 1191 attributes.Add("type", "hidden"); 1192 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1193 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1194 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1195 1196 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1197 } 1198 @using System.Reflection 1199 @using Dynamicweb.Rapido.Blocks.Components.General 1200 @using Dynamicweb.Rapido.Blocks.Components 1201 1202 @* Component *@ 1203 1204 @helper RenderCheckboxField(CheckboxField settings) 1205 { 1206 var attributes = new Dictionary<string, string>(); 1207 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1208 { 1209 settings.Id = Guid.NewGuid().ToString("N"); 1210 } 1211 1212 /*base settings*/ 1213 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1214 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1215 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1216 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1217 if (settings.Required) { attributes.Add("required", "true"); } 1218 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1219 /*end*/ 1220 1221 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1222 1223 attributes.Add("type", "checkbox"); 1224 if (settings.Checked) { attributes.Add("checked", "true"); } 1225 settings.CssClass = "form__control " + settings.CssClass; 1226 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1227 1228 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1229 1230 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1231 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1232 @if (!string.IsNullOrEmpty(settings.Label)) 1233 { 1234 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1235 } 1236 1237 @if (settings.Link != null) { 1238 <span> 1239 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1240 @Render(settings.Link) 1241 </span> 1242 } 1243 1244 @if (!string.IsNullOrEmpty(settings.HelpText)) 1245 { 1246 <small class="form__help-text checkbox-help dw-mod">@settings.HelpText</small> 1247 } 1248 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1249 </div> 1250 } 1251 @using System.Reflection 1252 @using Dynamicweb.Rapido.Blocks.Components.General 1253 @using Dynamicweb.Rapido.Blocks.Components 1254 1255 1256 @* Component *@ 1257 1258 @helper RenderCheckboxListField(CheckboxListField settings) 1259 { 1260 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1261 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1262 { 1263 <div class="u-full-width"> 1264 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1265 @if (settings.Link != null) { 1266 <div class="u-pull--right"> 1267 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1268 @Render(settings.Link) 1269 </div> 1270 } 1271 </div> 1272 1273 } 1274 1275 <div class="u-pull--left"> 1276 @if (!string.IsNullOrEmpty(settings.HelpText)) 1277 { 1278 <small class="form__help-text">@settings.HelpText</small> 1279 } 1280 1281 @foreach (var item in settings.Options) 1282 { 1283 if (settings.Required) 1284 { 1285 item.Required = true; 1286 } 1287 if (settings.Disabled) 1288 { 1289 item.Disabled = true; 1290 } 1291 if (!string.IsNullOrEmpty(settings.Name)) 1292 { 1293 item.Name = settings.Name; 1294 } 1295 if (!string.IsNullOrEmpty(settings.CssClass)) 1296 { 1297 item.CssClass += settings.CssClass; 1298 } 1299 1300 /* value is not supported */ 1301 1302 if (!string.IsNullOrEmpty(settings.OnClick)) 1303 { 1304 item.OnClick += settings.OnClick; 1305 } 1306 if (!string.IsNullOrEmpty(settings.OnChange)) 1307 { 1308 item.OnChange += settings.OnChange; 1309 } 1310 @Render(item) 1311 } 1312 1313 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1314 </div> 1315 1316 </div> 1317 } 1318 @using Dynamicweb.Rapido.Blocks.Components.General 1319 1320 @* Component *@ 1321 1322 @helper RenderSearch(Search settings) 1323 { 1324 var searchValue = HttpContext.Current.Request.QueryString.Get(settings.SearchParameter) ?? ""; 1325 var groupValue = HttpContext.Current.Request.QueryString.Get(settings.GroupsParameter) ?? ""; 1326 1327 if (string.IsNullOrEmpty(settings.Id)) 1328 { 1329 settings.Id = Guid.NewGuid().ToString("N"); 1330 } 1331 1332 var resultAttributes = new Dictionary<string, string>(); 1333 1334 if (settings.PageSize != 0) 1335 { 1336 resultAttributes.Add("data-page-size", settings.PageSize.ToString()); 1337 } 1338 if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1339 { 1340 resultAttributes.Add("data-groups-feed-url", settings.GroupItemsFeedUrl); 1341 if (!string.IsNullOrEmpty(groupValue)) 1342 { 1343 resultAttributes.Add("data-selected-group", groupValue); 1344 } 1345 if (!string.IsNullOrEmpty(settings.GroupsParameter)) 1346 { 1347 resultAttributes.Add("data-groups-parameter", settings.GroupsParameter); 1348 } 1349 } 1350 resultAttributes.Add("data-force-init", "true"); 1351 if (settings.GoToFirstSearchResultOnEnter) 1352 { 1353 resultAttributes.Add("data-go-to-first-search-result-on-enter", settings.GoToFirstSearchResultOnEnter.ToString().ToLower()); 1354 } 1355 if (!string.IsNullOrEmpty(settings.SearchParameter)) 1356 { 1357 resultAttributes.Add("data-search-parameter", settings.SearchParameter); 1358 } 1359 resultAttributes.Add("data-search-feed-url", settings.SearchData.SearchFeedUrl); 1360 resultAttributes.Add("data-results-template-id", settings.SearchData.ResultsTemplateId); 1361 1362 if (settings.SecondSearchData != null) 1363 { 1364 resultAttributes.Add("data-second-search-feed-url", settings.SecondSearchData.SearchFeedUrl); 1365 resultAttributes.Add("data-second-results-template-id", settings.SecondSearchData.ResultsTemplateId); 1366 } 1367 if (!string.IsNullOrEmpty(settings.ResultsPageUrl)) 1368 { 1369 resultAttributes.Add("data-results-page-url", settings.ResultsPageUrl); 1370 } 1371 1372 resultAttributes = resultAttributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1373 1374 string searchFieldCss = (settings.SearchButton == null) ? "search--with-icon" : ""; 1375 1376 <div class="search @settings.CssClass @searchFieldCss js-search-data-source dw-mod" id="@settings.Id" @ComponentMethods.AddAttributes(resultAttributes)> 1377 @if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1378 { 1379 <button type="button" class="search__groups-btn dw-mod js-search-groups-btn">@Translate("All")</button> 1380 <ul class="dropdown dropdown--absolute-position dw-mod search__groups-results js-search-groups-list"></ul> 1381 } 1382 1383 <input type="text" class="search__field dw-mod js-search-field" placeholder="@settings.Placeholder" value="@searchValue"> 1384 1385 <div class="dropdown dropdown--absolute-position search__results dw-mod js-search-results @(settings.SecondSearchData != null ? "search__results--combined" : "")"> 1386 @if (settings.SecondSearchData != null) 1387 { 1388 <div class="search__column search__column--products dw-mod"> 1389 <div class="search__column-header dw-mod">@Translate("Products")</div> 1390 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1391 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1392 { 1393 @Render(new Link { 1394 Title = Translate("View all"), 1395 CssClass = "js-view-all-button u-margin", 1396 Href = settings.SearchData.ResultsPageUrl 1397 }); 1398 } 1399 </div> 1400 <div class="search__column search__column--pages dw-mod"> 1401 <div class="search__column-header">@Translate("Pages")</div> 1402 <ul class="search__results-list dw-mod js-search-results-second-list" id="@(settings.Id)_SecondResultsList"></ul> 1403 @if (!string.IsNullOrEmpty(settings.SecondSearchData.ResultsPageUrl)) 1404 { 1405 @Render(new Link 1406 { 1407 Title = Translate("View all"), 1408 CssClass = "js-view-all-button u-margin", 1409 Href = settings.SecondSearchData.ResultsPageUrl 1410 }); 1411 } 1412 </div> 1413 } 1414 else 1415 { 1416 <div class="search__column search__column--only dw-mod"> 1417 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1418 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1419 { 1420 @Render(new Link { 1421 Title = Translate("View all"), 1422 CssClass = "js-view-all-button u-margin", 1423 Href = settings.SearchData.ResultsPageUrl 1424 }); 1425 } 1426 </div> 1427 } 1428 </div> 1429 1430 @if (settings.SearchButton != null) 1431 { 1432 settings.SearchButton.CssClass += " search__btn js-search-btn"; 1433 if (settings.RenderDefaultSearchIcon) 1434 { 1435 settings.SearchButton.Icon = new Icon { Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue }; 1436 } 1437 @Render(settings.SearchButton); 1438 } 1439 </div> 1440 } 1441 @using System.Reflection 1442 @using Dynamicweb.Rapido.Blocks.Components.General 1443 @using Dynamicweb.Rapido.Blocks.Components 1444 1445 1446 @* Component *@ 1447 1448 @helper RenderSelectField(SelectField settings) 1449 { 1450 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1451 { 1452 settings.Id = Guid.NewGuid().ToString("N"); 1453 } 1454 1455 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1456 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1457 { 1458 <div class="u-full-width"> 1459 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1460 @if (settings.Link != null) { 1461 <div class="u-pull--right"> 1462 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1463 @Render(settings.Link) 1464 </div> 1465 } 1466 </div> 1467 } 1468 1469 @if (!string.IsNullOrEmpty(settings.HelpText)) 1470 { 1471 <small class="form__help-text">@settings.HelpText</small> 1472 } 1473 1474 @if (settings.ActionButton != null) 1475 { 1476 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1477 <div class="form__field-combi u-no-margin dw-mod"> 1478 @RenderSelectBase(settings) 1479 @Render(settings.ActionButton) 1480 </div> 1481 } 1482 else 1483 { 1484 @RenderSelectBase(settings) 1485 } 1486 1487 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1488 </div> 1489 } 1490 1491 @helper RenderSelectBase(SelectField settings) 1492 { 1493 var attributes = new Dictionary<string, string>(); 1494 1495 /*base settings*/ 1496 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1497 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1498 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1499 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1500 if (settings.Required) { attributes.Add("required", "true"); } 1501 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1502 /*end*/ 1503 1504 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1505 1506 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1507 @if (settings.Default != null) 1508 { 1509 @Render(settings.Default) 1510 } 1511 1512 @foreach (var item in settings.Options) 1513 { 1514 if (settings.Value != null) { 1515 item.Checked = item.Value == settings.Value; 1516 } 1517 @Render(item) 1518 } 1519 </select> 1520 } 1521 @using System.Reflection 1522 @using Dynamicweb.Rapido.Blocks.Components.General 1523 @using Dynamicweb.Rapido.Blocks.Components 1524 1525 @* Component *@ 1526 1527 @helper RenderRadioButtonField(RadioButtonField settings) 1528 { 1529 var attributes = new Dictionary<string, string>(); 1530 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1531 { 1532 settings.Id = Guid.NewGuid().ToString("N"); 1533 } 1534 1535 /*base settings*/ 1536 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1537 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1538 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1539 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1540 if (settings.Required) { attributes.Add("required", "true"); } 1541 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1542 /*end*/ 1543 1544 attributes.Add("type", "radio"); 1545 if (settings.Checked) { attributes.Add("checked", "true"); } 1546 settings.CssClass = "form__control " + settings.CssClass; 1547 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1548 1549 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1550 1551 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1552 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1553 @if (!string.IsNullOrEmpty(settings.Label)) 1554 { 1555 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1556 } 1557 @if (!string.IsNullOrEmpty(settings.HelpText)) 1558 { 1559 <small class="form__help-text">@settings.HelpText</small> 1560 } 1561 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1562 </div> 1563 } 1564 @using System.Reflection 1565 @using Dynamicweb.Rapido.Blocks.Components.General 1566 @using Dynamicweb.Rapido.Blocks.Components 1567 1568 1569 @* Component *@ 1570 1571 @helper RenderRadioButtonListField(RadioButtonListField settings) 1572 { 1573 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1574 1575 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1576 @if (!string.IsNullOrEmpty(settings.Label)) 1577 { 1578 <label>@settings.Label</label> 1579 } 1580 @if (!string.IsNullOrEmpty(settings.HelpText)) 1581 { 1582 <small class="form__help-text">@settings.HelpText</small> 1583 } 1584 1585 @foreach (var item in settings.Options) 1586 { 1587 if (settings.Required) 1588 { 1589 item.Required = true; 1590 } 1591 if (settings.Disabled) 1592 { 1593 item.Disabled = true; 1594 } 1595 if (!string.IsNullOrEmpty(settings.Name)) 1596 { 1597 item.Name = settings.Name; 1598 } 1599 if (settings.Value != null && settings.Value == item.Value) 1600 { 1601 item.Checked = true; 1602 } 1603 if (!string.IsNullOrEmpty(settings.OnClick)) 1604 { 1605 item.OnClick += settings.OnClick; 1606 } 1607 if (!string.IsNullOrEmpty(settings.OnChange)) 1608 { 1609 item.OnChange += settings.OnChange; 1610 } 1611 if (!string.IsNullOrEmpty(settings.CssClass)) 1612 { 1613 item.CssClass += settings.CssClass; 1614 } 1615 @Render(item) 1616 } 1617 1618 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1619 </div> 1620 } 1621 @using System.Reflection 1622 @using Dynamicweb.Rapido.Blocks.Components.General 1623 @using Dynamicweb.Rapido.Blocks.Components 1624 1625 1626 @* Component *@ 1627 1628 @helper RenderNotificationMessage(NotificationMessage settings) 1629 { 1630 if (!string.IsNullOrEmpty(settings.Message)) 1631 { 1632 var attributes = new Dictionary<string, string>(); 1633 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1634 1635 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1636 string messageLayoutClass = Enum.GetName(typeof(NotificationMessageLayout), settings.MessageLayout).ToLower(); 1637 string minHeightClass = settings.Icon != null ? "u-min-h70px" : ""; 1638 1639 <div class="notification-message-@messageTypeClass notification-message-@messageLayoutClass @messageLayoutClass @minHeightClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)> 1640 @if (settings.Icon != null) { 1641 settings.Icon.Label = !string.IsNullOrEmpty(settings.Icon.Label) ? settings.Message + settings.Icon.Label : settings.Message; 1642 @Render(settings.Icon) 1643 } else { 1644 @settings.Message 1645 } 1646 </div> 1647 } 1648 } 1649 @using Dynamicweb.Rapido.Blocks.Components.General 1650 1651 1652 @* Component *@ 1653 1654 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1655 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1656 1657 <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> 1658 @if (settings.SubBlocks != null) { 1659 @RenderBlockList(settings.SubBlocks) 1660 } 1661 </div> 1662 } 1663 @using System.Reflection 1664 @using Dynamicweb.Rapido.Blocks.Components.General 1665 @using Dynamicweb.Rapido.Blocks.Components 1666 @using System.Text.RegularExpressions 1667 1668 1669 @* Component *@ 1670 1671 @helper RenderSticker(Sticker settings) { 1672 if (!String.IsNullOrEmpty(settings.Title)) { 1673 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1674 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1675 1676 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1677 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1678 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1679 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1680 optionalAttributes.Add("style", styleTag); 1681 } 1682 1683 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1684 } 1685 } 1686 1687 @using System.Reflection 1688 @using Dynamicweb.Rapido.Blocks.Components.General 1689 @using Dynamicweb.Rapido.Blocks.Components 1690 1691 1692 @* Component *@ 1693 1694 @helper RenderStickersCollection(StickersCollection settings) 1695 { 1696 if (settings.Stickers.Count > 0) 1697 { 1698 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1699 1700 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1701 @foreach (Sticker sticker in settings.Stickers) 1702 { 1703 @Render(sticker) 1704 } 1705 </div> 1706 } 1707 } 1708 1709 @using Dynamicweb.Rapido.Blocks.Components.General 1710 1711 1712 @* Component *@ 1713 1714 @helper RenderForm(Form settings) { 1715 if (settings != null) 1716 { 1717 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1718 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1719 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1720 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1721 var enctypes = new Dictionary<string, string> 1722 { 1723 { "multipart", "multipart/form-data" }, 1724 { "text", "text/plain" }, 1725 { "application", "application/x-www-form-urlencoded" } 1726 }; 1727 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1728 optionalAttributes.Add("method", settings.Method.ToString()); 1729 1730 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1731 { 1732 @settings.FormStartMarkup 1733 } 1734 else 1735 { 1736 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1737 } 1738 1739 foreach (var field in settings.GetFields()) 1740 { 1741 @Render(field) 1742 } 1743 1744 @:</form> 1745 } 1746 } 1747 @using System.Reflection 1748 @using Dynamicweb.Rapido.Blocks.Components.General 1749 @using Dynamicweb.Rapido.Blocks.Components 1750 1751 1752 @* Component *@ 1753 1754 @helper RenderText(Text settings) 1755 { 1756 @settings.Content 1757 } 1758 @using System.Reflection 1759 @using Dynamicweb.Rapido.Blocks.Components.General 1760 @using Dynamicweb.Rapido.Blocks.Components 1761 1762 1763 @* Component *@ 1764 1765 @helper RenderContentModule(ContentModule settings) { 1766 if (!string.IsNullOrEmpty(settings.Content)) 1767 { 1768 @settings.Content 1769 } 1770 } 1771 @using System.Reflection 1772 @using Dynamicweb.Rapido.Blocks.Components.General 1773 @using Dynamicweb.Rapido.Blocks.Components 1774 1775 1776 @* Component *@ 1777 1778 @helper RenderModal(Modal settings) { 1779 if (settings != null) 1780 { 1781 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1782 1783 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1784 1785 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1786 1787 <div class="modal-container"> 1788 @if (!settings.DisableDarkOverlay) 1789 { 1790 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1791 } 1792 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1793 @if (settings.Heading != null) 1794 { 1795 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1796 { 1797 <div class="modal__header"> 1798 @Render(settings.Heading) 1799 </div> 1800 } 1801 } 1802 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1803 @if (!string.IsNullOrEmpty(settings.BodyText)) 1804 { 1805 @settings.BodyText 1806 } 1807 @if (settings.BodyTemplate != null) 1808 { 1809 @settings.BodyTemplate 1810 } 1811 @{ 1812 var actions = settings.GetActions(); 1813 } 1814 </div> 1815 @if (actions.Length > 0) 1816 { 1817 <div class="modal__footer"> 1818 @foreach (var action in actions) 1819 { 1820 if (Pageview.Device.ToString() != "Mobile") { 1821 action.CssClass += " u-no-margin"; 1822 } else { 1823 action.CssClass += " u-full-width u-margin-bottom"; 1824 } 1825 1826 @Render(action) 1827 } 1828 </div> 1829 } 1830 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1831 </div> 1832 </div> 1833 } 1834 } 1835 @using Dynamicweb.Rapido.Blocks.Components.General 1836 1837 @* Component *@ 1838 1839 @helper RenderMediaListItem(MediaListItem settings) 1840 { 1841 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1842 @if (!string.IsNullOrEmpty(settings.Label)) 1843 { 1844 if (!string.IsNullOrEmpty(settings.Link)) 1845 { 1846 @Render(new Link 1847 { 1848 Href = settings.Link, 1849 CssClass = "media-list-item__sticker dw-mod", 1850 ButtonLayout = ButtonLayout.None, 1851 Title = settings.Label, 1852 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1853 }) 1854 } 1855 else if (!string.IsNullOrEmpty(settings.OnClick)) 1856 { 1857 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1858 <span class="u-uppercase">@settings.Label</span> 1859 </span> 1860 } 1861 else 1862 { 1863 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1864 <span class="u-uppercase">@settings.Label</span> 1865 </span> 1866 } 1867 } 1868 <div class="media-list-item__wrap"> 1869 <div class="media-list-item__info dw-mod"> 1870 <div class="media-list-item__header dw-mod"> 1871 @if (!string.IsNullOrEmpty(settings.Title)) 1872 { 1873 if (!string.IsNullOrEmpty(settings.Link)) 1874 { 1875 @Render(new Link 1876 { 1877 Href = settings.Link, 1878 CssClass = "media-list-item__name dw-mod", 1879 ButtonLayout = ButtonLayout.None, 1880 Title = settings.Title, 1881 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1882 }) 1883 } 1884 else if (!string.IsNullOrEmpty(settings.OnClick)) 1885 { 1886 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1887 } 1888 else 1889 { 1890 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1891 } 1892 } 1893 1894 @if (!string.IsNullOrEmpty(settings.Status)) 1895 { 1896 <div class="media-list-item__state dw-mod">@settings.Status</div> 1897 } 1898 </div> 1899 @{ 1900 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1901 } 1902 1903 @Render(settings.InfoTable) 1904 </div> 1905 <div class="media-list-item__actions dw-mod"> 1906 <div class="media-list-item__actions-list dw-mod"> 1907 @{ 1908 var actions = settings.GetActions(); 1909 1910 foreach (ButtonBase action in actions) 1911 { 1912 action.ButtonLayout = ButtonLayout.None; 1913 action.CssClass += " media-list-item__action link"; 1914 1915 @Render(action) 1916 } 1917 } 1918 </div> 1919 1920 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1921 { 1922 settings.SelectButton.CssClass += " u-no-margin"; 1923 1924 <div class="media-list-item__action-button"> 1925 @Render(settings.SelectButton) 1926 </div> 1927 } 1928 </div> 1929 </div> 1930 </div> 1931 } 1932 @using Dynamicweb.Rapido.Blocks.Components.General 1933 @using Dynamicweb.Rapido.Blocks.Components 1934 1935 @helper RenderTable(Table settings) 1936 { 1937 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1938 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1939 1940 var enumToClasses = new Dictionary<TableDesign, string> 1941 { 1942 { TableDesign.Clean, "table--clean" }, 1943 { TableDesign.Bordered, "table--bordered" }, 1944 { TableDesign.Striped, "table--striped" }, 1945 { TableDesign.Hover, "table--hover" }, 1946 { TableDesign.Compact, "table--compact" }, 1947 { TableDesign.Condensed, "table--condensed" }, 1948 { TableDesign.NoTopBorder, "table--no-top-border" } 1949 }; 1950 string tableDesignClass = ""; 1951 if (settings.Design != TableDesign.None) 1952 { 1953 tableDesignClass = enumToClasses[settings.Design]; 1954 } 1955 1956 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1957 1958 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1959 1960 <table @ComponentMethods.AddAttributes(resultAttributes)> 1961 @if (settings.Header != null) 1962 { 1963 <thead> 1964 @Render(settings.Header) 1965 </thead> 1966 } 1967 <tbody> 1968 @foreach (var row in settings.Rows) 1969 { 1970 @Render(row) 1971 } 1972 </tbody> 1973 @if (settings.Footer != null) 1974 { 1975 <tfoot> 1976 @Render(settings.Footer) 1977 </tfoot> 1978 } 1979 </table> 1980 } 1981 @using Dynamicweb.Rapido.Blocks.Components.General 1982 @using Dynamicweb.Rapido.Blocks.Components 1983 1984 @helper RenderTableRow(TableRow settings) 1985 { 1986 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1987 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1988 1989 var enumToClasses = new Dictionary<TableRowDesign, string> 1990 { 1991 { TableRowDesign.NoBorder, "table__row--no-border" }, 1992 { TableRowDesign.Border, "table__row--border" }, 1993 { TableRowDesign.TopBorder, "table__row--top-line" }, 1994 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1995 { TableRowDesign.Solid, "table__row--solid" } 1996 }; 1997 1998 string tableRowDesignClass = ""; 1999 if (settings.Design != TableRowDesign.None) 2000 { 2001 tableRowDesignClass = enumToClasses[settings.Design]; 2002 } 2003 2004 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 2005 2006 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2007 2008 <tr @ComponentMethods.AddAttributes(resultAttributes)> 2009 @foreach (var cell in settings.Cells) 2010 { 2011 if (settings.IsHeaderRow) 2012 { 2013 cell.IsHeader = true; 2014 } 2015 @Render(cell) 2016 } 2017 </tr> 2018 } 2019 @using Dynamicweb.Rapido.Blocks.Components.General 2020 @using Dynamicweb.Rapido.Blocks.Components 2021 @using Dynamicweb.Core 2022 2023 @helper RenderTableCell(TableCell settings) 2024 { 2025 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2026 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2027 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 2028 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 2029 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 2030 2031 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2032 2033 string tagName = settings.IsHeader ? "th" : "td"; 2034 2035 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 2036 @settings.Content 2037 @("</" + tagName + ">"); 2038 } 2039 @using System.Linq 2040 @using Dynamicweb.Rapido.Blocks.Components.General 2041 2042 @* Component *@ 2043 2044 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 2045 { 2046 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 2047 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 2048 2049 if (settings.NumberOfPages > 1) 2050 { 2051 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 2052 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 2053 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 2054 2055 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 2056 @if (settings.ShowPagingInfo) 2057 { 2058 <div class="pager__info dw-mod"> 2059 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 2060 </div> 2061 } 2062 <ul class="pager__list dw-mod"> 2063 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 2064 { 2065 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 2066 } 2067 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 2068 { 2069 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 2070 } 2071 @if (settings.GetPages().Any()) 2072 { 2073 foreach (var page in settings.GetPages()) 2074 { 2075 @Render(page) 2076 } 2077 } 2078 else 2079 { 2080 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 2081 { 2082 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 2083 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 2084 } 2085 } 2086 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 2087 { 2088 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 2089 } 2090 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 2091 { 2092 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 2093 } 2094 </ul> 2095 </div> 2096 } 2097 } 2098 2099 @helper RenderPaginationItem(PaginationItem settings) 2100 { 2101 if (settings.Icon == null) 2102 { 2103 settings.Icon = new Icon(); 2104 } 2105 2106 settings.Icon.Label = settings.Label; 2107 <li class="pager__btn dw-mod"> 2108 @if (settings.IsActive) 2109 { 2110 <span class="pager__num pager__num--current dw-mod"> 2111 @Render(settings.Icon) 2112 </span> 2113 } 2114 else 2115 { 2116 <a href="@settings.Link" class="pager__num dw-mod"> 2117 @Render(settings.Icon) 2118 </a> 2119 } 2120 </li> 2121 } 2122 2123 2124 @using Dynamicweb.Rapido.Blocks.Components.General 2125 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2126 2127 2128 2129 2130 2131 @functions { 2132 public string GenerateRgba(string color, string opacity) 2133 { 2134 color = color.Replace("#", ""); 2135 if (color.Length == 6) { 2136 return "rgba(" + Convert.ToInt32(color.Substring(0, 2), 16) + ", " + Convert.ToInt32(color.Substring(2, 2), 16) + ", " + Convert.ToInt32(color.Substring(4, 2), 16) + ", " + opacity + ");"; 2137 } else { 2138 return Convert.ToInt16(color).ToString(); 2139 } 2140 } 2141 } 2142 2143 @{ 2144 string link = !string.IsNullOrEmpty(Model.Item.GetString("Link")) ? Model.Item.GetString("Link") : ""; 2145 string linkTarget = link.Contains("http") ? "_blank" : "_self"; 2146 } 2147 2148 @if (!string.IsNullOrEmpty(link)) { 2149 <a href="@link" target="@linkTarget" class="u-overlay">&nbsp;</a> 2150 @RenderTheContent() 2151 } else { 2152 @RenderTheContent() 2153 } 2154 2155 @helper RenderTheContent(){ 2156 var colorService = new ColorSwatchService(); 2157 2158 string innerPadding = Model.Item.GetList("Padding") != null ? " padding-size-" + Model.Item.GetList("Padding").SelectedValue.ToLower() : ""; 2159 innerPadding += Model.Item.GetList("PaddingPosition") != null ? " padding-position-" + Model.Item.GetList("PaddingPosition").SelectedValue.ToLower() : ""; 2160 string outerMargin = Model.Item.GetList("Margin") != null ? " margin-" + Model.Item.GetList("Margin").SelectedValue.ToLower() : ""; 2161 string outerMarginPosition = Model.Item.GetList("MarginPosition") != null ? " margin-position-" + Model.Item.GetList("MarginPosition").SelectedValue.ToLower() : ""; 2162 2163 string cardBackgroundColor = Model.Item.GetString("CardBackgroundColor") != null ? Model.Item.GetString("CardBackgroundColor") : ""; 2164 cardBackgroundColor = !cardBackgroundColor.Contains("#") ? colorService.GetHexColor(Pageview.AreaID, cardBackgroundColor) : cardBackgroundColor; 2165 string styles = "background-color: " + cardBackgroundColor + ";"; 2166 if (!string.IsNullOrEmpty(Model.Item.GetString("Image"))) { 2167 int cropMode = !string.IsNullOrEmpty(Convert.ToString(Model.Item.GetList("ImageCrop"))) ? Convert.ToInt32(Model.Item.GetList("ImageCrop").SelectedValue) : 0; 2168 2169 Image image = new Image 2170 { 2171 Path = Model.Item.GetFile("Image") != null ? Model.Item.GetFile("Image").Path : "", 2172 CssClass = "background-image__cover", 2173 ImageDefault = new ImageSettings 2174 { 2175 Crop = cropMode, 2176 Height = 845, 2177 Width = 1920 2178 }, 2179 ImageMedium = new ImageSettings 2180 { 2181 Crop = cropMode, 2182 Height = 450, 2183 Width = 1024 2184 }, 2185 ImageSmall = new ImageSettings 2186 { 2187 Crop = cropMode, 2188 Height = 544, 2189 Width = 640 2190 } 2191 }; 2192 2193 image.FilterPrimary = !string.IsNullOrEmpty(Model.Item.GetList("ImageFilterPrimary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), Model.Item.GetList("ImageFilterPrimary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2194 image.FilterSecondary = !string.IsNullOrEmpty(Model.Item.GetList("ImageFilterSecondary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), Model.Item.GetList("ImageFilterSecondary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2195 2196 if (!string.IsNullOrEmpty(Model.Item.GetString("ColorForTheFilter"))) { 2197 image.FilterColor = Model.Item.GetString("ColorForTheFilter").StartsWith("#") ? GenerateRgba(Model.Item.GetString("ColorForTheFilter"), "0.3") : ""; 2198 } 2199 2200 <div class="background-image dw-mod"> 2201 <div class="background-image__wrapper dw-mod"> 2202 @Render(image) 2203 </div> 2204 </div> 2205 } 2206 2207 <div class="content-row__item__body @innerPadding @outerMargin @outerMarginPosition card-paragraph dw-mod" style="@styles"> 2208 @if (!string.IsNullOrEmpty(Model.Item.GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetString("Text"))) { 2209 if (!Model.Item.GetBoolean("HideTitle")) { 2210 @Render(new Heading { Title = Model.Item.GetString("Title"), CssClass = "u-no-margin", Level = 2 }) 2211 } 2212 @Render(new Text { Content = Model.Item.GetString("Text") }) 2213 } 2214 2215 @if (!string.IsNullOrEmpty(Model.Item.GetItem("ButtonOne").GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetItem("ButtonTwo").GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetItem("ButtonThree").GetString("Title"))) { 2216 <div> 2217 @ParagraphButton(Model.Item.GetItem("ButtonOne")) 2218 @ParagraphButton(Model.Item.GetItem("ButtonTwo")) 2219 @ParagraphButton(Model.Item.GetItem("ButtonThree")) 2220 </div> 2221 } 2222 </div> 2223 } 2224 2225 2226 @helper ParagraphButton(ItemViewModel item) { 2227 if (item != null) { 2228 if (!string.IsNullOrEmpty(item.GetString("Title"))) { 2229 Button button = new Button { 2230 Title = item.GetString("Title"), 2231 Href = item.GetString("Link"), 2232 CssClass = "u-no-margin", 2233 ButtonLayout = (ButtonLayout)System.Enum.Parse(typeof(ButtonLayout), char.ToUpper(item.GetList("Layout").SelectedValue[0]) + item.GetList("Layout").SelectedValue.Substring(1)) 2234 }; 2235 2236 if (!string.IsNullOrEmpty(item.GetString("Icon"))) { 2237 button.Icon = new Icon { 2238 CssClass = item.GetString("Icon") 2239 }; 2240 } 2241 2242 @Render(button) 2243 } 2244 } 2245 } 2246 2247 2248 2249 2250
Error executing template "Designs/Rapido/ContentPage/Paragraph/CardParagraph.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_776095055ad24d97af02f9a60cb157b4.<RenderTheContent>b__46_0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\S_DW_Thermex\Files\Templates\Designs\Rapido\ContentPage\Paragraph\CardParagraph.cshtml:line 2215
   at CompiledRazorTemplates.Dynamic.RazorEngine_776095055ad24d97af02f9a60cb157b4.Execute() in D:\Dynamicweb.net\Solutions\S_DW_Thermex\Files\Templates\Designs\Rapido\ContentPage\Paragraph\CardParagraph.cshtml:line 2152
   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.ParagraphViewModel> 2 @using Dynamicweb.Frontend 3 @using Dynamicweb.Content.Items 4 @using Dynamicweb 5 @using Dynamicweb.Rapido.Blocks.Components 6 @using Dynamicweb.Rapido.Blocks.Components.General 7 8 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 9 @using Dynamicweb.Frontend 10 11 @* Include the components *@ 12 @using System.Text.RegularExpressions 13 @using System.Collections.Generic 14 @using System.Reflection 15 @using System.Web 16 @using System.Web.UI.HtmlControls 17 @using Dynamicweb.Rapido.Blocks.Components 18 @using Dynamicweb.Rapido.Blocks.Components.Articles 19 @using Dynamicweb.Rapido.Blocks.Components.Documentation 20 @using Dynamicweb.Rapido.Blocks 21 22 23 @*--- START: Base block renderers ---*@ 24 25 @helper RenderBlockList(List<Block> blocks) 26 { 27 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 28 blocks = blocks.OrderBy(item => item.SortId).ToList(); 29 30 foreach (Block item in blocks) 31 { 32 if (debug) { 33 <!-- Block START: @item.Id --> 34 } 35 36 if (item.Design == null) 37 { 38 @RenderBlock(item) 39 } 40 else if (item.Design.RenderType == RenderType.None) { 41 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 42 43 <div class="@cssClass dw-mod"> 44 @RenderBlock(item) 45 </div> 46 } 47 else if (item.Design.RenderType != RenderType.Hide) 48 { 49 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 50 51 if (!item.SkipRenderBlocksList) { 52 if (item.Design.RenderType == RenderType.Row) 53 { 54 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 55 @RenderBlock(item) 56 </div> 57 } 58 59 if (item.Design.RenderType == RenderType.Column) 60 { 61 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 62 string size = item.Design.Size ?? "12"; 63 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 64 65 <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"> 66 @RenderBlock(item) 67 </div> 68 } 69 70 if (item.Design.RenderType == RenderType.Table) 71 { 72 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 73 @RenderBlock(item) 74 </table> 75 } 76 77 if (item.Design.RenderType == RenderType.TableRow) 78 { 79 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 80 @RenderBlock(item) 81 </tr> 82 } 83 84 if (item.Design.RenderType == RenderType.TableColumn) 85 { 86 <td class="@cssClass dw-mod" id="Block__@item.Id"> 87 @RenderBlock(item) 88 </td> 89 } 90 91 if (item.Design.RenderType == RenderType.CardHeader) 92 { 93 <div class="card-header @cssClass dw-mod"> 94 @RenderBlock(item) 95 </div> 96 } 97 98 if (item.Design.RenderType == RenderType.CardBody) 99 { 100 <div class="card @cssClass dw-mod"> 101 @RenderBlock(item) 102 </div> 103 } 104 105 if (item.Design.RenderType == RenderType.CardFooter) 106 { 107 <div class="card-footer @cssClass dw-mod"> 108 @RenderBlock(item) 109 </div> 110 } 111 } 112 else 113 { 114 @RenderBlock(item) 115 } 116 } 117 118 if (debug) { 119 <!-- Block END: @item.Id --> 120 } 121 } 122 } 123 124 @helper RenderBlock(Block item) 125 { 126 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 127 128 if (item.Template != null) 129 { 130 @BlocksPage.RenderTemplate(item.Template) 131 } 132 133 if (item.Component != null) 134 { 135 string customSufix = "Custom"; 136 string methodName = item.Component.HelperName; 137 138 ComponentBase[] methodParameters = new ComponentBase[1]; 139 methodParameters[0] = item.Component; 140 Type methodType = this.GetType(); 141 142 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 143 144 try { 145 if (debug) { 146 <!-- Component: @methodName.Replace("Render", "") --> 147 } 148 if(customMethod != null) { 149 @customMethod.Invoke(this, methodParameters).ToString(); 150 } else { 151 MethodInfo generalMethod = methodType.GetMethod(methodName); 152 @generalMethod.Invoke(this, methodParameters).ToString(); 153 } 154 } catch { 155 try { 156 MethodInfo generalMethod = methodType.GetMethod(methodName); 157 @generalMethod.Invoke(this, methodParameters).ToString(); 158 } catch(Exception ex) { 159 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 160 } 161 } 162 } 163 164 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 165 { 166 @RenderBlockList(item.BlocksList) 167 } 168 } 169 170 @*--- END: Base block renderers ---*@ 171 172 @using Dynamicweb.Rapido.Blocks.Components 173 @using Dynamicweb.Rapido.Blocks.Components.General 174 @using Dynamicweb.Rapido.Blocks 175 @using System.IO 176 177 @* Required *@ 178 @using Dynamicweb.Rapido.Blocks.Components 179 @using Dynamicweb.Rapido.Blocks.Components.General 180 @using Dynamicweb.Rapido.Blocks 181 182 183 @helper Render(ComponentBase component) 184 { 185 if (component != null) 186 { 187 @component.Render(this) 188 } 189 } 190 191 @* Components *@ 192 @using System.Reflection 193 @using Dynamicweb.Rapido.Blocks.Components.General 194 195 196 @* Component *@ 197 198 @helper RenderIcon(Icon settings) 199 { 200 if (settings != null) 201 { 202 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 203 204 if (settings.Name != null) 205 { 206 if (string.IsNullOrEmpty(settings.Label)) 207 { 208 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 209 } 210 else 211 { 212 if (settings.LabelPosition == IconLabelPosition.Before) 213 { 214 <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> 215 } 216 else 217 { 218 <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> 219 } 220 } 221 } 222 else if (!string.IsNullOrEmpty(settings.Label)) 223 { 224 @settings.Label 225 } 226 } 227 } 228 @using System.Reflection 229 @using Dynamicweb.Rapido.Blocks.Components.General 230 @using Dynamicweb.Rapido.Blocks.Components 231 @using Dynamicweb.Core 232 233 @* Component *@ 234 235 @helper RenderButton(Button settings) 236 { 237 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 238 { 239 Dictionary<string, string> attributes = new Dictionary<string, string>(); 240 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 241 if (settings.Disabled) { 242 attributes.Add("disabled", "true"); 243 classList.Add("disabled"); 244 } 245 246 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 247 { 248 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 249 @RenderConfirmDialog(settings); 250 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 251 } 252 253 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 254 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 255 if (!string.IsNullOrEmpty(settings.AltText)) 256 { 257 attributes.Add("title", settings.AltText); 258 } 259 else if (!string.IsNullOrEmpty(settings.Title)) 260 { 261 string cleanTitle = Regex.Replace(settings.Title, "<.*?>", String.Empty); 262 cleanTitle = cleanTitle.Replace("&nbsp;", " "); 263 attributes.Add("title", cleanTitle); 264 } 265 266 var onClickEvents = new List<string>(); 267 if (!string.IsNullOrEmpty(settings.OnClick)) 268 { 269 onClickEvents.Add(settings.OnClick); 270 } 271 if (!string.IsNullOrEmpty(settings.Href)) 272 { 273 onClickEvents.Add("location.href='" + settings.Href + "'"); 274 } 275 if (onClickEvents.Count > 0) 276 { 277 attributes.Add("onClick", string.Join(";", onClickEvents)); 278 } 279 280 if (settings.ButtonLayout != ButtonLayout.None) 281 { 282 classList.Add("btn"); 283 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 284 if (btnLayout == "linkclean") 285 { 286 btnLayout = "link-clean"; //fix 287 } 288 classList.Add("btn--" + btnLayout); 289 } 290 291 if (settings.Icon == null) 292 { 293 settings.Icon = new Icon(); 294 } 295 296 settings.Icon.CssClass += Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower() != "linkclean" ? " u-flex--align-center" : ""; 297 settings.Icon.Label = settings.Title; 298 299 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 300 301 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 302 } 303 } 304 305 @helper RenderConfirmDialog(Button settings) 306 { 307 Modal confirmDialog = new Modal { 308 Id = settings.Id, 309 Width = ModalWidth.Sm, 310 Heading = new Heading 311 { 312 Level = 2, 313 Title = settings.ConfirmTitle 314 }, 315 BodyText = settings.ConfirmText 316 }; 317 318 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 319 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 320 321 @Render(confirmDialog) 322 } 323 @using Dynamicweb.Rapido.Blocks.Components.General 324 @using Dynamicweb.Rapido.Blocks.Components 325 @using Dynamicweb.Core 326 327 @helper RenderDashboard(Dashboard settings) 328 { 329 var widgets = settings.GetWidgets(); 330 331 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 332 { 333 //set bg color for them 334 335 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 336 int r = Convert.ToInt16(color.R); 337 int g = Convert.ToInt16(color.G); 338 int b = Convert.ToInt16(color.B); 339 340 var count = widgets.Length; 341 var max = Math.Max(r, Math.Max(g, b)); 342 double step = 255.0 / (max * count); 343 var i = 0; 344 foreach (var widget in widgets) 345 { 346 i++; 347 348 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 349 widget.BackgroundColor = shade; 350 } 351 } 352 353 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 354 @foreach (var widget in widgets) 355 { 356 <div class="dashboard__widget"> 357 @Render(widget) 358 </div> 359 } 360 </div> 361 } 362 @using Dynamicweb.Rapido.Blocks.Components.General 363 @using Dynamicweb.Rapido.Blocks.Components 364 365 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 366 { 367 if (!string.IsNullOrEmpty(settings.Link)) 368 { 369 var backgroundStyles = ""; 370 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 371 { 372 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 373 } 374 375 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 376 <div class="u-center-middle u-color-light"> 377 @if (settings.Icon != null) 378 { 379 settings.Icon.CssClass += "widget__icon"; 380 @Render(settings.Icon) 381 } 382 <div class="widget__title">@settings.Title</div> 383 </div> 384 </a> 385 } 386 } 387 @using Dynamicweb.Rapido.Blocks.Components.General 388 @using Dynamicweb.Rapido.Blocks.Components 389 390 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 391 { 392 var backgroundStyles = ""; 393 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 394 { 395 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 396 } 397 398 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 399 <div class="u-center-middle u-color-light"> 400 @if (settings.Icon != null) 401 { 402 settings.Icon.CssClass += "widget__icon"; 403 @Render(settings.Icon) 404 } 405 <div class="widget__counter">@settings.Count</div> 406 <div class="widget__title">@settings.Title</div> 407 </div> 408 </div> 409 } 410 @using System.Reflection 411 @using Dynamicweb.Rapido.Blocks.Components.General 412 @using Dynamicweb.Rapido.Blocks.Components 413 @using Dynamicweb.Core 414 415 @* Component *@ 416 417 @helper RenderLink(Link settings) 418 { 419 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 420 { 421 Dictionary<string, string> attributes = new Dictionary<string, string>(); 422 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 423 if (settings.Disabled) 424 { 425 attributes.Add("disabled", "true"); 426 classList.Add("disabled"); 427 } 428 429 if (!string.IsNullOrEmpty(settings.AltText)) 430 { 431 attributes.Add("title", settings.AltText); 432 } 433 else if (!string.IsNullOrEmpty(settings.Title)) 434 { 435 attributes.Add("title", settings.Title); 436 } 437 438 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 439 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 440 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 441 attributes.Add("href", settings.Href); 442 443 if (settings.ButtonLayout != ButtonLayout.None) 444 { 445 classList.Add("btn"); 446 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 447 if (btnLayout == "linkclean") 448 { 449 btnLayout = "link-clean"; //fix 450 } 451 classList.Add("btn--" + btnLayout); 452 } 453 454 if (settings.Icon == null) 455 { 456 settings.Icon = new Icon(); 457 } 458 settings.Icon.Label = settings.Title; 459 460 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 461 { 462 settings.Rel = LinkRelType.Noopener; 463 } 464 if (settings.Target != LinkTargetType.None) 465 { 466 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 467 } 468 if (settings.Download) 469 { 470 attributes.Add("download", "true"); 471 } 472 if (settings.Rel != LinkRelType.None) 473 { 474 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 475 } 476 477 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 478 } 479 } 480 @using System.Reflection 481 @using Dynamicweb.Rapido.Blocks.Components 482 @using Dynamicweb.Rapido.Blocks.Components.General 483 @using Dynamicweb.Rapido.Blocks 484 485 486 @* Component *@ 487 488 @helper RenderRating(Rating settings) 489 { 490 if (settings.Score > 0) 491 { 492 int rating = settings.Score; 493 string iconType = "fa-star"; 494 495 switch (settings.Type.ToString()) { 496 case "Stars": 497 iconType = "fa-star"; 498 break; 499 case "Hearts": 500 iconType = "fa-heart"; 501 break; 502 case "Lemons": 503 iconType = "fa-lemon"; 504 break; 505 case "Bombs": 506 iconType = "fa-bomb"; 507 break; 508 } 509 510 <div class="u-ta-right"> 511 @for (int i = 0; i < settings.OutOf; i++) 512 { 513 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 514 } 515 </div> 516 } 517 } 518 @using System.Reflection 519 @using Dynamicweb.Rapido.Blocks.Components.General 520 @using Dynamicweb.Rapido.Blocks.Components 521 522 523 @* Component *@ 524 525 @helper RenderSelectFieldOption(SelectFieldOption settings) 526 { 527 Dictionary<string, string> attributes = new Dictionary<string, string>(); 528 if (settings.Checked) { attributes.Add("selected", "true"); } 529 if (settings.Disabled) { attributes.Add("disabled", "true"); } 530 if (settings.Value != null) { attributes.Add("value", settings.Value); } 531 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 532 533 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 534 } 535 @using System.Reflection 536 @using Dynamicweb.Rapido.Blocks.Components.General 537 @using Dynamicweb.Rapido.Blocks.Components 538 539 540 @* Component *@ 541 542 @helper RenderNavigation(Navigation settings) { 543 @RenderNavigation(new 544 { 545 id = settings.Id, 546 cssclass = settings.CssClass, 547 startLevel = settings.StartLevel, 548 endlevel = settings.EndLevel, 549 expandmode = settings.Expandmode, 550 sitemapmode = settings.SitemapMode, 551 template = settings.Template 552 }) 553 } 554 @using Dynamicweb.Rapido.Blocks.Components.General 555 @using Dynamicweb.Rapido.Blocks.Components 556 557 558 @* Component *@ 559 560 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 561 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 562 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 563 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 564 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 565 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 566 settings.SitemapMode = false; 567 568 @RenderNavigation(settings) 569 } 570 @using Dynamicweb.Rapido.Blocks.Components.General 571 @using Dynamicweb.Rapido.Blocks.Components 572 573 574 @* Component *@ 575 576 @helper RenderLeftNavigation(LeftNavigation settings) { 577 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 578 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 579 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 580 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 581 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 582 583 <div class="grid__cell"> 584 @RenderNavigation(settings) 585 </div> 586 } 587 @using System.Reflection 588 @using Dynamicweb.Rapido.Blocks.Components.General 589 @using Dynamicweb.Core 590 591 @* Component *@ 592 593 @helper RenderHeading(Heading settings) 594 { 595 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 596 { 597 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 598 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 599 600 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 601 if (!string.IsNullOrEmpty(settings.Link)) 602 { 603 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 604 } 605 else 606 { 607 if (settings.Icon == null) 608 { 609 settings.Icon = new Icon(); 610 } 611 settings.Icon.Label = settings.Title; 612 @Render(settings.Icon) 613 } 614 @("</" + tagName + ">"); 615 } 616 } 617 @using Dynamicweb.Rapido.Blocks.Components 618 @using Dynamicweb.Rapido.Blocks.Components.General 619 @using Dynamicweb.Rapido.Blocks 620 621 622 @* Component *@ 623 624 @helper RenderImage(Image settings) 625 { 626 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 627 { 628 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 629 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 630 631 if (settings.Caption != null) 632 { 633 @:<div> 634 } 635 636 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 637 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 638 639 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 640 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 641 @if (settings.Link != null) 642 { 643 <a href="@settings.Link"> 644 @RenderTheImage(settings) 645 </a> 646 } 647 else 648 { 649 @RenderTheImage(settings) 650 } 651 </div> 652 </div> 653 654 if (settings.Caption != null) 655 { 656 <span class="image-caption dw-mod">@settings.Caption</span> 657 @:</div> 658 } 659 } 660 else 661 { 662 if (settings.Caption != null) 663 { 664 @:<div> 665 } 666 if (!string.IsNullOrEmpty(settings.Link)) 667 { 668 <a href="@settings.Link"> 669 @RenderTheImage(settings) 670 </a> 671 } 672 else 673 { 674 @RenderTheImage(settings) 675 } 676 677 if (settings.Caption != null) 678 { 679 <span class="image-caption dw-mod">@settings.Caption</span> 680 @:</div> 681 } 682 } 683 } 684 685 @helper RenderTheImage(Image settings) 686 { 687 if (settings != null) 688 { 689 string alternativeImage = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("AlternativeImage")) ? Pageview.AreaSettings.GetItem("Settings").GetFile("AlternativeImage").PathUrlEncoded : "/Images/missing_image.jpg"; 690 string placeholderImage = "/Files/Images/placeholder.gif"; 691 string imageEngine = "/Admin/Public/GetImage.ashx?"; 692 693 string imageStyle = ""; 694 695 switch (settings.Style) 696 { 697 case ImageStyle.Ball: 698 imageStyle = "grid__cell-img--ball"; 699 break; 700 701 case ImageStyle.Triangle: 702 imageStyle = "grid__cell-img--triangle"; 703 break; 704 } 705 706 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle || settings.Style == ImageStyle.Triangle) 707 { 708 settings.ImageDefault.Crop = settings.ImageDefault.Crop == 5 ? settings.ImageDefault.Crop = 0 : settings.ImageDefault.Crop; 709 710 if (settings.ImageDefault != null) 711 { 712 settings.ImageDefault.Height = settings.ImageDefault.Width; 713 } 714 if (settings.ImageMedium != null) 715 { 716 settings.ImageMedium.Height = settings.ImageMedium.Width; 717 } 718 if (settings.ImageSmall != null) 719 { 720 settings.ImageSmall.Height = settings.ImageSmall.Width; 721 } 722 } 723 724 string defaultImage = imageEngine; 725 string imageSmall = ""; 726 string imageMedium = ""; 727 728 if (settings.DisableImageEngine) 729 { 730 defaultImage = settings.Path; 731 } 732 else 733 { 734 if (settings.ImageDefault != null) 735 { 736 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 737 738 if (settings.Path.GetType() != typeof(string)) 739 { 740 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 741 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 742 } 743 else 744 { 745 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 746 } 747 748 defaultImage += "&AlternativeImage=" + alternativeImage; 749 } 750 751 if (settings.ImageSmall != null) 752 { 753 imageSmall = "data-src-small=\"" + imageEngine; 754 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 755 756 if (settings.Path.GetType() != typeof(string)) 757 { 758 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 759 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 760 } 761 else 762 { 763 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 764 } 765 766 imageSmall += "&alternativeImage=" + alternativeImage; 767 768 imageSmall += "\""; 769 } 770 771 if (settings.ImageMedium != null) 772 { 773 imageMedium = "data-src-medium=\"" + imageEngine; 774 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 775 776 if (settings.Path.GetType() != typeof(string)) 777 { 778 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 779 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 780 } 781 else 782 { 783 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 784 } 785 786 imageMedium += "&alternativeImage=" + alternativeImage; 787 788 imageMedium += "\""; 789 } 790 } 791 792 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 793 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 794 if (!string.IsNullOrEmpty(settings.Title)) 795 { 796 optionalAttributes.Add("alt", settings.Title); 797 optionalAttributes.Add("title", settings.Title); 798 } 799 800 if (settings.DisableLazyLoad) 801 { 802 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 803 } 804 else 805 { 806 <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) /> 807 } 808 } 809 } 810 @using System.Reflection 811 @using Dynamicweb.Rapido.Blocks.Components.General 812 @using Dynamicweb.Rapido.Blocks.Components 813 814 @* Component *@ 815 816 @helper RenderFileField(FileField settings) 817 { 818 var attributes = new Dictionary<string, string>(); 819 if (string.IsNullOrEmpty(settings.Id)) 820 { 821 settings.Id = Guid.NewGuid().ToString("N"); 822 } 823 824 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 825 if (settings.Disabled) { attributes.Add("disabled", "true"); } 826 if (settings.Required) { attributes.Add("required", "true"); } 827 if (settings.Multiple) { attributes.Add("multiple", "true"); } 828 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 829 if (string.IsNullOrEmpty(settings.ChooseFileText)) 830 { 831 settings.ChooseFileText = Translate("Choose file"); 832 } 833 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 834 { 835 settings.NoFilesChosenText = Translate("No files chosen..."); 836 } 837 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 838 839 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 840 841 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 842 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 843 844 attributes.Add("type", "file"); 845 if (settings.Value != null) { attributes.Add("value", settings.Value); } 846 settings.CssClass = "u-full-width " + settings.CssClass; 847 848 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 849 850 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 851 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 852 { 853 <div class="u-full-width"> 854 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 855 @if (settings.Link != null) { 856 <div class="u-pull--right"> 857 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 858 @Render(settings.Link) 859 </div> 860 } 861 </div> 862 863 } 864 865 @if (!string.IsNullOrEmpty(settings.HelpText)) 866 { 867 <small class="form__help-text">@settings.HelpText</small> 868 } 869 870 <div class="form__field-combi file-input u-no-margin dw-mod"> 871 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 872 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 873 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 874 @if (settings.UploadButton != null) 875 { 876 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 877 @Render(settings.UploadButton) 878 } 879 </div> 880 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 881 </div> 882 } 883 @using System.Reflection 884 @using Dynamicweb.Rapido.Blocks.Components.General 885 @using Dynamicweb.Rapido.Blocks.Components 886 @using Dynamicweb.Core 887 @using System.Linq 888 889 @* Component *@ 890 891 @helper RenderDateTimeField(DateTimeField settings) 892 { 893 if (string.IsNullOrEmpty(settings.Id)) 894 { 895 settings.Id = Guid.NewGuid().ToString("N"); 896 } 897 if (settings.ExtraAttributes == null) 898 { 899 settings.ExtraAttributes = new Dictionary<string, string>(); 900 } 901 settings.ExtraAttributes.Add("autocomplete","off"); 902 var textField = new TextField { 903 Name = settings.Name, 904 Id = settings.Id, 905 Label = settings.Label, 906 HelpText = settings.HelpText, 907 Value = settings.Value, 908 Disabled = settings.Disabled, 909 Required = settings.Required, 910 ErrorMessage = settings.ErrorMessage, 911 CssClass = settings.CssClass, 912 WrapperCssClass = settings.WrapperCssClass, 913 OnChange = settings.OnChange, 914 OnClick = settings.OnClick, 915 Link = settings.Link, 916 ExtraAttributes = settings.ExtraAttributes, 917 // 918 Placeholder = settings.Placeholder 919 }; 920 921 @Render(textField) 922 923 List<string> jsAttributes = new List<string>(); 924 925 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 926 927 if (!string.IsNullOrEmpty(settings.DateFormat)) 928 { 929 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 930 } 931 if (!string.IsNullOrEmpty(settings.MinDate)) 932 { 933 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 934 } 935 if (!string.IsNullOrEmpty(settings.MaxDate)) 936 { 937 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 938 } 939 if (settings.IsInline) 940 { 941 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 942 } 943 if (settings.EnableTime) 944 { 945 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 946 } 947 if (settings.EnableWeekNumbers) 948 { 949 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 950 } 951 952 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 953 954 <script> 955 document.addEventListener( "DOMContentLoaded", function () { 956 flatpickr("#@textField.Id", { 957 onReady: function(selectedDates, dateStr, instance) { 958 instance.input.readOnly = false; 959 }, 960 onOpen: function(selectedDates, dateStr, instance) { 961 instance.input.readOnly = true; 962 }, 963 onClose: function(selectedDates, dateStr, instance) { 964 instance.input.readOnly = false; 965 //instance.input.blur(); 966 }, 967 @string.Join(",", jsAttributes) 968 } ) 969 } ); 970 </script> 971 } 972 @using System.Reflection 973 @using Dynamicweb.Rapido.Blocks.Components.General 974 @using Dynamicweb.Rapido.Blocks.Components 975 976 @* Component *@ 977 978 @helper RenderTextField(TextField settings) 979 { 980 var attributes = new Dictionary<string, string>(); 981 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 982 { 983 settings.Id = Guid.NewGuid().ToString("N"); 984 } 985 986 /*base settings*/ 987 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 988 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 989 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 990 if (settings.Disabled) { attributes.Add("disabled", "true"); } 991 if (settings.Required) { attributes.Add("required", "true"); } 992 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 993 /*end*/ 994 995 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 996 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 997 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 998 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 999 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1000 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1001 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1002 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1003 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1004 1005 settings.CssClass = "u-full-width " + settings.CssClass; 1006 1007 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1008 1009 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1010 1011 string noMargin = "u-no-margin"; 1012 if (!settings.ReadOnly) { 1013 noMargin = ""; 1014 } 1015 1016 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1017 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1018 { 1019 <div class="u-full-width"> 1020 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1021 @if (settings.Link != null) { 1022 settings.Link.ButtonLayout = ButtonLayout.LinkClean; 1023 1024 <div class="u-pull--right"> 1025 @Render(settings.Link) 1026 </div> 1027 } 1028 </div> 1029 1030 } 1031 1032 @if (!string.IsNullOrEmpty(settings.HelpText)) 1033 { 1034 <small class="form__help-text">@settings.HelpText</small> 1035 } 1036 1037 @if (settings.ActionButton != null) 1038 { 1039 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1040 <div class="form__field-combi u-no-margin dw-mod"> 1041 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1042 @Render(settings.ActionButton) 1043 </div> 1044 } 1045 else 1046 { 1047 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1048 } 1049 1050 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1051 </div> 1052 } 1053 @using System.Reflection 1054 @using Dynamicweb.Rapido.Blocks.Components.General 1055 @using Dynamicweb.Rapido.Blocks.Components 1056 1057 @* Component *@ 1058 1059 @helper RenderNumberField(NumberField settings) 1060 { 1061 var attributes = new Dictionary<string, string>(); 1062 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1063 { 1064 settings.Id = Guid.NewGuid().ToString("N"); 1065 } 1066 1067 /*base settings*/ 1068 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1069 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1070 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1071 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1072 if (settings.Required) { attributes.Add("required", "true"); } 1073 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1074 /*end*/ 1075 1076 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1077 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1078 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1079 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1080 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1081 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1082 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1083 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1084 attributes.Add("type", "number"); 1085 1086 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1087 1088 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1089 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1090 { 1091 <div class="u-full-width"> 1092 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1093 @if (settings.Link != null) { 1094 <div class="u-pull--right"> 1095 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1096 @Render(settings.Link) 1097 </div> 1098 } 1099 </div> 1100 1101 } 1102 1103 @if (!string.IsNullOrEmpty(settings.HelpText)) 1104 { 1105 <small class="form__help-text">@settings.HelpText</small> 1106 } 1107 1108 @if (settings.ActionButton != null) 1109 { 1110 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1111 <div class="form__field-combi u-no-margin dw-mod"> 1112 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1113 @Render(settings.ActionButton) 1114 </div> 1115 } 1116 else 1117 { 1118 <div class="form__field-combi u-no-margin dw-mod"> 1119 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1120 </div> 1121 } 1122 1123 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1124 </div> 1125 } 1126 @using System.Reflection 1127 @using Dynamicweb.Rapido.Blocks.Components.General 1128 @using Dynamicweb.Rapido.Blocks.Components 1129 1130 1131 @* Component *@ 1132 1133 @helper RenderTextareaField(TextareaField settings) 1134 { 1135 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1136 string id = settings.Id; 1137 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1138 { 1139 id = Guid.NewGuid().ToString("N"); 1140 } 1141 1142 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1143 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1144 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1145 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1146 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1147 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1148 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1149 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1150 if (settings.Required) { attributes.Add("required", "true"); } 1151 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1152 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1153 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1154 attributes.Add("name", settings.Name); 1155 1156 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1157 1158 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1159 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1160 { 1161 <div class="u-full-width"> 1162 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1163 @if (settings.Link != null) { 1164 <div class="u-pull--right"> 1165 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1166 @Render(settings.Link) 1167 </div> 1168 } 1169 </div> 1170 } 1171 1172 @if (!string.IsNullOrEmpty(settings.HelpText)) 1173 { 1174 <small class="form__help-text">@settings.HelpText</small> 1175 } 1176 1177 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1178 1179 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1180 </div> 1181 } 1182 @using System.Reflection 1183 @using Dynamicweb.Rapido.Blocks.Components.General 1184 @using Dynamicweb.Rapido.Blocks.Components 1185 1186 1187 @* Component *@ 1188 1189 @helper RenderHiddenField(HiddenField settings) { 1190 var attributes = new Dictionary<string, string>(); 1191 attributes.Add("type", "hidden"); 1192 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1193 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1194 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1195 1196 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1197 } 1198 @using System.Reflection 1199 @using Dynamicweb.Rapido.Blocks.Components.General 1200 @using Dynamicweb.Rapido.Blocks.Components 1201 1202 @* Component *@ 1203 1204 @helper RenderCheckboxField(CheckboxField settings) 1205 { 1206 var attributes = new Dictionary<string, string>(); 1207 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1208 { 1209 settings.Id = Guid.NewGuid().ToString("N"); 1210 } 1211 1212 /*base settings*/ 1213 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1214 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1215 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1216 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1217 if (settings.Required) { attributes.Add("required", "true"); } 1218 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1219 /*end*/ 1220 1221 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1222 1223 attributes.Add("type", "checkbox"); 1224 if (settings.Checked) { attributes.Add("checked", "true"); } 1225 settings.CssClass = "form__control " + settings.CssClass; 1226 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1227 1228 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1229 1230 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1231 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1232 @if (!string.IsNullOrEmpty(settings.Label)) 1233 { 1234 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1235 } 1236 1237 @if (settings.Link != null) { 1238 <span> 1239 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1240 @Render(settings.Link) 1241 </span> 1242 } 1243 1244 @if (!string.IsNullOrEmpty(settings.HelpText)) 1245 { 1246 <small class="form__help-text checkbox-help dw-mod">@settings.HelpText</small> 1247 } 1248 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1249 </div> 1250 } 1251 @using System.Reflection 1252 @using Dynamicweb.Rapido.Blocks.Components.General 1253 @using Dynamicweb.Rapido.Blocks.Components 1254 1255 1256 @* Component *@ 1257 1258 @helper RenderCheckboxListField(CheckboxListField settings) 1259 { 1260 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1261 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1262 { 1263 <div class="u-full-width"> 1264 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1265 @if (settings.Link != null) { 1266 <div class="u-pull--right"> 1267 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1268 @Render(settings.Link) 1269 </div> 1270 } 1271 </div> 1272 1273 } 1274 1275 <div class="u-pull--left"> 1276 @if (!string.IsNullOrEmpty(settings.HelpText)) 1277 { 1278 <small class="form__help-text">@settings.HelpText</small> 1279 } 1280 1281 @foreach (var item in settings.Options) 1282 { 1283 if (settings.Required) 1284 { 1285 item.Required = true; 1286 } 1287 if (settings.Disabled) 1288 { 1289 item.Disabled = true; 1290 } 1291 if (!string.IsNullOrEmpty(settings.Name)) 1292 { 1293 item.Name = settings.Name; 1294 } 1295 if (!string.IsNullOrEmpty(settings.CssClass)) 1296 { 1297 item.CssClass += settings.CssClass; 1298 } 1299 1300 /* value is not supported */ 1301 1302 if (!string.IsNullOrEmpty(settings.OnClick)) 1303 { 1304 item.OnClick += settings.OnClick; 1305 } 1306 if (!string.IsNullOrEmpty(settings.OnChange)) 1307 { 1308 item.OnChange += settings.OnChange; 1309 } 1310 @Render(item) 1311 } 1312 1313 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1314 </div> 1315 1316 </div> 1317 } 1318 @using Dynamicweb.Rapido.Blocks.Components.General 1319 1320 @* Component *@ 1321 1322 @helper RenderSearch(Search settings) 1323 { 1324 var searchValue = HttpContext.Current.Request.QueryString.Get(settings.SearchParameter) ?? ""; 1325 var groupValue = HttpContext.Current.Request.QueryString.Get(settings.GroupsParameter) ?? ""; 1326 1327 if (string.IsNullOrEmpty(settings.Id)) 1328 { 1329 settings.Id = Guid.NewGuid().ToString("N"); 1330 } 1331 1332 var resultAttributes = new Dictionary<string, string>(); 1333 1334 if (settings.PageSize != 0) 1335 { 1336 resultAttributes.Add("data-page-size", settings.PageSize.ToString()); 1337 } 1338 if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1339 { 1340 resultAttributes.Add("data-groups-feed-url", settings.GroupItemsFeedUrl); 1341 if (!string.IsNullOrEmpty(groupValue)) 1342 { 1343 resultAttributes.Add("data-selected-group", groupValue); 1344 } 1345 if (!string.IsNullOrEmpty(settings.GroupsParameter)) 1346 { 1347 resultAttributes.Add("data-groups-parameter", settings.GroupsParameter); 1348 } 1349 } 1350 resultAttributes.Add("data-force-init", "true"); 1351 if (settings.GoToFirstSearchResultOnEnter) 1352 { 1353 resultAttributes.Add("data-go-to-first-search-result-on-enter", settings.GoToFirstSearchResultOnEnter.ToString().ToLower()); 1354 } 1355 if (!string.IsNullOrEmpty(settings.SearchParameter)) 1356 { 1357 resultAttributes.Add("data-search-parameter", settings.SearchParameter); 1358 } 1359 resultAttributes.Add("data-search-feed-url", settings.SearchData.SearchFeedUrl); 1360 resultAttributes.Add("data-results-template-id", settings.SearchData.ResultsTemplateId); 1361 1362 if (settings.SecondSearchData != null) 1363 { 1364 resultAttributes.Add("data-second-search-feed-url", settings.SecondSearchData.SearchFeedUrl); 1365 resultAttributes.Add("data-second-results-template-id", settings.SecondSearchData.ResultsTemplateId); 1366 } 1367 if (!string.IsNullOrEmpty(settings.ResultsPageUrl)) 1368 { 1369 resultAttributes.Add("data-results-page-url", settings.ResultsPageUrl); 1370 } 1371 1372 resultAttributes = resultAttributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1373 1374 string searchFieldCss = (settings.SearchButton == null) ? "search--with-icon" : ""; 1375 1376 <div class="search @settings.CssClass @searchFieldCss js-search-data-source dw-mod" id="@settings.Id" @ComponentMethods.AddAttributes(resultAttributes)> 1377 @if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1378 { 1379 <button type="button" class="search__groups-btn dw-mod js-search-groups-btn">@Translate("All")</button> 1380 <ul class="dropdown dropdown--absolute-position dw-mod search__groups-results js-search-groups-list"></ul> 1381 } 1382 1383 <input type="text" class="search__field dw-mod js-search-field" placeholder="@settings.Placeholder" value="@searchValue"> 1384 1385 <div class="dropdown dropdown--absolute-position search__results dw-mod js-search-results @(settings.SecondSearchData != null ? "search__results--combined" : "")"> 1386 @if (settings.SecondSearchData != null) 1387 { 1388 <div class="search__column search__column--products dw-mod"> 1389 <div class="search__column-header dw-mod">@Translate("Products")</div> 1390 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1391 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1392 { 1393 @Render(new Link { 1394 Title = Translate("View all"), 1395 CssClass = "js-view-all-button u-margin", 1396 Href = settings.SearchData.ResultsPageUrl 1397 }); 1398 } 1399 </div> 1400 <div class="search__column search__column--pages dw-mod"> 1401 <div class="search__column-header">@Translate("Pages")</div> 1402 <ul class="search__results-list dw-mod js-search-results-second-list" id="@(settings.Id)_SecondResultsList"></ul> 1403 @if (!string.IsNullOrEmpty(settings.SecondSearchData.ResultsPageUrl)) 1404 { 1405 @Render(new Link 1406 { 1407 Title = Translate("View all"), 1408 CssClass = "js-view-all-button u-margin", 1409 Href = settings.SecondSearchData.ResultsPageUrl 1410 }); 1411 } 1412 </div> 1413 } 1414 else 1415 { 1416 <div class="search__column search__column--only dw-mod"> 1417 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1418 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1419 { 1420 @Render(new Link { 1421 Title = Translate("View all"), 1422 CssClass = "js-view-all-button u-margin", 1423 Href = settings.SearchData.ResultsPageUrl 1424 }); 1425 } 1426 </div> 1427 } 1428 </div> 1429 1430 @if (settings.SearchButton != null) 1431 { 1432 settings.SearchButton.CssClass += " search__btn js-search-btn"; 1433 if (settings.RenderDefaultSearchIcon) 1434 { 1435 settings.SearchButton.Icon = new Icon { Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue }; 1436 } 1437 @Render(settings.SearchButton); 1438 } 1439 </div> 1440 } 1441 @using System.Reflection 1442 @using Dynamicweb.Rapido.Blocks.Components.General 1443 @using Dynamicweb.Rapido.Blocks.Components 1444 1445 1446 @* Component *@ 1447 1448 @helper RenderSelectField(SelectField settings) 1449 { 1450 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1451 { 1452 settings.Id = Guid.NewGuid().ToString("N"); 1453 } 1454 1455 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1456 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1457 { 1458 <div class="u-full-width"> 1459 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1460 @if (settings.Link != null) { 1461 <div class="u-pull--right"> 1462 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1463 @Render(settings.Link) 1464 </div> 1465 } 1466 </div> 1467 } 1468 1469 @if (!string.IsNullOrEmpty(settings.HelpText)) 1470 { 1471 <small class="form__help-text">@settings.HelpText</small> 1472 } 1473 1474 @if (settings.ActionButton != null) 1475 { 1476 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1477 <div class="form__field-combi u-no-margin dw-mod"> 1478 @RenderSelectBase(settings) 1479 @Render(settings.ActionButton) 1480 </div> 1481 } 1482 else 1483 { 1484 @RenderSelectBase(settings) 1485 } 1486 1487 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1488 </div> 1489 } 1490 1491 @helper RenderSelectBase(SelectField settings) 1492 { 1493 var attributes = new Dictionary<string, string>(); 1494 1495 /*base settings*/ 1496 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1497 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1498 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1499 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1500 if (settings.Required) { attributes.Add("required", "true"); } 1501 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1502 /*end*/ 1503 1504 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1505 1506 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1507 @if (settings.Default != null) 1508 { 1509 @Render(settings.Default) 1510 } 1511 1512 @foreach (var item in settings.Options) 1513 { 1514 if (settings.Value != null) { 1515 item.Checked = item.Value == settings.Value; 1516 } 1517 @Render(item) 1518 } 1519 </select> 1520 } 1521 @using System.Reflection 1522 @using Dynamicweb.Rapido.Blocks.Components.General 1523 @using Dynamicweb.Rapido.Blocks.Components 1524 1525 @* Component *@ 1526 1527 @helper RenderRadioButtonField(RadioButtonField settings) 1528 { 1529 var attributes = new Dictionary<string, string>(); 1530 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1531 { 1532 settings.Id = Guid.NewGuid().ToString("N"); 1533 } 1534 1535 /*base settings*/ 1536 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1537 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1538 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1539 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1540 if (settings.Required) { attributes.Add("required", "true"); } 1541 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1542 /*end*/ 1543 1544 attributes.Add("type", "radio"); 1545 if (settings.Checked) { attributes.Add("checked", "true"); } 1546 settings.CssClass = "form__control " + settings.CssClass; 1547 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1548 1549 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1550 1551 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1552 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1553 @if (!string.IsNullOrEmpty(settings.Label)) 1554 { 1555 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1556 } 1557 @if (!string.IsNullOrEmpty(settings.HelpText)) 1558 { 1559 <small class="form__help-text">@settings.HelpText</small> 1560 } 1561 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1562 </div> 1563 } 1564 @using System.Reflection 1565 @using Dynamicweb.Rapido.Blocks.Components.General 1566 @using Dynamicweb.Rapido.Blocks.Components 1567 1568 1569 @* Component *@ 1570 1571 @helper RenderRadioButtonListField(RadioButtonListField settings) 1572 { 1573 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1574 1575 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1576 @if (!string.IsNullOrEmpty(settings.Label)) 1577 { 1578 <label>@settings.Label</label> 1579 } 1580 @if (!string.IsNullOrEmpty(settings.HelpText)) 1581 { 1582 <small class="form__help-text">@settings.HelpText</small> 1583 } 1584 1585 @foreach (var item in settings.Options) 1586 { 1587 if (settings.Required) 1588 { 1589 item.Required = true; 1590 } 1591 if (settings.Disabled) 1592 { 1593 item.Disabled = true; 1594 } 1595 if (!string.IsNullOrEmpty(settings.Name)) 1596 { 1597 item.Name = settings.Name; 1598 } 1599 if (settings.Value != null && settings.Value == item.Value) 1600 { 1601 item.Checked = true; 1602 } 1603 if (!string.IsNullOrEmpty(settings.OnClick)) 1604 { 1605 item.OnClick += settings.OnClick; 1606 } 1607 if (!string.IsNullOrEmpty(settings.OnChange)) 1608 { 1609 item.OnChange += settings.OnChange; 1610 } 1611 if (!string.IsNullOrEmpty(settings.CssClass)) 1612 { 1613 item.CssClass += settings.CssClass; 1614 } 1615 @Render(item) 1616 } 1617 1618 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1619 </div> 1620 } 1621 @using System.Reflection 1622 @using Dynamicweb.Rapido.Blocks.Components.General 1623 @using Dynamicweb.Rapido.Blocks.Components 1624 1625 1626 @* Component *@ 1627 1628 @helper RenderNotificationMessage(NotificationMessage settings) 1629 { 1630 if (!string.IsNullOrEmpty(settings.Message)) 1631 { 1632 var attributes = new Dictionary<string, string>(); 1633 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1634 1635 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1636 string messageLayoutClass = Enum.GetName(typeof(NotificationMessageLayout), settings.MessageLayout).ToLower(); 1637 string minHeightClass = settings.Icon != null ? "u-min-h70px" : ""; 1638 1639 <div class="notification-message-@messageTypeClass notification-message-@messageLayoutClass @messageLayoutClass @minHeightClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)> 1640 @if (settings.Icon != null) { 1641 settings.Icon.Label = !string.IsNullOrEmpty(settings.Icon.Label) ? settings.Message + settings.Icon.Label : settings.Message; 1642 @Render(settings.Icon) 1643 } else { 1644 @settings.Message 1645 } 1646 </div> 1647 } 1648 } 1649 @using Dynamicweb.Rapido.Blocks.Components.General 1650 1651 1652 @* Component *@ 1653 1654 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1655 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1656 1657 <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> 1658 @if (settings.SubBlocks != null) { 1659 @RenderBlockList(settings.SubBlocks) 1660 } 1661 </div> 1662 } 1663 @using System.Reflection 1664 @using Dynamicweb.Rapido.Blocks.Components.General 1665 @using Dynamicweb.Rapido.Blocks.Components 1666 @using System.Text.RegularExpressions 1667 1668 1669 @* Component *@ 1670 1671 @helper RenderSticker(Sticker settings) { 1672 if (!String.IsNullOrEmpty(settings.Title)) { 1673 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1674 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1675 1676 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1677 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1678 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1679 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1680 optionalAttributes.Add("style", styleTag); 1681 } 1682 1683 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1684 } 1685 } 1686 1687 @using System.Reflection 1688 @using Dynamicweb.Rapido.Blocks.Components.General 1689 @using Dynamicweb.Rapido.Blocks.Components 1690 1691 1692 @* Component *@ 1693 1694 @helper RenderStickersCollection(StickersCollection settings) 1695 { 1696 if (settings.Stickers.Count > 0) 1697 { 1698 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1699 1700 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1701 @foreach (Sticker sticker in settings.Stickers) 1702 { 1703 @Render(sticker) 1704 } 1705 </div> 1706 } 1707 } 1708 1709 @using Dynamicweb.Rapido.Blocks.Components.General 1710 1711 1712 @* Component *@ 1713 1714 @helper RenderForm(Form settings) { 1715 if (settings != null) 1716 { 1717 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1718 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1719 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1720 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1721 var enctypes = new Dictionary<string, string> 1722 { 1723 { "multipart", "multipart/form-data" }, 1724 { "text", "text/plain" }, 1725 { "application", "application/x-www-form-urlencoded" } 1726 }; 1727 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1728 optionalAttributes.Add("method", settings.Method.ToString()); 1729 1730 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1731 { 1732 @settings.FormStartMarkup 1733 } 1734 else 1735 { 1736 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1737 } 1738 1739 foreach (var field in settings.GetFields()) 1740 { 1741 @Render(field) 1742 } 1743 1744 @:</form> 1745 } 1746 } 1747 @using System.Reflection 1748 @using Dynamicweb.Rapido.Blocks.Components.General 1749 @using Dynamicweb.Rapido.Blocks.Components 1750 1751 1752 @* Component *@ 1753 1754 @helper RenderText(Text settings) 1755 { 1756 @settings.Content 1757 } 1758 @using System.Reflection 1759 @using Dynamicweb.Rapido.Blocks.Components.General 1760 @using Dynamicweb.Rapido.Blocks.Components 1761 1762 1763 @* Component *@ 1764 1765 @helper RenderContentModule(ContentModule settings) { 1766 if (!string.IsNullOrEmpty(settings.Content)) 1767 { 1768 @settings.Content 1769 } 1770 } 1771 @using System.Reflection 1772 @using Dynamicweb.Rapido.Blocks.Components.General 1773 @using Dynamicweb.Rapido.Blocks.Components 1774 1775 1776 @* Component *@ 1777 1778 @helper RenderModal(Modal settings) { 1779 if (settings != null) 1780 { 1781 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1782 1783 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1784 1785 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1786 1787 <div class="modal-container"> 1788 @if (!settings.DisableDarkOverlay) 1789 { 1790 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1791 } 1792 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1793 @if (settings.Heading != null) 1794 { 1795 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1796 { 1797 <div class="modal__header"> 1798 @Render(settings.Heading) 1799 </div> 1800 } 1801 } 1802 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1803 @if (!string.IsNullOrEmpty(settings.BodyText)) 1804 { 1805 @settings.BodyText 1806 } 1807 @if (settings.BodyTemplate != null) 1808 { 1809 @settings.BodyTemplate 1810 } 1811 @{ 1812 var actions = settings.GetActions(); 1813 } 1814 </div> 1815 @if (actions.Length > 0) 1816 { 1817 <div class="modal__footer"> 1818 @foreach (var action in actions) 1819 { 1820 if (Pageview.Device.ToString() != "Mobile") { 1821 action.CssClass += " u-no-margin"; 1822 } else { 1823 action.CssClass += " u-full-width u-margin-bottom"; 1824 } 1825 1826 @Render(action) 1827 } 1828 </div> 1829 } 1830 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1831 </div> 1832 </div> 1833 } 1834 } 1835 @using Dynamicweb.Rapido.Blocks.Components.General 1836 1837 @* Component *@ 1838 1839 @helper RenderMediaListItem(MediaListItem settings) 1840 { 1841 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1842 @if (!string.IsNullOrEmpty(settings.Label)) 1843 { 1844 if (!string.IsNullOrEmpty(settings.Link)) 1845 { 1846 @Render(new Link 1847 { 1848 Href = settings.Link, 1849 CssClass = "media-list-item__sticker dw-mod", 1850 ButtonLayout = ButtonLayout.None, 1851 Title = settings.Label, 1852 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1853 }) 1854 } 1855 else if (!string.IsNullOrEmpty(settings.OnClick)) 1856 { 1857 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1858 <span class="u-uppercase">@settings.Label</span> 1859 </span> 1860 } 1861 else 1862 { 1863 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1864 <span class="u-uppercase">@settings.Label</span> 1865 </span> 1866 } 1867 } 1868 <div class="media-list-item__wrap"> 1869 <div class="media-list-item__info dw-mod"> 1870 <div class="media-list-item__header dw-mod"> 1871 @if (!string.IsNullOrEmpty(settings.Title)) 1872 { 1873 if (!string.IsNullOrEmpty(settings.Link)) 1874 { 1875 @Render(new Link 1876 { 1877 Href = settings.Link, 1878 CssClass = "media-list-item__name dw-mod", 1879 ButtonLayout = ButtonLayout.None, 1880 Title = settings.Title, 1881 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1882 }) 1883 } 1884 else if (!string.IsNullOrEmpty(settings.OnClick)) 1885 { 1886 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1887 } 1888 else 1889 { 1890 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1891 } 1892 } 1893 1894 @if (!string.IsNullOrEmpty(settings.Status)) 1895 { 1896 <div class="media-list-item__state dw-mod">@settings.Status</div> 1897 } 1898 </div> 1899 @{ 1900 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1901 } 1902 1903 @Render(settings.InfoTable) 1904 </div> 1905 <div class="media-list-item__actions dw-mod"> 1906 <div class="media-list-item__actions-list dw-mod"> 1907 @{ 1908 var actions = settings.GetActions(); 1909 1910 foreach (ButtonBase action in actions) 1911 { 1912 action.ButtonLayout = ButtonLayout.None; 1913 action.CssClass += " media-list-item__action link"; 1914 1915 @Render(action) 1916 } 1917 } 1918 </div> 1919 1920 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1921 { 1922 settings.SelectButton.CssClass += " u-no-margin"; 1923 1924 <div class="media-list-item__action-button"> 1925 @Render(settings.SelectButton) 1926 </div> 1927 } 1928 </div> 1929 </div> 1930 </div> 1931 } 1932 @using Dynamicweb.Rapido.Blocks.Components.General 1933 @using Dynamicweb.Rapido.Blocks.Components 1934 1935 @helper RenderTable(Table settings) 1936 { 1937 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1938 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1939 1940 var enumToClasses = new Dictionary<TableDesign, string> 1941 { 1942 { TableDesign.Clean, "table--clean" }, 1943 { TableDesign.Bordered, "table--bordered" }, 1944 { TableDesign.Striped, "table--striped" }, 1945 { TableDesign.Hover, "table--hover" }, 1946 { TableDesign.Compact, "table--compact" }, 1947 { TableDesign.Condensed, "table--condensed" }, 1948 { TableDesign.NoTopBorder, "table--no-top-border" } 1949 }; 1950 string tableDesignClass = ""; 1951 if (settings.Design != TableDesign.None) 1952 { 1953 tableDesignClass = enumToClasses[settings.Design]; 1954 } 1955 1956 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1957 1958 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1959 1960 <table @ComponentMethods.AddAttributes(resultAttributes)> 1961 @if (settings.Header != null) 1962 { 1963 <thead> 1964 @Render(settings.Header) 1965 </thead> 1966 } 1967 <tbody> 1968 @foreach (var row in settings.Rows) 1969 { 1970 @Render(row) 1971 } 1972 </tbody> 1973 @if (settings.Footer != null) 1974 { 1975 <tfoot> 1976 @Render(settings.Footer) 1977 </tfoot> 1978 } 1979 </table> 1980 } 1981 @using Dynamicweb.Rapido.Blocks.Components.General 1982 @using Dynamicweb.Rapido.Blocks.Components 1983 1984 @helper RenderTableRow(TableRow settings) 1985 { 1986 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1987 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1988 1989 var enumToClasses = new Dictionary<TableRowDesign, string> 1990 { 1991 { TableRowDesign.NoBorder, "table__row--no-border" }, 1992 { TableRowDesign.Border, "table__row--border" }, 1993 { TableRowDesign.TopBorder, "table__row--top-line" }, 1994 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1995 { TableRowDesign.Solid, "table__row--solid" } 1996 }; 1997 1998 string tableRowDesignClass = ""; 1999 if (settings.Design != TableRowDesign.None) 2000 { 2001 tableRowDesignClass = enumToClasses[settings.Design]; 2002 } 2003 2004 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 2005 2006 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2007 2008 <tr @ComponentMethods.AddAttributes(resultAttributes)> 2009 @foreach (var cell in settings.Cells) 2010 { 2011 if (settings.IsHeaderRow) 2012 { 2013 cell.IsHeader = true; 2014 } 2015 @Render(cell) 2016 } 2017 </tr> 2018 } 2019 @using Dynamicweb.Rapido.Blocks.Components.General 2020 @using Dynamicweb.Rapido.Blocks.Components 2021 @using Dynamicweb.Core 2022 2023 @helper RenderTableCell(TableCell settings) 2024 { 2025 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2026 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2027 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 2028 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 2029 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 2030 2031 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2032 2033 string tagName = settings.IsHeader ? "th" : "td"; 2034 2035 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 2036 @settings.Content 2037 @("</" + tagName + ">"); 2038 } 2039 @using System.Linq 2040 @using Dynamicweb.Rapido.Blocks.Components.General 2041 2042 @* Component *@ 2043 2044 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 2045 { 2046 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 2047 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 2048 2049 if (settings.NumberOfPages > 1) 2050 { 2051 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 2052 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 2053 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 2054 2055 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 2056 @if (settings.ShowPagingInfo) 2057 { 2058 <div class="pager__info dw-mod"> 2059 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 2060 </div> 2061 } 2062 <ul class="pager__list dw-mod"> 2063 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 2064 { 2065 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 2066 } 2067 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 2068 { 2069 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 2070 } 2071 @if (settings.GetPages().Any()) 2072 { 2073 foreach (var page in settings.GetPages()) 2074 { 2075 @Render(page) 2076 } 2077 } 2078 else 2079 { 2080 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 2081 { 2082 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 2083 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 2084 } 2085 } 2086 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 2087 { 2088 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 2089 } 2090 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 2091 { 2092 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 2093 } 2094 </ul> 2095 </div> 2096 } 2097 } 2098 2099 @helper RenderPaginationItem(PaginationItem settings) 2100 { 2101 if (settings.Icon == null) 2102 { 2103 settings.Icon = new Icon(); 2104 } 2105 2106 settings.Icon.Label = settings.Label; 2107 <li class="pager__btn dw-mod"> 2108 @if (settings.IsActive) 2109 { 2110 <span class="pager__num pager__num--current dw-mod"> 2111 @Render(settings.Icon) 2112 </span> 2113 } 2114 else 2115 { 2116 <a href="@settings.Link" class="pager__num dw-mod"> 2117 @Render(settings.Icon) 2118 </a> 2119 } 2120 </li> 2121 } 2122 2123 2124 @using Dynamicweb.Rapido.Blocks.Components.General 2125 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2126 2127 2128 2129 2130 2131 @functions { 2132 public string GenerateRgba(string color, string opacity) 2133 { 2134 color = color.Replace("#", ""); 2135 if (color.Length == 6) { 2136 return "rgba(" + Convert.ToInt32(color.Substring(0, 2), 16) + ", " + Convert.ToInt32(color.Substring(2, 2), 16) + ", " + Convert.ToInt32(color.Substring(4, 2), 16) + ", " + opacity + ");"; 2137 } else { 2138 return Convert.ToInt16(color).ToString(); 2139 } 2140 } 2141 } 2142 2143 @{ 2144 string link = !string.IsNullOrEmpty(Model.Item.GetString("Link")) ? Model.Item.GetString("Link") : ""; 2145 string linkTarget = link.Contains("http") ? "_blank" : "_self"; 2146 } 2147 2148 @if (!string.IsNullOrEmpty(link)) { 2149 <a href="@link" target="@linkTarget" class="u-overlay">&nbsp;</a> 2150 @RenderTheContent() 2151 } else { 2152 @RenderTheContent() 2153 } 2154 2155 @helper RenderTheContent(){ 2156 var colorService = new ColorSwatchService(); 2157 2158 string innerPadding = Model.Item.GetList("Padding") != null ? " padding-size-" + Model.Item.GetList("Padding").SelectedValue.ToLower() : ""; 2159 innerPadding += Model.Item.GetList("PaddingPosition") != null ? " padding-position-" + Model.Item.GetList("PaddingPosition").SelectedValue.ToLower() : ""; 2160 string outerMargin = Model.Item.GetList("Margin") != null ? " margin-" + Model.Item.GetList("Margin").SelectedValue.ToLower() : ""; 2161 string outerMarginPosition = Model.Item.GetList("MarginPosition") != null ? " margin-position-" + Model.Item.GetList("MarginPosition").SelectedValue.ToLower() : ""; 2162 2163 string cardBackgroundColor = Model.Item.GetString("CardBackgroundColor") != null ? Model.Item.GetString("CardBackgroundColor") : ""; 2164 cardBackgroundColor = !cardBackgroundColor.Contains("#") ? colorService.GetHexColor(Pageview.AreaID, cardBackgroundColor) : cardBackgroundColor; 2165 string styles = "background-color: " + cardBackgroundColor + ";"; 2166 if (!string.IsNullOrEmpty(Model.Item.GetString("Image"))) { 2167 int cropMode = !string.IsNullOrEmpty(Convert.ToString(Model.Item.GetList("ImageCrop"))) ? Convert.ToInt32(Model.Item.GetList("ImageCrop").SelectedValue) : 0; 2168 2169 Image image = new Image 2170 { 2171 Path = Model.Item.GetFile("Image") != null ? Model.Item.GetFile("Image").Path : "", 2172 CssClass = "background-image__cover", 2173 ImageDefault = new ImageSettings 2174 { 2175 Crop = cropMode, 2176 Height = 845, 2177 Width = 1920 2178 }, 2179 ImageMedium = new ImageSettings 2180 { 2181 Crop = cropMode, 2182 Height = 450, 2183 Width = 1024 2184 }, 2185 ImageSmall = new ImageSettings 2186 { 2187 Crop = cropMode, 2188 Height = 544, 2189 Width = 640 2190 } 2191 }; 2192 2193 image.FilterPrimary = !string.IsNullOrEmpty(Model.Item.GetList("ImageFilterPrimary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), Model.Item.GetList("ImageFilterPrimary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2194 image.FilterSecondary = !string.IsNullOrEmpty(Model.Item.GetList("ImageFilterSecondary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), Model.Item.GetList("ImageFilterSecondary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2195 2196 if (!string.IsNullOrEmpty(Model.Item.GetString("ColorForTheFilter"))) { 2197 image.FilterColor = Model.Item.GetString("ColorForTheFilter").StartsWith("#") ? GenerateRgba(Model.Item.GetString("ColorForTheFilter"), "0.3") : ""; 2198 } 2199 2200 <div class="background-image dw-mod"> 2201 <div class="background-image__wrapper dw-mod"> 2202 @Render(image) 2203 </div> 2204 </div> 2205 } 2206 2207 <div class="content-row__item__body @innerPadding @outerMargin @outerMarginPosition card-paragraph dw-mod" style="@styles"> 2208 @if (!string.IsNullOrEmpty(Model.Item.GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetString("Text"))) { 2209 if (!Model.Item.GetBoolean("HideTitle")) { 2210 @Render(new Heading { Title = Model.Item.GetString("Title"), CssClass = "u-no-margin", Level = 2 }) 2211 } 2212 @Render(new Text { Content = Model.Item.GetString("Text") }) 2213 } 2214 2215 @if (!string.IsNullOrEmpty(Model.Item.GetItem("ButtonOne").GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetItem("ButtonTwo").GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetItem("ButtonThree").GetString("Title"))) { 2216 <div> 2217 @ParagraphButton(Model.Item.GetItem("ButtonOne")) 2218 @ParagraphButton(Model.Item.GetItem("ButtonTwo")) 2219 @ParagraphButton(Model.Item.GetItem("ButtonThree")) 2220 </div> 2221 } 2222 </div> 2223 } 2224 2225 2226 @helper ParagraphButton(ItemViewModel item) { 2227 if (item != null) { 2228 if (!string.IsNullOrEmpty(item.GetString("Title"))) { 2229 Button button = new Button { 2230 Title = item.GetString("Title"), 2231 Href = item.GetString("Link"), 2232 CssClass = "u-no-margin", 2233 ButtonLayout = (ButtonLayout)System.Enum.Parse(typeof(ButtonLayout), char.ToUpper(item.GetList("Layout").SelectedValue[0]) + item.GetList("Layout").SelectedValue.Substring(1)) 2234 }; 2235 2236 if (!string.IsNullOrEmpty(item.GetString("Icon"))) { 2237 button.Icon = new Icon { 2238 CssClass = item.GetString("Icon") 2239 }; 2240 } 2241 2242 @Render(button) 2243 } 2244 } 2245 } 2246 2247 2248 2249 2250
Error executing template "Designs/Rapido/ContentPage/Paragraph/CardParagraph.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_776095055ad24d97af02f9a60cb157b4.<RenderTheContent>b__46_0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\S_DW_Thermex\Files\Templates\Designs\Rapido\ContentPage\Paragraph\CardParagraph.cshtml:line 2215
   at CompiledRazorTemplates.Dynamic.RazorEngine_776095055ad24d97af02f9a60cb157b4.Execute() in D:\Dynamicweb.net\Solutions\S_DW_Thermex\Files\Templates\Designs\Rapido\ContentPage\Paragraph\CardParagraph.cshtml:line 2152
   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.ParagraphViewModel> 2 @using Dynamicweb.Frontend 3 @using Dynamicweb.Content.Items 4 @using Dynamicweb 5 @using Dynamicweb.Rapido.Blocks.Components 6 @using Dynamicweb.Rapido.Blocks.Components.General 7 8 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 9 @using Dynamicweb.Frontend 10 11 @* Include the components *@ 12 @using System.Text.RegularExpressions 13 @using System.Collections.Generic 14 @using System.Reflection 15 @using System.Web 16 @using System.Web.UI.HtmlControls 17 @using Dynamicweb.Rapido.Blocks.Components 18 @using Dynamicweb.Rapido.Blocks.Components.Articles 19 @using Dynamicweb.Rapido.Blocks.Components.Documentation 20 @using Dynamicweb.Rapido.Blocks 21 22 23 @*--- START: Base block renderers ---*@ 24 25 @helper RenderBlockList(List<Block> blocks) 26 { 27 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 28 blocks = blocks.OrderBy(item => item.SortId).ToList(); 29 30 foreach (Block item in blocks) 31 { 32 if (debug) { 33 <!-- Block START: @item.Id --> 34 } 35 36 if (item.Design == null) 37 { 38 @RenderBlock(item) 39 } 40 else if (item.Design.RenderType == RenderType.None) { 41 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 42 43 <div class="@cssClass dw-mod"> 44 @RenderBlock(item) 45 </div> 46 } 47 else if (item.Design.RenderType != RenderType.Hide) 48 { 49 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 50 51 if (!item.SkipRenderBlocksList) { 52 if (item.Design.RenderType == RenderType.Row) 53 { 54 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 55 @RenderBlock(item) 56 </div> 57 } 58 59 if (item.Design.RenderType == RenderType.Column) 60 { 61 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 62 string size = item.Design.Size ?? "12"; 63 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 64 65 <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"> 66 @RenderBlock(item) 67 </div> 68 } 69 70 if (item.Design.RenderType == RenderType.Table) 71 { 72 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 73 @RenderBlock(item) 74 </table> 75 } 76 77 if (item.Design.RenderType == RenderType.TableRow) 78 { 79 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 80 @RenderBlock(item) 81 </tr> 82 } 83 84 if (item.Design.RenderType == RenderType.TableColumn) 85 { 86 <td class="@cssClass dw-mod" id="Block__@item.Id"> 87 @RenderBlock(item) 88 </td> 89 } 90 91 if (item.Design.RenderType == RenderType.CardHeader) 92 { 93 <div class="card-header @cssClass dw-mod"> 94 @RenderBlock(item) 95 </div> 96 } 97 98 if (item.Design.RenderType == RenderType.CardBody) 99 { 100 <div class="card @cssClass dw-mod"> 101 @RenderBlock(item) 102 </div> 103 } 104 105 if (item.Design.RenderType == RenderType.CardFooter) 106 { 107 <div class="card-footer @cssClass dw-mod"> 108 @RenderBlock(item) 109 </div> 110 } 111 } 112 else 113 { 114 @RenderBlock(item) 115 } 116 } 117 118 if (debug) { 119 <!-- Block END: @item.Id --> 120 } 121 } 122 } 123 124 @helper RenderBlock(Block item) 125 { 126 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 127 128 if (item.Template != null) 129 { 130 @BlocksPage.RenderTemplate(item.Template) 131 } 132 133 if (item.Component != null) 134 { 135 string customSufix = "Custom"; 136 string methodName = item.Component.HelperName; 137 138 ComponentBase[] methodParameters = new ComponentBase[1]; 139 methodParameters[0] = item.Component; 140 Type methodType = this.GetType(); 141 142 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 143 144 try { 145 if (debug) { 146 <!-- Component: @methodName.Replace("Render", "") --> 147 } 148 if(customMethod != null) { 149 @customMethod.Invoke(this, methodParameters).ToString(); 150 } else { 151 MethodInfo generalMethod = methodType.GetMethod(methodName); 152 @generalMethod.Invoke(this, methodParameters).ToString(); 153 } 154 } catch { 155 try { 156 MethodInfo generalMethod = methodType.GetMethod(methodName); 157 @generalMethod.Invoke(this, methodParameters).ToString(); 158 } catch(Exception ex) { 159 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 160 } 161 } 162 } 163 164 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 165 { 166 @RenderBlockList(item.BlocksList) 167 } 168 } 169 170 @*--- END: Base block renderers ---*@ 171 172 @using Dynamicweb.Rapido.Blocks.Components 173 @using Dynamicweb.Rapido.Blocks.Components.General 174 @using Dynamicweb.Rapido.Blocks 175 @using System.IO 176 177 @* Required *@ 178 @using Dynamicweb.Rapido.Blocks.Components 179 @using Dynamicweb.Rapido.Blocks.Components.General 180 @using Dynamicweb.Rapido.Blocks 181 182 183 @helper Render(ComponentBase component) 184 { 185 if (component != null) 186 { 187 @component.Render(this) 188 } 189 } 190 191 @* Components *@ 192 @using System.Reflection 193 @using Dynamicweb.Rapido.Blocks.Components.General 194 195 196 @* Component *@ 197 198 @helper RenderIcon(Icon settings) 199 { 200 if (settings != null) 201 { 202 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 203 204 if (settings.Name != null) 205 { 206 if (string.IsNullOrEmpty(settings.Label)) 207 { 208 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 209 } 210 else 211 { 212 if (settings.LabelPosition == IconLabelPosition.Before) 213 { 214 <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> 215 } 216 else 217 { 218 <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> 219 } 220 } 221 } 222 else if (!string.IsNullOrEmpty(settings.Label)) 223 { 224 @settings.Label 225 } 226 } 227 } 228 @using System.Reflection 229 @using Dynamicweb.Rapido.Blocks.Components.General 230 @using Dynamicweb.Rapido.Blocks.Components 231 @using Dynamicweb.Core 232 233 @* Component *@ 234 235 @helper RenderButton(Button settings) 236 { 237 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 238 { 239 Dictionary<string, string> attributes = new Dictionary<string, string>(); 240 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 241 if (settings.Disabled) { 242 attributes.Add("disabled", "true"); 243 classList.Add("disabled"); 244 } 245 246 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 247 { 248 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 249 @RenderConfirmDialog(settings); 250 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 251 } 252 253 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 254 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 255 if (!string.IsNullOrEmpty(settings.AltText)) 256 { 257 attributes.Add("title", settings.AltText); 258 } 259 else if (!string.IsNullOrEmpty(settings.Title)) 260 { 261 string cleanTitle = Regex.Replace(settings.Title, "<.*?>", String.Empty); 262 cleanTitle = cleanTitle.Replace("&nbsp;", " "); 263 attributes.Add("title", cleanTitle); 264 } 265 266 var onClickEvents = new List<string>(); 267 if (!string.IsNullOrEmpty(settings.OnClick)) 268 { 269 onClickEvents.Add(settings.OnClick); 270 } 271 if (!string.IsNullOrEmpty(settings.Href)) 272 { 273 onClickEvents.Add("location.href='" + settings.Href + "'"); 274 } 275 if (onClickEvents.Count > 0) 276 { 277 attributes.Add("onClick", string.Join(";", onClickEvents)); 278 } 279 280 if (settings.ButtonLayout != ButtonLayout.None) 281 { 282 classList.Add("btn"); 283 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 284 if (btnLayout == "linkclean") 285 { 286 btnLayout = "link-clean"; //fix 287 } 288 classList.Add("btn--" + btnLayout); 289 } 290 291 if (settings.Icon == null) 292 { 293 settings.Icon = new Icon(); 294 } 295 296 settings.Icon.CssClass += Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower() != "linkclean" ? " u-flex--align-center" : ""; 297 settings.Icon.Label = settings.Title; 298 299 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 300 301 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 302 } 303 } 304 305 @helper RenderConfirmDialog(Button settings) 306 { 307 Modal confirmDialog = new Modal { 308 Id = settings.Id, 309 Width = ModalWidth.Sm, 310 Heading = new Heading 311 { 312 Level = 2, 313 Title = settings.ConfirmTitle 314 }, 315 BodyText = settings.ConfirmText 316 }; 317 318 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 319 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 320 321 @Render(confirmDialog) 322 } 323 @using Dynamicweb.Rapido.Blocks.Components.General 324 @using Dynamicweb.Rapido.Blocks.Components 325 @using Dynamicweb.Core 326 327 @helper RenderDashboard(Dashboard settings) 328 { 329 var widgets = settings.GetWidgets(); 330 331 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 332 { 333 //set bg color for them 334 335 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 336 int r = Convert.ToInt16(color.R); 337 int g = Convert.ToInt16(color.G); 338 int b = Convert.ToInt16(color.B); 339 340 var count = widgets.Length; 341 var max = Math.Max(r, Math.Max(g, b)); 342 double step = 255.0 / (max * count); 343 var i = 0; 344 foreach (var widget in widgets) 345 { 346 i++; 347 348 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 349 widget.BackgroundColor = shade; 350 } 351 } 352 353 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 354 @foreach (var widget in widgets) 355 { 356 <div class="dashboard__widget"> 357 @Render(widget) 358 </div> 359 } 360 </div> 361 } 362 @using Dynamicweb.Rapido.Blocks.Components.General 363 @using Dynamicweb.Rapido.Blocks.Components 364 365 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 366 { 367 if (!string.IsNullOrEmpty(settings.Link)) 368 { 369 var backgroundStyles = ""; 370 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 371 { 372 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 373 } 374 375 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 376 <div class="u-center-middle u-color-light"> 377 @if (settings.Icon != null) 378 { 379 settings.Icon.CssClass += "widget__icon"; 380 @Render(settings.Icon) 381 } 382 <div class="widget__title">@settings.Title</div> 383 </div> 384 </a> 385 } 386 } 387 @using Dynamicweb.Rapido.Blocks.Components.General 388 @using Dynamicweb.Rapido.Blocks.Components 389 390 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 391 { 392 var backgroundStyles = ""; 393 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 394 { 395 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 396 } 397 398 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 399 <div class="u-center-middle u-color-light"> 400 @if (settings.Icon != null) 401 { 402 settings.Icon.CssClass += "widget__icon"; 403 @Render(settings.Icon) 404 } 405 <div class="widget__counter">@settings.Count</div> 406 <div class="widget__title">@settings.Title</div> 407 </div> 408 </div> 409 } 410 @using System.Reflection 411 @using Dynamicweb.Rapido.Blocks.Components.General 412 @using Dynamicweb.Rapido.Blocks.Components 413 @using Dynamicweb.Core 414 415 @* Component *@ 416 417 @helper RenderLink(Link settings) 418 { 419 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 420 { 421 Dictionary<string, string> attributes = new Dictionary<string, string>(); 422 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 423 if (settings.Disabled) 424 { 425 attributes.Add("disabled", "true"); 426 classList.Add("disabled"); 427 } 428 429 if (!string.IsNullOrEmpty(settings.AltText)) 430 { 431 attributes.Add("title", settings.AltText); 432 } 433 else if (!string.IsNullOrEmpty(settings.Title)) 434 { 435 attributes.Add("title", settings.Title); 436 } 437 438 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 439 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 440 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 441 attributes.Add("href", settings.Href); 442 443 if (settings.ButtonLayout != ButtonLayout.None) 444 { 445 classList.Add("btn"); 446 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 447 if (btnLayout == "linkclean") 448 { 449 btnLayout = "link-clean"; //fix 450 } 451 classList.Add("btn--" + btnLayout); 452 } 453 454 if (settings.Icon == null) 455 { 456 settings.Icon = new Icon(); 457 } 458 settings.Icon.Label = settings.Title; 459 460 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 461 { 462 settings.Rel = LinkRelType.Noopener; 463 } 464 if (settings.Target != LinkTargetType.None) 465 { 466 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 467 } 468 if (settings.Download) 469 { 470 attributes.Add("download", "true"); 471 } 472 if (settings.Rel != LinkRelType.None) 473 { 474 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 475 } 476 477 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 478 } 479 } 480 @using System.Reflection 481 @using Dynamicweb.Rapido.Blocks.Components 482 @using Dynamicweb.Rapido.Blocks.Components.General 483 @using Dynamicweb.Rapido.Blocks 484 485 486 @* Component *@ 487 488 @helper RenderRating(Rating settings) 489 { 490 if (settings.Score > 0) 491 { 492 int rating = settings.Score; 493 string iconType = "fa-star"; 494 495 switch (settings.Type.ToString()) { 496 case "Stars": 497 iconType = "fa-star"; 498 break; 499 case "Hearts": 500 iconType = "fa-heart"; 501 break; 502 case "Lemons": 503 iconType = "fa-lemon"; 504 break; 505 case "Bombs": 506 iconType = "fa-bomb"; 507 break; 508 } 509 510 <div class="u-ta-right"> 511 @for (int i = 0; i < settings.OutOf; i++) 512 { 513 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 514 } 515 </div> 516 } 517 } 518 @using System.Reflection 519 @using Dynamicweb.Rapido.Blocks.Components.General 520 @using Dynamicweb.Rapido.Blocks.Components 521 522 523 @* Component *@ 524 525 @helper RenderSelectFieldOption(SelectFieldOption settings) 526 { 527 Dictionary<string, string> attributes = new Dictionary<string, string>(); 528 if (settings.Checked) { attributes.Add("selected", "true"); } 529 if (settings.Disabled) { attributes.Add("disabled", "true"); } 530 if (settings.Value != null) { attributes.Add("value", settings.Value); } 531 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 532 533 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 534 } 535 @using System.Reflection 536 @using Dynamicweb.Rapido.Blocks.Components.General 537 @using Dynamicweb.Rapido.Blocks.Components 538 539 540 @* Component *@ 541 542 @helper RenderNavigation(Navigation settings) { 543 @RenderNavigation(new 544 { 545 id = settings.Id, 546 cssclass = settings.CssClass, 547 startLevel = settings.StartLevel, 548 endlevel = settings.EndLevel, 549 expandmode = settings.Expandmode, 550 sitemapmode = settings.SitemapMode, 551 template = settings.Template 552 }) 553 } 554 @using Dynamicweb.Rapido.Blocks.Components.General 555 @using Dynamicweb.Rapido.Blocks.Components 556 557 558 @* Component *@ 559 560 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 561 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 562 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 563 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 564 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 565 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 566 settings.SitemapMode = false; 567 568 @RenderNavigation(settings) 569 } 570 @using Dynamicweb.Rapido.Blocks.Components.General 571 @using Dynamicweb.Rapido.Blocks.Components 572 573 574 @* Component *@ 575 576 @helper RenderLeftNavigation(LeftNavigation settings) { 577 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 578 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 579 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 580 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 581 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 582 583 <div class="grid__cell"> 584 @RenderNavigation(settings) 585 </div> 586 } 587 @using System.Reflection 588 @using Dynamicweb.Rapido.Blocks.Components.General 589 @using Dynamicweb.Core 590 591 @* Component *@ 592 593 @helper RenderHeading(Heading settings) 594 { 595 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 596 { 597 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 598 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 599 600 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 601 if (!string.IsNullOrEmpty(settings.Link)) 602 { 603 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 604 } 605 else 606 { 607 if (settings.Icon == null) 608 { 609 settings.Icon = new Icon(); 610 } 611 settings.Icon.Label = settings.Title; 612 @Render(settings.Icon) 613 } 614 @("</" + tagName + ">"); 615 } 616 } 617 @using Dynamicweb.Rapido.Blocks.Components 618 @using Dynamicweb.Rapido.Blocks.Components.General 619 @using Dynamicweb.Rapido.Blocks 620 621 622 @* Component *@ 623 624 @helper RenderImage(Image settings) 625 { 626 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 627 { 628 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 629 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 630 631 if (settings.Caption != null) 632 { 633 @:<div> 634 } 635 636 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 637 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 638 639 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 640 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 641 @if (settings.Link != null) 642 { 643 <a href="@settings.Link"> 644 @RenderTheImage(settings) 645 </a> 646 } 647 else 648 { 649 @RenderTheImage(settings) 650 } 651 </div> 652 </div> 653 654 if (settings.Caption != null) 655 { 656 <span class="image-caption dw-mod">@settings.Caption</span> 657 @:</div> 658 } 659 } 660 else 661 { 662 if (settings.Caption != null) 663 { 664 @:<div> 665 } 666 if (!string.IsNullOrEmpty(settings.Link)) 667 { 668 <a href="@settings.Link"> 669 @RenderTheImage(settings) 670 </a> 671 } 672 else 673 { 674 @RenderTheImage(settings) 675 } 676 677 if (settings.Caption != null) 678 { 679 <span class="image-caption dw-mod">@settings.Caption</span> 680 @:</div> 681 } 682 } 683 } 684 685 @helper RenderTheImage(Image settings) 686 { 687 if (settings != null) 688 { 689 string alternativeImage = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("AlternativeImage")) ? Pageview.AreaSettings.GetItem("Settings").GetFile("AlternativeImage").PathUrlEncoded : "/Images/missing_image.jpg"; 690 string placeholderImage = "/Files/Images/placeholder.gif"; 691 string imageEngine = "/Admin/Public/GetImage.ashx?"; 692 693 string imageStyle = ""; 694 695 switch (settings.Style) 696 { 697 case ImageStyle.Ball: 698 imageStyle = "grid__cell-img--ball"; 699 break; 700 701 case ImageStyle.Triangle: 702 imageStyle = "grid__cell-img--triangle"; 703 break; 704 } 705 706 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle || settings.Style == ImageStyle.Triangle) 707 { 708 settings.ImageDefault.Crop = settings.ImageDefault.Crop == 5 ? settings.ImageDefault.Crop = 0 : settings.ImageDefault.Crop; 709 710 if (settings.ImageDefault != null) 711 { 712 settings.ImageDefault.Height = settings.ImageDefault.Width; 713 } 714 if (settings.ImageMedium != null) 715 { 716 settings.ImageMedium.Height = settings.ImageMedium.Width; 717 } 718 if (settings.ImageSmall != null) 719 { 720 settings.ImageSmall.Height = settings.ImageSmall.Width; 721 } 722 } 723 724 string defaultImage = imageEngine; 725 string imageSmall = ""; 726 string imageMedium = ""; 727 728 if (settings.DisableImageEngine) 729 { 730 defaultImage = settings.Path; 731 } 732 else 733 { 734 if (settings.ImageDefault != null) 735 { 736 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 737 738 if (settings.Path.GetType() != typeof(string)) 739 { 740 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 741 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 742 } 743 else 744 { 745 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 746 } 747 748 defaultImage += "&AlternativeImage=" + alternativeImage; 749 } 750 751 if (settings.ImageSmall != null) 752 { 753 imageSmall = "data-src-small=\"" + imageEngine; 754 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 755 756 if (settings.Path.GetType() != typeof(string)) 757 { 758 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 759 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 760 } 761 else 762 { 763 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 764 } 765 766 imageSmall += "&alternativeImage=" + alternativeImage; 767 768 imageSmall += "\""; 769 } 770 771 if (settings.ImageMedium != null) 772 { 773 imageMedium = "data-src-medium=\"" + imageEngine; 774 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 775 776 if (settings.Path.GetType() != typeof(string)) 777 { 778 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 779 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 780 } 781 else 782 { 783 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 784 } 785 786 imageMedium += "&alternativeImage=" + alternativeImage; 787 788 imageMedium += "\""; 789 } 790 } 791 792 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 793 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 794 if (!string.IsNullOrEmpty(settings.Title)) 795 { 796 optionalAttributes.Add("alt", settings.Title); 797 optionalAttributes.Add("title", settings.Title); 798 } 799 800 if (settings.DisableLazyLoad) 801 { 802 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 803 } 804 else 805 { 806 <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) /> 807 } 808 } 809 } 810 @using System.Reflection 811 @using Dynamicweb.Rapido.Blocks.Components.General 812 @using Dynamicweb.Rapido.Blocks.Components 813 814 @* Component *@ 815 816 @helper RenderFileField(FileField settings) 817 { 818 var attributes = new Dictionary<string, string>(); 819 if (string.IsNullOrEmpty(settings.Id)) 820 { 821 settings.Id = Guid.NewGuid().ToString("N"); 822 } 823 824 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 825 if (settings.Disabled) { attributes.Add("disabled", "true"); } 826 if (settings.Required) { attributes.Add("required", "true"); } 827 if (settings.Multiple) { attributes.Add("multiple", "true"); } 828 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 829 if (string.IsNullOrEmpty(settings.ChooseFileText)) 830 { 831 settings.ChooseFileText = Translate("Choose file"); 832 } 833 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 834 { 835 settings.NoFilesChosenText = Translate("No files chosen..."); 836 } 837 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 838 839 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 840 841 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 842 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 843 844 attributes.Add("type", "file"); 845 if (settings.Value != null) { attributes.Add("value", settings.Value); } 846 settings.CssClass = "u-full-width " + settings.CssClass; 847 848 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 849 850 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 851 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 852 { 853 <div class="u-full-width"> 854 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 855 @if (settings.Link != null) { 856 <div class="u-pull--right"> 857 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 858 @Render(settings.Link) 859 </div> 860 } 861 </div> 862 863 } 864 865 @if (!string.IsNullOrEmpty(settings.HelpText)) 866 { 867 <small class="form__help-text">@settings.HelpText</small> 868 } 869 870 <div class="form__field-combi file-input u-no-margin dw-mod"> 871 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 872 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 873 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 874 @if (settings.UploadButton != null) 875 { 876 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 877 @Render(settings.UploadButton) 878 } 879 </div> 880 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 881 </div> 882 } 883 @using System.Reflection 884 @using Dynamicweb.Rapido.Blocks.Components.General 885 @using Dynamicweb.Rapido.Blocks.Components 886 @using Dynamicweb.Core 887 @using System.Linq 888 889 @* Component *@ 890 891 @helper RenderDateTimeField(DateTimeField settings) 892 { 893 if (string.IsNullOrEmpty(settings.Id)) 894 { 895 settings.Id = Guid.NewGuid().ToString("N"); 896 } 897 if (settings.ExtraAttributes == null) 898 { 899 settings.ExtraAttributes = new Dictionary<string, string>(); 900 } 901 settings.ExtraAttributes.Add("autocomplete","off"); 902 var textField = new TextField { 903 Name = settings.Name, 904 Id = settings.Id, 905 Label = settings.Label, 906 HelpText = settings.HelpText, 907 Value = settings.Value, 908 Disabled = settings.Disabled, 909 Required = settings.Required, 910 ErrorMessage = settings.ErrorMessage, 911 CssClass = settings.CssClass, 912 WrapperCssClass = settings.WrapperCssClass, 913 OnChange = settings.OnChange, 914 OnClick = settings.OnClick, 915 Link = settings.Link, 916 ExtraAttributes = settings.ExtraAttributes, 917 // 918 Placeholder = settings.Placeholder 919 }; 920 921 @Render(textField) 922 923 List<string> jsAttributes = new List<string>(); 924 925 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 926 927 if (!string.IsNullOrEmpty(settings.DateFormat)) 928 { 929 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 930 } 931 if (!string.IsNullOrEmpty(settings.MinDate)) 932 { 933 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 934 } 935 if (!string.IsNullOrEmpty(settings.MaxDate)) 936 { 937 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 938 } 939 if (settings.IsInline) 940 { 941 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 942 } 943 if (settings.EnableTime) 944 { 945 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 946 } 947 if (settings.EnableWeekNumbers) 948 { 949 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 950 } 951 952 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 953 954 <script> 955 document.addEventListener( "DOMContentLoaded", function () { 956 flatpickr("#@textField.Id", { 957 onReady: function(selectedDates, dateStr, instance) { 958 instance.input.readOnly = false; 959 }, 960 onOpen: function(selectedDates, dateStr, instance) { 961 instance.input.readOnly = true; 962 }, 963 onClose: function(selectedDates, dateStr, instance) { 964 instance.input.readOnly = false; 965 //instance.input.blur(); 966 }, 967 @string.Join(",", jsAttributes) 968 } ) 969 } ); 970 </script> 971 } 972 @using System.Reflection 973 @using Dynamicweb.Rapido.Blocks.Components.General 974 @using Dynamicweb.Rapido.Blocks.Components 975 976 @* Component *@ 977 978 @helper RenderTextField(TextField settings) 979 { 980 var attributes = new Dictionary<string, string>(); 981 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 982 { 983 settings.Id = Guid.NewGuid().ToString("N"); 984 } 985 986 /*base settings*/ 987 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 988 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 989 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 990 if (settings.Disabled) { attributes.Add("disabled", "true"); } 991 if (settings.Required) { attributes.Add("required", "true"); } 992 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 993 /*end*/ 994 995 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 996 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 997 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 998 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 999 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1000 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1001 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1002 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1003 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1004 1005 settings.CssClass = "u-full-width " + settings.CssClass; 1006 1007 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1008 1009 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1010 1011 string noMargin = "u-no-margin"; 1012 if (!settings.ReadOnly) { 1013 noMargin = ""; 1014 } 1015 1016 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1017 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1018 { 1019 <div class="u-full-width"> 1020 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1021 @if (settings.Link != null) { 1022 settings.Link.ButtonLayout = ButtonLayout.LinkClean; 1023 1024 <div class="u-pull--right"> 1025 @Render(settings.Link) 1026 </div> 1027 } 1028 </div> 1029 1030 } 1031 1032 @if (!string.IsNullOrEmpty(settings.HelpText)) 1033 { 1034 <small class="form__help-text">@settings.HelpText</small> 1035 } 1036 1037 @if (settings.ActionButton != null) 1038 { 1039 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1040 <div class="form__field-combi u-no-margin dw-mod"> 1041 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1042 @Render(settings.ActionButton) 1043 </div> 1044 } 1045 else 1046 { 1047 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1048 } 1049 1050 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1051 </div> 1052 } 1053 @using System.Reflection 1054 @using Dynamicweb.Rapido.Blocks.Components.General 1055 @using Dynamicweb.Rapido.Blocks.Components 1056 1057 @* Component *@ 1058 1059 @helper RenderNumberField(NumberField settings) 1060 { 1061 var attributes = new Dictionary<string, string>(); 1062 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1063 { 1064 settings.Id = Guid.NewGuid().ToString("N"); 1065 } 1066 1067 /*base settings*/ 1068 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1069 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1070 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1071 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1072 if (settings.Required) { attributes.Add("required", "true"); } 1073 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1074 /*end*/ 1075 1076 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1077 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1078 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1079 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1080 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1081 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1082 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1083 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1084 attributes.Add("type", "number"); 1085 1086 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1087 1088 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1089 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1090 { 1091 <div class="u-full-width"> 1092 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1093 @if (settings.Link != null) { 1094 <div class="u-pull--right"> 1095 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1096 @Render(settings.Link) 1097 </div> 1098 } 1099 </div> 1100 1101 } 1102 1103 @if (!string.IsNullOrEmpty(settings.HelpText)) 1104 { 1105 <small class="form__help-text">@settings.HelpText</small> 1106 } 1107 1108 @if (settings.ActionButton != null) 1109 { 1110 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1111 <div class="form__field-combi u-no-margin dw-mod"> 1112 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1113 @Render(settings.ActionButton) 1114 </div> 1115 } 1116 else 1117 { 1118 <div class="form__field-combi u-no-margin dw-mod"> 1119 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1120 </div> 1121 } 1122 1123 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1124 </div> 1125 } 1126 @using System.Reflection 1127 @using Dynamicweb.Rapido.Blocks.Components.General 1128 @using Dynamicweb.Rapido.Blocks.Components 1129 1130 1131 @* Component *@ 1132 1133 @helper RenderTextareaField(TextareaField settings) 1134 { 1135 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1136 string id = settings.Id; 1137 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1138 { 1139 id = Guid.NewGuid().ToString("N"); 1140 } 1141 1142 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1143 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1144 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1145 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1146 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1147 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1148 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1149 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1150 if (settings.Required) { attributes.Add("required", "true"); } 1151 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1152 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1153 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1154 attributes.Add("name", settings.Name); 1155 1156 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1157 1158 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1159 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1160 { 1161 <div class="u-full-width"> 1162 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1163 @if (settings.Link != null) { 1164 <div class="u-pull--right"> 1165 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1166 @Render(settings.Link) 1167 </div> 1168 } 1169 </div> 1170 } 1171 1172 @if (!string.IsNullOrEmpty(settings.HelpText)) 1173 { 1174 <small class="form__help-text">@settings.HelpText</small> 1175 } 1176 1177 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1178 1179 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1180 </div> 1181 } 1182 @using System.Reflection 1183 @using Dynamicweb.Rapido.Blocks.Components.General 1184 @using Dynamicweb.Rapido.Blocks.Components 1185 1186 1187 @* Component *@ 1188 1189 @helper RenderHiddenField(HiddenField settings) { 1190 var attributes = new Dictionary<string, string>(); 1191 attributes.Add("type", "hidden"); 1192 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1193 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1194 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1195 1196 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1197 } 1198 @using System.Reflection 1199 @using Dynamicweb.Rapido.Blocks.Components.General 1200 @using Dynamicweb.Rapido.Blocks.Components 1201 1202 @* Component *@ 1203 1204 @helper RenderCheckboxField(CheckboxField settings) 1205 { 1206 var attributes = new Dictionary<string, string>(); 1207 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1208 { 1209 settings.Id = Guid.NewGuid().ToString("N"); 1210 } 1211 1212 /*base settings*/ 1213 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1214 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1215 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1216 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1217 if (settings.Required) { attributes.Add("required", "true"); } 1218 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1219 /*end*/ 1220 1221 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1222 1223 attributes.Add("type", "checkbox"); 1224 if (settings.Checked) { attributes.Add("checked", "true"); } 1225 settings.CssClass = "form__control " + settings.CssClass; 1226 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1227 1228 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1229 1230 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1231 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1232 @if (!string.IsNullOrEmpty(settings.Label)) 1233 { 1234 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1235 } 1236 1237 @if (settings.Link != null) { 1238 <span> 1239 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1240 @Render(settings.Link) 1241 </span> 1242 } 1243 1244 @if (!string.IsNullOrEmpty(settings.HelpText)) 1245 { 1246 <small class="form__help-text checkbox-help dw-mod">@settings.HelpText</small> 1247 } 1248 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1249 </div> 1250 } 1251 @using System.Reflection 1252 @using Dynamicweb.Rapido.Blocks.Components.General 1253 @using Dynamicweb.Rapido.Blocks.Components 1254 1255 1256 @* Component *@ 1257 1258 @helper RenderCheckboxListField(CheckboxListField settings) 1259 { 1260 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1261 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1262 { 1263 <div class="u-full-width"> 1264 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1265 @if (settings.Link != null) { 1266 <div class="u-pull--right"> 1267 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1268 @Render(settings.Link) 1269 </div> 1270 } 1271 </div> 1272 1273 } 1274 1275 <div class="u-pull--left"> 1276 @if (!string.IsNullOrEmpty(settings.HelpText)) 1277 { 1278 <small class="form__help-text">@settings.HelpText</small> 1279 } 1280 1281 @foreach (var item in settings.Options) 1282 { 1283 if (settings.Required) 1284 { 1285 item.Required = true; 1286 } 1287 if (settings.Disabled) 1288 { 1289 item.Disabled = true; 1290 } 1291 if (!string.IsNullOrEmpty(settings.Name)) 1292 { 1293 item.Name = settings.Name; 1294 } 1295 if (!string.IsNullOrEmpty(settings.CssClass)) 1296 { 1297 item.CssClass += settings.CssClass; 1298 } 1299 1300 /* value is not supported */ 1301 1302 if (!string.IsNullOrEmpty(settings.OnClick)) 1303 { 1304 item.OnClick += settings.OnClick; 1305 } 1306 if (!string.IsNullOrEmpty(settings.OnChange)) 1307 { 1308 item.OnChange += settings.OnChange; 1309 } 1310 @Render(item) 1311 } 1312 1313 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1314 </div> 1315 1316 </div> 1317 } 1318 @using Dynamicweb.Rapido.Blocks.Components.General 1319 1320 @* Component *@ 1321 1322 @helper RenderSearch(Search settings) 1323 { 1324 var searchValue = HttpContext.Current.Request.QueryString.Get(settings.SearchParameter) ?? ""; 1325 var groupValue = HttpContext.Current.Request.QueryString.Get(settings.GroupsParameter) ?? ""; 1326 1327 if (string.IsNullOrEmpty(settings.Id)) 1328 { 1329 settings.Id = Guid.NewGuid().ToString("N"); 1330 } 1331 1332 var resultAttributes = new Dictionary<string, string>(); 1333 1334 if (settings.PageSize != 0) 1335 { 1336 resultAttributes.Add("data-page-size", settings.PageSize.ToString()); 1337 } 1338 if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1339 { 1340 resultAttributes.Add("data-groups-feed-url", settings.GroupItemsFeedUrl); 1341 if (!string.IsNullOrEmpty(groupValue)) 1342 { 1343 resultAttributes.Add("data-selected-group", groupValue); 1344 } 1345 if (!string.IsNullOrEmpty(settings.GroupsParameter)) 1346 { 1347 resultAttributes.Add("data-groups-parameter", settings.GroupsParameter); 1348 } 1349 } 1350 resultAttributes.Add("data-force-init", "true"); 1351 if (settings.GoToFirstSearchResultOnEnter) 1352 { 1353 resultAttributes.Add("data-go-to-first-search-result-on-enter", settings.GoToFirstSearchResultOnEnter.ToString().ToLower()); 1354 } 1355 if (!string.IsNullOrEmpty(settings.SearchParameter)) 1356 { 1357 resultAttributes.Add("data-search-parameter", settings.SearchParameter); 1358 } 1359 resultAttributes.Add("data-search-feed-url", settings.SearchData.SearchFeedUrl); 1360 resultAttributes.Add("data-results-template-id", settings.SearchData.ResultsTemplateId); 1361 1362 if (settings.SecondSearchData != null) 1363 { 1364 resultAttributes.Add("data-second-search-feed-url", settings.SecondSearchData.SearchFeedUrl); 1365 resultAttributes.Add("data-second-results-template-id", settings.SecondSearchData.ResultsTemplateId); 1366 } 1367 if (!string.IsNullOrEmpty(settings.ResultsPageUrl)) 1368 { 1369 resultAttributes.Add("data-results-page-url", settings.ResultsPageUrl); 1370 } 1371 1372 resultAttributes = resultAttributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1373 1374 string searchFieldCss = (settings.SearchButton == null) ? "search--with-icon" : ""; 1375 1376 <div class="search @settings.CssClass @searchFieldCss js-search-data-source dw-mod" id="@settings.Id" @ComponentMethods.AddAttributes(resultAttributes)> 1377 @if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1378 { 1379 <button type="button" class="search__groups-btn dw-mod js-search-groups-btn">@Translate("All")</button> 1380 <ul class="dropdown dropdown--absolute-position dw-mod search__groups-results js-search-groups-list"></ul> 1381 } 1382 1383 <input type="text" class="search__field dw-mod js-search-field" placeholder="@settings.Placeholder" value="@searchValue"> 1384 1385 <div class="dropdown dropdown--absolute-position search__results dw-mod js-search-results @(settings.SecondSearchData != null ? "search__results--combined" : "")"> 1386 @if (settings.SecondSearchData != null) 1387 { 1388 <div class="search__column search__column--products dw-mod"> 1389 <div class="search__column-header dw-mod">@Translate("Products")</div> 1390 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1391 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1392 { 1393 @Render(new Link { 1394 Title = Translate("View all"), 1395 CssClass = "js-view-all-button u-margin", 1396 Href = settings.SearchData.ResultsPageUrl 1397 }); 1398 } 1399 </div> 1400 <div class="search__column search__column--pages dw-mod"> 1401 <div class="search__column-header">@Translate("Pages")</div> 1402 <ul class="search__results-list dw-mod js-search-results-second-list" id="@(settings.Id)_SecondResultsList"></ul> 1403 @if (!string.IsNullOrEmpty(settings.SecondSearchData.ResultsPageUrl)) 1404 { 1405 @Render(new Link 1406 { 1407 Title = Translate("View all"), 1408 CssClass = "js-view-all-button u-margin", 1409 Href = settings.SecondSearchData.ResultsPageUrl 1410 }); 1411 } 1412 </div> 1413 } 1414 else 1415 { 1416 <div class="search__column search__column--only dw-mod"> 1417 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1418 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1419 { 1420 @Render(new Link { 1421 Title = Translate("View all"), 1422 CssClass = "js-view-all-button u-margin", 1423 Href = settings.SearchData.ResultsPageUrl 1424 }); 1425 } 1426 </div> 1427 } 1428 </div> 1429 1430 @if (settings.SearchButton != null) 1431 { 1432 settings.SearchButton.CssClass += " search__btn js-search-btn"; 1433 if (settings.RenderDefaultSearchIcon) 1434 { 1435 settings.SearchButton.Icon = new Icon { Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue }; 1436 } 1437 @Render(settings.SearchButton); 1438 } 1439 </div> 1440 } 1441 @using System.Reflection 1442 @using Dynamicweb.Rapido.Blocks.Components.General 1443 @using Dynamicweb.Rapido.Blocks.Components 1444 1445 1446 @* Component *@ 1447 1448 @helper RenderSelectField(SelectField settings) 1449 { 1450 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1451 { 1452 settings.Id = Guid.NewGuid().ToString("N"); 1453 } 1454 1455 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1456 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1457 { 1458 <div class="u-full-width"> 1459 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1460 @if (settings.Link != null) { 1461 <div class="u-pull--right"> 1462 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1463 @Render(settings.Link) 1464 </div> 1465 } 1466 </div> 1467 } 1468 1469 @if (!string.IsNullOrEmpty(settings.HelpText)) 1470 { 1471 <small class="form__help-text">@settings.HelpText</small> 1472 } 1473 1474 @if (settings.ActionButton != null) 1475 { 1476 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1477 <div class="form__field-combi u-no-margin dw-mod"> 1478 @RenderSelectBase(settings) 1479 @Render(settings.ActionButton) 1480 </div> 1481 } 1482 else 1483 { 1484 @RenderSelectBase(settings) 1485 } 1486 1487 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1488 </div> 1489 } 1490 1491 @helper RenderSelectBase(SelectField settings) 1492 { 1493 var attributes = new Dictionary<string, string>(); 1494 1495 /*base settings*/ 1496 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1497 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1498 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1499 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1500 if (settings.Required) { attributes.Add("required", "true"); } 1501 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1502 /*end*/ 1503 1504 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1505 1506 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1507 @if (settings.Default != null) 1508 { 1509 @Render(settings.Default) 1510 } 1511 1512 @foreach (var item in settings.Options) 1513 { 1514 if (settings.Value != null) { 1515 item.Checked = item.Value == settings.Value; 1516 } 1517 @Render(item) 1518 } 1519 </select> 1520 } 1521 @using System.Reflection 1522 @using Dynamicweb.Rapido.Blocks.Components.General 1523 @using Dynamicweb.Rapido.Blocks.Components 1524 1525 @* Component *@ 1526 1527 @helper RenderRadioButtonField(RadioButtonField settings) 1528 { 1529 var attributes = new Dictionary<string, string>(); 1530 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1531 { 1532 settings.Id = Guid.NewGuid().ToString("N"); 1533 } 1534 1535 /*base settings*/ 1536 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1537 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1538 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1539 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1540 if (settings.Required) { attributes.Add("required", "true"); } 1541 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1542 /*end*/ 1543 1544 attributes.Add("type", "radio"); 1545 if (settings.Checked) { attributes.Add("checked", "true"); } 1546 settings.CssClass = "form__control " + settings.CssClass; 1547 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1548 1549 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1550 1551 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1552 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1553 @if (!string.IsNullOrEmpty(settings.Label)) 1554 { 1555 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1556 } 1557 @if (!string.IsNullOrEmpty(settings.HelpText)) 1558 { 1559 <small class="form__help-text">@settings.HelpText</small> 1560 } 1561 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1562 </div> 1563 } 1564 @using System.Reflection 1565 @using Dynamicweb.Rapido.Blocks.Components.General 1566 @using Dynamicweb.Rapido.Blocks.Components 1567 1568 1569 @* Component *@ 1570 1571 @helper RenderRadioButtonListField(RadioButtonListField settings) 1572 { 1573 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1574 1575 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1576 @if (!string.IsNullOrEmpty(settings.Label)) 1577 { 1578 <label>@settings.Label</label> 1579 } 1580 @if (!string.IsNullOrEmpty(settings.HelpText)) 1581 { 1582 <small class="form__help-text">@settings.HelpText</small> 1583 } 1584 1585 @foreach (var item in settings.Options) 1586 { 1587 if (settings.Required) 1588 { 1589 item.Required = true; 1590 } 1591 if (settings.Disabled) 1592 { 1593 item.Disabled = true; 1594 } 1595 if (!string.IsNullOrEmpty(settings.Name)) 1596 { 1597 item.Name = settings.Name; 1598 } 1599 if (settings.Value != null && settings.Value == item.Value) 1600 { 1601 item.Checked = true; 1602 } 1603 if (!string.IsNullOrEmpty(settings.OnClick)) 1604 { 1605 item.OnClick += settings.OnClick; 1606 } 1607 if (!string.IsNullOrEmpty(settings.OnChange)) 1608 { 1609 item.OnChange += settings.OnChange; 1610 } 1611 if (!string.IsNullOrEmpty(settings.CssClass)) 1612 { 1613 item.CssClass += settings.CssClass; 1614 } 1615 @Render(item) 1616 } 1617 1618 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1619 </div> 1620 } 1621 @using System.Reflection 1622 @using Dynamicweb.Rapido.Blocks.Components.General 1623 @using Dynamicweb.Rapido.Blocks.Components 1624 1625 1626 @* Component *@ 1627 1628 @helper RenderNotificationMessage(NotificationMessage settings) 1629 { 1630 if (!string.IsNullOrEmpty(settings.Message)) 1631 { 1632 var attributes = new Dictionary<string, string>(); 1633 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1634 1635 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1636 string messageLayoutClass = Enum.GetName(typeof(NotificationMessageLayout), settings.MessageLayout).ToLower(); 1637 string minHeightClass = settings.Icon != null ? "u-min-h70px" : ""; 1638 1639 <div class="notification-message-@messageTypeClass notification-message-@messageLayoutClass @messageLayoutClass @minHeightClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)> 1640 @if (settings.Icon != null) { 1641 settings.Icon.Label = !string.IsNullOrEmpty(settings.Icon.Label) ? settings.Message + settings.Icon.Label : settings.Message; 1642 @Render(settings.Icon) 1643 } else { 1644 @settings.Message 1645 } 1646 </div> 1647 } 1648 } 1649 @using Dynamicweb.Rapido.Blocks.Components.General 1650 1651 1652 @* Component *@ 1653 1654 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1655 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1656 1657 <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> 1658 @if (settings.SubBlocks != null) { 1659 @RenderBlockList(settings.SubBlocks) 1660 } 1661 </div> 1662 } 1663 @using System.Reflection 1664 @using Dynamicweb.Rapido.Blocks.Components.General 1665 @using Dynamicweb.Rapido.Blocks.Components 1666 @using System.Text.RegularExpressions 1667 1668 1669 @* Component *@ 1670 1671 @helper RenderSticker(Sticker settings) { 1672 if (!String.IsNullOrEmpty(settings.Title)) { 1673 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1674 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1675 1676 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1677 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1678 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1679 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1680 optionalAttributes.Add("style", styleTag); 1681 } 1682 1683 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1684 } 1685 } 1686 1687 @using System.Reflection 1688 @using Dynamicweb.Rapido.Blocks.Components.General 1689 @using Dynamicweb.Rapido.Blocks.Components 1690 1691 1692 @* Component *@ 1693 1694 @helper RenderStickersCollection(StickersCollection settings) 1695 { 1696 if (settings.Stickers.Count > 0) 1697 { 1698 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1699 1700 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1701 @foreach (Sticker sticker in settings.Stickers) 1702 { 1703 @Render(sticker) 1704 } 1705 </div> 1706 } 1707 } 1708 1709 @using Dynamicweb.Rapido.Blocks.Components.General 1710 1711 1712 @* Component *@ 1713 1714 @helper RenderForm(Form settings) { 1715 if (settings != null) 1716 { 1717 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1718 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1719 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1720 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1721 var enctypes = new Dictionary<string, string> 1722 { 1723 { "multipart", "multipart/form-data" }, 1724 { "text", "text/plain" }, 1725 { "application", "application/x-www-form-urlencoded" } 1726 }; 1727 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1728 optionalAttributes.Add("method", settings.Method.ToString()); 1729 1730 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1731 { 1732 @settings.FormStartMarkup 1733 } 1734 else 1735 { 1736 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1737 } 1738 1739 foreach (var field in settings.GetFields()) 1740 { 1741 @Render(field) 1742 } 1743 1744 @:</form> 1745 } 1746 } 1747 @using System.Reflection 1748 @using Dynamicweb.Rapido.Blocks.Components.General 1749 @using Dynamicweb.Rapido.Blocks.Components 1750 1751 1752 @* Component *@ 1753 1754 @helper RenderText(Text settings) 1755 { 1756 @settings.Content 1757 } 1758 @using System.Reflection 1759 @using Dynamicweb.Rapido.Blocks.Components.General 1760 @using Dynamicweb.Rapido.Blocks.Components 1761 1762 1763 @* Component *@ 1764 1765 @helper RenderContentModule(ContentModule settings) { 1766 if (!string.IsNullOrEmpty(settings.Content)) 1767 { 1768 @settings.Content 1769 } 1770 } 1771 @using System.Reflection 1772 @using Dynamicweb.Rapido.Blocks.Components.General 1773 @using Dynamicweb.Rapido.Blocks.Components 1774 1775 1776 @* Component *@ 1777 1778 @helper RenderModal(Modal settings) { 1779 if (settings != null) 1780 { 1781 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1782 1783 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1784 1785 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1786 1787 <div class="modal-container"> 1788 @if (!settings.DisableDarkOverlay) 1789 { 1790 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1791 } 1792 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1793 @if (settings.Heading != null) 1794 { 1795 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1796 { 1797 <div class="modal__header"> 1798 @Render(settings.Heading) 1799 </div> 1800 } 1801 } 1802 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1803 @if (!string.IsNullOrEmpty(settings.BodyText)) 1804 { 1805 @settings.BodyText 1806 } 1807 @if (settings.BodyTemplate != null) 1808 { 1809 @settings.BodyTemplate 1810 } 1811 @{ 1812 var actions = settings.GetActions(); 1813 } 1814 </div> 1815 @if (actions.Length > 0) 1816 { 1817 <div class="modal__footer"> 1818 @foreach (var action in actions) 1819 { 1820 if (Pageview.Device.ToString() != "Mobile") { 1821 action.CssClass += " u-no-margin"; 1822 } else { 1823 action.CssClass += " u-full-width u-margin-bottom"; 1824 } 1825 1826 @Render(action) 1827 } 1828 </div> 1829 } 1830 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1831 </div> 1832 </div> 1833 } 1834 } 1835 @using Dynamicweb.Rapido.Blocks.Components.General 1836 1837 @* Component *@ 1838 1839 @helper RenderMediaListItem(MediaListItem settings) 1840 { 1841 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1842 @if (!string.IsNullOrEmpty(settings.Label)) 1843 { 1844 if (!string.IsNullOrEmpty(settings.Link)) 1845 { 1846 @Render(new Link 1847 { 1848 Href = settings.Link, 1849 CssClass = "media-list-item__sticker dw-mod", 1850 ButtonLayout = ButtonLayout.None, 1851 Title = settings.Label, 1852 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1853 }) 1854 } 1855 else if (!string.IsNullOrEmpty(settings.OnClick)) 1856 { 1857 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1858 <span class="u-uppercase">@settings.Label</span> 1859 </span> 1860 } 1861 else 1862 { 1863 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1864 <span class="u-uppercase">@settings.Label</span> 1865 </span> 1866 } 1867 } 1868 <div class="media-list-item__wrap"> 1869 <div class="media-list-item__info dw-mod"> 1870 <div class="media-list-item__header dw-mod"> 1871 @if (!string.IsNullOrEmpty(settings.Title)) 1872 { 1873 if (!string.IsNullOrEmpty(settings.Link)) 1874 { 1875 @Render(new Link 1876 { 1877 Href = settings.Link, 1878 CssClass = "media-list-item__name dw-mod", 1879 ButtonLayout = ButtonLayout.None, 1880 Title = settings.Title, 1881 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1882 }) 1883 } 1884 else if (!string.IsNullOrEmpty(settings.OnClick)) 1885 { 1886 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1887 } 1888 else 1889 { 1890 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1891 } 1892 } 1893 1894 @if (!string.IsNullOrEmpty(settings.Status)) 1895 { 1896 <div class="media-list-item__state dw-mod">@settings.Status</div> 1897 } 1898 </div> 1899 @{ 1900 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1901 } 1902 1903 @Render(settings.InfoTable) 1904 </div> 1905 <div class="media-list-item__actions dw-mod"> 1906 <div class="media-list-item__actions-list dw-mod"> 1907 @{ 1908 var actions = settings.GetActions(); 1909 1910 foreach (ButtonBase action in actions) 1911 { 1912 action.ButtonLayout = ButtonLayout.None; 1913 action.CssClass += " media-list-item__action link"; 1914 1915 @Render(action) 1916 } 1917 } 1918 </div> 1919 1920 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1921 { 1922 settings.SelectButton.CssClass += " u-no-margin"; 1923 1924 <div class="media-list-item__action-button"> 1925 @Render(settings.SelectButton) 1926 </div> 1927 } 1928 </div> 1929 </div> 1930 </div> 1931 } 1932 @using Dynamicweb.Rapido.Blocks.Components.General 1933 @using Dynamicweb.Rapido.Blocks.Components 1934 1935 @helper RenderTable(Table settings) 1936 { 1937 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1938 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1939 1940 var enumToClasses = new Dictionary<TableDesign, string> 1941 { 1942 { TableDesign.Clean, "table--clean" }, 1943 { TableDesign.Bordered, "table--bordered" }, 1944 { TableDesign.Striped, "table--striped" }, 1945 { TableDesign.Hover, "table--hover" }, 1946 { TableDesign.Compact, "table--compact" }, 1947 { TableDesign.Condensed, "table--condensed" }, 1948 { TableDesign.NoTopBorder, "table--no-top-border" } 1949 }; 1950 string tableDesignClass = ""; 1951 if (settings.Design != TableDesign.None) 1952 { 1953 tableDesignClass = enumToClasses[settings.Design]; 1954 } 1955 1956 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1957 1958 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1959 1960 <table @ComponentMethods.AddAttributes(resultAttributes)> 1961 @if (settings.Header != null) 1962 { 1963 <thead> 1964 @Render(settings.Header) 1965 </thead> 1966 } 1967 <tbody> 1968 @foreach (var row in settings.Rows) 1969 { 1970 @Render(row) 1971 } 1972 </tbody> 1973 @if (settings.Footer != null) 1974 { 1975 <tfoot> 1976 @Render(settings.Footer) 1977 </tfoot> 1978 } 1979 </table> 1980 } 1981 @using Dynamicweb.Rapido.Blocks.Components.General 1982 @using Dynamicweb.Rapido.Blocks.Components 1983 1984 @helper RenderTableRow(TableRow settings) 1985 { 1986 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1987 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1988 1989 var enumToClasses = new Dictionary<TableRowDesign, string> 1990 { 1991 { TableRowDesign.NoBorder, "table__row--no-border" }, 1992 { TableRowDesign.Border, "table__row--border" }, 1993 { TableRowDesign.TopBorder, "table__row--top-line" }, 1994 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1995 { TableRowDesign.Solid, "table__row--solid" } 1996 }; 1997 1998 string tableRowDesignClass = ""; 1999 if (settings.Design != TableRowDesign.None) 2000 { 2001 tableRowDesignClass = enumToClasses[settings.Design]; 2002 } 2003 2004 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 2005 2006 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2007 2008 <tr @ComponentMethods.AddAttributes(resultAttributes)> 2009 @foreach (var cell in settings.Cells) 2010 { 2011 if (settings.IsHeaderRow) 2012 { 2013 cell.IsHeader = true; 2014 } 2015 @Render(cell) 2016 } 2017 </tr> 2018 } 2019 @using Dynamicweb.Rapido.Blocks.Components.General 2020 @using Dynamicweb.Rapido.Blocks.Components 2021 @using Dynamicweb.Core 2022 2023 @helper RenderTableCell(TableCell settings) 2024 { 2025 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2026 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2027 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 2028 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 2029 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 2030 2031 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2032 2033 string tagName = settings.IsHeader ? "th" : "td"; 2034 2035 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 2036 @settings.Content 2037 @("</" + tagName + ">"); 2038 } 2039 @using System.Linq 2040 @using Dynamicweb.Rapido.Blocks.Components.General 2041 2042 @* Component *@ 2043 2044 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 2045 { 2046 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 2047 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 2048 2049 if (settings.NumberOfPages > 1) 2050 { 2051 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 2052 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 2053 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 2054 2055 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 2056 @if (settings.ShowPagingInfo) 2057 { 2058 <div class="pager__info dw-mod"> 2059 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 2060 </div> 2061 } 2062 <ul class="pager__list dw-mod"> 2063 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 2064 { 2065 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 2066 } 2067 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 2068 { 2069 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 2070 } 2071 @if (settings.GetPages().Any()) 2072 { 2073 foreach (var page in settings.GetPages()) 2074 { 2075 @Render(page) 2076 } 2077 } 2078 else 2079 { 2080 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 2081 { 2082 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 2083 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 2084 } 2085 } 2086 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 2087 { 2088 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 2089 } 2090 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 2091 { 2092 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 2093 } 2094 </ul> 2095 </div> 2096 } 2097 } 2098 2099 @helper RenderPaginationItem(PaginationItem settings) 2100 { 2101 if (settings.Icon == null) 2102 { 2103 settings.Icon = new Icon(); 2104 } 2105 2106 settings.Icon.Label = settings.Label; 2107 <li class="pager__btn dw-mod"> 2108 @if (settings.IsActive) 2109 { 2110 <span class="pager__num pager__num--current dw-mod"> 2111 @Render(settings.Icon) 2112 </span> 2113 } 2114 else 2115 { 2116 <a href="@settings.Link" class="pager__num dw-mod"> 2117 @Render(settings.Icon) 2118 </a> 2119 } 2120 </li> 2121 } 2122 2123 2124 @using Dynamicweb.Rapido.Blocks.Components.General 2125 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2126 2127 2128 2129 2130 2131 @functions { 2132 public string GenerateRgba(string color, string opacity) 2133 { 2134 color = color.Replace("#", ""); 2135 if (color.Length == 6) { 2136 return "rgba(" + Convert.ToInt32(color.Substring(0, 2), 16) + ", " + Convert.ToInt32(color.Substring(2, 2), 16) + ", " + Convert.ToInt32(color.Substring(4, 2), 16) + ", " + opacity + ");"; 2137 } else { 2138 return Convert.ToInt16(color).ToString(); 2139 } 2140 } 2141 } 2142 2143 @{ 2144 string link = !string.IsNullOrEmpty(Model.Item.GetString("Link")) ? Model.Item.GetString("Link") : ""; 2145 string linkTarget = link.Contains("http") ? "_blank" : "_self"; 2146 } 2147 2148 @if (!string.IsNullOrEmpty(link)) { 2149 <a href="@link" target="@linkTarget" class="u-overlay">&nbsp;</a> 2150 @RenderTheContent() 2151 } else { 2152 @RenderTheContent() 2153 } 2154 2155 @helper RenderTheContent(){ 2156 var colorService = new ColorSwatchService(); 2157 2158 string innerPadding = Model.Item.GetList("Padding") != null ? " padding-size-" + Model.Item.GetList("Padding").SelectedValue.ToLower() : ""; 2159 innerPadding += Model.Item.GetList("PaddingPosition") != null ? " padding-position-" + Model.Item.GetList("PaddingPosition").SelectedValue.ToLower() : ""; 2160 string outerMargin = Model.Item.GetList("Margin") != null ? " margin-" + Model.Item.GetList("Margin").SelectedValue.ToLower() : ""; 2161 string outerMarginPosition = Model.Item.GetList("MarginPosition") != null ? " margin-position-" + Model.Item.GetList("MarginPosition").SelectedValue.ToLower() : ""; 2162 2163 string cardBackgroundColor = Model.Item.GetString("CardBackgroundColor") != null ? Model.Item.GetString("CardBackgroundColor") : ""; 2164 cardBackgroundColor = !cardBackgroundColor.Contains("#") ? colorService.GetHexColor(Pageview.AreaID, cardBackgroundColor) : cardBackgroundColor; 2165 string styles = "background-color: " + cardBackgroundColor + ";"; 2166 if (!string.IsNullOrEmpty(Model.Item.GetString("Image"))) { 2167 int cropMode = !string.IsNullOrEmpty(Convert.ToString(Model.Item.GetList("ImageCrop"))) ? Convert.ToInt32(Model.Item.GetList("ImageCrop").SelectedValue) : 0; 2168 2169 Image image = new Image 2170 { 2171 Path = Model.Item.GetFile("Image") != null ? Model.Item.GetFile("Image").Path : "", 2172 CssClass = "background-image__cover", 2173 ImageDefault = new ImageSettings 2174 { 2175 Crop = cropMode, 2176 Height = 845, 2177 Width = 1920 2178 }, 2179 ImageMedium = new ImageSettings 2180 { 2181 Crop = cropMode, 2182 Height = 450, 2183 Width = 1024 2184 }, 2185 ImageSmall = new ImageSettings 2186 { 2187 Crop = cropMode, 2188 Height = 544, 2189 Width = 640 2190 } 2191 }; 2192 2193 image.FilterPrimary = !string.IsNullOrEmpty(Model.Item.GetList("ImageFilterPrimary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), Model.Item.GetList("ImageFilterPrimary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2194 image.FilterSecondary = !string.IsNullOrEmpty(Model.Item.GetList("ImageFilterSecondary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), Model.Item.GetList("ImageFilterSecondary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2195 2196 if (!string.IsNullOrEmpty(Model.Item.GetString("ColorForTheFilter"))) { 2197 image.FilterColor = Model.Item.GetString("ColorForTheFilter").StartsWith("#") ? GenerateRgba(Model.Item.GetString("ColorForTheFilter"), "0.3") : ""; 2198 } 2199 2200 <div class="background-image dw-mod"> 2201 <div class="background-image__wrapper dw-mod"> 2202 @Render(image) 2203 </div> 2204 </div> 2205 } 2206 2207 <div class="content-row__item__body @innerPadding @outerMargin @outerMarginPosition card-paragraph dw-mod" style="@styles"> 2208 @if (!string.IsNullOrEmpty(Model.Item.GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetString("Text"))) { 2209 if (!Model.Item.GetBoolean("HideTitle")) { 2210 @Render(new Heading { Title = Model.Item.GetString("Title"), CssClass = "u-no-margin", Level = 2 }) 2211 } 2212 @Render(new Text { Content = Model.Item.GetString("Text") }) 2213 } 2214 2215 @if (!string.IsNullOrEmpty(Model.Item.GetItem("ButtonOne").GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetItem("ButtonTwo").GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetItem("ButtonThree").GetString("Title"))) { 2216 <div> 2217 @ParagraphButton(Model.Item.GetItem("ButtonOne")) 2218 @ParagraphButton(Model.Item.GetItem("ButtonTwo")) 2219 @ParagraphButton(Model.Item.GetItem("ButtonThree")) 2220 </div> 2221 } 2222 </div> 2223 } 2224 2225 2226 @helper ParagraphButton(ItemViewModel item) { 2227 if (item != null) { 2228 if (!string.IsNullOrEmpty(item.GetString("Title"))) { 2229 Button button = new Button { 2230 Title = item.GetString("Title"), 2231 Href = item.GetString("Link"), 2232 CssClass = "u-no-margin", 2233 ButtonLayout = (ButtonLayout)System.Enum.Parse(typeof(ButtonLayout), char.ToUpper(item.GetList("Layout").SelectedValue[0]) + item.GetList("Layout").SelectedValue.Substring(1)) 2234 }; 2235 2236 if (!string.IsNullOrEmpty(item.GetString("Icon"))) { 2237 button.Icon = new Icon { 2238 CssClass = item.GetString("Icon") 2239 }; 2240 } 2241 2242 @Render(button) 2243 } 2244 } 2245 } 2246 2247 2248 2249 2250
Error executing template "Designs/Rapido/ContentPage/Paragraph/CardParagraph.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_776095055ad24d97af02f9a60cb157b4.<RenderTheContent>b__46_0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\S_DW_Thermex\Files\Templates\Designs\Rapido\ContentPage\Paragraph\CardParagraph.cshtml:line 2215
   at CompiledRazorTemplates.Dynamic.RazorEngine_776095055ad24d97af02f9a60cb157b4.Execute() in D:\Dynamicweb.net\Solutions\S_DW_Thermex\Files\Templates\Designs\Rapido\ContentPage\Paragraph\CardParagraph.cshtml:line 2152
   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.ParagraphViewModel> 2 @using Dynamicweb.Frontend 3 @using Dynamicweb.Content.Items 4 @using Dynamicweb 5 @using Dynamicweb.Rapido.Blocks.Components 6 @using Dynamicweb.Rapido.Blocks.Components.General 7 8 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 9 @using Dynamicweb.Frontend 10 11 @* Include the components *@ 12 @using System.Text.RegularExpressions 13 @using System.Collections.Generic 14 @using System.Reflection 15 @using System.Web 16 @using System.Web.UI.HtmlControls 17 @using Dynamicweb.Rapido.Blocks.Components 18 @using Dynamicweb.Rapido.Blocks.Components.Articles 19 @using Dynamicweb.Rapido.Blocks.Components.Documentation 20 @using Dynamicweb.Rapido.Blocks 21 22 23 @*--- START: Base block renderers ---*@ 24 25 @helper RenderBlockList(List<Block> blocks) 26 { 27 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 28 blocks = blocks.OrderBy(item => item.SortId).ToList(); 29 30 foreach (Block item in blocks) 31 { 32 if (debug) { 33 <!-- Block START: @item.Id --> 34 } 35 36 if (item.Design == null) 37 { 38 @RenderBlock(item) 39 } 40 else if (item.Design.RenderType == RenderType.None) { 41 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 42 43 <div class="@cssClass dw-mod"> 44 @RenderBlock(item) 45 </div> 46 } 47 else if (item.Design.RenderType != RenderType.Hide) 48 { 49 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 50 51 if (!item.SkipRenderBlocksList) { 52 if (item.Design.RenderType == RenderType.Row) 53 { 54 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 55 @RenderBlock(item) 56 </div> 57 } 58 59 if (item.Design.RenderType == RenderType.Column) 60 { 61 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 62 string size = item.Design.Size ?? "12"; 63 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 64 65 <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"> 66 @RenderBlock(item) 67 </div> 68 } 69 70 if (item.Design.RenderType == RenderType.Table) 71 { 72 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 73 @RenderBlock(item) 74 </table> 75 } 76 77 if (item.Design.RenderType == RenderType.TableRow) 78 { 79 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 80 @RenderBlock(item) 81 </tr> 82 } 83 84 if (item.Design.RenderType == RenderType.TableColumn) 85 { 86 <td class="@cssClass dw-mod" id="Block__@item.Id"> 87 @RenderBlock(item) 88 </td> 89 } 90 91 if (item.Design.RenderType == RenderType.CardHeader) 92 { 93 <div class="card-header @cssClass dw-mod"> 94 @RenderBlock(item) 95 </div> 96 } 97 98 if (item.Design.RenderType == RenderType.CardBody) 99 { 100 <div class="card @cssClass dw-mod"> 101 @RenderBlock(item) 102 </div> 103 } 104 105 if (item.Design.RenderType == RenderType.CardFooter) 106 { 107 <div class="card-footer @cssClass dw-mod"> 108 @RenderBlock(item) 109 </div> 110 } 111 } 112 else 113 { 114 @RenderBlock(item) 115 } 116 } 117 118 if (debug) { 119 <!-- Block END: @item.Id --> 120 } 121 } 122 } 123 124 @helper RenderBlock(Block item) 125 { 126 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 127 128 if (item.Template != null) 129 { 130 @BlocksPage.RenderTemplate(item.Template) 131 } 132 133 if (item.Component != null) 134 { 135 string customSufix = "Custom"; 136 string methodName = item.Component.HelperName; 137 138 ComponentBase[] methodParameters = new ComponentBase[1]; 139 methodParameters[0] = item.Component; 140 Type methodType = this.GetType(); 141 142 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 143 144 try { 145 if (debug) { 146 <!-- Component: @methodName.Replace("Render", "") --> 147 } 148 if(customMethod != null) { 149 @customMethod.Invoke(this, methodParameters).ToString(); 150 } else { 151 MethodInfo generalMethod = methodType.GetMethod(methodName); 152 @generalMethod.Invoke(this, methodParameters).ToString(); 153 } 154 } catch { 155 try { 156 MethodInfo generalMethod = methodType.GetMethod(methodName); 157 @generalMethod.Invoke(this, methodParameters).ToString(); 158 } catch(Exception ex) { 159 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 160 } 161 } 162 } 163 164 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 165 { 166 @RenderBlockList(item.BlocksList) 167 } 168 } 169 170 @*--- END: Base block renderers ---*@ 171 172 @using Dynamicweb.Rapido.Blocks.Components 173 @using Dynamicweb.Rapido.Blocks.Components.General 174 @using Dynamicweb.Rapido.Blocks 175 @using System.IO 176 177 @* Required *@ 178 @using Dynamicweb.Rapido.Blocks.Components 179 @using Dynamicweb.Rapido.Blocks.Components.General 180 @using Dynamicweb.Rapido.Blocks 181 182 183 @helper Render(ComponentBase component) 184 { 185 if (component != null) 186 { 187 @component.Render(this) 188 } 189 } 190 191 @* Components *@ 192 @using System.Reflection 193 @using Dynamicweb.Rapido.Blocks.Components.General 194 195 196 @* Component *@ 197 198 @helper RenderIcon(Icon settings) 199 { 200 if (settings != null) 201 { 202 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 203 204 if (settings.Name != null) 205 { 206 if (string.IsNullOrEmpty(settings.Label)) 207 { 208 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 209 } 210 else 211 { 212 if (settings.LabelPosition == IconLabelPosition.Before) 213 { 214 <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> 215 } 216 else 217 { 218 <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> 219 } 220 } 221 } 222 else if (!string.IsNullOrEmpty(settings.Label)) 223 { 224 @settings.Label 225 } 226 } 227 } 228 @using System.Reflection 229 @using Dynamicweb.Rapido.Blocks.Components.General 230 @using Dynamicweb.Rapido.Blocks.Components 231 @using Dynamicweb.Core 232 233 @* Component *@ 234 235 @helper RenderButton(Button settings) 236 { 237 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 238 { 239 Dictionary<string, string> attributes = new Dictionary<string, string>(); 240 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 241 if (settings.Disabled) { 242 attributes.Add("disabled", "true"); 243 classList.Add("disabled"); 244 } 245 246 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 247 { 248 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 249 @RenderConfirmDialog(settings); 250 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 251 } 252 253 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 254 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 255 if (!string.IsNullOrEmpty(settings.AltText)) 256 { 257 attributes.Add("title", settings.AltText); 258 } 259 else if (!string.IsNullOrEmpty(settings.Title)) 260 { 261 string cleanTitle = Regex.Replace(settings.Title, "<.*?>", String.Empty); 262 cleanTitle = cleanTitle.Replace("&nbsp;", " "); 263 attributes.Add("title", cleanTitle); 264 } 265 266 var onClickEvents = new List<string>(); 267 if (!string.IsNullOrEmpty(settings.OnClick)) 268 { 269 onClickEvents.Add(settings.OnClick); 270 } 271 if (!string.IsNullOrEmpty(settings.Href)) 272 { 273 onClickEvents.Add("location.href='" + settings.Href + "'"); 274 } 275 if (onClickEvents.Count > 0) 276 { 277 attributes.Add("onClick", string.Join(";", onClickEvents)); 278 } 279 280 if (settings.ButtonLayout != ButtonLayout.None) 281 { 282 classList.Add("btn"); 283 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 284 if (btnLayout == "linkclean") 285 { 286 btnLayout = "link-clean"; //fix 287 } 288 classList.Add("btn--" + btnLayout); 289 } 290 291 if (settings.Icon == null) 292 { 293 settings.Icon = new Icon(); 294 } 295 296 settings.Icon.CssClass += Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower() != "linkclean" ? " u-flex--align-center" : ""; 297 settings.Icon.Label = settings.Title; 298 299 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 300 301 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 302 } 303 } 304 305 @helper RenderConfirmDialog(Button settings) 306 { 307 Modal confirmDialog = new Modal { 308 Id = settings.Id, 309 Width = ModalWidth.Sm, 310 Heading = new Heading 311 { 312 Level = 2, 313 Title = settings.ConfirmTitle 314 }, 315 BodyText = settings.ConfirmText 316 }; 317 318 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 319 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 320 321 @Render(confirmDialog) 322 } 323 @using Dynamicweb.Rapido.Blocks.Components.General 324 @using Dynamicweb.Rapido.Blocks.Components 325 @using Dynamicweb.Core 326 327 @helper RenderDashboard(Dashboard settings) 328 { 329 var widgets = settings.GetWidgets(); 330 331 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 332 { 333 //set bg color for them 334 335 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 336 int r = Convert.ToInt16(color.R); 337 int g = Convert.ToInt16(color.G); 338 int b = Convert.ToInt16(color.B); 339 340 var count = widgets.Length; 341 var max = Math.Max(r, Math.Max(g, b)); 342 double step = 255.0 / (max * count); 343 var i = 0; 344 foreach (var widget in widgets) 345 { 346 i++; 347 348 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 349 widget.BackgroundColor = shade; 350 } 351 } 352 353 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 354 @foreach (var widget in widgets) 355 { 356 <div class="dashboard__widget"> 357 @Render(widget) 358 </div> 359 } 360 </div> 361 } 362 @using Dynamicweb.Rapido.Blocks.Components.General 363 @using Dynamicweb.Rapido.Blocks.Components 364 365 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 366 { 367 if (!string.IsNullOrEmpty(settings.Link)) 368 { 369 var backgroundStyles = ""; 370 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 371 { 372 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 373 } 374 375 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 376 <div class="u-center-middle u-color-light"> 377 @if (settings.Icon != null) 378 { 379 settings.Icon.CssClass += "widget__icon"; 380 @Render(settings.Icon) 381 } 382 <div class="widget__title">@settings.Title</div> 383 </div> 384 </a> 385 } 386 } 387 @using Dynamicweb.Rapido.Blocks.Components.General 388 @using Dynamicweb.Rapido.Blocks.Components 389 390 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 391 { 392 var backgroundStyles = ""; 393 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 394 { 395 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 396 } 397 398 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 399 <div class="u-center-middle u-color-light"> 400 @if (settings.Icon != null) 401 { 402 settings.Icon.CssClass += "widget__icon"; 403 @Render(settings.Icon) 404 } 405 <div class="widget__counter">@settings.Count</div> 406 <div class="widget__title">@settings.Title</div> 407 </div> 408 </div> 409 } 410 @using System.Reflection 411 @using Dynamicweb.Rapido.Blocks.Components.General 412 @using Dynamicweb.Rapido.Blocks.Components 413 @using Dynamicweb.Core 414 415 @* Component *@ 416 417 @helper RenderLink(Link settings) 418 { 419 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 420 { 421 Dictionary<string, string> attributes = new Dictionary<string, string>(); 422 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 423 if (settings.Disabled) 424 { 425 attributes.Add("disabled", "true"); 426 classList.Add("disabled"); 427 } 428 429 if (!string.IsNullOrEmpty(settings.AltText)) 430 { 431 attributes.Add("title", settings.AltText); 432 } 433 else if (!string.IsNullOrEmpty(settings.Title)) 434 { 435 attributes.Add("title", settings.Title); 436 } 437 438 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 439 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 440 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 441 attributes.Add("href", settings.Href); 442 443 if (settings.ButtonLayout != ButtonLayout.None) 444 { 445 classList.Add("btn"); 446 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 447 if (btnLayout == "linkclean") 448 { 449 btnLayout = "link-clean"; //fix 450 } 451 classList.Add("btn--" + btnLayout); 452 } 453 454 if (settings.Icon == null) 455 { 456 settings.Icon = new Icon(); 457 } 458 settings.Icon.Label = settings.Title; 459 460 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 461 { 462 settings.Rel = LinkRelType.Noopener; 463 } 464 if (settings.Target != LinkTargetType.None) 465 { 466 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 467 } 468 if (settings.Download) 469 { 470 attributes.Add("download", "true"); 471 } 472 if (settings.Rel != LinkRelType.None) 473 { 474 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 475 } 476 477 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 478 } 479 } 480 @using System.Reflection 481 @using Dynamicweb.Rapido.Blocks.Components 482 @using Dynamicweb.Rapido.Blocks.Components.General 483 @using Dynamicweb.Rapido.Blocks 484 485 486 @* Component *@ 487 488 @helper RenderRating(Rating settings) 489 { 490 if (settings.Score > 0) 491 { 492 int rating = settings.Score; 493 string iconType = "fa-star"; 494 495 switch (settings.Type.ToString()) { 496 case "Stars": 497 iconType = "fa-star"; 498 break; 499 case "Hearts": 500 iconType = "fa-heart"; 501 break; 502 case "Lemons": 503 iconType = "fa-lemon"; 504 break; 505 case "Bombs": 506 iconType = "fa-bomb"; 507 break; 508 } 509 510 <div class="u-ta-right"> 511 @for (int i = 0; i < settings.OutOf; i++) 512 { 513 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 514 } 515 </div> 516 } 517 } 518 @using System.Reflection 519 @using Dynamicweb.Rapido.Blocks.Components.General 520 @using Dynamicweb.Rapido.Blocks.Components 521 522 523 @* Component *@ 524 525 @helper RenderSelectFieldOption(SelectFieldOption settings) 526 { 527 Dictionary<string, string> attributes = new Dictionary<string, string>(); 528 if (settings.Checked) { attributes.Add("selected", "true"); } 529 if (settings.Disabled) { attributes.Add("disabled", "true"); } 530 if (settings.Value != null) { attributes.Add("value", settings.Value); } 531 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 532 533 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 534 } 535 @using System.Reflection 536 @using Dynamicweb.Rapido.Blocks.Components.General 537 @using Dynamicweb.Rapido.Blocks.Components 538 539 540 @* Component *@ 541 542 @helper RenderNavigation(Navigation settings) { 543 @RenderNavigation(new 544 { 545 id = settings.Id, 546 cssclass = settings.CssClass, 547 startLevel = settings.StartLevel, 548 endlevel = settings.EndLevel, 549 expandmode = settings.Expandmode, 550 sitemapmode = settings.SitemapMode, 551 template = settings.Template 552 }) 553 } 554 @using Dynamicweb.Rapido.Blocks.Components.General 555 @using Dynamicweb.Rapido.Blocks.Components 556 557 558 @* Component *@ 559 560 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 561 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 562 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 563 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 564 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 565 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 566 settings.SitemapMode = false; 567 568 @RenderNavigation(settings) 569 } 570 @using Dynamicweb.Rapido.Blocks.Components.General 571 @using Dynamicweb.Rapido.Blocks.Components 572 573 574 @* Component *@ 575 576 @helper RenderLeftNavigation(LeftNavigation settings) { 577 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 578 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 579 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 580 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 581 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 582 583 <div class="grid__cell"> 584 @RenderNavigation(settings) 585 </div> 586 } 587 @using System.Reflection 588 @using Dynamicweb.Rapido.Blocks.Components.General 589 @using Dynamicweb.Core 590 591 @* Component *@ 592 593 @helper RenderHeading(Heading settings) 594 { 595 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 596 { 597 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 598 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 599 600 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 601 if (!string.IsNullOrEmpty(settings.Link)) 602 { 603 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 604 } 605 else 606 { 607 if (settings.Icon == null) 608 { 609 settings.Icon = new Icon(); 610 } 611 settings.Icon.Label = settings.Title; 612 @Render(settings.Icon) 613 } 614 @("</" + tagName + ">"); 615 } 616 } 617 @using Dynamicweb.Rapido.Blocks.Components 618 @using Dynamicweb.Rapido.Blocks.Components.General 619 @using Dynamicweb.Rapido.Blocks 620 621 622 @* Component *@ 623 624 @helper RenderImage(Image settings) 625 { 626 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 627 { 628 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 629 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 630 631 if (settings.Caption != null) 632 { 633 @:<div> 634 } 635 636 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 637 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 638 639 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 640 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 641 @if (settings.Link != null) 642 { 643 <a href="@settings.Link"> 644 @RenderTheImage(settings) 645 </a> 646 } 647 else 648 { 649 @RenderTheImage(settings) 650 } 651 </div> 652 </div> 653 654 if (settings.Caption != null) 655 { 656 <span class="image-caption dw-mod">@settings.Caption</span> 657 @:</div> 658 } 659 } 660 else 661 { 662 if (settings.Caption != null) 663 { 664 @:<div> 665 } 666 if (!string.IsNullOrEmpty(settings.Link)) 667 { 668 <a href="@settings.Link"> 669 @RenderTheImage(settings) 670 </a> 671 } 672 else 673 { 674 @RenderTheImage(settings) 675 } 676 677 if (settings.Caption != null) 678 { 679 <span class="image-caption dw-mod">@settings.Caption</span> 680 @:</div> 681 } 682 } 683 } 684 685 @helper RenderTheImage(Image settings) 686 { 687 if (settings != null) 688 { 689 string alternativeImage = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("AlternativeImage")) ? Pageview.AreaSettings.GetItem("Settings").GetFile("AlternativeImage").PathUrlEncoded : "/Images/missing_image.jpg"; 690 string placeholderImage = "/Files/Images/placeholder.gif"; 691 string imageEngine = "/Admin/Public/GetImage.ashx?"; 692 693 string imageStyle = ""; 694 695 switch (settings.Style) 696 { 697 case ImageStyle.Ball: 698 imageStyle = "grid__cell-img--ball"; 699 break; 700 701 case ImageStyle.Triangle: 702 imageStyle = "grid__cell-img--triangle"; 703 break; 704 } 705 706 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle || settings.Style == ImageStyle.Triangle) 707 { 708 settings.ImageDefault.Crop = settings.ImageDefault.Crop == 5 ? settings.ImageDefault.Crop = 0 : settings.ImageDefault.Crop; 709 710 if (settings.ImageDefault != null) 711 { 712 settings.ImageDefault.Height = settings.ImageDefault.Width; 713 } 714 if (settings.ImageMedium != null) 715 { 716 settings.ImageMedium.Height = settings.ImageMedium.Width; 717 } 718 if (settings.ImageSmall != null) 719 { 720 settings.ImageSmall.Height = settings.ImageSmall.Width; 721 } 722 } 723 724 string defaultImage = imageEngine; 725 string imageSmall = ""; 726 string imageMedium = ""; 727 728 if (settings.DisableImageEngine) 729 { 730 defaultImage = settings.Path; 731 } 732 else 733 { 734 if (settings.ImageDefault != null) 735 { 736 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 737 738 if (settings.Path.GetType() != typeof(string)) 739 { 740 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 741 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 742 } 743 else 744 { 745 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 746 } 747 748 defaultImage += "&AlternativeImage=" + alternativeImage; 749 } 750 751 if (settings.ImageSmall != null) 752 { 753 imageSmall = "data-src-small=\"" + imageEngine; 754 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 755 756 if (settings.Path.GetType() != typeof(string)) 757 { 758 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 759 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 760 } 761 else 762 { 763 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 764 } 765 766 imageSmall += "&alternativeImage=" + alternativeImage; 767 768 imageSmall += "\""; 769 } 770 771 if (settings.ImageMedium != null) 772 { 773 imageMedium = "data-src-medium=\"" + imageEngine; 774 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 775 776 if (settings.Path.GetType() != typeof(string)) 777 { 778 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 779 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 780 } 781 else 782 { 783 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 784 } 785 786 imageMedium += "&alternativeImage=" + alternativeImage; 787 788 imageMedium += "\""; 789 } 790 } 791 792 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 793 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 794 if (!string.IsNullOrEmpty(settings.Title)) 795 { 796 optionalAttributes.Add("alt", settings.Title); 797 optionalAttributes.Add("title", settings.Title); 798 } 799 800 if (settings.DisableLazyLoad) 801 { 802 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 803 } 804 else 805 { 806 <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) /> 807 } 808 } 809 } 810 @using System.Reflection 811 @using Dynamicweb.Rapido.Blocks.Components.General 812 @using Dynamicweb.Rapido.Blocks.Components 813 814 @* Component *@ 815 816 @helper RenderFileField(FileField settings) 817 { 818 var attributes = new Dictionary<string, string>(); 819 if (string.IsNullOrEmpty(settings.Id)) 820 { 821 settings.Id = Guid.NewGuid().ToString("N"); 822 } 823 824 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 825 if (settings.Disabled) { attributes.Add("disabled", "true"); } 826 if (settings.Required) { attributes.Add("required", "true"); } 827 if (settings.Multiple) { attributes.Add("multiple", "true"); } 828 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 829 if (string.IsNullOrEmpty(settings.ChooseFileText)) 830 { 831 settings.ChooseFileText = Translate("Choose file"); 832 } 833 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 834 { 835 settings.NoFilesChosenText = Translate("No files chosen..."); 836 } 837 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 838 839 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 840 841 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 842 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 843 844 attributes.Add("type", "file"); 845 if (settings.Value != null) { attributes.Add("value", settings.Value); } 846 settings.CssClass = "u-full-width " + settings.CssClass; 847 848 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 849 850 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 851 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 852 { 853 <div class="u-full-width"> 854 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 855 @if (settings.Link != null) { 856 <div class="u-pull--right"> 857 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 858 @Render(settings.Link) 859 </div> 860 } 861 </div> 862 863 } 864 865 @if (!string.IsNullOrEmpty(settings.HelpText)) 866 { 867 <small class="form__help-text">@settings.HelpText</small> 868 } 869 870 <div class="form__field-combi file-input u-no-margin dw-mod"> 871 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 872 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 873 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 874 @if (settings.UploadButton != null) 875 { 876 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 877 @Render(settings.UploadButton) 878 } 879 </div> 880 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 881 </div> 882 } 883 @using System.Reflection 884 @using Dynamicweb.Rapido.Blocks.Components.General 885 @using Dynamicweb.Rapido.Blocks.Components 886 @using Dynamicweb.Core 887 @using System.Linq 888 889 @* Component *@ 890 891 @helper RenderDateTimeField(DateTimeField settings) 892 { 893 if (string.IsNullOrEmpty(settings.Id)) 894 { 895 settings.Id = Guid.NewGuid().ToString("N"); 896 } 897 if (settings.ExtraAttributes == null) 898 { 899 settings.ExtraAttributes = new Dictionary<string, string>(); 900 } 901 settings.ExtraAttributes.Add("autocomplete","off"); 902 var textField = new TextField { 903 Name = settings.Name, 904 Id = settings.Id, 905 Label = settings.Label, 906 HelpText = settings.HelpText, 907 Value = settings.Value, 908 Disabled = settings.Disabled, 909 Required = settings.Required, 910 ErrorMessage = settings.ErrorMessage, 911 CssClass = settings.CssClass, 912 WrapperCssClass = settings.WrapperCssClass, 913 OnChange = settings.OnChange, 914 OnClick = settings.OnClick, 915 Link = settings.Link, 916 ExtraAttributes = settings.ExtraAttributes, 917 // 918 Placeholder = settings.Placeholder 919 }; 920 921 @Render(textField) 922 923 List<string> jsAttributes = new List<string>(); 924 925 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 926 927 if (!string.IsNullOrEmpty(settings.DateFormat)) 928 { 929 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 930 } 931 if (!string.IsNullOrEmpty(settings.MinDate)) 932 { 933 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 934 } 935 if (!string.IsNullOrEmpty(settings.MaxDate)) 936 { 937 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 938 } 939 if (settings.IsInline) 940 { 941 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 942 } 943 if (settings.EnableTime) 944 { 945 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 946 } 947 if (settings.EnableWeekNumbers) 948 { 949 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 950 } 951 952 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 953 954 <script> 955 document.addEventListener( "DOMContentLoaded", function () { 956 flatpickr("#@textField.Id", { 957 onReady: function(selectedDates, dateStr, instance) { 958 instance.input.readOnly = false; 959 }, 960 onOpen: function(selectedDates, dateStr, instance) { 961 instance.input.readOnly = true; 962 }, 963 onClose: function(selectedDates, dateStr, instance) { 964 instance.input.readOnly = false; 965 //instance.input.blur(); 966 }, 967 @string.Join(",", jsAttributes) 968 } ) 969 } ); 970 </script> 971 } 972 @using System.Reflection 973 @using Dynamicweb.Rapido.Blocks.Components.General 974 @using Dynamicweb.Rapido.Blocks.Components 975 976 @* Component *@ 977 978 @helper RenderTextField(TextField settings) 979 { 980 var attributes = new Dictionary<string, string>(); 981 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 982 { 983 settings.Id = Guid.NewGuid().ToString("N"); 984 } 985 986 /*base settings*/ 987 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 988 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 989 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 990 if (settings.Disabled) { attributes.Add("disabled", "true"); } 991 if (settings.Required) { attributes.Add("required", "true"); } 992 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 993 /*end*/ 994 995 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 996 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 997 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 998 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 999 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1000 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1001 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1002 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1003 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1004 1005 settings.CssClass = "u-full-width " + settings.CssClass; 1006 1007 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1008 1009 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1010 1011 string noMargin = "u-no-margin"; 1012 if (!settings.ReadOnly) { 1013 noMargin = ""; 1014 } 1015 1016 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1017 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1018 { 1019 <div class="u-full-width"> 1020 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1021 @if (settings.Link != null) { 1022 settings.Link.ButtonLayout = ButtonLayout.LinkClean; 1023 1024 <div class="u-pull--right"> 1025 @Render(settings.Link) 1026 </div> 1027 } 1028 </div> 1029 1030 } 1031 1032 @if (!string.IsNullOrEmpty(settings.HelpText)) 1033 { 1034 <small class="form__help-text">@settings.HelpText</small> 1035 } 1036 1037 @if (settings.ActionButton != null) 1038 { 1039 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1040 <div class="form__field-combi u-no-margin dw-mod"> 1041 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1042 @Render(settings.ActionButton) 1043 </div> 1044 } 1045 else 1046 { 1047 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1048 } 1049 1050 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1051 </div> 1052 } 1053 @using System.Reflection 1054 @using Dynamicweb.Rapido.Blocks.Components.General 1055 @using Dynamicweb.Rapido.Blocks.Components 1056 1057 @* Component *@ 1058 1059 @helper RenderNumberField(NumberField settings) 1060 { 1061 var attributes = new Dictionary<string, string>(); 1062 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1063 { 1064 settings.Id = Guid.NewGuid().ToString("N"); 1065 } 1066 1067 /*base settings*/ 1068 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1069 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1070 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1071 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1072 if (settings.Required) { attributes.Add("required", "true"); } 1073 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1074 /*end*/ 1075 1076 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1077 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1078 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1079 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1080 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1081 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1082 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1083 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1084 attributes.Add("type", "number"); 1085 1086 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1087 1088 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1089 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1090 { 1091 <div class="u-full-width"> 1092 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1093 @if (settings.Link != null) { 1094 <div class="u-pull--right"> 1095 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1096 @Render(settings.Link) 1097 </div> 1098 } 1099 </div> 1100 1101 } 1102 1103 @if (!string.IsNullOrEmpty(settings.HelpText)) 1104 { 1105 <small class="form__help-text">@settings.HelpText</small> 1106 } 1107 1108 @if (settings.ActionButton != null) 1109 { 1110 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1111 <div class="form__field-combi u-no-margin dw-mod"> 1112 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1113 @Render(settings.ActionButton) 1114 </div> 1115 } 1116 else 1117 { 1118 <div class="form__field-combi u-no-margin dw-mod"> 1119 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1120 </div> 1121 } 1122 1123 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1124 </div> 1125 } 1126 @using System.Reflection 1127 @using Dynamicweb.Rapido.Blocks.Components.General 1128 @using Dynamicweb.Rapido.Blocks.Components 1129 1130 1131 @* Component *@ 1132 1133 @helper RenderTextareaField(TextareaField settings) 1134 { 1135 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1136 string id = settings.Id; 1137 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1138 { 1139 id = Guid.NewGuid().ToString("N"); 1140 } 1141 1142 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1143 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1144 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1145 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1146 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1147 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1148 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1149 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1150 if (settings.Required) { attributes.Add("required", "true"); } 1151 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1152 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1153 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1154 attributes.Add("name", settings.Name); 1155 1156 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1157 1158 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1159 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1160 { 1161 <div class="u-full-width"> 1162 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1163 @if (settings.Link != null) { 1164 <div class="u-pull--right"> 1165 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1166 @Render(settings.Link) 1167 </div> 1168 } 1169 </div> 1170 } 1171 1172 @if (!string.IsNullOrEmpty(settings.HelpText)) 1173 { 1174 <small class="form__help-text">@settings.HelpText</small> 1175 } 1176 1177 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1178 1179 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1180 </div> 1181 } 1182 @using System.Reflection 1183 @using Dynamicweb.Rapido.Blocks.Components.General 1184 @using Dynamicweb.Rapido.Blocks.Components 1185 1186 1187 @* Component *@ 1188 1189 @helper RenderHiddenField(HiddenField settings) { 1190 var attributes = new Dictionary<string, string>(); 1191 attributes.Add("type", "hidden"); 1192 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1193 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1194 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1195 1196 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1197 } 1198 @using System.Reflection 1199 @using Dynamicweb.Rapido.Blocks.Components.General 1200 @using Dynamicweb.Rapido.Blocks.Components 1201 1202 @* Component *@ 1203 1204 @helper RenderCheckboxField(CheckboxField settings) 1205 { 1206 var attributes = new Dictionary<string, string>(); 1207 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1208 { 1209 settings.Id = Guid.NewGuid().ToString("N"); 1210 } 1211 1212 /*base settings*/ 1213 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1214 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1215 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1216 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1217 if (settings.Required) { attributes.Add("required", "true"); } 1218 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1219 /*end*/ 1220 1221 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1222 1223 attributes.Add("type", "checkbox"); 1224 if (settings.Checked) { attributes.Add("checked", "true"); } 1225 settings.CssClass = "form__control " + settings.CssClass; 1226 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1227 1228 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1229 1230 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1231 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1232 @if (!string.IsNullOrEmpty(settings.Label)) 1233 { 1234 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1235 } 1236 1237 @if (settings.Link != null) { 1238 <span> 1239 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1240 @Render(settings.Link) 1241 </span> 1242 } 1243 1244 @if (!string.IsNullOrEmpty(settings.HelpText)) 1245 { 1246 <small class="form__help-text checkbox-help dw-mod">@settings.HelpText</small> 1247 } 1248 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1249 </div> 1250 } 1251 @using System.Reflection 1252 @using Dynamicweb.Rapido.Blocks.Components.General 1253 @using Dynamicweb.Rapido.Blocks.Components 1254 1255 1256 @* Component *@ 1257 1258 @helper RenderCheckboxListField(CheckboxListField settings) 1259 { 1260 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1261 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1262 { 1263 <div class="u-full-width"> 1264 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1265 @if (settings.Link != null) { 1266 <div class="u-pull--right"> 1267 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1268 @Render(settings.Link) 1269 </div> 1270 } 1271 </div> 1272 1273 } 1274 1275 <div class="u-pull--left"> 1276 @if (!string.IsNullOrEmpty(settings.HelpText)) 1277 { 1278 <small class="form__help-text">@settings.HelpText</small> 1279 } 1280 1281 @foreach (var item in settings.Options) 1282 { 1283 if (settings.Required) 1284 { 1285 item.Required = true; 1286 } 1287 if (settings.Disabled) 1288 { 1289 item.Disabled = true; 1290 } 1291 if (!string.IsNullOrEmpty(settings.Name)) 1292 { 1293 item.Name = settings.Name; 1294 } 1295 if (!string.IsNullOrEmpty(settings.CssClass)) 1296 { 1297 item.CssClass += settings.CssClass; 1298 } 1299 1300 /* value is not supported */ 1301 1302 if (!string.IsNullOrEmpty(settings.OnClick)) 1303 { 1304 item.OnClick += settings.OnClick; 1305 } 1306 if (!string.IsNullOrEmpty(settings.OnChange)) 1307 { 1308 item.OnChange += settings.OnChange; 1309 } 1310 @Render(item) 1311 } 1312 1313 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1314 </div> 1315 1316 </div> 1317 } 1318 @using Dynamicweb.Rapido.Blocks.Components.General 1319 1320 @* Component *@ 1321 1322 @helper RenderSearch(Search settings) 1323 { 1324 var searchValue = HttpContext.Current.Request.QueryString.Get(settings.SearchParameter) ?? ""; 1325 var groupValue = HttpContext.Current.Request.QueryString.Get(settings.GroupsParameter) ?? ""; 1326 1327 if (string.IsNullOrEmpty(settings.Id)) 1328 { 1329 settings.Id = Guid.NewGuid().ToString("N"); 1330 } 1331 1332 var resultAttributes = new Dictionary<string, string>(); 1333 1334 if (settings.PageSize != 0) 1335 { 1336 resultAttributes.Add("data-page-size", settings.PageSize.ToString()); 1337 } 1338 if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1339 { 1340 resultAttributes.Add("data-groups-feed-url", settings.GroupItemsFeedUrl); 1341 if (!string.IsNullOrEmpty(groupValue)) 1342 { 1343 resultAttributes.Add("data-selected-group", groupValue); 1344 } 1345 if (!string.IsNullOrEmpty(settings.GroupsParameter)) 1346 { 1347 resultAttributes.Add("data-groups-parameter", settings.GroupsParameter); 1348 } 1349 } 1350 resultAttributes.Add("data-force-init", "true"); 1351 if (settings.GoToFirstSearchResultOnEnter) 1352 { 1353 resultAttributes.Add("data-go-to-first-search-result-on-enter", settings.GoToFirstSearchResultOnEnter.ToString().ToLower()); 1354 } 1355 if (!string.IsNullOrEmpty(settings.SearchParameter)) 1356 { 1357 resultAttributes.Add("data-search-parameter", settings.SearchParameter); 1358 } 1359 resultAttributes.Add("data-search-feed-url", settings.SearchData.SearchFeedUrl); 1360 resultAttributes.Add("data-results-template-id", settings.SearchData.ResultsTemplateId); 1361 1362 if (settings.SecondSearchData != null) 1363 { 1364 resultAttributes.Add("data-second-search-feed-url", settings.SecondSearchData.SearchFeedUrl); 1365 resultAttributes.Add("data-second-results-template-id", settings.SecondSearchData.ResultsTemplateId); 1366 } 1367 if (!string.IsNullOrEmpty(settings.ResultsPageUrl)) 1368 { 1369 resultAttributes.Add("data-results-page-url", settings.ResultsPageUrl); 1370 } 1371 1372 resultAttributes = resultAttributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1373 1374 string searchFieldCss = (settings.SearchButton == null) ? "search--with-icon" : ""; 1375 1376 <div class="search @settings.CssClass @searchFieldCss js-search-data-source dw-mod" id="@settings.Id" @ComponentMethods.AddAttributes(resultAttributes)> 1377 @if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1378 { 1379 <button type="button" class="search__groups-btn dw-mod js-search-groups-btn">@Translate("All")</button> 1380 <ul class="dropdown dropdown--absolute-position dw-mod search__groups-results js-search-groups-list"></ul> 1381 } 1382 1383 <input type="text" class="search__field dw-mod js-search-field" placeholder="@settings.Placeholder" value="@searchValue"> 1384 1385 <div class="dropdown dropdown--absolute-position search__results dw-mod js-search-results @(settings.SecondSearchData != null ? "search__results--combined" : "")"> 1386 @if (settings.SecondSearchData != null) 1387 { 1388 <div class="search__column search__column--products dw-mod"> 1389 <div class="search__column-header dw-mod">@Translate("Products")</div> 1390 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1391 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1392 { 1393 @Render(new Link { 1394 Title = Translate("View all"), 1395 CssClass = "js-view-all-button u-margin", 1396 Href = settings.SearchData.ResultsPageUrl 1397 }); 1398 } 1399 </div> 1400 <div class="search__column search__column--pages dw-mod"> 1401 <div class="search__column-header">@Translate("Pages")</div> 1402 <ul class="search__results-list dw-mod js-search-results-second-list" id="@(settings.Id)_SecondResultsList"></ul> 1403 @if (!string.IsNullOrEmpty(settings.SecondSearchData.ResultsPageUrl)) 1404 { 1405 @Render(new Link 1406 { 1407 Title = Translate("View all"), 1408 CssClass = "js-view-all-button u-margin", 1409 Href = settings.SecondSearchData.ResultsPageUrl 1410 }); 1411 } 1412 </div> 1413 } 1414 else 1415 { 1416 <div class="search__column search__column--only dw-mod"> 1417 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1418 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1419 { 1420 @Render(new Link { 1421 Title = Translate("View all"), 1422 CssClass = "js-view-all-button u-margin", 1423 Href = settings.SearchData.ResultsPageUrl 1424 }); 1425 } 1426 </div> 1427 } 1428 </div> 1429 1430 @if (settings.SearchButton != null) 1431 { 1432 settings.SearchButton.CssClass += " search__btn js-search-btn"; 1433 if (settings.RenderDefaultSearchIcon) 1434 { 1435 settings.SearchButton.Icon = new Icon { Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue }; 1436 } 1437 @Render(settings.SearchButton); 1438 } 1439 </div> 1440 } 1441 @using System.Reflection 1442 @using Dynamicweb.Rapido.Blocks.Components.General 1443 @using Dynamicweb.Rapido.Blocks.Components 1444 1445 1446 @* Component *@ 1447 1448 @helper RenderSelectField(SelectField settings) 1449 { 1450 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1451 { 1452 settings.Id = Guid.NewGuid().ToString("N"); 1453 } 1454 1455 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1456 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1457 { 1458 <div class="u-full-width"> 1459 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1460 @if (settings.Link != null) { 1461 <div class="u-pull--right"> 1462 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1463 @Render(settings.Link) 1464 </div> 1465 } 1466 </div> 1467 } 1468 1469 @if (!string.IsNullOrEmpty(settings.HelpText)) 1470 { 1471 <small class="form__help-text">@settings.HelpText</small> 1472 } 1473 1474 @if (settings.ActionButton != null) 1475 { 1476 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1477 <div class="form__field-combi u-no-margin dw-mod"> 1478 @RenderSelectBase(settings) 1479 @Render(settings.ActionButton) 1480 </div> 1481 } 1482 else 1483 { 1484 @RenderSelectBase(settings) 1485 } 1486 1487 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1488 </div> 1489 } 1490 1491 @helper RenderSelectBase(SelectField settings) 1492 { 1493 var attributes = new Dictionary<string, string>(); 1494 1495 /*base settings*/ 1496 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1497 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1498 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1499 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1500 if (settings.Required) { attributes.Add("required", "true"); } 1501 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1502 /*end*/ 1503 1504 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1505 1506 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1507 @if (settings.Default != null) 1508 { 1509 @Render(settings.Default) 1510 } 1511 1512 @foreach (var item in settings.Options) 1513 { 1514 if (settings.Value != null) { 1515 item.Checked = item.Value == settings.Value; 1516 } 1517 @Render(item) 1518 } 1519 </select> 1520 } 1521 @using System.Reflection 1522 @using Dynamicweb.Rapido.Blocks.Components.General 1523 @using Dynamicweb.Rapido.Blocks.Components 1524 1525 @* Component *@ 1526 1527 @helper RenderRadioButtonField(RadioButtonField settings) 1528 { 1529 var attributes = new Dictionary<string, string>(); 1530 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1531 { 1532 settings.Id = Guid.NewGuid().ToString("N"); 1533 } 1534 1535 /*base settings*/ 1536 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1537 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1538 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1539 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1540 if (settings.Required) { attributes.Add("required", "true"); } 1541 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1542 /*end*/ 1543 1544 attributes.Add("type", "radio"); 1545 if (settings.Checked) { attributes.Add("checked", "true"); } 1546 settings.CssClass = "form__control " + settings.CssClass; 1547 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1548 1549 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1550 1551 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1552 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1553 @if (!string.IsNullOrEmpty(settings.Label)) 1554 { 1555 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1556 } 1557 @if (!string.IsNullOrEmpty(settings.HelpText)) 1558 { 1559 <small class="form__help-text">@settings.HelpText</small> 1560 } 1561 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1562 </div> 1563 } 1564 @using System.Reflection 1565 @using Dynamicweb.Rapido.Blocks.Components.General 1566 @using Dynamicweb.Rapido.Blocks.Components 1567 1568 1569 @* Component *@ 1570 1571 @helper RenderRadioButtonListField(RadioButtonListField settings) 1572 { 1573 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1574 1575 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1576 @if (!string.IsNullOrEmpty(settings.Label)) 1577 { 1578 <label>@settings.Label</label> 1579 } 1580 @if (!string.IsNullOrEmpty(settings.HelpText)) 1581 { 1582 <small class="form__help-text">@settings.HelpText</small> 1583 } 1584 1585 @foreach (var item in settings.Options) 1586 { 1587 if (settings.Required) 1588 { 1589 item.Required = true; 1590 } 1591 if (settings.Disabled) 1592 { 1593 item.Disabled = true; 1594 } 1595 if (!string.IsNullOrEmpty(settings.Name)) 1596 { 1597 item.Name = settings.Name; 1598 } 1599 if (settings.Value != null && settings.Value == item.Value) 1600 { 1601 item.Checked = true; 1602 } 1603 if (!string.IsNullOrEmpty(settings.OnClick)) 1604 { 1605 item.OnClick += settings.OnClick; 1606 } 1607 if (!string.IsNullOrEmpty(settings.OnChange)) 1608 { 1609 item.OnChange += settings.OnChange; 1610 } 1611 if (!string.IsNullOrEmpty(settings.CssClass)) 1612 { 1613 item.CssClass += settings.CssClass; 1614 } 1615 @Render(item) 1616 } 1617 1618 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1619 </div> 1620 } 1621 @using System.Reflection 1622 @using Dynamicweb.Rapido.Blocks.Components.General 1623 @using Dynamicweb.Rapido.Blocks.Components 1624 1625 1626 @* Component *@ 1627 1628 @helper RenderNotificationMessage(NotificationMessage settings) 1629 { 1630 if (!string.IsNullOrEmpty(settings.Message)) 1631 { 1632 var attributes = new Dictionary<string, string>(); 1633 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1634 1635 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1636 string messageLayoutClass = Enum.GetName(typeof(NotificationMessageLayout), settings.MessageLayout).ToLower(); 1637 string minHeightClass = settings.Icon != null ? "u-min-h70px" : ""; 1638 1639 <div class="notification-message-@messageTypeClass notification-message-@messageLayoutClass @messageLayoutClass @minHeightClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)> 1640 @if (settings.Icon != null) { 1641 settings.Icon.Label = !string.IsNullOrEmpty(settings.Icon.Label) ? settings.Message + settings.Icon.Label : settings.Message; 1642 @Render(settings.Icon) 1643 } else { 1644 @settings.Message 1645 } 1646 </div> 1647 } 1648 } 1649 @using Dynamicweb.Rapido.Blocks.Components.General 1650 1651 1652 @* Component *@ 1653 1654 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1655 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1656 1657 <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> 1658 @if (settings.SubBlocks != null) { 1659 @RenderBlockList(settings.SubBlocks) 1660 } 1661 </div> 1662 } 1663 @using System.Reflection 1664 @using Dynamicweb.Rapido.Blocks.Components.General 1665 @using Dynamicweb.Rapido.Blocks.Components 1666 @using System.Text.RegularExpressions 1667 1668 1669 @* Component *@ 1670 1671 @helper RenderSticker(Sticker settings) { 1672 if (!String.IsNullOrEmpty(settings.Title)) { 1673 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1674 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1675 1676 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1677 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1678 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1679 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1680 optionalAttributes.Add("style", styleTag); 1681 } 1682 1683 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1684 } 1685 } 1686 1687 @using System.Reflection 1688 @using Dynamicweb.Rapido.Blocks.Components.General 1689 @using Dynamicweb.Rapido.Blocks.Components 1690 1691 1692 @* Component *@ 1693 1694 @helper RenderStickersCollection(StickersCollection settings) 1695 { 1696 if (settings.Stickers.Count > 0) 1697 { 1698 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1699 1700 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1701 @foreach (Sticker sticker in settings.Stickers) 1702 { 1703 @Render(sticker) 1704 } 1705 </div> 1706 } 1707 } 1708 1709 @using Dynamicweb.Rapido.Blocks.Components.General 1710 1711 1712 @* Component *@ 1713 1714 @helper RenderForm(Form settings) { 1715 if (settings != null) 1716 { 1717 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1718 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1719 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1720 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1721 var enctypes = new Dictionary<string, string> 1722 { 1723 { "multipart", "multipart/form-data" }, 1724 { "text", "text/plain" }, 1725 { "application", "application/x-www-form-urlencoded" } 1726 }; 1727 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1728 optionalAttributes.Add("method", settings.Method.ToString()); 1729 1730 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1731 { 1732 @settings.FormStartMarkup 1733 } 1734 else 1735 { 1736 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1737 } 1738 1739 foreach (var field in settings.GetFields()) 1740 { 1741 @Render(field) 1742 } 1743 1744 @:</form> 1745 } 1746 } 1747 @using System.Reflection 1748 @using Dynamicweb.Rapido.Blocks.Components.General 1749 @using Dynamicweb.Rapido.Blocks.Components 1750 1751 1752 @* Component *@ 1753 1754 @helper RenderText(Text settings) 1755 { 1756 @settings.Content 1757 } 1758 @using System.Reflection 1759 @using Dynamicweb.Rapido.Blocks.Components.General 1760 @using Dynamicweb.Rapido.Blocks.Components 1761 1762 1763 @* Component *@ 1764 1765 @helper RenderContentModule(ContentModule settings) { 1766 if (!string.IsNullOrEmpty(settings.Content)) 1767 { 1768 @settings.Content 1769 } 1770 } 1771 @using System.Reflection 1772 @using Dynamicweb.Rapido.Blocks.Components.General 1773 @using Dynamicweb.Rapido.Blocks.Components 1774 1775 1776 @* Component *@ 1777 1778 @helper RenderModal(Modal settings) { 1779 if (settings != null) 1780 { 1781 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1782 1783 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1784 1785 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1786 1787 <div class="modal-container"> 1788 @if (!settings.DisableDarkOverlay) 1789 { 1790 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1791 } 1792 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1793 @if (settings.Heading != null) 1794 { 1795 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1796 { 1797 <div class="modal__header"> 1798 @Render(settings.Heading) 1799 </div> 1800 } 1801 } 1802 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1803 @if (!string.IsNullOrEmpty(settings.BodyText)) 1804 { 1805 @settings.BodyText 1806 } 1807 @if (settings.BodyTemplate != null) 1808 { 1809 @settings.BodyTemplate 1810 } 1811 @{ 1812 var actions = settings.GetActions(); 1813 } 1814 </div> 1815 @if (actions.Length > 0) 1816 { 1817 <div class="modal__footer"> 1818 @foreach (var action in actions) 1819 { 1820 if (Pageview.Device.ToString() != "Mobile") { 1821 action.CssClass += " u-no-margin"; 1822 } else { 1823 action.CssClass += " u-full-width u-margin-bottom"; 1824 } 1825 1826 @Render(action) 1827 } 1828 </div> 1829 } 1830 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1831 </div> 1832 </div> 1833 } 1834 } 1835 @using Dynamicweb.Rapido.Blocks.Components.General 1836 1837 @* Component *@ 1838 1839 @helper RenderMediaListItem(MediaListItem settings) 1840 { 1841 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1842 @if (!string.IsNullOrEmpty(settings.Label)) 1843 { 1844 if (!string.IsNullOrEmpty(settings.Link)) 1845 { 1846 @Render(new Link 1847 { 1848 Href = settings.Link, 1849 CssClass = "media-list-item__sticker dw-mod", 1850 ButtonLayout = ButtonLayout.None, 1851 Title = settings.Label, 1852 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1853 }) 1854 } 1855 else if (!string.IsNullOrEmpty(settings.OnClick)) 1856 { 1857 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1858 <span class="u-uppercase">@settings.Label</span> 1859 </span> 1860 } 1861 else 1862 { 1863 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1864 <span class="u-uppercase">@settings.Label</span> 1865 </span> 1866 } 1867 } 1868 <div class="media-list-item__wrap"> 1869 <div class="media-list-item__info dw-mod"> 1870 <div class="media-list-item__header dw-mod"> 1871 @if (!string.IsNullOrEmpty(settings.Title)) 1872 { 1873 if (!string.IsNullOrEmpty(settings.Link)) 1874 { 1875 @Render(new Link 1876 { 1877 Href = settings.Link, 1878 CssClass = "media-list-item__name dw-mod", 1879 ButtonLayout = ButtonLayout.None, 1880 Title = settings.Title, 1881 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1882 }) 1883 } 1884 else if (!string.IsNullOrEmpty(settings.OnClick)) 1885 { 1886 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1887 } 1888 else 1889 { 1890 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1891 } 1892 } 1893 1894 @if (!string.IsNullOrEmpty(settings.Status)) 1895 { 1896 <div class="media-list-item__state dw-mod">@settings.Status</div> 1897 } 1898 </div> 1899 @{ 1900 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1901 } 1902 1903 @Render(settings.InfoTable) 1904 </div> 1905 <div class="media-list-item__actions dw-mod"> 1906 <div class="media-list-item__actions-list dw-mod"> 1907 @{ 1908 var actions = settings.GetActions(); 1909 1910 foreach (ButtonBase action in actions) 1911 { 1912 action.ButtonLayout = ButtonLayout.None; 1913 action.CssClass += " media-list-item__action link"; 1914 1915 @Render(action) 1916 } 1917 } 1918 </div> 1919 1920 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1921 { 1922 settings.SelectButton.CssClass += " u-no-margin"; 1923 1924 <div class="media-list-item__action-button"> 1925 @Render(settings.SelectButton) 1926 </div> 1927 } 1928 </div> 1929 </div> 1930 </div> 1931 } 1932 @using Dynamicweb.Rapido.Blocks.Components.General 1933 @using Dynamicweb.Rapido.Blocks.Components 1934 1935 @helper RenderTable(Table settings) 1936 { 1937 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1938 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1939 1940 var enumToClasses = new Dictionary<TableDesign, string> 1941 { 1942 { TableDesign.Clean, "table--clean" }, 1943 { TableDesign.Bordered, "table--bordered" }, 1944 { TableDesign.Striped, "table--striped" }, 1945 { TableDesign.Hover, "table--hover" }, 1946 { TableDesign.Compact, "table--compact" }, 1947 { TableDesign.Condensed, "table--condensed" }, 1948 { TableDesign.NoTopBorder, "table--no-top-border" } 1949 }; 1950 string tableDesignClass = ""; 1951 if (settings.Design != TableDesign.None) 1952 { 1953 tableDesignClass = enumToClasses[settings.Design]; 1954 } 1955 1956 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1957 1958 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1959 1960 <table @ComponentMethods.AddAttributes(resultAttributes)> 1961 @if (settings.Header != null) 1962 { 1963 <thead> 1964 @Render(settings.Header) 1965 </thead> 1966 } 1967 <tbody> 1968 @foreach (var row in settings.Rows) 1969 { 1970 @Render(row) 1971 } 1972 </tbody> 1973 @if (settings.Footer != null) 1974 { 1975 <tfoot> 1976 @Render(settings.Footer) 1977 </tfoot> 1978 } 1979 </table> 1980 } 1981 @using Dynamicweb.Rapido.Blocks.Components.General 1982 @using Dynamicweb.Rapido.Blocks.Components 1983 1984 @helper RenderTableRow(TableRow settings) 1985 { 1986 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1987 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1988 1989 var enumToClasses = new Dictionary<TableRowDesign, string> 1990 { 1991 { TableRowDesign.NoBorder, "table__row--no-border" }, 1992 { TableRowDesign.Border, "table__row--border" }, 1993 { TableRowDesign.TopBorder, "table__row--top-line" }, 1994 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1995 { TableRowDesign.Solid, "table__row--solid" } 1996 }; 1997 1998 string tableRowDesignClass = ""; 1999 if (settings.Design != TableRowDesign.None) 2000 { 2001 tableRowDesignClass = enumToClasses[settings.Design]; 2002 } 2003 2004 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 2005 2006 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2007 2008 <tr @ComponentMethods.AddAttributes(resultAttributes)> 2009 @foreach (var cell in settings.Cells) 2010 { 2011 if (settings.IsHeaderRow) 2012 { 2013 cell.IsHeader = true; 2014 } 2015 @Render(cell) 2016 } 2017 </tr> 2018 } 2019 @using Dynamicweb.Rapido.Blocks.Components.General 2020 @using Dynamicweb.Rapido.Blocks.Components 2021 @using Dynamicweb.Core 2022 2023 @helper RenderTableCell(TableCell settings) 2024 { 2025 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2026 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2027 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 2028 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 2029 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 2030 2031 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2032 2033 string tagName = settings.IsHeader ? "th" : "td"; 2034 2035 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 2036 @settings.Content 2037 @("</" + tagName + ">"); 2038 } 2039 @using System.Linq 2040 @using Dynamicweb.Rapido.Blocks.Components.General 2041 2042 @* Component *@ 2043 2044 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 2045 { 2046 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 2047 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 2048 2049 if (settings.NumberOfPages > 1) 2050 { 2051 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 2052 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 2053 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 2054 2055 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 2056 @if (settings.ShowPagingInfo) 2057 { 2058 <div class="pager__info dw-mod"> 2059 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 2060 </div> 2061 } 2062 <ul class="pager__list dw-mod"> 2063 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 2064 { 2065 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 2066 } 2067 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 2068 { 2069 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 2070 } 2071 @if (settings.GetPages().Any()) 2072 { 2073 foreach (var page in settings.GetPages()) 2074 { 2075 @Render(page) 2076 } 2077 } 2078 else 2079 { 2080 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 2081 { 2082 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 2083 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 2084 } 2085 } 2086 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 2087 { 2088 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 2089 } 2090 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 2091 { 2092 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 2093 } 2094 </ul> 2095 </div> 2096 } 2097 } 2098 2099 @helper RenderPaginationItem(PaginationItem settings) 2100 { 2101 if (settings.Icon == null) 2102 { 2103 settings.Icon = new Icon(); 2104 } 2105 2106 settings.Icon.Label = settings.Label; 2107 <li class="pager__btn dw-mod"> 2108 @if (settings.IsActive) 2109 { 2110 <span class="pager__num pager__num--current dw-mod"> 2111 @Render(settings.Icon) 2112 </span> 2113 } 2114 else 2115 { 2116 <a href="@settings.Link" class="pager__num dw-mod"> 2117 @Render(settings.Icon) 2118 </a> 2119 } 2120 </li> 2121 } 2122 2123 2124 @using Dynamicweb.Rapido.Blocks.Components.General 2125 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2126 2127 2128 2129 2130 2131 @functions { 2132 public string GenerateRgba(string color, string opacity) 2133 { 2134 color = color.Replace("#", ""); 2135 if (color.Length == 6) { 2136 return "rgba(" + Convert.ToInt32(color.Substring(0, 2), 16) + ", " + Convert.ToInt32(color.Substring(2, 2), 16) + ", " + Convert.ToInt32(color.Substring(4, 2), 16) + ", " + opacity + ");"; 2137 } else { 2138 return Convert.ToInt16(color).ToString(); 2139 } 2140 } 2141 } 2142 2143 @{ 2144 string link = !string.IsNullOrEmpty(Model.Item.GetString("Link")) ? Model.Item.GetString("Link") : ""; 2145 string linkTarget = link.Contains("http") ? "_blank" : "_self"; 2146 } 2147 2148 @if (!string.IsNullOrEmpty(link)) { 2149 <a href="@link" target="@linkTarget" class="u-overlay">&nbsp;</a> 2150 @RenderTheContent() 2151 } else { 2152 @RenderTheContent() 2153 } 2154 2155 @helper RenderTheContent(){ 2156 var colorService = new ColorSwatchService(); 2157 2158 string innerPadding = Model.Item.GetList("Padding") != null ? " padding-size-" + Model.Item.GetList("Padding").SelectedValue.ToLower() : ""; 2159 innerPadding += Model.Item.GetList("PaddingPosition") != null ? " padding-position-" + Model.Item.GetList("PaddingPosition").SelectedValue.ToLower() : ""; 2160 string outerMargin = Model.Item.GetList("Margin") != null ? " margin-" + Model.Item.GetList("Margin").SelectedValue.ToLower() : ""; 2161 string outerMarginPosition = Model.Item.GetList("MarginPosition") != null ? " margin-position-" + Model.Item.GetList("MarginPosition").SelectedValue.ToLower() : ""; 2162 2163 string cardBackgroundColor = Model.Item.GetString("CardBackgroundColor") != null ? Model.Item.GetString("CardBackgroundColor") : ""; 2164 cardBackgroundColor = !cardBackgroundColor.Contains("#") ? colorService.GetHexColor(Pageview.AreaID, cardBackgroundColor) : cardBackgroundColor; 2165 string styles = "background-color: " + cardBackgroundColor + ";"; 2166 if (!string.IsNullOrEmpty(Model.Item.GetString("Image"))) { 2167 int cropMode = !string.IsNullOrEmpty(Convert.ToString(Model.Item.GetList("ImageCrop"))) ? Convert.ToInt32(Model.Item.GetList("ImageCrop").SelectedValue) : 0; 2168 2169 Image image = new Image 2170 { 2171 Path = Model.Item.GetFile("Image") != null ? Model.Item.GetFile("Image").Path : "", 2172 CssClass = "background-image__cover", 2173 ImageDefault = new ImageSettings 2174 { 2175 Crop = cropMode, 2176 Height = 845, 2177 Width = 1920 2178 }, 2179 ImageMedium = new ImageSettings 2180 { 2181 Crop = cropMode, 2182 Height = 450, 2183 Width = 1024 2184 }, 2185 ImageSmall = new ImageSettings 2186 { 2187 Crop = cropMode, 2188 Height = 544, 2189 Width = 640 2190 } 2191 }; 2192 2193 image.FilterPrimary = !string.IsNullOrEmpty(Model.Item.GetList("ImageFilterPrimary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), Model.Item.GetList("ImageFilterPrimary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2194 image.FilterSecondary = !string.IsNullOrEmpty(Model.Item.GetList("ImageFilterSecondary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), Model.Item.GetList("ImageFilterSecondary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2195 2196 if (!string.IsNullOrEmpty(Model.Item.GetString("ColorForTheFilter"))) { 2197 image.FilterColor = Model.Item.GetString("ColorForTheFilter").StartsWith("#") ? GenerateRgba(Model.Item.GetString("ColorForTheFilter"), "0.3") : ""; 2198 } 2199 2200 <div class="background-image dw-mod"> 2201 <div class="background-image__wrapper dw-mod"> 2202 @Render(image) 2203 </div> 2204 </div> 2205 } 2206 2207 <div class="content-row__item__body @innerPadding @outerMargin @outerMarginPosition card-paragraph dw-mod" style="@styles"> 2208 @if (!string.IsNullOrEmpty(Model.Item.GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetString("Text"))) { 2209 if (!Model.Item.GetBoolean("HideTitle")) { 2210 @Render(new Heading { Title = Model.Item.GetString("Title"), CssClass = "u-no-margin", Level = 2 }) 2211 } 2212 @Render(new Text { Content = Model.Item.GetString("Text") }) 2213 } 2214 2215 @if (!string.IsNullOrEmpty(Model.Item.GetItem("ButtonOne").GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetItem("ButtonTwo").GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetItem("ButtonThree").GetString("Title"))) { 2216 <div> 2217 @ParagraphButton(Model.Item.GetItem("ButtonOne")) 2218 @ParagraphButton(Model.Item.GetItem("ButtonTwo")) 2219 @ParagraphButton(Model.Item.GetItem("ButtonThree")) 2220 </div> 2221 } 2222 </div> 2223 } 2224 2225 2226 @helper ParagraphButton(ItemViewModel item) { 2227 if (item != null) { 2228 if (!string.IsNullOrEmpty(item.GetString("Title"))) { 2229 Button button = new Button { 2230 Title = item.GetString("Title"), 2231 Href = item.GetString("Link"), 2232 CssClass = "u-no-margin", 2233 ButtonLayout = (ButtonLayout)System.Enum.Parse(typeof(ButtonLayout), char.ToUpper(item.GetList("Layout").SelectedValue[0]) + item.GetList("Layout").SelectedValue.Substring(1)) 2234 }; 2235 2236 if (!string.IsNullOrEmpty(item.GetString("Icon"))) { 2237 button.Icon = new Icon { 2238 CssClass = item.GetString("Icon") 2239 }; 2240 } 2241 2242 @Render(button) 2243 } 2244 } 2245 } 2246 2247 2248 2249 2250
Error executing template "Designs/Rapido/ContentPage/Paragraph/CardParagraph.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_776095055ad24d97af02f9a60cb157b4.<RenderTheContent>b__46_0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\S_DW_Thermex\Files\Templates\Designs\Rapido\ContentPage\Paragraph\CardParagraph.cshtml:line 2215
   at CompiledRazorTemplates.Dynamic.RazorEngine_776095055ad24d97af02f9a60cb157b4.Execute() in D:\Dynamicweb.net\Solutions\S_DW_Thermex\Files\Templates\Designs\Rapido\ContentPage\Paragraph\CardParagraph.cshtml:line 2152
   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.ParagraphViewModel> 2 @using Dynamicweb.Frontend 3 @using Dynamicweb.Content.Items 4 @using Dynamicweb 5 @using Dynamicweb.Rapido.Blocks.Components 6 @using Dynamicweb.Rapido.Blocks.Components.General 7 8 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 9 @using Dynamicweb.Frontend 10 11 @* Include the components *@ 12 @using System.Text.RegularExpressions 13 @using System.Collections.Generic 14 @using System.Reflection 15 @using System.Web 16 @using System.Web.UI.HtmlControls 17 @using Dynamicweb.Rapido.Blocks.Components 18 @using Dynamicweb.Rapido.Blocks.Components.Articles 19 @using Dynamicweb.Rapido.Blocks.Components.Documentation 20 @using Dynamicweb.Rapido.Blocks 21 22 23 @*--- START: Base block renderers ---*@ 24 25 @helper RenderBlockList(List<Block> blocks) 26 { 27 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 28 blocks = blocks.OrderBy(item => item.SortId).ToList(); 29 30 foreach (Block item in blocks) 31 { 32 if (debug) { 33 <!-- Block START: @item.Id --> 34 } 35 36 if (item.Design == null) 37 { 38 @RenderBlock(item) 39 } 40 else if (item.Design.RenderType == RenderType.None) { 41 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 42 43 <div class="@cssClass dw-mod"> 44 @RenderBlock(item) 45 </div> 46 } 47 else if (item.Design.RenderType != RenderType.Hide) 48 { 49 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 50 51 if (!item.SkipRenderBlocksList) { 52 if (item.Design.RenderType == RenderType.Row) 53 { 54 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 55 @RenderBlock(item) 56 </div> 57 } 58 59 if (item.Design.RenderType == RenderType.Column) 60 { 61 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 62 string size = item.Design.Size ?? "12"; 63 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 64 65 <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"> 66 @RenderBlock(item) 67 </div> 68 } 69 70 if (item.Design.RenderType == RenderType.Table) 71 { 72 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 73 @RenderBlock(item) 74 </table> 75 } 76 77 if (item.Design.RenderType == RenderType.TableRow) 78 { 79 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 80 @RenderBlock(item) 81 </tr> 82 } 83 84 if (item.Design.RenderType == RenderType.TableColumn) 85 { 86 <td class="@cssClass dw-mod" id="Block__@item.Id"> 87 @RenderBlock(item) 88 </td> 89 } 90 91 if (item.Design.RenderType == RenderType.CardHeader) 92 { 93 <div class="card-header @cssClass dw-mod"> 94 @RenderBlock(item) 95 </div> 96 } 97 98 if (item.Design.RenderType == RenderType.CardBody) 99 { 100 <div class="card @cssClass dw-mod"> 101 @RenderBlock(item) 102 </div> 103 } 104 105 if (item.Design.RenderType == RenderType.CardFooter) 106 { 107 <div class="card-footer @cssClass dw-mod"> 108 @RenderBlock(item) 109 </div> 110 } 111 } 112 else 113 { 114 @RenderBlock(item) 115 } 116 } 117 118 if (debug) { 119 <!-- Block END: @item.Id --> 120 } 121 } 122 } 123 124 @helper RenderBlock(Block item) 125 { 126 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 127 128 if (item.Template != null) 129 { 130 @BlocksPage.RenderTemplate(item.Template) 131 } 132 133 if (item.Component != null) 134 { 135 string customSufix = "Custom"; 136 string methodName = item.Component.HelperName; 137 138 ComponentBase[] methodParameters = new ComponentBase[1]; 139 methodParameters[0] = item.Component; 140 Type methodType = this.GetType(); 141 142 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 143 144 try { 145 if (debug) { 146 <!-- Component: @methodName.Replace("Render", "") --> 147 } 148 if(customMethod != null) { 149 @customMethod.Invoke(this, methodParameters).ToString(); 150 } else { 151 MethodInfo generalMethod = methodType.GetMethod(methodName); 152 @generalMethod.Invoke(this, methodParameters).ToString(); 153 } 154 } catch { 155 try { 156 MethodInfo generalMethod = methodType.GetMethod(methodName); 157 @generalMethod.Invoke(this, methodParameters).ToString(); 158 } catch(Exception ex) { 159 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 160 } 161 } 162 } 163 164 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 165 { 166 @RenderBlockList(item.BlocksList) 167 } 168 } 169 170 @*--- END: Base block renderers ---*@ 171 172 @using Dynamicweb.Rapido.Blocks.Components 173 @using Dynamicweb.Rapido.Blocks.Components.General 174 @using Dynamicweb.Rapido.Blocks 175 @using System.IO 176 177 @* Required *@ 178 @using Dynamicweb.Rapido.Blocks.Components 179 @using Dynamicweb.Rapido.Blocks.Components.General 180 @using Dynamicweb.Rapido.Blocks 181 182 183 @helper Render(ComponentBase component) 184 { 185 if (component != null) 186 { 187 @component.Render(this) 188 } 189 } 190 191 @* Components *@ 192 @using System.Reflection 193 @using Dynamicweb.Rapido.Blocks.Components.General 194 195 196 @* Component *@ 197 198 @helper RenderIcon(Icon settings) 199 { 200 if (settings != null) 201 { 202 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 203 204 if (settings.Name != null) 205 { 206 if (string.IsNullOrEmpty(settings.Label)) 207 { 208 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 209 } 210 else 211 { 212 if (settings.LabelPosition == IconLabelPosition.Before) 213 { 214 <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> 215 } 216 else 217 { 218 <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> 219 } 220 } 221 } 222 else if (!string.IsNullOrEmpty(settings.Label)) 223 { 224 @settings.Label 225 } 226 } 227 } 228 @using System.Reflection 229 @using Dynamicweb.Rapido.Blocks.Components.General 230 @using Dynamicweb.Rapido.Blocks.Components 231 @using Dynamicweb.Core 232 233 @* Component *@ 234 235 @helper RenderButton(Button settings) 236 { 237 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 238 { 239 Dictionary<string, string> attributes = new Dictionary<string, string>(); 240 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 241 if (settings.Disabled) { 242 attributes.Add("disabled", "true"); 243 classList.Add("disabled"); 244 } 245 246 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 247 { 248 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 249 @RenderConfirmDialog(settings); 250 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 251 } 252 253 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 254 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 255 if (!string.IsNullOrEmpty(settings.AltText)) 256 { 257 attributes.Add("title", settings.AltText); 258 } 259 else if (!string.IsNullOrEmpty(settings.Title)) 260 { 261 string cleanTitle = Regex.Replace(settings.Title, "<.*?>", String.Empty); 262 cleanTitle = cleanTitle.Replace("&nbsp;", " "); 263 attributes.Add("title", cleanTitle); 264 } 265 266 var onClickEvents = new List<string>(); 267 if (!string.IsNullOrEmpty(settings.OnClick)) 268 { 269 onClickEvents.Add(settings.OnClick); 270 } 271 if (!string.IsNullOrEmpty(settings.Href)) 272 { 273 onClickEvents.Add("location.href='" + settings.Href + "'"); 274 } 275 if (onClickEvents.Count > 0) 276 { 277 attributes.Add("onClick", string.Join(";", onClickEvents)); 278 } 279 280 if (settings.ButtonLayout != ButtonLayout.None) 281 { 282 classList.Add("btn"); 283 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 284 if (btnLayout == "linkclean") 285 { 286 btnLayout = "link-clean"; //fix 287 } 288 classList.Add("btn--" + btnLayout); 289 } 290 291 if (settings.Icon == null) 292 { 293 settings.Icon = new Icon(); 294 } 295 296 settings.Icon.CssClass += Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower() != "linkclean" ? " u-flex--align-center" : ""; 297 settings.Icon.Label = settings.Title; 298 299 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 300 301 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 302 } 303 } 304 305 @helper RenderConfirmDialog(Button settings) 306 { 307 Modal confirmDialog = new Modal { 308 Id = settings.Id, 309 Width = ModalWidth.Sm, 310 Heading = new Heading 311 { 312 Level = 2, 313 Title = settings.ConfirmTitle 314 }, 315 BodyText = settings.ConfirmText 316 }; 317 318 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 319 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 320 321 @Render(confirmDialog) 322 } 323 @using Dynamicweb.Rapido.Blocks.Components.General 324 @using Dynamicweb.Rapido.Blocks.Components 325 @using Dynamicweb.Core 326 327 @helper RenderDashboard(Dashboard settings) 328 { 329 var widgets = settings.GetWidgets(); 330 331 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 332 { 333 //set bg color for them 334 335 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 336 int r = Convert.ToInt16(color.R); 337 int g = Convert.ToInt16(color.G); 338 int b = Convert.ToInt16(color.B); 339 340 var count = widgets.Length; 341 var max = Math.Max(r, Math.Max(g, b)); 342 double step = 255.0 / (max * count); 343 var i = 0; 344 foreach (var widget in widgets) 345 { 346 i++; 347 348 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 349 widget.BackgroundColor = shade; 350 } 351 } 352 353 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 354 @foreach (var widget in widgets) 355 { 356 <div class="dashboard__widget"> 357 @Render(widget) 358 </div> 359 } 360 </div> 361 } 362 @using Dynamicweb.Rapido.Blocks.Components.General 363 @using Dynamicweb.Rapido.Blocks.Components 364 365 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 366 { 367 if (!string.IsNullOrEmpty(settings.Link)) 368 { 369 var backgroundStyles = ""; 370 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 371 { 372 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 373 } 374 375 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 376 <div class="u-center-middle u-color-light"> 377 @if (settings.Icon != null) 378 { 379 settings.Icon.CssClass += "widget__icon"; 380 @Render(settings.Icon) 381 } 382 <div class="widget__title">@settings.Title</div> 383 </div> 384 </a> 385 } 386 } 387 @using Dynamicweb.Rapido.Blocks.Components.General 388 @using Dynamicweb.Rapido.Blocks.Components 389 390 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 391 { 392 var backgroundStyles = ""; 393 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 394 { 395 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 396 } 397 398 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 399 <div class="u-center-middle u-color-light"> 400 @if (settings.Icon != null) 401 { 402 settings.Icon.CssClass += "widget__icon"; 403 @Render(settings.Icon) 404 } 405 <div class="widget__counter">@settings.Count</div> 406 <div class="widget__title">@settings.Title</div> 407 </div> 408 </div> 409 } 410 @using System.Reflection 411 @using Dynamicweb.Rapido.Blocks.Components.General 412 @using Dynamicweb.Rapido.Blocks.Components 413 @using Dynamicweb.Core 414 415 @* Component *@ 416 417 @helper RenderLink(Link settings) 418 { 419 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 420 { 421 Dictionary<string, string> attributes = new Dictionary<string, string>(); 422 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 423 if (settings.Disabled) 424 { 425 attributes.Add("disabled", "true"); 426 classList.Add("disabled"); 427 } 428 429 if (!string.IsNullOrEmpty(settings.AltText)) 430 { 431 attributes.Add("title", settings.AltText); 432 } 433 else if (!string.IsNullOrEmpty(settings.Title)) 434 { 435 attributes.Add("title", settings.Title); 436 } 437 438 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 439 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 440 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 441 attributes.Add("href", settings.Href); 442 443 if (settings.ButtonLayout != ButtonLayout.None) 444 { 445 classList.Add("btn"); 446 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 447 if (btnLayout == "linkclean") 448 { 449 btnLayout = "link-clean"; //fix 450 } 451 classList.Add("btn--" + btnLayout); 452 } 453 454 if (settings.Icon == null) 455 { 456 settings.Icon = new Icon(); 457 } 458 settings.Icon.Label = settings.Title; 459 460 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 461 { 462 settings.Rel = LinkRelType.Noopener; 463 } 464 if (settings.Target != LinkTargetType.None) 465 { 466 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 467 } 468 if (settings.Download) 469 { 470 attributes.Add("download", "true"); 471 } 472 if (settings.Rel != LinkRelType.None) 473 { 474 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 475 } 476 477 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 478 } 479 } 480 @using System.Reflection 481 @using Dynamicweb.Rapido.Blocks.Components 482 @using Dynamicweb.Rapido.Blocks.Components.General 483 @using Dynamicweb.Rapido.Blocks 484 485 486 @* Component *@ 487 488 @helper RenderRating(Rating settings) 489 { 490 if (settings.Score > 0) 491 { 492 int rating = settings.Score; 493 string iconType = "fa-star"; 494 495 switch (settings.Type.ToString()) { 496 case "Stars": 497 iconType = "fa-star"; 498 break; 499 case "Hearts": 500 iconType = "fa-heart"; 501 break; 502 case "Lemons": 503 iconType = "fa-lemon"; 504 break; 505 case "Bombs": 506 iconType = "fa-bomb"; 507 break; 508 } 509 510 <div class="u-ta-right"> 511 @for (int i = 0; i < settings.OutOf; i++) 512 { 513 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 514 } 515 </div> 516 } 517 } 518 @using System.Reflection 519 @using Dynamicweb.Rapido.Blocks.Components.General 520 @using Dynamicweb.Rapido.Blocks.Components 521 522 523 @* Component *@ 524 525 @helper RenderSelectFieldOption(SelectFieldOption settings) 526 { 527 Dictionary<string, string> attributes = new Dictionary<string, string>(); 528 if (settings.Checked) { attributes.Add("selected", "true"); } 529 if (settings.Disabled) { attributes.Add("disabled", "true"); } 530 if (settings.Value != null) { attributes.Add("value", settings.Value); } 531 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 532 533 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 534 } 535 @using System.Reflection 536 @using Dynamicweb.Rapido.Blocks.Components.General 537 @using Dynamicweb.Rapido.Blocks.Components 538 539 540 @* Component *@ 541 542 @helper RenderNavigation(Navigation settings) { 543 @RenderNavigation(new 544 { 545 id = settings.Id, 546 cssclass = settings.CssClass, 547 startLevel = settings.StartLevel, 548 endlevel = settings.EndLevel, 549 expandmode = settings.Expandmode, 550 sitemapmode = settings.SitemapMode, 551 template = settings.Template 552 }) 553 } 554 @using Dynamicweb.Rapido.Blocks.Components.General 555 @using Dynamicweb.Rapido.Blocks.Components 556 557 558 @* Component *@ 559 560 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 561 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 562 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 563 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 564 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 565 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 566 settings.SitemapMode = false; 567 568 @RenderNavigation(settings) 569 } 570 @using Dynamicweb.Rapido.Blocks.Components.General 571 @using Dynamicweb.Rapido.Blocks.Components 572 573 574 @* Component *@ 575 576 @helper RenderLeftNavigation(LeftNavigation settings) { 577 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 578 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 579 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 580 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 581 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 582 583 <div class="grid__cell"> 584 @RenderNavigation(settings) 585 </div> 586 } 587 @using System.Reflection 588 @using Dynamicweb.Rapido.Blocks.Components.General 589 @using Dynamicweb.Core 590 591 @* Component *@ 592 593 @helper RenderHeading(Heading settings) 594 { 595 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 596 { 597 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 598 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 599 600 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 601 if (!string.IsNullOrEmpty(settings.Link)) 602 { 603 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 604 } 605 else 606 { 607 if (settings.Icon == null) 608 { 609 settings.Icon = new Icon(); 610 } 611 settings.Icon.Label = settings.Title; 612 @Render(settings.Icon) 613 } 614 @("</" + tagName + ">"); 615 } 616 } 617 @using Dynamicweb.Rapido.Blocks.Components 618 @using Dynamicweb.Rapido.Blocks.Components.General 619 @using Dynamicweb.Rapido.Blocks 620 621 622 @* Component *@ 623 624 @helper RenderImage(Image settings) 625 { 626 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 627 { 628 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 629 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 630 631 if (settings.Caption != null) 632 { 633 @:<div> 634 } 635 636 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 637 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 638 639 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 640 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 641 @if (settings.Link != null) 642 { 643 <a href="@settings.Link"> 644 @RenderTheImage(settings) 645 </a> 646 } 647 else 648 { 649 @RenderTheImage(settings) 650 } 651 </div> 652 </div> 653 654 if (settings.Caption != null) 655 { 656 <span class="image-caption dw-mod">@settings.Caption</span> 657 @:</div> 658 } 659 } 660 else 661 { 662 if (settings.Caption != null) 663 { 664 @:<div> 665 } 666 if (!string.IsNullOrEmpty(settings.Link)) 667 { 668 <a href="@settings.Link"> 669 @RenderTheImage(settings) 670 </a> 671 } 672 else 673 { 674 @RenderTheImage(settings) 675 } 676 677 if (settings.Caption != null) 678 { 679 <span class="image-caption dw-mod">@settings.Caption</span> 680 @:</div> 681 } 682 } 683 } 684 685 @helper RenderTheImage(Image settings) 686 { 687 if (settings != null) 688 { 689 string alternativeImage = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("AlternativeImage")) ? Pageview.AreaSettings.GetItem("Settings").GetFile("AlternativeImage").PathUrlEncoded : "/Images/missing_image.jpg"; 690 string placeholderImage = "/Files/Images/placeholder.gif"; 691 string imageEngine = "/Admin/Public/GetImage.ashx?"; 692 693 string imageStyle = ""; 694 695 switch (settings.Style) 696 { 697 case ImageStyle.Ball: 698 imageStyle = "grid__cell-img--ball"; 699 break; 700 701 case ImageStyle.Triangle: 702 imageStyle = "grid__cell-img--triangle"; 703 break; 704 } 705 706 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle || settings.Style == ImageStyle.Triangle) 707 { 708 settings.ImageDefault.Crop = settings.ImageDefault.Crop == 5 ? settings.ImageDefault.Crop = 0 : settings.ImageDefault.Crop; 709 710 if (settings.ImageDefault != null) 711 { 712 settings.ImageDefault.Height = settings.ImageDefault.Width; 713 } 714 if (settings.ImageMedium != null) 715 { 716 settings.ImageMedium.Height = settings.ImageMedium.Width; 717 } 718 if (settings.ImageSmall != null) 719 { 720 settings.ImageSmall.Height = settings.ImageSmall.Width; 721 } 722 } 723 724 string defaultImage = imageEngine; 725 string imageSmall = ""; 726 string imageMedium = ""; 727 728 if (settings.DisableImageEngine) 729 { 730 defaultImage = settings.Path; 731 } 732 else 733 { 734 if (settings.ImageDefault != null) 735 { 736 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 737 738 if (settings.Path.GetType() != typeof(string)) 739 { 740 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 741 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 742 } 743 else 744 { 745 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 746 } 747 748 defaultImage += "&AlternativeImage=" + alternativeImage; 749 } 750 751 if (settings.ImageSmall != null) 752 { 753 imageSmall = "data-src-small=\"" + imageEngine; 754 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 755 756 if (settings.Path.GetType() != typeof(string)) 757 { 758 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 759 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 760 } 761 else 762 { 763 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 764 } 765 766 imageSmall += "&alternativeImage=" + alternativeImage; 767 768 imageSmall += "\""; 769 } 770 771 if (settings.ImageMedium != null) 772 { 773 imageMedium = "data-src-medium=\"" + imageEngine; 774 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 775 776 if (settings.Path.GetType() != typeof(string)) 777 { 778 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 779 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 780 } 781 else 782 { 783 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 784 } 785 786 imageMedium += "&alternativeImage=" + alternativeImage; 787 788 imageMedium += "\""; 789 } 790 } 791 792 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 793 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 794 if (!string.IsNullOrEmpty(settings.Title)) 795 { 796 optionalAttributes.Add("alt", settings.Title); 797 optionalAttributes.Add("title", settings.Title); 798 } 799 800 if (settings.DisableLazyLoad) 801 { 802 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 803 } 804 else 805 { 806 <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) /> 807 } 808 } 809 } 810 @using System.Reflection 811 @using Dynamicweb.Rapido.Blocks.Components.General 812 @using Dynamicweb.Rapido.Blocks.Components 813 814 @* Component *@ 815 816 @helper RenderFileField(FileField settings) 817 { 818 var attributes = new Dictionary<string, string>(); 819 if (string.IsNullOrEmpty(settings.Id)) 820 { 821 settings.Id = Guid.NewGuid().ToString("N"); 822 } 823 824 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 825 if (settings.Disabled) { attributes.Add("disabled", "true"); } 826 if (settings.Required) { attributes.Add("required", "true"); } 827 if (settings.Multiple) { attributes.Add("multiple", "true"); } 828 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 829 if (string.IsNullOrEmpty(settings.ChooseFileText)) 830 { 831 settings.ChooseFileText = Translate("Choose file"); 832 } 833 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 834 { 835 settings.NoFilesChosenText = Translate("No files chosen..."); 836 } 837 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 838 839 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 840 841 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 842 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 843 844 attributes.Add("type", "file"); 845 if (settings.Value != null) { attributes.Add("value", settings.Value); } 846 settings.CssClass = "u-full-width " + settings.CssClass; 847 848 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 849 850 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 851 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 852 { 853 <div class="u-full-width"> 854 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 855 @if (settings.Link != null) { 856 <div class="u-pull--right"> 857 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 858 @Render(settings.Link) 859 </div> 860 } 861 </div> 862 863 } 864 865 @if (!string.IsNullOrEmpty(settings.HelpText)) 866 { 867 <small class="form__help-text">@settings.HelpText</small> 868 } 869 870 <div class="form__field-combi file-input u-no-margin dw-mod"> 871 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 872 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 873 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 874 @if (settings.UploadButton != null) 875 { 876 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 877 @Render(settings.UploadButton) 878 } 879 </div> 880 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 881 </div> 882 } 883 @using System.Reflection 884 @using Dynamicweb.Rapido.Blocks.Components.General 885 @using Dynamicweb.Rapido.Blocks.Components 886 @using Dynamicweb.Core 887 @using System.Linq 888 889 @* Component *@ 890 891 @helper RenderDateTimeField(DateTimeField settings) 892 { 893 if (string.IsNullOrEmpty(settings.Id)) 894 { 895 settings.Id = Guid.NewGuid().ToString("N"); 896 } 897 if (settings.ExtraAttributes == null) 898 { 899 settings.ExtraAttributes = new Dictionary<string, string>(); 900 } 901 settings.ExtraAttributes.Add("autocomplete","off"); 902 var textField = new TextField { 903 Name = settings.Name, 904 Id = settings.Id, 905 Label = settings.Label, 906 HelpText = settings.HelpText, 907 Value = settings.Value, 908 Disabled = settings.Disabled, 909 Required = settings.Required, 910 ErrorMessage = settings.ErrorMessage, 911 CssClass = settings.CssClass, 912 WrapperCssClass = settings.WrapperCssClass, 913 OnChange = settings.OnChange, 914 OnClick = settings.OnClick, 915 Link = settings.Link, 916 ExtraAttributes = settings.ExtraAttributes, 917 // 918 Placeholder = settings.Placeholder 919 }; 920 921 @Render(textField) 922 923 List<string> jsAttributes = new List<string>(); 924 925 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 926 927 if (!string.IsNullOrEmpty(settings.DateFormat)) 928 { 929 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 930 } 931 if (!string.IsNullOrEmpty(settings.MinDate)) 932 { 933 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 934 } 935 if (!string.IsNullOrEmpty(settings.MaxDate)) 936 { 937 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 938 } 939 if (settings.IsInline) 940 { 941 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 942 } 943 if (settings.EnableTime) 944 { 945 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 946 } 947 if (settings.EnableWeekNumbers) 948 { 949 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 950 } 951 952 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 953 954 <script> 955 document.addEventListener( "DOMContentLoaded", function () { 956 flatpickr("#@textField.Id", { 957 onReady: function(selectedDates, dateStr, instance) { 958 instance.input.readOnly = false; 959 }, 960 onOpen: function(selectedDates, dateStr, instance) { 961 instance.input.readOnly = true; 962 }, 963 onClose: function(selectedDates, dateStr, instance) { 964 instance.input.readOnly = false; 965 //instance.input.blur(); 966 }, 967 @string.Join(",", jsAttributes) 968 } ) 969 } ); 970 </script> 971 } 972 @using System.Reflection 973 @using Dynamicweb.Rapido.Blocks.Components.General 974 @using Dynamicweb.Rapido.Blocks.Components 975 976 @* Component *@ 977 978 @helper RenderTextField(TextField settings) 979 { 980 var attributes = new Dictionary<string, string>(); 981 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 982 { 983 settings.Id = Guid.NewGuid().ToString("N"); 984 } 985 986 /*base settings*/ 987 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 988 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 989 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 990 if (settings.Disabled) { attributes.Add("disabled", "true"); } 991 if (settings.Required) { attributes.Add("required", "true"); } 992 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 993 /*end*/ 994 995 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 996 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 997 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 998 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 999 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1000 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1001 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1002 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1003 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1004 1005 settings.CssClass = "u-full-width " + settings.CssClass; 1006 1007 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1008 1009 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1010 1011 string noMargin = "u-no-margin"; 1012 if (!settings.ReadOnly) { 1013 noMargin = ""; 1014 } 1015 1016 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1017 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1018 { 1019 <div class="u-full-width"> 1020 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1021 @if (settings.Link != null) { 1022 settings.Link.ButtonLayout = ButtonLayout.LinkClean; 1023 1024 <div class="u-pull--right"> 1025 @Render(settings.Link) 1026 </div> 1027 } 1028 </div> 1029 1030 } 1031 1032 @if (!string.IsNullOrEmpty(settings.HelpText)) 1033 { 1034 <small class="form__help-text">@settings.HelpText</small> 1035 } 1036 1037 @if (settings.ActionButton != null) 1038 { 1039 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1040 <div class="form__field-combi u-no-margin dw-mod"> 1041 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1042 @Render(settings.ActionButton) 1043 </div> 1044 } 1045 else 1046 { 1047 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1048 } 1049 1050 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1051 </div> 1052 } 1053 @using System.Reflection 1054 @using Dynamicweb.Rapido.Blocks.Components.General 1055 @using Dynamicweb.Rapido.Blocks.Components 1056 1057 @* Component *@ 1058 1059 @helper RenderNumberField(NumberField settings) 1060 { 1061 var attributes = new Dictionary<string, string>(); 1062 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1063 { 1064 settings.Id = Guid.NewGuid().ToString("N"); 1065 } 1066 1067 /*base settings*/ 1068 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1069 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1070 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1071 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1072 if (settings.Required) { attributes.Add("required", "true"); } 1073 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1074 /*end*/ 1075 1076 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1077 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1078 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1079 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1080 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1081 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1082 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1083 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1084 attributes.Add("type", "number"); 1085 1086 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1087 1088 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1089 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1090 { 1091 <div class="u-full-width"> 1092 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1093 @if (settings.Link != null) { 1094 <div class="u-pull--right"> 1095 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1096 @Render(settings.Link) 1097 </div> 1098 } 1099 </div> 1100 1101 } 1102 1103 @if (!string.IsNullOrEmpty(settings.HelpText)) 1104 { 1105 <small class="form__help-text">@settings.HelpText</small> 1106 } 1107 1108 @if (settings.ActionButton != null) 1109 { 1110 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1111 <div class="form__field-combi u-no-margin dw-mod"> 1112 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1113 @Render(settings.ActionButton) 1114 </div> 1115 } 1116 else 1117 { 1118 <div class="form__field-combi u-no-margin dw-mod"> 1119 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1120 </div> 1121 } 1122 1123 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1124 </div> 1125 } 1126 @using System.Reflection 1127 @using Dynamicweb.Rapido.Blocks.Components.General 1128 @using Dynamicweb.Rapido.Blocks.Components 1129 1130 1131 @* Component *@ 1132 1133 @helper RenderTextareaField(TextareaField settings) 1134 { 1135 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1136 string id = settings.Id; 1137 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1138 { 1139 id = Guid.NewGuid().ToString("N"); 1140 } 1141 1142 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1143 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1144 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1145 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1146 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1147 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1148 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1149 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1150 if (settings.Required) { attributes.Add("required", "true"); } 1151 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1152 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1153 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1154 attributes.Add("name", settings.Name); 1155 1156 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1157 1158 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1159 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1160 { 1161 <div class="u-full-width"> 1162 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1163 @if (settings.Link != null) { 1164 <div class="u-pull--right"> 1165 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1166 @Render(settings.Link) 1167 </div> 1168 } 1169 </div> 1170 } 1171 1172 @if (!string.IsNullOrEmpty(settings.HelpText)) 1173 { 1174 <small class="form__help-text">@settings.HelpText</small> 1175 } 1176 1177 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1178 1179 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1180 </div> 1181 } 1182 @using System.Reflection 1183 @using Dynamicweb.Rapido.Blocks.Components.General 1184 @using Dynamicweb.Rapido.Blocks.Components 1185 1186 1187 @* Component *@ 1188 1189 @helper RenderHiddenField(HiddenField settings) { 1190 var attributes = new Dictionary<string, string>(); 1191 attributes.Add("type", "hidden"); 1192 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1193 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1194 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1195 1196 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1197 } 1198 @using System.Reflection 1199 @using Dynamicweb.Rapido.Blocks.Components.General 1200 @using Dynamicweb.Rapido.Blocks.Components 1201 1202 @* Component *@ 1203 1204 @helper RenderCheckboxField(CheckboxField settings) 1205 { 1206 var attributes = new Dictionary<string, string>(); 1207 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1208 { 1209 settings.Id = Guid.NewGuid().ToString("N"); 1210 } 1211 1212 /*base settings*/ 1213 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1214 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1215 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1216 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1217 if (settings.Required) { attributes.Add("required", "true"); } 1218 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1219 /*end*/ 1220 1221 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1222 1223 attributes.Add("type", "checkbox"); 1224 if (settings.Checked) { attributes.Add("checked", "true"); } 1225 settings.CssClass = "form__control " + settings.CssClass; 1226 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1227 1228 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1229 1230 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1231 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1232 @if (!string.IsNullOrEmpty(settings.Label)) 1233 { 1234 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1235 } 1236 1237 @if (settings.Link != null) { 1238 <span> 1239 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1240 @Render(settings.Link) 1241 </span> 1242 } 1243 1244 @if (!string.IsNullOrEmpty(settings.HelpText)) 1245 { 1246 <small class="form__help-text checkbox-help dw-mod">@settings.HelpText</small> 1247 } 1248 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1249 </div> 1250 } 1251 @using System.Reflection 1252 @using Dynamicweb.Rapido.Blocks.Components.General 1253 @using Dynamicweb.Rapido.Blocks.Components 1254 1255 1256 @* Component *@ 1257 1258 @helper RenderCheckboxListField(CheckboxListField settings) 1259 { 1260 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1261 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1262 { 1263 <div class="u-full-width"> 1264 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1265 @if (settings.Link != null) { 1266 <div class="u-pull--right"> 1267 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1268 @Render(settings.Link) 1269 </div> 1270 } 1271 </div> 1272 1273 } 1274 1275 <div class="u-pull--left"> 1276 @if (!string.IsNullOrEmpty(settings.HelpText)) 1277 { 1278 <small class="form__help-text">@settings.HelpText</small> 1279 } 1280 1281 @foreach (var item in settings.Options) 1282 { 1283 if (settings.Required) 1284 { 1285 item.Required = true; 1286 } 1287 if (settings.Disabled) 1288 { 1289 item.Disabled = true; 1290 } 1291 if (!string.IsNullOrEmpty(settings.Name)) 1292 { 1293 item.Name = settings.Name; 1294 } 1295 if (!string.IsNullOrEmpty(settings.CssClass)) 1296 { 1297 item.CssClass += settings.CssClass; 1298 } 1299 1300 /* value is not supported */ 1301 1302 if (!string.IsNullOrEmpty(settings.OnClick)) 1303 { 1304 item.OnClick += settings.OnClick; 1305 } 1306 if (!string.IsNullOrEmpty(settings.OnChange)) 1307 { 1308 item.OnChange += settings.OnChange; 1309 } 1310 @Render(item) 1311 } 1312 1313 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1314 </div> 1315 1316 </div> 1317 } 1318 @using Dynamicweb.Rapido.Blocks.Components.General 1319 1320 @* Component *@ 1321 1322 @helper RenderSearch(Search settings) 1323 { 1324 var searchValue = HttpContext.Current.Request.QueryString.Get(settings.SearchParameter) ?? ""; 1325 var groupValue = HttpContext.Current.Request.QueryString.Get(settings.GroupsParameter) ?? ""; 1326 1327 if (string.IsNullOrEmpty(settings.Id)) 1328 { 1329 settings.Id = Guid.NewGuid().ToString("N"); 1330 } 1331 1332 var resultAttributes = new Dictionary<string, string>(); 1333 1334 if (settings.PageSize != 0) 1335 { 1336 resultAttributes.Add("data-page-size", settings.PageSize.ToString()); 1337 } 1338 if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1339 { 1340 resultAttributes.Add("data-groups-feed-url", settings.GroupItemsFeedUrl); 1341 if (!string.IsNullOrEmpty(groupValue)) 1342 { 1343 resultAttributes.Add("data-selected-group", groupValue); 1344 } 1345 if (!string.IsNullOrEmpty(settings.GroupsParameter)) 1346 { 1347 resultAttributes.Add("data-groups-parameter", settings.GroupsParameter); 1348 } 1349 } 1350 resultAttributes.Add("data-force-init", "true"); 1351 if (settings.GoToFirstSearchResultOnEnter) 1352 { 1353 resultAttributes.Add("data-go-to-first-search-result-on-enter", settings.GoToFirstSearchResultOnEnter.ToString().ToLower()); 1354 } 1355 if (!string.IsNullOrEmpty(settings.SearchParameter)) 1356 { 1357 resultAttributes.Add("data-search-parameter", settings.SearchParameter); 1358 } 1359 resultAttributes.Add("data-search-feed-url", settings.SearchData.SearchFeedUrl); 1360 resultAttributes.Add("data-results-template-id", settings.SearchData.ResultsTemplateId); 1361 1362 if (settings.SecondSearchData != null) 1363 { 1364 resultAttributes.Add("data-second-search-feed-url", settings.SecondSearchData.SearchFeedUrl); 1365 resultAttributes.Add("data-second-results-template-id", settings.SecondSearchData.ResultsTemplateId); 1366 } 1367 if (!string.IsNullOrEmpty(settings.ResultsPageUrl)) 1368 { 1369 resultAttributes.Add("data-results-page-url", settings.ResultsPageUrl); 1370 } 1371 1372 resultAttributes = resultAttributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1373 1374 string searchFieldCss = (settings.SearchButton == null) ? "search--with-icon" : ""; 1375 1376 <div class="search @settings.CssClass @searchFieldCss js-search-data-source dw-mod" id="@settings.Id" @ComponentMethods.AddAttributes(resultAttributes)> 1377 @if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1378 { 1379 <button type="button" class="search__groups-btn dw-mod js-search-groups-btn">@Translate("All")</button> 1380 <ul class="dropdown dropdown--absolute-position dw-mod search__groups-results js-search-groups-list"></ul> 1381 } 1382 1383 <input type="text" class="search__field dw-mod js-search-field" placeholder="@settings.Placeholder" value="@searchValue"> 1384 1385 <div class="dropdown dropdown--absolute-position search__results dw-mod js-search-results @(settings.SecondSearchData != null ? "search__results--combined" : "")"> 1386 @if (settings.SecondSearchData != null) 1387 { 1388 <div class="search__column search__column--products dw-mod"> 1389 <div class="search__column-header dw-mod">@Translate("Products")</div> 1390 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1391 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1392 { 1393 @Render(new Link { 1394 Title = Translate("View all"), 1395 CssClass = "js-view-all-button u-margin", 1396 Href = settings.SearchData.ResultsPageUrl 1397 }); 1398 } 1399 </div> 1400 <div class="search__column search__column--pages dw-mod"> 1401 <div class="search__column-header">@Translate("Pages")</div> 1402 <ul class="search__results-list dw-mod js-search-results-second-list" id="@(settings.Id)_SecondResultsList"></ul> 1403 @if (!string.IsNullOrEmpty(settings.SecondSearchData.ResultsPageUrl)) 1404 { 1405 @Render(new Link 1406 { 1407 Title = Translate("View all"), 1408 CssClass = "js-view-all-button u-margin", 1409 Href = settings.SecondSearchData.ResultsPageUrl 1410 }); 1411 } 1412 </div> 1413 } 1414 else 1415 { 1416 <div class="search__column search__column--only dw-mod"> 1417 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1418 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1419 { 1420 @Render(new Link { 1421 Title = Translate("View all"), 1422 CssClass = "js-view-all-button u-margin", 1423 Href = settings.SearchData.ResultsPageUrl 1424 }); 1425 } 1426 </div> 1427 } 1428 </div> 1429 1430 @if (settings.SearchButton != null) 1431 { 1432 settings.SearchButton.CssClass += " search__btn js-search-btn"; 1433 if (settings.RenderDefaultSearchIcon) 1434 { 1435 settings.SearchButton.Icon = new Icon { Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue }; 1436 } 1437 @Render(settings.SearchButton); 1438 } 1439 </div> 1440 } 1441 @using System.Reflection 1442 @using Dynamicweb.Rapido.Blocks.Components.General 1443 @using Dynamicweb.Rapido.Blocks.Components 1444 1445 1446 @* Component *@ 1447 1448 @helper RenderSelectField(SelectField settings) 1449 { 1450 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1451 { 1452 settings.Id = Guid.NewGuid().ToString("N"); 1453 } 1454 1455 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1456 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1457 { 1458 <div class="u-full-width"> 1459 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1460 @if (settings.Link != null) { 1461 <div class="u-pull--right"> 1462 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1463 @Render(settings.Link) 1464 </div> 1465 } 1466 </div> 1467 } 1468 1469 @if (!string.IsNullOrEmpty(settings.HelpText)) 1470 { 1471 <small class="form__help-text">@settings.HelpText</small> 1472 } 1473 1474 @if (settings.ActionButton != null) 1475 { 1476 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1477 <div class="form__field-combi u-no-margin dw-mod"> 1478 @RenderSelectBase(settings) 1479 @Render(settings.ActionButton) 1480 </div> 1481 } 1482 else 1483 { 1484 @RenderSelectBase(settings) 1485 } 1486 1487 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1488 </div> 1489 } 1490 1491 @helper RenderSelectBase(SelectField settings) 1492 { 1493 var attributes = new Dictionary<string, string>(); 1494 1495 /*base settings*/ 1496 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1497 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1498 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1499 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1500 if (settings.Required) { attributes.Add("required", "true"); } 1501 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1502 /*end*/ 1503 1504 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1505 1506 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1507 @if (settings.Default != null) 1508 { 1509 @Render(settings.Default) 1510 } 1511 1512 @foreach (var item in settings.Options) 1513 { 1514 if (settings.Value != null) { 1515 item.Checked = item.Value == settings.Value; 1516 } 1517 @Render(item) 1518 } 1519 </select> 1520 } 1521 @using System.Reflection 1522 @using Dynamicweb.Rapido.Blocks.Components.General 1523 @using Dynamicweb.Rapido.Blocks.Components 1524 1525 @* Component *@ 1526 1527 @helper RenderRadioButtonField(RadioButtonField settings) 1528 { 1529 var attributes = new Dictionary<string, string>(); 1530 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1531 { 1532 settings.Id = Guid.NewGuid().ToString("N"); 1533 } 1534 1535 /*base settings*/ 1536 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1537 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1538 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1539 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1540 if (settings.Required) { attributes.Add("required", "true"); } 1541 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1542 /*end*/ 1543 1544 attributes.Add("type", "radio"); 1545 if (settings.Checked) { attributes.Add("checked", "true"); } 1546 settings.CssClass = "form__control " + settings.CssClass; 1547 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1548 1549 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1550 1551 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1552 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1553 @if (!string.IsNullOrEmpty(settings.Label)) 1554 { 1555 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1556 } 1557 @if (!string.IsNullOrEmpty(settings.HelpText)) 1558 { 1559 <small class="form__help-text">@settings.HelpText</small> 1560 } 1561 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1562 </div> 1563 } 1564 @using System.Reflection 1565 @using Dynamicweb.Rapido.Blocks.Components.General 1566 @using Dynamicweb.Rapido.Blocks.Components 1567 1568 1569 @* Component *@ 1570 1571 @helper RenderRadioButtonListField(RadioButtonListField settings) 1572 { 1573 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1574 1575 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1576 @if (!string.IsNullOrEmpty(settings.Label)) 1577 { 1578 <label>@settings.Label</label> 1579 } 1580 @if (!string.IsNullOrEmpty(settings.HelpText)) 1581 { 1582 <small class="form__help-text">@settings.HelpText</small> 1583 } 1584 1585 @foreach (var item in settings.Options) 1586 { 1587 if (settings.Required) 1588 { 1589 item.Required = true; 1590 } 1591 if (settings.Disabled) 1592 { 1593 item.Disabled = true; 1594 } 1595 if (!string.IsNullOrEmpty(settings.Name)) 1596 { 1597 item.Name = settings.Name; 1598 } 1599 if (settings.Value != null && settings.Value == item.Value) 1600 { 1601 item.Checked = true; 1602 } 1603 if (!string.IsNullOrEmpty(settings.OnClick)) 1604 { 1605 item.OnClick += settings.OnClick; 1606 } 1607 if (!string.IsNullOrEmpty(settings.OnChange)) 1608 { 1609 item.OnChange += settings.OnChange; 1610 } 1611 if (!string.IsNullOrEmpty(settings.CssClass)) 1612 { 1613 item.CssClass += settings.CssClass; 1614 } 1615 @Render(item) 1616 } 1617 1618 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1619 </div> 1620 } 1621 @using System.Reflection 1622 @using Dynamicweb.Rapido.Blocks.Components.General 1623 @using Dynamicweb.Rapido.Blocks.Components 1624 1625 1626 @* Component *@ 1627 1628 @helper RenderNotificationMessage(NotificationMessage settings) 1629 { 1630 if (!string.IsNullOrEmpty(settings.Message)) 1631 { 1632 var attributes = new Dictionary<string, string>(); 1633 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1634 1635 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1636 string messageLayoutClass = Enum.GetName(typeof(NotificationMessageLayout), settings.MessageLayout).ToLower(); 1637 string minHeightClass = settings.Icon != null ? "u-min-h70px" : ""; 1638 1639 <div class="notification-message-@messageTypeClass notification-message-@messageLayoutClass @messageLayoutClass @minHeightClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)> 1640 @if (settings.Icon != null) { 1641 settings.Icon.Label = !string.IsNullOrEmpty(settings.Icon.Label) ? settings.Message + settings.Icon.Label : settings.Message; 1642 @Render(settings.Icon) 1643 } else { 1644 @settings.Message 1645 } 1646 </div> 1647 } 1648 } 1649 @using Dynamicweb.Rapido.Blocks.Components.General 1650 1651 1652 @* Component *@ 1653 1654 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1655 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1656 1657 <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> 1658 @if (settings.SubBlocks != null) { 1659 @RenderBlockList(settings.SubBlocks) 1660 } 1661 </div> 1662 } 1663 @using System.Reflection 1664 @using Dynamicweb.Rapido.Blocks.Components.General 1665 @using Dynamicweb.Rapido.Blocks.Components 1666 @using System.Text.RegularExpressions 1667 1668 1669 @* Component *@ 1670 1671 @helper RenderSticker(Sticker settings) { 1672 if (!String.IsNullOrEmpty(settings.Title)) { 1673 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1674 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1675 1676 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1677 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1678 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1679 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1680 optionalAttributes.Add("style", styleTag); 1681 } 1682 1683 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1684 } 1685 } 1686 1687 @using System.Reflection 1688 @using Dynamicweb.Rapido.Blocks.Components.General 1689 @using Dynamicweb.Rapido.Blocks.Components 1690 1691 1692 @* Component *@ 1693 1694 @helper RenderStickersCollection(StickersCollection settings) 1695 { 1696 if (settings.Stickers.Count > 0) 1697 { 1698 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1699 1700 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1701 @foreach (Sticker sticker in settings.Stickers) 1702 { 1703 @Render(sticker) 1704 } 1705 </div> 1706 } 1707 } 1708 1709 @using Dynamicweb.Rapido.Blocks.Components.General 1710 1711 1712 @* Component *@ 1713 1714 @helper RenderForm(Form settings) { 1715 if (settings != null) 1716 { 1717 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1718 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1719 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1720 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1721 var enctypes = new Dictionary<string, string> 1722 { 1723 { "multipart", "multipart/form-data" }, 1724 { "text", "text/plain" }, 1725 { "application", "application/x-www-form-urlencoded" } 1726 }; 1727 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1728 optionalAttributes.Add("method", settings.Method.ToString()); 1729 1730 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1731 { 1732 @settings.FormStartMarkup 1733 } 1734 else 1735 { 1736 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1737 } 1738 1739 foreach (var field in settings.GetFields()) 1740 { 1741 @Render(field) 1742 } 1743 1744 @:</form> 1745 } 1746 } 1747 @using System.Reflection 1748 @using Dynamicweb.Rapido.Blocks.Components.General 1749 @using Dynamicweb.Rapido.Blocks.Components 1750 1751 1752 @* Component *@ 1753 1754 @helper RenderText(Text settings) 1755 { 1756 @settings.Content 1757 } 1758 @using System.Reflection 1759 @using Dynamicweb.Rapido.Blocks.Components.General 1760 @using Dynamicweb.Rapido.Blocks.Components 1761 1762 1763 @* Component *@ 1764 1765 @helper RenderContentModule(ContentModule settings) { 1766 if (!string.IsNullOrEmpty(settings.Content)) 1767 { 1768 @settings.Content 1769 } 1770 } 1771 @using System.Reflection 1772 @using Dynamicweb.Rapido.Blocks.Components.General 1773 @using Dynamicweb.Rapido.Blocks.Components 1774 1775 1776 @* Component *@ 1777 1778 @helper RenderModal(Modal settings) { 1779 if (settings != null) 1780 { 1781 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1782 1783 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1784 1785 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1786 1787 <div class="modal-container"> 1788 @if (!settings.DisableDarkOverlay) 1789 { 1790 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1791 } 1792 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1793 @if (settings.Heading != null) 1794 { 1795 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1796 { 1797 <div class="modal__header"> 1798 @Render(settings.Heading) 1799 </div> 1800 } 1801 } 1802 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1803 @if (!string.IsNullOrEmpty(settings.BodyText)) 1804 { 1805 @settings.BodyText 1806 } 1807 @if (settings.BodyTemplate != null) 1808 { 1809 @settings.BodyTemplate 1810 } 1811 @{ 1812 var actions = settings.GetActions(); 1813 } 1814 </div> 1815 @if (actions.Length > 0) 1816 { 1817 <div class="modal__footer"> 1818 @foreach (var action in actions) 1819 { 1820 if (Pageview.Device.ToString() != "Mobile") { 1821 action.CssClass += " u-no-margin"; 1822 } else { 1823 action.CssClass += " u-full-width u-margin-bottom"; 1824 } 1825 1826 @Render(action) 1827 } 1828 </div> 1829 } 1830 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1831 </div> 1832 </div> 1833 } 1834 } 1835 @using Dynamicweb.Rapido.Blocks.Components.General 1836 1837 @* Component *@ 1838 1839 @helper RenderMediaListItem(MediaListItem settings) 1840 { 1841 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1842 @if (!string.IsNullOrEmpty(settings.Label)) 1843 { 1844 if (!string.IsNullOrEmpty(settings.Link)) 1845 { 1846 @Render(new Link 1847 { 1848 Href = settings.Link, 1849 CssClass = "media-list-item__sticker dw-mod", 1850 ButtonLayout = ButtonLayout.None, 1851 Title = settings.Label, 1852 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1853 }) 1854 } 1855 else if (!string.IsNullOrEmpty(settings.OnClick)) 1856 { 1857 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1858 <span class="u-uppercase">@settings.Label</span> 1859 </span> 1860 } 1861 else 1862 { 1863 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1864 <span class="u-uppercase">@settings.Label</span> 1865 </span> 1866 } 1867 } 1868 <div class="media-list-item__wrap"> 1869 <div class="media-list-item__info dw-mod"> 1870 <div class="media-list-item__header dw-mod"> 1871 @if (!string.IsNullOrEmpty(settings.Title)) 1872 { 1873 if (!string.IsNullOrEmpty(settings.Link)) 1874 { 1875 @Render(new Link 1876 { 1877 Href = settings.Link, 1878 CssClass = "media-list-item__name dw-mod", 1879 ButtonLayout = ButtonLayout.None, 1880 Title = settings.Title, 1881 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1882 }) 1883 } 1884 else if (!string.IsNullOrEmpty(settings.OnClick)) 1885 { 1886 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1887 } 1888 else 1889 { 1890 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1891 } 1892 } 1893 1894 @if (!string.IsNullOrEmpty(settings.Status)) 1895 { 1896 <div class="media-list-item__state dw-mod">@settings.Status</div> 1897 } 1898 </div> 1899 @{ 1900 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1901 } 1902 1903 @Render(settings.InfoTable) 1904 </div> 1905 <div class="media-list-item__actions dw-mod"> 1906 <div class="media-list-item__actions-list dw-mod"> 1907 @{ 1908 var actions = settings.GetActions(); 1909 1910 foreach (ButtonBase action in actions) 1911 { 1912 action.ButtonLayout = ButtonLayout.None; 1913 action.CssClass += " media-list-item__action link"; 1914 1915 @Render(action) 1916 } 1917 } 1918 </div> 1919 1920 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1921 { 1922 settings.SelectButton.CssClass += " u-no-margin"; 1923 1924 <div class="media-list-item__action-button"> 1925 @Render(settings.SelectButton) 1926 </div> 1927 } 1928 </div> 1929 </div> 1930 </div> 1931 } 1932 @using Dynamicweb.Rapido.Blocks.Components.General 1933 @using Dynamicweb.Rapido.Blocks.Components 1934 1935 @helper RenderTable(Table settings) 1936 { 1937 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1938 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1939 1940 var enumToClasses = new Dictionary<TableDesign, string> 1941 { 1942 { TableDesign.Clean, "table--clean" }, 1943 { TableDesign.Bordered, "table--bordered" }, 1944 { TableDesign.Striped, "table--striped" }, 1945 { TableDesign.Hover, "table--hover" }, 1946 { TableDesign.Compact, "table--compact" }, 1947 { TableDesign.Condensed, "table--condensed" }, 1948 { TableDesign.NoTopBorder, "table--no-top-border" } 1949 }; 1950 string tableDesignClass = ""; 1951 if (settings.Design != TableDesign.None) 1952 { 1953 tableDesignClass = enumToClasses[settings.Design]; 1954 } 1955 1956 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1957 1958 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1959 1960 <table @ComponentMethods.AddAttributes(resultAttributes)> 1961 @if (settings.Header != null) 1962 { 1963 <thead> 1964 @Render(settings.Header) 1965 </thead> 1966 } 1967 <tbody> 1968 @foreach (var row in settings.Rows) 1969 { 1970 @Render(row) 1971 } 1972 </tbody> 1973 @if (settings.Footer != null) 1974 { 1975 <tfoot> 1976 @Render(settings.Footer) 1977 </tfoot> 1978 } 1979 </table> 1980 } 1981 @using Dynamicweb.Rapido.Blocks.Components.General 1982 @using Dynamicweb.Rapido.Blocks.Components 1983 1984 @helper RenderTableRow(TableRow settings) 1985 { 1986 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1987 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1988 1989 var enumToClasses = new Dictionary<TableRowDesign, string> 1990 { 1991 { TableRowDesign.NoBorder, "table__row--no-border" }, 1992 { TableRowDesign.Border, "table__row--border" }, 1993 { TableRowDesign.TopBorder, "table__row--top-line" }, 1994 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1995 { TableRowDesign.Solid, "table__row--solid" } 1996 }; 1997 1998 string tableRowDesignClass = ""; 1999 if (settings.Design != TableRowDesign.None) 2000 { 2001 tableRowDesignClass = enumToClasses[settings.Design]; 2002 } 2003 2004 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 2005 2006 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2007 2008 <tr @ComponentMethods.AddAttributes(resultAttributes)> 2009 @foreach (var cell in settings.Cells) 2010 { 2011 if (settings.IsHeaderRow) 2012 { 2013 cell.IsHeader = true; 2014 } 2015 @Render(cell) 2016 } 2017 </tr> 2018 } 2019 @using Dynamicweb.Rapido.Blocks.Components.General 2020 @using Dynamicweb.Rapido.Blocks.Components 2021 @using Dynamicweb.Core 2022 2023 @helper RenderTableCell(TableCell settings) 2024 { 2025 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2026 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2027 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 2028 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 2029 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 2030 2031 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2032 2033 string tagName = settings.IsHeader ? "th" : "td"; 2034 2035 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 2036 @settings.Content 2037 @("</" + tagName + ">"); 2038 } 2039 @using System.Linq 2040 @using Dynamicweb.Rapido.Blocks.Components.General 2041 2042 @* Component *@ 2043 2044 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 2045 { 2046 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 2047 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 2048 2049 if (settings.NumberOfPages > 1) 2050 { 2051 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 2052 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 2053 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 2054 2055 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 2056 @if (settings.ShowPagingInfo) 2057 { 2058 <div class="pager__info dw-mod"> 2059 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 2060 </div> 2061 } 2062 <ul class="pager__list dw-mod"> 2063 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 2064 { 2065 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 2066 } 2067 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 2068 { 2069 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 2070 } 2071 @if (settings.GetPages().Any()) 2072 { 2073 foreach (var page in settings.GetPages()) 2074 { 2075 @Render(page) 2076 } 2077 } 2078 else 2079 { 2080 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 2081 { 2082 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 2083 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 2084 } 2085 } 2086 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 2087 { 2088 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 2089 } 2090 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 2091 { 2092 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 2093 } 2094 </ul> 2095 </div> 2096 } 2097 } 2098 2099 @helper RenderPaginationItem(PaginationItem settings) 2100 { 2101 if (settings.Icon == null) 2102 { 2103 settings.Icon = new Icon(); 2104 } 2105 2106 settings.Icon.Label = settings.Label; 2107 <li class="pager__btn dw-mod"> 2108 @if (settings.IsActive) 2109 { 2110 <span class="pager__num pager__num--current dw-mod"> 2111 @Render(settings.Icon) 2112 </span> 2113 } 2114 else 2115 { 2116 <a href="@settings.Link" class="pager__num dw-mod"> 2117 @Render(settings.Icon) 2118 </a> 2119 } 2120 </li> 2121 } 2122 2123 2124 @using Dynamicweb.Rapido.Blocks.Components.General 2125 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2126 2127 2128 2129 2130 2131 @functions { 2132 public string GenerateRgba(string color, string opacity) 2133 { 2134 color = color.Replace("#", ""); 2135 if (color.Length == 6) { 2136 return "rgba(" + Convert.ToInt32(color.Substring(0, 2), 16) + ", " + Convert.ToInt32(color.Substring(2, 2), 16) + ", " + Convert.ToInt32(color.Substring(4, 2), 16) + ", " + opacity + ");"; 2137 } else { 2138 return Convert.ToInt16(color).ToString(); 2139 } 2140 } 2141 } 2142 2143 @{ 2144 string link = !string.IsNullOrEmpty(Model.Item.GetString("Link")) ? Model.Item.GetString("Link") : ""; 2145 string linkTarget = link.Contains("http") ? "_blank" : "_self"; 2146 } 2147 2148 @if (!string.IsNullOrEmpty(link)) { 2149 <a href="@link" target="@linkTarget" class="u-overlay">&nbsp;</a> 2150 @RenderTheContent() 2151 } else { 2152 @RenderTheContent() 2153 } 2154 2155 @helper RenderTheContent(){ 2156 var colorService = new ColorSwatchService(); 2157 2158 string innerPadding = Model.Item.GetList("Padding") != null ? " padding-size-" + Model.Item.GetList("Padding").SelectedValue.ToLower() : ""; 2159 innerPadding += Model.Item.GetList("PaddingPosition") != null ? " padding-position-" + Model.Item.GetList("PaddingPosition").SelectedValue.ToLower() : ""; 2160 string outerMargin = Model.Item.GetList("Margin") != null ? " margin-" + Model.Item.GetList("Margin").SelectedValue.ToLower() : ""; 2161 string outerMarginPosition = Model.Item.GetList("MarginPosition") != null ? " margin-position-" + Model.Item.GetList("MarginPosition").SelectedValue.ToLower() : ""; 2162 2163 string cardBackgroundColor = Model.Item.GetString("CardBackgroundColor") != null ? Model.Item.GetString("CardBackgroundColor") : ""; 2164 cardBackgroundColor = !cardBackgroundColor.Contains("#") ? colorService.GetHexColor(Pageview.AreaID, cardBackgroundColor) : cardBackgroundColor; 2165 string styles = "background-color: " + cardBackgroundColor + ";"; 2166 if (!string.IsNullOrEmpty(Model.Item.GetString("Image"))) { 2167 int cropMode = !string.IsNullOrEmpty(Convert.ToString(Model.Item.GetList("ImageCrop"))) ? Convert.ToInt32(Model.Item.GetList("ImageCrop").SelectedValue) : 0; 2168 2169 Image image = new Image 2170 { 2171 Path = Model.Item.GetFile("Image") != null ? Model.Item.GetFile("Image").Path : "", 2172 CssClass = "background-image__cover", 2173 ImageDefault = new ImageSettings 2174 { 2175 Crop = cropMode, 2176 Height = 845, 2177 Width = 1920 2178 }, 2179 ImageMedium = new ImageSettings 2180 { 2181 Crop = cropMode, 2182 Height = 450, 2183 Width = 1024 2184 }, 2185 ImageSmall = new ImageSettings 2186 { 2187 Crop = cropMode, 2188 Height = 544, 2189 Width = 640 2190 } 2191 }; 2192 2193 image.FilterPrimary = !string.IsNullOrEmpty(Model.Item.GetList("ImageFilterPrimary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), Model.Item.GetList("ImageFilterPrimary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2194 image.FilterSecondary = !string.IsNullOrEmpty(Model.Item.GetList("ImageFilterSecondary").SelectedValue) ? (ImageFilter) Enum.Parse(typeof(ImageFilter), Model.Item.GetList("ImageFilterSecondary").SelectedValue.Replace("-", ""), true) : ImageFilter.None; 2195 2196 if (!string.IsNullOrEmpty(Model.Item.GetString("ColorForTheFilter"))) { 2197 image.FilterColor = Model.Item.GetString("ColorForTheFilter").StartsWith("#") ? GenerateRgba(Model.Item.GetString("ColorForTheFilter"), "0.3") : ""; 2198 } 2199 2200 <div class="background-image dw-mod"> 2201 <div class="background-image__wrapper dw-mod"> 2202 @Render(image) 2203 </div> 2204 </div> 2205 } 2206 2207 <div class="content-row__item__body @innerPadding @outerMargin @outerMarginPosition card-paragraph dw-mod" style="@styles"> 2208 @if (!string.IsNullOrEmpty(Model.Item.GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetString("Text"))) { 2209 if (!Model.Item.GetBoolean("HideTitle")) { 2210 @Render(new Heading { Title = Model.Item.GetString("Title"), CssClass = "u-no-margin", Level = 2 }) 2211 } 2212 @Render(new Text { Content = Model.Item.GetString("Text") }) 2213 } 2214 2215 @if (!string.IsNullOrEmpty(Model.Item.GetItem("ButtonOne").GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetItem("ButtonTwo").GetString("Title")) || !string.IsNullOrEmpty(Model.Item.GetItem("ButtonThree").GetString("Title"))) { 2216 <div> 2217 @ParagraphButton(Model.Item.GetItem("ButtonOne")) 2218 @ParagraphButton(Model.Item.GetItem("ButtonTwo")) 2219 @ParagraphButton(Model.Item.GetItem("ButtonThree")) 2220 </div> 2221 } 2222 </div> 2223 } 2224 2225 2226 @helper ParagraphButton(ItemViewModel item) { 2227 if (item != null) { 2228 if (!string.IsNullOrEmpty(item.GetString("Title"))) { 2229 Button button = new Button { 2230 Title = item.GetString("Title"), 2231 Href = item.GetString("Link"), 2232 CssClass = "u-no-margin", 2233 ButtonLayout = (ButtonLayout)System.Enum.Parse(typeof(ButtonLayout), char.ToUpper(item.GetList("Layout").SelectedValue[0]) + item.GetList("Layout").SelectedValue.Substring(1)) 2234 }; 2235 2236 if (!string.IsNullOrEmpty(item.GetString("Icon"))) { 2237 button.Icon = new Icon { 2238 CssClass = item.GetString("Icon") 2239 }; 2240 } 2241 2242 @Render(button) 2243 } 2244 } 2245 } 2246 2247 2248 2249 2250
Error executing template "Designs/Rapido/ContentPage/Paragraph/CardParagraph.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_776095055ad24d97af02f9a60cb157b4.<RenderTheContent>b__46_0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\S_DW_Thermex\Files\Templates\Designs\Rapido\ContentPage\Paragraph\CardParagraph.cshtml:line 2215
   at CompiledRazorTemplates.Dynamic.RazorEngine_776095055ad24d97af02f9a60cb157b4.Execute() in D:\Dynamicweb.net\Solutions\S_DW_Thermex\Files\Templates\Designs\Rapido\ContentPage\Paragraph\CardParagraph.cshtml:line 2152
   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.ParagraphViewModel> 2 @using Dynamicweb.Frontend 3 @using Dynamicweb.Content.Items 4 @using Dynamicweb 5 @using Dynamicweb.Rapido.Blocks.Components 6 @using Dynamicweb.Rapido.Blocks.Components.General 7 8 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 9 @using Dynamicweb.Frontend 10 11 @* Include the components *@ 12 @using System.Text.RegularExpressions 13 @using System.Collections.Generic 14 @using System.Reflection 15 @using System.Web 16 @using System.Web.UI.HtmlControls 17 @using Dynamicweb.Rapido.Blocks.Components 18 @using Dynamicweb.Rapido.Blocks.Components.Articles 19 @using Dynamicweb.Rapido.Blocks.Components.Documentation 20 @using Dynamicweb.Rapido.Blocks 21 22 23 @*--- START: Base block renderers ---*@ 24 25 @helper RenderBlockList(List<Block> blocks) 26 { 27 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 28 blocks = blocks.OrderBy(item => item.SortId).ToList(); 29 30 foreach (Block item in blocks) 31 { 32 if (debug) { 33 <!-- Block START: @item.Id --> 34 } 35 36 if (item.Design == null) 37 { 38 @RenderBlock(item) 39 } 40 else if (item.Design.RenderType == RenderType.None) { 41 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 42 43 <div class="@cssClass dw-mod"> 44 @RenderBlock(item) 45 </div> 46 } 47 else if (item.Design.RenderType != RenderType.Hide) 48 { 49 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 50 51 if (!item.SkipRenderBlocksList) { 52 if (item.Design.RenderType == RenderType.Row) 53 { 54 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 55 @RenderBlock(item) 56 </div> 57 } 58 59 if (item.Design.RenderType == RenderType.Column) 60 { 61 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 62 string size = item.Design.Size ?? "12"; 63 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 64 65 <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"> 66 @RenderBlock(item) 67 </div> 68 } 69 70 if (item.Design.RenderType == RenderType.Table) 71 { 72 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 73 @RenderBlock(item) 74 </table> 75 } 76 77 if (item.Design.RenderType == RenderType.TableRow) 78 { 79 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 80 @RenderBlock(item) 81 </tr> 82 } 83 84 if (item.Design.RenderType == RenderType.TableColumn) 85 { 86 <td class="@cssClass dw-mod" id="Block__@item.Id"> 87 @RenderBlock(item) 88 </td> 89 } 90 91 if (item.Design.RenderType == RenderType.CardHeader) 92 { 93 <div class="card-header @cssClass dw-mod"> 94 @RenderBlock(item) 95 </div> 96 } 97 98 if (item.Design.RenderType == RenderType.CardBody) 99 { 100 <div class="card @cssClass dw-mod"> 101 @RenderBlock(item) 102 </div> 103 } 104 105 if (item.Design.RenderType == RenderType.CardFooter) 106 { 107 <div class="card-footer @cssClass dw-mod"> 108 @RenderBlock(item) 109 </div> 110 } 111 } 112 else 113 { 114 @RenderBlock(item) 115 } 116 } 117 118 if (debug) { 119 <!-- Block END: @item.Id --> 120 } 121 } 122 } 123 124 @helper RenderBlock(Block item) 125 { 126 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 127 128 if (item.Template != null) 129 { 130 @BlocksPage.RenderTemplate(item.Template) 131 } 132 133 if (item.Component != null) 134 { 135 string customSufix = "Custom"; 136 string methodName = item.Component.HelperName; 137 138 ComponentBase[] methodParameters = new ComponentBase[1]; 139 methodParameters[0] = item.Component; 140 Type methodType = this.GetType(); 141 142 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 143 144 try { 145 if (debug) { 146 <!-- Component: @methodName.Replace("Render", "") --> 147 } 148 if(customMethod != null) { 149 @customMethod.Invoke(this, methodParameters).ToString(); 150 } else { 151 MethodInfo generalMethod = methodType.GetMethod(methodName); 152 @generalMethod.Invoke(this, methodParameters).ToString(); 153 } 154 } catch { 155 try { 156 MethodInfo generalMethod = methodType.GetMethod(methodName); 157 @generalMethod.Invoke(this, methodParameters).ToString(); 158 } catch(Exception ex) { 159 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 160 } 161 } 162 } 163 164 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 165 { 166 @RenderBlockList(item.BlocksList) 167 } 168 } 169 170 @*--- END: Base block renderers ---*@ 171 172 @using Dynamicweb.Rapido.Blocks.Components 173 @using Dynamicweb.Rapido.Blocks.Components.General 174 @using Dynamicweb.Rapido.Blocks 175 @using System.IO 176 177 @* Required *@ 178 @using Dynamicweb.Rapido.Blocks.Components 179 @using Dynamicweb.Rapido.Blocks.Components.General 180 @using Dynamicweb.Rapido.Blocks 181 182 183 @helper Render(ComponentBase component) 184 { 185 if (component != null) 186 { 187 @component.Render(this) 188 } 189 } 190 191 @* Components *@ 192 @using System.Reflection 193 @using Dynamicweb.Rapido.Blocks.Components.General 194 195 196 @* Component *@ 197 198 @helper RenderIcon(Icon settings) 199 { 200 if (settings != null) 201 { 202 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 203 204 if (settings.Name != null) 205 { 206 if (string.IsNullOrEmpty(settings.Label)) 207 { 208 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 209 } 210 else 211 { 212 if (settings.LabelPosition == IconLabelPosition.Before) 213 { 214 <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> 215 } 216 else 217 { 218 <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> 219 } 220 } 221 } 222 else if (!string.IsNullOrEmpty(settings.Label)) 223 { 224 @settings.Label 225 } 226 } 227 } 228 @using System.Reflection 229 @using Dynamicweb.Rapido.Blocks.Components.General 230 @using Dynamicweb.Rapido.Blocks.Components 231 @using Dynamicweb.Core 232 233 @* Component *@ 234 235 @helper RenderButton(Button settings) 236 { 237 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 238 { 239 Dictionary<string, string> attributes = new Dictionary<string, string>(); 240 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 241 if (settings.Disabled) { 242 attributes.Add("disabled", "true"); 243 classList.Add("disabled"); 244 } 245 246 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 247 { 248 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 249 @RenderConfirmDialog(settings); 250 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 251 } 252 253 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 254 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 255 if (!string.IsNullOrEmpty(settings.AltText)) 256 {