gettext 1.10.0 → 1.90.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +156 -2
- data/NEWS +28 -0
- data/README +128 -138
- data/Rakefile +83 -43
- data/data/locale/es/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/hu/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/hu/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ua/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ua/LC_MESSAGES/rgettext.mo +0 -0
- data/doc/classes/ActiveRecord/Base.html +360 -0
- data/doc/classes/ActiveRecord/ConnectionAdapters/Column.html +182 -0
- data/doc/classes/ActiveRecord/Migration.html +118 -0
- data/doc/classes/GetText.html +1790 -0
- data/doc/classes/GetText/ActiveRecordParser.html +236 -0
- data/doc/classes/GetText/Container.html +119 -0
- data/doc/classes/GetText/ErbContainer.html +223 -0
- data/doc/classes/GetText/ErbParser.html +156 -0
- data/doc/classes/GetText/GladeParser.html +133 -0
- data/doc/classes/GetText/NoboundTextDomainError.html +119 -0
- data/doc/classes/GetText/PoParser.html +169 -0
- data/doc/classes/GetText/Rails.html +293 -0
- data/doc/classes/GetText/RubyParser.html +123 -0
- data/doc/classes/GetText/TextDomain.html +572 -0
- data/doc/classes/GetText/TextDomainManager.html +443 -0
- data/doc/classes/Iconv.html +257 -0
- data/doc/classes/Iconv/Failure.html +105 -0
- data/doc/classes/Iconv/IllegalSequence.html +118 -0
- data/doc/classes/Iconv/InvalidCharacter.html +118 -0
- data/doc/classes/Iconv/InvalidEncoding.html +118 -0
- data/doc/classes/Locale.html +839 -0
- data/doc/classes/Locale/Object.html +799 -0
- data/doc/classes/Locale/SystemBase.html +271 -0
- data/doc/classes/Locale/SystemCGI.html +312 -0
- data/doc/classes/Locale/SystemJRuby.html +112 -0
- data/doc/classes/Locale/SystemPosix.html +113 -0
- data/doc/classes/Locale/SystemWin32.html +182 -0
- data/doc/classes/MOFile.html +678 -0
- data/doc/classes/MOFile/InvalidFormat.html +111 -0
- data/doc/classes/Module.html +158 -0
- data/doc/classes/String.html +225 -0
- data/doc/created.rid +1 -0
- data/doc/files/ChangeLog.html +2355 -0
- data/doc/files/README.html +510 -0
- data/doc/files/lib/gettext/active_record_rb.html +110 -0
- data/doc/files/lib/gettext/cgi_rb.html +110 -0
- data/doc/files/lib/gettext/container_rb.html +108 -0
- data/doc/files/lib/gettext/erb_rb.html +109 -0
- data/doc/files/lib/gettext/iconv_rb.html +109 -0
- data/doc/files/lib/gettext/mo_rb.html +108 -0
- data/doc/files/lib/gettext/parser/active_record_rb.html +119 -0
- data/doc/files/lib/gettext/parser/erb_rb.html +109 -0
- data/doc/files/lib/gettext/parser/glade_rb.html +109 -0
- data/doc/files/lib/gettext/parser/ruby_rb.html +110 -0
- data/doc/files/lib/gettext/poparser_rb.html +108 -0
- data/doc/files/lib/gettext/rails_compat_rb.html +108 -0
- data/doc/files/lib/gettext/rails_rb.html +112 -0
- data/doc/files/lib/gettext/rgettext_rb.html +110 -0
- data/doc/files/lib/gettext/rmsgfmt_rb.html +112 -0
- data/doc/files/lib/gettext/rmsgmerge_rb.html +112 -0
- data/doc/files/lib/gettext/string_rb.html +101 -0
- data/doc/files/lib/gettext/textdomain_rb.html +109 -0
- data/doc/files/lib/gettext/textdomainmanager_rb.html +109 -0
- data/doc/files/lib/gettext/utils_rb.html +111 -0
- data/doc/files/lib/gettext/version_rb.html +101 -0
- data/doc/files/lib/gettext_rb.html +113 -0
- data/doc/files/lib/locale/base_rb.html +101 -0
- data/doc/files/lib/locale/cgi_rb.html +108 -0
- data/doc/files/lib/locale/jruby_rb.html +110 -0
- data/doc/files/lib/locale/object_rb.html +101 -0
- data/doc/files/lib/locale/posix_rb.html +108 -0
- data/doc/files/lib/locale/win32_rb.html +110 -0
- data/doc/files/lib/locale/win32_table_rb.html +101 -0
- data/doc/files/lib/locale_rb.html +111 -0
- data/doc/fr_class_index.html +57 -0
- data/doc/fr_file_index.html +58 -0
- data/doc/fr_method_index.html +155 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/lib/gettext.rb +102 -50
- data/lib/gettext/cgi.rb +2 -27
- data/lib/gettext/iconv.rb +76 -62
- data/lib/gettext/mo.rb +3 -3
- data/lib/gettext/parser/erb.rb +2 -2
- data/lib/gettext/rails.rb +69 -48
- data/lib/gettext/rgettext.rb +2 -2
- data/lib/gettext/rmsgmerge.rb +2 -2
- data/lib/gettext/string.rb +9 -5
- data/lib/gettext/textdomain.rb +3 -3
- data/lib/gettext/textdomainmanager.rb +5 -5
- data/lib/gettext/utils.rb +4 -3
- data/lib/gettext/version.rb +1 -1
- data/lib/{gettext/locale.rb → locale.rb} +11 -58
- data/lib/locale/base.rb +60 -0
- data/lib/{gettext/locale_cgi.rb → locale/cgi.rb} +30 -28
- data/lib/locale/jruby.rb +36 -0
- data/lib/{gettext/locale_object.rb → locale/object.rb} +78 -24
- data/lib/locale/posix.rb +22 -0
- data/lib/locale/win32.rb +48 -0
- data/lib/{gettext/locale_table_win32.rb → locale/win32_table.rb} +3 -2
- data/po/es/rails.po +1 -2
- data/po/hu/rails.po +139 -0
- data/po/hu/rgettext.po +126 -0
- data/po/ja/rails.po +5 -5
- data/po/ua/rails.po +150 -0
- data/po/ua/rgettext.po +132 -0
- data/pre-setup.rb +2 -4
- data/samples/cgi/cookie.cgi +1 -0
- data/samples/cgi/helloerb1.cgi +6 -3
- data/samples/cgi/helloerb2.cgi +6 -3
- data/samples/cgi/http.rb +3 -7
- data/samples/cgi/index.cgi +2 -1
- data/samples/cgi/locale/hu/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/hu/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/hu/LC_MESSAGES/hellolib.mo +0 -0
- data/samples/cgi/locale/hu/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/ua/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/ua/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/ua/LC_MESSAGES/hellolib.mo +0 -0
- data/samples/cgi/locale/ua/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/po/hu/helloerb1.po +59 -0
- data/samples/cgi/po/hu/helloerb2.po +51 -0
- data/samples/cgi/po/hu/hellolib.po +23 -0
- data/samples/cgi/po/hu/main.po +82 -0
- data/samples/cgi/po/ua/helloerb1.po +62 -0
- data/samples/cgi/po/ua/helloerb2.po +54 -0
- data/samples/cgi/po/ua/hellolib.po +26 -0
- data/samples/cgi/po/ua/main.po +84 -0
- data/samples/locale/hu/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/hu/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/hu/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/hu/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/hu/LC_MESSAGES/helloglade2.mo +0 -0
- data/samples/locale/hu/LC_MESSAGES/hellogtk.mo +0 -0
- data/samples/locale/hu/LC_MESSAGES/hellotk.mo +0 -0
- data/samples/locale/ua/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/ua/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/ua/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/ua/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/ua/LC_MESSAGES/helloglade2.mo +0 -0
- data/samples/locale/ua/LC_MESSAGES/hellogtk.mo +0 -0
- data/samples/locale/ua/LC_MESSAGES/hellotk.mo +0 -0
- data/samples/po/hu/hello.po +22 -0
- data/samples/po/hu/hello2.po +30 -0
- data/samples/po/hu/hello_noop.po +26 -0
- data/samples/po/hu/hello_plural.po +25 -0
- data/samples/po/hu/helloglade2.po +31 -0
- data/samples/po/hu/hellogtk.po +22 -0
- data/samples/po/hu/hellotk.po +23 -0
- data/samples/po/ua/hello.po +22 -0
- data/samples/po/ua/hello2.po +30 -0
- data/samples/po/ua/hello_noop.po +26 -0
- data/samples/po/ua/hello_plural.po +29 -0
- data/samples/po/ua/helloglade2.po +34 -0
- data/samples/po/ua/hellogtk.po +22 -0
- data/samples/po/ua/hellotk.po +26 -0
- data/samples/rails/README +15 -31
- data/samples/rails/Rakefile +1 -1
- data/samples/rails/app/controllers/application.rb +11 -4
- data/samples/rails/app/controllers/articles_controller.rb +96 -0
- data/samples/rails/app/helpers/application_helper.rb +1 -1
- data/samples/rails/app/helpers/{blog_helper.rb → articles_helper.rb} +6 -7
- data/samples/rails/app/views/articles/edit.html.erb +18 -0
- data/samples/rails/app/views/articles/index.html.erb +17 -0
- data/samples/rails/app/views/articles/new.html.erb +16 -0
- data/samples/rails/app/views/articles/show.html.erb +6 -0
- data/samples/rails/app/views/layouts/articles.html.erb +26 -0
- data/samples/rails/config/boot.rb +104 -13
- data/samples/rails/config/database.yml +24 -21
- data/samples/rails/config/environment.rb +35 -30
- data/samples/rails/config/environments/development.rb +5 -6
- data/samples/rails/config/environments/production.rb +2 -3
- data/samples/rails/config/environments/test.rb +5 -2
- data/samples/rails/config/initializers/inflections.rb +10 -0
- data/samples/rails/config/initializers/mime_types.rb +5 -0
- data/samples/rails/config/routes.rb +30 -11
- data/samples/rails/db/migrate/001_create_articles.rb +14 -0
- data/samples/rails/db/schema.rb +16 -5
- data/samples/rails/lib/tasks/gettext.rake +2 -2
- data/samples/rails/locale/bs/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ca/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/cs/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/de/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/el/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/en/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/eo/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/es/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/fr/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/hr/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/hu/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/it/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ja/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ko/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/nb/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/nl/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/pt_BR/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ru/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ua/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/vi/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/zh/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/zh_TW/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/po/blog.pot +24 -24
- data/samples/rails/po/bs/blog.po +29 -29
- data/samples/rails/po/ca/blog.po +27 -27
- data/samples/rails/po/cs/blog.po +27 -27
- data/samples/rails/po/de/blog.po +27 -27
- data/samples/rails/po/el/blog.po +27 -27
- data/samples/rails/po/en/blog.po +24 -24
- data/samples/rails/po/eo/blog.po +27 -27
- data/samples/rails/po/es/blog.po +27 -27
- data/samples/rails/po/fr/blog.po +27 -27
- data/samples/rails/po/hr/blog.po +29 -29
- data/samples/rails/po/hu/blog.po +105 -0
- data/samples/rails/po/it/blog.po +27 -27
- data/samples/rails/po/ja/blog.po +27 -27
- data/samples/rails/po/ko/blog.po +27 -27
- data/samples/rails/po/nb/blog.po +26 -27
- data/samples/rails/po/nl/blog.po +27 -27
- data/samples/rails/po/pt_BR/blog.po +27 -27
- data/samples/rails/po/ru/blog.po +27 -27
- data/samples/rails/po/ua/blog.po +108 -0
- data/samples/rails/po/vi/blog.po +26 -31
- data/samples/rails/po/zh/blog.po +27 -27
- data/samples/rails/po/zh_TW/blog.po +27 -27
- data/samples/rails/public/404.html +27 -5
- data/samples/rails/public/422.html +30 -0
- data/samples/rails/public/500.html +27 -5
- data/samples/rails/public/index.html +6 -6
- data/samples/rails/public/javascripts/application.js +2 -0
- data/samples/rails/public/javascripts/controls.js +532 -319
- data/samples/rails/public/javascripts/dragdrop.js +521 -133
- data/samples/rails/public/javascripts/effects.js +708 -442
- data/samples/rails/public/javascripts/prototype.js +3393 -953
- data/samples/rails/public/stylesheets/blog.css +4 -0
- data/samples/rails/public/stylesheets/scaffold.css +5 -5
- data/samples/rails/test/functional/articles_controller_test.rb +51 -0
- data/samples/rails/test/test_helper.rb +31 -19
- data/samples/rails/test/unit/article_test.rb +2 -9
- data/samples/rails/vendor/plugins/gettext/init.rb +5 -3
- data/samples/rails/vendor/plugins/gettext/lib/gettext_plugin.rb +9 -10
- data/samples/rails/vendor/plugins/gettext/locale/eo/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/vendor/plugins/gettext/locale/hu/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/vendor/plugins/gettext/locale/ua/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/vendor/plugins/gettext/po/eo/gettext_plugin.po +28 -0
- data/samples/rails/vendor/plugins/gettext/po/hu/gettext_plugin.po +27 -0
- data/samples/rails/vendor/plugins/gettext/po/ua/gettext_plugin.po +30 -0
- data/test/Rakefile +2 -1
- data/test/benchmark.rb +28 -0
- data/test/fixtures/topic.rb +15 -0
- data/test/rails/Rakefile +2 -1
- data/test/rails/app/controllers/articles_controller.rb +1 -1
- data/test/rails/app/controllers/users_controller.rb +10 -0
- data/test/rails/app/models/user.rb +2 -1
- data/test/rails/app/views/articles/{_form.rhtml → _form.html.erb} +0 -0
- data/test/rails/app/views/articles/active_form_error.html.erb +1 -0
- data/test/rails/app/views/articles/change_title_error_messages_for.html.erb +21 -0
- data/test/rails/app/views/articles/{edit.rhtml → edit.html.erb} +0 -0
- data/test/rails/app/views/articles/{list.rhtml → list.html.erb} +0 -3
- data/test/rails/app/views/articles/{list_fr.rhtml → list_fr.html.erb} +0 -0
- data/test/rails/app/views/articles/{multi_error_messages_for.rhtml → multi_error_messages_for.html.erb} +0 -0
- data/test/rails/app/views/articles/{new.rhtml → new.html.erb} +0 -0
- data/test/rails/app/views/articles/{show.rhtml → show.html.erb} +0 -0
- data/test/rails/app/views/layouts/{application.rhtml → application.html.erb} +0 -0
- data/test/rails/app/views/layouts/{mailer.rhtml → mailer.html.erb} +0 -0
- data/test/rails/app/views/layouts/users.html.erb +13 -0
- data/test/rails/app/views/users/custom_error_message.html.erb +13 -0
- data/test/rails/app/views/users/custom_error_message_fr.html.erb +13 -0
- data/test/rails/config/environment.rb +6 -1
- data/test/rails/config/environments/development.rb +0 -3
- data/test/rails/db/schema.rb +17 -10
- data/test/rails/locale/ja/LC_MESSAGES/rails_test.mo +0 -0
- data/test/rails/log/development.log +136 -29
- data/test/rails/log/test.log +2002 -128
- data/test/rails/po/ja/rails_test.po +68 -61
- data/test/rails/po/rails_test.pot +57 -55
- data/test/rails/test/fixtures/users.yml +5 -0
- data/test/rails/test/functional/articles_controller_test.rb +6 -1
- data/test/rails/test/functional/users_controller_test.rb +65 -0
- data/test/rails/test/result/en/custom_error_message.html +83 -0
- data/test/rails/test/result/en/custom_error_message_with_plural.html +83 -0
- data/test/rails/test/result/en/list.html +0 -3
- data/test/rails/test/result/en/multi_error_messages_for.html +1 -1
- data/test/rails/test/result/fr/custom_error_message.html +83 -0
- data/test/rails/test/result/fr/custom_error_message_with_plural.html +83 -0
- data/test/rails/test/result/ja/custom_error_message.html +83 -0
- data/test/rails/test/result/ja/custom_error_message_with_plural.html +83 -0
- data/test/rails/test/result/ja/list.html +0 -3
- data/test/rails/test/result/ja/multi_error_messages_for.html +1 -1
- data/test/test.sh +5 -7
- data/test/{gettext_test_active_record.rb → test_active_record.rb} +20 -10
- data/test/{gettext_test_cgi.rb → test_cgi.rb} +0 -0
- data/test/{gettext_test.rb → test_gettext.rb} +91 -9
- data/test/test_java.sh +12 -0
- data/test/{gettext_test_locale.rb → test_locale.rb} +3 -8
- data/test/{gettext_test_multi_textdomain.rb → test_multi_textdomain.rb} +2 -2
- data/test/{gettext_test_parser.rb → test_parser.rb} +77 -77
- data/test/{gettext_test_rails.rb → test_rails.rb} +0 -0
- data/test/{gettext_test_rails_caching.rb → test_rails_caching.rb} +16 -2
- data/test/{gettext_test_string.rb → test_string.rb} +1 -0
- data/test/{test_rubyparser_N.rb → testlib/N_.rb} +0 -0
- data/test/testlib/erb.rhtml +15 -0
- data/test/testlib/erb.rxml +16 -0
- data/test/{test_rubyparser.rb → testlib/gettext.rb} +0 -0
- data/test/testlib/gladeparser.glade +183 -0
- data/test/{test_rubyparser_n_.rb → testlib/ngettext.rb} +0 -0
- data/test/{test_nsgettext.rb → testlib/nsgettext.rb} +0 -0
- data/test/{test_sgettext.rb → testlib/sgettext.rb} +0 -0
- data/test/{testlib1.rb → testlib/testlib1.rb} +0 -0
- data/test/{testlib2.rb → testlib/testlib2.rb} +1 -1
- data/test/{testlib3.rb → testlib/testlib3.rb} +0 -0
- data/test/{testlib4.rb → testlib/testlib4.rb} +1 -1
- data/test/{testlib5.rb → testlib/testlib5.rb} +0 -0
- data/test/{testlib6.rb → testlib/testlib6.rb} +0 -0
- metadata +1374 -1171
- data/ext/gettext/extconf.rb +0 -20
- data/ext/gettext/locale_system.c +0 -83
- data/lib/gettext/locale_posix.rb +0 -82
- data/lib/gettext/locale_win32.rb +0 -82
- data/samples/cgi/ruby.bat +0 -4
- data/samples/rails/app/controllers/blog_controller.rb +0 -58
- data/samples/rails/app/views/blog/_form.rhtml +0 -25
- data/samples/rails/app/views/blog/edit.rhtml +0 -22
- data/samples/rails/app/views/blog/list.rhtml +0 -29
- data/samples/rails/app/views/blog/new.rhtml +0 -21
- data/samples/rails/app/views/blog/show.rhtml +0 -18
- data/samples/rails/app/views/layouts/blog.rhtml +0 -36
- data/samples/rails/test/functional/blog_controller_test.rb +0 -98
- data/test/gettext_runner.rb +0 -22
data/samples/rails/po/zh/blog.po
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
msgid ""
|
10
10
|
msgstr ""
|
11
11
|
"Project-Id-Version: blog 1.2.0\n"
|
12
|
-
"POT-Creation-Date:
|
12
|
+
"POT-Creation-Date: 2007-08-01 23:20+0900\n"
|
13
13
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14
14
|
"Last-Translator: Yingfeng <blogyingfeng at gmail.com>\n"
|
15
15
|
"Language-Team: Simplified Chinese\n"
|
@@ -50,6 +50,20 @@ msgstr "文章创建成功"
|
|
50
50
|
msgid "Article was successfully updated."
|
51
51
|
msgstr "文章更新成功"
|
52
52
|
|
53
|
+
#: app/views/blog/show.rhtml:13 app/views/blog/list.rhtml:13
|
54
|
+
#: app/views/layouts/blog.rhtml:14
|
55
|
+
msgid "GetText Sample Blog on RoR"
|
56
|
+
msgstr "GetText的RoR示例Blog"
|
57
|
+
|
58
|
+
#: app/views/blog/show.rhtml:16 app/views/blog/edit.rhtml:16
|
59
|
+
msgid "Edit"
|
60
|
+
msgstr "编辑"
|
61
|
+
|
62
|
+
#: app/views/blog/show.rhtml:17 app/views/blog/new.rhtml:20
|
63
|
+
#: app/views/blog/edit.rhtml:21
|
64
|
+
msgid "Back"
|
65
|
+
msgstr "返回"
|
66
|
+
|
53
67
|
#: app/views/blog/new.rhtml:13 app/views/blog/list.rhtml:15
|
54
68
|
msgid "New article"
|
55
69
|
msgstr "新文章"
|
@@ -58,28 +72,6 @@ msgstr "新文章"
|
|
58
72
|
msgid "Create"
|
59
73
|
msgstr "创建"
|
60
74
|
|
61
|
-
#: app/views/blog/new.rhtml:20 app/views/blog/edit.rhtml:21
|
62
|
-
#: app/views/blog/show.rhtml:17
|
63
|
-
msgid "Back"
|
64
|
-
msgstr "返回"
|
65
|
-
|
66
|
-
#: app/views/blog/_form.rhtml:16
|
67
|
-
msgid "Lastupdate"
|
68
|
-
msgstr "上次更新"
|
69
|
-
|
70
|
-
#: app/views/blog/_form.rhtml:18
|
71
|
-
msgid "Title: Required."
|
72
|
-
msgstr "标题:需要设置"
|
73
|
-
|
74
|
-
#: app/views/blog/_form.rhtml:21
|
75
|
-
msgid "Description: More than 10 characters."
|
76
|
-
msgstr "描述:需要超过10个字符"
|
77
|
-
|
78
|
-
#: app/views/blog/list.rhtml:13 app/views/blog/show.rhtml:13
|
79
|
-
#: app/views/layouts/blog.rhtml:14
|
80
|
-
msgid "GetText Sample Blog on RoR"
|
81
|
-
msgstr "GetText的RoR示例Blog"
|
82
|
-
|
83
75
|
#: app/views/blog/list.rhtml:18
|
84
76
|
msgid "No articles were found."
|
85
77
|
msgstr "没有文章"
|
@@ -88,10 +80,6 @@ msgstr "没有文章"
|
|
88
80
|
msgid "Editing article"
|
89
81
|
msgstr "编辑文章"
|
90
82
|
|
91
|
-
#: app/views/blog/edit.rhtml:16 app/views/blog/show.rhtml:16
|
92
|
-
msgid "Edit"
|
93
|
-
msgstr "编辑"
|
94
|
-
|
95
83
|
#: app/views/blog/edit.rhtml:19
|
96
84
|
msgid "Show"
|
97
85
|
msgstr "显示"
|
@@ -103,3 +91,15 @@ msgstr "删除"
|
|
103
91
|
#: app/views/blog/edit.rhtml:20
|
104
92
|
msgid "Are you sure?"
|
105
93
|
msgstr "确认?"
|
94
|
+
|
95
|
+
#: app/views/blog/_form.rhtml:16
|
96
|
+
msgid "Lastupdate"
|
97
|
+
msgstr "上次更新"
|
98
|
+
|
99
|
+
#: app/views/blog/_form.rhtml:18
|
100
|
+
msgid "Title: Required."
|
101
|
+
msgstr "标题:需要设置"
|
102
|
+
|
103
|
+
#: app/views/blog/_form.rhtml:21
|
104
|
+
msgid "Description: More than 10 characters."
|
105
|
+
msgstr "描述:需要超过10个字符"
|
@@ -9,7 +9,7 @@
|
|
9
9
|
msgid ""
|
10
10
|
msgstr ""
|
11
11
|
"Project-Id-Version: blog 1.2.0\n"
|
12
|
-
"POT-Creation-Date:
|
12
|
+
"POT-Creation-Date: 2007-08-01 23:20+0900\n"
|
13
13
|
"PO-Revision-Date: 2006-08-15 09:38+0800\n"
|
14
14
|
"Last-Translator: LIN CHUNG-YI <xmarsh at gmail.com>\n"
|
15
15
|
"Language-Team: zh_TW <xmarsh at gmail.com>\n"
|
@@ -52,6 +52,20 @@ msgstr "文章已成功建立"
|
|
52
52
|
msgid "Article was successfully updated."
|
53
53
|
msgstr "文章已成功更新"
|
54
54
|
|
55
|
+
#: app/views/blog/show.rhtml:13 app/views/blog/list.rhtml:13
|
56
|
+
#: app/views/layouts/blog.rhtml:14
|
57
|
+
msgid "GetText Sample Blog on RoR"
|
58
|
+
msgstr "GetText 的 RoR 部落格範例"
|
59
|
+
|
60
|
+
#: app/views/blog/show.rhtml:16 app/views/blog/edit.rhtml:16
|
61
|
+
msgid "Edit"
|
62
|
+
msgstr "編輯"
|
63
|
+
|
64
|
+
#: app/views/blog/show.rhtml:17 app/views/blog/new.rhtml:20
|
65
|
+
#: app/views/blog/edit.rhtml:21
|
66
|
+
msgid "Back"
|
67
|
+
msgstr "返回"
|
68
|
+
|
55
69
|
#: app/views/blog/new.rhtml:13 app/views/blog/list.rhtml:15
|
56
70
|
msgid "New article"
|
57
71
|
msgstr "新文章"
|
@@ -60,28 +74,6 @@ msgstr "新文章"
|
|
60
74
|
msgid "Create"
|
61
75
|
msgstr "新增"
|
62
76
|
|
63
|
-
#: app/views/blog/new.rhtml:20 app/views/blog/edit.rhtml:21
|
64
|
-
#: app/views/blog/show.rhtml:17
|
65
|
-
msgid "Back"
|
66
|
-
msgstr "返回"
|
67
|
-
|
68
|
-
#: app/views/blog/_form.rhtml:16
|
69
|
-
msgid "Lastupdate"
|
70
|
-
msgstr "最近更新"
|
71
|
-
|
72
|
-
#: app/views/blog/_form.rhtml:18
|
73
|
-
msgid "Title: Required."
|
74
|
-
msgstr "標題需要填寫"
|
75
|
-
|
76
|
-
#: app/views/blog/_form.rhtml:21
|
77
|
-
msgid "Description: More than 10 characters."
|
78
|
-
msgstr "描述需多於十個字"
|
79
|
-
|
80
|
-
#: app/views/blog/list.rhtml:13 app/views/blog/show.rhtml:13
|
81
|
-
#: app/views/layouts/blog.rhtml:14
|
82
|
-
msgid "GetText Sample Blog on RoR"
|
83
|
-
msgstr "GetText 的 RoR 部落格範例"
|
84
|
-
|
85
77
|
#: app/views/blog/list.rhtml:18
|
86
78
|
msgid "No articles were found."
|
87
79
|
msgstr "找不到文章"
|
@@ -90,10 +82,6 @@ msgstr "找不到文章"
|
|
90
82
|
msgid "Editing article"
|
91
83
|
msgstr "編輯文章"
|
92
84
|
|
93
|
-
#: app/views/blog/edit.rhtml:16 app/views/blog/show.rhtml:16
|
94
|
-
msgid "Edit"
|
95
|
-
msgstr "編輯"
|
96
|
-
|
97
85
|
#: app/views/blog/edit.rhtml:19
|
98
86
|
msgid "Show"
|
99
87
|
msgstr "觀看"
|
@@ -105,3 +93,15 @@ msgstr "刪除"
|
|
105
93
|
#: app/views/blog/edit.rhtml:20
|
106
94
|
msgid "Are you sure?"
|
107
95
|
msgstr "你確定嗎?"
|
96
|
+
|
97
|
+
#: app/views/blog/_form.rhtml:16
|
98
|
+
msgid "Lastupdate"
|
99
|
+
msgstr "最近更新"
|
100
|
+
|
101
|
+
#: app/views/blog/_form.rhtml:18
|
102
|
+
msgid "Title: Required."
|
103
|
+
msgstr "標題需要填寫"
|
104
|
+
|
105
|
+
#: app/views/blog/_form.rhtml:21
|
106
|
+
msgid "Description: More than 10 characters."
|
107
|
+
msgstr "描述需多於十個字"
|
@@ -1,8 +1,30 @@
|
|
1
|
-
<!DOCTYPE
|
2
|
-
|
3
|
-
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
|
6
|
+
<head>
|
7
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
8
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
9
|
+
<style type="text/css">
|
10
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
11
|
+
div.dialog {
|
12
|
+
width: 25em;
|
13
|
+
padding: 0 4em;
|
14
|
+
margin: 4em auto 0 auto;
|
15
|
+
border: 1px solid #ccc;
|
16
|
+
border-right-color: #999;
|
17
|
+
border-bottom-color: #999;
|
18
|
+
}
|
19
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
20
|
+
</style>
|
21
|
+
</head>
|
22
|
+
|
4
23
|
<body>
|
5
|
-
|
6
|
-
<
|
24
|
+
<!-- This file lives in public/404.html -->
|
25
|
+
<div class="dialog">
|
26
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
27
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
28
|
+
</div>
|
7
29
|
</body>
|
8
30
|
</html>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
|
6
|
+
<head>
|
7
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
8
|
+
<title>The change you wanted was rejected (422)</title>
|
9
|
+
<style type="text/css">
|
10
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
11
|
+
div.dialog {
|
12
|
+
width: 25em;
|
13
|
+
padding: 0 4em;
|
14
|
+
margin: 4em auto 0 auto;
|
15
|
+
border: 1px solid #ccc;
|
16
|
+
border-right-color: #999;
|
17
|
+
border-bottom-color: #999;
|
18
|
+
}
|
19
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
20
|
+
</style>
|
21
|
+
</head>
|
22
|
+
|
23
|
+
<body>
|
24
|
+
<!-- This file lives in public/422.html -->
|
25
|
+
<div class="dialog">
|
26
|
+
<h1>The change you wanted was rejected.</h1>
|
27
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
28
|
+
</div>
|
29
|
+
</body>
|
30
|
+
</html>
|
@@ -1,8 +1,30 @@
|
|
1
|
-
<!DOCTYPE
|
2
|
-
|
3
|
-
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
|
6
|
+
<head>
|
7
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
8
|
+
<title>We're sorry, but something went wrong (500)</title>
|
9
|
+
<style type="text/css">
|
10
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
11
|
+
div.dialog {
|
12
|
+
width: 25em;
|
13
|
+
padding: 0 4em;
|
14
|
+
margin: 4em auto 0 auto;
|
15
|
+
border: 1px solid #ccc;
|
16
|
+
border-right-color: #999;
|
17
|
+
border-bottom-color: #999;
|
18
|
+
}
|
19
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
20
|
+
</style>
|
21
|
+
</head>
|
22
|
+
|
4
23
|
<body>
|
5
|
-
|
6
|
-
<
|
24
|
+
<!-- This file lives in public/500.html -->
|
25
|
+
<div class="dialog">
|
26
|
+
<h1>We're sorry, but something went wrong.</h1>
|
27
|
+
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
28
|
+
</div>
|
7
29
|
</body>
|
8
30
|
</html>
|
@@ -183,7 +183,7 @@
|
|
183
183
|
<script type="text/javascript">
|
184
184
|
function about() {
|
185
185
|
if (Element.empty('about-content')) {
|
186
|
-
new Ajax.Updater('about-content', '
|
186
|
+
new Ajax.Updater('about-content', 'rails/info/properties', {
|
187
187
|
method: 'get',
|
188
188
|
onFailure: function() {Element.classNames('about-content').add('failure')},
|
189
189
|
onComplete: function() {new Effect.BlindDown('about-content', {duration: 0.25})}
|
@@ -230,8 +230,8 @@
|
|
230
230
|
<h3>Browse the documentation</h3>
|
231
231
|
<ul class="links">
|
232
232
|
<li><a href="http://api.rubyonrails.org/">Rails API</a></li>
|
233
|
-
<li><a href="http://
|
234
|
-
<li><a href="http://
|
233
|
+
<li><a href="http://stdlib.rubyonrails.org/">Ruby standard library</a></li>
|
234
|
+
<li><a href="http://corelib.rubyonrails.org/">Ruby core</a></li>
|
235
235
|
</ul>
|
236
236
|
</li>
|
237
237
|
</ul>
|
@@ -240,11 +240,11 @@
|
|
240
240
|
<div id="content">
|
241
241
|
<div id="header">
|
242
242
|
<h1>Welcome aboard</h1>
|
243
|
-
<h2>You’re riding
|
243
|
+
<h2>You’re riding Ruby on Rails!</h2>
|
244
244
|
</div>
|
245
245
|
|
246
246
|
<div id="about">
|
247
|
-
<h3><a href="
|
247
|
+
<h3><a href="rails/info/properties" onclick="about(); return false">About your application’s environment</a></h3>
|
248
248
|
<div id="about-content" style="display: none"></div>
|
249
249
|
</div>
|
250
250
|
|
@@ -265,7 +265,7 @@
|
|
265
265
|
|
266
266
|
<li>
|
267
267
|
<h2>Set up a default route and remove or rename this file</h2>
|
268
|
-
<p>Routes are
|
268
|
+
<p>Routes are set up in config/routes.rb.</p>
|
269
269
|
</li>
|
270
270
|
</ol>
|
271
271
|
</div>
|
@@ -1,12 +1,13 @@
|
|
1
|
-
// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
2
|
-
// (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
|
3
|
-
// (c) 2005 Jon Tirsen (http://www.tirsen.com)
|
1
|
+
// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
2
|
+
// (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
|
3
|
+
// (c) 2005-2007 Jon Tirsen (http://www.tirsen.com)
|
4
4
|
// Contributors:
|
5
5
|
// Richard Livsey
|
6
6
|
// Rahul Bhargava
|
7
7
|
// Rob Wills
|
8
8
|
//
|
9
|
-
//
|
9
|
+
// script.aculo.us is freely distributable under the terms of an MIT-style license.
|
10
|
+
// For details, see the script.aculo.us web site: http://script.aculo.us/
|
10
11
|
|
11
12
|
// Autocompleter.Base handles all the autocompletion functionality
|
12
13
|
// that's independent of the data source for autocompletion. This
|
@@ -33,40 +34,50 @@
|
|
33
34
|
// useful when one of the tokens is \n (a newline), as it
|
34
35
|
// allows smart autocompletion after linebreaks.
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
if(typeof Effect == 'undefined')
|
38
|
+
throw("controls.js requires including script.aculo.us' effects.js library");
|
39
|
+
|
40
|
+
var Autocompleter = { }
|
41
|
+
Autocompleter.Base = Class.create({
|
39
42
|
baseInitialize: function(element, update, options) {
|
40
|
-
|
43
|
+
element = $(element)
|
44
|
+
this.element = element;
|
41
45
|
this.update = $(update);
|
42
46
|
this.hasFocus = false;
|
43
47
|
this.changed = false;
|
44
48
|
this.active = false;
|
45
49
|
this.index = 0;
|
46
50
|
this.entryCount = 0;
|
51
|
+
this.oldElementValue = this.element.value;
|
47
52
|
|
48
|
-
if
|
53
|
+
if(this.setOptions)
|
49
54
|
this.setOptions(options);
|
50
55
|
else
|
51
|
-
this.options = options || {};
|
56
|
+
this.options = options || { };
|
52
57
|
|
53
58
|
this.options.paramName = this.options.paramName || this.element.name;
|
54
59
|
this.options.tokens = this.options.tokens || [];
|
55
60
|
this.options.frequency = this.options.frequency || 0.4;
|
56
61
|
this.options.minChars = this.options.minChars || 1;
|
57
62
|
this.options.onShow = this.options.onShow ||
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
63
|
+
function(element, update){
|
64
|
+
if(!update.style.position || update.style.position=='absolute') {
|
65
|
+
update.style.position = 'absolute';
|
66
|
+
Position.clone(element, update, {
|
67
|
+
setHeight: false,
|
68
|
+
offsetTop: element.offsetHeight
|
69
|
+
});
|
70
|
+
}
|
71
|
+
Effect.Appear(update,{duration:0.15});
|
72
|
+
};
|
65
73
|
this.options.onHide = this.options.onHide ||
|
66
|
-
|
74
|
+
function(element, update){ new Effect.Fade(update,{duration:0.15}) };
|
67
75
|
|
68
|
-
if
|
76
|
+
if(typeof(this.options.tokens) == 'string')
|
69
77
|
this.options.tokens = new Array(this.options.tokens);
|
78
|
+
// Force carriage returns as token delimiters anyway
|
79
|
+
if (!this.options.tokens.include('\n'))
|
80
|
+
this.options.tokens.push('\n');
|
70
81
|
|
71
82
|
this.observer = null;
|
72
83
|
|
@@ -74,15 +85,14 @@ Autocompleter.Base.prototype = {
|
|
74
85
|
|
75
86
|
Element.hide(this.update);
|
76
87
|
|
77
|
-
Event.observe(this.element,
|
78
|
-
Event.observe(this.element,
|
88
|
+
Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this));
|
89
|
+
Event.observe(this.element, 'keydown', this.onKeyPress.bindAsEventListener(this));
|
79
90
|
},
|
80
91
|
|
81
92
|
show: function() {
|
82
93
|
if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update);
|
83
94
|
if(!this.iefix &&
|
84
|
-
(
|
85
|
-
(navigator.userAgent.indexOf('Opera')<0) &&
|
95
|
+
(Prototype.Browser.IE) &&
|
86
96
|
(Element.getStyle(this.update, 'position')=='absolute')) {
|
87
97
|
new Insertion.After(this.update,
|
88
98
|
'<iframe id="' + this.update.id + '_iefix" '+
|
@@ -94,7 +104,7 @@ Autocompleter.Base.prototype = {
|
|
94
104
|
},
|
95
105
|
|
96
106
|
fixIEOverlapping: function() {
|
97
|
-
Position.clone(this.update, this.iefix);
|
107
|
+
Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)});
|
98
108
|
this.iefix.style.zIndex = 1;
|
99
109
|
this.update.style.zIndex = 2;
|
100
110
|
Element.show(this.iefix);
|
@@ -132,17 +142,17 @@ Autocompleter.Base.prototype = {
|
|
132
142
|
case Event.KEY_UP:
|
133
143
|
this.markPrevious();
|
134
144
|
this.render();
|
135
|
-
|
145
|
+
Event.stop(event);
|
136
146
|
return;
|
137
147
|
case Event.KEY_DOWN:
|
138
148
|
this.markNext();
|
139
149
|
this.render();
|
140
|
-
|
150
|
+
Event.stop(event);
|
141
151
|
return;
|
142
152
|
}
|
143
153
|
else
|
144
|
-
|
145
|
-
|
154
|
+
if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN ||
|
155
|
+
(Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return;
|
146
156
|
|
147
157
|
this.changed = true;
|
148
158
|
this.hasFocus = true;
|
@@ -152,6 +162,12 @@ Autocompleter.Base.prototype = {
|
|
152
162
|
setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000);
|
153
163
|
},
|
154
164
|
|
165
|
+
activate: function() {
|
166
|
+
this.changed = false;
|
167
|
+
this.hasFocus = true;
|
168
|
+
this.getUpdatedChoices();
|
169
|
+
},
|
170
|
+
|
155
171
|
onHover: function(event) {
|
156
172
|
var element = Event.findElement(event, 'LI');
|
157
173
|
if(this.index != element.autocompleteIndex)
|
@@ -182,7 +198,6 @@ Autocompleter.Base.prototype = {
|
|
182
198
|
this.index==i ?
|
183
199
|
Element.addClassName(this.getEntry(i),"selected") :
|
184
200
|
Element.removeClassName(this.getEntry(i),"selected");
|
185
|
-
|
186
201
|
if(this.hasFocus) {
|
187
202
|
this.show();
|
188
203
|
this.active = true;
|
@@ -196,11 +211,13 @@ Autocompleter.Base.prototype = {
|
|
196
211
|
markPrevious: function() {
|
197
212
|
if(this.index > 0) this.index--
|
198
213
|
else this.index = this.entryCount-1;
|
214
|
+
this.getEntry(this.index).scrollIntoView(true);
|
199
215
|
},
|
200
216
|
|
201
217
|
markNext: function() {
|
202
218
|
if(this.index < this.entryCount-1) this.index++
|
203
219
|
else this.index = 0;
|
220
|
+
this.getEntry(this.index).scrollIntoView(false);
|
204
221
|
},
|
205
222
|
|
206
223
|
getEntry: function(index) {
|
@@ -221,18 +238,24 @@ Autocompleter.Base.prototype = {
|
|
221
238
|
this.options.updateElement(selectedElement);
|
222
239
|
return;
|
223
240
|
}
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
241
|
+
var value = '';
|
242
|
+
if (this.options.select) {
|
243
|
+
var nodes = $(selectedElement).select('.' + this.options.select) || [];
|
244
|
+
if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select);
|
245
|
+
} else
|
246
|
+
value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal');
|
247
|
+
|
248
|
+
var bounds = this.getTokenBounds();
|
249
|
+
if (bounds[0] != -1) {
|
250
|
+
var newValue = this.element.value.substr(0, bounds[0]);
|
251
|
+
var whitespace = this.element.value.substr(bounds[0]).match(/^\s+/);
|
230
252
|
if (whitespace)
|
231
253
|
newValue += whitespace[0];
|
232
|
-
this.element.value = newValue + value;
|
254
|
+
this.element.value = newValue + value + this.element.value.substr(bounds[1]);
|
233
255
|
} else {
|
234
256
|
this.element.value = value;
|
235
257
|
}
|
258
|
+
this.oldElementValue = this.element.value;
|
236
259
|
this.element.focus();
|
237
260
|
|
238
261
|
if (this.options.afterUpdateElement)
|
@@ -243,11 +266,11 @@ Autocompleter.Base.prototype = {
|
|
243
266
|
if(!this.changed && this.hasFocus) {
|
244
267
|
this.update.innerHTML = choices;
|
245
268
|
Element.cleanWhitespace(this.update);
|
246
|
-
Element.cleanWhitespace(this.update.
|
269
|
+
Element.cleanWhitespace(this.update.down());
|
247
270
|
|
248
|
-
if(this.update.firstChild && this.update.
|
271
|
+
if(this.update.firstChild && this.update.down().childNodes) {
|
249
272
|
this.entryCount =
|
250
|
-
this.update.
|
273
|
+
this.update.down().childNodes.length;
|
251
274
|
for (var i = 0; i < this.entryCount; i++) {
|
252
275
|
var entry = this.getEntry(i);
|
253
276
|
entry.autocompleteIndex = i;
|
@@ -258,9 +281,14 @@ Autocompleter.Base.prototype = {
|
|
258
281
|
}
|
259
282
|
|
260
283
|
this.stopIndicator();
|
261
|
-
|
262
284
|
this.index = 0;
|
263
|
-
|
285
|
+
|
286
|
+
if(this.entryCount==1 && this.options.autoSelect) {
|
287
|
+
this.selectEntry();
|
288
|
+
this.hide();
|
289
|
+
} else {
|
290
|
+
this.render();
|
291
|
+
}
|
264
292
|
}
|
265
293
|
},
|
266
294
|
|
@@ -271,41 +299,50 @@ Autocompleter.Base.prototype = {
|
|
271
299
|
|
272
300
|
onObserverEvent: function() {
|
273
301
|
this.changed = false;
|
302
|
+
this.tokenBounds = null;
|
274
303
|
if(this.getToken().length>=this.options.minChars) {
|
275
|
-
this.startIndicator();
|
276
304
|
this.getUpdatedChoices();
|
277
305
|
} else {
|
278
306
|
this.active = false;
|
279
307
|
this.hide();
|
280
308
|
}
|
309
|
+
this.oldElementValue = this.element.value;
|
281
310
|
},
|
282
311
|
|
283
312
|
getToken: function() {
|
284
|
-
var
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
var
|
295
|
-
|
296
|
-
for (var
|
297
|
-
|
298
|
-
if (
|
299
|
-
|
313
|
+
var bounds = this.getTokenBounds();
|
314
|
+
return this.element.value.substring(bounds[0], bounds[1]).strip();
|
315
|
+
},
|
316
|
+
|
317
|
+
getTokenBounds: function() {
|
318
|
+
if (null != this.tokenBounds) return this.tokenBounds;
|
319
|
+
var value = this.element.value;
|
320
|
+
if (value.strip().empty()) return [-1, 0];
|
321
|
+
var diff = arguments.callee.getFirstDifferencePos(value, this.oldElementValue);
|
322
|
+
var offset = (diff == this.oldElementValue.length ? 1 : 0);
|
323
|
+
var prevTokenPos = -1, nextTokenPos = value.length;
|
324
|
+
var tp;
|
325
|
+
for (var index = 0, l = this.options.tokens.length; index < l; ++index) {
|
326
|
+
tp = value.lastIndexOf(this.options.tokens[index], diff + offset - 1);
|
327
|
+
if (tp > prevTokenPos) prevTokenPos = tp;
|
328
|
+
tp = value.indexOf(this.options.tokens[index], diff + offset);
|
329
|
+
if (-1 != tp && tp < nextTokenPos) nextTokenPos = tp;
|
300
330
|
}
|
301
|
-
return
|
331
|
+
return (this.tokenBounds = [prevTokenPos + 1, nextTokenPos]);
|
302
332
|
}
|
303
|
-
}
|
333
|
+
});
|
334
|
+
|
335
|
+
Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos = function(newS, oldS) {
|
336
|
+
var boundary = Math.min(newS.length, oldS.length);
|
337
|
+
for (var index = 0; index < boundary; ++index)
|
338
|
+
if (newS[index] != oldS[index])
|
339
|
+
return index;
|
340
|
+
return boundary;
|
341
|
+
};
|
304
342
|
|
305
|
-
Ajax.Autocompleter = Class.create(
|
306
|
-
Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), {
|
343
|
+
Ajax.Autocompleter = Class.create(Autocompleter.Base, {
|
307
344
|
initialize: function(element, update, url, options) {
|
308
|
-
|
345
|
+
this.baseInitialize(element, update, options);
|
309
346
|
this.options.asynchronous = true;
|
310
347
|
this.options.onComplete = this.onComplete.bind(this);
|
311
348
|
this.options.defaultParams = this.options.parameters || null;
|
@@ -313,7 +350,9 @@ Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.pro
|
|
313
350
|
},
|
314
351
|
|
315
352
|
getUpdatedChoices: function() {
|
316
|
-
|
353
|
+
this.startIndicator();
|
354
|
+
|
355
|
+
var entry = encodeURIComponent(this.options.paramName) + '=' +
|
317
356
|
encodeURIComponent(this.getToken());
|
318
357
|
|
319
358
|
this.options.parameters = this.options.callback ?
|
@@ -321,14 +360,13 @@ Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.pro
|
|
321
360
|
|
322
361
|
if(this.options.defaultParams)
|
323
362
|
this.options.parameters += '&' + this.options.defaultParams;
|
324
|
-
|
363
|
+
|
325
364
|
new Ajax.Request(this.url, this.options);
|
326
365
|
},
|
327
366
|
|
328
367
|
onComplete: function(request) {
|
329
368
|
this.updateChoices(request.responseText);
|
330
369
|
}
|
331
|
-
|
332
370
|
});
|
333
371
|
|
334
372
|
// The local array autocompleter. Used when you'd prefer to
|
@@ -366,8 +404,7 @@ Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.pro
|
|
366
404
|
// In that case, the other options above will not apply unless
|
367
405
|
// you support them.
|
368
406
|
|
369
|
-
Autocompleter.Local = Class.create(
|
370
|
-
Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base(), {
|
407
|
+
Autocompleter.Local = Class.create(Autocompleter.Base, {
|
371
408
|
initialize: function(element, update, array, options) {
|
372
409
|
this.baseInitialize(element, update, options);
|
373
410
|
this.options.array = array;
|
@@ -423,13 +460,12 @@ Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base(), {
|
|
423
460
|
ret = ret.concat(partial.slice(0, instance.options.choices - ret.length))
|
424
461
|
return "<ul>" + ret.join('') + "</ul>";
|
425
462
|
}
|
426
|
-
}, options || {});
|
463
|
+
}, options || { });
|
427
464
|
}
|
428
465
|
});
|
429
466
|
|
430
|
-
// AJAX in-place editor
|
431
|
-
//
|
432
|
-
// see documentation on http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor
|
467
|
+
// AJAX in-place editor and collection editor
|
468
|
+
// Full rewrite by Christophe Porteneuve <tdd@tddsworld.com> (April 2007).
|
433
469
|
|
434
470
|
// Use this if you notice weird scrolling problems on some browsers,
|
435
471
|
// the DOM might be a bit confused when this gets called so do this
|
@@ -440,295 +476,472 @@ Field.scrollFreeActivate = function(field) {
|
|
440
476
|
}, 1);
|
441
477
|
}
|
442
478
|
|
443
|
-
Ajax.InPlaceEditor = Class.create(
|
444
|
-
Ajax.InPlaceEditor.defaultHighlightColor = "#FFFF99";
|
445
|
-
Ajax.InPlaceEditor.prototype = {
|
479
|
+
Ajax.InPlaceEditor = Class.create({
|
446
480
|
initialize: function(element, url, options) {
|
447
481
|
this.url = url;
|
448
|
-
this.element = $(element);
|
449
|
-
|
450
|
-
this.
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
onComplete: function(transport, element) {
|
458
|
-
new Effect.Highlight(element, {startcolor: this.options.highlightcolor});
|
459
|
-
},
|
460
|
-
onFailure: function(transport) {
|
461
|
-
alert("Error communicating with the server: " + transport.responseText.stripTags());
|
462
|
-
},
|
463
|
-
callback: function(form) {
|
464
|
-
return Form.serialize(form);
|
465
|
-
},
|
466
|
-
handleLineBreaks: true,
|
467
|
-
loadingText: 'Loading...',
|
468
|
-
savingClassName: 'inplaceeditor-saving',
|
469
|
-
loadingClassName: 'inplaceeditor-loading',
|
470
|
-
formClassName: 'inplaceeditor-form',
|
471
|
-
highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor,
|
472
|
-
highlightendcolor: "#FFFFFF",
|
473
|
-
externalControl: null,
|
474
|
-
ajaxOptions: {}
|
475
|
-
}, options || {});
|
476
|
-
|
477
|
-
if(!this.options.formId && this.element.id) {
|
478
|
-
this.options.formId = this.element.id + "-inplaceeditor";
|
479
|
-
if ($(this.options.formId)) {
|
480
|
-
// there's already a form with that name, don't specify an id
|
481
|
-
this.options.formId = null;
|
482
|
-
}
|
482
|
+
this.element = element = $(element);
|
483
|
+
this.prepareOptions();
|
484
|
+
this._controls = { };
|
485
|
+
arguments.callee.dealWithDeprecatedOptions(options); // DEPRECATION LAYER!!!
|
486
|
+
Object.extend(this.options, options || { });
|
487
|
+
if (!this.options.formId && this.element.id) {
|
488
|
+
this.options.formId = this.element.id + '-inplaceeditor';
|
489
|
+
if ($(this.options.formId))
|
490
|
+
this.options.formId = '';
|
483
491
|
}
|
484
|
-
|
485
|
-
if (this.options.externalControl) {
|
492
|
+
if (this.options.externalControl)
|
486
493
|
this.options.externalControl = $(this.options.externalControl);
|
487
|
-
|
488
|
-
|
489
|
-
this.
|
490
|
-
if (!this.originalBackground) {
|
491
|
-
this.originalBackground = "transparent";
|
492
|
-
}
|
493
|
-
|
494
|
+
if (!this.options.externalControl)
|
495
|
+
this.options.externalControlOnly = false;
|
496
|
+
this._originalBackground = this.element.getStyle('background-color') || 'transparent';
|
494
497
|
this.element.title = this.options.clickToEditText;
|
495
|
-
|
496
|
-
this.
|
497
|
-
this.
|
498
|
-
this.
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
498
|
+
this._boundCancelHandler = this.handleFormCancellation.bind(this);
|
499
|
+
this._boundComplete = (this.options.onComplete || Prototype.emptyFunction).bind(this);
|
500
|
+
this._boundFailureHandler = this.handleAJAXFailure.bind(this);
|
501
|
+
this._boundSubmitHandler = this.handleFormSubmission.bind(this);
|
502
|
+
this._boundWrapperHandler = this.wrapUp.bind(this);
|
503
|
+
this.registerListeners();
|
504
|
+
},
|
505
|
+
checkForEscapeOrReturn: function(e) {
|
506
|
+
if (!this._editing || e.ctrlKey || e.altKey || e.shiftKey) return;
|
507
|
+
if (Event.KEY_ESC == e.keyCode)
|
508
|
+
this.handleFormCancellation(e);
|
509
|
+
else if (Event.KEY_RETURN == e.keyCode)
|
510
|
+
this.handleFormSubmission(e);
|
511
|
+
},
|
512
|
+
createControl: function(mode, handler, extraClasses) {
|
513
|
+
var control = this.options[mode + 'Control'];
|
514
|
+
var text = this.options[mode + 'Text'];
|
515
|
+
if ('button' == control) {
|
516
|
+
var btn = document.createElement('input');
|
517
|
+
btn.type = 'submit';
|
518
|
+
btn.value = text;
|
519
|
+
btn.className = 'editor_' + mode + '_button';
|
520
|
+
if ('cancel' == mode)
|
521
|
+
btn.onclick = this._boundCancelHandler;
|
522
|
+
this._form.appendChild(btn);
|
523
|
+
this._controls[mode] = btn;
|
524
|
+
} else if ('link' == control) {
|
525
|
+
var link = document.createElement('a');
|
526
|
+
link.href = '#';
|
527
|
+
link.appendChild(document.createTextNode(text));
|
528
|
+
link.onclick = 'cancel' == mode ? this._boundCancelHandler : this._boundSubmitHandler;
|
529
|
+
link.className = 'editor_' + mode + '_link';
|
530
|
+
if (extraClasses)
|
531
|
+
link.className += ' ' + extraClasses;
|
532
|
+
this._form.appendChild(link);
|
533
|
+
this._controls[mode] = link;
|
506
534
|
}
|
507
535
|
},
|
508
|
-
enterEditMode: function(evt) {
|
509
|
-
if (this.saving) return;
|
510
|
-
if (this.editing) return;
|
511
|
-
this.editing = true;
|
512
|
-
this.onEnterEditMode();
|
513
|
-
if (this.options.externalControl) {
|
514
|
-
Element.hide(this.options.externalControl);
|
515
|
-
}
|
516
|
-
Element.hide(this.element);
|
517
|
-
this.createForm();
|
518
|
-
this.element.parentNode.insertBefore(this.form, this.element);
|
519
|
-
Field.scrollFreeActivate(this.editField);
|
520
|
-
// stop the event to avoid a page refresh in Safari
|
521
|
-
if (evt) {
|
522
|
-
Event.stop(evt);
|
523
|
-
}
|
524
|
-
return false;
|
525
|
-
},
|
526
|
-
createForm: function() {
|
527
|
-
this.form = document.createElement("form");
|
528
|
-
this.form.id = this.options.formId;
|
529
|
-
Element.addClassName(this.form, this.options.formClassName)
|
530
|
-
this.form.onsubmit = this.onSubmit.bind(this);
|
531
|
-
|
532
|
-
this.createEditField();
|
533
|
-
|
534
|
-
if (this.options.textarea) {
|
535
|
-
var br = document.createElement("br");
|
536
|
-
this.form.appendChild(br);
|
537
|
-
}
|
538
|
-
|
539
|
-
okButton = document.createElement("input");
|
540
|
-
okButton.type = "submit";
|
541
|
-
okButton.value = this.options.okText;
|
542
|
-
this.form.appendChild(okButton);
|
543
|
-
|
544
|
-
cancelLink = document.createElement("a");
|
545
|
-
cancelLink.href = "#";
|
546
|
-
cancelLink.appendChild(document.createTextNode(this.options.cancelText));
|
547
|
-
cancelLink.onclick = this.onclickCancel.bind(this);
|
548
|
-
this.form.appendChild(cancelLink);
|
549
|
-
},
|
550
|
-
hasHTMLLineBreaks: function(string) {
|
551
|
-
if (!this.options.handleLineBreaks) return false;
|
552
|
-
return string.match(/<br/i) || string.match(/<p>/i);
|
553
|
-
},
|
554
|
-
convertHTMLLineBreaks: function(string) {
|
555
|
-
return string.replace(/<br>/gi, "\n").replace(/<br\/>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<p>/gi, "");
|
556
|
-
},
|
557
536
|
createEditField: function() {
|
558
|
-
var text;
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
}
|
564
|
-
|
565
|
-
if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) {
|
566
|
-
this.options.textarea = false;
|
567
|
-
var textField = document.createElement("input");
|
568
|
-
textField.type = "text";
|
569
|
-
textField.name = "value";
|
570
|
-
textField.value = text;
|
571
|
-
textField.style.backgroundColor = this.options.highlightcolor;
|
537
|
+
var text = (this.options.loadTextURL ? this.options.loadingText : this.getText());
|
538
|
+
var fld;
|
539
|
+
if (1 >= this.options.rows && !/\r|\n/.test(this.getText())) {
|
540
|
+
fld = document.createElement('input');
|
541
|
+
fld.type = 'text';
|
572
542
|
var size = this.options.size || this.options.cols || 0;
|
573
|
-
if (
|
574
|
-
this.editField = textField;
|
543
|
+
if (0 < size) fld.size = size;
|
575
544
|
} else {
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
textArea.value = this.convertHTMLLineBreaks(text);
|
580
|
-
textArea.rows = this.options.rows;
|
581
|
-
textArea.cols = this.options.cols || 40;
|
582
|
-
this.editField = textArea;
|
545
|
+
fld = document.createElement('textarea');
|
546
|
+
fld.rows = (1 >= this.options.rows ? this.options.autoRows : this.options.rows);
|
547
|
+
fld.cols = this.options.cols || 40;
|
583
548
|
}
|
584
|
-
|
585
|
-
|
549
|
+
fld.name = this.options.paramName;
|
550
|
+
fld.value = text; // No HTML breaks conversion anymore
|
551
|
+
fld.className = 'editor_field';
|
552
|
+
if (this.options.submitOnBlur)
|
553
|
+
fld.onblur = this._boundSubmitHandler;
|
554
|
+
this._controls.editor = fld;
|
555
|
+
if (this.options.loadTextURL)
|
586
556
|
this.loadExternalText();
|
587
|
-
|
588
|
-
|
557
|
+
this._form.appendChild(this._controls.editor);
|
558
|
+
},
|
559
|
+
createForm: function() {
|
560
|
+
var ipe = this;
|
561
|
+
function addText(mode, condition) {
|
562
|
+
var text = ipe.options['text' + mode + 'Controls'];
|
563
|
+
if (!text || condition === false) return;
|
564
|
+
ipe._form.appendChild(document.createTextNode(text));
|
565
|
+
};
|
566
|
+
this._form = $(document.createElement('form'));
|
567
|
+
this._form.id = this.options.formId;
|
568
|
+
this._form.addClassName(this.options.formClassName);
|
569
|
+
this._form.onsubmit = this._boundSubmitHandler;
|
570
|
+
this.createEditField();
|
571
|
+
if ('textarea' == this._controls.editor.tagName.toLowerCase())
|
572
|
+
this._form.appendChild(document.createElement('br'));
|
573
|
+
if (this.options.onFormCustomization)
|
574
|
+
this.options.onFormCustomization(this, this._form);
|
575
|
+
addText('Before', this.options.okControl || this.options.cancelControl);
|
576
|
+
this.createControl('ok', this._boundSubmitHandler);
|
577
|
+
addText('Between', this.options.okControl && this.options.cancelControl);
|
578
|
+
this.createControl('cancel', this._boundCancelHandler, 'editor_cancel');
|
579
|
+
addText('After', this.options.okControl || this.options.cancelControl);
|
580
|
+
},
|
581
|
+
destroy: function() {
|
582
|
+
if (this._oldInnerHTML)
|
583
|
+
this.element.innerHTML = this._oldInnerHTML;
|
584
|
+
this.leaveEditMode();
|
585
|
+
this.unregisterListeners();
|
586
|
+
},
|
587
|
+
enterEditMode: function(e) {
|
588
|
+
if (this._saving || this._editing) return;
|
589
|
+
this._editing = true;
|
590
|
+
this.triggerCallback('onEnterEditMode');
|
591
|
+
if (this.options.externalControl)
|
592
|
+
this.options.externalControl.hide();
|
593
|
+
this.element.hide();
|
594
|
+
this.createForm();
|
595
|
+
this.element.parentNode.insertBefore(this._form, this.element);
|
596
|
+
if (!this.options.loadTextURL)
|
597
|
+
this.postProcessEditField();
|
598
|
+
if (e) Event.stop(e);
|
599
|
+
},
|
600
|
+
enterHover: function(e) {
|
601
|
+
if (this.options.hoverClassName)
|
602
|
+
this.element.addClassName(this.options.hoverClassName);
|
603
|
+
if (this._saving) return;
|
604
|
+
this.triggerCallback('onEnterHover');
|
589
605
|
},
|
590
606
|
getText: function() {
|
591
607
|
return this.element.innerHTML;
|
592
608
|
},
|
593
|
-
|
594
|
-
|
595
|
-
this.
|
596
|
-
|
597
|
-
this.
|
598
|
-
Object.extend({
|
599
|
-
asynchronous: true,
|
600
|
-
onComplete: this.onLoadedExternalText.bind(this)
|
601
|
-
}, this.options.ajaxOptions)
|
602
|
-
);
|
603
|
-
},
|
604
|
-
onLoadedExternalText: function(transport) {
|
605
|
-
Element.removeClassName(this.form, this.options.loadingClassName);
|
606
|
-
this.editField.disabled = false;
|
607
|
-
this.editField.value = transport.responseText.stripTags();
|
608
|
-
},
|
609
|
-
onclickCancel: function() {
|
610
|
-
this.onComplete();
|
611
|
-
this.leaveEditMode();
|
612
|
-
return false;
|
613
|
-
},
|
614
|
-
onFailure: function(transport) {
|
615
|
-
this.options.onFailure(transport);
|
616
|
-
if (this.oldInnerHTML) {
|
617
|
-
this.element.innerHTML = this.oldInnerHTML;
|
618
|
-
this.oldInnerHTML = null;
|
609
|
+
handleAJAXFailure: function(transport) {
|
610
|
+
this.triggerCallback('onFailure', transport);
|
611
|
+
if (this._oldInnerHTML) {
|
612
|
+
this.element.innerHTML = this._oldInnerHTML;
|
613
|
+
this._oldInnerHTML = null;
|
619
614
|
}
|
620
|
-
return false;
|
621
615
|
},
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
this.
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
}, this.options.ajaxOptions)
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
616
|
+
handleFormCancellation: function(e) {
|
617
|
+
this.wrapUp();
|
618
|
+
if (e) Event.stop(e);
|
619
|
+
},
|
620
|
+
handleFormSubmission: function(e) {
|
621
|
+
var form = this._form;
|
622
|
+
var value = $F(this._controls.editor);
|
623
|
+
this.prepareSubmission();
|
624
|
+
var params = this.options.callback(form, value) || '';
|
625
|
+
if (Object.isString(params))
|
626
|
+
params = params.toQueryParams();
|
627
|
+
params.editorId = this.element.id;
|
628
|
+
if (this.options.htmlResponse) {
|
629
|
+
var options = Object.extend({ evalScripts: true }, this.options.ajaxOptions);
|
630
|
+
Object.extend(options, {
|
631
|
+
parameters: params,
|
632
|
+
onComplete: this._boundWrapperHandler,
|
633
|
+
onFailure: this._boundFailureHandler
|
634
|
+
});
|
635
|
+
new Ajax.Updater({ success: this.element }, this.url, options);
|
636
|
+
} else {
|
637
|
+
var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
|
638
|
+
Object.extend(options, {
|
639
|
+
parameters: params,
|
640
|
+
onComplete: this._boundWrapperHandler,
|
641
|
+
onFailure: this._boundFailureHandler
|
642
|
+
});
|
643
|
+
new Ajax.Request(this.url, options);
|
648
644
|
}
|
649
|
-
|
645
|
+
if (e) Event.stop(e);
|
650
646
|
},
|
651
|
-
|
652
|
-
this.
|
647
|
+
leaveEditMode: function() {
|
648
|
+
this.element.removeClassName(this.options.savingClassName);
|
649
|
+
this.removeForm();
|
650
|
+
this.leaveHover();
|
651
|
+
this.element.style.backgroundColor = this._originalBackground;
|
652
|
+
this.element.show();
|
653
|
+
if (this.options.externalControl)
|
654
|
+
this.options.externalControl.show();
|
655
|
+
this._saving = false;
|
656
|
+
this._editing = false;
|
657
|
+
this._oldInnerHTML = null;
|
658
|
+
this.triggerCallback('onLeaveEditMode');
|
659
|
+
},
|
660
|
+
leaveHover: function(e) {
|
661
|
+
if (this.options.hoverClassName)
|
662
|
+
this.element.removeClassName(this.options.hoverClassName);
|
663
|
+
if (this._saving) return;
|
664
|
+
this.triggerCallback('onLeaveHover');
|
665
|
+
},
|
666
|
+
loadExternalText: function() {
|
667
|
+
this._form.addClassName(this.options.loadingClassName);
|
668
|
+
this._controls.editor.disabled = true;
|
669
|
+
var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
|
670
|
+
Object.extend(options, {
|
671
|
+
parameters: 'editorId=' + encodeURIComponent(this.element.id),
|
672
|
+
onComplete: Prototype.emptyFunction,
|
673
|
+
onSuccess: function(transport) {
|
674
|
+
this._form.removeClassName(this.options.loadingClassName);
|
675
|
+
var text = transport.responseText;
|
676
|
+
if (this.options.stripLoadedTextTags)
|
677
|
+
text = text.stripTags();
|
678
|
+
this._controls.editor.value = text;
|
679
|
+
this._controls.editor.disabled = false;
|
680
|
+
this.postProcessEditField();
|
681
|
+
}.bind(this),
|
682
|
+
onFailure: this._boundFailureHandler
|
683
|
+
});
|
684
|
+
new Ajax.Request(this.options.loadTextURL, options);
|
685
|
+
},
|
686
|
+
postProcessEditField: function() {
|
687
|
+
var fpc = this.options.fieldPostCreation;
|
688
|
+
if (fpc)
|
689
|
+
$(this._controls.editor)['focus' == fpc ? 'focus' : 'activate']();
|
690
|
+
},
|
691
|
+
prepareOptions: function() {
|
692
|
+
this.options = Object.clone(Ajax.InPlaceEditor.DefaultOptions);
|
693
|
+
Object.extend(this.options, Ajax.InPlaceEditor.DefaultCallbacks);
|
694
|
+
[this._extraDefaultOptions].flatten().compact().each(function(defs) {
|
695
|
+
Object.extend(this.options, defs);
|
696
|
+
}.bind(this));
|
697
|
+
},
|
698
|
+
prepareSubmission: function() {
|
699
|
+
this._saving = true;
|
653
700
|
this.removeForm();
|
654
701
|
this.leaveHover();
|
655
702
|
this.showSaving();
|
656
703
|
},
|
704
|
+
registerListeners: function() {
|
705
|
+
this._listeners = { };
|
706
|
+
var listener;
|
707
|
+
$H(Ajax.InPlaceEditor.Listeners).each(function(pair) {
|
708
|
+
listener = this[pair.value].bind(this);
|
709
|
+
this._listeners[pair.key] = listener;
|
710
|
+
if (!this.options.externalControlOnly)
|
711
|
+
this.element.observe(pair.key, listener);
|
712
|
+
if (this.options.externalControl)
|
713
|
+
this.options.externalControl.observe(pair.key, listener);
|
714
|
+
}.bind(this));
|
715
|
+
},
|
716
|
+
removeForm: function() {
|
717
|
+
if (!this._form) return;
|
718
|
+
this._form.remove();
|
719
|
+
this._form = null;
|
720
|
+
this._controls = { };
|
721
|
+
},
|
657
722
|
showSaving: function() {
|
658
|
-
this.
|
723
|
+
this._oldInnerHTML = this.element.innerHTML;
|
659
724
|
this.element.innerHTML = this.options.savingText;
|
660
|
-
|
661
|
-
this.element.style.backgroundColor = this.
|
662
|
-
|
725
|
+
this.element.addClassName(this.options.savingClassName);
|
726
|
+
this.element.style.backgroundColor = this._originalBackground;
|
727
|
+
this.element.show();
|
663
728
|
},
|
664
|
-
|
665
|
-
if(this.
|
666
|
-
|
667
|
-
this.form = null;
|
729
|
+
triggerCallback: function(cbName, arg) {
|
730
|
+
if ('function' == typeof this.options[cbName]) {
|
731
|
+
this.options[cbName](this, arg);
|
668
732
|
}
|
669
733
|
},
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
this.
|
675
|
-
|
676
|
-
|
734
|
+
unregisterListeners: function() {
|
735
|
+
$H(this._listeners).each(function(pair) {
|
736
|
+
if (!this.options.externalControlOnly)
|
737
|
+
this.element.stopObserving(pair.key, pair.value);
|
738
|
+
if (this.options.externalControl)
|
739
|
+
this.options.externalControl.stopObserving(pair.key, pair.value);
|
740
|
+
}.bind(this));
|
677
741
|
},
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
742
|
+
wrapUp: function(transport) {
|
743
|
+
this.leaveEditMode();
|
744
|
+
// Can't use triggerCallback due to backward compatibility: requires
|
745
|
+
// binding + direct element
|
746
|
+
this._boundComplete(transport, this.element);
|
747
|
+
}
|
748
|
+
});
|
749
|
+
|
750
|
+
Object.extend(Ajax.InPlaceEditor.prototype, {
|
751
|
+
dispose: Ajax.InPlaceEditor.prototype.destroy
|
752
|
+
});
|
753
|
+
|
754
|
+
Ajax.InPlaceCollectionEditor = Class.create(Ajax.InPlaceEditor, {
|
755
|
+
initialize: function($super, element, url, options) {
|
756
|
+
this._extraDefaultOptions = Ajax.InPlaceCollectionEditor.DefaultOptions;
|
757
|
+
$super(element, url, options);
|
758
|
+
},
|
759
|
+
|
760
|
+
createEditField: function() {
|
761
|
+
var list = document.createElement('select');
|
762
|
+
list.name = this.options.paramName;
|
763
|
+
list.size = 1;
|
764
|
+
this._controls.editor = list;
|
765
|
+
this._collection = this.options.collection || [];
|
766
|
+
if (this.options.loadCollectionURL)
|
767
|
+
this.loadCollection();
|
768
|
+
else
|
769
|
+
this.checkForExternalText();
|
770
|
+
this._form.appendChild(this._controls.editor);
|
771
|
+
},
|
772
|
+
|
773
|
+
loadCollection: function() {
|
774
|
+
this._form.addClassName(this.options.loadingClassName);
|
775
|
+
this.showLoadingText(this.options.loadingCollectionText);
|
776
|
+
var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
|
777
|
+
Object.extend(options, {
|
778
|
+
parameters: 'editorId=' + encodeURIComponent(this.element.id),
|
779
|
+
onComplete: Prototype.emptyFunction,
|
780
|
+
onSuccess: function(transport) {
|
781
|
+
var js = transport.responseText.strip();
|
782
|
+
if (!/^\[.*\]$/.test(js)) // TODO: improve sanity check
|
783
|
+
throw 'Server returned an invalid collection representation.';
|
784
|
+
this._collection = eval(js);
|
785
|
+
this.checkForExternalText();
|
786
|
+
}.bind(this),
|
787
|
+
onFailure: this.onFailure
|
688
788
|
});
|
789
|
+
new Ajax.Request(this.options.loadCollectionURL, options);
|
689
790
|
},
|
690
|
-
|
691
|
-
|
692
|
-
this.
|
693
|
-
this.
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
791
|
+
|
792
|
+
showLoadingText: function(text) {
|
793
|
+
this._controls.editor.disabled = true;
|
794
|
+
var tempOption = this._controls.editor.firstChild;
|
795
|
+
if (!tempOption) {
|
796
|
+
tempOption = document.createElement('option');
|
797
|
+
tempOption.value = '';
|
798
|
+
this._controls.editor.appendChild(tempOption);
|
799
|
+
tempOption.selected = true;
|
698
800
|
}
|
699
|
-
|
700
|
-
this.saving = false;
|
701
|
-
this.oldInnerHTML = null;
|
702
|
-
this.onLeaveEditMode();
|
801
|
+
tempOption.update((text || '').stripScripts().stripTags());
|
703
802
|
},
|
704
|
-
|
705
|
-
|
706
|
-
this.
|
803
|
+
|
804
|
+
checkForExternalText: function() {
|
805
|
+
this._text = this.getText();
|
806
|
+
if (this.options.loadTextURL)
|
807
|
+
this.loadExternalText();
|
808
|
+
else
|
809
|
+
this.buildOptionList();
|
707
810
|
},
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
811
|
+
|
812
|
+
loadExternalText: function() {
|
813
|
+
this.showLoadingText(this.options.loadingText);
|
814
|
+
var options = Object.extend({ method: 'get' }, this.options.ajaxOptions);
|
815
|
+
Object.extend(options, {
|
816
|
+
parameters: 'editorId=' + encodeURIComponent(this.element.id),
|
817
|
+
onComplete: Prototype.emptyFunction,
|
818
|
+
onSuccess: function(transport) {
|
819
|
+
this._text = transport.responseText.strip();
|
820
|
+
this.buildOptionList();
|
821
|
+
}.bind(this),
|
822
|
+
onFailure: this.onFailure
|
823
|
+
});
|
824
|
+
new Ajax.Request(this.options.loadTextURL, options);
|
825
|
+
},
|
826
|
+
|
827
|
+
buildOptionList: function() {
|
828
|
+
this._form.removeClassName(this.options.loadingClassName);
|
829
|
+
this._collection = this._collection.map(function(entry) {
|
830
|
+
return 2 === entry.length ? entry : [entry, entry].flatten();
|
831
|
+
});
|
832
|
+
var marker = ('value' in this.options) ? this.options.value : this._text;
|
833
|
+
var textFound = this._collection.any(function(entry) {
|
834
|
+
return entry[0] == marker;
|
835
|
+
}.bind(this));
|
836
|
+
this._controls.editor.update('');
|
837
|
+
var option;
|
838
|
+
this._collection.each(function(entry, index) {
|
839
|
+
option = document.createElement('option');
|
840
|
+
option.value = entry[0];
|
841
|
+
option.selected = textFound ? entry[0] == marker : 0 == index;
|
842
|
+
option.appendChild(document.createTextNode(entry[1]));
|
843
|
+
this._controls.editor.appendChild(option);
|
844
|
+
}.bind(this));
|
845
|
+
this._controls.editor.disabled = false;
|
846
|
+
Field.scrollFreeActivate(this._controls.editor);
|
847
|
+
}
|
848
|
+
});
|
849
|
+
|
850
|
+
//**** DEPRECATION LAYER FOR InPlace[Collection]Editor! ****
|
851
|
+
//**** This only exists for a while, in order to let ****
|
852
|
+
//**** users adapt to the new API. Read up on the new ****
|
853
|
+
//**** API and convert your code to it ASAP! ****
|
854
|
+
|
855
|
+
Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions = function(options) {
|
856
|
+
if (!options) return;
|
857
|
+
function fallback(name, expr) {
|
858
|
+
if (name in options || expr === undefined) return;
|
859
|
+
options[name] = expr;
|
860
|
+
};
|
861
|
+
fallback('cancelControl', (options.cancelLink ? 'link' : (options.cancelButton ? 'button' :
|
862
|
+
options.cancelLink == options.cancelButton == false ? false : undefined)));
|
863
|
+
fallback('okControl', (options.okLink ? 'link' : (options.okButton ? 'button' :
|
864
|
+
options.okLink == options.okButton == false ? false : undefined)));
|
865
|
+
fallback('highlightColor', options.highlightcolor);
|
866
|
+
fallback('highlightEndColor', options.highlightendcolor);
|
867
|
+
};
|
868
|
+
|
869
|
+
Object.extend(Ajax.InPlaceEditor, {
|
870
|
+
DefaultOptions: {
|
871
|
+
ajaxOptions: { },
|
872
|
+
autoRows: 3, // Use when multi-line w/ rows == 1
|
873
|
+
cancelControl: 'link', // 'link'|'button'|false
|
874
|
+
cancelText: 'cancel',
|
875
|
+
clickToEditText: 'Click to edit',
|
876
|
+
externalControl: null, // id|elt
|
877
|
+
externalControlOnly: false,
|
878
|
+
fieldPostCreation: 'activate', // 'activate'|'focus'|false
|
879
|
+
formClassName: 'inplaceeditor-form',
|
880
|
+
formId: null, // id|elt
|
881
|
+
highlightColor: '#ffff99',
|
882
|
+
highlightEndColor: '#ffffff',
|
883
|
+
hoverClassName: '',
|
884
|
+
htmlResponse: true,
|
885
|
+
loadingClassName: 'inplaceeditor-loading',
|
886
|
+
loadingText: 'Loading...',
|
887
|
+
okControl: 'button', // 'link'|'button'|false
|
888
|
+
okText: 'ok',
|
889
|
+
paramName: 'value',
|
890
|
+
rows: 1, // If 1 and multi-line, uses autoRows
|
891
|
+
savingClassName: 'inplaceeditor-saving',
|
892
|
+
savingText: 'Saving...',
|
893
|
+
size: 0,
|
894
|
+
stripLoadedTextTags: false,
|
895
|
+
submitOnBlur: false,
|
896
|
+
textAfterControls: '',
|
897
|
+
textBeforeControls: '',
|
898
|
+
textBetweenControls: ''
|
899
|
+
},
|
900
|
+
DefaultCallbacks: {
|
901
|
+
callback: function(form) {
|
902
|
+
return Form.serialize(form);
|
903
|
+
},
|
904
|
+
onComplete: function(transport, element) {
|
905
|
+
// For backward compatibility, this one is bound to the IPE, and passes
|
906
|
+
// the element directly. It was too often customized, so we don't break it.
|
907
|
+
new Effect.Highlight(element, {
|
908
|
+
startcolor: this.options.highlightColor, keepBackgroundImage: true });
|
909
|
+
},
|
910
|
+
onEnterEditMode: null,
|
911
|
+
onEnterHover: function(ipe) {
|
912
|
+
ipe.element.style.backgroundColor = ipe.options.highlightColor;
|
913
|
+
if (ipe._effect)
|
914
|
+
ipe._effect.cancel();
|
915
|
+
},
|
916
|
+
onFailure: function(transport, ipe) {
|
917
|
+
alert('Error communication with the server: ' + transport.responseText.stripTags());
|
918
|
+
},
|
919
|
+
onFormCustomization: null, // Takes the IPE and its generated form, after editor, before controls.
|
920
|
+
onLeaveEditMode: null,
|
921
|
+
onLeaveHover: function(ipe) {
|
922
|
+
ipe._effect = new Effect.Highlight(ipe.element, {
|
923
|
+
startcolor: ipe.options.highlightColor, endcolor: ipe.options.highlightEndColor,
|
924
|
+
restorecolor: ipe._originalBackground, keepBackgroundImage: true
|
925
|
+
});
|
722
926
|
}
|
927
|
+
},
|
928
|
+
Listeners: {
|
929
|
+
click: 'enterEditMode',
|
930
|
+
keydown: 'checkForEscapeOrReturn',
|
931
|
+
mouseover: 'enterHover',
|
932
|
+
mouseout: 'leaveHover'
|
723
933
|
}
|
934
|
+
});
|
935
|
+
|
936
|
+
Ajax.InPlaceCollectionEditor.DefaultOptions = {
|
937
|
+
loadingCollectionText: 'Loading options...'
|
724
938
|
};
|
725
939
|
|
726
940
|
// Delayed observer, like Form.Element.Observer,
|
727
941
|
// but waits for delay after last key input
|
728
942
|
// Ideal for live-search fields
|
729
943
|
|
730
|
-
Form.Element.DelayedObserver = Class.create(
|
731
|
-
Form.Element.DelayedObserver.prototype = {
|
944
|
+
Form.Element.DelayedObserver = Class.create({
|
732
945
|
initialize: function(element, delay, callback) {
|
733
946
|
this.delay = delay || 0.5;
|
734
947
|
this.element = $(element);
|
@@ -747,4 +960,4 @@ Form.Element.DelayedObserver.prototype = {
|
|
747
960
|
this.timer = null;
|
748
961
|
this.callback(this.element, $F(this.element));
|
749
962
|
}
|
750
|
-
};
|
963
|
+
});
|