Class: Projects::Page
- Inherits:
-
ContainerElement
- Object
- ContainerElement
- Projects::Page
- Defined in:
- lib/reparcs/projects.rb
Overview
A Page(or document). If you project requires you to make a single html page, this is where you should start.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body ⇒ Object
—–>.
-
#charset ⇒ Object
—–>.
-
#head ⇒ Object
—–>.
-
#lang ⇒ Object
—–>.
-
#xml_lang ⇒ Object
—–>.
-
#xmlns ⇒ Object
—–>.
Instance Method Summary collapse
-
#add_effect(element, event_type, effect_type) ⇒ Object
Adds a visual effect to a element Note* you must have included the scriptalicous library in your page beforehand and the element must have its id attribute set! Takes the element object, the event type, and the effect type as parameters.
-
#include_scriptaculous ⇒ Object
Includes the scriptaculous scripts in you page Note* it simply includes several script elements with relative paths to the scriptaculous script files, this method is really only useful if you have added this page to a Website object and have invoked the Website.include_scriptaculous_files method which will include the files when published.
-
#initialize ⇒ Page
constructor
Create a new Page.
Constructor Details
#initialize ⇒ Page
Create a new Page
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/reparcs/projects.rb', line 15 def initialize super("html") @xml_lang = "en" @lang = "en" @xmlns = "http://www.w3.org/1999/xhtml" @charset = "utf-8" @start_element = %{<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xml:lang=\"#{@xml_lang}\" lang=\"#{@lang}\" xmlns=\"#{@xmlns}\"}.strip() @end_element = "</html>" ["head", "body"].each do |c| @allowed_child_elements << c end @head = Head.new append(@head) @body = Body.new append(@body) c_type = Meta.new c_type.set_attribute("http-equiv", "Content-Type") c_type.set_attribute("content", "text/html;charset=#{@charset}") @head.append(c_type) end |
Instance Attribute Details
#xml_lang ⇒ Object
—–>
73 74 75 |
# File 'lib/reparcs/projects.rb', line 73 def xml_lang @xml_lang end |
Instance Method Details
#add_effect(element, event_type, effect_type) ⇒ Object
Adds a visual effect to a element Note* you must have included the scriptalicous library in your page beforehand and the element must have its id attribute set! Takes the element object, the event type, and the effect type as parameters.
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/reparcs/projects.rb', line 60 def add_effect(element, event_type, effect_type) script = shortcut_script(%{ window.addEventListener("load", function(event) { $('#{element.get_attribute('id')}').#{event_type} = function(event) { Effect.#{effect_type}($(#{element.get_attribute('id')})); return false; }; } ); }) @head.append(script) end |
#include_scriptaculous ⇒ Object
Includes the scriptaculous scripts in you page Note* it simply includes several script elements with relative paths to the scriptaculous script files, this method is really only useful if you have added this page to a Website object and have invoked the Website.include_scriptaculous_files method which will include the files when published. Unless you intend to create a javascript directory and include them yourself!
47 48 49 50 51 52 53 54 55 |
# File 'lib/reparcs/projects.rb', line 47 def include_scriptaculous Dir.foreach(JAVASCRIPT_LIB_PATH) { |f| unless f[0,1] == "." s = Script.new({:src => "javascript/#{f}"}) s.set_attribute("type", "text/javascript") @head.append(s) end } end |