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.
- data/ChangeLog +193 -0
- data/NEWS +51 -1
- data/README +29 -11
- data/Rakefile +70 -56
- data/bin/rgettext +2 -0
- data/bin/rmsgfmt +2 -0
- data/bin/rmsgmerge +24 -0
- data/data/locale/cs/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/cs/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/de/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/de/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/es/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/fr/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/fr/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/it/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ko/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ko/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/nl/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/nl/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/pt_BR/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/pt_BR/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
- data/ext/gettext/gettext/_locale.BAK +86 -0
- data/ext/gettext/gettext/_locale.c +1 -1
- data/ext/gettext/gettext/_locale.exp +0 -0
- data/ext/gettext/gettext/_locale.lib +0 -0
- data/ext/gettext/gettext/_locale.obj +0 -0
- data/ext/gettext/gettext/_locale.pdb +0 -0
- data/ext/gettext/gettext/_locale.so +0 -0
- data/ext/gettext/gettext/mkmf.log +4 -4
- data/ext/gettext/gettext/vc70.pdb +0 -0
- data/lib/_locale.so +0 -0
- data/lib/gettext.rb +17 -4
- data/lib/gettext/cgi.rb +34 -19
- data/lib/gettext/locale.rb +3 -13
- data/lib/gettext/locale_default.rb +2 -2
- data/lib/gettext/locale_win32.rb +27 -7
- data/lib/gettext/mo.rb +6 -1
- data/lib/gettext/parser/activerecord.rb +115 -0
- data/lib/gettext/parser/glade.rb +3 -1
- data/lib/gettext/parser/ruby.rb +56 -57
- data/lib/gettext/poparser.rb +297 -0
- data/lib/gettext/rails.rb +161 -3
- data/lib/gettext/rgettext.rb +19 -9
- data/lib/gettext/rmsgfmt.rb +95 -363
- data/lib/gettext/rmsgmerge.rb +381 -0
- data/lib/gettext/string.rb +26 -0
- data/lib/gettext/textdomain.rb +21 -18
- data/lib/gettext/utils.rb +55 -0
- data/lib/gettext/version.rb +1 -1
- data/po/cs/rails.po +83 -0
- data/po/cs/rgettext.po +104 -0
- data/po/de/rails.po +79 -0
- data/po/de/rgettext.po +72 -21
- data/po/es/rails.po +80 -0
- data/po/es/rgettext.po +75 -19
- data/po/fr/rails.po +81 -0
- data/po/fr/rgettext.po +75 -19
- data/po/it/rgettext.po +68 -17
- data/po/ja/rails.po +78 -0
- data/po/ja/rgettext.po +71 -20
- data/po/ko/rails.po +77 -0
- data/po/ko/rgettext.po +74 -22
- data/po/nl/rails.po +80 -0
- data/po/nl/rgettext.po +102 -0
- data/po/pt_BR/rails.po +79 -0
- data/po/pt_BR/rgettext.po +77 -24
- data/po/rails.pot +80 -0
- data/po/rgettext.pot +63 -13
- data/po/sv/rgettext.po +63 -15
- data/samples/cgi/cookie.cgi +5 -0
- data/samples/cgi/helloerb1.cgi +4 -0
- data/samples/cgi/helloerb2.cgi +5 -0
- data/samples/cgi/index.cgi +5 -0
- data/samples/cgi/locale/cs/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/cs/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/cs/LC_MESSAGES/hellolib.mo +0 -0
- data/samples/cgi/locale/cs/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/fr/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/ko/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/ko/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/ko/LC_MESSAGES/hellolib.mo +0 -0
- data/samples/cgi/locale/ko/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/nl/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/nl/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/nl/LC_MESSAGES/hellolib.mo +0 -0
- data/samples/cgi/locale/nl/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/pt_BR/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/pt_BR/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/pt_BR/LC_MESSAGES/hellolib.mo +0 -0
- data/samples/cgi/locale/pt_BR/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/po/cs/helloerb1.po +66 -0
- data/samples/cgi/po/cs/helloerb2.po +52 -0
- data/samples/cgi/po/cs/hellolib.po +25 -0
- data/samples/cgi/po/cs/main.po +78 -0
- data/samples/cgi/po/fr/main.po +8 -8
- data/samples/cgi/po/ko/helloerb1.po +2 -3
- data/samples/cgi/po/ko/helloerb2.po +1 -2
- data/samples/cgi/po/ko/hellolib.po +1 -2
- data/samples/cgi/po/ko/main.po +2 -3
- data/samples/cgi/po/nl/helloerb1.po +60 -0
- data/samples/cgi/po/nl/helloerb2.po +52 -0
- data/samples/cgi/po/nl/hellolib.po +24 -0
- data/samples/cgi/po/nl/main.po +76 -0
- data/samples/cgi/po/pt_BR/helloerb1.po +59 -0
- data/samples/cgi/po/pt_BR/helloerb2.po +51 -0
- data/samples/cgi/po/pt_BR/hellolib.po +22 -0
- data/samples/cgi/po/pt_BR/main.po +75 -0
- data/samples/locale/cs/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/cs/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/cs/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/cs/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/cs/LC_MESSAGES/helloglade2.mo +0 -0
- data/samples/locale/cs/LC_MESSAGES/hellogtk.mo +0 -0
- data/samples/locale/cs/LC_MESSAGES/hellotk.mo +0 -0
- data/samples/locale/fr/LC_MESSAGES/helloglade2.mo +0 -0
- data/samples/locale/ko/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/ko/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/ko/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/ko/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/ko/LC_MESSAGES/helloglade2.mo +0 -0
- data/samples/locale/ko/LC_MESSAGES/hellogtk.mo +0 -0
- data/samples/locale/ko/LC_MESSAGES/hellotk.mo +0 -0
- data/samples/locale/nl/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/nl/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/nl/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/nl/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/nl/LC_MESSAGES/helloglade2.mo +0 -0
- data/samples/locale/nl/LC_MESSAGES/hellogtk.mo +0 -0
- data/samples/locale/nl/LC_MESSAGES/hellotk.mo +0 -0
- data/samples/locale/pt_BR/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/pt_BR/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/pt_BR/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/pt_BR/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/pt_BR/LC_MESSAGES/helloglade2.mo +0 -0
- data/samples/locale/pt_BR/LC_MESSAGES/hellogtk.mo +0 -0
- data/samples/locale/pt_BR/LC_MESSAGES/hellotk.mo +0 -0
- data/samples/po/cs/hello.po +23 -0
- data/samples/po/cs/hello2.po +31 -0
- data/samples/po/cs/hello_noop.po +27 -0
- data/samples/po/cs/hello_plural.po +26 -0
- data/samples/po/cs/helloglade2.po +37 -0
- data/samples/po/cs/hellogtk.po +23 -0
- data/samples/po/cs/hellotk.po +23 -0
- data/samples/po/fr/helloglade2.po +2 -2
- data/samples/po/hello.pot +1 -0
- data/samples/po/hello2.pot +1 -0
- data/samples/po/hello_noop.pot +2 -1
- data/samples/po/hello_plural.pot +6 -2
- data/samples/po/helloglade2.pot +8 -3
- data/samples/po/hellotk.pot +4 -0
- data/samples/po/ko/hello.po +1 -2
- data/samples/po/ko/hello2.po +1 -2
- data/samples/po/ko/hello_noop.po +1 -2
- data/samples/po/ko/hello_plural.po +1 -2
- data/samples/po/ko/helloglade2.po +2 -2
- data/samples/po/ko/hellogtk.po +1 -2
- data/samples/po/ko/hellotk.po +1 -2
- data/samples/po/nl/hello.po +24 -0
- data/samples/po/nl/hello2.po +32 -0
- data/samples/po/nl/hello_noop.po +28 -0
- data/samples/po/nl/hello_plural.po +26 -0
- data/samples/po/nl/helloglade2.po +31 -0
- data/samples/po/nl/hellogtk.po +24 -0
- data/samples/po/nl/hellotk.po +24 -0
- data/samples/po/pt_BR/hello.po +6 -5
- data/samples/po/pt_BR/hello2.po +6 -5
- data/samples/po/pt_BR/hello_noop.po +6 -5
- data/samples/po/pt_BR/hello_plural.po +6 -6
- data/samples/po/pt_BR/helloglade2.po +6 -5
- data/samples/po/pt_BR/hellogtk.po +6 -5
- data/samples/po/pt_BR/hellotk.po +6 -5
- data/samples/rails/README +21 -15
- data/samples/rails/Rakefile +10 -1
- data/samples/rails/app/controllers/application.rb +10 -18
- data/samples/rails/app/controllers/blog_controller.rb +1 -5
- data/samples/rails/app/helpers/blog_helper.rb +1 -1
- data/samples/rails/app/models/article.rb +15 -0
- data/samples/rails/app/views/blog/_form.rhtml +2 -2
- data/samples/rails/config/boot.rb +17 -0
- data/samples/rails/config/database.yml +6 -4
- data/samples/rails/config/environment.rb +40 -75
- data/samples/rails/config/environments/development.rb +12 -7
- data/samples/rails/config/environments/production.rb +17 -6
- data/samples/rails/config/environments/test.rb +8 -6
- data/samples/rails/locale/cs/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/cs/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/de/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/de/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/en/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/es/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/es/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/fr/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/fr/LC_MESSAGES/{lang_helper.mo → gettext_plugin.mo} +0 -0
- data/samples/rails/locale/ja/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ja/LC_MESSAGES/{lang_helper.mo → gettext_plugin.mo} +0 -0
- data/samples/rails/locale/ko/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ko/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/nl/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/nl/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/pt_BR/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/pt_BR/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/po/blog.pot +57 -37
- data/samples/rails/po/cs/blog.po +116 -0
- data/samples/rails/po/cs/gettext_plugin.po +29 -0
- data/samples/rails/po/de/blog.po +70 -51
- data/samples/rails/po/de/{lang_helper.po → gettext_plugin.po} +4 -5
- data/samples/rails/po/en/blog.po +111 -0
- data/samples/rails/po/es/blog.po +67 -47
- data/samples/rails/po/es/{lang_helper.po → gettext_plugin.po} +5 -5
- data/samples/rails/po/fr/blog.po +65 -45
- data/samples/rails/po/fr/{lang_helper.po → gettext_plugin.po} +4 -4
- data/samples/rails/po/{lang_helper.pot → gettext_plugin.pot} +4 -4
- data/samples/rails/po/ja/blog.po +64 -44
- data/samples/rails/po/ja/{lang_helper.po → gettext_plugin.po} +4 -4
- data/samples/rails/po/ko/blog.po +65 -46
- data/samples/rails/po/ko/{lang_helper.po → gettext_plugin.po} +5 -6
- data/samples/rails/po/nl/blog.po +115 -0
- data/samples/rails/po/nl/gettext_plugin.po +28 -0
- data/samples/rails/po/pt_BR/blog.po +109 -0
- data/samples/rails/po/pt_BR/gettext_plugin.po +27 -0
- data/samples/rails/public/images/rails.png +0 -0
- data/samples/rails/public/index.html +272 -71
- data/samples/rails/public/javascripts/controls.js +441 -166
- data/samples/rails/public/javascripts/dragdrop.js +261 -279
- data/samples/rails/public/javascripts/effects.js +657 -277
- data/samples/rails/public/javascripts/prototype.js +911 -223
- data/samples/rails/public/robots.txt +1 -0
- data/samples/rails/public/stylesheets/scaffold.css +1 -1
- data/samples/rails/script/about +3 -0
- data/samples/rails/script/breakpointer +3 -4
- data/samples/rails/script/console +3 -23
- data/samples/rails/script/destroy +3 -7
- data/samples/rails/script/generate +3 -7
- data/samples/rails/script/performance/benchmarker +3 -0
- data/samples/rails/script/performance/profiler +3 -0
- data/samples/rails/script/plugin +3 -0
- data/samples/rails/script/process/reaper +3 -0
- data/samples/rails/script/process/spawner +3 -0
- data/samples/rails/script/process/spinner +3 -0
- data/samples/rails/script/runner +3 -29
- data/samples/rails/script/server +3 -49
- data/samples/rails/vendor/plugins/gettext/init.rb +19 -0
- data/samples/rails/vendor/{lang_helper.rb → plugins/gettext/lib/gettext_plugin.rb} +15 -11
- data/src/poparser.ry +171 -0
- data/test/gettext_runner.rb +3 -1
- data/test/gettext_test.rb +56 -31
- data/test/gettext_test_cgi.rb +12 -0
- data/test/gettext_test_parser.rb +3 -0
- data/test/gettext_test_string.rb +14 -0
- data/test/locale/cr/LC_MESSAGES/plural.mo +0 -0
- data/test/locale/da/LC_MESSAGES/plural.mo +0 -0
- data/test/locale/da/LC_MESSAGES/plural_error.mo +0 -0
- data/test/locale/fr/LC_MESSAGES/plural.mo +0 -0
- data/test/locale/fr/LC_MESSAGES/plural_error.mo +0 -0
- data/test/locale/ir/LC_MESSAGES/plural.mo +0 -0
- data/test/locale/la/LC_MESSAGES/plural.mo +0 -0
- data/test/locale/li/LC_MESSAGES/plural.mo +0 -0
- data/test/locale/po/LC_MESSAGES/plural.mo +0 -0
- data/test/locale/sl/LC_MESSAGES/plural.mo +0 -0
- data/test/po/cr/plural.po +3 -3
- data/test/po/da/plural.po +2 -2
- data/test/po/da/plural_error.po +2 -1
- data/test/po/fr/plural.po +2 -2
- data/test/po/fr/plural_error.po +2 -1
- data/test/po/ir/plural.po +3 -3
- data/test/po/la/plural.po +3 -3
- data/test/po/li/plural.po +3 -3
- data/test/po/po/plural.po +3 -3
- data/test/po/sl/plural.po +4 -4
- data/test/test.sh +1 -0
- data/test/test_rubyparser.rb +20 -0
- data/test/{test_rubyparser_n.rb → test_rubyparser_N.rb} +0 -0
- metadata +163 -43
- data/README.ja +0 -115
- data/data/locale/de/LC_MESSAGES/rmsgfmt.mo +0 -0
- data/data/locale/es/LC_MESSAGES/rmsgfmt.mo +0 -0
- data/data/locale/fr/LC_MESSAGES/rmsgfmt.mo +0 -0
- data/data/locale/it/LC_MESSAGES/rmsgfmt.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/rmsgfmt.mo +0 -0
- data/data/locale/ko/LC_MESSAGES/rmsgfmt.mo +0 -0
- data/data/locale/pt_BR/LC_MESSAGES/rmsgfmt.mo +0 -0
- data/data/locale/sv/LC_MESSAGES/rmsgfmt.mo +0 -0
- data/gettext-1.0.0-mswin32.gem +0 -0
- data/po/de/rmsgfmt.po +0 -45
- data/po/es/rmsgfmt.po +0 -43
- data/po/fr/rmsgfmt.po +0 -43
- data/po/it/rmsgfmt.po +0 -44
- data/po/ja/rmsgfmt.po +0 -43
- data/po/ko/rmsgfmt.po +0 -40
- data/po/pt_BR/rmsgfmt.po +0 -42
- data/po/rmsgfmt.pot +0 -40
- data/po/sv/rmsgfmt.po +0 -43
- data/samples/rails/locale/de/LC_MESSAGES/lang_helper.mo +0 -0
- data/samples/rails/locale/es/LC_MESSAGES/lang_helper.mo +0 -0
- data/samples/rails/locale/ko/LC_MESSAGES/lang_helper.mo +0 -0
- data/samples/rails/log/development.log +0 -378
- data/src/rmsgfmt.ry +0 -233
@@ -2,193 +2,79 @@
|
|
2
2
|
//
|
3
3
|
// Element.Class part Copyright (c) 2005 by Rick Olson
|
4
4
|
//
|
5
|
-
//
|
6
|
-
// a copy of this software and associated documentation files (the
|
7
|
-
// "Software"), to deal in the Software without restriction, including
|
8
|
-
// without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
// distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
// permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
// the following conditions:
|
12
|
-
//
|
13
|
-
// The above copyright notice and this permission notice shall be
|
14
|
-
// included in all copies or substantial portions of the Software.
|
15
|
-
//
|
16
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
-
|
24
|
-
Element.Class = {
|
25
|
-
// Element.toggleClass(element, className) toggles the class being on/off
|
26
|
-
// Element.toggleClass(element, className1, className2) toggles between both classes,
|
27
|
-
// defaulting to className1 if neither exist
|
28
|
-
toggle: function(element, className) {
|
29
|
-
if(Element.Class.has(element, className)) {
|
30
|
-
Element.Class.remove(element, className);
|
31
|
-
if(arguments.length == 3) Element.Class.add(element, arguments[2]);
|
32
|
-
} else {
|
33
|
-
Element.Class.add(element, className);
|
34
|
-
if(arguments.length == 3) Element.Class.remove(element, arguments[2]);
|
35
|
-
}
|
36
|
-
},
|
37
|
-
|
38
|
-
// gets space-delimited classnames of an element as an array
|
39
|
-
get: function(element) {
|
40
|
-
element = $(element);
|
41
|
-
return element.className.split(' ');
|
42
|
-
},
|
43
|
-
|
44
|
-
// functions adapted from original functions by Gavin Kistner
|
45
|
-
remove: function(element) {
|
46
|
-
element = $(element);
|
47
|
-
var regEx;
|
48
|
-
for(var i = 1; i < arguments.length; i++) {
|
49
|
-
regEx = new RegExp("^" + arguments[i] + "\\b\\s*|\\s*\\b" + arguments[i] + "\\b", 'g');
|
50
|
-
element.className = element.className.replace(regEx, '')
|
51
|
-
}
|
52
|
-
},
|
53
|
-
|
54
|
-
add: function(element) {
|
55
|
-
element = $(element);
|
56
|
-
for(var i = 1; i < arguments.length; i++) {
|
57
|
-
Element.Class.remove(element, arguments[i]);
|
58
|
-
element.className += (element.className.length > 0 ? ' ' : '') + arguments[i];
|
59
|
-
}
|
60
|
-
},
|
61
|
-
|
62
|
-
// returns true if all given classes exist in said element
|
63
|
-
has: function(element) {
|
64
|
-
element = $(element);
|
65
|
-
if(!element || !element.className) return false;
|
66
|
-
var regEx;
|
67
|
-
for(var i = 1; i < arguments.length; i++) {
|
68
|
-
regEx = new RegExp("\\b" + arguments[i] + "\\b");
|
69
|
-
if(!regEx.test(element.className)) return false;
|
70
|
-
}
|
71
|
-
return true;
|
72
|
-
},
|
73
|
-
|
74
|
-
// expects arrays of strings and/or strings as optional paramters
|
75
|
-
// Element.Class.has_any(element, ['classA','classB','classC'], 'classD')
|
76
|
-
has_any: function(element) {
|
77
|
-
element = $(element);
|
78
|
-
if(!element || !element.className) return false;
|
79
|
-
var regEx;
|
80
|
-
for(var i = 1; i < arguments.length; i++) {
|
81
|
-
if((typeof arguments[i] == 'object') &&
|
82
|
-
(arguments[i].constructor == Array)) {
|
83
|
-
for(var j = 0; j < arguments[i].length; j++) {
|
84
|
-
regEx = new RegExp("\\b" + arguments[i][j] + "\\b");
|
85
|
-
if(regEx.test(element.className)) return true;
|
86
|
-
}
|
87
|
-
} else {
|
88
|
-
regEx = new RegExp("\\b" + arguments[i] + "\\b");
|
89
|
-
if(regEx.test(element.className)) return true;
|
90
|
-
}
|
91
|
-
}
|
92
|
-
return false;
|
93
|
-
},
|
94
|
-
|
95
|
-
childrenWith: function(element, className) {
|
96
|
-
var children = $(element).getElementsByTagName('*');
|
97
|
-
var elements = new Array();
|
98
|
-
|
99
|
-
for (var i = 0; i < children.length; i++) {
|
100
|
-
if (Element.Class.has(children[i], className)) {
|
101
|
-
elements.push(children[i]);
|
102
|
-
break;
|
103
|
-
}
|
104
|
-
}
|
105
|
-
|
106
|
-
return elements;
|
107
|
-
}
|
108
|
-
}
|
5
|
+
// See scriptaculous.js for full license.
|
109
6
|
|
110
7
|
/*--------------------------------------------------------------------------*/
|
111
8
|
|
112
9
|
var Droppables = {
|
113
|
-
drops:
|
114
|
-
|
10
|
+
drops: [],
|
11
|
+
|
115
12
|
remove: function(element) {
|
116
|
-
|
117
|
-
if(this.drops[i].element == element)
|
118
|
-
this.drops.splice(i,1);
|
13
|
+
this.drops = this.drops.reject(function(d) { return d.element==element });
|
119
14
|
},
|
120
|
-
|
15
|
+
|
121
16
|
add: function(element) {
|
122
|
-
|
17
|
+
element = $(element);
|
123
18
|
var options = Object.extend({
|
124
19
|
greedy: true,
|
125
20
|
hoverclass: null
|
126
21
|
}, arguments[1] || {});
|
127
|
-
|
22
|
+
|
128
23
|
// cache containers
|
129
24
|
if(options.containment) {
|
130
|
-
options._containers =
|
25
|
+
options._containers = [];
|
131
26
|
var containment = options.containment;
|
132
27
|
if((typeof containment == 'object') &&
|
133
28
|
(containment.constructor == Array)) {
|
134
|
-
|
135
|
-
options._containers.push($(containment[i]));
|
29
|
+
containment.each( function(c) { options._containers.push($(c)) });
|
136
30
|
} else {
|
137
31
|
options._containers.push($(containment));
|
138
32
|
}
|
139
|
-
options._containers_length =
|
140
|
-
options._containers.length-1;
|
141
33
|
}
|
142
|
-
|
34
|
+
|
143
35
|
Element.makePositioned(element); // fix IE
|
144
|
-
|
145
36
|
options.element = element;
|
146
|
-
|
147
|
-
// activate the droppable
|
148
|
-
if(!this.drops) this.drops = [];
|
37
|
+
|
149
38
|
this.drops.push(options);
|
150
39
|
},
|
151
|
-
|
152
|
-
|
153
|
-
var containers = drop._containers;
|
40
|
+
|
41
|
+
isContained: function(element, drop) {
|
154
42
|
var parentNode = element.parentNode;
|
155
|
-
|
156
|
-
do { if(parentNode==containers[i]) return true; } while (i--);
|
157
|
-
return false;
|
43
|
+
return drop._containers.detect(function(c) { return parentNode == c });
|
158
44
|
},
|
159
|
-
|
160
|
-
|
45
|
+
|
46
|
+
isAffected: function(pX, pY, element, drop) {
|
161
47
|
return (
|
162
48
|
(drop.element!=element) &&
|
163
49
|
((!drop._containers) ||
|
164
|
-
this.
|
50
|
+
this.isContained(element, drop)) &&
|
165
51
|
((!drop.accept) ||
|
166
52
|
(Element.Class.has_any(element, drop.accept))) &&
|
167
53
|
Position.within(drop.element, pX, pY) );
|
168
54
|
},
|
169
|
-
|
55
|
+
|
170
56
|
deactivate: function(drop) {
|
171
|
-
|
57
|
+
if(drop.hoverclass)
|
58
|
+
Element.Class.remove(drop.element, drop.hoverclass);
|
172
59
|
this.last_active = null;
|
173
60
|
},
|
174
|
-
|
61
|
+
|
175
62
|
activate: function(drop) {
|
176
63
|
if(this.last_active) this.deactivate(this.last_active);
|
177
|
-
if(drop.hoverclass)
|
64
|
+
if(drop.hoverclass)
|
178
65
|
Element.Class.add(drop.element, drop.hoverclass);
|
179
|
-
|
180
|
-
}
|
66
|
+
this.last_active = drop;
|
181
67
|
},
|
182
|
-
|
68
|
+
|
183
69
|
show: function(event, element) {
|
184
|
-
if(!this.drops) return;
|
70
|
+
if(!this.drops.length) return;
|
185
71
|
var pX = Event.pointerX(event);
|
186
72
|
var pY = Event.pointerY(event);
|
187
73
|
Position.prepare();
|
188
|
-
|
74
|
+
|
189
75
|
var i = this.drops.length-1; do {
|
190
76
|
var drop = this.drops[i];
|
191
|
-
if(this.
|
77
|
+
if(this.isAffected(pX, pY, element, drop)) {
|
192
78
|
if(drop.onHover)
|
193
79
|
drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));
|
194
80
|
if(drop.greedy) {
|
@@ -197,43 +83,41 @@ var Droppables = {
|
|
197
83
|
}
|
198
84
|
}
|
199
85
|
} while (i--);
|
86
|
+
|
87
|
+
if(this.last_active) this.deactivate(this.last_active);
|
200
88
|
},
|
201
|
-
|
89
|
+
|
202
90
|
fire: function(event, element) {
|
203
91
|
if(!this.last_active) return;
|
204
92
|
Position.prepare();
|
205
|
-
|
206
|
-
if (this.
|
93
|
+
|
94
|
+
if (this.isAffected(Event.pointerX(event), Event.pointerY(event), element, this.last_active))
|
207
95
|
if (this.last_active.onDrop)
|
208
|
-
this.last_active.onDrop(element, this.last_active);
|
209
|
-
|
96
|
+
this.last_active.onDrop(element, this.last_active.element, event);
|
210
97
|
},
|
211
|
-
|
98
|
+
|
212
99
|
reset: function() {
|
213
100
|
if(this.last_active)
|
214
101
|
this.deactivate(this.last_active);
|
215
102
|
}
|
216
103
|
}
|
217
104
|
|
218
|
-
Draggables = {
|
219
|
-
observers:
|
105
|
+
var Draggables = {
|
106
|
+
observers: [],
|
220
107
|
addObserver: function(observer) {
|
221
108
|
this.observers.push(observer);
|
222
109
|
},
|
223
110
|
removeObserver: function(element) { // element instead of obsever fixes mem leaks
|
224
|
-
|
225
|
-
if(this.observers[i].element && (this.observers[i].element == element))
|
226
|
-
this.observers.splice(i,1);
|
111
|
+
this.observers = this.observers.reject( function(o) { return o.element==element });
|
227
112
|
},
|
228
113
|
notify: function(eventName, draggable) { // 'onStart', 'onEnd'
|
229
|
-
|
230
|
-
this.observers[i][eventName](draggable);
|
114
|
+
this.observers.invoke(eventName, draggable);
|
231
115
|
}
|
232
116
|
}
|
233
117
|
|
234
118
|
/*--------------------------------------------------------------------------*/
|
235
119
|
|
236
|
-
Draggable = Class.create();
|
120
|
+
var Draggable = Class.create();
|
237
121
|
Draggable.prototype = {
|
238
122
|
initialize: function(element) {
|
239
123
|
var options = Object.extend({
|
@@ -242,7 +126,8 @@ Draggable.prototype = {
|
|
242
126
|
new Effect.Opacity(element, {duration:0.2, from:1.0, to:0.7});
|
243
127
|
},
|
244
128
|
reverteffect: function(element, top_offset, left_offset) {
|
245
|
-
|
129
|
+
var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02;
|
130
|
+
new Effect.MoveBy(element, -top_offset, -left_offset, {duration:dur});
|
246
131
|
},
|
247
132
|
endeffect: function(element) {
|
248
133
|
new Effect.Opacity(element, {duration:0.2, from:0.7, to:1.0});
|
@@ -250,40 +135,50 @@ Draggable.prototype = {
|
|
250
135
|
zindex: 1000,
|
251
136
|
revert: false
|
252
137
|
}, arguments[1] || {});
|
253
|
-
|
138
|
+
|
254
139
|
this.element = $(element);
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
140
|
+
if(options.handle && (typeof options.handle == 'string'))
|
141
|
+
this.handle = Element.Class.childrenWith(this.element, options.handle)[0];
|
142
|
+
|
143
|
+
if(!this.handle) this.handle = $(options.handle);
|
144
|
+
if(!this.handle) this.handle = this.element;
|
145
|
+
|
146
|
+
Element.makePositioned(this.element); // fix IE
|
147
|
+
|
259
148
|
this.offsetX = 0;
|
260
149
|
this.offsetY = 0;
|
261
150
|
this.originalLeft = this.currentLeft();
|
262
151
|
this.originalTop = this.currentTop();
|
263
152
|
this.originalX = this.element.offsetLeft;
|
264
153
|
this.originalY = this.element.offsetTop;
|
265
|
-
|
266
|
-
|
154
|
+
|
267
155
|
this.options = options;
|
268
|
-
|
156
|
+
|
269
157
|
this.active = false;
|
270
158
|
this.dragging = false;
|
271
|
-
|
159
|
+
|
272
160
|
this.eventMouseDown = this.startDrag.bindAsEventListener(this);
|
273
161
|
this.eventMouseUp = this.endDrag.bindAsEventListener(this);
|
274
162
|
this.eventMouseMove = this.update.bindAsEventListener(this);
|
275
163
|
this.eventKeypress = this.keyPress.bindAsEventListener(this);
|
276
164
|
|
277
|
-
|
165
|
+
this.registerEvents();
|
166
|
+
},
|
167
|
+
destroy: function() {
|
168
|
+
Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
|
169
|
+
this.unregisterEvents();
|
170
|
+
},
|
171
|
+
registerEvents: function() {
|
278
172
|
Event.observe(document, "mouseup", this.eventMouseUp);
|
279
173
|
Event.observe(document, "mousemove", this.eventMouseMove);
|
280
174
|
Event.observe(document, "keypress", this.eventKeypress);
|
175
|
+
Event.observe(this.handle, "mousedown", this.eventMouseDown);
|
281
176
|
},
|
282
|
-
|
283
|
-
|
284
|
-
Event.stopObserving(document, "mouseup", this.eventMouseUp);
|
285
|
-
Event.stopObserving(document, "mousemove", this.eventMouseMove);
|
286
|
-
Event.stopObserving(document, "keypress", this.eventKeypress);
|
177
|
+
unregisterEvents: function() {
|
178
|
+
//if(!this.active) return;
|
179
|
+
//Event.stopObserving(document, "mouseup", this.eventMouseUp);
|
180
|
+
//Event.stopObserving(document, "mousemove", this.eventMouseMove);
|
181
|
+
//Event.stopObserving(document, "keypress", this.eventKeypress);
|
287
182
|
},
|
288
183
|
currentLeft: function() {
|
289
184
|
return parseInt(this.element.style.left || '0');
|
@@ -293,27 +188,42 @@ Draggable.prototype = {
|
|
293
188
|
},
|
294
189
|
startDrag: function(event) {
|
295
190
|
if(Event.isLeftClick(event)) {
|
296
|
-
this.active = true;
|
297
191
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
192
|
+
// abort on form elements, fixes a Firefox issue
|
193
|
+
var src = Event.element(event);
|
194
|
+
if(src.tagName && (
|
195
|
+
src.tagName=='INPUT' ||
|
196
|
+
src.tagName=='SELECT' ||
|
197
|
+
src.tagName=='BUTTON' ||
|
198
|
+
src.tagName=='TEXTAREA')) return;
|
303
199
|
|
200
|
+
// this.registerEvents();
|
201
|
+
this.active = true;
|
202
|
+
var pointer = [Event.pointerX(event), Event.pointerY(event)];
|
203
|
+
var offsets = Position.cumulativeOffset(this.element);
|
204
|
+
this.offsetX = (pointer[0] - offsets[0]);
|
205
|
+
this.offsetY = (pointer[1] - offsets[1]);
|
304
206
|
Event.stop(event);
|
305
207
|
}
|
306
208
|
},
|
307
209
|
finishDrag: function(event, success) {
|
210
|
+
// this.unregisterEvents();
|
211
|
+
|
308
212
|
this.active = false;
|
309
213
|
this.dragging = false;
|
310
|
-
|
214
|
+
|
215
|
+
if(this.options.ghosting) {
|
216
|
+
Position.relativize(this.element);
|
217
|
+
Element.remove(this._clone);
|
218
|
+
this._clone = null;
|
219
|
+
}
|
220
|
+
|
311
221
|
if(success) Droppables.fire(event, this.element);
|
312
222
|
Draggables.notify('onEnd', this);
|
313
|
-
|
223
|
+
|
314
224
|
var revert = this.options.revert;
|
315
225
|
if(revert && typeof revert == 'function') revert = revert(this.element);
|
316
|
-
|
226
|
+
|
317
227
|
if(revert && this.options.reverteffect) {
|
318
228
|
this.options.reverteffect(this.element,
|
319
229
|
this.currentTop()-this.originalTop,
|
@@ -322,12 +232,14 @@ Draggable.prototype = {
|
|
322
232
|
this.originalLeft = this.currentLeft();
|
323
233
|
this.originalTop = this.currentTop();
|
324
234
|
}
|
325
|
-
|
326
|
-
this.
|
327
|
-
|
235
|
+
|
236
|
+
if(this.options.zindex)
|
237
|
+
this.element.style.zIndex = this.originalZ;
|
238
|
+
|
328
239
|
if(this.options.endeffect)
|
329
240
|
this.options.endeffect(this.element);
|
330
|
-
|
241
|
+
|
242
|
+
|
331
243
|
Droppables.reset();
|
332
244
|
},
|
333
245
|
keyPress: function(event) {
|
@@ -347,13 +259,15 @@ Draggable.prototype = {
|
|
347
259
|
this.dragging = false;
|
348
260
|
},
|
349
261
|
draw: function(event) {
|
262
|
+
var pointer = [Event.pointerX(event), Event.pointerY(event)];
|
263
|
+
var offsets = Position.cumulativeOffset(this.element);
|
264
|
+
offsets[0] -= this.currentLeft();
|
265
|
+
offsets[1] -= this.currentTop();
|
350
266
|
var style = this.element.style;
|
351
|
-
this.originalX = this.element.offsetLeft - this.currentLeft() - this.originalLeft;
|
352
|
-
this.originalY = this.element.offsetTop - this.currentTop() - this.originalTop;
|
353
267
|
if((!this.options.constraint) || (this.options.constraint=='horizontal'))
|
354
|
-
style.left = (
|
268
|
+
style.left = (pointer[0] - offsets[0] - this.offsetX) + "px";
|
355
269
|
if((!this.options.constraint) || (this.options.constraint=='vertical'))
|
356
|
-
style.top = (
|
270
|
+
style.top = (pointer[1] - offsets[1] - this.offsetY) + "px";
|
357
271
|
if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
|
358
272
|
},
|
359
273
|
update: function(event) {
|
@@ -361,19 +275,32 @@ Draggable.prototype = {
|
|
361
275
|
if(!this.dragging) {
|
362
276
|
var style = this.element.style;
|
363
277
|
this.dragging = true;
|
364
|
-
|
365
|
-
|
278
|
+
|
279
|
+
if(Element.getStyle(this.element,'position')=='')
|
280
|
+
style.position = "relative";
|
281
|
+
|
282
|
+
if(this.options.zindex) {
|
283
|
+
this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
|
284
|
+
style.zIndex = this.options.zindex;
|
285
|
+
}
|
286
|
+
|
287
|
+
if(this.options.ghosting) {
|
288
|
+
this._clone = this.element.cloneNode(true);
|
289
|
+
Position.absolutize(this.element);
|
290
|
+
this.element.parentNode.insertBefore(this._clone, this.element);
|
291
|
+
}
|
292
|
+
|
366
293
|
Draggables.notify('onStart', this);
|
367
294
|
if(this.options.starteffect) this.options.starteffect(this.element);
|
368
295
|
}
|
369
|
-
|
296
|
+
|
370
297
|
Droppables.show(event, this.element);
|
371
298
|
this.draw(event);
|
372
299
|
if(this.options.change) this.options.change(this);
|
373
|
-
|
300
|
+
|
374
301
|
// fix AppleWebKit rendering
|
375
302
|
if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
|
376
|
-
|
303
|
+
|
377
304
|
Event.stop(event);
|
378
305
|
}
|
379
306
|
}
|
@@ -381,7 +308,7 @@ Draggable.prototype = {
|
|
381
308
|
|
382
309
|
/*--------------------------------------------------------------------------*/
|
383
310
|
|
384
|
-
SortableObserver = Class.create();
|
311
|
+
var SortableObserver = Class.create();
|
385
312
|
SortableObserver.prototype = {
|
386
313
|
initialize: function(element, observer) {
|
387
314
|
this.element = $(element);
|
@@ -391,147 +318,202 @@ SortableObserver.prototype = {
|
|
391
318
|
onStart: function() {
|
392
319
|
this.lastValue = Sortable.serialize(this.element);
|
393
320
|
},
|
394
|
-
onEnd: function() {
|
321
|
+
onEnd: function() {
|
322
|
+
Sortable.unmark();
|
395
323
|
if(this.lastValue != Sortable.serialize(this.element))
|
396
324
|
this.observer(this.element)
|
397
325
|
}
|
398
326
|
}
|
399
327
|
|
400
|
-
Sortable = {
|
328
|
+
var Sortable = {
|
401
329
|
sortables: new Array(),
|
402
330
|
options: function(element){
|
403
|
-
|
404
|
-
|
405
|
-
if(this.sortables[i].element == element)
|
406
|
-
return this.sortables[i];
|
407
|
-
return null;
|
331
|
+
element = $(element);
|
332
|
+
return this.sortables.detect(function(s) { return s.element == element });
|
408
333
|
},
|
409
334
|
destroy: function(element){
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
for(var j=0;j<s.draggables.length;j++)
|
418
|
-
s.draggables[j].destroy();
|
419
|
-
this.sortables.splice(i,1);
|
420
|
-
}
|
421
|
-
}
|
335
|
+
element = $(element);
|
336
|
+
this.sortables.findAll(function(s) { return s.element == element }).each(function(s){
|
337
|
+
Draggables.removeObserver(s.element);
|
338
|
+
s.droppables.each(function(d){ Droppables.remove(d) });
|
339
|
+
s.draggables.invoke('destroy');
|
340
|
+
});
|
341
|
+
this.sortables = this.sortables.reject(function(s) { return s.element == element });
|
422
342
|
},
|
423
343
|
create: function(element) {
|
424
|
-
|
344
|
+
element = $(element);
|
425
345
|
var options = Object.extend({
|
426
346
|
element: element,
|
427
347
|
tag: 'li', // assumes li children, override with tag: 'tagname'
|
348
|
+
dropOnEmpty: false,
|
349
|
+
tree: false, // fixme: unimplemented
|
428
350
|
overlap: 'vertical', // one of 'vertical', 'horizontal'
|
429
351
|
constraint: 'vertical', // one of 'vertical', 'horizontal', false
|
430
352
|
containment: element, // also takes array of elements (or id's); or false
|
431
353
|
handle: false, // or a CSS class
|
432
354
|
only: false,
|
433
355
|
hoverclass: null,
|
434
|
-
|
435
|
-
|
356
|
+
ghosting: false,
|
357
|
+
format: null,
|
358
|
+
onChange: Prototype.emptyFunction,
|
359
|
+
onUpdate: Prototype.emptyFunction
|
436
360
|
}, arguments[1] || {});
|
437
|
-
|
361
|
+
|
438
362
|
// clear any old sortable with same element
|
439
363
|
this.destroy(element);
|
440
|
-
|
364
|
+
|
441
365
|
// build options for the draggables
|
442
366
|
var options_for_draggable = {
|
443
367
|
revert: true,
|
368
|
+
ghosting: options.ghosting,
|
444
369
|
constraint: options.constraint,
|
445
|
-
handle: handle };
|
370
|
+
handle: options.handle };
|
371
|
+
|
446
372
|
if(options.starteffect)
|
447
373
|
options_for_draggable.starteffect = options.starteffect;
|
374
|
+
|
448
375
|
if(options.reverteffect)
|
449
376
|
options_for_draggable.reverteffect = options.reverteffect;
|
377
|
+
else
|
378
|
+
if(options.ghosting) options_for_draggable.reverteffect = function(element) {
|
379
|
+
element.style.top = 0;
|
380
|
+
element.style.left = 0;
|
381
|
+
};
|
382
|
+
|
450
383
|
if(options.endeffect)
|
451
384
|
options_for_draggable.endeffect = options.endeffect;
|
385
|
+
|
452
386
|
if(options.zindex)
|
453
387
|
options_for_draggable.zindex = options.zindex;
|
454
|
-
|
388
|
+
|
455
389
|
// build options for the droppables
|
456
390
|
var options_for_droppable = {
|
457
391
|
overlap: options.overlap,
|
458
392
|
containment: options.containment,
|
459
393
|
hoverclass: options.hoverclass,
|
460
|
-
onHover:
|
461
|
-
|
462
|
-
if(dropon.previousSibling != element) {
|
463
|
-
var oldParentNode = element.parentNode;
|
464
|
-
element.style.visibility = "hidden"; // fix gecko rendering
|
465
|
-
dropon.parentNode.insertBefore(element, dropon);
|
466
|
-
if(dropon.parentNode!=oldParentNode && oldParentNode.sortable)
|
467
|
-
oldParentNode.sortable.onChange(element);
|
468
|
-
if(dropon.parentNode.sortable)
|
469
|
-
dropon.parentNode.sortable.onChange(element);
|
470
|
-
}
|
471
|
-
} else {
|
472
|
-
var nextElement = dropon.nextSibling || null;
|
473
|
-
if(nextElement != element) {
|
474
|
-
var oldParentNode = element.parentNode;
|
475
|
-
element.style.visibility = "hidden"; // fix gecko rendering
|
476
|
-
dropon.parentNode.insertBefore(element, nextElement);
|
477
|
-
if(dropon.parentNode!=oldParentNode && oldParentNode.sortable)
|
478
|
-
oldParentNode.sortable.onChange(element);
|
479
|
-
if(dropon.parentNode.sortable)
|
480
|
-
dropon.parentNode.sortable.onChange(element);
|
481
|
-
}
|
482
|
-
}
|
483
|
-
}
|
394
|
+
onHover: Sortable.onHover,
|
395
|
+
greedy: !options.dropOnEmpty
|
484
396
|
}
|
485
397
|
|
486
398
|
// fix for gecko engine
|
487
399
|
Element.cleanWhitespace(element);
|
488
|
-
|
400
|
+
|
489
401
|
options.draggables = [];
|
490
402
|
options.droppables = [];
|
491
|
-
|
492
|
-
// make it so
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
403
|
+
|
404
|
+
// make it so
|
405
|
+
|
406
|
+
// drop on empty handling
|
407
|
+
if(options.dropOnEmpty) {
|
408
|
+
Droppables.add(element,
|
409
|
+
{containment: options.containment, onHover: Sortable.onEmptyHover, greedy: false});
|
410
|
+
options.droppables.push(element);
|
411
|
+
}
|
412
|
+
|
413
|
+
(this.findElements(element, options) || []).each( function(e) {
|
414
|
+
// handles are per-draggable
|
415
|
+
var handle = options.handle ?
|
416
|
+
Element.Class.childrenWith(e, options.handle)[0] : e;
|
417
|
+
options.draggables.push(
|
418
|
+
new Draggable(e, Object.extend(options_for_draggable, { handle: handle })));
|
419
|
+
Droppables.add(e, options_for_droppable);
|
420
|
+
options.droppables.push(e);
|
421
|
+
});
|
422
|
+
|
509
423
|
// keep reference
|
510
424
|
this.sortables.push(options);
|
511
|
-
|
425
|
+
|
512
426
|
// for onupdate
|
513
427
|
Draggables.addObserver(new SortableObserver(element, options.onUpdate));
|
514
428
|
|
515
429
|
},
|
430
|
+
|
431
|
+
// return all suitable-for-sortable elements in a guaranteed order
|
432
|
+
findElements: function(element, options) {
|
433
|
+
if(!element.hasChildNodes()) return null;
|
434
|
+
var elements = [];
|
435
|
+
$A(element.childNodes).each( function(e) {
|
436
|
+
if(e.tagName && e.tagName==options.tag.toUpperCase() &&
|
437
|
+
(!options.only || (Element.Class.has(e, options.only))))
|
438
|
+
elements.push(e);
|
439
|
+
if(options.tree) {
|
440
|
+
var grandchildren = this.findElements(e, options);
|
441
|
+
if(grandchildren) elements.push(grandchildren);
|
442
|
+
}
|
443
|
+
});
|
444
|
+
|
445
|
+
return (elements.length>0 ? elements.flatten() : null);
|
446
|
+
},
|
447
|
+
|
448
|
+
onHover: function(element, dropon, overlap) {
|
449
|
+
if(overlap>0.5) {
|
450
|
+
Sortable.mark(dropon, 'before');
|
451
|
+
if(dropon.previousSibling != element) {
|
452
|
+
var oldParentNode = element.parentNode;
|
453
|
+
element.style.visibility = "hidden"; // fix gecko rendering
|
454
|
+
dropon.parentNode.insertBefore(element, dropon);
|
455
|
+
if(dropon.parentNode!=oldParentNode)
|
456
|
+
Sortable.options(oldParentNode).onChange(element);
|
457
|
+
Sortable.options(dropon.parentNode).onChange(element);
|
458
|
+
}
|
459
|
+
} else {
|
460
|
+
Sortable.mark(dropon, 'after');
|
461
|
+
var nextElement = dropon.nextSibling || null;
|
462
|
+
if(nextElement != element) {
|
463
|
+
var oldParentNode = element.parentNode;
|
464
|
+
element.style.visibility = "hidden"; // fix gecko rendering
|
465
|
+
dropon.parentNode.insertBefore(element, nextElement);
|
466
|
+
if(dropon.parentNode!=oldParentNode)
|
467
|
+
Sortable.options(oldParentNode).onChange(element);
|
468
|
+
Sortable.options(dropon.parentNode).onChange(element);
|
469
|
+
}
|
470
|
+
}
|
471
|
+
},
|
472
|
+
|
473
|
+
onEmptyHover: function(element, dropon) {
|
474
|
+
if(element.parentNode!=dropon) {
|
475
|
+
var oldParentNode = element.parentNode;
|
476
|
+
dropon.appendChild(element);
|
477
|
+
Sortable.options(oldParentNode).onChange(element);
|
478
|
+
Sortable.options(dropon).onChange(element);
|
479
|
+
}
|
480
|
+
},
|
481
|
+
|
482
|
+
unmark: function() {
|
483
|
+
if(Sortable._marker) Element.hide(Sortable._marker);
|
484
|
+
},
|
485
|
+
|
486
|
+
mark: function(dropon, position) {
|
487
|
+
// mark on ghosting only
|
488
|
+
var sortable = Sortable.options(dropon.parentNode);
|
489
|
+
if(sortable && !sortable.ghosting) return;
|
490
|
+
|
491
|
+
if(!Sortable._marker) {
|
492
|
+
Sortable._marker = $('dropmarker') || document.createElement('DIV');
|
493
|
+
Element.hide(Sortable._marker);
|
494
|
+
Element.Class.add(Sortable._marker, 'dropmarker');
|
495
|
+
Sortable._marker.style.position = 'absolute';
|
496
|
+
document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
|
497
|
+
}
|
498
|
+
var offsets = Position.cumulativeOffset(dropon);
|
499
|
+
Sortable._marker.style.top = offsets[1] + 'px';
|
500
|
+
if(position=='after') Sortable._marker.style.top = (offsets[1]+dropon.clientHeight) + 'px';
|
501
|
+
Sortable._marker.style.left = offsets[0] + 'px';
|
502
|
+
Element.show(Sortable._marker);
|
503
|
+
},
|
504
|
+
|
516
505
|
serialize: function(element) {
|
517
|
-
|
506
|
+
element = $(element);
|
518
507
|
var sortableOptions = this.options(element);
|
519
508
|
var options = Object.extend({
|
520
509
|
tag: sortableOptions.tag,
|
521
510
|
only: sortableOptions.only,
|
522
|
-
name: element.id
|
511
|
+
name: element.id,
|
512
|
+
format: sortableOptions.format || /^[^_]*_(.*)$/
|
523
513
|
}, arguments[1] || {});
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
for(var i=0; i<items.length; i++)
|
529
|
-
if(items[i].tagName && items[i].tagName==options.tag.toUpperCase() &&
|
530
|
-
(!options.only || (Element.Class.has(items[i], options.only))))
|
531
|
-
queryComponents.push(
|
532
|
-
encodeURIComponent(options.name) + "[]=" +
|
533
|
-
encodeURIComponent(items[i].id.split("_")[1]));
|
534
|
-
|
535
|
-
return queryComponents.join("&");
|
514
|
+
return $(this.findElements(element, options) || []).collect( function(item) {
|
515
|
+
return (encodeURIComponent(options.name) + "[]=" +
|
516
|
+
encodeURIComponent(item.id.match(options.format) ? item.id.match(options.format)[1] : ''));
|
517
|
+
}).join("&");
|
536
518
|
}
|
537
|
-
}
|
519
|
+
}
|