• R/O
  • SSH
  • HTTPS

tenarai: 提交


Commit MetaInfo

修訂127 (tree)
時間2008-10-28 21:41:30
作者junkikuchi

Log Message

updated.

Change Summary

差異

--- trunk/init_model.rb (revision 126)
+++ trunk/init_model.rb (revision 127)
@@ -36,17 +36,17 @@
3636 },
3737 {
3838 :name => 'admin.yui',
39- :class => 'Widget::YUI',
39+ :class => 'Widget::Yahoo::UI::Loader',
4040 :relation => {'view' => 'view:admin.view'},
4141 },
4242 {
4343 :name => 'admin.yui.reset_css',
44- :class => 'Widget::YUI::ResetCSS',
44+ :class => 'Widget::Yahoo::UI::ResetCSS',
4545 :relation => {'view' => 'view:admin.view'},
4646 },
4747 {
4848 :name => 'admin.yui.layout',
49- :class => 'Widget::YUI::Layout',
49+ :class => 'Widget::Yahoo::UI::Layout',
5050 :relation => {'view' => 'view:admin.view'},
5151 :css => [
5252 ['.yui-layout-unit-top_background_background-color', '#c3d9ff'],
--- trunk/lib/tenarai/xml.rb (revision 126)
+++ trunk/lib/tenarai/xml.rb (revision 127)
@@ -245,10 +245,9 @@
245245
246246 def code(text)
247247 if 0 < @indent && !text.empty?
248- @buf << "\n"
249- @buf << "\n"
248+ @buf << "\n\n"
250249 @buf << text
251- @buf << "\n"
250+ #@buf << "\n"
252251 @text = false
253252 else
254253 @buf << text
--- trunk/config.rb (revision 126)
+++ trunk/config.rb (revision 127)
@@ -46,3 +46,5 @@
4646 ['widget.view', 'view.widget' ],
4747 ],
4848 }
49+
50+require 'config_local'
--- trunk/webapp/Widget/YUI.rb (revision 126)
+++ trunk/webapp/Widget/YUI.rb (nonexistent)
@@ -1,48 +0,0 @@
1-#
2-# Copyright (C) 2008 Jun Kikuchi <kikuchi@bonnou.com>
3-#
4-
5-Tenarai::ClassLoader.load_class('Widget')
6-
7-class Widget
8- class YUI < ::Widget
9- extend Tenarai::ClassLoader
10-
11- YUI_BASE_DIR = 'http://yui.yahooapis.com/2.6.0/build'
12-
13- property :src, YUI_BASE_DIR + '/yuiloader/yuiloader-min.js'
14-
15- attr_reader :modules
16-
17- def initialize(table, row={})
18- super
19- @modules = []
20- end
21-
22- def render_html(head, body)
23- modules = @modules.map do |val|
24- "'#{val}'"
25- end.join(', ')
26-
27- head.tag(
28- 'script',
29- 'type' => 'text/javascript',
30- 'src' => property[:src]
31- ).text('')
32-
33- script = head.tag('script', 'type' => 'text/javascript')
34- script.code <<-END
35-new YAHOO.util.YUILoader({
36- require: [#{modules}],
37- onSuccess: function() {
38- END
39-
40- super(head, script)
41-
42- script.code <<-END
43- }
44-}).insert();
45- END
46- end
47- end
48-end
--- trunk/webapp/Widget/GMap.rb (revision 126)
+++ trunk/webapp/Widget/GMap.rb (nonexistent)
@@ -1,52 +0,0 @@
1-#
2-# Copyright (C) 2008 Jun Kikuchi <kikuchi@bonnou.com>
3-#
4-
5-Tenarai::ClassLoader.load_class('Widget')
6-
7-class Widget
8- class GMap < ::Widget
9- extend Tenarai::ClassLoader
10-
11- preference_css 'box'
12-
13- preference 'preference' do |pref|
14- pref.group 'googlemaps' do |gmap|
15- gmap.edit 'key' do |key|
16- key.value = 'ABQIAAAAfZwvb09MEQqvWKTm8jvLtRTwM0brOpm-All5BF6PoaKBxRWWERRia6i9gSHSmIyQL2x1OB3bLqIzNQ'
17- end
18- end
19- end
20-
21- def render_html_head(xml, builder)
22- xml.tag(
23- 'script',
24- 'type'=> 'text/javascript',
25- 'src' => 'http://maps.google.com/maps?file=api&amp;v=2&amp;key=%s' % preference.preference.googlemaps.key.value
26- ).text('')
27- end
28-
29- def render_html(xml, builder)
30- xml.tag('div', 'id' => html_id).text('')
31- xml.tag('script', 'type' => 'text/javascript') do |js|
32- js.code <<-END
33-$(document).ready(function() {
34- if(GBrowserIsCompatible()) {
35- var map = new GMap2(document.getElementById('#{html_id}'));
36- map.addControl(new GLargeMapControl());
37- map.addControl(new GScaleControl());
38- map.addControl(new GMapTypeControl());
39- map.addControl(new GOverviewMapControl());
40- map.setCenter(new GLatLng(37.4419, -122.1419), 13);
41- map.enableScrollWheelZoom();
42- }
43-});
44-
45-$(document).unload(function() {
46- GUnload();
47-});
48- END
49- end
50- end
51- end
52-end
--- trunk/webapp/Widget/Yahoo/UI/Layout.rb (nonexistent)
+++ trunk/webapp/Widget/Yahoo/UI/Layout.rb (revision 127)
@@ -0,0 +1,148 @@
1+#
2+# Copyright (C) 2008 Jun Kikuchi <kikuchi@bonnou.com>
3+#
4+
5+Tenarai::ClassLoader.load_class('Widget::Yahoo::UI::Loader')
6+
7+class Widget
8+ class Yahoo
9+ class UI
10+ class Layout < ::Widget
11+ extend Tenarai::ClassLoader
12+
13+ resource 'Widget::Yahoo::UI::Loader'
14+
15+ property :layout_id
16+
17+ property :top_body
18+ property :top_header
19+ property :top_height
20+ property :top_resize
21+ property :top_gutter
22+ property :top_footer
23+ property :top_collapse
24+ property :top_scroll
25+ property :top_animate
26+
27+ property :right_body
28+ property :right_header
29+ property :right_width
30+ property :right_resize
31+ property :right_gutter
32+ property :right_footer
33+ property :right_collapse
34+ property :right_scroll
35+ property :right_animate
36+
37+ property :bottom_body
38+ property :bottom_header
39+ property :bottom_height
40+ property :bottom_resize
41+ property :bottom_gutter
42+ property :bottom_footer
43+ property :bottom_collapse
44+ property :bottom_scroll
45+ property :bottom_animate
46+
47+ property :left_body
48+ property :left_header
49+ property :left_width
50+ property :left_resize
51+ property :left_gutter
52+ property :left_footer
53+ property :left_collapse
54+ property :left_scroll
55+ property :left_animate
56+
57+ property :center_body
58+ property :center_header
59+ property :center_gutter
60+ property :center_footer
61+ property :center_scroll
62+
63+ css '.yui-layout-unit-top'
64+ css '.yui-layout-unit-right'
65+ css '.yui-layout-unit-bottom'
66+ css '.yui-layout-unit-left'
67+
68+ css '.yui-layout-unit .yui-resize-handle-t .yui-layout-resize-knob'
69+ css '.yui-layout-unit .yui-resize-handle-r .yui-layout-resize-knob'
70+ css '.yui-layout-unit .yui-resize-handle-b .yui-layout-resize-knob'
71+ css '.yui-layout-unit .yui-resize-handle-l .yui-layout-resize-knob'
72+
73+ def init(builder, service, *param)
74+ super
75+ resource.modules << 'layout'
76+ resource.modules << 'resize'
77+ end
78+
79+ def render_css(_css)
80+ css.each do |val|
81+ a = val.name.split('_')
82+ _css.selector(a.shift, a.pop => val.value)
83+ end
84+ end
85+
86+ def render_html(head, body)
87+ head.tag(
88+ 'link',
89+ 'rel' => 'stylesheet',
90+ 'type' => 'text/css',
91+ 'href' => 'http://yui.yahooapis.com/2.6.0/build/assets/skins/sam/resize.css'
92+ )
93+ head.tag(
94+ 'link',
95+ 'rel' => 'stylesheet',
96+ 'type' => 'text/css',
97+ 'href' => 'http://yui.yahooapis.com/2.6.0/build/assets/skins/sam/layout.css'
98+ )
99+
100+ units = [
101+ 'top',
102+ 'right',
103+ 'bottom',
104+ 'left',
105+ 'center'
106+ ].inject([]) do |ret, pos|
107+ if _body = property["#{pos}_body".intern]
108+ unit = {'position' => "'#{pos}'", 'body' => _body}
109+
110+ [
111+ 'header',
112+ 'height',
113+ 'width',
114+ 'resize',
115+ 'gutter',
116+ 'footer',
117+ 'collapse',
118+ 'scroll',
119+ 'animate'
120+ ].each do |key|
121+ if val = property["#{pos}_#{key}".intern]
122+ unit[key] = val
123+ end
124+ end
125+
126+ ret << '{' + unit.sort.map do |key, val|
127+ "#{key}: #{val}"
128+ end.join(', ') + '}'
129+ end
130+
131+ ret
132+ end.join(', ')
133+
134+ body.code <<-END
135+var Dom = YAHOO.util.Dom;
136+var Event = YAHOO.util.Event;
137+
138+Event.onDOMReady(function() {
139+ new YAHOO.widget.Layout({
140+ units: [#{units}]
141+ }).render();
142+});
143+ END
144+ end
145+ end
146+ end
147+ end
148+end
--- trunk/webapp/Widget/Yahoo/UI/Loader.rb (nonexistent)
+++ trunk/webapp/Widget/Yahoo/UI/Loader.rb (revision 127)
@@ -0,0 +1,52 @@
1+#
2+# Copyright (C) 2008 Jun Kikuchi <kikuchi@bonnou.com>
3+#
4+
5+Tenarai::ClassLoader.load_class('Widget')
6+
7+class Widget
8+ class Yahoo
9+ class UI
10+ class Loader < ::Widget
11+ extend Tenarai::ClassLoader
12+
13+ YUI_BASE_DIR = 'http://yui.yahooapis.com/2.6.0/build'
14+
15+ property :src, YUI_BASE_DIR + '/yuiloader/yuiloader-min.js'
16+
17+ attr_reader :modules
18+
19+ def initialize(table, row={})
20+ super
21+ @modules = []
22+ end
23+
24+ def render_html(head, body)
25+ modules = @modules.map do |val|
26+ "'#{val}'"
27+ end.join(', ')
28+
29+ head.tag(
30+ 'script',
31+ 'type' => 'text/javascript',
32+ 'src' => property[:src]
33+ ).text('')
34+
35+ script = head.tag('script', 'type' => 'text/javascript')
36+ script.code <<-END
37+new YAHOO.util.YUILoader({
38+ require: [#{modules}],
39+ onSuccess: function() {
40+ END
41+
42+ super(head, script)
43+
44+ script.code <<-END
45+ }
46+}).insert();
47+ END
48+ end
49+ end
50+ end
51+ end
52+end
--- trunk/webapp/Widget/Yahoo/UI/ResetCSS.rb (nonexistent)
+++ trunk/webapp/Widget/Yahoo/UI/ResetCSS.rb (revision 127)
@@ -0,0 +1,22 @@
1+#
2+# Copyright (C) 2008 Jun Kikuchi <kikuchi@bonnou.com>
3+#
4+
5+Tenarai::ClassLoader.load_class('Widget::Yahoo::UI::Loader')
6+
7+class Widget
8+ class Yahoo
9+ class UI
10+ class ResetCSS < ::Widget
11+ extend Tenarai::ClassLoader
12+
13+ resource 'Widget::Yahoo::UI::Loader'
14+
15+ def init(builder, service, *param)
16+ super
17+ resource.modules << 'reset-fonts-grids'
18+ end
19+ end
20+ end
21+ end
22+end
--- trunk/webapp/Widget/Google/AJAX/Load.rb (nonexistent)
+++ trunk/webapp/Widget/Google/AJAX/Load.rb (revision 127)
@@ -0,0 +1,26 @@
1+#
2+# Copyright (C) 2008 Jun Kikuchi <kikuchi@bonnou.com>
3+#
4+#
5+Tenarai::ClassLoader.load_class('Widget::Widget::Google::AJAX')
6+
7+class Widget
8+ class Widget
9+ class Google
10+ class AJAX
11+ class Load
12+ extend Tenarai::ClassLoader
13+
14+ property :name
15+ property :version
16+
17+ def render_html(head, body)
18+ head.tag('script', 'type' => 'text/javascript').code(
19+ "google.load('#{property[:name]}', '#{property[:version]}');"
20+ )
21+ end
22+ end
23+ end
24+ end
25+ end
26+end
--- trunk/webapp/Widget/Google/AJAX.rb (nonexistent)
+++ trunk/webapp/Widget/Google/AJAX.rb (revision 127)
@@ -0,0 +1,31 @@
1+#
2+# Copyright (C) 2008 Jun Kikuchi <kikuchi@bonnou.com>
3+#
4+
5+Tenarai::ClassLoader.load_class('Widget')
6+
7+class Widget
8+ class Widget
9+ class Google
10+ class AJAX < ::Widget
11+ extend Tenarai::ClassLoader
12+
13+ SRC = 'http://www.google.com/jsapi'
14+
15+ property :key
16+
17+ def render_html(head, body)
18+ head.tag(
19+ 'script',
20+ 'type' => 'text/javascript',
21+ 'src' => if property[:key].empty?
22+ Widget::Widget::Jsapi::SRC
23+ else
24+ Widget::Widget::Jsapi::SRC + "?key=#{key}"
25+ end
26+ ).text('')
27+ end
28+ end
29+ end
30+ end
31+end
Show on old repository browser