gettext 1.0.0-mswin32 → 1.1.0-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (301) hide show
  1. data/ChangeLog +193 -0
  2. data/NEWS +51 -1
  3. data/README +29 -11
  4. data/Rakefile +70 -56
  5. data/bin/rgettext +2 -0
  6. data/bin/rmsgfmt +2 -0
  7. data/bin/rmsgmerge +24 -0
  8. data/data/locale/cs/LC_MESSAGES/rails.mo +0 -0
  9. data/data/locale/cs/LC_MESSAGES/rgettext.mo +0 -0
  10. data/data/locale/de/LC_MESSAGES/rails.mo +0 -0
  11. data/data/locale/de/LC_MESSAGES/rgettext.mo +0 -0
  12. data/data/locale/es/LC_MESSAGES/rails.mo +0 -0
  13. data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
  14. data/data/locale/fr/LC_MESSAGES/rails.mo +0 -0
  15. data/data/locale/fr/LC_MESSAGES/rgettext.mo +0 -0
  16. data/data/locale/it/LC_MESSAGES/rgettext.mo +0 -0
  17. data/data/locale/ja/LC_MESSAGES/rails.mo +0 -0
  18. data/data/locale/ja/LC_MESSAGES/rgettext.mo +0 -0
  19. data/data/locale/ko/LC_MESSAGES/rails.mo +0 -0
  20. data/data/locale/ko/LC_MESSAGES/rgettext.mo +0 -0
  21. data/data/locale/nl/LC_MESSAGES/rails.mo +0 -0
  22. data/data/locale/nl/LC_MESSAGES/rgettext.mo +0 -0
  23. data/data/locale/pt_BR/LC_MESSAGES/rails.mo +0 -0
  24. data/data/locale/pt_BR/LC_MESSAGES/rgettext.mo +0 -0
  25. data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
  26. data/ext/gettext/gettext/_locale.BAK +86 -0
  27. data/ext/gettext/gettext/_locale.c +1 -1
  28. data/ext/gettext/gettext/_locale.exp +0 -0
  29. data/ext/gettext/gettext/_locale.lib +0 -0
  30. data/ext/gettext/gettext/_locale.obj +0 -0
  31. data/ext/gettext/gettext/_locale.pdb +0 -0
  32. data/ext/gettext/gettext/_locale.so +0 -0
  33. data/ext/gettext/gettext/mkmf.log +4 -4
  34. data/ext/gettext/gettext/vc70.pdb +0 -0
  35. data/lib/_locale.so +0 -0
  36. data/lib/gettext.rb +17 -4
  37. data/lib/gettext/cgi.rb +34 -19
  38. data/lib/gettext/locale.rb +3 -13
  39. data/lib/gettext/locale_default.rb +2 -2
  40. data/lib/gettext/locale_win32.rb +27 -7
  41. data/lib/gettext/mo.rb +6 -1
  42. data/lib/gettext/parser/activerecord.rb +115 -0
  43. data/lib/gettext/parser/glade.rb +3 -1
  44. data/lib/gettext/parser/ruby.rb +56 -57
  45. data/lib/gettext/poparser.rb +297 -0
  46. data/lib/gettext/rails.rb +161 -3
  47. data/lib/gettext/rgettext.rb +19 -9
  48. data/lib/gettext/rmsgfmt.rb +95 -363
  49. data/lib/gettext/rmsgmerge.rb +381 -0
  50. data/lib/gettext/string.rb +26 -0
  51. data/lib/gettext/textdomain.rb +21 -18
  52. data/lib/gettext/utils.rb +55 -0
  53. data/lib/gettext/version.rb +1 -1
  54. data/po/cs/rails.po +83 -0
  55. data/po/cs/rgettext.po +104 -0
  56. data/po/de/rails.po +79 -0
  57. data/po/de/rgettext.po +72 -21
  58. data/po/es/rails.po +80 -0
  59. data/po/es/rgettext.po +75 -19
  60. data/po/fr/rails.po +81 -0
  61. data/po/fr/rgettext.po +75 -19
  62. data/po/it/rgettext.po +68 -17
  63. data/po/ja/rails.po +78 -0
  64. data/po/ja/rgettext.po +71 -20
  65. data/po/ko/rails.po +77 -0
  66. data/po/ko/rgettext.po +74 -22
  67. data/po/nl/rails.po +80 -0
  68. data/po/nl/rgettext.po +102 -0
  69. data/po/pt_BR/rails.po +79 -0
  70. data/po/pt_BR/rgettext.po +77 -24
  71. data/po/rails.pot +80 -0
  72. data/po/rgettext.pot +63 -13
  73. data/po/sv/rgettext.po +63 -15
  74. data/samples/cgi/cookie.cgi +5 -0
  75. data/samples/cgi/helloerb1.cgi +4 -0
  76. data/samples/cgi/helloerb2.cgi +5 -0
  77. data/samples/cgi/index.cgi +5 -0
  78. data/samples/cgi/locale/cs/LC_MESSAGES/helloerb1.mo +0 -0
  79. data/samples/cgi/locale/cs/LC_MESSAGES/helloerb2.mo +0 -0
  80. data/samples/cgi/locale/cs/LC_MESSAGES/hellolib.mo +0 -0
  81. data/samples/cgi/locale/cs/LC_MESSAGES/main.mo +0 -0
  82. data/samples/cgi/locale/fr/LC_MESSAGES/main.mo +0 -0
  83. data/samples/cgi/locale/ko/LC_MESSAGES/helloerb1.mo +0 -0
  84. data/samples/cgi/locale/ko/LC_MESSAGES/helloerb2.mo +0 -0
  85. data/samples/cgi/locale/ko/LC_MESSAGES/hellolib.mo +0 -0
  86. data/samples/cgi/locale/ko/LC_MESSAGES/main.mo +0 -0
  87. data/samples/cgi/locale/nl/LC_MESSAGES/helloerb1.mo +0 -0
  88. data/samples/cgi/locale/nl/LC_MESSAGES/helloerb2.mo +0 -0
  89. data/samples/cgi/locale/nl/LC_MESSAGES/hellolib.mo +0 -0
  90. data/samples/cgi/locale/nl/LC_MESSAGES/main.mo +0 -0
  91. data/samples/cgi/locale/pt_BR/LC_MESSAGES/helloerb1.mo +0 -0
  92. data/samples/cgi/locale/pt_BR/LC_MESSAGES/helloerb2.mo +0 -0
  93. data/samples/cgi/locale/pt_BR/LC_MESSAGES/hellolib.mo +0 -0
  94. data/samples/cgi/locale/pt_BR/LC_MESSAGES/main.mo +0 -0
  95. data/samples/cgi/po/cs/helloerb1.po +66 -0
  96. data/samples/cgi/po/cs/helloerb2.po +52 -0
  97. data/samples/cgi/po/cs/hellolib.po +25 -0
  98. data/samples/cgi/po/cs/main.po +78 -0
  99. data/samples/cgi/po/fr/main.po +8 -8
  100. data/samples/cgi/po/ko/helloerb1.po +2 -3
  101. data/samples/cgi/po/ko/helloerb2.po +1 -2
  102. data/samples/cgi/po/ko/hellolib.po +1 -2
  103. data/samples/cgi/po/ko/main.po +2 -3
  104. data/samples/cgi/po/nl/helloerb1.po +60 -0
  105. data/samples/cgi/po/nl/helloerb2.po +52 -0
  106. data/samples/cgi/po/nl/hellolib.po +24 -0
  107. data/samples/cgi/po/nl/main.po +76 -0
  108. data/samples/cgi/po/pt_BR/helloerb1.po +59 -0
  109. data/samples/cgi/po/pt_BR/helloerb2.po +51 -0
  110. data/samples/cgi/po/pt_BR/hellolib.po +22 -0
  111. data/samples/cgi/po/pt_BR/main.po +75 -0
  112. data/samples/locale/cs/LC_MESSAGES/hello.mo +0 -0
  113. data/samples/locale/cs/LC_MESSAGES/hello2.mo +0 -0
  114. data/samples/locale/cs/LC_MESSAGES/hello_noop.mo +0 -0
  115. data/samples/locale/cs/LC_MESSAGES/hello_plural.mo +0 -0
  116. data/samples/locale/cs/LC_MESSAGES/helloglade2.mo +0 -0
  117. data/samples/locale/cs/LC_MESSAGES/hellogtk.mo +0 -0
  118. data/samples/locale/cs/LC_MESSAGES/hellotk.mo +0 -0
  119. data/samples/locale/fr/LC_MESSAGES/helloglade2.mo +0 -0
  120. data/samples/locale/ko/LC_MESSAGES/hello.mo +0 -0
  121. data/samples/locale/ko/LC_MESSAGES/hello2.mo +0 -0
  122. data/samples/locale/ko/LC_MESSAGES/hello_noop.mo +0 -0
  123. data/samples/locale/ko/LC_MESSAGES/hello_plural.mo +0 -0
  124. data/samples/locale/ko/LC_MESSAGES/helloglade2.mo +0 -0
  125. data/samples/locale/ko/LC_MESSAGES/hellogtk.mo +0 -0
  126. data/samples/locale/ko/LC_MESSAGES/hellotk.mo +0 -0
  127. data/samples/locale/nl/LC_MESSAGES/hello.mo +0 -0
  128. data/samples/locale/nl/LC_MESSAGES/hello2.mo +0 -0
  129. data/samples/locale/nl/LC_MESSAGES/hello_noop.mo +0 -0
  130. data/samples/locale/nl/LC_MESSAGES/hello_plural.mo +0 -0
  131. data/samples/locale/nl/LC_MESSAGES/helloglade2.mo +0 -0
  132. data/samples/locale/nl/LC_MESSAGES/hellogtk.mo +0 -0
  133. data/samples/locale/nl/LC_MESSAGES/hellotk.mo +0 -0
  134. data/samples/locale/pt_BR/LC_MESSAGES/hello.mo +0 -0
  135. data/samples/locale/pt_BR/LC_MESSAGES/hello2.mo +0 -0
  136. data/samples/locale/pt_BR/LC_MESSAGES/hello_noop.mo +0 -0
  137. data/samples/locale/pt_BR/LC_MESSAGES/hello_plural.mo +0 -0
  138. data/samples/locale/pt_BR/LC_MESSAGES/helloglade2.mo +0 -0
  139. data/samples/locale/pt_BR/LC_MESSAGES/hellogtk.mo +0 -0
  140. data/samples/locale/pt_BR/LC_MESSAGES/hellotk.mo +0 -0
  141. data/samples/po/cs/hello.po +23 -0
  142. data/samples/po/cs/hello2.po +31 -0
  143. data/samples/po/cs/hello_noop.po +27 -0
  144. data/samples/po/cs/hello_plural.po +26 -0
  145. data/samples/po/cs/helloglade2.po +37 -0
  146. data/samples/po/cs/hellogtk.po +23 -0
  147. data/samples/po/cs/hellotk.po +23 -0
  148. data/samples/po/fr/helloglade2.po +2 -2
  149. data/samples/po/hello.pot +1 -0
  150. data/samples/po/hello2.pot +1 -0
  151. data/samples/po/hello_noop.pot +2 -1
  152. data/samples/po/hello_plural.pot +6 -2
  153. data/samples/po/helloglade2.pot +8 -3
  154. data/samples/po/hellotk.pot +4 -0
  155. data/samples/po/ko/hello.po +1 -2
  156. data/samples/po/ko/hello2.po +1 -2
  157. data/samples/po/ko/hello_noop.po +1 -2
  158. data/samples/po/ko/hello_plural.po +1 -2
  159. data/samples/po/ko/helloglade2.po +2 -2
  160. data/samples/po/ko/hellogtk.po +1 -2
  161. data/samples/po/ko/hellotk.po +1 -2
  162. data/samples/po/nl/hello.po +24 -0
  163. data/samples/po/nl/hello2.po +32 -0
  164. data/samples/po/nl/hello_noop.po +28 -0
  165. data/samples/po/nl/hello_plural.po +26 -0
  166. data/samples/po/nl/helloglade2.po +31 -0
  167. data/samples/po/nl/hellogtk.po +24 -0
  168. data/samples/po/nl/hellotk.po +24 -0
  169. data/samples/po/pt_BR/hello.po +6 -5
  170. data/samples/po/pt_BR/hello2.po +6 -5
  171. data/samples/po/pt_BR/hello_noop.po +6 -5
  172. data/samples/po/pt_BR/hello_plural.po +6 -6
  173. data/samples/po/pt_BR/helloglade2.po +6 -5
  174. data/samples/po/pt_BR/hellogtk.po +6 -5
  175. data/samples/po/pt_BR/hellotk.po +6 -5
  176. data/samples/rails/README +21 -15
  177. data/samples/rails/Rakefile +10 -1
  178. data/samples/rails/app/controllers/application.rb +10 -18
  179. data/samples/rails/app/controllers/blog_controller.rb +1 -5
  180. data/samples/rails/app/helpers/blog_helper.rb +1 -1
  181. data/samples/rails/app/models/article.rb +15 -0
  182. data/samples/rails/app/views/blog/_form.rhtml +2 -2
  183. data/samples/rails/config/boot.rb +17 -0
  184. data/samples/rails/config/database.yml +6 -4
  185. data/samples/rails/config/environment.rb +40 -75
  186. data/samples/rails/config/environments/development.rb +12 -7
  187. data/samples/rails/config/environments/production.rb +17 -6
  188. data/samples/rails/config/environments/test.rb +8 -6
  189. data/samples/rails/locale/cs/LC_MESSAGES/blog.mo +0 -0
  190. data/samples/rails/locale/cs/LC_MESSAGES/gettext_plugin.mo +0 -0
  191. data/samples/rails/locale/de/LC_MESSAGES/blog.mo +0 -0
  192. data/samples/rails/locale/de/LC_MESSAGES/gettext_plugin.mo +0 -0
  193. data/samples/rails/locale/en/LC_MESSAGES/blog.mo +0 -0
  194. data/samples/rails/locale/es/LC_MESSAGES/blog.mo +0 -0
  195. data/samples/rails/locale/es/LC_MESSAGES/gettext_plugin.mo +0 -0
  196. data/samples/rails/locale/fr/LC_MESSAGES/blog.mo +0 -0
  197. data/samples/rails/locale/fr/LC_MESSAGES/{lang_helper.mo → gettext_plugin.mo} +0 -0
  198. data/samples/rails/locale/ja/LC_MESSAGES/blog.mo +0 -0
  199. data/samples/rails/locale/ja/LC_MESSAGES/{lang_helper.mo → gettext_plugin.mo} +0 -0
  200. data/samples/rails/locale/ko/LC_MESSAGES/blog.mo +0 -0
  201. data/samples/rails/locale/ko/LC_MESSAGES/gettext_plugin.mo +0 -0
  202. data/samples/rails/locale/nl/LC_MESSAGES/blog.mo +0 -0
  203. data/samples/rails/locale/nl/LC_MESSAGES/gettext_plugin.mo +0 -0
  204. data/samples/rails/locale/pt_BR/LC_MESSAGES/blog.mo +0 -0
  205. data/samples/rails/locale/pt_BR/LC_MESSAGES/gettext_plugin.mo +0 -0
  206. data/samples/rails/po/blog.pot +57 -37
  207. data/samples/rails/po/cs/blog.po +116 -0
  208. data/samples/rails/po/cs/gettext_plugin.po +29 -0
  209. data/samples/rails/po/de/blog.po +70 -51
  210. data/samples/rails/po/de/{lang_helper.po → gettext_plugin.po} +4 -5
  211. data/samples/rails/po/en/blog.po +111 -0
  212. data/samples/rails/po/es/blog.po +67 -47
  213. data/samples/rails/po/es/{lang_helper.po → gettext_plugin.po} +5 -5
  214. data/samples/rails/po/fr/blog.po +65 -45
  215. data/samples/rails/po/fr/{lang_helper.po → gettext_plugin.po} +4 -4
  216. data/samples/rails/po/{lang_helper.pot → gettext_plugin.pot} +4 -4
  217. data/samples/rails/po/ja/blog.po +64 -44
  218. data/samples/rails/po/ja/{lang_helper.po → gettext_plugin.po} +4 -4
  219. data/samples/rails/po/ko/blog.po +65 -46
  220. data/samples/rails/po/ko/{lang_helper.po → gettext_plugin.po} +5 -6
  221. data/samples/rails/po/nl/blog.po +115 -0
  222. data/samples/rails/po/nl/gettext_plugin.po +28 -0
  223. data/samples/rails/po/pt_BR/blog.po +109 -0
  224. data/samples/rails/po/pt_BR/gettext_plugin.po +27 -0
  225. data/samples/rails/public/images/rails.png +0 -0
  226. data/samples/rails/public/index.html +272 -71
  227. data/samples/rails/public/javascripts/controls.js +441 -166
  228. data/samples/rails/public/javascripts/dragdrop.js +261 -279
  229. data/samples/rails/public/javascripts/effects.js +657 -277
  230. data/samples/rails/public/javascripts/prototype.js +911 -223
  231. data/samples/rails/public/robots.txt +1 -0
  232. data/samples/rails/public/stylesheets/scaffold.css +1 -1
  233. data/samples/rails/script/about +3 -0
  234. data/samples/rails/script/breakpointer +3 -4
  235. data/samples/rails/script/console +3 -23
  236. data/samples/rails/script/destroy +3 -7
  237. data/samples/rails/script/generate +3 -7
  238. data/samples/rails/script/performance/benchmarker +3 -0
  239. data/samples/rails/script/performance/profiler +3 -0
  240. data/samples/rails/script/plugin +3 -0
  241. data/samples/rails/script/process/reaper +3 -0
  242. data/samples/rails/script/process/spawner +3 -0
  243. data/samples/rails/script/process/spinner +3 -0
  244. data/samples/rails/script/runner +3 -29
  245. data/samples/rails/script/server +3 -49
  246. data/samples/rails/vendor/plugins/gettext/init.rb +19 -0
  247. data/samples/rails/vendor/{lang_helper.rb → plugins/gettext/lib/gettext_plugin.rb} +15 -11
  248. data/src/poparser.ry +171 -0
  249. data/test/gettext_runner.rb +3 -1
  250. data/test/gettext_test.rb +56 -31
  251. data/test/gettext_test_cgi.rb +12 -0
  252. data/test/gettext_test_parser.rb +3 -0
  253. data/test/gettext_test_string.rb +14 -0
  254. data/test/locale/cr/LC_MESSAGES/plural.mo +0 -0
  255. data/test/locale/da/LC_MESSAGES/plural.mo +0 -0
  256. data/test/locale/da/LC_MESSAGES/plural_error.mo +0 -0
  257. data/test/locale/fr/LC_MESSAGES/plural.mo +0 -0
  258. data/test/locale/fr/LC_MESSAGES/plural_error.mo +0 -0
  259. data/test/locale/ir/LC_MESSAGES/plural.mo +0 -0
  260. data/test/locale/la/LC_MESSAGES/plural.mo +0 -0
  261. data/test/locale/li/LC_MESSAGES/plural.mo +0 -0
  262. data/test/locale/po/LC_MESSAGES/plural.mo +0 -0
  263. data/test/locale/sl/LC_MESSAGES/plural.mo +0 -0
  264. data/test/po/cr/plural.po +3 -3
  265. data/test/po/da/plural.po +2 -2
  266. data/test/po/da/plural_error.po +2 -1
  267. data/test/po/fr/plural.po +2 -2
  268. data/test/po/fr/plural_error.po +2 -1
  269. data/test/po/ir/plural.po +3 -3
  270. data/test/po/la/plural.po +3 -3
  271. data/test/po/li/plural.po +3 -3
  272. data/test/po/po/plural.po +3 -3
  273. data/test/po/sl/plural.po +4 -4
  274. data/test/test.sh +1 -0
  275. data/test/test_rubyparser.rb +20 -0
  276. data/test/{test_rubyparser_n.rb → test_rubyparser_N.rb} +0 -0
  277. metadata +163 -43
  278. data/README.ja +0 -115
  279. data/data/locale/de/LC_MESSAGES/rmsgfmt.mo +0 -0
  280. data/data/locale/es/LC_MESSAGES/rmsgfmt.mo +0 -0
  281. data/data/locale/fr/LC_MESSAGES/rmsgfmt.mo +0 -0
  282. data/data/locale/it/LC_MESSAGES/rmsgfmt.mo +0 -0
  283. data/data/locale/ja/LC_MESSAGES/rmsgfmt.mo +0 -0
  284. data/data/locale/ko/LC_MESSAGES/rmsgfmt.mo +0 -0
  285. data/data/locale/pt_BR/LC_MESSAGES/rmsgfmt.mo +0 -0
  286. data/data/locale/sv/LC_MESSAGES/rmsgfmt.mo +0 -0
  287. data/gettext-1.0.0-mswin32.gem +0 -0
  288. data/po/de/rmsgfmt.po +0 -45
  289. data/po/es/rmsgfmt.po +0 -43
  290. data/po/fr/rmsgfmt.po +0 -43
  291. data/po/it/rmsgfmt.po +0 -44
  292. data/po/ja/rmsgfmt.po +0 -43
  293. data/po/ko/rmsgfmt.po +0 -40
  294. data/po/pt_BR/rmsgfmt.po +0 -42
  295. data/po/rmsgfmt.pot +0 -40
  296. data/po/sv/rmsgfmt.po +0 -43
  297. data/samples/rails/locale/de/LC_MESSAGES/lang_helper.mo +0 -0
  298. data/samples/rails/locale/es/LC_MESSAGES/lang_helper.mo +0 -0
  299. data/samples/rails/locale/ko/LC_MESSAGES/lang_helper.mo +0 -0
  300. data/samples/rails/log/development.log +0 -378
  301. data/src/rmsgfmt.ry +0 -233
@@ -1,30 +1,226 @@
1
1
  // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
2
- //
3
- // Parts (c) 2005 Justin Palmer (http://encytemedia.com/)
4
- // Parts (c) 2005 Mark Pilgrim (http://diveintomark.org/)
2
+ // Contributors:
3
+ // Justin Palmer (http://encytemedia.com/)
4
+ // Mark Pilgrim (http://diveintomark.org/)
5
+ // Martin Bialasinki
5
6
  //
6
- // Permission is hereby granted, free of charge, to any person obtaining
7
- // a copy of this software and associated documentation files (the
8
- // "Software"), to deal in the Software without restriction, including
9
- // without limitation the rights to use, copy, modify, merge, publish,
10
- // distribute, sublicense, and/or sell copies of the Software, and to
11
- // permit persons to whom the Software is furnished to do so, subject to
12
- // the following conditions:
13
- //
14
- // The above copyright notice and this permission notice shall be
15
- // included in all copies or substantial portions of the Software.
16
- //
17
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
- // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
- // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7
+ // See scriptaculous.js for full license.
8
+
9
+ /* ------------- element ext -------------- */
10
+
11
+ // converts rgb() and #xxx to #xxxxxx format,
12
+ // returns self (or first argument) if not convertable
13
+ String.prototype.parseColor = function() {
14
+ color = "#";
15
+ if(this.slice(0,4) == "rgb(") {
16
+ var cols = this.slice(4,this.length-1).split(',');
17
+ var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);
18
+ } else {
19
+ if(this.slice(0,1) == '#') {
20
+ if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase();
21
+ if(this.length==7) color = this.toLowerCase();
22
+ }
23
+ }
24
+ return(color.length==7 ? color : (arguments[0] || this));
25
+ }
26
+
27
+ Element.collectTextNodesIgnoreClass = function(element, ignoreclass) {
28
+ var children = $(element).childNodes;
29
+ var text = "";
30
+ var classtest = new RegExp("^([^ ]+ )*" + ignoreclass+ "( [^ ]+)*$","i");
31
+
32
+ for (var i = 0; i < children.length; i++) {
33
+ if(children[i].nodeType==3) {
34
+ text+=children[i].nodeValue;
35
+ } else {
36
+ if((!children[i].className.match(classtest)) && children[i].hasChildNodes())
37
+ text += Element.collectTextNodesIgnoreClass(children[i], ignoreclass);
38
+ }
39
+ }
40
+
41
+ return text;
42
+ }
24
43
 
44
+ Element.setContentZoom = function(element, percent) {
45
+ element = $(element);
46
+ element.style.fontSize = (percent/100) + "em";
47
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
48
+ }
25
49
 
26
- Effect = {}
27
- Effect2 = Effect; // deprecated
50
+ Element.getOpacity = function(element){
51
+ var opacity;
52
+ if (opacity = Element.getStyle(element, "opacity"))
53
+ return parseFloat(opacity);
54
+ if (opacity = (Element.getStyle(element, "filter") || '').match(/alpha\(opacity=(.*)\)/))
55
+ if(opacity[1]) return parseFloat(opacity[1]) / 100;
56
+ return 1.0;
57
+ }
58
+
59
+ Element.setOpacity = function(element, value){
60
+ element= $(element);
61
+ var els = element.style;
62
+ if (value == 1){
63
+ els.opacity = '0.999999';
64
+ if(/MSIE/.test(navigator.userAgent))
65
+ els.filter = Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'');
66
+ } else {
67
+ if(value < 0.00001) value = 0;
68
+ els.opacity = value;
69
+ if(/MSIE/.test(navigator.userAgent))
70
+ els.filter = Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') +
71
+ "alpha(opacity="+value*100+")";
72
+ }
73
+ }
74
+
75
+ Element.getInlineOpacity = function(element){
76
+ element= $(element);
77
+ var op;
78
+ op = element.style.opacity;
79
+ if (typeof op != "undefined" && op != "") return op;
80
+ return "";
81
+ }
82
+
83
+ Element.setInlineOpacity = function(element, value){
84
+ element= $(element);
85
+ var els = element.style;
86
+ els.opacity = value;
87
+ }
88
+
89
+ /*--------------------------------------------------------------------------*/
90
+
91
+ Element.Class = {
92
+ // Element.toggleClass(element, className) toggles the class being on/off
93
+ // Element.toggleClass(element, className1, className2) toggles between both classes,
94
+ // defaulting to className1 if neither exist
95
+ toggle: function(element, className) {
96
+ if(Element.Class.has(element, className)) {
97
+ Element.Class.remove(element, className);
98
+ if(arguments.length == 3) Element.Class.add(element, arguments[2]);
99
+ } else {
100
+ Element.Class.add(element, className);
101
+ if(arguments.length == 3) Element.Class.remove(element, arguments[2]);
102
+ }
103
+ },
104
+
105
+ // gets space-delimited classnames of an element as an array
106
+ get: function(element) {
107
+ return $(element).className.split(' ');
108
+ },
109
+
110
+ // functions adapted from original functions by Gavin Kistner
111
+ remove: function(element) {
112
+ element = $(element);
113
+ var removeClasses = arguments;
114
+ $R(1,arguments.length-1).each( function(index) {
115
+ element.className =
116
+ element.className.split(' ').reject(
117
+ function(klass) { return (klass == removeClasses[index]) } ).join(' ');
118
+ });
119
+ },
120
+
121
+ add: function(element) {
122
+ element = $(element);
123
+ for(var i = 1; i < arguments.length; i++) {
124
+ Element.Class.remove(element, arguments[i]);
125
+ element.className += (element.className.length > 0 ? ' ' : '') + arguments[i];
126
+ }
127
+ },
128
+
129
+ // returns true if all given classes exist in said element
130
+ has: function(element) {
131
+ element = $(element);
132
+ if(!element || !element.className) return false;
133
+ var regEx;
134
+ for(var i = 1; i < arguments.length; i++) {
135
+ if((typeof arguments[i] == 'object') &&
136
+ (arguments[i].constructor == Array)) {
137
+ for(var j = 0; j < arguments[i].length; j++) {
138
+ regEx = new RegExp("(^|\\s)" + arguments[i][j] + "(\\s|$)");
139
+ if(!regEx.test(element.className)) return false;
140
+ }
141
+ } else {
142
+ regEx = new RegExp("(^|\\s)" + arguments[i] + "(\\s|$)");
143
+ if(!regEx.test(element.className)) return false;
144
+ }
145
+ }
146
+ return true;
147
+ },
148
+
149
+ // expects arrays of strings and/or strings as optional paramters
150
+ // Element.Class.has_any(element, ['classA','classB','classC'], 'classD')
151
+ has_any: function(element) {
152
+ element = $(element);
153
+ if(!element || !element.className) return false;
154
+ var regEx;
155
+ for(var i = 1; i < arguments.length; i++) {
156
+ if((typeof arguments[i] == 'object') &&
157
+ (arguments[i].constructor == Array)) {
158
+ for(var j = 0; j < arguments[i].length; j++) {
159
+ regEx = new RegExp("(^|\\s)" + arguments[i][j] + "(\\s|$)");
160
+ if(regEx.test(element.className)) return true;
161
+ }
162
+ } else {
163
+ regEx = new RegExp("(^|\\s)" + arguments[i] + "(\\s|$)");
164
+ if(regEx.test(element.className)) return true;
165
+ }
166
+ }
167
+ return false;
168
+ },
169
+
170
+ childrenWith: function(element, className) {
171
+ var children = $(element).getElementsByTagName('*');
172
+ var elements = new Array();
173
+
174
+ for (var i = 0; i < children.length; i++)
175
+ if (Element.Class.has(children[i], className))
176
+ elements.push(children[i]);
177
+
178
+ return elements;
179
+ }
180
+ }
181
+
182
+ /*--------------------------------------------------------------------------*/
183
+
184
+ var Effect = {
185
+ tagifyText: function(element) {
186
+ var tagifyStyle = "position:relative";
187
+ if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ";zoom:1";
188
+ element = $(element);
189
+ $A(element.childNodes).each( function(child) {
190
+ if(child.nodeType==3) {
191
+ child.nodeValue.toArray().each( function(character) {
192
+ element.insertBefore(
193
+ Builder.node('span',{style: tagifyStyle},
194
+ character == " " ? String.fromCharCode(160) : character),
195
+ child);
196
+ });
197
+ Element.remove(child);
198
+ }
199
+ });
200
+ },
201
+ multiple: function(element, effect) {
202
+ var elements;
203
+ if(((typeof element == 'object') ||
204
+ (typeof element == 'function')) &&
205
+ (element.length))
206
+ elements = element;
207
+ else
208
+ elements = $(element).childNodes;
209
+
210
+ var options = Object.extend({
211
+ speed: 0.1,
212
+ delay: 0.0
213
+ }, arguments[2] || {});
214
+ var speed = options.speed;
215
+ var delay = options.delay;
216
+
217
+ $A(elements).each( function(element, index) {
218
+ new effect(element, Object.extend(options, { delay: delay + index * speed }));
219
+ });
220
+ }
221
+ };
222
+
223
+ var Effect2 = Effect; // deprecated
28
224
 
29
225
  /* ------------- transitions ------------- */
30
226
 
@@ -40,7 +236,7 @@ Effect.Transitions.reverse = function(pos) {
40
236
  return 1-pos;
41
237
  }
42
238
  Effect.Transitions.flicker = function(pos) {
43
- return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random(0.25);
239
+ return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4;
44
240
  }
45
241
  Effect.Transitions.wobble = function(pos) {
46
242
  return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5;
@@ -56,73 +252,115 @@ Effect.Transitions.full = function(pos) {
56
252
  return 1;
57
253
  }
58
254
 
59
- /* ------------- element ext -------------- */
60
-
61
- Element.makePositioned = function(element) {
62
- element = $(element);
63
- if(element.style.position == "")
64
- element.style.position = "relative";
65
- }
66
-
67
- Element.makeClipping = function(element) {
68
- element = $(element);
69
- element._overflow = element.style.overflow || 'visible';
70
- if(element._overflow!='hidden') element.style.overflow = 'hidden';
71
- }
255
+ /* ------------- core effects ------------- */
72
256
 
73
- Element.undoClipping = function(element) {
74
- element = $(element);
75
- if(element._overflow!='hidden') element.style.overflow = element._overflow;
257
+ Effect.Queue = {
258
+ effects: [],
259
+ _each: function(iterator) {
260
+ this.effects._each(iterator);
261
+ },
262
+ interval: null,
263
+ add: function(effect) {
264
+ var timestamp = new Date().getTime();
265
+
266
+ switch(effect.options.queue) {
267
+ case 'front':
268
+ // move unstarted effects after this effect
269
+ this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) {
270
+ e.startOn += effect.finishOn;
271
+ e.finishOn += effect.finishOn;
272
+ });
273
+ break;
274
+ case 'end':
275
+ // start effect after last queued effect has finished
276
+ timestamp = this.effects.pluck('finishOn').max() || timestamp;
277
+ break;
278
+ }
279
+
280
+ effect.startOn += timestamp;
281
+ effect.finishOn += timestamp;
282
+ this.effects.push(effect);
283
+ if(!this.interval)
284
+ this.interval = setInterval(this.loop.bind(this), 40);
285
+ },
286
+ remove: function(effect) {
287
+ this.effects = this.effects.reject(function(e) { return e==effect });
288
+ if(this.effects.length == 0) {
289
+ clearInterval(this.interval);
290
+ this.interval = null;
291
+ }
292
+ },
293
+ loop: function() {
294
+ var timePos = new Date().getTime();
295
+ this.effects.invoke('loop', timePos);
296
+ }
76
297
  }
77
-
78
- /* ------------- core effects ------------- */
298
+ Object.extend(Effect.Queue, Enumerable);
79
299
 
80
300
  Effect.Base = function() {};
81
301
  Effect.Base.prototype = {
302
+ position: null,
82
303
  setOptions: function(options) {
83
304
  this.options = Object.extend({
84
305
  transition: Effect.Transitions.sinoidal,
85
306
  duration: 1.0, // seconds
86
- fps: 25.0, // max. 100fps
307
+ fps: 25.0, // max. 25fps due to Effect.Queue implementation
87
308
  sync: false, // true for combining
88
309
  from: 0.0,
89
- to: 1.0
310
+ to: 1.0,
311
+ delay: 0.0,
312
+ queue: 'parallel'
90
313
  }, options || {});
91
314
  },
92
315
  start: function(options) {
93
316
  this.setOptions(options || {});
94
317
  this.currentFrame = 0;
95
- this.startOn = new Date().getTime();
318
+ this.state = 'idle';
319
+ this.startOn = this.options.delay*1000;
96
320
  this.finishOn = this.startOn + (this.options.duration*1000);
97
- if(this.options.beforeStart) this.options.beforeStart(this);
98
- if(!this.options.sync) this.loop();
321
+ this.event('beforeStart');
322
+ if(!this.options.sync) Effect.Queue.add(this);
99
323
  },
100
- loop: function() {
101
- var timePos = new Date().getTime();
102
- if(timePos >= this.finishOn) {
103
- this.render(this.options.to);
104
- if(this.finish) this.finish();
105
- if(this.options.afterFinish) this.options.afterFinish(this);
106
- return;
107
- }
108
- var pos = (timePos - this.startOn) / (this.finishOn - this.startOn);
109
- var frame = Math.round(pos * this.options.fps * this.options.duration);
110
- if(frame > this.currentFrame) {
111
- this.render(pos);
112
- this.currentFrame = frame;
324
+ loop: function(timePos) {
325
+ if(timePos >= this.startOn) {
326
+ if(timePos >= this.finishOn) {
327
+ this.render(1.0);
328
+ this.cancel();
329
+ this.event('beforeFinish');
330
+ if(this.finish) this.finish();
331
+ this.event('afterFinish');
332
+ return;
333
+ }
334
+ var pos = (timePos - this.startOn) / (this.finishOn - this.startOn);
335
+ var frame = Math.round(pos * this.options.fps * this.options.duration);
336
+ if(frame > this.currentFrame) {
337
+ this.render(pos);
338
+ this.currentFrame = frame;
339
+ }
113
340
  }
114
- this.timeout = setTimeout(this.loop.bind(this), 10);
115
341
  },
116
342
  render: function(pos) {
343
+ if(this.state == 'idle') {
344
+ this.state = 'running';
345
+ this.event('beforeSetup');
346
+ if(this.setup) this.setup();
347
+ this.event('afterSetup');
348
+ }
117
349
  if(this.options.transition) pos = this.options.transition(pos);
118
350
  pos *= (this.options.to-this.options.from);
119
- pos += this.options.from;
120
- if(this.options.beforeUpdate) this.options.beforeUpdate(this);
351
+ pos += this.options.from;
352
+ this.position = pos;
353
+ this.event('beforeUpdate');
121
354
  if(this.update) this.update(pos);
122
- if(this.options.afterUpdate) this.options.afterUpdate(this);
355
+ this.event('afterUpdate');
123
356
  },
124
357
  cancel: function() {
125
- if(this.timeout) clearTimeout(this.timeout);
358
+ if(!this.options.sync) Effect.Queue.remove(this);
359
+ this.state = 'finished';
360
+ },
361
+ event: function(eventName) {
362
+ if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this);
363
+ if(this.options[eventName]) this.options[eventName](this);
126
364
  }
127
365
  }
128
366
 
@@ -133,35 +371,34 @@ Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), {
133
371
  this.start(arguments[1]);
134
372
  },
135
373
  update: function(position) {
136
- for (var i = 0; i < this.effects.length; i++)
137
- this.effects[i].render(position);
374
+ this.effects.invoke('render', position);
138
375
  },
139
376
  finish: function(position) {
140
- for (var i = 0; i < this.effects.length; i++)
141
- if(this.effects[i].finish) this.effects[i].finish(position);
377
+ this.effects.each( function(effect) {
378
+ effect.render(1.0);
379
+ effect.cancel();
380
+ effect.event('beforeFinish');
381
+ if(effect.finish) effect.finish(position);
382
+ effect.event('afterFinish');
383
+ });
142
384
  }
143
385
  });
144
386
 
145
- // Internet Explorer caveat: works only on elements the have
146
- // a 'layout', meaning having a given width or height.
147
- // There is no way to safely set this automatically.
148
387
  Effect.Opacity = Class.create();
149
388
  Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {
150
389
  initialize: function(element) {
151
390
  this.element = $(element);
152
- options = Object.extend({
153
- from: 0.0,
391
+ // make this work on IE on elements without 'layout'
392
+ if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout))
393
+ this.element.style.zoom = 1;
394
+ var options = Object.extend({
395
+ from: Element.getOpacity(this.element) || 0.0,
154
396
  to: 1.0
155
397
  }, arguments[1] || {});
156
398
  this.start(options);
157
399
  },
158
400
  update: function(position) {
159
- this.setOpacity(position);
160
- },
161
- setOpacity: function(opacity) {
162
- opacity = (opacity == 1) ? 0.99999 : opacity;
163
- this.element.style.opacity = opacity;
164
- this.element.style.filter = "alpha(opacity:"+opacity*100+")";
401
+ Element.setOpacity(this.element, position);
165
402
  }
166
403
  });
167
404
 
@@ -169,16 +406,23 @@ Effect.MoveBy = Class.create();
169
406
  Object.extend(Object.extend(Effect.MoveBy.prototype, Effect.Base.prototype), {
170
407
  initialize: function(element, toTop, toLeft) {
171
408
  this.element = $(element);
172
- this.originalTop = parseFloat(this.element.style.top || '0');
173
- this.originalLeft = parseFloat(this.element.style.left || '0');
174
409
  this.toTop = toTop;
175
410
  this.toLeft = toLeft;
176
- Element.makePositioned(this.element);
177
411
  this.start(arguments[3]);
178
412
  },
413
+ setup: function() {
414
+ // Bug in Opera: Opera returns the "real" position of a static element or
415
+ // relative element that does not have top/left explicitly set.
416
+ // ==> Always set top and left for position relative elements in your stylesheets
417
+ // (to 0 if you do not need them)
418
+
419
+ Element.makePositioned(this.element);
420
+ this.originalTop = parseFloat(Element.getStyle(this.element,'top') || '0');
421
+ this.originalLeft = parseFloat(Element.getStyle(this.element,'left') || '0');
422
+ },
179
423
  update: function(position) {
180
- topd = this.toTop * position + this.originalTop;
181
- leftd = this.toLeft * position + this.originalLeft;
424
+ var topd = this.toTop * position + this.originalTop;
425
+ var leftd = this.toLeft * position + this.originalLeft;
182
426
  this.setPosition(topd, leftd);
183
427
  },
184
428
  setPosition: function(topd, leftd) {
@@ -191,55 +435,77 @@ Effect.Scale = Class.create();
191
435
  Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
192
436
  initialize: function(element, percent) {
193
437
  this.element = $(element)
194
- options = Object.extend({
438
+ var options = Object.extend({
195
439
  scaleX: true,
196
440
  scaleY: true,
197
441
  scaleContent: true,
198
442
  scaleFromCenter: false,
199
443
  scaleMode: 'box', // 'box' or 'contents' or {} with provided values
200
- scaleFrom: 100.0
444
+ scaleFrom: 100.0,
445
+ scaleTo: percent
201
446
  }, arguments[2] || {});
202
- this.originalTop = this.element.offsetTop;
203
- this.originalLeft = this.element.offsetLeft;
204
- if(this.element.style.fontSize=="") this.sizeEm = 1.0;
205
- if(this.element.style.fontSize && this.element.style.fontSize.indexOf("em")>0)
206
- this.sizeEm = parseFloat(this.element.style.fontSize);
207
- this.factor = (percent/100.0) - (options.scaleFrom/100.0);
208
- if(options.scaleMode=='box') {
209
- this.originalHeight = this.element.clientHeight;
210
- this.originalWidth = this.element.clientWidth;
211
- } else
212
- if(options.scaleMode=='contents') {
213
- this.originalHeight = this.element.scrollHeight;
214
- this.originalWidth = this.element.scrollWidth;
215
- } else {
216
- this.originalHeight = options.scaleMode.originalHeight;
217
- this.originalWidth = options.scaleMode.originalWidth;
218
- }
219
447
  this.start(options);
220
448
  },
221
-
449
+ setup: function() {
450
+ var effect = this;
451
+
452
+ this.restoreAfterFinish = this.options.restoreAfterFinish || false;
453
+ this.elementPositioning = Element.getStyle(this.element,'position');
454
+
455
+ effect.originalStyle = {};
456
+ ['top','left','width','height','fontSize'].each( function(k) {
457
+ effect.originalStyle[k] = effect.element.style[k];
458
+ });
459
+
460
+ this.originalTop = this.element.offsetTop;
461
+ this.originalLeft = this.element.offsetLeft;
462
+
463
+ var fontSize = Element.getStyle(this.element,'font-size') || "100%";
464
+ ['em','px','%'].each( function(fontSizeType) {
465
+ if(fontSize.indexOf(fontSizeType)>0) {
466
+ effect.fontSize = parseFloat(fontSize);
467
+ effect.fontSizeType = fontSizeType;
468
+ }
469
+ });
470
+
471
+ this.factor = (this.options.scaleTo - this.options.scaleFrom)/100;
472
+
473
+ this.dims = null;
474
+ if(this.options.scaleMode=='box')
475
+ this.dims = [this.element.clientHeight, this.element.clientWidth];
476
+ if(this.options.scaleMode=='content')
477
+ this.dims = [this.element.scrollHeight, this.element.scrollWidth];
478
+ if(!this.dims)
479
+ this.dims = [this.options.scaleMode.originalHeight,
480
+ this.options.scaleMode.originalWidth];
481
+ },
222
482
  update: function(position) {
223
- currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
224
- if(this.options.scaleContent && this.sizeEm)
225
- this.element.style.fontSize = this.sizeEm*currentScale + "em";
226
- this.setDimensions(
227
- this.originalWidth * currentScale,
228
- this.originalHeight * currentScale);
483
+ var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
484
+ if(this.options.scaleContent && this.fontSize)
485
+ this.element.style.fontSize = this.fontSize*currentScale + this.fontSizeType;
486
+ this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
229
487
  },
230
-
231
- setDimensions: function(width, height) {
232
- if(this.options.scaleX) this.element.style.width = width + 'px';
233
- if(this.options.scaleY) this.element.style.height = height + 'px';
488
+ finish: function(position) {
489
+ if (this.restoreAfterFinish) {
490
+ var effect = this;
491
+ ['top','left','width','height','fontSize'].each( function(k) {
492
+ effect.element.style[k] = effect.originalStyle[k];
493
+ });
494
+ }
495
+ },
496
+ setDimensions: function(height, width) {
497
+ var els = this.element.style;
498
+ if(this.options.scaleX) els.width = width + 'px';
499
+ if(this.options.scaleY) els.height = height + 'px';
234
500
  if(this.options.scaleFromCenter) {
235
- topd = (height - this.originalHeight)/2;
236
- leftd = (width - this.originalWidth)/2;
237
- if(this.element.style.position=='absolute') {
238
- if(this.options.scaleY) this.element.style.top = this.originalTop-topd + "px";
239
- if(this.options.scaleX) this.element.style.left = this.originalLeft-leftd + "px";
501
+ var topd = (height - this.dims[0])/2;
502
+ var leftd = (width - this.dims[1])/2;
503
+ if(this.elementPositioning == 'absolute') {
504
+ if(this.options.scaleY) els.top = this.originalTop-topd + "px";
505
+ if(this.options.scaleX) els.left = this.originalLeft-leftd + "px";
240
506
  } else {
241
- if(this.options.scaleY) this.element.style.top = -topd + "px";
242
- if(this.options.scaleX) this.element.style.left = -leftd + "px";
507
+ if(this.options.scaleY) els.top = -topd + "px";
508
+ if(this.options.scaleX) els.left = -leftd + "px";
243
509
  }
244
510
  }
245
511
  }
@@ -249,44 +515,41 @@ Effect.Highlight = Class.create();
249
515
  Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), {
250
516
  initialize: function(element) {
251
517
  this.element = $(element);
252
-
253
- // try to parse current background color as default for endcolor
254
- // browser stores this as: "rgb(255, 255, 255)", convert to "#ffffff" format
255
- var endcolor = "#ffffff";
256
- var current = this.element.style.backgroundColor;
257
- if(current && current.slice(0,4) == "rgb(") {
258
- endcolor = "#";
259
- var cols = current.slice(4,current.length-1).split(',');
260
- var i=0; do { endcolor += parseInt(cols[i]).toColorPart() } while (++i<3); }
261
-
262
518
  var options = Object.extend({
263
- startcolor: "#ffff99",
264
- endcolor: endcolor,
265
- restorecolor: current
519
+ startcolor: "#ffff99"
266
520
  }, arguments[1] || {});
267
-
521
+ this.start(options);
522
+ },
523
+ setup: function() {
524
+ // Prevent executing on elements not in the layout flow
525
+ if(this.element.style.display=='none') { this.cancel(); return; }
526
+ // Disable background image during the effect
527
+ this.oldBgImage = this.element.style.backgroundImage;
528
+ this.element.style.backgroundImage = "none";
529
+ if(!this.options.endcolor)
530
+ this.options.endcolor = Element.getStyle(this.element, 'background-color').parseColor('#ffffff');
531
+ if (typeof this.options.restorecolor == "undefined")
532
+ this.options.restorecolor = this.element.style.backgroundColor;
268
533
  // init color calculations
269
534
  this.colors_base = [
270
- parseInt(options.startcolor.slice(1,3),16),
271
- parseInt(options.startcolor.slice(3,5),16),
272
- parseInt(options.startcolor.slice(5),16) ];
535
+ parseInt(this.options.startcolor.slice(1,3),16),
536
+ parseInt(this.options.startcolor.slice(3,5),16),
537
+ parseInt(this.options.startcolor.slice(5),16) ];
273
538
  this.colors_delta = [
274
- parseInt(options.endcolor.slice(1,3),16)-this.colors_base[0],
275
- parseInt(options.endcolor.slice(3,5),16)-this.colors_base[1],
276
- parseInt(options.endcolor.slice(5),16)-this.colors_base[2] ];
277
-
278
- this.start(options);
539
+ parseInt(this.options.endcolor.slice(1,3),16)-this.colors_base[0],
540
+ parseInt(this.options.endcolor.slice(3,5),16)-this.colors_base[1],
541
+ parseInt(this.options.endcolor.slice(5),16)-this.colors_base[2]];
279
542
  },
280
543
  update: function(position) {
281
- var colors = [
282
- Math.round(this.colors_base[0]+(this.colors_delta[0]*position)),
283
- Math.round(this.colors_base[1]+(this.colors_delta[1]*position)),
284
- Math.round(this.colors_base[2]+(this.colors_delta[2]*position)) ];
544
+ var effect = this; var colors = $R(0,2).map( function(i){
545
+ return Math.round(effect.colors_base[i]+(effect.colors_delta[i]*position))
546
+ });
285
547
  this.element.style.backgroundColor = "#" +
286
548
  colors[0].toColorPart() + colors[1].toColorPart() + colors[2].toColorPart();
287
549
  },
288
550
  finish: function() {
289
551
  this.element.style.backgroundColor = this.options.restorecolor;
552
+ this.element.style.backgroundImage = this.oldBgImage;
290
553
  }
291
554
  });
292
555
 
@@ -294,6 +557,9 @@ Effect.ScrollTo = Class.create();
294
557
  Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), {
295
558
  initialize: function(element) {
296
559
  this.element = $(element);
560
+ this.start(arguments[1] || {});
561
+ },
562
+ setup: function() {
297
563
  Position.prepare();
298
564
  var offsets = Position.cumulativeOffset(this.element);
299
565
  var max = window.innerHeight ?
@@ -302,8 +568,7 @@ Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), {
302
568
  (document.documentElement.clientHeight ?
303
569
  document.documentElement.clientHeight : document.body.clientHeight);
304
570
  this.scrollStart = Position.deltaY;
305
- this.delta = (offsets[1] > max ? max : offsets[1]) - this.scrollStart;
306
- this.start(arguments[1] || {});
571
+ this.delta = (offsets[1] > max ? max : offsets[1]) - this.scrollStart;
307
572
  },
308
573
  update: function(position) {
309
574
  Position.prepare();
@@ -312,51 +577,61 @@ Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), {
312
577
  }
313
578
  });
314
579
 
315
- /* ------------- prepackaged effects ------------- */
580
+ /* ------------- combination effects ------------- */
316
581
 
317
582
  Effect.Fade = function(element) {
318
- options = Object.extend({
319
- from: 1.0,
583
+ var oldOpacity = Element.getInlineOpacity(element);
584
+ var options = Object.extend({
585
+ from: Element.getOpacity(element) || 1.0,
320
586
  to: 0.0,
321
- afterFinish: function(effect)
322
- { Element.hide(effect.element);
323
- effect.setOpacity(1); }
587
+ afterFinishInternal: function(effect)
588
+ { if (effect.options.to == 0) {
589
+ Element.hide(effect.element);
590
+ Element.setInlineOpacity(effect.element, oldOpacity);
591
+ }
592
+ }
324
593
  }, arguments[1] || {});
325
- new Effect.Opacity(element,options);
594
+ return new Effect.Opacity(element,options);
326
595
  }
327
596
 
328
597
  Effect.Appear = function(element) {
329
- options = Object.extend({
330
- from: 0.0,
598
+ var options = Object.extend({
599
+ from: (Element.getStyle(element, "display") == "none" ? 0.0 : Element.getOpacity(element) || 0.0),
331
600
  to: 1.0,
332
- beforeStart: function(effect)
333
- { effect.setOpacity(0);
334
- Element.show(effect.element); },
335
- afterUpdate: function(effect)
336
- { Element.show(effect.element); }
601
+ beforeSetup: function(effect)
602
+ { Element.setOpacity(effect.element, effect.options.from);
603
+ Element.show(effect.element); }
337
604
  }, arguments[1] || {});
338
- new Effect.Opacity(element,options);
605
+ return new Effect.Opacity(element,options);
339
606
  }
340
607
 
341
608
  Effect.Puff = function(element) {
342
- new Effect.Parallel(
343
- [ new Effect.Scale(element, 200, { sync: true, scaleFromCenter: true }),
344
- new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0 } ) ],
345
- { duration: 1.0,
346
- afterUpdate: function(effect)
609
+ element = $(element);
610
+ var oldOpacity = Element.getInlineOpacity(element);
611
+ var oldPosition = element.style.position;
612
+ return new Effect.Parallel(
613
+ [ new Effect.Scale(element, 200,
614
+ { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }),
615
+ new Effect.Opacity(element, { sync: true, to: 0.0 } ) ],
616
+ Object.extend({ duration: 1.0,
617
+ beforeSetupInternal: function(effect)
347
618
  { effect.effects[0].element.style.position = 'absolute'; },
348
- afterFinish: function(effect)
349
- { Element.hide(effect.effects[0].element); }
350
- }
619
+ afterFinishInternal: function(effect)
620
+ { Element.hide(effect.effects[0].element);
621
+ effect.effects[0].element.style.position = oldPosition;
622
+ Element.setInlineOpacity(effect.effects[0].element, oldOpacity); }
623
+ }, arguments[1] || {})
351
624
  );
352
625
  }
353
626
 
354
627
  Effect.BlindUp = function(element) {
628
+ element = $(element);
355
629
  Element.makeClipping(element);
356
- new Effect.Scale(element, 0,
630
+ return new Effect.Scale(element, 0,
357
631
  Object.extend({ scaleContent: false,
358
632
  scaleX: false,
359
- afterFinish: function(effect)
633
+ restoreAfterFinish: true,
634
+ afterFinishInternal: function(effect)
360
635
  {
361
636
  Element.hide(effect.element);
362
637
  Element.undoClipping(effect.element);
@@ -366,120 +641,179 @@ Effect.BlindUp = function(element) {
366
641
  }
367
642
 
368
643
  Effect.BlindDown = function(element) {
369
- $(element).style.height = '0px';
370
- Element.makeClipping(element);
371
- Element.show(element);
372
- new Effect.Scale(element, 100,
644
+ element = $(element);
645
+ var oldHeight = element.style.height;
646
+ var elementDimensions = Element.getDimensions(element);
647
+ return new Effect.Scale(element, 100,
373
648
  Object.extend({ scaleContent: false,
374
- scaleX: false,
375
- scaleMode: 'contents',
649
+ scaleX: false,
376
650
  scaleFrom: 0,
377
- afterFinish: function(effect) {
651
+ scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
652
+ restoreAfterFinish: true,
653
+ afterSetup: function(effect) {
654
+ Element.makeClipping(effect.element);
655
+ effect.element.style.height = "0px";
656
+ Element.show(effect.element);
657
+ },
658
+ afterFinishInternal: function(effect) {
378
659
  Element.undoClipping(effect.element);
660
+ effect.element.style.height = oldHeight;
379
661
  }
380
662
  }, arguments[1] || {})
381
663
  );
382
664
  }
383
665
 
384
666
  Effect.SwitchOff = function(element) {
385
- new Effect.Appear(element,
386
- { duration: 0.4,
387
- transition: Effect.Transitions.flicker,
388
- afterFinish: function(effect)
389
- { effect.element.style.overflow = 'hidden';
390
- new Effect.Scale(effect.element, 1,
391
- { duration: 0.3, scaleFromCenter: true,
392
- scaleX: false, scaleContent: false,
393
- afterUpdate: function(effect) {
394
- if(effect.element.style.position=="")
395
- effect.element.style.position = 'relative'; },
396
- afterFinish: function(effect) { Element.hide(effect.element); }
397
- } )
398
- }
399
- } );
667
+ element = $(element);
668
+ var oldOpacity = Element.getInlineOpacity(element);
669
+ return new Effect.Appear(element, {
670
+ duration: 0.4,
671
+ from: 0,
672
+ transition: Effect.Transitions.flicker,
673
+ afterFinishInternal: function(effect) {
674
+ new Effect.Scale(effect.element, 1, {
675
+ duration: 0.3, scaleFromCenter: true,
676
+ scaleX: false, scaleContent: false, restoreAfterFinish: true,
677
+ beforeSetup: function(effect) {
678
+ Element.makePositioned(effect.element);
679
+ Element.makeClipping(effect.element);
680
+ },
681
+ afterFinishInternal: function(effect) {
682
+ Element.hide(effect.element);
683
+ Element.undoClipping(effect.element);
684
+ Element.undoPositioned(effect.element);
685
+ Element.setInlineOpacity(effect.element, oldOpacity);
686
+ }
687
+ })
688
+ }
689
+ });
400
690
  }
401
691
 
402
692
  Effect.DropOut = function(element) {
403
- new Effect.Parallel(
693
+ element = $(element);
694
+ var oldTop = element.style.top;
695
+ var oldLeft = element.style.left;
696
+ var oldOpacity = Element.getInlineOpacity(element);
697
+ return new Effect.Parallel(
404
698
  [ new Effect.MoveBy(element, 100, 0, { sync: true }),
405
- new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0 } ) ],
406
- { duration: 0.5,
407
- afterFinish: function(effect)
408
- { Element.hide(effect.effects[0].element); }
409
- });
699
+ new Effect.Opacity(element, { sync: true, to: 0.0 }) ],
700
+ Object.extend(
701
+ { duration: 0.5,
702
+ beforeSetup: function(effect) {
703
+ Element.makePositioned(effect.effects[0].element); },
704
+ afterFinishInternal: function(effect) {
705
+ Element.hide(effect.effects[0].element);
706
+ Element.undoPositioned(effect.effects[0].element);
707
+ effect.effects[0].element.style.left = oldLeft;
708
+ effect.effects[0].element.style.top = oldTop;
709
+ Element.setInlineOpacity(effect.effects[0].element, oldOpacity); }
710
+ }, arguments[1] || {}));
410
711
  }
411
712
 
412
713
  Effect.Shake = function(element) {
413
- new Effect.MoveBy(element, 0, 20,
414
- { duration: 0.05, afterFinish: function(effect) {
714
+ element = $(element);
715
+ var oldTop = element.style.top;
716
+ var oldLeft = element.style.left;
717
+ return new Effect.MoveBy(element, 0, 20,
718
+ { duration: 0.05, afterFinishInternal: function(effect) {
415
719
  new Effect.MoveBy(effect.element, 0, -40,
416
- { duration: 0.1, afterFinish: function(effect) {
720
+ { duration: 0.1, afterFinishInternal: function(effect) {
417
721
  new Effect.MoveBy(effect.element, 0, 40,
418
- { duration: 0.1, afterFinish: function(effect) {
722
+ { duration: 0.1, afterFinishInternal: function(effect) {
419
723
  new Effect.MoveBy(effect.element, 0, -40,
420
- { duration: 0.1, afterFinish: function(effect) {
724
+ { duration: 0.1, afterFinishInternal: function(effect) {
421
725
  new Effect.MoveBy(effect.element, 0, 40,
422
- { duration: 0.1, afterFinish: function(effect) {
726
+ { duration: 0.1, afterFinishInternal: function(effect) {
423
727
  new Effect.MoveBy(effect.element, 0, -20,
424
- { duration: 0.05, afterFinish: function(effect) {
728
+ { duration: 0.05, afterFinishInternal: function(effect) {
729
+ Element.undoPositioned(effect.element);
730
+ effect.element.style.left = oldLeft;
731
+ effect.element.style.top = oldTop;
425
732
  }}) }}) }}) }}) }}) }});
426
733
  }
427
734
 
428
735
  Effect.SlideDown = function(element) {
429
736
  element = $(element);
430
- element.style.height = '0px';
431
- Element.makeClipping(element);
432
737
  Element.cleanWhitespace(element);
433
- Element.makePositioned(element.firstChild);
434
- Element.show(element);
435
- new Effect.Scale(element, 100,
738
+ // SlideDown need to have the content of the element wrapped in a container element with fixed height!
739
+ var oldInnerBottom = element.firstChild.style.bottom;
740
+ var elementDimensions = Element.getDimensions(element);
741
+ return new Effect.Scale(element, 100,
436
742
  Object.extend({ scaleContent: false,
437
743
  scaleX: false,
438
- scaleMode: 'contents',
439
744
  scaleFrom: 0,
440
- afterUpdate: function(effect)
441
- { effect.element.firstChild.style.bottom =
442
- (effect.originalHeight - effect.element.clientHeight) + 'px'; },
443
- afterFinish: function(effect)
444
- { Element.undoClipping(effect.element); }
745
+ scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
746
+ restoreAfterFinish: true,
747
+ afterSetup: function(effect) {
748
+ Element.makePositioned(effect.element.firstChild);
749
+ if (window.opera) effect.element.firstChild.style.top = "";
750
+ Element.makeClipping(effect.element);
751
+ element.style.height = '0';
752
+ Element.show(element);
753
+ },
754
+ afterUpdateInternal: function(effect) {
755
+ effect.element.firstChild.style.bottom =
756
+ (effect.dims[0] - effect.element.clientHeight) + 'px'; },
757
+ afterFinishInternal: function(effect) {
758
+ Element.undoClipping(effect.element);
759
+ Element.undoPositioned(effect.element.firstChild);
760
+ effect.element.firstChild.style.bottom = oldInnerBottom; }
445
761
  }, arguments[1] || {})
446
762
  );
447
763
  }
448
764
 
449
765
  Effect.SlideUp = function(element) {
450
766
  element = $(element);
451
- Element.makeClipping(element);
452
767
  Element.cleanWhitespace(element);
453
- Element.makePositioned(element.firstChild);
454
- Element.show(element);
455
- new Effect.Scale(element, 0,
768
+ var oldInnerBottom = element.firstChild.style.bottom;
769
+ return new Effect.Scale(element, 0,
456
770
  Object.extend({ scaleContent: false,
457
771
  scaleX: false,
458
- afterUpdate: function(effect)
459
- { effect.element.firstChild.style.bottom =
460
- (effect.originalHeight - effect.element.clientHeight) + 'px'; },
461
- afterFinish: function(effect)
462
- {
772
+ scaleMode: 'box',
773
+ scaleFrom: 100,
774
+ restoreAfterFinish: true,
775
+ beforeStartInternal: function(effect) {
776
+ Element.makePositioned(effect.element.firstChild);
777
+ if (window.opera) effect.element.firstChild.style.top = "";
778
+ Element.makeClipping(effect.element);
779
+ Element.show(element);
780
+ },
781
+ afterUpdateInternal: function(effect) {
782
+ effect.element.firstChild.style.bottom =
783
+ (effect.dims[0] - effect.element.clientHeight) + 'px'; },
784
+ afterFinishInternal: function(effect) {
463
785
  Element.hide(effect.element);
464
- Element.undoClipping(effect.element);
465
- }
786
+ Element.undoClipping(effect.element);
787
+ Element.undoPositioned(effect.element.firstChild);
788
+ effect.element.firstChild.style.bottom = oldInnerBottom; }
466
789
  }, arguments[1] || {})
467
790
  );
468
791
  }
469
792
 
470
793
  Effect.Squish = function(element) {
471
- new Effect.Scale(element, 0,
472
- { afterFinish: function(effect) { Element.hide(effect.element); } });
794
+ // Bug in opera makes the TD containing this element expand for a instance after finish
795
+ return new Effect.Scale(element, window.opera ? 1 : 0,
796
+ { restoreAfterFinish: true,
797
+ beforeSetup: function(effect) {
798
+ Element.makeClipping(effect.element); },
799
+ afterFinishInternal: function(effect) {
800
+ Element.hide(effect.element);
801
+ Element.undoClipping(effect.element); }
802
+ });
473
803
  }
474
804
 
475
805
  Effect.Grow = function(element) {
476
806
  element = $(element);
477
807
  var options = arguments[1] || {};
478
808
 
479
- var originalWidth = element.clientWidth;
480
- var originalHeight = element.clientHeight;
481
- element.style.overflow = 'hidden';
482
- Element.show(element);
809
+ var elementDimensions = Element.getDimensions(element);
810
+ var originalWidth = elementDimensions.width;
811
+ var originalHeight = elementDimensions.height;
812
+ var oldTop = element.style.top;
813
+ var oldLeft = element.style.left;
814
+ var oldHeight = element.style.height;
815
+ var oldWidth = element.style.width;
816
+ var oldOpacity = Element.getInlineOpacity(element);
483
817
 
484
818
  var direction = options.direction || 'center';
485
819
  var moveTransition = options.moveTransition || Effect.Transitions.sinoidal;
@@ -517,18 +851,40 @@ Effect.Grow = function(element) {
517
851
  break;
518
852
  }
519
853
 
520
- new Effect.MoveBy(element, initialMoveY, initialMoveX, {
854
+ return new Effect.MoveBy(element, initialMoveY, initialMoveX, {
521
855
  duration: 0.01,
522
- beforeUpdate: function(effect) { $(element).style.height = '0px'; },
523
- afterFinish: function(effect) {
856
+ beforeSetup: function(effect) {
857
+ Element.hide(effect.element);
858
+ Element.makeClipping(effect.element);
859
+ Element.makePositioned(effect.element);
860
+ },
861
+ afterFinishInternal: function(effect) {
524
862
  new Effect.Parallel(
525
- [ new Effect.Opacity(element, { sync: true, to: 1.0, from: 0.0, transition: opacityTransition }),
526
- new Effect.MoveBy(element, moveY, moveX, { sync: true, transition: moveTransition }),
527
- new Effect.Scale(element, 100, {
863
+ [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: opacityTransition }),
864
+ new Effect.MoveBy(effect.element, moveY, moveX, { sync: true, transition: moveTransition }),
865
+ new Effect.Scale(effect.element, 100, {
528
866
  scaleMode: { originalHeight: originalHeight, originalWidth: originalWidth },
529
- sync: true, scaleFrom: 0, scaleTo: 100, transition: scaleTransition })],
530
- options); }
531
- });
867
+ sync: true, scaleFrom: window.opera ? 1 : 0, transition: scaleTransition, restoreAfterFinish: true})
868
+ ], Object.extend({
869
+ beforeSetup: function(effect) {
870
+ effect.effects[0].element.style.height = 0;
871
+ Element.show(effect.effects[0].element);
872
+ },
873
+ afterFinishInternal: function(effect) {
874
+ var el = effect.effects[0].element;
875
+ var els = el.style;
876
+ Element.undoClipping(el);
877
+ Element.undoPositioned(el);
878
+ els.top = oldTop;
879
+ els.left = oldLeft;
880
+ els.height = oldHeight;
881
+ els.width = originalWidth + 'px';
882
+ Element.setInlineOpacity(el, oldOpacity);
883
+ }
884
+ }, options)
885
+ )
886
+ }
887
+ });
532
888
  }
533
889
 
534
890
  Effect.Shrink = function(element) {
@@ -537,8 +893,11 @@ Effect.Shrink = function(element) {
537
893
 
538
894
  var originalWidth = element.clientWidth;
539
895
  var originalHeight = element.clientHeight;
540
- element.style.overflow = 'hidden';
541
- Element.show(element);
896
+ var oldTop = element.style.top;
897
+ var oldLeft = element.style.left;
898
+ var oldHeight = element.style.height;
899
+ var oldWidth = element.style.width;
900
+ var oldOpacity = Element.getInlineOpacity(element);
542
901
 
543
902
  var direction = options.direction || 'center';
544
903
  var moveTransition = options.moveTransition || Effect.Transitions.sinoidal;
@@ -569,44 +928,65 @@ Effect.Shrink = function(element) {
569
928
  break;
570
929
  }
571
930
 
572
- new Effect.Parallel(
931
+ return new Effect.Parallel(
573
932
  [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: opacityTransition }),
574
- new Effect.Scale(element, 0, { sync: true, transition: moveTransition }),
575
- new Effect.MoveBy(element, moveY, moveX, { sync: true, transition: scaleTransition }) ],
576
- options);
933
+ new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: scaleTransition, restoreAfterFinish: true}),
934
+ new Effect.MoveBy(element, moveY, moveX, { sync: true, transition: moveTransition })
935
+ ], Object.extend({
936
+ beforeStartInternal: function(effect) {
937
+ Element.makePositioned(effect.effects[0].element);
938
+ Element.makeClipping(effect.effects[0].element);
939
+ },
940
+ afterFinishInternal: function(effect) {
941
+ var el = effect.effects[0].element;
942
+ var els = el.style;
943
+ Element.hide(el);
944
+ Element.undoClipping(el);
945
+ Element.undoPositioned(el);
946
+ els.top = oldTop;
947
+ els.left = oldLeft;
948
+ els.height = oldHeight;
949
+ els.width = oldWidth;
950
+ Element.setInlineOpacity(el, oldOpacity);
951
+ }
952
+ }, options)
953
+ );
577
954
  }
578
955
 
579
956
  Effect.Pulsate = function(element) {
957
+ element = $(element);
580
958
  var options = arguments[1] || {};
959
+ var oldOpacity = Element.getInlineOpacity(element);
581
960
  var transition = options.transition || Effect.Transitions.sinoidal;
582
961
  var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) };
583
962
  reverser.bind(transition);
584
- new Effect.Opacity(element,
585
- Object.extend(Object.extend({ duration: 3.0,
586
- afterFinish: function(effect) { Element.show(effect.element); }
963
+ return new Effect.Opacity(element,
964
+ Object.extend(Object.extend({ duration: 3.0, from: 0,
965
+ afterFinishInternal: function(effect) { Element.setInlineOpacity(effect.element, oldOpacity); }
587
966
  }, options), {transition: reverser}));
588
967
  }
589
968
 
590
969
  Effect.Fold = function(element) {
591
- $(element).style.overflow = 'hidden';
592
- new Effect.Scale(element, 5, Object.extend({
593
- scaleContent: false,
594
- scaleTo: 100,
595
- scaleX: false,
596
- afterFinish: function(effect) {
597
- new Effect.Scale(element, 1, {
598
- scaleContent: false,
599
- scaleTo: 0,
600
- scaleY: false,
601
- afterFinish: function(effect) { Element.hide(effect.element) } });
602
- }}, arguments[1] || {}));
603
- }
604
-
605
- // old: new Effect.ContentZoom(element, percent)
606
- // new: Element.setContentZoom(element, percent)
607
-
608
- Element.setContentZoom = function(element, percent) {
609
- var element = $(element);
610
- element.style.fontSize = (percent/100) + "em";
611
- if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
970
+ element = $(element);
971
+ var originalTop = element.style.top;
972
+ var originalLeft = element.style.left;
973
+ var originalWidth = element.style.width;
974
+ var originalHeight = element.style.height;
975
+ Element.makeClipping(element);
976
+ return new Effect.Scale(element, 5, Object.extend({
977
+ scaleContent: false,
978
+ scaleX: false,
979
+ afterFinishInternal: function(effect) {
980
+ new Effect.Scale(element, 1, {
981
+ scaleContent: false,
982
+ scaleY: false,
983
+ afterFinishInternal: function(effect) {
984
+ Element.hide(effect.element);
985
+ Element.undoClipping(effect.element);
986
+ effect.element.style.top = originalTop;
987
+ effect.element.style.left = originalLeft;
988
+ effect.element.style.width = originalWidth;
989
+ effect.element.style.height = originalHeight;
990
+ } });
991
+ }}, arguments[1] || {}));
612
992
  }