/src/Mvc/Dinamico/Dinamico/Themes/Default/Views/ContentParts/ImageAndText.cshtml

https://github.com/lundbeck/n2cms · Razor · 70 lines · 36 code · 7 blank · 27 comment · 5 complexity · fba56dc831ed3abe3730d5b904ac41fd MD5 · raw file

  1. @*************************************************************************************************
  2. Image and Text Content Part: Razor Template-First Sample
  3. Licensed to users of N2CMS under the terms of the Boost Software License
  4. Copyright (c) 2013 Benjamin Herila <mailto:ben@herila.net>
  5. Boost Software License - Version 1.0 - August 17th, 2003
  6. Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the
  7. software and accompanying documentation covered by this license (the "Software") to use, reproduce,
  8. display, distribute, execute, and transmit the Software, and to prepare derivative works of the
  9. Software, and to permit third-parties to whom the Software is furnished to do so, all subject to
  10. the following:
  11. The copyright notices in the Software and this entire statement, including the above license grant,
  12. this restriction and the following disclaimer, must be included in all copies of the Software, in
  13. whole or in part, and all derivative works of the Software, unless such copies or derivative works
  14. are solely in the form of machine-executable object code generated by a source language processor.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
  16. NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-
  17. INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
  18. FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
  19. IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. *************************************************************************************************@
  21. @model Dinamico.Models.ContentPart
  22. @{
  23. Content.Define(ie => {
  24. ie.Title = "Image and Text";
  25. ie.IconUrl = "{IconsUrl}/text_padding_left.png";
  26. ie.Text("Title", "Heading text").SortOrder(100);
  27. ie.ImageUpload("Image").SortOrder(200);
  28. ie.FreeText("Description").SortOrder(300);
  29. ie.CheckBox("ImageFirst", "Image first").DefaultValue(true).SortOrder(400);
  30. ie.CheckBox("HiddenPhone", "Hide image in mobile view (requires responsive CSS)").DefaultValue(false).SortOrder(500);
  31. });
  32. var imgCssClass = "img-polaroid";
  33. if (Content.Has.HiddenPhone && Content.Data.HiddenPhone == true) { imgCssClass += " hidden-phone"; }
  34. }
  35. @if (Content.Has.Title && !String.IsNullOrWhiteSpace(Content.Data.Title))
  36. {
  37. <h3>@Content.Data.Title</h3>
  38. }
  39. @if (Content.Has.ImageFirst && Content.Data.ImageFirst)
  40. {
  41. <div class="imageAndText container-fluid">
  42. <div class="row-fluid">
  43. <div class="span3"><img class="@imgCssClass" alt="@Content.Data.Title" src="@Content.Data.Image" /></div>
  44. <div class="span9">@Content.Display.Description</div>
  45. </div>
  46. </div>
  47. }
  48. else
  49. {
  50. <div class="imageAndText container-fluid">
  51. <div class="row-fluid">
  52. <div class="span9">@Content.Display.Description</div>
  53. <div class="span3"><img class="@imgCssClass" alt="@Content.Data.Title" src="@Content.Data.Image" /></div>
  54. </div>
  55. </div>
  56. }