Error executing template "/Designs/Rapido/Paragraph/PIMFiles.cshtml" System.ArgumentException: The requested block ID can not be found Parameter name: TopNavigation at Dynamicweb.Rapido.Blocks.BlocksPage.GetBlockListById(String childId) at CompiledRazorTemplates.Dynamic.RazorEngine_c6580ea1583942e381c836d64b7dd683.Execute() in D:\Dynamicweb.net\Solutions\FlexMedia\granzow.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\Paragraph\PIMFiles.cshtml:line 383 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.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2 @using Dynamicweb.Frontend.Devices 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Content 5 @using Dynamicweb.Core 6 @using System 7 @using System.IO 8 @using System.Web 9 @using System.Collections.Generic; 10 @using System.Linq 11 @using System.Text.RegularExpressions 12 @using Dynamicweb.Rapido.Blocks 13 @using Dynamicweb.Rapido.Blocks.Components.General 14 15 @functions { 16 BlocksPage filesPage = BlocksPage.GetBlockPage("FilesList"); 17 } 18 19 @{ 20 Block pageContainer = new Block() 21 { 22 Id = "PageContainer", 23 Template = RenderPageContainer(), 24 SortId = 20 25 }; 26 27 filesPage.Add(pageContainer); 28 29 30 Block filesScript = new Block() 31 { 32 Id = "ScriptTemplates", 33 SortId = 30, 34 BlocksList = new List<Block> 35 { 36 new Block() 37 { 38 Id = "FilesContainerScript", 39 SortId = 10, 40 Template = RenderFilesContainerScript(), 41 SkipRenderBlocksList = true, 42 BlocksList = new List<Block> { 43 new Block() 44 { 45 Id = "LeftNavigation", 46 SortId = 10, 47 Design = new Design 48 { 49 RenderType = RenderType.Column, 50 Size = "3" 51 } 52 }, 53 new Block() 54 { 55 Id = "FilesList", 56 SortId = 20, 57 Design = new Design 58 { 59 RenderType = RenderType.Column, 60 Size = "auto" 61 }, 62 BlocksList = new List<Block> { 63 new Block() 64 { 65 Id = "Top", 66 SortId = 10 67 }, 68 new Block() 69 { 70 Id = "Files", 71 SortId = 20, 72 Template = RenderFiles() 73 }, 74 new Block() 75 { 76 Id = "LoadMoreRow", 77 SortId = 30, 78 Design = new Design 79 { 80 RenderType = RenderType.Row 81 }, 82 BlocksList = new List<Block> 83 { 84 new Block() 85 { 86 Id = "LoadMore", 87 SortId = 10, 88 Design = new Design 89 { 90 RenderType = RenderType.Column, 91 Size = "12" 92 }, 93 Template = RenderLoadMore() 94 } 95 } 96 } 97 } 98 } 99 } 100 }, 101 new Block() 102 { 103 Id = "preRenderTemplate", 104 Template = RenderPreRenderTemplate() 105 }, 106 new Block() 107 { 108 Id = "PIMJavascript", 109 Template = RenderJavascript() 110 } 111 } 112 }; 113 114 filesPage.Add(filesScript); 115 } 116 117 @using Dynamicweb.Rapido.Blocks; 118 @using Dynamicweb.Rapido.Blocks.Components.General; 119 120 @functions { 121 BlocksPage downloadModalPage = BlocksPage.GetBlockPage("FilesList"); 122 } 123 124 @{ 125 Block downloadModal = new Block() 126 { 127 Id = "DownloadModal", 128 Component = new Modal 129 { 130 Id = "Download", 131 Width = ModalWidth.Sm, 132 Heading = new Heading { Title = Translate("Download"), Level = 2 }, 133 BodyTemplate = RenderDownloadModal() 134 } 135 }; 136 137 downloadModalPage.Add(downloadModal); 138 139 } 140 141 @helper RenderDownloadModal() 142 { 143 int exportPageId = GetPageIdByNavigationTag("PIMAssetExport"); 144 145 Form downloadForm = new Form 146 { 147 Action = "/Default.aspx?ID=" + exportPageId, 148 Method = FormMethod.Post, 149 CssClass = "u-no-margin" 150 }; 151 152 downloadForm.Add(new HiddenField { Id = "assetPath", Name = "assetPath" }); 153 downloadForm.Add(new HiddenField { Id = "siteUrl", Name = "siteUrl", Value = string.Format("{0}://{1}", GetGlobalValue("Global:Request.Scheme"), GetGlobalValue("Global:Request.Host")) }); 154 155 SelectField purposeSelect = new SelectField 156 { 157 Id = "purpose", 158 Name = "purpose", 159 Label = Translate("Purpose"), 160 CssClass = "u-full-width", 161 Options = new List<SelectFieldOption> { 162 new SelectFieldOption { 163 Value = "Office", 164 Label = Translate("Office") 165 }, 166 new SelectFieldOption { 167 Value = "Original", 168 Label = Translate("Original") 169 }, 170 new SelectFieldOption { 171 Value = "Print", 172 Label = Translate("Print") 173 }, 174 new SelectFieldOption { 175 Value = "Web", 176 Label = Translate("Web") 177 } 178 } 179 }; 180 downloadForm.Add(purposeSelect); 181 downloadForm.Add(new Button { ButtonType = ButtonType.Submit, Title = Translate("Export asset"), CssClass = "u-pull--right u-no-margin" }); 182 183 @Render(downloadForm) 184 } 185 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 186 @using Dynamicweb.Rapido.Blocks 187 @using Dynamicweb.Rapido.Blocks.Components.General 188 189 @functions { 190 BlocksPage imageModalPage = BlocksPage.GetBlockPage("FilesList"); 191 } 192 193 @{ 194 Block imageModal = new Block() 195 { 196 Id = "ImageModal", 197 Template = RenderImageModal() 198 }; 199 200 imageModalPage.Add(imageModal); 201 202 Block imageModalTemplates = new Block() 203 { 204 Id = "imageModalTemplates", 205 Template = RenderImageModalTemplates() 206 }; 207 208 imageModalPage.Add("ScriptTemplates", imageModalTemplates); 209 210 Block imageModalScripts = new Block() 211 { 212 Id = "imageModalScripts", 213 Template = RenderImageModalScripts() 214 }; 215 216 imageModalPage.Add("ScriptTemplates", imageModalScripts); 217 } 218 219 @helper RenderImageModal() 220 { 221 <!-- Trigger for the gallery modal --> 222 <input type="checkbox" id="PreviewModalTrigger" class="modal-trigger" /> 223 224 <!-- Gallery modal --> 225 <div class="modal-container"> 226 <label for="PreviewModalTrigger" id="PreviewModalOverlay" class="modal-overlay"></label> 227 <div class="modal modal--full-width" id="PreviewModal"> 228 <div class="modal__body modal__body--file-preview"> 229 <div class="grid"> 230 <div class="grid__col-md-6 grid--align-center"> 231 @Render(new Image { Id = "PreviewImage", CssClass = "js-gallery-image modal__image--file-preview", DisableLazyLoad = true, Path = "" }) 232 </div> 233 <div class="grid__col-md-6"> 234 <div id="ImageMetadataContainer" data-template="FileInformationTemplate"></div> 235 </div> 236 </div> 237 <label class="modal__close-btn" for="PreviewModalTrigger"></label> 238 </div> 239 </div> 240 </div> 241 } 242 243 @helper RenderImageModalTemplates() 244 { 245 <script id="ImageMetadataItemTemplate" type="text/x-template"> 246 {{#.}} 247 <tr> 248 <th>{{Key}}</th> 249 <td class="u-ta-left"><span id="Value">{{Value}}</span></td> 250 </tr> 251 {{/.}} 252 </script> 253 254 <script id="FileInformationTemplate" type="text/x-template"> 255 <div class="tabs dw-mod"> 256 <input type="radio" class="tabs__trigger" name="imageInfoTabs" id="FileInformation" checked=""> 257 {{#if IPTC.length}} 258 <input type="radio" class="tabs__trigger" name="imageInfoTabs" id="IPTC"> 259 {{/if}} 260 {{#if XMP.length}} 261 <input type="radio" class="tabs__trigger" name="imageInfoTabs" id="XMP"> 262 {{/if}} 263 {{#if EXIF.length}} 264 <input type="radio" class="tabs__trigger" name="imageInfoTabs" id="EXIF"> 265 {{/if}} 266 <div class="tabs__list dw-mod"> 267 <label for="FileInformation" class="tabs__label dw-mod">File information</label> 268 {{#if IPTC.length}} 269 <label for="IPTC" class="tabs__label dw-mod">IPTC</label> 270 {{/if}} 271 {{#if XMP.length}} 272 <label for="XMP" class="tabs__label dw-mod">XMP</label> 273 {{/if}} 274 {{#if EXIF.length}} 275 <label for="EXIF" class="tabs__label dw-mod">EXIF</label> 276 {{/if}} 277 </div> 278 279 <div class="tabs__blocks dw-mod"> 280 <div class="tabs__block dw-mod" data-title="File information"> 281 <div class="u-padding u-border-top"> 282 <table class="table table--clean table--compact"> 283 {{#ImageData}} 284 {{>ImageMetadataItemTemplate}} 285 {{/ImageData}} 286 </table> 287 288 {{#if DynamicwebMetadata.length}} 289 <h3>Custom metadata (Dynamicweb metadata)</h3> 290 <table class="table table--clean table--compact"> 291 {{#DynamicwebMetadata}} 292 {{>ImageMetadataItemTemplate}} 293 {{/DynamicwebMetadata}} 294 </table> 295 {{/if}} 296 </div> 297 </div> 298 {{#if IPTC.length}} 299 <div class="tabs__block dw-mod" data-title="IPTC"> 300 <div class="u-padding u-border-top"> 301 <table class="table table--clean table--compact"> 302 {{#IPTC}} 303 {{>ImageMetadataItemTemplate}} 304 {{/IPTC}} 305 </table> 306 </div> 307 </div> 308 {{/if}} 309 {{#if XMP.length}} 310 <div class="tabs__block dw-mod" data-title="XMP"> 311 <div class="u-padding u-border-top"> 312 <table class="table table--clean table--compact"> 313 {{#XMP}} 314 {{>ImageMetadataItemTemplate}} 315 {{/XMP}} 316 </table> 317 </div> 318 </div> 319 {{/if}} 320 {{#if EXIF.length}} 321 <div class="tabs__block dw-mod" data-title="EXIF"> 322 <div class="u-padding u-border-top"> 323 <table class="table table--clean table--compact"> 324 {{#EXIF}} 325 {{>ImageMetadataItemTemplate}} 326 {{/EXIF}} 327 </table> 328 </div> 329 </div> 330 {{/if}} 331 </div> 332 </div> 333 </script> 334 } 335 336 @helper RenderImageModalScripts() 337 { 338 <script> 339 function getPreview(fileId) { 340 let file = handlebarsBoltCache.Files.find((file) => (file.id == fileId)); 341 var previewImage = document.getElementById("PreviewImage"); 342 previewImage.classList.remove('u-w220px'); 343 if (file.icon) { 344 previewImage.src = file.icon; 345 previewImage.classList.add('u-w220px'); 346 } else { 347 previewImage.src = "/Admin/Public/GetImage.ashx?Width=900&Compression=75&image=/" + file.path; 348 } 349 previewImage.alt = file.name; 350 HandlebarsBolt.CreateItemsFromJson(JSON.parse(file.fileInfo), 'ImageMetadataContainer'); 351 } 352 </script> 353 } 354 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 355 @using Dynamicweb.Rapido.Blocks 356 @using Dynamicweb.Rapido.Blocks.Components.General 357 358 @functions { 359 BlocksPage facetsPage = BlocksPage.GetBlockPage("FilesList"); 360 } 361 362 @{ 363 string facetsBlockViewMode = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("ProductList").GetString("FacetsViewMode")) ? Pageview.AreaSettings.GetItem("ProductList").GetString("FacetsViewMode").ToLower() : "left"; 364 365 Block leftFacets = new Block() 366 { 367 Id = "LeftFacets", 368 Template = RenderLeftFacets() 369 }; 370 371 Block topFacets = new Block() 372 { 373 Id = "TopFacets", 374 Template = RenderTopFacets() 375 }; 376 377 if (facetsBlockViewMode == "left") 378 { 379 facetsPage.GetBlockListById("LeftNavigation").Add(leftFacets); 380 } 381 else 382 { 383 facetsPage.GetBlockListById("TopNavigation").Add(topFacets); 384 } 385 386 Block facetSelection = new Block() 387 { 388 Id = "FacetSelection", 389 Template = RenderFacetSelection() 390 }; 391 392 facetsPage.GetBlockListById("Top").Add(facetSelection); 393 394 Block facetSelectionTemplates = new Block() 395 { 396 Id = "FacetSelectionTemplates", 397 Template = RenderFacetSelectionTemplates() 398 }; 399 400 facetSelection.SortId = 30; 401 facetsPage.Add("ScriptTemplates", facetSelectionTemplates); 402 } 403 404 @helper RenderLeftFacets() 405 { 406 <div class="u-margin-bottom--lg"> 407 @Render(new Heading { Level = 2, Title = Translate("Filters"), CssClass = "u-no-margin" }) 408 </div> 409 410 <input type="checkbox" id="CheckFacetGroups" class="js-remember-state u-hidden" data-expand="CheckFacetGroups" /> 411 <div class="facets-container facets-container--left expandable--collapsed dw-mod" data-trigger="CheckFacetGroups"> 412 {{#FacetGroups}} 413 <input type="checkbox" id="OptionsGroup_{{name}}" class="expand-trigger js-remember-state" {{defaultState}} /> 414 415 <div class="expand-container facets-container__box dw-mod js-filter"> 416 <label class="expand-container__btn facets-container__header dw-mod" for="OptionsGroup_{{name}}">{{name}}</label> 417 <div class="expand-container__content dw-mod"> 418 <div class="u-margin {{showFilter}}"> 419 <input type="text" class="u-full-width u-no-margin" onkeyup="Filter.FilterItems(event)" placeholder="@Translate("Search")" /> 420 </div> 421 <div class="facets-container__list dw-mod"> 422 {{#FacetOptions}} 423 {{#ifCond template "===" "Checkboxes"}} 424 {{>Checkboxes}} 425 {{/ifCond}} 426 {{#ifCond template "===" "Range"}} 427 {{>Checkboxes}} 428 {{/ifCond}} 429 {{#ifCond template "===" "Weight"}} 430 {{>Checkboxes}} 431 {{/ifCond}} 432 {{#ifCond template "===" "Tags"}} 433 {{>Tags}} 434 {{/ifCond}} 435 {{#ifCond template "===" "Colors"}} 436 {{>Colors}} 437 {{/ifCond}} 438 {{/FacetOptions}} 439 <div class="u-hidden js-filter-not-found"> 440 @Translate("Your search gave 0 results") 441 </div> 442 </div> 443 </div> 444 </div> 445 {{/FacetGroups}} 446 </div> 447 <label for="CheckFacetGroups" class="btn btn--primary btn--full dw-mod js-expand-hide facets-container-trigger" data-trigger="CheckFacetGroups">@Translate("Select filters")</label> 448 <label for="CheckFacetGroups" class="btn btn--primary btn--full dw-mod expandable--collapsed facets-container-trigger" data-trigger="CheckFacetGroups">@Translate("Close filters")</label> 449 } 450 451 @helper RenderTopFacets() 452 { 453 <input type="checkbox" id="CheckFacetGroups" class="js-remember-state u-hidden" data-expand="CheckFacetGroups" /> 454 <div class="grid grid--external-bleed-x dw-mod expandable--collapsed facets-container facets-container--top" data-trigger="CheckFacetGroups"> 455 {{#FacetGroups}} 456 <div class="grid__col-lg-3 grid__col-md-3 grid__col-sm-4 grid__col-xs-12"> 457 <input type="checkbox" id="OptionsGroup_{{counter}}" class="dropdown-trigger" /> 458 <div class="dropdown dw-mod js-filter"> 459 <label class="dropdown__header dropdown__btn dw-mod" for="OptionsGroup_{{counter}}">{{name}}</label> 460 <div class="dropdown__content dropdown__content--padding dw-mod"> 461 <div class="u-margin-bottom {{showFilter}}"> 462 <input type="text" class="u-full-width u-no-margin" onkeyup="Filter.FilterItems(event)" placeholder="@Translate("Search")" /> 463 </div> 464 {{#FacetOptions}} 465 {{#ifCond template "===" "Checkboxes"}} 466 {{>Checkboxes}} 467 {{/ifCond}} 468 {{#ifCond template "===" "Range"}} 469 {{>Checkboxes}} 470 {{/ifCond}} 471 {{#ifCond template "===" "Weight"}} 472 {{>Checkboxes}} 473 {{/ifCond}} 474 {{#ifCond template "===" "Tags"}} 475 {{>Tags}} 476 {{/ifCond}} 477 {{#ifCond template "===" "Colors"}} 478 {{>Colors}} 479 {{/ifCond}} 480 {{/FacetOptions}} 481 <div class="u-hidden js-filter-not-found"> 482 @Translate("Your search gave 0 results") 483 </div> 484 </div> 485 <label class="dropdown-trigger-off" for="OptionsGroup_{{counter}}"></label> 486 </div> 487 </div> 488 {{/FacetGroups}} 489 </div> 490 <label for="CheckFacetGroups" class="btn btn--primary btn--full dw-mod js-expand-hide facets-container-trigger" data-trigger="CheckFacetGroups">@Translate("Select filters")</label> 491 <label for="CheckFacetGroups" class="btn btn--primary btn--full dw-mod expandable--collapsed facets-container-trigger" data-trigger="CheckFacetGroups">@Translate("Close filters")</label> 492 } 493 494 @helper RenderFacetSelection() 495 { 496 <text> 497 {{#if FacetSelections}} 498 <div class="buttons-collection u-margin-bottom" id="selectedFacets"> 499 {{#FacetSelections}} 500 {{>(lookup . 'template')}} 501 {{/FacetSelections}} 502 </div> 503 {{/if}} 504 </text> 505 } 506 507 @helper RenderFacetSelectionTemplates() 508 { 509 @*Facets*@ 510 <script id="Checkboxes" type="text/x-template"> 511 <div class="form__field-group u-no-margin dw-mod"> 512 <input type="checkbox" class="{{selected}} checkbox-facet__checkbox form__control dw-mod" onclick="Facets.UpdateFacets(this);" id="{{queryParameter}}{{value}}" name="{{queryParameter}}" value="[{{value}}]" {{selected}} {{disabled}}> 513 <label class="{{disabled}} checkbox-facet dw-mod" data-filter-value="{{label}}" for="{{queryParameter}}{{value}}"> 514 <span class="checkbox-facet__label dw-mod">{{label}}</span> 515 <span class="checkbox-facet__count dw-mod">({{count}})</span> 516 </label> 517 </div> 518 </script> 519 520 <script id="Tags" type="text/x-template"> 521 <button type="button" class="btn btn--tag {{selected}} {{disabled}}" data-filter-value="{{label}}" data-check="{{selected}}" onclick="Facets.UpdateFacets(this);" name="{{queryParameter}}" value="[{{value}}]" {{disabled}}> 522 {{label}} <span class="facets-group__counter">({{count}})</span> 523 </button> 524 </script> 525 526 <script id="Colors" type="text/x-template"> 527 <button type="button" class="btn btn--colorbox u-margin-right {{selected}} {{disabled}}" data-filter-value="{{label}}" style="background-color: {{value}}" title="{{label}}" data-check="{{selected}}" onclick="Facets.UpdateFacets(this);" name="{{queryParameter}}" value="[{{value}}]" {{disabled}}></button> 528 </script> 529 530 @*Facet selections*@ 531 <script id="SelectedFilter" type="text/x-template"> 532 <button type="button" class="btn btn--tag" data-check="checked" onclick="Facets.UpdateFacets(this);" name="{{queryParameter}}" value="[{{value}}]" title="@Translate("Remove filter")"> 533 {{group}}: {{label}} <i class="fas fa-times"></i> 534 </button> 535 </script> 536 537 <script id="SelectedColorFilter" type="text/x-template"> 538 <button type="button" class="btn btn--tag" data-check="checked" onclick="Facets.UpdateFacets(this);" name="{{queryParameter}}" value="[{{value}}]" title="@Translate("Remove filter")"> 539 {{group}}: <div class="btn__colorbox" style="background-color: {{label}}"></div> <i class="fas fa-times"></i> 540 </button> 541 </script> 542 543 <script id="ResetFilters" type="text/x-template"> 544 <button type="button" class="btn btn--tag" onclick="Facets.ResetFacets();"> 545 @Translate("Reset all filters") <i class="fas fa-redo"></i> 546 </button> 547 </script> 548 } 549 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 550 @using Dynamicweb.Rapido.Blocks 551 @using Dynamicweb.Rapido.Blocks.Components.General 552 553 @functions { 554 555 BlocksPage topNavigationPage = BlocksPage.GetBlockPage("FilesList"); 556 } 557 558 @{ 559 Block topNavigation = new Block() 560 { 561 Id = "TopNavigation", 562 SortId = 10, 563 Template = RenderTopNavigation() 564 }; 565 566 topNavigationPage.GetBlockListById("Top").Add(topNavigation); 567 568 Block listViewSelectListener = new Block() 569 { 570 Id = "ListViewSelectListener", 571 Template = RenderListViewSelectListener() 572 }; 573 574 topNavigationPage.Add("ScriptTemplates", listViewSelectListener); 575 576 Block searchTemplates = new Block() 577 { 578 Id = "SearchTemplates", 579 Template = RenderSearchTemplates() 580 }; 581 582 topNavigationPage.Add("ScriptTemplates", searchTemplates); 583 } 584 585 @helper RenderTopNavigation() 586 { 587 int feedPageId = GetPageIdByNavigationTag("FilesFeed"); 588 589 <div class="grid__cell"> 590 <div class="u-pull--left"> 591 <div class="u-margin-bottom--lg"> 592 @Render(new Heading { Level = 2, Title = Translate("Files found") + ": {{filesCount}}", CssClass = "u-no-margin" }) 593 </div> 594 </div> 595 <div class="grid__col--bleed grid__col-6 u-pull--right"> 596 <div class="grid__cell"> 597 <div class="collection u-no-margin u-pull--right"> 598 <input type="radio" class="tag-btn-trigger" id="ListViewBtn_FileItemContainer" name="ViewBtnGroup"> 599 <label for="ListViewBtn_FileItemContainer" class="btn btn--tag btn--sm u-no-margin" onclick="HandlebarsBolt.UpdateTemplate('Files', 'FileItemContainer')"><i class="fas fa-th-list"></i></label> 600 601 <input type="radio" class="tag-btn-trigger" id="ListViewBtn_FileGridItemContainer" name="ViewBtnGroup"> 602 <label for="ListViewBtn_FileGridItemContainer" class="btn btn--tag btn--sm u-no-margin" onclick="HandlebarsBolt.UpdateTemplate('Files', 'FileGridItemContainer')"><i class="fas fa-th"></i></label> 603 604 <input type="radio" class="tag-btn-trigger" id="ListViewBtn_FileDetailsItemContainer" name="ViewBtnGroup"> 605 <label for="ListViewBtn_FileDetailsItemContainer" class="btn btn--tag btn--sm u-no-margin" onclick="HandlebarsBolt.UpdateTemplate('Files', 'FileDetailsItemContainer')"><i class="fas fa-list"></i></label> 606 </div> 607 @RenderSearch() 608 </div> 609 </div> 610 </div> 611 } 612 613 @helper RenderSearch() 614 { 615 int filesFeedPageId = GetPageIdByNavigationTag("FilesFeed"); 616 string filesSearchPageId = filesFeedPageId + "&LayoutTemplate=Json.cshtml&DisableStatistics=True"; 617 string filesPageId = GetGlobalValue("Global:Page.ID"); 618 string searchPlaceholder = Translate("Search files"); 619 string searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? ""; 620 621 <div class="typeahead u-color-inherit js-typeahead u-margin-bottom u-pull--right u-w220px u-margin-right" data-page-size="10" id="FilesSearch" data-search-feed-id="@filesSearchPageId" data-result-page-id="@filesPageId"> 622 <input type="text" class="typeahead-search-field u-no-margin u-full-width js-typeahead-search-field" placeholder="@searchPlaceholder" value="@searchValue"> 623 <ul class="dropdown dropdown--absolute-position u-full-width js-handlebars-root js-typeahead-search-content u-min-w220px u-full-width dw-mod" id="FilesSearchContent" data-template="SearchContentTemplate" data-json-feed="/Default.aspx?ID=@filesSearchPageId" data-init-onload="false" data-preloader="minimal"></ul> 624 <button type="button" class="btn btn--condensed btn--primary u-no-margin dw-mod js-typeahead-enter-btn"><i class="fas fa-search"></i></button> 625 </div> 626 } 627 628 @helper RenderSearchTemplates() 629 { 630 @* Templates for Typeahead *@ 631 <script id="SearchGroupsTemplate" type="text/x-template"> 632 {{#.}} 633 <li class="dropdown__item dw-mod" onclick="Search.UpdateGroupSelection(this)" data-group-id="{{id}}">{{name}}</li> 634 {{/.}} 635 </script> 636 637 <script id="SearchContentTemplate" type="text/x-template"> 638 {{#.}} 639 {{#ifCond template "!==" "SearchMore"}} 640 <li class="dropdown__item dw-mod"> 641 <div onclick="getPreview('{{id}}'); document.getElementById('PreviewModalTrigger').checked=true"> 642 <div class="u-margin-right u-pull--left u-hidden-xs u-hidden-xxs"> 643 <img src="/Admin/Public/GetImage.ashx?width=45&height=38&crop=1&Compression=75&image={{path}}" alt="{{name}}"> 644 </div> 645 <div class="u-pull--left"> 646 <div class="u-bold u-max-w220px u-truncate-text js-typeahead-name">{{name}}</div> 647 <div class="item-number u-max-w210px dw-mod">{{path}}</div> 648 </div> 649 </div> 650 <div class="u-margin-left u-pull--right"> 651 <button type="button" class="btn btn--primary btn--condensed u-pull--right dw-mod u-no-margin js-ignore-click-outside" 652 onclick="addFileToDownloads('{{path}}');"> 653 <i class="fas fa-upload"></i> 654 </button> 655 </div> 656 </li> 657 {{/ifCond}} 658 {{#ifCond template "===" "SearchMore"}} 659 {{>SearchMore}} 660 {{/ifCond}} 661 {{/.}} 662 {{^.}} 663 <li class="dropdown__item dropdown__item--seperator dropdown__item--not-selectable js-no-result dw-mod"> 664 @Translate("Your search gave 0 results") 665 </li> 666 {{/.}} 667 </script> 668 669 <script id="SearchMore" type="text/x-template"> 670 <li class="dropdown__item dropdown__item--not-selectable dw-mod"> 671 <a href="/Default.aspx?ID=@GetGlobalValue("Global:Page.ID")&Search={{searchParameter}}" class="btn btn--primary btn--full u-no-margin dw-mod js-typeahead-link"> 672 @Translate("View all") 673 </a> 674 </li> 675 </script> 676 677 <script id="SearchEmpty" type="text/x-template"> 678 <li class="u-margin u-padding-left"> 679 @Translate("Your search gave 0 results") 680 </li> 681 </script> 682 } 683 684 @helper RenderListViewSelectListener() 685 { 686 <script> 687 let defaultTemplate = 'FileItemContainer'; 688 let container = 'FilesListContainer'; 689 let cookieName = 'FilesTemplate'; 690 691 document.addEventListener('DOMContentLoaded', function (event) { 692 document.getElementById(container).addEventListener('contentLoaded', function () { 693 let selectedMode = RememberState.GetCookie(cookieName); 694 let element = document.getElementById('ListViewBtn_' + (selectedMode != null ? selectedMode : defaultTemplate)); 695 if (element != null) { 696 element.checked = true; 697 } 698 }, false); 699 }); 700 </script> 701 } 702 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 703 @using Dynamicweb.Rapido.Blocks 704 @using Dynamicweb.Rapido.Blocks.Components.General 705 706 @functions { 707 BlocksPage viewGridPage = BlocksPage.GetBlockPage("FilesList"); 708 } 709 710 @{ 711 Block gridViewTemplate = new Block() 712 { 713 Id = "GridViewTemplate", 714 Template = RenderGridViewTemplate() 715 }; 716 717 viewGridPage.Add("ScriptTemplates", gridViewTemplate); 718 } 719 720 @helper RenderGridViewTemplate() 721 { 722 @* Grid view *@ 723 <script id="FileGridItemContainer" type="text/x-template"> 724 {{#.}} 725 <div id="File{{id}}" class="grid__col-lg-4 grid__col-md-4 grid__col-sm-4 grid__col-xs-6 product-list__grid-item dw-mod"> 726 <div class="grid__cell product-list__grid-item__image dw-mod"> 727 <label for="PreviewModalTrigger" onclick="getPreview('{{id}}')" {{#if icon}}class="u-padding--lg"{{/if}}> 728 {{#if icon}} 729 @Render(new Image { Path = "{{icon}}", Title = "{{name}}", CssClass = "grid__cell-img--centered u-padding--lg" }) 730 {{else}} 731 @Render(new Image { Path = "{{path}}", Title = "{{name}}", CssClass = "grid__cell-img--centered u-padding", ImageDefault = new ImageSettings { Width = 300, Height = 300, Crop = 5, FillCanvas = true } }) 732 {{/if}} 733 </label> 734 </div> 735 736 <div class="grid__cell product-list__grid-item__price-info dw-mod"> 737 <h6 class="u-condensed-text u-bold"> 738 <label for="PreviewModalTrigger" onclick="getPreview('{{id}}')">{{name}}</label> 739 </h6> 740 <div class="item-number u-margin-bottom dw-mod">{{path}}</div> 741 </div> 742 743 @if (Pageview.User != null) 744 { 745 <div class="product-list__grid-item__footer dw-mod"> 746 @Render(new Button 747 { 748 ButtonType = ButtonType.Button, 749 ButtonLayout = ButtonLayout.Primary, 750 OnClick = "addFileToDownloads('{{path}}');", 751 CssClass = "u-no-margin btn--condensed u-no-margin u-pull--right", 752 Icon = new Icon 753 { 754 Prefix = "fas", 755 Name = "fa-download", 756 LabelPosition = IconLabelPosition.After 757 } 758 }) 759 </div> 760 } 761 </div> 762 {{/.}} 763 </script> 764 } 765 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 766 @using Dynamicweb.Rapido.Blocks 767 @using Dynamicweb.Rapido.Blocks.Components.General 768 769 @functions { 770 BlocksPage viewDetailsPage = BlocksPage.GetBlockPage("FilesList"); 771 } 772 773 @{ 774 Block detailsViewTemplate = new Block() 775 { 776 Id = "DetailsViewTemplate", 777 Template = RenderDetailsViewTemplate() 778 }; 779 780 viewDetailsPage.Add("ScriptTemplates", detailsViewTemplate); 781 } 782 783 @helper RenderDetailsViewTemplate() 784 { 785 @* Details view *@ 786 787 <script id="FileDetailsItemContainer" type="text/x-template"> 788 {{#.}} 789 <div id="File{{id}}" class="grid__col-12 u-no-padding-y"> 790 <div class="product-list__details-item grid__col-12 grid--direction-row grid--align-center dw-mod"> 791 <div class="product-list__details-item__left grid__cell dw-mod"> 792 793 <div class="lightbox u-hidden-xxs"> 794 <label for="PreviewModalTrigger" onclick="getPreview('{{id}}')"> 795 {{#if icon}} 796 @Render(new Image { Path = "{{icon}}", Title = "{{name}}", CssClass = "u-w50px u-margin-right" }) 797 {{else}} 798 @Render(new Image { Path = "{{path}}", Title = "{{name}}", CssClass = "lightbox__image", ImageDefault = new ImageSettings { Width = 220, Height = 222, Crop = 5, FillCanvas = true }, DisableLazyLoad = true }) 799 @Render(new Image { Path = "{{path}}", Title = "{{name}}", CssClass = "u-margin-right", ImageDefault = new ImageSettings { Width = 50, Height = 50, Crop = 5, FillCanvas = true } }) 800 {{/if}} 801 </label> 802 </div> 803 804 <div class="u-margin-left u-margin-right"> 805 <h6 class="u-no-margin"> 806 <label for="PreviewModalTrigger" onclick="getPreview('{{id}}')">{{name}}</label> 807 </h6> 808 <div class="item-number dw-mod">{{path}}</div> 809 </div> 810 </div> 811 <div class="product-list__details-item__right grid__cell dw-mod"> 812 @if (Pageview.User != null) 813 { 814 @Render(new Button { 815 ButtonType = ButtonType.Button, 816 ButtonLayout = ButtonLayout.Primary, 817 OnClick = "addFileToDownloads('{{path}}');", 818 CssClass = "u-no-margin btn--condensed u-margin-left u-margin-right", 819 Icon = new Icon { 820 Prefix = "fas", 821 Name = "fa-download", 822 LabelPosition = IconLabelPosition.After 823 } 824 }) 825 } 826 </div> 827 </div> 828 </div> 829 {{/.}} 830 </script> 831 } 832 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 833 @using Dynamicweb.Rapido.Blocks 834 @using Dynamicweb.Rapido.Blocks.Components.General 835 836 @functions { 837 BlocksPage viewListPage = BlocksPage.GetBlockPage("FilesList"); 838 } 839 840 @{ 841 Block listViewTemplate = new Block() 842 { 843 Id = "ListViewTemplate", 844 Template = RenderListViewTemplate() 845 }; 846 847 viewListPage.Add("ScriptTemplates", listViewTemplate); 848 } 849 850 @helper RenderListViewTemplate() 851 { 852 @* List view *@ 853 <script id="FileItemContainer" type="text/x-template"> 854 {{#.}} 855 <div id="File{{id}}" class="grid__col-12 dw-mod"> 856 <div class="grid product-list__list-item dw-mod"> 857 <div class="grid__col-md-4 {{noImage}} product-list__list-item__left u-no-padding u-color-light--bg dw-mod"> 858 <div class="grid__cell"> 859 <label for="PreviewModalTrigger" onclick="getPreview('{{id}}')" class="u-flex u-full-height"> 860 {{#if icon}} 861 @Render(new Image { Path = "{{icon}}", Title = "{{name}}", CssClass = "grid__cell-img--centered u-padding--lg" }) 862 {{else}} 863 @Render(new Image { Path = "{{path}}", Title = "{{name}}", CssClass = "grid__cell-img--centered u-padding", ImageDefault = new ImageSettings { Width = 300, Height = 300, Crop = 5, FillCanvas = true } }) 864 {{/if}} 865 </label> 866 </div> 867 </div> 868 <div class="grid__col-md-auto product-list__list-item__right dw-mod"> 869 <div class="grid__cell"> 870 <h2 class="u-no-margin"> 871 <label for="PreviewModalTrigger" onclick="getPreview('{{id}}')">{{name}}</label> 872 </h2> 873 <div class="item-number dw-mod">{{path}}</div> 874 <ul class="list list--clean u-margin-top dw-mod"> 875 <li><strong>@Translate("Updated"):</strong> {{lastWriteTime}}</li> 876 <li><strong>@Translate("File size"):</strong> {{size}} KB</li> 877 <li><strong>@Translate("File type"):</strong> {{extension}}</li> 878 {{#if dimension}} 879 <li><strong>@Translate("Dimension"):</strong> {{dimension}}</li> 880 {{/if}} 881 {{#if colors}} 882 <li><strong>@Translate("Colors"):</strong> {{colors}}</li> 883 {{/if}} 884 </ul> 885 </div> 886 887 @if (Pageview.User != null) 888 { 889 <div class="grid__cell-footer"> 890 <div class="grid__cell"> 891 @Render(new Button 892 { 893 ButtonType = ButtonType.Button, 894 ButtonLayout = ButtonLayout.Primary, 895 OnClick = "addFileToDownloads('{{path}}');", 896 CssClass = "u-no-margin btn--condensed u-no-margin u-pull--right", 897 Icon = new Icon 898 { 899 Prefix = "fas", 900 Name = "fa-download", 901 LabelPosition = IconLabelPosition.After 902 } 903 }) 904 </div> 905 </div> 906 } 907 </div> 908 </div> 909 </div> 910 {{/.}} 911 </script> 912 } 913 914 915 @* Include the required Grid builder (Contains the methods @RenderBlockList and @RenderBlock) *@ 916 @using System.Text.RegularExpressions 917 @using System.Collections.Generic 918 @using System.Reflection 919 @using System.Web 920 @using System.Web.UI.HtmlControls 921 @using Dynamicweb.Rapido.Blocks.Components 922 @using Dynamicweb.Rapido.Blocks.Components.Articles 923 @using Dynamicweb.Rapido.Blocks.Components.Documentation 924 @using Dynamicweb.Rapido.Blocks 925 926 927 @*--- START: Base block renderers ---*@ 928 929 @helper RenderBlockList(List<Block> blocks) 930 { 931 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 932 blocks = blocks.OrderBy(item => item.SortId).ToList(); 933 934 foreach (Block item in blocks) 935 { 936 if (debug) { 937 <!-- Block START: @item.Id --> 938 } 939 940 if (item.Design == null) 941 { 942 @RenderBlock(item) 943 } 944 else if (item.Design.RenderType == RenderType.None) { 945 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 946 947 <div class="@cssClass dw-mod"> 948 @RenderBlock(item) 949 </div> 950 } 951 else if (item.Design.RenderType != RenderType.Hide) 952 { 953 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 954 955 if (!item.SkipRenderBlocksList) { 956 if (item.Design.RenderType == RenderType.Row) 957 { 958 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 959 @RenderBlock(item) 960 </div> 961 } 962 963 if (item.Design.RenderType == RenderType.Column) 964 { 965 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 966 string size = item.Design.Size ?? "12"; 967 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 968 969 <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"> 970 @RenderBlock(item) 971 </div> 972 } 973 974 if (item.Design.RenderType == RenderType.Table) 975 { 976 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 977 @RenderBlock(item) 978 </table> 979 } 980 981 if (item.Design.RenderType == RenderType.TableRow) 982 { 983 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 984 @RenderBlock(item) 985 </tr> 986 } 987 988 if (item.Design.RenderType == RenderType.TableColumn) 989 { 990 <td class="@cssClass dw-mod" id="Block__@item.Id"> 991 @RenderBlock(item) 992 </td> 993 } 994 995 if (item.Design.RenderType == RenderType.CardHeader) 996 { 997 <div class="card-header @cssClass dw-mod"> 998 @RenderBlock(item) 999 </div> 1000 } 1001 1002 if (item.Design.RenderType == RenderType.CardBody) 1003 { 1004 <div class="card @cssClass dw-mod"> 1005 @RenderBlock(item) 1006 </div> 1007 } 1008 1009 if (item.Design.RenderType == RenderType.CardFooter) 1010 { 1011 <div class="card-footer @cssClass dw-mod"> 1012 @RenderBlock(item) 1013 </div> 1014 } 1015 } 1016 else 1017 { 1018 @RenderBlock(item) 1019 } 1020 } 1021 1022 if (debug) { 1023 <!-- Block END: @item.Id --> 1024 } 1025 } 1026 } 1027 1028 @helper RenderBlock(Block item) 1029 { 1030 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 1031 1032 if (item.Template != null) 1033 { 1034 @BlocksPage.RenderTemplate(item.Template) 1035 } 1036 1037 if (item.Component != null) 1038 { 1039 string customSufix = "Custom"; 1040 string methodName = item.Component.HelperName; 1041 1042 ComponentBase[] methodParameters = new ComponentBase[1]; 1043 methodParameters[0] = item.Component; 1044 Type methodType = this.GetType(); 1045 1046 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 1047 1048 try { 1049 if (debug) { 1050 <!-- Component: @methodName.Replace("Render", "") --> 1051 } 1052 if(customMethod != null) { 1053 @customMethod.Invoke(this, methodParameters).ToString(); 1054 } else { 1055 MethodInfo generalMethod = methodType.GetMethod(methodName); 1056 @generalMethod.Invoke(this, methodParameters).ToString(); 1057 } 1058 } catch { 1059 try { 1060 MethodInfo generalMethod = methodType.GetMethod(methodName); 1061 @generalMethod.Invoke(this, methodParameters).ToString(); 1062 } catch(Exception ex) { 1063 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 1064 } 1065 } 1066 } 1067 1068 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 1069 { 1070 @RenderBlockList(item.BlocksList) 1071 } 1072 } 1073 1074 @*--- END: Base block renderers ---*@ 1075 1076 @* Include the components *@ 1077 @using Dynamicweb.Rapido.Blocks.Components 1078 @using Dynamicweb.Rapido.Blocks.Components.General 1079 @using Dynamicweb.Rapido.Blocks 1080 @using System.IO 1081 1082 @* Required *@ 1083 @using Dynamicweb.Rapido.Blocks.Components 1084 @using Dynamicweb.Rapido.Blocks.Components.General 1085 @using Dynamicweb.Rapido.Blocks 1086 1087 1088 @helper Render(ComponentBase component) 1089 { 1090 if (component != null) 1091 { 1092 @component.Render(this) 1093 } 1094 } 1095 1096 @* Components *@ 1097 @using System.Reflection 1098 @using Dynamicweb.Rapido.Blocks.Components.General 1099 1100 1101 @* Component *@ 1102 1103 @helper RenderIcon(Icon settings) 1104 { 1105 if (settings != null) 1106 { 1107 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 1108 1109 if (settings.Name != null) 1110 { 1111 if (string.IsNullOrEmpty(settings.Label)) 1112 { 1113 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 1114 } 1115 else 1116 { 1117 if (settings.LabelPosition == IconLabelPosition.Before) 1118 { 1119 <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> 1120 } 1121 else 1122 { 1123 <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> 1124 } 1125 } 1126 } 1127 else if (!string.IsNullOrEmpty(settings.Label)) 1128 { 1129 @settings.Label 1130 } 1131 } 1132 } 1133 @using System.Reflection 1134 @using Dynamicweb.Rapido.Blocks.Components.General 1135 @using Dynamicweb.Rapido.Blocks.Components 1136 @using Dynamicweb.Core 1137 1138 @* Component *@ 1139 1140 @helper RenderButton(Button settings) 1141 { 1142 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 1143 { 1144 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1145 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 1146 if (settings.Disabled) { 1147 attributes.Add("disabled", "true"); 1148 classList.Add("disabled"); 1149 } 1150 1151 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 1152 { 1153 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1154 @RenderConfirmDialog(settings); 1155 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 1156 } 1157 1158 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1159 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1160 if (!string.IsNullOrEmpty(settings.AltText)) 1161 { 1162 attributes.Add("title", settings.AltText); 1163 } 1164 else if (!string.IsNullOrEmpty(settings.Title)) 1165 { 1166 string cleanTitle = Regex.Replace(settings.Title, "<.*?>", String.Empty); 1167 cleanTitle = cleanTitle.Replace(" ", " "); 1168 attributes.Add("title", cleanTitle); 1169 } 1170 1171 var onClickEvents = new List<string>(); 1172 if (!string.IsNullOrEmpty(settings.OnClick)) 1173 { 1174 onClickEvents.Add(settings.OnClick); 1175 } 1176 if (!string.IsNullOrEmpty(settings.Href)) 1177 { 1178 onClickEvents.Add("location.href='" + settings.Href + "'"); 1179 } 1180 if (onClickEvents.Count > 0) 1181 { 1182 attributes.Add("onClick", string.Join(";", onClickEvents)); 1183 } 1184 1185 if (settings.ButtonLayout != ButtonLayout.None) 1186 { 1187 classList.Add("btn"); 1188 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 1189 if (btnLayout == "linkclean") 1190 { 1191 btnLayout = "link-clean"; //fix 1192 } 1193 classList.Add("btn--" + btnLayout); 1194 } 1195 1196 if (settings.Icon == null) 1197 { 1198 settings.Icon = new Icon(); 1199 } 1200 1201 settings.Icon.CssClass += Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower() != "linkclean" ? " u-flex--align-center" : ""; 1202 settings.Icon.Label = settings.Title; 1203 1204 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 1205 1206 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 1207 } 1208 } 1209 1210 @helper RenderConfirmDialog(Button settings) 1211 { 1212 Modal confirmDialog = new Modal { 1213 Id = settings.Id, 1214 Width = ModalWidth.Sm, 1215 Heading = new Heading 1216 { 1217 Level = 2, 1218 Title = settings.ConfirmTitle 1219 }, 1220 BodyText = settings.ConfirmText 1221 }; 1222 1223 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 1224 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 1225 1226 @Render(confirmDialog) 1227 } 1228 @using Dynamicweb.Rapido.Blocks.Components.General 1229 @using Dynamicweb.Rapido.Blocks.Components 1230 @using Dynamicweb.Core 1231 1232 @helper RenderDashboard(Dashboard settings) 1233 { 1234 var widgets = settings.GetWidgets(); 1235 1236 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 1237 { 1238 //set bg color for them 1239 1240 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 1241 int r = Convert.ToInt16(color.R); 1242 int g = Convert.ToInt16(color.G); 1243 int b = Convert.ToInt16(color.B); 1244 1245 var count = widgets.Length; 1246 var max = Math.Max(r, Math.Max(g, b)); 1247 double step = 255.0 / (max * count); 1248 var i = 0; 1249 foreach (var widget in widgets) 1250 { 1251 i++; 1252 1253 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 1254 widget.BackgroundColor = shade; 1255 } 1256 } 1257 1258 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1259 @foreach (var widget in widgets) 1260 { 1261 <div class="dashboard__widget"> 1262 @Render(widget) 1263 </div> 1264 } 1265 </div> 1266 } 1267 @using Dynamicweb.Rapido.Blocks.Components.General 1268 @using Dynamicweb.Rapido.Blocks.Components 1269 1270 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 1271 { 1272 if (!string.IsNullOrEmpty(settings.Link)) 1273 { 1274 var backgroundStyles = ""; 1275 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 1276 { 1277 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 1278 } 1279 1280 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1281 <div class="u-center-middle u-color-light"> 1282 @if (settings.Icon != null) 1283 { 1284 settings.Icon.CssClass += "widget__icon"; 1285 @Render(settings.Icon) 1286 } 1287 <div class="widget__title">@settings.Title</div> 1288 </div> 1289 </a> 1290 } 1291 } 1292 @using Dynamicweb.Rapido.Blocks.Components.General 1293 @using Dynamicweb.Rapido.Blocks.Components 1294 1295 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 1296 { 1297 var backgroundStyles = ""; 1298 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 1299 { 1300 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 1301 } 1302 1303 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1304 <div class="u-center-middle u-color-light"> 1305 @if (settings.Icon != null) 1306 { 1307 settings.Icon.CssClass += "widget__icon"; 1308 @Render(settings.Icon) 1309 } 1310 <div class="widget__counter">@settings.Count</div> 1311 <div class="widget__title">@settings.Title</div> 1312 </div> 1313 </div> 1314 } 1315 @using System.Reflection 1316 @using Dynamicweb.Rapido.Blocks.Components.General 1317 @using Dynamicweb.Rapido.Blocks.Components 1318 @using Dynamicweb.Core 1319 1320 @* Component *@ 1321 1322 @helper RenderLink(Link settings) 1323 { 1324 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 1325 { 1326 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1327 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 1328 if (settings.Disabled) 1329 { 1330 attributes.Add("disabled", "true"); 1331 classList.Add("disabled"); 1332 } 1333 1334 if (!string.IsNullOrEmpty(settings.AltText)) 1335 { 1336 attributes.Add("title", settings.AltText); 1337 } 1338 else if (!string.IsNullOrEmpty(settings.Title)) 1339 { 1340 attributes.Add("title", settings.Title); 1341 } 1342 1343 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1344 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1345 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 1346 attributes.Add("href", settings.Href); 1347 1348 if (settings.ButtonLayout != ButtonLayout.None) 1349 { 1350 classList.Add("btn"); 1351 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 1352 if (btnLayout == "linkclean") 1353 { 1354 btnLayout = "link-clean"; //fix 1355 } 1356 classList.Add("btn--" + btnLayout); 1357 } 1358 1359 if (settings.Icon == null) 1360 { 1361 settings.Icon = new Icon(); 1362 } 1363 settings.Icon.Label = settings.Title; 1364 1365 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 1366 { 1367 settings.Rel = LinkRelType.Noopener; 1368 } 1369 if (settings.Target != LinkTargetType.None) 1370 { 1371 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 1372 } 1373 if (settings.Download) 1374 { 1375 attributes.Add("download", "true"); 1376 } 1377 if (settings.Rel != LinkRelType.None) 1378 { 1379 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 1380 } 1381 1382 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 1383 } 1384 } 1385 @using System.Reflection 1386 @using Dynamicweb.Rapido.Blocks.Components 1387 @using Dynamicweb.Rapido.Blocks.Components.General 1388 @using Dynamicweb.Rapido.Blocks 1389 1390 1391 @* Component *@ 1392 1393 @helper RenderRating(Rating settings) 1394 { 1395 if (settings.Score > 0) 1396 { 1397 int rating = settings.Score; 1398 string iconType = "fa-star"; 1399 1400 switch (settings.Type.ToString()) { 1401 case "Stars": 1402 iconType = "fa-star"; 1403 break; 1404 case "Hearts": 1405 iconType = "fa-heart"; 1406 break; 1407 case "Lemons": 1408 iconType = "fa-lemon"; 1409 break; 1410 case "Bombs": 1411 iconType = "fa-bomb"; 1412 break; 1413 } 1414 1415 <div class="u-ta-right"> 1416 @for (int i = 0; i < settings.OutOf; i++) 1417 { 1418 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 1419 } 1420 </div> 1421 } 1422 } 1423 @using System.Reflection 1424 @using Dynamicweb.Rapido.Blocks.Components.General 1425 @using Dynamicweb.Rapido.Blocks.Components 1426 1427 1428 @* Component *@ 1429 1430 @helper RenderSelectFieldOption(SelectFieldOption settings) 1431 { 1432 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1433 if (settings.Checked) { attributes.Add("selected", "true"); } 1434 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1435 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1436 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1437 1438 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 1439 } 1440 @using System.Reflection 1441 @using Dynamicweb.Rapido.Blocks.Components.General 1442 @using Dynamicweb.Rapido.Blocks.Components 1443 1444 1445 @* Component *@ 1446 1447 @helper RenderNavigation(Navigation settings) { 1448 @RenderNavigation(new 1449 { 1450 id = settings.Id, 1451 cssclass = settings.CssClass, 1452 startLevel = settings.StartLevel, 1453 endlevel = settings.EndLevel, 1454 expandmode = settings.Expandmode, 1455 sitemapmode = settings.SitemapMode, 1456 template = settings.Template 1457 }) 1458 } 1459 @using Dynamicweb.Rapido.Blocks.Components.General 1460 @using Dynamicweb.Rapido.Blocks.Components 1461 1462 1463 @* Component *@ 1464 1465 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 1466 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 1467 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 1468 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 1469 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 1470 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 1471 settings.SitemapMode = false; 1472 1473 @RenderNavigation(settings) 1474 } 1475 @using Dynamicweb.Rapido.Blocks.Components.General 1476 @using Dynamicweb.Rapido.Blocks.Components 1477 1478 1479 @* Component *@ 1480 1481 @helper RenderLeftNavigation(LeftNavigation settings) { 1482 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 1483 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 1484 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 1485 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 1486 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 1487 1488 <div class="grid__cell"> 1489 @RenderNavigation(settings) 1490 </div> 1491 } 1492 @using System.Reflection 1493 @using Dynamicweb.Rapido.Blocks.Components.General 1494 @using Dynamicweb.Core 1495 1496 @* Component *@ 1497 1498 @helper RenderHeading(Heading settings) 1499 { 1500 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 1501 { 1502 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 1503 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 1504 1505 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 1506 if (!string.IsNullOrEmpty(settings.Link)) 1507 { 1508 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 1509 } 1510 else 1511 { 1512 if (settings.Icon == null) 1513 { 1514 settings.Icon = new Icon(); 1515 } 1516 settings.Icon.Label = settings.Title; 1517 @Render(settings.Icon) 1518 } 1519 @("</" + tagName + ">"); 1520 } 1521 } 1522 @using Dynamicweb.Rapido.Blocks.Components 1523 @using Dynamicweb.Rapido.Blocks.Components.General 1524 @using Dynamicweb.Rapido.Blocks 1525 1526 1527 @* Component *@ 1528 1529 @helper RenderImage(Image settings) 1530 { 1531 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 1532 { 1533 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1534 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 1535 1536 if (settings.Caption != null) 1537 { 1538 @:<div> 1539 } 1540 1541 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 1542 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 1543 1544 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 1545 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 1546 @if (settings.Link != null) 1547 { 1548 <a href="@settings.Link"> 1549 @RenderTheImage(settings) 1550 </a> 1551 } 1552 else 1553 { 1554 @RenderTheImage(settings) 1555 } 1556 </div> 1557 </div> 1558 1559 if (settings.Caption != null) 1560 { 1561 <span class="image-caption dw-mod">@settings.Caption</span> 1562 @:</div> 1563 } 1564 } 1565 else 1566 { 1567 if (settings.Caption != null) 1568 { 1569 @:<div> 1570 } 1571 if (!string.IsNullOrEmpty(settings.Link)) 1572 { 1573 <a href="@settings.Link"> 1574 @RenderTheImage(settings) 1575 </a> 1576 } 1577 else 1578 { 1579 @RenderTheImage(settings) 1580 } 1581 1582 if (settings.Caption != null) 1583 { 1584 <span class="image-caption dw-mod">@settings.Caption</span> 1585 @:</div> 1586 } 1587 } 1588 } 1589 1590 @helper RenderTheImage(Image settings) 1591 { 1592 if (settings != null) 1593 { 1594 string alternativeImage = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("AlternativeImage")) ? Pageview.AreaSettings.GetItem("Settings").GetFile("AlternativeImage").PathUrlEncoded : "/Images/missing_image.jpg"; 1595 string placeholderImage = "/Files/Images/placeholder.gif"; 1596 string imageEngine = "/Admin/Public/GetImage.ashx?"; 1597 1598 string imageStyle = ""; 1599 1600 switch (settings.Style) 1601 { 1602 case ImageStyle.Ball: 1603 imageStyle = "grid__cell-img--ball"; 1604 break; 1605 1606 case ImageStyle.Triangle: 1607 imageStyle = "grid__cell-img--triangle"; 1608 break; 1609 } 1610 1611 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle || settings.Style == ImageStyle.Triangle) 1612 { 1613 settings.ImageDefault.Crop = settings.ImageDefault.Crop == 5 ? settings.ImageDefault.Crop = 0 : settings.ImageDefault.Crop; 1614 1615 if (settings.ImageDefault != null) 1616 { 1617 settings.ImageDefault.Height = settings.ImageDefault.Width; 1618 } 1619 if (settings.ImageMedium != null) 1620 { 1621 settings.ImageMedium.Height = settings.ImageMedium.Width; 1622 } 1623 if (settings.ImageSmall != null) 1624 { 1625 settings.ImageSmall.Height = settings.ImageSmall.Width; 1626 } 1627 } 1628 1629 string defaultImage = imageEngine; 1630 string imageSmall = ""; 1631 string imageMedium = ""; 1632 1633 string SVGimg = settings.Path.ToString(); 1634 1635 if(SVGimg.EndsWith(".svg&")){ 1636 settings.Path=SVGimg.Substring(0,SVGimg.Length-1); 1637 } 1638 1639 if (settings.DisableImageEngine || settings.Path.ToString().EndsWith(".svg")) 1640 { 1641 defaultImage = settings.Path.ToString(); 1642 } 1643 else 1644 { 1645 if (settings.ImageDefault != null) 1646 { 1647 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 1648 1649 if (settings.Path.GetType() != typeof(string)) 1650 { 1651 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 1652 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 1653 } 1654 else 1655 { 1656 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 1657 } 1658 1659 defaultImage += "&AlternativeImage=" + alternativeImage; 1660 } 1661 1662 if (settings.ImageSmall != null) 1663 { 1664 imageSmall = "data-src-small=\"" + imageEngine; 1665 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 1666 1667 if (settings.Path.GetType() != typeof(string)) 1668 { 1669 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 1670 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 1671 } 1672 else 1673 { 1674 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 1675 } 1676 1677 imageSmall += "&alternativeImage=" + alternativeImage; 1678 1679 imageSmall += "\""; 1680 } 1681 1682 if (settings.ImageMedium != null) 1683 { 1684 imageMedium = "data-src-medium=\"" + imageEngine; 1685 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 1686 1687 if (settings.Path.GetType() != typeof(string)) 1688 { 1689 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 1690 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 1691 } 1692 else 1693 { 1694 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 1695 } 1696 1697 imageMedium += "&alternativeImage=" + alternativeImage; 1698 1699 imageMedium += "\""; 1700 } 1701 } 1702 1703 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1704 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 1705 if (!string.IsNullOrEmpty(settings.Title)) 1706 { 1707 optionalAttributes.Add("alt", settings.Title); 1708 optionalAttributes.Add("title", settings.Title); 1709 } 1710 1711 if (settings.DisableLazyLoad) 1712 { 1713 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 1714 } 1715 else 1716 { 1717 <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) /> 1718 } 1719 } 1720 } 1721 @using System.Reflection 1722 @using Dynamicweb.Rapido.Blocks.Components.General 1723 @using Dynamicweb.Rapido.Blocks.Components 1724 1725 @* Component *@ 1726 1727 @helper RenderFileField(FileField settings) 1728 { 1729 var attributes = new Dictionary<string, string>(); 1730 if (string.IsNullOrEmpty(settings.Id)) 1731 { 1732 settings.Id = Guid.NewGuid().ToString("N"); 1733 } 1734 1735 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1736 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1737 if (settings.Required) { attributes.Add("required", "true"); } 1738 if (settings.Multiple) { attributes.Add("multiple", "true"); } 1739 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1740 if (string.IsNullOrEmpty(settings.ChooseFileText)) 1741 { 1742 settings.ChooseFileText = Translate("Choose file"); 1743 } 1744 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 1745 { 1746 settings.NoFilesChosenText = Translate("No files chosen..."); 1747 } 1748 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1749 1750 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1751 1752 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 1753 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 1754 1755 attributes.Add("type", "file"); 1756 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1757 settings.CssClass = "u-full-width " + settings.CssClass; 1758 1759 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1760 1761 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1762 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1763 { 1764 <div class="u-full-width"> 1765 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1766 @if (settings.Link != null) { 1767 <div class="u-pull--right"> 1768 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1769 @Render(settings.Link) 1770 </div> 1771 } 1772 </div> 1773 1774 } 1775 1776 @if (!string.IsNullOrEmpty(settings.HelpText)) 1777 { 1778 <small class="form__help-text">@settings.HelpText</small> 1779 } 1780 1781 <div class="form__field-combi file-input u-no-margin dw-mod"> 1782 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 1783 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 1784 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 1785 @if (settings.UploadButton != null) 1786 { 1787 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 1788 @Render(settings.UploadButton) 1789 } 1790 </div> 1791 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1792 </div> 1793 } 1794 @using System.Reflection 1795 @using Dynamicweb.Rapido.Blocks.Components.General 1796 @using Dynamicweb.Rapido.Blocks.Components 1797 @using Dynamicweb.Core 1798 @using System.Linq 1799 1800 @* Component *@ 1801 1802 @helper RenderDateTimeField(DateTimeField settings) 1803 { 1804 if (string.IsNullOrEmpty(settings.Id)) 1805 { 1806 settings.Id = Guid.NewGuid().ToString("N"); 1807 } 1808 1809 var textField = new TextField { 1810 Name = settings.Name, 1811 Id = settings.Id, 1812 Label = settings.Label, 1813 HelpText = settings.HelpText, 1814 Value = settings.Value, 1815 Disabled = settings.Disabled, 1816 Required = settings.Required, 1817 ErrorMessage = settings.ErrorMessage, 1818 CssClass = settings.CssClass, 1819 WrapperCssClass = settings.WrapperCssClass, 1820 OnChange = settings.OnChange, 1821 OnClick = settings.OnClick, 1822 Link = settings.Link, 1823 ExtraAttributes = settings.ExtraAttributes, 1824 // 1825 Placeholder = settings.Placeholder 1826 }; 1827 1828 @Render(textField) 1829 1830 List<string> jsAttributes = new List<string>(); 1831 1832 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 1833 1834 if (!string.IsNullOrEmpty(settings.DateFormat)) 1835 { 1836 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 1837 } 1838 if (!string.IsNullOrEmpty(settings.MinDate)) 1839 { 1840 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 1841 } 1842 if (!string.IsNullOrEmpty(settings.MaxDate)) 1843 { 1844 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 1845 } 1846 if (settings.IsInline) 1847 { 1848 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 1849 } 1850 if (settings.EnableTime) 1851 { 1852 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 1853 } 1854 if (settings.EnableWeekNumbers) 1855 { 1856 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 1857 } 1858 1859 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 1860 1861 <script> 1862 document.addEventListener("DOMContentLoaded", function () { 1863 flatpickr("#@textField.Id", { 1864 @string.Join(",", jsAttributes) 1865 }); 1866 }); 1867 </script> 1868 } 1869 @using System.Reflection 1870 @using Dynamicweb.Rapido.Blocks.Components.General 1871 @using Dynamicweb.Rapido.Blocks.Components 1872 1873 @* Component *@ 1874 1875 @helper RenderTextField(TextField settings) 1876 { 1877 var attributes = new Dictionary<string, string>(); 1878 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1879 { 1880 settings.Id = Guid.NewGuid().ToString("N"); 1881 } 1882 1883 /*base settings*/ 1884 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1885 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1886 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1887 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1888 if (settings.Required) { attributes.Add("required", "true"); } 1889 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1890 /*end*/ 1891 1892 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1893 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1894 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1895 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1896 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1897 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1898 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1899 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1900 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1901 1902 settings.CssClass = "u-full-width " + settings.CssClass; 1903 1904 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1905 1906 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1907 1908 string noMargin = "u-no-margin"; 1909 if (!settings.ReadOnly) { 1910 noMargin = ""; 1911 } 1912 1913 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1914 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1915 { 1916 <div class="u-full-width"> 1917 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1918 @if (settings.Link != null) { 1919 settings.Link.ButtonLayout = ButtonLayout.LinkClean; 1920 1921 <div class="u-pull--right"> 1922 @Render(settings.Link) 1923 </div> 1924 } 1925 </div> 1926 1927 } 1928 1929 @if (!string.IsNullOrEmpty(settings.HelpText)) 1930 { 1931 <small class="form__help-text">@settings.HelpText</small> 1932 } 1933 1934 @if (settings.ActionButton != null) 1935 { 1936 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1937 <div class="form__field-combi u-no-margin dw-mod"> 1938 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1939 @Render(settings.ActionButton) 1940 </div> 1941 } 1942 else 1943 { 1944 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1945 } 1946 1947 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1948 </div> 1949 } 1950 @using System.Reflection 1951 @using Dynamicweb.Rapido.Blocks.Components.General 1952 @using Dynamicweb.Rapido.Blocks.Components 1953 1954 @* Component *@ 1955 1956 @helper RenderNumberField(NumberField settings) 1957 { 1958 var attributes = new Dictionary<string, string>(); 1959 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1960 { 1961 settings.Id = Guid.NewGuid().ToString("N"); 1962 } 1963 1964 /*base settings*/ 1965 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1966 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1967 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1968 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1969 if (settings.Required) { attributes.Add("required", "true"); } 1970 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1971 /*end*/ 1972 1973 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1974 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1975 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1976 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1977 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1978 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1979 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1980 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1981 attributes.Add("type", "number"); 1982 1983 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1984 1985 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1986 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1987 { 1988 <div class="u-full-width"> 1989 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1990 @if (settings.Link != null) { 1991 <div class="u-pull--right"> 1992 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1993 @Render(settings.Link) 1994 </div> 1995 } 1996 </div> 1997 1998 } 1999 2000 @if (!string.IsNullOrEmpty(settings.HelpText)) 2001 { 2002 <small class="form__help-text">@settings.HelpText</small> 2003 } 2004 2005 @if (settings.ActionButton != null) 2006 { 2007 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 2008 <div class="form__field-combi u-no-margin dw-mod"> 2009 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 2010 @Render(settings.ActionButton) 2011 </div> 2012 } 2013 else 2014 { 2015 <div class="form__field-combi u-no-margin dw-mod"> 2016 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 2017 </div> 2018 } 2019 2020 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2021 </div> 2022 } 2023 @using System.Reflection 2024 @using Dynamicweb.Rapido.Blocks.Components.General 2025 @using Dynamicweb.Rapido.Blocks.Components 2026 2027 2028 @* Component *@ 2029 2030 @helper RenderTextareaField(TextareaField settings) 2031 { 2032 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2033 string id = settings.Id; 2034 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 2035 { 2036 id = Guid.NewGuid().ToString("N"); 2037 } 2038 2039 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 2040 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 2041 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 2042 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 2043 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 2044 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 2045 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 2046 if (settings.Disabled) { attributes.Add("disabled", "true"); } 2047 if (settings.Required) { attributes.Add("required", "true"); } 2048 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 2049 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 2050 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 2051 attributes.Add("name", settings.Name); 2052 2053 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 2054 2055 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 2056 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 2057 { 2058 <div class="u-full-width"> 2059 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 2060 @if (settings.Link != null) { 2061 <div class="u-pull--right"> 2062 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 2063 @Render(settings.Link) 2064 </div> 2065 } 2066 </div> 2067 } 2068 2069 @if (!string.IsNullOrEmpty(settings.HelpText)) 2070 { 2071 <small class="form__help-text">@settings.HelpText</small> 2072 } 2073 2074 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 2075 2076 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2077 </div> 2078 } 2079 @using System.Reflection 2080 @using Dynamicweb.Rapido.Blocks.Components.General 2081 @using Dynamicweb.Rapido.Blocks.Components 2082 2083 2084 @* Component *@ 2085 2086 @helper RenderHiddenField(HiddenField settings) { 2087 var attributes = new Dictionary<string, string>(); 2088 attributes.Add("type", "hidden"); 2089 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2090 if (settings.Value != null) { attributes.Add("value", settings.Value); } 2091 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 2092 2093 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 2094 } 2095 @using System.Reflection 2096 @using Dynamicweb.Rapido.Blocks.Components.General 2097 @using Dynamicweb.Rapido.Blocks.Components 2098 2099 @* Component *@ 2100 2101 @helper RenderCheckboxField(CheckboxField settings) 2102 { 2103 var attributes = new Dictionary<string, string>(); 2104 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 2105 { 2106 settings.Id = Guid.NewGuid().ToString("N"); 2107 } 2108 2109 /*base settings*/ 2110 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2111 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 2112 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 2113 if (settings.Disabled) { attributes.Add("disabled", "true"); } 2114 if (settings.Required) { attributes.Add("required", "true"); } 2115 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 2116 /*end*/ 2117 2118 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 2119 2120 attributes.Add("type", "checkbox"); 2121 if (settings.Checked) { attributes.Add("checked", "true"); } 2122 settings.CssClass = "form__control " + settings.CssClass; 2123 if (settings.Value != null) { attributes.Add("value", settings.Value); } 2124 2125 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 2126 2127 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 2128 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 2129 @if (!string.IsNullOrEmpty(settings.Label)) 2130 { 2131 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 2132 } 2133 2134 @if (settings.Link != null) { 2135 <span> 2136 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 2137 @Render(settings.Link) 2138 </span> 2139 } 2140 2141 @if (!string.IsNullOrEmpty(settings.HelpText)) 2142 { 2143 <small class="form__help-text checkbox-help dw-mod">@settings.HelpText</small> 2144 } 2145 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2146 </div> 2147 } 2148 @using System.Reflection 2149 @using Dynamicweb.Rapido.Blocks.Components.General 2150 @using Dynamicweb.Rapido.Blocks.Components 2151 2152 2153 @* Component *@ 2154 2155 @helper RenderCheckboxListField(CheckboxListField settings) 2156 { 2157 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2158 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 2159 { 2160 <div class="u-full-width"> 2161 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 2162 @if (settings.Link != null) { 2163 <div class="u-pull--right"> 2164 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 2165 @Render(settings.Link) 2166 </div> 2167 } 2168 </div> 2169 2170 } 2171 2172 <div class="u-pull--left"> 2173 @if (!string.IsNullOrEmpty(settings.HelpText)) 2174 { 2175 <small class="form__help-text">@settings.HelpText</small> 2176 } 2177 2178 @foreach (var item in settings.Options) 2179 { 2180 if (settings.Required) 2181 { 2182 item.Required = true; 2183 } 2184 if (settings.Disabled) 2185 { 2186 item.Disabled = true; 2187 } 2188 if (!string.IsNullOrEmpty(settings.Name)) 2189 { 2190 item.Name = settings.Name; 2191 } 2192 if (!string.IsNullOrEmpty(settings.CssClass)) 2193 { 2194 item.CssClass += settings.CssClass; 2195 } 2196 2197 /* value is not supported */ 2198 2199 if (!string.IsNullOrEmpty(settings.OnClick)) 2200 { 2201 item.OnClick += settings.OnClick; 2202 } 2203 if (!string.IsNullOrEmpty(settings.OnChange)) 2204 { 2205 item.OnChange += settings.OnChange; 2206 } 2207 @Render(item) 2208 } 2209 2210 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2211 </div> 2212 2213 </div> 2214 } 2215 @using Dynamicweb.Rapido.Blocks.Components.General 2216 2217 @* Component *@ 2218 2219 @helper RenderSearch(Search settings) 2220 { 2221 var searchValue = HttpContext.Current.Request.QueryString.Get(settings.SearchParameter) ?? ""; 2222 var groupValue = HttpContext.Current.Request.QueryString.Get(settings.GroupsParameter) ?? ""; 2223 2224 if (string.IsNullOrEmpty(settings.Id)) 2225 { 2226 settings.Id = Guid.NewGuid().ToString("N"); 2227 } 2228 2229 var resultAttributes = new Dictionary<string, string>(); 2230 2231 if (settings.PageSize != 0) 2232 { 2233 resultAttributes.Add("data-page-size", settings.PageSize.ToString()); 2234 } 2235 if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 2236 { 2237 resultAttributes.Add("data-groups-feed-url", settings.GroupItemsFeedUrl); 2238 if (!string.IsNullOrEmpty(groupValue)) 2239 { 2240 resultAttributes.Add("data-selected-group", groupValue); 2241 } 2242 if (!string.IsNullOrEmpty(settings.GroupsParameter)) 2243 { 2244 resultAttributes.Add("data-groups-parameter", settings.GroupsParameter); 2245 } 2246 } 2247 resultAttributes.Add("data-force-init", "true"); 2248 if (settings.GoToFirstSearchResultOnEnter) 2249 { 2250 resultAttributes.Add("data-go-to-first-search-result-on-enter", settings.GoToFirstSearchResultOnEnter.ToString().ToLower()); 2251 } 2252 if (!string.IsNullOrEmpty(settings.SearchParameter)) 2253 { 2254 resultAttributes.Add("data-search-parameter", settings.SearchParameter); 2255 } 2256 resultAttributes.Add("data-search-feed-url", settings.SearchData.SearchFeedUrl); 2257 resultAttributes.Add("data-results-template-id", settings.SearchData.ResultsTemplateId); 2258 2259 if (settings.SecondSearchData != null) 2260 { 2261 resultAttributes.Add("data-second-search-feed-url", settings.SecondSearchData.SearchFeedUrl); 2262 resultAttributes.Add("data-second-results-template-id", settings.SecondSearchData.ResultsTemplateId); 2263 } 2264 if (!string.IsNullOrEmpty(settings.ResultsPageUrl)) 2265 { 2266 resultAttributes.Add("data-results-page-url", settings.ResultsPageUrl); 2267 } 2268 2269 resultAttributes = resultAttributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 2270 2271 string searchFieldCss = (settings.SearchButton == null) ? "search--with-icon" : ""; 2272 2273 <div class="search @settings.CssClass @searchFieldCss js-search-data-source dw-mod" id="@settings.Id" @ComponentMethods.AddAttributes(resultAttributes)> 2274 @if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 2275 { 2276 <button type="button" class="search__groups-btn dw-mod js-search-groups-btn">@Translate("All")</button> 2277 <ul class="dropdown dropdown--absolute-position dw-mod search__groups-results js-search-groups-list"></ul> 2278 } 2279 2280 <input type="text" class="search__field dw-mod js-search-field" placeholder="@settings.Placeholder" value="@searchValue"> 2281 2282 <div class="dropdown dropdown--absolute-position search__results dw-mod js-search-results @(settings.SecondSearchData != null ? "search__results--combined" : "")"> 2283 @if (settings.SecondSearchData != null) 2284 { 2285 <div class="search__column search__column--products dw-mod"> 2286 <div class="search__column-header dw-mod">@Translate("Products")</div> 2287 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 2288 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 2289 { 2290 @Render(new Link { 2291 Title = Translate("View all"), 2292 CssClass = "js-view-all-button u-margin", 2293 Href = settings.SearchData.ResultsPageUrl 2294 }); 2295 } 2296 </div> 2297 <div class="search__column search__column--pages dw-mod"> 2298 <div class="search__column-header">@Translate("Pages")</div> 2299 <ul class="search__results-list dw-mod js-search-results-second-list" id="@(settings.Id)_SecondResultsList"></ul> 2300 @if (!string.IsNullOrEmpty(settings.SecondSearchData.ResultsPageUrl)) 2301 { 2302 @Render(new Link 2303 { 2304 Title = Translate("View all"), 2305 CssClass = "js-view-all-button u-margin", 2306 Href = settings.SecondSearchData.ResultsPageUrl 2307 }); 2308 } 2309 </div> 2310 } 2311 else 2312 { 2313 <div class="search__column search__column--only dw-mod"> 2314 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 2315 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 2316 { 2317 @Render(new Link { 2318 Title = Translate("View all"), 2319 CssClass = "js-view-all-button u-margin", 2320 Href = settings.SearchData.ResultsPageUrl 2321 }); 2322 } 2323 </div> 2324 } 2325 </div> 2326 2327 @if (settings.SearchButton != null) 2328 { 2329 settings.SearchButton.CssClass += " search__btn js-search-btn"; 2330 if (settings.RenderDefaultSearchIcon) 2331 { 2332 settings.SearchButton.Icon = new Icon { Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue }; 2333 } 2334 @Render(settings.SearchButton); 2335 } 2336 </div> 2337 } 2338 @using System.Reflection 2339 @using Dynamicweb.Rapido.Blocks.Components.General 2340 @using Dynamicweb.Rapido.Blocks.Components 2341 2342 2343 @* Component *@ 2344 2345 @helper RenderSelectField(SelectField settings) 2346 { 2347 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 2348 { 2349 settings.Id = Guid.NewGuid().ToString("N"); 2350 } 2351 2352 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 2353 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 2354 { 2355 <div class="u-full-width"> 2356 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 2357 @if (settings.Link != null) { 2358 <div class="u-pull--right"> 2359 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 2360 @Render(settings.Link) 2361 </div> 2362 } 2363 </div> 2364 } 2365 2366 @if (!string.IsNullOrEmpty(settings.HelpText)) 2367 { 2368 <small class="form__help-text">@settings.HelpText</small> 2369 } 2370 2371 @if (settings.ActionButton != null) 2372 { 2373 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 2374 <div class="form__field-combi u-no-margin dw-mod"> 2375 @RenderSelectBase(settings) 2376 @Render(settings.ActionButton) 2377 </div> 2378 } 2379 else 2380 { 2381 @RenderSelectBase(settings) 2382 } 2383 2384 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2385 </div> 2386 } 2387 2388 @helper RenderSelectBase(SelectField settings) 2389 { 2390 var attributes = new Dictionary<string, string>(); 2391 2392 /*base settings*/ 2393 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2394 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 2395 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 2396 if (settings.Disabled) { attributes.Add("disabled", "true"); } 2397 if (settings.Required) { attributes.Add("required", "true"); } 2398 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 2399 /*end*/ 2400 2401 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 2402 2403 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 2404 @if (settings.Default != null) 2405 { 2406 @Render(settings.Default) 2407 } 2408 2409 @foreach (var item in settings.Options) 2410 { 2411 if (settings.Value != null) { 2412 item.Checked = item.Value == settings.Value; 2413 } 2414 @Render(item) 2415 } 2416 </select> 2417 } 2418 @using System.Reflection 2419 @using Dynamicweb.Rapido.Blocks.Components.General 2420 @using Dynamicweb.Rapido.Blocks.Components 2421 2422 @* Component *@ 2423 2424 @helper RenderRadioButtonField(RadioButtonField settings) 2425 { 2426 var attributes = new Dictionary<string, string>(); 2427 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 2428 { 2429 settings.Id = Guid.NewGuid().ToString("N"); 2430 } 2431 2432 /*base settings*/ 2433 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2434 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 2435 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 2436 if (settings.Disabled) { attributes.Add("disabled", "true"); } 2437 if (settings.Required) { attributes.Add("required", "true"); } 2438 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 2439 /*end*/ 2440 2441 attributes.Add("type", "radio"); 2442 if (settings.Checked) { attributes.Add("checked", "true"); } 2443 settings.CssClass = "form__control " + settings.CssClass; 2444 if (settings.Value != null) { attributes.Add("value", settings.Value); } 2445 2446 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 2447 2448 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 2449 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 2450 @if (!string.IsNullOrEmpty(settings.Label)) 2451 { 2452 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 2453 } 2454 @if (!string.IsNullOrEmpty(settings.HelpText)) 2455 { 2456 <small class="form__help-text">@settings.HelpText</small> 2457 } 2458 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2459 </div> 2460 } 2461 @using System.Reflection 2462 @using Dynamicweb.Rapido.Blocks.Components.General 2463 @using Dynamicweb.Rapido.Blocks.Components 2464 2465 2466 @* Component *@ 2467 2468 @helper RenderRadioButtonListField(RadioButtonListField settings) 2469 { 2470 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 2471 2472 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2473 @if (!string.IsNullOrEmpty(settings.Label)) 2474 { 2475 <label>@settings.Label</label> 2476 } 2477 @if (!string.IsNullOrEmpty(settings.HelpText)) 2478 { 2479 <small class="form__help-text">@settings.HelpText</small> 2480 } 2481 2482 @foreach (var item in settings.Options) 2483 { 2484 if (settings.Required) 2485 { 2486 item.Required = true; 2487 } 2488 if (settings.Disabled) 2489 { 2490 item.Disabled = true; 2491 } 2492 if (!string.IsNullOrEmpty(settings.Name)) 2493 { 2494 item.Name = settings.Name; 2495 } 2496 if (settings.Value != null && settings.Value == item.Value) 2497 { 2498 item.Checked = true; 2499 } 2500 if (!string.IsNullOrEmpty(settings.OnClick)) 2501 { 2502 item.OnClick += settings.OnClick; 2503 } 2504 if (!string.IsNullOrEmpty(settings.OnChange)) 2505 { 2506 item.OnChange += settings.OnChange; 2507 } 2508 if (!string.IsNullOrEmpty(settings.CssClass)) 2509 { 2510 item.CssClass += settings.CssClass; 2511 } 2512 @Render(item) 2513 } 2514 2515 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2516 </div> 2517 } 2518 @using System.Reflection 2519 @using Dynamicweb.Rapido.Blocks.Components.General 2520 @using Dynamicweb.Rapido.Blocks.Components 2521 2522 2523 @* Component *@ 2524 2525 @helper RenderNotificationMessage(NotificationMessage settings) 2526 { 2527 if (!string.IsNullOrEmpty(settings.Message)) 2528 { 2529 var attributes = new Dictionary<string, string>(); 2530 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2531 2532 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 2533 string messageLayoutClass = Enum.GetName(typeof(NotificationMessageLayout), settings.MessageLayout).ToLower(); 2534 string minHeightClass = settings.Icon != null ? "u-min-h70px" : ""; 2535 2536 <div class="notification-message-@messageTypeClass notification-message-@messageLayoutClass @messageLayoutClass @minHeightClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)> 2537 @if (settings.Icon != null) { 2538 settings.Icon.Label = !string.IsNullOrEmpty(settings.Icon.Label) ? settings.Message + settings.Icon.Label : settings.Message; 2539 @Render(settings.Icon) 2540 } else { 2541 @settings.Message 2542 } 2543 </div> 2544 } 2545 } 2546 @using Dynamicweb.Rapido.Blocks.Components.General 2547 2548 2549 @* Component *@ 2550 2551 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 2552 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 2553 2554 <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> 2555 @if (settings.SubBlocks != null) { 2556 @RenderBlockList(settings.SubBlocks) 2557 } 2558 </div> 2559 } 2560 @using System.Reflection 2561 @using Dynamicweb.Rapido.Blocks.Components.General 2562 @using Dynamicweb.Rapido.Blocks.Components 2563 @using System.Text.RegularExpressions 2564 2565 2566 @* Component *@ 2567 2568 @helper RenderSticker(Sticker settings) { 2569 if (!String.IsNullOrEmpty(settings.Title)) { 2570 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 2571 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 2572 2573 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 2574 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 2575 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 2576 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 2577 optionalAttributes.Add("style", styleTag); 2578 } 2579 2580 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 2581 } 2582 } 2583 2584 @using System.Reflection 2585 @using Dynamicweb.Rapido.Blocks.Components.General 2586 @using Dynamicweb.Rapido.Blocks.Components 2587 2588 2589 @* Component *@ 2590 2591 @helper RenderStickersCollection(StickersCollection settings) 2592 { 2593 if (settings.Stickers.Count > 0) 2594 { 2595 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 2596 2597 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2598 @foreach (Sticker sticker in settings.Stickers) 2599 { 2600 @Render(sticker) 2601 } 2602 </div> 2603 } 2604 } 2605 2606 @using Dynamicweb.Rapido.Blocks.Components.General 2607 2608 2609 @* Component *@ 2610 2611 @helper RenderForm(Form settings) { 2612 if (settings != null) 2613 { 2614 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 2615 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 2616 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 2617 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 2618 var enctypes = new Dictionary<string, string> 2619 { 2620 { "multipart", "multipart/form-data" }, 2621 { "text", "text/plain" }, 2622 { "application", "application/x-www-form-urlencoded" } 2623 }; 2624 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 2625 optionalAttributes.Add("method", settings.Method.ToString()); 2626 2627 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 2628 { 2629 @settings.FormStartMarkup 2630 } 2631 else 2632 { 2633 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2634 } 2635 2636 foreach (var field in settings.GetFields()) 2637 { 2638 @Render(field) 2639 } 2640 2641 @:</form> 2642 } 2643 } 2644 @using System.Reflection 2645 @using Dynamicweb.Rapido.Blocks.Components.General 2646 @using Dynamicweb.Rapido.Blocks.Components 2647 2648 2649 @* Component *@ 2650 2651 @helper RenderText(Text settings) 2652 { 2653 @settings.Content 2654 } 2655 @using System.Reflection 2656 @using Dynamicweb.Rapido.Blocks.Components.General 2657 @using Dynamicweb.Rapido.Blocks.Components 2658 2659 2660 @* Component *@ 2661 2662 @helper RenderContentModule(ContentModule settings) { 2663 if (!string.IsNullOrEmpty(settings.Content)) 2664 { 2665 @settings.Content 2666 } 2667 } 2668 @using System.Reflection 2669 @using Dynamicweb.Rapido.Blocks.Components.General 2670 @using Dynamicweb.Rapido.Blocks.Components 2671 2672 2673 @* Component *@ 2674 2675 @helper RenderModal(Modal settings) { 2676 if (settings != null) 2677 { 2678 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 2679 2680 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 2681 2682 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 2683 2684 <div class="modal-container"> 2685 @if (!settings.DisableDarkOverlay) 2686 { 2687 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 2688 } 2689 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 2690 @if (settings.Heading != null) 2691 { 2692 if (!string.IsNullOrEmpty(settings.Heading.Title)) 2693 { 2694 <div class="modal__header"> 2695 @Render(settings.Heading) 2696 </div> 2697 } 2698 } 2699 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 2700 @if (!string.IsNullOrEmpty(settings.BodyText)) 2701 { 2702 @settings.BodyText 2703 } 2704 @if (settings.BodyTemplate != null) 2705 { 2706 @settings.BodyTemplate 2707 } 2708 @{ 2709 var actions = settings.GetActions(); 2710 } 2711 </div> 2712 @if (actions.Length > 0) 2713 { 2714 <div class="modal__footer"> 2715 @foreach (var action in actions) 2716 { 2717 if (Pageview.Device.ToString() != "Mobile") { 2718 action.CssClass += " u-no-margin"; 2719 } else { 2720 action.CssClass += " u-full-width u-margin-bottom"; 2721 } 2722 2723 @Render(action) 2724 } 2725 </div> 2726 } 2727 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 2728 </div> 2729 </div> 2730 } 2731 } 2732 @using Dynamicweb.Rapido.Blocks.Components.General 2733 2734 @* Component *@ 2735 2736 @helper RenderMediaListItem(MediaListItem settings) 2737 { 2738 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 2739 @if (!string.IsNullOrEmpty(settings.Label)) 2740 { 2741 if (!string.IsNullOrEmpty(settings.Link)) 2742 { 2743 @Render(new Link 2744 { 2745 Href = settings.Link, 2746 CssClass = "media-list-item__sticker dw-mod", 2747 ButtonLayout = ButtonLayout.None, 2748 Title = settings.Label, 2749 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 2750 }) 2751 } 2752 else if (!string.IsNullOrEmpty(settings.OnClick)) 2753 { 2754 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 2755 <span class="u-uppercase">@settings.Label</span> 2756 </span> 2757 } 2758 else 2759 { 2760 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 2761 <span class="u-uppercase">@settings.Label</span> 2762 </span> 2763 } 2764 } 2765 <div class="media-list-item__wrap"> 2766 <div class="media-list-item__info dw-mod"> 2767 <div class="media-list-item__header dw-mod"> 2768 @if (!string.IsNullOrEmpty(settings.Title)) 2769 { 2770 if (!string.IsNullOrEmpty(settings.Link)) 2771 { 2772 @Render(new Link 2773 { 2774 Href = settings.Link, 2775 CssClass = "media-list-item__name dw-mod", 2776 ButtonLayout = ButtonLayout.None, 2777 Title = settings.Title, 2778 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 2779 }) 2780 } 2781 else if (!string.IsNullOrEmpty(settings.OnClick)) 2782 { 2783 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 2784 } 2785 else 2786 { 2787 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 2788 } 2789 } 2790 2791 @if (!string.IsNullOrEmpty(settings.Status)) 2792 { 2793 <div class="media-list-item__state dw-mod">@settings.Status</div> 2794 } 2795 </div> 2796 @{ 2797 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 2798 } 2799 2800 @Render(settings.InfoTable) 2801 </div> 2802 <div class="media-list-item__actions dw-mod"> 2803 <div class="media-list-item__actions-list dw-mod"> 2804 @{ 2805 var actions = settings.GetActions(); 2806 2807 foreach (ButtonBase action in actions) 2808 { 2809 action.ButtonLayout = ButtonLayout.None; 2810 action.CssClass += " media-list-item__action link"; 2811 2812 @Render(action) 2813 } 2814 } 2815 </div> 2816 2817 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 2818 { 2819 settings.SelectButton.CssClass += " u-no-margin"; 2820 2821 <div class="media-list-item__action-button"> 2822 @Render(settings.SelectButton) 2823 </div> 2824 } 2825 </div> 2826 </div> 2827 </div> 2828 } 2829 @using Dynamicweb.Rapido.Blocks.Components.General 2830 @using Dynamicweb.Rapido.Blocks.Components 2831 2832 @helper RenderTable(Table settings) 2833 { 2834 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2835 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2836 2837 var enumToClasses = new Dictionary<TableDesign, string> 2838 { 2839 { TableDesign.Clean, "table--clean" }, 2840 { TableDesign.Bordered, "table--bordered" }, 2841 { TableDesign.Striped, "table--striped" }, 2842 { TableDesign.Hover, "table--hover" }, 2843 { TableDesign.Compact, "table--compact" }, 2844 { TableDesign.Condensed, "table--condensed" }, 2845 { TableDesign.NoTopBorder, "table--no-top-border" } 2846 }; 2847 string tableDesignClass = ""; 2848 if (settings.Design != TableDesign.None) 2849 { 2850 tableDesignClass = enumToClasses[settings.Design]; 2851 } 2852 2853 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 2854 2855 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2856 2857 <table @ComponentMethods.AddAttributes(resultAttributes)> 2858 @if (settings.Header != null) 2859 { 2860 <thead> 2861 @Render(settings.Header) 2862 </thead> 2863 } 2864 <tbody> 2865 @foreach (var row in settings.Rows) 2866 { 2867 @Render(row) 2868 } 2869 </tbody> 2870 @if (settings.Footer != null) 2871 { 2872 <tfoot> 2873 @Render(settings.Footer) 2874 </tfoot> 2875 } 2876 </table> 2877 } 2878 @using Dynamicweb.Rapido.Blocks.Components.General 2879 @using Dynamicweb.Rapido.Blocks.Components 2880 2881 @helper RenderTableRow(TableRow settings) 2882 { 2883 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2884 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2885 2886 var enumToClasses = new Dictionary<TableRowDesign, string> 2887 { 2888 { TableRowDesign.NoBorder, "table__row--no-border" }, 2889 { TableRowDesign.Border, "table__row--border" }, 2890 { TableRowDesign.TopBorder, "table__row--top-line" }, 2891 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 2892 { TableRowDesign.Solid, "table__row--solid" } 2893 }; 2894 2895 string tableRowDesignClass = ""; 2896 if (settings.Design != TableRowDesign.None) 2897 { 2898 tableRowDesignClass = enumToClasses[settings.Design]; 2899 } 2900 2901 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 2902 2903 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2904 2905 <tr @ComponentMethods.AddAttributes(resultAttributes)> 2906 @foreach (var cell in settings.Cells) 2907 { 2908 if (settings.IsHeaderRow) 2909 { 2910 cell.IsHeader = true; 2911 } 2912 @Render(cell) 2913 } 2914 </tr> 2915 } 2916 @using Dynamicweb.Rapido.Blocks.Components.General 2917 @using Dynamicweb.Rapido.Blocks.Components 2918 @using Dynamicweb.Core 2919 2920 @helper RenderTableCell(TableCell settings) 2921 { 2922 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2923 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2924 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 2925 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 2926 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 2927 2928 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2929 2930 string tagName = settings.IsHeader ? "th" : "td"; 2931 2932 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 2933 @settings.Content 2934 @("</" + tagName + ">"); 2935 } 2936 @using System.Linq 2937 @using Dynamicweb.Rapido.Blocks.Components.General 2938 2939 @* Component *@ 2940 2941 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 2942 { 2943 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 2944 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 2945 2946 if (settings.NumberOfPages > 1) 2947 { 2948 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 2949 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 2950 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 2951 2952 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 2953 @if (settings.ShowPagingInfo) 2954 { 2955 <div class="pager__info dw-mod"> 2956 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 2957 </div> 2958 } 2959 <ul class="pager__list dw-mod"> 2960 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 2961 { 2962 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 2963 } 2964 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 2965 { 2966 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 2967 } 2968 @if (settings.GetPages().Any()) 2969 { 2970 foreach (var page in settings.GetPages()) 2971 { 2972 @Render(page) 2973 } 2974 } 2975 else 2976 { 2977 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 2978 { 2979 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 2980 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 2981 } 2982 } 2983 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 2984 { 2985 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 2986 } 2987 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 2988 { 2989 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 2990 } 2991 </ul> 2992 </div> 2993 } 2994 } 2995 2996 @helper RenderPaginationItem(PaginationItem settings) 2997 { 2998 if (settings.Icon == null) 2999 { 3000 settings.Icon = new Icon(); 3001 } 3002 3003 settings.Icon.Label = settings.Label; 3004 <li class="pager__btn dw-mod"> 3005 @if (settings.IsActive) 3006 { 3007 <span class="pager__num pager__num--current dw-mod"> 3008 @Render(settings.Icon) 3009 </span> 3010 } 3011 else 3012 { 3013 <a href="@settings.Link" class="pager__num dw-mod"> 3014 @Render(settings.Icon) 3015 </a> 3016 } 3017 </li> 3018 } 3019 3020 3021 @using Dynamicweb.Rapido.Blocks.Components.General 3022 3023 3024 3025 3026 @RenderBlockList(filesPage.BlocksRoot.BlocksList) 3027 3028 @helper RenderPageContainer() 3029 { 3030 int feedPageId = GetPageIdByNavigationTag("FilesFeed"); 3031 string pageUrl = GetGlobalValue("Global:Pageview.Url.Raw"); 3032 string feedPageUrl = new Regex("([?&]ID)=[^?&]+").Replace(pageUrl, "?ID=" + feedPageId); 3033 3034 <div class="grid grid--align-content-start u-padding js-handlebars-root" id="FilesListContainer" data-template="FilesContainerScript" data-pre-render-template="FilesPreRenderContainer" data-json-feed="@feedPageUrl" data-save-cookie="true" data-preloader="overlay"></div> 3035 } 3036 3037 @helper RenderFilesContainerScript() 3038 { 3039 List<Block> subBlocks = this.filesPage.GetBlockListById("FilesContainerScript").OrderBy(item => item.SortId).ToList(); 3040 3041 <script id="FilesContainerScript" type="text/x-template"> 3042 {{#each .}} 3043 @RenderBlockList(subBlocks) 3044 {{else}} 3045 <div class="grid__col-12"> 3046 @Render(new Heading { Level = 2, Title = Translate("Your search gave 0 results"), CssClass = "u-ta-center" }) 3047 </div> 3048 {{/each}} 3049 </script> 3050 } 3051 3052 @helper RenderFiles() 3053 { 3054 <div id="Files" data-template="{{listTemplate}}" class="grid product-list grid--external-bleed-x dw-mod" data-save-cookie="true"> 3055 {{#Files}} 3056 {{> (lookup . 'template') }} 3057 {{/Files}} 3058 </div> 3059 } 3060 3061 @helper RenderLoadMore() 3062 { 3063 int feedPageId = GetPageIdByNavigationTag("FilesFeed"); 3064 3065 Button loadMore = new Button 3066 { 3067 Title = Translate("Load") + " {{pageSize}} " + Translate("more"), 3068 OnClick = "LoadMore.Next(this)", 3069 ButtonLayout = ButtonLayout.Primary, 3070 CssClass = "btn--full {{nextdisabled}}", 3071 Disabled = !String.IsNullOrEmpty("{{nextdisabled}}") ? false : true 3072 }; 3073 loadMore.ExtraAttributes.Add("data-current", "{{currentPage}}"); 3074 loadMore.ExtraAttributes.Add("data-page-size", "{{pageSize}}"); 3075 loadMore.ExtraAttributes.Add("data-total", "{{totalPages}}"); 3076 loadMore.ExtraAttributes.Add("data-container", "Files"); 3077 loadMore.ExtraAttributes.Add("data-feed-url", "/Default.aspx?ID=" + feedPageId); 3078 3079 @Render(loadMore) 3080 @Render(new Button { Title = Translate("Return to top"), ButtonLayout = ButtonLayout.Clean, OnClick = "window.scroll(0, 0)" }) 3081 } 3082 3083 @helper RenderPreRenderTemplate() 3084 { 3085 <script id="FilesPreRenderContainer" type="text/x-template"> 3086 <div class="grid__col-3"> 3087 <div class="pre-render-element pre-render-element--xs"></div> 3088 <div class="pre-render-element pre-render-element--md"></div> 3089 <div class="pre-render-element pre-render-element--md"></div> 3090 <div class="pre-render-element pre-render-element--md"></div> 3091 </div> 3092 <div class="grid__col-auto"> 3093 <div class="pre-render-element pre-render-element--xs"></div> 3094 <div class="pre-render-element pre-render-element--xs"></div> 3095 <div class="pre-render-element pre-render-element--lg"></div> 3096 <div class="pre-render-element pre-render-element--lg"></div> 3097 <div class="pre-render-element pre-render-element--lg"></div> 3098 <div class="pre-render-element pre-render-element--lg"></div> 3099 </div> 3100 </script> 3101 } 3102 3103 @helper RenderJavascript() 3104 { 3105 int filesFeedPageId = GetPageIdByNavigationTag("FilesFeed"); 3106 3107 <script> 3108 document.addEventListener("DOMContentLoaded", function (event) { 3109 3110 document.getElementById("FilesListContainer").addEventListener('contentLoaded', function (e) { 3111 if (getTarget(e).id === "FilesListContainer") { 3112 Search.Init(); 3113 Facets.Init("selectedFacets", "FilesListContainer"); 3114 } 3115 }, false); 3116 }); 3117 3118 function addFileToDownloads(path) { 3119 document.getElementById('assetPath').value = path; 3120 document.getElementById('DownloadModalTrigger').checked = true; 3121 } 3122 </script> 3123 }