require 'source/why/example_page' module Views module Why class BuildingARichModalDialog < Views::Why::ExamplePage def example_intro p { text "In our last example, we saw how using inheritance lets you easily solve view-factoring problems " text "with Fortitude that remain painful in traditional templating engines. In this example, we’ll see " text "how Fortitude’s widget classes let us create specialized contexts for rendering views that are " text "very powerful. In effect, they become little mini-languages, introducing view primitives exactly " text "when you need them and providing an elegant language for you to describe what your view should " text "look like." } end def example_description p { text "Almost everybody knows the concept of a "; em "modal dialog"; text " — a “layer” of HTML that " text "requests some kind of input or confirmation from the user before proceeding, and which obscures " text "the rest of the web page so that the user is forced to provide this input or confirmation before " text "proceeding. They’re often also known as a "; em "lightbox"; text ", "; em "modal window"; text ", or " em "heavy window"; text ", and have become a staple of modern Web design." } p { text "Here’s an example of a modal dialog that appears in Google Docs when you choose “Make a Copy”: " } featured_image 'why/modal_dialog.png' p { text "This simple example has a number of features that modal dialogs tend to share:" } ul { li "A clear border, often with a drop shadow, around the entire dialog." li "A large layer that dims or otherwise obscures the rest of the page behind the dialog." li "Some kind of “close” or “dismiss” control, often in the upper-right-hand corner." li "A title of some kind at the top — sometimes styled, sometimes not." li "Primary content, which can be more-or-less arbitraily complex." li "At the bottom, at least one button (“OK”), and often more than one." } p { text "These simple dialogs present an interesting challenge for view builders. Even the frame of the dialog " text "will consist of multiple elements (usually "; code "div"; text "s), with some important CSS classes " text "applied. There will be a standard way of creating tht title, and likely a container that the primary " text "content needs to go into. The buttons at the bottom will typically have their own container and styles, " text "and standard ways of rendering them." } p { text "Let’s look at an example modal dialog in completely non-refactored (one-off) HTML:" } erb 'app/views/docs/copy_document.html.erb', <<-EOS