• R/O
  • SSH
  • HTTPS

tenarai: 提交


Commit MetaInfo

修訂113 (tree)
時間2008-09-07 15:32:08
作者junkikuchi

Log Message

updated.

Change Summary

差異

--- trunk/webapp/Widget/Widget/Property.rb (revision 112)
+++ trunk/webapp/Widget/Widget/Property.rb (revision 113)
@@ -12,6 +12,7 @@
1212 css
1313
1414 def render_property_form(xml, widget)
15+ xml.tag('h3').text('Property')
1516 xml.tag(
1617 'form',
1718 'method' => 'post',
--- trunk/webapp/Widget/Widget/CSS.rb (revision 112)
+++ trunk/webapp/Widget/Widget/CSS.rb (revision 113)
@@ -11,25 +11,136 @@
1111
1212 css
1313
14+ CSS = Tenarai::Container.new
15+ CSS << Tenarai::Container::Value.new(
16+ 'font',
17+ [
18+ 'font-family',
19+ 'font-weight',
20+ 'font-size',
21+ 'font-style',
22+ 'font-variant',
23+ ]
24+ )
25+ CSS << Tenarai::Container::Value.new(
26+ 'text',
27+ [
28+ 'color',
29+ 'text-indent',
30+ 'text-align',
31+ 'line-height',
32+ 'vertical-align',
33+ 'word-spacing',
34+ 'letter-spacing',
35+ 'text-transform',
36+ 'text-decoration',
37+ 'white-space',
38+ ]
39+ )
40+ CSS << Tenarai::Container::Value.new(
41+ 'background',
42+ [
43+ 'background-color',
44+ 'background-image',
45+ 'background-repeat',
46+ 'background-position',
47+ 'background-attachment',
48+ ]
49+ )
50+ CSS << Tenarai::Container::Value.new(
51+ 'margin',
52+ [
53+ 'margin',
54+ 'margin-top',
55+ 'margin-right',
56+ 'margin-bottom',
57+ 'margin-left',
58+ ]
59+ )
60+ CSS << Tenarai::Container::Value.new(
61+ 'border',
62+ [
63+ 'border',
64+ 'border-top',
65+ 'border-right',
66+ 'border-bottom',
67+ 'border-left',
68+ ]
69+ )
70+ CSS << Tenarai::Container::Value.new(
71+ 'padding',
72+ [
73+ 'padding',
74+ 'padding-top',
75+ 'padding-right',
76+ 'padding-bottom',
77+ 'padding-left',
78+ ]
79+ )
80+ CSS << Tenarai::Container::Value.new(
81+ 'size',
82+ [
83+ 'width',
84+ 'height',
85+ 'min-width',
86+ 'min-height',
87+ 'max-width',
88+ 'max-height',
89+ ]
90+ )
91+ CSS << Tenarai::Container::Value.new(
92+ 'layout',
93+ [
94+ 'float',
95+ 'clear',
96+ 'position',
97+ 'top',
98+ 'right',
99+ 'bottom',
100+ 'left',
101+ 'overflow',
102+ 'clip',
103+ 'visibility',
104+ 'z-index',
105+ 'display',
106+ ]
107+ )
108+ CSS << Tenarai::Container::Value.new(
109+ 'list',
110+ [
111+ 'list-style-type',
112+ ]
113+ )
114+ CSS << Tenarai::Container::Value.new(
115+ 'ui',
116+ [
117+ 'cursor',
118+ ]
119+ )
120+
14121 def render_css_form(xml, widget)
15122 widget.class.meta[:css].each do |val|
16- xml.tag('h3').text(val.name)
123+ xml.tag('h3').text(
124+ if val.name.to_s.empty? then 'CSS' else val.name end
125+ )
17126 xml.tag(
18127 'form',
19128 'method' => 'post',
20- 'action' => uri(
21- @builder.view,
22- resource.content.id
23- ) do |query|
129+ 'action' => uri(@builder.view, resource.content.id) do |query|
24130 query[form_id('update')] = nil
25131 end
26132 ) do |form|
27- ::Widget::CSS::CSS.each do |css|
133+ self.class::CSS.each do |css|
28134 form.tag('h4').text(css.name)
29135 form.tag('dl') do |dl|
30136 css.value.each do |selector|
31137 _form_id = [val.name, css.name, selector].join('.')
32- _id = form_id(_form_id)
138+ _id = form_id(_form_id)
139+ value = if widget.css.key?(_form_id) then
140+ widget.css[_form_id].value
141+ else
142+ ''
143+ end
33144 dl.tag('dt').tag('label', 'for' => _id).text(selector)
34145 dl.tag('dd').tag(
35146 'input',
@@ -36,7 +147,7 @@
36147 'type' => 'text',
37148 'id' => _id,
38149 'name' => _id,
39- 'value' => widget.css[_form_id]
150+ 'value' => value
40151 )
41152 end
42153 dl.tag('dt').tag('br')
@@ -54,14 +165,17 @@
54165
55166 def render_html(head, body)
56167 body.tag('div', html_attr) do |div|
57- #render_css_form(div, resource.content)
168+ render_css_form(div, resource.content)
58169 div.text('') if div.empty?
59170 end
60171 end
61172
62173 def post(query={})
174+ resource.content.css.clear
63175 query.each do |key, val|
64- resource.content.css[key] = val
176+ unless val.empty?
177+ resource.content.css << Tenarai::Container::Value.new(key, val)
178+ end
65179 end
66180 resource.content.save
67181 end
--- trunk/webapp/Widget.rb (revision 112)
+++ trunk/webapp/Widget.rb (revision 113)
@@ -8,6 +8,7 @@
88 extend Tenarai::ClassLoader
99
1010 meta[:property] = {}
11+ meta[:css] = Tenarai::Container.new
1112 meta[:resource] = nil
1213
1314 class << self
@@ -19,10 +20,17 @@
1920 meta[:property][name] = value
2021 end
2122
22- def css(name=nil, *selectors)
23+ def css(name='', *selectors)
24+ meta[:css] << Tenarai::Container::Value.new(name, selectors)
2325 end
2426
2527 def css_list
28+ css 'ul'
29+ css 'li ul'
30+ css 'ul li'
31+ css 'a'
32+ css 'a.selected'
33+ css 'a:hover'
2634 end
2735
2836 def resource(klass)
@@ -39,6 +47,7 @@
3947 def inherited(subclass)
4048 super
4149 subclass.meta[:property] = meta[:property].clone
50+ subclass.meta[:css] = meta[:css].clone
4251 subclass.meta[:resource] = subclass.name.sub(/\w+?$/, '').sub(/::+?$/, '')
4352 subclass.meta[:resource] = nil if subclass.meta[:resource].empty?
4453 end
@@ -57,7 +66,7 @@
5766 def initialize(table, row={})
5867 super
5968 self.property ||= self.class.meta[:property].clone
60- self.css ||= []
69+ self.css ||= Tenarai::Container.new
6170 end
6271
6372 def init(builder, service, *param)
Show on old repository browser